/plugin/codemirror/dist/modes/ |
H A D | javascript.min.js | 1 …Oa(a,b)}function Na(a,b){if(a=="variable"){E(b);return C(Oa)}}function Oa(a,b){if(b=="<")return C(… function
|
/plugin/diagramsnet/lib/math/extensions/a11y/ |
H A D | wgxpath.install.js | 42 …Oa(a){this.node=a;this.a=this.b=null}function Pa(a,b){if(!a.a)return b;if(!b.a)return a;for(var c=… class 43 function F(a,b){var c=new Oa(b);c.b=a.b;a.a?a.b.a=c:a.a=a.b=c;a.b=c;a.l++}function Ra(a){return(a=a…
|
/plugin/dokumicrobugtracker/js/ |
H A D | jquery.dataTables.min.js.gz |
|
H A D | jquery.dataTables.min.js | 81 b.bind("keypress.DT",function(d){if(d.keyCode==13)return false});return c}function N(a,b,c){Oa(a,b.… 82 …aoColumns[c].sType);if(!b.test(f)){a.aiDisplay.splice(d,1);e++}}}}function Oa(a,b,c,d,f){var e=pa(… 136 …s.oApi._fnFilterCustom=Qa;this.oApi._fnFilterColumn=Pa;this.oApi._fnFilter=Oa;this.oApi._fnBuildSe…
|
/plugin/datatables/assets/datatables.net/js/ |
H A D | jquery.dataTables.min.js | 70 (b=0),null===b?e.splice(c,1):(e[c][1]=f[b],e[c]._idx=b)):(e.push([b,f[0],0]),e[e.length-1]._idx=0)):e.length&&e[0][0]==b?(b=g(e[0]),e.length=1,e[0][1]=f[b],e[0]._idx=b):(e.length=0 global() function
|
/plugin/jquery/ |
H A D | jquery-1.4.2.min.js | 114 … kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha… variable 116 Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.… 117 …d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.…
|
/plugin/amcharts/assets/amcharts/ |
H A D | amcharts.js | 90 n=a.labelRotationR;var ia=a.counter,H=a.inside,Z=a.labelOffset,va=a.dx,ma=a.dy,Oa=a.orientation,ea=… 91 …bels&&(ga="middle");var T=n*Math.PI/180,Y,Ca,G=0,v=0,na=0,ha=Y=0,Pa=0;"V"==Oa&&(n=0);var ba;Q&&""!… 92 if("H"==Oa){if(0<=b&&b<=ya+1&&(0<B&&0<z&&b+l<=ya+1&&(fa=d.line(x,[b+l,b+l],[0,B],A,z,D),y.push(fa))… 153 …&&(Z="scrollbar-graph-column-");var va=this.categoryAxis,ma=this.baseCoord,Oa=this.negativeBase,ea… 154 …et&&(this.bullet="round",this.resetBullet=!0),!Qa&&void 0==Ja||m))){var Ua=Oa;Ua>f.max&&(Ua=f.max)… 161 …1;isNaN(W)||(m?W>Ta?(Sa&&($a=!0),Sa=!1):(Sa||($a=!0),Sa=!0):v.isNegative=W<Oa?!0:!1,za=W);var Ob=!… 167 (v.isNegative=W<Oa?!0:!1);v.isNegative&&(Qa&&(Ma=Qa),void 0!=Ja&&(Aa=Ja));var Pb=f.min,Qb=f.max,ob=…
|
/plugin/bpmnio/vendor/bpmn-js/dist/ |
H A D | bpmn-modeler.production.min.js | 27 function(e){const t=he('<a href="http://bpmn.io" target="_blank" class="bjs-powered-by" title="Powered by bpmn.io" >'+Er+"</a>");q(fe("svg",t),Sr),q(t,Cr,{position:"absolute",bottom:"15px",right:"15px",zIndex:"100"}),e.appendChild(t),oe.bind(t,"click",(function(e){Mr(),e.preventDefault()}))}(this._container)}function Dr(e,t){return e.warnings=t,e}e(Tr,Zn),Tr.prototype.importXML=async function(e,t){const n=this;let i=[];try{let o;e=this._emit("import.parse.start",{xml:e})||e;try{o=await this._moddle.fromXML(e,"bpmn:Definitions")}catch(e){throw this._emit("import.parse.complete",{error:e}),e}let a=o.rootElement;const s=o.references,c=o.warnings,p=o.elementsById;i=i.concat(c),a=this._emit("import.parse.complete",(r={error:null,definitions:a,elementsById:p,references:s,warnings:i},n.get("eventBus").createEvent(r)))||a;const l=await this.importDefinitions(a,t);return i=i.concat(l.warnings),this._emit("import.done",{error:null,warnings:i}),{warnings:i}}catch(e){let t=e;throw i=i.concat(t.warnings||[]),Dr(t,i),t=function(e){const t=/unparsable content <([^>]+)> detected([\s\S]*)$/.exec(e.message);t&&(e.message="unparsable content <"+t[1]+"> detected; this may indicate an invalid BPMN 2.0 diagram file"+t[2]);return e}(t),this._emit("import.done",{error:t,warnings:t.warnings}),t}var r},Tr.prototype.importDefinitions=async function(e,t){this._setDefinitions(e);return{warnings:(await this.open(t)).warnings}},Tr.prototype.open=async function(e){const t=this._definitions;let n=e;if(!t){const e=new Error("no XML imported");throw Dr(e,[]),e}if("string"==typeof e&&(n=function(e,t){if(!t)return null;return m(e.diagrams,(function(e){return e.id===t}))||null}(t,e),!n)){const t=new Error("BPMNDiagram <"+e+"> not found");throw Dr(t,[]),t}try{this.clear()}catch(e){throw Dr(e,[]),e}const{warnings:i}=await _r(this,t,n);return{warnings:i}},Tr.prototype.saveXML=async function(e){e=e||{};let t,n,i=this._definitions;try{if(!i)throw new Error("no definitions loaded");i=this._emit("saveXML.start",{definitions:i})||i;n=(await this._moddle.toXML(i,e)).xml,n=this._emit("saveXML.serialized",{xml:n})||n}catch(e){t=e}const r=t?{error:t}:{xml:n};if(this._emit("saveXML.done",r),t)throw t;return r},Tr.prototype.saveSVG=async function(){let e,t;this._emit("saveSVG.start");try{const t=this.get("canvas"),n=t.getActiveLayer(),i=fe(":scope > defs",t._svg),r=Ie(n),o=i?"<defs>"+Ie(i)+"</defs>":"",a=n.getBBox();e='<?xml version="1.0" encoding="utf-8"?>\n\x3c!-- created with bpmn-js / http://bpmn.io --\x3e\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'+a.width+'" height="'+a.height+'" viewBox="'+a.x+" "+a.y+" "+a.width+" "+a.height+'" version="1.1">'+o+r+"</svg>"}catch(e){t=e}if(this._emit("saveSVG.done",{error:t,svg:e}),t)throw t;return{svg:e}},Tr.prototype._setDefinitions=function(e){this._definitions=e},Tr.prototype.getModules=function(){return this._modules},Tr.prototype.clear=function(){this.getDefinitions()&&Zn.prototype.clear.call(this)},Tr.prototype.destroy=function(){Zn.prototype.destroy.call(this),ve(this._container)},Tr.prototype.on=function(e,t,n,i){return this.get("eventBus").on(e,t,n,i)},Tr.prototype.off=function(e,t){this.get("eventBus").off(e,t)},Tr.prototype.attachTo=function(e){if(!e)throw new Error("parentNode required");this.detach(),e.get&&e.constructor.prototype.jquery&&(e=e.get(0)),"string"==typeof e&&(e=fe(e)),e.appendChild(this._container),this._emit("attach",{}),this.get("canvas").resized()},Tr.prototype.getDefinitions=function(){return this._definitions},Tr.prototype.detach=function(){const e=this._container,t=e.parentNode;t&&(this._emit("detach",{}),t.removeChild(e))},Tr.prototype._init=function(e,t,n){const i=n.modules||this.getModules(n),r=n.additionalModules||[],o=[].concat([{bpmnjs:["value",this],moddle:["value",t]}],i,r),a=L(I(n,["additionalModules"]),{canvas:L({},n.canvas,{container:e}),modules:o});Zn.call(this,a),n&&n.container&&this.attachTo(n.container)},Tr.prototype._emit=function(e,t){return this.get("eventBus").fire(e,t)},Tr.prototype._createContainer=function(e){const t=he('<div class="bjs-container"></div>');return q(t,{width:Nr(e.width),height:Nr(e.height),position:e.position}),t},Tr.prototype._createModdle=function(e){return new ur(L({},this._moddleExtensions,e.moddleExtensions))},Tr.prototype._modules=[];const Br={width:"100%",height:"100%",position:"relative"};function Nr(e){return e+(u(e)?"px":"")}function jr(e){Tr.call(this,e),this.on("import.parse.complete",(function(e){e.error||this._collectIds(e.definitions,e.elementsById)}),this),this.on("diagram.destroy",(function(){this.get("moddle").ids.clear()}),this)}function Or(e,t){return!vr(e,"bpmn:CallActivity")&&(vr(e,"bpmn:SubProcess")?!(!(t=t||br(e))||!vr(t,"bpmndi:BPMNPlane"))||t&&!!t.isExpanded:!vr(e,"bpmn:Participant")||!!gr(e).processRef)}function Lr(e){if(vr(e,"bpmn:Participant")||vr(e,"bpmn:Lane")){var t=br(e).isHorizontal;return void 0===t||t}}function $r(e){return e&&!!gr(e).triggeredByEvent}function Ir(e,t){return w(gr(e).eventDefinitions,(function(e){return vr(e,t)}))}e(jr,Tr),jr.prototype._createModdle=function(e){var t=Tr.prototype._createModdle.call(this,e);return t.ids=new n([32,36,1]),t},jr.prototype._collectIds=function(e,t){var n,i=e.$model.ids;for(n in i.clear(),t)i.claim(n,t[n])};var Fr={width:90,height:20};function zr(e){return vr(e,"bpmn:Event")||vr(e,"bpmn:Gateway")||vr(e,"bpmn:DataStoreReference")||vr(e,"bpmn:DataObjectReference")||vr(e,"bpmn:DataInput")||vr(e,"bpmn:DataOutput")||vr(e,"bpmn:SequenceFlow")||vr(e,"bpmn:MessageFlow")||vr(e,"bpmn:Group")}function Hr(e){return cn(e.label)}function Vr(e){var t=e.length/2-1,n=e[Math.floor(t)],i=e[Math.ceil(t+.01)],r=function(e){var t=e.length/2-1,n=e[Math.floor(t)],i=e[Math.ceil(t+.01)];return{x:n.x+(i.x-n.x)/2,y:n.y+(i.y-n.y)/2}}(e),o=Math.atan((i.y-n.y)/(i.x-n.x)),a=r.x,s=r.y;return Math.abs(o)<Math.PI/2?s-=15:a+=15,{x:a,y:s}}function Gr(e){return e.waypoints?Vr(e.waypoints):vr(e,"bpmn:Group")?{x:e.x+e.width/2,y:e.y+Fr.height/2}:{x:e.x+e.width/2,y:e.y+e.height+Fr.height/2}}function Wr(e){return vr(e,"bpmn:FlowElement")||vr(e,"bpmn:Participant")||vr(e,"bpmn:Lane")||vr(e,"bpmn:SequenceFlow")||vr(e,"bpmn:MessageFlow")||vr(e,"bpmn:DataInput")||vr(e,"bpmn:DataOutput")?"name":vr(e,"bpmn:TextAnnotation")?"text":vr(e,"bpmn:Group")?"categoryValueRef":void 0}function Ur(e){var t=e.businessObject,n=Wr(t);if(n)return"categoryValueRef"===n?function(e){var t=e.categoryValueRef;return t&&t.value||""}(t):t[n]||""}var qr="hsl(225, 10%, 15%)";function Kr(e,t){return w(e.eventDefinitions,(function(e){return e.$type===t}))}function Yr(e,t,n){var i=br(e);return n||i.get("color:background-color")||i.get("bioc:fill")||t||"white"}function Xr(e,t,n){var i=br(e);return n||i.get("color:border-color")||i.get("bioc:stroke")||t||qr}function Zr(e,t,n,i){var r=br(e).get("label");return i||r&&r.get("color:color")||t||Xr(e,n)}function Qr(e,t={}){return{width:Jr(e,t),height:eo(e,t)}}function Jr(e,t={}){return f(t,"width")?t.width:e.width}function eo(e,t={}){return f(t,"height")?t.height:e.height}var to=new n,no=.95;function io(e,t,n,i,r,o,a){Je.call(this,t,a);var s=e&&e.defaultFillColor,c=e&&e.defaultStrokeColor,p=e&&e.defaultLabelColor;function u(e){return n.computeStyle(e,{strokeLinecap:"round",strokeLinejoin:"round",stroke:qr,strokeWidth:2,fill:"white"})}function h(e){return n.computeStyle(e,["no-fill"],{strokeLinecap:"round",strokeLinejoin:"round",stroke:qr,strokeWidth:2})}function d(e,t){var{ref:n={x:0,y:0},scale:i=1,element:o,parentGfx:a=r._svg}=t,s=Ae("marker",{id:e,viewBox:"0 0 20 20",refX:n.x,refY:n.y,markerWidth:20*i,markerHeight:20*i,orient:"auto"});ye(s,o);var c=fe(":scope > defs",a);c||ye(a,c=Ae("defs")),ye(c,s)}function f(e,t,n,i){var r=to.nextPrefixed("marker-");return function(e,t,n,i,r){if("sequenceflow-end"===n){d(t,{element:Ae("path",{d:"M 1 5 L 11 10 L 1 15 Z",...u({fill:r,stroke:r,strokeWidth:1})}),ref:{x:11,y:10},scale:.5,parentGfx:e})}if("messageflow-start"===n){d(t,{element:Ae("circle",{cx:6,cy:6,r:3.5,...u({fill:i,stroke:r,strokeWidth:1,strokeDasharray:[1e4,1]})}),ref:{x:6,y:6},parentGfx:e})}if("messageflow-end"===n){d(t,{element:Ae("path",{d:"m 1 5 l 0 -3 l 7 3 l -7 3 z",...u({fill:i,stroke:r,strokeWidth:1,strokeDasharray:[1e4,1]})}),ref:{x:8.5,y:5},parentGfx:e})}if("association-start"===n){d(t,{element:Ae("path",{d:"M 11 5 L 1 10 L 11 15",...h({fill:"none",stroke:r,strokeWidth:1.5,strokeDasharray:[1e4,1]})}),ref:{x:1,y:10},scale:.5,parentGfx:e})}if("association-end"===n){d(t,{element:Ae("path",{d:"M 1 5 L 11 10 L 1 15",...h({fill:"none",stroke:r,strokeWidth:1.5,strokeDasharray:[1e4,1]})}),ref:{x:11,y:10},scale:.5,parentGfx:e})}if("conditional-flow-marker"===n){d(t,{element:Ae("path",{d:"M 0 10 L 8 6 L 16 10 L 8 14 Z",...u({fill:i,stroke:r})}),ref:{x:-1,y:10},scale:.5,parentGfx:e})}if("conditional-default-flow-marker"===n){d(t,{element:Ae("path",{d:"M 6 4 L 10 16",...u({stroke:r,fill:"none"})}),ref:{x:0,y:10},scale:.5,parentGfx:e})}}(e,r,t,n,i),"url(#"+r+")"}function m(e,t,n,i,r={}){l(i)&&(r=i,i=0),i=i||0,r=u(r);var o=Ae("circle",{cx:t/2,cy:n/2,r:Math.round((t+n)/4-i),...r});return ye(e,o),o}function v(e,t,n,i,r,o){l(r)&&(o=r,r=0),r=r||0,o=u(o);var a=Ae("rect",{x:r,y:r,width:t-2*r,height:n-2*r,rx:i,ry:i,...o});return ye(e,a),a}function y(e,t,n,i){var r=ot(t,n=h(n),i);return ye(e,r),r}function b(e,t,n){return y(e,t,n,5)}function _(e,t,n){n=h(n);var i=Ae("path",{...n,d:t});return ye(e,i),i}function x(e,t,n,i){return _(t,n,L({"data-marker":e},i))}function w(e){return Q[e]}function E(e){return function(t,n,i){return w(e)(t,n,i)}}var S=function(e,t,n={},r){return _(e,i.getScaledPath("EVENT_MESSAGE",{xScaleFactor:.9,yScaleFactor:.9,containerWidth:t.width,containerHeight:t.height,position:{mx:.235,my:.315}}),{fill:r?Xr(t,c,n.stroke):Yr(t,s,n.fill),stroke:r?Yr(t,s,n.fill):Xr(t,c,n.stroke),strokeWidth:1})},C=function(e,t,n={}){var r=m(e,t.width,t.height,.2*t.height,{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:2});_(e,i.getScaledPath("EVENT_TIMER_WH",{xScaleFactor:.75,yScaleFactor:.75,containerWidth:t.width,containerHeight:t.height,position:{mx:.5,my:.5}}),{stroke:Xr(t,c,n.stroke),strokeWidth:2});for(var o=0;o<12;o++){var a=i.getScaledPath("EVENT_TIMER_LINE",{xScaleFactor:.75,yScaleFactor:.75,containerWidth:t.width,containerHeight:t.height,position:{mx:.5,my:.5}}),p=t.width/2,l=t.height/2;_(e,a,{strokeWidth:1,stroke:Xr(t,c,n.stroke),transform:"rotate("+30*o+","+l+","+p+")"})}return r},k=function(e,t,n={},r){return _(e,i.getScaledPath("EVENT_ESCALATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:.5,my:.2}}),{fill:r?Xr(t,c,n.stroke):Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:1})},R=function(e,t,n={}){return _(e,i.getScaledPath("EVENT_CONDITIONAL",{xScaleFactor:1,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:.5,my:.222}}),{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:1})},P=function(e,t,n={},r){return _(e,i.getScaledPath("EVENT_LINK",{xScaleFactor:1,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:.57,my:.263}}),{fill:r?Xr(t,c,n.stroke):Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:1})},A=function(e,t,n={},r){return _(e,i.getScaledPath("EVENT_ERROR",{xScaleFactor:1.1,yScaleFactor:1.1,containerWidth:t.width,containerHeight:t.height,position:{mx:.2,my:.722}}),{fill:r?Xr(t,c,n.stroke):Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:1})},M=function(e,t,n={},r){var o=_(e,i.getScaledPath("EVENT_CANCEL_45",{xScaleFactor:1,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:.638,my:-.055}}),{fill:r?Xr(t,c,n.stroke):"none",stroke:Xr(t,c,n.stroke),strokeWidth:1});return Un(o,45),o},T=function(e,t,n={},r){return _(e,i.getScaledPath("EVENT_COMPENSATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:.22,my:.5}}),{fill:r?Xr(t,c,n.stroke):Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:1})},D=function(e,t,n={},r){return _(e,i.getScaledPath("EVENT_SIGNAL",{xScaleFactor:.9,yScaleFactor:.9,containerWidth:t.width,containerHeight:t.height,position:{mx:.5,my:.2}}),{strokeWidth:1,fill:r?Xr(t,c,n.stroke):Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke)})},B=function(e,t,n={},r){return _(e,i.getScaledPath("EVENT_MULTIPLE",{xScaleFactor:1.1,yScaleFactor:1.1,containerWidth:t.width,containerHeight:t.height,position:{mx:.222,my:.36}}),{fill:r?Xr(t,c,n.stroke):Yr(t,s,n.fill),strokeWidth:1})},N=function(e,t,n={}){return _(e,i.getScaledPath("EVENT_PARALLEL_MULTIPLE",{xScaleFactor:1.2,yScaleFactor:1.2,containerWidth:t.width,containerHeight:t.height,position:{mx:.458,my:.194}}),{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:1})},j=function(e,t,n={}){return m(e,t.width,t.height,8,{fill:Xr(t,c,n.stroke),stroke:Xr(t,c,n.stroke),strokeWidth:4})};function O(e,t,n={}){var i=gr(e),r=function(e){return"bpmn:IntermediateThrowEvent"===e.$type||"bpmn:EndEvent"===e.$type}(i);return i.get("eventDefinitions")&&i.get("eventDefinitions").length>1?i.get("parallelMultiple")?N(t,e,n,r):B(t,e,n,r):Kr(i,"bpmn:MessageEventDefinition")?S(t,e,n,r):Kr(i,"bpmn:TimerEventDefinition")?C(t,e,n,r):Kr(i,"bpmn:ConditionalEventDefinition")?R(t,e,n,r):Kr(i,"bpmn:SignalEventDefinition")?D(t,e,n,r):Kr(i,"bpmn:EscalationEventDefinition")?k(t,e,n,r):Kr(i,"bpmn:LinkEventDefinition")?P(t,e,n,r):Kr(i,"bpmn:ErrorEventDefinition")?A(t,e,n,r):Kr(i,"bpmn:CancelEventDefinition")?M(t,e,n,r):Kr(i,"bpmn:CompensateEventDefinition")?T(t,e,n,r):Kr(i,"bpmn:TerminateEventDefinition")?j(t,e,n,r):null}var $={ParticipantMultiplicityMarker:function(e,t,n={}){var r=Jr(t,n),o=eo(t,n);x("participant-multiplicity",e,i.getScaledPath("MARKER_PARALLEL",{xScaleFactor:1,yScaleFactor:1,containerWidth:r,containerHeight:o,position:{mx:(r/2-6)/r,my:(o-15)/o}}),{strokeWidth:2,fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke)})},SubProcessMarker:function(e,t,n={}){Wn(v(e,14,14,0,{strokeWidth:1,fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke)}),t.width/2-7.5,t.height-20),x("sub-process",e,i.getScaledPath("MARKER_SUB_PROCESS",{xScaleFactor:1.5,yScaleFactor:1.5,containerWidth:t.width,containerHeight:t.height,position:{mx:(t.width/2-7.5)/t.width,my:(t.height-20)/t.height}}),{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke)})},ParallelMarker:function(e,t,n){var r=Jr(t,n),o=eo(t,n);x("parallel",e,i.getScaledPath("MARKER_PARALLEL",{xScaleFactor:1,yScaleFactor:1,containerWidth:r,containerHeight:o,position:{mx:(r/2+n.parallel)/r,my:(o-20)/o}}),{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke)})},SequentialMarker:function(e,t,n){x("sequential",e,i.getScaledPath("MARKER_SEQUENTIAL",{xScaleFactor:1,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:(t.width/2+n.seq)/t.width,my:(t.height-19)/t.height}}),{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke)})},CompensationMarker:function(e,t,n){x("compensation",e,i.getScaledPath("MARKER_COMPENSATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:(t.width/2+n.compensation)/t.width,my:(t.height-13)/t.height}}),{strokeWidth:1,fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke)})},LoopMarker:function(e,t,n){var r=Jr(t,n),o=eo(t,n);x("loop",e,i.getScaledPath("MARKER_LOOP",{xScaleFactor:1,yScaleFactor:1,containerWidth:r,containerHeight:o,position:{mx:(r/2+n.loop)/r,my:(o-7)/o}}),{strokeWidth:1.5,fill:"none",stroke:Xr(t,c,n.stroke),strokeMiterlimit:.5})},AdhocMarker:function(e,t,n){var r=Jr(t,n),o=eo(t,n);x("adhoc",e,i.getScaledPath("MARKER_ADHOC",{xScaleFactor:1,yScaleFactor:1,containerWidth:r,containerHeight:o,position:{mx:(r/2+n.adhoc)/r,my:(o-15)/o}}),{strokeWidth:1,fill:Xr(t,c,n.stroke),stroke:Xr(t,c,n.stroke)})}};function I(e,t,n,i){$[e](t,n,i)}function F(e,t,n,i={}){i={fill:i.fill,stroke:i.stroke,width:Jr(t,i),height:eo(t,i)};var r=gr(t),o=n&&n.includes("SubProcessMarker");i=o?{...i,seq:-21,parallel:-22,compensation:-42,loop:-18,adhoc:10}:{...i,seq:-5,parallel:-6,compensation:-27,loop:0,adhoc:10},g(n,(function(n){I(n,e,t,i)})),r.get("isForCompensation")&&I("CompensationMarker",e,t,i),vr(r,"bpmn:AdHocSubProcess")&&I("AdhocMarker",e,t,i);var a=r.get("loopCharacteristics"),s=a&&a.get("isSequential");a&&(void 0===s&&I("LoopMarker",e,t,i),!1===s&&I("ParallelMarker",e,t,i),!0===s&&I("SequentialMarker",e,t,i))}function z(e,t,n={}){n=L({size:{width:100}},n);var i=o.createText(t||"",n);return we(i).add("djs-label"),ye(e,i),i}function H(e,t,n,i={}){var r=gr(t),o=Qr({x:t.x,y:t.y,width:t.width,height:t.height},i);return z(e,r.name,{align:n,box:o,padding:7,style:{fill:Zr(t,p,c,i.stroke)}})}function V(e,t,n,i={}){var r=Lr(n),o=z(e,t,{box:{height:30,width:r?eo(n,i):Jr(n,i)},align:"center-middle",style:{fill:Zr(n,p,c,i.stroke)}});r&&Gn(o,0,-(-1*eo(n,i)),270)}function G(e,t,n={}){var{width:i,height:r}=Qr(t,n);return v(e,i,r,10,{...n,fill:Yr(t,s,n.fill),fillOpacity:no,stroke:Xr(t,c,n.stroke)})}function W(e,t,n={}){var i=gr(t),r=Yr(t,s,n.fill),o=Xr(t,c,n.stroke);return"One"!==i.get("associationDirection")&&"Both"!==i.get("associationDirection")||(n.markerEnd=f(e,"association-end",r,o)),"Both"===i.get("associationDirection")&&(n.markerStart=f(e,"association-start",r,o)),n=ro(n,["markerStart","markerEnd"]),b(e,t.waypoints,{...n,stroke:o,strokeDasharray:"0, 5"})}function U(e,t,n={}){var r=Yr(t,s,n.fill),o=Xr(t,c,n.stroke),a=_(e,i.getScaledPath("DATA_OBJECT_PATH",{xScaleFactor:1,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:.474,my:.296}}),{fill:r,fillOpacity:no,stroke:o});(function(e){var t=e.dataObjectRef;return e.isCollection||t&&t.isCollection})(gr(t))&&_(e,i.getScaledPath("DATA_OBJECT_COLLECTION_PATH",{xScaleFactor:1,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:.33,my:(t.height-18)/t.height}}),{strokeWidth:2,fill:r,stroke:o});return a}function q(e,t,n={}){return m(e,t.width,t.height,{fillOpacity:no,...n,fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke)})}function K(e,t,n={}){return function(e,t,n,i){var r=t/2,o=n/2,a=[{x:r,y:0},{x:t,y:o},{x:r,y:n},{x:0,y:o}].map((function(e){return e.x+","+e.y})).join(" ");i=u(i);var s=Ae("polygon",{...i,points:a});return ye(e,s),s}(e,t.width,t.height,{fill:Yr(t,s,n.fill),fillOpacity:no,stroke:Xr(t,c,n.stroke)})}function Y(e,t,n={}){var i=v(e,Jr(t,n),eo(t,n),0,{fill:Yr(t,s,n.fill),fillOpacity:n.fillOpacity||no,stroke:Xr(t,c,n.stroke),strokeWidth:1.5}),r=gr(t);vr(r,"bpmn:Lane")&&V(e,r.get("name"),t,n);return i}function X(e,t,n={}){var i=G(e,t,n);$r(t)&&_e(i,{strokeDasharray:"0, 5.5",strokeWidth:2.5});var r=Or(t);return H(e,t,r?"center-top":"center-middle",n),F(e,t,r?void 0:["SubProcessMarker"],n),i}function Z(e,t,n={}){var i=G(e,t,n);return H(e,t,"center-middle",n),F(e,t,void 0,n),i}var Q=this.handlers={"bpmn:AdHocSubProcess":function(e,t,n={}){return X(e,t,n=Or(t)?ro(n,["fill","stroke","width","height"]):ro(n,["fill","stroke"]))},"bpmn:Association":function(e,t,n={}){return W(e,t,n=ro(n,["fill","stroke"]))},"bpmn:BoundaryEvent":function(e,t,n={}){var{renderIcon:i=!0}=n;n=ro(n,["fill","stroke"]);var r=gr(t).get("cancelActivity");n={strokeWidth:1.5,fill:Yr(t,s,n.fill),fillOpacity:1,stroke:Xr(t,c,n.stroke)},r||(n.strokeDasharray="6");var o=q(e,t,n);return m(e,t.width,t.height,3,{...n,fill:"none"}),i&&O(t,e,n),o},"bpmn:BusinessRuleTask":function(e,t,n={}){var r=Z(e,t,n=ro(n,["fill","stroke"]));return _e(_(e,i.getScaledPath("TASK_TYPE_BUSINESS_RULE_MAIN",{abspos:{x:8,y:8}})),{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:1}),_e(_(e,i.getScaledPath("TASK_TYPE_BUSINESS_RULE_HEADER",{abspos:{x:8,y:8}})),{fill:Xr(t,c,n.stroke),stroke:Xr(t,c,n.stroke),strokeWidth:1}),r},"bpmn:CallActivity":function(e,t,n={}){return n=ro(n,["fill","stroke"]),X(e,t,{strokeWidth:5,...n})},"bpmn:ComplexGateway":function(e,t,n={}){var r=K(e,t,n=ro(n,["fill","stroke"]));return _(e,i.getScaledPath("GATEWAY_COMPLEX",{xScaleFactor:.5,yScaleFactor:.5,containerWidth:t.width,containerHeight:t.height,position:{mx:.46,my:.26}}),{fill:Xr(t,c,n.stroke),stroke:Xr(t,c,n.stroke),strokeWidth:1}),r},"bpmn:DataInput":function(e,t,n={}){n=ro(n,["fill","stroke"]);var r=i.getRawPath("DATA_ARROW"),o=U(e,t,n);return _(e,r,{fill:"none",stroke:Xr(t,c,n.stroke),strokeWidth:1}),o},"bpmn:DataInputAssociation":function(e,t,n={}){return n=ro(n,["fill","stroke"]),W(e,t,{...n,markerEnd:f(e,"association-end",Yr(t,s,n.fill),Xr(t,c,n.stroke))})},"bpmn:DataObject":function(e,t,n={}){return U(e,t,n=ro(n,["fill","stroke"]))},"bpmn:DataObjectReference":E("bpmn:DataObject"),"bpmn:DataOutput":function(e,t,n={}){n=ro(n,["fill","stroke"]);var r=i.getRawPath("DATA_ARROW"),o=U(e,t,n);return _(e,r,{strokeWidth:1,fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke)}),o},"bpmn:DataOutputAssociation":function(e,t,n={}){return n=ro(n,["fill","stroke"]),W(e,t,{...n,markerEnd:f(e,"association-end",Yr(t,s,n.fill),Xr(t,c,n.stroke))})},"bpmn:DataStoreReference":function(e,t,n={}){return n=ro(n,["fill","stroke"]),_(e,i.getScaledPath("DATA_STORE",{xScaleFactor:1,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:0,my:.133}}),{fill:Yr(t,s,n.fill),fillOpacity:no,stroke:Xr(t,c,n.stroke),strokeWidth:2})},"bpmn:EndEvent":function(e,t,n={}){var{renderIcon:i=!0}=n;n=ro(n,["fill","stroke"]);var r=q(e,t,{...n,strokeWidth:4});return i&&O(t,e,n),r},"bpmn:EventBasedGateway":function(e,t,n={}){n=ro(n,["fill","stroke"]);var r=gr(t),o=K(e,t,n);m(e,t.width,t.height,.2*t.height,{fill:Yr(t,"none",n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:1});var a=r.get("eventGatewayType"),s=!!r.get("instantiate");if("Parallel"===a){var p=i.getScaledPath("GATEWAY_PARALLEL",{xScaleFactor:.4,yScaleFactor:.4,containerWidth:t.width,containerHeight:t.height,position:{mx:.474,my:.296}});_(e,p,{fill:"none",stroke:Xr(t,c,n.stroke),strokeWidth:1})}else"Exclusive"===a&&(s||m(e,t.width,t.height,.26*t.height,{fill:"none",stroke:Xr(t,c,n.stroke),strokeWidth:1}),function(){var r=i.getScaledPath("GATEWAY_EVENT_BASED",{xScaleFactor:.18,yScaleFactor:.18,containerWidth:t.width,containerHeight:t.height,position:{mx:.36,my:.44}});_(e,r,{fill:"none",stroke:Xr(t,c,n.stroke),strokeWidth:2})}());return o},"bpmn:ExclusiveGateway":function(e,t,n={}){var r=K(e,t,n=ro(n,["fill","stroke"])),o=i.getScaledPath("GATEWAY_EXCLUSIVE",{xScaleFactor:.4,yScaleFactor:.4,containerWidth:t.width,containerHeight:t.height,position:{mx:.32,my:.3}});return br(t).get("isMarkerVisible")&&_(e,o,{fill:Xr(t,c,n.stroke),stroke:Xr(t,c,n.stroke),strokeWidth:1}),r},"bpmn:Gateway":function(e,t,n={}){return K(e,t,n=ro(n,["fill","stroke"]))},"bpmn:Group":function(e,t,n={}){return n=ro(n,["fill","stroke","width","height"]),v(e,t.width,t.height,10,{stroke:Xr(t,c,n.stroke),strokeWidth:1.5,strokeDasharray:"10, 6, 0, 6",fill:"none",pointerEvents:"none",width:Jr(t,n),height:eo(t,n)})},"bpmn:InclusiveGateway":function(e,t,n={}){var i=K(e,t,n=ro(n,["fill","stroke"]));return m(e,t.width,t.height,.24*t.height,{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:2.5}),i},"bpmn:IntermediateEvent":function(e,t,n={}){var{renderIcon:i=!0}=n;n=ro(n,["fill","stroke"]);var r=q(e,t,{...n,strokeWidth:1.5});return m(e,t.width,t.height,3,{fill:"none",stroke:Xr(t,c,n.stroke),strokeWidth:1.5}),i&&O(t,e,n),r},"bpmn:IntermediateCatchEvent":E("bpmn:IntermediateEvent"),"bpmn:IntermediateThrowEvent":E("bpmn:IntermediateEvent"),"bpmn:Lane":function(e,t,n={}){return n=ro(n,["fill","stroke","width","height"]),Y(e,t,{...n,fillOpacity:.25})},"bpmn:ManualTask":function(e,t,n={}){var r=Z(e,t,n=ro(n,["fill","stroke"]));return _(e,i.getScaledPath("TASK_TYPE_MANUAL",{abspos:{x:17,y:15}}),{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:.5}),r},"bpmn:MessageFlow":function(e,t,n={}){n=ro(n,["fill","stroke"]);var r=gr(t),o=br(t),a=Yr(t,s,n.fill),p=Xr(t,c,n.stroke),l=b(e,t.waypoints,{markerEnd:f(e,"messageflow-end",a,p),markerStart:f(e,"messageflow-start",a,p),stroke:p,strokeDasharray:"10, 11",strokeWidth:1.5});if(r.get("messageRef")){var u=l.getPointAtLength(l.getTotalLength()/2),h=i.getScaledPath("MESSAGE_FLOW_MARKER",{abspos:{x:u.x,y:u.y}}),d={strokeWidth:1};"initiating"===o.get("messageVisibleKind")?(d.fill=a,d.stroke=p):(d.fill=p,d.stroke=a);var m=_(e,h,d),v=z(e,r.get("messageRef").get("name"),{align:"center-top",fitBox:!0,style:{fill:p}}),y=m.getBBox(),g=v.getBBox();Gn(v,u.x-g.width/2,u.y+y.height/2+10,0)}return l},"bpmn:ParallelGateway":function(e,t,n={}){var r=K(e,t,n=ro(n,["fill","stroke"]));return _(e,i.getScaledPath("GATEWAY_PARALLEL",{xScaleFactor:.6,yScaleFactor:.6,containerWidth:t.width,containerHeight:t.height,position:{mx:.46,my:.2}}),{fill:Xr(t,c,n.stroke),stroke:Xr(t,c,n.stroke),strokeWidth:1}),r},"bpmn:Participant":function(e,t,n={}){var i=Y(e,t,n=ro(n,["fill","stroke","width","height"])),r=Or(t),o=Lr(t),a=gr(t),s=a.get("name");if(r){y(e,o?[{x:30,y:0},{x:30,y:eo(t,n)}]:[{x:0,y:30},{x:Jr(t,n),y:30}],{stroke:Xr(t,c,n.stroke),strokeWidth:1.5}),V(e,s,t,n)}else{var l=Qr(t,n);o||(l.height=Jr(t,n),l.width=eo(t,n));var u=z(e,s,{box:l,align:"center-middle",style:{fill:Zr(t,p,c,n.stroke)}});if(!o)Gn(u,0,-(-1*eo(t,n)),270)}return a.get("participantMultiplicity")&&I("ParticipantMultiplicityMarker",e,t,n),i},"bpmn:ReceiveTask":function(e,t,n={}){n=ro(n,["fill","stroke"]);var r,o=gr(t),a=Z(e,t,n);return o.get("instantiate")?(m(e,28,28,4.4,{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:1}),r=i.getScaledPath("TASK_TYPE_INSTANTIATING_SEND",{abspos:{x:7.77,y:9.52}})):r=i.getScaledPath("TASK_TYPE_SEND",{xScaleFactor:.9,yScaleFactor:.9,containerWidth:21,containerHeight:14,position:{mx:.3,my:.4}}),_(e,r,{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:1}),a},"bpmn:ScriptTask":function(e,t,n={}){var r=Z(e,t,n=ro(n,["fill","stroke"]));return _(e,i.getScaledPath("TASK_TYPE_SCRIPT",{abspos:{x:15,y:20}}),{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:1}),r},"bpmn:SendTask":function(e,t,n={}){var r=Z(e,t,n=ro(n,["fill","stroke"]));return _(e,i.getScaledPath("TASK_TYPE_SEND",{xScaleFactor:1,yScaleFactor:1,containerWidth:21,containerHeight:14,position:{mx:.285,my:.357}}),{fill:Xr(t,c,n.stroke),stroke:Yr(t,s,n.fill),strokeWidth:1}),r},"bpmn:SequenceFlow":function(e,t,n={}){n=ro(n,["fill","stroke"]);var i=Yr(t,s,n.fill),r=Xr(t,c,n.stroke),o=b(e,t.waypoints,{markerEnd:f(e,"sequenceflow-end",i,r),stroke:r}),a=gr(t),{source:p}=t;if(p){var l=gr(p);a.get("conditionExpression")&&vr(l,"bpmn:Activity")&&_e(o,{markerStart:f(e,"conditional-flow-marker",i,r)}),l.get("default")&&(vr(l,"bpmn:Gateway")||vr(l,"bpmn:Activity"))&&l.get("default")===a&&_e(o,{markerStart:f(e,"conditional-default-flow-marker",i,r)})}return o},"bpmn:ServiceTask":function(e,t,n={}){var r=Z(e,t,n=ro(n,["fill","stroke"]));return m(e,10,10,{fill:Yr(t,s,n.fill),stroke:"none",transform:"translate(6, 6)"}),_(e,i.getScaledPath("TASK_TYPE_SERVICE",{abspos:{x:12,y:18}}),{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:1}),m(e,10,10,{fill:Yr(t,s,n.fill),stroke:"none",transform:"translate(11, 10)"}),_(e,i.getScaledPath("TASK_TYPE_SERVICE",{abspos:{x:17,y:22}}),{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:1}),r},"bpmn:StartEvent":function(e,t,n={}){var{renderIcon:i=!0}=n;n=ro(n,["fill","stroke"]),gr(t).get("isInterrupting")||(n={...n,strokeDasharray:"6"});var r=q(e,t,n);return i&&O(t,e,n),r},"bpmn:SubProcess":function(e,t,n={}){return X(e,t,n=Or(t)?ro(n,["fill","stroke","width","height"]):ro(n,["fill","stroke"]))},"bpmn:Task":function(e,t,n={}){return Z(e,t,n=ro(n,["fill","stroke"]))},"bpmn:TextAnnotation":function(e,t,n={}){n=ro(n,["fill","stroke","width","height"]);var{width:r,height:o}=Qr(t,n),a=v(e,r,o,0,0,{fill:"none",stroke:"none"});return _(e,i.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:r,containerHeight:o,position:{mx:0,my:0}}),{stroke:Xr(t,c,n.stroke)}),z(e,gr(t).get("text")||"",{align:"left-top",box:Qr(t,n),padding:7,style:{fill:Zr(t,p,c,n.stroke)}}),a},"bpmn:Transaction":function(e,t,i={}){i=Or(t)?ro(i,["fill","stroke","width","height"]):ro(i,["fill","stroke"]);var r=X(e,t,{strokeWidth:1.5,...i}),o=n.style(["no-fill","no-events"],{stroke:Xr(t,c,i.stroke),strokeWidth:1.5});return Or(t)||(i={}),v(e,Jr(t,i),eo(t,i),7,3,o),r},"bpmn:UserTask":function(e,t,n={}){var r=Z(e,t,n=ro(n,["fill","stroke"]));return _(e,i.getScaledPath("TASK_TYPE_USER_1",{abspos:{x:15,y:12}}),{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:.5}),_(e,i.getScaledPath("TASK_TYPE_USER_2",{abspos:{x:15,y:12}}),{fill:Yr(t,s,n.fill),stroke:Xr(t,c,n.stroke),strokeWidth:.5}),_(e,i.getScaledPath("TASK_TYPE_USER_3",{abspos:{x:15,y:12}}),{fill:Xr(t,c,n.stroke),stroke:Xr(t,c,n.stroke),strokeWidth:.5}),r},label:function(e,t,n={}){return function(e,t,n={}){var i={width:90,height:30,x:t.width/2+t.x,y:t.height/2+t.y};return z(e,Ur(t),{box:i,fitBox:!0,style:L({},o.getExternalStyle(),{fill:Zr(t,p,c,n.stroke)})})}(e,t,n)}};this._drawPath=_,this._renderer=w}function ro(e,t=[]){return t.reduce(((t,n)=>(e[n]&&(t[n]=e[n]),t)),{})}e(io,Je),io.$inject=["config.bpmnRenderer","eventBus","styles","pathMap","canvas","textRenderer"],io.prototype.canRender=function(e){return vr(e,"bpmn:BaseElement")},io.prototype.drawShape=function(e,t,n={}){var{type:i}=t;return this._renderer(i)(e,t,n)},io.prototype.drawConnection=function(e,t,n={}){var{type:i}=t;return this._renderer(i)(e,t,n)},io.prototype.getShapePath=function(e){return vr(e,"bpmn:Event")?function(e){var t=e.x+e.width/2,n=e.y+e.height/2,i=e.width/2;return et([["M",t,n],["m",0,-i],["a",i,i,0,1,1,0,2*i],["a",i,i,0,1,1,0,-2*i],["z"]])}(e):vr(e,"bpmn:Activity")?function(e,t){var n=e.x,i=e.y,r=e.width,o=e.height;return et([["M",n+t,i],["l",r-2*t,0],["a",t,t,0,0,1,t,t],["l",0,o-2*t],["a",t,t,0,0,1,-t,t],["l",2*t-r,0],["a",t,t,0,0,1,-t,-t],["l",0,2*t-o],["a",t,t,0,0,1,t,-t],["z"]])}(e,10):vr(e,"bpmn:Gateway")?function(e){var t=e.width/2,n=e.height/2;return et([["M",e.x+t,e.y],["l",t,n],["l",-t,n],["l",-t,-n],["z"]])}(e):function(e){var t=e.x,n=e.y,i=e.width;return et([["M",t,n],["l",i,0],["l",0,e.height],["l",-i,0],["z"]])}(e)};var oo={width:150,height:50};function ao(e,t){var n;t.textContent=e;try{var i,r=""===e;return t.textContent=r?"dummy":e,i={width:(n=t.getBBox()).width+2*n.x,height:n.height},r&&(i.width=0),i}catch(e){return console.log(e),{width:0,height:0}}}function so(e,t,n){for(var i,r=e.shift(),o=r;;){if((i=ao(o,n)).width=o?i.width:0," "===o||""===o||i.width<Math.round(t)||o.length<2)return co(e,o,r,i);o=lo(o,i.width,t)}}function co(e,t,n,i){if(t.length<n.length){var r=n.slice(t.length).trim();e.unshift(r)}return{width:i.width,height:i.height,text:t}}var po="";function lo(e,t,n){var i=Math.max(e.length*(n/t),1),r=function(e,t){var n,i=e.split(/(\s|-|\u00AD)/g),r=[],o=0;if(i.length>1)for(;n=i.shift();){if(!(n.length+o<t)){"-"!==n&&n!==po||r.pop();break}r.push(n),o+=n.length}var a=r[r.length-1];return a&&a===po&&(r[r.length-1]="-"),r.join("")}(e,i);return r||(r=e.slice(0,Math.max(Math.round(i-1),1))),r}function uo(e){this._config=L({},{size:oo,padding:0,style:{},align:"center-top"},e||{})}uo.prototype.createText=function(e,t){return this.layoutText(e,t).element},uo.prototype.getDimensions=function(e,t){return this.layoutText(e,t).dimensions},uo.prototype.layoutText=function(e,t){var n=L({},this._config.size,t.box),i=L({},this._config.style,t.style),r=function(e){var t=e.split("-");return{horizontal:t[0]||"center",vertical:t[1]||"top"}}(t.align||this._config.align),o=function(e){return l(e)?L({top:0,left:0,right:0,bottom:0},e):{top:e,left:e,right:e,bottom:e}}(void 0!==t.padding?t.padding:this._config.padding),a=t.fitBox||!1,s=function(e){if("fontSize"in e&&"lineHeight"in e)return e.lineHeight*parseInt(e.fontSize,10)}(i),c=e.split(/\u00AD?\r?\n/),p=[],u=n.width-o.left-o.right,h=Ae("text");for(_e(h,{x:0,y:0}),_e(h,i),ye(function(){var e=document.getElementById("helper-svg");return e||(_e(e=Ae("svg"),{id:"helper-svg"}),q(e,{visibility:"hidden",position:"fixed",width:0,height:0}),document.body.appendChild(e)),e}(),h);c.length;)p.push(so(c,u,h));"middle"===r.vertical&&(o.top=o.bottom=0);var d=_(p,(function(e,t,n){return e+(s||t.height)}),0)+o.top+o.bottom,f=_(p,(function(e,t,n){return t.width>e?t.width:e}),0),m=o.top;"middle"===r.vertical&&(m+=(n.height-d)/2),m-=(s||p[0].height)/4;var v=Ae("text");return _e(v,i),g(p,(function(e){var t;switch(m+=s||e.height,r.horizontal){case"left":t=o.left;break;case"right":t=(a?f:u)-o.right-e.width;break;default:t=Math.max(((a?f:u)-e.width)/2+o.left,0)}var n=Ae("tspan");_e(n,{x:t,y:m}),n.textContent=e.text,ye(v,n)})),Fe(h),{dimensions:{width:f,height:d},element:v}};function ho(e){var t=L({fontFamily:"Arial, sans-serif",fontSize:12,fontWeight:"normal",lineHeight:1.2},e&&e.defaultStyle||{}),n=parseInt(t.fontSize,10)-1,i=L({},t,{fontSize:n},e&&e.externalStyle||{}),r=new uo({style:t});this.getExternalLabelBounds=function(e,t){var n=r.getDimensions(t,{box:{width:90,height:30},style:i});return{x:Math.round(e.x+e.width/2-n.width/2),y:Math.round(e.y),width:Math.ceil(n.width),height:Math.ceil(n.height)}},this.getTextAnnotationBounds=function(e,n){var i=r.getDimensions(n,{box:e,style:t,align:"left-top",padding:5});return{x:e.x,y:e.y,width:e.width,height:Math.max(30,Math.round(i.height))}},this.createText=function(e,t){return r.createText(e,t||{})},this.getDefaultStyle=function(){return t},this.getExternalStyle=function(){return i}}ho.$inject=["config.textRenderer"];var fo=/\{([^{}]+)\}/g,mo=/(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g;var vo={__init__:["bpmnRenderer"],bpmnRenderer:["type",io],textRenderer:["type",ho],pathMap:["type",function(){this.pathMap={EVENT_MESSAGE:{d:"m {mx},{my} l 0,{e.y1} l {e.x1},0 l 0,-{e.y1} z l {e.x0},{e.y0} l {e.x0},-{e.y0}",height:36,width:36,heightElements:[6,14],widthElements:[10.5,21]},EVENT_SIGNAL:{d:"M {mx},{my} l {e.x0},{e.y0} l -{e.x1},0 Z",height:36,width:36,heightElements:[18],widthElements:[10,20]},EVENT_ESCALATION:{d:"M {mx},{my} l {e.x0},{e.y0} l -{e.x0},-{e.y1} l -{e.x0},{e.y1} Z",height:36,width:36,heightElements:[20,7],widthElements:[8]},EVENT_CONDITIONAL:{d:"M {e.x0},{e.y0} l {e.x1},0 l 0,{e.y2} l -{e.x1},0 Z M {e.x2},{e.y3} l {e.x0},0 M {e.x2},{e.y4} l {e.x0},0 M {e.x2},{e.y5} l {e.x0},0 M {e.x2},{e.y6} l {e.x0},0 M {e.x2},{e.y7} l {e.x0},0 M {e.x2},{e.y8} l {e.x0},0 ",height:36,width:36,heightElements:[8.5,14.5,18,11.5,14.5,17.5,20.5,23.5,26.5],widthElements:[10.5,14.5,12.5]},EVENT_LINK:{d:"m {mx},{my} 0,{e.y0} -{e.x1},0 0,{e.y1} {e.x1},0 0,{e.y0} {e.x0},-{e.y2} -{e.x0},-{e.y2} z",height:36,width:36,heightElements:[4.4375,6.75,7.8125],widthElements:[9.84375,13.5]},EVENT_ERROR:{d:"m {mx},{my} {e.x0},-{e.y0} {e.x1},-{e.y1} {e.x2},{e.y2} {e.x3},-{e.y3} -{e.x4},{e.y4} -{e.x5},-{e.y5} z",height:36,width:36,heightElements:[.023,8.737,8.151,16.564,10.591,8.714],widthElements:[.085,6.672,6.97,4.273,5.337,6.636]},EVENT_CANCEL_45:{d:"m {mx},{my} -{e.x1},0 0,{e.x0} {e.x1},0 0,{e.y1} {e.x0},0 0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z",height:36,width:36,heightElements:[4.75,8.5],widthElements:[4.75,8.5]},EVENT_COMPENSATION:{d:"m {mx},{my} {e.x0},-{e.y0} 0,{e.y1} z m {e.x1},-{e.y2} {e.x2},-{e.y3} 0,{e.y1} -{e.x2},-{e.y3} z",height:36,width:36,heightElements:[6.5,13,.4,6.1],widthElements:[9,9.3,8.7]},EVENT_TIMER_WH:{d:"M {mx},{my} l {e.x0},-{e.y0} m -{e.x0},{e.y0} l {e.x1},{e.y1} ",height:36,width:36,heightElements:[10,2],widthElements:[3,7]},EVENT_TIMER_LINE:{d:"M {mx},{my} m {e.x0},{e.y0} l -{e.x1},{e.y1} ",height:36,width:36,heightElements:[10,3],widthElements:[0,0]},EVENT_MULTIPLE:{d:"m {mx},{my} {e.x1},-{e.y0} {e.x1},{e.y0} -{e.x0},{e.y1} -{e.x2},0 z",height:36,width:36,heightElements:[6.28099,12.56199],widthElements:[3.1405,9.42149,12.56198]},EVENT_PARALLEL_MULTIPLE:{d:"m {mx},{my} {e.x0},0 0,{e.y1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} -{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z",height:36,width:36,heightElements:[2.56228,7.68683],widthElements:[2.56228,7.68683]},GATEWAY_EXCLUSIVE:{d:"m {mx},{my} {e.x0},{e.y0} {e.x1},{e.y0} {e.x2},0 {e.x4},{e.y2} {e.x4},{e.y1} {e.x2},0 {e.x1},{e.y3} {e.x0},{e.y3} {e.x3},0 {e.x5},{e.y1} {e.x5},{e.y2} {e.x3},0 z",height:17.5,width:17.5,heightElements:[8.5,6.5312,-6.5312,-8.5],widthElements:[6.5,-6.5,3,-3,5,-5]},GATEWAY_PARALLEL:{d:"m {mx},{my} 0,{e.y1} -{e.x1},0 0,{e.y0} {e.x1},0 0,{e.y1} {e.x0},0 0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z",height:30,width:30,heightElements:[5,12.5],widthElements:[5,12.5]},GATEWAY_EVENT_BASED:{d:"m {mx},{my} {e.x0},{e.y0} {e.x0},{e.y1} {e.x1},{e.y2} {e.x2},0 z",height:11,width:11,heightElements:[-6,6,12,-12],widthElements:[9,-3,-12]},GATEWAY_COMPLEX:{d:"m {mx},{my} 0,{e.y0} -{e.x0},-{e.y1} -{e.x1},{e.y2} {e.x0},{e.y1} -{e.x2},0 0,{e.y3} {e.x2},0 -{e.x0},{e.y1} l {e.x1},{e.y2} {e.x0},-{e.y1} 0,{e.y0} {e.x3},0 0,-{e.y0} {e.x0},{e.y1} {e.x1},-{e.y2} -{e.x0},-{e.y1} {e.x2},0 0,-{e.y3} -{e.x2},0 {e.x0},-{e.y1} -{e.x1},-{e.y2} -{e.x0},{e.y1} 0,-{e.y0} -{e.x3},0 z",height:17.125,width:17.125,heightElements:[4.875,3.4375,2.125,3],widthElements:[3.4375,2.125,4.875,3]},DATA_OBJECT_PATH:{d:"m 0,0 {e.x1},0 {e.x0},{e.y0} 0,{e.y1} -{e.x2},0 0,-{e.y2} {e.x1},0 0,{e.y0} {e.x0},0",height:61,width:51,heightElements:[10,50,60],widthElements:[10,40,50,60]},DATA_OBJECT_COLLECTION_PATH:{d:"m{mx},{my} m 3,2 l 0,10 m 3,-10 l 0,10 m 3,-10 l 0,10",height:10,width:10,heightElements:[],widthElements:[]},DATA_ARROW:{d:"m 5,9 9,0 0,-3 5,5 -5,5 0,-3 -9,0 z",height:61,width:51,heightElements:[],widthElements:[]},DATA_STORE:{d:"m {mx},{my} l 0,{e.y2} c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 l 0,-{e.y2} c -{e.x0},-{e.y1} -{e.x1},-{e.y1} -{e.x2},0c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 m -{e.x2},{e.y0}c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0m -{e.x2},{e.y0}c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0",height:61,width:61,heightElements:[7,10,45],widthElements:[2,58,60]},TEXT_ANNOTATION:{d:"m {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0",height:30,width:10,heightElements:[30],widthElements:[10]},MARKER_SUB_PROCESS:{d:"m{mx},{my} m 7,2 l 0,10 m -5,-5 l 10,0",height:10,width:10,heightElements:[],widthElements:[]},MARKER_PARALLEL:{d:"m{mx},{my} m 3,2 l 0,10 m 3,-10 l 0,10 m 3,-10 l 0,10",height:10,width:10,heightElements:[],widthElements:[]},MARKER_SEQUENTIAL:{d:"m{mx},{my} m 0,3 l 10,0 m -10,3 l 10,0 m -10,3 l 10,0",height:10,width:10,heightElements:[],widthElements:[]},MARKER_COMPENSATION:{d:"m {mx},{my} 7,-5 0,10 z m 7.1,-0.3 6.9,-4.7 0,10 -6.9,-4.7 z",height:10,width:21,heightElements:[],widthElements:[]},MARKER_LOOP:{d:"m {mx},{my} c 3.526979,0 6.386161,-2.829858 6.386161,-6.320661 0,-3.490806 -2.859182,-6.320661 -6.386161,-6.320661 -3.526978,0 -6.38616,2.829855 -6.38616,6.320661 0,1.745402 0.714797,3.325567 1.870463,4.469381 0.577834,0.571908 1.265885,1.034728 2.029916,1.35457 l -0.718163,-3.909793 m 0.718163,3.909793 -3.885211,0.802902",height:13.9,width:13.7,heightElements:[],widthElements:[]},MARKER_ADHOC:{d:"m {mx},{my} m 0.84461,2.64411 c 1.05533,-1.23780996 2.64337,-2.07882 4.29653,-1.97997996 2.05163,0.0805 3.85579,1.15803 5.76082,1.79107 1.06385,0.34139996 2.24454,0.1438 3.18759,-0.43767 0.61743,-0.33642 1.2775,-0.64078 1.7542,-1.17511 0,0.56023 0,1.12046 0,1.6807 -0.98706,0.96237996 -2.29792,1.62393996 -3.6918,1.66181996 -1.24459,0.0927 -2.46671,-0.2491 -3.59505,-0.74812 -1.35789,-0.55965 -2.75133,-1.33436996 -4.27027,-1.18121996 -1.37741,0.14601 -2.41842,1.13685996 -3.44288,1.96782996 z",height:4,width:15,heightElements:[],widthElements:[]},TASK_TYPE_SEND:{d:"m {mx},{my} l 0,{e.y1} l {e.x1},0 l 0,-{e.y1} z l {e.x0},{e.y0} l {e.x0},-{e.y0}",height:14,width:21,heightElements:[6,14],widthElements:[10.5,21]},TASK_TYPE_SCRIPT:{d:"m {mx},{my} c 9.966553,-6.27276 -8.000926,-7.91932 2.968968,-14.938 l -8.802728,0 c -10.969894,7.01868 6.997585,8.66524 -2.968967,14.938 z m -7,-12 l 5,0 m -4.5,3 l 4.5,0 m -3,3 l 5,0m -4,3 l 5,0",height:15,width:12.6,heightElements:[6,14],widthElements:[10.5,21]},TASK_TYPE_USER_1:{d:"m {mx},{my} c 0.909,-0.845 1.594,-2.049 1.594,-3.385 0,-2.554 -1.805,-4.62199999 -4.357,-4.62199999 -2.55199998,0 -4.28799998,2.06799999 -4.28799998,4.62199999 0,1.348 0.974,2.562 1.89599998,3.405 -0.52899998,0.187 -5.669,2.097 -5.794,4.7560005 v 6.718 h 17 v -6.718 c 0,-2.2980005 -5.5279996,-4.5950005 -6.0509996,-4.7760005 zm -8,6 l 0,5.5 m 11,0 l 0,-5"},TASK_TYPE_USER_2:{d:"m {mx},{my} m 2.162,1.009 c 0,2.4470005 -2.158,4.4310005 -4.821,4.4310005 -2.66499998,0 -4.822,-1.981 -4.822,-4.4310005 "},TASK_TYPE_USER_3:{d:"m {mx},{my} m -6.9,-3.80 c 0,0 2.25099998,-2.358 4.27399998,-1.177 2.024,1.181 4.221,1.537 4.124,0.965 -0.098,-0.57 -0.117,-3.79099999 -4.191,-4.13599999 -3.57499998,0.001 -4.20799998,3.36699999 -4.20699998,4.34799999 z"},TASK_TYPE_MANUAL:{d:"m {mx},{my} c 0.234,-0.01 5.604,0.008 8.029,0.004 0.808,0 1.271,-0.172 1.417,-0.752 0.227,-0.898 -0.334,-1.314 -1.338,-1.316 -2.467,-0.01 -7.886,-0.004 -8.108,-0.004 -0.014,-0.079 0.016,-0.533 0,-0.61 0.195,-0.042 8.507,0.006 9.616,0.002 0.877,-0.007 1.35,-0.438 1.353,-1.208 0.003,-0.768 -0.479,-1.09 -1.35,-1.091 -2.968,-0.002 -9.619,-0.013 -9.619,-0.013 v -0.591 c 0,0 5.052,-0.016 7.225,-0.016 0.888,-0.002 1.354,-0.416 1.351,-1.193 -0.006,-0.761 -0.492,-1.196 -1.361,-1.196 -3.473,-0.005 -10.86,-0.003 -11.0829995,-0.003 -0.022,-0.047 -0.045,-0.094 -0.069,-0.139 0.3939995,-0.319 2.0409995,-1.626 2.4149995,-2.017 0.469,-0.4870005 0.519,-1.1650005 0.162,-1.6040005 -0.414,-0.511 -0.973,-0.5 -1.48,-0.236 -1.4609995,0.764 -6.5999995,3.6430005 -7.7329995,4.2710005 -0.9,0.499 -1.516,1.253 -1.882,2.19 -0.37000002,0.95 -0.17,2.01 -0.166,2.979 0.004,0.718 -0.27300002,1.345 -0.055,2.063 0.629,2.087 2.425,3.312 4.859,3.318 4.6179995,0.014 9.2379995,-0.139 13.8569995,-0.158 0.755,-0.004 1.171,-0.301 1.182,-1.033 0.012,-0.754 -0.423,-0.969 -1.183,-0.973 -1.778,-0.01 -5.824,-0.004 -6.04,-0.004 10e-4,-0.084 0.003,-0.586 10e-4,-0.67 z"},TASK_TYPE_INSTANTIATING_SEND:{d:"m {mx},{my} l 0,8.4 l 12.6,0 l 0,-8.4 z l 6.3,3.6 l 6.3,-3.6"},TASK_TYPE_SERVICE:{d:"m {mx},{my} v -1.71335 c 0.352326,-0.0705 0.703932,-0.17838 1.047628,-0.32133 0.344416,-0.14465 0.665822,-0.32133 0.966377,-0.52145 l 1.19431,1.18005 1.567487,-1.57688 -1.195028,-1.18014 c 0.403376,-0.61394 0.683079,-1.29908 0.825447,-2.01824 l 1.622133,-0.01 v -2.2196 l -1.636514,0.01 c -0.07333,-0.35153 -0.178319,-0.70024 -0.323564,-1.04372 -0.145244,-0.34406 -0.321407,-0.6644 -0.522735,-0.96217 l 1.131035,-1.13631 -1.583305,-1.56293 -1.129598,1.13589 c -0.614052,-0.40108 -1.302883,-0.68093 -2.022633,-0.82247 l 0.0093,-1.61852 h -2.241173 l 0.0042,1.63124 c -0.353763,0.0736 -0.705369,0.17977 -1.049785,0.32371 -0.344415,0.14437 -0.665102,0.32092 -0.9635006,0.52046 l -1.1698628,-1.15823 -1.5667691,1.5792 1.1684265,1.15669 c -0.4026573,0.61283 -0.68308,1.29797 -0.8247287,2.01713 l -1.6588041,0.003 v 2.22174 l 1.6724648,-0.006 c 0.073327,0.35077 0.1797598,0.70243 0.3242851,1.04472 0.1452428,0.34448 0.3214064,0.6644 0.5227339,0.96066 l -1.1993431,1.19723 1.5840256,1.56011 1.1964668,-1.19348 c 0.6140517,0.40346 1.3028827,0.68232 2.0233517,0.82331 l 7.19e-4,1.69892 h 2.226848 z m 0.221462,-3.9957 c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z"},TASK_TYPE_SERVICE_FILL:{d:"m {mx},{my} c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z"},TASK_TYPE_BUSINESS_RULE_HEADER:{d:"m {mx},{my} 0,4 20,0 0,-4 z"},TASK_TYPE_BUSINESS_RULE_MAIN:{d:"m {mx},{my} 0,12 20,0 0,-12 zm 0,8 l 20,0 m -13,-4 l 0,8"},MESSAGE_FLOW_MARKER:{d:"m {mx},{my} m -10.5 ,-7 l 0,14 l 21,0 l 0,-14 z l 10.5,6 l 10.5,-6"}},this.getRawPath=function(e){return this.pathMap[e].d},this.getScaledPath=function(e,t){var n,i,r=this.pathMap[e];t.abspos?(n=t.abspos.x,i=t.abspos.y):(n=t.containerWidth*t.position.mx,i=t.containerHeight*t.position.my);var o={};if(t.position){for(var a=t.containerHeight/r.height*t.yScaleFactor,s=t.containerWidth/r.width*t.xScaleFactor,c=0;c<r.heightElements.length;c++)o["y"+c]=r.heightElements[c]*a;for(var p=0;p<r.widthElements.length;p++)o["x"+p]=r.widthElements[p]*s}var l,u,h=(l=r.d,u={mx:n,my:i,e:o},String(l).replace(fo,(function(e,t){return function(e,t,n){var i=n;return t.replace(mo,(function(e,t,n,r,o){t=t||r,i&&(t in i&&(i=i[t]),"function"==typeof i&&o&&(i=i()))})),i=(null==i||i==n?e:i)+""}(e,t,u)})));return h}}]};var yo={translate:["value",function(e,t){return t=t||{},e.replace(/{([^}]+)}/g,(function(e,n){return t[n]||"{"+n+"}"}))}]};function go(e,t,n){return L({id:e.id,type:e.$type,businessObject:e,di:t},n)}function bo(e,t,n){var i=e.waypoint;return!i||i.length<2?[fn(t),fn(n)]:i.map((function(e){return{x:e.x,y:e.y}}))}function _o(e,t,n){return new Error(`element ${hr(t)} referenced by ${hr(e)}#${n} not yet drawn`)}function xo(e,t,n,i,r){this._eventBus=e,this._canvas=t,this._elementFactory=n,this._elementRegistry=i,this._textRenderer=r}xo.$inject=["eventBus","canvas","elementFactory","elementRegistry","textRenderer"],xo.prototype.add=function(e,t,n){var i,r,o;if(vr(t,"bpmndi:BPMNPlane")){var a=vr(e,"bpmn:SubProcess")?{id:e.id+"_plane"}:{};i=this._elementFactory.createRoot(go(e,t,a)),this._canvas.addRootElement(i)}else if(vr(t,"bpmndi:BPMNShape")){var s=!Or(e,t),c=function(e){return vr(e,"bpmn:Group")}(e);r=n&&(n.hidden||n.collapsed);var p=t.bounds;i=this._elementFactory.createShape(go(e,t,{collapsed:s,hidden:r,x:Math.round(p.x),y:Math.round(p.y),width:Math.round(p.width),height:Math.round(p.height),isFrame:c})),vr(e,"bpmn:BoundaryEvent")&&this._attachBoundary(e,i),vr(e,"bpmn:Lane")&&(o=0),vr(e,"bpmn:DataStoreReference")&&(function(e,t){var n=t.x,i=t.y;return n>=e.x&&n<=e.x+e.width&&i>=e.y&&i<=e.y+e.height}(n,fn(p))||(n=this._canvas.findRoot(n))),this._canvas.addShape(i,n,o)}else{if(!vr(t,"bpmndi:BPMNEdge"))throw new Error(`unknown di ${hr(t)} for element ${hr(e)}`);var l=this._getSource(e),u=this._getTarget(e);r=n&&(n.hidden||n.collapsed),i=this._elementFactory.createConnection(go(e,t,{hidden:r,source:l,target:u,waypoints:bo(t,l,u)})),vr(e,"bpmn:DataAssociation")&&(n=this._canvas.findRoot(n)),this._canvas.addConnection(i,n,o)}return zr(e)&&Ur(i)&&this.addLabel(e,t,i),this._eventBus.fire("bpmnElement.added",{element:i}),i},xo.prototype._attachBoundary=function(e,t){var n=e.attachedToRef;if(!n)throw new Error(`missing ${hr(e)}#attachedToRef`);var i=this._elementRegistry.get(n.id),r=i&&i.attachers;if(!i)throw _o(e,n,"attachedToRef");t.host=i,r||(i.attachers=r=[]),-1===r.indexOf(t)&&r.push(t)},xo.prototype.addLabel=function(e,t,n){var i,r,o;return i=function(e,t){var n,i,r,o=e.label;return o&&o.bounds?(r=o.bounds,i={width:Math.max(Fr.width,r.width),height:r.height},n={x:r.x+r.width/2,y:r.y+r.height/2}):(n=Gr(t),i=Fr),L({x:n.x-i.width/2,y:n.y-i.height/2},i)}(t,n),(r=Ur(n))&&(i=this._textRenderer.getExternalLabelBounds(i,r)),o=this._elementFactory.createLabel(go(e,t,{id:e.id+"_label",labelTarget:n,type:"label",hidden:n.hidden||!Ur(n),x:Math.round(i.x),y:Math.round(i.y),width:Math.round(i.width),height:Math.round(i.height)})),this._canvas.addShape(o,n.parent)},xo.prototype._getConnectedElement=function(e,t){var n,i,r=e.$type;if(i=e[t+"Ref"],"source"===t&&"bpmn:DataInputAssociation"===r&&(i=i&&i[0]),("source"===t&&"bpmn:DataOutputAssociation"===r||"target"===t&&"bpmn:DataInputAssociation"===r)&&(i=e.$parent),n=i&&this._getElement(i))return n;throw i?_o(e,i,t+"Ref"):new Error(`${hr(e)}#${t} Ref not specified`)},xo.prototype._getSource=function(e){return this._getConnectedElement(e,"source")},xo.prototype._getTarget=function(e){return this._getConnectedElement(e,"target")},xo.prototype._getElement=function(e){return this._elementRegistry.get(e.id)};var wo={__depends__:[vo,{__depends__:[yo],bpmnImporter:["type",xo]}]};function Eo(e){this._counter=0,this._prefix=(e?e+"-":"")+Math.floor(1e9*Math.random())+"-"}Eo.prototype.next=function(){return this._prefix+ ++this._counter};var So=new Eo("ov");function Co(e,t,n,i){var r,o;this._eventBus=t,this._canvas=n,this._elementRegistry=i,this._ids=So,this._overlayDefaults=L({show:null,scale:!0},e&&e.defaults),this._overlays={},this._overlayContainers=[],this._overlayRoot=(r=n.getContainer(),q(o=he('<div class="djs-overlay-container" />'),{position:"absolute",width:0,height:0}),r.insertBefore(o,r.firstChild),o),this._init()}function ko(e,t,n){q(e,{left:t+"px",top:n+"px"})}function Ro(e,t){e.style.display=!1===t?"none":""}function Po(e,t){e.style["transform-origin"]="top left",["","-ms-","-webkit-"].forEach((function(n){e.style[n+"transform"]=t}))}Co.$inject=["config.overlays","eventBus","canvas","elementRegistry"],Co.prototype.get=function(e){if(d(e)&&(e={id:e}),d(e.element)&&(e.element=this._elementRegistry.get(e.element)),e.element){var t=this._getOverlayContainer(e.element,!0);return t?e.type?y(t.overlays,M({type:e.type})):t.overlays.slice():[]}return e.type?y(this._overlays,M({type:e.type})):e.id?this._overlays[e.id]:null},Co.prototype.add=function(e,t,n){if(l(t)&&(n=t,t=null),e.id||(e=this._elementRegistry.get(e)),!n.position)throw new Error("must specifiy overlay position");if(!n.html)throw new Error("must specifiy overlay html");if(!e)throw new Error("invalid element specified");var i=this._ids.next();return n=L({},this._overlayDefaults,n,{id:i,type:t,element:e,html:n.html}),this._addOverlay(n),i},Co.prototype.remove=function(e){var t=this.get(e)||[];p(t)||(t=[t]);var n=this;g(t,(function(e){var t=n._getOverlayContainer(e.element,!0);if(e&&(ve(e.html),ve(e.htmlContainer),delete e.htmlContainer,delete e.element,delete n._overlays[e.id]),t){var i=t.overlays.indexOf(e);-1!==i&&t.overlays.splice(i,1)}}))},Co.prototype.isShown=function(){return"none"!==this._overlayRoot.style.display},Co.prototype.show=function(){Ro(this._overlayRoot)},Co.prototype.hide=function(){Ro(this._overlayRoot,!1)},Co.prototype.clear=function(){this._overlays={},this._overlayContainers=[],Q(this._overlayRoot)},Co.prototype._updateOverlayContainer=function(e){var t=e.element,n=e.html,i=t.x,r=t.y;if(t.waypoints){var o=ht(t);i=o.x,r=o.y}ko(n,i,r),K(e.html,"data-container-id",t.id)},Co.prototype._updateOverlay=function(e){var t,n,i=e.position,r=e.htmlContainer,o=e.element,a=i.left,s=i.top;void 0!==i.right&&(t=o.waypoints?ht(o).width:o.width,a=-1*i.right+t);void 0!==i.bottom&&(n=o.waypoints?ht(o).height:o.height,s=-1*i.bottom+n);ko(r,a||0,s||0),this._updateOverlayVisibilty(e,this._canvas.viewbox())},Co.prototype._createOverlayContainer=function(e){var t=he('<div class="djs-overlays" />');q(t,{position:"absolute"}),this._overlayRoot.appendChild(t);var n={html:t,element:e,overlays:[]};return this._updateOverlayContainer(n),this._overlayContainers.push(n),n},Co.prototype._updateRoot=function(e){var t=e.scale||1,n="matrix("+[t,0,0,t,-1*e.x*t,-1*e.y*t].join(",")+")";Po(this._overlayRoot,n)},Co.prototype._getOverlayContainer=function(e,t){var n=m(this._overlayContainers,(function(t){return t.element===e}));return n||t?n:this._createOverlayContainer(e)},Co.prototype._addOverlay=function(e){var t,n,i=e.id,r=e.element,o=e.html;o.get&&o.constructor.prototype.jquery&&(o=o.get(0)),d(o)&&(o=he(o)),n=this._getOverlayContainer(r),q(t=he('<div class="djs-overlay" data-overlay-id="'+i+'">'),{position:"absolute"}),t.appendChild(o),e.type&&X(t).add("djs-overlay-"+e.type),Ro(t,this._canvas.findRoot(r)===this._canvas.getRootElement()),e.htmlContainer=t,n.overlays.push(e),n.html.appendChild(t),this._overlays[i]=e,this._updateOverlay(e),this._updateOverlayVisibilty(e,this._canvas.viewbox())},Co.prototype._updateOverlayVisibilty=function(e,t){var n=e.show,i=this._canvas.findRoot(e.element),r=n&&n.minZoom,o=n&&n.maxZoom,a=e.htmlContainer,c=!0;(i!==this._canvas.getRootElement()||n&&(s(r)&&r>t.scale||s(o)&&o<t.scale))&&(c=!1),Ro(a,c),this._updateOverlayScale(e,t)},Co.prototype._updateOverlayScale=function(e,t){var n,i,r,o=e.scale,a=e.htmlContainer,c="";!0!==o&&(!1===o?(n=1,i=1):(n=o.min,i=o.max),s(n)&&t.scale<n&&(r=(1/t.scale||1)*n),s(i)&&t.scale>i&&(r=(1/t.scale||1)*i)),s(r)&&(c="scale("+r+","+r+")"),Po(a,c)},Co.prototype._updateOverlaysVisibilty=function(e){var t=this;g(this._overlays,(function(n){t._updateOverlayVisibilty(n,e)}))},Co.prototype._init=function(){var e=this._eventBus,t=this;e.on("canvas.viewbox.changing",(function(e){t.hide()})),e.on("canvas.viewbox.changed",(function(e){var n;n=e.viewbox,t._updateRoot(n),t._updateOverlaysVisibilty(n),t.show()})),e.on(["shape.remove","connection.remove"],(function(e){var n=e.element;g(t.get({element:n}),(function(e){t.remove(e.id)}));var i=t._getOverlayContainer(n);if(i){ve(i.html);var r=t._overlayContainers.indexOf(i);-1!==r&&t._overlayContainers.splice(r,1)}})),e.on("element.changed",500,(function(e){var n=e.element,i=t._getOverlayContainer(n,!0);i&&(g(i.overlays,(function(e){t._updateOverlay(e)})),t._updateOverlayContainer(i))})),e.on("element.marker.update",(function(e){var n=t._getOverlayContainer(e.element,!0);n&&X(n.html)[e.add?"add":"remove"](e.marker)})),e.on("root.set",(function(){t._updateOverlaysVisibilty(t._canvas.viewbox())})),e.on("diagram.clear",this.clear,this)};var Ao={__init__:["overlays"],overlays:["type",Co]};function Mo(e,t,n,i){e.on("element.changed",(function(i){var r=i.element;(r.parent||r===t.getRootElement())&&(i.gfx=n.getGraphics(r)),i.gfx&&e.fire(ft(r)+".changed",i)})),e.on("elements.changed",(function(t){var n=t.elements;n.forEach((function(t){e.fire("element.changed",{element:t})})),i.updateContainments(n)})),e.on("shape.changed",(function(e){i.update("shape",e.element,e.gfx)})),e.on("connection.changed",(function(e){i.update("connection",e.element,e.gfx)}))}Mo.$inject=["eventBus","canvas","elementRegistry","graphicsFactory"];var To={__init__:["changeSupport"],changeSupport:["type",Mo]};function Do(e){this._eventBus=e}function Bo(e){return function(t,n,i,r,o){(h(t)||u(t))&&(o=r,r=i,i=n,n=t,t=null),this.on(t,e,n,i,r,o)}}function No(e,t){t.invoke(Do,this),this.executed((function(t){var n=t.context;n.rootElement?e.setRootElement(n.rootElement):n.rootElement=e.getRootElement()})),this.revert((function(t){var n=t.context;n.rootElement&&e.setRootElement(n.rootElement)}))}Do.$inject=["eventBus"],Do.prototype.on=function(e,t,n,i,r,o){if((h(t)||u(t))&&(o=r,r=i,i=n,n=t,t=null),h(n)&&(o=r,r=i,i=n,n=1e3),l(r)&&(o=r,r=!1),!h(i))throw new Error("handlerFn must be a function");p(e)||(e=[e]);var a=this._eventBus;g(e,(function(e){var s=["commandStack",e,t].filter((function(e){return e})).join(".");a.on(s,n,r?function(e,t){return function(n){return e.call(t||null,n.context,n.command,n)}}(i,o):i,o)}))},Do.prototype.canExecute=Bo("canExecute"),Do.prototype.preExecute=Bo("preExecute"),Do.prototype.preExecuted=Bo("preExecuted"),Do.prototype.execute=Bo("execute"),Do.prototype.executed=Bo("executed"),Do.prototype.postExecute=Bo("postExecute"),Do.prototype.postExecuted=Bo("postExecuted"),Do.prototype.revert=Bo("revert"),Do.prototype.reverted=Bo("reverted"),e(No,Do),No.$inject=["canvas","injector"];var jo={__init__:["rootElementsBehavior"],rootElementsBehavior:["type",No]};function Oo(e){return CSS.escape(e)}var Lo={"&":"&","<":"<",">":">",'"':""","'":"'"};function $o(e){return(e=""+e)&&e.replace(/[&<>"']/g,(function(e){return Lo[e]}))}var Io="_plane";function Fo(e){return function(e){return e.replace(new RegExp(Io+"$"),"")}(e.id)}function zo(e){var t=e.id;return vr(e,"bpmn:SubProcess")?Go(t):t}function Ho(e){return Go(e)}function Vo(e){return vr(br(e),"bpmndi:BPMNPlane")}function Go(e){return e+Io}function Wo(e,t,n){var i=he('<ul class="bjs-breadcrumbs"></ul>'),r=n.getContainer(),o=X(r);r.appendChild(i);var a=[];function s(e){e&&(a=function(e){for(var t=gr(e),n=[],i=t;i;i=i.$parent)(vr(i,"bpmn:SubProcess")||vr(i,"bpmn:Process"))&&n.push(i);return n.reverse()}(e));var r=a.flatMap((function(e){var i=n.findRoot(zo(e))||n.findRoot(e.id);if(!i&&vr(e,"bpmn:Process")){var r=t.find((function(t){var n=gr(t);return n&&n.get("processRef")===e}));i=r&&n.findRoot(r.id)}if(!i)return[];var o=$o(e.name||e.id),a=he('<li><span class="bjs-crumb"><a title="'+o+'">'+o+"</a></span></li>");return a.addEventListener("click",(function(){n.setRootElement(i)})),a}));i.innerHTML="";var s=r.length>1;o.toggle("bjs-breadcrumbs-shown",s),r.forEach((function(e){i.appendChild(e)}))}e.on("element.changed",(function(e){var t=gr(e.element);m(a,(function(e){return e===t}))&&s()})),e.on("root.set",(function(e){s(e.element)}))}function Uo(e,t){var n=null,i=new qo;e.on("root.set",(function(e){var r=e.element,o=t.viewbox(),a=i.get(r);if(i.set(n,{x:o.x,y:o.y,zoom:o.scale}),n=r,vr(r,"bpmn:SubProcess")||a){a=a||{x:0,y:0,zoom:1};var s=(o.x-a.x)*o.scale,c=(o.y-a.y)*o.scale;0===s&&0===c||t.scroll({dx:s,dy:c}),a.zoom!==o.scale&&t.zoom(a.zoom,{x:0,y:0})}})),e.on("diagram.clear",(function(){i.clear(),n=null}))}function qo(){this._entries=[],this.set=function(e,t){var n=!1;for(var i in this._entries)if(this._entries[i][0]===e){this._entries[i][1]=t,n=!0;break}n||this._entries.push([e,t])},this.get=function(e){for(var t in this._entries)if(this._entries[t][0]===e)return this._entries[t][1];return null},this.clear=function(){this._entries.length=0},this.remove=function(e){var t=-1;for(var n in this._entries)if(this._entries[n][0]===e){t=n;break}-1!==t&&this._entries.splice(t,1)}}Wo.$inject=["eventBus","elementRegistry","canvas"],Uo.$inject=["eventBus","canvas"];var Ko=180,Yo=160;function Xo(e,t){this._eventBus=e,this._moddle=t;var n=this;e.on("import.render.start",1500,(function(e,t){n._handleImport(t.definitions)}))}function Zo(e){return vr(e,"bpmndi:BPMNDiagram")?e:Zo(e.$parent)}Xo.prototype._handleImport=function(e){if(e.diagrams){var t=this;this._definitions=e,this._processToDiagramMap={},e.diagrams.forEach((function(e){e.plane&&e.plane.bpmnElement&&(t._processToDiagramMap[e.plane.bpmnElement.id]=e)})),e.diagrams.filter((e=>e.plane)).flatMap((e=>t._createNewDiagrams(e.plane))).forEach((function(e){t._movePlaneElementsToOrigin(e.plane)}))}},Xo.prototype._createNewDiagrams=function(e){var t=this,n=[],i=[];e.get("planeElement").forEach((function(t){var r=t.bpmnElement;if(r){var o=r.$parent;vr(r,"bpmn:SubProcess")&&!t.isExpanded&&n.push(r),function(e,t){var n=e.$parent;if(!vr(n,"bpmn:SubProcess")||n===t.bpmnElement)return!1;if(yr(e,["bpmn:DataInputAssociation","bpmn:DataOutputAssociation"]))return!1;return!0}(r,e)&&i.push({diElement:t,parent:o})}}));var r=[];return n.forEach((function(e){if(!t._processToDiagramMap[e.id]){var n=t._createDiagram(e);t._processToDiagramMap[e.id]=n,r.push(n)}})),i.forEach((function(e){for(var i=e.diElement,r=e.parent;r&&-1===n.indexOf(r);)r=r.$parent;if(r){var o=t._processToDiagramMap[r.id];t._moveToDiPlane(i,o.plane)}})),r},Xo.prototype._movePlaneElementsToOrigin=function(e){var t=e.get("planeElement"),n=function(e){var t={top:1/0,right:-1/0,bottom:-1/0,left:1/0};return e.planeElement.forEach((function(e){if(e.bounds){var n=un(e.bounds);t.top=Math.min(n.top,t.top),t.left=Math.min(n.left,t.left)}})),hn(t)}(e),i=n.x-Ko,r=n.y-Yo;t.forEach((function(e){e.waypoint?e.waypoint.forEach((function(e){e.x=e.x-i,e.y=e.y-r})):e.bounds&&(e.bounds.x=e.bounds.x-i,e.bounds.y=e.bounds.y-r)}))},Xo.prototype._moveToDiPlane=function(e,t){var n=Zo(e).plane.get("planeElement");n.splice(n.indexOf(e),1),t.get("planeElement").push(e)},Xo.prototype._createDiagram=function(e){var t=this._moddle.create("bpmndi:BPMNPlane",{bpmnElement:e}),n=this._moddle.create("bpmndi:BPMNDiagram",{plane:t});return t.$parent=n,t.bpmnElement=e,n.$parent=this._definitions,this._definitions.diagrams.push(n),n},Xo.$inject=["eventBus","moddle"];var Qo=250;function Jo(e,t,n,i,r){Do.call(this,t),this._canvas=e,this._eventBus=t,this._elementRegistry=n,this._overlays=i,this._translate=r;var o=this;this.executed("shape.toggleCollapse",Qo,(function(e){var t=e.shape;o._canDrillDown(t)?o._addOverlay(t):o._removeOverlay(t)}),!0),this.reverted("shape.toggleCollapse",Qo,(function(e){var t=e.shape;o._canDrillDown(t)?o._addOverlay(t):o._removeOverlay(t)}),!0),this.executed(["shape.create","shape.move","shape.delete"],Qo,(function(e){var t=e.oldParent,n=e.newParent||e.parent,i=e.shape;o._canDrillDown(i)&&o._addOverlay(i),o._updateDrilldownOverlay(t),o._updateDrilldownOverlay(n),o._updateDrilldownOverlay(i)}),!0),this.reverted(["shape.create","shape.move","shape.delete"],Qo,(function(e){var t=e.oldParent,n=e.newParent||e.parent,i=e.shape;o._canDrillDown(i)&&o._addOverlay(i),o._updateDrilldownOverlay(t),o._updateDrilldownOverlay(n),o._updateDrilldownOverlay(i)}),!0),t.on("import.render.complete",(function(){n.filter((function(e){return o._canDrillDown(e)})).map((function(e){o._addOverlay(e)}))}))}e(Jo,Do),Jo.prototype._updateDrilldownOverlay=function(e){var t=this._canvas;if(e){var n=t.findRoot(e);n&&this._updateOverlayVisibility(n)}},Jo.prototype._canDrillDown=function(e){var t=this._canvas;return vr(e,"bpmn:SubProcess")&&t.findRoot(zo(e))},Jo.prototype._updateOverlayVisibility=function(e){var t=this._overlays,n=gr(e),i=t.get({element:n.id,type:"drilldown"})[0];if(i){var r=n&&n.get("flowElements")&&n.get("flowElements").length;X(i.html).toggle("bjs-drilldown-empty",!r)}},Jo.prototype._addOverlay=function(e){var t=this._canvas,n=this._overlays,i=gr(e);n.get({element:e,type:"drilldown"}).length&&this._removeOverlay(e);var r=he('<button type="button" class="bjs-drilldown"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.81801948,3.50735931 L10.4996894,9.1896894 L10.5,4 L12,4 L12,12 L4,12 L4,10.5 L9.6896894,10.4996894 L3.75735931,4.56801948 C3.46446609,4.27512627 3.46446609,3.80025253 3.75735931,3.50735931 C4.05025253,3.21446609 4.52512627,3.21446609 4.81801948,3.50735931 Z"/></svg></button>'),o=i.get("name")||i.get("id"),a=this._translate("Open {element}",{element:o});r.setAttribute("title",a),r.addEventListener("click",(function(){t.setRootElement(t.findRoot(zo(e)))})),n.add(e,"drilldown",{position:{bottom:-7,right:-8},html:r}),this._updateOverlayVisibility(e)},Jo.prototype._removeOverlay=function(e){this._overlays.remove({element:e,type:"drilldown"})},Jo.$inject=["canvas","eventBus","elementRegistry","overlays","translate"];var ea={__depends__:[Ao,To,jo],__init__:["drilldownBreadcrumbs","drilldownOverlayBehavior","drilldownCentering","subprocessCompatibility"],drilldownBreadcrumbs:["type",Wo],drilldownCentering:["type",Uo],drilldownOverlayBehavior:["type",Jo],subprocessCompatibility:["type",Xo]};function ta(e){e&&"function"==typeof e.stopPropagation&&e.stopPropagation()}function na(e){return e.originalEvent||e.srcEvent}function ia(e){ta(e),ta(na(e))}function ra(e){return e.pointers&&e.pointers.length&&(e=e.pointers[0]),e.touches&&e.touches.length&&(e=e.touches[0]),e?{x:e.clientX,y:e.clientY}:null}function oa(){return/mac/i.test(navigator.platform)}function aa(e,t){return(na(e)||e).button===t}function sa(e){return aa(e,0)}function ca(e){var t=na(e)||e;return!!sa(e)&&(oa()?t.metaKey:t.ctrlKey)}function pa(e){var t=na(e)||e;return sa(e)&&t.shiftKey}function la(e){return!0}function ua(e){return sa(e)||function(e){return aa(e,1)}(e)}function ha(e,t,n){var i=this;function r(n,i,r){var o,a;(function(e,t){var n=c[e]||sa;return!n(t)})(n,i)||(r?a=t.getGraphics(r):(o=i.delegateTarget||i.target)&&(a=o,r=t.get(a)),a&&r&&!1===e.fire(n,{element:r,gfx:a,originalEvent:i})&&(i.stopPropagation(),i.preventDefault()))}var o={};function a(e){return o[e]}var s={click:"element.click",contextmenu:"element.contextmenu",dblclick:"element.dblclick",mousedown:"element.mousedown",mousemove:"element.mousemove",mouseover:"element.hover",mouseout:"element.out",mouseup:"element.mouseup"},c={"element.contextmenu":la,"element.mousedown":ua,"element.mouseup":ua,"element.click":ua,"element.dblclick":ua};function p(e,t,n,i){var a=o[n]=function(e){r(n,e)};i&&(c[n]=i),a.$delegate=ce.bind(e,"svg, .djs-element",t,a)}function l(e,t,n){var i=a(n);i&&ce.unbind(e,t,i.$delegate)}e.on("canvas.destroy",(function(e){var t;t=e.svg,g(s,(function(e,n){l(t,n,e)}))})),e.on("canvas.init",(function(e){var t;t=e.svg,g(s,(function(e,n){p(t,n,e)}))})),e.on(["shape.added","connection.added"],(function(t){var n=t.element,i=t.gfx;e.fire("interactionEvents.createHit",{element:n,gfx:i})})),e.on(["shape.changed","connection.changed"],500,(function(t){var n=t.element,i=t.gfx;e.fire("interactionEvents.updateHit",{element:n,gfx:i})})),e.on("interactionEvents.createHit",500,(function(e){var t=e.element,n=e.gfx;i.createDefaultHit(t,n)})),e.on("interactionEvents.updateHit",(function(e){var t=e.element,n=e.gfx;i.updateDefaultHit(t,n)}));var u=f("djs-hit djs-hit-stroke"),h=f("djs-hit djs-hit-click-stroke"),d={all:f("djs-hit djs-hit-all"),"click-stroke":h,stroke:u,"no-move":f("djs-hit djs-hit-no-move")};function f(e,t){return t=L({stroke:"white",strokeWidth:15},t||{}),n.cls(e,["no-fill","no-border"],t)}function m(e,t){var n=d[t];if(!n)throw new Error("invalid hit type <"+t+">");return _e(e,n),e}function v(e,t){ye(e,t)}this.removeHits=function(e){g(me(".djs-hit",e),Fe)},this.createDefaultHit=function(e,t){var n,i=e.waypoints,r=e.isFrame;return i?this.createWaypointsHit(t,i):(n=r?"stroke":"all",this.createBoxHit(t,n,{width:e.width,height:e.height}))},this.createWaypointsHit=function(e,t){var n=ot(t);return m(n,"stroke"),v(e,n),n},this.createBoxHit=function(e,t,n){n=L({x:0,y:0},n);var i=Ae("rect");return m(i,t),_e(i,n),v(e,i),i},this.updateDefaultHit=function(e,t){var n=fe(".djs-hit",t);if(n)return e.waypoints?at(n,e.waypoints):_e(n,{width:e.width,height:e.height}),n},this.fire=r,this.triggerMouseEvent=function(e,t,n){var i=s[e];if(!i)throw new Error("unmapped DOM event name <"+e+">");return r(i,t,n)},this.mouseHandler=a,this.registerEvent=p,this.unregisterEvent=l}ha.$inject=["eventBus","elementRegistry","styles"];var da={__init__:["interactionEvents"],interactionEvents:["type",ha]};function fa(e,t){this._eventBus=e,this._canvas=t,this._selectedElements=[];var n=this;e.on(["shape.remove","connection.remove"],(function(e){var t=e.element;n.deselect(t)})),e.on(["diagram.clear","root.set"],(function(e){n.select(null)}))}fa.$inject=["eventBus","canvas"],fa.prototype.deselect=function(e){var t=this._selectedElements,n=t.indexOf(e);if(-1!==n){var i=t.slice();t.splice(n,1),this._eventBus.fire("selection.changed",{oldSelection:i,newSelection:t})}},fa.prototype.get=function(){return this._selectedElements},fa.prototype.isSelected=function(e){return-1!==this._selectedElements.indexOf(e)},fa.prototype.select=function(e,t){var n=this._selectedElements,i=n.slice();p(e)||(e=e?[e]:[]);var r=this._canvas,o=r.getRootElement();e=e.filter((function(e){var t=r.findRoot(e);return o===t})),t?g(e,(function(e){-1===n.indexOf(e)&&n.push(e)})):this._selectedElements=n=e.slice(),this._eventBus.fire("selection.changed",{oldSelection:i,newSelection:n})};var ma="hover",va="selected";function ya(e,t){function n(t,n){e.addMarker(t,n)}function i(t,n){e.removeMarker(t,n)}this._canvas=e,t.on("element.hover",(function(e){n(e.element,ma)})),t.on("element.out",(function(e){i(e.element,ma)})),t.on("selection.changed",(function(e){var t=e.oldSelection,r=e.newSelection;g(t,(function(e){-1===r.indexOf(e)&&function(e){i(e,va)}(e)})),g(r,(function(e){-1===t.indexOf(e)&&function(e){n(e,va)}(e)}))}))}function ga(e,t,n,i){e.on("create.end",500,(function(e){var n=e.context,i=n.canExecute,r=n.elements,o=(n.hints||{}).autoSelect;if(i){if(!1===o)return;p(o)?t.select(o):t.select(r.filter(ba))}})),e.on("connect.end",500,(function(e){var n=e.context.connection;n&&t.select(n)})),e.on("shape.move.end",500,(function(e){var n=e.previousSelection||[],r=i.get(e.context.shape.id);m(n,(function(e){return r.id===e.id}))||t.select(r)})),e.on("element.click",(function(e){if(sa(e)){var i=e.element;i===n.getRootElement()&&(i=null);var r=t.isSelected(i),o=t.get().length>1,a=pa(e);if(r&&o)return a?t.deselect(i):t.select(i);r?t.deselect(i):t.select(i,a)}}))}function ba(e){return!e.hidden}ya.$inject=["canvas","eventBus"],ga.$inject=["eventBus","selection","canvas","elementRegistry"];var _a={__init__:["selectionVisuals","selectionBehavior"],__depends__:[da],selection:["type",fa],selectionVisuals:["type",ya],selectionBehavior:["type",ga]};function xa(e){Tr.call(this,e)}e(xa,Tr),xa.prototype._modules=[wo,ea,Ao,_a,yo],xa.prototype._moddleExtensions={};var wa=["c","C"],Ea=["v","V"],Sa=["y","Y"],Ca=["z","Z"];function ka(e){return!e.altKey&&(e.ctrlKey||e.metaKey)}function Ra(e,t){return-1!==(e=p(e)?e:[e]).indexOf(t.key)||-1!==e.indexOf(t.code)}function Pa(e){return e.shiftKey}var Aa="keyboard.keydown",Ma="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 Ta(e,t){var n=this;this._config=e=e||{},this._eventBus=t,this._keydownHandler=this._keydownHandler.bind(this),this._keyupHandler=this._keyupHandler.bind(this),t.on("diagram.destroy",(function(){n._fire("destroy"),n.unbind()})),e.bindTo&&console.error("unsupported configuration <keyboard.bindTo>",new Error(Ma));var i=e&&!1!==e.bind;t.on("canvas.init",(function(e){n._target=e.svg,i&&n.bind(),n._fire("init")}))}Ta.$inject=["config.keyboard","eventBus"],Ta.prototype._keydownHandler=function(e){this._keyHandler(e,Aa)},Ta.prototype._keyupHandler=function(e){this._keyHandler(e,"keyboard.keyup")},Ta.prototype._keyHandler=function(e,t){if(!this._isEventIgnored(e)){var n={keyEvent:e};this._eventBus.fire(t||Aa,n)&&e.preventDefault()}},Ta.prototype._isEventIgnored=function(e){return!1},Ta.prototype.bind=function(e){e&&console.error("unsupported argument <node>",new Error(Ma)),this.unbind(),e=this._node=this._target,oe.bind(e,"keydown",this._keydownHandler),oe.bind(e,"keyup",this._keyupHandler),this._fire("bind")},Ta.prototype.getBinding=function(){return this._node},Ta.prototype.unbind=function(){var e=this._node;e&&(this._fire("unbind"),oe.unbind(e,"keydown",this._keydownHandler),oe.unbind(e,"keyup",this._keyupHandler)),this._node=null},Ta.prototype._fire=function(e){this._eventBus.fire("keyboard."+e,{node:this._node})},Ta.prototype.addListener=function(e,t,n){h(e)&&(n=t,t=e,e=1e3),this._eventBus.on(n||Aa,e,t)},Ta.prototype.removeListener=function(e,t){this._eventBus.off(t||Aa,e)},Ta.prototype.hasModifier=function(e){return e.ctrlKey||e.metaKey||e.shiftKey||e.altKey},Ta.prototype.isCmd=ka,Ta.prototype.isShift=Pa,Ta.prototype.isKey=Ra;function Da(e,t){var n=this;e.on("editorActions.init",500,(function(e){var i=e.editorActions;n.registerBindings(t,i)}))}Da.$inject=["eventBus","keyboard"],Da.prototype.registerBindings=function(e,t){function n(n,i){t.isRegistered(n)&&e.addListener(i)}n("undo",(function(e){if(function(e){return ka(e)&&!Pa(e)&&Ra(Ca,e)}(e.keyEvent))return t.trigger("undo"),!0})),n("redo",(function(e){if(function(e){return ka(e)&&(Ra(Sa,e)||Ra(Ca,e)&&Pa(e))}(e.keyEvent))return t.trigger("redo"),!0})),n("copy",(function(e){if(function(e){return ka(e)&&Ra(wa,e)}(e.keyEvent))return t.trigger("copy"),!0})),n("paste",(function(e){if(function(e){return ka(e)&&Ra(Ea,e)}(e.keyEvent))return t.trigger("paste"),!0})),n("stepZoom",(function(e){var n=e.keyEvent;if(Ra(["+","Add","="],n)&&ka(n))return t.trigger("stepZoom",{value:1}),!0})),n("stepZoom",(function(e){var n=e.keyEvent;if(Ra(["-","Subtract"],n)&&ka(n))return t.trigger("stepZoom",{value:-1}),!0})),n("zoom",(function(e){var n=e.keyEvent;if(Ra("0",n)&&ka(n))return t.trigger("zoom",{value:1}),!0})),n("removeSelection",(function(e){if(Ra(["Backspace","Delete","Del"],e.keyEvent))return t.trigger("removeSelection"),!0}))};var Ba={__init__:["keyboard","keyboardBindings"],keyboard:["type",Ta],keyboardBindings:["type",Da]},Na={moveSpeed:50,moveSpeedAccelerated:200};function ja(e,t,n){var i=this;this._config=L({},Na,e||{}),t.addListener((function(e){var n=e.keyEvent,r=i._config;if(!t.isCmd(n))return;if(t.isKey(["ArrowLeft","Left","ArrowUp","Up","ArrowDown","Down","ArrowRight","Right"],n)){var o,a=t.isShift(n)?r.moveSpeedAccelerated:r.moveSpeed;switch(n.key){case"ArrowLeft":case"Left":o="left";break;case"ArrowUp":case"Up":o="up";break;case"ArrowRight":case"Right":o="right";break;case"ArrowDown":case"Down":o="down"}return i.moveCanvas({speed:a,direction:o}),!0}})),this.moveCanvas=function(e){var t=0,i=0,r=e.speed/Math.min(Math.sqrt(n.viewbox().scale),1);switch(e.direction){case"left":t=r;break;case"up":i=r;break;case"right":t=-r;break;case"down":i=-r}n.scroll({dx:t,dy:i})}}ja.$inject=["config.keyboardMove","keyboard","canvas"];var Oa={__depends__:[Ba],__init__:["keyboardMove"],keyboardMove:["type",ja]},La=/^djs-cursor-.*$/;function $a(e){var t=X(document.body);t.removeMatching(La),e&&t.add("djs-cursor-"+e)}function Ia(){$a(null)}function Fa(e,t){function n(){return!1}return t=t||"element.click",e.once(t,5e3,n),function(){e.off(t,n)}}function za(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function Ha(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Va(e,t){var n;function i(e){return a(e.originalEvent)}function r(i){var r,o=n.start,a=n.button,s=ra(i),c=Ha(s,o);(!n.dragging&&(r=c,Math.sqrt(Math.pow(r.x,2)+Math.pow(r.y,2))>15)&&(n.dragging=!0,0===a&&Fa(e),$a("grab")),n.dragging)&&(c=Ha(s,n.last||n.start),t.scroll({dx:c.x,dy:c.y}),n.last=s);i.preventDefault()}function o(e){oe.unbind(document,"mousemove",r),oe.unbind(document,"mouseup",o),n=null,Ia()}function a(e){if(!J(e.target,".djs-draggable")){var t=e.button;if(!(t>=2||e.ctrlKey||e.shiftKey||e.altKey))return n={button:t,start:ra(e)},oe.bind(document,"mousemove",r),oe.bind(document,"mouseup",o),!0}}e.on("canvas.focus.changed",(function(t){t.focused?e.on("element.mousedown",500,i):e.off("element.mousedown",i)})),this.isActive=function(){return!!n}}Va.$inject=["eventBus","canvas"];var Ga={__init__:["moveCanvas"],moveCanvas:["type",Va]};function Wa(e){return Math.log(e)/Math.log(10)}function Ua(e,t){var n=Wa(e.min),i=Wa(e.max);return(Math.abs(n)+Math.abs(i))/t}var qa=Math.sign||function(e){return e>=0?1:-1},Ka={min:.2,max:4};function Ya(e,t,n){e=e||{},this._enabled=!1,this._canvas=n,this._container=n._container,this._handleWheel=O(this._handleWheel,this),this._totalDelta=0,this._scale=e.scale||.75;var i=this;t.on("canvas.focus.changed",(function(t){i._init(t.focused&&!1!==e.enabled)}))}Ya.$inject=["config.zoomScroll","eventBus","canvas"],Ya.prototype.scroll=function(e){this._canvas.scroll(e)},Ya.prototype.reset=function(){this._canvas.zoom("fit-viewport")},Ya.prototype.zoom=function(e,t){var n=Ua(Ka,20);this._totalDelta+=e,Math.abs(this._totalDelta)>.1&&(this._zoom(e,t,n),this._totalDelta=0)},Ya.prototype._handleWheel=function(e){if(this._canvas.isFocused()){var t=this._container;e.preventDefault();var n,i=e.ctrlKey||oa()&&e.metaKey,r=e.shiftKey,o=-1*this._scale;if(o*=i?0===e.deltaMode?.02:.32:0===e.deltaMode?1:16,i){var a=t.getBoundingClientRect(),s={x:e.clientX-a.left,y:e.clientY-a.top};n=Math.sqrt(Math.pow(e.deltaY,2)+Math.pow(e.deltaX,2))*qa(e.deltaY)*o,this.zoom(n,s)}else n=r?{dx:o*e.deltaY,dy:0}:{dx:o*e.deltaX,dy:o*e.deltaY},this.scroll(n)}},Ya.prototype.stepZoom=function(e,t){var n=Ua(Ka,10);this._zoom(e,t,n)},Ya.prototype._zoom=function(e,t,n){var i=this._canvas,r=e>0?1:-1,o=Wa(i.zoom()),a=Math.round(o/n)*n;a+=n*r;var s,c,p=Math.pow(10,a);i.zoom((s=Ka,c=p,Math.max(s.min,Math.min(s.max,c))),t)},Ya.prototype.toggle=function(e){var t=this._container,n=this._handleWheel,i=this._enabled;return void 0===e&&(e=!i),i!==e&&oe[e?"bind":"unbind"](t,"wheel",n,!1),this._enabled=e,e},Ya.prototype._init=function(e){this.toggle(e)};var Xa={__init__:["zoomScroll"],zoomScroll:["type",Ya]};function Za(e){xa.call(this,e)}function Qa(e){return e&&e[e.length-1]}function Ja(e){return e.y}function es(e){return e.x}e(Za,xa),Za.prototype._navigationModules=[Oa,Ga,Xa],Za.prototype._modules=[].concat(xa.prototype._modules,Za.prototype._navigationModules);var ts={left:es,center:es,right:function(e){return e.x+e.width},top:Ja,middle:Ja,bottom:function(e){return e.y+e.height}};function ns(e,t){this._modeling=e,this._rules=t}ns.$inject=["modeling","rules"],ns.prototype._getOrientationDetails=function(e){var t="x",n="width";return-1!==["top","bottom","middle"].indexOf(e)&&(t="y",n="height"),{axis:t,dimension:n}},ns.prototype._isType=function(e,t){return-1!==t.indexOf(e)},ns.prototype._alignmentPosition=function(e,t){var n,i,r,o=this._getOrientationDetails(e),a=o.axis,s=o.dimension,c={},p={},l=!1;if(this._isType(e,["left","top"]))c[e]=t[0][a];else if(this._isType(e,["right","bottom"]))r=Qa(t),c[e]=r[a]+r[s];else if(this._isType(e,["center","middle"])){if(g(t,(function(e){var t=e[a]+Math.round(e[s]/2);p[t]?p[t].elements.push(e):p[t]={elements:[e],center:t}})),n=A(p,(function(e){return e.elements.length>1&&(l=!0),e.elements.length})),l)return c[e]=Qa(n).center,c;i=t[0],r=Qa(t=A(t,(function(e){return e[a]+e[s]}))),c[e]=function(e,t){return Math.round((e[a]+t[a]+t[s])/2)}(i,r)}return c},ns.prototype.trigger=function(e,t){var n,i=this._modeling,r=y(e,(function(e){return!(e.waypoints||e.host||e.labelTarget)}));if(p(n=this._rules.allowed("elements.align",{elements:r}))&&(r=n),!(r.length<2)&&n){var o=A(r,ts[t]),a=this._alignmentPosition(t,o);i.alignElements(o,a)}};var is={__init__:["alignElements"],alignElements:["type",ns]};const rs=new Eo;function os(e){this._scheduled={},e.on("diagram.destroy",(()=>{Object.keys(this._scheduled).forEach((e=>{this.cancel(e)}))}))}os.$inject=["eventBus"],os.prototype.schedule=function(e,t=rs.next()){this.cancel(t);const n=this._schedule(e,t);return this._scheduled[t]=n,n.promise},os.prototype._schedule=function(e,t){const n=function(){const e={};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e}(),i=setTimeout((()=>{try{this._scheduled[t]=null;try{n.resolve(e())}catch(e){n.reject(e)}}catch(e){console.error("Scheduler#_schedule execution failed",e)}}));return{executionId:i,promise:n.promise}},os.prototype.cancel=function(e){const t=this._scheduled[e];t&&(this._cancel(t),this._scheduled[e]=null)},os.prototype._cancel=function(e){clearTimeout(e.executionId)};var as={scheduler:["type",os]},ss=".entry";function cs(e,t,n,i){this._canvas=e,this._elementRegistry=t,this._eventBus=n,this._scheduler=i,this._current=null,this._init()}cs.$inject=["canvas","elementRegistry","eventBus","scheduler"],cs.prototype._init=function(){var e=this;this._eventBus.on("selection.changed",(function(t){var n=t.newSelection,i=n.length?1===n.length?n[0]:n:null;i?e.open(i,!0):e.close()})),this._eventBus.on("elements.changed",(function(t){var n=t.elements,i=e._current;if(i){var r=i.target,o=p(r)?r:[r];if(o.filter((function(e){return n.includes(e)})).length){e.close();var a=o.filter((function(t){return e._elementRegistry.get(t.id)}));a.length&&e._updateAndOpen(a.length>1?a:a[0])}}})),this._eventBus.on("canvas.viewbox.changed",(function(){e._updatePosition()})),this._eventBus.on("element.marker.update",(function(t){if(e.isOpen()){var n=t.element,i=e._current;(p(i.target)?i.target:[i.target]).includes(n)&&e._updateVisibility()}})),this._container=this._createContainer()},cs.prototype._createContainer=function(){var e=he('<div class="djs-context-pad-parent"></div>');return this._canvas.getContainer().appendChild(e),e},cs.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("contextPad.getProviders",e,(function(e){e.providers.push(t)}))},cs.prototype.getEntries=function(e){var t=this._getProviders(),n=p(e)?"getMultiElementContextPadEntries":"getContextPadEntries",i={};return g(t,(function(t){if(h(t[n])){var r=t[n](e);h(r)?i=r(i):g(r,(function(e,t){i[t]=e}))}})),i},cs.prototype.trigger=function(e,t,n){var i,r,o=this,a=t.delegateTarget||t.target;return a?(i=K(a,"data-action"),r=t.originalEvent||t,"mouseover"!==e?"mouseout"===e?(clearTimeout(this._timeout),void(this._mouseout&&(this._mouseout(),this._mouseout=null))):this.triggerEntry(i,e,r,n):void(this._timeout=setTimeout((function(){o._mouseout=o.triggerEntry(i,"hover",r,n)}),300))):t.preventDefault()},cs.prototype.triggerEntry=function(e,t,n,i){if(this.isShown()){var r=this._current.target,o=this._current.entries[e];if(o){var a=o.action;if(!1!==this._eventBus.fire("contextPad.trigger",{entry:o,event:n})){if(h(a)){if("click"===t)return a(n,r,i)}else if(a[t])return a[t](n,r,i);n.preventDefault()}}}},cs.prototype.open=function(e,t){!t&&this.isOpen(e)||(this.close(),this._updateAndOpen(e))},cs.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"contextPad.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},cs.prototype._updateAndOpen=function(e){var t,n=this.getEntries(e),i=this._createHtml(e);g(n,(function(e,n){var r,o=e.group||"default",a=he(e.html||'<div class="entry" draggable="true"></div>');K(a,"data-action",n),(r=fe("[data-group="+Oo(o)+"]",i))||(K(r=he('<div class="group"></div>'),"data-group",o),i.appendChild(r)),r.appendChild(a),e.className&&function(e,t){var n=X(e);(t=p(t)?t:t.split(/\s+/g)).forEach((function(e){n.add(e)}))}(a,e.className),e.title&&K(a,"title",e.title),e.imageUrl&&(K(t=he("<img>"),"src",e.imageUrl),t.style.width="100%",t.style.height="100%",a.appendChild(t))})),X(i).add("open"),this._current={entries:n,html:i,target:e},this._updatePosition(),this._updateVisibility(),this._eventBus.fire("contextPad.open",{current:this._current})},cs.prototype._createHtml=function(e){var t=this,n=he('<div class="djs-context-pad"></div>');return ce.bind(n,ss,"click",(function(e){t.trigger("click",e)})),ce.bind(n,ss,"dragstart",(function(e){t.trigger("dragstart",e)})),ce.bind(n,ss,"mouseover",(function(e){t.trigger("mouseover",e)})),ce.bind(n,ss,"mouseout",(function(e){t.trigger("mouseout",e)})),oe.bind(n,"mousedown",(function(e){e.stopPropagation()})),this._container.appendChild(n),this._eventBus.fire("contextPad.create",{target:e,pad:n}),n},cs.prototype.getPad=function(e){let t;return 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")),t=this.isOpen()&&function(e,t){return e=p(e)?e:[e],t=p(t)?t:[t],e.length===t.length&&x(e,(function(e){return t.includes(e)}))}(this._current.target,e)?this._current.html:this._createHtml(e),{html:t}},cs.prototype.close=function(){this.isOpen()&&(clearTimeout(this._timeout),this._container.innerHTML="",this._eventBus.fire("contextPad.close",{current:this._current}),this._current=null)},cs.prototype.isOpen=function(e){var t=this._current;if(!t)return!1;if(!e)return!0;var n=t.target;return p(e)===p(n)&&(p(e)?e.length===n.length&&x(e,(function(e){return n.includes(e)})):n===e)},cs.prototype.isShown=function(){return this.isOpen()&&X(this._current.html).has("open")},cs.prototype.show=function(){this.isOpen()&&(X(this._current.html).add("open"),this._updatePosition(),this._eventBus.fire("contextPad.show",{current:this._current}))},cs.prototype.hide=function(){this.isOpen()&&(X(this._current.html).remove("open"),this._eventBus.fire("contextPad.hide",{current:this._current}))},cs.prototype._getPosition=function(e){if(!p(e)&&sn(e)){var t=this._canvas.viewbox(),n=(o=e).waypoints[o.waypoints.length-1],i=n.x*t.scale-t.x*t.scale,r=n.y*t.scale-t.y*t.scale;return{left:i+8*this._canvas.zoom(),top:r}}var o,a=this._canvas.getContainer().getBoundingClientRect(),s=this._getTargetBounds(e);return{left:s.right-a.left+8*this._canvas.zoom(),top:s.top-a.top}},cs.prototype._updatePosition=function(){this._scheduler.schedule((()=>{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(n){n in t&&(e.style[n]=t[n]+"px")}))}}),"ContextPad#_updatePosition")},cs.prototype._updateVisibility=function(){this._scheduler.schedule((()=>{if(this.isOpen()){var e=this,t=this._current.target;(p(t)?t:[t]).some((function(t){return e._canvas.hasMarker(t,"djs-element-hidden")}))?e.hide():e.show()}}),"ContextPad#_updateVisibility")},cs.prototype._getTargetBounds=function(e){var t=this;return(p(e)?e:[e]).map((function(e){return t._canvas.getGraphics(e)})).reduce((function(e,t){const n=t.getBoundingClientRect();return e.top=Math.min(e.top,n.top),e.right=Math.max(e.right,n.right),e.bottom=Math.max(e.bottom,n.bottom),e.left=Math.min(e.left,n.left),e.x=e.left,e.y=e.top,e.width=e.right-e.left,e.height=e.bottom-e.top,e}),{top:1/0,right:-1/0,bottom:-1/0,left:1/0})};var ps,ls,us,hs,ds,fs,ms,vs={__depends__:[da,as,Ao],contextPad:["type",cs]},ys={},gs=[],bs=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_s=Array.isArray;function xs(e,t){for(var n in t)e[n]=t[n];return e}function ws(e){var t=e.parentNode;t&&t.removeChild(e)}function Es(e,t,n){var i,r,o,a={};for(o in t)"key"==o?i=t[o]:"ref"==o?r=t[o]:a[o]=t[o];if(arguments.length>2&&(a.children=arguments.length>3?ps.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===a[o]&&(a[o]=e.defaultProps[o]);return Ss(e,a,i,r,null)}function Ss(e,t,n,i,r){var o={type:e,props:t,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++us:r,__i:-1,__u:0};return null==r&&null!=ls.vnode&&ls.vnode(o),o}function Cs(e){return e.children}function ks(e,t){this.props=e,this.context=t}function Rs(e,t){if(null==t)return e.__?Rs(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?Rs(e):null}function Ps(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return Ps(e)}}function As(e){(!e.__d&&(e.__d=!0)&&hs.push(e)&&!Ms.__r++||ds!==ls.debounceRendering)&&((ds=ls.debounceRendering)||fs)(Ms)}function Ms(){var e,t,n,i,r,o,a,s,c;for(hs.sort(ms);e=hs.shift();)e.__d&&(t=hs.length,i=void 0,o=(r=(n=e).__v).__e,s=[],c=[],(a=n.__P)&&((i=xs({},r)).__v=r.__v+1,ls.vnode&&ls.vnode(i),Is(a,i,r,n.__n,void 0!==a.ownerSVGElement,32&r.__u?[o]:null,s,null==o?Rs(r):o,!!(32&r.__u),c),i.__v=r.__v,i.__.__k[i.__i]=i,Fs(s,i,c),i.__e!=o&&Ps(i)),hs.length>t&&hs.sort(ms));Ms.__r=0}function Ts(e,t,n,i,r,o,a,s,c,p,l){var u,h,d,f,m,v=i&&i.__k||gs,y=t.length;for(n.__d=c,Ds(n,t,v),c=n.__d,u=0;u<y;u++)null!=(d=n.__k[u])&&"boolean"!=typeof d&&"function"!=typeof d&&(h=-1===d.__i?ys:v[d.__i]||ys,d.__i=u,Is(e,d,h,r,o,a,s,c,p,l),f=d.__e,d.ref&&h.ref!=d.ref&&(h.ref&&Hs(h.ref,null,d),l.push(d.ref,d.__c||f,d)),null==m&&null!=f&&(m=f),65536&d.__u||h.__k===d.__k?c=Bs(d,c,e):"function"==typeof d.type&&void 0!==d.__d?c=d.__d:f&&(c=f.nextSibling),d.__d=void 0,d.__u&=-196609);n.__d=c,n.__e=m}function Ds(e,t,n){var i,r,o,a,s,c=t.length,p=n.length,l=p,u=0;for(e.__k=[],i=0;i<c;i++)a=i+u,null!=(r=e.__k[i]=null==(r=t[i])||"boolean"==typeof r||"function"==typeof r?null:"string"==typeof r||"number"==typeof r||"bigint"==typeof r||r.constructor==String?Ss(null,r,null,null,null):_s(r)?Ss(Cs,{children:r},null,null,null):void 0===r.constructor&&r.__b>0?Ss(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r)?(r.__=e,r.__b=e.__b+1,s=Ns(r,n,a,l),r.__i=s,o=null,-1!==s&&(l--,(o=n[s])&&(o.__u|=131072)),null==o||null===o.__v?(-1==s&&u--,"function"!=typeof r.type&&(r.__u|=65536)):s!==a&&(s===a+1?u++:s>a?l>c-a?u+=s-a:u--:s<a?s==a-1&&(u=s-a):u=0,s!==i+u&&(r.__u|=65536))):(o=n[a])&&null==o.key&&o.__e&&!(131072&o.__u)&&(o.__e==e.__d&&(e.__d=Rs(o)),Vs(o,o,!1),n[a]=null,l--);if(l)for(i=0;i<p;i++)null!=(o=n[i])&&!(131072&o.__u)&&(o.__e==e.__d&&(e.__d=Rs(o)),Vs(o,o))}function Bs(e,t,n){var i,r;if("function"==typeof e.type){for(i=e.__k,r=0;i&&r<i.length;r++)i[r]&&(i[r].__=e,t=Bs(i[r],t,n));return t}e.__e!=t&&(n.insertBefore(e.__e,t||null),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8===t.nodeType);return t}function Ns(e,t,n,i){var r=e.key,o=e.type,a=n-1,s=n+1,c=t[n];if(null===c||c&&r==c.key&&o===c.type&&!(131072&c.__u))return n;if(i>(null==c||131072&c.__u?0:1))for(;a>=0||s<t.length;){if(a>=0){if((c=t[a])&&!(131072&c.__u)&&r==c.key&&o===c.type)return a;a--}if(s<t.length){if((c=t[s])&&!(131072&c.__u)&&r==c.key&&o===c.type)return s;s++}}return-1}function js(e,t,n){"-"===t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||bs.test(t)?n:n+"px"}function Os(e,t,n,i,r){var o;e:if("style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof i&&(e.style.cssText=i=""),i)for(t in i)n&&t in n||js(e.style,t,"");if(n)for(t in n)i&&n[t]===i[t]||js(e.style,t,n[t])}else if("o"===t[0]&&"n"===t[1])o=t!==(t=t.replace(/(PointerCapture)$|Capture$/i,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?i?n.u=i.u:(n.u=Date.now(),e.addEventListener(t,o?$s:Ls,o)):e.removeEventListener(t,o?$s:Ls,o);else{if(r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&"rowSpan"!==t&&"colSpan"!==t&&"role"!==t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,n))}}function Ls(e){if(this.l){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(ls.event?ls.event(e):e)}}function $s(e){if(this.l)return this.l[e.type+!0](ls.event?ls.event(e):e)}function Is(e,t,n,i,r,o,a,s,c,p){var l,u,h,d,f,m,v,y,g,b,_,x,w,E,S,C=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(c=!!(32&n.__u),o=[s=t.__e=n.__e]),(l=ls.__b)&&l(t);e:if("function"==typeof C)try{if(y=t.props,g=(l=C.contextType)&&i[l.__c],b=l?g?g.props.value:l.__:i,n.__c?v=(u=t.__c=n.__c).__=u.__E:("prototype"in C&&C.prototype.render?t.__c=u=new C(y,b):(t.__c=u=new ks(y,b),u.constructor=C,u.render=Gs),g&&g.sub(u),u.props=y,u.state||(u.state={}),u.context=b,u.__n=i,h=u.__d=!0,u.__h=[],u._sb=[]),null==u.__s&&(u.__s=u.state),null!=C.getDerivedStateFromProps&&(u.__s==u.state&&(u.__s=xs({},u.__s)),xs(u.__s,C.getDerivedStateFromProps(y,u.__s))),d=u.props,f=u.state,u.__v=t,h)null==C.getDerivedStateFromProps&&null!=u.componentWillMount&&u.componentWillMount(),null!=u.componentDidMount&&u.__h.push(u.componentDidMount);else{if(null==C.getDerivedStateFromProps&&y!==d&&null!=u.componentWillReceiveProps&&u.componentWillReceiveProps(y,b),!u.__e&&(null!=u.shouldComponentUpdate&&!1===u.shouldComponentUpdate(y,u.__s,b)||t.__v===n.__v)){for(t.__v!==n.__v&&(u.props=y,u.state=u.__s,u.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.forEach((function(e){e&&(e.__=t)})),_=0;_<u._sb.length;_++)u.__h.push(u._sb[_]);u._sb=[],u.__h.length&&a.push(u);break e}null!=u.componentWillUpdate&&u.componentWillUpdate(y,u.__s,b),null!=u.componentDidUpdate&&u.__h.push((function(){u.componentDidUpdate(d,f,m)}))}if(u.context=b,u.props=y,u.__P=e,u.__e=!1,x=ls.__r,w=0,"prototype"in C&&C.prototype.render){for(u.state=u.__s,u.__d=!1,x&&x(t),l=u.render(u.props,u.state,u.context),E=0;E<u._sb.length;E++)u.__h.push(u._sb[E]);u._sb=[]}else do{u.__d=!1,x&&x(t),l=u.render(u.props,u.state,u.context),u.state=u.__s}while(u.__d&&++w<25);u.state=u.__s,null!=u.getChildContext&&(i=xs(xs({},i),u.getChildContext())),h||null==u.getSnapshotBeforeUpdate||(m=u.getSnapshotBeforeUpdate(d,f)),Ts(e,_s(S=null!=l&&l.type===Cs&&null==l.key?l.props.children:l)?S:[S],t,n,i,r,o,a,s,c,p),u.base=t.__e,t.__u&=-161,u.__h.length&&a.push(u),v&&(u.__E=u.__=null)}catch(e){t.__v=null,c||null!=o?(t.__e=s,t.__u|=c?160:32,o[o.indexOf(s)]=null):(t.__e=n.__e,t.__k=n.__k),ls.__e(e,t,n)}else null==o&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=zs(n.__e,t,n,i,r,o,a,c,p);(l=ls.diffed)&&l(t)}function Fs(e,t,n){t.__d=void 0;for(var i=0;i<n.length;i++)Hs(n[i],n[++i],n[++i]);ls.__c&&ls.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(e){ls.__e(e,t.__v)}}))}function zs(e,t,n,i,r,o,a,s,c){var p,l,u,h,d,f,m,v=n.props,y=t.props,g=t.type;if("svg"===g&&(r=!0),null!=o)for(p=0;p<o.length;p++)if((d=o[p])&&"setAttribute"in d==!!g&&(g?d.localName===g:3===d.nodeType)){e=d,o[p]=null;break}if(null==e){if(null===g)return document.createTextNode(y);e=r?document.createElementNS("http://www.w3.org/2000/svg",g):document.createElement(g,y.is&&y),o=null,s=!1}if(null===g)v===y||s&&e.data===y||(e.data=y);else{if(o=o&&ps.call(e.childNodes),v=n.props||ys,!s&&null!=o)for(v={},p=0;p<e.attributes.length;p++)v[(d=e.attributes[p]).name]=d.value;for(p in v)d=v[p],"children"==p||("dangerouslySetInnerHTML"==p?u=d:"key"===p||p in y||Os(e,p,null,d,r));for(p in y)d=y[p],"children"==p?h=d:"dangerouslySetInnerHTML"==p?l=d:"value"==p?f=d:"checked"==p?m=d:"key"===p||s&&"function"!=typeof d||v[p]===d||Os(e,p,d,v[p],r);if(l)s||u&&(l.__html===u.__html||l.__html===e.innerHTML)||(e.innerHTML=l.__html),t.__k=[];else if(u&&(e.innerHTML=""),Ts(e,_s(h)?h:[h],t,n,i,r&&"foreignObject"!==g,o,a,o?o[0]:n.__k&&Rs(n,0),s,c),null!=o)for(p=o.length;p--;)null!=o[p]&&ws(o[p]);s||(p="value",void 0!==f&&(f!==e[p]||"progress"===g&&!f||"option"===g&&f!==v[p])&&Os(e,p,f,v[p],!1),p="checked",void 0!==m&&m!==e[p]&&Os(e,p,m,v[p],!1))}return e}function Hs(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(e){ls.__e(e,n)}}function Vs(e,t,n){var i,r;if(ls.unmount&&ls.unmount(e),(i=e.ref)&&(i.current&&i.current!==e.__e||Hs(i,null,t)),null!=(i=e.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){ls.__e(e,t)}i.base=i.__P=null,e.__c=void 0}if(i=e.__k)for(r=0;r<i.length;r++)i[r]&&Vs(i[r],t,n||"function"!=typeof e.type);n||null==e.__e||ws(e.__e),e.__=e.__e=e.__d=void 0}function Gs(e,t,n){return this.constructor(e,n)}function Ws(e,t,n){var i,r,o,a;ls.__&&ls.__(e,t),r=(i="function"==typeof n)?null:t.__k,o=[],a=[],Is(t,e=(!i&&n||t).__k=Es(Cs,null,[e]),r||ys,ys,void 0!==t.ownerSVGElement,!i&&n?[n]:r?null:t.firstChild?ps.call(t.childNodes):null,o,!i&&n?n:r?r.__e:t.firstChild,i,a),Fs(o,e,a)}ps=gs.slice,ls={__e:function(e,t,n,i){for(var r,o,a;t=t.__;)if((r=t.__c)&&!r.__)try{if((o=r.constructor)&&null!=o.getDerivedStateFromError&&(r.setState(o.getDerivedStateFromError(e)),a=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,i||{}),a=r.__d),a)return r.__E=r}catch(t){e=t}throw e}},us=0,ks.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=xs({},this.state),"function"==typeof e&&(e=e(xs({},n),this.props)),e&&xs(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),As(this))},ks.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),As(this))},ks.prototype.render=Cs,hs=[],fs="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ms=function(e,t){return e.__v.__b-t.__v.__b},Ms.__r=0;var Us=function(e,t,n,i){var r;t[0]=0;for(var o=1;o<t.length;o++){var a=t[o++],s=t[o]?(t[0]|=a?1:2,n[t[o++]]):t[++o];3===a?i[0]=s:4===a?i[1]=Object.assign(i[1]||{},s):5===a?(i[1]=i[1]||{})[t[++o]]=s:6===a?i[1][t[++o]]+=s+"":a?(r=e.apply(s,Us(e,s,n,["",null])),i.push(r),s[0]?t[0]|=2:(t[o-2]=0,t[o]=r)):i.push(s)}return i},qs=new Map;var Ks,Ys,Xs,Zs,Qs=function(e){var t=qs.get(this);return t||(t=new Map,qs.set(this,t)),(t=Us(this,t.get(e)||(t.set(e,t=function(e){for(var t,n,i=1,r="",o="",a=[0],s=function(e){1===i&&(e||(r=r.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?a.push(0,e,r):3===i&&(e||r)?(a.push(3,e,r),i=2):2===i&&"..."===r&&e?a.push(4,e,0):2===i&&r&&!e?a.push(5,0,!0,r):i>=5&&((r||!e&&5===i)&&(a.push(i,0,r,n),i=6),e&&(a.push(i,e,0,n),i=6)),r=""},c=0;c<e.length;c++){c&&(1===i&&s(),s(c));for(var p=0;p<e[c].length;p++)t=e[c][p],1===i?"<"===t?(s(),a=[a],i=3):r+=t:4===i?"--"===r&&">"===t?(i=1,r=""):r=t+r[0]:o?t===o?o="":r+=t:'"'===t||"'"===t?o=t:">"===t?(s(),i=1):i&&("="===t?(i=5,n=r,r=""):"/"===t&&(i<5||">"===e[c][p+1])?(s(),3===i&&(a=a[0]),i=a,(a=a[0]).push(2,0,i),i=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(s(),i=2):r+=t),3===i&&"!--"===r&&(i=4,a=a[0])}return s(),a}(e)),t),arguments,[])).length>1?t:t[0]}.bind(Es),Js=0,ec=[],tc=[],nc=ls,ic=nc.__b,rc=nc.__r,oc=nc.diffed,ac=nc.__c,sc=nc.unmount,cc=nc.__;function pc(e,t){nc.__h&&nc.__h(Ys,e,Js||t),Js=0;var n=Ys.__H||(Ys.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({__V:tc}),n.__[e]}function lc(e){return Js=1,function(e,t){var n=pc(Ks++,2);if(n.t=e,!n.__c&&(n.__=[wc(void 0,t),function(e){var t=n.__N?n.__N[0]:n.__[0],i=n.t(t,e);t!==i&&(n.__N=[i,n.__[1]],n.__c.setState({}))}],n.__c=Ys,!Ys.u)){var i=function(e,t,i){if(!n.__c.__H)return!0;var o=n.__c.__H.__.filter((function(e){return!!e.__c}));if(o.every((function(e){return!e.__N})))return!r||r.call(this,e,t,i);var a=!1;return o.forEach((function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(a=!0)}})),!(!a&&n.__c.props===e)&&(!r||r.call(this,e,t,i))};Ys.u=!0;var r=Ys.shouldComponentUpdate,o=Ys.componentWillUpdate;Ys.componentWillUpdate=function(e,t,n){if(this.__e){var a=r;r=void 0,i(e,t,n),r=a}o&&o.call(this,e,t,n)},Ys.shouldComponentUpdate=i}return n.__N||n.__}(wc,e)}function uc(e,t){var n=pc(Ks++,3);!nc.__s&&xc(n.__H,t)&&(n.__=e,n.i=t,Ys.__H.__h.push(n))}function hc(e,t){var n=pc(Ks++,4);!nc.__s&&xc(n.__H,t)&&(n.__=e,n.i=t,Ys.__h.push(n))}function dc(e){return Js=5,fc((function(){return{current:e}}),[])}function fc(e,t){var n=pc(Ks++,7);return xc(n.__H,t)?(n.__V=e(),n.i=t,n.__h=e,n.__V):n.__}function mc(e,t){return Js=8,fc((function(){return e}),t)}function vc(){for(var e;e=ec.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(bc),e.__H.__h.forEach(_c),e.__H.__h=[]}catch(t){e.__H.__h=[],nc.__e(t,e.__v)}}nc.__b=function(e){Ys=null,ic&&ic(e)},nc.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),cc&&cc(e,t)},nc.__r=function(e){rc&&rc(e),Ks=0;var t=(Ys=e.__c).__H;t&&(Xs===Ys?(t.__h=[],Ys.__h=[],t.__.forEach((function(e){e.__N&&(e.__=e.__N),e.__V=tc,e.__N=e.i=void 0}))):(t.__h.forEach(bc),t.__h.forEach(_c),t.__h=[],Ks=0)),Xs=Ys},nc.diffed=function(e){oc&&oc(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==ec.push(t)&&Zs===nc.requestAnimationFrame||((Zs=nc.requestAnimationFrame)||gc)(vc)),t.__H.__.forEach((function(e){e.i&&(e.__H=e.i),e.__V!==tc&&(e.__=e.__V),e.i=void 0,e.__V=tc}))),Xs=Ys=null},nc.__c=function(e,t){t.some((function(e){try{e.__h.forEach(bc),e.__h=e.__h.filter((function(e){return!e.__||_c(e)}))}catch(n){t.some((function(e){e.__h&&(e.__h=[])})),t=[],nc.__e(n,e.__v)}})),ac&&ac(e,t)},nc.unmount=function(e){sc&&sc(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach((function(e){try{bc(e)}catch(e){t=e}})),n.__H=void 0,t&&nc.__e(t,n.__v))};var yc="function"==typeof requestAnimationFrame;function gc(e){var t,n=function(){clearTimeout(i),yc&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(n,100);yc&&(t=requestAnimationFrame(n))}function bc(e){var t=Ys,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),Ys=t}function _c(e){var t=Ys;e.__c=e.__(),Ys=t}function xc(e,t){return!e||e.length!==t.length||t.some((function(t,n){return t!==e[n]}))}function wc(e,t){return"function"==typeof t?t(e):t}function Ec(e){var t,n,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=Ec(e[t]))&&(i&&(i+=" "),i+=n)}else for(n in e)e[n]&&(i&&(i+=" "),i+=n);return i}function Sc(){for(var e,t,n=0,i="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Ec(e))&&(i&&(i+=" "),i+=t);return i}function Cc(e){const{headerEntries:t,onSelect:n,selectedEntry:i,setSelectedEntry:r,title:o}=e,a=fc((()=>t.reduce(((e,t)=>{const n=t.group||"default",i=e.find((e=>e.id===n));return i?i.entries.push(t):e.push({id:n,entries:[t]}),e}),[])),[t]);return Qs` class 197 `,this._current.container)},Tc.prototype.open=function(e,t,n,i){if(!e)throw new Error("target is missing");if(!t)throw new Error("providers for <"+t+"> not found");if(!n)throw new Error("position is missing");this.isOpen()&&this.close();const{entries:r,headerEntries:o,emptyPlaceholder:a}=this._getContext(e,t);this._current={position:n,providerId:t,target:e,entries:r,headerEntries:o,emptyPlaceholder:a,container:this._createContainer({provider:t}),options:i},this._emit("open"),this._bindAutoClose(),this._render()},Tc.prototype.refresh=function(){if(!this.isOpen())return;const{target:e,providerId:t}=this._current,{entries:n,headerEntries:i,emptyPlaceholder:r}=this._getContext(e,t);this._current={...this._current,entries:n,headerEntries:i,emptyPlaceholder:r},this._emit("refresh"),this._render()},Tc.prototype._getContext=function(e,t){const n=this._getProviders(t);if(!n||!n.length)throw new Error("provider for <"+t+"> not found");const i=this._getEntries(e,n),r=this._getHeaderEntries(e,n);return{entries:i,headerEntries:r,emptyPlaceholder:this._getEmptyPlaceholder(n),empty:!(Object.keys(i).length||Object.keys(r).length)}},Tc.prototype.close=function(){this.isOpen()&&(this._emit("close"),this.reset(),this._canvas.restoreFocus(),this._current=null)},Tc.prototype.reset=function(){const e=this._current.container;Ws(null,e),ve(e)},Tc.prototype._emit=function(e,t){this._eventBus.fire(`popupMenu.${e}`,t)},Tc.prototype._onOpened=function(){this._emit("opened")},Tc.prototype._onClosed=function(){this._emit("closed")},Tc.prototype._createContainer=function(e){var t=this._canvas.getContainer();const n=he(`<div class="djs-popup-parent djs-scrollable" data-popup=${e.provider}></div>`);return t.appendChild(n),n},Tc.prototype._bindAutoClose=function(){this._eventBus.once(Mc,this.close,this)},Tc.prototype._unbindAutoClose=function(){this._eventBus.off(Mc,this.close,this)},Tc.prototype._updateScale=function(){var e,t,n=this._canvas.zoom(),i=this._config.scale,r=n;return!0!==i&&(!1===i?(e=1,t=1):(e=i.min,t=i.max),s(e)&&n<e&&(r=e),s(t)&&n>t&&(r=t)),r},Tc.prototype._ensureVisible=function(e,t){var n=document.documentElement.getBoundingClientRect(),i=e.getBoundingClientRect(),r={},o=t.x,a=t.y;return t.x+i.width>n.width&&(r.x=!0),t.y+i.height>n.height&&(r.y=!0),r.x&&r.y?(o=t.x-i.width,a=t.y-i.height):r.x?(o=t.x-i.width,a=t.y):r.y&&t.y<i.height?(o=t.x,a=10):r.y&&(o=t.x,a=t.y-i.height),t.y<n.top&&(a=t.y+i.height),{x:o,y:a}},Tc.prototype.isEmpty=function(e,t){if(!e)throw new Error("target is missing");if(!t)throw new Error("provider ID is missing");const n=this._getProviders(t);return!n||!n.length||this._getContext(e,t).empty},Tc.prototype.registerProvider=function(e,t,n){n||(n=t,t=1e3),this._eventBus.on("popupMenu.getProviders."+e,t,(function(e){e.providers.push(n)}))},Tc.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"popupMenu.getProviders."+e,providers:[]});return this._eventBus.fire(t),t.providers},Tc.prototype._getEntries=function(e,t){var n={};return g(t,(function(t){if(t.getPopupMenuEntries){var i=t.getPopupMenuEntries(e);h(i)?n=i(n):g(i,(function(e,t){n[t]=e}))}else g(t.getEntries(e),(function(e){var t=e.id;if(!t)throw new Error("entry ID is missing");n[t]=I(e,["id"])}))})),n},Tc.prototype._getHeaderEntries=function(e,t){var n={};return g(t,(function(t){if(t.getPopupMenuHeaderEntries){var i=t.getPopupMenuHeaderEntries(e);h(i)?n=i(n):g(i,(function(e,t){n[t]=e}))}else{if(!t.getHeaderEntries)return;g(t.getHeaderEntries(e),(function(e){var t=e.id;if(!t)throw new Error("entry ID is missing");n[t]=I(e,["id"])}))}})),n},Tc.prototype._getEmptyPlaceholder=function(e){const t=e.find((e=>h(e.getEmptyPlaceholder)));return t&&t.getEmptyPlaceholder()},Tc.prototype.isOpen=function(){return!!this._current},Tc.prototype.trigger=function(e,t,n="click"){if(e.preventDefault(),!t){let n=K(J(e.delegateTarget||e.target,".entry",!0),"data-id");t={id:n,...this._getEntry(n)}}const i=t.action;if(!1!==this._emit("trigger",{entry:t,event:e}))if(h(i)){if("click"===n)return i(e,t)}else if(i[n])return i[n](e,t)},Tc.prototype._getEntry=function(e){var t=this._current.entries[e]||this._current.headerEntries[e];if(!t)throw new Error("entry not found");return t};var Oc={search:["value",function(e,t,n){const{keys:i}=n;if(!(t=t.trim().toLowerCase()))throw new Error("<pattern> must not be empty");const r=t.trim().toLowerCase().split(/\s+/);return e.flatMap((e=>{const t=function(e,t,n){const{matchedWords:i,tokens:r}=n.reduce(((n,i)=>{const r=e[i],{tokens:o,matchedWords:a}=function(e,t){if(!e)return{tokens:[],matchedWords:{}};const n=[],i={},r=t.map(jc),o=[`(?<all>${r.join("\\s+")})`,...r].join("|"),a=new RegExp(o,"ig");let s,c=0;for(;s=a.exec(e);){const[r]=s,o=s.index,a=s.index+r.length,p=0===o,l=a===e.length,u=!!s.groups.all,h=p||/\s/.test(e.charAt(o-1)),d=l||/\s/.test(e.charAt(a+1));s.index>c&&n.push({value:e.slice(c,s.index),index:c}),n.push({value:r,index:s.index,match:!0,wordStart:h,wordEnd:d,start:p,end:l,all:u});const f=u?t:[r];for(const e of f)i[e.toLowerCase()]=!0;c=s.index+r.length}c<e.length&&n.push({value:e.slice(c),index:c});return{tokens:n,matchedWords:i}}(r,t);return{tokens:{...n.tokens,[i]:o},matchedWords:{...n.matchedWords,...a}}}),{matchedWords:{},tokens:{}});if(Object.keys(i).length!==t.length)return null;return r}(e,r,i);return t?{item:e,tokens:t}:[]})).sort(function(e){return(t,n)=>{for(const i of e){const e=Dc(t.tokens[i],n.tokens[i]);if(0!==e)return e;const r=Nc(t.item[i],n.item[i]);if(0!==r)return r}return 0}}(i))}]},Lc={__depends__:[Oc],__init__:["popupMenu"],popupMenu:["type",Tc]},$c={align:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2000 2000">\n <line x1="200" y1="150" x2="200" y2="1850" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="500" y="150" width="1300" height="700" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="500" y="1150" width="700" height="700" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',bottom:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="150" y1="1650" x2="1650" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="150" y="350" width="600" height="1300" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="1050" y="850" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',center:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="900" y1="150" x2="900" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="250" y="150" width="1300" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="500" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',left:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="100" y1="150" x2="100" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="100" y="150" width="1300" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="100" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',right:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="1650" y1="150" x2="1650" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="350" y="150" width="1300" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="850" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',top:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="150" y1="150" x2="1650" y2="150" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="150" y="150" width="600" height="1300" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="1050" y="150" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',middle:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="150" y1="900" x2="1650" y2="900" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="150" y="250" width="600" height="1300" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="1050" y="500" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>'};function Ic(e,t,n,i){e.registerProvider(900,this),this._contextPad=e,this._popupMenu=t,this._translate=n,this._canvas=i}Ic.$inject=["contextPad","popupMenu","translate","canvas"],Ic.prototype.getMultiElementContextPadEntries=function(e){var t={};return this._isAllowed(e)&&L(t,this._getEntries(e)),t},Ic.prototype._isAllowed=function(e){return!this._popupMenu.isEmpty(e,"align-elements")},Ic.prototype._getEntries=function(){var e=this;return{"align-elements":{group:"align-elements",title:e._translate("Align elements"),html:`<div class="entry">${$c.align}</div>`,action:{click:function(t,n){var i=e._getMenuPosition(n);L(i,{cursor:{x:t.x,y:t.y}}),e._popupMenu.open(n,"align-elements",i)}}}}},Ic.prototype._getMenuPosition=function(e){var t=this._contextPad.getPad(e).html.getBoundingClientRect();return{x:t.left,y:t.bottom+5}};var Fc=["left","center","right","top","middle","bottom"];function zc(e,t,n,i){this._alignElements=t,this._translate=n,this._popupMenu=e,this._rules=i,e.registerProvider("align-elements",this)}function Hc(e){Do.call(this,e),this.init()}function Vc(e){Hc.call(this,e)}zc.$inject=["popupMenu","alignElements","translate","rules"],zc.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&L(t,this._getEntries(e)),t},zc.prototype._isAllowed=function(e){return this._rules.allowed("elements.align",{elements:e})},zc.prototype._getEntries=function(e){var t=this._alignElements,n=this._translate,i=this._popupMenu,r={};return g(Fc,(function(o){r["align-elements-"+o]={group:"align",title:n("Align elements "+o),className:"bjs-align-elements-menu-entry",imageHtml:$c[o],action:function(){t.trigger(e,o),i.close()}}})),r},Hc.$inject=["eventBus"],e(Hc,Do),Hc.prototype.addRule=function(e,t,n){var i=this;"string"==typeof e&&(e=[e]),e.forEach((function(e){i.canExecute(e,t,(function(e,t,i){return n(e)}),!0)}))},Hc.prototype.init=function(){},Vc.$inject=["eventBus"],e(Vc,Hc),Vc.prototype.init=function(){this.addRule("elements.align",(function(e){var t=y(e.elements,(function(e){return!(e.waypoints||e.host||e.labelTarget)}));return!((t=st(t)).length<2)&&t}))};var Gc={__depends__:[is,vs,Lc],__init__:["alignElementsContextPadProvider","alignElementsMenuProvider","bpmnAlignElements"],alignElementsContextPadProvider:["type",Ic],alignElementsMenuProvider:["type",zc],bpmnAlignElements:["type",Vc]};function Wc(e,t,n,i){for(var r;r=qc(e,n,t);)n=i(t,n,r);return n}function Uc(e){return function(t,n,i){var r={x:n.x,y:n.y};return["x","y"].forEach((function(o){var a=e[o];if(a){var s="x"===o?"width":"height",c=a.margin,p=a.minDistance;r[o]=c<0?Math.min(i[o]+c-t[s]/2,n[o]-p+c):Math.max(i[o]+i[s]+c+t[s]/2,n[o]+p+c)}})),r}}function qc(e,t,n){var i={x:t.x-n.width/2,y:t.y-n.height/2,width:n.width,height:n.height},r=function(e){var t=Kc(e);e.host&&(t=t.concat(Kc(e.host)));e.attachers&&(t=t.concat(e.attachers.reduce((function(e,t){return e.concat(Kc(t))}),[])));return t}(e);return m(r,(function(e){return e!==n&&"intersect"===mn(e,i,10)}))}function Kc(e){return(t=e,t.outgoing.map((function(e){return e.target}))).concat(function(e){return e.incoming.map((function(e){return e.source}))}(e));var t}function Yc(){return!0}function Xc(e,t,n){e.on("autoPlace",100,(function(e){var t=e.shape;return function(e,t,n){n||(n={});var i=n.defaultDistance||50,r=fn(e),o=un(e);return{x:o.right+i+t.width/2,y:r.y}}(e.source,t)})),e.on("autoPlace.end",(function(e){n.scrollToElement(e.shape)})),this.append=function(n,i,r){e.fire("autoPlace.start",{source:n,shape:i});var o=e.fire("autoPlace",{source:n,shape:i}),a=t.appendShape(n,i,o,n.parent,r);return e.fire("autoPlace.end",{source:n,shape:a}),a}}function Zc(e,t){e.on("autoPlace.end",500,(function(e){t.select(e.shape)}))}Xc.$inject=["eventBus","modeling","canvas"],Zc.$inject=["eventBus","selection"];var Qc={__init__:["autoPlaceSelectionBehavior"],autoPlace:["type",Xc],autoPlaceSelectionBehavior:["type",Zc]};function Jc(e,t){for(d(t)&&(t=[t]);e=e.parent;)if(yr(e,t))return e;return null}function ep(e,t){var n=Jc(e,"bpmn:Process");if(n)return!0;var i,r=["bpmn:Participant","bpmn:Lane"];if(n=Jc(e,r))return Lr(n);if(yr(e,r))return Lr(e);for(i=gr(e);i&&!vr(i,"bpmn:Process");i=i.$parent);if(!t)return!0;var o=t.find((function(e){var t=gr(e);return t&&t.get("processRef")===i}));return!o||Lr(o)}function tp(e,t,n){var i=ep(e,n);return vr(t,"bpmn:TextAnnotation")?function(e,t,n){var i=un(e),r=n?{x:i.right+t.width/2,y:i.top-50-t.height/2}:{x:i.right+50+t.width/2,y:i.bottom+t.height/2};sn(e)&&(r=fn(e),n?(r.x+=100,r.y-=50):(r.x+=100,r.y+=50));var o={margin:n?-30:30,minDistance:20},a=n?{y:o}:{x:o};return Wc(e,t,r,Uc(a))}(e,t,i):yr(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])?function(e,t,n){var i=un(e),r=n?{x:i.right-10+t.width/2,y:i.bottom+40+t.width/2}:{x:i.left-40-t.width/2,y:i.bottom-10+t.height/2},o={margin:30,minDistance:30},a=n?{x:o}:{y:o};return Wc(e,t,r,Uc(a))}(e,t,i):vr(t,"bpmn:FlowNode")?function(e,t,n){var i=un(e),r=fn(e),o=n?{directionHint:"e",minDistance:80,baseOrientation:"left",boundaryOrientation:"top",start:"top",end:"bottom"}:{directionHint:"s",minDistance:90,baseOrientation:"top",boundaryOrientation:"left",start:"left",end:"right"},a=function(e,t){t||(t={});var n=t.defaultDistance||50,i=t.direction||"e",r=t.filter,o=t.getWeight||function(t){return t.source===e?1:-1},a=t.maxDistance||250,s=t.reference||"start";function c(e,t){return"n"===i?"start"===s?un(e).top-un(t).bottom:"center"===s?un(e).top-fn(t).y:un(e).top-un(t).top:"w"===i?"start"===s?un(e).left-un(t).right:"center"===s?un(e).left-fn(t).x:un(e).left-un(t).left:"s"===i?"start"===s?un(t).top-un(e).bottom:"center"===s?fn(t).y-un(e).bottom:un(t).bottom-un(e).bottom:"start"===s?un(t).left-un(e).right:"center"===s?fn(t).x-un(e).right:un(t).right-un(e).right}r||(r=Yc);var p=e.incoming.filter(r).map((function(t){var n=o(t),i=n<0?c(t.source,e):c(e,t.source);return{id:t.source.id,distance:i,weight:n}})),l=e.outgoing.filter(r).map((function(t){var n=o(t),i=n>0?c(e,t.target):c(t.target,e);return{id:t.target.id,distance:i,weight:n}})),u=_(p.concat(l).reduce((function(e,t){return e[t.id+"__weight_"+t.weight]=t,e}),{}),(function(e,t){var n=t.distance,i=t.weight;return n<0||n>a||(e[String(n)]||(e[String(n)]=0),e[String(n)]+=1*i,(!e.distance||e[e.distance]<e[String(n)])&&(e.distance=n)),e}),{});return u.distance||n}(e,{filter:function(e){return vr(e,"bpmn:SequenceFlow")},direction:o.directionHint}),s=30,c=o.minDistance,p=o.baseOrientation;vr(e,"bpmn:BoundaryEvent")&&-1!==(p=mn(e,e.host,-25)).indexOf(o.boundaryOrientation)&&(s*=-1);var l=n?{x:i.right+a+t.width/2,y:r.y+np(p,c,o)}:{x:r.x+np(p,c,o),y:i.bottom+a+t.height/2},u={margin:s,minDistance:c},h=n?{y:u}:{x:u};return Wc(e,t,l,Uc(h))}(e,t,i):void 0}function np(e,t,n){return e.includes(n.start)?-1*t:e.includes(n.end)?t:0}function ip(e,t){e.on("autoPlace",(function(e){var n=e.shape;return tp(e.source,n,t)}))}ip.$inject=["eventBus","elementRegistry"];var rp={__depends__:[Qc],__init__:["bpmnAutoPlace"],bpmnAutoPlace:["type",ip]};function op(e,t,n,r){Do.call(this,e),this._elementRegistry=t,this._modeling=n,this._rules=r;var o=this;this.postExecuted(["shape.create"],(function(e){var t=e.context,n=t.hints||{},i=t.shape,r=t.parent||t.newParent;!1!==n.autoResize&&o._expand([i],r)})),this.postExecuted(["elements.move"],(function(e){var t=e.context,n=i(C(t.closure.topLevel)),r=t.hints,a=!r||r.autoResize;!1!==a&&g(k(n,(function(e){return e.parent.id})),(function(e,t){p(a)&&(e=e.filter((function(e){return m(a,M({id:e.id}))}))),o._expand(e,t)}))})),this.postExecuted(["shape.toggleCollapse"],(function(e){var t=e.context,n=t.hints,i=t.shape;n&&!1===n.autoResize||i.collapsed||o._expand(i.children||[],i)})),this.postExecuted(["shape.resize"],(function(e){var t=e.context,n=t.hints,i=t.shape,r=i.parent;n&&!1===n.autoResize||r&&o._expand([i],r)}))}function ap(e){e.invoke(op,this)}function sp(e){Hc.call(this,e);var t=this;this.addRule("element.autoResize",(function(e){return t.canResize(e.elements,e.target)}))}function cp(e,t){sp.call(this,e),this._modeling=t}op.$inject=["eventBus","elementRegistry","modeling","rules"],e(op,Do),op.prototype._getOptimalBounds=function(e,t){var n=this.getOffset(t),i=this.getPadding(t),r=un(ht(e)),o=un(t),a={};return r.top-o.top<i.top&&(a.top=r.top-n.top),r.left-o.left<i.left&&(a.left=r.left-n.left),o.right-r.right<i.right&&(a.right=r.right+n.right),o.bottom-r.bottom<i.bottom&&(a.bottom=r.bottom+n.bottom),hn(L({},o,a))},op.prototype._expand=function(e,t){if("string"==typeof t&&(t=this._elementRegistry.get(t)),this._rules.allowed("element.autoResize",{elements:e,target:t})){var n=this._getOptimalBounds(e,t);if(function(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}(n,t)){var i=function(e,t){var n="";e=un(e),t=un(t),e.top>t.top&&(n=n.concat("n"));e.right<t.right&&(n=n.concat("w"));e.bottom<t.bottom&&(n=n.concat("s"));e.left>t.left&&(n=n.concat("e"));return n}($(t,["x","y","width","height"]),n);this.resize(t,n,{autoResize:i});var r=t.parent;r&&this._expand([t],r)}}},op.prototype.getOffset=function(e){return{top:60,bottom:60,left:100,right:100}},op.prototype.getPadding=function(e){return{top:2,bottom:2,left:15,right:15}},op.prototype.resize=function(e,t,n){this._modeling.resizeShape(e,t,null,n)},ap.$inject=["injector"],e(ap,op),ap.prototype.resize=function(e,t,n){vr(e,"bpmn:Participant")?this._modeling.resizeLane(e,t,null,n):this._modeling.resizeShape(e,t,null,n)},sp.$inject=["eventBus"],e(sp,Hc),sp.prototype.canResize=function(e,t){return!1},e(cp,sp),cp.$inject=["eventBus","modeling"],cp.prototype.canResize=function(e,t){if(vr(t.di,"bpmndi:BPMNPlane"))return!1;if(!vr(t,"bpmn:Participant")&&!vr(t,"bpmn:Lane")&&!vr(t,"bpmn:SubProcess"))return!1;var n=!0;return g(e,(function(e){(vr(e,"bpmn:Lane")||cn(e))&&(n=!1)})),n};var pp={__init__:["bpmnAutoResize","bpmnAutoResizeProvider"],bpmnAutoResize:["type",ap],bpmnAutoResizeProvider:["type",cp]};function lp(e,t,n){var i,r,o=this,a=n.get("dragging",!1);a&&t.on("drag.start",(function(n){t.once("drag.move",1500,(function(t){!function(t){if(!t.hover){var n=t.originalEvent,i=o._findTargetGfx(n),r=i&&e.get(i);i&&r&&(t.stopPropagation(),a.hover({element:r,gfx:i}),a.move(n))}}(t)}))})),t.on("element.hover",(function(e){i=e.gfx,r=e.element})),t.on("element.hover",1500,(function(e){r&&t.fire("element.out",{element:r,gfx:i})})),t.on("element.out",(function(){i=null,r=null})),this._findTargetGfx=function(e){var t;if(e instanceof MouseEvent)return t=ra(e),function(e){return J(e,"svg, .djs-element",!0)}(document.elementFromPoint(t.x,t.y))}}lp.$inject=["elementRegistry","eventBus","injector"];var up={__init__:["hoverFix"],hoverFix:["type",lp]},hp=Math.round,dp="djs-drag-active";function fp(e){e.preventDefault()}function mp(e,t,n,i){var r,o={threshold:5,trapClick:!0};function a(e){var n=t.viewbox(),i=t._container.getBoundingClientRect();return{x:n.x+(e.x-i.left)/n.scale,y:n.y+(e.y-i.top)/n.scale}}function s(t,n){n=n||r;var i=e.createEvent(L({},n.payload,n.data,{isTouch:n.isTouch}));return!1!==e.fire("drag."+t,i)&&e.fire(n.prefix+"."+t,i)}function c(e,i){var o,c=r.payload,p=r.displacement,l=r.globalStart,u=ra(e),h=Ha(u,l),d=r.localStart,f=a(u),v=Ha(f,d);if(!r.active&&(i||(o=h,Math.sqrt(Math.pow(o.x,2)+Math.pow(o.y,2))>r.threshold))){if(L(c,{x:hp(d.x+p.x),y:hp(d.y+p.y),dx:0,dy:0},{originalEvent:e}),!1===s("start"))return m();r.active=!0,r.keepSelection||(c.previousSelection=n.get(),n.select(null)),r.cursor&&$a(r.cursor),t.addMarker(t.getRootElement(),dp)}ia(e),r.active&&(L(c,{x:hp(f.x+p.x),y:hp(f.y+p.y),dx:hp(v.x),dy:hp(v.y)},{originalEvent:e}),s("move"))}function p(e){var t=!0;r.active&&(e&&(r.payload.originalEvent=e,ia(e)),t=s("end")),!1===t&&s("rejected"),s("ended",v(!0!==t))}function l(e){Ra("Escape",e)&&(fp(e),m())}function u(t){var n;r.active&&(n=Fa(e),setTimeout(n,400),fp(t)),p(t)}function h(e){c(e)}function d(e){var t=r.payload;t.hoverGfx=e.gfx,t.hover=e.element,s("hover")}function f(e){s("out");var t=r.payload;t.hoverGfx=null,t.hover=null}function m(e){var t;if(r){var n=r.active;n&&s("cancel"),t=v(e),n&&s("canceled",t)}}function v(o){var a,v;s("cleanup"),Ia(),v=r.trapClick?u:p,oe.unbind(document,"mousemove",c),oe.unbind(document,"dragstart",fp),oe.unbind(document,"selectstart",fp),oe.unbind(document,"mousedown",v,!0),oe.unbind(document,"mouseup",v,!0),oe.unbind(document,"keyup",l),oe.unbind(document,"touchstart",h,!0),oe.unbind(document,"touchcancel",m,!0),oe.unbind(document,"touchmove",c,!0),oe.unbind(document,"touchend",p,!0),e.off("element.hover",d),e.off("element.out",f),t.removeMarker(t.getRootElement(),dp);var y=r.payload.previousSelection;return!1!==o&&y&&!n.get().length&&function(e){var t=e.filter((function(e){return i.get(e.id)}));t.length&&n.select(t)}(y),a=r,r=null,a}e.on("diagram.destroy",m),this.init=function(t,n,i,v){r&&m(!1),"string"==typeof n&&(v=i,i=n,n=null);var y,g,b,_,x,w=(v=L({},o,v||{})).data||{};_=v.trapClick?u:p,t?(y=na(t)||t,g=ra(t),ia(t),"dragstart"===y.type&&fp(y)):(y=null,g={x:0,y:0}),b=a(g),n||(n=b),x=function(e){return"undefined"!=typeof TouchEvent&&e instanceof TouchEvent}(y),r=L({prefix:i,data:w,payload:{},globalStart:g,displacement:Ha(n,b),localStart:b,isTouch:x},v),v.manual||(x?(oe.bind(document,"touchstart",h,!0),oe.bind(document,"touchcancel",m,!0),oe.bind(document,"touchmove",c,!0),oe.bind(document,"touchend",p,!0)):(oe.bind(document,"mousemove",c),oe.bind(document,"dragstart",fp),oe.bind(document,"selectstart",fp),oe.bind(document,"mousedown",_,!0),oe.bind(document,"mouseup",_,!0)),oe.bind(document,"keyup",l),e.on("element.hover",d),e.on("element.out",f)),s("init"),v.autoActivate&&c(t,!0)},this.move=c,this.hover=d,this.out=f,this.end=p,this.cancel=m,this.context=function(){return r},this.setOptions=function(e){L(o,e)}}mp.$inject=["eventBus","canvas","selection","elementRegistry"];var vp={__depends__:[up,_a],dragging:["type",mp]};function yp(e,t,n){this._canvas=n,this._opts=L({scrollThresholdIn:[20,20,20,20],scrollThresholdOut:[0,0,0,0],scrollRepeatTimeout:15,scrollStep:10},e);var i=this;t.on("drag.move",(function(e){var t=i._toBorderPoint(e);i.startScroll(t)})),t.on(["drag.cleanup"],(function(){i.stopScroll()}))}function gp(e,t,n){return t<e&&e<n}yp.$inject=["config.autoScroll","eventBus","canvas"],yp.prototype.startScroll=function(e){var t=this._canvas,n=this._opts,i=this,r=t.getContainer().getBoundingClientRect(),o=[e.x,e.y,r.width-e.x,r.height-e.y];this.stopScroll();for(var a=0,s=0,c=0;c<4;c++)gp(o[c],n.scrollThresholdOut[c],n.scrollThresholdIn[c])&&(0===c?a=n.scrollStep:1==c?s=n.scrollStep:2==c?a=-n.scrollStep:3==c&&(s=-n.scrollStep));0===a&&0===s||(t.scroll({dx:a,dy:s}),this._scrolling=setTimeout((function(){i.startScroll(e)}),n.scrollRepeatTimeout))},yp.prototype.stopScroll=function(){clearTimeout(this._scrolling)},yp.prototype.setOptions=function(e){this._opts=L({},this._opts,e)},yp.prototype._toBorderPoint=function(e){var t=this._canvas._container.getBoundingClientRect(),n=ra(e.originalEvent);return{x:n.x-t.left,y:n.y-t.top}};var bp={__depends__:[vp],__init__:["autoScroll"],autoScroll:["type",yp]};function _p(e){this._commandStack=e.get("commandStack",!1)}_p.$inject=["injector"],_p.prototype.allowed=function(e,t){var n=!0,i=this._commandStack;return i&&(n=i.canExecute(e,t)),void 0===n||n};var xp={__init__:["rules"],rules:["type",_p]},wp=Math.round,Ep=Math.max;function Sp(e,t){return function(e,t){var n,i;for(n=0;i=e[n];n++)if(wt(i,t)<=10)return{point:e[n],bendpoint:!0,index:n};return null}(e,t)||function(e,t){var n,i,r=Jt(function(e,t){return[["M",e.x,e.y],["m",0,-t],["a",t,t,0,1,1,0,2*t],["a",t,t,0,1,1,0,-2*t],["z"]]}(t,10),(n=[],e.forEach((function(e,t){n.push([0===t?"M":"L",e.x,e.y])})),n)),o=r[0],a=r[r.length-1];return o?o!==a?o.segment2!==a.segment2?{point:e[i=Ep(o.segment2,a.segment2)-1],bendpoint:!0,index:i}:{point:{x:wp(o.x+a.x)/2,y:wp(o.y+a.y)/2},index:o.segment2}:{point:{x:wp(o.x),y:wp(o.y)},index:o.segment2}:null}(e,t)}function Cp(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}function kp(e){return Math.atan((e[1].y-e[0].y)/(e[1].x-e[0].x))}function Rp(e,t){var n=t[0],i=t[1],r={x:i.x-n.x,y:i.y-n.y},o=function(e,t,n){var i=[{n:e[0]-n[0],lambda:t[0]},{n:e[1]-n[1],lambda:t[1]}];return-(i[0].n*t[0]+i[1].n*t[1])/(i[0].lambda*t[0]+i[1].lambda*t[1])}([n.x,n.y],[r.x,r.y],[e.x,e.y]);return{x:n.x+o*r.x,y:n.y+o*r.y}}function Pp(e,t){var n=Rp(e,t);return Cp({x:n.x-e.x,y:n.y-e.y})}function Ap(e,t){return Cp({x:e.x-t.x,y:e.y-t.y})}var Mp="djs-bendpoint",Tp="djs-segment-dragger";function Dp(e,t,n){var i=function(e,t){var n,i=ra(t),r=e._container.getBoundingClientRect();n={x:r.left,y:r.top};var o=e.viewbox();return{x:o.x+(i.x-n.x)/o.scale,y:o.y+(i.y-n.y)/o.scale}}(e,n);return Sp(t,i)}function Bp(e,t){var n=Ae("g");we(n).add(Mp),ye(e,n);var i=Ae("circle");_e(i,{cx:0,cy:0,r:4}),we(i).add("djs-visual"),ye(n,i);var r=Ae("circle");return _e(r,{cx:0,cy:0,r:10}),we(r).add("djs-hit"),ye(n,r),t&&we(n).add(t),n}function Np(e,t,n,i){var r=Ae("g");ye(e,r);var o=function(e,t,n){var i=t.x-e.x,r=t.y-e.y;return Op("h"===n?i:r)}(t,n,i),a=Ae("rect");_e(a,{x:-9,y:-3,width:18,height:6}),we(a).add("djs-visual"),ye(r,a);var s=Ae("rect");return _e(s,{x:-o/2,y:-8.5,width:o,height:17}),we(s).add("djs-hit"),ye(r,s),Un(r,"v"===i?90:0),r}function jp(e,t,n){var i=Ae("g"),r=Rt(t,n),o=St(t,n);return ye(e,i),Np(i,t,n,o),we(i).add(Tp),we(i).add("h"===o?"horizontal":"vertical"),Wn(i,r.x,r.y),i}function Op(e){return Math.abs(Math.round(2*e/3))}function Lp(e,t){var n=function(e,t){for(var n,i=t.waypoints,r=1/0,o=0;o<i.length-1;o++){var a=Pp(e,[i[o],i[o+1]]);a<r&&(r=a,n=o)}return[i[n],i[n+1]]}(e,t);return Rp(e,n)}function $p(e,t,n,i,r){function o(e,n){var o,a=n.waypoints,s=Dp(t,a,e);if(s)return o=function(e,t){var n,i,r=e.waypoints;return t.index<=0||t.bendpoint?null:(i=St((n={start:r[t.index-1],end:r[t.index]}).start,n.end))?Op("h"===i?n.end.x-n.start.x:n.end.y-n.start.y)/2:null}(n,s),!function(e,t,n){var i,r,o,a,s,c,p=e.index,l=e.point;return!(p<=0||e.bendpoint)&&(o=Rt(i=t[p-1],r=t[p]),a=St(i,r),s=Math.abs(l.x-o.x),c=Math.abs(l.y-o.y),a&&s<=n&&c<=n)}(s,a,o)?i.start(e,n,s.index,!s.bendpoint):r.start(e,n,s.index),!0}function a(e,t,i){oe.bind(e,t,(function(e){n.triggerMouseEvent(t,e,i),e.stopPropagation()}))}function s(e,n){var i=t.getLayer("overlays"),r=fe('.djs-bendpoints[data-element-id="'+Oo(e.id)+'"]',i);return!r&&n&&(_e(r=Ae("g"),{"data-element-id":e.id}),we(r).add("djs-bendpoints"),ye(i,r),a(r,"mousedown",e),a(r,"click",e),a(r,"dblclick",e)),r}function c(e,t){return fe('.djs-segment-dragger[data-segment-idx="'+e+'"]',t)}function p(e,t){t.waypoints.forEach((function(t,n){var i=Bp(e);ye(e,i),Wn(i,t.x,t.y)})),Bp(e,"floating")}function l(e,t){for(var n,i,r,o=t.waypoints,s=1;s<o.length;s++)St(n=o[s-1],i=o[s])&&(_e(r=jp(e,n,i),{"data-segment-idx":s}),a(r,"mousemove",t))}function u(e){var t=s(e);return t||(p(t=s(e,!0),e),l(t,e)),t}function h(e){var t=s(e);t&&(!function(e){g(me("."+Tp,e),(function(e){Fe(e)}))}(t),function(e){g(me("."+Mp,e),(function(e){Fe(e)}))}(t),l(t,e),p(t,e))}function d(e,t,n){var i,r,o=c(t.index,e),a=n[t.index-1],s=n[t.index],p=t.point,l=Rt(a,s),u=St(a,s);o&&(i=function(e){return fe(".djs-visual",e)}(o),r={x:p.x-l.x,y:p.y-l.y},"v"===u&&(r={x:r.y,y:r.x}),Wn(i,r.x,r.y))}e.on("connection.changed",(function(e){h(e.element)})),e.on("connection.remove",(function(e){var t=s(e.element);t&&Fe(t)})),e.on("element.marker.update",(function(e){var t,n=e.element;n.waypoints&&(t=u(n),e.add?we(t).add(e.marker):we(t).remove(e.marker))})),e.on("element.mousemove",(function(e){var n,i,r=e.element,o=r.waypoints;if(o){if(n=s(r,!0),!(i=Dp(t,o,e.originalEvent)))return;!function(e,t){var n=fe(".floating",e),i=t.point;n&&Wn(n,i.x,i.y)}(n,i),i.bendpoint||d(n,i,o)}})),e.on("element.mousedown",(function(e){if(sa(e)){var t=e.originalEvent,n=e.element;if(n.waypoints)return o(t,n)}})),e.on("selection.changed",(function(e){var t=e.newSelection[0];t&&t.waypoints&&u(t)})),e.on("element.hover",(function(e){var t=e.element;t.waypoints&&(u(t),n.registerEvent(e.gfx,"mousemove","element.mousemove"))})),e.on("element.out",(function(e){n.unregisterEvent(e.gfx,"mousemove","element.mousemove")})),e.on("element.updateId",(function(e){var t=e.element,n=e.newId;if(t.waypoints){var i=s(t);i&&_e(i,{"data-element-id":n})}})),this.addHandles=u,this.updateHandles=h,this.getBendpointsContainer=s,this.getSegmentDragger=c}$p.$inject=["eventBus","canvas","interactionEvents","bendpointMove","connectionSegmentMove"];var Ip=Math.round,Fp="reconnectStart",zp="reconnectEnd",Hp="updateWaypoints";function Vp(e,t,n,i,r,o){this._injector=e,this.start=function(e,t,o,a){var s,c=n.getGraphics(t),p=t.source,l=t.target,u=t.waypoints,h=(s=a||0!==o?a||o!==u.length-1?Hp:zp:Fp)===Hp?"connection.updateWaypoints":"connection.reconnect",d=r.allowed(h,{connection:t,source:p,target:l});!1===d&&(d=r.allowed(h,{connection:t,source:l,target:p})),!1!==d&&i.init(e,"bendpoint.move",{data:{connection:t,connectionGfx:c,context:{allowed:d,bendpointIndex:o,connection:t,source:p,target:l,insert:a,type:s}}})},t.on("bendpoint.move.hover",(function(e){var t,n=e.context,i=n.connection,o=i.source,a=i.target,s=e.hover,c=n.type;if(n.hover=s,s){var p=c===Hp?"connection.updateWaypoints":"connection.reconnect";if(t=n.allowed=r.allowed(p,{connection:i,source:c===Fp?s:o,target:c===zp?s:a}))return n.source=c===Fp?s:o,void(n.target=c===zp?s:a);!1===t&&(t=n.allowed=r.allowed(p,{connection:i,source:c===zp?s:a,target:c===Fp?s:o})),t&&(n.source=c===zp?s:a,n.target=c===Fp?s:o)}})),t.on(["bendpoint.move.out","bendpoint.move.cleanup"],(function(e){var t=e.context,n=t.type;t.hover=null,t.source=null,t.target=null,n!==Hp&&(t.allowed=!1)})),t.on("bendpoint.move.end",(function(e){var t=e.context,n=t.allowed,i=t.bendpointIndex,r=t.connection,a=t.insert,s=r.waypoints.slice(),c=t.source,p=t.target,l=t.type,u=t.hints||{},h={x:Ip(e.x),y:Ip(e.y)};if(!n)return!1;l===Hp?(a?s.splice(i,0,h):s[i]=h,u.bendpointMove={insert:a,bendpointIndex:i},s=this.cropWaypoints(r,s),o.updateWaypoints(r,function(e){e=e.slice();for(var t,n,i,r=0;e[r];)t=e[r],n=e[r-1],0===wt(t,i=e[r+1])||Et(n,i,t)?e.splice(r,1):r++;return e}(s),u)):(l===Fp?(u.docking="source",Gp(t)&&(u.docking="target",u.newWaypoints=s.reverse())):l===zp&&(u.docking="target",Gp(t)&&(u.docking="source",u.newWaypoints=s.reverse())),o.reconnect(r,c,p,h,u))}),this)}function Gp(e){var t=e.hover,n=e.source,i=e.target,r=e.type;return r===Fp?t&&i&&t===i&&n!==i:r===zp?t&&n&&t===n&&n!==i:void 0}Vp.$inject=["injector","eventBus","canvas","dragging","rules","modeling"],Vp.prototype.cropWaypoints=function(e,t){var n=this._injector.get("connectionDocking",!1);if(!n)return t;var i=e.waypoints;return e.waypoints=t,e.waypoints=n.getCroppedWaypoints(e),t=e.waypoints,e.waypoints=i,t};var Wp="updateWaypoints",Up="connect-ok",qp="connect-not-ok",Kp="connect-hover",Yp="djs-updating",Xp="djs-dragging";function Zp(e,t,n,i){this._injector=t;var r=t.get("connectionPreview",!1);n.on("bendpoint.move.start",(function(e){var t=e.context,n=t.bendpointIndex,r=t.connection,o=t.insert,a=r.waypoints,s=a.slice();t.waypoints=a,o&&s.splice(n,0,{x:e.x,y:e.y}),r.waypoints=s,we(t.draggerGfx=Bp(i.getLayer("overlays"))).add("djs-dragging"),i.addMarker(r,Xp),i.addMarker(r,Yp)})),n.on("bendpoint.move.hover",(function(e){var t=e.context,n=t.allowed,r=t.hover,o=t.type;if(r){if(i.addMarker(r,Kp),o===Wp)return;n?(i.removeMarker(r,qp),i.addMarker(r,Up)):!1===n&&(i.removeMarker(r,Up),i.addMarker(r,qp))}})),n.on(["bendpoint.move.out","bendpoint.move.cleanup"],1100,(function(e){var t=e.context,n=t.hover,r=t.target;n&&(i.removeMarker(n,Kp),i.removeMarker(n,r?Up:qp))})),n.on("bendpoint.move.move",(function(t){var n=t.context,i=n.allowed,o=n.bendpointIndex,a=n.draggerGfx,s=n.hover,c=n.type,p=n.connection,l=p.source,u=p.target,h=p.waypoints.slice(),d={x:t.x,y:t.y},f=n.hints||{},m={};r&&(f.connectionStart&&(m.connectionStart=f.connectionStart),f.connectionEnd&&(m.connectionEnd=f.connectionEnd),"reconnectStart"===c?Gp(n)?(m.connectionEnd=m.connectionEnd||d,m.source=u,m.target=s||l,h=h.reverse()):(m.connectionStart=m.connectionStart||d,m.source=s||l,m.target=u):"reconnectEnd"===c?Gp(n)?(m.connectionStart=m.connectionStart||d,m.source=s||u,m.target=l,h=h.reverse()):(m.connectionEnd=m.connectionEnd||d,m.source=l,m.target=s||u):(m.noCropping=!0,m.noLayout=!0,h[o]=d),c===Wp&&(h=e.cropWaypoints(p,h)),m.waypoints=h,r.drawPreview(n,i,m)),Wn(a,t.x,t.y)}),this),n.on(["bendpoint.move.end","bendpoint.move.cancel"],1100,(function(e){var t=e.context,n=t.connection,o=t.draggerGfx,a=t.hover,s=t.target,c=t.waypoints;n.waypoints=c,Fe(o),i.removeMarker(n,Yp),i.removeMarker(n,Xp),a&&(i.removeMarker(a,Up),i.removeMarker(a,s?Up:qp)),r&&r.cleanUp(t)}))}Zp.$inject=["bendpointMove","injector","eventBus","canvas"];var Qp="connect-hover",Jp="djs-updating";function el(e,t,n){return tl(e,t,e[t]+n)}function tl(e,t,n){return{x:"x"===t?n:e.x,y:"y"===t?n:e.y}}function nl(e){return"x"===e?"y":"x"}function il(e,t,n){var i,r;return e.original?e.original:(i=fn(t),tl(e,r=nl(n),i[r]))}function rl(e,t,n,i,r,o){var a=e.get("connectionDocking",!1);function s(e,t){if(!a)return t;var n,i=e.waypoints;return e.waypoints=t,n=a.getCroppedWaypoints(e),e.waypoints=i,n}function c(e){r.update("connection",e.connection,e.connectionGfx)}function p(e,t,n){var i=e.newWaypoints,r=function(e,t,n,i){var r=Math.max(t[i],n[i]),o=Math.min(t[i],n[i]);return tl(t,i,Math.min(Math.max(o+20,e[i]),r-20))}(n,i[e.segmentStartIndex+t],i[e.segmentEndIndex+t],nl(e.axis));Wn(e.draggerGfx,r.x,r.y)}this.start=function(e,t,r){var o,a,s,c,p=n.getGraphics(t),l=r-1,u=r,h=t.waypoints,d=h[l],f=h[u],m=Dp(n,h,e);(a=St(d,f))&&(s="v"===a?"x":"y",0===l&&(d=il(d,t.source,s)),u===h.length-1&&(f=il(f,t.target,s)),o={connection:t,segmentStartIndex:l,segmentEndIndex:u,segmentStart:d,segmentEnd:f,axis:s,dragPosition:c=m?m.point:{x:(d.x+f.x)/2,y:(d.y+f.y)/2}},i.init(e,c,"connectionSegment.move",{cursor:"x"===s?"resize-ew":"resize-ns",data:{connection:t,connectionGfx:p,context:o}}))},t.on("connectionSegment.move.start",(function(e){var t=e.context,i=e.connection,r=n.getLayer("overlays");t.originalWaypoints=i.waypoints.slice(),t.draggerGfx=jp(r,t.segmentStart,t.segmentEnd),we(t.draggerGfx).add("djs-dragging"),n.addMarker(i,Jp)})),t.on("connectionSegment.move.move",(function(e){var t,n,i=e.context,r=i.connection,o=i.segmentStartIndex,a=i.segmentEndIndex,l=i.segmentStart,u=i.segmentEnd,h=i.axis,d=i.originalWaypoints.slice(),f=el(l,h,e["d"+h]),m=el(u,h,e["d"+h]),v=d.length,y=0;d[o]=f,d[a]=m,o<2&&(t=mn(r.source,f),1===o?"intersect"===t&&(d.shift(),d[0]=f,y--):"intersect"!==t&&(d.unshift(l),y++)),a>v-3&&(n=mn(r.target,m),a===v-2?"intersect"===n&&(d.pop(),d[d.length-1]=m):"intersect"!==n&&d.push(u)),i.newWaypoints=r.waypoints=s(r,d),p(i,y,e),i.newSegmentStartIndex=o+y,c(e)})),t.on("connectionSegment.move.hover",(function(e){e.context.hover=e.hover,n.addMarker(e.hover,Qp)})),t.on(["connectionSegment.move.out","connectionSegment.move.cleanup"],(function(e){var t=e.context.hover;t&&n.removeMarker(t,Qp)})),t.on("connectionSegment.move.cleanup",(function(e){var t=e.context,i=t.connection;t.draggerGfx&&Fe(t.draggerGfx),n.removeMarker(i,Jp)})),t.on(["connectionSegment.move.cancel","connectionSegment.move.end"],(function(e){var t=e.context;t.connection.waypoints=t.originalWaypoints,c(e)})),t.on("connectionSegment.move.end",(function(e){var t=e.context,n=t.connection,i=t.newWaypoints,r=t.newSegmentStartIndex;i=i.map((function(e){return{original:e.original,x:Math.round(e.x),y:Math.round(e.y)}}));var a=function(e,t){var n=0,i=e.filter((function(i,r){return!Et(e[r-1],e[r+1],i)||(n=r<=t?n-1:n,!1)}));return{waypoints:i,segmentOffset:n}}(i,r),c=s(n,a.waypoints),p=a.segmentOffset,l={segmentMove:{segmentStartIndex:t.segmentStartIndex,newSegmentStartIndex:r+p}};o.updateWaypoints(n,c,l)}))}rl.$inject=["injector","eventBus","canvas","dragging","graphicsFactory","modeling"];var ol=Math.abs,al=Math.round;function sl(e){return{x:e.x,y:e.y}}function cl(e){return{x:e.x+e.width,y:e.y+e.height}}function pl(e,t){return!e||isNaN(e.x)||isNaN(e.y)?t:{x:al(e.x+e.width/2),y:al(e.y+e.height/2)}}function ll(e,t){var n=e.snapped;return!!n&&("string"==typeof t?n[t]:n.x&&n.y)}function ul(e,t,n){if("string"!=typeof t)throw new Error("axis must be in [x, y]");if("number"!=typeof n&&!1!==n)throw new Error("value must be Number or false");var i,r=e[t],o=e.snapped=e.snapped||{};return!1===n?o[t]=!1:(o[t]=!0,i=n-r,e[t]+=i,e["d"+t]+=i),r}function hl(e){return e.children||[]}var dl=Math.abs,fl=Math.round;function ml(e){function t(e,t){if(p(e)){for(var n=e.length;n--;)if(dl(e[n]-t)<=10)return e[n]}else{var i=t%(e=+e);if(i<10)return t-i;if(i>e-10)return t-i+e}return t}function n(e,t){return e.waypoints?Lp(t,e):e.width?{x:fl(e.width/2+e.x),y:fl(e.height/2+e.y)}:void 0}e.on("connectionSegment.move.move",1500,(function(e){var i,r,o=function(e){var t=e.context,i=t.snapPoints,r=t.connection,o=r.waypoints,a=t.segmentStart,s=t.segmentStartIndex,c=t.segmentEnd,p=t.segmentEndIndex,l=t.axis;if(i)return i;var u=[o[s-1],a,c,o[p+1]];return s<2&&u.unshift(n(r.source,e)),p>o.length-3&&u.unshift(n(r.target,e)),t.snapPoints=i={horizontal:[],vertical:[]},g(u,(function(e){e&&(e=e.original||e,"y"===l&&i.horizontal.push(e.y),"x"===l&&i.vertical.push(e.x))})),i}(e),a=e.x,s=e.y;if(o){var c=a-(i=t(o.vertical,a)),p=s-(r=t(o.horizontal,s));L(e,{dx:e.dx-c,dy:e.dy-p,x:i,y:r}),(c||-1!==o.vertical.indexOf(a))&&ul(e,"x",i),(p||-1!==o.horizontal.indexOf(s))&&ul(e,"y",r)}})),e.on(["connect.hover","connect.move","connect.end"],1500,(function(e){var t=e.context.hover,i=t&&n(t,e);sn(t)&&i&&i.x&&i.y&&(ul(e,"x",i.x),ul(e,"y",i.y))})),e.on(["bendpoint.move.move","bendpoint.move.end"],1500,(function(e){var i,r,o=e.context,a=function(e){var t=e.snapPoints,n=e.connection.waypoints,i=e.bendpointIndex;if(t)return t;var r=[n[i-1],n[i+1]];return e.snapPoints=t={horizontal:[],vertical:[]},g(r,(function(e){e&&(e=e.original||e,t.horizontal.push(e.y),t.vertical.push(e.x))})),t}(o),s=o.hover,c=s&&n(s,e),p=e.x,l=e.y;if(a){var u=p-(i=t(c?a.vertical.concat([c.x]):a.vertical,p)),h=l-(r=t(c?a.horizontal.concat([c.y]):a.horizontal,l));L(e,{dx:e.dx-u,dy:e.dy-h,x:e.x-u,y:e.y-h}),(u||-1!==a.vertical.indexOf(p))&&ul(e,"x",i),(h||-1!==a.horizontal.indexOf(l))&&ul(e,"y",r)}}))}ml.$inject=["eventBus"];var vl={__depends__:[vp,xp],__init__:["bendpoints","bendpointSnapping","bendpointMovePreview"],bendpoints:["type",$p],bendpointMove:["type",Vp],bendpointMovePreview:["type",Zp],connectionSegmentMove:["type",rl],bendpointSnapping:["type",ml]};function yl(e,t,n,i){function r(e,t){return i.allowed("connection.create",{source:e,target:t})}e.on("connect.hover",(function(e){var t,n=e.context,i=n.start,o=e.hover;if(n.hover=o,!c(t=n.canExecute=r(i,o))){if(!1!==t)return n.source=i,void(n.target=o);c(t=n.canExecute=r(o,i))||!1!==t&&(n.source=o,n.target=i)}})),e.on(["connect.out","connect.cleanup"],(function(e){var t=e.context;t.hover=null,t.source=null,t.target=null,t.canExecute=!1})),e.on("connect.end",(function(e){var t=e.context,i=t.canExecute,r=t.connectionStart,o={x:e.x,y:e.y},a=t.source,s=t.target;if(!i)return!1;var c=null,p={connectionStart:gl(t)?o:r,connectionEnd:gl(t)?r:o};l(i)&&(c=i),t.connection=n.connect(a,s,c,p)})),this.start=function(e,n,i,r){l(i)||(r=i,i=fn(n)),t.init(e,"connect",{autoActivate:r,data:{shape:n,context:{start:n,connectionStart:i}}})}}function gl(e){var t=e.hover,n=e.source,i=e.target;return t&&n&&t===n&&n!==i}yl.$inject=["eventBus","dragging","modeling","rules"];var bl="connect-ok",_l="connect-not-ok";function xl(e,t,n){var i=e.get("connectionPreview",!1);i&&t.on("connect.move",(function(e){var t=e.context,n=t.canExecute,r=t.hover,o=t.source,a=t.start,s=t.startPosition,c=t.target,p=t.connectionStart||s,l=t.connectionEnd||{x:e.x,y:e.y},u=p,h=l;gl(t)&&(u=l,h=p),i.drawPreview(t,n,{source:o||a,target:c||r,connectionStart:u,connectionEnd:h})})),t.on("connect.hover",900,(function(e){var t=e.context,i=e.hover,r=t.canExecute;null!==r&&n.addMarker(i,r?bl:_l)})),t.on(["connect.out","connect.cleanup"],1100,(function(e){var t=e.hover;t&&(n.removeMarker(t,bl),n.removeMarker(t,_l))})),i&&t.on("connect.cleanup",(function(e){i.cleanUp(e.context)}))}xl.$inject=["injector","eventBus","canvas"];var wl={__depends__:[_a,xp,vp],__init__:["connectPreview"],connect:["type",yl],connectPreview:["type",xl]};function El(e,t,n,i){this._canvas=t,this._graphicsFactory=n,this._elementFactory=i,this._connectionDocking=e.get("connectionDocking",!1),this._layouter=e.get("layouter",!1)}El.$inject=["injector","canvas","graphicsFactory","elementFactory"],El.prototype.drawPreview=function(e,t,n){n=n||{};var i,r,o,a=e.connectionPreviewGfx,s=e.getConnection,c=n.source,p=n.target,l=n.waypoints,u=n.connectionStart,h=n.connectionEnd,d=n.noLayout,f=n.noCropping,m=n.noNoop,v=this;a||(a=e.connectionPreviewGfx=this.createConnectionPreviewGfx()),Se(a),s||(s=e.getConnection=(r=function(e,t,n){return v.getConnection(e,t,n)},o={},function(e){var t=JSON.stringify(e),n=o[t];return n||(n=o[t]=r.apply(null,arguments)),n})),t&&(i=s(t,c,p)),i?(i.waypoints=l||[],this._layouter&&!d&&(i.waypoints=this._layouter.layoutConnection(i,{source:c,target:p,connectionStart:u,connectionEnd:h,waypoints:n.waypoints||i.waypoints})),i.waypoints&&i.waypoints.length||(i.waypoints=[c?fn(c):u,p?fn(p):h]),this._connectionDocking&&(c||p)&&!f&&(i.waypoints=this._connectionDocking.getCroppedWaypoints(i,c,p)),this._graphicsFactory.drawConnection(a,i,{stroke:"var(--element-dragger-color)"})):!m&&this.drawNoopPreview(a,n)},El.prototype.drawNoopPreview=function(e,t){var n=t.source,i=t.target,r=t.connectionStart||fn(n),o=t.connectionEnd||fn(i),a=this.cropWaypoints(r,o,n,i);ye(e,this.createNoopConnection(a[0],a[1]))},El.prototype.cropWaypoints=function(e,t,n,i){var r=this._graphicsFactory,o=n&&r.getShapePath(n),a=i&&r.getShapePath(i),s=r.getConnectionPath({waypoints:[e,t]});return[e=n&&vn(o,s,!0)||e,t=i&&vn(a,s,!1)||t]},El.prototype.cleanUp=function(e){e&&e.connectionPreviewGfx&&Fe(e.connectionPreviewGfx)},El.prototype.getConnection=function(e){var t=function(e){return l(e)?e:{}}(e);return this._elementFactory.createConnection(t)},El.prototype.createConnectionPreviewGfx=function(){var e=Ae("g");return _e(e,{pointerEvents:"none"}),we(e).add("djs-dragger"),ye(this._canvas.getActiveLayer(),e),e},El.prototype.createNoopConnection=function(e,t){return ot([e,t],{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"})};var Sl={__init__:["connectionPreview"],connectionPreview:["type",El]};const Cl=new Eo("ps");var kl=["marker-start","marker-mid","marker-end"],Rl=["circle","ellipse","line","path","polygon","polyline","path","rect"];function Pl(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._styles=i}Pl.$inject=["elementRegistry","eventBus","canvas","styles"],Pl.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")},Pl.prototype.getGfx=function(e){return this._elementRegistry.getGraphics(e)},Pl.prototype.addDragger=function(e,t,n,i="djs-dragger"){var r=Ce(n=n||this.getGfx(e)),o=n.getBoundingClientRect();return this._cloneMarkers(Vn(r),i),_e(r,this._styles.cls(i,[],{x:o.top,y:o.left})),ye(t,r),_e(r,"data-preview-support-element-id",e.id),r},Pl.prototype.addFrame=function(e,t){var n=Ae("rect",{class:"djs-resize-overlay",width:e.width,height:e.height,x:e.x,y:e.y});return ye(t,n),_e(n,"data-preview-support-element-id",e.id),n},Pl.prototype._cloneMarkers=function(e,t="djs-dragger",n=e){var i=this;e.childNodes&&e.childNodes.forEach((e=>{i._cloneMarkers(e,t,n)})),function(e){return-1!==Rl.indexOf(e.nodeName)}(e)&&kl.forEach((function(r){if(_e(e,r)){var o=function(e,t,n){var i=(r=_e(e,t),r.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]);var r;return fe("marker#"+i,n||document)}(e,r,i._canvas.getContainer());o&&i._cloneMarker(n,e,o,r,t)}}))},Pl.prototype._cloneMarker=function(e,t,n,i,r="djs-dragger"){var o=[n.id,r,Cl.next()].join("-"),a=fe("marker#"+n.id,e);e=e||this._canvas._svg;var s=a||Ce(n);s.id=o,we(s).add(r);var c=fe(":scope > defs",e);c||ye(e,c=Ae("defs")),ye(c,s),_e(t,i,"url(#"+s.id+")")};var Al={__init__:["previewSupport"],previewSupport:["type",Pl]};const Ml="complex-preview";class Tl{constructor(e,t,n){this._canvas=e,this._graphicsFactory=t,this._previewSupport=n,this._markers=[]}create(e){this.cleanUp();const{created:t=[],moved:n=[],removed:i=[],resized:r=[]}=e,o=this._canvas.getLayer(Ml);t.filter((e=>!function(e){return e.hidden}(e))).forEach((e=>{let t;sn(e)?(t=this._graphicsFactory._createContainer("connection",Ae("g")),this._graphicsFactory.drawConnection(Vn(t),e)):(t=this._graphicsFactory._createContainer("shape",Ae("g")),this._graphicsFactory.drawShape(Vn(t),e),Wn(t,e.x,e.y)),this._previewSupport.addDragger(e,o,t)})),n.forEach((({element:e,delta:t})=>{this._previewSupport.addDragger(e,o,void 0,"djs-dragging"),this._canvas.addMarker(e,"djs-element-hidden"),this._markers.push([e,"djs-element-hidden"]);const n=this._previewSupport.addDragger(e,o);sn(e)?Wn(n,t.x,t.y):Wn(n,e.x+t.x,e.y+t.y)})),i.forEach((e=>{this._previewSupport.addDragger(e,o,void 0,"djs-dragging"),this._canvas.addMarker(e,"djs-element-hidden"),this._markers.push([e,"djs-element-hidden"])})),r.forEach((({shape:e,bounds:t})=>{this._canvas.addMarker(e,"djs-hidden"),this._markers.push([e,"djs-hidden"]),this._previewSupport.addDragger(e,o,void 0,"djs-dragging");const n=this._graphicsFactory._createContainer("shape",Ae("g"));this._graphicsFactory.drawShape(Vn(n),e,{width:t.width,height:t.height}),Wn(n,t.x,t.y),this._previewSupport.addDragger(e,o,n)}))}cleanUp(){Se(this._canvas.getLayer(Ml)),this._markers.forEach((([e,t])=>this._canvas.removeMarker(e,t))),this._markers=[]}show(){this._canvas.showLayer(Ml)}hide(){this._canvas.hideLayer(Ml)}}Tl.$inject=["canvas","graphicsFactory","previewSupport"];var Dl={__depends__:[Al],__init__:["complexPreview"],complexPreview:["type",Tl]},Bl=["top","bottom","left","right"],Nl=10;function jl(e,t){function n(e){if(Hr(e)&&!sn(e)){var n=function(e){var t=fn(e.label),n=fn(e),i=Ol(n,t);if(r=i,-1===Bl.indexOf(r))return;var r;var o=function(e){var t=fn(e),n=[].concat(e.incoming.map((function(e){return e.waypoints[e.waypoints.length-2]})),e.outgoing.map((function(e){return e.waypoints[1]}))).map((function(e){return Ol(t,e)}));return n}(e);if(e.host){var a=function(e){var t,n=e.host,i=fn(e),r=mn(i,n);t=r.indexOf("-")>=0?r.split("-"):[r];var o=Bl.filter((function(e){return-1===t.indexOf(e)}));return o}(e);o=o.concat(a)}var s=Bl.filter((function(e){return-1===o.indexOf(e)}));if(-1!==s.indexOf(i))return;return s[0]}(e);n&&function(e,n){var i=fn(e),r=e.label,o=fn(r);if(!r.parent)return;var a,s=un(e);switch(n){case"top":a={x:i.x,y:s.top-Nl-r.height/2};break;case"left":a={x:s.left-Nl-r.width/2,y:i.y};break;case"bottom":a={x:i.x,y:s.bottom+Nl+r.height/2};break;case"right":a={x:s.right+Nl+r.width/2,y:i.y}}var c=Ha(a,o);t.moveShape(r,c)}(e,n)}}Do.call(this,e),this.postExecuted(["connection.create","connection.layout","connection.updateWaypoints"],(function(e){var t=e.context,i=t.connection,r=i.source,o=i.target;!1!==(t.hints||{}).createElementsBehavior&&(n(r),n(o))})),this.postExecuted(["label.create"],(function(e){var t=e.context,i=t.shape;!1!==(t.hints||{}).createElementsBehavior&&n(i.labelTarget)})),this.postExecuted(["elements.create"],(function(e){var t=e.context,i=t.elements;!1!==(t.hints||{}).createElementsBehavior&&i.forEach((function(e){n(e)}))}))}function Ol(e,t){return mn(t,e,5)}function Ll(e){Do.call(this,e),this.preExecute("shape.append",(function(e){var t=e.source,n=e.shape;e.position||(vr(n,"bpmn:TextAnnotation")?e.position={x:t.x+t.width/2+75,y:t.y-50-n.height/2}:e.position={x:t.x+t.width+80+n.width/2,y:t.y+t.height/2})}),!0)}function $l(e,t){e.invoke(Do,this),this.postExecute("shape.move",(function(e){var n=e.newParent,i=e.shape;g(y(i.incoming.concat(i.outgoing),(function(e){return vr(e,"bpmn:Association")})),(function(e){t.moveConnection(e,{x:0,y:0},n)}))}),!0)}e(jl,Do),jl.$inject=["eventBus","modeling"],e(Ll,Do),Ll.$inject=["eventBus"],e($l,Do),$l.$inject=["injector","modeling"];function Il(e,t){t.invoke(Do,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",500,(function(e){var t=e.elements;1===(t=t.filter((function(e){return Fl(e,e.host)}))).length&&t.map((function(e){return t.indexOf(e)})).forEach((function(i){var r=t[i];e.elements[i]=n._replaceShape(t[i],r)}))}),!0),this.preExecute("elements.move",500,(function(e){var t=e.shapes,i=e.newHost;if(1===t.length){var r=t[0];Fl(r,i)&&(e.shapes=[n._replaceShape(r,i)])}}),!0)}function Fl(e,t){return!cn(e)&&yr(e,["bpmn:IntermediateThrowEvent","bpmn:IntermediateCatchEvent"])&&!!t}function zl(e,t){function n(e){return y(e.attachers,(function(e){return vr(e,"bpmn:BoundaryEvent")}))}Do.call(this,e),this.postExecute("connection.create",(function(e){var i=e.context.source,r=e.context.target,o=n(r);vr(i,"bpmn:EventBasedGateway")&&vr(r,"bpmn:ReceiveTask")&&o.length>0&&t.removeElements(o)})),this.postExecute("connection.reconnect",(function(e){var i=e.context.oldSource,r=e.context.newSource;vr(i,"bpmn:Gateway")&&vr(r,"bpmn:EventBasedGateway")&&g(r.outgoing,(function(e){var i=e.target,r=n(i);vr(i,"bpmn:ReceiveTask")&&r.length>0&&t.removeElements(r)}))}))}function Hl(e,t,n){function i(e){t.updateProperties(e,{isForCompensation:!0})}function r(e){t.updateProperties(e,{isForCompensation:void 0})}Do.call(this,e),this.preExecute("shape.replace",(function(e){const{newData:n,oldShape:i}=e;if(Gl(e.oldShape)&&"bpmn:CompensateEventDefinition"!==n.eventDefinitionType||"bpmn:BoundaryEvent"!==n.type){const t=i.outgoing.find((({target:e})=>Vl(e)));t&&t.target&&(e._connectionTarget=t.target)}else if(!Gl(e.oldShape)&&"bpmn:CompensateEventDefinition"===n.eventDefinitionType&&"bpmn:BoundaryEvent"===n.type){const n=i.outgoing.find((({target:e})=>Wl(e)));n&&n.target&&(e._connectionTarget=n.target),function(e){const n=e.outgoing.filter((e=>vr(e,"bpmn:SequenceFlow")));t.removeElements(n)}(i)}}),!0),this.postExecuted("shape.replace",(function(e){const{_connectionTarget:n,newShape:i}=e;n&&t.connect(i,n)}),!0),this.preExecute("connection.create",(function(e){const n=e.connection,r=e.source,o=e.target;Gl(r)&&Wl(o)&&(i(o),function(e,n){const i=e.outgoing.filter((e=>vr(e,"bpmn:Association"))),r=i.filter((e=>Vl(e.target)&&!n.includes(e)));r.forEach((e=>t.removeConnection(e)))}(r,[n]))}),!0),this.postExecuted("connection.delete",(function(e){const t=e.source,n=e.target;Gl(t)&&Vl(n)&&r(n)}),!0),this.postExecuted("connection.reconnect",(function(e){const t=e.newTarget,n=e.oldSource,o=e.oldTarget;if(o!==t){const e=n;Vl(o)&&r(o),Gl(e)&&Wl(t)&&i(t)}}),!0),this.postExecuted("element.updateProperties",(function(e){const{element:i}=e;Vl(i)?(function(e){for(const i of e.incoming)n.canConnect(i.source,e)||t.removeConnection(i);for(const i of e.outgoing)n.canConnect(e,i.target)||t.removeConnection(i)}(i),function(e){const n=e.attachers.slice();if(!n.length)return;t.removeElements(n)}(i)):Wl(i)&&function(e){const n=e.incoming.filter((e=>Gl(e.source)));t.removeElements(n)}(i)}),!0)}function Vl(e){const t=gr(e);return t&&t.get("isForCompensation")}function Gl(e){return e&&vr(e,"bpmn:BoundaryEvent")&&Ir(e,"bpmn:CompensateEventDefinition")}function Wl(e){return e&&vr(e,"bpmn:Activity")&&!$r(e)}function Ul(e){e.invoke(Do,this),this.preExecute("shape.create",1500,(function(e){var t=e.context,n=t.parent,i=t.shape;vr(n,"bpmn:Lane")&&!vr(i,"bpmn:Lane")&&(t.parent=Jc(n,"bpmn:Participant"))}))}function ql(e,t){Do.call(this,e),this.preExecute("shape.create",(function(e){var n=e.context.shape;if(vr(n,"bpmn:DataObjectReference")&&"label"!==n.type){var i=t.create("bpmn:DataObject");n.businessObject.dataObjectRef=i}}))}Il.$inject=["bpmnReplace","injector"],e(Il,Do),Il.prototype._replaceShape=function(e,t){var n,i=(n=gr(e).eventDefinitions)&&n[0],r={type:"bpmn:BoundaryEvent",host:t};return i&&(r.eventDefinitionType=i.$type),this._bpmnReplace.replaceElement(e,r,{layoutConnection:!1})},zl.$inject=["eventBus","modeling"],e(zl,Do),e(Hl,Do),Hl.$inject=["eventBus","modeling","bpmnRules"],Ul.$inject=["injector"],e(Ul,Do),ql.$inject=["eventBus","bpmnFactory"],e(ql,Do);var Kl=20,Yl=20,Xl=2e3;function Zl(e,t,n){function i(){var t=e.getRootElement();return vr(t,"bpmn:Collaboration")?t:n.makeCollaboration()}Do.call(this,t),t.on(["create.start","shape.move.start"],Xl,(function(t){var n=t.context,i=n.shape,r=e.getRootElement();if(vr(i,"bpmn:Participant")&&vr(r,"bpmn:Process")&&r.children.length){var o=r.children.filter((function(e){return!vr(e,"bpmn:Group")&&!cn(e)&&!sn(e)}));if(o.length){var a=ht(o),s=function(e,t){t={width:t.width+40+30,height:t.height+40};var n=Math.max(e.width,t.width),i=Math.max(e.height,t.height);return{x:-n/2,y:-i/2,width:n,height:i}}(i,a);L(i,s),n.createConstraints=function(e,t){return t=un(t),{bottom:t.top+e.height/2-Yl,left:t.right-e.width/2+Kl,top:t.bottom-e.height/2+Yl,right:t.left+e.width/2-Kl-30}}(i,a)}}})),t.on("create.start",Xl,(function(n){var i=n.context.shape,r=e.getRootElement(),o=e.getGraphics(r);function a(e){e.element=r,e.gfx=o}vr(i,"bpmn:Participant")&&vr(r,"bpmn:Process")&&(t.on("element.hover",Xl,a),t.once("create.cleanup",(function(){t.off("element.hover",a)})))})),this.preExecute("elements.create",Xl,(function(e){var t,n=e.elements,r=e.parent,o=function(e){return m(e,(function(e){return vr(e,"bpmn:Participant")}))}(n);o&&vr(r,"bpmn:Process")&&(e.parent=i(),(t=e.hints=e.hints||{}).participant=o,t.process=r,t.processRef=gr(o).get("processRef"))}),!0),this.preExecute("shape.create",(function(e){var t=e.parent,n=e.shape;vr(n,"bpmn:Participant")&&vr(t,"bpmn:Process")&&(e.parent=i(),e.process=t,e.processRef=gr(n).get("processRef"))}),!0),this.execute("shape.create",(function(e){var t=e.hints||{},n=e.process||t.process,i=e.shape,r=t.participant;!n||r&&i!==r||gr(i).set("processRef",gr(n))}),!0),this.revert("shape.create",(function(e){var t=e.hints||{},n=e.process||t.process,i=e.processRef||t.processRef,r=e.shape,o=t.participant;!n||o&&r!==o||gr(r).set("processRef",i)}),!0),this.postExecute("shape.create",(function(e){var t=e.hints||{},i=e.process||e.hints.process,r=e.shape,o=t.participant;if(i){var a=i.children.slice();o?r===o&&n.moveElements(a,{x:0,y:0},o):n.moveElements(a,{x:0,y:0},r)}}),!0)}Zl.$inject=["canvas","eventBus","modeling"],e(Zl,Do);var Ql="__targetRef_placeholder";function Jl(e,t){function n(e,n){var i=e.get("properties"),r=m(i,(function(e){return e.name===Ql}));return!r&&n&&_t(i,r=t.create("bpmn:Property",{name:Ql})),r}function i(e,t){var i=n(e);i&&(function(e,t,n){return m(e.get("dataInputAssociations"),(function(e){return e!==n&&e.targetRef===t}))}(e,i,t)||bt(e.get("properties"),i))}function r(e){var t,r=e.context,o=r.connection,a=o.businessObject,s=o.target,c=s&&s.businessObject,p=r.newTarget,l=p&&p.businessObject,u=r.oldTarget||r.target,h=u&&u.businessObject,d=o.businessObject;h&&h!==c&&i(h,a),l&&l!==c&&i(l,a),c?(t=n(c,!0),d.targetRef=t):d.targetRef=null}Do.call(this,e),this.executed(["connection.create","connection.delete","connection.move","connection.reconnect"],eu(r)),this.reverted(["connection.create","connection.delete","connection.move","connection.reconnect"],eu(r))}function eu(e){return function(t){if(vr(t.context.connection,"bpmn:DataInputAssociation"))return e(t)}}function tu(e){this._bpmnUpdater=e}function nu(e,t,n,i){function r(e){return e.children.filter((function(e){return vr(e,"bpmn:DataStoreReference")&&!e.labelTarget}))}function o(e,i){var r=e.businessObject||e;if(i=i||n.filter((function(e){return vr(e,"bpmn:Participant")&&gr(e).processRef}))[0]){var o=i.businessObject||i;t.execute("dataStore.updateContainment",{dataStoreBo:r,dataStoreDi:br(e),newSemanticParent:o.processRef||o,newDiParent:br(i)})}}Do.call(this,i),t.registerHandler("dataStore.updateContainment",tu),this.preExecute("shape.create",(function(e){var t=e.context,n=t.shape;vr(n,"bpmn:DataStoreReference")&&"label"!==n.type&&(t.hints||(t.hints={}),t.hints.autoResize=!1)})),this.preExecute("elements.move",(function(e){var t=e.context,n=t.shapes;n.filter((function(e){return vr(e,"bpmn:DataStoreReference")})).length&&(t.hints||(t.hints={}),t.hints.autoResize=n.filter((function(e){return!vr(e,"bpmn:DataStoreReference")})))})),this.postExecute("shape.create",(function(e){var t=e.context.shape,n=t.parent;vr(t,"bpmn:DataStoreReference")&&"label"!==t.type&&vr(n,"bpmn:Collaboration")&&o(t)})),this.postExecute("shape.move",(function(e){var t=e.context,n=t.shape,i=t.oldParent,r=n.parent;vr(i,"bpmn:Collaboration")||vr(n,"bpmn:DataStoreReference")&&"label"!==n.type&&vr(r,"bpmn:Collaboration")&&o(n,vr(i,"bpmn:Participant")?i:function(e,t){for(;e.parent;){if(vr(e.parent,t))return e.parent;e=e.parent}}(i,"bpmn:Participant"))})),this.postExecute("shape.delete",(function(t){var n=t.context.shape,i=e.getRootElement();yr(n,["bpmn:Participant","bpmn:SubProcess"])&&vr(i,"bpmn:Collaboration")&&r(i).filter((function(e){return function(e,t){var n=e.businessObject||e,i=t.businessObject||t;for(;n.$parent;){if(n.$parent===i.processRef||i)return!0;n=n.$parent}return!1}(e,n)})).forEach((function(e){o(e)}))})),this.postExecute("canvas.updateRoot",(function(e){var t=e.context,n=t.oldRoot,i=t.newRoot;r(n).forEach((function(e){vr(i,"bpmn:Process")&&o(e,i)}))}))}Jl.$inject=["eventBus","bpmnFactory"],e(Jl,Do),tu.$inject=["bpmnUpdater"],tu.prototype.execute=function(e){var t=e.dataStoreBo,n=e.dataStoreDi,i=e.newSemanticParent,r=e.newDiParent;return e.oldSemanticParent=t.$parent,e.oldDiParent=n.$parent,this._bpmnUpdater.updateSemanticParent(t,i),this._bpmnUpdater.updateDiParent(n,r),[]},tu.prototype.revert=function(e){var t=e.dataStoreBo,n=e.dataStoreDi,i=e.oldSemanticParent,r=e.oldDiParent;return this._bpmnUpdater.updateSemanticParent(t,i),this._bpmnUpdater.updateDiParent(n,r),[]},nu.$inject=["canvas","commandStack","elementRegistry","eventBus"],e(nu,Do);var iu=Math.max,ru=Math.min;function ou(e,t){return{top:e.top-t.top,right:e.right-t.right,bottom:e.bottom-t.bottom,left:e.left-t.left}}function au(e,t,n){var i=t[e],r=n.min&&n.min[e],o=n.max&&n.max[e];return u(r)&&(i=(/top|left/.test(e)?ru:iu)(i,r)),u(o)&&(i=(/top|left/.test(e)?iu:ru)(i,o)),i}function su(e,t){return void 0!==e?e:20}function cu(e){return!e.waypoints&&"label"!==e.type}function pu(e,t){var n;if((n=void 0===e.length?y(e.children,cu):e).length)return function(e,t){var n,i,r,o;return"object"==typeof t?(n=su(t.left),i=su(t.right),r=su(t.top),o=su(t.bottom)):n=i=r=o=su(t),{x:e.x-n,y:e.y-r,width:e.width+n+i,height:e.height+r+o}}(ht(n),t)}var lu=Math.abs;var uu=["bpmn:Participant","bpmn:Process","bpmn:SubProcess"],hu=30;function du(e,t){return t=t||[],e.children.filter((function(e){vr(e,"bpmn:Lane")&&(du(e,t),t.push(e))})),t}function fu(e){return e.children.filter((function(e){return vr(e,"bpmn:Lane")}))}function mu(e){return Jc(e,uu)||e}function vu(e,t){var n=mu(e),i=du(n,vr(n,"bpmn:Process")?[]:[n]),r=un(e),o=un(t),a=function(e,t){return ou(un(t),un(e))}(e,t),s=[],c=Lr(e);return i.forEach((function(t){if(t!==e){var n,i,p=c?0:a.top,l=c?a.right:0,u=c?0:a.bottom,h=c?a.left:0,d=un(t);a.top&&(lu(d.bottom-r.top)<10&&(u=o.top-d.bottom),lu(d.top-r.top)<5&&(p=o.top-d.top)),a.left&&(lu(d.right-r.left)<10&&(l=o.left-d.right),lu(d.left-r.left)<5&&(h=o.left-d.left)),a.bottom&&(lu(d.top-r.bottom)<10&&(p=o.bottom-d.top),lu(d.bottom-r.bottom)<5&&(u=o.bottom-d.bottom)),a.right&&(lu(d.left-r.right)<10&&(h=o.right-d.left),lu(d.right-r.right)<5&&(l=o.right-d.right)),(p||l||u||h)&&s.push({shape:t,newBounds:(n=t,i={top:p,right:l,bottom:u,left:h},{x:n.x+(i.left||0),y:n.y+(i.top||0),width:n.width-(i.left||0)+(i.right||0),height:n.height-(i.top||0)+(i.bottom||0)})})}})),s}function yu(e,t){Do.call(this,e),this.postExecuted("shape.delete",500,(function(e){var n=e.context,i=n.hints,r=n.shape,o=n.oldParent;vr(r,"bpmn:Lane")&&(i&&i.nested||function(e,n){var i,r,o,a,s,c=Lr(e),p=fu(n),l=[],u=[],h=[],d=[];lt(p,(function(t){return c?t.y>e.y?u.push(t):l.push(t):t.x>e.x?d.push(t):h.push(t),t.children})),p.length&&(i=c?u.length&&l.length?e.height/2:e.height:d.length&&h.length?e.width/2:e.width,l.length&&(r=t.calculateAdjustments(l,"y",i,e.y-10),t.makeSpace(r.movingShapes,r.resizingShapes,{x:0,y:i},"s")),u.length&&(o=t.calculateAdjustments(u,"y",-i,e.y+e.height+10),t.makeSpace(o.movingShapes,o.resizingShapes,{x:0,y:-i},"n")),h.length&&(a=t.calculateAdjustments(h,"x",i,e.x-10),t.makeSpace(a.movingShapes,a.resizingShapes,{x:i,y:0},"e")),d.length&&(s=t.calculateAdjustments(d,"x",-i,e.x+e.width+10),t.makeSpace(s.movingShapes,s.resizingShapes,{x:-i,y:0},"w")))}(r,o))}))}yu.$inject=["eventBus","spaceTool"],e(yu,Do);function gu(e,t){t.invoke(Do,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",500,(function(e){var t=e.elements;t.filter((function(e){return bu(e,e.host)})).map((function(e){return t.indexOf(e)})).forEach((function(i){e.elements[i]=n._replaceShape(t[i])}))}),!0),this.preExecute("elements.move",500,(function(e){var t=e.shapes,i=e.newHost;t.forEach((function(e,r){var o,a=e.host;bu(e,(o=a,-1!==t.indexOf(o)?a:i))&&(t[r]=n._replaceShape(e))}))}),!0)}function bu(e,t){return!cn(e)&&vr(e,"bpmn:BoundaryEvent")&&!t}function _u(e,t,n){function i(e,i,r){var o,a,s,c,p,l,h,d,f=i.waypoints,m=e.outgoing.slice(),v=e.incoming.slice(),g=Sp(f,d=u(r.width)?fn(r):r);if(g){if(o=f.slice(0,g.index),a=f.slice(g.index+(g.bendpoint?1:0)),!o.length||!a.length)return;s=g.bendpoint?f[g.index]:d,1!==o.length&&xu(e,o[o.length-1])||o.push(wu(s)),1!==a.length&&xu(e,a[0])||a.unshift(wu(s))}c=i.source,p=i.target,t.canConnect(c,e,i)&&(n.reconnectEnd(i,e,o||d),l=i),t.canConnect(e,p,i)&&(l?h=n.connect(e,p,{type:i.type,waypoints:a}):(n.reconnectStart(i,e,a||d),h=i));var b=[].concat(l&&y(v,(function(e){return e.source===l.source}))||[],h&&y(m,(function(e){return e.target===h.target}))||[]);b.length&&n.removeElements(b)}Do.call(this,e),this.preExecute("elements.move",(function(e){var n=e.newParent,i=e.shapes,r=e.delta,o=i[0];if(o&&n){n&&n.waypoints&&(e.newParent=n=n.parent);var a=fn(o),s={x:a.x+r.x,y:a.y+r.y},c=m(n.children,(function(e){return t.canInsert(i,e)&&Sp(e.waypoints,s)}));c&&(e.targetFlow=c,e.position=s)}}),!0),this.postExecuted("elements.move",(function(e){var t=e.shapes,n=e.targetFlow,r=e.position;n&&i(t[0],n,r)}),!0),this.preExecute("shape.create",(function(e){var n=e.parent,i=e.shape;t.canInsert(i,n)&&(e.targetFlow=n,e.parent=n.parent)}),!0),this.postExecuted("shape.create",(function(e){var t=e.shape,n=e.targetFlow,r=e.position;n&&i(t,n,r)}),!0)}function xu(e,t){var n=t.x,i=t.y;return n>=e.x&&n<=e.x+e.width&&i>=e.y&&i<=e.y+e.height}function wu(e){return L({},e)}function Eu(e,t){Do.call(this,e),this.preExecuted("connection.create",(function(e){var n=e.context,i=n.connection,r=n.source,o=n.target,a=n.hints;if((!a||!1!==a.createElementsBehavior)&&Su(i)){(vr(r,"bpmn:EventBasedGateway")?o.incoming.filter((e=>e!==i&&Su(e))):o.incoming.filter((e=>e!==i&&Su(e)&&vr(e.source,"bpmn:EventBasedGateway")))).forEach((function(e){t.removeConnection(e)}))}})),this.preExecuted("shape.replace",(function(e){var n=e.context.newShape;vr(n,"bpmn:EventBasedGateway")&&n.outgoing.filter(Su).reduce((function(e,t){return e.includes(t.target)?e:e.concat(t.target)}),[]).forEach((function(e){e.incoming.filter(Su).forEach((function(i){const r=e.incoming.filter(Su).filter((function(e){return e.source===n}));(i.source!==n||r.length>1)&&t.removeConnection(i)}))}))}))}function Su(e){return vr(e,"bpmn:SequenceFlow")}gu.$inject=["bpmnReplace","injector"],e(gu,Do),gu.prototype._replaceShape=function(e){var t,n,i=(n=gr(e).eventDefinitions)&&n[0];return t=i?{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:i.$type}:{type:"bpmn:IntermediateThrowEvent"},this._bpmnReplace.replaceElement(e,t,{layoutConnection:!1})},e(_u,Do),_u.$inject=["eventBus","bpmnRules","modeling"],Eu.$inject=["eventBus","modeling"],e(Eu,Do);var Cu=1500;function ku(e,t,n){t.on(["create.hover","create.move","create.out","create.end","shape.move.hover","shape.move.move","shape.move.out","shape.move.end"],Cu,(function(t){var i=t.context.shape||t.shape,r=t.hover;vr(r,"bpmn:Lane")&&!yr(i,["bpmn:Lane","bpmn:Participant"])&&(t.hover=mu(r),t.hoverGfx=e.getGraphics(t.hover));var o=n.getRootElement();r!==o&&(i.labelTarget||yr(i,["bpmn:Group","bpmn:TextAnnotation"]))&&(t.hover=o,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["connect.hover","connect.out","connect.end","connect.cleanup","global-connect.hover","global-connect.out","global-connect.end","global-connect.cleanup"],Cu,(function(t){var n=t.hover;vr(n,"bpmn:Lane")&&(t.hover=mu(n)||n,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["bendpoint.move.hover"],Cu,(function(t){var n=t.context,i=t.hover,r=n.type;vr(i,"bpmn:Lane")&&/reconnect/.test(r)&&(t.hover=mu(i)||i,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["connect.start"],Cu,(function(e){var t=e.context,n=t.start;vr(n,"bpmn:Lane")&&(t.start=mu(n)||n)})),t.on("shape.move.start",2e3,(function(e){var t=e.shape;vr(t,"bpmn:Lane")&&(e.shape=mu(t)||t)})),t.on("spaceTool.move",2e3,(function(e){var t=e.hover;t&&vr(t,"bpmn:Lane")&&(e.hover=mu(t))}))}ku.$inject=["elementRegistry","eventBus","canvas"];function Ru(e,t,n,i,r,o){function a(e,t,i){var r=n.filter((function(e){return vr(e,"bpmn:Group")})).filter((function(e){return e.businessObject!==i}));t&&!function(e,t){return e.some((function(e){var n=gr(e);return(n.categoryValueRef&&n.categoryValueRef.$parent)===t}))}(r,t)&&function(e){var t=e.$parent;t&&(bt(t.get("rootElements"),e),e.$parent=null)}(t),e&&!function(e,t){return e.some((function(e){return gr(e).categoryValueRef===t}))}(r,e)&&function(e){var t=e.$parent;t&&(bt(t.get("categoryValue"),e),e.$parent=null)}(e)}function s(e,n){return function(e,t,n){return _t(t.get("categoryValue"),e),e.$parent=t,_t(n.get("rootElements"),t),t.$parent=n,e}(e,n,t.getDefinitions())}function c(n,i){var r=gr(n),o=r.categoryValueRef;o||(o=r.categoryValueRef=i.categoryValue=i.categoryValue||function(e){return e.create("bpmn:CategoryValue")}(e));var a=o.$parent;a||(a=o.$parent=i.category=i.category||function(e){return e.create("bpmn:Category")}(e)),s(o,a,t.getDefinitions())}function p(e,t){var n=t.category,i=t.categoryValue,r=gr(e);i?(r.categoryValueRef=null,a(i,n,r)):a(null,r.categoryValueRef.$parent,r)}function l(t,n){var i=e.create(t.$type);return o.copyElement(t,i,null,n)}r.invoke(Do,this),this.execute("label.create",(function(e){var t=e.context,n=t.labelTarget;vr(n,"bpmn:Group")&&c(n,t)})),this.revert("label.create",(function(e){var t=e.context,n=t.labelTarget;vr(n,"bpmn:Group")&&p(n,t)})),this.execute("shape.delete",(function(e){var t=e.context,n=t.shape,i=gr(n);if(vr(n,"bpmn:Group")&&!n.labelTarget){var r=t.categoryValue=i.categoryValueRef;r&&(a(r,t.category=r.$parent,i),i.categoryValueRef=null)}})),this.reverted("shape.delete",(function(e){var t=e.context,n=t.shape;if(vr(n,"bpmn:Group")&&!n.labelTarget){var i=t.category,r=t.categoryValue,o=gr(n);r&&(o.categoryValueRef=r,s(r,i))}})),this.execute("shape.create",(function(e){var t=e.context,n=t.shape;vr(n,"bpmn:Group")&&!n.labelTarget&&gr(n).categoryValueRef&&c(n,t)})),this.reverted("shape.create",(function(e){var t=e.context,n=t.shape;vr(n,"bpmn:Group")&&!n.labelTarget&&gr(n).categoryValueRef&&p(n,t)})),i.on("copyPaste.copyElement",770,(function(e){var t=e.descriptor,n=e.element;if(vr(n,"bpmn:Group")&&!n.labelTarget){var i=gr(n);if(i.categoryValueRef){var r=i.categoryValueRef;t.categoryValue=l(r,!0),r.$parent&&(t.category=l(r.$parent,!0))}}})),i.on("copyPaste.pasteElement",770,(function(e){var t=e.descriptor,n=t.businessObject,i=t.categoryValue,r=t.category;i&&(i=n.categoryValueRef=l(i)),r&&(i.$parent=l(r)),delete t.category,delete t.categoryValue}))}function Pu(e,t,n,i){var r,o,a,s;return 0==(r=(i.y-n.y)*(t.x-e.x)-(i.x-n.x)*(t.y-e.y))?null:(o=e.y-n.y,a=e.x-n.x,s=((i.x-n.x)*o-(i.y-n.y)*a)/r,{x:Math.round(e.x+s*(t.x-e.x)),y:Math.round(e.y+s*(t.y-e.y))})}function Au(e){function t(e,t,n){var i,r={x:n.x,y:n.y-50},o={x:n.x-50,y:n.y},a=Pu(e,t,n,r),s=Pu(e,t,n,o);i=a&&s?Mu(a,n)>Mu(s,n)?s:a:a||s,e.original=i}e.on("bpmnElement.added",(function(e){var n,i,r=e.element;r.waypoints&&(t((i=(n=r).waypoints)[0],i[1],fn(n.source)),t(i[i.length-1],i[i.length-2],fn(n.target)))}))}function Mu(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Tu(e){Do.call(this,e);var t=["bpmn:Participant","bpmn:Lane"];this.executed(["shape.move","shape.create","shape.resize"],(function(e){var n=e.context.shape,i=gr(n),r=br(n);if(yr(i,t)){var o=r.get("isHorizontal");void 0===o&&(o=!0),r.set("isHorizontal",o)}}))}Ru.$inject=["bpmnFactory","bpmnjs","elementRegistry","eventBus","injector","moddleCopy"],e(Ru,Do),Au.$inject=["eventBus"],Tu.$inject=["eventBus"],e(Tu,Do);var Du=Math.sqrt,Bu=Math.min,Nu=Math.max,ju=Math.abs;function Ou(e){return Math.pow(e,2)}function Lu(e,t){return Du(Ou(e.x-t.x)+Ou(e.y-t.y))}function $u(e,t,n,i){var r=t.x-e.x,o=t.y-e.y,a=n.x-e.x,s=n.y-e.y,c=r*r+o*o,p=(r*a+o*s)/c,l=p*p-(a*a+s*s-i*i)/c;if(l<0&&l>-1e-6&&(l=0),l<0)return[];var u=Du(l),h=-p+u,d=-p-u,f={x:e.x-r*h,y:e.y-o*h};return 0===l?[f]:[f,{x:e.x-r*d,y:e.y-o*d}].filter((function(n){return function(e,t,n){return Iu(e.x,t.x,n.x)&&Iu(e.y,t.y,n.y)}(n,e,t)}))}function Iu(e,t,n){return e>=Bu(t,n)-Fu&&e<=Nu(t,n)+Fu}var Fu=.1;function zu(e,t){return ju(e.x-t.x)<=Fu&&ju(e.y-t.y)<=Fu}function Hu(e,t,n,i){var r=0,o=0,a={point:e,delta:{x:0,y:0}},s=function(e,t){var n,i,r,o,a,s,c,p,l,u,h,d,f=0;for(f=0;f<t.length-1;f++){if(zu(n=t[f],i=t[f+1])?s=[n]:(r=Lu(e,n),o=Lu(e,i),s=$u(n,i,e,Bu(r,o))),s.length<1)throw new Error("expected between [1, 2] circle -> line intersections");1===s.length&&(c={type:"bendpoint",position:s[0],segmentIndex:f,bendpointIndex:zu(n,s[0])?f:f+1}),2===s.length&&(h=s[0],d=s[1],c={type:"segment",position:a={x:(h.x+d.x)/2,y:(h.y+d.y)/2},segmentIndex:f,relativeLocation:Lu(n,a)/Lu(n,i)}),p=Lu(c.position,e),(!u||l>p)&&(u=c,l=p)}return u}(e,n),c=s.segmentIndex,p=function(e,t,n,i){var r=n.segmentIndex,o=t.length-e.length;if(i.segmentMove){var a=i.segmentMove.segmentStartIndex,s=i.segmentMove.newSegmentStartIndex;return r===a?s:r>=s?r+o<s?s:r+o:r}if(i.bendpointMove){var c,p=i.bendpointMove.insert,l=i.bendpointMove.bendpointIndex;return 0===o?r:(r>=l&&(c=p?r+1:r-1),r<l&&(c=r,p&&"bendpoint"!==n.type&&l-1===r&&Vu(t,l)<n.relativeLocation&&c++),c)}return 0===o?r:i.connectionStart&&0===r?0:i.connectionEnd&&r===e.length-2?t.length-2:Math.floor((t.length-2)/2)}(n,t,s,i);if(p<0||p>t.length-2||null===p)return a;var l,u,h=Gu(n,c),d=Gu(t,p),f=s.position,m=function(e,t){var n=Ap(e[0],e[1]),i=Ap(e[0],t);return 0===n?0:i/n}(h,f),v=(l=d,u=kp(h),kp(l)-u);if("bendpoint"===s.type){var y=t.length-n.length,g=s.bendpointIndex,b=n[g];if(-1!==t.indexOf(b))return a;if(0===y){var _=t[g];return{delta:{x:r=_.x-s.position.x,y:o=_.y-s.position.y},point:{x:e.x+r,y:e.y+o}}}y<0&&0!==g&&g<n.length-1&&(m=Vu(n,g))}var x,w,E={x:(d[1].x-d[0].x)*m+d[0].x,y:(d[1].y-d[0].y)*m+d[0].y},S=(x={x:e.x-f.x,y:e.y-f.y},(w=v)?{x:Math.cos(w)*x.x-Math.sin(w)*x.y,y:Math.sin(w)*x.x+Math.cos(w)*x.y}:x);return r=E.x+S.x-e.x,o=E.y+S.y-e.y,{point:ln(E),delta:ln({x:r,y:o})}}function Vu(e,t){var n=Ap(e[t-1],e[t]);return n/(n+Ap(e[t],e[t+1]))}function Gu(e,t){return[e[t],e[t+1]]}function Wu(e,t,n){var i=za(t),r=za(n),o=Ha(e,i),a=o.x*(n.width/t.width),s=o.y*(n.height/t.height);return ln({x:r.x+a,y:r.y+s})}function Uu(e,t,n){var i=za(e),r=za(t),o=za(n),a=Ha(e,i),s=Ha(i,r),c=function(e,t,n){var i=un(t),r=un(n);if(function(e,t){return function(e,t){return e.right!==t.right&&e.left!==t.left}(e,t)||function(e,t){return e.top!==t.top&&e.bottom!==t.bottom}(e,t)}(i,r))return null;var o,a,s,c=mn(t,e);if("top"===c)o={x:0,y:r.bottom-i.bottom};else if("bottom"===c)o={x:0,y:r.top-i.top};else if("right"===c)o={x:r.left-i.left,y:0};else{if("left"!==c)return null;o={x:r.right-i.right,y:0}}if(a={x:e.x+o.x,y:e.y+o.y},s=mn(n,a),s!==c)return null;return o}(i,t,n);if(c)return c;var p=s.x*(n.width/t.width),l=s.y*(n.height/t.height),u=o.x+p,h=o.y+l;return ln({x:u+a.x-e.x,y:h+a.y-e.y})}var qu="name",Ku="text";function Yu(e,t,n,i){function r(e){var n=e.context,r=n.element,o=n.properties;if(qu in o&&t.updateLabel(r,o[qu]),Ku in o&&vr(r,"bpmn:TextAnnotation")){var a=i.getTextAnnotationBounds({x:r.x,y:r.y,width:r.width,height:r.height},o[Ku]||"");t.updateLabel(r,o.text,a)}}function o(e){var t=e.context,n=t.connection,i=n.label,r=L({},t.hints),o=t.newWaypoints||n.waypoints,a=t.oldWaypoints;return void 0===r.startChanged&&(r.startChanged=!!r.connectionStart),void 0===r.endChanged&&(r.endChanged=!!r.connectionEnd),function(e,t,n,i){return Hu(fn(e),t,n,i).delta}(i,o,a,r)}Do.call(this,e),this.postExecute("element.updateProperties",r),this.postExecute("element.updateModdleProperties",(e=>{gr(e.context.element)===e.context.moddleElement&&r(e)})),this.postExecute(["shape.create","connection.create"],(function(e){var n=e.context;if(!1!==(n.hints||{}).createElementsBehavior){var i=n.shape||n.connection;!cn(i)&&zr(i)&&Ur(i)&&t.updateLabel(i,Ur(i))}})),this.postExecute("shape.delete",(function(e){var n=e.context,i=n.labelTarget,r=n.hints||{};i&&!1!==r.unsetLabel&&t.updateLabel(i,null,null,{removeShape:!1})})),this.postExecute(["connection.layout","connection.updateWaypoints"],(function(e){var n=e.context;if(!1!==(n.hints||{}).labelBehavior){var i,r=n.connection.label;r&&r.parent&&(i=o(e),t.moveShape(r,i))}})),this.postExecute(["shape.replace"],(function(e){var t=e.context,n=t.newShape,i=t.oldShape,r=gr(n);r&&zr(r)&&i.label&&n.label&&(n.label.x=i.label.x,n.label.y=i.label.y)})),this.postExecute("shape.resize",(function(e){var n,i=e.context,r=i.shape,o=i.newBounds,a=i.oldBounds;if(Hr(r)){var s=r.label,c=function(e,t){if(!t.length)return;var n=function(e,t){var n=t.map((function(t){return{line:t,distance:Pp(e,t)}}));return A(n,"distance")[0].line}(e,t);return Rp(e,n)}(fn(s),[[{x:(n=a).x,y:n.y},{x:n.x+(n.width||0),y:n.y}],[{x:n.x+(n.width||0),y:n.y},{x:n.x+(n.width||0),y:n.y+(n.height||0)}],[{x:n.x,y:n.y+(n.height||0)},{x:n.x+(n.width||0),y:n.y+(n.height||0)}],[{x:n.x,y:n.y},{x:n.x,y:n.y+(n.height||0)}]]),p=Xu(c,a,o);t.moveShape(s,p)}}))}function Xu(e,t,n){return ln(Ha(Wu(e,t,n),e))}function Zu(e,t){function n(e,t){var n=e.context,i=n.connection,r=L({},n.hints),o=n.newWaypoints||i.waypoints,a=n.oldWaypoints;return void 0===r.startChanged&&(r.startChanged=!!r.connectionStart),void 0===r.endChanged&&(r.endChanged=!!r.connectionEnd),function(e,t,n,i){return Hu(e,t,n,i).point}(t,o,a,r)}Do.call(this,e),this.postExecute(["connection.layout","connection.updateWaypoints"],(function(e){var i=e.context.connection,r=i.outgoing;i.incoming.forEach((function(i){var r=i.waypoints[i.waypoints.length-1],o=n(e,r),a=[].concat(i.waypoints.slice(0,-1),[o]);t.updateWaypoints(i,a)})),r.forEach((function(i){var r=i.waypoints[0],o=n(e,r),a=[].concat([o],i.waypoints.slice(1));t.updateWaypoints(i,a)}))})),this.postExecute(["connection.move"],(function(e){var n=e.context,i=n.connection,r=i.outgoing,o=i.incoming,a=n.delta;o.forEach((function(e){var n=e.waypoints[e.waypoints.length-1],i={x:n.x+a.x,y:n.y+a.y},r=[].concat(e.waypoints.slice(0,-1),[i]);t.updateWaypoints(e,r)})),r.forEach((function(e){var n=e.waypoints[0],i={x:n.x+a.x,y:n.y+a.y},r=[].concat([i],e.waypoints.slice(1));t.updateWaypoints(e,r)}))}))}function Qu(e,t,n){var i=ih(e),r=rh(i,t),o=i[0];return r.length?r[r.length-1]:Wu(o.original||o,n,t)}function Ju(e,t,n){var i=ih(e),r=rh(i,t),o=i[i.length-1];return r.length?r[0]:Wu(o.original||o,n,t)}function eh(e,t,n){var i=ih(e),r=nh(t,n),o=i[0];return Wu(o.original||o,r,t)}function th(e,t,n){var i=ih(e),r=nh(t,n),o=i[i.length-1];return Wu(o.original||o,r,t)}function nh(e,t){return{x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height}}function ih(e){var t=e.waypoints;if(!t.length)throw new Error("connection#"+e.id+": no waypoints");return t}function rh(e,t){return y(E(e,oh),(function(e){return function(e,t){return"intersect"===mn(t,e,1)}(e,t)}))}function oh(e){return e.original||e}function ah(e,t){Do.call(this,e),this.postExecute("shape.replace",(function(e){var n=e.oldShape,i=e.newShape;if(function(e,t){return vr(e,"bpmn:Participant")&&Or(e)&&vr(t,"bpmn:Participant")&&!Or(t)}(n,i)){var r,o,a,s,c=(o=ut([r=n],!1),a=[],s=[],o.forEach((function(e){e!==r&&(e.incoming.forEach((function(e){vr(e,"bpmn:MessageFlow")&&a.push(e)})),e.outgoing.forEach((function(e){vr(e,"bpmn:MessageFlow")&&s.push(e)})))}),[]),{incoming:a,outgoing:s});c.incoming.forEach((function(e){var r=Ju(e,i,n);t.reconnectEnd(e,i,r)})),c.outgoing.forEach((function(e){var r=Qu(e,i,n);t.reconnectStart(e,i,r)}))}}),!0)}e(Yu,Do),Yu.$inject=["eventBus","modeling","bpmnFactory","textRenderer"],e(Zu,Do),Zu.$inject=["eventBus","modeling"],ah.$inject=["eventBus","modeling"],e(ah,Do);const sh=["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:EscalationEventDefinition","bpmn:ConditionalEventDefinition","bpmn:SignalEventDefinition"];function ch(e){const t=gr(e);if(!(vr(t,"bpmn:BoundaryEvent")||vr(t,"bpmn:StartEvent")&&$r(t.$parent)))return!1;const n=t.get("eventDefinitions");return!(!n||!n.length)&&sh.some((e=>vr(n[0],e)))}function ph(e){return vr(e,"bpmn:BoundaryEvent")?"cancelActivity":"isInterrupting"}function lh(e,t){e.invoke(Do,this),this.postExecuted("shape.replace",(function(e){const n=e.context.oldShape,i=e.context.newShape,r=e.context.hints;if(!ch(i))return;const o=ph(i);if(r.targetElement&&void 0!==r.targetElement[o])return;const a=gr(n).get(o);a!==gr(i).get(o)&&t.updateProperties(i,{[o]:a})}))}function uh(e,t){Do.call(this,e),this.preExecute("shape.resize",(function(e){var n=e.shape,i=br(n),r=i&&i.get("label");r&&r.get("bounds")&&t.updateModdleProperties(n,r,{bounds:void 0})}),!0)}function hh(e,t,n){Do.call(this,e),this.preExecute("shape.delete",(function(e){var i=e.context.shape;if(1===i.incoming.length&&1===i.outgoing.length){var r=i.incoming[0],o=i.outgoing[0];if(vr(r,"bpmn:SequenceFlow")&&vr(o,"bpmn:SequenceFlow")&&t.canConnect(r.source,o.target,r)){var a=function(e,t){var n=Pu(dh(e[e.length-2]),dh(e[e.length-1]),dh(t[1]),dh(t[0]));return n?[].concat(e.slice(0,e.length-1),[n],t.slice(1)):[dh(e[0]),dh(t[t.length-1])]}(r.waypoints,o.waypoints);n.reconnectEnd(r,o.target,a)}}}))}function dh(e){return e.original||e}function fh(e,t){Do.call(this,e),this.preExecute("shape.delete",(function(e){var t=e.shape,n=t.parent;vr(t,"bpmn:Participant")&&(e.collaborationRoot=n)}),!0),this.postExecute("shape.delete",(function(e){var n=e.collaborationRoot;if(n&&!n.businessObject.participants.length){var i=t.makeProcess(),r=n.children.slice();t.moveElements(r,{x:0,y:0},i)}}),!0)}function mh(e,t,n,i){Do.call(this,e);var r=i.get("dragging",!1);function o(e){var i,r,o=e.source,a=e.target;e.parent&&(vr(e,"bpmn:SequenceFlow")&&(n.canConnectSequenceFlow(o,a)||(r=!0),n.canConnectMessageFlow(o,a)&&(i="bpmn:MessageFlow")),vr(e,"bpmn:MessageFlow")&&(n.canConnectMessageFlow(o,a)||(r=!0),n.canConnectSequenceFlow(o,a)&&(i="bpmn:SequenceFlow")),r&&t.removeConnection(e),i&&t.connect(o,a,{type:i,waypoints:e.waypoints.slice()}))}this.postExecuted("elements.move",(function(e){g(e.closure.allConnections,o)}),!0),this.preExecute("connection.reconnect",(function(e){var i,o,a=e.context,s=a.connection,c=a.newSource||s.source,p=a.newTarget||s.target;(i=n.canConnect(c,p))&&i.type!==s.type&&(o=t.connect(c,p,{type:i.type,associationDirection:i.associationDirection,waypoints:s.waypoints.slice()}),s.parent&&t.removeConnection(s),a.connection=o,r&&function(e,t){var n,i=r.context(),o=i&&i.payload.previousSelection;if(!o||!o.length)return;if(-1===(n=o.indexOf(e)))return;o.splice(n,1,t)}(s,o))})),this.postExecuted("element.updateProperties",(function(e){var n,i=e.context,r=i.properties,o=i.element,a=o.businessObject;r.default&&(n=m(o.outgoing,M({id:o.businessObject.default.id})))&&t.updateProperties(n,{conditionExpression:void 0}),r.conditionExpression&&a.sourceRef.default===a&&t.updateProperties(o.source,{default:void 0})}))}function vh(e,t,n,i,r,o){i.invoke(Do,this),this._bpmnReplace=e,this._elementRegistry=n,this._selection=o,this.postExecuted(["elements.create"],500,(function(e){var n=e.context,i=n.parent,r=n.elements,o=_(r,(function(e,n){var r=t.canReplace([n],n.host||n.parent||i);return r?e.concat(r.replacements):e}),[]);o.length&&this._replaceElements(r,o)}),this),this.postExecuted(["elements.move"],500,(function(e){var n=e.context,i=n.newParent,r=n.newHost,o=[];g(n.closure.topLevel,(function(e){o=$r(e)?o.concat(e.children):o.concat(e)})),1===o.length&&r&&(i=r);var a=t.canReplace(o,i);a&&this._replaceElements(o,a.replacements,r)}),this),this.postExecute(["shape.replace"],1500,(function(e){var n,i=e.context,r=i.oldShape,o=i.newShape,a=r.attachers;a&&a.length&&(n=t.canReplace(a,o),this._replaceElements(a,n.replacements))}),this),this.postExecuted(["shape.replace"],1500,(function(e){var t=e.context,n=t.oldShape,i=t.newShape;r.unclaimId(n.businessObject.id,n.businessObject),r.updateProperties(i,{id:n.id})}))}lh.$inject=["injector","modeling"],e(lh,Do),e(uh,Do),uh.$inject=["eventBus","modeling"],e(hh,Do),hh.$inject=["eventBus","bpmnRules","modeling"],fh.$inject=["eventBus","modeling"],e(fh,Do),e(mh,Do),mh.$inject=["eventBus","modeling","bpmnRules","injector"],e(vh,Do),vh.prototype._replaceElements=function(e,t){var n=this._elementRegistry,i=this._bpmnReplace,r=this._selection;g(t,(function(t){var r={type:t.newElementType},o=n.get(t.oldElementId),a=e.indexOf(o);e[a]=i.replaceElement(o,r,{select:!1})})),t&&r.select(e)},vh.$inject=["bpmnReplace","bpmnRules","elementRegistry","injector","modeling","selection"];var yh={width:140,height:120},gh={width:300,height:60},bh={width:60,height:300},_h={width:300,height:150},xh={width:150,height:300},wh={width:140,height:120},Eh={width:50,height:30};function Sh(e){e.on("resize.start",1500,(function(e){var t=e.context,n=t.shape,i=t.direction,r=t.balanced;(vr(n,"bpmn:Lane")||vr(n,"bpmn:Participant"))&&(t.resizeConstraints=function(e,t,n){var i=mu(e),r=!0,o=!0,a=du(i,[i]),s=un(e),c={},p={},l=Lr(e),u=l?gh:bh;/n/.test(t)?p.top=s.bottom-u.height:/e/.test(t)?p.right=s.left+u.width:/s/.test(t)?p.bottom=s.top+u.height:/w/.test(t)&&(p.left=s.right-u.width);a.forEach((function(e){var i=un(e);l?(i.top<s.top-10&&(r=!1),i.bottom>s.bottom+10&&(o=!1)):(i.left<s.left-10&&(r=!1),i.right>s.right+10&&(o=!1)),/n/.test(t)&&(n&&Ch(s.top-i.bottom)<10&&Mh(c,"top",i.top+u.height),Ch(s.top-i.top)<5&&Ah(p,"top",i.bottom-u.height)),/e/.test(t)&&(n&&Ch(s.right-i.left)<10&&Ah(c,"right",i.right-u.width),Ch(s.right-i.right)<5&&Mh(p,"right",i.left+u.width)),/s/.test(t)&&(n&&Ch(s.bottom-i.top)<10&&Ah(c,"bottom",i.bottom-u.height),Ch(s.bottom-i.bottom)<5&&Mh(p,"bottom",i.top+u.height)),/w/.test(t)&&(n&&Ch(s.left-i.right)<10&&Mh(c,"left",i.left+u.width),Ch(s.left-i.left)<5&&Ah(p,"left",i.right-u.width))}));var h=i.children.filter((function(e){return!e.hidden&&!e.waypoints&&(vr(e,"bpmn:FlowElement")||vr(e,"bpmn:Artifact"))})),d=l?Th:Dh;return h.forEach((function(e){var n=un(e);!/n/.test(t)||l&&!r||Ah(p,"top",n.top-d.top),/e/.test(t)&&(l||o)&&Mh(p,"right",n.right+d.right),!/s/.test(t)||l&&!o||Mh(p,"bottom",n.bottom+d.bottom),/w/.test(t)&&(l||r)&&Ah(p,"left",n.left-d.left)})),{min:p,max:c}}(n,i,r)),vr(n,"bpmn:SubProcess")&&Or(n)&&(t.minDimensions=wh),vr(n,"bpmn:TextAnnotation")&&(t.minDimensions=Eh)}))}Sh.$inject=["eventBus"];var Ch=Math.abs,kh=Math.min,Rh=Math.max;function Ph(e,t,n,i){var r=e[t];e[t]=void 0===r?n:i(n,r)}function Ah(e,t,n){return Ph(e,t,n,kh)}function Mh(e,t,n){return Ph(e,t,n,Rh)}var Th={top:20,left:50,right:20,bottom:20},Dh={top:50,left:20,right:20,bottom:20};function Bh(e,t){e.on("resize.start",1501,(function(e){var t=e.context,n=t.shape;(vr(n,"bpmn:Lane")||vr(n,"bpmn:Participant"))&&(t.balanced=!ca(e))})),e.on("resize.end",1001,(function(e){var n=e.context,i=n.shape,r=n.canExecute,o=n.newBounds;if(vr(i,"bpmn:Lane")||vr(i,"bpmn:Participant"))return r&&(o=pn(o),t.resizeLane(i,o,n.balanced)),!1}))}Bh.$inject=["eventBus","modeling"];function Nh(e,t,n,i,r){function o(e){return yr(e,["bpmn:ReceiveTask","bpmn:SendTask"])||function(e,t){p(t)||(t=[t]);return w(t,(function(t){return Ir(e,t)}))}(e,["bpmn:ErrorEventDefinition","bpmn:EscalationEventDefinition","bpmn:MessageEventDefinition","bpmn:SignalEventDefinition"])}function a(t){return!!m(e.getDefinitions().get("rootElements"),M({id:t.id}))}function s(e){return vr(e,"bpmn:ErrorEventDefinition")?"errorRef":vr(e,"bpmn:EscalationEventDefinition")?"escalationRef":vr(e,"bpmn:MessageEventDefinition")?"messageRef":vr(e,"bpmn:SignalEventDefinition")?"signalRef":void 0}function c(e){if(yr(e,["bpmn:ReceiveTask","bpmn:SendTask"]))return e.get("messageRef");var t=e.get("eventDefinitions")[0];return t.get(s(t))}n.invoke(Do,this),this.executed(["shape.create","element.updateProperties","element.updateModdleProperties"],(function(t){var n=t.shape||t.element;if(o(n)){var i=c(gr(n));i&&!a(i)&&(_t(e.getDefinitions().get("rootElements"),i),t.addedRootElement=i)}}),!0),this.reverted(["shape.create","element.updateProperties","element.updateModdleProperties"],(function(t){var n=t.addedRootElement;n&&bt(e.getDefinitions().get("rootElements"),n)}),!0),t.on("copyPaste.copyElement",(function(e){var t=e.descriptor,n=e.element;if(!n.labelTarget&&o(n)){var i=c(gr(n));i&&(t.referencedRootElement=i)}})),t.on("copyPaste.pasteElement",500,(function(e){var t=e.descriptor,n=t.businessObject,o=t.referencedRootElement;o&&(a(o)||(o=i.copyElement(o,r.create(o.$type))),function(e,t){if(yr(e,["bpmn:ReceiveTask","bpmn:SendTask"]))return e.set("messageRef",t);var n=e.get("eventDefinitions")[0];n.set(s(n),t)}(n,o),delete t.referencedRootElement)}))}Nh.$inject=["bpmnjs","eventBus","injector","moddleCopy","bpmnFactory"],e(Nh,Do);var jh=Math.max;function Oh(e){e.on("spaceTool.getMinDimensions",(function(e){var t=e.shapes,n=e.axis,i=e.start,r={};return g(t,(function(e){var t=e.id;vr(e,"bpmn:Participant")&&(r[t]=function(e,t,n){var i=Lr(e);if(r=e,!fu(r).length)return i?_h:xh;var r;var o=function(e){return"x"===e}(t),a={};a=o?i?_h:{width:$h(e,n,o),height:xh.height}:i?{width:_h.width,height:Lh(e,n,o)}:xh;return a}(e,n,i)),vr(e,"bpmn:Lane")&&(r[t]=Lr(e)?gh:bh),vr(e,"bpmn:SubProcess")&&Or(e)&&(r[t]=wh),vr(e,"bpmn:TextAnnotation")&&(r[t]=Eh),vr(e,"bpmn:Group")&&(r[t]=yh)})),r}))}function Lh(e,t,n){var i;return i=function(e,t,n){var i,r=fu(e);return i=Ih(r,t,n),e.height-i.height+gh.height}(e,t,n),jh(_h.height,i)}function $h(e,t,n){var i;return i=function(e,t,n){var i,r=fu(e);return i=Ih(r,t,n),e.width-i.width+bh.width}(e,t,n),jh(xh.width,i)}function Ih(e,t,n){var i,r,o;for(i=0;i<e.length;i++)if(r=e[i],!n&&t>=r.y&&t<=r.y+r.height||n&&t>=r.x&&t<=r.x+r.width)return(o=fu(r)).length?Ih(o,t,n):r}Oh.$inject=["eventBus"];var Fh=180,zh=160;function Hh(e,t,n,i,r,o,a){Do.call(this,t),this._canvas=e,this._eventBus=t,this._modeling=n,this._elementFactory=i,this._bpmnFactory=r,this._bpmnjs=o,this._elementRegistry=a;var s=this;function c(e){return vr(e,"bpmn:SubProcess")&&!Or(e)}function p(t){var n=t.shape,i=t.newRootElement,r=gr(n);i=s._addDiagram(i||r),t.newRootElement=e.addRootElement(i)}function l(t){var n=gr(t.shape);s._removeDiagram(n);var i=t.newRootElement=a.get(zo(n));e.removeRootElement(i)}this.executed("shape.create",(function(e){c(e.shape)&&p(e)}),!0),this.postExecuted("shape.create",(function(e){var t=e.shape,n=e.newRootElement;n&&t.children&&(s._showRecursively(t.children),s._moveChildrenToShape(t,n))}),!0),this.reverted("shape.create",(function(e){c(e.shape)&&l(e)}),!0),this.preExecuted("shape.delete",(function(e){var t=e.shape;if(c(t)){var i=a.get(zo(t));i&&n.removeElements(i.children.slice())}}),!0),this.executed("shape.delete",(function(e){c(e.shape)&&l(e)}),!0),this.reverted("shape.delete",(function(e){c(e.shape)&&p(e)}),!0),this.preExecuted("shape.replace",(function(t){var n=t.oldShape,i=t.newShape;c(n)&&c(i)&&(t.oldRoot=e.removeRootElement(zo(n)))}),!0),this.postExecuted("shape.replace",(function(t){var i=t.newShape,r=t.oldRoot,o=e.findRoot(zo(i));if(r&&o){var a=r.children;n.moveElements(a,{x:0,y:0},o)}}),!0),this.executed("element.updateProperties",(function(e){var t=e.element;if(vr(t,"bpmn:SubProcess")){var n=e.properties,i=e.oldProperties.id,r=n.id;if(i!==r){if(Vo(t))return a.updateId(t,Ho(r)),void a.updateId(i,r);a.get(Ho(i))&&a.updateId(Ho(i),Ho(r))}}}),!0),this.reverted("element.updateProperties",(function(e){var t=e.element;if(vr(t,"bpmn:SubProcess")){var n=e.properties,i=e.oldProperties.id,r=n.id;if(i!==r){if(Vo(t))return a.updateId(t,Ho(i)),void a.updateId(r,i);var o=a.get(Ho(r));o&&a.updateId(o,Ho(i))}}}),!0),t.on("element.changed",(function(e){var n=e.element;if(Vo(n)){var i=n,r=a.get(Fo(i));r&&r!==i&&t.fire("element.changed",{element:r})}})),this.executed("shape.toggleCollapse",400,(function(e){var t=e.shape;vr(t,"bpmn:SubProcess")&&(Or(t)?l(e):(p(e),s._showRecursively(t.children)))}),!0),this.reverted("shape.toggleCollapse",400,(function(e){var t=e.shape;vr(t,"bpmn:SubProcess")&&(Or(t)?l(e):(p(e),s._showRecursively(t.children)))}),!0),this.postExecuted("shape.toggleCollapse",600,(function(e){var t=e.shape;if(vr(t,"bpmn:SubProcess")){var n=e.newRootElement;n&&(Or(t)?s._moveChildrenToShape(n,t):s._moveChildrenToShape(t,n))}}),!0),t.on("copyPaste.createTree",(function(e){var t=e.element,n=e.children;if(c(t)){var i=zo(t),r=a.get(i);r&&n.push.apply(n,r.children)}})),t.on("copyPaste.copyElement",(function(e){var t=e.descriptor,n=e.element,i=e.elements,r=n.parent;if(vr(br(r),"bpmndi:BPMNPlane")){var o=Fo(r),a=m(i,(function(e){return e.id===o}));a&&(t.parent=a.id)}})),t.on("copyPaste.pasteElement",(function(e){var t=e.descriptor;t.parent&&(c(t.parent)||t.parent.hidden)&&(t.hidden=!0)}))}function Vh(e,t){e.invoke(Do,this),this.postExecuted("shape.replace",(function(e){var n=e.context.oldShape,i=e.context.newShape;if(vr(i,"bpmn:SubProcess")&&(vr(n,"bpmn:Task")||vr(n,"bpmn:CallActivity"))&&Or(i)){var r,o={x:(r=i).x+r.width/6,y:r.y+r.height/2};t.createShape({type:"bpmn:StartEvent"},o,i)}}))}function Gh(e){Do.call(this,e),this.preExecute("connection.create",(function(e){const{target:t}=e;vr(t,"bpmn:TextAnnotation")&&(e.parent=t.parent)}),!0),this.preExecute(["shape.create","shape.resize","elements.move"],(function(e){const t=e.shapes||[e.shape];1===t.length&&vr(t[0],"bpmn:TextAnnotation")&&(e.hints=e.hints||{},e.hints.autoResize=!1)}),!0)}function Wh(e,t){Do.call(this,e),this.postExecuted("shape.toggleCollapse",1500,(function(e){var n=e.shape;if(!Or(n)){var i=ut(n);i.forEach((function(e){var t=e.incoming.slice(),n=e.outgoing.slice();g(t,(function(e){r(e,!0)})),g(n,(function(e){r(e,!1)}))}))}function r(e,r){-1!==i.indexOf(e.source)&&-1!==i.indexOf(e.target)||(r?t.reconnectEnd(e,n,fn(n)):t.reconnectStart(e,n,fn(n)))}}),!0)}e(Hh,Do),Hh.prototype._moveChildrenToShape=function(e,t){var n,i=this._modeling,r=e.children;if(r){var o=(r=r.concat(r.reduce((function(t,n){return n.label&&n.label.parent!==e?t.concat(n.label):t}),[]))).filter((function(e){return!e.hidden}));if(o.length){var a=ht(o);if(t.x){var s=fn(t),c=fn(a);n={x:s.x-c.x,y:s.y-c.y}}else n={x:Fh-a.x,y:zh-a.y};i.moveElements(r,n,t,{autoResize:!1})}else i.moveElements(r,{x:0,y:0},t,{autoResize:!1})}},Hh.prototype._showRecursively=function(e,t){var n=this,i=[];return e.forEach((function(e){e.hidden=!!t,i=i.concat(e),e.children&&(i=i.concat(n._showRecursively(e.children,e.collapsed||t)))})),i},Hh.prototype._addDiagram=function(e){var t=this._bpmnjs.getDefinitions().diagrams;return e.businessObject||(e=this._createNewDiagram(e)),t.push(e.di.$parent),e},Hh.prototype._createNewDiagram=function(e){var t=this._bpmnFactory,n=this._elementFactory,i=t.create("bpmndi:BPMNPlane",{bpmnElement:e}),r=t.create("bpmndi:BPMNDiagram",{plane:i});return i.$parent=r,n.createRoot({id:zo(e),type:e.$type,di:i,businessObject:e,collapsed:!0})},Hh.prototype._removeDiagram=function(e){var t=this._bpmnjs.getDefinitions().diagrams,n=m(t,(function(t){return t.plane.bpmnElement.id===e.id}));return t.splice(t.indexOf(n),1),n},Hh.$inject=["canvas","eventBus","modeling","elementFactory","bpmnFactory","bpmnjs","elementRegistry"],Vh.$inject=["injector","modeling"],e(Vh,Do),e(Gh,Do),Gh.$inject=["eventBus"],e(Wh,Do),Wh.$inject=["eventBus","modeling"];function Uh(e,t,n){Do.call(this,e),this.executed(["shape.toggleCollapse"],500,(function(e){var t,n=e.context.shape;vr(n,"bpmn:SubProcess")&&(n.collapsed?br(n).isExpanded=!1:((t=n.children).length&&t.forEach((function(e){"label"!==e.type||e.businessObject.name||(e.hidden=!0)})),br(n).isExpanded=!0))})),this.reverted(["shape.toggleCollapse"],500,(function(e){var t=e.context.shape;t.collapsed?br(t).isExpanded=!1:br(t).isExpanded=!0})),this.postExecuted(["shape.toggleCollapse"],500,(function(e){var i,r=e.context.shape,o=t.getDefaultSize(r);i=r.collapsed?function(e,t){return{x:e.x+(e.width-t.width)/2,y:e.y+(e.height-t.height)/2,width:t.width,height:t.height}}(r,o):function(e,t){var n,i,r,o=e.children,a=t;return n=(r=o,r.filter((function(e){return!e.hidden}))).concat([e]),(i=pu(n))?(a.width=Math.max(i.width,a.width),a.height=Math.max(i.height,a.height),a.x=i.x+(i.width-a.width)/2,a.y=i.y+(i.height-a.height)/2):(a.x=e.x+(e.width-a.width)/2,a.y=e.y+(e.height-a.height)/2),a}(r,o),n.resizeShape(r,i,null,{autoResize:!r.collapsed&&"nwse"})}))}function qh(e,t,n,i){t.invoke(Do,this),this.preExecute("shape.delete",(function(e){var t=e.context.shape,r=t.businessObject;cn(t)||(vr(t,"bpmn:Participant")&&Or(t)&&n.ids.unclaim(r.processRef.id),i.unclaimId(r.id,r))})),this.preExecute("connection.delete",(function(e){var t=e.context.connection.businessObject;i.unclaimId(t.id,t)})),this.preExecute("canvas.updateRoot",(function(){var t=e.getRootElement(),i=t.businessObject;vr(t,"bpmn:Collaboration")&&n.ids.unclaim(i.id)}))}function Kh(e,t){Do.call(this,e),this.preExecute("connection.delete",(function(e){var n=e.context.connection,i=n.source;(function(e,t){if(!vr(e,"bpmn:SequenceFlow"))return!1;var n=gr(t),i=gr(e);return n.get("default")===i})(n,i)&&t.updateProperties(i,{default:null})}))}e(Uh,Do),Uh.$inject=["eventBus","elementFactory","modeling"],e(qh,Do),qh.$inject=["canvas","injector","moddle","modeling"],e(Kh,Do),Kh.$inject=["eventBus","modeling"];function Yh(e,t){var n;function i(){if(!n)throw new Error("out of bounds release");return n}Do.call(this,e);var r=["spaceTool","lane.add","lane.resize","lane.split","elements.create","elements.delete","elements.move","shape.create","shape.delete","shape.move","shape.resize"];this.preExecute(r,5e3,(function(e){(n=n||new Xh).enter()})),this.postExecuted(r,500,(function(e){!function(){if(!n)throw new Error("out of bounds release");var e=n.leave();e&&(t.updateLaneRefs(n.flowNodes,n.lanes),n=null)}()})),this.preExecute(["shape.create","shape.move","shape.delete","shape.resize"],(function(e){var t=e.context.shape,n=i();t.labelTarget||(vr(t,"bpmn:Lane")&&n.addLane(t),vr(t,"bpmn:FlowNode")&&n.addFlowNode(t))}))}function Xh(){this.flowNodes=[],this.lanes=[],this.counter=0,this.addLane=function(e){this.lanes.push(e)},this.addFlowNode=function(e){this.flowNodes.push(e)},this.enter=function(){this.counter++},this.leave=function(){return this.counter--,!this.counter}}function Zh(e,t){Do.call(this,e),this.postExecuted("elements.create",(function(e){const n=e.context.elements;for(const e of n)Qh(e)&&!Jh(e)&&t.updateProperties(e,{isForCompensation:void 0})}))}function Qh(e){const t=gr(e);return t&&t.isForCompensation}function Jh(e){return e.incoming.filter((e=>function(e){return e&&vr(e,"bpmn:BoundaryEvent")&&Ir(e,"bpmn:CompensateEventDefinition")}(e.source))).length>0}Yh.$inject=["eventBus","modeling"],e(Yh,Do),e(Zh,Do),Zh.$inject=["eventBus","modeling"];var ed={__init__:["adaptiveLabelPositioningBehavior","appendBehavior","associationBehavior","attachEventBehavior","boundaryEventBehavior","compensateBoundaryEventBehaviour","createBehavior","createDataObjectBehavior","createParticipantBehavior","dataInputAssociationBehavior","dataStoreBehavior","deleteLaneBehavior","detachEventBehavior","dropOnFlowBehavior","eventBasedGatewayBehavior","fixHoverBehavior","groupBehavior","importDockingFix","isHorizontalFix","labelBehavior","layoutConnectionBehavior","messageFlowBehavior","nonInterruptingBehavior","removeElementBehavior","removeEmbeddedLabelBoundsBehavior","removeParticipantBehavior","replaceConnectionBehavior","replaceElementBehaviour","resizeBehavior","resizeLaneBehavior","rootElementReferenceBehavior","spaceToolBehavior","subProcessPlaneBehavior","subProcessStartEventBehavior","textAnnotationBehavior","toggleCollapseConnectionBehaviour","toggleElementCollapseBehaviour","unclaimIdBehavior","updateFlowNodeRefsBehavior","unsetDefaultFlowBehavior","setCompensationActivityAfterPasteBehavior"],adaptiveLabelPositioningBehavior:["type",jl],appendBehavior:["type",Ll],associationBehavior:["type",$l],attachEventBehavior:["type",Il],boundaryEventBehavior:["type",zl],compensateBoundaryEventBehaviour:["type",Hl],createBehavior:["type",Ul],createDataObjectBehavior:["type",ql],createParticipantBehavior:["type",Zl],dataInputAssociationBehavior:["type",Jl],dataStoreBehavior:["type",nu],deleteLaneBehavior:["type",yu],detachEventBehavior:["type",gu],dropOnFlowBehavior:["type",_u],eventBasedGatewayBehavior:["type",Eu],fixHoverBehavior:["type",ku],groupBehavior:["type",Ru],importDockingFix:["type",Au],isHorizontalFix:["type",Tu],labelBehavior:["type",Yu],layoutConnectionBehavior:["type",Zu],messageFlowBehavior:["type",ah],nonInterruptingBehavior:["type",lh],removeElementBehavior:["type",hh],removeEmbeddedLabelBoundsBehavior:["type",uh],removeParticipantBehavior:["type",fh],replaceConnectionBehavior:["type",mh],replaceElementBehaviour:["type",vh],resizeBehavior:["type",Sh],resizeLaneBehavior:["type",Bh],rootElementReferenceBehavior:["type",Nh],spaceToolBehavior:["type",Oh],subProcessPlaneBehavior:["type",Hh],subProcessStartEventBehavior:["type",Vh],textAnnotationBehavior:["type",Gh],toggleCollapseConnectionBehaviour:["type",Wh],toggleElementCollapseBehaviour:["type",Uh],unclaimIdBehavior:["type",qh],unsetDefaultFlowBehavior:["type",Kh],updateFlowNodeRefsBehavior:["type",Yh],setCompensationActivityAfterPasteBehavior:["type",Zh]};function td(e,t){var n=mn(e,t,-15);return"intersect"!==n?n:null}function nd(e){Hc.call(this,e)}function id(e){return!e||cn(e)}function rd(e){do{if(vr(e,"bpmn:Process"))return gr(e);if(vr(e,"bpmn:Participant"))return gr(e).processRef||gr(e)}while(e=e.parent)}function od(e){return vr(e,"bpmn:TextAnnotation")}function ad(e){return vr(e,"bpmn:Group")&&!e.labelTarget}function sd(e){return vr(e,"bpmn:BoundaryEvent")&&ud(e,"bpmn:CompensateEventDefinition")}function cd(e){return gr(e).isForCompensation}function pd(e){for(var t=e;t=t.parent;){if(vr(t,"bpmn:FlowElementsContainer"))return gr(t);if(vr(t,"bpmn:Participant"))return gr(t).processRef}return null}function ld(e,t){return pd(e)===pd(t)}function ud(e,t){return!!m(gr(e).eventDefinitions||[],(function(e){return vr(e,t)}))}function hd(e,t){return(gr(e).eventDefinitions||[]).every((function(e){return vr(e,t)}))}function dd(e,t){var n=function(e){for(var t=[];e;)(e=e.parent)&&t.push(e);return t}(t);return-1!==n.indexOf(e)}function fd(e,t,n){if(id(e)||id(t))return null;if(!vr(n,"bpmn:DataAssociation")){if(Pd(e,t))return{type:"bpmn:MessageFlow"};if(Ad(e,t))return{type:"bpmn:SequenceFlow"}}var i=Md(e,t);return i||(Rd(e,t)?{type:"bpmn:Association",associationDirection:"One"}:!!kd(e,t)&&{type:"bpmn:Association",associationDirection:"None"})}function md(e,t){return!(!cn(e)&&!ad(e))||!(vr(t,"bpmn:Participant")&&!Or(t))&&(vr(e,"bpmn:Participant")?vr(t,"bpmn:Process")||vr(t,"bpmn:Collaboration"):yr(e,["bpmn:DataInput","bpmn:DataOutput"])&&e.parent?t===e.parent:vr(e,"bpmn:Lane")?vr(t,"bpmn:Participant")||vr(t,"bpmn:Lane"):!(vr(e,"bpmn:BoundaryEvent")&&!function(e){return gr(e).cancelActivity&&(gd(e)||bd(e))}(e))&&(vr(e,"bpmn:FlowElement")&&!vr(e,"bpmn:DataStoreReference")?vr(t,"bpmn:FlowElementsContainer")?Or(t):yr(t,["bpmn:Participant","bpmn:Lane"]):vr(e,"bpmn:DataStoreReference")&&vr(t,"bpmn:Collaboration")?w(gr(t).get("participants"),(function(e){return!!e.get("processRef")})):yr(e,["bpmn:Artifact","bpmn:DataAssociation","bpmn:DataStoreReference"])?yr(t,["bpmn:Collaboration","bpmn:Lane","bpmn:Participant","bpmn:Process","bpmn:SubProcess"]):!!vr(e,"bpmn:MessageFlow")&&(vr(t,"bpmn:Collaboration")||e.source.parent==t||e.target.parent==t)))}function vd(e){return vr(e,"bpmn:Lane")}function yd(e){return!!function(e){return!cn(e)&&vr(e,"bpmn:BoundaryEvent")}(e)||(!(!vr(e,"bpmn:IntermediateThrowEvent")||!gd(e))||vr(e,"bpmn:IntermediateCatchEvent")&&bd(e))}function gd(e){var t=gr(e);return t&&!(t.eventDefinitions&&t.eventDefinitions.length)}function bd(e){return _d(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])}function _d(e,t){return t.some((function(t){return ud(e,t)}))}function xd(e,t,n,i){if(Array.isArray(e)||(e=[e]),1!==e.length)return!1;var r=e[0];return!cn(r)&&(!!yd(r)&&(!$r(t)&&(!(!vr(t,"bpmn:Activity")||cd(t))&&(!(i&&!td(i,t))&&(!function(e){return vr(e,"bpmn:ReceiveTask")&&m(e.incoming,(function(e){return vr(e.source,"bpmn:EventBasedGateway")}))}(t)&&"attach")))))}function wd(e,t,n){if(!t)return!1;var i={replacements:[]};return g(e,(function(e){$r(t)||vr(e,"bpmn:StartEvent")&&"label"!==e.type&&md(e,t)&&(function(e){return e&&!1!==gr(e).isInterrupting}(e)||i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"}),(function(e){return Ir(e,"bpmn:ErrorEventDefinition")}(e)||function(e){return Ir(e,"bpmn:EscalationEventDefinition")}(e)||function(e){return Ir(e,"bpmn:CompensateEventDefinition")}(e))&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"}),_d(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])&&vr(t,"bpmn:SubProcess")&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"})),vr(t,"bpmn:Transaction")||ud(e,"bpmn:CancelEventDefinition")&&"label"!==e.type&&(vr(e,"bpmn:EndEvent")&&md(e,t)&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:EndEvent"}),vr(e,"bpmn:BoundaryEvent")&&xd(e,t,0,n)&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:BoundaryEvent"}))})),!!i.replacements.length&&i}function Ed(e,t){return!w(e,vd)&&(!t||e.every((function(e){return md(e,t)})))}function Sd(e,t,n,i){return!!t&&(!(!cn(e)&&!ad(e))||!function(e,t){return e===t}(n,t)&&((!n||!dd(n,t))&&(md(e,t)||Td(e,t))))}function Cd(e,t){return vr(e,"bpmn:SubProcess")?Or(e)&&(!t||t.width>=100&&t.height>=80):!!vr(e,"bpmn:Lane")||(!!vr(e,"bpmn:Participant")||(!!od(e)||!!ad(e)))}function kd(e,t){return!dd(t,e)&&!dd(e,t)&&(!!function(e,t){var n=od(e),i=od(t);return(n||i)&&n!==i}(e,t)||!!Md(e,t))}function Rd(e,t){return ld(e,t)&&sd(e)&&vr(t,"bpmn:Activity")&&(n=e,!t.attachers.includes(n))&&!$r(t);var n}function Pd(e,t){return!(Bd(e)&&!Bd(t))&&(vr(n=e,"bpmn:InteractionNode")&&!vr(n,"bpmn:BoundaryEvent")&&(!vr(n,"bpmn:Event")||vr(n,"bpmn:ThrowEvent")&&hd(n,"bpmn:MessageEventDefinition"))&&function(e){return vr(e,"bpmn:InteractionNode")&&!cd(e)&&(!vr(e,"bpmn:Event")||vr(e,"bpmn:CatchEvent")&&hd(e,"bpmn:MessageEventDefinition"))&&!(vr(e,"bpmn:BoundaryEvent")&&!ud(e,"bpmn:MessageEventDefinition"))}(t)&&!function(e,t){return rd(e)===rd(t)}(e,t));var n}function Ad(e,t){return vr(n=e,"bpmn:FlowNode")&&!vr(n,"bpmn:EndEvent")&&!$r(n)&&!(vr(n,"bpmn:IntermediateThrowEvent")&&ud(n,"bpmn:LinkEventDefinition"))&&!sd(n)&&!cd(n)&&function(e){return vr(e,"bpmn:FlowNode")&&!vr(e,"bpmn:StartEvent")&&!vr(e,"bpmn:BoundaryEvent")&&!$r(e)&&!(vr(e,"bpmn:IntermediateCatchEvent")&&ud(e,"bpmn:LinkEventDefinition"))&&!cd(e)}(t)&&ld(e,t)&&!(vr(e,"bpmn:EventBasedGateway")&&!function(e){return vr(e,"bpmn:ReceiveTask")||vr(e,"bpmn:IntermediateCatchEvent")&&(ud(e,"bpmn:MessageEventDefinition")||ud(e,"bpmn:TimerEventDefinition")||ud(e,"bpmn:ConditionalEventDefinition")||ud(e,"bpmn:SignalEventDefinition"))}(t));var n}function Md(e,t){return yr(e,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&yr(t,["bpmn:Activity","bpmn:ThrowEvent"])?{type:"bpmn:DataInputAssociation"}:!(!yr(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])||!yr(e,["bpmn:Activity","bpmn:CatchEvent"]))&&{type:"bpmn:DataOutputAssociation"}}function Td(e,t,n){if(!t)return!1;if(Array.isArray(e)){if(1!==e.length)return!1;e=e[0]}return t.source!==e&&t.target!==e&&(yr(t,["bpmn:SequenceFlow","bpmn:MessageFlow"])&&!cn(t)&&vr(e,"bpmn:FlowNode")&&!vr(e,"bpmn:BoundaryEvent")&&md(e,t.parent))}function Dd(e,t){return!!cn(t)||!(vr(t,"bpmn:Lane")&&!function(e,t){return e&&t&&-1!==e.indexOf(t)}(e,t.parent))}function Bd(e){return Jc(e,"bpmn:Process")||Jc(e,"bpmn:Collaboration")}e(nd,Hc),nd.$inject=["eventBus"],nd.prototype.init=function(){this.addRule("connection.start",(function(e){return function(e){if(id(e))return null;return yr(e,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference","bpmn:Group","bpmn:TextAnnotation"])}(e.source)})),this.addRule("connection.create",(function(e){var t=e.source,n=e.target,i=e.hints||{},r=i.targetParent;if(i.targetAttach)return!1;r&&(n.parent=r);try{return fd(t,n)}finally{r&&(n.parent=null)}})),this.addRule("connection.reconnect",(function(e){var t=e.connection;return fd(e.source,e.target,t)})),this.addRule("connection.updateWaypoints",(function(e){return{type:e.connection.type}})),this.addRule("shape.resize",(function(e){return Cd(e.shape,e.newBounds)})),this.addRule("elements.create",(function(e){var t=e.elements,n=e.position,i=e.target;return!(sn(i)&&!Td(t,i))&&x(t,(function(e){return sn(e)?fd(e.source,e.target,e):e.host?xd(e,e.host,null,n):Sd(e,i,null)}))})),this.addRule("elements.move",(function(e){var t=e.target,n=e.shapes,i=e.position;return xd(n,t,null,i)||wd(n,t,i)||Ed(n,t)||Td(n,t)})),this.addRule("shape.create",(function(e){return Sd(e.shape,e.target,e.source,e.position)})),this.addRule("shape.attach",(function(e){return xd(e.shape,e.target,null,e.position)})),this.addRule("element.copy",(function(e){var t=e.element;return Dd(e.elements,t)}))},nd.prototype.canConnectMessageFlow=Pd,nd.prototype.canConnectSequenceFlow=Ad,nd.prototype.canConnectDataAssociation=Md,nd.prototype.canConnectAssociation=kd,nd.prototype.canConnectCompensationAssociation=Rd,nd.prototype.canMove=Ed,nd.prototype.canAttach=xd,nd.prototype.canReplace=wd,nd.prototype.canDrop=md,nd.prototype.canInsert=Td,nd.prototype.canCreate=Sd,nd.prototype.canConnect=fd,nd.prototype.canResize=Cd,nd.prototype.canCopy=Dd;var Nd={__depends__:[xp],__init__:["bpmnRules"],bpmnRules:["type",nd]};function jd(e,t){e.on("saveXML.start",2e3,(function(){g(t.getRootElements(),(function(e){var t,n=br(e);t=E(y(ut([e],!1),(function(t){return t!==e&&!t.labelTarget})),br),n.set("planeElement",t)}))}))}jd.$inject=["eventBus","canvas"];var Od={__init__:["bpmnDiOrdering"],bpmnDiOrdering:["type",jd]};function Ld(e){Do.call(this,e);var t=this;this.preExecute(["shape.create","connection.create"],(function(e){var n=e.context,i=n.shape||n.connection,r=n.parent,o=t.getOrdering(i,r);o&&(void 0!==o.parent&&(n.parent=o.parent),n.parentIndex=o.index)})),this.preExecute(["shape.move","connection.move"],(function(e){var n=e.context,i=n.shape||n.connection,r=n.newParent||i.parent,o=t.getOrdering(i,r);o&&(void 0!==o.parent&&(n.newParent=o.parent),n.newParentIndex=o.index)}))}function $d(e,t){Ld.call(this,e);var n=[{type:"bpmn:SubProcess",order:{level:6}},{type:"bpmn:SequenceFlow",order:{level:9,containers:["bpmn:Participant","bpmn:FlowElementsContainer"]}},{type:"bpmn:DataAssociation",order:{level:9,containers:["bpmn:Collaboration","bpmn:FlowElementsContainer"]}},{type:"bpmn:TextAnnotation",order:{level:9}},{type:"bpmn:MessageFlow",order:{level:9,containers:["bpmn:Collaboration"]}},{type:"bpmn:Association",order:{level:6,containers:["bpmn:Participant","bpmn:FlowElementsContainer","bpmn:Collaboration"]}},{type:"bpmn:BoundaryEvent",order:{level:8}},{type:"bpmn:Group",order:{level:10,containers:["bpmn:Collaboration","bpmn:FlowElementsContainer"]}},{type:"bpmn:FlowElement",order:{level:5}},{type:"bpmn:Participant",order:{level:-2}},{type:"bpmn:Lane",order:{level:-1}}];function i(e){var t=e.order;if(t||(e.order=t=function(e){if(e.labelTarget)return{level:10};var t=m(n,(function(t){return yr(e,[t.type])}));return t&&t.order||{level:1}}(e)),!t)throw new Error(`no order for <${e.id}>`);return t}this.getOrdering=function(e,n){if(e.labelTarget||vr(e,"bpmn:TextAnnotation"))return{parent:t.findRoot(n)||t.getRootElement(),index:-1};var r=i(e);r.containers&&(n=function(e,t,n){for(var i=t;i&&!yr(i,n);)i=i.parent;if(!i)throw new Error(`no parent for <${e.id}> in <${t&&t.id}>`);return i}(e,n,r.containers));var o=n.children.indexOf(e),a=v(n.children,(function(t){return!(!e.labelTarget&&t.labelTarget)&&r.level<i(t).level}));return-1!==a&&-1!==o&&o<a&&(a-=1),{index:a,parent:n}}}Ld.prototype.getOrdering=function(e,t){return null},e(Ld,Do),$d.$inject=["eventBus","canvas"],e($d,Ld);var Id={__init__:["bpmnOrderingProvider"],bpmnOrderingProvider:["type",$d]};function Fd(){}Fd.prototype.get=function(){return this._data},Fd.prototype.set=function(e){this._data=e},Fd.prototype.clear=function(){var e=this._data;return delete this._data,e},Fd.prototype.isEmpty=function(){return!this._data};var zd={clipboard:["type",Fd]},Hd="drop-ok",Vd="drop-not-ok",Gd="attach-ok",Wd="new-parent",Ud="create";function qd(e,t,n,i,r){function o(t,n){[Gd,Hd,Vd,Wd].forEach((function(i){i===n?e.addMarker(t,i):e.removeMarker(t,i)}))}function a(){var e=t.context();e&&e.prefix===Ud&&t.cancel()}n.on(["create.move","create.hover"],(function(e){var t=e.context,n=t.elements,i=e.hover,a=t.source,s=t.hints||{};if(!i)return t.canExecute=!1,void(t.target=null);Kd(e);var c={x:e.x,y:e.y},p=t.canExecute=i&&function(e,t,n,i,o){if(!t)return!1;var a=m(e=y(e,(function(t){var n=t.labelTarget;return!(t.parent||cn(t)&&-1!==e.indexOf(n))})),(function(e){return!sn(e)})),s=!1,c=!1,p=!1;Yd(e)&&(s=r.allowed("shape.attach",{position:n,shape:a,target:t})),s||(p=Yd(e)?r.allowed("shape.create",{position:n,shape:a,source:i,target:t}):r.allowed("elements.create",{elements:e,position:n,target:t}));var l=o.connectionTarget;return p||s?(a&&i&&(c=r.allowed("connection.create",{source:l===i?a:i,target:l===i?i:a,hints:{targetParent:t,targetAttach:s}})),{attach:s,connect:c}):(null===p||null===s)&&null}(n,i,c,a,s);i&&null!==p&&(t.target=i,p&&p.attach?o(i,Gd):o(i,p?Wd:Vd))})),n.on(["create.end","create.out","create.cleanup"],(function(e){var t=e.hover;t&&o(t,null)})),n.on("create.end",(function(e){var t=e.context,n=t.source,r=t.shape,o=t.elements,a=t.target,s=t.canExecute,c=s&&s.attach,p=s&&s.connect,l=t.hints||{};if(!1===s||!a)return!1;Kd(e);var u={x:e.x,y:e.y};r=p?i.appendShape(n,r,u,a,{attach:c,connection:!0===p?{}:p,connectionTarget:l.connectionTarget}):m(o=i.createElements(o,u,a,L({},l,{attach:c})),(function(e){return!sn(e)})),L(t,{elements:o,shape:r}),L(e,{elements:o,shape:r})})),n.on("create.init",(function(){n.on("elements.changed",a),n.once(["create.cancel","create.end"],2e3,(function(){n.off("elements.changed",a)}))})),this.start=function(e,n,i){p(n)||(n=[n]);var r=m(n,(function(e){return!sn(e)}));if(r){i=L({elements:n,hints:{},shape:r},i||{}),g(n,(function(e){u(e.x)||(e.x=0),u(e.y)||(e.y=0)}));var o=ht(y(n,(function(e){return!e.hidden})));g(n,(function(e){sn(e)&&(e.waypoints=E(e.waypoints,(function(e){return{x:e.x-o.x-o.width/2,y:e.y-o.y-o.height/2}}))),L(e,{x:e.x-o.x-o.width/2,y:e.y-o.y-o.height/2})})),t.init(e,Ud,{cursor:"grabbing",autoActivate:!0,data:{shape:r,elements:n,context:i}})}}}function Kd(e){var t=e.context.createConstraints;t&&(t.left&&(e.x=Math.max(e.x,t.left)),t.right&&(e.x=Math.min(e.x,t.right)),t.top&&(e.y=Math.max(e.y,t.top)),t.bottom&&(e.y=Math.min(e.y,t.bottom)))}function Yd(e){return e&&1===e.length&&!sn(e[0])}qd.$inject=["canvas","dragging","eventBus","modeling","rules"];function Xd(e,t,n,i,r){t.on("create.move",750,(function(t){var o=t.hover,a=t.context,s=a.elements,c=a.dragGroup;c||(c=a.dragGroup=function(e){var t=Ae("g");_e(t,r.cls("djs-drag-group",["no-events"]));var o=Ae("g");return e.forEach((function(e){var r;e.hidden||(e.waypoints?(r=n._createContainer("connection",o),n.drawConnection(Vn(r),e)):(r=n._createContainer("shape",o),n.drawShape(Vn(r),e),Wn(r,e.x,e.y)),i.addDragger(e,t,r))})),t}(s)),o?(c.parentNode||ye(e.getActiveLayer(),c),Wn(c,t.x,t.y)):Fe(c)})),t.on("create.cleanup",(function(e){var t=e.context.dragGroup;t&&Fe(t)}))}Xd.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];var Zd={__depends__:[vp,Al,xp,_a],__init__:["create","createPreview"],create:["type",qd],createPreview:["type",Xd]};function Qd(e){var t=this;function n(e){t._lastMoveEvent=e}this._lastMoveEvent=null,e.on("canvas.init",(function(e){(t._svg=e.svg).addEventListener("mousemove",n)})),e.on("canvas.destroy",(function(){t._lastMouseEvent=null,t._svg.removeEventListener("mousemove",n)}))}Qd.$inject=["eventBus"],Qd.prototype.getLastMoveEvent=function(){return this._lastMoveEvent||function(e,t){var n=document.createEvent("MouseEvent"),i=e,r=t,o=e,a=t;n.initMouseEvent&&n.initMouseEvent("mousemove",!0,!0,window,0,i,r,o,a,!1,!1,!1,!1,0,null);return n}(0,0)};var Jd={__init__:["mouse"],mouse:["type",Qd]};function ef(e,t,n,i,r,o,a,s){this._canvas=e,this._create=t,this._clipboard=n,this._elementFactory=i,this._eventBus=r,this._modeling=o,this._mouse=a,this._rules=s,r.on("copyPaste.copyElement",(function(e){var t=e.descriptor,n=e.element,i=e.elements;t.priority=1,t.id=n.id;var r=m(i,(function(e){return e===n.parent}));r&&(t.parent=n.parent.id),function(e){return!!e.host}(n)&&(t.priority=2,t.host=n.host.id),sn(n)&&(t.priority=3,t.source=n.source.id,t.target=n.target.id,t.waypoints=function(e){return E(e.waypoints,(function(e){return(e=tf(e)).original&&(e.original=tf(e.original)),e}))}(n)),cn(n)&&(t.priority=4,t.labelTarget=n.labelTarget.id),g(["x","y","width","height"],(function(e){u(n[e])&&(t[e]=n[e])})),t.hidden=n.hidden,t.collapsed=n.collapsed})),r.on("copyPaste.pasteElements",(function(e){L(e.hints,{createElementsBehavior:!1})}))}function tf(e){return L({},e)}function nf(e,t){var n=t.indexOf(e);return-1===n?t:t.splice(n,1)}ef.$inject=["canvas","create","clipboard","elementFactory","eventBus","modeling","mouse","rules"],ef.prototype.copy=function(e){var t,n;return p(e)||(e=e?[e]:[]),n=!1===(t=this._eventBus.fire("copyPaste.canCopyElements",{elements:e}))?{}:this.createTree(p(t)?t:e),this._clipboard.set(n),this._eventBus.fire("copyPaste.elementsCopied",{elements:e,tree:n}),n},ef.prototype.paste=function(e){var t=this._clipboard.get();if(!this._clipboard.isEmpty()){var n=e&&e.hints||{};this._eventBus.fire("copyPaste.pasteElements",{hints:n});var i=this._createElements(t);if(e&&e.element&&e.point)return this._paste(i,e.element,e.point,n);this._create.start(this._mouse.getLastMoveEvent(),i,{hints:n||{}})}},ef.prototype._paste=function(e,t,n,i){g(e,(function(e){u(e.x)||(e.x=0),u(e.y)||(e.y=0)}));var r=ht(e);return g(e,(function(e){sn(e)&&(e.waypoints=E(e.waypoints,(function(e){return{x:e.x-r.x-r.width/2,y:e.y-r.y-r.height/2}}))),L(e,{x:e.x-r.x-r.width/2,y:e.y-r.y-r.height/2})})),this._modeling.createElements(e,n,t,L({},i))},ef.prototype._createElements=function(e){var t=this,n=this._eventBus,i={},r=[];return g(e,(function(e,o){g(e=A(e,"priority"),(function(e){var o,a=L({},I(e,["priority"]));return i[e.parent]?a.parent=i[e.parent]:delete a.parent,n.fire("copyPaste.pasteElement",{cache:i,descriptor:a}),sn(a)?(a.source=i[e.source],a.target=i[e.target],o=i[e.id]=t.createConnection(a),void r.push(o)):cn(a)?(a.labelTarget=i[a.labelTarget],o=i[e.id]=t.createLabel(a),void r.push(o)):(a.host&&(a.host=i[a.host]),o=i[e.id]=t.createShape(a),void r.push(o))}))})),r},ef.prototype.createConnection=function(e){return this._elementFactory.createConnection(I(e,["id"]))},ef.prototype.createLabel=function(e){return this._elementFactory.createLabel(I(e,["id"]))},ef.prototype.createShape=function(e){return this._elementFactory.createShape(I(e,["id"]))},ef.prototype.hasRelations=function(e,t){var n,i;return!(sn(e)&&(n=m(t,M({id:e.source.id})),i=m(t,M({id:e.target.id})),!n||!i))&&!(cn(e)&&!m(t,M({id:e.labelTarget.id})))},ef.prototype.createTree=function(e){var t=this._rules,n=this,i={},r=[];function o(e,t){var n=m(r,(function(t){return e===t.element}));n?n.depth<t&&(r=function(e,t){var n=t.indexOf(e);-1!==n&&t.splice(n,1);return t}(n,r),r.push({element:n.element,depth:t})):r.push({element:e,depth:t})}return lt(st(e),(function(e,t,i){if(!cn(e)){g(e.labels,(function(e){o(e,i)})),g([e.attachers,e.incoming,e.outgoing],(function(e){e&&e.length&&g(e,(function(e){g(e.labels,(function(e){o(e,i)})),o(e,i)}))})),o(e,i);var r=[];return e.children&&(r=e.children.slice()),n._eventBus.fire("copyPaste.createTree",{element:e,children:r}),r}})),e=E(r,(function(e){return e.element})),r=E(r,(function(t){return t.descriptor={},n._eventBus.fire("copyPaste.copyElement",{descriptor:t.descriptor,element:t.element,elements:e}),t})),r=A(r,(function(e){return e.descriptor.priority})),e=E(r,(function(e){return e.element})),g(r,(function(r){var o=r.depth;n.hasRelations(r.element,e)?!function(e,n){return t.allowed("element.copy",{element:e,elements:n})}(r.element,e)?nf(r.element,e):(i[o]||(i[o]=[]),i[o].push(r.descriptor)):nf(r.element,e)})),i};var rf={__depends__:[zd,Zd,Jd,xp],__init__:["copyPaste"],copyPaste:["type",ef]};function of(e,t,n){p(n)||(n=[n]),g(n,(function(n){a(e[n])||(t[n]=e[n])}))}function af(e,t,n){function i(t,i){var r=e.create(t.$type);return n.copyElement(t,r,null,i)}t.on("copyPaste.copyElement",750,(function(e){var t=e.descriptor,n=e.element,r=gr(n);if(cn(n))return t;var o=t.businessObject=i(r,!0),a=t.di=i(br(n),!0);a.bpmnElement=o,of(o,t,"name"),of(a,t,"isExpanded"),r.default&&(t.default=r.default.id)}));var r="-bpmn-js-refs";t.on("copyPaste.pasteElement",(function(e){var t=e.cache,n=e.descriptor,r=n.businessObject,o=n.di;if(cn(n))return n.businessObject=gr(t[n.labelTarget]),void(n.di=br(t[n.labelTarget]));r=n.businessObject=i(r),(o=n.di=i(o)).bpmnElement=r,of(n,r,["isExpanded","name"]),n.type=r.$type})),t.on("copyPaste.copyElement",750,(function(e){var t=e.descriptor,n=e.element;if(vr(n,"bpmn:Participant")){var r=gr(n);r.processRef&&(t.processRef=i(r.processRef,!0))}})),t.on("copyPaste.pasteElement",(function(e){var t=e.descriptor,n=t.processRef;n&&(t.processRef=i(n))})),t.on("copyPaste.pasteElement",750,(function(e){var t=e.cache;!function(e,t){e[r]=t}(t,function(e,t,n){var i=gr(e);return e.default&&(n[e.default]={element:i,property:"default"}),e.host&&(gr(e).attachedToRef=gr(t[e.host])),I(n,_(n,(function(t,n,r){var o=n.element,a=n.property;return r===e.id&&(o.set(a,i),t.push(e.id)),t}),[]))}(e.descriptor,t,function(e){return e[r]=e[r]||{}}(t)))}))}af.$inject=["bpmnFactory","eventBus","moddleCopy"];var sf=["artifacts","dataInputAssociations","dataOutputAssociations","default","flowElements","lanes","incoming","outgoing","categoryValue"];function cf(e,t,n){this._bpmnFactory=t,this._eventBus=e,this._moddle=n,e.on("moddleCopy.canCopyProperties",(function(e){var t=e.propertyNames;if(t&&t.length)return A(t,(function(e){return"extensionElements"===e}))})),e.on("moddleCopy.canCopyProperty",(function(e){var t=e.parent,n=l(t)&&t.$descriptor,i=e.propertyName;return(!i||-1===sf.indexOf(i))&&(!(i&&n&&!m(n.properties,M({name:i})))&&void 0)})),e.on("moddleCopy.canSetCopiedProperty",(function(e){var t,n,i=e.property;if(n="bpmn:ExtensionElements",(t=i)&&h(t.$instanceOf)&&t.$instanceOf(n)&&(!i.values||!i.values.length))return!1}))}function pf(e,t){return _(e.properties,(function(e,n){return t&&n.default?e:e.concat(n.name)}),[])}cf.$inject=["eventBus","bpmnFactory","moddle"],cf.prototype.copyElement=function(e,t,n,i=!1){var r=this;n&&!p(n)&&(n=[n]),n=n||pf(e.$descriptor);var o=this._eventBus.fire("moddleCopy.canCopyProperties",{propertyNames:n,sourceElement:e,targetElement:t,clone:i});return!1===o||(p(o)&&(n=o),g(n,(function(n){var o;f(e,n)&&(o=e.get(n));var a=r.copyProperty(o,t,n,i);s(a)&&(!1!==r._eventBus.fire("moddleCopy.canSetCopiedProperty",{parent:t,property:a,propertyName:n})&&t.set(n,a))}))),t},cf.prototype.copyProperty=function(e,t,n,i=!1){var r=this,o=this._eventBus.fire("moddleCopy.canCopyProperty",{parent:t,property:e,propertyName:n,clone:i});if(!1!==o){if(o)return l(o)&&o.$type&&!o.$parent&&(o.$parent=t),o;var a=this._moddle.getPropertyDescriptor(t,n);if(!a.isReference){if(a.isId)return e&&this._copyId(e,t,i);if(p(e))return _(e,(function(e,a){return(o=r.copyProperty(a,t,n,i))?e.concat(o):e}),[]);if(l(e)&&e.$type){if(this._moddle.getElementDescriptor(e).isGeneric)return;return(o=r._bpmnFactory.create(e.$type)).$parent=t,o=r.copyElement(e,o,null,i)}return e}}},cf.prototype._copyId=function(e,t,n=!1){return n?e:this._moddle.ids.assigned(e)?void 0:(this._moddle.ids.claim(e,t),e)};var lf={__depends__:[rf],__init__:["bpmnCopyPaste","moddleCopy"],bpmnCopyPaste:["type",af],moddleCopy:["type",cf]},uf=Math.round;function hf(e,t){this._modeling=e,this._eventBus=t}function df(e,t){t.on("replace.end",500,(function(t){const{newElement:n,hints:i={}}=t;!1!==i.select&&e.select(n)}))}hf.$inject=["modeling","eventBus"],hf.prototype.replaceElement=function(e,t,n){if(e.waypoints)return null;var i=this._modeling,r=this._eventBus;r.fire("replace.start",{element:e,attrs:t,hints:n});var o=t.width||e.width,a=t.height||e.height,s=t.x||e.x,c=t.y||e.y,p=uf(s+o/2),l=uf(c+a/2),u=i.replaceShape(e,L({},t,{x:p,y:l,width:o,height:a}),n);return r.fire("replace.end",{element:e,newElement:u,hints:n}),u},df.$inject=["selection","eventBus"];var ff={__init__:["replace","replaceSelectionBehavior"],replaceSelectionBehavior:["type",df],replace:["type",hf]};var mf=["cancelActivity","instantiate","eventGatewayType","triggeredByEvent","isInterrupting"];function vf(e,t,n,i,r,o){this.replaceElement=function(s,c,l){l=l||{};var u=c.type,h=s.businessObject;if(yf(h)&&("bpmn:SubProcess"===u||"bpmn:AdHocSubProcess"===u)&&function(e,t){var n=e&&f(e,"collapsed")?e.collapsed:!Or(e);return n!==(t&&(f(t,"collapsed")||f(t,"isExpanded"))?f(t,"collapsed")?t.collapsed:!t.isExpanded:n)}(s,c))return i.toggleCollapse(s),s;var d=e.create(u),m={type:u,businessObject:d,di:{}};"bpmn:ExclusiveGateway"===u&&(m.di.isMarkerVisible=!0),function(e,t,n){p(n)||(n=[n]),g(n,(function(n){a(e[n])||(t[n]=e[n])}))}(s.di,m.di,["fill","stroke","background-color","border-color","color"]);var v=function(e,t){return e.filter((function(e){return t.includes(e)}))}(pf(h.$descriptor),pf(d.$descriptor,!0));L(d,$(c,mf));var b=y(v,(function(e){return"eventDefinitions"===e?gf(s,c.eventDefinitionType):"loopCharacteristics"===e?!$r(d):!f(d,e)&&(("processRef"!==e||!1!==c.isExpanded)&&("triggeredByEvent"!==e&&("isForCompensation"!==e||!$r(d))))}));if(d=n.copyElement(h,d,b),c.eventDefinitionType&&(gf(d,c.eventDefinitionType)||(m.eventDefinitionType=c.eventDefinitionType,m.eventDefinitionAttrs=c.eventDefinitionAttrs)),vr(h,"bpmn:Activity")){if(yf(h))m.isExpanded=Or(s);else if(c&&f(c,"isExpanded")){m.isExpanded=c.isExpanded;var _=t.getDefaultSize(d,{isExpanded:m.isExpanded});m.width=_.width,m.height=_.height,m.x=s.x-(m.width-s.width)/2,m.y=s.y-(m.height-s.height)/2}Or(s)&&!vr(h,"bpmn:Task")&&m.isExpanded&&(m.width=s.width,m.height=s.height)}if(yf(h)&&!yf(d)&&(l.moveChildren=!1),vr(h,"bpmn:Participant")){!0===c.isExpanded?d.processRef=e.create("bpmn:Process"):l.moveChildren=!1;var x=Lr(s);br(s).isHorizontal||(br(m).isHorizontal=x),m.width=x?s.width:t.getDefaultSize(m).width,m.height=x?t.getDefaultSize(m).height:s.height}return o.allowed("shape.resize",{shape:d})||(m.height=t.getDefaultSize(m).height,m.width=t.getDefaultSize(m).width),d.name=h.name,yr(h,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&yr(d,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&(d.default=h.default),c.host&&!vr(h,"bpmn:BoundaryEvent")&&vr(d,"bpmn:BoundaryEvent")&&(m.host=c.host),"bpmn:DataStoreReference"!==m.type&&"bpmn:DataObjectReference"!==m.type||(m.x=s.x+(s.width-m.width)/2),r.replaceElement(s,m,{...l,targetElement:c})}}function yf(e){return vr(e,"bpmn:SubProcess")}function gf(e,t){var n=gr(e);return t&&n.get("eventDefinitions").some((function(e){return vr(e,t)}))}vf.$inject=["bpmnFactory","elementFactory","moddleCopy","modeling","replace","rules"];var bf={__depends__:[lf,ff,_a],bpmnReplace:["type",vf]};function _f(e){this._eventBus=e,this._tools=[],this._active=null}_f.$inject=["eventBus"],_f.prototype.registerTool=function(e,t){var n=this._tools;if(!t)throw new Error('A tool has to be registered with it\'s "events"');n.push(e),this.bindEvents(e,t)},_f.prototype.isActive=function(e){return e&&this._active===e},_f.prototype.length=function(e){return this._tools.length},_f.prototype.setActive=function(e){var t=this._eventBus;this._active!==e&&(this._active=e,t.fire("tool-manager.update",{tool:e}))},_f.prototype.bindEvents=function(e,t){var n=this._eventBus,i=[];n.on(t.tool+".init",(function(t){t.context.reactivate||!this.isActive(e)?this.setActive(e):this.setActive(null)}),this),g(t,(function(e){i.push(e+".ended"),i.push(e+".canceled")})),n.on(i,250,(function(e){this._active&&(function(e){var t=e.originalEvent&&e.originalEvent.target;return t&&J(t,'.group[data-group="tools"]')}(e)||this.setActive(null))}),this)};var xf={__depends__:[vp],__init__:["toolManager"],toolManager:["type",_f]};function wf(e,t){return-1!==e.indexOf(t)}var Ef=Math.abs,Sf=Math.round,Cf={x:"width",y:"height"},kf="crosshair",Rf={n:"top",w:"left",s:"bottom",e:"right"},Pf={n:"s",w:"e",s:"n",e:"w"};function Af(e,t,n,i,r,o,a){this._canvas=e,this._dragging=t,this._eventBus=n,this._modeling=i,this._rules=r,this._toolManager=o,this._mouse=a;var s=this;o.registerTool("space",{tool:"spaceTool.selection",dragging:"spaceTool"}),n.on("spaceTool.selection.end",(function(e){n.once("spaceTool.selection.ended",(function(){s.activateMakeSpace(e.originalEvent)}))})),n.on("spaceTool.move",1500,(function(e){var t=e.context,n=t.initialized;n||(n=t.initialized=s.init(e,t)),n&&Tf(e)})),n.on("spaceTool.end",(function(e){var t=e.context,i=t.axis,r=t.direction,o=t.movingShapes,a=t.resizingShapes,c=t.start;if(t.initialized){Tf(e);var p={x:0,y:0};p[i]=Sf(e["d"+i]),s.makeSpace(o,a,p,r,c),n.once("spaceTool.ended",(function(e){s.activateSelection(e.originalEvent,!0,!0)}))}}))}function Mf(e){return{top:e.top-20,right:e.right+20,bottom:e.bottom+20,left:e.left-20}}function Tf(e){var t,n,i=e.context.spaceToolConstraints;i&&(u(i.left)&&(t=Math.max(e.x,i.left),e.dx=e.dx+t-e.x,e.x=t),u(i.right)&&(t=Math.min(e.x,i.right),e.dx=e.dx+t-e.x,e.x=t),u(i.top)&&(n=Math.max(e.y,i.top),e.dy=e.dy+n-e.y,e.y=n),u(i.bottom)&&(n=Math.min(e.y,i.bottom),e.dy=e.dy+n-e.y,e.y=n))}function Df(e,t){return-1!==e.indexOf(t)}Af.$inject=["canvas","dragging","eventBus","modeling","rules","toolManager","mouse"],Af.prototype.activateSelection=function(e,t,n){this._dragging.init(e,"spaceTool.selection",{autoActivate:t,cursor:kf,data:{context:{reactivate:n}},trapClick:!1})},Af.prototype.activateMakeSpace=function(e){this._dragging.init(e,"spaceTool",{autoActivate:!0,cursor:kf,data:{context:{}}})},Af.prototype.makeSpace=function(e,t,n,i,r){return this._modeling.createSpace(e,t,n,i,r)},Af.prototype.init=function(e,t){var n=Ef(e.dx)>Ef(e.dy)?"x":"y",i=e["d"+n],r=e[n]-i;if(Ef(i)<5)return!1;i<0&&(i*=-1),ca(e)&&(i*=-1);var o=function(e,t){if("x"===e){if(t>0)return"e";if(t<0)return"w"}if("y"===e){if(t>0)return"s";if(t<0)return"n"}return null}(n,i),a=this._canvas.getRootElement();!pa(e)&&e.hover&&(a=e.hover);var s=[...ut(a,!0),...a.attachers||[]],c=this.calculateAdjustments(s,n,i,r),p=function(e,t,n,i,r){var o=e.movingShapes,a=e.resizingShapes;if(!a.length)return;var s,c,p={};return g(a,(function(e){var l,h,d,f,m,v,g=e.attachers,b=e.children,_=un(e),x=y(b,(function(e){return!(sn(e)||cn(e)||Df(o,e)||Df(a,e))})),w=y(b,(function(e){return!sn(e)&&!cn(e)&&Df(o,e)})),E=[],S=[];x.length&&(h=Mf(un(ht(x))),l=i-_[Rf[n]]+h[Rf[n]],"n"===n?p.bottom=c=u(c)?Math.min(c,l):l:"w"===n?p.right=c=u(c)?Math.min(c,l):l:"s"===n?p.top=s=u(s)?Math.max(s,l):l:"e"===n&&(p.left=s=u(s)?Math.max(s,l):l)),w.length&&(d=Mf(un(ht(w))),l=i-d[Rf[Pf[n]]]+_[Rf[Pf[n]]],"n"===n?p.bottom=c=u(c)?Math.min(c,l):l:"w"===n?p.right=c=u(c)?Math.min(c,l):l:"s"===n?p.top=s=u(s)?Math.max(s,l):l:"e"===n&&(p.left=s=u(s)?Math.max(s,l):l)),g&&g.length&&(g.forEach((function(e){Df(o,e)?E.push(e):S.push(e)})),E.length&&(f=un(ht(E.map(fn))),m=_[Rf[Pf[n]]]-(f[Rf[Pf[n]]]-i)),S.length&&(v=un(ht(S.map(fn)))[Rf[n]]-(_[Rf[n]]-i)),"n"===n?(l=Math.min(m||1/0,v||1/0),p.bottom=c=u(c)?Math.min(c,l):l):"w"===n?(l=Math.min(m||1/0,v||1/0),p.right=c=u(c)?Math.min(c,l):l):"s"===n?(l=Math.max(m||-1/0,v||-1/0),p.top=s=u(s)?Math.max(s,l):l):"e"===n&&(l=Math.max(m||-1/0,v||-1/0),p.left=s=u(s)?Math.max(s,l):l));var C=r&&r[e.id];C&&("n"===n?(l=i+e[Cf[t]]-C[Cf[t]],p.bottom=c=u(c)?Math.min(c,l):l):"w"===n?(l=i+e[Cf[t]]-C[Cf[t]],p.right=c=u(c)?Math.min(c,l):l):"s"===n?(l=i-e[Cf[t]]+C[Cf[t]],p.top=s=u(s)?Math.max(s,l):l):"e"===n&&(l=i-e[Cf[t]]+C[Cf[t]],p.left=s=u(s)?Math.max(s,l):l))})),p}(c,n,o,r,this._eventBus.fire("spaceTool.getMinDimensions",{axis:n,direction:o,shapes:c.resizingShapes,start:r}));return L(t,c,{axis:n,direction:o,spaceToolConstraints:p,start:r}),$a("resize-"+("x"===n?"ew":"ns")),!0},Af.prototype.calculateAdjustments=function(e,t,n,i){var r=this._rules,o=[],a=[],s=[],c=[];function p(e){o.includes(e)||o.push(e);var t=e.label;t&&!o.includes(t)&&o.push(t)}g(e,(function(e){if(e.parent&&!cn(e))if(sn(e))c.push(e);else{var o=e[t],l=o+e[Cf[t]];if(function(e){return!!e.host}(e)&&(n>0&&fn(e)[t]>i||n<0&&fn(e)[t]<i))s.push(e);else{var u;if(!(n>0&&o>i||n<0&&l<i))return o<i&&l>i&&r.allowed("shape.resize",{shape:e})?(u=e,void(a.includes(u)||a.push(u))):void 0;p(e)}}})),g(o,(function(e){var t=e.attachers;t&&g(t,(function(e){p(e)}))}));var l=o.concat(a);return g(s,(function(e){var t=e.host;Df(l,t)&&p(e)})),l=o.concat(a),g(c,(function(e){var t=e.source,n=e.target,i=e.label;Df(l,t)&&Df(l,n)&&i&&p(i)})),{movingShapes:o,resizingShapes:a}},Af.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},Af.prototype.isActive=function(){var e=this._dragging.context();return!!e&&/^spaceTool/.test(e.prefix)};var Bf="djs-dragging",Nf="djs-resizing",jf=Math.max;function Of(e,t,n,i,r){function o(e,t){g(e,(function(e){r.addDragger(e,t),n.addMarker(e,Bf)}))}e.on("spaceTool.selection.start",(function(e){var t=n.getLayer("space"),r=e.context,o="M 0,-10000 L 0,10000",a="M -10000,0 L 10000,0",s=Ae("g");_e(s,i.cls("djs-crosshair-group",["no-events"])),ye(t,s);var c=Ae("path");_e(c,"d",o),we(c).add("djs-crosshair"),ye(s,c);var p=Ae("path");_e(p,"d",a),we(p).add("djs-crosshair"),ye(s,p),r.crosshairGroup=s})),e.on("spaceTool.selection.move",(function(e){Wn(e.context.crosshairGroup,e.x,e.y)})),e.on("spaceTool.selection.cleanup",(function(e){var t=e.context.crosshairGroup;t&&Fe(t)})),e.on("spaceTool.move",250,(function(e){var a=e.context,s=a.line,c=a.axis,p=a.movingShapes,l=a.resizingShapes;if(a.initialized){if(!a.dragGroup){var u=n.getLayer("space");_e(s=Ae("path"),"d","M0,0 L0,0"),we(s).add("djs-crosshair"),ye(u,s),a.line=s;var h=Ae("g");_e(h,i.cls("djs-drag-group",["no-events"])),ye(n.getActiveLayer(),h),o(p,h),o(a.movingConnections=t.filter((function(e){var t=!1;g(p,(function(n){g(n.outgoing,(function(n){e===n&&(t=!0)}))}));var n=!1;g(p,(function(t){g(t.incoming,(function(t){e===t&&(n=!0)}))}));var i=!1;g(l,(function(t){g(t.outgoing,(function(t){e===t&&(i=!0)}))}));var r=!1;return g(l,(function(t){g(t.incoming,(function(t){e===t&&(r=!0)}))})),sn(e)&&(t||i)&&(n||r)})),h),a.dragGroup=h}if(!a.frameGroup){var d=Ae("g");_e(d,i.cls("djs-frame-group",["no-events"])),ye(n.getActiveLayer(),d);var f=[];g(l,(function(e){var t=r.addFrame(e,d),i=t.getBBox();f.push({element:t,initialBounds:i}),n.addMarker(e,Nf)})),a.frameGroup=d,a.frames=f}_e(s,{d:{x:"M"+e.x+", -10000 L"+e.x+", 10000",y:"M -10000, "+e.y+" L 10000, "+e.y}[c]});var m={x:e.dx,y:e.dy};m[{x:"y",y:"x"}[a.axis]]=0,Wn(a.dragGroup,m.x,m.y),g(a.frames,(function(e){var t,n,i=e.element,r=e.initialBounds;"e"===a.direction?_e(i,{width:jf(r.width+m.x,5)}):_e(i,{width:t=jf(r.width-m.x,5),x:r.x+r.width-t}),"s"===a.direction?_e(i,{height:jf(r.height+m.y,5)}):_e(i,{height:n=jf(r.height-m.y,5),y:r.y+r.height-n})}))}})),e.on("spaceTool.cleanup",(function(e){var t=e.context,i=t.movingShapes,r=t.movingConnections,o=t.resizingShapes,a=t.line,s=t.dragGroup,c=t.frameGroup;g(i,(function(e){n.removeMarker(e,Bf)})),g(r,(function(e){n.removeMarker(e,Bf)})),s&&(Fe(a),Fe(s)),g(o,(function(e){n.removeMarker(e,Nf)})),c&&Fe(c)}))}Of.$inject=["eventBus","elementRegistry","canvas","styles","previewSupport"];var Lf={__init__:["spaceToolPreview"],__depends__:[vp,xp,xf,Al,Jd],spaceTool:["type",Af],spaceToolPreview:["type",Of]};function $f(e,t){e.invoke(Af,this),this._canvas=t}$f.$inject=["injector","canvas"],e($f,Af),$f.prototype.calculateAdjustments=function(e,t,n,i){var r=this._canvas.getRootElement(),o=e[0]===r?null:e[0],a=[];o&&(a=C(dt(r.children.filter((e=>vr(e,"bpmn:Artifact"))),ht(o))));const s=[...e,...a];var c=Af.prototype.calculateAdjustments.call(this,s,t,n,i);return c.resizingShapes=c.resizingShapes.filter((function(e){return!vr(e,"bpmn:TextAnnotation")&&(!function(e){return vr(e,"bpmn:Participant")&&!gr(e).processRef}(e)||!("y"===t&&Lr(e)||"x"===t&&!Lr(e)))})),c};var If={__depends__:[Lf],spaceTool:["type",$f]};function Ff(e,t){this._handlerMap={},this._stack=[],this._stackIdx=-1,this._currentExecution={actions:[],dirty:[],trigger:null},this._injector=t,this._eventBus=e,this._uid=1,e.on(["diagram.destroy","diagram.clear"],(function(){this.clear(!1)}),this)}Ff.$inject=["eventBus","injector"],Ff.prototype.execute=function(e,t){if(!e)throw new Error("command required");this._currentExecution.trigger="execute";const n={command:e,context:t};this._pushAction(n),this._internalExecute(n),this._popAction()},Ff.prototype.canExecute=function(e,t){const n={command:e,context:t},i=this._getHandler(e);let r=this._fire(e,"canExecute",n);if(void 0===r){if(!i)return!1;i.canExecute&&(r=i.canExecute(t))}return r},Ff.prototype.clear=function(e){this._stack.length=0,this._stackIdx=-1,!1!==e&&this._fire("changed",{trigger:"clear"})},Ff.prototype.undo=function(){let e,t=this._getUndoAction();if(t){for(this._currentExecution.trigger="undo",this._pushAction(t);t&&(this._internalUndo(t),e=this._getUndoAction(),e&&e.id===t.id);)t=e;this._popAction()}},Ff.prototype.redo=function(){let e,t=this._getRedoAction();if(t){for(this._currentExecution.trigger="redo",this._pushAction(t);t&&(this._internalExecute(t,!0),e=this._getRedoAction(),e&&e.id===t.id);)t=e;this._popAction()}},Ff.prototype.register=function(e,t){this._setHandler(e,t)},Ff.prototype.registerHandler=function(e,t){if(!e||!t)throw new Error("command and handlerCls must be defined");const n=this._injector.instantiate(t);this.register(e,n)},Ff.prototype.canUndo=function(){return!!this._getUndoAction()},Ff.prototype.canRedo=function(){return!!this._getRedoAction()},Ff.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]},Ff.prototype._getUndoAction=function(){return this._stack[this._stackIdx]},Ff.prototype._internalUndo=function(e){const t=e.command,n=e.context,i=this._getHandler(t);this._atomicDo((()=>{this._fire(t,"revert",e),i.revert&&this._markDirty(i.revert(n)),this._revertedAction(e),this._fire(t,"reverted",e)}))},Ff.prototype._fire=function(e,t,n){arguments.length<3&&(n=t,t=null);const i=t?[e+"."+t,t]:[e];let r;n=this._eventBus.createEvent(n);for(const e of i)if(r=this._eventBus.fire("commandStack."+e,n),n.cancelBubble)break;return r},Ff.prototype._createId=function(){return this._uid++},Ff.prototype._atomicDo=function(e){const t=this._currentExecution;t.atomic=!0;try{e()}finally{t.atomic=!1}},Ff.prototype._internalExecute=function(e,t){const n=e.command,i=e.context,r=this._getHandler(n);if(!r)throw new Error("no command handler registered for <"+n+">");this._pushAction(e),t||(this._fire(n,"preExecute",e),r.preExecute&&r.preExecute(i),this._fire(n,"preExecuted",e)),this._atomicDo((()=>{this._fire(n,"execute",e),r.execute&&this._markDirty(r.execute(i)),this._executedAction(e,t),this._fire(n,"executed",e)})),t||(this._fire(n,"postExecute",e),r.postExecute&&r.postExecute(i),this._fire(n,"postExecuted",e)),this._popAction()},Ff.prototype._pushAction=function(e){const t=this._currentExecution,n=t.actions,i=n[0];if(t.atomic)throw new Error("illegal invocation in <execute> or <revert> phase (action: "+e.command+")");e.id||(e.id=i&&i.id||this._createId()),n.push(e)},Ff.prototype._popAction=function(){const e=this._currentExecution,t=e.trigger,n=e.actions,i=e.dirty;n.pop(),n.length||(this._eventBus.fire("elements.changed",{elements:R("id",i.reverse())}),i.length=0,this._fire("changed",{trigger:t}),e.trigger=null)},Ff.prototype._markDirty=function(e){const t=this._currentExecution;e&&(e=p(e)?e:[e],t.dirty=t.dirty.concat(e))},Ff.prototype._executedAction=function(e,t){const n=++this._stackIdx;t||this._stack.splice(n,this._stack.length,e)},Ff.prototype._revertedAction=function(e){this._stackIdx--},Ff.prototype._getHandler=function(e){return this._handlerMap[e]},Ff.prototype._setHandler=function(e,t){if(!e||!t)throw new Error("command and handler required");if(this._handlerMap[e])throw new Error("overriding handler for command <"+e+">");this._handlerMap[e]=t};var zf={commandStack:["type",Ff]};function Hf(e,t){if("function"!=typeof t)throw new Error("removeFn iterator must be a function");if(e){for(var n;n=e[0];)t(n);return e}}function Vf(e,t,n){Do.call(this,t);var i=e.get("movePreview",!1);t.on("shape.move.start",1400,(function(e){var t=e.context,n=t.shapes,i=t.validatedShapes;t.shapes=Gf(n),t.validatedShapes=Gf(i)})),i&&t.on("shape.move.start",250,(function(e){var t=e.context,n=t.shapes,r=[];g(n,(function(e){g(e.labels,(function(n){n.hidden||-1!==t.shapes.indexOf(n)||r.push(n),e.labelTarget&&r.push(e)}))})),g(r,(function(e){i.makeDraggable(t,e,!0)}))})),this.preExecuted("elements.move",1400,(function(e){var t=e.context.closure,n=t.enclosedElements,i=[];g(n,(function(e){g(e.labels,(function(e){n[e.id]||i.push(e)}))})),t.addAll(i)})),this.preExecute(["connection.delete","shape.delete"],(function(e){var t=e.context;Hf((t.connection||t.shape).labels,(function(e){n.removeShape(e,{nested:!0})}))})),this.execute("shape.delete",(function(e){var t=e.context,n=t.shape,i=n.labelTarget;i&&(t.labelTargetIndex=xt(i.labels,n),t.labelTarget=i,n.labelTarget=null)})),this.revert("shape.delete",(function(e){var t=e.context,n=t.shape,i=t.labelTarget,r=t.labelTargetIndex;i&&(_t(i.labels,n,r),n.labelTarget=i)}))}function Gf(e){return y(e,(function(t){return-1===e.indexOf(t.labelTarget)}))}e(Vf,Do),Vf.$inject=["injector","eventBus","modeling"];var Wf={__init__:["labelSupport"],labelSupport:["type",Vf]},Uf="attach-ok";function qf(e,t,n,i,r){Do.call(this,t);var o=e.get("movePreview",!1);t.on("shape.move.start",1401,(function(e){var t,n,i=e.context,r=i.shapes,o=i.validatedShapes;i.shapes=(n=Kf(t=r),P("id",t,n)),i.validatedShapes=function(e){var t=k(e,"id");return y(e,(function(e){for(;e;){if(e.host&&t[e.host.id])return!1;e=e.parent}return!0}))}(o)})),o&&t.on("shape.move.start",251,(function(e){var t=e.context;g(Kf(t.shapes),(function(e){o.makeDraggable(t,e,!0),g(e.labels,(function(e){o.makeDraggable(t,e,!0)}))}))})),o&&t.on("shape.move.start",(function(e){var i=e.context.shapes;if(1===i.length){var r=i[0].host;r&&(n.addMarker(r,Uf),t.once(["shape.move.out","shape.move.cleanup"],(function(){n.removeMarker(r,Uf)})))}})),this.preExecuted("elements.move",1401,(function(e){var t=e.context,n=t.closure;g(Kf(t.shapes),(function(e){n.add(e,n.topLevel[e.host.id])}))})),this.postExecuted("elements.move",(function(e){var t=e.context,n=t.shapes,i=t.newHost;i&&1!==n.length||g(i?n:y(n,(function(e){var t,i=e.host;return function(e){return!!e.host}(e)&&(t=i,!(-1!==n.indexOf(t)))})),(function(e){r.updateAttachment(e,i)}))})),this.postExecuted("elements.move",(function(e){g(e.context.shapes,(function(e){g(e.attachers,(function(e){g(e.outgoing.slice(),(function(e){i.allowed("connection.reconnect",{connection:e,source:e.source,target:e.target})||r.removeConnection(e)})),g(e.incoming.slice(),(function(e){i.allowed("connection.reconnect",{connection:e,source:e.source,target:e.target})||r.removeConnection(e)}))}))}))})),this.postExecute("shape.create",(function(e){var t=e.context,n=t.shape,i=t.host;i&&r.updateAttachment(n,i)})),this.postExecute("shape.replace",(function(e){var t=e.context,n=t.oldShape,o=t.newShape;Hf(n.attachers,(function(e){"attach"===i.allowed("elements.move",{target:o,shapes:[e]})?r.updateAttachment(e,o):r.removeShape(e)})),o.attachers.length&&g(o.attachers,(function(e){var t=Uu(e,n,o);r.moveShape(e,t,e.parent)}))})),this.postExecute("shape.resize",(function(e){var t=e.context,n=t.shape,i=t.oldBounds,o=t.newBounds,a=n.attachers;!1!==(t.hints||{}).attachSupport&&g(a,(function(e){var t=Uu(e,i,o);r.moveShape(e,t,e.parent),g(e.labels,(function(e){r.moveShape(e,t,e.parent)}))}))})),this.preExecute("shape.delete",(function(e){var t=e.context.shape;Hf(t.attachers,(function(e){r.removeShape(e)})),t.host&&r.updateAttachment(t,null)}))}function Kf(e){return i(E(e,(function(e){return e.attachers||[]})))}e(qf,Do),qf.$inject=["injector","eventBus","canvas","rules","modeling"];var Yf={__depends__:[xp],__init__:["attachSupport"],attachSupport:["type",qf]};function Xf(e){this._model=e}function Zf(e,t,n){Do.call(this,e),this._bpmnFactory=t;var i=this;function r(e){g(e.context.oldRoot.children,(function(e){vr(e,"bpmn:BaseElement")&&i.updateParent(e)}))}function o(e){var t=e.context.shape;vr(t,"bpmn:BaseElement")&&i.updateBounds(t)}function a(e){i.updateConnection(e.context)}function s(e){i.updateConnectionWaypoints(e.context.connection)}function c(e){i.updateAttachment(e.context)}function p(e){const{element:n}=e.context,i=Ur(n),r=br(n),o=r&&r.get("label");zr(n)||Vo(n)||(i&&!o?r.set("label",t.create("bpmndi:BPMNLabel")):!i&&o&&r.set("label",void 0))}this.executed(["connection.layout","connection.create"],(function(e){var t,i=e.context,r=i.hints||{};i.cropped||!1===r.createElementsBehavior||((t=i.connection).waypoints=n.getCroppedWaypoints(t),i.cropped=!0)})),this.reverted(["connection.layout"],(function(e){delete e.context.cropped})),this.executed(["shape.move","shape.create","shape.delete","connection.create","connection.move","connection.delete"],Qf((function(e){var t=e.context;i.updateParent(t.shape||t.connection,t.oldParent)}))),this.reverted(["shape.move","shape.create","shape.delete","connection.create","connection.move","connection.delete"],Qf((function(e){var t=e.context,n=t.shape||t.connection,r=t.parent||t.newParent;i.updateParent(n,r)}))),this.executed(["canvas.updateRoot"],r),this.reverted(["canvas.updateRoot"],r),this.executed(["shape.move","shape.create","shape.resize"],Qf((function(e){"label"!==e.context.shape.type&&o(e)}))),this.reverted(["shape.move","shape.create","shape.resize"],Qf((function(e){"label"!==e.context.shape.type&&o(e)}))),e.on("shape.changed",(function(e){"label"===e.element.type&&o({context:{shape:e.element}})})),this.executed(["connection.create","connection.move","connection.delete","connection.reconnect"],Qf(a)),this.reverted(["connection.create","connection.move","connection.delete","connection.reconnect"],Qf(a)),this.executed(["connection.layout","connection.move","connection.updateWaypoints"],Qf(s)),this.reverted(["connection.layout","connection.move","connection.updateWaypoints"],Qf(s)),this.executed("connection.reconnect",Qf((function(e){var t=e.context,n=t.connection,i=t.oldSource,r=t.newSource,o=gr(n),a=gr(i),s=gr(r);o.conditionExpression&&!yr(s,["bpmn:Activity","bpmn:ExclusiveGateway","bpmn:InclusiveGateway"])&&(t.oldConditionExpression=o.conditionExpression,delete o.conditionExpression),i!==r&&a.default===o&&(t.oldDefault=a.default,delete a.default)}))),this.reverted("connection.reconnect",Qf((function(e){var t=e.context,n=t.connection,i=t.oldSource,r=t.newSource,o=gr(n),a=gr(i),s=gr(r);t.oldConditionExpression&&(o.conditionExpression=t.oldConditionExpression),t.oldDefault&&(a.default=t.oldDefault,delete s.default)}))),this.executed(["element.updateAttachment"],Qf(c)),this.reverted(["element.updateAttachment"],Qf(c)),this.executed("element.updateLabel",Qf(p)),this.reverted("element.updateLabel",Qf(p))}function Qf(e){return function(t){var n=t.context;vr(n.shape||n.connection||n.element,"bpmn:BaseElement")&&e(t)}}function Jf(e,t){$n.call(this),this._bpmnFactory=e,this._moddle=t}function em(e,t,n){return void 0===t[n]?t:(e[n]=t[n],I(t,[n]))}function tm(e,t){this._modeling=e,this._canvas=t}function nm(e){this._modeling=e}function im(e,t){this._canvas=e,this._layouter=t}Xf.$inject=["moddle"],Xf.prototype._needsId=function(e){return yr(e,["bpmn:RootElement","bpmn:FlowElement","bpmn:MessageFlow","bpmn:DataAssociation","bpmn:Artifact","bpmn:Participant","bpmn:Lane","bpmn:LaneSet","bpmn:Process","bpmn:Collaboration","bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane","bpmn:Property","bpmn:CategoryValue"])},Xf.prototype._ensureId=function(e){var t;e.id?this._model.ids.claim(e.id,e):(t=vr(e,"bpmn:Activity")?"Activity":vr(e,"bpmn:Event")?"Event":vr(e,"bpmn:Gateway")?"Gateway":yr(e,["bpmn:SequenceFlow","bpmn:MessageFlow"])?"Flow":(e.$type||"").replace(/^[^:]*:/g,""),t+="_",!e.id&&this._needsId(e)&&(e.id=this._model.ids.nextPrefixed(t,e)))},Xf.prototype.create=function(e,t){var n=this._model.create(e,t||{});return this._ensureId(n),n},Xf.prototype.createDiLabel=function(){return this.create("bpmndi:BPMNLabel",{bounds:this.createDiBounds()})},Xf.prototype.createDiShape=function(e,t){return this.create("bpmndi:BPMNShape",L({bpmnElement:e,bounds:this.createDiBounds()},t))},Xf.prototype.createDiBounds=function(e){return this.create("dc:Bounds",e)},Xf.prototype.createDiWaypoints=function(e){var t=this;return E(e,(function(e){return t.createDiWaypoint(e)}))},Xf.prototype.createDiWaypoint=function(e){return this.create("dc:Point",$(e,["x","y"]))},Xf.prototype.createDiEdge=function(e,t){return this.create("bpmndi:BPMNEdge",L({bpmnElement:e,waypoint:this.createDiWaypoints([])},t))},Xf.prototype.createDiPlane=function(e,t){return this.create("bpmndi:BPMNPlane",L({bpmnElement:e},t))},e(Zf,Do),Zf.$inject=["eventBus","bpmnFactory","connectionDocking"],Zf.prototype.updateAttachment=function(e){var t=e.shape,n=t.businessObject,i=t.host;n.attachedToRef=i&&i.businessObject},Zf.prototype.updateParent=function(e,t){if(!(cn(e)||vr(e,"bpmn:DataStoreReference")&&e.parent&&vr(e.parent,"bpmn:Collaboration"))){var n=e.parent,i=e.businessObject,r=br(e),o=n&&n.businessObject,a=br(n);vr(e,"bpmn:FlowNode")&&this.updateFlowNodeRefs(i,o,t&&t.businessObject),vr(e,"bpmn:DataOutputAssociation")&&(o=e.source?e.source.businessObject:null),vr(e,"bpmn:DataInputAssociation")&&(o=e.target?e.target.businessObject:null),this.updateSemanticParent(i,o),vr(e,"bpmn:DataObjectReference")&&i.dataObjectRef&&this.updateSemanticParent(i.dataObjectRef,o),this.updateDiParent(r,a)}},Zf.prototype.updateBounds=function(e){var t=br(e),n=function(e){if(!vr(e,"bpmn:Activity"))return;var t=br(e);if(!t)return;var n=t.get("label");if(!n)return;return n.get("bounds")}(e);if(n){var i=Ha(n,t.get("bounds"));L(n,{x:e.x+i.x,y:e.y+i.y})}var r=cn(e)?this._getLabel(t):t,o=r.bounds;o||(o=this._bpmnFactory.createDiBounds(),r.set("bounds",o)),L(o,{x:e.x,y:e.y,width:e.width,height:e.height})},Zf.prototype.updateFlowNodeRefs=function(e,t,n){n!==t&&(vr(n,"bpmn:Lane")&&bt(n.get("flowNodeRef"),e),vr(t,"bpmn:Lane")&&_t(t.get("flowNodeRef"),e))},Zf.prototype.updateDiConnection=function(e,t,n){var i=br(e),r=br(t),o=br(n);i.sourceElement&&i.sourceElement.bpmnElement!==gr(t)&&(i.sourceElement=t&&r),i.targetElement&&i.targetElement.bpmnElement!==gr(n)&&(i.targetElement=n&&o)},Zf.prototype.updateDiParent=function(e,t){if(t&&!vr(t,"bpmndi:BPMNPlane")&&(t=t.$parent),e.$parent!==t){var n=(t||e.$parent).get("planeElement");t?(n.push(e),e.$parent=t):(bt(n,e),e.$parent=null)}},Zf.prototype.getLaneSet=function(e){var t,n;return vr(e,"bpmn:Lane")?((t=e.childLaneSet)||(t=this._bpmnFactory.create("bpmn:LaneSet"),e.childLaneSet=t,t.$parent=e),t):(vr(e,"bpmn:Participant")&&(e=e.processRef),(t=(n=e.get("laneSets"))[0])||((t=this._bpmnFactory.create("bpmn:LaneSet")).$parent=e,n.push(t)),t)},Zf.prototype.updateSemanticParent=function(e,t,n){var i;if(e.$parent!==t&&(!vr(e,"bpmn:DataInput")&&!vr(e,"bpmn:DataOutput")||(vr(t,"bpmn:Participant")&&"processRef"in t&&(t=t.processRef),!("ioSpecification"in t)||t.ioSpecification!==e.$parent))){if(vr(e,"bpmn:Lane"))t&&(t=this.getLaneSet(t)),i="lanes";else if(vr(e,"bpmn:FlowElement")){if(t)if(vr(t,"bpmn:Participant"))t=t.processRef;else if(vr(t,"bpmn:Lane"))do{t=t.$parent.$parent}while(vr(t,"bpmn:Lane"));i="flowElements"}else if(vr(e,"bpmn:Artifact")){for(;t&&!vr(t,"bpmn:Process")&&!vr(t,"bpmn:SubProcess")&&!vr(t,"bpmn:Collaboration");){if(vr(t,"bpmn:Participant")){t=t.processRef;break}t=t.$parent}i="artifacts"}else if(vr(e,"bpmn:MessageFlow"))i="messageFlows";else if(vr(e,"bpmn:Participant")){i="participants";var r,o=e.processRef;o&&(r=function(e){for(;e&&!vr(e,"bpmn:Definitions");)e=e.$parent;return e}(e.$parent||t),e.$parent&&(bt(r.get("rootElements"),o),o.$parent=null),t&&(_t(r.get("rootElements"),o),o.$parent=r))}else vr(e,"bpmn:DataOutputAssociation")?i="dataOutputAssociations":vr(e,"bpmn:DataInputAssociation")&&(i="dataInputAssociations");if(!i)throw new Error(`no parent for <${e.id}> in <${t.id}>`);var a;if(e.$parent&&bt(a=e.$parent.get(i),e),t?((a=t.get(i)).push(e),e.$parent=t):e.$parent=null,n){var s=n.get(i);bt(a,e),t&&(s||(s=[],t.set(i,s)),s.push(e))}}},Zf.prototype.updateConnectionWaypoints=function(e){br(e).set("waypoint",this._bpmnFactory.createDiWaypoints(e.waypoints))},Zf.prototype.updateConnection=function(e){var t,n=e.connection,i=gr(n),r=n.source,o=gr(r),a=n.target,s=gr(n.target);if(vr(i,"bpmn:DataAssociation"))vr(i,"bpmn:DataInputAssociation")?(i.get("sourceRef")[0]=o,t=e.parent||e.newParent||s,this.updateSemanticParent(i,s,t)):vr(i,"bpmn:DataOutputAssociation")&&(t=e.parent||e.newParent||o,this.updateSemanticParent(i,o,t),i.targetRef=s);else{var c=vr(i,"bpmn:SequenceFlow");i.sourceRef!==o&&(c&&(bt(i.sourceRef&&i.sourceRef.get("outgoing"),i),o&&o.get("outgoing")&&o.get("outgoing").push(i)),i.sourceRef=o),i.targetRef!==s&&(c&&(bt(i.targetRef&&i.targetRef.get("incoming"),i),s&&s.get("incoming")&&s.get("incoming").push(i)),i.targetRef=s)}this.updateConnectionWaypoints(n),this.updateDiConnection(n,r,a)},Zf.prototype._getLabel=function(e){return e.label||(e.label=this._bpmnFactory.createDiLabel()),e.label},e(Jf,$n),Jf.$inject=["bpmnFactory","moddle"],Jf.prototype._baseCreate=$n.prototype.create,Jf.prototype.create=function(e,t){if("label"===e){var n=t.di||this._bpmnFactory.createDiLabel();return this._baseCreate(e,L({type:"label",di:n},Fr,t))}return this.createElement(e,t)},Jf.prototype.createElement=function(e,t){var n,i,r,o=(t=L({},t||{})).businessObject,a=t.di;if(!o){if(!t.type)throw new Error("no shape type specified");dr(o=this._bpmnFactory.create(t.type))}if(!yr(a,["bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane"])){var c=L({},a||{},{id:o.id+"_di"});a="root"===e?this._bpmnFactory.createDiPlane(o,c):"connection"===e?this._bpmnFactory.createDiEdge(o,c):this._bpmnFactory.createDiShape(o,c)}return vr(o,"bpmn:Group")&&(t=L({isFrame:!0},t)),t=function(e,t,n){return g(n,(function(n){t=em(e,t,n)})),t}(o,t,["processRef","isInterrupting","associationDirection","isForCompensation"]),t.isExpanded&&(t=em(a,t,"isExpanded")),yr(o,["bpmn:Lane","bpmn:Participant"])&&(t=em(a,t,"isHorizontal")),vr(o,"bpmn:SubProcess")&&(t.collapsed=!Or(o,a)),vr(o,"bpmn:ExclusiveGateway")&&(f(a,"isMarkerVisible")?void 0===a.isMarkerVisible&&(a.isMarkerVisible=!1):a.isMarkerVisible=!0),s(t.triggeredByEvent)&&(o.triggeredByEvent=t.triggeredByEvent,delete t.triggeredByEvent),s(t.cancelActivity)&&(o.cancelActivity=t.cancelActivity,delete t.cancelActivity),t.eventDefinitionType&&(i=o.get("eventDefinitions")||[],r=this._bpmnFactory.create(t.eventDefinitionType,t.eventDefinitionAttrs),"bpmn:ConditionalEventDefinition"===t.eventDefinitionType&&(r.condition=this._bpmnFactory.create("bpmn:FormalExpression")),i.push(r),r.$parent=o,o.eventDefinitions=i,delete t.eventDefinitionType),n=this.getDefaultSize(o,a),t=L({id:o.id},n,t,{businessObject:o,di:a}),this._baseCreate(e,t)},Jf.prototype.getDefaultSize=function(e,t){var n=gr(e);if(t=t||br(e),vr(n,"bpmn:SubProcess"))return Or(n,t)?{width:350,height:200}:{width:100,height:80};if(vr(n,"bpmn:Task"))return{width:100,height:80};if(vr(n,"bpmn:Gateway"))return{width:50,height:50};if(vr(n,"bpmn:Event"))return{width:36,height:36};if(vr(n,"bpmn:Participant")){var i=void 0===t.isHorizontal||!0===t.isHorizontal;return Or(n,t)?i?{width:600,height:250}:{width:250,height:600}:i?{width:400,height:60}:{width:60,height:400}}return vr(n,"bpmn:Lane")?{width:400,height:100}:vr(n,"bpmn:DataObjectReference")?{width:36,height:50}:vr(n,"bpmn:DataStoreReference")?{width:50,height:50}:vr(n,"bpmn:TextAnnotation")?{width:100,height:30}:vr(n,"bpmn:Group")?{width:300,height:300}:{width:100,height:80}},Jf.prototype.createParticipantShape=function(e){return l(e)||(e={isExpanded:e}),!1!==(e=L({type:"bpmn:Participant"},e||{})).isExpanded&&(e.processRef=this._bpmnFactory.create("bpmn:Process")),this.createShape(e)},tm.$inject=["modeling","canvas"],tm.prototype.preExecute=function(e){var t=this._modeling,n=e.elements,i=e.alignment;g(n,(function(e){var n={x:0,y:0};s(i.left)?n.x=i.left-e.x:s(i.right)?n.x=i.right-e.width-e.x:s(i.center)?n.x=i.center-Math.round(e.width/2)-e.x:s(i.top)?n.y=i.top-e.y:s(i.bottom)?n.y=i.bottom-e.height-e.y:s(i.middle)&&(n.y=i.middle-Math.round(e.height/2)-e.y),t.moveElements([e],n,e.parent)}))},tm.prototype.postExecute=function(e){},nm.$inject=["modeling"],nm.prototype.preExecute=function(e){var t=e.source;if(!t)throw new Error("source required");var n=e.target||t.parent,i=e.shape,r=e.hints||{};i=e.shape=this._modeling.createShape(i,e.position,n,{attach:r.attach}),e.shape=i},nm.prototype.postExecute=function(e){var t,n,i=e.hints||{};t=e.source,n=e.shape,w(t.outgoing,(function(e){return e.target===n}))||(i.connectionTarget===e.source?this._modeling.connect(e.shape,e.source,e.connection):this._modeling.connect(e.source,e.shape,e.connection))},im.$inject=["canvas","layouter"],im.prototype.execute=function(e){var t=e.connection,n=e.source,i=e.target,r=e.parent,o=e.parentIndex,a=e.hints;if(!n||!i)throw new Error("source and target required");if(!r)throw new Error("parent required");return t.source=n,t.target=i,t.waypoints||(t.waypoints=this._layouter.layoutConnection(t,a)),this._canvas.addConnection(t,r,o),t},im.prototype.revert=function(e){var t=e.connection;return this._canvas.removeConnection(t),t.source=null,t.target=null,t};var rm=Math.round;function om(e){this._modeling=e}om.$inject=["modeling"],om.prototype.preExecute=function(e){var t=e.elements,n=e.parent,i=e.parentIndex,r=e.position,o=e.hints,a=this._modeling;g(t,(function(e){u(e.x)||(e.x=0),u(e.y)||(e.y=0)}));var s=ht(y(t,(function(e){return!e.hidden})));g(t,(function(e){sn(e)&&(e.waypoints=E(e.waypoints,(function(e){return{x:rm(e.x-s.x-s.width/2+r.x),y:rm(e.y-s.y-s.height/2+r.y)}}))),L(e,{x:rm(e.x-s.x-s.width/2+r.x),y:rm(e.y-s.y-s.height/2+r.y)})}));var c=st(t),p={};g(t,(function(e){if(sn(e))p[e.id]=u(i)?a.createConnection(p[e.source.id],p[e.target.id],i,e,e.parent||n,o):a.createConnection(p[e.source.id],p[e.target.id],e,e.parent||n,o);else{var t=L({},o);-1===c.indexOf(e)&&(t.autoResize=!1),cn(e)&&(t=I(t,["attach"])),p[e.id]=u(i)?a.createShape(e,$(e,["x","y","width","height"]),e.parent||n,i,t):a.createShape(e,$(e,["x","y","width","height"]),e.parent||n,t)}})),e.elements=C(p)};var am=Math.round;function sm(e){this._canvas=e}function cm(e){sm.call(this,e)}sm.$inject=["canvas"],sm.prototype.execute=function(e){var t=e.shape,n=e.position,i=e.parent,r=e.parentIndex;if(!i)throw new Error("parent required");if(!n)throw new Error("position required");return void 0!==n.width?L(t,n):L(t,{x:n.x-am(t.width/2),y:n.y-am(t.height/2)}),this._canvas.addShape(t,i,r),t},sm.prototype.revert=function(e){var t=e.shape;return this._canvas.removeShape(t),t},e(cm,sm),cm.$inject=["canvas"];var pm=sm.prototype.execute;cm.prototype.execute=function(e){var t=e.shape;return function(e){["width","height"].forEach((function(t){void 0===e[t]&&(e[t]=0)}))}(t),t.labelTarget=e.labelTarget,pm.call(this,e)};var lm=sm.prototype.revert;function um(e,t){this._canvas=e,this._modeling=t}function hm(e,t){this._modeling=e,this._elementRegistry=t}function dm(e,t){this._canvas=e,this._modeling=t}function fm(e){this._modeling=e}cm.prototype.revert=function(e){return e.shape.labelTarget=null,lm.call(this,e)},um.$inject=["canvas","modeling"],um.prototype.preExecute=function(e){var t=this._modeling,n=e.connection;Hf(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),Hf(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})}))},um.prototype.execute=function(e){var t=e.connection,n=t.parent;return e.parent=n,e.parentIndex=xt(n.children,t),e.source=t.source,e.target=t.target,this._canvas.removeConnection(t),t.source=null,t.target=null,t},um.prototype.revert=function(e){var t=e.connection,n=e.parent,i=e.parentIndex;return t.source=e.source,t.target=e.target,_t(n.children,t,i),this._canvas.addConnection(t,n),t},hm.$inject=["modeling","elementRegistry"],hm.prototype.postExecute=function(e){var t=this._modeling,n=this._elementRegistry;g(e.elements,(function(e){n.get(e.id)&&(e.waypoints?t.removeConnection(e):t.removeShape(e))}))},dm.$inject=["canvas","modeling"],dm.prototype.preExecute=function(e){var t=this._modeling,n=e.shape;Hf(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),Hf(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})})),Hf(n.children,(function(e){sn(e)?t.removeConnection(e,{nested:!0}):t.removeShape(e,{nested:!0})}))},dm.prototype.execute=function(e){var t=this._canvas,n=e.shape,i=n.parent;return e.oldParent=i,e.oldParentIndex=xt(i.children,n),t.removeShape(n),n},dm.prototype.revert=function(e){var t=this._canvas,n=e.shape,i=e.oldParent,r=e.oldParentIndex;return _t(i.children,n,r),t.addShape(n,i),n},fm.$inject=["modeling"];var mm={x:"y",y:"x"};function vm(e,t){this._layouter=e,this._canvas=t}function ym(){}function gm(){this.allShapes={},this.allConnections={},this.enclosedElements={},this.enclosedConnections={},this.topLevel={}}function bm(e){this._modeling=e}function _m(e){this._helper=new bm(e)}function xm(e){this._modeling=e,this._helper=new bm(e)}function wm(e){this._modeling=e}function Em(e){return e.original||e}function Sm(e,t){this._modeling=e,this._rules=t}function Cm(e){this._modeling=e}function km(e){this._modeling=e}function Rm(e){return L({},e)}function Pm(e){switch(e){case"n":case"s":return"y";case"w":case"e":return"x"}}function Am(e,t,n){var i=Pm(n);return/e|s/.test(n)?e[i]>t:/n|w/.test(n)?e[i]<t:void 0}function Mm(e,t){return-1!==e.indexOf(t)}function Tm(e){this._modeling=e}function Dm(e){var t={};return g(e,(function(e){t[e.id]=e.hidden,e.children&&(t=L({},t,Dm(e.children)))})),t}function Bm(e,t){var n=[];return g(e,(function(e){e.hidden=t,n=n.concat(e),e.children&&(n=n.concat(Bm(e.children,e.collapsed||t)))})),n}function Nm(e,t){var n=[];return g(e,(function(e){e.hidden=t[e.id],n=n.concat(e),e.children&&(n=n.concat(Nm(e.children,t)))})),n}function jm(e){this._modeling=e}function Om(e,t){return bt(e&&e.attachers,t)}function Lm(e,t,n){if(e){var i=e.attachers;i||(e.attachers=i=[]),_t(i,t,n)}}function $m(){}function Im(e,t,n){this._eventBus=e,this._elementFactory=t,this._commandStack=n;var i=this;e.on("diagram.init",(function(){i.registerHandlers(n)}))}function Fm(e){this._elementRegistry=e}function zm(e,t){g(t,(function(t,n){e.set(n,t)}))}fm.prototype.preExecute=function(e){var t=this._modeling,n=e.groups,i=e.axis,r=e.dimension;function o(e,t){e.range.min=Math.min(t[i],e.range.min),e.range.max=Math.max(t[i]+t[r],e.range.max)}function a(e){return e[i]+e[r]/2}function s(e){return e.length-1}function c(e){return e.max-e.min}var p,l,u=n[0],h=s(n),d=n[h],f=0;g(n,(function(e,p){var l,u,d;e.elements.length<2?p&&p!==n.length-1&&(o(e,e.elements[0]),f+=c(e.range)):(u=(l=A(e.elements,i))[0],p===h&&(u=l[s(l)]),d=a(u),e.range=null,g(l,(function(n){!function(e,n){var r={y:0};r[i]=e-a(n),r[i]&&(r[mm[i]]=0,t.moveElements([n],r,n.parent))}(d,n),null!==e.range?o(e,n):e.range={min:n[i],max:n[i]+n[r]}})),p&&p!==n.length-1&&(f+=c(e.range)))})),l=Math.abs(d.range.min-u.range.max),(p=Math.round((l-f)/(n.length-1)))<n.length-1||g(n,(function(e,o){var a,s={};e!==u&&e!==d&&(a=n[o-1],e.range.max=0,g(e.elements,(function(n,o){s[mm[i]]=0,s[i]=a.range.max-n[i]+p,e.range.min!==n[i]&&(s[i]+=n[i]-e.range.min),s[i]&&t.moveElements([n],s,n.parent),e.range.max=Math.max(n[i]+n[r],o?e.range.max:0)})))}))},fm.prototype.postExecute=function(e){},vm.$inject=["layouter","canvas"],vm.prototype.execute=function(e){var t=e.connection;return L(e,{oldWaypoints:t.waypoints}),t.waypoints=this._layouter.layoutConnection(t,e.hints),t},vm.prototype.revert=function(e){var t=e.connection;return t.waypoints=e.oldWaypoints,t},ym.prototype.execute=function(e){var t=e.connection,n=e.delta,i=e.newParent||t.parent,r=e.newParentIndex,o=t.parent;return e.oldParent=o,e.oldParentIndex=bt(o.children,t),_t(i.children,t,r),t.parent=i,g(t.waypoints,(function(e){e.x+=n.x,e.y+=n.y,e.original&&(e.original.x+=n.x,e.original.y+=n.y)})),t},ym.prototype.revert=function(e){var t=e.connection,n=t.parent,i=e.oldParent,r=e.oldParentIndex,o=e.delta;return bt(n.children,t),_t(i.children,t,r),t.parent=i,g(t.waypoints,(function(e){e.x-=o.x,e.y-=o.y,e.original&&(e.original.x-=o.x,e.original.y-=o.y)})),t},gm.prototype.add=function(e,t){return this.addAll([e],t)},gm.prototype.addAll=function(e,t){var n=function(e,t,n){a(t)&&(t=!0),l(t)&&(n=t,t=!0);var i=vt((n=n||{}).allShapes),r=vt(n.allConnections),o=vt(n.enclosedElements),s=vt(n.enclosedConnections),c=vt(n.topLevel,t&&k(e,(function(e){return e.id})));function p(e){c[e.source.id]&&c[e.target.id]&&(c[e.id]=[e]),i[e.source.id]&&i[e.target.id]&&(s[e.id]=o[e.id]=e),r[e.id]=e}return lt(e,(function(e){if(o[e.id]=e,!e.waypoints)return i[e.id]=e,g(e.incoming,p),g(e.outgoing,p),e.children;s[e.id]=r[e.id]=e})),{allShapes:i,allConnections:r,topLevel:c,enclosedConnections:s,enclosedElements:o}}(e,!!t,this);return L(this,n),this},bm.prototype.moveRecursive=function(e,t,n){return e?this.moveClosure(this.getClosure(e),t,n):[]},bm.prototype.moveClosure=function(e,t,n,i,r){var o=this._modeling,a=e.allShapes,s=e.allConnections,c=e.enclosedConnections,p=e.topLevel,l=!1;r&&r.parent===n&&(l=!0),g(a,(function(e){o.moveShape(e,t,p[e.id]&&!l&&n,{recurse:!1,layout:!1})})),g(s,(function(e){var i=!!a[e.source.id],r=!!a[e.target.id];c[e.id]&&i&&r?o.moveConnection(e,t,p[e.id]&&!l&&n):o.layoutConnection(e,{connectionStart:i&&eh(e,e.source,t),connectionEnd:r&&th(e,e.target,t)})}))},bm.prototype.getClosure=function(e){return(new gm).addAll(e,!0)},_m.$inject=["modeling"],_m.prototype.preExecute=function(e){e.closure=this._helper.getClosure(e.shapes)},_m.prototype.postExecute=function(e){var t,n=e.hints;n&&n.primaryShape&&(t=n.primaryShape,n.oldParent=t.parent),this._helper.moveClosure(e.closure,e.delta,e.newParent,e.newHost,t)},xm.$inject=["modeling"],xm.prototype.execute=function(e){var t=e.shape,n=e.delta,i=e.newParent||t.parent,r=e.newParentIndex,o=t.parent;return e.oldBounds=$(t,["x","y","width","height"]),e.oldParent=o,e.oldParentIndex=bt(o.children,t),_t(i.children,t,r),L(t,{parent:i,x:t.x+n.x,y:t.y+n.y}),t},xm.prototype.postExecute=function(e){var t=e.shape,n=e.delta,i=e.hints,r=this._modeling;!1!==i.layout&&(g(t.incoming,(function(e){r.layoutConnection(e,{connectionEnd:th(e,t,n)})})),g(t.outgoing,(function(e){r.layoutConnection(e,{connectionStart:eh(e,t,n)})}))),!1!==i.recurse&&this.moveChildren(e)},xm.prototype.revert=function(e){var t=e.shape,n=e.oldParent,i=e.oldParentIndex,r=e.delta;return _t(n.children,t,i),L(t,{parent:n,x:t.x-r.x,y:t.y-r.y}),t},xm.prototype.moveChildren=function(e){var t=e.delta,n=e.shape;this._helper.moveRecursive(n.children,t,null)},xm.prototype.getNewParent=function(e){return e.newParent||e.shape.parent},wm.$inject=["modeling"],wm.prototype.execute=function(e){var t=e.newSource,n=e.newTarget,i=e.connection,r=e.dockingOrPoints;if(!t&&!n)throw new Error("newSource or newTarget required");return p(r)&&(e.oldWaypoints=i.waypoints,i.waypoints=r),t&&(e.oldSource=i.source,i.source=t),n&&(e.oldTarget=i.target,i.target=n),i},wm.prototype.postExecute=function(e){var t=e.connection,n=e.newSource,i=e.newTarget,r=e.dockingOrPoints,o=e.hints||{},a={};o.connectionStart&&(a.connectionStart=o.connectionStart),o.connectionEnd&&(a.connectionEnd=o.connectionEnd),!1!==o.layoutConnection&&(!n||i&&"source"!==o.docking||(a.connectionStart=a.connectionStart||Em(p(r)?r[0]:r)),!i||n&&"target"!==o.docking||(a.connectionEnd=a.connectionEnd||Em(p(r)?r[r.length-1]:r)),o.newWaypoints&&(a.waypoints=o.newWaypoints),this._modeling.layoutConnection(t,a))},wm.prototype.revert=function(e){var t=e.oldSource,n=e.oldTarget,i=e.oldWaypoints,r=e.connection;return t&&(r.source=t),n&&(r.target=n),i&&(r.waypoints=i),r},Sm.$inject=["modeling","rules"],Sm.prototype.preExecute=function(e){var t,n=this,i=this._modeling,r=this._rules,o=e.oldShape,a=e.newData,s=e.hints||{};function c(e,t,n){return r.allowed("connection.reconnect",{connection:n,source:e,target:t})}var p,l={x:a.x,y:a.y},u={x:o.x,y:o.y,width:o.width,height:o.height};t=e.newShape=e.newShape||n.createShape(a,l,o.parent,s),o.host&&i.updateAttachment(t,o.host),!1!==s.moveChildren&&(p=o.children.slice(),i.moveElements(p,{x:0,y:0},t,s));var h=o.incoming.slice(),d=o.outgoing.slice();g(h,(function(e){c(e.source,t,e)&&n.reconnectEnd(e,t,Ju(e,t,u),s)})),g(d,(function(e){var i=e.target;c(t,i,e)&&n.reconnectStart(e,t,Qu(e,t,u),s)}))},Sm.prototype.postExecute=function(e){var t=e.oldShape;this._modeling.removeShape(t)},Sm.prototype.execute=function(e){},Sm.prototype.revert=function(e){},Sm.prototype.createShape=function(e,t,n,i){return this._modeling.createShape(e,t,n,i)},Sm.prototype.reconnectStart=function(e,t,n,i){this._modeling.reconnectStart(e,t,n,i)},Sm.prototype.reconnectEnd=function(e,t,n,i){this._modeling.reconnectEnd(e,t,n,i)},Cm.$inject=["modeling"],Cm.prototype.execute=function(e){var t=e.shape,n=e.newBounds,i=e.minBounds;if(void 0===n.x||void 0===n.y||void 0===n.width||void 0===n.height)throw new Error("newBounds must have {x, y, width, height} properties");if(i&&(n.width<i.width||n.height<i.height))throw new Error("width and height cannot be less than minimum height and width");if(!i&&n.width<10||n.height<10)throw new Error("width and height cannot be less than 10px");return e.oldBounds={width:t.width,height:t.height,x:t.x,y:t.y},L(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Cm.prototype.postExecute=function(e){var t=this._modeling,n=e.shape,i=e.oldBounds;!1!==(e.hints||{}).layout&&(g(n.incoming,(function(e){t.layoutConnection(e,{connectionEnd:Ju(e,n,i)})})),g(n.outgoing,(function(e){t.layoutConnection(e,{connectionStart:Qu(e,n,i)})})))},Cm.prototype.revert=function(e){var t=e.shape,n=e.oldBounds;return L(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},km.$inject=["modeling"],km.prototype.preExecute=function(e){var t=e.delta,n=e.direction,i=e.movingShapes,r=e.resizingShapes,o=e.start,a={};this.moveShapes(i,t),g(r,(function(e){a[e.id]=function(e){return{x:e.x,y:e.y,height:e.height,width:e.width}}(e)})),this.resizeShapes(r,t,n),this.updateConnectionWaypoints(function(e,t){var n=[];return g(e.concat(t),(function(i){var r=i.incoming,o=i.outgoing;g(r.concat(o),(function(i){var r=i.source,o=i.target;(wf(e,r)||wf(e,o)||wf(t,r)||wf(t,o))&&(wf(n,i)||n.push(i))}))})),n}(i,r),t,n,o,i,r,a)},km.prototype.execute=function(){},km.prototype.revert=function(){},km.prototype.moveShapes=function(e,t){var n=this;g(e,(function(e){n._modeling.moveShape(e,t,null,{autoResize:!1,layout:!1,recurse:!1})}))},km.prototype.resizeShapes=function(e,t,n){var i=this;g(e,(function(e){var r=function(e,t,n){var i=e.x,r=e.y,o=e.width,a=e.height,s=n.x,c=n.y;switch(t){case"n":return{x:i,y:r+c,width:o,height:a-c};case"s":return{x:i,y:r,width:o,height:a+c};case"w":return{x:i+s,y:r,width:o-s,height:a};case"e":return{x:i,y:r,width:o+s,height:a};default:throw new Error("unknown direction: "+t)}}(e,n,t);i._modeling.resizeShape(e,r,null,{attachSupport:!1,autoResize:!1,layout:!1})}))},km.prototype.updateConnectionWaypoints=function(e,t,n,i,r,o,a){var s=this,c=r.concat(o);g(e,(function(e){var p=e.source,l=e.target,u=function(e){return E(e.waypoints,(function(e){return(e=Rm(e)).original&&(e.original=Rm(e.original)),e}))}(e),h=Pm(n),d={};Mm(c,p)&&Mm(c,l)?(u=E(u,(function(e){return Am(e,i,n)&&(e[h]=e[h]+t[h]),e.original&&Am(e.original,i,n)&&(e.original[h]=e.original[h]+t[h]),e})),s._modeling.updateWaypoints(e,u,{labelBehavior:!1})):(Mm(c,p)||Mm(c,l))&&(Mm(r,p)?d.connectionStart=eh(e,p,t):Mm(r,l)?d.connectionEnd=th(e,l,t):Mm(o,p)?d.connectionStart=Qu(e,p,a[p.id]):Mm(o,l)&&(d.connectionEnd=Ju(e,l,a[l.id])),s._modeling.layoutConnection(e,d))}))},Tm.$inject=["modeling"],Tm.prototype.execute=function(e){var t=e.shape,n=t.children;e.oldChildrenVisibility=Dm(n),t.collapsed=!t.collapsed;var i=Bm(n,t.collapsed);return[t].concat(i)},Tm.prototype.revert=function(e){var t=e.shape,n=e.oldChildrenVisibility,i=Nm(t.children,n);return t.collapsed=!t.collapsed,[t].concat(i)},jm.$inject=["modeling"],jm.prototype.execute=function(e){var t=e.shape,n=e.newHost,i=t.host;return e.oldHost=i,e.attacherIdx=Om(i,t),Lm(n,t),t.host=n,t},jm.prototype.revert=function(e){var t=e.shape,n=e.newHost,i=e.oldHost,r=e.attacherIdx;return t.host=i,Om(n,t),Lm(i,t,r),t},$m.prototype.execute=function(e){var t=e.connection,n=e.newWaypoints;return e.oldWaypoints=t.waypoints,t.waypoints=n,t},$m.prototype.revert=function(e){var t=e.connection,n=e.oldWaypoints;return t.waypoints=n,t},Im.$inject=["eventBus","elementFactory","commandStack"],Im.prototype.getHandlers=function(){return{"shape.append":nm,"shape.create":sm,"shape.delete":dm,"shape.move":xm,"shape.resize":Cm,"shape.replace":Sm,"shape.toggleCollapse":Tm,spaceTool:km,"label.create":cm,"connection.create":im,"connection.delete":um,"connection.move":ym,"connection.layout":vm,"connection.updateWaypoints":$m,"connection.reconnect":wm,"elements.create":om,"elements.move":_m,"elements.delete":hm,"elements.distribute":fm,"elements.align":tm,"element.updateAttachment":jm}},Im.prototype.registerHandlers=function(e){g(this.getHandlers(),(function(t,n){e.registerHandler(n,t)}))},Im.prototype.moveShape=function(e,t,n,i,r){"object"==typeof i&&(r=i,i=null);var o={shape:e,delta:t,newParent:n,newParentIndex:i,hints:r||{}};this._commandStack.execute("shape.move",o)},Im.prototype.updateAttachment=function(e,t){var n={shape:e,newHost:t};this._commandStack.execute("element.updateAttachment",n)},Im.prototype.moveElements=function(e,t,n,i){var r,o=(i=i||{}).attach,a=n;!0===o?(r=n,a=n.parent):!1===o&&(r=null);var s={shapes:e,delta:t,newParent:a,newHost:r,hints:i};this._commandStack.execute("elements.move",s)},Im.prototype.moveConnection=function(e,t,n,i,r){"object"==typeof i&&(r=i,i=void 0);var o={connection:e,delta:t,newParent:n,newParentIndex:i,hints:r||{}};this._commandStack.execute("connection.move",o)},Im.prototype.layoutConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.layout",n)},Im.prototype.createConnection=function(e,t,n,i,r,o){"object"==typeof n&&(o=r,r=i,i=n,n=void 0);var a={source:e,target:t,parent:r,parentIndex:n,connection:i=this._create("connection",i),hints:o};return this._commandStack.execute("connection.create",a),a.connection},Im.prototype.createShape=function(e,t,n,i,r){"number"!=typeof i&&(r=i,i=void 0);var o,a,s=(r=r||{}).attach;e=this._create("shape",e),s?(o=n.parent,a=n):o=n;var c={position:t,shape:e,parent:o,parentIndex:i,host:a,hints:r};return this._commandStack.execute("shape.create",c),c.shape},Im.prototype.createElements=function(e,t,n,i,r){p(e)||(e=[e]),"number"!=typeof i&&(r=i,i=void 0);var o={position:t,elements:e,parent:n,parentIndex:i,hints:r=r||{}};return this._commandStack.execute("elements.create",o),o.elements},Im.prototype.createLabel=function(e,t,n,i){n=this._create("label",n);var r={labelTarget:e,position:t,parent:i||e.parent,shape:n};return this._commandStack.execute("label.create",r),r.shape},Im.prototype.appendShape=function(e,t,n,i,r){r=r||{};var o={source:e,position:n,target:i,shape:t=this._create("shape",t),connection:r.connection,connectionParent:r.connectionParent,hints:r};return this._commandStack.execute("shape.append",o),o.shape},Im.prototype.removeElements=function(e){var t={elements:e};this._commandStack.execute("elements.delete",t)},Im.prototype.distributeElements=function(e,t,n){var i={groups:e,axis:t,dimension:n};this._commandStack.execute("elements.distribute",i)},Im.prototype.removeShape=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.delete",n)},Im.prototype.removeConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.delete",n)},Im.prototype.replaceShape=function(e,t,n){var i={oldShape:e,newData:t,hints:n||{}};return this._commandStack.execute("shape.replace",i),i.newShape},Im.prototype.alignElements=function(e,t){var n={elements:e,alignment:t};this._commandStack.execute("elements.align",n)},Im.prototype.resizeShape=function(e,t,n,i){var r={shape:e,newBounds:t,minBounds:n,hints:i};this._commandStack.execute("shape.resize",r)},Im.prototype.createSpace=function(e,t,n,i,r){var o={delta:n,direction:i,movingShapes:e,resizingShapes:t,start:r};this._commandStack.execute("spaceTool",o)},Im.prototype.updateWaypoints=function(e,t,n){var i={connection:e,newWaypoints:t,hints:n||{}};this._commandStack.execute("connection.updateWaypoints",i)},Im.prototype.reconnect=function(e,t,n,i,r){var o={connection:e,newSource:t,newTarget:n,dockingOrPoints:i,hints:r||{}};this._commandStack.execute("connection.reconnect",o)},Im.prototype.reconnectStart=function(e,t,n,i){i||(i={}),this.reconnect(e,t,e.target,n,L(i,{docking:"source"}))},Im.prototype.reconnectEnd=function(e,t,n,i){i||(i={}),this.reconnect(e,e.source,t,n,L(i,{docking:"target"}))},Im.prototype.connect=function(e,t,n,i){return this.createConnection(e,t,n||{},e.parent,i)},Im.prototype._create=function(e,t){return t instanceof Dn?t:this._elementFactory.create(e,t)},Im.prototype.toggleCollapse=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.toggleCollapse",n)},Fm.$inject=["elementRegistry"],Fm.prototype.execute=function(e){var t=e.element,n=e.moddleElement,i=e.properties;if(!n)throw new Error("<moddleElement> required");var r=e.changed||this._getVisualReferences(n).concat(t),o=e.oldProperties||function(e,t){return _(t,(function(t,n){return t[n]=e.get(n),t}),{})}(n,S(i));return zm(n,i),e.oldProperties=o,e.changed=r,r},Fm.prototype.revert=function(e){var t=e.oldProperties,n=e.moddleElement,i=e.changed;return zm(n,t),i},Fm.prototype._getVisualReferences=function(e){var t=this._elementRegistry;return vr(e,"bpmn:DataObject")?function(e,t){return t.filter((function(t){return vr(t,"bpmn:DataObjectReference")&&gr(t).dataObjectRef===e}))}(e,t):[]};var Hm="default",Vm="id",Gm="di",Wm={width:0,height:0};function Um(e,t,n,i){this._elementRegistry=e,this._moddle=t,this._modeling=n,this._textRenderer=i}function qm(e,t){return Vm in e&&e[Vm]!==t[Vm]}function Km(e,t){var n=e.businessObject,i=br(e);g(t,(function(e,t){t!==Gm?n.set(t,e):i&&function(e,t){g(t,(function(t,n){e.set(n,t)}))}(i,e)}))}Um.$inject=["elementRegistry","moddle","modeling","textRenderer"],Um.prototype.execute=function(e){var t=e.element,n=[t];if(!t)throw new Error("element required");var i=this._elementRegistry,r=this._moddle.ids,o=t.businessObject,a=function(e){var t=L({},e);return Ym.forEach((function(n){n in e&&(t[n]=gr(t[n]))})),t}(e.properties),s=e.oldProperties||function(e,t){var n=S(t),i=e.businessObject,r=br(e);return _(n,(function(e,n){return e[n]=n!==Gm?i.get(n):function(e,t){return _(t,(function(t,n){return t[n]=e&&e.get(n),t}),{})}(r,S(t.di)),e}),{})}(t,a);return qm(a,o)&&(r.unclaim(o[Vm]),i.updateId(t,a[Vm]),r.claim(a[Vm],o)),Hm in a&&(a[Hm]&&n.push(i.get(a[Hm].id)),o[Hm]&&n.push(i.get(o[Hm].id))),Km(t,a),e.oldProperties=s,e.changed=n,n},Um.prototype.postExecute=function(e){var t=e.element.label,n=t&&gr(t).name;if(n){var i=this._textRenderer.getExternalLabelBounds(t,n);this._modeling.resizeShape(t,i,Wm)}},Um.prototype.revert=function(e){var t=e.element,n=e.properties,i=e.oldProperties,r=t.businessObject,o=this._elementRegistry,a=this._moddle.ids;return Km(t,i),qm(n,r)&&(a.unclaim(n[Vm]),o.updateId(t,i[Vm]),a.claim(i[Vm],r)),e.changed};var Ym=["default"];function Xm(e,t){this._canvas=e,this._modeling=t}function Zm(e,t){this._modeling=e,this._spaceTool=t}function Qm(e){this._modeling=e}function Jm(e,t){this._modeling=e,this._spaceTool=t}Xm.$inject=["canvas","modeling"],Xm.prototype.execute=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,r=t.getRootElement(),o=r.businessObject,a=o.$parent,s=br(r);return t.setRootElement(n),t.removeRootElement(r),_t(a.rootElements,i),i.$parent=a,bt(a.rootElements,o),o.$parent=null,r.di=null,s.bpmnElement=i,n.di=s,e.oldRoot=r,[]},Xm.prototype.revert=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,r=e.oldRoot,o=r.businessObject,a=i.$parent,s=br(n);return t.setRootElement(r),t.removeRootElement(n),bt(a.rootElements,i),i.$parent=null,_t(a.rootElements,o),o.$parent=a,n.di=null,s.bpmnElement=o,r.di=s,[]},Zm.$inject=["modeling","spaceTool"],Zm.prototype.preExecute=function(e){var t=this._spaceTool,n=this._modeling,i=e.shape,r=e.location,o=mu(i),a=o===i,s=a?i:i.parent,c=fu(s),p=Lr(i);if(p?"left"===r?r="top":"right"===r&&(r="bottom"):"top"===r?r="left":"bottom"===r&&(r="right"),!c.length){var l=p?{x:i.x+hu,y:i.y,width:i.width-hu,height:i.height}:{x:i.x,y:i.y+hu,width:i.width,height:i.height-hu};n.createShape({type:"bpmn:Lane",isHorizontal:p},l,s)}var u,h,d,f,m,v=[];lt(o,(function(e){return v.push(e),e.label&&v.push(e.label),e===i?[]:y(e.children,(function(e){return e!==i}))})),"top"===r?(u=-120,d=(h=i.y)+10,f="n",m="y"):"left"===r?(u=-120,d=(h=i.x)+10,f="w",m="x"):"bottom"===r?(u=120,d=(h=i.y+i.height)-10,f="s",m="y"):"right"===r&&(u=120,d=(h=i.x+i.width)-10,f="e",m="x");var g=t.calculateAdjustments(v,m,u,d),b=p?{x:0,y:u}:{x:u,y:0};t.makeSpace(g.movingShapes,g.resizingShapes,b,f,d);var _=p?{x:i.x+(a?hu:0),y:h-("top"===r?120:0),width:i.width-(a?hu:0),height:120}:{x:h-("left"===r?120:0),y:i.y+(a?hu:0),width:120,height:i.height-(a?hu:0)};e.newLane=n.createShape({type:"bpmn:Lane",isHorizontal:p},_,s)},Qm.$inject=["modeling"],Qm.prototype.preExecute=function(e){var t=this._modeling,n=e.shape,i=e.count,r=fu(n),o=r.length;if(o>i)throw new Error(`more than <${i}> child lanes`);var a,s,c,p,l=Lr(n),u=l?n.height:n.width,h=Math.round(u/i);for(p=0;p<i;p++)a=p===i-1?u-h*p:h,s=l?{x:n.x+hu,y:n.y+p*h,width:n.width-hu,height:a}:{x:n.x+p*h,y:n.y+hu,width:a,height:n.height-hu},p<o?t.resizeShape(r[p],s):(c={type:"bpmn:Lane",isHorizontal:l},t.createShape(c,s,n))},Jm.$inject=["modeling","spaceTool"],Jm.prototype.preExecute=function(e){var t=e.shape,n=e.newBounds;!1!==e.balanced?this.resizeBalanced(t,n):this.resizeSpace(t,n)},Jm.prototype.resizeBalanced=function(e,t){var n=this._modeling,i=vu(e,t);n.resizeShape(e,t),i.forEach((function(e){n.resizeShape(e.shape,e.newBounds)}))},Jm.prototype.resizeSpace=function(e,t){var n,i,r,o,a,s=this._spaceTool,c=un(e),p=ou(un(t),c),l=mu(e),u=[],h=[];lt(l,(function(e){return u.push(e),(vr(e,"bpmn:Lane")||vr(e,"bpmn:Participant"))&&h.push(e),e.children})),(p.bottom||p.top)&&(n=p.bottom||p.top,i=e.y+(p.bottom?e.height:0)+(p.bottom?-10:10),r=p.bottom?"s":"n",o=p.top>0||p.bottom<0?-n:n,a=s.calculateAdjustments(u,"y",o,i),s.makeSpace(a.movingShapes,a.resizingShapes,{x:0,y:n},r)),(p.left||p.right)&&(n=p.right||p.left,i=e.x+(p.right?e.width:0)+(p.right?-10:100),r=p.right?"e":"w",o=p.left>0||p.right<0?-n:n,a=s.calculateAdjustments(h,"x",o,i),s.makeSpace(a.movingShapes,a.resizingShapes,{x:n,y:0},r))};var ev="flowNodeRef",tv="lanes";function nv(e){this._elementRegistry=e}function iv(e){this._moddle=e}nv.$inject=["elementRegistry"],nv.prototype._computeUpdates=function(e,t){var n=[],i=[],r={},o=[];function a(e){-1===n.indexOf(e)&&(o.push(e),n.push(e))}function s(e){if(!e.parent)return[];var t=function(e){var t=mu(e);return r[t.id]||(r[t.id]=du(t)),r[t.id]}(e);return t.filter((function(t){return n=e,i=un(t),r=n.x+n.width/2,o=n.y+n.height/2,r>i.left&&r<i.right&&o>i.top&&o<i.bottom;var n,i,r,o})).map((function(e){return e.businessObject}))}return t.forEach((function(e){var t=mu(e);if(t&&-1===n.indexOf(t)){var i=t.children.filter((function(e){return vr(e,"bpmn:FlowNode")}));i.forEach(a),n.push(t)}})),e.forEach(a),o.forEach((function(e){var t=e.businessObject,n=t.get(tv).slice(),r=s(e);i.push({flowNode:t,remove:n,add:r})})),t.forEach((function(e){var t=e.businessObject;e.parent||t.get(ev).forEach((function(e){i.push({flowNode:e,remove:[t],add:[]})}))})),i},nv.prototype.execute=function(e){var t=e.updates;return t||(t=e.updates=this._computeUpdates(e.flowNodeShapes,e.laneShapes)),t.forEach((function(e){var t=e.flowNode,n=t.get(tv);e.remove.forEach((function(e){bt(n,e),bt(e.get(ev),t)})),e.add.forEach((function(e){_t(n,e),_t(e.get(ev),t)}))})),[]},nv.prototype.revert=function(e){return e.updates.forEach((function(e){var t=e.flowNode,n=t.get(tv);e.add.forEach((function(e){bt(n,e),bt(e.get(ev),t)})),e.remove.forEach((function(e){_t(n,e),_t(e.get(ev),t)}))})),[]},iv.$inject=["moddle"],iv.prototype.execute=function(e){var t=this._moddle.ids,n=e.id,i=e.element;return e.claiming?t.claim(n,i):t.unclaim(n),[]},iv.prototype.revert=function(e){var t=this._moddle.ids,n=e.id,i=e.element;return e.claiming?t.unclaim(n):t.claim(n,i),[]};var rv={fill:void 0,stroke:void 0};function ov(e){this._commandStack=e,this._normalizeColor=function(e){if(e){if(d(e)){var t=function(e){var t=document.createElement("canvas").getContext("2d");return t.fillStyle="transparent",t.fillStyle=e,/^#[0-9a-fA-F]{6}$/.test(t.fillStyle)?t.fillStyle:null}(e);if(t)return t}throw new Error(`invalid color value: ${e}`)}}}ov.$inject=["commandStack"],ov.prototype.postExecute=function(e){var t=e.elements,n=e.colors||rv,i=this,r={};"fill"in n&&L(r,{"background-color":this._normalizeColor(n.fill)}),"stroke"in n&&L(r,{"border-color":this._normalizeColor(n.stroke)}),g(t,(function(e){var t=sn(e)?$(r,["border-color"]):r,n=br(e);if(function(e){"border-color"in e&&(e.stroke=e["border-color"]);"background-color"in e&&(e.fill=e["background-color"])}(t),cn(e))i._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:n.label,properties:{color:r["border-color"]}});else{if(!yr(n,["bpmndi:BPMNEdge","bpmndi:BPMNShape"]))return;i._commandStack.execute("element.updateProperties",{element:e,properties:{di:t}})}}))};var av={width:0,height:0};function sv(e,t,n){function i(e,t){var n=e.label||e,i=e.labelTarget||e;return function(e,t){var n=e.businessObject,i=Wr(n);if(i)if("categoryValueRef"===i){if(!n[i])return e;n[i].value=t}else n[i]=t}(n,t),[n,i]}this.preExecute=function(t){var n=t.element,i=n.businessObject,r=t.newLabel;if(!cn(n)&&zr(n)&&!Hr(n)&&!cv(r)){var o=Gr(n);o={x:o.x,y:o.y+7},e.createLabel(n,o,{id:i.id+"_label",businessObject:i,di:n.di})}},this.execute=function(e){return e.oldLabel=Ur(e.element),i(e.element,e.newLabel)},this.revert=function(e){return i(e.element,e.oldLabel)},this.postExecute=function(n){var i=n.element,r=i.label||i,o=n.newLabel,a=n.newBounds,s=n.hints||{};if(cn(r)||vr(r,"bpmn:TextAnnotation"))if(cn(r)&&cv(o))!1!==s.removeShape&&e.removeShape(r,{unsetLabel:!1});else{var c=Ur(i);void 0===a&&(a=t.getExternalLabelBounds(r,c)),a&&e.resizeShape(r,a,av)}}}function cv(e){return!e||!e.trim()}function pv(e,t,n,i){Im.call(this,e,t,n),this._bpmnRules=i}function lv(){}sv.$inject=["modeling","textRenderer","bpmnFactory"],e(pv,Im),pv.$inject=["eventBus","elementFactory","commandStack","bpmnRules"],pv.prototype.getHandlers=function(){var e=Im.prototype.getHandlers.call(this);return e["element.updateModdleProperties"]=Fm,e["element.updateProperties"]=Um,e["canvas.updateRoot"]=Xm,e["lane.add"]=Zm,e["lane.resize"]=Jm,e["lane.split"]=Qm,e["lane.updateRefs"]=nv,e["id.updateClaim"]=iv,e["element.setColor"]=ov,e["element.updateLabel"]=sv,e},pv.prototype.updateLabel=function(e,t,n,i){this._commandStack.execute("element.updateLabel",{element:e,newLabel:t,newBounds:n,hints:i||{}})},pv.prototype.connect=function(e,t,n,i){var r=this._bpmnRules;if(n||(n=r.canConnect(e,t)),n)return this.createConnection(e,t,n,e.parent,i)},pv.prototype.updateModdleProperties=function(e,t,n){this._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:t,properties:n})},pv.prototype.updateProperties=function(e,t){this._commandStack.execute("element.updateProperties",{element:e,properties:t})},pv.prototype.resizeLane=function(e,t,n){this._commandStack.execute("lane.resize",{shape:e,newBounds:t,balanced:n})},pv.prototype.addLane=function(e,t){var n={shape:e,location:t};return this._commandStack.execute("lane.add",n),n.newLane},pv.prototype.splitLane=function(e,t){this._commandStack.execute("lane.split",{shape:e,count:t})},pv.prototype.makeCollaboration=function(){var e=this._create("root",{type:"bpmn:Collaboration"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},pv.prototype.makeProcess=function(){var e=this._create("root",{type:"bpmn:Process"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},pv.prototype.updateLaneRefs=function(e,t){this._commandStack.execute("lane.updateRefs",{flowNodeShapes:e,laneShapes:t})},pv.prototype.claimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t,claiming:!0})},pv.prototype.unclaimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t})},pv.prototype.setColor=function(e,t){e.length||(e=[e]),this._commandStack.execute("element.setColor",{elements:e,colors:t})},lv.prototype.layoutConnection=function(e,t){return[(t=t||{}).connectionStart||fn(t.source||e.source),t.connectionEnd||fn(t.target||e.target)]};var uv=Math.round,hv={"h:h":20,"v:v":20,"h:v":-10,"v:h":-10};function dv(e,t,n){var i,r,o,a=mn(t,e,5),s=n.split(":")[0],c=uv((t.x-e.x)/2+e.x),p=uv((t.y-e.y)/2+e.y),l=(o=a,{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/left|right/,v:/top|bottom/}[s].test(o)),u=/h|r|l/.test(s),h=!1,d=!1;return l?(i=u?{x:c,y:e.y}:{x:e.x,y:p},r=u?"h:h":"v:v"):(h=function(e,t){return!{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/./,v:/./}[t].test(e)}(a,s),r=u?"h:v":"v:h",h?u?(d=p===e.y,i={x:e.x+20*(/l/.test(s)?-1:1),y:d?p+20:p}):i={x:(d=c===e.x)?c+20:c,y:e.y+20*(/t/.test(s)?-1:1)}:i={x:c,y:p}),{waypoints:mv(e,i,r).concat(i),directions:r,turnNextDirections:d}}function fv(e){return e.split(":").reverse().join(":")}function mv(e,t,n){if(!function(e){return e&&/^h|v|t|r|b|l:h|v|t|r|b|l$/.test(e)}(n=n||"h:h"))throw new Error("unknown directions: <"+n+">: must be specified as <start>:<end> with start/end in { h,v,t,r,b,l }");if(_v(n)){var i=function(e,t,n){return dv(e,t,n)}(e,t,n),r=function(e,t,n){var i=dv(t,e,fv(n));return{waypoints:i.waypoints.slice().reverse(),directions:fv(i.directions),turnNextDirections:i.turnNextDirections}}(e,t,n),o=function(e,t){var n=e.directions.split(":")[1],i=t.directions.split(":")[0];e.turnNextDirections&&(n="h"==n?"v":"h"),t.turnNextDirections&&(i="h"==i?"v":"h");var r=n+":"+i;return{waypoints:mv(e.waypoints[e.waypoints.length-1],t.waypoints[0],r),directions:r}}(i,r);return[].concat(i.waypoints,o.waypoints,r.waypoints)}return function(e,t,n){var i=uv((t.x-e.x)/2+e.x),r=uv((t.y-e.y)/2+e.y);if("h:v"===n)return[{x:t.x,y:e.y}];if("v:h"===n)return[{x:e.x,y:t.y}];if("h:h"===n)return[{x:i,y:e.y},{x:i,y:t.y}];if("v:v"===n)return[{x:e.x,y:r},{x:t.x,y:r}];throw new Error("invalid directions: can only handle varians of [hv]:[hv]")}(e,t,n)}function vv(e,t,n,i,r){var o=b(r&&r.preferredLayouts||[],"straight")[0]||"h:h",a=mn(e,t,hv[o]||0),s=function(e,t){if(_v(t))return t;switch(e){case"intersect":return"t:t";case"top":case"bottom":return"v:v";case"left":case"right":return"h:h";default:return t}}(a,o);n=n||fn(e),i=i||fn(t);var c=s.split(":"),p=xv(n,e,c[0],function(e){return{top:"bottom",bottom:"top",left:"right",right:"left","top-left":"bottom-right","bottom-right":"top-left","top-right":"bottom-left","bottom-left":"top-right"}[e]}(a));return function(e,t,n){var i=mv(e,t,n);return i.unshift(e),i.push(t),wv(i)}(p,xv(i,t,c[1],a),s)}function yv(e,t,n,i,r,o){var a;return p(n)&&(r=n,o=i,n=fn(e),i=fn(t)),r=r||[],a=-1!==(o=L({preferredLayouts:[]},o)).preferredLayouts.indexOf("straight")&&function(e,t,n,i,r){var o,a,s={};if(a=mn(e,t),!/^(top|bottom|left|right)$/.test(a))return null;/top|bottom/.test(a)&&(o="x");/left|right/.test(a)&&(o="y");return"target"===r.preserveDocking?gv(o,i,e)?(s[o]=i[o],[{x:void 0!==s.x?s.x:n.x,y:void 0!==s.y?s.y:n.y,original:{x:void 0!==s.x?s.x:n.x,y:void 0!==s.y?s.y:n.y}},{x:i.x,y:i.y}]):null:gv(o,n,t)?(s[o]=n[o],[{x:n.x,y:n.y},{x:void 0!==s.x?s.x:i.x,y:void 0!==s.y?s.y:i.y,original:{x:void 0!==s.x?s.x:i.x,y:void 0!==s.y?s.y:i.y}}]):null}(e,t,n,i,o),a||(a=o.connectionEnd&&function(e,t,n,i){var r=i.slice().reverse();return r=bv(e,t,n,r),r?r.reverse():null}(t,e,i,r),a||((a=o.connectionStart&&bv(e,t,n,r))||(!o.connectionStart&&!o.connectionEnd&&r&&r.length?r:vv(e,t,n,i,o))))}function gv(e,t,n){return function(e,t,n){return e>=t&&e<=n}(t[e],n[e],n[e]+n[{x:"width",y:"height"}[e]])}function bv(e,t,n,i){if(function(e){return e.length<3||!(e.length>4)&&!!m(e,(function(t,n){var i=e[n-1];return i&&wt(t,i)<3}))}(i))return null;var r,o=i[0],a=i.slice();return a[0]=n,a[1]=function(e,t,n){switch(St(t,e)){case"v":return{x:n.x,y:e.y};case"h":return{x:e.x,y:n.y}}return{x:e.x,y:e.y}}(a[1],o,n),r=function(e,t,n){var i;for(i=e.length-2;0!==i;i--)if(kt(e[i],t,20)||kt(e[i],n,20))return e.slice(i);return e}(a,e,t),r!==a&&(a=bv(e,t,n,r)),a&&St(a)?null:a}function _v(e){return e&&/t|r|b|l/.test(e)}function xv(e,t,n,i){if("h"===n&&(n=/left/.test(i)?"l":"r"),"v"===n&&(n=/top/.test(i)?"t":"b"),"t"===n)return{original:e,x:e.x,y:t.y};if("r"===n)return{original:e,x:t.x+t.width,y:e.y};if("b"===n)return{original:e,x:e.x,y:t.y+t.height};if("l"===n)return{original:e,x:t.x,y:e.y};throw new Error("unexpected dockingDirection: <"+n+">")}function wv(e){return e.reduce((function(t,n,i){return Et(t[t.length-1],e[i+1],n,0)||t.push(n),t}),[])}var Ev={default:["h:h"],fromGateway:["v:h"],toGateway:["h:v"],loop:{fromTop:["t:r"],fromRight:["r:b"],fromLeft:["l:t"],fromBottom:["b:l"]},boundaryLoop:{alternateHorizontalSide:"b",alternateVerticalSide:"l",default:"v"},messageFlow:["straight","v:v"],subProcess:["straight","h:h"],isHorizontal:!0},Sv={default:["v:v"],fromGateway:["h:v"],toGateway:["v:h"],loop:{fromTop:["t:l"],fromRight:["r:t"],fromLeft:["l:b"],fromBottom:["b:r"]},boundaryLoop:{alternateHorizontalSide:"t",alternateVerticalSide:"r",default:"h"},messageFlow:["straight","h:h"],subProcess:["straight","v:v"],isHorizontal:!1},Cv={top:"bottom","top-right":"bottom-left","top-left":"bottom-right",right:"left",bottom:"top","bottom-right":"top-left","bottom-left":"top-right",left:"right"},kv={top:"t",right:"r",bottom:"b",left:"l"};function Rv(e){this._elementRegistry=e}function Pv(e,t){return vr(t,"bpmn:Participant")?"source":vr(e,"bpmn:Participant")?"target":Dv(t)?"source":Dv(e)||vr(t,"bpmn:Event")?"target":vr(e,"bpmn:Event")?"source":null}function Av(e){return Dv(e)?"target":"source"}function Mv(e,t){return e?e.original||e:fn(t)}function Tv(e,t){return vr(t,"bpmn:Activity")&&vr(e,"bpmn:BoundaryEvent")&&t.businessObject.isForCompensation}function Dv(e){return vr(e,"bpmn:SubProcess")&&Or(e)}function Bv(e,t){return e===t}function Nv(e){var t=/right|left/.exec(e);return t&&t[0]}function jv(e){var t=/top|bottom/.exec(e);return t&&t[0]}function Ov(e,t){return Cv[e]===t}function Lv(e){return"right"===e||"left"===e}function $v(e,t,n){var i=t.waypoints,r=i&&i.length&&mn(i[0],e);return"top"===r?n.loop.fromTop:"right"===r?n.loop.fromRight:"left"===r?n.loop.fromLeft:n.loop.fromBottom}function Iv(e,t,n,i){var r,o,a,s,c=fn(e),p=fn(t),l=(s=(a=e).host,mn(fn(a),s,-10)),u=Bv(e.host,t),h=-1!==["top","right","bottom","left"].indexOf(l),d=mn(p,c,{x:e.width/2+t.width/2,y:e.height/2+t.height/2});return u?function(e,t,n,i,r,o){var a,s=t?e:o.isHorizontal?jv(e):Nv(e),c=kv[s];a=t?Lv(e)?Fv("y",n,i,r)?"h":o.boundaryLoop.alternateHorizontalSide:Fv("x",n,i,r)?"v":o.boundaryLoop.alternateVerticalSide:o.boundaryLoop.default;return[c+":"+a]}(l,h,e,t,n,i):(r=function(e,t,n,i){if(n)return kv[e];var r=jv(e),o=Nv(e),a=jv(t),s=Nv(t);if(i){if(Bv(r,a)||Ov(o,s))return kv[r]}else if(Bv(o,s)||Ov(r,a))return kv[o];return kv[i?o:r]}(l,d,h,i.isHorizontal),o=function(e,t,n,i){if(n)return Lv(e)?function(e,t){var n=Nv(e),i=Cv[n];return-1!==t.indexOf(i)}(e,t)||Bv(e,t)?"h":"v":function(e,t){var n=jv(e),i=Cv[n];return-1!==t.indexOf(i)}(e,t)||Bv(e,t)?"v":"h";return i?Bv(jv(e),jv(t))?"h":"v":Bv(Nv(e),Nv(t))?"v":"h"}(l,d,h,i.isHorizontal),[r+":"+o])}function Fv(e,t,n,i){return!(zv(e,i,n,40)||zv(e,i,{x:n.x+n.width,y:n.y+n.height},40)||zv(e,i,fn(t),40))}function zv(e,t,n,i){return Math.abs(t[e]-n[e])<i}function Hv(e){return L({original:e.point.original||e.point},e.actual)}function Vv(e,t){this._elementRegistry=e,this._graphicsFactory=t}e(Rv,lv),Rv.prototype.layoutConnection=function(e,t){t||(t={});var n,i,r=t.source||e.source,o=t.target||e.target,a=t.waypoints||e.waypoints,s=t.connectionStart,c=t.connectionEnd,p=this._elementRegistry;if(s||(s=Mv(a&&a[0],r)),c||(c=Mv(a&&a[a.length-1],o)),(vr(e,"bpmn:Association")||vr(e,"bpmn:DataAssociation"))&&a&&!Tv(r,o))return[].concat([s],a.slice(1,-1),[c]);var l=ep(r,p)?Ev:Sv;return vr(e,"bpmn:MessageFlow")?n=function(e,t,n){return{preferredLayouts:n.messageFlow,preserveDocking:Pv(e,t)}}(r,o,l):(vr(e,"bpmn:SequenceFlow")||Tv(r,o))&&(n=r===o?{preferredLayouts:$v(r,e,l)}:vr(r,"bpmn:BoundaryEvent")?{preferredLayouts:Iv(r,o,c,l)}:Dv(r)||Dv(o)?{preferredLayouts:l.subProcess,preserveDocking:Av(r)}:vr(r,"bpmn:Gateway")?{preferredLayouts:l.fromGateway}:vr(o,"bpmn:Gateway")?{preferredLayouts:l.toGateway}:{preferredLayouts:l.default}),n&&(i=wv(yv(r,o,s,c,a,n=L(n,t)))),i||[s,c]},Rv.$inject=["elementRegistry"],Vv.$inject=["elementRegistry","graphicsFactory"],Vv.prototype.getCroppedWaypoints=function(e,t,n){t=t||e.source,n=n||e.target;var i=this.getDockingPoint(e,t,!0),r=this.getDockingPoint(e,n),o=e.waypoints.slice(i.idx+1,r.idx);return o.unshift(Hv(i)),o.push(Hv(r)),o},Vv.prototype.getDockingPoint=function(e,t,n){var i,r,o=e.waypoints;return{point:r=o[i=n?0:o.length-1],actual:this._getIntersection(t,e,n)||r,idx:i}},Vv.prototype._getIntersection=function(e,t,n){return vn(this._getShapePath(e),this._getConnectionPath(t),n)},Vv.prototype._getConnectionPath=function(e){return this._graphicsFactory.getConnectionPath(e)},Vv.prototype._getShapePath=function(e){return this._graphicsFactory.getShapePath(e)},Vv.prototype._getGfx=function(e){return this._elementRegistry.getGraphics(e)};var Gv={__init__:["modeling","bpmnUpdater"],__depends__:[ed,Nd,Od,Id,bf,zf,Wf,Yf,_a,To,If],bpmnFactory:["type",Xf],bpmnUpdater:["type",Zf],elementFactory:["type",Jf],modeling:["type",pv],layouter:["type",Rv],connectionDocking:["type",Vv]};const Wv=Math.round;function Uv(e,t,n,i,r,o){this._complexPreview=e,this._connectionDocking=t,this._elementFactory=n,this._eventBus=i,this._layouter=r,this._rules=o}Uv.prototype.create=function(e,t,n){const i=this._complexPreview,r=this._connectionDocking,o=this._elementFactory,a=this._eventBus,s=this._layouter,p=this._rules,l=o.createShape(L({type:t},n)),u=a.fire("autoPlace",{source:e,shape:l});if(!u)return;L(l,{x:u.x-Wv(l.width/2),y:u.y-Wv(l.height/2)});const h=p.allowed("connection.create",{source:e,target:l,hints:{targetParent:e.parent}});let d=null;h&&(d=o.createConnection(h),d.waypoints=s.layoutConnection(d,{source:e,target:l}),d.waypoints=r.getCroppedWaypoints(d,e,l)),i.create({created:[l,d].filter((e=>!c(e)))})},Uv.prototype.cleanUp=function(){this._complexPreview.cleanUp()},Uv.$inject=["complexPreview","connectionDocking","elementFactory","eventBus","layouter","rules"];var qv={__depends__:[rp,Dl,Gv],__init__:["appendPreview"],appendPreview:["type",Uv]},Kv=Math.min,Yv=Math.max;function Xv(e){e.preventDefault()}function Zv(e){e.stopPropagation()}function Qv(e){this.container=e.container,this.parent=he('<div class="djs-direct-editing-parent"><div class="djs-direct-editing-content" contenteditable="true"></div></div>'),this.content=fe("[contenteditable]",this.parent),this.keyHandler=e.keyHandler||function(){},this.resizeHandler=e.resizeHandler||function(){},this.autoResize=O(this.autoResize,this),this.handlePaste=O(this.handlePaste,this)}function Jv(e,t){this._eventBus=e,this._canvas=t,this._providers=[],this._textbox=new Qv({container:t.getContainer(),keyHandler:O(this._handleKey,this),resizeHandler:O(this._handleResize,this)})}Qv.prototype.create=function(e,t,n,i){var r=this.parent,o=this.content,a=this.container;i=this.options=i||{};var s=$(t=this.style=t||{},["width","height","maxWidth","maxHeight","minWidth","minHeight","left","top","backgroundColor","position","overflow","border","wordWrap","textAlign","outline","transform"]);L(r.style,{width:e.width+"px",height:e.height+"px",maxWidth:e.maxWidth+"px",maxHeight:e.maxHeight+"px",minWidth:e.minWidth+"px",minHeight:e.minHeight+"px",left:e.x+"px",top:e.y+"px",backgroundColor:"#ffffff",position:"absolute",overflow:"visible",border:"1px solid #ccc",boxSizing:"border-box",wordWrap:"normal",textAlign:"center",outline:"none"},s);var c=$(t,["fontFamily","fontSize","fontWeight","lineHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft"]);return L(o.style,{boxSizing:"border-box",width:"100%",outline:"none",wordWrap:"break-word"},c),i.centerVertically&&L(o.style,{position:"absolute",top:"50%",transform:"translate(0, -50%)"},c),o.innerText=n,oe.bind(o,"keydown",this.keyHandler),oe.bind(o,"mousedown",Zv),oe.bind(o,"paste",this.handlePaste),i.autoResize&&oe.bind(o,"input",this.autoResize),i.resizable&&this.resizable(t),a.appendChild(r),this.setSelection(o.lastChild,o.lastChild&&o.lastChild.length),r},Qv.prototype.handlePaste=function(e){var t,n=this.options,i=this.style;if(e.preventDefault(),t=e.clipboardData?e.clipboardData.getData("text/plain"):window.clipboardData.getData("Text"),this.insertText(t),n.autoResize){var r=this.autoResize(i);r&&this.resizeHandler(r)}},Qv.prototype.insertText=function(e){e=e.replace(/\r\n|\r|\n/g,"\n"),document.execCommand("insertText",!1,e)||this._insertTextIE(e)},Qv.prototype._insertTextIE=function(e){var t,n,i,r=this.getSelection(),o=r.startContainer,a=r.endContainer,s=r.startOffset,c=r.endOffset,p=r.commonAncestorContainer,l=(t=p.childNodes,[].slice.call(t));if(function(e){return e.nodeType===Node.TEXT_NODE}(p)){var u=o.textContent;o.textContent=u.substring(0,s)+e+u.substring(c),n=o,i=s+e.length}else if(o===this.content&&a===this.content){var h=document.createTextNode(e);this.content.insertBefore(h,l[s]),n=h,i=h.textContent.length}else{var d=l.indexOf(o),f=l.indexOf(a);l.forEach((function(t,n){n===d?t.textContent=o.textContent.substring(0,s)+e+a.textContent.substring(c):n>d&&n<=f&&ve(t)})),n=o,i=s+e.length}n&&void 0!==i&&setTimeout((function(){self.setSelection(n,i)}))},Qv.prototype.autoResize=function(){var e=this.parent,t=this.content,n=parseInt(this.style.fontSize)||12;if(t.scrollHeight>e.offsetHeight||t.scrollHeight<e.offsetHeight-n){var i=e.getBoundingClientRect(),r=t.scrollHeight;e.style.height=r+"px",this.resizeHandler({width:i.width,height:i.height,dx:0,dy:r-i.height})}},Qv.prototype.resizable=function(){var e=this,t=this.parent,n=this.resizeHandle,i=parseInt(this.style.minWidth)||0,r=parseInt(this.style.minHeight)||0,o=parseInt(this.style.maxWidth)||1/0,a=parseInt(this.style.maxHeight)||1/0;if(!n){var s,c,p,l;n=this.resizeHandle=he('<div class="djs-direct-editing-resize-handle"></div>');var u=function(n){Xv(n),Zv(n);var u=Kv(Yv(p+n.clientX-s,i),o),h=Kv(Yv(l+n.clientY-c,r),a);t.style.width=u+"px",t.style.height=h+"px",e.resizeHandler({width:p,height:l,dx:n.clientX-s,dy:n.clientY-c})},h=function(e){Xv(e),Zv(e),oe.unbind(document,"mousemove",u,!1),oe.unbind(document,"mouseup",h,!1)};oe.bind(n,"mousedown",(function(e){Xv(e),Zv(e),s=e.clientX,c=e.clientY;var n=t.getBoundingClientRect();p=n.width,l=n.height,oe.bind(document,"mousemove",u),oe.bind(document,"mouseup",h)}))}L(n.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"}),t.appendChild(n)},Qv.prototype.destroy=function(){var e=this.parent,t=this.content,n=this.resizeHandle;t.innerText="",e.removeAttribute("style"),t.removeAttribute("style"),oe.unbind(t,"keydown",this.keyHandler),oe.unbind(t,"mousedown",Zv),oe.unbind(t,"input",this.autoResize),oe.unbind(t,"paste",this.handlePaste),n&&(n.removeAttribute("style"),ve(n)),ve(e)},Qv.prototype.getValue=function(){return this.content.innerText.trim()},Qv.prototype.getSelection=function(){return window.getSelection().getRangeAt(0)},Qv.prototype.setSelection=function(e,t){var n=document.createRange();null===e?n.selectNodeContents(this.content):(n.setStart(e,t),n.setEnd(e,t));var i=window.getSelection();i.removeAllRanges(),i.addRange(n)},Jv.$inject=["eventBus","canvas"],Jv.prototype.registerProvider=function(e){this._providers.push(e)},Jv.prototype.isActive=function(e){return!(!this._active||e&&this._active.element!==e)},Jv.prototype.cancel=function(){this._active&&(this._fire("cancel"),this.close())},Jv.prototype._fire=function(e,t){this._eventBus.fire("directEditing."+e,t||{active:this._active})},Jv.prototype.close=function(){this._textbox.destroy(),this._fire("deactivate"),this._active=null,this.resizable=void 0,this._canvas.restoreFocus&&this._canvas.restoreFocus()},Jv.prototype.complete=function(){var e=this._active;if(e){var t,n=e.context.bounds,i=this.$textbox.getBoundingClientRect(),r=this.getValue();r===e.context.text&&i.height===n.height&&i.width===n.width||(t=this._textbox.container.getBoundingClientRect(),e.provider.update(e.element,r,e.context.text,{x:i.left-t.left,y:i.top-t.top,width:i.width,height:i.height})),this._fire("complete"),this.close()}},Jv.prototype.getValue=function(){return this._textbox.getValue()},Jv.prototype._handleKey=function(e){e.stopPropagation();var t=e.keyCode||e.charCode;return 27===t?(e.preventDefault(),this.cancel()):13!==t||e.shiftKey?void 0:(e.preventDefault(),this.complete())},Jv.prototype._handleResize=function(e){this._fire("resize",e)},Jv.prototype.activate=function(e){var t;this.isActive()&&this.cancel();var n=m(this._providers,(function(n){return(t=n.activate(e))?n:null}));return t&&(this.$textbox=this._textbox.create(t.bounds,t.style,t.text,t.options),this._active={element:e,context:t,provider:n},t.options&&t.options.resizable&&(this.resizable=!0),this._fire("activate")),!!t};var ey={__depends__:[da],__init__:["directEditing"],directEditing:["type",Jv]};var ty=[{label:"Start event",actionName:"replace-with-none-start",className:"bpmn-icon-start-event-none",target:{type:"bpmn:StartEvent"}},{label:"Intermediate throw event",actionName:"replace-with-none-intermediate-throwing",className:"bpmn-icon-intermediate-event-none",target:{type:"bpmn:IntermediateThrowEvent"}},{label:"End event",actionName:"replace-with-none-end",className:"bpmn-icon-end-event-none",target:{type:"bpmn:EndEvent"}},{label:"Message start event",actionName:"replace-with-message-start",className:"bpmn-icon-start-event-message",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Timer start event",actionName:"replace-with-timer-start",className:"bpmn-icon-start-event-timer",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:TimerEventDefinition"}},{label:"Conditional start event",actionName:"replace-with-conditional-start",className:"bpmn-icon-start-event-condition",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition"}},{label:"Signal start event",actionName:"replace-with-signal-start",className:"bpmn-icon-start-event-signal",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}}],ny=[{label:"Start event",actionName:"replace-with-none-start",className:"bpmn-icon-start-event-none",target:{type:"bpmn:StartEvent"}},{label:"Intermediate throw event",actionName:"replace-with-none-intermediate-throwing",className:"bpmn-icon-intermediate-event-none",target:{type:"bpmn:IntermediateThrowEvent"}},{label:"End event",actionName:"replace-with-none-end",className:"bpmn-icon-end-event-none",target:{type:"bpmn:EndEvent"}}],iy=[{label:"Start event",actionName:"replace-with-none-start",className:"bpmn-icon-start-event-none",target:{type:"bpmn:StartEvent"}},{label:"Intermediate throw event",actionName:"replace-with-none-intermediate-throw",className:"bpmn-icon-intermediate-event-none",target:{type:"bpmn:IntermediateThrowEvent"}},{label:"End event",actionName:"replace-with-none-end",className:"bpmn-icon-end-event-none",target:{type:"bpmn:EndEvent"}},{label:"Message intermediate catch event",actionName:"replace-with-message-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-message",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Message intermediate throw event",actionName:"replace-with-message-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-message",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Timer intermediate catch event",actionName:"replace-with-timer-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-timer",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:TimerEventDefinition"}},{label:"Escalation intermediate throw event",actionName:"replace-with-escalation-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-escalation",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}},{label:"Conditional intermediate catch event",actionName:"replace-with-conditional-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-condition",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition"}},{label:"Link intermediate catch event",actionName:"replace-with-link-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-link",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:LinkEventDefinition",eventDefinitionAttrs:{name:""}}},{label:"Link intermediate throw event",actionName:"replace-with-link-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-link",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:LinkEventDefinition",eventDefinitionAttrs:{name:""}}},{label:"Compensation intermediate throw event",actionName:"replace-with-compensation-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-compensation",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}},{label:"Signal intermediate catch event",actionName:"replace-with-signal-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-signal",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},{label:"Signal intermediate throw event",actionName:"replace-with-signal-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-signal",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}}],ry=[{label:"Start event",actionName:"replace-with-none-start",className:"bpmn-icon-start-event-none",target:{type:"bpmn:StartEvent"}},{label:"Intermediate throw event",actionName:"replace-with-none-intermediate-throw",className:"bpmn-icon-intermediate-event-none",target:{type:"bpmn:IntermediateThrowEvent"}},{label:"End event",actionName:"replace-with-none-end",className:"bpmn-icon-end-event-none",target:{type:"bpmn:EndEvent"}},{label:"Message end event",actionName:"replace-with-message-end",className:"bpmn-icon-end-event-message",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Escalation end event",actionName:"replace-with-escalation-end",className:"bpmn-icon-end-event-escalation",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}},{label:"Error end event",actionName:"replace-with-error-end",className:"bpmn-icon-end-event-error",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:ErrorEventDefinition"}},{label:"Cancel end event",actionName:"replace-with-cancel-end",className:"bpmn-icon-end-event-cancel",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:CancelEventDefinition"}},{label:"Compensation end event",actionName:"replace-with-compensation-end",className:"bpmn-icon-end-event-compensation",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}},{label:"Signal end event",actionName:"replace-with-signal-end",className:"bpmn-icon-end-event-signal",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},{label:"Terminate end event",actionName:"replace-with-terminate-end",className:"bpmn-icon-end-event-terminate",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:TerminateEventDefinition"}}],oy=[{label:"Exclusive gateway",actionName:"replace-with-exclusive-gateway",className:"bpmn-icon-gateway-xor",target:{type:"bpmn:ExclusiveGateway"}},{label:"Parallel gateway",actionName:"replace-with-parallel-gateway",className:"bpmn-icon-gateway-parallel",target:{type:"bpmn:ParallelGateway"}},{label:"Inclusive gateway",actionName:"replace-with-inclusive-gateway",className:"bpmn-icon-gateway-or",target:{type:"bpmn:InclusiveGateway"}},{label:"Complex gateway",actionName:"replace-with-complex-gateway",className:"bpmn-icon-gateway-complex",target:{type:"bpmn:ComplexGateway"}},{label:"Event-based gateway",actionName:"replace-with-event-based-gateway",className:"bpmn-icon-gateway-eventbased",target:{type:"bpmn:EventBasedGateway",instantiate:!1,eventGatewayType:"Exclusive"}}],ay=[{label:"Transaction",actionName:"replace-with-transaction",className:"bpmn-icon-transaction",target:{type:"bpmn:Transaction",isExpanded:!0}},{label:"Event sub-process",actionName:"replace-with-event-subprocess",className:"bpmn-icon-event-subprocess-expanded",target:{type:"bpmn:SubProcess",triggeredByEvent:!0,isExpanded:!0}},{label:"Ad-hoc sub-process",actionName:"replace-with-ad-hoc-subprocess",className:"bpmn-icon-subprocess-expanded",target:{type:"bpmn:AdHocSubProcess",isExpanded:!0}},{label:"Sub-process (collapsed)",actionName:"replace-with-collapsed-subprocess",className:"bpmn-icon-subprocess-collapsed",target:{type:"bpmn:SubProcess",isExpanded:!1}}],sy=[{label:"Sub-process",actionName:"replace-with-subprocess",className:"bpmn-icon-subprocess-expanded",target:{type:"bpmn:SubProcess",isExpanded:!0}},{label:"Transaction",actionName:"replace-with-transaction",className:"bpmn-icon-transaction",target:{type:"bpmn:Transaction",isExpanded:!0}},{label:"Event sub-process",actionName:"replace-with-event-subprocess",className:"bpmn-icon-event-subprocess-expanded",target:{type:"bpmn:SubProcess",triggeredByEvent:!0,isExpanded:!0}},{label:"Ad-hoc sub-process (collapsed)",actionName:"replace-with-collapsed-ad-hoc-subprocess",className:"bpmn-icon-subprocess-collapsed",target:{type:"bpmn:AdHocSubProcess",isExpanded:!1}}],cy=[{label:"Transaction",actionName:"replace-with-transaction",className:"bpmn-icon-transaction",target:{type:"bpmn:Transaction",isExpanded:!0}},{label:"Sub-process",actionName:"replace-with-subprocess",className:"bpmn-icon-subprocess-expanded",target:{type:"bpmn:SubProcess",isExpanded:!0}},{label:"Ad-hoc sub-process",actionName:"replace-with-ad-hoc-subprocess",className:"bpmn-icon-subprocess-expanded",target:{type:"bpmn:AdHocSubProcess",isExpanded:!0}},{label:"Event sub-process",actionName:"replace-with-event-subprocess",className:"bpmn-icon-event-subprocess-expanded",target:{type:"bpmn:SubProcess",triggeredByEvent:!0,isExpanded:!0}}],py=cy,ly=[{label:"Task",actionName:"replace-with-task",className:"bpmn-icon-task",target:{type:"bpmn:Task"}},{label:"User task",actionName:"replace-with-user-task",className:"bpmn-icon-user",target:{type:"bpmn:UserTask"}},{label:"Service task",actionName:"replace-with-service-task",className:"bpmn-icon-service",target:{type:"bpmn:ServiceTask"}},{label:"Send task",actionName:"replace-with-send-task",className:"bpmn-icon-send",target:{type:"bpmn:SendTask"}},{label:"Receive task",actionName:"replace-with-receive-task",className:"bpmn-icon-receive",target:{type:"bpmn:ReceiveTask"}},{label:"Manual task",actionName:"replace-with-manual-task",className:"bpmn-icon-manual",target:{type:"bpmn:ManualTask"}},{label:"Business rule task",actionName:"replace-with-rule-task",className:"bpmn-icon-business-rule",target:{type:"bpmn:BusinessRuleTask"}},{label:"Script task",actionName:"replace-with-script-task",className:"bpmn-icon-script",target:{type:"bpmn:ScriptTask"}},{label:"Call activity",actionName:"replace-with-call-activity",className:"bpmn-icon-call-activity",target:{type:"bpmn:CallActivity"}},{label:"Sub-process (collapsed)",actionName:"replace-with-collapsed-subprocess",className:"bpmn-icon-subprocess-collapsed",target:{type:"bpmn:SubProcess",isExpanded:!1}},{label:"Sub-process (expanded)",actionName:"replace-with-expanded-subprocess",className:"bpmn-icon-subprocess-expanded",target:{type:"bpmn:SubProcess",isExpanded:!0}},{label:"Ad-hoc sub-process (collapsed)",actionName:"replace-with-collapsed-ad-hoc-subprocess",className:"bpmn-icon-subprocess-collapsed",target:{type:"bpmn:AdHocSubProcess",isExpanded:!1}},{label:"Ad-hoc sub-process (expanded)",actionName:"replace-with-ad-hoc-subprocess",className:"bpmn-icon-subprocess-expanded",target:{type:"bpmn:AdHocSubProcess",isExpanded:!0}}],uy=[{label:"Data store reference",actionName:"replace-with-data-store-reference",className:"bpmn-icon-data-store",target:{type:"bpmn:DataStoreReference"}}],hy=[{label:"Data object reference",actionName:"replace-with-data-object-reference",className:"bpmn-icon-data-object",target:{type:"bpmn:DataObjectReference"}}],dy=[{label:"Message boundary event",actionName:"replace-with-message-boundary",className:"bpmn-icon-intermediate-event-catch-message",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:MessageEventDefinition",cancelActivity:!0}},{label:"Timer boundary event",actionName:"replace-with-timer-boundary",className:"bpmn-icon-intermediate-event-catch-timer",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:TimerEventDefinition",cancelActivity:!0}},{label:"Escalation boundary event",actionName:"replace-with-escalation-boundary",className:"bpmn-icon-intermediate-event-catch-escalation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",cancelActivity:!0}},{label:"Conditional boundary event",actionName:"replace-with-conditional-boundary",className:"bpmn-icon-intermediate-event-catch-condition",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",cancelActivity:!0}},{label:"Error boundary event",actionName:"replace-with-error-boundary",className:"bpmn-icon-intermediate-event-catch-error",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ErrorEventDefinition",cancelActivity:!0}},{label:"Cancel boundary event",actionName:"replace-with-cancel-boundary",className:"bpmn-icon-intermediate-event-catch-cancel",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:CancelEventDefinition",cancelActivity:!0}},{label:"Signal boundary event",actionName:"replace-with-signal-boundary",className:"bpmn-icon-intermediate-event-catch-signal",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:SignalEventDefinition",cancelActivity:!0}},{label:"Compensation boundary event",actionName:"replace-with-compensation-boundary",className:"bpmn-icon-intermediate-event-catch-compensation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:CompensateEventDefinition",cancelActivity:!0}},{label:"Message boundary event (non-interrupting)",actionName:"replace-with-non-interrupting-message-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-message",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:MessageEventDefinition",cancelActivity:!1}},{label:"Timer boundary event (non-interrupting)",actionName:"replace-with-non-interrupting-timer-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-timer",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:TimerEventDefinition",cancelActivity:!1}},{label:"Escalation boundary event (non-interrupting)",actionName:"replace-with-non-interrupting-escalation-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-escalation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",cancelActivity:!1}},{label:"Conditional boundary event (non-interrupting)",actionName:"replace-with-non-interrupting-conditional-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-condition",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",cancelActivity:!1}},{label:"Signal boundary event (non-interrupting)",actionName:"replace-with-non-interrupting-signal-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-signal",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:SignalEventDefinition",cancelActivity:!1}}],fy=[{label:"Message start event",actionName:"replace-with-message-start",className:"bpmn-icon-start-event-message",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:MessageEventDefinition",isInterrupting:!0}},{label:"Timer start event",actionName:"replace-with-timer-start",className:"bpmn-icon-start-event-timer",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:TimerEventDefinition",isInterrupting:!0}},{label:"Conditional start event",actionName:"replace-with-conditional-start",className:"bpmn-icon-start-event-condition",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",isInterrupting:!0}},{label:"Signal start event",actionName:"replace-with-signal-start",className:"bpmn-icon-start-event-signal",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:SignalEventDefinition",isInterrupting:!0}},{label:"Error start event",actionName:"replace-with-error-start",className:"bpmn-icon-start-event-error",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ErrorEventDefinition",isInterrupting:!0}},{label:"Escalation start event",actionName:"replace-with-escalation-start",className:"bpmn-icon-start-event-escalation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",isInterrupting:!0}},{label:"Compensation start event",actionName:"replace-with-compensation-start",className:"bpmn-icon-start-event-compensation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:CompensateEventDefinition",isInterrupting:!0}},{label:"Message start event (non-interrupting)",actionName:"replace-with-non-interrupting-message-start",className:"bpmn-icon-start-event-non-interrupting-message",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:MessageEventDefinition",isInterrupting:!1}},{label:"Timer start event (non-interrupting)",actionName:"replace-with-non-interrupting-timer-start",className:"bpmn-icon-start-event-non-interrupting-timer",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:TimerEventDefinition",isInterrupting:!1}},{label:"Conditional start event (non-interrupting)",actionName:"replace-with-non-interrupting-conditional-start",className:"bpmn-icon-start-event-non-interrupting-condition",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",isInterrupting:!1}},{label:"Signal start event (non-interrupting)",actionName:"replace-with-non-interrupting-signal-start",className:"bpmn-icon-start-event-non-interrupting-signal",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:SignalEventDefinition",isInterrupting:!1}},{label:"Escalation start event (non-interrupting)",actionName:"replace-with-non-interrupting-escalation-start",className:"bpmn-icon-start-event-non-interrupting-escalation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",isInterrupting:!1}}],my=[{label:"Sequence flow",actionName:"replace-with-sequence-flow",className:"bpmn-icon-connection"},{label:"Default flow",actionName:"replace-with-default-flow",className:"bpmn-icon-default-flow"},{label:"Conditional flow",actionName:"replace-with-conditional-flow",className:"bpmn-icon-conditional-flow"}],vy=[{label:"Expanded pool/participant",actionName:"replace-with-expanded-pool",className:"bpmn-icon-participant",target:{type:"bpmn:Participant",isExpanded:!0}},{label:function(e){var t="Empty pool/participant";return e.children&&e.children.length&&(t+=" (removes content)"),t},actionName:"replace-with-collapsed-pool",className:"bpmn-icon-lane",target:{type:"bpmn:Participant",isExpanded:!1}}],yy={"bpmn:MessageEventDefinition":[{label:"Message start event",actionName:"replace-with-message-start",className:"bpmn-icon-start-event-message",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Message intermediate catch event",actionName:"replace-with-message-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-message",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Message intermediate throw event",actionName:"replace-with-message-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-message",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Message end event",actionName:"replace-with-message-end",className:"bpmn-icon-end-event-message",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}}],"bpmn:TimerEventDefinition":[{label:"Timer start event",actionName:"replace-with-timer-start",className:"bpmn-icon-start-event-timer",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:TimerEventDefinition"}},{label:"Timer intermediate catch event",actionName:"replace-with-timer-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-timer",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:TimerEventDefinition"}}],"bpmn:ConditionalEventDefinition":[{label:"Conditional start event",actionName:"replace-with-conditional-start",className:"bpmn-icon-start-event-condition",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition"}},{label:"Conditional intermediate catch event",actionName:"replace-with-conditional-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-condition",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition"}}],"bpmn:SignalEventDefinition":[{label:"Signal start event",actionName:"replace-with-signal-start",className:"bpmn-icon-start-event-signal",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},{label:"Signal intermediate catch event",actionName:"replace-with-signal-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-signal",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},{label:"Signal intermediate throw event",actionName:"replace-with-signal-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-signal",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},{label:"Signal end event",actionName:"replace-with-signal-end",className:"bpmn-icon-end-event-signal",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}}],"bpmn:ErrorEventDefinition":[{label:"Error start event",actionName:"replace-with-error-start",className:"bpmn-icon-start-event-error",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ErrorEventDefinition"}},{label:"Error end event",actionName:"replace-with-error-end",className:"bpmn-icon-end-event-error",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:ErrorEventDefinition"}}],"bpmn:EscalationEventDefinition":[{label:"Escalation start event",actionName:"replace-with-escalation-start",className:"bpmn-icon-start-event-escalation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}},{label:"Escalation intermediate throw event",actionName:"replace-with-escalation-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-escalation",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}},{label:"Escalation end event",actionName:"replace-with-escalation-end",className:"bpmn-icon-end-event-escalation",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}}],"bpmn:CompensateEventDefinition":[{label:"Compensation start event",actionName:"replace-with-compensation-start",className:"bpmn-icon-start-event-compensation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}},{label:"Compensation intermediate throw event",actionName:"replace-with-compensation-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-compensation",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}},{label:"Compensation end event",actionName:"replace-with-compensation-end",className:"bpmn-icon-end-event-compensation",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}}]},gy={"start-event-non-interrupting":'\n <svg viewBox="0 0 2048 2048" xmlns="http://www.w3.org/2000/svg">\n <g transform="translate(0 995.64)">\n <path d="m1899 28.357c21.545 567.43-598.38 1023.5-1133.6 835.92-548.09-147.21-801.57-873.95-463.59-1330 302.62-480.3 1071.7-507.54 1407.6-49.847 122.14 153.12 190.07 348.07 189.59 543.91z" fill="none" stroke="currentColor" stroke-dasharray="418.310422, 361.2328165" stroke-linecap="round" stroke-width="100"/>\n </g>\n </svg>',"intermediate-event-non-interrupting":'\n <svg viewBox="0 0 2048 2048" xmlns="http://www.w3.org/2000/svg">\n <g transform="translate(0 995.64)" fill="none" stroke="currentColor" stroke-linecap="round">\n <circle cx="1024" cy="28.357" r="875" stroke-dasharray="418.310422, 361.2328165" stroke-width="100"/>\n <circle cx="1024" cy="28.357" r="685" stroke-dasharray="348.31044857,261.23283643" stroke-dashoffset="500" stroke-width="100"/>\n </g>\n </svg>'};function by(e,t,n,i,r,o,a,s){this._bpmnFactory=e,this._popupMenu=t,this._modeling=n,this._moddle=i,this._bpmnReplace=r,this._rules=o,this._translate=a,this._moddleCopy=s,this._register()}by.$inject=["bpmnFactory","popupMenu","modeling","moddle","bpmnReplace","rules","translate","moddleCopy"],by.prototype._register=function(){this._popupMenu.registerProvider("bpmn-replace",this)},by.prototype.getPopupMenuEntries=function(e){var t,n=e.businessObject,i=this._rules,r=[],o=[];if(p(e)||!i.allowed("shape.replace",{element:e}))return{};var a,s=(a=e,function(e){var t=e.target,n=gr(a),i=n.eventDefinitions&&n.eventDefinitions[0],r=n.$type===t.type,o=(i&&i.$type)===t.eventDefinitionType,s=!!t.triggeredByEvent==!!n.triggeredByEvent,c=void 0===t.isExpanded||t.isExpanded===Or(a);return!(r&&o&&s&&c)});return vr(n,"bpmn:DataObjectReference")?this._createEntries(e,uy):vr(n,"bpmn:DataStoreReference")&&!vr(e.parent,"bpmn:Collaboration")?this._createEntries(e,hy):(vr(n,"bpmn:Event")&&!vr(n,"bpmn:BoundaryEvent")&&(t=n.get("eventDefinitions")[0]?.$type,r=yy[t]||[],!$r(n.$parent)&&vr(n.$parent,"bpmn:SubProcess")&&(r=y(r,(function(e){return"bpmn:StartEvent"!==e.target.type})))),vr(n,"bpmn:StartEvent")&&!vr(n.$parent,"bpmn:SubProcess")?(o=y(ty.concat(r),s),this._createEntries(e,o)):vr(n,"bpmn:Participant")?(o=y(vy,(function(t){return Or(e)!==t.target.isExpanded})),this._createEntries(e,o)):vr(n,"bpmn:StartEvent")&&$r(n.$parent)?(o=y(fy.concat(r),(function(e){var t=!1!==e.target.isInterrupting,i=n.isInterrupting===t;return s(e)||!s(e)&&!i})),this._createEntries(e,o)):vr(n,"bpmn:StartEvent")&&!$r(n.$parent)&&vr(n.$parent,"bpmn:SubProcess")?(o=y(ny.concat(r),s),this._createEntries(e,o)):vr(n,"bpmn:EndEvent")?(o=y(ry.concat(r),(function(e){return!("bpmn:CancelEventDefinition"==e.target.eventDefinitionType&&!vr(n.$parent,"bpmn:Transaction"))&&s(e)})),this._createEntries(e,o)):vr(n,"bpmn:BoundaryEvent")?(o=y(dy,(function(e){var t=e.target;if("bpmn:CancelEventDefinition"==t.eventDefinitionType&&!vr(n.attachedToRef,"bpmn:Transaction"))return!1;var i=!1!==t.cancelActivity,r=n.cancelActivity==i;return s(e)||!s(e)&&!r})),this._createEntries(e,o)):vr(n,"bpmn:IntermediateCatchEvent")||vr(n,"bpmn:IntermediateThrowEvent")?(o=y(iy.concat(r),s),this._createEntries(e,o)):vr(n,"bpmn:Gateway")?(o=y(oy,s),this._createEntries(e,o)):vr(n,"bpmn:Transaction")?(o=y(cy,s),this._createEntries(e,o)):$r(n)&&Or(e)?(o=y(py,s),this._createEntries(e,o)):vr(n,"bpmn:AdHocSubProcess")&&Or(e)?(o=y(sy,s),this._createEntries(e,o)):vr(n,"bpmn:SubProcess")&&Or(e)?(o=y(ay,s),this._createEntries(e,o)):vr(n,"bpmn:SubProcess")&&!Or(e)?(o=y(ly,(function(t){return t.target.type===e.type===(!0===t.target.isExpanded)})),this._createEntries(e,o)):vr(n,"bpmn:SequenceFlow")?this._createSequenceFlowEntries(e,my):vr(n,"bpmn:FlowNode")?(o=y(ly,s),this._createEntries(e,o)):{})},by.prototype.getPopupMenuHeaderEntries=function(e){var t={};return vr(e,"bpmn:Activity")&&!$r(e)&&(t={...t,...this._getLoopCharacteristicsHeaderEntries(e)}),vr(e,"bpmn:DataObjectReference")&&(t={...t,...this._getCollectionHeaderEntries(e)}),vr(e,"bpmn:Participant")&&(t={...t,...this._getParticipantMultiplicityHeaderEntries(e)}),ch(e)&&(t={...t,...this._getNonInterruptingHeaderEntries(e)}),t},by.prototype._createEntries=function(e,t){var n={},i=this;return g(t,(function(t){n[t.actionName]=i._createEntry(t,e)})),n},by.prototype._createSequenceFlowEntries=function(e,t){var n=gr(e),i={},r=this._modeling,o=this._moddle,a=this;return g(t,(function(t){switch(t.actionName){case"replace-with-default-flow":n.sourceRef.default!==n&&(vr(n.sourceRef,"bpmn:ExclusiveGateway")||vr(n.sourceRef,"bpmn:InclusiveGateway")||vr(n.sourceRef,"bpmn:ComplexGateway")||vr(n.sourceRef,"bpmn:Activity"))&&(i={...i,[t.actionName]:a._createEntry(t,e,(function(){r.updateProperties(e.source,{default:n})}))});break;case"replace-with-conditional-flow":!n.conditionExpression&&vr(n.sourceRef,"bpmn:Activity")&&(i={...i,[t.actionName]:a._createEntry(t,e,(function(){var t=o.create("bpmn:FormalExpression",{body:""});r.updateProperties(e,{conditionExpression:t})}))});break;default:vr(n.sourceRef,"bpmn:Activity")&&n.conditionExpression&&(i={...i,[t.actionName]:a._createEntry(t,e,(function(){r.updateProperties(e,{conditionExpression:void 0})}))}),(vr(n.sourceRef,"bpmn:ExclusiveGateway")||vr(n.sourceRef,"bpmn:InclusiveGateway")||vr(n.sourceRef,"bpmn:ComplexGateway")||vr(n.sourceRef,"bpmn:Activity"))&&n.sourceRef.default===n&&(i={...i,[t.actionName]:a._createEntry(t,e,(function(){r.updateProperties(e.source,{default:void 0})}))})}})),i},by.prototype._createEntry=function(e,t,n){var i=this._translate,r=this._bpmnReplace.replaceElement,o=e.label;return o&&"function"==typeof o&&(o=o(t)),n=n||function(){return r(t,e.target)},{label:i(o),className:e.className,action:n}},by.prototype._getLoopCharacteristicsHeaderEntries=function(e){var t=this,n=this._translate;function i(n,i){if(i.active)t._modeling.updateProperties(e,{loopCharacteristics:void 0});else{var r=e.businessObject.get("loopCharacteristics");r&&vr(r,i.options.loopCharacteristics)?t._modeling.updateModdleProperties(e,r,{isSequential:i.options.isSequential}):(r=t._moddle.create(i.options.loopCharacteristics,{isSequential:i.options.isSequential}),t._modeling.updateProperties(e,{loopCharacteristics:r}))}}var r,o,a,s=gr(e).loopCharacteristics;return s&&(r=s.isSequential,o=void 0===s.isSequential,a=void 0!==s.isSequential&&!s.isSequential),{"toggle-parallel-mi":{className:"bpmn-icon-parallel-mi-marker",title:n("Parallel multi-instance"),active:a,action:i,options:{loopCharacteristics:"bpmn:MultiInstanceLoopCharacteristics",isSequential:!1}},"toggle-sequential-mi":{className:"bpmn-icon-sequential-mi-marker",title:n("Sequential multi-instance"),active:r,action:i,options:{loopCharacteristics:"bpmn:MultiInstanceLoopCharacteristics",isSequential:!0}},"toggle-loop":{className:"bpmn-icon-loop-marker",title:n("Loop"),active:o,action:i,options:{loopCharacteristics:"bpmn:StandardLoopCharacteristics"}}}},by.prototype._getCollectionHeaderEntries=function(e){var t=this,n=this._translate,i=e.businessObject.dataObjectRef;if(!i)return{};var r=i.isCollection;return{"toggle-is-collection":{className:"bpmn-icon-parallel-mi-marker",title:n("Collection"),active:r,action:function(n,r){t._modeling.updateModdleProperties(e,i,{isCollection:!r.active})}}}},by.prototype._getParticipantMultiplicityHeaderEntries=function(e){var t=this,n=this._bpmnFactory,i=this._translate;var r=e.businessObject.participantMultiplicity;return{"toggle-participant-multiplicity":{className:"bpmn-icon-parallel-mi-marker",title:i("Participant multiplicity"),active:!!r,action:function(i,r){var o;r.active||(o=n.create("bpmn:ParticipantMultiplicity")),t._modeling.updateProperties(e,{participantMultiplicity:o})}}}},by.prototype._getNonInterruptingHeaderEntries=function(e){const t=this._translate,n=gr(e),i=this,r=ph(e),o=vr(e,"bpmn:BoundaryEvent")?gy["intermediate-event-non-interrupting"]:gy["start-event-non-interrupting"],a=!n[r];return{"toggle-non-interrupting":{imageHtml:o,title:t("Toggle non-interrupting"),active:a,action:function(){i._modeling.updateProperties(e,{[r]:!!a})}}}};var _y={__depends__:[Lc,bf,rp],__init__:["replaceMenuProvider"],replaceMenuProvider:["type",by]};function xy(e,t,n,i,r,o,a,s,c,p,l,u,h){e=e||{},i.registerProvider(this),this._contextPad=i,this._modeling=r,this._elementFactory=o,this._connect=a,this._create=s,this._popupMenu=c,this._canvas=p,this._rules=l,this._translate=u,this._eventBus=n,this._appendPreview=h,!1!==e.autoPlace&&(this._autoPlace=t.get("autoPlace",!1)),n.on("create.end",250,(function(e){var t=e.context.shape;if(ca(e)&&i.isOpen(t)){var n=i.getEntries(t);n.replace&&n.replace.action.click(e,t)}})),n.on("contextPad.close",(function(){h.cleanUp()}))}function wy(e,t,n){var i=e.$instanceOf(t),r=!1;return g(e.eventDefinitions||[],(function(e){e.$type===n&&(r=!0)})),i&&r}xy.$inject=["config.contextPad","injector","eventBus","contextPad","modeling","elementFactory","connect","create","popupMenu","canvas","rules","translate","appendPreview"],xy.prototype.getMultiElementContextPadEntries=function(e){var t=this._modeling,n={};return this._isDeleteAllowed(e)&&L(n,{delete:{group:"edit",className:"bpmn-icon-trash",title:this._translate("Delete"),action:{click:function(e,n){t.removeElements(n.slice())}}}}),n},xy.prototype._isDeleteAllowed=function(e){var t=this._rules.allowed("elements.delete",{elements:e});return p(t)?x(e,(e=>t.includes(e))):t},xy.prototype.getContextPadEntries=function(e){var t=this._contextPad,n=this._modeling,i=this._elementFactory,r=this._connect,o=this._create,a=this._popupMenu,s=this._autoPlace,c=this._translate,p=this._appendPreview,l={};if("label"===e.type)return this._isDeleteAllowed([e])&&L(l,f()),l;var u=e.businessObject;function h(e,t){r.start(e,t)}function d(e,t){n.removeElements([t])}function f(){return{delete:{group:"edit",className:"bpmn-icon-trash",title:c("Delete"),action:{click:d}}}}function m(e,t,n,r){function a(t,n){var a=i.createShape(L({type:e},r));o.start(t,a,{source:n})}var c=s?function(t,n){var o=i.createShape(L({type:e},r));s.append(n,o)}:a,l=s?function(t,n){return p.create(n,e,r),()=>{p.cleanUp()}}:null;return{group:"model",className:t,title:n,action:{dragstart:a,click:c,hover:l}}}function v(e){return function(i,r){n.splitLane(r,e),t.open(r,!0)}}if(yr(u,["bpmn:Lane","bpmn:Participant"])&&Or(e)){var y=fu(e);L(l,{"lane-insert-above":{group:"lane-insert-above",className:"bpmn-icon-lane-insert-above",title:c("Add lane above"),action:{click:function(e,t){n.addLane(t,"top")}}}}),y.length<2&&((Lr(e)?e.height>=120:e.width>=120)&&L(l,{"lane-divide-two":{group:"lane-divide",className:"bpmn-icon-lane-divide-two",title:c("Divide into two lanes"),action:{click:v(2)}}}),(Lr(e)?e.height>=180:e.width>=180)&&L(l,{"lane-divide-three":{group:"lane-divide",className:"bpmn-icon-lane-divide-three",title:c("Divide into three lanes"),action:{click:v(3)}}})),L(l,{"lane-insert-below":{group:"lane-insert-below",className:"bpmn-icon-lane-insert-below",title:c("Add lane below"),action:{click:function(e,t){n.addLane(t,"bottom")}}}})}return vr(u,"bpmn:FlowNode")&&(vr(u,"bpmn:EventBasedGateway")?L(l,{"append.receive-task":m("bpmn:ReceiveTask","bpmn-icon-receive-task",c("Append receive task")),"append.message-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-message",c("Append message intermediate catch event"),{eventDefinitionType:"bpmn:MessageEventDefinition"}),"append.timer-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-timer",c("Append timer intermediate catch event"),{eventDefinitionType:"bpmn:TimerEventDefinition"}),"append.condition-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-condition",c("Append conditional intermediate catch event"),{eventDefinitionType:"bpmn:ConditionalEventDefinition"}),"append.signal-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-signal",c("Append signal intermediate catch event"),{eventDefinitionType:"bpmn:SignalEventDefinition"})}):wy(u,"bpmn:BoundaryEvent","bpmn:CompensateEventDefinition")?L(l,{"append.compensation-activity":m("bpmn:Task","bpmn-icon-task",c("Append compensation activity"),{isForCompensation:!0})}):vr(u,"bpmn:EndEvent")||u.isForCompensation||wy(u,"bpmn:IntermediateThrowEvent","bpmn:LinkEventDefinition")||$r(u)||L(l,{"append.end-event":m("bpmn:EndEvent","bpmn-icon-end-event-none",c("Append end event")),"append.gateway":m("bpmn:ExclusiveGateway","bpmn-icon-gateway-none",c("Append gateway")),"append.append-task":m("bpmn:Task","bpmn-icon-task",c("Append task")),"append.intermediate-event":m("bpmn:IntermediateThrowEvent","bpmn-icon-intermediate-event-none",c("Append intermediate/boundary event"))})),a.isEmpty(e,"bpmn-replace")||L(l,{replace:{group:"edit",className:"bpmn-icon-screw-wrench",title:c("Change element"),action:{click:function(e,n){var i=L(function(e){var n=t.getPad(e).html.getBoundingClientRect();return{x:n.left,y:n.bottom+5}}(n),{cursor:{x:e.x,y:e.y}});a.open(n,"bpmn-replace",i,{title:c("Change element"),width:300,search:!0})}}}}),vr(u,"bpmn:SequenceFlow")&&L(l,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation"))}),yr(u,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference"])&&L(l,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation")),connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect to other element"),action:{click:h,dragstart:h}}}),vr(u,"bpmn:TextAnnotation")&&L(l,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect using association"),action:{click:h,dragstart:h}}}),yr(u,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&L(l,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect using data input association"),action:{click:h,dragstart:h}}}),vr(u,"bpmn:Group")&&L(l,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation"))}),this._isDeleteAllowed([e])&&L(l,f()),l};var Ey={__depends__:[qv,ey,vs,_a,wl,Zd,_y],__init__:["contextPadProvider"],contextPadProvider:["type",xy]},Sy={horizontal:["x","width"],vertical:["y","height"]};function Cy(e,t){this._modeling=e,this._filters=[],this.registerFilter((function(e){var n=t.allowed("elements.distribute",{elements:e});return p(n)?n:n?e:[]}))}Cy.$inject=["modeling","rules"],Cy.prototype.registerFilter=function(e){if("function"!=typeof e)throw new Error("the filter has to be a function");this._filters.push(e)},Cy.prototype.trigger=function(e,t){var n,i,r=this._modeling;if(!(e.length<3||(this._setOrientation(t),i=this._filterElements(e),(n=this._createGroups(i)).length<=2)))return r.distributeElements(n,this._axis,this._dimension),n},Cy.prototype._filterElements=function(e){var t=this._filters,n=this._axis,i=this._dimension,r=[].concat(e);return t.length?(g(t,(function(e){r=e(r,n,i)})),r):e},Cy.prototype._createGroups=function(e){var t=[],n=this,i=this._axis,r=this._dimension;if(!i)throw new Error('must have a defined "axis" and "dimension"');return g(A(e,i),(function(e,o){var a,s=n._findRange(e,i,r),c=t[t.length-1];c&&n._hasIntersection(c.range,s)?t[t.length-1].elements.push(e):(a={range:s,elements:[e]},t.push(a))})),t},Cy.prototype._setOrientation=function(e){var t=Sy[e];this._axis=t[0],this._dimension=t[1]},Cy.prototype._hasIntersection=function(e,t){return Math.max(e.min,e.max)>=Math.min(t.min,t.max)&&Math.min(e.min,e.max)<=Math.max(t.min,t.max)},Cy.prototype._findRange=function(e){var t=e[this._axis];return{min:t+5,max:t+e[this._dimension]-5}};var ky={__init__:["distributeElements"],distributeElements:["type",Cy]};function Ry(e){Hc.call(this,e)}Ry.$inject=["eventBus"],e(Ry,Hc),Ry.prototype.init=function(){this.addRule("elements.distribute",(function(e){var t=e.elements;return!((t=st(t=y(t,(function(e){var t=yr(e,["bpmn:Association","bpmn:BoundaryEvent","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:Lane","bpmn:MessageFlow","bpmn:SequenceFlow","bpmn:TextAnnotation"]);return!(e.labelTarget||t)})))).length<3)&&t}))};var Py={horizontal:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <polyline points="450 400 450 150 1350 150 1350 400" style="fill:none;stroke:currentColor;stroke-width:100;stroke-linejoin:round;"/>\n <rect x="150" y="450" width="600" height="1200" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="1050" y="450" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',vertical:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <polyline points="400 1350 150 1350 150 450 400 450" style="fill:none;stroke:currentColor;stroke-width:100;stroke-linejoin:round;"/>\n <rect x="450" y="150" width="1200" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="450" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>'};function Ay(e,t,n,i){this._distributeElements=t,this._translate=n,this._popupMenu=e,this._rules=i,e.registerProvider("align-elements",900,this)}Ay.$inject=["popupMenu","distributeElements","translate","rules"],Ay.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&L(t,this._getEntries(e)),t},Ay.prototype._isAllowed=function(e){return this._rules.allowed("elements.distribute",{elements:e})},Ay.prototype._getEntries=function(e){var t=this._distributeElements,n=this._translate,i=this._popupMenu;return{"distribute-elements-horizontal":{group:"distribute",title:n("Distribute elements horizontally"),className:"bjs-align-elements-menu-entry",imageHtml:Py.horizontal,action:function(n,r){t.trigger(e,"horizontal"),i.close()}},"distribute-elements-vertical":{group:"distribute",title:n("Distribute elements vertically"),imageHtml:Py.vertical,action:function(n,r){t.trigger(e,"vertical"),i.close()}}}};var My={__depends__:[Lc,ky],__init__:["bpmnDistributeElements","distributeElementsMenuProvider"],bpmnDistributeElements:["type",Ry],distributeElementsMenuProvider:["type",Ay]},Ty="is not a registered action";function Dy(e,t){this._actions={};var n=this;e.on("diagram.init",(function(){n._registerDefaultActions(t),e.fire("editorActions.init",{editorActions:n})}))}function By(e,t){return new Error(e+" "+t)}Dy.$inject=["eventBus","injector"],Dy.prototype._registerDefaultActions=function(e){var t=e.get("commandStack",!1),n=e.get("modeling",!1),i=e.get("selection",!1),r=e.get("zoomScroll",!1),o=e.get("copyPaste",!1),a=e.get("canvas",!1),s=e.get("rules",!1),c=e.get("keyboardMove",!1),l=e.get("keyboardMoveSelection",!1);t&&(this.register("undo",(function(){t.undo()})),this.register("redo",(function(){t.redo()}))),o&&i&&this.register("copy",(function(){var e=i.get();if(e.length)return o.copy(e)})),o&&this.register("paste",(function(){o.paste()})),r&&this.register("stepZoom",(function(e){r.stepZoom(e.value)})),a&&this.register("zoom",(function(e){a.zoom(e.value)})),n&&i&&s&&this.register("removeSelection",(function(){var e=i.get();if(e.length){var t,r=s.allowed("elements.delete",{elements:e});!1!==r&&(t=p(r)?r:e).length&&n.removeElements(t.slice())}})),c&&this.register("moveCanvas",(function(e){c.moveCanvas(e)})),l&&this.register("moveSelection",(function(e){l.moveSelection(e.direction,e.accelerated)}))},Dy.prototype.trigger=function(e,t){if(!this._actions[e])throw By(e,Ty);return this._actions[e](t)},Dy.prototype.register=function(e,t){var n=this;if("string"==typeof e)return this._registerAction(e,t);g(e,(function(e,t){n._registerAction(t,e)}))},Dy.prototype._registerAction=function(e,t){if(this.isRegistered(e))throw By(e,"is already registered");this._actions[e]=t},Dy.prototype.unregister=function(e){if(!this.isRegistered(e))throw By(e,Ty);this._actions[e]=void 0},Dy.prototype.getActions=function(){return Object.keys(this._actions)},Dy.prototype.isRegistered=function(e){return!!this._actions[e]};var Ny={__init__:["editorActions"],editorActions:["type",Dy]};function jy(e){e.invoke(Dy,this)}e(jy,Dy),jy.$inject=["injector"],jy.prototype._registerDefaultActions=function(e){Dy.prototype._registerDefaultActions.call(this,e);var t=e.get("canvas",!1),n=e.get("elementRegistry",!1),i=e.get("selection",!1),r=e.get("spaceTool",!1),o=e.get("lassoTool",!1),a=e.get("handTool",!1),s=e.get("globalConnect",!1),c=e.get("distributeElements",!1),p=e.get("alignElements",!1),l=e.get("directEditing",!1),u=e.get("searchPad",!1),h=e.get("modeling",!1),d=e.get("contextPad",!1);t&&n&&i&&this._registerAction("selectElements",(function(){var e=t.getRootElement(),r=n.filter((function(t){return t!==e}));return i.select(r),r})),r&&this._registerAction("spaceTool",(function(){r.toggle()})),o&&this._registerAction("lassoTool",(function(){o.toggle()})),a&&this._registerAction("handTool",(function(){a.toggle()})),s&&this._registerAction("globalConnectTool",(function(){s.toggle()})),i&&c&&this._registerAction("distributeElements",(function(e){var t=i.get(),n=e.type;t.length&&c.trigger(t,n)})),i&&p&&this._registerAction("alignElements",(function(e){var t=i.get(),n=[],r=e.type;t.length&&(n=y(t,(function(e){return!vr(e,"bpmn:Lane")})),p.trigger(n,r))})),i&&h&&this._registerAction("setColor",(function(e){var t=i.get();t.length&&h.setColor(t,e)})),i&&l&&this._registerAction("directEditing",(function(){var e=i.get();e.length&&l.activate(e[0])})),u&&this._registerAction("find",(function(){u.toggle()})),t&&h&&this._registerAction("moveToOrigin",(function(){var e,i,r=t.getRootElement();e=ht(i=vr(r,"bpmn:Collaboration")?n.filter((function(e){return vr(e.parent,"bpmn:Collaboration")})):n.filter((function(e){return e!==r&&!vr(e.parent,"bpmn:SubProcess")}))),h.moveElements(i,{x:-e.x,y:-e.y},r)})),i&&d&&this._registerAction("replaceElement",(function(e){d.triggerEntry("replace","click",e)}))};var Oy={__depends__:[Ny],editorActions:["type",jy]};function Ly(e){e.on(["create.init","shape.move.init"],(function(e){var t=e.context;yr(e.shape,["bpmn:Participant","bpmn:SubProcess","bpmn:TextAnnotation"])&&(t.gridSnappingContext||(t.gridSnappingContext={}),t.gridSnappingContext.snapLocation="top-left")}))}Ly.$inject=["eventBus"];function $y(e,t,n){return n||(n="round"),Math[n](e/t)*t}function Iy(e,t,n){var i=!n||!1!==n.active;this._eventBus=t;var r=this;t.on("diagram.init",800,(function(){r.setActive(i)})),t.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"],1200,(function(t){var n=t.originalEvent;if(!(!r.active||n&&ka(n))){var i=t.context,o=i.gridSnappingContext;o||(o=i.gridSnappingContext={}),["x","y"].forEach((function(n){var i={},o=function(e,t,n){var i=e.context,r=e.shape,o=i.gridSnappingContext,a=o.snapLocation,s=o.snapOffset;if(s&&u(s[t]))return s[t];s||(s=o.snapOffset={});u(s[t])||(s[t]=0);if(!r)return s[t];n.get(r.id)||(Fy(t)?s[t]+=r[t]+r.width/2:s[t]+=r[t]+r.height/2);if(!a)return s[t];"x"===t?/left/.test(a)?s[t]-=r.width/2:/right/.test(a)&&(s[t]+=r.width/2):/top/.test(a)?s[t]-=r.height/2:/bottom/.test(a)&&(s[t]+=r.height/2);return s[t]}(t,n,e);o&&(i.offset=o);var a=function(e,t){var n=e.context,i=n.createConstraints,r=n.resizeConstraints||{},o=n.gridSnappingContext,a=o.snapConstraints;if(a&&a[t])return a[t];a||(a=o.snapConstraints={});a[t]||(a[t]={});var s=n.direction;i&&(Fy(t)?(a.x.min=i.left,a.x.max=i.right):(a.y.min=i.top,a.y.max=i.bottom));var c=r.min,p=r.max;c&&(Fy(t)?Hy(s)?a.x.max=c.left:a.x.min=c.right:zy(s)?a.y.max=c.top:a.y.min=c.bottom);p&&(Fy(t)?Hy(s)?a.x.min=p.left:a.x.max=p.right:zy(s)?a.y.min=p.top:a.y.max=p.bottom);return a[t]}(t,n);a&&L(i,a),ll(t,n)||r.snapEvent(t,n,i)}))}}))}function Fy(e){return"x"===e}function zy(e){return-1!==e.indexOf("n")}function Hy(e){return-1!==e.indexOf("w")}function Vy(e,t){Do.call(this,e),this._gridSnapping=t;var n=this;this.preExecute("shape.resize",(function(e){var t=e.context,i=(t.hints||{}).autoResize;if(i){var r=t.shape,o=t.newBounds;d(i)?t.newBounds=n.snapComplex(o,i):t.newBounds=n.snapSimple(r,o)}}))}Iy.prototype.snapEvent=function(e,t,n){ul(e,t,this.snapValue(e[t],n))},Iy.prototype.getGridSpacing=function(){return 10},Iy.prototype.snapValue=function(e,t){var n,i,r=0;return t&&t.offset&&(r=t.offset),e=$y(e+=r,10),t&&t.min&&u(n=t.min)&&(n=$y(n+r,10,"ceil"),e=Math.max(e,n)),t&&t.max&&u(i=t.max)&&(i=$y(i+r,10,"floor"),e=Math.min(e,i)),e-=r},Iy.prototype.isActive=function(){return this.active},Iy.prototype.setActive=function(e){this.active=e,this._eventBus.fire("gridSnapping.toggle",{active:e})},Iy.prototype.toggleActive=function(){this.setActive(!this.active)},Iy.$inject=["elementRegistry","eventBus","config.gridSnapping"],Vy.$inject=["eventBus","gridSnapping","modeling"],e(Vy,Do),Vy.prototype.snapSimple=function(e,t){var n=this._gridSnapping;return t.width=n.snapValue(t.width,{min:t.width}),t.height=n.snapValue(t.height,{min:t.height}),t.x=e.x+e.width/2-t.width/2,t.y=e.y+e.height/2-t.height/2,t},Vy.prototype.snapComplex=function(e,t){return/w|e/.test(t)&&(e=this.snapHorizontally(e,t)),/n|s/.test(t)&&(e=this.snapVertically(e,t)),e},Vy.prototype.snapHorizontally=function(e,t){var n=this._gridSnapping,i=/w/.test(t),r=/e/.test(t),o={};return o.width=n.snapValue(e.width,{min:e.width}),r&&(i?(o.x=n.snapValue(e.x,{max:e.x}),o.width+=n.snapValue(e.x-o.x,{min:e.x-o.x})):e.x=e.x+e.width-o.width),L(e,o),e},Vy.prototype.snapVertically=function(e,t){var n=this._gridSnapping,i=/n/.test(t),r=/s/.test(t),o={};return o.height=n.snapValue(e.height,{min:e.height}),i&&(r?(o.y=n.snapValue(e.y,{max:e.y}),o.height+=n.snapValue(e.y-o.y,{min:e.y-o.y})):e.y=e.y+e.height-o.height),L(e,o),e};function Gy(e,t){e.on(["spaceTool.move","spaceTool.end"],2e3,(function(e){var n,i=e.context;i.initialized&&("x"===i.axis?(n=t.snapValue(e.dx),e.x=e.x+n-e.dx,e.dx=n):(n=t.snapValue(e.dy),e.y=e.y+n-e.dy,e.dy=n))}))}Gy.$inject=["eventBus","gridSnapping"];var Wy={__depends__:[{__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",Vy],gridSnappingSpaceToolBehavior:["type",Gy]}],__init__:["gridSnapping"],gridSnapping:["type",Iy]};function Uy(e,t,n){e.on("autoPlace",2e3,(function(e){var i=e.source,r=fn(i),o=e.shape,a=tp(i,o,n);return["x","y"].forEach((function(e){var n={};a[e]!==r[e]&&(a[e]>r[e]?n.min=a[e]:n.max=a[e],vr(o,"bpmn:TextAnnotation")&&(!function(e){return"x"===e}(e)?n.offset=-o.height/2:n.offset=-o.width/2),a[e]=t.snapValue(a[e],n))})),a}))}Uy.$inject=["eventBus","gridSnapping","elementRegistry"];function qy(e,t,n){t.on(["create.start","shape.move.start"],1750,(function(t){var i=t.context,r=i.shape,o=e.getRootElement();vr(r,"bpmn:Participant")&&vr(o,"bpmn:Process")&&o.children.length&&(i.createConstraints&&(r.width=n.snapValue(r.width,{min:r.width}),r.height=n.snapValue(r.height,{min:r.height})))}))}qy.$inject=["canvas","eventBus","gridSnapping"];function Ky(e,t,n){Do.call(this,e),this._gridSnapping=t;var i=this;this.postExecuted(["connection.create","connection.layout"],3e3,(function(e){var t=e.context,r=t.connection,o=t.hints||{},a=r.waypoints;o.connectionStart||o.connectionEnd||!1===o.createElementsBehavior||function(e){return e.length>3}(a)&&n.updateWaypoints(r,i.snapMiddleSegments(a))}))}function Yy(e,t,n){var i=St(t,n),r={};return function(e){return"h"===e}(i)&&(r.y=e.snapValue(t.y)),function(e){return"v"===e}(i)&&(r.x=e.snapValue(t.x)),("x"in r||"y"in r)&&(t=L({},t,r),n=L({},n,r)),[t,n]}Ky.$inject=["eventBus","gridSnapping","modeling"],e(Ky,Do),Ky.prototype.snapMiddleSegments=function(e){var t,n=this._gridSnapping;e=e.slice();for(var i=1;i<e.length-2;i++)t=Yy(n,e[i],e[i+1]),e[i]=t[0],e[i+1]=t[1];return e};var Xy={__depends__:[Wy,{__init__:["gridSnappingAutoPlaceBehavior","gridSnappingParticipantBehavior","gridSnappingLayoutConnectionBehavior"],gridSnappingAutoPlaceBehavior:["type",Uy],gridSnappingParticipantBehavior:["type",qy],gridSnappingLayoutConnectionBehavior:["type",Ky]}],__init__:["bpmnGridSnapping"],bpmnGridSnapping:["type",Ly]};function Zy(e,t){this._interactionEvents=t;var n=this;e.on(["interactionEvents.createHit","interactionEvents.updateHit"],(function(e){var t=e.element,i=e.gfx;return vr(t,"bpmn:Lane")?n._createParticipantHit(t,i):vr(t,"bpmn:Participant")?Or(t)?n._createParticipantHit(t,i):n._createDefaultHit(t,i):vr(t,"bpmn:SubProcess")?Or(t)?n._createSubProcessHit(t,i):n._createDefaultHit(t,i):void 0}))}Zy.$inject=["eventBus","interactionEvents"],Zy.prototype._createDefaultHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createDefaultHit(e,t),!0},Zy.prototype._createParticipantHit=function(e,t){this._interactionEvents.removeHits(t),this._interactionEvents.createBoxHit(t,"no-move",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"click-stroke",{width:e.width,height:e.height});var n=Lr(e)?{width:30,height:e.height}:{width:e.width,height:30};return this._interactionEvents.createBoxHit(t,"all",n),!0},Zy.prototype._createSubProcessHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createBoxHit(t,"no-move",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"click-stroke",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"all",{width:e.width,height:30}),!0};var Qy={__init__:["bpmnInteractionEvents"],bpmnInteractionEvents:["type",Zy]};function Jy(e){e.invoke(Da,this)}e(Jy,Da),Jy.$inject=["injector"],Jy.prototype.registerBindings=function(e,t){function n(n,i){t.isRegistered(n)&&e.addListener(i)}Da.prototype.registerBindings.call(this,e,t),n("selectElements",(function(n){var i=n.keyEvent;if(e.isKey(["a","A"],i)&&e.isCmd(i))return t.trigger("selectElements"),!0})),n("find",(function(n){var i=n.keyEvent;if(e.isKey(["f","F"],i)&&e.isCmd(i))return t.trigger("find"),!0})),n("spaceTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["s","S"],i)?(t.trigger("spaceTool"),!0):void 0})),n("lassoTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["l","L"],i)?(t.trigger("lassoTool"),!0):void 0})),n("handTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["h","H"],i)?(t.trigger("handTool"),!0):void 0})),n("globalConnectTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["c","C"],i)?(t.trigger("globalConnectTool"),!0):void 0})),n("directEditing",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["e","E"],i)?(t.trigger("directEditing"),!0):void 0})),n("replaceElement",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["r","R"],i)?(t.trigger("replaceElement",i),!0):void 0}))};var eg={__depends__:[Ba],__init__:["keyboardBindings"],keyboardBindings:["type",Jy]},tg={moveSpeed:1,moveSpeedAccelerated:10},ng="left",ig="right",rg="down",og={ArrowLeft:ng,Left:ng,ArrowUp:"up",Up:"up",ArrowRight:ig,Right:ig,ArrowDown:rg,Down:rg},ag={left:function(e){return{x:-e,y:0}},up:function(e){return{x:0,y:-e}},right:function(e){return{x:e,y:0}},down:function(e){return{x:0,y:e}}};function sg(e,t,n,i,r){var o=this;this._config=L({},tg,e||{}),t.addListener(1500,(function(e){var n=e.keyEvent,i=og[n.key];if(i&&!t.isCmd(n)){var r=t.isShift(n);return o.moveSelection(i,r),!0}})),this.moveSelection=function(e,t){var o=r.get();if(o.length){var a=this._config[t?"moveSpeedAccelerated":"moveSpeed"],s=ag[e](a);i.allowed("elements.move",{shapes:o})&&n.moveElements(o,s)}}}sg.$inject=["config.keyboardMoveSelection","keyboard","modeling","rules","selection"];var cg={__depends__:[Ba,_a],__init__:["keyboardMoveSelection"],keyboardMoveSelection:["type",sg]};function pg(e,t,n,i){this._dragging=i,this._rules=t;var r=this;function o(e,t){var n,i=e.shape,o=e.direction,a=e.resizeConstraints;e.delta=t,n=function(e,t,n){var i=n.x,r=n.y,o={x:e.x,y:e.y,width:e.width,height:e.height};return-1!==t.indexOf("n")?(o.y=e.y+r,o.height=e.height-r):-1!==t.indexOf("s")&&(o.height=e.height+r),-1!==t.indexOf("e")?o.width=e.width+i:-1!==t.indexOf("w")&&(o.x=e.x+i,o.width=e.width-i),o}(i,o,t),e.newBounds=function(e,t){if(!t)return e;var n=un(e);return hn({top:au("top",n,t),right:au("right",n,t),bottom:au("bottom",n,t),left:au("left",n,t)})}(n,a),e.canExecute=r.canResize(e)}e.on("resize.start",(function(e){var t,n,i;t=e.context,n=t.resizeConstraints,i=t.minBounds,void 0===n&&(void 0===i&&(i=r.computeMinResizeBox(t)),t.resizeConstraints={min:un(i)})})),e.on("resize.move",(function(e){var t={x:e.dx,y:e.dy};o(e.context,t)})),e.on("resize.end",(function(e){!function(e){var t=e.shape,i=e.canExecute,r=e.newBounds;if(i){if(!function(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}(t,r=pn(r)))return;n.resizeShape(t,r)}}(e.context)}))}function lg(e,t){var n=fn(e),i=un(e),r={x:n.x,y:n.y};return-1!==t.indexOf("n")?r.y=i.top:-1!==t.indexOf("s")&&(r.y=i.bottom),-1!==t.indexOf("e")?r.x=i.right:-1!==t.indexOf("w")&&(r.x=i.left),r}function ug(e){var t="resize-";return"n"===e||"s"===e?t+"ns":"e"===e||"w"===e?t+"ew":"nw"===e||"se"===e?t+"nwse":t+"nesw"}pg.prototype.canResize=function(e){var t=this._rules,n=$(e,["newBounds","shape","delta","direction"]);return t.allowed("shape.resize",n)},pg.prototype.activate=function(e,t,n){var i,r,o=this._dragging;if("string"==typeof n&&(n={direction:n}),!(r=(i=L({shape:t},n)).direction))throw new Error("must provide a direction (n|w|s|e|nw|se|ne|sw)");o.init(e,lg(t,r),"resize",{autoActivate:!0,cursor:ug(r),data:{shape:t,context:i}})},pg.prototype.computeMinResizeBox=function(e){var t=e.shape;return function(e,t,n,i){var r=un(t),o={top:/n/.test(e)?r.bottom-n.height:r.top,left:/w/.test(e)?r.right-n.width:r.left,bottom:/s/.test(e)?r.top+n.height:r.bottom,right:/e/.test(e)?r.left+n.width:r.right},a=i?un(i):o;return hn({top:ru(o.top,a.top),left:ru(o.left,a.left),bottom:iu(o.bottom,a.bottom),right:iu(o.right,a.right)})}(e.direction,t,e.minDimensions||{width:10,height:10},pu(t,e.childrenBoxPadding))},pg.$inject=["eventBus","rules","modeling","dragging"];var hg="djs-resizing",dg="resize-not-ok";function fg(e,t,n){e.on("resize.move",500,(function(e){var i,r,o,a;i=e.context,r=i.shape,o=i.newBounds,(a=i.frame)||(a=i.frame=n.addFrame(r,t.getActiveLayer()),t.addMarker(r,hg)),o.width>5&&_e(a,{x:o.x,width:o.width}),o.height>5&&_e(a,{y:o.y,height:o.height}),i.canExecute?we(a).remove(dg):we(a).add(dg)})),e.on("resize.cleanup",(function(e){var n,i;n=e.context,i=n.shape,n.frame&&Fe(n.frame),t.removeMarker(i,hg)}))}fg.$inject=["eventBus","canvas","previewSupport"];var mg=-6,vg="djs-resizer",yg=["n","w","s","e","nw","ne","se","sw"];function gg(e,t,n,i){this._resize=i,this._canvas=t;var r=this;e.on("selection.changed",(function(e){var t=e.newSelection;r.removeResizers(),1===t.length&&g(t,O(r.addResizer,r))})),e.on("shape.changed",(function(e){var t=e.element;n.isSelected(t)&&(r.removeResizers(),r.addResizer(t))}))}gg.prototype.makeDraggable=function(e,t,n){var i=this._resize;function r(t){sa(t)&&i.activate(t,e,n)}oe.bind(t,"mousedown",r),oe.bind(t,"touchstart",r)},gg.prototype._createResizer=function(e,t,n,i){var r=this._getResizersParent(),o=function(e){var t={x:0,y:0};-1!==e.indexOf("e")?t.x=6:-1!==e.indexOf("w")&&(t.x=mg);-1!==e.indexOf("s")?t.y=6:-1!==e.indexOf("n")&&(t.y=mg);return t}(i),a=Ae("g");we(a).add(vg),we(a).add(vg+"-"+e.id),we(a).add(vg+"-"+i),ye(r,a);var s=Ae("rect");_e(s,{x:-4+o.x,y:-4+o.y,width:8,height:8}),we(s).add(vg+"-visual"),ye(a,s);var c=Ae("rect");return _e(c,{x:-10+o.x,y:-10+o.y,width:20,height:20}),we(c).add(vg+"-hit"),ye(a,c),Gn(a,t,n),a},gg.prototype.createResizer=function(e,t){var n=lg(e,t),i=this._createResizer(e,n.x,n.y,t);this.makeDraggable(e,i,t)},gg.prototype.addResizer=function(e){var t=this;!sn(e)&&this._resize.canResize({shape:e})&&g(yg,(function(n){t.createResizer(e,n)}))},gg.prototype.removeResizers=function(){Se(this._getResizersParent())},gg.prototype._getResizersParent=function(){return this._canvas.getLayer("resizers")},gg.$inject=["eventBus","canvas","selection","resize"];var bg={__depends__:[xp,vp,Al],__init__:["resize","resizePreview","resizeHandles"],resize:["type",pg],resizePreview:["type",fg],resizeHandles:["type",gg]};function _g(e,t,n,i,r,o,a){function s(e,t){(t||yr(e,["bpmn:Task","bpmn:TextAnnotation","bpmn:Participant"])||xg(e))&&i.activate(e)}this._bpmnFactory=t,this._canvas=n,this._modeling=r,this._textRenderer=a,i.registerProvider(this),e.on("element.dblclick",(function(e){s(e.element,!0)})),e.on(["autoPlace.start","canvas.viewbox.changing","drag.init","element.mousedown","popupMenu.open","root.set","selection.changed"],(function(){i.isActive()&&i.complete()})),e.on(["shape.remove","connection.remove"],2e3,(function(e){i.isActive(e.element)&&i.cancel()})),e.on(["commandStack.changed"],(function(e){i.isActive()&&i.cancel()})),e.on("directEditing.activate",(function(e){o.removeResizers()})),e.on("create.end",500,(function(e){var t=e.context,n=t.shape,i=e.context.canExecute;e.isTouch||i&&(t.hints&&!1===t.hints.createElementsBehavior||s(n))})),e.on("autoPlace.end",500,(function(e){s(e.shape)}))}function xg(e){return vr(e,"bpmn:SubProcess")&&!Or(e)}_g.$inject=["eventBus","bpmnFactory","canvas","directEditing","modeling","resizeHandles","textRenderer"],_g.prototype.activate=function(e){var t=Ur(e);if(void 0!==t){var n={text:t};L(n,this.getEditingBBox(e));var i={},r=n.style||{};return L(r,{backgroundColor:null,border:null}),(yr(e,["bpmn:Task","bpmn:Participant","bpmn:Lane","bpmn:CallActivity"])||xg(e))&&L(i,{centerVertically:!0}),zr(e)&&(L(i,{autoResize:!0}),L(r,{backgroundColor:"#ffffff",border:"1px solid #ccc"})),vr(e,"bpmn:TextAnnotation")&&(L(i,{resizable:!0,autoResize:!0}),L(r,{backgroundColor:"#ffffff",border:"1px solid #ccc"})),L(n,{options:i,style:r}),n}},_g.prototype.getEditingBBox=function(e){var t=this._canvas,n=e.label||e,i=t.getAbsoluteBBox(n),r=i.x+i.width/2,o=i.y+i.height/2,a={x:i.x,y:i.y},s=t.zoom(),c=this._textRenderer.getDefaultStyle(),p=this._textRenderer.getExternalStyle(),l=p.fontSize*s,u=p.lineHeight,h=c.fontSize*s,d=c.lineHeight,f={fontFamily:this._textRenderer.getDefaultStyle().fontFamily,fontWeight:this._textRenderer.getDefaultStyle().fontWeight};if(vr(e,"bpmn:Lane")||function(e){return vr(e,"bpmn:Participant")&&Or(e)}(e)){var m=Lr(e);L(a,m?{width:i.height,height:30*s,x:i.x-i.height/2+15*s,y:o-30*s/2}:{width:i.width,height:30*s}),L(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px",transform:m?"rotate(-90deg)":null})}if(function(e){return vr(e,"bpmn:Participant")&&!Or(e)}(e)){var v=Lr(e);L(a,v?{width:i.width,height:i.height}:{width:i.height,height:i.width,x:r-i.height/2,y:o-i.width/2}),L(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px",transform:v?null:"rotate(-90deg)"})}(yr(e,["bpmn:Task","bpmn:CallActivity"])||xg(e))&&(L(a,{width:i.width,height:i.height}),L(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px"})),function(e){return vr(e,"bpmn:SubProcess")&&Or(e)}(e)&&(L(a,{width:i.width,x:i.x}),L(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px"}));var y=90*s,g=7*s,b=4*s;if(n.labelTarget&&(L(a,{width:y,height:i.height+g+b,x:r-y/2,y:i.y-g}),L(f,{fontSize:l+"px",lineHeight:u,paddingTop:g+"px",paddingBottom:b+"px"})),zr(n)&&!Hr(n)&&!cn(n)){var _=Gr(e),x=t.getAbsoluteBBox({x:_.x,y:_.y,width:0,height:0}),w=l+g+b;L(a,{width:y,height:w,x:x.x-y/2,y:x.y-w/2}),L(f,{fontSize:l+"px",lineHeight:u,paddingTop:g+"px",paddingBottom:b+"px"})}return vr(e,"bpmn:TextAnnotation")&&(L(a,{width:i.width,height:i.height,minWidth:30*s,minHeight:10*s}),L(f,{textAlign:"left",paddingTop:5*s+"px",paddingBottom:7*s+"px",paddingLeft:7*s+"px",paddingRight:5*s+"px",fontSize:h+"px",lineHeight:d})),{bounds:a,style:f}},_g.prototype.update=function(e,t,n,i){var r,o,a;vr(e,"bpmn:TextAnnotation")&&(o=this._canvas.getAbsoluteBBox(e),r={x:e.x,y:e.y,width:e.width/o.width*i.width,height:e.height/o.height*i.height}),(a=t)&&a.trim()||(t=null),this._modeling.updateLabel(e,t,r)};var wg="djs-element-hidden",Eg="djs-label-hidden";function Sg(e,t,n){var i,r,o,a=this,s=t.getDefaultLayer();e.on("directEditing.activate",(function(e){var c=e.active;if(vr(i=c.element.label||c.element,"bpmn:TextAnnotation")){r=t.getAbsoluteBBox(i),o=Ae("g");var p=n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:i.width,containerHeight:i.height,position:{mx:0,my:0}}),l=a.path=Ae("path");_e(l,{d:p,strokeWidth:2,stroke:Cg(i)}),ye(o,l),ye(s,o),Wn(o,i.x,i.y)}vr(i,"bpmn:TextAnnotation")||i.labelTarget?t.addMarker(i,wg):(vr(i,"bpmn:Task")||vr(i,"bpmn:CallActivity")||vr(i,"bpmn:SubProcess")||vr(i,"bpmn:Participant")||vr(i,"bpmn:Lane"))&&t.addMarker(i,Eg)})),e.on("directEditing.resize",(function(e){if(vr(i,"bpmn:TextAnnotation")){var t=e.height,o=e.dy,s=Math.max(i.height/r.height*(t+o),0),c=n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:i.width,containerHeight:s,position:{mx:0,my:0}});_e(a.path,{d:c})}})),e.on(["directEditing.complete","directEditing.cancel"],(function(e){var n=e.active;n&&(t.removeMarker(n.element.label||n.element,wg),t.removeMarker(i,Eg)),i=void 0,r=void 0,o&&(Fe(o),o=void 0)}))}function Cg(e,t){return br(e).get("stroke")||t||"black"}Sg.$inject=["eventBus","canvas","pathMap"];var kg={__depends__:[To,bg,ey],__init__:["labelEditingProvider","labelEditingPreview"],labelEditingProvider:["type",_g],labelEditingPreview:["type",Sg]},Rg=new Eo("tt");function Pg(e,t){e.style.display=!1===t?"none":""}var Ag="djs-tooltip",Mg="."+Ag;function Tg(e,t){var n,i;this._eventBus=e,this._canvas=t,this._ids=Rg,this._tooltipDefaults={show:{minZoom:.7,maxZoom:5}},this._tooltips={},this._tooltipRoot=(n=t.getContainer(),q(i=he('<div class="djs-tooltip-container" />'),{position:"absolute",width:"0",height:"0"}),n.insertBefore(i,n.firstChild),i);var r=this;ce.bind(this._tooltipRoot,Mg,"mousedown",(function(e){e.stopPropagation()})),ce.bind(this._tooltipRoot,Mg,"mouseover",(function(e){r.trigger("mouseover",e)})),ce.bind(this._tooltipRoot,Mg,"mouseout",(function(e){r.trigger("mouseout",e)})),this._init()}Tg.$inject=["eventBus","canvas"],Tg.prototype.add=function(e){if(!e.position)throw new Error("must specifiy tooltip position");if(!e.html)throw new Error("must specifiy tooltip html");var t=this._ids.next();return e=L({},this._tooltipDefaults,e,{id:t}),this._addTooltip(e),e.timeout&&this.setTimeout(e),t},Tg.prototype.trigger=function(e,t){var n=t.delegateTarget||t.target,i=this.get(K(n,"data-tooltip-id"));i&&("mouseover"===e&&i.timeout&&this.clearTimeout(i),"mouseout"===e&&i.timeout&&(i.timeout=1e3,this.setTimeout(i)))},Tg.prototype.get=function(e){return"string"!=typeof e&&(e=e.id),this._tooltips[e]},Tg.prototype.clearTimeout=function(e){if(e=this.get(e)){var t=e.removeTimer;t&&(clearTimeout(t),e.removeTimer=null)}},Tg.prototype.setTimeout=function(e){if(e=this.get(e)){this.clearTimeout(e);var t=this;e.removeTimer=setTimeout((function(){t.remove(e)}),e.timeout)}},Tg.prototype.remove=function(e){var t=this.get(e);t&&(ve(t.html),ve(t.htmlContainer),delete t.htmlContainer,delete this._tooltips[t.id])},Tg.prototype.show=function(){Pg(this._tooltipRoot)},Tg.prototype.hide=function(){Pg(this._tooltipRoot,!1)},Tg.prototype._updateRoot=function(e){var t=e.scale||1,n=e.scale||1,i="matrix("+t+",0,0,"+n+","+-1*e.x*t+","+-1*e.y*n+")";this._tooltipRoot.style.transform=i,this._tooltipRoot.style["-ms-transform"]=i},Tg.prototype._addTooltip=function(e){var t,n=e.id,i=e.html,r=this._tooltipRoot;i.get&&i.constructor.prototype.jquery&&(i=i.get(0)),d(i)&&(i=he(i)),q(t=he('<div data-tooltip-id="'+n+'" class="'+Ag+'">'),{position:"absolute"}),t.appendChild(i),e.type&&X(t).add("djs-tooltip-"+e.type),e.className&&X(t).add(e.className),e.htmlContainer=t,r.appendChild(t),this._tooltips[n]=e,this._updateTooltip(e)},Tg.prototype._updateTooltip=function(e){var t=e.position;!function(e,t,n){q(e,{left:t+"px",top:n+"px"})}(e.htmlContainer,t.x,t.y)},Tg.prototype._updateTooltipVisibilty=function(e){g(this._tooltips,(function(t){var n=t.show,i=t.htmlContainer,r=!0;n&&((n.minZoom>e.scale||n.maxZoom<e.scale)&&(r=!1),Pg(i,r))}))},Tg.prototype._init=function(){var e=this;this._eventBus.on("canvas.viewbox.changing",(function(t){e.hide()})),this._eventBus.on("canvas.viewbox.changed",(function(t){var n;n=t.viewbox,e._updateRoot(n),e._updateTooltipVisibilty(n),e.show()}))};var Dg={__init__:["tooltips"],tooltips:["type",Tg]};function Bg(e,t,n){e.on(["shape.move.rejected","create.rejected"],(function(e){var i,r,o=e.context,a=o.shape;vr(o.target,"bpmn:Collaboration")&&vr(a,"bpmn:FlowNode")&&(i=e,r=n("flow elements must be children of pools/participants"),t.add({position:{x:i.x+5,y:i.y+5},type:"error",timeout:2e3,html:"<div>"+r+"</div>"}))}))}Bg.$inject=["eventBus","tooltips","translate"];var Ng={__depends__:[Dg],__init__:["modelingFeedback"],modelingFeedback:["type",Bg]};function jg(e,t){this._eventBus=e,this.offset=5;var n=t.cls("djs-outline",["no-fill"]),i=this;function r(e){var t=Ae("rect");return _e(t,L({x:0,y:0,rx:4,width:100,height:100},n)),t}e.on(["shape.added","shape.changed"],500,(function(e){var t=e.element,n=e.gfx,o=fe(".djs-outline",n);o||ye(n,o=i.getOutline(t)||r()),i.updateShapeOutline(o,t)})),e.on(["connection.added","connection.changed"],(function(e){var t=e.element,n=e.gfx,o=fe(".djs-outline",n);o||ye(n,o=r()),i.updateConnectionOutline(o,t)}))}jg.prototype.updateShapeOutline=function(e,t){var n=!1,i=this._getProviders();i.length&&g(i,(function(i){n=n||i.updateOutline(t,e)})),n||_e(e,{x:-this.offset,y:-this.offset,width:t.width+2*this.offset,height:t.height+2*this.offset})},jg.prototype.updateConnectionOutline=function(e,t){var n=ht(t);_e(e,{x:n.x-this.offset,y:n.y-this.offset,width:n.width+2*this.offset,height:n.height+2*this.offset})},jg.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("outline.getProviders",e,(function(e){e.providers.push(t)}))},jg.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"outline.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},jg.prototype.getOutline=function(e){var t;return g(this._getProviders(),(function(n){h(n.getOutline)&&(t=t||n.getOutline(e))})),t},jg.$inject=["eventBus","styles","elementRegistry"];function Og(e,t,n){this._canvas=t;var i=this;e.on("element.changed",(function(e){n.isSelected(e.element)&&i._updateMultiSelectionOutline(n.get())})),e.on("selection.changed",(function(e){var t=e.newSelection;i._updateMultiSelectionOutline(t)}))}Og.prototype._updateMultiSelectionOutline=function(e){var t=this._canvas.getLayer("selectionOutline");Se(t);var n=e.length>1;if(we(this._canvas.getContainer())[n?"add":"remove"]("djs-multi-select"),n){var i=function(e){return{x:e.x-6,y:e.y-6,width:e.width+12,height:e.height+12}}(ht(e)),r=Ae("rect");_e(r,L({rx:3},i)),we(r).add("djs-selection-outline"),ye(t,r)}},Og.$inject=["eventBus","canvas","selection"];var Lg={__depends__:[_a],__init__:["outline","multiSelectionOutline"],outline:["type",jg],multiSelectionOutline:["type",Og]},$g=Math.round;function Ig(e,t,n,i,r){function o(e,t,n,i){return r.allowed("elements.move",{shapes:e,delta:t,position:n,target:i})}function a(e,n,i,r){if(l(i)&&(r=i,i=!1),!n.waypoints&&n.parent&&!we(e.target).has("djs-hit-no-move")){var o=function(e){return{x:e.x+$g(e.width/2),y:e.y+$g(e.height/2)}}(n);return t.init(e,o,"shape.move",{cursor:"grabbing",autoActivate:i,data:{shape:n,context:r||{}}}),!0}}e.on("shape.move.start",1500,(function(e){var t=e.context,n=e.shape,r=i.get().slice();-1===r.indexOf(n)&&(r=[n]),r=function(e){var t=k(e,"id");return y(e,(function(e){for(;e=e.parent;)if(t[e.id])return!1;return!0}))}(r),L(t,{shapes:r,validatedShapes:r,shape:n})})),e.on("shape.move.start",1250,(function(e){var t=e.context,n=t.validatedShapes;if(!(t.canExecute=o(n)))return!1})),e.on("shape.move.move",500,(function(e){var t,n=e.context,i=n.validatedShapes,r=e.hover,a={x:e.dx,y:e.dy};t=o(i,a,{x:e.x,y:e.y},r),n.delta=a,n.canExecute=t,n.target=null!==t?r:null})),e.on("shape.move.end",(function(e){var t=e.context,i=t.delta,r=t.canExecute,o="attach"===r,a=t.shapes;if(!1===r)return!1;i.x=$g(i.x),i.y=$g(i.y),0===i.x&&0===i.y||n.moveElements(a,i,t.target,{primaryShape:t.shape,attach:o})})),e.on("element.mousedown",(function(e){if(sa(e)){var t=na(e);if(!t)throw new Error("must supply DOM mousedown event");return a(t,e.element)}})),this.start=a}Ig.$inject=["eventBus","dragging","modeling","selection","rules"];var Fg="djs-dragging",zg="drop-ok",Hg="drop-not-ok",Vg="new-parent",Gg="attach-ok";function Wg(e,t,n,r){function o(e){var t=function(e){var t=y(e,(function(t){return!sn(t)||m(e,M({id:t.source.id}))&&m(e,M({id:t.target.id}))}));return t}(a(e));return t}function a(e){var t=ut(e,!0),n=t.flatMap((e=>(e.incoming||[]).concat(e.outgoing||[]))),i=t.concat(n);return[...new Set(i)]}function s(e,n){[Gg,zg,Hg,Vg].forEach((function(i){i===n?t.addMarker(e,i):t.removeMarker(e,i)}))}e.on("shape.move.start",499,(function(e){var s,c=e.context,p=c.shapes,l=c.allDraggedElements,u=o(p);if(!c.dragGroup){var h=Ae("g");_e(h,n.cls("djs-drag-group",["no-events"])),ye(t.getActiveLayer(),h),c.dragGroup=h}u.forEach((function(e){r.addDragger(e,c.dragGroup)})),g(l=l?i([l,a(p)]):a(p),(function(e){t.addMarker(e,Fg)})),c.allDraggedElements=l,c.differentParents=1!==(s=k(p,(function(e){return e.parent&&e.parent.id})),S(s).length)})),e.on("shape.move.move",499,(function(e){var t=e.context,n=t.dragGroup,i=t.target,r=t.shape.parent,o=t.canExecute;i&&("attach"===o?s(i,Gg):t.canExecute&&r&&i.id!==r.id?s(i,Vg):s(i,t.canExecute?zg:Hg)),Wn(n,e.dx,e.dy)})),e.on(["shape.move.out","shape.move.cleanup"],(function(e){var t=e.context.target;t&&s(t,null)})),e.on("shape.move.cleanup",(function(e){var n=e.context,i=n.allDraggedElements,r=n.dragGroup;g(i,(function(e){t.removeMarker(e,Fg)})),r&&Fe(r)})),this.makeDraggable=function(e,n,i){r.addDragger(n,e.dragGroup),i&&t.addMarker(n,Fg),e.allDraggedElements?e.allDraggedElements.push(n):e.allDraggedElements=[n]}}Wg.$inject=["eventBus","canvas","styles","previewSupport"];var Ug={__depends__:[da,_a,Lg,xp,vp,Al],__init__:["move","movePreview"],move:["type",Ig],movePreview:["type",Wg]},qg=".djs-palette-toggle",Kg=".entry",Yg=qg+", "+Kg,Xg="djs-palette-",Zg="open",Qg="two-column";function Jg(e,t){this._eventBus=e,this._canvas=t;var n=this;e.on("tool-manager.update",(function(e){var t=e.tool;n.updateToolHighlight(t)})),e.on("i18n.changed",(function(){n._update()})),e.on("diagram.init",(function(){n._diagramInitialized=!0,n._rebuild()}))}function eb(e,t){var n=t.getPaletteEntries();return h(n)?n(e):(g(n,(function(t,n){e[n]=t})),e)}Jg.$inject=["eventBus","canvas"],Jg.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("palette.getProviders",e,(function(e){e.providers.push(t)})),this._rebuild()},Jg.prototype.getEntries=function(){return this._getProviders().reduce(eb,{})},Jg.prototype._rebuild=function(){this._diagramInitialized&&(this._getProviders().length&&(this._container||this._init(),this._update()))},Jg.prototype._init=function(){var e=this,t=this._eventBus,n=this._getParentContainer(),i=this._container=he(Jg.HTML_MARKUP);n.appendChild(i),X(n).add(Xg+"shown"),ce.bind(i,Yg,"click",(function(t){if(de(t.delegateTarget,qg))return e.toggle();e.trigger("click",t)})),oe.bind(i,"mousedown",(function(e){e.stopPropagation()})),ce.bind(i,Kg,"dragstart",(function(t){e.trigger("dragstart",t)})),t.on("canvas.resized",this._layoutChanged,this),t.fire("palette.create",{container:i})},Jg.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(t),t.providers},Jg.prototype._toggleState=function(e){e=e||{};var t,n=this._getParentContainer(),i=this._container,r=this._eventBus,o=X(i),a=X(n);t="twoColumn"in e?e.twoColumn:this._needsCollapse(n.clientHeight,this._entries||{}),o.toggle(Qg,t),a.toggle(Xg+Qg,t),"open"in e&&(o.toggle(Zg,e.open),a.toggle(Xg+Zg,e.open)),r.fire("palette.changed",{twoColumn:t,open:this.isOpen()})},Jg.prototype._update=function(){var e=fe(".djs-palette-entries",this._container),t=this._entries=this.getEntries();Q(e),g(t,(function(t,n){var i=t.group||"default",r=fe("[data-group="+Oo(i)+"]",e);r||(K(r=he('<div class="group"></div>'),"data-group",i),e.appendChild(r));var o=t.html||(t.separator?'<hr class="separator" />':'<div class="entry" draggable="true"></div>'),a=he(o);if(r.appendChild(a),!t.separator&&(K(a,"data-action",n),t.title&&K(a,"title",t.title),t.className&&function(e,t){var n=X(e);(p(t)?t:t.split(/\s+/g)).forEach((function(e){n.add(e)}))}(a,t.className),t.imageUrl)){var s=he("<img>");K(s,"src",t.imageUrl),a.appendChild(s)}})),this.open()},Jg.prototype.trigger=function(e,t,n){var i,r,o=t.delegateTarget||t.target;return o?(i=K(o,"data-action"),r=t.originalEvent||t,this.triggerEntry(i,e,r,n)):t.preventDefault()},Jg.prototype.triggerEntry=function(e,t,n,i){var r,o;if((r=this._entries[e])&&(o=r.action,!1!==this._eventBus.fire("palette.trigger",{entry:r,event:n}))){if(h(o)){if("click"===t)return o(n,i)}else if(o[t])return o[t](n,i);n.preventDefault()}},Jg.prototype._layoutChanged=function(){this._toggleState({})},Jg.prototype._needsCollapse=function(e,t){return e<46*Object.keys(t).length+50},Jg.prototype.close=function(){this._toggleState({open:!1,twoColumn:!1})},Jg.prototype.open=function(){this._toggleState({open:!0})},Jg.prototype.toggle=function(){this.isOpen()?this.close():this.open()},Jg.prototype.isActiveTool=function(e){return e&&this._activeTool===e},Jg.prototype.updateToolHighlight=function(e){var t;this._toolsContainer||(t=fe(".djs-palette-entries",this._container),this._toolsContainer=fe("[data-group=tools]",t)),g(this._toolsContainer.children,(function(t){var n=t.getAttribute("data-action");if(n){var i=X(t);n=n.replace("-tool",""),i.contains("entry")&&n===e?i.add("highlighted-entry"):i.remove("highlighted-entry")}}))},Jg.prototype.isOpen=function(){return X(this._container).has(Zg)},Jg.prototype._getParentContainer=function(){return this._canvas.getContainer()},Jg.HTML_MARKUP='<div class="djs-palette"><div class="djs-palette-entries"></div><div class="djs-palette-toggle"></div></div>';var tb={__init__:["palette"],palette:["type",Jg]},nb="crosshair";function ib(e,t,n,i,r,o,a){this._selection=r,this._dragging=n,this._mouse=a;var s=this,c=function(e){var n,i=t.getActiveLayer();_e(n=e.frame=Ae("rect"),{class:"djs-lasso-overlay",width:1,height:1,x:0,y:0}),ye(i,n)},p=function(e){var t=e.frame,n=e.bbox;_e(t,{x:n.x,y:n.y,width:n.width,height:n.height})},l=function(e){e.frame&&Fe(e.frame)};o.registerTool("lasso",{tool:"lasso.selection",dragging:"lasso"}),e.on("lasso.selection.end",(function(t){var n=t.originalEvent.target;(t.hover||n instanceof SVGElement)&&e.once("lasso.selection.ended",(function(){s.activateLasso(t.originalEvent,!0)}))})),e.on("lasso.end",0,(function(e){var t=e.context,n=rb(e),r=i.filter((function(e){return e})),o=pa(e);s.select(r,n,o?t.selection:[])})),e.on("lasso.start",(function(e){var t=e.context;t.bbox=rb(e),c(t),t.selection=r.get()})),e.on("lasso.move",(function(e){var t=e.context;t.bbox=rb(e),p(t)})),e.on("lasso.cleanup",(function(e){var t=e.context;l(t)})),e.on("element.mousedown",1500,(function(e){if(pa(e))return s.activateLasso(e.originalEvent),!0}))}function rb(e){var t={x:e.x-e.dx,y:e.y-e.dy},n={x:e.x,y:e.y};return t.x<=n.x&&t.y<n.y||t.x<n.x&&t.y<=n.y?{x:t.x,y:t.y,width:n.x-t.x,height:n.y-t.y}:t.x>=n.x&&t.y<n.y||t.x>n.x&&t.y<=n.y?{x:n.x,y:t.y,width:t.x-n.x,height:n.y-t.y}:t.x<=n.x&&t.y>n.y||t.x<n.x&&t.y>=n.y?{x:t.x,y:n.y,width:n.x-t.x,height:t.y-n.y}:t.x>=n.x&&t.y>n.y||t.x>n.x&&t.y>=n.y?{x:n.x,y:n.y,width:t.x-n.x,height:t.y-n.y}:{x:n.x,y:n.y,width:0,height:0}}ib.$inject=["eventBus","canvas","dragging","elementRegistry","selection","toolManager","mouse"],ib.prototype.activateLasso=function(e,t){this._dragging.init(e,"lasso",{autoActivate:t,cursor:nb,data:{context:{}}})},ib.prototype.activateSelection=function(e,t){this._dragging.init(e,"lasso.selection",{trapClick:!1,autoActivate:t,cursor:nb,data:{context:{}},keepSelection:!0})},ib.prototype.select=function(e,t,n=[]){var i=dt(e,t);this._selection.select([...n,...C(i)])},ib.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},ib.prototype.isActive=function(){var e=this._dragging.context();return e&&/^lasso/.test(e.prefix)};var ob={__depends__:[xf,Jd],__init__:["lassoTool"],lassoTool:["type",ib]},ab=1500,sb="grab";function cb(e,t,n,i,r,o){this._dragging=n,this._mouse=o;var a=this,s=i.get("keyboard",!1);r.registerTool("hand",{tool:"hand",dragging:"hand.move"}),e.on("element.mousedown",ab,(function(e){if(ca(e))return a.activateMove(e.originalEvent,!0),!1})),s&&s.addListener(ab,(function(e){if(pb(e.keyEvent)&&!a.isActive()){var t=a._mouse.getLastMoveEvent();a.activateMove(t,!!t)}}),"keyboard.keydown"),s&&s.addListener(ab,(function(e){pb(e.keyEvent)&&a.isActive()&&a.toggle()}),"keyboard.keyup"),e.on("hand.end",(function(t){var n=t.originalEvent.target;if(!(t.hover||n instanceof SVGElement))return!1;e.once("hand.ended",(function(){a.activateMove(t.originalEvent,{reactivate:!0})}))})),e.on("hand.move.move",(function(e){var n=t.viewbox().scale;t.scroll({dx:e.dx*n,dy:e.dy*n})})),e.on("hand.move.end",(function(t){var n=t.context.reactivate;return!ca(t)&&n&&e.once("hand.move.ended",(function(e){a.activateHand(e.originalEvent,!0,!0)})),!1}))}function pb(e){return Ra("Space",e)}cb.$inject=["eventBus","canvas","dragging","injector","toolManager","mouse"],cb.prototype.activateMove=function(e,t,n){"object"==typeof t&&(n=t,t=!1),this._dragging.init(e,"hand.move",{autoActivate:t,cursor:sb,data:{context:n||{}}})},cb.prototype.activateHand=function(e,t,n){this._dragging.init(e,"hand",{trapClick:!1,autoActivate:t,cursor:sb,data:{context:{reactivate:n}}})},cb.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateHand(e,!!e)},cb.prototype.isActive=function(){var e=this._dragging.context();return!!e&&/^(hand|hand\.move)$/.test(e.prefix)};var lb={__depends__:[xf,Jd],__init__:["handTool"],handTool:["type",cb]},ub="connect-ok",hb="connect-not-ok";function db(e,t,n,i,r,o,a){var s=this;this._dragging=t,this._rules=o,this._mouse=a,r.registerTool("global-connect",{tool:"global-connect",dragging:"global-connect.drag"}),e.on("global-connect.hover",(function(e){var t=e.context,n=e.hover,r=t.canStartConnect=s.canStartConnect(n);null!==r&&(t.startTarget=n,i.addMarker(n,r?ub:hb))})),e.on(["global-connect.out","global-connect.cleanup"],(function(e){var t=e.context.startTarget,n=e.context.canStartConnect;t&&i.removeMarker(t,n?ub:hb)})),e.on(["global-connect.ended"],(function(t){var i=t.context.startTarget,r={x:t.x,y:t.y};if(s.canStartConnect(i))return e.once("element.out",(function(){e.once(["connect.ended","connect.canceled"],(function(){e.fire("global-connect.drag.ended")})),n.start(null,i,r)})),!1}))}db.$inject=["eventBus","dragging","connect","canvas","toolManager","rules","mouse"],db.prototype.start=function(e,t){this._dragging.init(e,"global-connect",{autoActivate:t,trapClick:!1,data:{context:{}}})},db.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();return this.start(e,!!e)},db.prototype.isActive=function(){var e=this._dragging.context();return e&&/^global-connect/.test(e.prefix)},db.prototype.canStartConnect=function(e){return this._rules.allowed("connection.start",{source:e})};var fb={__depends__:[wl,xp,vp,xf,Jd],globalConnect:["type",db]};function mb(e,t,n,i,r,o,a,s){this._palette=e,this._create=t,this._elementFactory=n,this._spaceTool=i,this._lassoTool=r,this._handTool=o,this._globalConnect=a,this._translate=s,e.registerProvider(this)}mb.$inject=["palette","create","elementFactory","spaceTool","lassoTool","handTool","globalConnect","translate"],mb.prototype.getPaletteEntries=function(){var e={},t=this._create,n=this._elementFactory,i=this._spaceTool,r=this._lassoTool,o=this._handTool,a=this._globalConnect,s=this._translate;function c(e,i,r,o,a){function s(i){var r=n.createShape(L({type:e},a));t.start(i,r)}return{group:i,className:r,title:o,action:{dragstart:s,click:s}}}function p(e){var i=n.createShape({type:"bpmn:SubProcess",x:0,y:0,isExpanded:!0}),r=n.createShape({type:"bpmn:StartEvent",x:40,y:82,parent:i});t.start(e,[i,r],{hints:{autoSelect:[i]}})}function l(e){t.start(e,n.createParticipantShape())}return L(e,{"hand-tool":{group:"tools",className:"bpmn-icon-hand-tool",title:s("Activate hand tool"),action:{click:function(e){o.activateHand(e)}}},"lasso-tool":{group:"tools",className:"bpmn-icon-lasso-tool",title:s("Activate lasso tool"),action:{click:function(e){r.activateSelection(e)}}},"space-tool":{group:"tools",className:"bpmn-icon-space-tool",title:s("Activate create/remove space tool"),action:{click:function(e){i.activateSelection(e)}}},"global-connect-tool":{group:"tools",className:"bpmn-icon-connection-multi",title:s("Activate global connect tool"),action:{click:function(e){a.start(e)}}},"tool-separator":{group:"tools",separator:!0},"create.start-event":c("bpmn:StartEvent","event","bpmn-icon-start-event-none",s("Create start event")),"create.intermediate-event":c("bpmn:IntermediateThrowEvent","event","bpmn-icon-intermediate-event-none",s("Create intermediate/boundary event")),"create.end-event":c("bpmn:EndEvent","event","bpmn-icon-end-event-none",s("Create end event")),"create.exclusive-gateway":c("bpmn:ExclusiveGateway","gateway","bpmn-icon-gateway-none",s("Create gateway")),"create.task":c("bpmn:Task","activity","bpmn-icon-task",s("Create task")),"create.data-object":c("bpmn:DataObjectReference","data-object","bpmn-icon-data-object",s("Create data object reference")),"create.data-store":c("bpmn:DataStoreReference","data-store","bpmn-icon-data-store",s("Create data store reference")),"create.subprocess-expanded":{group:"activity",className:"bpmn-icon-subprocess-expanded",title:s("Create expanded sub-process"),action:{dragstart:p,click:p}},"create.participant-expanded":{group:"collaboration",className:"bpmn-icon-participant",title:s("Create pool/participant"),action:{dragstart:l,click:l}},"create.group":c("bpmn:Group","artifact","bpmn-icon-group",s("Create group"))}),e};var vb={__depends__:[tb,Zd,If,ob,lb,fb,yo],__init__:["paletteProvider"],paletteProvider:["type",mb]};function yb(e,t,n,i,r){Do.call(this,e),e.on("shape.move.move",250,(function(e){var o=e.context,a=o.canExecute;o.visualReplacements||(o.visualReplacements={}),a&&a.replacements?function(e){g(e.canExecute.replacements,(function(o){var a=o.oldElementId,s={type:o.newElementType};if(!e.visualReplacements[a]){var c=t.get(a);L(s,{x:c.x,y:c.y});var p=n.createShape(s);i.addShape(p,c.parent);var l=fe('[data-element-id="'+Oo(c.id)+'"]',e.dragGroup);l&&_e(l,{display:"none"});var u=r.addDragger(p,e.dragGroup);e.visualReplacements[a]=u,i.removeShape(p)}}))}(o):function(e){var t=e.visualReplacements;g(t,(function(n,i){var r=fe('[data-element-id="'+Oo(i)+'"]',e.dragGroup);r&&_e(r,{display:"inline"}),n.remove(),t[i]&&delete t[i]}))}(o)}))}yb.$inject=["eventBus","elementRegistry","elementFactory","canvas","previewSupport"],e(yb,Do);var gb={__depends__:[Al],__init__:["bpmnReplacePreview"],bpmnReplacePreview:["type",yb]},bb=40,_b=["x","y"],xb=Math.abs;function wb(e){e.on(["connect.hover","connect.move","connect.end"],1250,(function(e){var t=e.context,n=t.canExecute,i=t.start,r=t.hover,o=t.source,a=t.target;e.originalEvent&&ka(e.originalEvent)||(t.initialConnectionStart||(t.initialConnectionStart=t.connectionStart),n&&r&&function(e,t,n){_b.forEach((function(i){var r=Cb(i,t);e[i]<t[i]+n?ul(e,i,t[i]+n):e[i]>t[i]+r-n&&ul(e,i,t[i]+r-n)}))}(e,r,function(e){return vr(e,"bpmn:Task")?10:20}(r)),r&&function(e,t){return w(t,(function(t){return Sb(e,t)}))}(n,["bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:SequenceFlow"])?(t.connectionStart=pl(i),yr(r,["bpmn:Event","bpmn:Gateway"])&&Eb(e,pl(r)),yr(r,["bpmn:Task","bpmn:SubProcess"])&&function(e,t){var n=pl(t);_b.forEach((function(i){(function(e,t,n){return e[n]>t[n]+20&&e[n]<t[n]+Cb(n,t)-20})(e,t,i)&&ul(e,i,n[i])}))}(e,r),vr(o,"bpmn:BoundaryEvent")&&a===o.host&&function(e){var t=e.context,n=t.source,i=t.target;if(function(e){var t=e.hover,n=e.source;return t&&n&&t===n}(t))return;var r=pl(n),o=mn(r,i,-10),a=[];/top|bottom/.test(o)&&a.push("x");/left|right/.test(o)&&a.push("y");a.forEach((function(t){var n,i=e[t];xb(i-r[t])<bb&&(n=i>r[t]?r[t]+bb:r[t]-bb,ul(e,t,n))}))}(e)):Sb(n,"bpmn:MessageFlow")?(vr(i,"bpmn:Event")&&(t.connectionStart=pl(i)),vr(r,"bpmn:Event")&&Eb(e,pl(r))):t.connectionStart=t.initialConnectionStart)}))}function Eb(e,t){ul(e,"x",t.x),ul(e,"y",t.y)}function Sb(e,t){return e&&e.type===t}function Cb(e,t){return"x"===e?t.width:t.height}function kb(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}function Rb(){this._snapValues={}}wb.$inject=["eventBus"],kb.prototype.getSnapOrigin=function(e){return this._snapOrigins[e]},kb.prototype.setSnapOrigin=function(e,t){this._snapOrigins[e]=t,-1===this._snapLocations.indexOf(e)&&this._snapLocations.push(e)},kb.prototype.addDefaultSnap=function(e,t){var n=this._defaultSnaps[e];n||(n=this._defaultSnaps[e]=[]),n.push(t)},kb.prototype.getSnapLocations=function(){return this._snapLocations},kb.prototype.setSnapLocations=function(e){this._snapLocations=e},kb.prototype.pointsForTarget=function(e){var t=e.id||e,n=this._targets[t];return n||(n=this._targets[t]=new Rb).initDefaults(this._defaultSnaps),n},Rb.prototype.add=function(e,t){var n=this._snapValues[e];n||(n=this._snapValues[e]={x:[],y:[]}),-1===n.x.indexOf(t.x)&&n.x.push(t.x),-1===n.y.indexOf(t.y)&&n.y.push(t.y)},Rb.prototype.snap=function(e,t,n,i){var r=this._snapValues[t];return r&&function(e,t,n){var i,r;for(n=void 0===n?10:n,i=0;i<t.length;i++)if(r=t[i],ol(r-e)<=n)return r}(e[n],r[n],i)},Rb.prototype.initDefaults=function(e){var t=this;g(e||{},(function(e,n){g(e,(function(e){t.add(n,e)}))}))};function Pb(e,t,n){var i=this;this._elementRegistry=e,t.on(["create.start","shape.move.start"],(function(e){i.initSnap(e)})),t.on(["create.move","create.end","shape.move.move","shape.move.end"],1250,(function(e){var t=e.context,r=t.shape,o=t.snapContext,a=t.target;if((!e.originalEvent||!ka(e.originalEvent))&&!ll(e)&&a){var s=o.pointsForTarget(a);s.initialized||((s=i.addSnapTargetPoints(s,r,a)).initialized=!0),n.snap(e,s)}})),t.on(["create.cleanup","shape.move.cleanup"],(function(){n.hide()}))}Pb.$inject=["elementRegistry","eventBus","snapping"],Pb.prototype.initSnap=function(e){var t,n=this._elementRegistry,i=e.context,r=i.shape,o=i.snapContext;o||(o=i.snapContext=new kb);var a=(t=n.get(r.id)?pl(r,e):{x:e.x+pl(r).x,y:e.y+pl(r).y}).x-r.width/2,s=t.y-r.height/2,c=t.x+r.width/2,p=t.y+r.height/2;return o.setSnapOrigin("mid",{x:t.x-e.x,y:t.y-e.y}),cn(r)||(o.setSnapOrigin("top-left",{x:a-e.x,y:s-e.y}),o.setSnapOrigin("bottom-right",{x:c-e.x,y:p-e.y})),o},Pb.prototype.addSnapTargetPoints=function(e,t,n){return g(this.getSnapTargets(t,n),(function(n){if(cn(n))cn(t)&&e.add("mid",pl(n));else if(sn(n)){if(n.waypoints.length<3)return;g(n.waypoints.slice(1,-1),(function(t){e.add("mid",t)}))}else e.add("mid",pl(n))})),u(t.x)&&u(t.y)?(this._elementRegistry.get(t.id)&&e.add("mid",pl(t)),e):e},Pb.prototype.getSnapTargets=function(e,t){return hl(t).filter((function(e){return!e.hidden}))};function Ab(e,t){t.invoke(Pb,this),e.on(["create.move","create.end"],1500,Mb),e.on(["create.move","create.end","shape.move.move","shape.move.end"],1500,(function(e){var t=e.context,n=t.canExecute,i=t.target;n&&("attach"===n||n.attach)&&!ll(e)&&function(e,t){var n,i=un(t),r=td(e,t),o=e.context,a=o.shape;n=a.parent?{x:0,y:0}:fn(a);/top/.test(r)?ul(e,"y",i.top-n.y):/bottom/.test(r)&&ul(e,"y",i.bottom-n.y);/left/.test(r)?ul(e,"x",i.left-n.x):/right/.test(r)&&ul(e,"x",i.right-n.x)}(e,i)}))}function Mb(e){var t=e.context.createConstraints;if(t){var n=t.top,i=t.right,r=t.bottom,o=t.left;(o&&o>=e.x||i&&i<=e.x)&&ul(e,"x",e.x),(n&&n>=e.y||r&&r<=e.y)&&ul(e,"y",e.y)}}function Tb(e,t){return-1!==e.indexOf(t)}function Db(e,t,n){return t?{x:e.x-n.x,y:e.y-n.y}:{x:e.x,y:e.y}}e(Ab,Pb),Ab.$inject=["eventBus","injector"],Ab.prototype.initSnap=function(e){var t=Pb.prototype.initSnap.call(this,e),n=e.shape,i=!!this._elementRegistry.get(n.id);return g(n.outgoing,(function(n){var r=n.waypoints[0];r=r.original||r,t.setSnapOrigin(n.id+"-docking",Db(r,i,e))})),g(n.incoming,(function(n){var r=n.waypoints[n.waypoints.length-1];r=r.original||r,t.setSnapOrigin(n.id+"-docking",Db(r,i,e))})),vr(n,"bpmn:Participant")&&t.setSnapLocations(["top-left","bottom-right","mid"]),t},Ab.prototype.addSnapTargetPoints=function(e,t,n){Pb.prototype.addSnapTargetPoints.call(this,e,t,n);var i=this.getSnapTargets(t,n);g(i,(function(n){var i;(function(e){if(vr(e,"bpmn:SubProcess")&&Or(e))return!0;return vr(e,"bpmn:Participant")}(n)||(i="bpmn:TextAnnotation",[t,n].every((function(e){return vr(e,i)}))))&&(e.add("top-left",sl(n)),e.add("bottom-right",cl(n)))}));var r=this._elementRegistry;return g(t.incoming,(function(n){if(r.get(t.id)){Tb(i,n.source)||e.add("mid",fn(n.source));var o=n.waypoints[0];e.add(n.id+"-docking",o.original||o)}})),g(t.outgoing,(function(n){if(r.get(t.id)){Tb(i,n.target)||e.add("mid",fn(n.target));var o=n.waypoints[n.waypoints.length-1];e.add(n.id+"-docking",o.original||o)}})),vr(n,"bpmn:SequenceFlow")&&(e=this.addSnapTargetPoints(e,t,n.parent)),e},Ab.prototype.getSnapTargets=function(e,t){return Pb.prototype.getSnapTargets.call(this,e,t).filter((function(e){return!vr(e,"bpmn:Lane")}))};function Bb(e,t){var n=this;e.on(["resize.start"],(function(e){n.initSnap(e)})),e.on(["resize.move","resize.end"],1250,(function(e){var i=e.context,r=i.shape,o=r.parent,a=i.direction,s=i.snapContext;if(!(e.originalEvent&&ka(e.originalEvent)||ll(e))){var c=s.pointsForTarget(o);c.initialized||((c=n.addSnapTargetPoints(c,r,o,a)).initialized=!0),function(e){return"n"===e||"s"===e}(a)&&ul(e,"x",e.x),function(e){return"e"===e||"w"===e}(a)&&ul(e,"y",e.y),t.snap(e,c)}})),e.on(["resize.cleanup"],(function(){t.hide()}))}function Nb(e,t){var n=fn(e),i=un(e),r={x:n.x,y:n.y};return-1!==t.indexOf("n")?r.y=i.top:-1!==t.indexOf("s")&&(r.y=i.bottom),-1!==t.indexOf("e")?r.x=i.right:-1!==t.indexOf("w")&&(r.x=i.left),r}Bb.prototype.initSnap=function(e){var t=e.context,n=t.shape,i=t.direction,r=t.snapContext;r||(r=t.snapContext=new kb);var o=Nb(n,i);return r.setSnapOrigin("corner",{x:o.x-e.x,y:o.y-e.y}),r},Bb.prototype.addSnapTargetPoints=function(e,t,n,i){return g(this.getSnapTargets(t,n),(function(t){e.add("corner",cl(t)),e.add("corner",sl(t))})),e.add("corner",Nb(t,i)),e},Bb.$inject=["eventBus","snapping"],Bb.prototype.getSnapTargets=function(e,t){return hl(t).filter((function(t){return!(n=t,i=e,n.host===i||sn(t)||function(e){return!!e.hidden}(t)||cn(t));var n,i}))};function jb(e){this._canvas=e,this._asyncHide=j(O(this.hide,this),1e3)}jb.$inject=["canvas"],jb.prototype.snap=function(e,t){var n=e.context.snapContext,i=n.getSnapLocations(),r={x:ll(e,"x"),y:ll(e,"y")};g(i,(function(i){var o=n.getSnapOrigin(i),a={x:e.x+o.x,y:e.y+o.y};if(g(["x","y"],(function(e){var n;r[e]||void 0!==(n=t.snap(a,i,e,7))&&(r[e]={value:n,originValue:n-o[e]})})),r.x&&r.y)return!1})),this.showSnapLine("vertical",r.x&&r.x.value),this.showSnapLine("horizontal",r.y&&r.y.value),g(["x","y"],(function(t){var n=r[t];l(n)&&ul(e,t,n.originValue)}))},jb.prototype._createLine=function(e){var t=this._canvas.getLayer("snap"),n=Ae("path");return _e(n,{d:"M0,0 L0,0"}),we(n).add("djs-snap-line"),ye(t,n),{update:function(t){u(t)?_e(n,"horizontal"===e?{d:"M-100000,"+t+" L+100000,"+t,display:""}:{d:"M "+t+",-100000 L "+t+", +100000",display:""}):_e(n,{display:"none"})}}},jb.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}},jb.prototype.showSnapLine=function(e,t){var n=this.getSnapLine(e);n&&n.update(t),this._asyncHide()},jb.prototype.getSnapLine=function(e){return this._snapLines||this._createSnapLines(),this._snapLines[e]},jb.prototype.hide=function(){g(this._snapLines,(function(e){e.update()}))};var Ob={__depends__:[{__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",Pb],resizeSnapping:["type",Bb],snapping:["type",jb]}],__init__:["connectSnapping","createMoveSnapping"],connectSnapping:["type",wb],createMoveSnapping:["type",Ab]};function Lb(e,t,n,i){this._open=!1,this._results={},this._eventMaps=[],this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._canvas=e,this._eventBus=t,this._selection=n,this._translate=i,this._container=this._getBoxHtml(),this._searchInput=fe(Lb.INPUT_SELECTOR,this._container),this._resultsContainer=fe(Lb.RESULTS_CONTAINER_SELECTOR,this._container),this._canvas.getContainer().appendChild(this._container),t.on(["canvas.destroy","diagram.destroy","drag.init","elements.changed"],this.close,this)}function $b(e,t,n){var i=function(e){var t="";return e.forEach((function(e){var n=$o(e.value||e.matched||e.normal),i=e.match||e.matched;t+=i?'<b class="'+Lb.RESULT_HIGHLIGHT_CLASS+'">'+n+"</b>":n})),""!==t?t:null}(t),r=he(n);r.innerHTML=i,e.appendChild(r)}Lb.$inject=["canvas","eventBus","selection","translate"],Lb.prototype._bindEvents=function(){var e=this;function t(t,n,i,r){e._eventMaps.push({el:t,type:i,listener:ce.bind(t,n,i,r)})}t(document,"html","click",(function(t){e.close(!1)})),t(this._container,Lb.INPUT_SELECTOR,"click",(function(e){e.stopPropagation(),e.delegateTarget.focus()})),t(this._container,Lb.RESULT_SELECTOR,"mouseover",(function(t){t.stopPropagation(),e._scrollToNode(t.delegateTarget),e._preselect(t.delegateTarget)})),t(this._container,Lb.RESULT_SELECTOR,"click",(function(t){t.stopPropagation(),e._select(t.delegateTarget)})),t(this._container,Lb.INPUT_SELECTOR,"keydown",(function(e){Ra("ArrowUp",e)&&e.preventDefault(),Ra("ArrowDown",e)&&e.preventDefault()})),t(this._container,Lb.INPUT_SELECTOR,"keyup",(function(t){if(Ra("Escape",t))return e.close();if(Ra("Enter",t)){var n=e._getCurrentResult();return n?e._select(n):e.close(!1)}return Ra("ArrowUp",t)?e._scrollToDirection(!0):Ra("ArrowDown",t)?e._scrollToDirection():void(Ra(["ArrowLeft","ArrowRight"],t)||e._search(t.delegateTarget.value))}))},Lb.prototype._unbindEvents=function(){this._eventMaps.forEach((function(e){ce.unbind(e.el,e.type,e.listener)}))},Lb.prototype._search=function(e){var t=this;if(this._clearResults(),e.trim()){var n=this._searchProvider.find(e);if((n=n.filter((function(e){return!t._canvas.getRootElements().includes(e.element)}))).length){n.forEach((function(e){var n=e.element.id,i=t._createResultNode(e,n);t._results[n]={element:e.element,node:i}}));var i=fe(Lb.RESULT_SELECTOR,this._resultsContainer);this._scrollToNode(i),this._preselect(i)}else this._selection.select(null)}},Lb.prototype._scrollToDirection=function(e){var t=this._getCurrentResult();if(t){var n=e?t.previousElementSibling:t.nextElementSibling;n&&(this._scrollToNode(n),this._preselect(n))}},Lb.prototype._scrollToNode=function(e){if(e&&e!==this._getCurrentResult()){var t=e.offsetTop,n=this._resultsContainer.scrollTop,i=t-this._resultsContainer.clientHeight+e.clientHeight;t<n?this._resultsContainer.scrollTop=t:n<i&&(this._resultsContainer.scrollTop=i)}},Lb.prototype._clearResults=function(){Q(this._resultsContainer),this._results={},this._eventBus.fire("searchPad.cleared")},Lb.prototype._getCurrentResult=function(){return fe(Lb.RESULT_SELECTED_SELECTOR,this._resultsContainer)},Lb.prototype._createResultNode=function(e,t){var n=he(Lb.RESULT_HTML);return e.primaryTokens.length>0&&$b(n,e.primaryTokens,Lb.RESULT_PRIMARY_HTML),$b(n,e.secondaryTokens,Lb.RESULT_SECONDARY_HTML),K(n,Lb.RESULT_ID_ATTRIBUTE,t),this._resultsContainer.appendChild(n),n},Lb.prototype.registerProvider=function(e){this._searchProvider=e},Lb.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,X(this._canvas.getContainer()).add("djs-search-open"),X(this._container).add("open"),this._searchInput.focus(),this._eventBus.fire("searchPad.opened"))},Lb.prototype.close=function(e=!0){this.isOpen()&&(e&&(this._cachedRootElement&&this._canvas.setRootElement(this._cachedRootElement),this._cachedSelection&&this._selection.select(this._cachedSelection),this._cachedViewbox&&this._canvas.viewbox(this._cachedViewbox),this._eventBus.fire("searchPad.restored")),this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._unbindEvents(),this._open=!1,X(this._canvas.getContainer()).remove("djs-search-open"),X(this._container).remove("open"),this._clearResults(),this._searchInput.value="",this._searchInput.blur(),this._eventBus.fire("searchPad.closed"),this._canvas.restoreFocus())},Lb.prototype.toggle=function(){this.isOpen()?this.close():this.open()},Lb.prototype.isOpen=function(){return this._open},Lb.prototype._preselect=function(e){var t=this._getCurrentResult();if(e!==t){t&&X(t).remove(Lb.RESULT_SELECTED_CLASS);var n=K(e,Lb.RESULT_ID_ATTRIBUTE),i=this._results[n].element;X(e).add(Lb.RESULT_SELECTED_CLASS),this._canvas.scrollToElement(i,{top:300}),this._selection.select(i),this._eventBus.fire("searchPad.preselected",i)}},Lb.prototype._select=function(e){var t=K(e,Lb.RESULT_ID_ATTRIBUTE),n=this._results[t].element;this._cachedSelection=null,this._cachedViewbox=null,this.close(!1),this._canvas.scrollToElement(n,{top:300}),this._selection.select(n),this._eventBus.fire("searchPad.selected",n)},Lb.prototype._getBoxHtml=function(){const e=he(Lb.BOX_HTML),t=fe(Lb.INPUT_SELECTOR,e);return t&&t.setAttribute("aria-label",this._translate("Search in diagram")),e},Lb.CONTAINER_SELECTOR=".djs-search-container",Lb.INPUT_SELECTOR=".djs-search-input input",Lb.RESULTS_CONTAINER_SELECTOR=".djs-search-results",Lb.RESULT_SELECTOR=".djs-search-result",Lb.RESULT_SELECTED_CLASS="djs-search-result-selected",Lb.RESULT_SELECTED_SELECTOR="."+Lb.RESULT_SELECTED_CLASS,Lb.RESULT_ID_ATTRIBUTE="data-result-id",Lb.RESULT_HIGHLIGHT_CLASS="djs-search-highlight",Lb.BOX_HTML='<div class="djs-search-container djs-scrollable">\n <div class="djs-search-input">\n <svg class="djs-search-icon" width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M9.0325 8.5H9.625L13.3675 12.25L12.25 13.3675L8.5 9.625V9.0325L8.2975 8.8225C7.4425 9.5575 6.3325 10 5.125 10C2.4325 10 0.25 7.8175 0.25 5.125C0.25 2.4325 2.4325 0.25 5.125 0.25C7.8175 0.25 10 2.4325 10 5.125C10 6.3325 9.5575 7.4425 8.8225 8.2975L9.0325 8.5ZM1.75 5.125C1.75 6.9925 3.2575 8.5 5.125 8.5C6.9925 8.5 8.5 6.9925 8.5 5.125C8.5 3.2575 6.9925 1.75 5.125 1.75C3.2575 1.75 1.75 3.2575 1.75 5.125Z" fill="#22242A"/>\n </svg>\n <input type="text" spellcheck="false" />\n </div>\n <div class="djs-search-results" />\n</div>',Lb.RESULT_HTML='<div class="djs-search-result"></div>',Lb.RESULT_PRIMARY_HTML='<div class="djs-search-result-primary"></div>',Lb.RESULT_SECONDARY_HTML='<p class="djs-search-result-secondary"></p>';var Ib={__depends__:[yo,Ao,_a],searchPad:["type",Lb]};function Fb(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._search=i,t.registerProvider(this)}function zb(e){const{item:{element:t},tokens:n}=e;return{element:t,primaryTokens:n.label,secondaryTokens:n.id}}Fb.$inject=["elementRegistry","searchPad","canvas","search"],Fb.prototype.find=function(e){var t=this._canvas.getRootElements(),n=this._elementRegistry.filter((function(e){return!cn(e)&&!t.includes(e)}));return this._search(n.map((e=>({element:e,label:Ur(e),id:e.id}))),e,{keys:["label","id"]}).map(zb)};var Hb={__depends__:[Ib,Oc],__init__:["bpmnSearch"],bpmnSearch:["type",Fb]};const Vb={width:36,height:50},Gb={width:50,height:50};function Wb(e,t,n){return Ae("path",{d:e,strokeWidth:2,transform:`translate(${t.x}, ${t.y})`,...n})}function Ub(e,t){this._styles=t,e.registerProvider(this)}function qb(e,t){var n;return"bpmn:DataObjectReference"===t?n=Vb:"bpmn:DataStoreReference"===t&&(n=Gb),e.width===n.width&&e.height===n.height}Ub.$inject=["outline","styles"],Ub.prototype.getOutline=function(e){const t=this._styles.cls("djs-outline",["no-fill"]);var n;if(!cn(e))return vr(e,"bpmn:Gateway")?(L((n=Ae("rect")).style,{"transform-box":"fill-box",transform:"rotate(45deg)","transform-origin":"center"}),_e(n,L({x:2,y:2,rx:4,width:e.width-4,height:e.height-4},t))):yr(e,["bpmn:Task","bpmn:SubProcess","bpmn:Group","bpmn:CallActivity"])?_e(n=Ae("rect"),L({x:-5,y:-5,rx:14,width:e.width+10,height:e.height+10},t)):vr(e,"bpmn:EndEvent")?_e(n=Ae("circle"),L({cx:e.width/2,cy:e.height/2,r:e.width/2+5+1},t)):vr(e,"bpmn:Event")?_e(n=Ae("circle"),L({cx:e.width/2,cy:e.height/2,r:e.width/2+5},t)):vr(e,"bpmn:DataObjectReference")&&qb(e,"bpmn:DataObjectReference")?n=Wb("M44.7648 11.3263L36.9892 2.64074C36.0451 1.58628 34.5651 0.988708 33.1904 0.988708H5.98667C3.22688 0.988708 0.989624 3.34892 0.989624 6.26039V55.0235C0.989624 57.9349 3.22688 60.2952 5.98667 60.2952H40.966C43.7257 60.2952 45.963 57.9349 45.963 55.0235V14.9459C45.963 13.5998 45.6407 12.3048 44.7648 11.3263Z",{x:-6,y:-6},t):vr(e,"bpmn:DataStoreReference")&&qb(e,"bpmn:DataStoreReference")&&(n=Wb("M1.03845 48.1347C1.03845 49.3511 1.07295 50.758 1.38342 52.064C1.69949 53.3938 2.32428 54.7154 3.56383 55.6428C6.02533 57.4841 10.1161 58.7685 14.8212 59.6067C19.5772 60.4538 25.1388 60.8738 30.6831 60.8738C36.2276 60.8738 41.7891 60.4538 46.545 59.6067C51.2504 58.7687 55.3412 57.4842 57.8028 55.6429C59.0424 54.7156 59.6673 53.3938 59.9834 52.064C60.2938 50.7579 60.3285 49.351 60.3285 48.1344V13.8415C60.3285 12.6249 60.2938 11.218 59.9834 9.91171C59.6673 8.58194 59.0423 7.2602 57.8027 6.33294C55.341 4.49168 51.2503 3.20723 46.545 2.36914C41.7891 1.522 36.2276 1.10204 30.6831 1.10205C25.1388 1.10206 19.5772 1.52206 14.8213 2.36923C10.1162 3.20734 6.02543 4.49183 3.5639 6.33314C2.32433 7.26038 1.69951 8.58206 1.38343 9.91181C1.07295 11.2179 1.03845 12.6247 1.03845 13.8411V48.1347Z",{x:-6,y:-6},t)),n},Ub.prototype.updateOutline=function(e,t){if(!cn(e))return yr(e,["bpmn:SubProcess","bpmn:Group"])?(_e(t,{width:e.width+10,height:e.height+10}),!0):!!yr(e,["bpmn:Event","bpmn:Gateway","bpmn:DataStoreReference","bpmn:DataObjectReference"])};var Kb={__depends__:[Lg],__init__:["outlineProvider"],outlineProvider:["type",Ub]};function Yb(e){jr.call(this,e)}return e(Yb,jr),Yb.Viewer=xa,Yb.NavigatedViewer=Za,Yb.prototype.createDiagram=function(){return this.importXML('<?xml version="1.0" encoding="UTF-8"?><bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" targetNamespace="http://bpmn.io/schema/bpmn" id="Definitions_1"><bpmn:process id="Process_1" isExecutable="false"><bpmn:startEvent id="StartEvent_1"/></bpmn:process><bpmndi:BPMNDiagram id="BPMNDiagram_1"><bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"><bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"><dc:Bounds height="36.0" width="36.0" x="173.0" y="102.0"/></bpmndi:BPMNShape></bpmndi:BPMNPlane></bpmndi:BPMNDiagram></bpmn:definitions>')},Yb.prototype._interactionModules=[Oa,Ga,Xa],Yb.prototype._modelingModules=[Gc,rp,bp,pp,vl,wl,Sl,Ey,lf,Zd,My,Oy,Xy,Qy,eg,cg,kg,Gv,Ng,Ug,vb,gb,bg,Ob,Hb,Kb],Yb.prototype._modules=[].concat(xa.prototype._modules,Yb.prototype._interactionModules,Yb.prototype._modelingModules),Yb}));
|
/plugin/codemirror/dist/keymaps/ |
H A D | vim.min.js | 2 …Oa(f,c);if(!e)return null;e.ch+=f;return e},moveToCharacter:function(a,b,c){var d=c.repeat;Oa(0,c)… function
|
/plugin/dirtylittlehelper/script/ |
H A D | mermaid.min.js | 1 …Oa(t,e,n,r){return 1===arguments.length?Ma(t):new Na(t,e,n,null==r?1:r)}function Na(t,e,n,r){this.… function
|
/plugin/diagramsnet/lib/js/mermaid/ |
H A D | mermaid.min.js | 6 …Oa(t,e,n,r){return 1===arguments.length?Ma(t):new Ba(t,e,n,null==r?1:r)}function Ba(t,e,n,r){this.… function
|
/plugin/findologicxmlexport/vendor/phpunit/php-code-coverage/src/Report/Html/Renderer/Template/js/ |
H A D | jquery.min.js | 3 …Oa(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}… function 4 …a,d,arguments.length)}}),r.each(["top","left"],function(a,b){r.cssHooks[b]=Oa(o.pixelPosition,func…
|
H A D | d3.min.js | 4 …Oa,Ia,Ya,Za,Va,Xa,$a={point:b,lineStart:b,lineEnd:b,polygonStart:function(){Ia=0,$a.lineStart=$t},… variable
|
/plugin/html5video2/script/ |
H A D | video.min.js | 21 …Oa(){this._nsMap={}}function Ra(){}function Ma(){}function Na(){}function Ua(){}function Ba(){}fun… class
|
/plugin/diagramsnet/lib/js/ |
H A D | extensions.min.js | 46 …tions.p&&a.Restrictions.c}:a.Hidden&&(d.visible=!1);return d}catch(Oa){console.log(Oa)}}function W… 64 …neBlockRotated":case "AdvancedSwimLaneBlock":case "UMLSwimLaneBlockV2":var Oa="MainText",Xa=null,y… 65 …neTitleHeight);t*=.75;r=.75*r+vd+Qd;v.geometry.width=t;v.geometry.height=r;Oa="poolPrimaryTitleKey… 66 …Oa];v.style=(wd?"swimlane;startSize="+vd+";":"fillColor=none;strokeColor=none;pointerEvents=0;font… 1705 …Oa(t,e,n,r){return 1===arguments.length?Ma(t):new Ba(t,e,n,null==r?1:r)}function Ba(t,e,n,r){this.… function
|
/plugin/mermaid/ |
H A D | mermaid.min.js | 584 `,"getStyles"),Sne=iMe});var _ne={};hr(_ne,{diagram:()=>aMe});var aMe,Lne=R(()=>{"use strict";nne();sne();Cne();Ane();aMe={parser:rne,db:ane,renderer:Ene,styles:Sne}});function Xn(t){return typeof t=="object"&&t!==null&&typeof t.$type=="string"}function xa(t){return typeof t=="object"&&t!==null&&typeof t.$refText=="string"}function ED(t){return typeof t=="object"&&t!==null&&typeof t.name=="string"&&typeof t.type=="string"&&typeof t.path=="string"}function Wd(t){return typeof t=="object"&&t!==null&&Xn(t.container)&&xa(t.reference)&&typeof t.message=="string"}function co(t){return typeof t=="object"&&t!==null&&Array.isArray(t.content)}function ef(t){return typeof t=="object"&&t!==null&&typeof t.tokenType=="object"}function zv(t){return co(t)&&typeof t.fullText=="string"}var Yd,Vo=R(()=>{"use strict";o(Xn,"isAstNode");o(xa,"isReference");o(ED,"isAstNodeDescription");o(Wd,"isLinkingError");Yd=class{static{o(this,"AbstractAstReflection")}constructor(){this.subtypes={},this.allSubtypes={}}isInstance(e,r){return Xn(e)&&this.isSubtype(e.$type,r)}isSubtype(e,r){if(e===r)return!0;let n=this.subtypes[e];n||(n=this.subtypes[e]={});let i=n[r];if(i!==void 0)return i;{let a=this.computeIsSubtype(e,r);return n[r]=a,a}}getAllSubTypes(e){let r=this.allSubtypes[e];if(r)return r;{let n=this.getAllTypes(),i=[];for(let a of n)this.isSubtype(a,e)&&i.push(a);return this.allSubtypes[e]=i,i}}};o(co,"isCompositeCstNode");o(ef,"isLeafCstNode");o(zv,"isRootCstNode")});function cMe(t){return typeof t=="string"?t:typeof t>"u"?"undefined":typeof t.toString=="function"?t.toString():Object.prototype.toString.call(t)}function hT(t){return!!t&&typeof t[Symbol.iterator]=="function"}function Kr(...t){if(t.length===1){let e=t[0];if(e instanceof uo)return e;if(hT(e))return new uo(()=>e[Symbol.iterator](),r=>r.next());if(typeof e.length=="number")return new uo(()=>({index:0}),r=>r.index<e.length?{done:!1,value:e[r.index++]}:Ja)}return t.length>1?new uo(()=>({collIndex:0,arrIndex:0}),e=>{do{if(e.iterator){let r=e.iterator.next();if(!r.done)return r;e.iterator=void 0}if(e.array){if(e.arrIndex<e.array.length)return{done:!1,value:e.array[e.arrIndex++]};e.array=void 0,e.arrIndex=0}if(e.collIndex<t.length){let r=t[e.collIndex++];hT(r)?e.iterator=r[Symbol.iterator]():r&&typeof r.length=="number"&&(e.array=r)}}while(e.iterator||e.array||e.collIndex<t.length);return Ja}):Gv}var uo,Gv,Ja,Cc,Fm,Ds=R(()=>{"use strict";uo=class t{static{o(this,"StreamImpl")}constructor(e,r){this.startFn=e,this.nextFn=r}iterator(){let e={state:this.startFn(),next:o(()=>this.nextFn(e.state),"next"),[Symbol.iterator]:()=>e};return e}[Symbol.iterator](){return this.iterator()}isEmpty(){return!!this.iterator().next().done}count(){let e=this.iterator(),r=0,n=e.next();for(;!n.done;)r++,n=e.next();return r}toArray(){let e=[],r=this.iterator(),n;do n=r.next(),n.value!==void 0&&e.push(n.value);while(!n.done);return e}toSet(){return new Set(this)}toMap(e,r){let n=this.map(i=>[e?e(i):i,r?r(i):i]);return new Map(n)}toString(){return this.join()}concat(e){let r=e[Symbol.iterator]();return new t(()=>({first:this.startFn(),firstDone:!1}),n=>{let i;if(!n.firstDone){do if(i=this.nextFn(n.first),!i.done)return i;while(!i.done);n.firstDone=!0}do if(i=r.next(),!i.done)return i;while(!i.done);return Ja})}join(e=","){let r=this.iterator(),n="",i,a=!1;do i=r.next(),i.done||(a&&(n+=e),n+=cMe(i.value)),a=!0;while(!i.done);return n}indexOf(e,r=0){let n=this.iterator(),i=0,a=n.next();for(;!a.done;){if(i>=r&&a.value===e)return i;a=n.next(),i++}return-1}every(e){let r=this.iterator(),n=r.next();for(;!n.done;){if(!e(n.value))return!1;n=r.next()}return!0}some(e){let r=this.iterator(),n=r.next();for(;!n.done;){if(e(n.value))return!0;n=r.next()}return!1}forEach(e){let r=this.iterator(),n=0,i=r.next();for(;!i.done;)e(i.value,n),i=r.next(),n++}map(e){return new t(this.startFn,r=>{let{done:n,value:i}=this.nextFn(r);return n?Ja:{done:!1,value:e(i)}})}filter(e){return new t(this.startFn,r=>{let n;do if(n=this.nextFn(r),!n.done&&e(n.value))return n;while(!n.done);return Ja})}nonNullable(){return this.filter(e=>e!=null)}reduce(e,r){let n=this.iterator(),i=r,a=n.next();for(;!a.done;)i===void 0?i=a.value:i=e(i,a.value),a=n.next();return i}reduceRight(e,r){return this.recursiveReduce(this.iterator(),e,r)}recursiveReduce(e,r,n){let i=e.next();if(i.done)return n;let a=this.recursiveReduce(e,r,n);return a===void 0?i.value:r(a,i.value)}find(e){let r=this.iterator(),n=r.next();for(;!n.done;){if(e(n.value))return n.value;n=r.next()}}findIndex(e){let r=this.iterator(),n=0,i=r.next();for(;!i.done;){if(e(i.value))return n;i=r.next(),n++}return-1}includes(e){let r=this.iterator(),n=r.next();for(;!n.done;){if(n.value===e)return!0;n=r.next()}return!1}flatMap(e){return new t(()=>({this:this.startFn()}),r=>{do{if(r.iterator){let a=r.iterator.next();if(a.done)r.iterator=void 0;else return a}let{done:n,value:i}=this.nextFn(r.this);if(!n){let a=e(i);if(hT(a))r.iterator=a[Symbol.iterator]();else return{done:!1,value:a}}}while(r.iterator);return Ja})}flat(e){if(e===void 0&&(e=1),e<=0)return this;let r=e>1?this.flat(e-1):this;return new t(()=>({this:r.startFn()}),n=>{do{if(n.iterator){let s=n.iterator.next();if(s.done)n.iterator=void 0;else return s}let{done:i,value:a}=r.nextFn(n.this);if(!i)if(hT(a))n.iterator=a[Symbol.iterator]();else return{done:!1,value:a}}while(n.iterator);return Ja})}head(){let r=this.iterator().next();if(!r.done)return r.value}tail(e=1){return new t(()=>{let r=this.startFn();for(let n=0;n<e;n++)if(this.nextFn(r).done)return r;return r},this.nextFn)}limit(e){return new t(()=>({size:0,state:this.startFn()}),r=>(r.size++,r.size>e?Ja:this.nextFn(r.state)))}distinct(e){let r=new Set;return this.filter(n=>{let i=e?e(n):n;return r.has(i)?!1:(r.add(i),!0)})}exclude(e,r){let n=new Set;for(let i of e){let a=r?r(i):i;n.add(a)}return this.filter(i=>{let a=r?r(i):i;return!n.has(a)})}};o(cMe,"toString");o(hT,"isIterable");Gv=new uo(()=>{},()=>Ja),Ja=Object.freeze({done:!0,value:void 0});o(Kr,"stream");Cc=class extends uo{static{o(this,"TreeStreamImpl")}constructor(e,r,n){super(()=>({iterators:n?.includeRoot?[[e][Symbol.iterator]()]:[r(e)[Symbol.iterator]()],pruned:!1}),i=>{for(i.pruned&&(i.iterators.pop(),i.pruned=!1);i.iterators.length>0;){let s=i.iterators[i.iterators.length-1].next();if(s.done)i.iterators.pop();else return i.iterators.push(r(s.value)[Symbol.iterator]()),s}return Ja})}iterator(){let e={state:this.startFn(),next:o(()=>this.nextFn(e.state),"next"),prune:o(()=>{e.state.pruned=!0},"prune"),[Symbol.iterator]:()=>e};return e}};(function(t){function e(a){return a.reduce((s,l)=>s+l,0)}o(e,"sum"),t.sum=e;function r(a){return a.reduce((s,l)=>s*l,0)}o(r,"product"),t.product=r;function n(a){return a.reduce((s,l)=>Math.min(s,l))}o(n,"min"),t.min=n;function i(a){return a.reduce((s,l)=>Math.max(s,l))}o(i,"max"),t.max=i})(Fm||(Fm={}))});var dT={};hr(dT,{DefaultNameRegexp:()=>fT,RangeComparison:()=>Mu,compareRange:()=>Mne,findCommentNode:()=>_D,findDeclarationNodeAtOffset:()=>hMe,findLeafNodeAtOffset:()=>LD,findLeafNodeBeforeOffset:()=>Ine,flattenCst:()=>uMe,getInteriorNodes:()=>pMe,getNextNode:()=>fMe,getPreviousNode:()=>Pne,getStartlineNode:()=>dMe,inRange:()=>AD,isChildNode:()=>SD,isCommentNode:()=>CD,streamCst:()=>qd,toDocumentSegment:()=>Xd,tokenToRange:()=>zm});function qd(t){return new Cc(t,e=>co(e)?e.content:[],{includeRoot:!0})}function uMe(t){return qd(t).filter(ef)}function SD(t,e){for(;t.container;)if(t=t.container,t===e)return!0;return!1}function zm(t){return{start:{character:t.startColumn-1,line:t.startLine-1},end:{character:t.endColumn,line:t.endLine-1}}}function Xd(t){if(!t)return;let{offset:e,end:r,range:n}=t;return{range:n,offset:e,end:r,length:r-e}}function Mne(t,e){if(t.end.line<e.start.line||t.end.line===e.start.line&&t.end.character<t.start.character)return Mu.Before;if(t.start.line>e.end.line||t.start.line===e.end.line&&t.start.character>e.end.character)return Mu.After;let r=t.start.line>e.start.line||t.start.line===e.start.line&&t.start.character>=e.start.character,n=t.end.line<e.end.line||t.end.line===e.end.line&&t.end.character<=e.end.character;return r&&n?Mu.Inside:r?Mu.OverlapBack:Mu.OverlapFront}function AD(t,e){return Mne(t,e)>Mu.After}function hMe(t,e,r=fT){if(t){if(e>0){let n=e-t.offset,i=t.text.charAt(n);r.test(i)||e--}return LD(t,e)}}function _D(t,e){if(t){let r=Pne(t,!0);if(r&&CD(r,e))return r;if(zv(t)){let n=t.content.findIndex(i=>!i.hidden);for(let i=n-1;i>=0;i--){let a=t.content[i];if(CD(a,e))return a}}}}function CD(t,e){return ef(t)&&e.includes(t.tokenType.name)}function LD(t,e){if(ef(t))return t;if(co(t)){let r=One(t,e,!1);if(r)return LD(r,e)}}function Ine(t,e){if(ef(t))return t;if(co(t)){let r=One(t,e,!0);if(r)return Ine(r,e)}}function One(t,e,r){let n=0,i=t.content.length-1,a;for(;n<=i;){let s=Math.floor((n+i)/2),l=t.content[s];if(l.offset<=e&&l.end>e)return l;l.end<=e?(a=r?l:void 0,n=s+1):i=s-1}return a}function Pne(t,e=!0){for(;t.container;){let r=t.container,n=r.content.indexOf(t);for(;n>0;){n--;let i=r.content[n];if(e||!i.hidden)return i}t=r}}function fMe(t,e=!0){for(;t.container;){let r=t.container,n=r.content.indexOf(t),i=r.content.length-1;for(;n<i;){n++;let a=r.content[n];if(e||!a.hidden)return a}t=r}}function dMe(t){if(t.range.start.character===0)return t;let e=t.range.start.line,r=t,n;for(;t.container;){let i=t.container,a=n??i.content.indexOf(t);if(a===0?(t=i,n=void 0):(n=a-1,t=i.content[n]),t.range.start.line!==e)break;r=t}return r}function pMe(t,e){let r=mMe(t,e);return r?r.parent.content.slice(r.a+1,r.b):[]}function mMe(t,e){let r=Nne(t),n=Nne(e),i;for(let a=0;a<r.length&&a<n.length;a++){let s=r[a],l=n[a];if(s.parent===l.parent)i={parent:s.parent,a:s.index,b:l.index};else break}return i}function Nne(t){let e=[];for(;t.container;){let r=t.container,n=r.content.indexOf(t);e.push({parent:r,index:n}),t=r}return e.reverse()}var Mu,fT,Rl=R(()=>{"use strict";Vo();Ds();o(qd,"streamCst");o(uMe,"flattenCst");o(SD,"isChildNode");o(zm,"tokenToRange");o(Xd,"toDocumentSegment");(function(t){t[t.Before=0]="Before",t[t.After=1]="After",t[t.OverlapFront=2]="OverlapFront",t[t.OverlapBack=3]="OverlapBack",t[t.Inside=4]="Inside"})(Mu||(Mu={}));o(Mne,"compareRange");o(AD,"inRange");fT=/^[\w\p{L}]$/u;o(hMe,"findDeclarationNodeAtOffset");o(_D,"findCommentNode");o(CD,"isCommentNode");o(LD,"findLeafNodeAtOffset");o(Ine,"findLeafNodeBeforeOffset");o(One,"binarySearch");o(Pne,"getPreviousNode");o(fMe,"getNextNode");o(dMe,"getStartlineNode");o(pMe,"getInteriorNodes");o(mMe,"getCommonParent");o(Nne,"getParentChain")});function tf(t){throw new Error("Error! The input value was not handled.")}var jd,pT=R(()=>{"use strict";jd=class extends Error{static{o(this,"ErrorWithLocation")}constructor(e,r){super(e?`${r} at ${e.range.start.line}:${e.range.start.character}`:r)}};o(tf,"assertUnreachable")});var Yv={};hr(Yv,{AbstractElement:()=>RD,AbstractRule:()=>$v,AbstractType:()=>Vv,Action:()=>aR,Alternatives:()=>sR,ArrayLiteral:()=>ND,ArrayType:()=>MD,Assignment:()=>oR,BooleanLiteral:()=>OD,CharacterRange:()=>lR,Condition:()=>mT,Conjunction:()=>BD,CrossReference:()=>uR,Disjunction:()=>zD,EndOfFile:()=>hR,Grammar:()=>$D,GrammarImport:()=>Fne,Group:()=>dR,InferredType:()=>VD,Interface:()=>UD,Keyword:()=>pR,LangiumGrammarAstReflection:()=>Gm,LangiumGrammarTerminals:()=>gMe,NamedArgument:()=>zne,NegatedToken:()=>mR,Negation:()=>HD,NumberLiteral:()=>WD,Parameter:()=>qD,ParameterReference:()=>XD,ParserRule:()=>KD,ReferenceType:()=>QD,RegexToken:()=>yR,ReturnType:()=>Gne,RuleCall:()=>xR,SimpleType:()=>eR,StringLiteral:()=>tR,TerminalAlternatives:()=>bR,TerminalGroup:()=>TR,TerminalRule:()=>yT,TerminalRuleCall:()=>ER,Type:()=>rR,TypeAttribute:()=>$ne,TypeDefinition:()=>DD,UnionType:()=>nR,UnorderedGroup:()=>CR,UntilToken:()=>SR,ValueLiteral:()=>gT,Wildcard:()=>_R,isAbstractElement:()=>Uv,isAbstractRule:()=>yMe,isAbstractType:()=>vMe,isAction:()=>Iu,isAlternatives:()=>wT,isArrayLiteral:()=>kMe,isArrayType:()=>ID,isAssignment:()=>Nl,isBooleanLiteral:()=>PD,isCharacterRange:()=>cR,isCondition:()=>xMe,isConjunction:()=>FD,isCrossReference:()=>Kd,isDisjunction:()=>GD,isEndOfFile:()=>fR,isFeatureName:()=>bMe,isGrammar:()=>EMe,isGrammarImport:()=>CMe,isGroup:()=>rf,isInferredType:()=>vT,isInterface:()=>xT,isKeyword:()=>Ho,isNamedArgument:()=>SMe,isNegatedToken:()=>gR,isNegation:()=>YD,isNumberLiteral:()=>AMe,isParameter:()=>_Me,isParameterReference:()=>jD,isParserRule:()=>Oa,isPrimitiveType:()=>Bne,isReferenceType:()=>ZD,isRegexToken:()=>vR,isReturnType:()=>JD,isRuleCall:()=>Ml,isSimpleType:()=>bT,isStringLiteral:()=>LMe,isTerminalAlternatives:()=>wR,isTerminalGroup:()=>kR,isTerminalRule:()=>Uo,isTerminalRuleCall:()=>TT,isType:()=>Hv,isTypeAttribute:()=>DMe,isTypeDefinition:()=>wMe,isUnionType:()=>iR,isUnorderedGroup:()=>kT,isUntilToken:()=>AR,isValueLiteral:()=>TMe,isWildcard:()=>LR,reflection:()=>Kt});function yMe(t){return Kt.isInstance(t,$v)}function vMe(t){return Kt.isInstance(t,Vv)}function xMe(t){return Kt.isInstance(t,mT)}function bMe(t){return Bne(t)||t==="current"||t==="entry"||t==="extends"||t==="false"||t==="fragment"||t==="grammar"||t==="hidden"||t==="import"||t==="interface"||t==="returns"||t==="terminal"||t==="true"||t==="type"||t==="infer"||t==="infers"||t==="with"||typeof t=="string"&&/\^?[_a-zA-Z][\w_]*/.test(t)}function Bne(t){return t==="string"||t==="number"||t==="boolean"||t==="Date"||t==="bigint"}function wMe(t){return Kt.isInstance(t,DD)}function TMe(t){return Kt.isInstance(t,gT)}function Uv(t){return Kt.isInstance(t,RD)}function kMe(t){return Kt.isInstance(t,ND)}function ID(t){return Kt.isInstance(t,MD)}function PD(t){return Kt.isInstance(t,OD)}function FD(t){return Kt.isInstance(t,BD)}function GD(t){return Kt.isInstance(t,zD)}function EMe(t){return Kt.isInstance(t,$D)}function CMe(t){return Kt.isInstance(t,Fne)}function vT(t){return Kt.isInstance(t,VD)}function xT(t){return Kt.isInstance(t,UD)}function SMe(t){return Kt.isInstance(t,zne)}function YD(t){return Kt.isInstance(t,HD)}function AMe(t){return Kt.isInstance(t,WD)}function _Me(t){return Kt.isInstance(t,qD)}function jD(t){return Kt.isInstance(t,XD)}function Oa(t){return Kt.isInstance(t,KD)}function ZD(t){return Kt.isInstance(t,QD)}function JD(t){return Kt.isInstance(t,Gne)}function bT(t){return Kt.isInstance(t,eR)}function LMe(t){return Kt.isInstance(t,tR)}function Uo(t){return Kt.isInstance(t,yT)}function Hv(t){return Kt.isInstance(t,rR)}function DMe(t){return Kt.isInstance(t,$ne)}function iR(t){return Kt.isInstance(t,nR)}function Iu(t){return Kt.isInstance(t,aR)}function wT(t){return Kt.isInstance(t,sR)}function Nl(t){return Kt.isInstance(t,oR)}function cR(t){return Kt.isInstance(t,lR)}function Kd(t){return Kt.isInstance(t,uR)}function fR(t){return Kt.isInstance(t,hR)}function rf(t){return Kt.isInstance(t,dR)}function Ho(t){return Kt.isInstance(t,pR)}function gR(t){return Kt.isInstance(t,mR)}function vR(t){return Kt.isInstance(t,yR)}function Ml(t){return Kt.isInstance(t,xR)}function wR(t){return Kt.isInstance(t,bR)}function kR(t){return Kt.isInstance(t,TR)}function TT(t){return Kt.isInstance(t,ER)}function kT(t){return Kt.isInstance(t,CR)}function AR(t){return Kt.isInstance(t,SR)}function LR(t){return Kt.isInstance(t,_R)}var gMe,$v,Vv,mT,DD,gT,RD,ND,MD,OD,BD,zD,$D,Fne,VD,UD,zne,HD,WD,qD,XD,KD,QD,Gne,eR,tR,yT,rR,$ne,nR,aR,sR,oR,lR,uR,hR,dR,pR,mR,yR,xR,bR,TR,ER,CR,SR,_R,Gm,Kt,Sc=R(()=>{"use strict";Vo();gMe={ID:/\^?[_a-zA-Z][\w_]*/,STRING:/"(\\.|[^"\\])*"|'(\\.|[^'\\])*'/,NUMBER:/NaN|-?((\d*\.\d+|\d+)([Ee][+-]?\d+)?|Infinity)/,RegexLiteral:/\/(?![*+?])(?:[^\r\n\[/\\]|\\.|\[(?:[^\r\n\]\\]|\\.)*\])+\/[a-z]*/,WS:/\s+/,ML_COMMENT:/\/\*[\s\S]*?\*\//,SL_COMMENT:/\/\/[^\n\r]*/},$v="AbstractRule";o(yMe,"isAbstractRule");Vv="AbstractType";o(vMe,"isAbstractType");mT="Condition";o(xMe,"isCondition");o(bMe,"isFeatureName");o(Bne,"isPrimitiveType");DD="TypeDefinition";o(wMe,"isTypeDefinition");gT="ValueLiteral";o(TMe,"isValueLiteral");RD="AbstractElement";o(Uv,"isAbstractElement");ND="ArrayLiteral";o(kMe,"isArrayLiteral");MD="ArrayType";o(ID,"isArrayType");OD="BooleanLiteral";o(PD,"isBooleanLiteral");BD="Conjunction";o(FD,"isConjunction");zD="Disjunction";o(GD,"isDisjunction");$D="Grammar";o(EMe,"isGrammar");Fne="GrammarImport";o(CMe,"isGrammarImport");VD="InferredType";o(vT,"isInferredType");UD="Interface";o(xT,"isInterface");zne="NamedArgument";o(SMe,"isNamedArgument");HD="Negation";o(YD,"isNegation");WD="NumberLiteral";o(AMe,"isNumberLiteral");qD="Parameter";o(_Me,"isParameter");XD="ParameterReference";o(jD,"isParameterReference");KD="ParserRule";o(Oa,"isParserRule");QD="ReferenceType";o(ZD,"isReferenceType");Gne="ReturnType";o(JD,"isReturnType");eR="SimpleType";o(bT,"isSimpleType");tR="StringLiteral";o(LMe,"isStringLiteral");yT="TerminalRule";o(Uo,"isTerminalRule");rR="Type";o(Hv,"isType");$ne="TypeAttribute";o(DMe,"isTypeAttribute");nR="UnionType";o(iR,"isUnionType");aR="Action";o(Iu,"isAction");sR="Alternatives";o(wT,"isAlternatives");oR="Assignment";o(Nl,"isAssignment");lR="CharacterRange";o(cR,"isCharacterRange");uR="CrossReference";o(Kd,"isCrossReference");hR="EndOfFile";o(fR,"isEndOfFile");dR="Group";o(rf,"isGroup");pR="Keyword";o(Ho,"isKeyword");mR="NegatedToken";o(gR,"isNegatedToken");yR="RegexToken";o(vR,"isRegexToken");xR="RuleCall";o(Ml,"isRuleCall");bR="TerminalAlternatives";o(wR,"isTerminalAlternatives");TR="TerminalGroup";o(kR,"isTerminalGroup");ER="TerminalRuleCall";o(TT,"isTerminalRuleCall");CR="UnorderedGroup";o(kT,"isUnorderedGroup");SR="UntilToken";o(AR,"isUntilToken");_R="Wildcard";o(LR,"isWildcard");Gm=class extends Yd{static{o(this,"LangiumGrammarAstReflection")}getAllTypes(){return["AbstractElement","AbstractRule","AbstractType","Action","Alternatives","ArrayLiteral","ArrayType","Assignment","BooleanLiteral","CharacterRange","Condition","Conjunction","CrossReference","Disjunction","EndOfFile","Grammar","GrammarImport","Group","InferredType","Interface","Keyword","NamedArgument","NegatedToken","Negation","NumberLiteral","Parameter","ParameterReference","ParserRule","ReferenceType","RegexToken","ReturnType","RuleCall","SimpleType","StringLiteral","TerminalAlternatives","TerminalGroup","TerminalRule","TerminalRuleCall","Type","TypeAttribute","TypeDefinition","UnionType","UnorderedGroup","UntilToken","ValueLiteral","Wildcard"]}computeIsSubtype(e,r){switch(e){case aR:case sR:case oR:case lR:case uR:case hR:case dR:case pR:case mR:case yR:case xR:case bR:case TR:case ER:case CR:case SR:case _R:return this.isSubtype(RD,r);case ND:case WD:case tR:return this.isSubtype(gT,r);case MD:case QD:case eR:case nR:return this.isSubtype(DD,r);case OD:return this.isSubtype(mT,r)||this.isSubtype(gT,r);case BD:case zD:case HD:case XD:return this.isSubtype(mT,r);case VD:case UD:case rR:return this.isSubtype(Vv,r);case KD:return this.isSubtype($v,r)||this.isSubtype(Vv,r);case yT:return this.isSubtype($v,r);default:return!1}}getReferenceType(e){let r=`${e.container.$type}:${e.property}`;switch(r){case"Action:type":case"CrossReference:type":case"Interface:superTypes":case"ParserRule:returnType":case"SimpleType:typeRef":return Vv;case"Grammar:hiddenTokens":case"ParserRule:hiddenTokens":case"RuleCall:rule":return $v;case"Grammar:usedGrammars":return $D;case"NamedArgument:parameter":case"ParameterReference:parameter":return qD;case"TerminalRuleCall:rule":return yT;default:throw new Error(`${r} is not a valid reference id.`)}}getTypeMetaData(e){switch(e){case"AbstractElement":return{name:"AbstractElement",properties:[{name:"cardinality"},{name:"lookahead"}]};case"ArrayLiteral":return{name:"ArrayLiteral",properties:[{name:"elements",defaultValue:[]}]};case"ArrayType":return{name:"ArrayType",properties:[{name:"elementType"}]};case"BooleanLiteral":return{name:"BooleanLiteral",properties:[{name:"true",defaultValue:!1}]};case"Conjunction":return{name:"Conjunction",properties:[{name:"left"},{name:"right"}]};case"Disjunction":return{name:"Disjunction",properties:[{name:"left"},{name:"right"}]};case"Grammar":return{name:"Grammar",properties:[{name:"definesHiddenTokens",defaultValue:!1},{name:"hiddenTokens",defaultValue:[]},{name:"imports",defaultValue:[]},{name:"interfaces",defaultValue:[]},{name:"isDeclared",defaultValue:!1},{name:"name"},{name:"rules",defaultValue:[]},{name:"types",defaultValue:[]},{name:"usedGrammars",defaultValue:[]}]};case"GrammarImport":return{name:"GrammarImport",properties:[{name:"path"}]};case"InferredType":return{name:"InferredType",properties:[{name:"name"}]};case"Interface":return{name:"Interface",properties:[{name:"attributes",defaultValue:[]},{name:"name"},{name:"superTypes",defaultValue:[]}]};case"NamedArgument":return{name:"NamedArgument",properties:[{name:"calledByName",defaultValue:!1},{name:"parameter"},{name:"value"}]};case"Negation":return{name:"Negation",properties:[{name:"value"}]};case"NumberLiteral":return{name:"NumberLiteral",properties:[{name:"value"}]};case"Parameter":return{name:"Parameter",properties:[{name:"name"}]};case"ParameterReference":return{name:"ParameterReference",properties:[{name:"parameter"}]};case"ParserRule":return{name:"ParserRule",properties:[{name:"dataType"},{name:"definesHiddenTokens",defaultValue:!1},{name:"definition"},{name:"entry",defaultValue:!1},{name:"fragment",defaultValue:!1},{name:"hiddenTokens",defaultValue:[]},{name:"inferredType"},{name:"name"},{name:"parameters",defaultValue:[]},{name:"returnType"},{name:"wildcard",defaultValue:!1}]};case"ReferenceType":return{name:"ReferenceType",properties:[{name:"referenceType"}]};case"ReturnType":return{name:"ReturnType",properties:[{name:"name"}]};case"SimpleType":return{name:"SimpleType",properties:[{name:"primitiveType"},{name:"stringType"},{name:"typeRef"}]};case"StringLiteral":return{name:"StringLiteral",properties:[{name:"value"}]};case"TerminalRule":return{name:"TerminalRule",properties:[{name:"definition"},{name:"fragment",defaultValue:!1},{name:"hidden",defaultValue:!1},{name:"name"},{name:"type"}]};case"Type":return{name:"Type",properties:[{name:"name"},{name:"type"}]};case"TypeAttribute":return{name:"TypeAttribute",properties:[{name:"defaultValue"},{name:"isOptional",defaultValue:!1},{name:"name"},{name:"type"}]};case"UnionType":return{name:"UnionType",properties:[{name:"types",defaultValue:[]}]};case"Action":return{name:"Action",properties:[{name:"cardinality"},{name:"feature"},{name:"inferredType"},{name:"lookahead"},{name:"operator"},{name:"type"}]};case"Alternatives":return{name:"Alternatives",properties:[{name:"cardinality"},{name:"elements",defaultValue:[]},{name:"lookahead"}]};case"Assignment":return{name:"Assignment",properties:[{name:"cardinality"},{name:"feature"},{name:"lookahead"},{name:"operator"},{name:"terminal"}]};case"CharacterRange":return{name:"CharacterRange",properties:[{name:"cardinality"},{name:"left"},{name:"lookahead"},{name:"right"}]};case"CrossReference":return{name:"CrossReference",properties:[{name:"cardinality"},{name:"deprecatedSyntax",defaultValue:!1},{name:"lookahead"},{name:"terminal"},{name:"type"}]};case"EndOfFile":return{name:"EndOfFile",properties:[{name:"cardinality"},{name:"lookahead"}]};case"Group":return{name:"Group",properties:[{name:"cardinality"},{name:"elements",defaultValue:[]},{name:"guardCondition"},{name:"lookahead"}]};case"Keyword":return{name:"Keyword",properties:[{name:"cardinality"},{name:"lookahead"},{name:"value"}]};case"NegatedToken":return{name:"NegatedToken",properties:[{name:"cardinality"},{name:"lookahead"},{name:"terminal"}]};case"RegexToken":return{name:"RegexToken",properties:[{name:"cardinality"},{name:"lookahead"},{name:"regex"}]};case"RuleCall":return{name:"RuleCall",properties:[{name:"arguments",defaultValue:[]},{name:"cardinality"},{name:"lookahead"},{name:"rule"}]};case"TerminalAlternatives":return{name:"TerminalAlternatives",properties:[{name:"cardinality"},{name:"elements",defaultValue:[]},{name:"lookahead"}]};case"TerminalGroup":return{name:"TerminalGroup",properties:[{name:"cardinality"},{name:"elements",defaultValue:[]},{name:"lookahead"}]};case"TerminalRuleCall":return{name:"TerminalRuleCall",properties:[{name:"cardinality"},{name:"lookahead"},{name:"rule"}]};case"UnorderedGroup":return{name:"UnorderedGroup",properties:[{name:"cardinality"},{name:"elements",defaultValue:[]},{name:"lookahead"}]};case"UntilToken":return{name:"UntilToken",properties:[{name:"cardinality"},{name:"lookahead"},{name:"terminal"}]};case"Wildcard":return{name:"Wildcard",properties:[{name:"cardinality"},{name:"lookahead"}]};default:return{name:e,properties:[]}}}},Kt=new Gm});var CT={};hr(CT,{assignMandatoryProperties:()=>NR,copyAstNode:()=>RR,findLocalReferences:()=>NMe,findRootNode:()=>Vne,getContainerOfType:()=>Qd,getDocument:()=>Oi,hasContainerOfType:()=>RMe,linkContentToContainer:()=>ET,streamAllContents:()=>Ac,streamAst:()=>Yo,streamContents:()=>Wv,streamReferences:()=>$m});function ET(t){for(let[e,r]of Object.entries(t))e.startsWith("$")||(Array.isArray(r)?r.forEach((n,i)=>{Xn(n)&&(n.$container=t,n.$containerProperty=e,n.$containerIndex=i)}):Xn(r)&&(r.$container=t,r.$containerProperty=e))}function Qd(t,e){let r=t;for(;r;){if(e(r))return r;r=r.$container}}function RMe(t,e){let r=t;for(;r;){if(e(r))return!0;r=r.$container}return!1}function Oi(t){let r=Vne(t).$document;if(!r)throw new Error("AST node has no document.");return r}function Vne(t){for(;t.$container;)t=t.$container;return t}function Wv(t,e){if(!t)throw new Error("Node must be an AstNode.");let r=e?.range;return new uo(()=>({keys:Object.keys(t),keyIndex:0,arrayIndex:0}),n=>{for(;n.keyIndex<n.keys.length;){let i=n.keys[n.keyIndex];if(!i.startsWith("$")){let a=t[i];if(Xn(a)){if(n.keyIndex++,DR(a,r))return{done:!1,value:a}}else if(Array.isArray(a)){for(;n.arrayIndex<a.length;){let s=n.arrayIndex++,l=a[s];if(Xn(l)&&DR(l,r))return{done:!1,value:l}}n.arrayIndex=0}}n.keyIndex++}return Ja})}function Ac(t,e){if(!t)throw new Error("Root node must be an AstNode.");return new Cc(t,r=>Wv(r,e))}function Yo(t,e){if(t){if(e?.range&&!DR(t,e.range))return new Cc(t,()=>[])}else throw new Error("Root node must be an AstNode.");return new Cc(t,r=>Wv(r,e),{includeRoot:!0})}function DR(t,e){var r;if(!e)return!0;let n=(r=t.$cstNode)===null||r===void 0?void 0:r.range;return n?AD(n,e):!1}function $m(t){return new uo(()=>({keys:Object.keys(t),keyIndex:0,arrayIndex:0}),e=>{for(;e.keyIndex<e.keys.length;){let r=e.keys[e.keyIndex];if(!r.startsWith("$")){let n=t[r];if(xa(n))return e.keyIndex++,{done:!1,value:{reference:n,container:t,property:r}};if(Array.isArray(n)){for(;e.arrayIndex<n.length;){let i=e.arrayIndex++,a=n[i];if(xa(a))return{done:!1,value:{reference:a,container:t,property:r,index:i}}}e.arrayIndex=0}}e.keyIndex++}return Ja})}function NMe(t,e=Oi(t).parseResult.value){let r=[];return Yo(e).forEach(n=>{$m(n).forEach(i=>{i.reference.ref===t&&r.push(i.reference)})}),Kr(r)}function NR(t,e){let r=t.getTypeMetaData(e.$type),n=e;for(let i of r.properties)i.defaultValue!==void 0&&n[i.name]===void 0&&(n[i.name]=Une(i.defaultValue))}function Une(t){return Array.isArray(t)?[...t.map(Une)]:t}function RR(t,e){let r={$type:t.$type};for(let[n,i]of Object.entries(t))if(!n.startsWith("$"))if(Xn(i))r[n]=RR(i,e);else if(xa(i))r[n]=e(r,n,i.$refNode,i.$refText);else if(Array.isArray(i)){let a=[];for(let s of i)Xn(s)?a.push(RR(s,e)):xa(s)?a.push(e(r,n,s.$refNode,s.$refText)):a.push(s);r[n]=a}else r[n]=i;return ET(r),r}var es=R(()=>{"use strict";Vo();Ds();Rl();o(ET,"linkContentToContainer");o(Qd,"getContainerOfType");o(RMe,"hasContainerOfType");o(Oi,"getDocument");o(Vne,"findRootNode");o(Wv,"streamContents");o(Ac,"streamAllContents");o(Yo,"streamAst");o(DR,"isAstNodeInRange");o($m,"streamReferences");o(NMe,"findLocalReferences");o(NR,"assignMandatoryProperties");o(Une,"copyDefaultValue");o(RR,"copyAstNode")});function qt(t){return t.charCodeAt(0)}function ST(t,e){Array.isArray(t)?t.forEach(function(r){e.push(r)}):e.push(t)}function Vm(t,e){if(t[e]===!0)throw"duplicate flag "+e;let r=t[e];t[e]=!0}function Zd(t){if(t===void 0)throw Error("Internal Error - Should never get here!");return!0}function qv(){throw Error("Internal Error - Should never get here!")}function MR(t){return t.type==="Character"}var IR=R(()=>{"use strict";o(qt,"cc");o(ST,"insertToSet");o(Vm,"addFlag");o(Zd,"ASSERT_EXISTS");o(qv,"ASSERT_NEVER_REACH_HERE");o(MR,"isCharacter")});var Xv,jv,OR,Hne=R(()=>{"use strict";IR();Xv=[];for(let t=qt("0");t<=qt("9");t++)Xv.push(t);jv=[qt("_")].concat(Xv);for(let t=qt("a");t<=qt("z");t++)jv.push(t);for(let t=qt("A");t<=qt("Z");t++)jv.push(t);OR=[qt(" "),qt("\f"),qt(` 594 `.match(n)}if(e.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{let r=this.regex.substring(e.loc.begin,e.loc.end);this.endRegexpStack.push(r),this.isStarting&&(this.startRegexp+=r)}}visitChildren(e){e.type==="Group"&&e.quantifier||super.visitChildren(e)}},e0=new PR;o(OMe,"getTerminalParts");o(FR,"isMultilineComment");o(_T,"isWhitespace");o(t0,"escapeRegExp");o(zR,"getCaseInsensitivePattern");o(GR,"partialMatches");o(Xne,"partialRegExp")});var RT={};hr(RT,{findAssignment:()=>jR,findNameAssignment:()=>DT,findNodeForKeyword:()=>qR,findNodeForProperty:()=>Zv,findNodesForKeyword:()=>PMe,findNodesForKeywordInternal:()=>XR,findNodesForProperty:()=>YR,getActionAtElement:()=>Jne,getActionType:()=>tie,getAllReachableRules:()=>Qv,getCrossReferenceTerminal:()=>UR,getEntryRule:()=>jne,getExplicitRuleType:()=>KR,getHiddenRules:()=>Kne,getRuleType:()=>QR,getTypeName:()=>r0,isArrayCardinality:()=>FMe,isArrayOperator:()=>zMe,isCommentTerminal:()=>HR,isDataType:()=>GMe,isDataTypeRule:()=>Jv,isOptionalCardinality:()=>BMe,terminalRegex:()=>Hm});function jne(t){return t.rules.find(e=>Oa(e)&&e.entry)}function Kne(t){return t.rules.filter(e=>Uo(e)&&e.hidden)}function Qv(t,e){let r=new Set,n=jne(t);if(!n)return new Set(t.rules);let i=[n].concat(Kne(t));for(let s of i)Qne(s,r,e);let a=new Set;for(let s of t.rules)(r.has(s.name)||Uo(s)&&s.hidden)&&a.add(s);return a}function Qne(t,e,r){e.add(t.name),Ac(t).forEach(n=>{if(Ml(n)||r&&TT(n)){let i=n.rule.ref;i&&!e.has(i.name)&&Qne(i,e,r)}})}function UR(t){if(t.terminal)return t.terminal;if(t.type.ref){let e=DT(t.type.ref);return e?.terminal}}function HR(t){return t.hidden&&!Hm(t).test(" ")}function YR(t,e){return!t||!e?[]:WR(t,e,t.astNode,!0)}function Zv(t,e,r){if(!t||!e)return;let n=WR(t,e,t.astNode,!0);if(n.length!==0)return r!==void 0?r=Math.max(0,Math.min(r,n.length-1)):r=0,n[r]}function WR(t,e,r,n){if(!n){let i=Qd(t.grammarSource,Nl);if(i&&i.feature===e)return[t]}return co(t)&&t.astNode===r?t.content.flatMap(i=>WR(i,e,r,!1)):[]}function PMe(t,e){return t?XR(t,e,t?.astNode):[]}function qR(t,e,r){if(!t)return;let n=XR(t,e,t?.astNode);if(n.length!==0)return r!==void 0?r=Math.max(0,Math.min(r,n.length-1)):r=0,n[r]}function XR(t,e,r){if(t.astNode!==r)return[];if(Ho(t.grammarSource)&&t.grammarSource.value===e)return[t];let n=qd(t).iterator(),i,a=[];do if(i=n.next(),!i.done){let s=i.value;s.astNode===r?Ho(s.grammarSource)&&s.grammarSource.value===e&&a.push(s):n.prune()}while(!i.done);return a}function jR(t){var e;let r=t.astNode;for(;r===((e=t.container)===null||e===void 0?void 0:e.astNode);){let n=Qd(t.grammarSource,Nl);if(n)return n;t=t.container}}function DT(t){let e=t;return vT(e)&&(Iu(e.$container)?e=e.$container.$container:Oa(e.$container)?e=e.$container:tf(e.$container)),Zne(t,e,new Map)}function Zne(t,e,r){var n;function i(a,s){let l;return Qd(a,Nl)||(l=Zne(s,s,r)),r.set(t,l),l}if(o(i,"go"),r.has(t))return r.get(t);r.set(t,void 0);for(let a of Ac(e)){if(Nl(a)&&a.feature.toLowerCase()==="name")return r.set(t,a),a;if(Ml(a)&&Oa(a.rule.ref))return i(a,a.rule.ref);if(bT(a)&&(!((n=a.typeRef)===null||n===void 0)&&n.ref))return i(a,a.typeRef.ref)}}function Jne(t){let e=t.$container;if(rf(e)){let r=e.elements,n=r.indexOf(t);for(let i=n-1;i>=0;i--){let a=r[i];if(Iu(a))return a;{let s=Ac(r[i]).find(Iu);if(s)return s}}}if(Uv(e))return Jne(e)}function BMe(t,e){return t==="?"||t==="*"||rf(e)&&!!e.guardCondition}function FMe(t){return t==="*"||t==="+"}function zMe(t){return t==="+="}function Jv(t){return eie(t,new Set)}function eie(t,e){if(e.has(t))return!0;e.add(t);for(let r of Ac(t))if(Ml(r)){if(!r.rule.ref||Oa(r.rule.ref)&&!eie(r.rule.ref,e))return!1}else{if(Nl(r))return!1;if(Iu(r))return!1}return!!t.definition}function GMe(t){return VR(t.type,new Set)}function VR(t,e){if(e.has(t))return!0;if(e.add(t),ID(t))return!1;if(ZD(t))return!1;if(iR(t))return t.types.every(r=>VR(r,e));if(bT(t)){if(t.primitiveType!==void 0)return!0;if(t.stringType!==void 0)return!0;if(t.typeRef!==void 0){let r=t.typeRef.ref;return Hv(r)?VR(r.type,e):!1}else return!1}else return!1}function KR(t){if(t.inferredType)return t.inferredType.name;if(t.dataType)return t.dataType;if(t.returnType){let e=t.returnType.ref;if(e){if(Oa(e))return e.name;if(xT(e)||Hv(e))return e.name}}}function r0(t){var e;if(Oa(t))return Jv(t)?t.name:(e=KR(t))!==null&&e!==void 0?e:t.name;if(xT(t)||Hv(t)||JD(t))return t.name;if(Iu(t)){let r=tie(t);if(r)return r}else if(vT(t))return t.name;throw new Error("Cannot get name of Unknown Type")}function tie(t){var e;if(t.inferredType)return t.inferredType.name;if(!((e=t.type)===null||e===void 0)&&e.ref)return r0(t.type.ref)}function QR(t){var e,r,n;return Uo(t)?(r=(e=t.type)===null||e===void 0?void 0:e.name)!==null&&r!==void 0?r:"string":Jv(t)?t.name:(n=KR(t))!==null&&n!==void 0?n:t.name}function Hm(t){let e={s:!1,i:!1,u:!1},r=Ym(t.definition,e),n=Object.entries(e).filter(([,i])=>i).map(([i])=>i).join("");return new RegExp(r,n)}function Ym(t,e){if(wR(t))return $Me(t);if(kR(t))return VMe(t);if(cR(t))return YMe(t);if(TT(t)){let r=t.rule.ref;if(!r)throw new Error("Missing rule reference.");return Ou(Ym(r.definition),{cardinality:t.cardinality,lookahead:t.lookahead})}else{if(gR(t))return HMe(t);if(AR(t))return UMe(t);if(vR(t)){let r=t.regex.lastIndexOf("/"),n=t.regex.substring(1,r),i=t.regex.substring(r+1);return e&&(e.i=i.includes("i"),e.s=i.includes("s"),e.u=i.includes("u")),Ou(n,{cardinality:t.cardinality,lookahead:t.lookahead,wrap:!1})}else{if(LR(t))return Ou(ZR,{cardinality:t.cardinality,lookahead:t.lookahead});throw new Error(`Invalid terminal element: ${t?.$type}`)}}}function $Me(t){return Ou(t.elements.map(e=>Ym(e)).join("|"),{cardinality:t.cardinality,lookahead:t.lookahead})}function VMe(t){return Ou(t.elements.map(e=>Ym(e)).join(""),{cardinality:t.cardinality,lookahead:t.lookahead})}function UMe(t){return Ou(`${ZR}*?${Ym(t.terminal)}`,{cardinality:t.cardinality,lookahead:t.lookahead})}function HMe(t){return Ou(`(?!${Ym(t.terminal)})${ZR}*?`,{cardinality:t.cardinality,lookahead:t.lookahead})}function YMe(t){return t.right?Ou(`[${$R(t.left)}-${$R(t.right)}]`,{cardinality:t.cardinality,lookahead:t.lookahead,wrap:!1}):Ou($R(t.left),{cardinality:t.cardinality,lookahead:t.lookahead,wrap:!1})}function $R(t){return t0(t.value)}function Ou(t,e){var r;return(e.wrap!==!1||e.lookahead)&&(t=`(${(r=e.lookahead)!==null&&r!==void 0?r:""}${t})`),e.cardinality?`${t}${e.cardinality}`:t}var ZR,Il=R(()=>{"use strict";pT();Sc();Vo();es();Rl();Um();o(jne,"getEntryRule");o(Kne,"getHiddenRules");o(Qv,"getAllReachableRules");o(Qne,"ruleDfs");o(UR,"getCrossReferenceTerminal");o(HR,"isCommentTerminal");o(YR,"findNodesForProperty");o(Zv,"findNodeForProperty");o(WR,"findNodesForPropertyInternal");o(PMe,"findNodesForKeyword");o(qR,"findNodeForKeyword");o(XR,"findNodesForKeywordInternal");o(jR,"findAssignment");o(DT,"findNameAssignment");o(Zne,"findNameAssignmentInternal");o(Jne,"getActionAtElement");o(BMe,"isOptionalCardinality");o(FMe,"isArrayCardinality");o(zMe,"isArrayOperator");o(Jv,"isDataTypeRule");o(eie,"isDataTypeRuleInternal");o(GMe,"isDataType");o(VR,"isDataTypeInternal");o(KR,"getExplicitRuleType");o(r0,"getTypeName");o(tie,"getActionType");o(QR,"getRuleType");o(Hm,"terminalRegex");ZR=/[\s\S]/.source;o(Ym,"abstractElementToRegex");o($Me,"terminalAlternativesToRegex");o(VMe,"terminalGroupToRegex");o(UMe,"untilTokenToRegex");o(HMe,"negateTokenToRegex");o(YMe,"characterRangeToRegex");o($R,"keywordToRegex");o(Ou,"withCardinality")});function JR(t){let e=[],r=t.Grammar;for(let n of r.rules)Uo(n)&&HR(n)&&FR(Hm(n))&&e.push(n.name);return{multilineCommentRules:e,nameRegexp:fT}}var eN=R(()=>{"use strict";Rl();Il();Um();Sc();o(JR,"createGrammarConfig")});var tN=R(()=>{"use strict"});function Wm(t){console&&console.error&&console.error(`Error: ${t}`)}function e2(t){console&&console.warn&&console.warn(`Warning: ${t}`)}var rie=R(()=>{"use strict";o(Wm,"PRINT_ERROR");o(e2,"PRINT_WARNING")});function t2(t){let e=new Date().getTime(),r=t();return{time:new Date().getTime()-e,value:r}}var nie=R(()=>{"use strict";o(t2,"timer")});function r2(t){function e(){}o(e,"FakeConstructor"),e.prototype=t;let r=new e;function n(){return typeof r.bar}return o(n,"fakeAccess"),n(),n(),t;(0,eval)(t)}var iie=R(()=>{"use strict";o(r2,"toFastProperties")});var qm=R(()=>{"use strict";rie();nie();iie()});function WMe(t){return qMe(t)?t.LABEL:t.name}function qMe(t){return di(t.LABEL)&&t.LABEL!==""}function NT(t){return qe(t,Xm)}function Xm(t){function e(r){return qe(r,Xm)}if(o(e,"convertDefinition"),t instanceof Zr){let r={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};return di(t.label)&&(r.label=t.label),r}else{if(t instanceof Sn)return{type:"Alternative",definition:e(t.definition)};if(t instanceof Jr)return{type:"Option",idx:t.idx,definition:e(t.definition)};if(t instanceof An)return{type:"RepetitionMandatory",idx:t.idx,definition:e(t.definition)};if(t instanceof _n)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:Xm(new fr({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof mn)return{type:"RepetitionWithSeparator",idx:t.idx,separator:Xm(new fr({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof br)return{type:"Repetition",idx:t.idx,definition:e(t.definition)};if(t instanceof gn)return{type:"Alternation",idx:t.idx,definition:e(t.definition)};if(t instanceof fr){let r={type:"Terminal",name:t.terminalType.name,label:WMe(t.terminalType),idx:t.idx};di(t.label)&&(r.terminalLabel=t.label);let n=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(r.pattern=zo(n)?n.source:n),r}else{if(t instanceof ts)return{type:"Rule",name:t.name,orgText:t.orgText,definition:e(t.definition)};throw Error("non exhaustive match")}}}var ho,Zr,ts,Sn,Jr,An,_n,br,mn,gn,fr,MT=R(()=>{"use strict";Pt();o(WMe,"tokenLabel");o(qMe,"hasTokenLabel");ho=class{static{o(this,"AbstractProduction")}get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),Ee(this.definition,r=>{r.accept(e)})}},Zr=class extends ho{static{o(this,"NonTerminal")}constructor(e){super([]),this.idx=1,pa(this,Ls(e,r=>r!==void 0))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}},ts=class extends ho{static{o(this,"Rule")}constructor(e){super(e.definition),this.orgText="",pa(this,Ls(e,r=>r!==void 0))}},Sn=class extends ho{static{o(this,"Alternative")}constructor(e){super(e.definition),this.ignoreAmbiguities=!1,pa(this,Ls(e,r=>r!==void 0))}},Jr=class extends ho{static{o(this,"Option")}constructor(e){super(e.definition),this.idx=1,pa(this,Ls(e,r=>r!==void 0))}},An=class extends ho{static{o(this,"RepetitionMandatory")}constructor(e){super(e.definition),this.idx=1,pa(this,Ls(e,r=>r!==void 0))}},_n=class extends ho{static{o(this,"RepetitionMandatoryWithSeparator")}constructor(e){super(e.definition),this.idx=1,pa(this,Ls(e,r=>r!==void 0))}},br=class extends ho{static{o(this,"Repetition")}constructor(e){super(e.definition),this.idx=1,pa(this,Ls(e,r=>r!==void 0))}},mn=class extends ho{static{o(this,"RepetitionWithSeparator")}constructor(e){super(e.definition),this.idx=1,pa(this,Ls(e,r=>r!==void 0))}},gn=class extends ho{static{o(this,"Alternation")}get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,pa(this,Ls(e,r=>r!==void 0))}},fr=class{static{o(this,"Terminal")}constructor(e){this.idx=1,pa(this,Ls(e,r=>r!==void 0))}accept(e){e.visit(this)}};o(NT,"serializeGrammar");o(Xm,"serializeProduction")});var rs,aie=R(()=>{"use strict";MT();rs=class{static{o(this,"GAstVisitor")}visit(e){let r=e;switch(r.constructor){case Zr:return this.visitNonTerminal(r);case Sn:return this.visitAlternative(r);case Jr:return this.visitOption(r);case An:return this.visitRepetitionMandatory(r);case _n:return this.visitRepetitionMandatoryWithSeparator(r);case mn:return this.visitRepetitionWithSeparator(r);case br:return this.visitRepetition(r);case gn:return this.visitAlternation(r);case fr:return this.visitTerminal(r);case ts:return this.visitRule(r);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}}});function rN(t){return t instanceof Sn||t instanceof Jr||t instanceof br||t instanceof An||t instanceof _n||t instanceof mn||t instanceof fr||t instanceof ts}function n0(t,e=[]){return t instanceof Jr||t instanceof br||t instanceof mn?!0:t instanceof gn?Nv(t.definition,n=>n0(n,e)):t instanceof Zr&&Fn(e,t)?!1:t instanceof ho?(t instanceof Zr&&e.push(t),Ia(t.definition,n=>n0(n,e))):!1}function nN(t){return t instanceof gn}function Rs(t){if(t instanceof Zr)return"SUBRULE";if(t instanceof Jr)return"OPTION";if(t instanceof gn)return"OR";if(t instanceof An)return"AT_LEAST_ONE";if(t instanceof _n)return"AT_LEAST_ONE_SEP";if(t instanceof mn)return"MANY_SEP";if(t instanceof br)return"MANY";if(t instanceof fr)return"CONSUME";throw Error("non exhaustive match")}var sie=R(()=>{"use strict";Pt();MT();o(rN,"isSequenceProd");o(n0,"isOptionalProd");o(nN,"isBranchingProd");o(Rs,"getProductionDslName")});var ns=R(()=>{"use strict";MT();aie();sie()});function oie(t,e,r){return[new Jr({definition:[new fr({terminalType:t.separator})].concat(t.definition)})].concat(e,r)}var Pu,IT=R(()=>{"use strict";Pt();ns();Pu=class{static{o(this,"RestWalker")}walk(e,r=[]){Ee(e.definition,(n,i)=>{let a=fi(e.definition,i+1);if(n instanceof Zr)this.walkProdRef(n,a,r);else if(n instanceof fr)this.walkTerminal(n,a,r);else if(n instanceof Sn)this.walkFlat(n,a,r);else if(n instanceof Jr)this.walkOption(n,a,r);else if(n instanceof An)this.walkAtLeastOne(n,a,r);else if(n instanceof _n)this.walkAtLeastOneSep(n,a,r);else if(n instanceof mn)this.walkManySep(n,a,r);else if(n instanceof br)this.walkMany(n,a,r);else if(n instanceof gn)this.walkOr(n,a,r);else throw Error("non exhaustive match")})}walkTerminal(e,r,n){}walkProdRef(e,r,n){}walkFlat(e,r,n){let i=r.concat(n);this.walk(e,i)}walkOption(e,r,n){let i=r.concat(n);this.walk(e,i)}walkAtLeastOne(e,r,n){let i=[new Jr({definition:e.definition})].concat(r,n);this.walk(e,i)}walkAtLeastOneSep(e,r,n){let i=oie(e,r,n);this.walk(e,i)}walkMany(e,r,n){let i=[new Jr({definition:e.definition})].concat(r,n);this.walk(e,i)}walkManySep(e,r,n){let i=oie(e,r,n);this.walk(e,i)}walkOr(e,r,n){let i=r.concat(n);Ee(e.definition,a=>{let s=new Sn({definition:[a]});this.walk(s,i)})}};o(oie,"restForRepetitionWithSeparator")});function i0(t){if(t instanceof Zr)return i0(t.referencedRule);if(t instanceof fr)return KMe(t);if(rN(t))return XMe(t);if(nN(t))return jMe(t);throw Error("non exhaustive match")}function XMe(t){let e=[],r=t.definition,n=0,i=r.length>n,a,s=!0;for(;i&&s;)a=r[n],s=n0(a),e=e.concat(i0(a)),n=n+1,i=r.length>n;return Pm(e)}function jMe(t){let e=qe(t.definition,r=>i0(r));return Pm(Gr(e))}function KMe(t){return[t.terminalType]}var iN=R(()=>{"use strict";Pt();ns();o(i0,"first");o(XMe,"firstForSequence");o(jMe,"firstForBranching");o(KMe,"firstForTerminal")});var OT,aN=R(()=>{"use strict";OT="_~IN~_"});function lie(t){let e={};return Ee(t,r=>{let n=new sN(r).startWalking();pa(e,n)}),e}function QMe(t,e){return t.name+e+OT}var sN,cie=R(()=>{"use strict";IT();iN();Pt();aN();ns();sN=class extends Pu{static{o(this,"ResyncFollowsWalker")}constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,r,n){}walkProdRef(e,r,n){let i=QMe(e.referencedRule,e.idx)+this.topProd.name,a=r.concat(n),s=new Sn({definition:a}),l=i0(s);this.follows[i]=l}};o(lie,"computeAllProdsFollows");o(QMe,"buildBetweenProdsFollowPrefix")});function jm(t){let e=t.toString();if(PT.hasOwnProperty(e))return PT[e];{let r=ZMe.pattern(e);return PT[e]=r,r}}function uie(){PT={}}var PT,ZMe,BT=R(()=>{"use strict";Kv();PT={},ZMe=new Jd;o(jm,"getRegExpAst");o(uie,"clearRegExpParserCache")});function die(t,e=!1){try{let r=jm(t);return oN(r.value,{},r.flags.ignoreCase)}catch(r){if(r.message===fie)e&&e2(`${n2} Unable to optimize: < ${t.toString()} > [all...] |
/plugin/bpmnio/vendor/dmn-js/dist/ |
H A D | dmn-navigated-viewer.production.min.js | 16 */function ys(e){this._container=this._createContainer(),uo(this._container),this._init(this._container,e)}function ws(e,t){return{x:e.x-t.x,y:e.y-t.y}}function bs(e){return Math.log(e)/Math.log(10)}function xs(e,t){var n=bs(e.min),i=bs(e.max);return(Math.abs(n)+Math.abs(i))/t}Yt(ys,wi),ys.prototype.saveSVG=zt((function(e){var t=this;return new Promise((function(e){var n=t.get("canvas"),i=n.getActiveLayer(),r=Vt("defs",n._svg),o=Tn(i),s=r&&r.outerHTML||"",a=i.getBBox();e({svg:'<?xml version="1.0" encoding="utf-8"?>\n\x3c!-- created with dmn-js / http://bpmn.io --\x3e\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'+a.width+'" height="'+a.height+'" viewBox="'+a.x+" "+a.y+" "+a.width+" "+a.height+'" version="1.1">'+s+o+"</svg>"})}))})),ys.prototype.getModules=function(){return this._modules},ys.prototype.destroy=function(){wi.prototype.destroy.call(this),$t(this._container)},ys.prototype.on=function(e,t,n,i){return this.get("eventBus").on(e,t,n,i)},ys.prototype.off=function(e,t){this.get("eventBus").off(e,t)},ys.prototype._init=function(e,t){var{additionalModules:n,canvas:i,...r}=t,o={...r,canvas:{...i,container:e},modules:[...[{drd:["value",this]}],...t.modules||this.getModules(),...n||[]]};wi.call(this,o),t&&t.container&&this.attachTo(t.container)},ys.prototype._emit=function(e,t){return this.get("eventBus").fire(e,t)},ys.prototype._createContainer=function(){return Ft('<div class="dmn-drd-container"></div>')},ys.prototype.open=function(e){var t=this;return new Promise(((n,i)=>{var r;try{return t._definitions&&t.clear(),t._definitions=e,function(e,t,n){var i,r=e.get("drdImporter"),o=e.get("eventBus"),s=[];o.fire("import.start",{definitions:t});try{!function(e){new ki({root:function(e){return r.root(e)},element:function(e,t){return r.add(e,t)},error:function(e,t){s.push({message:e,context:t})}}).handleDefinitions(e)}(t)}catch(e){i=e}o.fire("import.done",{error:i,warnings:s}),n(i,s)}(t,e,(function(e,t){e?(e.warnings=t||[],i(e)):n({warnings:t||[]})}))}catch(e){r=e}r?(r.warnings=r.warnings||[],i(r)):n({warnings:[]})}))},ys.prototype.attachTo=function(e){if(!e)throw new Error("parentNode required");this.detach();var t=this._container;e.appendChild(t),this._emit("attach",{}),this.get("canvas").resized()},ys.prototype.detach=function(){var e=this._container,t=e.parentNode;t&&(this._emit("detach",{}),t.removeChild(e))},ys.prototype._modules=[$o,zo,rs,us,fs,vs];var _s=Math.sign||function(e){return e>=0?1:-1},Ss={min:.2,max:4};function ks(e,t,n){e=e||{},this._enabled=!1,this._canvas=n,this._container=n._container,this._handleWheel=x(this._handleWheel,this),this._totalDelta=0,this._scale=e.scale||.75;var i=this;t.on("canvas.init",(function(t){i._init(!1!==e.enabled)}))}ks.$inject=["config.zoomScroll","eventBus","canvas"],ks.prototype.scroll=function(e){this._canvas.scroll(e)},ks.prototype.reset=function(){this._canvas.zoom("fit-viewport")},ks.prototype.zoom=function(e,t){var n=xs(Ss,20);this._totalDelta+=e,Math.abs(this._totalDelta)>.1&&(this._zoom(e,t,n),this._totalDelta=0)},ks.prototype._handleWheel=function(e){if(!Mt(e.target,".djs-scrollable",!0)){var t=this._container;e.preventDefault();var n,i=e.ctrlKey||/mac/i.test(navigator.platform)&&e.metaKey,r=e.shiftKey,o=-1*this._scale;if(o*=i?0===e.deltaMode?.02:.32:0===e.deltaMode?1:16,i){var s=t.getBoundingClientRect(),a={x:e.clientX-s.left,y:e.clientY-s.top};n=Math.sqrt(Math.pow(e.deltaY,2)+Math.pow(e.deltaX,2))*_s(e.deltaY)*o,this.zoom(n,a)}else n=r?{dx:o*e.deltaY,dy:0}:{dx:o*e.deltaX,dy:o*e.deltaY},this.scroll(n)}},ks.prototype.stepZoom=function(e,t){var n=xs(Ss,10);this._zoom(e,t,n)},ks.prototype._zoom=function(e,t,n){var i=this._canvas,r=e>0?1:-1,o=bs(i.zoom()),s=Math.round(o/n)*n;s+=n*r;var a,l,c=Math.pow(10,s);i.zoom((a=Ss,l=c,Math.max(a.min,Math.min(a.max,l))),t)},ks.prototype.toggle=function(e){var t=this._container,n=this._handleWheel,i=this._enabled;return void 0===e&&(e=!i),i!==e&&Nt[e?"bind":"unbind"](t,"wheel",n,!1),this._enabled=e,e},ks.prototype._init=function(e){this.toggle(e)};var Cs={__init__:["zoomScroll"],zoomScroll:["type",ks]},Es=/^djs-cursor-.*$/;function Ms(e){var t=kt(document.body);t.removeMatching(Es),e&&t.add("djs-cursor-"+e)}var As=5e3;function Rs(e,t){var n;function i(i){var r,o=n.start,s=n.button,a=Wo(i),l=ws(a,o);(!n.dragging&&(r=l,Math.sqrt(Math.pow(r.x,2)+Math.pow(r.y,2))>15)&&(n.dragging=!0,0===s&&function(e,t){function n(){return!1}t=t||"element.click",e.once(t,As,n)}(e),Ms("grab")),n.dragging)&&(l=ws(a,n.last||n.start),t.scroll({dx:l.x,dy:l.y}),n.last=a);i.preventDefault()}function r(e){Nt.unbind(document,"mousemove",i),Nt.unbind(document,"mouseup",r),n=null,Ms(null)}e.on("element.mousedown",500,(function(e){return function(e){if(Mt(e.target,".djs-draggable"))return;var t=e.button;if(t>=2||e.ctrlKey||e.shiftKey||e.altKey)return;return n={button:t,start:Wo(e)},Nt.bind(document,"mousemove",i),Nt.bind(document,"mouseup",r),!0}(e.originalEvent)})),this.isActive=function(){return!!n}}Rs.$inject=["eventBus","canvas"];var Ts={__init__:["moveCanvas"],moveCanvas:["type",Rs]},Ds={"&":"&","<":"<",">":">",'"':""","'":"'"};function Os(e,t){return-1!==(e=i(e)?e:[e]).indexOf(t.key)||-1!==e.indexOf(t.code)}function Ns(e,t,n,i){this._open=!1,this._results={},this._eventMaps=[],this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._canvas=e,this._eventBus=t,this._selection=n,this._translate=i,this._container=this._getBoxHtml(),this._searchInput=Vt(Ns.INPUT_SELECTOR,this._container),this._resultsContainer=Vt(Ns.RESULTS_CONTAINER_SELECTOR,this._container),this._canvas.getContainer().appendChild(this._container),t.on(["canvas.destroy","diagram.destroy","drag.init","elements.changed"],this.close,this)}function Ps(e,t,n){var i=function(e){var t="";return e.forEach((function(e){var n,i=(n=""+(n=e.value||e.matched||e.normal))&&n.replace(/[&<>"']/g,(function(e){return Ds[e]})),r=e.match||e.matched;t+=r?'<b class="'+Ns.RESULT_HIGHLIGHT_CLASS+'">'+i+"</b>":i})),""!==t?t:null}(t),r=Ft(n);r.innerHTML=i,e.appendChild(r)}Ns.$inject=["canvas","eventBus","selection","translate"],Ns.prototype._bindEvents=function(){var e=this;function t(t,n,i,r){e._eventMaps.push({el:t,type:i,listener:Bt.bind(t,n,i,r)})}t(document,"html","click",(function(t){e.close(!1)})),t(this._container,Ns.INPUT_SELECTOR,"click",(function(e){e.stopPropagation(),e.delegateTarget.focus()})),t(this._container,Ns.RESULT_SELECTOR,"mouseover",(function(t){t.stopPropagation(),e._scrollToNode(t.delegateTarget),e._preselect(t.delegateTarget)})),t(this._container,Ns.RESULT_SELECTOR,"click",(function(t){t.stopPropagation(),e._select(t.delegateTarget)})),t(this._container,Ns.INPUT_SELECTOR,"keydown",(function(e){Os("ArrowUp",e)&&e.preventDefault(),Os("ArrowDown",e)&&e.preventDefault()})),t(this._container,Ns.INPUT_SELECTOR,"keyup",(function(t){if(Os("Escape",t))return e.close();if(Os("Enter",t)){var n=e._getCurrentResult();return n?e._select(n):e.close(!1)}return Os("ArrowUp",t)?e._scrollToDirection(!0):Os("ArrowDown",t)?e._scrollToDirection():void(Os(["ArrowLeft","ArrowRight"],t)||e._search(t.delegateTarget.value))}))},Ns.prototype._unbindEvents=function(){this._eventMaps.forEach((function(e){Bt.unbind(e.el,e.type,e.listener)}))},Ns.prototype._search=function(e){var t=this;if(this._clearResults(),e&&""!==e){var n=this._searchProvider.find(e);if((n=n.filter((function(e){return!t._canvas.getRootElements().includes(e.element)}))).length){n.forEach((function(e){var n=e.element.id,i=t._createResultNode(e,n);t._results[n]={element:e.element,node:i}}));var i=Vt(Ns.RESULT_SELECTOR,this._resultsContainer);this._scrollToNode(i),this._preselect(i)}else this._selection.select(null)}},Ns.prototype._scrollToDirection=function(e){var t=this._getCurrentResult();if(t){var n=e?t.previousElementSibling:t.nextElementSibling;n&&(this._scrollToNode(n),this._preselect(n))}},Ns.prototype._scrollToNode=function(e){if(e&&e!==this._getCurrentResult()){var t=e.offsetTop,n=this._resultsContainer.scrollTop,i=t-this._resultsContainer.clientHeight+e.clientHeight;t<n?this._resultsContainer.scrollTop=t:n<i&&(this._resultsContainer.scrollTop=i)}},Ns.prototype._clearResults=function(){Et(this._resultsContainer),this._results={},this._eventBus.fire("searchPad.cleared")},Ns.prototype._getCurrentResult=function(){return Vt(Ns.RESULT_SELECTED_SELECTOR,this._resultsContainer)},Ns.prototype._createResultNode=function(e,t){var n=Ft(Ns.RESULT_HTML);return e.primaryTokens.length>0&&Ps(n,e.primaryTokens,Ns.RESULT_PRIMARY_HTML),Ps(n,e.secondaryTokens,Ns.RESULT_SECONDARY_HTML),_t(n,Ns.RESULT_ID_ATTRIBUTE,t),this._resultsContainer.appendChild(n),n},Ns.prototype.registerProvider=function(e){this._searchProvider=e},Ns.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,kt(this._canvas.getContainer()).add("djs-search-open"),kt(this._container).add("open"),this._searchInput.focus(),this._eventBus.fire("searchPad.opened"))},Ns.prototype.close=function(e=!0){this.isOpen()&&(e&&(this._cachedRootElement&&this._canvas.setRootElement(this._cachedRootElement),this._cachedSelection&&this._selection.select(this._cachedSelection),this._cachedViewbox&&this._canvas.viewbox(this._cachedViewbox),this._eventBus.fire("searchPad.restored")),this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._unbindEvents(),this._open=!1,kt(this._canvas.getContainer()).remove("djs-search-open"),kt(this._container).remove("open"),this._clearResults(),this._searchInput.value="",this._searchInput.blur(),this._eventBus.fire("searchPad.closed"),this._canvas.restoreFocus())},Ns.prototype.toggle=function(){this.isOpen()?this.close():this.open()},Ns.prototype.isOpen=function(){return this._open},Ns.prototype._preselect=function(e){var t=this._getCurrentResult();if(e!==t){t&&kt(t).remove(Ns.RESULT_SELECTED_CLASS);var n=_t(e,Ns.RESULT_ID_ATTRIBUTE),i=this._results[n].element;kt(e).add(Ns.RESULT_SELECTED_CLASS),this._canvas.scrollToElement(i,{top:300}),this._selection.select(i),this._eventBus.fire("searchPad.preselected",i)}},Ns.prototype._select=function(e){var t=_t(e,Ns.RESULT_ID_ATTRIBUTE),n=this._results[t].element;this._cachedSelection=null,this._cachedViewbox=null,this.close(!1),this._canvas.scrollToElement(n,{top:300}),this._selection.select(n),this._eventBus.fire("searchPad.selected",n)},Ns.prototype._getBoxHtml=function(){const e=Ft(Ns.BOX_HTML),t=Vt(Ns.INPUT_SELECTOR,e);return t&&t.setAttribute("aria-label",this._translate("Search in diagram")),e},Ns.CONTAINER_SELECTOR=".djs-search-container",Ns.INPUT_SELECTOR=".djs-search-input input",Ns.RESULTS_CONTAINER_SELECTOR=".djs-search-results",Ns.RESULT_SELECTOR=".djs-search-result",Ns.RESULT_SELECTED_CLASS="djs-search-result-selected",Ns.RESULT_SELECTED_SELECTOR="."+Ns.RESULT_SELECTED_CLASS,Ns.RESULT_ID_ATTRIBUTE="data-result-id",Ns.RESULT_HIGHLIGHT_CLASS="djs-search-highlight",Ns.BOX_HTML='<div class="djs-search-container djs-scrollable">\n <div class="djs-search-input">\n <svg class="djs-search-icon" width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M9.0325 8.5H9.625L13.3675 12.25L12.25 13.3675L8.5 9.625V9.0325L8.2975 8.8225C7.4425 9.5575 6.3325 10 5.125 10C2.4325 10 0.25 7.8175 0.25 5.125C0.25 2.4325 2.4325 0.25 5.125 0.25C7.8175 0.25 10 2.4325 10 5.125C10 6.3325 9.5575 7.4425 8.8225 8.2975L9.0325 8.5ZM1.75 5.125C1.75 6.9925 3.2575 8.5 5.125 8.5C6.9925 8.5 8.5 6.9925 8.5 5.125C8.5 3.2575 6.9925 1.75 5.125 1.75C3.2575 1.75 1.75 3.2575 1.75 5.125Z" fill="#22242A"/>\n </svg>\n <input type="text" spellcheck="false" />\n </div>\n <div class="djs-search-results" />\n</div>',Ns.RESULT_HTML='<div class="djs-search-result"></div>',Ns.RESULT_PRIMARY_HTML='<div class="djs-search-result-primary"></div>',Ns.RESULT_SECONDARY_HTML='<p class="djs-search-result-secondary"></p>';var qs={__depends__:[zo,us,rs],searchPad:["type",Ns]};function Bs(e){var t=e.businessObject,n=function(e){return bi(e,"dmn:Decision")||bi(e,"dmn:BusinessKnowledgeModel")||bi(e,"dmn:InputData")||bi(e,"dmn:KnowledgeSource")?"name":bi(e,"dmn:TextAnnotation")?"text":void 0}(t);if(n)return t[n]||""}function Ls(e,t,n){this._elementRegistry=e,this._canvas=n,t.registerProvider(this)}function Is(e){return h(e,(function(e){return!!e.matched})).length>0}function js(e,t){const n=[],i=e;if(!e)return n;e=e.toLowerCase(),t=t.toLowerCase();const r=e.indexOf(t);return r>-1?(0!==r&&n.push({normal:i.substr(0,r)}),n.push({matched:i.substr(r,t.length)}),t.length+r<e.length&&n.push({normal:i.substr(t.length+r,e.length)})):n.push({normal:i}),n}Ls.$inject=["elementRegistry","searchPad","canvas"],Ls.prototype.find=function(e){const t=this._canvas.getRootElement();let n=this._elementRegistry.filter((function(e){return!e.labelTarget}));return n=h(n,(function(e){return e!==t})),n=f(n,(function(t){return{primaryTokens:js(Bs(t),e),secondaryTokens:js(t.id,e),element:t}})),n=h(n,(function(e){return Is(e.primaryTokens)||Is(e.secondaryTokens)})),n=g(n,(function(e){return Bs(e.element)+e.element.id})),n};var Fs={__depends__:[qs],__init__:["dmnSearch"],dmnSearch:["type",Ls]};function Vs(e){ys.call(this,e)}Yt(Vs,ys),Vs.prototype._navigationModules=[Cs,Ts,Fs],Vs.prototype._modules=[].concat(Vs.prototype._modules,Vs.prototype._navigationModules);class $s{constructor(e){_(this,e),Hs(this,"businessObject",{writable:!0})}}const zs={root:class extends $s{constructor(e){super(e),Hs(this,"rows",{enumerable:!0,value:this.rows||[]}),Hs(this,"cols",{enumerable:!0,value:this.cols||[]})}},row:class extends $s{constructor(e){super(e),Hs(this,"root",{writable:!0}),Hs(this,"cells",{enumerable:!0,value:this.cells||[]})}},col:class extends $s{constructor(e){super(e),Hs(this,"root",{writable:!0}),Hs(this,"cells",{enumerable:!0,value:this.cells||[]})}},cell:class extends $s{constructor(e){super(e),Hs(this,"row",{writable:!0}),Hs(this,"col",{writable:!0})}}};function Hs(e,t,n){Object.defineProperty(e,t,n)}let Ws=class{constructor(e){this._eventBus=e,this._elements={},e.on("table.clear",this.clear.bind(this))}add(e,t){const{id:n}=e;this._elements[n]=e}remove(e){const t=e.id||e;delete this._elements[t]}get(e){return this._elements[e]}getAll(){return Us(this._elements)}forEach(e){Us(this._elements).forEach((t=>e(t)))}filter(e){return Us(this._elements).filter((t=>e(t)))}clear(){this._elements={}}updateId(e,t){this._validateId(t),"string"==typeof e&&(e=this.get(e)),this._eventBus.fire("element.updateId",{element:e,newId:t}),this.remove(e),e.id=t,this.add(e)}_validateId(e){if(!e)throw new Error("element must have an id");if(this._elements[e])throw new Error("element with id "+e+" already added")}};function Us(e){return Object.keys(e).map((function(t){return e[t]}))}Ws.$inject=["eventBus"];let Gs=class{constructor(e){this._listeners={},e.on("elements.changed",(({elements:e})=>{this.elementsChanged(e)})),e.on("root.remove",(t=>{const n=t.root.id;this._listeners[n]&&e.once("root.add",(e=>{const t=e.root.id;this.updateId(n,t)}))})),e.on("element.updateId",(({element:e,newId:t})=>{this.updateId(e.id,t)}))}elementsChanged(e){const t={},n=e.length;for(let i=0;i<n;i++){const{id:n}=e[i];if(t[n])return;t[n]=!0;const r=this._listeners[n]&&this._listeners[n].length;if(r)for(let e=0;e<r;e++)this._listeners[n][e]&&this._listeners[n][e]()}}onElementsChanged(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e][this._listeners[e].length]=t}offElementsChanged(e,t){if(this._listeners[e])if(t){const n=this._listeners[e].indexOf(t);-1!==n&&this._listeners[e].splice(n,1)}else this._listeners[e].length=0}updateId(e,t){this._listeners[e]&&(this._listeners[t]=this._listeners[e],delete this._listeners[e])}};Gs.$inject=["eventBus"];class Ks extends lo{constructor(e){super(e);const t=this._injector=e.injector;this._sheet=t.get("sheet"),this._changeSupport=t.get("changeSupport"),this._components=t.get("components"),this._eventBus=t.get("eventBus");const n=t.get("throttle");this.onElementsChanged=this.onElementsChanged.bind(this),this.onScroll=n(this.onScroll.bind(this))}onElementsChanged(){this.forceUpdate()}onScroll(){this._eventBus.fire("sheet.scroll")}getChildContext(){return{changeSupport:this._changeSupport,components:this._components,injector:this._injector}}componentWillMount(){const{id:e}=this._sheet.getRoot();this._changeSupport.onElementsChanged(e,this.onElementsChanged)}componentWillUnmount(){const{id:e}=this._sheet.getRoot();this._changeSupport.offElementsChanged(e,this.onElementsChanged)}render(){const{rows:e,cols:t}=this._sheet.getRoot(),n=this._components.getComponents("table.before"),i=this._components.getComponents("table.after"),r=this._components.getComponent("table.head"),o=this._components.getComponent("table.body"),s=this._components.getComponent("table.foot");return Ui(1,"div","tjs-container",[n&&n.map(((e,t)=>Gi(2,e,null,t))),Ui(1,"div","tjs-table-container",Ui(1,"table","tjs-table",[r&&Gi(2,r,{rows:e,cols:t}),o&&Gi(2,o,{rows:e,cols:t}),s&&Gi(2,s,{rows:e,cols:t})],0),2,{onScroll:this.onScroll}),i&&i.map(((e,t)=>Gi(2,e,null,t)))],0)}}let Xs=class{constructor(e,t,n,i,r){const{container:o}=n;this._container=o,i.on("root.added",(()=>{io(Gi(2,Ks,{injector:r}),o)})),i.on("root.remove",(()=>{io(null,o)}))}getContainer(){return this._container}};Xs.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var Ys={__init__:["changeSupport","components","renderer"],changeSupport:["type",Gs],components:["type",class{constructor(){this._listeners={}}getComponent(e,t){const n=this._listeners[e];if(!n)return;let i;for(let e=0;e<n.length&&(i=n[e].callback(t),!i);e++);return i}getComponents(e,t){const n=this._listeners[e],i=[];if(!n)return i;for(let e=0;e<n.length;e++){const r=n[e].callback(t);r&&i.push(r)}return i.length,i}onGetComponent(e,t,n){if(s(t)&&(n=t,t=1e3),!o(t))throw new Error("priority must be a number");const i=this._getListeners(e);let r,a;const l={priority:t,callback:n};for(a=0;r=i[a];a++)if(r.priority<t)return void i.splice(a,0,l);i.push(l)}offGetComponent(e,t){const n=this._getListeners(e);let i,r,o;if(t)for(o=n.length-1;i=n[o];o--)r=i.callback,r===t&&n.splice(o,1);else n.length=0}_getListeners(e){let t=this._listeners[e];return t||(this._listeners[e]=t=[]),t}}],renderer:["type",Xs]};class Js{constructor(e,t){this._elementRegistry=e,this._eventBus=t,this._root=null,t.on("table.clear",(()=>{this.setRoot(null)}))}setRoot(e){if(this._root){const e=this._root;this._eventBus.fire("root.remove",{root:e}),this._root=null,this._eventBus.fire("root.removed",{root:e})}e&&this._eventBus.fire("root.add",{root:e}),this._root=e,e&&this._eventBus.fire("root.added",{root:e})}getRoot(){return this._root||this.setRoot({id:"__implicitroot",rows:[],cols:[]}),this._root}addRow(e,t){const n=this.getRoot();if(n.cols.length!=e.cells.length)throw new Error("number of cells is not equal to number of cols");return void 0===t&&(t=n.rows.length),Qs(t,n.rows,e),e.root=n,this._elementRegistry.add(e),e.cells.forEach(((i,r)=>{this._elementRegistry.add(i),i.row=e,i.col=n.cols[r],Qs(t,n.cols[r].cells,i)})),this._eventBus.fire("row.add",{row:e}),e}removeRow(e){const t=this.getRoot();"string"==typeof e&&(e=this._elementRegistry.get(e));const n=t.rows.indexOf(e);-1!==n&&(Zs(n,t.rows),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach(((e,i)=>{this._elementRegistry.remove(e),e.col=void 0,Zs(n,t.cols[i].cells)})),this._eventBus.fire("row.remove",{row:e}))}addCol(e,t){const n=this.getRoot();if(this._elementRegistry.add(e),n.rows.length!=e.cells.length)throw new Error("number of cells is not equal to number of rows");return void 0===t&&(t=n.cols.length),Qs(t,n.cols,e),e.root=n,e.cells.forEach(((i,r)=>{this._elementRegistry.add(i),i.col=e,i.row=n.rows[r],Qs(t,n.rows[r].cells,i)})),this._eventBus.fire("col.add",{col:e}),e}removeCol(e){const t=this.getRoot();"string"==typeof e&&(e=this._elementRegistry.get(e));const n=t.cols.indexOf(e);-1!==n&&(Zs(n,t.cols),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach(((e,i)=>{this._elementRegistry.remove(e),e.row=void 0,Zs(n,t.rows[i].cells)})),this._eventBus.fire("col.remove",{col:e}))}resized(){this._eventBus.fire("sheet.resized")}}function Qs(e,t,n){return t.splice(e,0,n)}function Zs(e,t){return t.splice(e,1)}function ea(e=!0){const t="number"==typeof e?e:e?300:0;return t?e=>function(e,t){let n=!1;return function(...i){n||(e(...i),n=!0,setTimeout((()=>{n=!1}),t))}}(e,t):e=>e}Js.$inject=["elementRegistry","eventBus"],ea.$inject=["config.throttle"];var ta={__depends__:[Ys],__init__:["elementFactory","sheet"],elementFactory:["type",class{constructor(){this._uid=12}create(e,t={}){return t.id||(t.id=e+"_"+this._uid++),function(e,t){const n=zs[e];if(!n)throw new Error("unknown type "+e);return new n(t)}(e,t)}createRoot(e){return this.create("root",e)}createRow(e){return this.create("row",e)}createCol(e){return this.create("col",e)}createCell(e){return this.create("cell",e)}}],elementRegistry:["type",Ws],eventBus:["type",C],sheet:["type",Js],throttle:["factory",ea]};class na{constructor(e={}){let{injector:t}=e;if(!t){let{modules:n,config:i}=this._init(e);t=function(e,t){const n=[{config:["value",e]},ta].concat(t||[]),i=new sn(n);return i.init(),i}(i,n)}this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("table.init"),this.get("eventBus").fire("diagram.init")}_init(e){let{modules:t,...n}=e;return{modules:t,config:n}}destroy(){const e=this.get("eventBus");e.fire("table.destroy"),e.fire("diagram.destroy")}clear(){const e=this.get("eventBus");e.fire("table.clear"),e.fire("diagram.clear")}}function ia(e){if(!e)return"<null>";const t=e.id?` id="${e.id}"`:"";return`<${e.$type}${t} />`}function ra(e,t){function n(t,n,i){if(t.gfx)throw new Error(`already rendered ${ia(t)}`);return e.element(t,n,i)}function i(e,t,i){u(e,(function(e){n(e,t,i)}))}function r(e,t,i){u(e,(function(e){n(e,t,i)}))}return{handleDecision:function(t){t.id||(t.id="decision");const o=t.decisionLogic;if(!o)throw new Error(`no table for ${ia(t)}`);{if(!o.output)throw new Error(`missing output for ${ia(o)}`);const t=(c=o,e.table(c));o.input&&i(o.input,t,o),i(o.output,t,o),s=o.rule,a=t,l=o,u(s,(function(e){n(e,a,l),r(e.inputEntry,e),r(e.outputEntry,e)}))}var s,a,l,c}}}function oa(e,t){const{elements:n,index:i}=e;return i[t]?e:{elements:[...n,t],index:{...i,[t]:!0}}}function sa(...e){let t={elements:[],index:{}};return e.forEach((function(e){const n=typeof e;"string"===n&&e.length>0?t=oa(t,e):"object"===n&&null!==e&&Object.keys(e).forEach((function(n){e[n]&&(t=oa(t,n))}))})),function(e,t){return e.elements.join(t)}(t," ")}function aa(e){return la(e.constructor,e)}function la(e,t){const n=e.$inject;if(!n)return;const{injector:i}=t.context,r=[...n,function(...e){for(const i in e){const r=n[i],o=e[i];t[r]=o}}];i.invoke(r)}function ca(e,t){Object.keys(t).forEach((function(n){if("$inject"===n||"__init"===n)return;const i=t[n];"constructor"===n&&i.call(e,e.props,e.context);const r=e[n];if(void 0!==r){if("function"!=typeof r)throw new Error(`failed to mixin <${n}>: cannot combine with non-fn component value`);e[n]=function(e,...t){return function(...n){let i;return t.forEach((function(t){if(i=t.call(e,...n),void 0!==i)return!1})),i}.bind(e)}(e,r,i)}else e[n]=i.bind(e)})),"$inject"in t&&la(t,e),"__init"in t&&t.__init.call(e,e.props,e.context)}const ha={getSelectionClasses(){const{selected:e,selectedSecondary:t,focussed:n}=this.state;return sa({selected:e,"selected-secondary":t,focussed:n})},selectionChanged(e){this.setState(e)},componentWillUpdate(e){e.elementId!==this.props.elementId&&this.updateSelectionSubscription(!1)},componentDidUpdate(e){e.elementId!==this.props.elementId&&this.updateSelectionSubscription(!0)},componentDidMount(){this.updateSelectionSubscription(!0)},componentWillUnmount(){this.updateSelectionSubscription(!1)},updateSelectionSubscription(e){const{elementId:t}=this.props;t&&t&&this.eventBus[e?"on":"off"](`selection.${t}.changed`,this.selectionChanged)},$inject:["eventBus"]};class ua extends lo{constructor(e,t){super(e,t),ca(this,ha),aa(this)}getRenderProps(...e){const{className:t,elementId:n,coords:i,...r}=this.props,o={className:sa(...e,this.getSelectionClasses(),t)};return n&&(o["data-element-id"]=n),i&&(o["data-coords"]=i),{...o,...r}}}class da extends ua{constructor(e,t){super(e,t),this.state={}}render(){const{children:e}=this.props;return Xi(Ui(1,"td",null,e,0,{...this.getRenderProps("cell")}))}}const pa={slotFill(e,t){const{type:n,context:i,...r}=e,o=this.components.getComponent(n,i)||t;return o?Xi(Gi(2,o,{...i,...r})):null},slotFills(e){const{type:t,context:n,...i}=e;return this.components.getComponents(t,n).map((e=>Xi(Gi(2,e,{...n,...i}))))},$inject:["components"]};class fa extends lo{constructor(e,t){super(e,t),ca(this,pa),aa(this)}componentDidMount(){this.changeSupport.onElementsChanged(this.getRoot(),this.onElementsChanged)}componentWillUnmount(){this.changeSupport.offElementsChanged(this.getRoot(),this.onElementsChanged)}onElementsChanged=()=>{this.forceUpdate()};getRoot(){return this.sheet.getRoot()}render(){const e=(this.getRoot().businessObject.get("annotationsWidth")||400)+"px";return Ui(1,"th","annotation header",[this.slotFills({type:"cell-inner",context:{cellType:"annotations",col:this.sheet.getRoot(),minWidth:400}}),this.translate("Annotations")],0,{style:{width:e}})}}function ga(e){const{row:t}=e,{id:n,description:i}=t.businessObject;return Gi(2,da,{className:"annotation",elementId:n,children:i||"-"})}function ma(e){e.onGetComponent("cell",(({cellType:e})=>"after-label-cells"===e?fa:"after-rule-cells"===e?ga:void 0))}fa.$inject=["changeSupport","sheet","translate"],ma.$inject=["components"];var va={__init__:["annotationsProvider"],annotationsProvider:["type",ma]};function ya(e,t){return _({id:e.id,type:e.$type,businessObject:e},t)}class wa{constructor(e,t,n){this._elementFactory=e,this._eventBus=t,this._sheet=n}add(e){let t;if(bi(e,"dmn:DecisionTable"))t=this._elementFactory.createRoot(ya(e)),this._sheet.setRoot(t);else if(bi(e,"dmn:InputClause"))t=this._elementFactory.createCol(ya(e)),this._sheet.addCol(t);else if(bi(e,"dmn:OutputClause"))t=this._elementFactory.createCol(ya(e)),this._sheet.addCol(t);else if(bi(e,"dmn:DecisionRule")){e.inputEntry||(e.inputEntry=[]),e.outputEntry||(e.outputEntry=[]);const n=[...e.inputEntry,...e.outputEntry].map((e=>this._elementFactory.createCell(ya(e))));t=this._elementFactory.createRow(_(ya(e),{cells:n})),this._sheet.addRow(t)}return this._eventBus.fire("dmnElement.added",{element:t}),t}}wa.$inject=["elementFactory","eventBus","sheet"];var ba={__depends__:[{__depends__:[zo],tableImporter:["type",wa]},Ys]};class xa extends lo{constructor(e,t){super(e,t),ca(this,pa),this._sheet=t.injector.get("sheet"),this._changeSupport=t.changeSupport}onElementsChanged=()=>{this.forceUpdate()};componentWillMount(){const e=this._sheet.getRoot();this._changeSupport.onElementsChanged(e.id,this.onElementsChanged)}componentWillUnmount(){const e=this._sheet.getRoot();this._changeSupport.offElementsChanged(e.id,this.onElementsChanged)}render(){const e=this._sheet.getRoot();if(!bi(e,"dmn:DMNElement"))return null;const t=xi(e),n=t.input,i=t.output;return Ui(1,"thead",null,Ui(1,"tr",null,[Ui(1,"th","index-column"),this.slotFills({type:"cell",context:{cellType:"before-label-cells"}}),n&&n.map(((e,t)=>{const i=e.width||"192px";return this.slotFill({type:"cell",context:{cellType:"input-header",input:e,index:t,inputsLength:n.length,width:i},key:e.id},_a)})),i.map(((e,t)=>this.slotFill({type:"cell",context:{cellType:"output-header",output:e,index:t,outputsLength:i.length},key:e.id},Sa))),this.slotFills({type:"cell",context:{cellType:"after-label-cells"}})],0),2)}}function _a(e,t){const{input:n,className:i,index:r}=e,{label:o,inputExpression:s,inputValues:a}=n,l=t.injector.get("translate");return Ui(1,"th",(i||"")+" input-cell",[Ui(1,"div","clause",l(0===r?"When":"And"),0),o?Ui(1,"div","input-label",o,0,{title:l("Input label: ")+o}):Ui(1,"div","input-expression",s.text,0,{title:l("Input expression: ")+s.text}),Ui(1,"div","input-variable",a&&a.text||s.typeRef,0,{title:a&&a.text?l("Input values"):l("Input type")})],0,{"data-col-id":n.id},n.id)}function Sa(e,t){const{output:n,className:i,index:r}=e,{label:o,name:s,outputValues:a,typeRef:l}=n,c=t.injector.get("translate");return Ui(1,"th",(i||"")+" output-cell",[Ui(1,"div","clause",c(0===r?"Then":"And"),0),o?Ui(1,"div","output-label",o,0,{title:c("Output label")}):Ui(1,"div","output-name",s,0,{title:c("Output name")}),Ui(1,"div","output-variable",a&&a.text||l,0,{title:a&&a.text?c("Output values"):c("Output type")})],0,null,n.id)}function ka(e){e.onGetComponent("table.head",(()=>xa))}ka.$inject=["components"];var Ca={__init__:["decisionTableHeadProvider"],decisionTableHeadProvider:["type",ka]};class Ea extends lo{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),aa(this)}render(){const e=this.sheet.getRoot();if(!bi(e,"dmn:DMNElement"))return null;const{name:t}=e.businessObject.$parent,n=this.components.getComponent("hit-policy")||Ma;return Ui(1,"div","decision-table-properties",[Ui(1,"div","decision-table-name",t,0,{title:this._translate("Decision name: ")+t}),Ui(1,"div","decision-table-header-separator"),Gi(2,n)],4)}}function Ma(){return null}Ea.$inject=["sheet","components"];class Aa{constructor(e){e.onGetComponent("table.before",500,(()=>Ea))}}Aa.$inject=["components"];var Ra={__init__:["decisionTableProperties"],decisionTableProperties:["type",Aa]};class Ta extends lo{render(){const{row:e,rowIndex:t}=this.props,{components:n}=this.context,i=n.getComponents("cell-inner",{cellType:"rule-index",row:e,rowIndex:t});return Ui(1,"td","rule-index",[i&&i.map((n=>Gi(2,n,{row:e,rowIndex:t}))),t+1],0,{"data-element-id":e.id,"data-row-id":e.id})}}class Da{constructor(e){e.onGetComponent("cell",(({cellType:e})=>{if("before-rule-cells"===e)return Ta}))}}Da.$inject=["components"];var Oa={__init__:["decisionRuleIndices"],decisionRuleIndices:["type",Da]};const Na=[{label:"FEEL",value:"feel"}];class Pa{constructor(e){this._injector=e;const t=e.get("config.expressionLanguages")||{};this._config={options:Na,defaults:{editor:"feel"}},t.options&&(this._config.options=t.options);const n=this._getLegacyDefaults();_(this._config.defaults,n,t.defaults)}getDefault(e){const{defaults:t}=this._config,n=t[e]||t.editor;return this._getLanguageByValue(n)||this.getAll()[0]}getLabel(e){const t=this._getLanguageByValue(e);return t?t.label:e}getAll(){return this._config.options}_getLegacyDefaults(){const e={},t=this._injector,n=t.get("config.defaultInputExpressionLanguage"),i=t.get("config.defaultOutputExpressionLanguage");return n&&(e.inputCell=n),i&&(e.outputCell=i),e}_getLanguageByValue(e){return c(this.getAll(),(t=>e===t.value))}}Pa.$inject=["injector"];var qa={__init__:["expressionLanguages"],expressionLanguages:["type",Pa]};class Ba extends lo{render({rows:e,cols:t}){const{components:n}=this.context;return Ui(1,"tbody",null,e.map(((e,i)=>{const r=n.getComponent("row",{rowType:"rule"});return r&&Gi(2,r,{row:e,rowIndex:i,cols:t},e.id)})),0)}}class La extends lo{constructor(e,t){super(e,t),ca(this,pa)}render(){const{row:e,rowIndex:t,cols:n}=this.props,{cells:i}=e;return Ui(1,"tr",null,[this.slotFills({type:"cell",context:{cellType:"before-rule-cells",row:e,rowIndex:t}}),i.map(((i,r)=>this.slotFill({type:"cell",context:{cellType:"rule",cell:i,rowIndex:t,colIndex:r},key:i.id,row:e,col:n[r]}))),this.slotFills({type:"cell",context:{cellType:"after-rule-cells",row:e,rowIndex:t}})],0)}}class Ia extends lo{render(){const{cell:e,row:t,col:n}=this.props;return bi(e,"dmn:UnaryTests")?Gi(2,da,{className:"input-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":n.id,children:e.businessObject.text}):Gi(2,da,{className:"output-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":n.id,children:e.businessObject.text})}}class ja{constructor(e){e.onGetComponent("table.body",(()=>Ba)),e.onGetComponent("row",(({rowType:e})=>{if("rule"===e)return La})),e.onGetComponent("cell",(({cellType:e})=>{if("rule"===e)return Ia}))}}ja.$inject=["components"];var Fa={__depends__:[qa],__init__:["decisionRules"],decisionRules:["type",ja]};const Va=[{label:"Unique",value:{hitPolicy:"UNIQUE",aggregation:void 0},explanation:"No overlap is possible and all rules are disjoint. Only a single rule can be matched"},{label:"First",value:{hitPolicy:"FIRST",aggregation:void 0},explanation:"Rules may overlap. The first matching rule will be chosen"},{label:"Priority",value:{hitPolicy:"PRIORITY",aggregation:void 0},explanation:"Rules may overlap. The one with the highest priority will be chosen"},{label:"Any",value:{hitPolicy:"ANY",aggregation:void 0},explanation:"Rules may overlap. Their output have to match"},{label:"Collect",value:{hitPolicy:"COLLECT",aggregation:void 0},explanation:"Collects the values of all matching rules"},{label:"Collect (Sum)",value:{hitPolicy:"COLLECT",aggregation:"SUM"},explanation:"Collects the values of all matching rules and sums up to a single value"},{label:"Collect (Min)",value:{hitPolicy:"COLLECT",aggregation:"MIN"},explanation:"Collects the values of all matching rules and uses the lowest value"},{label:"Collect (Max)",value:{hitPolicy:"COLLECT",aggregation:"MAX"},explanation:"Collects the values of all matching rules and uses the highest value"},{label:"Collect (Count)",value:{hitPolicy:"COLLECT",aggregation:"COUNT"},explanation:"Collects the values of all matching rules and counts the number of them"},{label:"Rule order",value:{hitPolicy:"RULE ORDER",aggregation:void 0},explanation:"Collects the values of all matching rules in rule order"},{label:"Output order",value:{hitPolicy:"OUTPUT ORDER",aggregation:void 0},explanation:"Collects the values of all matching rules in decreasing output priority order"}];class $a extends lo{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),aa(this)}getRoot(){return this.sheet.getRoot()}render(){const e=this.getRoot().businessObject,{aggregation:t,hitPolicy:n}=e,i=c(Va,(e=>{return i=e.value,r={aggregation:t,hitPolicy:n},i.hitPolicy===r.hitPolicy&&i.aggregation===r.aggregation;var i,r}));return Ui(1,"div","hit-policy header",[Ui(1,"label","dms-label",this._translate("Hit policy:"),0),Ui(1,"span","hit-policy-value",this._translate(i.label),0)],4,{title:this._translate(i.explanation)})}}function za(e){e.onGetComponent("hit-policy",(()=>$a))}$a.$inject=["sheet"],za.$inject=["components"];var Ha={__init__:["hitPolicyProvider"],hitPolicyProvider:["type",za]};let Wa=class extends lo{constructor(e,t){super(e,t);const{injector:n}=t;this._translate=n.get("translate"),this._eventBus=n.get("eventBus")}onClick=()=>{this._eventBus.fire("showDrd")};render(){return Ui(1,"div","view-drd",Ui(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,(e=>this.node=e))}},Ua=class{constructor(e,t,n,i){this._injector=n,this._sheet=i,e.onGetComponent("table.before",(()=>{if(this.canViewDrd())return Wa})),t.on("showDrd",(()=>{const e=n.get("_parent",!1),t=Ga(i.getRoot());if(!t)return;const r=e.getView(t);e.open(r)}))}canViewDrd(){const e=this._injector.get("_parent",!1);if(!e)return!1;const t=Ga(this._sheet.getRoot());return!!e.getView(t)}};function Ga(e){const{businessObject:t}=e;if(!t)return;return t.$parent.$parent}Ua.$inject=["components","eventBus","injector","sheet"];var Ka={__init__:["viewDrd"],viewDrd:["type",Ua]};let Xa=class{constructor(e){e.onGetComponent("table.before",(()=>po))}};Xa.$inject=["components"];var Ya={__init__:["poweredBy"],poweredBy:["type",Xa]};let Ja=class e extends na{constructor(t={}){const n=e._createContainer();super(_(t,{renderer:{container:n}})),this._container=n}open(e){var t=this;return new Promise(((n,i)=>{var r;try{return t._decision&&t.clear(),t._decision=e,function(e,t,n){const i=e.get("tableImporter"),r=e.get("eventBus"),o=e.get("sheet");e.get("modeling",!1);let s,a=[];r.fire("import.render.start",{decision:t});try{!function(e){new ra({create:(e,t,n,r)=>i.create(e,t,n,r),table:e=>i.add(e),element:(e,t,n)=>i.add(e,t,n),error(e,t){a.push({message:e,context:t})}}).handleDecision(e)}(t)}catch(e){s=e}r.fire("import.render.complete",{error:s,warnings:a}),r.fire("elements.changed",{elements:[o.getRoot()]}),n(s,a)}(t,e,(function(e,t){e?(e.warnings=t||[],i(e)):n({warnings:t||[]})}))}catch(e){r=e}r?(r.warnings=r.warnings||[],i(r)):n({warnings:[]})}))}_init(e){let{modules:t,additionalModules:n,...i}=e,r=t||this.getModules();return{modules:[Ya,...r,...n||[],...[{decisionTable:["value",this]}]],config:i}}on(e,t,n,i){return this.get("eventBus").on(e,t,n,i)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}attachTo(e){if(!e)throw new Error("parentNode required");this.detach();const t=this._container;e.appendChild(t),this._emit("attach",{})}detach(){const e=this._container;e.parentNode&&(this._emit("detach",{}),$t(e))}destroy(){super.destroy(),this.detach()}getModules(){return e._getModules()}static _getModules(){return[va,ba,zo,Ca,Ra,Oa,Fa,Ha,Ka]}static _createContainer(){return Ft('<div class="dmn-decision-table-container"></div>')}};class Qa{constructor(e){this._listeners={},e.on("elements.changed",(({elements:e})=>{this.elementsChanged(e)})),e.on("element.updateId",(({element:e,newId:t})=>{this.updateId(e.id,t)}))}elementsChanged(e){const t={},n=e.length;for(let i=0;i<n;i++){const{id:n}=e[i];if(t[n])return;t[n]=!0;const r=this._listeners[n]&&this._listeners[n].length;if(r)for(let e=0;e<r;e++)this._listeners[n][e]&&this._listeners[n][e]()}}onElementsChanged(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e][this._listeners[e].length]=t}offElementsChanged(e,t){if(this._listeners[e])if(t){const n=this._listeners[e].indexOf(t);-1!==n&&this._listeners[e].splice(n,1)}else this._listeners[e].length=0}updateId(e,t){this._listeners[e]&&(this._listeners[t]=this._listeners[e],delete this._listeners[e])}}Qa.$inject=["eventBus"];class Za extends lo{constructor(e){super(e);const t=this._injector=e.injector;this._changeSupport=t.get("changeSupport"),this._components=t.get("components"),this._renderer=t.get("renderer")}getChildContext(){return{changeSupport:this._changeSupport,components:this._components,renderer:this._renderer,injector:this._injector}}render(){const e=this._components.getComponents("viewer");return Ui(1,"div","viewer-container",e&&e.map(((e,t)=>Gi(2,e,null,t))),0)}}class el{constructor(e,t,n,i,r){const{container:o}=n;this._container=o,i.on("renderer.mount",(()=>{io(Gi(2,Za,{injector:r}),o)})),i.on("renderer.unmount",(()=>{io(null,o)}))}getContainer(){return this._container}}el.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var tl={__init__:["changeSupport","components","renderer"],changeSupport:["type",Qa],components:["type",class{constructor(){this._listeners={}}getComponent(e,t){const n=this._listeners[e];if(!n)return;let i;for(let e=0;e<n.length&&(i=n[e].callback(t),!i);e++);return i}getComponents(e,t){const n=this._listeners[e];if(!n)return;const i=[];for(let e=0;e<n.length;e++){const r=n[e].callback(t);r&&i.push(r)}return i.length?i:void 0}onGetComponent(e,t,n){if(s(t)&&(n=t,t=1e3),!o(t))throw new Error("priority must be a number");const i=this._getListeners(e);let r,a;const l={priority:t,callback:n};for(a=0;r=i[a];a++)if(r.priority<t)return void i.splice(a,0,l);i.push(l)}offGetComponent(e,t){const n=this._getListeners(e);let i,r,o;if(t)for(o=n.length-1;i=n[o];o--)r=i.callback,r===t&&n.splice(o,1);else n.length=0}_getListeners(e){let t=this._listeners[e];return t||(this._listeners[e]=t=[]),t}}],eventBus:["type",C],renderer:["type",el]};let nl=class{constructor(e={}){let{injector:t}=e;if(!t){let{modules:n,config:i}=this._init(e);t=function(e,t){const n=[{config:["value",e]},tl].concat(t||[]),i=new sn(n);return i.init(),i}(i,n)}this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("viewer.init")}_init(e){let{modules:t,...n}=e;return{modules:t,config:n}}destroy(){this.get("eventBus").fire("viewer.destroy")}clear(){this.get("eventBus").fire("viewer.clear")}};class il{constructor(e,t){this._eventBus=t,this._viewer=e}getDecision(){return this._viewer.getDecision()}updateId(e,t){if(e!==this.getDecision())throw new Error("element !== decision");this._eventBus.fire("element.updateId",{element:e,newId:t}),e.id=t}}il.$inject=["viewer","eventBus"];var rl={__init__:["elementRegistry"],elementRegistry:["type",il]};class ol extends lo{constructor(e,t){super(e,t),this._viewer=t.injector.get("viewer")}render(){const{name:e}=this._viewer.getDecision();return Ui(1,"div","decision-properties",Ui(1,"h3","decision-name",e,0),2)}}let sl=class{constructor(e){e.onGetComponent("viewer",1500,(()=>ol))}};sl.$inject=["components"];var al={__init__:["decisionProperties"],decisionProperties:["type",sl]};class ll extends lo{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._viewer=t.injector.get("viewer")}render(){const{decisionLogic:e,variable:t}=this._viewer.getDecision();return Ui(1,"div","literal-expression-properties",Ui(1,"table",null,[Ui(1,"tr",null,[Ui(1,"td",null,this._translate("Variable name:"),0),Ui(1,"td",null,Ui(1,"span",null,t.name||"-",0),2)],4),Ui(1,"tr",null,[Ui(1,"td",null,this._translate("Variable type:"),0),Ui(1,"td",null,Ui(1,"span",null,this._translate(t.typeRef||"")||"-",0),2)],4),Ui(1,"tr",null,[Ui(1,"td",null,this._translate("Expression language:"),0),Ui(1,"td",null,Ui(1,"span",null,e.expressionLanguage||"-",0),2)],4)],4),2)}}class cl{constructor(e){e.onGetComponent("viewer",500,(()=>ll))}}cl.$inject=["components"];var hl={__depends__:[],__init__:["literalExpressionProperties"],literalExpressionProperties:["type",cl]};let ul=class{constructor(e){e.onGetComponent("viewer",2e3,(()=>po))}};ul.$inject=["components"];var dl={__init__:["poweredBy"],poweredBy:["type",ul]};class pl extends lo{constructor(e,t){super(e,t),this._viewer=t.injector.get("viewer")}render(){const{text:e}=this._viewer.getDecision().decisionLogic;return Ui(1,"div","textarea",Ui(1,"div","content",e,0),2)}}class fl{constructor(e){e.onGetComponent("viewer",(()=>pl))}}fl.$inject=["components"];var gl={__init__:["textarea"],textarea:["type",fl]};let ml=class extends lo{constructor(e,t){super(e,t);const{injector:n}=t;this._translate=n.get("translate"),this._eventBus=n.get("eventBus")}onClick=()=>{this._eventBus.fire("showDrd")};render(){return Ui(1,"div","view-drd",Ui(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,(e=>this.node=e))}};ml.$inject=["translate"];let vl=class{constructor(e,t,n,i){this._injector=i,this._viewer=t,e.onGetComponent("viewer",2e3,(()=>{if(this.canViewDrd())return ml})),n.on("showDrd",(()=>{const e=i.get("_parent",!1),t=this.getDefinitions(),n=e.getView(t);e.open(n)}))}canViewDrd(){const e=this._injector.get("_parent",!1);if(!e)return;const t=this.getDefinitions();return!!e.getView(t)}getDefinitions(){return this._viewer.getDecision().$parent}};vl.$inject=["components","viewer","eventBus","injector"];var yl={__init__:["viewDrd"],viewDrd:["type",vl]};let wl=class e extends nl{constructor(t={}){const n=e._createContainer();super(_(t,{renderer:{container:n}})),this._container=n}open(e){var t=this;return new Promise((function(n,i){var r;try{t._decision&&(t.clear(),t.get("eventBus").fire("renderer.unmount")),t._decision=e,t.get("eventBus").fire("import",e),t.get("eventBus").fire("renderer.mount")}catch(e){r=e}r?(r.warnings=r.warnings||[],i(r)):n({warnings:[]})}))}_init(e){let{modules:t,additionalModules:n,...i}=e;return{modules:[...t||this.getModules(),...n||[],...[{viewer:["value",this]}]],config:i}}on(e,t,n,i){return this.get("eventBus").on(e,t,n,i)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}getDecision(){return this._decision}attachTo(e){if(!e)throw new Error("parentNode required");this.detach(),e.appendChild(this._container),this._emit("attach",{})}detach(){const e=this._container;e.parentNode&&(this._emit("detach",{}),$t(e))}destroy(){super.destroy(),this.detach()}getModules(){return e._getModules()}static _getModules(){return[rl,zo,al,hl,dl,gl,yl]}static _createContainer(){return Ft('<div class="dmn-literal-expression-container"></div>')}};function bl(e,{injector:t}){const n=t.get("components").getComponents("header");return Ui(1,"div","dmn-boxed-expression-section dmn-boxed-expression-header",n&&n.map(((e,t)=>Gi(2,e,null,t))),0)}function xl(e,{injector:t}){const n=t.get("components").getComponents("body");return Ui(1,"div","dmn-boxed-expression-section dmn-boxed-expression-body",n&&n.map(((e,t)=>Gi(2,e,null,t))),0)}function _l(e,{injector:t}){const n=t.get("components").getComponents("footer");return Ui(1,"div","dmn-boxed-expression-section dmn-boxed-expression-footer",n&&n.map(((e,t)=>Gi(2,e,null,t))),0)}var Sl={__init__:["viewRenderer","tableJsSupport"],viewRenderer:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("viewer",(()=>bl)),e.onGetComponent("viewer",(()=>xl)),e.onGetComponent("viewer",(()=>_l))}}],tableJsSupport:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("viewer",(()=>{const t=e.getComponents("table.before")||[];return()=>Ui(1,"div",null,t.map(((e,t)=>Gi(2,e,null,t))),0)}))}}]};class kl{constructor(e){e.onGetComponent("viewer",2e3,(()=>po))}}kl.$inject=["components"];var Cl={__init__:["poweredBy"],poweredBy:["type",kl]};function El({expression:e},t){return Ui(1,"div","textarea",Ui(1,"div","content",t.injector.get("literalExpression").getText(e),0),2)}class Ml{getText(e){return e.get("text")}}var Al={__init__:["literalExpressionComponent"],literalExpressionComponent:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("expression",(({expression:e})=>{if(bi(e,"dmn:LiteralExpression"))return El}))}}],literalExpression:["type",Ml]};function Rl({expression:e},t){const n=t.injector.get("functionDefinition"),i=n.getKind(e),r=n.getParameters(e),o=n.getBody(e);return Ui(1,"div","function-definition",[Gi(2,Dl,{kind:i}),Gi(2,Ol,{parameters:r}),Gi(2,Pl,{expression:o})],4)}const Tl={FEEL:"F",Java:"J",PMML:"P"};function Dl({kind:e},t){const n=t.injector.get("translate");return Ui(1,"div","function-definition-kind",Tl[e],0,{title:n("Function kind: {kind}",{kind:e})})}function Ol({parameters:e}){return Ui(1,"div","function-definition-parameters",Ui(1,"div",null,[Ki("("),e.reduce(((e,t)=>e.concat(Gi(2,Nl,{parameter:t}),", ")),[]).slice(0,-1),Ki(")")],0),2)}function Nl({parameter:e}){const{name:t,typeRef:n}=e,i=t||"<unnamed>";return Ui(1,"span",null,n?`${i}: ${n}`:i,0)}function Pl({expression:e},t){return Ui(1,"div","function-definition-body",Gi(2,t.components.getComponent("expression",{expression:e}),{expression:e}),2)}var ql={__init__:["functionDefinitionComponent"],functionDefinition:["type",class{getParameters(e){return e.get("formalParameter")}getBody(e){return e.get("body")}getKind(e){return e.get("kind")||"FEEL"}}],functionDefinitionComponent:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("expression",(({expression:e})=>{if(bi(e,"dmn:FunctionDefinition"))return Rl}))}}]};class Bl extends lo{constructor(e,t){super(e,t);const{injector:n}=t;this._translate=n.get("translate"),this._eventBus=n.get("eventBus")}onClick=()=>{this._eventBus.fire("showDrd")};render(){return Ui(1,"div","view-drd",Ui(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,(e=>this.node=e))}}Bl.$inject=["translate"];class Ll{constructor(e,t,n){this._injector=n,e.onGetComponent("viewer",2e3,(()=>{if(this.canViewDrd())return Bl})),t.on("showDrd",(()=>{const e=n.get("_parent",!1),t=e.getDefinitions(),i=e.getView(t);e.open(i)}))}canViewDrd(){const e=this._injector.get("_parent",!1);if(!e)return;const t=e.getDefinitions();return!!e.getView(t)}}Ll.$inject=["components","eventBus","injector"];var Il={__init__:["viewDrd"],viewDrd:["type",Ll]};function jl(e,t){const n=t.injector.get("viewer"),{name:i}=n.getRootElement();return Ui(1,"div","element-properties",Ui(1,"h2","element-name",i,0),2)}class Fl{constructor(e){e.onGetComponent("header",(()=>jl))}}Fl.$inject=["components"];var Vl={__init__:["elementProperties"],elementProperties:["type",Fl]};function $l(e,{injector:t}){const n=t.get("components"),i=function(e){if(bi(e,"dmn:Decision"))return e.get("decisionLogic");if(bi(e,"dmn:BusinessKnowledgeModel"))return e.get("encapsulatedLogic")}(t.get("viewer").getRootElement());return Gi(2,n.getComponent("expression",{expression:i}),{expression:i})}function zl({expression:e}){return Ui(1,"div",null,Ui(1,"span",null,[Ki("Expression of type "),e.$type,Ki(" is not supported.")],0,{style:"color:red;"}),2)}var Hl={__init__:["elementLogic"],elementLogic:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("body",(()=>$l)),e.onGetComponent("expression",100,(()=>zl))}}]};function Wl(e,t){const n=t.injector.get("elementVariable"),i=t.injector.get("translate"),r=n.getName(),o=n.getType();return Ui(1,"div","element-variable",[Ui(1,"h2",null,Ki("Result"),2),Ui(1,"div","element-variable-name",[Ui(1,"span","element-variable-name-label",i("Variable name"),0),Ui(1,"span",null,r,0)],4),Ui(1,"div","element-variable-type",[Ui(1,"span","element-variable-type-label",i("Variable type"),0),Ui(1,"span",null,o,0)],4)],4)}var Ul={__init__:["elementVariableComponent"],elementVariable:["type",class{static $inject=["viewer"];constructor(e){this._viewer=e}getName(){const e=this.getVariable(),t=this._getElement();return(e?e.get("name"):null)||t.get("name")}getType(){const e=this.getVariable();return e?e.get("typeRef"):"Any"}_getElement(){return this._viewer.getRootElement()}getVariable(){return this._getElement().get("variable")}}],elementVariableComponent:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("footer",(()=>Wl))}}]};let Gl=class e extends nl{constructor(t={}){const n=e._createContainer();super(_(t,{renderer:{container:n}})),this._container=n}open(e){const t=this.get("eventBus");return new Promise(((n,i)=>{let r;try{this.getRootElement()&&(this.clear(),t.fire("renderer.unmount")),this._setRootElement(e),t.fire("import",e),t.fire("renderer.mount")}catch(e){r=e}r?(r.warnings=r.warnings||[],i(r)):n({warnings:[]})}))}_init(e){let{modules:t,additionalModules:n,...i}=e;return{modules:[...t||this.getModules(),...n||[],...[{viewer:["value",this]}]],config:i}}on(e,t,n,i){return this.get("eventBus").on(e,t,n,i)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}getRootElement(){return this._root}_setRootElement(e){this._root=e}attachTo(e){if(!e)throw new Error("parentNode required");this.detach(),e.appendChild(this._container),this._emit("attach",{})}detach(){const e=this._container;e.parentNode&&(this._emit("detach",{}),$t(e))}destroy(){super.destroy(),this.detach()}getModules(){return[Sl,zo,Cl,Il,Vl,Hl,ql,Al,Ul]}static _createContainer(){return Ft('<div class="dmn-boxed-expression-container"></div>')}};window.getSelection();var Kl,Xl={exports:{}};!function(){if(Kl)return Xl.exports;function e(e,t){return{start:e,end:void 0===t?e:t}}Kl=1,Xl.exports=function(t,n,i){var r=t.start,o=r,s=(i.length,n.length);i.length,n.length;var a=n.substring(r);return i.lastIndexOf(a)===i.length-a.length&&(n=n.substring(0,n.length-a.length),i=i.substring(0,i.length-a.length)),s=function(e,t){var n,i,r,o=0,s=0;t.length>e.length?(i=t,r=e):(i=e,r=t);for(;o<i.length;)i.charAt(o)!==r.charAt(s)?(n||(n={l_start:o,s_start:s}),o++):(n&&!n.complete&&(n.l_end=o,n.s_end=s,n.complete=!0),s++,o++);n&&!n.complete&&(n.complete=!0,n.s_end=r.length,n.l_end=i.length);if(!n)return;return t.length>e.length?{newStart:n.l_start,newEnd:n.l_end,type:"add"}:{newStart:n.s_start,newEnd:n.s_end,type:t.length<e.length?"remove":"replace"}}(n,i),s&&(o="remove"===s.type?s.newStart:s.newEnd),e(o)},Xl.exports.range=e,Xl.exports}();let Yl=[],Jl=[];function Ql(e){if(e<768)return!1;for(let t=0,n=Yl.length;;){let i=t+n>>1;if(e<Yl[i])n=i;else{if(!(e>=Jl[i]))return!0;t=i+1}if(t==n)return!1}}function Zl(e){return e>=127462&&e<=127487}(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((e=>e?parseInt(e,36):1));for(let t=0,n=0;t<e.length;t++)(t%2?Jl:Yl).push(n+=e[t])})();const ec=8205;function tc(e,t,n=!0,i=!0){return(n?nc:ic)(e,t,i)}function nc(e,t,n){if(t==e.length)return t;t&&oc(e.charCodeAt(t))&&sc(e.charCodeAt(t-1))&&t--;let i=rc(e,t);for(t+=ac(i);t<e.length;){let r=rc(e,t);if(i==ec||r==ec||n&&Ql(r))t+=ac(r),i=r;else{if(!Zl(r))break;{let n=0,i=t-2;for(;i>=0&&Zl(rc(e,i));)n++,i-=2;if(n%2==0)break;t+=2}}}return t}function ic(e,t,n){for(;t>0;){let i=nc(e,t-2,n);if(i<t)return i;t--}return 0}function rc(e,t){let n=e.charCodeAt(t);if(!sc(n)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return oc(i)?i-56320+(n-55296<<10)+65536:n}function oc(e){return e>=56320&&e<57344}function sc(e){return e>=55296&&e<56320}function ac(e){return e<65536?1:2}class lc{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=vc(this,e,t);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(t,this.length,i,1),hc.from(i,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=vc(this,e,t);let n=[];return this.decompose(e,t,n,0),hc.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new pc(this),r=new pc(e);for(let e=t,o=t;;){if(i.next(e),r.next(e),e=0,i.lineBreak!=r.lineBreak||i.done!=r.done||i.value!=r.value)return!1;if(o+=i.value.length,i.done||o>=n)return!0}}iter(e=1){return new pc(this,e)}iterRange(e,t=this.length){return new fc(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new gc(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new cc(e):hc.from(cc.split(e,[])):lc.empty}}class cc extends lc{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,i){for(let r=0;;r++){let o=this.text[r],s=i+o.length;if((t?n:s)>=e)return new mc(i,s,n,o);i=s+1,n++}}decompose(e,t,n,i){let r=e<=0&&t>=this.length?this:new cc(dc(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&i){let e=n.pop(),t=uc(r.text,e.text.slice(),0,r.length);if(t.length<=32)n.push(new cc(t,e.length+r.length));else{let e=t.length>>1;n.push(new cc(t.slice(0,e)),new cc(t.slice(e)))}}else n.push(r)}replace(e,t,n){if(!(n instanceof cc))return super.replace(e,t,n);[e,t]=vc(this,e,t);let i=uc(this.text,uc(n.text,dc(this.text,0,e)),t),r=this.length+n.length-(t-e);return i.length<=32?new cc(i,r):hc.from(cc.split(i,[]),r)}sliceString(e,t=this.length,n="\n"){[e,t]=vc(this,e,t);let i="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let s=this.text[o],a=r+s.length;r>e&&o&&(i+=n),e<a&&t>r&&(i+=s.slice(Math.max(0,e-r),t-r)),r=a+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],i=-1;for(let r of e)n.push(r),i+=r.length+1,32==n.length&&(t.push(new cc(n,i)),n=[],i=-1);return i>-1&&t.push(new cc(n,i)),t}}class hc extends lc{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,i){for(let r=0;;r++){let o=this.children[r],s=i+o.length,a=n+o.lines-1;if((t?a:s)>=e)return o.lineInner(e,t,n,i);i=s+1,n=a+1}}decompose(e,t,n,i){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let s=this.children[r],a=o+s.length;if(e<=a&&t>=o){let r=i&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!r?n.push(s):s.decompose(e-o,t-o,n,r)}o=a+1}}replace(e,t,n){if([e,t]=vc(this,e,t),n.lines<this.lines)for(let i=0,r=0;i<this.children.length;i++){let o=this.children[i],s=r+o.length;if(e>=r&&t<=s){let a=o.replace(e-r,t-r,n),l=this.lines-o.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let r=this.children.slice();return r[i]=a,new hc(r,this.length-(t-e)+n.length)}return super.replace(r,s,a)}r=s+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=vc(this,e,t);let i="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let s=this.children[r],a=o+s.length;o>e&&r&&(i+=n),e<a&&t>o&&(i+=s.sliceString(e-o,t-o,n)),o=a+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof hc))return 0;let n=0,[i,r,o,s]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,r+=t){if(i==o||r==s)return n;let a=this.children[i],l=e.children[r];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce(((e,t)=>e+t.length+1),-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new cc(n,t)}let i=Math.max(32,n>>5),r=i<<1,o=i>>1,s=[],a=0,l=-1,c=[];function h(e){let t;if(e.lines>r&&e instanceof hc)for(let t of e.children)h(t);else e.lines>o&&(a>o||!a)?(u(),s.push(e)):e instanceof cc&&a&&(t=c[c.length-1])instanceof cc&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new cc(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>i&&u(),a+=e.lines,l+=e.length+1,c.push(e))}function u(){0!=a&&(s.push(1==c.length?c[0]:hc.from(c,l)),l=-1,a=c.length=0)}for(let t of e)h(t);return u(),1==s.length?s[0]:new hc(s,t)}}function uc(e,t,n=0,i=1e9){for(let r=0,o=0,s=!0;o<e.length&&r<=i;o++){let a=e[o],l=r+a.length;l>=n&&(l>i&&(a=a.slice(0,i-r)),r<n&&(a=a.slice(n-r)),s?(t[t.length-1]+=a,s=!1):t.push(a)),r=l+1}return t}function dc(e,t,n){return uc(e,[""],t,n)}lc.empty=new cc([""],0);class pc{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof cc?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],r=this.offsets[n],o=r>>1,s=i instanceof cc?i.text.length:i.children.length;if(o==(t>0?s:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(i instanceof cc){let r=i.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,r.length>Math.max(0,e))return this.value=0==e?r:t>0?r.slice(e):r.slice(0,r.length-e),this;e-=r.length}else{let r=i.children[o+(t<0?-1:0)];e>r.length?(e-=r.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(r),this.offsets.push(t>0?1:(r instanceof cc?r.text.length:r.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class fc{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new pc(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*t,this.value=i.length<=n?i:t<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class gc{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:i}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(lc.prototype[Symbol.iterator]=function(){return this.iter()},pc.prototype[Symbol.iterator]=fc.prototype[Symbol.iterator]=gc.prototype[Symbol.iterator]=function(){return this});class mc{constructor(e,t,n,i){this.from=e,this.to=t,this.number=n,this.text=i}get length(){return this.to-this.from}}function vc(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function yc(e,t,n=!0,i=!0){return tc(e,t,n,i)}const wc=/\r\n?|\n/;var bc=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(bc||(bc={}));class xc{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,i=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(n,i,r),i+=r):i+=o,n+=r}}iterChangedRanges(e,t=!1){Cc(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];i<0?e.push(n,i):e.push(i,n)}return new xc(e)}composeDesc(e){return this.empty?e:e.empty?this:Mc(this,e)}mapDesc(e,t=!1){return e.empty?this:Ec(this,e,t)}mapPos(e,t=-1,n=bc.Simple){let i=0,r=0;for(let o=0;o<this.sections.length;){let s=this.sections[o++],a=this.sections[o++],l=i+s;if(a<0){if(l>e)return r+(e-i);r+=s}else{if(n!=bc.Simple&&l>=e&&(n==bc.TrackDel&&i<e&&l>e||n==bc.TrackBefore&&i<e||n==bc.TrackAfter&&l>e))return null;if(l>e||l==e&&t<0&&!s)return e==i||t<0?r:r+a;r+=a}i=l}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return r}touchesRange(e,t=e){for(let n=0,i=0;n<this.sections.length&&i<=t;){let r=i+this.sections[n++];if(this.sections[n++]>=0&&i<=t&&r>=e)return!(i<e&&r>t)||"cover";i=r}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];e+=(e?" ":"")+n+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some((e=>"number"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new xc(e)}static create(e){return new xc(e)}}class _c extends xc{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 Cc(this,((t,n,i,r,o)=>e=e.replace(i,i+(n-t),o)),!1),e}mapDesc(e,t=!1){return Ec(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let i=0,r=0;i<t.length;i+=2){let o=t[i],s=t[i+1];if(s>=0){t[i]=s,t[i+1]=o;let a=i>>1;for(;n.length<a;)n.push(lc.empty);n.push(o?e.slice(r,r+o):lc.empty)}r+=o}return new _c(t,n)}compose(e){return this.empty?e:e.empty?this:Mc(this,e,!0)}map(e,t=!1){return e.empty?this:Ec(this,e,t,!0)}iterChanges(e,t=!1){Cc(this,e,t)}get desc(){return xc.create(this.sections)}filter(e){let t=[],n=[],i=[],r=new Ac(this);e:for(let o=0,s=0;;){let a=o==e.length?1e9:e[o++];for(;s<a||s==a&&0==r.len;){if(r.done)break e;let e=Math.min(r.len,a-s);Sc(i,e,-1);let o=-1==r.ins?-1:0==r.off?r.ins:0;Sc(t,e,o),o>0&&kc(n,t,r.text),r.forward(e),s+=e}let l=e[o++];for(;s<l;){if(r.done)break e;let e=Math.min(r.len,l-s);Sc(t,e,-1),Sc(i,e,-1==r.ins?-1:0==r.off?r.ins:0),r.forward(e),s+=e}}return{changes:new _c(t,n),filtered:xc.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],i=this.sections[t+1];i<0?e.push(n):0==i?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let i=[],r=[],o=0,s=null;function a(e=!1){if(!e&&!i.length)return;o<t&&Sc(i,t-o,-1);let n=new _c(i,r);s=s?s.compose(n.map(s)):n,i=[],r=[],o=0}return function e(l){if(Array.isArray(l))for(let t of l)e(t);else if(l instanceof _c){if(l.length!=t)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),s=s?s.compose(l.map(s)):l}else{let{from:e,to:s=e,insert:c}=l;if(e>s||e<0||s>t)throw new RangeError(`Invalid change range ${e} to ${s} (in doc of length ${t})`);let h=c?"string"==typeof c?lc.of(c.split(n||wc)):c:lc.empty,u=h.length;if(e==s&&0==u)return;e<o&&a(),e>o&&Sc(i,e-o,-1),Sc(i,s-e,u),kc(r,i,h),o=s}}(e),a(!s),s}static empty(e){return new _c(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let i=0;i<e.length;i++){let r=e[i];if("number"==typeof r)t.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((e,t)=>t&&"string"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)t.push(r[0],0);else{for(;n.length<i;)n.push(lc.empty);n[i]=lc.of(r.slice(1)),t.push(r[0],n[i].length)}}}return new _c(t,n)}static createSet(e,t){return new _c(e,t)}}function Sc(e,t,n,i=!1){if(0==t&&n<=0)return;let r=e.length-2;r>=0&&n<=0&&n==e[r+1]?e[r]+=t:r>=0&&0==t&&0==e[r]?e[r+1]+=n:i?(e[r]+=t,e[r+1]+=n):e.push(t,n)}function kc(e,t,n){if(0==n.length)return;let i=t.length-2>>1;if(i<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<i;)e.push(lc.empty);e.push(n)}}function Cc(e,t,n){let i=e.inserted;for(let r=0,o=0,s=0;s<e.sections.length;){let a=e.sections[s++],l=e.sections[s++];if(l<0)r+=a,o+=a;else{let c=r,h=o,u=lc.empty;for(;c+=a,h+=l,l&&i&&(u=u.append(i[s-2>>1])),!(n||s==e.sections.length||e.sections[s+1]<0);)a=e.sections[s++],l=e.sections[s++];t(r,c,o,h,u),r=c,o=h}}}function Ec(e,t,n,i=!1){let r=[],o=i?[]:null,s=new Ac(e),a=new Ac(t);for(let e=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(-1==s.ins&&-1==a.ins){let e=Math.min(s.len,a.len);Sc(r,e,-1),s.forward(e),a.forward(e)}else if(a.ins>=0&&(s.ins<0||e==s.i||0==s.off&&(a.len<s.len||a.len==s.len&&!n))){let t=a.len;for(Sc(r,a.ins,-1);t;){let n=Math.min(s.len,t);s.ins>=0&&e<s.i&&s.len<=n&&(Sc(r,0,s.ins),o&&kc(o,r,s.text),e=s.i),s.forward(n),t-=n}a.next()}else{if(!(s.ins>=0)){if(s.done&&a.done)return o?_c.createSet(r,o):xc.create(r);throw new Error("Mismatched change set lengths")}{let t=0,n=s.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else{if(!(0==a.ins&&a.len<n))break;n-=a.len,a.next()}Sc(r,t,e<s.i?s.ins:0),o&&e<s.i&&kc(o,r,s.text),e=s.i,s.forward(s.len-n)}}}}function Mc(e,t,n=!1){let i=[],r=n?[]:null,o=new Ac(e),s=new Ac(t);for(let e=!1;;){if(o.done&&s.done)return r?_c.createSet(i,r):xc.create(i);if(0==o.ins)Sc(i,o.len,0,e),o.next();else if(0!=s.len||s.done){if(o.done||s.done)throw new Error("Mismatched change set lengths");{let t=Math.min(o.len2,s.len),n=i.length;if(-1==o.ins){let n=-1==s.ins?-1:s.off?0:s.ins;Sc(i,t,n,e),r&&n&&kc(r,i,s.text)}else-1==s.ins?(Sc(i,o.off?0:o.len,t,e),r&&kc(r,i,o.textBit(t))):(Sc(i,o.off?0:o.len,s.off?0:s.ins,e),r&&!s.off&&kc(r,i,s.text));e=(o.ins>t||s.ins>=0&&s.len>t)&&(e||i.length>n),o.forward2(t),s.forward(t)}}else Sc(i,0,s.ins,e),r&&kc(r,i,s.text),s.next()}}class Ac{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?lc.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?lc.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Rc{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let n,i;return this.empty?n=i=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new Rc(n,i,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return Tc.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return Tc.range(this.anchor,n)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return Tc.range(e.anchor,e.head)}static create(e,t,n){return new Rc(e,t,n)}}class Tc{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:Tc.create(this.ranges.map((n=>n.map(e,t))),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new Tc([this.main],0)}addRange(e,t=!0){return Tc.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,Tc.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((e=>e.toJSON())),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Tc(e.ranges.map((e=>Rc.fromJSON(e))),e.main)}static single(e,t=e){return new Tc([Tc.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;i<e.length;i++){let r=e[i];if(r.empty?r.from<=n:r.from<n)return Tc.normalized(e.slice(),t);n=r.to}return new Tc(e,t)}static cursor(e,t=0,n,i){return Rc.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=i?i:16777215)<<6)}static range(e,t,n,i){let r=(null!=n?n:16777215)<<6|(null==i?7:Math.min(6,i));return t<e?Rc.create(t,e,48|r):Rc.create(e,t,(t>e?8:0)|r)}static normalized(e,t=0){let n=e[t];e.sort(((e,t)=>e.from-t.from)),t=e.indexOf(n);for(let n=1;n<e.length;n++){let i=e[n],r=e[n-1];if(i.empty?i.from<=r.to:i.from<r.to){let o=r.from,s=Math.max(i.to,r.to);n<=t&&t--,e.splice(--n,2,i.anchor>i.head?Tc.range(s,o):Tc.range(o,s))}}return new Tc(e,t)}}function Dc(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let Oc=0;class Nc{constructor(e,t,n,i,r){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=i,this.id=Oc++,this.default=e([]),this.extensions="function"==typeof r?r(this):r}get reader(){return this}static define(e={}){return new Nc(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:Pc),!!e.static,e.enables)}of(e){return new qc([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new qc(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new qc(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],(n=>t(n.field(e))))}}function Pc(e,t){return e==t||e.length==t.length&&e.every(((e,n)=>e===t[n]))}class qc{constructor(e,t,n,i){this.dependencies=e,this.facet=t,this.type=n,this.value=i,this.id=Oc++}dynamicSlot(e){var t;let n=this.value,i=this.facet.compareInput,r=this.id,o=e[r]>>1,s=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:1&(null!==(t=e[n.id])&&void 0!==t?t:1)||c.push(e[n.id]);return{create:e=>(e.values[o]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||Lc(e,c)){let t=n(e);if(s?!Bc(t,e.values[o],i):!i(t,e.values[o]))return e.values[o]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[r];if(null!=l){let r=Qc(t,l);if(this.dependencies.every((n=>n instanceof Nc?t.facet(n)===e.facet(n):!(n instanceof Fc)||t.field(n,!1)==e.field(n,!1)))||(s?Bc(a=n(e),r,i):i(a=n(e),r)))return e.values[o]=r,0}else a=n(e);return e.values[o]=a,1}}}}function Bc(e,t,n){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}function Lc(e,t){let n=!1;for(let i of t)1&Jc(e,i)&&(n=!0);return n}function Ic(e,t,n){let i=n.map((t=>e[t.id])),r=n.map((e=>e.type)),o=i.filter((e=>!(1&e))),s=e[t.id]>>1;function a(e){let n=[];for(let t=0;t<i.length;t++){let o=Qc(e,i[t]);if(2==r[t])for(let e of o)n.push(e);else n.push(o)}return t.combine(n)}return{create(e){for(let t of i)Jc(e,t);return e.values[s]=a(e),1},update(e,n){if(!Lc(e,o))return 0;let i=a(e);return t.compare(i,e.values[s])?0:(e.values[s]=i,1)},reconfigure(e,r){let o=Lc(e,i),l=r.config.facets[t.id],c=r.facet(t);if(l&&!o&&Pc(n,l))return e.values[s]=c,0;let h=a(e);return t.compare(h,c)?(e.values[s]=c,0):(e.values[s]=h,1)}}}const jc=Nc.define({static:!0});class Fc{constructor(e,t,n,i,r){this.id=e,this.createF=t,this.updateF=n,this.compareF=i,this.spec=r,this.provides=void 0}static define(e){let t=new Fc(Oc++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(jc).find((e=>e.field==this));return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let i=e.values[t],r=this.updateF(i,n);return this.compareF(i,r)?0:(e.values[t]=r,1)},reconfigure:(e,n)=>null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}init(e){return[this,jc.of({field:this,create:e})]}get extension(){return this}}const Vc=4,$c=3,zc=2,Hc=1;function Wc(e){return t=>new Gc(t,e)}const Uc={highest:Wc(0),high:Wc(Hc),default:Wc(zc),low:Wc($c),lowest:Wc(Vc)};class Gc{constructor(e,t){this.inner=e,this.prec=t}}class Kc{of(e){return new Xc(this,e)}reconfigure(e){return Kc.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Xc{constructor(e,t){this.compartment=e,this.inner=t}}class Yc{constructor(e,t,n,i,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=i,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let i=[],r=Object.create(null),o=new Map;for(let n of function(e,t,n){let i=[[],[],[],[],[]],r=new Map;function o(e,s){let a=r.get(e);if(null!=a){if(a<=s)return;let t=i[a].indexOf(e);t>-1&&i[a].splice(t,1),e instanceof Xc&&n.delete(e.compartment)}if(r.set(e,s),Array.isArray(e))for(let t of e)o(t,s);else if(e instanceof Xc){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let i=t.get(e.compartment)||e.inner;n.set(e.compartment,i),o(i,s)}else if(e instanceof Gc)o(e.inner,e.prec);else if(e instanceof Fc)i[s].push(e),e.provides&&o(e.provides,s);else if(e instanceof qc)i[s].push(e),e.facet.extensions&&o(e.facet.extensions,zc);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(t,s)}}return o(e,zc),i.reduce(((e,t)=>e.concat(t)))}(e,t,o))n instanceof Fc?i.push(n):(r[n.facet.id]||(r[n.facet.id]=[])).push(n);let s=Object.create(null),a=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push((t=>e.slot(t)));let c=null==n?void 0:n.config.facets;for(let e in r){let t=r[e],i=t[0].facet,o=c&&c[e]||[];if(t.every((e=>0==e.type)))if(s[i.id]=a.length<<1|1,Pc(o,t))a.push(n.facet(i));else{let e=i.combine(t.map((e=>e.value)));a.push(n&&i.compare(e,n.facet(i))?n.facet(i):e)}else{for(let e of t)0==e.type?(s[e.id]=a.length<<1|1,a.push(e.value)):(s[e.id]=l.length<<1,l.push((t=>e.dynamicSlot(t))));s[i.id]=l.length<<1,l.push((e=>Ic(e,i,t)))}}let h=l.map((e=>e(s)));return new Yc(e,o,h,s,a,r)}}function Jc(e,t){if(1&t)return 2;let n=t>>1,i=e.status[n];if(4==i)throw new Error("Cyclic dependency between fields and/or facets");if(2&i)return i;e.status[n]=4;let r=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|r}function Qc(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const Zc=Nc.define(),eh=Nc.define({combine:e=>e.some((e=>e)),static:!0}),th=Nc.define({combine:e=>e.length?e[0]:void 0,static:!0}),nh=Nc.define(),ih=Nc.define(),rh=Nc.define(),oh=Nc.define({combine:e=>!!e.length&&e[0]});class sh{constructor(e,t){this.type=e,this.value=t}static define(){return new ah}}class ah{of(e){return new sh(this,e)}}class lh{constructor(e){this.map=e}of(e){return new ch(this,e)}}class ch{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new ch(this.type,t)}is(e){return this.type==e}static define(e={}){return new lh(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let i of e){let e=i.map(t);e&&n.push(e)}return n}}ch.reconfigure=ch.define(),ch.appendConfig=ch.define();class hh{constructor(e,t,n,i,r,o){this.startState=e,this.changes=t,this.selection=n,this.effects=i,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,n&&Dc(n,t.newLength),r.some((e=>e.type==hh.time))||(this.annotations=r.concat(hh.time.of(Date.now())))}static create(e,t,n,i,r,o){return new hh(e,t,n,i,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(hh.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function uh(e,t){let n=[];for(let i=0,r=0;;){let o,s;if(i<e.length&&(r==t.length||t[r]>=e[i]))o=e[i++],s=e[i++];else{if(!(r<t.length))return n;o=t[r++],s=t[r++]}!n.length||n[n.length-1]<o?n.push(o,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function dh(e,t,n){var i;let r,o,s;return n?(r=t.changes,o=_c.empty(t.changes.length),s=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),o=e.changes.mapDesc(t.changes,!0),s=e.changes.compose(r)),{changes:s,selection:t.selection?t.selection.map(o):null===(i=e.selection)||void 0===i?void 0:i.map(r),effects:ch.mapEffects(e.effects,r).concat(ch.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function ph(e,t,n){let i=t.selection,r=mh(t.annotations);return t.userEvent&&(r=r.concat(hh.userEvent.of(t.userEvent))),{changes:t.changes instanceof _c?t.changes:_c.of(t.changes||[],n,e.facet(th)),selection:i&&(i instanceof Tc?i:Tc.single(i.anchor,i.head)),effects:mh(t.effects),annotations:r,scrollIntoView:!!t.scrollIntoView}}function fh(e,t,n){let i=ph(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(n=!1);for(let r=1;r<t.length;r++){!1===t[r].filter&&(n=!1);let o=!!t[r].sequential;i=dh(i,ph(e,t[r],o?i.changes.newLength:e.doc.length),o)}let r=hh.create(e,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return function(e){let t=e.startState,n=t.facet(rh),i=e;for(let r=n.length-1;r>=0;r--){let o=n[r](e);o&&Object.keys(o).length&&(i=dh(i,ph(t,o,e.changes.newLength),!0))}return i==e?e:hh.create(t,e.changes,e.selection,i.effects,i.annotations,i.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let i of t.facet(nh)){let t=i(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:uh(n,t))}if(!0!==n){let i,r;if(!1===n)r=e.changes.invertedDesc,i=_c.empty(t.doc.length);else{let t=e.changes.filter(n);i=t.changes,r=t.filtered.mapDesc(t.changes).invertedDesc}e=hh.create(t,i,e.selection&&e.selection.map(r),ch.mapEffects(e.effects,r),e.annotations,e.scrollIntoView)}let i=t.facet(ih);for(let n=i.length-1;n>=0;n--){let r=i[n](e);e=r instanceof hh?r:Array.isArray(r)&&1==r.length&&r[0]instanceof hh?r[0]:fh(t,mh(r),!1)}return e}(r):r)}hh.time=sh.define(),hh.userEvent=sh.define(),hh.addToHistory=sh.define(),hh.remote=sh.define();const gh=[];function mh(e){return null==e?gh:Array.isArray(e)?e:[e]}var vh=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(vh||(vh={}));const yh=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let wh;try{wh=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function bh(e){return t=>{if(!/\S/.test(t))return vh.Space;if(function(e){if(wh)return wh.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||yh.test(n)))return!0}return!1}(t))return vh.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return vh.Word;return vh.Other}}class xh{constructor(e,t,n,i,r,o){this.config=e,this.doc=t,this.selection=n,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Jc(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null!=n)return Jc(this,n),Qc(this,n);if(t)throw new RangeError("Field is not present in this state")}update(...e){return fh(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:i,compartments:r}=n;for(let t of e.effects)t.is(Kc.reconfigure)?(n&&(r=new Map,n.compartments.forEach(((e,t)=>r.set(t,e))),n=null),r.set(t.value.compartment,t.value.extension)):t.is(ch.reconfigure)?(n=null,i=t.value):t.is(ch.appendConfig)&&(n=null,i=mh(i).concat(t.value));if(n)t=e.startState.values.slice();else{n=Yc.resolve(i,r,this),t=new xh(n,this.doc,this.selection,n.dynamicSlots.map((()=>null)),((e,t)=>t.reconfigure(e,this)),null).values}let o=e.startState.facet(eh)?e.newSelection:e.newSelection.asSingle();new xh(n,e.newDoc,o,t,((t,n)=>n.update(t,e)),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:e},range:Tc.cursor(t.from+e.length)})))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),i=this.changes(n.changes),r=[n.range],o=mh(n.effects);for(let n=1;n<t.ranges.length;n++){let s=e(t.ranges[n]),a=this.changes(s.changes),l=a.map(i);for(let e=0;e<n;e++)r[e]=r[e].map(l);let c=i.mapDesc(a,!0);r.push(s.range.map(c)),i=i.compose(l),o=ch.mapEffects(o,l).concat(ch.mapEffects(mh(s.effects),c))}return{changes:i,selection:Tc.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof _c?e:_c.of(e,this.doc.length,this.facet(xh.lineSeparator))}toText(e){return lc.of(e.split(this.facet(xh.lineSeparator)||wc))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(Jc(this,t),Qc(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let i=e[n];i instanceof Fc&&null!=this.config.address[i.id]&&(t[n]=i.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(n)for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let r=n[t],o=e[t];i.push(r.init((e=>r.spec.fromJSON(o,e))))}return xh.create({doc:e.doc,selection:Tc.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let t=Yc.resolve(e.extensions||[],new Map),n=e.doc instanceof lc?e.doc:lc.of((e.doc||"").split(t.staticFacet(xh.lineSeparator)||wc)),i=e.selection?e.selection instanceof Tc?e.selection:Tc.single(e.selection.anchor,e.selection.head):Tc.single(0);return Dc(i,n.length),t.staticFacet(eh)||(i=i.asSingle()),new xh(t,n,i,t.dynamicSlots.map((()=>null)),((e,t)=>t.create(e)),null)}get tabSize(){return this.facet(xh.tabSize)}get lineBreak(){return this.facet(xh.lineSeparator)||"\n"}get readOnly(){return this.facet(oh)}phrase(e,...t){for(let t of this.facet(xh.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,((e,n)=>{if("$"==n)return"$";let i=+(n||1);return!i||i>t.length?e:t[i-1]}))),e}languageDataAt(e,t,n=-1){let i=[];for(let r of this.facet(Zc))for(let o of r(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){return bh(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:i}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-n,s=e-n;for(;o>0;){let e=yc(t,o,!1);if(r(t.slice(e,o))!=vh.Word)break;o=e}for(;s<i;){let e=yc(t,s);if(r(t.slice(s,e))!=vh.Word)break;s=e}return o==s?null:Tc.range(o+n,s+n)}}xh.allowMultipleSelections=eh,xh.tabSize=Nc.define({combine:e=>e.length?e[0]:4}),xh.lineSeparator=th,xh.readOnly=oh,xh.phrases=Nc.define({compare(e,t){let n=Object.keys(e),i=Object.keys(t);return n.length==i.length&&n.every((n=>e[n]==t[n]))}}),xh.languageData=Zc,xh.changeFilter=nh,xh.transactionFilter=ih,xh.transactionExtender=rh,Kc.reconfigure=ch.define();class _h{eq(e){return this==e}range(e,t=e){return Sh.create(e,t,this)}}_h.prototype.startSide=_h.prototype.endSide=0,_h.prototype.point=!1,_h.prototype.mapMode=bc.TrackDel;let Sh=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,i){return new e(t,n,i)}};function kh(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class Ch{constructor(e,t,n,i){this.from=e,this.to=t,this.value=n,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,i=0){let r=n?this.to:this.from;for(let o=i,s=r.length;;){if(o==s)return o;let i=o+s>>1,a=r[i]-e||(n?this.value[i].endSide:this.value[i].startSide)-t;if(i==o)return a>=0?o:s;a>=0?s=i:o=i+1}}between(e,t,n,i){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,r);r<o;r++)if(!1===i(this.from[r]+e,this.to[r]+e,this.value[r]))return!1}map(e,t){let n=[],i=[],r=[],o=-1,s=-1;for(let a=0;a<this.value.length;a++){let l,c,h=this.value[a],u=this.from[a]+e,d=this.to[a]+e;if(u==d){let e=t.mapPos(u,h.startSide,h.mapMode);if(null==e)continue;if(l=c=e,h.startSide!=h.endSide&&(c=t.mapPos(u,h.endSide),c<l))continue}else if(l=t.mapPos(u,h.startSide),c=t.mapPos(d,h.endSide),l>c||l==c&&h.startSide>0&&h.endSide<=0)continue;(c-l||h.endSide-h.startSide)<0||(o<0&&(o=l),h.point&&(s=Math.max(s,c-l)),n.push(h),i.push(l-o),r.push(c-o))}return{mapped:n.length?new Ch(i,r,n,s):null,pos:o}}}class Eh{constructor(e,t,n,i){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=i}static create(e,t,n,i){return new Eh(e,t,n,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:i=0,filterTo:r=this.length}=e,o=e.filter;if(0==t.length&&!o)return this;if(n&&(t=t.slice().sort(kh)),this.isEmpty)return t.length?Eh.of(t):this;let s=new Rh(this,null,-1).goto(0),a=0,l=[],c=new Mh;for(;s.value||a<t.length;)if(a<t.length&&(s.from-t[a].from||s.startSide-t[a].value.startSide)>=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==s.rangeIndex&&s.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(s.chunkIndex)<t[a].from)&&(!o||i>this.chunkEnd(s.chunkIndex)||r<this.chunkPos[s.chunkIndex])&&c.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||i>s.to||r<s.from||o(s.from,s.to,s.value))&&(c.addInner(s.from,s.to,s.value)||l.push(Sh.create(s.from,s.to,s.value))),s.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?Eh.empty:this.nextLayer.update({add:l,filter:o,filterFrom:i,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],i=-1;for(let r=0;r<this.chunk.length;r++){let o=this.chunkPos[r],s=this.chunk[r],a=e.touchesRange(o,o+s.length);if(!1===a)i=Math.max(i,s.maxPoint),t.push(s),n.push(e.mapPos(o));else if(!0===a){let{mapped:r,pos:a}=s.map(o,e);r&&(i=Math.max(i,r.maxPoint),t.push(r),n.push(a))}}let r=this.nextLayer.map(e);return 0==t.length?r:new Eh(n,t,r||Eh.empty,i)}between(e,t,n){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let r=this.chunkPos[i],o=this.chunk[i];if(t>=r&&e<=r+o.length&&!1===o.between(r,e-r,t-r,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return Th.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Th.from(e).goto(t)}static compare(e,t,n,i,r=-1){let o=e.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r)),s=t.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r)),a=Ah(o,s,n),l=new Oh(o,a,r),c=new Oh(s,a,r);n.iterGaps(((e,t,n)=>Nh(l,e,c,t,n,i))),n.empty&&0==n.length&&Nh(l,0,c,0,0,i)}static eq(e,t,n=0,i){null==i&&(i=999999999);let r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0)),o=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0));if(r.length!=o.length)return!1;if(!r.length)return!0;let s=Ah(r,o),a=new Oh(r,s,0).goto(n),l=new Oh(o,s,0).goto(n);for(;;){if(a.to!=l.to||!Ph(a.active,l.active)||a.point&&(!l.point||!a.point.eq(l.point)))return!1;if(a.to>i)return!0;a.next(),l.next()}}static spans(e,t,n,i,r=-1){let o=new Oh(e,null,r).goto(t),s=t,a=o.openStart;for(;;){let e=Math.min(o.to,n);if(o.point){let n=o.activeForPoint(o.to),r=o.pointFrom<t?n.length+1:o.point.startSide<0?n.length:Math.min(n.length,a);i.point(s,e,o.point,n,r,o.pointRank),a=Math.min(o.openEnd(e),n.length)}else e>s&&(i.span(s,e,o.active,a),a=o.openEnd(e));if(o.to>n)return a+(o.point&&o.to>n?1:0);s=o.to,o.next()}}static of(e,t=!1){let n=new Mh;for(let i of e instanceof Sh?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let i=e[n];if(kh(t,i)>0)return e.slice().sort(kh);t=i}return e}(e):e)n.add(i.from,i.to,i.value);return n.finish()}static join(e){if(!e.length)return Eh.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let i=e[n];i!=Eh.empty;i=i.nextLayer)t=new Eh(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}}Eh.empty=new Eh([],[],null,-1),Eh.empty.nextLayer=Eh.empty;class Mh{finishChunk(e){this.chunks.push(new Ch(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Mh)).add(e,t,n)}addInner(e,t,n){let i=e-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(i<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(Eh.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=Eh.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Ah(e,t,n){let i=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&i.set(t.chunk[e],t.chunkPos[e]);let r=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let o=i.get(e.chunk[t]);null==o||(n?n.mapPos(o):o)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(o,o+e.chunk[t].length))||r.add(e.chunk[t])}return r}class Rh{constructor(e,t,n,i=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=i}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Th{constructor(e){this.heap=e}static from(e,t=null,n=-1){let i=[];for(let r=0;r<e.length;r++)for(let o=e[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&i.push(new Rh(o,t,n,r));return 1==i.length?i[0]:new Th(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)Dh(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)Dh(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Dh(this.heap,0)}}}function Dh(e,t){for(let n=e[t];;){let i=1+(t<<1);if(i>=e.length)break;let r=e[i];if(i+1<e.length&&r.compare(e[i+1])>=0&&(r=e[i+1],i++),n.compare(r)<0)break;e[i]=n,e[t]=r,t=i}}class Oh{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Th.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){qh(this.active,e),qh(this.activeTo,e),qh(this.activeRank,e),this.minActive=Lh(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:i,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||i-this.activeTo[t])>0;)t++;Bh(this.active,t,n),Bh(this.activeTo,t,i),Bh(this.activeRank,t,r),e&&Bh(e,t,this.cursor.from),this.minActive=Lh(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),n&&qh(n,i)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function Nh(e,t,n,i,r,o){e.goto(t),n.goto(i);let s=i+r,a=i,l=i-t;for(;;){let t=e.to+l-n.to,i=t||e.endSide-n.endSide,r=i<0?e.to+l:n.to,c=Math.min(r,s);if(e.point||n.point?e.point&&n.point&&(e.point==n.point||e.point.eq(n.point))&&Ph(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,c,e.point,n.point):c>a&&!Ph(e.active,n.active)&&o.compareRange(a,c,e.active,n.active),r>s)break;(t||e.openEnd!=n.openEnd)&&o.boundChange&&o.boundChange(r),a=r,i<=0&&e.next(),i>=0&&n.next()}}function Ph(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!e[n].eq(t[n]))return!1;return!0}function qh(e,t){for(let n=t,i=e.length-1;n<i;n++)e[n]=e[n+1];e.pop()}function Bh(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function Lh(e,t){let n=-1,i=1e9;for(let r=0;r<t.length;r++)(t[r]-i||e[r].endSide-e[n].endSide)<0&&(n=r,i=t[r]);return n}const Ih="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),jh="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),Fh="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class Vh{constructor(e,t){this.rules=[];let{finish:n}=t||{};function i(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function r(e,t,o,s){let a=[],l=/^@(\w+)\b/.exec(e[0]),c=l&&"keyframes"==l[1];if(l&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))r(n.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),s,o);else if(s&&"object"==typeof s){if(!l)throw new RangeError("The value of a property ("+n+") should be a primitive value.");r(i(n),s,a,c)}else null!=s&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+s+";")}(a.length||c)&&o.push((!n||l||s?e:e.map(n)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)r(i(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=Fh[Ih]||1;return Fh[Ih]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let i=e[jh],r=n&&n.nonce;i?r&&i.setNonce(r):i=new zh(e,r),i.mount(Array.isArray(t)?t:[t],e)}}let $h=new Map;class zh{constructor(e,t){let n=e.ownerDocument||e,i=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let t=$h.get(n);if(t)return e[jh]=t;this.sheet=new i.CSSStyleSheet,$h.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[jh]=this}mount(e,t){let n=this.sheet,i=0,r=0;for(let t=0;t<e.length;t++){let o=e[t],s=this.modules.indexOf(o);if(s<r&&s>-1&&(this.modules.splice(s,1),r--,s=-1),-1==s){if(this.modules.splice(r++,0,o),n)for(let e=0;e<o.rules.length;e++)n.insertRule(o.rules[e],i++)}else{for(;r<s;)i+=this.modules[r++].rules.length;i+=o.rules.length,r++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var Hh={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Wh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Uh=0;Uh<10;Uh++)Hh[48+Uh]=Hh[96+Uh]=String(Uh);for(Uh=1;Uh<=24;Uh++)Hh[Uh+111]="F"+Uh;for(Uh=65;Uh<=90;Uh++)Hh[Uh]=String.fromCharCode(Uh+32),Wh[Uh]=String.fromCharCode(Uh);for(var Gh in Hh)Wh.hasOwnProperty(Gh)||(Wh[Gh]=Hh[Gh]);function Kh(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function Xh(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function Yh(e,t){if(!t.anchorNode)return!1;try{return Xh(e,t.anchorNode)}catch(e){return!1}}function Jh(e){return 3==e.nodeType?hu(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function Qh(e,t,n,i){return!!n&&(tu(e,t,n,i,-1)||tu(e,t,n,i,1))}function Zh(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function eu(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function tu(e,t,n,i,r){for(;;){if(e==n&&t==i)return!0;if(t==(r<0?0:nu(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=Zh(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(r<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=r<0?nu(e):0}}}function nu(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function iu(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function ru(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function ou(e,t){let n=t.width/e.offsetWidth,i=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.height-e.offsetHeight)<1)&&(i=1),{scaleX:n,scaleY:i}}class su{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?nu(t):0),n,Math.min(e.focusOffset,n?nu(n):0))}set(e,t,n,i){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=i}}let au,lu=null;function cu(e){if(e.setActive)return e.setActive();if(lu)return e.focus(lu);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==lu?{get preventScroll(){return lu={preventScroll:!0},!0}}:void 0),!lu){lu=!1;for(let e=0;e<t.length;){let n=t[e++],i=t[e++],r=t[e++];n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}}}function hu(e,t,n=t){let i=au||(au=document.createRange());return i.setEnd(e,n),i.setStart(e,t),i}function uu(e,t,n,i){let r={key:t,code:t,keyCode:n,which:n,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let o=new KeyboardEvent("keydown",r);o.synthetic=!0,e.dispatchEvent(o);let s=new KeyboardEvent("keyup",r);return s.synthetic=!0,e.dispatchEvent(s),o.defaultPrevented||s.defaultPrevented}function du(e){for(;e.attributes.length;)e.removeAttributeNode(e.attributes[0])}function pu(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function fu(e,t){for(let n=e,i=t;;){if(3==n.nodeType&&i>0)return{node:n,offset:i};if(1==n.nodeType&&i>0){if("false"==n.contentEditable)return null;n=n.childNodes[i-1],i=nu(n)}else{if(!n.parentNode||eu(n))return null;i=Zh(n),n=n.parentNode}}}function gu(e,t){for(let n=e,i=t;;){if(3==n.nodeType&&i<n.nodeValue.length)return{node:n,offset:i};if(1==n.nodeType&&i<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[i],i=0}else{if(!n.parentNode||eu(n))return null;i=Zh(n)+1,n=n.parentNode}}}class mu{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new mu(e.parentNode,Zh(e),t)}static after(e,t){return new mu(e.parentNode,Zh(e)+1,t)}}const vu=[];class yu{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(2&this.flags){let n,i=this.dom,r=null;for(let o of this.children){if(7&o.flags){if(!o.dom&&(n=r?r.nextSibling:i.firstChild)){let e=yu.get(n);(!e||!e.parent&&e.canReuseDOM(o))&&o.reuseDOM(n)}o.sync(e,t),o.flags&=-8}if(n=r?r.nextSibling:i.firstChild,t&&!t.written&&t.node==i&&n!=o.dom&&(t.written=!0),o.dom.parentNode==i)for(;n&&n!=o.dom;)n=wu(n);else i.insertBefore(o.dom,n);r=o.dom}for(n=r?r.nextSibling:i.firstChild,n&&t&&t.node==i&&(t.written=!0);n;)n=wu(n)}else if(1&this.flags)for(let n of this.children)7&n.flags&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let i=0==nu(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==this.dom)break;0==i&&t.firstChild!=t.lastChild&&(i=e==t.firstChild?-1:1),e=t}n=i<0?e:e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!yu.get(n);)n=n.nextSibling;if(!n)return this.length;for(let e=0,t=0;;e++){let i=this.children[e];if(i.dom==n)return t;t+=i.length+i.breakAfter}}domBoundsAround(e,t,n=0){let i=-1,r=-1,o=-1,s=-1;for(let a=0,l=n,c=n;a<this.children.length;a++){let n=this.children[a],h=l+n.length;if(l<e&&h>t)return n.domBoundsAround(e,t,l);if(h>=e&&-1==i&&(i=a,r=l),l>t&&n.dom.parentNode==this.dom){o=a,s=c;break}c=h,l=h+n.breakAfter}return{from:r,to:s<0?n+this.length:s,startDOM:(i?this.children[i-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),1&t.flags)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,7&this.flags&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=vu){this.markDirty();for(let i=e;i<t;i++){let e=this.children[i];e.parent==this&&n.indexOf(e)<0&&e.destroy()}n.length<250?this.children.splice(e,t-e,...n):this.children=[].concat(this.children.slice(0,e),n,this.children.slice(t));for(let e=0;e<n.length;e++)n[e].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new bu(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==e?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,i,r,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!(8&(this.flags|e.flags))}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}}function wu(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}yu.prototype.breakAfter=0;class bu{constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}function xu(e,t,n,i,r,o,s,a,l){let{children:c}=e,h=c.length?c[t]:null,u=o.length?o[o.length-1]:null,d=u?u.breakAfter:s;if(!(t==i&&h&&!s&&!d&&o.length<2&&h.merge(n,r,o.length?u:null,0==n,a,l))){if(i<c.length){let e=c[i];e&&(r<e.length||e.breakAfter&&(null==u?void 0:u.breakAfter))?(t==i&&(e=e.split(r),r=0),!d&&u&&e.merge(0,r,u,!0,0,l)?o[o.length-1]=e:((r||e.children.length&&!e.children[0].length)&&e.merge(0,r,null,!1,0,l),o.push(e))):(null==e?void 0:e.breakAfter)&&(u?u.breakAfter=1:s=1),i++}for(h&&(h.breakAfter=s,n>0&&(!s&&o.length&&h.merge(n,h.length,o[0],!1,a,0)?h.breakAfter=o.shift().breakAfter:(n<h.length||h.children.length&&0==h.children[h.children.length-1].length)&&h.merge(n,h.length,null,!1,a,0),t++));t<i&&o.length;)if(c[i-1].become(o[o.length-1]))i--,o.pop(),l=o.length?0:a;else{if(!c[t].become(o[0]))break;t++,o.shift(),a=o.length?0:l}!o.length&&t&&i<c.length&&!c[t-1].breakAfter&&c[i].merge(0,0,c[t-1],!1,a,l)&&t--,(t<i||o.length)&&e.replaceChildren(t,i,o)}}function _u(e,t,n,i,r,o){let s=e.childCursor(),{i:a,off:l}=s.findPos(n,1),{i:c,off:h}=s.findPos(t,-1),u=t-n;for(let e of i)u+=e.length;e.length+=u,xu(e,c,h,a,l,i,0,r,o)}let Su="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},ku="undefined"!=typeof document?document:{documentElement:{style:{}}};const Cu=/Edge\/(\d+)/.exec(Su.userAgent),Eu=/MSIE \d/.test(Su.userAgent),Mu=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Su.userAgent),Au=!!(Eu||Mu||Cu),Ru=!Au&&/gecko\/(\d+)/i.test(Su.userAgent),Tu=!Au&&/Chrome\/(\d+)/.exec(Su.userAgent),Du="webkitFontSmoothing"in ku.documentElement.style,Ou=!Au&&/Apple Computer/.test(Su.vendor),Nu=Ou&&(/Mobile\/\w+/.test(Su.userAgent)||Su.maxTouchPoints>2);var Pu={mac:Nu||/Mac/.test(Su.platform),windows:/Win/.test(Su.platform),linux:/Linux|X11/.test(Su.platform),ie:Au,ie_version:Eu?ku.documentMode||6:Mu?+Mu[1]:Cu?+Cu[1]:0,gecko:Ru,gecko_version:Ru?+(/Firefox\/(\d+)/.exec(Su.userAgent)||[0,0])[1]:0,chrome:!!Tu,chrome_version:Tu?+Tu[1]:0,ios:Nu,android:/Android\b/.test(Su.userAgent),webkit:Du,safari:Ou,webkit_version:Du?+(/\bAppleWebKit\/(\d+)/.exec(Su.userAgent)||[0,0])[1]:0,tabSize:null!=ku.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class qu extends yu{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){3==e.nodeType&&this.createDOM(e)}merge(e,t,n){return!(8&this.flags||n&&(!(n instanceof qu)||this.length-(t-e)+n.length>256||8&n.flags))&&(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new qu(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=8&this.flags,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new mu(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return function(e,t,n){let i=e.nodeValue.length;t>i&&(t=i);let r=t,o=t,s=0;0==t&&n<0||t==i&&n>=0?Pu.chrome||Pu.gecko||(t?(r--,s=1):o<i&&(o++,s=-1)):n<0?r--:o<i&&o++;let a=hu(e,r,o).getClientRects();if(!a.length)return null;let l=a[(s?s<0:n>=0)?0:a.length-1];Pu.safari&&!s&&0==l.width&&(l=Array.prototype.find.call(a,(e=>e.width))||l);return s?iu(l,s<0):l||null}(this.dom,e,t)}}class Bu extends yu{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let e of t)e.setParent(this)}setAttrs(e){if(du(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!(8&(this.flags|e.flags))}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,i,r,o){return(!n||!(!(n instanceof Bu&&n.mark.eq(this.mark))||e&&r<=0||t<this.length&&o<=0))&&(_u(this,e,t,n?n.children.slice():[],r-1,o-1),this.markDirty(),!0)}split(e){let t=[],n=0,i=-1,r=0;for(let o of this.children){let s=n+o.length;s>e&&t.push(n<e?o.split(e-n):o),i<0&&n>=e&&(i=r),n=s,r++}let o=this.length-e;return this.length=e,i>-1&&(this.children.length=i,this.markDirty()),new Bu(this.mark,t,o)}domAtPos(e){return ju(this,e)}coordsAt(e,t){return Vu(this,e,t)}}class Lu extends yu{static create(e,t,n){return new Lu(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}split(e){let t=Lu.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,n,i,r,o){return!(n&&(!(n instanceof Lu&&this.widget.compare(n.widget))||e>0&&r<=0||t<this.length&&o<=0))&&(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof Lu&&e.side==this.side&&this.widget.constructor==e.widget.constructor&&(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0)}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(0==this.length)return lc.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,i=this.posAtStart;return n?n.slice(i,i+this.length):lc.empty}domAtPos(e){return(this.length?0==e:this.side>0)?mu.before(this.dom):mu.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let i=this.dom.getClientRects(),r=null;if(!i.length)return null;let o=this.side?this.side<0:e>0;for(let t=o?i.length-1:0;r=i[t],!(e>0?0==t:t==i.length-1||r.top<r.bottom);t+=o?-1:1);return iu(r,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Iu extends yu{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof Iu&&e.side==this.side}split(){return new Iu(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?mu.before(this.dom):mu.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return lc.empty}get isHidden(){return!0}}function ju(e,t){let n=e.dom,{children:i}=e,r=0;for(let e=0;r<i.length;r++){let o=i[r],s=e+o.length;if(!(s==e&&o.getSide()<=0)){if(t>e&&t<s&&o.dom.parentNode==n)return o.domAtPos(t-e);if(t<=e)break;e=s}}for(let e=r;e>0;e--){let t=i[e-1];if(t.dom.parentNode==n)return t.domAtPos(t.length)}for(let e=r;e<i.length;e++){let t=i[e];if(t.dom.parentNode==n)return t.domAtPos(0)}return new mu(n,0)}function Fu(e,t,n){let i,{children:r}=e;n>0&&t instanceof Bu&&r.length&&(i=r[r.length-1])instanceof Bu&&i.mark.eq(t.mark)?Fu(i,t.children[0],n-1):(r.push(t),t.setParent(e)),e.length+=t.length}function Vu(e,t,n){let i=null,r=-1,o=null,s=-1;!function e(t,a){for(let l=0,c=0;l<t.children.length&&c<=a;l++){let h=t.children[l],u=c+h.length;u>=a&&(h.children.length?e(h,a-c):(!o||o.isHidden&&n>0)&&(u>a||c==u&&h.getSide()>0)?(o=h,s=a-c):(c<a||c==u&&h.getSide()<0&&!h.isHidden)&&(i=h,r=a-c)),c=u}}(e,t);let a=(n<0?i:o)||i||o;return a?a.coordsAt(Math.max(0,a==i?r:s),n):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=Jh(t);return n[n.length-1]||null}(e)}function $u(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}qu.prototype.children=Lu.prototype.children=Iu.prototype.children=vu;const zu=Object.create(null);function Hu(e,t,n){if(e==t)return!0;e||(e=zu),t||(t=zu);let i=Object.keys(e),r=Object.keys(t);if(i.length-(n&&i.indexOf(n)>-1?1:0)!=r.length-(n&&r.indexOf(n)>-1?1:0))return!1;for(let o of i)if(o!=n&&(-1==r.indexOf(o)||e[o]!==t[o]))return!1;return!0}function Wu(e,t,n){let i=!1;if(t)for(let r in t)n&&r in n||(i=!0,"style"==r?e.style.cssText="":e.removeAttribute(r));if(n)for(let r in n)t&&t[r]==n[r]||(i=!0,"style"==r?e.style.cssText=n[r]:e.setAttribute(r,n[r]));return i}function Uu(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n];t[i.name]=i.value}return t}class Gu{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var Ku=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(Ku||(Ku={}));class Xu extends _h{constructor(e,t,n,i){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=i}get heightRelevant(){return!1}static mark(e){return new Yu(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Qu(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,i=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:r,end:o}=Zu(e,i);t=(r?i?-3e8:-1:5e8)-1,n=1+(o?i?2e8:1:-6e8)}return new Qu(e,t,n,i,e.widget||null,!0)}static line(e){return new Ju(e)}static set(e,t=!1){return Eh.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Xu.none=Eh.empty;class Yu extends Xu{constructor(e){let{start:t,end:n}=Zu(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof Yu&&this.tagName==e.tagName&&(this.class||(null===(t=this.attrs)||void 0===t?void 0:t.class))==(e.class||(null===(n=e.attrs)||void 0===n?void 0:n.class))&&Hu(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Yu.prototype.point=!1;class Ju extends Xu{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Ju&&this.spec.class==e.spec.class&&Hu(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)}}Ju.prototype.mapMode=bc.TrackBefore,Ju.prototype.point=!0;class Qu extends Xu{constructor(e,t,n,i,r,o){super(t,n,r,e),this.block=i,this.isReplace=o,this.mapMode=i?t<=0?bc.TrackBefore:bc.TrackAfter:bc.TrackDel}get type(){return this.startSide!=this.endSide?Ku.WidgetRange:this.startSide<=0?Ku.WidgetBefore:Ku.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Qu&&(t=this.widget,n=e.widget,t==n||!!(t&&n&&t.compare(n)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide;var t,n}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function Zu(e,t=!1){let{inclusiveStart:n,inclusiveEnd:i}=e;return null==n&&(n=e.inclusive),null==i&&(i=e.inclusive),{start:null!=n?n:t,end:null!=i?i:t}}function ed(e,t,n,i=0){let r=n.length-1;r>=0&&n[r]+i>=e?n[r]=Math.max(n[r],t):n.push(e,t)}Qu.prototype.point=!0;class td extends yu{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,i,r,o){if(n){if(!(n instanceof td))return!1;this.dom||n.transferDOM(this)}return i&&this.setDeco(n?n.attrs:null),_u(this,e,t,n?n.children.slice():[],r,o),!0}split(e){let t=new td;if(t.breakAfter=this.breakAfter,0==this.length)return t;let{i:n,off:i}=this.childPos(e);i&&(t.append(this.children[n].split(i),0),this.children[n].merge(i,this.children[n].length,null,!1,0,0),n++);for(let e=n;e<this.children.length;e++)t.append(this.children[e],0);for(;n>0&&0==this.children[n-1].length;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Hu(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Fu(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=$u(t,this.attrs||{})),n&&(this.attrs=$u({class:n},this.attrs||{}))}domAtPos(e){return ju(this,e)}reuseDOM(e){"DIV"==e.nodeName&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?4&this.flags&&(du(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(Wu(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let i=this.dom.lastChild;for(;i&&yu.get(i)instanceof Bu;)i=i.lastChild;if(!(i&&this.length&&("BR"==i.nodeName||0!=(null===(n=yu.get(i))||void 0===n?void 0:n.isEditable)||Pu.ios&&this.children.some((e=>e instanceof qu))))){let e=document.createElement("BR");e.cmIgnore=!0,this.dom.appendChild(e)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let e,t=0;for(let n of this.children){if(!(n instanceof qu)||/[^ -~]/.test(n.text))return null;let i=Jh(n.dom);if(1!=i.length)return null;t+=i[0].width,e=i[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(e,t){let n=Vu(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:e}=this.parent.view.viewState,t=n.bottom-n.top;if(Math.abs(t-e.lineHeight)<2&&e.textHeight<t){let i=(t-e.textHeight)/2;return{top:n.top+i,bottom:n.bottom-i,left:n.left,right:n.left}}}return n}become(e){return e instanceof td&&0==this.children.length&&0==e.children.length&&Hu(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let n=0,i=0;n<e.children.length;n++){let r=e.children[n],o=i+r.length;if(o>=t){if(r instanceof td)return r;if(o>t)break}i=o+r.breakAfter}return null}}class nd extends yu{constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,i,r,o){return!(n&&(!(n instanceof nd&&this.widget.compare(n.widget))||e>0&&r<=0||t<this.length&&o<=0))&&(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return 0==e?mu.before(this.dom):mu.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new nd(this.widget,t,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return vu}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):lc.empty}domBoundsAround(){return null}become(e){return e instanceof nd&&e.widget.constructor==this.widget.constructor&&(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);return n||(this.widget instanceof id?null:iu(this.dom.getBoundingClientRect(),this.length?0==e:t<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:n}=this.deco;return t!=n&&(e<0?t<0:n>0)}}class id extends Gu{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}}class rd{constructor(e,t,n,i){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=i,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof nd&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new td),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(od(new Iu(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||e&&this.content.length&&this.content[this.content.length-1]instanceof nd||this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:i}=this.cursor.next(this.skip);if(this.skip=0,i)throw new Error("Ran out of text content when drawing inline views");if(n){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}this.text=t,this.textOff=0}let i=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(od(new qu(this.text.slice(this.textOff,this.textOff+i)),t),n),this.atCursorPos=!0,this.textOff+=i,e-=i,n=0}}span(e,t,n,i){this.buildText(t-e,n,i),this.pos=t,this.openStart<0&&(this.openStart=i)}point(e,t,n,i,r,o){if(this.disallowBlockEffectsFor[o]&&n instanceof Qu){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let s=t-e;if(n instanceof Qu)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new nd(n.widget||sd.block,s,n));else{let o=Lu.create(n.widget||sd.inline,s,s?0:n.startSide),a=this.atCursorPos&&!o.isEditable&&r<=i.length&&(e<t||n.startSide>0),l=!o.isEditable&&(e<t||r>i.length||n.startSide<=0),c=this.getLine();2!=this.pendingBuffer||a||o.isEditable||(this.pendingBuffer=0),this.flushBuffer(i),a&&(c.append(od(new Iu(1),i),r),r=i.length+Math.max(0,r-i.length)),c.append(od(o,i),r),this.atCursorPos=l,this.pendingBuffer=l?e<t||r>i.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=i.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);s&&(this.textOff+s<=this.text.length?this.textOff+=s:(this.skip+=s-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,n,i,r){let o=new rd(e,t,n,r);return o.openEnd=Eh.spans(i,t,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function od(e,t){for(let n of t)e=new Bu(n,[e],e.length);return e}class sd extends Gu{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}}sd.inline=new sd("span"),sd.block=new sd("div");var ad=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(ad||(ad={}));const ld=ad.LTR,cd=ad.RTL;function hd(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}const ud=hd("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),dd=hd("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),pd=Object.create(null),fd=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);pd[t]=n,pd[n]=-t}function gd(e){return e<=247?ud[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?dd[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const md=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class vd{get dir(){return this.level%2?cd:ld}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,i){let r=-1;for(let o=0;o<e.length;o++){let s=e[o];if(s.from<=t&&s.to>=t){if(s.level==n)return o;(r<0||(0!=i?i<0?s.from<t:s.to>t:e[r].level>s.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function yd(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],r=t[n];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!yd(i.inner,r.inner))return!1}return!0}const wd=[];function bd(e,t,n,i,r,o,s){let a=i%2?2:1;if(i%2==r%2)for(let l=t,c=0;l<n;){let t=!0,h=!1;if(c==o.length||l<o[c].from){let e=wd[l];e!=a&&(t=!1,h=16==e)}let u=t||1!=a?null:[],d=t?i:i+1,p=l;e:for(;;)if(c<o.length&&p==o[c].from){if(h)break e;let f=o[c];if(!t)for(let e=f.to,t=c+1;;){if(e==n)break e;if(!(t<o.length&&o[t].from==e)){if(wd[e]==a)break e;break}e=o[t++].to}if(c++,u)u.push(f);else{f.from>l&&s.push(new vd(l,f.from,d)),xd(e,f.direction==ld!=!(d%2)?i+1:i,r,f.inner,f.from,f.to,s),l=f.to}p=f.to}else{if(p==n||(t?wd[p]!=a:wd[p]==a))break;p++}u?bd(e,l,p,i+1,r,u,s):l<p&&s.push(new vd(l,p,d)),l=p}else for(let l=n,c=o.length;l>t;){let n=!0,h=!1;if(!c||l>o[c-1].to){let e=wd[l-1];e!=a&&(n=!1,h=16==e)}let u=n||1!=a?null:[],d=n?i:i+1,p=l;e:for(;;)if(c&&p==o[c-1].to){if(h)break e;let f=o[--c];if(!n)for(let e=f.from,n=c;;){if(e==t)break e;if(!n||o[n-1].to!=e){if(wd[e-1]==a)break e;break}e=o[--n].from}if(u)u.push(f);else{f.to<l&&s.push(new vd(f.to,l,d)),xd(e,f.direction==ld!=!(d%2)?i+1:i,r,f.inner,f.from,f.to,s),l=f.from}p=f.from}else{if(p==t||(n?wd[p-1]!=a:wd[p-1]==a))break;p--}u?bd(e,p,l,i+1,r,u,s):p<l&&s.push(new vd(p,l,d)),l=p}}function xd(e,t,n,i,r,o,s){let a=t%2?2:1;!function(e,t,n,i,r){for(let o=0;o<=i.length;o++){let s=o?i[o-1].to:t,a=o<i.length?i[o].from:n,l=o?256:r;for(let t=s,n=l,i=l;t<a;t++){let r=gd(e.charCodeAt(t));512==r?r=n:8==r&&4==i&&(r=16),wd[t]=4==r?2:r,7&r&&(i=r),n=r}for(let e=s,t=l,i=l;e<a;e++){let r=wd[e];if(128==r)e<a-1&&t==wd[e+1]&&24&t?r=wd[e]=t:wd[e]=256;else if(64==r){let r=e+1;for(;r<a&&64==wd[r];)r++;let o=e&&8==t||r<n&&8==wd[r]?1==i?1:8:256;for(let t=e;t<r;t++)wd[t]=o;e=r-1}else 8==r&&1==i&&(wd[e]=1);t=r,7&r&&(i=r)}}}(e,r,o,i,a),function(e,t,n,i,r){let o=1==r?2:1;for(let s=0,a=0,l=0;s<=i.length;s++){let c=s?i[s-1].to:t,h=s<i.length?i[s].from:n;for(let t,n,i,s=c;s<h;s++)if(n=pd[t=e.charCodeAt(s)])if(n<0){for(let e=a-3;e>=0;e-=3)if(fd[e+1]==-n){let t=fd[e+2],n=2&t?r:4&t?1&t?o:r:0;n&&(wd[s]=wd[fd[e]]=n),a=e;break}}else{if(189==fd.length)break;fd[a++]=s,fd[a++]=t,fd[a++]=l}else if(2==(i=wd[s])||1==i){let e=i==r;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=fd[t+2];if(2&n)break;if(e)fd[t+2]|=2;else{if(4&n)break;fd[t+2]|=4}}}}}(e,r,o,i,a),function(e,t,n,i){for(let r=0,o=i;r<=n.length;r++){let s=r?n[r-1].to:e,a=r<n.length?n[r].from:t;for(let l=s;l<a;){let s=wd[l];if(256==s){let s=l+1;for(;;)if(s==a){if(r==n.length)break;s=n[r++].to,a=r<n.length?n[r].from:t}else{if(256!=wd[s])break;s++}let c=1==o,h=c==(1==(s<t?wd[s]:i))?c?1:2:i;for(let t=s,i=r,o=i?n[i-1].to:e;t>l;)t==o&&(t=n[--i].from,o=i?n[i-1].to:e),wd[--t]=h;l=s}else o=s,l++}}}(r,o,i,a),bd(e,r,o,t,n,i,s)}function _d(e){return[new vd(0,e,0)]}let Sd="";function kd(e,t,n,i,r){var o;let s=i.head-e.from,a=vd.find(t,s,null!==(o=i.bidiLevel)&&void 0!==o?o:-1,i.assoc),l=t[a],c=l.side(r,n);if(s==c){let e=a+=r?1:-1;if(e<0||e>=t.length)return null;l=t[a=e],s=l.side(!r,n),c=l.side(r,n)}let h=yc(e.text,s,l.forward(r,n));(h<l.from||h>l.to)&&(h=c),Sd=e.text.slice(Math.min(s,h),Math.max(s,h));let u=a==(r?t.length-1:0)?null:t[a+(r?1:-1)];return u&&h==c&&u.level+(r?0:1)<l.level?Tc.cursor(u.side(!r,n)+e.from,u.forward(r,n)?1:-1,u.level):Tc.cursor(h+e.from,l.forward(r,n)?-1:1,l.level)}function Cd(e,t,n){for(let i=t;i<n;i++){let t=gd(e.charCodeAt(i));if(1==t)return ld;if(2==t||4==t)return cd}return ld}const Ed=Nc.define(),Md=Nc.define(),Ad=Nc.define(),Rd=Nc.define(),Td=Nc.define(),Dd=Nc.define(),Od=Nc.define(),Nd=Nc.define(),Pd=Nc.define(),qd=Nc.define({combine:e=>e.some((e=>e))}),Bd=Nc.define({combine:e=>e.some((e=>e))}),Ld=Nc.define();class Id{constructor(e,t="nearest",n="nearest",i=5,r=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=i,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new Id(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 Id(Tc.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const jd=ch.define({map:(e,t)=>e.map(t)}),Fd=ch.define();function Vd(e,t,n){let i=e.facet(Rd);i.length?i[0](t):window.onerror?window.onerror(String(t),n,void 0,void 0,t):n?console.error(n+":",t):console.error(t)}const $d=Nc.define({combine:e=>!e.length||e[0]});let zd=0;const Hd=Nc.define();class Wd{constructor(e,t,n,i,r){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=i,this.extension=r(this)}static define(e,t){const{eventHandlers:n,eventObservers:i,provide:r,decorations:o}=t||{};return new Wd(zd++,e,n,i,(e=>{let t=[Hd.of(e)];return o&&t.push(Xd.of((t=>{let n=t.plugin(e);return n?o(n):Xu.none}))),r&&t.push(r(e)),t}))}static fromClass(e,t){return Wd.define((t=>new e(t)),t)}}class Ud{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(Vd(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Vd(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){Vd(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Gd=Nc.define(),Kd=Nc.define(),Xd=Nc.define(),Yd=Nc.define(),Jd=Nc.define(),Qd=Nc.define();function Zd(e,t){let n=e.state.facet(Qd);if(!n.length)return n;let i=n.map((t=>t instanceof Function?t(e):t)),r=[];return Eh.spans(i,t.from,t.to,{point(){},span(e,n,i,o){let s=e-t.from,a=n-t.from,l=r;for(let e=i.length-1;e>=0;e--,o--){let n,r=i[e].spec.bidiIsolate;if(null==r&&(r=Cd(t.text,s,a)),o>0&&l.length&&(n=l[l.length-1]).to==s&&n.direction==r)n.to=a,l=n.inner;else{let e={from:s,to:a,direction:r,inner:[]};l.push(e),l=e.inner}}}}),r}const ep=Nc.define();function tp(e){let t=0,n=0,i=0,r=0;for(let o of e.state.facet(ep)){let s=o(e);s&&(null!=s.left&&(t=Math.max(t,s.left)),null!=s.right&&(n=Math.max(n,s.right)),null!=s.top&&(i=Math.max(i,s.top)),null!=s.bottom&&(r=Math.max(r,s.bottom)))}return{left:t,right:n,top:i,bottom:r}}const np=Nc.define();class ip{constructor(e,t,n,i){this.fromA=e,this.toA=t,this.fromB=n,this.toB=i}join(e){return new ip(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let i=e[t-1];if(!(i.fromA>n.toA)){if(i.toA<n.fromA)break;n=n.join(i),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let i=0,r=0,o=0,s=0;;i++){let a=i==e.length?null:e[i],l=o-s,c=a?a.fromB:1e9;for(;r<t.length&&t[r]<c;){let e=t[r],i=t[r+1],o=Math.max(s,e),a=Math.min(c,i);if(o<=a&&new ip(o+l,a+l,o,a).addToSet(n),i>c)break;r+=2}if(!a)return n;new ip(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),o=a.toA,s=a.toB}}}class rp{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=_c.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let i=[];this.changes.iterChangedRanges(((e,t,n,r)=>i.push(new ip(e,t,n,r)))),this.changedRanges=i}static create(e,t,n){return new rp(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((e=>e.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class op extends yu{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=Xu.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.setDOM(e.contentDOM),this.children=[new td],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ip(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every((({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo))?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?i=this.domChanged.newSel.head:function(e,t){let n=!1;t&&e.iterChangedRanges(((e,i)=>{e<t.to&&i>t.from&&(n=!0)}));return n}(e.changes,this.hasComposition)||e.selectionSet||(i=e.state.selection.main.head));let r=i>-1?function(e,t,n){let i=sp(e,n);if(!i)return null;let{node:r,from:o,to:s}=i,a=r.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(i.from,i.to)!=a)return null;let l=t.invertedDesc,c=new ip(l.mapPos(o),l.mapPos(s),o,s),h=[];for(let t=r.parentNode;;t=t.parentNode){let n=yu.get(t);if(n instanceof Bu)h.push({node:t,deco:n.mark});else{if(n instanceof td||"DIV"==t.nodeName&&t.parentNode==e.contentDOM)return{range:c,text:r,marks:h,line:t};if(t==e.contentDOM)return null;h.push({node:t,deco:new Yu({inclusive:!0,attributes:Uu(t),tagName:t.tagName.toLowerCase()})})}}}(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:t,to:i}=this.hasComposition;n=new ip(t,i,e.changes.mapPos(t,-1),e.changes.mapPos(i,1)).addToSet(n.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(Pu.ie||Pu.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=function(e,t,n){let i=new ap;return Eh.compare(e,t,n,i),i.changes}(this.decorations,this.updateDeco(),e.changes);return n=ip.extendWithRanges(n,o),!!(7&this.flags||0!=n.length)&&(this.updateInner(n,e.startState.doc.length,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:i}=this.view;i.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let e=Pu.chrome||Pu.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,e),this.flags&=-8,e&&(e.written||i.selectionRange.focusNode!=e.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((e=>e.flags&=-9));let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.children)e instanceof nd&&e.widget instanceof id&&r.push(e.dom);i.updateGaps(r)}updateChildren(e,t,n){let i=n?n.range.addToSet(e.slice()):e,r=this.childCursor(t);for(let e=i.length-1;;e--){let t=e>=0?i[e]:null;if(!t)break;let o,s,a,l,{fromA:c,toA:h,fromB:u,toB:d}=t;if(n&&n.range.fromB<d&&n.range.toB>u){let e=rd.build(this.view.state.doc,u,n.range.fromB,this.decorations,this.dynamicDecorationMap),t=rd.build(this.view.state.doc,n.range.toB,d,this.decorations,this.dynamicDecorationMap);s=e.breakAtStart,a=e.openStart,l=t.openEnd;let i=this.compositionView(n);t.breakAtStart?i.breakAfter=1:t.content.length&&i.merge(i.length,i.length,t.content[0],!1,t.openStart,0)&&(i.breakAfter=t.content[0].breakAfter,t.content.shift()),e.content.length&&i.merge(0,0,e.content[e.content.length-1],!0,0,e.openEnd)&&e.content.pop(),o=e.content.concat(i).concat(t.content)}else({content:o,breakAtStart:s,openStart:a,openEnd:l}=rd.build(this.view.state.doc,u,d,this.decorations,this.dynamicDecorationMap));let{i:p,off:f}=r.findPos(h,1),{i:g,off:m}=r.findPos(c,-1);xu(this,g,m,p,f,o,s,a,l)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(Fd)&&(this.editContextFormatting=e.value)}compositionView(e){let t=new qu(e.text.nodeValue);t.flags|=8;for(let{deco:n}of e.marks)t=new Bu(n,[t],t.length);let n=new td;return n.append(t,0),n}fixCompositionDOM(e){let t=(e,t)=>{t.flags|=8|(t.children.some((e=>7&e.flags))?1:0),this.markedForComposition.add(t);let n=yu.get(e);n&&n!=t&&(n.dom=null),t.setDOM(e)},n=this.childPos(e.range.fromB,1),i=this.children[n.i];t(e.line,i);for(let r=e.marks.length-1;r>=-1;r--)n=i.childPos(n.off,1),i=i.children[n.i],t(r>=0?e.marks[r].node:e.text,i)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let n=this.view.root.activeElement,i=n==this.dom,r=!i&&!(this.view.state.facet($d)||this.dom.tabIndex>-1)&&Yh(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(i||t||r))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(s.anchor)),l=s.empty?a:this.moveToLine(this.domAtPos(s.head));if(Pu.gecko&&s.empty&&!this.hasComposition&&(1==(c=a).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore((()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null))),a=l=new mu(e,0),o=!0}var c;let h=this.view.observer.selectionRange;!o&&h.focusNode&&(Qh(a.node,a.offset,h.anchorNode,h.anchorOffset)&&Qh(l.node,l.offset,h.focusNode,h.focusOffset)||this.suppressWidgetCursorChange(h,s))||(this.view.observer.ignore((()=>{Pu.android&&Pu.chrome&&this.dom.contains(h.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(h.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let e=Kh(this.view.root);if(e)if(s.empty){if(Pu.gecko){let e=function(e,t){return 1!=e.nodeType?0:(t&&"false"==e.childNodes[t-1].contentEditable?1:0)|(t<e.childNodes.length&&"false"==e.childNodes[t].contentEditable?2:0)}(a.node,a.offset);if(e&&3!=e){let t=(1==e?fu:gu)(a.node,a.offset);t&&(a=new mu(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=s.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(l.node,l.offset)}catch(e){}}else{let t=document.createRange();s.anchor>s.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}else;r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())})),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new mu(h.anchorNode,h.anchorOffset),this.impreciseHead=l.precise?null:new mu(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Qh(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Kh(e.root),{anchorNode:i,anchorOffset:r}=e.observer.selectionRange;if(!(n&&t.empty&&t.assoc&&n.modify))return;let o=td.find(this,t.head);if(!o)return;let s=o.posAtStart;if(t.head==s||t.head==s+o.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(i,r)}moveToLine(e){let t,n=this.dom;if(e.node!=n)return e;for(let i=e.offset;!t&&i<n.childNodes.length;i++){let e=yu.get(n.childNodes[i]);e instanceof td&&(t=e.domAtPos(0))}for(let i=e.offset-1;!t&&i>=0;i--){let e=yu.get(n.childNodes[i]);e instanceof td&&(t=e.domAtPos(e.length))}return t?new mu(t.node,t.offset,!0):e}nearest(e){for(let t=e;t;){let e=yu.get(t);if(e&&e.rootView==this)return e;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let e=this.children[t];if(n<e.length||e instanceof td)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){let n=null,i=0;for(let r=this.length,o=this.children.length-1;o>=0;o--){let s=this.children[o],a=r-s.breakAfter,l=a-s.length;if(a<e)break;if(l<=e&&(l<e||s.covers(-1))&&(a>e||s.covers(1))&&(!n||s instanceof td&&!(n instanceof td&&t>=0)))n=s,i=l;else if(n&&l==e&&a==e&&s instanceof nd&&Math.abs(t)<2){if(s.deco.startSide<0)break;o&&(n=null)}r=l}return n?n.coordsAt(e-i,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),i=this.children[t];if(!(i instanceof td))return null;for(;i.children.length;){let{i:e,off:t}=i.childPos(n,1);for(;;e++){if(e==i.children.length)return null;if((i=i.children[e]).length)break}n=t}if(!(i instanceof qu))return null;let r=yc(i.text,n);if(r==n)return null;let o=hu(i.dom,n,r).getClientRects();for(let e=0;e<o.length;e++){let t=o[e];if(e==o.length-1||t.top<t.bottom&&t.left<t.right)return t}return null}measureVisibleLineHeights(e){let t=[],{from:n,to:i}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,s=-1,a=this.view.textDirection==ad.LTR;for(let e=0,l=0;l<this.children.length;l++){let c=this.children[l],h=e+c.length;if(h>i)break;if(e>=n){let n=c.dom.getBoundingClientRect();if(t.push(n.height),o){let t=c.dom.lastChild,i=t?Jh(t):[];if(i.length){let t=i[i.length-1],o=a?t.right-n.left:n.right-t.left;o>s&&(s=o,this.minWidth=r,this.minWidthFrom=e,this.minWidthTo=h)}}}e=h+c.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return"rtl"==getComputedStyle(this.children[t].dom).direction?ad.RTL:ad.LTR}measureTextSize(){for(let e of this.children)if(e instanceof td){let t=e.measureTextSize();if(t)return t}let e,t,n,i=document.createElement("div");return i.className="cm-line",i.style.width="99999px",i.style.position="absolute",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(i);let r=Jh(i.firstChild)[0];e=i.getBoundingClientRect().height,t=r?r.width/27:7,n=r?r.height:e,i.remove()})),{lineHeight:e,charWidth:t,textHeight:n}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new bu(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,i=0;;i++){let r=i==t.viewports.length?null:t.viewports[i],o=r?r.from-1:this.length;if(o>n){let i=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(Xu.replace({widget:new id(i),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!r)break;n=r.to+1}return Xu.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Xd).map((t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t)),n=!1,i=this.view.state.facet(Yd).map(((e,t)=>{let i="function"==typeof e;return i&&(n=!0),i?e(this.view):e}));for(i.length&&(this.dynamicDecorationMap[e++]=n,t.push(Eh.join(i))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(Ld))try{if(t(this.view,e.range,e))return!0}catch(e){Vd(this.view.state,e,"scroll handler")}let t,{range:n}=e,i=this.coordsAt(n.head,n.empty?n.assoc:n.head>n.anchor?-1:1);if(!i)return;!n.empty&&(t=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(i={left:Math.min(i.left,t.left),top:Math.min(i.top,t.top),right:Math.max(i.right,t.right),bottom:Math.max(i.bottom,t.bottom)});let r=tp(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:s,offsetHeight:a}=this.view.scrollDOM;!function(e,t,n,i,r,o,s,a){let l=e.ownerDocument,c=l.defaultView||window;for(let h=e,u=!1;h&&!u;)if(1==h.nodeType){let e,d=h==l.body,p=1,f=1;if(d)e=ru(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let t=h.getBoundingClientRect();({scaleX:p,scaleY:f}=ou(h,t)),e={left:t.left,right:t.left+h.clientWidth*p,top:t.top,bottom:t.top+h.clientHeight*f}}let g=0,m=0;if("nearest"==r)t.top<e.top?(m=-(e.top-t.top+s),n>0&&t.bottom>e.bottom+m&&(m=t.bottom-e.bottom+m+s)):t.bottom>e.bottom&&(m=t.bottom-e.bottom+s,n<0&&t.top-m<e.top&&(m=-(e.top+m-t.top+s)));else{let i=t.bottom-t.top,o=e.bottom-e.top;m=("center"==r&&i<=o?t.top+i/2-o/2:"start"==r||"center"==r&&n<0?t.top-s:t.bottom-o+s)-e.top}if("nearest"==i?t.left<e.left?(g=-(e.left-t.left+o),n>0&&t.right>e.right+g&&(g=t.right-e.right+g+o)):t.right>e.right&&(g=t.right-e.right+o,n<0&&t.left<e.left+g&&(g=-(e.left+g-t.left+o))):g=("center"==i?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==i==a?t.left-o:t.right-(e.right-e.left)+o)-e.left,g||m)if(d)c.scrollBy(g,m);else{let e=0,n=0;if(m){let e=h.scrollTop;h.scrollTop+=m/f,n=(h.scrollTop-e)*f}if(g){let t=h.scrollLeft;h.scrollLeft+=g/p,e=(h.scrollLeft-t)*p}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-g)<1&&(i="nearest"),n&&Math.abs(n-m)<1&&(r="nearest")}if(d)break;h=h.assignedSlot||h.parentNode}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,o,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,s),-s),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==ad.LTR)}}function sp(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let i=fu(n.focusNode,n.focusOffset),r=gu(n.focusNode,n.focusOffset),o=i||r;if(r&&i&&r.node!=i.node){let t=yu.get(r.node);if(!t||t instanceof qu&&t.text!=r.node.nodeValue)o=r;else if(e.docView.lastCompositionAfterCursor){let e=yu.get(i.node);!e||e instanceof qu&&e.text!=i.node.nodeValue||(o=r)}}if(e.docView.lastCompositionAfterCursor=o!=i,!o)return null;let s=t-o.offset;return{from:s,to:s+o.node.nodeValue.length,node:o.node}}let ap=class{constructor(){this.changes=[]}compareRange(e,t){ed(e,t,this.changes)}comparePoint(e,t){ed(e,t,this.changes)}boundChange(e){ed(e,e,this.changes)}};function lp(e,t){return t.left>e?t.left-e:Math.max(0,e-t.right)}function cp(e,t){return t.top>e?t.top-e:Math.max(0,e-t.bottom)}function hp(e,t){return e.top<t.bottom-1&&e.bottom>t.top+1}function up(e,t){return t<e.top?{top:t,left:e.left,right:e.right,bottom:e.bottom}:e}function dp(e,t){return t>e.bottom?{top:e.top,left:e.left,right:e.right,bottom:t}:e}function pp(e,t,n){let i,r,o,s,a,l,c,h,u=!1;for(let d=e.firstChild;d;d=d.nextSibling){let e=Jh(d);for(let p=0;p<e.length;p++){let f=e[p];r&&hp(r,f)&&(f=up(dp(f,r.bottom),r.top));let g=lp(t,f),m=cp(n,f);if(0==g&&0==m)return 3==d.nodeType?fp(d,t,n):pp(d,t,n);if(!i||s>m||s==m&&o>g){i=d,r=f,o=g,s=m;let a=m?n<f.top?-1:1:g?t<f.left?-1:1:0;u=!a||(a>0?p<e.length-1:p>0)}0==g?n>f.bottom&&(!c||c.bottom<f.bottom)?(a=d,c=f):n<f.top&&(!h||h.top>f.top)&&(l=d,h=f):c&&hp(c,f)?c=dp(c,f.bottom):h&&hp(h,f)&&(h=up(h,f.top))}}if(c&&c.bottom>=n?(i=a,r=c):h&&h.top<=n&&(i=l,r=h),!i)return{node:e,offset:0};let d=Math.max(r.left,Math.min(r.right,t));return 3==i.nodeType?fp(i,d,n):u&&"false"!=i.contentEditable?pp(i,d,n):{node:e,offset:Array.prototype.indexOf.call(e.childNodes,i)+(t>=(r.left+r.right)/2?1:0)}}function fp(e,t,n){let i=e.nodeValue.length,r=-1,o=1e9,s=0;for(let a=0;a<i;a++){let i=hu(e,a,a+1).getClientRects();for(let l=0;l<i.length;l++){let c=i[l];if(c.top==c.bottom)continue;s||(s=t-c.left);let h=(c.top>n?c.top-n:n-c.bottom)-1;if(c.left-1<=t&&c.right+1>=t&&h<o){let n=t>=(c.left+c.right)/2,i=n;if(Pu.chrome||Pu.gecko){hu(e,a).getBoundingClientRect().left==c.right&&(i=!n)}if(h<=0)return{node:e,offset:a+(i?1:0)};r=a+(i?1:0),o=h}}}return{node:e,offset:r>-1?r:s>0?e.nodeValue.length:0}}function gp(e,t,n,i=-1){var r,o;let s,a=e.contentDOM.getBoundingClientRect(),l=a.top+e.viewState.paddingTop,{docHeight:c}=e.viewState,{x:h,y:u}=t,d=u-l;if(d<0)return 0;if(d>c)return e.state.doc.length;for(let t=e.viewState.heightOracle.textHeight/2,r=!1;s=e.elementAtHeight(d),s.type!=Ku.Text;)for(;d=i>0?s.bottom+t:s.top-t,!(d>=0&&d<=c);){if(r)return n?null:0;r=!0,i=-i}u=l+d;let p=s.from;if(p<e.viewport.from)return 0==e.viewport.from?0:n?null:mp(e,a,s,h,u);if(p>e.viewport.to)return e.viewport.to==e.state.doc.length?e.state.doc.length:n?null:mp(e,a,s,h,u);let f=e.dom.ownerDocument,g=e.root.elementFromPoint?e.root:f,m=g.elementFromPoint(h,u);m&&!e.contentDOM.contains(m)&&(m=null),m||(h=Math.max(a.left+1,Math.min(a.right-1,h)),m=g.elementFromPoint(h,u),m&&!e.contentDOM.contains(m)&&(m=null));let v,y=-1;if(m&&0!=(null===(r=e.docView.nearest(m))||void 0===r?void 0:r.isEditable)){if(f.caretPositionFromPoint){let e=f.caretPositionFromPoint(h,u);e&&({offsetNode:v,offset:y}=e)}else if(f.caretRangeFromPoint){let t=f.caretRangeFromPoint(h,u);t&&(({startContainer:v,startOffset:y}=t),(!e.contentDOM.contains(v)||Pu.safari&&function(e,t,n){let i;if(3!=e.nodeType||t!=(i=e.nodeValue.length))return!1;for(let t=e.nextSibling;t;t=t.nextSibling)if(1!=t.nodeType||"BR"!=t.nodeName)return!1;return hu(e,i-1,i).getBoundingClientRect().left>n}(v,y,h)||Pu.chrome&&function(e,t,n){if(0!=t)return!1;for(let t=e;;){let e=t.parentNode;if(!e||1!=e.nodeType||e.firstChild!=t)return!1;if(e.classList.contains("cm-line"))break;t=e}let i=1==e.nodeType?e.getBoundingClientRect():hu(e,0,Math.max(e.nodeValue.length,1)).getBoundingClientRect();return n-i.left>5}(v,y,h))&&(v=void 0))}v&&(y=Math.min(nu(v),y))}if(!v||!e.docView.dom.contains(v)){let t=td.find(e.docView,p);if(!t)return d>s.top+s.height/2?s.to:s.from;({node:v,offset:y}=pp(t.dom,h,u))}let w=e.docView.nearest(v);if(!w)return null;if(w.isWidget&&1==(null===(o=w.dom)||void 0===o?void 0:o.nodeType)){let e=w.dom.getBoundingClientRect();return t.y<e.top||t.y<=e.bottom&&t.x<=(e.left+e.right)/2?w.posAtStart:w.posAtEnd}return w.localPosFromDOM(v,y)+w.posAtStart}function mp(e,t,n,i,r){let o=Math.round((i-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;o+=Math.floor((r-n.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let s=e.state.sliceDoc(n.from,n.to);return n.from+function(e,t,n,i){for(let i=0,r=0;;){if(r>=t)return i;if(i==e.length)break;r+=9==e.charCodeAt(i)?n-r%n:1,i=yc(e,i)}return!0===i?-1:e.length}(s,o,e.state.tabSize)}function vp(e,t,n,i){let r=function(e,t){let n=e.lineBlockAt(t);if(Array.isArray(n.type))for(let e of n.type)if(e.to>t||e.to==t&&(e.to==n.to||e.type==Ku.Text))return e;return n}(e,t.head),o=i&&r.type==Ku.Text&&(e.lineWrapping||r.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head):null;if(o){let t=e.dom.getBoundingClientRect(),i=e.textDirectionAt(r.from),s=e.posAtCoords({x:n==(i==ad.LTR)?t.right-1:t.left+1,y:(o.top+o.bottom)/2});if(null!=s)return Tc.cursor(s,n?-1:1)}return Tc.cursor(n?r.to:r.from,n?-1:1)}function yp(e,t,n,i){let r=e.state.doc.lineAt(t.head),o=e.bidiSpans(r),s=e.textDirectionAt(r.from);for(let a=t,l=null;;){let t=kd(r,o,s,a,n),c=Sd;if(!t){if(r.number==(n?e.state.doc.lines:1))return a;c="\n",r=e.state.doc.line(r.number+(n?1:-1)),o=e.bidiSpans(r),t=e.visualLineSide(r,!n)}if(l){if(!l(c))return a}else{if(!i)return t;l=i(c)}a=t}}function wp(e,t,n){for(;;){let i=0;for(let r of e)r.between(t-1,t+1,((e,r,o)=>{if(t>e&&t<r){let o=i||n||(t-e<r-t?-1:1);t=o<0?e:r,i=o}}));if(!i)return t}}function bp(e,t,n){let i=wp(e.state.facet(Jd).map((t=>t(e))),n.from,t.head>n.from?-1:1);return i==n.from?n:Tc.cursor(i,i<n.from?1:-1)}const xp="";class _p{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(xh.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=xp}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let i=e;;){this.findPointBefore(n,i);let e=this.text.length;this.readNode(i);let r=i.nextSibling;if(r==t)break;let o=yu.get(i),s=yu.get(r);(o&&s?o.breakAfter:(o?o.breakAfter:eu(i))||eu(r)&&("BR"!=i.nodeName||i.cmIgnore)&&this.text.length>e)&&this.lineBreak(),i=r}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let r,o=-1,s=1;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(r=i.exec(t))&&(o=r.index,s=r[0].length),this.append(t.slice(n,o<0?t.length:o)),o<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);n=o+s}}readNode(e){if(e.cmIgnore)return;let t=yu.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Sp(e,n.node,n.offset)?t:0))}}function Sp(e,t,n){for(;;){if(!t||n<nu(t))return!1;if(t==e)return!0;n=Zh(t)+1,t=t.parentNode}}class kp{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class Cp{constructor(e,t,n,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let t=r||o?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:o}=e.observer.selectionRange;n&&(t.push(new kp(n,i)),r==n&&o==i||t.push(new kp(r,o)));return t}(e),n=new _p(t,e.state);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,i=2==e.length?e[1].pos:n;return n>-1&&i>-1?Tc.single(n+t,i+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=r&&r.node==t.focusNode&&r.offset==t.focusOffset||!Xh(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),i=o&&o.node==t.anchorNode&&o.offset==t.anchorOffset||!Xh(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((Pu.ios||Pu.chrome)&&e.state.selection.main.empty&&n!=i&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,i),r=Math.max(n,i),o=s.from-t,a=s.to-r;0!=o&&1!=o&&0!=t||0!=a&&-1!=a&&r!=e.state.doc.length||(n=0,i=e.state.doc.length)}this.newSel=Tc.single(i,n)}}}function Ep(e,t){let n,{newSel:i}=t,r=e.state.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:i,to:s}=t.bounds,a=r.from,l=null;(8===o||Pu.android&&t.text.length<s-i)&&(a=r.to,l="end");let c=function(e,t,n,i){let r=Math.min(e.length,t.length),o=0;for(;o<r&&e.charCodeAt(o)==t.charCodeAt(o);)o++;if(o==r&&e.length==t.length)return null;let s=e.length,a=t.length;for(;s>0&&a>0&&e.charCodeAt(s-1)==t.charCodeAt(a-1);)s--,a--;if("end"==i){n-=s+Math.max(0,o-Math.min(s,a))-o}if(s<o&&e.length<t.length){o-=n<=o&&n>=s?o-n:0,a=o+(a-s),s=o}else if(a<o){o-=n<=o&&n>=a?o-n:0,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}(e.state.doc.sliceString(i,s,xp),t.text,a-i,l);c&&(Pu.chrome&&13==o&&c.toB==c.from+2&&t.text.slice(c.from,c.toB)==xp+xp&&c.toB--,n={from:i+c.from,to:i+c.toA,insert:lc.of(t.text.slice(c.from,c.toB).split(xp))})}else i&&(!e.hasFocus&&e.state.facet($d)||i.main.eq(r))&&(i=null);if(!n&&!i)return!1;if(!n&&t.typeOver&&!r.empty&&i&&i.main.empty?n={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,r.to)}:(Pu.mac||Pu.android)&&n&&n.from==n.to&&n.from==r.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(i&&2==n.insert.length&&(i=Tc.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:lc.of([n.insert.toString().replace("."," ")])}):n&&n.from>=r.from&&n.to<=r.to&&(n.from!=r.from||n.to!=r.to)&&r.to-r.from-(n.to-n.from)<=4?n={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,n.from).append(n.insert).append(e.state.doc.slice(n.to,r.to))}:Pu.chrome&&n&&n.from==n.to&&n.from==r.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(i&&(i=Tc.single(i.main.anchor-1,i.main.head-1)),n={from:r.from,to:r.to,insert:lc.of([" "])}),n)return Mp(e,n,i,o);if(i&&!i.main.eq(r)){let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),n=e.inputState.lastSelectionOrigin),e.dispatch({selection:i,scrollIntoView:t,userEvent:n}),!0}return!1}function Mp(e,t,n,i=-1){if(Pu.ios&&e.inputState.flushIOSKey(t))return!0;let r=e.state.selection.main;if(Pu.android&&(t.to==r.to&&(t.from==r.from||t.from==r.from-1&&" "==e.state.sliceDoc(t.from,r.from))&&1==t.insert.length&&2==t.insert.lines&&uu(e.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&0==t.insert.length||8==i&&t.insert.length<t.to-t.from&&t.to>r.head)&&uu(e.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&0==t.insert.length&&uu(e.contentDOM,"Delete",46)))return!0;let o,s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>o||(o=function(e,t,n){let i,r=e.state,o=r.selection.main;if(t.from>=o.from&&t.to<=o.to&&t.to-t.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=o.from<t.from?r.sliceDoc(o.from,t.from):"",s=o.to>t.to?r.sliceDoc(t.to,o.to):"";i=r.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+s))}else{let s=r.changes(t),a=n&&n.main.to<=s.newLength?n.main:void 0;if(r.selection.ranges.length>1&&e.inputState.composing>=0&&t.to<=o.to&&t.to>=o.to-10){let l,c=e.state.sliceDoc(t.from,t.to),h=n&&sp(e,n.main.head);if(h){let e=t.insert.length-(t.to-t.from);l={from:h.from,to:h.to-e}}else l=e.state.doc.lineAt(o.head);let u=o.to-t.to,d=o.to-o.from;i=r.changeByRange((n=>{if(n.from==o.from&&n.to==o.to)return{changes:s,range:a||n.map(s)};let i=n.to-u,h=i-c.length;if(n.to-n.from!=d||e.state.sliceDoc(h,i)!=c||n.to>=l.from&&n.from<=l.to)return{range:n};let p=r.changes({from:h,to:i,insert:t.insert}),f=n.to-o.to;return{changes:p,range:a?Tc.range(Math.max(0,a.anchor+f),Math.max(0,a.head+f)):n.map(p)}}))}else i={changes:s,selection:a&&r.selection.replaceRange(a)}}let s="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=".compose",e.inputState.compositionFirstChange&&(s+=".start",e.inputState.compositionFirstChange=!1));return r.update(i,{userEvent:s,scrollIntoView:!0})}(e,t,n));return e.state.facet(Dd).some((n=>n(e,t.from,t.to,s,a)))||e.dispatch(a()),!0}class Ap{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Pu.safari&&e.contentDOM.addEventListener("input",(()=>null)),Pu.gecko&&function(e){tf.has(e)||(tf.add(e),e.addEventListener("copy",(()=>{})),e.addEventListener("cut",(()=>{})))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n,i=t.target;i!=e.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(n=yu.get(i))&&n.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Tp(e),n=this.handlers,i=this.view.contentDOM;for(let e in t)if("scroll"!=e){let r=!t[e].handlers.length,o=n[e];o&&r!=!o.handlers.length&&(i.removeEventListener(e,this.handleEvent),o=null),o||i.addEventListener(e,this.handleEvent,{passive:r})}for(let e in n)"scroll"==e||t[e]||i.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&Np.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Pu.android&&Pu.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!Pu.ios||e.synthetic||e.altKey||e.metaKey||!((t=Dp.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||Op.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,uu(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0)))}ignoreDuringComposition(e){return!!/^key/.test(e.type)&&(this.composing>0||!!(Pu.safari&&!Pu.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Rp(e,t){return(n,i)=>{try{return t.call(e,i,n)}catch(e){Vd(n.state,e)}}}function Tp(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec;if(e&&e.domEventHandlers)for(let i in e.domEventHandlers){let r=e.domEventHandlers[i];r&&n(i).handlers.push(Rp(t.value,r))}if(e&&e.domEventObservers)for(let i in e.domEventObservers){let r=e.domEventObservers[i];r&&n(i).observers.push(Rp(t.value,r))}}for(let e in Bp)n(e).handlers.push(Bp[e]);for(let e in Lp)n(e).observers.push(Lp[e]);return t}const Dp=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Op="dthko",Np=[16,17,18,20,91,92,224,225];function Pp(e){return.7*Math.max(0,e)+8}class qp{constructor(e,t,n,i){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t,n,i=e.ownerDocument;for(let r=e.parentNode;r&&!(r==i.body||t&&n);)if(1==r.nodeType)!n&&r.scrollHeight>r.clientHeight&&(n=r),!t&&r.scrollWidth>r.clientWidth&&(t=r),r=r.assignedSlot||r.parentNode;else{if(11!=r.nodeType)break;r=r.host}return{x:t,y:n}}(e.contentDOM),this.atoms=e.state.facet(Jd).map((t=>t(e)));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(xh.allowMultipleSelections)&&function(e,t){let n=e.state.facet(Ed);return n.length?n[0](t):Pu.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let i=Kh(e.root);if(!i||0==i.rangeCount)return!0;let r=i.getRangeAt(0).getClientRects();for(let e=0;e<r.length;e++){let n=r[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)||1!=Xp(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(t=this.startEvent,n=e,Math.max(Math.abs(t.clientX-n.clientX),Math.abs(t.clientY-n.clientY))<10))return;var t,n;this.select(this.lastEvent=e);let i=0,r=0,o=0,s=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=tp(this.view);e.clientX-c.left<=o+6?i=-Pp(o-e.clientX):e.clientX+c.right>=a-6&&(i=Pp(e.clientX-a)),e.clientY-c.top<=s+6?r=-Pp(s-e.clientY):e.clientY+c.bottom>=l-6&&(r=Pp(e.clientY-l)),this.setScrollSpeed(i,r)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;n<e.ranges.length;n++){let i=e.ranges[n],r=null;if(i.empty){let e=wp(this.atoms,i.from,0);e!=i.from&&(r=Tc.cursor(e,-1))}else{let e=wp(this.atoms,i.from,-1),t=wp(this.atoms,i.to,1);e==i.from&&t==i.to||(r=Tc.range(i.from==i.anchor?e:t,i.from==i.head?e:t))}r&&(t||(t=e.ranges.slice()),t[n]=r)}return t?Tc.create(t,e.mainIndex):e}select(e){let{view:t}=this,n=this.skipAtoms(this.style.get(e,this.extend,this.multiple));!this.mustSelect&&n.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some((e=>e.isUserEvent("input.type")))?this.destroy():this.style.update(e)&&setTimeout((()=>this.select(this.lastEvent)),20)}}const Bp=Object.create(null),Lp=Object.create(null),Ip=Pu.ie&&Pu.ie_version<15||Pu.ios&&Pu.webkit_version<604;function jp(e,t,n){for(let i of e.facet(t))n=i(n,e);return n}function Fp(e,t){t=jp(e.state,Nd,t);let n,{state:i}=e,r=1,o=i.toText(t),s=o.lines==i.selection.ranges.length;if(null!=Jp&&i.selection.ranges.every((e=>e.empty))&&Jp==o.toString()){let e=-1;n=i.changeByRange((n=>{let a=i.doc.lineAt(n.from);if(a.from==e)return{range:n};e=a.from;let l=i.toText((s?o.line(r++).text:t)+i.lineBreak);return{changes:{from:a.from,insert:l},range:Tc.cursor(n.from+l.length)}}))}else n=s?i.changeByRange((e=>{let t=o.line(r++);return{changes:{from:e.from,to:e.to,insert:t.text},range:Tc.cursor(e.from+t.length)}})):i.replaceSelection(o);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function Vp(e,t,n,i){if(1==i)return Tc.cursor(t,n);if(2==i)return function(e,t,n=1){let i=e.charCategorizer(t),r=e.doc.lineAt(t),o=t-r.from;if(0==r.length)return Tc.cursor(t);0==o?n=1:o==r.length&&(n=-1);let s=o,a=o;n<0?s=yc(r.text,o,!1):a=yc(r.text,o);let l=i(r.text.slice(s,a));for(;s>0;){let e=yc(r.text,s,!1);if(i(r.text.slice(e,s))!=l)break;s=e}for(;a<r.length;){let e=yc(r.text,a);if(i(r.text.slice(a,e))!=l)break;a=e}return Tc.range(s+r.from,a+r.from)}(e.state,t,n);{let n=td.find(e.docView,t),i=e.state.doc.lineAt(n?n.posAtEnd:t),r=n?n.posAtStart:i.from,o=n?n.posAtEnd:i.to;return o<e.state.doc.length&&o==i.to&&o++,Tc.range(r,o)}}Lp.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},Bp.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),Lp.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},Lp.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},Bp.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of e.state.facet(Ad))if(n=i(e,t),n)break;if(n||0!=t.button||(n=function(e,t){let n=Hp(e,t),i=Xp(t),r=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),r=r.map(e.changes))},get(t,o,s){let a,l=Hp(e,t),c=Vp(e,l.pos,l.bias,i);if(n.pos!=l.pos&&!o){let t=Vp(e,n.pos,n.bias,i),r=Math.min(t.from,c.from),o=Math.max(t.to,c.to);c=r<c.from?Tc.range(r,o):Tc.range(o,r)}return o?r.replaceRange(r.main.extend(c.from,c.to)):s&&1==i&&r.ranges.length>1&&(a=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:i,to:r}=e.ranges[n];if(i<=t&&r>=t)return Tc.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(r,l.pos))?a:s?r.addRange(c):Tc.create([c])}}}(e,t)),n){let i=!e.hasFocus;e.inputState.startMouseSelection(new qp(e,t,n,i)),i&&e.observer.ignore((()=>{cu(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()}));let r=e.inputState.mouseSelection;if(r)return r.start(t),!1===r.dragging}return!1};let $p=(e,t,n)=>t>=n.top&&t<=n.bottom&&e>=n.left&&e<=n.right;function zp(e,t,n,i){let r=td.find(e.docView,t);if(!r)return 1;let o=t-r.posAtStart;if(0==o)return 1;if(o==r.length)return-1;let s=r.coordsAt(o,-1);if(s&&$p(n,i,s))return-1;let a=r.coordsAt(o,1);return a&&$p(n,i,a)?1:s&&s.bottom>=i?-1:1}function Hp(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1);return{pos:n,bias:zp(e,n,t.clientX,t.clientY)}}const Wp=Pu.ie&&Pu.ie_version<=11;let Up=null,Gp=0,Kp=0;function Xp(e){if(!Wp)return e.detail;let t=Up,n=Kp;return Up=e,Kp=Date.now(),Gp=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Gp+1)%3:1}function Yp(e,t,n,i){if(!(n=jp(e.state,Nd,n)))return;let r=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,s=i&&o&&function(e,t){let n=e.state.facet(Md);return n.length?n[0](t):Pu.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:o.from,to:o.to}:null,a={from:r,insert:n},l=e.state.changes(s?[s,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}Bp.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let i=e.docView.nearest(t.target);if(i&&i.isWidget){let e=i.posAtStart,t=e+i.length;(e>=n.to||t<=n.from)&&(n=Tc.range(e,t))}}let{inputState:i}=e;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",jp(e.state,Pd,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},Bp.dragend=e=>(e.inputState.draggedContent=null,!1),Bp.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,o=()=>{++r==n.length&&Yp(e,t,i.filter((e=>null!=e)).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=o,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(i[e]=t.result),o()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return Yp(e,t,n,!0),!0}return!1},Bp.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=Ip?null:t.clipboardData;return n?(Fp(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout((()=>{e.focus(),n.remove(),Fp(e,n.value)}),50)}(e),!1)};let Jp=null;Bp.copy=Bp.cut=(e,t)=>{let{text:n,ranges:i,linewise:r}=function(e){let t=[],n=[],i=!1;for(let i of e.selection.ranges)i.empty||(t.push(e.sliceDoc(i.from,i.to)),n.push(i));if(!t.length){let r=-1;for(let{from:i}of e.selection.ranges){let o=e.doc.lineAt(i);o.number>r&&(t.push(o.text),n.push({from:o.from,to:Math.min(e.doc.length,o.to+1)})),r=o.number}i=!0}return{text:jp(e,Pd,t.join(e.lineBreak)),ranges:n,linewise:i}}(e.state);if(!n&&!r)return!1;Jp=r?n:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let o=Ip?null:t.clipboardData;return o?(o.clearData(),o.setData("text/plain",n),!0):(function(e,t){let n=e.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout((()=>{i.remove(),e.focus()}),50)}(e,n),!1)};const Qp=sh.define();function Zp(e,t){let n=[];for(let i of e.facet(Od)){let r=i(e,t);r&&n.push(r)}return n?e.update({effects:n,annotations:Qp.of(!0)}):null}function ef(e){setTimeout((()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=Zp(e.state,t);n?e.dispatch(n):e.update([])}}),10)}Lp.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),ef(e)},Lp.blur=e=>{e.observer.clearSelectionRange(),ef(e)},Lp.compositionstart=Lp.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},Lp.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,Pu.chrome&&Pu.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then((()=>e.observer.flush())):setTimeout((()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])}),50))},Lp.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},Bp.beforeinput=(e,t)=>{var n,i;if("insertReplacementText"==t.inputType&&e.observer.editContext){let i=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/plain"),r=t.getTargetRanges();if(i&&r.length){let t=r[0],n=e.posAtDOM(t.startContainer,t.startOffset),o=e.posAtDOM(t.endContainer,t.endOffset);return Mp(e,{from:n,to:o,insert:e.state.toText(i)},null),!0}}let r;if(Pu.chrome&&Pu.android&&(r=Dp.find((e=>e.inputType==t.inputType)))&&(e.observer.delayAndroidKey(r.key,r.keyCode),"Backspace"==r.key||"Delete"==r.key)){let t=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var n;((null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())}),100)}return Pu.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),Pu.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout((()=>Lp.compositionend(e,t)),20),!1};const tf=new Set;const nf=["pre-wrap","normal","pre-line","break-spaces"];let rf=!1;function of(){rf=!1}class sf{constructor(e){this.lineWrapping=e,this.doc=lc.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return nf.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let i=e[n];i<0?n++:this.heightSamples[Math.floor(10*i)]||(t=!0,this.heightSamples[Math.floor(10*i)]=!0)}return t}refresh(e,t,n,i,r,o){let s=nf.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=s;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=n,this.textHeight=i,this.lineLength=r,a){this.heightSamples={};for(let e=0;e<o.length;e++){let t=o[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return a}}class af{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class lf{constructor(e,t,n,i,r){this.from=e,this.length=t,this.top=n,this.height=i,this._content=r}get type(){return"number"==typeof this._content?Ku.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Qu?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new lf(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var cf=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(cf||(cf={}));const hf=.001;class uf{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>hf&&(rf=!0),this.height=e)}replace(e,t,n){return uf.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,i){let r=this,o=n.doc;for(let s=i.length-1;s>=0;s--){let{fromA:a,toA:l,fromB:c,toB:h}=i[s],u=r.lineAt(a,cf.ByPosNoHeight,n.setDoc(t),0,0),d=u.to>=l?u:r.lineAt(l,cf.ByPosNoHeight,n,0,0);for(h+=d.to-l,l=d.to;s>0&&u.from<=i[s-1].toA;)a=i[s-1].fromA,c=i[s-1].fromB,s--,a<u.from&&(u=r.lineAt(a,cf.ByPosNoHeight,n,0,0));c+=u.from-a,a=u.from;let p=yf.build(n.setDoc(o),e,c,h);r=df(r,r.replace(a,l,p))}return r.updateHeight(n,0)}static empty(){return new ff(0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,i=0,r=0;for(;;)if(t==n)if(i>2*r){let r=e[t-1];r.break?e.splice(--t,1,r.left,null,r.right):e.splice(--t,1,r.left,r.right),n+=1+r.break,i-=r.size}else{if(!(r>2*i))break;{let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,r-=t.size}}else if(i<r){let n=e[t++];n&&(i+=n.size)}else{let t=e[--n];t&&(r+=t.size)}let o=0;return null==e[t-1]?(o=1,t--):null==e[t]&&(o=1,n++),new mf(uf.of(e.slice(0,t)),o,uf.of(e.slice(n)))}}function df(e,t){return e==t?e:(e.constructor!=t.constructor&&(rf=!0),t)}uf.prototype.size=1;class pf extends uf{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,i){return new lf(i,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,i,r){return this.blockAt(0,n,i,r)}forEachLine(e,t,n,i,r,o){e<=r+this.length&&t>=r&&o(this.blockAt(0,n,i,r))}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more&&this.setHeight(i.heights[i.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ff extends pf{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,i){return new lf(i,this.length,n,this.height,this.breaks)}replace(e,t,n){let i=n[0];return 1==n.length&&(i instanceof ff||i instanceof gf&&4&i.flags)&&Math.abs(this.length-i.length)<10?(i instanceof gf?i=new ff(i.length,this.height):i.height=this.height,this.outdated||(i.outdated=!1),i):uf.of(n)}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more?this.setHeight(i.heights[i.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class gf extends uf{constructor(e){super(e,0)}heightMetrics(e,t){let n,i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,o=r-i+1,s=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*o);n=t/o,this.length>o+1&&(s=(this.height-t)/(this.length-o-1))}else n=this.height/o;return{firstLine:i,lastLine:r,perLine:n,perChar:s}}blockAt(e,t,n,i){let{firstLine:r,lastLine:o,perLine:s,perChar:a}=this.heightMetrics(t,i);if(t.lineWrapping){let r=i+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),o=t.doc.lineAt(r),l=s+o.length*a,c=Math.max(n,e-l/2);return new lf(o.from,o.length,c,l,0)}{let i=Math.max(0,Math.min(o-r,Math.floor((e-n)/s))),{from:a,length:l}=t.doc.line(r+i);return new lf(a,l,n+s*i,s,0)}}lineAt(e,t,n,i,r){if(t==cf.ByHeight)return this.blockAt(e,n,i,r);if(t==cf.ByPosNoHeight){let{from:t,to:i}=n.doc.lineAt(e);return new lf(t,i-t,0,0,0)}let{firstLine:o,perLine:s,perChar:a}=this.heightMetrics(n,r),l=n.doc.lineAt(e),c=s+l.length*a,h=l.number-o,u=i+s*h+a*(l.from-r-h);return new lf(l.from,l.length,Math.max(i,Math.min(u,i+this.height-c)),c,0)}forEachLine(e,t,n,i,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(n,r);for(let c=e,h=i;c<=t;){let t=n.doc.lineAt(c);if(c==e){let n=t.number-s;h+=a*n+l*(e-r-n)}let i=a+l*t.length;o(new lf(t.from,t.length,h,i,0)),h+=i,c=t.to+1}}replace(e,t,n){let i=this.length-t;if(i>0){let e=n[n.length-1];e instanceof gf?n[n.length-1]=new gf(e.length+i):n.push(null,new gf(i-1))}if(e>0){let t=n[0];t instanceof gf?n[0]=new gf(e+t.length):n.unshift(new gf(e-1),null)}return uf.of(n)}decomposeLeft(e,t){t.push(new gf(e-1),null)}decomposeRight(e,t){t.push(null,new gf(this.length-e-1))}updateHeight(e,t=0,n=!1,i){let r=t+this.length;if(i&&i.from<=t+this.length&&i.more){let n=[],o=Math.max(t,i.from),s=-1;for(i.from>t&&n.push(new gf(i.from-t-1).updateHeight(e,t));o<=r&&i.more;){let t=e.doc.lineAt(o).length;n.length&&n.push(null);let r=i.heights[i.index++];-1==s?s=r:Math.abs(r-s)>=hf&&(s=-2);let a=new ff(t,r);a.outdated=!1,n.push(a),o+=t+1}o<=r&&n.push(null,new gf(r-o).updateHeight(e,o));let a=uf.of(n);return(s<0||Math.abs(a.height-this.height)>=hf||Math.abs(s-this.heightMetrics(e,t).perLine)>=hf)&&(rf=!0),df(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class mf extends uf{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return 1&this.flags}blockAt(e,t,n,i){let r=n+this.left.height;return e<r?this.left.blockAt(e,t,n,i):this.right.blockAt(e,t,r,i+this.left.length+this.break)}lineAt(e,t,n,i,r){let o=i+this.left.height,s=r+this.left.length+this.break,a=t==cf.ByHeight?e<o:e<s,l=a?this.left.lineAt(e,t,n,i,r):this.right.lineAt(e,t,n,o,s);if(this.break||(a?l.to<s:l.from>s))return l;let c=t==cf.ByPosNoHeight?cf.ByPosNoHeight:cf.ByPos;return a?l.join(this.right.lineAt(s,c,n,o,s)):this.left.lineAt(s,c,n,i,r).join(l)}forEachLine(e,t,n,i,r,o){let s=i+this.left.height,a=r+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,i,r,o),t>=a&&this.right.forEachLine(e,t,n,s,a,o);else{let l=this.lineAt(a,cf.ByPos,n,i,r);e<l.from&&this.left.forEachLine(e,l.from-1,n,i,r,o),l.to>=e&&l.from<=t&&o(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,s,a,o)}}replace(e,t,n){let i=this.left.length+this.break;if(t<i)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,n));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let e of n)r.push(e);if(e>0&&vf(r,o-1),t<this.length){let e=r.length;this.decomposeRight(t,r),vf(r,e)}return uf.of(r)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,i=n+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<i&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?uf.of(this.break?[e,null,t]:[e,t]):(this.left=df(this.left,e),this.right=df(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,i){let{left:r,right:o}=this,s=t+r.length+this.break,a=null;return i&&i.from<=t+r.length&&i.more?a=r=r.updateHeight(e,t,n,i):r.updateHeight(e,t,n),i&&i.from<=s+o.length&&i.more?a=o=o.updateHeight(e,s,n,i):o.updateHeight(e,s,n),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function vf(e,t){let n,i;null==e[t]&&(n=e[t-1])instanceof gf&&(i=e[t+1])instanceof gf&&e.splice(t-1,3,new gf(n.length+1+i.length))}class yf{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof ff?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new ff(e-this.pos,-1)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let i=n.widget?n.widget.estimatedHeight:0,r=n.widget?n.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new pf(o,i,n)):(o||r||i>=5)&&this.addLineDeco(i,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new ff(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new gf(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ff)return e;let t=new ff(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let i=this.ensureLine();i.length+=n,i.collapsed+=n,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof ff||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new ff(0,-1));let n=e;for(let e of this.nodes)e instanceof ff&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,i){let r=new yf(n,e);return Eh.spans(t,n,i,r,0),r.finish(n)}}class wf{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,i){(e<t||n&&n.heightRelevant||i&&i.heightRelevant)&&ed(e,t,this.changes,5)}}function bf(e,t){let n=e.getBoundingClientRect(),i=e.ownerDocument,r=i.defaultView||window,o=Math.max(0,n.left),s=Math.min(r.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(r.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=i.body;)if(1==t.nodeType){let n=t,i=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=i.overflow){let i=n.getBoundingClientRect();o=Math.max(o,i.left),s=Math.min(s,i.right),a=Math.max(a,i.top),l=Math.min(t==e.parentNode?r.innerHeight:l,i.bottom)}t="absolute"==i.position||"fixed"==i.position?n.offsetParent:n.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:o-n.left,right:Math.max(o,s)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function xf(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class _f{constructor(e,t,n,i){this.from=e,this.to=t,this.size=n,this.displaySize=i}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],r=t[n];if(i.from!=r.from||i.to!=r.to||i.size!=r.size)return!1}return!0}draw(e,t){return Xu.replace({widget:new Sf(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Sf extends Gu{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class kf{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Af,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ad.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Kd).some((e=>"function"!=typeof e&&"cm-lineWrapping"==e.class));this.heightOracle=new sf(t),this.stateDeco=e.facet(Xd).filter((e=>"function"!=typeof e)),this.heightMap=uf.empty().applyChanges(this.stateDeco,lc.empty,this.heightOracle.setDoc(e.doc),[new ip(0,0,0,e.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Xu.set(this.lineGaps.map((e=>e.draw(this,!1)))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let i=n?t.head:t.anchor;if(!e.some((({from:e,to:t})=>i>=e&&i<=t))){let{from:t,to:n}=this.lineBlockAt(i);e.push(new Cf(t,n))}}return this.viewports=e.sort(((e,t)=>e.from-t.from)),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Af:new Rf(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(Tf(e,this.scaler))}))}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(Xd).filter((e=>"function"!=typeof e));let i=e.changedRanges,r=ip.extendWithRanges(i,function(e,t,n){let i=new wf;return Eh.compare(e,t,n,i,0),i.changes}(n,this.stateDeco,e?e.changes:_c.empty(this.state.doc.length))),o=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);of(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||rf)&&(e.flags|=2),s?(this.scrollAnchorPos=e.changes.mapPos(s.from,-1),this.scrollAnchorHeight=s.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Bd)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),i=this.heightOracle,r=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?ad.RTL:ad.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),s=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=s.height;this.contentDOMHeight=s.height,this.mustMeasureContent=!1;let l=0,c=0;if(s.width&&s.height){let{scaleX:e,scaleY:n}=ou(t,s);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,l|=16,o=a=!0)}let h=(parseInt(n.paddingTop)||0)*this.scaleY,u=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==h&&this.paddingBottom==u||(this.paddingTop=h,this.paddingBottom=u,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=pu(e.scrollDOM);let p=(this.printing?xf:bf)(t,this.paddingTop),f=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}(e.dom))return 0;let v=s.width;if(this.contentDOMWidth==v&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(t)&&(o=!0),o||i.lineWrapping&&Math.abs(v-this.contentDOMWidth)>i.charWidth){let{lineHeight:n,charWidth:s,textHeight:a}=e.docView.measureTextSize();o=n>0&&i.refresh(r,n,s,a,v/s,t),o&&(e.docView.minWidth=0,l|=16)}f>0&&g>0?c=Math.max(f,g):f<0&&g<0&&(c=Math.min(f,g)),of();for(let n of this.viewports){let r=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(o?uf.empty().applyChanges(this.stateDeco,lc.empty,this.heightOracle,[new ip(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new af(n.from,r))}rf&&(l|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:s}=this,a=new Cf(i.lineAt(o-1e3*n,cf.ByHeight,r,0,0).from,i.lineAt(s+1e3*(1-n),cf.ByHeight,r,0,0).to);if(t){let{head:e}=t.range;if(e<a.from||e>a.to){let n,o=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=i.lineAt(e,cf.ByPos,r,0,0);n="center"==t.y?(s.top+s.bottom)/2-o/2:"start"==t.y||"nearest"==t.y&&e<a.from?s.top:s.bottom-o,a=new Cf(i.lineAt(n-500,cf.ByHeight,r,0,0).from,i.lineAt(n+o+500,cf.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),i=t.mapPos(e.to,1);return new Cf(this.heightMap.lineAt(n,cf.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,cf.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:i}=this.heightMap.lineAt(e,cf.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,cf.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:s}=this;return(0==e||i<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||r>=s+Math.max(10,Math.min(n,250)))&&i>o-2e3&&r<s+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let i of e)t.touchesRange(i.from,i.to)||n.push(new _f(t.mapPos(i.from),t.mapPos(i.to),i.size,i.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,i=n?1e4:2e3,r=i>>1,o=i<<1;if(this.defaultTextDirection!=ad.LTR&&!n)return[];let s=[],a=(i,o,l,c)=>{if(o-i<r)return;let h=this.state.selection.main,u=[h.from];h.empty||u.push(h.to);for(let e of u)if(e>i&&e<o)return a(i,e-10,l,c),void a(e+10,o,l,c);let d=function(e,t){for(let n of e)if(t(n))return n;return}(e,(e=>e.from>=l.from&&e.to<=l.to&&Math.abs(e.from-i)<r&&Math.abs(e.to-o)<r&&!u.some((t=>e.from<t&&e.to>t))));if(!d){if(o<l.to&&t&&n&&t.visibleRanges.some((e=>e.from<=o&&e.to>=o))){let e=t.moveToLineBoundary(Tc.cursor(o),!1,!0).head;e>i&&(o=e)}let e=this.gapSize(l,i,o,c);d=new _f(i,o,e,n||e<2e6?e:2e6)}s.push(d)},l=t=>{if(t.length<o||t.type!=Ku.Text)return;let r=function(e,t,n){let i=[],r=e,o=0;Eh.spans(n,e,t,{span(){},point(e,t){e>r&&(i.push({from:r,to:e}),o+=e-r),r=t}},20),r<t&&(i.push({from:r,to:t}),o+=t-r);return{total:o,ranges:i}}(t.from,t.to,this.stateDeco);if(r.total<o)return;let s,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,o=i/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let i=Mf(r,c),s=((this.visibleBottom-this.visibleTop)/2+o)/t.height;e=i-s,n=i+s}else e=(this.visibleTop-t.top-o)/t.height,n=(this.visibleBottom-t.top+o)/t.height;s=Ef(r,e),l=Ef(r,n)}else{let n=r.total*this.heightOracle.charWidth,o=i*this.heightOracle.charWidth,a=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=n.size-n.displaySize);let h,u,d=this.pixelViewport.left+a,p=this.pixelViewport.right+a;if(null!=c){let e=Mf(r,c),t=((p-d)/2+o)/n;h=e-t,u=e+t}else h=(d-o)/n,u=(p+o)/n;s=Ef(r,h),l=Ef(r,u)}s>t.from&&a(t.from,s,t,r),l<t.to&&a(l,t.to,t,r)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(l):l(e);return s}gapSize(e,t,n,i){let r=Mf(i,n)-Mf(i,t);return this.heightOracle.lineWrapping?e.height*r:i.total*this.heightOracle.charWidth*r}updateLineGaps(e){_f.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Xu.set(e.map((e=>e.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];Eh.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let i=0;if(n.length!=this.visibleRanges.length)i=12;else for(let t=0;t<n.length&&!(8&i);t++){let r=this.visibleRanges[t],o=n[t];r.from==o.from&&r.to==o.to||(i|=4,e&&e.mapPos(r.from,-1)==o.from&&e.mapPos(r.to,1)==o.to||(i|=8))}return this.visibleRanges=n,i}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find((t=>t.from<=e&&t.to>=e))||Tf(this.heightMap.lineAt(e,cf.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))||Tf(this.heightMap.lineAt(this.scaler.fromDOM(e),cf.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Tf(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Cf{constructor(e,t){this.from=e,this.to=t}}function Ef({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let i=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:r}=t[e],o=r-n;if(i<=o)return n+i;i-=o}}function Mf(e,t){let n=0;for(let{from:i,to:r}of e.ranges){if(t<=r){n+=t-i;break}n+=r-i}return n/e.total}const Af={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};class Rf{constructor(e,t,n){let i=0,r=0,o=0;this.viewports=n.map((({from:n,to:r})=>{let o=t.lineAt(n,cf.ByPos,e,0,0).top,s=t.lineAt(r,cf.ByPos,e,0,0).bottom;return i+=s-o,{from:n,to:r,top:o,bottom:s,domTop:0,domBottom:0}})),this.scale=(7e6-i)/(t.height-i);for(let e of this.viewports)e.domTop=o+(e.top-r)*this.scale,o=e.domBottom=e.domTop+(e.bottom-e.top),r=e.bottom}toDOM(e){for(let t=0,n=0,i=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return i+(e-n)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);n=r.bottom,i=r.domBottom}}fromDOM(e){for(let t=0,n=0,i=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return n+(e-i)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);n=r.bottom,i=r.domBottom}}eq(e){return e instanceof Rf&&(this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every(((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to)))}}function Tf(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),i=t.toDOM(e.bottom);return new lf(e.from,e.length,n,i-n,Array.isArray(e._content)?e._content.map((e=>Tf(e,t))):e._content)}const Df=Nc.define({combine:e=>e.join(" ")}),Of=Nc.define({combine:e=>e.indexOf(!0)>-1}),Nf=Vh.newName(),Pf=Vh.newName(),qf=Vh.newName(),Bf={"&light":"."+Pf,"&dark":"."+qf};function Lf(e,t,n){return new Vh(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,(t=>{if("&"==t)return e;if(!n||!n[t])throw new RangeError(`Unsupported selector: ${t}`);return n[t]})):e+" "+t})}const If=Lf("."+Nf,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&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-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"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Bf),jf={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ff=Pu.ie&&Pu.ie_version<=11;class Vf{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new su,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver((t=>{for(let e of t)this.queue.push(e);(Pu.ie&&Pu.ie_version<=11||Pu.ios&&e.composing)&&t.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),!window.EditContext||!1===e.constructor.EDIT_CONTEXT||Pu.chrome&&Pu.chrome_version<126||(this.editContext=new Hf(e),e.state.facet($d)&&(e.contentDOM.editContext=this.editContext.editContext)),Ff&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(e){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some(((t,n)=>t!=e[n])))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,i=this.selectionRange;if(n.state.facet($d)?n.root.activeElement!=this.dom:!Yh(this.dom,i))return;let r=i.anchorNode&&n.docView.nearest(i.anchorNode);r&&r.ignoreEvent(e)?t||(this.selectionChanged=!1):(Pu.ie&&Pu.ie_version<=11||Pu.android&&Pu.chrome)&&!n.state.selection.main.empty&&i.focusNode&&Qh(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Kh(e.root);if(!t)return!1;let n=Pu.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return zf(e,n)}let n=null;function i(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",i,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",i,!0),n?zf(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let i=Yh(this.dom,n);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,i=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=i)return!1;for(i=Math.min(i,nu(n));;)if(i){if(1!=n.nodeType)return!1;let e=n.childNodes[i-1];"false"==e.contentEditable?i--:(n=e,i=nu(n))}else{if(n==e)return!0;i=Zh(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(1==n.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,jf),Ff&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ff&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;if(e){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&uu(this.dom,e.key,e.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(n=this.delayedAndroidKey)||void 0===n?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,i=!1;for(let r of e){let e=this.readMutation(r);e&&(e.typeOver&&(i=!0),-1==t?({from:t,to:n}=e):(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:i}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),i=this.selectionChanged&&Yh(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new Cp(this.view,e,t,n);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,i=Ep(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty("attributes"==e.type),"attributes"==e.type&&(t.flags|=4),"childList"==e.type){let n=$f(t,e.previousSibling||e.target.previousSibling,-1),i=$f(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet($d)!=e.state.facet($d)&&(e.view.contentDOM.editContext=e.state.facet($d)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(n=this.resizeScroll)||void 0===n||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function $f(e,t,n){for(;t;){let i=yu.get(t);if(i&&i.parent==e)return i;let r=t.parentNode;t=r!=e.dom?r:n>0?t.nextSibling:t.previousSibling}return null}function zf(e,t){let n=t.startContainer,i=t.startOffset,r=t.endContainer,o=t.endOffset,s=e.docView.domAtPos(e.state.selection.main.anchor);return Qh(s.node,s.offset,r,o)&&([n,i,r,o]=[r,o,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:o}}class Hf{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=t=>{let n=e.state.selection.main,{anchor:i,head:r}=n,o=this.toEditorPos(t.updateRangeStart),s=this.toEditorPos(t.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:t.updateRangeStart,editorBase:o,drifted:!1});let a={from:o,to:s,insert:lc.of(t.text.split("\n"))};if(a.from==this.from&&i<this.from?a.from=i:a.to==this.to&&i>this.to&&(a.to=i),a.from!=a.to||a.insert.length){if((Pu.mac||Pu.android)&&a.from==r-1&&/^\. ?$/.test(t.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(a={from:o,to:s,insert:lc.of([t.text.replace("."," ")])}),this.pendingContextChange=a,!e.state.readOnly){let n=this.to-this.from+(a.to-a.from+a.insert.length);Mp(e,a,Tc.single(this.toEditorPos(t.selectionStart,n),this.toEditorPos(t.selectionEnd,n)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state))}else{let i=Tc.single(this.toEditorPos(t.selectionStart),this.toEditorPos(t.selectionEnd));i.main.eq(n)||e.dispatch({selection:i,userEvent:"select"})}},this.handlers.characterboundsupdate=n=>{let i=[],r=null;for(let t=this.toEditorPos(n.rangeStart),o=this.toEditorPos(n.rangeEnd);t<o;t++){let n=e.coordsForChar(t);r=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||r||new DOMRect,i.push(r)}t.updateCharacterBounds(n.rangeStart,i)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,i=e.underlineThickness;if("None"!=t&&"None"!=i){let r=this.toEditorPos(e.rangeStart),o=this.toEditorPos(e.rangeEnd);if(r<o){let e=`text-decoration: underline ${"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${"Thin"==i?1:2}px`;n.push(Xu.mark({attributes:{style:e}}).range(r,o))}}}e.dispatch({effects:Fd.of(Xu.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=Kh(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,i=this.pendingContextChange;return e.changes.iterChanges(((r,o,s,a,l)=>{if(n)return;let c=l.length-(o-r);if(i&&o>=i.to){if(i.from==r&&i.to==o&&i.insert.eq(l))return i=this.pendingContextChange=null,t+=c,void(this.to+=c);i=null,this.revertPending(e.state)}if(r+=t,(o+=t)<=this.from)this.from+=c,this.to+=c;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+l.length>3e4)return void(n=!0);this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),l.toString()),this.to+=c}t+=c})),i&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange;this.composing&&(this.composing.drifted||e.transactions.some((e=>!e.isUserEvent("input.type")&&e.changes.touchesRange(this.from,this.to))))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),i=this.toContextPos(t.head);this.editContext.selectionStart==n&&this.editContext.selectionEnd==i||this.editContext.updateSelection(n,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Wf{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.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(e=>e.forEach((e=>n(e,this))))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new kf(e.state||xh.create(e)),e.scrollTo&&e.scrollTo.is(jd)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Hd).map((e=>new Ud(e)));for(let e of this.plugins)e.update(this);this.observer=new Vf(this),this.inputState=new Ap(this),this.inputState.ensureHandlers(this.plugins),this.docView=new op(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then((()=>this.requestMeasure()))}dispatch(...e){let t=1==e.length&&e[0]instanceof hh?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,n=!1,i=!1,r=this.state;for(let t of e){if(t.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=t.state}if(this.destroyed)return void(this.viewState.state=r);let o=this.hasFocus,s=0,a=null;e.some((e=>e.annotation(Qp)))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Zp(r,o),a||(s=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(xh.phrases)!=this.state.facet(xh.phrases))return this.setState(r);t=rp.create(this,r,e),t.flags|=s;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(h&&(h=h.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;h=new Id(e.empty?e:Tc.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(jd)&&(h=e.value.clip(this.state))}this.viewState.update(t,h),this.bidiCache=Kf.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(np)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some((e=>e.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(t.startState.facet(Df)!=t.state.facet(Df)&&(this.viewState.mustMeasureContent=!0),(n||i||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(Td))try{e(t)}catch(e){Vd(this.state,e,"update listener")}(a||c)&&Promise.resolve().then((()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Ep(this,c)&&l.force&&uu(this.contentDOM,l.key,l.keyCode)}))}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new kf(e),this.plugins=e.facet(Hd).map((e=>new Ud(e))),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new op(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(Hd),n=e.state.facet(Hd);if(t!=n){let i=[];for(let r of n){let n=t.indexOf(r);if(n<0)i.push(new Ud(r));else{let t=this.plugins[n];t.mustUpdate=e,i.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){Vd(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,i=n.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(o<0)if(pu(n))r=-1,o=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(i);r=e.from,o=e.top}this.updateState=1;let s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let a=[];4&s||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map((e=>{try{return e.read(this)}catch(e){return Vd(this.state,e),Gf}})),c=rp.create(this,this.state,[]),h=!1;c.flags|=s,t?t.flags|=s:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),h=this.docView.update(c),h&&this.docViewUpdate());for(let e=0;e<a.length;e++)if(l[e]!=Gf)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){Vd(this.state,e)}if(h&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}{let e=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o;if(e>1||e<-1){i+=e,n.scrollTop=i/this.scaleY,o=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(Td))e(t)}get themeClasses(){return Nf+" "+(this.state.facet(Of)?qf:Pf)+" "+this.state.facet(Df)}updateAttrs(){let e=Xf(this,Gd,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet($d)?"true":"false",class:"cm-content",style:`${Pu.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Xf(this,Kd,t);let n=this.observer.ignore((()=>{let n=Wu(this.contentDOM,this.contentAttrs,t),i=Wu(this.dom,this.editorAttrs,e);return n||i}));return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)if(e.is(Wf.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(np);let e=this.state.facet(Wf.cspNonce);Vh.mount(this.root,this.styleModules.concat(If).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure()))),e){if(this.measureRequests.indexOf(e)>-1)return;if(null!=e.key)for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key)return void(this.measureRequests[t]=e);this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find((t=>t.spec==e))||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return bp(this,e,yp(this,e,t,n))}moveByGroup(e,t){return bp(this,e,yp(this,e,t,(t=>function(e,t,n){let i=e.state.charCategorizer(t),r=i(n);return e=>{let t=i(e);return r==vh.Space&&(r=t),r==t}}(this,e.head,t))))}visualLineSide(e,t){let n=this.bidiSpans(e),i=this.textDirectionAt(e.from),r=n[t?n.length-1:0];return Tc.cursor(r.side(t,i)+e.from,r.forward(!t,i)?1:-1)}moveToLineBoundary(e,t,n=!0){return vp(this,e,t,n)}moveVertically(e,t,n){return bp(this,e,function(e,t,n,i){let r=t.head,o=n?1:-1;if(r==(n?e.state.doc.length:0))return Tc.cursor(r,t.assoc);let s,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(r,t.assoc||-1),h=e.documentTop;if(c)null==a&&(a=c.left-l.left),s=o<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(r);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(r-t.from))),s=(o<0?t.top:t.bottom)+h}let u=l.left+a,d=null!=i?i:e.viewState.heightOracle.textHeight>>1;for(let t=0;;t+=10){let n=s+(d+t)*o,i=gp(e,{x:u,y:n},!1,o);if(n<l.top||n>l.bottom||(o<0?i<r:i>r)){let t=e.docView.coordsForChar(i),r=!t||n<t.top?-1:1;return Tc.cursor(i,r,void 0,a)}}}(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),gp(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let i=this.state.doc.lineAt(e),r=this.bidiSpans(i);return iu(n,r[vd.find(r,e-i.from,-1,t)].dir==ad.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(qd)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Uf)return _d(e.length);let t,n=this.textDirectionAt(e.from);for(let i of this.bidiCache)if(i.from==e.from&&i.dir==n&&(i.fresh||yd(i.isolates,t=Zd(this,e))))return i.order;t||(t=Zd(this,e));let i=function(e,t,n){if(!e)return[new vd(0,0,t==cd?1:0)];if(t==ld&&!n.length&&!md.test(e))return _d(e.length);if(n.length)for(;e.length>wd.length;)wd[wd.length]=256;let i=[],r=t==ld?0:1;return xd(e,r,r,n,0,e.length,i),i}(e.text,n,t);return this.bidiCache.push(new Kf(e.from,e.to,n,t,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Pu.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{cu(this.contentDOM),this.docView.updateSelection()}))}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return jd.of(new Id("number"==typeof e?Tc.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return jd.of(new Id(Tc.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Wd.define((()=>({})),{eventHandlers:e})}static domEventObservers(e){return Wd.define((()=>({})),{eventObservers:e})}static theme(e,t){let n=Vh.newName(),i=[Df.of(n),np.of(Lf(`.${n}`,e))];return t&&t.dark&&i.push(Of.of(!0)),i}static baseTheme(e){return Uc.lowest(np.of(Lf("."+Nf,e,Bf)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),i=n&&yu.get(n)||yu.get(e);return(null===(t=null==i?void 0:i.rootView)||void 0===t?void 0:t.view)||null}}Wf.styleModule=np,Wf.inputHandler=Dd,Wf.clipboardInputFilter=Nd,Wf.clipboardOutputFilter=Pd,Wf.scrollHandler=Ld,Wf.focusChangeEffect=Od,Wf.perLineTextDirection=qd,Wf.exceptionSink=Rd,Wf.updateListener=Td,Wf.editable=$d,Wf.mouseSelectionStyle=Ad,Wf.dragMovesSelection=Md,Wf.clickAddsSelectionRange=Ed,Wf.decorations=Xd,Wf.outerDecorations=Yd,Wf.atomicRanges=Jd,Wf.bidiIsolatedRanges=Qd,Wf.scrollMargins=ep,Wf.darkTheme=Of,Wf.cspNonce=Nc.define({combine:e=>e.length?e[0]:""}),Wf.contentAttributes=Kd,Wf.editorAttributes=Gd,Wf.lineWrapping=Wf.contentAttributes.of({class:"cm-lineWrapping"}),Wf.announce=ch.define();const Uf=4096,Gf={};class Kf{constructor(e,t,n,i,r,o){this.from=e,this.to=t,this.dir=n,this.isolates=i,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some((e=>e.fresh)))return e;let n=[],i=e.length?e[e.length-1].dir:ad.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let o=e[r];o.dir!=i||t.touchesRange(o.from,o.to)||n.push(new Kf(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function Xf(e,t,n){for(let i=e.state.facet(t),r=i.length-1;r>=0;r--){let t=i[r],o="function"==typeof t?t(e):t;o&&$u(o,n)}return n}const Yf={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};!(Pu.ios&&Pu.webkit&&Pu.webkit_version<534)&&(Yf[".cm-line"].caretColor=Yf[".cm-content"].caretColor="transparent !important");class Jf extends _h{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Jf.prototype.elementClass="",Jf.prototype.toDOM=void 0,Jf.prototype.mapMode=bc.TrackBefore,Jf.prototype.startSide=Jf.prototype.endSide=-1,Jf.prototype.point=!0;const Qf=1024;let Zf=0;class eg{constructor(e,t){this.from=e,this.to=t}}class tg{constructor(e={}){this.id=Zf++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=rg.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}tg.closedBy=new tg({deserialize:e=>e.split(" ")}),tg.openedBy=new tg({deserialize:e=>e.split(" ")}),tg.group=new tg({deserialize:e=>e.split(" ")}),tg.isolate=new tg({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),tg.contextHash=new tg({perNode:!0}),tg.lookAhead=new tg({perNode:!0}),tg.mounted=new tg({perNode:!0});class ng{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[tg.mounted.id]}}const ig=Object.create(null);class rg{constructor(e,t,n,i=0){this.name=e,this.props=t,this.id=n,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):ig,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),i=new rg(e.name||"",t,e.id,n);if(e.props)for(let n of e.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}return i}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(tg.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let i of n.split(" "))t[i]=e[n];return e=>{for(let n=e.prop(tg.group),i=-1;i<(n?n.length:0);i++){let r=t[i<0?e.name:n[i]];if(r)return r}}}}rg.none=new rg("",Object.create(null),0,8);const og=new WeakMap,sg=new WeakMap;var ag;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(ag||(ag={}));class lg{constructor(e,t,n,i,r){if(this.type=e,this.children=t,this.positions=n,this.length=i,this.props=null,r&&r.length){this.props=Object.create(null);for(let[e,t]of r)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=ng.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new xg(this.topNode,e)}cursorAt(e,t=0,n=0){let i=og.get(this)||this.topNode,r=new xg(i);return r.moveTo(e,t),og.set(this,r._tree),r}get topNode(){return new fg(this,0,0,null)}resolve(e,t=0){let n=dg(og.get(this)||this.topNode,e,t,!1);return og.set(this,n),n}resolveInner(e,t=0){let n=dg(sg.get(this)||this.topNode,e,t,!0);return sg.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let i=e.resolveInner(t,n),r=null;for(let e=i instanceof fg?i:i.context.parent;e;e=e.parent)if(e.index<0){let o=e.parent;(r||(r=[i])).push(o.resolve(t,n)),e=o}else{let o=ng.get(e.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let s=new fg(o.tree,o.overlay[0].from+e.from,-1,e);(r||(r=[i])).push(dg(s,t,n,!1))}}return r?wg(r):i}(this,e,t)}iterate(e){let{enter:t,leave:n,from:i=0,to:r=this.length}=e,o=e.mode||0,s=(o&ag.IncludeAnonymous)>0;for(let e=this.cursor(o|ag.IncludeAnonymous);;){let o=!1;if(e.from<=r&&e.to>=i&&(!s&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;o=!0}for(;o&&n&&(s||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;o=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Cg(rg.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,n)=>new lg(this.type,e,t,n,this.propValues)),e.makeTree||((e,t,n)=>new lg(rg.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:i,maxBufferLength:r=Qf,reused:o=[],minRepeatType:s=i.types.length}=e,a=Array.isArray(n)?new cg(n,n.length):n,l=i.types,c=0,h=0;function u(e,t,n,y,w,b){let{id:x,start:_,end:S,size:k}=a,C=h,E=c;for(;k<0;){if(a.next(),-1==k){let t=o[x];return n.push(t),void y.push(_-e)}if(-3==k)return void(c=x);if(-4==k)return void(h=x);throw new RangeError(`Unrecognized record size: ${k}`)}let M,A,R=l[x],T=_-e;if(S-_<=r&&(A=m(a.pos-t,w))){let t=new Uint16Array(A.size-A.skip),n=a.pos-A.size,r=t.length;for(;a.pos>n;)r=v(A.start,t,r);M=new hg(t,S-A.start,i),T=A.start-e}else{let e=a.pos-k;a.next();let t=[],n=[],i=x>=s?x:-1,o=0,l=S;for(;a.pos>e;)i>=0&&a.id==i&&a.size>=0?(a.end<=l-r&&(f(t,n,_,o,a.end,l,i,C,E),o=t.length,l=a.end),a.next()):b>2500?d(_,e,t,n):u(_,e,t,n,i,b+1);if(i>=0&&o>0&&o<t.length&&f(t,n,_,o,_,l,i,C,E),t.reverse(),n.reverse(),i>-1&&o>0){let e=p(R,E);M=Cg(R,t,n,0,t.length,0,S-_,e,e)}else M=g(R,t,n,S-_,C-S,E)}n.push(M),y.push(T)}function d(e,t,n,o){let s=[],l=0,c=-1;for(;a.pos>t;){let{id:e,start:t,end:n,size:i}=a;if(i>4)a.next();else{if(c>-1&&t<c)break;c<0&&(c=n-r),s.push(e,t,n),l++,a.next()}}if(l){let t=new Uint16Array(4*l),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;n.push(new hg(t,s[2]-r,i)),o.push(r-e)}}function p(e,t){return(n,i,r)=>{let o,s,a=0,l=n.length-1;if(l>=0&&(o=n[l])instanceof lg){if(!l&&o.type==e&&o.length==r)return o;(s=o.prop(tg.lookAhead))&&(a=i[l]+o.length+s)}return g(e,n,i,r,a,t)}}function f(e,t,n,r,o,s,a,l,c){let h=[],u=[];for(;e.length>r;)h.push(e.pop()),u.push(t.pop()+n-o);e.push(g(i.types[a],h,u,s-o,l-s,c)),t.push(o-n)}function g(e,t,n,i,r,o,s){if(o){let e=[tg.contextHash,o];s=s?[e].concat(s):[e]}if(r>25){let e=[tg.lookAhead,r];s=s?[e].concat(s):[e]}return new lg(e,t,n,i,s)}function m(e,t){let n=a.fork(),i=0,o=0,l=0,c=n.end-r,h={size:0,start:0,skip:0};e:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){h.size=i,h.start=o,h.skip=l,l+=4,i+=4,n.next();continue}let a=n.pos-e;if(e<0||a<r||n.start<c)break;let u=n.id>=s?4:0,d=n.start;for(n.next();n.pos>a;){if(n.size<0){if(-3!=n.size)break e;u+=4}else n.id>=s&&(u+=4);n.next()}o=d,i+=e,l+=u}return(t<0||i==e)&&(h.size=i,h.start=o,h.skip=l),h.size>4?h:void 0}function v(e,t,n){let{id:i,start:r,end:o,size:l}=a;if(a.next(),l>=0&&i<s){let s=n;if(l>4){let i=a.pos-(l-4);for(;a.pos>i;)n=v(e,t,n)}t[--n]=s,t[--n]=o-e,t[--n]=r-e,t[--n]=i}else-3==l?c=i:-4==l&&(h=i);return n}let y=[],w=[];for(;a.pos>0;)u(e.start||0,e.bufferStart||0,y,w,-1,0);let b=null!==(t=e.length)&&void 0!==t?t:y.length?w[0]+y[0].length:0;return new lg(l[e.topID],y.reverse(),w.reverse(),b)}(e)}}lg.empty=new lg(rg.none,[],[],0);class cg{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 cg(this.buffer,this.index)}}class hg{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return rg.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],i=this.set.types[t],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),n==(e+=4))return r;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,n,i,r){let{buffer:o}=this,s=-1;for(let a=e;a!=t&&!(ug(r,i,o[a+1],o[a+2])&&(s=a,n>0));a=o[a+3]);return s}slice(e,t,n){let i=this.buffer,r=new Uint16Array(t-e),o=0;for(let s=e,a=0;s<t;){r[a++]=i[s++],r[a++]=i[s++]-n;let t=r[a++]=i[s++]-n;r[a++]=i[s++]-e,o=Math.max(o,t)}return new hg(r,o,this.set)}}function ug(e,t,n,i){switch(e){case-2:return n<t;case-1:return i>=t&&n<t;case 0:return n<t&&i>t;case 1:return n<=t&&i>t;case 2:return i>t;case 4:return!0}}function dg(e,t,n,i){for(var r;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!i&&e instanceof fg&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=i?0:ag.IgnoreOverlays;if(i)for(let i=e,s=i.parent;s;i=s,s=i.parent)i instanceof fg&&i.index<0&&(null===(r=s.enter(t,n,o))||void 0===r?void 0:r.from)!=i.from&&(e=s);for(;;){let i=e.enter(t,n,o);if(!i)return e;e=i}}class pg{cursor(e=0){return new xg(this,e)}getChild(e,t=null,n=null){let i=gg(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return gg(this,e,t,n)}resolve(e,t=0){return dg(this,e,t,!1)}resolveInner(e,t=0){return dg(this,e,t,!0)}matchContext(e){return mg(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class fg extends pg{constructor(e,t,n,i){super(),this._tree=e,this.from=t,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,i,r=0){for(let o=this;;){for(let{children:s,positions:a}=o._tree,l=t>0?s.length:-1;e!=l;e+=t){let l=s[e],c=a[e]+o.from;if(ug(i,n,c,c+l.length))if(l instanceof hg){if(r&ag.ExcludeBuffers)continue;let s=l.findChild(0,l.buffer.length,t,n-c,i);if(s>-1)return new yg(new vg(o,l,e,c),null,s)}else if(r&ag.IncludeAnonymous||!l.type.isAnonymous||_g(l)){let s;if(!(r&ag.IgnoreMounts)&&(s=ng.get(l))&&!s.overlay)return new fg(s.tree,c,e,o);let a=new fg(l,c,e,o);return r&ag.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?l.children.length-1:0,t,n,i)}}if(r&ag.IncludeAnonymous||!o.type.isAnonymous)return null;if(e=o.index>=0?o.index+t:t<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let i;if(!(n&ag.IgnoreOverlays)&&(i=ng.get(this._tree))&&i.overlay){let n=e-this.from;for(let{from:e,to:r}of i.overlay)if((t>0?e<=n:e<n)&&(t<0?r>=n:r>n))return new fg(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function gg(e,t,n,i){let r=e.cursor(),o=[];if(!r.firstChild())return o;if(null!=n)for(let e=!1;!e;)if(e=r.type.is(n),!r.nextSibling())return o;for(;;){if(null!=i&&r.type.is(i))return o;if(r.type.is(t)&&o.push(r.node),!r.nextSibling())return null==i?o:[]}}function mg(e,t,n=t.length-1){for(let i=e;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[n]&&t[n]!=i.name)return!1;n--}}return!0}class vg{constructor(e,t,n,i){this.parent=e,this.buffer=t,this.index=n,this.start=i}}class yg extends pg{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,n);return r<0?null:new yg(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&ag.ExcludeBuffers)return null;let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new yg(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new yg(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 yg(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,i=this.index+4,r=n.buffer[this.index+3];if(r>i){let o=n.buffer[this.index+1];e.push(n.slice(i,r,o)),t.push(0)}return new lg(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function wg(e){if(!e.length)return null;let t=0,n=e[0];for(let i=1;i<e.length;i++){let r=e[i];(r.from>n.from||r.to<n.to)&&(n=r,t=i)}let i=n instanceof fg&&n.index<0?null:n.parent,r=e.slice();return i?r[t]=i:r.splice(t,1),new bg(r,n)}class bg{constructor(e,t){this.heads=e,this.node=t}get next(){return wg(this.heads)}}class xg{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof fg)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return!!e&&(e instanceof fg?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:i}=this.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,n);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&ag.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ag.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ag.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(i.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=i)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let i=t+e,r=e<0?-1:n._tree.children.length;i!=r;i+=e){let e=n._tree.children[i];if(this.mode&ag.IncludeAnonymous||e instanceof hg||!e.type.isAnonymous||_g(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let i=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;t=o,n=r+1;break e}i=this.stack[--r]}for(let e=n;e<this.stack.length;e++)t=new yg(this.buffer,t,this.stack[e]);return this.bufferNode=new yg(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let i=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&t&&t(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(e){if(!this.buffer)return mg(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let i=e.length-1,r=this.stack.length-1;i>=0;r--){if(r<0)return mg(this._tree,e,i);let o=n[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function _g(e){return e.children.some((e=>e instanceof hg||!e.type.isAnonymous||_g(e)))}const Sg=new WeakMap;function kg(e,t){if(!e.isAnonymous||t instanceof hg||t.type!=e)return 1;let n=Sg.get(t);if(null==n){n=1;for(let i of t.children){if(i.type!=e||!(i instanceof lg)){n=1;break}n+=kg(e,i)}Sg.set(t,n)}return n}function Cg(e,t,n,i,r,o,s,a,l){let c=0;for(let n=i;n<r;n++)c+=kg(e,t[n]);let h=Math.ceil(1.5*c/8),u=[],d=[];return function t(n,i,r,s,a){for(let c=r;c<s;){let r=c,p=i[c],f=kg(e,n[c]);for(c++;c<s;c++){let t=kg(e,n[c]);if(f+t>=h)break;f+=t}if(c==r+1){if(f>h){let e=n[r];t(e.children,e.positions,0,e.children.length,i[r]+a);continue}u.push(n[r])}else{let t=i[c-1]+n[c-1].length-p;u.push(Cg(e,n,i,r,c,p,t,null,l))}d.push(p+a-o)}}(t,n,i,r,0),(a||l)(u,d,s)}class Eg{constructor(e,t,n,i,r=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=i,this.open=(r?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let i=[new Eg(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&i.push(n);return i}static applyChanges(e,t,n=128){if(!t.length)return e;let i=[],r=1,o=e.length?e[0]:null;for(let s=0,a=0,l=0;;s++){let c=s<t.length?t[s]:null,h=c?c.fromA:1e9;if(h-a>=n)for(;o&&o.from<h;){let t=o;if(a>=t.from||h<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,h)-l;t=e>=n?null:new Eg(e,n,t.tree,t.offset+l,s>0,!!c)}if(t&&i.push(t),o.to>h)break;o=r<e.length?e[r++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return i}}class Mg{startParse(e,t,n){return"string"==typeof e&&(e=new Ag(e)),n=n?n.length?n.map((e=>new eg(e.from,e.to))):[new eg(0,0)]:[new eg(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let i=this.startParse(e,t,n);for(;;){let e=i.advance();if(e)return e}}}class Ag{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new tg({perNode:!0});let Rg=0;class Tg{constructor(e,t,n,i){this.name=e,this.set=t,this.base=n,this.modified=i,this.id=Rg++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n="string"==typeof e?e:"?";if(e instanceof Tg&&(t=e),null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let i=new Tg(n,[],null,[]);if(i.set.push(i),t)for(let e of t.set)i.set.push(e);return i}static defineModifier(e){let t=new Og(e);return e=>e.modified.indexOf(t)>-1?e:Og.get(e.base||e,e.modified.concat(t).sort(((e,t)=>e.id-t.id)))}}let Dg=0;class Og{constructor(e){this.name=e,this.instances=[],this.id=Dg++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find((n=>{return n.base==e&&(i=t,r=n.modified,i.length==r.length&&i.every(((e,t)=>e==r[t])));var i,r}));if(n)return n;let i=[],r=new Tg(e.name,i,e,t);for(let e of t)e.instances.push(r);let o=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let i=0,r=t.length;i<r;i++)t.push(t[i].concat(e[n]));return t.sort(((e,t)=>t.length-e.length))}(t);for(let t of e.set)if(!t.modified.length)for(let e of o)i.push(Og.get(t,e));return r}}function Ng(e){let t=Object.create(null);for(let n in e){let i=e[n];Array.isArray(i)||(i=[i]);for(let e of n.split(" "))if(e){let n=[],r=2,o=e;for(let t=0;;){if("..."==o&&t>0&&t+3==e.length){r=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!i)throw new RangeError("Invalid path: "+e);if(n.push("*"==i[0]?"":'"'==i[0][0]?JSON.parse(i[0]):i[0]),t+=i[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){r=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);o=e.slice(t)}let s=n.length-1,a=n[s];if(!a)throw new RangeError("Invalid path: "+e);let l=new qg(i,r,s>0?n.slice(0,s):null);t[a]=l.sort(t[a])}}return Pg.add(t)}const Pg=new tg;class qg{constructor(e,t,n,i){this.tags=e,this.mode=t,this.context=n,this.next=i}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function Bg(e,t){let n=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)n[e.id]=t.class;else n[t.tag.id]=t.class;let{scope:i,all:r=null}=t||{};return{style:e=>{let t=r;for(let i of e)for(let e of i.set){let i=n[e.id];if(i){t=t?t+" "+i:i;break}}return t},scope:i}}function Lg(e,t,n,i=0,r=e.length){let o=new Ig(i,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),i,r,"",o.highlighters),o.flush(r)}qg.empty=new qg([],2,null);class Ig{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,i,r){let{type:o,from:s,to:a}=e;if(s>=n||a<=t)return;o.isTop&&(r=this.highlighters.filter((e=>!e.scope||e.scope(o))));let l=i,c=function(e){let t=e.type.prop(Pg);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||qg.empty,h=function(e,t){let n=null;for(let i of e){let e=i.style(t);e&&(n=n?n+" "+e:e)}return n}(r,c.tags);if(h&&(l&&(l+=" "),l+=h,1==c.mode&&(i+=(i?" ":"")+h)),this.startSpan(Math.max(t,s),l),c.opaque)return;let u=e.tree&&e.tree.prop(tg.mounted);if(u&&u.overlay){let o=e.node.enter(u.overlay[0].from+s,1),c=this.highlighters.filter((e=>!e.scope||e.scope(u.tree.type))),h=e.firstChild();for(let d=0,p=s;;d++){let f=d<u.overlay.length?u.overlay[d]:null,g=f?f.from+s:a,m=Math.max(t,p),v=Math.min(n,g);if(m<v&&h)for(;e.from<v&&(this.highlightRange(e,m,v,i,r),this.startSpan(Math.min(v,e.to),l),!(e.to>=g)&&e.nextSibling()););if(!f||g>n)break;p=f.to+s,p>t&&(this.highlightRange(o.cursor(),Math.max(t,f.from+s),Math.min(n,p),"",c),this.startSpan(Math.min(n,p),l))}h&&e.parent()}else if(e.firstChild()){u&&(i="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,i,r),this.startSpan(Math.min(n,e.to),l)}}while(e.nextSibling());e.parent()}}}const jg=Tg.define,Fg=jg(),Vg=jg(),$g=jg(Vg),zg=jg(Vg),Hg=jg(),Wg=jg(Hg),Ug=jg(Hg),Gg=jg(),Kg=jg(Gg),Xg=jg(),Yg=jg(),Jg=jg(),Qg=jg(Jg),Zg=jg(),em={comment:Fg,lineComment:jg(Fg),blockComment:jg(Fg),docComment:jg(Fg),name:Vg,variableName:jg(Vg),typeName:$g,tagName:jg($g),propertyName:zg,attributeName:jg(zg),className:jg(Vg),labelName:jg(Vg),namespace:jg(Vg),macroName:jg(Vg),literal:Hg,string:Wg,docString:jg(Wg),character:jg(Wg),attributeValue:jg(Wg),number:Ug,integer:jg(Ug),float:jg(Ug),bool:jg(Hg),regexp:jg(Hg),escape:jg(Hg),color:jg(Hg),url:jg(Hg),keyword:Xg,self:jg(Xg),null:jg(Xg),atom:jg(Xg),unit:jg(Xg),modifier:jg(Xg),operatorKeyword:jg(Xg),controlKeyword:jg(Xg),definitionKeyword:jg(Xg),moduleKeyword:jg(Xg),operator:Yg,derefOperator:jg(Yg),arithmeticOperator:jg(Yg),logicOperator:jg(Yg),bitwiseOperator:jg(Yg),compareOperator:jg(Yg),updateOperator:jg(Yg),definitionOperator:jg(Yg),typeOperator:jg(Yg),controlOperator:jg(Yg),punctuation:Jg,separator:jg(Jg),bracket:Qg,angleBracket:jg(Qg),squareBracket:jg(Qg),paren:jg(Qg),brace:jg(Qg),content:Gg,heading:Kg,heading1:jg(Kg),heading2:jg(Kg),heading3:jg(Kg),heading4:jg(Kg),heading5:jg(Kg),heading6:jg(Kg),contentSeparator:jg(Gg),list:jg(Gg),quote:jg(Gg),emphasis:jg(Gg),strong:jg(Gg),link:jg(Gg),monospace:jg(Gg),strikethrough:jg(Gg),inserted:jg(),deleted:jg(),changed:jg(),invalid:jg(),meta:Zg,documentMeta:jg(Zg),annotation:jg(Zg),processingInstruction:jg(Zg),definition:Tg.defineModifier("definition"),constant:Tg.defineModifier("constant"),function:Tg.defineModifier("function"),standard:Tg.defineModifier("standard"),local:Tg.defineModifier("local"),special:Tg.defineModifier("special")};for(let e in em){let t=em[e];t instanceof Tg&&(t.name=e)}var tm;Bg([{tag:em.link,class:"tok-link"},{tag:em.heading,class:"tok-heading"},{tag:em.emphasis,class:"tok-emphasis"},{tag:em.strong,class:"tok-strong"},{tag:em.keyword,class:"tok-keyword"},{tag:em.atom,class:"tok-atom"},{tag:em.bool,class:"tok-bool"},{tag:em.url,class:"tok-url"},{tag:em.labelName,class:"tok-labelName"},{tag:em.inserted,class:"tok-inserted"},{tag:em.deleted,class:"tok-deleted"},{tag:em.literal,class:"tok-literal"},{tag:em.string,class:"tok-string"},{tag:em.number,class:"tok-number"},{tag:[em.regexp,em.escape,em.special(em.string)],class:"tok-string2"},{tag:em.variableName,class:"tok-variableName"},{tag:em.local(em.variableName),class:"tok-variableName tok-local"},{tag:em.definition(em.variableName),class:"tok-variableName tok-definition"},{tag:em.special(em.variableName),class:"tok-variableName2"},{tag:em.definition(em.propertyName),class:"tok-propertyName tok-definition"},{tag:em.typeName,class:"tok-typeName"},{tag:em.namespace,class:"tok-namespace"},{tag:em.className,class:"tok-className"},{tag:em.macroName,class:"tok-macroName"},{tag:em.propertyName,class:"tok-propertyName"},{tag:em.operator,class:"tok-operator"},{tag:em.comment,class:"tok-comment"},{tag:em.meta,class:"tok-meta"},{tag:em.invalid,class:"tok-invalid"},{tag:em.punctuation,class:"tok-punctuation"}]);const nm=new tg,im=new tg;class rm{constructor(e,t,n=[],i=""){this.data=e,this.name=i,xh.prototype.hasOwnProperty("tree")||Object.defineProperty(xh.prototype,"tree",{get(){return sm(this)}}),this.parser=t,this.extension=[gm.of(this),xh.languageData.of(((e,t,n)=>{let i=om(e,t,n),r=i.type.prop(nm);if(!r)return[];let o=e.facet(r),s=i.type.prop(im);if(s){let r=i.resolve(t-i.from,n);for(let t of s)if(t.test(r,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(o)}}return o}))].concat(n)}isActiveAt(e,t,n=-1){return om(e,t,n).type.prop(nm)==this.data}findRegions(e){let t=e.facet(gm);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(e,t)=>{if(e.prop(nm)==this.data)return void n.push({from:t,to:t+e.length});let r=e.prop(tg.mounted);if(r){if(r.tree.prop(nm)==this.data){if(r.overlay)for(let e of r.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(r.overlay){let e=n.length;if(i(r.tree,r.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let r=e.children[n];r instanceof lg&&i(r,e.positions[n]+t)}};return i(sm(e),0),n}get allowsNesting(){return!0}}function om(e,t,n){let i=e.facet(gm),r=sm(e).topNode;if(!i||i.allowsNesting)for(let e=r;e;e=e.enter(t,n,ag.ExcludeBuffers))e.type.isTop&&(r=e);return r}function sm(e){let t=e.field(rm.state,!1);return t?t.tree:lg.empty}rm.setState=ch.define();class am{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let lm=null;class cm{constructor(e,t,n=[],i,r,o,s,a){this.parser=e,this.state=t,this.fragments=n,this.tree=i,this.treeLen=r,this.viewport=o,this.skipped=s,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new cm(e,t,[],lg.empty,0,n,[],null)}startParse(){return this.parser.startParse(new am(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=lg.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(Eg.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}}))}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext((()=>{for(;!(t=this.parse.advance()););})),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Eg.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=lm;lm=this;try{return e()}finally{lm=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=hm(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:r,viewport:o,skipped:s}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges(((e,n,i,r)=>t.push({fromA:e,toA:n,fromB:i,toB:r}))),n=Eg.applyChanges(n,t),i=lg.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){s=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);n<i&&s.push({from:n,to:i})}}}return new cm(this.parser,t,n,i,r,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:i}=this.skipped[t];n<e.to&&i>e.from&&(this.fragments=hm(this.fragments,n,i),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Mg{createParse(t,n,i){let r=i[0].from,o=i[i.length-1].to;return{parsedPos:r,advance(){let t=lm;if(t){for(let e of i)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=o,new lg(rg.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return lm}}function hm(e,t,n){return Eg.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class um{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new um(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=cm.create(e.facet(gm).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new um(n)}}rm.state=Fc.define({create:um.init,update(e,t){for(let e of t.effects)if(e.is(rm.setState))return e.value;return t.startState.facet(gm)!=t.state.facet(gm)?um.init(t.state):e.apply(t)}});let dm=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(dm=e=>{let t=-1,n=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const pm="undefined"!=typeof navigator&&(null===(tm=navigator.scheduling)||void 0===tm?void 0:tm.isInputPending)?()=>navigator.scheduling.isInputPending():null,fm=Wd.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(rm.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(rm.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=dm(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,r=n.field(rm.state);if(r.tree==r.context.tree&&r.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!pm?Math.max(25,e.timeRemaining()-5):1e9),s=r.context.treeLen<i&&n.doc.length>i+1e3,a=r.context.work((()=>pm&&pm()||Date.now()>o),i+(s?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:rm.setState.of(new um(r.context))})),this.chunkBudget>0&&(!a||s)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((()=>this.scheduleWork())).catch((e=>Vd(this.view.state,e))).then((()=>this.workScheduled--)),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),gm=Nc.define({combine:e=>e.length?e[0]:null,enables:e=>[rm.state,fm,Wf.contentAttributes.compute([e],(t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}}))]});class mm{constructor(e,t){let n;function i(e){let t=Vh.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const r="string"==typeof t.all?t.all:t.all?i(t.all):void 0,o=t.scope;this.scope=o instanceof rm?e=>e.prop(nm)==o.data:o?e=>e==o:void 0,this.style=Bg(e.map((e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))}))),{all:r}).style,this.module=n?new Vh(n):null,this.themeType=t.themeType}static define(e,t){return new mm(e,t||{})}}const vm=Nc.define(),ym=Nc.define({combine:e=>e.length?[e[0]]:null});function wm(e){let t=e.facet(vm);return t.length?t:e.facet(ym)}class bm{constructor(e){this.markCache=Object.create(null),this.tree=sm(e.state),this.decorations=this.buildDeco(e,wm(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=sm(e.state),n=wm(e.state),i=n!=wm(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!i&&t.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return Xu.none;let n=new Mh;for(let{from:i,to:r}of e.visibleRanges)Lg(this.tree,t,((e,t,i)=>{n.add(e,t,this.markCache[i]||(this.markCache[i]=Xu.mark({class:i})))}),i,r);return n.finish()}}const xm=Uc.high(Wd.fromClass(bm,{decorations:e=>e.decorations}));em.meta,em.link,em.heading,em.emphasis,em.strong,em.strikethrough,em.keyword,em.atom,em.bool,em.url,em.contentSeparator,em.labelName,em.literal,em.inserted,em.string,em.deleted,em.regexp,em.escape,em.string,em.variableName,em.variableName,em.typeName,em.namespace,em.className,em.variableName,em.macroName,em.propertyName,em.comment,em.invalid;const _m=Object.create(null),Sm=[rg.none],km=[],Cm=Object.create(null),Em=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Em[e]=Am(_m,t);function Mm(e,t){km.indexOf(e)>-1||(km.push(e),console.warn(t))}function Am(e,t){let n=[];for(let i of t.split(" ")){let t=[];for(let n of i.split(".")){let i=e[n]||em[n];i?"function"==typeof i?t.length?t=t.map(i):Mm(n,`Modifier ${n} used at start of tag`):t.length?Mm(n,`Tag ${n} used as modifier`):t=Array.isArray(i)?i:[i]:Mm(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let i=t.replace(/ /g,"_"),r=i+" "+n.map((e=>e.id)),o=Cm[r];if(o)return o.id;let s=Cm[r]=rg.define({id:Sm.length,name:i,props:[Ng({[i]:n})]});return Sm.push(s),s.id}ad.RTL,ad.LTR;const Rm=Nc.define({combine:e=>Object.assign({sources:e.map((e=>e.source)).filter((e=>null!=e))},function(e,t,n={}){let i={};for(let t of e)for(let e of Object.keys(t)){let r=t[e],o=i[e];if(void 0===o)i[e]=r;else if(o===r||void 0===r);else{if(!Object.hasOwnProperty.call(n,e))throw new Error("Config merge conflict for field "+e);i[e]=n[e](o,r)}}for(let e in t)void 0===i[e]&&(i[e]=t[e]);return i}(e.map((e=>e.config)),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))});function Tm(e){const t=[];return e.iterate({enter:e=>{const n=e.node;if(!n.type.isError)return;const i=n.parent,r=Dm(n),o={from:n.from,to:n.to,severity:"error",type:"Syntax Error"};if(n.from!==n.to)o.message=`Unrecognized token in <${i.name}>`;else if(r)o.message=`Unrecognized token <${r.name}> in <${i.name}>`,o.to=r.to;else{const e=i.enterUnfinishedNodesBefore(n.to);o.message=`Incomplete <${(e||i).name}>`}t.push(o)}}),t}function Dm(e){return e?e.nextSibling||Dm(e.parent):null}var Om={create:e=>({enter(t){if("FilterExpression"!==t.name)return;const n=e.readContent(t.from,t.to);if(/\[\s*0\s*\]$/.test(n)){const{from:i,to:r}=t;e.report({from:i,to:r,message:"First item is accessed via [1]",severity:"warning",type:"first-item",actions:[{name:"fix",apply(t,o=i,s=r){e.updateContent(o,s,n.replace(/\[\s*0\s*\]$/,"[1]"))}}]})}}})};const Nm=[Om];function Pm(e){const{readContent:t,syntaxTree:n,updateContent:i}=e,r=[],o={readContent:t,report:e=>{r.push(e)},updateContent:i},s=Nm.map((e=>e.create(o)));return n.iterate({enter:e=>{for(const t of s)t.enter&&t.enter(e)},leave:e=>{for(const t of s)t.leave&&t.leave(e)}}),r}!function(e,t={}){Rm.of({source:e,config:t})}((e=>{if(0===e.state.doc.length)return[];const t=sm(e.state),n=(i={syntaxTree:t,readContent:(t,n)=>e.state.sliceDoc(t,n),updateContent:(t,n,i)=>e.dispatch({changes:{from:t,to:n,insert:i}})},[...Tm(i.syntaxTree),...Pm(i)]);var i;return n.map((e=>({...e,source:e.type})))})),Wf.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}}),Wf.baseTheme({"& .variableName":{color:"#10f"},"& .number":{color:"#164"},"& .string":{color:"#a11"},"& .bool":{color:"#219"},"& .function":{color:"#aa3731",fontWeight:"bold"},"& .control":{color:"#708"}}),function(e,t){let n,i=[xm];e instanceof mm&&(e.module&&i.push(Wf.styleModule.of(e.module)),n=e.themeType),n?i.push(vm.computeN([Wf.darkTheme],(t=>t.facet(Wf.darkTheme)==("dark"==n)?[e]:[]))):i.push(vm.of(e))}(mm.define([{tag:em.variableName,class:"variableName"},{tag:em.name,class:"variableName"},{tag:em.number,class:"number"},{tag:em.string,class:"string"},{tag:em.bool,class:"bool"},{tag:em.function(em.variableName),class:"function"},{tag:em.function(em.special(em.variableName)),class:"function"},{tag:em.controlKeyword,class:"control"},{tag:em.operatorKeyword,class:"control"}])),Nc.define(),Nc.define(),Nc.define(),Nc.define();function qm(e){const{name:t,description:n}=e,i=t.match(/^([\w\s]+)\((.*)\)$/),r=i[1],o=i[2],s=o?o.split(", ").map((e=>({name:e}))):[];return{name:r,type:"function",params:s,info:()=>Ft(`<div class="description">${n}<div>`),boost:0}}[{name:"not(negand)",description:'<p>Returns the logical negation of the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">not(negand: boolean): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">not(true)\n// false\n\nnot(null)\n// null\n</code></pre>\n'},{name:"is defined(value)",description:'<p><em>Camunda Extension</em></p>\n<p>Checks if a given value is not <code>null</code>. If the value is <code>null</code> then the function returns <code>false</code>.\nOtherwise, the function returns <code>true</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">is defined(value: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">is defined(1)\n// true\n\nis defined(null)\n// false\n\nis defined(x)\n// false - if no variable "x" exists\n\nis defined(x.y)\n// false - if no variable "x" exists or it doesn't have a property "y"\n</code></pre>\n<p>:::caution Breaking change</p>\n<p>This function worked differently in previous versions. It returned <code>true</code> if the value was <code>null</code>.\nSince this version, the function returns <code>false</code> if the value is <code>null</code>.</p>\n<p>:::</p>\n'},{name:"get or else(value, default)",description:'<p><em>Camunda Extension</em></p>\n<p>Return the provided value parameter if not <code>null</code>, otherwise return the default parameter</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">get or else(value: Any, default: Any): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">get or else("this", "default")\n// "this"\n\nget or else(null, "default")\n// "default"\n\nget or else(null, null)\n// null\n</code></pre>\n'},{name:"assert(value, condition)",description:'<p><em>Camunda Extension</em></p>\n<p>Verify that the given condition is met. If the condition is <code>true</code>, the function returns the value.\nOtherwise, the evaluation fails with an error.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">assert(value: Any, condition: Any)\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">assert(x, x != null)\n// "value" - if x is "value"\n// error - if x is null or doesn't exist\n\nassert(x, x >= 0)\n// 4 - if x is 4\n// error - if x is less than zero\n</code></pre>\n'},{name:"assert(value, condition, cause)",description:'<p><em>Camunda Extension</em></p>\n<p>Verify that the given condition is met. If the condition is <code>true</code>, the function returns the value.\nOtherwise, the evaluation fails with an error containing the given message.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">assert(value: Any, condition: Any, cause: String)\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">assert(x, x != null, "'x' should not be null")\n// "value" - if x is "value"\n// error('x' should not be null) - if x is null or doesn't exist\n\nassert(x, x >= 0, "'x' should be positive")\n// 4 - if x is 4\n// error('x' should be positive) - if x is less than zero\n</code></pre>\n'},{name:"get value(context, key)",description:'<p>Returns the value of the context entry with the given key.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">get value(context: context, key: string): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">get value({foo: 123}, "foo")\n// 123\n\nget value({a: 1}, "b")\n// null\n</code></pre>\n'},{name:"get value(context, keys)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns the value of the context entry for a context path defined by the given keys.</p>\n<p>If <code>keys</code> contains the keys <code>[k1, k2]</code> then it returns the value at the nested entry <code>k1.k2</code> of the context.</p>\n<p>If <code>keys</code> are empty or the nested entry defined by the keys doesn't exist in the context, it returns <code>null</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">get value(context: context, keys: list<string>): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">get value({x:1, y: {z:0}}, ["y", "z"])\n// 0\n\nget value({x: {y: {z:0}}}, ["x", "y"])\n// {z:0}\n\nget value({a: {b: 3}}, ["b"])\n// null\n</code></pre>\n'},{name:"get entries(context)",description:'<p>Returns the entries of the context as a list of key-value-pairs.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">get entries(context: context): list<context>\n</code></pre>\n<p>The return value is a list of contexts. Each context contains two entries for "key" and "value".</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">get entries({foo: 123})\n// [{key: "foo", value: 123}]\n</code></pre>\n'},{name:"context put(context, key, value)",description:'<p>Adds a new entry with the given key and value to the context. Returns a new context that includes the entry.</p>\n<p>If an entry for the same key already exists in the context, it overrides the value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">context put(context: context, key: string, value: Any): context\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">context put({x:1}, "y", 2)\n// {x:1, y:2}\n</code></pre>\n<p>:::info\nThe function <code>context put()</code> replaced the previous function <code>put()</code> (Camunda Extension). The\nprevious function is deprecated and should not be used anymore.\n:::</p>\n'},{name:"context put(context, keys, value)",description:'<p>Adds a new entry with the given value to the context. The path of the entry is defined by the keys. Returns a new context that includes the entry.</p>\n<p>If <code>keys</code> contains the keys <code>[k1, k2]</code> then it adds the nested entry <code>k1.k2 = value</code> to the context.</p>\n<p>If an entry for the same keys already exists in the context, it overrides the value.</p>\n<p>If <code>keys</code> are empty, it returns <code>null</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">context put(context: context, keys: list<string>, value: Any): context\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">context put({x:1}, ["y"], 2)\n// {x:1, y:2}\n\ncontext put({x:1, y: {z:0}}, ["y", "z"], 2)\n// {x:1, y: {z:2}}\n\ncontext put({x:1}, ["y", "z"], 2)\n// {x:1, y: {z:2}}\n</code></pre>\n'},{name:"context merge(contexts)",description:'<p>Union the given contexts. Returns a new context that includes all entries of the given contexts.</p>\n<p>If an entry for the same key already exists in a context, it overrides the value. The entries are overridden in the same order as in the list of contexts.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">context merge(contexts: list<context>): context\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">context merge([{x:1}, {y:2}])\n// {x:1, y:2}\n\ncontext merge([{x:1, y: 0}, {y:2}])\n// {x:1, y:2}\n</code></pre>\n<p>:::info\nThe function <code>context merge()</code> replaced the previous function <code>put all()</code> (Camunda Extension). The\nprevious function is deprecated and should not be used anymore.\n:::</p>\n'},{name:"string(from)",description:'<p>Returns the given value as a string representation.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string(from: Any): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string(1.1)\n// "1.1"\n\nstring(date("2012-12-25"))\n// "2012-12-25"\n</code></pre>\n'},{name:"number(from)",description:'<p>Parses the given string to a number.</p>\n<p>Returns <code>null</code> if the string is not a number.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">number(from: string): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">number("1500.5")\n// 1500.5\n</code></pre>\n'},{name:"context(entries)",description:'<p>Constructs a context of the given list of key-value pairs. It is the reverse function to <a href="feel-built-in-functions-context.md#get-entriescontext">get entries()</a>.</p>\n<p>Each key-value pair must be a context with two entries: <code>key</code> and <code>value</code>. The entry with name <code>key</code> must have a value of the type <code>string</code>.</p>\n<p>It might override context entries if the keys are equal. The entries are overridden in the same order as the contexts in the given list.</p>\n<p>Returns <code>null</code> if one of the entries is not a context or if a context doesn't contain the required entries.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">context(entries: list<context>): context\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">context([{"key":"a", "value":1}, {"key":"b", "value":2}])\n// {a:1, b:2}\n</code></pre>\n'},{name:"date(from)",description:'<p>Returns a date from the given value.</p>\n<p>Returns <code>null</code> if the string is not a valid calendar date. For example, <code>"2024-06-31"</code> is invalid because June has\nonly 30 days.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date(from: string): date\n</code></pre>\n<p>Parses the given string into a date.</p>\n<pre><code class="language-feel">date(from: date and time): date\n</code></pre>\n<p>Extracts the date component from the given date and time.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date("2018-04-29")\n// date("2018-04-29")\n\ndate(date and time("2012-12-25T11:00:00"))\n// date("2012-12-25")\n</code></pre>\n'},{name:"date(year, month, day)",description:'<p>Returns a date from the given components.</p>\n<p>Returns <code>null</code> if the components don't represent a valid calendar date. For example, <code>2024,6,31</code> is invalid because\nJune has only 30 days.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date(year: number, month: number, day: number): date\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date(2012, 12, 25)\n// date("2012-12-25")\n</code></pre>\n'},{name:"time(from)",description:'<p>Returns a time from the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">time(from: string): time\n</code></pre>\n<p>Parses the given string into a time.</p>\n<pre><code class="language-feel">time(from: date and time): time\n</code></pre>\n<p>Extracts the time component from the given date and time.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">time("12:00:00")\n// time("12:00:00")\n\ntime(date and time("2012-12-25T11:00:00"))\n// time("11:00:00")\n</code></pre>\n'},{name:"time(hour, minute, second)",description:'<p>Returns a time from the given components.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">time(hour: number, minute: number, second: number): time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">time(23, 59, 0)\n// time("23:59:00")\n</code></pre>\n'},{name:"time(hour, minute, second, offset)",description:'<p>Returns a time from the given components, including a timezone offset.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">time(hour: number, minute: number, second: number, offset: days and time duration): time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">time(14, 30, 0, duration("PT1H"))\n// time("14:30:00+01:00")\n</code></pre>\n'},{name:"date and time(from)",description:'<p>Parses the given string into a date and time.</p>\n<p>Returns <code>null</code> if the string is not a valid calendar date. For example, <code>"2024-06-31T10:00:00"</code> is invalid because\nJune has only 30 days.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date and time(from: string): date and time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date and time("2018-04-29T09:30:00")\n// date and time("2018-04-29T09:30:00")\n</code></pre>\n'},{name:"date and time(date, time)",description:'<p>Returns a date and time from the given components.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date and time(date: date, time: time): date and time\n</code></pre>\n<pre><code class="language-feel">date and time(date: date and time, time: time): date and time\n</code></pre>\n<p>Returns a date and time value that consists of the date component of <code>date</code> combined with <code>time</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date and time(date("2012-12-24"),time("T23:59:00"))\n// date and time("2012-12-24T23:59:00")\n\ndate and time(date and time("2012-12-25T11:00:00"),time("T23:59:00"))\n// date and time("2012-12-25T23:59:00")\n</code></pre>\n'},{name:"date and time(date, timezone)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns the given date and time value at the given timezone.</p>\n<p>If <code>date</code> has a different timezone than <code>timezone</code> then it adjusts the time to match the local time of <code>timezone</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date and time(date: date and time, timezone: string): date and time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date and time(@"2020-07-31T14:27:30@Europe/Berlin", "America/Los_Angeles")\n// date and time("2020-07-31T05:27:30@America/Los_Angeles")\n\ndate and time(@"2020-07-31T14:27:30", "Z")\n// date and time("2020-07-31T12:27:30Z")\n</code></pre>\n'},{name:"duration(from)",description:'<p>Parses the given string into a duration. The duration is either a days and time duration or a years and months duration.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">duration(from: string): days and time duration\n</code></pre>\n<pre><code class="language-feel">duration(from: string): years and months duration\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">duration("P5D")\n// duration("P5D")\n\nduration("P32Y")\n// duration("P32Y")\n</code></pre>\n'},{name:"years and months duration(from, to)",description:'<p>Returns the years and months duration between <code>from</code> and <code>to</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">years and months duration(from: date, to: date): years and months duration\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">years and months duration(date("2011-12-22"), date("2013-08-24"))\n// duration("P1Y8M")\n</code></pre>\n'},{name:"list contains(list, element)",description:'<p>Returns <code>true</code> if the given list contains the element. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">list contains(list: list, element: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">list contains([1,2,3], 2)\n// true\n</code></pre>\n'},{name:"count(list)",description:'<p>Returns the number of elements of the given list.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">count(list: list): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">count([1,2,3])\n// 3\n</code></pre>\n'},{name:"min(list)",description:'<p>Returns the minimum of the given list.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">min(list: list): Any\n</code></pre>\n<p>All elements in <code>list</code> should have the same type and be comparable.</p>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">min([1,2,3])\n// 1\n\nmin(1,2,3)\n// 1\n</code></pre>\n'},{name:"max(list)",description:'<p>Returns the maximum of the given list.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">max(list: list): Any\n</code></pre>\n<p>All elements in <code>list</code> should have the same type and be comparable.</p>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">max([1,2,3])\n// 3\n\nmax(1,2,3)\n// 3\n</code></pre>\n'},{name:"sum(list)",description:'<p>Returns the sum of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sum(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sum([1,2,3])\n// 6\n\nsum(1,2,3)\n// 6\n</code></pre>\n'},{name:"product(list)",description:'<p>Returns the product of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">product(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">product([2, 3, 4])\n// 24\n\nproduct(2, 3, 4)\n// 24\n</code></pre>\n'},{name:"mean(list)",description:'<p>Returns the arithmetic mean (i.e. average) of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">mean(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">mean([1,2,3])\n// 2\n\nmean(1,2,3)\n// 2\n</code></pre>\n'},{name:"median(list)",description:'<p>Returns the median element of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">median(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">median(8, 2, 5, 3, 4)\n// 4\n\nmedian([6, 1, 2, 3])\n// 2.5\n</code></pre>\n'},{name:"stddev(list)",description:'<p>Returns the standard deviation of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">stddev(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">stddev(2, 4, 7, 5)\n// 2.0816659994661326\n\nstddev([2, 4, 7, 5])\n// 2.0816659994661326\n</code></pre>\n'},{name:"mode(list)",description:'<p>Returns the mode of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">mode(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">mode(6, 3, 9, 6, 6)\n// [6]\n\nmode([6, 1, 9, 6, 1])\n// [1, 6]\n</code></pre>\n'},{name:"all(list)",description:'<p>Returns <code>false</code> if any element of the given list is <code>false</code>. Otherwise, returns <code>true</code>.</p>\n<p>If the given list is empty, it returns <code>true</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">all(list: list<boolean>): boolean\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">all([true,false])\n// false\n\nall(false,null,true)\n// false\n</code></pre>\n<p>:::info\nThe function <code>all()</code> replaced the previous function <code>and()</code>. The previous function is deprecated and\nshould not be used anymore.\n:::</p>\n'},{name:"any(list)",description:'<p>Returns <code>true</code> if any element of the given list is <code>true</code>. Otherwise, returns <code>false</code>.</p>\n<p>If the given list is empty, it returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">any(list: list<boolean>): boolean\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">any([false,true])\n// true\n\nany(false,null,true)\n// true\n</code></pre>\n<p>:::info\nThe function <code>any()</code> replaced the previous function <code>or()</code>. The previous function is deprecated and\nshould not be used anymore.\n:::</p>\n'},{name:"sublist(list, start position)",description:'<p>Returns a partial list of the given value starting at <code>start position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sublist(list: list, start position: number): list\n</code></pre>\n<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sublist([1,2,3], 2)\n// [2,3]\n</code></pre>\n'},{name:"sublist(list, start position, length)",description:'<p>Returns a partial list of the given value starting at <code>start position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sublist(list: list, start position: number, length: number): list\n</code></pre>\n<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sublist([1,2,3], 1, 2)\n// [1,2]\n</code></pre>\n'},{name:"append(list, items)",description:'<p>Returns the given list with all <code>items</code> appended.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">append(list: list, items: Any): list\n</code></pre>\n<p>The parameter <code>items</code> can be a single element or a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">append([1], 2, 3)\n// [1,2,3]\n</code></pre>\n'},{name:"concatenate(lists)",description:'<p>Returns a list that includes all elements of the given lists.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">concatenate(lists: list): list\n</code></pre>\n<p>The parameter <code>lists</code> is a sequence of lists.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">concatenate([1,2],[3])\n// [1,2,3]\n\nconcatenate([1],[2],[3])\n// [1,2,3]\n</code></pre>\n'},{name:"insert before(list, position, newItem)",description:'<p>Returns the given list with <code>newItem</code> inserted at <code>position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">insert before(list: list, position: number, newItem: Any): list\n</code></pre>\n<p>The <code>position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">insert before([1,3],1,2)\n// [2,1,3]\n</code></pre>\n'},{name:"remove(list, position)",description:'<p>Returns the given list without the element at <code>position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">remove(list: list, position: number): list\n</code></pre>\n<p>The <code>position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">remove([1,2,3], 2)\n// [1,3]\n</code></pre>\n'},{name:"reverse(list)",description:'<p>Returns the given list in revered order.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">reverse(list: list): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">reverse([1,2,3])\n// [3,2,1]\n</code></pre>\n'},{name:"index of(list, match)",description:'<p>Returns an ascending list of positions containing <code>match</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">index of(list: list, match: Any): list<number>\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">index of([1,2,3,2],2)\n// [2,4]\n</code></pre>\n'},{name:"union(list)",description:'<p>Returns a list that includes all elements of the given lists without duplicates.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">union(list: list): list\n</code></pre>\n<p>The parameter <code>list</code> is a sequence of lists.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">union([1,2],[2,3])\n// [1,2,3]\n</code></pre>\n'},{name:"distinct values(list)",description:'<p>Returns the given list without duplicates.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">distinct values(list: list): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">distinct values([1,2,3,2,1])\n// [1,2,3]\n</code></pre>\n'},{name:"duplicate values(list)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns all duplicate values of the given list.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">duplicate values(list: list): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">duplicate values([1,2,3,2,1])\n// [1,2]\n</code></pre>\n'},{name:"flatten(list)",description:'<p>Returns a list that includes all elements of the given list without nested lists.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">flatten(list: list): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">flatten([[1,2],[[3]], 4])\n// [1,2,3,4]\n</code></pre>\n'},{name:"sort(list, precedes)",description:'<p>Returns the given list sorted by the <code>precedes</code> function.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sort(list: list, precedes: function<(Any, Any) -> boolean>): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sort(list: [3,1,4,5,2], precedes: function(x,y) x < y)\n// [1,2,3,4,5]\n</code></pre>\n'},{name:"string join(list)",description:'<p>Joins a list of strings into a single string. This is similar to\nJava's <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Collectors.html#joining(java.lang.CharSequence,java.lang.CharSequence,java.lang.CharSequence)">joining</a>\nfunction.</p>\n<p>If an item of the list is <code>null</code>, the item is ignored for the result string. If an item is\nneither a string nor <code>null</code>, the function returns <code>null</code> instead of a string.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string join(list: list<string>): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string join(["a","b","c"])\n// "abc"\n\nstring join(["a",null,"c"])\n// "ac"\n\nstring join([])\n// ""\n</code></pre>\n'},{name:"string join(list, delimiter)",description:'<p>Joins a list of strings into a single string. This is similar to\nJava's <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Collectors.html#joining(java.lang.CharSequence,java.lang.CharSequence,java.lang.CharSequence)">joining</a>\nfunction.</p>\n<p>If an item of the list is <code>null</code>, the item is ignored for the result string. If an item is\nneither a string nor <code>null</code>, the function returns <code>null</code> instead of a string.</p>\n<p>The resulting string contains a <code>delimiter</code> between each element.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string join(list: list<string>, delimiter: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string join(["a"], "X")\n// "a"\n\nstring join(["a","b","c"], ", ")\n// "a, b, c"\n</code></pre>\n'},{name:"string join(list, delimiter, prefix, suffix)",description:'<p><em>Camunda Extension</em></p>\n<p>Joins a list of strings into a single string. This is similar to\nJava's <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Collectors.html#joining(java.lang.CharSequence,java.lang.CharSequence,java.lang.CharSequence)">joining</a>\nfunction.</p>\n<p>If an item of the list is <code>null</code>, the item is ignored for the result string. If an item is\nneither a string nor <code>null</code>, the function returns <code>null</code> instead of a string.</p>\n<p>The resulting string starts with <code>prefix</code>, contains a <code>delimiter</code> between each element, and ends\nwith <code>suffix</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string join(list: list<string>, delimiter: string, prefix: string, suffix: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string join(["a","b","c"], ", ", "[", "]")\n// "[a, b, c]"\n</code></pre>\n'},{name:"is empty(list)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns <code>true</code> if the given list is empty. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">is empty(list: list): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">is empty([])\n// true\n\nis empty([1,2,3])\n// false\n</code></pre>\n'},{name:"partition(list, size)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns consecutive sublists of a list, each of the same size (the final list may be smaller).</p>\n<p>If <code>size</code> is less than <code>0</code>, it returns <code>null</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">partition(list: list, size: number): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">partition([1,2,3,4,5], 2)\n// [[1,2], [3,4], [5]]\n\npartition([], 2)\n// []\n\npartition([1,2], 0)\n// null\n</code></pre>\n'},{name:"decimal(n, scale)",description:'<p>Rounds the given value at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">decimal(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">decimal(1/3, 2)\n// .33\n\ndecimal(1.5, 0)\n// 2\n</code></pre>\n'},{name:"floor(n)",description:'<p>Rounds the given value with rounding mode flooring.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">floor(n: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">floor(1.5)\n// 1\n\nfloor(-1.5)\n// -2\n</code></pre>\n'},{name:"floor(n, scale)",description:'<p>Rounds the given value with rounding mode flooring at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">floor(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">floor(-1.56, 1)\n// -1.6\n</code></pre>\n'},{name:"ceiling(n)",description:'<p>Rounds the given value with rounding mode ceiling.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">ceiling(n: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">ceiling(1.5)\n// 2\n\nceiling(-1.5)\n// -1\n</code></pre>\n'},{name:"ceiling(n, scale)",description:'<p>Rounds the given value with rounding mode ceiling at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">ceiling(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">ceiling(-1.56, 1)\n// -1.5\n</code></pre>\n'},{name:"round up(n, scale)",description:'<p>Rounds the given value with the rounding mode round-up at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">round up(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">round up(5.5)\n// 6\n\nround up(-5.5)\n// -6\n\nround up(1.121, 2)\n// 1.13\n\nround up(-1.126, 2)\n// -1.13\n</code></pre>\n'},{name:"round down(n, scale)",description:'<p>Rounds the given value with the rounding mode round-down at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">round down(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">round down(5.5, 0)\n// 5\n\nround down (-5.5, 0)\n// -5\n\nround down (1.121, 2)\n// 1.12\n\nround down (-1.126, 2)\n// -1.12\n</code></pre>\n'},{name:"round half up(n, scale)",description:'<p>Rounds the given value with the rounding mode round-half-up at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">round half up(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">round half up(5.5, 0)\n// 6\n\nround half up(-5.5, 0)\n// -6\n\nround half up(1.121, 2)\n// 1.12\n\nround half up(-1.126, 2)\n// -1.13\n</code></pre>\n'},{name:"round half down(n, scale)",description:'<p>Rounds the given value with the rounding mode round-half-down at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">round half down(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">round half down (5.5, 0)\n// 5\n\nround half down (-5.5, 0)\n// -5\n\nround half down (1.121, 2)\n// 1.12\n\nround half down (-1.126, 2)\n// -1.13\n</code></pre>\n'},{name:"abs(number)",description:'<p>Returns the absolute value of the given numeric value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">abs(number: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">abs(10)\n// 10\n\nabs(-10)\n// 10\n</code></pre>\n'},{name:"modulo(dividend, divisor)",description:'<p>Returns the remainder of the division of dividend by divisor.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">modulo(dividend: number, divisor: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">modulo(12, 5)\n// 2\n</code></pre>\n'},{name:"sqrt(number)",description:'<p>Returns the square root of the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sqrt(number: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sqrt(16)\n// 4\n</code></pre>\n'},{name:"log(number)",description:'<p>Returns the natural logarithm (base e) of the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">log(number: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">log(10)\n// 2.302585092994046\n</code></pre>\n'},{name:"exp(number)",description:'<p>Returns the Euler’s number e raised to the power of the given number .</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">exp(number: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">exp(5)\n// 148.4131591025766\n</code></pre>\n'},{name:"odd(number)",description:'<p>Returns <code>true</code> if the given value is odd. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">odd(number: number): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">odd(5)\n// true\n\nodd(2)\n// false\n</code></pre>\n'},{name:"even(number)",description:'<p>Returns <code>true</code> if the given is even. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">even(number: number): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">even(5)\n// false\n\neven(2)\n// true\n</code></pre>\n'},{name:"random number()",description:'<p><em>Camunda Extension</em></p>\n<p>Returns a random number between <code>0</code> and <code>1</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">random number(): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">random number()\n// 0.9701618132579795\n</code></pre>\n'},{name:"before(point1, point2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">before(point1: Any, point2: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">before(1, 10)\n// true\n\nbefore(10, 1)\n// false\n</code></pre>\n'},{name:"before(range, point)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">before(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">before([1..5], 10)\n// true\n</code></pre>\n'},{name:"before(point, range)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">before(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">before(1, [2..5])\n// true\n</code></pre>\n'},{name:"before(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">before(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">before([1..5], [6..10])\n// true\n\nbefore([1..5),[5..10])\n// true\n</code></pre>\n'},{name:"after(point1, point2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">after(point1: Any, point2: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">after(10, 1)\n// true\n\nafter(1, 10)\n// false\n</code></pre>\n'},{name:"after(range, point)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">after(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">after([1..5], 10)\n// false\n</code></pre>\n'},{name:"after(point, range)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">after(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">after(12, [2..5])\n// true\n</code></pre>\n'},{name:"after(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">after(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">after([6..10], [1..5])\n// true\n\nafter([5..10], [1..5))\n// true\n</code></pre>\n'},{name:"meets(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">meets(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">meets([1..5], [5..10])\n// true\n\nmeets([1..3], [4..6])\n// false\n\nmeets([1..3], [3..5])\n// true\n\nmeets([1..5], (5..8])\n// false\n</code></pre>\n'},{name:"met by(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">met by(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">met by([5..10], [1..5])\n// true\n\nmet by([3..4], [1..2])\n// false\n\nmet by([3..5], [1..3])\n// true\n\nmet by((5..8], [1..5))\n// false\n\nmet by([5..10], [1..5))\n// false\n</code></pre>\n'},{name:"overlaps(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">overlaps(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">overlaps([5..10], [1..6])\n// true\n\noverlaps((3..7], [1..4])\n// true\n\noverlaps([1..3], (3..6])\n// false\n\noverlaps((5..8], [1..5))\n// false\n\noverlaps([4..10], [1..5))\n// true\n</code></pre>\n'},{name:"overlaps before(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">overlaps before(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">overlaps before([1..5], [4..10])\n// true\n\noverlaps before([3..4], [1..2])\n// false\n\noverlaps before([1..3], (3..5])\n// false\n\noverlaps before([1..5), (3..8])\n// true\n\noverlaps before([1..5), [5..10])\n// false\n</code></pre>\n'},{name:"overlaps after(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">overlaps after(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">overlaps after([4..10], [1..5])\n// true\n\noverlaps after([3..4], [1..2])\n// false\n\noverlaps after([3..5], [1..3))\n// false\n\noverlaps after((5..8], [1..5))\n// false\n\noverlaps after([4..10], [1..5))\n// true\n</code></pre>\n'},{name:"finishes(point, range)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">finishes(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">finishes(5, [1..5])\n// true\n\nfinishes(10, [1..7])\n// false\n</code></pre>\n'},{name:"finishes(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">finishes(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">finishes([3..5], [1..5])\n// true\n\nfinishes((1..5], [1..5))\n// false\n\nfinishes([5..10], [1..10))\n// false\n</code></pre>\n'},{name:"finished by(range, point)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">finished by(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">finished by([5..10], 10)\n// true\n\nfinished by([3..4], 2)\n// false\n</code></pre>\n'},{name:"finished by(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">finished by(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">finished by([1..5], [3..5])\n// true\n\nfinished by((5..8], [1..5))\n// false\n\nfinished by([5..10], (1..10))\n// false\n</code></pre>\n'},{name:"includes(range, point)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">includes(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">includes([5..10], 6)\n// true\n\nincludes([3..4], 5)\n// false\n</code></pre>\n'},{name:"includes(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">includes(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">includes([1..10], [4..6])\n// true\n\nincludes((5..8], [1..5))\n// false\n\nincludes([1..10], [1..5))\n// true\n</code></pre>\n'},{name:"during(point, range)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">during(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">during(5, [1..10])\n// true\n\nduring(12, [1..10])\n// false\n\nduring(1, (1..10])\n// false\n</code></pre>\n'},{name:"during(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">during(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">during([4..6], [1..10))\n// true\n\nduring((1..5], (1..10])\n// true\n</code></pre>\n'},{name:"starts(point, range)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">starts(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">starts(1, [1..5])\n// true\n\nstarts(1, (1..8])\n// false\n</code></pre>\n'},{name:"starts(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">starts(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">starts((1..5], [1..5])\n// false\n\nstarts([1..10], [1..5])\n// false\n\nstarts((1..5), (1..10))\n// true\n</code></pre>\n'},{name:"started by(range, point)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">started by(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">started by([1..10], 1)\n// true\n\nstarted by((1..10], 1)\n// false\n</code></pre>\n'},{name:"started by(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">started by(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">started by([1..10], [1..5])\n// true\n\nstarted by((1..10], [1..5))\n// false\n\nstarted by([1..10], [1..10))\n// true\n</code></pre>\n'},{name:"coincides(point1, point2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">coincides(point1: Any, point2: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">coincides(5, 5)\n// true\n\ncoincides(3, 4)\n// false\n</code></pre>\n'},{name:"coincides(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">coincides(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">coincides([1..5], [1..5])\n// true\n\ncoincides((1..5], [1..5))\n// false\n\ncoincides([1..5], [2..6])\n// false\n</code></pre>\n'},{name:"substring(string, start position)",description:'<p>Returns a substring of the given value starting at <code>start position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">substring(string: string, start position: number): string\n</code></pre>\n<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">substring("foobar", 3)\n// "obar"\n\nsubstring("foobar", -2)\n// "ar"\n</code></pre>\n'},{name:"substring(string, start position, length)",description:'<p>Returns a substring of the given value, starting at <code>start position</code> with the given <code>length</code>. If <code>length</code> is greater than\nthe remaining characters of the value, it returns all characters from <code>start position</code> until the end.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">substring(string: string, start position: number, length: number): string\n</code></pre>\n<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">substring("foobar", 3, 3)\n// "oba"\n\nsubstring("foobar", -3, 2)\n// "ba"\n\nsubstring("foobar", 3, 10)\n// "obar"\n</code></pre>\n'},{name:"string length(string)",description:'<p>Returns the number of characters in the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string length(string: string): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string length("foo")\n// 3\n</code></pre>\n'},{name:"upper case(string)",description:'<p>Returns the given value with all characters are uppercase.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">upper case(string: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">upper case("aBc4")\n// "ABC4"\n</code></pre>\n'},{name:"lower case(string)",description:'<p>Returns the given value with all characters are lowercase.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">lower case(string: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">lower case("aBc4")\n// "abc4"\n</code></pre>\n'},{name:"substring before(string, match)",description:'<p>Returns a substring of the given value that contains all characters before <code>match</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">substring before(string: string, match: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">substring before("foobar", "bar")\n// "foo"\n</code></pre>\n'},{name:"substring after(string, match)",description:'<p>Returns a substring of the given value that contains all characters after <code>match</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">substring after(string: string, match: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">substring after("foobar", "ob")\n// "ar"\n</code></pre>\n'},{name:"contains(string, match)",description:'<p>Returns <code>true</code> if the given value contains the substring <code>match</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">contains(string: string, match: string): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">contains("foobar", "of")\n// false\n</code></pre>\n'},{name:"starts with(string, match)",description:'<p>Returns <code>true</code> if the given value starts with the substring <code>match</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">starts with(string: string, match: string): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">starts with("foobar", "fo")\n// true\n</code></pre>\n'},{name:"ends with(string, match)",description:'<p>Returns <code>true</code> if the given value ends with the substring <code>match</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">ends with(string: string, match: string): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">ends with("foobar", "r")\n// true\n</code></pre>\n'},{name:"matches(input, pattern)",description:'<p>Returns <code>true</code> if the given value matches the <code>pattern</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">matches(input: string, pattern: string): boolean\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">matches("foobar", "^fo*bar")\n// true\n</code></pre>\n'},{name:"matches(input, pattern, flags)",description:'<p>Returns <code>true</code> if the given value matches the <code>pattern</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">matches(input: string, pattern: string, flags: string): boolean\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p>The <code>flags</code> can contain one or more of the following characters:</p>\n<ul>\n<li><code>s</code> (dot-all)</li>\n<li><code>m</code> (multi-line)</li>\n<li><code>i</code> (case insensitive)</li>\n<li><code>x</code> (comments)</li>\n</ul>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">matches("FooBar", "foo", "i")\n// true\n</code></pre>\n'},{name:"replace(input, pattern, replacement)",description:'<p>Returns the resulting string after replacing all occurrences of <code>pattern</code> with <code>replacement</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">replace(input: string, pattern: string, replacement: string): string\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p>The <code>replacement</code> can access the match groups by using <code>$</code> and the number of the group, for example,\n<code>$1</code> to access the first group.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">replace("abcd", "(ab)|(a)", "[1=$1][2=$2]")\n// "[1=ab][2=]cd"\n\nreplace("0123456789", "(\\d{3})(\\d{3})(\\d{4})", "($1) $2-$3")\n// "(012) 345-6789"\n</code></pre>\n'},{name:"replace(input, pattern, replacement, flags)",description:'<p>Returns the resulting string after replacing all occurrences of <code>pattern</code> with <code>replacement</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">replace(input: string, pattern: string, replacement: string, flags: string): string\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p>The <code>replacement</code> can access the match groups by using <code>$</code> and the number of the group, for example,\n<code>$1</code> to access the first group.</p>\n<p>The <code>flags</code> can contain one or more of the following characters:</p>\n<ul>\n<li><code>s</code> (dot-all)</li>\n<li><code>m</code> (multi-line)</li>\n<li><code>i</code> (case insensitive)</li>\n<li><code>x</code> (comments)</li>\n</ul>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">replace("How do you feel?", "Feel", "FEEL", "i")\n// "How do you FEEL?"\n</code></pre>\n'},{name:"split(string, delimiter)",description:'<p>Splits the given value into a list of substrings, breaking at each occurrence of the <code>delimiter</code> pattern.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">split(string: string, delimiter: string): list<string>\n</code></pre>\n<p>The <code>delimiter</code> is a string that contains a regular expression.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">split("John Doe", "\\s" )\n// ["John", "Doe"]\n\nsplit("a;b;c;;", ";")\n// ["a", "b", "c", "", ""]\n</code></pre>\n'},{name:"extract(string, pattern)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns all matches of the pattern in the given string. Returns an empty list if the pattern doesn't\nmatch.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">extract(string: string, pattern: string): list<string>\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">extract("references are 1234, 1256, 1378", "12[0-9]*")\n// ["1234","1256"]\n</code></pre>\n'},{name:"trim(string)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns the given string without leading and trailing spaces.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">trim(string: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">trim(" hello world ")\n// "hello world"\n\ntrim("hello world ")\n// "hello world"\n</code></pre>\n'},{name:"uuid()",description:'<p><em>Camunda Extension</em></p>\n<p>Returns a UUID (Universally Unique Identifier) with 36 characters.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">uuid(): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">uuid()\n// "7793aab1-d761-4d38-916b-b7270e309894"\n</code></pre>\n'},{name:"to base64(value)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns the given string encoded in Base64 format.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">to base64(value: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">to base64("FEEL")\n// "RkVFTA=="\n</code></pre>\n'},{name:"is blank(string)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns <code>true</code> if the given string is blank (empty or contains only whitespaces).</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">is blank(string: string): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">is blank("")\n// true\n\nis blank(" ")\n// true\n\nis blank("hello world")\n// false\n</code></pre>\n'},{name:"now()",description:'<p>Returns the current date and time including the timezone.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">now(): date and time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">now()\n// date and time("2020-07-31T14:27:30@Europe/Berlin")\n</code></pre>\n'},{name:"today()",description:'<p>Returns the current date.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">today(): date\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">today()\n// date("2020-07-31")\n</code></pre>\n'},{name:"day of week(date)",description:'<p>Returns the day of the week according to the Gregorian calendar. Note that it always returns the English name of the day.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">day of week(date: date): string\n</code></pre>\n<pre><code class="language-feel">day of week(date: date and time): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">day of week(date("2019-09-17"))\n// "Tuesday"\n\nday of week(date and time("2019-09-17T12:00:00"))\n// "Tuesday"\n</code></pre>\n'},{name:"day of year(date)",description:'<p>Returns the Gregorian number of the day within the year.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">day of year(date: date): number\n</code></pre>\n<pre><code class="language-feel">day of year(date: date and time): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">day of year(date("2019-09-17"))\n// 260\n\nday of year(date and time("2019-09-17T12:00:00"))\n// 260\n</code></pre>\n'},{name:"week of year(date)",description:'<p>Returns the Gregorian number of the week within the year, according to ISO 8601.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">week of year(date: date): number\n</code></pre>\n<pre><code class="language-feel">week of year(date: date and time): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">week of year(date("2019-09-17"))\n// 38\n\nweek of year(date and time("2019-09-17T12:00:00"))\n// 38\n</code></pre>\n'},{name:"month of year(date)",description:'<p>Returns the month of the year according to the Gregorian calendar. Note that it always returns the English name of the month.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">month of year(date: date): string\n</code></pre>\n<pre><code class="language-feel">month of year(date: date and time): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">month of year(date("2019-09-17"))\n// "September"\n\nmonth of year(date and time("2019-09-17T12:00:00"))\n// "September"\n</code></pre>\n'},{name:"abs(n)",description:'<p>Returns the absolute value of a given duration.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">abs(n: days and time duration): days and time duration\n</code></pre>\n<pre><code class="language-feel">abs(n: years and months duration): years and months duration\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">abs(duration("-PT5H"))\n// "duration("PT5H")"\n\nabs(duration("PT5H"))\n// "duration("PT5H")"\n\nabs(duration("-P2M"))\n// duration("P2M")\n</code></pre>\n'},{name:"last day of month(date)",description:'<p><em>Camunda Extension</em></p>\n<p>Takes the month of the given date or date-time value and returns the last day of this month.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">last day of month(date: date): date\n</code></pre>\n<pre><code class="language-feel">last day of month(date: date and time): date\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">last day of month(date("2022-10-01"))\n// date("2022-10-31"))\n\nlast day of month(date and time("2022-10-16T12:00:00"))\n// date("2022-10-31"))\n</code></pre>\n'}].map(qm);(class extends Ml{constructor(e){super(),this._modeling=e}setText(e,t){this._modeling.updateProperties(e,{text:t})}}).$inject=["modeling"];function Bm(e){e.stopPropagation()}(class extends lo{constructor(e,t){super(e,t),aa(this);const{value:n}=e;this.state={value:n,optionsVisible:!1},this._portalEl=null}componentDidMount(){document.addEventListener("mousedown",this.onGlobalClick),document.addEventListener("focusin",this.onFocusChanged),this.keyboard.addListener(this.onKeyboard)}componentWillUnmount(){document.removeEventListener("focusin",this.onFocusChanged),document.removeEventListener("mousedown",this.onGlobalClick),this.keyboard.removeListener(this.onKeyboard),this.removePortalEl()}componentWillReceiveProps(e){const{value:t}=e;this.setState({value:t})}componentWillUpdate(e,t){const{optionsVisible:n}=t;n?this._portalEl||this.addPortalEl():this._portalEl&&this.removePortalEl()}componentDidUpdate(){const{optionsVisible:e}=this.state;if(!e||!this.inputNode)return;const t=this.getOptionsBounds();_(this._portalEl.style,t)}getOptionsBounds(){const e=this.renderer.getContainer(),{top:t,left:n,bottom:i}=e.getBoundingClientRect(),{top:r,left:o,width:s,height:a,bottom:l}=this.inputNode.getBoundingClientRect(),c=r+a-t+e.scrollTop,h={top:`${c}px`,left:`${o-n+e.scrollLeft}px`,width:`${s}px`,"max-height":`calc(100% - ${c}px)`};if(i-l<a){const e=i-r;h.bottom=`${e}px`,h["max-height"]=`calc(100% - ${e})`,delete h.top}return h}addPortalEl(){this._portalEl=Ft('<div class="dms-select-options"></div>');this.renderer.getContainer().appendChild(this._portalEl),this._portalEl.addEventListener("mousedown",Bm)}removePortalEl(){this._portalEl&&(this._portalEl.removeEventListener("mousedown",Bm),$t(this._portalEl),this._portalEl=null)}onChange=e=>{this.setState({value:e});const{onChange:t}=this.props;"function"==typeof t&&t(e)};onInputClick=e=>{e.preventDefault(),e.stopPropagation(),this.setOptionsVisible(!this.state.optionsVisible),this.focusInput()};onInput=e=>{const{value:t}=e.target;this.onChange(t)};onOptionClick=(e,t)=>{t.preventDefault(),t.stopPropagation(),this.setOptionsVisible(!1),this.onChange(e),this.focusInput()};focusInput(){const e=this.inputNode;e.focus(),"selectionStart"in e&&(e.selectionStart=1e5)}checkClose(e){!this._portalEl||this._portalEl.contains(e)||this.parentNode.contains(e)||this.setOptionsVisible(!1)}onFocusChanged=e=>{this.checkClose(e.target)};onGlobalClick=e=>{this.checkClose(e.target)};select(e){const{options:t}=this.props,{value:n}=this.state;if(!t)return;const i=t.filter((e=>e.value===n))[0],r=i?t.indexOf(i):-1,o=-1===r?1===e?0:t.length-1:(r+e)%t.length,s=t[o<0?t.length+o:o];this.onChange(s.value)}setOptionsVisible(e){this.setState({optionsVisible:e})}onKeyDown=e=>{const{optionsVisible:t}=this.state;var n=e.which;40!==n&&38!==n||(e.stopPropagation(),e.preventDefault(),t?this.select(40===n?1:-1):this.setOptionsVisible(!0)),t&&(13!==n&&27!==n||(e.stopPropagation(),e.preventDefault(),this.setOptionsVisible(!1)))};onKeyboard=e=>{const{optionsVisible:t}=this.state;if(t)return 27===e?(this.setOptionsVisible(!1),!0):void 0};renderOptions(e,t){return Ui(1,"div","options",e.map((e=>Ui(1,"div",["option",t===e?"active":""].join(" "),e.label,0,{"data-value":e.value,onClick:t=>this.onOptionClick(e.value,t)}))),0)}render(){const{className:e,label:t,id:n,options:i,noInput:r,title:o}=this.props,{optionsVisible:s,value:a}=this.state,l=!!i&&i.filter((e=>e.value===a))[0],c=l?l.label:a;return Ui(1,"div",[e||"","dms-input-select"].join(" "),[r?Ui(1,"div","dms-input",c,0,{"aria-label":t,tabIndex:"0",onKeyDown:this.onKeyDown},null,(e=>this.inputNode=e)):Ui(64,"input","dms-input",null,1,{"aria-label":t,onInput:this.onInput,onKeyDown:this.onKeyDown,spellCheck:"false",type:"text",value:a,id:n},null,(e=>this.inputNode=e)),Ui(1,"span",["dms-input-select-icon",s?"dmn-icon-up":"dmn-icon-down"].join(" ")),s&&(h=this.renderOptions(i,l),u=this._portalEl,Ui(1024,u,null,h,0,null,Di(h)?null:h.key,null))],0,{title:o,onClick:this.onInputClick},null,(e=>this.parentNode=e));var h,u}}).$inject=["keyboard","renderer"];return class extends Wt{_getViewProviders(){return[{id:"drd",constructor:Vs,opens(e){return bi(e,"dmn:Definitions")&&((t=e).dmnDI&&t.dmnDI.diagrams&&t.dmnDI.diagrams[0]);var t}},{id:"decisionTable",constructor:Ja,opens:e=>bi(e,"dmn:Decision")&&bi(e.decisionLogic,"dmn:DecisionTable")},{id:"literalExpression",constructor:wl,opens:e=>bi(e,"dmn:Decision")&&bi(e.decisionLogic,"dmn:LiteralExpression")},{id:"boxedExpression",constructor:Gl,opens:e=>bi(e,"dmn:BusinessKnowledgeModel")&&_i(e)}]}}})); function
|
H A D | dmn-modeler.production.min.js | 15 */function Is(e){var t=Gt('<a href="http://bpmn.io" target="_blank" class="bjs-powered-by" title="Powered by bpmn.io" style="position: absolute; bottom: 15px; right: 15px; z-index: 100;">'+js+"</a>");e.appendChild(t),zt.bind(t,"click",(function(e){!function(){Ns||(Ns=Gt(qs),Wt.bind(Ns,".backdrop","click",(function(e){document.body.removeChild(Ns)})));document.body.appendChild(Ns)}(),e.preventDefault()}))}class Bs extends Ds{constructor(e,t){super(e,t),this.node=null}componentDidMount(){Is(this.node)}render(){return vr(1,"div",null,null,1,null,null,(e=>this.node=e))}}function Ls(e){return e.join(";")}var Ns,qs='<div class="bjs-powered-by-lightbox" style="'+Ls(["z-index: 1001","position: fixed","top: 0","left: 0","right: 0","bottom: 0"])+'"><div class="backdrop" style="'+Ls(["width: 100%","height: 100%","background: rgba(40,40,40,0.2)"])+'"></div><div class="notice" style="'+Ls(["position: absolute","left: 50%","top: 40%","transform: translate(-50%)","width: 260px","padding: 10px","background: white","box-shadow: 0 1px 4px rgba(0,0,0,0.3)","font-family: Helvetica, Arial, sans-serif","font-size: 14px","display: flex","line-height: 1.3"])+'"><a href="https://bpmn.io" target="_blank" rel="noopener" style="margin: 15px 20px 15px 10px; align-self: center;">'+js+'</a><span>Web-based tooling for BPMN, DMN and CMMN diagrams powered by <a href="https://bpmn.io" target="_blank" rel="noopener">bpmn.io</a>.</span></div></div>';var Vs=new un,Fs="hsl(225, 10%, 15%)";function zs(e,t,n,i,o,r){Mn.call(this,t);var a=Vs.next(),l=i.computeStyle,c={},u=e&&e.defaultFillColor||"white",h=e&&e.defaultStrokeColor||Fs,d=e&&e.defaultLabelColor;function p(e,t,n){var i=e+"-"+Hs(t)+"-"+Hs(n)+"-"+a;return c[i]||function(e,t,n,i){if("association-start"===t){var o=Qn("path");jn(o,{d:"M 11 5 L 1 10 L 11 15"}),f(e,{element:o,attrs:{fill:"none",stroke:i,strokeWidth:1.5},ref:{x:1,y:10},scale:.5})}else if("association-end"===t){var r=Qn("path");jn(r,{d:"M 1 5 L 11 10 L 1 15"}),f(e,{element:r,attrs:{fill:"none",stroke:i,strokeWidth:1.5},ref:{x:12,y:10},scale:.5})}else if("information-requirement-end"===t){var s=Qn("path");jn(s,{d:"M 1 5 L 11 10 L 1 15 Z"}),f(e,{element:s,attrs:{fill:i,stroke:"none"},ref:{x:11,y:10},scale:1})}else if("knowledge-requirement-end"===t){var a=Qn("path");jn(a,{d:"M 1 3 L 11 10 L 1 17"}),f(e,{element:a,attrs:{fill:"none",stroke:i,strokeWidth:2},ref:{x:11,y:10},scale:.8})}else if("authority-requirement-end"===t){var l=Qn("circle");jn(l,{cx:3,cy:3,r:3}),f(e,{element:l,attrs:{fill:i,stroke:"none"},ref:{x:3,y:3},scale:.9})}}(i,e,0,n),"url(#"+i+")"}function f(e,t){var n=M({strokeWidth:1,strokeLinecap:"round",strokeDasharray:"none"},t.attrs),i=t.ref||{x:0,y:0},o=t.scale||1;"none"===n.strokeDasharray&&(n.strokeDasharray=[1e4,1]);var s=Qn("marker");jn(t.element,n),An(s,t.element),jn(s,{id:e,viewBox:"0 0 20 20",refX:i.x,refY:i.y,markerWidth:20*o,markerHeight:20*o,orient:"auto"});var a=Zt("defs",r._svg);a||(a=Qn("defs"),An(r._svg,a)),An(a,s),c[e]=s}function g(e,t,n,i,o,r){s(o)&&(r=o,o=0),o=o||0,r=l(r,{stroke:Fs,strokeWidth:2,fill:"white"});var a=Qn("rect");return jn(a,{x:o,y:o,width:t-2*o,height:n-2*o,rx:i,ry:i}),jn(a,r),An(e,a),a}function m(e,t,n){var i=o.createText(t||"",n);return Pt(i,"class","djs-label"),An(e,i),i}function v(e,t,n,i){var o=function(e){return fn(e).name}(t);return m(e,o,i=M({box:t,align:n,padding:5,style:{fill:Xs(t,d,h)}},i))}function y(e,t,n){n=l(n,["no-fill"],{strokeWidth:2,stroke:Fs});var i=Qn("path");return jn(i,{d:t}),jn(i,n),An(e,i),i}var x={"dmn:Decision":function(e,t){var n=g(e,t.width,t.height,0,{stroke:Ws(t,h),fill:Us(t,u)});return v(e,t,"center-middle"),n},"dmn:KnowledgeSource":function(e,t){var i=y(e,n.getScaledPath("KNOWLEDGE_SOURCE",{xScaleFactor:1.021,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:0,my:.075}}),{strokeWidth:2,fill:Us(t,u),stroke:Ws(t,h)});return v(e,t,"center-middle"),i},"dmn:BusinessKnowledgeModel":function(e,t){var i=y(e,n.getScaledPath("BUSINESS_KNOWLEDGE_MODEL",{xScaleFactor:1,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:0,my:.3}}),{strokeWidth:2,fill:Us(t,u),stroke:Ws(t,h)});return v(e,t,"center-middle"),i},"dmn:InputData":function(e,t){var n=g(e,t.width,t.height,22,{stroke:Ws(t,h),fill:Us(t,u)});return v(e,t,"center-middle"),n},"dmn:TextAnnotation":function(e,t){var i=g(e,t.width,t.height,0,0,{fill:"none",stroke:"none"});return y(e,n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:0,my:0}}),{stroke:Ws(t,h)}),m(e,Qs(t).text||"",{style:{fill:Xs(t,d,h)},box:t,align:"left-top",padding:5}),i},"dmn:Association":function(e,t){var n=Qs(t),i=Us(t,u),o=Ws(t,h),r={stroke:o,strokeDasharray:"0.5, 5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"};return"One"!==n.associationDirection&&"Both"!==n.associationDirection||(r.markerEnd=p("association-end",i,o)),"Both"===n.associationDirection&&(r.markerStart=p("association-start",i,o)),b(e,t.waypoints,r)},"dmn:InformationRequirement":function(e,t){var n=Us(t,u),i=Ws(t,h),o={stroke:i,strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:p("information-requirement-end",n,i)};return b(e,t.waypoints,o)},"dmn:KnowledgeRequirement":function(e,t){var n=Us(t,u),i=Ws(t,h),o={stroke:i,strokeWidth:1,strokeDasharray:5,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:p("knowledge-requirement-end",n,i)};return b(e,t.waypoints,o)},"dmn:AuthorityRequirement":function(e,t){var n=Us(t,u),i=Ws(t,h),o={stroke:i,strokeWidth:1.5,strokeDasharray:5,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:p("authority-requirement-end",n,i)};return b(e,t.waypoints,o)}};function b(e,t,n){var i=ci(t,n=l(n,["no-fill"],{stroke:Fs,strokeWidth:2,fill:"none"}));return An(e,i),i}this.canRender=function(e){return hn(e,"dmn:DMNElement")||hn(e,"dmn:InformationRequirement")||hn(e,"dmn:KnowledgeRequirement")||hn(e,"dmn:AuthorityRequirement")},this.drawShape=function(e,t){var n=x[t.type];return n?n(e,t):Mn.prototype.drawShape.apply(this,[e,t])},this.drawConnection=function(e,t){var n=t.type,i=x[n];return i?i(e,t):Mn.prototype.drawConnection.apply(this,[e,t])}}function Qs(e){return e.businessObject}function Hs(e){return e.replace(/[^0-9a-zA-z]+/g,"_")}function Ws(e,t){return t}function Us(e,t){return t}function Xs(e,t,n){return t||Ws(0,n)}yn(zs,Mn),zs.$inject=["config.drdRenderer","eventBus","pathMap","styles","textRenderer","canvas"];var Ks=0,Gs={width:150,height:50};function Ys(e,t){var n;t.textContent=e;try{var i,o=""===e;return t.textContent=o?"dummy":e,i={width:(n=t.getBBox()).width+2*n.x,height:n.height},o&&(i.width=0),i}catch(e){return console.log(e),{width:0,height:0}}}function Zs(e,t,n){for(var i,o=e.shift(),r=o;;){if((i=Ys(r,n)).width=r?i.width:0," "===r||""===r||i.width<Math.round(t)||r.length<2)return Js(e,r,o,i);r=ta(r,i.width,t)}}function Js(e,t,n,i){if(t.length<n.length){var o=n.slice(t.length).trim();e.unshift(o)}return{width:i.width,height:i.height,text:t}}var ea="";function ta(e,t,n){var i=Math.max(e.length*(n/t),1),o=function(e,t){var n,i=e.split(/(\s|-|\u00AD)/g),o=[],r=0;if(i.length>1)for(;n=i.shift();){if(!(n.length+r<t)){"-"!==n&&n!==ea||o.pop();break}o.push(n),r+=n.length}var s=o[o.length-1];return s&&s===ea&&(o[o.length-1]="-"),o.join("")}(e,i);return o||(o=e.slice(0,Math.max(Math.round(i-1),1))),o}function na(e){this._config=M({},{size:Gs,padding:Ks,style:{},align:"center-top"},e||{})}na.prototype.createText=function(e,t){return this.layoutText(e,t).element},na.prototype.getDimensions=function(e,t){return this.layoutText(e,t).dimensions},na.prototype.layoutText=function(e,t){var n=M({},this._config.size,t.box),i=M({},this._config.style,t.style),o=function(e){var t=e.split("-");return{horizontal:t[0]||"center",vertical:t[1]||"top"}}(t.align||this._config.align),r=function(e){return s(e)?M({top:0,left:0,right:0,bottom:0},e):{top:e,left:e,right:e,bottom:e}}(void 0!==t.padding?t.padding:this._config.padding),a=t.fitBox||!1,l=function(e){if("fontSize"in e&&"lineHeight"in e)return e.lineHeight*parseInt(e.fontSize,10)}(i),c=e.split(/\u00AD?\r?\n/),u=[],h=n.width-r.left-r.right,d=Qn("text");for(jn(d,{x:0,y:0}),jn(d,i),An(function(){var e=document.getElementById("helper-svg");return e||(jn(e=Qn("svg"),{id:"helper-svg"}),At(e,{visibility:"hidden",position:"fixed",width:0,height:0}),document.body.appendChild(e)),e}(),d);c.length;)u.push(Zs(c,h,d));"middle"===o.vertical&&(r.top=r.bottom=0);var g=f(u,(function(e,t,n){return e+(l||t.height)}),0)+r.top+r.bottom,m=f(u,(function(e,t,n){return t.width>e?t.width:e}),0),v=r.top;"middle"===o.vertical&&(v+=(n.height-g)/2),v-=(l||u[0].height)/4;var y=Qn("text");return jn(y,i),p(u,(function(e){var t;switch(v+=l||e.height,o.horizontal){case"left":t=r.left;break;case"right":t=(a?m:h)-r.right-e.width;break;default:t=Math.max(((a?m:h)-e.width)/2+r.left,0)}var n=Qn("tspan");jn(n,{x:t,y:v}),n.textContent=e.text,An(y,n)})),ti(d),{dimensions:{width:m,height:g},element:y}};function ia(e){var t=M({fontFamily:"Arial, sans-serif",fontSize:12,fontWeight:"normal",lineHeight:1.2},e&&e.defaultStyle||{}),n=parseInt(t.fontSize,10)-1,i=M({},t,{fontSize:n},e&&e.externalStyle||{}),o=new na({style:t});this.getExternalLabelBounds=function(e,t){var n=o.getDimensions(t,{box:{width:90,height:30,x:e.width/2+e.x,y:e.height/2+e.y},style:i});return{x:Math.round(e.x+e.width/2-n.width/2),y:Math.round(e.y),width:Math.ceil(n.width),height:Math.ceil(n.height)}},this.getTextAnnotationBounds=function(e,n){var i=o.getDimensions(n,{box:e,style:t,align:"left-top",padding:5});return{x:e.x,y:e.y,width:e.width,height:Math.max(30,Math.round(i.height))}},this.createText=function(e,t){return o.createText(e,t||{})},this.getDefaultStyle=function(){return t},this.getExternalStyle=function(){return i}}ia.$inject=["config.textRenderer"];var oa=/\{([^{}]+)\}/g,ra=/(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g;var sa={__init__:["drdRenderer"],drdRenderer:["type",zs],textRenderer:["type",ia],pathMap:["type",function(){this.pathMap={KNOWLEDGE_SOURCE:{d:"m {mx},{my} l 0,{e.y0} c {e.x0},{e.y1} {e.x1},-{e.y2} {e.x2},-{e.y3} c {e.x3},-{e.y4} {e.x4},{e.y5} {e.x5},{e.y6} l 0,-{e.y7}z",width:100,height:65,widthElements:[29.8,48.4,67.2,12.2,19.8,30.8],heightElements:[55.3,19.7,4.2,6.7,2.3,1.6,6.2,54.6]},BUSINESS_KNOWLEDGE_MODEL:{d:"m {mx},{my} l {e.x0},-{e.y0} l {e.x1},0 l 0,{e.y1} l -{e.x2},{e.y2} l -{e.x3},0z",width:125,height:45,widthElements:[13.8,109.2,13.8,109.1],heightElements:[13.2,29.8,13.2]},TEXT_ANNOTATION:{d:"m {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0",width:10,height:30,widthElements:[10],heightElements:[30]}},this.getRawPath=function(e){return this.pathMap[e].d},this.getScaledPath=function(e,t){var n,i,o=this.pathMap[e];t.abspos?(n=t.abspos.x,i=t.abspos.y):(n=t.containerWidth*t.position.mx,i=t.containerHeight*t.position.my);var r={};if(t.position){for(var s=t.containerHeight/o.height*t.yScaleFactor,a=t.containerWidth/o.width*t.xScaleFactor,l=0;l<o.heightElements.length;l++)r["y"+l]=o.heightElements[l]*s;for(var c=0;c<o.widthElements.length;c++)r["x"+c]=o.widthElements[c]*a}var u,h,d=(u=o.d,h={mx:n,my:i,e:r},String(u).replace(oa,(function(e,t){return function(e,t,n){var i=n;return t.replace(ra,(function(e,t,n,o,r){t=t||o,i&&(t in i&&(i=i[t]),"function"==typeof i&&r&&(i=i()))})),i=(null==i||i==n?e:i)+""}(e,t,h)})));return d}}]};function aa(e,t,n,i){this._eventBus=e,this._canvas=t,this._elementRegistry=i,this._elementFactory=n}function la(e,t){return M({id:e.id,type:e.$type,businessObject:e},t)}function ca(e){return e.split("#").pop()}aa.$inject=["eventBus","canvas","elementFactory","elementRegistry"],aa.prototype.root=function(e){var t=this._elementFactory.createRoot(la(e));return this._canvas.setRootElement(t),t},aa.prototype.add=function(e){var t,n,i,o,r,s,a=this._elementFactory,l=this._canvas,c=this._eventBus,u=e.di;if(u.$instanceOf("dmndi:DMNShape"))s=u.bounds,r=la(e,{x:Math.round(s.x),y:Math.round(s.y),width:Math.round(s.width),height:Math.round(s.height)}),t=a.createShape(r),l.addShape(t),c.fire("drdElement.added",{element:t,di:u});else{if(!u.$instanceOf("dmndi:DMNEdge"))throw new Error("unknown di for element "+e.id);n=function(e){var t=e.waypoint;if(t)return v(t,(function(e){var t={x:e.x,y:e.y};return M({original:t},t)}))}(u),i=this._getSource(e),o=this._getTarget(e),i&&o&&(r=la(e,{hidden:!1,source:i,target:o,waypoints:n}),t=a.createConnection(r),l.addConnection(t),c.fire("drdElement.added",{element:t,di:u}))}return t},aa.prototype._getSource=function(e){var t,n;if(hn(e,"dmn:Association")?n=e.sourceRef:hn(e,"dmn:InformationRequirement")?n=e.requiredDecision||e.requiredInput:hn(e,"dmn:KnowledgeRequirement")?n=e.requiredKnowledge:hn(e,"dmn:AuthorityRequirement")&&(n=e.requiredDecision||e.requiredInput||e.requiredAuthority),n&&(t=n.href),t)return this._getShape(ca(t))},aa.prototype._getTarget=function(e){return hn(e,"dmn:Association")?e.targetRef&&this._getShape(ca(e.targetRef.href)):this._getShape(e.$parent.id)},aa.prototype._getShape=function(e){return this._elementRegistry.get(e)};var ua={__depends__:[sa,{drdImporter:["type",aa]}]};var ha={translate:["value",function(e,t){return t=t||{},e.replace(/{([^}]+)}/g,(function(e,n){return t[n]||"{"+n+"}"}))}]};function da(e){e&&"function"==typeof e.stopPropagation&&e.stopPropagation()}function pa(e){return e.originalEvent||e.srcEvent}function fa(e){da(e),da(pa(e))}function ga(e){return e.pointers&&e.pointers.length&&(e=e.pointers[0]),e.touches&&e.touches.length&&(e=e.touches[0]),e?{x:e.clientX,y:e.clientY}:null}function ma(){return/mac/i.test(navigator.platform)}function va(e,t){return(pa(e)||e).button===t}function ya(e){return va(e,0)}function xa(e){var t=pa(e)||e;return!!ya(e)&&(ma()?t.metaKey:t.ctrlKey)}function ba(e){var t=pa(e)||e;return ya(e)&&t.shiftKey}function _a(e){return!0}function wa(e){return ya(e)||function(e){return va(e,1)}(e)}function Ca(e,t,n){var i=this;function o(n,i,o){var r,s;(function(e,t){var n=l[e]||ya;return!n(t)})(n,i)||(o?s=t.getGraphics(o):(r=i.delegateTarget||i.target)&&(s=r,o=t.get(s)),s&&o&&!1===e.fire(n,{element:o,gfx:s,originalEvent:i})&&(i.stopPropagation(),i.preventDefault()))}var r={};function s(e){return r[e]}var a={click:"element.click",contextmenu:"element.contextmenu",dblclick:"element.dblclick",mousedown:"element.mousedown",mousemove:"element.mousemove",mouseover:"element.hover",mouseout:"element.out",mouseup:"element.mouseup"},l={"element.contextmenu":_a,"element.mousedown":wa,"element.mouseup":wa,"element.click":wa,"element.dblclick":wa};var c="svg, .djs-element";function u(e,t,n,i){var s=r[n]=function(e){o(n,e)};i&&(l[n]=i),s.$delegate=Wt.bind(e,c,t,s)}function h(e,t,n){var i=s(n);i&&Wt.unbind(e,t,i.$delegate)}e.on("canvas.destroy",(function(e){!function(e){p(a,(function(t,n){h(e,n,t)}))}(e.svg)})),e.on("canvas.init",(function(e){!function(e){p(a,(function(t,n){u(e,n,t)}))}(e.svg)})),e.on(["shape.added","connection.added"],(function(t){var n=t.element,i=t.gfx;e.fire("interactionEvents.createHit",{element:n,gfx:i})})),e.on(["shape.changed","connection.changed"],500,(function(t){var n=t.element,i=t.gfx;e.fire("interactionEvents.updateHit",{element:n,gfx:i})})),e.on("interactionEvents.createHit",500,(function(e){var t=e.element,n=e.gfx;i.createDefaultHit(t,n)})),e.on("interactionEvents.updateHit",(function(e){var t=e.element,n=e.gfx;i.updateDefaultHit(t,n)}));var d=m("djs-hit djs-hit-stroke"),f=m("djs-hit djs-hit-click-stroke"),g={all:m("djs-hit djs-hit-all"),"click-stroke":f,stroke:d,"no-move":m("djs-hit djs-hit-no-move")};function m(e,t){return t=M({stroke:"white",strokeWidth:15},t||{}),n.cls(e,["no-fill","no-border"],t)}function v(e,t){var n=g[t];if(!n)throw new Error("invalid hit type <"+t+">");return jn(e,n),e}function y(e,t){An(e,t)}this.removeHits=function(e){p(Jt(".djs-hit",e),ti)},this.createDefaultHit=function(e,t){var n,i=e.waypoints,o=e.isFrame;return i?this.createWaypointsHit(t,i):(n=o?"stroke":"all",this.createBoxHit(t,n,{width:e.width,height:e.height}))},this.createWaypointsHit=function(e,t){var n=ci(t);return v(n,"stroke"),y(e,n),n},this.createBoxHit=function(e,t,n){n=M({x:0,y:0},n);var i=Qn("rect");return v(i,t),jn(i,n),y(e,i),i},this.updateDefaultHit=function(e,t){var n=Zt(".djs-hit",t);if(n)return e.waypoints?ui(n,e.waypoints):jn(n,{width:e.width,height:e.height}),n},this.fire=o,this.triggerMouseEvent=function(e,t,n){var i=a[e];if(!i)throw new Error("unmapped DOM event name <"+e+">");return o(i,t,n)},this.mouseHandler=s,this.registerEvent=u,this.unregisterEvent=h}Ca.$inject=["eventBus","elementRegistry","styles"];var Oa={__init__:["interactionEvents"],interactionEvents:["type",Ca]};function ka(e,t){this._eventBus=e,this._canvas=t,this._selectedElements=[];var n=this;e.on(["shape.remove","connection.remove"],(function(e){var t=e.element;n.deselect(t)})),e.on(["diagram.clear","root.set"],(function(e){n.select(null)}))}ka.$inject=["eventBus","canvas"],ka.prototype.deselect=function(e){var t=this._selectedElements,n=t.indexOf(e);if(-1!==n){var i=t.slice();t.splice(n,1),this._eventBus.fire("selection.changed",{oldSelection:i,newSelection:t})}},ka.prototype.get=function(){return this._selectedElements},ka.prototype.isSelected=function(e){return-1!==this._selectedElements.indexOf(e)},ka.prototype.select=function(e,t){var n=this._selectedElements,i=n.slice();r(e)||(e=e?[e]:[]);var o=this._canvas,s=o.getRootElement();e=e.filter((function(e){var t=o.findRoot(e);return s===t})),t?p(e,(function(e){-1===n.indexOf(e)&&n.push(e)})):this._selectedElements=n=e.slice(),this._eventBus.fire("selection.changed",{oldSelection:i,newSelection:n})};var Ea="hover",Sa="selected";function Ra(e,t){function n(t,n){e.addMarker(t,n)}function i(t,n){e.removeMarker(t,n)}this._canvas=e,t.on("element.hover",(function(e){n(e.element,Ea)})),t.on("element.out",(function(e){i(e.element,Ea)})),t.on("selection.changed",(function(e){var t=e.oldSelection,o=e.newSelection;p(t,(function(e){-1===o.indexOf(e)&&function(e){i(e,Sa)}(e)})),p(o,(function(e){-1===t.indexOf(e)&&function(e){n(e,Sa)}(e)}))}))}function Ta(e,t,n,i){e.on("create.end",500,(function(e){var n=e.context,i=n.canExecute,o=n.elements,s=(n.hints||{}).autoSelect;if(i){if(!1===s)return;r(s)?t.select(s):t.select(o.filter(Ma))}})),e.on("connect.end",500,(function(e){var n=e.context.connection;n&&t.select(n)})),e.on("shape.move.end",500,(function(e){var n=e.previousSelection||[],o=i.get(e.context.shape.id);h(n,(function(e){return o.id===e.id}))||t.select(o)})),e.on("element.click",(function(e){if(ya(e)){var i=e.element;i===n.getRootElement()&&(i=null);var o=t.isSelected(i),r=t.get().length>1,s=ba(e);if(o&&r)return s?t.deselect(i):t.select(i);o?t.deselect(i):t.select(i,s)}}))}function Ma(e){return!e.hidden}Ra.$inject=["canvas","eventBus"],Ta.$inject=["eventBus","selection","canvas","elementRegistry"];var Aa={__init__:["selectionVisuals","selectionBehavior"],__depends__:[Oa],selection:["type",ka],selectionVisuals:["type",Ra],selectionBehavior:["type",Ta]};function Pa(e){this._counter=0,this._prefix=(e?e+"-":"")+Math.floor(1e9*Math.random())+"-"}Pa.prototype.next=function(){return this._prefix+ ++this._counter};var Da=new Pa("ov");function $a(e,t,n,i){var o,r;this._eventBus=t,this._canvas=n,this._elementRegistry=i,this._ids=Da,this._overlayDefaults=M({show:null,scale:!0},e&&e.defaults),this._overlays={},this._overlayContainers=[],this._overlayRoot=(o=n.getContainer(),At(r=Gt('<div class="djs-overlay-container" />'),{position:"absolute",width:0,height:0}),o.insertBefore(r,o.firstChild),r),this._init()}function ja(e,t,n){At(e,{left:t+"px",top:n+"px"})}function Ia(e,t){e.style.display=!1===t?"none":""}function Ba(e,t){e.style["transform-origin"]="top left",["","-ms-","-webkit-"].forEach((function(n){e.style[n+"transform"]=t}))}$a.$inject=["config.overlays","eventBus","canvas","elementRegistry"],$a.prototype.get=function(e){if(c(e)&&(e={id:e}),c(e.element)&&(e.element=this._elementRegistry.get(e.element)),e.element){var t=this._getOverlayContainer(e.element,!0);return t?e.type?d(t.overlays,C({type:e.type})):t.overlays.slice():[]}return e.type?d(this._overlays,C({type:e.type})):e.id?this._overlays[e.id]:null},$a.prototype.add=function(e,t,n){if(s(t)&&(n=t,t=null),e.id||(e=this._elementRegistry.get(e)),!n.position)throw new Error("must specifiy overlay position");if(!n.html)throw new Error("must specifiy overlay html");if(!e)throw new Error("invalid element specified");var i=this._ids.next();return n=M({},this._overlayDefaults,n,{id:i,type:t,element:e,html:n.html}),this._addOverlay(n),i},$a.prototype.remove=function(e){var t=this.get(e)||[];r(t)||(t=[t]);var n=this;p(t,(function(e){var t=n._getOverlayContainer(e.element,!0);if(e&&(en(e.html),en(e.htmlContainer),delete e.htmlContainer,delete e.element,delete n._overlays[e.id]),t){var i=t.overlays.indexOf(e);-1!==i&&t.overlays.splice(i,1)}}))},$a.prototype.isShown=function(){return"none"!==this._overlayRoot.style.display},$a.prototype.show=function(){Ia(this._overlayRoot)},$a.prototype.hide=function(){Ia(this._overlayRoot,!1)},$a.prototype.clear=function(){this._overlays={},this._overlayContainers=[],It(this._overlayRoot)},$a.prototype._updateOverlayContainer=function(e){var t=e.element,n=e.html,i=t.x,o=t.y;if(t.waypoints){var r=mi(t);i=r.x,o=r.y}ja(n,i,o),Pt(e.html,"data-container-id",t.id)},$a.prototype._updateOverlay=function(e){var t,n,i=e.position,o=e.htmlContainer,r=e.element,s=i.left,a=i.top;void 0!==i.right&&(t=r.waypoints?mi(r).width:r.width,s=-1*i.right+t);void 0!==i.bottom&&(n=r.waypoints?mi(r).height:r.height,a=-1*i.bottom+n);ja(o,s||0,a||0),this._updateOverlayVisibilty(e,this._canvas.viewbox())},$a.prototype._createOverlayContainer=function(e){var t=Gt('<div class="djs-overlays" />');At(t,{position:"absolute"}),this._overlayRoot.appendChild(t);var n={html:t,element:e,overlays:[]};return this._updateOverlayContainer(n),this._overlayContainers.push(n),n},$a.prototype._updateRoot=function(e){var t=e.scale||1,n="matrix("+[t,0,0,t,-1*e.x*t,-1*e.y*t].join(",")+")";Ba(this._overlayRoot,n)},$a.prototype._getOverlayContainer=function(e,t){var n=h(this._overlayContainers,(function(t){return t.element===e}));return n||t?n:this._createOverlayContainer(e)},$a.prototype._addOverlay=function(e){var t,n,i=e.id,o=e.element,r=e.html;r.get&&r.constructor.prototype.jquery&&(r=r.get(0)),c(r)&&(r=Gt(r)),n=this._getOverlayContainer(o),At(t=Gt('<div class="djs-overlay" data-overlay-id="'+i+'">'),{position:"absolute"}),t.appendChild(r),e.type&&$t(t).add("djs-overlay-"+e.type),Ia(t,this._canvas.findRoot(o)===this._canvas.getRootElement()),e.htmlContainer=t,n.overlays.push(e),n.html.appendChild(t),this._overlays[i]=e,this._updateOverlay(e),this._updateOverlayVisibilty(e,this._canvas.viewbox())},$a.prototype._updateOverlayVisibilty=function(e,t){var n=e.show,o=this._canvas.findRoot(e.element),r=n&&n.minZoom,s=n&&n.maxZoom,a=e.htmlContainer,l=!0;(o!==this._canvas.getRootElement()||n&&(i(r)&&r>t.scale||i(s)&&s<t.scale))&&(l=!1),Ia(a,l),this._updateOverlayScale(e,t)},$a.prototype._updateOverlayScale=function(e,t){var n,o,r,s=e.scale,a=e.htmlContainer,l="";!0!==s&&(!1===s?(n=1,o=1):(n=s.min,o=s.max),i(n)&&t.scale<n&&(r=(1/t.scale||1)*n),i(o)&&t.scale>o&&(r=(1/t.scale||1)*o)),i(r)&&(l="scale("+r+","+r+")"),Ba(a,l)},$a.prototype._updateOverlaysVisibilty=function(e){var t=this;p(this._overlays,(function(n){t._updateOverlayVisibilty(n,e)}))},$a.prototype._init=function(){var e=this._eventBus,t=this;e.on("canvas.viewbox.changing",(function(e){t.hide()})),e.on("canvas.viewbox.changed",(function(e){var n;n=e.viewbox,t._updateRoot(n),t._updateOverlaysVisibilty(n),t.show()})),e.on(["shape.remove","connection.remove"],(function(e){var n=e.element;p(t.get({element:n}),(function(e){t.remove(e.id)}));var i=t._getOverlayContainer(n);if(i){en(i.html);var o=t._overlayContainers.indexOf(i);-1!==o&&t._overlayContainers.splice(o,1)}})),e.on("element.changed",500,(function(e){var n=e.element,i=t._getOverlayContainer(n,!0);i&&(p(i.overlays,(function(e){t._updateOverlay(e)})),t._updateOverlayContainer(i))})),e.on("element.marker.update",(function(e){var n=t._getOverlayContainer(e.element,!0);n&&$t(n.html)[e.add?"add":"remove"](e.marker)})),e.on("root.set",(function(){t._updateOverlaysVisibilty(t._canvas.viewbox())})),e.on("diagram.clear",this.clear,this)};var La={__init__:["overlays"],overlays:["type",$a]};function Na(e,t,n){this._eventBus=e,this._canvas=t,this._translate=n,e.on("diagram.init",(function(){this._init()}),this),e.on("import.done",(function(e){e.error||this.update()}),this),this.HTML_MARKUP='<div class="dmn-definitions"><div class="dmn-definitions-name" title="'+this._translate("Definition name")+'" spellcheck="false"></div><div class="dmn-definitions-id" title="'+this._translate("Definition ID")+'" spellcheck="false"></div></div>'}function qa(e,t){function n(e,n){$t(t.getContainer()).toggle(e,n)}e.on("palette.create",(function(){n("with-palette",!0)})),e.on("palette.changed",(function(e){n("with-palette-two-column",e.twoColumn)}))}Na.$inject=["eventBus","canvas","translate"],Na.prototype._init=function(){var e=this._canvas,t=this._eventBus,n=e.getContainer(),i=this._container=Gt(this.HTML_MARKUP);n.appendChild(i),this.nameElement=Zt(".dmn-definitions-name",this._container),this.idElement=Zt(".dmn-definitions-id",this._container),Wt.bind(i,".dmn-definitions-name, .dmn-definitions-id","mousedown",(function(e){e.stopPropagation()})),t.fire("definitionIdView.create",{html:i})},Na.prototype.update=function(){var e=this._canvas.getRootElement().businessObject;this.nameElement.textContent=e.name,this.idElement.textContent=e.id},qa.$inject=["eventBus","canvas"];var Va={__depends__:[ha],__init__:["definitionPropertiesView","definitionPropertiesPaletteAdapter"],definitionPropertiesView:["type",Na],definitionPropertiesPaletteAdapter:["type",qa]},Fa=[{className:"dmn-icon-decision-table",matches:function(e){var t=fn(e);return hn(t,"dmn:Decision")&&hn(t.decisionLogic,"dmn:DecisionTable")},title:"Open decision table"},{className:"dmn-icon-literal-expression",matches:function(e){return hn(mn(e),"dmn:LiteralExpression")},title:"Open literal expression"}];class za{constructor(e,t,n,i,o){this._injector=e,this._eventBus=t,this._overlays=n,this._translate=o,this._config=i||{enabled:!0},t.on(["shape.added"],(({element:e})=>{for(let t=0;t<Fa.length;t++){const{matches:n,className:i,title:o}=Fa[t];n&&n(e)&&this.addOverlay(e,i,o)}}))}addOverlay(e,t,n){const i=!1!==this._config.enabled,o=this._getOverlayNode(t,n,i),r=this._overlays.add(e,{position:{top:2,left:2},html:o});i&&($t(o).add("interactive"),this.bindEventListener(e,o,r))}_getOverlayNode(e,t,n){const i=document.createElement("div");if(i.className="drill-down-overlay",!n){const t=document.createElement("span");return t.className=e,i.appendChild(t),i}const o=document.createElement("button");return o.type="button",o.className=e,o.title=this._translate(t),i.appendChild(o),i}bindEventListener(e,t,n){const i=this._overlays,o=this._eventBus,r=i._overlayRoot;Wt.bind(r,'[data-overlay-id="'+n+'"]',"click",(()=>{!1!==o.fire("drillDown.click",{element:e})&&this.drillDown(e)}))}drillDown(e){const t=this._injector.get("_parent",!1);if(!t)return!1;const n=t.getView(e.businessObject);return!!n&&(t.open(n),!0)}}za.$inject=["injector","eventBus","overlays","config.drillDown","translate"];var Qa={__depends__:[La,ha],__init__:["drillDown"],drillDown:["type",za]}; 21 */function Ha(e){this._container=this._createContainer(),Is(this._container),this._init(this._container,e)}function Wa(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function Ua(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Xa(e){return Math.log(e)/Math.log(10)}function Ka(e,t){var n=Xa(e.min),i=Xa(e.max);return(Math.abs(n)+Math.abs(i))/t}yn(Ha,Uo),Ha.prototype.saveSVG=tn((function(e){var t=this;return new Promise((function(e){var n=t.get("canvas"),i=n.getActiveLayer(),o=Zt("defs",n._svg),r=ei(i),s=o&&o.outerHTML||"",a=i.getBBox();e({svg:'<?xml version="1.0" encoding="utf-8"?>\n\x3c!-- created with dmn-js / http://bpmn.io --\x3e\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'+a.width+'" height="'+a.height+'" viewBox="'+a.x+" "+a.y+" "+a.width+" "+a.height+'" version="1.1">'+s+r+"</svg>"})}))})),Ha.prototype.getModules=function(){return this._modules},Ha.prototype.destroy=function(){Uo.prototype.destroy.call(this),en(this._container)},Ha.prototype.on=function(e,t,n,i){return this.get("eventBus").on(e,t,n,i)},Ha.prototype.off=function(e,t){this.get("eventBus").off(e,t)},Ha.prototype._init=function(e,t){var{additionalModules:n,canvas:i,...o}=t,r={...o,canvas:{...i,container:e},modules:[...[{drd:["value",this]}],...t.modules||this.getModules(),...n||[]]};Uo.call(this,r),t&&t.container&&this.attachTo(t.container)},Ha.prototype._emit=function(e,t){return this.get("eventBus").fire(e,t)},Ha.prototype._createContainer=function(){return Gt('<div class="dmn-drd-container"></div>')},Ha.prototype.open=function(e){var t=this;return new Promise(((n,i)=>{var o;try{return t._definitions&&t.clear(),t._definitions=e,function(e,t,n){var i,o=e.get("drdImporter"),r=e.get("eventBus"),s=[];r.fire("import.start",{definitions:t});try{!function(e){new Ko({root:function(e){return o.root(e)},element:function(e,t){return o.add(e,t)},error:function(e,t){s.push({message:e,context:t})}}).handleDefinitions(e)}(t)}catch(e){i=e}r.fire("import.done",{error:i,warnings:s}),n(i,s)}(t,e,(function(e,t){e?(e.warnings=t||[],i(e)):n({warnings:t||[]})}))}catch(e){o=e}o?(o.warnings=o.warnings||[],i(o)):n({warnings:[]})}))},Ha.prototype.attachTo=function(e){if(!e)throw new Error("parentNode required");this.detach();var t=this._container;e.appendChild(t),this._emit("attach",{}),this.get("canvas").resized()},Ha.prototype.detach=function(){var e=this._container,t=e.parentNode;t&&(this._emit("detach",{}),t.removeChild(e))},Ha.prototype._modules=[ua,ha,Aa,La,Va,Qa];var Ga=Math.sign||function(e){return e>=0?1:-1},Ya={min:.2,max:4};function Za(e,t,n){e=e||{},this._enabled=!1,this._canvas=n,this._container=n._container,this._handleWheel=T(this._handleWheel,this),this._totalDelta=0,this._scale=e.scale||.75;var i=this;t.on("canvas.init",(function(t){i._init(!1!==e.enabled)}))}Za.$inject=["config.zoomScroll","eventBus","canvas"],Za.prototype.scroll=function(e){this._canvas.scroll(e)},Za.prototype.reset=function(){this._canvas.zoom("fit-viewport")},Za.prototype.zoom=function(e,t){var n=Ka(Ya,20);this._totalDelta+=e,Math.abs(this._totalDelta)>.1&&(this._zoom(e,t,n),this._totalDelta=0)},Za.prototype._handleWheel=function(e){if(!Bt(e.target,".djs-scrollable",!0)){var t=this._container;e.preventDefault();var n,i=e.ctrlKey||ma()&&e.metaKey,o=e.shiftKey,r=-1*this._scale;if(r*=i?0===e.deltaMode?.02:.32:0===e.deltaMode?1:16,i){var s=t.getBoundingClientRect(),a={x:e.clientX-s.left,y:e.clientY-s.top};n=Math.sqrt(Math.pow(e.deltaY,2)+Math.pow(e.deltaX,2))*Ga(e.deltaY)*r,this.zoom(n,a)}else n=o?{dx:r*e.deltaY,dy:0}:{dx:r*e.deltaX,dy:r*e.deltaY},this.scroll(n)}},Za.prototype.stepZoom=function(e,t){var n=Ka(Ya,10);this._zoom(e,t,n)},Za.prototype._zoom=function(e,t,n){var i=this._canvas,o=e>0?1:-1,r=Xa(i.zoom()),s=Math.round(r/n)*n;s+=n*o;var a,l,c=Math.pow(10,s);i.zoom((a=Ya,l=c,Math.max(a.min,Math.min(a.max,l))),t)},Za.prototype.toggle=function(e){var t=this._container,n=this._handleWheel,i=this._enabled;return void 0===e&&(e=!i),i!==e&&zt[e?"bind":"unbind"](t,"wheel",n,!1),this._enabled=e,e},Za.prototype._init=function(e){this.toggle(e)};var Ja={__init__:["zoomScroll"],zoomScroll:["type",Za]},el=/^djs-cursor-.*$/;function tl(e){var t=$t(document.body);t.removeMatching(el),e&&t.add("djs-cursor-"+e)}function nl(){tl(null)}var il=5e3;function ol(e,t){function n(){return!1}return t=t||"element.click",e.once(t,il,n),function(){e.off(t,n)}}function rl(e,t){var n;function i(i){var o,r=n.start,s=n.button,a=ga(i),l=Ua(a,r);(!n.dragging&&(o=l,Math.sqrt(Math.pow(o.x,2)+Math.pow(o.y,2))>15)&&(n.dragging=!0,0===s&&ol(e),tl("grab")),n.dragging)&&(l=Ua(a,n.last||n.start),t.scroll({dx:l.x,dy:l.y}),n.last=a);i.preventDefault()}function o(e){zt.unbind(document,"mousemove",i),zt.unbind(document,"mouseup",o),n=null,nl()}e.on("element.mousedown",500,(function(e){return function(e){if(Bt(e.target,".djs-draggable"))return;var t=e.button;if(t>=2||e.ctrlKey||e.shiftKey||e.altKey)return;return n={button:t,start:ga(e)},zt.bind(document,"mousemove",i),zt.bind(document,"mouseup",o),!0}(e.originalEvent)})),this.isActive=function(){return!!n}}rl.$inject=["eventBus","canvas"];var sl={__init__:["moveCanvas"],moveCanvas:["type",rl]};function al(e){return CSS.escape(e)}var ll={"&":"&","<":"<",">":">",'"':""","'":"'"};var cl=["c","C"],ul=["v","V"],hl=["y","Y"],dl=["z","Z"];function pl(e){return!e.altKey&&(e.ctrlKey||e.metaKey)}function fl(e,t){return-1!==(e=r(e)?e:[e]).indexOf(t.key)||-1!==e.indexOf(t.code)}function gl(e){return e.shiftKey}function ml(e){return pl(e)&&!gl(e)&&fl(dl,e)}function vl(e){return pl(e)&&(fl(hl,e)||fl(dl,e)&&gl(e))}function yl(e,t,n,i){this._open=!1,this._results={},this._eventMaps=[],this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._canvas=e,this._eventBus=t,this._selection=n,this._translate=i,this._container=this._getBoxHtml(),this._searchInput=Zt(yl.INPUT_SELECTOR,this._container),this._resultsContainer=Zt(yl.RESULTS_CONTAINER_SELECTOR,this._container),this._canvas.getContainer().appendChild(this._container),t.on(["canvas.destroy","diagram.destroy","drag.init","elements.changed"],this.close,this)}function xl(e,t,n){var i=function(e){var t="";return e.forEach((function(e){var n,i=(n=""+(n=e.value||e.matched||e.normal))&&n.replace(/[&<>"']/g,(function(e){return ll[e]})),o=e.match||e.matched;t+=o?'<b class="'+yl.RESULT_HIGHLIGHT_CLASS+'">'+i+"</b>":i})),""!==t?t:null}(t),o=Gt(n);o.innerHTML=i,e.appendChild(o)}yl.$inject=["canvas","eventBus","selection","translate"],yl.prototype._bindEvents=function(){var e=this;function t(t,n,i,o){e._eventMaps.push({el:t,type:i,listener:Wt.bind(t,n,i,o)})}t(document,"html","click",(function(t){e.close(!1)})),t(this._container,yl.INPUT_SELECTOR,"click",(function(e){e.stopPropagation(),e.delegateTarget.focus()})),t(this._container,yl.RESULT_SELECTOR,"mouseover",(function(t){t.stopPropagation(),e._scrollToNode(t.delegateTarget),e._preselect(t.delegateTarget)})),t(this._container,yl.RESULT_SELECTOR,"click",(function(t){t.stopPropagation(),e._select(t.delegateTarget)})),t(this._container,yl.INPUT_SELECTOR,"keydown",(function(e){fl("ArrowUp",e)&&e.preventDefault(),fl("ArrowDown",e)&&e.preventDefault()})),t(this._container,yl.INPUT_SELECTOR,"keyup",(function(t){if(fl("Escape",t))return e.close();if(fl("Enter",t)){var n=e._getCurrentResult();return n?e._select(n):e.close(!1)}return fl("ArrowUp",t)?e._scrollToDirection(!0):fl("ArrowDown",t)?e._scrollToDirection():void(fl(["ArrowLeft","ArrowRight"],t)||e._search(t.delegateTarget.value))}))},yl.prototype._unbindEvents=function(){this._eventMaps.forEach((function(e){Wt.unbind(e.el,e.type,e.listener)}))},yl.prototype._search=function(e){var t=this;if(this._clearResults(),e&&""!==e){var n=this._searchProvider.find(e);if((n=n.filter((function(e){return!t._canvas.getRootElements().includes(e.element)}))).length){n.forEach((function(e){var n=e.element.id,i=t._createResultNode(e,n);t._results[n]={element:e.element,node:i}}));var i=Zt(yl.RESULT_SELECTOR,this._resultsContainer);this._scrollToNode(i),this._preselect(i)}else this._selection.select(null)}},yl.prototype._scrollToDirection=function(e){var t=this._getCurrentResult();if(t){var n=e?t.previousElementSibling:t.nextElementSibling;n&&(this._scrollToNode(n),this._preselect(n))}},yl.prototype._scrollToNode=function(e){if(e&&e!==this._getCurrentResult()){var t=e.offsetTop,n=this._resultsContainer.scrollTop,i=t-this._resultsContainer.clientHeight+e.clientHeight;t<n?this._resultsContainer.scrollTop=t:n<i&&(this._resultsContainer.scrollTop=i)}},yl.prototype._clearResults=function(){It(this._resultsContainer),this._results={},this._eventBus.fire("searchPad.cleared")},yl.prototype._getCurrentResult=function(){return Zt(yl.RESULT_SELECTED_SELECTOR,this._resultsContainer)},yl.prototype._createResultNode=function(e,t){var n=Gt(yl.RESULT_HTML);return e.primaryTokens.length>0&&xl(n,e.primaryTokens,yl.RESULT_PRIMARY_HTML),xl(n,e.secondaryTokens,yl.RESULT_SECONDARY_HTML),Pt(n,yl.RESULT_ID_ATTRIBUTE,t),this._resultsContainer.appendChild(n),n},yl.prototype.registerProvider=function(e){this._searchProvider=e},yl.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,$t(this._canvas.getContainer()).add("djs-search-open"),$t(this._container).add("open"),this._searchInput.focus(),this._eventBus.fire("searchPad.opened"))},yl.prototype.close=function(e=!0){this.isOpen()&&(e&&(this._cachedRootElement&&this._canvas.setRootElement(this._cachedRootElement),this._cachedSelection&&this._selection.select(this._cachedSelection),this._cachedViewbox&&this._canvas.viewbox(this._cachedViewbox),this._eventBus.fire("searchPad.restored")),this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._unbindEvents(),this._open=!1,$t(this._canvas.getContainer()).remove("djs-search-open"),$t(this._container).remove("open"),this._clearResults(),this._searchInput.value="",this._searchInput.blur(),this._eventBus.fire("searchPad.closed"),this._canvas.restoreFocus())},yl.prototype.toggle=function(){this.isOpen()?this.close():this.open()},yl.prototype.isOpen=function(){return this._open},yl.prototype._preselect=function(e){var t=this._getCurrentResult();if(e!==t){t&&$t(t).remove(yl.RESULT_SELECTED_CLASS);var n=Pt(e,yl.RESULT_ID_ATTRIBUTE),i=this._results[n].element;$t(e).add(yl.RESULT_SELECTED_CLASS),this._canvas.scrollToElement(i,{top:300}),this._selection.select(i),this._eventBus.fire("searchPad.preselected",i)}},yl.prototype._select=function(e){var t=Pt(e,yl.RESULT_ID_ATTRIBUTE),n=this._results[t].element;this._cachedSelection=null,this._cachedViewbox=null,this.close(!1),this._canvas.scrollToElement(n,{top:300}),this._selection.select(n),this._eventBus.fire("searchPad.selected",n)},yl.prototype._getBoxHtml=function(){const e=Gt(yl.BOX_HTML),t=Zt(yl.INPUT_SELECTOR,e);return t&&t.setAttribute("aria-label",this._translate("Search in diagram")),e},yl.CONTAINER_SELECTOR=".djs-search-container",yl.INPUT_SELECTOR=".djs-search-input input",yl.RESULTS_CONTAINER_SELECTOR=".djs-search-results",yl.RESULT_SELECTOR=".djs-search-result",yl.RESULT_SELECTED_CLASS="djs-search-result-selected",yl.RESULT_SELECTED_SELECTOR="."+yl.RESULT_SELECTED_CLASS,yl.RESULT_ID_ATTRIBUTE="data-result-id",yl.RESULT_HIGHLIGHT_CLASS="djs-search-highlight",yl.BOX_HTML='<div class="djs-search-container djs-scrollable">\n <div class="djs-search-input">\n <svg class="djs-search-icon" width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M9.0325 8.5H9.625L13.3675 12.25L12.25 13.3675L8.5 9.625V9.0325L8.2975 8.8225C7.4425 9.5575 6.3325 10 5.125 10C2.4325 10 0.25 7.8175 0.25 5.125C0.25 2.4325 2.4325 0.25 5.125 0.25C7.8175 0.25 10 2.4325 10 5.125C10 6.3325 9.5575 7.4425 8.8225 8.2975L9.0325 8.5ZM1.75 5.125C1.75 6.9925 3.2575 8.5 5.125 8.5C6.9925 8.5 8.5 6.9925 8.5 5.125C8.5 3.2575 6.9925 1.75 5.125 1.75C3.2575 1.75 1.75 3.2575 1.75 5.125Z" fill="#22242A"/>\n </svg>\n <input type="text" spellcheck="false" />\n </div>\n <div class="djs-search-results" />\n</div>',yl.RESULT_HTML='<div class="djs-search-result"></div>',yl.RESULT_PRIMARY_HTML='<div class="djs-search-result-primary"></div>',yl.RESULT_SECONDARY_HTML='<p class="djs-search-result-secondary"></p>';var bl={__depends__:[ha,La,Aa],searchPad:["type",yl]};function _l(e){return hn(e,"dmn:Decision")||hn(e,"dmn:BusinessKnowledgeModel")||hn(e,"dmn:InputData")||hn(e,"dmn:KnowledgeSource")?"name":hn(e,"dmn:TextAnnotation")?"text":void 0}function wl(e){var t=e.businessObject,n=_l(t);if(n)return t[n]||""}function Cl(e,t,n){this._elementRegistry=e,this._canvas=n,t.registerProvider(this)}function Ol(e){return d(e,(function(e){return!!e.matched})).length>0}function kl(e,t){const n=[],i=e;if(!e)return n;e=e.toLowerCase(),t=t.toLowerCase();const o=e.indexOf(t);return o>-1?(0!==o&&n.push({normal:i.substr(0,o)}),n.push({matched:i.substr(o,t.length)}),t.length+o<e.length&&n.push({normal:i.substr(t.length+o,e.length)})):n.push({normal:i}),n}Cl.$inject=["elementRegistry","searchPad","canvas"],Cl.prototype.find=function(e){const t=this._canvas.getRootElement();let n=this._elementRegistry.filter((function(e){return!e.labelTarget}));return n=d(n,(function(e){return e!==t})),n=v(n,(function(t){return{primaryTokens:kl(wl(t),e),secondaryTokens:kl(t.id,e),element:t}})),n=d(n,(function(e){return Ol(e.primaryTokens)||Ol(e.secondaryTokens)})),n=w(n,(function(e){return wl(e.element)+e.element.id})),n};var El={__depends__:[bl],__init__:["dmnSearch"],dmnSearch:["type",Cl]};function Sl(e){Ha.call(this,e)}function Rl(e){return e&&e[e.length-1]}function Tl(e){return e.y}function Ml(e){return e.x}yn(Sl,Ha),Sl.prototype._navigationModules=[Ja,sl,El],Sl.prototype._modules=[].concat(Sl.prototype._modules,Sl.prototype._navigationModules);var Al={left:Ml,center:Ml,right:function(e){return e.x+e.width},top:Tl,middle:Tl,bottom:function(e){return e.y+e.height}};function Pl(e,t){this._modeling=e,this._rules=t}Pl.$inject=["modeling","rules"],Pl.prototype._getOrientationDetails=function(e){var t="x",n="width";return-1!==["top","bottom","middle"].indexOf(e)&&(t="y",n="height"),{axis:t,dimension:n}},Pl.prototype._isType=function(e,t){return-1!==t.indexOf(e)},Pl.prototype._alignmentPosition=function(e,t){var n,i,o,r=this._getOrientationDetails(e),s=r.axis,a=r.dimension,l={},c={},u=!1;if(this._isType(e,["left","top"]))l[e]=t[0][s];else if(this._isType(e,["right","bottom"]))o=Rl(t),l[e]=o[s]+o[a];else if(this._isType(e,["center","middle"])){if(p(t,(function(e){var t=e[s]+Math.round(e[a]/2);c[t]?c[t].elements.push(e):c[t]={elements:[e],center:t}})),n=w(c,(function(e){return e.elements.length>1&&(u=!0),e.elements.length})),u)return l[e]=Rl(n).center,l;i=t[0],o=Rl(t=w(t,(function(e){return e[s]+e[a]}))),l[e]=function(e,t){return Math.round((e[s]+t[s]+t[a])/2)}(i,o)}return l},Pl.prototype.trigger=function(e,t){var n,i=this._modeling,o=d(e,(function(e){return!(e.waypoints||e.host||e.labelTarget)}));if(r(n=this._rules.allowed("elements.align",{elements:o}))&&(o=n),!(o.length<2)&&n){var s=w(o,Al[t]),a=this._alignmentPosition(t,s);i.alignElements(s,a)}};var Dl={__init__:["alignElements"],alignElements:["type",Pl]},$l=10,jl=50,Il=250;function Bl(e,t,n,i){for(var o;o=Ll(e,n,t);)n=i(t,n,o);return n}function Ll(e,t,n){var i={x:t.x-n.width/2,y:t.y-n.height/2,width:n.width,height:n.height},o=function(e){var t=Nl(e);e.host&&(t=t.concat(Nl(e.host)));e.attachers&&(t=t.concat(e.attachers.reduce((function(e,t){return e.concat(Nl(t))}),[])));return t}(e);return h(o,(function(e){return e!==n&&"intersect"===vo(e,i,$l)}))}function Nl(e){return(t=e,t.outgoing.map((function(e){return e.target}))).concat(function(e){return e.incoming.map((function(e){return e.source}))}(e));var t}function ql(){return!0}function Vl(e,t,n){e.on("autoPlace",100,(function(e){var t=e.shape;return function(e,t,n){n||(n={});var i=n.defaultDistance||jl,o=mo(e),r=po(e);return{x:r.right+i+t.width/2,y:o.y}}(e.source,t)})),e.on("autoPlace.end",(function(e){n.scrollToElement(e.shape)})),this.append=function(n,i,o){e.fire("autoPlace.start",{source:n,shape:i});var r=e.fire("autoPlace",{source:n,shape:i}),s=t.appendShape(n,i,r,n.parent,o);return e.fire("autoPlace.end",{source:n,shape:s}),s}}function Fl(e,t){e.on("autoPlace.end",500,(function(e){t.select(e.shape)}))}Vl.$inject=["eventBus","modeling","canvas"],Fl.$inject=["eventBus","selection"];var zl={__init__:["autoPlaceSelectionBehavior"],autoPlace:["type",Vl],autoPlaceSelectionBehavior:["type",Fl]},Ql={width:135,height:46},Hl={width:180,height:80},Wl={width:125,height:45},Ul={width:100,height:63};function Xl(e){qo.call(this),this._drdFactory=e}yn(Xl,qo),Xl.$inject=["drdFactory"],Xl.prototype.baseCreate=qo.prototype.create,Xl.prototype.create=function(e,t){return this.createDrdElement(e,t)},Xl.prototype.createDrdElement=function(e,t){var n,i=this._drdFactory,o=(t=t||{}).businessObject;if(!o){if(!t.type)throw new Error("no shape type specified");o=i.create(t.type)}return o.di||("connection"===e?o.di=i.createDiEdge(o,[]):"shape"===e&&(o.di=i.createDiShape(o,{}))),n=this._getDefaultSize(o),t=M({businessObject:o,id:o.id},n,t),this.baseCreate(e,t)},Xl.prototype._getDefaultSize=function(e){return hn(e,"dmn:BusinessKnowledgeModel")?Ql:hn(e,"dmn:Decision")?Hl:hn(e,"dmn:InputData")?Wl:hn(e,"dmn:KnowledgeSource")?Ul:{width:100,height:80}};var Kl="left",Gl="right",Yl=60,Zl=Hl.width;function Jl(e,t){return hn(t,"dmn:TextAnnotation")?function(e,t){var n=po(e),i={x:n.right+t.width/2,y:n.top-50-t.height/2};return Bl(e,t,i,function(e){return function(t,n,i){var o={x:n.x,y:n.y};return["x","y"].forEach((function(r){var s=e[r];if(s){var a="x"===r?"width":"height",l=s.margin,c=s.minDistance;o[r]=l<0?Math.min(i[r]+l-t[a]/2,n[r]-c+l):Math.max(i[r]+i[a]+l+t[a]/2,n[r]+c+l)}})),o}}({y:{margin:-30,minDistance:20}}))}(e,t):hn(t,"dmn:DRGElement")?function(e,t){var n=po(e),i=mo(e);function o(t){return t.target===e?1:-1}var r=function(e,t){t||(t={});var n=t.defaultDistance||jl,i=t.direction||"e",o=t.filter,r=t.getWeight||function(t){return t.source===e?1:-1},s=t.maxDistance||Il,a=t.reference||"start";function l(e,t){return"n"===i?"start"===a?po(e).top-po(t).bottom:"center"===a?po(e).top-mo(t).y:po(e).top-po(t).top:"w"===i?"start"===a?po(e).left-po(t).right:"center"===a?po(e).left-mo(t).x:po(e).left-po(t).left:"s"===i?"start"===a?po(t).top-po(e).bottom:"center"===a?mo(t).y-po(e).bottom:po(t).bottom-po(e).bottom:"start"===a?po(t).left-po(e).right:"center"===a?mo(t).x-po(e).right:po(t).right-po(e).right}o||(o=ql);var c=e.incoming.filter(o).map((function(t){var n=r(t),i=n<0?l(t.source,e):l(e,t.source);return{id:t.source.id,distance:i,weight:n}})),u=e.outgoing.filter(o).map((function(t){var n=r(t),i=n>0?l(e,t.target):l(t.target,e);return{id:t.target.id,distance:i,weight:n}})),h=f(c.concat(u).reduce((function(e,t){return e[t.id+"__weight_"+t.weight]=t,e}),{}),(function(e,t){var n=t.distance,i=t.weight;return n<0||n>s||(e[String(n)]||(e[String(n)]=0),e[String(n)]+=1*i,(!e.distance||e[e.distance]<e[String(n)])&&(e.distance=n)),e}),{});return h.distance||n}(e,{defaultDistance:180,direction:"s",getWeight:o,filter:ec,reference:"center"}),s={x:i.x,y:n.bottom+r};return Bl(e,t,s,function(e){var t,n,i=mo(e);return function(e,o,r){var s;return t?(o.x<i.x?t=r:n=r,s=tc(i,mo(t))<tc(i,mo(n))?Kl:Gl):(t=r,n=r,s=mo(r).x-i.x>0?Kl:Gl),s===Kl?{x:Math.min(mo(t).x-Zl-Yl,po(t).left-Yl-e.width/2),y:o.y}:{x:Math.max(mo(n).x+Zl+Yl,po(n).right+Yl+e.width/2),y:o.y}}}(e))}(e,t):void 0}function ec(e){return!hn(e,"dmn:Association")}function tc(e,t){return Math.abs(t.x-e.x)}function nc(e){e.on("autoPlace",(function(e){var t=e.shape;return Jl(e.source,t)}))}nc.$inject=["eventBus"];var ic={__depends__:[zl],__init__:["dmnAutoPlace"],dmnAutoPlace:["type",nc]};function oc(e,t,n){var i,o,r=this,s=n.get("dragging",!1);s&&t.on("drag.start",(function(n){t.once("drag.move",1500,(function(t){!function(t){if(!t.hover){var n=t.originalEvent,i=r._findTargetGfx(n),o=i&&e.get(i);i&&o&&(t.stopPropagation(),s.hover({element:o,gfx:i}),s.move(n))}}(t)}))})),t.on("element.hover",(function(e){i=e.gfx,o=e.element})),t.on("element.hover",1500,(function(e){o&&t.fire("element.out",{element:o,gfx:i})})),t.on("element.out",(function(){i=null,o=null})),this._findTargetGfx=function(e){var t;if(e instanceof MouseEvent)return t=ga(e),function(e){return Bt(e,"svg, .djs-element",!0)}(document.elementFromPoint(t.x,t.y))}}oc.$inject=["elementRegistry","eventBus","injector"];var rc={__init__:["hoverFix"],hoverFix:["type",oc]},sc=Math.round,ac="djs-drag-active";function lc(e){e.preventDefault()}function cc(e,t,n,i){var o,r={threshold:5,trapClick:!0};function s(e){var n=t.viewbox(),i=t._container.getBoundingClientRect();return{x:n.x+(e.x-i.left)/n.scale,y:n.y+(e.y-i.top)/n.scale}}function a(t,n){n=n||o;var i=e.createEvent(M({},n.payload,n.data,{isTouch:n.isTouch}));return!1!==e.fire("drag."+t,i)&&e.fire(n.prefix+"."+t,i)}function l(e,i){var r,l=o.payload,c=o.displacement,u=o.globalStart,h=ga(e),d=Ua(h,u),p=o.localStart,f=s(h),m=Ua(f,p);if(!o.active&&(i||(r=d,Math.sqrt(Math.pow(r.x,2)+Math.pow(r.y,2))>o.threshold))){if(M(l,{x:sc(p.x+c.x),y:sc(p.y+c.y),dx:0,dy:0},{originalEvent:e}),!1===a("start"))return g();o.active=!0,o.keepSelection||(l.previousSelection=n.get(),n.select(null)),o.cursor&&tl(o.cursor),t.addMarker(t.getRootElement(),ac)}fa(e),o.active&&(M(l,{x:sc(f.x+c.x),y:sc(f.y+c.y),dx:sc(m.x),dy:sc(m.y)},{originalEvent:e}),a("move"))}function c(e){var t=!0;o.active&&(e&&(o.payload.originalEvent=e,fa(e)),t=a("end")),!1===t&&a("rejected"),a("ended",m(!0!==t))}function u(e){fl("Escape",e)&&(lc(e),g())}function h(t){var n;o.active&&(n=ol(e),setTimeout(n,400),lc(t)),c(t)}function d(e){l(e)}function p(e){var t=o.payload;t.hoverGfx=e.gfx,t.hover=e.element,a("hover")}function f(e){a("out");var t=o.payload;t.hoverGfx=null,t.hover=null}function g(e){var t;if(o){var n=o.active;n&&a("cancel"),t=m(e),n&&a("canceled",t)}}function m(r){var s,m;a("cleanup"),nl(),m=o.trapClick?h:c,zt.unbind(document,"mousemove",l),zt.unbind(document,"dragstart",lc),zt.unbind(document,"selectstart",lc),zt.unbind(document,"mousedown",m,!0),zt.unbind(document,"mouseup",m,!0),zt.unbind(document,"keyup",u),zt.unbind(document,"touchstart",d,!0),zt.unbind(document,"touchcancel",g,!0),zt.unbind(document,"touchmove",l,!0),zt.unbind(document,"touchend",c,!0),e.off("element.hover",p),e.off("element.out",f),t.removeMarker(t.getRootElement(),ac);var v=o.payload.previousSelection;return!1!==r&&v&&!n.get().length&&function(e){var t=e.filter((function(e){return i.get(e.id)}));t.length&&n.select(t)}(v),s=o,o=null,s}e.on("diagram.destroy",g),this.init=function(t,n,i,m){o&&g(!1),"string"==typeof n&&(m=i,i=n,n=null);var v,y,x,b,_,w=(m=M({},r,m||{})).data||{};b=m.trapClick?h:c,t?(v=pa(t)||t,y=ga(t),fa(t),"dragstart"===v.type&&lc(v)):(v=null,y={x:0,y:0}),x=s(y),n||(n=x),_=function(e){return"undefined"!=typeof TouchEvent&&e instanceof TouchEvent}(v),o=M({prefix:i,data:w,payload:{},globalStart:y,displacement:Ua(n,x),localStart:x,isTouch:_},m),m.manual||(_?(zt.bind(document,"touchstart",d,!0),zt.bind(document,"touchcancel",g,!0),zt.bind(document,"touchmove",l,!0),zt.bind(document,"touchend",c,!0)):(zt.bind(document,"mousemove",l),zt.bind(document,"dragstart",lc),zt.bind(document,"selectstart",lc),zt.bind(document,"mousedown",b,!0),zt.bind(document,"mouseup",b,!0)),zt.bind(document,"keyup",u),e.on("element.hover",p),e.on("element.out",f)),a("init"),m.autoActivate&&l(t,!0)},this.move=l,this.hover=p,this.out=f,this.end=c,this.cancel=g,this.context=function(){return o},this.setOptions=function(e){M(r,e)}}cc.$inject=["eventBus","canvas","selection","elementRegistry"];var uc={__depends__:[rc,Aa],dragging:["type",cc]};function hc(e,t,n){this._canvas=n,this._opts=M({scrollThresholdIn:[20,20,20,20],scrollThresholdOut:[0,0,0,0],scrollRepeatTimeout:15,scrollStep:10},e);var i=this;t.on("drag.move",(function(e){var t=i._toBorderPoint(e);i.startScroll(t)})),t.on(["drag.cleanup"],(function(){i.stopScroll()}))}function dc(e,t,n){return t<e&&e<n}hc.$inject=["config.autoScroll","eventBus","canvas"],hc.prototype.startScroll=function(e){var t=this._canvas,n=this._opts,i=this,o=t.getContainer().getBoundingClientRect(),r=[e.x,e.y,o.width-e.x,o.height-e.y];this.stopScroll();for(var s=0,a=0,l=0;l<4;l++)dc(r[l],n.scrollThresholdOut[l],n.scrollThresholdIn[l])&&(0===l?s=n.scrollStep:1==l?a=n.scrollStep:2==l?s=-n.scrollStep:3==l&&(a=-n.scrollStep));0===s&&0===a||(t.scroll({dx:s,dy:a}),this._scrolling=setTimeout((function(){i.startScroll(e)}),n.scrollRepeatTimeout))},hc.prototype.stopScroll=function(){clearTimeout(this._scrolling)},hc.prototype.setOptions=function(e){this._opts=M({},this._opts,e)},hc.prototype._toBorderPoint=function(e){var t=this._canvas._container.getBoundingClientRect(),n=ga(e.originalEvent);return{x:n.x-t.left,y:n.y-t.top}};var pc={__depends__:[uc],__init__:["autoScroll"],autoScroll:["type",hc]};function fc(e){this._commandStack=e.get("commandStack",!1)}fc.$inject=["injector"],fc.prototype.allowed=function(e,t){var n=!0,i=this._commandStack;return i&&(n=i.canExecute(e,t)),void 0===n||n};var gc={__init__:["rules"],rules:["type",fc]},mc=Math.round,vc=Math.max;var yc=10;function xc(e,t){return function(e,t){var n,i;for(n=0;i=e[n];n++)if(ki(i,t)<=yc)return{point:e[n],bendpoint:!0,index:n};return null}(e,t)||function(e,t){var n,i,o=no(function(e,t){return[["M",e.x,e.y],["m",0,-t],["a",t,t,0,1,1,0,2*t],["a",t,t,0,1,1,0,-2*t],["z"]]}(t,yc),(n=[],e.forEach((function(e,t){n.push([0===t?"M":"L",e.x,e.y])})),n)),r=o[0],s=o[o.length-1];return r?r!==s?r.segment2!==s.segment2?{point:e[i=vc(r.segment2,s.segment2)-1],bendpoint:!0,index:i}:{point:{x:mc(r.x+s.x)/2,y:mc(r.y+s.y)/2},index:r.segment2}:{point:{x:mc(r.x),y:mc(r.y)},index:r.segment2}:null}(e,t)}function bc(e,t){var n=t[0],i=t[1],o={x:i.x-n.x,y:i.y-n.y},r=function(e,t,n){var i=[{n:e[0]-n[0],lambda:t[0]},{n:e[1]-n[1],lambda:t[1]}];return-(i[0].n*t[0]+i[1].n*t[1])/(i[0].lambda*t[0]+i[1].lambda*t[1])}([n.x,n.y],[o.x,o.y],[e.x,e.y]);return{x:n.x+r*o.x,y:n.y+r*o.y}}function _c(e,t){var n,i=bc(e,t),o={x:i.x-e.x,y:i.y-e.y};return n=o,Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2))}var wc="djs-bendpoint",Cc="djs-segment-dragger";function Oc(e,t,n){var i=function(e,t){var n,i=ga(t),o=e._container.getBoundingClientRect();n={x:o.left,y:o.top};var r=e.viewbox();return{x:r.x+(i.x-n.x)/r.scale,y:r.y+(i.y-n.y)/r.scale}}(e,n);return xc(t,i)}function kc(e,t){var n=Qn("g");Bn(n).add(wc),An(e,n);var i=Qn("circle");jn(i,{cx:0,cy:0,r:4}),Bn(i).add("djs-visual"),An(n,i);var o=Qn("circle");return jn(o,{cx:0,cy:0,r:10}),Bn(o).add("djs-hit"),An(n,o),t&&Bn(n).add(t),n}function Ec(e,t,n,i){var o=Qn("g");An(e,o);var r=function(e,t,n){var i=t.x-e.x,o=t.y-e.y;return Rc("h"===n?i:o)}(t,n,i),s=Qn("rect");jn(s,{x:-9,y:-3,width:18,height:6}),Bn(s).add("djs-visual"),An(o,s);var a=Qn("rect");return jn(a,{x:-r/2,y:-8.5,width:r,height:17}),Bn(a).add("djs-hit"),An(o,a),function(e,t){var n=Xn();n.setRotate(t,0,0),ii(e,n)}(o,"v"===i?90:0),o}function Sc(e,t,n){var i=Qn("g"),o=Mi(t,n),r=Ri(t,n);return An(e,i),Ec(i,t,n,r),Bn(i).add(Cc),Bn(i).add("h"===r?"horizontal":"vertical"),Fo(i,o.x,o.y),i}function Rc(e){return Math.abs(Math.round(2*e/3))}function Tc(e,t){var n=function(e,t){for(var n,i=t.waypoints,o=1/0,r=0;r<i.length-1;r++){var s=_c(e,[i[r],i[r+1]]);s<o&&(o=s,n=r)}return[i[n],i[n+1]]}(e,t);return bc(e,n)}function Mc(e,t,n,i,o){function r(e,n){var r,s=n.waypoints,a=Oc(t,s,e);if(a)return r=function(e,t){var n,i,o=e.waypoints;return t.index<=0||t.bendpoint?null:(i=Ri((n={start:o[t.index-1],end:o[t.index]}).start,n.end))?Rc("h"===i?n.end.x-n.start.x:n.end.y-n.start.y)/2:null}(n,a),!function(e,t,n){var i,o,r,s,a,l,c=e.index,u=e.point;return!(c<=0||e.bendpoint)&&(r=Mi(i=t[c-1],o=t[c]),s=Ri(i,o),a=Math.abs(u.x-r.x),l=Math.abs(u.y-r.y),s&&a<=n&&l<=n)}(a,s,r)?i.start(e,n,a.index,!a.bendpoint):o.start(e,n,a.index),!0}function s(e,t,i){zt.bind(e,t,(function(e){n.triggerMouseEvent(t,e,i),e.stopPropagation()}))}function a(e,n){var i=t.getLayer("overlays"),o=Zt('.djs-bendpoints[data-element-id="'+al(e.id)+'"]',i);return!o&&n&&(jn(o=Qn("g"),{"data-element-id":e.id}),Bn(o).add("djs-bendpoints"),An(i,o),s(o,"mousedown",e),s(o,"click",e),s(o,"dblclick",e)),o}function l(e,t){return Zt('.djs-segment-dragger[data-segment-idx="'+e+'"]',t)}function c(e,t){t.waypoints.forEach((function(t,n){var i=kc(e);An(e,i),Fo(i,t.x,t.y)})),kc(e,"floating")}function u(e,t){for(var n,i,o,r=t.waypoints,a=1;a<r.length;a++)Ri(n=r[a-1],i=r[a])&&(jn(o=Sc(e,n,i),{"data-segment-idx":a}),s(o,"mousemove",t))}function h(e){var t=a(e);return t||(c(t=a(e,!0),e),u(t,e)),t}function d(e){var t=a(e);t&&(!function(e){p(Jt("."+Cc,e),(function(e){ti(e)}))}(t),function(e){p(Jt("."+wc,e),(function(e){ti(e)}))}(t),u(t,e),c(t,e))}function f(e,t,n){var i,o,r=l(t.index,e),s=n[t.index-1],a=n[t.index],c=t.point,u=Mi(s,a),h=Ri(s,a);r&&(i=function(e){return Zt(".djs-visual",e)}(r),o={x:c.x-u.x,y:c.y-u.y},"v"===h&&(o={x:o.y,y:o.x}),Fo(i,o.x,o.y))}e.on("connection.changed",(function(e){d(e.element)})),e.on("connection.remove",(function(e){var t=a(e.element);t&&ti(t)})),e.on("element.marker.update",(function(e){var t,n=e.element;n.waypoints&&(t=h(n),e.add?Bn(t).add(e.marker):Bn(t).remove(e.marker))})),e.on("element.mousemove",(function(e){var n,i,o=e.element,r=o.waypoints;if(r){if(n=a(o,!0),!(i=Oc(t,r,e.originalEvent)))return;!function(e,t){var n=Zt(".floating",e),i=t.point;n&&Fo(n,i.x,i.y)}(n,i),i.bendpoint||f(n,i,r)}})),e.on("element.mousedown",(function(e){if(ya(e)){var t=e.originalEvent,n=e.element;if(n.waypoints)return r(t,n)}})),e.on("selection.changed",(function(e){var t=e.newSelection[0];t&&t.waypoints&&h(t)})),e.on("element.hover",(function(e){var t=e.element;t.waypoints&&(h(t),n.registerEvent(e.gfx,"mousemove","element.mousemove"))})),e.on("element.out",(function(e){n.unregisterEvent(e.gfx,"mousemove","element.mousemove")})),e.on("element.updateId",(function(e){var t=e.element,n=e.newId;if(t.waypoints){var i=a(t);i&&jn(i,{"data-element-id":n})}})),this.addHandles=h,this.updateHandles=d,this.getBendpointsContainer=a,this.getSegmentDragger=l}Mc.$inject=["eventBus","canvas","interactionEvents","bendpointMove","connectionSegmentMove"];var Ac=Math.round,Pc="reconnectStart",Dc="reconnectEnd",$c="updateWaypoints";function jc(e,t,n,i,o,r){this._injector=e,this.start=function(e,t,r,s){var a,l=n.getGraphics(t),c=t.source,u=t.target,h=t.waypoints,d=(a=s||0!==r?s||r!==h.length-1?$c:Dc:Pc)===$c?"connection.updateWaypoints":"connection.reconnect",p=o.allowed(d,{connection:t,source:c,target:u});!1===p&&(p=o.allowed(d,{connection:t,source:u,target:c})),!1!==p&&i.init(e,"bendpoint.move",{data:{connection:t,connectionGfx:l,context:{allowed:p,bendpointIndex:r,connection:t,source:c,target:u,insert:s,type:a}}})},t.on("bendpoint.move.hover",(function(e){var t,n=e.context,i=n.connection,r=i.source,s=i.target,a=e.hover,l=n.type;if(n.hover=a,a){var c=l===$c?"connection.updateWaypoints":"connection.reconnect";if(t=n.allowed=o.allowed(c,{connection:i,source:l===Pc?a:r,target:l===Dc?a:s}))return n.source=l===Pc?a:r,void(n.target=l===Dc?a:s);!1===t&&(t=n.allowed=o.allowed(c,{connection:i,source:l===Dc?a:s,target:l===Pc?a:r})),t&&(n.source=l===Dc?a:s,n.target=l===Pc?a:r)}})),t.on(["bendpoint.move.out","bendpoint.move.cleanup"],(function(e){var t=e.context,n=t.type;t.hover=null,t.source=null,t.target=null,n!==$c&&(t.allowed=!1)})),t.on("bendpoint.move.end",(function(e){var t=e.context,n=t.allowed,i=t.bendpointIndex,o=t.connection,s=t.insert,a=o.waypoints.slice(),l=t.source,c=t.target,u=t.type,h=t.hints||{},d={x:Ac(e.x),y:Ac(e.y)};if(!n)return!1;u===$c?(s?a.splice(i,0,d):a[i]=d,h.bendpointMove={insert:s,bendpointIndex:i},a=this.cropWaypoints(o,a),r.updateWaypoints(o,function(e){e=e.slice();for(var t,n,i,o=0;e[o];)t=e[o],n=e[o-1],0===ki(t,i=e[o+1])||Ei(n,i,t)?e.splice(o,1):o++;return e}(a),h)):(u===Pc?(h.docking="source",Ic(t)&&(h.docking="target",h.newWaypoints=a.reverse())):u===Dc&&(h.docking="target",Ic(t)&&(h.docking="source",h.newWaypoints=a.reverse())),r.reconnect(o,l,c,d,h))}),this)}function Ic(e){var t=e.hover,n=e.source,i=e.target,o=e.type;return o===Pc?t&&i&&t===i&&n!==i:o===Dc?t&&n&&t===n&&n!==i:void 0}jc.$inject=["injector","eventBus","canvas","dragging","rules","modeling"],jc.prototype.cropWaypoints=function(e,t){var n=this._injector.get("connectionDocking",!1);if(!n)return t;var i=e.waypoints;return e.waypoints=t,e.waypoints=n.getCroppedWaypoints(e),t=e.waypoints,e.waypoints=i,t};var Bc="updateWaypoints",Lc="connect-ok",Nc="connect-not-ok",qc="connect-hover",Vc="djs-updating",Fc="djs-dragging";function zc(e,t,n,i){this._injector=t;var o=t.get("connectionPreview",!1);n.on("bendpoint.move.start",(function(e){var t=e.context,n=t.bendpointIndex,o=t.connection,r=t.insert,s=o.waypoints,a=s.slice();t.waypoints=s,r&&a.splice(n,0,{x:e.x,y:e.y}),o.waypoints=a,Bn(t.draggerGfx=kc(i.getLayer("overlays"))).add("djs-dragging"),i.addMarker(o,Fc),i.addMarker(o,Vc)})),n.on("bendpoint.move.hover",(function(e){var t=e.context,n=t.allowed,o=t.hover,r=t.type;if(o){if(i.addMarker(o,qc),r===Bc)return;n?(i.removeMarker(o,Nc),i.addMarker(o,Lc)):!1===n&&(i.removeMarker(o,Lc),i.addMarker(o,Nc))}})),n.on(["bendpoint.move.out","bendpoint.move.cleanup"],1100,(function(e){var t=e.context,n=t.hover,o=t.target;n&&(i.removeMarker(n,qc),i.removeMarker(n,o?Lc:Nc))})),n.on("bendpoint.move.move",(function(t){var n=t.context,i=n.allowed,r=n.bendpointIndex,s=n.draggerGfx,a=n.hover,l=n.type,c=n.connection,u=c.source,h=c.target,d=c.waypoints.slice(),p={x:t.x,y:t.y},f=n.hints||{},g={};o&&(f.connectionStart&&(g.connectionStart=f.connectionStart),f.connectionEnd&&(g.connectionEnd=f.connectionEnd),"reconnectStart"===l?Ic(n)?(g.connectionEnd=g.connectionEnd||p,g.source=h,g.target=a||u,d=d.reverse()):(g.connectionStart=g.connectionStart||p,g.source=a||u,g.target=h):"reconnectEnd"===l?Ic(n)?(g.connectionStart=g.connectionStart||p,g.source=a||h,g.target=u,d=d.reverse()):(g.connectionEnd=g.connectionEnd||p,g.source=u,g.target=a||h):(g.noCropping=!0,g.noLayout=!0,d[r]=p),l===Bc&&(d=e.cropWaypoints(c,d)),g.waypoints=d,o.drawPreview(n,i,g)),Fo(s,t.x,t.y)}),this),n.on(["bendpoint.move.end","bendpoint.move.cancel"],1100,(function(e){var t=e.context,n=t.connection,r=t.draggerGfx,s=t.hover,a=t.target,l=t.waypoints;n.waypoints=l,ti(r),i.removeMarker(n,Vc),i.removeMarker(n,Fc),s&&(i.removeMarker(s,Lc),i.removeMarker(s,a?Lc:Nc)),o&&o.cleanUp(t)}))}zc.$inject=["bendpointMove","injector","eventBus","canvas"];var Qc="connect-hover",Hc="djs-updating";function Wc(e,t,n){return Uc(e,t,e[t]+n)}function Uc(e,t,n){return{x:"x"===t?n:e.x,y:"y"===t?n:e.y}}function Xc(e){return"x"===e?"y":"x"}function Kc(e,t,n){var i,o;return e.original?e.original:(i=mo(t),Uc(e,o=Xc(n),i[o]))}function Gc(e,t,n,i,o,r){var s=e.get("connectionDocking",!1);function a(e,t){if(!s)return t;var n,i=e.waypoints;return e.waypoints=t,n=s.getCroppedWaypoints(e),e.waypoints=i,n}function l(e){o.update("connection",e.connection,e.connectionGfx)}function c(e,t,n){var i=e.newWaypoints,o=function(e,t,n,i){var o=Math.max(t[i],n[i]),r=Math.min(t[i],n[i]);return Uc(t,i,Math.min(Math.max(r+20,e[i]),o-20))}(n,i[e.segmentStartIndex+t],i[e.segmentEndIndex+t],Xc(e.axis));Fo(e.draggerGfx,o.x,o.y)}this.start=function(e,t,o){var r,s,a,l,c=n.getGraphics(t),u=o-1,h=o,d=t.waypoints,p=d[u],f=d[h],g=Oc(n,d,e);(s=Ri(p,f))&&(a="v"===s?"x":"y",0===u&&(p=Kc(p,t.source,a)),h===d.length-1&&(f=Kc(f,t.target,a)),r={connection:t,segmentStartIndex:u,segmentEndIndex:h,segmentStart:p,segmentEnd:f,axis:a,dragPosition:l=g?g.point:{x:(p.x+f.x)/2,y:(p.y+f.y)/2}},i.init(e,l,"connectionSegment.move",{cursor:"x"===a?"resize-ew":"resize-ns",data:{connection:t,connectionGfx:c,context:r}}))},t.on("connectionSegment.move.start",(function(e){var t=e.context,i=e.connection,o=n.getLayer("overlays");t.originalWaypoints=i.waypoints.slice(),t.draggerGfx=Sc(o,t.segmentStart,t.segmentEnd),Bn(t.draggerGfx).add("djs-dragging"),n.addMarker(i,Hc)})),t.on("connectionSegment.move.move",(function(e){var t,n,i=e.context,o=i.connection,r=i.segmentStartIndex,s=i.segmentEndIndex,u=i.segmentStart,h=i.segmentEnd,d=i.axis,p=i.originalWaypoints.slice(),f=Wc(u,d,e["d"+d]),g=Wc(h,d,e["d"+d]),m=p.length,v=0;p[r]=f,p[s]=g,r<2&&(t=vo(o.source,f),1===r?"intersect"===t&&(p.shift(),p[0]=f,v--):"intersect"!==t&&(p.unshift(u),v++)),s>m-3&&(n=vo(o.target,g),s===m-2?"intersect"===n&&(p.pop(),p[p.length-1]=g):"intersect"!==n&&p.push(h)),i.newWaypoints=o.waypoints=a(o,p),c(i,v,e),i.newSegmentStartIndex=r+v,l(e)})),t.on("connectionSegment.move.hover",(function(e){e.context.hover=e.hover,n.addMarker(e.hover,Qc)})),t.on(["connectionSegment.move.out","connectionSegment.move.cleanup"],(function(e){var t=e.context.hover;t&&n.removeMarker(t,Qc)})),t.on("connectionSegment.move.cleanup",(function(e){var t=e.context,i=t.connection;t.draggerGfx&&ti(t.draggerGfx),n.removeMarker(i,Hc)})),t.on(["connectionSegment.move.cancel","connectionSegment.move.end"],(function(e){var t=e.context;t.connection.waypoints=t.originalWaypoints,l(e)})),t.on("connectionSegment.move.end",(function(e){var t=e.context,n=t.connection,i=t.newWaypoints,o=t.newSegmentStartIndex;i=i.map((function(e){return{original:e.original,x:Math.round(e.x),y:Math.round(e.y)}}));var s=function(e,t){var n=0,i=e.filter((function(i,o){return!Ei(e[o-1],e[o+1],i)||(n=o<=t?n-1:n,!1)}));return{waypoints:i,segmentOffset:n}}(i,o),l=a(n,s.waypoints),c=s.segmentOffset,u={segmentMove:{segmentStartIndex:t.segmentStartIndex,newSegmentStartIndex:o+c}};r.updateWaypoints(n,l,u)}))}Gc.$inject=["injector","eventBus","canvas","dragging","graphicsFactory","modeling"];var Yc=Math.abs,Zc=Math.round;function Jc(e,t){return!e||isNaN(e.x)||isNaN(e.y)?t:{x:Zc(e.x+e.width/2),y:Zc(e.y+e.height/2)}}function eu(e,t){var n=e.snapped;return!!n&&("string"==typeof t?n[t]:n.x&&n.y)}function tu(e,t,n){if("string"!=typeof t)throw new Error("axis must be in [x, y]");if("number"!=typeof n&&!1!==n)throw new Error("value must be Number or false");var i,o=e[t],r=e.snapped=e.snapped||{};return!1===n?r[t]=!1:(r[t]=!0,i=n-o,e[t]+=i,e["d"+t]+=i),o}function nu(e){return e.children||[]}var iu=Math.abs,ou=Math.round;function ru(e){function t(e,t){if(r(e)){for(var n=e.length;n--;)if(iu(e[n]-t)<=10)return e[n]}else{var i=t%(e=+e);if(i<10)return t-i;if(i>e-10)return t-i+e}return t}function n(e,t){return e.waypoints?Tc(t,e):e.width?{x:ou(e.width/2+e.x),y:ou(e.height/2+e.y)}:void 0}e.on("connectionSegment.move.move",1500,(function(e){var i,o,r=function(e){var t=e.context,i=t.snapPoints,o=t.connection,r=o.waypoints,s=t.segmentStart,a=t.segmentStartIndex,l=t.segmentEnd,c=t.segmentEndIndex,u=t.axis;if(i)return i;var h=[r[a-1],s,l,r[c+1]];return a<2&&h.unshift(n(o.source,e)),c>r.length-3&&h.unshift(n(o.target,e)),t.snapPoints=i={horizontal:[],vertical:[]},p(h,(function(e){e&&(e=e.original||e,"y"===u&&i.horizontal.push(e.y),"x"===u&&i.vertical.push(e.x))})),i}(e),s=e.x,a=e.y;if(r){var l=s-(i=t(r.vertical,s)),c=a-(o=t(r.horizontal,a));M(e,{dx:e.dx-l,dy:e.dy-c,x:i,y:o}),(l||-1!==r.vertical.indexOf(s))&&tu(e,"x",i),(c||-1!==r.horizontal.indexOf(a))&&tu(e,"y",o)}})),e.on(["connect.hover","connect.move","connect.end"],1500,(function(e){var t=e.context.hover,i=t&&n(t,e);co(t)&&i&&i.x&&i.y&&(tu(e,"x",i.x),tu(e,"y",i.y))})),e.on(["bendpoint.move.move","bendpoint.move.end"],1500,(function(e){var i,o,r=e.context,s=function(e){var t=e.snapPoints,n=e.connection.waypoints,i=e.bendpointIndex;if(t)return t;var o=[n[i-1],n[i+1]];return e.snapPoints=t={horizontal:[],vertical:[]},p(o,(function(e){e&&(e=e.original||e,t.horizontal.push(e.y),t.vertical.push(e.x))})),t}(r),a=r.hover,l=a&&n(a,e),c=e.x,u=e.y;if(s){var h=c-(i=t(l?s.vertical.concat([l.x]):s.vertical,c)),d=u-(o=t(l?s.horizontal.concat([l.y]):s.horizontal,u));M(e,{dx:e.dx-h,dy:e.dy-d,x:e.x-h,y:e.y-d}),(h||-1!==s.vertical.indexOf(c))&&tu(e,"x",i),(d||-1!==s.horizontal.indexOf(u))&&tu(e,"y",o)}}))}ru.$inject=["eventBus"];var su={__depends__:[uc,gc],__init__:["bendpoints","bendpointSnapping","bendpointMovePreview"],bendpoints:["type",Mc],bendpointMove:["type",jc],bendpointMovePreview:["type",zc],connectionSegmentMove:["type",Gc],bendpointSnapping:["type",ru]};const au=new Pa;function lu(e){this._scheduled={},e.on("diagram.destroy",(()=>{Object.keys(this._scheduled).forEach((e=>{this.cancel(e)}))}))}lu.$inject=["eventBus"],lu.prototype.schedule=function(e,t=au.next()){this.cancel(t);const n=this._schedule(e,t);return this._scheduled[t]=n,n.promise},lu.prototype._schedule=function(e,t){const n=function(){const e={};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e}(),i=setTimeout((()=>{try{this._scheduled[t]=null;try{n.resolve(e())}catch(e){n.reject(e)}}catch(e){console.error("Scheduler#_schedule execution failed",e)}}));return{executionId:i,promise:n.promise}},lu.prototype.cancel=function(e){const t=this._scheduled[e];t&&(this._cancel(t),this._scheduled[e]=null)},lu.prototype._cancel=function(e){clearTimeout(e.executionId)};var cu={scheduler:["type",lu]},uu=".entry";function hu(e,t,n,i){this._canvas=e,this._elementRegistry=t,this._eventBus=n,this._scheduler=i,this._current=null,this._init()}hu.$inject=["canvas","elementRegistry","eventBus","scheduler"],hu.prototype._init=function(){var e=this;this._eventBus.on("selection.changed",(function(t){var n=t.newSelection,i=n.length?1===n.length?n[0]:n:null;i?e.open(i,!0):e.close()})),this._eventBus.on("elements.changed",(function(t){var n=t.elements,i=e._current;if(i){var o=i.target,s=r(o)?o:[o];if(s.filter((function(e){return n.includes(e)})).length){e.close();var a=s.filter((function(t){return e._elementRegistry.get(t.id)}));a.length&&e._updateAndOpen(a.length>1?a:a[0])}}})),this._eventBus.on("canvas.viewbox.changed",(function(){e._updatePosition()})),this._eventBus.on("element.marker.update",(function(t){if(e.isOpen()){var n=t.element,i=e._current;(r(i.target)?i.target:[i.target]).includes(n)&&e._updateVisibility()}})),this._container=this._createContainer()},hu.prototype._createContainer=function(){var e=Gt('<div class="djs-context-pad-parent"></div>');return this._canvas.getContainer().appendChild(e),e},hu.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("contextPad.getProviders",e,(function(e){e.providers.push(t)}))},hu.prototype.getEntries=function(e){var t=this._getProviders(),n=r(e)?"getMultiElementContextPadEntries":"getContextPadEntries",i={};return p(t,(function(t){if(l(t[n])){var o=t[n](e);l(o)?i=o(i):p(o,(function(e,t){i[t]=e}))}})),i},hu.prototype.trigger=function(e,t,n){var i,o,r=this,s=t.delegateTarget||t.target;return s?(i=Pt(s,"data-action"),o=t.originalEvent||t,"mouseover"!==e?"mouseout"===e?(clearTimeout(this._timeout),void(this._mouseout&&(this._mouseout(),this._mouseout=null))):this.triggerEntry(i,e,o,n):void(this._timeout=setTimeout((function(){r._mouseout=r.triggerEntry(i,"hover",o,n)}),300))):t.preventDefault()},hu.prototype.triggerEntry=function(e,t,n,i){if(this.isShown()){var o=this._current.target,r=this._current.entries[e];if(r){var s=r.action;if(!1!==this._eventBus.fire("contextPad.trigger",{entry:r,event:n})){if(l(s)){if("click"===t)return s(n,o,i)}else if(s[t])return s[t](n,o,i);n.preventDefault()}}}},hu.prototype.open=function(e,t){!t&&this.isOpen(e)||(this.close(),this._updateAndOpen(e))},hu.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"contextPad.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},hu.prototype._updateAndOpen=function(e){var t,n=this.getEntries(e),i=this._createHtml(e);p(n,(function(e,n){var o,s=e.group||"default",a=Gt(e.html||'<div class="entry" draggable="true"></div>');Pt(a,"data-action",n),(o=Zt("[data-group="+al(s)+"]",i))||(Pt(o=Gt('<div class="group"></div>'),"data-group",s),i.appendChild(o)),o.appendChild(a),e.className&&function(e,t){var n=$t(e);t=r(t)?t:t.split(/\s+/g),t.forEach((function(e){n.add(e)}))}(a,e.className),e.title&&Pt(a,"title",e.title),e.imageUrl&&(Pt(t=Gt("<img>"),"src",e.imageUrl),t.style.width="100%",t.style.height="100%",a.appendChild(t))})),$t(i).add("open"),this._current={entries:n,html:i,target:e},this._updatePosition(),this._updateVisibility(),this._eventBus.fire("contextPad.open",{current:this._current})},hu.prototype._createHtml=function(e){var t=this,n=Gt('<div class="djs-context-pad"></div>');return Wt.bind(n,uu,"click",(function(e){t.trigger("click",e)})),Wt.bind(n,uu,"dragstart",(function(e){t.trigger("dragstart",e)})),Wt.bind(n,uu,"mouseover",(function(e){t.trigger("mouseover",e)})),Wt.bind(n,uu,"mouseout",(function(e){t.trigger("mouseout",e)})),zt.bind(n,"mousedown",(function(e){e.stopPropagation()})),this._container.appendChild(n),this._eventBus.fire("contextPad.create",{target:e,pad:n}),n},hu.prototype.getPad=function(e){let t;return 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")),t=this.isOpen()&&function(e,t){return e=r(e)?e:[e],t=r(t)?t:[t],e.length===t.length&&g(e,(function(e){return t.includes(e)}))}(this._current.target,e)?this._current.html:this._createHtml(e),{html:t}},hu.prototype.close=function(){this.isOpen()&&(clearTimeout(this._timeout),this._container.innerHTML="",this._eventBus.fire("contextPad.close",{current:this._current}),this._current=null)},hu.prototype.isOpen=function(e){var t=this._current;if(!t)return!1;if(!e)return!0;var n=t.target;return r(e)===r(n)&&(r(e)?e.length===n.length&&g(e,(function(e){return n.includes(e)})):n===e)},hu.prototype.isShown=function(){return this.isOpen()&&$t(this._current.html).has("open")},hu.prototype.show=function(){this.isOpen()&&($t(this._current.html).add("open"),this._updatePosition(),this._eventBus.fire("contextPad.show",{current:this._current}))},hu.prototype.hide=function(){this.isOpen()&&($t(this._current.html).remove("open"),this._eventBus.fire("contextPad.hide",{current:this._current}))},hu.prototype._getPosition=function(e){if(!r(e)&&co(e)){var t=this._canvas.viewbox(),n=(s=e).waypoints[s.waypoints.length-1],i=n.x*t.scale-t.x*t.scale,o=n.y*t.scale-t.y*t.scale;return{left:i+8*this._canvas.zoom(),top:o}}var s,a=this._canvas.getContainer().getBoundingClientRect(),l=this._getTargetBounds(e);return{left:l.right-a.left+8*this._canvas.zoom(),top:l.top-a.top}},hu.prototype._updatePosition=function(){this._scheduler.schedule((()=>{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(n){n in t&&(e.style[n]=t[n]+"px")}))}}),"ContextPad#_updatePosition")},hu.prototype._updateVisibility=function(){this._scheduler.schedule((()=>{if(this.isOpen()){var e=this,t=this._current.target;(r(t)?t:[t]).some((function(t){return e._canvas.hasMarker(t,"djs-element-hidden")}))?e.hide():e.show()}}),"ContextPad#_updateVisibility")},hu.prototype._getTargetBounds=function(e){var t=this;return(r(e)?e:[e]).map((function(e){return t._canvas.getGraphics(e)})).reduce((function(e,t){const n=t.getBoundingClientRect();return e.top=Math.min(e.top,n.top),e.right=Math.max(e.right,n.right),e.bottom=Math.max(e.bottom,n.bottom),e.left=Math.min(e.left,n.left),e.x=e.left,e.y=e.top,e.width=e.right-e.left,e.height=e.bottom-e.top,e}),{top:1/0,right:-1/0,bottom:-1/0,left:1/0})};var du={__depends__:[Oa,cu,La],contextPad:["type",hu]};function pu(e,t,n,i){function r(e,t){return i.allowed("connection.create",{source:e,target:t})}e.on("connect.hover",(function(e){var t,n=e.context,i=n.start,s=e.hover;if(n.hover=s,!o(t=n.canExecute=r(i,s))){if(!1!==t)return n.source=i,void(n.target=s);o(t=n.canExecute=r(s,i))||!1!==t&&(n.source=s,n.target=i)}})),e.on(["connect.out","connect.cleanup"],(function(e){var t=e.context;t.hover=null,t.source=null,t.target=null,t.canExecute=!1})),e.on("connect.end",(function(e){var t=e.context,i=t.canExecute,o=t.connectionStart,r={x:e.x,y:e.y},a=t.source,l=t.target;if(!i)return!1;var c=null,u={connectionStart:fu(t)?r:o,connectionEnd:fu(t)?o:r};s(i)&&(c=i),t.connection=n.connect(a,l,c,u)})),this.start=function(e,n,i,o){s(i)||(o=i,i=mo(n)),t.init(e,"connect",{autoActivate:o,data:{shape:n,context:{start:n,connectionStart:i}}})}}function fu(e){var t=e.hover,n=e.source,i=e.target;return t&&n&&t===n&&n!==i}pu.$inject=["eventBus","dragging","modeling","rules"];var gu="connect-ok",mu="connect-not-ok";function vu(e,t,n){var i=e.get("connectionPreview",!1);i&&t.on("connect.move",(function(e){var t=e.context,n=t.canExecute,o=t.hover,r=t.source,s=t.start,a=t.startPosition,l=t.target,c=t.connectionStart||a,u=t.connectionEnd||{x:e.x,y:e.y},h=c,d=u;fu(t)&&(h=u,d=c),i.drawPreview(t,n,{source:r||s,target:l||o,connectionStart:h,connectionEnd:d})})),t.on("connect.hover",900,(function(e){var t=e.context,i=e.hover,o=t.canExecute;null!==o&&n.addMarker(i,o?gu:mu)})),t.on(["connect.out","connect.cleanup"],1100,(function(e){var t=e.hover;t&&(n.removeMarker(t,gu),n.removeMarker(t,mu))})),i&&t.on("connect.cleanup",(function(e){i.cleanUp(e.context)}))}vu.$inject=["injector","eventBus","canvas"];var yu={__depends__:[Aa,gc,uc],__init__:["connectPreview"],connect:["type",pu],connectPreview:["type",vu]};const xu=new Pa("ps");var bu=["marker-start","marker-mid","marker-end"],_u=["circle","ellipse","line","path","polygon","polyline","path","rect"];function wu(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._styles=i}wu.$inject=["elementRegistry","eventBus","canvas","styles"],wu.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")},wu.prototype.getGfx=function(e){return this._elementRegistry.getGraphics(e)},wu.prototype.addDragger=function(e,t,n,i="djs-dragger"){var o=qn(n=n||this.getGfx(e)),r=n.getBoundingClientRect();return this._cloneMarkers(Vo(o),i),jn(o,this._styles.cls(i,[],{x:r.top,y:r.left})),An(t,o),jn(o,"data-preview-support-element-id",e.id),o},wu.prototype.addFrame=function(e,t){var n=Qn("rect",{class:"djs-resize-overlay",width:e.width,height:e.height,x:e.x,y:e.y});return An(t,n),jn(n,"data-preview-support-element-id",e.id),n},wu.prototype._cloneMarkers=function(e,t="djs-dragger",n=e){var i=this;e.childNodes&&e.childNodes.forEach((e=>{i._cloneMarkers(e,t,n)})),function(e){return-1!==_u.indexOf(e.nodeName)}(e)&&bu.forEach((function(o){if(jn(e,o)){var r=function(e,t,n){var i=(o=jn(e,t),o.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]);var o;return Zt("marker#"+i,n||document)}(e,o,i._canvas.getContainer());r&&i._cloneMarker(n,e,r,o,t)}}))},wu.prototype._cloneMarker=function(e,t,n,i,o="djs-dragger"){var r=[n.id,o,xu.next()].join("-"),s=Zt("marker#"+n.id,e);e=e||this._canvas._svg;var a=s||qn(n);a.id=r,Bn(a).add(o);var l=Zt(":scope > defs",e);l||An(e,l=Qn("defs")),An(l,a);var c=function(e){return"url(#"+e+")"}(a.id);jn(t,i,c)};var Cu={__init__:["previewSupport"],previewSupport:["type",wu]},Ou="drop-ok",ku="drop-not-ok",Eu="attach-ok",Su="new-parent",Ru="create";function Tu(e,t,n,i,o){function s(t,n){[Eu,Ou,ku,Su].forEach((function(i){i===n?e.addMarker(t,i):e.removeMarker(t,i)}))}function l(){var e=t.context();e&&e.prefix===Ru&&t.cancel()}n.on(["create.move","create.hover"],(function(e){var t=e.context,n=t.elements,i=e.hover,r=t.source,a=t.hints||{};if(!i)return t.canExecute=!1,void(t.target=null);Mu(e);var l={x:e.x,y:e.y},c=t.canExecute=i&&function(e,t,n,i,r){if(!t)return!1;var s=h(e=d(e,(function(t){var n=t.labelTarget;return!(t.parent||uo(t)&&-1!==e.indexOf(n))})),(function(e){return!co(e)})),a=!1,l=!1,c=!1;Au(e)&&(a=o.allowed("shape.attach",{position:n,shape:s,target:t})),a||(c=Au(e)?o.allowed("shape.create",{position:n,shape:s,source:i,target:t}):o.allowed("elements.create",{elements:e,position:n,target:t}));var u=r.connectionTarget;return c||a?(s&&i&&(l=o.allowed("connection.create",{source:u===i?s:i,target:u===i?i:s,hints:{targetParent:t,targetAttach:a}})),{attach:a,connect:l}):(null===c||null===a)&&null}(n,i,l,r,a);i&&null!==c&&(t.target=i,c&&c.attach?s(i,Eu):s(i,c?Su:ku))})),n.on(["create.end","create.out","create.cleanup"],(function(e){var t=e.hover;t&&s(t,null)})),n.on("create.end",(function(e){var t=e.context,n=t.source,o=t.shape,r=t.elements,s=t.target,a=t.canExecute,l=a&&a.attach,c=a&&a.connect,u=t.hints||{};if(!1===a||!s)return!1;Mu(e);var d={x:e.x,y:e.y};o=c?i.appendShape(n,o,d,s,{attach:l,connection:!0===c?{}:c,connectionTarget:u.connectionTarget}):h(r=i.createElements(r,d,s,M({},u,{attach:l})),(function(e){return!co(e)})),M(t,{elements:r,shape:o}),M(e,{elements:r,shape:o})})),n.on("create.init",(function(){n.on("elements.changed",l),n.once(["create.cancel","create.end"],2e3,(function(){n.off("elements.changed",l)}))})),this.start=function(e,n,i){r(n)||(n=[n]);var o=h(n,(function(e){return!co(e)}));if(o){i=M({elements:n,hints:{},shape:o},i||{}),p(n,(function(e){a(e.x)||(e.x=0),a(e.y)||(e.y=0)}));var s=mi(d(n,(function(e){return!e.hidden})));p(n,(function(e){co(e)&&(e.waypoints=v(e.waypoints,(function(e){return{x:e.x-s.x-s.width/2,y:e.y-s.y-s.height/2}}))),M(e,{x:e.x-s.x-s.width/2,y:e.y-s.y-s.height/2})})),t.init(e,Ru,{cursor:"grabbing",autoActivate:!0,data:{shape:o,elements:n,context:i}})}}}function Mu(e){var t=e.context.createConstraints;t&&(t.left&&(e.x=Math.max(e.x,t.left)),t.right&&(e.x=Math.min(e.x,t.right)),t.top&&(e.y=Math.max(e.y,t.top)),t.bottom&&(e.y=Math.min(e.y,t.bottom)))}function Au(e){return e&&1===e.length&&!co(e[0])}Tu.$inject=["canvas","dragging","eventBus","modeling","rules"];function Pu(e,t,n,i,o){t.on("create.move",750,(function(t){var r=t.hover,s=t.context,a=s.elements,l=s.dragGroup;l||(l=s.dragGroup=function(e){var t=Qn("g");jn(t,o.cls("djs-drag-group",["no-events"]));var r=Qn("g");return e.forEach((function(e){var o;e.hidden||(e.waypoints?(o=n._createContainer("connection",r),n.drawConnection(Vo(o),e)):(o=n._createContainer("shape",r),n.drawShape(Vo(o),e),Fo(o,e.x,e.y)),i.addDragger(e,t,o))})),t}(a)),r?(l.parentNode||An(e.getActiveLayer(),l),Fo(l,t.x,t.y)):ti(l)})),t.on("create.cleanup",(function(e){var t=e.context.dragGroup;t&&ti(t)}))}Pu.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];var Du,$u,ju,Iu,Bu,Lu,Nu,qu,Vu,Fu,zu={__depends__:[uc,Cu,gc,Aa],__init__:["create","createPreview"],create:["type",Tu],createPreview:["type",Pu]},Qu={},Hu=[],Wu=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Uu=Array.isArray;function Xu(e,t){for(var n in t)e[n]=t[n];return e}function Ku(e){var t=e.parentNode;t&&t.removeChild(e)}function Gu(e,t,n){var i,o,r,s={};for(r in t)"key"==r?i=t[r]:"ref"==r?o=t[r]:s[r]=t[r];if(arguments.length>2&&(s.children=arguments.length>3?Du.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(r in e.defaultProps)void 0===s[r]&&(s[r]=e.defaultProps[r]);return Yu(e,s,i,o,null)}function Yu(e,t,n,i,o){var r={type:e,props:t,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==o?++ju:o,__i:-1,__u:0};return null==o&&null!=$u.vnode&&$u.vnode(r),r}function Zu(e){return e.children}function Ju(e,t){this.props=e,this.context=t}function eh(e,t){if(null==t)return e.__?eh(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?eh(e):null}function th(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return th(e)}}function nh(e){(!e.__d&&(e.__d=!0)&&Iu.push(e)&&!ih.__r++||Bu!==$u.debounceRendering)&&((Bu=$u.debounceRendering)||Lu)(ih)}function ih(){var e,t,n,i,o,r,s,a;for(Iu.sort(Nu);e=Iu.shift();)e.__d&&(t=Iu.length,i=void 0,r=(o=(n=e).__v).__e,s=[],a=[],n.__P&&((i=Xu({},o)).__v=o.__v+1,$u.vnode&&$u.vnode(i),hh(n.__P,i,o,n.__n,void 0!==n.__P.ownerSVGElement,32&o.__u?[r]:null,s,null==r?eh(o):r,!!(32&o.__u),a),i.__v=o.__v,i.__.__k[i.__i]=i,dh(s,i,a),i.__e!=r&&th(i)),Iu.length>t&&Iu.sort(Nu));ih.__r=0}function oh(e,t,n,i,o,r,s,a,l,c,u){var h,d,p,f,g,m=i&&i.__k||Hu,v=t.length;for(n.__d=l,rh(n,t,m),l=n.__d,h=0;h<v;h++)null!=(p=n.__k[h])&&"boolean"!=typeof p&&"function"!=typeof p&&(d=-1===p.__i?Qu:m[p.__i]||Qu,p.__i=h,hh(e,p,d,o,r,s,a,l,c,u),f=p.__e,p.ref&&d.ref!=p.ref&&(d.ref&&ph(d.ref,null,p),u.push(p.ref,p.__c||f,p)),null==g&&null!=f&&(g=f),65536&p.__u||d.__k===p.__k?(l&&!l.isConnected&&(l=eh(d)),l=sh(p,l,e)):"function"==typeof p.type&&void 0!==p.__d?l=p.__d:f&&(l=f.nextSibling),p.__d=void 0,p.__u&=-196609);n.__d=l,n.__e=g}function rh(e,t,n){var i,o,r,s,a,l=t.length,c=n.length,u=c,h=0;for(e.__k=[],i=0;i<l;i++)s=i+h,null!=(o=e.__k[i]=null==(o=t[i])||"boolean"==typeof o||"function"==typeof o?null:"string"==typeof o||"number"==typeof o||"bigint"==typeof o||o.constructor==String?Yu(null,o,null,null,null):Uu(o)?Yu(Zu,{children:o},null,null,null):void 0===o.constructor&&o.__b>0?Yu(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o)?(o.__=e,o.__b=e.__b+1,a=ah(o,n,s,u),o.__i=a,r=null,-1!==a&&(u--,(r=n[a])&&(r.__u|=131072)),null==r||null===r.__v?(-1==a&&h--,"function"!=typeof o.type&&(o.__u|=65536)):a!==s&&(a===s+1?h++:a>s?u>l-s?h+=a-s:h--:a<s?a==s-1&&(h=a-s):h=0,a!==i+h&&(o.__u|=65536))):(r=n[s])&&null==r.key&&r.__e&&!(131072&r.__u)&&(r.__e==e.__d&&(e.__d=eh(r)),fh(r,r,!1),n[s]=null,u--);if(u)for(i=0;i<c;i++)null!=(r=n[i])&&!(131072&r.__u)&&(r.__e==e.__d&&(e.__d=eh(r)),fh(r,r))}function sh(e,t,n){var i,o;if("function"==typeof e.type){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=sh(i[o],t,n));return t}e.__e!=t&&(n.insertBefore(e.__e,t||null),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8===t.nodeType);return t}function ah(e,t,n,i){var o=e.key,r=e.type,s=n-1,a=n+1,l=t[n];if(null===l||l&&o==l.key&&r===l.type&&!(131072&l.__u))return n;if(i>(null==l||131072&l.__u?0:1))for(;s>=0||a<t.length;){if(s>=0){if((l=t[s])&&!(131072&l.__u)&&o==l.key&&r===l.type)return s;s--}if(a<t.length){if((l=t[a])&&!(131072&l.__u)&&o==l.key&&r===l.type)return a;a++}}return-1}function lh(e,t,n){"-"===t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||Wu.test(t)?n:n+"px"}function ch(e,t,n,i,o){var r;e:if("style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof i&&(e.style.cssText=i=""),i)for(t in i)n&&t in n||lh(e.style,t,"");if(n)for(t in n)i&&n[t]===i[t]||lh(e.style,t,n[t])}else if("o"===t[0]&&"n"===t[1])r=t!==(t=t.replace(/(PointerCapture)$|Capture$/i,"$1")),t=t.toLowerCase()in e||"onFocusOut"===t||"onFocusIn"===t?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=n,n?i?n.u=i.u:(n.u=qu,e.addEventListener(t,r?Fu:Vu,r)):e.removeEventListener(t,r?Fu:Vu,r);else{if(o)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,n))}}function uh(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t.t)t.t=qu++;else if(t.t<n.u)return;return n($u.event?$u.event(t):t)}}}function hh(e,t,n,i,o,r,s,a,l,c){var u,h,d,p,f,g,m,v,y,x,b,_,w,C,O,k=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(l=!!(32&n.__u),r=[a=t.__e=n.__e]),(u=$u.__b)&&u(t);e:if("function"==typeof k)try{if(v=t.props,y=(u=k.contextType)&&i[u.__c],x=u?y?y.props.value:u.__:i,n.__c?m=(h=t.__c=n.__c).__=h.__E:("prototype"in k&&k.prototype.render?t.__c=h=new k(v,x):(t.__c=h=new Ju(v,x),h.constructor=k,h.render=gh),y&&y.sub(h),h.props=v,h.state||(h.state={}),h.context=x,h.__n=i,d=h.__d=!0,h.__h=[],h._sb=[]),null==h.__s&&(h.__s=h.state),null!=k.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=Xu({},h.__s)),Xu(h.__s,k.getDerivedStateFromProps(v,h.__s))),p=h.props,f=h.state,h.__v=t,d)null==k.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(null==k.getDerivedStateFromProps&&v!==p&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(v,x),!h.__e&&(null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(v,h.__s,x)||t.__v===n.__v)){for(t.__v!==n.__v&&(h.props=v,h.state=h.__s,h.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.forEach((function(e){e&&(e.__=t)})),b=0;b<h._sb.length;b++)h.__h.push(h._sb[b]);h._sb=[],h.__h.length&&s.push(h);break e}null!=h.componentWillUpdate&&h.componentWillUpdate(v,h.__s,x),null!=h.componentDidUpdate&&h.__h.push((function(){h.componentDidUpdate(p,f,g)}))}if(h.context=x,h.props=v,h.__P=e,h.__e=!1,_=$u.__r,w=0,"prototype"in k&&k.prototype.render){for(h.state=h.__s,h.__d=!1,_&&_(t),u=h.render(h.props,h.state,h.context),C=0;C<h._sb.length;C++)h.__h.push(h._sb[C]);h._sb=[]}else do{h.__d=!1,_&&_(t),u=h.render(h.props,h.state,h.context),h.state=h.__s}while(h.__d&&++w<25);h.state=h.__s,null!=h.getChildContext&&(i=Xu(Xu({},i),h.getChildContext())),d||null==h.getSnapshotBeforeUpdate||(g=h.getSnapshotBeforeUpdate(p,f)),oh(e,Uu(O=null!=u&&u.type===Zu&&null==u.key?u.props.children:u)?O:[O],t,n,i,o,r,s,a,l,c),h.base=t.__e,t.__u&=-161,h.__h.length&&s.push(h),m&&(h.__E=h.__=null)}catch(e){t.__v=null,l||null!=r?(t.__e=a,t.__u|=l?160:32,r[r.indexOf(a)]=null):(t.__e=n.__e,t.__k=n.__k),$u.__e(e,t,n)}else null==r&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=function(e,t,n,i,o,r,s,a,l){var c,u,h,d,p,f,g,m=n.props,v=t.props,y=t.type;if("svg"===y&&(o=!0),null!=r)for(c=0;c<r.length;c++)if((p=r[c])&&"setAttribute"in p==!!y&&(y?p.localName===y:3===p.nodeType)){e=p,r[c]=null;break}if(null==e){if(null===y)return document.createTextNode(v);e=o?document.createElementNS("http://www.w3.org/2000/svg",y):document.createElement(y,v.is&&v),r=null,a=!1}if(null===y)m===v||a&&e.data===v||(e.data=v);else{if(r=r&&Du.call(e.childNodes),m=n.props||Qu,!a&&null!=r)for(m={},c=0;c<e.attributes.length;c++)m[(p=e.attributes[c]).name]=p.value;for(c in m)p=m[c],"children"==c||("dangerouslySetInnerHTML"==c?h=p:"key"===c||c in v||ch(e,c,null,p,o));for(c in v)p=v[c],"children"==c?d=p:"dangerouslySetInnerHTML"==c?u=p:"value"==c?f=p:"checked"==c?g=p:"key"===c||a&&"function"!=typeof p||m[c]===p||ch(e,c,p,m[c],o);if(u)a||h&&(u.__html===h.__html||u.__html===e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(h&&(e.innerHTML=""),oh(e,Uu(d)?d:[d],t,n,i,o&&"foreignObject"!==y,r,s,r?r[0]:n.__k&&eh(n,0),a,l),null!=r)for(c=r.length;c--;)null!=r[c]&&Ku(r[c]);a||(c="value",void 0!==f&&(f!==e[c]||"progress"===y&&!f||"option"===y&&f!==m[c])&&ch(e,c,f,m[c],!1),c="checked",void 0!==g&&g!==e[c]&&ch(e,c,g,m[c],!1))}return e}(n.__e,t,n,i,o,r,s,l,c);(u=$u.diffed)&&u(t)}function dh(e,t,n){t.__d=void 0;for(var i=0;i<n.length;i++)ph(n[i],n[++i],n[++i]);$u.__c&&$u.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(e){$u.__e(e,t.__v)}}))}function ph(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(e){$u.__e(e,n)}}function fh(e,t,n){var i,o;if($u.unmount&&$u.unmount(e),(i=e.ref)&&(i.current&&i.current!==e.__e||ph(i,null,t)),null!=(i=e.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){$u.__e(e,t)}i.base=i.__P=null}if(i=e.__k)for(o=0;o<i.length;o++)i[o]&&fh(i[o],t,n||"function"!=typeof e.type);n||null==e.__e||Ku(e.__e),e.__c=e.__=e.__e=e.__d=void 0}function gh(e,t,n){return this.constructor(e,n)}function mh(e,t,n){var i,o,r,s;$u.__&&$u.__(e,t),o=(i="function"==typeof n)?null:t.__k,r=[],s=[],hh(t,e=(!i&&n||t).__k=Gu(Zu,null,[e]),o||Qu,Qu,void 0!==t.ownerSVGElement,!i&&n?[n]:o?null:t.firstChild?Du.call(t.childNodes):null,r,!i&&n?n:o?o.__e:t.firstChild,i,s),dh(r,e,s)}Du=Hu.slice,$u={__e:function(e,t,n,i){for(var o,r,s;t=t.__;)if((o=t.__c)&&!o.__)try{if((r=o.constructor)&&null!=r.getDerivedStateFromError&&(o.setState(r.getDerivedStateFromError(e)),s=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(e,i||{}),s=o.__d),s)return o.__E=o}catch(t){e=t}throw e}},ju=0,Ju.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=Xu({},this.state),"function"==typeof e&&(e=e(Xu({},n),this.props)),e&&Xu(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),nh(this))},Ju.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),nh(this))},Ju.prototype.render=Zu,Iu=[],Lu="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Nu=function(e,t){return e.__v.__b-t.__v.__b},ih.__r=0,qu=0,Vu=uh(!1),Fu=uh(!0);var vh=function(e,t,n,i){var o;t[0]=0;for(var r=1;r<t.length;r++){var s=t[r++],a=t[r]?(t[0]|=s?1:2,n[t[r++]]):t[++r];3===s?i[0]=a:4===s?i[1]=Object.assign(i[1]||{},a):5===s?(i[1]=i[1]||{})[t[++r]]=a:6===s?i[1][t[++r]]+=a+"":s?(o=e.apply(a,vh(e,a,n,["",null])),i.push(o),a[0]?t[0]|=2:(t[r-2]=0,t[r]=o)):i.push(a)}return i},yh=new Map;var xh,bh,_h,wh,Ch=function(e){var t=yh.get(this);return t||(t=new Map,yh.set(this,t)),(t=vh(this,t.get(e)||(t.set(e,t=function(e){for(var t,n,i=1,o="",r="",s=[0],a=function(e){1===i&&(e||(o=o.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?s.push(0,e,o):3===i&&(e||o)?(s.push(3,e,o),i=2):2===i&&"..."===o&&e?s.push(4,e,0):2===i&&o&&!e?s.push(5,0,!0,o):i>=5&&((o||!e&&5===i)&&(s.push(i,0,o,n),i=6),e&&(s.push(i,e,0,n),i=6)),o=""},l=0;l<e.length;l++){l&&(1===i&&a(),a(l));for(var c=0;c<e[l].length;c++)t=e[l][c],1===i?"<"===t?(a(),s=[s],i=3):o+=t:4===i?"--"===o&&">"===t?(i=1,o=""):o=t+o[0]:r?t===r?r="":o+=t:'"'===t||"'"===t?r=t:">"===t?(a(),i=1):i&&("="===t?(i=5,n=o,o=""):"/"===t&&(i<5||">"===e[l][c+1])?(a(),3===i&&(s=s[0]),i=s,(s=s[0]).push(2,0,i),i=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(a(),i=2):o+=t),3===i&&"!--"===o&&(i=4,s=s[0])}return a(),s}(e)),t),arguments,[])).length>1?t:t[0]}.bind(Gu),Oh=0,kh=[],Eh=[],Sh=$u,Rh=Sh.__b,Th=Sh.__r,Mh=Sh.diffed,Ah=Sh.__c,Ph=Sh.unmount,Dh=Sh.__;function $h(e,t){Sh.__h&&Sh.__h(bh,e,Oh||t),Oh=0;var n=bh.__H||(bh.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({__V:Eh}),n.__[e]}function jh(e){return Oh=1,function(e,t,n){var i=$h(xh++,2);if(i.t=e,!i.__c&&(i.__=[Uh(void 0,t),function(e){var t=i.__N?i.__N[0]:i.__[0],n=i.t(t,e);t!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=bh,!bh.u)){var o=function(e,t,n){if(!i.__c.__H)return!0;var o=i.__c.__H.__.filter((function(e){return!!e.__c}));if(o.every((function(e){return!e.__N})))return!r||r.call(this,e,t,n);var s=!1;return o.forEach((function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(s=!0)}})),!(!s&&i.__c.props===e)&&(!r||r.call(this,e,t,n))};bh.u=!0;var r=bh.shouldComponentUpdate,s=bh.componentWillUpdate;bh.componentWillUpdate=function(e,t,n){if(this.__e){var i=r;r=void 0,o(e,t,n),r=i}s&&s.call(this,e,t,n)},bh.shouldComponentUpdate=o}return i.__N||i.__}(Uh,e)}function Ih(e,t){var n=$h(xh++,3);!Sh.__s&&Wh(n.__H,t)&&(n.__=e,n.i=t,bh.__H.__h.push(n))}function Bh(e,t){var n=$h(xh++,4);!Sh.__s&&Wh(n.__H,t)&&(n.__=e,n.i=t,bh.__h.push(n))}function Lh(e){return Oh=5,Nh((function(){return{current:e}}),[])}function Nh(e,t){var n=$h(xh++,7);return Wh(n.__H,t)?(n.__V=e(),n.i=t,n.__h=e,n.__V):n.__}function qh(e,t){return Oh=8,Nh((function(){return e}),t)}function Vh(){for(var e;e=kh.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Qh),e.__H.__h.forEach(Hh),e.__H.__h=[]}catch(t){e.__H.__h=[],Sh.__e(t,e.__v)}}Sh.__b=function(e){bh=null,Rh&&Rh(e)},Sh.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Dh&&Dh(e,t)},Sh.__r=function(e){Th&&Th(e),xh=0;var t=(bh=e.__c).__H;t&&(_h===bh?(t.__h=[],bh.__h=[],t.__.forEach((function(e){e.__N&&(e.__=e.__N),e.__V=Eh,e.__N=e.i=void 0}))):(t.__h.forEach(Qh),t.__h.forEach(Hh),t.__h=[],xh=0)),_h=bh},Sh.diffed=function(e){Mh&&Mh(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==kh.push(t)&&wh===Sh.requestAnimationFrame||((wh=Sh.requestAnimationFrame)||zh)(Vh)),t.__H.__.forEach((function(e){e.i&&(e.__H=e.i),e.__V!==Eh&&(e.__=e.__V),e.i=void 0,e.__V=Eh}))),_h=bh=null},Sh.__c=function(e,t){t.some((function(e){try{e.__h.forEach(Qh),e.__h=e.__h.filter((function(e){return!e.__||Hh(e)}))}catch(n){t.some((function(e){e.__h&&(e.__h=[])})),t=[],Sh.__e(n,e.__v)}})),Ah&&Ah(e,t)},Sh.unmount=function(e){Ph&&Ph(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach((function(e){try{Qh(e)}catch(e){t=e}})),n.__H=void 0,t&&Sh.__e(t,n.__v))};var Fh="function"==typeof requestAnimationFrame;function zh(e){var t,n=function(){clearTimeout(i),Fh&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(n,100);Fh&&(t=requestAnimationFrame(n))}function Qh(e){var t=bh,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),bh=t}function Hh(e){var t=bh;e.__c=e.__(),bh=t}function Wh(e,t){return!e||e.length!==t.length||t.some((function(t,n){return t!==e[n]}))}function Uh(e,t){return"function"==typeof t?t(e):t}function Xh(e){var t,n,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Xh(e[t]))&&(i&&(i+=" "),i+=n)}else for(n in e)e[n]&&(i&&(i+=" "),i+=n);return i}function Kh(){for(var e,t,n=0,i="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Xh(e))&&(i&&(i+=" "),i+=t);return i}function Gh(e){const{headerEntries:t,onSelect:n,selectedEntry:i,setSelectedEntry:o,title:r}=e,s=Nh((()=>t.reduce(((e,t)=>{const n=t.group||"default",i=e.find((e=>e.id===n));return i?i.entries.push(t):e.push({id:n,entries:[t]}),e}),[])),[t]);return Ch` 191 `,this._current.container)},nd.prototype.open=function(e,t,n,i){if(!e)throw new Error("target is missing");if(!t)throw new Error("providers for <"+t+"> not found");if(!n)throw new Error("position is missing");this.isOpen()&&this.close();const{entries:o,headerEntries:r,emptyPlaceholder:s}=this._getContext(e,t);this._current={position:n,providerId:t,target:e,entries:o,headerEntries:r,emptyPlaceholder:s,container:this._createContainer({provider:t}),options:i},this._emit("open"),this._bindAutoClose(),this._render()},nd.prototype.refresh=function(){if(!this.isOpen())return;const{target:e,providerId:t}=this._current,{entries:n,headerEntries:i,emptyPlaceholder:o}=this._getContext(e,t);this._current={...this._current,entries:n,headerEntries:i,emptyPlaceholder:o},this._emit("refresh"),this._render()},nd.prototype._getContext=function(e,t){const n=this._getProviders(t);if(!n||!n.length)throw new Error("provider for <"+t+"> not found");const i=this._getEntries(e,n),o=this._getHeaderEntries(e,n);return{entries:i,headerEntries:o,emptyPlaceholder:this._getEmptyPlaceholder(n),empty:!(Object.keys(i).length||Object.keys(o).length)}},nd.prototype.close=function(){this.isOpen()&&(this._emit("close"),this.reset(),this._canvas.restoreFocus(),this._current=null)},nd.prototype.reset=function(){const e=this._current.container;mh(null,e),en(e)},nd.prototype._emit=function(e,t){this._eventBus.fire(`popupMenu.${e}`,t)},nd.prototype._onOpened=function(){this._emit("opened")},nd.prototype._onClosed=function(){this._emit("closed")},nd.prototype._createContainer=function(e){var t=this._canvas.getContainer();const n=Gt(`<div class="djs-popup-parent djs-scrollable" data-popup=${e.provider}></div>`);return t.appendChild(n),n},nd.prototype._bindAutoClose=function(){this._eventBus.once(td,this.close,this)},nd.prototype._unbindAutoClose=function(){this._eventBus.off(td,this.close,this)},nd.prototype._updateScale=function(){var e,t,n=this._canvas.zoom(),o=this._config.scale,r=n;return!0!==o&&(!1===o?(e=1,t=1):(e=o.min,t=o.max),i(e)&&n<e&&(r=e),i(t)&&n>t&&(r=t)),r},nd.prototype._ensureVisible=function(e,t){var n=document.documentElement.getBoundingClientRect(),i=e.getBoundingClientRect(),o={},r=t.x,s=t.y;return t.x+i.width>n.width&&(o.x=!0),t.y+i.height>n.height&&(o.y=!0),o.x&&o.y?(r=t.x-i.width,s=t.y-i.height):o.x?(r=t.x-i.width,s=t.y):o.y&&t.y<i.height?(r=t.x,s=10):o.y&&(r=t.x,s=t.y-i.height),t.y<n.top&&(s=t.y+i.height),{x:r,y:s}},nd.prototype.isEmpty=function(e,t){if(!e)throw new Error("target is missing");if(!t)throw new Error("provider ID is missing");const n=this._getProviders(t);return!n||!n.length||this._getContext(e,t).empty},nd.prototype.registerProvider=function(e,t,n){n||(n=t,t=1e3),this._eventBus.on("popupMenu.getProviders."+e,t,(function(e){e.providers.push(n)}))},nd.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"popupMenu.getProviders."+e,providers:[]});return this._eventBus.fire(t),t.providers},nd.prototype._getEntries=function(e,t){var n={};return p(t,(function(t){if(t.getPopupMenuEntries){var i=t.getPopupMenuEntries(e);l(i)?n=i(n):p(i,(function(e,t){n[t]=e}))}else p(t.getEntries(e),(function(e){var t=e.id;if(!t)throw new Error("entry ID is missing");n[t]=P(e,["id"])}))})),n},nd.prototype._getHeaderEntries=function(e,t){var n={};return p(t,(function(t){if(t.getPopupMenuHeaderEntries){var i=t.getPopupMenuHeaderEntries(e);l(i)?n=i(n):p(i,(function(e,t){n[t]=e}))}else{if(!t.getHeaderEntries)return;p(t.getHeaderEntries(e),(function(e){var t=e.id;if(!t)throw new Error("entry ID is missing");n[t]=P(e,["id"])}))}})),n},nd.prototype._getEmptyPlaceholder=function(e){const t=e.find((e=>l(e.getEmptyPlaceholder)));return t&&t.getEmptyPlaceholder()},nd.prototype.isOpen=function(){return!!this._current},nd.prototype.trigger=function(e,t,n="click"){if(e.preventDefault(),!t){let n=Pt(Bt(e.delegateTarget||e.target,".entry",!0),"data-id");t={id:n,...this._getEntry(n)}}const i=t.action;if(!1!==this._emit("trigger",{entry:t,event:e}))if(l(i)){if("click"===n)return i(e,t)}else if(i[n])return i[n](e,t)},nd.prototype._getEntry=function(e){var t=this._current.entries[e]||this._current.headerEntries[e];if(!t)throw new Error("entry not found");return t};var ad={search:["value",function(e,t,n){const{keys:i}=n,o=t.trim().toLowerCase().split(/\s+/);return e.flatMap((e=>{const t=function(e,t,n){const{matchedWords:i,tokens:o}=n.reduce(((n,i)=>{const o=e[i],{tokens:r,matchedWords:s}=function(e,t){if(!e)return{tokens:[],matchedWords:{}};const n=[],i={},o=t.map(sd).flatMap((e=>["(?<wordStart>\\b"+e+")",e])).join("|"),r=new RegExp(o,"ig");let s,a=0;for(;s=r.exec(e);){const[t]=s;s.index>a&&n.push({value:e.slice(a,s.index),index:a}),n.push({value:t,index:s.index,match:!0,wordStart:!!s.groups.wordStart,start:0===s.index}),i[t.toLowerCase()]=!0,a=s.index+t.length}a<e.length&&n.push({value:e.slice(a),index:a});return{tokens:n,matchedWords:i}}(o,t);return{tokens:{...n.tokens,[i]:r},matchedWords:{...n.matchedWords,...s}}}),{matchedWords:{},tokens:{}});if(Object.keys(i).length!==t.length)return null;return o}(e,o,i);return t?{item:e,tokens:t}:[]})).sort(function(e){return(t,n)=>{for(const i of e){const e=id(t.tokens[i],n.tokens[i]);if(0!==e)return e;const o=rd(t.item[i],n.item[i]);if(0!==o)return o}return 0}}(i))}]},ld={__depends__:[ad],__init__:["popupMenu"],popupMenu:["type",nd]},cd=Math.round;function ud(e,t){this._modeling=e,this._eventBus=t}function hd(e,t){t.on("replace.end",500,(function(t){const{newElement:n,hints:i={}}=t;!1!==i.select&&e.select(n)}))}ud.$inject=["modeling","eventBus"],ud.prototype.replaceElement=function(e,t,n){if(e.waypoints)return null;var i=this._modeling,o=this._eventBus;o.fire("replace.start",{element:e,attrs:t,hints:n});var r=t.width||e.width,s=t.height||e.height,a=t.x||e.x,l=t.y||e.y,c=cd(a+r/2),u=cd(l+s/2),h=i.replaceShape(e,M({},t,{x:c,y:u,width:r,height:s}),n);return o.fire("replace.end",{element:e,newElement:h,hints:n}),h},hd.$inject=["selection","eventBus"];var dd={__init__:["replace","replaceSelectionBehavior"],replaceSelectionBehavior:["type",hd],replace:["type",ud]};function pd(e,t,n,i){this.replaceElement=function(n,i,o){o=o||{};var r=i.type,s=n.businessObject,a=e.create(r),l={type:r,businessObject:a};if(l.width=n.width,l.height=n.height,a.name=s.name,i.table){var c=e.create("dmn:DecisionTable");c.$parent=a;var u=e.create("dmn:OutputClause");u.typeRef="string",u.$parent=c,c.output=[u];var h=e.create("dmn:InputClause");h.$parent=c;var d=e.create("dmn:LiteralExpression",{typeRef:"string"});h.inputExpression=d,d.$parent=h,c.input=[h],fd(a,c,e)}if(i.expression){var p=e.create("dmn:LiteralExpression"),f=e.create("dmn:InformationItem",{name:s.name});fd(a,p,e,f)}return t.replaceElement(n,l,o)}}function fd(e,t,n,i){if(hn(e,"dmn:Decision"))e.decisionLogic=t,t.$parent=e;else if(hn(e,"dmn:BusinessKnowledgeModel")){var o=n.create("dmn:FunctionDefinition",{body:t});e.encapsulatedLogic=o,o.$parent=e,t.$parent=o}i&&(e.variable=i,i.$parent=e)}pd.$inject=["drdFactory","replace","selection","modeling"];var gd={__depends__:[dd,Aa],drdReplace:["type",pd]},md=[{label:"Empty",actionName:"replace-with-empty-decision",className:"dmn-icon-clear",target:{type:"dmn:Decision",table:!1,expression:!1}},{label:"Decision table",actionName:"replace-with-decision-table",className:"dmn-icon-decision-table",target:{type:"dmn:Decision",table:!0,expression:!1}},{label:"Literal expression",actionName:"replace-with-literal-expression",className:"dmn-icon-literal-expression",target:{type:"dmn:Decision",table:!1,expression:!0}}],vd=[{label:"Empty",actionName:"replace-with-empty",className:"dmn-icon-clear",target:{type:"dmn:BusinessKnowledgeModel",table:!1,expression:!1}},{label:"Literal Expression",actionName:"replace-with-literal-expression",className:"dmn-icon-literal-expression",target:{type:"dmn:BusinessKnowledgeModel",table:!1,expression:!0}}];function yd(e,t,n,i,o,r){this._popupMenu=e,this._modeling=t,this._moddle=n,this._drdReplace=i,this._rules=o,this._translate=r,this.register()}yd.$inject=["popupMenu","modeling","moddle","drdReplace","rules","translate"],yd.prototype.register=function(){this._popupMenu.registerProvider("dmn-replace",this)},yd.prototype.getEntries=function(e){var t,n,i=e.businessObject;return this._rules.allowed("shape.replace",{element:e})?hn(i,"dmn:Decision")?(n=mn(i),t=d(md,(function(e){var t="replace-with-empty-decision"===e.actionName&&n,i="replace-with-decision-table"===e.actionName&&!hn(n,"dmn:DecisionTable"),o="replace-with-literal-expression"===e.actionName&&!hn(n,"dmn:LiteralExpression");return t||i||o})),this._createEntries(e,t)):hn(i,"dmn:BusinessKnowledgeModel")?(n=mn(i),t=d(vd,(function(e){var t="replace-with-empty"===e.actionName&&n,i="replace-with-decision-table"===e.actionName&&!hn(n,"dmn:DecisionTable"),o="replace-with-literal-expression"===e.actionName&&!hn(n,"dmn:LiteralExpression");return t||i||o})),this._createEntries(e,t)):[]:[]},yd.prototype._createEntries=function(e,t){var n=[],i=this;return p(t,(function(t){var o=i._createMenuEntry(t,e);n.push(o)})),n},yd.prototype._createMenuEntry=function(e,t,n){var i=this._drdReplace.replaceElement;return n=n||function(){return i(t,e.target)},{label:(0,this._translate)(e.label),className:e.className,id:e.actionName,action:n}},yd.prototype.getHeaderEntries=function(e){return[]};var xd={__depends__:[ha,ld,gd],__init__:["replaceMenuProvider"],replaceMenuProvider:["type",yd]};function bd(e,t,n,i,o,r,s,a,l,c,u,h){u=u||{},t.registerProvider(this),this._contextPad=t,this._modeling=n,this._elementFactory=i,this._connect=o,this._create=r,this._rules=s,this._popupMenu=a,this._canvas=l,this._translate=c,!1!==u.autoPlace&&(this._autoPlace=h.get("autoPlace",!1)),e.on("create.end",250,(function(e){var n=e.context.shape;if(xa(e)){var i=t.getEntries(n);i.replace&&i.replace.action.click(e,n)}}))}bd.$inject=["eventBus","contextPad","modeling","elementFactory","connect","create","rules","popupMenu","canvas","translate","config.contextPad","injector"],bd.prototype.getContextPadEntries=function(e){var t=this._modeling,n=this._elementFactory,i=this._connect,o=this._create,s=this._popupMenu,a=this._contextPad,l=this._rules,c=this._translate,u=this._autoPlace,h={};if("label"===e.type)return h;var d=e.businessObject;function p(e,t,n){i.start(e,t,n)}function f(e,t,i,r){function s(t,i){var s=n.createShape(M({type:e},r));o.start(t,s,{source:i,hints:{connectionTarget:i}})}var a=u?function(t,i){var o=n.createShape(M({type:e},r));u.append(i,o,{connectionTarget:i})}:s;return{group:"model",className:t,title:i,action:{dragstart:s,click:a}}}hn(d,"dmn:Decision")&&M(h,{"append.decision":f("dmn:Decision","dmn-icon-decision",c("Append decision"))}),gn(d,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:KnowledgeSource"])&&M(h,{"append.knowledge-source":f("dmn:KnowledgeSource","dmn-icon-knowledge-source",c("Append knowledge source"))}),gn(d,["dmn:BusinessKnowledgeModel","dmn:Decision"])&&M(h,{"append.business-knowledge-model":f("dmn:BusinessKnowledgeModel","dmn-icon-business-knowledge",c("Append business knowledge model"))}),gn(d,["dmn:Decision","dmn:KnowledgeSource"])&&M(h,{"append.input-data":f("dmn:InputData","dmn-icon-input-data",c("Append input data"))}),hn(d,"dmn:DRGElement")&&M(h,{"append.text-annotation":f("dmn:TextAnnotation","dmn-icon-text-annotation",c("Add text annotation")),connect:{group:"connect",className:"dmn-icon-connection-multi",title:c("Connect to other element"),action:{click:p,dragstart:p}}}),hn(d,"dmn:TextAnnotation")&&M(h,{connect:{group:"connect",className:"dmn-icon-connection-multi",title:c("Connect to other element"),action:{click:p,dragstart:p}}}),s.isEmpty(e,"dmn-replace")||M(h,{replace:{group:"edit",className:"dmn-icon-screw-wrench",title:c("Change type"),action:{click:function(e,t){var n=M(function(e){var t=a.getPad(e).html.getBoundingClientRect();return{x:t.left,y:t.bottom+5}}(t),{cursor:{x:e.x,y:e.y}});s.open(t,"dmn-replace",n)}}}});var g=l.allowed("elements.delete",{elements:[e]});return r(g)&&(g=g[0]===e),g&&M(h,{delete:{group:"edit",className:"dmn-icon-trash",title:c("Delete"),action:{click:function(n){t.removeElements([e])}}}}),h};var _d={__depends__:[ha,du,Aa,yu,zu,xd],__init__:["contextPadProvider"],contextPadProvider:["type",bd]};function wd(e,t,n,i){this._canvas=t,this._graphicsFactory=n,this._elementFactory=i,this._connectionDocking=e.get("connectionDocking",!1),this._layouter=e.get("layouter",!1)}wd.$inject=["injector","canvas","graphicsFactory","elementFactory"],wd.prototype.drawPreview=function(e,t,n){n=n||{};var i,o,r,s=e.connectionPreviewGfx,a=e.getConnection,l=n.source,c=n.target,u=n.waypoints,h=n.connectionStart,d=n.connectionEnd,p=n.noLayout,f=n.noCropping,g=n.noNoop,m=this;s||(s=e.connectionPreviewGfx=this.createConnectionPreviewGfx()),Nn(s),a||(a=e.getConnection=(o=function(e,t,n){return m.getConnection(e,t,n)},r={},function(e){var t=JSON.stringify(e),n=r[t];return n||(n=r[t]=o.apply(null,arguments)),n})),t&&(i=a(t,l,c)),i?(i.waypoints=u||[],this._layouter&&!p&&(i.waypoints=this._layouter.layoutConnection(i,{source:l,target:c,connectionStart:h,connectionEnd:d,waypoints:n.waypoints||i.waypoints})),i.waypoints&&i.waypoints.length||(i.waypoints=[l?mo(l):h,c?mo(c):d]),this._connectionDocking&&(l||c)&&!f&&(i.waypoints=this._connectionDocking.getCroppedWaypoints(i,l,c)),this._graphicsFactory.drawConnection(s,i,{stroke:"var(--element-dragger-color)"})):!g&&this.drawNoopPreview(s,n)},wd.prototype.drawNoopPreview=function(e,t){var n=t.source,i=t.target,o=t.connectionStart||mo(n),r=t.connectionEnd||mo(i),s=this.cropWaypoints(o,r,n,i);An(e,this.createNoopConnection(s[0],s[1]))},wd.prototype.cropWaypoints=function(e,t,n,i){var o=this._graphicsFactory,r=n&&o.getShapePath(n),s=i&&o.getShapePath(i),a=o.getConnectionPath({waypoints:[e,t]});return[e=n&&yo(r,a,!0)||e,t=i&&yo(s,a,!1)||t]},wd.prototype.cleanUp=function(e){e&&e.connectionPreviewGfx&&ti(e.connectionPreviewGfx)},wd.prototype.getConnection=function(e){var t=function(e){return s(e)?e:{}}(e);return this._elementFactory.createConnection(t)},wd.prototype.createConnectionPreviewGfx=function(){var e=Qn("g");return jn(e,{pointerEvents:"none"}),Bn(e).add("djs-dragger"),An(this._canvas.getActiveLayer(),e),e},wd.prototype.createNoopConnection=function(e,t){return ci([e,t],{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"})};var Cd={__init__:["connectionPreview"],connectionPreview:["type",wd]};const Od=/\s/,kd=/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i,Ed=/^[a-z_][\w-.]*$/i,Sd=/\$\{([^}]*)\}/g;function Rd(e,t){const n=e.$model.ids.assigned(t);return t?n&&n!==e?"Element must have unique ID.":function(e){if(e=function(e){return e.replace(Sd,"$1")}(e),function(e){return Od.test(e)}(e))return"Id must not contain spaces.";if(!Ed.test(e))return kd.test(e)?"Id must not contain prefix.":"Id must be a valid QName."}(t):"Element must have ID."}function Td(e,t,n,i,o){this._eventBus=e,this._modeling=t,this._canvas=n,this._definitionPropertiesView=i,this._translate=o,e.on("definitionIdView.create",(function(e){this._container=e.html;var t=Zt(".dmn-definitions-name",this._container),n=Zt(".dmn-definitions-id",this._container);this._setup(t,"name"),this._setup(n,"id")}),this)}Td.$inject=["eventBus","modeling","canvas","definitionPropertiesView","translate"],Td.prototype.update=function(e,t){var n=this._canvas.getRootElement(),i={};if(i[e]=t,"id"===e){var o=Rd(fn(n),t);if(o)return void this._addErrorMessage(o);this._clearErrorMessage()}this._modeling.updateProperties(n,i)},Td.prototype._setup=function(e,t){var n=this;e.setAttribute("contenteditable",!0),e.addEventListener("input",R((function(e){var i=e.target.value||e.target.textContent;n.update(t,i.trim())}),300)),e.addEventListener("keydown",(function(t){13===t.keyCode&&(e.blur(),window.getSelection().removeAllRanges())})),e.addEventListener("blur",(function(){n._clearErrorMessage(),n._definitionPropertiesView.update()}))},Td.prototype._addErrorMessage=function(e){const t='<span class="dmn-definitions-error-message">'+this._translate(e)+"</span>";var n=Zt(".dmn-definitions-id",this._container);this._clearErrorMessage(),$t(n).add("dmn-definitions-error"),n.parentElement.appendChild(Gt(t))},Td.prototype._clearErrorMessage=function(){var e=Zt(".dmn-definitions-id",this._container);if($t(e).has("dmn-definitions-error")){$t(e).remove("dmn-definitions-error");const t=Zt(".dmn-definitions-error-message",this._container);e.parentNode.removeChild(t)}};var Md={__depends__:[Va],__init__:["definitionPropertiesEdit","definitionPropertiesPaletteAdapter"],definitionPropertiesEdit:["type",Td],definitionPropertiesPaletteAdapter:["type",qa]},Ad={horizontal:["x","width"],vertical:["y","height"]};function Pd(e,t){this._modeling=e,this._filters=[],this.registerFilter((function(e){var n=t.allowed("elements.distribute",{elements:e});return r(n)?n:n?e:[]}))}Pd.$inject=["modeling","rules"],Pd.prototype.registerFilter=function(e){if("function"!=typeof e)throw new Error("the filter has to be a function");this._filters.push(e)},Pd.prototype.trigger=function(e,t){var n,i,o=this._modeling;if(!(e.length<3||(this._setOrientation(t),i=this._filterElements(e),(n=this._createGroups(i)).length<=2)))return o.distributeElements(n,this._axis,this._dimension),n},Pd.prototype._filterElements=function(e){var t=this._filters,n=this._axis,i=this._dimension,o=[].concat(e);return t.length?(p(t,(function(e){o=e(o,n,i)})),o):e},Pd.prototype._createGroups=function(e){var t=[],n=this,i=this._axis,o=this._dimension;if(!i)throw new Error('must have a defined "axis" and "dimension"');return p(w(e,i),(function(e,r){var s,a=n._findRange(e,i,o),l=t[t.length-1];l&&n._hasIntersection(l.range,a)?t[t.length-1].elements.push(e):(s={range:a,elements:[e]},t.push(s))})),t},Pd.prototype._setOrientation=function(e){var t=Ad[e];this._axis=t[0],this._dimension=t[1]},Pd.prototype._hasIntersection=function(e,t){return Math.max(e.min,e.max)>=Math.min(t.min,t.max)&&Math.min(e.min,e.max)<=Math.max(t.min,t.max)},Pd.prototype._findRange=function(e){var t=e[this._axis];return{min:t+5,max:t+e[this._dimension]-5}};var Dd={__init__:["distributeElements"],distributeElements:["type",Pd]};function $d(e){e.registerFilter((function(e){return d(e,(function(e){var t=gn(e,["dmn:AuthorityRequirement","dmn:InformationRequirement","dmn:KnowledgeRequirement","dmn:Association","dmn:TextAnnotation"]);return!(e.labelTarget||t)}))}))}$d.$inject=["distributeElements"];var jd={__depends__:[Dd],__init__:["drdDistributeElements"],drdDistributeElements:["type",$d]},Id="is not a registered action";function Bd(e,t){this._actions={};var n=this;e.on("diagram.init",(function(){n._registerDefaultActions(t),e.fire("editorActions.init",{editorActions:n})}))}function Ld(e,t){return new Error(e+" "+t)}Bd.$inject=["eventBus","injector"],Bd.prototype._registerDefaultActions=function(e){var t=e.get("commandStack",!1),n=e.get("modeling",!1),i=e.get("selection",!1),o=e.get("zoomScroll",!1),s=e.get("copyPaste",!1),a=e.get("canvas",!1),l=e.get("rules",!1),c=e.get("keyboardMove",!1),u=e.get("keyboardMoveSelection",!1);t&&(this.register("undo",(function(){t.undo()})),this.register("redo",(function(){t.redo()}))),s&&i&&this.register("copy",(function(){var e=i.get();if(e.length)return s.copy(e)})),s&&this.register("paste",(function(){s.paste()})),o&&this.register("stepZoom",(function(e){o.stepZoom(e.value)})),a&&this.register("zoom",(function(e){a.zoom(e.value)})),n&&i&&l&&this.register("removeSelection",(function(){var e=i.get();if(e.length){var t,o=l.allowed("elements.delete",{elements:e});!1!==o&&(t=r(o)?o:e).length&&n.removeElements(t.slice())}})),c&&this.register("moveCanvas",(function(e){c.moveCanvas(e)})),u&&this.register("moveSelection",(function(e){u.moveSelection(e.direction,e.accelerated)}))},Bd.prototype.trigger=function(e,t){if(!this._actions[e])throw Ld(e,Id);return this._actions[e](t)},Bd.prototype.register=function(e,t){var n=this;if("string"==typeof e)return this._registerAction(e,t);p(e,(function(e,t){n._registerAction(t,e)}))},Bd.prototype._registerAction=function(e,t){if(this.isRegistered(e))throw Ld(e,"is already registered");this._actions[e]=t},Bd.prototype.unregister=function(e){if(!this.isRegistered(e))throw Ld(e,Id);this._actions[e]=void 0},Bd.prototype.getActions=function(){return Object.keys(this._actions)},Bd.prototype.isRegistered=function(e){return!!this._actions[e]};var Nd={__init__:["editorActions"],editorActions:["type",Bd]};function qd(e){e.invoke(Bd,this)}yn(qd,Bd),qd.$inject=["injector"],qd.prototype._registerDefaultActions=function(e){Bd.prototype._registerDefaultActions.call(this,e);const t=e.get("canvas",!1),n=e.get("elementRegistry",!1),i=e.get("selection",!1),o=e.get("lassoTool",!1),r=e.get("handTool",!1),s=e.get("directEditing",!1),a=e.get("distributeElements",!1),l=e.get("alignElements",!1),c=e.get("searchPad",!1);t&&n&&i&&this._registerAction("selectElements",(function(){var e=t.getRootElement(),o=n.filter((function(t){return t!==e}));return i.select(o),o})),i&&a&&this._registerAction("distributeElements",(function(e){var t=i.get(),n=e.type;t.length>2&&a.trigger(t,n)})),i&&l&&this._registerAction("alignElements",(function(e){var t=i.get(),n=e.type;t.length>1&&l.trigger(t,n)})),o&&this._registerAction("lassoTool",(function(){o.toggle()})),r&&this._registerAction("handTool",(function(){r.toggle()})),i&&s&&this._registerAction("directEditing",(function(){var e=i.get();e.length&&s.activate(e[0])})),i&&c&&this._registerAction("find",(function(){c.toggle()}))};var Vd={__depends__:[Nd],editorActions:["type",qd]};function Fd(e){return e.dmnDI&&e.dmnDI.diagrams&&e.dmnDI.diagrams[0]}function zd(e,t,n,i){n.on("import.start",(({definitions:n})=>{Fd(n)||function(n){var o=n.dmnDI;o||(o=e.create("dmndi:DMNDI"),n.set("dmnDI",o));var r=e.create("dmndi:DMNDiagram");o.set("diagrams",[r]);var s=0;p(n.get("drgElement"),(function(n){if(hn(n,"dmn:Decision")){var o=t._getDefaultSize(n),a=e.createDiShape(n,{x:150+30*s,y:150+30*s,width:o.width,height:o.height});i.updateDiParent(a,r),s++}}))}(n)}))}zd.$inject=["drdFactory","elementFactory","eventBus","drdUpdater"];var Qd={__init__:["diGenerator"],diGenerator:["type",zd]};function Hd(e,t,n){return n||(n="round"),Math[n](e/t)*t}function Wd(e,t,n){var i=!n||!1!==n.active;this._eventBus=t;var o=this;t.on("diagram.init",800,(function(){o.setActive(i)})),t.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"],1200,(function(t){var n=t.originalEvent;if(!(!o.active||n&&pl(n))){var i=t.context,r=i.gridSnappingContext;r||(r=i.gridSnappingContext={}),["x","y"].forEach((function(n){var i={},r=function(e,t,n){var i=e.context,o=e.shape,r=i.gridSnappingContext,s=r.snapLocation,l=r.snapOffset;if(l&&a(l[t]))return l[t];l||(l=r.snapOffset={});a(l[t])||(l[t]=0);if(!o)return l[t];n.get(o.id)||(Ud(t)?l[t]+=o[t]+o.width/2:l[t]+=o[t]+o.height/2);if(!s)return l[t];"x"===t?/left/.test(s)?l[t]-=o.width/2:/right/.test(s)&&(l[t]+=o.width/2):/top/.test(s)?l[t]-=o.height/2:/bottom/.test(s)&&(l[t]+=o.height/2);return l[t]}(t,n,e);r&&(i.offset=r);var s=function(e,t){var n=e.context,i=n.createConstraints,o=n.resizeConstraints||{},r=n.gridSnappingContext,s=r.snapConstraints;if(s&&s[t])return s[t];s||(s=r.snapConstraints={});s[t]||(s[t]={});var a=n.direction;i&&(Ud(t)?(s.x.min=i.left,s.x.max=i.right):(s.y.min=i.top,s.y.max=i.bottom));var l=o.min,c=o.max;l&&(Ud(t)?Kd(a)?s.x.max=l.left:s.x.min=l.right:Xd(a)?s.y.max=l.top:s.y.min=l.bottom);c&&(Ud(t)?Kd(a)?s.x.min=c.left:s.x.max=c.right:Xd(a)?s.y.min=c.top:s.y.max=c.bottom);return s[t]}(t,n);s&&M(i,s),eu(t,n)||o.snapEvent(t,n,i)}))}}))}function Ud(e){return"x"===e}function Xd(e){return-1!==e.indexOf("n")}function Kd(e){return-1!==e.indexOf("w")}Wd.prototype.snapEvent=function(e,t,n){tu(e,t,this.snapValue(e[t],n))},Wd.prototype.getGridSpacing=function(){return 10},Wd.prototype.snapValue=function(e,t){var n,i,o=0;return t&&t.offset&&(o=t.offset),e=Hd(e+=o,10),t&&t.min&&a(n=t.min)&&(n=Hd(n+o,10,"ceil"),e=Math.max(e,n)),t&&t.max&&a(i=t.max)&&(i=Hd(i+o,10,"floor"),e=Math.min(e,i)),e-=o},Wd.prototype.isActive=function(){return this.active},Wd.prototype.setActive=function(e){this.active=e,this._eventBus.fire("gridSnapping.toggle",{active:e})},Wd.prototype.toggleActive=function(){this.setActive(!this.active)},Wd.$inject=["elementRegistry","eventBus","config.gridSnapping"];function Gd(e){this._eventBus=e}function Yd(e){return function(t,n,i,o,r){(l(t)||a(t))&&(r=o,o=i,i=n,n=t,t=null),this.on(t,e,n,i,o,r)}}function Zd(e,t){Gd.call(this,e),this._gridSnapping=t;var n=this;this.preExecute("shape.resize",(function(e){var t=e.context,i=(t.hints||{}).autoResize;if(i){var o=t.shape,r=t.newBounds;c(i)?t.newBounds=n.snapComplex(r,i):t.newBounds=n.snapSimple(o,r)}}))}Gd.$inject=["eventBus"],Gd.prototype.on=function(e,t,n,i,o,c){if((l(t)||a(t))&&(c=o,o=i,i=n,n=t,t=null),l(n)&&(c=o,o=i,i=n,n=1e3),s(o)&&(c=o,o=!1),!l(i))throw new Error("handlerFn must be a function");r(e)||(e=[e]);var u=this._eventBus;p(e,(function(e){var r=["commandStack",e,t].filter((function(e){return e})).join(".");u.on(r,n,o?function(e,t){return function(n){return e.call(t||null,n.context,n.command,n)}}(i,c):i,c)}))},Gd.prototype.canExecute=Yd("canExecute"),Gd.prototype.preExecute=Yd("preExecute"),Gd.prototype.preExecuted=Yd("preExecuted"),Gd.prototype.execute=Yd("execute"),Gd.prototype.executed=Yd("executed"),Gd.prototype.postExecute=Yd("postExecute"),Gd.prototype.postExecuted=Yd("postExecuted"),Gd.prototype.revert=Yd("revert"),Gd.prototype.reverted=Yd("reverted"),Zd.$inject=["eventBus","gridSnapping","modeling"],yn(Zd,Gd),Zd.prototype.snapSimple=function(e,t){var n=this._gridSnapping;return t.width=n.snapValue(t.width,{min:t.width}),t.height=n.snapValue(t.height,{min:t.height}),t.x=e.x+e.width/2-t.width/2,t.y=e.y+e.height/2-t.height/2,t},Zd.prototype.snapComplex=function(e,t){return/w|e/.test(t)&&(e=this.snapHorizontally(e,t)),/n|s/.test(t)&&(e=this.snapVertically(e,t)),e},Zd.prototype.snapHorizontally=function(e,t){var n=this._gridSnapping,i=/w/.test(t),o=/e/.test(t),r={};return r.width=n.snapValue(e.width,{min:e.width}),o&&(i?(r.x=n.snapValue(e.x,{max:e.x}),r.width+=n.snapValue(e.x-r.x,{min:e.x-r.x})):e.x=e.x+e.width-r.width),M(e,r),e},Zd.prototype.snapVertically=function(e,t){var n=this._gridSnapping,i=/n/.test(t),o=/s/.test(t),r={};return r.height=n.snapValue(e.height,{min:e.height}),i&&(o?(r.y=n.snapValue(e.y,{max:e.y}),r.height+=n.snapValue(e.y-r.y,{min:e.y-r.y})):e.y=e.y+e.height-r.height),M(e,r),e};function Jd(e,t){e.on(["spaceTool.move","spaceTool.end"],2e3,(function(e){var n,i=e.context;i.initialized&&("x"===i.axis?(n=t.snapValue(e.dx),e.x=e.x+n-e.dx,e.dx=n):(n=t.snapValue(e.dy),e.y=e.y+n-e.dy,e.dy=n))}))}Jd.$inject=["eventBus","gridSnapping"];var ep={__depends__:[{__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",Zd],gridSnappingSpaceToolBehavior:["type",Jd]}],__init__:["gridSnapping"],gridSnapping:["type",Wd]},tp="keyboard.keydown",np="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 ip(e,t){var n=this;this._config=e=e||{},this._eventBus=t,this._keydownHandler=this._keydownHandler.bind(this),this._keyupHandler=this._keyupHandler.bind(this),t.on("diagram.destroy",(function(){n._fire("destroy"),n.unbind()})),e.bindTo&&console.error("unsupported configuration <keyboard.bindTo>",new Error(np));var i=e&&!1!==e.bind;t.on("canvas.init",(function(e){n._target=e.svg,i&&n.bind(),n._fire("init")}))}ip.$inject=["config.keyboard","eventBus"],ip.prototype._keydownHandler=function(e){this._keyHandler(e,tp)},ip.prototype._keyupHandler=function(e){this._keyHandler(e,"keyboard.keyup")},ip.prototype._keyHandler=function(e,t){if(!this._isEventIgnored(e)){var n={keyEvent:e};this._eventBus.fire(t||tp,n)&&e.preventDefault()}},ip.prototype._isEventIgnored=function(e){return!1},ip.prototype.bind=function(e){e&&console.error("unsupported argument <node>",new Error(np)),this.unbind(),e=this._node=this._target,zt.bind(e,"keydown",this._keydownHandler),zt.bind(e,"keyup",this._keyupHandler),this._fire("bind")},ip.prototype.getBinding=function(){return this._node},ip.prototype.unbind=function(){var e=this._node;e&&(this._fire("unbind"),zt.unbind(e,"keydown",this._keydownHandler),zt.unbind(e,"keyup",this._keyupHandler)),this._node=null},ip.prototype._fire=function(e){this._eventBus.fire("keyboard."+e,{node:this._node})},ip.prototype.addListener=function(e,t,n){l(e)&&(n=t,t=e,e=1e3),this._eventBus.on(n||tp,e,t)},ip.prototype.removeListener=function(e,t){this._eventBus.off(t||tp,e)},ip.prototype.hasModifier=function(e){return e.ctrlKey||e.metaKey||e.shiftKey||e.altKey},ip.prototype.isCmd=pl,ip.prototype.isShift=gl,ip.prototype.isKey=fl;var op=500;function rp(e,t){var n=this;e.on("editorActions.init",op,(function(e){var i=e.editorActions;n.registerBindings(t,i)}))}rp.$inject=["eventBus","keyboard"],rp.prototype.registerBindings=function(e,t){function n(n,i){t.isRegistered(n)&&e.addListener(i)}n("undo",(function(e){if(ml(e.keyEvent))return t.trigger("undo"),!0})),n("redo",(function(e){if(vl(e.keyEvent))return t.trigger("redo"),!0})),n("copy",(function(e){if(function(e){return pl(e)&&fl(cl,e)}(e.keyEvent))return t.trigger("copy"),!0})),n("paste",(function(e){if(function(e){return pl(e)&&fl(ul,e)}(e.keyEvent))return t.trigger("paste"),!0})),n("stepZoom",(function(e){var n=e.keyEvent;if(fl(["+","Add","="],n)&&pl(n))return t.trigger("stepZoom",{value:1}),!0})),n("stepZoom",(function(e){var n=e.keyEvent;if(fl(["-","Subtract"],n)&&pl(n))return t.trigger("stepZoom",{value:-1}),!0})),n("zoom",(function(e){var n=e.keyEvent;if(fl("0",n)&&pl(n))return t.trigger("zoom",{value:1}),!0})),n("removeSelection",(function(e){if(fl(["Backspace","Delete","Del"],e.keyEvent))return t.trigger("removeSelection"),!0}))};var sp={__init__:["keyboard","keyboardBindings"],keyboard:["type",ip],keyboardBindings:["type",rp]};function ap(e){e.invoke(rp,this)}yn(ap,rp),ap.$inject=["injector"],ap.prototype.registerBindings=function(e,t){function n(n,i){t.isRegistered(n)&&e.addListener(i)}rp.prototype.registerBindings.call(this,e,t),n("selectElements",(function(n){var i=n.keyEvent;if(e.isKey(["a","A"],i)&&e.isCmd(i))return t.trigger("selectElements"),!0})),n("lassoTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["l","L"],i)?(t.trigger("lassoTool"),!0):void 0})),n("handTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["h","H"],i)?(t.trigger("handTool"),!0):void 0})),n("directEditing",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["e","E"],i)?(t.trigger("directEditing"),!0):void 0})),n("find",(function(n){var i=n.keyEvent;if(e.isKey(["f","F"],i)&&e.isCmd(i))return t.trigger("find"),!0}))};var lp={__depends__:[sp],__init__:["keyboardBindings"],keyboardBindings:["type",ap]},cp={moveSpeed:50,moveSpeedAccelerated:200};function up(e,t,n){var i=this;this._config=M({},cp,e||{}),t.addListener((function(e){var n=e.keyEvent,o=i._config;if(!t.isCmd(n))return;if(t.isKey(["ArrowLeft","Left","ArrowUp","Up","ArrowDown","Down","ArrowRight","Right"],n)){var r,s=t.isShift(n)?o.moveSpeedAccelerated:o.moveSpeed;switch(n.key){case"ArrowLeft":case"Left":r="left";break;case"ArrowUp":case"Up":r="up";break;case"ArrowRight":case"Right":r="right";break;case"ArrowDown":case"Down":r="down"}return i.moveCanvas({speed:s,direction:r}),!0}})),this.moveCanvas=function(e){var t=0,i=0,o=e.speed/Math.min(Math.sqrt(n.viewbox().scale),1);switch(e.direction){case"left":t=o;break;case"up":i=o;break;case"right":t=-o;break;case"down":i=-o}n.scroll({dx:t,dy:i})}}up.$inject=["config.keyboardMove","keyboard","canvas"];var hp={__depends__:[sp],__init__:["keyboardMove"],keyboardMove:["type",up]},dp={moveSpeed:1,moveSpeedAccelerated:10},pp="left",fp="right",gp="down",mp={ArrowLeft:pp,Left:pp,ArrowUp:"up",Up:"up",ArrowRight:fp,Right:fp,ArrowDown:gp,Down:gp},vp={left:function(e){return{x:-e,y:0}},up:function(e){return{x:0,y:-e}},right:function(e){return{x:e,y:0}},down:function(e){return{x:0,y:e}}};function yp(e,t,n,i,o){var r=this;this._config=M({},dp,e||{}),t.addListener(1500,(function(e){var n=e.keyEvent,i=mp[n.key];if(i&&!t.isCmd(n)){var o=t.isShift(n);return r.moveSelection(i,o),!0}})),this.moveSelection=function(e,t){var r=o.get();if(r.length){var s=this._config[t?"moveSpeedAccelerated":"moveSpeed"],a=vp[e](s);i.allowed("elements.move",{shapes:r})&&n.moveElements(r,a)}}}yp.$inject=["config.keyboardMoveSelection","keyboard","modeling","rules","selection"];var xp={__depends__:[sp,Aa],__init__:["keyboardMoveSelection"],keyboardMoveSelection:["type",yp]};function bp(e,t){this._handlerMap={},this._stack=[],this._stackIdx=-1,this._currentExecution={actions:[],dirty:[],trigger:null},this._injector=t,this._eventBus=e,this._uid=1,e.on(["diagram.destroy","diagram.clear"],(function(){this.clear(!1)}),this)}bp.$inject=["eventBus","injector"],bp.prototype.execute=function(e,t){if(!e)throw new Error("command required");this._currentExecution.trigger="execute";const n={command:e,context:t};this._pushAction(n),this._internalExecute(n),this._popAction()},bp.prototype.canExecute=function(e,t){const n={command:e,context:t},i=this._getHandler(e);let o=this._fire(e,"canExecute",n);if(void 0===o){if(!i)return!1;i.canExecute&&(o=i.canExecute(t))}return o},bp.prototype.clear=function(e){this._stack.length=0,this._stackIdx=-1,!1!==e&&this._fire("changed",{trigger:"clear"})},bp.prototype.undo=function(){let e,t=this._getUndoAction();if(t){for(this._currentExecution.trigger="undo",this._pushAction(t);t&&(this._internalUndo(t),e=this._getUndoAction(),e&&e.id===t.id);)t=e;this._popAction()}},bp.prototype.redo=function(){let e,t=this._getRedoAction();if(t){for(this._currentExecution.trigger="redo",this._pushAction(t);t&&(this._internalExecute(t,!0),e=this._getRedoAction(),e&&e.id===t.id);)t=e;this._popAction()}},bp.prototype.register=function(e,t){this._setHandler(e,t)},bp.prototype.registerHandler=function(e,t){if(!e||!t)throw new Error("command and handlerCls must be defined");const n=this._injector.instantiate(t);this.register(e,n)},bp.prototype.canUndo=function(){return!!this._getUndoAction()},bp.prototype.canRedo=function(){return!!this._getRedoAction()},bp.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]},bp.prototype._getUndoAction=function(){return this._stack[this._stackIdx]},bp.prototype._internalUndo=function(e){const t=e.command,n=e.context,i=this._getHandler(t);this._atomicDo((()=>{this._fire(t,"revert",e),i.revert&&this._markDirty(i.revert(n)),this._revertedAction(e),this._fire(t,"reverted",e)}))},bp.prototype._fire=function(e,t,n){arguments.length<3&&(n=t,t=null);const i=t?[e+"."+t,t]:[e];let o;n=this._eventBus.createEvent(n);for(const e of i)if(o=this._eventBus.fire("commandStack."+e,n),n.cancelBubble)break;return o},bp.prototype._createId=function(){return this._uid++},bp.prototype._atomicDo=function(e){const t=this._currentExecution;t.atomic=!0;try{e()}finally{t.atomic=!1}},bp.prototype._internalExecute=function(e,t){const n=e.command,i=e.context,o=this._getHandler(n);if(!o)throw new Error("no command handler registered for <"+n+">");this._pushAction(e),t||(this._fire(n,"preExecute",e),o.preExecute&&o.preExecute(i),this._fire(n,"preExecuted",e)),this._atomicDo((()=>{this._fire(n,"execute",e),o.execute&&this._markDirty(o.execute(i)),this._executedAction(e,t),this._fire(n,"executed",e)})),t||(this._fire(n,"postExecute",e),o.postExecute&&o.postExecute(i),this._fire(n,"postExecuted",e)),this._popAction()},bp.prototype._pushAction=function(e){const t=this._currentExecution,n=t.actions,i=n[0];if(t.atomic)throw new Error("illegal invocation in <execute> or <revert> phase (action: "+e.command+")");e.id||(e.id=i&&i.id||this._createId()),n.push(e)},bp.prototype._popAction=function(){const e=this._currentExecution,t=e.trigger,n=e.actions,i=e.dirty;n.pop(),n.length||(this._eventBus.fire("elements.changed",{elements:_("id",i.reverse())}),i.length=0,this._fire("changed",{trigger:t}),e.trigger=null)},bp.prototype._markDirty=function(e){const t=this._currentExecution;e&&(e=r(e)?e:[e],t.dirty=t.dirty.concat(e))},bp.prototype._executedAction=function(e,t){const n=++this._stackIdx;t||this._stack.splice(n,this._stack.length,e)},bp.prototype._revertedAction=function(e){this._stackIdx--},bp.prototype._getHandler=function(e){return this._handlerMap[e]},bp.prototype._setHandler=function(e,t){if(!e||!t)throw new Error("command and handler required");if(this._handlerMap[e])throw new Error("overriding handler for command <"+e+">");this._handlerMap[e]=t};var _p={commandStack:["type",bp]};function wp(e,t,n,i){e.on("element.changed",(function(i){var o=i.element;(o.parent||o===t.getRootElement())&&(i.gfx=n.getGraphics(o)),i.gfx&&e.fire(vi(o)+".changed",i)})),e.on("elements.changed",(function(t){var n=t.elements;n.forEach((function(t){e.fire("element.changed",{element:t})})),i.updateContainments(n)})),e.on("shape.changed",(function(e){i.update("shape",e.element,e.gfx)})),e.on("connection.changed",(function(e){i.update("connection",e.element,e.gfx)}))}wp.$inject=["eventBus","canvas","elementRegistry","graphicsFactory"];var Cp={__init__:["changeSupport"],changeSupport:["type",wp]},Op=Math.min,kp=Math.max;function Ep(e){e.preventDefault()}function Sp(e){e.stopPropagation()}function Rp(e){this.container=e.container,this.parent=Gt('<div class="djs-direct-editing-parent"><div class="djs-direct-editing-content" contenteditable="true"></div></div>'),this.content=Zt("[contenteditable]",this.parent),this.keyHandler=e.keyHandler||function(){},this.resizeHandler=e.resizeHandler||function(){},this.autoResize=T(this.autoResize,this),this.handlePaste=T(this.handlePaste,this)}function Tp(e,t){this._eventBus=e,this._canvas=t,this._providers=[],this._textbox=new Rp({container:t.getContainer(),keyHandler:T(this._handleKey,this),resizeHandler:T(this._handleResize,this)})}Rp.prototype.create=function(e,t,n,i){var o=this.parent,r=this.content,s=this.container;i=this.options=i||{};var a=A(t=this.style=t||{},["width","height","maxWidth","maxHeight","minWidth","minHeight","left","top","backgroundColor","position","overflow","border","wordWrap","textAlign","outline","transform"]);M(o.style,{width:e.width+"px",height:e.height+"px",maxWidth:e.maxWidth+"px",maxHeight:e.maxHeight+"px",minWidth:e.minWidth+"px",minHeight:e.minHeight+"px",left:e.x+"px",top:e.y+"px",backgroundColor:"#ffffff",position:"absolute",overflow:"visible",border:"1px solid #ccc",boxSizing:"border-box",wordWrap:"normal",textAlign:"center",outline:"none"},a);var l=A(t,["fontFamily","fontSize","fontWeight","lineHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft"]);return M(r.style,{boxSizing:"border-box",width:"100%",outline:"none",wordWrap:"break-word"},l),i.centerVertically&&M(r.style,{position:"absolute",top:"50%",transform:"translate(0, -50%)"},l),r.innerText=n,zt.bind(r,"keydown",this.keyHandler),zt.bind(r,"mousedown",Sp),zt.bind(r,"paste",this.handlePaste),i.autoResize&&zt.bind(r,"input",this.autoResize),i.resizable&&this.resizable(t),s.appendChild(o),this.setSelection(r.lastChild,r.lastChild&&r.lastChild.length),o},Rp.prototype.handlePaste=function(e){var t,n=this.options,i=this.style;if(e.preventDefault(),t=e.clipboardData?e.clipboardData.getData("text/plain"):window.clipboardData.getData("Text"),this.insertText(t),n.autoResize){var o=this.autoResize(i);o&&this.resizeHandler(o)}},Rp.prototype.insertText=function(e){e=function(e){return e.replace(/\r\n|\r|\n/g,"\n")}(e),document.execCommand("insertText",!1,e)||this._insertTextIE(e)},Rp.prototype._insertTextIE=function(e){var t,n,i,o=this.getSelection(),r=o.startContainer,s=o.endContainer,a=o.startOffset,l=o.endOffset,c=o.commonAncestorContainer,u=(t=c.childNodes,[].slice.call(t));if(function(e){return e.nodeType===Node.TEXT_NODE}(c)){var h=r.textContent;r.textContent=h.substring(0,a)+e+h.substring(l),n=r,i=a+e.length}else if(r===this.content&&s===this.content){var d=document.createTextNode(e);this.content.insertBefore(d,u[a]),n=d,i=d.textContent.length}else{var p=u.indexOf(r),f=u.indexOf(s);u.forEach((function(t,n){n===p?t.textContent=r.textContent.substring(0,a)+e+s.textContent.substring(l):n>p&&n<=f&&en(t)})),n=r,i=a+e.length}n&&void 0!==i&&setTimeout((function(){self.setSelection(n,i)}))},Rp.prototype.autoResize=function(){var e=this.parent,t=this.content,n=parseInt(this.style.fontSize)||12;if(t.scrollHeight>e.offsetHeight||t.scrollHeight<e.offsetHeight-n){var i=e.getBoundingClientRect(),o=t.scrollHeight;e.style.height=o+"px",this.resizeHandler({width:i.width,height:i.height,dx:0,dy:o-i.height})}},Rp.prototype.resizable=function(){var e=this,t=this.parent,n=this.resizeHandle,i=parseInt(this.style.minWidth)||0,o=parseInt(this.style.minHeight)||0,r=parseInt(this.style.maxWidth)||1/0,s=parseInt(this.style.maxHeight)||1/0;if(!n){var a,l,c,u;n=this.resizeHandle=Gt('<div class="djs-direct-editing-resize-handle"></div>');var h=function(n){Ep(n),Sp(n);var h=Op(kp(c+n.clientX-a,i),r),d=Op(kp(u+n.clientY-l,o),s);t.style.width=h+"px",t.style.height=d+"px",e.resizeHandler({width:c,height:u,dx:n.clientX-a,dy:n.clientY-l})},d=function(e){Ep(e),Sp(e),zt.unbind(document,"mousemove",h,!1),zt.unbind(document,"mouseup",d,!1)};zt.bind(n,"mousedown",(function(e){Ep(e),Sp(e),a=e.clientX,l=e.clientY;var n=t.getBoundingClientRect();c=n.width,u=n.height,zt.bind(document,"mousemove",h),zt.bind(document,"mouseup",d)}))}M(n.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"}),t.appendChild(n)},Rp.prototype.destroy=function(){var e=this.parent,t=this.content,n=this.resizeHandle;t.innerText="",e.removeAttribute("style"),t.removeAttribute("style"),zt.unbind(t,"keydown",this.keyHandler),zt.unbind(t,"mousedown",Sp),zt.unbind(t,"input",this.autoResize),zt.unbind(t,"paste",this.handlePaste),n&&(n.removeAttribute("style"),en(n)),en(e)},Rp.prototype.getValue=function(){return this.content.innerText.trim()},Rp.prototype.getSelection=function(){return window.getSelection().getRangeAt(0)},Rp.prototype.setSelection=function(e,t){var n=document.createRange();null===e?n.selectNodeContents(this.content):(n.setStart(e,t),n.setEnd(e,t));var i=window.getSelection();i.removeAllRanges(),i.addRange(n)},Tp.$inject=["eventBus","canvas"],Tp.prototype.registerProvider=function(e){this._providers.push(e)},Tp.prototype.isActive=function(e){return!(!this._active||e&&this._active.element!==e)},Tp.prototype.cancel=function(){this._active&&(this._fire("cancel"),this.close())},Tp.prototype._fire=function(e,t){this._eventBus.fire("directEditing."+e,t||{active:this._active})},Tp.prototype.close=function(){this._textbox.destroy(),this._fire("deactivate"),this._active=null,this.resizable=void 0,this._canvas.restoreFocus&&this._canvas.restoreFocus()},Tp.prototype.complete=function(){var e=this._active;if(e){var t,n=e.context.bounds,i=this.$textbox.getBoundingClientRect(),o=this.getValue();o===e.context.text&&i.height===n.height&&i.width===n.width||(t=this._textbox.container.getBoundingClientRect(),e.provider.update(e.element,o,e.context.text,{x:i.left-t.left,y:i.top-t.top,width:i.width,height:i.height})),this._fire("complete"),this.close()}},Tp.prototype.getValue=function(){return this._textbox.getValue()},Tp.prototype._handleKey=function(e){e.stopPropagation();var t=e.keyCode||e.charCode;return 27===t?(e.preventDefault(),this.cancel()):13!==t||e.shiftKey?void 0:(e.preventDefault(),this.complete())},Tp.prototype._handleResize=function(e){this._fire("resize",e)},Tp.prototype.activate=function(e){var t;this.isActive()&&this.cancel();var n=h(this._providers,(function(n){return(t=n.activate(e))?n:null}));return t&&(this.$textbox=this._textbox.create(t.bounds,t.style,t.text,t.options),this._active={element:e,context:t,provider:n},t.options&&t.options.resizable&&(this.resizable=!0),this._fire("activate")),!!t};var Mp={__depends__:[Oa],__init__:["directEditing"],directEditing:["type",Tp]},Ap="djs-label-hidden";function Pp(e,t,n,i,o){this._canvas=e,this._modeling=i,this._textRenderer=o,this._eventBus=n,t.registerProvider(this),n.on("element.dblclick",(function(e){t.activate(e.element)})),n.on(["autoPlace.start","canvas.viewbox.changing","drag.init","drillDown.click","element.mousedown","popupMenu.open","selection.changed"],(function(){t.complete()})),n.on(["commandStack.changed"],(function(){t.cancel()})),n.on("create.end",500,(function(e){var n=e.shape;(hn(n,"dmn:Decision")||hn(n,"dmn:InputData")||hn(n,"dmn:BusinessKnowledgeModel")||hn(n,"dmn:KnowledgeSource")||hn(n,"dmn:TextAnnotation"))&&t.activate(n)})),n.on("autoPlace.end",500,(function(e){t.activate(e.shape)})),this._eventBus.on(["directEditing.complete","directEditing.cancel"],(function(t){var n=t.active;if(n){var i=n.element.label||n.element;e.removeMarker(i,Ap)}}))}Pp.$inject=["canvas","directEditing","eventBus","modeling","textRenderer"],Pp.prototype.activate=function(e){var t=wl(e);if(i(t)){var n={text:t};M(n,this.getEditingBBox(e));var o={},r=n.style||{};return hn(e,"dmn:DRGElement")&&(M(o,{centerVertically:!0}),M(r,{backgroundColor:null,border:null})),hn(e,"dmn:TextAnnotation")&&M(o,{resizable:!0}),M(n,{options:o,style:r}),this._canvas.addMarker(e,Ap),n}},Pp.prototype.getEditingBBox=function(e){var t=this._canvas,n=e.label||e,i=t.getAbsoluteBBox(n),o={x:i.x,y:i.y},r=t.zoom(),s=this._textRenderer.getDefaultStyle(),a=s.fontSize*r,l=s.lineHeight,c={fontFamily:this._textRenderer.getDefaultStyle().fontFamily,fontWeight:this._textRenderer.getDefaultStyle().fontWeight};return hn(e,"dmn:DRGElement")&&(M(o,{width:i.width,height:i.height}),M(c,{fontSize:a+"px",lineHeight:l,paddingTop:7*r+"px",paddingBottom:7*r+"px",paddingLeft:5*r+"px",paddingRight:5*r+"px"})),hn(e,"dmn:TextAnnotation")&&(M(o,{width:i.width,height:i.height,minWidth:30*r,minHeight:10*r}),M(c,{textAlign:"left",paddingTop:5*r+"px",paddingBottom:7*r+"px",paddingLeft:7*r+"px",paddingRight:5*r+"px",fontSize:a+"px",lineHeight:l})),{bounds:o,style:c}},Pp.prototype.update=function(e,t,n,i){var o,r,s;hn(e,"dmn:TextAnnotation")&&(r=this._canvas.getAbsoluteBBox(e),o={x:e.x,y:e.y,width:e.width/r.width*i.width,height:e.height/r.height*i.height}),(s=t)&&s.trim()||(t=null),this._modeling.updateLabel(e,t,o)};var Dp={__depends__:[_p,Cp,Mp],__init__:["labelEditingProvider"],labelEditingProvider:["type",Pp]};function $p(e,t){t.invoke(Gd,this),this.preExecute("connection.create",(function(t){var n=t.connection,i=n.businessObject,o=t.source,r=t.target;hn(n,"dmn:Association")?((i.sourceRef=e.create("dmn:DMNElementReference",{href:"#"+o.id})).$parent=i,(i.targetRef=e.create("dmn:DMNElementReference",{href:"#"+r.id})).$parent=i):(i["required"+function(e){if(hn(e,"dmn:BusinessKnowledgeModel"))return"Knowledge";if(hn(e,"dmn:Decision"))return"Decision";if(hn(e,"dmn:InputData"))return"Input";if(hn(e,"dmn:KnowledgeSource"))return"Authority"}(o)]=e.create("dmn:DMNElementReference",{href:"#"+o.id})).$parent=i}),!0)}$p.$inject=["drdFactory","injector"],yn($p,Gd);function jp(e,t,n,i){function o(e,i,o){i||(i=e.incoming.filter((function(e){return hn(e,"dmn:InformationRequirement")})));var r={};o?r[o]=i:r=function(e,t){var n={};return t.forEach((function(t){var i=vo(t.source,e).split("-").shift();n[i]||(n[i]=[]),n[i].push(t)})),n}(e,i),p(r,(function(i,o){i=function(e,t){var n;n=t.includes("top")||t.includes("bottom")?"x":"y";return e.sort((function(e,t){return mo(e.source)[n]-mo(t.source)[n]}))}(i,o);var r=function(e,t,n){return e.map((function(i,o){var r=i.source,s=mo(r),a=po(r),l=po(t),c=e.length;return n.includes("bottom")?{start:{x:s.x,y:a.top},end:{x:l.left+t.width/(c+1)*(o+1),y:l.bottom}}:n.includes("top")?{start:{x:s.x,y:a.bottom},end:{x:l.left+t.width/(c+1)*(o+1),y:l.top}}:n.includes("right")?{start:{x:a.left,y:s.y},end:{x:l.right,y:l.top+t.height/(c+1)*(o+1)}}:{start:{x:a.right,y:s.y},end:{x:l.left,y:l.top+t.height/(c+1)*(o+1)}}}))}(i,e,o);i.forEach(((e,i)=>{var o=r[i].start,s=r[i].end,a=t.layoutConnection(e,{connectionStart:o,connectionEnd:s});n.updateWaypoints(e,a)}))}))}e.invoke(Gd,this),this.preExecute(["connection.create","connection.reconnect"],(function(e){var t=e.connection,n=e.newSource||e.source,o=e.newTarget||e.target;if((!hn(t,"dmn:InformationRequirement")||i.allowed("connection.connect",{connection:t,source:n,target:o}))&&hn(t,"dmn:InformationRequirement")){var r=vo(n,o);e.hints||(e.hints={}),M(e.hints,function(e,t,n){var i=mo(e),o=mo(t);n.includes("bottom")?(i.y=e.y,o.y=t.y+t.height):n.includes("top")?(i.y=e.y+e.height,o.y=t.y):n.includes("right")?(i.x=e.x,o.x=t.x+t.width):(i.x=e.x+e.width,o.x=t.x);return{connectionStart:i,connectionEnd:o}}(n,o,r))}}),!0),this.postExecuted(["connection.create","connection.delete","connection.reconnect"],(function(e){var t=e.connection,n=t.source||e.source,i=t.target||e.target;if(hn(t,"dmn:InformationRequirement")){var r=vo(n,i),s=i.incoming.filter((e=>{var t=vo(e.source,e.target);return hn(e,"dmn:InformationRequirement")&&Ip(t,r)}));s.length&&o(i,s,r)}}),!0),this.preExecute("connection.reconnect",(function(e){var t=e.connection,n=t.source,i=t.target;if(hn(t,"dmn:InformationRequirement")){var r=vo(n,i),s=i.incoming.filter((e=>{var n=vo(e.source,e.target);return e!==t&&hn(e,"dmn:InformationRequirement")&&Ip(n,r)}));s.length&&o(i,s,r)}}),!0),this.postExecuted("elements.move",500,(function(e){var t=e.shapes,n=e.closure.enclosedConnections;t.forEach((function(e){if(gn(e,["dmn:Decision","dmn:InputData"])){var t=e.incoming.filter((function(e){return hn(e,"dmn:InformationRequirement")&&!n[e.id]}));t.length&&o(e,t),e.outgoing.forEach((function(e){hn(e,"dmn:InformationRequirement")&&!n[e.id]&&o(e.target)}))}}))}),!0)}function Ip(e,t){return e&&t&&e.split("-").shift()===t.split("-").shift()}function Bp(e,t,n){e.invoke(Gd,this),this.preExecute("connection.reconnect",(function(e){var i=e.connection,o=e.newSource||i.source,r=e.newTarget||i.target,s=i.waypoints.slice(),a=n.allowed("connection.reconnect",{connection:i,source:o,target:r});a&&a.type!==i.type&&(e.connection=t.connect(o,r,{type:a.type,waypoints:s}),t.removeConnection(i))}),!0)}function Lp(e,t,n){Gd.call(this,e),this._modeling=t,this.postExecuted(["shape.replace"],1500,(function(e){var i=e.context,o=i.oldShape,r=i.newShape;t.unclaimId(o.businessObject.id,o.businessObject),t.updateProperties(r,{id:o.id}),n.select(r)}))}jp.$inject=["injector","layouter","modeling","rules"],yn(jp,Gd),yn(Bp,Gd),Bp.$inject=["injector","modeling","rules"],yn(Lp,Gd),Lp.$inject=["eventBus","modeling","selection"];const Np="id";class qp extends Gd{constructor(e){super(e),this.executed("element.updateProperties",this.updateIds.bind(this))}updateIds({context:e}){const{element:t,oldProperties:n,properties:i}=e,o=fn(t);if(this.shouldSkipUpdate(o,n,i))return;const r=function(e){let t=e;for(;!hn(t,"dmn:Definitions");)t=t.$parent;return t}(o);r.get("drgElement").forEach((e=>{!function(e,t,n){const i={authorityRequirement:()=>{e.authorityRequirement.forEach((e=>{const{requiredAuthority:i,requiredDecision:o,requiredInput:r}=e;i&&i.href===`#${t}`&&(i.href=`#${n}`),o&&o.href===`#${t}`&&(o.href=`#${n}`),r&&r.href===`#${t}`&&(r.href=`#${n}`)}))},informationRequirement:()=>{e.informationRequirement.forEach((e=>{const{requiredDecision:i,requiredInput:o}=e;i&&i.href===`#${t}`&&(i.href=`#${n}`),o&&o.href===`#${t}`&&(o.href=`#${n}`)}))},knowledgeRequirement:()=>{e.knowledgeRequirement.forEach((e=>{const{requiredKnowledge:i}=e;i&&i.href===`#${t}`&&(i.href=`#${n}`)}))}};p(i,((t,n)=>{e[n]&&t()}))}(e,n.id,i.id)}));r.get("artifact").forEach((e=>{!function(e,t,n){const i={sourceRef:()=>{const{sourceRef:i}=e;i.href===`#${t}`&&(i.href=`#${n}`)},targetRef:()=>{const{targetRef:i}=e;i.href===`#${t}`&&(i.href=`#${n}`)}};p(i,((t,n)=>{e[n]&&t()}))}(e,n.id,i.id)}))}shouldSkipUpdate(e,t,n){return!function(e,t){return Np in e&&Np in t}(t,n)||!hn(e,"dmn:DRGElement")&&!hn(e,"dmn:TextAnnotation")}}qp.$inject=["eventBus"];let Vp=class extends Gd{static $inject=["eventBus","modeling"];constructor(e,t){super(e),this._modeling=t,this.postExecuted("element.updateProperties",this.updateVariableFromElement),this.postExecuted("element.updateLabel",this.updateVariableFromLabel)}updateVariableFromLabel=({context:e})=>{const{element:t,newLabel:n}=e,i=fn(t).variable;i&&this._modeling.updateProperties(i,{name:n})};updateVariableFromElement=({context:e})=>{const{element:t,properties:n}=e,i=fn(t);i.variable&&(hn(t,"dmn:Decision")||hn(t,"dmn:BusinessKnowledgeModel"))&&this.isNameChanged(n)&&(this.isVariable(t)||this.shouldSyncVariable(t)||this.syncElementVariableChange(i))};isNameChanged(e){return"name"in e}isVariable(e){const t=function(e){return e.$parent}(e);return hn(e,"dmn:InformationItem")&&t&&t.get("variable")===e}shouldSyncVariable(e){const t=fn(e),n=t.get("variable");return n&&t.name===n.name}syncElementVariableChange(e){const t=e.get("name"),n=e.variable;this._modeling.updateProperties(n,{name:t})}};var Fp={__init__:["createConnectionBehavior","idChangeBehavior","nameChangeBehavior","layoutConnectionBehavior","replaceConnectionBehavior","replaceElementBehavior"],createConnectionBehavior:["type",$p],idChangeBehavior:["type",qp],nameChangeBehavior:["type",Vp],layoutConnectionBehavior:["type",jp],replaceConnectionBehavior:["type",Bp],replaceElementBehavior:["type",Lp]};function zp(e){Gd.call(this,e),this.init()}function Qp(e){e.invoke(zp,this)}function Hp(e,t){if(!e||Xp(e)||!t||Xp(t))return null;if(e===t)return!1;if(hn(e,"dmn:BusinessKnowledgeModel")&&gn(t,["dmn:BusinessKnowledgeModel","dmn:Decision"]))return{type:"dmn:KnowledgeRequirement"};if(hn(e,"dmn:Decision")){if(hn(t,"dmn:Decision"))return{type:"dmn:InformationRequirement"};if(hn(t,"dmn:KnowledgeSource"))return{type:"dmn:AuthorityRequirement"}}if(hn(e,"dmn:Definitions")||hn(t,"dmn:Definitions"))return!1;if(hn(e,"dmn:InputData")){if(hn(t,"dmn:Decision"))return{type:"dmn:InformationRequirement"};if(hn(t,"dmn:KnowledgeSource"))return{type:"dmn:AuthorityRequirement"}}return hn(e,"dmn:KnowledgeSource")&&gn(t,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:KnowledgeSource"])?{type:"dmn:AuthorityRequirement"}:!!(hn(e,"dmn:TextAnnotation")&&!hn(t,"dmn:TextAnnotation")||!hn(e,"dmn:TextAnnotation")&&hn(t,"dmn:TextAnnotation"))&&{type:"dmn:Association"}}function Wp(e,t){return gn(e,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:InputData","dmn:KnowledgeSource","dmn:TextAnnotation"])&&hn(t,"dmn:Definitions")}function Up(e,t){return r(e)||(e=[e]),!t||!(!g(e,(function(e){return gn(e,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:InputData","dmn:KnowledgeSource","dmn:TextAnnotation","dmn:InformationRequirement","dmn:AuthorityRequirement","dmn:KnowledgeRequirement","dmn:Association"])}))||!hn(t,"dmn:Definitions"))}function Xp(e){return!!e.labelTarget}zp.$inject=["eventBus"],yn(zp,Gd),zp.prototype.addRule=function(e,t,n){var i=this;"string"==typeof e&&(e=[e]),e.forEach((function(e){i.canExecute(e,t,(function(e,t,i){return n(e)}),!0)}))},zp.prototype.init=function(){},yn(Qp,zp),Qp.$inject=["injector"],Qp.prototype.init=function(){this.addRule("connection.create",(function(e){return Hp(e.source,e.target)})),this.addRule("connection.reconnect",(function(e){return e.connection,Hp(e.source,e.target)})),this.addRule("connection.updateWaypoints",(function(e){const t=e.connection;return{type:t.type,businessObject:t.businessObject}})),this.addRule("elements.move",(function(e){var t=e.target,n=e.shapes;return e.position,Up(n,t)})),this.addRule("shape.create",(function(e){return Wp(e.shape,e.target)})),this.addRule("shape.resize",(function(e){return hn(e.shape,"dmn:TextAnnotation")}))},Qp.prototype.canConnect=Hp,Qp.prototype.canCreate=Wp,Qp.prototype.canMove=Up;var Kp={__depends__:[gc],__init__:["drdRules"],drdRules:["type",Qp]};function Gp(e){this._model=e}function Yp(e,t,n,i,o){o.invoke(Gd,this),this._definitionPropertiesView=t,this._drdFactory=n,this._drdRules=i;var r=this;function s(e){var t=e.connection,n=e.parent,i=e.shape;t&&!hn(t,"dmn:Association")&&(n=t.target),r.updateParent(i||t,n)}function a(e){var t=e.connection,n=e.shape,i=e.parent||e.newParent;t&&!hn(t,"dmn:Association")&&(i=t.target),r.updateParent(n||t,i)}function l(e){var t=e.shape;(hn(t,"dmn:DRGElement")||hn(t,"dmn:TextAnnotation"))&&r.updateBounds(t)}function c(e){r.updateConnectionWaypoints(e)}this.executed(["connection.create","connection.layout"],(function(t){var n=t.connection;t.cropped||(n.waypoints=e.getCroppedWaypoints(n),t.cropped=!0)}),!0),this.reverted(["connection.layout"],(function(e){delete e.cropped}),!0),this.executed(["connection.create","connection.delete","connection.move","shape.create","shape.delete"],s,!0),this.reverted(["connection.create","connection.delete","connection.move","shape.create","shape.delete"],a,!0),this.executed(["shape.create","shape.move","shape.resize"],l,!0),this.reverted(["shape.create","shape.move","shape.resize"],l,!0),this.executed(["connection.create","connection.layout","connection.move","connection.updateWaypoints"],c,!0),this.reverted(["connection.create","connection.layout","connection.move","connection.updateWaypoints"],c,!0),this.executed("connection.create",(function(e){var t=e.connection,n=t.businessObject,i=e.target.businessObject;hn(t,"dmn:Association")?s(e):r.updateSemanticParent(n,i)}),!0),this.reverted("connection.create",(function(e){a(e)}),!0),this.executed("connection.reconnect",(function(e){var t=e.connection.businessObject,n=e.newTarget.businessObject;hn(t,"dmn:Association")||r.updateSemanticParent(t,n)}),!0),this.reverted("connection.reconnect",(function(e){var t=e.connection.businessObject,n=e.oldTarget.businessObject;hn(t,"dmn:Association")||r.updateSemanticParent(t,n)}),!0),this.executed("element.updateProperties",(function(e){t.update()}),!0),this.reverted("element.updateProperties",(function(e){t.update()}),!0)}function Zp(e,t){this._modeling=e,this._canvas=t}function Jp(e){this._modeling=e}function ef(e,t){this._canvas=e,this._layouter=t}Gp.$inject=["moddle"],Gp.prototype._needsId=function(e){return gn(e,["dmn:Artifact","dmn:DMNElement","dmn:DRGElement","dmndi:DMNDiagram","dmndi:DMNDiagramElement"])},Gp.prototype._ensureId=function(e){var t=(e.$type||"").replace(/^[^:]*:/g,"")+"_";!e.id&&this._needsId(e)&&(e.id=this._model.ids.nextPrefixed(t,e))},Gp.prototype.create=function(e,t){var n=this._model.create(e,t||{});return this._ensureId(n),n},Gp.prototype.createDiShape=function(e,t,n){return this.create("dmndi:DMNShape",M({dmnElementRef:e,bounds:this.createDiBounds(t)},n))},Gp.prototype.createDiBounds=function(e){return this.create("dc:Bounds",e)},Gp.prototype.createDiEdge=function(e,t,n){return this.create("dmndi:DMNEdge",{dmnElementRef:e,waypoint:this.createDiWaypoints(t)},n)},Gp.prototype.createDiWaypoints=function(e){var t=this;return e.map((function(e){return t.createDiWaypoint(e)}))},Gp.prototype.createDiWaypoint=function(e){return this.create("dc:Point",A(e,["x","y"]))},Gp.prototype.createExtensionElements=function(){return this.create("dmn:ExtensionElements",{values:[]})},yn(Yp,Gd),Yp.$inject=["connectionDocking","definitionPropertiesView","drdFactory","drdRules","injector"],Yp.prototype.updateBounds=function(e){M(e.businessObject.di.bounds,{x:e.x,y:e.y,width:e.width,height:e.height})},Yp.prototype.updateConnectionWaypoints=function(e){var t=this._drdFactory,n=e.connection,i=n.businessObject.di;i.waypoint=t.createDiWaypoints(n.waypoints).map((function(e){return e.$parent=i,e}))},Yp.prototype.updateParent=function(e,t){var n=e.parent;hn(e,"dmn:DRGElement")||hn(e,"dmn:Artifact")||(n=t);var i=e.businessObject,o=n&&n.businessObject;this.updateSemanticParent(i,o),this.updateDiParent(i.di,o&&o.di)},Yp.prototype.updateSemanticParent=function(e,t){var n,i;e.$parent!==t&&(hn(e,"dmn:DRGElement")?i="drgElement":hn(e,"dmn:Artifact")?i="artifact":hn(e,"dmn:InformationRequirement")?i="informationRequirement":hn(e,"dmn:AuthorityRequirement")?i="authorityRequirement":hn(e,"dmn:KnowledgeRequirement")&&(i="knowledgeRequirement"),e.$parent&&wi(n=e.$parent.get(i),e),t?(n=t.get(i))&&(n.push(e),e.$parent=t):e.$parent=null)},Yp.prototype.updateDiParent=function(e,t){if(e.$parent!==t){if(!gn(e,["dmndi:DMNEdge","dmndi:DMNShape"]))throw new Error("unsupported");for(var n=t||e;!hn(n,"dmndi:DMNDiagram");)n=n.$parent;var i=n.get("diagramElements");t?(e.$parent=n,Ci(i,e)):(e.$parent=null,wi(i,e))}},Zp.$inject=["modeling","canvas"],Zp.prototype.preExecute=function(e){var t=this._modeling,n=e.elements,o=e.alignment;p(n,(function(e){var n={x:0,y:0};i(o.left)?n.x=o.left-e.x:i(o.right)?n.x=o.right-e.width-e.x:i(o.center)?n.x=o.center-Math.round(e.width/2)-e.x:i(o.top)?n.y=o.top-e.y:i(o.bottom)?n.y=o.bottom-e.height-e.y:i(o.middle)&&(n.y=o.middle-Math.round(e.height/2)-e.y),t.moveElements([e],n,e.parent)}))},Zp.prototype.postExecute=function(e){},Jp.$inject=["modeling"],Jp.prototype.preExecute=function(e){var t=e.source;if(!t)throw new Error("source required");var n=e.target||t.parent,i=e.shape,o=e.hints||{};i=e.shape=this._modeling.createShape(i,e.position,n,{attach:o.attach}),e.shape=i},Jp.prototype.postExecute=function(e){var t,n,i=e.hints||{};t=e.source,n=e.shape,m(t.outgoing,(function(e){return e.target===n}))||(i.connectionTarget===e.source?this._modeling.connect(e.shape,e.source,e.connection):this._modeling.connect(e.source,e.shape,e.connection))},ef.$inject=["canvas","layouter"],ef.prototype.execute=function(e){var t=e.connection,n=e.source,i=e.target,o=e.parent,r=e.parentIndex,s=e.hints;if(!n||!i)throw new Error("source and target required");if(!o)throw new Error("parent required");return t.source=n,t.target=i,t.waypoints||(t.waypoints=this._layouter.layoutConnection(t,s)),this._canvas.addConnection(t,o,r),t},ef.prototype.revert=function(e){var t=e.connection;return this._canvas.removeConnection(t),t.source=null,t.target=null,t};var tf=Math.round;function nf(e){this._modeling=e}nf.$inject=["modeling"],nf.prototype.preExecute=function(e){var t=e.elements,n=e.parent,i=e.parentIndex,o=e.position,r=e.hints,s=this._modeling;p(t,(function(e){a(e.x)||(e.x=0),a(e.y)||(e.y=0)}));var l=mi(d(t,(function(e){return!e.hidden})));p(t,(function(e){co(e)&&(e.waypoints=v(e.waypoints,(function(e){return{x:tf(e.x-l.x-l.width/2+o.x),y:tf(e.y-l.y-l.height/2+o.y)}}))),M(e,{x:tf(e.x-l.x-l.width/2+o.x),y:tf(e.y-l.y-l.height/2+o.y)})}));var c=hi(t),u={};p(t,(function(e){if(co(e))u[e.id]=a(i)?s.createConnection(u[e.source.id],u[e.target.id],i,e,e.parent||n,r):s.createConnection(u[e.source.id],u[e.target.id],e,e.parent||n,r);else{var t=M({},r);-1===c.indexOf(e)&&(t.autoResize=!1),uo(e)&&(t=P(t,["attach"])),u[e.id]=a(i)?s.createShape(e,A(e,["x","y","width","height"]),e.parent||n,i,t):s.createShape(e,A(e,["x","y","width","height"]),e.parent||n,t)}})),e.elements=x(u)};var of=Math.round;function rf(e){this._canvas=e}function sf(e){rf.call(this,e)}rf.$inject=["canvas"],rf.prototype.execute=function(e){var t=e.shape,n=e.position,i=e.parent,o=e.parentIndex;if(!i)throw new Error("parent required");if(!n)throw new Error("position required");return void 0!==n.width?M(t,n):M(t,{x:n.x-of(t.width/2),y:n.y-of(t.height/2)}),this._canvas.addShape(t,i,o),t},rf.prototype.revert=function(e){var t=e.shape;return this._canvas.removeShape(t),t},yn(sf,rf),sf.$inject=["canvas"];var af=rf.prototype.execute;sf.prototype.execute=function(e){var t=e.shape;return function(e){["width","height"].forEach((function(t){void 0===e[t]&&(e[t]=0)}))}(t),t.labelTarget=e.labelTarget,af.call(this,e)};var lf=rf.prototype.revert;function cf(e,t){if("function"!=typeof t)throw new Error("removeFn iterator must be a function");if(e){for(var n;n=e[0];)t(n);return e}}function uf(e,t){this._canvas=e,this._modeling=t}function hf(e,t){this._modeling=e,this._elementRegistry=t}function df(e,t){this._canvas=e,this._modeling=t}function pf(e){this._modeling=e}sf.prototype.revert=function(e){return e.shape.labelTarget=null,lf.call(this,e)},uf.$inject=["canvas","modeling"],uf.prototype.preExecute=function(e){var t=this._modeling,n=e.connection;cf(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),cf(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})}))},uf.prototype.execute=function(e){var t=e.connection,n=t.parent;return e.parent=n,e.parentIndex=Oi(n.children,t),e.source=t.source,e.target=t.target,this._canvas.removeConnection(t),t.source=null,t.target=null,t},uf.prototype.revert=function(e){var t=e.connection,n=e.parent,i=e.parentIndex;return t.source=e.source,t.target=e.target,Ci(n.children,t,i),this._canvas.addConnection(t,n),t},hf.$inject=["modeling","elementRegistry"],hf.prototype.postExecute=function(e){var t=this._modeling,n=this._elementRegistry;p(e.elements,(function(e){n.get(e.id)&&(e.waypoints?t.removeConnection(e):t.removeShape(e))}))},df.$inject=["canvas","modeling"],df.prototype.preExecute=function(e){var t=this._modeling,n=e.shape;cf(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),cf(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})})),cf(n.children,(function(e){co(e)?t.removeConnection(e,{nested:!0}):t.removeShape(e,{nested:!0})}))},df.prototype.execute=function(e){var t=this._canvas,n=e.shape,i=n.parent;return e.oldParent=i,e.oldParentIndex=Oi(i.children,n),t.removeShape(n),n},df.prototype.revert=function(e){var t=this._canvas,n=e.shape,i=e.oldParent,o=e.oldParentIndex;return Ci(i.children,n,o),t.addShape(n,i),n},pf.$inject=["modeling"];var ff={x:"y",y:"x"};function gf(e,t){this._layouter=e,this._canvas=t}function mf(){}function vf(e,t,n){var i=Wa(t),o=Wa(n),r=Ua(e,i),s=r.x*(n.width/t.width),a=r.y*(n.height/t.height);return ho({x:o.x+s,y:o.y+a})}function yf(e,t,n){var i=Cf(e),o=Of(i,t),r=i[0];return o.length?o[o.length-1]:vf(r.original||r,n,t)}function xf(e,t,n){var i=Cf(e),o=Of(i,t),r=i[i.length-1];return o.length?o[0]:vf(r.original||r,n,t)}function bf(e,t,n){var i=Cf(e),o=wf(t,n),r=i[0];return vf(r.original||r,o,t)}function _f(e,t,n){var i=Cf(e),o=wf(t,n),r=i[i.length-1];return vf(r.original||r,o,t)}function wf(e,t){return{x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height}}function Cf(e){var t=e.waypoints;if(!t.length)throw new Error("connection#"+e.id+": no waypoints");return t}function Of(e,t){return d(v(e,kf),(function(e){return function(e,t){return"intersect"===vo(t,e,1)}(e,t)}))}function kf(e){return e.original||e}function Ef(){this.allShapes={},this.allConnections={},this.enclosedElements={},this.enclosedConnections={},this.topLevel={}}function Sf(e){this._modeling=e}function Rf(e){this._helper=new Sf(e)}function Tf(e){this._modeling=e,this._helper=new Sf(e)}function Mf(e){this._modeling=e}function Af(e){return e.original||e}function Pf(e,t){this._modeling=e,this._rules=t}function Df(e){this._modeling=e}function $f(e,t){return-1!==e.indexOf(t)}function jf(e){this._modeling=e}function If(e){return M({},e)}function Bf(e){switch(e){case"n":case"s":return"y";case"w":case"e":return"x"}}function Lf(e,t,n){var i=Bf(n);return/e|s/.test(n)?e[i]>t:/n|w/.test(n)?e[i]<t:void 0}function Nf(e,t){return-1!==e.indexOf(t)}function qf(e){this._modeling=e}function Vf(e){var t={};return p(e,(function(e){t[e.id]=e.hidden,e.children&&(t=M({},t,Vf(e.children)))})),t}function Ff(e,t){var n=[];return p(e,(function(e){e.hidden=t,n=n.concat(e),e.children&&(n=n.concat(Ff(e.children,e.collapsed||t)))})),n}function zf(e,t){var n=[];return p(e,(function(e){e.hidden=t[e.id],n=n.concat(e),e.children&&(n=n.concat(zf(e.children,t)))})),n}function Qf(e){this._modeling=e}function Hf(e,t){return wi(e&&e.attachers,t)}function Wf(e,t,n){if(e){var i=e.attachers;i||(e.attachers=i=[]),Ci(i,t,n)}}function Uf(){}function Xf(e,t,n){this._eventBus=e,this._elementFactory=t,this._commandStack=n;var i=this;e.on("diagram.init",(function(){i.registerHandlers(n)}))}function Kf(e){this._moddle=e}function Gf(){function e(e,t){var n=e.label||e,i=e.labelTarget||e;return function(e,t,n){var i=e.businessObject,o=_l(i);o&&(i[o]=t),n&&(e.hidden=!t)}(n,t,i!==n),[n,i]}this.execute=function(t){return t.oldLabel=wl(t.element),e(t.element,t.newLabel)},this.revert=function(t){return e(t.element,t.oldLabel)}}pf.prototype.preExecute=function(e){var t=this._modeling,n=e.groups,i=e.axis,o=e.dimension;function r(e,t){e.range.min=Math.min(t[i],e.range.min),e.range.max=Math.max(t[i]+t[o],e.range.max)}function s(e){return e[i]+e[o]/2}function a(e){return e.length-1}function l(e){return e.max-e.min}var c,u,h=n[0],d=a(n),f=n[d],g=0;p(n,(function(e,c){var u,h,f;e.elements.length<2?c&&c!==n.length-1&&(r(e,e.elements[0]),g+=l(e.range)):(h=(u=w(e.elements,i))[0],c===d&&(h=u[a(u)]),f=s(h),e.range=null,p(u,(function(n){!function(e,n){var o={y:0};o[i]=e-s(n),o[i]&&(o[ff[i]]=0,t.moveElements([n],o,n.parent))}(f,n),null!==e.range?r(e,n):e.range={min:n[i],max:n[i]+n[o]}})),c&&c!==n.length-1&&(g+=l(e.range)))})),u=Math.abs(f.range.min-h.range.max),(c=Math.round((u-g)/(n.length-1)))<n.length-1||p(n,(function(e,r){var s,a={};e!==h&&e!==f&&(s=n[r-1],e.range.max=0,p(e.elements,(function(n,r){a[ff[i]]=0,a[i]=s.range.max-n[i]+c,e.range.min!==n[i]&&(a[i]+=n[i]-e.range.min),a[i]&&t.moveElements([n],a,n.parent),e.range.max=Math.max(n[i]+n[o],r?e.range.max:0)})))}))},pf.prototype.postExecute=function(e){},gf.$inject=["layouter","canvas"],gf.prototype.execute=function(e){var t=e.connection;return M(e,{oldWaypoints:t.waypoints}),t.waypoints=this._layouter.layoutConnection(t,e.hints),t},gf.prototype.revert=function(e){var t=e.connection;return t.waypoints=e.oldWaypoints,t},mf.prototype.execute=function(e){var t=e.connection,n=e.delta,i=e.newParent||t.parent,o=e.newParentIndex,r=t.parent;return e.oldParent=r,e.oldParentIndex=wi(r.children,t),Ci(i.children,t,o),t.parent=i,p(t.waypoints,(function(e){e.x+=n.x,e.y+=n.y,e.original&&(e.original.x+=n.x,e.original.y+=n.y)})),t},mf.prototype.revert=function(e){var t=e.connection,n=t.parent,i=e.oldParent,o=e.oldParentIndex,r=e.delta;return wi(n.children,t),Ci(i.children,t,o),t.parent=i,p(t.waypoints,(function(e){e.x-=r.x,e.y-=r.y,e.original&&(e.original.x-=r.x,e.original.y-=r.y)})),t},Ef.prototype.add=function(e,t){return this.addAll([e],t)},Ef.prototype.addAll=function(e,t){var i=function(e,t,i){n(t)&&(t=!0),s(t)&&(i=t,t=!0);var o=xi((i=i||{}).allShapes),r=xi(i.allConnections),a=xi(i.enclosedElements),l=xi(i.enclosedConnections),c=xi(i.topLevel,t&&b(e,(function(e){return e.id})));function u(e){c[e.source.id]&&c[e.target.id]&&(c[e.id]=[e]),o[e.source.id]&&o[e.target.id]&&(l[e.id]=a[e.id]=e),r[e.id]=e}return fi(e,(function(e){if(a[e.id]=e,!e.waypoints)return o[e.id]=e,p(e.incoming,u),p(e.outgoing,u),e.children;l[e.id]=r[e.id]=e})),{allShapes:o,allConnections:r,topLevel:c,enclosedConnections:l,enclosedElements:a}}(e,!!t,this);return M(this,i),this},Sf.prototype.moveRecursive=function(e,t,n){return e?this.moveClosure(this.getClosure(e),t,n):[]},Sf.prototype.moveClosure=function(e,t,n,i,o){var r=this._modeling,s=e.allShapes,a=e.allConnections,l=e.enclosedConnections,c=e.topLevel,u=!1;o&&o.parent===n&&(u=!0),p(s,(function(e){r.moveShape(e,t,c[e.id]&&!u&&n,{recurse:!1,layout:!1})})),p(a,(function(e){var i=!!s[e.source.id],o=!!s[e.target.id];l[e.id]&&i&&o?r.moveConnection(e,t,c[e.id]&&!u&&n):r.layoutConnection(e,{connectionStart:i&&bf(e,e.source,t),connectionEnd:o&&_f(e,e.target,t)})}))},Sf.prototype.getClosure=function(e){return(new Ef).addAll(e,!0)},Rf.$inject=["modeling"],Rf.prototype.preExecute=function(e){e.closure=this._helper.getClosure(e.shapes)},Rf.prototype.postExecute=function(e){var t,n=e.hints;n&&n.primaryShape&&(t=n.primaryShape,n.oldParent=t.parent),this._helper.moveClosure(e.closure,e.delta,e.newParent,e.newHost,t)},Tf.$inject=["modeling"],Tf.prototype.execute=function(e){var t=e.shape,n=e.delta,i=e.newParent||t.parent,o=e.newParentIndex,r=t.parent;return e.oldBounds=A(t,["x","y","width","height"]),e.oldParent=r,e.oldParentIndex=wi(r.children,t),Ci(i.children,t,o),M(t,{parent:i,x:t.x+n.x,y:t.y+n.y}),t},Tf.prototype.postExecute=function(e){var t=e.shape,n=e.delta,i=e.hints,o=this._modeling;!1!==i.layout&&(p(t.incoming,(function(e){o.layoutConnection(e,{connectionEnd:_f(e,t,n)})})),p(t.outgoing,(function(e){o.layoutConnection(e,{connectionStart:bf(e,t,n)})}))),!1!==i.recurse&&this.moveChildren(e)},Tf.prototype.revert=function(e){var t=e.shape,n=e.oldParent,i=e.oldParentIndex,o=e.delta;return Ci(n.children,t,i),M(t,{parent:n,x:t.x-o.x,y:t.y-o.y}),t},Tf.prototype.moveChildren=function(e){var t=e.delta,n=e.shape;this._helper.moveRecursive(n.children,t,null)},Tf.prototype.getNewParent=function(e){return e.newParent||e.shape.parent},Mf.$inject=["modeling"],Mf.prototype.execute=function(e){var t=e.newSource,n=e.newTarget,i=e.connection,o=e.dockingOrPoints;if(!t&&!n)throw new Error("newSource or newTarget required");return r(o)&&(e.oldWaypoints=i.waypoints,i.waypoints=o),t&&(e.oldSource=i.source,i.source=t),n&&(e.oldTarget=i.target,i.target=n),i},Mf.prototype.postExecute=function(e){var t=e.connection,n=e.newSource,i=e.newTarget,o=e.dockingOrPoints,s=e.hints||{},a={};s.connectionStart&&(a.connectionStart=s.connectionStart),s.connectionEnd&&(a.connectionEnd=s.connectionEnd),!1!==s.layoutConnection&&(!n||i&&"source"!==s.docking||(a.connectionStart=a.connectionStart||Af(r(o)?o[0]:o)),!i||n&&"target"!==s.docking||(a.connectionEnd=a.connectionEnd||Af(r(o)?o[o.length-1]:o)),s.newWaypoints&&(a.waypoints=s.newWaypoints),this._modeling.layoutConnection(t,a))},Mf.prototype.revert=function(e){var t=e.oldSource,n=e.oldTarget,i=e.oldWaypoints,o=e.connection;return t&&(o.source=t),n&&(o.target=n),i&&(o.waypoints=i),o},Pf.$inject=["modeling","rules"],Pf.prototype.preExecute=function(e){var t,n=this,i=this._modeling,o=this._rules,r=e.oldShape,s=e.newData,a=e.hints||{};function l(e,t,n){return o.allowed("connection.reconnect",{connection:n,source:e,target:t})}var c,u={x:s.x,y:s.y},h={x:r.x,y:r.y,width:r.width,height:r.height};t=e.newShape=e.newShape||n.createShape(s,u,r.parent,a),r.host&&i.updateAttachment(t,r.host),!1!==a.moveChildren&&(c=r.children.slice(),i.moveElements(c,{x:0,y:0},t,a));var d=r.incoming.slice(),f=r.outgoing.slice();p(d,(function(e){l(e.source,t,e)&&n.reconnectEnd(e,t,xf(e,t,h),a)})),p(f,(function(e){var i=e.target;l(t,i,e)&&n.reconnectStart(e,t,yf(e,t,h),a)}))},Pf.prototype.postExecute=function(e){var t=e.oldShape;this._modeling.removeShape(t)},Pf.prototype.execute=function(e){},Pf.prototype.revert=function(e){},Pf.prototype.createShape=function(e,t,n,i){return this._modeling.createShape(e,t,n,i)},Pf.prototype.reconnectStart=function(e,t,n,i){this._modeling.reconnectStart(e,t,n,i)},Pf.prototype.reconnectEnd=function(e,t,n,i){this._modeling.reconnectEnd(e,t,n,i)},Df.$inject=["modeling"],Df.prototype.execute=function(e){var t=e.shape,n=e.newBounds,i=e.minBounds;if(void 0===n.x||void 0===n.y||void 0===n.width||void 0===n.height)throw new Error("newBounds must have {x, y, width, height} properties");if(i&&(n.width<i.width||n.height<i.height))throw new Error("width and height cannot be less than minimum height and width");if(!i&&n.width<10||n.height<10)throw new Error("width and height cannot be less than 10px");return e.oldBounds={width:t.width,height:t.height,x:t.x,y:t.y},M(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Df.prototype.postExecute=function(e){var t=this._modeling,n=e.shape,i=e.oldBounds;!1!==(e.hints||{}).layout&&(p(n.incoming,(function(e){t.layoutConnection(e,{connectionEnd:xf(e,n,i)})})),p(n.outgoing,(function(e){t.layoutConnection(e,{connectionStart:yf(e,n,i)})})))},Df.prototype.revert=function(e){var t=e.shape,n=e.oldBounds;return M(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},jf.$inject=["modeling"],jf.prototype.preExecute=function(e){var t=e.delta,n=e.direction,i=e.movingShapes,o=e.resizingShapes,r=e.start,s={};this.moveShapes(i,t),p(o,(function(e){s[e.id]=function(e){return{x:e.x,y:e.y,height:e.height,width:e.width}}(e)})),this.resizeShapes(o,t,n),this.updateConnectionWaypoints(function(e,t){var n=[];return p(e.concat(t),(function(i){var o=i.incoming,r=i.outgoing;p(o.concat(r),(function(i){var o=i.source,r=i.target;($f(e,o)||$f(e,r)||$f(t,o)||$f(t,r))&&($f(n,i)||n.push(i))}))})),n}(i,o),t,n,r,i,o,s)},jf.prototype.execute=function(){},jf.prototype.revert=function(){},jf.prototype.moveShapes=function(e,t){var n=this;p(e,(function(e){n._modeling.moveShape(e,t,null,{autoResize:!1,layout:!1,recurse:!1})}))},jf.prototype.resizeShapes=function(e,t,n){var i=this;p(e,(function(e){var o=function(e,t,n){var i=e.x,o=e.y,r=e.width,s=e.height,a=n.x,l=n.y;switch(t){case"n":return{x:i,y:o+l,width:r,height:s-l};case"s":return{x:i,y:o,width:r,height:s+l};case"w":return{x:i+a,y:o,width:r-a,height:s};case"e":return{x:i,y:o,width:r+a,height:s};default:throw new Error("unknown direction: "+t)}}(e,n,t);i._modeling.resizeShape(e,o,null,{attachSupport:!1,autoResize:!1,layout:!1})}))},jf.prototype.updateConnectionWaypoints=function(e,t,n,i,o,r,s){var a=this,l=o.concat(r);p(e,(function(e){var c=e.source,u=e.target,h=function(e){return v(e.waypoints,(function(e){return(e=If(e)).original&&(e.original=If(e.original)),e}))}(e),d=Bf(n),p={};Nf(l,c)&&Nf(l,u)?(h=v(h,(function(e){return Lf(e,i,n)&&(e[d]=e[d]+t[d]),e.original&&Lf(e.original,i,n)&&(e.original[d]=e.original[d]+t[d]),e})),a._modeling.updateWaypoints(e,h,{labelBehavior:!1})):(Nf(l,c)||Nf(l,u))&&(Nf(o,c)?p.connectionStart=bf(e,c,t):Nf(o,u)?p.connectionEnd=_f(e,u,t):Nf(r,c)?p.connectionStart=yf(e,c,s[c.id]):Nf(r,u)&&(p.connectionEnd=xf(e,u,s[u.id])),a._modeling.layoutConnection(e,p))}))},qf.$inject=["modeling"],qf.prototype.execute=function(e){var t=e.shape,n=t.children;e.oldChildrenVisibility=Vf(n),t.collapsed=!t.collapsed;var i=Ff(n,t.collapsed);return[t].concat(i)},qf.prototype.revert=function(e){var t=e.shape,n=e.oldChildrenVisibility,i=zf(t.children,n);return t.collapsed=!t.collapsed,[t].concat(i)},Qf.$inject=["modeling"],Qf.prototype.execute=function(e){var t=e.shape,n=e.newHost,i=t.host;return e.oldHost=i,e.attacherIdx=Hf(i,t),Wf(n,t),t.host=n,t},Qf.prototype.revert=function(e){var t=e.shape,n=e.newHost,i=e.oldHost,o=e.attacherIdx;return t.host=i,Hf(n,t),Wf(i,t,o),t},Uf.prototype.execute=function(e){var t=e.connection,n=e.newWaypoints;return e.oldWaypoints=t.waypoints,t.waypoints=n,t},Uf.prototype.revert=function(e){var t=e.connection,n=e.oldWaypoints;return t.waypoints=n,t},Xf.$inject=["eventBus","elementFactory","commandStack"],Xf.prototype.getHandlers=function(){return{"shape.append":Jp,"shape.create":rf,"shape.delete":df,"shape.move":Tf,"shape.resize":Df,"shape.replace":Pf,"shape.toggleCollapse":qf,spaceTool:jf,"label.create":sf,"connection.create":ef,"connection.delete":uf,"connection.move":mf,"connection.layout":gf,"connection.updateWaypoints":Uf,"connection.reconnect":Mf,"elements.create":nf,"elements.move":Rf,"elements.delete":hf,"elements.distribute":pf,"elements.align":Zp,"element.updateAttachment":Qf}},Xf.prototype.registerHandlers=function(e){p(this.getHandlers(),(function(t,n){e.registerHandler(n,t)}))},Xf.prototype.moveShape=function(e,t,n,i,o){"object"==typeof i&&(o=i,i=null);var r={shape:e,delta:t,newParent:n,newParentIndex:i,hints:o||{}};this._commandStack.execute("shape.move",r)},Xf.prototype.updateAttachment=function(e,t){var n={shape:e,newHost:t};this._commandStack.execute("element.updateAttachment",n)},Xf.prototype.moveElements=function(e,t,n,i){var o,r=(i=i||{}).attach,s=n;!0===r?(o=n,s=n.parent):!1===r&&(o=null);var a={shapes:e,delta:t,newParent:s,newHost:o,hints:i};this._commandStack.execute("elements.move",a)},Xf.prototype.moveConnection=function(e,t,n,i,o){"object"==typeof i&&(o=i,i=void 0);var r={connection:e,delta:t,newParent:n,newParentIndex:i,hints:o||{}};this._commandStack.execute("connection.move",r)},Xf.prototype.layoutConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.layout",n)},Xf.prototype.createConnection=function(e,t,n,i,o,r){"object"==typeof n&&(r=o,o=i,i=n,n=void 0);var s={source:e,target:t,parent:o,parentIndex:n,connection:i=this._create("connection",i),hints:r};return this._commandStack.execute("connection.create",s),s.connection},Xf.prototype.createShape=function(e,t,n,i,o){"number"!=typeof i&&(o=i,i=void 0);var r,s,a=(o=o||{}).attach;e=this._create("shape",e),a?(r=n.parent,s=n):r=n;var l={position:t,shape:e,parent:r,parentIndex:i,host:s,hints:o};return this._commandStack.execute("shape.create",l),l.shape},Xf.prototype.createElements=function(e,t,n,i,o){r(e)||(e=[e]),"number"!=typeof i&&(o=i,i=void 0);var s={position:t,elements:e,parent:n,parentIndex:i,hints:o=o||{}};return this._commandStack.execute("elements.create",s),s.elements},Xf.prototype.createLabel=function(e,t,n,i){n=this._create("label",n);var o={labelTarget:e,position:t,parent:i||e.parent,shape:n};return this._commandStack.execute("label.create",o),o.shape},Xf.prototype.appendShape=function(e,t,n,i,o){o=o||{};var r={source:e,position:n,target:i,shape:t=this._create("shape",t),connection:o.connection,connectionParent:o.connectionParent,hints:o};return this._commandStack.execute("shape.append",r),r.shape},Xf.prototype.removeElements=function(e){var t={elements:e};this._commandStack.execute("elements.delete",t)},Xf.prototype.distributeElements=function(e,t,n){var i={groups:e,axis:t,dimension:n};this._commandStack.execute("elements.distribute",i)},Xf.prototype.removeShape=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.delete",n)},Xf.prototype.removeConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.delete",n)},Xf.prototype.replaceShape=function(e,t,n){var i={oldShape:e,newData:t,hints:n||{}};return this._commandStack.execute("shape.replace",i),i.newShape},Xf.prototype.alignElements=function(e,t){var n={elements:e,alignment:t};this._commandStack.execute("elements.align",n)},Xf.prototype.resizeShape=function(e,t,n,i){var o={shape:e,newBounds:t,minBounds:n,hints:i};this._commandStack.execute("shape.resize",o)},Xf.prototype.createSpace=function(e,t,n,i,o){var r={delta:n,direction:i,movingShapes:e,resizingShapes:t,start:o};this._commandStack.execute("spaceTool",r)},Xf.prototype.updateWaypoints=function(e,t,n){var i={connection:e,newWaypoints:t,hints:n||{}};this._commandStack.execute("connection.updateWaypoints",i)},Xf.prototype.reconnect=function(e,t,n,i,o){var r={connection:e,newSource:t,newTarget:n,dockingOrPoints:i,hints:o||{}};this._commandStack.execute("connection.reconnect",r)},Xf.prototype.reconnectStart=function(e,t,n,i){i||(i={}),this.reconnect(e,t,e.target,n,M(i,{docking:"source"}))},Xf.prototype.reconnectEnd=function(e,t,n,i){i||(i={}),this.reconnect(e,e.source,t,n,M(i,{docking:"target"}))},Xf.prototype.connect=function(e,t,n,i){return this.createConnection(e,t,n||{},e.parent,i)},Xf.prototype._create=function(e,t){return t instanceof $o?t:this._elementFactory.create(e,t)},Xf.prototype.toggleCollapse=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.toggleCollapse",n)},Kf.$inject=["moddle"],Kf.prototype.execute=function(e){var t=this._moddle.ids,n=e.id,i=e.element;e.claiming?t.claim(n,i):t.unclaim(n)},Kf.prototype.revert=function(e){var t=this._moddle.ids,n=e.id,i=e.element;e.claiming?t.unclaim(n):t.claim(n,i)};const Yf="id";function Zf(e,t){this._elementRegistry=e,this._moddle=t}function Jf(e,t){return Yf in e&&e[Yf]!==t[Yf]}function eg(e,t){p(t,(function(t,n){e.set(n,t)}))}function tg(e){this._elementRegistry=e}function ng(e,t){p(t,(function(t,n){e.set(n,t)}))}function ig(e,t,n){this._canvas=e,this._drdRules=t,n.invoke(Xf,this)}function og(){}Zf.$inject=["elementRegistry","moddle"],Zf.prototype.execute=function(e){const{element:t,properties:n}=e,i=[t];if(!t)throw new Error("element required");const o=this._elementRegistry,r=this._moddle.ids,s=fn(t),a=e.oldProperties||function(e,t){return f(t,(function(t,n){return t[n]=e.get(n),t}),{})}(s,y(n));return Jf(n,s)&&(r.unclaim(s[Yf]),o.updateId(t,n[Yf]),r.claim(n[Yf],s)),"name"in n&&t.label&&i.push(t.label),eg(s,n),e.oldProperties=a,e.changed=i,i},Zf.prototype.revert=function(e){const{element:t,properties:n,oldProperties:i}=e,o=fn(t),r=this._elementRegistry,s=this._moddle.ids;return eg(o,i),Jf(n,o)&&(s.unclaim(n[Yf]),r.updateId(t,i[Yf]),s.claim(i[Yf],o)),e.changed},tg.$inject=["elementRegistry"],tg.prototype.execute=function(e){var t=e.element,n=e.moddleElement,i=e.properties;if(!n)throw new Error("<moddleElement> required");var o=e.changed||[t],r=e.oldProperties||function(e,t){return f(t,(function(t,n){return t[n]=e.get(n),t}),{})}(n,y(i));return ng(n,i),e.oldProperties=r,e.changed=o,o},tg.prototype.revert=function(e){var t=e.oldProperties,n=e.moddleElement,i=e.changed;return ng(n,t),i},yn(ig,Xf),ig.$inject=["canvas","drdRules","injector"],ig.prototype.claimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t,claiming:!0})},ig.prototype.connect=function(e,t,n,i){var o=this._drdRules,r=this._canvas.getRootElement();return n||(n=o.canConnect(e,t)||{type:"dmn:Association"}),this.createConnection(e,t,n,r,i)},ig.prototype.getHandlers=function(){var e=Xf.prototype.getHandlers.call(this);return e["id.updateClaim"]=Kf,e["element.updateLabel"]=Gf,e["element.updateProperties"]=Zf,e["element.updateModdleProperties"]=tg,e},ig.prototype.unclaimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t})},ig.prototype.updateModdleProperties=function(e,t,n){this._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:t,properties:n})},ig.prototype.updateProperties=function(e,t){this._commandStack.execute("element.updateProperties",{element:e,properties:t})},ig.prototype.updateLabel=function(e,t,n,i){this._commandStack.execute("element.updateLabel",{element:e,newLabel:t,newBounds:n,hints:i||{}})},og.prototype.layoutConnection=function(e,t){return[(t=t||{}).connectionStart||mo(t.source||e.source),t.connectionEnd||mo(t.target||e.target)]};function rg(e){this._connectionDocking=e}function sg(e,t){return e?e.original||e:mo(t)}function ag(e){return M({original:e.point.original||e.point},e.actual)}function lg(e,t){this._elementRegistry=e,this._graphicsFactory=t}yn(rg,og),rg.$inject=["connectionDocking"],rg.prototype.layoutConnection=function(e,t){var n=this._connectionDocking;t||(t={});var i=t.source||e.source,o=t.target||e.target,r=t.waypoints||e.waypoints||[],s=t.connectionStart,a=t.connectionEnd,l=vo(i,o);if(s||(s=sg(r[0],i)),a||(a=sg(r[r.length-1],o)),hn(e,"dmn:InformationRequirement")){r=[s,a];var c=n.getCroppedWaypoints(M({},e,{waypoints:r}),i,o),u={x:(a=c.pop()).x,y:a.y};return l.includes("bottom")?u.y+=20:l.includes("top")?u.y-=20:l.includes("right")?u.x+=20:u.x-=20,r=c.concat([u,a])}return[s,a]},lg.$inject=["elementRegistry","graphicsFactory"],lg.prototype.getCroppedWaypoints=function(e,t,n){t=t||e.source,n=n||e.target;var i=this.getDockingPoint(e,t,!0),o=this.getDockingPoint(e,n),r=e.waypoints.slice(i.idx+1,o.idx);return r.unshift(ag(i)),r.push(ag(o)),r},lg.prototype.getDockingPoint=function(e,t,n){var i,o,r=e.waypoints;return{point:o=r[i=n?0:r.length-1],actual:this._getIntersection(t,e,n)||o,idx:i}},lg.prototype._getIntersection=function(e,t,n){return yo(this._getShapePath(e),this._getConnectionPath(t),n)},lg.prototype._getConnectionPath=function(e){return this._graphicsFactory.getConnectionPath(e)},lg.prototype._getShapePath=function(e){return this._graphicsFactory.getShapePath(e)},lg.prototype._getGfx=function(e){return this._elementRegistry.getGraphics(e)};var cg={__init__:["modeling","drdUpdater"],__depends__:[Fp,Kp,Va,_p,Aa,Cp],drdFactory:["type",Gp],drdUpdater:["type",Yp],elementFactory:["type",Xl],modeling:["type",ig],layouter:["type",rg],connectionDocking:["type",lg]};function ug(e,t){this._eventBus=e,this.offset=5;var n=t.cls("djs-outline",["no-fill"]),i=this;function o(e){var t=Qn("rect");return jn(t,M({x:0,y:0,rx:4,width:100,height:100},n)),t}e.on(["shape.added","shape.changed"],500,(function(e){var t=e.element,n=e.gfx,r=Zt(".djs-outline",n);r||An(n,r=i.getOutline(t)||o()),i.updateShapeOutline(r,t)})),e.on(["connection.added","connection.changed"],(function(e){var t=e.element,n=e.gfx,r=Zt(".djs-outline",n);r||An(n,r=o()),i.updateConnectionOutline(r,t)}))}ug.prototype.updateShapeOutline=function(e,t){var n=!1,i=this._getProviders();i.length&&p(i,(function(i){n=n||i.updateOutline(t,e)})),n||jn(e,{x:-this.offset,y:-this.offset,width:t.width+2*this.offset,height:t.height+2*this.offset})},ug.prototype.updateConnectionOutline=function(e,t){var n=mi(t);jn(e,{x:n.x-this.offset,y:n.y-this.offset,width:n.width+2*this.offset,height:n.height+2*this.offset})},ug.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("outline.getProviders",e,(function(e){e.providers.push(t)}))},ug.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"outline.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},ug.prototype.getOutline=function(e){var t;return p(this._getProviders(),(function(n){l(n.getOutline)&&(t=t||n.getOutline(e))})),t},ug.$inject=["eventBus","styles","elementRegistry"];function hg(e,t,n){this._canvas=t;var i=this;e.on("element.changed",(function(e){n.isSelected(e.element)&&i._updateMultiSelectionOutline(n.get())})),e.on("selection.changed",(function(e){var t=e.newSelection;i._updateMultiSelectionOutline(t)}))}hg.prototype._updateMultiSelectionOutline=function(e){var t=this._canvas.getLayer("selectionOutline");Nn(t);var n=e.length>1;if(Bn(this._canvas.getContainer())[n?"add":"remove"]("djs-multi-select"),n){var i=function(e){return{x:e.x-6,y:e.y-6,width:e.width+12,height:e.height+12}}(mi(e)),o=Qn("rect");jn(o,M({rx:3},i)),Bn(o).add("djs-selection-outline"),An(t,o)}},hg.$inject=["eventBus","canvas","selection"];var dg={__depends__:[Aa],__init__:["outline","multiSelectionOutline"],outline:["type",ug],multiSelectionOutline:["type",hg]},pg=Math.round;function fg(e,t,n,i,o){function r(e,t,n,i){return o.allowed("elements.move",{shapes:e,delta:t,position:n,target:i})}function a(e,n,i,o){if(s(i)&&(o=i,i=!1),!n.waypoints&&n.parent&&!Bn(e.target).has("djs-hit-no-move")){var r=function(e){return{x:e.x+pg(e.width/2),y:e.y+pg(e.height/2)}}(n);return t.init(e,r,"shape.move",{cursor:"grabbing",autoActivate:i,data:{shape:n,context:o||{}}}),!0}}e.on("shape.move.start",1500,(function(e){var t=e.context,n=e.shape,o=i.get().slice();-1===o.indexOf(n)&&(o=[n]),o=function(e){var t=b(e,"id");return d(e,(function(e){for(;e=e.parent;)if(t[e.id])return!1;return!0}))}(o),M(t,{shapes:o,validatedShapes:o,shape:n})})),e.on("shape.move.start",1250,(function(e){var t=e.context,n=t.validatedShapes;if(!(t.canExecute=r(n)))return!1})),e.on("shape.move.move",500,(function(e){var t,n=e.context,i=n.validatedShapes,o=e.hover,s={x:e.dx,y:e.dy};t=r(i,s,{x:e.x,y:e.y},o),n.delta=s,n.canExecute=t,n.target=null!==t?o:null})),e.on("shape.move.end",(function(e){var t=e.context,i=t.delta,o=t.canExecute,r="attach"===o,s=t.shapes;if(!1===o)return!1;i.x=pg(i.x),i.y=pg(i.y),0===i.x&&0===i.y||n.moveElements(s,i,t.target,{primaryShape:t.shape,attach:r})})),e.on("element.mousedown",(function(e){if(ya(e)){var t=pa(e);if(!t)throw new Error("must supply DOM mousedown event");return a(t,e.element)}})),this.start=a}fg.$inject=["eventBus","dragging","modeling","selection","rules"];var gg="djs-dragging",mg="drop-ok",vg="drop-not-ok",yg="new-parent",xg="attach-ok";function bg(e,t,n,i){function o(e){var t=function(e){var t=d(e,(function(t){return!co(t)||h(e,C({id:t.source.id}))&&h(e,C({id:t.target.id}))}));return t}(r(e));return t}function r(e){var t=gi(e,!0),n=t.flatMap((e=>(e.incoming||[]).concat(e.outgoing||[]))),i=t.concat(n);return[...new Set(i)]}function s(e,n){[xg,mg,vg,yg].forEach((function(i){i===n?t.addMarker(e,i):t.removeMarker(e,i)}))}e.on("shape.move.start",499,(function(e){var s,a,l=e.context,c=l.shapes,u=l.allDraggedElements,h=o(c);if(!l.dragGroup){var d=Qn("g");jn(d,n.cls("djs-drag-group",["no-events"])),An(t.getActiveLayer(),d),l.dragGroup=d}h.forEach((function(e){i.addDragger(e,l.dragGroup)})),u?(s=[u,r(c)],u=Array.prototype.concat.apply([],s)):u=r(c),p(u,(function(e){t.addMarker(e,gg)})),l.allDraggedElements=u,l.differentParents=1!==(a=b(c,(function(e){return e.parent&&e.parent.id})),y(a).length)})),e.on("shape.move.move",499,(function(e){var t=e.context,n=t.dragGroup,i=t.target,o=t.shape.parent,r=t.canExecute;i&&("attach"===r?s(i,xg):t.canExecute&&o&&i.id!==o.id?s(i,yg):s(i,t.canExecute?mg:vg)),Fo(n,e.dx,e.dy)})),e.on(["shape.move.out","shape.move.cleanup"],(function(e){var t=e.context.target;t&&s(t,null)})),e.on("shape.move.cleanup",(function(e){var n=e.context,i=n.allDraggedElements,o=n.dragGroup;p(i,(function(e){t.removeMarker(e,gg)})),o&&ti(o)})),this.makeDraggable=function(e,n,o){i.addDragger(n,e.dragGroup),o&&t.addMarker(n,gg),e.allDraggedElements?e.allDraggedElements.push(n):e.allDraggedElements=[n]}}bg.$inject=["eventBus","canvas","styles","previewSupport"];var _g={__depends__:[Oa,Aa,dg,gc,uc,Cu],__init__:["move","movePreview"],move:["type",fg],movePreview:["type",bg]};const wg={width:135,height:46},Cg={width:100,height:63};function Og(e,t,n){return Qn("path",{d:e,strokeWidth:2,transform:`translate(${t.x}, ${t.y})`,...n})}function kg(e,t){this._styles=t,e.registerProvider(this)}function Eg(e,t){var n;return"dmn:BusinessKnowledgeModel"===t?n=wg:"dmn:KnowledgeSource"===t&&(n=Cg),e.width===n.width&&e.height===n.height}kg.$inject=["outline","styles"],kg.prototype.getOutline=function(e){const t=this._styles.cls("djs-outline",["no-fill"]);var n;return hn(e,"dmn:InputData")?jn(n=Qn("rect"),M({x:-5,y:-5,rx:27,width:e.width+10,height:e.height+10},t)):hn(e,"dmn:BusinessKnowledgeModel")&&Eg(e,"dmn:BusinessKnowledgeModel")?n=Og("\nM2.45221 16.0068L18.7175 1.74436L18.0615 0.996331L18.7175 1.74436C19.2646 1.26455 19.9676 \n1 20.6953 1H140.926C142.583 1 143.926 2.34295 143.926 3.99967L143.93 37.5457C143.93 \n38.3668 143.593 39.152 142.999 39.7183L143.689 40.4424L142.999 39.7183L127.299 \n54.6723C126.741 55.2036 126 55.5 125.23 55.5H4.53787C2.88599 55.5 1.54491 54.1646 1.5379 \n52.5127L1.43066 27.229L1.43065 27.2248L1.4301 18.2626C1.43005 \n17.3986 1.80255 16.5765 2.45221 16.0068Z\n",{x:-6,y:-6},t):hn(e,"dmn:KnowledgeSource")&&Eg(e,"dmn:KnowledgeSource")&&(n=Og("\nM1.79494 63.0032L1.2941 63.6423L1.79493 63.0032C1.71778 62.9427 1.6428 62.8741 1.57288 \n62.8L1.01736 63.3241L1.57288 62.8C1.20495 62.41 1 61.8941 1 61.3579V2.65067C1 1.74066 \n1.73867 1.00345 2.64868 1.00526L108.006 1.2145C109.66 1.21778 111 2.55996 111 \n4.21449V21.7015V61.6762C111 63.3188 109.679 64.656 108.037 64.676L107.06 64.6879C106.66 \n64.6927 106.26 64.6165 105.89 64.4652C105.04 64.1176 104.222 63.78 103.43 \n63.4531C93.4866 59.3517 87.6891 56.9603 76.3991 58.1057C71.7035 58.5821 66.8747 60.74 \n61.5721 63.1744C61.3243 63.2881 61.0753 63.4026 60.825 63.5177C55.6712 65.8868 49.9696 \n68.5077 43.2365 70.3468C31.101 73.6617 15.2135 73.5179 1.79494 63.0032Z\n",{x:-6,y:-1.5},t)),n},kg.prototype.updateOutline=function(e){return!!gn(e,["dmn:InputData","dmn:BusinessKnowledgeModel","dmn:KnowledgeSource"])};var Sg={__depends__:[dg],__init__:["outlineProvider"],outlineProvider:["type",kg]},Rg=".djs-palette-toggle",Tg=".entry",Mg=Rg+", "+Tg,Ag="djs-palette-",Pg="open",Dg="two-column";function $g(e,t){this._eventBus=e,this._canvas=t;var n=this;e.on("tool-manager.update",(function(e){var t=e.tool;n.updateToolHighlight(t)})),e.on("i18n.changed",(function(){n._update()})),e.on("diagram.init",(function(){n._diagramInitialized=!0,n._rebuild()}))}function jg(e,t){var n=t.getPaletteEntries();return l(n)?n(e):(p(n,(function(t,n){e[n]=t})),e)}$g.$inject=["eventBus","canvas"],$g.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("palette.getProviders",e,(function(e){e.providers.push(t)})),this._rebuild()},$g.prototype.getEntries=function(){return this._getProviders().reduce(jg,{})},$g.prototype._rebuild=function(){this._diagramInitialized&&(this._getProviders().length&&(this._container||this._init(),this._update()))},$g.prototype._init=function(){var e=this,t=this._eventBus,n=this._getParentContainer(),i=this._container=Gt($g.HTML_MARKUP);n.appendChild(i),$t(n).add(Ag+"shown"),Wt.bind(i,Mg,"click",(function(t){if(Yt(t.delegateTarget,Rg))return e.toggle();e.trigger("click",t)})),zt.bind(i,"mousedown",(function(e){e.stopPropagation()})),Wt.bind(i,Tg,"dragstart",(function(t){e.trigger("dragstart",t)})),t.on("canvas.resized",this._layoutChanged,this),t.fire("palette.create",{container:i})},$g.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(t),t.providers},$g.prototype._toggleState=function(e){e=e||{};var t,n=this._getParentContainer(),i=this._container,o=this._eventBus,r=$t(i),s=$t(n);t="twoColumn"in e?e.twoColumn:this._needsCollapse(n.clientHeight,this._entries||{}),r.toggle(Dg,t),s.toggle(Ag+Dg,t),"open"in e&&(r.toggle(Pg,e.open),s.toggle(Ag+Pg,e.open)),o.fire("palette.changed",{twoColumn:t,open:this.isOpen()})},$g.prototype._update=function(){var e=Zt(".djs-palette-entries",this._container),t=this._entries=this.getEntries();It(e),p(t,(function(t,n){var i=t.group||"default",o=Zt("[data-group="+al(i)+"]",e);o||(Pt(o=Gt('<div class="group"></div>'),"data-group",i),e.appendChild(o));var s=t.html||(t.separator?'<hr class="separator" />':'<div class="entry" draggable="true"></div>'),a=Gt(s);if(o.appendChild(a),!t.separator&&(Pt(a,"data-action",n),t.title&&Pt(a,"title",t.title),t.className&&function(e,t){var n=$t(e),i=r(t)?t:t.split(/\s+/g);i.forEach((function(e){n.add(e)}))}(a,t.className),t.imageUrl)){var l=Gt("<img>");Pt(l,"src",t.imageUrl),a.appendChild(l)}})),this.open()},$g.prototype.trigger=function(e,t,n){var i,o,r=t.delegateTarget||t.target;return r?(i=Pt(r,"data-action"),o=t.originalEvent||t,this.triggerEntry(i,e,o,n)):t.preventDefault()},$g.prototype.triggerEntry=function(e,t,n,i){var o,r;if((o=this._entries[e])&&(r=o.action,!1!==this._eventBus.fire("palette.trigger",{entry:o,event:n}))){if(l(r)){if("click"===t)return r(n,i)}else if(r[t])return r[t](n,i);n.preventDefault()}},$g.prototype._layoutChanged=function(){this._toggleState({})},$g.prototype._needsCollapse=function(e,t){return e<46*Object.keys(t).length+50},$g.prototype.close=function(){this._toggleState({open:!1,twoColumn:!1})},$g.prototype.open=function(){this._toggleState({open:!0})},$g.prototype.toggle=function(){this.isOpen()?this.close():this.open()},$g.prototype.isActiveTool=function(e){return e&&this._activeTool===e},$g.prototype.updateToolHighlight=function(e){var t;this._toolsContainer||(t=Zt(".djs-palette-entries",this._container),this._toolsContainer=Zt("[data-group=tools]",t)),p(this._toolsContainer.children,(function(t){var n=t.getAttribute("data-action");if(n){var i=$t(t);n=n.replace("-tool",""),i.contains("entry")&&n===e?i.add("highlighted-entry"):i.remove("highlighted-entry")}}))},$g.prototype.isOpen=function(){return $t(this._container).has(Pg)},$g.prototype._getParentContainer=function(){return this._canvas.getContainer()},$g.HTML_MARKUP='<div class="djs-palette"><div class="djs-palette-entries"></div><div class="djs-palette-toggle"></div></div>';var Ig={__init__:["palette"],palette:["type",$g]};function Bg(e){this._eventBus=e,this._tools=[],this._active=null}Bg.$inject=["eventBus"],Bg.prototype.registerTool=function(e,t){var n=this._tools;if(!t)throw new Error('A tool has to be registered with it\'s "events"');n.push(e),this.bindEvents(e,t)},Bg.prototype.isActive=function(e){return e&&this._active===e},Bg.prototype.length=function(e){return this._tools.length},Bg.prototype.setActive=function(e){var t=this._eventBus;this._active!==e&&(this._active=e,t.fire("tool-manager.update",{tool:e}))},Bg.prototype.bindEvents=function(e,t){var n=this._eventBus,i=[];n.on(t.tool+".init",(function(t){t.context.reactivate||!this.isActive(e)?this.setActive(e):this.setActive(null)}),this),p(t,(function(e){i.push(e+".ended"),i.push(e+".canceled")})),n.on(i,250,(function(e){this._active&&(function(e){var t=e.originalEvent&&e.originalEvent.target;return t&&Bt(t,'.group[data-group="tools"]')}(e)||this.setActive(null))}),this)};var Lg={__depends__:[uc],__init__:["toolManager"],toolManager:["type",Bg]};function Ng(e){var t=this;function n(e){t._lastMoveEvent=e}this._lastMoveEvent=null,e.on("canvas.init",(function(e){(t._svg=e.svg).addEventListener("mousemove",n)})),e.on("canvas.destroy",(function(){t._lastMouseEvent=null,t._svg.removeEventListener("mousemove",n)}))}Ng.$inject=["eventBus"],Ng.prototype.getLastMoveEvent=function(){return this._lastMoveEvent||function(e,t){var n=document.createEvent("MouseEvent"),i=e,o=t,r=e,s=t;n.initMouseEvent&&n.initMouseEvent("mousemove",!0,!0,window,0,i,o,r,s,!1,!1,!1,!1,0,null);return n}(0,0)};var qg={__init__:["mouse"],mouse:["type",Ng]},Vg="crosshair";function Fg(e,t,n,i,o,r,s){this._selection=o,this._dragging=n,this._mouse=s;var a=this,l=function(e){var n,i=t.getActiveLayer();jn(n=e.frame=Qn("rect"),{class:"djs-lasso-overlay",width:1,height:1,x:0,y:0}),An(i,n)},c=function(e){var t=e.frame,n=e.bbox;jn(t,{x:n.x,y:n.y,width:n.width,height:n.height})},u=function(e){e.frame&&ti(e.frame)};r.registerTool("lasso",{tool:"lasso.selection",dragging:"lasso"}),e.on("lasso.selection.end",(function(t){var n=t.originalEvent.target;(t.hover||n instanceof SVGElement)&&e.once("lasso.selection.ended",(function(){a.activateLasso(t.originalEvent,!0)}))})),e.on("lasso.end",0,(function(e){var t=e.context,n=zg(e),o=i.filter((function(e){return e})),r=ba(e);a.select(o,n,r?t.selection:[])})),e.on("lasso.start",(function(e){var t=e.context;t.bbox=zg(e),l(t),t.selection=o.get()})),e.on("lasso.move",(function(e){var t=e.context;t.bbox=zg(e),c(t)})),e.on("lasso.cleanup",(function(e){var t=e.context;u(t)})),e.on("element.mousedown",1500,(function(e){if(ba(e))return a.activateLasso(e.originalEvent),!0}))}function zg(e){var t={x:e.x-e.dx,y:e.y-e.dy},n={x:e.x,y:e.y};return t.x<=n.x&&t.y<n.y||t.x<n.x&&t.y<=n.y?{x:t.x,y:t.y,width:n.x-t.x,height:n.y-t.y}:t.x>=n.x&&t.y<n.y||t.x>n.x&&t.y<=n.y?{x:n.x,y:t.y,width:t.x-n.x,height:n.y-t.y}:t.x<=n.x&&t.y>n.y||t.x<n.x&&t.y>=n.y?{x:t.x,y:n.y,width:n.x-t.x,height:t.y-n.y}:t.x>=n.x&&t.y>n.y||t.x>n.x&&t.y>=n.y?{x:n.x,y:n.y,width:t.x-n.x,height:t.y-n.y}:{x:n.x,y:n.y,width:0,height:0}}Fg.$inject=["eventBus","canvas","dragging","elementRegistry","selection","toolManager","mouse"],Fg.prototype.activateLasso=function(e,t){this._dragging.init(e,"lasso",{autoActivate:t,cursor:Vg,data:{context:{}}})},Fg.prototype.activateSelection=function(e,t){this._dragging.init(e,"lasso.selection",{trapClick:!1,autoActivate:t,cursor:Vg,data:{context:{}},keepSelection:!0})},Fg.prototype.select=function(e,t,n=[]){var i=function(e,t){var n={};return p(e,(function(e){var i=e;i.waypoints&&(i=mi(i)),!a(t.y)&&i.x>t.x&&(n[e.id]=e),!a(t.x)&&i.y>t.y&&(n[e.id]=e),i.x>t.x&&i.y>t.y&&(a(t.width)&&a(t.height)&&i.width+i.x<t.width+t.x&&i.height+i.y<t.height+t.y?n[e.id]=e:a(t.width)&&a(t.height)||(n[e.id]=e))})),n}(e,t);this._selection.select([...n,...x(i)])},Fg.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},Fg.prototype.isActive=function(){var e=this._dragging.context();return e&&/^lasso/.test(e.prefix)};var Qg={__depends__:[Lg,qg],__init__:["lassoTool"],lassoTool:["type",Fg]},Hg=1500,Wg="grab";function Ug(e,t,n,i,o,r){this._dragging=n,this._mouse=r;var s=this,a=i.get("keyboard",!1);o.registerTool("hand",{tool:"hand",dragging:"hand.move"}),e.on("element.mousedown",Hg,(function(e){if(xa(e))return s.activateMove(e.originalEvent,!0),!1})),a&&a.addListener(Hg,(function(e){if(Xg(e.keyEvent)&&!s.isActive()){var t=s._mouse.getLastMoveEvent();s.activateMove(t,!!t)}}),"keyboard.keydown"),a&&a.addListener(Hg,(function(e){Xg(e.keyEvent)&&s.isActive()&&s.toggle()}),"keyboard.keyup"),e.on("hand.end",(function(t){var n=t.originalEvent.target;if(!(t.hover||n instanceof SVGElement))return!1;e.once("hand.ended",(function(){s.activateMove(t.originalEvent,{reactivate:!0})}))})),e.on("hand.move.move",(function(e){var n=t.viewbox().scale;t.scroll({dx:e.dx*n,dy:e.dy*n})})),e.on("hand.move.end",(function(t){var n=t.context.reactivate;return!xa(t)&&n&&e.once("hand.move.ended",(function(e){s.activateHand(e.originalEvent,!0,!0)})),!1}))}function Xg(e){return fl("Space",e)}Ug.$inject=["eventBus","canvas","dragging","injector","toolManager","mouse"],Ug.prototype.activateMove=function(e,t,n){"object"==typeof t&&(n=t,t=!1),this._dragging.init(e,"hand.move",{autoActivate:t,cursor:Wg,data:{context:n||{}}})},Ug.prototype.activateHand=function(e,t,n){this._dragging.init(e,"hand",{trapClick:!1,autoActivate:t,cursor:Wg,data:{context:{reactivate:n}}})},Ug.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateHand(e,!!e)},Ug.prototype.isActive=function(){var e=this._dragging.context();return!!e&&/^(hand|hand\.move)$/.test(e.prefix)};var Kg={__depends__:[Lg,qg],__init__:["handTool"],handTool:["type",Ug]};function Gg(e,t,n,i,o,r){this._palette=e,this._create=t,this._elementFactory=n,this._handTool=i,this._lassoTool=o,this._translate=r,e.registerProvider(this)}Gg.$inject=["palette","create","elementFactory","handTool","lassoTool","translate"],Gg.prototype.getPaletteEntries=function(e){var t={},n=this._create,i=this._elementFactory,o=this._handTool,r=this._lassoTool,s=this._translate;function a(e,t,o,r,s){function a(t){var o=i.createShape(M({type:e},s));n.start(t,o)}return{group:t,className:o,title:r,action:{dragstart:a,click:a}}}return M(t,{"hand-tool":{group:"tools",className:"dmn-icon-hand-tool",title:s("Activate hand tool"),action:{click:function(e){o.activateHand(e)}}},"lasso-tool":{group:"tools",className:"dmn-icon-lasso-tool",title:s("Activate lasso tool"),action:{click:function(e){r.activateSelection(e)}}},"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"))}),t};var Yg={__depends__:[ha,Ig,zu,Qg,Kg],__init__:["paletteProvider"],paletteProvider:["type",Gg]},Zg=Math.max,Jg=Math.min,em=20;function tm(e,t,n){var i=t[e],o=n.min&&n.min[e],r=n.max&&n.max[e];return a(o)&&(i=(/top|left/.test(e)?Jg:Zg)(i,o)),a(r)&&(i=(/top|left/.test(e)?Zg:Jg)(i,r)),i}function nm(e,t){return void 0!==e?e:em}function im(e){return!e.waypoints&&"label"!==e.type}function om(e,t){var n;if((n=void 0===e.length?d(e.children,im):e).length)return function(e,t){var n,i,o,r;return"object"==typeof t?(n=nm(t.left),i=nm(t.right),o=nm(t.top),r=nm(t.bottom)):n=i=o=r=nm(t),{x:e.x-n,y:e.y-o,width:e.width+n+i,height:e.height+o+r}}(mi(n),t)}function rm(e,t,n,i){this._dragging=i,this._rules=t;var o=this;function r(e,t){var n,i=e.shape,r=e.direction,s=e.resizeConstraints;e.delta=t,n=function(e,t,n){var i=n.x,o=n.y,r={x:e.x,y:e.y,width:e.width,height:e.height};return-1!==t.indexOf("n")?(r.y=e.y+o,r.height=e.height-o):-1!==t.indexOf("s")&&(r.height=e.height+o),-1!==t.indexOf("e")?r.width=e.width+i:-1!==t.indexOf("w")&&(r.x=e.x+i,r.width=e.width-i),r}(i,r,t),e.newBounds=function(e,t){if(!t)return e;var n=po(e);return fo({top:tm("top",n,t),right:tm("right",n,t),bottom:tm("bottom",n,t),left:tm("left",n,t)})}(n,s),e.canExecute=o.canResize(e)}function s(e){var t,i=e.shape,o=e.canExecute,r=e.newBounds;if(o){if(t=r,!function(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}(i,r={x:Math.round(t.x),y:Math.round(t.y),width:Math.round(t.width),height:Math.round(t.height)}))return;n.resizeShape(i,r)}}e.on("resize.start",(function(e){var t,n,i;t=e.context,n=t.resizeConstraints,i=t.minBounds,void 0===n&&(void 0===i&&(i=o.computeMinResizeBox(t)),t.resizeConstraints={min:po(i)})})),e.on("resize.move",(function(e){var t={x:e.dx,y:e.dy};r(e.context,t)})),e.on("resize.end",(function(e){s(e.context)}))}function sm(e,t){var n=mo(e),i=po(e),o={x:n.x,y:n.y};return-1!==t.indexOf("n")?o.y=i.top:-1!==t.indexOf("s")&&(o.y=i.bottom),-1!==t.indexOf("e")?o.x=i.right:-1!==t.indexOf("w")&&(o.x=i.left),o}function am(e){var t="resize-";return"n"===e||"s"===e?t+"ns":"e"===e||"w"===e?t+"ew":"nw"===e||"se"===e?t+"nwse":t+"nesw"}rm.prototype.canResize=function(e){var t=this._rules,n=A(e,["newBounds","shape","delta","direction"]);return t.allowed("shape.resize",n)},rm.prototype.activate=function(e,t,n){var i,o,r=this._dragging;if("string"==typeof n&&(n={direction:n}),!(o=(i=M({shape:t},n)).direction))throw new Error("must provide a direction (n|w|s|e|nw|se|ne|sw)");r.init(e,sm(t,o),"resize",{autoActivate:!0,cursor:am(o),data:{shape:t,context:i}})},rm.prototype.computeMinResizeBox=function(e){var t=e.shape;return function(e,t,n,i){var o=po(t),r={top:/n/.test(e)?o.bottom-n.height:o.top,left:/w/.test(e)?o.right-n.width:o.left,bottom:/s/.test(e)?o.top+n.height:o.bottom,right:/e/.test(e)?o.left+n.width:o.right},s=i?po(i):r;return fo({top:Jg(r.top,s.top),left:Jg(r.left,s.left),bottom:Zg(r.bottom,s.bottom),right:Zg(r.right,s.right)})}(e.direction,t,e.minDimensions||{width:10,height:10},om(t,e.childrenBoxPadding))},rm.$inject=["eventBus","rules","modeling","dragging"];var lm="djs-resizing",cm="resize-not-ok";function um(e,t,n){e.on("resize.move",500,(function(e){var i,o,r,s;i=e.context,o=i.shape,r=i.newBounds,(s=i.frame)||(s=i.frame=n.addFrame(o,t.getActiveLayer()),t.addMarker(o,lm)),r.width>5&&jn(s,{x:r.x,width:r.width}),r.height>5&&jn(s,{y:r.y,height:r.height}),i.canExecute?Bn(s).remove(cm):Bn(s).add(cm)})),e.on("resize.cleanup",(function(e){var n,i;n=e.context,i=n.shape,n.frame&&ti(n.frame),t.removeMarker(i,lm)}))}um.$inject=["eventBus","canvas","previewSupport"];var hm=-6,dm="djs-resizer",pm=["n","w","s","e","nw","ne","se","sw"];function fm(e,t,n,i){this._resize=i,this._canvas=t;var o=this;e.on("selection.changed",(function(e){var t=e.newSelection;o.removeResizers(),1===t.length&&p(t,T(o.addResizer,o))})),e.on("shape.changed",(function(e){var t=e.element;n.isSelected(t)&&(o.removeResizers(),o.addResizer(t))}))}fm.prototype.makeDraggable=function(e,t,n){var i=this._resize;function o(t){ya(t)&&i.activate(t,e,n)}zt.bind(t,"mousedown",o),zt.bind(t,"touchstart",o)},fm.prototype._createResizer=function(e,t,n,i){var o=this._getResizersParent(),r=function(e){var t={x:0,y:0};-1!==e.indexOf("e")?t.x=6:-1!==e.indexOf("w")&&(t.x=hm);-1!==e.indexOf("s")?t.y=6:-1!==e.indexOf("n")&&(t.y=hm);return t}(i),s=Qn("g");Bn(s).add(dm),Bn(s).add(dm+"-"+e.id),Bn(s).add(dm+"-"+i),An(o,s);var a=Qn("rect");jn(a,{x:-4+r.x,y:-4+r.y,width:8,height:8}),Bn(a).add(dm+"-visual"),An(s,a);var l=Qn("rect");return jn(l,{x:-10+r.x,y:-10+r.y,width:20,height:20}),Bn(l).add(dm+"-hit"),An(s,l),function(e,t,n,i,o){var r=Xn();r.setTranslate(t,n);var s=Xn();s.setRotate(0,0,0);var a=Xn();a.setScale(1,1),ii(e,[r,s,a])}(s,t,n),s},fm.prototype.createResizer=function(e,t){var n=sm(e,t),i=this._createResizer(e,n.x,n.y,t);this.makeDraggable(e,i,t)},fm.prototype.addResizer=function(e){var t=this;!co(e)&&this._resize.canResize({shape:e})&&p(pm,(function(n){t.createResizer(e,n)}))},fm.prototype.removeResizers=function(){Nn(this._getResizersParent())},fm.prototype._getResizersParent=function(){return this._canvas.getLayer("resizers")},fm.$inject=["eventBus","canvas","selection","resize"];var gm={__depends__:[gc,uc,Cu],__init__:["resize","resizePreview","resizeHandles"],resize:["type",rm],resizePreview:["type",um],resizeHandles:["type",fm]};function mm(e){e.on(["bendpoint.move.move","bendpoint.move.end"],2e3,(function(e){var t=e.context,n=t.allowed,i=t.hover,o=t.source,r=t.target,s=t.type;if(t.hints||(t.hints={}),delete t.hints.connectionStart,delete t.hints.connectionEnd,(!n||"dmn:InformationRequirement"===n.type)&&i&&gn(i,["dmn:Decision","dmn:InputData"])&&o!==r){var a="reconnectStart"===s||"reconnectEnd"===s,l=vo(o,r);a&&i===o?(!function(e,t){var n=e.context,i=n.source,o=vm(i,t),r=e.x-o.x,s=e.y-o.y;e.x-=r,e.y-=s,e.dx-=r,e.dy-=s}(e,l),t.hints.connectionEnd=ym(r,l)):a&&i===r&&(t.hints.connectionStart=vm(o,l),function(e,t){var n=e.context,i=n.target,o=ym(i,t),r=0,s=0;t.includes("top")||t.includes("bottom")?s=e.y-o.y:r=e.x-o.x;e.x-=r,e.y-=s,e.dx-=r,e.dy-=s}(e,l))}}))}function vm(e,t){var n=po(e),i=mo(e);return t.includes("bottom")?i.y=n.top:t.includes("top")?i.y=n.bottom:t.includes("right")?i.x=n.left:i.x=n.right,i}function ym(e,t){var n=po(e),i=mo(e);return t.includes("bottom")?i.y=n.bottom:t.includes("top")?i.y=n.top:t.includes("right")?i.x=n.right:i.x=n.left,i}mm.$inject=["eventBus"];function xm(e){e.on(["connect.hover","connect.move","connect.end"],250,(function(e){var t=e.context,n=t.canExecute,i=t.hover,o=t.source,r=t.target;if(n&&"dmn:InformationRequirement"===n.type){var s=vo(o,r);t.connectionStart=mo(o),t.connectionEnd=i===o?mo(r):{x:e.x,y:e.y},s.includes("bottom")?(t.connectionStart.y=po(o).top,t.connectionEnd.y=po(r).bottom):s.includes("top")?(t.connectionStart.y=po(o).bottom,t.connectionEnd.y=po(r).top):s.includes("right")?(t.connectionStart.x=po(o).left,t.connectionEnd.x=po(r).right):(t.connectionStart.x=po(o).right,t.connectionEnd.x=po(r).left)}else delete t.connectionStart,delete t.connectionEnd}))}function bm(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}function _m(){this._snapValues={}}xm.$inject=["eventBus"],bm.prototype.getSnapOrigin=function(e){return this._snapOrigins[e]},bm.prototype.setSnapOrigin=function(e,t){this._snapOrigins[e]=t,-1===this._snapLocations.indexOf(e)&&this._snapLocations.push(e)},bm.prototype.addDefaultSnap=function(e,t){var n=this._defaultSnaps[e];n||(n=this._defaultSnaps[e]=[]),n.push(t)},bm.prototype.getSnapLocations=function(){return this._snapLocations},bm.prototype.setSnapLocations=function(e){this._snapLocations=e},bm.prototype.pointsForTarget=function(e){var t=e.id||e,n=this._targets[t];return n||(n=this._targets[t]=new _m).initDefaults(this._defaultSnaps),n},_m.prototype.add=function(e,t){var n=this._snapValues[e];n||(n=this._snapValues[e]={x:[],y:[]}),-1===n.x.indexOf(t.x)&&n.x.push(t.x),-1===n.y.indexOf(t.y)&&n.y.push(t.y)},_m.prototype.snap=function(e,t,n,i){var o=this._snapValues[t];return o&&function(e,t,n){var i,o;for(n=void 0===n?10:n,i=0;i<t.length;i++)if(o=t[i],Yc(o-e)<=n)return o}(e[n],o[n],i)},_m.prototype.initDefaults=function(e){var t=this;p(e||{},(function(e,n){p(e,(function(e){t.add(n,e)}))}))};function wm(e,t,n){var i=this;this._elementRegistry=e,t.on(["create.start","shape.move.start"],(function(e){i.initSnap(e)})),t.on(["create.move","create.end","shape.move.move","shape.move.end"],1250,(function(e){var t=e.context,o=t.shape,r=t.snapContext,s=t.target;if((!e.originalEvent||!pl(e.originalEvent))&&!eu(e)&&s){var a=r.pointsForTarget(s);a.initialized||((a=i.addSnapTargetPoints(a,o,s)).initialized=!0),n.snap(e,a)}})),t.on(["create.cleanup","shape.move.cleanup"],(function(){n.hide()}))}wm.$inject=["elementRegistry","eventBus","snapping"],wm.prototype.initSnap=function(e){var t,n=this._elementRegistry,i=e.context,o=i.shape,r=i.snapContext;r||(r=i.snapContext=new bm);var s=(t=n.get(o.id)?Jc(o,e):{x:e.x+Jc(o).x,y:e.y+Jc(o).y}).x-o.width/2,a=t.y-o.height/2,l=t.x+o.width/2,c=t.y+o.height/2;return r.setSnapOrigin("mid",{x:t.x-e.x,y:t.y-e.y}),uo(o)||(r.setSnapOrigin("top-left",{x:s-e.x,y:a-e.y}),r.setSnapOrigin("bottom-right",{x:l-e.x,y:c-e.y})),r},wm.prototype.addSnapTargetPoints=function(e,t,n){return p(this.getSnapTargets(t,n),(function(n){if(uo(n))uo(t)&&e.add("mid",Jc(n));else if(co(n)){if(n.waypoints.length<3)return;p(n.waypoints.slice(1,-1),(function(t){e.add("mid",t)}))}else e.add("mid",Jc(n))})),a(t.x)&&a(t.y)?(this._elementRegistry.get(t.id)&&e.add("mid",Jc(t)),e):e},wm.prototype.getSnapTargets=function(e,t){return nu(t).filter((function(e){return!e.hidden}))};function Cm(e,t){var n=this;e.on(["resize.start"],(function(e){n.initSnap(e)})),e.on(["resize.move","resize.end"],1250,(function(e){var i=e.context,o=i.shape,r=o.parent,s=i.direction,a=i.snapContext;if(!(e.originalEvent&&pl(e.originalEvent)||eu(e))){var l=a.pointsForTarget(r);l.initialized||((l=n.addSnapTargetPoints(l,o,r,s)).initialized=!0),function(e){return"n"===e||"s"===e}(s)&&tu(e,"x",e.x),function(e){return"e"===e||"w"===e}(s)&&tu(e,"y",e.y),t.snap(e,l)}})),e.on(["resize.cleanup"],(function(){t.hide()}))}function Om(e,t){var n=mo(e),i=po(e),o={x:n.x,y:n.y};return-1!==t.indexOf("n")?o.y=i.top:-1!==t.indexOf("s")&&(o.y=i.bottom),-1!==t.indexOf("e")?o.x=i.right:-1!==t.indexOf("w")&&(o.x=i.left),o}Cm.prototype.initSnap=function(e){var t=e.context,n=t.shape,i=t.direction,o=t.snapContext;o||(o=t.snapContext=new bm);var r=Om(n,i);return o.setSnapOrigin("corner",{x:r.x-e.x,y:r.y-e.y}),o},Cm.prototype.addSnapTargetPoints=function(e,t,n,i){return p(this.getSnapTargets(t,n),(function(t){var n;e.add("corner",{x:(n=t).x+n.width,y:n.y+n.height}),e.add("corner",function(e){return{x:e.x,y:e.y}}(t))})),e.add("corner",Om(t,i)),e},Cm.$inject=["eventBus","snapping"],Cm.prototype.getSnapTargets=function(e,t){return nu(t).filter((function(t){return!(n=t,i=e,n.host===i||co(t)||function(e){return!!e.hidden}(t)||uo(t));var n,i}))};function km(e){this._canvas=e,this._asyncHide=R(T(this.hide,this),1e3)}km.$inject=["canvas"],km.prototype.snap=function(e,t){var n=e.context.snapContext,i=n.getSnapLocations(),o={x:eu(e,"x"),y:eu(e,"y")};p(i,(function(i){var r=n.getSnapOrigin(i),s={x:e.x+r.x,y:e.y+r.y};if(p(["x","y"],(function(e){var n;o[e]||void 0!==(n=t.snap(s,i,e,7))&&(o[e]={value:n,originValue:n-r[e]})})),o.x&&o.y)return!1})),this.showSnapLine("vertical",o.x&&o.x.value),this.showSnapLine("horizontal",o.y&&o.y.value),p(["x","y"],(function(t){var n=o[t];s(n)&&tu(e,t,n.originValue)}))},km.prototype._createLine=function(e){var t=this._canvas.getLayer("snap"),n=Qn("path");return jn(n,{d:"M0,0 L0,0"}),Bn(n).add("djs-snap-line"),An(t,n),{update:function(t){a(t)?jn(n,"horizontal"===e?{d:"M-100000,"+t+" L+100000,"+t,display:""}:{d:"M "+t+",-100000 L "+t+", +100000",display:""}):jn(n,{display:"none"})}}},km.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}},km.prototype.showSnapLine=function(e,t){var n=this.getSnapLine(e);n&&n.update(t),this._asyncHide()},km.prototype.getSnapLine=function(e){return this._snapLines||this._createSnapLines(),this._snapLines[e]},km.prototype.hide=function(){p(this._snapLines,(function(e){e.update()}))};var Em={__depends__:[{__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",wm],resizeSnapping:["type",Cm],snapping:["type",km]}],__init__:["bendpointSnapping","connectSnapping"],bendpointSnapping:["type",mm],connectSnapping:["type",xm]};function Sm(e){Sl.call(this,e)}function Rm(e,t){jm(e,"dmn:Decision")?function(e,t){for(const n of e.get("informationRequirement"))Tm(n,t);for(const n of e.get("knowledgeRequirement"))Am(n,t)}(e,t):jm(e,"dmn:BusinessKnowledgeModel")?function(e,t){for(const n of e.get("knowledgeRequirement"))Am(n,t)}(e,t):jm(e,"dmn:Expression")&&function(e,t){jm(e,"dmn:FunctionDefinition")&&function(e,t){const n=e.get("formalParameter");for(const e of n)Pm(e,t)}(e,t)}(e,t)}function Tm(e,t){const n=e.get("requiredInput");n&&function(e,t){const n=$m(e,t.rootElement);if(!n)return;const i=n.get("name");if(!i)return;t.variables.push({name:i,origin:n})}(n,t);const i=e.get("requiredDecision");i&&function(e,t){const n=$m(e,t.rootElement);if(!n)return;const i=n.get("name");if(!i)return;const o={name:i,origin:n},r=n.get("decisionLogic");r&&function(e,t,n){if(jm(e,"dmn:DecisionTable")){!function(e,t,n){if(1===e.length){const n={...Mm(e[0]),name:t.name};return void Object.assign(t,n)}const i=e.map(Mm);t.entries=i.filter((e=>!!e.name))}(e.get("output"),t)}}(r,o);t.variables.push(o)}(i,t)}function Mm(e){const t={name:e.name};return e.typeRef&&(t.detail=e.typeRef),t}function Am(e,t){const n=e.get("requiredKnowledge");n&&function(e,t){const n=$m(e,t.rootElement);if(!n)return;jm(n,"dmn:BusinessKnowledgeModel")&&function(e,t){const n=e.get("name");if(!n)return;const i={name:n,origin:e},o=e.get("encapsulatedLogic");o&&function(e,t,n){const i=e.get("formalParameter"),o=i.map(((e,t)=>{const n={name:e.get("name")||`param ${t+1}`,type:e.get("typeRef")};return n.type||delete n.type,n}));Object.assign(t,{type:"function",params:o})}(o,i);t.variables.push(i)}(n,t)}(n,t)}function Pm(e,t){const n=e.get("name");if(!n)return;const i={name:n,origin:e};e.get("typeRef")&&(i.detail=e.get("typeRef")),t.variables.push(i)}function Dm(e){let t=e;for(;t.$parent;)t=t.$parent;return t}function $m(e,t){const n=e.get("href");if(!n||!n.startsWith("#"))return;const i=n.slice(1);return t.get("drgElement").find((e=>e.get("id")===i))}function jm(e,t){return e.$instanceOf(t)}yn(Sm,Sl),Sm.prototype._modelingModules=[Dl,ic,pc,su,_d,Cd,Md,jd,Vd,Qd,ep,lp,hp,xp,Dp,cg,_g,Sg,Yg,gm,Em],Sm.prototype._modules=[].concat(Sm.prototype._modules,Sm.prototype._modelingModules);class Im{constructor(e){e.registerProvider(this)}getVariables(e,t){return e.concat(function(e){const t={variables:[],rootElement:Dm(e)};for(let n=e;n;n=n.$parent)Rm(n,t);return t.variables}(t))}}Im.$inject=["variableResolver"];const Bm={__init__:["dmnVariableProvider"],dmnVariableProvider:["type",Im],variableResolver:["type",class{constructor(){this._providers=[]}registerProvider(e){this._providers.push(e)}getVariables(e){return this._providers.reduce(((t,n)=>n.getVariables(t,e)),[])}}]};class Lm{constructor(e){M(this,e),zm(this,"businessObject",{writable:!0})}}class Nm extends Lm{constructor(e){super(e),zm(this,"root",{writable:!0}),zm(this,"cells",{enumerable:!0,value:this.cells||[]})}}class qm extends Lm{constructor(e){super(e),zm(this,"root",{writable:!0}),zm(this,"cells",{enumerable:!0,value:this.cells||[]})}}class Vm extends Lm{constructor(e){super(e),zm(this,"row",{writable:!0}),zm(this,"col",{writable:!0})}}const Fm={root:class extends Lm{constructor(e){super(e),zm(this,"rows",{enumerable:!0,value:this.rows||[]}),zm(this,"cols",{enumerable:!0,value:this.cols||[]})}},row:Nm,col:qm,cell:Vm};function zm(e,t,n){Object.defineProperty(e,t,n)}let Qm=class{constructor(){this._uid=12}create(e,t={}){return t.id||(t.id=e+"_"+this._uid++),function(e,t){const n=Fm[e];if(!n)throw new Error("unknown type "+e);return new n(t)}(e,t)}createRoot(e){return this.create("root",e)}createRow(e){return this.create("row",e)}createCol(e){return this.create("col",e)}createCell(e){return this.create("cell",e)}},Hm=class{constructor(e){this._eventBus=e,this._elements={},e.on("table.clear",this.clear.bind(this))}add(e,t){const{id:n}=e;this._elements[n]=e}remove(e){const t=e.id||e;delete this._elements[t]}get(e){return this._elements[e]}getAll(){return Wm(this._elements)}forEach(e){Wm(this._elements).forEach((t=>e(t)))}filter(e){return Wm(this._elements).filter((t=>e(t)))}clear(){this._elements={}}updateId(e,t){this._validateId(t),"string"==typeof e&&(e=this.get(e)),this._eventBus.fire("element.updateId",{element:e,newId:t}),this.remove(e),e.id=t,this.add(e)}_validateId(e){if(!e)throw new Error("element must have an id");if(this._elements[e])throw new Error("element with id "+e+" already added")}};function Wm(e){return Object.keys(e).map((function(t){return e[t]}))}Hm.$inject=["eventBus"];let Um=class{constructor(e){this._listeners={},e.on("elements.changed",(({elements:e})=>{this.elementsChanged(e)})),e.on("root.remove",(t=>{const n=t.root.id;this._listeners[n]&&e.once("root.add",(e=>{const t=e.root.id;this.updateId(n,t)}))})),e.on("element.updateId",(({element:e,newId:t})=>{this.updateId(e.id,t)}))}elementsChanged(e){const t={},n=e.length;for(let i=0;i<n;i++){const{id:n}=e[i];if(t[n])return;t[n]=!0;const o=this._listeners[n]&&this._listeners[n].length;if(o)for(let e=0;e<o;e++)this._listeners[n][e]&&this._listeners[n][e]()}}onElementsChanged(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e][this._listeners[e].length]=t}offElementsChanged(e,t){if(this._listeners[e])if(t){const n=this._listeners[e].indexOf(t);-1!==n&&this._listeners[e].splice(n,1)}else this._listeners[e].length=0}updateId(e,t){this._listeners[e]&&(this._listeners[t]=this._listeners[e],delete this._listeners[e])}};Um.$inject=["eventBus"];class Xm extends Ds{constructor(e){super(e);const t=this._injector=e.injector;this._sheet=t.get("sheet"),this._changeSupport=t.get("changeSupport"),this._components=t.get("components"),this._eventBus=t.get("eventBus");const n=t.get("throttle");this.onElementsChanged=this.onElementsChanged.bind(this),this.onScroll=n(this.onScroll.bind(this))}onElementsChanged(){this.forceUpdate()}onScroll(){this._eventBus.fire("sheet.scroll")}getChildContext(){return{changeSupport:this._changeSupport,components:this._components,injector:this._injector}}componentWillMount(){const{id:e}=this._sheet.getRoot();this._changeSupport.onElementsChanged(e,this.onElementsChanged)}componentWillUnmount(){const{id:e}=this._sheet.getRoot();this._changeSupport.offElementsChanged(e,this.onElementsChanged)}render(){const{rows:e,cols:t}=this._sheet.getRoot(),n=this._components.getComponents("table.before"),i=this._components.getComponents("table.after"),o=this._components.getComponent("table.head"),r=this._components.getComponent("table.body"),s=this._components.getComponent("table.foot");return vr(1,"div","tjs-container",[n&&n.map(((e,t)=>yr(2,e,null,t))),vr(1,"div","tjs-table-container",vr(1,"table","tjs-table",[o&&yr(2,o,{rows:e,cols:t}),r&&yr(2,r,{rows:e,cols:t}),s&&yr(2,s,{rows:e,cols:t})],0),2,{onScroll:this.onScroll}),i&&i.map(((e,t)=>yr(2,e,null,t)))],0)}}let Km=class{constructor(e,t,n,i,o){const{container:r}=n;this._container=r,i.on("root.added",(()=>{Rs(yr(2,Xm,{injector:o}),r)})),i.on("root.remove",(()=>{Rs(null,r)}))}getContainer(){return this._container}};Km.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var Gm={__init__:["changeSupport","components","renderer"],changeSupport:["type",Um],components:["type",class{constructor(){this._listeners={}}getComponent(e,t){const n=this._listeners[e];if(!n)return;let i;for(let e=0;e<n.length&&(i=n[e].callback(t),!i);e++);return i}getComponents(e,t){const n=this._listeners[e],i=[];if(!n)return i;for(let e=0;e<n.length;e++){const o=n[e].callback(t);o&&i.push(o)}return i.length,i}onGetComponent(e,t,n){if(l(t)&&(n=t,t=1e3),!a(t))throw new Error("priority must be a number");const i=this._getListeners(e);let o,r;const s={priority:t,callback:n};for(r=0;o=i[r];r++)if(o.priority<t)return void i.splice(r,0,s);i.push(s)}offGetComponent(e,t){const n=this._getListeners(e);let i,o,r;if(t)for(r=n.length-1;i=n[r];r--)o=i.callback,o===t&&n.splice(r,1);else n.length=0}_getListeners(e){let t=this._listeners[e];return t||(this._listeners[e]=t=[]),t}}],renderer:["type",Km]};class Ym{constructor(e,t){this._elementRegistry=e,this._eventBus=t,this._root=null,t.on("table.clear",(()=>{this.setRoot(null)}))}setRoot(e){if(this._root){const e=this._root;this._eventBus.fire("root.remove",{root:e}),this._root=null,this._eventBus.fire("root.removed",{root:e})}e&&this._eventBus.fire("root.add",{root:e}),this._root=e,e&&this._eventBus.fire("root.added",{root:e})}getRoot(){return this._root||this.setRoot({id:"__implicitroot",rows:[],cols:[]}),this._root}addRow(e,t){const n=this.getRoot();if(n.cols.length!=e.cells.length)throw new Error("number of cells is not equal to number of cols");return void 0===t&&(t=n.rows.length),Zm(t,n.rows,e),e.root=n,this._elementRegistry.add(e),e.cells.forEach(((i,o)=>{this._elementRegistry.add(i),i.row=e,i.col=n.cols[o],Zm(t,n.cols[o].cells,i)})),this._eventBus.fire("row.add",{row:e}),e}removeRow(e){const t=this.getRoot();"string"==typeof e&&(e=this._elementRegistry.get(e));const n=t.rows.indexOf(e);-1!==n&&(Jm(n,t.rows),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach(((e,i)=>{this._elementRegistry.remove(e),e.col=void 0,Jm(n,t.cols[i].cells)})),this._eventBus.fire("row.remove",{row:e}))}addCol(e,t){const n=this.getRoot();if(this._elementRegistry.add(e),n.rows.length!=e.cells.length)throw new Error("number of cells is not equal to number of rows");return void 0===t&&(t=n.cols.length),Zm(t,n.cols,e),e.root=n,e.cells.forEach(((i,o)=>{this._elementRegistry.add(i),i.col=e,i.row=n.rows[o],Zm(t,n.rows[o].cells,i)})),this._eventBus.fire("col.add",{col:e}),e}removeCol(e){const t=this.getRoot();"string"==typeof e&&(e=this._elementRegistry.get(e));const n=t.cols.indexOf(e);-1!==n&&(Jm(n,t.cols),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach(((e,i)=>{this._elementRegistry.remove(e),e.row=void 0,Jm(n,t.rows[i].cells)})),this._eventBus.fire("col.remove",{col:e}))}resized(){this._eventBus.fire("sheet.resized")}}function Zm(e,t,n){return t.splice(e,0,n)}function Jm(e,t){return t.splice(e,1)}function ev(e=!0){const t="number"==typeof e?e:e?300:0;return t?e=>function(e,t){let n=!1;return function(...i){n||(e(...i),n=!0,setTimeout((()=>{n=!1}),t))}}(e,t):e=>e}Ym.$inject=["elementRegistry","eventBus"],ev.$inject=["config.throttle"];var tv={__depends__:[Gm],__init__:["elementFactory","sheet"],elementFactory:["type",Qm],elementRegistry:["type",Hm],eventBus:["type",j],sheet:["type",Ym],throttle:["factory",ev]};class nv{constructor(e={}){let{injector:t}=e;if(!t){let{modules:n,config:i}=this._init(e);t=function(e,t){const n=[{config:["value",e]},tv].concat(t||[]),i=new Sn(n);return i.init(),i}(i,n)}this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("table.init"),this.get("eventBus").fire("diagram.init")}_init(e){let{modules:t,...n}=e;return{modules:t,config:n}}destroy(){const e=this.get("eventBus");e.fire("table.destroy"),e.fire("diagram.destroy")}clear(){const e=this.get("eventBus");e.fire("table.clear"),e.fire("diagram.clear")}}function iv(e){if(!e)return"<null>";const t=e.id?` id="${e.id}"`:"";return`<${e.$type}${t} />`}function ov(e,t){function n(t,n,i){if(t.gfx)throw new Error(`already rendered ${iv(t)}`);return e.element(t,n,i)}function i(e,t,i){p(e,(function(e){n(e,t,i)}))}function o(e,t,i){p(e,(function(e){n(e,t,i)}))}return{handleDecision:function(t){t.id||(t.id="decision");const r=t.decisionLogic;if(!r)throw new Error(`no table for ${iv(t)}`);{if(!r.output)throw new Error(`missing output for ${iv(r)}`);const t=(c=r,e.table(c));r.input&&i(r.input,t,r),i(r.output,t,r),s=r.rule,a=t,l=r,p(s,(function(e){n(e,a,l),o(e.inputEntry,e),o(e.outputEntry,e)}))}var s,a,l,c}}}function rv(e,t){const{elements:n,index:i}=e;return i[t]?e:{elements:[...n,t],index:{...i,[t]:!0}}}function sv(...e){let t={elements:[],index:{}};return e.forEach((function(e){const n=typeof e;"string"===n&&e.length>0?t=rv(t,e):"object"===n&&null!==e&&Object.keys(e).forEach((function(n){e[n]&&(t=rv(t,n))}))})),function(e,t){return e.elements.join(t)}(t," ")}function av(e){return lv(e.constructor,e)}function lv(e,t){const n=e.$inject;if(!n)return;const{injector:i}=t.context,o=[...n,function(...e){for(const i in e){const o=n[i],r=e[i];t[o]=r}}];i.invoke(o)}function cv(e,t){Object.keys(t).forEach((function(n){if("$inject"===n||"__init"===n)return;const i=t[n];"constructor"===n&&i.call(e,e.props,e.context);const o=e[n];if(void 0!==o){if("function"!=typeof o)throw new Error(`failed to mixin <${n}>: cannot combine with non-fn component value`);e[n]=function(e,...t){return function(...n){let i;return t.forEach((function(t){if(i=t.call(e,...n),void 0!==i)return!1})),i}.bind(e)}(e,o,i)}else e[n]=i.bind(e)})),"$inject"in t&&lv(t,e),"__init"in t&&t.__init.call(e,e.props,e.context)}const uv={getSelectionClasses(){const{selected:e,selectedSecondary:t,focussed:n}=this.state;return sv({selected:e,"selected-secondary":t,focussed:n})},selectionChanged(e){this.setState(e)},componentWillUpdate(e){e.elementId!==this.props.elementId&&this.updateSelectionSubscription(!1)},componentDidUpdate(e){e.elementId!==this.props.elementId&&this.updateSelectionSubscription(!0)},componentDidMount(){this.updateSelectionSubscription(!0)},componentWillUnmount(){this.updateSelectionSubscription(!1)},updateSelectionSubscription(e){const{elementId:t}=this.props;t&&t&&this.eventBus[e?"on":"off"](`selection.${t}.changed`,this.selectionChanged)},$inject:["eventBus"]};class hv extends Ds{constructor(e,t){super(e,t),cv(this,uv),av(this)}getRenderProps(...e){const{className:t,elementId:n,coords:i,...o}=this.props,r={className:sv(...e,this.getSelectionClasses(),t)};return n&&(r["data-element-id"]=n),i&&(r["data-coords"]=i),{...r,...o}}}class dv extends hv{constructor(e,t){super(e,t),this.state={}}render(){const{children:e}=this.props;return br(vr(1,"td",null,e,0,{...this.getRenderProps("cell")}))}}const pv={slotFill(e,t){const{type:n,context:i,...o}=e,r=this.components.getComponent(n,i)||t;return r?br(yr(2,r,{...i,...o})):null},slotFills(e){const{type:t,context:n,...i}=e;return this.components.getComponents(t,n).map((e=>br(yr(2,e,{...n,...i}))))},$inject:["components"]};class fv extends Ds{constructor(e,t){super(e,t),cv(this,pv),av(this)}componentDidMount(){this.changeSupport.onElementsChanged(this.getRoot(),this.onElementsChanged)}componentWillUnmount(){this.changeSupport.offElementsChanged(this.getRoot(),this.onElementsChanged)}onElementsChanged=()=>{this.forceUpdate()};getRoot(){return this.sheet.getRoot()}render(){const e=(this.getRoot().businessObject.get("annotationsWidth")||400)+"px";return vr(1,"th","annotation header",[this.slotFills({type:"cell-inner",context:{cellType:"annotations",col:this.sheet.getRoot(),minWidth:400}}),this.translate("Annotations")],0,{style:{width:e}})}}function gv(e){const{row:t}=e,{id:n,description:i}=t.businessObject;return yr(2,dv,{className:"annotation",elementId:n,children:i||"-"})}function mv(e){e.onGetComponent("cell",(({cellType:e})=>"after-label-cells"===e?fv:"after-rule-cells"===e?gv:void 0))}fv.$inject=["changeSupport","sheet","translate"],mv.$inject=["components"];var vv={__init__:["annotationsProvider"],annotationsProvider:["type",mv]};function yv(e,t){return M({id:e.id,type:e.$type,businessObject:e},t)}class xv{constructor(e,t,n){this._elementFactory=e,this._eventBus=t,this._sheet=n}add(e){let t;if(hn(e,"dmn:DecisionTable"))t=this._elementFactory.createRoot(yv(e)),this._sheet.setRoot(t);else if(hn(e,"dmn:InputClause"))t=this._elementFactory.createCol(yv(e)),this._sheet.addCol(t);else if(hn(e,"dmn:OutputClause"))t=this._elementFactory.createCol(yv(e)),this._sheet.addCol(t);else if(hn(e,"dmn:DecisionRule")){e.inputEntry||(e.inputEntry=[]),e.outputEntry||(e.outputEntry=[]);const n=[...e.inputEntry,...e.outputEntry].map((e=>this._elementFactory.createCell(yv(e))));t=this._elementFactory.createRow(M(yv(e),{cells:n})),this._sheet.addRow(t)}return this._eventBus.fire("dmnElement.added",{element:t}),t}}xv.$inject=["elementFactory","eventBus","sheet"];var bv={__depends__:[{__depends__:[ha],tableImporter:["type",xv]},Gm]};class _v extends Ds{constructor(e,t){super(e,t),cv(this,pv),this._sheet=t.injector.get("sheet"),this._changeSupport=t.changeSupport}onElementsChanged=()=>{this.forceUpdate()};componentWillMount(){const e=this._sheet.getRoot();this._changeSupport.onElementsChanged(e.id,this.onElementsChanged)}componentWillUnmount(){const e=this._sheet.getRoot();this._changeSupport.offElementsChanged(e.id,this.onElementsChanged)}render(){const e=this._sheet.getRoot();if(!hn(e,"dmn:DMNElement"))return null;const t=fn(e),n=t.input,i=t.output;return vr(1,"thead",null,vr(1,"tr",null,[vr(1,"th","index-column"),this.slotFills({type:"cell",context:{cellType:"before-label-cells"}}),n&&n.map(((e,t)=>{const i=e.width||"192px";return this.slotFill({type:"cell",context:{cellType:"input-header",input:e,index:t,inputsLength:n.length,width:i},key:e.id},wv)})),i.map(((e,t)=>this.slotFill({type:"cell",context:{cellType:"output-header",output:e,index:t,outputsLength:i.length},key:e.id},Cv))),this.slotFills({type:"cell",context:{cellType:"after-label-cells"}})],0),2)}}function wv(e,t){const{input:n,className:i,index:o}=e,{label:r,inputExpression:s,inputValues:a}=n,l=t.injector.get("translate");return vr(1,"th",(i||"")+" input-cell",[vr(1,"div","clause",l(0===o?"When":"And"),0),r?vr(1,"div","input-label",r,0,{title:l("Input label: ")+r}):vr(1,"div","input-expression",s.text,0,{title:l("Input expression: ")+s.text}),vr(1,"div","input-variable",a&&a.text||s.typeRef,0,{title:a&&a.text?l("Input values"):l("Input type")})],0,{"data-col-id":n.id},n.id)}function Cv(e,t){const{output:n,className:i,index:o}=e,{label:r,name:s,outputValues:a,typeRef:l}=n,c=t.injector.get("translate");return vr(1,"th",(i||"")+" output-cell",[vr(1,"div","clause",c(0===o?"Then":"And"),0),r?vr(1,"div","output-label",r,0,{title:c("Output label")}):vr(1,"div","output-name",s,0,{title:c("Output name")}),vr(1,"div","output-variable",a&&a.text||l,0,{title:a&&a.text?c("Output values"):c("Output type")})],0,null,n.id)}function Ov(e){e.onGetComponent("table.head",(()=>_v))}Ov.$inject=["components"];var kv={__init__:["decisionTableHeadProvider"],decisionTableHeadProvider:["type",Ov]};let Ev=class extends Ds{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),av(this)}render(){const e=this.sheet.getRoot();if(!hn(e,"dmn:DMNElement"))return null;const{name:t}=e.businessObject.$parent,n=this.components.getComponent("hit-policy")||Sv;return vr(1,"div","decision-table-properties",[vr(1,"div","decision-table-name",t,0,{title:this._translate("Decision name: ")+t}),vr(1,"div","decision-table-header-separator"),yr(2,n)],4)}};function Sv(){return null}Ev.$inject=["sheet","components"];let Rv=class{constructor(e){e.onGetComponent("table.before",500,(()=>Ev))}};Rv.$inject=["components"];var Tv={__init__:["decisionTableProperties"],decisionTableProperties:["type",Rv]};class Mv extends Ds{render(){const{row:e,rowIndex:t}=this.props,{components:n}=this.context,i=n.getComponents("cell-inner",{cellType:"rule-index",row:e,rowIndex:t});return vr(1,"td","rule-index",[i&&i.map((n=>yr(2,n,{row:e,rowIndex:t}))),t+1],0,{"data-element-id":e.id,"data-row-id":e.id})}}class Av{constructor(e){e.onGetComponent("cell",(({cellType:e})=>{if("before-rule-cells"===e)return Mv}))}}Av.$inject=["components"];var Pv={__init__:["decisionRuleIndices"],decisionRuleIndices:["type",Av]};const Dv=[{label:"FEEL",value:"feel"}];class $v{constructor(e){this._injector=e;const t=e.get("config.expressionLanguages")||{};this._config={options:Dv,defaults:{editor:"feel"}},t.options&&(this._config.options=t.options);const n=this._getLegacyDefaults();M(this._config.defaults,n,t.defaults)}getDefault(e){const{defaults:t}=this._config,n=t[e]||t.editor;return this._getLanguageByValue(n)||this.getAll()[0]}getLabel(e){const t=this._getLanguageByValue(e);return t?t.label:e}getAll(){return this._config.options}_getLegacyDefaults(){const e={},t=this._injector,n=t.get("config.defaultInputExpressionLanguage"),i=t.get("config.defaultOutputExpressionLanguage");return n&&(e.inputCell=n),i&&(e.outputCell=i),e}_getLanguageByValue(e){return h(this.getAll(),(t=>e===t.value))}}$v.$inject=["injector"];var jv={__init__:["expressionLanguages"],expressionLanguages:["type",$v]};class Iv extends Ds{render({rows:e,cols:t}){const{components:n}=this.context;return vr(1,"tbody",null,e.map(((e,i)=>{const o=n.getComponent("row",{rowType:"rule"});return o&&yr(2,o,{row:e,rowIndex:i,cols:t},e.id)})),0)}}class Bv extends Ds{constructor(e,t){super(e,t),cv(this,pv)}render(){const{row:e,rowIndex:t,cols:n}=this.props,{cells:i}=e;return vr(1,"tr",null,[this.slotFills({type:"cell",context:{cellType:"before-rule-cells",row:e,rowIndex:t}}),i.map(((i,o)=>this.slotFill({type:"cell",context:{cellType:"rule",cell:i,rowIndex:t,colIndex:o},key:i.id,row:e,col:n[o]}))),this.slotFills({type:"cell",context:{cellType:"after-rule-cells",row:e,rowIndex:t}})],0)}}class Lv extends Ds{render(){const{cell:e,row:t,col:n}=this.props;return hn(e,"dmn:UnaryTests")?yr(2,dv,{className:"input-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":n.id,children:e.businessObject.text}):yr(2,dv,{className:"output-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":n.id,children:e.businessObject.text})}}let Nv=class{constructor(e){e.onGetComponent("table.body",(()=>Iv)),e.onGetComponent("row",(({rowType:e})=>{if("rule"===e)return Bv})),e.onGetComponent("cell",(({cellType:e})=>{if("rule"===e)return Lv}))}};Nv.$inject=["components"];var qv={__depends__:[jv],__init__:["decisionRules"],decisionRules:["type",Nv]};const Vv=[{label:"Unique",value:{hitPolicy:"UNIQUE",aggregation:void 0},explanation:"No overlap is possible and all rules are disjoint. Only a single rule can be matched"},{label:"First",value:{hitPolicy:"FIRST",aggregation:void 0},explanation:"Rules may overlap. The first matching rule will be chosen"},{label:"Priority",value:{hitPolicy:"PRIORITY",aggregation:void 0},explanation:"Rules may overlap. The one with the highest priority will be chosen"},{label:"Any",value:{hitPolicy:"ANY",aggregation:void 0},explanation:"Rules may overlap. Their output have to match"},{label:"Collect",value:{hitPolicy:"COLLECT",aggregation:void 0},explanation:"Collects the values of all matching rules"},{label:"Collect (Sum)",value:{hitPolicy:"COLLECT",aggregation:"SUM"},explanation:"Collects the values of all matching rules and sums up to a single value"},{label:"Collect (Min)",value:{hitPolicy:"COLLECT",aggregation:"MIN"},explanation:"Collects the values of all matching rules and uses the lowest value"},{label:"Collect (Max)",value:{hitPolicy:"COLLECT",aggregation:"MAX"},explanation:"Collects the values of all matching rules and uses the highest value"},{label:"Collect (Count)",value:{hitPolicy:"COLLECT",aggregation:"COUNT"},explanation:"Collects the values of all matching rules and counts the number of them"},{label:"Rule order",value:{hitPolicy:"RULE ORDER",aggregation:void 0},explanation:"Collects the values of all matching rules in rule order"},{label:"Output order",value:{hitPolicy:"OUTPUT ORDER",aggregation:void 0},explanation:"Collects the values of all matching rules in decreasing output priority order"}];class Fv extends Ds{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),av(this)}getRoot(){return this.sheet.getRoot()}render(){const e=this.getRoot().businessObject,{aggregation:t,hitPolicy:n}=e,i=h(Vv,(e=>function(e,t){return e.hitPolicy===t.hitPolicy&&e.aggregation===t.aggregation}(e.value,{aggregation:t,hitPolicy:n})));return vr(1,"div","hit-policy header",[vr(1,"label","dms-label",this._translate("Hit policy:"),0),vr(1,"span","hit-policy-value",this._translate(i.label),0)],4,{title:this._translate(i.explanation)})}}function zv(e){e.onGetComponent("hit-policy",(()=>Fv))}Fv.$inject=["sheet"],zv.$inject=["components"];var Qv={__init__:["hitPolicyProvider"],hitPolicyProvider:["type",zv]};let Hv=class extends Ds{constructor(e,t){super(e,t);const{injector:n}=t;this._translate=n.get("translate"),this._eventBus=n.get("eventBus")}onClick=()=>{this._eventBus.fire("showDrd")};render(){return vr(1,"div","view-drd",vr(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,(e=>this.node=e))}},Wv=class{constructor(e,t,n,i){this._injector=n,this._sheet=i,e.onGetComponent("table.before",(()=>{if(this.canViewDrd())return Hv})),t.on("showDrd",(()=>{const e=n.get("_parent",!1),t=Uv(i.getRoot());if(!t)return;const o=e.getView(t);e.open(o)}))}canViewDrd(){const e=this._injector.get("_parent",!1);if(!e)return!1;const t=Uv(this._sheet.getRoot());return!!e.getView(t)}};function Uv(e){const{businessObject:t}=e;if(!t)return;return t.$parent.$parent}Wv.$inject=["components","eventBus","injector","sheet"];var Xv={__init__:["viewDrd"],viewDrd:["type",Wv]};let Kv=class{constructor(e){e.onGetComponent("table.before",(()=>Bs))}};Kv.$inject=["components"];var Gv={__init__:["poweredBy"],poweredBy:["type",Kv]};let Yv=class e extends nv{constructor(t={}){const n=e._createContainer();super(M(t,{renderer:{container:n}})),this._container=n}open(e){var t=this;return new Promise(((n,i)=>{var o;try{return t._decision&&t.clear(),t._decision=e,function(e,t,n){const i=e.get("tableImporter"),o=e.get("eventBus"),r=e.get("sheet");e.get("modeling",!1);let s,a=[];o.fire("import.render.start",{decision:t});try{!function(e){new ov({create:(e,t,n,o)=>i.create(e,t,n,o),table:e=>i.add(e),element:(e,t,n)=>i.add(e,t,n),error(e,t){a.push({message:e,context:t})}}).handleDecision(e)}(t)}catch(e){s=e}o.fire("import.render.complete",{error:s,warnings:a}),o.fire("elements.changed",{elements:[r.getRoot()]}),n(s,a)}(t,e,(function(e,t){e?(e.warnings=t||[],i(e)):n({warnings:t||[]})}))}catch(e){o=e}o?(o.warnings=o.warnings||[],i(o)):n({warnings:[]})}))}_init(e){let{modules:t,additionalModules:n,...i}=e,o=t||this.getModules();return{modules:[Gv,...o,...n||[],...[{decisionTable:["value",this]}]],config:i}}on(e,t,n,i){return this.get("eventBus").on(e,t,n,i)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}attachTo(e){if(!e)throw new Error("parentNode required");this.detach();const t=this._container;e.appendChild(t),this._emit("attach",{})}detach(){const e=this._container;e.parentNode&&(this._emit("detach",{}),en(e))}destroy(){super.destroy(),this.detach()}getModules(){return e._getModules()}static _getModules(){return[vv,bv,ha,kv,Tv,Pv,qv,Qv,Xv]}static _createContainer(){return Gt('<div class="dmn-decision-table-container"></div>')}};class Zv extends Ds{constructor(e,t){super(e,t),av(this),this.addRule=this.addRule.bind(this)}componentWillMount(){this._eventBus=this.context.injector.get("eventBus")}handleClick=e=>{e.stopPropagation(),this.addRule(e.target.dataset.colIndex)};addRule(e){this._eventBus.fire("addRule",{colIndex:e})}render(){const{cols:e}=this.props,t=[vr(1,"td","add-rule-add",vr(1,"button","dmn-icon-plus action-icon",null,1,{title:this.translate("Add rule")}),2)],{businessObject:n}=this.sheet.getRoot();n.input&&n.input.length||t.push(vr(1,"td","input-cell",xr("-"),2));for(let n=0;n<e.length+1;n++){let i="add-rule";const o=e[n]&&e[n].businessObject;let r="";o?(o.$instanceOf("dmn:InputClause")&&(i+=" input-cell",r="-"),o.$instanceOf("dmn:OutputClause")&&(i+=" output-cell")):i+=" annotation",t.push(vr(1,"td",i,r,0,{"data-col-index":n}))}return vr(1,"tfoot","actionable add-rule",vr(1,"tr",null,t,0),2,{onClick:this.handleClick})}}Zv.$inject=["sheet","translate"];class Jv{constructor(e,t,n,i){e.onGetComponent("table.foot",(()=>Zv)),n.on("addRule",((e,n)=>{const o=t.trigger("addRule"),r=n.colIndex;o.cells[r]?i.select(o.cells[r]):i.select(o.cells[0])}))}}Jv.$inject=["components","editorActions","eventBus","selection"];class ey{constructor(e,t,n){this._elementRegistry=e,this._eventBus=t,this._renderer=n,this._selection=void 0,t.on("diagram.clear",(()=>{this._selection=void 0}))}select(e){c(e)&&(e=this._elementRegistry.get(e));const t=this._selection;t!==e&&(this._selection=e,this._eventBus.fire("selection.changed",{oldSelection:t,selection:e}))}deselect(){const 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}}ey.$inject=["elementRegistry","eventBus","renderer"];class ty{constructor(e,t,n,i){this._elementRegistry=e,this._renderer=n,this._selection=i,t.on(["cell.click","cell.contextmenu"],(({id:t})=>{const n=e.get(t);n&&i.select(n)})),t.on("row.remove",(({row:e})=>{const t=i.get();t&&e===t.row&&i.deselect()})),t.on("col.remove",(({col:e})=>{const t=i.get();t&&e===t.col&&i.deselect()}))}}ty.$inject=["elementRegistry","eventBus","renderer","selection"];var ny={__init__:["selection","selectionBehavior"],selection:["type",ey],selectionBehavior:["type",ty]};const iy=["click","dblclick","contextmenu","mousedown","mouseup","mouseenter","mouseleave","mouseout","mouseover","mousemove","focusin","focusout","drag","dragstart","dragend","dragover","dragenter","dragleave","drop"];class oy{constructor(e,t){var n,i,o;o=e=>{const{target:t,type:n}=e,i=Bt(t,"[data-element-id]",!0);if(!i)return;const o=i.getAttribute("data-element-id");if(o){const t=this._eventBus.createEvent({id:o,event:e,node:i,target:i});this._eventBus.fire(`cell.${n}`,t),t.defaultPrevented&&e.preventDefault(),t.cancelBubble&&e.stopPropagation()}},(i="_handleEvent")in(n=this)?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o,this._eventBus=t,this._container=e.container,t.on("table.init",(()=>{this._addEventListeners(iy)})),t.on("table.destroy",(()=>{this._removeEventListeners(iy)}))}_addEventListeners(e){const t=this._container;e.forEach((e=>{t.addEventListener(e,this._handleEvent)}))}_removeEventListeners(e){const t=this._container;e.forEach((e=>{t.removeEventListener(e,this._handleEvent)}))}}oy.$inject=["config.renderer","eventBus"];var ry={__init__:["interactionEvents"],interactionEvents:["type",oy]},sy="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ay(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ly,cy={exports:{}},uy=cy.exports; 192 /*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */var hy=(ly||(ly=1,function(e,t){var n;n=void 0!==sy?sy:uy,e.exports=function(e){if(e.CSS&&e.CSS.escape)return e.CSS.escape;var t=function(e){if(0==arguments.length)throw new TypeError("`CSS.escape` requires an argument.");for(var t,n=String(e),i=n.length,o=-1,r="",s=n.charCodeAt(0);++o<i;)0!=(t=n.charCodeAt(o))?r+=t>=1&&t<=31||127==t||0==o&&t>=48&&t<=57||1==o&&t>=48&&t<=57&&45==s?"\\"+t.toString(16)+" ":0==o&&1==i&&45==t||!(t>=128||45==t||95==t||t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122)?"\\"+n.charAt(o):n.charAt(o):r+="�";return r};return e.CSS||(e.CSS={}),e.CSS.escape=t,t}(n)}(cy)),cy.exports),dy=ay(hy),py=function(e,t){return e^t};var fy=/\b(Array|Date|Object|Math|JSON)\b/g,gy=function(e,t){var n=function(e){for(var t=[],n=0;n<e.length;n++)~t.indexOf(e[n])||t.push(e[n]);return t}(function(e){return e.replace(/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\//g,"").replace(fy,"").match(/[a-zA-Z_]\w*/g)||[]}(e));return t&&"string"==typeof t&&(t=function(e){return function(t){return e+t}}(t)),t?function(e,t,n){var i=/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g;return e.replace(i,(function(e){return"("==e[e.length-1]||~t.indexOf(e)?n(e):e}))}(e,n,t):n};var my=vy;function vy(e,t){if(!(this instanceof vy))return new vy(e,t);if(this.node=this.start=this.peeked=e,this.root=t,this.closingTag=!1,this._revisit=!0,this._selects=[],this._rejects=[],e&&this.higher(e))throw new Error("root must be a parent or ancestor to node")}function yy(e,t){var n="nextSibling"==e;return function(i,o,r){i=this.compile(i),o=o&&o>0?o:1;for(var s=this.node,a=this.closingTag,l=this._revisit;s;){if(py(n,a)&&s[t])s=s[t],a=!n;else if(1==s.nodeType&&!s[t]&&py(n,a)){if(a=n,!l)continue}else if(s[e])s=s[e],a=!n;else if(s=s.parentNode,a=n,!l)continue;if(!s||this.higher(s,this.root))break;if(i(s)&&this.selects(s,r)&&this.rejects(s,r)){if(--o)continue;return r||(this.node=s),this.closingTag=a,s}}return null}}vy.prototype.reset=function(e){return this.node=e||this.start,this},vy.prototype.revisit=function(e){return this._revisit=null==e||e,this},vy.prototype.opening=function(){return 1==this.node.nodeType&&(this.closingTag=!1),this},vy.prototype.atOpening=function(){return!this.closingTag},vy.prototype.closing=function(){return 1==this.node.nodeType&&(this.closingTag=!0),this},vy.prototype.atClosing=function(){return this.closingTag},vy.prototype.next=yy("nextSibling","firstChild"),vy.prototype.previous=vy.prototype.prev=yy("previousSibling","lastChild"),vy.prototype.select=function(e){return e=this.compile(e),this._selects.push(e),this},vy.prototype.selects=function(e,t){var n=this._selects,i=n.length;if(!i)return!0;for(var o=0;o<i;o++)if(n[o].call(this,e,t))return!0;return!1},vy.prototype.reject=function(e){return e=this.compile(e),this._rejects.push(e),this},vy.prototype.rejects=function(e,t){var n=this._rejects,i=n.length;if(!i)return!0;for(var o=0;o<i;o++)if(n[o].call(this,e,t))return!1;return!0},vy.prototype.higher=function(e){var t=this.root;if(!t)return!1;for(e=e.parentNode;e&&e!=t;)e=e.parentNode;return e!=t},vy.prototype.compile=function(e){switch(typeof e){case"number":return function(t){return e==t.nodeType};case"string":return new Function("node","return "+gy(e,"node."));case"function":return e;default:return function(){return!0}}},vy.prototype.peak=vy.prototype.peek=function(e,t){return 1==arguments.length&&(t=e,e=!0),(t=null==t?1:t)?t>0?this.next(e,t,!0):this.prev(e,Math.abs(t),!0):this.node},vy.prototype.use=function(e){return e(this),this};var xy=window.getSelection();function by(e){xy.removeAllRanges(),xy.addRange(e)}function _y(e,t){var n=function(e,t){var n,i=t.start,o=t.end,r=document.createRange(),s=my(e.firstChild,e),a=s.node,l=!1,c=0;for(;a;){if(c===i&&(l?r.setStartAfter(a):r.setStartBefore(a)),c===o)return l?r.setEndAfter(a):r.setEndBefore(a),r;if(l||(Oy(a)||a.previousSibling&&(ky(a)||Ey(a)))&&c++,Cy(a)){if(n=a.textContent.length,c<=i&&c+n>i&&r.setStart(a,i-c),c+n>o)return r.setEnd(a,o-c),r;c+=n}a=s.next(),l=s.closingTag}c<=i&&(e.lastChild?r.setStartAfter(e.lastChild):r.setStart(e,0));e.lastChild?r.setEndAfter(e.lastChild):r.setEnd(e,0);return r}(e,t);by(n)}function wy(e){if(!function(e){if(!xy.rangeCount)return null;var t=xy.focusNode;return Cy(t)&&(t=t.parentNode),e==t||e.contains(t)}(e))return null;var t,n,i=xy.getRangeAt(0),o=i.startContainer,r=i.endContainer,s=i.startOffset,a=i.endOffset,l=my(e.firstChild,e),c=l.node,u=!1,h=0;function d(e,t){return 1===arguments.length&&(t=e),e.parentNode===r&&t==r.childNodes[a]}function p(e,t){return 1===arguments.length&&(t=e),e.parentNode===o&&t==o.childNodes[s]}for(;c&&(p(c)&&(n=h),!d(c));){if(u||(Oy(c)||t&&t.nextSibling==c&&(ky(c)||Ey(c)))&&h++,Cy(c)){if(o===c&&(n=h+s),r===c){h+=a;break}h+=c.textContent.length}if((Cy(c)||u)&&(p(c,c.nextSibling)&&(n=h),d(c,c.nextSibling)))break;t=c,c=l.next(),u=l.closingTag}return{start:void 0===n?h:n,end:h}}function Cy(e){return 3===e.nodeType}function Oy(e){return 1===e.nodeType&&"BR"===e.nodeName}function ky(e){return 1===e.nodeType&&"DIV"===e.nodeName}function Ey(e){return 1===e.nodeType&&"P"===e.nodeName}const Sy="[contenteditable]",Ry="[data-element-id]";function Ty(e){return e.getAttribute("data-element-id")}function My(e,t){return Zt(`[data-element-id="${dy(e)}"]`,t)}function Ay(e){return Bt(e,Ry,!0)}function Py(e){const t=Sy;return Yt(e,t)?e:Zt(t,e)}const Dy={above:!0,below:!0,right:!0,left:!0};function $y(e,t,n,i,o){const{container:r}=e;let s=null;function a(e,n){t.fire("selection."+e+".changed",n),t.fire("cellSelection.changed",{elementId:e,selection:n})}function l(e,t=!0){s!==e&&a(s,{selected:!1,focussed:!1}),s=e,e&&a(e,{selected:!0,focussed:t}),e?i.select(e):i.deselect()}t.on("cell.click",500,(function(e){const t=e.target;if(function(e){return Bt(e,".no-deselect",!0)}(t))return;const n=Ay(t);l(n&&Ty(n),!e.defaultPrevented)})),t.on("cell.focusin",500,(function(e){const t=Ty(e.target),n=!e.defaultPrevented;return e.stopPropagation(),l(t,n)})),t.on("cell.focusout",500,(function(e){a(Ty(e.target),{focussed:!1})})),t.on("cellSelection.changed",(function(e){const{elementId:t,selection:n}=e,i=My(t,r);n.focussed&&i&&function(e){const t=Py(e);if(!t)return;if(!document.body.contains(t))return;if(document.activeElement===t)return;t.focus();const n=wy(t);n&&0!==n.end||window.getSelection().setPosition(t.firstChild,t.firstChild.length)}(i)})),t.on("selection.changed",(function(e){const{selection:t,oldSelection:n}=e;var i=t&&t.id,o=n&&n.id;i&&i!==s?l(t.id):o&&o===s&&l()})),this.isCellSelected=function(){return!!s},this.getCellSelection=function(){return s},this.selectCell=function(e){if(!s)return;if(!(e in Dy))throw new Error("direction must be any of { above, below, left, right }");const t=function(e){const t=e.getAttribute("data-coords");if(!t)return null;const[n,i]=t.split(":");return{row:n,col:i}}(My(s,r));if(!t)return!1;const n=function(e,t){const{row:n,col:i}=e;if("above"===t||"below"===t){const o=parseInt(n,10);if(isNaN(o))return e;return{col:i,row:"above"===t?o-1:o+1}}if("left"===t||"right"===t){const o=parseInt(i,10);if(isNaN(o))return e;return{row:n,col:"left"===t?o-1:o+1}}throw new Error("invalid direction <"+t+">")}(t,e),i=function(e,t){const n=`${e.row}:${e.col}`;return Zt(`[data-coords="${dy(n)}"]`,t)}(n,r);if(!i)return!1;const o=Ty(i);return o&&l(o,{focussed:!0,selected:!0}),!0},t.on("contextMenu.close",(function(){if(s)return l(s)}))}$y.$inject=["config.renderer","eventBus","sheet","selection","elementRegistry"];var jy={__depends__:[ry,ny],__init__:["cellSelection"],cellSelection:["type",$y]};function Iy(){}Iy.prototype.get=function(){return this._data},Iy.prototype.set=function(e){this._data=e},Iy.prototype.clear=function(){var e=this._data;return delete this._data,e},Iy.prototype.isEmpty=function(){return!this._data};var By={clipboard:["type",Iy]};const Ly=2e3;class Ny extends zp{constructor(e,t){super(e),this._sheet=t}init(){this.addRule("col.move",Ly,(({col:e,index:t})=>{const{businessObject:n}=this._sheet.getRoot(),{input:i}=n;return dn(e)?t<i.length:t>=i.length})),this.addRule("col.remove",Ly,(({col:e})=>{const{cols:t}=this._sheet.getRoot();return!pn(e)||t.filter((e=>pn(e))).length>1})),this.addRule("paste",Ly,(({data:e,target:t})=>{if(!e||!t)return!1;const{root:n}=e;return t instanceof Nm?this.canPasteRows(n):t instanceof qm&&this.canPasteCols(n,t)}))}canPasteRows(e){const{cols:t}=this._sheet.getRoot();return g(e,(e=>"row"===e.type&&(e.cells.length===t.length&&g(e.cells,((e,n)=>dn(t[n])?"dmn:UnaryTests"===e.businessObject.$type:"dmn:LiteralExpression"===e.businessObject.$type)))))}canPasteCols(e,t){const{rows:n}=this._sheet.getRoot();return g(e,(e=>"col"===e.type&&(e.cells.length===n.length&&(dn(t)?"dmn:InputClause"===e.businessObject.$type:"dmn:OutputClause"===e.businessObject.$type))))}}Ny.$inject=["eventBus","sheet"];var qy={__depends__:[{__depends__:[gc]}],__init__:["decisionTableModelingRules"],decisionTableModelingRules:["type",Ny]};class Vy{constructor(e,t,n){this._clipboard=e,this._modeling=t,this._sheet=n}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((e=>{e instanceof Nm?this._modeling.removeRow(e):e instanceof qm&&this._modeling.removeCol(e)}))}revert(e){const{oldData:t}=e;return this._clipboard.set(t),this._sheet.getRoot()}}Vy.$inject=["clipboard","modeling","sheet"];const Fy=[function(e,t,n,i){var o=n,r={...t,type:Wy(e)};if(e instanceof Nm||e instanceof qm){let t=i(e.cells,o);r.cells=t.root,o=t.descriptorCache}return{root:r,descriptorCache:o}},function(e,t,n){var i=e.businessObject;if(!i)return{root:t,descriptorCache:n};var o=Uy(i,n);return{root:{...t,businessObject:o.root},descriptorCache:o.descriptorCache}}],zy=[function(e,t,n){var i=e.root.businessObject;if(!i)return{root:t,reviveCache:n};var o=Gy({root:i,descriptorCache:e.descriptorCache},n);return{root:{...t,businessObject:o.root},reviveCache:o.reviveCache}},function(e,t,n,i){var o=e.root,r=e.descriptorCache,s={...t};t.businessObject&&t.businessObject.id&&(s.id=t.businessObject.id);if("row"===o.type||"col"===o.type){let e=i({root:o.cells,descriptorCache:r},n);s.cells=e.root,n=e.reviveCache}var a=new(function(e){switch(e.type){case"row":return Nm;case"cell":return Vm;case"col":return qm;default:throw new Error("unknown element type: #"+e.type)}}(o))(s);a instanceof Nm?a.cells.forEach((e=>{e.row=a})):a instanceof qm&&a.cells.forEach((e=>{e.col=a}));return{root:a,reviveCache:n}}];function Qy(e,t,n){return n=n||Fy,t=t||{},r(e)?function(e,t,n){return f(e,((e,t)=>{var i=e.descriptorCache,o=e.root;let{root:r,descriptorCache:s}=Hy(t,i,n);return{root:[...o,r],descriptorCache:{...i,...s}}}),{root:[],descriptorCache:t})}(e,t,n):Hy(e,t,n)}function Hy(e,t,n){var i=e.id,o={id:i},r=t.elements||{},s=r[i];if(s)return{root:s,descriptorCache:t};let a=function(e,t,n,i){function o(e,t){return Qy(e,t,n)}return f(n,(function(t,n){return n(e,t.root,t.descriptorCache,o)}),{root:t,descriptorCache:i})}(e,o,n,{...t,elements:r});return{root:a.root,descriptorCache:{...a.descriptorCache,elements:{...a.descriptorCache.elements,[i]:a.root}}}}function Wy(e){if(e instanceof Nm)return"row";if(e instanceof qm)return"col";if(e instanceof Vm)return"cell";throw new Error("cannot deduce element type: #"+e.id)}function Uy(e,t){var n,i,o=e.id;if(o&&(i=(n=t.boCache||{})[o]))return{root:i,descriptorCache:t};var s={$type:e.$type};return o&&(s.id=o,n={...n,[o]:s},t={...t,boCache:n}),e.$descriptor.properties.forEach((function(n){var i=e[n.name];if(i){if(r(i)&&(i=i.map((e=>{var n=Uy(e,t);return t=n.descriptorCache,n.root}))),i.$type){let e=Uy(i,t);t=e.descriptorCache,i=e.root}s[n.name]=i}})),{root:s,descriptorCache:t}}function Xy(e,t,n){return n=n||zy,t=t||{},r(e.root)?function(e,t,n){let i=e.root,o=e.descriptorCache;return f(i,((e,t)=>{var i=e.reviveCache,r=e.root;let{root:s,reviveCache:a}=Ky({root:t,descriptorCache:o},i,n);return{root:[...r,s],reviveCache:a}}),{root:[],reviveCache:t})}(e,t,n):Ky(e,t,n)}function Ky(e,t,n){var i=e.root.id,o=t.elements||{},r=o[i];if(r)return{root:r,reviveCache:t};let s=function(e,t,n,i){function o(e,t){return Xy(e,t,n)}return f(n,(function(t,n){return n(e,t.root,t.reviveCache,o)}),{root:t,reviveCache:i})}(e,{id:i},n,{...t,elements:o});return{root:s.root,reviveCache:{...s.reviveCache,elements:{...s.reviveCache.elements,[i]:s.root}}}}function Gy(e,t){var n=e.root,i=n.id;let o,s;if(i&&(o=t.boCache||{},s=o[i],s))return{root:s,reviveCache:t};var a={};y(n).forEach((e=>{let i,s;n[e].$type?(s=Gy({root:n[e]},t),i=s.root,t=s.reviveCache,o=t.boCache||{}):i=r(n[e])?n[e].map((e=>(s=Gy({root:e},t),t=s.reviveCache,o=t.boCache||{},s.root))):n[e],a[e]=i}));const l=a.$type;delete a.$type,t._keepIds&&!t._model.ids.assigned(a.id)||delete a.id;var c=t._dmnFactory.create(l,a);return p(a,(e=>{e.$type&&(e.$parent=c),r(e)&&e.forEach((e=>e.$parent=c))})),i&&(o={...o,[i]:c},t={...t,boCache:o}),{root:c,reviveCache:t}}class Yy{constructor(e,t,n,i,o,r,s,a){this._clipboard=e,this._dmnFactory=t,this._elementFactory=n,this._elementRegistry=i,this._eventBus=o,this._model=r,this._modeling=s,this._sheet=a}postExecute(e){let{element:t,after:n}=e;const i=this._clipboard.get();if(!i)throw new Error("missing clipboard data");const o=this._sheet.getRoot(),r=Xy(i.elements,{_dmnFactory:this._dmnFactory,_keepIds:i.keepIds,_model:this._model}).root;if(t instanceof Nm){let e=o.rows.indexOf(t);if(-1===e)return;r.forEach((t=>{n&&e++,this._modeling.addRow(t,e)}))}else if(t instanceof qm){let e=o.cols.indexOf(t);if(-1===e)return;r.forEach((t=>{n&&e++,this._modeling.addCol(t,e)}))}return e.oldElements=this._clipboard.get(),this._sheet.getRoot()}revert(e){}}Yy.$inject=["clipboard","dmnFactory","elementFactory","elementRegistry","eventBus","moddle","modeling","sheet"];class Zy{constructor(e,t,n,i,o,r){this._clipboard=e,this._commandStack=t,this._eventBus=n,this._modeling=i,this._sheet=o,this._rules=r,t.registerHandler("cut",Vy),t.registerHandler("paste",Yy)}copy(e){r(e)||(e=[e]);const t={elements:Qy(e)};this._eventBus.fire("copyCutPaste.copy",{data:t}),this._clipboard.set(t)}cut(e){r(e)||(e=[e]);const t={elements:Qy(e),keepIds:!0},n={elements:e,data:t};this._eventBus.fire("copyCutPaste.cut",{data:t}),this._commandStack.execute("cut",n)}pasteBefore(e){return this._paste(e,{before:!0})}pasteAfter(e){return this._paste(e,{after:!0})}_paste(e,t){const n=this._clipboard.get();if(!n)return;return!!this._rules.allowed("paste",{data:n.elements,target:e})&&(this._commandStack.execute("paste",{element:e,...t}),this._clipboard.clear(),!0)}pasteAt(e){}}Zy.$inject=["clipboard","commandStack","eventBus","modeling","sheet","rules"];var Jy={__depends__:[By,qy],__init__:["copyCutPaste"],copyCutPaste:["type",Zy]};class ex{constructor(e,t,n,i,o,r){const s={addRule:()=>n.addRow({type:"dmn:DecisionRule"}),addRuleAbove(e){let t=e&&e.rule;if(!t&&!i.hasSelection())return;t=t||i.get().row;const o=r.getRoot().rows.indexOf(t);return-1!==o?n.addRow({type:"dmn:DecisionRule"},o):void 0},addRuleBelow(e){let t=e&&e.rule;if(!t&&!i.hasSelection())return;t=t||i.get().row;const o=r.getRoot().rows.indexOf(t);return-1!==o?n.addRow({type:"dmn:DecisionRule"},o+1):void 0},removeRule(e){let t=e&&e.rule;(t||i.hasSelection())&&(t=t||i.get().row,n.removeRow(t))},addInput(){const e=r.getRoot().businessObject,{input:t}=e;return n.addCol({type:"dmn:InputClause"},t?t.length:0)},addInputLeft(e){let t=e&&e.input;if(!t&&!i.hasSelection())return;t=t||i.get().col;const o=r.getRoot().cols.indexOf(t);return-1!==o?n.addCol({type:"dmn:InputClause"},o):void 0},addInputRight(e){let t=e&&e.input;if(!t&&!i.hasSelection())return;t=t||i.get().col;const o=r.getRoot().cols.indexOf(t);return-1!==o?n.addCol({type:"dmn:InputClause"},o+1):void 0},removeInput(e){let t=e&&e.input;(t||i.hasSelection())&&(t=t||i.get().col,n.removeCol(t))},addOutput(){const e=r.getRoot().businessObject,t=e.get("input"),i=e.get("output");return n.addCol({type:"dmn:OutputClause"},t.length+i.length)},addOutputLeft(e){let t=e&&e.output;if(!t&&!i.hasSelection())return;t=t||i.get().col;const o=r.getRoot().cols.indexOf(t);return-1!==o?n.addCol({type:"dmn:OutputClause"},o):void 0},addOutputRight(e){let t=e&&e.output;if(!t&&!i.hasSelection())return;t=t||i.get().col;const o=r.getRoot().cols.indexOf(t);return-1!==o?n.addCol({type:"dmn:OutputClause"},o+1):void 0},removeOutput(e){let t=e&&e.output;(t||i.hasSelection())&&(t=t||i.get().col,n.removeCol(t))},addClause(){if(!i.hasSelection())return;const e=i.get().col;return hn(e,"dmn:InputClause")?s.addInput({input:e}):hn(e,"dmn:OutputClause")?s.addOutput({output:e}):void 0},addClauseLeft(){if(!i.hasSelection())return;const e=i.get().col;return hn(e,"dmn:InputClause")?s.addInputLeft({input:e}):hn(e,"dmn:OutputClause")?s.addOutputLeft({output:e}):void 0},addClauseRight(){if(!i.hasSelection())return;const e=i.get().col;return hn(e,"dmn:InputClause")?s.addInputRight({input:e}):hn(e,"dmn:OutputClause")?s.addOutputRight({output:e}):void 0},removeClause(){if(!i.hasSelection())return;const e=i.get().col;return hn(e,"dmn:InputClause")?s.removeInput({input:e}):hn(e,"dmn:OutputClause")?s.removeOutput({output:e}):void 0},selectCellAbove:()=>o.selectCell("above"),selectCellBelow:()=>o.selectCell("below"),copy({element:t}){e.copy(t)},cut({element:t}){e.cut(t)},pasteBefore:({element:t})=>e.pasteBefore(t),pasteAfter:({element:t})=>e.pasteAfter(t)};t.register(s)}}ex.$inject=["copyCutPaste","editorActions","modeling","selection","cellSelection","sheet"];const tx="is not a registered action";let nx=class{constructor(e,t,n,i){this._actions={undo(){e.undo()},redo(){e.redo()},select({cell:e}){i.select(e)},deselect(){i.deselect()},addRow({attrs:e,index:t}){n.addRow(e,t)},removeRow({row:e}){n.removeRow(e)},moveRow({row:e,index:t}){n.moveRow(e,t)},addCol({attrs:e,index:t}){n.addCol(e,t)},removeCol({col:e}){n.removeCol(e)},moveCol({col:e,index:t}){n.moveCol(e,t)}}}trigger(e,t){if(!this._actions[e])throw ix(e,tx);return this._actions[e](t)}register(e,t){if("string"==typeof e)return this._registerAction(e,t);p(e,((e,t)=>{this._registerAction(t,e)}))}_registerAction(e,t){if(this.isRegistered(e))throw ix(e,"is already registered");this._actions[e]=t}unregister(e){if(!this.isRegistered(e))throw ix(e,tx);this._actions[e]=void 0}isRegistered(e){return!!this._actions[e]}};function ix(e,t){return new Error(e+" "+t)}nx.$inject=["commandStack","eventBus","modeling","selection"];var ox,rx,sx={__depends__:[ny],__init__:["editorActions"],editorActions:["type",nx]},ax={__depends__:[jy,Jy,sx,ny],__init__:["decisionTableEditorActions"],decisionTableEditorActions:["type",ex]},lx={__depends__:[ax],__init__:["addRule"],addRule:["type",Jv]};var cx,ux=function(){if(rx)return ox;rx=1;var e=/["'&<>]/;return ox=function(t){var n,i=""+t,o=e.exec(i);if(!o)return i;var r="",s=0,a=0;for(s=o.index;s<i.length;s++){switch(i.charCodeAt(s)){case 34:n=""";break;case 38:n="&";break;case 39:n="'";break;case 60:n="<";break;case 62:n=">";break;default:continue}a!==s&&(r+=i.substring(a,s)),a=s+1,r+=n}return a!==s?r+i.substring(a,s):r},ox}(),hx=ay(ux),dx={exports:{}};var px=function(){if(cx)return dx.exports;function e(e,t){return{start:e,end:void 0===t?e:t}}return cx=1,dx.exports=function(t,n,i){var o=t.start,r=o,s=(i.length,n.length);i.length,n.length;var a=n.substring(o);return i.lastIndexOf(a)===i.length-a.length&&(n=n.substring(0,n.length-a.length),i=i.substring(0,i.length-a.length)),s=function(e,t){var n,i,o,r=0,s=0;t.length>e.length?(i=t,o=e):(i=e,o=t);for(;r<i.length;)i.charAt(r)!==o.charAt(s)?(n||(n={l_start:r,s_start:s}),r++):(n&&!n.complete&&(n.l_end=r,n.s_end=s,n.complete=!0),s++,r++);n&&!n.complete&&(n.complete=!0,n.s_end=o.length,n.l_end=i.length);if(!n)return;return t.length>e.length?{newStart:n.l_start,newEnd:n.l_end,type:"add"}:{newStart:n.s_start,newEnd:n.s_end,type:t.length<e.length?"remove":"replace"}}(n,i),s&&(r="remove"===s.type?s.newStart:s.newEnd),e(r)},dx.exports.range=e,dx.exports}(),fx=ay(px);class gx extends Ds{constructor(e,t){var n;super(e,t),this.state={},((n=window.navigator.userAgent).indexOf("MSIE ")>0||n.indexOf("Trident/")>0)&&(this.onInputIEPolyfill=e=>{var t=this.node.innerHTML;setTimeout((()=>{var n=this.node.innerHTML;t!==n&&this.onInput(e)}),0)})}componentWillUpdate(e,t){var n=this.node,i=t.focussed&&wy(n);this.selected=i&&{range:i,text:mx(n)}}componentDidUpdate(){var e=this.selected;if(!e)return;const t=e.range,n=e.text,i=this.node,o=mx(i);_y(i,o!==n?fx(t,n,o):t)}onFocus=e=>{var t=this.props.onFocus;this.setState({focussed:!0}),"function"==typeof t&&t(e)};onBlur=e=>{const{onBlur:t,onChange:n,value:i}=this.props;if(this.setState({focussed:!1}),"function"==typeof n&&this.node){const e=mx(this.node);e!==i&&n(e)}"function"==typeof t&&t(e)};onkeydown=e=>{if(13===e.which){if(e.preventDefault(),this.props.ctrlForNewline&&!function(e){return e.metaKey||e.ctrlKey}(e))return;if(this.props.singleLine)return;e.stopPropagation(),function(){var e=xy,t=e.getRangeAt(0);if(!t)return;var n=t.cloneRange(),i=document.createElement("br");n.deleteContents(),n.insertNode(i),n.setStartAfter(i),n.setEndAfter(i),by(n)}(),this.onInput(e)}};onInput=e=>{var t=this.props.onInput;"function"==typeof t&&t(mx(this.node))};onkeypress=e=>{this.onInputIEPolyfill&&this.onInputIEPolyfill(e)};onPaste=e=>{if(this.onInputIEPolyfill&&this.onInputIEPolyfill(e),this.props.singleLine){const t=(e.clipboardData||window.clipboardData).getData("text");document.execCommand("insertText",!1,t.replace(/\n/g," ")),e.preventDefault()}};getClassName(){const{className:e,placeholder:t,value:n}=this.props;return[e||"","content-editable",!n&&t?"placeholder":""].join(" ")}render(e){var{label:t,value:n,placeholder:i}=e;return n=hx(n).replace(/\r?\n/g,"<br/>")+"<br/>",vr(1,"div",this.getClassName(),null,1,{"aria-label":t,role:"textbox","aria-multiline":!this.props.singleLine,tabIndex:"0",contentEditable:"true",spellCheck:"false","data-placeholder":i||"",onInput:this.onInput,onkeypress:this.onkeypress,onPaste:this.onPaste,onFocus:this.onFocus,onBlur:this.onBlur,onkeydown:this.onkeydown,dangerouslySetInnerHTML:{__html:n}},null,(e=>this.node=e))}}function mx(e){return e.innerText.replace(/\n$/,"")}class vx extends Ds{constructor(e,t){super(e,t),this.state={changing:!1,focussed:!1};const{injector:n}=t,i=n.get("debounceInput");this.inputChanged=i((e=>{const{onChange:t}=this.props;"function"==typeof t&&t(e);const n=this.state.changing;this.setState({changing:n!==e&&n})})),this.onInput=e=>{var t=(this.props.validate||function(){})(e);this.setState({changing:e,invalid:t}),t||this.inputChanged(e)}}onFocus=e=>{this.setState({focussed:!0});var{onFocus:t}=this.props;"function"==typeof t&&t(e)};onBlur=e=>{this.setState({focussed:!1});const{invalid:t}=this.state;t&&this.setState({changing:!1,invalid:!1});const{onBlur:n}=this.props;"function"==typeof n&&n(e)};getClassName(){var{className:e,value:t}=this.props,{changing:n,focussed:i,invalid:o}=this.state;return e+=" editable",i&&(e+=" focussed"),o&&(e+=" invalid"),t||n||(e+=" empty"),e}getDisplayValue(){var{value:e,placeholder:t}=this.props,{focussed:n,changing:i}=this.state;return"string"==typeof i&&(e=i),e||(e=n?"":t||""),e}getEditor(e={}){return yr(2,gx,{className:e.className,ctrlForNewline:this.props.ctrlForNewline,label:this.props.label,onFocus:this.onFocus,onBlur:this.onBlur,onInput:this.onInput,value:this.getDisplayValue()})}}class yx extends Ds{constructor(e,t){super(e,t),av(this)}componentWillMount(){const{row:e}=this.props;this.changeSupport.onElementsChanged(e.id,this.onElementsChanged)}componentWillUnmount(){const{row:e}=this.props;this.changeSupport.offElementsChanged(e.id,this.onElementsChanged)}onElementsChanged=()=>{this.forceUpdate()};setAnnotationValue=e=>{const{row:t}=this.props;this.modeling.editAnnotation(t.businessObject,e)};render(){const{row:e,rowIndex:t}=this.props,{description:n,id:i}=e.businessObject;return yr(2,dv,{className:"annotation",onChange:this.setAnnotationValue,coords:`${t}:annotation`,value:n,elementId:i,"data-row-id":e.id,children:yr(2,xx,{label:this.translate("Annotation"),ctrlForNewline:!0,className:"annotation-editor",onChange:this.setAnnotationValue,value:n})})}}yx.$inject=["changeSupport","modeling","translate"];class xx extends vx{render(){return vr(1,"div",this.getClassName(),this.getEditor(),0)}}function bx(e){e.onGetComponent("cell",(({cellType:e})=>"after-label-cells"===e?fv:"after-rule-cells"===e?yx:void 0))}bx.$inject=["components"];function _x(e){return function(t){return!1!==e?R(t,a(e)?e:300):t}}_x.$inject=["config.debounceInput"];var wx={debounceInput:["factory",_x]},Cx={__depends__:[wx],__init__:["annotationsProvider"],annotationsProvider:["type",bx]};function Ox(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var kx=function(e,t){return e^t};var Ex=/\b(Array|Date|Object|Math|JSON)\b/g;var Sx=kx,Rx=function(e,t){var n=function(e){for(var t=[],n=0;n<e.length;n++)~t.indexOf(e[n])||t.push(e[n]);return t}(function(e){return e.replace(/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\//g,"").replace(Ex,"").match(/[a-zA-Z_]\w*/g)||[]}(e));return t&&"string"==typeof t&&(t=function(e){return function(t){return e+t}}(t)),t?function(e,t,n){var i=/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g;return e.replace(i,(function(e){return"("==e[e.length-1]||~t.indexOf(e)?n(e):e}))}(e,n,t):n},Tx=Mx;function Mx(e,t){if(!(this instanceof Mx))return new Mx(e,t);if(this.node=this.start=this.peeked=e,this.root=t,this.closingTag=!1,this._revisit=!0,this._selects=[],this._rejects=[],e&&this.higher(e))throw new Error("root must be a parent or ancestor to node")}function Ax(e,t){var n="nextSibling"==e;return function(i,o,r){i=this.compile(i),o=o&&o>0?o:1;for(var s=this.node,a=this.closingTag,l=this._revisit;s;){if(Sx(n,a)&&s[t])s=s[t],a=!n;else if(1==s.nodeType&&!s[t]&&Sx(n,a)){if(a=n,!l)continue}else if(s[e])s=s[e],a=!n;else if(s=s.parentNode,a=n,!l)continue;if(!s||this.higher(s,this.root))break;if(i(s)&&this.selects(s,r)&&this.rejects(s,r)){if(--o)continue;return r||(this.node=s),this.closingTag=a,s}}return null}}Mx.prototype.reset=function(e){return this.node=e||this.start,this},Mx.prototype.revisit=function(e){return this._revisit=null==e||e,this},Mx.prototype.opening=function(){return 1==this.node.nodeType&&(this.closingTag=!1),this},Mx.prototype.atOpening=function(){return!this.closingTag},Mx.prototype.closing=function(){return 1==this.node.nodeType&&(this.closingTag=!0),this},Mx.prototype.atClosing=function(){return this.closingTag},Mx.prototype.next=Ax("nextSibling","firstChild"),Mx.prototype.previous=Mx.prototype.prev=Ax("previousSibling","lastChild"),Mx.prototype.select=function(e){return e=this.compile(e),this._selects.push(e),this},Mx.prototype.selects=function(e,t){var n=this._selects,i=n.length;if(!i)return!0;for(var o=0;o<i;o++)if(n[o].call(this,e,t))return!0;return!1},Mx.prototype.reject=function(e){return e=this.compile(e),this._rejects.push(e),this},Mx.prototype.rejects=function(e,t){var n=this._rejects,i=n.length;if(!i)return!0;for(var o=0;o<i;o++)if(n[o].call(this,e,t))return!1;return!0},Mx.prototype.higher=function(e){var t=this.root;if(!t)return!1;for(e=e.parentNode;e&&e!=t;)e=e.parentNode;return e!=t},Mx.prototype.compile=function(e){switch(typeof e){case"number":return function(t){return e==t.nodeType};case"string":return new Function("node","return "+Rx(e,"node."));case"function":return e;default:return function(){return!0}}},Mx.prototype.peak=Mx.prototype.peek=function(e,t){return 1==arguments.length&&(t=e,e=!0),(t=null==t?1:t)?t>0?this.next(e,t,!0):this.prev(e,Math.abs(t),!0):this.node},Mx.prototype.use=function(e){return e(this),this};var Px=Ox(Tx),Dx=window.getSelection();function $x(e){Dx.removeAllRanges(),Dx.addRange(e)}function jx(e,t){var n=function(e,t){var n,i=t.start,o=t.end,r=document.createRange(),s=Px(e.firstChild,e),a=s.node,l=!1,c=0;for(;a;){if(c===i&&(l?r.setStartAfter(a):r.setStartBefore(a)),c===o)return l?r.setEndAfter(a):r.setEndBefore(a),r;if(l||(Bx(a)||a.previousSibling&&(Lx(a)||Nx(a)))&&c++,Ix(a)){if(n=a.textContent.length,c<=i&&c+n>i&&r.setStart(a,i-c),c+n>o)return r.setEnd(a,o-c),r;c+=n}a=s.next(),l=s.closingTag}c<=i&&(e.lastChild?r.setStartAfter(e.lastChild):r.setStart(e,0));e.lastChild?r.setEndAfter(e.lastChild):r.setEnd(e,0);return r}(e,t);$x(n)}function Ix(e){return 3===e.nodeType}function Bx(e){return 1===e.nodeType&&"BR"===e.nodeName}function Lx(e){return 1===e.nodeType&&"DIV"===e.nodeName}function Nx(e){return 1===e.nodeType&&"P"===e.nodeName}function qx(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const Vx={position:"absolute"};class Fx extends Ds{constructor(e,t){super(e,t),qx(this,"open",(({position:e,context:t})=>{this.close(),this.setState({isOpen:!0,position:e||{x:0,y:0},context:t||{}})})),qx(this,"close",(()=>{this.state.isOpen&&this.setState({context:void 0,isOpen:!1,position:{x:0,y:0}})})),qx(this,"triggerClose",(()=>{this.eventBus.fire("contextMenu.close")})),this.state={isOpen:!1,position:{x:0,y:0}},av(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(){const{isOpen:e,context:t,position:n}=this.state;if(!e)return null;const i=this.components.getComponents("context-menu",t);return i.length?yr(2,zx,{className:"context-menu no-deselect",context:t,position:n,offset:t.offset||{x:0,y:0},autoFocus:!1!==t.autoFocus,autoClose:!1!==t.autoClose,components:i,onClose:this.triggerClose}):null}}Fx.$inject=["eventBus","components"];let zx=class extends Ds{constructor(e,t){super(e,t),qx(this,"onGlobalMouseDown",(e=>{this.checkClose(e.target)})),qx(this,"onGlobalKey",(e=>{var t=e.which;13!==t&&27!==t||(e.stopPropagation(),e.preventDefault(),this.close())})),qx(this,"onFocusChanged",(e=>{this.checkClose(e.target)})),qx(this,"setNode",(e=>{this.node=e;const{autoFocus:t}=this.props;var n;e&&(this.updatePosition(),t&&(n=Zt(Hx,e))&&(n.focus(),n.selectionStart&&"text"===n.type?n.selectionStart=1e5:"contentEditable"in n&&jx(n,{start:1e5,end:1e5})))})),av(this)}close(){const{onClose:e}=this.props;l(e)&&e()}checkClose(e){const{autoClose:t}=this.props;if(t){var n=this.node;n&&n!==e&&(n.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(){const{position:e,offset:t}=this.props,{node:n}=this,i=n.getBoundingClientRect();e.width||(e.width=0),e.height||(e.height=0);const o=this.renderer.getContainer().getBoundingClientRect();o.width>o.height?(this.node.classList.add("horizontal"),this.node.classList.remove("vertical")):(this.node.classList.add("vertical"),this.node.classList.remove("horizontal"));const{scrollLeft:r,scrollTop:s}=function(e){const t=Bt(e,".tjs-container");if(!t)return{scrollTop:0,scrollLeft:0};const{scrollLeft:n,scrollTop:i}=t;return{scrollTop:i,scrollLeft:n}}(n),a={};let l,c,u;e.align&&(l=e.align.split("-"));"left"===(l&&l[1]||(e.x+e.width/2>o.width/2?"left":"right"))?(c=e.x-o.left-i.width+t.x+r,n.classList.remove("right"),n.classList.add("left")):(c=-o.left+e.x+e.width-t.x+r,n.classList.remove("left"),n.classList.add("right")),c=l?c:Qx(c,0+r,o.width-i.width+r),a.left=c+"px";"top"===(l&&l[0]||(e.y+e.height/2>o.height/2?"top":"bottom"))?(u=e.y-o.top-i.height+t.y+s,n.classList.remove("bottom"),n.classList.add("top")):(u=-o.top+e.y-t.y+s,n.classList.remove("top"),n.classList.add("bottom")),u=l?u:Qx(u,0+s,o.height-i.height+s),a.top=u+"px",a.overflowY="auto",a.maxHeight=o.height-u+s+"px",M(this.node.style,Vx,a)}render(){const{context:e,components:t,className:n}=this.props;return vr(1,"div",n,t.map(((t,n)=>yr(2,t,{context:e},n))),0,{onContextMenu:e=>e.preventDefault()},null,this.setNode)}};function Qx(e,t,n){return Math.max(t,Math.min(n,e))}zx.$inject=["renderer"];const Hx="\n input[type=text],\n input[type=number],\n input[type=button],\n input[type=submit],\n [contenteditable],\n [tabindex],\n a[href],\n textarea,\n button\n";let Wx=class{constructor(e,t,n){this._eventBus=t,e.onGetComponent("table.before",(()=>Fx))}open(e,t){this._eventBus.fire("contextMenu.open",{position:e,context:t})}close(){this._eventBus.fire("contextMenu.close")}};Wx.$inject=["components","eventBus","renderer"];var Ux={__init__:["contextMenu"],contextMenu:["type",Wx]};function Xx(e){return!e.altKey&&(e.ctrlKey||e.metaKey)}function Kx(e){return e.shiftKey}class Gx{constructor(e,t,n,i,o,r,s){this._clipboard=n,this._cellSelection=i,this._elementRegistry=o,this._editorActions=r,this._keyboard=e.get("keyboard",!1),this._renderer=s,this._keyboard&&(t.on("keyboard.init",this._registerBindings),t.on("keyboard.bind",(()=>{zt.bind(document,"copy",this._clearClipboard,!0),zt.bind(document,"cut",this._clearClipboard,!0)})),t.on("keyboard.unbind",(()=>{zt.unbind(document,"copy",this._clearClipboard,!0),zt.unbind(document,"cut",this._clearClipboard,!0)})))}_clearClipboard=()=>{this._clipboard.clear()};_getSelectedCell(){const e=this._cellSelection.getCellSelection();if(!e)return;const t=this._elementRegistry.get(e);if(!t)return;const n=My(e,this._renderer.getContainer()),i=Py(n);if(document.activeElement!==i)return;const o=wy(n);return o&&o.start!==o.end?void 0:t}_registerBindings=()=>{[(e,t)=>{if(Xx(t)&&67===e){const e=this._getSelectedCell();if(!e)return;return Kx(t)?this._editorActions.trigger("copy",{element:e.col}):this._editorActions.trigger("copy",{element:e.row}),!0}},(e,t)=>{if(Xx(t)&&88===e){const e=this._getSelectedCell();if(!e)return;return Kx(t)?this._editorActions.trigger("cut",{element:e.col}):this._editorActions.trigger("cut",{element:e.row}),!0}},(e,t)=>{let n;if(Xx(t)&&86===e){const e=this._getSelectedCell();if(!e)return;Kx(t)?(n=this._editorActions.trigger("pasteAfter",{element:e.col}),n&&this._cellSelection.selectCell("right")):(n=this._editorActions.trigger("pasteAfter",{element:e.row}),n&&this._cellSelection.selectCell("below"))}return void 0!==n}].forEach((e=>{this._keyboard.addListener(e)}))}}Gx.$inject=["injector","eventBus","clipboard","cellSelection","elementRegistry","editorActions","renderer"];var Yx={__depends__:[By,jy],__init__:["copyCutPasteKeyBindings"],copyCutPasteKeyBindings:["type",Gx]};class Zx extends Ds{constructor(e,t){super(e,t),av(this)}onClick=e=>{this.editorActions.trigger("addInput")};render(){return vr(1,"th","input-cell create-inputs header actionable",[this.translate("Input"),xr(" "),vr(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")})}}Zx.$inject=["editorActions","translate"];class Jx extends Ds{constructor(e,t){super(e,t),av(this)}onClick=e=>{this.editorActions.trigger("addInput")};render(){return vr(1,"td","input-cell create-inputs",xr("-"),2,{onClick:this.onClick,title:this.translate("Add input")})}}Jx.$inject=["editorActions","translate"];class eb{constructor(e,t){e.onGetComponent("cell",500,(({cellType:e})=>{const{businessObject:n}=t.getRoot();if(!n.input||!n.input.length)return"before-label-cells"===e?Zx:"before-rule-cells"===e?Jx:void 0}))}}eb.$inject=["components","sheet"];var tb={__depends__:[ax],__init__:["createInputsProvider"],createInputsProvider:["type",eb]};const nb=["string","boolean","number","date","time","dateTime","dayTimeDuration","yearMonthDuration","Any"];class ib{constructor(e){this._dataTypes=e||nb}getAll(){return this._dataTypes}}ib.$inject=["config.dataTypes"];var ob={__init__:["dataTypes"],dataTypes:["type",ib]};class rb{constructor(e,t,n,i,o,r,s,a,l,c,u){this._contextMenu=t,this._clipboard=n,this._editorActions=i,this._elementRegistry=r,this._eventBus=o,this._modeling=s,this._selection=a,this._sheet=l,this._rules=c,this._translate=u,this._getEntries=this._getEntries.bind(this),e.onGetComponent("context-menu",((t={})=>{if(t.contextMenuType&&"context-menu"===t.contextMenuType){const n=this._getEntries(t),i=function(e){return e instanceof Vm}(this._elementRegistry.get(t.id))&&e.getComponents("context-menu-cell-additional",t);if(i&&i.length){const e=vr(1,"div","context-menu-group context-menu-group-cell",i,0,{role:"presentation"});n.push(e)}return()=>vr(1,"div","context-menu-flex",n,0,{tabIndex:0,role:"menu","aria-label":"Decision table context menu"})}})),o.on("cell.contextmenu",(({event:e,id:n,node:i})=>{e.preventDefault(),t.open({x:e.pageX,y:e.pageY},{contextMenuType:"context-menu",event:e,id:n})}))}_getEntries(e){const t=t=>{const n=t.cells.map((e=>e.id)).indexOf(e.id),i=this._editorActions.trigger("addRuleAbove",{rule:t});i.cells[n]?this._selection.select(i.cells[n]):this._selection.select(i.cells[0]),this._contextMenu.close()},n=t=>{const n=t.cells.map((e=>e.id)).indexOf(e.id),i=this._editorActions.trigger("addRuleBelow",{rule:t});i.cells[n]?this._selection.select(i.cells[n]):this._selection.select(i.cells[0]),this._contextMenu.close()},i=e=>{this._editorActions.trigger("removeRule",{rule:e}),this._contextMenu.close()},o=e=>{this._editorActions.trigger("addInputLeft",{input:e}),this._contextMenu.close()},r=e=>{this._editorActions.trigger("addInputRight",{input:e}),this._contextMenu.close()},s=e=>{this._editorActions.trigger("removeInput",{input:e}),this._contextMenu.close()},a=e=>{this._editorActions.trigger("addOutputLeft",{output:e}),this._contextMenu.close()},l=e=>{this._editorActions.trigger("addOutputRight",{output:e}),this._contextMenu.close()},c=e=>{this._editorActions.trigger("removeOutput",{output:e}),this._contextMenu.close()},u=e=>{this._editorActions.trigger("copy",{element:e}),this._contextMenu.close()},h=e=>{this._editorActions.trigger("cut",{element:e}),this._contextMenu.close()},d=e=>{this._editorActions.trigger("pasteBefore",{element:e}),this._contextMenu.close()},p=e=>{this._editorActions.trigger("pasteAfter",{element:e}),this._contextMenu.close()},f=e&&e.id;if(!f)return null;const g=this._elementRegistry.get(f);if(!g)return null;const m=this._clipboard.get()||{},v=[],y=g.row||g;if(hn(y,"dmn:DecisionRule")){const e=this._rules.allowed("paste",{data:m.elements,target:y});v.push(vr(1,"div","context-menu-group",[vr(1,"div","context-menu-group-entry context-menu-entry-copy-rule",this._translate("Copy rule"),0,{onClick:()=>u(y),tabIndex:"-1",role:"menuitem"}),vr(1,"div","context-menu-group-entry context-menu-entry-cut-rule",this._translate("Cut rule"),0,{onClick:()=>h(y),tabIndex:"-1",role:"menuitem"}),vr(1,"div",`context-menu-group-entry ${e?"":"disabled"} context-menu-entry-paste-rule-above`,this._translate("Paste rule above"),0,{onClick:()=>d(y),tabIndex:"-1",role:"menuitem","aria-disabled":!e}),vr(1,"div",`context-menu-group-entry ${e?"":"disabled"} context-menu-entry-paste-rule-below`,this._translate("Paste rule below"),0,{onClick:()=>p(y),tabIndex:"-1",role:"menuitem","aria-disabled":!e})],4,{role:"presentation"}),vr(1,"div","context-menu-group",[vr(1,"div","context-menu-group-entry context-menu-entry-add-rule-above",this._translate("Add rule above"),0,{onClick:()=>t(y),tabIndex:"-1",role:"menuitem"}),vr(1,"div","context-menu-group-entry context-menu-entry-add-rule-below",this._translate("Add rule below"),0,{onClick:()=>n(y),tabIndex:"-1",role:"menuitem"}),vr(1,"div","context-menu-group-entry context-menu-entry-remove-rule",this._translate("Remove rule"),0,{onClick:()=>i(y),tabIndex:"-1",role:"menuitem"})],4,{role:"presentation"}))}else if(hn(g,"dmn:InputClause")){const e=hn(g,"dmn:InputClause")?g:g.col,t=this._rules.allowed("col.remove",{col:g.col||g}),n=this._rules.allowed("paste",{data:m.elements,target:g.col||g});v.push(vr(1,"div","context-menu-group",[vr(1,"div","context-menu-group-entry context-menu-entry-copy-input",this._translate("Copy input column"),0,{onClick:()=>u(e),tabIndex:"-1",role:"menuitem"}),vr(1,"div",`context-menu-group-entry ${t?"":"disabled"} context-menu-entry-cut-input`,this._translate("Cut input column"),0,{onClick:()=>h(e),tabIndex:"-1",role:"menuitem","aria-disabled":!t}),vr(1,"div",`context-menu-group-entry ${n?"":"disabled"} context-menu-entry-paste-input-left`,this._translate("Paste input column left"),0,{onClick:()=>d(e),tabIndex:"-1",role:"menuitem","aria-disabled":!n}),vr(1,"div",`context-menu-group-entry ${n?"":"disabled"} context-menu-entry-paste-input-right`,this._translate("Paste input column right"),0,{onClick:()=>p(e),tabIndex:"-1",role:"menuitem","aria-disabled":!n})],4,{role:"presentation"}),vr(1,"div","context-menu-group",[vr(1,"div","context-menu-group-entry context-menu-entry-add-input-left",this._translate("Add input column left"),0,{onClick:()=>o(e),tabIndex:"-1",role:"menuitem"}),vr(1,"div","context-menu-group-entry context-menu-entry-add-input-right",this._translate("Add input column right"),0,{onClick:()=>r(e),tabIndex:"-1",role:"menuitem"}),vr(1,"div",`context-menu-group-entry ${t?"":"disabled"} context-menu-entry-remove-input`,this._translate("Remove input column"),0,{onClick:()=>s(e),tabIndex:"-1",role:"menuitem","aria-disabled":!t})],4,{role:"presentation"}))}else if(hn(g,"dmn:OutputClause")||hn(g.col,"dmn:OutputClause")){const e=hn(g,"dmn:OutputClause")?g:g.col,t=this._rules.allowed("col.remove",{col:g.col||g}),n=this._rules.allowed("paste",{data:m.elements,target:g.col||g});v.push(vr(1,"div","context-menu-group",[vr(1,"div","context-menu-group-entry context-menu-entry-copy-output",this._translate("Copy output column"),0,{onClick:()=>u(e),tabIndex:"-1",role:"menuitem"}),vr(1,"div",`context-menu-group-entry ${t?"":"disabled"} context-menu-entry-cut-output`,this._translate("Cut output column"),0,{onClick:()=>h(e),tabIndex:"-1",role:"menuitem","aria-disabled":!t}),vr(1,"div",`context-menu-group-entry ${n?"":"disabled"} context-menu-entry-paste-output-left`,this._translate("Paste output column left"),0,{onClick:()=>d(e),tabIndex:"-1",role:"menuitem","aria-disabled":!n}),vr(1,"div",`context-menu-group-entry ${n?"":"disabled"} context-menu-entry-paste-output-right`,this._translate("Paste output column right"),0,{onClick:()=>p(e),tabIndex:"-1",role:"menuitem","aria-disabled":!n})],4,{role:"presentation"}),vr(1,"div","context-menu-group",[vr(1,"div","context-menu-group-entry context-menu-entry-add-output-left",this._translate("Add output column left"),0,{onClick:()=>a(e),tabIndex:"-1",role:"menuitem"}),vr(1,"div","context-menu-group-entry context-menu-entry-add-output-right",this._translate("Add output column right"),0,{onClick:()=>l(e),tabIndex:"-1",role:"menuitem"}),vr(1,"div",`context-menu-group-entry ${t?"":"disabled"} context-menu-entry-remove-output`,this._translate("Remove output column"),0,{onClick:()=>c(e),tabIndex:"-1",role:"menuitem","aria-disabled":!t})],4,{role:"presentation"}))}return v}}rb.$inject=["components","contextMenu","clipboard","editorActions","eventBus","elementRegistry","modeling","selection","sheet","rules","translate"];const sb=["row.add","row.remove","col.add","col.remove"];class ab{constructor(e,t){t.on("commandStack.executed",(({command:t})=>{-1!==sb.indexOf(t)&&e.close()})),t.on("commandStack.reverted",(()=>{e.close()}))}}ab.$inject=["contextMenu","eventBus"];class lb{constructor(e){e.on("contextMenu.open",(()=>this.addEventListeners())),e.on("contextMenu.close",(()=>this.removeEventListeners())),e.on("commandStack.executed",(()=>this.removeEventListeners()))}addEventListeners=()=>{document.addEventListener("keydown",this.handleKeyEvent),document.addEventListener("mouseover",this.handleMouseOver)};removeEventListeners=()=>{document.removeEventListener("keydown",this.handleKeyEvent),document.removeEventListener("mouseover",this.handleMouseOver)};handleKeyEvent=e=>{"ArrowUp"===e.key?(e.preventDefault(),this.move(e.target,-1)):"ArrowDown"===e.key?(e.preventDefault(),this.move(e.target,1)):"Enter"===e.key&&(e.preventDefault(),this.clickCurrentEntry())};handleMouseOver=()=>{this.getEntries().forEach((e=>{return(t=e).style.removeProperty("background-color"),void t.style.removeProperty("pointer-events");var t}));const{focused:e}=this.getActiveEntries(document);e&&$t(e).remove("focused")};getEntries=()=>Array.from(Jt(".context-menu-group-entry")).filter((e=>!$t(e).has("disabled")));getActiveEntries=e=>{const t=Zt(".context-menu-group-entry:hover",e),n=Zt(".context-menu-group-entry.focused",e);return{hover:t,focused:n,current:n||t}};move=(e,t)=>{const n=this.getEntries(),{current:i,hover:o}=this.getActiveEntries(e);if(!i){return void $t(n[0]).add("focused")}const r=n.indexOf(i)+t;let s=n[r];var a;r<0&&(s=n[n.length-1]),r>=n.length&&(s=n[0]),o&&((a=o).style.setProperty("pointer-events","none"),a.style.setProperty("background-color","transparent")),$t(i).remove("focused"),$t(s).add("focused"),s.style.removeProperty("background-color")};clickCurrentEntry=()=>{const{current:e}=this.getActiveEntries(document);e&&e.click()}}lb.$inject=["eventBus"];var cb={__depends__:[ax,Ux,qy],__init__:["decisionTableContextMenu","contextMenuCloseBehavior","contextMenuKeyboard"],decisionTableContextMenu:["type",rb],contextMenuCloseBehavior:["type",ab],contextMenuKeyboard:["type",lb]};class ub extends Ds{constructor(e,t){super(e,t),cv(this,pv),this._translate=t.injector.get("translate")}onClick=e=>{const{output:t}=this.props;this._eventBus.fire("output.edit",{event:e,output:t})};onContextmenu=e=>{const{id:t}=this.props.output;this._eventBus.fire("cell.contextmenu",{event:e,id:t})};onElementsChanged=()=>{this.forceUpdate()};componentWillMount(){const{injector:e}=this.context;this._changeSupport=this.context.changeSupport,this._eventBus=e.get("eventBus"),this._elementRegistry=e.get("elementRegistry");const{output:t}=this.props;this._changeSupport.onElementsChanged(t.id,this.onElementsChanged)}componentWillUnmount(){const{output:e}=this.props;this._changeSupport.offElementsChanged(e.id,this.onElementsChanged)}render(){const{output:e,index:t,outputsLength:n}=this.props,{label:i,name:o,outputValues:r,typeRef:s}=e,a=e.width?e.width+"px":"192px";return vr(1,"th","output-cell output-editor",[this.slotFills({type:"cell-inner",context:{cellType:"output-cell",col:this._elementRegistry.get(e.id),index:t,outputsLength:n},col:e}),vr(1,"div","clause",0===t?this._translate("Then"):this._translate("And"),0),i?vr(1,"div","output-label",i,0,{title:this._translate("Output label: ")+i}):vr(1,"div","output-name",o,0,{title:this._translate("Output name: ")+o}),vr(1,"div","output-variable",r&&r.text||this._translate(s||""),0,{title:r&&r.text?this._translate("Output values"):this._translate("Output type")})],0,{"data-col-id":e.id,onDblClick:this.onClick,onContextMenu:this.onContextmenu,style:{width:a}})}}class hb extends Ds{constructor(e,t){super(e,t),this.state={value:e.value}}onInput=e=>{const{onInput:t}=this.props,n=e.target.value;this.setState({value:n},(()=>{"function"==typeof t&&t(n)}))};onChange=e=>{const{onChange:t}=this.props;"function"==typeof t&&t(e.target.value)};onKeyDown=e=>{const{onKeyDown:t}=this.props;"function"==typeof t&&t(e)};onKeyUp=e=>{const{onKeyUp:t}=this.props;"function"==typeof t&&t(e)};componentDidUpdate(e){const{value:t}=this.props;t!==e.value&&t!==this.state.value&&this.setState({value:t})}render(){const{className:e,label:t,id:n,placeholder:i,type:o}=this.props,{value:r}=this.state;return vr(64,"input",[e||"","dms-input"].join(" "),null,1,{"aria-label":t,placeholder:i||"",onChange:this.onChange,onInput:this.onInput,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp,spellCheck:"false",type:o||"text",value:r,id:n})}}class db extends Ds{constructor(e,t){super(e,t),this.translate=t.injector?t.injector.get("translate"):pb,this.setName=e=>{e=e||void 0,this.handleChange({name:e})},this.setLabel=e=>{e=e||void 0,this.handleChange({label:e})}}handleChange(e){var{onChange:t}=this.props;"function"==typeof t&&t(e)}render(){const{name:e,label:t}=this.props;return vr(1,"div","context-menu-container ref-output-editor output-edit",[vr(1,"div","dms-form-control",yr(2,gx,{label:this.translate("Output label"),className:"dms-output-label",value:t||"",placeholder:this.translate("Output"),singleLine:!0,onInput:this.setLabel}),2),vr(1,"div","dms-form-control",[vr(1,"label","dms-label",this.translate("Output name"),0),yr(2,hb,{label:this.translate("Output name"),className:"ref-output-name",value:e||"",onInput:this.setName})],4)],4)}}function pb(e){return e}class fb extends Ds{constructor(e,t){super(e,t),this.state={},av(this),this.persistChanges=this.debounceInput(this.persistChanges)}persistChanges=()=>{const{output:e}=this.props.context,{unsaved:t}=this.state;t&&(this.modeling.updateProperties(e,t),this.setState({unsaved:!1}))};handleChange=e=>{this.setState({unsaved:{...this.state.unsaved,...e}},this.persistChanges)};getValue(e){const{output:t}=this.props.context,{unsaved:n}=this.state;return n&&e in n?n[e]:t.get(e)}render(){return yr(2,db,{name:this.getValue("name"),label:this.getValue("label"),onChange:this.handleChange})}}fb.$inject=["debounceInput","modeling"];class gb extends Ds{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._eventBus=t.injector.get("eventBus")}onClick=e=>{const{col:t}=this.props;this._eventBus.fire("output.edit",{event:e,output:t})};render(){return vr(1,"button","edit-button dmn-icon-edit",null,1,{"aria-label":this._translate("Edit output"),type:"button",onClick:this.onClick})}}class mb{constructor(e,t,n,i){e.onGetComponent("cell",(({cellType:e})=>{if("output-header"===e)return ub})),e.onGetComponent("context-menu",((e={})=>{if("output-edit"===e.contextMenuType)return fb})),e.onGetComponent("cell-inner",((e={})=>{const{cellType:t}=e;if("output-cell"===t)return gb})),n.on("output.edit",(({event:e,output:n})=>{const{target:i}=e,o=Bt(i,"th",!0),{left:r,top:s}=o.getBoundingClientRect(),a=function(e){if(!Yt(e,".output-cell + .output-cell"))return{x:-1,y:0}}(o);t.open({x:r,y:s,align:"bottom-right"},{contextMenuType:"output-edit",output:n,offset:a})}))}}mb.$inject=["components","contextMenu","eventBus","renderer"];class vb extends Ds{constructor(e,t){super(e,t),cv(this,pv),this._translate=t.injector.get("translate")}onClick=e=>{const{input:t}=this.props;this._eventBus.fire("input.edit",{event:e,input:t})};onContextmenu=e=>{const{id:t}=this.props.input;this._eventBus.fire("cell.contextmenu",{event:e,id:t})};onElementsChanged=()=>{this.forceUpdate()};componentWillMount(){const{injector:e}=this.context;this._changeSupport=this.context.changeSupport,this._sheet=e.get("sheet"),this._eventBus=e.get("eventBus"),this._elementRegistry=e.get("elementRegistry");const t=this._sheet.getRoot(),{input:n}=this.props;this._changeSupport.onElementsChanged(t.id,this.onElementsChanged),this._changeSupport.onElementsChanged(n.id,this.onElementsChanged)}componentWillUnmount(){const e=this._sheet.getRoot(),{input:t}=this.props;this._changeSupport.offElementsChanged(e.id,this.onElementsChanged),this._changeSupport.offElementsChanged(t.id,this.onElementsChanged)}render(){const{input:e,index:t,inputsLength:n}=this.props,{inputExpression:i,inputValues:o}=e,r=e.get("label"),s=e.width?e.width+"px":"192px";return vr(1,"th","input-cell input-editor",[this.slotFills({type:"cell-inner",context:{cellType:"input-cell",col:this._elementRegistry.get(e.id),index:t,inputsLength:n},col:e}),vr(1,"div","clause",0===t?this._translate("When"):this._translate("And"),0),r?vr(1,"div","input-label",r,0,{title:this._translate("Input label: ")+r}):vr(1,"div","input-expression",i.text,0,{title:this._translate("Input expression: ")+i.text}),vr(1,"div","input-variable",o&&o.text||this._translate(i.typeRef||""),0,{title:o&&o.text?this._translate("Input values"):this._translate("Input type")})],0,{"data-col-id":e.id,onDblClick:this.onClick,onContextMenu:this.onContextmenu,style:{width:s}})}}let yb=[],xb=[];function bb(e){if(e<768)return!1;for(let t=0,n=yb.length;;){let i=t+n>>1;if(e<yb[i])n=i;else{if(!(e>=xb[i]))return!0;t=i+1}if(t==n)return!1}}function _b(e){return e>=127462&&e<=127487}(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((e=>e?parseInt(e,36):1));for(let t=0,n=0;t<e.length;t++)(t%2?xb:yb).push(n+=e[t])})();const wb=8205;function Cb(e,t,n=!0,i=!0){return(n?Ob:kb)(e,t,i)}function Ob(e,t,n){if(t==e.length)return t;t&&Sb(e.charCodeAt(t))&&Rb(e.charCodeAt(t-1))&&t--;let i=Eb(e,t);for(t+=Tb(i);t<e.length;){let o=Eb(e,t);if(i==wb||o==wb||n&&bb(o))t+=Tb(o),i=o;else{if(!_b(o))break;{let n=0,i=t-2;for(;i>=0&&_b(Eb(e,i));)n++,i-=2;if(n%2==0)break;t+=2}}}return t}function kb(e,t,n){for(;t>0;){let i=Ob(e,t-2,n);if(i<t)return i;t--}return 0}function Eb(e,t){let n=e.charCodeAt(t);if(!Rb(n)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return Sb(i)?i-56320+(n-55296<<10)+65536:n}function Sb(e){return e>=56320&&e<57344}function Rb(e){return e>=55296&&e<56320}function Tb(e){return e<65536?1:2}class Mb{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Nb(this,e,t);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(t,this.length,i,1),Pb.from(i,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Nb(this,e,t);let n=[];return this.decompose(e,t,n,0),Pb.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new jb(this),o=new jb(e);for(let e=t,r=t;;){if(i.next(e),o.next(e),e=0,i.lineBreak!=o.lineBreak||i.done!=o.done||i.value!=o.value)return!1;if(r+=i.value.length,i.done||r>=n)return!0}}iter(e=1){return new jb(this,e)}iterRange(e,t=this.length){return new Ib(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Bb(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new Ab(e):Pb.from(Ab.split(e,[])):Mb.empty}}class Ab extends Mb{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,i){for(let o=0;;o++){let r=this.text[o],s=i+r.length;if((t?n:s)>=e)return new Lb(i,s,n,r);i=s+1,n++}}decompose(e,t,n,i){let o=e<=0&&t>=this.length?this:new Ab($b(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&i){let e=n.pop(),t=Db(o.text,e.text.slice(),0,o.length);if(t.length<=32)n.push(new Ab(t,e.length+o.length));else{let e=t.length>>1;n.push(new Ab(t.slice(0,e)),new Ab(t.slice(e)))}}else n.push(o)}replace(e,t,n){if(!(n instanceof Ab))return super.replace(e,t,n);[e,t]=Nb(this,e,t);let i=Db(this.text,Db(n.text,$b(this.text,0,e)),t),o=this.length+n.length-(t-e);return i.length<=32?new Ab(i,o):Pb.from(Ab.split(i,[]),o)}sliceString(e,t=this.length,n="\n"){[e,t]=Nb(this,e,t);let i="";for(let o=0,r=0;o<=t&&r<this.text.length;r++){let s=this.text[r],a=o+s.length;o>e&&r&&(i+=n),e<a&&t>o&&(i+=s.slice(Math.max(0,e-o),t-o)),o=a+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],i=-1;for(let o of e)n.push(o),i+=o.length+1,32==n.length&&(t.push(new Ab(n,i)),n=[],i=-1);return i>-1&&t.push(new Ab(n,i)),t}}class Pb extends Mb{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,i){for(let o=0;;o++){let r=this.children[o],s=i+r.length,a=n+r.lines-1;if((t?a:s)>=e)return r.lineInner(e,t,n,i);i=s+1,n=a+1}}decompose(e,t,n,i){for(let o=0,r=0;r<=t&&o<this.children.length;o++){let s=this.children[o],a=r+s.length;if(e<=a&&t>=r){let o=i&((r<=e?1:0)|(a>=t?2:0));r>=e&&a<=t&&!o?n.push(s):s.decompose(e-r,t-r,n,o)}r=a+1}}replace(e,t,n){if([e,t]=Nb(this,e,t),n.lines<this.lines)for(let i=0,o=0;i<this.children.length;i++){let r=this.children[i],s=o+r.length;if(e>=o&&t<=s){let a=r.replace(e-o,t-o,n),l=this.lines-r.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let o=this.children.slice();return o[i]=a,new Pb(o,this.length-(t-e)+n.length)}return super.replace(o,s,a)}o=s+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=Nb(this,e,t);let i="";for(let o=0,r=0;o<this.children.length&&r<=t;o++){let s=this.children[o],a=r+s.length;r>e&&o&&(i+=n),e<a&&t>r&&(i+=s.sliceString(e-r,t-r,n)),r=a+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Pb))return 0;let n=0,[i,o,r,s]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,o+=t){if(i==r||o==s)return n;let a=this.children[i],l=e.children[o];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce(((e,t)=>e+t.length+1),-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new Ab(n,t)}let i=Math.max(32,n>>5),o=i<<1,r=i>>1,s=[],a=0,l=-1,c=[];function u(e){let t;if(e.lines>o&&e instanceof Pb)for(let t of e.children)u(t);else e.lines>r&&(a>r||!a)?(h(),s.push(e)):e instanceof Ab&&a&&(t=c[c.length-1])instanceof Ab&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new Ab(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>i&&h(),a+=e.lines,l+=e.length+1,c.push(e))}function h(){0!=a&&(s.push(1==c.length?c[0]:Pb.from(c,l)),l=-1,a=c.length=0)}for(let t of e)u(t);return h(),1==s.length?s[0]:new Pb(s,t)}}function Db(e,t,n=0,i=1e9){for(let o=0,r=0,s=!0;r<e.length&&o<=i;r++){let a=e[r],l=o+a.length;l>=n&&(l>i&&(a=a.slice(0,i-o)),o<n&&(a=a.slice(n-o)),s?(t[t.length-1]+=a,s=!1):t.push(a)),o=l+1}return t}function $b(e,t,n){return Db(e,[""],t,n)}Mb.empty=new Ab([""],0);class jb{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof Ab?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],o=this.offsets[n],r=o>>1,s=i instanceof Ab?i.text.length:i.children.length;if(r==(t>0?s:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&o)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(i instanceof Ab){let o=i.text[r+(t<0?-1:0)];if(this.offsets[n]+=t,o.length>Math.max(0,e))return this.value=0==e?o:t>0?o.slice(e):o.slice(0,o.length-e),this;e-=o.length}else{let o=i.children[r+(t<0?-1:0)];e>o.length?(e-=o.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(o),this.offsets.push(t>0?1:(o instanceof Ab?o.text.length:o.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Ib{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new jb(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*t,this.value=i.length<=n?i:t<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class Bb{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:i}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(Mb.prototype[Symbol.iterator]=function(){return this.iter()},jb.prototype[Symbol.iterator]=Ib.prototype[Symbol.iterator]=Bb.prototype[Symbol.iterator]=function(){return this});class Lb{constructor(e,t,n,i){this.from=e,this.to=t,this.number=n,this.text=i}get length(){return this.to-this.from}}function Nb(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function qb(e,t,n=!0,i=!0){return Cb(e,t,n,i)}function Vb(e,t){let n=e.charCodeAt(t);if(!(i=n,i>=55296&&i<56320&&t+1!=e.length))return n;var i;let o=e.charCodeAt(t+1);return function(e){return e>=56320&&e<57344}(o)?o-56320+(n-55296<<10)+65536:n}function Fb(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function zb(e){return e<65536?1:2}const Qb=/\r\n?|\n/;var Hb=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(Hb||(Hb={}));class Wb{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,i=0;t<this.sections.length;){let o=this.sections[t++],r=this.sections[t++];r<0?(e(n,i,o),i+=o):i+=r,n+=o}}iterChangedRanges(e,t=!1){Gb(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];i<0?e.push(n,i):e.push(i,n)}return new Wb(e)}composeDesc(e){return this.empty?e:e.empty?this:Zb(this,e)}mapDesc(e,t=!1){return e.empty?this:Yb(this,e,t)}mapPos(e,t=-1,n=Hb.Simple){let i=0,o=0;for(let r=0;r<this.sections.length;){let s=this.sections[r++],a=this.sections[r++],l=i+s;if(a<0){if(l>e)return o+(e-i);o+=s}else{if(n!=Hb.Simple&&l>=e&&(n==Hb.TrackDel&&i<e&&l>e||n==Hb.TrackBefore&&i<e||n==Hb.TrackAfter&&l>e))return null;if(l>e||l==e&&t<0&&!s)return e==i||t<0?o:o+a;o+=a}i=l}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return o}touchesRange(e,t=e){for(let n=0,i=0;n<this.sections.length&&i<=t;){let o=i+this.sections[n++];if(this.sections[n++]>=0&&i<=t&&o>=e)return!(i<e&&o>t)||"cover";i=o}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];e+=(e?" ":"")+n+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some((e=>"number"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Wb(e)}static create(e){return new Wb(e)}}class Ub extends Wb{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 Gb(this,((t,n,i,o,r)=>e=e.replace(i,i+(n-t),r)),!1),e}mapDesc(e,t=!1){return Yb(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let i=0,o=0;i<t.length;i+=2){let r=t[i],s=t[i+1];if(s>=0){t[i]=s,t[i+1]=r;let a=i>>1;for(;n.length<a;)n.push(Mb.empty);n.push(r?e.slice(o,o+r):Mb.empty)}o+=r}return new Ub(t,n)}compose(e){return this.empty?e:e.empty?this:Zb(this,e,!0)}map(e,t=!1){return e.empty?this:Yb(this,e,t,!0)}iterChanges(e,t=!1){Gb(this,e,t)}get desc(){return Wb.create(this.sections)}filter(e){let t=[],n=[],i=[],o=new Jb(this);e:for(let r=0,s=0;;){let a=r==e.length?1e9:e[r++];for(;s<a||s==a&&0==o.len;){if(o.done)break e;let e=Math.min(o.len,a-s);Xb(i,e,-1);let r=-1==o.ins?-1:0==o.off?o.ins:0;Xb(t,e,r),r>0&&Kb(n,t,o.text),o.forward(e),s+=e}let l=e[r++];for(;s<l;){if(o.done)break e;let e=Math.min(o.len,l-s);Xb(t,e,-1),Xb(i,e,-1==o.ins?-1:0==o.off?o.ins:0),o.forward(e),s+=e}}return{changes:new Ub(t,n),filtered:Wb.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],i=this.sections[t+1];i<0?e.push(n):0==i?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let i=[],o=[],r=0,s=null;function a(e=!1){if(!e&&!i.length)return;r<t&&Xb(i,t-r,-1);let n=new Ub(i,o);s=s?s.compose(n.map(s)):n,i=[],o=[],r=0}return function e(l){if(Array.isArray(l))for(let t of l)e(t);else if(l instanceof Ub){if(l.length!=t)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),s=s?s.compose(l.map(s)):l}else{let{from:e,to:s=e,insert:c}=l;if(e>s||e<0||s>t)throw new RangeError(`Invalid change range ${e} to ${s} (in doc of length ${t})`);let u=c?"string"==typeof c?Mb.of(c.split(n||Qb)):c:Mb.empty,h=u.length;if(e==s&&0==h)return;e<r&&a(),e>r&&Xb(i,e-r,-1),Xb(i,s-e,h),Kb(o,i,u),r=s}}(e),a(!s),s}static empty(e){return new Ub(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let i=0;i<e.length;i++){let o=e[i];if("number"==typeof o)t.push(o,-1);else{if(!Array.isArray(o)||"number"!=typeof o[0]||o.some(((e,t)=>t&&"string"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==o.length)t.push(o[0],0);else{for(;n.length<i;)n.push(Mb.empty);n[i]=Mb.of(o.slice(1)),t.push(o[0],n[i].length)}}}return new Ub(t,n)}static createSet(e,t){return new Ub(e,t)}}function Xb(e,t,n,i=!1){if(0==t&&n<=0)return;let o=e.length-2;o>=0&&n<=0&&n==e[o+1]?e[o]+=t:o>=0&&0==t&&0==e[o]?e[o+1]+=n:i?(e[o]+=t,e[o+1]+=n):e.push(t,n)}function Kb(e,t,n){if(0==n.length)return;let i=t.length-2>>1;if(i<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<i;)e.push(Mb.empty);e.push(n)}}function Gb(e,t,n){let i=e.inserted;for(let o=0,r=0,s=0;s<e.sections.length;){let a=e.sections[s++],l=e.sections[s++];if(l<0)o+=a,r+=a;else{let c=o,u=r,h=Mb.empty;for(;c+=a,u+=l,l&&i&&(h=h.append(i[s-2>>1])),!(n||s==e.sections.length||e.sections[s+1]<0);)a=e.sections[s++],l=e.sections[s++];t(o,c,r,u,h),o=c,r=u}}}function Yb(e,t,n,i=!1){let o=[],r=i?[]:null,s=new Jb(e),a=new Jb(t);for(let e=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(-1==s.ins&&-1==a.ins){let e=Math.min(s.len,a.len);Xb(o,e,-1),s.forward(e),a.forward(e)}else if(a.ins>=0&&(s.ins<0||e==s.i||0==s.off&&(a.len<s.len||a.len==s.len&&!n))){let t=a.len;for(Xb(o,a.ins,-1);t;){let n=Math.min(s.len,t);s.ins>=0&&e<s.i&&s.len<=n&&(Xb(o,0,s.ins),r&&Kb(r,o,s.text),e=s.i),s.forward(n),t-=n}a.next()}else{if(!(s.ins>=0)){if(s.done&&a.done)return r?Ub.createSet(o,r):Wb.create(o);throw new Error("Mismatched change set lengths")}{let t=0,n=s.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else{if(!(0==a.ins&&a.len<n))break;n-=a.len,a.next()}Xb(o,t,e<s.i?s.ins:0),r&&e<s.i&&Kb(r,o,s.text),e=s.i,s.forward(s.len-n)}}}}function Zb(e,t,n=!1){let i=[],o=n?[]:null,r=new Jb(e),s=new Jb(t);for(let e=!1;;){if(r.done&&s.done)return o?Ub.createSet(i,o):Wb.create(i);if(0==r.ins)Xb(i,r.len,0,e),r.next();else if(0!=s.len||s.done){if(r.done||s.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,s.len),n=i.length;if(-1==r.ins){let n=-1==s.ins?-1:s.off?0:s.ins;Xb(i,t,n,e),o&&n&&Kb(o,i,s.text)}else-1==s.ins?(Xb(i,r.off?0:r.len,t,e),o&&Kb(o,i,r.textBit(t))):(Xb(i,r.off?0:r.len,s.off?0:s.ins,e),o&&!s.off&&Kb(o,i,s.text));e=(r.ins>t||s.ins>=0&&s.len>t)&&(e||i.length>n),r.forward2(t),s.forward(t)}}else Xb(i,0,s.ins,e),o&&Kb(o,i,s.text),s.next()}}class Jb{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Mb.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Mb.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class e_{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let n,i;return this.empty?n=i=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new e_(n,i,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return t_.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return t_.range(this.anchor,n)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return t_.range(e.anchor,e.head)}static create(e,t,n){return new e_(e,t,n)}}class t_{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:t_.create(this.ranges.map((n=>n.map(e,t))),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new t_([this.main],0)}addRange(e,t=!0){return t_.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,t_.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((e=>e.toJSON())),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new t_(e.ranges.map((e=>e_.fromJSON(e))),e.main)}static single(e,t=e){return new t_([t_.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;i<e.length;i++){let o=e[i];if(o.empty?o.from<=n:o.from<n)return t_.normalized(e.slice(),t);n=o.to}return new t_(e,t)}static cursor(e,t=0,n,i){return e_.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=i?i:16777215)<<6)}static range(e,t,n,i){let o=(null!=n?n:16777215)<<6|(null==i?7:Math.min(6,i));return t<e?e_.create(t,e,48|o):e_.create(e,t,(t>e?8:0)|o)}static normalized(e,t=0){let n=e[t];e.sort(((e,t)=>e.from-t.from)),t=e.indexOf(n);for(let n=1;n<e.length;n++){let i=e[n],o=e[n-1];if(i.empty?i.from<=o.to:i.from<o.to){let r=o.from,s=Math.max(i.to,o.to);n<=t&&t--,e.splice(--n,2,i.anchor>i.head?t_.range(s,r):t_.range(r,s))}}return new t_(e,t)}}function n_(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let i_=0;class o_{constructor(e,t,n,i,o){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=i,this.id=i_++,this.default=e([]),this.extensions="function"==typeof o?o(this):o}get reader(){return this}static define(e={}){return new o_(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:r_),!!e.static,e.enables)}of(e){return new s_([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new s_(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new s_(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],(n=>t(n.field(e))))}}function r_(e,t){return e==t||e.length==t.length&&e.every(((e,n)=>e===t[n]))}class s_{constructor(e,t,n,i){this.dependencies=e,this.facet=t,this.type=n,this.value=i,this.id=i_++}dynamicSlot(e){var t;let n=this.value,i=this.facet.compareInput,o=this.id,r=e[o]>>1,s=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:1&(null!==(t=e[n.id])&&void 0!==t?t:1)||c.push(e[n.id]);return{create:e=>(e.values[r]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||l_(e,c)){let t=n(e);if(s?!a_(t,e.values[r],i):!i(t,e.values[r]))return e.values[r]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[o];if(null!=l){let o=C_(t,l);if(this.dependencies.every((n=>n instanceof o_?t.facet(n)===e.facet(n):!(n instanceof h_)||t.field(n,!1)==e.field(n,!1)))||(s?a_(a=n(e),o,i):i(a=n(e),o)))return e.values[r]=o,0}else a=n(e);return e.values[r]=a,1}}}}function a_(e,t,n){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}function l_(e,t){let n=!1;for(let i of t)1&w_(e,i)&&(n=!0);return n}function c_(e,t,n){let i=n.map((t=>e[t.id])),o=n.map((e=>e.type)),r=i.filter((e=>!(1&e))),s=e[t.id]>>1;function a(e){let n=[];for(let t=0;t<i.length;t++){let r=C_(e,i[t]);if(2==o[t])for(let e of r)n.push(e);else n.push(r)}return t.combine(n)}return{create(e){for(let t of i)w_(e,t);return e.values[s]=a(e),1},update(e,n){if(!l_(e,r))return 0;let i=a(e);return t.compare(i,e.values[s])?0:(e.values[s]=i,1)},reconfigure(e,o){let r=l_(e,i),l=o.config.facets[t.id],c=o.facet(t);if(l&&!r&&r_(n,l))return e.values[s]=c,0;let u=a(e);return t.compare(u,c)?(e.values[s]=c,0):(e.values[s]=u,1)}}}const u_=o_.define({static:!0});class h_{constructor(e,t,n,i,o){this.id=e,this.createF=t,this.updateF=n,this.compareF=i,this.spec=o,this.provides=void 0}static define(e){let t=new h_(i_++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(u_).find((e=>e.field==this));return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let i=e.values[t],o=this.updateF(i,n);return this.compareF(i,o)?0:(e.values[t]=o,1)},reconfigure:(e,n)=>null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}init(e){return[this,u_.of({field:this,create:e})]}get extension(){return this}}const d_=4,p_=3,f_=2,g_=1;function m_(e){return t=>new y_(t,e)}const v_={highest:m_(0),high:m_(g_),default:m_(f_),low:m_(p_),lowest:m_(d_)};class y_{constructor(e,t){this.inner=e,this.prec=t}}class x_{of(e){return new b_(this,e)}reconfigure(e){return x_.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class b_{constructor(e,t){this.compartment=e,this.inner=t}}class __{constructor(e,t,n,i,o,r){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=i,this.staticValues=o,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let i=[],o=Object.create(null),r=new Map;for(let n of function(e,t,n){let i=[[],[],[],[],[]],o=new Map;function r(e,s){let a=o.get(e);if(null!=a){if(a<=s)return;let t=i[a].indexOf(e);t>-1&&i[a].splice(t,1),e instanceof b_&&n.delete(e.compartment)}if(o.set(e,s),Array.isArray(e))for(let t of e)r(t,s);else if(e instanceof b_){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let i=t.get(e.compartment)||e.inner;n.set(e.compartment,i),r(i,s)}else if(e instanceof y_)r(e.inner,e.prec);else if(e instanceof h_)i[s].push(e),e.provides&&r(e.provides,s);else if(e instanceof s_)i[s].push(e),e.facet.extensions&&r(e.facet.extensions,f_);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(t,s)}}return r(e,f_),i.reduce(((e,t)=>e.concat(t)))}(e,t,r))n instanceof h_?i.push(n):(o[n.facet.id]||(o[n.facet.id]=[])).push(n);let s=Object.create(null),a=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push((t=>e.slot(t)));let c=null==n?void 0:n.config.facets;for(let e in o){let t=o[e],i=t[0].facet,r=c&&c[e]||[];if(t.every((e=>0==e.type)))if(s[i.id]=a.length<<1|1,r_(r,t))a.push(n.facet(i));else{let e=i.combine(t.map((e=>e.value)));a.push(n&&i.compare(e,n.facet(i))?n.facet(i):e)}else{for(let e of t)0==e.type?(s[e.id]=a.length<<1|1,a.push(e.value)):(s[e.id]=l.length<<1,l.push((t=>e.dynamicSlot(t))));s[i.id]=l.length<<1,l.push((e=>c_(e,i,t)))}}let u=l.map((e=>e(s)));return new __(e,r,u,s,a,o)}}function w_(e,t){if(1&t)return 2;let n=t>>1,i=e.status[n];if(4==i)throw new Error("Cyclic dependency between fields and/or facets");if(2&i)return i;e.status[n]=4;let o=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|o}function C_(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const O_=o_.define(),k_=o_.define({combine:e=>e.some((e=>e)),static:!0}),E_=o_.define({combine:e=>e.length?e[0]:void 0,static:!0}),S_=o_.define(),R_=o_.define(),T_=o_.define(),M_=o_.define({combine:e=>!!e.length&&e[0]});class A_{constructor(e,t){this.type=e,this.value=t}static define(){return new P_}}class P_{of(e){return new A_(this,e)}}class D_{constructor(e){this.map=e}of(e){return new $_(this,e)}}class $_{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new $_(this.type,t)}is(e){return this.type==e}static define(e={}){return new D_(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let i of e){let e=i.map(t);e&&n.push(e)}return n}}$_.reconfigure=$_.define(),$_.appendConfig=$_.define();class j_{constructor(e,t,n,i,o,r){this.startState=e,this.changes=t,this.selection=n,this.effects=i,this.annotations=o,this.scrollIntoView=r,this._doc=null,this._state=null,n&&n_(n,t.newLength),o.some((e=>e.type==j_.time))||(this.annotations=o.concat(j_.time.of(Date.now())))}static create(e,t,n,i,o,r){return new j_(e,t,n,i,o,r)}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(j_.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function I_(e,t){let n=[];for(let i=0,o=0;;){let r,s;if(i<e.length&&(o==t.length||t[o]>=e[i]))r=e[i++],s=e[i++];else{if(!(o<t.length))return n;r=t[o++],s=t[o++]}!n.length||n[n.length-1]<r?n.push(r,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function B_(e,t,n){var i;let o,r,s;return n?(o=t.changes,r=Ub.empty(t.changes.length),s=e.changes.compose(t.changes)):(o=t.changes.map(e.changes),r=e.changes.mapDesc(t.changes,!0),s=e.changes.compose(o)),{changes:s,selection:t.selection?t.selection.map(r):null===(i=e.selection)||void 0===i?void 0:i.map(o),effects:$_.mapEffects(e.effects,o).concat($_.mapEffects(t.effects,r)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function L_(e,t,n){let i=t.selection,o=V_(t.annotations);return t.userEvent&&(o=o.concat(j_.userEvent.of(t.userEvent))),{changes:t.changes instanceof Ub?t.changes:Ub.of(t.changes||[],n,e.facet(E_)),selection:i&&(i instanceof t_?i:t_.single(i.anchor,i.head)),effects:V_(t.effects),annotations:o,scrollIntoView:!!t.scrollIntoView}}function N_(e,t,n){let i=L_(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(n=!1);for(let o=1;o<t.length;o++){!1===t[o].filter&&(n=!1);let r=!!t[o].sequential;i=B_(i,L_(e,t[o],r?i.changes.newLength:e.doc.length),r)}let o=j_.create(e,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return function(e){let t=e.startState,n=t.facet(T_),i=e;for(let o=n.length-1;o>=0;o--){let r=n[o](e);r&&Object.keys(r).length&&(i=B_(i,L_(t,r,e.changes.newLength),!0))}return i==e?e:j_.create(t,e.changes,e.selection,i.effects,i.annotations,i.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let i of t.facet(S_)){let t=i(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:I_(n,t))}if(!0!==n){let i,o;if(!1===n)o=e.changes.invertedDesc,i=Ub.empty(t.doc.length);else{let t=e.changes.filter(n);i=t.changes,o=t.filtered.mapDesc(t.changes).invertedDesc}e=j_.create(t,i,e.selection&&e.selection.map(o),$_.mapEffects(e.effects,o),e.annotations,e.scrollIntoView)}let i=t.facet(R_);for(let n=i.length-1;n>=0;n--){let o=i[n](e);e=o instanceof j_?o:Array.isArray(o)&&1==o.length&&o[0]instanceof j_?o[0]:N_(t,V_(o),!1)}return e}(o):o)}j_.time=A_.define(),j_.userEvent=A_.define(),j_.addToHistory=A_.define(),j_.remote=A_.define();const q_=[];function V_(e){return null==e?q_:Array.isArray(e)?e:[e]}var F_=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(F_||(F_={}));const z_=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Q_;try{Q_=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(Ih){}function H_(e){return t=>{if(!/\S/.test(t))return F_.Space;if(function(e){if(Q_)return Q_.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||z_.test(n)))return!0}return!1}(t))return F_.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return F_.Word;return F_.Other}}class W_{constructor(e,t,n,i,o,r){this.config=e,this.doc=t,this.selection=n,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=o,r&&(r._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)w_(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null!=n)return w_(this,n),C_(this,n);if(t)throw new RangeError("Field is not present in this state")}update(...e){return N_(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:i,compartments:o}=n;for(let t of e.effects)t.is(x_.reconfigure)?(n&&(o=new Map,n.compartments.forEach(((e,t)=>o.set(t,e))),n=null),o.set(t.value.compartment,t.value.extension)):t.is($_.reconfigure)?(n=null,i=t.value):t.is($_.appendConfig)&&(n=null,i=V_(i).concat(t.value));if(n)t=e.startState.values.slice();else{n=__.resolve(i,o,this),t=new W_(n,this.doc,this.selection,n.dynamicSlots.map((()=>null)),((e,t)=>t.reconfigure(e,this)),null).values}let r=e.startState.facet(k_)?e.newSelection:e.newSelection.asSingle();new W_(n,e.newDoc,r,t,((t,n)=>n.update(t,e)),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:e},range:t_.cursor(t.from+e.length)})))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),i=this.changes(n.changes),o=[n.range],r=V_(n.effects);for(let n=1;n<t.ranges.length;n++){let s=e(t.ranges[n]),a=this.changes(s.changes),l=a.map(i);for(let e=0;e<n;e++)o[e]=o[e].map(l);let c=i.mapDesc(a,!0);o.push(s.range.map(c)),i=i.compose(l),r=$_.mapEffects(r,l).concat($_.mapEffects(V_(s.effects),c))}return{changes:i,selection:t_.create(o,t.mainIndex),effects:r}}changes(e=[]){return e instanceof Ub?e:Ub.of(e,this.doc.length,this.facet(W_.lineSeparator))}toText(e){return Mb.of(e.split(this.facet(W_.lineSeparator)||Qb))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(w_(this,t),C_(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let i=e[n];i instanceof h_&&null!=this.config.address[i.id]&&(t[n]=i.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(n)for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let o=n[t],r=e[t];i.push(o.init((e=>o.spec.fromJSON(r,e))))}return W_.create({doc:e.doc,selection:t_.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let t=__.resolve(e.extensions||[],new Map),n=e.doc instanceof Mb?e.doc:Mb.of((e.doc||"").split(t.staticFacet(W_.lineSeparator)||Qb)),i=e.selection?e.selection instanceof t_?e.selection:t_.single(e.selection.anchor,e.selection.head):t_.single(0);return n_(i,n.length),t.staticFacet(k_)||(i=i.asSingle()),new W_(t,n,i,t.dynamicSlots.map((()=>null)),((e,t)=>t.create(e)),null)}get tabSize(){return this.facet(W_.tabSize)}get lineBreak(){return this.facet(W_.lineSeparator)||"\n"}get readOnly(){return this.facet(M_)}phrase(e,...t){for(let t of this.facet(W_.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,((e,n)=>{if("$"==n)return"$";let i=+(n||1);return!i||i>t.length?e:t[i-1]}))),e}languageDataAt(e,t,n=-1){let i=[];for(let o of this.facet(O_))for(let r of o(this,t,n))Object.prototype.hasOwnProperty.call(r,e)&&i.push(r[e]);return i}charCategorizer(e){return H_(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:i}=this.doc.lineAt(e),o=this.charCategorizer(e),r=e-n,s=e-n;for(;r>0;){let e=qb(t,r,!1);if(o(t.slice(e,r))!=F_.Word)break;r=e}for(;s<i;){let e=qb(t,s);if(o(t.slice(s,e))!=F_.Word)break;s=e}return r==s?null:t_.range(r+n,s+n)}}function U_(e,t,n={}){let i={};for(let t of e)for(let e of Object.keys(t)){let o=t[e],r=i[e];if(void 0===r)i[e]=o;else if(r===o||void 0===o);else{if(!Object.hasOwnProperty.call(n,e))throw new Error("Config merge conflict for field "+e);i[e]=n[e](r,o)}}for(let e in t)void 0===i[e]&&(i[e]=t[e]);return i}W_.allowMultipleSelections=k_,W_.tabSize=o_.define({combine:e=>e.length?e[0]:4}),W_.lineSeparator=E_,W_.readOnly=M_,W_.phrases=o_.define({compare(e,t){let n=Object.keys(e),i=Object.keys(t);return n.length==i.length&&n.every((n=>e[n]==t[n]))}}),W_.languageData=O_,W_.changeFilter=S_,W_.transactionFilter=R_,W_.transactionExtender=T_,x_.reconfigure=$_.define();class X_{eq(e){return this==e}range(e,t=e){return K_.create(e,t,this)}}X_.prototype.startSide=X_.prototype.endSide=0,X_.prototype.point=!1,X_.prototype.mapMode=Hb.TrackDel;let K_=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,i){return new e(t,n,i)}};function G_(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class Y_{constructor(e,t,n,i){this.from=e,this.to=t,this.value=n,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,i=0){let o=n?this.to:this.from;for(let r=i,s=o.length;;){if(r==s)return r;let i=r+s>>1,a=o[i]-e||(n?this.value[i].endSide:this.value[i].startSide)-t;if(i==r)return a>=0?r:s;a>=0?s=i:r=i+1}}between(e,t,n,i){for(let o=this.findIndex(t,-1e9,!0),r=this.findIndex(n,1e9,!1,o);o<r;o++)if(!1===i(this.from[o]+e,this.to[o]+e,this.value[o]))return!1}map(e,t){let n=[],i=[],o=[],r=-1,s=-1;for(let a=0;a<this.value.length;a++){let l,c,u=this.value[a],h=this.from[a]+e,d=this.to[a]+e;if(h==d){let e=t.mapPos(h,u.startSide,u.mapMode);if(null==e)continue;if(l=c=e,u.startSide!=u.endSide&&(c=t.mapPos(h,u.endSide),c<l))continue}else if(l=t.mapPos(h,u.startSide),c=t.mapPos(d,u.endSide),l>c||l==c&&u.startSide>0&&u.endSide<=0)continue;(c-l||u.endSide-u.startSide)<0||(r<0&&(r=l),u.point&&(s=Math.max(s,c-l)),n.push(u),i.push(l-r),o.push(c-r))}return{mapped:n.length?new Y_(i,o,n,s):null,pos:r}}}class Z_{constructor(e,t,n,i){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=i}static create(e,t,n,i){return new Z_(e,t,n,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:i=0,filterTo:o=this.length}=e,r=e.filter;if(0==t.length&&!r)return this;if(n&&(t=t.slice().sort(G_)),this.isEmpty)return t.length?Z_.of(t):this;let s=new tw(this,null,-1).goto(0),a=0,l=[],c=new J_;for(;s.value||a<t.length;)if(a<t.length&&(s.from-t[a].from||s.startSide-t[a].value.startSide)>=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==s.rangeIndex&&s.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(s.chunkIndex)<t[a].from)&&(!r||i>this.chunkEnd(s.chunkIndex)||o<this.chunkPos[s.chunkIndex])&&c.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!r||i>s.to||o<s.from||r(s.from,s.to,s.value))&&(c.addInner(s.from,s.to,s.value)||l.push(K_.create(s.from,s.to,s.value))),s.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?Z_.empty:this.nextLayer.update({add:l,filter:r,filterFrom:i,filterTo:o}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],i=-1;for(let o=0;o<this.chunk.length;o++){let r=this.chunkPos[o],s=this.chunk[o],a=e.touchesRange(r,r+s.length);if(!1===a)i=Math.max(i,s.maxPoint),t.push(s),n.push(e.mapPos(r));else if(!0===a){let{mapped:o,pos:a}=s.map(r,e);o&&(i=Math.max(i,o.maxPoint),t.push(o),n.push(a))}}let o=this.nextLayer.map(e);return 0==t.length?o:new Z_(n,t,o||Z_.empty,i)}between(e,t,n){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let o=this.chunkPos[i],r=this.chunk[i];if(t>=o&&e<=o+r.length&&!1===r.between(o,e-o,t-o,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return nw.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return nw.from(e).goto(t)}static compare(e,t,n,i,o=-1){let r=e.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=o)),s=t.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=o)),a=ew(r,s,n),l=new ow(r,a,o),c=new ow(s,a,o);n.iterGaps(((e,t,n)=>rw(l,e,c,t,n,i))),n.empty&&0==n.length&&rw(l,0,c,0,0,i)}static eq(e,t,n=0,i){null==i&&(i=999999999);let o=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0)),r=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0));if(o.length!=r.length)return!1;if(!o.length)return!0;let s=ew(o,r),a=new ow(o,s,0).goto(n),l=new ow(r,s,0).goto(n);for(;;){if(a.to!=l.to||!sw(a.active,l.active)||a.point&&(!l.point||!a.point.eq(l.point)))return!1;if(a.to>i)return!0;a.next(),l.next()}}static spans(e,t,n,i,o=-1){let r=new ow(e,null,o).goto(t),s=t,a=r.openStart;for(;;){let e=Math.min(r.to,n);if(r.point){let n=r.activeForPoint(r.to),o=r.pointFrom<t?n.length+1:r.point.startSide<0?n.length:Math.min(n.length,a);i.point(s,e,r.point,n,o,r.pointRank),a=Math.min(r.openEnd(e),n.length)}else e>s&&(i.span(s,e,r.active,a),a=r.openEnd(e));if(r.to>n)return a+(r.point&&r.to>n?1:0);s=r.to,r.next()}}static of(e,t=!1){let n=new J_;for(let i of e instanceof K_?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let i=e[n];if(G_(t,i)>0)return e.slice().sort(G_);t=i}return e}(e):e)n.add(i.from,i.to,i.value);return n.finish()}static join(e){if(!e.length)return Z_.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let i=e[n];i!=Z_.empty;i=i.nextLayer)t=new Z_(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}}Z_.empty=new Z_([],[],null,-1),Z_.empty.nextLayer=Z_.empty;class J_{finishChunk(e){this.chunks.push(new Y_(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new J_)).add(e,t,n)}addInner(e,t,n){let i=e-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(i<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(Z_.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=Z_.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function ew(e,t,n){let i=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&i.set(t.chunk[e],t.chunkPos[e]);let o=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let r=i.get(e.chunk[t]);null==r||(n?n.mapPos(r):r)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(r,r+e.chunk[t].length))||o.add(e.chunk[t])}return o}class tw{constructor(e,t,n,i=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=i}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class nw{constructor(e){this.heap=e}static from(e,t=null,n=-1){let i=[];for(let o=0;o<e.length;o++)for(let r=e[o];!r.isEmpty;r=r.nextLayer)r.maxPoint>=n&&i.push(new tw(r,t,n,o));return 1==i.length?i[0]:new nw(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)iw(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)iw(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),iw(this.heap,0)}}}function iw(e,t){for(let n=e[t];;){let i=1+(t<<1);if(i>=e.length)break;let o=e[i];if(i+1<e.length&&o.compare(e[i+1])>=0&&(o=e[i+1],i++),n.compare(o)<0)break;e[i]=n,e[t]=o,t=i}}class ow{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=nw.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){aw(this.active,e),aw(this.activeTo,e),aw(this.activeRank,e),this.minActive=cw(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:i,rank:o}=this.cursor;for(;t<this.activeRank.length&&(o-this.activeRank[t]||i-this.activeTo[t])>0;)t++;lw(this.active,t,n),lw(this.activeTo,t,i),lw(this.activeRank,t,o),e&&lw(e,t,this.cursor.from),this.minActive=cw(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),n&&aw(n,i)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function rw(e,t,n,i,o,r){e.goto(t),n.goto(i);let s=i+o,a=i,l=i-t;for(;;){let t=e.to+l-n.to,i=t||e.endSide-n.endSide,o=i<0?e.to+l:n.to,c=Math.min(o,s);if(e.point||n.point?e.point&&n.point&&(e.point==n.point||e.point.eq(n.point))&&sw(e.activeForPoint(e.to),n.activeForPoint(n.to))||r.comparePoint(a,c,e.point,n.point):c>a&&!sw(e.active,n.active)&&r.compareRange(a,c,e.active,n.active),o>s)break;(t||e.openEnd!=n.openEnd)&&r.boundChange&&r.boundChange(o),a=o,i<=0&&e.next(),i>=0&&n.next()}}function sw(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!e[n].eq(t[n]))return!1;return!0}function aw(e,t){for(let n=t,i=e.length-1;n<i;n++)e[n]=e[n+1];e.pop()}function lw(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function cw(e,t){let n=-1,i=1e9;for(let o=0;o<t.length;o++)(t[o]-i||e[o].endSide-e[n].endSide)<0&&(n=o,i=t[o]);return n}function uw(e,t,n=e.length){let i=0;for(let o=0;o<n&&o<e.length;)9==e.charCodeAt(o)?(i+=t-i%t,o++):(i++,o=qb(e,o));return i}const hw="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),dw="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),pw="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class fw{constructor(e,t){this.rules=[];let{finish:n}=t||{};function i(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function o(e,t,r,s){let a=[],l=/^@(\w+)\b/.exec(e[0]),c=l&&"keyframes"==l[1];if(l&&null==t)return r.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))o(n.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),s,r);else if(s&&"object"==typeof s){if(!l)throw new RangeError("The value of a property ("+n+") should be a primitive value.");o(i(n),s,a,c)}else null!=s&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+s+";")}(a.length||c)&&r.push((!n||l||s?e:e.map(n)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)o(i(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=pw[hw]||1;return pw[hw]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let i=e[dw],o=n&&n.nonce;i?o&&i.setNonce(o):i=new mw(e,o),i.mount(Array.isArray(t)?t:[t],e)}}let gw=new Map;class mw{constructor(e,t){let n=e.ownerDocument||e,i=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let t=gw.get(n);if(t)return e[dw]=t;this.sheet=new i.CSSStyleSheet,gw.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[dw]=this}mount(e,t){let n=this.sheet,i=0,o=0;for(let t=0;t<e.length;t++){let r=e[t],s=this.modules.indexOf(r);if(s<o&&s>-1&&(this.modules.splice(s,1),o--,s=-1),-1==s){if(this.modules.splice(o++,0,r),n)for(let e=0;e<r.rules.length;e++)n.insertRule(r.rules[e],i++)}else{for(;o<s;)i+=this.modules[o++].rules.length;i+=r.rules.length,o++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var vw={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},yw={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},xw="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),bw="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),_w=0;_w<10;_w++)vw[48+_w]=vw[96+_w]=String(_w);for(_w=1;_w<=24;_w++)vw[_w+111]="F"+_w;for(_w=65;_w<=90;_w++)vw[_w]=String.fromCharCode(_w+32),yw[_w]=String.fromCharCode(_w);for(var ww in vw)yw.hasOwnProperty(ww)||(yw[ww]=vw[ww]);function Cw(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function Ow(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function kw(e,t){if(!t.anchorNode)return!1;try{return Ow(e,t.anchorNode)}catch(e){return!1}}function Ew(e){return 3==e.nodeType?Nw(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function Sw(e,t,n,i){return!!n&&(Mw(e,t,n,i,-1)||Mw(e,t,n,i,1))}function Rw(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function Tw(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function Mw(e,t,n,i,o){for(;;){if(e==n&&t==i)return!0;if(t==(o<0?0:Aw(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=Rw(e)+(o<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(o<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=o<0?Aw(e):0}}}function Aw(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Pw(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function Dw(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function $w(e,t){let n=t.width/e.offsetWidth,i=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.height-e.offsetHeight)<1)&&(i=1),{scaleX:n,scaleY:i}}class jw{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?Aw(t):0),n,Math.min(e.focusOffset,n?Aw(n):0))}set(e,t,n,i){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=i}}let Iw,Bw=null;function Lw(e){if(e.setActive)return e.setActive();if(Bw)return e.focus(Bw);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==Bw?{get preventScroll(){return Bw={preventScroll:!0},!0}}:void 0),!Bw){Bw=!1;for(let e=0;e<t.length;){let n=t[e++],i=t[e++],o=t[e++];n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=o&&(n.scrollLeft=o)}}}function Nw(e,t,n=t){let i=Iw||(Iw=document.createRange());return i.setEnd(e,n),i.setStart(e,t),i}function qw(e,t,n,i){let o={key:t,code:t,keyCode:n,which:n,cancelable:!0};i&&({altKey:o.altKey,ctrlKey:o.ctrlKey,shiftKey:o.shiftKey,metaKey:o.metaKey}=i);let r=new KeyboardEvent("keydown",o);r.synthetic=!0,e.dispatchEvent(r);let s=new KeyboardEvent("keyup",o);return s.synthetic=!0,e.dispatchEvent(s),r.defaultPrevented||s.defaultPrevented}function Vw(e){for(;e.attributes.length;)e.removeAttributeNode(e.attributes[0])}function Fw(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function zw(e,t){for(let n=e,i=t;;){if(3==n.nodeType&&i>0)return{node:n,offset:i};if(1==n.nodeType&&i>0){if("false"==n.contentEditable)return null;n=n.childNodes[i-1],i=Aw(n)}else{if(!n.parentNode||Tw(n))return null;i=Rw(n),n=n.parentNode}}}function Qw(e,t){for(let n=e,i=t;;){if(3==n.nodeType&&i<n.nodeValue.length)return{node:n,offset:i};if(1==n.nodeType&&i<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[i],i=0}else{if(!n.parentNode||Tw(n))return null;i=Rw(n)+1,n=n.parentNode}}}class Hw{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new Hw(e.parentNode,Rw(e),t)}static after(e,t){return new Hw(e.parentNode,Rw(e)+1,t)}}const Ww=[];class Uw{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(2&this.flags){let n,i=this.dom,o=null;for(let r of this.children){if(7&r.flags){if(!r.dom&&(n=o?o.nextSibling:i.firstChild)){let e=Uw.get(n);(!e||!e.parent&&e.canReuseDOM(r))&&r.reuseDOM(n)}r.sync(e,t),r.flags&=-8}if(n=o?o.nextSibling:i.firstChild,t&&!t.written&&t.node==i&&n!=r.dom&&(t.written=!0),r.dom.parentNode==i)for(;n&&n!=r.dom;)n=Xw(n);else i.insertBefore(r.dom,n);o=r.dom}for(n=o?o.nextSibling:i.firstChild,n&&t&&t.node==i&&(t.written=!0);n;)n=Xw(n)}else if(1&this.flags)for(let n of this.children)7&n.flags&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let i=0==Aw(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==this.dom)break;0==i&&t.firstChild!=t.lastChild&&(i=e==t.firstChild?-1:1),e=t}n=i<0?e:e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!Uw.get(n);)n=n.nextSibling;if(!n)return this.length;for(let e=0,t=0;;e++){let i=this.children[e];if(i.dom==n)return t;t+=i.length+i.breakAfter}}domBoundsAround(e,t,n=0){let i=-1,o=-1,r=-1,s=-1;for(let a=0,l=n,c=n;a<this.children.length;a++){let n=this.children[a],u=l+n.length;if(l<e&&u>t)return n.domBoundsAround(e,t,l);if(u>=e&&-1==i&&(i=a,o=l),l>t&&n.dom.parentNode==this.dom){r=a,s=c;break}c=u,l=u+n.breakAfter}return{from:o,to:s<0?n+this.length:s,startDOM:(i?this.children[i-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),1&t.flags)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,7&this.flags&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=Ww){this.markDirty();for(let i=e;i<t;i++){let e=this.children[i];e.parent==this&&n.indexOf(e)<0&&e.destroy()}n.length<250?this.children.splice(e,t-e,...n):this.children=[].concat(this.children.slice(0,e),n,this.children.slice(t));for(let e=0;e<n.length;e++)n[e].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new Kw(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==e?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,i,o,r){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!(8&(this.flags|e.flags))}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}}function Xw(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}Uw.prototype.breakAfter=0;class Kw{constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}function Gw(e,t,n,i,o,r,s,a,l){let{children:c}=e,u=c.length?c[t]:null,h=r.length?r[r.length-1]:null,d=h?h.breakAfter:s;if(!(t==i&&u&&!s&&!d&&r.length<2&&u.merge(n,o,r.length?h:null,0==n,a,l))){if(i<c.length){let e=c[i];e&&(o<e.length||e.breakAfter&&(null==h?void 0:h.breakAfter))?(t==i&&(e=e.split(o),o=0),!d&&h&&e.merge(0,o,h,!0,0,l)?r[r.length-1]=e:((o||e.children.length&&!e.children[0].length)&&e.merge(0,o,null,!1,0,l),r.push(e))):(null==e?void 0:e.breakAfter)&&(h?h.breakAfter=1:s=1),i++}for(u&&(u.breakAfter=s,n>0&&(!s&&r.length&&u.merge(n,u.length,r[0],!1,a,0)?u.breakAfter=r.shift().breakAfter:(n<u.length||u.children.length&&0==u.children[u.children.length-1].length)&&u.merge(n,u.length,null,!1,a,0),t++));t<i&&r.length;)if(c[i-1].become(r[r.length-1]))i--,r.pop(),l=r.length?0:a;else{if(!c[t].become(r[0]))break;t++,r.shift(),a=r.length?0:l}!r.length&&t&&i<c.length&&!c[t-1].breakAfter&&c[i].merge(0,0,c[t-1],!1,a,l)&&t--,(t<i||r.length)&&e.replaceChildren(t,i,r)}}function Yw(e,t,n,i,o,r){let s=e.childCursor(),{i:a,off:l}=s.findPos(n,1),{i:c,off:u}=s.findPos(t,-1),h=t-n;for(let e of i)h+=e.length;e.length+=h,Gw(e,c,u,a,l,i,0,o,r)}let Zw="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Jw="undefined"!=typeof document?document:{documentElement:{style:{}}};const eC=/Edge\/(\d+)/.exec(Zw.userAgent),tC=/MSIE \d/.test(Zw.userAgent),nC=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Zw.userAgent),iC=!!(tC||nC||eC),oC=!iC&&/gecko\/(\d+)/i.test(Zw.userAgent),rC=!iC&&/Chrome\/(\d+)/.exec(Zw.userAgent),sC="webkitFontSmoothing"in Jw.documentElement.style,aC=!iC&&/Apple Computer/.test(Zw.vendor),lC=aC&&(/Mobile\/\w+/.test(Zw.userAgent)||Zw.maxTouchPoints>2);var cC={mac:lC||/Mac/.test(Zw.platform),windows:/Win/.test(Zw.platform),linux:/Linux|X11/.test(Zw.platform),ie:iC,ie_version:tC?Jw.documentMode||6:nC?+nC[1]:eC?+eC[1]:0,gecko:oC,gecko_version:oC?+(/Firefox\/(\d+)/.exec(Zw.userAgent)||[0,0])[1]:0,chrome:!!rC,chrome_version:rC?+rC[1]:0,ios:lC,android:/Android\b/.test(Zw.userAgent),webkit:sC,safari:aC,webkit_version:sC?+(/\bAppleWebKit\/(\d+)/.exec(Zw.userAgent)||[0,0])[1]:0,tabSize:null!=Jw.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class uC extends Uw{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){3==e.nodeType&&this.createDOM(e)}merge(e,t,n){return!(8&this.flags||n&&(!(n instanceof uC)||this.length-(t-e)+n.length>256||8&n.flags))&&(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new uC(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=8&this.flags,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new Hw(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return function(e,t,n){let i=e.nodeValue.length;t>i&&(t=i);let o=t,r=t,s=0;0==t&&n<0||t==i&&n>=0?cC.chrome||cC.gecko||(t?(o--,s=1):r<i&&(r++,s=-1)):n<0?o--:r<i&&r++;let a=Nw(e,o,r).getClientRects();if(!a.length)return null;let l=a[(s?s<0:n>=0)?0:a.length-1];cC.safari&&!s&&0==l.width&&(l=Array.prototype.find.call(a,(e=>e.width))||l);return s?Pw(l,s<0):l||null}(this.dom,e,t)}}class hC extends Uw{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let e of t)e.setParent(this)}setAttrs(e){if(Vw(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!(8&(this.flags|e.flags))}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,i,o,r){return(!n||!(!(n instanceof hC&&n.mark.eq(this.mark))||e&&o<=0||t<this.length&&r<=0))&&(Yw(this,e,t,n?n.children.slice():[],o-1,r-1),this.markDirty(),!0)}split(e){let t=[],n=0,i=-1,o=0;for(let r of this.children){let s=n+r.length;s>e&&t.push(n<e?r.split(e-n):r),i<0&&n>=e&&(i=o),n=s,o++}let r=this.length-e;return this.length=e,i>-1&&(this.children.length=i,this.markDirty()),new hC(this.mark,t,r)}domAtPos(e){return fC(this,e)}coordsAt(e,t){return mC(this,e,t)}}class dC extends Uw{static create(e,t,n){return new dC(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}split(e){let t=dC.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,n,i,o,r){return!(n&&(!(n instanceof dC&&this.widget.compare(n.widget))||e>0&&o<=0||t<this.length&&r<=0))&&(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof dC&&e.side==this.side&&this.widget.constructor==e.widget.constructor&&(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0)}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(0==this.length)return Mb.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,i=this.posAtStart;return n?n.slice(i,i+this.length):Mb.empty}domAtPos(e){return(this.length?0==e:this.side>0)?Hw.before(this.dom):Hw.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let i=this.dom.getClientRects(),o=null;if(!i.length)return null;let r=this.side?this.side<0:e>0;for(let t=r?i.length-1:0;o=i[t],!(e>0?0==t:t==i.length-1||o.top<o.bottom);t+=r?-1:1);return Pw(o,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class pC extends Uw{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof pC&&e.side==this.side}split(){return new pC(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?Hw.before(this.dom):Hw.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Mb.empty}get isHidden(){return!0}}function fC(e,t){let n=e.dom,{children:i}=e,o=0;for(let e=0;o<i.length;o++){let r=i[o],s=e+r.length;if(!(s==e&&r.getSide()<=0)){if(t>e&&t<s&&r.dom.parentNode==n)return r.domAtPos(t-e);if(t<=e)break;e=s}}for(let e=o;e>0;e--){let t=i[e-1];if(t.dom.parentNode==n)return t.domAtPos(t.length)}for(let e=o;e<i.length;e++){let t=i[e];if(t.dom.parentNode==n)return t.domAtPos(0)}return new Hw(n,0)}function gC(e,t,n){let i,{children:o}=e;n>0&&t instanceof hC&&o.length&&(i=o[o.length-1])instanceof hC&&i.mark.eq(t.mark)?gC(i,t.children[0],n-1):(o.push(t),t.setParent(e)),e.length+=t.length}function mC(e,t,n){let i=null,o=-1,r=null,s=-1;!function e(t,a){for(let l=0,c=0;l<t.children.length&&c<=a;l++){let u=t.children[l],h=c+u.length;h>=a&&(u.children.length?e(u,a-c):(!r||r.isHidden&&n>0)&&(h>a||c==h&&u.getSide()>0)?(r=u,s=a-c):(c<a||c==h&&u.getSide()<0&&!u.isHidden)&&(i=u,o=a-c)),c=h}}(e,t);let a=(n<0?i:r)||i||r;return a?a.coordsAt(Math.max(0,a==i?o:s),n):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=Ew(t);return n[n.length-1]||null}(e)}function vC(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}uC.prototype.children=dC.prototype.children=pC.prototype.children=Ww;const yC=Object.create(null);function xC(e,t,n){if(e==t)return!0;e||(e=yC),t||(t=yC);let i=Object.keys(e),o=Object.keys(t);if(i.length-(n&&i.indexOf(n)>-1?1:0)!=o.length-(n&&o.indexOf(n)>-1?1:0))return!1;for(let r of i)if(r!=n&&(-1==o.indexOf(r)||e[r]!==t[r]))return!1;return!0}function bC(e,t,n){let i=!1;if(t)for(let o in t)n&&o in n||(i=!0,"style"==o?e.style.cssText="":e.removeAttribute(o));if(n)for(let o in n)t&&t[o]==n[o]||(i=!0,"style"==o?e.style.cssText=n[o]:e.setAttribute(o,n[o]));return i}function _C(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n];t[i.name]=i.value}return t}class wC{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var CC=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(CC||(CC={}));class OC extends X_{constructor(e,t,n,i){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=i}get heightRelevant(){return!1}static mark(e){return new kC(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new SC(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,i=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:o,end:r}=RC(e,i);t=(o?i?-3e8:-1:5e8)-1,n=1+(r?i?2e8:1:-6e8)}return new SC(e,t,n,i,e.widget||null,!0)}static line(e){return new EC(e)}static set(e,t=!1){return Z_.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}OC.none=Z_.empty;class kC extends OC{constructor(e){let{start:t,end:n}=RC(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof kC&&this.tagName==e.tagName&&(this.class||(null===(t=this.attrs)||void 0===t?void 0:t.class))==(e.class||(null===(n=e.attrs)||void 0===n?void 0:n.class))&&xC(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}kC.prototype.point=!1;class EC extends OC{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof EC&&this.spec.class==e.spec.class&&xC(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)}}EC.prototype.mapMode=Hb.TrackBefore,EC.prototype.point=!0;class SC extends OC{constructor(e,t,n,i,o,r){super(t,n,o,e),this.block=i,this.isReplace=r,this.mapMode=i?t<=0?Hb.TrackBefore:Hb.TrackAfter:Hb.TrackDel}get type(){return this.startSide!=this.endSide?CC.WidgetRange:this.startSide<=0?CC.WidgetBefore:CC.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof SC&&function(e,t){return e==t||!!(e&&t&&e.compare(t))}(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)}}function RC(e,t=!1){let{inclusiveStart:n,inclusiveEnd:i}=e;return null==n&&(n=e.inclusive),null==i&&(i=e.inclusive),{start:null!=n?n:t,end:null!=i?i:t}}function TC(e,t,n,i=0){let o=n.length-1;o>=0&&n[o]+i>=e?n[o]=Math.max(n[o],t):n.push(e,t)}SC.prototype.point=!0;class MC extends Uw{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,i,o,r){if(n){if(!(n instanceof MC))return!1;this.dom||n.transferDOM(this)}return i&&this.setDeco(n?n.attrs:null),Yw(this,e,t,n?n.children.slice():[],o,r),!0}split(e){let t=new MC;if(t.breakAfter=this.breakAfter,0==this.length)return t;let{i:n,off:i}=this.childPos(e);i&&(t.append(this.children[n].split(i),0),this.children[n].merge(i,this.children[n].length,null,!1,0,0),n++);for(let e=n;e<this.children.length;e++)t.append(this.children[e],0);for(;n>0&&0==this.children[n-1].length;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){xC(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){gC(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=vC(t,this.attrs||{})),n&&(this.attrs=vC({class:n},this.attrs||{}))}domAtPos(e){return fC(this,e)}reuseDOM(e){"DIV"==e.nodeName&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?4&this.flags&&(Vw(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(bC(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let i=this.dom.lastChild;for(;i&&Uw.get(i)instanceof hC;)i=i.lastChild;if(!(i&&this.length&&("BR"==i.nodeName||0!=(null===(n=Uw.get(i))||void 0===n?void 0:n.isEditable)||cC.ios&&this.children.some((e=>e instanceof uC))))){let e=document.createElement("BR");e.cmIgnore=!0,this.dom.appendChild(e)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let e,t=0;for(let n of this.children){if(!(n instanceof uC)||/[^ -~]/.test(n.text))return null;let i=Ew(n.dom);if(1!=i.length)return null;t+=i[0].width,e=i[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(e,t){let n=mC(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:e}=this.parent.view.viewState,t=n.bottom-n.top;if(Math.abs(t-e.lineHeight)<2&&e.textHeight<t){let i=(t-e.textHeight)/2;return{top:n.top+i,bottom:n.bottom-i,left:n.left,right:n.left}}}return n}become(e){return e instanceof MC&&0==this.children.length&&0==e.children.length&&xC(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let n=0,i=0;n<e.children.length;n++){let o=e.children[n],r=i+o.length;if(r>=t){if(o instanceof MC)return o;if(r>t)break}i=r+o.breakAfter}return null}}class AC extends Uw{constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,i,o,r){return!(n&&(!(n instanceof AC&&this.widget.compare(n.widget))||e>0&&o<=0||t<this.length&&r<=0))&&(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return 0==e?Hw.before(this.dom):Hw.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new AC(this.widget,t,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return Ww}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Mb.empty}domBoundsAround(){return null}become(e){return e instanceof AC&&e.widget.constructor==this.widget.constructor&&(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);return n||(this.widget instanceof PC?null:Pw(this.dom.getBoundingClientRect(),this.length?0==e:t<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:n}=this.deco;return t!=n&&(e<0?t<0:n>0)}}class PC extends wC{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}}class DC{constructor(e,t,n,i){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=i,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof AC&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new MC),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append($C(new pC(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||e&&this.content.length&&this.content[this.content.length-1]instanceof AC||this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:i}=this.cursor.next(this.skip);if(this.skip=0,i)throw new Error("Ran out of text content when drawing inline views");if(n){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}this.text=t,this.textOff=0}let i=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append($C(new uC(this.text.slice(this.textOff,this.textOff+i)),t),n),this.atCursorPos=!0,this.textOff+=i,e-=i,n=0}}span(e,t,n,i){this.buildText(t-e,n,i),this.pos=t,this.openStart<0&&(this.openStart=i)}point(e,t,n,i,o,r){if(this.disallowBlockEffectsFor[r]&&n instanceof SC){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let s=t-e;if(n instanceof SC)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new AC(n.widget||jC.block,s,n));else{let r=dC.create(n.widget||jC.inline,s,s?0:n.startSide),a=this.atCursorPos&&!r.isEditable&&o<=i.length&&(e<t||n.startSide>0),l=!r.isEditable&&(e<t||o>i.length||n.startSide<=0),c=this.getLine();2!=this.pendingBuffer||a||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(i),a&&(c.append($C(new pC(1),i),o),o=i.length+Math.max(0,o-i.length)),c.append($C(r,i),o),this.atCursorPos=l,this.pendingBuffer=l?e<t||o>i.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=i.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);s&&(this.textOff+s<=this.text.length?this.textOff+=s:(this.skip+=s-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=o)}static build(e,t,n,i,o){let r=new DC(e,t,n,o);return r.openEnd=Z_.spans(i,t,n,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function $C(e,t){for(let n of t)e=new hC(n,[e],e.length);return e}class jC extends wC{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}}jC.inline=new jC("span"),jC.block=new jC("div");var IC=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(IC||(IC={}));const BC=IC.LTR,LC=IC.RTL;function NC(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}const qC=NC("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),VC=NC("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),FC=Object.create(null),zC=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);FC[t]=n,FC[n]=-t}function QC(e){return e<=247?qC[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?VC[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const HC=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class WC{get dir(){return this.level%2?LC:BC}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,i){let o=-1;for(let r=0;r<e.length;r++){let s=e[r];if(s.from<=t&&s.to>=t){if(s.level==n)return r;(o<0||(0!=i?i<0?s.from<t:s.to>t:e[o].level>s.level))&&(o=r)}}if(o<0)throw new RangeError("Index out of range");return o}}function UC(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],o=t[n];if(i.from!=o.from||i.to!=o.to||i.direction!=o.direction||!UC(i.inner,o.inner))return!1}return!0}const XC=[];function KC(e,t,n,i,o,r,s){let a=i%2?2:1;if(i%2==o%2)for(let l=t,c=0;l<n;){let t=!0,u=!1;if(c==r.length||l<r[c].from){let e=XC[l];e!=a&&(t=!1,u=16==e)}let h=t||1!=a?null:[],d=t?i:i+1,p=l;e:for(;;)if(c<r.length&&p==r[c].from){if(u)break e;let f=r[c];if(!t)for(let e=f.to,t=c+1;;){if(e==n)break e;if(!(t<r.length&&r[t].from==e)){if(XC[e]==a)break e;break}e=r[t++].to}if(c++,h)h.push(f);else{f.from>l&&s.push(new WC(l,f.from,d)),GC(e,f.direction==BC!=!(d%2)?i+1:i,o,f.inner,f.from,f.to,s),l=f.to}p=f.to}else{if(p==n||(t?XC[p]!=a:XC[p]==a))break;p++}h?KC(e,l,p,i+1,o,h,s):l<p&&s.push(new WC(l,p,d)),l=p}else for(let l=n,c=r.length;l>t;){let n=!0,u=!1;if(!c||l>r[c-1].to){let e=XC[l-1];e!=a&&(n=!1,u=16==e)}let h=n||1!=a?null:[],d=n?i:i+1,p=l;e:for(;;)if(c&&p==r[c-1].to){if(u)break e;let f=r[--c];if(!n)for(let e=f.from,n=c;;){if(e==t)break e;if(!n||r[n-1].to!=e){if(XC[e-1]==a)break e;break}e=r[--n].from}if(h)h.push(f);else{f.to<l&&s.push(new WC(f.to,l,d)),GC(e,f.direction==BC!=!(d%2)?i+1:i,o,f.inner,f.from,f.to,s),l=f.from}p=f.from}else{if(p==t||(n?XC[p-1]!=a:XC[p-1]==a))break;p--}h?KC(e,p,l,i+1,o,h,s):p<l&&s.push(new WC(p,l,d)),l=p}}function GC(e,t,n,i,o,r,s){let a=t%2?2:1;!function(e,t,n,i,o){for(let r=0;r<=i.length;r++){let s=r?i[r-1].to:t,a=r<i.length?i[r].from:n,l=r?256:o;for(let t=s,n=l,i=l;t<a;t++){let o=QC(e.charCodeAt(t));512==o?o=n:8==o&&4==i&&(o=16),XC[t]=4==o?2:o,7&o&&(i=o),n=o}for(let e=s,t=l,i=l;e<a;e++){let o=XC[e];if(128==o)e<a-1&&t==XC[e+1]&&24&t?o=XC[e]=t:XC[e]=256;else if(64==o){let o=e+1;for(;o<a&&64==XC[o];)o++;let r=e&&8==t||o<n&&8==XC[o]?1==i?1:8:256;for(let t=e;t<o;t++)XC[t]=r;e=o-1}else 8==o&&1==i&&(XC[e]=1);t=o,7&o&&(i=o)}}}(e,o,r,i,a),function(e,t,n,i,o){let r=1==o?2:1;for(let s=0,a=0,l=0;s<=i.length;s++){let c=s?i[s-1].to:t,u=s<i.length?i[s].from:n;for(let t,n,i,s=c;s<u;s++)if(n=FC[t=e.charCodeAt(s)])if(n<0){for(let e=a-3;e>=0;e-=3)if(zC[e+1]==-n){let t=zC[e+2],n=2&t?o:4&t?1&t?r:o:0;n&&(XC[s]=XC[zC[e]]=n),a=e;break}}else{if(189==zC.length)break;zC[a++]=s,zC[a++]=t,zC[a++]=l}else if(2==(i=XC[s])||1==i){let e=i==o;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=zC[t+2];if(2&n)break;if(e)zC[t+2]|=2;else{if(4&n)break;zC[t+2]|=4}}}}}(e,o,r,i,a),function(e,t,n,i){for(let o=0,r=i;o<=n.length;o++){let s=o?n[o-1].to:e,a=o<n.length?n[o].from:t;for(let l=s;l<a;){let s=XC[l];if(256==s){let s=l+1;for(;;)if(s==a){if(o==n.length)break;s=n[o++].to,a=o<n.length?n[o].from:t}else{if(256!=XC[s])break;s++}let c=1==r,u=c==(1==(s<t?XC[s]:i))?c?1:2:i;for(let t=s,i=o,r=i?n[i-1].to:e;t>l;)t==r&&(t=n[--i].from,r=i?n[i-1].to:e),XC[--t]=u;l=s}else r=s,l++}}}(o,r,i,a),KC(e,o,r,t,n,i,s)}function YC(e){return[new WC(0,e,0)]}let ZC="";function JC(e,t,n,i,o){var r;let s=i.head-e.from,a=WC.find(t,s,null!==(r=i.bidiLevel)&&void 0!==r?r:-1,i.assoc),l=t[a],c=l.side(o,n);if(s==c){let e=a+=o?1:-1;if(e<0||e>=t.length)return null;l=t[a=e],s=l.side(!o,n),c=l.side(o,n)}let u=qb(e.text,s,l.forward(o,n));(u<l.from||u>l.to)&&(u=c),ZC=e.text.slice(Math.min(s,u),Math.max(s,u));let h=a==(o?t.length-1:0)?null:t[a+(o?1:-1)];return h&&u==c&&h.level+(o?0:1)<l.level?t_.cursor(h.side(!o,n)+e.from,h.forward(o,n)?1:-1,h.level):t_.cursor(u+e.from,l.forward(o,n)?-1:1,l.level)}function eO(e,t,n){for(let i=t;i<n;i++){let t=QC(e.charCodeAt(i));if(1==t)return BC;if(2==t||4==t)return LC}return BC}const tO=o_.define(),nO=o_.define(),iO=o_.define(),oO=o_.define(),rO=o_.define(),sO=o_.define(),aO=o_.define(),lO=o_.define(),cO=o_.define(),uO=o_.define({combine:e=>e.some((e=>e))}),hO=o_.define({combine:e=>e.some((e=>e))}),dO=o_.define();class pO{constructor(e,t="nearest",n="nearest",i=5,o=5,r=!1){this.range=e,this.y=t,this.x=n,this.yMargin=i,this.xMargin=o,this.isSnapshot=r}map(e){return e.empty?this:new pO(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 pO(t_.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const fO=$_.define({map:(e,t)=>e.map(t)}),gO=$_.define();function mO(e,t,n){let i=e.facet(oO);i.length?i[0](t):window.onerror?window.onerror(String(t),n,void 0,void 0,t):n?console.error(n+":",t):console.error(t)}const vO=o_.define({combine:e=>!e.length||e[0]});let yO=0;const xO=o_.define();class bO{constructor(e,t,n,i,o){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=i,this.extension=o(this)}static define(e,t){const{eventHandlers:n,eventObservers:i,provide:o,decorations:r}=t||{};return new bO(yO++,e,n,i,(e=>{let t=[xO.of(e)];return r&&t.push(OO.of((t=>{let n=t.plugin(e);return n?r(n):OC.none}))),o&&t.push(o(e)),t}))}static fromClass(e,t){return bO.define((t=>new e(t)),t)}}class _O{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(mO(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){mO(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){mO(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const wO=o_.define(),CO=o_.define(),OO=o_.define(),kO=o_.define(),EO=o_.define(),SO=o_.define();function RO(e,t){let n=e.state.facet(SO);if(!n.length)return n;let i=n.map((t=>t instanceof Function?t(e):t)),o=[];return Z_.spans(i,t.from,t.to,{point(){},span(e,n,i,r){let s=e-t.from,a=n-t.from,l=o;for(let e=i.length-1;e>=0;e--,r--){let n,o=i[e].spec.bidiIsolate;if(null==o&&(o=eO(t.text,s,a)),r>0&&l.length&&(n=l[l.length-1]).to==s&&n.direction==o)n.to=a,l=n.inner;else{let e={from:s,to:a,direction:o,inner:[]};l.push(e),l=e.inner}}}}),o}const TO=o_.define();function MO(e){let t=0,n=0,i=0,o=0;for(let r of e.state.facet(TO)){let s=r(e);s&&(null!=s.left&&(t=Math.max(t,s.left)),null!=s.right&&(n=Math.max(n,s.right)),null!=s.top&&(i=Math.max(i,s.top)),null!=s.bottom&&(o=Math.max(o,s.bottom)))}return{left:t,right:n,top:i,bottom:o}}const AO=o_.define();class PO{constructor(e,t,n,i){this.fromA=e,this.toA=t,this.fromB=n,this.toB=i}join(e){return new PO(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let i=e[t-1];if(!(i.fromA>n.toA)){if(i.toA<n.fromA)break;n=n.join(i),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let i=0,o=0,r=0,s=0;;i++){let a=i==e.length?null:e[i],l=r-s,c=a?a.fromB:1e9;for(;o<t.length&&t[o]<c;){let e=t[o],i=t[o+1],r=Math.max(s,e),a=Math.min(c,i);if(r<=a&&new PO(r+l,a+l,r,a).addToSet(n),i>c)break;o+=2}if(!a)return n;new PO(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),r=a.toA,s=a.toB}}}class DO{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=Ub.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let i=[];this.changes.iterChangedRanges(((e,t,n,o)=>i.push(new PO(e,t,n,o)))),this.changedRanges=i}static create(e,t,n){return new DO(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((e=>e.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class $O extends Uw{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=OC.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.setDOM(e.contentDOM),this.children=[new MC],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new PO(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every((({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo))?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?i=this.domChanged.newSel.head:function(e,t){let n=!1;t&&e.iterChangedRanges(((e,i)=>{e<t.to&&i>t.from&&(n=!0)}));return n}(e.changes,this.hasComposition)||e.selectionSet||(i=e.state.selection.main.head));let o=i>-1?function(e,t,n){let i=jO(e,n);if(!i)return null;let{node:o,from:r,to:s}=i,a=o.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(i.from,i.to)!=a)return null;let l=t.invertedDesc,c=new PO(l.mapPos(r),l.mapPos(s),r,s),u=[];for(let t=o.parentNode;;t=t.parentNode){let n=Uw.get(t);if(n instanceof hC)u.push({node:t,deco:n.mark});else{if(n instanceof MC||"DIV"==t.nodeName&&t.parentNode==e.contentDOM)return{range:c,text:o,marks:u,line:t};if(t==e.contentDOM)return null;u.push({node:t,deco:new kC({inclusive:!0,attributes:_C(t),tagName:t.tagName.toLowerCase()})})}}}(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:t,to:i}=this.hasComposition;n=new PO(t,i,e.changes.mapPos(t,-1),e.changes.mapPos(i,1)).addToSet(n.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(cC.ie||cC.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let r=function(e,t,n){let i=new IO;return Z_.compare(e,t,n,i),i.changes}(this.decorations,this.updateDeco(),e.changes);return n=PO.extendWithRanges(n,r),!!(7&this.flags||0!=n.length)&&(this.updateInner(n,e.startState.doc.length,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:i}=this.view;i.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let e=cC.chrome||cC.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,e),this.flags&=-8,e&&(e.written||i.selectionRange.focusNode!=e.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((e=>e.flags&=-9));let o=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.children)e instanceof AC&&e.widget instanceof PC&&o.push(e.dom);i.updateGaps(o)}updateChildren(e,t,n){let i=n?n.range.addToSet(e.slice()):e,o=this.childCursor(t);for(let e=i.length-1;;e--){let t=e>=0?i[e]:null;if(!t)break;let r,s,a,l,{fromA:c,toA:u,fromB:h,toB:d}=t;if(n&&n.range.fromB<d&&n.range.toB>h){let e=DC.build(this.view.state.doc,h,n.range.fromB,this.decorations,this.dynamicDecorationMap),t=DC.build(this.view.state.doc,n.range.toB,d,this.decorations,this.dynamicDecorationMap);s=e.breakAtStart,a=e.openStart,l=t.openEnd;let i=this.compositionView(n);t.breakAtStart?i.breakAfter=1:t.content.length&&i.merge(i.length,i.length,t.content[0],!1,t.openStart,0)&&(i.breakAfter=t.content[0].breakAfter,t.content.shift()),e.content.length&&i.merge(0,0,e.content[e.content.length-1],!0,0,e.openEnd)&&e.content.pop(),r=e.content.concat(i).concat(t.content)}else({content:r,breakAtStart:s,openStart:a,openEnd:l}=DC.build(this.view.state.doc,h,d,this.decorations,this.dynamicDecorationMap));let{i:p,off:f}=o.findPos(u,1),{i:g,off:m}=o.findPos(c,-1);Gw(this,g,m,p,f,r,s,a,l)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(gO)&&(this.editContextFormatting=e.value)}compositionView(e){let t=new uC(e.text.nodeValue);t.flags|=8;for(let{deco:n}of e.marks)t=new hC(n,[t],t.length);let n=new MC;return n.append(t,0),n}fixCompositionDOM(e){let t=(e,t)=>{t.flags|=8|(t.children.some((e=>7&e.flags))?1:0),this.markedForComposition.add(t);let n=Uw.get(e);n&&n!=t&&(n.dom=null),t.setDOM(e)},n=this.childPos(e.range.fromB,1),i=this.children[n.i];t(e.line,i);for(let o=e.marks.length-1;o>=-1;o--)n=i.childPos(n.off,1),i=i.children[n.i],t(o>=0?e.marks[o].node:e.text,i)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let n=this.view.root.activeElement,i=n==this.dom,o=!i&&!(this.view.state.facet(vO)||this.dom.tabIndex>-1)&&kw(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(i||t||o))return;let r=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(s.anchor)),l=s.empty?a:this.moveToLine(this.domAtPos(s.head));if(cC.gecko&&s.empty&&!this.hasComposition&&(1==(c=a).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore((()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null))),a=l=new Hw(e,0),r=!0}var c;let u=this.view.observer.selectionRange;!r&&u.focusNode&&(Sw(a.node,a.offset,u.anchorNode,u.anchorOffset)&&Sw(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,s))||(this.view.observer.ignore((()=>{cC.android&&cC.chrome&&this.dom.contains(u.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let e=Cw(this.view.root);if(e)if(s.empty){if(cC.gecko){let e=function(e,t){return 1!=e.nodeType?0:(t&&"false"==e.childNodes[t-1].contentEditable?1:0)|(t<e.childNodes.length&&"false"==e.childNodes[t].contentEditable?2:0)}(a.node,a.offset);if(e&&3!=e){let t=(1==e?zw:Qw)(a.node,a.offset);t&&(a=new Hw(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=s.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(l.node,l.offset)}catch(e){}}else{let t=document.createRange();s.anchor>s.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}else;o&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())})),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new Hw(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new Hw(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Sw(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Cw(e.root),{anchorNode:i,anchorOffset:o}=e.observer.selectionRange;if(!(n&&t.empty&&t.assoc&&n.modify))return;let r=MC.find(this,t.head);if(!r)return;let s=r.posAtStart;if(t.head==s||t.head==s+r.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(i,o)}moveToLine(e){let t,n=this.dom;if(e.node!=n)return e;for(let i=e.offset;!t&&i<n.childNodes.length;i++){let e=Uw.get(n.childNodes[i]);e instanceof MC&&(t=e.domAtPos(0))}for(let i=e.offset-1;!t&&i>=0;i--){let e=Uw.get(n.childNodes[i]);e instanceof MC&&(t=e.domAtPos(e.length))}return t?new Hw(t.node,t.offset,!0):e}nearest(e){for(let t=e;t;){let e=Uw.get(t);if(e&&e.rootView==this)return e;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let e=this.children[t];if(n<e.length||e instanceof MC)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){let n=null,i=0;for(let o=this.length,r=this.children.length-1;r>=0;r--){let s=this.children[r],a=o-s.breakAfter,l=a-s.length;if(a<e)break;if(l<=e&&(l<e||s.covers(-1))&&(a>e||s.covers(1))&&(!n||s instanceof MC&&!(n instanceof MC&&t>=0)))n=s,i=l;else if(n&&l==e&&a==e&&s instanceof AC&&Math.abs(t)<2){if(s.deco.startSide<0)break;r&&(n=null)}o=l}return n?n.coordsAt(e-i,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),i=this.children[t];if(!(i instanceof MC))return null;for(;i.children.length;){let{i:e,off:t}=i.childPos(n,1);for(;;e++){if(e==i.children.length)return null;if((i=i.children[e]).length)break}n=t}if(!(i instanceof uC))return null;let o=qb(i.text,n);if(o==n)return null;let r=Nw(i.dom,n,o).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}return null}measureVisibleLineHeights(e){let t=[],{from:n,to:i}=e,o=this.view.contentDOM.clientWidth,r=o>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,s=-1,a=this.view.textDirection==IC.LTR;for(let e=0,l=0;l<this.children.length;l++){let c=this.children[l],u=e+c.length;if(u>i)break;if(e>=n){let n=c.dom.getBoundingClientRect();if(t.push(n.height),r){let t=c.dom.lastChild,i=t?Ew(t):[];if(i.length){let t=i[i.length-1],r=a?t.right-n.left:n.right-t.left;r>s&&(s=r,this.minWidth=o,this.minWidthFrom=e,this.minWidthTo=u)}}}e=u+c.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return"rtl"==getComputedStyle(this.children[t].dom).direction?IC.RTL:IC.LTR}measureTextSize(){for(let e of this.children)if(e instanceof MC){let t=e.measureTextSize();if(t)return t}let e,t,n,i=document.createElement("div");return i.className="cm-line",i.style.width="99999px",i.style.position="absolute",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(i);let o=Ew(i.firstChild)[0];e=i.getBoundingClientRect().height,t=o?o.width/27:7,n=o?o.height:e,i.remove()})),{lineHeight:e,charWidth:t,textHeight:n}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Kw(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,i=0;;i++){let o=i==t.viewports.length?null:t.viewports[i],r=o?o.from-1:this.length;if(r>n){let i=(t.lineBlockAt(r).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(OC.replace({widget:new PC(i),block:!0,inclusive:!0,isBlockGap:!0}).range(n,r))}if(!o)break;n=o.to+1}return OC.set(e)}updateDeco(){let e=1,t=this.view.state.facet(OO).map((t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t)),n=!1,i=this.view.state.facet(kO).map(((e,t)=>{let i="function"==typeof e;return i&&(n=!0),i?e(this.view):e}));for(i.length&&(this.dynamicDecorationMap[e++]=n,t.push(Z_.join(i))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(dO))try{if(t(this.view,e.range,e))return!0}catch(e){mO(this.view.state,e,"scroll handler")}let t,{range:n}=e,i=this.coordsAt(n.head,n.empty?n.assoc:n.head>n.anchor?-1:1);if(!i)return;!n.empty&&(t=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(i={left:Math.min(i.left,t.left),top:Math.min(i.top,t.top),right:Math.max(i.right,t.right),bottom:Math.max(i.bottom,t.bottom)});let o=MO(this.view),r={left:i.left-o.left,top:i.top-o.top,right:i.right+o.right,bottom:i.bottom+o.bottom},{offsetWidth:s,offsetHeight:a}=this.view.scrollDOM;!function(e,t,n,i,o,r,s,a){let l=e.ownerDocument,c=l.defaultView||window;for(let u=e,h=!1;u&&!h;)if(1==u.nodeType){let e,d=u==l.body,p=1,f=1;if(d)e=Dw(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(h=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let t=u.getBoundingClientRect();({scaleX:p,scaleY:f}=$w(u,t)),e={left:t.left,right:t.left+u.clientWidth*p,top:t.top,bottom:t.top+u.clientHeight*f}}let g=0,m=0;if("nearest"==o)t.top<e.top?(m=-(e.top-t.top+s),n>0&&t.bottom>e.bottom+m&&(m=t.bottom-e.bottom+m+s)):t.bottom>e.bottom&&(m=t.bottom-e.bottom+s,n<0&&t.top-m<e.top&&(m=-(e.top+m-t.top+s)));else{let i=t.bottom-t.top,r=e.bottom-e.top;m=("center"==o&&i<=r?t.top+i/2-r/2:"start"==o||"center"==o&&n<0?t.top-s:t.bottom-r+s)-e.top}if("nearest"==i?t.left<e.left?(g=-(e.left-t.left+r),n>0&&t.right>e.right+g&&(g=t.right-e.right+g+r)):t.right>e.right&&(g=t.right-e.right+r,n<0&&t.left<e.left+g&&(g=-(e.left+g-t.left+r))):g=("center"==i?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==i==a?t.left-r:t.right-(e.right-e.left)+r)-e.left,g||m)if(d)c.scrollBy(g,m);else{let e=0,n=0;if(m){let e=u.scrollTop;u.scrollTop+=m/f,n=(u.scrollTop-e)*f}if(g){let t=u.scrollLeft;u.scrollLeft+=g/p,e=(u.scrollLeft-t)*p}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-g)<1&&(i="nearest"),n&&Math.abs(n-m)<1&&(o="nearest")}if(d)break;u=u.assignedSlot||u.parentNode}else{if(11!=u.nodeType)break;u=u.host}}(this.view.scrollDOM,r,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,s),-s),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==IC.LTR)}}function jO(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let i=zw(n.focusNode,n.focusOffset),o=Qw(n.focusNode,n.focusOffset),r=i||o;if(o&&i&&o.node!=i.node){let t=Uw.get(o.node);if(!t||t instanceof uC&&t.text!=o.node.nodeValue)r=o;else if(e.docView.lastCompositionAfterCursor){let e=Uw.get(i.node);!e||e instanceof uC&&e.text!=i.node.nodeValue||(r=o)}}if(e.docView.lastCompositionAfterCursor=r!=i,!r)return null;let s=t-r.offset;return{from:s,to:s+r.node.nodeValue.length,node:r.node}}let IO=class{constructor(){this.changes=[]}compareRange(e,t){TC(e,t,this.changes)}comparePoint(e,t){TC(e,t,this.changes)}boundChange(e){TC(e,e,this.changes)}};function BO(e,t){return t.left>e?t.left-e:Math.max(0,e-t.right)}function LO(e,t){return t.top>e?t.top-e:Math.max(0,e-t.bottom)}function NO(e,t){return e.top<t.bottom-1&&e.bottom>t.top+1}function qO(e,t){return t<e.top?{top:t,left:e.left,right:e.right,bottom:e.bottom}:e}function VO(e,t){return t>e.bottom?{top:e.top,left:e.left,right:e.right,bottom:t}:e}function FO(e,t,n){let i,o,r,s,a,l,c,u,h=!1;for(let d=e.firstChild;d;d=d.nextSibling){let e=Ew(d);for(let p=0;p<e.length;p++){let f=e[p];o&&NO(o,f)&&(f=qO(VO(f,o.bottom),o.top));let g=BO(t,f),m=LO(n,f);if(0==g&&0==m)return 3==d.nodeType?zO(d,t,n):FO(d,t,n);if(!i||s>m||s==m&&r>g){i=d,o=f,r=g,s=m;let a=m?n<f.top?-1:1:g?t<f.left?-1:1:0;h=!a||(a>0?p<e.length-1:p>0)}0==g?n>f.bottom&&(!c||c.bottom<f.bottom)?(a=d,c=f):n<f.top&&(!u||u.top>f.top)&&(l=d,u=f):c&&NO(c,f)?c=VO(c,f.bottom):u&&NO(u,f)&&(u=qO(u,f.top))}}if(c&&c.bottom>=n?(i=a,o=c):u&&u.top<=n&&(i=l,o=u),!i)return{node:e,offset:0};let d=Math.max(o.left,Math.min(o.right,t));return 3==i.nodeType?zO(i,d,n):h&&"false"!=i.contentEditable?FO(i,d,n):{node:e,offset:Array.prototype.indexOf.call(e.childNodes,i)+(t>=(o.left+o.right)/2?1:0)}}function zO(e,t,n){let i=e.nodeValue.length,o=-1,r=1e9,s=0;for(let a=0;a<i;a++){let i=Nw(e,a,a+1).getClientRects();for(let l=0;l<i.length;l++){let c=i[l];if(c.top==c.bottom)continue;s||(s=t-c.left);let u=(c.top>n?c.top-n:n-c.bottom)-1;if(c.left-1<=t&&c.right+1>=t&&u<r){let n=t>=(c.left+c.right)/2,i=n;if(cC.chrome||cC.gecko){Nw(e,a).getBoundingClientRect().left==c.right&&(i=!n)}if(u<=0)return{node:e,offset:a+(i?1:0)};o=a+(i?1:0),r=u}}}return{node:e,offset:o>-1?o:s>0?e.nodeValue.length:0}}function QO(e,t,n,i=-1){var o,r;let s,a=e.contentDOM.getBoundingClientRect(),l=a.top+e.viewState.paddingTop,{docHeight:c}=e.viewState,{x:u,y:h}=t,d=h-l;if(d<0)return 0;if(d>c)return e.state.doc.length;for(let t=e.viewState.heightOracle.textHeight/2,o=!1;s=e.elementAtHeight(d),s.type!=CC.Text;)for(;d=i>0?s.bottom+t:s.top-t,!(d>=0&&d<=c);){if(o)return n?null:0;o=!0,i=-i}h=l+d;let p=s.from;if(p<e.viewport.from)return 0==e.viewport.from?0:n?null:HO(e,a,s,u,h);if(p>e.viewport.to)return e.viewport.to==e.state.doc.length?e.state.doc.length:n?null:HO(e,a,s,u,h);let f=e.dom.ownerDocument,g=e.root.elementFromPoint?e.root:f,m=g.elementFromPoint(u,h);m&&!e.contentDOM.contains(m)&&(m=null),m||(u=Math.max(a.left+1,Math.min(a.right-1,u)),m=g.elementFromPoint(u,h),m&&!e.contentDOM.contains(m)&&(m=null));let v,y=-1;if(m&&0!=(null===(o=e.docView.nearest(m))||void 0===o?void 0:o.isEditable)){if(f.caretPositionFromPoint){let e=f.caretPositionFromPoint(u,h);e&&({offsetNode:v,offset:y}=e)}else if(f.caretRangeFromPoint){let t=f.caretRangeFromPoint(u,h);t&&(({startContainer:v,startOffset:y}=t),(!e.contentDOM.contains(v)||cC.safari&&function(e,t,n){let i;if(3!=e.nodeType||t!=(i=e.nodeValue.length))return!1;for(let t=e.nextSibling;t;t=t.nextSibling)if(1!=t.nodeType||"BR"!=t.nodeName)return!1;return Nw(e,i-1,i).getBoundingClientRect().left>n}(v,y,u)||cC.chrome&&function(e,t,n){if(0!=t)return!1;for(let t=e;;){let e=t.parentNode;if(!e||1!=e.nodeType||e.firstChild!=t)return!1;if(e.classList.contains("cm-line"))break;t=e}let i=1==e.nodeType?e.getBoundingClientRect():Nw(e,0,Math.max(e.nodeValue.length,1)).getBoundingClientRect();return n-i.left>5}(v,y,u))&&(v=void 0))}v&&(y=Math.min(Aw(v),y))}if(!v||!e.docView.dom.contains(v)){let t=MC.find(e.docView,p);if(!t)return d>s.top+s.height/2?s.to:s.from;({node:v,offset:y}=FO(t.dom,u,h))}let x=e.docView.nearest(v);if(!x)return null;if(x.isWidget&&1==(null===(r=x.dom)||void 0===r?void 0:r.nodeType)){let e=x.dom.getBoundingClientRect();return t.y<e.top||t.y<=e.bottom&&t.x<=(e.left+e.right)/2?x.posAtStart:x.posAtEnd}return x.localPosFromDOM(v,y)+x.posAtStart}function HO(e,t,n,i,o){let r=Math.round((i-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;r+=Math.floor((o-n.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let s=e.state.sliceDoc(n.from,n.to);return n.from+function(e,t,n,i){for(let i=0,o=0;;){if(o>=t)return i;if(i==e.length)break;o+=9==e.charCodeAt(i)?n-o%n:1,i=qb(e,i)}return!0===i?-1:e.length}(s,r,e.state.tabSize)}function WO(e,t,n,i){let o=function(e,t){let n=e.lineBlockAt(t);if(Array.isArray(n.type))for(let e of n.type)if(e.to>t||e.to==t&&(e.to==n.to||e.type==CC.Text))return e;return n}(e,t.head),r=i&&o.type==CC.Text&&(e.lineWrapping||o.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>o.from?t.head-1:t.head):null;if(r){let t=e.dom.getBoundingClientRect(),i=e.textDirectionAt(o.from),s=e.posAtCoords({x:n==(i==IC.LTR)?t.right-1:t.left+1,y:(r.top+r.bottom)/2});if(null!=s)return t_.cursor(s,n?-1:1)}return t_.cursor(n?o.to:o.from,n?-1:1)}function UO(e,t,n,i){let o=e.state.doc.lineAt(t.head),r=e.bidiSpans(o),s=e.textDirectionAt(o.from);for(let a=t,l=null;;){let t=JC(o,r,s,a,n),c=ZC;if(!t){if(o.number==(n?e.state.doc.lines:1))return a;c="\n",o=e.state.doc.line(o.number+(n?1:-1)),r=e.bidiSpans(o),t=e.visualLineSide(o,!n)}if(l){if(!l(c))return a}else{if(!i)return t;l=i(c)}a=t}}function XO(e,t,n){for(;;){let i=0;for(let o of e)o.between(t-1,t+1,((e,o,r)=>{if(t>e&&t<o){let r=i||n||(t-e<o-t?-1:1);t=r<0?e:o,i=r}}));if(!i)return t}}function KO(e,t,n){let i=XO(e.state.facet(EO).map((t=>t(e))),n.from,t.head>n.from?-1:1);return i==n.from?n:t_.cursor(i,i<n.from?1:-1)}const GO="";class YO{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(W_.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=GO}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let i=e;;){this.findPointBefore(n,i);let e=this.text.length;this.readNode(i);let o=i.nextSibling;if(o==t)break;let r=Uw.get(i),s=Uw.get(o);(r&&s?r.breakAfter:(r?r.breakAfter:Tw(i))||Tw(o)&&("BR"!=i.nodeName||i.cmIgnore)&&this.text.length>e)&&this.lineBreak(),i=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let o,r=-1,s=1;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(o=i.exec(t))&&(r=o.index,s=o[0].length),this.append(t.slice(n,r<0?t.length:r)),r<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);n=r+s}}readNode(e){if(e.cmIgnore)return;let t=Uw.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(ZO(e,n.node,n.offset)?t:0))}}function ZO(e,t,n){for(;;){if(!t||n<Aw(t))return!1;if(t==e)return!0;n=Rw(t)+1,t=t.parentNode}}class JO{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class ek{constructor(e,t,n,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:o,impreciseAnchor:r}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let t=o||r?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:i,focusNode:o,focusOffset:r}=e.observer.selectionRange;n&&(t.push(new JO(n,i)),o==n&&r==i||t.push(new JO(o,r)));return t}(e),n=new YO(t,e.state);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,i=2==e.length?e[1].pos:n;return n>-1&&i>-1?t_.single(n+t,i+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=o&&o.node==t.focusNode&&o.offset==t.focusOffset||!Ow(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),i=r&&r.node==t.anchorNode&&r.offset==t.anchorOffset||!Ow(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((cC.ios||cC.chrome)&&e.state.selection.main.empty&&n!=i&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,i),o=Math.max(n,i),r=s.from-t,a=s.to-o;0!=r&&1!=r&&0!=t||0!=a&&-1!=a&&o!=e.state.doc.length||(n=0,i=e.state.doc.length)}this.newSel=t_.single(i,n)}}}function tk(e,t){let n,{newSel:i}=t,o=e.state.selection.main,r=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:i,to:s}=t.bounds,a=o.from,l=null;(8===r||cC.android&&t.text.length<s-i)&&(a=o.to,l="end");let c=function(e,t,n,i){let o=Math.min(e.length,t.length),r=0;for(;r<o&&e.charCodeAt(r)==t.charCodeAt(r);)r++;if(r==o&&e.length==t.length)return null;let s=e.length,a=t.length;for(;s>0&&a>0&&e.charCodeAt(s-1)==t.charCodeAt(a-1);)s--,a--;if("end"==i){n-=s+Math.max(0,r-Math.min(s,a))-r}if(s<r&&e.length<t.length){r-=n<=r&&n>=s?r-n:0,a=r+(a-s),s=r}else if(a<r){r-=n<=r&&n>=a?r-n:0,s=r+(s-a),a=r}return{from:r,toA:s,toB:a}}(e.state.doc.sliceString(i,s,GO),t.text,a-i,l);c&&(cC.chrome&&13==r&&c.toB==c.from+2&&t.text.slice(c.from,c.toB)==GO+GO&&c.toB--,n={from:i+c.from,to:i+c.toA,insert:Mb.of(t.text.slice(c.from,c.toB).split(GO))})}else i&&(!e.hasFocus&&e.state.facet(vO)||i.main.eq(o))&&(i=null);if(!n&&!i)return!1;if(!n&&t.typeOver&&!o.empty&&i&&i.main.empty?n={from:o.from,to:o.to,insert:e.state.doc.slice(o.from,o.to)}:(cC.mac||cC.android)&&n&&n.from==n.to&&n.from==o.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(i&&2==n.insert.length&&(i=t_.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:Mb.of([n.insert.toString().replace("."," ")])}):n&&n.from>=o.from&&n.to<=o.to&&(n.from!=o.from||n.to!=o.to)&&o.to-o.from-(n.to-n.from)<=4?n={from:o.from,to:o.to,insert:e.state.doc.slice(o.from,n.from).append(n.insert).append(e.state.doc.slice(n.to,o.to))}:cC.chrome&&n&&n.from==n.to&&n.from==o.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(i&&(i=t_.single(i.main.anchor-1,i.main.head-1)),n={from:o.from,to:o.to,insert:Mb.of([" "])}),n)return nk(e,n,i,r);if(i&&!i.main.eq(o)){let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),n=e.inputState.lastSelectionOrigin),e.dispatch({selection:i,scrollIntoView:t,userEvent:n}),!0}return!1}function nk(e,t,n,i=-1){if(cC.ios&&e.inputState.flushIOSKey(t))return!0;let o=e.state.selection.main;if(cC.android&&(t.to==o.to&&(t.from==o.from||t.from==o.from-1&&" "==e.state.sliceDoc(t.from,o.from))&&1==t.insert.length&&2==t.insert.lines&&qw(e.contentDOM,"Enter",13)||(t.from==o.from-1&&t.to==o.to&&0==t.insert.length||8==i&&t.insert.length<t.to-t.from&&t.to>o.head)&&qw(e.contentDOM,"Backspace",8)||t.from==o.from&&t.to==o.to+1&&0==t.insert.length&&qw(e.contentDOM,"Delete",46)))return!0;let r,s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>r||(r=function(e,t,n){let i,o=e.state,r=o.selection.main;if(t.from>=r.from&&t.to<=r.to&&t.to-t.from>=(r.to-r.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=r.from<t.from?o.sliceDoc(r.from,t.from):"",s=r.to>t.to?o.sliceDoc(t.to,r.to):"";i=o.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+s))}else{let s=o.changes(t),a=n&&n.main.to<=s.newLength?n.main:void 0;if(o.selection.ranges.length>1&&e.inputState.composing>=0&&t.to<=r.to&&t.to>=r.to-10){let l,c=e.state.sliceDoc(t.from,t.to),u=n&&jO(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(r.head);let h=r.to-t.to,d=r.to-r.from;i=o.changeByRange((n=>{if(n.from==r.from&&n.to==r.to)return{changes:s,range:a||n.map(s)};let i=n.to-h,u=i-c.length;if(n.to-n.from!=d||e.state.sliceDoc(u,i)!=c||n.to>=l.from&&n.from<=l.to)return{range:n};let p=o.changes({from:u,to:i,insert:t.insert}),f=n.to-r.to;return{changes:p,range:a?t_.range(Math.max(0,a.anchor+f),Math.max(0,a.head+f)):n.map(p)}}))}else i={changes:s,selection:a&&o.selection.replaceRange(a)}}let s="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=".compose",e.inputState.compositionFirstChange&&(s+=".start",e.inputState.compositionFirstChange=!1));return o.update(i,{userEvent:s,scrollIntoView:!0})}(e,t,n));return e.state.facet(sO).some((n=>n(e,t.from,t.to,s,a)))||e.dispatch(a()),!0}class ik{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,cC.safari&&e.contentDOM.addEventListener("input",(()=>null)),cC.gecko&&function(e){Mk.has(e)||(Mk.add(e),e.addEventListener("copy",(()=>{})),e.addEventListener("cut",(()=>{})))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n,i=t.target;i!=e.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(n=Uw.get(i))&&n.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=rk(e),n=this.handlers,i=this.view.contentDOM;for(let e in t)if("scroll"!=e){let o=!t[e].handlers.length,r=n[e];r&&o!=!r.handlers.length&&(i.removeEventListener(e,this.handleEvent),r=null),r||i.addEventListener(e,this.handleEvent,{passive:o})}for(let e in n)"scroll"==e||t[e]||i.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&lk.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),cC.android&&cC.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!cC.ios||e.synthetic||e.altKey||e.metaKey||!((t=sk.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||ak.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,qw(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0)))}ignoreDuringComposition(e){return!!/^key/.test(e.type)&&(this.composing>0||!!(cC.safari&&!cC.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function ok(e,t){return(n,i)=>{try{return t.call(e,i,n)}catch(e){mO(n.state,e)}}}function rk(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec;if(e&&e.domEventHandlers)for(let i in e.domEventHandlers){let o=e.domEventHandlers[i];o&&n(i).handlers.push(ok(t.value,o))}if(e&&e.domEventObservers)for(let i in e.domEventObservers){let o=e.domEventObservers[i];o&&n(i).observers.push(ok(t.value,o))}}for(let e in hk)n(e).handlers.push(hk[e]);for(let e in dk)n(e).observers.push(dk[e]);return t}const sk=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ak="dthko",lk=[16,17,18,20,91,92,224,225];function ck(e){return.7*Math.max(0,e)+8}class uk{constructor(e,t,n,i){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t,n,i=e.ownerDocument;for(let o=e.parentNode;o&&!(o==i.body||t&&n);)if(1==o.nodeType)!n&&o.scrollHeight>o.clientHeight&&(n=o),!t&&o.scrollWidth>o.clientWidth&&(t=o),o=o.assignedSlot||o.parentNode;else{if(11!=o.nodeType)break;o=o.host}return{x:t,y:n}}(e.contentDOM),this.atoms=e.state.facet(EO).map((t=>t(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(W_.allowMultipleSelections)&&function(e,t){let n=e.state.facet(tO);return n.length?n[0](t):cC.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let i=Cw(e.root);if(!i||0==i.rangeCount)return!0;let o=i.getRangeAt(0).getClientRects();for(let e=0;e<o.length;e++){let n=o[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)||1!=Ok(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&function(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,i=0,o=0,r=this.view.win.innerWidth,s=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:r}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:s}=this.scrollParents.y.getBoundingClientRect());let a=MO(this.view);e.clientX-a.left<=i+6?t=-ck(i-e.clientX):e.clientX+a.right>=r-6&&(t=ck(e.clientX-r)),e.clientY-a.top<=o+6?n=-ck(o-e.clientY):e.clientY+a.bottom>=s-6&&(n=ck(e.clientY-s)),this.setScrollSpeed(t,n)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;n<e.ranges.length;n++){let i=e.ranges[n],o=null;if(i.empty){let e=XO(this.atoms,i.from,0);e!=i.from&&(o=t_.cursor(e,-1))}else{let e=XO(this.atoms,i.from,-1),t=XO(this.atoms,i.to,1);e==i.from&&t==i.to||(o=t_.range(i.from==i.anchor?e:t,i.from==i.head?e:t))}o&&(t||(t=e.ranges.slice()),t[n]=o)}return t?t_.create(t,e.mainIndex):e}select(e){let{view:t}=this,n=this.skipAtoms(this.style.get(e,this.extend,this.multiple));!this.mustSelect&&n.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some((e=>e.isUserEvent("input.type")))?this.destroy():this.style.update(e)&&setTimeout((()=>this.select(this.lastEvent)),20)}}const hk=Object.create(null),dk=Object.create(null),pk=cC.ie&&cC.ie_version<15||cC.ios&&cC.webkit_version<604;function fk(e,t,n){for(let i of e.facet(t))n=i(n,e);return n}function gk(e,t){t=fk(e.state,lO,t);let n,{state:i}=e,o=1,r=i.toText(t),s=r.lines==i.selection.ranges.length,a=null!=Ek&&i.selection.ranges.every((e=>e.empty))&&Ek==r.toString();if(a){let e=-1;n=i.changeByRange((n=>{let a=i.doc.lineAt(n.from);if(a.from==e)return{range:n};e=a.from;let l=i.toText((s?r.line(o++).text:t)+i.lineBreak);return{changes:{from:a.from,insert:l},range:t_.cursor(n.from+l.length)}}))}else n=s?i.changeByRange((e=>{let t=r.line(o++);return{changes:{from:e.from,to:e.to,insert:t.text},range:t_.cursor(e.from+t.length)}})):i.replaceSelection(r);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function mk(e,t,n,i){if(1==i)return t_.cursor(t,n);if(2==i)return function(e,t,n=1){let i=e.charCategorizer(t),o=e.doc.lineAt(t),r=t-o.from;if(0==o.length)return t_.cursor(t);0==r?n=1:r==o.length&&(n=-1);let s=r,a=r;n<0?s=qb(o.text,r,!1):a=qb(o.text,r);let l=i(o.text.slice(s,a));for(;s>0;){let e=qb(o.text,s,!1);if(i(o.text.slice(e,s))!=l)break;s=e}for(;a<o.length;){let e=qb(o.text,a);if(i(o.text.slice(a,e))!=l)break;a=e}return t_.range(s+o.from,a+o.from)}(e.state,t,n);{let n=MC.find(e.docView,t),i=e.state.doc.lineAt(n?n.posAtEnd:t),o=n?n.posAtStart:i.from,r=n?n.posAtEnd:i.to;return r<e.state.doc.length&&r==i.to&&r++,t_.range(o,r)}}dk.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},hk.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),dk.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},dk.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},hk.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of e.state.facet(iO))if(n=i(e,t),n)break;if(n||0!=t.button||(n=function(e,t){let n=xk(e,t),i=Ok(t),o=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),o=o.map(e.changes))},get(t,r,s){let a,l=xk(e,t),c=mk(e,l.pos,l.bias,i);if(n.pos!=l.pos&&!r){let t=mk(e,n.pos,n.bias,i),o=Math.min(t.from,c.from),r=Math.max(t.to,c.to);c=o<c.from?t_.range(o,r):t_.range(r,o)}return r?o.replaceRange(o.main.extend(c.from,c.to)):s&&1==i&&o.ranges.length>1&&(a=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:i,to:o}=e.ranges[n];if(i<=t&&o>=t)return t_.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(o,l.pos))?a:s?o.addRange(c):t_.create([c])}}}(e,t)),n){let i=!e.hasFocus;e.inputState.startMouseSelection(new uk(e,t,n,i)),i&&e.observer.ignore((()=>{Lw(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()}));let o=e.inputState.mouseSelection;if(o)return o.start(t),!1===o.dragging}return!1};let vk=(e,t,n)=>t>=n.top&&t<=n.bottom&&e>=n.left&&e<=n.right;function yk(e,t,n,i){let o=MC.find(e.docView,t);if(!o)return 1;let r=t-o.posAtStart;if(0==r)return 1;if(r==o.length)return-1;let s=o.coordsAt(r,-1);if(s&&vk(n,i,s))return-1;let a=o.coordsAt(r,1);return a&&vk(n,i,a)?1:s&&s.bottom>=i?-1:1}function xk(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1);return{pos:n,bias:yk(e,n,t.clientX,t.clientY)}}const bk=cC.ie&&cC.ie_version<=11;let _k=null,wk=0,Ck=0;function Ok(e){if(!bk)return e.detail;let t=_k,n=Ck;return _k=e,Ck=Date.now(),wk=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(wk+1)%3:1}function kk(e,t,n,i){if(!(n=fk(e.state,lO,n)))return;let o=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:r}=e.inputState,s=i&&r&&function(e,t){let n=e.state.facet(nO);return n.length?n[0](t):cC.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:r.from,to:r.to}:null,a={from:o,insert:n},l=e.state.changes(s?[s,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(o,-1),head:l.mapPos(o,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}hk.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let i=e.docView.nearest(t.target);if(i&&i.isWidget){let e=i.posAtStart,t=e+i.length;(e>=n.to||t<=n.from)&&(n=t_.range(e,t))}}let{inputState:i}=e;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",fk(e.state,cO,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},hk.dragend=e=>(e.inputState.draggedContent=null,!1),hk.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let i=Array(n.length),o=0,r=()=>{++o==n.length&&kk(e,t,i.filter((e=>null!=e)).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=r,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(i[e]=t.result),r()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return kk(e,t,n,!0),!0}return!1},hk.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=pk?null:t.clipboardData;return n?(gk(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout((()=>{e.focus(),n.remove(),gk(e,n.value)}),50)}(e),!1)};let Ek=null;hk.copy=hk.cut=(e,t)=>{let{text:n,ranges:i,linewise:o}=function(e){let t=[],n=[],i=!1;for(let i of e.selection.ranges)i.empty||(t.push(e.sliceDoc(i.from,i.to)),n.push(i));if(!t.length){let o=-1;for(let{from:i}of e.selection.ranges){let r=e.doc.lineAt(i);r.number>o&&(t.push(r.text),n.push({from:r.from,to:Math.min(e.doc.length,r.to+1)})),o=r.number}i=!0}return{text:fk(e,cO,t.join(e.lineBreak)),ranges:n,linewise:i}}(e.state);if(!n&&!o)return!1;Ek=o?n:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=pk?null:t.clipboardData;return r?(r.clearData(),r.setData("text/plain",n),!0):(function(e,t){let n=e.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout((()=>{i.remove(),e.focus()}),50)}(e,n),!1)};const Sk=A_.define();function Rk(e,t){let n=[];for(let i of e.facet(aO)){let o=i(e,t);o&&n.push(o)}return n?e.update({effects:n,annotations:Sk.of(!0)}):null}function Tk(e){setTimeout((()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=Rk(e.state,t);n?e.dispatch(n):e.update([])}}),10)}dk.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),Tk(e)},dk.blur=e=>{e.observer.clearSelectionRange(),Tk(e)},dk.compositionstart=dk.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},dk.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,cC.chrome&&cC.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then((()=>e.observer.flush())):setTimeout((()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])}),50))},dk.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},hk.beforeinput=(e,t)=>{var n,i;if("insertReplacementText"==t.inputType&&e.observer.editContext){let i=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/plain"),o=t.getTargetRanges();if(i&&o.length){let t=o[0],n=e.posAtDOM(t.startContainer,t.startOffset),r=e.posAtDOM(t.endContainer,t.endOffset);return nk(e,{from:n,to:r,insert:e.state.toText(i)},null),!0}}let o;if(cC.chrome&&cC.android&&(o=sk.find((e=>e.inputType==t.inputType)))&&(e.observer.delayAndroidKey(o.key,o.keyCode),"Backspace"==o.key||"Delete"==o.key)){let t=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var n;((null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())}),100)}return cC.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),cC.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout((()=>dk.compositionend(e,t)),20),!1};const Mk=new Set;const Ak=["pre-wrap","normal","pre-line","break-spaces"];let Pk=!1;function Dk(){Pk=!1}class $k{constructor(e){this.lineWrapping=e,this.doc=Mb.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Ak.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let i=e[n];i<0?n++:this.heightSamples[Math.floor(10*i)]||(t=!0,this.heightSamples[Math.floor(10*i)]=!0)}return t}refresh(e,t,n,i,o,r){let s=Ak.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=s;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=n,this.textHeight=i,this.lineLength=o,a){this.heightSamples={};for(let e=0;e<r.length;e++){let t=r[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return a}}class jk{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Ik{constructor(e,t,n,i,o){this.from=e,this.length=t,this.top=n,this.height=i,this._content=o}get type(){return"number"==typeof this._content?CC.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof SC?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Ik(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var Bk=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(Bk||(Bk={}));const Lk=.001;class Nk{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Lk&&(Pk=!0),this.height=e)}replace(e,t,n){return Nk.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,i){let o=this,r=n.doc;for(let s=i.length-1;s>=0;s--){let{fromA:a,toA:l,fromB:c,toB:u}=i[s],h=o.lineAt(a,Bk.ByPosNoHeight,n.setDoc(t),0,0),d=h.to>=l?h:o.lineAt(l,Bk.ByPosNoHeight,n,0,0);for(u+=d.to-l,l=d.to;s>0&&h.from<=i[s-1].toA;)a=i[s-1].fromA,c=i[s-1].fromB,s--,a<h.from&&(h=o.lineAt(a,Bk.ByPosNoHeight,n,0,0));c+=h.from-a,a=h.from;let p=Wk.build(n.setDoc(r),e,c,u);o=qk(o,o.replace(a,l,p))}return o.updateHeight(n,0)}static empty(){return new Fk(0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,i=0,o=0;for(;;)if(t==n)if(i>2*o){let o=e[t-1];o.break?e.splice(--t,1,o.left,null,o.right):e.splice(--t,1,o.left,o.right),n+=1+o.break,i-=o.size}else{if(!(o>2*i))break;{let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,o-=t.size}}else if(i<o){let n=e[t++];n&&(i+=n.size)}else{let t=e[--n];t&&(o+=t.size)}let r=0;return null==e[t-1]?(r=1,t--):null==e[t]&&(r=1,n++),new Qk(Nk.of(e.slice(0,t)),r,Nk.of(e.slice(n)))}}function qk(e,t){return e==t?e:(e.constructor!=t.constructor&&(Pk=!0),t)}Nk.prototype.size=1;class Vk extends Nk{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,i){return new Ik(i,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,i,o){return this.blockAt(0,n,i,o)}forEachLine(e,t,n,i,o,r){e<=o+this.length&&t>=o&&r(this.blockAt(0,n,i,o))}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more&&this.setHeight(i.heights[i.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Fk extends Vk{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,i){return new Ik(i,this.length,n,this.height,this.breaks)}replace(e,t,n){let i=n[0];return 1==n.length&&(i instanceof Fk||i instanceof zk&&4&i.flags)&&Math.abs(this.length-i.length)<10?(i instanceof zk?i=new Fk(i.length,this.height):i.height=this.height,this.outdated||(i.outdated=!1),i):Nk.of(n)}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more?this.setHeight(i.heights[i.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class zk extends Nk{constructor(e){super(e,0)}heightMetrics(e,t){let n,i=e.doc.lineAt(t).number,o=e.doc.lineAt(t+this.length).number,r=o-i+1,s=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*r);n=t/r,this.length>r+1&&(s=(this.height-t)/(this.length-r-1))}else n=this.height/r;return{firstLine:i,lastLine:o,perLine:n,perChar:s}}blockAt(e,t,n,i){let{firstLine:o,lastLine:r,perLine:s,perChar:a}=this.heightMetrics(t,i);if(t.lineWrapping){let o=i+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),r=t.doc.lineAt(o),l=s+r.length*a,c=Math.max(n,e-l/2);return new Ik(r.from,r.length,c,l,0)}{let i=Math.max(0,Math.min(r-o,Math.floor((e-n)/s))),{from:a,length:l}=t.doc.line(o+i);return new Ik(a,l,n+s*i,s,0)}}lineAt(e,t,n,i,o){if(t==Bk.ByHeight)return this.blockAt(e,n,i,o);if(t==Bk.ByPosNoHeight){let{from:t,to:i}=n.doc.lineAt(e);return new Ik(t,i-t,0,0,0)}let{firstLine:r,perLine:s,perChar:a}=this.heightMetrics(n,o),l=n.doc.lineAt(e),c=s+l.length*a,u=l.number-r,h=i+s*u+a*(l.from-o-u);return new Ik(l.from,l.length,Math.max(i,Math.min(h,i+this.height-c)),c,0)}forEachLine(e,t,n,i,o,r){e=Math.max(e,o),t=Math.min(t,o+this.length);let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(n,o);for(let c=e,u=i;c<=t;){let t=n.doc.lineAt(c);if(c==e){let n=t.number-s;u+=a*n+l*(e-o-n)}let i=a+l*t.length;r(new Ik(t.from,t.length,u,i,0)),u+=i,c=t.to+1}}replace(e,t,n){let i=this.length-t;if(i>0){let e=n[n.length-1];e instanceof zk?n[n.length-1]=new zk(e.length+i):n.push(null,new zk(i-1))}if(e>0){let t=n[0];t instanceof zk?n[0]=new zk(e+t.length):n.unshift(new zk(e-1),null)}return Nk.of(n)}decomposeLeft(e,t){t.push(new zk(e-1),null)}decomposeRight(e,t){t.push(null,new zk(this.length-e-1))}updateHeight(e,t=0,n=!1,i){let o=t+this.length;if(i&&i.from<=t+this.length&&i.more){let n=[],r=Math.max(t,i.from),s=-1;for(i.from>t&&n.push(new zk(i.from-t-1).updateHeight(e,t));r<=o&&i.more;){let t=e.doc.lineAt(r).length;n.length&&n.push(null);let o=i.heights[i.index++];-1==s?s=o:Math.abs(o-s)>=Lk&&(s=-2);let a=new Fk(t,o);a.outdated=!1,n.push(a),r+=t+1}r<=o&&n.push(null,new zk(o-r).updateHeight(e,r));let a=Nk.of(n);return(s<0||Math.abs(a.height-this.height)>=Lk||Math.abs(s-this.heightMetrics(e,t).perLine)>=Lk)&&(Pk=!0),qk(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Qk extends Nk{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return 1&this.flags}blockAt(e,t,n,i){let o=n+this.left.height;return e<o?this.left.blockAt(e,t,n,i):this.right.blockAt(e,t,o,i+this.left.length+this.break)}lineAt(e,t,n,i,o){let r=i+this.left.height,s=o+this.left.length+this.break,a=t==Bk.ByHeight?e<r:e<s,l=a?this.left.lineAt(e,t,n,i,o):this.right.lineAt(e,t,n,r,s);if(this.break||(a?l.to<s:l.from>s))return l;let c=t==Bk.ByPosNoHeight?Bk.ByPosNoHeight:Bk.ByPos;return a?l.join(this.right.lineAt(s,c,n,r,s)):this.left.lineAt(s,c,n,i,o).join(l)}forEachLine(e,t,n,i,o,r){let s=i+this.left.height,a=o+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,i,o,r),t>=a&&this.right.forEachLine(e,t,n,s,a,r);else{let l=this.lineAt(a,Bk.ByPos,n,i,o);e<l.from&&this.left.forEachLine(e,l.from-1,n,i,o,r),l.to>=e&&l.from<=t&&r(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,s,a,r)}}replace(e,t,n){let i=this.left.length+this.break;if(t<i)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,n));let o=[];e>0&&this.decomposeLeft(e,o);let r=o.length;for(let e of n)o.push(e);if(e>0&&Hk(o,r-1),t<this.length){let e=o.length;this.decomposeRight(t,o),Hk(o,e)}return Nk.of(o)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,i=n+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<i&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Nk.of(this.break?[e,null,t]:[e,t]):(this.left=qk(this.left,e),this.right=qk(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,i){let{left:o,right:r}=this,s=t+o.length+this.break,a=null;return i&&i.from<=t+o.length&&i.more?a=o=o.updateHeight(e,t,n,i):o.updateHeight(e,t,n),i&&i.from<=s+r.length&&i.more?a=r=r.updateHeight(e,s,n,i):r.updateHeight(e,s,n),a?this.balanced(o,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Hk(e,t){let n,i;null==e[t]&&(n=e[t-1])instanceof zk&&(i=e[t+1])instanceof zk&&e.splice(t-1,3,new zk(n.length+1+i.length))}class Wk{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof Fk?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new Fk(e-this.pos,-1)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let i=n.widget?n.widget.estimatedHeight:0,o=n.widget?n.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let r=t-e;n.block?this.addBlock(new Vk(r,i,n)):(r||o||i>=5)&&this.addLineDeco(i,o,r)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Fk(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new zk(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Fk)return e;let t=new Fk(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let i=this.ensureLine();i.length+=n,i.collapsed+=n,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof Fk||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Fk(0,-1));let n=e;for(let e of this.nodes)e instanceof Fk&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,i){let o=new Wk(n,e);return Z_.spans(t,n,i,o,0),o.finish(n)}}class Uk{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,i){(e<t||n&&n.heightRelevant||i&&i.heightRelevant)&&TC(e,t,this.changes,5)}}function Xk(e,t){let n=e.getBoundingClientRect(),i=e.ownerDocument,o=i.defaultView||window,r=Math.max(0,n.left),s=Math.min(o.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(o.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=i.body;)if(1==t.nodeType){let n=t,i=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=i.overflow){let i=n.getBoundingClientRect();r=Math.max(r,i.left),s=Math.min(s,i.right),a=Math.max(a,i.top),l=Math.min(t==e.parentNode?o.innerHeight:l,i.bottom)}t="absolute"==i.position||"fixed"==i.position?n.offsetParent:n.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:r-n.left,right:Math.max(r,s)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function Kk(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class Gk{constructor(e,t,n,i){this.from=e,this.to=t,this.size=n,this.displaySize=i}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],o=t[n];if(i.from!=o.from||i.to!=o.to||i.size!=o.size)return!1}return!0}draw(e,t){return OC.replace({widget:new Yk(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Yk extends wC{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Zk{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=nE,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=IC.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(CO).some((e=>"function"!=typeof e&&"cm-lineWrapping"==e.class));this.heightOracle=new $k(t),this.stateDeco=e.facet(OO).filter((e=>"function"!=typeof e)),this.heightMap=Nk.empty().applyChanges(this.stateDeco,Mb.empty,this.heightOracle.setDoc(e.doc),[new PO(0,0,0,e.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=OC.set(this.lineGaps.map((e=>e.draw(this,!1)))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let i=n?t.head:t.anchor;if(!e.some((({from:e,to:t})=>i>=e&&i<=t))){let{from:t,to:n}=this.lineBlockAt(i);e.push(new Jk(t,n))}}return this.viewports=e.sort(((e,t)=>e.from-t.from)),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?nE:new iE(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(oE(e,this.scaler))}))}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(OO).filter((e=>"function"!=typeof e));let i=e.changedRanges,o=PO.extendWithRanges(i,function(e,t,n){let i=new Uk;return Z_.compare(e,t,n,i,0),i.changes}(n,this.stateDeco,e?e.changes:Ub.empty(this.state.doc.length))),r=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Dk(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=r||Pk)&&(e.flags|=2),s?(this.scrollAnchorPos=e.changes.mapPos(s.from,-1),this.scrollAnchorHeight=s.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(hO)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),i=this.heightOracle,o=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?IC.RTL:IC.LTR;let r=this.heightOracle.mustRefreshForWrapping(o),s=t.getBoundingClientRect(),a=r||this.mustMeasureContent||this.contentDOMHeight!=s.height;this.contentDOMHeight=s.height,this.mustMeasureContent=!1;let l=0,c=0;if(s.width&&s.height){let{scaleX:e,scaleY:n}=$w(t,s);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,l|=16,r=a=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,h=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==u&&this.paddingBottom==h||(this.paddingTop=u,this.paddingBottom=h,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Fw(e.scrollDOM);let p=(this.printing?Kk:Xk)(t,this.paddingTop),f=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}(e.dom))return 0;let v=s.width;if(this.contentDOMWidth==v&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(t)&&(r=!0),r||i.lineWrapping&&Math.abs(v-this.contentDOMWidth)>i.charWidth){let{lineHeight:n,charWidth:s,textHeight:a}=e.docView.measureTextSize();r=n>0&&i.refresh(o,n,s,a,v/s,t),r&&(e.docView.minWidth=0,l|=16)}f>0&&g>0?c=Math.max(f,g):f<0&&g<0&&(c=Math.min(f,g)),Dk();for(let n of this.viewports){let o=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(r?Nk.empty().applyChanges(this.stateDeco,Mb.empty,this.heightOracle,[new PO(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,r,new jk(n.from,o))}Pk&&(l|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(r?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,o=this.heightOracle,{visibleTop:r,visibleBottom:s}=this,a=new Jk(i.lineAt(r-1e3*n,Bk.ByHeight,o,0,0).from,i.lineAt(s+1e3*(1-n),Bk.ByHeight,o,0,0).to);if(t){let{head:e}=t.range;if(e<a.from||e>a.to){let n,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=i.lineAt(e,Bk.ByPos,o,0,0);n="center"==t.y?(s.top+s.bottom)/2-r/2:"start"==t.y||"nearest"==t.y&&e<a.from?s.top:s.bottom-r,a=new Jk(i.lineAt(n-500,Bk.ByHeight,o,0,0).from,i.lineAt(n+r+500,Bk.ByHeight,o,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),i=t.mapPos(e.to,1);return new Jk(this.heightMap.lineAt(n,Bk.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,Bk.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:i}=this.heightMap.lineAt(e,Bk.ByPos,this.heightOracle,0,0),{bottom:o}=this.heightMap.lineAt(t,Bk.ByPos,this.heightOracle,0,0),{visibleTop:r,visibleBottom:s}=this;return(0==e||i<=r-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||o>=s+Math.max(10,Math.min(n,250)))&&i>r-2e3&&o<s+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let i of e)t.touchesRange(i.from,i.to)||n.push(new Gk(t.mapPos(i.from),t.mapPos(i.to),i.size,i.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,i=n?1e4:2e3,o=i>>1,r=i<<1;if(this.defaultTextDirection!=IC.LTR&&!n)return[];let s=[],a=(i,r,l,c)=>{if(r-i<o)return;let u=this.state.selection.main,h=[u.from];u.empty||h.push(u.to);for(let e of h)if(e>i&&e<r)return a(i,e-10,l,c),void a(e+10,r,l,c);let d=function(e,t){for(let n of e)if(t(n))return n;return}(e,(e=>e.from>=l.from&&e.to<=l.to&&Math.abs(e.from-i)<o&&Math.abs(e.to-r)<o&&!h.some((t=>e.from<t&&e.to>t))));if(!d){if(r<l.to&&t&&n&&t.visibleRanges.some((e=>e.from<=r&&e.to>=r))){let e=t.moveToLineBoundary(t_.cursor(r),!1,!0).head;e>i&&(r=e)}let e=this.gapSize(l,i,r,c);d=new Gk(i,r,e,n||e<2e6?e:2e6)}s.push(d)},l=t=>{if(t.length<r||t.type!=CC.Text)return;let o=function(e,t,n){let i=[],o=e,r=0;Z_.spans(n,e,t,{span(){},point(e,t){e>o&&(i.push({from:o,to:e}),r+=e-o),o=t}},20),o<t&&(i.push({from:o,to:t}),r+=t-o);return{total:r,ranges:i}}(t.from,t.to,this.stateDeco);if(o.total<r)return;let s,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,r=i/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let i=tE(o,c),s=((this.visibleBottom-this.visibleTop)/2+r)/t.height;e=i-s,n=i+s}else e=(this.visibleTop-t.top-r)/t.height,n=(this.visibleBottom-t.top+r)/t.height;s=eE(o,e),l=eE(o,n)}else{let n=o.total*this.heightOracle.charWidth,r=i*this.heightOracle.charWidth,a=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=n.size-n.displaySize);let u,h,d=this.pixelViewport.left+a,p=this.pixelViewport.right+a;if(null!=c){let e=tE(o,c),t=((p-d)/2+r)/n;u=e-t,h=e+t}else u=(d-r)/n,h=(p+r)/n;s=eE(o,u),l=eE(o,h)}s>t.from&&a(t.from,s,t,o),l<t.to&&a(l,t.to,t,o)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(l):l(e);return s}gapSize(e,t,n,i){let o=tE(i,n)-tE(i,t);return this.heightOracle.lineWrapping?e.height*o:i.total*this.heightOracle.charWidth*o}updateLineGaps(e){Gk.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=OC.set(e.map((e=>e.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];Z_.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let i=0;if(n.length!=this.visibleRanges.length)i=12;else for(let t=0;t<n.length&&!(8&i);t++){let o=this.visibleRanges[t],r=n[t];o.from==r.from&&o.to==r.to||(i|=4,e&&e.mapPos(o.from,-1)==r.from&&e.mapPos(o.to,1)==r.to||(i|=8))}return this.visibleRanges=n,i}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find((t=>t.from<=e&&t.to>=e))||oE(this.heightMap.lineAt(e,Bk.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))||oE(this.heightMap.lineAt(this.scaler.fromDOM(e),Bk.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return oE(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Jk{constructor(e,t){this.from=e,this.to=t}}function eE({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let i=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:o}=t[e],r=o-n;if(i<=r)return n+i;i-=r}}function tE(e,t){let n=0;for(let{from:i,to:o}of e.ranges){if(t<=o){n+=t-i;break}n+=o-i}return n/e.total}const nE={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};class iE{constructor(e,t,n){let i=0,o=0,r=0;this.viewports=n.map((({from:n,to:o})=>{let r=t.lineAt(n,Bk.ByPos,e,0,0).top,s=t.lineAt(o,Bk.ByPos,e,0,0).bottom;return i+=s-r,{from:n,to:o,top:r,bottom:s,domTop:0,domBottom:0}})),this.scale=(7e6-i)/(t.height-i);for(let e of this.viewports)e.domTop=r+(e.top-o)*this.scale,r=e.domBottom=e.domTop+(e.bottom-e.top),o=e.bottom}toDOM(e){for(let t=0,n=0,i=0;;t++){let o=t<this.viewports.length?this.viewports[t]:null;if(!o||e<o.top)return i+(e-n)*this.scale;if(e<=o.bottom)return o.domTop+(e-o.top);n=o.bottom,i=o.domBottom}}fromDOM(e){for(let t=0,n=0,i=0;;t++){let o=t<this.viewports.length?this.viewports[t]:null;if(!o||e<o.domTop)return n+(e-i)/this.scale;if(e<=o.domBottom)return o.top+(e-o.domTop);n=o.bottom,i=o.domBottom}}eq(e){return e instanceof iE&&(this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every(((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to)))}}function oE(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),i=t.toDOM(e.bottom);return new Ik(e.from,e.length,n,i-n,Array.isArray(e._content)?e._content.map((e=>oE(e,t))):e._content)}const rE=o_.define({combine:e=>e.join(" ")}),sE=o_.define({combine:e=>e.indexOf(!0)>-1}),aE=fw.newName(),lE=fw.newName(),cE=fw.newName(),uE={"&light":"."+lE,"&dark":"."+cE};function hE(e,t,n){return new fw(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,(t=>{if("&"==t)return e;if(!n||!n[t])throw new RangeError(`Unsupported selector: ${t}`);return n[t]})):e+" "+t})}const dE=hE("."+aE,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&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-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"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},uE),pE={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},fE=cC.ie&&cC.ie_version<=11;class gE{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new jw,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver((t=>{for(let e of t)this.queue.push(e);(cC.ie&&cC.ie_version<=11||cC.ios&&e.composing)&&t.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),!window.EditContext||!1===e.constructor.EDIT_CONTEXT||cC.chrome&&cC.chrome_version<126||(this.editContext=new yE(e),e.state.facet(vO)&&(e.contentDOM.editContext=this.editContext.editContext)),fE&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(e){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some(((t,n)=>t!=e[n])))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,i=this.selectionRange;if(n.state.facet(vO)?n.root.activeElement!=this.dom:!kw(this.dom,i))return;let o=i.anchorNode&&n.docView.nearest(i.anchorNode);o&&o.ignoreEvent(e)?t||(this.selectionChanged=!1):(cC.ie&&cC.ie_version<=11||cC.android&&cC.chrome)&&!n.state.selection.main.empty&&i.focusNode&&Sw(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Cw(e.root);if(!t)return!1;let n=cC.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return vE(e,n)}let n=null;function i(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",i,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",i,!0),n?vE(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let i=kw(this.dom,n);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,i=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=i)return!1;for(i=Math.min(i,Aw(n));;)if(i){if(1!=n.nodeType)return!1;let e=n.childNodes[i-1];"false"==e.contentEditable?i--:(n=e,i=Aw(n))}else{if(n==e)return!0;i=Rw(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(1==n.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,pE),fE&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),fE&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;if(e){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&qw(this.dom,e.key,e.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(n=this.delayedAndroidKey)||void 0===n?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,i=!1;for(let o of e){let e=this.readMutation(o);e&&(e.typeOver&&(i=!0),-1==t?({from:t,to:n}=e):(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:i}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),i=this.selectionChanged&&kw(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new ek(this.view,e,t,n);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 n=this.view.state,i=tk(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty("attributes"==e.type),"attributes"==e.type&&(t.flags|=4),"childList"==e.type){let n=mE(t,e.previousSibling||e.target.previousSibling,-1),i=mE(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(vO)!=e.state.facet(vO)&&(e.view.contentDOM.editContext=e.state.facet(vO)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(n=this.resizeScroll)||void 0===n||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function mE(e,t,n){for(;t;){let i=Uw.get(t);if(i&&i.parent==e)return i;let o=t.parentNode;t=o!=e.dom?o:n>0?t.nextSibling:t.previousSibling}return null}function vE(e,t){let n=t.startContainer,i=t.startOffset,o=t.endContainer,r=t.endOffset,s=e.docView.domAtPos(e.state.selection.main.anchor);return Sw(s.node,s.offset,o,r)&&([n,i,o,r]=[o,r,n,i]),{anchorNode:n,anchorOffset:i,focusNode:o,focusOffset:r}}class yE{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=t=>{let n=e.state.selection.main,{anchor:i,head:o}=n,r=this.toEditorPos(t.updateRangeStart),s=this.toEditorPos(t.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:t.updateRangeStart,editorBase:r,drifted:!1});let a={from:r,to:s,insert:Mb.of(t.text.split("\n"))};if(a.from==this.from&&i<this.from?a.from=i:a.to==this.to&&i>this.to&&(a.to=i),a.from!=a.to||a.insert.length){if((cC.mac||cC.android)&&a.from==o-1&&/^\. ?$/.test(t.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(a={from:r,to:s,insert:Mb.of([t.text.replace("."," ")])}),this.pendingContextChange=a,!e.state.readOnly){let n=this.to-this.from+(a.to-a.from+a.insert.length);nk(e,a,t_.single(this.toEditorPos(t.selectionStart,n),this.toEditorPos(t.selectionEnd,n)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state))}else{let i=t_.single(this.toEditorPos(t.selectionStart),this.toEditorPos(t.selectionEnd));i.main.eq(n)||e.dispatch({selection:i,userEvent:"select"})}},this.handlers.characterboundsupdate=n=>{let i=[],o=null;for(let t=this.toEditorPos(n.rangeStart),r=this.toEditorPos(n.rangeEnd);t<r;t++){let n=e.coordsForChar(t);o=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||o||new DOMRect,i.push(o)}t.updateCharacterBounds(n.rangeStart,i)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,i=e.underlineThickness;if("None"!=t&&"None"!=i){let o=this.toEditorPos(e.rangeStart),r=this.toEditorPos(e.rangeEnd);if(o<r){let e=`text-decoration: underline ${"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${"Thin"==i?1:2}px`;n.push(OC.mark({attributes:{style:e}}).range(o,r))}}}e.dispatch({effects:gO.of(OC.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=Cw(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,i=this.pendingContextChange;return e.changes.iterChanges(((o,r,s,a,l)=>{if(n)return;let c=l.length-(r-o);if(i&&r>=i.to){if(i.from==o&&i.to==r&&i.insert.eq(l))return i=this.pendingContextChange=null,t+=c,void(this.to+=c);i=null,this.revertPending(e.state)}if(o+=t,(r+=t)<=this.from)this.from+=c,this.to+=c;else if(o<this.to){if(o<this.from||r>this.to||this.to-this.from+l.length>3e4)return void(n=!0);this.editContext.updateText(this.toContextPos(o),this.toContextPos(r),l.toString()),this.to+=c}t+=c})),i&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange;this.composing&&(this.composing.drifted||e.transactions.some((e=>!e.isUserEvent("input.type")&&e.changes.touchesRange(this.from,this.to))))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),i=this.toContextPos(t.head);this.editContext.selectionStart==n&&this.editContext.selectionEnd==i||this.editContext.updateSelection(n,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class xE{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.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(e=>e.forEach((e=>n(e,this))))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new Zk(e.state||W_.create(e)),e.scrollTo&&e.scrollTo.is(fO)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(xO).map((e=>new _O(e)));for(let e of this.plugins)e.update(this);this.observer=new gE(this),this.inputState=new ik(this),this.inputState.ensureHandlers(this.plugins),this.docView=new $O(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then((()=>this.requestMeasure()))}dispatch(...e){let t=1==e.length&&e[0]instanceof j_?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,n=!1,i=!1,o=this.state;for(let t of e){if(t.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=t.state}if(this.destroyed)return void(this.viewState.state=o);let r=this.hasFocus,s=0,a=null;e.some((e=>e.annotation(Sk)))?(this.inputState.notifiedFocused=r,s=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,a=Rk(o,r),a||(s=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(c=null)):this.observer.clear(),o.facet(W_.phrases)!=this.state.facet(W_.phrases))return this.setState(o);t=DO.create(this,o,e),t.flags|=s;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(u&&(u=u.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;u=new pO(e.empty?e:t_.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(fO)&&(u=e.value.clip(this.state))}this.viewState.update(t,u),this.bidiCache=wE.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(AO)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some((e=>e.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(t.startState.facet(rE)!=t.state.facet(rE)&&(this.viewState.mustMeasureContent=!0),(n||i||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(rO))try{e(t)}catch(e){mO(this.state,e,"update listener")}(a||c)&&Promise.resolve().then((()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!tk(this,c)&&l.force&&qw(this.contentDOM,l.key,l.keyCode)}))}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new Zk(e),this.plugins=e.facet(xO).map((e=>new _O(e))),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new $O(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(xO),n=e.state.facet(xO);if(t!=n){let i=[];for(let o of n){let n=t.indexOf(o);if(n<0)i.push(new _O(o));else{let t=this.plugins[n];t.mustUpdate=e,i.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){mO(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,i=n.scrollTop*this.scaleY,{scrollAnchorPos:o,scrollAnchorHeight:r}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(r<0)if(Fw(n))o=-1,r=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(i);o=e.from,r=e.top}this.updateState=1;let s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let a=[];4&s||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map((e=>{try{return e.read(this)}catch(e){return mO(this.state,e),_E}})),c=DO.create(this,this.state,[]),u=!1;c.flags|=s,t?t.flags|=s:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c),u&&this.docViewUpdate());for(let e=0;e<a.length;e++)if(l[e]!=_E)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){mO(this.state,e)}if(u&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,r=-1;continue}{let e=(o<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(o).top)-r;if(e>1||e<-1){i+=e,n.scrollTop=i/this.scaleY,r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(rO))e(t)}get themeClasses(){return aE+" "+(this.state.facet(sE)?cE:lE)+" "+this.state.facet(rE)}updateAttrs(){let e=CE(this,wO,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(vO)?"true":"false",class:"cm-content",style:`${cC.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),CE(this,CO,t);let n=this.observer.ignore((()=>{let n=bC(this.contentDOM,this.contentAttrs,t),i=bC(this.dom,this.editorAttrs,e);return n||i}));return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)if(e.is(xE.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(AO);let e=this.state.facet(xE.cspNonce);fw.mount(this.root,this.styleModules.concat(dE).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure()))),e){if(this.measureRequests.indexOf(e)>-1)return;if(null!=e.key)for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key)return void(this.measureRequests[t]=e);this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find((t=>t.spec==e))||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return KO(this,e,UO(this,e,t,n))}moveByGroup(e,t){return KO(this,e,UO(this,e,t,(t=>function(e,t,n){let i=e.state.charCategorizer(t),o=i(n);return e=>{let t=i(e);return o==F_.Space&&(o=t),o==t}}(this,e.head,t))))}visualLineSide(e,t){let n=this.bidiSpans(e),i=this.textDirectionAt(e.from),o=n[t?n.length-1:0];return t_.cursor(o.side(t,i)+e.from,o.forward(!t,i)?1:-1)}moveToLineBoundary(e,t,n=!0){return WO(this,e,t,n)}moveVertically(e,t,n){return KO(this,e,function(e,t,n,i){let o=t.head,r=n?1:-1;if(o==(n?e.state.doc.length:0))return t_.cursor(o,t.assoc);let s,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(o,t.assoc||-1),u=e.documentTop;if(c)null==a&&(a=c.left-l.left),s=r<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(o);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(o-t.from))),s=(r<0?t.top:t.bottom)+u}let h=l.left+a,d=null!=i?i:e.viewState.heightOracle.textHeight>>1;for(let t=0;;t+=10){let n=s+(d+t)*r,i=QO(e,{x:h,y:n},!1,r);if(n<l.top||n>l.bottom||(r<0?i<o:i>o)){let t=e.docView.coordsForChar(i),o=!t||n<t.top?-1:1;return t_.cursor(i,o,void 0,a)}}}(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),QO(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let i=this.state.doc.lineAt(e),o=this.bidiSpans(i);return Pw(n,o[WC.find(o,e-i.from,-1,t)].dir==IC.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(uO)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>bE)return YC(e.length);let t,n=this.textDirectionAt(e.from);for(let i of this.bidiCache)if(i.from==e.from&&i.dir==n&&(i.fresh||UC(i.isolates,t=RO(this,e))))return i.order;t||(t=RO(this,e));let i=function(e,t,n){if(!e)return[new WC(0,0,t==LC?1:0)];if(t==BC&&!n.length&&!HC.test(e))return YC(e.length);if(n.length)for(;e.length>XC.length;)XC[XC.length]=256;let i=[],o=t==BC?0:1;return GC(e,o,o,n,0,e.length,i),i}(e.text,n,t);return this.bidiCache.push(new wE(e.from,e.to,n,t,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||cC.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{Lw(this.contentDOM),this.docView.updateSelection()}))}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return fO.of(new pO("number"==typeof e?t_.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return fO.of(new pO(t_.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return bO.define((()=>({})),{eventHandlers:e})}static domEventObservers(e){return bO.define((()=>({})),{eventObservers:e})}static theme(e,t){let n=fw.newName(),i=[rE.of(n),AO.of(hE(`.${n}`,e))];return t&&t.dark&&i.push(sE.of(!0)),i}static baseTheme(e){return v_.lowest(AO.of(hE("."+aE,e,uE)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),i=n&&Uw.get(n)||Uw.get(e);return(null===(t=null==i?void 0:i.rootView)||void 0===t?void 0:t.view)||null}}xE.styleModule=AO,xE.inputHandler=sO,xE.clipboardInputFilter=lO,xE.clipboardOutputFilter=cO,xE.scrollHandler=dO,xE.focusChangeEffect=aO,xE.perLineTextDirection=uO,xE.exceptionSink=oO,xE.updateListener=rO,xE.editable=vO,xE.mouseSelectionStyle=iO,xE.dragMovesSelection=nO,xE.clickAddsSelectionRange=tO,xE.decorations=OO,xE.outerDecorations=kO,xE.atomicRanges=EO,xE.bidiIsolatedRanges=SO,xE.scrollMargins=TO,xE.darkTheme=sE,xE.cspNonce=o_.define({combine:e=>e.length?e[0]:""}),xE.contentAttributes=CO,xE.editorAttributes=wO,xE.lineWrapping=xE.contentAttributes.of({class:"cm-lineWrapping"}),xE.announce=$_.define();const bE=4096,_E={};class wE{constructor(e,t,n,i,o,r){this.from=e,this.to=t,this.dir=n,this.isolates=i,this.fresh=o,this.order=r}static update(e,t){if(t.empty&&!e.some((e=>e.fresh)))return e;let n=[],i=e.length?e[e.length-1].dir:IC.LTR;for(let o=Math.max(0,e.length-10);o<e.length;o++){let r=e[o];r.dir!=i||t.touchesRange(r.from,r.to)||n.push(new wE(t.mapPos(r.from,1),t.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return n}}function CE(e,t,n){for(let i=e.state.facet(t),o=i.length-1;o>=0;o--){let t=i[o],r="function"==typeof t?t(e):t;r&&vC(r,n)}return n}const OE=cC.mac?"mac":cC.windows?"win":cC.linux?"linux":"key";function kE(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}const EE=v_.default(xE.domEventHandlers({keydown:(e,t)=>function(e,t,n,i){AE=t;let o=function(e){var t=!(xw&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||bw&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?yw:vw)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(t),r=Vb(o,0),s=zb(r)==o.length&&" "!=o,a="",l=!1,c=!1,u=!1;TE&&TE.view==n&&TE.scope==i&&(a=TE.prefix+" ",lk.indexOf(t.keyCode)<0&&(c=!0,TE=null));let h,d,p=new Set,f=e=>{if(e){for(let t of e.run)if(!p.has(t)&&(p.add(t),t(n)))return e.stopPropagation&&(u=!0),!0;e.preventDefault&&(e.stopPropagation&&(u=!0),c=!0)}return!1},g=e[i];g&&(f(g[a+kE(o,t,!s)])?l=!0:s&&(t.altKey||t.metaKey||t.ctrlKey)&&!(cC.windows&&t.ctrlKey&&t.altKey)&&(h=vw[t.keyCode])&&h!=o?(f(g[a+kE(h,t,!0)])||t.shiftKey&&(d=yw[t.keyCode])!=o&&d!=h&&f(g[a+kE(d,t,!1)]))&&(l=!0):s&&t.shiftKey&&f(g[a+kE(o,t,!0)])&&(l=!0),!l&&f(g._any)&&(l=!0));c&&(l=!0);l&&u&&t.stopPropagation();return AE=null,l}(function(e){let t=e.facet(SE),n=RE.get(t);n||RE.set(t,n=function(e,t=OE){let n=Object.create(null),i=Object.create(null),o=(e,t)=>{let n=i[e];if(null==n)i[e]=t;else if(n!=t)throw new Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},r=(e,i,r,s,a)=>{var l,c;let u=n[e]||(n[e]=Object.create(null)),h=i.split(/ (?!$)/).map((e=>function(e,t){const n=e.split(/-(?!$)/);let i,o,r,s,a=n[n.length-1];"Space"==a&&(a=" ");for(let e=0;e<n.length-1;++e){const a=n[e];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))i=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))r=!0;else{if(!/^mod$/i.test(a))throw new Error("Unrecognized modifier name: "+a);"mac"==t?s=!0:o=!0}}return i&&(a="Alt-"+a),o&&(a="Ctrl-"+a),s&&(a="Meta-"+a),r&&(a="Shift-"+a),a}(e,t)));for(let t=1;t<h.length;t++){let n=h.slice(0,t).join(" ");o(n,!0),u[n]||(u[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let i=TE={view:t,prefix:n,scope:e};return setTimeout((()=>{TE==i&&(TE=null)}),ME),!0}]})}let d=h.join(" ");o(d,!1);let p=u[d]||(u[d]={preventDefault:!1,stopPropagation:!1,run:(null===(c=null===(l=u._any)||void 0===l?void 0:l.run)||void 0===c?void 0:c.slice())||[]});r&&p.run.push(r),s&&(p.preventDefault=!0),a&&(p.stopPropagation=!0)};for(let i of e){let e=i.scope?i.scope.split(" "):["editor"];if(i.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:o}=i;for(let t in e)e[t].run.push((e=>o(e,AE)))}let o=i[t]||i.key;if(o)for(let t of e)r(t,o,i.run,i.preventDefault,i.stopPropagation),i.shift&&r(t,"Shift-"+o,i.shift,i.preventDefault,i.stopPropagation)}return n}(t.reduce(((e,t)=>e.concat(t)),[])));return n}(t.state),e,t,"editor")})),SE=o_.define({enables:EE}),RE=new WeakMap;let TE=null;const ME=4e3;let AE=null;const PE={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};!(cC.ios&&cC.webkit&&cC.webkit_version<534)&&(PE[".cm-line"].caretColor=PE[".cm-content"].caretColor="transparent !important");class DE extends wC{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):"function"==typeof this.content?this.content(e):this.content.cloneNode(!0)),"string"==typeof this.content?t.setAttribute("aria-label","placeholder "+this.content):t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?Ew(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),i=Pw(t[0],"rtl"!=n.direction),o=parseInt(n.lineHeight);return i.bottom-i.top>1.5*o?{left:i.left,right:i.right,top:i.top,bottom:i.top+o}:i}ignoreEvent(){return!1}}function $E(e){return bO.fromClass(class{constructor(t){this.view=t,this.placeholder=e?OC.set([OC.widget({widget:new DE(e),side:1}).range(0)]):OC.none}get decorations(){return this.view.state.doc.length?OC.none:this.placeholder}},{decorations:e=>e.decorations})}const jE="-10000px";class IE{constructor(e,t,n,i){this.facet=t,this.createTooltipView=n,this.removeTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter((e=>e));let o=null;this.tooltipViews=this.tooltips.map((e=>o=n(e,o)))}update(e,t){var n;let i=e.state.facet(this.facet),o=i.filter((e=>e));if(i===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let r=[],s=t?[]:null;for(let n=0;n<o.length;n++){let i=o[n],a=-1;if(i){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==i.create&&(a=e)}if(a<0)r[n]=this.createTooltipView(i,n?r[n-1]:null),s&&(s[n]=!!i.above);else{let i=r[n]=this.tooltipViews[a];s&&(s[n]=t[a]),i.update&&i.update(e)}}}for(let e of this.tooltipViews)r.indexOf(e)<0&&(this.removeTooltipView(e),null===(n=e.destroy)||void 0===n||n.call(e));return t&&(s.forEach(((e,n)=>t[n]=e)),t.length=s.length),this.input=i,this.tooltips=o,this.tooltipViews=r,!0}}function BE(e){let{win:t}=e;return{top:0,left:0,bottom:t.innerHeight,right:t.innerWidth}}const LE=o_.define({combine:e=>{var t,n,i;return{position:cC.ios?"absolute":(null===(t=e.find((e=>e.position)))||void 0===t?void 0:t.position)||"fixed",parent:(null===(n=e.find((e=>e.parent)))||void 0===n?void 0:n.parent)||null,tooltipSpace:(null===(i=e.find((e=>e.tooltipSpace)))||void 0===i?void 0:i.tooltipSpace)||BE}}}),NE=new WeakMap,qE=bO.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(LE);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver((()=>this.measureSoon())):null,this.manager=new IE(e,QE,((e,t)=>this.createTooltip(e,t)),(e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()})),this.above=this.manager.tooltips.map((e=>!!e.above)),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver((e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()}),{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout((()=>{this.measureTimeout=-1,this.maybeMeasure()}),50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,i=e.state.facet(LE);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),i=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=jE,n.dom.style.left="0px",this.container.insertBefore(n.dom,i),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t);this.parent&&this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(n=this.intersectionObserver)||void 0===n||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(cC.gecko)n=e.offsetParent!=this.container.ownerDocument.body;else if(e.style.top==jE&&"0px"==e.style.left){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}}if(n||"absolute"==this.position)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),o=MO(this.view);return{visible:{left:i.left+o.left,top:i.top+o.top,right:i.right-o.right,bottom:i.bottom-o.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map(((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)})),size:this.manager.tooltipViews.map((({dom:e})=>e.getBoundingClientRect())),space:this.view.state.facet(LE).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let e of this.manager.tooltipViews)e.dom.style.position="absolute"}let{visible:n,space:i,scaleX:o,scaleY:r}=e,s=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:u}=c,h=e.pos[a],d=e.size[a];if(!h||!1!==l.clip&&(h.bottom<=Math.max(n.top,i.top)||h.top>=Math.min(n.bottom,i.bottom)||h.right<Math.max(n.left,i.left)-.1||h.left>Math.min(n.right,i.right)+.1)){u.style.top=jE;continue}let p=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,f=p?7:0,g=d.right-d.left,m=null!==(t=NE.get(c))&&void 0!==t?t:d.bottom-d.top,v=c.offset||zE,y=this.view.textDirection==IC.LTR,x=d.width>i.right-i.left?y?i.left:i.right-d.width:y?Math.max(i.left,Math.min(h.left-(p?14:0)+v.x,i.right-g)):Math.min(Math.max(i.left,h.left-g+(p?14:0)-v.x),i.right-g),b=this.above[a];!l.strictSide&&(b?h.top-m-f-v.y<i.top:h.bottom+m+f+v.y>i.bottom)&&b==i.bottom-h.bottom>h.top-i.top&&(b=this.above[a]=!b);let _=(b?h.top-i.top:i.bottom-h.bottom)-f;if(_<m&&!1!==c.resize){if(_<this.view.defaultLineHeight){u.style.top=jE;continue}NE.set(c,m),u.style.height=(m=_)/r+"px"}else u.style.height&&(u.style.height="");let w=b?h.top-m-f-v.y:h.bottom+f+v.y,C=x+g;if(!0!==c.overlap)for(let e of s)e.left<C&&e.right>x&&e.top<w+m&&e.bottom>w&&(w=b?e.top-m-2-f:e.bottom+f+2);if("absolute"==this.position?(u.style.top=(w-e.parent.top)/r+"px",VE(u,(x-e.parent.left)/o)):(u.style.top=w/r+"px",VE(u,x/o)),p){let e=h.left+(y?v.x:-v.x)-(x+14-7);p.style.left=e/o+"px"}!0!==c.overlap&&s.push({left:x,top:w,right:C,bottom:w+m}),u.classList.toggle("cm-tooltip-above",b),u.classList.toggle("cm-tooltip-below",!b),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=jE}},{eventObservers:{scroll(){this.maybeMeasure()}}});function VE(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const FE=xE.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"}}}),zE={x:0,y:0},QE=o_.define({enables:[qE,FE]}),HE=o_.define({combine:e=>e.reduce(((e,t)=>e.concat(t)),[])});class WE{static create(e){return new WE(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new IE(e,HE,((e,t)=>this.createHostedView(e,t)),(e=>e.dom.remove()))}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)null===(e=t.destroy)||void 0===e||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let i=n[e];if(void 0!==i)if(void 0===t)t=i;else if(t!==i)return}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const UE=QE.compute([HE],(e=>{let t=e.facet(HE);return 0===t.length?null:{pos:Math.min(...t.map((e=>e.pos))),end:Math.max(...t.map((e=>{var t;return null!==(t=e.end)&&void 0!==t?t:e.pos}))),create:WE.create,above:t[0].above,arrow:t.some((e=>e.arrow))}}));class XE{constructor(e,t,n,i,o){this.view=e,this.source=t,this.field=n,this.setHover=i,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;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.nearest(t.target);if(!n)return;let i,o=1;if(n instanceof dC)i=n.posAtStart;else{if(i=e.posAtCoords(t),null==i)return;let n=e.coordsAtPos(i);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let r=e.bidiSpans(e.state.doc.lineAt(i)).find((e=>e.from<=i&&e.to>=i)),s=r&&r.dir==IC.RTL?-1:1;o=t.x<n.left?-s:s}let r=this.source(e,i,o);if(null==r?void 0:r.then){let t=this.pending={pos:i};r.then((n=>{this.pending==t&&(this.pending=null,!n||Array.isArray(n)&&!n.length||e.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])}))}),(t=>mO(e.state,t,"hover tooltip")))}else!r||Array.isArray(r)&&!r.length||e.dispatch({effects:this.setHover.of(Array.isArray(r)?r:[r])})}get tooltip(){let e=this.view.plugin(qE),t=e?e.manager.tooltips.findIndex((e=>e.create==WE.create)):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:o}=this;if(i.length&&o&&!function(e,t){let n,{left:i,right:o,top:r,bottom:s}=e.getBoundingClientRect();if(n=e.querySelector(".cm-tooltip-arrow")){let e=n.getBoundingClientRect();r=Math.min(e.top,r),s=Math.max(e.bottom,s)}return t.clientX>=i-KE&&t.clientX<=o+KE&&t.clientY>=r-KE&&t.clientY<=s+KE}(o.dom,e)||this.pending){let{pos:o}=i[0]||this.pending,r=null!==(n=null===(t=i[0])||void 0===t?void 0:t.end)&&void 0!==n?n:o;(o==r?this.view.posAtCoords(this.lastMove)==o:function(e,t,n,i,o,r){let s=e.scrollDOM.getBoundingClientRect(),a=e.documentTop+e.documentPadding.top+e.contentHeight;if(s.left>i||s.right<i||s.top>o||Math.min(s.bottom,a)<o)return!1;let l=e.posAtCoords({x:i,y:o},!1);return l>=t&&l<=n}(this.view,o,r,e.clientX,e.clientY))||(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const KE=4;function GE(e,t={}){let n=$_.define(),i=h_.define({create:()=>[],update(e,i){if(e.length&&(t.hideOnChange&&(i.docChanged||i.selection)?e=[]:t.hideOn&&(e=e.filter((e=>!t.hideOn(i,e)))),i.docChanged)){let t=[];for(let n of e){let e=i.changes.mapPos(n.pos,-1,Hb.TrackDel);if(null!=e){let o=Object.assign(Object.create(null),n);o.pos=e,null!=o.end&&(o.end=i.changes.mapPos(o.end)),t.push(o)}}e=t}for(let t of i.effects)t.is(n)&&(e=t.value),t.is(ZE)&&(e=[]);return e},provide:e=>HE.from(e)});return{active:i,extension:[i,bO.define((o=>new XE(o,e,i,n,t.hoverTime||300))),UE]}}function YE(e,t){let n=e.plugin(qE);if(!n)return null;let i=n.manager.tooltips.indexOf(t);return i<0?null:n.manager.tooltipViews[i]}const ZE=$_.define(),JE=o_.define({combine(e){let t,n;for(let i of e)t=t||i.topContainer,n=n||i.bottomContainer;return{topContainer:t,bottomContainer:n}}}),eS=bO.fromClass(class{constructor(e){this.input=e.state.facet(iS),this.specs=this.input.filter((e=>e)),this.panels=this.specs.map((t=>t(e)));let t=e.state.facet(JE);this.top=new tS(e,!0,t.topContainer),this.bottom=new tS(e,!1,t.bottomContainer),this.top.sync(this.panels.filter((e=>e.top))),this.bottom.sync(this.panels.filter((e=>!e.top)));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(e){let t=e.state.facet(JE);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new tS(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new tS(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(iS);if(n!=this.input){let t=n.filter((e=>e)),i=[],o=[],r=[],s=[];for(let n of t){let t,a=this.specs.indexOf(n);a<0?(t=n(e.view),s.push(t)):(t=this.panels[a],t.update&&t.update(e)),i.push(t),(t.top?o:r).push(t)}this.specs=t,this.panels=i,this.top.sync(o),this.bottom.sync(r);for(let e of s)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>xE.scrollMargins.of((t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}}))});class tS{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=nS(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=nS(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 nS(e){let t=e.nextSibling;return e.remove(),t}const iS=o_.define({enables:eS});class oS extends X_{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}oS.prototype.elementClass="",oS.prototype.toDOM=void 0,oS.prototype.mapMode=Hb.TrackBefore,oS.prototype.startSide=oS.prototype.endSide=-1,oS.prototype.point=!0;const rS=1024;let sS=0;class aS{constructor(e,t){this.from=e,this.to=t}}class lS{constructor(e={}){this.id=sS++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=hS.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}lS.closedBy=new lS({deserialize:e=>e.split(" ")}),lS.openedBy=new lS({deserialize:e=>e.split(" ")}),lS.group=new lS({deserialize:e=>e.split(" ")}),lS.isolate=new lS({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),lS.contextHash=new lS({perNode:!0}),lS.lookAhead=new lS({perNode:!0}),lS.mounted=new lS({perNode:!0});class cS{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[lS.mounted.id]}}const uS=Object.create(null);class hS{constructor(e,t,n,i=0){this.name=e,this.props=t,this.id=n,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):uS,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),i=new hS(e.name||"",t,e.id,n);if(e.props)for(let n of e.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}return i}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(lS.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let i of n.split(" "))t[i]=e[n];return e=>{for(let n=e.prop(lS.group),i=-1;i<(n?n.length:0);i++){let o=t[i<0?e.name:n[i]];if(o)return o}}}}hS.none=new hS("",Object.create(null),0,8);class dS{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let i=null;for(let t of e){let e=t(n);e&&(i||(i=Object.assign({},n.props)),i[e[0].id]=e[1])}t.push(i?new hS(n.name,i,n.id,n.flags):n)}return new dS(t)}}const pS=new WeakMap,fS=new WeakMap;var gS;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(gS||(gS={}));class mS{constructor(e,t,n,i,o){if(this.type=e,this.children=t,this.positions=n,this.length=i,this.props=null,o&&o.length){this.props=Object.create(null);for(let[e,t]of o)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=cS.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new TS(this.topNode,e)}cursorAt(e,t=0,n=0){let i=pS.get(this)||this.topNode,o=new TS(i);return o.moveTo(e,t),pS.set(this,o._tree),o}get topNode(){return new wS(this,0,0,null)}resolve(e,t=0){let n=bS(pS.get(this)||this.topNode,e,t,!1);return pS.set(this,n),n}resolveInner(e,t=0){let n=bS(fS.get(this)||this.topNode,e,t,!0);return fS.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let i=e.resolveInner(t,n),o=null;for(let e=i instanceof wS?i:i.context.parent;e;e=e.parent)if(e.index<0){let r=e.parent;(o||(o=[i])).push(r.resolve(t,n)),e=r}else{let r=cS.get(e.tree);if(r&&r.overlay&&r.overlay[0].from<=t&&r.overlay[r.overlay.length-1].to>=t){let s=new wS(r.tree,r.overlay[0].from+e.from,-1,e);(o||(o=[i])).push(bS(s,t,n,!1))}}return o?SS(o):i}(this,e,t)}iterate(e){let{enter:t,leave:n,from:i=0,to:o=this.length}=e,r=e.mode||0,s=(r&gS.IncludeAnonymous)>0;for(let e=this.cursor(r|gS.IncludeAnonymous);;){let r=!1;if(e.from<=o&&e.to>=i&&(!s&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;r=!0}for(;r&&n&&(s||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;r=!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:DS(hS.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,n)=>new mS(this.type,e,t,n,this.propValues)),e.makeTree||((e,t,n)=>new mS(hS.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:i,maxBufferLength:o=rS,reused:r=[],minRepeatType:s=i.types.length}=e,a=Array.isArray(n)?new vS(n,n.length):n,l=i.types,c=0,u=0;function h(e,t,n,y,x,b){let{id:_,start:w,end:C,size:O}=a,k=u,E=c;for(;O<0;){if(a.next(),-1==O){let t=r[_];return n.push(t),void y.push(w-e)}if(-3==O)return void(c=_);if(-4==O)return void(u=_);throw new RangeError(`Unrecognized record size: ${O}`)}let S,R,T=l[_],M=w-e;if(C-w<=o&&(R=m(a.pos-t,x))){let t=new Uint16Array(R.size-R.skip),n=a.pos-R.size,o=t.length;for(;a.pos>n;)o=v(R.start,t,o);S=new yS(t,C-R.start,i),M=R.start-e}else{let e=a.pos-O;a.next();let t=[],n=[],i=_>=s?_:-1,r=0,l=C;for(;a.pos>e;)i>=0&&a.id==i&&a.size>=0?(a.end<=l-o&&(f(t,n,w,r,a.end,l,i,k,E),r=t.length,l=a.end),a.next()):b>2500?d(w,e,t,n):h(w,e,t,n,i,b+1);if(i>=0&&r>0&&r<t.length&&f(t,n,w,r,w,l,i,k,E),t.reverse(),n.reverse(),i>-1&&r>0){let e=p(T,E);S=DS(T,t,n,0,t.length,0,C-w,e,e)}else S=g(T,t,n,C-w,k-C,E)}n.push(S),y.push(M)}function d(e,t,n,r){let s=[],l=0,c=-1;for(;a.pos>t;){let{id:e,start:t,end:n,size:i}=a;if(i>4)a.next();else{if(c>-1&&t<c)break;c<0&&(c=n-o),s.push(e,t,n),l++,a.next()}}if(l){let t=new Uint16Array(4*l),o=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-o,t[n++]=s[e+2]-o,t[n++]=n;n.push(new yS(t,s[2]-o,i)),r.push(o-e)}}function p(e,t){return(n,i,o)=>{let r,s,a=0,l=n.length-1;if(l>=0&&(r=n[l])instanceof mS){if(!l&&r.type==e&&r.length==o)return r;(s=r.prop(lS.lookAhead))&&(a=i[l]+r.length+s)}return g(e,n,i,o,a,t)}}function f(e,t,n,o,r,s,a,l,c){let u=[],h=[];for(;e.length>o;)u.push(e.pop()),h.push(t.pop()+n-r);e.push(g(i.types[a],u,h,s-r,l-s,c)),t.push(r-n)}function g(e,t,n,i,o,r,s){if(r){let e=[lS.contextHash,r];s=s?[e].concat(s):[e]}if(o>25){let e=[lS.lookAhead,o];s=s?[e].concat(s):[e]}return new mS(e,t,n,i,s)}function m(e,t){let n=a.fork(),i=0,r=0,l=0,c=n.end-o,u={size:0,start:0,skip:0};e:for(let o=n.pos-e;n.pos>o;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=r,u.skip=l,l+=4,i+=4,n.next();continue}let a=n.pos-e;if(e<0||a<o||n.start<c)break;let h=n.id>=s?4:0,d=n.start;for(n.next();n.pos>a;){if(n.size<0){if(-3!=n.size)break e;h+=4}else n.id>=s&&(h+=4);n.next()}r=d,i+=e,l+=h}return(t<0||i==e)&&(u.size=i,u.start=r,u.skip=l),u.size>4?u:void 0}function v(e,t,n){let{id:i,start:o,end:r,size:l}=a;if(a.next(),l>=0&&i<s){let s=n;if(l>4){let i=a.pos-(l-4);for(;a.pos>i;)n=v(e,t,n)}t[--n]=s,t[--n]=r-e,t[--n]=o-e,t[--n]=i}else-3==l?c=i:-4==l&&(u=i);return n}let y=[],x=[];for(;a.pos>0;)h(e.start||0,e.bufferStart||0,y,x,-1,0);let b=null!==(t=e.length)&&void 0!==t?t:y.length?x[0]+y[0].length:0;return new mS(l[e.topID],y.reverse(),x.reverse(),b)}(e)}}mS.empty=new mS(hS.none,[],[],0);class vS{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 vS(this.buffer,this.index)}}class yS{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return hS.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],i=this.set.types[t],o=i.name;if(/\W/.test(o)&&!i.isError&&(o=JSON.stringify(o)),n==(e+=4))return o;let r=[];for(;e<n;)r.push(this.childString(e)),e=this.buffer[e+3];return o+"("+r.join(",")+")"}findChild(e,t,n,i,o){let{buffer:r}=this,s=-1;for(let a=e;a!=t&&!(xS(o,i,r[a+1],r[a+2])&&(s=a,n>0));a=r[a+3]);return s}slice(e,t,n){let i=this.buffer,o=new Uint16Array(t-e),r=0;for(let s=e,a=0;s<t;){o[a++]=i[s++],o[a++]=i[s++]-n;let t=o[a++]=i[s++]-n;o[a++]=i[s++]-e,r=Math.max(r,t)}return new yS(o,r,this.set)}}function xS(e,t,n,i){switch(e){case-2:return n<t;case-1:return i>=t&&n<t;case 0:return n<t&&i>t;case 1:return n<=t&&i>t;case 2:return i>t;case 4:return!0}}function bS(e,t,n,i){for(var o;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!i&&e instanceof wS&&e.index<0?null:e.parent;if(!t)return e;e=t}let r=i?0:gS.IgnoreOverlays;if(i)for(let i=e,s=i.parent;s;i=s,s=i.parent)i instanceof wS&&i.index<0&&(null===(o=s.enter(t,n,r))||void 0===o?void 0:o.from)!=i.from&&(e=s);for(;;){let i=e.enter(t,n,r);if(!i)return e;e=i}}class _S{cursor(e=0){return new TS(this,e)}getChild(e,t=null,n=null){let i=CS(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return CS(this,e,t,n)}resolve(e,t=0){return bS(this,e,t,!1)}resolveInner(e,t=0){return bS(this,e,t,!0)}matchContext(e){return OS(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class wS extends _S{constructor(e,t,n,i){super(),this._tree=e,this.from=t,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,i,o=0){for(let r=this;;){for(let{children:s,positions:a}=r._tree,l=t>0?s.length:-1;e!=l;e+=t){let l=s[e],c=a[e]+r.from;if(xS(i,n,c,c+l.length))if(l instanceof yS){if(o&gS.ExcludeBuffers)continue;let s=l.findChild(0,l.buffer.length,t,n-c,i);if(s>-1)return new ES(new kS(r,l,e,c),null,s)}else if(o&gS.IncludeAnonymous||!l.type.isAnonymous||MS(l)){let s;if(!(o&gS.IgnoreMounts)&&(s=cS.get(l))&&!s.overlay)return new wS(s.tree,c,e,r);let a=new wS(l,c,e,r);return o&gS.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?l.children.length-1:0,t,n,i)}}if(o&gS.IncludeAnonymous||!r.type.isAnonymous)return null;if(e=r.index>=0?r.index+t:t<0?-1:r._parent._tree.children.length,r=r._parent,!r)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)}enter(e,t,n=0){let i;if(!(n&gS.IgnoreOverlays)&&(i=cS.get(this._tree))&&i.overlay){let n=e-this.from;for(let{from:e,to:o}of i.overlay)if((t>0?e<=n:e<n)&&(t<0?o>=n:o>n))return new wS(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function CS(e,t,n,i){let o=e.cursor(),r=[];if(!o.firstChild())return r;if(null!=n)for(let e=!1;!e;)if(e=o.type.is(n),!o.nextSibling())return r;for(;;){if(null!=i&&o.type.is(i))return r;if(o.type.is(t)&&r.push(o.node),!o.nextSibling())return null==i?r:[]}}function OS(e,t,n=t.length-1){for(let i=e;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[n]&&t[n]!=i.name)return!1;n--}}return!0}class kS{constructor(e,t,n,i){this.parent=e,this.buffer=t,this.index=n,this.start=i}}class ES extends _S{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,n);return o<0?null:new ES(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)}enter(e,t,n=0){if(n&gS.ExcludeBuffers)return null;let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return o<0?null:new ES(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 ES(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 ES(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,i=this.index+4,o=n.buffer[this.index+3];if(o>i){let r=n.buffer[this.index+1];e.push(n.slice(i,o,r)),t.push(0)}return new mS(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function SS(e){if(!e.length)return null;let t=0,n=e[0];for(let i=1;i<e.length;i++){let o=e[i];(o.from>n.from||o.to<n.to)&&(n=o,t=i)}let i=n instanceof wS&&n.index<0?null:n.parent,o=e.slice();return i?o[t]=i:o.splice(t,1),new RS(o,n)}class RS{constructor(e,t){this.heads=e,this.node=t}get next(){return SS(this.heads)}}class TS{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof wS)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return!!e&&(e instanceof wS?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:i}=this.buffer,o=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,n);return!(o<0)&&(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,n=this.mode){return this.buffer?!(n&gS.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&gS.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&gS.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(i.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=i)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let i=t+e,o=e<0?-1:n._tree.children.length;i!=o;i+=e){let e=n._tree.children[i];if(this.mode&gS.IncludeAnonymous||e instanceof yS||!e.type.isAnonymous||MS(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let i=this.index,o=this.stack.length;o>=0;){for(let r=e;r;r=r._parent)if(r.index==i){if(i==this.index)return r;t=r,n=o+1;break e}i=this.stack[--o]}for(let e=n;e<this.stack.length;e++)t=new ES(this.buffer,t,this.stack[e]);return this.bufferNode=new ES(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let i=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&t&&t(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(e){if(!this.buffer)return OS(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let i=e.length-1,o=this.stack.length-1;i>=0;o--){if(o<0)return OS(this._tree,e,i);let r=n[t.buffer[this.stack[o]]];if(!r.isAnonymous){if(e[i]&&e[i]!=r.name)return!1;i--}}return!0}}function MS(e){return e.children.some((e=>e instanceof yS||!e.type.isAnonymous||MS(e)))}const AS=new WeakMap;function PS(e,t){if(!e.isAnonymous||t instanceof yS||t.type!=e)return 1;let n=AS.get(t);if(null==n){n=1;for(let i of t.children){if(i.type!=e||!(i instanceof mS)){n=1;break}n+=PS(e,i)}AS.set(t,n)}return n}function DS(e,t,n,i,o,r,s,a,l){let c=0;for(let n=i;n<o;n++)c+=PS(e,t[n]);let u=Math.ceil(1.5*c/8),h=[],d=[];return function t(n,i,o,s,a){for(let c=o;c<s;){let o=c,p=i[c],f=PS(e,n[c]);for(c++;c<s;c++){let t=PS(e,n[c]);if(f+t>=u)break;f+=t}if(c==o+1){if(f>u){let e=n[o];t(e.children,e.positions,0,e.children.length,i[o]+a);continue}h.push(n[o])}else{let t=i[c-1]+n[c-1].length-p;h.push(DS(e,n,i,o,c,p,t,null,l))}d.push(p+a-r)}}(t,n,i,o,0),(a||l)(h,d,s)}class $S{constructor(e,t,n,i,o=!1,r=!1){this.from=e,this.to=t,this.tree=n,this.offset=i,this.open=(o?1:0)|(r?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let i=[new $S(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&i.push(n);return i}static applyChanges(e,t,n=128){if(!t.length)return e;let i=[],o=1,r=e.length?e[0]:null;for(let s=0,a=0,l=0;;s++){let c=s<t.length?t[s]:null,u=c?c.fromA:1e9;if(u-a>=n)for(;r&&r.from<u;){let t=r;if(a>=t.from||u<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,u)-l;t=e>=n?null:new $S(e,n,t.tree,t.offset+l,s>0,!!c)}if(t&&i.push(t),r.to>u)break;r=o<e.length?e[o++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return i}}class jS{startParse(e,t,n){return"string"==typeof e&&(e=new IS(e)),n=n?n.length?n.map((e=>new aS(e.from,e.to))):[new aS(0,0)]:[new aS(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let i=this.startParse(e,t,n);for(;;){let e=i.advance();if(e)return e}}}class IS{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new lS({perNode:!0});let BS=0;class LS{constructor(e,t,n,i){this.name=e,this.set=t,this.base=n,this.modified=i,this.id=BS++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n="string"==typeof e?e:"?";if(e instanceof LS&&(t=e),null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let i=new LS(n,[],null,[]);if(i.set.push(i),t)for(let e of t.set)i.set.push(e);return i}static defineModifier(e){let t=new qS(e);return e=>e.modified.indexOf(t)>-1?e:qS.get(e.base||e,e.modified.concat(t).sort(((e,t)=>e.id-t.id)))}}let NS=0;class qS{constructor(e){this.name=e,this.instances=[],this.id=NS++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find((n=>n.base==e&&function(e,t){return e.length==t.length&&e.every(((e,n)=>e==t[n]))}(t,n.modified)));if(n)return n;let i=[],o=new LS(e.name,i,e,t);for(let e of t)e.instances.push(o);let r=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let i=0,o=t.length;i<o;i++)t.push(t[i].concat(e[n]));return t.sort(((e,t)=>t.length-e.length))}(t);for(let t of e.set)if(!t.modified.length)for(let e of r)i.push(qS.get(t,e));return o}}function VS(e){let t=Object.create(null);for(let n in e){let i=e[n];Array.isArray(i)||(i=[i]);for(let e of n.split(" "))if(e){let n=[],o=2,r=e;for(let t=0;;){if("..."==r&&t>0&&t+3==e.length){o=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!i)throw new RangeError("Invalid path: "+e);if(n.push("*"==i[0]?"":'"'==i[0][0]?JSON.parse(i[0]):i[0]),t+=i[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){o=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);r=e.slice(t)}let s=n.length-1,a=n[s];if(!a)throw new RangeError("Invalid path: "+e);let l=new zS(i,o,s>0?n.slice(0,s):null);t[a]=l.sort(t[a])}}return FS.add(t)}const FS=new lS;class zS{constructor(e,t,n,i){this.tags=e,this.mode=t,this.context=n,this.next=i}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function QS(e,t){let n=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)n[e.id]=t.class;else n[t.tag.id]=t.class;let{scope:i,all:o=null}=t||{};return{style:e=>{let t=o;for(let i of e)for(let e of i.set){let i=n[e.id];if(i){t=t?t+" "+i:i;break}}return t},scope:i}}function HS(e,t,n,i=0,o=e.length){let r=new WS(i,Array.isArray(t)?t:[t],n);r.highlightRange(e.cursor(),i,o,"",r.highlighters),r.flush(o)}zS.empty=new zS([],2,null);class WS{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,i,o){let{type:r,from:s,to:a}=e;if(s>=n||a<=t)return;r.isTop&&(o=this.highlighters.filter((e=>!e.scope||e.scope(r))));let l=i,c=function(e){let t=e.type.prop(FS);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||zS.empty,u=function(e,t){let n=null;for(let i of e){let e=i.style(t);e&&(n=n?n+" "+e:e)}return n}(o,c.tags);if(u&&(l&&(l+=" "),l+=u,1==c.mode&&(i+=(i?" ":"")+u)),this.startSpan(Math.max(t,s),l),c.opaque)return;let h=e.tree&&e.tree.prop(lS.mounted);if(h&&h.overlay){let r=e.node.enter(h.overlay[0].from+s,1),c=this.highlighters.filter((e=>!e.scope||e.scope(h.tree.type))),u=e.firstChild();for(let d=0,p=s;;d++){let f=d<h.overlay.length?h.overlay[d]:null,g=f?f.from+s:a,m=Math.max(t,p),v=Math.min(n,g);if(m<v&&u)for(;e.from<v&&(this.highlightRange(e,m,v,i,o),this.startSpan(Math.min(v,e.to),l),!(e.to>=g)&&e.nextSibling()););if(!f||g>n)break;p=f.to+s,p>t&&(this.highlightRange(r.cursor(),Math.max(t,f.from+s),Math.min(n,p),"",c),this.startSpan(Math.min(n,p),l))}u&&e.parent()}else if(e.firstChild()){h&&(i="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,i,o),this.startSpan(Math.min(n,e.to),l)}}while(e.nextSibling());e.parent()}}}const US=LS.define,XS=US(),KS=US(),GS=US(KS),YS=US(KS),ZS=US(),JS=US(ZS),eR=US(ZS),tR=US(),nR=US(tR),iR=US(),oR=US(),rR=US(),sR=US(rR),aR=US(),lR={comment:XS,lineComment:US(XS),blockComment:US(XS),docComment:US(XS),name:KS,variableName:US(KS),typeName:GS,tagName:US(GS),propertyName:YS,attributeName:US(YS),className:US(KS),labelName:US(KS),namespace:US(KS),macroName:US(KS),literal:ZS,string:JS,docString:US(JS),character:US(JS),attributeValue:US(JS),number:eR,integer:US(eR),float:US(eR),bool:US(ZS),regexp:US(ZS),escape:US(ZS),color:US(ZS),url:US(ZS),keyword:iR,self:US(iR),null:US(iR),atom:US(iR),unit:US(iR),modifier:US(iR),operatorKeyword:US(iR),controlKeyword:US(iR),definitionKeyword:US(iR),moduleKeyword:US(iR),operator:oR,derefOperator:US(oR),arithmeticOperator:US(oR),logicOperator:US(oR),bitwiseOperator:US(oR),compareOperator:US(oR),updateOperator:US(oR),definitionOperator:US(oR),typeOperator:US(oR),controlOperator:US(oR),punctuation:rR,separator:US(rR),bracket:sR,angleBracket:US(sR),squareBracket:US(sR),paren:US(sR),brace:US(sR),content:tR,heading:nR,heading1:US(nR),heading2:US(nR),heading3:US(nR),heading4:US(nR),heading5:US(nR),heading6:US(nR),contentSeparator:US(tR),list:US(tR),quote:US(tR),emphasis:US(tR),strong:US(tR),link:US(tR),monospace:US(tR),strikethrough:US(tR),inserted:US(),deleted:US(),changed:US(),invalid:US(),meta:aR,documentMeta:US(aR),annotation:US(aR),processingInstruction:US(aR),definition:LS.defineModifier("definition"),constant:LS.defineModifier("constant"),function:LS.defineModifier("function"),standard:LS.defineModifier("standard"),local:LS.defineModifier("local"),special:LS.defineModifier("special")};for(let e in lR){let t=lR[e];t instanceof LS&&(t.name=e)}var cR;QS([{tag:lR.link,class:"tok-link"},{tag:lR.heading,class:"tok-heading"},{tag:lR.emphasis,class:"tok-emphasis"},{tag:lR.strong,class:"tok-strong"},{tag:lR.keyword,class:"tok-keyword"},{tag:lR.atom,class:"tok-atom"},{tag:lR.bool,class:"tok-bool"},{tag:lR.url,class:"tok-url"},{tag:lR.labelName,class:"tok-labelName"},{tag:lR.inserted,class:"tok-inserted"},{tag:lR.deleted,class:"tok-deleted"},{tag:lR.literal,class:"tok-literal"},{tag:lR.string,class:"tok-string"},{tag:lR.number,class:"tok-number"},{tag:[lR.regexp,lR.escape,lR.special(lR.string)],class:"tok-string2"},{tag:lR.variableName,class:"tok-variableName"},{tag:lR.local(lR.variableName),class:"tok-variableName tok-local"},{tag:lR.definition(lR.variableName),class:"tok-variableName tok-definition"},{tag:lR.special(lR.variableName),class:"tok-variableName2"},{tag:lR.definition(lR.propertyName),class:"tok-propertyName tok-definition"},{tag:lR.typeName,class:"tok-typeName"},{tag:lR.namespace,class:"tok-namespace"},{tag:lR.className,class:"tok-className"},{tag:lR.macroName,class:"tok-macroName"},{tag:lR.propertyName,class:"tok-propertyName"},{tag:lR.operator,class:"tok-operator"},{tag:lR.comment,class:"tok-comment"},{tag:lR.meta,class:"tok-meta"},{tag:lR.invalid,class:"tok-invalid"},{tag:lR.punctuation,class:"tok-punctuation"}]);const uR=new lS;const hR=new lS;class dR{constructor(e,t,n=[],i=""){this.data=e,this.name=i,W_.prototype.hasOwnProperty("tree")||Object.defineProperty(W_.prototype,"tree",{get(){return gR(this)}}),this.parser=t,this.extension=[OR.of(this),W_.languageData.of(((e,t,n)=>{let i=pR(e,t,n),o=i.type.prop(uR);if(!o)return[];let r=e.facet(o),s=i.type.prop(hR);if(s){let o=i.resolve(t-i.from,n);for(let t of s)if(t.test(o,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(r)}}return r}))].concat(n)}isActiveAt(e,t,n=-1){return pR(e,t,n).type.prop(uR)==this.data}findRegions(e){let t=e.facet(OR);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(e,t)=>{if(e.prop(uR)==this.data)return void n.push({from:t,to:t+e.length});let o=e.prop(lS.mounted);if(o){if(o.tree.prop(uR)==this.data){if(o.overlay)for(let e of o.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(o.overlay){let e=n.length;if(i(o.tree,o.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let o=e.children[n];o instanceof mS&&i(o,e.positions[n]+t)}};return i(gR(e),0),n}get allowsNesting(){return!0}}function pR(e,t,n){let i=e.facet(OR),o=gR(e).topNode;if(!i||i.allowsNesting)for(let e=o;e;e=e.enter(t,n,gS.ExcludeBuffers))e.type.isTop&&(o=e);return o}dR.setState=$_.define();class fR extends dR{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=(n=e.languageData,o_.define({combine:n?e=>e.concat(n):void 0}));var n;return new fR(t,e.parser.configure({props:[uR.add((e=>e.isTop?t:void 0))]}),e.name)}configure(e,t){return new fR(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function gR(e){let t=e.field(dR.state,!1);return t?t.tree:mS.empty}class mR{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let vR=null;class yR{constructor(e,t,n=[],i,o,r,s,a){this.parser=e,this.state=t,this.fragments=n,this.tree=i,this.treeLen=o,this.viewport=r,this.skipped=s,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new yR(e,t,[],mS.empty,0,n,[],null)}startParse(){return this.parser.startParse(new mR(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=mS.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped($S.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}}))}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext((()=>{for(;!(t=this.parse.advance()););})),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped($S.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=vR;vR=this;try{return e()}finally{vR=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=xR(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:o,viewport:r,skipped:s}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges(((e,n,i,o)=>t.push({fromA:e,toA:n,fromB:i,toB:o}))),n=$S.applyChanges(n,t),i=mS.empty,o=0,r={from:e.mapPos(r.from,-1),to:e.mapPos(r.to,1)},this.skipped.length){s=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);n<i&&s.push({from:n,to:i})}}}return new yR(this.parser,t,n,i,o,r,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:i}=this.skipped[t];n<e.to&&i>e.from&&(this.fragments=xR(this.fragments,n,i),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends jS{createParse(t,n,i){let o=i[0].from,r=i[i.length-1].to,s={parsedPos:o,advance(){let t=vR;if(t){for(let e of i)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=r,new mS(hS.none,[],[],r-o)},stoppedAt:null,stopAt(){}};return s}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return vR}}function xR(e,t,n){return $S.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class bR{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new bR(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=yR.create(e.facet(OR).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new bR(n)}}dR.state=h_.define({create:bR.init,update(e,t){for(let e of t.effects)if(e.is(dR.setState))return e.value;return t.startState.facet(OR)!=t.state.facet(OR)?bR.init(t.state):e.apply(t)}});let _R=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(_R=e=>{let t=-1,n=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const wR="undefined"!=typeof navigator&&(null===(cR=navigator.scheduling)||void 0===cR?void 0:cR.isInputPending)?()=>navigator.scheduling.isInputPending():null,CR=bO.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(dR.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(dR.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=_R(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,o=n.field(dR.state);if(o.tree==o.context.tree&&o.context.isDone(i+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,e&&!wR?Math.max(25,e.timeRemaining()-5):1e9),s=o.context.treeLen<i&&n.doc.length>i+1e3,a=o.context.work((()=>wR&&wR()||Date.now()>r),i+(s?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:dR.setState.of(new bR(o.context))})),this.chunkBudget>0&&(!a||s)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((()=>this.scheduleWork())).catch((e=>mO(this.view.state,e))).then((()=>this.workScheduled--)),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),OR=o_.define({combine:e=>e.length?e[0]:null,enables:e=>[dR.state,CR,xE.contentAttributes.compute([e],(t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}}))]});class kR{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const ER=o_.define(),SR=o_.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some((e=>e!=t[0])))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function RR(e){let t=e.facet(SR);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function TR(e,t){let n="",i=e.tabSize,o=e.facet(SR)[0];if("\t"==o){for(;t>=i;)n+="\t",t-=i;o=" "}for(let e=0;e<t;e++)n+=o;return n}function MR(e,t){e instanceof W_&&(e=new AR(e));for(let n of e.state.facet(ER)){let i=n(e,t);if(void 0!==i)return i}let n=gR(e.state);return n.length>=t?function(e,t,n){let i=t.resolveStack(n),o=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(o!=i.node){let e=[];for(let t=o;t&&(t.from!=i.node.from||t.type!=i.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)i={node:e[t],next:i}}return DR(i,e,n)}(e,n,t):null}class AR{constructor(e,t={}){this.state=e,this.options=t,this.unit=RR(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:o}=this.options;return null!=i&&i>=n.from&&i<=n.to?o&&i==e?{text:"",from:e}:(t<0?i<e:i<=e)?{text:n.text.slice(i-n.from),from:i}:{text:n.text.slice(0,i-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(e,t);return n.slice(e-i,Math.min(n.length,e+100-i))}column(e,t=1){let{text:n,from:i}=this.lineAt(e,t),o=this.countColumn(n,e-i),r=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return r>-1&&(o+=r-this.countColumn(n,n.search(/\S|$/))),o}countColumn(e,t=e.length){return uw(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:i}=this.lineAt(e,t),o=this.options.overrideIndentation;if(o){let e=o(i);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const PR=new lS;function DR(e,t,n){for(let i=e;i;i=i.next){let e=$R(i.node);if(e)return e(IR.create(t,n,i))}return 0}function $R(e){let t=e.type.prop(PR);if(t)return t;let n,i=e.firstChild;if(i&&(n=i.type.prop(lS.closedBy))){let t=e.lastChild,i=t&&n.indexOf(t.name)>-1;return e=>NR(e,!0,1,void 0,i&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?jR:null}function jR(){return 0}class IR extends AR{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new IR(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(BR(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return DR(this.context.next,this.base,this.pos)}}function BR(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function LR({closing:e,align:t=!0,units:n=1}){return i=>NR(i,t,n,e)}function NR(e,t,n,i,o){let r=e.textAfter,s=r.match(/^\s*/)[0].length,a=i&&r.slice(s,s+i.length)==i||o==e.pos+s,l=t?function(e){let t=e.node,n=t.childAfter(t.from),i=t.lastChild;if(!n)return null;let o=e.options.simulateBreak,r=e.state.doc.lineAt(n.from),s=null==o||o<=r.from?r.to:Math.min(r.to,o);for(let e=n.to;;){let o=t.childAfter(e);if(!o||o==i)return null;if(!o.type.isSkipped){if(o.from>=s)return null;let e=/^ */.exec(r.text.slice(n.to-r.from))[0].length;return{from:n.from,to:n.to+e}}e=o.to}}(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}function qR({except:e,units:t=1}={}){return n=>{let i=e&&e.test(n.textAfter);return n.baseIndent+(i?0:t*n.unit)}}const VR=200;const FR=new lS;function zR(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}class QR{constructor(e,t){let n;function i(e){let t=fw.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const o="string"==typeof t.all?t.all:t.all?i(t.all):void 0,r=t.scope;this.scope=r instanceof dR?e=>e.prop(uR)==r.data:r?e=>e==r:void 0,this.style=QS(e.map((e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))}))),{all:o}).style,this.module=n?new fw(n):null,this.themeType=t.themeType}static define(e,t){return new QR(e,t||{})}}const HR=o_.define(),WR=o_.define({combine:e=>e.length?[e[0]]:null});function UR(e){let t=e.facet(HR);return t.length?t:e.facet(WR)}class XR{constructor(e){this.markCache=Object.create(null),this.tree=gR(e.state),this.decorations=this.buildDeco(e,UR(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=gR(e.state),n=UR(e.state),i=n!=UR(e.startState),{viewport:o}=e.view,r=e.changes.mapPos(this.decoratedTo,1);t.length<o.to&&!i&&t.type==this.tree.type&&r>=o.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=r):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=o.to)}buildDeco(e,t){if(!t||!this.tree.length)return OC.none;let n=new J_;for(let{from:i,to:o}of e.visibleRanges)HS(this.tree,t,((e,t,i)=>{n.add(e,t,this.markCache[i]||(this.markCache[i]=OC.mark({class:i})))}),i,o);return n.finish()}}const KR=v_.high(bO.fromClass(XR,{decorations:e=>e.decorations}));lR.meta,lR.link,lR.heading,lR.emphasis,lR.strong,lR.strikethrough,lR.keyword,lR.atom,lR.bool,lR.url,lR.contentSeparator,lR.labelName,lR.literal,lR.inserted,lR.string,lR.deleted,lR.regexp,lR.escape,lR.string,lR.variableName,lR.variableName,lR.typeName,lR.namespace,lR.className,lR.variableName,lR.macroName,lR.propertyName,lR.comment,lR.invalid;const GR=xE.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),YR=1e4,ZR="()[]{}",JR=o_.define({combine:e=>U_(e,{afterCursor:!0,brackets:ZR,maxScanDistance:YR,renderMatch:nT})}),eT=OC.mark({class:"cm-matchingBracket"}),tT=OC.mark({class:"cm-nonmatchingBracket"});function nT(e){let t=[],n=e.matched?eT:tT;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const iT=h_.define({create:()=>OC.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],i=t.state.facet(JR);for(let e of t.state.selection.ranges){if(!e.empty)continue;let o=cT(t.state,e.head,-1,i)||e.head>0&&cT(t.state,e.head-1,1,i)||i.afterCursor&&(cT(t.state,e.head,1,i)||e.head<t.state.doc.length&&cT(t.state,e.head+1,-1,i));o&&(n=n.concat(i.renderMatch(o,t.state)))}return OC.set(n,!0)},provide:e=>xE.decorations.from(e)}),oT=[iT,GR];function rT(e={}){return[JR.of(e),oT]}const sT=new lS;function aT(e,t,n){let i=e.prop(t<0?lS.openedBy:lS.closedBy);if(i)return i;if(1==e.name.length){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function lT(e){let t=e.type.prop(sT);return t?t(e.node):e}function cT(e,t,n,i={}){let o=i.maxScanDistance||YR,r=i.brackets||ZR,s=gR(e),a=s.resolveInner(t,n);for(let i=a;i;i=i.parent){let o=aT(i.type,n,r);if(o&&i.from<i.to){let s=lT(i);if(s&&(n>0?t>=s.from&&t<s.to:t>s.from&&t<=s.to))return uT(e,t,n,i,s,o,r)}}return function(e,t,n,i,o,r,s){let a=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=s.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),h=0;for(let e=0;!u.next().done&&e<=r;){let r=u.value;n<0&&(e+=r.length);let a=t+e*n;for(let e=n>0?0:r.length-1,t=n>0?r.length:-1;e!=t;e+=n){let t=s.indexOf(r[e]);if(!(t<0||i.resolveInner(a+e,1).type!=o))if(t%2==0==n>0)h++;else{if(1==h)return{start:c,end:{from:a+e,to:a+e+1},matched:t>>1==l>>1};h--}}n>0&&(e+=r.length)}return u.done?{start:c,matched:!1}:null}(e,t,n,s,a.type,o,r)}function uT(e,t,n,i,o,r,s){let a=i.parent,l={from:o.from,to:o.to},c=0,u=null==a?void 0:a.cursor();if(u&&(n<0?u.childBefore(i.from):u.childAfter(i.to)))do{if(n<0?u.to<=i.from:u.from>=i.to){if(0==c&&r.indexOf(u.type.name)>-1&&u.from<u.to){let e=lT(u);return{start:l,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(aT(u.type,n,s))c++;else if(aT(u.type,-n,s)){if(0==c){let e=lT(u);return{start:l,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}c--}}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}const hT=Object.create(null),dT=[hS.none],pT=[],fT=Object.create(null),gT=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])gT[e]=vT(hT,t);function mT(e,t){pT.indexOf(e)>-1||(pT.push(e),console.warn(t))}function vT(e,t){let n=[];for(let i of t.split(" ")){let t=[];for(let n of i.split(".")){let i=e[n]||lR[n];i?"function"==typeof i?t.length?t=t.map(i):mT(n,`Modifier ${n} used at start of tag`):t.length?mT(n,`Tag ${n} used as modifier`):t=Array.isArray(i)?i:[i]:mT(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let i=t.replace(/ /g,"_"),o=i+" "+n.map((e=>e.id)),r=fT[o];if(r)return r.id;let s=fT[o]=hS.define({id:dT.length,name:i,props:[VS({[i]:n})]});return dT.push(s),s.id}IC.RTL,IC.LTR;class yT{constructor(e,t,n,i){this.state=e,this.pos=t,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=gR(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),i=t.text.slice(n-t.from,this.pos-t.from),o=i.search(CT(e,!1));return o<0?null:{from:n+o,to:this.pos,text:i.slice(o)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,n){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function xT(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function bT(e){let t=e.map((e=>"string"==typeof e?{label:e}:e)),[n,i]=t.every((e=>/^\w+$/.test(e.label)))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let e=1;e<i.length;e++)n[i[e]]=!0}let i=xT(t)+xT(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}(t);return e=>{let o=e.matchBefore(i);return o||e.explicit?{from:o?o.from:e.pos,options:t,validFor:n}:null}}class _T{constructor(e,t,n,i){this.completion=e,this.source=t,this.match=n,this.score=i}}function wT(e){return e.selection.main.from}function CT(e,t){var n;let{source:i}=e,o=t&&"^"!=i[0],r="$"!=i[i.length-1];return o||r?new RegExp(`${o?"^":""}(?:${i})${r?"$":""}`,null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}const OT=A_.define();const kT=new WeakMap;function ET(e){if(!Array.isArray(e))return e;let t=kT.get(e);return t||kT.set(e,t=bT(e)),t}const ST=$_.define(),RT=$_.define();class TT{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=Vb(e,t),i=zb(n);this.chars.push(n);let o=e.slice(t,t+i),r=o.toUpperCase();this.folded.push(Vb(r==o?o.toLowerCase():r,0)),t+=i}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:i,precise:o,byWord:r}=this;if(1==t.length){let i=Vb(e,0),o=zb(i),r=o==e.length?0:-100;if(i==t[0]);else{if(i!=n[0])return null;r+=-200}return this.ret(r,[0,o])}let s=e.indexOf(this.pattern);if(0==s)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,l=0;if(s<0){for(let o=0,r=Math.min(e.length,200);o<r&&l<a;){let r=Vb(e,o);r!=t[l]&&r!=n[l]||(i[l++]=o),o+=zb(r)}if(l<a)return null}let c=0,u=0,h=!1,d=0,p=-1,f=-1,g=/[a-z]/.test(e),m=!0;for(let i=0,l=Math.min(e.length,200),v=0;i<l&&u<a;){let l=Vb(e,i);s<0&&(c<a&&l==t[c]&&(o[c++]=i),d<a&&(l==t[d]||l==n[d]?(0==d&&(p=i),f=i+1,d++):d=0));let y,x=l<255?l>=48&&l<=57||l>=97&&l<=122?2:l>=65&&l<=90?1:0:(y=Fb(l))!=y.toLowerCase()?1:y!=y.toUpperCase()?2:0;(!i||1==x&&g||0==v&&0!=x)&&(t[u]==l||n[u]==l&&(h=!0)?r[u++]=i:r.length&&(m=!1)),v=x,i+=zb(l)}return u==a&&0==r[0]&&m?this.result((h?-200:0)-100,r,e):d==a&&0==p?this.ret(-200-e.length+(f==e.length?0:-100),[0,f]):s>-1?this.ret(-700-e.length,[s,s+this.pattern.length]):d==a?this.ret(-900-e.length,[p,f]):u==a?this.result((h?-200:0)-100-700+(m?0:-1100),r,e):2==t.length?null:this.result((i[0]?-700:0)-200-1100,i,e)}result(e,t,n){let i=[],o=0;for(let e of t){let t=e+(this.astral?zb(Vb(n,e)):1);o&&i[o-1]==e?i[o-1]=t:(i[o++]=e,i[o++]=t)}return this.ret(e-n.length,i)}}class MT{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const AT=o_.define({combine:e=>U_(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:DT,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>PT(e(n),t(n)),optionClass:(e,t)=>n=>PT(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function PT(e,t){return e?t?e+" "+t:e:t}function DT(e,t,n,i,o,r){let s,a,l=e.textDirection==IC.RTL,c=l,u=!1,h="top",d=t.left-o.left,p=o.right-t.right,f=i.right-i.left,g=i.bottom-i.top;if(c&&d<Math.min(f,p)?c=!1:!c&&p<Math.min(f,d)&&(c=!0),f<=(c?d:p))s=Math.max(o.top,Math.min(n.top,o.bottom-g))-t.top,a=Math.min(400,c?d:p);else{u=!0,a=Math.min(400,(l?t.right:o.right-t.left)-30);let e=o.bottom-t.bottom;e>=g||e>t.top?s=n.bottom-t.top:(h="bottom",s=t.bottom-n.top)}return{style:`${h}: ${s/((t.bottom-t.top)/r.offsetHeight)}px; max-width: ${a/((t.right-t.left)/r.offsetWidth)}px`,class:"cm-completionInfo-"+(u?l?"left-narrow":"right-narrow":c?"left":"right")}}function $T(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let i=Math.floor((e-t)/n);return{from:e-(i+1)*n,to:e-i*n}}class jT{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let i=e.state.field(t),{options:o,selected:r}=i.open,s=e.state.facet(AT);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map((e=>"cm-completionIcon-"+e))),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n,i){let o=document.createElement("span");o.className="cm-completionLabel";let r=e.displayLabel||e.label,s=0;for(let e=0;e<i.length;){let t=i[e++],n=i[e++];t>s&&o.appendChild(document.createTextNode(r.slice(s,t)));let a=o.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(r.slice(t,n))),a.className="cm-completionMatchedText",s=n}return s<r.length&&o.appendChild(document.createTextNode(r.slice(s))),o},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort(((e,t)=>e.position-t.position)).map((e=>e.render))}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=$T(o.length,r,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",(n=>{let{options:i}=e.state.field(t).open;for(let t,o=n.target;o&&o!=this.dom;o=o.parentNode)if("LI"==o.nodeName&&(t=/-(\d+)$/.exec(o.id))&&+t[1]<i.length)return this.applyCompletion(e,i[+t[1]]),void n.preventDefault()})),this.dom.addEventListener("focusout",(t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(AT).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:RT.of(null)})})),this.showOptions(o,i.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}update(e){var t;let n=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=i){let{options:o,selected:r,disabled:s}=n.open;i.open&&i.open.options==o||(this.range=$T(o.length,r,e.state.facet(AT).maxRenderedOptions),this.showOptions(o,n.id)),this.updateSel(),s!=(null===(t=i.open)||void 0===t?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=$T(t.options.length,t.selected,this.view.state.facet(AT).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:i}=n;if(!i)return;let o="string"==typeof i?document.createTextNode(i):i(n);if(!o)return;"then"in o?o.then((t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,n)})).catch((e=>mO(this.view.state,e,"completion info"))):this.addInfoPane(o,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:i}=e;n.appendChild(t),this.infoDestroy=i||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)"LI"==n.nodeName&&n.id?i==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected"):i--;return t&&function(e,t){let n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),o=n.height/e.offsetHeight;i.top<n.top?e.scrollTop-=(n.top-i.top)/o:i.bottom>n.bottom&&(e.scrollTop+=(i.bottom-n.bottom)/o)}(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),o=this.space;if(!o){let e=this.dom.ownerDocument.defaultView||window;o={left:0,top:0,right:e.innerWidth,bottom:e.innerHeight}}return i.top>Math.min(o.bottom,t.bottom)-10||i.bottom<Math.max(o.top,t.top)+10?null:this.view.state.facet(AT).positionInfo(this.view,t,i,n,o,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const i=document.createElement("ul");i.id=t,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions"));let o=null;for(let r=n.from;r<n.to;r++){let{completion:s,match:a}=e[r],{section:l}=s;if(l){let e="string"==typeof l?l:l.name;if(e!=o&&(r>n.from||0==n.from))if(o=e,"string"!=typeof l&&l.header)i.appendChild(l.header(l));else{i.appendChild(document.createElement("completion-section")).textContent=e}}const c=i.appendChild(document.createElement("li"));c.id=t+"-"+r,c.setAttribute("role","option");let u=this.optionClass(s);u&&(c.className=u);for(let e of this.optionContent){let t=e(s,this.view.state,this.view,a);t&&c.appendChild(t)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function IT(e,t){return n=>new jT(n,e,t)}function BT(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class LT{constructor(e,t,n,i,o,r){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=i,this.selected=o,this.disabled=r}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new LT(this.options,FT(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,i,o,r){if(i&&!r&&e.some((e=>e.isPending)))return i.setDisabled();let s=function(e,t){let n=[],i=null,o=e=>{n.push(e);let{section:t}=e.completion;if(t){i||(i=[]);let e="string"==typeof t?t:t.name;i.some((t=>t.name==e))||i.push("string"==typeof t?{name:e}:t)}},r=t.facet(AT);for(let i of e)if(i.hasResult()){let e=i.result.getMatch;if(!1===i.result.filter)for(let t of i.result.options)o(new _T(t,i.source,e?e(t):[],1e9-n.length));else{let n,s=t.sliceDoc(i.from,i.to),a=r.filterStrict?new MT(s):new TT(s);for(let t of i.result.options)if(n=a.match(t.label)){let r=t.displayLabel?e?e(t,n.matched):[]:n.matched;o(new _T(t,i.source,r,n.score+(t.boost||0)))}}}if(i){let e=Object.create(null),t=0,o=(e,t)=>{var n,i;return(null!==(n=e.rank)&&void 0!==n?n:1e9)-(null!==(i=t.rank)&&void 0!==i?i:1e9)||(e.name<t.name?-1:1)};for(let n of i.sort(o))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e["string"==typeof n?n:n.name])}}let s=[],a=null,l=r.compareCompletions;for(let e of n.sort(((e,t)=>t.score-e.score||l(e.completion,t.completion)))){let t=e.completion;!a||a.label!=t.label||a.detail!=t.detail||null!=a.type&&null!=t.type&&a.type!=t.type||a.apply!=t.apply||a.boost!=t.boost?s.push(e):BT(e.completion)>BT(a)&&(s[s.length-1]=e),a=e.completion}return s}(e,t);if(!s.length)return i&&e.some((e=>e.isPending))?i.setDisabled():null;let a=t.facet(AT).selectOnOpen?0:-1;if(i&&i.selected!=a&&-1!=i.selected){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){a=t;break}}return new LT(s,FT(n,a),{pos:e.reduce(((e,t)=>t.hasResult()?Math.min(e,t.from):e),1e8),create:YT,above:o.aboveCursor},i?i.timestamp:Date.now(),a,!1)}map(e){return new LT(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new LT(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class NT{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new NT(zT,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(AT),i=(n.override||t.languageDataAt("autocomplete",wT(t)).map(ET)).map((t=>{let i=this.active.find((e=>e.source==t))||new HT(t,this.active.some((e=>0!=e.state))?1:0);return i.update(e,n)}));i.length==this.active.length&&i.every(((e,t)=>e==this.active[t]))&&(i=this.active);let o=this.open,r=e.effects.some((e=>e.is(UT)));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||i.some((t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to)))||!function(e,t){if(e==t)return!0;for(let n=0,i=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;i<t.length&&!t[i].hasResult();)i++;let o=n==e.length,r=i==t.length;if(o||r)return o==r;if(e[n++].result!=t[i++].result)return!1}}(i,this.active)||r?o=LT.build(i,t,this.id,o,n,r):o&&o.disabled&&!i.some((e=>e.isPending))&&(o=null),!o&&i.every((e=>!e.isPending))&&i.some((e=>e.hasResult()))&&(i=i.map((e=>e.hasResult()?new HT(e.source,0):e)));for(let t of e.effects)t.is(XT)&&(o=o&&o.setSelected(t.value,this.id));return i==this.active&&o==this.open?this:new NT(i,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?qT:VT}}const qT={"aria-autocomplete":"list"},VT={};function FT(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const zT=[];function QT(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(OT);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class HT{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let n=QT(e,t),i=this;(8&n||16&n&&this.touches(e))&&(i=new HT(i.source,0)),4&n&&0==i.state&&(i=new HT(this.source,1)),i=i.updateFor(e,n);for(let t of e.effects)if(t.is(ST))i=new HT(i.source,1,t.value);else if(t.is(RT))i=new HT(i.source,0);else if(t.is(UT))for(let e of t.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(wT(e.state))}}class WT extends HT{constructor(e,t,n,i,o,r){super(e,3,t),this.limit=n,this.result=i,this.from=o,this.to=r}hasResult(){return!0}updateFor(e,t){var n;if(!(3&t))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let o=e.changes.mapPos(this.from),r=e.changes.mapPos(this.to,1),s=wT(e.state);if(s>r||!i||2&t&&(wT(e.startState)==this.from||s<this.limit))return new HT(this.source,4&t?1:0);let a=e.changes.mapPos(this.limit);return function(e,t,n,i){if(!e)return!1;let o=t.sliceDoc(n,i);return"function"==typeof e?e(o,n,i,t):CT(e,!0).test(o)}(i.validFor,e.state,o,r)?new WT(this.source,this.explicit,a,i,o,r):i.update&&(i=i.update(i,o,r,new yT(e.state,s,!1)))?new WT(this.source,this.explicit,a,i,i.from,null!==(n=i.to)&&void 0!==n?n:wT(e.state)):new HT(this.source,1,this.explicit)}map(e){if(e.empty)return this;return(this.result.map?this.result.map(this.result,e):this.result)?new WT(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new HT(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}const UT=$_.define({map:(e,t)=>e.map((e=>e.map(t)))}),XT=$_.define(),KT=h_.define({create:()=>NT.start(),update:(e,t)=>e.update(t),provide:e=>[QE.from(e,(e=>e.tooltip)),xE.contentAttributes.from(e,(e=>e.attrs))]});function GT(e,t){const n=t.completion.apply||t.completion.label;let i=e.state.field(KT).active.find((e=>e.source==t.source));return i instanceof WT&&("string"==typeof n?e.dispatch(Object.assign(Object.assign({},function(e,t,n,i){let{main:o}=e.selection,r=n-o.from,s=i-o.from;return Object.assign(Object.assign({},e.changeByRange((a=>{if(a!=o&&n!=i&&e.sliceDoc(a.from+r,a.from+s)!=e.sliceDoc(n,i))return{range:a};let l=e.toText(t);return{changes:{from:a.from+r,to:i==o.from?a.to:a.from+s,insert:l},range:t_.cursor(a.from+r+l.length)}}))),{scrollIntoView:!0,userEvent:"input.complete"})}(e.state,n,i.from,i.to)),{annotations:OT.of(t.completion)})):n(e,t.completion,i.from,i.to),!0)}const YT=IT(KT,GT);function ZT(e,t="option"){return n=>{let i=n.state.field(KT,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(AT).interactionDelay)return!1;let o,r=1;"page"==t&&(o=YE(n,i.open.tooltip))&&(r=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:s}=i.open.options,a=i.open.selected>-1?i.open.selected+r*(e?1:-1):e?0:s-1;return a<0?a="page"==t?0:s-1:a>=s&&(a="page"==t?s-1:0),n.dispatch({effects:XT.of(a)}),!0}}const JT=e=>!!e.state.field(KT,!1)&&(e.dispatch({effects:ST.of(!0)}),!0);class eM{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const tM=bO.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(KT).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(KT),n=e.state.facet(AT);if(!e.selectionSet&&!e.docChanged&&e.startState.field(KT)==t)return;let i=e.transactions.some((e=>{let t=QT(e,n);return 8&t||(e.selection||e.docChanged)&&!(3&t)}));for(let t=0;t<this.running.length;t++){let n=this.running[t];if(i||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>50&&Date.now()-n.time>1e3){for(let e of n.context.abortListeners)try{e()}catch(e){mO(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some((e=>e.effects.some((e=>e.is(ST)))))&&(this.pendingStart=!0);let o=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some((e=>e.isPending&&!this.running.some((t=>t.active.source==e.source))))?setTimeout((()=>this.startUpdate()),o):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(KT);for(let e of t.active)e.isPending&&!this.running.some((t=>t.active.source==e.source))&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(AT).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=wT(t),i=new yT(t,n,e.explicit,this.view),o=new eM(e,i);this.running.push(o),Promise.resolve(e.source(i)).then((e=>{o.context.aborted||(o.done=e||null,this.scheduleAccept())}),(e=>{this.view.dispatch({effects:RT.of(null)}),mO(this.view.state,e)}))}scheduleAccept(){this.running.every((e=>void 0!==e.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(AT).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(AT),i=this.view.state.field(KT);for(let o=0;o<this.running.length;o++){let r=this.running[o];if(void 0===r.done)continue;if(this.running.splice(o--,1),r.done){let i=wT(r.updates.length?r.updates[0].startState:this.view.state),o=Math.min(i,r.done.from+(r.active.explicit?0:1)),s=new WT(r.active.source,r.active.explicit,o,r.done,r.done.from,null!==(e=r.done.to)&&void 0!==e?e:i);for(let e of r.updates)s=s.update(e,n);if(s.hasResult()){t.push(s);continue}}let s=i.active.find((e=>e.source==r.active.source));if(s&&s.isPending)if(null==r.done){let e=new HT(r.active.source,0);for(let t of r.updates)e=e.update(t,n);e.isPending||t.push(e)}else this.startQuery(s)}(t.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:UT.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(KT,!1);if(t&&t.tooltip&&this.view.state.facet(AT).closeOnBlur){let n=t.open&&YE(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:RT.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:ST.of(!1)})),20),this.composing=0}}}),nM="object"==typeof navigator&&/Win/.test(navigator.platform),iM=v_.highest(xE.domEventHandlers({keydown(e,t){let n=t.state.field(KT,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&(!nM||!e.altKey)||e.metaKey)return!1;let i=n.open.options[n.open.selected],o=n.active.find((e=>e.source==i.source)),r=i.completion.commitCharacters||o.result.commitCharacters;return r&&r.indexOf(e.key)>-1&>(t,i),!1}})),oM=xE.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'?︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class rM{constructor(e,t,n,i){this.field=e,this.line=t,this.from=n,this.to=i}}class sM{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(e){let t=e.mapPos(this.from,-1,Hb.TrackDel),n=e.mapPos(this.to,1,Hb.TrackDel);return null==t||null==n?null:new sM(this.field,t,n)}}class aM{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],i=[t],o=e.doc.lineAt(t),r=/^\s*/.exec(o.text)[0];for(let o of this.lines){if(n.length){let n=r,s=/^\t*/.exec(o)[0].length;for(let t=0;t<s;t++)n+=e.facet(SR);i.push(t+n.length-s),o=n+o.slice(s)}n.push(o),t+=o.length+1}let s=this.fieldPositions.map((e=>new sM(e.field,i[e.line]+e.from,i[e.line]+e.to)));return{text:n,ranges:s}}static parse(e){let t,n=[],i=[],o=[];for(let r of e.split(/\r\n?|\n/)){for(;t=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(r);){let e=t[1]?+t[1]:null,s=t[2]||t[3]||"",a=-1,l=s.replace(/\\[{}]/g,(e=>e[1]));for(let t=0;t<n.length;t++)(null!=e?n[t].seq==e:l&&n[t].name==l)&&(a=t);if(a<0){let t=0;for(;t<n.length&&(null==e||null!=n[t].seq&&n[t].seq<e);)t++;n.splice(t,0,{seq:e,name:l}),a=t;for(let e of o)e.field>=a&&e.field++}o.push(new rM(a,i.length,t.index,t.index+l.length)),r=r.slice(0,t.index)+s+r.slice(t.index+t[0].length)}r=r.replace(/\\([{}])/g,((e,t,n)=>{for(let e of o)e.line==i.length&&e.from>n&&(e.from--,e.to--);return t})),i.push(r)}return new aM(i,o)}}let lM=OC.widget({widget:new class extends wC{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),cM=OC.mark({class:"cm-snippetField"});class uM{constructor(e,t){this.ranges=e,this.active=t,this.deco=OC.set(e.map((e=>(e.from==e.to?lM:cM).range(e.from,e.to))))}map(e){let t=[];for(let n of this.ranges){let i=n.map(e);if(!i)return null;t.push(i)}return new uM(t,this.active)}selectionInsideField(e){return e.ranges.every((e=>this.ranges.some((t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))))}}const hM=$_.define({map:(e,t)=>e&&e.map(t)}),dM=$_.define(),pM=h_.define({create:()=>null,update(e,t){for(let n of t.effects){if(n.is(hM))return n.value;if(n.is(dM)&&e)return new uM(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>xE.decorations.from(e,(e=>e?e.deco:OC.none))});function fM(e,t){return t_.create(e.filter((e=>e.field==t)).map((e=>t_.range(e.from,e.to))))}function gM(e){let t=aM.parse(e);return(e,n,i,o)=>{let{text:r,ranges:s}=t.instantiate(e.state,i),{main:a}=e.state.selection,l={changes:{from:i,to:o==a.from?a.to:o,insert:Mb.of(r)},scrollIntoView:!0,annotations:n?[OT.of(n),j_.userEvent.of("input.complete")]:void 0};if(s.length&&(l.selection=fM(s,0)),s.some((e=>e.field>0))){let t=new uM(s,0),n=l.effects=[hM.of(t)];void 0===e.state.field(pM,!1)&&n.push($_.appendConfig.of([pM,xM,_M,oM]))}e.dispatch(e.state.update(l))}}function mM(e){return({state:t,dispatch:n})=>{let i=t.field(pM,!1);if(!i||e<0&&0==i.active)return!1;let o=i.active+e,r=e>0&&!i.ranges.some((t=>t.field==o+e));return n(t.update({selection:fM(i.ranges,o),effects:hM.of(r?null:new uM(i.ranges,o)),scrollIntoView:!0})),!0}}const vM=[{key:"Tab",run:mM(1),shift:mM(-1)},{key:"Escape",run:({state:e,dispatch:t})=>!!e.field(pM,!1)&&(t(e.update({effects:hM.of(null)})),!0)}],yM=o_.define({combine:e=>e.length?e[0]:vM}),xM=v_.highest(SE.compute([yM],(e=>e.facet(yM))));function bM(e,t){return Object.assign(Object.assign({},t),{apply:gM(e)})}const _M=xE.domEventHandlers({mousedown(e,t){let n,i=t.state.field(pM,!1);if(!i||null==(n=t.posAtCoords({x:e.clientX,y:e.clientY})))return!1;let o=i.ranges.find((e=>e.from<=n&&e.to>=n));return!(!o||o.field==i.active)&&(t.dispatch({selection:fM(i.ranges,o.field),effects:hM.of(i.ranges.some((e=>e.field>o.field))?new uM(i.ranges,o.field):null),scrollIntoView:!0}),!0)}}),wM={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},CM=$_.define({map(e,t){let n=t.mapPos(e,-1,Hb.TrackAfter);return null==n?void 0:n}}),OM=new class extends X_{};OM.startSide=1,OM.endSide=-1;const kM=h_.define({create:()=>Z_.empty,update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(CM)&&(e=e.update({add:[OM.range(n.value,n.value+1)]}));return e}});const EM="()[]{}<>";function SM(e){for(let t=0;t<EM.length;t+=2)if(EM.charCodeAt(t)==e)return EM.charAt(t+1);return Fb(e<128?e:e+1)}const RM="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),TM=xE.inputHandler.of(((e,t,n,i)=>{if((RM?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let o=e.state.selection.main;if(i.length>2||2==i.length&&1==zb(Vb(i,0))||t!=o.from||n!=o.to)return!1;let r=function(e,t){let n=function(e,t){return e.languageDataAt("closeBrackets",t)[0]||wM}(e,e.selection.main.head),i=n.brackets||wM.brackets;for(let o of i){let r=SM(Vb(o,0));if(t==o)return r==o?$M(e,o,i.indexOf(o+o+o)>-1,n):PM(e,o,r,n.before||wM.before);if(t==r&&MM(e,e.selection.main.from))return DM(e,o,r)}return null}(e.state,i);return!!r&&(e.dispatch(r),!0)}));function MM(e,t){let n=!1;return e.field(kM).between(0,e.doc.length,(e=>{e==t&&(n=!0)})),n}function AM(e,t){let n=e.sliceString(t,t+2);return n.slice(0,zb(Vb(n,0)))}function PM(e,t,n,i){let o=null,r=e.changeByRange((r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:n,from:r.to}],effects:CM.of(r.to+t.length),range:t_.range(r.anchor+t.length,r.head+t.length)};let s=AM(e.doc,r.head);return!s||/\s/.test(s)||i.indexOf(s)>-1?{changes:{insert:t+n,from:r.head},effects:CM.of(r.head+t.length),range:t_.cursor(r.head+t.length)}:{range:o=r}}));return o?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function DM(e,t,n){let i=null,o=e.changeByRange((t=>t.empty&&AM(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:t_.cursor(t.head+n.length)}:i={range:t}));return i?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function $M(e,t,n,i){let o=i.stringPrefixes||wM.stringPrefixes,r=null,s=e.changeByRange((i=>{if(!i.empty)return{changes:[{insert:t,from:i.from},{insert:t,from:i.to}],effects:CM.of(i.to+t.length),range:t_.range(i.anchor+t.length,i.head+t.length)};let s,a=i.head,l=AM(e.doc,a);if(l==t){if(jM(e,a))return{changes:{insert:t+t,from:a},effects:CM.of(a+t.length),range:t_.cursor(a+t.length)};if(MM(e,a)){let i=n&&e.sliceDoc(a,a+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:a,to:a+i.length,insert:i},range:t_.cursor(a+i.length)}}}else{if(n&&e.sliceDoc(a-2*t.length,a)==t+t&&(s=IM(e,a-2*t.length,o))>-1&&jM(e,s))return{changes:{insert:t+t+t+t,from:a},effects:CM.of(a+t.length),range:t_.cursor(a+t.length)};if(e.charCategorizer(a)(l)!=F_.Word&&IM(e,a,o)>-1&&!function(e,t,n,i){let o=gR(e).resolveInner(t,-1),r=i.reduce(((e,t)=>Math.max(e,t.length)),0);for(let s=0;s<5;s++){let s=e.sliceDoc(o.from,Math.min(o.to,o.from+n.length+r)),a=s.indexOf(n);if(!a||a>-1&&i.indexOf(s.slice(0,a))>-1){let t=o.firstChild;for(;t&&t.from==o.from&&t.to-t.from>n.length+a;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let l=o.to==t&&o.parent;if(!l)break;o=l}return!1}(e,a,t,o))return{changes:{insert:t+t,from:a},effects:CM.of(a+t.length),range:t_.cursor(a+t.length)}}return{range:r=i}}));return r?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function jM(e,t){let n=gR(e).resolveInner(t+1);return n.parent&&n.from==t}function IM(e,t,n){let i=e.charCategorizer(t);if(i(e.sliceDoc(t-1,t))!=F_.Word)return t;for(let o of n){let n=t-o.length;if(e.sliceDoc(n,t)==o&&i(e.sliceDoc(n-1,n))!=F_.Word)return n}return-1}function BM(e={}){return[iM,KT,AT.of(e),tM,NM,oM]}const LM=[{key:"Ctrl-Space",run:JT},{mac:"Alt-`",run:JT},{key:"Escape",run:e=>{let t=e.state.field(KT,!1);return!(!t||!t.active.some((e=>0!=e.state)))&&(e.dispatch({effects:RT.of(null)}),!0)}},{key:"ArrowDown",run:ZT(!0)},{key:"ArrowUp",run:ZT(!1)},{key:"PageDown",run:ZT(!0,"page")},{key:"PageUp",run:ZT(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(KT,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(AT).interactionDelay)&>(e,t.open.options[t.open.selected])}}],NM=v_.highest(SE.computeN([AT],(e=>e.facet(AT).defaultKeymap?[LM]:[])));function qM(e,t){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let o=e(t,n);return!!o&&(i(n.update(o)),!0)}}const VM=qM(UM,0),FM=qM(WM,0),zM=qM(((e,t)=>WM(e,t,function(e){let t=[];for(let n of e.selection.ranges){let i=e.doc.lineAt(n.from),o=n.to<=i.to?i:e.doc.lineAt(n.to);o.from>i.from&&o.from==n.to&&(o=n.to==i.to+1?i:e.doc.lineAt(n.to-1));let r=t.length-1;r>=0&&t[r].to>i.from?t[r].to=o.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:o.to})}return t}(t))),0);function QM(e,t){let n=e.languageDataAt("commentTokens",t);return n.length?n[0]:{}}const HM=50;function WM(e,t,n=t.selection.ranges){let i=n.map((e=>QM(t,e.from).block));if(!i.every((e=>e)))return null;let o=n.map(((e,n)=>function(e,{open:t,close:n},i,o){let r,s,a=e.sliceDoc(i-HM,i),l=e.sliceDoc(o,o+HM),c=/\s*$/.exec(a)[0].length,u=/^\s*/.exec(l)[0].length,h=a.length-c;if(a.slice(h-t.length,h)==t&&l.slice(u,u+n.length)==n)return{open:{pos:i-c,margin:c&&1},close:{pos:o+u,margin:u&&1}};o-i<=2*HM?r=s=e.sliceDoc(i,o):(r=e.sliceDoc(i,i+HM),s=e.sliceDoc(o-HM,o));let d=/^\s*/.exec(r)[0].length,p=/\s*$/.exec(s)[0].length,f=s.length-p-n.length;return r.slice(d,d+t.length)==t&&s.slice(f,f+n.length)==n?{open:{pos:i+d+t.length,margin:/\s/.test(r.charAt(d+t.length))?1:0},close:{pos:o-p-n.length,margin:/\s/.test(s.charAt(f-1))?1:0}}:null}(t,i[n],e.from,e.to)));if(2!=e&&!o.every((e=>e)))return{changes:t.changes(n.map(((e,t)=>o[t]?[]:[{from:e.from,insert:i[t].open+" "},{from:e.to,insert:" "+i[t].close}])))};if(1!=e&&o.some((e=>e))){let e=[];for(let t,n=0;n<o.length;n++)if(t=o[n]){let o=i[n],{open:r,close:s}=t;e.push({from:r.pos-o.open.length,to:r.pos+r.margin},{from:s.pos-s.margin,to:s.pos+o.close.length})}return{changes:e}}return null}function UM(e,t,n=t.selection.ranges){let i=[],o=-1;for(let{from:e,to:r}of n){let n=i.length,s=1e9,a=QM(t,e).line;if(a){for(let n=e;n<=r;){let l=t.doc.lineAt(n);if(l.from>o&&(e==r||r>l.from)){o=l.from;let e=/^\s*/.exec(l.text)[0].length,t=e==l.length,n=l.text.slice(e,e+a.length)==a?e:-1;e<l.text.length&&e<s&&(s=e),i.push({line:l,comment:n,token:a,indent:e,empty:t,single:!1})}n=l.to+1}if(s<1e9)for(let e=n;e<i.length;e++)i[e].indent<i[e].line.text.length&&(i[e].indent=s);i.length==n+1&&(i[n].single=!0)}}if(2!=e&&i.some((e=>e.comment<0&&(!e.empty||e.single)))){let e=[];for(let{line:t,token:n,indent:o,empty:r,single:s}of i)!s&&r||e.push({from:t.from+o,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&i.some((e=>e.comment>=0))){let e=[];for(let{line:t,comment:n,token:o}of i)if(n>=0){let i=t.from+n,r=i+o.length;" "==t.text[r-t.from]&&r++,e.push({from:i,to:r})}return{changes:e}}return null}function XM(e,t){return t_.create(e.ranges.map(t),e.mainIndex)}function KM(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function GM({state:e,dispatch:t},n){let i=XM(e.selection,n);return!i.eq(e.selection,!0)&&(t(KM(e,i)),!0)}function YM(e,t){return t_.cursor(t?e.to:e.from)}function ZM(e,t){return GM(e,(n=>n.empty?e.moveByChar(n,t):YM(n,t)))}function JM(e){return e.textDirectionAt(e.state.selection.main.head)==IC.LTR}const eA=e=>ZM(e,!JM(e)),tA=e=>ZM(e,JM(e));function nA(e,t){return GM(e,(n=>n.empty?e.moveByGroup(n,t):YM(n,t)))}function iA(e,t,n){if(t.type.prop(n))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function oA(e,t,n){let i,o,r=gR(e).resolveInner(t.head),s=n?lS.closedBy:lS.openedBy;for(let i=t.head;;){let t=n?r.childAfter(i):r.childBefore(i);if(!t)break;iA(e,t,s)?r=t:i=n?t.to:t.from}return o=r.type.prop(s)&&(i=n?cT(e,r.from,1):cT(e,r.to,-1))&&i.matched?n?i.end.to:i.end.from:n?r.to:r.from,t_.cursor(o,n?-1:1)}function rA(e,t){return GM(e,(n=>{if(!n.empty)return YM(n,t);let i=e.moveVertically(n,t);return i.head!=n.head?i:e.moveToLineBoundary(n,t)}))}const sA=e=>rA(e,!1),aA=e=>rA(e,!0);function lA(e){let t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,i=0,o=0;if(n){for(let t of e.state.facet(xE.scrollMargins)){let n=t(e);(null==n?void 0:n.top)&&(i=Math.max(null==n?void 0:n.top,i)),(null==n?void 0:n.bottom)&&(o=Math.max(null==n?void 0:n.bottom,o))}t=e.scrollDOM.clientHeight-i-o}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:i,marginBottom:o,selfScroll:n,height:Math.max(e.defaultLineHeight,t-5)}}function cA(e,t){let n,i=lA(e),{state:o}=e,r=XM(o.selection,(n=>n.empty?e.moveVertically(n,t,i.height):YM(n,t)));if(r.eq(o.selection))return!1;if(i.selfScroll){let t=e.coordsAtPos(o.selection.main.head),s=e.scrollDOM.getBoundingClientRect(),a=s.top+i.marginTop,l=s.bottom-i.marginBottom;t&&t.top>a&&t.bottom<l&&(n=xE.scrollIntoView(r.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(KM(o,r),{effects:n}),!0}const uA=e=>cA(e,!1),hA=e=>cA(e,!0);function dA(e,t,n){let i=e.lineBlockAt(t.head),o=e.moveToLineBoundary(t,n);if(o.head==t.head&&o.head!=(n?i.to:i.from)&&(o=e.moveToLineBoundary(t,n,!1)),!n&&o.head==i.from&&i.length){let n=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&t.head!=i.from+n&&(o=t_.cursor(i.from+n))}return o}function pA(e,t){let n=XM(e.state.selection,(e=>{let n=t(e);return t_.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)}));return!n.eq(e.state.selection)&&(e.dispatch(KM(e.state,n)),!0)}function fA(e,t){return pA(e,(n=>e.moveByChar(n,t)))}const gA=e=>fA(e,!JM(e)),mA=e=>fA(e,JM(e));function vA(e,t){return pA(e,(n=>e.moveByGroup(n,t)))}function yA(e,t){return pA(e,(n=>e.moveVertically(n,t)))}const xA=e=>yA(e,!1),bA=e=>yA(e,!0);function _A(e,t){return pA(e,(n=>e.moveVertically(n,t,lA(e).height)))}const wA=e=>_A(e,!1),CA=e=>_A(e,!0),OA=({state:e,dispatch:t})=>(t(KM(e,{anchor:0})),!0),kA=({state:e,dispatch:t})=>(t(KM(e,{anchor:e.doc.length})),!0),EA=({state:e,dispatch:t})=>(t(KM(e,{anchor:e.selection.main.anchor,head:0})),!0),SA=({state:e,dispatch:t})=>(t(KM(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function RA(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:i}=e,o=i.changeByRange((i=>{let{from:o,to:r}=i;if(o==r){let s=t(i);s<o?(n="delete.backward",s=TA(e,s,!1)):s>o&&(n="delete.forward",s=TA(e,s,!0)),o=Math.min(o,s),r=Math.max(r,s)}else o=TA(e,o,!1),r=TA(e,r,!0);return o==r?{range:i}:{changes:{from:o,to:r},range:t_.cursor(o,o<i.head?-1:1)}}));return!o.changes.empty&&(e.dispatch(i.update(o,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?xE.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function TA(e,t,n){if(e instanceof xE)for(let i of e.state.facet(xE.atomicRanges).map((t=>t(e))))i.between(t,t,((e,i)=>{e<t&&i>t&&(t=n?i:e)}));return t}const MA=(e,t,n)=>RA(e,(i=>{let o,r,s=i.from,{state:a}=e,l=a.doc.lineAt(s);if(n&&!t&&s>l.from&&s<l.from+200&&!/[^ \t]/.test(o=l.text.slice(0,s-l.from))){if("\t"==o[o.length-1])return s-1;let e=uw(o,a.tabSize)%RR(a)||RR(a);for(let t=0;t<e&&" "==o[o.length-1-t];t++)s--;r=s}else r=qb(l.text,s-l.from,t,t)+l.from,r==s&&l.number!=(t?a.doc.lines:1)?r+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(l.text.slice(r-l.from,s-l.from))&&(r=qb(l.text,r-l.from,!1,!1)+l.from);return r})),AA=e=>MA(e,!1,!0),PA=e=>MA(e,!0,!1),DA=(e,t)=>RA(e,(n=>{let i=n.head,{state:o}=e,r=o.doc.lineAt(i),s=o.charCategorizer(i);for(let e=null;;){if(i==(t?r.to:r.from)){i==n.head&&r.number!=(t?o.doc.lines:1)&&(i+=t?1:-1);break}let a=qb(r.text,i-r.from,t)+r.from,l=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),c=s(l);if(null!=e&&c!=e)break;" "==l&&i==n.head||(e=c),i=a}return i})),$A=e=>DA(e,!1);function jA(e){let t=[],n=-1;for(let i of e.selection.ranges){let o=e.doc.lineAt(i.from),r=e.doc.lineAt(i.to);if(i.empty||i.to!=r.from||(r=e.doc.lineAt(i.to-1)),n>=o.number){let e=t[t.length-1];e.to=r.to,e.ranges.push(i)}else t.push({from:o.from,to:r.to,ranges:[i]});n=r.number+1}return t}function IA(e,t,n){if(e.readOnly)return!1;let i=[],o=[];for(let t of jA(e)){if(n?t.to==e.doc.length:0==t.from)continue;let r=e.doc.lineAt(n?t.to+1:t.from-1),s=r.length+1;if(n){i.push({from:t.to,to:r.to},{from:t.from,insert:r.text+e.lineBreak});for(let n of t.ranges)o.push(t_.range(Math.min(e.doc.length,n.anchor+s),Math.min(e.doc.length,n.head+s)))}else{i.push({from:r.from,to:t.from},{from:t.to,insert:e.lineBreak+r.text});for(let e of t.ranges)o.push(t_.range(e.anchor-s,e.head-s))}}return!!i.length&&(t(e.update({changes:i,scrollIntoView:!0,selection:t_.create(o,e.selection.mainIndex),userEvent:"move.line"})),!0)}function BA(e,t,n){if(e.readOnly)return!1;let i=[];for(let t of jA(e))n?i.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):i.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});return t(e.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const LA=qA(!1),NA=qA(!0);function qA(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let i=t.changeByRange((n=>{let{from:i,to:o}=n,r=t.doc.lineAt(i),s=!e&&i==o&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,i=gR(e).resolveInner(t),o=i.childBefore(t),r=i.childAfter(t);return o&&r&&o.to<=t&&r.from>=t&&(n=o.type.prop(lS.closedBy))&&n.indexOf(r.name)>-1&&e.doc.lineAt(o.to).from==e.doc.lineAt(r.from).from&&!/\S/.test(e.sliceDoc(o.to,r.from))?{from:o.to,to:r.from}:null}(t,i);e&&(i=o=(o<=r.to?r:t.doc.lineAt(o)).to);let a=new AR(t,{simulateBreak:i,simulateDoubleBreak:!!s}),l=MR(a,i);for(null==l&&(l=uw(/^\s*/.exec(t.doc.lineAt(i).text)[0],t.tabSize));o<r.to&&/\s/.test(r.text[o-r.from]);)o++;s?({from:i,to:o}=s):i>r.from&&i<r.from+100&&!/\S/.test(r.text.slice(0,i))&&(i=r.from);let c=["",TR(t,l)];return s&&c.push(TR(t,a.lineIndent(r.from,-1))),{changes:{from:i,to:o,insert:Mb.of(c)},range:t_.cursor(i+1+c[1].length)}}));return n(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function VA(e,t){let n=-1;return e.changeByRange((i=>{let o=[];for(let r=i.from;r<=i.to;){let s=e.doc.lineAt(r);s.number>n&&(i.empty||i.to>s.from)&&(t(s,o,i),n=s.number),r=s.to+1}let r=e.changes(o);return{changes:o,range:t_.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}}))}const FA=[{key:"ArrowLeft",run:eA,shift:gA,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>nA(e,!JM(e)),shift:e=>vA(e,!JM(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>GM(e,(t=>dA(e,t,!JM(e)))),shift:e=>pA(e,(t=>dA(e,t,!JM(e)))),preventDefault:!0},{key:"ArrowRight",run:tA,shift:mA,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>nA(e,JM(e)),shift:e=>vA(e,JM(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>GM(e,(t=>dA(e,t,JM(e)))),shift:e=>pA(e,(t=>dA(e,t,JM(e)))),preventDefault:!0},{key:"ArrowUp",run:sA,shift:xA,preventDefault:!0},{mac:"Cmd-ArrowUp",run:OA,shift:EA},{mac:"Ctrl-ArrowUp",run:uA,shift:wA},{key:"ArrowDown",run:aA,shift:bA,preventDefault:!0},{mac:"Cmd-ArrowDown",run:kA,shift:SA},{mac:"Ctrl-ArrowDown",run:hA,shift:CA},{key:"PageUp",run:uA,shift:wA},{key:"PageDown",run:hA,shift:CA},{key:"Home",run:e=>GM(e,(t=>dA(e,t,!1))),shift:e=>pA(e,(t=>dA(e,t,!1))),preventDefault:!0},{key:"Mod-Home",run:OA,shift:EA},{key:"End",run:e=>GM(e,(t=>dA(e,t,!0))),shift:e=>pA(e,(t=>dA(e,t,!0))),preventDefault:!0},{key:"Mod-End",run:kA,shift:SA},{key:"Enter",run:LA,shift:LA},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:AA,shift:AA},{key:"Delete",run:PA},{key:"Mod-Backspace",mac:"Alt-Backspace",run:$A},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>DA(e,!0)},{mac:"Mod-Backspace",run:e=>RA(e,(t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}))},{mac:"Mod-Delete",run:e=>RA(e,(t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}))}].concat([{key:"Ctrl-b",run:eA,shift:gA,preventDefault:!0},{key:"Ctrl-f",run:tA,shift:mA},{key:"Ctrl-p",run:sA,shift:xA},{key:"Ctrl-n",run:aA,shift:bA},{key:"Ctrl-a",run:e=>GM(e,(t=>t_.cursor(e.lineBlockAt(t.head).from,1))),shift:e=>pA(e,(t=>t_.cursor(e.lineBlockAt(t.head).from)))},{key:"Ctrl-e",run:e=>GM(e,(t=>t_.cursor(e.lineBlockAt(t.head).to,-1))),shift:e=>pA(e,(t=>t_.cursor(e.lineBlockAt(t.head).to)))},{key:"Ctrl-d",run:PA},{key:"Ctrl-h",run:AA},{key:"Ctrl-k",run:e=>RA(e,(t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}))},{key:"Ctrl-Alt-h",run:$A},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:Mb.of(["",""])},range:t_.cursor(e.from)})));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,i=e.doc.lineAt(n),o=n==i.from?n-1:qb(i.text,n-i.from,!1)+i.from,r=n==i.to?n+1:qb(i.text,n-i.from,!0)+i.from;return{changes:{from:o,to:r,insert:e.doc.slice(n,r).append(e.doc.slice(o,n))},range:t_.cursor(r)}}));return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:hA}].map((e=>({mac:e.key,run:e.run,shift:e.shift})))),zA=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>GM(e,(t=>oA(e.state,t,!JM(e)))),shift:e=>pA(e,(t=>oA(e.state,t,!JM(e))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>GM(e,(t=>oA(e.state,t,JM(e)))),shift:e=>pA(e,(t=>oA(e.state,t,JM(e))))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>IA(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>BA(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>IA(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>BA(e,t,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,i=null;return n.ranges.length>1?i=t_.create([n.main]):n.main.empty||(i=t_.create([t_.cursor(n.main.head)])),!!i&&(t(KM(e,i)),!0)}},{key:"Mod-Enter",run:NA},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=jA(e).map((({from:t,to:n})=>t_.range(t,Math.min(n+1,e.doc.length))));return t(e.update({selection:t_.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=XM(e.selection,(t=>{let n=gR(e),i=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=i.node.from&&e.node.to<=i.node.to&&(i=e)}for(let e=i;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return t_.range(n.to,n.from)}return t}));return!n.eq(e.selection)&&(t(KM(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(VA(e,((t,n)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let o=uw(i,e.tabSize),r=0,s=TR(e,Math.max(0,o-RR(e)));for(;r<i.length&&r<s.length&&i.charCodeAt(r)==s.charCodeAt(r);)r++;n.push({from:t.from+r,to:t.from+i.length,insert:s.slice(r)})})),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(VA(e,((t,n)=>{n.push({from:t.from,insert:e.facet(SR)})})),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),i=new AR(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),o=VA(e,((t,o,r)=>{let s=MR(i,t.from);if(null==s)return;/\S/.test(t.text)||(s=0);let a=/^\s*/.exec(t.text)[0],l=TR(e,s);(a!=l||r.from<t.from+a.length)&&(n[t.from]=s,o.push({from:t.from,to:t.from+a.length,insert:l}))}));return o.changes.empty||t(e.update(o,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(jA(t).map((({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n})))),i=XM(t.selection,(t=>{let n;if(e.lineWrapping){let i=e.lineBlockAt(t.head),o=e.coordsAtPos(t.head,t.assoc||1);o&&(n=i.bottom+e.documentTop-o.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)})).map(n);return e.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>function(e,t,n){let i=!1,o=XM(e.selection,(t=>{let n=cT(e,t.head,-1)||cT(e,t.head,1)||t.head>0&&cT(e,t.head-1,1)||t.head<e.doc.length&&cT(e,t.head+1,-1);if(!n||!n.end)return t;i=!0;let o=n.start.from==t.head?n.end.to:n.end.from;return t_.cursor(o)}));return!!i&&(t(KM(e,o)),!0)}(e,t)},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),i=QM(e.state,n.from);return i.line?VM(e):!!i.block&&zM(e)}},{key:"Alt-A",run:FM},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat(FA);function QA(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var o=n[i];"string"==typeof o?e.setAttribute(i,o):null!=o&&(e[i]=o)}t++}for(;t<arguments.length;t++)HA(e,arguments[t]);return e}function HA(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)HA(e,t[n])}}class WA{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class UA{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let i=e,o=n.facet(rP).markerFilter;o&&(i=o(i,n));let r=e.slice().sort(((e,t)=>e.from-t.from||e.to-t.to)),s=new J_,a=[],l=0;for(let e=0;;){let t,i,o=e==r.length?null:r[e];if(!o&&!a.length)break;for(a.length?(t=l,i=a.reduce(((e,t)=>Math.min(e,t.to)),o&&o.from>t?o.from:1e8)):(t=o.from,i=o.to,a.push(o),e++);e<r.length;){let n=r[e];if(n.from!=t||!(n.to>n.from||n.to==t)){i=Math.min(n.from,i);break}a.push(n),e++,i=Math.min(n.to,i)}let c=fP(a);if(a.some((e=>e.from==e.to||e.from==e.to-1&&n.doc.lineAt(e.from).to==e.from)))s.add(t,t,OC.widget({widget:new lP(c),diagnostics:a.slice()}));else{let e=a.reduce(((e,t)=>t.markClass?e+" "+t.markClass:e),"");s.add(t,i,OC.mark({class:"cm-lintRange cm-lintRange-"+c+e,diagnostics:a.slice(),inclusiveEnd:a.some((e=>e.to>i))}))}l=i;for(let e=0;e<a.length;e++)a[e].to<=l&&a.splice(e--,1)}let c=s.finish();return new UA(c,t,XA(c))}}function XA(e,t=null,n=0){let i=null;return e.between(n,1e9,((e,n,{spec:o})=>{if(!(t&&o.diagnostics.indexOf(t)<0))if(i){if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new WA(i.from,n,i.diagnostic)}else i=new WA(e,n,t||o.diagnostics[0])})),i}function KA(e,t){return e.field(JA,!1)?t:t.concat($_.appendConfig.of(gP))}const GA=$_.define(),YA=$_.define(),ZA=$_.define(),JA=h_.define({create:()=>new UA(OC.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),i=null,o=e.panel;if(e.selected){let o=t.changes.mapPos(e.selected.from,1);i=XA(n,e.selected.diagnostic,o)||XA(n,null,o)}!n.size&&o&&t.state.facet(rP).autoPanel&&(o=null),e=new UA(n,o,i)}for(let n of t.effects)if(n.is(GA)){let i=t.state.facet(rP).autoPanel?n.value.length?uP.open:null:e.panel;e=UA.init(n.value,i,t.state)}else n.is(YA)?e=new UA(e.diagnostics,n.value?uP.open:null,e.selected):n.is(ZA)&&(e=new UA(e.diagnostics,e.panel,n.value));return e},provide:e=>[iS.from(e,(e=>e.panel)),xE.decorations.from(e,(e=>e.diagnostics))]}),eP=OC.mark({class:"cm-lintRange cm-lintRange-active"});function tP(e,t,n){let i,{diagnostics:o}=e.state.field(JA),r=-1,s=-1;o.between(t-(n<0?1:0),t+(n>0?1:0),((e,o,{spec:a})=>{if(t>=e&&t<=o&&(e==o||(t>e||n>0)&&(t<o||n<0)))return i=a.diagnostics,r=e,s=o,!1}));let a=e.state.facet(rP).tooltipFilter;return i&&a&&(i=a(i,e.state)),i?{pos:r,end:s,above:e.state.doc.lineAt(r).to<s,create:()=>({dom:nP(e,i)})}:null}function nP(e,t){return QA("ul",{class:"cm-tooltip-lint"},t.map((t=>aP(e,t,!1))))}const iP=e=>{let t=e.state.field(JA,!1);return!(!t||!t.panel)&&(e.dispatch({effects:YA.of(!1)}),!0)},oP=bO.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(rP);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let e=Date.now();if(e<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-e);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(rP);t.length&&function(e,t,n){let i=[],o=-1;for(let r of e)r.then((n=>{i.push(n),clearTimeout(o),i.length==e.length?t(i):o=setTimeout((()=>t(i)),200)}),n)}(t.map((e=>Promise.resolve(e(this.view)))),(t=>{this.view.state.doc==e.doc&&this.view.dispatch(function(e,t){return{effects:KA(e,[GA.of(t)])}}(this.view.state,t.reduce(((e,t)=>e.concat(t)))))}),(e=>{mO(this.view.state,e)}))}}update(e){let t=e.state.facet(rP);(e.docChanged||t!=e.startState.facet(rP)||t.needsRefresh&&t.needsRefresh(e))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});const rP=o_.define({combine:e=>Object.assign({sources:e.map((e=>e.source)).filter((e=>null!=e))},U_(e.map((e=>e.config)),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))});function sP(e){let t=[];if(e)e:for(let{name:n}of e){for(let e=0;e<n.length;e++){let i=n[e];if(/[a-zA-Z]/.test(i)&&!t.some((e=>e.toLowerCase()==i.toLowerCase()))){t.push(i);continue e}}t.push("")}return t}function aP(e,t,n){var i;let o=n?sP(t.actions):[];return QA("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},QA("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(i=t.actions)||void 0===i?void 0:i.map(((n,i)=>{let r=!1,s=i=>{if(i.preventDefault(),r)return;r=!0;let o=XA(e.state.field(JA).diagnostics,t);o&&n.apply(e,o.from,o.to)},{name:a}=n,l=o[i]?a.indexOf(o[i]):-1,c=l<0?a:[a.slice(0,l),QA("u",a.slice(l,l+1)),a.slice(l+1)];return QA("button",{type:"button",class:"cm-diagnosticAction",onclick:s,onmousedown:s,"aria-label":` Action: ${a}${l<0?"":` (access key "${o[i]})"`}.`},c)})),t.source&&QA("div",{class:"cm-diagnosticSource"},t.source))}class lP extends wC{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return QA("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class cP{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=aP(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class uP{constructor(e){this.view=e,this.items=[];this.list=QA("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)iP(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],i=sP(n.actions);for(let o=0;o<i.length;o++)if(i[o].toUpperCase().charCodeAt(0)==t.keyCode){let t=XA(this.view.state.field(JA).diagnostics,n);t&&n.actions[o].apply(e,t.from,t.to)}}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=QA("div",{class:"cm-panel-lint"},this.list,QA("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>iP(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(JA).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(JA),n=0,i=!1,o=null,r=new Set;for(e.between(0,this.view.state.doc.length,((e,s,{spec:a})=>{for(let e of a.diagnostics){if(r.has(e))continue;r.add(e);let s,a=-1;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){a=t;break}a<0?(s=new cP(this.view,e),this.items.splice(n,0,s),i=!0):(s=this.items[a],a>n&&(this.items.splice(n,a-n),i=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute("aria-selected")||(s.dom.setAttribute("aria-selected","true"),o=s):s.dom.hasAttribute("aria-selected")&&s.dom.removeAttribute("aria-selected"),n++}}));n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();0==this.items.length&&(this.items.push(new cP(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),o?(this.list.setAttribute("aria-activedescendant",o.id),this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=XA(this.view.state.field(JA).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:ZA.of(t)})}static open(e){return new uP(e)}}function hP(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const dP=xE.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:hP("#d11")},".cm-lintRange-warning":{backgroundImage:hP("orange")},".cm-lintRange-info":{backgroundImage:hP("#999")},".cm-lintRange-hint":{backgroundImage:hP("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function pP(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function fP(e){let t="hint",n=1;for(let i of e){let e=pP(i.severity);e>n&&(n=e,t=i.severity)}return t}const gP=[JA,xE.decorations.compute([JA],(e=>{let{selected:t,panel:n}=e.field(JA);return t&&n&&t.from!=t.to?OC.set([eP.range(t.from,t.to)]):OC.none})),GE(tP,{hideOn:function(e,t){let n=t.pos,i=t.end||n,o=e.state.facet(rP).hideOn(e,n,i);if(null!=o)return o;let r=e.startState.doc.lineAt(t.pos);return!(!e.effects.some((e=>e.is(GA)))&&!e.changes.touchesRange(r.from,Math.max(r.to,i)))}}),dP];class mP{constructor(e,t,n,i,o,r,s,a,l,c=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=i,this.pos=o,this.score=r,this.buffer=s,this.bufferBase=a,this.curContext=l,this.lookAhead=c,this.parent=u}toString(){return`[${this.stack.filter(((e,t)=>t%3==0)).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let i=e.parser.context;return new mP(e,[],t,n,n,0,[],0,i?new vP(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,i=65535&e,{parser:o}=this.p,r=this.reducePos<this.pos-25;r&&this.setLookAhead(this.pos);let s=o.dynamicPrecedence(i);if(s&&(this.score+=s),0==n)return this.pushState(o.getGoto(this.state,i,!0),this.reducePos),i<o.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,r?8:4,!0),void this.reduceContext(i,this.reducePos);let a=this.stack.length-3*(n-1)-(262144&e?6:0),l=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-l;c>=2e3&&!(null===(t=this.p.parser.nodeSet.types[i])||void 0===t?void 0:t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=c));let u=a?this.stack[a-1]:0,h=this.bufferBase+this.buffer.length-u;if(i<o.minRepeatTerm||131072&e){let e=o.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,l,e,h+4,!0)}if(262144&e)this.state=this.stack[a];else{let e=this.stack[a-3];this.state=o.getGoto(e,i,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(i,l)}storeNode(e,t,n,i=4,o=!1){if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,i=this.buffer.length;if(0==i&&e.parent&&(i=e.bufferBase-e.parent.bufferBase,e=e.parent),i>0&&0==e.buffer[i-4]&&e.buffer[i-1]>-1){if(t==n)return;if(e.buffer[i-2]>=t)return void(e.buffer[i-2]=n)}}if(o&&this.pos!=n){let o=this.buffer.length;if(o>0&&0!=this.buffer[o-4]){let e=!1;for(let t=o;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;o>0&&this.buffer[o-2]>n;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=n,this.buffer[o+3]=i}else this.buffer.push(e,t,n,i)}shift(e,t,n,i){if(131072&e)this.pushState(65535&e,this.pos);else if(262144&e)this.pos=i,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,i,4);else{let o=e,{parser:r}=this.p;(i>this.pos||t<=r.maxNode)&&(this.pos=i,r.stateFlag(o,1)||(this.reducePos=i)),this.pushState(o,n),this.shiftContext(t,n),t<=r.maxNode&&this.buffer.push(t,n,i,4)}}apply(e,t,n,i){65536&e?this.reduce(e):this.shift(e,t,n,i)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(t,i),this.buffer.push(n,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),i=e.bufferBase+t;for(;e&&i==e.bufferBase;)e=e.parent;return new mP(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new yP(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==n)return!1;if(!(65536&n))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let i,o=0;o<t.length;o+=2)(i=t[o+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[o],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let i=t[e+1];n.some(((e,t)=>1&t&&e==i))||n.push(t[e],i)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let i=t[e+1];if(i==this.state)continue;let o=this.split();o.pushState(i,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[e],this.pos),o.reducePos=this.pos,o.score-=200,n.push(o)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(65536&t))return!1;if(!e.validAction(this.state,t)){let n=t>>19,i=65535&t,o=this.stack.length-3*n;if(o<0||e.getGoto(this.stack[o],i,!1)<0){let e=this.findForcedReduction();if(null==e)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(i,o)=>{if(!t.includes(i))return t.push(i),e.allActions(i,(t=>{if(393216&t);else if(65536&t){let n=(t>>19)-o;if(n>1){let i=65535&t,o=this.stack.length-3*n;if(o>=0&&e.getGoto(this.stack[o],i,!1)>=0)return n<<19|65536|i}}else{let e=n(t,o+1);if(null!=e)return e}}))};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||-3!=this.buffer[e])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||-4!=this.buffer[e])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new vP(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class vP{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class yP{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=65535&e,n=e>>19;0==n?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(n-1);let i=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=i}}class xP{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new xP(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new xP(this.stack,this.pos,this.index)}}function bP(e,t=Uint16Array){if("string"!=typeof e)return e;let n=null;for(let i=0,o=0;i<e.length;){let r=0;for(;;){let t=e.charCodeAt(i++),n=!1;if(126==t){r=65535;break}t>=92&&t--,t>=34&&t--;let o=t-32;if(o>=46&&(o-=46,n=!0),r+=o,n)break;r*=46}n?n[o++]=r:n=new t(r)}return n}class _P{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const wP=new _P;class CP{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=wP,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,i=this.rangeIndex,o=this.pos+e;for(;o<n.from;){if(!i)return null;let e=this.ranges[--i];o-=n.from-e.to,n=e}for(;t<0?o>n.to:o>=n.to;){if(i==this.ranges.length-1)return null;let e=this.ranges[++i];o+=e.from-n.to,n=e}return o}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t,n,i=this.chunkOff+e;if(i>=0&&i<this.chunk.length)t=this.pos+e,n=this.chunk.charCodeAt(i);else{let i=this.resolveOffset(e,1);if(null==i)return-1;if(t=i,t>=this.chunk2Pos&&t<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(t-this.chunk2Pos);else{let e=this.rangeIndex,i=this.range;for(;i.to<=t;)i=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=t),t+this.chunk2.length>i.to&&(this.chunk2=this.chunk2.slice(0,i.to-t)),n=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),n}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(null==n||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=wP,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let i of this.ranges){if(i.from>=t)break;i.to>e&&(n+=this.input.read(Math.max(i.from,e),Math.min(i.to,t)))}return n}}class OP{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;!function(e,t,n,i,o,r){let s=0,a=1<<i,{dialect:l}=n.p.parser;e:for(;a&e[s];){let n=e[s+1];for(let i=s+3;i<n;i+=2)if((e[i+1]&a)>0){let n=e[i];if(l.allows(n)&&(-1==t.token.value||t.token.value==n||SP(n,t.token.value,o,r))){t.acceptToken(n);break}}let i=t.next,c=0,u=e[s+2];if(!(t.next<0&&u>c&&65535==e[n+3*u-3])){for(;c<u;){let o=c+u>>1,r=n+o+(o<<1),a=e[r],l=e[r+1]||65536;if(i<a)u=o;else{if(!(i>=l)){s=e[r+2],t.advance();continue e}c=o+1}}break}s=e[n+3*u-1]}}(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}OP.prototype.contextual=OP.prototype.fallback=OP.prototype.extend=!1,OP.prototype.fallback=OP.prototype.extend=!1;class kP{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function EP(e,t,n){for(let i,o=t;65535!=(i=e[o]);o++)if(i==n)return o-t;return-1}function SP(e,t,n,i){let o=EP(n,i,t);return o<0||EP(n,i,e)<o}const RP="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let TP=null;function MP(e,t,n){let i=e.cursor(gS.IncludeAnonymous);for(i.moveTo(t);;)if(!(n<0?i.childBefore(t):i.childAfter(t)))for(;;){if((n<0?i.to<t:i.from>t)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(e.length,Math.max(i.from+1,t+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:e.length}}class AP{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?MP(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?MP(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],i=this.index[t];if(i==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let o=n.children[i],r=this.start[t]+n.positions[i];if(r>e)return this.nextStart=r,null;if(o instanceof mS){if(r==e){if(r<this.safeFrom)return null;let e=r+o.length;if(e<=this.safeTo){let t=o.prop(lS.lookAhead);if(!t||e+t<this.fragment.to)return o}}this.index[t]++,r+o.length>=Math.max(this.safeFrom,e)&&(this.trees.push(o),this.start.push(r),this.index.push(0))}else this.index[t]++,this.nextStart=r+o.length}}}class PP{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map((e=>new _P))}getActions(e){let t=0,n=null,{parser:i}=e.p,{tokenizers:o}=i,r=i.stateSlot(e.state,3),s=e.curContext?e.curContext.hash:0,a=0;for(let i=0;i<o.length;i++){if(!(1<<i&r))continue;let l=o[i],c=this.tokens[i];if((!n||l.fallback)&&((l.contextual||c.start!=e.pos||c.mask!=r||c.context!=s)&&(this.updateCachedToken(c,l,e),c.mask=r,c.context=s),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),0!=c.value)){let i=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!l.extend&&(n=c,t>i))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),n||e.pos!=this.stream.end||(n=new _P,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new _P,{pos:n,p:i}=e;return t.start=n,t.end=Math.min(n+1,i.stream.end),t.value=n==i.stream.end?i.parser.eofTerm:0,t}updateCachedToken(e,t,n){let i=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(i,e),n),e.value>-1){let{parser:t}=n.p;for(let i=0;i<t.specialized.length;i++)if(t.specialized[i]==e.value){let o=t.specializers[i](this.stream.read(e.start,e.end),n);if(o>=0&&n.p.parser.dialect.allows(o>>1)){1&o?e.extended=o>>1:e.value=o>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,t,n,i){for(let t=0;t<i;t+=3)if(this.actions[t]==e)return i;return this.actions[i++]=e,this.actions[i++]=t,this.actions[i++]=n,i}addActions(e,t,n,i){let{state:o}=e,{parser:r}=e.p,{data:s}=r;for(let e=0;e<2;e++)for(let a=r.stateSlot(o,e?2:1);;a+=3){if(65535==s[a]){if(1!=s[a+1]){0==i&&2==s[a+1]&&(i=this.putAction(NP(s,a+2),t,n,i));break}a=NP(s,a+2)}s[a]==t&&(i=this.putAction(NP(s,a+1),t,n,i))}return i}}class DP{constructor(e,t,n,i){this.parser=e,this.input=t,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new CP(t,i),this.tokens=new PP(e,this.stream),this.topTerm=e.top[1];let{from:o}=i[0];this.stacks=[mP.start(this,e.top[0],o)],this.fragments=n.length&&this.stream.end-o>4*e.bufferLength?new AP(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,n=this.stacks,i=this.minStackPos,o=this.stacks=[];if(this.bigReductionCount>300&&1==n.length){let[e]=n;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let r=0;r<n.length;r++){let s=n[r];for(;;){if(this.tokens.mainToken=null,s.pos>i)o.push(s);else{if(this.advanceStack(s,o,n))continue;{e||(e=[],t=[]),e.push(s);let n=this.tokens.getMainToken(s);t.push(n.value,n.end)}}break}}if(!o.length){let t=e&&function(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||null!=e&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}(e);if(t)return RP&&console.log("Finish with "+this.stackID(t)),this.stackToTree(t);if(this.parser.strict)throw RP&&e&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+i);this.recovering||(this.recovering=5)}if(this.recovering&&e){let n=null!=this.stoppedAt&&e[0].pos>this.stoppedAt?e[0]:this.runRecovery(e,t,o);if(n)return RP&&console.log("Force-finish "+this.stackID(n)),this.stackToTree(n.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(o.length>e)for(o.sort(((e,t)=>t.score-e.score));o.length>e;)o.pop();o.some((e=>e.reducePos>i))&&this.recovering--}else if(o.length>1){e:for(let e=0;e<o.length-1;e++){let t=o[e];for(let n=e+1;n<o.length;n++){let i=o[n];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500){if(!((t.score-i.score||t.buffer.length-i.buffer.length)>0)){o.splice(e--,1);continue e}o.splice(n--,1)}}}o.length>12&&o.splice(12,o.length-12)}this.minStackPos=o[0].pos;for(let e=1;e<o.length;e++)o[e].pos<this.minStackPos&&(this.minStackPos=o[e].pos);return null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let i=e.pos,{parser:o}=this,r=RP?this.stackID(e)+" -> ":"";if(null!=this.stoppedAt&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let s=this.fragments.nodeAt(i);s;){let i=this.parser.nodeSet.types[s.type.id]==s.type?o.getGoto(e.state,s.type.id):-1;if(i>-1&&s.length&&(!t||(s.prop(lS.contextHash)||0)==n))return e.useNode(s,i),RP&&console.log(r+this.stackID(e)+` (via reuse of ${o.getName(s.type.id)})`),!0;if(!(s instanceof mS)||0==s.children.length||s.positions[0]>0)break;let a=s.children[0];if(!(a instanceof mS&&0==s.positions[0]))break;s=a}}let s=o.stateSlot(e.state,4);if(s>0)return e.reduce(s),RP&&console.log(r+this.stackID(e)+` (via always-reduce ${o.getName(65535&s)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let s=0;s<a.length;){let l=a[s++],c=a[s++],u=a[s++],h=s==a.length||!n,d=h?e:e.split(),p=this.tokens.mainToken;if(d.apply(l,c,p?p.start:d.pos,u),RP&&console.log(r+this.stackID(d)+` (via ${65536&l?`reduce of ${o.getName(65535&l)}`:"shift"} for ${o.getName(c)} @ ${i}${d==e?"":", split"})`),h)return!0;d.pos>i?t.push(d):n.push(d)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return $P(e,t),!0}}runRecovery(e,t,n){let i=null,o=!1;for(let r=0;r<e.length;r++){let s=e[r],a=t[r<<1],l=t[1+(r<<1)],c=RP?this.stackID(s)+" -> ":"";if(s.deadEnd){if(o)continue;if(o=!0,s.restart(),RP&&console.log(c+this.stackID(s)+" (restarted)"),this.advanceFully(s,n))continue}let u=s.split(),h=c;for(let e=0;u.forceReduce()&&e<10;e++){if(RP&&console.log(h+this.stackID(u)+" (via force-reduce)"),this.advanceFully(u,n))break;RP&&(h=this.stackID(u)+" -> ")}for(let e of s.recoverByInsert(a))RP&&console.log(c+this.stackID(e)+" (via recover-insert)"),this.advanceFully(e,n);this.stream.end>s.pos?(l==s.pos&&(l++,a=0),s.recoverByDelete(a,l),RP&&console.log(c+this.stackID(s)+` (via recover-delete ${this.parser.getName(a)})`),$P(s,n)):(!i||i.score<s.score)&&(i=s)}return i}stackToTree(e){return e.close(),mS.build({buffer:xP.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(TP||(TP=new WeakMap)).get(e);return t||TP.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function $P(e,t){for(let n=0;n<t.length;n++){let i=t[n];if(i.pos==e.pos&&i.sameState(e))return void(t[n].score<e.score&&(t[n]=e))}t.push(e)}class jP{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||0==this.disabled[e]}}const IP=e=>e;class BP{constructor(e){this.start=e.start,this.shift=e.shift||IP,this.reduce=e.reduce||IP,this.reuse=e.reuse||IP,this.hash=e.hash||(()=>0),this.strict=!1!==e.strict}}class LP extends jS{constructor(e){if(super(),this.wrappers=[],14!=e.version)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push("");let n=Object.keys(e.topRules).map((t=>e.topRules[t][1])),i=[];for(let e=0;e<t.length;e++)i.push([]);function o(e,t,n){i[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];"string"==typeof e&&(e=lS[e]);for(let n=1;n<t.length;){let i=t[n++];if(i>=0)o(i,e,t[n++]);else{let r=t[n+-i];for(let s=-i;s>0;s--)o(t[n++],e,r);n++}}}this.nodeSet=new dS(t.map(((t,o)=>hS.define({name:o>=this.minRepeatTerm?void 0:t,id:o,props:i[o],top:n.indexOf(o)>-1,error:0==o,skipped:e.skippedNodes&&e.skippedNodes.indexOf(o)>-1})))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=rS;let r=bP(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(qP),this.states=bP(e.states,Uint32Array),this.data=bP(e.stateData),this.goto=bP(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map((e=>"number"==typeof e?new OP(r,e):e)),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let i=new DP(this,e,t,n);for(let o of this.wrappers)i=o(i,e,t,n);return i}getGoto(e,t,n=!1){let i=this.goto;if(t>=i[0])return-1;for(let o=i[t+1];;){let t=i[o++],r=1&t,s=i[o++];if(r&&n)return s;for(let n=o+(t>>1);o<n;o++)if(i[o]==e)return s;if(r)return-1}}hasAction(e,t){let n=this.data;for(let i=0;i<2;i++)for(let o,r=this.stateSlot(e,i?2:1);;r+=3){if(65535==(o=n[r])){if(1!=n[r+1]){if(2==n[r+1])return NP(n,r+2);break}o=n[r=NP(n,r+2)]}if(o==t||0==o)return NP(n,r+1)}return 0}stateSlot(e,t){return this.states[6*e+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,(e=>e==t||null))}allActions(e,t){let n=this.stateSlot(e,4),i=n?t(n):void 0;for(let n=this.stateSlot(e,1);null==i;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=NP(this.data,n+2)}i=t(NP(this.data,n+1))}return i}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=NP(this.data,n+2)}if(!(1&this.data[n+2])){let e=this.data[n+1];t.some(((t,n)=>1&n&&t==e))||t.push(this.data[n],e)}}return t}configure(e){let t=Object.assign(Object.create(LP.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map((t=>{let n=e.tokenizers.find((e=>e.from==t));return n?n.to:t}))),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map(((n,i)=>{let o=e.specializers.find((e=>e.from==n.external));if(!o)return n;let r=Object.assign(Object.assign({},n),{external:o.to});return t.specializers[i]=qP(r),r}))),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return null==t?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map((()=>!1));if(e)for(let i of e.split(" ")){let e=t.indexOf(i);e>=0&&(n[e]=!0)}let i=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n,o=this.dialects[t[e]];65535!=(n=this.data[o++]);)(i||(i=new Uint8Array(this.maxTerm+1)))[n]=1;return new jP(e,n,i)}static deserialize(e){return new LP(e)}}function NP(e,t){return e[t]|e[t+1]<<16}function qP(e){if(e.external){let t=e.extend?1:0;return(n,i)=>e.external(n,i)<<1|t}return e.get}const VP=122,FP=123,zP=128,QP=4,HP=131,WP=7,UP=8,XP=9,KP=10,GP=139,YP=19,ZP=140,JP=23,eD=141,tD=27,nD=37,iD=41,oD=145,rD=146,sD=147,aD=148,lD=47,cD=68,uD=154,hD=70,dD=155,pD=72,fD=156,gD=76,mD=161,vD=79,yD=80,xD=81,bD=167,_D=89,wD=90,CD=169,OD=97,kD=171,ED=98,SD=100,RD=101,TD="undefined"!=typeof process&&process.env&&/\bfparse(:dbg)?\b/.test(process.env.LOG),MD="undefined"!=typeof process&&process.env&&/\bfparse:dbg\b/.test(process.env.LOG),AD="undefined"!=typeof process&&process.env&&/\bcontext\b/.test(process.env.LOG),PD=[9,11,12,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],DD=ID("\n\r"),$D="*".charCodeAt(0),jD=ID("'./-+*^");function ID(e){return Array.from(e).map((e=>e.charCodeAt(0)))}function BD(e){return e>=48&&e<=57||183===e||e>=768&&e<=879||e>=8255&&e<=8256}function LD(e,t){return t.concat(e.split(/\n/g).join("\n"+t))}function ND(e,t=0){const n=e.peek(t);return n===$D&&e.peek(t+1)===$D?{offset:2,token:"**"}:(i=n,jD.includes(i)?{offset:1,token:String.fromCharCode(n)}:null);var i}function qD(e,t=0,n=!1){for(let o=!1,r=[],s=0;;s++){const a=e.peek(t+s);if(!(63===(i=a)||i>=65&&i<=90||95===i||i>=97&&i<=122||i>=192&&i<=214||i>=216&&i<=246||i>=248&&i<=767||i>=880&&i<=893||i>=895&&i<=8191||i>=8204&&i<=8205||i>=8304&&i<=8591||i>=11264&&i<=12271||i>=12289&&i<=55295||i>=63744&&i<=64975||i>=65008&&i<=65533||i>=55296&&i<=56319||i>=56320&&i<=57343||(o||n)&&BD(a)))return r.length?{token:String.fromCharCode(...r),offset:s}:null;o||(o=!0),r.push(a)}var i}function VD(e,t){for(let i=!1,o=0;;o++){let r=e.peek(t+o);if(n=r,!PD.includes(n))return i?{token:" ",offset:o}:null;i||(i=!0)}var n}const FD={[VP]:"identifier",[FP]:"nameIdentifier"},zD=new kP(((e,t)=>{MD&&console.log("%s: T <identifier | nameIdentifier>",e.pos);const n=function(e,t){const n=t.contextKeys(),i=t.tokens;for(let t=0,o=[],r=null;;){const s=i.length+o.length>0,a=o.length>0,l=qD(e,t,s)||s&&ND(e,t)||a&&VD(e,t);if(!l)return r;const{token:c,offset:u}=l;if(t+=u," "===c)continue;o=[...o,c];const h=[...i,...o].join(" ");if(n.some((e=>e===h))){const e=o[0];r={token:e,offset:e.length,term:123}}if(!n.some((e=>e.startsWith(h)))){if(GD.some((e=>e===h))){const e=o[0];r={token:e,offset:e.length,term:122}}if(!GD.some((e=>e.startsWith(h))))return r}}}(e,t.context),i=t.context.tokens,o=n||qD(e,0,i.length>0);o&&(e.advance(o.offset),e.acceptToken(n?n.term:122),TD&&console.log("%s: MATCH <%s> <%s>",e.pos,n?FD[n.term]:"identifier",o.token))}),{contextual:!0}),QD=new kP(((e,t)=>{MD&&console.log("%s: T <propertyIdentifier>",e.pos);const n=qD(e,0,t.context.tokens.length>0);n&&(e.advance(n.offset),e.acceptToken(121),TD&&console.log("%s: MATCH <propertyIdentifier> <%s>",e.pos,n.token))})),HD=new kP(((e,t)=>{let n;MD&&console.log("%s: T <insertSemi>",e.pos);let i=!1;for(n=0;;n++){const t=e.peek(n);if(!PD.includes(t)){DD.includes(t)&&(i=!0);break}}if(i){const t=qD(e,n+1);if(VD(e,n+1)||t&&/^(then|else|return|satisfies)$/.test(t.token))return;TD&&console.log("%s: MATCH <insertSemi>",e.pos),e.acceptToken(124)}})),WD={[fD]:"FunctionInvocation",[dD]:"FilterExpression",[uD]:"PathExpression"},UD={[kD]:"Context",[CD]:"FunctionDefinition",[HP]:"ForExpression",[bD]:"List",[ZP]:"IfExpression",[eD]:"QuantifiedExpression"},XD={[OD]:"Context",[wD]:"FunctionDefinition",[QP]:"ForExpression",[_D]:"List",[YP]:"IfExpression",[JP]:"QuantifiedExpression",[cD]:"PathExpression",[pD]:"FunctionInvocation",[hD]:"FilterExpression",[iD]:"ArithmeticExpression"};class KD{constructor(e){this.fn=e}get(e){return this.fn(e)}static of(e){return new KD(e)}}const GD=Object.keys({"date and time":1,date:1,time:1,duration:1});class YD{constructor(e={}){this.value=e}getKeys(){return Object.keys(this.value)}get(e){const t=this.value[e],n=this.constructor;return n.isAtomic(t)?t:n.of(t)}set(e,t){return this.constructor.of({...this.value,[e]:t})}merge(e){const t=this.constructor;return new t(t.__merge(this.value,e))}static isAtomic(e){return!e||e instanceof this||e instanceof KD||"object"!=typeof e}static of(...e){return e.reduce(((e,t)=>e.merge(t)),new this({}))}static __unwrap(e){return e?e instanceof this?e.value:"object"!=typeof e?{}:{...e}:{}}static __merge(e,t){return f(this.__unwrap(t),((e,t,n)=>t instanceof KD?{...e,[n]:t}:(t=this.__unwrap(t),u(e,n)&&(t=this.__merge(this.__unwrap(e[n]),t)),{...e,[n]:t})),this.__unwrap(e))}}class ZD{constructor({name:e="Expressions",tokens:t=[],children:n=[],parent:i=null,context:o,value:r,raw:s}){this.name=e,this.tokens=t,this.children=n,this.parent=i,this.context=o,this.value=r,this.raw=s}enterScope(e){const t=this.of({name:e,parent:this});return AD&&console.log("[%s] enter",t.path,t.context),t}exitScope(e){return this.parent?(AD&&console.log("[%s] exit %o\n%s",this.path,this.context,LD(e," ")),this.parent.pushChild(this)):(AD&&console.log("[%s] NO exit %o\n%s",this.path,this.context,LD(e," ")),this)}token(e){return AD&&console.log("[%s] token <%s> + <%s>",this.path,this.tokens.join(" "),e),this.assign({tokens:[...this.tokens,e]})}literal(e){return AD&&console.log("[%s] literal %o",this.path,e),this.pushChild(this.of({name:"Literal",value:e}))}computedValue(){for(let e=this;;e=i$(e.children)){if(!e)return null;if(e.value)return e.value}}contextKeys(){return this.context.getKeys().map(JD)}get path(){return this.parent?.path?.concat(" > ",this.name)||this.name}get(e){const t=[e,e&&JD(e)],n=this.context.getKeys().find((e=>t.includes(JD(e))));if(void 0===n)return;const i=this.context.get(n);return i instanceof KD?i.get(this):i}resolveName(){const e=this.tokens.join(" "),t=this.assign({tokens:[]}),n=this.of({name:"VariableName",parent:t,value:this.get(e),raw:e});return AD&&console.log("[%s] resolve name <%s=%s>",n.path,e,this.get(e)),t.pushChild(n)}pushChild(e){if(!e)return this;const t=this.assign({children:[...this.children,e]});return e.parent=t,t}pushChildren(e){let t=this;for(const n of e)t=t.pushChild(n);return t}declareName(){if(0===this.tokens.length)throw Error("no tokens to declare name");const e=this.tokens.join(" ");return AD&&console.log("[%s] declareName <%s>",this.path,e),this.assign({tokens:[]}).pushChild(this.of({name:"Name",value:e}))}define(e,t){if("string"!=typeof e)return AD&&console.log("[%s] no define <%s=%s>",this.path,e,t),this;AD&&console.log("[%s] define <%s=%s>",this.path,e,t);const n=this.context.set(e,t);return this.assign({context:n})}assign(e={}){return ZD.of({...this,...e})}of(e={}){const t={context:this.context,parent:this.parent};return ZD.of({...t,...e})}static of(e){const{name:t,tokens:n=[],children:i=[],parent:o=null,context:r,value:s,raw:a}=e;if(!r)throw new Error("must provide <context>");return new ZD({name:t,tokens:[...n],children:[...i],context:r,parent:o,value:s,raw:a})}}function JD(e){return e.replace(/\s*([./\-'+]|\*\*?)\s*/g," $1 ").replace(/\s{2,}/g," ").trim()}function e$(e,t,n){const i=e.children.filter((e=>e.name!==t)),o=e.children.filter((e=>e.name===t)),r=i[0],s=i[Math.max(1,i.length-1)],a=r?.computedValue(),l=s?.computedValue()||null;return e.assign({children:o}).enterScope(t).pushChildren(i).exitScope(n).define(a,l)}function t$(e={},t=YD){const n=ZD.of({context:t.of(e)});return new BP({start:n,reduce(e,n,i,o){if(n===YP){const[n,i]=e.children.slice(-2);e=e.assign({value:t.of(n?.computedValue(),i?.computedValue())})}if(n===_D&&(e=e.assign({value:t.of(...e.children.map((e=>e?.computedValue())))})),n===hD){const[t,n]=e.children.slice(-2);e=e.assign({value:t?.computedValue()})}if(n===pD){const[t,...n]=e.children;"get value"===t?.raw&&(e=function(e,t){if(!t.length)return e.assign({value:null});"Name"===t[0].name&&(t=function(e,t){const n={};for(let t=0;t<e.length;t+=2){const[i,o]=e.slice(t,t+2);n[i.value]=o}return t.map((e=>n[e]))}(t,["m","key"]));if(2!==t.length)return e.assign({value:null});const[n,i]=t,o=i?.computedValue(),r=n?.computedValue();if(!r||"object"!=typeof r||"string"!=typeof o)return e.assign({value:null});return e.assign({value:[JD(o),o].reduce(((e,t)=>r.get(t)||e),null)})}(e,n))}const r=UD[n];if(r)return e.enterScope(r);const s=WD[n];if(s){const{children:i,context:o}=e,r=i.slice(0,-1),a=i$(i);let l=null;return n===uD&&(l=t.of(a?.computedValue())),n===dD&&(l=t.of(o,a?.computedValue()).set("item",a?.computedValue())),e.assign({children:r}).enterScope(s).pushChild(a).assign({context:l||o})}const a=o.read(o.pos,i.pos);if(XD[n])return e.exitScope(a);if(n===ED){const n=e.children.filter((e=>"ContextEntry"!==e.name)),i=n[0],o=i$(n);return e$(e,"ContextEntry",a).assign({value:t.of(e.value).set(i?.computedValue(),o?.computedValue())})}if(n===WP||n===tD)return e$(e,"InExpression",a);if(n===GP)return e.define("partial",KD.of((e=>i$(e.children)?.computedValue())));if(n===gD){const t=i$(e.children).computedValue();return e.define(t,1)}if(n===oD||n===rD||n===sD){const t=e.children.slice(0,-1),n=i$(e.children);return e.assign({children:t}).enterScope("ArithmeticExpression").pushChild(n)}if(n===aD)return e.enterScope("ArithmeticExpression");if(n===XP||n===KP||n===RD)return e.token(a);if(n===yD)return e.literal(a.replace(/^"|"$/g,""));if(n===xD)return e.literal("true"===a);if(n===vD)return e.literal(parseFloat(a));if(n===mD)return e.literal(null);if(n===lD)return e.resolveName();if(n===UP||n===SD)return e.declareName();if((n===zP||n===nD)&&e.tokens.length>0)throw new Error("uncleared name");if(n===zP){let t=e;for(;t.parent;)t=t.exitScope(a);return t}return e}})}const n$=t$({});function i$(e){return e[e.length-1]}const o$=VS({StringLiteral:lR.string,NumericLiteral:lR.number,BooleanLiteral:lR.bool,"AtLiteral!":lR.special(lR.string),CompareOp:lR.compareOperator,ArithOp:lR.arithmeticOperator,"for if then else some every satisfies between return":lR.controlKeyword,"in instance of and or":lR.operatorKeyword,function:lR.definitionKeyword,as:lR.keyword,"Type/...":lR.typeName,Wildcard:lR.special(lR.variableName),null:lR.null,LineComment:lR.lineComment,BlockComment:lR.blockComment,'VariableName! "?"':lR.variableName,"DateTimeConstructor! SpecialFunctionName!":lR.function(lR.special(lR.variableName)),"List Interval":lR.list,Context:lR.definition(lR.literal),"Name!":lR.definition(lR.variableName),"Key/Name! ContextEntryType/Name!":lR.definition(lR.propertyName),"PathExpression/VariableName!":lR.function(lR.propertyName),"FormalParameter/ParameterName!":lR.function(lR.definition(lR.variableName)),"( )":lR.paren,"[ ]":lR.squareBracket,"{ }":lR.brace,".":lR.derefOperator,", ;":lR.separator,"..":lR.punctuation}),r$={__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},s$=LP.deserialize({version:14,states:"C|O`QYOOO`QYOOO$sQYOOOOQU'#Ce'#CeO$}QYO'#C`O&WQYO'#FQOOQQ'#Ff'#FfO&bQYO'#FfO`QYO'#DVOOQU'#En'#EnO(UQ^O'#D]OOQU'#D^'#D^OOQU'#D]'#D]OOQO'#Fn'#FnO*RQWO'#DvOOQQ'#D}'#D}OOQQ'#EO'#EOOOQQ'#EP'#EPO*WOWO'#ESO*RQWO'#EQOOQQ'#EQ'#EQOOQQ'#Ft'#FtOOQQ'#Fr'#FrOOQQ'#Fy'#FyOOQQ'#EU'#EUO`QYO'#EWOOQQ'#FS'#FSO*]Q^O'#FSO,SQYO'#EXO,ZQWO'#EYOOQP'#F}'#F}O,`QXO'#EaOOQQ'#Fz'#FzOOQQ'#FR'#FRQOQWOOOOQQ'#FT'#FTOOQQ'#F^'#F^O`QYO'#CoOOQQ'#F_'#F_O$}QYO'#CsO,kQYO'#DwOOQQ'#Fs'#FsO,pQYO'#EROOQO'#ER'#ERO`QYO'#EVO`QYO'#EUOOQO'#F{'#F{Q,xQWOOO,}QYO'#DRO-tQWO'#FbOOQO'#DT'#DTO.PQYO'#FfO.WQWOOO.}QYO'#CdO/[QYO'#FVOOQQ'#Cc'#CcO/aQYO'#FUOOQQ'#Cb'#CbO/iQYO,58zO`QYO,59iOOQQ'#Fc'#FcOOQQ'#Fd'#FdOOQQ'#Fe'#FeO`QYO,59qO`QYO,59qO`QYO,59qOOQQ'#Fl'#FlO/nQYO,5:^OOQQ'#Fm'#FmO`QYO,5:`O`QYO,59eO`QYO,59gO`QYO,59iO1jQYO,59iO1qQYO,59rOOQQ,5:i,5:iO1vQYO,59qOOQU-E8l-E8lO3jQYO'#FoOOQQ,5:b,5:bOOQQ,5:n,5:nOOQQ,5:l,5:lO3qQYO,5:rOOQQ,5;n,5;nO3{QYO,5:qO4YQWO,5:sO4_QYO,5:tOOQP'#Ee'#EeO5UQXO'#EdOOQO'#Ec'#EcO5]QWO'#EbO5bQWO'#GOO5jQWO,5:{O5oQYO,59ZO/[QYO'#FaOOQQ'#Cw'#CwO5vQYO'#F`OOQQ'#Cv'#CvO6OQYO,59_O6TQYO,5:cO6YQYO,5:mO3tQYO,5:qO6_QYO,5:pO`QYO'#EwQ,xQWOOO`QYO'#EmO7UQWO,5;|O`QYOOOOQR'#Cf'#CfOOQQ'#Ej'#EjO8OQYO,59OO`QYO,5;qOOQQ'#FY'#FYO$}QYO'#EkO8`QYO,5;pO`QYO1G.fOOQQ'#F]'#F]O9VQYO1G/TO;|QYO1G/]O<WQYO1G/]O<bQYO1G/]OOQQ1G/x1G/xO>UQYO1G/zO>]QYO1G/PO?fQYO1G/RO@oQYO1G/TO`QYO1G/TOOQQ1G/T1G/TOAVQYO1G/^OAtQ^O'#CdOCWQYO'#FqOOQO'#Dz'#DzOCbQWO'#DyOCgQWO'#FpOOQO'#Dx'#DxOOQO'#D{'#D{OCoQWO,5<ZOOQQ1G0^1G0^O`QYO1G0]O`QYO'#EsOCtQWO,5<]OOQQ1G0_1G0_ODPQWO'#E[OD[QWO'#F|OOQO'#EZ'#EZODdQWO1G0`OOQP'#Eu'#EuODiQXO,5;OO`QYO,5:|ODpQXO'#EvODxQWO,5<jOOQQ1G0g1G0gO`QYO1G.uO`QYO,5;{O$}QYO'#ElOEQQYO,5;zO`QYO1G.yOEYQYO1G/}OOQO1G0X1G0XOOQO,5;c,5;cOOQO-E8u-E8uOOQO,5;X,5;XOOQO-E8k-E8kOE_QWOOOOQQ-E8h-E8hOEdQYO'#CmOOQQ1G1]1G1]OOQQ,5;V,5;VOOQQ-E8i-E8iOEqQYO7+$QOOQQ7+%f7+%fO`QYO7+$oOFhQYO,5:rOFuQWO7+$oOFzQYO'#D[OOQQ'#DZ'#DZOHnQYO'#D_OHsQYO'#D_OHxQYO'#D_OH}Q`O'#DgOISQ`O'#DjOIXQ`O'#DnOOQQ7+$x7+$xO`QYO,5:eO$}QYO'#ErOI^QWO,5<[OOQQ1G1u1G1uOJdQYO7+%wOJqQYO,5;_OOQO-E8q-E8qOAVQYO,5:vO$}QYO'#EtOKOQWO,5<hOKWQYO7+%zOOQP-E8s-E8sOK_QYO1G0hOOQO,5;b,5;bOOQO-E8t-E8tOKiQYO7+$aOKpQYO1G1gOOQQ,5;W,5;WOOQQ-E8j-E8jOKzQYO7+$eOOQO7+%i7+%iO`QYO,59XOLqQYO<<HZOOQQ<<HZ<<HZO/nQYO'#EoOMzQYO,59vO! nQYO,59yO! sQYO,59yO! xQYO,59yO! }QYO,5:RO$}QYO,5:UO!!lQbO,5:YO!!sQYO1G0POOQO,5;^,5;^OOQO-E8p-E8pO!!}QYO<<IcOOQQ<<Ic<<IcOOQO1G0b1G0bOOQO,5;`,5;`OOQO-E8r-E8rO!%|QYO'#E^OOQQ<<If<<IfO`QYO<<IfO`QYO<<G{O!&sQYO1G.sOOQQ,5;Z,5;ZOOQQ-E8m-E8mO!&}QYO1G/eOOQQ1G/e1G/eO!'SQbO'#D]O!'eQ`O'#D[O!'pQ`O1G/mO!'uQWO'#DmO!'zQ`O'#FhOOQO'#Dl'#DlO!(SQ`O1G/pOOQO'#Dq'#DqO!(XQ`O'#FjOOQO'#Dp'#DpO!(aQ`O1G/tOOQQAN?QAN?QO!(fQYOAN=gOOQQ7+%P7+%PO!)]Q`O,59vOOQQ7+%X7+%XO! }QYO,5:XO$}QYO'#EpO!)hQ`O,5<SOOQQ7+%[7+%[O! }QYO'#EqO!)pQ`O,5<UO!)xQ`O7+%`OOQO1G/s1G/sOOQO,5;[,5;[OOQO-E8n-E8nOOQO,5;],5;]OOQO-E8o-E8oOAVQYO<<HzOOQQAN>fAN>fO/nQYO'#EoO! }QYO<<HzO!)}Q`O7+%`O!*SQ`O1G/tO!!lQbO,5:YO!*XQ`O'#Dn",stateData:"!*h~O#rOS#sOSPOSQOS~OTsOZVO[UOdtOhvOivOr}Os}OviO!T{O!U{O!VxO!XzO!c!OO!g|O!igO!pyO!wjO#SnO#nRO#oRO$ZZO$i_O$j`O$kaO$lbO~OTsO[UOdtOhvOivOr}Os}OviO!T{O!U{O!VxO!XzO!c!OO!g|O!igO!pyO!wjO#SnO#nRO#oRO$ZZO$i_O$j`O$kaO$lbO~OZ!TO#]!UO~P#SO#nRO#oRO~OZ!^O[!^O]!_O^!_O_!`O`!kOn!hOp!iOr!]Os!]Ot!jO{!lO!i!fO#z!dOv$bX~O#l#tX$s#tX~P%VO$i!mOT$YXZ$YX[$YXd$YXh$YXi$YXr$YXs$YXv$YX!T$YX!U$YX!V$YX!X$YX!c$YX!g$YX!i$YX!p$YX!w$YX#S$YX#n$YX#o$YX$Z$YX$j$YX$k$YX$l$YX~O#nRO#oROZ!PX[!PX]!PX^!PX_!PX`!PXn!PXp!PXr!PXs!PXt!PXv!PX{!PX!i!PX#l!PX#p!PX#z!PX$s!PX$O!PXx!PX#}!PX!g!PXe!PXb!PX#R!PXf!PXl!PX~Ov!pO~O$j`O~O#p!uOZ#vX[#vX]#vX^#vX_#vX`#vXn#vXp#vXr#vXs#vXt#vXv#vX{#vX!i#vX#l#vX#z#vX$s#vX$O#vXx#vX#}#vX!g#vXe#vXb#vX#R#vXf#vXl#vX~O!g$eP~P`Ov!xO~O#m!yO$j`O#R$rP~Op#VO~Op#WOv!uX~O$s#ZO~O#luX$OuX$suXxuX#}uX!guXeuXbuX#RuXfuXluX~P%VO$O#]O#l$UXx$UX~O#l#[X~P&bOv#_O~OZ#`O[#`O]#`O^#`O_#`O#nRO#oRO#z#`O#{#`O$]WX~O`WXxWX$OWX~P.]O`#dO~O$O#eOb#xX~Ob#hO~O#nRO#oRO$ZZO~OTsOZVO[UOdtOhvOivOr}Os}O!T{O!U{O!VxO!XzO!c!OO!g|O!igO!pyO!wjO#SnO#nRO#oRO$ZZO$i_O$j`O$kaO$lbO~Ov#rO~P/yO|#tO~O{!lO!i!fO#z!dOZya[ya]ya^ya_ya`yanyapyaryasyatyav$bX#lya$sya$Oyaxya#}ya!gyaeyabya#Ryafyalya~Ox$eP~P`Ox#}O#}$OO~P%VO#}$OO$O$PO!g$eX~P%VO!g$RO~O#nRO#oROx$pP~OZ#`O[#`O]#`O^#`O_#`O#m!yO#z#`O#{#`O~O$]#WX~P4jO$]$YO~O$O$ZO#R$rX~O#R$]O~Oe$^O~P%VO$O$`Ol$SX~Ol$bO~O!W$cO~O!T$dO~O#l!xa$s!xa$O!xax!xa#}!xa!g!xae!xab!xa#R!xaf!xal!xa~P%VO$O#]O#l$Uax$Ua~OZ#`O[#`O]#`O^#`O_#`O#nRO#oRO#z#`O#{#`O~O`Wa$]WaxWa$OWa~P7aO$O#eOb#xa~OZ!^O[!^O]!_O^!_O_!`O{!lO!i!fO#z!dOv$bX~O`qinqipqirqisqitqi#lqi$sqi$Oqixqi#}qi!gqieqibqi#Rqifqilqi~P8hO_!`O{!lO!i!fO#z!dOZyi[yi`yinyipyiryisyityiv$bX#lyi$syi$Oyixyi#}yi!gyieyibyi#Ryifyilyi~O]!_O^!_O~P:`O]yi^yi~P:`O{!lO!i!fO#z!dOZyi[yi]yi^yi_yi`yinyipyiryisyityiv$bX#lyi$syi$Oyixyi#}yi!gyieyibyi#Ryifyilyi~O!g$pO~P%VO`!kOp!iOr!]Os!]Ot!jOnmi#lmi$smi$Omixmi#}mi!gmiemibmi#Rmifmilmi~P8hO`!kOr!]Os!]Ot!jOnoipoi#loi$soi$Ooixoi#}oi!goieoiboi#Roifoiloi~P8hO`!kOn!hOp$qOr!]Os!]Ot!jO~P8hO!S$vO!V$wO!X$xO![$yO!_$zO!c${O#nRO#oRO$ZZO~OZ#bX[#bX]#bX^#bX_#bX`#bXn#bXp#bXr#bXs#bXt#bXv#bXx#bX{#bX!i#bX#n#bX#o#bX#p#bX#z#bX$O#bX~P.]O$O$POx$eX~P%VO$]$}O~O$O%OOx$dX~Ox%QO~O$O$PO!g$eax$ea~O$]%UOx#OX$O#OX~O$O%VOx$pX~Ox%XO~O$]#Wa~P4jO#m!yO$j`O~O$O$ZO#R$ra~O$O$`Ol$Sa~O!U%cO~OxrO~O#}%dObaX$OaX~P%VO#lSq$sSq$OSqxSq#}Sq!gSqeSqbSq#RSqfSqlSq~P%VOx#}O#}$OO$OuX~P%VOx%fO~O#z%gOZ!OX[!OX]!OX^!OX_!OX`!OXn!OXp!OXr!OXs!OXt!OXv!OX{!OX!i!OX#l!OX$s!OX$O!OXx!OX#}!OX!g!OXe!OXb!OX#R!OXf!OXl!OX~Op%iO~Op%jO~Op%kO~O!]%lO~O!]%mO~O!]%nO~O$O%OOx$da~OZ!^O[!^O]!_O^!_O_!`O`!kOn!hOp!iOr!]Os!]Ot!jO{!lO#z!dOv$bX~Ox%sO!g%sO!i%rO~PIfO!g#ga$O#gax#ga~P%VO$O%VOx$pa~O#P%yO~P`O#R#Ui$O#Ui~P%VOf%zO~P%VOl$Ti$O$Ti~P%VO#lgq$sgq$Ogqxgq#}gq!ggqegqbgq#Rgqfgqlgq~P%VO`qynqypqyrqysqytqy#lqy$sqy$Oqyxqy#}qy!gqyeqybqy#Rqyfqylqy~P8hO#z%gOZ!Oa[!Oa]!Oa^!Oa_!Oa`!Oan!Oap!Oar!Oas!Oat!Oav!Oa{!O 7 */var or=/,?([a-z]),?/gi,ar=parseFloat,sr=Math,ur=sr.PI,cr=sr.min,lr=sr.max,dr=sr.pow,pr=sr.abs,hr=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?[\s]*,?[\s]*)+)/gi,fr=/( global() class [all...] |
H A D | dmn-viewer.production.min.js | 16 */function fs(e){this._container=this._createContainer(),lo(this._container),this._init(this._container,e)}rn(fs,mi),fs.prototype.saveSVG=jt((function(e){var t=this;return new Promise((function(e){var n=t.get("canvas"),i=n.getActiveLayer(),r=It("defs",n._svg),o=Mn(i),s=r&&r.outerHTML||"",a=i.getBBox();e({svg:'<?xml version="1.0" encoding="utf-8"?>\n\x3c!-- created with dmn-js / http://bpmn.io --\x3e\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'+a.width+'" height="'+a.height+'" viewBox="'+a.x+" "+a.y+" "+a.width+" "+a.height+'" version="1.1">'+s+o+"</svg>"})}))})),fs.prototype.getModules=function(){return this._modules},fs.prototype.destroy=function(){mi.prototype.destroy.call(this),Ft(this._container)},fs.prototype.on=function(e,t,n,i){return this.get("eventBus").on(e,t,n,i)},fs.prototype.off=function(e,t){this.get("eventBus").off(e,t)},fs.prototype._init=function(e,t){var{additionalModules:n,canvas:i,...r}=t,o={...r,canvas:{...i,container:e},modules:[...[{drd:["value",this]}],...t.modules||this.getModules(),...n||[]]};mi.call(this,o),t&&t.container&&this.attachTo(t.container)},fs.prototype._emit=function(e,t){return this.get("eventBus").fire(e,t)},fs.prototype._createContainer=function(){return Lt('<div class="dmn-drd-container"></div>')},fs.prototype.open=function(e){var t=this;return new Promise(((n,i)=>{var r;try{return t._definitions&&t.clear(),t._definitions=e,function(e,t,n){var i,r=e.get("drdImporter"),o=e.get("eventBus"),s=[];o.fire("import.start",{definitions:t});try{!function(e){new xi({root:function(e){return r.root(e)},element:function(e,t){return r.add(e,t)},error:function(e,t){s.push({message:e,context:t})}}).handleDefinitions(e)}(t)}catch(e){i=e}o.fire("import.done",{error:i,warnings:s}),n(i,s)}(t,e,(function(e,t){e?(e.warnings=t||[],i(e)):n({warnings:t||[]})}))}catch(e){r=e}r?(r.warnings=r.warnings||[],i(r)):n({warnings:[]})}))},fs.prototype.attachTo=function(e){if(!e)throw new Error("parentNode required");this.detach();var t=this._container;e.appendChild(t),this._emit("attach",{}),this.get("canvas").resized()},fs.prototype.detach=function(){var e=this._container,t=e.parentNode;t&&(this._emit("detach",{}),t.removeChild(e))},fs.prototype._modules=[Fo,jo,es,as,hs,ps];class gs{constructor(e){b(this,e),ys(this,"businessObject",{writable:!0})}}const ms={root:class extends gs{constructor(e){super(e),ys(this,"rows",{enumerable:!0,value:this.rows||[]}),ys(this,"cols",{enumerable:!0,value:this.cols||[]})}},row:class extends gs{constructor(e){super(e),ys(this,"root",{writable:!0}),ys(this,"cells",{enumerable:!0,value:this.cells||[]})}},col:class extends gs{constructor(e){super(e),ys(this,"root",{writable:!0}),ys(this,"cells",{enumerable:!0,value:this.cells||[]})}},cell:class extends gs{constructor(e){super(e),ys(this,"row",{writable:!0}),ys(this,"col",{writable:!0})}}};function ys(e,t,n){Object.defineProperty(e,t,n)}let vs=class{constructor(e){this._eventBus=e,this._elements={},e.on("table.clear",this.clear.bind(this))}add(e,t){const{id:n}=e;this._elements[n]=e}remove(e){const t=e.id||e;delete this._elements[t]}get(e){return this._elements[e]}getAll(){return ws(this._elements)}forEach(e){ws(this._elements).forEach((t=>e(t)))}filter(e){return ws(this._elements).filter((t=>e(t)))}clear(){this._elements={}}updateId(e,t){this._validateId(t),"string"==typeof e&&(e=this.get(e)),this._eventBus.fire("element.updateId",{element:e,newId:t}),this.remove(e),e.id=t,this.add(e)}_validateId(e){if(!e)throw new Error("element must have an id");if(this._elements[e])throw new Error("element with id "+e+" already added")}};function ws(e){return Object.keys(e).map((function(t){return e[t]}))}vs.$inject=["eventBus"];let bs=class{constructor(e){this._listeners={},e.on("elements.changed",(({elements:e})=>{this.elementsChanged(e)})),e.on("root.remove",(t=>{const n=t.root.id;this._listeners[n]&&e.once("root.add",(e=>{const t=e.root.id;this.updateId(n,t)}))})),e.on("element.updateId",(({element:e,newId:t})=>{this.updateId(e.id,t)}))}elementsChanged(e){const t={},n=e.length;for(let i=0;i<n;i++){const{id:n}=e[i];if(t[n])return;t[n]=!0;const r=this._listeners[n]&&this._listeners[n].length;if(r)for(let e=0;e<r;e++)this._listeners[n][e]&&this._listeners[n][e]()}}onElementsChanged(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e][this._listeners[e].length]=t}offElementsChanged(e,t){if(this._listeners[e])if(t){const n=this._listeners[e].indexOf(t);-1!==n&&this._listeners[e].splice(n,1)}else this._listeners[e].length=0}updateId(e,t){this._listeners[e]&&(this._listeners[t]=this._listeners[e],delete this._listeners[e])}};bs.$inject=["eventBus"];class xs extends oo{constructor(e){super(e);const t=this._injector=e.injector;this._sheet=t.get("sheet"),this._changeSupport=t.get("changeSupport"),this._components=t.get("components"),this._eventBus=t.get("eventBus");const n=t.get("throttle");this.onElementsChanged=this.onElementsChanged.bind(this),this.onScroll=n(this.onScroll.bind(this))}onElementsChanged(){this.forceUpdate()}onScroll(){this._eventBus.fire("sheet.scroll")}getChildContext(){return{changeSupport:this._changeSupport,components:this._components,injector:this._injector}}componentWillMount(){const{id:e}=this._sheet.getRoot();this._changeSupport.onElementsChanged(e,this.onElementsChanged)}componentWillUnmount(){const{id:e}=this._sheet.getRoot();this._changeSupport.offElementsChanged(e,this.onElementsChanged)}render(){const{rows:e,cols:t}=this._sheet.getRoot(),n=this._components.getComponents("table.before"),i=this._components.getComponents("table.after"),r=this._components.getComponent("table.head"),o=this._components.getComponent("table.body"),s=this._components.getComponent("table.foot");return zi(1,"div","tjs-container",[n&&n.map(((e,t)=>Hi(2,e,null,t))),zi(1,"div","tjs-table-container",zi(1,"table","tjs-table",[r&&Hi(2,r,{rows:e,cols:t}),o&&Hi(2,o,{rows:e,cols:t}),s&&Hi(2,s,{rows:e,cols:t})],0),2,{onScroll:this.onScroll}),i&&i.map(((e,t)=>Hi(2,e,null,t)))],0)}}let ks=class{constructor(e,t,n,i,r){const{container:o}=n;this._container=o,i.on("root.added",(()=>{eo(Hi(2,xs,{injector:r}),o)})),i.on("root.remove",(()=>{eo(null,o)}))}getContainer(){return this._container}};ks.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var _s={__init__:["changeSupport","components","renderer"],changeSupport:["type",bs],components:["type",class{constructor(){this._listeners={}}getComponent(e,t){const n=this._listeners[e];if(!n)return;let i;for(let e=0;e<n.length&&(i=n[e].callback(t),!i);e++);return i}getComponents(e,t){const n=this._listeners[e],i=[];if(!n)return i;for(let e=0;e<n.length;e++){const r=n[e].callback(t);r&&i.push(r)}return i.length,i}onGetComponent(e,t,n){if(s(t)&&(n=t,t=1e3),!o(t))throw new Error("priority must be a number");const i=this._getListeners(e);let r,a;const l={priority:t,callback:n};for(a=0;r=i[a];a++)if(r.priority<t)return void i.splice(a,0,l);i.push(l)}offGetComponent(e,t){const n=this._getListeners(e);let i,r,o;if(t)for(o=n.length-1;i=n[o];o--)r=i.callback,r===t&&n.splice(o,1);else n.length=0}_getListeners(e){let t=this._listeners[e];return t||(this._listeners[e]=t=[]),t}}],renderer:["type",ks]};class Ss{constructor(e,t){this._elementRegistry=e,this._eventBus=t,this._root=null,t.on("table.clear",(()=>{this.setRoot(null)}))}setRoot(e){if(this._root){const e=this._root;this._eventBus.fire("root.remove",{root:e}),this._root=null,this._eventBus.fire("root.removed",{root:e})}e&&this._eventBus.fire("root.add",{root:e}),this._root=e,e&&this._eventBus.fire("root.added",{root:e})}getRoot(){return this._root||this.setRoot({id:"__implicitroot",rows:[],cols:[]}),this._root}addRow(e,t){const n=this.getRoot();if(n.cols.length!=e.cells.length)throw new Error("number of cells is not equal to number of cols");return void 0===t&&(t=n.rows.length),Cs(t,n.rows,e),e.root=n,this._elementRegistry.add(e),e.cells.forEach(((i,r)=>{this._elementRegistry.add(i),i.row=e,i.col=n.cols[r],Cs(t,n.cols[r].cells,i)})),this._eventBus.fire("row.add",{row:e}),e}removeRow(e){const t=this.getRoot();"string"==typeof e&&(e=this._elementRegistry.get(e));const n=t.rows.indexOf(e);-1!==n&&(Es(n,t.rows),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach(((e,i)=>{this._elementRegistry.remove(e),e.col=void 0,Es(n,t.cols[i].cells)})),this._eventBus.fire("row.remove",{row:e}))}addCol(e,t){const n=this.getRoot();if(this._elementRegistry.add(e),n.rows.length!=e.cells.length)throw new Error("number of cells is not equal to number of rows");return void 0===t&&(t=n.cols.length),Cs(t,n.cols,e),e.root=n,e.cells.forEach(((i,r)=>{this._elementRegistry.add(i),i.col=e,i.row=n.rows[r],Cs(t,n.rows[r].cells,i)})),this._eventBus.fire("col.add",{col:e}),e}removeCol(e){const t=this.getRoot();"string"==typeof e&&(e=this._elementRegistry.get(e));const n=t.cols.indexOf(e);-1!==n&&(Es(n,t.cols),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach(((e,i)=>{this._elementRegistry.remove(e),e.row=void 0,Es(n,t.rows[i].cells)})),this._eventBus.fire("col.remove",{col:e}))}resized(){this._eventBus.fire("sheet.resized")}}function Cs(e,t,n){return t.splice(e,0,n)}function Es(e,t){return t.splice(e,1)}function Ms(e=!0){const t="number"==typeof e?e:e?300:0;return t?e=>function(e,t){let n=!1;return function(...i){n||(e(...i),n=!0,setTimeout((()=>{n=!1}),t))}}(e,t):e=>e}Ss.$inject=["elementRegistry","eventBus"],Ms.$inject=["config.throttle"];var As={__depends__:[_s],__init__:["elementFactory","sheet"],elementFactory:["type",class{constructor(){this._uid=12}create(e,t={}){return t.id||(t.id=e+"_"+this._uid++),function(e,t){const n=ms[e];if(!n)throw new Error("unknown type "+e);return new n(t)}(e,t)}createRoot(e){return this.create("root",e)}createRow(e){return this.create("row",e)}createCol(e){return this.create("col",e)}createCell(e){return this.create("cell",e)}}],elementRegistry:["type",vs],eventBus:["type",_],sheet:["type",Ss],throttle:["factory",Ms]};class Ds{constructor(e={}){let{injector:t}=e;if(!t){let{modules:n,config:i}=this._init(e);t=function(e,t){const n=[{config:["value",e]},As].concat(t||[]),i=new tn(n);return i.init(),i}(i,n)}this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("table.init"),this.get("eventBus").fire("diagram.init")}_init(e){let{modules:t,...n}=e;return{modules:t,config:n}}destroy(){const e=this.get("eventBus");e.fire("table.destroy"),e.fire("diagram.destroy")}clear(){const e=this.get("eventBus");e.fire("table.clear"),e.fire("diagram.clear")}}function Rs(e){if(!e)return"<null>";const t=e.id?` id="${e.id}"`:"";return`<${e.$type}${t} />`}function Os(e,t){function n(t,n,i){if(t.gfx)throw new Error(`already rendered ${Rs(t)}`);return e.element(t,n,i)}function i(e,t,i){u(e,(function(e){n(e,t,i)}))}function r(e,t,i){u(e,(function(e){n(e,t,i)}))}return{handleDecision:function(t){t.id||(t.id="decision");const o=t.decisionLogic;if(!o)throw new Error(`no table for ${Rs(t)}`);{if(!o.output)throw new Error(`missing output for ${Rs(o)}`);const t=(c=o,e.table(c));o.input&&i(o.input,t,o),i(o.output,t,o),s=o.rule,a=t,l=o,u(s,(function(e){n(e,a,l),r(e.inputEntry,e),r(e.outputEntry,e)}))}var s,a,l,c}}}function Ts(e,t){const{elements:n,index:i}=e;return i[t]?e:{elements:[...n,t],index:{...i,[t]:!0}}}function Ns(...e){let t={elements:[],index:{}};return e.forEach((function(e){const n=typeof e;"string"===n&&e.length>0?t=Ts(t,e):"object"===n&&null!==e&&Object.keys(e).forEach((function(n){e[n]&&(t=Ts(t,n))}))})),function(e,t){return e.elements.join(t)}(t," ")}function Ps(e){return qs(e.constructor,e)}function qs(e,t){const n=e.$inject;if(!n)return;const{injector:i}=t.context,r=[...n,function(...e){for(const i in e){const r=n[i],o=e[i];t[r]=o}}];i.invoke(r)}function Bs(e,t){Object.keys(t).forEach((function(n){if("$inject"===n||"__init"===n)return;const i=t[n];"constructor"===n&&i.call(e,e.props,e.context);const r=e[n];if(void 0!==r){if("function"!=typeof r)throw new Error(`failed to mixin <${n}>: cannot combine with non-fn component value`);e[n]=function(e,...t){return function(...n){let i;return t.forEach((function(t){if(i=t.call(e,...n),void 0!==i)return!1})),i}.bind(e)}(e,r,i)}else e[n]=i.bind(e)})),"$inject"in t&&qs(t,e),"__init"in t&&t.__init.call(e,e.props,e.context)}const Ls={getSelectionClasses(){const{selected:e,selectedSecondary:t,focussed:n}=this.state;return Ns({selected:e,"selected-secondary":t,focussed:n})},selectionChanged(e){this.setState(e)},componentWillUpdate(e){e.elementId!==this.props.elementId&&this.updateSelectionSubscription(!1)},componentDidUpdate(e){e.elementId!==this.props.elementId&&this.updateSelectionSubscription(!0)},componentDidMount(){this.updateSelectionSubscription(!0)},componentWillUnmount(){this.updateSelectionSubscription(!1)},updateSelectionSubscription(e){const{elementId:t}=this.props;t&&t&&this.eventBus[e?"on":"off"](`selection.${t}.changed`,this.selectionChanged)},$inject:["eventBus"]};class Is extends oo{constructor(e,t){super(e,t),Bs(this,Ls),Ps(this)}getRenderProps(...e){const{className:t,elementId:n,coords:i,...r}=this.props,o={className:Ns(...e,this.getSelectionClasses(),t)};return n&&(o["data-element-id"]=n),i&&(o["data-coords"]=i),{...o,...r}}}class Fs extends Is{constructor(e,t){super(e,t),this.state={}}render(){const{children:e}=this.props;return Ui(zi(1,"td",null,e,0,{...this.getRenderProps("cell")}))}}const js={slotFill(e,t){const{type:n,context:i,...r}=e,o=this.components.getComponent(n,i)||t;return o?Ui(Hi(2,o,{...i,...r})):null},slotFills(e){const{type:t,context:n,...i}=e;return this.components.getComponents(t,n).map((e=>Ui(Hi(2,e,{...n,...i}))))},$inject:["components"]};class Vs extends oo{constructor(e,t){super(e,t),Bs(this,js),Ps(this)}componentDidMount(){this.changeSupport.onElementsChanged(this.getRoot(),this.onElementsChanged)}componentWillUnmount(){this.changeSupport.offElementsChanged(this.getRoot(),this.onElementsChanged)}onElementsChanged=()=>{this.forceUpdate()};getRoot(){return this.sheet.getRoot()}render(){const e=(this.getRoot().businessObject.get("annotationsWidth")||400)+"px";return zi(1,"th","annotation header",[this.slotFills({type:"cell-inner",context:{cellType:"annotations",col:this.sheet.getRoot(),minWidth:400}}),this.translate("Annotations")],0,{style:{width:e}})}}function $s(e){const{row:t}=e,{id:n,description:i}=t.businessObject;return Hi(2,Fs,{className:"annotation",elementId:n,children:i||"-"})}function zs(e){e.onGetComponent("cell",(({cellType:e})=>"after-label-cells"===e?Vs:"after-rule-cells"===e?$s:void 0))}Vs.$inject=["changeSupport","sheet","translate"],zs.$inject=["components"];var Hs={__init__:["annotationsProvider"],annotationsProvider:["type",zs]};function Ws(e,t){return b({id:e.id,type:e.$type,businessObject:e},t)}class Us{constructor(e,t,n){this._elementFactory=e,this._eventBus=t,this._sheet=n}add(e){let t;if(yi(e,"dmn:DecisionTable"))t=this._elementFactory.createRoot(Ws(e)),this._sheet.setRoot(t);else if(yi(e,"dmn:InputClause"))t=this._elementFactory.createCol(Ws(e)),this._sheet.addCol(t);else if(yi(e,"dmn:OutputClause"))t=this._elementFactory.createCol(Ws(e)),this._sheet.addCol(t);else if(yi(e,"dmn:DecisionRule")){e.inputEntry||(e.inputEntry=[]),e.outputEntry||(e.outputEntry=[]);const n=[...e.inputEntry,...e.outputEntry].map((e=>this._elementFactory.createCell(Ws(e))));t=this._elementFactory.createRow(b(Ws(e),{cells:n})),this._sheet.addRow(t)}return this._eventBus.fire("dmnElement.added",{element:t}),t}}Us.$inject=["elementFactory","eventBus","sheet"];var Gs={__depends__:[{__depends__:[jo],tableImporter:["type",Us]},_s]};class Ks extends oo{constructor(e,t){super(e,t),Bs(this,js),this._sheet=t.injector.get("sheet"),this._changeSupport=t.changeSupport}onElementsChanged=()=>{this.forceUpdate()};componentWillMount(){const e=this._sheet.getRoot();this._changeSupport.onElementsChanged(e.id,this.onElementsChanged)}componentWillUnmount(){const e=this._sheet.getRoot();this._changeSupport.offElementsChanged(e.id,this.onElementsChanged)}render(){const e=this._sheet.getRoot();if(!yi(e,"dmn:DMNElement"))return null;const t=vi(e),n=t.input,i=t.output;return zi(1,"thead",null,zi(1,"tr",null,[zi(1,"th","index-column"),this.slotFills({type:"cell",context:{cellType:"before-label-cells"}}),n&&n.map(((e,t)=>{const i=e.width||"192px";return this.slotFill({type:"cell",context:{cellType:"input-header",input:e,index:t,inputsLength:n.length,width:i},key:e.id},Xs)})),i.map(((e,t)=>this.slotFill({type:"cell",context:{cellType:"output-header",output:e,index:t,outputsLength:i.length},key:e.id},Ys))),this.slotFills({type:"cell",context:{cellType:"after-label-cells"}})],0),2)}}function Xs(e,t){const{input:n,className:i,index:r}=e,{label:o,inputExpression:s,inputValues:a}=n,l=t.injector.get("translate");return zi(1,"th",(i||"")+" input-cell",[zi(1,"div","clause",l(0===r?"When":"And"),0),o?zi(1,"div","input-label",o,0,{title:l("Input label: ")+o}):zi(1,"div","input-expression",s.text,0,{title:l("Input expression: ")+s.text}),zi(1,"div","input-variable",a&&a.text||s.typeRef,0,{title:a&&a.text?l("Input values"):l("Input type")})],0,{"data-col-id":n.id},n.id)}function Ys(e,t){const{output:n,className:i,index:r}=e,{label:o,name:s,outputValues:a,typeRef:l}=n,c=t.injector.get("translate");return zi(1,"th",(i||"")+" output-cell",[zi(1,"div","clause",c(0===r?"Then":"And"),0),o?zi(1,"div","output-label",o,0,{title:c("Output label")}):zi(1,"div","output-name",s,0,{title:c("Output name")}),zi(1,"div","output-variable",a&&a.text||l,0,{title:a&&a.text?c("Output values"):c("Output type")})],0,null,n.id)}function Js(e){e.onGetComponent("table.head",(()=>Ks))}Js.$inject=["components"];var Qs={__init__:["decisionTableHeadProvider"],decisionTableHeadProvider:["type",Js]};class Zs extends oo{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),Ps(this)}render(){const e=this.sheet.getRoot();if(!yi(e,"dmn:DMNElement"))return null;const{name:t}=e.businessObject.$parent,n=this.components.getComponent("hit-policy")||ea;return zi(1,"div","decision-table-properties",[zi(1,"div","decision-table-name",t,0,{title:this._translate("Decision name: ")+t}),zi(1,"div","decision-table-header-separator"),Hi(2,n)],4)}}function ea(){return null}Zs.$inject=["sheet","components"];class ta{constructor(e){e.onGetComponent("table.before",500,(()=>Zs))}}ta.$inject=["components"];var na={__init__:["decisionTableProperties"],decisionTableProperties:["type",ta]};class ia extends oo{render(){const{row:e,rowIndex:t}=this.props,{components:n}=this.context,i=n.getComponents("cell-inner",{cellType:"rule-index",row:e,rowIndex:t});return zi(1,"td","rule-index",[i&&i.map((n=>Hi(2,n,{row:e,rowIndex:t}))),t+1],0,{"data-element-id":e.id,"data-row-id":e.id})}}class ra{constructor(e){e.onGetComponent("cell",(({cellType:e})=>{if("before-rule-cells"===e)return ia}))}}ra.$inject=["components"];var oa={__init__:["decisionRuleIndices"],decisionRuleIndices:["type",ra]};const sa=[{label:"FEEL",value:"feel"}];class aa{constructor(e){this._injector=e;const t=e.get("config.expressionLanguages")||{};this._config={options:sa,defaults:{editor:"feel"}},t.options&&(this._config.options=t.options);const n=this._getLegacyDefaults();b(this._config.defaults,n,t.defaults)}getDefault(e){const{defaults:t}=this._config,n=t[e]||t.editor;return this._getLanguageByValue(n)||this.getAll()[0]}getLabel(e){const t=this._getLanguageByValue(e);return t?t.label:e}getAll(){return this._config.options}_getLegacyDefaults(){const e={},t=this._injector,n=t.get("config.defaultInputExpressionLanguage"),i=t.get("config.defaultOutputExpressionLanguage");return n&&(e.inputCell=n),i&&(e.outputCell=i),e}_getLanguageByValue(e){return c(this.getAll(),(t=>e===t.value))}}aa.$inject=["injector"];var la={__init__:["expressionLanguages"],expressionLanguages:["type",aa]};class ca extends oo{render({rows:e,cols:t}){const{components:n}=this.context;return zi(1,"tbody",null,e.map(((e,i)=>{const r=n.getComponent("row",{rowType:"rule"});return r&&Hi(2,r,{row:e,rowIndex:i,cols:t},e.id)})),0)}}class ha extends oo{constructor(e,t){super(e,t),Bs(this,js)}render(){const{row:e,rowIndex:t,cols:n}=this.props,{cells:i}=e;return zi(1,"tr",null,[this.slotFills({type:"cell",context:{cellType:"before-rule-cells",row:e,rowIndex:t}}),i.map(((i,r)=>this.slotFill({type:"cell",context:{cellType:"rule",cell:i,rowIndex:t,colIndex:r},key:i.id,row:e,col:n[r]}))),this.slotFills({type:"cell",context:{cellType:"after-rule-cells",row:e,rowIndex:t}})],0)}}class ua extends oo{render(){const{cell:e,row:t,col:n}=this.props;return yi(e,"dmn:UnaryTests")?Hi(2,Fs,{className:"input-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":n.id,children:e.businessObject.text}):Hi(2,Fs,{className:"output-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":n.id,children:e.businessObject.text})}}class da{constructor(e){e.onGetComponent("table.body",(()=>ca)),e.onGetComponent("row",(({rowType:e})=>{if("rule"===e)return ha})),e.onGetComponent("cell",(({cellType:e})=>{if("rule"===e)return ua}))}}da.$inject=["components"];var pa={__depends__:[la],__init__:["decisionRules"],decisionRules:["type",da]};const fa=[{label:"Unique",value:{hitPolicy:"UNIQUE",aggregation:void 0},explanation:"No overlap is possible and all rules are disjoint. Only a single rule can be matched"},{label:"First",value:{hitPolicy:"FIRST",aggregation:void 0},explanation:"Rules may overlap. The first matching rule will be chosen"},{label:"Priority",value:{hitPolicy:"PRIORITY",aggregation:void 0},explanation:"Rules may overlap. The one with the highest priority will be chosen"},{label:"Any",value:{hitPolicy:"ANY",aggregation:void 0},explanation:"Rules may overlap. Their output have to match"},{label:"Collect",value:{hitPolicy:"COLLECT",aggregation:void 0},explanation:"Collects the values of all matching rules"},{label:"Collect (Sum)",value:{hitPolicy:"COLLECT",aggregation:"SUM"},explanation:"Collects the values of all matching rules and sums up to a single value"},{label:"Collect (Min)",value:{hitPolicy:"COLLECT",aggregation:"MIN"},explanation:"Collects the values of all matching rules and uses the lowest value"},{label:"Collect (Max)",value:{hitPolicy:"COLLECT",aggregation:"MAX"},explanation:"Collects the values of all matching rules and uses the highest value"},{label:"Collect (Count)",value:{hitPolicy:"COLLECT",aggregation:"COUNT"},explanation:"Collects the values of all matching rules and counts the number of them"},{label:"Rule order",value:{hitPolicy:"RULE ORDER",aggregation:void 0},explanation:"Collects the values of all matching rules in rule order"},{label:"Output order",value:{hitPolicy:"OUTPUT ORDER",aggregation:void 0},explanation:"Collects the values of all matching rules in decreasing output priority order"}];class ga extends oo{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),Ps(this)}getRoot(){return this.sheet.getRoot()}render(){const e=this.getRoot().businessObject,{aggregation:t,hitPolicy:n}=e,i=c(fa,(e=>{return i=e.value,r={aggregation:t,hitPolicy:n},i.hitPolicy===r.hitPolicy&&i.aggregation===r.aggregation;var i,r}));return zi(1,"div","hit-policy header",[zi(1,"label","dms-label",this._translate("Hit policy:"),0),zi(1,"span","hit-policy-value",this._translate(i.label),0)],4,{title:this._translate(i.explanation)})}}function ma(e){e.onGetComponent("hit-policy",(()=>ga))}ga.$inject=["sheet"],ma.$inject=["components"];var ya={__init__:["hitPolicyProvider"],hitPolicyProvider:["type",ma]};let va=class extends oo{constructor(e,t){super(e,t);const{injector:n}=t;this._translate=n.get("translate"),this._eventBus=n.get("eventBus")}onClick=()=>{this._eventBus.fire("showDrd")};render(){return zi(1,"div","view-drd",zi(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,(e=>this.node=e))}},wa=class{constructor(e,t,n,i){this._injector=n,this._sheet=i,e.onGetComponent("table.before",(()=>{if(this.canViewDrd())return va})),t.on("showDrd",(()=>{const e=n.get("_parent",!1),t=ba(i.getRoot());if(!t)return;const r=e.getView(t);e.open(r)}))}canViewDrd(){const e=this._injector.get("_parent",!1);if(!e)return!1;const t=ba(this._sheet.getRoot());return!!e.getView(t)}};function ba(e){const{businessObject:t}=e;if(!t)return;return t.$parent.$parent}wa.$inject=["components","eventBus","injector","sheet"];var xa={__init__:["viewDrd"],viewDrd:["type",wa]};let ka=class{constructor(e){e.onGetComponent("table.before",(()=>co))}};ka.$inject=["components"];var _a={__init__:["poweredBy"],poweredBy:["type",ka]};let Sa=class e extends Ds{constructor(t={}){const n=e._createContainer();super(b(t,{renderer:{container:n}})),this._container=n}open(e){var t=this;return new Promise(((n,i)=>{var r;try{return t._decision&&t.clear(),t._decision=e,function(e,t,n){const i=e.get("tableImporter"),r=e.get("eventBus"),o=e.get("sheet");e.get("modeling",!1);let s,a=[];r.fire("import.render.start",{decision:t});try{!function(e){new Os({create:(e,t,n,r)=>i.create(e,t,n,r),table:e=>i.add(e),element:(e,t,n)=>i.add(e,t,n),error(e,t){a.push({message:e,context:t})}}).handleDecision(e)}(t)}catch(e){s=e}r.fire("import.render.complete",{error:s,warnings:a}),r.fire("elements.changed",{elements:[o.getRoot()]}),n(s,a)}(t,e,(function(e,t){e?(e.warnings=t||[],i(e)):n({warnings:t||[]})}))}catch(e){r=e}r?(r.warnings=r.warnings||[],i(r)):n({warnings:[]})}))}_init(e){let{modules:t,additionalModules:n,...i}=e,r=t||this.getModules();return{modules:[_a,...r,...n||[],...[{decisionTable:["value",this]}]],config:i}}on(e,t,n,i){return this.get("eventBus").on(e,t,n,i)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}attachTo(e){if(!e)throw new Error("parentNode required");this.detach();const t=this._container;e.appendChild(t),this._emit("attach",{})}detach(){const e=this._container;e.parentNode&&(this._emit("detach",{}),Ft(e))}destroy(){super.destroy(),this.detach()}getModules(){return e._getModules()}static _getModules(){return[Hs,Gs,jo,Qs,na,oa,pa,ya,xa]}static _createContainer(){return Lt('<div class="dmn-decision-table-container"></div>')}};class Ca{constructor(e){this._listeners={},e.on("elements.changed",(({elements:e})=>{this.elementsChanged(e)})),e.on("element.updateId",(({element:e,newId:t})=>{this.updateId(e.id,t)}))}elementsChanged(e){const t={},n=e.length;for(let i=0;i<n;i++){const{id:n}=e[i];if(t[n])return;t[n]=!0;const r=this._listeners[n]&&this._listeners[n].length;if(r)for(let e=0;e<r;e++)this._listeners[n][e]&&this._listeners[n][e]()}}onElementsChanged(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e][this._listeners[e].length]=t}offElementsChanged(e,t){if(this._listeners[e])if(t){const n=this._listeners[e].indexOf(t);-1!==n&&this._listeners[e].splice(n,1)}else this._listeners[e].length=0}updateId(e,t){this._listeners[e]&&(this._listeners[t]=this._listeners[e],delete this._listeners[e])}}Ca.$inject=["eventBus"];class Ea extends oo{constructor(e){super(e);const t=this._injector=e.injector;this._changeSupport=t.get("changeSupport"),this._components=t.get("components"),this._renderer=t.get("renderer")}getChildContext(){return{changeSupport:this._changeSupport,components:this._components,renderer:this._renderer,injector:this._injector}}render(){const e=this._components.getComponents("viewer");return zi(1,"div","viewer-container",e&&e.map(((e,t)=>Hi(2,e,null,t))),0)}}class Ma{constructor(e,t,n,i,r){const{container:o}=n;this._container=o,i.on("renderer.mount",(()=>{eo(Hi(2,Ea,{injector:r}),o)})),i.on("renderer.unmount",(()=>{eo(null,o)}))}getContainer(){return this._container}}Ma.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var Aa={__init__:["changeSupport","components","renderer"],changeSupport:["type",Ca],components:["type",class{constructor(){this._listeners={}}getComponent(e,t){const n=this._listeners[e];if(!n)return;let i;for(let e=0;e<n.length&&(i=n[e].callback(t),!i);e++);return i}getComponents(e,t){const n=this._listeners[e];if(!n)return;const i=[];for(let e=0;e<n.length;e++){const r=n[e].callback(t);r&&i.push(r)}return i.length?i:void 0}onGetComponent(e,t,n){if(s(t)&&(n=t,t=1e3),!o(t))throw new Error("priority must be a number");const i=this._getListeners(e);let r,a;const l={priority:t,callback:n};for(a=0;r=i[a];a++)if(r.priority<t)return void i.splice(a,0,l);i.push(l)}offGetComponent(e,t){const n=this._getListeners(e);let i,r,o;if(t)for(o=n.length-1;i=n[o];o--)r=i.callback,r===t&&n.splice(o,1);else n.length=0}_getListeners(e){let t=this._listeners[e];return t||(this._listeners[e]=t=[]),t}}],eventBus:["type",_],renderer:["type",Ma]};let Da=class{constructor(e={}){let{injector:t}=e;if(!t){let{modules:n,config:i}=this._init(e);t=function(e,t){const n=[{config:["value",e]},Aa].concat(t||[]),i=new tn(n);return i.init(),i}(i,n)}this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("viewer.init")}_init(e){let{modules:t,...n}=e;return{modules:t,config:n}}destroy(){this.get("eventBus").fire("viewer.destroy")}clear(){this.get("eventBus").fire("viewer.clear")}};class Ra{constructor(e,t){this._eventBus=t,this._viewer=e}getDecision(){return this._viewer.getDecision()}updateId(e,t){if(e!==this.getDecision())throw new Error("element !== decision");this._eventBus.fire("element.updateId",{element:e,newId:t}),e.id=t}}Ra.$inject=["viewer","eventBus"];var Oa={__init__:["elementRegistry"],elementRegistry:["type",Ra]};class Ta extends oo{constructor(e,t){super(e,t),this._viewer=t.injector.get("viewer")}render(){const{name:e}=this._viewer.getDecision();return zi(1,"div","decision-properties",zi(1,"h3","decision-name",e,0),2)}}let Na=class{constructor(e){e.onGetComponent("viewer",1500,(()=>Ta))}};Na.$inject=["components"];var Pa={__init__:["decisionProperties"],decisionProperties:["type",Na]};class qa extends oo{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._viewer=t.injector.get("viewer")}render(){const{decisionLogic:e,variable:t}=this._viewer.getDecision();return zi(1,"div","literal-expression-properties",zi(1,"table",null,[zi(1,"tr",null,[zi(1,"td",null,this._translate("Variable name:"),0),zi(1,"td",null,zi(1,"span",null,t.name||"-",0),2)],4),zi(1,"tr",null,[zi(1,"td",null,this._translate("Variable type:"),0),zi(1,"td",null,zi(1,"span",null,this._translate(t.typeRef||"")||"-",0),2)],4),zi(1,"tr",null,[zi(1,"td",null,this._translate("Expression language:"),0),zi(1,"td",null,zi(1,"span",null,e.expressionLanguage||"-",0),2)],4)],4),2)}}class Ba{constructor(e){e.onGetComponent("viewer",500,(()=>qa))}}Ba.$inject=["components"];var La={__depends__:[],__init__:["literalExpressionProperties"],literalExpressionProperties:["type",Ba]};let Ia=class{constructor(e){e.onGetComponent("viewer",2e3,(()=>co))}};Ia.$inject=["components"];var Fa={__init__:["poweredBy"],poweredBy:["type",Ia]};class ja extends oo{constructor(e,t){super(e,t),this._viewer=t.injector.get("viewer")}render(){const{text:e}=this._viewer.getDecision().decisionLogic;return zi(1,"div","textarea",zi(1,"div","content",e,0),2)}}class Va{constructor(e){e.onGetComponent("viewer",(()=>ja))}}Va.$inject=["components"];var $a={__init__:["textarea"],textarea:["type",Va]};let za=class extends oo{constructor(e,t){super(e,t);const{injector:n}=t;this._translate=n.get("translate"),this._eventBus=n.get("eventBus")}onClick=()=>{this._eventBus.fire("showDrd")};render(){return zi(1,"div","view-drd",zi(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,(e=>this.node=e))}};za.$inject=["translate"];let Ha=class{constructor(e,t,n,i){this._injector=i,this._viewer=t,e.onGetComponent("viewer",2e3,(()=>{if(this.canViewDrd())return za})),n.on("showDrd",(()=>{const e=i.get("_parent",!1),t=this.getDefinitions(),n=e.getView(t);e.open(n)}))}canViewDrd(){const e=this._injector.get("_parent",!1);if(!e)return;const t=this.getDefinitions();return!!e.getView(t)}getDefinitions(){return this._viewer.getDecision().$parent}};Ha.$inject=["components","viewer","eventBus","injector"];var Wa={__init__:["viewDrd"],viewDrd:["type",Ha]};let Ua=class e extends Da{constructor(t={}){const n=e._createContainer();super(b(t,{renderer:{container:n}})),this._container=n}open(e){var t=this;return new Promise((function(n,i){var r;try{t._decision&&(t.clear(),t.get("eventBus").fire("renderer.unmount")),t._decision=e,t.get("eventBus").fire("import",e),t.get("eventBus").fire("renderer.mount")}catch(e){r=e}r?(r.warnings=r.warnings||[],i(r)):n({warnings:[]})}))}_init(e){let{modules:t,additionalModules:n,...i}=e;return{modules:[...t||this.getModules(),...n||[],...[{viewer:["value",this]}]],config:i}}on(e,t,n,i){return this.get("eventBus").on(e,t,n,i)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}getDecision(){return this._decision}attachTo(e){if(!e)throw new Error("parentNode required");this.detach(),e.appendChild(this._container),this._emit("attach",{})}detach(){const e=this._container;e.parentNode&&(this._emit("detach",{}),Ft(e))}destroy(){super.destroy(),this.detach()}getModules(){return e._getModules()}static _getModules(){return[Oa,jo,Pa,La,Fa,$a,Wa]}static _createContainer(){return Lt('<div class="dmn-literal-expression-container"></div>')}};function Ga(e,{injector:t}){const n=t.get("components").getComponents("header");return zi(1,"div","dmn-boxed-expression-section dmn-boxed-expression-header",n&&n.map(((e,t)=>Hi(2,e,null,t))),0)}function Ka(e,{injector:t}){const n=t.get("components").getComponents("body");return zi(1,"div","dmn-boxed-expression-section dmn-boxed-expression-body",n&&n.map(((e,t)=>Hi(2,e,null,t))),0)}function Xa(e,{injector:t}){const n=t.get("components").getComponents("footer");return zi(1,"div","dmn-boxed-expression-section dmn-boxed-expression-footer",n&&n.map(((e,t)=>Hi(2,e,null,t))),0)}var Ya={__init__:["viewRenderer","tableJsSupport"],viewRenderer:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("viewer",(()=>Ga)),e.onGetComponent("viewer",(()=>Ka)),e.onGetComponent("viewer",(()=>Xa))}}],tableJsSupport:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("viewer",(()=>{const t=e.getComponents("table.before")||[];return()=>zi(1,"div",null,t.map(((e,t)=>Hi(2,e,null,t))),0)}))}}]};class Ja{constructor(e){e.onGetComponent("viewer",2e3,(()=>co))}}Ja.$inject=["components"];var Qa={__init__:["poweredBy"],poweredBy:["type",Ja]};function Za({expression:e},t){return zi(1,"div","textarea",zi(1,"div","content",t.injector.get("literalExpression").getText(e),0),2)}class el{getText(e){return e.get("text")}}var tl={__init__:["literalExpressionComponent"],literalExpressionComponent:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("expression",(({expression:e})=>{if(yi(e,"dmn:LiteralExpression"))return Za}))}}],literalExpression:["type",el]};function nl({expression:e},t){const n=t.injector.get("functionDefinition"),i=n.getKind(e),r=n.getParameters(e),o=n.getBody(e);return zi(1,"div","function-definition",[Hi(2,rl,{kind:i}),Hi(2,ol,{parameters:r}),Hi(2,al,{expression:o})],4)}const il={FEEL:"F",Java:"J",PMML:"P"};function rl({kind:e},t){const n=t.injector.get("translate");return zi(1,"div","function-definition-kind",il[e],0,{title:n("Function kind: {kind}",{kind:e})})}function ol({parameters:e}){return zi(1,"div","function-definition-parameters",zi(1,"div",null,[Wi("("),e.reduce(((e,t)=>e.concat(Hi(2,sl,{parameter:t}),", ")),[]).slice(0,-1),Wi(")")],0),2)}function sl({parameter:e}){const{name:t,typeRef:n}=e,i=t||"<unnamed>";return zi(1,"span",null,n?`${i}: ${n}`:i,0)}function al({expression:e},t){return zi(1,"div","function-definition-body",Hi(2,t.components.getComponent("expression",{expression:e}),{expression:e}),2)}var ll={__init__:["functionDefinitionComponent"],functionDefinition:["type",class{getParameters(e){return e.get("formalParameter")}getBody(e){return e.get("body")}getKind(e){return e.get("kind")||"FEEL"}}],functionDefinitionComponent:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("expression",(({expression:e})=>{if(yi(e,"dmn:FunctionDefinition"))return nl}))}}]};class cl extends oo{constructor(e,t){super(e,t);const{injector:n}=t;this._translate=n.get("translate"),this._eventBus=n.get("eventBus")}onClick=()=>{this._eventBus.fire("showDrd")};render(){return zi(1,"div","view-drd",zi(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,(e=>this.node=e))}}cl.$inject=["translate"];class hl{constructor(e,t,n){this._injector=n,e.onGetComponent("viewer",2e3,(()=>{if(this.canViewDrd())return cl})),t.on("showDrd",(()=>{const e=n.get("_parent",!1),t=e.getDefinitions(),i=e.getView(t);e.open(i)}))}canViewDrd(){const e=this._injector.get("_parent",!1);if(!e)return;const t=e.getDefinitions();return!!e.getView(t)}}hl.$inject=["components","eventBus","injector"];var ul={__init__:["viewDrd"],viewDrd:["type",hl]};function dl(e,t){const n=t.injector.get("viewer"),{name:i}=n.getRootElement();return zi(1,"div","element-properties",zi(1,"h2","element-name",i,0),2)}class pl{constructor(e){e.onGetComponent("header",(()=>dl))}}pl.$inject=["components"];var fl={__init__:["elementProperties"],elementProperties:["type",pl]};function gl(e,{injector:t}){const n=t.get("components"),i=function(e){if(yi(e,"dmn:Decision"))return e.get("decisionLogic");if(yi(e,"dmn:BusinessKnowledgeModel"))return e.get("encapsulatedLogic")}(t.get("viewer").getRootElement());return Hi(2,n.getComponent("expression",{expression:i}),{expression:i})}function ml({expression:e}){return zi(1,"div",null,zi(1,"span",null,[Wi("Expression of type "),e.$type,Wi(" is not supported.")],0,{style:"color:red;"}),2)}var yl={__init__:["elementLogic"],elementLogic:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("body",(()=>gl)),e.onGetComponent("expression",100,(()=>ml))}}]};function vl(e,t){const n=t.injector.get("elementVariable"),i=t.injector.get("translate"),r=n.getName(),o=n.getType();return zi(1,"div","element-variable",[zi(1,"h2",null,Wi("Result"),2),zi(1,"div","element-variable-name",[zi(1,"span","element-variable-name-label",i("Variable name"),0),zi(1,"span",null,r,0)],4),zi(1,"div","element-variable-type",[zi(1,"span","element-variable-type-label",i("Variable type"),0),zi(1,"span",null,o,0)],4)],4)}var wl={__init__:["elementVariableComponent"],elementVariable:["type",class{static $inject=["viewer"];constructor(e){this._viewer=e}getName(){const e=this.getVariable(),t=this._getElement();return(e?e.get("name"):null)||t.get("name")}getType(){const e=this.getVariable();return e?e.get("typeRef"):"Any"}_getElement(){return this._viewer.getRootElement()}getVariable(){return this._getElement().get("variable")}}],elementVariableComponent:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("footer",(()=>vl))}}]};let bl=class e extends Da{constructor(t={}){const n=e._createContainer();super(b(t,{renderer:{container:n}})),this._container=n}open(e){const t=this.get("eventBus");return new Promise(((n,i)=>{let r;try{this.getRootElement()&&(this.clear(),t.fire("renderer.unmount")),this._setRootElement(e),t.fire("import",e),t.fire("renderer.mount")}catch(e){r=e}r?(r.warnings=r.warnings||[],i(r)):n({warnings:[]})}))}_init(e){let{modules:t,additionalModules:n,...i}=e;return{modules:[...t||this.getModules(),...n||[],...[{viewer:["value",this]}]],config:i}}on(e,t,n,i){return this.get("eventBus").on(e,t,n,i)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}getRootElement(){return this._root}_setRootElement(e){this._root=e}attachTo(e){if(!e)throw new Error("parentNode required");this.detach(),e.appendChild(this._container),this._emit("attach",{})}detach(){const e=this._container;e.parentNode&&(this._emit("detach",{}),Ft(e))}destroy(){super.destroy(),this.detach()}getModules(){return[Ya,jo,Qa,ul,fl,yl,ll,tl,wl]}static _createContainer(){return Lt('<div class="dmn-boxed-expression-container"></div>')}};window.getSelection();var xl,kl={exports:{}};!function(){if(xl)return kl.exports;function e(e,t){return{start:e,end:void 0===t?e:t}}xl=1,kl.exports=function(t,n,i){var r=t.start,o=r,s=(i.length,n.length);i.length,n.length;var a=n.substring(r);return i.lastIndexOf(a)===i.length-a.length&&(n=n.substring(0,n.length-a.length),i=i.substring(0,i.length-a.length)),s=function(e,t){var n,i,r,o=0,s=0;t.length>e.length?(i=t,r=e):(i=e,r=t);for(;o<i.length;)i.charAt(o)!==r.charAt(s)?(n||(n={l_start:o,s_start:s}),o++):(n&&!n.complete&&(n.l_end=o,n.s_end=s,n.complete=!0),s++,o++);n&&!n.complete&&(n.complete=!0,n.s_end=r.length,n.l_end=i.length);if(!n)return;return t.length>e.length?{newStart:n.l_start,newEnd:n.l_end,type:"add"}:{newStart:n.s_start,newEnd:n.s_end,type:t.length<e.length?"remove":"replace"}}(n,i),s&&(o="remove"===s.type?s.newStart:s.newEnd),e(o)},kl.exports.range=e,kl.exports}();let _l=[],Sl=[];function Cl(e){if(e<768)return!1;for(let t=0,n=_l.length;;){let i=t+n>>1;if(e<_l[i])n=i;else{if(!(e>=Sl[i]))return!0;t=i+1}if(t==n)return!1}}function El(e){return e>=127462&&e<=127487}(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((e=>e?parseInt(e,36):1));for(let t=0,n=0;t<e.length;t++)(t%2?Sl:_l).push(n+=e[t])})();const Ml=8205;function Al(e,t,n=!0,i=!0){return(n?Dl:Rl)(e,t,i)}function Dl(e,t,n){if(t==e.length)return t;t&&Tl(e.charCodeAt(t))&&Nl(e.charCodeAt(t-1))&&t--;let i=Ol(e,t);for(t+=Pl(i);t<e.length;){let r=Ol(e,t);if(i==Ml||r==Ml||n&&Cl(r))t+=Pl(r),i=r;else{if(!El(r))break;{let n=0,i=t-2;for(;i>=0&&El(Ol(e,i));)n++,i-=2;if(n%2==0)break;t+=2}}}return t}function Rl(e,t,n){for(;t>0;){let i=Dl(e,t-2,n);if(i<t)return i;t--}return 0}function Ol(e,t){let n=e.charCodeAt(t);if(!Nl(n)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return Tl(i)?i-56320+(n-55296<<10)+65536:n}function Tl(e){return e>=56320&&e<57344}function Nl(e){return e>=55296&&e<56320}function Pl(e){return e<65536?1:2}class ql{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Hl(this,e,t);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(t,this.length,i,1),Ll.from(i,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Hl(this,e,t);let n=[];return this.decompose(e,t,n,0),Ll.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new jl(this),r=new jl(e);for(let e=t,o=t;;){if(i.next(e),r.next(e),e=0,i.lineBreak!=r.lineBreak||i.done!=r.done||i.value!=r.value)return!1;if(o+=i.value.length,i.done||o>=n)return!0}}iter(e=1){return new jl(this,e)}iterRange(e,t=this.length){return new Vl(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new $l(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new Bl(e):Ll.from(Bl.split(e,[])):ql.empty}}class Bl extends ql{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,i){for(let r=0;;r++){let o=this.text[r],s=i+o.length;if((t?n:s)>=e)return new zl(i,s,n,o);i=s+1,n++}}decompose(e,t,n,i){let r=e<=0&&t>=this.length?this:new Bl(Fl(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&i){let e=n.pop(),t=Il(r.text,e.text.slice(),0,r.length);if(t.length<=32)n.push(new Bl(t,e.length+r.length));else{let e=t.length>>1;n.push(new Bl(t.slice(0,e)),new Bl(t.slice(e)))}}else n.push(r)}replace(e,t,n){if(!(n instanceof Bl))return super.replace(e,t,n);[e,t]=Hl(this,e,t);let i=Il(this.text,Il(n.text,Fl(this.text,0,e)),t),r=this.length+n.length-(t-e);return i.length<=32?new Bl(i,r):Ll.from(Bl.split(i,[]),r)}sliceString(e,t=this.length,n="\n"){[e,t]=Hl(this,e,t);let i="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let s=this.text[o],a=r+s.length;r>e&&o&&(i+=n),e<a&&t>r&&(i+=s.slice(Math.max(0,e-r),t-r)),r=a+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],i=-1;for(let r of e)n.push(r),i+=r.length+1,32==n.length&&(t.push(new Bl(n,i)),n=[],i=-1);return i>-1&&t.push(new Bl(n,i)),t}}class Ll extends ql{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,i){for(let r=0;;r++){let o=this.children[r],s=i+o.length,a=n+o.lines-1;if((t?a:s)>=e)return o.lineInner(e,t,n,i);i=s+1,n=a+1}}decompose(e,t,n,i){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let s=this.children[r],a=o+s.length;if(e<=a&&t>=o){let r=i&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!r?n.push(s):s.decompose(e-o,t-o,n,r)}o=a+1}}replace(e,t,n){if([e,t]=Hl(this,e,t),n.lines<this.lines)for(let i=0,r=0;i<this.children.length;i++){let o=this.children[i],s=r+o.length;if(e>=r&&t<=s){let a=o.replace(e-r,t-r,n),l=this.lines-o.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let r=this.children.slice();return r[i]=a,new Ll(r,this.length-(t-e)+n.length)}return super.replace(r,s,a)}r=s+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=Hl(this,e,t);let i="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let s=this.children[r],a=o+s.length;o>e&&r&&(i+=n),e<a&&t>o&&(i+=s.sliceString(e-o,t-o,n)),o=a+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Ll))return 0;let n=0,[i,r,o,s]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,r+=t){if(i==o||r==s)return n;let a=this.children[i],l=e.children[r];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce(((e,t)=>e+t.length+1),-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new Bl(n,t)}let i=Math.max(32,n>>5),r=i<<1,o=i>>1,s=[],a=0,l=-1,c=[];function h(e){let t;if(e.lines>r&&e instanceof Ll)for(let t of e.children)h(t);else e.lines>o&&(a>o||!a)?(u(),s.push(e)):e instanceof Bl&&a&&(t=c[c.length-1])instanceof Bl&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new Bl(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>i&&u(),a+=e.lines,l+=e.length+1,c.push(e))}function u(){0!=a&&(s.push(1==c.length?c[0]:Ll.from(c,l)),l=-1,a=c.length=0)}for(let t of e)h(t);return u(),1==s.length?s[0]:new Ll(s,t)}}function Il(e,t,n=0,i=1e9){for(let r=0,o=0,s=!0;o<e.length&&r<=i;o++){let a=e[o],l=r+a.length;l>=n&&(l>i&&(a=a.slice(0,i-r)),r<n&&(a=a.slice(n-r)),s?(t[t.length-1]+=a,s=!1):t.push(a)),r=l+1}return t}function Fl(e,t,n){return Il(e,[""],t,n)}ql.empty=new Bl([""],0);class jl{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof Bl?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],r=this.offsets[n],o=r>>1,s=i instanceof Bl?i.text.length:i.children.length;if(o==(t>0?s:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(i instanceof Bl){let r=i.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,r.length>Math.max(0,e))return this.value=0==e?r:t>0?r.slice(e):r.slice(0,r.length-e),this;e-=r.length}else{let r=i.children[o+(t<0?-1:0)];e>r.length?(e-=r.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(r),this.offsets.push(t>0?1:(r instanceof Bl?r.text.length:r.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Vl{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new jl(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*t,this.value=i.length<=n?i:t<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class $l{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:i}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(ql.prototype[Symbol.iterator]=function(){return this.iter()},jl.prototype[Symbol.iterator]=Vl.prototype[Symbol.iterator]=$l.prototype[Symbol.iterator]=function(){return this});class zl{constructor(e,t,n,i){this.from=e,this.to=t,this.number=n,this.text=i}get length(){return this.to-this.from}}function Hl(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function Wl(e,t,n=!0,i=!0){return Al(e,t,n,i)}const Ul=/\r\n?|\n/;var Gl=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(Gl||(Gl={}));class Kl{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,i=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(n,i,r),i+=r):i+=o,n+=r}}iterChangedRanges(e,t=!1){Ql(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];i<0?e.push(n,i):e.push(i,n)}return new Kl(e)}composeDesc(e){return this.empty?e:e.empty?this:ec(this,e)}mapDesc(e,t=!1){return e.empty?this:Zl(this,e,t)}mapPos(e,t=-1,n=Gl.Simple){let i=0,r=0;for(let o=0;o<this.sections.length;){let s=this.sections[o++],a=this.sections[o++],l=i+s;if(a<0){if(l>e)return r+(e-i);r+=s}else{if(n!=Gl.Simple&&l>=e&&(n==Gl.TrackDel&&i<e&&l>e||n==Gl.TrackBefore&&i<e||n==Gl.TrackAfter&&l>e))return null;if(l>e||l==e&&t<0&&!s)return e==i||t<0?r:r+a;r+=a}i=l}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return r}touchesRange(e,t=e){for(let n=0,i=0;n<this.sections.length&&i<=t;){let r=i+this.sections[n++];if(this.sections[n++]>=0&&i<=t&&r>=e)return!(i<e&&r>t)||"cover";i=r}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];e+=(e?" ":"")+n+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some((e=>"number"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Kl(e)}static create(e){return new Kl(e)}}class Xl extends Kl{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 Ql(this,((t,n,i,r,o)=>e=e.replace(i,i+(n-t),o)),!1),e}mapDesc(e,t=!1){return Zl(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let i=0,r=0;i<t.length;i+=2){let o=t[i],s=t[i+1];if(s>=0){t[i]=s,t[i+1]=o;let a=i>>1;for(;n.length<a;)n.push(ql.empty);n.push(o?e.slice(r,r+o):ql.empty)}r+=o}return new Xl(t,n)}compose(e){return this.empty?e:e.empty?this:ec(this,e,!0)}map(e,t=!1){return e.empty?this:Zl(this,e,t,!0)}iterChanges(e,t=!1){Ql(this,e,t)}get desc(){return Kl.create(this.sections)}filter(e){let t=[],n=[],i=[],r=new tc(this);e:for(let o=0,s=0;;){let a=o==e.length?1e9:e[o++];for(;s<a||s==a&&0==r.len;){if(r.done)break e;let e=Math.min(r.len,a-s);Yl(i,e,-1);let o=-1==r.ins?-1:0==r.off?r.ins:0;Yl(t,e,o),o>0&&Jl(n,t,r.text),r.forward(e),s+=e}let l=e[o++];for(;s<l;){if(r.done)break e;let e=Math.min(r.len,l-s);Yl(t,e,-1),Yl(i,e,-1==r.ins?-1:0==r.off?r.ins:0),r.forward(e),s+=e}}return{changes:new Xl(t,n),filtered:Kl.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],i=this.sections[t+1];i<0?e.push(n):0==i?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let i=[],r=[],o=0,s=null;function a(e=!1){if(!e&&!i.length)return;o<t&&Yl(i,t-o,-1);let n=new Xl(i,r);s=s?s.compose(n.map(s)):n,i=[],r=[],o=0}return function e(l){if(Array.isArray(l))for(let t of l)e(t);else if(l instanceof Xl){if(l.length!=t)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),s=s?s.compose(l.map(s)):l}else{let{from:e,to:s=e,insert:c}=l;if(e>s||e<0||s>t)throw new RangeError(`Invalid change range ${e} to ${s} (in doc of length ${t})`);let h=c?"string"==typeof c?ql.of(c.split(n||Ul)):c:ql.empty,u=h.length;if(e==s&&0==u)return;e<o&&a(),e>o&&Yl(i,e-o,-1),Yl(i,s-e,u),Jl(r,i,h),o=s}}(e),a(!s),s}static empty(e){return new Xl(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let i=0;i<e.length;i++){let r=e[i];if("number"==typeof r)t.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((e,t)=>t&&"string"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)t.push(r[0],0);else{for(;n.length<i;)n.push(ql.empty);n[i]=ql.of(r.slice(1)),t.push(r[0],n[i].length)}}}return new Xl(t,n)}static createSet(e,t){return new Xl(e,t)}}function Yl(e,t,n,i=!1){if(0==t&&n<=0)return;let r=e.length-2;r>=0&&n<=0&&n==e[r+1]?e[r]+=t:r>=0&&0==t&&0==e[r]?e[r+1]+=n:i?(e[r]+=t,e[r+1]+=n):e.push(t,n)}function Jl(e,t,n){if(0==n.length)return;let i=t.length-2>>1;if(i<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<i;)e.push(ql.empty);e.push(n)}}function Ql(e,t,n){let i=e.inserted;for(let r=0,o=0,s=0;s<e.sections.length;){let a=e.sections[s++],l=e.sections[s++];if(l<0)r+=a,o+=a;else{let c=r,h=o,u=ql.empty;for(;c+=a,h+=l,l&&i&&(u=u.append(i[s-2>>1])),!(n||s==e.sections.length||e.sections[s+1]<0);)a=e.sections[s++],l=e.sections[s++];t(r,c,o,h,u),r=c,o=h}}}function Zl(e,t,n,i=!1){let r=[],o=i?[]:null,s=new tc(e),a=new tc(t);for(let e=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(-1==s.ins&&-1==a.ins){let e=Math.min(s.len,a.len);Yl(r,e,-1),s.forward(e),a.forward(e)}else if(a.ins>=0&&(s.ins<0||e==s.i||0==s.off&&(a.len<s.len||a.len==s.len&&!n))){let t=a.len;for(Yl(r,a.ins,-1);t;){let n=Math.min(s.len,t);s.ins>=0&&e<s.i&&s.len<=n&&(Yl(r,0,s.ins),o&&Jl(o,r,s.text),e=s.i),s.forward(n),t-=n}a.next()}else{if(!(s.ins>=0)){if(s.done&&a.done)return o?Xl.createSet(r,o):Kl.create(r);throw new Error("Mismatched change set lengths")}{let t=0,n=s.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else{if(!(0==a.ins&&a.len<n))break;n-=a.len,a.next()}Yl(r,t,e<s.i?s.ins:0),o&&e<s.i&&Jl(o,r,s.text),e=s.i,s.forward(s.len-n)}}}}function ec(e,t,n=!1){let i=[],r=n?[]:null,o=new tc(e),s=new tc(t);for(let e=!1;;){if(o.done&&s.done)return r?Xl.createSet(i,r):Kl.create(i);if(0==o.ins)Yl(i,o.len,0,e),o.next();else if(0!=s.len||s.done){if(o.done||s.done)throw new Error("Mismatched change set lengths");{let t=Math.min(o.len2,s.len),n=i.length;if(-1==o.ins){let n=-1==s.ins?-1:s.off?0:s.ins;Yl(i,t,n,e),r&&n&&Jl(r,i,s.text)}else-1==s.ins?(Yl(i,o.off?0:o.len,t,e),r&&Jl(r,i,o.textBit(t))):(Yl(i,o.off?0:o.len,s.off?0:s.ins,e),r&&!s.off&&Jl(r,i,s.text));e=(o.ins>t||s.ins>=0&&s.len>t)&&(e||i.length>n),o.forward2(t),s.forward(t)}}else Yl(i,0,s.ins,e),r&&Jl(r,i,s.text),s.next()}}class tc{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?ql.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?ql.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class nc{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let n,i;return this.empty?n=i=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new nc(n,i,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return ic.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return ic.range(this.anchor,n)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return ic.range(e.anchor,e.head)}static create(e,t,n){return new nc(e,t,n)}}class ic{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:ic.create(this.ranges.map((n=>n.map(e,t))),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new ic([this.main],0)}addRange(e,t=!0){return ic.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,ic.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((e=>e.toJSON())),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ic(e.ranges.map((e=>nc.fromJSON(e))),e.main)}static single(e,t=e){return new ic([ic.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;i<e.length;i++){let r=e[i];if(r.empty?r.from<=n:r.from<n)return ic.normalized(e.slice(),t);n=r.to}return new ic(e,t)}static cursor(e,t=0,n,i){return nc.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=i?i:16777215)<<6)}static range(e,t,n,i){let r=(null!=n?n:16777215)<<6|(null==i?7:Math.min(6,i));return t<e?nc.create(t,e,48|r):nc.create(e,t,(t>e?8:0)|r)}static normalized(e,t=0){let n=e[t];e.sort(((e,t)=>e.from-t.from)),t=e.indexOf(n);for(let n=1;n<e.length;n++){let i=e[n],r=e[n-1];if(i.empty?i.from<=r.to:i.from<r.to){let o=r.from,s=Math.max(i.to,r.to);n<=t&&t--,e.splice(--n,2,i.anchor>i.head?ic.range(s,o):ic.range(o,s))}}return new ic(e,t)}}function rc(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let oc=0;class sc{constructor(e,t,n,i,r){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=i,this.id=oc++,this.default=e([]),this.extensions="function"==typeof r?r(this):r}get reader(){return this}static define(e={}){return new sc(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:ac),!!e.static,e.enables)}of(e){return new lc([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new lc(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new lc(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],(n=>t(n.field(e))))}}function ac(e,t){return e==t||e.length==t.length&&e.every(((e,n)=>e===t[n]))}class lc{constructor(e,t,n,i){this.dependencies=e,this.facet=t,this.type=n,this.value=i,this.id=oc++}dynamicSlot(e){var t;let n=this.value,i=this.facet.compareInput,r=this.id,o=e[r]>>1,s=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:1&(null!==(t=e[n.id])&&void 0!==t?t:1)||c.push(e[n.id]);return{create:e=>(e.values[o]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||hc(e,c)){let t=n(e);if(s?!cc(t,e.values[o],i):!i(t,e.values[o]))return e.values[o]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[r];if(null!=l){let r=Cc(t,l);if(this.dependencies.every((n=>n instanceof sc?t.facet(n)===e.facet(n):!(n instanceof pc)||t.field(n,!1)==e.field(n,!1)))||(s?cc(a=n(e),r,i):i(a=n(e),r)))return e.values[o]=r,0}else a=n(e);return e.values[o]=a,1}}}}function cc(e,t,n){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}function hc(e,t){let n=!1;for(let i of t)1&Sc(e,i)&&(n=!0);return n}function uc(e,t,n){let i=n.map((t=>e[t.id])),r=n.map((e=>e.type)),o=i.filter((e=>!(1&e))),s=e[t.id]>>1;function a(e){let n=[];for(let t=0;t<i.length;t++){let o=Cc(e,i[t]);if(2==r[t])for(let e of o)n.push(e);else n.push(o)}return t.combine(n)}return{create(e){for(let t of i)Sc(e,t);return e.values[s]=a(e),1},update(e,n){if(!hc(e,o))return 0;let i=a(e);return t.compare(i,e.values[s])?0:(e.values[s]=i,1)},reconfigure(e,r){let o=hc(e,i),l=r.config.facets[t.id],c=r.facet(t);if(l&&!o&&ac(n,l))return e.values[s]=c,0;let h=a(e);return t.compare(h,c)?(e.values[s]=c,0):(e.values[s]=h,1)}}}const dc=sc.define({static:!0});class pc{constructor(e,t,n,i,r){this.id=e,this.createF=t,this.updateF=n,this.compareF=i,this.spec=r,this.provides=void 0}static define(e){let t=new pc(oc++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(dc).find((e=>e.field==this));return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let i=e.values[t],r=this.updateF(i,n);return this.compareF(i,r)?0:(e.values[t]=r,1)},reconfigure:(e,n)=>null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}init(e){return[this,dc.of({field:this,create:e})]}get extension(){return this}}const fc=4,gc=3,mc=2,yc=1;function vc(e){return t=>new bc(t,e)}const wc={highest:vc(0),high:vc(yc),default:vc(mc),low:vc(gc),lowest:vc(fc)};class bc{constructor(e,t){this.inner=e,this.prec=t}}class xc{of(e){return new kc(this,e)}reconfigure(e){return xc.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class kc{constructor(e,t){this.compartment=e,this.inner=t}}class _c{constructor(e,t,n,i,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=i,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let i=[],r=Object.create(null),o=new Map;for(let n of function(e,t,n){let i=[[],[],[],[],[]],r=new Map;function o(e,s){let a=r.get(e);if(null!=a){if(a<=s)return;let t=i[a].indexOf(e);t>-1&&i[a].splice(t,1),e instanceof kc&&n.delete(e.compartment)}if(r.set(e,s),Array.isArray(e))for(let t of e)o(t,s);else if(e instanceof kc){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let i=t.get(e.compartment)||e.inner;n.set(e.compartment,i),o(i,s)}else if(e instanceof bc)o(e.inner,e.prec);else if(e instanceof pc)i[s].push(e),e.provides&&o(e.provides,s);else if(e instanceof lc)i[s].push(e),e.facet.extensions&&o(e.facet.extensions,mc);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(t,s)}}return o(e,mc),i.reduce(((e,t)=>e.concat(t)))}(e,t,o))n instanceof pc?i.push(n):(r[n.facet.id]||(r[n.facet.id]=[])).push(n);let s=Object.create(null),a=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push((t=>e.slot(t)));let c=null==n?void 0:n.config.facets;for(let e in r){let t=r[e],i=t[0].facet,o=c&&c[e]||[];if(t.every((e=>0==e.type)))if(s[i.id]=a.length<<1|1,ac(o,t))a.push(n.facet(i));else{let e=i.combine(t.map((e=>e.value)));a.push(n&&i.compare(e,n.facet(i))?n.facet(i):e)}else{for(let e of t)0==e.type?(s[e.id]=a.length<<1|1,a.push(e.value)):(s[e.id]=l.length<<1,l.push((t=>e.dynamicSlot(t))));s[i.id]=l.length<<1,l.push((e=>uc(e,i,t)))}}let h=l.map((e=>e(s)));return new _c(e,o,h,s,a,r)}}function Sc(e,t){if(1&t)return 2;let n=t>>1,i=e.status[n];if(4==i)throw new Error("Cyclic dependency between fields and/or facets");if(2&i)return i;e.status[n]=4;let r=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|r}function Cc(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const Ec=sc.define(),Mc=sc.define({combine:e=>e.some((e=>e)),static:!0}),Ac=sc.define({combine:e=>e.length?e[0]:void 0,static:!0}),Dc=sc.define(),Rc=sc.define(),Oc=sc.define(),Tc=sc.define({combine:e=>!!e.length&&e[0]});class Nc{constructor(e,t){this.type=e,this.value=t}static define(){return new Pc}}class Pc{of(e){return new Nc(this,e)}}class qc{constructor(e){this.map=e}of(e){return new Bc(this,e)}}class Bc{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new Bc(this.type,t)}is(e){return this.type==e}static define(e={}){return new qc(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let i of e){let e=i.map(t);e&&n.push(e)}return n}}Bc.reconfigure=Bc.define(),Bc.appendConfig=Bc.define();class Lc{constructor(e,t,n,i,r,o){this.startState=e,this.changes=t,this.selection=n,this.effects=i,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,n&&rc(n,t.newLength),r.some((e=>e.type==Lc.time))||(this.annotations=r.concat(Lc.time.of(Date.now())))}static create(e,t,n,i,r,o){return new Lc(e,t,n,i,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Lc.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function Ic(e,t){let n=[];for(let i=0,r=0;;){let o,s;if(i<e.length&&(r==t.length||t[r]>=e[i]))o=e[i++],s=e[i++];else{if(!(r<t.length))return n;o=t[r++],s=t[r++]}!n.length||n[n.length-1]<o?n.push(o,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function Fc(e,t,n){var i;let r,o,s;return n?(r=t.changes,o=Xl.empty(t.changes.length),s=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),o=e.changes.mapDesc(t.changes,!0),s=e.changes.compose(r)),{changes:s,selection:t.selection?t.selection.map(o):null===(i=e.selection)||void 0===i?void 0:i.map(r),effects:Bc.mapEffects(e.effects,r).concat(Bc.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function jc(e,t,n){let i=t.selection,r=zc(t.annotations);return t.userEvent&&(r=r.concat(Lc.userEvent.of(t.userEvent))),{changes:t.changes instanceof Xl?t.changes:Xl.of(t.changes||[],n,e.facet(Ac)),selection:i&&(i instanceof ic?i:ic.single(i.anchor,i.head)),effects:zc(t.effects),annotations:r,scrollIntoView:!!t.scrollIntoView}}function Vc(e,t,n){let i=jc(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(n=!1);for(let r=1;r<t.length;r++){!1===t[r].filter&&(n=!1);let o=!!t[r].sequential;i=Fc(i,jc(e,t[r],o?i.changes.newLength:e.doc.length),o)}let r=Lc.create(e,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return function(e){let t=e.startState,n=t.facet(Oc),i=e;for(let r=n.length-1;r>=0;r--){let o=n[r](e);o&&Object.keys(o).length&&(i=Fc(i,jc(t,o,e.changes.newLength),!0))}return i==e?e:Lc.create(t,e.changes,e.selection,i.effects,i.annotations,i.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let i of t.facet(Dc)){let t=i(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:Ic(n,t))}if(!0!==n){let i,r;if(!1===n)r=e.changes.invertedDesc,i=Xl.empty(t.doc.length);else{let t=e.changes.filter(n);i=t.changes,r=t.filtered.mapDesc(t.changes).invertedDesc}e=Lc.create(t,i,e.selection&&e.selection.map(r),Bc.mapEffects(e.effects,r),e.annotations,e.scrollIntoView)}let i=t.facet(Rc);for(let n=i.length-1;n>=0;n--){let r=i[n](e);e=r instanceof Lc?r:Array.isArray(r)&&1==r.length&&r[0]instanceof Lc?r[0]:Vc(t,zc(r),!1)}return e}(r):r)}Lc.time=Nc.define(),Lc.userEvent=Nc.define(),Lc.addToHistory=Nc.define(),Lc.remote=Nc.define();const $c=[];function zc(e){return null==e?$c:Array.isArray(e)?e:[e]}var Hc=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(Hc||(Hc={}));const Wc=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Uc;try{Uc=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function Gc(e){return t=>{if(!/\S/.test(t))return Hc.Space;if(function(e){if(Uc)return Uc.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||Wc.test(n)))return!0}return!1}(t))return Hc.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return Hc.Word;return Hc.Other}}class Kc{constructor(e,t,n,i,r,o){this.config=e,this.doc=t,this.selection=n,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Sc(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null!=n)return Sc(this,n),Cc(this,n);if(t)throw new RangeError("Field is not present in this state")}update(...e){return Vc(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:i,compartments:r}=n;for(let t of e.effects)t.is(xc.reconfigure)?(n&&(r=new Map,n.compartments.forEach(((e,t)=>r.set(t,e))),n=null),r.set(t.value.compartment,t.value.extension)):t.is(Bc.reconfigure)?(n=null,i=t.value):t.is(Bc.appendConfig)&&(n=null,i=zc(i).concat(t.value));if(n)t=e.startState.values.slice();else{n=_c.resolve(i,r,this),t=new Kc(n,this.doc,this.selection,n.dynamicSlots.map((()=>null)),((e,t)=>t.reconfigure(e,this)),null).values}let o=e.startState.facet(Mc)?e.newSelection:e.newSelection.asSingle();new Kc(n,e.newDoc,o,t,((t,n)=>n.update(t,e)),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:e},range:ic.cursor(t.from+e.length)})))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),i=this.changes(n.changes),r=[n.range],o=zc(n.effects);for(let n=1;n<t.ranges.length;n++){let s=e(t.ranges[n]),a=this.changes(s.changes),l=a.map(i);for(let e=0;e<n;e++)r[e]=r[e].map(l);let c=i.mapDesc(a,!0);r.push(s.range.map(c)),i=i.compose(l),o=Bc.mapEffects(o,l).concat(Bc.mapEffects(zc(s.effects),c))}return{changes:i,selection:ic.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Xl?e:Xl.of(e,this.doc.length,this.facet(Kc.lineSeparator))}toText(e){return ql.of(e.split(this.facet(Kc.lineSeparator)||Ul))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(Sc(this,t),Cc(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let i=e[n];i instanceof pc&&null!=this.config.address[i.id]&&(t[n]=i.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(n)for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let r=n[t],o=e[t];i.push(r.init((e=>r.spec.fromJSON(o,e))))}return Kc.create({doc:e.doc,selection:ic.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let t=_c.resolve(e.extensions||[],new Map),n=e.doc instanceof ql?e.doc:ql.of((e.doc||"").split(t.staticFacet(Kc.lineSeparator)||Ul)),i=e.selection?e.selection instanceof ic?e.selection:ic.single(e.selection.anchor,e.selection.head):ic.single(0);return rc(i,n.length),t.staticFacet(Mc)||(i=i.asSingle()),new Kc(t,n,i,t.dynamicSlots.map((()=>null)),((e,t)=>t.create(e)),null)}get tabSize(){return this.facet(Kc.tabSize)}get lineBreak(){return this.facet(Kc.lineSeparator)||"\n"}get readOnly(){return this.facet(Tc)}phrase(e,...t){for(let t of this.facet(Kc.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,((e,n)=>{if("$"==n)return"$";let i=+(n||1);return!i||i>t.length?e:t[i-1]}))),e}languageDataAt(e,t,n=-1){let i=[];for(let r of this.facet(Ec))for(let o of r(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){return Gc(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:i}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-n,s=e-n;for(;o>0;){let e=Wl(t,o,!1);if(r(t.slice(e,o))!=Hc.Word)break;o=e}for(;s<i;){let e=Wl(t,s);if(r(t.slice(s,e))!=Hc.Word)break;s=e}return o==s?null:ic.range(o+n,s+n)}}Kc.allowMultipleSelections=Mc,Kc.tabSize=sc.define({combine:e=>e.length?e[0]:4}),Kc.lineSeparator=Ac,Kc.readOnly=Tc,Kc.phrases=sc.define({compare(e,t){let n=Object.keys(e),i=Object.keys(t);return n.length==i.length&&n.every((n=>e[n]==t[n]))}}),Kc.languageData=Ec,Kc.changeFilter=Dc,Kc.transactionFilter=Rc,Kc.transactionExtender=Oc,xc.reconfigure=Bc.define();class Xc{eq(e){return this==e}range(e,t=e){return Yc.create(e,t,this)}}Xc.prototype.startSide=Xc.prototype.endSide=0,Xc.prototype.point=!1,Xc.prototype.mapMode=Gl.TrackDel;let Yc=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,i){return new e(t,n,i)}};function Jc(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class Qc{constructor(e,t,n,i){this.from=e,this.to=t,this.value=n,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,i=0){let r=n?this.to:this.from;for(let o=i,s=r.length;;){if(o==s)return o;let i=o+s>>1,a=r[i]-e||(n?this.value[i].endSide:this.value[i].startSide)-t;if(i==o)return a>=0?o:s;a>=0?s=i:o=i+1}}between(e,t,n,i){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,r);r<o;r++)if(!1===i(this.from[r]+e,this.to[r]+e,this.value[r]))return!1}map(e,t){let n=[],i=[],r=[],o=-1,s=-1;for(let a=0;a<this.value.length;a++){let l,c,h=this.value[a],u=this.from[a]+e,d=this.to[a]+e;if(u==d){let e=t.mapPos(u,h.startSide,h.mapMode);if(null==e)continue;if(l=c=e,h.startSide!=h.endSide&&(c=t.mapPos(u,h.endSide),c<l))continue}else if(l=t.mapPos(u,h.startSide),c=t.mapPos(d,h.endSide),l>c||l==c&&h.startSide>0&&h.endSide<=0)continue;(c-l||h.endSide-h.startSide)<0||(o<0&&(o=l),h.point&&(s=Math.max(s,c-l)),n.push(h),i.push(l-o),r.push(c-o))}return{mapped:n.length?new Qc(i,r,n,s):null,pos:o}}}class Zc{constructor(e,t,n,i){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=i}static create(e,t,n,i){return new Zc(e,t,n,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:i=0,filterTo:r=this.length}=e,o=e.filter;if(0==t.length&&!o)return this;if(n&&(t=t.slice().sort(Jc)),this.isEmpty)return t.length?Zc.of(t):this;let s=new nh(this,null,-1).goto(0),a=0,l=[],c=new eh;for(;s.value||a<t.length;)if(a<t.length&&(s.from-t[a].from||s.startSide-t[a].value.startSide)>=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==s.rangeIndex&&s.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(s.chunkIndex)<t[a].from)&&(!o||i>this.chunkEnd(s.chunkIndex)||r<this.chunkPos[s.chunkIndex])&&c.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||i>s.to||r<s.from||o(s.from,s.to,s.value))&&(c.addInner(s.from,s.to,s.value)||l.push(Yc.create(s.from,s.to,s.value))),s.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?Zc.empty:this.nextLayer.update({add:l,filter:o,filterFrom:i,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],i=-1;for(let r=0;r<this.chunk.length;r++){let o=this.chunkPos[r],s=this.chunk[r],a=e.touchesRange(o,o+s.length);if(!1===a)i=Math.max(i,s.maxPoint),t.push(s),n.push(e.mapPos(o));else if(!0===a){let{mapped:r,pos:a}=s.map(o,e);r&&(i=Math.max(i,r.maxPoint),t.push(r),n.push(a))}}let r=this.nextLayer.map(e);return 0==t.length?r:new Zc(n,t,r||Zc.empty,i)}between(e,t,n){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let r=this.chunkPos[i],o=this.chunk[i];if(t>=r&&e<=r+o.length&&!1===o.between(r,e-r,t-r,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return ih.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return ih.from(e).goto(t)}static compare(e,t,n,i,r=-1){let o=e.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r)),s=t.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r)),a=th(o,s,n),l=new oh(o,a,r),c=new oh(s,a,r);n.iterGaps(((e,t,n)=>sh(l,e,c,t,n,i))),n.empty&&0==n.length&&sh(l,0,c,0,0,i)}static eq(e,t,n=0,i){null==i&&(i=999999999);let r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0)),o=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0));if(r.length!=o.length)return!1;if(!r.length)return!0;let s=th(r,o),a=new oh(r,s,0).goto(n),l=new oh(o,s,0).goto(n);for(;;){if(a.to!=l.to||!ah(a.active,l.active)||a.point&&(!l.point||!a.point.eq(l.point)))return!1;if(a.to>i)return!0;a.next(),l.next()}}static spans(e,t,n,i,r=-1){let o=new oh(e,null,r).goto(t),s=t,a=o.openStart;for(;;){let e=Math.min(o.to,n);if(o.point){let n=o.activeForPoint(o.to),r=o.pointFrom<t?n.length+1:o.point.startSide<0?n.length:Math.min(n.length,a);i.point(s,e,o.point,n,r,o.pointRank),a=Math.min(o.openEnd(e),n.length)}else e>s&&(i.span(s,e,o.active,a),a=o.openEnd(e));if(o.to>n)return a+(o.point&&o.to>n?1:0);s=o.to,o.next()}}static of(e,t=!1){let n=new eh;for(let i of e instanceof Yc?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let i=e[n];if(Jc(t,i)>0)return e.slice().sort(Jc);t=i}return e}(e):e)n.add(i.from,i.to,i.value);return n.finish()}static join(e){if(!e.length)return Zc.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let i=e[n];i!=Zc.empty;i=i.nextLayer)t=new Zc(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}}Zc.empty=new Zc([],[],null,-1),Zc.empty.nextLayer=Zc.empty;class eh{finishChunk(e){this.chunks.push(new Qc(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new eh)).add(e,t,n)}addInner(e,t,n){let i=e-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(i<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(Zc.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=Zc.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function th(e,t,n){let i=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&i.set(t.chunk[e],t.chunkPos[e]);let r=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let o=i.get(e.chunk[t]);null==o||(n?n.mapPos(o):o)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(o,o+e.chunk[t].length))||r.add(e.chunk[t])}return r}class nh{constructor(e,t,n,i=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=i}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class ih{constructor(e){this.heap=e}static from(e,t=null,n=-1){let i=[];for(let r=0;r<e.length;r++)for(let o=e[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&i.push(new nh(o,t,n,r));return 1==i.length?i[0]:new ih(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)rh(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)rh(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),rh(this.heap,0)}}}function rh(e,t){for(let n=e[t];;){let i=1+(t<<1);if(i>=e.length)break;let r=e[i];if(i+1<e.length&&r.compare(e[i+1])>=0&&(r=e[i+1],i++),n.compare(r)<0)break;e[i]=n,e[t]=r,t=i}}class oh{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=ih.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){lh(this.active,e),lh(this.activeTo,e),lh(this.activeRank,e),this.minActive=hh(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:i,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||i-this.activeTo[t])>0;)t++;ch(this.active,t,n),ch(this.activeTo,t,i),ch(this.activeRank,t,r),e&&ch(e,t,this.cursor.from),this.minActive=hh(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),n&&lh(n,i)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function sh(e,t,n,i,r,o){e.goto(t),n.goto(i);let s=i+r,a=i,l=i-t;for(;;){let t=e.to+l-n.to,i=t||e.endSide-n.endSide,r=i<0?e.to+l:n.to,c=Math.min(r,s);if(e.point||n.point?e.point&&n.point&&(e.point==n.point||e.point.eq(n.point))&&ah(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,c,e.point,n.point):c>a&&!ah(e.active,n.active)&&o.compareRange(a,c,e.active,n.active),r>s)break;(t||e.openEnd!=n.openEnd)&&o.boundChange&&o.boundChange(r),a=r,i<=0&&e.next(),i>=0&&n.next()}}function ah(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!e[n].eq(t[n]))return!1;return!0}function lh(e,t){for(let n=t,i=e.length-1;n<i;n++)e[n]=e[n+1];e.pop()}function ch(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function hh(e,t){let n=-1,i=1e9;for(let r=0;r<t.length;r++)(t[r]-i||e[r].endSide-e[n].endSide)<0&&(n=r,i=t[r]);return n}const uh="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),dh="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),ph="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class fh{constructor(e,t){this.rules=[];let{finish:n}=t||{};function i(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function r(e,t,o,s){let a=[],l=/^@(\w+)\b/.exec(e[0]),c=l&&"keyframes"==l[1];if(l&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))r(n.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),s,o);else if(s&&"object"==typeof s){if(!l)throw new RangeError("The value of a property ("+n+") should be a primitive value.");r(i(n),s,a,c)}else null!=s&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+s+";")}(a.length||c)&&o.push((!n||l||s?e:e.map(n)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)r(i(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=ph[uh]||1;return ph[uh]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let i=e[dh],r=n&&n.nonce;i?r&&i.setNonce(r):i=new mh(e,r),i.mount(Array.isArray(t)?t:[t],e)}}let gh=new Map;class mh{constructor(e,t){let n=e.ownerDocument||e,i=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let t=gh.get(n);if(t)return e[dh]=t;this.sheet=new i.CSSStyleSheet,gh.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[dh]=this}mount(e,t){let n=this.sheet,i=0,r=0;for(let t=0;t<e.length;t++){let o=e[t],s=this.modules.indexOf(o);if(s<r&&s>-1&&(this.modules.splice(s,1),r--,s=-1),-1==s){if(this.modules.splice(r++,0,o),n)for(let e=0;e<o.rules.length;e++)n.insertRule(o.rules[e],i++)}else{for(;r<s;)i+=this.modules[r++].rules.length;i+=o.rules.length,r++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var yh={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},vh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},wh=0;wh<10;wh++)yh[48+wh]=yh[96+wh]=String(wh);for(wh=1;wh<=24;wh++)yh[wh+111]="F"+wh;for(wh=65;wh<=90;wh++)yh[wh]=String.fromCharCode(wh+32),vh[wh]=String.fromCharCode(wh);for(var bh in yh)vh.hasOwnProperty(bh)||(vh[bh]=yh[bh]);function xh(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function kh(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function _h(e,t){if(!t.anchorNode)return!1;try{return kh(e,t.anchorNode)}catch(e){return!1}}function Sh(e){return 3==e.nodeType?Lh(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function Ch(e,t,n,i){return!!n&&(Ah(e,t,n,i,-1)||Ah(e,t,n,i,1))}function Eh(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function Mh(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function Ah(e,t,n,i,r){for(;;){if(e==n&&t==i)return!0;if(t==(r<0?0:Dh(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=Eh(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(r<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=r<0?Dh(e):0}}}function Dh(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Rh(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function Oh(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function Th(e,t){let n=t.width/e.offsetWidth,i=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.height-e.offsetHeight)<1)&&(i=1),{scaleX:n,scaleY:i}}class Nh{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?Dh(t):0),n,Math.min(e.focusOffset,n?Dh(n):0))}set(e,t,n,i){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=i}}let Ph,qh=null;function Bh(e){if(e.setActive)return e.setActive();if(qh)return e.focus(qh);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==qh?{get preventScroll(){return qh={preventScroll:!0},!0}}:void 0),!qh){qh=!1;for(let e=0;e<t.length;){let n=t[e++],i=t[e++],r=t[e++];n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}}}function Lh(e,t,n=t){let i=Ph||(Ph=document.createRange());return i.setEnd(e,n),i.setStart(e,t),i}function Ih(e,t,n,i){let r={key:t,code:t,keyCode:n,which:n,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let o=new KeyboardEvent("keydown",r);o.synthetic=!0,e.dispatchEvent(o);let s=new KeyboardEvent("keyup",r);return s.synthetic=!0,e.dispatchEvent(s),o.defaultPrevented||s.defaultPrevented}function Fh(e){for(;e.attributes.length;)e.removeAttributeNode(e.attributes[0])}function jh(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Vh(e,t){for(let n=e,i=t;;){if(3==n.nodeType&&i>0)return{node:n,offset:i};if(1==n.nodeType&&i>0){if("false"==n.contentEditable)return null;n=n.childNodes[i-1],i=Dh(n)}else{if(!n.parentNode||Mh(n))return null;i=Eh(n),n=n.parentNode}}}function $h(e,t){for(let n=e,i=t;;){if(3==n.nodeType&&i<n.nodeValue.length)return{node:n,offset:i};if(1==n.nodeType&&i<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[i],i=0}else{if(!n.parentNode||Mh(n))return null;i=Eh(n)+1,n=n.parentNode}}}class zh{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new zh(e.parentNode,Eh(e),t)}static after(e,t){return new zh(e.parentNode,Eh(e)+1,t)}}const Hh=[];class Wh{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(2&this.flags){let n,i=this.dom,r=null;for(let o of this.children){if(7&o.flags){if(!o.dom&&(n=r?r.nextSibling:i.firstChild)){let e=Wh.get(n);(!e||!e.parent&&e.canReuseDOM(o))&&o.reuseDOM(n)}o.sync(e,t),o.flags&=-8}if(n=r?r.nextSibling:i.firstChild,t&&!t.written&&t.node==i&&n!=o.dom&&(t.written=!0),o.dom.parentNode==i)for(;n&&n!=o.dom;)n=Uh(n);else i.insertBefore(o.dom,n);r=o.dom}for(n=r?r.nextSibling:i.firstChild,n&&t&&t.node==i&&(t.written=!0);n;)n=Uh(n)}else if(1&this.flags)for(let n of this.children)7&n.flags&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let i=0==Dh(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==this.dom)break;0==i&&t.firstChild!=t.lastChild&&(i=e==t.firstChild?-1:1),e=t}n=i<0?e:e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!Wh.get(n);)n=n.nextSibling;if(!n)return this.length;for(let e=0,t=0;;e++){let i=this.children[e];if(i.dom==n)return t;t+=i.length+i.breakAfter}}domBoundsAround(e,t,n=0){let i=-1,r=-1,o=-1,s=-1;for(let a=0,l=n,c=n;a<this.children.length;a++){let n=this.children[a],h=l+n.length;if(l<e&&h>t)return n.domBoundsAround(e,t,l);if(h>=e&&-1==i&&(i=a,r=l),l>t&&n.dom.parentNode==this.dom){o=a,s=c;break}c=h,l=h+n.breakAfter}return{from:r,to:s<0?n+this.length:s,startDOM:(i?this.children[i-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),1&t.flags)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,7&this.flags&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=Hh){this.markDirty();for(let i=e;i<t;i++){let e=this.children[i];e.parent==this&&n.indexOf(e)<0&&e.destroy()}n.length<250?this.children.splice(e,t-e,...n):this.children=[].concat(this.children.slice(0,e),n,this.children.slice(t));for(let e=0;e<n.length;e++)n[e].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new Gh(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==e?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,i,r,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!(8&(this.flags|e.flags))}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}}function Uh(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}Wh.prototype.breakAfter=0;class Gh{constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}function Kh(e,t,n,i,r,o,s,a,l){let{children:c}=e,h=c.length?c[t]:null,u=o.length?o[o.length-1]:null,d=u?u.breakAfter:s;if(!(t==i&&h&&!s&&!d&&o.length<2&&h.merge(n,r,o.length?u:null,0==n,a,l))){if(i<c.length){let e=c[i];e&&(r<e.length||e.breakAfter&&(null==u?void 0:u.breakAfter))?(t==i&&(e=e.split(r),r=0),!d&&u&&e.merge(0,r,u,!0,0,l)?o[o.length-1]=e:((r||e.children.length&&!e.children[0].length)&&e.merge(0,r,null,!1,0,l),o.push(e))):(null==e?void 0:e.breakAfter)&&(u?u.breakAfter=1:s=1),i++}for(h&&(h.breakAfter=s,n>0&&(!s&&o.length&&h.merge(n,h.length,o[0],!1,a,0)?h.breakAfter=o.shift().breakAfter:(n<h.length||h.children.length&&0==h.children[h.children.length-1].length)&&h.merge(n,h.length,null,!1,a,0),t++));t<i&&o.length;)if(c[i-1].become(o[o.length-1]))i--,o.pop(),l=o.length?0:a;else{if(!c[t].become(o[0]))break;t++,o.shift(),a=o.length?0:l}!o.length&&t&&i<c.length&&!c[t-1].breakAfter&&c[i].merge(0,0,c[t-1],!1,a,l)&&t--,(t<i||o.length)&&e.replaceChildren(t,i,o)}}function Xh(e,t,n,i,r,o){let s=e.childCursor(),{i:a,off:l}=s.findPos(n,1),{i:c,off:h}=s.findPos(t,-1),u=t-n;for(let e of i)u+=e.length;e.length+=u,Kh(e,c,h,a,l,i,0,r,o)}let Yh="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Jh="undefined"!=typeof document?document:{documentElement:{style:{}}};const Qh=/Edge\/(\d+)/.exec(Yh.userAgent),Zh=/MSIE \d/.test(Yh.userAgent),eu=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Yh.userAgent),tu=!!(Zh||eu||Qh),nu=!tu&&/gecko\/(\d+)/i.test(Yh.userAgent),iu=!tu&&/Chrome\/(\d+)/.exec(Yh.userAgent),ru="webkitFontSmoothing"in Jh.documentElement.style,ou=!tu&&/Apple Computer/.test(Yh.vendor),su=ou&&(/Mobile\/\w+/.test(Yh.userAgent)||Yh.maxTouchPoints>2);var au={mac:su||/Mac/.test(Yh.platform),windows:/Win/.test(Yh.platform),linux:/Linux|X11/.test(Yh.platform),ie:tu,ie_version:Zh?Jh.documentMode||6:eu?+eu[1]:Qh?+Qh[1]:0,gecko:nu,gecko_version:nu?+(/Firefox\/(\d+)/.exec(Yh.userAgent)||[0,0])[1]:0,chrome:!!iu,chrome_version:iu?+iu[1]:0,ios:su,android:/Android\b/.test(Yh.userAgent),webkit:ru,safari:ou,webkit_version:ru?+(/\bAppleWebKit\/(\d+)/.exec(Yh.userAgent)||[0,0])[1]:0,tabSize:null!=Jh.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class lu extends Wh{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){3==e.nodeType&&this.createDOM(e)}merge(e,t,n){return!(8&this.flags||n&&(!(n instanceof lu)||this.length-(t-e)+n.length>256||8&n.flags))&&(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new lu(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=8&this.flags,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new zh(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return function(e,t,n){let i=e.nodeValue.length;t>i&&(t=i);let r=t,o=t,s=0;0==t&&n<0||t==i&&n>=0?au.chrome||au.gecko||(t?(r--,s=1):o<i&&(o++,s=-1)):n<0?r--:o<i&&o++;let a=Lh(e,r,o).getClientRects();if(!a.length)return null;let l=a[(s?s<0:n>=0)?0:a.length-1];au.safari&&!s&&0==l.width&&(l=Array.prototype.find.call(a,(e=>e.width))||l);return s?Rh(l,s<0):l||null}(this.dom,e,t)}}class cu extends Wh{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let e of t)e.setParent(this)}setAttrs(e){if(Fh(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!(8&(this.flags|e.flags))}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,i,r,o){return(!n||!(!(n instanceof cu&&n.mark.eq(this.mark))||e&&r<=0||t<this.length&&o<=0))&&(Xh(this,e,t,n?n.children.slice():[],r-1,o-1),this.markDirty(),!0)}split(e){let t=[],n=0,i=-1,r=0;for(let o of this.children){let s=n+o.length;s>e&&t.push(n<e?o.split(e-n):o),i<0&&n>=e&&(i=r),n=s,r++}let o=this.length-e;return this.length=e,i>-1&&(this.children.length=i,this.markDirty()),new cu(this.mark,t,o)}domAtPos(e){return du(this,e)}coordsAt(e,t){return fu(this,e,t)}}class hu extends Wh{static create(e,t,n){return new hu(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}split(e){let t=hu.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,n,i,r,o){return!(n&&(!(n instanceof hu&&this.widget.compare(n.widget))||e>0&&r<=0||t<this.length&&o<=0))&&(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof hu&&e.side==this.side&&this.widget.constructor==e.widget.constructor&&(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0)}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(0==this.length)return ql.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,i=this.posAtStart;return n?n.slice(i,i+this.length):ql.empty}domAtPos(e){return(this.length?0==e:this.side>0)?zh.before(this.dom):zh.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let i=this.dom.getClientRects(),r=null;if(!i.length)return null;let o=this.side?this.side<0:e>0;for(let t=o?i.length-1:0;r=i[t],!(e>0?0==t:t==i.length-1||r.top<r.bottom);t+=o?-1:1);return Rh(r,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class uu extends Wh{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof uu&&e.side==this.side}split(){return new uu(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?zh.before(this.dom):zh.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return ql.empty}get isHidden(){return!0}}function du(e,t){let n=e.dom,{children:i}=e,r=0;for(let e=0;r<i.length;r++){let o=i[r],s=e+o.length;if(!(s==e&&o.getSide()<=0)){if(t>e&&t<s&&o.dom.parentNode==n)return o.domAtPos(t-e);if(t<=e)break;e=s}}for(let e=r;e>0;e--){let t=i[e-1];if(t.dom.parentNode==n)return t.domAtPos(t.length)}for(let e=r;e<i.length;e++){let t=i[e];if(t.dom.parentNode==n)return t.domAtPos(0)}return new zh(n,0)}function pu(e,t,n){let i,{children:r}=e;n>0&&t instanceof cu&&r.length&&(i=r[r.length-1])instanceof cu&&i.mark.eq(t.mark)?pu(i,t.children[0],n-1):(r.push(t),t.setParent(e)),e.length+=t.length}function fu(e,t,n){let i=null,r=-1,o=null,s=-1;!function e(t,a){for(let l=0,c=0;l<t.children.length&&c<=a;l++){let h=t.children[l],u=c+h.length;u>=a&&(h.children.length?e(h,a-c):(!o||o.isHidden&&n>0)&&(u>a||c==u&&h.getSide()>0)?(o=h,s=a-c):(c<a||c==u&&h.getSide()<0&&!h.isHidden)&&(i=h,r=a-c)),c=u}}(e,t);let a=(n<0?i:o)||i||o;return a?a.coordsAt(Math.max(0,a==i?r:s),n):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=Sh(t);return n[n.length-1]||null}(e)}function gu(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}lu.prototype.children=hu.prototype.children=uu.prototype.children=Hh;const mu=Object.create(null);function yu(e,t,n){if(e==t)return!0;e||(e=mu),t||(t=mu);let i=Object.keys(e),r=Object.keys(t);if(i.length-(n&&i.indexOf(n)>-1?1:0)!=r.length-(n&&r.indexOf(n)>-1?1:0))return!1;for(let o of i)if(o!=n&&(-1==r.indexOf(o)||e[o]!==t[o]))return!1;return!0}function vu(e,t,n){let i=!1;if(t)for(let r in t)n&&r in n||(i=!0,"style"==r?e.style.cssText="":e.removeAttribute(r));if(n)for(let r in n)t&&t[r]==n[r]||(i=!0,"style"==r?e.style.cssText=n[r]:e.setAttribute(r,n[r]));return i}function wu(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n];t[i.name]=i.value}return t}class bu{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var xu=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(xu||(xu={}));class ku extends Xc{constructor(e,t,n,i){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=i}get heightRelevant(){return!1}static mark(e){return new _u(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Cu(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,i=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:r,end:o}=Eu(e,i);t=(r?i?-3e8:-1:5e8)-1,n=1+(o?i?2e8:1:-6e8)}return new Cu(e,t,n,i,e.widget||null,!0)}static line(e){return new Su(e)}static set(e,t=!1){return Zc.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}ku.none=Zc.empty;class _u extends ku{constructor(e){let{start:t,end:n}=Eu(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof _u&&this.tagName==e.tagName&&(this.class||(null===(t=this.attrs)||void 0===t?void 0:t.class))==(e.class||(null===(n=e.attrs)||void 0===n?void 0:n.class))&&yu(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}_u.prototype.point=!1;class Su extends ku{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Su&&this.spec.class==e.spec.class&&yu(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)}}Su.prototype.mapMode=Gl.TrackBefore,Su.prototype.point=!0;class Cu extends ku{constructor(e,t,n,i,r,o){super(t,n,r,e),this.block=i,this.isReplace=o,this.mapMode=i?t<=0?Gl.TrackBefore:Gl.TrackAfter:Gl.TrackDel}get type(){return this.startSide!=this.endSide?xu.WidgetRange:this.startSide<=0?xu.WidgetBefore:xu.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Cu&&(t=this.widget,n=e.widget,t==n||!!(t&&n&&t.compare(n)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide;var t,n}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function Eu(e,t=!1){let{inclusiveStart:n,inclusiveEnd:i}=e;return null==n&&(n=e.inclusive),null==i&&(i=e.inclusive),{start:null!=n?n:t,end:null!=i?i:t}}function Mu(e,t,n,i=0){let r=n.length-1;r>=0&&n[r]+i>=e?n[r]=Math.max(n[r],t):n.push(e,t)}Cu.prototype.point=!0;class Au extends Wh{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,i,r,o){if(n){if(!(n instanceof Au))return!1;this.dom||n.transferDOM(this)}return i&&this.setDeco(n?n.attrs:null),Xh(this,e,t,n?n.children.slice():[],r,o),!0}split(e){let t=new Au;if(t.breakAfter=this.breakAfter,0==this.length)return t;let{i:n,off:i}=this.childPos(e);i&&(t.append(this.children[n].split(i),0),this.children[n].merge(i,this.children[n].length,null,!1,0,0),n++);for(let e=n;e<this.children.length;e++)t.append(this.children[e],0);for(;n>0&&0==this.children[n-1].length;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){yu(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){pu(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=gu(t,this.attrs||{})),n&&(this.attrs=gu({class:n},this.attrs||{}))}domAtPos(e){return du(this,e)}reuseDOM(e){"DIV"==e.nodeName&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?4&this.flags&&(Fh(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(vu(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let i=this.dom.lastChild;for(;i&&Wh.get(i)instanceof cu;)i=i.lastChild;if(!(i&&this.length&&("BR"==i.nodeName||0!=(null===(n=Wh.get(i))||void 0===n?void 0:n.isEditable)||au.ios&&this.children.some((e=>e instanceof lu))))){let e=document.createElement("BR");e.cmIgnore=!0,this.dom.appendChild(e)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let e,t=0;for(let n of this.children){if(!(n instanceof lu)||/[^ -~]/.test(n.text))return null;let i=Sh(n.dom);if(1!=i.length)return null;t+=i[0].width,e=i[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(e,t){let n=fu(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:e}=this.parent.view.viewState,t=n.bottom-n.top;if(Math.abs(t-e.lineHeight)<2&&e.textHeight<t){let i=(t-e.textHeight)/2;return{top:n.top+i,bottom:n.bottom-i,left:n.left,right:n.left}}}return n}become(e){return e instanceof Au&&0==this.children.length&&0==e.children.length&&yu(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let n=0,i=0;n<e.children.length;n++){let r=e.children[n],o=i+r.length;if(o>=t){if(r instanceof Au)return r;if(o>t)break}i=o+r.breakAfter}return null}}class Du extends Wh{constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,i,r,o){return!(n&&(!(n instanceof Du&&this.widget.compare(n.widget))||e>0&&r<=0||t<this.length&&o<=0))&&(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return 0==e?zh.before(this.dom):zh.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new Du(this.widget,t,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return Hh}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):ql.empty}domBoundsAround(){return null}become(e){return e instanceof Du&&e.widget.constructor==this.widget.constructor&&(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);return n||(this.widget instanceof Ru?null:Rh(this.dom.getBoundingClientRect(),this.length?0==e:t<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:n}=this.deco;return t!=n&&(e<0?t<0:n>0)}}class Ru extends bu{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}}class Ou{constructor(e,t,n,i){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=i,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof Du&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Au),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Tu(new uu(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||e&&this.content.length&&this.content[this.content.length-1]instanceof Du||this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:i}=this.cursor.next(this.skip);if(this.skip=0,i)throw new Error("Ran out of text content when drawing inline views");if(n){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}this.text=t,this.textOff=0}let i=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(Tu(new lu(this.text.slice(this.textOff,this.textOff+i)),t),n),this.atCursorPos=!0,this.textOff+=i,e-=i,n=0}}span(e,t,n,i){this.buildText(t-e,n,i),this.pos=t,this.openStart<0&&(this.openStart=i)}point(e,t,n,i,r,o){if(this.disallowBlockEffectsFor[o]&&n instanceof Cu){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let s=t-e;if(n instanceof Cu)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Du(n.widget||Nu.block,s,n));else{let o=hu.create(n.widget||Nu.inline,s,s?0:n.startSide),a=this.atCursorPos&&!o.isEditable&&r<=i.length&&(e<t||n.startSide>0),l=!o.isEditable&&(e<t||r>i.length||n.startSide<=0),c=this.getLine();2!=this.pendingBuffer||a||o.isEditable||(this.pendingBuffer=0),this.flushBuffer(i),a&&(c.append(Tu(new uu(1),i),r),r=i.length+Math.max(0,r-i.length)),c.append(Tu(o,i),r),this.atCursorPos=l,this.pendingBuffer=l?e<t||r>i.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=i.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);s&&(this.textOff+s<=this.text.length?this.textOff+=s:(this.skip+=s-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,n,i,r){let o=new Ou(e,t,n,r);return o.openEnd=Zc.spans(i,t,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Tu(e,t){for(let n of t)e=new cu(n,[e],e.length);return e}class Nu extends bu{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}}Nu.inline=new Nu("span"),Nu.block=new Nu("div");var Pu=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(Pu||(Pu={}));const qu=Pu.LTR,Bu=Pu.RTL;function Lu(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}const Iu=Lu("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Fu=Lu("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),ju=Object.create(null),Vu=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);ju[t]=n,ju[n]=-t}function $u(e){return e<=247?Iu[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?Fu[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const zu=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Hu{get dir(){return this.level%2?Bu:qu}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,i){let r=-1;for(let o=0;o<e.length;o++){let s=e[o];if(s.from<=t&&s.to>=t){if(s.level==n)return o;(r<0||(0!=i?i<0?s.from<t:s.to>t:e[r].level>s.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function Wu(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],r=t[n];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!Wu(i.inner,r.inner))return!1}return!0}const Uu=[];function Gu(e,t,n,i,r,o,s){let a=i%2?2:1;if(i%2==r%2)for(let l=t,c=0;l<n;){let t=!0,h=!1;if(c==o.length||l<o[c].from){let e=Uu[l];e!=a&&(t=!1,h=16==e)}let u=t||1!=a?null:[],d=t?i:i+1,p=l;e:for(;;)if(c<o.length&&p==o[c].from){if(h)break e;let f=o[c];if(!t)for(let e=f.to,t=c+1;;){if(e==n)break e;if(!(t<o.length&&o[t].from==e)){if(Uu[e]==a)break e;break}e=o[t++].to}if(c++,u)u.push(f);else{f.from>l&&s.push(new Hu(l,f.from,d)),Ku(e,f.direction==qu!=!(d%2)?i+1:i,r,f.inner,f.from,f.to,s),l=f.to}p=f.to}else{if(p==n||(t?Uu[p]!=a:Uu[p]==a))break;p++}u?Gu(e,l,p,i+1,r,u,s):l<p&&s.push(new Hu(l,p,d)),l=p}else for(let l=n,c=o.length;l>t;){let n=!0,h=!1;if(!c||l>o[c-1].to){let e=Uu[l-1];e!=a&&(n=!1,h=16==e)}let u=n||1!=a?null:[],d=n?i:i+1,p=l;e:for(;;)if(c&&p==o[c-1].to){if(h)break e;let f=o[--c];if(!n)for(let e=f.from,n=c;;){if(e==t)break e;if(!n||o[n-1].to!=e){if(Uu[e-1]==a)break e;break}e=o[--n].from}if(u)u.push(f);else{f.to<l&&s.push(new Hu(f.to,l,d)),Ku(e,f.direction==qu!=!(d%2)?i+1:i,r,f.inner,f.from,f.to,s),l=f.from}p=f.from}else{if(p==t||(n?Uu[p-1]!=a:Uu[p-1]==a))break;p--}u?Gu(e,p,l,i+1,r,u,s):p<l&&s.push(new Hu(p,l,d)),l=p}}function Ku(e,t,n,i,r,o,s){let a=t%2?2:1;!function(e,t,n,i,r){for(let o=0;o<=i.length;o++){let s=o?i[o-1].to:t,a=o<i.length?i[o].from:n,l=o?256:r;for(let t=s,n=l,i=l;t<a;t++){let r=$u(e.charCodeAt(t));512==r?r=n:8==r&&4==i&&(r=16),Uu[t]=4==r?2:r,7&r&&(i=r),n=r}for(let e=s,t=l,i=l;e<a;e++){let r=Uu[e];if(128==r)e<a-1&&t==Uu[e+1]&&24&t?r=Uu[e]=t:Uu[e]=256;else if(64==r){let r=e+1;for(;r<a&&64==Uu[r];)r++;let o=e&&8==t||r<n&&8==Uu[r]?1==i?1:8:256;for(let t=e;t<r;t++)Uu[t]=o;e=r-1}else 8==r&&1==i&&(Uu[e]=1);t=r,7&r&&(i=r)}}}(e,r,o,i,a),function(e,t,n,i,r){let o=1==r?2:1;for(let s=0,a=0,l=0;s<=i.length;s++){let c=s?i[s-1].to:t,h=s<i.length?i[s].from:n;for(let t,n,i,s=c;s<h;s++)if(n=ju[t=e.charCodeAt(s)])if(n<0){for(let e=a-3;e>=0;e-=3)if(Vu[e+1]==-n){let t=Vu[e+2],n=2&t?r:4&t?1&t?o:r:0;n&&(Uu[s]=Uu[Vu[e]]=n),a=e;break}}else{if(189==Vu.length)break;Vu[a++]=s,Vu[a++]=t,Vu[a++]=l}else if(2==(i=Uu[s])||1==i){let e=i==r;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=Vu[t+2];if(2&n)break;if(e)Vu[t+2]|=2;else{if(4&n)break;Vu[t+2]|=4}}}}}(e,r,o,i,a),function(e,t,n,i){for(let r=0,o=i;r<=n.length;r++){let s=r?n[r-1].to:e,a=r<n.length?n[r].from:t;for(let l=s;l<a;){let s=Uu[l];if(256==s){let s=l+1;for(;;)if(s==a){if(r==n.length)break;s=n[r++].to,a=r<n.length?n[r].from:t}else{if(256!=Uu[s])break;s++}let c=1==o,h=c==(1==(s<t?Uu[s]:i))?c?1:2:i;for(let t=s,i=r,o=i?n[i-1].to:e;t>l;)t==o&&(t=n[--i].from,o=i?n[i-1].to:e),Uu[--t]=h;l=s}else o=s,l++}}}(r,o,i,a),Gu(e,r,o,t,n,i,s)}function Xu(e){return[new Hu(0,e,0)]}let Yu="";function Ju(e,t,n,i,r){var o;let s=i.head-e.from,a=Hu.find(t,s,null!==(o=i.bidiLevel)&&void 0!==o?o:-1,i.assoc),l=t[a],c=l.side(r,n);if(s==c){let e=a+=r?1:-1;if(e<0||e>=t.length)return null;l=t[a=e],s=l.side(!r,n),c=l.side(r,n)}let h=Wl(e.text,s,l.forward(r,n));(h<l.from||h>l.to)&&(h=c),Yu=e.text.slice(Math.min(s,h),Math.max(s,h));let u=a==(r?t.length-1:0)?null:t[a+(r?1:-1)];return u&&h==c&&u.level+(r?0:1)<l.level?ic.cursor(u.side(!r,n)+e.from,u.forward(r,n)?1:-1,u.level):ic.cursor(h+e.from,l.forward(r,n)?-1:1,l.level)}function Qu(e,t,n){for(let i=t;i<n;i++){let t=$u(e.charCodeAt(i));if(1==t)return qu;if(2==t||4==t)return Bu}return qu}const Zu=sc.define(),ed=sc.define(),td=sc.define(),nd=sc.define(),id=sc.define(),rd=sc.define(),od=sc.define(),sd=sc.define(),ad=sc.define(),ld=sc.define({combine:e=>e.some((e=>e))}),cd=sc.define({combine:e=>e.some((e=>e))}),hd=sc.define();class ud{constructor(e,t="nearest",n="nearest",i=5,r=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=i,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new ud(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 ud(ic.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const dd=Bc.define({map:(e,t)=>e.map(t)}),pd=Bc.define();function fd(e,t,n){let i=e.facet(nd);i.length?i[0](t):window.onerror?window.onerror(String(t),n,void 0,void 0,t):n?console.error(n+":",t):console.error(t)}const gd=sc.define({combine:e=>!e.length||e[0]});let md=0;const yd=sc.define();class vd{constructor(e,t,n,i,r){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=i,this.extension=r(this)}static define(e,t){const{eventHandlers:n,eventObservers:i,provide:r,decorations:o}=t||{};return new vd(md++,e,n,i,(e=>{let t=[yd.of(e)];return o&&t.push(kd.of((t=>{let n=t.plugin(e);return n?o(n):ku.none}))),r&&t.push(r(e)),t}))}static fromClass(e,t){return vd.define((t=>new e(t)),t)}}class wd{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(fd(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){fd(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){fd(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const bd=sc.define(),xd=sc.define(),kd=sc.define(),_d=sc.define(),Sd=sc.define(),Cd=sc.define();function Ed(e,t){let n=e.state.facet(Cd);if(!n.length)return n;let i=n.map((t=>t instanceof Function?t(e):t)),r=[];return Zc.spans(i,t.from,t.to,{point(){},span(e,n,i,o){let s=e-t.from,a=n-t.from,l=r;for(let e=i.length-1;e>=0;e--,o--){let n,r=i[e].spec.bidiIsolate;if(null==r&&(r=Qu(t.text,s,a)),o>0&&l.length&&(n=l[l.length-1]).to==s&&n.direction==r)n.to=a,l=n.inner;else{let e={from:s,to:a,direction:r,inner:[]};l.push(e),l=e.inner}}}}),r}const Md=sc.define();function Ad(e){let t=0,n=0,i=0,r=0;for(let o of e.state.facet(Md)){let s=o(e);s&&(null!=s.left&&(t=Math.max(t,s.left)),null!=s.right&&(n=Math.max(n,s.right)),null!=s.top&&(i=Math.max(i,s.top)),null!=s.bottom&&(r=Math.max(r,s.bottom)))}return{left:t,right:n,top:i,bottom:r}}const Dd=sc.define();class Rd{constructor(e,t,n,i){this.fromA=e,this.toA=t,this.fromB=n,this.toB=i}join(e){return new Rd(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let i=e[t-1];if(!(i.fromA>n.toA)){if(i.toA<n.fromA)break;n=n.join(i),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let i=0,r=0,o=0,s=0;;i++){let a=i==e.length?null:e[i],l=o-s,c=a?a.fromB:1e9;for(;r<t.length&&t[r]<c;){let e=t[r],i=t[r+1],o=Math.max(s,e),a=Math.min(c,i);if(o<=a&&new Rd(o+l,a+l,o,a).addToSet(n),i>c)break;r+=2}if(!a)return n;new Rd(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),o=a.toA,s=a.toB}}}class Od{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=Xl.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let i=[];this.changes.iterChangedRanges(((e,t,n,r)=>i.push(new Rd(e,t,n,r)))),this.changedRanges=i}static create(e,t,n){return new Od(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((e=>e.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class Td extends Wh{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=ku.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.setDOM(e.contentDOM),this.children=[new Au],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Rd(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every((({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo))?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?i=this.domChanged.newSel.head:function(e,t){let n=!1;t&&e.iterChangedRanges(((e,i)=>{e<t.to&&i>t.from&&(n=!0)}));return n}(e.changes,this.hasComposition)||e.selectionSet||(i=e.state.selection.main.head));let r=i>-1?function(e,t,n){let i=Nd(e,n);if(!i)return null;let{node:r,from:o,to:s}=i,a=r.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(i.from,i.to)!=a)return null;let l=t.invertedDesc,c=new Rd(l.mapPos(o),l.mapPos(s),o,s),h=[];for(let t=r.parentNode;;t=t.parentNode){let n=Wh.get(t);if(n instanceof cu)h.push({node:t,deco:n.mark});else{if(n instanceof Au||"DIV"==t.nodeName&&t.parentNode==e.contentDOM)return{range:c,text:r,marks:h,line:t};if(t==e.contentDOM)return null;h.push({node:t,deco:new _u({inclusive:!0,attributes:wu(t),tagName:t.tagName.toLowerCase()})})}}}(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:t,to:i}=this.hasComposition;n=new Rd(t,i,e.changes.mapPos(t,-1),e.changes.mapPos(i,1)).addToSet(n.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(au.ie||au.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=function(e,t,n){let i=new Pd;return Zc.compare(e,t,n,i),i.changes}(this.decorations,this.updateDeco(),e.changes);return n=Rd.extendWithRanges(n,o),!!(7&this.flags||0!=n.length)&&(this.updateInner(n,e.startState.doc.length,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:i}=this.view;i.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let e=au.chrome||au.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,e),this.flags&=-8,e&&(e.written||i.selectionRange.focusNode!=e.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((e=>e.flags&=-9));let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.children)e instanceof Du&&e.widget instanceof Ru&&r.push(e.dom);i.updateGaps(r)}updateChildren(e,t,n){let i=n?n.range.addToSet(e.slice()):e,r=this.childCursor(t);for(let e=i.length-1;;e--){let t=e>=0?i[e]:null;if(!t)break;let o,s,a,l,{fromA:c,toA:h,fromB:u,toB:d}=t;if(n&&n.range.fromB<d&&n.range.toB>u){let e=Ou.build(this.view.state.doc,u,n.range.fromB,this.decorations,this.dynamicDecorationMap),t=Ou.build(this.view.state.doc,n.range.toB,d,this.decorations,this.dynamicDecorationMap);s=e.breakAtStart,a=e.openStart,l=t.openEnd;let i=this.compositionView(n);t.breakAtStart?i.breakAfter=1:t.content.length&&i.merge(i.length,i.length,t.content[0],!1,t.openStart,0)&&(i.breakAfter=t.content[0].breakAfter,t.content.shift()),e.content.length&&i.merge(0,0,e.content[e.content.length-1],!0,0,e.openEnd)&&e.content.pop(),o=e.content.concat(i).concat(t.content)}else({content:o,breakAtStart:s,openStart:a,openEnd:l}=Ou.build(this.view.state.doc,u,d,this.decorations,this.dynamicDecorationMap));let{i:p,off:f}=r.findPos(h,1),{i:g,off:m}=r.findPos(c,-1);Kh(this,g,m,p,f,o,s,a,l)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(pd)&&(this.editContextFormatting=e.value)}compositionView(e){let t=new lu(e.text.nodeValue);t.flags|=8;for(let{deco:n}of e.marks)t=new cu(n,[t],t.length);let n=new Au;return n.append(t,0),n}fixCompositionDOM(e){let t=(e,t)=>{t.flags|=8|(t.children.some((e=>7&e.flags))?1:0),this.markedForComposition.add(t);let n=Wh.get(e);n&&n!=t&&(n.dom=null),t.setDOM(e)},n=this.childPos(e.range.fromB,1),i=this.children[n.i];t(e.line,i);for(let r=e.marks.length-1;r>=-1;r--)n=i.childPos(n.off,1),i=i.children[n.i],t(r>=0?e.marks[r].node:e.text,i)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let n=this.view.root.activeElement,i=n==this.dom,r=!i&&!(this.view.state.facet(gd)||this.dom.tabIndex>-1)&&_h(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(i||t||r))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(s.anchor)),l=s.empty?a:this.moveToLine(this.domAtPos(s.head));if(au.gecko&&s.empty&&!this.hasComposition&&(1==(c=a).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore((()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null))),a=l=new zh(e,0),o=!0}var c;let h=this.view.observer.selectionRange;!o&&h.focusNode&&(Ch(a.node,a.offset,h.anchorNode,h.anchorOffset)&&Ch(l.node,l.offset,h.focusNode,h.focusOffset)||this.suppressWidgetCursorChange(h,s))||(this.view.observer.ignore((()=>{au.android&&au.chrome&&this.dom.contains(h.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(h.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let e=xh(this.view.root);if(e)if(s.empty){if(au.gecko){let e=function(e,t){return 1!=e.nodeType?0:(t&&"false"==e.childNodes[t-1].contentEditable?1:0)|(t<e.childNodes.length&&"false"==e.childNodes[t].contentEditable?2:0)}(a.node,a.offset);if(e&&3!=e){let t=(1==e?Vh:$h)(a.node,a.offset);t&&(a=new zh(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=s.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(l.node,l.offset)}catch(e){}}else{let t=document.createRange();s.anchor>s.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}else;r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())})),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new zh(h.anchorNode,h.anchorOffset),this.impreciseHead=l.precise?null:new zh(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Ch(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=xh(e.root),{anchorNode:i,anchorOffset:r}=e.observer.selectionRange;if(!(n&&t.empty&&t.assoc&&n.modify))return;let o=Au.find(this,t.head);if(!o)return;let s=o.posAtStart;if(t.head==s||t.head==s+o.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(i,r)}moveToLine(e){let t,n=this.dom;if(e.node!=n)return e;for(let i=e.offset;!t&&i<n.childNodes.length;i++){let e=Wh.get(n.childNodes[i]);e instanceof Au&&(t=e.domAtPos(0))}for(let i=e.offset-1;!t&&i>=0;i--){let e=Wh.get(n.childNodes[i]);e instanceof Au&&(t=e.domAtPos(e.length))}return t?new zh(t.node,t.offset,!0):e}nearest(e){for(let t=e;t;){let e=Wh.get(t);if(e&&e.rootView==this)return e;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let e=this.children[t];if(n<e.length||e instanceof Au)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){let n=null,i=0;for(let r=this.length,o=this.children.length-1;o>=0;o--){let s=this.children[o],a=r-s.breakAfter,l=a-s.length;if(a<e)break;if(l<=e&&(l<e||s.covers(-1))&&(a>e||s.covers(1))&&(!n||s instanceof Au&&!(n instanceof Au&&t>=0)))n=s,i=l;else if(n&&l==e&&a==e&&s instanceof Du&&Math.abs(t)<2){if(s.deco.startSide<0)break;o&&(n=null)}r=l}return n?n.coordsAt(e-i,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),i=this.children[t];if(!(i instanceof Au))return null;for(;i.children.length;){let{i:e,off:t}=i.childPos(n,1);for(;;e++){if(e==i.children.length)return null;if((i=i.children[e]).length)break}n=t}if(!(i instanceof lu))return null;let r=Wl(i.text,n);if(r==n)return null;let o=Lh(i.dom,n,r).getClientRects();for(let e=0;e<o.length;e++){let t=o[e];if(e==o.length-1||t.top<t.bottom&&t.left<t.right)return t}return null}measureVisibleLineHeights(e){let t=[],{from:n,to:i}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,s=-1,a=this.view.textDirection==Pu.LTR;for(let e=0,l=0;l<this.children.length;l++){let c=this.children[l],h=e+c.length;if(h>i)break;if(e>=n){let n=c.dom.getBoundingClientRect();if(t.push(n.height),o){let t=c.dom.lastChild,i=t?Sh(t):[];if(i.length){let t=i[i.length-1],o=a?t.right-n.left:n.right-t.left;o>s&&(s=o,this.minWidth=r,this.minWidthFrom=e,this.minWidthTo=h)}}}e=h+c.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return"rtl"==getComputedStyle(this.children[t].dom).direction?Pu.RTL:Pu.LTR}measureTextSize(){for(let e of this.children)if(e instanceof Au){let t=e.measureTextSize();if(t)return t}let e,t,n,i=document.createElement("div");return i.className="cm-line",i.style.width="99999px",i.style.position="absolute",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(i);let r=Sh(i.firstChild)[0];e=i.getBoundingClientRect().height,t=r?r.width/27:7,n=r?r.height:e,i.remove()})),{lineHeight:e,charWidth:t,textHeight:n}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Gh(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,i=0;;i++){let r=i==t.viewports.length?null:t.viewports[i],o=r?r.from-1:this.length;if(o>n){let i=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(ku.replace({widget:new Ru(i),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!r)break;n=r.to+1}return ku.set(e)}updateDeco(){let e=1,t=this.view.state.facet(kd).map((t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t)),n=!1,i=this.view.state.facet(_d).map(((e,t)=>{let i="function"==typeof e;return i&&(n=!0),i?e(this.view):e}));for(i.length&&(this.dynamicDecorationMap[e++]=n,t.push(Zc.join(i))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(hd))try{if(t(this.view,e.range,e))return!0}catch(e){fd(this.view.state,e,"scroll handler")}let t,{range:n}=e,i=this.coordsAt(n.head,n.empty?n.assoc:n.head>n.anchor?-1:1);if(!i)return;!n.empty&&(t=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(i={left:Math.min(i.left,t.left),top:Math.min(i.top,t.top),right:Math.max(i.right,t.right),bottom:Math.max(i.bottom,t.bottom)});let r=Ad(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:s,offsetHeight:a}=this.view.scrollDOM;!function(e,t,n,i,r,o,s,a){let l=e.ownerDocument,c=l.defaultView||window;for(let h=e,u=!1;h&&!u;)if(1==h.nodeType){let e,d=h==l.body,p=1,f=1;if(d)e=Oh(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let t=h.getBoundingClientRect();({scaleX:p,scaleY:f}=Th(h,t)),e={left:t.left,right:t.left+h.clientWidth*p,top:t.top,bottom:t.top+h.clientHeight*f}}let g=0,m=0;if("nearest"==r)t.top<e.top?(m=-(e.top-t.top+s),n>0&&t.bottom>e.bottom+m&&(m=t.bottom-e.bottom+m+s)):t.bottom>e.bottom&&(m=t.bottom-e.bottom+s,n<0&&t.top-m<e.top&&(m=-(e.top+m-t.top+s)));else{let i=t.bottom-t.top,o=e.bottom-e.top;m=("center"==r&&i<=o?t.top+i/2-o/2:"start"==r||"center"==r&&n<0?t.top-s:t.bottom-o+s)-e.top}if("nearest"==i?t.left<e.left?(g=-(e.left-t.left+o),n>0&&t.right>e.right+g&&(g=t.right-e.right+g+o)):t.right>e.right&&(g=t.right-e.right+o,n<0&&t.left<e.left+g&&(g=-(e.left+g-t.left+o))):g=("center"==i?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==i==a?t.left-o:t.right-(e.right-e.left)+o)-e.left,g||m)if(d)c.scrollBy(g,m);else{let e=0,n=0;if(m){let e=h.scrollTop;h.scrollTop+=m/f,n=(h.scrollTop-e)*f}if(g){let t=h.scrollLeft;h.scrollLeft+=g/p,e=(h.scrollLeft-t)*p}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-g)<1&&(i="nearest"),n&&Math.abs(n-m)<1&&(r="nearest")}if(d)break;h=h.assignedSlot||h.parentNode}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,o,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,s),-s),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==Pu.LTR)}}function Nd(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let i=Vh(n.focusNode,n.focusOffset),r=$h(n.focusNode,n.focusOffset),o=i||r;if(r&&i&&r.node!=i.node){let t=Wh.get(r.node);if(!t||t instanceof lu&&t.text!=r.node.nodeValue)o=r;else if(e.docView.lastCompositionAfterCursor){let e=Wh.get(i.node);!e||e instanceof lu&&e.text!=i.node.nodeValue||(o=r)}}if(e.docView.lastCompositionAfterCursor=o!=i,!o)return null;let s=t-o.offset;return{from:s,to:s+o.node.nodeValue.length,node:o.node}}let Pd=class{constructor(){this.changes=[]}compareRange(e,t){Mu(e,t,this.changes)}comparePoint(e,t){Mu(e,t,this.changes)}boundChange(e){Mu(e,e,this.changes)}};function qd(e,t){return t.left>e?t.left-e:Math.max(0,e-t.right)}function Bd(e,t){return t.top>e?t.top-e:Math.max(0,e-t.bottom)}function Ld(e,t){return e.top<t.bottom-1&&e.bottom>t.top+1}function Id(e,t){return t<e.top?{top:t,left:e.left,right:e.right,bottom:e.bottom}:e}function Fd(e,t){return t>e.bottom?{top:e.top,left:e.left,right:e.right,bottom:t}:e}function jd(e,t,n){let i,r,o,s,a,l,c,h,u=!1;for(let d=e.firstChild;d;d=d.nextSibling){let e=Sh(d);for(let p=0;p<e.length;p++){let f=e[p];r&&Ld(r,f)&&(f=Id(Fd(f,r.bottom),r.top));let g=qd(t,f),m=Bd(n,f);if(0==g&&0==m)return 3==d.nodeType?Vd(d,t,n):jd(d,t,n);if(!i||s>m||s==m&&o>g){i=d,r=f,o=g,s=m;let a=m?n<f.top?-1:1:g?t<f.left?-1:1:0;u=!a||(a>0?p<e.length-1:p>0)}0==g?n>f.bottom&&(!c||c.bottom<f.bottom)?(a=d,c=f):n<f.top&&(!h||h.top>f.top)&&(l=d,h=f):c&&Ld(c,f)?c=Fd(c,f.bottom):h&&Ld(h,f)&&(h=Id(h,f.top))}}if(c&&c.bottom>=n?(i=a,r=c):h&&h.top<=n&&(i=l,r=h),!i)return{node:e,offset:0};let d=Math.max(r.left,Math.min(r.right,t));return 3==i.nodeType?Vd(i,d,n):u&&"false"!=i.contentEditable?jd(i,d,n):{node:e,offset:Array.prototype.indexOf.call(e.childNodes,i)+(t>=(r.left+r.right)/2?1:0)}}function Vd(e,t,n){let i=e.nodeValue.length,r=-1,o=1e9,s=0;for(let a=0;a<i;a++){let i=Lh(e,a,a+1).getClientRects();for(let l=0;l<i.length;l++){let c=i[l];if(c.top==c.bottom)continue;s||(s=t-c.left);let h=(c.top>n?c.top-n:n-c.bottom)-1;if(c.left-1<=t&&c.right+1>=t&&h<o){let n=t>=(c.left+c.right)/2,i=n;if(au.chrome||au.gecko){Lh(e,a).getBoundingClientRect().left==c.right&&(i=!n)}if(h<=0)return{node:e,offset:a+(i?1:0)};r=a+(i?1:0),o=h}}}return{node:e,offset:r>-1?r:s>0?e.nodeValue.length:0}}function $d(e,t,n,i=-1){var r,o;let s,a=e.contentDOM.getBoundingClientRect(),l=a.top+e.viewState.paddingTop,{docHeight:c}=e.viewState,{x:h,y:u}=t,d=u-l;if(d<0)return 0;if(d>c)return e.state.doc.length;for(let t=e.viewState.heightOracle.textHeight/2,r=!1;s=e.elementAtHeight(d),s.type!=xu.Text;)for(;d=i>0?s.bottom+t:s.top-t,!(d>=0&&d<=c);){if(r)return n?null:0;r=!0,i=-i}u=l+d;let p=s.from;if(p<e.viewport.from)return 0==e.viewport.from?0:n?null:zd(e,a,s,h,u);if(p>e.viewport.to)return e.viewport.to==e.state.doc.length?e.state.doc.length:n?null:zd(e,a,s,h,u);let f=e.dom.ownerDocument,g=e.root.elementFromPoint?e.root:f,m=g.elementFromPoint(h,u);m&&!e.contentDOM.contains(m)&&(m=null),m||(h=Math.max(a.left+1,Math.min(a.right-1,h)),m=g.elementFromPoint(h,u),m&&!e.contentDOM.contains(m)&&(m=null));let y,v=-1;if(m&&0!=(null===(r=e.docView.nearest(m))||void 0===r?void 0:r.isEditable)){if(f.caretPositionFromPoint){let e=f.caretPositionFromPoint(h,u);e&&({offsetNode:y,offset:v}=e)}else if(f.caretRangeFromPoint){let t=f.caretRangeFromPoint(h,u);t&&(({startContainer:y,startOffset:v}=t),(!e.contentDOM.contains(y)||au.safari&&function(e,t,n){let i;if(3!=e.nodeType||t!=(i=e.nodeValue.length))return!1;for(let t=e.nextSibling;t;t=t.nextSibling)if(1!=t.nodeType||"BR"!=t.nodeName)return!1;return Lh(e,i-1,i).getBoundingClientRect().left>n}(y,v,h)||au.chrome&&function(e,t,n){if(0!=t)return!1;for(let t=e;;){let e=t.parentNode;if(!e||1!=e.nodeType||e.firstChild!=t)return!1;if(e.classList.contains("cm-line"))break;t=e}let i=1==e.nodeType?e.getBoundingClientRect():Lh(e,0,Math.max(e.nodeValue.length,1)).getBoundingClientRect();return n-i.left>5}(y,v,h))&&(y=void 0))}y&&(v=Math.min(Dh(y),v))}if(!y||!e.docView.dom.contains(y)){let t=Au.find(e.docView,p);if(!t)return d>s.top+s.height/2?s.to:s.from;({node:y,offset:v}=jd(t.dom,h,u))}let w=e.docView.nearest(y);if(!w)return null;if(w.isWidget&&1==(null===(o=w.dom)||void 0===o?void 0:o.nodeType)){let e=w.dom.getBoundingClientRect();return t.y<e.top||t.y<=e.bottom&&t.x<=(e.left+e.right)/2?w.posAtStart:w.posAtEnd}return w.localPosFromDOM(y,v)+w.posAtStart}function zd(e,t,n,i,r){let o=Math.round((i-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;o+=Math.floor((r-n.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let s=e.state.sliceDoc(n.from,n.to);return n.from+function(e,t,n,i){for(let i=0,r=0;;){if(r>=t)return i;if(i==e.length)break;r+=9==e.charCodeAt(i)?n-r%n:1,i=Wl(e,i)}return!0===i?-1:e.length}(s,o,e.state.tabSize)}function Hd(e,t,n,i){let r=function(e,t){let n=e.lineBlockAt(t);if(Array.isArray(n.type))for(let e of n.type)if(e.to>t||e.to==t&&(e.to==n.to||e.type==xu.Text))return e;return n}(e,t.head),o=i&&r.type==xu.Text&&(e.lineWrapping||r.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head):null;if(o){let t=e.dom.getBoundingClientRect(),i=e.textDirectionAt(r.from),s=e.posAtCoords({x:n==(i==Pu.LTR)?t.right-1:t.left+1,y:(o.top+o.bottom)/2});if(null!=s)return ic.cursor(s,n?-1:1)}return ic.cursor(n?r.to:r.from,n?-1:1)}function Wd(e,t,n,i){let r=e.state.doc.lineAt(t.head),o=e.bidiSpans(r),s=e.textDirectionAt(r.from);for(let a=t,l=null;;){let t=Ju(r,o,s,a,n),c=Yu;if(!t){if(r.number==(n?e.state.doc.lines:1))return a;c="\n",r=e.state.doc.line(r.number+(n?1:-1)),o=e.bidiSpans(r),t=e.visualLineSide(r,!n)}if(l){if(!l(c))return a}else{if(!i)return t;l=i(c)}a=t}}function Ud(e,t,n){for(;;){let i=0;for(let r of e)r.between(t-1,t+1,((e,r,o)=>{if(t>e&&t<r){let o=i||n||(t-e<r-t?-1:1);t=o<0?e:r,i=o}}));if(!i)return t}}function Gd(e,t,n){let i=Ud(e.state.facet(Sd).map((t=>t(e))),n.from,t.head>n.from?-1:1);return i==n.from?n:ic.cursor(i,i<n.from?1:-1)}const Kd="";class Xd{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(Kc.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Kd}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let i=e;;){this.findPointBefore(n,i);let e=this.text.length;this.readNode(i);let r=i.nextSibling;if(r==t)break;let o=Wh.get(i),s=Wh.get(r);(o&&s?o.breakAfter:(o?o.breakAfter:Mh(i))||Mh(r)&&("BR"!=i.nodeName||i.cmIgnore)&&this.text.length>e)&&this.lineBreak(),i=r}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let r,o=-1,s=1;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(r=i.exec(t))&&(o=r.index,s=r[0].length),this.append(t.slice(n,o<0?t.length:o)),o<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);n=o+s}}readNode(e){if(e.cmIgnore)return;let t=Wh.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Yd(e,n.node,n.offset)?t:0))}}function Yd(e,t,n){for(;;){if(!t||n<Dh(t))return!1;if(t==e)return!0;n=Eh(t)+1,t=t.parentNode}}class Jd{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class Qd{constructor(e,t,n,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let t=r||o?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:o}=e.observer.selectionRange;n&&(t.push(new Jd(n,i)),r==n&&o==i||t.push(new Jd(r,o)));return t}(e),n=new Xd(t,e.state);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,i=2==e.length?e[1].pos:n;return n>-1&&i>-1?ic.single(n+t,i+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=r&&r.node==t.focusNode&&r.offset==t.focusOffset||!kh(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),i=o&&o.node==t.anchorNode&&o.offset==t.anchorOffset||!kh(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((au.ios||au.chrome)&&e.state.selection.main.empty&&n!=i&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,i),r=Math.max(n,i),o=s.from-t,a=s.to-r;0!=o&&1!=o&&0!=t||0!=a&&-1!=a&&r!=e.state.doc.length||(n=0,i=e.state.doc.length)}this.newSel=ic.single(i,n)}}}function Zd(e,t){let n,{newSel:i}=t,r=e.state.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:i,to:s}=t.bounds,a=r.from,l=null;(8===o||au.android&&t.text.length<s-i)&&(a=r.to,l="end");let c=function(e,t,n,i){let r=Math.min(e.length,t.length),o=0;for(;o<r&&e.charCodeAt(o)==t.charCodeAt(o);)o++;if(o==r&&e.length==t.length)return null;let s=e.length,a=t.length;for(;s>0&&a>0&&e.charCodeAt(s-1)==t.charCodeAt(a-1);)s--,a--;if("end"==i){n-=s+Math.max(0,o-Math.min(s,a))-o}if(s<o&&e.length<t.length){o-=n<=o&&n>=s?o-n:0,a=o+(a-s),s=o}else if(a<o){o-=n<=o&&n>=a?o-n:0,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}(e.state.doc.sliceString(i,s,Kd),t.text,a-i,l);c&&(au.chrome&&13==o&&c.toB==c.from+2&&t.text.slice(c.from,c.toB)==Kd+Kd&&c.toB--,n={from:i+c.from,to:i+c.toA,insert:ql.of(t.text.slice(c.from,c.toB).split(Kd))})}else i&&(!e.hasFocus&&e.state.facet(gd)||i.main.eq(r))&&(i=null);if(!n&&!i)return!1;if(!n&&t.typeOver&&!r.empty&&i&&i.main.empty?n={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,r.to)}:(au.mac||au.android)&&n&&n.from==n.to&&n.from==r.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(i&&2==n.insert.length&&(i=ic.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:ql.of([n.insert.toString().replace("."," ")])}):n&&n.from>=r.from&&n.to<=r.to&&(n.from!=r.from||n.to!=r.to)&&r.to-r.from-(n.to-n.from)<=4?n={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,n.from).append(n.insert).append(e.state.doc.slice(n.to,r.to))}:au.chrome&&n&&n.from==n.to&&n.from==r.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(i&&(i=ic.single(i.main.anchor-1,i.main.head-1)),n={from:r.from,to:r.to,insert:ql.of([" "])}),n)return ep(e,n,i,o);if(i&&!i.main.eq(r)){let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),n=e.inputState.lastSelectionOrigin),e.dispatch({selection:i,scrollIntoView:t,userEvent:n}),!0}return!1}function ep(e,t,n,i=-1){if(au.ios&&e.inputState.flushIOSKey(t))return!0;let r=e.state.selection.main;if(au.android&&(t.to==r.to&&(t.from==r.from||t.from==r.from-1&&" "==e.state.sliceDoc(t.from,r.from))&&1==t.insert.length&&2==t.insert.lines&&Ih(e.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&0==t.insert.length||8==i&&t.insert.length<t.to-t.from&&t.to>r.head)&&Ih(e.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&0==t.insert.length&&Ih(e.contentDOM,"Delete",46)))return!0;let o,s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>o||(o=function(e,t,n){let i,r=e.state,o=r.selection.main;if(t.from>=o.from&&t.to<=o.to&&t.to-t.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=o.from<t.from?r.sliceDoc(o.from,t.from):"",s=o.to>t.to?r.sliceDoc(t.to,o.to):"";i=r.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+s))}else{let s=r.changes(t),a=n&&n.main.to<=s.newLength?n.main:void 0;if(r.selection.ranges.length>1&&e.inputState.composing>=0&&t.to<=o.to&&t.to>=o.to-10){let l,c=e.state.sliceDoc(t.from,t.to),h=n&&Nd(e,n.main.head);if(h){let e=t.insert.length-(t.to-t.from);l={from:h.from,to:h.to-e}}else l=e.state.doc.lineAt(o.head);let u=o.to-t.to,d=o.to-o.from;i=r.changeByRange((n=>{if(n.from==o.from&&n.to==o.to)return{changes:s,range:a||n.map(s)};let i=n.to-u,h=i-c.length;if(n.to-n.from!=d||e.state.sliceDoc(h,i)!=c||n.to>=l.from&&n.from<=l.to)return{range:n};let p=r.changes({from:h,to:i,insert:t.insert}),f=n.to-o.to;return{changes:p,range:a?ic.range(Math.max(0,a.anchor+f),Math.max(0,a.head+f)):n.map(p)}}))}else i={changes:s,selection:a&&r.selection.replaceRange(a)}}let s="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=".compose",e.inputState.compositionFirstChange&&(s+=".start",e.inputState.compositionFirstChange=!1));return r.update(i,{userEvent:s,scrollIntoView:!0})}(e,t,n));return e.state.facet(rd).some((n=>n(e,t.from,t.to,s,a)))||e.dispatch(a()),!0}class tp{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,au.safari&&e.contentDOM.addEventListener("input",(()=>null)),au.gecko&&function(e){Ap.has(e)||(Ap.add(e),e.addEventListener("copy",(()=>{})),e.addEventListener("cut",(()=>{})))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n,i=t.target;i!=e.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(n=Wh.get(i))&&n.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=ip(e),n=this.handlers,i=this.view.contentDOM;for(let e in t)if("scroll"!=e){let r=!t[e].handlers.length,o=n[e];o&&r!=!o.handlers.length&&(i.removeEventListener(e,this.handleEvent),o=null),o||i.addEventListener(e,this.handleEvent,{passive:r})}for(let e in n)"scroll"==e||t[e]||i.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&sp.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),au.android&&au.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!au.ios||e.synthetic||e.altKey||e.metaKey||!((t=rp.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||op.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,Ih(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0)))}ignoreDuringComposition(e){return!!/^key/.test(e.type)&&(this.composing>0||!!(au.safari&&!au.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function np(e,t){return(n,i)=>{try{return t.call(e,i,n)}catch(e){fd(n.state,e)}}}function ip(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec;if(e&&e.domEventHandlers)for(let i in e.domEventHandlers){let r=e.domEventHandlers[i];r&&n(i).handlers.push(np(t.value,r))}if(e&&e.domEventObservers)for(let i in e.domEventObservers){let r=e.domEventObservers[i];r&&n(i).observers.push(np(t.value,r))}}for(let e in cp)n(e).handlers.push(cp[e]);for(let e in hp)n(e).observers.push(hp[e]);return t}const rp=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],op="dthko",sp=[16,17,18,20,91,92,224,225];function ap(e){return.7*Math.max(0,e)+8}class lp{constructor(e,t,n,i){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t,n,i=e.ownerDocument;for(let r=e.parentNode;r&&!(r==i.body||t&&n);)if(1==r.nodeType)!n&&r.scrollHeight>r.clientHeight&&(n=r),!t&&r.scrollWidth>r.clientWidth&&(t=r),r=r.assignedSlot||r.parentNode;else{if(11!=r.nodeType)break;r=r.host}return{x:t,y:n}}(e.contentDOM),this.atoms=e.state.facet(Sd).map((t=>t(e)));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Kc.allowMultipleSelections)&&function(e,t){let n=e.state.facet(Zu);return n.length?n[0](t):au.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let i=xh(e.root);if(!i||0==i.rangeCount)return!0;let r=i.getRangeAt(0).getClientRects();for(let e=0;e<r.length;e++){let n=r[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)||1!=kp(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(t=this.startEvent,n=e,Math.max(Math.abs(t.clientX-n.clientX),Math.abs(t.clientY-n.clientY))<10))return;var t,n;this.select(this.lastEvent=e);let i=0,r=0,o=0,s=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=Ad(this.view);e.clientX-c.left<=o+6?i=-ap(o-e.clientX):e.clientX+c.right>=a-6&&(i=ap(e.clientX-a)),e.clientY-c.top<=s+6?r=-ap(s-e.clientY):e.clientY+c.bottom>=l-6&&(r=ap(e.clientY-l)),this.setScrollSpeed(i,r)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;n<e.ranges.length;n++){let i=e.ranges[n],r=null;if(i.empty){let e=Ud(this.atoms,i.from,0);e!=i.from&&(r=ic.cursor(e,-1))}else{let e=Ud(this.atoms,i.from,-1),t=Ud(this.atoms,i.to,1);e==i.from&&t==i.to||(r=ic.range(i.from==i.anchor?e:t,i.from==i.head?e:t))}r&&(t||(t=e.ranges.slice()),t[n]=r)}return t?ic.create(t,e.mainIndex):e}select(e){let{view:t}=this,n=this.skipAtoms(this.style.get(e,this.extend,this.multiple));!this.mustSelect&&n.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some((e=>e.isUserEvent("input.type")))?this.destroy():this.style.update(e)&&setTimeout((()=>this.select(this.lastEvent)),20)}}const cp=Object.create(null),hp=Object.create(null),up=au.ie&&au.ie_version<15||au.ios&&au.webkit_version<604;function dp(e,t,n){for(let i of e.facet(t))n=i(n,e);return n}function pp(e,t){t=dp(e.state,sd,t);let n,{state:i}=e,r=1,o=i.toText(t),s=o.lines==i.selection.ranges.length;if(null!=Sp&&i.selection.ranges.every((e=>e.empty))&&Sp==o.toString()){let e=-1;n=i.changeByRange((n=>{let a=i.doc.lineAt(n.from);if(a.from==e)return{range:n};e=a.from;let l=i.toText((s?o.line(r++).text:t)+i.lineBreak);return{changes:{from:a.from,insert:l},range:ic.cursor(n.from+l.length)}}))}else n=s?i.changeByRange((e=>{let t=o.line(r++);return{changes:{from:e.from,to:e.to,insert:t.text},range:ic.cursor(e.from+t.length)}})):i.replaceSelection(o);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function fp(e,t,n,i){if(1==i)return ic.cursor(t,n);if(2==i)return function(e,t,n=1){let i=e.charCategorizer(t),r=e.doc.lineAt(t),o=t-r.from;if(0==r.length)return ic.cursor(t);0==o?n=1:o==r.length&&(n=-1);let s=o,a=o;n<0?s=Wl(r.text,o,!1):a=Wl(r.text,o);let l=i(r.text.slice(s,a));for(;s>0;){let e=Wl(r.text,s,!1);if(i(r.text.slice(e,s))!=l)break;s=e}for(;a<r.length;){let e=Wl(r.text,a);if(i(r.text.slice(a,e))!=l)break;a=e}return ic.range(s+r.from,a+r.from)}(e.state,t,n);{let n=Au.find(e.docView,t),i=e.state.doc.lineAt(n?n.posAtEnd:t),r=n?n.posAtStart:i.from,o=n?n.posAtEnd:i.to;return o<e.state.doc.length&&o==i.to&&o++,ic.range(r,o)}}hp.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},cp.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),hp.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},hp.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},cp.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of e.state.facet(td))if(n=i(e,t),n)break;if(n||0!=t.button||(n=function(e,t){let n=yp(e,t),i=kp(t),r=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),r=r.map(e.changes))},get(t,o,s){let a,l=yp(e,t),c=fp(e,l.pos,l.bias,i);if(n.pos!=l.pos&&!o){let t=fp(e,n.pos,n.bias,i),r=Math.min(t.from,c.from),o=Math.max(t.to,c.to);c=r<c.from?ic.range(r,o):ic.range(o,r)}return o?r.replaceRange(r.main.extend(c.from,c.to)):s&&1==i&&r.ranges.length>1&&(a=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:i,to:r}=e.ranges[n];if(i<=t&&r>=t)return ic.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(r,l.pos))?a:s?r.addRange(c):ic.create([c])}}}(e,t)),n){let i=!e.hasFocus;e.inputState.startMouseSelection(new lp(e,t,n,i)),i&&e.observer.ignore((()=>{Bh(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()}));let r=e.inputState.mouseSelection;if(r)return r.start(t),!1===r.dragging}return!1};let gp=(e,t,n)=>t>=n.top&&t<=n.bottom&&e>=n.left&&e<=n.right;function mp(e,t,n,i){let r=Au.find(e.docView,t);if(!r)return 1;let o=t-r.posAtStart;if(0==o)return 1;if(o==r.length)return-1;let s=r.coordsAt(o,-1);if(s&&gp(n,i,s))return-1;let a=r.coordsAt(o,1);return a&&gp(n,i,a)?1:s&&s.bottom>=i?-1:1}function yp(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1);return{pos:n,bias:mp(e,n,t.clientX,t.clientY)}}const vp=au.ie&&au.ie_version<=11;let wp=null,bp=0,xp=0;function kp(e){if(!vp)return e.detail;let t=wp,n=xp;return wp=e,xp=Date.now(),bp=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(bp+1)%3:1}function _p(e,t,n,i){if(!(n=dp(e.state,sd,n)))return;let r=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,s=i&&o&&function(e,t){let n=e.state.facet(ed);return n.length?n[0](t):au.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:o.from,to:o.to}:null,a={from:r,insert:n},l=e.state.changes(s?[s,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}cp.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let i=e.docView.nearest(t.target);if(i&&i.isWidget){let e=i.posAtStart,t=e+i.length;(e>=n.to||t<=n.from)&&(n=ic.range(e,t))}}let{inputState:i}=e;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",dp(e.state,ad,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},cp.dragend=e=>(e.inputState.draggedContent=null,!1),cp.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,o=()=>{++r==n.length&&_p(e,t,i.filter((e=>null!=e)).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=o,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(i[e]=t.result),o()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return _p(e,t,n,!0),!0}return!1},cp.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=up?null:t.clipboardData;return n?(pp(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout((()=>{e.focus(),n.remove(),pp(e,n.value)}),50)}(e),!1)};let Sp=null;cp.copy=cp.cut=(e,t)=>{let{text:n,ranges:i,linewise:r}=function(e){let t=[],n=[],i=!1;for(let i of e.selection.ranges)i.empty||(t.push(e.sliceDoc(i.from,i.to)),n.push(i));if(!t.length){let r=-1;for(let{from:i}of e.selection.ranges){let o=e.doc.lineAt(i);o.number>r&&(t.push(o.text),n.push({from:o.from,to:Math.min(e.doc.length,o.to+1)})),r=o.number}i=!0}return{text:dp(e,ad,t.join(e.lineBreak)),ranges:n,linewise:i}}(e.state);if(!n&&!r)return!1;Sp=r?n:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let o=up?null:t.clipboardData;return o?(o.clearData(),o.setData("text/plain",n),!0):(function(e,t){let n=e.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout((()=>{i.remove(),e.focus()}),50)}(e,n),!1)};const Cp=Nc.define();function Ep(e,t){let n=[];for(let i of e.facet(od)){let r=i(e,t);r&&n.push(r)}return n?e.update({effects:n,annotations:Cp.of(!0)}):null}function Mp(e){setTimeout((()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=Ep(e.state,t);n?e.dispatch(n):e.update([])}}),10)}hp.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),Mp(e)},hp.blur=e=>{e.observer.clearSelectionRange(),Mp(e)},hp.compositionstart=hp.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},hp.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,au.chrome&&au.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then((()=>e.observer.flush())):setTimeout((()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])}),50))},hp.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},cp.beforeinput=(e,t)=>{var n,i;if("insertReplacementText"==t.inputType&&e.observer.editContext){let i=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/plain"),r=t.getTargetRanges();if(i&&r.length){let t=r[0],n=e.posAtDOM(t.startContainer,t.startOffset),o=e.posAtDOM(t.endContainer,t.endOffset);return ep(e,{from:n,to:o,insert:e.state.toText(i)},null),!0}}let r;if(au.chrome&&au.android&&(r=rp.find((e=>e.inputType==t.inputType)))&&(e.observer.delayAndroidKey(r.key,r.keyCode),"Backspace"==r.key||"Delete"==r.key)){let t=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var n;((null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())}),100)}return au.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),au.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout((()=>hp.compositionend(e,t)),20),!1};const Ap=new Set;const Dp=["pre-wrap","normal","pre-line","break-spaces"];let Rp=!1;function Op(){Rp=!1}class Tp{constructor(e){this.lineWrapping=e,this.doc=ql.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Dp.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let i=e[n];i<0?n++:this.heightSamples[Math.floor(10*i)]||(t=!0,this.heightSamples[Math.floor(10*i)]=!0)}return t}refresh(e,t,n,i,r,o){let s=Dp.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=s;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=n,this.textHeight=i,this.lineLength=r,a){this.heightSamples={};for(let e=0;e<o.length;e++){let t=o[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return a}}class Np{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Pp{constructor(e,t,n,i,r){this.from=e,this.length=t,this.top=n,this.height=i,this._content=r}get type(){return"number"==typeof this._content?xu.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Cu?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Pp(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var qp=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(qp||(qp={}));const Bp=.001;class Lp{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Bp&&(Rp=!0),this.height=e)}replace(e,t,n){return Lp.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,i){let r=this,o=n.doc;for(let s=i.length-1;s>=0;s--){let{fromA:a,toA:l,fromB:c,toB:h}=i[s],u=r.lineAt(a,qp.ByPosNoHeight,n.setDoc(t),0,0),d=u.to>=l?u:r.lineAt(l,qp.ByPosNoHeight,n,0,0);for(h+=d.to-l,l=d.to;s>0&&u.from<=i[s-1].toA;)a=i[s-1].fromA,c=i[s-1].fromB,s--,a<u.from&&(u=r.lineAt(a,qp.ByPosNoHeight,n,0,0));c+=u.from-a,a=u.from;let p=Hp.build(n.setDoc(o),e,c,h);r=Ip(r,r.replace(a,l,p))}return r.updateHeight(n,0)}static empty(){return new jp(0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,i=0,r=0;for(;;)if(t==n)if(i>2*r){let r=e[t-1];r.break?e.splice(--t,1,r.left,null,r.right):e.splice(--t,1,r.left,r.right),n+=1+r.break,i-=r.size}else{if(!(r>2*i))break;{let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,r-=t.size}}else if(i<r){let n=e[t++];n&&(i+=n.size)}else{let t=e[--n];t&&(r+=t.size)}let o=0;return null==e[t-1]?(o=1,t--):null==e[t]&&(o=1,n++),new $p(Lp.of(e.slice(0,t)),o,Lp.of(e.slice(n)))}}function Ip(e,t){return e==t?e:(e.constructor!=t.constructor&&(Rp=!0),t)}Lp.prototype.size=1;class Fp extends Lp{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,i){return new Pp(i,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,i,r){return this.blockAt(0,n,i,r)}forEachLine(e,t,n,i,r,o){e<=r+this.length&&t>=r&&o(this.blockAt(0,n,i,r))}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more&&this.setHeight(i.heights[i.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class jp extends Fp{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,i){return new Pp(i,this.length,n,this.height,this.breaks)}replace(e,t,n){let i=n[0];return 1==n.length&&(i instanceof jp||i instanceof Vp&&4&i.flags)&&Math.abs(this.length-i.length)<10?(i instanceof Vp?i=new jp(i.length,this.height):i.height=this.height,this.outdated||(i.outdated=!1),i):Lp.of(n)}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more?this.setHeight(i.heights[i.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Vp extends Lp{constructor(e){super(e,0)}heightMetrics(e,t){let n,i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,o=r-i+1,s=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*o);n=t/o,this.length>o+1&&(s=(this.height-t)/(this.length-o-1))}else n=this.height/o;return{firstLine:i,lastLine:r,perLine:n,perChar:s}}blockAt(e,t,n,i){let{firstLine:r,lastLine:o,perLine:s,perChar:a}=this.heightMetrics(t,i);if(t.lineWrapping){let r=i+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),o=t.doc.lineAt(r),l=s+o.length*a,c=Math.max(n,e-l/2);return new Pp(o.from,o.length,c,l,0)}{let i=Math.max(0,Math.min(o-r,Math.floor((e-n)/s))),{from:a,length:l}=t.doc.line(r+i);return new Pp(a,l,n+s*i,s,0)}}lineAt(e,t,n,i,r){if(t==qp.ByHeight)return this.blockAt(e,n,i,r);if(t==qp.ByPosNoHeight){let{from:t,to:i}=n.doc.lineAt(e);return new Pp(t,i-t,0,0,0)}let{firstLine:o,perLine:s,perChar:a}=this.heightMetrics(n,r),l=n.doc.lineAt(e),c=s+l.length*a,h=l.number-o,u=i+s*h+a*(l.from-r-h);return new Pp(l.from,l.length,Math.max(i,Math.min(u,i+this.height-c)),c,0)}forEachLine(e,t,n,i,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(n,r);for(let c=e,h=i;c<=t;){let t=n.doc.lineAt(c);if(c==e){let n=t.number-s;h+=a*n+l*(e-r-n)}let i=a+l*t.length;o(new Pp(t.from,t.length,h,i,0)),h+=i,c=t.to+1}}replace(e,t,n){let i=this.length-t;if(i>0){let e=n[n.length-1];e instanceof Vp?n[n.length-1]=new Vp(e.length+i):n.push(null,new Vp(i-1))}if(e>0){let t=n[0];t instanceof Vp?n[0]=new Vp(e+t.length):n.unshift(new Vp(e-1),null)}return Lp.of(n)}decomposeLeft(e,t){t.push(new Vp(e-1),null)}decomposeRight(e,t){t.push(null,new Vp(this.length-e-1))}updateHeight(e,t=0,n=!1,i){let r=t+this.length;if(i&&i.from<=t+this.length&&i.more){let n=[],o=Math.max(t,i.from),s=-1;for(i.from>t&&n.push(new Vp(i.from-t-1).updateHeight(e,t));o<=r&&i.more;){let t=e.doc.lineAt(o).length;n.length&&n.push(null);let r=i.heights[i.index++];-1==s?s=r:Math.abs(r-s)>=Bp&&(s=-2);let a=new jp(t,r);a.outdated=!1,n.push(a),o+=t+1}o<=r&&n.push(null,new Vp(r-o).updateHeight(e,o));let a=Lp.of(n);return(s<0||Math.abs(a.height-this.height)>=Bp||Math.abs(s-this.heightMetrics(e,t).perLine)>=Bp)&&(Rp=!0),Ip(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class $p extends Lp{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return 1&this.flags}blockAt(e,t,n,i){let r=n+this.left.height;return e<r?this.left.blockAt(e,t,n,i):this.right.blockAt(e,t,r,i+this.left.length+this.break)}lineAt(e,t,n,i,r){let o=i+this.left.height,s=r+this.left.length+this.break,a=t==qp.ByHeight?e<o:e<s,l=a?this.left.lineAt(e,t,n,i,r):this.right.lineAt(e,t,n,o,s);if(this.break||(a?l.to<s:l.from>s))return l;let c=t==qp.ByPosNoHeight?qp.ByPosNoHeight:qp.ByPos;return a?l.join(this.right.lineAt(s,c,n,o,s)):this.left.lineAt(s,c,n,i,r).join(l)}forEachLine(e,t,n,i,r,o){let s=i+this.left.height,a=r+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,i,r,o),t>=a&&this.right.forEachLine(e,t,n,s,a,o);else{let l=this.lineAt(a,qp.ByPos,n,i,r);e<l.from&&this.left.forEachLine(e,l.from-1,n,i,r,o),l.to>=e&&l.from<=t&&o(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,s,a,o)}}replace(e,t,n){let i=this.left.length+this.break;if(t<i)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,n));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let e of n)r.push(e);if(e>0&&zp(r,o-1),t<this.length){let e=r.length;this.decomposeRight(t,r),zp(r,e)}return Lp.of(r)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,i=n+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<i&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Lp.of(this.break?[e,null,t]:[e,t]):(this.left=Ip(this.left,e),this.right=Ip(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,i){let{left:r,right:o}=this,s=t+r.length+this.break,a=null;return i&&i.from<=t+r.length&&i.more?a=r=r.updateHeight(e,t,n,i):r.updateHeight(e,t,n),i&&i.from<=s+o.length&&i.more?a=o=o.updateHeight(e,s,n,i):o.updateHeight(e,s,n),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function zp(e,t){let n,i;null==e[t]&&(n=e[t-1])instanceof Vp&&(i=e[t+1])instanceof Vp&&e.splice(t-1,3,new Vp(n.length+1+i.length))}class Hp{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof jp?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new jp(e-this.pos,-1)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let i=n.widget?n.widget.estimatedHeight:0,r=n.widget?n.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new Fp(o,i,n)):(o||r||i>=5)&&this.addLineDeco(i,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new jp(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new Vp(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof jp)return e;let t=new jp(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let i=this.ensureLine();i.length+=n,i.collapsed+=n,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof jp||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new jp(0,-1));let n=e;for(let e of this.nodes)e instanceof jp&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,i){let r=new Hp(n,e);return Zc.spans(t,n,i,r,0),r.finish(n)}}class Wp{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,i){(e<t||n&&n.heightRelevant||i&&i.heightRelevant)&&Mu(e,t,this.changes,5)}}function Up(e,t){let n=e.getBoundingClientRect(),i=e.ownerDocument,r=i.defaultView||window,o=Math.max(0,n.left),s=Math.min(r.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(r.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=i.body;)if(1==t.nodeType){let n=t,i=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=i.overflow){let i=n.getBoundingClientRect();o=Math.max(o,i.left),s=Math.min(s,i.right),a=Math.max(a,i.top),l=Math.min(t==e.parentNode?r.innerHeight:l,i.bottom)}t="absolute"==i.position||"fixed"==i.position?n.offsetParent:n.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:o-n.left,right:Math.max(o,s)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function Gp(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class Kp{constructor(e,t,n,i){this.from=e,this.to=t,this.size=n,this.displaySize=i}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],r=t[n];if(i.from!=r.from||i.to!=r.to||i.size!=r.size)return!1}return!0}draw(e,t){return ku.replace({widget:new Xp(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Xp extends bu{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Yp{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=ef,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Pu.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(xd).some((e=>"function"!=typeof e&&"cm-lineWrapping"==e.class));this.heightOracle=new Tp(t),this.stateDeco=e.facet(kd).filter((e=>"function"!=typeof e)),this.heightMap=Lp.empty().applyChanges(this.stateDeco,ql.empty,this.heightOracle.setDoc(e.doc),[new Rd(0,0,0,e.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ku.set(this.lineGaps.map((e=>e.draw(this,!1)))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let i=n?t.head:t.anchor;if(!e.some((({from:e,to:t})=>i>=e&&i<=t))){let{from:t,to:n}=this.lineBlockAt(i);e.push(new Jp(t,n))}}return this.viewports=e.sort(((e,t)=>e.from-t.from)),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?ef:new tf(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(nf(e,this.scaler))}))}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(kd).filter((e=>"function"!=typeof e));let i=e.changedRanges,r=Rd.extendWithRanges(i,function(e,t,n){let i=new Wp;return Zc.compare(e,t,n,i,0),i.changes}(n,this.stateDeco,e?e.changes:Xl.empty(this.state.doc.length))),o=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Op(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||Rp)&&(e.flags|=2),s?(this.scrollAnchorPos=e.changes.mapPos(s.from,-1),this.scrollAnchorHeight=s.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(cd)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),i=this.heightOracle,r=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?Pu.RTL:Pu.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),s=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=s.height;this.contentDOMHeight=s.height,this.mustMeasureContent=!1;let l=0,c=0;if(s.width&&s.height){let{scaleX:e,scaleY:n}=Th(t,s);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,l|=16,o=a=!0)}let h=(parseInt(n.paddingTop)||0)*this.scaleY,u=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==h&&this.paddingBottom==u||(this.paddingTop=h,this.paddingBottom=u,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=jh(e.scrollDOM);let p=(this.printing?Gp:Up)(t,this.paddingTop),f=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}(e.dom))return 0;let y=s.width;if(this.contentDOMWidth==y&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(t)&&(o=!0),o||i.lineWrapping&&Math.abs(y-this.contentDOMWidth)>i.charWidth){let{lineHeight:n,charWidth:s,textHeight:a}=e.docView.measureTextSize();o=n>0&&i.refresh(r,n,s,a,y/s,t),o&&(e.docView.minWidth=0,l|=16)}f>0&&g>0?c=Math.max(f,g):f<0&&g<0&&(c=Math.min(f,g)),Op();for(let n of this.viewports){let r=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(o?Lp.empty().applyChanges(this.stateDeco,ql.empty,this.heightOracle,[new Rd(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new Np(n.from,r))}Rp&&(l|=2)}let v=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:s}=this,a=new Jp(i.lineAt(o-1e3*n,qp.ByHeight,r,0,0).from,i.lineAt(s+1e3*(1-n),qp.ByHeight,r,0,0).to);if(t){let{head:e}=t.range;if(e<a.from||e>a.to){let n,o=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=i.lineAt(e,qp.ByPos,r,0,0);n="center"==t.y?(s.top+s.bottom)/2-o/2:"start"==t.y||"nearest"==t.y&&e<a.from?s.top:s.bottom-o,a=new Jp(i.lineAt(n-500,qp.ByHeight,r,0,0).from,i.lineAt(n+o+500,qp.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),i=t.mapPos(e.to,1);return new Jp(this.heightMap.lineAt(n,qp.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,qp.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:i}=this.heightMap.lineAt(e,qp.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,qp.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:s}=this;return(0==e||i<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||r>=s+Math.max(10,Math.min(n,250)))&&i>o-2e3&&r<s+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let i of e)t.touchesRange(i.from,i.to)||n.push(new Kp(t.mapPos(i.from),t.mapPos(i.to),i.size,i.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,i=n?1e4:2e3,r=i>>1,o=i<<1;if(this.defaultTextDirection!=Pu.LTR&&!n)return[];let s=[],a=(i,o,l,c)=>{if(o-i<r)return;let h=this.state.selection.main,u=[h.from];h.empty||u.push(h.to);for(let e of u)if(e>i&&e<o)return a(i,e-10,l,c),void a(e+10,o,l,c);let d=function(e,t){for(let n of e)if(t(n))return n;return}(e,(e=>e.from>=l.from&&e.to<=l.to&&Math.abs(e.from-i)<r&&Math.abs(e.to-o)<r&&!u.some((t=>e.from<t&&e.to>t))));if(!d){if(o<l.to&&t&&n&&t.visibleRanges.some((e=>e.from<=o&&e.to>=o))){let e=t.moveToLineBoundary(ic.cursor(o),!1,!0).head;e>i&&(o=e)}let e=this.gapSize(l,i,o,c);d=new Kp(i,o,e,n||e<2e6?e:2e6)}s.push(d)},l=t=>{if(t.length<o||t.type!=xu.Text)return;let r=function(e,t,n){let i=[],r=e,o=0;Zc.spans(n,e,t,{span(){},point(e,t){e>r&&(i.push({from:r,to:e}),o+=e-r),r=t}},20),r<t&&(i.push({from:r,to:t}),o+=t-r);return{total:o,ranges:i}}(t.from,t.to,this.stateDeco);if(r.total<o)return;let s,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,o=i/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let i=Zp(r,c),s=((this.visibleBottom-this.visibleTop)/2+o)/t.height;e=i-s,n=i+s}else e=(this.visibleTop-t.top-o)/t.height,n=(this.visibleBottom-t.top+o)/t.height;s=Qp(r,e),l=Qp(r,n)}else{let n=r.total*this.heightOracle.charWidth,o=i*this.heightOracle.charWidth,a=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=n.size-n.displaySize);let h,u,d=this.pixelViewport.left+a,p=this.pixelViewport.right+a;if(null!=c){let e=Zp(r,c),t=((p-d)/2+o)/n;h=e-t,u=e+t}else h=(d-o)/n,u=(p+o)/n;s=Qp(r,h),l=Qp(r,u)}s>t.from&&a(t.from,s,t,r),l<t.to&&a(l,t.to,t,r)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(l):l(e);return s}gapSize(e,t,n,i){let r=Zp(i,n)-Zp(i,t);return this.heightOracle.lineWrapping?e.height*r:i.total*this.heightOracle.charWidth*r}updateLineGaps(e){Kp.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=ku.set(e.map((e=>e.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];Zc.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let i=0;if(n.length!=this.visibleRanges.length)i=12;else for(let t=0;t<n.length&&!(8&i);t++){let r=this.visibleRanges[t],o=n[t];r.from==o.from&&r.to==o.to||(i|=4,e&&e.mapPos(r.from,-1)==o.from&&e.mapPos(r.to,1)==o.to||(i|=8))}return this.visibleRanges=n,i}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find((t=>t.from<=e&&t.to>=e))||nf(this.heightMap.lineAt(e,qp.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))||nf(this.heightMap.lineAt(this.scaler.fromDOM(e),qp.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return nf(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Jp{constructor(e,t){this.from=e,this.to=t}}function Qp({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let i=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:r}=t[e],o=r-n;if(i<=o)return n+i;i-=o}}function Zp(e,t){let n=0;for(let{from:i,to:r}of e.ranges){if(t<=r){n+=t-i;break}n+=r-i}return n/e.total}const ef={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};class tf{constructor(e,t,n){let i=0,r=0,o=0;this.viewports=n.map((({from:n,to:r})=>{let o=t.lineAt(n,qp.ByPos,e,0,0).top,s=t.lineAt(r,qp.ByPos,e,0,0).bottom;return i+=s-o,{from:n,to:r,top:o,bottom:s,domTop:0,domBottom:0}})),this.scale=(7e6-i)/(t.height-i);for(let e of this.viewports)e.domTop=o+(e.top-r)*this.scale,o=e.domBottom=e.domTop+(e.bottom-e.top),r=e.bottom}toDOM(e){for(let t=0,n=0,i=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return i+(e-n)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);n=r.bottom,i=r.domBottom}}fromDOM(e){for(let t=0,n=0,i=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return n+(e-i)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);n=r.bottom,i=r.domBottom}}eq(e){return e instanceof tf&&(this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every(((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to)))}}function nf(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),i=t.toDOM(e.bottom);return new Pp(e.from,e.length,n,i-n,Array.isArray(e._content)?e._content.map((e=>nf(e,t))):e._content)}const rf=sc.define({combine:e=>e.join(" ")}),of=sc.define({combine:e=>e.indexOf(!0)>-1}),sf=fh.newName(),af=fh.newName(),lf=fh.newName(),cf={"&light":"."+af,"&dark":"."+lf};function hf(e,t,n){return new fh(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,(t=>{if("&"==t)return e;if(!n||!n[t])throw new RangeError(`Unsupported selector: ${t}`);return n[t]})):e+" "+t})}const uf=hf("."+sf,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&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-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"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},cf),df={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},pf=au.ie&&au.ie_version<=11;class ff{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Nh,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver((t=>{for(let e of t)this.queue.push(e);(au.ie&&au.ie_version<=11||au.ios&&e.composing)&&t.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),!window.EditContext||!1===e.constructor.EDIT_CONTEXT||au.chrome&&au.chrome_version<126||(this.editContext=new yf(e),e.state.facet(gd)&&(e.contentDOM.editContext=this.editContext.editContext)),pf&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(e){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some(((t,n)=>t!=e[n])))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,i=this.selectionRange;if(n.state.facet(gd)?n.root.activeElement!=this.dom:!_h(this.dom,i))return;let r=i.anchorNode&&n.docView.nearest(i.anchorNode);r&&r.ignoreEvent(e)?t||(this.selectionChanged=!1):(au.ie&&au.ie_version<=11||au.android&&au.chrome)&&!n.state.selection.main.empty&&i.focusNode&&Ch(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=xh(e.root);if(!t)return!1;let n=au.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return mf(e,n)}let n=null;function i(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",i,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",i,!0),n?mf(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let i=_h(this.dom,n);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,i=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=i)return!1;for(i=Math.min(i,Dh(n));;)if(i){if(1!=n.nodeType)return!1;let e=n.childNodes[i-1];"false"==e.contentEditable?i--:(n=e,i=Dh(n))}else{if(n==e)return!0;i=Eh(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(1==n.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,df),pf&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),pf&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;if(e){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&Ih(this.dom,e.key,e.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(n=this.delayedAndroidKey)||void 0===n?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,i=!1;for(let r of e){let e=this.readMutation(r);e&&(e.typeOver&&(i=!0),-1==t?({from:t,to:n}=e):(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:i}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),i=this.selectionChanged&&_h(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new Qd(this.view,e,t,n);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,i=Zd(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty("attributes"==e.type),"attributes"==e.type&&(t.flags|=4),"childList"==e.type){let n=gf(t,e.previousSibling||e.target.previousSibling,-1),i=gf(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(gd)!=e.state.facet(gd)&&(e.view.contentDOM.editContext=e.state.facet(gd)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(n=this.resizeScroll)||void 0===n||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gf(e,t,n){for(;t;){let i=Wh.get(t);if(i&&i.parent==e)return i;let r=t.parentNode;t=r!=e.dom?r:n>0?t.nextSibling:t.previousSibling}return null}function mf(e,t){let n=t.startContainer,i=t.startOffset,r=t.endContainer,o=t.endOffset,s=e.docView.domAtPos(e.state.selection.main.anchor);return Ch(s.node,s.offset,r,o)&&([n,i,r,o]=[r,o,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:o}}class yf{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=t=>{let n=e.state.selection.main,{anchor:i,head:r}=n,o=this.toEditorPos(t.updateRangeStart),s=this.toEditorPos(t.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:t.updateRangeStart,editorBase:o,drifted:!1});let a={from:o,to:s,insert:ql.of(t.text.split("\n"))};if(a.from==this.from&&i<this.from?a.from=i:a.to==this.to&&i>this.to&&(a.to=i),a.from!=a.to||a.insert.length){if((au.mac||au.android)&&a.from==r-1&&/^\. ?$/.test(t.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(a={from:o,to:s,insert:ql.of([t.text.replace("."," ")])}),this.pendingContextChange=a,!e.state.readOnly){let n=this.to-this.from+(a.to-a.from+a.insert.length);ep(e,a,ic.single(this.toEditorPos(t.selectionStart,n),this.toEditorPos(t.selectionEnd,n)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state))}else{let i=ic.single(this.toEditorPos(t.selectionStart),this.toEditorPos(t.selectionEnd));i.main.eq(n)||e.dispatch({selection:i,userEvent:"select"})}},this.handlers.characterboundsupdate=n=>{let i=[],r=null;for(let t=this.toEditorPos(n.rangeStart),o=this.toEditorPos(n.rangeEnd);t<o;t++){let n=e.coordsForChar(t);r=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||r||new DOMRect,i.push(r)}t.updateCharacterBounds(n.rangeStart,i)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,i=e.underlineThickness;if("None"!=t&&"None"!=i){let r=this.toEditorPos(e.rangeStart),o=this.toEditorPos(e.rangeEnd);if(r<o){let e=`text-decoration: underline ${"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${"Thin"==i?1:2}px`;n.push(ku.mark({attributes:{style:e}}).range(r,o))}}}e.dispatch({effects:pd.of(ku.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=xh(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,i=this.pendingContextChange;return e.changes.iterChanges(((r,o,s,a,l)=>{if(n)return;let c=l.length-(o-r);if(i&&o>=i.to){if(i.from==r&&i.to==o&&i.insert.eq(l))return i=this.pendingContextChange=null,t+=c,void(this.to+=c);i=null,this.revertPending(e.state)}if(r+=t,(o+=t)<=this.from)this.from+=c,this.to+=c;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+l.length>3e4)return void(n=!0);this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),l.toString()),this.to+=c}t+=c})),i&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange;this.composing&&(this.composing.drifted||e.transactions.some((e=>!e.isUserEvent("input.type")&&e.changes.touchesRange(this.from,this.to))))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),i=this.toContextPos(t.head);this.editContext.selectionStart==n&&this.editContext.selectionEnd==i||this.editContext.updateSelection(n,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class vf{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.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(e=>e.forEach((e=>n(e,this))))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new Yp(e.state||Kc.create(e)),e.scrollTo&&e.scrollTo.is(dd)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(yd).map((e=>new wd(e)));for(let e of this.plugins)e.update(this);this.observer=new ff(this),this.inputState=new tp(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Td(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then((()=>this.requestMeasure()))}dispatch(...e){let t=1==e.length&&e[0]instanceof Lc?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,n=!1,i=!1,r=this.state;for(let t of e){if(t.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=t.state}if(this.destroyed)return void(this.viewState.state=r);let o=this.hasFocus,s=0,a=null;e.some((e=>e.annotation(Cp)))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Ep(r,o),a||(s=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(Kc.phrases)!=this.state.facet(Kc.phrases))return this.setState(r);t=Od.create(this,r,e),t.flags|=s;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(h&&(h=h.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;h=new ud(e.empty?e:ic.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(dd)&&(h=e.value.clip(this.state))}this.viewState.update(t,h),this.bidiCache=xf.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(Dd)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some((e=>e.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(t.startState.facet(rf)!=t.state.facet(rf)&&(this.viewState.mustMeasureContent=!0),(n||i||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(id))try{e(t)}catch(e){fd(this.state,e,"update listener")}(a||c)&&Promise.resolve().then((()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Zd(this,c)&&l.force&&Ih(this.contentDOM,l.key,l.keyCode)}))}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new Yp(e),this.plugins=e.facet(yd).map((e=>new wd(e))),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new Td(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(yd),n=e.state.facet(yd);if(t!=n){let i=[];for(let r of n){let n=t.indexOf(r);if(n<0)i.push(new wd(r));else{let t=this.plugins[n];t.mustUpdate=e,i.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){fd(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,i=n.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(o<0)if(jh(n))r=-1,o=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(i);r=e.from,o=e.top}this.updateState=1;let s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let a=[];4&s||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map((e=>{try{return e.read(this)}catch(e){return fd(this.state,e),bf}})),c=Od.create(this,this.state,[]),h=!1;c.flags|=s,t?t.flags|=s:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),h=this.docView.update(c),h&&this.docViewUpdate());for(let e=0;e<a.length;e++)if(l[e]!=bf)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){fd(this.state,e)}if(h&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}{let e=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o;if(e>1||e<-1){i+=e,n.scrollTop=i/this.scaleY,o=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(id))e(t)}get themeClasses(){return sf+" "+(this.state.facet(of)?lf:af)+" "+this.state.facet(rf)}updateAttrs(){let e=kf(this,bd,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(gd)?"true":"false",class:"cm-content",style:`${au.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),kf(this,xd,t);let n=this.observer.ignore((()=>{let n=vu(this.contentDOM,this.contentAttrs,t),i=vu(this.dom,this.editorAttrs,e);return n||i}));return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)if(e.is(vf.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(Dd);let e=this.state.facet(vf.cspNonce);fh.mount(this.root,this.styleModules.concat(uf).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure()))),e){if(this.measureRequests.indexOf(e)>-1)return;if(null!=e.key)for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key)return void(this.measureRequests[t]=e);this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find((t=>t.spec==e))||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Gd(this,e,Wd(this,e,t,n))}moveByGroup(e,t){return Gd(this,e,Wd(this,e,t,(t=>function(e,t,n){let i=e.state.charCategorizer(t),r=i(n);return e=>{let t=i(e);return r==Hc.Space&&(r=t),r==t}}(this,e.head,t))))}visualLineSide(e,t){let n=this.bidiSpans(e),i=this.textDirectionAt(e.from),r=n[t?n.length-1:0];return ic.cursor(r.side(t,i)+e.from,r.forward(!t,i)?1:-1)}moveToLineBoundary(e,t,n=!0){return Hd(this,e,t,n)}moveVertically(e,t,n){return Gd(this,e,function(e,t,n,i){let r=t.head,o=n?1:-1;if(r==(n?e.state.doc.length:0))return ic.cursor(r,t.assoc);let s,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(r,t.assoc||-1),h=e.documentTop;if(c)null==a&&(a=c.left-l.left),s=o<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(r);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(r-t.from))),s=(o<0?t.top:t.bottom)+h}let u=l.left+a,d=null!=i?i:e.viewState.heightOracle.textHeight>>1;for(let t=0;;t+=10){let n=s+(d+t)*o,i=$d(e,{x:u,y:n},!1,o);if(n<l.top||n>l.bottom||(o<0?i<r:i>r)){let t=e.docView.coordsForChar(i),r=!t||n<t.top?-1:1;return ic.cursor(i,r,void 0,a)}}}(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),$d(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let i=this.state.doc.lineAt(e),r=this.bidiSpans(i);return Rh(n,r[Hu.find(r,e-i.from,-1,t)].dir==Pu.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(ld)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>wf)return Xu(e.length);let t,n=this.textDirectionAt(e.from);for(let i of this.bidiCache)if(i.from==e.from&&i.dir==n&&(i.fresh||Wu(i.isolates,t=Ed(this,e))))return i.order;t||(t=Ed(this,e));let i=function(e,t,n){if(!e)return[new Hu(0,0,t==Bu?1:0)];if(t==qu&&!n.length&&!zu.test(e))return Xu(e.length);if(n.length)for(;e.length>Uu.length;)Uu[Uu.length]=256;let i=[],r=t==qu?0:1;return Ku(e,r,r,n,0,e.length,i),i}(e.text,n,t);return this.bidiCache.push(new xf(e.from,e.to,n,t,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||au.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{Bh(this.contentDOM),this.docView.updateSelection()}))}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return dd.of(new ud("number"==typeof e?ic.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return dd.of(new ud(ic.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return vd.define((()=>({})),{eventHandlers:e})}static domEventObservers(e){return vd.define((()=>({})),{eventObservers:e})}static theme(e,t){let n=fh.newName(),i=[rf.of(n),Dd.of(hf(`.${n}`,e))];return t&&t.dark&&i.push(of.of(!0)),i}static baseTheme(e){return wc.lowest(Dd.of(hf("."+sf,e,cf)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),i=n&&Wh.get(n)||Wh.get(e);return(null===(t=null==i?void 0:i.rootView)||void 0===t?void 0:t.view)||null}}vf.styleModule=Dd,vf.inputHandler=rd,vf.clipboardInputFilter=sd,vf.clipboardOutputFilter=ad,vf.scrollHandler=hd,vf.focusChangeEffect=od,vf.perLineTextDirection=ld,vf.exceptionSink=nd,vf.updateListener=id,vf.editable=gd,vf.mouseSelectionStyle=td,vf.dragMovesSelection=ed,vf.clickAddsSelectionRange=Zu,vf.decorations=kd,vf.outerDecorations=_d,vf.atomicRanges=Sd,vf.bidiIsolatedRanges=Cd,vf.scrollMargins=Md,vf.darkTheme=of,vf.cspNonce=sc.define({combine:e=>e.length?e[0]:""}),vf.contentAttributes=xd,vf.editorAttributes=bd,vf.lineWrapping=vf.contentAttributes.of({class:"cm-lineWrapping"}),vf.announce=Bc.define();const wf=4096,bf={};class xf{constructor(e,t,n,i,r,o){this.from=e,this.to=t,this.dir=n,this.isolates=i,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some((e=>e.fresh)))return e;let n=[],i=e.length?e[e.length-1].dir:Pu.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let o=e[r];o.dir!=i||t.touchesRange(o.from,o.to)||n.push(new xf(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function kf(e,t,n){for(let i=e.state.facet(t),r=i.length-1;r>=0;r--){let t=i[r],o="function"==typeof t?t(e):t;o&&gu(o,n)}return n}const _f={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};!(au.ios&&au.webkit&&au.webkit_version<534)&&(_f[".cm-line"].caretColor=_f[".cm-content"].caretColor="transparent !important");class Sf extends Xc{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Sf.prototype.elementClass="",Sf.prototype.toDOM=void 0,Sf.prototype.mapMode=Gl.TrackBefore,Sf.prototype.startSide=Sf.prototype.endSide=-1,Sf.prototype.point=!0;const Cf=1024;let Ef=0;class Mf{constructor(e,t){this.from=e,this.to=t}}class Af{constructor(e={}){this.id=Ef++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=Of.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}Af.closedBy=new Af({deserialize:e=>e.split(" ")}),Af.openedBy=new Af({deserialize:e=>e.split(" ")}),Af.group=new Af({deserialize:e=>e.split(" ")}),Af.isolate=new Af({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),Af.contextHash=new Af({perNode:!0}),Af.lookAhead=new Af({perNode:!0}),Af.mounted=new Af({perNode:!0});class Df{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[Af.mounted.id]}}const Rf=Object.create(null);class Of{constructor(e,t,n,i=0){this.name=e,this.props=t,this.id=n,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):Rf,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),i=new Of(e.name||"",t,e.id,n);if(e.props)for(let n of e.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}return i}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(Af.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let i of n.split(" "))t[i]=e[n];return e=>{for(let n=e.prop(Af.group),i=-1;i<(n?n.length:0);i++){let r=t[i<0?e.name:n[i]];if(r)return r}}}}Of.none=new Of("",Object.create(null),0,8);const Tf=new WeakMap,Nf=new WeakMap;var Pf;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(Pf||(Pf={}));class qf{constructor(e,t,n,i,r){if(this.type=e,this.children=t,this.positions=n,this.length=i,this.props=null,r&&r.length){this.props=Object.create(null);for(let[e,t]of r)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=Df.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Kf(this.topNode,e)}cursorAt(e,t=0,n=0){let i=Tf.get(this)||this.topNode,r=new Kf(i);return r.moveTo(e,t),Tf.set(this,r._tree),r}get topNode(){return new Vf(this,0,0,null)}resolve(e,t=0){let n=Ff(Tf.get(this)||this.topNode,e,t,!1);return Tf.set(this,n),n}resolveInner(e,t=0){let n=Ff(Nf.get(this)||this.topNode,e,t,!0);return Nf.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let i=e.resolveInner(t,n),r=null;for(let e=i instanceof Vf?i:i.context.parent;e;e=e.parent)if(e.index<0){let o=e.parent;(r||(r=[i])).push(o.resolve(t,n)),e=o}else{let o=Df.get(e.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let s=new Vf(o.tree,o.overlay[0].from+e.from,-1,e);(r||(r=[i])).push(Ff(s,t,n,!1))}}return r?Uf(r):i}(this,e,t)}iterate(e){let{enter:t,leave:n,from:i=0,to:r=this.length}=e,o=e.mode||0,s=(o&Pf.IncludeAnonymous)>0;for(let e=this.cursor(o|Pf.IncludeAnonymous);;){let o=!1;if(e.from<=r&&e.to>=i&&(!s&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;o=!0}for(;o&&n&&(s||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;o=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Qf(Of.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,n)=>new qf(this.type,e,t,n,this.propValues)),e.makeTree||((e,t,n)=>new qf(Of.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:i,maxBufferLength:r=Cf,reused:o=[],minRepeatType:s=i.types.length}=e,a=Array.isArray(n)?new Bf(n,n.length):n,l=i.types,c=0,h=0;function u(e,t,n,v,w,b){let{id:x,start:k,end:_,size:S}=a,C=h,E=c;for(;S<0;){if(a.next(),-1==S){let t=o[x];return n.push(t),void v.push(k-e)}if(-3==S)return void(c=x);if(-4==S)return void(h=x);throw new RangeError(`Unrecognized record size: ${S}`)}let M,A,D=l[x],R=k-e;if(_-k<=r&&(A=m(a.pos-t,w))){let t=new Uint16Array(A.size-A.skip),n=a.pos-A.size,r=t.length;for(;a.pos>n;)r=y(A.start,t,r);M=new Lf(t,_-A.start,i),R=A.start-e}else{let e=a.pos-S;a.next();let t=[],n=[],i=x>=s?x:-1,o=0,l=_;for(;a.pos>e;)i>=0&&a.id==i&&a.size>=0?(a.end<=l-r&&(f(t,n,k,o,a.end,l,i,C,E),o=t.length,l=a.end),a.next()):b>2500?d(k,e,t,n):u(k,e,t,n,i,b+1);if(i>=0&&o>0&&o<t.length&&f(t,n,k,o,k,l,i,C,E),t.reverse(),n.reverse(),i>-1&&o>0){let e=p(D,E);M=Qf(D,t,n,0,t.length,0,_-k,e,e)}else M=g(D,t,n,_-k,C-_,E)}n.push(M),v.push(R)}function d(e,t,n,o){let s=[],l=0,c=-1;for(;a.pos>t;){let{id:e,start:t,end:n,size:i}=a;if(i>4)a.next();else{if(c>-1&&t<c)break;c<0&&(c=n-r),s.push(e,t,n),l++,a.next()}}if(l){let t=new Uint16Array(4*l),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;n.push(new Lf(t,s[2]-r,i)),o.push(r-e)}}function p(e,t){return(n,i,r)=>{let o,s,a=0,l=n.length-1;if(l>=0&&(o=n[l])instanceof qf){if(!l&&o.type==e&&o.length==r)return o;(s=o.prop(Af.lookAhead))&&(a=i[l]+o.length+s)}return g(e,n,i,r,a,t)}}function f(e,t,n,r,o,s,a,l,c){let h=[],u=[];for(;e.length>r;)h.push(e.pop()),u.push(t.pop()+n-o);e.push(g(i.types[a],h,u,s-o,l-s,c)),t.push(o-n)}function g(e,t,n,i,r,o,s){if(o){let e=[Af.contextHash,o];s=s?[e].concat(s):[e]}if(r>25){let e=[Af.lookAhead,r];s=s?[e].concat(s):[e]}return new qf(e,t,n,i,s)}function m(e,t){let n=a.fork(),i=0,o=0,l=0,c=n.end-r,h={size:0,start:0,skip:0};e:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){h.size=i,h.start=o,h.skip=l,l+=4,i+=4,n.next();continue}let a=n.pos-e;if(e<0||a<r||n.start<c)break;let u=n.id>=s?4:0,d=n.start;for(n.next();n.pos>a;){if(n.size<0){if(-3!=n.size)break e;u+=4}else n.id>=s&&(u+=4);n.next()}o=d,i+=e,l+=u}return(t<0||i==e)&&(h.size=i,h.start=o,h.skip=l),h.size>4?h:void 0}function y(e,t,n){let{id:i,start:r,end:o,size:l}=a;if(a.next(),l>=0&&i<s){let s=n;if(l>4){let i=a.pos-(l-4);for(;a.pos>i;)n=y(e,t,n)}t[--n]=s,t[--n]=o-e,t[--n]=r-e,t[--n]=i}else-3==l?c=i:-4==l&&(h=i);return n}let v=[],w=[];for(;a.pos>0;)u(e.start||0,e.bufferStart||0,v,w,-1,0);let b=null!==(t=e.length)&&void 0!==t?t:v.length?w[0]+v[0].length:0;return new qf(l[e.topID],v.reverse(),w.reverse(),b)}(e)}}qf.empty=new qf(Of.none,[],[],0);class Bf{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 Bf(this.buffer,this.index)}}class Lf{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Of.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],i=this.set.types[t],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),n==(e+=4))return r;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,n,i,r){let{buffer:o}=this,s=-1;for(let a=e;a!=t&&!(If(r,i,o[a+1],o[a+2])&&(s=a,n>0));a=o[a+3]);return s}slice(e,t,n){let i=this.buffer,r=new Uint16Array(t-e),o=0;for(let s=e,a=0;s<t;){r[a++]=i[s++],r[a++]=i[s++]-n;let t=r[a++]=i[s++]-n;r[a++]=i[s++]-e,o=Math.max(o,t)}return new Lf(r,o,this.set)}}function If(e,t,n,i){switch(e){case-2:return n<t;case-1:return i>=t&&n<t;case 0:return n<t&&i>t;case 1:return n<=t&&i>t;case 2:return i>t;case 4:return!0}}function Ff(e,t,n,i){for(var r;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!i&&e instanceof Vf&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=i?0:Pf.IgnoreOverlays;if(i)for(let i=e,s=i.parent;s;i=s,s=i.parent)i instanceof Vf&&i.index<0&&(null===(r=s.enter(t,n,o))||void 0===r?void 0:r.from)!=i.from&&(e=s);for(;;){let i=e.enter(t,n,o);if(!i)return e;e=i}}class jf{cursor(e=0){return new Kf(this,e)}getChild(e,t=null,n=null){let i=$f(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return $f(this,e,t,n)}resolve(e,t=0){return Ff(this,e,t,!1)}resolveInner(e,t=0){return Ff(this,e,t,!0)}matchContext(e){return zf(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class Vf extends jf{constructor(e,t,n,i){super(),this._tree=e,this.from=t,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,i,r=0){for(let o=this;;){for(let{children:s,positions:a}=o._tree,l=t>0?s.length:-1;e!=l;e+=t){let l=s[e],c=a[e]+o.from;if(If(i,n,c,c+l.length))if(l instanceof Lf){if(r&Pf.ExcludeBuffers)continue;let s=l.findChild(0,l.buffer.length,t,n-c,i);if(s>-1)return new Wf(new Hf(o,l,e,c),null,s)}else if(r&Pf.IncludeAnonymous||!l.type.isAnonymous||Xf(l)){let s;if(!(r&Pf.IgnoreMounts)&&(s=Df.get(l))&&!s.overlay)return new Vf(s.tree,c,e,o);let a=new Vf(l,c,e,o);return r&Pf.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?l.children.length-1:0,t,n,i)}}if(r&Pf.IncludeAnonymous||!o.type.isAnonymous)return null;if(e=o.index>=0?o.index+t:t<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let i;if(!(n&Pf.IgnoreOverlays)&&(i=Df.get(this._tree))&&i.overlay){let n=e-this.from;for(let{from:e,to:r}of i.overlay)if((t>0?e<=n:e<n)&&(t<0?r>=n:r>n))return new Vf(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $f(e,t,n,i){let r=e.cursor(),o=[];if(!r.firstChild())return o;if(null!=n)for(let e=!1;!e;)if(e=r.type.is(n),!r.nextSibling())return o;for(;;){if(null!=i&&r.type.is(i))return o;if(r.type.is(t)&&o.push(r.node),!r.nextSibling())return null==i?o:[]}}function zf(e,t,n=t.length-1){for(let i=e;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[n]&&t[n]!=i.name)return!1;n--}}return!0}class Hf{constructor(e,t,n,i){this.parent=e,this.buffer=t,this.index=n,this.start=i}}class Wf extends jf{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,n);return r<0?null:new Wf(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&Pf.ExcludeBuffers)return null;let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new Wf(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Wf(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 Wf(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,i=this.index+4,r=n.buffer[this.index+3];if(r>i){let o=n.buffer[this.index+1];e.push(n.slice(i,r,o)),t.push(0)}return new qf(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Uf(e){if(!e.length)return null;let t=0,n=e[0];for(let i=1;i<e.length;i++){let r=e[i];(r.from>n.from||r.to<n.to)&&(n=r,t=i)}let i=n instanceof Vf&&n.index<0?null:n.parent,r=e.slice();return i?r[t]=i:r.splice(t,1),new Gf(r,n)}class Gf{constructor(e,t){this.heads=e,this.node=t}get next(){return Uf(this.heads)}}class Kf{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Vf)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return!!e&&(e instanceof Vf?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:i}=this.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,n);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&Pf.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pf.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pf.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(i.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=i)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let i=t+e,r=e<0?-1:n._tree.children.length;i!=r;i+=e){let e=n._tree.children[i];if(this.mode&Pf.IncludeAnonymous||e instanceof Lf||!e.type.isAnonymous||Xf(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let i=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;t=o,n=r+1;break e}i=this.stack[--r]}for(let e=n;e<this.stack.length;e++)t=new Wf(this.buffer,t,this.stack[e]);return this.bufferNode=new Wf(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let i=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&t&&t(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(e){if(!this.buffer)return zf(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let i=e.length-1,r=this.stack.length-1;i>=0;r--){if(r<0)return zf(this._tree,e,i);let o=n[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function Xf(e){return e.children.some((e=>e instanceof Lf||!e.type.isAnonymous||Xf(e)))}const Yf=new WeakMap;function Jf(e,t){if(!e.isAnonymous||t instanceof Lf||t.type!=e)return 1;let n=Yf.get(t);if(null==n){n=1;for(let i of t.children){if(i.type!=e||!(i instanceof qf)){n=1;break}n+=Jf(e,i)}Yf.set(t,n)}return n}function Qf(e,t,n,i,r,o,s,a,l){let c=0;for(let n=i;n<r;n++)c+=Jf(e,t[n]);let h=Math.ceil(1.5*c/8),u=[],d=[];return function t(n,i,r,s,a){for(let c=r;c<s;){let r=c,p=i[c],f=Jf(e,n[c]);for(c++;c<s;c++){let t=Jf(e,n[c]);if(f+t>=h)break;f+=t}if(c==r+1){if(f>h){let e=n[r];t(e.children,e.positions,0,e.children.length,i[r]+a);continue}u.push(n[r])}else{let t=i[c-1]+n[c-1].length-p;u.push(Qf(e,n,i,r,c,p,t,null,l))}d.push(p+a-o)}}(t,n,i,r,0),(a||l)(u,d,s)}class Zf{constructor(e,t,n,i,r=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=i,this.open=(r?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let i=[new Zf(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&i.push(n);return i}static applyChanges(e,t,n=128){if(!t.length)return e;let i=[],r=1,o=e.length?e[0]:null;for(let s=0,a=0,l=0;;s++){let c=s<t.length?t[s]:null,h=c?c.fromA:1e9;if(h-a>=n)for(;o&&o.from<h;){let t=o;if(a>=t.from||h<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,h)-l;t=e>=n?null:new Zf(e,n,t.tree,t.offset+l,s>0,!!c)}if(t&&i.push(t),o.to>h)break;o=r<e.length?e[r++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return i}}class eg{startParse(e,t,n){return"string"==typeof e&&(e=new tg(e)),n=n?n.length?n.map((e=>new Mf(e.from,e.to))):[new Mf(0,0)]:[new Mf(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let i=this.startParse(e,t,n);for(;;){let e=i.advance();if(e)return e}}}class tg{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new Af({perNode:!0});let ng=0;class ig{constructor(e,t,n,i){this.name=e,this.set=t,this.base=n,this.modified=i,this.id=ng++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n="string"==typeof e?e:"?";if(e instanceof ig&&(t=e),null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let i=new ig(n,[],null,[]);if(i.set.push(i),t)for(let e of t.set)i.set.push(e);return i}static defineModifier(e){let t=new og(e);return e=>e.modified.indexOf(t)>-1?e:og.get(e.base||e,e.modified.concat(t).sort(((e,t)=>e.id-t.id)))}}let rg=0;class og{constructor(e){this.name=e,this.instances=[],this.id=rg++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find((n=>{return n.base==e&&(i=t,r=n.modified,i.length==r.length&&i.every(((e,t)=>e==r[t])));var i,r}));if(n)return n;let i=[],r=new ig(e.name,i,e,t);for(let e of t)e.instances.push(r);let o=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let i=0,r=t.length;i<r;i++)t.push(t[i].concat(e[n]));return t.sort(((e,t)=>t.length-e.length))}(t);for(let t of e.set)if(!t.modified.length)for(let e of o)i.push(og.get(t,e));return r}}function sg(e){let t=Object.create(null);for(let n in e){let i=e[n];Array.isArray(i)||(i=[i]);for(let e of n.split(" "))if(e){let n=[],r=2,o=e;for(let t=0;;){if("..."==o&&t>0&&t+3==e.length){r=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!i)throw new RangeError("Invalid path: "+e);if(n.push("*"==i[0]?"":'"'==i[0][0]?JSON.parse(i[0]):i[0]),t+=i[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){r=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);o=e.slice(t)}let s=n.length-1,a=n[s];if(!a)throw new RangeError("Invalid path: "+e);let l=new lg(i,r,s>0?n.slice(0,s):null);t[a]=l.sort(t[a])}}return ag.add(t)}const ag=new Af;class lg{constructor(e,t,n,i){this.tags=e,this.mode=t,this.context=n,this.next=i}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function cg(e,t){let n=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)n[e.id]=t.class;else n[t.tag.id]=t.class;let{scope:i,all:r=null}=t||{};return{style:e=>{let t=r;for(let i of e)for(let e of i.set){let i=n[e.id];if(i){t=t?t+" "+i:i;break}}return t},scope:i}}function hg(e,t,n,i=0,r=e.length){let o=new ug(i,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),i,r,"",o.highlighters),o.flush(r)}lg.empty=new lg([],2,null);class ug{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,i,r){let{type:o,from:s,to:a}=e;if(s>=n||a<=t)return;o.isTop&&(r=this.highlighters.filter((e=>!e.scope||e.scope(o))));let l=i,c=function(e){let t=e.type.prop(ag);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||lg.empty,h=function(e,t){let n=null;for(let i of e){let e=i.style(t);e&&(n=n?n+" "+e:e)}return n}(r,c.tags);if(h&&(l&&(l+=" "),l+=h,1==c.mode&&(i+=(i?" ":"")+h)),this.startSpan(Math.max(t,s),l),c.opaque)return;let u=e.tree&&e.tree.prop(Af.mounted);if(u&&u.overlay){let o=e.node.enter(u.overlay[0].from+s,1),c=this.highlighters.filter((e=>!e.scope||e.scope(u.tree.type))),h=e.firstChild();for(let d=0,p=s;;d++){let f=d<u.overlay.length?u.overlay[d]:null,g=f?f.from+s:a,m=Math.max(t,p),y=Math.min(n,g);if(m<y&&h)for(;e.from<y&&(this.highlightRange(e,m,y,i,r),this.startSpan(Math.min(y,e.to),l),!(e.to>=g)&&e.nextSibling()););if(!f||g>n)break;p=f.to+s,p>t&&(this.highlightRange(o.cursor(),Math.max(t,f.from+s),Math.min(n,p),"",c),this.startSpan(Math.min(n,p),l))}h&&e.parent()}else if(e.firstChild()){u&&(i="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,i,r),this.startSpan(Math.min(n,e.to),l)}}while(e.nextSibling());e.parent()}}}const dg=ig.define,pg=dg(),fg=dg(),gg=dg(fg),mg=dg(fg),yg=dg(),vg=dg(yg),wg=dg(yg),bg=dg(),xg=dg(bg),kg=dg(),_g=dg(),Sg=dg(),Cg=dg(Sg),Eg=dg(),Mg={comment:pg,lineComment:dg(pg),blockComment:dg(pg),docComment:dg(pg),name:fg,variableName:dg(fg),typeName:gg,tagName:dg(gg),propertyName:mg,attributeName:dg(mg),className:dg(fg),labelName:dg(fg),namespace:dg(fg),macroName:dg(fg),literal:yg,string:vg,docString:dg(vg),character:dg(vg),attributeValue:dg(vg),number:wg,integer:dg(wg),float:dg(wg),bool:dg(yg),regexp:dg(yg),escape:dg(yg),color:dg(yg),url:dg(yg),keyword:kg,self:dg(kg),null:dg(kg),atom:dg(kg),unit:dg(kg),modifier:dg(kg),operatorKeyword:dg(kg),controlKeyword:dg(kg),definitionKeyword:dg(kg),moduleKeyword:dg(kg),operator:_g,derefOperator:dg(_g),arithmeticOperator:dg(_g),logicOperator:dg(_g),bitwiseOperator:dg(_g),compareOperator:dg(_g),updateOperator:dg(_g),definitionOperator:dg(_g),typeOperator:dg(_g),controlOperator:dg(_g),punctuation:Sg,separator:dg(Sg),bracket:Cg,angleBracket:dg(Cg),squareBracket:dg(Cg),paren:dg(Cg),brace:dg(Cg),content:bg,heading:xg,heading1:dg(xg),heading2:dg(xg),heading3:dg(xg),heading4:dg(xg),heading5:dg(xg),heading6:dg(xg),contentSeparator:dg(bg),list:dg(bg),quote:dg(bg),emphasis:dg(bg),strong:dg(bg),link:dg(bg),monospace:dg(bg),strikethrough:dg(bg),inserted:dg(),deleted:dg(),changed:dg(),invalid:dg(),meta:Eg,documentMeta:dg(Eg),annotation:dg(Eg),processingInstruction:dg(Eg),definition:ig.defineModifier("definition"),constant:ig.defineModifier("constant"),function:ig.defineModifier("function"),standard:ig.defineModifier("standard"),local:ig.defineModifier("local"),special:ig.defineModifier("special")};for(let e in Mg){let t=Mg[e];t instanceof ig&&(t.name=e)}var Ag;cg([{tag:Mg.link,class:"tok-link"},{tag:Mg.heading,class:"tok-heading"},{tag:Mg.emphasis,class:"tok-emphasis"},{tag:Mg.strong,class:"tok-strong"},{tag:Mg.keyword,class:"tok-keyword"},{tag:Mg.atom,class:"tok-atom"},{tag:Mg.bool,class:"tok-bool"},{tag:Mg.url,class:"tok-url"},{tag:Mg.labelName,class:"tok-labelName"},{tag:Mg.inserted,class:"tok-inserted"},{tag:Mg.deleted,class:"tok-deleted"},{tag:Mg.literal,class:"tok-literal"},{tag:Mg.string,class:"tok-string"},{tag:Mg.number,class:"tok-number"},{tag:[Mg.regexp,Mg.escape,Mg.special(Mg.string)],class:"tok-string2"},{tag:Mg.variableName,class:"tok-variableName"},{tag:Mg.local(Mg.variableName),class:"tok-variableName tok-local"},{tag:Mg.definition(Mg.variableName),class:"tok-variableName tok-definition"},{tag:Mg.special(Mg.variableName),class:"tok-variableName2"},{tag:Mg.definition(Mg.propertyName),class:"tok-propertyName tok-definition"},{tag:Mg.typeName,class:"tok-typeName"},{tag:Mg.namespace,class:"tok-namespace"},{tag:Mg.className,class:"tok-className"},{tag:Mg.macroName,class:"tok-macroName"},{tag:Mg.propertyName,class:"tok-propertyName"},{tag:Mg.operator,class:"tok-operator"},{tag:Mg.comment,class:"tok-comment"},{tag:Mg.meta,class:"tok-meta"},{tag:Mg.invalid,class:"tok-invalid"},{tag:Mg.punctuation,class:"tok-punctuation"}]);const Dg=new Af,Rg=new Af;class Og{constructor(e,t,n=[],i=""){this.data=e,this.name=i,Kc.prototype.hasOwnProperty("tree")||Object.defineProperty(Kc.prototype,"tree",{get(){return Ng(this)}}),this.parser=t,this.extension=[$g.of(this),Kc.languageData.of(((e,t,n)=>{let i=Tg(e,t,n),r=i.type.prop(Dg);if(!r)return[];let o=e.facet(r),s=i.type.prop(Rg);if(s){let r=i.resolve(t-i.from,n);for(let t of s)if(t.test(r,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(o)}}return o}))].concat(n)}isActiveAt(e,t,n=-1){return Tg(e,t,n).type.prop(Dg)==this.data}findRegions(e){let t=e.facet($g);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(e,t)=>{if(e.prop(Dg)==this.data)return void n.push({from:t,to:t+e.length});let r=e.prop(Af.mounted);if(r){if(r.tree.prop(Dg)==this.data){if(r.overlay)for(let e of r.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(r.overlay){let e=n.length;if(i(r.tree,r.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let r=e.children[n];r instanceof qf&&i(r,e.positions[n]+t)}};return i(Ng(e),0),n}get allowsNesting(){return!0}}function Tg(e,t,n){let i=e.facet($g),r=Ng(e).topNode;if(!i||i.allowsNesting)for(let e=r;e;e=e.enter(t,n,Pf.ExcludeBuffers))e.type.isTop&&(r=e);return r}function Ng(e){let t=e.field(Og.state,!1);return t?t.tree:qf.empty}Og.setState=Bc.define();class Pg{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let qg=null;class Bg{constructor(e,t,n=[],i,r,o,s,a){this.parser=e,this.state=t,this.fragments=n,this.tree=i,this.treeLen=r,this.viewport=o,this.skipped=s,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Bg(e,t,[],qf.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Pg(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=qf.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(Zf.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}}))}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext((()=>{for(;!(t=this.parse.advance()););})),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Zf.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=qg;qg=this;try{return e()}finally{qg=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Lg(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:r,viewport:o,skipped:s}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges(((e,n,i,r)=>t.push({fromA:e,toA:n,fromB:i,toB:r}))),n=Zf.applyChanges(n,t),i=qf.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){s=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);n<i&&s.push({from:n,to:i})}}}return new Bg(this.parser,t,n,i,r,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:i}=this.skipped[t];n<e.to&&i>e.from&&(this.fragments=Lg(this.fragments,n,i),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends eg{createParse(t,n,i){let r=i[0].from,o=i[i.length-1].to;return{parsedPos:r,advance(){let t=qg;if(t){for(let e of i)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=o,new qf(Of.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return qg}}function Lg(e,t,n){return Zf.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class Ig{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Ig(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Bg.create(e.facet($g).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Ig(n)}}Og.state=pc.define({create:Ig.init,update(e,t){for(let e of t.effects)if(e.is(Og.setState))return e.value;return t.startState.facet($g)!=t.state.facet($g)?Ig.init(t.state):e.apply(t)}});let Fg=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(Fg=e=>{let t=-1,n=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const jg="undefined"!=typeof navigator&&(null===(Ag=navigator.scheduling)||void 0===Ag?void 0:Ag.isInputPending)?()=>navigator.scheduling.isInputPending():null,Vg=vd.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(Og.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(Og.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=Fg(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,r=n.field(Og.state);if(r.tree==r.context.tree&&r.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!jg?Math.max(25,e.timeRemaining()-5):1e9),s=r.context.treeLen<i&&n.doc.length>i+1e3,a=r.context.work((()=>jg&&jg()||Date.now()>o),i+(s?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Og.setState.of(new Ig(r.context))})),this.chunkBudget>0&&(!a||s)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((()=>this.scheduleWork())).catch((e=>fd(this.view.state,e))).then((()=>this.workScheduled--)),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),$g=sc.define({combine:e=>e.length?e[0]:null,enables:e=>[Og.state,Vg,vf.contentAttributes.compute([e],(t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}}))]});class zg{constructor(e,t){let n;function i(e){let t=fh.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const r="string"==typeof t.all?t.all:t.all?i(t.all):void 0,o=t.scope;this.scope=o instanceof Og?e=>e.prop(Dg)==o.data:o?e=>e==o:void 0,this.style=cg(e.map((e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))}))),{all:r}).style,this.module=n?new fh(n):null,this.themeType=t.themeType}static define(e,t){return new zg(e,t||{})}}const Hg=sc.define(),Wg=sc.define({combine:e=>e.length?[e[0]]:null});function Ug(e){let t=e.facet(Hg);return t.length?t:e.facet(Wg)}class Gg{constructor(e){this.markCache=Object.create(null),this.tree=Ng(e.state),this.decorations=this.buildDeco(e,Ug(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Ng(e.state),n=Ug(e.state),i=n!=Ug(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!i&&t.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return ku.none;let n=new eh;for(let{from:i,to:r}of e.visibleRanges)hg(this.tree,t,((e,t,i)=>{n.add(e,t,this.markCache[i]||(this.markCache[i]=ku.mark({class:i})))}),i,r);return n.finish()}}const Kg=wc.high(vd.fromClass(Gg,{decorations:e=>e.decorations}));Mg.meta,Mg.link,Mg.heading,Mg.emphasis,Mg.strong,Mg.strikethrough,Mg.keyword,Mg.atom,Mg.bool,Mg.url,Mg.contentSeparator,Mg.labelName,Mg.literal,Mg.inserted,Mg.string,Mg.deleted,Mg.regexp,Mg.escape,Mg.string,Mg.variableName,Mg.variableName,Mg.typeName,Mg.namespace,Mg.className,Mg.variableName,Mg.macroName,Mg.propertyName,Mg.comment,Mg.invalid;const Xg=Object.create(null),Yg=[Of.none],Jg=[],Qg=Object.create(null),Zg=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Zg[e]=tm(Xg,t);function em(e,t){Jg.indexOf(e)>-1||(Jg.push(e),console.warn(t))}function tm(e,t){let n=[];for(let i of t.split(" ")){let t=[];for(let n of i.split(".")){let i=e[n]||Mg[n];i?"function"==typeof i?t.length?t=t.map(i):em(n,`Modifier ${n} used at start of tag`):t.length?em(n,`Tag ${n} used as modifier`):t=Array.isArray(i)?i:[i]:em(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let i=t.replace(/ /g,"_"),r=i+" "+n.map((e=>e.id)),o=Qg[r];if(o)return o.id;let s=Qg[r]=Of.define({id:Yg.length,name:i,props:[sg({[i]:n})]});return Yg.push(s),s.id}Pu.RTL,Pu.LTR;const nm=sc.define({combine:e=>Object.assign({sources:e.map((e=>e.source)).filter((e=>null!=e))},function(e,t,n={}){let i={};for(let t of e)for(let e of Object.keys(t)){let r=t[e],o=i[e];if(void 0===o)i[e]=r;else if(o===r||void 0===r);else{if(!Object.hasOwnProperty.call(n,e))throw new Error("Config merge conflict for field "+e);i[e]=n[e](o,r)}}for(let e in t)void 0===i[e]&&(i[e]=t[e]);return i}(e.map((e=>e.config)),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))});function im(e){const t=[];return e.iterate({enter:e=>{const n=e.node;if(!n.type.isError)return;const i=n.parent,r=rm(n),o={from:n.from,to:n.to,severity:"error",type:"Syntax Error"};if(n.from!==n.to)o.message=`Unrecognized token in <${i.name}>`;else if(r)o.message=`Unrecognized token <${r.name}> in <${i.name}>`,o.to=r.to;else{const e=i.enterUnfinishedNodesBefore(n.to);o.message=`Incomplete <${(e||i).name}>`}t.push(o)}}),t}function rm(e){return e?e.nextSibling||rm(e.parent):null}var om={create:e=>({enter(t){if("FilterExpression"!==t.name)return;const n=e.readContent(t.from,t.to);if(/\[\s*0\s*\]$/.test(n)){const{from:i,to:r}=t;e.report({from:i,to:r,message:"First item is accessed via [1]",severity:"warning",type:"first-item",actions:[{name:"fix",apply(t,o=i,s=r){e.updateContent(o,s,n.replace(/\[\s*0\s*\]$/,"[1]"))}}]})}}})};const sm=[om];function am(e){const{readContent:t,syntaxTree:n,updateContent:i}=e,r=[],o={readContent:t,report:e=>{r.push(e)},updateContent:i},s=sm.map((e=>e.create(o)));return n.iterate({enter:e=>{for(const t of s)t.enter&&t.enter(e)},leave:e=>{for(const t of s)t.leave&&t.leave(e)}}),r}!function(e,t={}){nm.of({source:e,config:t})}((e=>{if(0===e.state.doc.length)return[];const t=Ng(e.state),n=(i={syntaxTree:t,readContent:(t,n)=>e.state.sliceDoc(t,n),updateContent:(t,n,i)=>e.dispatch({changes:{from:t,to:n,insert:i}})},[...im(i.syntaxTree),...am(i)]);var i;return n.map((e=>({...e,source:e.type})))})),vf.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}}),vf.baseTheme({"& .variableName":{color:"#10f"},"& .number":{color:"#164"},"& .string":{color:"#a11"},"& .bool":{color:"#219"},"& .function":{color:"#aa3731",fontWeight:"bold"},"& .control":{color:"#708"}}),function(e,t){let n,i=[Kg];e instanceof zg&&(e.module&&i.push(vf.styleModule.of(e.module)),n=e.themeType),n?i.push(Hg.computeN([vf.darkTheme],(t=>t.facet(vf.darkTheme)==("dark"==n)?[e]:[]))):i.push(Hg.of(e))}(zg.define([{tag:Mg.variableName,class:"variableName"},{tag:Mg.name,class:"variableName"},{tag:Mg.number,class:"number"},{tag:Mg.string,class:"string"},{tag:Mg.bool,class:"bool"},{tag:Mg.function(Mg.variableName),class:"function"},{tag:Mg.function(Mg.special(Mg.variableName)),class:"function"},{tag:Mg.controlKeyword,class:"control"},{tag:Mg.operatorKeyword,class:"control"}])),sc.define(),sc.define(),sc.define(),sc.define();function lm(e){const{name:t,description:n}=e,i=t.match(/^([\w\s]+)\((.*)\)$/),r=i[1],o=i[2],s=o?o.split(", ").map((e=>({name:e}))):[];return{name:r,type:"function",params:s,info:()=>Lt(`<div class="description">${n}<div>`),boost:0}}[{name:"not(negand)",description:'<p>Returns the logical negation of the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">not(negand: boolean): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">not(true)\n// false\n\nnot(null)\n// null\n</code></pre>\n'},{name:"is defined(value)",description:'<p><em>Camunda Extension</em></p>\n<p>Checks if a given value is not <code>null</code>. If the value is <code>null</code> then the function returns <code>false</code>.\nOtherwise, the function returns <code>true</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">is defined(value: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">is defined(1)\n// true\n\nis defined(null)\n// false\n\nis defined(x)\n// false - if no variable "x" exists\n\nis defined(x.y)\n// false - if no variable "x" exists or it doesn't have a property "y"\n</code></pre>\n<p>:::caution Breaking change</p>\n<p>This function worked differently in previous versions. It returned <code>true</code> if the value was <code>null</code>.\nSince this version, the function returns <code>false</code> if the value is <code>null</code>.</p>\n<p>:::</p>\n'},{name:"get or else(value, default)",description:'<p><em>Camunda Extension</em></p>\n<p>Return the provided value parameter if not <code>null</code>, otherwise return the default parameter</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">get or else(value: Any, default: Any): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">get or else("this", "default")\n// "this"\n\nget or else(null, "default")\n// "default"\n\nget or else(null, null)\n// null\n</code></pre>\n'},{name:"assert(value, condition)",description:'<p><em>Camunda Extension</em></p>\n<p>Verify that the given condition is met. If the condition is <code>true</code>, the function returns the value.\nOtherwise, the evaluation fails with an error.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">assert(value: Any, condition: Any)\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">assert(x, x != null)\n// "value" - if x is "value"\n// error - if x is null or doesn't exist\n\nassert(x, x >= 0)\n// 4 - if x is 4\n// error - if x is less than zero\n</code></pre>\n'},{name:"assert(value, condition, cause)",description:'<p><em>Camunda Extension</em></p>\n<p>Verify that the given condition is met. If the condition is <code>true</code>, the function returns the value.\nOtherwise, the evaluation fails with an error containing the given message.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">assert(value: Any, condition: Any, cause: String)\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">assert(x, x != null, "'x' should not be null")\n// "value" - if x is "value"\n// error('x' should not be null) - if x is null or doesn't exist\n\nassert(x, x >= 0, "'x' should be positive")\n// 4 - if x is 4\n// error('x' should be positive) - if x is less than zero\n</code></pre>\n'},{name:"get value(context, key)",description:'<p>Returns the value of the context entry with the given key.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">get value(context: context, key: string): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">get value({foo: 123}, "foo")\n// 123\n\nget value({a: 1}, "b")\n// null\n</code></pre>\n'},{name:"get value(context, keys)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns the value of the context entry for a context path defined by the given keys.</p>\n<p>If <code>keys</code> contains the keys <code>[k1, k2]</code> then it returns the value at the nested entry <code>k1.k2</code> of the context.</p>\n<p>If <code>keys</code> are empty or the nested entry defined by the keys doesn't exist in the context, it returns <code>null</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">get value(context: context, keys: list<string>): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">get value({x:1, y: {z:0}}, ["y", "z"])\n// 0\n\nget value({x: {y: {z:0}}}, ["x", "y"])\n// {z:0}\n\nget value({a: {b: 3}}, ["b"])\n// null\n</code></pre>\n'},{name:"get entries(context)",description:'<p>Returns the entries of the context as a list of key-value-pairs.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">get entries(context: context): list<context>\n</code></pre>\n<p>The return value is a list of contexts. Each context contains two entries for "key" and "value".</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">get entries({foo: 123})\n// [{key: "foo", value: 123}]\n</code></pre>\n'},{name:"context put(context, key, value)",description:'<p>Adds a new entry with the given key and value to the context. Returns a new context that includes the entry.</p>\n<p>If an entry for the same key already exists in the context, it overrides the value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">context put(context: context, key: string, value: Any): context\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">context put({x:1}, "y", 2)\n// {x:1, y:2}\n</code></pre>\n<p>:::info\nThe function <code>context put()</code> replaced the previous function <code>put()</code> (Camunda Extension). The\nprevious function is deprecated and should not be used anymore.\n:::</p>\n'},{name:"context put(context, keys, value)",description:'<p>Adds a new entry with the given value to the context. The path of the entry is defined by the keys. Returns a new context that includes the entry.</p>\n<p>If <code>keys</code> contains the keys <code>[k1, k2]</code> then it adds the nested entry <code>k1.k2 = value</code> to the context.</p>\n<p>If an entry for the same keys already exists in the context, it overrides the value.</p>\n<p>If <code>keys</code> are empty, it returns <code>null</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">context put(context: context, keys: list<string>, value: Any): context\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">context put({x:1}, ["y"], 2)\n// {x:1, y:2}\n\ncontext put({x:1, y: {z:0}}, ["y", "z"], 2)\n// {x:1, y: {z:2}}\n\ncontext put({x:1}, ["y", "z"], 2)\n// {x:1, y: {z:2}}\n</code></pre>\n'},{name:"context merge(contexts)",description:'<p>Union the given contexts. Returns a new context that includes all entries of the given contexts.</p>\n<p>If an entry for the same key already exists in a context, it overrides the value. The entries are overridden in the same order as in the list of contexts.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">context merge(contexts: list<context>): context\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">context merge([{x:1}, {y:2}])\n// {x:1, y:2}\n\ncontext merge([{x:1, y: 0}, {y:2}])\n// {x:1, y:2}\n</code></pre>\n<p>:::info\nThe function <code>context merge()</code> replaced the previous function <code>put all()</code> (Camunda Extension). The\nprevious function is deprecated and should not be used anymore.\n:::</p>\n'},{name:"string(from)",description:'<p>Returns the given value as a string representation.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string(from: Any): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string(1.1)\n// "1.1"\n\nstring(date("2012-12-25"))\n// "2012-12-25"\n</code></pre>\n'},{name:"number(from)",description:'<p>Parses the given string to a number.</p>\n<p>Returns <code>null</code> if the string is not a number.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">number(from: string): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">number("1500.5")\n// 1500.5\n</code></pre>\n'},{name:"context(entries)",description:'<p>Constructs a context of the given list of key-value pairs. It is the reverse function to <a href="feel-built-in-functions-context.md#get-entriescontext">get entries()</a>.</p>\n<p>Each key-value pair must be a context with two entries: <code>key</code> and <code>value</code>. The entry with name <code>key</code> must have a value of the type <code>string</code>.</p>\n<p>It might override context entries if the keys are equal. The entries are overridden in the same order as the contexts in the given list.</p>\n<p>Returns <code>null</code> if one of the entries is not a context or if a context doesn't contain the required entries.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">context(entries: list<context>): context\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">context([{"key":"a", "value":1}, {"key":"b", "value":2}])\n// {a:1, b:2}\n</code></pre>\n'},{name:"date(from)",description:'<p>Returns a date from the given value.</p>\n<p>Returns <code>null</code> if the string is not a valid calendar date. For example, <code>"2024-06-31"</code> is invalid because June has\nonly 30 days.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date(from: string): date\n</code></pre>\n<p>Parses the given string into a date.</p>\n<pre><code class="language-feel">date(from: date and time): date\n</code></pre>\n<p>Extracts the date component from the given date and time.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date("2018-04-29")\n// date("2018-04-29")\n\ndate(date and time("2012-12-25T11:00:00"))\n// date("2012-12-25")\n</code></pre>\n'},{name:"date(year, month, day)",description:'<p>Returns a date from the given components.</p>\n<p>Returns <code>null</code> if the components don't represent a valid calendar date. For example, <code>2024,6,31</code> is invalid because\nJune has only 30 days.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date(year: number, month: number, day: number): date\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date(2012, 12, 25)\n// date("2012-12-25")\n</code></pre>\n'},{name:"time(from)",description:'<p>Returns a time from the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">time(from: string): time\n</code></pre>\n<p>Parses the given string into a time.</p>\n<pre><code class="language-feel">time(from: date and time): time\n</code></pre>\n<p>Extracts the time component from the given date and time.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">time("12:00:00")\n// time("12:00:00")\n\ntime(date and time("2012-12-25T11:00:00"))\n// time("11:00:00")\n</code></pre>\n'},{name:"time(hour, minute, second)",description:'<p>Returns a time from the given components.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">time(hour: number, minute: number, second: number): time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">time(23, 59, 0)\n// time("23:59:00")\n</code></pre>\n'},{name:"time(hour, minute, second, offset)",description:'<p>Returns a time from the given components, including a timezone offset.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">time(hour: number, minute: number, second: number, offset: days and time duration): time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">time(14, 30, 0, duration("PT1H"))\n// time("14:30:00+01:00")\n</code></pre>\n'},{name:"date and time(from)",description:'<p>Parses the given string into a date and time.</p>\n<p>Returns <code>null</code> if the string is not a valid calendar date. For example, <code>"2024-06-31T10:00:00"</code> is invalid because\nJune has only 30 days.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date and time(from: string): date and time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date and time("2018-04-29T09:30:00")\n// date and time("2018-04-29T09:30:00")\n</code></pre>\n'},{name:"date and time(date, time)",description:'<p>Returns a date and time from the given components.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date and time(date: date, time: time): date and time\n</code></pre>\n<pre><code class="language-feel">date and time(date: date and time, time: time): date and time\n</code></pre>\n<p>Returns a date and time value that consists of the date component of <code>date</code> combined with <code>time</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date and time(date("2012-12-24"),time("T23:59:00"))\n// date and time("2012-12-24T23:59:00")\n\ndate and time(date and time("2012-12-25T11:00:00"),time("T23:59:00"))\n// date and time("2012-12-25T23:59:00")\n</code></pre>\n'},{name:"date and time(date, timezone)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns the given date and time value at the given timezone.</p>\n<p>If <code>date</code> has a different timezone than <code>timezone</code> then it adjusts the time to match the local time of <code>timezone</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date and time(date: date and time, timezone: string): date and time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date and time(@"2020-07-31T14:27:30@Europe/Berlin", "America/Los_Angeles")\n// date and time("2020-07-31T05:27:30@America/Los_Angeles")\n\ndate and time(@"2020-07-31T14:27:30", "Z")\n// date and time("2020-07-31T12:27:30Z")\n</code></pre>\n'},{name:"duration(from)",description:'<p>Parses the given string into a duration. The duration is either a days and time duration or a years and months duration.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">duration(from: string): days and time duration\n</code></pre>\n<pre><code class="language-feel">duration(from: string): years and months duration\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">duration("P5D")\n// duration("P5D")\n\nduration("P32Y")\n// duration("P32Y")\n</code></pre>\n'},{name:"years and months duration(from, to)",description:'<p>Returns the years and months duration between <code>from</code> and <code>to</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">years and months duration(from: date, to: date): years and months duration\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">years and months duration(date("2011-12-22"), date("2013-08-24"))\n// duration("P1Y8M")\n</code></pre>\n'},{name:"list contains(list, element)",description:'<p>Returns <code>true</code> if the given list contains the element. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">list contains(list: list, element: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">list contains([1,2,3], 2)\n// true\n</code></pre>\n'},{name:"count(list)",description:'<p>Returns the number of elements of the given list.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">count(list: list): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">count([1,2,3])\n// 3\n</code></pre>\n'},{name:"min(list)",description:'<p>Returns the minimum of the given list.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">min(list: list): Any\n</code></pre>\n<p>All elements in <code>list</code> should have the same type and be comparable.</p>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">min([1,2,3])\n// 1\n\nmin(1,2,3)\n// 1\n</code></pre>\n'},{name:"max(list)",description:'<p>Returns the maximum of the given list.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">max(list: list): Any\n</code></pre>\n<p>All elements in <code>list</code> should have the same type and be comparable.</p>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">max([1,2,3])\n// 3\n\nmax(1,2,3)\n// 3\n</code></pre>\n'},{name:"sum(list)",description:'<p>Returns the sum of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sum(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sum([1,2,3])\n// 6\n\nsum(1,2,3)\n// 6\n</code></pre>\n'},{name:"product(list)",description:'<p>Returns the product of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">product(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">product([2, 3, 4])\n// 24\n\nproduct(2, 3, 4)\n// 24\n</code></pre>\n'},{name:"mean(list)",description:'<p>Returns the arithmetic mean (i.e. average) of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">mean(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">mean([1,2,3])\n// 2\n\nmean(1,2,3)\n// 2\n</code></pre>\n'},{name:"median(list)",description:'<p>Returns the median element of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">median(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">median(8, 2, 5, 3, 4)\n// 4\n\nmedian([6, 1, 2, 3])\n// 2.5\n</code></pre>\n'},{name:"stddev(list)",description:'<p>Returns the standard deviation of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">stddev(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">stddev(2, 4, 7, 5)\n// 2.0816659994661326\n\nstddev([2, 4, 7, 5])\n// 2.0816659994661326\n</code></pre>\n'},{name:"mode(list)",description:'<p>Returns the mode of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">mode(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">mode(6, 3, 9, 6, 6)\n// [6]\n\nmode([6, 1, 9, 6, 1])\n// [1, 6]\n</code></pre>\n'},{name:"all(list)",description:'<p>Returns <code>false</code> if any element of the given list is <code>false</code>. Otherwise, returns <code>true</code>.</p>\n<p>If the given list is empty, it returns <code>true</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">all(list: list<boolean>): boolean\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">all([true,false])\n// false\n\nall(false,null,true)\n// false\n</code></pre>\n<p>:::info\nThe function <code>all()</code> replaced the previous function <code>and()</code>. The previous function is deprecated and\nshould not be used anymore.\n:::</p>\n'},{name:"any(list)",description:'<p>Returns <code>true</code> if any element of the given list is <code>true</code>. Otherwise, returns <code>false</code>.</p>\n<p>If the given list is empty, it returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">any(list: list<boolean>): boolean\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">any([false,true])\n// true\n\nany(false,null,true)\n// true\n</code></pre>\n<p>:::info\nThe function <code>any()</code> replaced the previous function <code>or()</code>. The previous function is deprecated and\nshould not be used anymore.\n:::</p>\n'},{name:"sublist(list, start position)",description:'<p>Returns a partial list of the given value starting at <code>start position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sublist(list: list, start position: number): list\n</code></pre>\n<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sublist([1,2,3], 2)\n// [2,3]\n</code></pre>\n'},{name:"sublist(list, start position, length)",description:'<p>Returns a partial list of the given value starting at <code>start position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sublist(list: list, start position: number, length: number): list\n</code></pre>\n<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sublist([1,2,3], 1, 2)\n// [1,2]\n</code></pre>\n'},{name:"append(list, items)",description:'<p>Returns the given list with all <code>items</code> appended.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">append(list: list, items: Any): list\n</code></pre>\n<p>The parameter <code>items</code> can be a single element or a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">append([1], 2, 3)\n// [1,2,3]\n</code></pre>\n'},{name:"concatenate(lists)",description:'<p>Returns a list that includes all elements of the given lists.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">concatenate(lists: list): list\n</code></pre>\n<p>The parameter <code>lists</code> is a sequence of lists.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">concatenate([1,2],[3])\n// [1,2,3]\n\nconcatenate([1],[2],[3])\n// [1,2,3]\n</code></pre>\n'},{name:"insert before(list, position, newItem)",description:'<p>Returns the given list with <code>newItem</code> inserted at <code>position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">insert before(list: list, position: number, newItem: Any): list\n</code></pre>\n<p>The <code>position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">insert before([1,3],1,2)\n// [2,1,3]\n</code></pre>\n'},{name:"remove(list, position)",description:'<p>Returns the given list without the element at <code>position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">remove(list: list, position: number): list\n</code></pre>\n<p>The <code>position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">remove([1,2,3], 2)\n// [1,3]\n</code></pre>\n'},{name:"reverse(list)",description:'<p>Returns the given list in revered order.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">reverse(list: list): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">reverse([1,2,3])\n// [3,2,1]\n</code></pre>\n'},{name:"index of(list, match)",description:'<p>Returns an ascending list of positions containing <code>match</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">index of(list: list, match: Any): list<number>\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">index of([1,2,3,2],2)\n// [2,4]\n</code></pre>\n'},{name:"union(list)",description:'<p>Returns a list that includes all elements of the given lists without duplicates.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">union(list: list): list\n</code></pre>\n<p>The parameter <code>list</code> is a sequence of lists.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">union([1,2],[2,3])\n// [1,2,3]\n</code></pre>\n'},{name:"distinct values(list)",description:'<p>Returns the given list without duplicates.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">distinct values(list: list): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">distinct values([1,2,3,2,1])\n// [1,2,3]\n</code></pre>\n'},{name:"duplicate values(list)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns all duplicate values of the given list.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">duplicate values(list: list): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">duplicate values([1,2,3,2,1])\n// [1,2]\n</code></pre>\n'},{name:"flatten(list)",description:'<p>Returns a list that includes all elements of the given list without nested lists.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">flatten(list: list): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">flatten([[1,2],[[3]], 4])\n// [1,2,3,4]\n</code></pre>\n'},{name:"sort(list, precedes)",description:'<p>Returns the given list sorted by the <code>precedes</code> function.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sort(list: list, precedes: function<(Any, Any) -> boolean>): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sort(list: [3,1,4,5,2], precedes: function(x,y) x < y)\n// [1,2,3,4,5]\n</code></pre>\n'},{name:"string join(list)",description:'<p>Joins a list of strings into a single string. This is similar to\nJava's <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Collectors.html#joining(java.lang.CharSequence,java.lang.CharSequence,java.lang.CharSequence)">joining</a>\nfunction.</p>\n<p>If an item of the list is <code>null</code>, the item is ignored for the result string. If an item is\nneither a string nor <code>null</code>, the function returns <code>null</code> instead of a string.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string join(list: list<string>): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string join(["a","b","c"])\n// "abc"\n\nstring join(["a",null,"c"])\n// "ac"\n\nstring join([])\n// ""\n</code></pre>\n'},{name:"string join(list, delimiter)",description:'<p>Joins a list of strings into a single string. This is similar to\nJava's <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Collectors.html#joining(java.lang.CharSequence,java.lang.CharSequence,java.lang.CharSequence)">joining</a>\nfunction.</p>\n<p>If an item of the list is <code>null</code>, the item is ignored for the result string. If an item is\nneither a string nor <code>null</code>, the function returns <code>null</code> instead of a string.</p>\n<p>The resulting string contains a <code>delimiter</code> between each element.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string join(list: list<string>, delimiter: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string join(["a"], "X")\n// "a"\n\nstring join(["a","b","c"], ", ")\n// "a, b, c"\n</code></pre>\n'},{name:"string join(list, delimiter, prefix, suffix)",description:'<p><em>Camunda Extension</em></p>\n<p>Joins a list of strings into a single string. This is similar to\nJava's <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Collectors.html#joining(java.lang.CharSequence,java.lang.CharSequence,java.lang.CharSequence)">joining</a>\nfunction.</p>\n<p>If an item of the list is <code>null</code>, the item is ignored for the result string. If an item is\nneither a string nor <code>null</code>, the function returns <code>null</code> instead of a string.</p>\n<p>The resulting string starts with <code>prefix</code>, contains a <code>delimiter</code> between each element, and ends\nwith <code>suffix</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string join(list: list<string>, delimiter: string, prefix: string, suffix: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string join(["a","b","c"], ", ", "[", "]")\n// "[a, b, c]"\n</code></pre>\n'},{name:"is empty(list)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns <code>true</code> if the given list is empty. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">is empty(list: list): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">is empty([])\n// true\n\nis empty([1,2,3])\n// false\n</code></pre>\n'},{name:"partition(list, size)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns consecutive sublists of a list, each of the same size (the final list may be smaller).</p>\n<p>If <code>size</code> is less than <code>0</code>, it returns <code>null</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">partition(list: list, size: number): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">partition([1,2,3,4,5], 2)\n// [[1,2], [3,4], [5]]\n\npartition([], 2)\n// []\n\npartition([1,2], 0)\n// null\n</code></pre>\n'},{name:"decimal(n, scale)",description:'<p>Rounds the given value at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">decimal(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">decimal(1/3, 2)\n// .33\n\ndecimal(1.5, 0)\n// 2\n</code></pre>\n'},{name:"floor(n)",description:'<p>Rounds the given value with rounding mode flooring.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">floor(n: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">floor(1.5)\n// 1\n\nfloor(-1.5)\n// -2\n</code></pre>\n'},{name:"floor(n, scale)",description:'<p>Rounds the given value with rounding mode flooring at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">floor(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">floor(-1.56, 1)\n// -1.6\n</code></pre>\n'},{name:"ceiling(n)",description:'<p>Rounds the given value with rounding mode ceiling.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">ceiling(n: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">ceiling(1.5)\n// 2\n\nceiling(-1.5)\n// -1\n</code></pre>\n'},{name:"ceiling(n, scale)",description:'<p>Rounds the given value with rounding mode ceiling at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">ceiling(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">ceiling(-1.56, 1)\n// -1.5\n</code></pre>\n'},{name:"round up(n, scale)",description:'<p>Rounds the given value with the rounding mode round-up at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">round up(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">round up(5.5)\n// 6\n\nround up(-5.5)\n// -6\n\nround up(1.121, 2)\n// 1.13\n\nround up(-1.126, 2)\n// -1.13\n</code></pre>\n'},{name:"round down(n, scale)",description:'<p>Rounds the given value with the rounding mode round-down at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">round down(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">round down(5.5, 0)\n// 5\n\nround down (-5.5, 0)\n// -5\n\nround down (1.121, 2)\n// 1.12\n\nround down (-1.126, 2)\n// -1.12\n</code></pre>\n'},{name:"round half up(n, scale)",description:'<p>Rounds the given value with the rounding mode round-half-up at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">round half up(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">round half up(5.5, 0)\n// 6\n\nround half up(-5.5, 0)\n// -6\n\nround half up(1.121, 2)\n// 1.12\n\nround half up(-1.126, 2)\n// -1.13\n</code></pre>\n'},{name:"round half down(n, scale)",description:'<p>Rounds the given value with the rounding mode round-half-down at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">round half down(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">round half down (5.5, 0)\n// 5\n\nround half down (-5.5, 0)\n// -5\n\nround half down (1.121, 2)\n// 1.12\n\nround half down (-1.126, 2)\n// -1.13\n</code></pre>\n'},{name:"abs(number)",description:'<p>Returns the absolute value of the given numeric value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">abs(number: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">abs(10)\n// 10\n\nabs(-10)\n// 10\n</code></pre>\n'},{name:"modulo(dividend, divisor)",description:'<p>Returns the remainder of the division of dividend by divisor.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">modulo(dividend: number, divisor: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">modulo(12, 5)\n// 2\n</code></pre>\n'},{name:"sqrt(number)",description:'<p>Returns the square root of the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sqrt(number: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sqrt(16)\n// 4\n</code></pre>\n'},{name:"log(number)",description:'<p>Returns the natural logarithm (base e) of the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">log(number: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">log(10)\n// 2.302585092994046\n</code></pre>\n'},{name:"exp(number)",description:'<p>Returns the Euler’s number e raised to the power of the given number .</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">exp(number: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">exp(5)\n// 148.4131591025766\n</code></pre>\n'},{name:"odd(number)",description:'<p>Returns <code>true</code> if the given value is odd. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">odd(number: number): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">odd(5)\n// true\n\nodd(2)\n// false\n</code></pre>\n'},{name:"even(number)",description:'<p>Returns <code>true</code> if the given is even. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">even(number: number): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">even(5)\n// false\n\neven(2)\n// true\n</code></pre>\n'},{name:"random number()",description:'<p><em>Camunda Extension</em></p>\n<p>Returns a random number between <code>0</code> and <code>1</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">random number(): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">random number()\n// 0.9701618132579795\n</code></pre>\n'},{name:"before(point1, point2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">before(point1: Any, point2: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">before(1, 10)\n// true\n\nbefore(10, 1)\n// false\n</code></pre>\n'},{name:"before(range, point)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">before(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">before([1..5], 10)\n// true\n</code></pre>\n'},{name:"before(point, range)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">before(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">before(1, [2..5])\n// true\n</code></pre>\n'},{name:"before(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">before(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">before([1..5], [6..10])\n// true\n\nbefore([1..5),[5..10])\n// true\n</code></pre>\n'},{name:"after(point1, point2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">after(point1: Any, point2: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">after(10, 1)\n// true\n\nafter(1, 10)\n// false\n</code></pre>\n'},{name:"after(range, point)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">after(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">after([1..5], 10)\n// false\n</code></pre>\n'},{name:"after(point, range)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">after(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">after(12, [2..5])\n// true\n</code></pre>\n'},{name:"after(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">after(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">after([6..10], [1..5])\n// true\n\nafter([5..10], [1..5))\n// true\n</code></pre>\n'},{name:"meets(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">meets(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">meets([1..5], [5..10])\n// true\n\nmeets([1..3], [4..6])\n// false\n\nmeets([1..3], [3..5])\n// true\n\nmeets([1..5], (5..8])\n// false\n</code></pre>\n'},{name:"met by(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">met by(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">met by([5..10], [1..5])\n// true\n\nmet by([3..4], [1..2])\n// false\n\nmet by([3..5], [1..3])\n// true\n\nmet by((5..8], [1..5))\n// false\n\nmet by([5..10], [1..5))\n// false\n</code></pre>\n'},{name:"overlaps(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">overlaps(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">overlaps([5..10], [1..6])\n// true\n\noverlaps((3..7], [1..4])\n// true\n\noverlaps([1..3], (3..6])\n// false\n\noverlaps((5..8], [1..5))\n// false\n\noverlaps([4..10], [1..5))\n// true\n</code></pre>\n'},{name:"overlaps before(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">overlaps before(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">overlaps before([1..5], [4..10])\n// true\n\noverlaps before([3..4], [1..2])\n// false\n\noverlaps before([1..3], (3..5])\n// false\n\noverlaps before([1..5), (3..8])\n// true\n\noverlaps before([1..5), [5..10])\n// false\n</code></pre>\n'},{name:"overlaps after(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">overlaps after(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">overlaps after([4..10], [1..5])\n// true\n\noverlaps after([3..4], [1..2])\n// false\n\noverlaps after([3..5], [1..3))\n// false\n\noverlaps after((5..8], [1..5))\n// false\n\noverlaps after([4..10], [1..5))\n// true\n</code></pre>\n'},{name:"finishes(point, range)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">finishes(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">finishes(5, [1..5])\n// true\n\nfinishes(10, [1..7])\n// false\n</code></pre>\n'},{name:"finishes(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">finishes(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">finishes([3..5], [1..5])\n// true\n\nfinishes((1..5], [1..5))\n// false\n\nfinishes([5..10], [1..10))\n// false\n</code></pre>\n'},{name:"finished by(range, point)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">finished by(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">finished by([5..10], 10)\n// true\n\nfinished by([3..4], 2)\n// false\n</code></pre>\n'},{name:"finished by(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">finished by(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">finished by([1..5], [3..5])\n// true\n\nfinished by((5..8], [1..5))\n// false\n\nfinished by([5..10], (1..10))\n// false\n</code></pre>\n'},{name:"includes(range, point)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">includes(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">includes([5..10], 6)\n// true\n\nincludes([3..4], 5)\n// false\n</code></pre>\n'},{name:"includes(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">includes(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">includes([1..10], [4..6])\n// true\n\nincludes((5..8], [1..5))\n// false\n\nincludes([1..10], [1..5))\n// true\n</code></pre>\n'},{name:"during(point, range)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">during(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">during(5, [1..10])\n// true\n\nduring(12, [1..10])\n// false\n\nduring(1, (1..10])\n// false\n</code></pre>\n'},{name:"during(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">during(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">during([4..6], [1..10))\n// true\n\nduring((1..5], (1..10])\n// true\n</code></pre>\n'},{name:"starts(point, range)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">starts(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">starts(1, [1..5])\n// true\n\nstarts(1, (1..8])\n// false\n</code></pre>\n'},{name:"starts(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">starts(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">starts((1..5], [1..5])\n// false\n\nstarts([1..10], [1..5])\n// false\n\nstarts((1..5), (1..10))\n// true\n</code></pre>\n'},{name:"started by(range, point)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">started by(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">started by([1..10], 1)\n// true\n\nstarted by((1..10], 1)\n// false\n</code></pre>\n'},{name:"started by(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">started by(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">started by([1..10], [1..5])\n// true\n\nstarted by((1..10], [1..5))\n// false\n\nstarted by([1..10], [1..10))\n// true\n</code></pre>\n'},{name:"coincides(point1, point2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">coincides(point1: Any, point2: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">coincides(5, 5)\n// true\n\ncoincides(3, 4)\n// false\n</code></pre>\n'},{name:"coincides(range1, range2)",description:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">coincides(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">coincides([1..5], [1..5])\n// true\n\ncoincides((1..5], [1..5))\n// false\n\ncoincides([1..5], [2..6])\n// false\n</code></pre>\n'},{name:"substring(string, start position)",description:'<p>Returns a substring of the given value starting at <code>start position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">substring(string: string, start position: number): string\n</code></pre>\n<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">substring("foobar", 3)\n// "obar"\n\nsubstring("foobar", -2)\n// "ar"\n</code></pre>\n'},{name:"substring(string, start position, length)",description:'<p>Returns a substring of the given value, starting at <code>start position</code> with the given <code>length</code>. If <code>length</code> is greater than\nthe remaining characters of the value, it returns all characters from <code>start position</code> until the end.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">substring(string: string, start position: number, length: number): string\n</code></pre>\n<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">substring("foobar", 3, 3)\n// "oba"\n\nsubstring("foobar", -3, 2)\n// "ba"\n\nsubstring("foobar", 3, 10)\n// "obar"\n</code></pre>\n'},{name:"string length(string)",description:'<p>Returns the number of characters in the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string length(string: string): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string length("foo")\n// 3\n</code></pre>\n'},{name:"upper case(string)",description:'<p>Returns the given value with all characters are uppercase.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">upper case(string: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">upper case("aBc4")\n// "ABC4"\n</code></pre>\n'},{name:"lower case(string)",description:'<p>Returns the given value with all characters are lowercase.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">lower case(string: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">lower case("aBc4")\n// "abc4"\n</code></pre>\n'},{name:"substring before(string, match)",description:'<p>Returns a substring of the given value that contains all characters before <code>match</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">substring before(string: string, match: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">substring before("foobar", "bar")\n// "foo"\n</code></pre>\n'},{name:"substring after(string, match)",description:'<p>Returns a substring of the given value that contains all characters after <code>match</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">substring after(string: string, match: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">substring after("foobar", "ob")\n// "ar"\n</code></pre>\n'},{name:"contains(string, match)",description:'<p>Returns <code>true</code> if the given value contains the substring <code>match</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">contains(string: string, match: string): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">contains("foobar", "of")\n// false\n</code></pre>\n'},{name:"starts with(string, match)",description:'<p>Returns <code>true</code> if the given value starts with the substring <code>match</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">starts with(string: string, match: string): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">starts with("foobar", "fo")\n// true\n</code></pre>\n'},{name:"ends with(string, match)",description:'<p>Returns <code>true</code> if the given value ends with the substring <code>match</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">ends with(string: string, match: string): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">ends with("foobar", "r")\n// true\n</code></pre>\n'},{name:"matches(input, pattern)",description:'<p>Returns <code>true</code> if the given value matches the <code>pattern</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">matches(input: string, pattern: string): boolean\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">matches("foobar", "^fo*bar")\n// true\n</code></pre>\n'},{name:"matches(input, pattern, flags)",description:'<p>Returns <code>true</code> if the given value matches the <code>pattern</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">matches(input: string, pattern: string, flags: string): boolean\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p>The <code>flags</code> can contain one or more of the following characters:</p>\n<ul>\n<li><code>s</code> (dot-all)</li>\n<li><code>m</code> (multi-line)</li>\n<li><code>i</code> (case insensitive)</li>\n<li><code>x</code> (comments)</li>\n</ul>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">matches("FooBar", "foo", "i")\n// true\n</code></pre>\n'},{name:"replace(input, pattern, replacement)",description:'<p>Returns the resulting string after replacing all occurrences of <code>pattern</code> with <code>replacement</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">replace(input: string, pattern: string, replacement: string): string\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p>The <code>replacement</code> can access the match groups by using <code>$</code> and the number of the group, for example,\n<code>$1</code> to access the first group.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">replace("abcd", "(ab)|(a)", "[1=$1][2=$2]")\n// "[1=ab][2=]cd"\n\nreplace("0123456789", "(\\d{3})(\\d{3})(\\d{4})", "($1) $2-$3")\n// "(012) 345-6789"\n</code></pre>\n'},{name:"replace(input, pattern, replacement, flags)",description:'<p>Returns the resulting string after replacing all occurrences of <code>pattern</code> with <code>replacement</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">replace(input: string, pattern: string, replacement: string, flags: string): string\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p>The <code>replacement</code> can access the match groups by using <code>$</code> and the number of the group, for example,\n<code>$1</code> to access the first group.</p>\n<p>The <code>flags</code> can contain one or more of the following characters:</p>\n<ul>\n<li><code>s</code> (dot-all)</li>\n<li><code>m</code> (multi-line)</li>\n<li><code>i</code> (case insensitive)</li>\n<li><code>x</code> (comments)</li>\n</ul>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">replace("How do you feel?", "Feel", "FEEL", "i")\n// "How do you FEEL?"\n</code></pre>\n'},{name:"split(string, delimiter)",description:'<p>Splits the given value into a list of substrings, breaking at each occurrence of the <code>delimiter</code> pattern.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">split(string: string, delimiter: string): list<string>\n</code></pre>\n<p>The <code>delimiter</code> is a string that contains a regular expression.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">split("John Doe", "\\s" )\n// ["John", "Doe"]\n\nsplit("a;b;c;;", ";")\n// ["a", "b", "c", "", ""]\n</code></pre>\n'},{name:"extract(string, pattern)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns all matches of the pattern in the given string. Returns an empty list if the pattern doesn't\nmatch.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">extract(string: string, pattern: string): list<string>\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">extract("references are 1234, 1256, 1378", "12[0-9]*")\n// ["1234","1256"]\n</code></pre>\n'},{name:"trim(string)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns the given string without leading and trailing spaces.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">trim(string: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">trim(" hello world ")\n// "hello world"\n\ntrim("hello world ")\n// "hello world"\n</code></pre>\n'},{name:"uuid()",description:'<p><em>Camunda Extension</em></p>\n<p>Returns a UUID (Universally Unique Identifier) with 36 characters.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">uuid(): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">uuid()\n// "7793aab1-d761-4d38-916b-b7270e309894"\n</code></pre>\n'},{name:"to base64(value)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns the given string encoded in Base64 format.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">to base64(value: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">to base64("FEEL")\n// "RkVFTA=="\n</code></pre>\n'},{name:"is blank(string)",description:'<p><em>Camunda Extension</em></p>\n<p>Returns <code>true</code> if the given string is blank (empty or contains only whitespaces).</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">is blank(string: string): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">is blank("")\n// true\n\nis blank(" ")\n// true\n\nis blank("hello world")\n// false\n</code></pre>\n'},{name:"now()",description:'<p>Returns the current date and time including the timezone.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">now(): date and time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">now()\n// date and time("2020-07-31T14:27:30@Europe/Berlin")\n</code></pre>\n'},{name:"today()",description:'<p>Returns the current date.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">today(): date\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">today()\n// date("2020-07-31")\n</code></pre>\n'},{name:"day of week(date)",description:'<p>Returns the day of the week according to the Gregorian calendar. Note that it always returns the English name of the day.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">day of week(date: date): string\n</code></pre>\n<pre><code class="language-feel">day of week(date: date and time): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">day of week(date("2019-09-17"))\n// "Tuesday"\n\nday of week(date and time("2019-09-17T12:00:00"))\n// "Tuesday"\n</code></pre>\n'},{name:"day of year(date)",description:'<p>Returns the Gregorian number of the day within the year.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">day of year(date: date): number\n</code></pre>\n<pre><code class="language-feel">day of year(date: date and time): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">day of year(date("2019-09-17"))\n// 260\n\nday of year(date and time("2019-09-17T12:00:00"))\n// 260\n</code></pre>\n'},{name:"week of year(date)",description:'<p>Returns the Gregorian number of the week within the year, according to ISO 8601.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">week of year(date: date): number\n</code></pre>\n<pre><code class="language-feel">week of year(date: date and time): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">week of year(date("2019-09-17"))\n// 38\n\nweek of year(date and time("2019-09-17T12:00:00"))\n// 38\n</code></pre>\n'},{name:"month of year(date)",description:'<p>Returns the month of the year according to the Gregorian calendar. Note that it always returns the English name of the month.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">month of year(date: date): string\n</code></pre>\n<pre><code class="language-feel">month of year(date: date and time): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">month of year(date("2019-09-17"))\n// "September"\n\nmonth of year(date and time("2019-09-17T12:00:00"))\n// "September"\n</code></pre>\n'},{name:"abs(n)",description:'<p>Returns the absolute value of a given duration.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">abs(n: days and time duration): days and time duration\n</code></pre>\n<pre><code class="language-feel">abs(n: years and months duration): years and months duration\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">abs(duration("-PT5H"))\n// "duration("PT5H")"\n\nabs(duration("PT5H"))\n// "duration("PT5H")"\n\nabs(duration("-P2M"))\n// duration("P2M")\n</code></pre>\n'},{name:"last day of month(date)",description:'<p><em>Camunda Extension</em></p>\n<p>Takes the month of the given date or date-time value and returns the last day of this month.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">last day of month(date: date): date\n</code></pre>\n<pre><code class="language-feel">last day of month(date: date and time): date\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">last day of month(date("2022-10-01"))\n// date("2022-10-31"))\n\nlast day of month(date and time("2022-10-16T12:00:00"))\n// date("2022-10-31"))\n</code></pre>\n'}].map(lm);(class extends el{constructor(e){super(),this._modeling=e}setText(e,t){this._modeling.updateProperties(e,{text:t})}}).$inject=["modeling"];function cm(e){e.stopPropagation()}(class extends oo{constructor(e,t){super(e,t),Ps(this);const{value:n}=e;this.state={value:n,optionsVisible:!1},this._portalEl=null}componentDidMount(){document.addEventListener("mousedown",this.onGlobalClick),document.addEventListener("focusin",this.onFocusChanged),this.keyboard.addListener(this.onKeyboard)}componentWillUnmount(){document.removeEventListener("focusin",this.onFocusChanged),document.removeEventListener("mousedown",this.onGlobalClick),this.keyboard.removeListener(this.onKeyboard),this.removePortalEl()}componentWillReceiveProps(e){const{value:t}=e;this.setState({value:t})}componentWillUpdate(e,t){const{optionsVisible:n}=t;n?this._portalEl||this.addPortalEl():this._portalEl&&this.removePortalEl()}componentDidUpdate(){const{optionsVisible:e}=this.state;if(!e||!this.inputNode)return;const t=this.getOptionsBounds();b(this._portalEl.style,t)}getOptionsBounds(){const e=this.renderer.getContainer(),{top:t,left:n,bottom:i}=e.getBoundingClientRect(),{top:r,left:o,width:s,height:a,bottom:l}=this.inputNode.getBoundingClientRect(),c=r+a-t+e.scrollTop,h={top:`${c}px`,left:`${o-n+e.scrollLeft}px`,width:`${s}px`,"max-height":`calc(100% - ${c}px)`};if(i-l<a){const e=i-r;h.bottom=`${e}px`,h["max-height"]=`calc(100% - ${e})`,delete h.top}return h}addPortalEl(){this._portalEl=Lt('<div class="dms-select-options"></div>');this.renderer.getContainer().appendChild(this._portalEl),this._portalEl.addEventListener("mousedown",cm)}removePortalEl(){this._portalEl&&(this._portalEl.removeEventListener("mousedown",cm),Ft(this._portalEl),this._portalEl=null)}onChange=e=>{this.setState({value:e});const{onChange:t}=this.props;"function"==typeof t&&t(e)};onInputClick=e=>{e.preventDefault(),e.stopPropagation(),this.setOptionsVisible(!this.state.optionsVisible),this.focusInput()};onInput=e=>{const{value:t}=e.target;this.onChange(t)};onOptionClick=(e,t)=>{t.preventDefault(),t.stopPropagation(),this.setOptionsVisible(!1),this.onChange(e),this.focusInput()};focusInput(){const e=this.inputNode;e.focus(),"selectionStart"in e&&(e.selectionStart=1e5)}checkClose(e){!this._portalEl||this._portalEl.contains(e)||this.parentNode.contains(e)||this.setOptionsVisible(!1)}onFocusChanged=e=>{this.checkClose(e.target)};onGlobalClick=e=>{this.checkClose(e.target)};select(e){const{options:t}=this.props,{value:n}=this.state;if(!t)return;const i=t.filter((e=>e.value===n))[0],r=i?t.indexOf(i):-1,o=-1===r?1===e?0:t.length-1:(r+e)%t.length,s=t[o<0?t.length+o:o];this.onChange(s.value)}setOptionsVisible(e){this.setState({optionsVisible:e})}onKeyDown=e=>{const{optionsVisible:t}=this.state;var n=e.which;40!==n&&38!==n||(e.stopPropagation(),e.preventDefault(),t?this.select(40===n?1:-1):this.setOptionsVisible(!0)),t&&(13!==n&&27!==n||(e.stopPropagation(),e.preventDefault(),this.setOptionsVisible(!1)))};onKeyboard=e=>{const{optionsVisible:t}=this.state;if(t)return 27===e?(this.setOptionsVisible(!1),!0):void 0};renderOptions(e,t){return zi(1,"div","options",e.map((e=>zi(1,"div",["option",t===e?"active":""].join(" "),e.label,0,{"data-value":e.value,onClick:t=>this.onOptionClick(e.value,t)}))),0)}render(){const{className:e,label:t,id:n,options:i,noInput:r,title:o}=this.props,{optionsVisible:s,value:a}=this.state,l=!!i&&i.filter((e=>e.value===a))[0],c=l?l.label:a;return zi(1,"div",[e||"","dms-input-select"].join(" "),[r?zi(1,"div","dms-input",c,0,{"aria-label":t,tabIndex:"0",onKeyDown:this.onKeyDown},null,(e=>this.inputNode=e)):zi(64,"input","dms-input",null,1,{"aria-label":t,onInput:this.onInput,onKeyDown:this.onKeyDown,spellCheck:"false",type:"text",value:a,id:n},null,(e=>this.inputNode=e)),zi(1,"span",["dms-input-select-icon",s?"dmn-icon-up":"dmn-icon-down"].join(" ")),s&&(h=this.renderOptions(i,l),u=this._portalEl,zi(1024,u,null,h,0,null,Ai(h)?null:h.key,null))],0,{title:o,onClick:this.onInputClick},null,(e=>this.parentNode=e));var h,u}}).$inject=["keyboard","renderer"];return class extends $t{_getViewProviders(){return[{id:"drd",constructor:fs,opens(e){return yi(e,"dmn:Definitions")&&((t=e).dmnDI&&t.dmnDI.diagrams&&t.dmnDI.diagrams[0]);var t}},{id:"decisionTable",constructor:Sa,opens:e=>yi(e,"dmn:Decision")&&yi(e.decisionLogic,"dmn:DecisionTable")},{id:"literalExpression",constructor:Ua,opens:e=>yi(e,"dmn:Decision")&&yi(e.decisionLogic,"dmn:LiteralExpression")},{id:"boxedExpression",constructor:bl,opens:e=>yi(e,"dmn:BusinessKnowledgeModel")&&wi(e)}]}}})); function
|
/plugin/jplayer/vendor/happyworm/jplayer/lib/aurora/ |
H A D | ogg.js | 6 …((Ea(a)|0)==0){i=b;return a|0}else{oa(1040,1072,17,1088)}return 0}function Oa(a,b,d,e){a=a|0;b=b|0… function 12 …n{_strlen:cb,_free:Ra,_AVOggDestroy:Pa,_AVOggInit:Na,_i64Add:Za,_AVOggRead:Oa,_realloc:Ta,_memset:…
|
H A D | vorbis.js | 10 …ion Cg(a,b){a=a|0;b=b|0;fa(49,a|0,b|0)}function Dg(a,b){a=a|0;b=b|0;return Oa[a&127](b|0)|0}functi… 16 …,ql,ql,ql,ql,ql,ql,ql,ql,ql,ql,ql,ql,ql,ql,ql,ql,ql,ql,ql,ql,ql,ql,ql];var Oa=[rl,rl,Eg,rl,Fg,rl,G…
|
/plugin/stlviewer/stlviewer/ |
H A D | three.min.js | 2 !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).THREE={})}(this,(function(t){"use strict";void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}),void 0===Math.sign&&(Math.sign=function(t){return t<0?-1:t>0?1:+t}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var r=arguments[n];if(null!=r)for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e});var e=100,n=300,r=301,i=302,a=303,o=304,s=306,c=307,l=1e3,u=1001,h=1002,d=1003,p=1004,f=1005,m=1006,v=1007,g=1008,y=1009,x=1012,_=1014,b=1015,w=1016,M=1020,S=1022,T=1023,E=1026,A=1027,L=33776,R=33777,C=33778,P=33779,I=35840,D=35841,O=35842,N=35843,B=37492,z=37496,G=2300,F=2301,U=2302,H=2400,k=2401,V=2402,W=2500,j=2501,q=3e3,X=3001,Y=3007,Z=3002,J=3004,Q=3005,K=3006,$=7680,tt=35044,et=35048,nt="300 es";function rt(){}Object.assign(rt.prototype,{addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});var n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;var n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)},removeEventListener:function(t,e){if(void 0!==this._listeners){var n=this._listeners[t];if(void 0!==n){var r=n.indexOf(e);-1!==r&&n.splice(r,1)}}},dispatchEvent:function(t){if(void 0!==this._listeners){var e=this._listeners[t.type];if(void 0!==e){t.target=this;for(var n=e.slice(0),r=0,i=n.length;r<i;r++)n[r].call(this,t)}}}});for(var it=[],at=0;at<256;at++)it[at]=(at<16?"0":"")+at.toString(16);var ot=1234567,st={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(it[255&t]+it[t>>8&255]+it[t>>16&255]+it[t>>24&255]+"-"+it[255&e]+it[e>>8&255]+"-"+it[e>>16&15|64]+it[e>>24&255]+"-"+it[63&n|128]+it[n>>8&255]+"-"+it[n>>16&255]+it[n>>24&255]+it[255&r]+it[r>>8&255]+it[r>>16&255]+it[r>>24&255]).toUpperCase()},clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)},lerp:function(t,e,n){return(1-n)*t+n*e},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return void 0!==t&&(ot=t%2147483647),((ot=16807*ot%2147483647)-1)/2147483646},degToRad:function(t){return t*st.DEG2RAD},radToDeg:function(t){return t*st.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,r,i){var a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((e+r)/2),u=o((e+r)/2),h=a((e-r)/2),d=o((e-r)/2),p=a((r-e)/2),f=o((r-e)/2);switch(i){case"XYX":t.set(s*u,c*h,c*d,s*l);break;case"YZY":t.set(c*d,s*u,c*h,s*l);break;case"ZXZ":t.set(c*h,c*d,s*u,s*l);break;case"XZX":t.set(s*u,c*f,c*p,s*l);break;case"YXY":t.set(c*p,s*u,c*f,s*l);break;case"ZYZ":t.set(c*f,c*p,s*u,s*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}};function ct(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function lt(t,e,n){return e&&ct(t.prototype,e),n&&ct(t,n),t}function ut(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function ht(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var dt,pt=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),Object.defineProperty(this,"isVector2",{value:!0}),this.x=t,this.y=e}var e=t.prototype;return e.set=function(t,e){return this.x=t,this.y=e,this},e.setScalar=function(t){return this.x=t,this.y=t,this},e.setX=function(t){return this.x=t,this},e.setY=function(t){return this.y=t,this},e.setComponent=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},e.getComponent=function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},e.clone=function(){return new this.constructor(this.x,this.y)},e.copy=function(t){return this.x=t.x,this.y=t.y,this},e.add=function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},e.addScalar=function(t){return this.x+=t,this.y+=t,this},e.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},e.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},e.sub=function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},e.subScalar=function(t){return this.x-=t,this.y-=t,this},e.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},e.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},e.multiplyScalar=function(t){return this.x*=t,this.y*=t,this},e.divide=function(t){return this.x/=t.x,this.y/=t.y,this},e.divideScalar=function(t){return this.multiplyScalar(1/t)},e.applyMatrix3=function(t){var e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this},e.min=function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},e.max=function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},e.clamp=function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},e.clampScalar=function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this},e.clampLength=function(t,e){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))},e.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},e.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},e.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},e.roundToZero=function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},e.negate=function(){return this.x=-this.x,this.y=-this.y,this},e.dot=function(t){return this.x*t.x+this.y*t.y},e.cross=function(t){return this.x*t.y-this.y*t.x},e.lengthSq=function(){return this.x*this.x+this.y*this.y},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)},e.normalize=function(){return this.divideScalar(this.length()||1)},e.angle=function(){var t=Math.atan2(-this.y,-this.x)+Math.PI;return t},e.distanceTo=function(t){return Math.sqrt(this.distanceToSquared(t))},e.distanceToSquared=function(t){var e=this.x-t.x,n=this.y-t.y;return e*e+n*n},e.manhattanDistanceTo=function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},e.setLength=function(t){return this.normalize().multiplyScalar(t)},e.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},e.lerpVectors=function(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this},e.equals=function(t){return t.x===this.x&&t.y===this.y},e.fromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},e.toArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},e.fromBufferAttribute=function(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},e.rotateAround=function(t,e){var n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,a=this.y-t.y;return this.x=i*n-a*r+t.x,this.y=i*r+a*n+t.y,this},e.random=function(){return this.x=Math.random(),this.y=Math.random(),this},lt(t,[{key:"width",get:function(){return this.x},set:function(t){this.x=t}},{key:"height",get:function(){return this.y},set:function(t){this.y=t}}]),t}(),ft=function(){function t(){Object.defineProperty(this,"isMatrix3",{value:!0}),this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}var e=t.prototype;return e.set=function(t,e,n,r,i,a,o,s,c){var l=this.elements;return l[0]=t,l[1]=r,l[2]=o,l[3]=e,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this},e.identity=function(){return this.set(1,0,0,0,1,0,0,0,1),this},e.clone=function(){return(new this.constructor).fromArray(this.elements)},e.copy=function(t){var e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this},e.extractBasis=function(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this},e.setFromMatrix4=function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},e.multiply=function(t){return this.multiplyMatrices(this,t)},e.premultiply=function(t){return this.multiplyMatrices(t,this)},e.multiplyMatrices=function(t,e){var n=t.elements,r=e.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],h=n[2],d=n[5],p=n[8],f=r[0],m=r[3],v=r[6],g=r[1],y=r[4],x=r[7],_=r[2],b=r[5],w=r[8];return i[0]=a*f+o*g+s*_,i[3]=a*m+o*y+s*b,i[6]=a*v+o*x+s*w,i[1]=c*f+l*g+u*_,i[4]=c*m+l*y+u*b,i[7]=c*v+l*x+u*w,i[2]=h*f+d*g+p*_,i[5]=h*m+d*y+p*b,i[8]=h*v+d*x+p*w,this},e.multiplyScalar=function(t){var e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this},e.determinant=function(){var t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8];return e*a*l-e*o*c-n*i*l+n*o*s+r*i*c-r*a*s},e.getInverse=function(t,e){void 0!==e&&console.warn("THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.");var n=t.elements,r=this.elements,i=n[0],a=n[1],o=n[2],s=n[3],c=n[4],l=n[5],u=n[6],h=n[7],d=n[8],p=d*c-l*h,f=l*u-d*s,m=h*s-c*u,v=i*p+a*f+o*m;if(0===v)return this.set(0,0,0,0,0,0,0,0,0);var g=1/v;return r[0]=p*g,r[1]=(o*h-d*a)*g,r[2]=(l*a-o*c)*g,r[3]=f*g,r[4]=(d*i-o*u)*g,r[5]=(o*s-l*i)*g,r[6]=m*g,r[7]=(a*u-h*i)*g,r[8]=(c*i-a*s)*g,this},e.transpose=function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},e.getNormalMatrix=function(t){return this.setFromMatrix4(t).getInverse(this).transpose()},e.transposeIntoArray=function(t){var e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this},e.setUvTransform=function(t,e,n,r,i,a,o){var s=Math.cos(i),c=Math.sin(i);this.set(n*s,n*c,-n*(s*a+c*o)+a+t,-r*c,r*s,-r*(-c*a+s*o)+o+e,0,0,1)},e.scale=function(t,e){var n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=e,n[4]*=e,n[7]*=e,this},e.rotate=function(t){var e=Math.cos(t),n=Math.sin(t),r=this.elements,i=r[0],a=r[3],o=r[6],s=r[1],c=r[4],l=r[7];return r[0]=e*i+n*s,r[3]=e*a+n*c,r[6]=e*o+n*l,r[1]=-n*i+e*s,r[4]=-n*a+e*c,r[7]=-n*o+e*l,this},e.translate=function(t,e){var n=this.elements;return n[0]+=t*n[2],n[3]+=t*n[5],n[6]+=t*n[8],n[1]+=e*n[2],n[4]+=e*n[5],n[7]+=e*n[8],this},e.equals=function(t){for(var e=this.elements,n=t.elements,r=0;r<9;r++)if(e[r]!==n[r])return!1;return!0},e.fromArray=function(t,e){void 0===e&&(e=0);for(var n=0;n<9;n++)this.elements[n]=t[n+e];return this},e.toArray=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t},t}(),mt={getDataURL:function(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;var e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===dt&&(dt=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),dt.width=t.width,dt.height=t.height;var n=dt.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=dt}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}},vt=0;function gt(t,e,n,r,i,a,o,s,c,l){Object.defineProperty(this,"id",{value:vt++}),this.uuid=st.generateUUID(),this.name="",this.image=void 0!==t?t:gt.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:gt.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:u,this.wrapT=void 0!==r?r:u,this.magFilter=void 0!==i?i:m,this.minFilter=void 0!==a?a:g,this.anisotropy=void 0!==c?c:1,this.format=void 0!==o?o:T,this.internalFormat=null,this.type=void 0!==s?s:y,this.offset=new pt(0,0),this.repeat=new pt(1,1),this.center=new pt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ft,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==l?l:q,this.version=0,this.onUpdate=null}gt.DEFAULT_IMAGE=void 0,gt.DEFAULT_MAPPING=n,gt.prototype=Object.assign(Object.create(rt.prototype),{constructor:gt,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){var e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];var n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var r=this.image;if(void 0===r.uuid&&(r.uuid=st.generateUUID()),!e&&void 0===t.images[r.uuid]){var i;if(Array.isArray(r)){i=[];for(var a=0,o=r.length;a<o;a++)i.push(mt.getDataURL(r[a]))}else i=mt.getDataURL(r);t.images[r.uuid]={uuid:r.uuid,url:i}}n.image=r.uuid}return e||(t.textures[this.uuid]=n),n},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(this.mapping!==n)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case l:t.x=t.x-Math.floor(t.x);break;case u:t.x=t.x<0?0:1;break;case h:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case l:t.y=t.y-Math.floor(t.y);break;case u:t.y=t.y<0?0:1;break;case h:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}}),Object.defineProperty(gt.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}});var yt=function(){function t(t,e,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=1),Object.defineProperty(this,"isVector4",{value:!0}),this.x=t,this.y=e,this.z=n,this.w=r}var e=t.prototype;return e.set=function(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this},e.setScalar=function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},e.setX=function(t){return this.x=t,this},e.setY=function(t){return this.y=t,this},e.setZ=function(t){return this.z=t,this},e.setW=function(t){return this.w=t,this},e.setComponent=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},e.getComponent=function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},e.clone=function(){return new this.constructor(this.x,this.y,this.z,this.w)},e.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},e.add=function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},e.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},e.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},e.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},e.sub=function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},e.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},e.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},e.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},e.applyMatrix4=function(t){var e=this.x,n=this.y,r=this.z,i=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*e+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*e+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*e+a[7]*n+a[11]*r+a[15]*i,this},e.divideScalar=function(t){return this.multiplyScalar(1/t)},e.setAxisAngleFromQuaternion=function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},e.setAxisAngleFromRotationMatrix=function(t){var e,n,r,i,a=.01,o=.1,s=t.elements,c=s[0],l=s[4],u=s[8],h=s[1],d=s[5],p=s[9],f=s[2],m=s[6],v=s[10];if(Math.abs(l-h)<a&&Math.abs(u-f)<a&&Math.abs(p-m)<a){if(Math.abs(l+h)<o&&Math.abs(u+f)<o&&Math.abs(p+m)<o&&Math.abs(c+d+v-3)<o)return this.set(1,0,0,0),this;e=Math.PI;var g=(c+1)/2,y=(d+1)/2,x=(v+1)/2,_=(l+h)/4,b=(u+f)/4,w=(p+m)/4;return g>y&&g>x?g<a?(n=0,r=.707106781,i=.707106781):(r=_/(n=Math.sqrt(g)),i=b/n):y>x?y<a?(n=.707106781,r=0,i=.707106781):(n=_/(r=Math.sqrt(y)),i=w/r):x<a?(n=.707106781,r=.707106781,i=0):(n=b/(i=Math.sqrt(x)),r=w/i),this.set(n,r,i,e),this}var M=Math.sqrt((m-p)*(m-p)+(u-f)*(u-f)+(h-l)*(h-l));return Math.abs(M)<.001&&(M=1),this.x=(m-p)/M,this.y=(u-f)/M,this.z=(h-l)/M,this.w=Math.acos((c+d+v-1)/2),this},e.min=function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},e.max=function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},e.clamp=function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},e.clampScalar=function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this},e.clampLength=function(t,e){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))},e.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},e.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},e.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},e.roundToZero=function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},e.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},e.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},e.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},e.normalize=function(){return this.divideScalar(this.length()||1)},e.setLength=function(t){return this.normalize().multiplyScalar(t)},e.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},e.lerpVectors=function(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this},e.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},e.fromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},e.toArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},e.fromBufferAttribute=function(t,e,n){return void 0!==n&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this},e.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this},lt(t,[{key:"width",get:function(){return this.z},set:function(t){this.z=t}},{key:"height",get:function(){return this.w},set:function(t){this.w=t}}]),t}();function xt(t,e,n){this.width=t,this.height=e,this.scissor=new yt(0,0,t,e),this.scissorTest=!1,this.viewport=new yt(0,0,t,e),n=n||{},this.texture=new gt(void 0,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=e,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:m,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}function _t(t,e,n){xt.call(this,t,e,n),this.samples=4}xt.prototype=Object.assign(Object.create(rt.prototype),{constructor:xt,isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.texture.image.width=t,this.texture.image.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),_t.prototype=Object.assign(Object.create(xt.prototype),{constructor:_t,isWebGLMultisampleRenderTarget:!0,copy:function(t){return xt.prototype.copy.call(this,t),this.samples=t.samples,this}});var bt=function(){function t(t,e,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=1),Object.defineProperty(this,"isQuaternion",{value:!0}),this._x=t,this._y=e,this._z=n,this._w=r}t.slerp=function(t,e,n,r){return n.copy(t).slerp(e,r)},t.slerpFlat=function(t,e,n,r,i,a,o){var s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],h=i[a+0],d=i[a+1],p=i[a+2],f=i[a+3];if(u!==f||s!==h||c!==d||l!==p){var m=1-o,v=s*h+c*d+l*p+u*f,g=v>=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),_=Math.atan2(x,v*g);m=Math.sin(m*_)/x,o=Math.sin(o*_)/x}var b=o*g;if(s=s*m+h*b,c=c*m+d*b,l=l*m+p*b,u=u*m+f*b,m===1-o){var w=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=w,c*=w,l*=w,u*=w}}t[e]=s,t[e+1]=c,t[e+2]=l,t[e+3]=u},t.multiplyQuaternionsFlat=function(t,e,n,r,i,a){var o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],h=i[a+1],d=i[a+2],p=i[a+3];return t[e]=o*p+l*u+s*d-c*h,t[e+1]=s*p+l*h+c*u-o*d,t[e+2]=c*p+l*d+o*h-s*u,t[e+3]=l*p-o*u-s*h-c*d,t};var e=t.prototype;return e.set=function(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this},e.clone=function(){return new this.constructor(this._x,this._y,this._z,this._w)},e.copy=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},e.setFromEuler=function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=t._x,r=t._y,i=t._z,a=t._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),h=s(n/2),d=s(r/2),p=s(i/2);switch(a){case"XYZ":this._x=h*l*u+c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u-h*d*p;break;case"YXZ":this._x=h*l*u+c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u+h*d*p;break;case"ZXY":this._x=h*l*u-c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u-h*d*p;break;case"ZYX":this._x=h*l*u-c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u+h*d*p;break;case"YZX":this._x=h*l*u+c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u-h*d*p;break;case"XZY":this._x=h*l*u-c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u+h*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==e&&this._onChangeCallback(),this},e.setFromAxisAngle=function(t,e){var n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this},e.setFromRotationMatrix=function(t){var e=t.elements,n=e[0],r=e[4],i=e[8],a=e[1],o=e[5],s=e[9],c=e[2],l=e[6],u=e[10],h=n+o+u;if(h>0){var d=.5/Math.sqrt(h+1);this._w=.25/d,this._x=(l-s)*d,this._y=(i-c)*d,this._z=(a-r)*d}else if(n>o&&n>u){var p=2*Math.sqrt(1+n-o-u);this._w=(l-s)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(i+c)/p}else if(o>u){var f=2*Math.sqrt(1+o-n-u);this._w=(i-c)/f,this._x=(r+a)/f,this._y=.25*f,this._z=(s+l)/f}else{var m=2*Math.sqrt(1+u-n-o);this._w=(a-r)/m,this._x=(i+c)/m,this._y=(s+l)/m,this._z=.25*m}return this._onChangeCallback(),this},e.setFromUnitVectors=function(t,e){var n=t.dot(e)+1;return n<1e-6?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()},e.angleTo=function(t){return 2*Math.acos(Math.abs(st.clamp(this.dot(t),-1,1)))},e.rotateTowards=function(t,e){var n=this.angleTo(t);if(0===n)return this;var r=Math.min(1,e/n);return this.slerp(t,r),this},e.identity=function(){return this.set(0,0,0,1)},e.inverse=function(){return this.conjugate()},e.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},e.dot=function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},e.lengthSq=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},e.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},e.normalize=function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this},e.multiply=function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},e.premultiply=function(t){return this.multiplyQuaternions(t,this)},e.multiplyQuaternions=function(t,e){var n=t._x,r=t._y,i=t._z,a=t._w,o=e._x,s=e._y,c=e._z,l=e._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this},e.slerp=function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var n=this._x,r=this._y,i=this._z,a=this._w,o=a*t._w+n*t._x+r*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;var s=1-o*o;if(s<=Number.EPSILON){var c=1-e;return this._w=c*a+e*this._w,this._x=c*n+e*this._x,this._y=c*r+e*this._y,this._z=c*i+e*this._z,this.normalize(),this._onChangeCallback(),this}var l=Math.sqrt(s),u=Math.atan2(l,o),h=Math.sin((1-e)*u)/l,d=Math.sin(e*u)/l;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=r*h+this._y*d,this._z=i*h+this._z*d,this._onChangeCallback(),this},e.equals=function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},e.fromArray=function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this},e.toArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},e.fromBufferAttribute=function(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this},e._onChange=function(t){return this._onChangeCallback=t,this},e._onChangeCallback=function(){},lt(t,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onChangeCallback()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()}},{key:"w",get:function(){return this._w},set:function(t){this._w=t,this._onChangeCallback()}}]),t}(),wt=function(){function t(t,e,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),Object.defineProperty(this,"isVector3",{value:!0}),this.x=t,this.y=e,this.z=n}var e=t.prototype;return e.set=function(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this},e.setScalar=function(t){return this.x=t,this.y=t,this.z=t,this},e.setX=function(t){return this.x=t,this},e.setY=function(t){return this.y=t,this},e.setZ=function(t){return this.z=t,this},e.setComponent=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},e.getComponent=function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},e.clone=function(){return new this.constructor(this.x,this.y,this.z)},e.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},e.add=function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},e.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this},e.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},e.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},e.sub=function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},e.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this},e.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},e.multiply=function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},e.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this},e.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},e.applyEuler=function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(St.setFromEuler(t))},e.applyAxisAngle=function(t,e){return this.applyQuaternion(St.setFromAxisAngle(t,e))},e.applyMatrix3=function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this},e.applyNormalMatrix=function(t){return this.applyMatrix3(t).normalize()},e.applyMatrix4=function(t){var e=this.x,n=this.y,r=this.z,i=t.elements,a=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*a,this},e.applyQuaternion=function(t){var e=this.x,n=this.y,r=this.z,i=t.x,a=t.y,o=t.z,s=t.w,c=s*e+a*r-o*n,l=s*n+o*e-i*r,u=s*r+i*n-a*e,h=-i*e-a*n-o*r;return this.x=c*s+h*-i+l*-o-u*-a,this.y=l*s+h*-a+u*-i-c*-o,this.z=u*s+h*-o+c*-a-l*-i,this},e.project=function(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)},e.unproject=function(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)},e.transformDirection=function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()},e.divide=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},e.divideScalar=function(t){return this.multiplyScalar(1/t)},e.min=function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},e.max=function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},e.clamp=function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},e.clampScalar=function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this},e.clampLength=function(t,e){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))},e.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},e.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},e.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},e.roundToZero=function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},e.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},e.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},e.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},e.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},e.normalize=function(){return this.divideScalar(this.length()||1)},e.setLength=function(t){return this.normalize().multiplyScalar(t)},e.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},e.lerpVectors=function(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this},e.cross=function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)},e.crossVectors=function(t,e){var n=t.x,r=t.y,i=t.z,a=e.x,o=e.y,s=e.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this},e.projectOnVector=function(t){var e=t.lengthSq();if(0===e)return this.set(0,0,0);var n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)},e.projectOnPlane=function(t){return Mt.copy(this).projectOnVector(t),this.sub(Mt)},e.reflect=function(t){return this.sub(Mt.copy(t).multiplyScalar(2*this.dot(t)))},e.angleTo=function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;var n=this.dot(t)/e;return Math.acos(st.clamp(n,-1,1))},e.distanceTo=function(t){return Math.sqrt(this.distanceToSquared(t))},e.distanceToSquared=function(t){var e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r},e.manhattanDistanceTo=function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},e.setFromSpherical=function(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)},e.setFromSphericalCoords=function(t,e,n){var r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this},e.setFromCylindrical=function(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)},e.setFromCylindricalCoords=function(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this},e.setFromMatrixPosition=function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},e.setFromMatrixScale=function(t){var e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this},e.setFromMatrixColumn=function(t,e){return this.fromArray(t.elements,4*e)},e.setFromMatrix3Column=function(t,e){return this.fromArray(t.elements,3*e)},e.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},e.fromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},e.toArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},e.fromBufferAttribute=function(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this},e.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this},t}(),Mt=new wt,St=new bt,Tt=function(){function t(t,e){Object.defineProperty(this,"isBox3",{value:!0}),this.min=void 0!==t?t:new wt(1/0,1/0,1/0),this.max=void 0!==e?e:new wt(-1/0,-1/0,-1/0)}var e=t.prototype;return e.set=function(t,e){return this.min.copy(t),this.max.copy(e),this},e.setFromArray=function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.length;s<c;s+=3){var l=t[s],u=t[s+1],h=t[s+2];l<e&&(e=l),u<n&&(n=u),h<r&&(r=h),l>i&&(i=l),u>a&&(a=u),h>o&&(o=h)}return this.min.set(e,n,r),this.max.set(i,a,o),this},e.setFromBufferAttribute=function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.count;s<c;s++){var l=t.getX(s),u=t.getY(s),h=t.getZ(s);l<e&&(e=l),u<n&&(n=u),h<r&&(r=h),l>i&&(i=l),u>a&&(a=u),h>o&&(o=h)}return this.min.set(e,n,r),this.max.set(i,a,o),this},e.setFromPoints=function(t){this.makeEmpty();for(var e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this},e.setFromCenterAndSize=function(t,e){var n=Lt.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this},e.setFromObject=function(t){return this.makeEmpty(),this.expandByObject(t)},e.clone=function(){return(new this.constructor).copy(this)},e.copy=function(t){return this.min.copy(t.min),this.max.copy(t.max),this},e.makeEmpty=function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},e.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},e.getCenter=function(t){return void 0===t&&(console.warn("THREE.Box3: .getCenter() target is now required"),t=new wt),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},e.getSize=function(t){return void 0===t&&(console.warn("THREE.Box3: .getSize() target is now required"),t=new wt),this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)},e.expandByPoint=function(t){return this.min.min(t),this.max.max(t),this},e.expandByVector=function(t){return this.min.sub(t),this.max.add(t),this},e.expandByScalar=function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},e.expandByObject=function(t){t.updateWorldMatrix(!1,!1);var e=t.geometry;void 0!==e&&(null===e.boundingBox&&e.computeBoundingBox(),Rt.copy(e.boundingBox),Rt.applyMatrix4(t.matrixWorld),this.union(Rt));for(var n=t.children,r=0,i=n.length;r<i;r++)this.expandByObject(n[r]);return this},e.containsPoint=function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)},e.containsBox=function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},e.getParameter=function(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new wt),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},e.intersectsBox=function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},e.intersectsSphere=function(t){return this.clampPoint(t.center,Lt),Lt.distanceToSquared(t.center)<=t.radius*t.radius},e.intersectsPlane=function(t){var e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant},e.intersectsTriangle=function(t){if(this.isEmpty())return!1;this.getCenter(Bt),zt.subVectors(this.max,Bt),Ct.subVectors(t.a,Bt),Pt.subVectors(t.b,Bt),It.subVectors(t.c,Bt),Dt.subVectors(Pt,Ct),Ot.subVectors(It,Pt),Nt.subVectors(Ct,It);var e=[0,-Dt.z,Dt.y,0,-Ot.z,Ot.y,0,-Nt.z,Nt.y,Dt.z,0,-Dt.x,Ot.z,0,-Ot.x,Nt.z,0,-Nt.x,-Dt.y,Dt.x,0,-Ot.y,Ot.x,0,-Nt.y,Nt.x,0];return!!Et(e,Ct,Pt,It,zt)&&(!!Et(e=[1,0,0,0,1,0,0,0,1],Ct,Pt,It,zt)&&(Gt.crossVectors(Dt,Ot),Et(e=[Gt.x,Gt.y,Gt.z],Ct,Pt,It,zt)))},e.clampPoint=function(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new wt),e.copy(t).clamp(this.min,this.max)},e.distanceToPoint=function(t){return Lt.copy(t).clamp(this.min,this.max).sub(t).length()},e.getBoundingSphere=function(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(Lt).length(),t},e.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},e.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},e.applyMatrix4=function(t){return this.isEmpty()||(At[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),At[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),At[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),At[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),At[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),At[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),At[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),At[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(At)),this},e.translate=function(t){return this.min.add(t),this.max.add(t),this},e.equals=function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},t}();function Et(t,e,n,r,i){for(var a=0,o=t.length-3;a<=o;a+=3){Ft.fromArray(t,a);var s=i.x*Math.abs(Ft.x)+i.y*Math.abs(Ft.y)+i.z*Math.abs(Ft.z),c=e.dot(Ft),l=n.dot(Ft),u=r.dot(Ft);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>s)return!1}return!0}var At=[new wt,new wt,new wt,new wt,new wt,new wt,new wt,new wt],Lt=new wt,Rt=new Tt,Ct=new wt,Pt=new wt,It=new wt,Dt=new wt,Ot=new wt,Nt=new wt,Bt=new wt,zt=new wt,Gt=new wt,Ft=new wt,Ut=new Tt,Ht=function(){function t(t,e){this.center=void 0!==t?t:new wt,this.radius=void 0!==e?e:-1}var e=t.prototype;return e.set=function(t,e){return this.center.copy(t),this.radius=e,this},e.setFromPoints=function(t,e){var n=this.center;void 0!==e?n.copy(e):Ut.setFromPoints(t).getCenter(n);for(var r=0,i=0,a=t.length;i<a;i++)r=Math.max(r,n.distanceToSquared(t[i]));return this.radius=Math.sqrt(r),this},e.clone=function(){return(new this.constructor).copy(this)},e.copy=function(t){return this.center.copy(t.center),this.radius=t.radius,this},e.isEmpty=function(){return this.radius<0},e.makeEmpty=function(){return this.center.set(0,0,0),this.radius=-1,this},e.containsPoint=function(t){return t.distanceToSquared(this.center)<=this.radius*this.radius},e.distanceToPoint=function(t){return t.distanceTo(this.center)-this.radius},e.intersectsSphere=function(t){var e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e},e.intersectsBox=function(t){return t.intersectsSphere(this)},e.intersectsPlane=function(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius},e.clampPoint=function(t,e){var n=this.center.distanceToSquared(t);return void 0===e&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),e=new wt),e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e},e.getBoundingBox=function(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new Tt),this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)},e.applyMatrix4=function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},e.translate=function(t){return this.center.add(t),this},e.equals=function(t){return t.center.equals(this.center)&&t.radius===this.radius},t}(),kt=new wt,Vt=new wt,Wt=new wt,jt=new wt,qt=new wt,Xt=new wt,Yt=new wt,Zt=function(){function t(t,e){this.origin=void 0!==t?t:new wt,this.direction=void 0!==e?e:new wt(0,0,-1)}var e=t.prototype;return e.set=function(t,e){return this.origin.copy(t),this.direction.copy(e),this},e.clone=function(){return(new this.constructor).copy(this)},e.copy=function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},e.at=function(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new wt),e.copy(this.direction).multiplyScalar(t).add(this.origin)},e.lookAt=function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},e.recast=function(t){return this.origin.copy(this.at(t,kt)),this},e.closestPointToPoint=function(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new wt),e.subVectors(t,this.origin);var n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)},e.distanceToPoint=function(t){return Math.sqrt(this.distanceSqToPoint(t))},e.distanceSqToPoint=function(t){var e=kt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(kt.copy(this.direction).multiplyScalar(e).add(this.origin),kt.distanceToSquared(t))},e.distanceSqToSegment=function(t,e,n,r){Vt.copy(t).add(e).multiplyScalar(.5),Wt.copy(e).sub(t).normalize(),jt.copy(this.origin).sub(Vt);var i,a,o,s,c=.5*t.distanceTo(e),l=-this.direction.dot(Wt),u=jt.dot(this.direction),h=-jt.dot(Wt),d=jt.lengthSq(),p=Math.abs(1-l*l);if(p>0)if(a=l*u-h,s=c*p,(i=l*h-u)>=0)if(a>=-s)if(a<=s){var f=1/p;o=(i*=f)*(i+l*(a*=f)+2*u)+a*(l*i+a+2*h)+d}else a=c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;else a=-c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;else a<=-s?o=-(i=Math.max(0,-(-l*c+u)))*i+(a=i>0?-c:Math.min(Math.max(-c,-h),c))*(a+2*h)+d:a<=s?(i=0,o=(a=Math.min(Math.max(-c,-h),c))*(a+2*h)+d):o=-(i=Math.max(0,-(l*c+u)))*i+(a=i>0?c:Math.min(Math.max(-c,-h),c))*(a+2*h)+d;else a=l>0?-c:c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;return n&&n.copy(this.direction).multiplyScalar(i).add(this.origin),r&&r.copy(Wt).multiplyScalar(a).add(Vt),o},e.intersectSphere=function(t,e){kt.subVectors(t.center,this.origin);var n=kt.dot(this.direction),r=kt.dot(kt)-n*n,i=t.radius*t.radius;if(r>i)return null;var a=Math.sqrt(i-r),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,e):this.at(o,e)},e.intersectsSphere=function(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius},e.distanceToPlane=function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null},e.intersectPlane=function(t,e){var n=this.distanceToPlane(t);return null===n?null:this.at(n,e)},e.intersectsPlane=function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},e.intersectBox=function(t,e){var n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;return c>=0?(n=(t.min.x-h.x)*c,r=(t.max.x-h.x)*c):(n=(t.max.x-h.x)*c,r=(t.min.x-h.x)*c),l>=0?(i=(t.min.y-h.y)*l,a=(t.max.y-h.y)*l):(i=(t.max.y-h.y)*l,a=(t.min.y-h.y)*l),n>a||i>r?null:((i>n||n!=n)&&(n=i),(a<r||r!=r)&&(r=a),u>=0?(o=(t.min.z-h.z)*u,s=(t.max.z-h.z)*u):(o=(t.max.z-h.z)*u,s=(t.min.z-h.z)*u),n>s||o>r?null:((o>n||n!=n)&&(n=o),(s<r||r!=r)&&(r=s),r<0?null:this.at(n>=0?n:r,e)))},e.intersectsBox=function(t){return null!==this.intersectBox(t,kt)},e.intersectTriangle=function(t,e,n,r,i){qt.subVectors(e,t),Xt.subVectors(n,t),Yt.crossVectors(qt,Xt);var a,o=this.direction.dot(Yt);if(o>0){if(r)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}jt.subVectors(this.origin,t);var s=a*this.direction.dot(Xt.crossVectors(jt,Xt));if(s<0)return null;var c=a*this.direction.dot(qt.cross(jt));if(c<0)return null;if(s+c>o)return null;var l=-a*jt.dot(Yt);return l<0?null:this.at(l/o,i)},e.applyMatrix4=function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},e.equals=function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)},t}(),Jt=function(){function t(){Object.defineProperty(this,"isMatrix4",{value:!0}),this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}var e=t.prototype;return e.set=function(t,e,n,r,i,a,o,s,c,l,u,h,d,p,f,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=n,v[12]=r,v[1]=i,v[5]=a,v[9]=o,v[13]=s,v[2]=c,v[6]=l,v[10]=u,v[14]=h,v[3]=d,v[7]=p,v[11]=f,v[15]=m,this},e.identity=function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},e.clone=function(){return(new t).fromArray(this.elements)},e.copy=function(t){var e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this},e.copyPosition=function(t){var e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this},e.extractBasis=function(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},e.makeBasis=function(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this},e.extractRotation=function(t){var e=this.elements,n=t.elements,r=1/Qt.setFromMatrixColumn(t,0).length(),i=1/Qt.setFromMatrixColumn(t,1).length(),a=1/Qt.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},e.makeRotationFromEuler=function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,n=t.x,r=t.y,i=t.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=a*l,d=a*u,p=o*l,f=o*u;e[0]=s*l,e[4]=-s*u,e[8]=c,e[1]=d+p*c,e[5]=h-f*c,e[9]=-o*s,e[2]=f-h*c,e[6]=p+d*c,e[10]=a*s}else if("YXZ"===t.order){var m=s*l,v=s*u,g=c*l,y=c*u;e[0]=m+y*o,e[4]=g*o-v,e[8]=a*c,e[1]=a*u,e[5]=a*l,e[9]=-o,e[2]=v*o-g,e[6]=y+m*o,e[10]=a*s}else if("ZXY"===t.order){var x=s*l,_=s*u,b=c*l,w=c*u;e[0]=x-w*o,e[4]=-a*u,e[8]=b+_*o,e[1]=_+b*o,e[5]=a*l,e[9]=w-x*o,e[2]=-a*c,e[6]=o,e[10]=a*s}else if("ZYX"===t.order){var M=a*l,S=a*u,T=o*l,E=o*u;e[0]=s*l,e[4]=T*c-S,e[8]=M*c+E,e[1]=s*u,e[5]=E*c+M,e[9]=S*c-T,e[2]=-c,e[6]=o*s,e[10]=a*s}else if("YZX"===t.order){var A=a*s,L=a*c,R=o*s,C=o*c;e[0]=s*l,e[4]=C-A*u,e[8]=R*u+L,e[1]=u,e[5]=a*l,e[9]=-o*l,e[2]=-c*l,e[6]=L*u+R,e[10]=A-C*u}else if("XZY"===t.order){var P=a*s,I=a*c,D=o*s,O=o*c;e[0]=s*l,e[4]=-u,e[8]=c*l,e[1]=P*u+O,e[5]=a*l,e[9]=I*u-D,e[2]=D*u-I,e[6]=o*l,e[10]=O*u+P}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},e.makeRotationFromQuaternion=function(t){return this.compose($t,t,te)},e.lookAt=function(t,e,n){var r=this.elements;return re.subVectors(t,e),0===re.lengthSq()&&(re.z=1),re.normalize(),ee.crossVectors(n,re),0===ee.lengthSq()&&(1===Math.abs(n.z)?re.x+=1e-4:re.z+=1e-4,re.normalize(),ee.crossVectors(n,re)),ee.normalize(),ne.crossVectors(re,ee),r[0]=ee.x,r[4]=ne.x,r[8]=re.x,r[1]=ee.y,r[5]=ne.y,r[9]=re.y,r[2]=ee.z,r[6]=ne.z,r[10]=re.z,this},e.multiply=function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},e.premultiply=function(t){return this.multiplyMatrices(t,this)},e.multiplyMatrices=function(t,e){var n=t.elements,r=e.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],v=n[14],g=n[3],y=n[7],x=n[11],_=n[15],b=r[0],w=r[4],M=r[8],S=r[12],T=r[1],E=r[5],A=r[9],L=r[13],R=r[2],C=r[6],P=r[10],I=r[14],D=r[3],O=r[7],N=r[11],B=r[15];return i[0]=a*b+o*T+s*R+c*D,i[4]=a*w+o*E+s*C+c*O,i[8]=a*M+o*A+s*P+c*N,i[12]=a*S+o*L+s*I+c*B,i[1]=l*b+u*T+h*R+d*D,i[5]=l*w+u*E+h*C+d*O,i[9]=l*M+u*A+h*P+d*N,i[13]=l*S+u*L+h*I+d*B,i[2]=p*b+f*T+m*R+v*D,i[6]=p*w+f*E+m*C+v*O,i[10]=p*M+f*A+m*P+v*N,i[14]=p*S+f*L+m*I+v*B,i[3]=g*b+y*T+x*R+_*D,i[7]=g*w+y*E+x*C+_*O,i[11]=g*M+y*A+x*P+_*N,i[15]=g*S+y*L+x*I+_*B,this},e.multiplyScalar=function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},e.determinant=function(){var t=this.elements,e=t[0],n=t[4],r=t[8],i=t[12],a=t[1],o=t[5],s=t[9],c=t[13],l=t[2],u=t[6],h=t[10],d=t[14];return t[3]*(+i*s*u-r*c*u-i*o*h+n*c*h+r*o*d-n*s*d)+t[7]*(+e*s*d-e*c*h+i*a*h-r*a*d+r*c*l-i*s*l)+t[11]*(+e*c*u-e*o*d-i*a*u+n*a*d+i*o*l-n*c*l)+t[15]*(-r*o*l-e*s*u+e*o*h+r*a*u-n*a*h+n*s*l)},e.transpose=function(){var t,e=this.elements;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},e.setPosition=function(t,e,n){var r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this},e.getInverse=function(t,e){void 0!==e&&console.warn("THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.");var n=this.elements,r=t.elements,i=r[0],a=r[1],o=r[2],s=r[3],c=r[4],l=r[5],u=r[6],h=r[7],d=r[8],p=r[9],f=r[10],m=r[11],v=r[12],g=r[13],y=r[14],x=r[15],_=p*y*h-g*f*h+g*u*m-l*y*m-p*u*x+l*f*x,b=v*f*h-d*y*h-v*u*m+c*y*m+d*u*x-c*f*x,w=d*g*h-v*p*h+v*l*m-c*g*m-d*l*x+c*p*x,M=v*p*u-d*g*u-v*l*f+c*g*f+d*l*y-c*p*y,S=i*_+a*b+o*w+s*M;if(0===S)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var T=1/S;return n[0]=_*T,n[1]=(g*f*s-p*y*s-g*o*m+a*y*m+p*o*x-a*f*x)*T,n[2]=(l*y*s-g*u*s+g*o*h-a*y*h-l*o*x+a*u*x)*T,n[3]=(p*u*s-l*f*s-p*o*h+a*f*h+l*o*m-a*u*m)*T,n[4]=b*T,n[5]=(d*y*s-v*f*s+v*o*m-i*y*m-d*o*x+i*f*x)*T,n[6]=(v*u*s-c*y*s-v*o*h+i*y*h+c*o*x-i*u*x)*T,n[7]=(c*f*s-d*u*s+d*o*h-i*f*h-c*o*m+i*u*m)*T,n[8]=w*T,n[9]=(v*p*s-d*g*s-v*a*m+i*g*m+d*a*x-i*p*x)*T,n[10]=(c*g*s-v*l*s+v*a*h-i*g*h-c*a*x+i*l*x)*T,n[11]=(d*l*s-c*p*s-d*a*h+i*p*h+c*a*m-i*l*m)*T,n[12]=M*T,n[13]=(d*g*o-v*p*o+v*a*f-i*g*f-d*a*y+i*p*y)*T,n[14]=(v*l*o-c*g*o-v*a*u+i*g*u+c*a*y-i*l*y)*T,n[15]=(c*p*o-d*l*o+d*a*u-i*p*u-c*a*f+i*l*f)*T,this},e.scale=function(t){var e=this.elements,n=t.x,r=t.y,i=t.z;return e[0]*=n,e[4]*=r,e[8]*=i,e[1]*=n,e[5]*=r,e[9]*=i,e[2]*=n,e[6]*=r,e[10]*=i,e[3]*=n,e[7]*=r,e[11]*=i,this},e.getMaxScaleOnAxis=function(){var t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))},e.makeTranslation=function(t,e,n){return this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this},e.makeRotationX=function(t){var e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this},e.makeRotationY=function(t){var e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this},e.makeRotationZ=function(t){var e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this},e.makeRotationAxis=function(t,e){var n=Math.cos(e),r=Math.sin(e),i=1-n,a=t.x,o=t.y,s=t.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this},e.makeScale=function(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this},e.makeShear=function(t,e,n){return this.set(1,e,n,0,t,1,n,0,t,e,1,0,0,0,0,1),this},e.compose=function(t,e,n){var r=this.elements,i=e._x,a=e._y,o=e._z,s=e._w,c=i+i,l=a+a,u=o+o,h=i*c,d=i*l,p=i*u,f=a*l,m=a*u,v=o*u,g=s*c,y=s*l,x=s*u,_=n.x,b=n.y,w=n.z;return r[0]=(1-(f+v))*_,r[1]=(d+x)*_,r[2]=(p-y)*_,r[3]=0,r[4]=(d-x)*b,r[5]=(1-(h+v))*b,r[6]=(m+g)*b,r[7]=0,r[8]=(p+y)*w,r[9]=(m-g)*w,r[10]=(1-(h+f))*w,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this},e.decompose=function(t,e,n){var r=this.elements,i=Qt.set(r[0],r[1],r[2]).length(),a=Qt.set(r[4],r[5],r[6]).length(),o=Qt.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),t.x=r[12],t.y=r[13],t.z=r[14],Kt.copy(this);var s=1/i,c=1/a,l=1/o;return Kt.elements[0]*=s,Kt.elements[1]*=s,Kt.elements[2]*=s,Kt.elements[4]*=c,Kt.elements[5]*=c,Kt.elements[6]*=c,Kt.elements[8]*=l,Kt.elements[9]*=l,Kt.elements[10]*=l,e.setFromRotationMatrix(Kt),n.x=i,n.y=a,n.z=o,this},e.makePerspective=function(t,e,n,r,i,a){void 0===a&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var o=this.elements,s=2*i/(e-t),c=2*i/(n-r),l=(e+t)/(e-t),u=(n+r)/(n-r),h=-(a+i)/(a-i),d=-2*a*i/(a-i);return o[0]=s,o[4]=0,o[8]=l,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=h,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this},e.makeOrthographic=function(t,e,n,r,i,a){var o=this.elements,s=1/(e-t),c=1/(n-r),l=1/(a-i),u=(e+t)*s,h=(n+r)*c,d=(a+i)*l;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-h,o[2]=0,o[6]=0,o[10]=-2*l,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this},e.equals=function(t){for(var e=this.elements,n=t.elements,r=0;r<16;r++)if(e[r]!==n[r])return!1;return!0},e.fromArray=function(t,e){void 0===e&&(e=0);for(var n=0;n<16;n++)this.elements[n]=t[n+e];return this},e.toArray=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t},t}(),Qt=new wt,Kt=new Jt,$t=new wt(0,0,0),te=new wt(1,1,1),ee=new wt,ne=new wt,re=new wt,ie=function(){function t(e,n,r,i){void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=t.DefaultOrder),Object.defineProperty(this,"isEuler",{value:!0}),this._x=e,this._y=n,this._z=r,this._order=i}var e=t.prototype;return e.set=function(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._order=r||this._order,this._onChangeCallback(),this},e.clone=function(){return new this.constructor(this._x,this._y,this._z,this._order)},e.copy=function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this},e.setFromRotationMatrix=function(t,e,n){var r=st.clamp,i=t.elements,a=i[0],o=i[4],s=i[8],c=i[1],l=i[5],u=i[9],h=i[2],d=i[6],p=i[10];switch(e=e||this._order){case"XYZ":this._y=Math.asin(r(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-r(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(s,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,a),this._z=0);break;case"ZXY":this._x=Math.asin(r(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-r(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(r(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,a)):(this._x=0,this._y=Math.atan2(s,p));break;case"XZY":this._z=Math.asin(-r(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(s,a)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!1!==n&&this._onChangeCallback(),this},e.setFromQuaternion=function(t,e,n){return ae.makeRotationFromQuaternion(t),this.setFromRotationMatrix(ae,e,n)},e.setFromVector3=function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},e.reorder=function(t){return oe.setFromEuler(this),this.setFromQuaternion(oe,t)},e.equals=function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},e.fromArray=function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this},e.toArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},e.toVector3=function(t){return t?t.set(this._x,this._y,this._z):new wt(this._x,this._y,this._z)},e._onChange=function(t){return this._onChangeCallback=t,this},e._onChangeCallback=function(){},lt(t,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onChangeCallback()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()}},{key:"order",get:function(){return this._order},set:function(t){this._order=t,this._onChangeCallback()}}]),t}();ie.DefaultOrder="XYZ",ie.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];var ae=new Jt,oe=new bt,se=function(){function t(){this.mask=1}var e=t.prototype;return e.set=function(t){this.mask=1<<t|0},e.enable=function(t){this.mask|=1<<t|0},e.enableAll=function(){this.mask=-1},e.toggle=function(t){this.mask^=1<<t|0},e.disable=function(t){this.mask&=~(1<<t|0)},e.disableAll=function(){this.mask=0},e.test=function(t){return 0!=(this.mask&t.mask)},t}(),ce=0,le=new wt,ue=new bt,he=new Jt,de=new wt,pe=new wt,fe=new wt,me=new bt,ve=new wt(1,0,0),ge=new wt(0,1,0),ye=new wt(0,0,1),xe={type:"added"},_e={type:"removed"};function be(){Object.defineProperty(this,"id",{value:ce++}),this.uuid=st.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=be.DefaultUp.clone();var t=new wt,e=new ie,n=new bt,r=new wt(1,1,1);e._onChange((function(){n.setFromEuler(e,!1)})),n._onChange((function(){e.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Jt},normalMatrix:{value:new ft}}),this.matrix=new Jt,this.matrixWorld=new Jt,this.matrixAutoUpdate=be.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new se,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}be.DefaultUp=new wt(0,1,0),be.DefaultMatrixAutoUpdate=!0,be.prototype=Object.assign(Object.create(rt.prototype),{constructor:be,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,e){this.quaternion.setFromAxisAngle(t,e)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:function(t,e){return ue.setFromAxisAngle(t,e),this.quaternion.multiply(ue),this},rotateOnWorldAxis:function(t,e){return ue.setFromAxisAngle(t,e),this.quaternion.premultiply(ue),this},rotateX:function(t){return this.rotateOnAxis(ve,t)},rotateY:function(t){return this.rotateOnAxis(ge,t)},rotateZ:function(t){return this.rotateOnAxis(ye,t)},translateOnAxis:function(t,e){return le.copy(t).applyQuaternion(this.quaternion),this.position.add(le.multiplyScalar(e)),this},translateX:function(t){return this.translateOnAxis(ve,t)},translateY:function(t){return this.translateOnAxis(ge,t)},translateZ:function(t){return this.translateOnAxis(ye,t)},localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(t){return t.applyMatrix4(he.getInverse(this.matrixWorld))},lookAt:function(t,e,n){t.isVector3?de.copy(t):de.set(t,e,n);var r=this.parent;this.updateWorldMatrix(!0,!1),pe.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?he.lookAt(pe,de,this.up):he.lookAt(de,pe,this.up),this.quaternion.setFromRotationMatrix(he),r&&(he.extractRotation(r.matrixWorld),ue.setFromRotationMatrix(he),this.quaternion.premultiply(ue.inverse()))},add:function(t){if(arguments.length>1){for(var e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(xe)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)},remove:function(t){if(arguments.length>1){for(var e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}var n=this.children.indexOf(t);return-1!==n&&(t.parent=null,this.children.splice(n,1),t.dispatchEvent(_e)),this},clear:function(){for(var t=0;t<this.children.length;t++){var e=this.children[t];e.parent=null,e.dispatchEvent(_e)}return this.children.length=0,this},attach:function(t){return this.updateWorldMatrix(!0,!1),he.getInverse(this.matrixWorld),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),he.multiply(t.parent.matrixWorld)),t.applyMatrix4(he),t.updateWorldMatrix(!1,!1),this.add(t),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,e){if(this[t]===e)return this;for(var n=0,r=this.children.length;n<r;n++){var i=this.children[n].getObjectByProperty(t,e);if(void 0!==i)return i}},getWorldPosition:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),t=new wt),this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),t=new bt),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(pe,t,fe),t},getWorldScale:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),t=new wt),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(pe,me,t),t},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),t=new wt),this.updateWorldMatrix(!0,!1);var e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()},raycast:function(){},traverse:function(t){t(this);for(var e=this.children,n=0,r=e.length;n<r;n++)e[n].traverse(t)},traverseVisible:function(t){if(!1!==this.visible){t(this);for(var e=this.children,n=0,r=e.length;n<r;n++)e[n].traverseVisible(t)}},traverseAncestors:function(t){var e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(var e=this.children,n=0,r=e.length;n<r;n++)e[n].updateMatrixWorld(t)},updateWorldMatrix:function(t,e){var n=this.parent;if(!0===t&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===e)for(var r=this.children,i=0,a=r.length;i<a;i++)r[i].updateWorldMatrix(!1,!0)},toJSON:function(t){var e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var r={};function i(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),!0===this.castShadow&&(r.castShadow=!0),!0===this.receiveShadow&&(r.receiveShadow=!0),!1===this.visible&&(r.visible=!1),!1===this.frustumCulled&&(r.frustumCulled=!1),0!==this.renderOrder&&(r.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON()),this.isMesh||this.isLine||this.isPoints){r.geometry=i(t.geometries,this.geometry);var a=this.geometry.parameters;if(void 0!==a&&void 0!==a.shapes){var o=a.shapes;if(Array.isArray(o))for(var s=0,c=o.length;s<c;s++){var l=o[s];i(t.shapes,l)}else i(t.shapes,o)}}if(void 0!==this.material)if(Array.isArray(this.material)){for(var u=[],h=0,d=this.material.length;h<d;h++)u.push(i(t.materials,this.material[h]));r.material=u}else r.material=i(t.materials,this.material);if(this.children.length>0){r.children=[];for(var p=0;p<this.children.length;p++)r.children.push(this.children[p].toJSON(t).object)}if(e){var f=x(t.geometries),m=x(t.materials),v=x(t.textures),g=x(t.images),y=x(t.shapes);f.length>0&&(n.geometries=f),m.length>0&&(n.materials=m),v.length>0&&(n.textures=v),g.length>0&&(n.images=g),y.length>0&&(n.shapes=y)}return n.object=r,n;function x(t){var e=[];for(var n in t){var r=t[n];delete r.metadata,e.push(r)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var n=0;n<t.children.length;n++){var r=t.children[n];this.add(r.clone())}return this}});var we=new wt,Me=new wt,Se=new ft,Te=function(){function t(t,e){Object.defineProperty(this,"isPlane",{value:!0}),this.normal=void 0!==t?t:new wt(1,0,0),this.constant=void 0!==e?e:0}var e=t.prototype;return e.set=function(t,e){return this.normal.copy(t),this.constant=e,this},e.setComponents=function(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this},e.setFromNormalAndCoplanarPoint=function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},e.setFromCoplanarPoints=function(t,e,n){var r=we.subVectors(n,e).cross(Me.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this},e.clone=function(){return(new this.constructor).copy(this)},e.copy=function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},e.normalize=function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},e.negate=function(){return this.constant*=-1,this.normal.negate(),this},e.distanceToPoint=function(t){return this.normal.dot(t)+this.constant},e.distanceToSphere=function(t){return this.distanceToPoint(t.center)-t.radius},e.projectPoint=function(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new wt),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},e.intersectLine=function(t,e){void 0===e&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new wt);var n=t.delta(we),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):void 0;var i=-(t.start.dot(this.normal)+this.constant)/r;return i<0||i>1?void 0:e.copy(n).multiplyScalar(i).add(t.start)},e.intersectsLine=function(t){var e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0},e.intersectsBox=function(t){return t.intersectsPlane(this)},e.intersectsSphere=function(t){return t.intersectsPlane(this)},e.coplanarPoint=function(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new wt),t.copy(this.normal).multiplyScalar(-this.constant)},e.applyMatrix4=function(t,e){var n=e||Se.getNormalMatrix(t),r=this.coplanarPoint(we).applyMatrix4(t),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this},e.translate=function(t){return this.constant-=t.dot(this.normal),this},e.equals=function(t){return t.normal.equals(this.normal)&&t.constant===this.constant},t}(),Ee=new wt,Ae=new wt,Le=new wt,Re=new wt,Ce=new wt,Pe=new wt,Ie=new wt,De=new wt,Oe=new wt,Ne=new wt,Be=function(){function t(t,e,n){this.a=void 0!==t?t:new wt,this.b=void 0!==e?e:new wt,this.c=void 0!==n?n:new wt}t.getNormal=function(t,e,n,r){void 0===r&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new wt),r.subVectors(n,e),Ee.subVectors(t,e),r.cross(Ee);var i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)},t.getBarycoord=function(t,e,n,r,i){Ee.subVectors(r,e),Ae.subVectors(n,e),Le.subVectors(t,e);var a=Ee.dot(Ee),o=Ee.dot(Ae),s=Ee.dot(Le),c=Ae.dot(Ae),l=Ae.dot(Le),u=a*c-o*o;if(void 0===i&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),i=new wt),0===u)return i.set(-2,-1,-1);var h=1/u,d=(c*s-o*l)*h,p=(a*l-o*s)*h;return i.set(1-d-p,p,d)},t.containsPoint=function(t,e,n,r){return this.getBarycoord(t,e,n,r,Re),Re.x>=0&&Re.y>=0&&Re.x+Re.y<=1},t.getUV=function(t,e,n,r,i,a,o,s){return this.getBarycoord(t,e,n,r,Re),s.set(0,0),s.addScaledVector(i,Re.x),s.addScaledVector(a,Re.y),s.addScaledVector(o,Re.z),s},t.isFrontFacing=function(t,e,n,r){return Ee.subVectors(n,e),Ae.subVectors(t,e),Ee.cross(Ae).dot(r)<0};var e=t.prototype;return e.set=function(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this},e.setFromPointsAndIndices=function(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this},e.clone=function(){return(new this.constructor).copy(this)},e.copy=function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},e.getArea=function(){return Ee.subVectors(this.c,this.b),Ae.subVectors(this.a,this.b),.5*Ee.cross(Ae).length()},e.getMidpoint=function(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new wt),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},e.getNormal=function(e){return t.getNormal(this.a,this.b,this.c,e)},e.getPlane=function(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Te),t.setFromCoplanarPoints(this.a,this.b,this.c)},e.getBarycoord=function(e,n){return t.getBarycoord(e,this.a,this.b,this.c,n)},e.getUV=function(e,n,r,i,a){return t.getUV(e,this.a,this.b,this.c,n,r,i,a)},e.containsPoint=function(e){return t.containsPoint(e,this.a,this.b,this.c)},e.isFrontFacing=function(e){return t.isFrontFacing(this.a,this.b,this.c,e)},e.intersectsBox=function(t){return t.intersectsTriangle(this)},e.closestPointToPoint=function(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new wt);var n,r,i=this.a,a=this.b,o=this.c;Ce.subVectors(a,i),Pe.subVectors(o,i),De.subVectors(t,i);var s=Ce.dot(De),c=Pe.dot(De);if(s<=0&&c<=0)return e.copy(i);Oe.subVectors(t,a);var l=Ce.dot(Oe),u=Pe.dot(Oe);if(l>=0&&u<=l)return e.copy(a);var h=s*u-l*c;if(h<=0&&s>=0&&l<=0)return n=s/(s-l),e.copy(i).addScaledVector(Ce,n);Ne.subVectors(t,o);var d=Ce.dot(Ne),p=Pe.dot(Ne);if(p>=0&&d<=p)return e.copy(o);var f=d*c-s*p;if(f<=0&&c>=0&&p<=0)return r=c/(c-p),e.copy(i).addScaledVector(Pe,r);var m=l*p-d*u;if(m<=0&&u-l>=0&&d-p>=0)return Ie.subVectors(o,a),r=(u-l)/(u-l+(d-p)),e.copy(a).addScaledVector(Ie,r);var v=1/(m+f+h);return n=f*v,r=h*v,e.copy(i).addScaledVector(Ce,n).addScaledVector(Pe,r)},e.equals=function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)},t}(),ze={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ge={h:0,s:0,l:0},Fe={h:0,s:0,l:0};function Ue(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}function He(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function ke(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}var Ve=function(){function t(t,e,n){return Object.defineProperty(this,"isColor",{value:!0}),void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}var e=t.prototype;return e.set=function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},e.setScalar=function(t){return this.r=t,this.g=t,this.b=t,this},e.setHex=function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},e.setRGB=function(t,e,n){return this.r=t,this.g=e,this.b=n,this},e.setHSL=function(t,e,n){if(t=st.euclideanModulo(t,1),e=st.clamp(e,0,1),n=st.clamp(n,0,1),0===e)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+e):n+e-n*e,i=2*n-r;this.r=Ue(i,r,t+1/3),this.g=Ue(i,r,t),this.b=Ue(i,r,t-1/3)}return this},e.setStyle=function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var r,i=n[1],a=n[2];switch(i){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,e(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,e(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return e(r[5]),this.setHSL(o,s,c)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(t)){var l=n[1],u=l.length;if(3===u)return this.r=parseInt(l.charAt(0)+l.charAt(0),16)/255,this.g=parseInt(l.charAt(1)+l.charAt(1),16)/255,this.b=parseInt(l.charAt(2)+l.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(l.charAt(0)+l.charAt(1),16)/255,this.g=parseInt(l.charAt(2)+l.charAt(3),16)/255,this.b=parseInt(l.charAt(4)+l.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this},e.setColorName=function(t){var e=ze[t];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this},e.clone=function(){return new this.constructor(this.r,this.g,this.b)},e.copy=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},e.copyGammaToLinear=function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},e.copyLinearToGamma=function(t,e){void 0===e&&(e=2);var n=e>0?1/e:1;return this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this},e.convertGammaToLinear=function(t){return this.copyGammaToLinear(this,t),this},e.convertLinearToGamma=function(t){return this.copyLinearToGamma(this,t),this},e.copySRGBToLinear=function(t){return this.r=He(t.r),this.g=He(t.g),this.b=He(t.b),this},e.copyLinearToSRGB=function(t){return this.r=ke(t.r),this.g=ke(t.g),this.b=ke(t.b),this},e.convertSRGBToLinear=function(){return this.copySRGBToLinear(this),this},e.convertLinearToSRGB=function(){return this.copyLinearToSRGB(this),this},e.getHex=function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},e.getHexString=function(){return("000000"+this.getHex().toString(16)).slice(-6)},e.getHSL=function(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});var e,n,r=this.r,i=this.g,a=this.b,o=Math.max(r,i,a),s=Math.min(r,i,a),c=(s+o)/2;if(s===o)e=0,n=0;else{var l=o-s;switch(n=c<=.5?l/(o+s):l/(2-o-s),o){case r:e=(i-a)/l+(i<a?6:0);break;case i:e=(a-r)/l+2;break;case a:e=(r-i)/l+4}e/=6}return t.h=e,t.s=n,t.l=c,t},e.getStyle=function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},e.offsetHSL=function(t,e,n){return this.getHSL(Ge),Ge.h+=t,Ge.s+=e,Ge.l+=n,this.setHSL(Ge.h,Ge.s,Ge.l),this},e.add=function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this},e.addColors=function(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this},e.addScalar=function(t){return this.r+=t,this.g+=t,this.b+=t,this},e.sub=function(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this},e.multiply=function(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this},e.multiplyScalar=function(t){return this.r*=t,this.g*=t,this.b*=t,this},e.lerp=function(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this},e.lerpHSL=function(t,e){this.getHSL(Ge),t.getHSL(Fe);var n=st.lerp(Ge.h,Fe.h,e),r=st.lerp(Ge.s,Fe.s,e),i=st.lerp(Ge.l,Fe.l,e);return this.setHSL(n,r,i),this},e.equals=function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b},e.fromArray=function(t,e){return void 0===e&&(e=0),this.r=t[e],this.g=t[e+1],this.b=t[e+2],this},e.toArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t},e.fromBufferAttribute=function(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),!0===t.normalized&&(this.r/=255,this.g/=255,this.b/=255),this},e.toJSON=function(){return this.getHex()},t}();Ve.NAMES=ze,Ve.prototype.r=1,Ve.prototype.g=1,Ve.prototype.b=1;var We=function(){function t(t,e,n,r,i,a){this.a=t,this.b=e,this.c=n,this.normal=r&&r.isVector3?r:new wt,this.vertexNormals=Array.isArray(r)?r:[],this.color=i&&i.isColor?i:new Ve,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=void 0!==a?a:0}var e=t.prototype;return e.clone=function(){return(new this.constructor).copy(this)},e.copy=function(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(var e=0,n=t.vertexNormals.length;e<n;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(var r=0,i=t.vertexColors.length;r<i;r++)this.vertexColors[r]=t.vertexColors[r].clone();return this},t}(),je=0;function qe(){Object.defineProperty(this,"id",{value:je++}),this.uuid=st.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.flatShading=!1,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=e,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=$,this.stencilZFail=$,this.stencilZPass=$,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}function Xe(t){qe.call(this),this.type="MeshBasicMaterial",this.color=new Ve(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(t)}qe.prototype=Object.assign(Object.create(rt.prototype),{constructor:qe,isMaterial:!0,onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(t){if(void 0!==t)for(var e in t){var n=t[e];if(void 0!==n)if("shading"!==e){var r=this[e];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=n:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}else console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===n;else console.warn("THREE.Material: '"+e+"' parameter is undefined.")}},toJSON:function(t){var e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});var n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(t){var e=[];for(var n in t){var r=t[n];delete r.metadata,e.push(r)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,n.reflectivity=this.reflectivity,n.refractionRatio=this.refractionRatio,void 0!==this.combine&&(n.combine=this.combine),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(n.size=this.size),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),0!==this.side&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(n.morphTargets=!0),!0===this.morphNormals&&(n.morphNormals=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e){var i=r(t.textures),a=r(t.images);i.length>0&&(n.textures=i),a.length>0&&(n.images=a)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;var e=t.clippingPlanes,n=null;if(null!==e){var r=e.length;n=new Array(r);for(var i=0;i!==r;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(qe.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Xe.prototype=Object.create(qe.prototype),Xe.prototype.constructor=Xe,Xe.prototype.isMeshBasicMaterial=!0,Xe.prototype.copy=function(t){return qe.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this};var Ye=new wt,Ze=new pt;function Je(t,e,n){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===n,this.usage=tt,this.updateRange={offset:0,count:-1},this.version=0}function Qe(t,e,n){Je.call(this,new Int8Array(t),e,n)}function Ke(t,e,n){Je.call(this,new Uint8Array(t),e,n)}function $e(t,e,n){Je.call(this,new Uint8ClampedArray(t),e,n)}function tn(t,e,n){Je.call(this,new Int16Array(t),e,n)}function en(t,e,n){Je.call(this,new Uint16Array(t),e,n)}function nn(t,e,n){Je.call(this,new Int32Array(t),e,n)}function rn(t,e,n){Je.call(this,new Uint32Array(t),e,n)}function an(t,e,n){Je.call(this,new Float32Array(t),e,n)}function on(t,e,n){Je.call(this,new Float64Array(t),e,n)}Object.defineProperty(Je.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Je.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.itemSize,n*=e.itemSize;for(var r=0,i=this.itemSize;r<i;r++)this.array[t+r]=e.array[n+r];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){for(var e=this.array,n=0,r=0,i=t.length;r<i;r++){var a=t[r];void 0===a&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),a=new Ve),e[n++]=a.r,e[n++]=a.g,e[n++]=a.b}return this},copyVector2sArray:function(t){for(var e=this.array,n=0,r=0,i=t.length;r<i;r++){var a=t[r];void 0===a&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),a=new pt),e[n++]=a.x,e[n++]=a.y}return this},copyVector3sArray:function(t){for(var e=this.array,n=0,r=0,i=t.length;r<i;r++){var a=t[r];void 0===a&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),a=new wt),e[n++]=a.x,e[n++]=a.y,e[n++]=a.z}return this},copyVector4sArray:function(t){for(var e=this.array,n=0,r=0,i=t.length;r<i;r++){var a=t[r];void 0===a&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),a=new yt),e[n++]=a.x,e[n++]=a.y,e[n++]=a.z,e[n++]=a.w}return this},applyMatrix3:function(t){if(2===this.itemSize)for(var e=0,n=this.count;e<n;e++)Ze.fromBufferAttribute(this,e),Ze.applyMatrix3(t),this.setXY(e,Ze.x,Ze.y);else if(3===this.itemSize)for(var r=0,i=this.count;r<i;r++)Ye.fromBufferAttribute(this,r),Ye.applyMatrix3(t),this.setXYZ(r,Ye.x,Ye.y,Ye.z);return this},applyMatrix4:function(t){for(var e=0,n=this.count;e<n;e++)Ye.x=this.getX(e),Ye.y=this.getY(e),Ye.z=this.getZ(e),Ye.applyMatrix4(t),this.setXYZ(e,Ye.x,Ye.y,Ye.z);return this},applyNormalMatrix:function(t){for(var e=0,n=this.count;e<n;e++)Ye.x=this.getX(e),Ye.y=this.getY(e),Ye.z=this.getZ(e),Ye.applyNormalMatrix(t),this.setXYZ(e,Ye.x,Ye.y,Ye.z);return this},transformDirection:function(t){for(var e=0,n=this.count;e<n;e++)Ye.x=this.getX(e),Ye.y=this.getY(e),Ye.z=this.getZ(e),Ye.transformDirection(t),this.setXYZ(e,Ye.x,Ye.y,Ye.z);return this},set:function(t,e){return void 0===e&&(e=0),this.array.set(t,e),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,e){return this.array[t*this.itemSize]=e,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,e){return this.array[t*this.itemSize+1]=e,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,e){return this.array[t*this.itemSize+2]=e,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,e){return this.array[t*this.itemSize+3]=e,this},setXY:function(t,e,n){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this},setXYZ:function(t,e,n,r){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this},setXYZW:function(t,e,n,r,i){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this.array[t+3]=i,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}}),Qe.prototype=Object.create(Je.prototype),Qe.prototype.constructor=Qe,Ke.prototype=Object.create(Je.prototype),Ke.prototype.constructor=Ke,$e.prototype=Object.create(Je.prototype),$e.prototype.constructor=$e,tn.prototype=Object.create(Je.prototype),tn.prototype.constructor=tn,en.prototype=Object.create(Je.prototype),en.prototype.constructor=en,nn.prototype=Object.create(Je.prototype),nn.prototype.constructor=nn,rn.prototype=Object.create(Je.prototype),rn.prototype.constructor=rn,an.prototype=Object.create(Je.prototype),an.prototype.constructor=an,on.prototype=Object.create(Je.prototype),on.prototype.constructor=on;var sn=function(){function t(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}var e=t.prototype;return e.computeGroups=function(t){var e,n,r=[],i=void 0,a=t.faces;for(n=0;n<a.length;n++){var o=a[n];o.materialIndex!==i&&(i=o.materialIndex,void 0!==e&&(e.count=3*n-e.start,r.push(e)),e={start:3*n,materialIndex:i})}void 0!==e&&(e.count=3*n-e.start,r.push(e)),this.groups=r},e.fromGeometry=function(t){var e,n=t.faces,r=t.vertices,i=t.faceVertexUvs,a=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,s=t.morphTargets,c=s.length;if(c>0){e=[];for(var l=0;l<c;l++)e[l]={name:s[l].name,data:[]};this.morphTargets.position=e}var u,h=t.morphNormals,d=h.length;if(d>0){u=[];for(var p=0;p<d;p++)u[p]={name:h[p].name,data:[]};this.morphTargets.normal=u}var f=t.skinIndices,m=t.skinWeights,v=f.length===r.length,g=m.length===r.length;r.length>0&&0===n.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(var y=0;y<n.length;y++){var x=n[y];this.vertices.push(r[x.a],r[x.b],r[x.c]);var _=x.vertexNormals;if(3===_.length)this.normals.push(_[0],_[1],_[2]);else{var b=x.normal;this.normals.push(b,b,b)}var w=x.vertexColors;if(3===w.length)this.colors.push(w[0],w[1],w[2]);else{var M=x.color;this.colors.push(M,M,M)}if(!0===a){var S=i[0][y];void 0!==S?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new pt,new pt,new pt))}if(!0===o){var T=i[1][y];void 0!==T?this.uvs2.push(T[0],T[1],T[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new pt,new pt,new pt))}for(var E=0;E<c;E++){var A=s[E].vertices;e[E].data.push(A[x.a],A[x.b],A[x.c])}for(var L=0;L<d;L++){var R=h[L].vertexNormals[y];u[L].data.push(R.a,R.b,R.c)}v&&this.skinIndices.push(f[x.a],f[x.b],f[x.c]),g&&this.skinWeights.push(m[x.a],m[x.b],m[x.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},t}();function cn(t){if(0===t.length)return-1/0;for(var e=t[0],n=1,r=t.length;n<r;++n)t[n]>e&&(e=t[n]);return e}var ln=1,un=new Jt,hn=new be,dn=new wt,pn=new Tt,fn=new Tt,mn=new wt;function vn(){Object.defineProperty(this,"id",{value:ln+=2}),this.uuid=st.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}vn.prototype=Object.assign(Object.create(rt.prototype),{constructor:vn,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){return Array.isArray(t)?this.index=new(cn(t)>65535?rn:en)(t,1):this.index=t,this},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,e){return this.attributes[t]=e,this},deleteAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,n){this.groups.push({start:t,count:e,materialIndex:void 0!==n?n:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix4:function(t){var e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);var n=this.attributes.normal;if(void 0!==n){var r=(new ft).getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}var i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(t){return un.makeRotationX(t),this.applyMatrix4(un),this},rotateY:function(t){return un.makeRotationY(t),this.applyMatrix4(un),this},rotateZ:function(t){return un.makeRotationZ(t),this.applyMatrix4(un),this},translate:function(t,e,n){return un.makeTranslation(t,e,n),this.applyMatrix4(un),this},scale:function(t,e,n){return un.makeScale(t,e,n),this.applyMatrix4(un),this},lookAt:function(t){return hn.lookAt(t),hn.updateMatrix(),this.applyMatrix4(hn.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(dn).negate(),this.translate(dn.x,dn.y,dn.z),this},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var n=new an(3*e.vertices.length,3),r=new an(3*e.colors.length,3);if(this.setAttribute("position",n.copyVector3sArray(e.vertices)),this.setAttribute("color",r.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new an(e.lineDistances.length,1);this.setAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},setFromPoints:function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];e.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new an(e,3)),this},updateFromObject:function(t){var e=t.geometry;if(t.isMesh){var n=e.__directGeometry;if(!0===e.elementsNeedUpdate&&(n=void 0,e.elementsNeedUpdate=!1),void 0===n)return this.fromGeometry(e);n.verticesNeedUpdate=e.verticesNeedUpdate,n.normalsNeedUpdate=e.normalsNeedUpdate,n.colorsNeedUpdate=e.colorsNeedUpdate,n.uvsNeedUpdate=e.uvsNeedUpdate,n.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=n}if(!0===e.verticesNeedUpdate){var r=this.attributes.position;void 0!==r&&(r.copyVector3sArray(e.vertices),r.needsUpdate=!0),e.verticesNeedUpdate=!1}if(!0===e.normalsNeedUpdate){var i=this.attributes.normal;void 0!==i&&(i.copyVector3sArray(e.normals),i.needsUpdate=!0),e.normalsNeedUpdate=!1}if(!0===e.colorsNeedUpdate){var a=this.attributes.color;void 0!==a&&(a.copyColorsArray(e.colors),a.needsUpdate=!0),e.colorsNeedUpdate=!1}if(e.uvsNeedUpdate){var o=this.attributes.uv;void 0!==o&&(o.copyVector2sArray(e.uvs),o.needsUpdate=!0),e.uvsNeedUpdate=!1}if(e.lineDistancesNeedUpdate){var s=this.attributes.lineDistance;void 0!==s&&(s.copyArray(e.lineDistances),s.needsUpdate=!0),e.lineDistancesNeedUpdate=!1}return e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new sn).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.setAttribute("position",new Je(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var n=new Float32Array(3*t.normals.length);this.setAttribute("normal",new Je(n,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var r=new Float32Array(3*t.colors.length);this.setAttribute("color",new Je(r,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.setAttribute("uv",new Je(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var a=new Float32Array(2*t.uvs2.length);this.setAttribute("uv2",new Je(a,2).copyVector2sArray(t.uvs2))}for(var o in this.groups=t.groups,t.morphTargets){for(var s=[],c=t.morphTargets[o],l=0,u=c.length;l<u;l++){var h=c[l],d=new an(3*h.data.length,3);d.name=h.name,s.push(d.copyVector3sArray(h.data))}this.morphAttributes[o]=s}if(t.skinIndices.length>0){var p=new an(4*t.skinIndices.length,4);this.setAttribute("skinIndex",p.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var f=new an(4*t.skinWeights.length,4);this.setAttribute("skinWeight",f.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Tt);var t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new wt(-1/0,-1/0,-1/0),new wt(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(var n=0,r=e.length;n<r;n++){var i=e[n];pn.setFromBufferAttribute(i),this.morphTargetsRelative?(mn.addVectors(this.boundingBox.min,pn.min),this.boundingBox.expandByPoint(mn),mn.addVectors(this.boundingBox.max,pn.max),this.boundingBox.expandByPoint(mn)):(this.boundingBox.expandByPoint(pn.min),this.boundingBox.expandByPoint(pn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new Ht);var t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new wt,1/0);if(t){var n=this.boundingSphere.center;if(pn.setFromBufferAttribute(t),e)for(var r=0,i=e.length;r<i;r++){var a=e[r];fn.setFromBufferAttribute(a),this.morphTargetsRelative?(mn.addVectors(pn.min,fn.min),pn.expandByPoint(mn),mn.addVectors(pn.max,fn.max),pn.expandByPoint(mn)):(pn.expandByPoint(fn.min),pn.expandByPoint(fn.max))}pn.getCenter(n);for(var o=0,s=0,c=t.count;s<c;s++)mn.fromBufferAttribute(t,s),o=Math.max(o,n.distanceToSquared(mn));if(e)for(var l=0,u=e.length;l<u;l++)for(var h=e[l],d=this.morphTargetsRelative,p=0,f=h.count;p<f;p++)mn.fromBufferAttribute(h,p),d&&(dn.fromBufferAttribute(t,p),mn.add(dn)),o=Math.max(o,n.distanceToSquared(mn));this.boundingSphere.radius=Math.sqrt(o),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeVertexNormals:function(){var t=this.index,e=this.getAttribute("position");if(void 0!==e){var n=this.getAttribute("normal");if(void 0===n)n=new Je(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(var r=0,i=n.count;r<i;r++)n.setXYZ(r,0,0,0);var a=new wt,o=new wt,s=new wt,c=new wt,l=new wt,u=new wt,h=new wt,d=new wt;if(t)for(var p=0,f=t.count;p<f;p+=3){var m=t.getX(p+0),v=t.getX(p+1),g=t.getX(p+2);a.fromBufferAttribute(e,m),o.fromBufferAttribute(e,v),s.fromBufferAttribute(e,g),h.subVectors(s,o),d.subVectors(a,o),h.cross(d),c.fromBufferAttribute(n,m),l.fromBufferAttribute(n,v),u.fromBufferAttribute(n,g),c.add(h),l.add(h),u.add(h),n.setXYZ(m,c.x,c.y,c.z),n.setXYZ(v,l.x,l.y,l.z),n.setXYZ(g,u.x,u.y,u.z)}else for(var y=0,x=e.count;y<x;y+=3)a.fromBufferAttribute(e,y+0),o.fromBufferAttribute(e,y+1),s.fromBufferAttribute(e,y+2),h.subVectors(s,o),d.subVectors(a,o),h.cross(d),n.setXYZ(y+0,h.x,h.y,h.z),n.setXYZ(y+1,h.x,h.y,h.z),n.setXYZ(y+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}},merge:function(t,e){if(t&&t.isBufferGeometry){void 0===e&&(e=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));var n=this.attributes;for(var r in n)if(void 0!==t.attributes[r])for(var i=n[r].array,a=t.attributes[r],o=a.array,s=a.itemSize*e,c=Math.min(o.length,i.length-s),l=0,u=s;l<c;l++,u++)i[u]=o[l];return this}console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",t)},normalizeNormals:function(){for(var t=this.attributes.normal,e=0,n=t.count;e<n;e++)mn.fromBufferAttribute(t,e),mn.normalize(),t.setXYZ(e,mn.x,mn.y,mn.z)},toNonIndexed:function(){function t(t,e){for(var n=t.array,r=t.itemSize,i=t.normalized,a=new n.constructor(e.length*r),o=0,s=0,c=0,l=e.length;c<l;c++){o=e[c]*r;for(var u=0;u<r;u++)a[s++]=n[o++]}return new Je(a,r,i)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var e=new vn,n=this.index.array,r=this.attributes;for(var i in r){var a=t(r[i],n);e.setAttribute(i,a)}var o=this.morphAttributes;for(var s in o){for(var c=[],l=o[s],u=0,h=l.length;u<h;u++){var d=t(l[u],n);c.push(d)}e.morphAttributes[s]=c}e.morphTargetsRelative=this.morphTargetsRelative;for(var p=this.groups,f=0,m=p.length;f<m;f++){var v=p[f];e.addGroup(v.start,v.count,v.materialIndex)}return e},toJSON:function(){var t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){var e=this.parameters;for(var n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};var r=this.index;null!==r&&(t.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});var i=this.attributes;for(var a in i){var o=i[a],s=o.toJSON(t.data);""!==o.name&&(s.name=o.name),t.data.attributes[a]=s}var c={},l=!1;for(var u in this.morphAttributes){for(var h=this.morphAttributes[u],d=[],p=0,f=h.length;p<f;p++){var m=h[p],v=m.toJSON(t.data);""!==m.name&&(v.name=m.name),d.push(v)}d.length>0&&(c[u]=d,l=!0)}l&&(t.data.morphAttributes=c,t.data.morphTargetsRelative=this.morphTargetsRelative);var g=this.groups;g.length>0&&(t.data.groups=JSON.parse(JSON.stringify(g)));var y=this.boundingSphere;return null!==y&&(t.data.boundingSphere={center:y.center.toArray(),radius:y.radius}),t},clone:function(){return(new vn).copy(this)},copy:function(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;var e={};this.name=t.name;var n=t.index;null!==n&&this.setIndex(n.clone(e));var r=t.attributes;for(var i in r){var a=r[i];this.setAttribute(i,a.clone(e))}var o=t.morphAttributes;for(var s in o){for(var c=[],l=o[s],u=0,h=l.length;u<h;u++)c.push(l[u].clone(e));this.morphAttributes[s]=c}this.morphTargetsRelative=t.morphTargetsRelative;for(var d=t.groups,p=0,f=d.length;p<f;p++){var m=d[p];this.addGroup(m.start,m.count,m.materialIndex)}var v=t.boundingBox;null!==v&&(this.boundingBox=v.clone());var g=t.boundingSphere;return null!==g&&(this.boundingSphere=g.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var gn=new Jt,yn=new Zt,xn=new Ht,_n=new wt,bn=new wt,wn=new wt,Mn=new wt,Sn=new wt,Tn=new wt,En=new wt,An=new wt,Ln=new wt,Rn=new pt,Cn=new pt,Pn=new pt,In=new wt,Dn=new wt;function On(t,e){be.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new vn,this.material=void 0!==e?e:new Xe,this.updateMorphTargets()}function Nn(t,e,n,r,i,a,o,s){if(null===(1===e.side?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,2!==e.side,s)))return null;Dn.copy(s),Dn.applyMatrix4(t.matrixWorld);var c=n.ray.origin.distanceTo(Dn);return c<n.near||c>n.far?null:{distance:c,point:Dn.clone(),object:t}}function Bn(t,e,n,r,i,a,o,s,c,l,u,h){_n.fromBufferAttribute(i,l),bn.fromBufferAttribute(i,u),wn.fromBufferAttribute(i,h);var d=t.morphTargetInfluences;if(e.morphTargets&&a&&d){En.set(0,0,0),An.set(0,0,0),Ln.set(0,0,0);for(var p=0,f=a.length;p<f;p++){var m=d[p],v=a[p];0!==m&&(Mn.fromBufferAttribute(v,l),Sn.fromBufferAttribute(v,u),Tn.fromBufferAttribute(v,h),o?(En.addScaledVector(Mn,m),An.addScaledVector(Sn,m),Ln.addScaledVector(Tn,m)):(En.addScaledVector(Mn.sub(_n),m),An.addScaledVector(Sn.sub(bn),m),Ln.addScaledVector(Tn.sub(wn),m)))}_n.add(En),bn.add(An),wn.add(Ln)}t.isSkinnedMesh&&(t.boneTransform(l,_n),t.boneTransform(u,bn),t.boneTransform(h,wn));var g=Nn(t,e,n,r,_n,bn,wn,In);if(g){s&&(Rn.fromBufferAttribute(s,l),Cn.fromBufferAttribute(s,u),Pn.fromBufferAttribute(s,h),g.uv=Be.getUV(In,_n,bn,wn,Rn,Cn,Pn,new pt)),c&&(Rn.fromBufferAttribute(c,l),Cn.fromBufferAttribute(c,u),Pn.fromBufferAttribute(c,h),g.uv2=Be.getUV(In,_n,bn,wn,Rn,Cn,Pn,new pt));var y=new We(l,u,h);Be.getNormal(_n,bn,wn,y.normal),g.face=y}return g}On.prototype=Object.assign(Object.create(be.prototype),{constructor:On,isMesh:!0,copy:function(t){return be.prototype.copy.call(this,t),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=t.material,this.geometry=t.geometry,this},updateMorphTargets:function(){var t=this.geometry;if(t.isBufferGeometry){var e=t.morphAttributes,n=Object.keys(e);if(n.length>0){var r=e[n[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var i=0,a=r.length;i<a;i++){var o=r[i].name||String(i);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=i}}}}else{var s=t.morphTargets;void 0!==s&&s.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,e){var n,r=this.geometry,i=this.material,a=this.matrixWorld;if(void 0!==i&&(null===r.boundingSphere&&r.computeBoundingSphere(),xn.copy(r.boundingSphere),xn.applyMatrix4(a),!1!==t.ray.intersectsSphere(xn)&&(gn.getInverse(a),yn.copy(t.ray).applyMatrix4(gn),null===r.boundingBox||!1!==yn.intersectsBox(r.boundingBox))))if(r.isBufferGeometry){var o=r.index,s=r.attributes.position,c=r.morphAttributes.position,l=r.morphTargetsRelative,u=r.attributes.uv,h=r.attributes.uv2,d=r.groups,p=r.drawRange;if(null!==o)if(Array.isArray(i))for(var f=0,m=d.length;f<m;f++)for(var v=d[f],g=i[v.materialIndex],y=Math.max(v.start,p.start),x=Math.min(v.start+v.count,p.start+p.count);y<x;y+=3){var _=o.getX(y),b=o.getX(y+1),w=o.getX(y+2);(n=Bn(this,g,t,yn,s,c,l,u,h,_,b,w))&&(n.faceIndex=Math.floor(y/3),n.face.materialIndex=v.materialIndex,e.push(n))}else for(var M=Math.max(0,p.start),S=Math.min(o.count,p.start+p.count);M<S;M+=3){var T=o.getX(M),E=o.getX(M+1),A=o.getX(M+2);(n=Bn(this,i,t,yn,s,c,l,u,h,T,E,A))&&(n.faceIndex=Math.floor(M/3),e.push(n))}else if(void 0!==s)if(Array.isArray(i))for(var L=0,R=d.length;L<R;L++)for(var C=d[L],P=i[C.materialIndex],I=Math.max(C.start,p.start),D=Math.min(C.start+C.count,p.start+p.count);I<D;I+=3){(n=Bn(this,P,t,yn,s,c,l,u,h,I,I+1,I+2))&&(n.faceIndex=Math.floor(I/3),n.face.materialIndex=C.materialIndex,e.push(n))}else for(var O=Math.max(0,p.start),N=Math.min(s.count,p.start+p.count);O<N;O+=3){(n=Bn(this,i,t,yn,s,c,l,u,h,O,O+1,O+2))&&(n.faceIndex=Math.floor(O/3),e.push(n))}}else if(r.isGeometry){var B,z=Array.isArray(i),G=r.vertices,F=r.faces,U=r.faceVertexUvs[0];U.length>0&&(B=U);for(var H=0,k=F.length;H<k;H++){var V=F[H],W=z?i[V.materialIndex]:i;if(void 0!==W){var j=G[V.a],q=G[V.b],X=G[V.c];if(n=Nn(this,W,t,yn,j,q,X,In)){if(B&&B[H]){var Y=B[H];Rn.copy(Y[0]),Cn.copy(Y[1]),Pn.copy(Y[2]),n.uv=Be.getUV(In,j,q,X,Rn,Cn,Pn,new pt)}n.face=V,n.faceIndex=H,e.push(n)}}}}}});var zn=function(t){function e(e,n,r,i,a,o){var s;void 0===e&&(e=1),void 0===n&&(n=1),void 0===r&&(r=1),void 0===i&&(i=1),void 0===a&&(a=1),void 0===o&&(o=1),(s=t.call(this)||this).type="BoxBufferGeometry",s.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};var c=ht(s);i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);var l=[],u=[],h=[],d=[],p=0,f=0;function m(t,e,n,r,i,a,o,s,m,v,g){for(var y=a/m,x=o/v,_=a/2,b=o/2,w=s/2,M=m+1,S=v+1,T=0,E=0,A=new wt,L=0;L<S;L++)for(var R=L*x-b,C=0;C<M;C++){var P=C*y-_;A[t]=P*r,A[e]=R*i,A[n]=w,u.push(A.x,A.y,A.z),A[t]=0,A[e]=0,A[n]=s>0?1:-1,h.push(A.x,A.y,A.z),d.push(C/m),d.push(1-L/v),T+=1}for(var I=0;I<v;I++)for(var D=0;D<m;D++){var O=p+D+M*I,N=p+D+M*(I+1),B=p+(D+1)+M*(I+1),z=p+(D+1)+M*I;l.push(O,N,z),l.push(N,B,z),E+=6}c.addGroup(f,E,g),f+=E,p+=T}return m("z","y","x",-1,-1,r,n,e,o,a,0),m("z","y","x",1,-1,r,n,-e,o,a,1),m("x","z","y",1,1,e,r,n,i,o,2),m("x","z","y",1,-1,e,r,-n,i,o,3),m("x","y","z",1,-1,e,n,r,i,a,4),m("x","y","z",-1,-1,e,n,-r,i,a,5),s.setIndex(l),s.setAttribute("position",new an(u,3)),s.setAttribute("normal",new an(h,3)),s.setAttribute("uv",new an(d,2)),s}return ut(e,t),e}(vn);function Gn(t){var e={};for(var n in t)for(var r in e[n]={},t[n]){var i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture)?e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}return e}function Fn(t){for(var e={},n=0;n<t.length;n++){var r=Gn(t[n]);for(var i in r)e[i]=r[i]}return e}var Un={clone:Gn,merge:Fn};function Hn(t){qe.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function kn(){be.call(this),this.type="Camera",this.matrixWorldInverse=new Jt,this.projectionMatrix=new Jt,this.projectionMatrixInverse=new Jt}function Vn(t,e,n,r){kn.call(this),this.type="PerspectiveCamera",this.fov=void 0!==t?t:50,this.zoom=1,this.near=void 0!==n?n:.1,this.far=void 0!==r?r:2e3,this.focus=10,this.aspect=void 0!==e?e:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}Hn.prototype=Object.create(qe.prototype),Hn.prototype.constructor=Hn,Hn.prototype.isShaderMaterial=!0,Hn.prototype.copy=function(t){return qe.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Gn(t.uniforms),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this},Hn.prototype.toJSON=function(t){var e=qe.prototype.toJSON.call(this,t);for(var n in e.glslVersion=this.glslVersion,e.uniforms={},this.uniforms){var r=this.uniforms[n].value;r&&r.isTexture?e.uniforms[n]={type:"t",value:r.toJSON(t).uuid}:r&&r.isColor?e.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?e.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?e.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?e.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?e.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?e.uniforms[n]={type:"m4",value:r.toArray()}:e.uniforms[n]={value:r}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;var i={};for(var a in this.extensions)!0===this.extensions[a]&&(i[a]=!0);return Object.keys(i).length>0&&(e.extensions=i),e},kn.prototype=Object.assign(Object.create(be.prototype),{constructor:kn,isCamera:!0,copy:function(t,e){return be.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new wt),this.updateWorldMatrix(!0,!1);var e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){be.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},updateWorldMatrix:function(t,e){be.prototype.updateWorldMatrix.call(this,t,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),Vn.prototype=Object.assign(Object.create(kn.prototype),{constructor:Vn,isPerspectiveCamera:!0,copy:function(t,e){return kn.prototype.copy.call(this,t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this},setFocalLength:function(t){var e=.5*this.getFilmHeight()/t;this.fov=2*st.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){var t=Math.tan(.5*st.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*st.RAD2DEG*Math.atan(Math.tan(.5*st.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(t,e,n,r,i,a){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=this.near,e=t*Math.tan(.5*st.DEG2RAD*this.fov)/this.zoom,n=2*e,r=this.aspect*n,i=-.5*r,a=this.view;if(null!==this.view&&this.view.enabled){var o=a.fullWidth,s=a.fullHeight;i+=a.offsetX*r/o,e-=a.offsetY*n/s,r*=a.width/o,n*=a.height/s}var c=this.filmOffset;0!==c&&(i+=t*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,e,e-n,t,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(t){var e=be.prototype.toJSON.call(this,t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}});var Wn=90;function jn(t,e,n){if(be.call(this),this.type="CubeCamera",!0===n.isWebGLCubeRenderTarget){this.renderTarget=n;var r=new Vn(Wn,1,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new wt(1,0,0)),this.add(r);var i=new Vn(Wn,1,t,e);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new wt(-1,0,0)),this.add(i);var a=new Vn(Wn,1,t,e);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(new wt(0,1,0)),this.add(a);var o=new Vn(Wn,1,t,e);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new wt(0,-1,0)),this.add(o);var s=new Vn(Wn,1,t,e);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new wt(0,0,1)),this.add(s);var c=new Vn(Wn,1,t,e);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new wt(0,0,-1)),this.add(c),this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();var l=t.xr.enabled,u=t.getRenderTarget();t.xr.enabled=!1;var h=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0),t.render(e,r),t.setRenderTarget(n,1),t.render(e,i),t.setRenderTarget(n,2),t.render(e,a),t.setRenderTarget(n,3),t.render(e,o),t.setRenderTarget(n,4),t.render(e,s),n.texture.generateMipmaps=h,t.setRenderTarget(n,5),t.render(e,c),t.setRenderTarget(u),t.xr.enabled=l}}else console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.")}function qn(t,e,n,i,a,o,s,c,l,u){t=void 0!==t?t:[],e=void 0!==e?e:r,s=void 0!==s?s:S,gt.call(this,t,e,n,i,a,o,s,c,l,u),this.flipY=!1,this._needsFlipEnvMap=!0}function Xn(t,e,n){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=n),xt.call(this,t,t,e),e=e||{},this.texture=new qn(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture._needsFlipEnvMap=!1}function Yn(t,e,n,r,i,a,o,s,c,l,u,h){gt.call(this,null,a,o,s,c,l,r,i,u,h),this.image={data:t||null,width:e||1,height:n||1},this.magFilter=void 0!==c?c:d,this.minFilter=void 0!==l?l:d,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}jn.prototype=Object.create(be.prototype),jn.prototype.constructor=jn,qn.prototype=Object.create(gt.prototype),qn.prototype.constructor=qn,qn.prototype.isCubeTexture=!0,Object.defineProperty(qn.prototype,"images",{get:function(){return this.image},set:function(t){this.image=t}}),Xn.prototype=Object.create(xt.prototype),Xn.prototype.constructor=Xn,Xn.prototype.isWebGLCubeRenderTarget=!0,Xn.prototype.fromEquirectangularTexture=function(t,e){this.texture.type=e.type,this.texture.format=T,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;var n={tEquirect:{value:null}},r="\n\n\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t#include <begin_vertex>\n\t\t\t\t#include <project_vertex>\n\n\t\t\t}\n\t\t",i="\n\n\t\t\tuniform sampler2D tEquirect;\n\n\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t}\n\t\t",a=new zn(5,5,5),o=new Hn({name:"CubemapFromEquirect",uniforms:Gn(n),vertexShader:r,fragmentShader:i,side:1,blending:0});o.uniforms.tEquirect.value=e;var s=new On(a,o),c=e.minFilter;return e.minFilter===g&&(e.minFilter=m),new jn(1,10,this).update(t,s),e.minFilter=c,s.geometry.dispose(),s.material.dispose(),this},Xn.prototype.clear=function(t,e,n,r){for(var i=t.getRenderTarget(),a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,r);t.setRenderTarget(i)},Yn.prototype=Object.create(gt.prototype),Yn.prototype.constructor=Yn,Yn.prototype.isDataTexture=!0;var Zn=new Ht,Jn=new wt,Qn=function(){function t(t,e,n,r,i,a){this.planes=[void 0!==t?t:new Te,void 0!==e?e:new Te,void 0!==n?n:new Te,void 0!==r?r:new Te,void 0!==i?i:new Te,void 0!==a?a:new Te]}var e=t.prototype;return e.set=function(t,e,n,r,i,a){var o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this},e.clone=function(){return(new this.constructor).copy(this)},e.copy=function(t){for(var e=this.planes,n=0;n<6;n++)e[n].copy(t.planes[n]);return this},e.setFromProjectionMatrix=function(t){var e=this.planes,n=t.elements,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],h=n[8],d=n[9],p=n[10],f=n[11],m=n[12],v=n[13],g=n[14],y=n[15];return e[0].setComponents(o-r,u-s,f-h,y-m).normalize(),e[1].setComponents(o+r,u+s,f+h,y+m).normalize(),e[2].setComponents(o+i,u+c,f+d,y+v).normalize(),e[3].setComponents(o-i,u-c,f-d,y-v).normalize(),e[4].setComponents(o-a,u-l,f-p,y-g).normalize(),e[5].setComponents(o+a,u+l,f+p,y+g).normalize(),this},e.intersectsObject=function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),Zn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(Zn)},e.intersectsSprite=function(t){return Zn.center.set(0,0,0),Zn.radius=.7071067811865476,Zn.applyMatrix4(t.matrixWorld),this.intersectsSphere(Zn)},e.intersectsSphere=function(t){for(var e=this.planes,n=t.center,r=-t.radius,i=0;i<6;i++){if(e[i].distanceToPoint(n)<r)return!1}return!0},e.intersectsBox=function(t){for(var e=this.planes,n=0;n<6;n++){var r=e[n];if(Jn.x=r.normal.x>0?t.max.x:t.min.x,Jn.y=r.normal.y>0?t.max.y:t.min.y,Jn.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(Jn)<0)return!1}return!0},e.containsPoint=function(t){for(var e=this.planes,n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0},t}();function Kn(){var t=null,e=!1,n=null,r=null;function i(e,a){n(e,a),r=t.requestAnimationFrame(i)}return{start:function(){!0!==e&&null!==n&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function $n(t,e){var n=e.isWebGL2,r=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),r.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);var n=r.get(e);n&&(t.deleteBuffer(n.buffer),r.delete(e))},update:function(e,i){if(e.isGLBufferAttribute){var a=r.get(e);(!a||a.version<e.version)&&r.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version})}else{e.isInterleavedBufferAttribute&&(e=e.data);var o=r.get(e);void 0===o?r.set(e,function(e,n){var r=e.array,i=e.usage,a=t.createBuffer();t.bindBuffer(n,a),t.bufferData(n,r,i),e.onUploadCallback();var o=5126;return r instanceof Float32Array?o=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?o=5123:r instanceof Int16Array?o=5122:r instanceof Uint32Array?o=5125:r instanceof Int32Array?o=5124:r instanceof Int8Array?o=5120:r instanceof Uint8Array&&(o=5121),{buffer:a,type:o,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(e,i)):o.version<e.version&&(!function(e,r,i){var a=r.array,o=r.updateRange;t.bindBuffer(i,e),-1===o.count?t.bufferSubData(i,0,a):(n?t.bufferSubData(i,o.offset*a.BYTES_PER_ELEMENT,a,o.offset,o.count):t.bufferSubData(i,o.offset*a.BYTES_PER_ELEMENT,a.subarray(o.offset,o.offset+o.count)),o.count=-1)}(o.buffer,e,i),o.version=e.version)}}}}var tr=function(t){function e(e,n,r,i){var a;(a=t.call(this)||this).type="PlaneBufferGeometry",a.parameters={width:e,height:n,widthSegments:r,heightSegments:i};for(var o=(e=e||1)/2,s=(n=n||1)/2,c=Math.floor(r)||1,l=Math.floor(i)||1,u=c+1,h=l+1,d=e/c,p=n/l,f=[],m=[],v=[],g=[],y=0;y<h;y++)for(var x=y*p-s,_=0;_<u;_++){var b=_*d-o;m.push(b,-x,0),v.push(0,0,1),g.push(_/c),g.push(1-y/l)}for(var w=0;w<l;w++)for(var M=0;M<c;M++){var S=M+u*w,T=M+u*(w+1),E=M+1+u*(w+1),A=M+1+u*w;f.push(S,T,A),f.push(T,E,A)}return a.setIndex(f),a.setAttribute("position",new an(m,3)),a.setAttribute("normal",new an(v,3)),a.setAttribute("uv",new an(g,2)),a}return ut(e,t),e}(vn),er={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor.xyz *= color.xyz;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat specularRoughness;\n\tvec3 specularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(\t\t0, 1,\t\t0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tmat3 tsn = mat3( S, T, N );\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3(\t1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,\t1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,\t1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmissionmap_fragment:"#ifdef USE_TRANSMISSIONMAP\n\ttotalTransmission *= texture2D( transmissionMap, vUv ).r;\n#endif",transmissionmap_pars_fragment:"#ifdef USE_TRANSMISSIONMAP\n\tuniform sampler2D transmissionMap;\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSMISSION\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSMISSION\n\tuniform float transmission;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <transmissionmap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#ifdef TRANSMISSION\n\t\tfloat totalTransmission = transmission;\n\t#endif\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <transmissionmap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSMISSION\n\t\tdiffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}"},nr={common:{diffuse:{value:new Ve(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new ft},uv2Transform:{value:new ft},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new pt(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ve(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ve(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new ft}},sprite:{diffuse:{value:new Ve(15658734)},opacity:{value:1},center:{value:new pt(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new ft}}},rr={basic:{uniforms:Fn([nr.common,nr.specularmap,nr.envmap,nr.aomap,nr.lightmap,nr.fog]),vertexShader:er.meshbasic_vert,fragmentShader:er.meshbasic_frag},lambert:{uniforms:Fn([nr.common,nr.specularmap,nr.envmap,nr.aomap,nr.lightmap,nr.emissivemap,nr.fog,nr.lights,{emissive:{value:new Ve(0)}}]),vertexShader:er.meshlambert_vert,fragmentShader:er.meshlambert_frag},phong:{uniforms:Fn([nr.common,nr.specularmap,nr.envmap,nr.aomap,nr.lightmap,nr.emissivemap,nr.bumpmap,nr.normalmap,nr.displacementmap,nr.fog,nr.lights,{emissive:{value:new Ve(0)},specular:{value:new Ve(1118481)},shininess:{value:30}}]),vertexShader:er.meshphong_vert,fragmentShader:er.meshphong_frag},standard:{uniforms:Fn([nr.common,nr.envmap,nr.aomap,nr.lightmap,nr.emissivemap,nr.bumpmap,nr.normalmap,nr.displacementmap,nr.roughnessmap,nr.metalnessmap,nr.fog,nr.lights,{emissive:{value:new Ve(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:er.meshphysical_vert,fragmentShader:er.meshphysical_frag},toon:{uniforms:Fn([nr.common,nr.aomap,nr.lightmap,nr.emissivemap,nr.bumpmap,nr.normalmap,nr.displacementmap,nr.gradientmap,nr.fog,nr.lights,{emissive:{value:new Ve(0)}}]),vertexShader:er.meshtoon_vert,fragmentShader:er.meshtoon_frag},matcap:{uniforms:Fn([nr.common,nr.bumpmap,nr.normalmap,nr.displacementmap,nr.fog,{matcap:{value:null}}]),vertexShader:er.meshmatcap_vert,fragmentShader:er.meshmatcap_frag},points:{uniforms:Fn([nr.points,nr.fog]),vertexShader:er.points_vert,fragmentShader:er.points_frag},dashed:{uniforms:Fn([nr.common,nr.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:er.linedashed_vert,fragmentShader:er.linedashed_frag},depth:{uniforms:Fn([nr.common,nr.displacementmap]),vertexShader:er.depth_vert,fragmentShader:er.depth_frag},normal:{uniforms:Fn([nr.common,nr.bumpmap,nr.normalmap,nr.displacementmap,{opacity:{value:1}}]),vertexShader:er.normal_vert,fragmentShader:er.normal_frag},sprite:{uniforms:Fn([nr.sprite,nr.fog]),vertexShader:er.sprite_vert,fragmentShader:er.sprite_frag},background:{uniforms:{uvTransform:{value:new ft},t2D:{value:null}},vertexShader:er.background_vert,fragmentShader:er.background_frag},cube:{uniforms:Fn([nr.envmap,{opacity:{value:1}}]),vertexShader:er.cube_vert,fragmentShader:er.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:er.equirect_vert,fragmentShader:er.equirect_frag},distanceRGBA:{uniforms:Fn([nr.common,nr.displacementmap,{referencePosition:{value:new wt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:er.distanceRGBA_vert,fragmentShader:er.distanceRGBA_frag},shadow:{uniforms:Fn([nr.lights,nr.fog,{color:{value:new Ve(0)},opacity:{value:1}}]),vertexShader:er.shadow_vert,fragmentShader:er.shadow_frag}};function ir(t,e,n,r,i){var a,o,c=new Ve(0),l=0,u=null,h=0,d=null;function p(t,e){n.buffers.color.setClear(t.r,t.g,t.b,e,i)}return{getClearColor:function(){return c},setClearColor:function(t,e){c.set(t),p(c,l=void 0!==e?e:1)},getClearAlpha:function(){return l},setClearAlpha:function(t){p(c,l=t)},render:function(n,i,f,m){var v=!0===i.isScene?i.background:null;v&&v.isTexture&&(v=e.get(v));var g=t.xr,y=g.getSession&&g.getSession();y&&"additive"===y.environmentBlendMode&&(v=null),null===v?p(c,l):v&&v.isColor&&(p(v,1),m=!0),(t.autoClear||m)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),v&&(v.isCubeTexture||v.isWebGLCubeRenderTarget||v.mapping===s)?(void 0===o&&((o=new On(new zn(1,1,1),new Hn({name:"BackgroundCubeMaterial",uniforms:Gn(rr.cube.uniforms),vertexShader:rr.cube.vertexShader,fragmentShader:rr.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),o.geometry.deleteAttribute("uv"),o.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(o.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(o)),v.isWebGLCubeRenderTarget&&(v=v.texture),o.material.uniforms.envMap.value=v,o.material.uniforms.flipEnvMap.value=v.isCubeTexture&&v._needsFlipEnvMap?-1:1,u===v&&h===v.version&&d===t.toneMapping||(o.material.needsUpdate=!0,u=v,h=v.version,d=t.toneMapping),n.unshift(o,o.geometry,o.material,0,0,null)):v&&v.isTexture&&(void 0===a&&((a=new On(new tr(2,2),new Hn({name:"BackgroundMaterial",uniforms:Gn(rr.background.uniforms),vertexShader:rr.background.vertexShader,fragmentShader:rr.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(a)),a.material.uniforms.t2D.value=v,!0===v.matrixAutoUpdate&&v.updateMatrix(),a.material.uniforms.uvTransform.value.copy(v.matrix),u===v&&h===v.version&&d===t.toneMapping||(a.material.needsUpdate=!0,u=v,h=v.version,d=t.toneMapping),n.unshift(a,a.geometry,a.material,0,0,null))}}}function ar(t,e,n,r){var i=t.getParameter(34921),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||null!==a,s={},c=d(null),l=c;function u(e){return r.isWebGL2?t.bindVertexArray(e):a.bindVertexArrayOES(e)}function h(e){return r.isWebGL2?t.deleteVertexArray(e):a.deleteVertexArrayOES(e)}function d(t){for(var e=[],n=[],r=[],a=0;a<i;a++)e[a]=0,n[a]=0,r[a]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:n,attributeDivisors:r,object:t,attributes:{},index:null}}function p(){for(var t=l.newAttributes,e=0,n=t.length;e<n;e++)t[e]=0}function f(t){m(t,0)}function m(n,i){var a=l.newAttributes,o=l.enabledAttributes,s=l.attributeDivisors;(a[n]=1,0===o[n]&&(t.enableVertexAttribArray(n),o[n]=1),s[n]!==i)&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,i),s[n]=i)}function v(){for(var e=l.newAttributes,n=l.enabledAttributes,r=0,i=n.length;r<i;r++)n[r]!==e[r]&&(t.disableVertexAttribArray(r),n[r]=0)}function g(e,n,i,a,o,s){!0!==r.isWebGL2||5124!==i&&5125!==i?t.vertexAttribPointer(e,n,i,a,o,s):t.vertexAttribIPointer(e,n,i,o,s)}function y(){x(),l!==c&&u((l=c).object)}function x(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:function(i,c,h,y,x){var _=!1;if(o){var b=function(e,n,i){var o=!0===i.wireframe,c=s[e.id];void 0===c&&(c={},s[e.id]=c);var l=c[n.id];void 0===l&&(l={},c[n.id]=l);var u=l[o];void 0===u&&(u=d(r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()),l[o]=u);return u}(y,h,c);l!==b&&u((l=b).object),(_=function(t,e){var n=l.attributes,r=t.attributes;if(Object.keys(n).length!==Object.keys(r).length)return!0;for(var i in r){var a=n[i],o=r[i];if(void 0===a)return!0;if(a.attribute!==o)return!0;if(a.data!==o.data)return!0}return l.index!==e}(y,x))&&function(t,e){var n={},r=t.attributes;for(var i in r){var a=r[i],o={};o.attribute=a,a.data&&(o.data=a.data),n[i]=o}l.attributes=n,l.index=e}(y,x)}else{var w=!0===c.wireframe;l.geometry===y.id&&l.program===h.id&&l.wireframe===w||(l.geometry=y.id,l.program=h.id,l.wireframe=w,_=!0)}!0===i.isInstancedMesh&&(_=!0),null!==x&&n.update(x,34963),_&&(!function(i,a,o,s){if(!1===r.isWebGL2&&(i.isInstancedMesh||s.isInstancedBufferGeometry)&&null===e.get("ANGLE_instanced_arrays"))return;p();var c=s.attributes,l=o.getAttributes(),u=a.defaultAttributeValues;for(var h in l){var d=l[h];if(d>=0){var y=c[h];if(void 0!==y){var x=y.normalized,_=y.itemSize,b=n.get(y);if(void 0===b)continue;var w=b.buffer,M=b.type,S=b.bytesPerElement;if(y.isInterleavedBufferAttribute){var T=y.data,E=T.stride,A=y.offset;T&&T.isInstancedInterleavedBuffer?(m(d,T.meshPerAttribute),void 0===s._maxInstanceCount&&(s._maxInstanceCount=T.meshPerAttribute*T.count)):f(d),t.bindBuffer(34962,w),g(d,_,M,x,E*S,A*S)}else y.isInstancedBufferAttribute?(m(d,y.meshPerAttribute),void 0===s._maxInstanceCount&&(s._maxInstanceCount=y.meshPerAttribute*y.count)):f(d),t.bindBuffer(34962,w),g(d,_,M,x,0,0)}else if("instanceMatrix"===h){var L=n.get(i.instanceMatrix);if(void 0===L)continue;var R=L.buffer,C=L.type;m(d+0,1),m(d+1,1),m(d+2,1),m(d+3,1),t.bindBuffer(34962,R),t.vertexAttribPointer(d+0,4,C,!1,64,0),t.vertexAttribPointer(d+1,4,C,!1,64,16),t.vertexAttribPointer(d+2,4,C,!1,64,32),t.vertexAttribPointer(d+3,4,C,!1,64,48)}else if("instanceColor"===h){var P=n.get(i.instanceColor);if(void 0===P)continue;var I=P.buffer,D=P.type;m(d,1),t.bindBuffer(34962,I),t.vertexAttribPointer(d,3,D,!1,12,0)}else if(void 0!==u){var O=u[h];if(void 0!==O)switch(O.length){case 2:t.vertexAttrib2fv(d,O);break;case 3:t.vertexAttrib3fv(d,O);break;case 4:t.vertexAttrib4fv(d,O);break;default:t.vertexAttrib1fv(d,O)}}}}v()}(i,c,h,y),null!==x&&t.bindBuffer(34963,n.get(x).buffer))},reset:y,resetDefaultState:x,dispose:function(){for(var t in y(),s){var e=s[t];for(var n in e){var r=e[n];for(var i in r)h(r[i].object),delete r[i];delete e[n]}delete s[t]}},releaseStatesOfGeometry:function(t){if(void 0!==s[t.id]){var e=s[t.id];for(var n in e){var r=e[n];for(var i in r)h(r[i].object),delete r[i];delete e[n]}delete s[t.id]}},releaseStatesOfProgram:function(t){for(var e in s){var n=s[e];if(void 0!==n[t.id]){var r=n[t.id];for(var i in r)h(r[i].object),delete r[i];delete n[t.id]}}},initAttributes:p,enableAttribute:f,disableUnusedAttributes:v}}function or(t,e,n,r){var i,a=r.isWebGL2;this.setMode=function(t){i=t},this.render=function(e,r){t.drawArrays(i,e,r),n.update(r,i,1)},this.renderInstances=function(r,o,s){if(0!==s){var c,l;if(a)c=t,l="drawArraysInstanced";else if(l="drawArraysInstancedANGLE",null===(c=e.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");c[l](i,r,o,s),n.update(o,i,s)}}}function sr(t,e,n){var r;function i(e){if("highp"===e){if(t.getShaderPrecisionFormat(35633,36338).precision>0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var a="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext,o=void 0!==n.precision?n.precision:"highp",s=i(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var c=!0===n.logarithmicDepthBuffer,l=t.getParameter(34930),u=t.getParameter(35660),h=t.getParameter(3379),d=t.getParameter(34076),p=t.getParameter(34921),f=t.getParameter(36347),m=t.getParameter(36348),v=t.getParameter(36349),g=u>0,y=a||!!e.get("OES_texture_float");return{isWebGL2:a,getMaxAnisotropy:function(){if(void 0!==r)return r;var n=e.get("EXT_texture_filter_anisotropic");return r=null!==n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:c,maxTextures:l,maxVertexTextures:u,maxTextureSize:h,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:v,vertexTextures:g,floatFragmentTextures:y,floatVertexTextures:g&&y,maxSamples:a?t.getParameter(36183):0}}function cr(t){var e=this,n=null,r=0,i=!1,a=!1,o=new Te,s=new ft,c={value:null,needsUpdate:!1};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function u(t,n,r,i){var a=null!==t?t.length:0,l=null;if(0!==a){if(l=c.value,!0!==i||null===l){var u=r+4*a,h=n.matrixWorldInverse;s.getNormalMatrix(h),(null===l||l.length<u)&&(l=new Float32Array(u));for(var d=0,p=r;d!==a;++d,p+=4)o.copy(t[d]).applyMatrix4(h,s),o.normal.toArray(l,p),l[p+3]=o.constant}c.value=l,c.needsUpdate=!0}return e.numPlanes=a,e.numIntersection=0,l}this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e,a){var o=0!==t.length||e||0!==r||i;return i=e,n=u(t,a,0),r=t.length,o},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1,l()},this.setState=function(e,o,s){var h=e.clippingPlanes,d=e.clipIntersection,p=e.clipShadows,f=t.get(e);if(!i||null===h||0===h.length||a&&!p)a?u(null):l();else{var m=a?0:r,v=4*m,g=f.clippingState||null;c.value=g,g=u(h,o,v,s);for(var y=0;y!==v;++y)g[y]=n[y];f.clippingState=g,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=m}}}function lr(t){var e=new WeakMap;function n(t,e){return e===a?t.mapping=r:e===o&&(t.mapping=i),t}function s(t){var n=t.target;n.removeEventListener("dispose",s);var r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){var i=r.mapping;if(i===a||i===o){if(e.has(r))return n(e.get(r).texture,r.mapping);var c=r.image;if(c&&c.height>0){var l=t.getRenderList(),u=t.getRenderTarget(),h=t.getRenderState(),d=new Xn(c.height/2);return d.fromEquirectangularTexture(t,r),e.set(r,d),t.setRenderTarget(u),t.setRenderList(l),t.setRenderState(h),r.addEventListener("dispose",s),n(d.texture,r.mapping)}return null}}return r},dispose:function(){e=new WeakMap}}}function ur(t){var e={};return{has:function(n){if(void 0!==e[n])return null!==e[n];var r;switch(n){case"WEBGL_depth_texture":r=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=t.getExtension(n)}return e[n]=r,null!==r},get:function(t){return this.has(t)||console.warn("THREE.WebGLRenderer: "+t+" extension not supported."),e[t]}}}function hr(t,e,n,r){var i=new WeakMap,a=new WeakMap;function o(t){var s=t.target,c=i.get(s);for(var l in null!==c.index&&e.remove(c.index),c.attributes)e.remove(c.attributes[l]);s.removeEventListener("dispose",o),i.delete(s);var u=a.get(c);u&&(e.remove(u),a.delete(c)),r.releaseStatesOfGeometry(c),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(t){var n=[],r=t.index,i=t.attributes.position,o=0;if(null!==r){var s=r.array;o=r.version;for(var c=0,l=s.length;c<l;c+=3){var u=s[c+0],h=s[c+1],d=s[c+2];n.push(u,h,h,d,d,u)}}else{var p=i.array;o=i.version;for(var f=0,m=p.length/3-1;f<m;f+=3){var v=f+0,g=f+1,y=f+2;n.push(v,g,g,y,y,v)}}var x=new(cn(n)>65535?rn:en)(n,1);x.version=o;var _=a.get(t);_&&e.remove(_),a.set(t,x)}return{get:function(t,e){var r=i.get(e);return r||(e.addEventListener("dispose",o),e.isBufferGeometry?r=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new vn).setFromObject(t)),r=e._bufferGeometry),i.set(e,r),n.memory.geometries++,r)},update:function(t){var n=t.attributes;for(var r in n)e.update(n[r],34962);var i=t.morphAttributes;for(var a in i)for(var o=i[a],s=0,c=o.length;s<c;s++)e.update(o[s],34962)},getWireframeAttribute:function(t){var e=a.get(t);if(e){var n=t.index;null!==n&&e.version<n.version&&s(t)}else s(t);return a.get(t)}}}function dr(t,e,n,r){var i,a,o,s=r.isWebGL2;this.setMode=function(t){i=t},this.setIndex=function(t){a=t.type,o=t.bytesPerElement},this.render=function(e,r){t.drawElements(i,r,a,e*o),n.update(r,i,1)},this.renderInstances=function(r,c,l){if(0!==l){var u,h;if(s)u=t,h="drawElementsInstanced";else if(h="drawElementsInstancedANGLE",null===(u=e.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");u[h](i,c,a,r*o,l),n.update(c,i,l)}}}function pr(t){var e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.frame++,e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(t,n,r){switch(e.calls++,n){case 4:e.triangles+=r*(t/3);break;case 1:e.lines+=r*(t/2);break;case 3:e.lines+=r*(t-1);break;case 2:e.lines+=r*t;break;case 0:e.points+=r*t;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function fr(t,e){return t[0]-e[0]}function mr(t,e){return Math.abs(e[1])-Math.abs(t[1])}function vr(t){for(var e={},n=new Float32Array(8),r=[],i=0;i<8;i++)r[i]=[i,0];return{update:function(i,a,o,s){var c=i.morphTargetInfluences,l=void 0===c?0:c.length,u=e[a.id];if(void 0===u){u=[];for(var h=0;h<l;h++)u[h]=[h,0];e[a.id]=u}for(var d=0;d<l;d++){var p=u[d];p[0]=d,p[1]=c[d]}u.sort(mr);for(var f=0;f<8;f++)f<l&&u[f][1]?(r[f][0]=u[f][0],r[f][1]=u[f][1]):(r[f][0]=Number.MAX_SAFE_INTEGER,r[f][1]=0);r.sort(fr);for(var m=o.morphTargets&&a.morphAttributes.position,v=o.morphNormals&&a.morphAttributes.normal,g=0,y=0;y<8;y++){var x=r[y],_=x[0],b=x[1];_!==Number.MAX_SAFE_INTEGER&&b?(m&&a.getAttribute("morphTarget"+y)!==m[_]&&a.setAttribute("morphTarget"+y,m[_]),v&&a.getAttribute("morphNormal"+y)!==v[_]&&a.setAttribute("morphNormal"+y,v[_]),n[y]=b,g+=b):(m&&void 0!==a.getAttribute("morphTarget"+y)&&a.deleteAttribute("morphTarget"+y),v&&void 0!==a.getAttribute("morphNormal"+y)&&a.deleteAttribute("morphNormal"+y),n[y]=0)}var w=a.morphTargetsRelative?1:1-g;s.getUniforms().setValue(t,"morphTargetBaseInfluence",w),s.getUniforms().setValue(t,"morphTargetInfluences",n)}}}function gr(t,e,n,r){var i=new WeakMap;return{update:function(t){var a=r.render.frame,o=t.geometry,s=e.get(t,o);return i.get(s)!==a&&(o.isGeometry&&s.updateFromObject(t),e.update(s),i.set(s,a)),t.isInstancedMesh&&(n.update(t.instanceMatrix,34962),null!==t.instanceColor&&n.update(t.instanceColor,34962)),s},dispose:function(){i=new WeakMap}}}function yr(t,e,n,r){gt.call(this,null),this.image={data:t||null,width:e||1,height:n||1,depth:r||1},this.magFilter=d,this.minFilter=d,this.wrapR=u,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}function xr(t,e,n,r){gt.call(this,null),this.image={data:t||null,width:e||1,height:n||1,depth:r||1},this.magFilter=d,this.minFilter=d,this.wrapR=u,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}rr.physical={uniforms:Fn([rr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new pt(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new Ve(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:er.meshphysical_vert,fragmentShader:er.meshphysical_frag},yr.prototype=Object.create(gt.prototype),yr.prototype.constructor=yr,yr.prototype.isDataTexture2DArray=!0,xr.prototype=Object.create(gt.prototype),xr.prototype.constructor=xr,xr.prototype.isDataTexture3D=!0;var _r=new gt,br=new yr,wr=new xr,Mr=new qn,Sr=[],Tr=[],Er=new Float32Array(16),Ar=new Float32Array(9),Lr=new Float32Array(4);function Rr(t,e,n){var r=t[0];if(r<=0||r>0)return t;var i=e*n,a=Sr[i];if(void 0===a&&(a=new Float32Array(i),Sr[i]=a),0!==e){r.toArray(a,0);for(var o=1,s=0;o!==e;++o)s+=n,t[o].toArray(a,s)}return a}function Cr(t,e){if(t.length!==e.length)return!1;for(var n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function Pr(t,e){for(var n=0,r=e.length;n<r;n++)t[n]=e[n]}function Ir(t,e){var n=Tr[e];void 0===n&&(n=new Int32Array(e),Tr[e]=n);for(var r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function Dr(t,e){var n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Or(t,e){var n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Cr(n,e))return;t.uniform2fv(this.addr,e),Pr(n,e)}}function Nr(t,e){var n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(void 0!==e.r)n[0]===e.r&&n[1]===e.g&&n[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(Cr(n,e))return;t.uniform3fv(this.addr,e),Pr(n,e)}}function Br(t,e){var n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Cr(n,e))return;t.uniform4fv(this.addr,e),Pr(n,e)}}function zr(t,e){var n=this.cache,r=e.elements;if(void 0===r){if(Cr(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Pr(n,e)}else{if(Cr(n,r))return;Lr.set(r),t.uniformMatrix2fv(this.addr,!1,Lr),Pr(n,r)}}function Gr(t,e){var n=this.cache,r=e.elements;if(void 0===r){if(Cr(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Pr(n,e)}else{if(Cr(n,r))return;Ar.set(r),t.uniformMatrix3fv(this.addr,!1,Ar),Pr(n,r)}}function Fr(t,e){var n=this.cache,r=e.elements;if(void 0===r){if(Cr(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Pr(n,e)}else{if(Cr(n,r))return;Er.set(r),t.uniformMatrix4fv(this.addr,!1,Er),Pr(n,r)}}function Ur(t,e,n){var r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.safeSetTexture2D(e||_r,i)}function Hr(t,e,n){var r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||br,i)}function kr(t,e,n){var r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||wr,i)}function Vr(t,e,n){var r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.safeSetTextureCube(e||Mr,i)}function Wr(t,e){var n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function jr(t,e){var n=this.cache;Cr(n,e)||(t.uniform2iv(this.addr,e),Pr(n,e))}function qr(t,e){var n=this.cache;Cr(n,e)||(t.uniform3iv(this.addr,e),Pr(n,e))}function Xr(t,e){var n=this.cache;Cr(n,e)||(t.uniform4iv(this.addr,e),Pr(n,e))}function Yr(t,e){var n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Zr(t,e){t.uniform1fv(this.addr,e)}function Jr(t,e){t.uniform1iv(this.addr,e)}function Qr(t,e){t.uniform2iv(this.addr,e)}function Kr(t,e){t.uniform3iv(this.addr,e)}function $r(t,e){t.uniform4iv(this.addr,e)}function ti(t,e){var n=Rr(e,this.size,2);t.uniform2fv(this.addr,n)}function ei(t,e){var n=Rr(e,this.size,3);t.uniform3fv(this.addr,n)}function ni(t,e){var n=Rr(e,this.size,4);t.uniform4fv(this.addr,n)}function ri(t,e){var n=Rr(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function ii(t,e){var n=Rr(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function ai(t,e){var n=Rr(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function oi(t,e,n){var r=e.length,i=Ir(n,r);t.uniform1iv(this.addr,i);for(var a=0;a!==r;++a)n.safeSetTexture2D(e[a]||_r,i[a])}function si(t,e,n){var r=e.length,i=Ir(n,r);t.uniform1iv(this.addr,i);for(var a=0;a!==r;++a)n.safeSetTextureCube(e[a]||Mr,i[a])}function ci(t,e,n){this.id=t,this.addr=n,this.cache=[],this.setValue=function(t){switch(t){case 5126:return Dr;case 35664:return Or;case 35665:return Nr;case 35666:return Br;case 35674:return zr;case 35675:return Gr;case 35676:return Fr;case 5124:case 35670:return Wr;case 35667:case 35671:return jr;case 35668:case 35672:return qr;case 35669:case 35673:return Xr;case 5125:return Yr;case 35678:case 36198:case 36298:case 36306:case 35682:return Ur;case 35679:case 36299:case 36307:return kr;case 35680:case 36300:case 36308:case 36293:return Vr;case 36289:case 36303:case 36311:case 36292:return Hr}}(e.type)}function li(t,e,n){this.id=t,this.addr=n,this.cache=[],this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Zr;case 35664:return ti;case 35665:return ei;case 35666:return ni;case 35674:return ri;case 35675:return ii;case 35676:return ai;case 5124:case 35670:return Jr;case 35667:case 35671:return Qr;case 35668:case 35672:return Kr;case 35669:case 35673:return $r;case 35678:case 36198:case 36298:case 36306:case 35682:return oi;case 35680:case 36300:case 36308:case 36293:return si}}(e.type)}function ui(t){this.id=t,this.seq=[],this.map={}}li.prototype.updateCache=function(t){var e=this.cache;t instanceof Float32Array&&e.length!==t.length&&(this.cache=new Float32Array(t.length)),Pr(e,t)},ui.prototype.setValue=function(t,e,n){for(var r=this.seq,i=0,a=r.length;i!==a;++i){var o=r[i];o.setValue(t,e[o.id],n)}};var hi=/([\w\d_]+)(\])?(\[|\.)?/g;function di(t,e){t.seq.push(e),t.map[e.id]=e}function pi(t,e,n){var r=t.name,i=r.length;for(hi.lastIndex=0;;){var a=hi.exec(r),o=hi.lastIndex,s=a[1],c="]"===a[2],l=a[3];if(c&&(s|=0),void 0===l||"["===l&&o+2===i){di(n,void 0===l?new ci(s,t,e):new li(s,t,e));break}var u=n.map[s];void 0===u&&di(n,u=new ui(s)),n=u}}function fi(t,e){this.seq=[],this.map={};for(var n=t.getProgramParameter(e,35718),r=0;r<n;++r){var i=t.getActiveUniform(e,r);pi(i,t.getUniformLocation(e,i.name),this)}}function mi(t,e,n){var r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}fi.prototype.setValue=function(t,e,n,r){var i=this.map[e];void 0!==i&&i.setValue(t,n,r)},fi.prototype.setOptional=function(t,e,n){var r=e[n];void 0!==r&&this.setValue(t,n,r)},fi.upload=function(t,e,n,r){for(var i=0,a=e.length;i!==a;++i){var o=e[i],s=n[o.id];!1!==s.needsUpdate&&o.setValue(t,s.value,r)}},fi.seqWithValue=function(t,e){for(var n=[],r=0,i=t.length;r!==i;++r){var a=t[r];a.id in e&&n.push(a)}return n};var vi=0;function gi(t){switch(t){case q:return["Linear","( value )"];case X:return["sRGB","( value )"];case Z:return["RGBE","( value )"];case J:return["RGBM","( value, 7.0 )"];case Q:return["RGBM","( value, 16.0 )"];case K:return["RGBD","( value, 256.0 )"];case Y:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case 3003:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",t),["Linear","( value )"]}}function yi(t,e,n){var r=t.getShaderParameter(e,35713),i=t.getShaderInfoLog(e).trim();return r&&""===i?"":"THREE.WebGLShader: gl.getShaderInfoLog() "+n+"\n"+i+function(t){for(var e=t.split("\n"),n=0;n<e.length;n++)e[n]=n+1+": "+e[n];return e.join("\n")}(t.getShaderSource(e))}function xi(t,e){var n=gi(e);return"vec4 "+t+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function _i(t,e){var n;switch(e){case 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="OptimizedCineon";break;case 4:n="ACESFilmic";break;case 5:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function bi(t){return""!==t}function wi(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Mi(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var Si=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ti(t){return t.replace(Si,Ei)}function Ei(t,e){var n=er[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return Ti(n)}var Ai=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,Li=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Ri(t){return t.replace(Li,Pi).replace(Ai,Ci)}function Ci(t,e,n,r){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),Pi(t,e,n,r)}function Pi(t,e,n,r){for(var i="",a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function Ii(t){var e="precision "+t.precision+" float;\nprecision "+t.precision+" int;";return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function Di(t,e,n,a){var o,l,u,h,d,p=t.getContext(),f=n.defines,m=n.vertexShader,v=n.fragmentShader,g=function(t){var e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(n),y=function(t){var e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case r:case i:e="ENVMAP_TYPE_CUBE";break;case s:case c:e="ENVMAP_TYPE_CUBE_UV"}return e}(n),x=function(t){var e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case i:case c:e="ENVMAP_MODE_REFRACTION"}return e}(n),_=function(t){var e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(n),b=t.gammaFactor>0?t.gammaFactor:1,w=n.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUV||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(bi).join("\n")}(n),M=function(t){var e=[];for(var n in t){var r=t[n];!1!==r&&e.push("#define "+n+" "+r)}return e.join("\n")}(f),S=p.createProgram(),T=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?((o=[M].filter(bi).join("\n")).length>0&&(o+="\n"),(l=[w,M].filter(bi).join("\n")).length>0&&(l+="\n")):(o=[Ii(n),"#define SHADER_NAME "+n.shaderName,M,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+b,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+x:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+g:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(bi).join("\n"),l=[w,Ii(n),"#define SHADER_NAME "+n.shaderName,M,n.alphaTest?"#define ALPHATEST "+n.alphaTest+(n.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+y:"",n.envMap?"#define "+x:"",n.envMap?"#define "+_:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.sheen?"#define USE_SHEEN":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+g:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?er.tonemapping_pars_fragment:"",0!==n.toneMapping?_i("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",er.encodings_pars_fragment,n.map?xi("mapTexelToLinear",n.mapEncoding):"",n.matcap?xi("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?xi("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?xi("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.lightMap?xi("lightMapTexelToLinear",n.lightMapEncoding):"",(u="linearToOutputTexel",h=n.outputEncoding,d=gi(h),"vec4 "+u+"( vec4 value ) { return LinearTo"+d[0]+d[1]+"; }"),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(bi).join("\n")),m=Mi(m=wi(m=Ti(m),n),n),v=Mi(v=wi(v=Ti(v),n),n),m=Ri(m),v=Ri(v),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(T="#version 300 es\n",o=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+o,l=["#define varying in",n.glslVersion===nt?"":"out highp vec4 pc_fragColor;",n.glslVersion===nt?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+l);var E,A,L=T+l+v,R=mi(p,35633,T+o+m),C=mi(p,35632,L);if(p.attachShader(S,R),p.attachShader(S,C),void 0!==n.index0AttributeName?p.bindAttribLocation(S,0,n.index0AttributeName):!0===n.morphTargets&&p.bindAttribLocation(S,0,"position"),p.linkProgram(S),t.debug.checkShaderErrors){var P=p.getProgramInfoLog(S).trim(),I=p.getShaderInfoLog(R).trim(),D=p.getShaderInfoLog(C).trim(),O=!0,N=!0;if(!1===p.getProgramParameter(S,35714)){O=!1;var B=yi(p,R,"vertex"),z=yi(p,C,"fragment");console.error("THREE.WebGLProgram: shader error: ",p.getError(),"35715",p.getProgramParameter(S,35715),"gl.getProgramInfoLog",P,B,z)}else""!==P?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",P):""!==I&&""!==D||(N=!1);N&&(this.diagnostics={runnable:O,programLog:P,vertexShader:{log:I,prefix:o},fragmentShader:{log:D,prefix:l}})}return p.deleteShader(R),p.deleteShader(C),this.getUniforms=function(){return void 0===E&&(E=new fi(p,S)),E},this.getAttributes=function(){return void 0===A&&(A=function(t,e){for(var n={},r=t.getProgramParameter(e,35721),i=0;i<r;i++){var a=t.getActiveAttrib(e,i).name;n[a]=t.getAttribLocation(e,a)}return n}(p,S)),A},this.destroy=function(){a.releaseStatesOfProgram(this),p.deleteProgram(S),this.program=void 0},this.name=n.shaderName,this.id=vi++,this.cacheKey=e,this.usedTimes=1,this.program=S,this.vertexShader=R,this.fragmentShader=C,this}function Oi(t,e,n,r,i,a){var o=[],l=r.isWebGL2,u=r.logarithmicDepthBuffer,h=r.floatVertexTextures,d=r.maxVertexUniforms,p=r.vertexTextures,f=r.precision,m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},v=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen","transmissionMap"];function g(t){var e;return t?t.isTexture?e=t.encoding:t.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),e=t.texture.encoding):e=q,e}return{getParameters:function(i,o,v,y,x){var _,b,w=y.fog,M=i.isMeshStandardMaterial?y.environment:null,S=e.get(i.envMap||M),T=m[i.type],E=x.isSkinnedMesh?function(t){var e=t.skeleton.bones;if(h)return 1024;var n=d,r=Math.floor((n-20)/4),i=Math.min(r,e.length);return i<e.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+e.length+" bones. This GPU supports "+i+"."),0):i}(x):0;if(null!==i.precision&&(f=r.getMaxPrecision(i.precision))!==i.precision&&console.warn("THREE.WebGLProgram.getParameters:",i.precision,"not supported, using",f,"instead."),T){var A=rr[T];_=A.vertexShader,b=A.fragmentShader}else _=i.vertexShader,b=i.fragmentShader;var L=t.getRenderTarget();return{isWebGL2:l,shaderID:T,shaderName:i.type,vertexShader:_,fragmentShader:b,defines:i.defines,isRawShaderMaterial:!0===i.isRawShaderMaterial,glslVersion:i.glslVersion,precision:f,instancing:!0===x.isInstancedMesh,instancingColor:!0===x.isInstancedMesh&&null!==x.instanceColor,supportsVertexTextures:p,outputEncoding:null!==L?g(L.texture):t.outputEncoding,map:!!i.map,mapEncoding:g(i.map),matcap:!!i.matcap,matcapEncoding:g(i.matcap),envMap:!!S,envMapMode:S&&S.mapping,envMapEncoding:g(S),envMapCubeUV:!!S&&(S.mapping===s||S.mapping===c),lightMap:!!i.lightMap,lightMapEncoding:g(i.lightMap),aoMap:!!i.aoMap,emissiveMap:!!i.emissiveMap,emissiveMapEncoding:g(i.emissiveMap),bumpMap:!!i.bumpMap,normalMap:!!i.normalMap,objectSpaceNormalMap:1===i.normalMapType,tangentSpaceNormalMap:0===i.normalMapType,clearcoatMap:!!i.clearcoatMap,clearcoatRoughnessMap:!!i.clearcoatRoughnessMap,clearcoatNormalMap:!!i.clearcoatNormalMap,displacementMap:!!i.displacementMap,roughnessMap:!!i.roughnessMap,metalnessMap:!!i.metalnessMap,specularMap:!!i.specularMap,alphaMap:!!i.alphaMap,gradientMap:!!i.gradientMap,sheen:!!i.sheen,transmissionMap:!!i.transmissionMap,combine:i.combine,vertexTangents:i.normalMap&&i.vertexTangents,vertexColors:i.vertexColors,vertexUvs:!!(i.map||i.bumpMap||i.normalMap||i.specularMap||i.alphaMap||i.emissiveMap||i.roughnessMap||i.metalnessMap||i.clearcoatMap||i.clearcoatRoughnessMap||i.clearcoatNormalMap||i.displacementMap||i.transmissionMap),uvsVertexOnly:!(i.map||i.bumpMap||i.normalMap||i.specularMap||i.alphaMap||i.emissiveMap||i.roughnessMap||i.metalnessMap||i.clearcoatNormalMap||i.transmissionMap||!i.displacementMap),fog:!!w,useFog:i.fog,fogExp2:w&&w.isFogExp2,flatShading:i.flatShading,sizeAttenuation:i.sizeAttenuation,logarithmicDepthBuffer:u,skinning:i.skinning&&E>0,maxBones:E,useVertexTexture:h,morphTargets:i.morphTargets,morphNormals:i.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:t.shadowMap.enabled&&v.length>0,shadowMapType:t.shadowMap.type,toneMapping:i.toneMapped?t.toneMapping:0,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:i.premultipliedAlpha,alphaTest:i.alphaTest,doubleSided:2===i.side,flipSided:1===i.side,depthPacking:void 0!==i.depthPacking&&i.depthPacking,index0AttributeName:i.index0AttributeName,extensionDerivatives:i.extensions&&i.extensions.derivatives,extensionFragDepth:i.extensions&&i.extensions.fragDepth,extensionDrawBuffers:i.extensions&&i.extensions.drawBuffers,extensionShaderTextureLOD:i.extensions&&i.extensions.shaderTextureLOD,rendererExtensionFragDepth:l||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:l||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:l||n.has("EXT_shader_texture_lod"),customProgramCacheKey:i.customProgramCacheKey()}},getProgramCacheKey:function(e){var n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.fragmentShader),n.push(e.vertexShader)),void 0!==e.defines)for(var r in e.defines)n.push(r),n.push(e.defines[r]);if(!1===e.isRawShaderMaterial){for(var i=0;i<v.length;i++)n.push(e[v[i]]);n.push(t.outputEncoding),n.push(t.gammaFactor)}return n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){var e,n=m[t.type];if(n){var r=rr[n];e=Un.clone(r.uniforms)}else e=t.uniforms;return e},acquireProgram:function(e,n){for(var r,a=0,s=o.length;a<s;a++){var c=o[a];if(c.cacheKey===n){++(r=c).usedTimes;break}}return void 0===r&&(r=new Di(t,n,e,i),o.push(r)),r},releaseProgram:function(t){if(0==--t.usedTimes){var e=o.indexOf(t);o[e]=o[o.length-1],o.pop(),t.destroy()}},programs:o}}function Ni(){var t=new WeakMap;return{get:function(e){var n=t.get(e);return void 0===n&&(n={},t.set(e,n)),n},remove:function(e){t.delete(e)},update:function(e,n,r){t.get(e)[n]=r},dispose:function(){t=new WeakMap}}}function Bi(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function zi(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Gi(t){var e=[],n=0,r=[],i=[],a={id:-1};function o(r,i,o,s,c,l){var u=e[n],h=t.get(o);return void 0===u?(u={id:r.id,object:r,geometry:i,material:o,program:h.program||a,groupOrder:s,renderOrder:r.renderOrder,z:c,group:l},e[n]=u):(u.id=r.id,u.object=r,u.geometry=i,u.material=o,u.program=h.program||a,u.groupOrder=s,u.renderOrder=r.renderOrder,u.z=c,u.group=l),n++,u}return{opaque:r,transparent:i,init:function(){n=0,r.length=0,i.length=0},push:function(t,e,n,a,s,c){var l=o(t,e,n,a,s,c);(!0===n.transparent?i:r).push(l)},unshift:function(t,e,n,a,s,c){var l=o(t,e,n,a,s,c);(!0===n.transparent?i:r).unshift(l)},finish:function(){for(var t=n,r=e.length;t<r;t++){var i=e[t];if(null===i.id)break;i.id=null,i.object=null,i.geometry=null,i.material=null,i.program=null,i.group=null}},sort:function(t,e){r.length>1&&r.sort(t||Bi),i.length>1&&i.sort(e||zi)}}}function Fi(t){var e=new WeakMap;return{get:function(n,r){var i,a=e.get(n);return void 0===a?(i=new Gi(t),e.set(n,new WeakMap),e.get(n).set(r,i)):void 0===(i=a.get(r))&&(i=new Gi(t),a.set(r,i)),i},dispose:function(){e=new WeakMap}}}function Ui(){var t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];var n;switch(e.type){case"DirectionalLight":n={direction:new wt,color:new Ve};break;case"SpotLight":n={position:new wt,direction:new wt,color:new Ve,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new wt,color:new Ve,distance:0,decay:0};break;case"HemisphereLight":n={direction:new wt,skyColor:new Ve,groundColor:new Ve};break;case"RectAreaLight":n={color:new Ve,position:new wt,halfWidth:new wt,halfHeight:new wt}}return t[e.id]=n,n}}}var Hi=0;function ki(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function Vi(t,e){for(var n,r=new Ui,i=(n={},{get:function(t){if(void 0!==n[t.id])return n[t.id];var e;switch(t.type){case"DirectionalLight":case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pt};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pt,shadowCameraNear:1,shadowCameraFar:1e3}}return n[t.id]=e,e}}),a={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},o=0;o<9;o++)a.probe.push(new wt);var s=new wt,c=new Jt,l=new Jt;return{setup:function(n,o,u){for(var h=0,d=0,p=0,f=0;f<9;f++)a.probe[f].set(0,0,0);var m=0,v=0,g=0,y=0,x=0,_=0,b=0,w=0,M=u.matrixWorldInverse;n.sort(ki);for(var S=0,T=n.length;S<T;S++){var E=n[S],A=E.color,L=E.intensity,R=E.distance,C=E.shadow&&E.shadow.map?E.shadow.map.texture:null;if(E.isAmbientLight)h+=A.r*L,d+=A.g*L,p+=A.b*L;else if(E.isLightProbe)for(var P=0;P<9;P++)a.probe[P].addScaledVector(E.sh.coefficients[P],L);else if(E.isDirectionalLight){var I=r.get(E);if(I.color.copy(E.color).multiplyScalar(E.intensity),I.direction.setFromMatrixPosition(E.matrixWorld),s.setFromMatrixPosition(E.target.matrixWorld),I.direction.sub(s),I.direction.transformDirection(M),E.castShadow){var D=E.shadow,O=i.get(E);O.shadowBias=D.bias,O.shadowNormalBias=D.normalBias,O.shadowRadius=D.radius,O.shadowMapSize=D.mapSize,a.directionalShadow[m]=O,a.directionalShadowMap[m]=C,a.directionalShadowMatrix[m]=E.shadow.matrix,_++}a.directional[m]=I,m++}else if(E.isSpotLight){var N=r.get(E);if(N.position.setFromMatrixPosition(E.matrixWorld),N.position.applyMatrix4(M),N.color.copy(A).multiplyScalar(L),N.distance=R,N.direction.setFromMatrixPosition(E.matrixWorld),s.setFromMatrixPosition(E.target.matrixWorld),N.direction.sub(s),N.direction.transformDirection(M),N.coneCos=Math.cos(E.angle),N.penumbraCos=Math.cos(E.angle*(1-E.penumbra)),N.decay=E.decay,E.castShadow){var B=E.shadow,z=i.get(E);z.shadowBias=B.bias,z.shadowNormalBias=B.normalBias,z.shadowRadius=B.radius,z.shadowMapSize=B.mapSize,a.spotShadow[g]=z,a.spotShadowMap[g]=C,a.spotShadowMatrix[g]=E.shadow.matrix,w++}a.spot[g]=N,g++}else if(E.isRectAreaLight){var G=r.get(E);G.color.copy(A).multiplyScalar(L),G.position.setFromMatrixPosition(E.matrixWorld),G.position.applyMatrix4(M),l.identity(),c.copy(E.matrixWorld),c.premultiply(M),l.extractRotation(c),G.halfWidth.set(.5*E.width,0,0),G.halfHeight.set(0,.5*E.height,0),G.halfWidth.applyMatrix4(l),G.halfHeight.applyMatrix4(l),a.rectArea[y]=G,y++}else if(E.isPointLight){var F=r.get(E);if(F.position.setFromMatrixPosition(E.matrixWorld),F.position.applyMatrix4(M),F.color.copy(E.color).multiplyScalar(E.intensity),F.distance=E.distance,F.decay=E.decay,E.castShadow){var U=E.shadow,H=i.get(E);H.shadowBias=U.bias,H.shadowNormalBias=U.normalBias,H.shadowRadius=U.radius,H.shadowMapSize=U.mapSize,H.shadowCameraNear=U.camera.near,H.shadowCameraFar=U.camera.far,a.pointShadow[v]=H,a.pointShadowMap[v]=C,a.pointShadowMatrix[v]=E.shadow.matrix,b++}a.point[v]=F,v++}else if(E.isHemisphereLight){var k=r.get(E);k.direction.setFromMatrixPosition(E.matrixWorld),k.direction.transformDirection(M),k.direction.normalize(),k.skyColor.copy(E.color).multiplyScalar(L),k.groundColor.copy(E.groundColor).multiplyScalar(L),a.hemi[x]=k,x++}}y>0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(a.rectAreaLTC1=nr.LTC_FLOAT_1,a.rectAreaLTC2=nr.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(a.rectAreaLTC1=nr.LTC_HALF_1,a.rectAreaLTC2=nr.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),a.ambient[0]=h,a.ambient[1]=d,a.ambient[2]=p;var V=a.hash;V.directionalLength===m&&V.pointLength===v&&V.spotLength===g&&V.rectAreaLength===y&&V.hemiLength===x&&V.numDirectionalShadows===_&&V.numPointShadows===b&&V.numSpotShadows===w||(a.directional.length=m,a.spot.length=g,a.rectArea.length=y,a.point.length=v,a.hemi.length=x,a.directionalShadow.length=_,a.directionalShadowMap.length=_,a.pointShadow.length=b,a.pointShadowMap.length=b,a.spotShadow.length=w,a.spotShadowMap.length=w,a.directionalShadowMatrix.length=_,a.pointShadowMatrix.length=b,a.spotShadowMatrix.length=w,V.directionalLength=m,V.pointLength=v,V.spotLength=g,V.rectAreaLength=y,V.hemiLength=x,V.numDirectionalShadows=_,V.numPointShadows=b,V.numSpotShadows=w,a.version=Hi++)},state:a}}function Wi(t,e){var n=new Vi(t,e),r=[],i=[];return{init:function(){r.length=0,i.length=0},state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:function(t){n.setup(r,i,t)},pushLight:function(t){r.push(t)},pushShadow:function(t){i.push(t)}}}function ji(t,e){var n=new WeakMap;return{get:function(r,i){var a;return!1===n.has(r)?(a=new Wi(t,e),n.set(r,new WeakMap),n.get(r).set(i,a)):!1===n.get(r).has(i)?(a=new Wi(t,e),n.get(r).set(i,a)):a=n.get(r).get(i),a},dispose:function(){n=new WeakMap}}}function qi(t){qe.call(this),this.type="MeshDepthMaterial",this.depthPacking=3200,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(t)}function Xi(t){qe.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new wt,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(t)}qi.prototype=Object.create(qe.prototype),qi.prototype.constructor=qi,qi.prototype.isMeshDepthMaterial=!0,qi.prototype.copy=function(t){return qe.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},Xi.prototype=Object.create(qe.prototype),Xi.prototype.constructor=Xi,Xi.prototype.isMeshDistanceMaterial=!0,Xi.prototype.copy=function(t){return qe.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this};function Yi(t,e,n){var r=new Qn,i=new pt,a=new pt,o=new yt,s=[],c=[],l={},u={0:1,1:0,2:2},h=new Hn({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new pt},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n\tfor ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n\t\t#ifdef HORIZONAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean * HALF_SAMPLE_RATE;\n\tsquared_mean = squared_mean * HALF_SAMPLE_RATE;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=h.clone();p.defines.HORIZONAL_PASS=1;var f=new vn;f.setAttribute("position",new Je(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var v=new On(f,h),g=this;function y(n,r){var i=e.update(v);h.uniforms.shadow_pass.value=n.map.texture,h.uniforms.resolution.value=n.mapSize,h.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(r,null,i,h,v,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(r,null,i,p,v,null)}function x(t,e,n){var r=t<<0|e<<1|n<<2,i=s[r];return void 0===i&&(i=new qi({depthPacking:3201,morphTargets:t,skinning:e}),s[r]=i),i}function _(t,e,n){var r=t<<0|e<<1|n<<2,i=c[r];return void 0===i&&(i=new Xi({morphTargets:t,skinning:e}),c[r]=i),i}function b(e,n,r,i,a,o,s){var c=null,h=x,d=e.customDepthMaterial;if(!0===i.isPointLight&&(h=_,d=e.customDistanceMaterial),void 0===d){var p=!1;!0===r.morphTargets&&(p=n.morphAttributes&&n.morphAttributes.position&&n.morphAttributes.position.length>0);var f=!1;!0===e.isSkinnedMesh&&(!0===r.skinning?f=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e)),c=h(p,f,!0===e.isInstancedMesh)}else c=d;if(t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var m=c.uuid,v=r.uuid,g=l[m];void 0===g&&(g={},l[m]=g);var y=g[v];void 0===y&&(y=c.clone(),g[v]=y),c=y}return c.visible=r.visible,c.wireframe=r.wireframe,c.side=3===s?null!==r.shadowSide?r.shadowSide:r.side:null!==r.shadowSide?r.shadowSide:u[r.side],c.clipShadows=r.clipShadows,c.clippingPlanes=r.clippingPlanes,c.clipIntersection=r.clipIntersection,c.wireframeLinewidth=r.wireframeLinewidth,c.linewidth=r.linewidth,!0===i.isPointLight&&!0===c.isMeshDistanceMaterial&&(c.referencePosition.setFromMatrixPosition(i.matrixWorld),c.nearDistance=a,c.farDistance=o),c}function w(n,i,a,o,s){if(!1!==n.visible){if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===s)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);var c=e.update(n),l=n.material;if(Array.isArray(l))for(var u=c.groups,h=0,d=u.length;h<d;h++){var p=u[h],f=l[p.materialIndex];if(f&&f.visible){var m=b(n,c,f,o,a.near,a.far,s);t.renderBufferDirect(a,null,c,m,n,p)}}else if(l.visible){var v=b(n,c,l,o,a.near,a.far,s);t.renderBufferDirect(a,null,c,v,n,null)}}for(var g=n.children,y=0,x=g.length;y<x;y++)w(g[y],i,a,o,s)}}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.render=function(e,s,c){if(!1!==g.enabled&&(!1!==g.autoUpdate||!1!==g.needsUpdate)&&0!==e.length){var l=t.getRenderTarget(),u=t.getActiveCubeFace(),h=t.getActiveMipmapLevel(),p=t.state;p.setBlending(0),p.buffers.color.setClear(1,1,1,1),p.buffers.depth.setTest(!0),p.setScissorTest(!1);for(var f=0,v=e.length;f<v;f++){var x=e[f],_=x.shadow;if(void 0!==_){if(!1!==_.autoUpdate||!1!==_.needsUpdate){i.copy(_.mapSize);var b=_.getFrameExtents();if(i.multiply(b),a.copy(_.mapSize),(i.x>n||i.y>n)&&(i.x>n&&(a.x=Math.floor(n/b.x),i.x=a.x*b.x,_.mapSize.x=a.x),i.y>n&&(a.y=Math.floor(n/b.y),i.y=a.y*b.y,_.mapSize.y=a.y)),null===_.map&&!_.isPointLightShadow&&3===this.type){var M={minFilter:m,magFilter:m,format:T};_.map=new xt(i.x,i.y,M),_.map.texture.name=x.name+".shadowMap",_.mapPass=new xt(i.x,i.y,M),_.camera.updateProjectionMatrix()}if(null===_.map){var S={minFilter:d,magFilter:d,format:T};_.map=new xt(i.x,i.y,S),_.map.texture.name=x.name+".shadowMap",_.camera.updateProjectionMatrix()}t.setRenderTarget(_.map),t.clear();for(var E=_.getViewportCount(),A=0;A<E;A++){var L=_.getViewport(A);o.set(a.x*L.x,a.y*L.y,a.x*L.z,a.y*L.w),p.viewport(o),_.updateMatrices(x,A),r=_.getFrustum(),w(s,c,_.camera,x,this.type)}_.isPointLightShadow||3!==this.type||y(_,c),_.needsUpdate=!1}}else console.warn("THREE.WebGLShadowMap:",x,"has no shadow.")}g.needsUpdate=!1,t.setRenderTarget(l,u,h)}}}function Zi(t,n,r){var i,a,o=r.isWebGL2;var s=new function(){var e=!1,n=new yt,r=null,i=new yt(0,0,0,0);return{setMask:function(n){r===n||e||(t.colorMask(n,n,n,n),r=n)},setLocked:function(t){e=t},setClear:function(e,r,a,o,s){!0===s&&(e*=o,r*=o,a*=o),n.set(e,r,a,o),!1===i.equals(n)&&(t.clearColor(e,r,a,o),i.copy(n))},reset:function(){e=!1,r=null,i.set(-1,0,0,0)}}},c=new function(){var e=!1,n=null,r=null,i=null;return{setTest:function(t){t?B(2929):z(2929)},setMask:function(r){n===r||e||(t.depthMask(r),n=r)},setFunc:function(e){if(r!==e){if(e)switch(e){case 0:t.depthFunc(512);break;case 1:t.depthFunc(519);break;case 2:t.depthFunc(513);break;case 3:t.depthFunc(515);break;case 4:t.depthFunc(514);break;case 5:t.depthFunc(518);break;case 6:t.depthFunc(516);break;case 7:t.depthFunc(517);break;default:t.depthFunc(515)}else t.depthFunc(515);r=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,n=null,r=null,i=null}}},l=new function(){var e=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(t){e||(t?B(2960):z(2960))},setMask:function(r){n===r||e||(t.stencilMask(r),n=r)},setFunc:function(e,n,o){r===e&&i===n&&a===o||(t.stencilFunc(e,n,o),r=e,i=n,a=o)},setOp:function(e,n,r){o===e&&s===n&&c===r||(t.stencilOp(e,n,r),o=e,s=n,c=r)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null}}},u={},h=null,d=null,p=null,f=null,m=null,v=null,g=null,y=null,x=null,_=!1,b=null,w=null,M=null,S=null,T=null,E=t.getParameter(35661),A=!1,L=0,R=t.getParameter(7938);-1!==R.indexOf("WebGL")?(L=parseFloat(/^WebGL\ ([0-9])/.exec(R)[1]),A=L>=1):-1!==R.indexOf("OpenGL ES")&&(L=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(R)[1]),A=L>=2);var C=null,P={},I=new yt,D=new yt;function O(e,n,r){var i=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(var o=0;o<r;o++)t.texImage2D(n+o,0,6408,1,1,0,6408,5121,i);return a}var N={};function B(e){!0!==u[e]&&(t.enable(e),u[e]=!0)}function z(e){!1!==u[e]&&(t.disable(e),u[e]=!1)}N[3553]=O(3553,3553,1),N[34067]=O(34067,34069,6),s.setClear(0,0,0,1),c.setClear(1),l.setClear(0),B(2929),c.setFunc(3),k(!1),V(1),B(2884),H(0);var G=((i={})[100]=32774,i[101]=32778,i[102]=32779,i);if(o)G[103]=32775,G[104]=32776;else{var F=n.get("EXT_blend_minmax");null!==F&&(G[103]=F.MIN_EXT,G[104]=F.MAX_EXT)}var U=((a={})[200]=0,a[201]=1,a[202]=768,a[204]=770,a[210]=776,a[208]=774,a[206]=772,a[203]=769,a[205]=771,a[209]=775,a[207]=773,a);function H(n,r,i,a,o,s,c,l){if(0!==n){if(d||(B(3042),d=!0),5===n)o=o||r,s=s||i,c=c||a,r===f&&o===g||(t.blendEquationSeparate(G[r],G[o]),f=r,g=o),i===m&&a===v&&s===y&&c===x||(t.blendFuncSeparate(U[i],U[a],U[s],U[c]),m=i,v=a,y=s,x=c),p=n,_=null;else if(n!==p||l!==_){if(f===e&&g===e||(t.blendEquation(32774),f=e,g=e),l)switch(n){case 1:t.blendFuncSeparate(1,771,1,771);break;case 2:t.blendFunc(1,1);break;case 3:t.blendFuncSeparate(0,0,769,771);break;case 4:t.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",n)}else switch(n){case 1:t.blendFuncSeparate(770,771,1,771);break;case 2:t.blendFunc(770,1);break;case 3:t.blendFunc(0,769);break;case 4:t.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",n)}m=null,v=null,y=null,x=null,p=n,_=l}}else d&&(z(3042),d=!1)}function k(e){b!==e&&(e?t.frontFace(2304):t.frontFace(2305),b=e)}function V(e){0!==e?(B(2884),e!==w&&(1===e?t.cullFace(1029):2===e?t.cullFace(1028):t.cullFace(1032))):z(2884),w=e}function W(e,n,r){e?(B(32823),S===n&&T===r||(t.polygonOffset(n,r),S=n,T=r)):z(32823)}function j(e){void 0===e&&(e=33984+E-1),C!==e&&(t.activeTexture(e),C=e)}return{buffers:{color:s,depth:c,stencil:l},enable:B,disable:z,useProgram:function(e){return h!==e&&(t.useProgram(e),h=e,!0)},setBlending:H,setMaterial:function(t,e){2===t.side?z(2884):B(2884);var n=1===t.side;e&&(n=!n),k(n),1===t.blending&&!1===t.transparent?H(0):H(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),c.setFunc(t.depthFunc),c.setTest(t.depthTest),c.setMask(t.depthWrite),s.setMask(t.colorWrite);var r=t.stencilWrite;l.setTest(r),r&&(l.setMask(t.stencilWriteMask),l.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),l.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),W(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits)},setFlipSided:k,setCullFace:V,setLineWidth:function(e){e!==M&&(A&&t.lineWidth(e),M=e)},setPolygonOffset:W,setScissorTest:function(t){t?B(3089):z(3089)},activeTexture:j,bindTexture:function(e,n){null===C&&j();var r=P[C];void 0===r&&(r={type:void 0,texture:void 0},P[C]=r),r.type===e&&r.texture===n||(t.bindTexture(e,n||N[e]),r.type=e,r.texture=n)},unbindTexture:function(){var e=P[C];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===I.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),I.copy(e))},viewport:function(e){!1===D.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),D.copy(e))},reset:function(){u={},C=null,P={},h=null,p=null,b=null,w=null,s.reset(),c.reset(),l.reset()}}}function Ji(t,e,n,r,i,a,o){var s,c,l,h=i.isWebGL2,v=i.maxTextures,g=i.maxCubemapSize,y=i.maxTextureSize,L=i.maxSamples,R=new WeakMap,C=!1;try{C="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function P(t,e){return C?new OffscreenCanvas(t,e):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function I(t,e,n,r){var i=1;if((t.width>r||t.height>r)&&(i=r/Math.max(t.width,t.height)),i<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){var a=e?st.floorPowerOfTwo:Math.floor,o=a(i*t.width),s=a(i*t.height);void 0===l&&(l=P(o,s));var c=n?P(o,s):l;return c.width=o,c.height=s,c.getContext("2d").drawImage(t,0,0,o,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+o+"x"+s+")."),c}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function D(t){return st.isPowerOfTwo(t.width)&&st.isPowerOfTwo(t.height)}function O(t,e){return t.generateMipmaps&&e&&t.minFilter!==d&&t.minFilter!==m}function N(e,n,i,a){t.generateMipmap(e),r.get(n).__maxMipLevel=Math.log(Math.max(i,a))*Math.LOG2E}function B(n,r,i){if(!1===h)return r;if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}var a=r;return 6403===r&&(5126===i&&(a=33326),5131===i&&(a=33325),5121===i&&(a=33321)),6407===r&&(5126===i&&(a=34837),5131===i&&(a=34843),5121===i&&(a=32849)),6408===r&&(5126===i&&(a=34836),5131===i&&(a=34842),5121===i&&(a=32856)),33325!==a&&33326!==a&&34842!==a&&34836!==a||e.get("EXT_color_buffer_float"),a}function z(t){return t===d||t===p||t===f?9728:9729}function G(e){var n=e.target;n.removeEventListener("dispose",G),function(e){var n=r.get(e);if(void 0===n.__webglInit)return;t.deleteTexture(n.__webglTexture),r.remove(e)}(n),n.isVideoTexture&&R.delete(n),o.memory.textures--}function F(e){var n=e.target;n.removeEventListener("dispose",F),function(e){var n=r.get(e),i=r.get(e.texture);if(!e)return;void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(var a=0;a<6;a++)t.deleteFramebuffer(n.__webglFramebuffer[a]),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[a]);else t.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&t.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer&&t.deleteRenderbuffer(n.__webglColorRenderbuffer),n.__webglDepthRenderbuffer&&t.deleteRenderbuffer(n.__webglDepthRenderbuffer);r.remove(e.texture),r.remove(e)}(n),o.memory.textures--}var U=0;function H(t,e){var i=r.get(t);if(t.isVideoTexture&&function(t){var e=o.render.frame;R.get(t)!==e&&(R.set(t,e),t.update())}(t),t.version>0&&i.__version!==t.version){var a=t.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==a.complete)return void X(i,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+e),n.bindTexture(3553,i.__webglTexture)}function k(e,i){var o=r.get(e);e.version>0&&o.__version!==e.version?function(e,r,i){if(6!==r.image.length)return;q(e,r),n.activeTexture(33984+i),n.bindTexture(34067,e.__webglTexture),t.pixelStorei(37440,r.flipY);for(var o=r&&(r.isCompressedTexture||r.image[0].isCompressedTexture),s=r.image[0]&&r.image[0].isDataTexture,c=[],l=0;l<6;l++)c[l]=o||s?s?r.image[l].image:r.image[l]:I(r.image[l],!1,!0,g);var u,d=c[0],p=D(d)||h,f=a.convert(r.format),m=a.convert(r.type),v=B(r.internalFormat,f,m);if(j(34067,r,p),o){for(var y=0;y<6;y++){u=c[y].mipmaps;for(var x=0;x<u.length;x++){var _=u[x];r.format!==T&&r.format!==S?null!==f?n.compressedTexImage2D(34069+y,x,v,_.width,_.height,0,_.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(34069+y,x,v,_.width,_.height,0,f,m,_.data)}}e.__maxMipLevel=u.length-1}else{u=r.mipmaps;for(var b=0;b<6;b++)if(s){n.texImage2D(34069+b,0,v,c[b].width,c[b].height,0,f,m,c[b].data);for(var w=0;w<u.length;w++){var M=u[w].image[b].image;n.texImage2D(34069+b,w+1,v,M.width,M.height,0,f,m,M.data)}}else{n.texImage2D(34069+b,0,v,f,m,c[b]);for(var E=0;E<u.length;E++){var A=u[E];n.texImage2D(34069+b,E+1,v,f,m,A.image[b])}}e.__maxMipLevel=u.length}O(r,p)&&N(34067,r,d.width,d.height);e.__version=r.version,r.onUpdate&&r.onUpdate(r)}(o,e,i):(n.activeTexture(33984+i),n.bindTexture(34067,o.__webglTexture))}var V=((s={})[1e3]=10497,s[1001]=33071,s[1002]=33648,s),W=((c={})[1003]=9728,c[1004]=9984,c[1005]=9986,c[1006]=9729,c[1007]=9985,c[1008]=9987,c);function j(n,a,o){o?(t.texParameteri(n,10242,V[a.wrapS]),t.texParameteri(n,10243,V[a.wrapT]),32879!==n&&35866!==n||t.texParameteri(n,32882,V[a.wrapR]),t.texParameteri(n,10240,W[a.magFilter]),t.texParameteri(n,10241,W[a.minFilter])):(t.texParameteri(n,10242,33071),t.texParameteri(n,10243,33071),32879!==n&&35866!==n||t.texParameteri(n,32882,33071),a.wrapS===u&&a.wrapT===u||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(n,10240,z(a.magFilter)),t.texParameteri(n,10241,z(a.minFilter)),a.minFilter!==d&&a.minFilter!==m&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));var s=e.get("EXT_texture_filter_anisotropic");if(s){if(a.type===b&&null===e.get("OES_texture_float_linear"))return;if(a.type===w&&null===(h||e.get("OES_texture_half_float_linear")))return;(a.anisotropy>1||r.get(a).__currentAnisotropy)&&(t.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function q(e,n){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",G),e.__webglTexture=t.createTexture(),o.memory.textures++)}function X(e,r,i){var o=3553;r.isDataTexture2DArray&&(o=35866),r.isDataTexture3D&&(o=32879),q(e,r),n.activeTexture(33984+i),n.bindTexture(o,e.__webglTexture),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment);var s,c=function(t){return!h&&(t.wrapS!==u||t.wrapT!==u||t.minFilter!==d&&t.minFilter!==m)}(r)&&!1===D(r.image),l=I(r.image,c,!1,y),p=D(l)||h,f=a.convert(r.format),v=a.convert(r.type),g=B(r.internalFormat,f,v);j(o,r,p);var w=r.mipmaps;if(r.isDepthTexture)g=6402,h?g=r.type===b?36012:r.type===_?33190:r.type===M?35056:33189:r.type===b&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===E&&6402===g&&r.type!==x&&r.type!==_&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=x,v=a.convert(r.type)),r.format===A&&6402===g&&(g=34041,r.type!==M&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=M,v=a.convert(r.type))),n.texImage2D(3553,0,g,l.width,l.height,0,f,v,null);else if(r.isDataTexture)if(w.length>0&&p){for(var L=0,R=w.length;L<R;L++)s=w[L],n.texImage2D(3553,L,g,s.width,s.height,0,f,v,s.data);r.generateMipmaps=!1,e.__maxMipLevel=w.length-1}else n.texImage2D(3553,0,g,l.width,l.height,0,f,v,l.data),e.__maxMipLevel=0;else if(r.isCompressedTexture){for(var C=0,P=w.length;C<P;C++)s=w[C],r.format!==T&&r.format!==S?null!==f?n.compressedTexImage2D(3553,C,g,s.width,s.height,0,s.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(3553,C,g,s.width,s.height,0,f,v,s.data);e.__maxMipLevel=w.length-1}else if(r.isDataTexture2DArray)n.texImage3D(35866,0,g,l.width,l.height,l.depth,0,f,v,l.data),e.__maxMipLevel=0;else if(r.isDataTexture3D)n.texImage3D(32879,0,g,l.width,l.height,l.depth,0,f,v,l.data),e.__maxMipLevel=0;else if(w.length>0&&p){for(var z=0,G=w.length;z<G;z++)s=w[z],n.texImage2D(3553,z,g,f,v,s);r.generateMipmaps=!1,e.__maxMipLevel=w.length-1}else n.texImage2D(3553,0,g,f,v,l),e.__maxMipLevel=0;O(r,p)&&N(o,r,l.width,l.height),e.__version=r.version,r.onUpdate&&r.onUpdate(r)}function Y(e,i,o,s){var c=a.convert(i.texture.format),l=a.convert(i.texture.type),u=B(i.texture.internalFormat,c,l);n.texImage2D(s,0,u,i.width,i.height,0,c,l,null),t.bindFramebuffer(36160,e),t.framebufferTexture2D(36160,o,s,r.get(i.texture).__webglTexture,0),t.bindFramebuffer(36160,null)}function Z(e,n,r){if(t.bindRenderbuffer(36161,e),n.depthBuffer&&!n.stencilBuffer){var i=33189;if(r){var o=n.depthTexture;o&&o.isDepthTexture&&(o.type===b?i=36012:o.type===_&&(i=33190));var s=Q(n);t.renderbufferStorageMultisample(36161,s,i,n.width,n.height)}else t.renderbufferStorage(36161,i,n.width,n.height);t.framebufferRenderbuffer(36160,36096,36161,e)}else if(n.depthBuffer&&n.stencilBuffer){if(r){var c=Q(n);t.renderbufferStorageMultisample(36161,c,35056,n.width,n.height)}else t.renderbufferStorage(36161,34041,n.width,n.height);t.framebufferRenderbuffer(36160,33306,36161,e)}else{var l=a.convert(n.texture.format),u=a.convert(n.texture.type),h=B(n.texture.internalFormat,l,u);if(r){var d=Q(n);t.renderbufferStorageMultisample(36161,d,h,n.width,n.height)}else t.renderbufferStorage(36161,h,n.width,n.height)}t.bindRenderbuffer(36161,null)}function J(e){var n=r.get(e),i=!0===e.isWebGLCubeRenderTarget;if(e.depthTexture){if(i)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,n){if(n&&n.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,e),!n.depthTexture||!n.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(n.depthTexture).__webglTexture&&n.depthTexture.image.width===n.width&&n.depthTexture.image.height===n.height||(n.depthTexture.image.width=n.width,n.depthTexture.image.height=n.height,n.depthTexture.needsUpdate=!0),H(n.depthTexture,0);var i=r.get(n.depthTexture).__webglTexture;if(n.depthTexture.format===E)t.framebufferTexture2D(36160,36096,3553,i,0);else{if(n.depthTexture.format!==A)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(36160,33306,3553,i,0)}}(n.__webglFramebuffer,e)}else if(i){n.__webglDepthbuffer=[];for(var a=0;a<6;a++)t.bindFramebuffer(36160,n.__webglFramebuffer[a]),n.__webglDepthbuffer[a]=t.createRenderbuffer(),Z(n.__webglDepthbuffer[a],e,!1)}else t.bindFramebuffer(36160,n.__webglFramebuffer),n.__webglDepthbuffer=t.createRenderbuffer(),Z(n.__webglDepthbuffer,e,!1);t.bindFramebuffer(36160,null)}function Q(t){return h&&t.isWebGLMultisampleRenderTarget?Math.min(L,t.samples):0}var K=!1,$=!1;this.allocateTextureUnit=function(){var t=U;return t>=v&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+v),U+=1,t},this.resetTextureUnits=function(){U=0},this.setTexture2D=H,this.setTexture2DArray=function(t,e){var i=r.get(t);t.version>0&&i.__version!==t.version?X(i,t,e):(n.activeTexture(33984+e),n.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function(t,e){var i=r.get(t);t.version>0&&i.__version!==t.version?X(i,t,e):(n.activeTexture(33984+e),n.bindTexture(32879,i.__webglTexture))},this.setTextureCube=k,this.setupRenderTarget=function(e){var i=r.get(e),s=r.get(e.texture);e.addEventListener("dispose",F),s.__webglTexture=t.createTexture(),o.memory.textures++;var c=!0===e.isWebGLCubeRenderTarget,l=!0===e.isWebGLMultisampleRenderTarget,u=D(e)||h;if(!h||e.texture.format!==S||e.texture.type!==b&&e.texture.type!==w||(e.texture.format=T,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),c){i.__webglFramebuffer=[];for(var d=0;d<6;d++)i.__webglFramebuffer[d]=t.createFramebuffer()}else if(i.__webglFramebuffer=t.createFramebuffer(),l)if(h){i.__webglMultisampledFramebuffer=t.createFramebuffer(),i.__webglColorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,i.__webglColorRenderbuffer);var p=a.convert(e.texture.format),f=a.convert(e.texture.type),m=B(e.texture.internalFormat,p,f),v=Q(e);t.renderbufferStorageMultisample(36161,v,m,e.width,e.height),t.bindFramebuffer(36160,i.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064,36161,i.__webglColorRenderbuffer),t.bindRenderbuffer(36161,null),e.depthBuffer&&(i.__webglDepthRenderbuffer=t.createRenderbuffer(),Z(i.__webglDepthRenderbuffer,e,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(c){n.bindTexture(34067,s.__webglTexture),j(34067,e.texture,u);for(var g=0;g<6;g++)Y(i.__webglFramebuffer[g],e,36064,34069+g);O(e.texture,u)&&N(34067,e.texture,e.width,e.height),n.bindTexture(34067,null)}else n.bindTexture(3553,s.__webglTexture),j(3553,e.texture,u),Y(i.__webglFramebuffer,e,36064,3553),O(e.texture,u)&&N(3553,e.texture,e.width,e.height),n.bindTexture(3553,null);e.depthBuffer&&J(e)},this.updateRenderTargetMipmap=function(t){var e=t.texture;if(O(e,D(t)||h)){var i=t.isWebGLCubeRenderTarget?34067:3553,a=r.get(e).__webglTexture;n.bindTexture(i,a),N(i,e,t.width,t.height),n.bindTexture(i,null)}},this.updateMultisampleRenderTarget=function(e){if(e.isWebGLMultisampleRenderTarget)if(h){var n=r.get(e);t.bindFramebuffer(36008,n.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,n.__webglFramebuffer);var i=e.width,a=e.height,o=16384;e.depthBuffer&&(o|=256),e.stencilBuffer&&(o|=1024),t.blitFramebuffer(0,0,i,a,0,0,i,a,o,9728),t.bindFramebuffer(36160,n.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(t,e){t&&t.isWebGLRenderTarget&&(!1===K&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),K=!0),t=t.texture),H(t,e)},this.safeSetTextureCube=function(t,e){t&&t.isWebGLCubeRenderTarget&&(!1===$&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),$=!0),t=t.texture),k(t,e)}}function Qi(t,e,n){var r=n.isWebGL2;return{convert:function(t){var n;if(t===y)return 5121;if(1017===t)return 32819;if(1018===t)return 32820;if(1019===t)return 33635;if(1010===t)return 5120;if(1011===t)return 5122;if(t===x)return 5123;if(1013===t)return 5124;if(t===_)return 5125;if(t===b)return 5126;if(t===w)return r?5131:null!==(n=e.get("OES_texture_half_float"))?n.HALF_FLOAT_OES:null;if(1021===t)return 6406;if(t===S)return 6407;if(t===T)return 6408;if(1024===t)return 6409;if(1025===t)return 6410;if(t===E)return 6402;if(t===A)return 34041;if(1028===t)return 6403;if(1029===t)return 36244;if(1030===t)return 33319;if(1031===t)return 33320;if(1032===t)return 36248;if(1033===t)return 36249;if(t===L||t===R||t===C||t===P){if(null===(n=e.get("WEBGL_compressed_texture_s3tc")))return null;if(t===L)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===R)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===C)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===P)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(t===I||t===D||t===O||t===N){if(null===(n=e.get("WEBGL_compressed_texture_pvrtc")))return null;if(t===I)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===D)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===O)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===N)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===t)return null!==(n=e.get("WEBGL_compressed_texture_etc1"))?n.COMPRESSED_RGB_ETC1_WEBGL:null;if((t===B||t===z)&&null!==(n=e.get("WEBGL_compressed_texture_etc"))){if(t===B)return n.COMPRESSED_RGB8_ETC2;if(t===z)return n.COMPRESSED_RGBA8_ETC2_EAC}return 37808===t||37809===t||37810===t||37811===t||37812===t||37813===t||37814===t||37815===t||37816===t||37817===t||37818===t||37819===t||37820===t||37821===t||37840===t||37841===t||37842===t||37843===t||37844===t||37845===t||37846===t||37847===t||37848===t||37849===t||37850===t||37851===t||37852===t||37853===t?null!==(n=e.get("WEBGL_compressed_texture_astc"))?t:null:36492===t?null!==(n=e.get("EXT_texture_compression_bptc"))?t:null:t===M?r?34042:null!==(n=e.get("WEBGL_depth_texture"))?n.UNSIGNED_INT_24_8_WEBGL:null:void 0}}}function Ki(t){Vn.call(this),this.cameras=t||[]}function $i(){be.call(this),this.type="Group"}function ta(){this._targetRay=null,this._grip=null,this._hand=null}function ea(t,e){var n=this,r=null,i=1,a=null,o="local-floor",s=null,c=[],l=new Map,u=new Vn;u.layers.enable(1),u.viewport=new yt;var h=new Vn;h.layers.enable(2),h.viewport=new yt;var d=[u,h],p=new Ki;p.layers.enable(1),p.layers.enable(2);var f=null,m=null;function v(t){var e=l.get(t.inputSource);e&&e.dispatchEvent({type:t.type,data:t.inputSource})}function g(){l.forEach((function(t,e){t.disconnect(e)})),l.clear(),t.setFramebuffer(null),t.setRenderTarget(t.getRenderTarget()),S.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function y(t){a=t,S.setContext(r),S.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}function x(t){for(var e=r.inputSources,n=0;n<c.length;n++)l.set(e[n],c[n]);for(var i=0;i<t.removed.length;i++){var a=t.removed[i],o=l.get(a);o&&(o.dispatchEvent({type:"disconnected",data:a}),l.delete(a))}for(var s=0;s<t.added.length;s++){var u=t.added[s],h=l.get(u);h&&h.dispatchEvent({type:"connected",data:u})}}this.enabled=!1,this.isPresenting=!1,this.getController=function(t){var e=c[t];return void 0===e&&(e=new ta,c[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){var e=c[t];return void 0===e&&(e=new ta,c[t]=e),e.getGripSpace()},this.getHand=function(t){var e=c[t];return void 0===e&&(e=new ta,c[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){i=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){o=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return a},this.getSession=function(){return r},this.setSession=function(t){if(null!==(r=t)){r.addEventListener("select",v),r.addEventListener("selectstart",v),r.addEventListener("selectend",v),r.addEventListener("squeeze",v),r.addEventListener("squeezestart",v),r.addEventListener("squeezeend",v),r.addEventListener("end",g);var n=e.getContextAttributes();!0!==n.xrCompatible&&e.makeXRCompatible();var a={antialias:n.antialias,alpha:n.alpha,depth:n.depth,stencil:n.stencil,framebufferScaleFactor:i},s=new XRWebGLLayer(r,e,a);r.updateRenderState({baseLayer:s}),r.requestReferenceSpace(o).then(y),r.addEventListener("inputsourceschange",x)}};var _=new wt,b=new wt;function w(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.getInverse(t.matrixWorld)}this.getCamera=function(t){p.near=h.near=u.near=t.near,p.far=h.far=u.far=t.far,f===p.near&&m===p.far||(r.updateRenderState({depthNear:p.near,depthFar:p.far}),f=p.near,m=p.far);var e=t.parent,n=p.cameras;w(p,e);for(var i=0;i<n.length;i++)w(n[i],e);t.matrixWorld.copy(p.matrixWorld);for(var a=t.children,o=0,s=a.length;o<s;o++)a[o].updateMatrixWorld(!0);return 2===n.length?function(t,e,n){_.setFromMatrixPosition(e.matrixWorld),b.setFromMatrixPosition(n.matrixWorld);var r=_.distanceTo(b),i=e.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],h=(a[8]+1)/a[0],d=o*u,p=o*h,f=r/(-u+h),m=f*-u;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(m),t.translateZ(f),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.getInverse(t.matrixWorld);var v=o+f,g=s+f,y=d-m,x=p+(r-m),w=c*s/g*v,M=l*s/g*v;t.projectionMatrix.makePerspective(y,x,w,M,v,g)}(p,u,h):p.projectionMatrix.copy(u.projectionMatrix),p};var M=null;var S=new Kn;S.setAnimationLoop((function(e,n){if(null!==(s=n.getViewerPose(a))){var i=s.views,o=r.renderState.baseLayer;t.setFramebuffer(o.framebuffer);var l=!1;i.length!==p.cameras.length&&(p.cameras.length=0,l=!0);for(var u=0;u<i.length;u++){var h=i[u],f=o.getViewport(h),m=d[u];m.matrix.fromArray(h.transform.matrix),m.projectionMatrix.fromArray(h.projectionMatrix),m.viewport.set(f.x,f.y,f.width,f.height),0===u&&p.matrix.copy(m.matrix),!0===l&&p.cameras.push(m)}}for(var v=r.inputSources,g=0;g<c.length;g++){var y=c[g],x=v[g];y.update(x,n,a)}M&&M(e,n)})),this.setAnimationLoop=function(t){M=t},this.dispose=function(){}}function na(t){function e(e,n){e.opacity.value=n.opacity,n.color&&e.diffuse.value.copy(n.color),n.emissive&&e.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(e.map.value=n.map),n.alphaMap&&(e.alphaMap.value=n.alphaMap),n.specularMap&&(e.specularMap.value=n.specularMap);var r,i,a=t.get(n).envMap;if(a){e.envMap.value=a,e.flipEnvMap.value=a.isCubeTexture&&a._needsFlipEnvMap?-1:1,e.reflectivity.value=n.reflectivity,e.refractionRatio.value=n.refractionRatio;var o=t.get(a).__maxMipLevel;void 0!==o&&(e.maxMipLevel.value=o)}n.lightMap&&(e.lightMap.value=n.lightMap,e.lightMapIntensity.value=n.lightMapIntensity),n.aoMap&&(e.aoMap.value=n.aoMap,e.aoMapIntensity.value=n.aoMapIntensity),n.map?r=n.map:n.specularMap?r=n.specularMap:n.displacementMap?r=n.displacementMap:n.normalMap?r=n.normalMap:n.bumpMap?r=n.bumpMap:n.roughnessMap?r=n.roughnessMap:n.metalnessMap?r=n.metalnessMap:n.alphaMap?r=n.alphaMap:n.emissiveMap?r=n.emissiveMap:n.clearcoatMap?r=n.clearcoatMap:n.clearcoatNormalMap?r=n.clearcoatNormalMap:n.clearcoatRoughnessMap&&(r=n.clearcoatRoughnessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix)),n.aoMap?i=n.aoMap:n.lightMap&&(i=n.lightMap),void 0!==i&&(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uv2Transform.value.copy(i.matrix))}function n(e,n){e.roughness.value=n.roughness,e.metalness.value=n.metalness,n.roughnessMap&&(e.roughnessMap.value=n.roughnessMap),n.metalnessMap&&(e.metalnessMap.value=n.metalnessMap),n.emissiveMap&&(e.emissiveMap.value=n.emissiveMap),n.bumpMap&&(e.bumpMap.value=n.bumpMap,e.bumpScale.value=n.bumpScale,1===n.side&&(e.bumpScale.value*=-1)),n.normalMap&&(e.normalMap.value=n.normalMap,e.normalScale.value.copy(n.normalScale),1===n.side&&e.normalScale.value.negate()),n.displacementMap&&(e.displacementMap.value=n.displacementMap,e.displacementScale.value=n.displacementScale,e.displacementBias.value=n.displacementBias),t.get(n).envMap&&(e.envMapIntensity.value=n.envMapIntensity)}return{refreshFogUniforms:function(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)},refreshMaterialUniforms:function(t,r,i,a){r.isMeshBasicMaterial?e(t,r):r.isMeshLambertMaterial?(e(t,r),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(t,r)):r.isMeshToonMaterial?(e(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap);e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshPhongMaterial?(e(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshStandardMaterial?(e(t,r),r.isMeshPhysicalMaterial?function(t,e){n(t,e),t.reflectivity.value=e.reflectivity,t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.sheen&&t.sheen.value.copy(e.sheen);e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap);e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap);e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,1===e.side&&t.clearcoatNormalScale.value.negate());t.transmission.value=e.transmission,e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap)}(t,r):n(t,r)):r.isMeshMatcapMaterial?(e(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshDepthMaterial?(e(t,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshDistanceMaterial?(e(t,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(t,r)):r.isMeshNormalMaterial?(e(t,r),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,n,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*r,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);var i;e.map?i=e.map:e.alphaMap&&(i=e.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(t,r,i,a):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);var n;e.map?n=e.map:e.alphaMap&&(n=e.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function ra(t){var e=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),n=void 0!==t.context?t.context:null,r=void 0!==t.alpha&&t.alpha,i=void 0===t.depth||t.depth,a=void 0===t.stencil||t.stencil,o=void 0!==t.antialias&&t.antialias,s=void 0===t.premultipliedAlpha||t.premultipliedAlpha,c=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,l=void 0!==t.powerPreference?t.powerPreference:"default",u=void 0!==t.failIfMajorPerformanceCaveat&&t.failIfMajorPerformanceCaveat,h=null,d=null;this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=q,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var p=this,f=!1,m=null,v=0,g=0,x=null,_=null,M=-1,S=null,E=null,A=new yt,L=new yt,R=null,C=e.width,P=e.height,I=1,D=null,O=null,N=new yt(0,0,C,P),B=new yt(0,0,C,P),z=!1,G=new Qn,F=!1,U=!1,H=new Jt,k=new wt,V={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function W(){return null===x?I:1}var j,X,Y,Z,J,Q,K,$,tt,et,nt,rt,it,at,ot,ct,lt,ut,ht,dt,ft,mt=n;function vt(t,n){for(var r=0;r<t.length;r++){var i=t[r],a=e.getContext(i,n);if(null!==a)return a}return null}try{var gt={alpha:r,depth:i,stencil:a,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(e.addEventListener("webglcontextlost",St,!1),e.addEventListener("webglcontextrestored",Tt,!1),null===mt){var xt=["webgl2","webgl","experimental-webgl"];if(!0===p.isWebGL1Renderer&&xt.shift(),null===(mt=vt(xt,gt)))throw vt(xt)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===mt.getShaderPrecisionFormat&&(mt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function _t(){j=new ur(mt),!1===(X=new sr(mt,j,t)).isWebGL2&&(j.get("WEBGL_depth_texture"),j.get("OES_texture_float"),j.get("OES_texture_half_float"),j.get("OES_texture_half_float_linear"),j.get("OES_standard_derivatives"),j.get("OES_element_index_uint"),j.get("OES_vertex_array_object"),j.get("ANGLE_instanced_arrays")),j.get("OES_texture_float_linear"),dt=new Qi(mt,j,X),(Y=new Zi(mt,j,X)).scissor(L.copy(B).multiplyScalar(I).floor()),Y.viewport(A.copy(N).multiplyScalar(I).floor()),Z=new pr(mt),J=new Ni,Q=new Ji(mt,j,Y,J,X,dt,Z),K=new lr(p),$=new $n(mt,X),ft=new ar(mt,j,$,X),tt=new hr(mt,$,Z,ft),et=new gr(mt,tt,$,Z),lt=new vr(mt),ot=new cr(J),nt=new Oi(p,K,j,X,ft,ot),rt=new na(J),it=new Fi(J),at=new ji(j,X),ct=new ir(p,K,Y,et,s),ut=new or(mt,j,Z,X),ht=new dr(mt,j,Z,X),Z.programs=nt.programs,p.capabilities=X,p.extensions=j,p.properties=J,p.renderLists=it,p.state=Y,p.info=Z}_t();var bt=new ea(p,mt);this.xr=bt;var Mt=new Yi(p,et,X.maxTextureSize);function St(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),f=!0}function Tt(){console.log("THREE.WebGLRenderer: Context Restored."),f=!1,_t()}function Et(t){var e=t.target;e.removeEventListener("dispose",Et),function(t){At(t),J.remove(t)}(e)}function At(t){var e=J.get(t).program;void 0!==e&&nt.releaseProgram(e)}this.shadowMap=Mt,this.getContext=function(){return mt},this.getContextAttributes=function(){return mt.getContextAttributes()},this.forceContextLoss=function(){var t=j.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){var t=j.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(t){void 0!==t&&(I=t,this.setSize(C,P,!1))},this.getSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),t=new pt),t.set(C,P)},this.setSize=function(t,n,r){bt.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(C=t,P=n,e.width=Math.floor(t*I),e.height=Math.floor(n*I),!1!==r&&(e.style.width=t+"px",e.style.height=n+"px"),this.setViewport(0,0,t,n))},this.getDrawingBufferSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),t=new pt),t.set(C*I,P*I).floor()},this.setDrawingBufferSize=function(t,n,r){C=t,P=n,I=r,e.width=Math.floor(t*r),e.height=Math.floor(n*r),this.setViewport(0,0,t,n)},this.getCurrentViewport=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),t=new yt),t.copy(A)},this.getViewport=function(t){return t.copy(N)},this.setViewport=function(t,e,n,r){t.isVector4?N.set(t.x,t.y,t.z,t.w):N.set(t,e,n,r),Y.viewport(A.copy(N).multiplyScalar(I).floor())},this.getScissor=function(t){return t.copy(B)},this.setScissor=function(t,e,n,r){t.isVector4?B.set(t.x,t.y,t.z,t.w):B.set(t,e,n,r),Y.scissor(L.copy(B).multiplyScalar(I).floor())},this.getScissorTest=function(){return z},this.setScissorTest=function(t){Y.setScissorTest(z=t)},this.setOpaqueSort=function(t){D=t},this.setTransparentSort=function(t){O=t},this.getClearColor=function(){return ct.getClearColor()},this.setClearColor=function(){ct.setClearColor.apply(ct,arguments)},this.getClearAlpha=function(){return ct.getClearAlpha()},this.setClearAlpha=function(){ct.setClearAlpha.apply(ct,arguments)},this.clear=function(t,e,n){var r=0;(void 0===t||t)&&(r|=16384),(void 0===e||e)&&(r|=256),(void 0===n||n)&&(r|=1024),mt.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",St,!1),e.removeEventListener("webglcontextrestored",Tt,!1),it.dispose(),at.dispose(),J.dispose(),K.dispose(),et.dispose(),ft.dispose(),bt.dispose(),Rt.stop()},this.renderBufferImmediate=function(t,e){ft.initAttributes();var n=J.get(t);t.hasPositions&&!n.position&&(n.position=mt.createBuffer()),t.hasNormals&&!n.normal&&(n.normal=mt.createBuffer()),t.hasUvs&&!n.uv&&(n.uv=mt.createBuffer()),t.hasColors&&!n.color&&(n.color=mt.createBuffer());var r=e.getAttributes();t.hasPositions&&(mt.bindBuffer(34962,n.position),mt.bufferData(34962,t.positionArray,35048),ft.enableAttribute(r.position),mt.vertexAttribPointer(r.position,3,5126,!1,0,0)),t.hasNormals&&(mt.bindBuffer(34962,n.normal),mt.bufferData(34962,t.normalArray,35048),ft.enableAttribute(r.normal),mt.vertexAttribPointer(r.normal,3,5126,!1,0,0)),t.hasUvs&&(mt.bindBuffer(34962,n.uv),mt.bufferData(34962,t.uvArray,35048),ft.enableAttribute(r.uv),mt.vertexAttribPointer(r.uv,2,5126,!1,0,0)),t.hasColors&&(mt.bindBuffer(34962,n.color),mt.bufferData(34962,t.colorArray,35048),ft.enableAttribute(r.color),mt.vertexAttribPointer(r.color,3,5126,!1,0,0)),ft.disableUnusedAttributes(),mt.drawArrays(4,0,t.count),t.count=0},this.renderBufferDirect=function(t,e,n,r,i,a){null===e&&(e=V);var o=i.isMesh&&i.matrixWorld.determinant()<0,s=Ot(t,e,r,i);Y.setMaterial(r,o);var c=n.index,l=n.attributes.position;if(null===c){if(void 0===l||0===l.count)return}else if(0===c.count)return;var u,h=1;!0===r.wireframe&&(c=tt.getWireframeAttribute(n),h=2),(r.morphTargets||r.morphNormals)&<.update(i,n,r,s),ft.setup(i,r,s,n,c);var d=ut;null!==c&&(u=$.get(c),(d=ht).setIndex(u));var p=null!==c?c.count:l.count,f=n.drawRange.start*h,m=n.drawRange.count*h,v=null!==a?a.start*h:0,g=null!==a?a.count*h:1/0,y=Math.max(f,v),x=Math.min(p,f+m,v+g)-1,_=Math.max(0,x-y+1);if(0!==_){if(i.isMesh)!0===r.wireframe?(Y.setLineWidth(r.wireframeLinewidth*W()),d.setMode(1)):d.setMode(4);else if(i.isLine){var b=r.linewidth;void 0===b&&(b=1),Y.setLineWidth(b*W()),i.isLineSegments?d.setMode(1):i.isLineLoop?d.setMode(2):d.setMode(3)}else i.isPoints?d.setMode(0):i.isSprite&&d.setMode(4);if(i.isInstancedMesh)d.renderInstances(y,_,i.count);else if(n.isInstancedBufferGeometry){var w=Math.min(n.instanceCount,n._maxInstanceCount);d.renderInstances(y,_,w)}else d.render(y,_)}},this.compile=function(t,e){(d=at.get(t,e)).init(),t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(d.pushLight(t),t.castShadow&&d.pushShadow(t))})),d.setupLights(e);var n=new WeakMap;t.traverse((function(e){var r=e.material;if(r)if(Array.isArray(r))for(var i=0;i<r.length;i++){var a=r[i];!1===n.has(a)&&(Dt(a,t,e),n.set(a))}else!1===n.has(r)&&(Dt(r,t,e),n.set(r))}))};var Lt=null;var Rt=new Kn;function Ct(t,e,n,r){if(!1!==t.visible){if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)d.pushLight(t),t.castShadow&&d.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||G.intersectsSprite(t)){r&&k.setFromMatrixPosition(t.matrixWorld).applyMatrix4(H);var i=et.update(t),a=t.material;a.visible&&h.push(t,i,a,n,k.z,null)}}else if(t.isImmediateRenderObject)r&&k.setFromMatrixPosition(t.matrixWorld).applyMatrix4(H),h.push(t,null,t.material,n,k.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.frame!==Z.render.frame&&(t.skeleton.update(),t.skeleton.frame=Z.render.frame),!t.frustumCulled||G.intersectsObject(t))){r&&k.setFromMatrixPosition(t.matrixWorld).applyMatrix4(H);var o=et.update(t),s=t.material;if(Array.isArray(s))for(var c=o.groups,l=0,u=c.length;l<u;l++){var p=c[l],f=s[p.materialIndex];f&&f.visible&&h.push(t,o,f,n,k.z,p)}else s.visible&&h.push(t,o,s,n,k.z,null)}for(var m=t.children,v=0,g=m.length;v<g;v++)Ct(m[v],e,n,r)}}function Pt(t,e,n){for(var r=!0===e.isScene?e.overrideMaterial:null,i=0,a=t.length;i<a;i++){var o=t[i],s=o.object,c=o.geometry,l=null===r?o.material:r,u=o.group;if(n.isArrayCamera){E=n;for(var h=n.cameras,p=0,f=h.length;p<f;p++){var m=h[p];s.layers.test(m.layers)&&(Y.viewport(A.copy(m.viewport)),d.setupLights(m),It(s,e,m,c,l,u))}}else E=null,It(s,e,n,c,l,u)}}function It(t,e,n,r,i,a){if(t.onBeforeRender(p,e,n,r,i,a),d=at.get(e,E||n),t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),t.isImmediateRenderObject){var o=Ot(n,e,i,t);Y.setMaterial(i),ft.reset(),function(t,e){t.render((function(t){p.renderBufferImmediate(t,e)}))}(t,o)}else p.renderBufferDirect(n,e,r,i,t,a);t.onAfterRender(p,e,n,r,i,a),d=at.get(e,E||n)}function Dt(t,e,n){!0!==e.isScene&&(e=V);var r=J.get(t),i=d.state.lights,a=d.state.shadowsArray,o=i.state.version,s=nt.getParameters(t,i.state,a,e,n),c=nt.getProgramCacheKey(s),l=r.program,u=!0;if(void 0===l)t.addEventListener("dispose",Et);else if(l.cacheKey!==c)At(t);else if(r.lightsStateVersion!==o)u=!1;else{if(void 0!==s.shaderID){var h=t.isMeshStandardMaterial?e.environment:null;return void(r.envMap=K.get(t.envMap||h))}u=!1}u&&(s.uniforms=nt.getUniforms(t),t.onBeforeCompile(s,p),l=nt.acquireProgram(s,c),r.program=l,r.uniforms=s.uniforms,r.outputEncoding=s.outputEncoding);var f=r.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(r.numClippingPlanes=ot.numPlanes,r.numIntersection=ot.numIntersection,f.clippingPlanes=ot.uniform),r.environment=t.isMeshStandardMaterial?e.environment:null,r.fog=e.fog,r.envMap=K.get(t.envMap||r.environment),r.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),r.lightsStateVersion=o,r.needsLights&&(f.ambientLightColor.value=i.state.ambient,f.lightProbe.value=i.state.probe,f.directionalLights.value=i.state.directional,f.directionalLightShadows.value=i.state.directionalShadow,f.spotLights.value=i.state.spot,f.spotLightShadows.value=i.state.spotShadow,f.rectAreaLights.value=i.state.rectArea,f.ltc_1.value=i.state.rectAreaLTC1,f.ltc_2.value=i.state.rectAreaLTC2,f.pointLights.value=i.state.point,f.pointLightShadows.value=i.state.pointShadow,f.hemisphereLights.value=i.state.hemi,f.directionalShadowMap.value=i.state.directionalShadowMap,f.directionalShadowMatrix.value=i.state.directionalShadowMatrix,f.spotShadowMap.value=i.state.spotShadowMap,f.spotShadowMatrix.value=i.state.spotShadowMatrix,f.pointShadowMap.value=i.state.pointShadowMap,f.pointShadowMatrix.value=i.state.pointShadowMatrix);var m=r.program.getUniforms(),v=fi.seqWithValue(m.seq,f);r.uniformsList=v}function Ot(t,e,n,r){!0!==e.isScene&&(e=V),Q.resetTextureUnits();var i=e.fog,a=n.isMeshStandardMaterial?e.environment:null,o=null===x?p.outputEncoding:x.texture.encoding,s=K.get(n.envMap||a),c=J.get(n),l=d.state.lights;if(!0===F&&(!0===U||t!==S)){var u=t===S&&n.id===M;ot.setState(n,t,u)}n.version===c.__version?n.fog&&c.fog!==i||c.environment!==a||c.needsLights&&c.lightsStateVersion!==l.state.version?Dt(n,e,r):void 0===c.numClippingPlanes||c.numClippingPlanes===ot.numPlanes&&c.numIntersection===ot.numIntersection?(c.outputEncoding!==o||c.envMap!==s)&&Dt(n,e,r):Dt(n,e,r):(Dt(n,e,r),c.__version=n.version);var h,f,m=!1,v=!1,g=!1,y=c.program,_=y.getUniforms(),w=c.uniforms;if(Y.useProgram(y.program)&&(m=!0,v=!0,g=!0),n.id!==M&&(M=n.id,v=!0),m||S!==t){if(_.setValue(mt,"projectionMatrix",t.projectionMatrix),X.logarithmicDepthBuffer&&_.setValue(mt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),S!==t&&(S=t,v=!0,g=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshStandardMaterial||n.envMap){var E=_.map.cameraPosition;void 0!==E&&E.setValue(mt,k.setFromMatrixPosition(t.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&_.setValue(mt,"isOrthographic",!0===t.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.isShadowMaterial||n.skinning)&&_.setValue(mt,"viewMatrix",t.matrixWorldInverse)}if(n.skinning){_.setOptional(mt,r,"bindMatrix"),_.setOptional(mt,r,"bindMatrixInverse");var A=r.skeleton;if(A){var L=A.bones;if(X.floatVertexTextures){if(void 0===A.boneTexture){var R=Math.sqrt(4*L.length);R=st.ceilPowerOfTwo(R),R=Math.max(R,4);var C=new Float32Array(R*R*4);C.set(A.boneMatrices);var D=new Yn(C,R,R,T,b);A.boneMatrices=C,A.boneTexture=D,A.boneTextureSize=R}_.setValue(mt,"boneTexture",A.boneTexture,Q),_.setValue(mt,"boneTextureSize",A.boneTextureSize)}else _.setOptional(mt,A,"boneMatrices")}}return(v||c.receiveShadow!==r.receiveShadow)&&(c.receiveShadow=r.receiveShadow,_.setValue(mt,"receiveShadow",r.receiveShadow)),v&&(_.setValue(mt,"toneMappingExposure",p.toneMappingExposure),c.needsLights&&(f=g,(h=w).ambientLightColor.needsUpdate=f,h.lightProbe.needsUpdate=f,h.directionalLights.needsUpdate=f,h.directionalLightShadows.needsUpdate=f,h.pointLights.needsUpdate=f,h.pointLightShadows.needsUpdate=f,h.spotLights.needsUpdate=f,h.spotLightShadows.needsUpdate=f,h.rectAreaLights.needsUpdate=f,h.hemisphereLights.needsUpdate=f),i&&n.fog&&rt.refreshFogUniforms(w,i),rt.refreshMaterialUniforms(w,n,I,P),fi.upload(mt,c.uniformsList,w,Q)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(fi.upload(mt,c.uniformsList,w,Q),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&_.setValue(mt,"center",r.center),_.setValue(mt,"modelViewMatrix",r.modelViewMatrix),_.setValue(mt,"normalMatrix",r.normalMatrix),_.setValue(mt,"modelMatrix",r.matrixWorld),y}Rt.setAnimationLoop((function(t){bt.isPresenting||Lt&&Lt(t)})),"undefined"!=typeof window&&Rt.setContext(window),this.setAnimationLoop=function(t){Lt=t,bt.setAnimationLoop(t),null===t?Rt.stop():Rt.start()},this.render=function(t,e){var n,r;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),n=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),r=arguments[3]),void 0===e||!0===e.isCamera){if(!0!==f){ft.resetDefaultState(),M=-1,S=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),!0===bt.enabled&&!0===bt.isPresenting&&(e=bt.getCamera(e)),!0===t.isScene&&t.onBeforeRender(p,t,e,n||x),(d=at.get(t,e)).init(),H.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),G.setFromProjectionMatrix(H),U=this.localClippingEnabled,F=ot.init(this.clippingPlanes,U,e),(h=it.get(t,e)).init(),Ct(t,e,0,p.sortObjects),h.finish(),!0===p.sortObjects&&h.sort(D,O),!0===F&&ot.beginShadows();var i=d.state.shadowsArray;Mt.render(i,t,e),d.setupLights(e),!0===F&&ot.endShadows(),!0===this.info.autoReset&&this.info.reset(),void 0!==n&&this.setRenderTarget(n),ct.render(h,t,e,r);var a=h.opaque,o=h.transparent;a.length>0&&Pt(a,t,e),o.length>0&&Pt(o,t,e),!0===t.isScene&&t.onAfterRender(p,t,e),null!==x&&(Q.updateRenderTargetMipmap(x),Q.updateMultisampleRenderTarget(x)),Y.buffers.depth.setTest(!0),Y.buffers.depth.setMask(!0),Y.buffers.color.setMask(!0),Y.setPolygonOffset(!1),h=null,d=null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.setFramebuffer=function(t){m!==t&&null===x&&mt.bindFramebuffer(36160,t),m=t},this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return g},this.getRenderList=function(){return h},this.setRenderList=function(t){h=t},this.getRenderState=function(){return d},this.setRenderState=function(t){d=t},this.getRenderTarget=function(){return x},this.setRenderTarget=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=0),x=t,v=e,g=n,t&&void 0===J.get(t).__webglFramebuffer&&Q.setupRenderTarget(t);var r=m,i=!1;if(t){var a=J.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=a[e],i=!0):r=t.isWebGLMultisampleRenderTarget?J.get(t).__webglMultisampledFramebuffer:a,A.copy(t.viewport),L.copy(t.scissor),R=t.scissorTest}else A.copy(N).multiplyScalar(I).floor(),L.copy(B).multiplyScalar(I).floor(),R=z;if(_!==r&&(mt.bindFramebuffer(36160,r),_=r),Y.viewport(A),Y.scissor(L),Y.setScissorTest(R),i){var o=J.get(t.texture);mt.framebufferTexture2D(36160,36064,34069+e,o.__webglTexture,n)}},this.readRenderTargetPixels=function(t,e,n,r,i,a,o){if(t&&t.isWebGLRenderTarget){var s=J.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==o&&(s=s[o]),s){var c=!1;s!==_&&(mt.bindFramebuffer(36160,s),c=!0);try{var l=t.texture,u=l.format,h=l.type;if(u!==T&&dt.convert(u)!==mt.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(h===y||dt.convert(h)===mt.getParameter(35738)||h===b&&(X.isWebGL2||j.get("OES_texture_float")||j.get("WEBGL_color_buffer_float"))||h===w&&(X.isWebGL2?j.get("EXT_color_buffer_float"):j.get("EXT_color_buffer_half_float"))))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===mt.checkFramebufferStatus(36160)?e>=0&&e<=t.width-r&&n>=0&&n<=t.height-i&&mt.readPixels(e,n,r,i,dt.convert(u),dt.convert(h),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{c&&mt.bindFramebuffer(36160,_)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(t,e,n){void 0===n&&(n=0);var r=Math.pow(2,-n),i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=dt.convert(e.format);Q.setTexture2D(e,0),mt.copyTexImage2D(3553,n,o,t.x,t.y,i,a,0),Y.unbindTexture()},this.copyTextureToTexture=function(t,e,n,r){void 0===r&&(r=0);var i=e.image.width,a=e.image.height,o=dt.convert(n.format),s=dt.convert(n.type);Q.setTexture2D(n,0),mt.pixelStorei(37440,n.flipY),mt.pixelStorei(37441,n.premultiplyAlpha),mt.pixelStorei(3317,n.unpackAlignment),e.isDataTexture?mt.texSubImage2D(3553,r,t.x,t.y,i,a,o,s,e.image.data):e.isCompressedTexture?mt.compressedTexSubImage2D(3553,r,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,o,e.mipmaps[0].data):mt.texSubImage2D(3553,r,t.x,t.y,o,s,e.image),0===r&&n.generateMipmaps&&mt.generateMipmap(3553),Y.unbindTexture()},this.initTexture=function(t){Q.setTexture2D(t,0),Y.unbindTexture()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function ia(t){ra.call(this,t)}Ki.prototype=Object.assign(Object.create(Vn.prototype),{constructor:Ki,isArrayCamera:!0}),$i.prototype=Object.assign(Object.create(be.prototype),{constructor:$i,isGroup:!0}),Object.assign(ta.prototype,{constructor:ta,getHandSpace:function(){if(null===this._hand&&(this._hand=new $i,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints=[],this._hand.inputState={pinching:!1},window.XRHand))for(var t=0;t<=window.XRHand.LITTLE_PHALANX_TIP;t++){var e=new $i;e.matrixAutoUpdate=!1,e.visible=!1,this._hand.joints.push(e),this._hand.add(e)}return this._hand},getTargetRaySpace:function(){return null===this._targetRay&&(this._targetRay=new $i,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return null===this._grip&&(this._grip=new $i,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this},disconnect:function(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this},update:function(t,e,n){var r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(t)if(c&&t.hand){a=!0;for(var l=0;l<=window.XRHand.LITTLE_PHALANX_TIP;l++)if(t.hand[l]){var u=e.getJointPose(t.hand[l],n),h=c.joints[l];null!==u&&(h.matrix.fromArray(u.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.jointRadius=u.radius),h.visible=null!==u;var d=c.joints[window.XRHand.INDEX_PHALANX_TIP],p=c.joints[window.XRHand.THUMB_PHALANX_TIP],f=d.position.distanceTo(p.position);c.inputState.pinching&&f>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&f<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}}else null!==o&&null!==(r=e.getPose(t.targetRaySpace,n))&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale)),null!==s&&t.gripSpace&&null!==(i=e.getPose(t.gripSpace,n))&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale));return null!==o&&(o.visible=null!==r),null!==s&&(s.visible=null!==i),null!==c&&(c.visible=null!==a),this}}),Object.assign(ea.prototype,rt.prototype),ia.prototype=Object.assign(Object.create(ra.prototype),{constructor:ia,isWebGL1Renderer:!0});var aa=function(){function t(t,e){Object.defineProperty(this,"isFogExp2",{value:!0}),this.name="",this.color=new Ve(t),this.density=void 0!==e?e:25e-5}var e=t.prototype;return e.clone=function(){return new t(this.color,this.density)},e.toJSON=function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}},t}(),oa=function(){function t(t,e,n){Object.defineProperty(this,"isFog",{value:!0}),this.name="",this.color=new Ve(t),this.near=void 0!==e?e:1,this.far=void 0!==n?n:1e3}var e=t.prototype;return e.clone=function(){return new t(this.color,this.near,this.far)},e.toJSON=function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}},t}(),sa=function(t){function e(){var e;return e=t.call(this)||this,Object.defineProperty(ht(e),"isScene",{value:!0}),e.type="Scene",e.background=null,e.environment=null,e.fog=null,e.overrideMaterial=null,e.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:ht(e)})),e}ut(e,t);var n=e.prototype;return n.copy=function(e,n){return t.prototype.copy.call(this,e,n),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this},n.toJSON=function(e){var n=t.prototype.toJSON.call(this,e);return null!==this.background&&(n.object.background=this.background.toJSON(e)),null!==this.environment&&(n.object.environment=this.environment.toJSON(e)),null!==this.fog&&(n.object.fog=this.fog.toJSON()),n},e}(be);function ca(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=tt,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=st.generateUUID()}Object.defineProperty(ca.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(ca.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.stride,n*=e.stride;for(var r=0,i=this.stride;r<i;r++)this.array[t+r]=e.array[n+r];return this},set:function(t,e){return void 0===e&&(e=0),this.array.set(t,e),this},clone:function(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=st.generateUUID()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);var e=new ca(new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),this.stride);return e.setUsage(this.usage),e},onUpload:function(t){return this.onUploadCallback=t,this},toJSON:function(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=st.generateUUID()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}});var la,ua=new wt;function ha(t,e,n,r){this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=!0===r}function da(t){qe.call(this),this.type="SpriteMaterial",this.color=new Ve(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}Object.defineProperties(ha.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}},needsUpdate:{set:function(t){this.data.needsUpdate=t}}}),Object.assign(ha.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(t){for(var e=0,n=this.data.count;e<n;e++)ua.x=this.getX(e),ua.y=this.getY(e),ua.z=this.getZ(e),ua.applyMatrix4(t),this.setXYZ(e,ua.x,ua.y,ua.z);return this},setX:function(t,e){return this.data.array[t*this.data.stride+this.offset]=e,this},setY:function(t,e){return this.data.array[t*this.data.stride+this.offset+1]=e,this},setZ:function(t,e){return this.data.array[t*this.data.stride+this.offset+2]=e,this},setW:function(t,e){return this.data.array[t*this.data.stride+this.offset+3]=e,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,e,n){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this},setXYZ:function(t,e,n,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this},setXYZW:function(t,e,n,r,i){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this.data.array[t+3]=i,this},clone:function(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");for(var e=[],n=0;n<this.count;n++)for(var r=n*this.data.stride+this.offset,i=0;i<this.itemSize;i++)e.push(this.data.array[r+i]);return new Je(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new ha(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)},toJSON:function(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");for(var e=[],n=0;n<this.count;n++)for(var r=n*this.data.stride+this.offset,i=0;i<this.itemSize;i++)e.push(this.data.array[r+i]);return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}),da.prototype=Object.create(qe.prototype),da.prototype.constructor=da,da.prototype.isSpriteMaterial=!0,da.prototype.copy=function(t){return qe.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this};var pa=new wt,fa=new wt,ma=new wt,va=new pt,ga=new pt,ya=new Jt,xa=new wt,_a=new wt,ba=new wt,wa=new pt,Ma=new pt,Sa=new pt;function Ta(t){if(be.call(this),this.type="Sprite",void 0===la){la=new vn;var e=new ca(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);la.setIndex([0,1,2,0,2,3]),la.setAttribute("position",new ha(e,3,0,!1)),la.setAttribute("uv",new ha(e,2,3,!1))}this.geometry=la,this.material=void 0!==t?t:new da,this.center=new pt(.5,.5)}function Ea(t,e,n,r,i,a){va.subVectors(t,n).addScalar(.5).multiply(r),void 0!==i?(ga.x=a*va.x-i*va.y,ga.y=i*va.x+a*va.y):ga.copy(va),t.copy(e),t.x+=ga.x,t.y+=ga.y,t.applyMatrix4(ya)}Ta.prototype=Object.assign(Object.create(be.prototype),{constructor:Ta,isSprite:!0,raycast:function(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),fa.setFromMatrixScale(this.matrixWorld),ya.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),ma.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&fa.multiplyScalar(-ma.z);var n,r,i=this.material.rotation;0!==i&&(r=Math.cos(i),n=Math.sin(i));var a=this.center;Ea(xa.set(-.5,-.5,0),ma,a,fa,n,r),Ea(_a.set(.5,-.5,0),ma,a,fa,n,r),Ea(ba.set(.5,.5,0),ma,a,fa,n,r),wa.set(0,0),Ma.set(1,0),Sa.set(1,1);var o=t.ray.intersectTriangle(xa,_a,ba,!1,pa);if(null!==o||(Ea(_a.set(-.5,.5,0),ma,a,fa,n,r),Ma.set(0,1),null!==(o=t.ray.intersectTriangle(xa,ba,_a,!1,pa)))){var s=t.ray.origin.distanceTo(pa);s<t.near||s>t.far||e.push({distance:s,point:pa.clone(),uv:Be.getUV(pa,xa,_a,ba,wa,Ma,Sa,new pt),face:null,object:this})}},copy:function(t){return be.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}});var Aa,La,Ra,Ca,Pa,Ia=new wt,Da=new wt;function Oa(){be.call(this),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function Na(t,e){t&&t.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),On.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Jt,this.bindMatrixInverse=new Jt}Oa.prototype=Object.assign(Object.create(be.prototype),{constructor:Oa,isLOD:!0,copy:function(t){be.prototype.copy.call(this,t,!1);for(var e=t.levels,n=0,r=e.length;n<r;n++){var i=e[n];this.addLevel(i.object.clone(),i.distance)}return this.autoUpdate=t.autoUpdate,this},addLevel:function(t,e){void 0===e&&(e=0),e=Math.abs(e);var n,r=this.levels;for(n=0;n<r.length&&!(e<r[n].distance);n++);return r.splice(n,0,{distance:e,object:t}),this.add(t),this},getCurrentLevel:function(){return this._currentLevel},getObjectForDistance:function(t){var e=this.levels;if(e.length>0){var n,r;for(n=1,r=e.length;n<r&&!(t<e[n].distance);n++);return e[n-1].object}return null},raycast:function(t,e){if(this.levels.length>0){Ia.setFromMatrixPosition(this.matrixWorld);var n=t.ray.origin.distanceTo(Ia);this.getObjectForDistance(n).raycast(t,e)}},update:function(t){var e=this.levels;if(e.length>1){Ia.setFromMatrixPosition(t.matrixWorld),Da.setFromMatrixPosition(this.matrixWorld);var n,r,i=Ia.distanceTo(Da)/t.zoom;for(e[0].object.visible=!0,n=1,r=e.length;n<r&&i>=e[n].distance;n++)e[n-1].object.visible=!1,e[n].object.visible=!0;for(this._currentLevel=n-1;n<r;n++)e[n].object.visible=!1}},toJSON:function(t){var e=be.prototype.toJSON.call(this,t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];for(var n=this.levels,r=0,i=n.length;r<i;r++){var a=n[r];e.object.levels.push({object:a.object.uuid,distance:a.distance})}return e}}),Na.prototype=Object.assign(Object.create(On.prototype),{constructor:Na,isSkinnedMesh:!0,copy:function(t){return On.prototype.copy.call(this,t),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,this},bind:function(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.getInverse(e)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){for(var t=new yt,e=this.geometry.attributes.skinWeight,n=0,r=e.count;n<r;n++){t.x=e.getX(n),t.y=e.getY(n),t.z=e.getZ(n),t.w=e.getW(n);var i=1/t.manhattanLength();i!==1/0?t.multiplyScalar(i):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}},updateMatrixWorld:function(t){On.prototype.updateMatrixWorld.call(this,t),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},boneTransform:(Aa=new wt,La=new yt,Ra=new yt,Ca=new wt,Pa=new Jt,function(t,e){var n=this.skeleton,r=this.geometry;La.fromBufferAttribute(r.attributes.skinIndex,t),Ra.fromBufferAttribute(r.attributes.skinWeight,t),Aa.fromBufferAttribute(r.attributes.position,t).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(var i=0;i<4;i++){var a=Ra.getComponent(i);if(0!==a){var o=La.getComponent(i);Pa.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),e.addScaledVector(Ca.copy(Aa).applyMatrix4(Pa),a)}}return e.applyMatrix4(this.bindMatrixInverse)})});var Ba=new Jt,za=new Jt;function Ga(t,e){if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),this.frame=-1,void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new Jt)}}function Fa(){be.call(this),this.type="Bone"}Object.assign(Ga.prototype,{calculateInverses:function(){this.boneInverses=[];for(var t=0,e=this.bones.length;t<e;t++){var n=new Jt;this.bones[t]&&n.getInverse(this.bones[t].matrixWorld),this.boneInverses.push(n)}},pose:function(){for(var t=0,e=this.bones.length;t<e;t++){var n=this.bones[t];n&&n.matrixWorld.getInverse(this.boneInverses[t])}for(var r=0,i=this.bones.length;r<i;r++){var a=this.bones[r];a&&(a.parent&&a.parent.isBone?(a.matrix.getInverse(a.parent.matrixWorld),a.matrix.multiply(a.matrixWorld)):a.matrix.copy(a.matrixWorld),a.matrix.decompose(a.position,a.quaternion,a.scale))}},update:function(){for(var t=this.bones,e=this.boneInverses,n=this.boneMatrices,r=this.boneTexture,i=0,a=t.length;i<a;i++){var o=t[i]?t[i].matrixWorld:za;Ba.multiplyMatrices(o,e[i]),Ba.toArray(n,16*i)}void 0!==r&&(r.needsUpdate=!0)},clone:function(){return new Ga(this.bones,this.boneInverses)},getBoneByName:function(t){for(var e=0,n=this.bones.length;e<n;e++){var r=this.bones[e];if(r.name===t)return r}},dispose:function(){this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=void 0)}}),Fa.prototype=Object.assign(Object.create(be.prototype),{constructor:Fa,isBone:!0});var Ua=new Jt,Ha=new Jt,ka=[],Va=new On;function Wa(t,e,n){On.call(this,t,e),this.instanceMatrix=new Je(new Float32Array(16*n),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1}function ja(t){qe.call(this),this.type="LineBasicMaterial",this.color=new Ve(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,this.setValues(t)}Wa.prototype=Object.assign(Object.create(On.prototype),{constructor:Wa,isInstancedMesh:!0,copy:function(t){return On.prototype.copy.call(this,t),this.instanceMatrix.copy(t.instanceMatrix),this.count=t.count,this},setColorAt:function(t,e){null===this.instanceColor&&(this.instanceColor=new Je(new Float32Array(3*this.count),3)),e.toArray(this.instanceColor.array,3*t)},getMatrixAt:function(t,e){e.fromArray(this.instanceMatrix.array,16*t)},raycast:function(t,e){var n=this.matrixWorld,r=this.count;if(Va.geometry=this.geometry,Va.material=this.material,void 0!==Va.material)for(var i=0;i<r;i++){this.getMatrixAt(i,Ua),Ha.multiplyMatrices(n,Ua),Va.matrixWorld=Ha,Va.raycast(t,ka);for(var a=0,o=ka.length;a<o;a++){var s=ka[a];s.instanceId=i,s.object=this,e.push(s)}ka.length=0}},setMatrixAt:function(t,e){e.toArray(this.instanceMatrix.array,16*t)},updateMorphTargets:function(){}}),ja.prototype=Object.create(qe.prototype),ja.prototype.constructor=ja,ja.prototype.isLineBasicMaterial=!0,ja.prototype.copy=function(t){return qe.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.morphTargets=t.morphTargets,this};var qa=new wt,Xa=new wt,Ya=new Jt,Za=new Zt,Ja=new Ht;function Qa(t,e,n){1===n&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead."),be.call(this),this.type="Line",this.geometry=void 0!==t?t:new vn,this.material=void 0!==e?e:new ja,this.updateMorphTargets()}Qa.prototype=Object.assign(Object.create(be.prototype),{constructor:Qa,isLine:!0,copy:function(t){return be.prototype.copy.call(this,t),this.material=t.material,this.geometry=t.geometry,this},computeLineDistances:function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var e=t.attributes.position,n=[0],r=1,i=e.count;r<i;r++)qa.fromBufferAttribute(e,r-1),Xa.fromBufferAttribute(e,r),n[r]=n[r-1],n[r]+=qa.distanceTo(Xa);t.setAttribute("lineDistance",new an(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(t.isGeometry){var a=t.vertices,o=t.lineDistances;o[0]=0;for(var s=1,c=a.length;s<c;s++)o[s]=o[s-1],o[s]+=a[s-1].distanceTo(a[s])}return this},raycast:function(t,e){var n=this.geometry,r=this.matrixWorld,i=t.params.Line.threshold;if(null===n.boundingSphere&&n.computeBoundingSphere(),Ja.copy(n.boundingSphere),Ja.applyMatrix4(r),Ja.radius+=i,!1!==t.ray.intersectsSphere(Ja)){Ya.getInverse(r),Za.copy(t.ray).applyMatrix4(Ya);var a=i/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,s=new wt,c=new wt,l=new wt,u=new wt,h=this.isLineSegments?2:1;if(n.isBufferGeometry){var d=n.index,p=n.attributes.position;if(null!==d)for(var f=d.array,m=0,v=f.length-1;m<v;m+=h){var g=f[m],y=f[m+1];if(s.fromBufferAttribute(p,g),c.fromBufferAttribute(p,y),!(Za.distanceSqToSegment(s,c,u,l)>o)){u.applyMatrix4(this.matrixWorld);var x=t.ray.origin.distanceTo(u);x<t.near||x>t.far||e.push({distance:x,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}else for(var _=0,b=p.count-1;_<b;_+=h){if(s.fromBufferAttribute(p,_),c.fromBufferAttribute(p,_+1),!(Za.distanceSqToSegment(s,c,u,l)>o)){u.applyMatrix4(this.matrixWorld);var w=t.ray.origin.distanceTo(u);w<t.near||w>t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:_,face:null,faceIndex:null,object:this})}}}else if(n.isGeometry)for(var M=n.vertices,S=M.length,T=0;T<S-1;T+=h){if(!(Za.distanceSqToSegment(M[T],M[T+1],u,l)>o)){u.applyMatrix4(this.matrixWorld);var E=t.ray.origin.distanceTo(u);E<t.near||E>t.far||e.push({distance:E,point:l.clone().applyMatrix4(this.matrixWorld),index:T,face:null,faceIndex:null,object:this})}}}},updateMorphTargets:function(){var t=this.geometry;if(t.isBufferGeometry){var e=t.morphAttributes,n=Object.keys(e);if(n.length>0){var r=e[n[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var i=0,a=r.length;i<a;i++){var o=r[i].name||String(i);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=i}}}}else{var s=t.morphTargets;void 0!==s&&s.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});var Ka=new wt,$a=new wt;function to(t,e){Qa.call(this,t,e),this.type="LineSegments"}function eo(t,e){Qa.call(this,t,e),this.type="LineLoop"}function no(t){qe.call(this),this.type="PointsMaterial",this.color=new Ve(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(t)}to.prototype=Object.assign(Object.create(Qa.prototype),{constructor:to,isLineSegments:!0,computeLineDistances:function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var e=t.attributes.position,n=[],r=0,i=e.count;r<i;r+=2)Ka.fromBufferAttribute(e,r),$a.fromBufferAttribute(e,r+1),n[r]=0===r?0:n[r-1],n[r+1]=n[r]+Ka.distanceTo($a);t.setAttribute("lineDistance",new an(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(t.isGeometry)for(var a=t.vertices,o=t.lineDistances,s=0,c=a.length;s<c;s+=2)Ka.copy(a[s]),$a.copy(a[s+1]),o[s]=0===s?0:o[s-1],o[s+1]=o[s]+Ka.distanceTo($a);return this}}),eo.prototype=Object.assign(Object.create(Qa.prototype),{constructor:eo,isLineLoop:!0}),no.prototype=Object.create(qe.prototype),no.prototype.constructor=no,no.prototype.isPointsMaterial=!0,no.prototype.copy=function(t){return qe.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.morphTargets=t.morphTargets,this};var ro=new Jt,io=new Zt,ao=new Ht,oo=new wt;function so(t,e){be.call(this),this.type="Points",this.geometry=void 0!==t?t:new vn,this.material=void 0!==e?e:new no,this.updateMorphTargets()}function co(t,e,n,r,i,a,o){var s=io.distanceSqToPoint(t);if(s<n){var c=new wt;io.closestPointToPoint(t,c),c.applyMatrix4(r);var l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;a.push({distance:l,distanceToRay:Math.sqrt(s),point:c,index:e,face:null,object:o})}}function lo(t,e,n,r,i,a,o,s,c){gt.call(this,t,e,n,r,i,a,o,s,c),this.format=void 0!==o?o:S,this.minFilter=void 0!==a?a:m,this.magFilter=void 0!==i?i:m,this.generateMipmaps=!1;var l=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){l.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}function uo(t,e,n,r,i,a,o,s,c,l,u,h){gt.call(this,null,a,o,s,c,l,r,i,u,h),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function ho(t,e,n,r,i,a,o,s,c){gt.call(this,t,e,n,r,i,a,o,s,c),this.needsUpdate=!0}function po(t,e,n,r,i,a,o,s,c,l){if((l=void 0!==l?l:E)!==E&&l!==A)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&l===E&&(n=x),void 0===n&&l===A&&(n=M),gt.call(this,null,r,i,a,o,s,l,n,c),this.image={width:t,height:e},this.magFilter=void 0!==o?o:d,this.minFilter=void 0!==s?s:d,this.flipY=!1,this.generateMipmaps=!1}so.prototype=Object.assign(Object.create(be.prototype),{constructor:so,isPoints:!0,copy:function(t){return be.prototype.copy.call(this,t),this.material=t.material,this.geometry=t.geometry,this},raycast:function(t,e){var n=this.geometry,r=this.matrixWorld,i=t.params.Points.threshold;if(null===n.boundingSphere&&n.computeBoundingSphere(),ao.copy(n.boundingSphere),ao.applyMatrix4(r),ao.radius+=i,!1!==t.ray.intersectsSphere(ao)){ro.getInverse(r),io.copy(t.ray).applyMatrix4(ro);var a=i/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a;if(n.isBufferGeometry){var s=n.index,c=n.attributes.position;if(null!==s)for(var l=s.array,u=0,h=l.length;u<h;u++){var d=l[u];oo.fromBufferAttribute(c,d),co(oo,d,o,r,t,e,this)}else for(var p=0,f=c.count;p<f;p++)oo.fromBufferAttribute(c,p),co(oo,p,o,r,t,e,this)}else for(var m=n.vertices,v=0,g=m.length;v<g;v++)co(m[v],v,o,r,t,e,this)}},updateMorphTargets:function(){var t=this.geometry;if(t.isBufferGeometry){var e=t.morphAttributes,n=Object.keys(e);if(n.length>0){var r=e[n[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var i=0,a=r.length;i<a;i++){var o=r[i].name||String(i);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=i}}}}else{var s=t.morphTargets;void 0!==s&&s.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}),lo.prototype=Object.assign(Object.create(gt.prototype),{constructor:lo,clone:function(){return new this.constructor(this.image).copy(this)},isVideoTexture:!0,update:function(){var t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),uo.prototype=Object.create(gt.prototype),uo.prototype.constructor=uo,uo.prototype.isCompressedTexture=!0,ho.prototype=Object.create(gt.prototype),ho.prototype.constructor=ho,ho.prototype.isCanvasTexture=!0,po.prototype=Object.create(gt.prototype),po.prototype.constructor=po,po.prototype.isDepthTexture=!0;var fo=0,mo=new Jt,vo=new be,go=new wt;function yo(){Object.defineProperty(this,"id",{value:fo+=2}),this.uuid=st.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}yo.prototype=Object.assign(Object.create(rt.prototype),{constructor:yo,isGeometry:!0,applyMatrix4:function(t){for(var e=(new ft).getNormalMatrix(t),n=0,r=this.vertices.length;n<r;n++){this.vertices[n].applyMatrix4(t)}for(var i=0,a=this.faces.length;i<a;i++){var o=this.faces[i];o.normal.applyMatrix3(e).normalize();for(var s=0,c=o.vertexNormals.length;s<c;s++)o.vertexNormals[s].applyMatrix3(e).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(t){return mo.makeRotationX(t),this.applyMatrix4(mo),this},rotateY:function(t){return mo.makeRotationY(t),this.applyMatrix4(mo),this},rotateZ:function(t){return mo.makeRotationZ(t),this.applyMatrix4(mo),this},translate:function(t,e,n){return mo.makeTranslation(t,e,n),this.applyMatrix4(mo),this},scale:function(t,e,n){return mo.makeScale(t,e,n),this.applyMatrix4(mo),this},lookAt:function(t){return vo.lookAt(t),vo.updateMatrix(),this.applyMatrix4(vo.matrix),this},fromBufferGeometry:function(t){var e=this,n=null!==t.index?t.index:void 0,r=t.attributes;if(void 0===r.position)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;var i=r.position,a=r.normal,o=r.color,s=r.uv,c=r.uv2;void 0!==c&&(this.faceVertexUvs[1]=[]);for(var l=0;l<i.count;l++)e.vertices.push((new wt).fromBufferAttribute(i,l)),void 0!==o&&e.colors.push((new Ve).fromBufferAttribute(o,l));function u(t,n,r,i){var l=void 0===o?[]:[e.colors[t].clone(),e.colors[n].clone(),e.colors[r].clone()],u=void 0===a?[]:[(new wt).fromBufferAttribute(a,t),(new wt).fromBufferAttribute(a,n),(new wt).fromBufferAttribute(a,r)],h=new We(t,n,r,u,l,i);e.faces.push(h),void 0!==s&&e.faceVertexUvs[0].push([(new pt).fromBufferAttribute(s,t),(new pt).fromBufferAttribute(s,n),(new pt).fromBufferAttribute(s,r)]),void 0!==c&&e.faceVertexUvs[1].push([(new pt).fromBufferAttribute(c,t),(new pt).fromBufferAttribute(c,n),(new pt).fromBufferAttribute(c,r)])}var h=t.groups;if(h.length>0)for(var d=0;d<h.length;d++)for(var p=h[d],f=p.start,m=f,v=f+p.count;m<v;m+=3)void 0!==n?u(n.getX(m),n.getX(m+1),n.getX(m+2),p.materialIndex):u(m,m+1,m+2,p.materialIndex);else if(void 0!==n)for(var g=0;g<n.count;g+=3)u(n.getX(g),n.getX(g+1),n.getX(g+2));else for(var y=0;y<i.count;y+=3)u(y,y+1,y+2);return this.computeFaceNormals(),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(go).negate(),this.translate(go.x,go.y,go.z),this},normalize:function(){this.computeBoundingSphere();var t=this.boundingSphere.center,e=this.boundingSphere.radius,n=0===e?1:1/e,r=new Jt;return r.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix4(r),this},computeFaceNormals:function(){for(var t=new wt,e=new wt,n=0,r=this.faces.length;n<r;n++){var i=this.faces[n],a=this.vertices[i.a],o=this.vertices[i.b],s=this.vertices[i.c];t.subVectors(s,o),e.subVectors(a,o),t.cross(e),t.normalize(),i.normal.copy(t)}},computeVertexNormals:function(t){void 0===t&&(t=!0);for(var e=new Array(this.vertices.length),n=0,r=this.vertices.length;n<r;n++)e[n]=new wt;if(t)for(var i=new wt,a=new wt,o=0,s=this.faces.length;o<s;o++){var c=this.faces[o],l=this.vertices[c.a],u=this.vertices[c.b],h=this.vertices[c.c];i.subVectors(h,u),a.subVectors(l,u),i.cross(a),e[c.a].add(i),e[c.b].add(i),e[c.c].add(i)}else{this.computeFaceNormals();for(var d=0,p=this.faces.length;d<p;d++){var f=this.faces[d];e[f.a].add(f.normal),e[f.b].add(f.normal),e[f.c].add(f.normal)}}for(var m=0,v=this.vertices.length;m<v;m++)e[m].normalize();for(var g=0,y=this.faces.length;g<y;g++){var x=this.faces[g],_=x.vertexNormals;3===_.length?(_[0].copy(e[x.a]),_[1].copy(e[x.b]),_[2].copy(e[x.c])):(_[0]=e[x.a].clone(),_[1]=e[x.b].clone(),_[2]=e[x.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){this.computeFaceNormals();for(var t=0,e=this.faces.length;t<e;t++){var n=this.faces[t],r=n.vertexNormals;3===r.length?(r[0].copy(n.normal),r[1].copy(n.normal),r[2].copy(n.normal)):(r[0]=n.normal.clone(),r[1]=n.normal.clone(),r[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){for(var t=0,e=this.faces.length;t<e;t++){var n=this.faces[t];n.__originalFaceNormal?n.__originalFaceNormal.copy(n.normal):n.__originalFaceNormal=n.normal.clone(),n.__originalVertexNormals||(n.__originalVertexNormals=[]);for(var r=0,i=n.vertexNormals.length;r<i;r++)n.__originalVertexNormals[r]?n.__originalVertexNormals[r].copy(n.vertexNormals[r]):n.__originalVertexNormals[r]=n.vertexNormals[r].clone()}var a=new yo;a.faces=this.faces;for(var o=0,s=this.morphTargets.length;o<s;o++){if(!this.morphNormals[o]){this.morphNormals[o]={},this.morphNormals[o].faceNormals=[],this.morphNormals[o].vertexNormals=[];for(var c=this.morphNormals[o].faceNormals,l=this.morphNormals[o].vertexNormals,u=0,h=this.faces.length;u<h;u++){var d=new wt,p={a:new wt,b:new wt,c:new wt};c.push(d),l.push(p)}}var f=this.morphNormals[o];a.vertices=this.morphTargets[o].vertices,a.computeFaceNormals(),a.computeVertexNormals();for(var m=0,v=this.faces.length;m<v;m++){var g=this.faces[m],y=f.faceNormals[m],x=f.vertexNormals[m];y.copy(g.normal),x.a.copy(g.vertexNormals[0]),x.b.copy(g.vertexNormals[1]),x.c.copy(g.vertexNormals[2])}}for(var _=0,b=this.faces.length;_<b;_++){var w=this.faces[_];w.normal=w.__originalFaceNormal,w.vertexNormals=w.__originalVertexNormals}},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Tt),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new Ht),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,n){if(t&&t.isGeometry){var r,i=this.vertices.length,a=this.vertices,o=t.vertices,s=this.faces,c=t.faces,l=this.colors,u=t.colors;void 0===n&&(n=0),void 0!==e&&(r=(new ft).getNormalMatrix(e));for(var h=0,d=o.length;h<d;h++){var p=o[h].clone();void 0!==e&&p.applyMatrix4(e),a.push(p)}for(var f=0,m=u.length;f<m;f++)l.push(u[f].clone());for(var v=0,g=c.length;v<g;v++){var y=c[v],x=void 0,_=void 0,b=y.vertexNormals,w=y.vertexColors,M=new We(y.a+i,y.b+i,y.c+i);M.normal.copy(y.normal),void 0!==r&&M.normal.applyMatrix3(r).normalize();for(var S=0,T=b.length;S<T;S++)x=b[S].clone(),void 0!==r&&x.applyMatrix3(r).normalize(),M.vertexNormals.push(x);M.color.copy(y.color);for(var E=0,A=w.length;E<A;E++)_=w[E],M.vertexColors.push(_.clone());M.materialIndex=y.materialIndex+n,s.push(M)}for(var L=0,R=t.faceVertexUvs.length;L<R;L++){var C=t.faceVertexUvs[L];void 0===this.faceVertexUvs[L]&&(this.faceVertexUvs[L]=[]);for(var P=0,I=C.length;P<I;P++){for(var D=C[P],O=[],N=0,B=D.length;N<B;N++)O.push(D[N].clone());this.faceVertexUvs[L].push(O)}}}else console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t)},mergeMesh:function(t){t&&t.isMesh?(t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)):console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t)},mergeVertices:function(){for(var t={},e=[],n=[],r=Math.pow(10,4),i=0,a=this.vertices.length;i<a;i++){var o=this.vertices[i],s=Math.round(o.x*r)+"_"+Math.round(o.y*r)+"_"+Math.round(o.z*r);void 0===t[s]?(t[s]=i,e.push(this.vertices[i]),n[i]=e.length-1):n[i]=n[t[s]]}for(var c=[],l=0,u=this.faces.length;l<u;l++){var h=this.faces[l];h.a=n[h.a],h.b=n[h.b],h.c=n[h.c];for(var d=[h.a,h.b,h.c],p=0;p<3;p++)if(d[p]===d[(p+1)%3]){c.push(l);break}}for(var f=c.length-1;f>=0;f--){var m=c[f];this.faces.splice(m,1);for(var v=0,g=this.faceVertexUvs.length;v<g;v++)this.faceVertexUvs[v].splice(m,1)}var y=this.vertices.length-e.length;return this.vertices=e,y},setFromPoints:function(t){this.vertices=[];for(var e=0,n=t.length;e<n;e++){var r=t[e];this.vertices.push(new wt(r.x,r.y,r.z||0))}return this},sortFacesByMaterialIndex:function(){for(var t=this.faces,e=t.length,n=0;n<e;n++)t[n]._id=n;t.sort((function(t,e){return t.materialIndex-e.materialIndex}));var r,i,a=this.faceVertexUvs[0],o=this.faceVertexUvs[1];a&&a.length===e&&(r=[]),o&&o.length===e&&(i=[]);for(var s=0;s<e;s++){var c=t[s]._id;r&&r.push(a[c]),i&&i.push(o[c])}r&&(this.faceVertexUvs[0]=r),i&&(this.faceVertexUvs[1]=i)},toJSON:function(){var t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),void 0!==this.parameters){var e=this.parameters;for(var n in e)void 0!==e[n]&&(t[n]=e[n]);return t}for(var r=[],i=0;i<this.vertices.length;i++){var a=this.vertices[i];r.push(a.x,a.y,a.z)}for(var o=[],s=[],c={},l=[],u={},h=[],d={},p=0;p<this.faces.length;p++){var f=this.faces[p],m=void 0!==this.faceVertexUvs[0][p],v=f.normal.length()>0,g=f.vertexNormals.length>0,y=1!==f.color.r||1!==f.color.g||1!==f.color.b,x=f.vertexColors.length>0,_=0;if(_=S(_,0,0),_=S(_,1,!0),_=S(_,2,!1),_=S(_,3,m),_=S(_,4,v),_=S(_,5,g),_=S(_,6,y),_=S(_,7,x),o.push(_),o.push(f.a,f.b,f.c),o.push(f.materialIndex),m){var b=this.faceVertexUvs[0][p];o.push(A(b[0]),A(b[1]),A(b[2]))}if(v&&o.push(T(f.normal)),g){var w=f.vertexNormals;o.push(T(w[0]),T(w[1]),T(w[2]))}if(y&&o.push(E(f.color)),x){var M=f.vertexColors;o.push(E(M[0]),E(M[1]),E(M[2]))}}function S(t,e,n){return n?t|1<<e:t&~(1<<e)}function T(t){var e=t.x.toString()+t.y.toString()+t.z.toString();return void 0!==c[e]||(c[e]=s.length/3,s.push(t.x,t.y,t.z)),c[e]}function E(t){var e=t.r.toString()+t.g.toString()+t.b.toString();return void 0!==u[e]||(u[e]=l.length,l.push(t.getHex())),u[e]}function A(t){var e=t.x.toString()+t.y.toString();return void 0!==d[e]||(d[e]=h.length/2,h.push(t.x,t.y)),d[e]}return t.data={},t.data.vertices=r,t.data.normals=s,l.length>0&&(t.data.colors=l),h.length>0&&(t.data.uvs=[h]),t.data.faces=o,t},clone:function(){return(new yo).copy(this)},copy:function(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;for(var e=t.vertices,n=0,r=e.length;n<r;n++)this.vertices.push(e[n].clone());for(var i=t.colors,a=0,o=i.length;a<o;a++)this.colors.push(i[a].clone());for(var s=t.faces,c=0,l=s.length;c<l;c++)this.faces.push(s[c].clone());for(var u=0,h=t.faceVertexUvs.length;u<h;u++){var d=t.faceVertexUvs[u];void 0===this.faceVertexUvs[u]&&(this.faceVertexUvs[u]=[]);for(var p=0,f=d.length;p<f;p++){for(var m=d[p],v=[],g=0,y=m.length;g<y;g++){var x=m[g];v.push(x.clone())}this.faceVertexUvs[u].push(v)}}for(var _=t.morphTargets,b=0,w=_.length;b<w;b++){var M={};if(M.name=_[b].name,void 0!==_[b].vertices){M.vertices=[];for(var S=0,T=_[b].vertices.length;S<T;S++)M.vertices.push(_[b].vertices[S].clone())}if(void 0!==_[b].normals){M.normals=[];for(var E=0,A=_[b].normals.length;E<A;E++)M.normals.push(_[b].normals[E].clone())}this.morphTargets.push(M)}for(var L=t.morphNormals,R=0,C=L.length;R<C;R++){var P={};if(void 0!==L[R].vertexNormals){P.vertexNormals=[];for(var I=0,D=L[R].vertexNormals.length;I<D;I++){var O=L[R].vertexNormals[I],N={};N.a=O.a.clone(),N.b=O.b.clone(),N.c=O.c.clone(),P.vertexNormals.push(N)}}if(void 0!==L[R].faceNormals){P.faceNormals=[];for(var B=0,z=L[R].faceNormals.length;B<z;B++)P.faceNormals.push(L[R].faceNormals[B].clone())}this.morphNormals.push(P)}for(var G=t.skinWeights,F=0,U=G.length;F<U;F++)this.skinWeights.push(G[F].clone());for(var H=t.skinIndices,k=0,V=H.length;k<V;k++)this.skinIndices.push(H[k].clone());for(var W=t.lineDistances,j=0,q=W.length;j<q;j++)this.lineDistances.push(W[j]);var X=t.boundingBox;null!==X&&(this.boundingBox=X.clone());var Y=t.boundingSphere;return null!==Y&&(this.boundingSphere=Y.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var xo=function(t){function e(e,n,r,i,a,o){var s;return(s=t.call(this)||this).type="BoxGeometry",s.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o},s.fromBufferGeometry(new zn(e,n,r,i,a,o)),s.mergeVertices(),s}return ut(e,t),e}(yo),_o=function(t){function e(e,n,r,i){var a;(a=t.call(this)||this).type="CircleBufferGeometry",a.parameters={radius:e,segments:n,thetaStart:r,thetaLength:i},e=e||1,n=void 0!==n?Math.max(3,n):8,r=void 0!==r?r:0,i=void 0!==i?i:2*Math.PI;var o=[],s=[],c=[],l=[],u=new wt,h=new pt;s.push(0,0,0),c.push(0,0,1),l.push(.5,.5);for(var d=0,p=3;d<=n;d++,p+=3){var f=r+d/n*i;u.x=e*Math.cos(f),u.y=e*Math.sin(f),s.push(u.x,u.y,u.z),c.push(0,0,1),h.x=(s[p]/e+1)/2,h.y=(s[p+1]/e+1)/2,l.push(h.x,h.y)}for(var m=1;m<=n;m++)o.push(m,m+1,0);return a.setIndex(o),a.setAttribute("position",new an(s,3)),a.setAttribute("normal",new an(c,3)),a.setAttribute("uv",new an(l,2)),a}return ut(e,t),e}(vn),bo=function(t){function e(e,n,r,i){var a;return(a=t.call(this)||this).type="CircleGeometry",a.parameters={radius:e,segments:n,thetaStart:r,thetaLength:i},a.fromBufferGeometry(new _o(e,n,r,i)),a.mergeVertices(),a}return ut(e,t),e}(yo),wo=function(t){function e(e,n,r,i,a,o,s,c){var l;(l=t.call(this)||this).type="CylinderBufferGeometry",l.parameters={radiusTop:e,radiusBottom:n,height:r,radialSegments:i,heightSegments:a,openEnded:o,thetaStart:s,thetaLength:c};var u=ht(l);e=void 0!==e?e:1,n=void 0!==n?n:1,r=r||1,i=Math.floor(i)||8,a=Math.floor(a)||1,o=void 0!==o&&o,s=void 0!==s?s:0,c=void 0!==c?c:2*Math.PI;var h=[],d=[],p=[],f=[],m=0,v=[],g=r/2,y=0;function x(t){for(var r=m,a=new pt,o=new wt,l=0,v=!0===t?e:n,x=!0===t?1:-1,_=1;_<=i;_++)d.push(0,g*x,0),p.push(0,x,0),f.push(.5,.5),m++;for(var b=m,w=0;w<=i;w++){var M=w/i*c+s,S=Math.cos(M),T=Math.sin(M);o.x=v*T,o.y=g*x,o.z=v*S,d.push(o.x,o.y,o.z),p.push(0,x,0),a.x=.5*S+.5,a.y=.5*T*x+.5,f.push(a.x,a.y),m++}for(var E=0;E<i;E++){var A=r+E,L=b+E;!0===t?h.push(L,L+1,A):h.push(L+1,L,A),l+=3}u.addGroup(y,l,!0===t?1:2),y+=l}return function(){for(var t=new wt,o=new wt,l=0,x=(n-e)/r,_=0;_<=a;_++){for(var b=[],w=_/a,M=w*(n-e)+e,S=0;S<=i;S++){var T=S/i,E=T*c+s,A=Math.sin(E),L=Math.cos(E);o.x=M*A,o.y=-w*r+g,o.z=M*L,d.push(o.x,o.y,o.z),t.set(A,x,L).normalize(),p.push(t.x,t.y,t.z),f.push(T,1-w),b.push(m++)}v.push(b)}for(var R=0;R<i;R++)for(var C=0;C<a;C++){var P=v[C][R],I=v[C+1][R],D=v[C+1][R+1],O=v[C][R+1];h.push(P,I,O),h.push(I,D,O),l+=6}u.addGroup(y,l,0),y+=l}(),!1===o&&(e>0&&x(!0),n>0&&x(!1)),l.setIndex(h),l.setAttribute("position",new an(d,3)),l.setAttribute("normal",new an(p,3)),l.setAttribute("uv",new an(f,2)),l}return ut(e,t),e}(vn),Mo=function(t){function e(e,n,r,i,a,o,s,c){var l;return(l=t.call(this)||this).type="CylinderGeometry",l.parameters={radiusTop:e,radiusBottom:n,height:r,radialSegments:i,heightSegments:a,openEnded:o,thetaStart:s,thetaLength:c},l.fromBufferGeometry(new wo(e,n,r,i,a,o,s,c)),l.mergeVertices(),l}return ut(e,t),e}(yo),So=function(t){function e(e,n,r,i,a,o,s){var c;return(c=t.call(this,0,e,n,r,i,a,o,s)||this).type="ConeGeometry",c.parameters={radius:e,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s},c}return ut(e,t),e}(Mo),To=function(t){function e(e,n,r,i,a,o,s){var c;return(c=t.call(this,0,e,n,r,i,a,o,s)||this).type="ConeBufferGeometry",c.parameters={radius:e,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s},c}return ut(e,t),e}(wo),Eo=function(t){function e(e,n,r,i){var a;(a=t.call(this)||this).type="PolyhedronBufferGeometry",a.parameters={vertices:e,indices:n,radius:r,detail:i},r=r||1;var o=[],s=[];function c(t,e,n,r){for(var i=r+1,a=[],o=0;o<=i;o++){a[o]=[];for(var s=t.clone().lerp(n,o/i),c=e.clone().lerp(n,o/i),u=i-o,h=0;h<=u;h++)a[o][h]=0===h&&o===i?s:s.clone().lerp(c,h/u)}for(var d=0;d<i;d++)for(var p=0;p<2*(i-d)-1;p++){var f=Math.floor(p/2);p%2==0?(l(a[d][f+1]),l(a[d+1][f]),l(a[d][f])):(l(a[d][f+1]),l(a[d+1][f+1]),l(a[d+1][f]))}}function l(t){o.push(t.x,t.y,t.z)}function u(t,n){var r=3*t;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function h(t,e,n,r){r<0&&1===t.x&&(s[e]=t.x-1),0===n.x&&0===n.z&&(s[e]=r/2/Math.PI+.5)}function d(t){return Math.atan2(t.z,-t.x)}function p(t){return Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))}return function(t){for(var e=new wt,r=new wt,i=new wt,a=0;a<n.length;a+=3)u(n[a+0],e),u(n[a+1],r),u(n[a+2],i),c(e,r,i,t)}(i=i||0),function(t){for(var e=new wt,n=0;n<o.length;n+=3)e.x=o[n+0],e.y=o[n+1],e.z=o[n+2],e.normalize().multiplyScalar(t),o[n+0]=e.x,o[n+1]=e.y,o[n+2]=e.z}(r),function(){for(var t=new wt,e=0;e<o.length;e+=3){t.x=o[e+0],t.y=o[e+1],t.z=o[e+2];var n=d(t)/2/Math.PI+.5,r=p(t)/Math.PI+.5;s.push(n,1-r)}(function(){for(var t=new wt,e=new wt,n=new wt,r=new wt,i=new pt,a=new pt,c=new pt,l=0,u=0;l<o.length;l+=9,u+=6){t.set(o[l+0],o[l+1],o[l+2]),e.set(o[l+3],o[l+4],o[l+5]),n.set(o[l+6],o[l+7],o[l+8]),i.set(s[u+0],s[u+1]),a.set(s[u+2],s[u+3]),c.set(s[u+4],s[u+5]),r.copy(t).add(e).add(n).divideScalar(3);var p=d(r);h(i,u+0,t,p),h(a,u+2,e,p),h(c,u+4,n,p)}})(),function(){for(var t=0;t<s.length;t+=6){var e=s[t+0],n=s[t+2],r=s[t+4],i=Math.max(e,n,r),a=Math.min(e,n,r);i>.9&&a<.1&&(e<.2&&(s[t+0]+=1),n<.2&&(s[t+2]+=1),r<.2&&(s[t+4]+=1))}}()}(),a.setAttribute("position",new an(o,3)),a.setAttribute("normal",new an(o.slice(),3)),a.setAttribute("uv",new an(s,2)),0===i?a.computeVertexNormals():a.normalizeNormals(),a}return ut(e,t),e}(vn),Ao=function(t){function e(e,n){var r,i=(1+Math.sqrt(5))/2,a=1/i,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-a,-i,0,-a,i,0,a,-i,0,a,i,-a,-i,0,-a,i,0,a,-i,0,a,i,0,-i,0,-a,i,0,-a,-i,0,a,i,0,a];return(r=t.call(this,o,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,n)||this).type="DodecahedronBufferGeometry",r.parameters={radius:e,detail:n},r}return ut(e,t),e}(Eo),Lo=function(t){function e(e,n){var r;return(r=t.call(this)||this).type="DodecahedronGeometry",r.parameters={radius:e,detail:n},r.fromBufferGeometry(new Ao(e,n)),r.mergeVertices(),r}return ut(e,t),e}(yo),Ro=new wt,Co=new wt,Po=new wt,Io=new Be,Do=function(t){function e(e,n){var r;(r=t.call(this)||this).type="EdgesGeometry",r.parameters={thresholdAngle:n},n=void 0!==n?n:1,e.isGeometry&&(e=(new vn).fromGeometry(e));for(var i=Math.pow(10,4),a=Math.cos(st.DEG2RAD*n),o=e.getIndex(),s=e.getAttribute("position"),c=o?o.count:s.count,l=[0,0,0],u=["a","b","c"],h=new Array(3),d={},p=[],f=0;f<c;f+=3){o?(l[0]=o.getX(f),l[1]=o.getX(f+1),l[2]=o.getX(f+2)):(l[0]=f,l[1]=f+1,l[2]=f+2);var m=Io.a,v=Io.b,g=Io.c;if(m.fromBufferAttribute(s,l[0]),v.fromBufferAttribute(s,l[1]),g.fromBufferAttribute(s,l[2]),Io.getNormal(Po),h[0]=Math.round(m.x*i)+","+Math.round(m.y*i)+","+Math.round(m.z*i),h[1]=Math.round(v.x*i)+","+Math.round(v.y*i)+","+Math.round(v.z*i),h[2]=Math.round(g.x*i)+","+Math.round(g.y*i)+","+Math.round(g.z*i),h[0]!==h[1]&&h[1]!==h[2]&&h[2]!==h[0])for(var y=0;y<3;y++){var x=(y+1)%3,_=h[y],b=h[x],w=Io[u[y]],M=Io[u[x]],S=_+"_"+b,T=b+"_"+_;T in d&&d[T]?(Po.dot(d[T].normal)<=a&&(p.push(w.x,w.y,w.z),p.push(M.x,M.y,M.z)),d[T]=null):S in d||(d[S]={index0:l[y],index1:l[x],normal:Po.clone()})}}for(var E in d)if(d[E]){var A=d[E],L=A.index0,R=A.index1;Ro.fromBufferAttribute(s,L),Co.fromBufferAttribute(s,R),p.push(Ro.x,Ro.y,Ro.z),p.push(Co.x,Co.y,Co.z)}return r.setAttribute("position",new an(p,3)),r}return ut(e,t),e}(vn),Oo=function(t,e,n){n=n||2;var r,i,a,o,s,c,l,u=e&&e.length,h=u?e[0]*n:t.length,d=No(t,0,h,n,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=function(t,e,n,r){var i,a,o,s=[];for(i=0,a=e.length;i<a;i++)(o=No(t,e[i]*r,i<a-1?e[i+1]*r:t.length,r,!1))===o.next&&(o.steiner=!0),s.push(qo(o));for(s.sort(ko),i=0;i<s.length;i++)Vo(s[i],n),n=Bo(n,n.next);return n}(t,e,d,n)),t.length>80*n){r=a=t[0],i=o=t[1];for(var f=n;f<h;f+=n)(s=t[f])<r&&(r=s),(c=t[f+1])<i&&(i=c),s>a&&(a=s),c>o&&(o=c);l=0!==(l=Math.max(a-r,o-i))?1/l:0}return zo(d,p,n,r,i,l),p};function No(t,e,n,r,i){var a,o;if(i===function(t,e,n,r){for(var i=0,a=e,o=n-r;a<n;a+=r)i+=(t[o]-t[a])*(t[a+1]+t[o+1]),o=a;return i}(t,e,n,r)>0)for(a=e;a<n;a+=r)o=ns(a,t[a],t[a+1],o);else for(a=n-r;a>=e;a-=r)o=ns(a,t[a],t[a+1],o);return o&&Jo(o,o.next)&&(rs(o),o=o.next),o}function Bo(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!Jo(r,r.next)&&0!==Zo(r.prev,r,r.next))r=r.next;else{if(rs(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function zo(t,e,n,r,i,a,o){if(t){!o&&a&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=jo(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,a,o,s,c,l=1;do{for(n=t,t=null,a=null,o=0;n;){for(o++,r=n,s=0,e=0;e<l&&(s++,r=r.nextZ);e++);for(c=l;s>0||c>0&&r;)0!==s&&(0===c||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1)}(i)}(t,r,i,a);for(var s,c,l=t;t.prev!==t.next;)if(s=t.prev,c=t.next,a?Fo(t,r,i,a):Go(t))e.push(s.i/n),e.push(t.i/n),e.push(c.i/n),rs(t),t=c.next,l=c.next;else if((t=c)===l){o?1===o?zo(t=Uo(Bo(t),e,n),e,n,r,i,a,2):2===o&&Ho(t,e,n,r,i,a):zo(Bo(t),e,n,r,i,a,1);break}}}function Go(t){var e=t.prev,n=t,r=t.next;if(Zo(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Xo(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Zo(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Fo(t,e,n,r){var i=t.prev,a=t,o=t.next;if(Zo(i,a,o)>=0)return!1;for(var s=i.x<a.x?i.x<o.x?i.x:o.x:a.x<o.x?a.x:o.x,c=i.y<a.y?i.y<o.y?i.y:o.y:a.y<o.y?a.y:o.y,l=i.x>a.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,h=jo(s,c,e,n,r),d=jo(l,u,e,n,r),p=t.prevZ,f=t.nextZ;p&&p.z>=h&&f&&f.z<=d;){if(p!==t.prev&&p!==t.next&&Xo(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Zo(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==t.prev&&f!==t.next&&Xo(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Zo(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=h;){if(p!==t.prev&&p!==t.next&&Xo(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Zo(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&Xo(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Zo(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function Uo(t,e,n){var r=t;do{var i=r.prev,a=r.next.next;!Jo(i,a)&&Qo(i,r,r.next,a)&&ts(i,a)&&ts(a,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(a.i/n),rs(r),rs(r.next),r=t=a),r=r.next}while(r!==t);return Bo(r)}function Ho(t,e,n,r,i,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Yo(o,s)){var c=es(o,s);return o=Bo(o,o.next),c=Bo(c,c.next),zo(o,e,n,r,i,a),void zo(c,e,n,r,i,a)}s=s.next}o=o.next}while(o!==t)}function ko(t,e){return t.x-e.x}function Vo(t,e){if(e=function(t,e){var n,r=e,i=t.x,a=t.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var s=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>o){if(o=s,s===i){if(a===r.y)return r;if(a===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==e);if(!n)return null;if(i===o)return n;var c,l=n,u=n.x,h=n.y,d=1/0;r=n;do{i>=r.x&&r.x>=u&&i!==r.x&&Xo(a<h?i:o,a,u,h,a<h?o:i,a,r.x,r.y)&&(c=Math.abs(a-r.y)/(i-r.x),ts(r,t)&&(c<d||c===d&&(r.x>n.x||r.x===n.x&&Wo(n,r)))&&(n=r,d=c)),r=r.next}while(r!==l);return n}(t,e)){var n=es(e,t);Bo(e,e.next),Bo(n,n.next)}}function Wo(t,e){return Zo(t.prev,t,e.prev)<0&&Zo(e.next,t,t.next)<0}function jo(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function qo(t){var e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function Xo(t,e,n,r,i,a,o,s){return(i-o)*(e-s)-(t-o)*(a-s)>=0&&(t-o)*(r-s)-(n-o)*(e-s)>=0&&(n-o)*(a-s)-(i-o)*(r-s)>=0}function Yo(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Qo(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(ts(t,e)&&ts(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(Zo(t.prev,t,e.prev)||Zo(t,e.prev,e))||Jo(t,e)&&Zo(t.prev,t,t.next)>0&&Zo(e.prev,e,e.next)>0)}function Zo(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Jo(t,e){return t.x===e.x&&t.y===e.y}function Qo(t,e,n,r){var i=$o(Zo(t,e,n)),a=$o(Zo(t,e,r)),o=$o(Zo(n,r,t)),s=$o(Zo(n,r,e));return i!==a&&o!==s||(!(0!==i||!Ko(t,n,e))||(!(0!==a||!Ko(t,r,e))||(!(0!==o||!Ko(n,t,r))||!(0!==s||!Ko(n,e,r)))))}function Ko(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function $o(t){return t>0?1:t<0?-1:0}function ts(t,e){return Zo(t.prev,t,t.next)<0?Zo(t,e,t.next)>=0&&Zo(t,t.prev,e)>=0:Zo(t,e,t.prev)<0||Zo(t,t.next,e)<0}function es(t,e){var n=new is(t.i,t.x,t.y),r=new is(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function ns(t,e,n,r){var i=new is(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function rs(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function is(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var as={area:function(t){for(var e=t.length,n=0,r=e-1,i=0;i<e;r=i++)n+=t[r].x*t[i].y-t[i].x*t[r].y;return.5*n},isClockWise:function(t){return as.area(t)<0},triangulateShape:function(t,e){var n=[],r=[],i=[];os(t),ss(n,t);var a=t.length;e.forEach(os);for(var o=0;o<e.length;o++)r.push(a),a+=e[o].length,ss(n,e[o]);for(var s=Oo(n,r),c=0;c<s.length;c+=3)i.push(s.slice(c,c+3));return i}};function os(t){var e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function ss(t,e){for(var n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}var cs=function(t){function e(e,n){var r;(r=t.call(this)||this).type="ExtrudeBufferGeometry",r.parameters={shapes:e,options:n},e=Array.isArray(e)?e:[e];for(var i=ht(r),a=[],o=[],s=0,c=e.length;s<c;s++){l(e[s])}function l(t){var e=[],r=void 0!==n.curveSegments?n.curveSegments:12,s=void 0!==n.steps?n.steps:1,c=void 0!==n.depth?n.depth:100,l=void 0===n.bevelEnabled||n.bevelEnabled,u=void 0!==n.bevelThickness?n.bevelThickness:6,h=void 0!==n.bevelSize?n.bevelSize:u-2,d=void 0!==n.bevelOffset?n.bevelOffset:0,p=void 0!==n.bevelSegments?n.bevelSegments:3,f=n.extrudePath,m=void 0!==n.UVGenerator?n.UVGenerator:ls;void 0!==n.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),c=n.amount);var v,g,y,x,_,b=!1;f&&(v=f.getSpacedPoints(s),b=!0,l=!1,g=f.computeFrenetFrames(s,!1),y=new wt,x=new wt,_=new wt),l||(p=0,u=0,h=0,d=0);var w=t.extractPoints(r),M=w.shape,S=w.holes;if(!as.isClockWise(M)){M=M.reverse();for(var T=0,E=S.length;T<E;T++){var A=S[T];as.isClockWise(A)&&(S[T]=A.reverse())}}for(var L=as.triangulateShape(M,S),R=M,C=0,P=S.length;C<P;C++){var I=S[C];M=M.concat(I)}function D(t,e,n){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().multiplyScalar(n).add(t)}var O=M.length,N=L.length;function B(t,e,n){var r,i,a,o=t.x-e.x,s=t.y-e.y,c=n.x-t.x,l=n.y-t.y,u=o*o+s*s,h=o*l-s*c;if(Math.abs(h)>Number.EPSILON){var d=Math.sqrt(u),p=Math.sqrt(c*c+l*l),f=e.x-s/d,m=e.y+o/d,v=((n.x-l/p-f)*l-(n.y+c/p-m)*c)/(o*l-s*c),g=(r=f+o*v-t.x)*r+(i=m+s*v-t.y)*i;if(g<=2)return new pt(r,i);a=Math.sqrt(g/2)}else{var y=!1;o>Number.EPSILON?c>Number.EPSILON&&(y=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(l)&&(y=!0),y?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new pt(r/a,i/a)}for(var z=[],G=0,F=R.length,U=F-1,H=G+1;G<F;G++,U++,H++)U===F&&(U=0),H===F&&(H=0),z[G]=B(R[G],R[U],R[H]);for(var k,V=[],W=z.concat(),j=0,q=S.length;j<q;j++){var X=S[j];k=[];for(var Y=0,Z=X.length,J=Z-1,Q=Y+1;Y<Z;Y++,J++,Q++)J===Z&&(J=0),Q===Z&&(Q=0),k[Y]=B(X[Y],X[J],X[Q]);V.push(k),W=W.concat(k)}for(var K=0;K<p;K++){for(var $=K/p,tt=u*Math.cos($*Math.PI/2),et=h*Math.sin($*Math.PI/2)+d,nt=0,rt=R.length;nt<rt;nt++){var it=D(R[nt],z[nt],et);Dt(it.x,it.y,-tt)}for(var at=0,ot=S.length;at<ot;at++){var st=S[at];k=V[at];for(var ct=0,lt=st.length;ct<lt;ct++){var ut=D(st[ct],k[ct],et);Dt(ut.x,ut.y,-tt)}}}for(var ht=h+d,dt=0;dt<O;dt++){var ft=l?D(M[dt],W[dt],ht):M[dt];b?(x.copy(g.normals[0]).multiplyScalar(ft.x),y.copy(g.binormals[0]).multiplyScalar(ft.y),_.copy(v[0]).add(x).add(y),Dt(_.x,_.y,_.z)):Dt(ft.x,ft.y,0)}for(var mt=1;mt<=s;mt++)for(var vt=0;vt<O;vt++){var gt=l?D(M[vt],W[vt],ht):M[vt];b?(x.copy(g.normals[mt]).multiplyScalar(gt.x),y.copy(g.binormals[mt]).multiplyScalar(gt.y),_.copy(v[mt]).add(x).add(y),Dt(_.x,_.y,_.z)):Dt(gt.x,gt.y,c/s*mt)}for(var yt=p-1;yt>=0;yt--){for(var xt=yt/p,_t=u*Math.cos(xt*Math.PI/2),bt=h*Math.sin(xt*Math.PI/2)+d,Mt=0,St=R.length;Mt<St;Mt++){var Tt=D(R[Mt],z[Mt],bt);Dt(Tt.x,Tt.y,c+_t)}for(var Et=0,At=S.length;Et<At;Et++){var Lt=S[Et];k=V[Et];for(var Rt=0,Ct=Lt.length;Rt<Ct;Rt++){var Pt=D(Lt[Rt],k[Rt],bt);b?Dt(Pt.x,Pt.y+v[s-1].y,v[s-1].x+_t):Dt(Pt.x,Pt.y,c+_t)}}}function It(t,e){for(var n=t.length;--n>=0;){var r=n,i=n-1;i<0&&(i=t.length-1);for(var a=0,o=s+2*p;a<o;a++){var c=O*a,l=O*(a+1);Nt(e+r+c,e+i+c,e+i+l,e+r+l)}}}function Dt(t,n,r){e.push(t),e.push(n),e.push(r)}function Ot(t,e,n){Bt(t),Bt(e),Bt(n);var r=a.length/3,o=m.generateTopUV(i,a,r-3,r-2,r-1);zt(o[0]),zt(o[1]),zt(o[2])}function Nt(t,e,n,r){Bt(t),Bt(e),Bt(r),Bt(e),Bt(n),Bt(r);var o=a.length/3,s=m.generateSideWallUV(i,a,o-6,o-3,o-2,o-1);zt(s[0]),zt(s[1]),zt(s[3]),zt(s[1]),zt(s[2]),zt(s[3])}function Bt(t){a.push(e[3*t+0]),a.push(e[3*t+1]),a.push(e[3*t+2])}function zt(t){o.push(t.x),o.push(t.y)}!function(){var t=a.length/3;if(l){for(var e=0,n=O*e,r=0;r<N;r++){var o=L[r];Ot(o[2]+n,o[1]+n,o[0]+n)}n=O*(e=s+2*p);for(var c=0;c<N;c++){var u=L[c];Ot(u[0]+n,u[1]+n,u[2]+n)}}else{for(var h=0;h<N;h++){var d=L[h];Ot(d[2],d[1],d[0])}for(var f=0;f<N;f++){var m=L[f];Ot(m[0]+O*s,m[1]+O*s,m[2]+O*s)}}i.addGroup(t,a.length/3-t,0)}(),function(){var t=a.length/3,e=0;It(R,e),e+=R.length;for(var n=0,r=S.length;n<r;n++){var o=S[n];It(o,e),e+=o.length}i.addGroup(t,a.length/3-t,1)}()}return r.setAttribute("position",new an(a,3)),r.setAttribute("uv",new an(o,2)),r.computeVertexNormals(),r}return ut(e,t),e.prototype.toJSON=function(){var t=vn.prototype.toJSON.call(this);return function(t,e,n){if(n.shapes=[],Array.isArray(t))for(var r=0,i=t.length;r<i;r++){var a=t[r];n.shapes.push(a.uuid)}else n.shapes.push(t.uuid);void 0!==e.extrudePath&&(n.options.extrudePath=e.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,t)},e}(vn),ls={generateTopUV:function(t,e,n,r,i){var a=e[3*n],o=e[3*n+1],s=e[3*r],c=e[3*r+1],l=e[3*i],u=e[3*i+1];return[new pt(a,o),new pt(s,c),new pt(l,u)]},generateSideWallUV:function(t,e,n,r,i,a){var o=e[3*n],s=e[3*n+1],c=e[3*n+2],l=e[3*r],u=e[3*r+1],h=e[3*r+2],d=e[3*i],p=e[3*i+1],f=e[3*i+2],m=e[3*a],v=e[3*a+1],g=e[3*a+2];return Math.abs(s-u)<.01?[new pt(o,1-c),new pt(l,1-h),new pt(d,1-f),new pt(m,1-g)]:[new pt(s,1-c),new pt(u,1-h),new pt(p,1-f),new pt(v,1-g)]}};var us=function(t){function e(e,n){var r;return(r=t.call(this)||this).type="ExtrudeGeometry",r.parameters={shapes:e,options:n},r.fromBufferGeometry(new cs(e,n)),r.mergeVertices(),r}return ut(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return function(t,e,n){if(n.shapes=[],Array.isArray(t))for(var r=0,i=t.length;r<i;r++){var a=t[r];n.shapes.push(a.uuid)}else n.shapes.push(t.uuid);void 0!==e.extrudePath&&(n.options.extrudePath=e.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,e)},e}(yo);var hs=function(t){function e(e,n){var r,i=(1+Math.sqrt(5))/2,a=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1];return(r=t.call(this,a,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,n)||this).type="IcosahedronBufferGeometry",r.parameters={radius:e,detail:n},r}return ut(e,t),e}(Eo),ds=function(t){function e(e,n){var r;return(r=t.call(this)||this).type="IcosahedronGeometry",r.parameters={radius:e,detail:n},r.fromBufferGeometry(new hs(e,n)),r.mergeVertices(),r}return ut(e,t),e}(yo),ps=function(t){function e(e,n,r,i){var a;(a=t.call(this)||this).type="LatheBufferGeometry",a.parameters={points:e,segments:n,phiStart:r,phiLength:i},n=Math.floor(n)||12,r=r||0,i=i||2*Math.PI,i=st.clamp(i,0,2*Math.PI);for(var o=[],s=[],c=[],l=1/n,u=new wt,h=new pt,d=0;d<=n;d++)for(var p=r+d*l*i,f=Math.sin(p),m=Math.cos(p),v=0;v<=e.length-1;v++)u.x=e[v].x*f,u.y=e[v].y,u.z=e[v].x*m,s.push(u.x,u.y,u.z),h.x=d/n,h.y=v/(e.length-1),c.push(h.x,h.y);for(var g=0;g<n;g++)for(var y=0;y<e.length-1;y++){var x=y+g*e.length,_=x,b=x+e.length,w=x+e.length+1,M=x+1;o.push(_,b,M),o.push(b,w,M)}if(a.setIndex(o),a.setAttribute("position",new an(s,3)),a.setAttribute("uv",new an(c,2)),a.computeVertexNormals(),i===2*Math.PI)for(var S=a.attributes.normal.array,T=new wt,E=new wt,A=new wt,L=n*e.length*3,R=0,C=0;R<e.length;R++,C+=3)T.x=S[C+0],T.y=S[C+1],T.z=S[C+2],E.x=S[L+C+0],E.y=S[L+C+1],E.z=S[L+C+2],A.addVectors(T,E).normalize(),S[C+0]=S[L+C+0]=A.x,S[C+1]=S[L+C+1]=A.y,S[C+2]=S[L+C+2]=A.z;return a}return ut(e,t),e}(vn),fs=function(t){function e(e,n,r,i){var a;return(a=t.call(this)||this).type="LatheGeometry",a.parameters={points:e,segments:n,phiStart:r,phiLength:i},a.fromBufferGeometry(new ps(e,n,r,i)),a.mergeVertices(),a}return ut(e,t),e}(yo),ms=function(t){function e(e,n){var r;return(r=t.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,n)||this).type="OctahedronBufferGeometry",r.parameters={radius:e,detail:n},r}return ut(e,t),e}(Eo),vs=function(t){function e(e,n){var r;return(r=t.call(this)||this).type="OctahedronGeometry",r.parameters={radius:e,detail:n},r.fromBufferGeometry(new ms(e,n)),r.mergeVertices(),r}return ut(e,t),e}(yo);function gs(t,e,n){vn.call(this),this.type="ParametricBufferGeometry",this.parameters={func:t,slices:e,stacks:n};var r=[],i=[],a=[],o=[],s=1e-5,c=new wt,l=new wt,u=new wt,h=new wt,d=new wt;t.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");for(var p=e+1,f=0;f<=n;f++)for(var m=f/n,v=0;v<=e;v++){var g=v/e;t(g,m,l),i.push(l.x,l.y,l.z),g-s>=0?(t(g-s,m,u),h.subVectors(l,u)):(t(g+s,m,u),h.subVectors(u,l)),m-s>=0?(t(g,m-s,u),d.subVectors(l,u)):(t(g,m+s,u),d.subVectors(u,l)),c.crossVectors(h,d).normalize(),a.push(c.x,c.y,c.z),o.push(g,m)}for(var y=0;y<n;y++)for(var x=0;x<e;x++){var _=y*p+x,b=y*p+x+1,w=(y+1)*p+x+1,M=(y+1)*p+x;r.push(_,b,M),r.push(b,w,M)}this.setIndex(r),this.setAttribute("position",new an(i,3)),this.setAttribute("normal",new an(a,3)),this.setAttribute("uv",new an(o,2))}function ys(t,e,n){yo.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:n},this.fromBufferGeometry(new gs(t,e,n)),this.mergeVertices()}gs.prototype=Object.create(vn.prototype),gs.prototype.constructor=gs,ys.prototype=Object.create(yo.prototype),ys.prototype.constructor=ys;var xs=function(t){function e(e,n,r,i){var a;return(a=t.call(this)||this).type="PlaneGeometry",a.parameters={width:e,height:n,widthSegments:r,heightSegments:i},a.fromBufferGeometry(new tr(e,n,r,i)),a.mergeVertices(),a}return ut(e,t),e}(yo),_s=function(t){function e(e,n,r,i){var a;return(a=t.call(this)||this).type="PolyhedronGeometry",a.parameters={vertices:e,indices:n,radius:r,detail:i},a.fromBufferGeometry(new Eo(e,n,r,i)),a.mergeVertices(),a}return ut(e,t),e}(yo),bs=function(t){function e(e,n,r,i,a,o){var s;(s=t.call(this)||this).type="RingBufferGeometry",s.parameters={innerRadius:e,outerRadius:n,thetaSegments:r,phiSegments:i,thetaStart:a,thetaLength:o},e=e||.5,n=n||1,a=void 0!==a?a:0,o=void 0!==o?o:2*Math.PI,r=void 0!==r?Math.max(3,r):8;for(var c=[],l=[],u=[],h=[],d=e,p=(n-e)/(i=void 0!==i?Math.max(1,i):1),f=new wt,m=new pt,v=0;v<=i;v++){for(var g=0;g<=r;g++){var y=a+g/r*o;f.x=d*Math.cos(y),f.y=d*Math.sin(y),l.push(f.x,f.y,f.z),u.push(0,0,1),m.x=(f.x/n+1)/2,m.y=(f.y/n+1)/2,h.push(m.x,m.y)}d+=p}for(var x=0;x<i;x++)for(var _=x*(r+1),b=0;b<r;b++){var w=b+_,M=w,S=w+r+1,T=w+r+2,E=w+1;c.push(M,S,E),c.push(S,T,E)}return s.setIndex(c),s.setAttribute("position",new an(l,3)),s.setAttribute("normal",new an(u,3)),s.setAttribute("uv",new an(h,2)),s}return ut(e,t),e}(vn),ws=function(t){function e(e,n,r,i,a,o){var s;return(s=t.call(this)||this).type="RingGeometry",s.parameters={innerRadius:e,outerRadius:n,thetaSegments:r,phiSegments:i,thetaStart:a,thetaLength:o},s.fromBufferGeometry(new bs(e,n,r,i,a,o)),s.mergeVertices(),s}return ut(e,t),e}(yo),Ms=function(t){function e(e,n){var r;(r=t.call(this)||this).type="ShapeBufferGeometry",r.parameters={shapes:e,curveSegments:n},n=n||12;var i=[],a=[],o=[],s=[],c=0,l=0;if(!1===Array.isArray(e))h(e);else for(var u=0;u<e.length;u++)h(e[u]),r.addGroup(c,l,u),c+=l,l=0;function h(t){var e=a.length/3,r=t.extractPoints(n),c=r.shape,u=r.holes;!1===as.isClockWise(c)&&(c=c.reverse());for(var h=0,d=u.length;h<d;h++){var p=u[h];!0===as.isClockWise(p)&&(u[h]=p.reverse())}for(var f=as.triangulateShape(c,u),m=0,v=u.length;m<v;m++){var g=u[m];c=c.concat(g)}for(var y=0,x=c.length;y<x;y++){var _=c[y];a.push(_.x,_.y,0),o.push(0,0,1),s.push(_.x,_.y)}for(var b=0,w=f.length;b<w;b++){var M=f[b],S=M[0]+e,T=M[1]+e,E=M[2]+e;i.push(S,T,E),l+=3}}return r.setIndex(i),r.setAttribute("position",new an(a,3)),r.setAttribute("normal",new an(o,3)),r.setAttribute("uv",new an(s,2)),r}return ut(e,t),e.prototype.toJSON=function(){var t=vn.prototype.toJSON.call(this);return function(t,e){if(e.shapes=[],Array.isArray(t))for(var n=0,r=t.length;n<r;n++){var i=t[n];e.shapes.push(i.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)},e}(vn);var Ss=function(t){function e(e,n){var r;return(r=t.call(this)||this).type="ShapeGeometry","object"==typeof n&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),n=n.curveSegments),r.parameters={shapes:e,curveSegments:n},r.fromBufferGeometry(new Ms(e,n)),r.mergeVertices(),r}return ut(e,t),e.prototype.toJSON=function(){var t=yo.prototype.toJSON.call(this);return function(t,e){if(e.shapes=[],Array.isArray(t))for(var n=0,r=t.length;n<r;n++){var i=t[n];e.shapes.push(i.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)},e}(yo);var Ts=function(t){function e(e,n,r,i,a,o,s){var c;(c=t.call(this)||this).type="SphereBufferGeometry",c.parameters={radius:e,widthSegments:n,heightSegments:r,phiStart:i,phiLength:a,thetaStart:o,thetaLength:s},e=e||1,n=Math.max(3,Math.floor(n)||8),r=Math.max(2,Math.floor(r)||6),i=void 0!==i?i:0,a=void 0!==a?a:2*Math.PI,o=void 0!==o?o:0,s=void 0!==s?s:Math.PI;for(var l=Math.min(o+s,Math.PI),u=0,h=[],d=new wt,p=new wt,f=[],m=[],v=[],g=[],y=0;y<=r;y++){var x=[],_=y/r,b=0;0==y&&0==o?b=.5/n:y==r&&l==Math.PI&&(b=-.5/n);for(var w=0;w<=n;w++){var M=w/n;d.x=-e*Math.cos(i+M*a)*Math.sin(o+_*s),d.y=e*Math.cos(o+_*s),d.z=e*Math.sin(i+M*a)*Math.sin(o+_*s),m.push(d.x,d.y,d.z),p.copy(d).normalize(),v.push(p.x,p.y,p.z),g.push(M+b,1-_),x.push(u++)}h.push(x)}for(var S=0;S<r;S++)for(var T=0;T<n;T++){var E=h[S][T+1],A=h[S][T],L=h[S+1][T],R=h[S+1][T+1];(0!==S||o>0)&&f.push(E,A,R),(S!==r-1||l<Math.PI)&&f.push(A,L,R)}return c.setIndex(f),c.setAttribute("position",new an(m,3)),c.setAttribute("normal",new an(v,3)),c.setAttribute("uv",new an(g,2)),c}return ut(e,t),e}(vn),Es=function(t){function e(e,n,r,i,a,o,s){var c;return(c=t.call(this)||this).type="SphereGeometry",c.parameters={radius:e,widthSegments:n,heightSegments:r,phiStart:i,phiLength:a,thetaStart:o,thetaLength:s},c.fromBufferGeometry(new Ts(e,n,r,i,a,o,s)),c.mergeVertices(),c}return ut(e,t),e}(yo),As=function(t){function e(e,n){var r;return(r=t.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,n)||this).type="TetrahedronBufferGeometry",r.parameters={radius:e,detail:n},r}return ut(e,t),e}(Eo),Ls=function(t){function e(e,n){var r;return(r=t.call(this)||this).type="TetrahedronGeometry",r.parameters={radius:e,detail:n},r.fromBufferGeometry(new As(e,n)),r.mergeVertices(),r}return ut(e,t),e}(yo),Rs=function(t){function e(e,n){var r,i=(n=n||{}).font;if(!i||!i.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new vn||ht(r);var a=i.generateShapes(e,n.size);return n.depth=void 0!==n.height?n.height:50,void 0===n.bevelThickness&&(n.bevelThickness=10),void 0===n.bevelSize&&(n.bevelSize=8),void 0===n.bevelEnabled&&(n.bevelEnabled=!1),(r=t.call(this,a,n)||this).type="TextBufferGeometry",r}return ut(e,t),e}(cs),Cs=function(t){function e(e,n){var r;return(r=t.call(this)||this).type="TextGeometry",r.parameters={text:e,parameters:n},r.fromBufferGeometry(new Rs(e,n)),r.mergeVertices(),r}return ut(e,t),e}(yo),Ps=function(t){function e(e,n,r,i,a){var o;(o=t.call(this)||this).type="TorusBufferGeometry",o.parameters={radius:e,tube:n,radialSegments:r,tubularSegments:i,arc:a},e=e||1,n=n||.4,r=Math.floor(r)||8,i=Math.floor(i)||6,a=a||2*Math.PI;for(var s=[],c=[],l=[],u=[],h=new wt,d=new wt,p=new wt,f=0;f<=r;f++)for(var m=0;m<=i;m++){var v=m/i*a,g=f/r*Math.PI*2;d.x=(e+n*Math.cos(g))*Math.cos(v),d.y=(e+n*Math.cos(g))*Math.sin(v),d.z=n*Math.sin(g),c.push(d.x,d.y,d.z),h.x=e*Math.cos(v),h.y=e*Math.sin(v),p.subVectors(d,h).normalize(),l.push(p.x,p.y,p.z),u.push(m/i),u.push(f/r)}for(var y=1;y<=r;y++)for(var x=1;x<=i;x++){var _=(i+1)*y+x-1,b=(i+1)*(y-1)+x-1,w=(i+1)*(y-1)+x,M=(i+1)*y+x;s.push(_,b,M),s.push(b,w,M)}return o.setIndex(s),o.setAttribute("position",new an(c,3)),o.setAttribute("normal",new an(l,3)),o.setAttribute("uv",new an(u,2)),o}return ut(e,t),e}(vn),Is=function(t){function e(e,n,r,i,a){var o;return(o=t.call(this)||this).type="TorusGeometry",o.parameters={radius:e,tube:n,radialSegments:r,tubularSegments:i,arc:a},o.fromBufferGeometry(new Ps(e,n,r,i,a)),o.mergeVertices(),o}return ut(e,t),e}(yo),Ds=function(t){function e(e,n,r,i,a,o){var s;(s=t.call(this)||this).type="TorusKnotBufferGeometry",s.parameters={radius:e,tube:n,tubularSegments:r,radialSegments:i,p:a,q:o},e=e||1,n=n||.4,r=Math.floor(r)||64,i=Math.floor(i)||8,a=a||2,o=o||3;for(var c=[],l=[],u=[],h=[],d=new wt,p=new wt,f=new wt,m=new wt,v=new wt,g=new wt,y=new wt,x=0;x<=r;++x){var _=x/r*a*Math.PI*2;P(_,a,o,e,f),P(_+.01,a,o,e,m),g.subVectors(m,f),y.addVectors(m,f),v.crossVectors(g,y),y.crossVectors(v,g),v.normalize(),y.normalize();for(var b=0;b<=i;++b){var w=b/i*Math.PI*2,M=-n*Math.cos(w),S=n*Math.sin(w);d.x=f.x+(M*y.x+S*v.x),d.y=f.y+(M*y.y+S*v.y),d.z=f.z+(M*y.z+S*v.z),l.push(d.x,d.y,d.z),p.subVectors(d,f).normalize(),u.push(p.x,p.y,p.z),h.push(x/r),h.push(b/i)}}for(var T=1;T<=r;T++)for(var E=1;E<=i;E++){var A=(i+1)*(T-1)+(E-1),L=(i+1)*T+(E-1),R=(i+1)*T+E,C=(i+1)*(T-1)+E;c.push(A,L,C),c.push(L,R,C)}function P(t,e,n,r,i){var a=Math.cos(t),o=Math.sin(t),s=n/e*t,c=Math.cos(s);i.x=r*(2+c)*.5*a,i.y=r*(2+c)*o*.5,i.z=r*Math.sin(s)*.5}return s.setIndex(c),s.setAttribute("position",new an(l,3)),s.setAttribute("normal",new an(u,3)),s.setAttribute("uv",new an(h,2)),s}return ut(e,t),e}(vn),Os=function(t){function e(e,n,r,i,a,o,s){var c;return(c=t.call(this)||this).type="TorusKnotGeometry",c.parameters={radius:e,tube:n,tubularSegments:r,radialSegments:i,p:a,q:o},void 0!==s&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),c.fromBufferGeometry(new Ds(e,n,r,i,a,o)),c.mergeVertices(),c}return ut(e,t),e}(yo),Ns=function(t){function e(e,n,r,i,a){var o;(o=t.call(this)||this).type="TubeBufferGeometry",o.parameters={path:e,tubularSegments:n,radius:r,radialSegments:i,closed:a},n=n||64,r=r||1,i=i||8,a=a||!1;var s=e.computeFrenetFrames(n,a);o.tangents=s.tangents,o.normals=s.normals,o.binormals=s.binormals;var c=new wt,l=new wt,u=new pt,h=new wt,d=[],p=[],f=[],m=[];function v(t){h=e.getPointAt(t/n,h);for(var a=s.normals[t],o=s.binormals[t],u=0;u<=i;u++){var f=u/i*Math.PI*2,m=Math.sin(f),v=-Math.cos(f);l.x=v*a.x+m*o.x,l.y=v*a.y+m*o.y,l.z=v*a.z+m*o.z,l.normalize(),p.push(l.x,l.y,l.z),c.x=h.x+r*l.x,c.y=h.y+r*l.y,c.z=h.z+r*l.z,d.push(c.x,c.y,c.z)}}return function(){for(var t=0;t<n;t++)v(t);v(!1===a?n:0),function(){for(var t=0;t<=n;t++)for(var e=0;e<=i;e++)u.x=t/n,u.y=e/i,f.push(u.x,u.y)}(),function(){for(var t=1;t<=n;t++)for(var e=1;e<=i;e++){var r=(i+1)*(t-1)+(e-1),a=(i+1)*t+(e-1),o=(i+1)*t+e,s=(i+1)*(t-1)+e;m.push(r,a,s),m.push(a,o,s)}}()}(),o.setIndex(m),o.setAttribute("position",new an(d,3)),o.setAttribute("normal",new an(p,3)),o.setAttribute("uv",new an(f,2)),o}return ut(e,t),e.prototype.toJSON=function(){var t=vn.prototype.toJSON.call(this);return t.path=this.parameters.path.toJSON(),t},e}(vn),Bs=function(t){function e(e,n,r,i,a,o){var s;(s=t.call(this)||this).type="TubeGeometry",s.parameters={path:e,tubularSegments:n,radius:r,radialSegments:i,closed:a},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed.");var c=new Ns(e,n,r,i,a);return s.tangents=c.tangents,s.normals=c.normals,s.binormals=c.binormals,s.fromBufferGeometry(c),s.mergeVertices(),s}return ut(e,t),e}(yo),zs=function(t){function e(e){var n;(n=t.call(this)||this).type="WireframeGeometry";var r=[],i=[0,0],a={},o=["a","b","c"];if(e&&e.isGeometry){for(var s=e.faces,c=0,l=s.length;c<l;c++)for(var u=s[c],h=0;h<3;h++){var d=u[o[h]],p=u[o[(h+1)%3]];i[0]=Math.min(d,p),i[1]=Math.max(d,p);var f=i[0]+","+i[1];void 0===a[f]&&(a[f]={index1:i[0],index2:i[1]})}for(var m in a){var v=a[m],g=e.vertices[v.index1];r.push(g.x,g.y,g.z),g=e.vertices[v.index2],r.push(g.x,g.y,g.z)}}else if(e&&e.isBufferGeometry){var y=new wt;if(null!==e.index){var x=e.attributes.position,_=e.index,b=e.groups;0===b.length&&(b=[{start:0,count:_.count,materialIndex:0}]);for(var w=0,M=b.length;w<M;++w)for(var S=b[w],T=S.start,E=T,A=T+S.count;E<A;E+=3)for(var L=0;L<3;L++){var R=_.getX(E+L),C=_.getX(E+(L+1)%3);i[0]=Math.min(R,C),i[1]=Math.max(R,C);var P=i[0]+","+i[1];void 0===a[P]&&(a[P]={index1:i[0],index2:i[1]})}for(var I in a){var D=a[I];y.fromBufferAttribute(x,D.index1),r.push(y.x,y.y,y.z),y.fromBufferAttribute(x,D.index2),r.push(y.x,y.y,y.z)}}else for(var O=e.attributes.position,N=0,B=O.count/3;N<B;N++)for(var z=0;z<3;z++){var G=3*N+z;y.fromBufferAttribute(O,G),r.push(y.x,y.y,y.z);var F=3*N+(z+1)%3;y.fromBufferAttribute(O,F),r.push(y.x,y.y,y.z)}}return n.setAttribute("position",new an(r,3)),n}return ut(e,t),e}(vn),Gs=Object.freeze({__proto__:null,BoxGeometry:xo,BoxBufferGeometry:zn,CircleGeometry:bo,CircleBufferGeometry:_o,ConeGeometry:So,ConeBufferGeometry:To,CylinderGeometry:Mo,CylinderBufferGeometry:wo,DodecahedronGeometry:Lo,DodecahedronBufferGeometry:Ao,EdgesGeometry:Do,ExtrudeGeometry:us,ExtrudeBufferGeometry:cs,IcosahedronGeometry:ds,IcosahedronBufferGeometry:hs,LatheGeometry:fs,LatheBufferGeometry:ps,OctahedronGeometry:vs,OctahedronBufferGeometry:ms,ParametricGeometry:ys,ParametricBufferGeometry:gs,PlaneGeometry:xs,PlaneBufferGeometry:tr,PolyhedronGeometry:_s,PolyhedronBufferGeometry:Eo,RingGeometry:ws,RingBufferGeometry:bs,ShapeGeometry:Ss,ShapeBufferGeometry:Ms,SphereGeometry:Es,SphereBufferGeometry:Ts,TetrahedronGeometry:Ls,TetrahedronBufferGeometry:As,TextGeometry:Cs,TextBufferGeometry:Rs,TorusGeometry:Is,TorusBufferGeometry:Ps,TorusKnotGeometry:Os,TorusKnotBufferGeometry:Ds,TubeGeometry:Bs,TubeBufferGeometry:Ns,WireframeGeometry:zs});function Fs(t){qe.call(this),this.type="ShadowMaterial",this.color=new Ve(0),this.transparent=!0,this.setValues(t)}function Us(t){Hn.call(this,t),this.type="RawShaderMaterial"}function Hs(t){qe.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ve(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.vertexTangents=!1,this.setValues(t)}function ks(t){Hs.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new pt(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,Object.defineProperty(this,"ior",{get:function(){return(1+.4*this.reflectivity)/(1-.4*this.reflectivity)},set:function(t){this.reflectivity=st.clamp(2.5*(t-1)/(t+1),0,1)}}),this.sheen=null,this.transmission=0,this.transmissionMap=null,this.setValues(t)}function Vs(t){qe.call(this),this.type="MeshPhongMaterial",this.color=new Ve(16777215),this.specular=new Ve(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Ws(t){qe.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ve(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function js(t){qe.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function qs(t){qe.call(this),this.type="MeshLambertMaterial",this.color=new Ve(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Xs(t){qe.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ve(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Ys(t){ja.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}Fs.prototype=Object.create(qe.prototype),Fs.prototype.constructor=Fs,Fs.prototype.isShadowMaterial=!0,Fs.prototype.copy=function(t){return qe.prototype.copy.call(this,t),this.color.copy(t.color),this},Us.prototype=Object.create(Hn.prototype),Us.prototype.constructor=Us,Us.prototype.isRawShaderMaterial=!0,Hs.prototype=Object.create(qe.prototype),Hs.prototype.constructor=Hs,Hs.prototype.isMeshStandardMaterial=!0,Hs.prototype.copy=function(t){return qe.prototype.copy.call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.vertexTangents=t.vertexTangents,this},ks.prototype=Object.create(Hs.prototype),ks.prototype.constructor=ks,ks.prototype.isMeshPhysicalMaterial=!0,ks.prototype.copy=function(t){return Hs.prototype.copy.call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.reflectivity=t.reflectivity,t.sheen?this.sheen=(this.sheen||new Ve).copy(t.sheen):this.sheen=null,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this},Vs.prototype=Object.create(qe.prototype),Vs.prototype.constructor=Vs,Vs.prototype.isMeshPhongMaterial=!0,Vs.prototype.copy=function(t){return qe.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Ws.prototype=Object.create(qe.prototype),Ws.prototype.constructor=Ws,Ws.prototype.isMeshToonMaterial=!0,Ws.prototype.copy=function(t){return qe.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},js.prototype=Object.create(qe.prototype),js.prototype.constructor=js,js.prototype.isMeshNormalMaterial=!0,js.prototype.copy=function(t){return qe.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},qs.prototype=Object.create(qe.prototype),qs.prototype.constructor=qs,qs.prototype.isMeshLambertMaterial=!0,qs.prototype.copy=function(t){return qe.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Xs.prototype=Object.create(qe.prototype),Xs.prototype.constructor=Xs,Xs.prototype.isMeshMatcapMaterial=!0,Xs.prototype.copy=function(t){return qe.prototype.copy.call(this,t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Ys.prototype=Object.create(ja.prototype),Ys.prototype.constructor=Ys,Ys.prototype.isLineDashedMaterial=!0,Ys.prototype.copy=function(t){return ja.prototype.copy.call(this,t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var Zs=Object.freeze({__proto__:null,ShadowMaterial:Fs,SpriteMaterial:da,RawShaderMaterial:Us,ShaderMaterial:Hn,PointsMaterial:no,MeshPhysicalMaterial:ks,MeshStandardMaterial:Hs,MeshPhongMaterial:Vs,MeshToonMaterial:Ws,MeshNormalMaterial:js,MeshLambertMaterial:qs,MeshDepthMaterial:qi,MeshDistanceMaterial:Xi,MeshBasicMaterial:Xe,MeshMatcapMaterial:Xs,LineDashedMaterial:Ys,LineBasicMaterial:ja,Material:qe}),Js={arraySlice:function(t,e,n){return Js.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==n?n:t.length)):t.slice(e,n)},convertArray:function(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){for(var e=t.length,n=new Array(e),r=0;r!==e;++r)n[r]=r;return n.sort((function(e,n){return t[e]-t[n]})),n},sortedArray:function(t,e,n){for(var r=t.length,i=new t.constructor(r),a=0,o=0;o!==r;++a)for(var s=n[a]*e,c=0;c!==e;++c)i[o++]=t[s+c];return i},flattenJSON:function(t,e,n,r){for(var i=1,a=t[0];void 0!==a&&void 0===a[r];)a=t[i++];if(void 0!==a){var o=a[r];if(void 0!==o)if(Array.isArray(o))do{void 0!==(o=a[r])&&(e.push(a.time),n.push.apply(n,o)),a=t[i++]}while(void 0!==a);else if(void 0!==o.toArray)do{void 0!==(o=a[r])&&(e.push(a.time),o.toArray(n,n.length)),a=t[i++]}while(void 0!==a);else do{void 0!==(o=a[r])&&(e.push(a.time),n.push(o)),a=t[i++]}while(void 0!==a)}},subclip:function(t,e,n,r,i){i=i||30;var a=t.clone();a.name=e;for(var o=[],s=0;s<a.tracks.length;++s){for(var c=a.tracks[s],l=c.getValueSize(),u=[],h=[],d=0;d<c.times.length;++d){var p=c.times[d]*i;if(!(p<n||p>=r)){u.push(c.times[d]);for(var f=0;f<l;++f)h.push(c.values[d*l+f])}}0!==u.length&&(c.times=Js.convertArray(u,c.times.constructor),c.values=Js.convertArray(h,c.values.constructor),o.push(c))}a.tracks=o;for(var m=1/0,v=0;v<a.tracks.length;++v)m>a.tracks[v].times[0]&&(m=a.tracks[v].times[0]);for(var g=0;g<a.tracks.length;++g)a.tracks[g].shift(-1*m);return a.resetDuration(),a},makeClipAdditive:function(t,e,n,r){void 0===e&&(e=0),void 0===n&&(n=t),(void 0===r||r<=0)&&(r=30);for(var i=n.tracks.length,a=e/r,o=function(e){var r=n.tracks[e],i=r.ValueTypeName;if("bool"===i||"string"===i)return"continue";var o=t.tracks.find((function(t){return t.name===r.name&&t.ValueTypeName===i}));if(void 0===o)return"continue";var s=0,c=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=c/3);var l=0,u=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=u/3);var h=r.times.length-1,d=void 0;if(a<=r.times[0]){var p=s,f=c-s;d=Js.arraySlice(r.values,p,f)}else if(a>=r.times[h]){var m=h*c+s,v=m+c-s;d=Js.arraySlice(r.values,m,v)}else{var g=r.createInterpolant(),y=s,x=c-s;g.evaluate(a),d=Js.arraySlice(g.resultBuffer,y,x)}"quaternion"===i&&(new bt).fromArray(d).normalize().conjugate().toArray(d);for(var _=o.times.length,b=0;b<_;++b){var w=b*u+l;if("quaternion"===i)bt.multiplyQuaternionsFlat(o.values,w,d,0,o.values,w);else for(var M=u-2*l,S=0;S<M;++S)o.values[w+S]-=d[S]}},s=0;s<i;++s)o(s);return t.blendMode=j,t}};function Qs(t,e,n,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new e.constructor(n),this.sampleValues=e,this.valueSize=n}function Ks(t,e,n,r){Qs.call(this,t,e,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function $s(t,e,n,r){Qs.call(this,t,e,n,r)}function tc(t,e,n,r){Qs.call(this,t,e,n,r)}function ec(t,e,n,r){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Js.convertArray(e,this.TimeBufferType),this.values=Js.convertArray(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}function nc(t,e,n){ec.call(this,t,e,n)}function rc(t,e,n,r){ec.call(this,t,e,n,r)}function ic(t,e,n,r){ec.call(this,t,e,n,r)}function ac(t,e,n,r){Qs.call(this,t,e,n,r)}function oc(t,e,n,r){ec.call(this,t,e,n,r)}function sc(t,e,n,r){ec.call(this,t,e,n,r)}function cc(t,e,n,r){ec.call(this,t,e,n,r)}function lc(t,e,n,r){this.name=t,this.tracks=n,this.duration=void 0!==e?e:-1,this.blendMode=void 0!==r?r:W,this.uuid=st.generateUUID(),this.duration<0&&this.resetDuration()}function uc(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");var e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ic;case"vector":case"vector2":case"vector3":case"vector4":return cc;case"color":return rc;case"quaternion":return oc;case"bool":case"boolean":return nc;case"string":return sc}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){var n=[],r=[];Js.flattenJSON(t.keys,n,r,"value"),t.times=n,t.values=r}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}Object.assign(Qs.prototype,{evaluate:function(t){var e=this.parameterPositions,n=this._cachedIndex,r=e[n],i=e[n-1];t:{e:{var a;n:{r:if(!(t<r)){for(var o=n+2;;){if(void 0===r){if(t<i)break r;return n=e.length,this._cachedIndex=n,this.afterEnd_(n-1,t,i)}if(n===o)break;if(i=r,t<(r=e[++n]))break e}a=e.length;break n}if(t>=i)break t;var s=e[1];t<s&&(n=2,i=s);for(var c=n-2;;){if(void 0===i)return this._cachedIndex=0,this.beforeStart_(0,t,r);if(n===c)break;if(r=i,t>=(i=e[--n-1]))break e}a=n,n=0}for(;n<a;){var l=n+a>>>1;t<e[l]?a=l:n=l+1}if(r=e[n],void 0===(i=e[n-1]))return this._cachedIndex=0,this.beforeStart_(0,t,r);if(void 0===r)return n=e.length,this._cachedIndex=n,this.afterEnd_(n-1,i,t)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,t,r)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(t){for(var e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=t*r,a=0;a!==r;++a)e[a]=n[i+a];return e},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}}),Object.assign(Qs.prototype,{beforeStart_:Qs.prototype.copySampleValue_,afterEnd_:Qs.prototype.copySampleValue_}),Ks.prototype=Object.assign(Object.create(Qs.prototype),{constructor:Ks,DefaultSettings_:{endingStart:H,endingEnd:H},intervalChanged_:function(t,e,n){var r=this.parameterPositions,i=t-2,a=t+1,o=r[i],s=r[a];if(void 0===o)switch(this.getSettings_().endingStart){case k:i=t,o=2*e-n;break;case V:o=e+r[i=r.length-2]-r[i+1];break;default:i=t,o=n}if(void 0===s)switch(this.getSettings_().endingEnd){case k:a=t,s=2*n-e;break;case V:a=1,s=n+r[1]-r[0];break;default:a=t-1,s=e}var c=.5*(n-e),l=this.valueSize;this._weightPrev=c/(e-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l},interpolate_:function(t,e,n,r){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=t*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,d=this._weightNext,p=(n-e)/(r-e),f=p*p,m=f*p,v=-h*m+2*h*f-h*p,g=(1+h)*m+(-1.5-2*h)*f+(-.5+h)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,x=d*m-d*f,_=0;_!==o;++_)i[_]=v*a[l+_]+g*a[c+_]+y*a[s+_]+x*a[u+_];return i}}),$s.prototype=Object.assign(Object.create(Qs.prototype),{constructor:$s,interpolate_:function(t,e,n,r){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=t*o,c=s-o,l=(n-e)/(r-e),u=1-l,h=0;h!==o;++h)i[h]=a[c+h]*u+a[s+h]*l;return i}}),tc.prototype=Object.assign(Object.create(Qs.prototype),{constructor:tc,interpolate_:function(t){return this.copySampleValue_(t-1)}}),Object.assign(ec,{toJSON:function(t){var e,n=t.constructor;if(void 0!==n.toJSON)e=n.toJSON(t);else{e={name:t.name,times:Js.convertArray(t.times,Array),values:Js.convertArray(t.values,Array)};var r=t.getInterpolation();r!==t.DefaultInterpolation&&(e.interpolation=r)}return e.type=t.ValueTypeName,e}}),Object.assign(ec.prototype,{constructor:ec,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:F,InterpolantFactoryMethodDiscrete:function(t){return new tc(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodLinear:function(t){return new $s(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:function(t){return new Ks(this.times,this.values,this.getValueSize(),t)},setInterpolation:function(t){var e;switch(t){case G:e=this.InterpolantFactoryMethodDiscrete;break;case F:e=this.InterpolantFactoryMethodLinear;break;case U:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){var n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(n);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return G;case this.InterpolantFactoryMethodLinear:return F;case this.InterpolantFactoryMethodSmooth:return U}},getValueSize:function(){return this.values.length/this.times.length},shift:function(t){if(0!==t)for(var e=this.times,n=0,r=e.length;n!==r;++n)e[n]+=t;return this},scale:function(t){if(1!==t)for(var e=this.times,n=0,r=e.length;n!==r;++n)e[n]*=t;return this},trim:function(t,e){for(var n=this.times,r=n.length,i=0,a=r-1;i!==r&&n[i]<t;)++i;for(;-1!==a&&n[a]>e;)--a;if(++a,0!==i||a!==r){i>=a&&(i=(a=Math.max(a,1))-1);var o=this.getValueSize();this.times=Js.arraySlice(n,i,a),this.values=Js.arraySlice(this.values,i*o,a*o)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);var n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);for(var a=null,o=0;o!==i;o++){var s=n[o];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,s),t=!1;break}if(null!==a&&a>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,s,a),t=!1;break}a=s}if(void 0!==r&&Js.isTypedArray(r))for(var c=0,l=r.length;c!==l;++c){var u=r[c];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,c,u),t=!1;break}}return t},optimize:function(){for(var t=Js.arraySlice(this.times),e=Js.arraySlice(this.values),n=this.getValueSize(),r=this.getInterpolation()===U,i=t.length-1,a=1,o=1;o<i;++o){var s=!1,c=t[o];if(c!==t[o+1]&&(1!==o||c!==c[0]))if(r)s=!0;else for(var l=o*n,u=l-n,h=l+n,d=0;d!==n;++d){var p=e[l+d];if(p!==e[u+d]||p!==e[h+d]){s=!0;break}}if(s){if(o!==a){t[a]=t[o];for(var f=o*n,m=a*n,v=0;v!==n;++v)e[m+v]=e[f+v]}++a}}if(i>0){t[a]=t[i];for(var g=i*n,y=a*n,x=0;x!==n;++x)e[y+x]=e[g+x];++a}return a!==t.length?(this.times=Js.arraySlice(t,0,a),this.values=Js.arraySlice(e,0,a*n)):(this.times=t,this.values=e),this},clone:function(){var t=Js.arraySlice(this.times,0),e=Js.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}),nc.prototype=Object.assign(Object.create(ec.prototype),{constructor:nc,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:G,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),rc.prototype=Object.assign(Object.create(ec.prototype),{constructor:rc,ValueTypeName:"color"}),ic.prototype=Object.assign(Object.create(ec.prototype),{constructor:ic,ValueTypeName:"number"}),ac.prototype=Object.assign(Object.create(Qs.prototype),{constructor:ac,interpolate_:function(t,e,n,r){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-e)/(r-e),c=t*o,l=c+o;c!==l;c+=4)bt.slerpFlat(i,0,a,c-o,a,c,s);return i}}),oc.prototype=Object.assign(Object.create(ec.prototype),{constructor:oc,ValueTypeName:"quaternion",DefaultInterpolation:F,InterpolantFactoryMethodLinear:function(t){return new ac(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),sc.prototype=Object.assign(Object.create(ec.prototype),{constructor:sc,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:G,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),cc.prototype=Object.assign(Object.create(ec.prototype),{constructor:cc,ValueTypeName:"vector"}),Object.assign(lc,{parse:function(t){for(var e=[],n=t.tracks,r=1/(t.fps||1),i=0,a=n.length;i!==a;++i)e.push(uc(n[i]).scale(r));return new lc(t.name,t.duration,e,t.blendMode)},toJSON:function(t){for(var e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode},i=0,a=n.length;i!==a;++i)e.push(ec.toJSON(n[i]));return r},CreateFromMorphTargetSequence:function(t,e,n,r){for(var i=e.length,a=[],o=0;o<i;o++){var s=[],c=[];s.push((o+i-1)%i,o,(o+1)%i),c.push(0,1,0);var l=Js.getKeyframeOrder(s);s=Js.sortedArray(s,1,l),c=Js.sortedArray(c,1,l),r||0!==s[0]||(s.push(i),c.push(c[0])),a.push(new ic(".morphTargetInfluences["+e[o].name+"]",s,c).scale(1/n))}return new lc(t,-1,a)},findByName:function(t,e){var n=t;if(!Array.isArray(t)){var r=t;n=r.geometry&&r.geometry.animations||r.animations}for(var i=0;i<n.length;i++)if(n[i].name===e)return n[i];return null},CreateClipsFromMorphTargetSequences:function(t,e,n){for(var r={},i=/^([\w-]*?)([\d]+)$/,a=0,o=t.length;a<o;a++){var s=t[a],c=s.name.match(i);if(c&&c.length>1){var l=c[1],u=r[l];u||(r[l]=u=[]),u.push(s)}}var h=[];for(var d in r)h.push(lc.CreateFromMorphTargetSequence(d,r[d],e,n));return h},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var n=function(t,e,n,r,i){if(0!==n.length){var a=[],o=[];Js.flattenJSON(n,a,o,r),0!==a.length&&i.push(new t(e,a,o))}},r=[],i=t.name||"default",a=t.fps||30,o=t.blendMode,s=t.length||-1,c=t.hierarchy||[],l=0;l<c.length;l++){var u=c[l].keys;if(u&&0!==u.length)if(u[0].morphTargets){var h={},d=void 0;for(d=0;d<u.length;d++)if(u[d].morphTargets)for(var p=0;p<u[d].morphTargets.length;p++)h[u[d].morphTargets[p]]=-1;for(var f in h){for(var m=[],v=[],g=0;g!==u[d].morphTargets.length;++g){var y=u[d];m.push(y.time),v.push(y.morphTarget===f?1:0)}r.push(new ic(".morphTargetInfluence["+f+"]",m,v))}s=h.length*(a||1)}else{var x=".bones["+e[l].name+"]";n(cc,x+".position",u,"pos",r),n(oc,x+".quaternion",u,"rot",r),n(cc,x+".scale",u,"scl",r)}}return 0===r.length?null:new lc(i,s,r,o)}}),Object.assign(lc.prototype,{resetDuration:function(){for(var t=0,e=0,n=this.tracks.length;e!==n;++e){var r=this.tracks[e];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this},trim:function(){for(var t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this},validate:function(){for(var t=!0,e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t},optimize:function(){for(var t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this},clone:function(){for(var t=[],e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new lc(this.name,this.duration,t,this.blendMode)}});var hc={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};function dc(t,e,n){var r=this,i=!1,a=0,o=0,s=void 0,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(t){o++,!1===i&&void 0!==r.onStart&&r.onStart(t,a,o),i=!0},this.itemEnd=function(t){a++,void 0!==r.onProgress&&r.onProgress(t,a,o),a===o&&(i=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(t){void 0!==r.onError&&r.onError(t)},this.resolveURL=function(t){return s?s(t):t},this.setURLModifier=function(t){return s=t,this},this.addHandler=function(t,e){return c.push(t,e),this},this.removeHandler=function(t){var e=c.indexOf(t);return-1!==e&&c.splice(e,2),this},this.getHandler=function(t){for(var e=0,n=c.length;e<n;e+=2){var r=c[e],i=c[e+1];if(r.global&&(r.lastIndex=0),r.test(t))return i}return null}}var pc=new dc;function fc(t){this.manager=void 0!==t?t:pc,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}Object.assign(fc.prototype,{load:function(){},loadAsync:function(t,e){var n=this;return new Promise((function(r,i){n.load(t,r,e,i)}))},parse:function(){},setCrossOrigin:function(t){return this.crossOrigin=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setPath:function(t){return this.path=t,this},setResourcePath:function(t){return this.resourcePath=t,this},setRequestHeader:function(t){return this.requestHeader=t,this}});var mc={};function vc(t){fc.call(this,t)}function gc(t){fc.call(this,t)}function yc(t){fc.call(this,t)}function xc(t){fc.call(this,t)}function _c(t){fc.call(this,t)}function bc(t){fc.call(this,t)}function wc(t){fc.call(this,t)}function Mc(){this.type="Curve",this.arcLengthDivisions=200}function Sc(t,e,n,r,i,a,o,s){Mc.call(this),this.type="EllipseCurve",this.aX=t||0,this.aY=e||0,this.xRadius=n||1,this.yRadius=r||1,this.aStartAngle=i||0,this.aEndAngle=a||2*Math.PI,this.aClockwise=o||!1,this.aRotation=s||0}function Tc(t,e,n,r,i,a){Sc.call(this,t,e,n,n,r,i,a),this.type="ArcCurve"}function Ec(){var t=0,e=0,n=0,r=0;function i(i,a,o,s){t=i,e=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(t,e,n,r,a){i(e,n,a*(n-t),a*(r-e))},initNonuniformCatmullRom:function(t,e,n,r,a,o,s){var c=(e-t)/a-(n-t)/(a+o)+(n-e)/o,l=(n-e)/o-(r-e)/(o+s)+(r-n)/s;i(e,n,c*=o,l*=o)},calc:function(i){var a=i*i;return t+e*i+n*a+r*(a*i)}}}vc.prototype=Object.assign(Object.create(fc.prototype),{constructor:vc,load:function(t,e,n,r){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);var i=this,a=hc.get(t);if(void 0!==a)return i.manager.itemStart(t),setTimeout((function(){e&&e(a),i.manager.itemEnd(t)}),0),a;if(void 0===mc[t]){var o,s=t.match(/^data:(.*?)(;base64)?,(.*)$/);if(s){var c=s[1],l=!!s[2],u=s[3];u=decodeURIComponent(u),l&&(u=atob(u));try{var h,d=(this.responseType||"").toLowerCase();switch(d){case"arraybuffer":case"blob":for(var p=new Uint8Array(u.length),f=0;f<u.length;f++)p[f]=u.charCodeAt(f);h="blob"===d?new Blob([p.buffer],{type:c}):p.buffer;break;case"document":var m=new DOMParser;h=m.parseFromString(u,c);break;case"json":h=JSON.parse(u);break;default:h=u}setTimeout((function(){e&&e(h),i.manager.itemEnd(t)}),0)}catch(e){setTimeout((function(){r&&r(e),i.manager.itemError(t),i.manager.itemEnd(t)}),0)}}else{for(var v in mc[t]=[],mc[t].push({onLoad:e,onProgress:n,onError:r}),(o=new XMLHttpRequest).open("GET",t,!0),o.addEventListener("load",(function(e){var n=this.response,r=mc[t];if(delete mc[t],200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),hc.add(t,n);for(var a=0,o=r.length;a<o;a++){var s=r[a];s.onLoad&&s.onLoad(n)}i.manager.itemEnd(t)}else{for(var c=0,l=r.length;c<l;c++){var u=r[c];u.onError&&u.onError(e)}i.manager.itemError(t),i.manager.itemEnd(t)}}),!1),o.addEventListener("progress",(function(e){for(var n=mc[t],r=0,i=n.length;r<i;r++){var a=n[r];a.onProgress&&a.onProgress(e)}}),!1),o.addEventListener("error",(function(e){var n=mc[t];delete mc[t];for(var r=0,a=n.length;r<a;r++){var o=n[r];o.onError&&o.onError(e)}i.manager.itemError(t),i.manager.itemEnd(t)}),!1),o.addEventListener("abort",(function(e){var n=mc[t];delete mc[t];for(var r=0,a=n.length;r<a;r++){var o=n[r];o.onError&&o.onError(e)}i.manager.itemError(t),i.manager.itemEnd(t)}),!1),void 0!==this.responseType&&(o.responseType=this.responseType),void 0!==this.withCredentials&&(o.withCredentials=this.withCredentials),o.overrideMimeType&&o.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain"),this.requestHeader)o.setRequestHeader(v,this.requestHeader[v]);o.send(null)}return i.manager.itemStart(t),o}mc[t].push({onLoad:e,onProgress:n,onError:r})},setResponseType:function(t){return this.responseType=t,this},setMimeType:function(t){return this.mimeType=t,this}}),gc.prototype=Object.assign(Object.create(fc.prototype),{constructor:gc,load:function(t,e,n,r){var i=this,a=new vc(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(t,(function(n){try{e(i.parse(JSON.parse(n)))}catch(e){r?r(e):console.error(e),i.manager.itemError(t)}}),n,r)},parse:function(t){for(var e=[],n=0;n<t.length;n++){var r=lc.parse(t[n]);e.push(r)}return e}}),yc.prototype=Object.assign(Object.create(fc.prototype),{constructor:yc,load:function(t,e,n,r){var i=this,a=[],o=new uo;o.image=a;var s=new vc(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(i.withCredentials);var c=0;function l(l){s.load(t[l],(function(t){var n=i.parse(t,!0);a[l]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},6===(c+=1)&&(1===n.mipmapCount&&(o.minFilter=m),o.format=n.format,o.needsUpdate=!0,e&&e(o))}),n,r)}if(Array.isArray(t))for(var u=0,h=t.length;u<h;++u)l(u);else s.load(t,(function(t){var n=i.parse(t,!0);if(n.isCubemap)for(var r=n.mipmaps.length/n.mipmapCount,s=0;s<r;s++){a[s]={mipmaps:[]};for(var c=0;c<n.mipmapCount;c++)a[s].mipmaps.push(n.mipmaps[s*n.mipmapCount+c]),a[s].format=n.format,a[s].width=n.width,a[s].height=n.height}else o.image.width=n.width,o.image.height=n.height,o.mipmaps=n.mipmaps;1===n.mipmapCount&&(o.minFilter=m),o.format=n.format,o.needsUpdate=!0,e&&e(o)}),n,r);return o}}),xc.prototype=Object.assign(Object.create(fc.prototype),{constructor:xc,load:function(t,e,n,r){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);var i=this,a=hc.get(t);if(void 0!==a)return i.manager.itemStart(t),setTimeout((function(){e&&e(a),i.manager.itemEnd(t)}),0),a;var o=document.createElementNS("http://www.w3.org/1999/xhtml","img");function s(){o.removeEventListener("load",s,!1),o.removeEventListener("error",c,!1),hc.add(t,this),e&&e(this),i.manager.itemEnd(t)}function c(e){o.removeEventListener("load",s,!1),o.removeEventListener("error",c,!1),r&&r(e),i.manager.itemError(t),i.manager.itemEnd(t)}return o.addEventListener("load",s,!1),o.addEventListener("error",c,!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),i.manager.itemStart(t),o.src=t,o}}),_c.prototype=Object.assign(Object.create(fc.prototype),{constructor:_c,load:function(t,e,n,r){var i=new qn,a=new xc(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);var o=0;function s(n){a.load(t[n],(function(t){i.images[n]=t,6===++o&&(i.needsUpdate=!0,e&&e(i))}),void 0,r)}for(var c=0;c<t.length;++c)s(c);return i}}),bc.prototype=Object.assign(Object.create(fc.prototype),{constructor:bc,load:function(t,e,n,r){var i=this,a=new Yn,o=new vc(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(i.withCredentials),o.load(t,(function(t){var n=i.parse(t);n&&(void 0!==n.image?a.image=n.image:void 0!==n.data&&(a.image.width=n.width,a.image.height=n.height,a.image.data=n.data),a.wrapS=void 0!==n.wrapS?n.wrapS:u,a.wrapT=void 0!==n.wrapT?n.wrapT:u,a.magFilter=void 0!==n.magFilter?n.magFilter:m,a.minFilter=void 0!==n.minFilter?n.minFilter:m,a.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.format&&(a.format=n.format),void 0!==n.type&&(a.type=n.type),void 0!==n.mipmaps&&(a.mipmaps=n.mipmaps,a.minFilter=g),1===n.mipmapCount&&(a.minFilter=m),a.needsUpdate=!0,e&&e(a,n))}),n,r),a}}),wc.prototype=Object.assign(Object.create(fc.prototype),{constructor:wc,load:function(t,e,n,r){var i=new gt,a=new xc(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,(function(n){i.image=n;var r=t.search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/);i.format=r?S:T,i.needsUpdate=!0,void 0!==e&&e(i)}),n,r),i}}),Object.assign(Mc.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){var n=this.getUtoTmapping(t);return this.getPoint(n,e)},getPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPoint(n/t));return e},getSpacedPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,n=[],r=this.getPoint(0),i=0;n.push(0);for(var a=1;a<=t;a++)i+=(e=this.getPoint(a/t)).distanceTo(r),n.push(i),r=e;return this.cacheArcLengths=n,n},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var n,r=this.getLengths(),i=0,a=r.length;n=e||t*r[a-1];for(var o,s=0,c=a-1;s<=c;)if((o=r[i=Math.floor(s+(c-s)/2)]-n)<0)s=i+1;else{if(!(o>0)){c=i;break}c=i-1}if(r[i=c]===n)return i/(a-1);var l=r[i];return(i+(n-l)/(r[i+1]-l))/(a-1)},getTangent:function(t,e){var n=1e-4,r=t-n,i=t+n;r<0&&(r=0),i>1&&(i=1);var a=this.getPoint(r),o=this.getPoint(i),s=e||(a.isVector2?new pt:new wt);return s.copy(o).sub(a).normalize(),s},getTangentAt:function(t,e){var n=this.getUtoTmapping(t);return this.getTangent(n,e)},computeFrenetFrames:function(t,e){for(var n=new wt,r=[],i=[],a=[],o=new wt,s=new Jt,c=0;c<=t;c++){var l=c/t;r[c]=this.getTangentAt(l,new wt),r[c].normalize()}i[0]=new wt,a[0]=new wt;var u=Number.MAX_VALUE,h=Math.abs(r[0].x),d=Math.abs(r[0].y),p=Math.abs(r[0].z);h<=u&&(u=h,n.set(1,0,0)),d<=u&&(u=d,n.set(0,1,0)),p<=u&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(var f=1;f<=t;f++){if(i[f]=i[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(r[f-1],r[f]),o.length()>Number.EPSILON){o.normalize();var m=Math.acos(st.clamp(r[f-1].dot(r[f]),-1,1));i[f].applyMatrix4(s.makeRotationAxis(o,m))}a[f].crossVectors(r[f],i[f])}if(!0===e){var v=Math.acos(st.clamp(i[0].dot(i[t]),-1,1));v/=t,r[0].dot(o.crossVectors(i[0],i[t]))>0&&(v=-v);for(var g=1;g<=t;g++)i[g].applyMatrix4(s.makeRotationAxis(r[g],v*g)),a[g].crossVectors(r[g],i[g])}return{tangents:r,normals:i,binormals:a}},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this},toJSON:function(){var t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t},fromJSON:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}),Sc.prototype=Object.create(Mc.prototype),Sc.prototype.constructor=Sc,Sc.prototype.isEllipseCurve=!0,Sc.prototype.getPoint=function(t,e){for(var n=e||new pt,r=2*Math.PI,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<Number.EPSILON;i<0;)i+=r;for(;i>r;)i-=r;i<Number.EPSILON&&(i=a?0:r),!0!==this.aClockwise||a||(i===r?i=-r:i-=r);var o=this.aStartAngle+t*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(0!==this.aRotation){var l=Math.cos(this.aRotation),u=Math.sin(this.aRotation),h=s-this.aX,d=c-this.aY;s=h*l-d*u+this.aX,c=h*u+d*l+this.aY}return n.set(s,c)},Sc.prototype.copy=function(t){return Mc.prototype.copy.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this},Sc.prototype.toJSON=function(){var t=Mc.prototype.toJSON.call(this);return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t},Sc.prototype.fromJSON=function(t){return Mc.prototype.fromJSON.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this},Tc.prototype=Object.create(Sc.prototype),Tc.prototype.constructor=Tc,Tc.prototype.isArcCurve=!0;var Ac=new wt,Lc=new Ec,Rc=new Ec,Cc=new Ec;function Pc(t,e,n,r){Mc.call(this),this.type="CatmullRomCurve3",this.points=t||[],this.closed=e||!1,this.curveType=n||"centripetal",this.tension=void 0!==r?r:.5}function Ic(t,e,n,r,i){var a=.5*(r-e),o=.5*(i-n),s=t*t;return(2*n-2*r+a+o)*(t*s)+(-3*n+3*r-2*a-o)*s+a*t+n}function Dc(t,e,n,r){return function(t,e){var n=1-t;return n*n*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,n)+function(t,e){return t*t*e}(t,r)}function Oc(t,e,n,r,i){return function(t,e){var n=1-t;return n*n*n*e}(t,e)+function(t,e){var n=1-t;return 3*n*n*t*e}(t,n)+function(t,e){return 3*(1-t)*t*t*e}(t,r)+function(t,e){return t*t*t*e}(t,i)}function Nc(t,e,n,r){Mc.call(this),this.type="CubicBezierCurve",this.v0=t||new pt,this.v1=e||new pt,this.v2=n||new pt,this.v3=r||new pt}function Bc(t,e,n,r){Mc.call(this),this.type="CubicBezierCurve3",this.v0=t||new wt,this.v1=e||new wt,this.v2=n||new wt,this.v3=r||new wt}function zc(t,e){Mc.call(this),this.type="LineCurve",this.v1=t||new pt,this.v2=e||new pt}function Gc(t,e){Mc.call(this),this.type="LineCurve3",this.v1=t||new wt,this.v2=e||new wt}function Fc(t,e,n){Mc.call(this),this.type="QuadraticBezierCurve",this.v0=t||new pt,this.v1=e||new pt,this.v2=n||new pt}function Uc(t,e,n){Mc.call(this),this.type="QuadraticBezierCurve3",this.v0=t||new wt,this.v1=e||new wt,this.v2=n||new wt}function Hc(t){Mc.call(this),this.type="SplineCurve",this.points=t||[]}Pc.prototype=Object.create(Mc.prototype),Pc.prototype.constructor=Pc,Pc.prototype.isCatmullRomCurve3=!0,Pc.prototype.getPoint=function(t,e){var n,r,i=e||new wt,a=this.points,o=a.length,s=(o-(this.closed?0:1))*t,c=Math.floor(s),l=s-c;this.closed?c+=c>0?0:(Math.floor(Math.abs(c)/o)+1)*o:0===l&&c===o-1&&(c=o-2,l=1),this.closed||c>0?n=a[(c-1)%o]:(Ac.subVectors(a[0],a[1]).add(a[0]),n=Ac);var u=a[c%o],h=a[(c+1)%o];if(this.closed||c+2<o?r=a[(c+2)%o]:(Ac.subVectors(a[o-1],a[o-2]).add(a[o-1]),r=Ac),"centripetal"===this.curveType||"chordal"===this.curveType){var d="chordal"===this.curveType?.5:.25,p=Math.pow(n.distanceToSquared(u),d),f=Math.pow(u.distanceToSquared(h),d),m=Math.pow(h.distanceToSquared(r),d);f<1e-4&&(f=1),p<1e-4&&(p=f),m<1e-4&&(m=f),Lc.initNonuniformCatmullRom(n.x,u.x,h.x,r.x,p,f,m),Rc.initNonuniformCatmullRom(n.y,u.y,h.y,r.y,p,f,m),Cc.initNonuniformCatmullRom(n.z,u.z,h.z,r.z,p,f,m)}else"catmullrom"===this.curveType&&(Lc.initCatmullRom(n.x,u.x,h.x,r.x,this.tension),Rc.initCatmullRom(n.y,u.y,h.y,r.y,this.tension),Cc.initCatmullRom(n.z,u.z,h.z,r.z,this.tension));return i.set(Lc.calc(l),Rc.calc(l),Cc.calc(l)),i},Pc.prototype.copy=function(t){Mc.prototype.copy.call(this,t),this.points=[];for(var e=0,n=t.points.length;e<n;e++){var r=t.points[e];this.points.push(r.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this},Pc.prototype.toJSON=function(){var t=Mc.prototype.toJSON.call(this);t.points=[];for(var e=0,n=this.points.length;e<n;e++){var r=this.points[e];t.points.push(r.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t},Pc.prototype.fromJSON=function(t){Mc.prototype.fromJSON.call(this,t),this.points=[];for(var e=0,n=t.points.length;e<n;e++){var r=t.points[e];this.points.push((new wt).fromArray(r))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this},Nc.prototype=Object.create(Mc.prototype),Nc.prototype.constructor=Nc,Nc.prototype.isCubicBezierCurve=!0,Nc.prototype.getPoint=function(t,e){var n=e||new pt,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(Oc(t,r.x,i.x,a.x,o.x),Oc(t,r.y,i.y,a.y,o.y)),n},Nc.prototype.copy=function(t){return Mc.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},Nc.prototype.toJSON=function(){var t=Mc.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t},Nc.prototype.fromJSON=function(t){return Mc.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this},Bc.prototype=Object.create(Mc.prototype),Bc.prototype.constructor=Bc,Bc.prototype.isCubicBezierCurve3=!0,Bc.prototype.getPoint=function(t,e){var n=e||new wt,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(Oc(t,r.x,i.x,a.x,o.x),Oc(t,r.y,i.y,a.y,o.y),Oc(t,r.z,i.z,a.z,o.z)),n},Bc.prototype.copy=function(t){return Mc.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},Bc.prototype.toJSON=function(){var t=Mc.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t},Bc.prototype.fromJSON=function(t){return Mc.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this},zc.prototype=Object.create(Mc.prototype),zc.prototype.constructor=zc,zc.prototype.isLineCurve=!0,zc.prototype.getPoint=function(t,e){var n=e||new pt;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n},zc.prototype.getPointAt=function(t,e){return this.getPoint(t,e)},zc.prototype.getTangent=function(t,e){var n=e||new pt;return n.copy(this.v2).sub(this.v1).normalize(),n},zc.prototype.copy=function(t){return Mc.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},zc.prototype.toJSON=function(){var t=Mc.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},zc.prototype.fromJSON=function(t){return Mc.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},Gc.prototype=Object.create(Mc.prototype),Gc.prototype.constructor=Gc,Gc.prototype.isLineCurve3=!0,Gc.prototype.getPoint=function(t,e){var n=e||new wt;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n},Gc.prototype.getPointAt=function(t,e){return this.getPoint(t,e)},Gc.prototype.copy=function(t){return Mc.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},Gc.prototype.toJSON=function(){var t=Mc.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},Gc.prototype.fromJSON=function(t){return Mc.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},Fc.prototype=Object.create(Mc.prototype),Fc.prototype.constructor=Fc,Fc.prototype.isQuadraticBezierCurve=!0,Fc.prototype.getPoint=function(t,e){var n=e||new pt,r=this.v0,i=this.v1,a=this.v2;return n.set(Dc(t,r.x,i.x,a.x),Dc(t,r.y,i.y,a.y)),n},Fc.prototype.copy=function(t){return Mc.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this},Fc.prototype.toJSON=function(){var t=Mc.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},Fc.prototype.fromJSON=function(t){return Mc.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},Uc.prototype=Object.create(Mc.prototype),Uc.prototype.constructor=Uc,Uc.prototype.isQuadraticBezierCurve3=!0,Uc.prototype.getPoint=function(t,e){var n=e||new wt,r=this.v0,i=this.v1,a=this.v2;return n.set(Dc(t,r.x,i.x,a.x),Dc(t,r.y,i.y,a.y),Dc(t,r.z,i.z,a.z)),n},Uc.prototype.copy=function(t){return Mc.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this},Uc.prototype.toJSON=function(){var t=Mc.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},Uc.prototype.fromJSON=function(t){return Mc.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},Hc.prototype=Object.create(Mc.prototype),Hc.prototype.constructor=Hc,Hc.prototype.isSplineCurve=!0,Hc.prototype.getPoint=function(t,e){var n=e||new pt,r=this.points,i=(r.length-1)*t,a=Math.floor(i),o=i-a,s=r[0===a?a:a-1],c=r[a],l=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Ic(o,s.x,c.x,l.x,u.x),Ic(o,s.y,c.y,l.y,u.y)),n},Hc.prototype.copy=function(t){Mc.prototype.copy.call(this,t),this.points=[];for(var e=0,n=t.points.length;e<n;e++){var r=t.points[e];this.points.push(r.clone())}return this},Hc.prototype.toJSON=function(){var t=Mc.prototype.toJSON.call(this);t.points=[];for(var e=0,n=this.points.length;e<n;e++){var r=this.points[e];t.points.push(r.toArray())}return t},Hc.prototype.fromJSON=function(t){Mc.prototype.fromJSON.call(this,t),this.points=[];for(var e=0,n=t.points.length;e<n;e++){var r=t.points[e];this.points.push((new pt).fromArray(r))}return this};var kc=Object.freeze({__proto__:null,ArcCurve:Tc,CatmullRomCurve3:Pc,CubicBezierCurve:Nc,CubicBezierCurve3:Bc,EllipseCurve:Sc,LineCurve:zc,LineCurve3:Gc,QuadraticBezierCurve:Fc,QuadraticBezierCurve3:Uc,SplineCurve:Hc});function Vc(){Mc.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function Wc(t){Vc.call(this),this.type="Path",this.currentPoint=new pt,t&&this.setFromPoints(t)}function jc(t){Wc.call(this,t),this.uuid=st.generateUUID(),this.type="Shape",this.holes=[]}function qc(t,e){be.call(this),this.type="Light",this.color=new Ve(t),this.intensity=void 0!==e?e:1}function Xc(t,e,n){qc.call(this,t,n),this.type="HemisphereLight",this.position.copy(be.DefaultUp),this.updateMatrix(),this.groundColor=new Ve(e)}function Yc(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new pt(512,512),this.map=null,this.mapPass=null,this.matrix=new Jt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Qn,this._frameExtents=new pt(1,1),this._viewportCount=1,this._viewports=[new yt(0,0,1,1)]}function Zc(){Yc.call(this,new Vn(50,1,.5,500)),this.focus=1}function Jc(t,e,n,r,i,a){qc.call(this,t,e),this.type="SpotLight",this.position.copy(be.DefaultUp),this.updateMatrix(),this.target=new be,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==n?n:0,this.angle=void 0!==r?r:Math.PI/3,this.penumbra=void 0!==i?i:0,this.decay=void 0!==a?a:1,this.shadow=new Zc}function Qc(){Yc.call(this,new Vn(90,1,.5,500)),this._frameExtents=new pt(4,2),this._viewportCount=6,this._viewports=[new yt(2,1,1,1),new yt(0,1,1,1),new yt(3,1,1,1),new yt(1,1,1,1),new yt(3,0,1,1),new yt(1,0,1,1)],this._cubeDirections=[new wt(1,0,0),new wt(-1,0,0),new wt(0,0,1),new wt(0,0,-1),new wt(0,1,0),new wt(0,-1,0)],this._cubeUps=[new wt(0,1,0),new wt(0,1,0),new wt(0,1,0),new wt(0,1,0),new wt(0,0,1),new wt(0,0,-1)]}function Kc(t,e,n,r){qc.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==n?n:0,this.decay=void 0!==r?r:1,this.shadow=new Qc}function $c(t,e,n,r,i,a){kn.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=void 0!==t?t:-1,this.right=void 0!==e?e:1,this.top=void 0!==n?n:1,this.bottom=void 0!==r?r:-1,this.near=void 0!==i?i:.1,this.far=void 0!==a?a:2e3,this.updateProjectionMatrix()}function tl(){Yc.call(this,new $c(-5,5,5,-5,.5,500))}function el(t,e){qc.call(this,t,e),this.type="DirectionalLight",this.position.copy(be.DefaultUp),this.updateMatrix(),this.target=new be,this.shadow=new tl}function nl(t,e){qc.call(this,t,e),this.type="AmbientLight"}function rl(t,e,n,r){qc.call(this,t,e),this.type="RectAreaLight",this.width=void 0!==n?n:10,this.height=void 0!==r?r:10}Vc.prototype=Object.assign(Object.create(Mc.prototype),{constructor:Vc,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new zc(e,t))},getPoint:function(t){for(var e=t*this.getLength(),n=this.getCurveLengths(),r=0;r<n.length;){if(n[r]>=e){var i=n[r]-e,a=this.curves[r],o=a.getLength(),s=0===o?0:1-i/o;return a.getPointAt(s)}r++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,n=0,r=this.curves.length;n<r;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e},getPoints:function(t){t=t||12;for(var e,n=[],r=0,i=this.curves;r<i.length;r++)for(var a=i[r],o=a&&a.isEllipseCurve?2*t:a&&(a.isLineCurve||a.isLineCurve3)?1:a&&a.isSplineCurve?t*a.points.length:t,s=a.getPoints(o),c=0;c<s.length;c++){var l=s[c];e&&e.equals(l)||(n.push(l),e=l)}return this.autoClose&&n.length>1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(t){Mc.prototype.copy.call(this,t),this.curves=[];for(var e=0,n=t.curves.length;e<n;e++){var r=t.curves[e];this.curves.push(r.clone())}return this.autoClose=t.autoClose,this},toJSON:function(){var t=Mc.prototype.toJSON.call(this);t.autoClose=this.autoClose,t.curves=[];for(var e=0,n=this.curves.length;e<n;e++){var r=this.curves[e];t.curves.push(r.toJSON())}return t},fromJSON:function(t){Mc.prototype.fromJSON.call(this,t),this.autoClose=t.autoClose,this.curves=[];for(var e=0,n=t.curves.length;e<n;e++){var r=t.curves[e];this.curves.push((new kc[r.type]).fromJSON(r))}return this}}),Wc.prototype=Object.assign(Object.create(Vc.prototype),{constructor:Wc,setFromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this},moveTo:function(t,e){return this.currentPoint.set(t,e),this},lineTo:function(t,e){var n=new zc(this.currentPoint.clone(),new pt(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this},quadraticCurveTo:function(t,e,n,r){var i=new Fc(this.currentPoint.clone(),new pt(t,e),new pt(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this},bezierCurveTo:function(t,e,n,r,i,a){var o=new Nc(this.currentPoint.clone(),new pt(t,e),new pt(n,r),new pt(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this},splineThru:function(t){var e=new Hc([this.currentPoint.clone()].concat(t));return this.curves.push(e),this.currentPoint.copy(t[t.length-1]),this},arc:function(t,e,n,r,i,a){var o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(t+o,e+s,n,r,i,a),this},absarc:function(t,e,n,r,i,a){return this.absellipse(t,e,n,n,r,i,a),this},ellipse:function(t,e,n,r,i,a,o,s){var c=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(t+c,e+l,n,r,i,a,o,s),this},absellipse:function(t,e,n,r,i,a,o,s){var c=new Sc(t,e,n,r,i,a,o,s);if(this.curves.length>0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var u=c.getPoint(1);return this.currentPoint.copy(u),this},copy:function(t){return Vc.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){var t=Vc.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return Vc.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}}),jc.prototype=Object.assign(Object.create(Wc.prototype),{constructor:jc,getPointsHoles:function(t){for(var e=[],n=0,r=this.holes.length;n<r;n++)e[n]=this.holes[n].getPoints(t);return e},extractPoints:function(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}},copy:function(t){Wc.prototype.copy.call(this,t),this.holes=[];for(var e=0,n=t.holes.length;e<n;e++){var r=t.holes[e];this.holes.push(r.clone())}return this},toJSON:function(){var t=Wc.prototype.toJSON.call(this);t.uuid=this.uuid,t.holes=[];for(var e=0,n=this.holes.length;e<n;e++){var r=this.holes[e];t.holes.push(r.toJSON())}return t},fromJSON:function(t){Wc.prototype.fromJSON.call(this,t),this.uuid=t.uuid,this.holes=[];for(var e=0,n=t.holes.length;e<n;e++){var r=t.holes[e];this.holes.push((new Wc).fromJSON(r))}return this}}),qc.prototype=Object.assign(Object.create(be.prototype),{constructor:qc,isLight:!0,copy:function(t){return be.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=be.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),Xc.prototype=Object.assign(Object.create(qc.prototype),{constructor:Xc,isHemisphereLight:!0,copy:function(t){return qc.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Yc.prototype,{_projScreenMatrix:new Jt,_lightPositionWorld:new wt,_lookTarget:new wt,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(t){var e=this.camera,n=this.matrix,r=this._projScreenMatrix,i=this._lookTarget,a=this._lightPositionWorld;a.setFromMatrixPosition(t.matrixWorld),e.position.copy(a),i.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(i),e.updateMatrixWorld(),r.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(r),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(e.projectionMatrix),n.multiply(e.matrixWorldInverse)},getViewport:function(t){return this._viewports[t]},getFrameExtents:function(){return this._frameExtents},copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t={};return 0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),Zc.prototype=Object.assign(Object.create(Yc.prototype),{constructor:Zc,isSpotLightShadow:!0,updateMatrices:function(t){var e=this.camera,n=2*st.RAD2DEG*t.angle*this.focus,r=this.mapSize.width/this.mapSize.height,i=t.distance||e.far;n===e.fov&&r===e.aspect&&i===e.far||(e.fov=n,e.aspect=r,e.far=i,e.updateProjectionMatrix()),Yc.prototype.updateMatrices.call(this,t)}}),Jc.prototype=Object.assign(Object.create(qc.prototype),{constructor:Jc,isSpotLight:!0,copy:function(t){return qc.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Qc.prototype=Object.assign(Object.create(Yc.prototype),{constructor:Qc,isPointLightShadow:!0,updateMatrices:function(t,e){void 0===e&&(e=0);var n=this.camera,r=this.matrix,i=this._lightPositionWorld,a=this._lookTarget,o=this._projScreenMatrix;i.setFromMatrixPosition(t.matrixWorld),n.position.copy(i),a.copy(n.position),a.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(a),n.updateMatrixWorld(),r.makeTranslation(-i.x,-i.y,-i.z),o.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(o)}}),Kc.prototype=Object.assign(Object.create(qc.prototype),{constructor:Kc,isPointLight:!0,copy:function(t){return qc.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),$c.prototype=Object.assign(Object.create(kn.prototype),{constructor:$c,isOrthographicCamera:!0,copy:function(t,e){return kn.prototype.copy.call(this,t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this},setViewOffset:function(t,e,n,r,i,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-t,a=n+t,o=r+e,s=r-e;if(null!==this.view&&this.view.enabled){var c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a=(i+=c*this.view.offsetX)+c*this.view.width,s=(o-=l*this.view.offsetY)-l*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(t){var e=be.prototype.toJSON.call(this,t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}),tl.prototype=Object.assign(Object.create(Yc.prototype),{constructor:tl,isDirectionalLightShadow:!0,updateMatrices:function(t){Yc.prototype.updateMatrices.call(this,t)}}),el.prototype=Object.assign(Object.create(qc.prototype),{constructor:el,isDirectionalLight:!0,copy:function(t){return qc.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),nl.prototype=Object.assign(Object.create(qc.prototype),{constructor:nl,isAmbientLight:!0}),rl.prototype=Object.assign(Object.create(qc.prototype),{constructor:rl,isRectAreaLight:!0,copy:function(t){return qc.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=qc.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var il=function(){function t(){Object.defineProperty(this,"isSphericalHarmonics3",{value:!0}),this.coefficients=[];for(var t=0;t<9;t++)this.coefficients.push(new wt)}var e=t.prototype;return e.set=function(t){for(var e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this},e.zero=function(){for(var t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this},e.getAt=function(t,e){var n=t.x,r=t.y,i=t.z,a=this.coefficients;return e.copy(a[0]).multiplyScalar(.282095),e.addScaledVector(a[1],.488603*r),e.addScaledVector(a[2],.488603*i),e.addScaledVector(a[3],.488603*n),e.addScaledVector(a[4],n*r*1.092548),e.addScaledVector(a[5],r*i*1.092548),e.addScaledVector(a[6],.315392*(3*i*i-1)),e.addScaledVector(a[7],n*i*1.092548),e.addScaledVector(a[8],.546274*(n*n-r*r)),e},e.getIrradianceAt=function(t,e){var n=t.x,r=t.y,i=t.z,a=this.coefficients;return e.copy(a[0]).multiplyScalar(.886227),e.addScaledVector(a[1],1.023328*r),e.addScaledVector(a[2],1.023328*i),e.addScaledVector(a[3],1.023328*n),e.addScaledVector(a[4],.858086*n*r),e.addScaledVector(a[5],.858086*r*i),e.addScaledVector(a[6],.743125*i*i-.247708),e.addScaledVector(a[7],.858086*n*i),e.addScaledVector(a[8],.429043*(n*n-r*r)),e},e.add=function(t){for(var e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this},e.addScaledSH=function(t,e){for(var n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this},e.scale=function(t){for(var e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this},e.lerp=function(t,e){for(var n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this},e.equals=function(t){for(var e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0},e.copy=function(t){return this.set(t.coefficients)},e.clone=function(){return(new this.constructor).copy(this)},e.fromArray=function(t,e){void 0===e&&(e=0);for(var n=this.coefficients,r=0;r<9;r++)n[r].fromArray(t,e+3*r);return this},e.toArray=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);for(var n=this.coefficients,r=0;r<9;r++)n[r].toArray(t,e+3*r);return t},t.getBasisAt=function(t,e){var n=t.x,r=t.y,i=t.z;e[0]=.282095,e[1]=.488603*r,e[2]=.488603*i,e[3]=.488603*n,e[4]=1.092548*n*r,e[5]=1.092548*r*i,e[6]=.315392*(3*i*i-1),e[7]=1.092548*n*i,e[8]=.546274*(n*n-r*r)},t}();function al(t,e){qc.call(this,void 0,e),this.type="LightProbe",this.sh=void 0!==t?t:new il}function ol(t){fc.call(this,t),this.textures={}}al.prototype=Object.assign(Object.create(qc.prototype),{constructor:al,isLightProbe:!0,copy:function(t){return qc.prototype.copy.call(this,t),this.sh.copy(t.sh),this},fromJSON:function(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this},toJSON:function(t){var e=qc.prototype.toJSON.call(this,t);return e.object.sh=this.sh.toArray(),e}}),ol.prototype=Object.assign(Object.create(fc.prototype),{constructor:ol,load:function(t,e,n,r){var i=this,a=new vc(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(t,(function(n){try{e(i.parse(JSON.parse(n)))}catch(e){r?r(e):console.error(e),i.manager.itemError(t)}}),n,r)},parse:function(t){var e=this.textures;function n(t){return void 0===e[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),e[t]}var r=new Zs[t.type];if(void 0!==t.uuid&&(r.uuid=t.uuid),void 0!==t.name&&(r.name=t.name),void 0!==t.color&&void 0!==r.color&&r.color.setHex(t.color),void 0!==t.roughness&&(r.roughness=t.roughness),void 0!==t.metalness&&(r.metalness=t.metalness),void 0!==t.sheen&&(r.sheen=(new Ve).setHex(t.sheen)),void 0!==t.emissive&&void 0!==r.emissive&&r.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==r.specular&&r.specular.setHex(t.specular),void 0!==t.shininess&&(r.shininess=t.shininess),void 0!==t.clearcoat&&(r.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(r.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.fog&&(r.fog=t.fog),void 0!==t.flatShading&&(r.flatShading=t.flatShading),void 0!==t.blending&&(r.blending=t.blending),void 0!==t.combine&&(r.combine=t.combine),void 0!==t.side&&(r.side=t.side),void 0!==t.opacity&&(r.opacity=t.opacity),void 0!==t.transparent&&(r.transparent=t.transparent),void 0!==t.alphaTest&&(r.alphaTest=t.alphaTest),void 0!==t.depthTest&&(r.depthTest=t.depthTest),void 0!==t.depthWrite&&(r.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(r.colorWrite=t.colorWrite),void 0!==t.stencilWrite&&(r.stencilWrite=t.stencilWrite),void 0!==t.stencilWriteMask&&(r.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(r.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(r.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(r.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(r.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(r.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(r.stencilZPass=t.stencilZPass),void 0!==t.wireframe&&(r.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(r.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(r.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(r.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(r.rotation=t.rotation),1!==t.linewidth&&(r.linewidth=t.linewidth),void 0!==t.dashSize&&(r.dashSize=t.dashSize),void 0!==t.gapSize&&(r.gapSize=t.gapSize),void 0!==t.scale&&(r.scale=t.scale),void 0!==t.polygonOffset&&(r.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(r.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(r.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.skinning&&(r.skinning=t.skinning),void 0!==t.morphTargets&&(r.morphTargets=t.morphTargets),void 0!==t.morphNormals&&(r.morphNormals=t.morphNormals),void 0!==t.dithering&&(r.dithering=t.dithering),void 0!==t.vertexTangents&&(r.vertexTangents=t.vertexTangents),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.toneMapped&&(r.toneMapped=t.toneMapped),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?r.vertexColors=t.vertexColors>0:r.vertexColors=t.vertexColors),void 0!==t.uniforms)for(var i in t.uniforms){var a=t.uniforms[i];switch(r.uniforms[i]={},a.type){case"t":r.uniforms[i].value=n(a.value);break;case"c":r.uniforms[i].value=(new Ve).setHex(a.value);break;case"v2":r.uniforms[i].value=(new pt).fromArray(a.value);break;case"v3":r.uniforms[i].value=(new wt).fromArray(a.value);break;case"v4":r.uniforms[i].value=(new yt).fromArray(a.value);break;case"m3":r.uniforms[i].value=(new ft).fromArray(a.value);break;case"m4":r.uniforms[i].value=(new Jt).fromArray(a.value);break;default:r.uniforms[i].value=a.value}}if(void 0!==t.defines&&(r.defines=t.defines),void 0!==t.vertexShader&&(r.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(r.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(var o in t.extensions)r.extensions[o]=t.extensions[o];if(void 0!==t.shading&&(r.flatShading=1===t.shading),void 0!==t.size&&(r.size=t.size),void 0!==t.sizeAttenuation&&(r.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(r.map=n(t.map)),void 0!==t.matcap&&(r.matcap=n(t.matcap)),void 0!==t.alphaMap&&(r.alphaMap=n(t.alphaMap)),void 0!==t.bumpMap&&(r.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(r.bumpScale=t.bumpScale),void 0!==t.normalMap&&(r.normalMap=n(t.normalMap)),void 0!==t.normalMapType&&(r.normalMapType=t.normalMapType),void 0!==t.normalScale){var s=t.normalScale;!1===Array.isArray(s)&&(s=[s,s]),r.normalScale=(new pt).fromArray(s)}return void 0!==t.displacementMap&&(r.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(r.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(r.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(r.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(r.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(r.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(r.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(r.specularMap=n(t.specularMap)),void 0!==t.envMap&&(r.envMap=n(t.envMap)),void 0!==t.envMapIntensity&&(r.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(r.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(r.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(r.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(r.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(r.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(r.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(r.gradientMap=n(t.gradientMap)),void 0!==t.clearcoatMap&&(r.clearcoatMap=n(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(r.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(r.clearcoatNormalMap=n(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(r.clearcoatNormalScale=(new pt).fromArray(t.clearcoatNormalScale)),void 0!==t.transmission&&(r.transmission=t.transmission),void 0!==t.transmissionMap&&(r.transmissionMap=n(t.transmissionMap)),r},setTextures:function(t){return this.textures=t,this}});var sl={decodeText:function(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);for(var e="",n=0,r=t.length;n<r;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch(t){return e}},extractUrlBase:function(t){var e=t.lastIndexOf("/");return-1===e?"./":t.substr(0,e+1)}};function cl(){vn.call(this),this.type="InstancedBufferGeometry",this.instanceCount=1/0}function ll(t,e,n,r){"number"==typeof n&&(r=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),Je.call(this,t,e,n),this.meshPerAttribute=r||1}function ul(t){fc.call(this,t)}cl.prototype=Object.assign(Object.create(vn.prototype),{constructor:cl,isInstancedBufferGeometry:!0,copy:function(t){return vn.prototype.copy.call(this,t),this.instanceCount=t.instanceCount,this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t=vn.prototype.toJSON.call(this);return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}),ll.prototype=Object.assign(Object.create(Je.prototype),{constructor:ll,isInstancedBufferAttribute:!0,copy:function(t){return Je.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},toJSON:function(){var t=Je.prototype.toJSON.call(this);return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}),ul.prototype=Object.assign(Object.create(fc.prototype),{constructor:ul,load:function(t,e,n,r){var i=this,a=new vc(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(t,(function(n){try{e(i.parse(JSON.parse(n)))}catch(e){r?r(e):console.error(e),i.manager.itemError(t)}}),n,r)},parse:function(t){var e={},n={};function r(t,r){if(void 0!==e[r])return e[r];var i=t.interleavedBuffers[r],a=function(t,e){if(void 0!==n[e])return n[e];var r=t.arrayBuffers[e],i=new Uint32Array(r).buffer;return n[e]=i,i}(t,i.buffer),o=new ca(new dl[i.type](a),i.stride);return o.uuid=i.uuid,e[r]=o,o}var i=t.isInstancedBufferGeometry?new cl:new vn,a=t.data.index;if(void 0!==a){var o=new dl[a.type](a.array);i.setIndex(new Je(o,1))}var s=t.data.attributes;for(var c in s){var l=s[c],u=void 0;if(l.isInterleavedBufferAttribute){u=new ha(r(t.data,l.data),l.itemSize,l.offset,l.normalized)}else{var h=new dl[l.type](l.array);u=new(l.isInstancedBufferAttribute?ll:Je)(h,l.itemSize,l.normalized)}void 0!==l.name&&(u.name=l.name),i.setAttribute(c,u)}var d=t.data.morphAttributes;if(d)for(var p in d){for(var f=d[p],m=[],v=0,g=f.length;v<g;v++){var y=f[v],x=void 0;if(y.isInterleavedBufferAttribute)x=new ha(r(t.data,y.data),y.itemSize,y.offset,y.normalized);else x=new Je(new dl[y.type](y.array),y.itemSize,y.normalized);void 0!==y.name&&(x.name=y.name),m.push(x)}i.morphAttributes[p]=m}t.data.morphTargetsRelative&&(i.morphTargetsRelative=!0);var _=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==_)for(var b=0,w=_.length;b!==w;++b){var M=_[b];i.addGroup(M.start,M.count,M.materialIndex)}var S=t.data.boundingSphere;if(void 0!==S){var T=new wt;void 0!==S.center&&T.fromArray(S.center),i.boundingSphere=new Ht(T,S.radius)}return t.name&&(i.name=t.name),t.userData&&(i.userData=t.userData),i}});var hl,dl={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!=typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array},pl=function(t){function e(e){return t.call(this,e)||this}ut(e,t);var n=e.prototype;return n.load=function(t,e,n,r){var i=this,a=""===this.path?sl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||a;var o=new vc(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(n){var a=null;try{a=JSON.parse(n)}catch(e){return void 0!==r&&r(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}var o=a.metadata;void 0!==o&&void 0!==o.type&&"geometry"!==o.type.toLowerCase()?i.parse(a,e):console.error("THREE.ObjectLoader: Can't load "+t)}),n,r)},n.parse=function(t,e){var n=this.parseShape(t.shapes),r=this.parseGeometries(t.geometries,n),i=this.parseImages(t.images,(function(){void 0!==e&&e(s)})),a=this.parseTextures(t.textures,i),o=this.parseMaterials(t.materials,a),s=this.parseObject(t.object,r,o);return t.animations&&(s.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(s),s},n.parseShape=function(t){var e={};if(void 0!==t)for(var n=0,r=t.length;n<r;n++){var i=(new jc).fromJSON(t[n]);e[i.uuid]=i}return e},n.parseGeometries=function(t,e){var n,r={};if(void 0!==t)for(var i=new ul,a=0,o=t.length;a<o;a++){var s=void 0,c=t[a];switch(c.type){case"PlaneGeometry":case"PlaneBufferGeometry":s=new Gs[c.type](c.width,c.height,c.widthSegments,c.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":s=new Gs[c.type](c.width,c.height,c.depth,c.widthSegments,c.heightSegments,c.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":s=new Gs[c.type](c.radius,c.segments,c.thetaStart,c.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":s=new Gs[c.type](c.radiusTop,c.radiusBottom,c.height,c.radialSegments,c.heightSegments,c.openEnded,c.thetaStart,c.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":s=new Gs[c.type](c.radius,c.height,c.radialSegments,c.heightSegments,c.openEnded,c.thetaStart,c.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":s=new Gs[c.type](c.radius,c.widthSegments,c.heightSegments,c.phiStart,c.phiLength,c.thetaStart,c.thetaLength);break;case"DodecahedronGeometry":case"DodecahedronBufferGeometry":case"IcosahedronGeometry":case"IcosahedronBufferGeometry":case"OctahedronGeometry":case"OctahedronBufferGeometry":case"TetrahedronGeometry":case"TetrahedronBufferGeometry":s=new Gs[c.type](c.radius,c.detail);break;case"RingGeometry":case"RingBufferGeometry":s=new Gs[c.type](c.innerRadius,c.outerRadius,c.thetaSegments,c.phiSegments,c.thetaStart,c.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":s=new Gs[c.type](c.radius,c.tube,c.radialSegments,c.tubularSegments,c.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":s=new Gs[c.type](c.radius,c.tube,c.tubularSegments,c.radialSegments,c.p,c.q);break;case"TubeGeometry":case"TubeBufferGeometry":s=new Gs[c.type]((new kc[c.path.type]).fromJSON(c.path),c.tubularSegments,c.radius,c.radialSegments,c.closed);break;case"LatheGeometry":case"LatheBufferGeometry":s=new Gs[c.type](c.points,c.segments,c.phiStart,c.phiLength);break;case"PolyhedronGeometry":case"PolyhedronBufferGeometry":s=new Gs[c.type](c.vertices,c.indices,c.radius,c.details);break;case"ShapeGeometry":case"ShapeBufferGeometry":n=[];for(var l=0,u=c.shapes.length;l<u;l++){var h=e[c.shapes[l]];n.push(h)}s=new Gs[c.type](n,c.curveSegments);break;case"ExtrudeGeometry":case"ExtrudeBufferGeometry":n=[];for(var d=0,p=c.shapes.length;d<p;d++){var f=e[c.shapes[d]];n.push(f)}var m=c.options.extrudePath;void 0!==m&&(c.options.extrudePath=(new kc[m.type]).fromJSON(m)),s=new Gs[c.type](n,c.options);break;case"BufferGeometry":case"InstancedBufferGeometry":s=i.parse(c);break;case"Geometry":console.error('THREE.ObjectLoader: Loading "Geometry" is not supported anymore.');break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+c.type+'"');continue}s.uuid=c.uuid,void 0!==c.name&&(s.name=c.name),!0===s.isBufferGeometry&&void 0!==c.userData&&(s.userData=c.userData),r[c.uuid]=s}return r},n.parseMaterials=function(t,e){var n={},r={};if(void 0!==t){var i=new ol;i.setTextures(e);for(var a=0,o=t.length;a<o;a++){var s=t[a];if("MultiMaterial"===s.type){for(var c=[],l=0;l<s.materials.length;l++){var u=s.materials[l];void 0===n[u.uuid]&&(n[u.uuid]=i.parse(u)),c.push(n[u.uuid])}r[s.uuid]=c}else void 0===n[s.uuid]&&(n[s.uuid]=i.parse(s)),r[s.uuid]=n[s.uuid]}}return r},n.parseAnimations=function(t){for(var e=[],n=0;n<t.length;n++){var r=t[n],i=lc.parse(r);void 0!==r.uuid&&(i.uuid=r.uuid),e.push(i)}return e},n.parseImages=function(t,e){var n,r=this,i={};function a(t){return r.manager.itemStart(t),n.load(t,(function(){r.manager.itemEnd(t)}),void 0,(function(){r.manager.itemError(t),r.manager.itemEnd(t)}))}if(void 0!==t&&t.length>0){var o=new dc(e);(n=new xc(o)).setCrossOrigin(this.crossOrigin);for(var s=0,c=t.length;s<c;s++){var l=t[s],u=l.url;if(Array.isArray(u)){i[l.uuid]=[];for(var h=0,d=u.length;h<d;h++){var p=u[h],f=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(p)?p:r.resourcePath+p;i[l.uuid].push(a(f))}}else{var m=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l.url)?l.url:r.resourcePath+l.url;i[l.uuid]=a(m)}}}return i},n.parseTextures=function(t,e){function n(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}var r={};if(void 0!==t)for(var i=0,a=t.length;i<a;i++){var o=t[i];void 0===o.image&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),void 0===e[o.image]&&console.warn("THREE.ObjectLoader: Undefined image",o.image);var s=void 0;(s=Array.isArray(e[o.image])?new qn(e[o.image]):new gt(e[o.image])).needsUpdate=!0,s.uuid=o.uuid,void 0!==o.name&&(s.name=o.name),void 0!==o.mapping&&(s.mapping=n(o.mapping,fl)),void 0!==o.offset&&s.offset.fromArray(o.offset),void 0!==o.repeat&&s.repeat.fromArray(o.repeat),void 0!==o.center&&s.center.fromArray(o.center),void 0!==o.rotation&&(s.rotation=o.rotation),void 0!==o.wrap&&(s.wrapS=n(o.wrap[0],ml),s.wrapT=n(o.wrap[1],ml)),void 0!==o.format&&(s.format=o.format),void 0!==o.type&&(s.type=o.type),void 0!==o.encoding&&(s.encoding=o.encoding),void 0!==o.minFilter&&(s.minFilter=n(o.minFilter,vl)),void 0!==o.magFilter&&(s.magFilter=n(o.magFilter,vl)),void 0!==o.anisotropy&&(s.anisotropy=o.anisotropy),void 0!==o.flipY&&(s.flipY=o.flipY),void 0!==o.premultiplyAlpha&&(s.premultiplyAlpha=o.premultiplyAlpha),void 0!==o.unpackAlignment&&(s.unpackAlignment=o.unpackAlignment),r[o.uuid]=s}return r},n.parseObject=function(t,e,n){var r,i,a;function o(t){return void 0===e[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),e[t]}function s(t){if(void 0!==t){if(Array.isArray(t)){for(var e=[],r=0,i=t.length;r<i;r++){var a=t[r];void 0===n[a]&&console.warn("THREE.ObjectLoader: Undefined material",a),e.push(n[a])}return e}return void 0===n[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),n[t]}}switch(t.type){case"Scene":r=new sa,void 0!==t.background&&Number.isInteger(t.background)&&(r.background=new Ve(t.background)),void 0!==t.fog&&("Fog"===t.fog.type?r.fog=new oa(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(r.fog=new aa(t.fog.color,t.fog.density)));break;case"PerspectiveCamera":r=new Vn(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(r.focus=t.focus),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.filmGauge&&(r.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(r.filmOffset=t.filmOffset),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"OrthographicCamera":r=new $c(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"AmbientLight":r=new nl(t.color,t.intensity);break;case"DirectionalLight":r=new el(t.color,t.intensity);break;case"PointLight":r=new Kc(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":r=new rl(t.color,t.intensity,t.width,t.height);break;case"SpotLight":r=new Jc(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay);break;case"HemisphereLight":r=new Xc(t.color,t.groundColor,t.intensity);break;case"LightProbe":r=(new al).fromJSON(t);break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");case"Mesh":r=new On(i=o(t.geometry),a=s(t.material));break;case"InstancedMesh":i=o(t.geometry),a=s(t.material);var c=t.count,l=t.instanceMatrix;(r=new Wa(i,a,c)).instanceMatrix=new Je(new Float32Array(l.array),16);break;case"LOD":r=new Oa;break;case"Line":r=new Qa(o(t.geometry),s(t.material),t.mode);break;case"LineLoop":r=new eo(o(t.geometry),s(t.material));break;case"LineSegments":r=new to(o(t.geometry),s(t.material));break;case"PointCloud":case"Points":r=new so(o(t.geometry),s(t.material));break;case"Sprite":r=new Ta(s(t.material));break;case"Group":r=new $i;break;default:r=new be}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(r.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.layers&&(r.layers.mask=t.layers),void 0!==t.children)for(var u=t.children,h=0;h<u.length;h++)r.add(this.parseObject(u[h],e,n));if("LOD"===t.type){void 0!==t.autoUpdate&&(r.autoUpdate=t.autoUpdate);for(var d=t.levels,p=0;p<d.length;p++){var f=d[p],m=r.getObjectByProperty("uuid",f.object);void 0!==m&&r.addLevel(m,f.distance)}}return r},n.setTexturePath=function(t){return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(t)},e}(fc),fl={UVMapping:n,CubeReflectionMapping:r,CubeRefractionMapping:i,EquirectangularReflectionMapping:a,EquirectangularRefractionMapping:o,CubeUVReflectionMapping:s,CubeUVRefractionMapping:c},ml={RepeatWrapping:l,ClampToEdgeWrapping:u,MirroredRepeatWrapping:h},vl={NearestFilter:d,NearestMipmapNearestFilter:p,NearestMipmapLinearFilter:f,LinearFilter:m,LinearMipmapNearestFilter:v,LinearMipmapLinearFilter:g};function gl(t){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),fc.call(this,t),this.options={premultiplyAlpha:"none"}}function yl(){this.type="ShapePath",this.color=new Ve,this.subPaths=[],this.currentPath=null}function xl(t){this.type="Font",this.data=t}function _l(t,e,n,r,i){var a=i.glyphs[t]||i.glyphs["?"];if(a){var o,s,c,l,u,h,d,p,f=new yl;if(a.o)for(var m=a._cachedOutline||(a._cachedOutline=a.o.split(" ")),v=0,g=m.length;v<g;){switch(m[v++]){case"m":o=m[v++]*e+n,s=m[v++]*e+r,f.moveTo(o,s);break;case"l":o=m[v++]*e+n,s=m[v++]*e+r,f.lineTo(o,s);break;case"q":c=m[v++]*e+n,l=m[v++]*e+r,u=m[v++]*e+n,h=m[v++]*e+r,f.quadraticCurveTo(u,h,c,l);break;case"b":c=m[v++]*e+n,l=m[v++]*e+r,u=m[v++]*e+n,h=m[v++]*e+r,d=m[v++]*e+n,p=m[v++]*e+r,f.bezierCurveTo(u,h,d,p,c,l)}}return{offsetX:a.ha*e,path:f}}console.error('THREE.Font: character "'+t+'" does not exists in font family '+i.familyName+".")}function bl(t){fc.call(this,t)}gl.prototype=Object.assign(Object.create(fc.prototype),{constructor:gl,isImageBitmapLoader:!0,setOptions:function(t){return this.options=t,this},load:function(t,e,n,r){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);var i=this,a=hc.get(t);if(void 0!==a)return i.manager.itemStart(t),setTimeout((function(){e&&e(a),i.manager.itemEnd(t)}),0),a;var o={};o.credentials="anonymous"===this.crossOrigin?"same-origin":"include",fetch(t,o).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,i.options)})).then((function(n){hc.add(t,n),e&&e(n),i.manager.itemEnd(t)})).catch((function(e){r&&r(e),i.manager.itemError(t),i.manager.itemEnd(t)})),i.manager.itemStart(t)}}),Object.assign(yl.prototype,{moveTo:function(t,e){return this.currentPath=new Wc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this},lineTo:function(t,e){return this.currentPath.lineTo(t,e),this},quadraticCurveTo:function(t,e,n,r){return this.currentPath.quadraticCurveTo(t,e,n,r),this},bezierCurveTo:function(t,e,n,r,i,a){return this.currentPath.bezierCurveTo(t,e,n,r,i,a),this},splineThru:function(t){return this.currentPath.splineThru(t),this},toShapes:function(t,e){function n(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n],a=new jc;a.curves=i.curves,e.push(a)}return e}function r(t,e){for(var n=e.length,r=!1,i=n-1,a=0;a<n;i=a++){var o=e[i],s=e[a],c=s.x-o.x,l=s.y-o.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(o=e[a],c=-c,s=e[i],l=-l),t.y<o.y||t.y>s.y)continue;if(t.y===o.y){if(t.x===o.x)return!0}else{var u=l*(t.x-o.x)-c*(t.y-o.y);if(0===u)return!0;if(u<0)continue;r=!r}}else{if(t.y!==o.y)continue;if(s.x<=t.x&&t.x<=o.x||o.x<=t.x&&t.x<=s.x)return!0}}return r}var i,a,o,s=as.isClockWise,c=this.subPaths;if(0===c.length)return[];if(!0===e)return n(c);var l=[];if(1===c.length)return a=c[0],(o=new jc).curves=a.curves,l.push(o),l;var u=!s(c[0].getPoints());u=t?!u:u;var h,d,p=[],f=[],m=[],v=0;f[v]=void 0,m[v]=[];for(var g=0,y=c.length;g<y;g++)i=s(h=(a=c[g]).getPoints()),(i=t?!i:i)?(!u&&f[v]&&v++,f[v]={s:new jc,p:h},f[v].s.curves=a.curves,u&&v++,m[v]=[]):m[v].push({h:a,p:h[0]});if(!f[0])return n(c);if(f.length>1){for(var x=!1,_=[],b=0,w=f.length;b<w;b++)p[b]=[];for(var M=0,S=f.length;M<S;M++)for(var T=m[M],E=0;E<T.length;E++){for(var A=T[E],L=!0,R=0;R<f.length;R++)r(A.p,f[R].p)&&(M!==R&&_.push({froms:M,tos:R,hole:E}),L?(L=!1,p[R].push(A)):x=!0);L&&p[M].push(A)}_.length>0&&(x||(m=p))}for(var C=0,P=f.length;C<P;C++){o=f[C].s,l.push(o);for(var I=0,D=(d=m[C]).length;I<D;I++)o.holes.push(d[I].h)}return l}}),Object.assign(xl.prototype,{isFont:!0,generateShapes:function(t,e){void 0===e&&(e=100);for(var n=[],r=function(t,e,n){for(var r=Array.from?Array.from(t):String(t).split(""),i=e/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*i,o=[],s=0,c=0,l=0;l<r.length;l++){var u=r[l];if("\n"===u)s=0,c-=a;else{var h=_l(u,i,s,c,n);s+=h.offsetX,o.push(h.path)}}return o}(t,e,this.data),i=0,a=r.length;i<a;i++)Array.prototype.push.apply(n,r[i].toShapes());return n}}),bl.prototype=Object.assign(Object.create(fc.prototype),{constructor:bl,load:function(t,e,n,r){var i=this,a=new vc(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(i.withCredentials),a.load(t,(function(t){var n;try{n=JSON.parse(t)}catch(e){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),n=JSON.parse(t.substring(65,t.length-2))}var r=i.parse(n);e&&e(r)}),n,r)},parse:function(t){return new xl(t)}});var wl={getContext:function(){return void 0===hl&&(hl=new(window.AudioContext||window.webkitAudioContext)),hl},setContext:function(t){hl=t}};function Ml(t){fc.call(this,t)}function Sl(t,e,n){al.call(this,void 0,n);var r=(new Ve).set(t),i=(new Ve).set(e),a=new wt(r.r,r.g,r.b),o=new wt(i.r,i.g,i.b),s=Math.sqrt(Math.PI),c=s*Math.sqrt(.75);this.sh.coefficients[0].copy(a).add(o).multiplyScalar(s),this.sh.coefficients[1].copy(a).sub(o).multiplyScalar(c)}function Tl(t,e){al.call(this,void 0,e);var n=(new Ve).set(t);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}Ml.prototype=Object.assign(Object.create(fc.prototype),{constructor:Ml,load:function(t,e,n,r){var i=this,a=new vc(i.manager);a.setResponseType("arraybuffer"),a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(t,(function(n){try{var a=n.slice(0);wl.getContext().decodeAudioData(a,(function(t){e(t)}))}catch(e){r?r(e):console.error(e),i.manager.itemError(t)}}),n,r)}}),Sl.prototype=Object.assign(Object.create(al.prototype),{constructor:Sl,isHemisphereLightProbe:!0,copy:function(t){return al.prototype.copy.call(this,t),this},toJSON:function(t){return al.prototype.toJSON.call(this,t)}}),Tl.prototype=Object.assign(Object.create(al.prototype),{constructor:Tl,isAmbientLightProbe:!0,copy:function(t){return al.prototype.copy.call(this,t),this},toJSON:function(t){return al.prototype.toJSON.call(this,t)}});var El=new Jt,Al=new Jt;function Ll(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Vn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Vn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}Object.assign(Ll.prototype,{update:function(t){var e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep;var n,r,i=t.projectionMatrix.clone(),a=e.eyeSep/2,o=a*e.near/e.focus,s=e.near*Math.tan(st.DEG2RAD*e.fov*.5)/e.zoom;Al.elements[12]=-a,El.elements[12]=a,n=-s*e.aspect+o,r=s*e.aspect+o,i.elements[0]=2*e.near/(r-n),i.elements[8]=(r+n)/(r-n),this.cameraL.projectionMatrix.copy(i),n=-s*e.aspect-o,r=s*e.aspect-o,i.elements[0]=2*e.near/(r-n),i.elements[8]=(r+n)/(r-n),this.cameraR.projectionMatrix.copy(i)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(Al),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(El)}});var Rl=function(){function t(t){this.autoStart=void 0===t||t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}var e=t.prototype;return e.start=function(){this.startTime=("undefined"==typeof performance?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0},e.stop=function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1},e.getElapsedTime=function(){return this.getDelta(),this.elapsedTime},e.getDelta=function(){var t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var e=("undefined"==typeof performance?Date:performance).now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t},t}(),Cl=new wt,Pl=new bt,Il=new wt,Dl=new wt,Ol=function(t){function e(){var e;return(e=t.call(this)||this).type="AudioListener",e.context=wl.getContext(),e.gain=e.context.createGain(),e.gain.connect(e.context.destination),e.filter=null,e.timeDelta=0,e._clock=new Rl,e}ut(e,t);var n=e.prototype;return n.getInput=function(){return this.gain},n.removeFilter=function(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this},n.getFilter=function(){return this.filter},n.setFilter=function(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this},n.getMasterVolume=function(){return this.gain.gain.value},n.setMasterVolume=function(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this},n.updateMatrixWorld=function(e){t.prototype.updateMatrixWorld.call(this,e);var n=this.context.listener,r=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Cl,Pl,Il),Dl.set(0,0,-1).applyQuaternion(Pl),n.positionX){var i=this.context.currentTime+this.timeDelta;n.positionX.linearRampToValueAtTime(Cl.x,i),n.positionY.linearRampToValueAtTime(Cl.y,i),n.positionZ.linearRampToValueAtTime(Cl.z,i),n.forwardX.linearRampToValueAtTime(Dl.x,i),n.forwardY.linearRampToValueAtTime(Dl.y,i),n.forwardZ.linearRampToValueAtTime(Dl.z,i),n.upX.linearRampToValueAtTime(r.x,i),n.upY.linearRampToValueAtTime(r.y,i),n.upZ.linearRampToValueAtTime(r.z,i)}else n.setPosition(Cl.x,Cl.y,Cl.z),n.setOrientation(Dl.x,Dl.y,Dl.z,r.x,r.y,r.z)},e}(be),Nl=function(t){function e(e){var n;return(n=t.call(this)||this).type="Audio",n.listener=e,n.context=e.context,n.gain=n.context.createGain(),n.gain.connect(e.getInput()),n.autoplay=!1,n.buffer=null,n.detune=0,n.loop=!1,n.loopStart=0,n.loopEnd=0,n.offset=0,n.duration=void 0,n.playbackRate=1,n.isPlaying=!1,n.hasPlaybackControl=!0,n.source=null,n.sourceType="empty",n._startedAt=0,n._progress=0,n._connected=!1,n.filters=[],n}ut(e,t);var n=e.prototype;return n.getOutput=function(){return this.gain},n.setNodeSource=function(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this},n.setMediaElementSource=function(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this},n.setMediaStreamSource=function(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this},n.setBuffer=function(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this},n.play=function(t){if(void 0===t&&(t=0),!0!==this.isPlaying){if(!1!==this.hasPlaybackControl){this._startedAt=this.context.currentTime+t;var e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}console.warn("THREE.Audio: this Audio has no playback control.")}else console.warn("THREE.Audio: Audio is already playing.")},n.pause=function(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")},n.stop=function(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")},n.connect=function(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this},n.disconnect=function(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this},n.getFilters=function(){return this.filters},n.setFilters=function(t){return t||(t=[]),!0===this._connected?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this},n.setDetune=function(t){if(this.detune=t,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this},n.getDetune=function(){return this.detune},n.getFilter=function(){return this.getFilters()[0]},n.setFilter=function(t){return this.setFilters(t?[t]:[])},n.setPlaybackRate=function(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")},n.getPlaybackRate=function(){return this.playbackRate},n.onEnded=function(){this.isPlaying=!1},n.getLoop=function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop},n.setLoop=function(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")},n.setLoopStart=function(t){return this.loopStart=t,this},n.setLoopEnd=function(t){return this.loopEnd=t,this},n.getVolume=function(){return this.gain.gain.value},n.setVolume=function(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this},e}(be),Bl=new wt,zl=new bt,Gl=new wt,Fl=new wt,Ul=function(t){function e(e){var n;return(n=t.call(this,e)||this).panner=n.context.createPanner(),n.panner.panningModel="HRTF",n.panner.connect(n.gain),n}ut(e,t);var n=e.prototype;return n.getOutput=function(){return this.panner},n.getRefDistance=function(){return this.panner.refDistance},n.setRefDistance=function(t){return this.panner.refDistance=t,this},n.getRolloffFactor=function(){return this.panner.rolloffFactor},n.setRolloffFactor=function(t){return this.panner.rolloffFactor=t,this},n.getDistanceModel=function(){return this.panner.distanceModel},n.setDistanceModel=function(t){return this.panner.distanceModel=t,this},n.getMaxDistance=function(){return this.panner.maxDistance},n.setMaxDistance=function(t){return this.panner.maxDistance=t,this},n.setDirectionalCone=function(t,e,n){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=n,this},n.updateMatrixWorld=function(e){if(t.prototype.updateMatrixWorld.call(this,e),!0!==this.hasPlaybackControl||!1!==this.isPlaying){this.matrixWorld.decompose(Bl,zl,Gl),Fl.set(0,0,1).applyQuaternion(zl);var n=this.panner;if(n.positionX){var r=this.context.currentTime+this.listener.timeDelta;n.positionX.linearRampToValueAtTime(Bl.x,r),n.positionY.linearRampToValueAtTime(Bl.y,r),n.positionZ.linearRampToValueAtTime(Bl.z,r),n.orientationX.linearRampToValueAtTime(Fl.x,r),n.orientationY.linearRampToValueAtTime(Fl.y,r),n.orientationZ.linearRampToValueAtTime(Fl.z,r)}else n.setPosition(Bl.x,Bl.y,Bl.z),n.setOrientation(Fl.x,Fl.y,Fl.z)}},e}(Nl),Hl=function(){function t(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}var e=t.prototype;return e.getFrequencyData=function(){return this.analyser.getByteFrequencyData(this.data),this.data},e.getAverageFrequency=function(){for(var t=0,e=this.getFrequencyData(),n=0;n<e.length;n++)t+=e[n];return t/e.length},t}();function kl(t,e,n){var r,i,a;switch(this.binding=t,this.valueSize=n,e){case"quaternion":r=this._slerp,i=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":r=this._select,i=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:r=this._lerp,i=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=i,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}Object.assign(kl.prototype,{accumulate:function(t,e){var n=this.buffer,r=this.valueSize,i=t*r+r,a=this.cumulativeWeight;if(0===a){for(var o=0;o!==r;++o)n[i+o]=n[o];a=e}else{var s=e/(a+=e);this._mixBufferRegion(n,i,0,s,r)}this.cumulativeWeight=a},accumulateAdditive:function(t){var e=this.buffer,n=this.valueSize,r=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,r,0,t,n),this.cumulativeWeightAdditive+=t},apply:function(t){var e=this.valueSize,n=this.buffer,r=t*e+e,i=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,i<1){var s=e*this._origIndex;this._mixBufferRegion(n,r,s,1-i,e)}a>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*e,1,e);for(var c=e,l=e+e;c!==l;++c)if(n[c]!==n[c+e]){o.setValue(n,r);break}},saveOriginalState:function(){var t=this.binding,e=this.buffer,n=this.valueSize,r=n*this._origIndex;t.getValue(e,r);for(var i=n,a=r;i!==a;++i)e[i]=e[r+i%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0},restoreOriginalState:function(){var t=3*this.valueSize;this.binding.setValue(this.buffer,t)},_setAdditiveIdentityNumeric:function(){for(var t=this._addIndex*this.valueSize,e=t+this.valueSize,n=t;n<e;n++)this.buffer[n]=0},_setAdditiveIdentityQuaternion:function(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1},_setAdditiveIdentityOther:function(){for(var t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize,n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]},_select:function(t,e,n,r,i){if(r>=.5)for(var a=0;a!==i;++a)t[e+a]=t[n+a]},_slerp:function(t,e,n,r){bt.slerpFlat(t,e,t,e,t,n,r)},_slerpAdditive:function(t,e,n,r,i){var a=this._workIndex*i;bt.multiplyQuaternionsFlat(t,a,t,e,t,n),bt.slerpFlat(t,e,t,e,t,a,r)},_lerp:function(t,e,n,r,i){for(var a=1-r,o=0;o!==i;++o){var s=e+o;t[s]=t[s]*a+t[n+o]*r}},_lerpAdditive:function(t,e,n,r,i){for(var a=0;a!==i;++a){var o=e+a;t[o]=t[o]+t[n+a]*r}}});var Vl="\\[\\]\\.:\\/",Wl=new RegExp("[\\[\\]\\.:\\/]","g"),jl="[^\\[\\]\\.:\\/]",ql="[^"+Vl.replace("\\.","")+"]",Xl=/((?:WC+[\/:])*)/.source.replace("WC",jl),Yl=/(WCOD+)?/.source.replace("WCOD",ql),Zl=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",jl),Jl=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",jl),Ql=new RegExp("^"+Xl+Yl+Zl+Jl+"$"),Kl=["material","materials","bones"];function $l(t,e,n){var r=n||tu.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}function tu(t,e,n){this.path=e,this.parsedPath=n||tu.parseTrackName(e),this.node=tu.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function eu(){this.uuid=st.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var t={};this._indicesByUUID=t;for(var e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var r=this;this.stats={objects:{get total(){return r._objects.length},get inUse(){return this.total-r.nCachedObjects_}},get bindingsPerObject(){return r._bindings.length}}}Object.assign($l.prototype,{getValue:function(t,e){this.bind();var n=this._targetGroup.nCachedObjects_,r=this._bindings[n];void 0!==r&&r.getValue(t,e)},setValue:function(t,e){for(var n=this._bindings,r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(t,e)},bind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()},unbind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}),Object.assign(tu,{Composite:$l,create:function(t,e,n){return t&&t.isAnimationObjectGroup?new tu.Composite(t,e,n):new tu(t,e,n)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(Wl,"")},parseTrackName:function(t){var e=Ql.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);var n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){var i=n.nodeName.substring(r+1);-1!==Kl.indexOf(i)&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=i)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n},findNode:function(t,e){if(!e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){var n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){var r=function t(n){for(var r=0;r<n.length;r++){var i=n[r];if(i.name===e||i.uuid===e)return i;var a=t(i.children);if(a)return a}return null}(t.children);if(r)return r}return null}}),Object.assign(tu.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(t,e){t[e]=this.node[this.propertyName]},function(t,e){for(var n=this.resolvedProperty,r=0,i=n.length;r!==i;++r)t[e++]=n[r]},function(t,e){t[e]=this.resolvedProperty[this.propertyIndex]},function(t,e){this.resolvedProperty.toArray(t,e)}],SetterByBindingTypeAndVersioning:[[function(t,e){this.targetObject[this.propertyName]=t[e]},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){for(var n=this.resolvedProperty,r=0,i=n.length;r!==i;++r)n[r]=t[e++]},function(t,e){for(var n=this.resolvedProperty,r=0,i=n.length;r!==i;++r)n[r]=t[e++];this.targetObject.needsUpdate=!0},function(t,e){for(var n=this.resolvedProperty,r=0,i=n.length;r!==i;++r)n[r]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty[this.propertyIndex]=t[e]},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty.fromArray(t,e)},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){var t=this.node,e=this.parsedPath,n=e.objectName,r=e.propertyName,i=e.propertyIndex;if(t||(t=tu.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,t){if(n){var a=e.objectIndex;switch(n){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(var o=0;o<t.length;o++)if(t[o].name===a){a=o;break}break;default:if(void 0===t[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[n]}if(void 0!==a){if(void 0===t[a])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[a]}}var s=t[r];if(void 0!==s){var c=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?c=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(c=this.Versioning.MatrixWorldNeedsUpdate);var l=this.BindingType.Direct;if(void 0!==i){if("morphTargetInfluences"===r){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.isBufferGeometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[i]&&(i=t.morphTargetDictionary[i])}l=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=i}else void 0!==s.fromArray&&void 0!==s.toArray?(l=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(l=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][c]}else{var u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+r+" but it wasn't found.",t)}}else console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.")},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(tu.prototype,{_getValue_unbound:tu.prototype.getValue,_setValue_unbound:tu.prototype.setValue}),Object.assign(eu.prototype,{isAnimationObjectGroup:!0,add:function(){for(var t=this._objects,e=this._indicesByUUID,n=this._paths,r=this._parsedPaths,i=this._bindings,a=i.length,o=void 0,s=t.length,c=this.nCachedObjects_,l=0,u=arguments.length;l!==u;++l){var h=arguments[l],d=h.uuid,p=e[d];if(void 0===p){p=s++,e[d]=p,t.push(h);for(var f=0,m=a;f!==m;++f)i[f].push(new tu(h,n[f],r[f]))}else if(p<c){o=t[p];var v=--c,g=t[v];e[g.uuid]=p,t[p]=g,e[d]=v,t[v]=h;for(var y=0,x=a;y!==x;++y){var _=i[y],b=_[v],w=_[p];_[p]=b,void 0===w&&(w=new tu(h,n[y],r[y])),_[v]=w}}else t[p]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c},remove:function(){for(var t=this._objects,e=this._indicesByUUID,n=this._bindings,r=n.length,i=this.nCachedObjects_,a=0,o=arguments.length;a!==o;++a){var s=arguments[a],c=s.uuid,l=e[c];if(void 0!==l&&l>=i){var u=i++,h=t[u];e[h.uuid]=l,t[l]=h,e[c]=u,t[u]=s;for(var d=0,p=r;d!==p;++d){var f=n[d],m=f[u],v=f[l];f[l]=m,f[u]=v}}}this.nCachedObjects_=i},uncache:function(){for(var t=this._objects,e=this._indicesByUUID,n=this._bindings,r=n.length,i=this.nCachedObjects_,a=t.length,o=0,s=arguments.length;o!==s;++o){var c=arguments[o],l=c.uuid,u=e[l];if(void 0!==u)if(delete e[l],u<i){var h=--i,d=t[h],p=--a,f=t[p];e[d.uuid]=u,t[u]=d,e[f.uuid]=h,t[h]=f,t.pop();for(var m=0,v=r;m!==v;++m){var g=n[m],y=g[h],x=g[p];g[u]=y,g[h]=x,g.pop()}}else{var _=--a,b=t[_];_>0&&(e[b.uuid]=u),t[u]=b,t.pop();for(var w=0,M=r;w!==M;++w){var S=n[w];S[u]=S[_],S.pop()}}}this.nCachedObjects_=i},subscribe_:function(t,e){var n=this._bindingsIndicesByPath,r=n[t],i=this._bindings;if(void 0!==r)return i[r];var a=this._paths,o=this._parsedPaths,s=this._objects,c=s.length,l=this.nCachedObjects_,u=new Array(c);r=i.length,n[t]=r,a.push(t),o.push(e),i.push(u);for(var h=l,d=s.length;h!==d;++h){var p=s[h];u[h]=new tu(p,t,e)}return u},unsubscribe_:function(t){var e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){var r=this._paths,i=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o];e[t[o]]=n,a[n]=s,a.pop(),i[n]=i[o],i.pop(),r[n]=r[o],r.pop()}}});var nu=function(){function t(t,e,n,r){this._mixer=t,this._clip=e,this._localRoot=n||null,this.blendMode=r||e.blendMode;for(var i=e.tracks,a=i.length,o=new Array(a),s={endingStart:H,endingEnd:H},c=0;c!==a;++c){var l=i[c].createInterpolant(null);o[c]=l,l.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}var e=t.prototype;return e.play=function(){return this._mixer._activateAction(this),this},e.stop=function(){return this._mixer._deactivateAction(this),this.reset()},e.reset=function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()},e.isRunning=function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},e.isScheduled=function(){return this._mixer._isActiveAction(this)},e.startAt=function(t){return this._startTime=t,this},e.setLoop=function(t,e){return this.loop=t,this.repetitions=e,this},e.setEffectiveWeight=function(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()},e.getEffectiveWeight=function(){return this._effectiveWeight},e.fadeIn=function(t){return this._scheduleFading(t,0,1)},e.fadeOut=function(t){return this._scheduleFading(t,1,0)},e.crossFadeFrom=function(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){var r=this._clip.duration,i=t._clip.duration,a=i/r,o=r/i;t.warp(1,a,e),this.warp(o,1,e)}return this},e.crossFadeTo=function(t,e,n){return t.crossFadeFrom(this,e,n)},e.stopFading=function(){var t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this},e.setEffectiveTimeScale=function(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()},e.getEffectiveTimeScale=function(){return this._effectiveTimeScale},e.setDuration=function(t){return this.timeScale=this._clip.duration/t,this.stopWarping()},e.syncWith=function(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()},e.halt=function(t){return this.warp(this._effectiveTimeScale,0,t)},e.warp=function(t,e,n){var r=this._mixer,i=r.time,a=this.timeScale,o=this._timeScaleInterpolant;null===o&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);var s=o.parameterPositions,c=o.sampleValues;return s[0]=i,s[1]=i+n,c[0]=t/a,c[1]=e/a,this},e.stopWarping=function(){var t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this},e.getMixer=function(){return this._mixer},e.getClip=function(){return this._clip},e.getRoot=function(){return this._localRoot||this._mixer._root},e._update=function(t,e,n,r){if(this.enabled){var i=this._startTime;if(null!==i){var a=(t-i)*n;if(a<0||0===n)return;this._startTime=null,e=n*a}e*=this._updateTimeScale(t);var o=this._updateTime(e),s=this._updateWeight(t);if(s>0){var c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case j:for(var u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulateAdditive(s);break;case W:default:for(var d=0,p=c.length;d!==p;++d)c[d].evaluate(o),l[d].accumulate(r,s)}}}else this._updateWeight(t)},e._updateWeight=function(t){var e=0;if(this.enabled){e=this.weight;var n=this._weightInterpolant;if(null!==n){var r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=e,e},e._updateTimeScale=function(t){var e=0;if(!this.paused){e=this.timeScale;var n=this._timeScaleInterpolant;if(null!==n)e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}return this._effectiveTimeScale=e,e},e._updateTime=function(t){var e=this._clip.duration,n=this.loop,r=this.time+t,i=this._loopCount,a=2202===n;if(0===t)return-1===i?r:a&&1==(1&i)?e-r:r;if(2200===n){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(r>=e)r=e;else{if(!(r<0)){this.time=r;break t}r=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),r>=e||r<0){var o=Math.floor(r/e);r-=e*o,i+=Math.abs(o);var s=this.repetitions-i;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=t>0?e:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===s){var c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&1==(1&i))return e-r}return r},e._setEndings=function(t,e,n){var r=this._interpolantSettings;n?(r.endingStart=k,r.endingEnd=k):(r.endingStart=t?this.zeroSlopeAtStart?k:H:V,r.endingEnd=e?this.zeroSlopeAtEnd?k:H:V)},e._scheduleFading=function(t,e,n){var r=this._mixer,i=r.time,a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=e,o[1]=i+t,s[1]=n,this},t}();function ru(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}ru.prototype=Object.assign(Object.create(rt.prototype),{constructor:ru,_bindAction:function(t,e){var n=t._localRoot||this._root,r=t._clip.tracks,i=r.length,a=t._propertyBindings,o=t._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var u=0;u!==i;++u){var h=r[u],d=h.name,p=l[d];if(void 0!==p)a[u]=p;else{if(void 0!==(p=a[u])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,d));continue}var f=e&&e._propertyBindings[u].binding.parsedPath;++(p=new kl(tu.create(n,d,f),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(p,s,d),a[u]=p}o[u].resultBuffer=p.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,n=t._clip.uuid,r=this._actionsByClip[n];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,n,e)}for(var i=t._propertyBindings,a=0,o=i.length;a!==o;++a){var s=i[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,n=0,r=e.length;n!==r;++n){var i=e[n];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e<this._nActiveActions},_addInactiveAction:function(t,e,n){var r=this._actions,i=this._actionsByClip,a=i[e];if(void 0===a)a={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,i[e]=a;else{var o=a.knownActions;t._byClipCacheIndex=o.length,o.push(t)}t._cacheIndex=r.length,r.push(t),a.actionByRoot[n]=t},_removeInactiveAction:function(t){var e=this._actions,n=e[e.length-1],r=t._cacheIndex;n._cacheIndex=r,e[r]=n,e.pop(),t._cacheIndex=null;var i=t._clip.uuid,a=this._actionsByClip,o=a[i],s=o.knownActions,c=s[s.length-1],l=t._byClipCacheIndex;c._byClipCacheIndex=l,s[l]=c,s.pop(),t._byClipCacheIndex=null,delete o.actionByRoot[(t._localRoot||this._root).uuid],0===s.length&&delete a[i],this._removeInactiveBindingsForAction(t)},_removeInactiveBindingsForAction:function(t){for(var e=t._propertyBindings,n=0,r=e.length;n!==r;++n){var i=e[n];0==--i.referenceCount&&this._removeInactiveBinding(i)}},_lendAction:function(t){var e=this._actions,n=t._cacheIndex,r=this._nActiveActions++,i=e[r];t._cacheIndex=r,e[r]=t,i._cacheIndex=n,e[n]=i},_takeBackAction:function(t){var e=this._actions,n=t._cacheIndex,r=--this._nActiveActions,i=e[r];t._cacheIndex=r,e[r]=t,i._cacheIndex=n,e[n]=i},_addInactiveBinding:function(t,e,n){var r=this._bindingsByRootAndName,i=this._bindings,a=r[e];void 0===a&&(a={},r[e]=a),a[n]=t,t._cacheIndex=i.length,i.push(t)},_removeInactiveBinding:function(t){var e=this._bindings,n=t.binding,r=n.rootNode.uuid,i=n.path,a=this._bindingsByRootAndName,o=a[r],s=e[e.length-1],c=t._cacheIndex;s._cacheIndex=c,e[c]=s,e.pop(),delete o[i],0===Object.keys(o).length&&delete a[r]},_lendBinding:function(t){var e=this._bindings,n=t._cacheIndex,r=this._nActiveBindings++,i=e[r];t._cacheIndex=r,e[r]=t,i._cacheIndex=n,e[n]=i},_takeBackBinding:function(t){var e=this._bindings,n=t._cacheIndex,r=--this._nActiveBindings,i=e[r];t._cacheIndex=r,e[r]=t,i._cacheIndex=n,e[n]=i},_lendControlInterpolant:function(){var t=this._controlInterpolants,e=this._nActiveControlInterpolants++,n=t[e];return void 0===n&&((n=new $s(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=e,t[e]=n),n},_takeBackControlInterpolant:function(t){var e=this._controlInterpolants,n=t.__cacheIndex,r=--this._nActiveControlInterpolants,i=e[r];t.__cacheIndex=r,e[r]=t,i.__cacheIndex=n,e[n]=i},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(t,e,n){var r=e||this._root,i=r.uuid,a="string"==typeof t?lc.findByName(r,t):t,o=null!==a?a.uuid:t,s=this._actionsByClip[o],c=null;if(void 0===n&&(n=null!==a?a.blendMode:W),void 0!==s){var l=s.actionByRoot[i];if(void 0!==l&&l.blendMode===n)return l;c=s.knownActions[0],null===a&&(a=c._clip)}if(null===a)return null;var u=new nu(this,a,e,n);return this._bindAction(u,c),this._addInactiveAction(u,o,i),u},existingAction:function(t,e){var n=e||this._root,r=n.uuid,i="string"==typeof t?lc.findByName(n,t):t,a=i?i.uuid:t,o=this._actionsByClip[a];return void 0!==o&&o.actionByRoot[r]||null},stopAllAction:function(){for(var t=this._actions,e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this},update:function(t){t*=this.timeScale;for(var e=this._actions,n=this._nActiveActions,r=this.time+=t,i=Math.sign(t),a=this._accuIndex^=1,o=0;o!==n;++o){e[o]._update(r,t,i,a)}for(var s=this._bindings,c=this._nActiveBindings,l=0;l!==c;++l)s[l].apply(a);return this},setTime:function(t){this.time=0;for(var e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)},getRoot:function(){return this._root},uncacheClip:function(t){var e=this._actions,n=t.uuid,r=this._actionsByClip,i=r[n];if(void 0!==i){for(var a=i.knownActions,o=0,s=a.length;o!==s;++o){var c=a[o];this._deactivateAction(c);var l=c._cacheIndex,u=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,e[l]=u,e.pop(),this._removeInactiveBindingsForAction(c)}delete r[n]}},uncacheRoot:function(t){var e=t.uuid,n=this._actionsByClip;for(var r in n){var i=n[r].actionByRoot[e];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}var a=this._bindingsByRootAndName[e];if(void 0!==a)for(var o in a){var s=a[o];s.restoreOriginalState(),this._removeInactiveBinding(s)}},uncacheAction:function(t,e){var n=this.existingAction(t,e);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}});var iu=function(){function t(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}return t.prototype.clone=function(){return new t(void 0===this.value.clone?this.value:this.value.clone())},t}();function au(t,e,n){ca.call(this,t,e),this.meshPerAttribute=n||1}function ou(t,e,n,r,i){this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=r,this.count=i,this.version=0}function su(t,e,n,r){this.ray=new Zt(t,e),this.near=n||0,this.far=r||1/0,this.camera=null,this.layers=new se,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function cu(t,e){return t.distance-e.distance}function lu(t,e,n,r){if(t.layers.test(e.layers)&&t.raycast(e,n),!0===r)for(var i=t.children,a=0,o=i.length;a<o;a++)lu(i[a],e,n,!0)}au.prototype=Object.assign(Object.create(ca.prototype),{constructor:au,isInstancedInterleavedBuffer:!0,copy:function(t){return ca.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},clone:function(t){var e=ca.prototype.clone.call(this,t);return e.meshPerAttribute=this.meshPerAttribute,e},toJSON:function(t){var e=ca.prototype.toJSON.call(this,t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}),Object.defineProperty(ou.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(ou.prototype,{isGLBufferAttribute:!0,setBuffer:function(t){return this.buffer=t,this},setType:function(t,e){return this.type=t,this.elementSize=e,this},setItemSize:function(t){return this.itemSize=t,this},setCount:function(t){return this.count=t,this}}),Object.assign(su.prototype,{set:function(t,e){this.ray.set(t,e)},setFromCamera:function(t,e){e&&e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e&&e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(t,e,n){var r=n||[];return lu(t,this,r,e),r.sort(cu),r},intersectObjects:function(t,e,n){var r=n||[];if(!1===Array.isArray(t))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),r;for(var i=0,a=t.length;i<a;i++)lu(t[i],this,r,e);return r.sort(cu),r}});var uu=function(){function t(t,e,n){return void 0===t&&(t=1),void 0===e&&(e=0),void 0===n&&(n=0),this.radius=t,this.phi=e,this.theta=n,this}var e=t.prototype;return e.set=function(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this},e.clone=function(){return(new this.constructor).copy(this)},e.copy=function(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this},e.makeSafe=function(){var t=1e-6;return this.phi=Math.max(t,Math.min(Math.PI-t,this.phi)),this},e.setFromVector3=function(t){return this.setFromCartesianCoords(t.x,t.y,t.z)},e.setFromCartesianCoords=function(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(st.clamp(e/this.radius,-1,1))),this},t}(),hu=function(){function t(t,e,n){return this.radius=void 0!==t?t:1,this.theta=void 0!==e?e:0,this.y=void 0!==n?n:0,this}var e=t.prototype;return e.set=function(t,e,n){return this.radius=t,this.theta=e,this.y=n,this},e.clone=function(){return(new this.constructor).copy(this)},e.copy=function(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this},e.setFromVector3=function(t){return this.setFromCartesianCoords(t.x,t.y,t.z)},e.setFromCartesianCoords=function(t,e,n){return this.radius=Math.sqrt(t*t+n*n),this.theta=Math.atan2(t,n),this.y=e,this},t}(),du=new pt,pu=function(){function t(t,e){Object.defineProperty(this,"isBox2",{value:!0}),this.min=void 0!==t?t:new pt(1/0,1/0),this.max=void 0!==e?e:new pt(-1/0,-1/0)}var e=t.prototype;return e.set=function(t,e){return this.min.copy(t),this.max.copy(e),this},e.setFromPoints=function(t){this.makeEmpty();for(var e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this},e.setFromCenterAndSize=function(t,e){var n=du.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this},e.clone=function(){return(new this.constructor).copy(this)},e.copy=function(t){return this.min.copy(t.min),this.max.copy(t.max),this},e.makeEmpty=function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},e.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y},e.getCenter=function(t){return void 0===t&&(console.warn("THREE.Box2: .getCenter() target is now required"),t=new pt),this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},e.getSize=function(t){return void 0===t&&(console.warn("THREE.Box2: .getSize() target is now required"),t=new pt),this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)},e.expandByPoint=function(t){return this.min.min(t),this.max.max(t),this},e.expandByVector=function(t){return this.min.sub(t),this.max.add(t),this},e.expandByScalar=function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},e.containsPoint=function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)},e.containsBox=function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},e.getParameter=function(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new pt),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},e.intersectsBox=function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)},e.clampPoint=function(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new pt),e.copy(t).clamp(this.min,this.max)},e.distanceToPoint=function(t){return du.copy(t).clamp(this.min,this.max).sub(t).length()},e.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this},e.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},e.translate=function(t){return this.min.add(t),this.max.add(t),this},e.equals=function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},t}(),fu=new wt,mu=new wt,vu=function(){function t(t,e){this.start=void 0!==t?t:new wt,this.end=void 0!==e?e:new wt}var e=t.prototype;return e.set=function(t,e){return this.start.copy(t),this.end.copy(e),this},e.clone=function(){return(new this.constructor).copy(this)},e.copy=function(t){return this.start.copy(t.start),this.end.copy(t.end),this},e.getCenter=function(t){return void 0===t&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new wt),t.addVectors(this.start,this.end).multiplyScalar(.5)},e.delta=function(t){return void 0===t&&(console.warn("THREE.Line3: .delta() target is now required"),t=new wt),t.subVectors(this.end,this.start)},e.distanceSq=function(){return this.start.distanceToSquared(this.end)},e.distance=function(){return this.start.distanceTo(this.end)},e.at=function(t,e){return void 0===e&&(console.warn("THREE.Line3: .at() target is now required"),e=new wt),this.delta(e).multiplyScalar(t).add(this.start)},e.closestPointToPointParameter=function(t,e){fu.subVectors(t,this.start),mu.subVectors(this.end,this.start);var n=mu.dot(mu),r=mu.dot(fu)/n;return e&&(r=st.clamp(r,0,1)),r},e.closestPointToPoint=function(t,e,n){var r=this.closestPointToPointParameter(t,e);return void 0===n&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),n=new wt),this.delta(n).multiplyScalar(r).add(this.start)},e.applyMatrix4=function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},e.equals=function(t){return t.start.equals(this.start)&&t.end.equals(this.end)},t}();function gu(t){be.call(this),this.material=t,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}gu.prototype=Object.create(be.prototype),gu.prototype.constructor=gu,gu.prototype.isImmediateRenderObject=!0;var yu=new wt,xu=function(t){function e(e,n){var r;(r=t.call(this)||this).light=e,r.light.updateMatrixWorld(),r.matrix=e.matrixWorld,r.matrixAutoUpdate=!1,r.color=n;for(var i=new vn,a=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1],o=0,s=1;o<32;o++,s++){var c=o/32*Math.PI*2,l=s/32*Math.PI*2;a.push(Math.cos(c),Math.sin(c),1,Math.cos(l),Math.sin(l),1)}i.setAttribute("position",new an(a,3));var u=new ja({fog:!1,toneMapped:!1});return r.cone=new to(i,u),r.add(r.cone),r.update(),r}ut(e,t);var n=e.prototype;return n.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},n.update=function(){this.light.updateMatrixWorld();var t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),yu.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(yu),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)},e}(be),_u=new wt,bu=new Jt,wu=new Jt,Mu=function(t){function e(e){for(var n,r=Su(e),i=new vn,a=[],o=[],s=new Ve(0,0,1),c=new Ve(0,1,0),l=0;l<r.length;l++){var u=r[l];u.parent&&u.parent.isBone&&(a.push(0,0,0),a.push(0,0,0),o.push(s.r,s.g,s.b),o.push(c.r,c.g,c.b))}i.setAttribute("position",new an(a,3)),i.setAttribute("color",new an(o,3));var h=new ja({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});return(n=t.call(this,i,h)||this).type="SkeletonHelper",n.isSkeletonHelper=!0,n.root=e,n.bones=r,n.matrix=e.matrixWorld,n.matrixAutoUpdate=!1,n}return ut(e,t),e.prototype.updateMatrixWorld=function(e){var n=this.bones,r=this.geometry,i=r.getAttribute("position");wu.getInverse(this.root.matrixWorld);for(var a=0,o=0;a<n.length;a++){var s=n[a];s.parent&&s.parent.isBone&&(bu.multiplyMatrices(wu,s.matrixWorld),_u.setFromMatrixPosition(bu),i.setXYZ(o,_u.x,_u.y,_u.z),bu.multiplyMatrices(wu,s.parent.matrixWorld),_u.setFromMatrixPosition(bu),i.setXYZ(o+1,_u.x,_u.y,_u.z),o+=2)}r.getAttribute("position").needsUpdate=!0,t.prototype.updateMatrixWorld.call(this,e)},e}(to);function Su(t){var e=[];t&&t.isBone&&e.push(t);for(var n=0;n<t.children.length;n++)e.push.apply(e,Su(t.children[n]));return e}var Tu=function(t){function e(e,n,r){var i,a=new Ts(n,4,2),o=new Xe({wireframe:!0,fog:!1,toneMapped:!1});return(i=t.call(this,a,o)||this).light=e,i.light.updateMatrixWorld(),i.color=r,i.type="PointLightHelper",i.matrix=i.light.matrixWorld,i.matrixAutoUpdate=!1,i.update(),i}ut(e,t);var n=e.prototype;return n.dispose=function(){this.geometry.dispose(),this.material.dispose()},n.update=function(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)},e}(On),Eu=new wt,Au=new Ve,Lu=new Ve,Ru=function(t){function e(e,n,r){var i;(i=t.call(this)||this).light=e,i.light.updateMatrixWorld(),i.matrix=e.matrixWorld,i.matrixAutoUpdate=!1,i.color=r;var a=new ms(n);a.rotateY(.5*Math.PI),i.material=new Xe({wireframe:!0,fog:!1,toneMapped:!1}),void 0===i.color&&(i.material.vertexColors=!0);var o=a.getAttribute("position"),s=new Float32Array(3*o.count);return a.setAttribute("color",new Je(s,3)),i.add(new On(a,i.material)),i.update(),i}ut(e,t);var n=e.prototype;return n.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},n.update=function(){var t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var e=t.geometry.getAttribute("color");Au.copy(this.light.color),Lu.copy(this.light.groundColor);for(var n=0,r=e.count;n<r;n++){var i=n<r/2?Au:Lu;e.setXYZ(n,i.r,i.g,i.b)}e.needsUpdate=!0}t.lookAt(Eu.setFromMatrixPosition(this.light.matrixWorld).negate())},e}(be),Cu=function(t){function e(e,n,r,i){var a;e=e||10,n=n||10,r=new Ve(void 0!==r?r:4473924),i=new Ve(void 0!==i?i:8947848);for(var o=n/2,s=e/n,c=e/2,l=[],u=[],h=0,d=0,p=-c;h<=n;h++,p+=s){l.push(-c,0,p,c,0,p),l.push(p,0,-c,p,0,c);var f=h===o?r:i;f.toArray(u,d),d+=3,f.toArray(u,d),d+=3,f.toArray(u,d),d+=3,f.toArray(u,d),d+=3}var m=new vn;m.setAttribute("position",new an(l,3)),m.setAttribute("color",new an(u,3));var v=new ja({vertexColors:!0,toneMapped:!1});return(a=t.call(this,m,v)||this).type="GridHelper",a}return ut(e,t),e}(to),Pu=function(t){function e(e,n,r,i,a,o){var s;e=e||10,n=n||16,r=r||8,i=i||64,a=new Ve(void 0!==a?a:4473924),o=new Ve(void 0!==o?o:8947848);for(var c=[],l=[],u=0;u<=n;u++){var h=u/n*(2*Math.PI),d=Math.sin(h)*e,p=Math.cos(h)*e;c.push(0,0,0),c.push(d,0,p);var f=1&u?a:o;l.push(f.r,f.g,f.b),l.push(f.r,f.g,f.b)}for(var m=0;m<=r;m++)for(var v=1&m?a:o,g=e-e/r*m,y=0;y<i;y++){var x=y/i*(2*Math.PI),_=Math.sin(x)*g,b=Math.cos(x)*g;c.push(_,0,b),l.push(v.r,v.g,v.b),x=(y+1)/i*(2*Math.PI),_=Math.sin(x)*g,b=Math.cos(x)*g,c.push(_,0,b),l.push(v.r,v.g,v.b)}var w=new vn;w.setAttribute("position",new an(c,3)),w.setAttribute("color",new an(l,3));var M=new ja({vertexColors:!0,toneMapped:!1});return(s=t.call(this,w,M)||this).type="PolarGridHelper",s}return ut(e,t),e}(to),Iu=new wt,Du=new wt,Ou=new wt,Nu=function(t){function e(e,n,r){var i;(i=t.call(this)||this).light=e,i.light.updateMatrixWorld(),i.matrix=e.matrixWorld,i.matrixAutoUpdate=!1,i.color=r,void 0===n&&(n=1);var a=new vn;a.setAttribute("position",new an([-n,n,0,n,n,0,n,-n,0,-n,-n,0,-n,n,0],3));var o=new ja({fog:!1,toneMapped:!1});return i.lightPlane=new Qa(a,o),i.add(i.lightPlane),(a=new vn).setAttribute("position",new an([0,0,0,0,0,1],3)),i.targetLine=new Qa(a,o),i.add(i.targetLine),i.update(),i}ut(e,t);var n=e.prototype;return n.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},n.update=function(){Iu.setFromMatrixPosition(this.light.matrixWorld),Du.setFromMatrixPosition(this.light.target.matrixWorld),Ou.subVectors(Du,Iu),this.lightPlane.lookAt(Du),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Du),this.targetLine.scale.z=Ou.length()},e}(be),Bu=new wt,zu=new kn,Gu=function(t){function e(e){var n,r=new vn,i=new ja({color:16777215,vertexColors:!0,toneMapped:!1}),a=[],o=[],s={},c=new Ve(16755200),l=new Ve(16711680),u=new Ve(43775),h=new Ve(16777215),d=new Ve(3355443);function p(t,e,n){f(t,n),f(e,n)}function f(t,e){a.push(0,0,0),o.push(e.r,e.g,e.b),void 0===s[t]&&(s[t]=[]),s[t].push(a.length/3-1)}return p("n1","n2",c),p("n2","n4",c),p("n4","n3",c),p("n3","n1",c),p("f1","f2",c),p("f2","f4",c),p("f4","f3",c),p("f3","f1",c),p("n1","f1",c),p("n2","f2",c),p("n3","f3",c),p("n4","f4",c),p("p","n1",l),p("p","n2",l),p("p","n3",l),p("p","n4",l),p("u1","u2",u),p("u2","u3",u),p("u3","u1",u),p("c","t",h),p("p","c",d),p("cn1","cn2",d),p("cn3","cn4",d),p("cf1","cf2",d),p("cf3","cf4",d),r.setAttribute("position",new an(a,3)),r.setAttribute("color",new an(o,3)),(n=t.call(this,r,i)||this).type="CameraHelper",n.camera=e,n.camera.updateProjectionMatrix&&n.camera.updateProjectionMatrix(),n.matrix=e.matrixWorld,n.matrixAutoUpdate=!1,n.pointMap=s,n.update(),n}return ut(e,t),e.prototype.update=function(){var t=this.geometry,e=this.pointMap;zu.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Fu("c",e,t,zu,0,0,-1),Fu("t",e,t,zu,0,0,1),Fu("n1",e,t,zu,-1,-1,-1),Fu("n2",e,t,zu,1,-1,-1),Fu("n3",e,t,zu,-1,1,-1),Fu("n4",e,t,zu,1,1,-1),Fu("f1",e,t,zu,-1,-1,1),Fu("f2",e,t,zu,1,-1,1),Fu("f3",e,t,zu,-1,1,1),Fu("f4",e,t,zu,1,1,1),Fu("u1",e,t,zu,.7,1.1,-1),Fu("u2",e,t,zu,-.7,1.1,-1),Fu("u3",e,t,zu,0,2,-1),Fu("cf1",e,t,zu,-1,0,1),Fu("cf2",e,t,zu,1,0,1),Fu("cf3",e,t,zu,0,-1,1),Fu("cf4",e,t,zu,0,1,1),Fu("cn1",e,t,zu,-1,0,-1),Fu("cn2",e,t,zu,1,0,-1),Fu("cn3",e,t,zu,0,-1,-1),Fu("cn4",e,t,zu,0,1,-1),t.getAttribute("position").needsUpdate=!0},e}(to);function Fu(t,e,n,r,i,a,o){Bu.set(i,a,o).unproject(r);var s=e[t];if(void 0!==s)for(var c=n.getAttribute("position"),l=0,u=s.length;l<u;l++)c.setXYZ(s[l],Bu.x,Bu.y,Bu.z)}var Uu,Hu,ku,Vu=new Tt,Wu=function(t){function e(e,n){var r;void 0===n&&(n=16776960);var i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),a=new Float32Array(24),o=new vn;return o.setIndex(new Je(i,1)),o.setAttribute("position",new Je(a,3)),(r=t.call(this,o,new ja({color:n,toneMapped:!1}))||this).object=e,r.type="BoxHelper",r.matrixAutoUpdate=!1,r.update(),r}ut(e,t);var n=e.prototype;return n.update=function(t){if(void 0!==t&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&Vu.setFromObject(this.object),!Vu.isEmpty()){var e=Vu.min,n=Vu.max,r=this.geometry.attributes.position,i=r.array;i[0]=n.x,i[1]=n.y,i[2]=n.z,i[3]=e.x,i[4]=n.y,i[5]=n.z,i[6]=e.x,i[7]=e.y,i[8]=n.z,i[9]=n.x,i[10]=e.y,i[11]=n.z,i[12]=n.x,i[13]=n.y,i[14]=e.z,i[15]=e.x,i[16]=n.y,i[17]=e.z,i[18]=e.x,i[19]=e.y,i[20]=e.z,i[21]=n.x,i[22]=e.y,i[23]=e.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}},n.setFromObject=function(t){return this.object=t,this.update(),this},n.copy=function(t){return to.prototype.copy.call(this,t),this.object=t.object,this},e}(to),ju=function(t){function e(e,n){var r;void 0===n&&(n=16776960);var i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),a=new vn;return a.setIndex(new Je(i,1)),a.setAttribute("position",new an([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),(r=t.call(this,a,new ja({color:n,toneMapped:!1}))||this).box=e,r.type="Box3Helper",r.geometry.computeBoundingSphere(),r}return ut(e,t),e.prototype.updateMatrixWorld=function(e){var n=this.box;n.isEmpty()||(n.getCenter(this.position),n.getSize(this.scale),this.scale.multiplyScalar(.5),t.prototype.updateMatrixWorld.call(this,e))},e}(to),qu=function(t){function e(e,n,r){var i,a=void 0!==r?r:16776960,o=new vn;o.setAttribute("position",new an([1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],3)),o.computeBoundingSphere(),(i=t.call(this,o,new ja({color:a,toneMapped:!1}))||this).type="PlaneHelper",i.plane=e,i.size=void 0===n?1:n;var s=new vn;return s.setAttribute("position",new an([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),s.computeBoundingSphere(),i.add(new On(s,new Xe({color:a,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1}))),i}return ut(e,t),e.prototype.updateMatrixWorld=function(e){var n=-this.plane.constant;Math.abs(n)<1e-8&&(n=1e-8),this.scale.set(.5*this.size,.5*this.size,n),this.children[0].material.side=n<0?1:0,this.lookAt(this.plane.normal),t.prototype.updateMatrixWorld.call(this,e)},e}(Qa),Xu=new wt,Yu=function(t){function e(e,n,r,i,a,o){var s;return(s=t.call(this)||this).type="ArrowHelper",void 0===e&&(e=new wt(0,0,1)),void 0===n&&(n=new wt(0,0,0)),void 0===r&&(r=1),void 0===i&&(i=16776960),void 0===a&&(a=.2*r),void 0===o&&(o=.2*a),void 0===Uu&&((Uu=new vn).setAttribute("position",new an([0,0,0,0,1,0],3)),(Hu=new wo(0,.5,1,5,1)).translate(0,-.5,0)),s.position.copy(n),s.line=new Qa(Uu,new ja({color:i,toneMapped:!1})),s.line.matrixAutoUpdate=!1,s.add(s.line),s.cone=new On(Hu,new Xe({color:i,toneMapped:!1})),s.cone.matrixAutoUpdate=!1,s.add(s.cone),s.setDirection(e),s.setLength(r,a,o),s}ut(e,t);var n=e.prototype;return n.setDirection=function(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Xu.set(t.z,0,-t.x).normalize();var e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Xu,e)}},n.setLength=function(t,e,n){void 0===e&&(e=.2*t),void 0===n&&(n=.2*e),this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()},n.setColor=function(t){this.line.material.color.set(t),this.cone.material.color.set(t)},n.copy=function(e){return t.prototype.copy.call(this,e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this},e}(be),Zu=function(t){function e(e){var n;void 0===e&&(e=1);var r=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=new vn;i.setAttribute("position",new an(r,3)),i.setAttribute("color",new an([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));var a=new ja({vertexColors:!0,toneMapped:!1});return(n=t.call(this,i,a)||this).type="AxesHelper",n}return ut(e,t),e}(to),Ju=Math.pow(2,8),Qu=[.125,.215,.35,.446,.526,.582],Ku=5+Qu.length,$u=20,th=((ku={})[3e3]=0,ku[3001]=1,ku[3002]=2,ku[3004]=3,ku[3005]=4,ku[3006]=5,ku[3007]=6,ku),eh=new $c,nh=dh(),rh=nh._lodPlanes,ih=nh._sizeLods,ah=nh._sigmas,oh=null,sh=(1+Math.sqrt(5))/2,ch=1/sh,lh=[new wt(1,1,1),new wt(-1,1,1),new wt(1,1,-1),new wt(-1,1,-1),new wt(0,sh,ch),new wt(0,sh,-ch),new wt(ch,0,sh),new wt(-ch,0,sh),new wt(sh,ch,0),new wt(-sh,ch,0)],uh=function(){function t(t){var e,n,r;this._renderer=t,this._pingPongRenderTarget=null,this._blurMaterial=(e=$u,n=new Float32Array(e),r=new wt(0,1,0),new Us({name:"SphericalGaussianBlur",defines:{n:e},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r},inputEncoding:{value:th[3e3]},outputEncoding:{value:th[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include <encodings_pars_fragment>\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}var e=t.prototype;return e.fromScene=function(t,e,n,r){void 0===e&&(e=0),void 0===n&&(n=.1),void 0===r&&(r=100),oh=this._renderer.getRenderTarget();var i=this._allocateTargets();return this._sceneToCubeUV(t,n,r,i),e>0&&this._blur(i,0,0,e),this._applyPMREM(i),this._cleanup(i),i},e.fromEquirectangular=function(t){return this._fromTexture(t)},e.fromCubemap=function(t){return this._fromTexture(t)},e.compileCubemapShader=function(){null===this._cubemapShader&&(this._cubemapShader=vh(),this._compileMaterial(this._cubemapShader))},e.compileEquirectangularShader=function(){null===this._equirectShader&&(this._equirectShader=mh(),this._compileMaterial(this._equirectShader))},e.dispose=function(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(var t=0;t<rh.length;t++)rh[t].dispose()},e._cleanup=function(t){this._pingPongRenderTarget.dispose(),this._renderer.setRenderTarget(oh),t.scissorTest=!1,fh(t,0,0,t.width,t.height)},e._fromTexture=function(t){oh=this._renderer.getRenderTarget();var e=this._allocateTargets(t);return this._textureToCubeUV(t,e),this._applyPMREM(e),this._cleanup(e),e},e._allocateTargets=function(t){var e={magFilter:d,minFilter:d,generateMipmaps:!1,type:y,format:1023,encoding:hh(t)?t.encoding:Z,depthBuffer:!1},n=ph(e);return n.depthBuffer=!t,this._pingPongRenderTarget=ph(e),n},e._compileMaterial=function(t){var e=new On(rh[0],t);this._renderer.compile(e,eh)},e._sceneToCubeUV=function(t,e,n,r){var i=new Vn(90,1,e,n),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],s=this._renderer,c=s.outputEncoding,l=s.toneMapping,u=s.getClearColor(),h=s.getClearAlpha();s.toneMapping=0,s.outputEncoding=q;var d=t.background;if(d&&d.isColor){d.convertSRGBToLinear();var p=Math.max(d.r,d.g,d.b),f=Math.min(Math.max(Math.ceil(Math.log2(p)),-128),127);d=d.multiplyScalar(Math.pow(2,-f));var m=(f+128)/255;s.setClearColor(d,m),t.background=null}for(var v=0;v<6;v++){var g=v%3;0==g?(i.up.set(0,a[v],0),i.lookAt(o[v],0,0)):1==g?(i.up.set(0,0,a[v]),i.lookAt(0,o[v],0)):(i.up.set(0,a[v],0),i.lookAt(0,0,o[v])),fh(r,g*Ju,v>2?Ju:0,Ju,Ju),s.setRenderTarget(r),s.render(t,i)}s.toneMapping=l,s.outputEncoding=c,s.setClearColor(u,h)},e._textureToCubeUV=function(t,e){var n=this._renderer;t.isCubeTexture?null==this._cubemapShader&&(this._cubemapShader=vh()):null==this._equirectShader&&(this._equirectShader=mh());var r=t.isCubeTexture?this._cubemapShader:this._equirectShader,i=new On(rh[0],r),a=r.uniforms;a.envMap.value=t,t.isCubeTexture||a.texelSize.value.set(1/t.image.width,1/t.image.height),a.inputEncoding.value=th[t.encoding],a.outputEncoding.value=th[e.texture.encoding],fh(e,0,0,3*Ju,2*Ju),n.setRenderTarget(e),n.render(i,eh)},e._applyPMREM=function(t){var e=this._renderer,n=e.autoClear;e.autoClear=!1;for(var r=1;r<Ku;r++){var i=Math.sqrt(ah[r]*ah[r]-ah[r-1]*ah[r-1]),a=lh[(r-1)%lh.length];this._blur(t,r-1,r,i,a)}e.autoClear=n},e._blur=function(t,e,n,r,i){var a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,r,"latitudinal",i),this._halfBlur(a,t,n,n,r,"longitudinal",i)},e._halfBlur=function(t,e,n,r,i,a,o){var s=this._renderer,c=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&console.error("blur direction must be either latitudinal or longitudinal!");var l=new On(rh[r],c),u=c.uniforms,h=ih[n]-1,d=isFinite(i)?Math.PI/(2*h):2*Math.PI/39,p=i/d,f=isFinite(i)?1+Math.floor(3*p):$u;f>$u&&console.warn("sigmaRadians, "+i+", is too large and will clip, as it requested "+f+" samples when the maximum is set to "+$u);for(var m=[],v=0,g=0;g<$u;++g){var y=g/p,x=Math.exp(-y*y/2);m.push(x),0==g?v+=x:g<f&&(v+=2*x)}for(var _=0;_<m.length;_++)m[_]=m[_]/v;u.envMap.value=t.texture,u.samples.value=f,u.weights.value=m,u.latitudinal.value="latitudinal"===a,o&&(u.poleAxis.value=o),u.dTheta.value=d,u.mipInt.value=8-n,u.inputEncoding.value=th[t.texture.encoding],u.outputEncoding.value=th[t.texture.encoding];var b=ih[r];fh(e,3*Math.max(0,Ju-2*b),(0===r?0:2*Ju)+2*b*(r>4?r-8+4:0),3*b,2*b),s.setRenderTarget(e),s.render(l,eh)},t}();function hh(t){return void 0!==t&&t.type===y&&(t.encoding===q||t.encoding===X||t.encoding===Y)}function dh(){for(var t=[],e=[],n=[],r=8,i=0;i<Ku;i++){var a=Math.pow(2,r);e.push(a);var o=1/a;i>4?o=Qu[i-8+4-1]:0==i&&(o=0),n.push(o);for(var s=1/(a-1),c=-s/2,l=1+s/2,u=[c,c,l,c,l,l,c,c,l,l,c,l],h=new Float32Array(108),d=new Float32Array(72),p=new Float32Array(36),f=0;f<6;f++){var m=f%3*2/3-1,v=f>2?0:-1,g=[m,v,0,m+2/3,v,0,m+2/3,v+1,0,m,v,0,m+2/3,v+1,0,m,v+1,0];h.set(g,18*f),d.set(u,12*f);var y=[f,f,f,f,f,f];p.set(y,6*f)}var x=new vn;x.setAttribute("position",new Je(h,3)),x.setAttribute("uv",new Je(d,2)),x.setAttribute("faceIndex",new Je(p,1)),t.push(x),r>4&&r--}return{_lodPlanes:t,_sizeLods:e,_sigmas:n}}function ph(t){var e=new xt(3*Ju,3*Ju,t);return e.texture.mapping=s,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function fh(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function mh(){return new Us({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:new pt(1,1)},inputEncoding:{value:th[3e3]},outputEncoding:{value:th[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform vec2 texelSize;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include <encodings_pars_fragment>\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function vh(){return new Us({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:th[3e3]},outputEncoding:{value:th[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include <encodings_pars_fragment>\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function gh(t){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Pc.call(this,t),this.type="catmullrom",this.closed=!0}function yh(t){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Pc.call(this,t),this.type="catmullrom"}function xh(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Pc.call(this,t),this.type="catmullrom"}Mc.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(Mc.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Object.assign(Vc.prototype,{createPointsGeometry:function(t){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var e=new yo,n=0,r=t.length;n<r;n++){var i=t[n];e.vertices.push(new wt(i.x,i.y,i.z||0))}return e}}),Object.assign(Wc.prototype,{fromPoints:function(t){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(t)}}),gh.prototype=Object.create(Pc.prototype),yh.prototype=Object.create(Pc.prototype),xh.prototype=Object.create(Pc.prototype),Object.assign(xh.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),Cu.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},Mu.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Object.assign(fc.prototype,{extractUrlBase:function(t){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),sl.extractUrlBase(t)}}),fc.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Object.assign(pu.prototype,{center:function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},size:function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)}}),Object.assign(Tt.prototype,{center:function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionSphere:function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},size:function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)}}),Object.assign(Ht.prototype,{empty:function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()}}),Qn.prototype.setFromMatrix=function(t){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(t)},vu.prototype.center=function(t){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(t)},Object.assign(st,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(t){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),st.floorPowerOfTwo(t)},nextPowerOfTwo:function(t){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),st.ceilPowerOfTwo(t)}}),Object.assign(ft.prototype,{flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},multiplyVector3:function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBufferAttribute:function(t){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}}),Object.assign(Jt.prototype,{extractPosition:function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},getPosition:function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new wt).setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector4:function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},crossVector:function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBufferAttribute:function(t){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(t,e,n,r,i,a){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(t,e,r,n,i,a)}}),Te.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)},bt.prototype.multiplyVector3=function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)},Object.assign(Zt.prototype,{isIntersectionBox:function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionPlane:function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},isIntersectionSphere:function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)}}),Object.assign(Be.prototype,{area:function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(t,e){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(t,e)},midpoint:function(t){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(t)},normal:function(t){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(t)},plane:function(t){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(t)}}),Object.assign(Be,{barycoordFromPoint:function(t,e,n,r,i){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Be.getBarycoord(t,e,n,r,i)},normal:function(t,e,n,r){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),Be.getNormal(t,e,n,r)}}),Object.assign(jc.prototype,{extractAllPoints:function(t){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(t)},extrude:function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new us(this,t)},makeGeometry:function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new Ss(this,t)}}),Object.assign(pt.prototype,{fromAttribute:function(t,e,n){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},distanceToManhattan:function(t){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(wt.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},getScaleFromMatrix:function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},getColumnFromMatrix:function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},applyProjection:function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},fromAttribute:function(t,e,n){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},distanceToManhattan:function(t){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(yt.prototype,{fromAttribute:function(t,e,n){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(yo.prototype,{computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")},applyMatrix:function(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}}),Object.assign(be.prototype,{getChildByName:function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},applyMatrix:function(t){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}}),Object.defineProperties(be.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(t){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=t}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.assign(On.prototype,{setDrawMode:function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}),Object.defineProperties(On.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),0},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),Object.defineProperties(Oa.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(Ga.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),Na.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(Mc.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(t){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=t}}),Vn.prototype.setLens=function(t,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==e&&(this.filmGauge=e),this.setFocalLength(t)},Object.defineProperties(qc.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(t){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=t}},shadowCameraLeft:{set:function(t){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=t}},shadowCameraRight:{set:function(t){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=t}},shadowCameraTop:{set:function(t){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=t}},shadowCameraBottom:{set:function(t){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=t}},shadowCameraNear:{set:function(t){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=t}},shadowCameraFar:{set:function(t){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=t}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(t){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=t}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(t){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=t}},shadowMapHeight:{set:function(t){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=t}}}),Object.defineProperties(Je.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===et},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(et)}}}),Object.assign(Je.prototype,{setDynamic:function(t){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?et:tt),this},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},setArray:function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(vn.prototype,{addIndex:function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},addAttribute:function(t,e){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(e),this):this.setAttribute(t,e):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(t,new Je(arguments[1],arguments[2])))},addDrawCall:function(t,e,n){void 0!==n&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(t,e)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},removeAttribute:function(t){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(t)},applyMatrix:function(t){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}}),Object.defineProperties(vn.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(cl.prototype,{maxInstancedCount:{get:function(){return console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount},set:function(t){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount=t}}}),Object.defineProperties(su.prototype,{linePrecision:{get:function(){return console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold},set:function(t){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold=t}}}),Object.defineProperties(ca.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===et},set:function(t){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(t)}}}),Object.assign(ca.prototype,{setDynamic:function(t){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?et:tt),this},setArray:function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(cs.prototype,{getArrays:function(){console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.")}}),Object.assign(sa.prototype,{dispose:function(){console.error("THREE.Scene: .dispose() has been removed.")}}),Object.defineProperties(iu.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(qe.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new Ve}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===t}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(t){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=t}}}),Object.defineProperties(Vs.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(ks.prototype,{transparency:{get:function(){return console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission},set:function(t){console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission=t}}}),Object.defineProperties(Hn.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(t){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=t}}}),Object.assign(ra.prototype,{clearTarget:function(t,e,n,r){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(t),this.clear(e,n,r)},animate:function(t){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(t)},getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},allocTextureUnit:function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},setTextureCube:function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()}}),Object.defineProperties(ra.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=t}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=t}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(t){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===t?X:q}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(Yi.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(xt.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=t}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=t}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=t}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=t}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(t){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=t}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(t){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=t}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(t){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=t}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(t){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=t}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(t){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=t}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(t){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=t}}}),Object.defineProperties(Nl.prototype,{load:{value:function(t){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var e=this;return(new Ml).load(t,(function(t){e.setBuffer(t)})),this}},startTime:{set:function(){console.warn("THREE.Audio: .startTime is now .play( delay ).")}}}),Hl.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},jn.prototype.updateCubeMap=function(t,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(t,e)},jn.prototype.clear=function(t,e,n,r){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(t,e,n,r)};var _h={merge:function(t,e,n){var r;console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead."),e.isMesh&&(e.matrixAutoUpdate&&e.updateMatrix(),r=e.matrix,e=e.geometry),t.merge(e,r,n)},center:function(t){return console.warn("THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead."),t.center()}};mt.crossOrigin=void 0,mt.loadTexture=function(t,e,n,r){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var i=new wc;i.setCrossOrigin(this.crossOrigin);var a=i.load(t,n,void 0,r);return e&&(a.mapping=e),a},mt.loadTextureCube=function(t,e,n,r){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var i=new _c;i.setCrossOrigin(this.crossOrigin);var a=i.load(t,n,void 0,r);return e&&(a.mapping=e),a},mt.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},mt.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};var bh={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},attach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")}};"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"122"}})),t.ACESFilmicToneMapping=4,t.AddEquation=e,t.AddOperation=2,t.AdditiveAnimationBlendMode=j,t.AdditiveBlending=2,t.AlphaFormat=1021,t.AlwaysDepth=1,t.AlwaysStencilFunc=519,t.AmbientLight=nl,t.AmbientLightProbe=Tl,t.AnimationClip=lc,t.AnimationLoader=gc,t.AnimationMixer=ru,t.AnimationObjectGroup=eu,t.AnimationUtils=Js,t.ArcCurve=Tc,t.ArrayCamera=Ki,t.ArrowHelper=Yu,t.Audio=Nl,t.AudioAnalyser=Hl,t.AudioContext=wl,t.AudioListener=Ol,t.AudioLoader=Ml,t.AxesHelper=Zu,t.AxisHelper=function(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Zu(t)},t.BackSide=1,t.BasicDepthPacking=3200,t.BasicShadowMap=0,t.BinaryTextureLoader=function(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new bc(t)},t.Bone=Fa,t.BooleanKeyframeTrack=nc,t.BoundingBoxHelper=function(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Wu(t,e)},t.Box2=pu,t.Box3=Tt,t.Box3Helper=ju,t.BoxBufferGeometry=zn,t.BoxGeometry=xo,t.BoxHelper=Wu,t.BufferAttribute=Je,t.BufferGeometry=vn,t.BufferGeometryLoader=ul,t.ByteType=1010,t.Cache=hc,t.Camera=kn,t.CameraHelper=Gu,t.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been removed")},t.CanvasTexture=ho,t.CatmullRomCurve3=Pc,t.CineonToneMapping=3,t.CircleBufferGeometry=_o,t.CircleGeometry=bo,t.ClampToEdgeWrapping=u,t.Clock=Rl,t.ClosedSplineCurve3=gh,t.Color=Ve,t.ColorKeyframeTrack=rc,t.CompressedTexture=uo,t.CompressedTextureLoader=yc,t.ConeBufferGeometry=To,t.ConeGeometry=So,t.CubeCamera=jn,t.CubeGeometry=xo,t.CubeReflectionMapping=r,t.CubeRefractionMapping=i,t.CubeTexture=qn,t.CubeTextureLoader=_c,t.CubeUVReflectionMapping=s,t.CubeUVRefractionMapping=c,t.CubicBezierCurve=Nc,t.CubicBezierCurve3=Bc,t.CubicInterpolant=Ks,t.CullFaceBack=1,t.CullFaceFront=2,t.CullFaceFrontBack=3,t.CullFaceNone=0,t.Curve=Mc,t.CurvePath=Vc,t.CustomBlending=5,t.CustomToneMapping=5,t.CylinderBufferGeometry=wo,t.CylinderGeometry=Mo,t.Cylindrical=hu,t.DataTexture=Yn,t.DataTexture2DArray=yr,t.DataTexture3D=xr,t.DataTextureLoader=bc,t.DecrementStencilOp=7683,t.DecrementWrapStencilOp=34056,t.DefaultLoadingManager=pc,t.DepthFormat=E,t.DepthStencilFormat=A,t.DepthTexture=po,t.DirectionalLight=el,t.DirectionalLightHelper=Nu,t.DiscreteInterpolant=tc,t.DodecahedronBufferGeometry=Ao,t.DodecahedronGeometry=Lo,t.DoubleSide=2,t.DstAlphaFactor=206,t.DstColorFactor=208,t.DynamicBufferAttribute=function(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new Je(t,e).setUsage(et)},t.DynamicCopyUsage=35050,t.DynamicDrawUsage=et,t.DynamicReadUsage=35049,t.EdgesGeometry=Do,t.EdgesHelper=function(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new to(new Do(t.geometry),new ja({color:void 0!==e?e:16777215}))},t.EllipseCurve=Sc,t.EqualDepth=4,t.EqualStencilFunc=514,t.EquirectangularReflectionMapping=a,t.EquirectangularRefractionMapping=o,t.Euler=ie,t.EventDispatcher=rt,t.ExtrudeBufferGeometry=cs,t.ExtrudeGeometry=us,t.Face3=We,t.Face4=function(t,e,n,r,i,a,o){return console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead."),new We(t,e,n,i,a,o)},t.FaceColors=1,t.FileLoader=vc,t.FlatShading=1,t.Float32Attribute=function(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new an(t,e)},t.Float32BufferAttribute=an,t.Float64Attribute=function(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new on(t,e)},t.Float64BufferAttribute=on,t.FloatType=b,t.Fog=oa,t.FogExp2=aa,t.Font=xl,t.FontLoader=bl,t.FrontSide=0,t.Frustum=Qn,t.GLBufferAttribute=ou,t.GLSL1="100",t.GLSL3=nt,t.GammaEncoding=Y,t.Geometry=yo,t.GeometryUtils=_h,t.GreaterDepth=6,t.GreaterEqualDepth=5,t.GreaterEqualStencilFunc=518,t.GreaterStencilFunc=516,t.GridHelper=Cu,t.Group=$i,t.HalfFloatType=w,t.HemisphereLight=Xc,t.HemisphereLightHelper=Ru,t.HemisphereLightProbe=Sl,t.IcosahedronBufferGeometry=hs,t.IcosahedronGeometry=ds,t.ImageBitmapLoader=gl,t.ImageLoader=xc,t.ImageUtils=mt,t.ImmediateRenderObject=gu,t.IncrementStencilOp=7682,t.IncrementWrapStencilOp=34055,t.InstancedBufferAttribute=ll,t.InstancedBufferGeometry=cl,t.InstancedInterleavedBuffer=au,t.InstancedMesh=Wa,t.Int16Attribute=function(t,e){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new tn(t,e)},t.Int16BufferAttribute=tn,t.Int32Attribute=function(t,e){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new nn(t,e)},t.Int32BufferAttribute=nn,t.Int8Attribute=function(t,e){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new Qe(t,e)},t.Int8BufferAttribute=Qe,t.IntType=1013,t.InterleavedBuffer=ca,t.InterleavedBufferAttribute=ha,t.Interpolant=Qs,t.InterpolateDiscrete=G,t.InterpolateLinear=F,t.InterpolateSmooth=U,t.InvertStencilOp=5386,t.JSONLoader=function(){console.error("THREE.JSONLoader has been removed.")},t.KeepStencilOp=$,t.KeyframeTrack=ec,t.LOD=Oa,t.LatheBufferGeometry=ps,t.LatheGeometry=fs,t.Layers=se,t.LensFlare=function(){console.error("THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js")},t.LessDepth=2,t.LessEqualDepth=3,t.LessEqualStencilFunc=515,t.LessStencilFunc=513,t.Light=qc,t.LightProbe=al,t.Line=Qa,t.Line3=vu,t.LineBasicMaterial=ja,t.LineCurve=zc,t.LineCurve3=Gc,t.LineDashedMaterial=Ys,t.LineLoop=eo,t.LinePieces=1,t.LineSegments=to,t.LineStrip=0,t.LinearEncoding=q,t.LinearFilter=m,t.LinearInterpolant=$s,t.LinearMipMapLinearFilter=1008,t.LinearMipMapNearestFilter=1007,t.LinearMipmapLinearFilter=g,t.LinearMipmapNearestFilter=v,t.LinearToneMapping=1,t.Loader=fc,t.LoaderUtils=sl,t.LoadingManager=dc,t.LogLuvEncoding=3003,t.LoopOnce=2200,t.LoopPingPong=2202,t.LoopRepeat=2201,t.LuminanceAlphaFormat=1025,t.LuminanceFormat=1024,t.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},t.Material=qe,t.MaterialLoader=ol,t.Math=st,t.MathUtils=st,t.Matrix3=ft,t.Matrix4=Jt,t.MaxEquation=104,t.Mesh=On,t.MeshBasicMaterial=Xe,t.MeshDepthMaterial=qi,t.MeshDistanceMaterial=Xi,t.MeshFaceMaterial=function(t){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),t},t.MeshLambertMaterial=qs,t.MeshMatcapMaterial=Xs,t.MeshNormalMaterial=js,t.MeshPhongMaterial=Vs,t.MeshPhysicalMaterial=ks,t.MeshStandardMaterial=Hs,t.MeshToonMaterial=Ws,t.MinEquation=103,t.MirroredRepeatWrapping=h,t.MixOperation=1,t.MultiMaterial=function(t){return void 0===t&&(t=[]),console.warn("THREE.MultiMaterial has been removed. Use an Array instead."),t.isMultiMaterial=!0,t.materials=t,t.clone=function(){return t.slice()},t},t.MultiplyBlending=4,t.MultiplyOperation=0,t.NearestFilter=d,t.NearestMipMapLinearFilter=1005,t.NearestMipMapNearestFilter=1004,t.NearestMipmapLinearFilter=f,t.NearestMipmapNearestFilter=p,t.NeverDepth=0,t.NeverStencilFunc=512,t.NoBlending=0,t.NoColors=0,t.NoToneMapping=0,t.NormalAnimationBlendMode=W,t.NormalBlending=1,t.NotEqualDepth=7,t.NotEqualStencilFunc=517,t.NumberKeyframeTrack=ic,t.Object3D=be,t.ObjectLoader=pl,t.ObjectSpaceNormalMap=1,t.OctahedronBufferGeometry=ms,t.OctahedronGeometry=vs,t.OneFactor=201,t.OneMinusDstAlphaFactor=207,t.OneMinusDstColorFactor=209,t.OneMinusSrcAlphaFactor=205,t.OneMinusSrcColorFactor=203,t.OrthographicCamera=$c,t.PCFShadowMap=1,t.PCFSoftShadowMap=2,t.PMREMGenerator=uh,t.ParametricBufferGeometry=gs,t.ParametricGeometry=ys,t.Particle=function(t){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new Ta(t)},t.ParticleBasicMaterial=function(t){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new no(t)},t.ParticleSystem=function(t,e){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new so(t,e)},t.ParticleSystemMaterial=function(t){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new no(t)},t.Path=Wc,t.PerspectiveCamera=Vn,t.Plane=Te,t.PlaneBufferGeometry=tr,t.PlaneGeometry=xs,t.PlaneHelper=qu,t.PointCloud=function(t,e){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new so(t,e)},t.PointCloudMaterial=function(t){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new no(t)},t.PointLight=Kc,t.PointLightHelper=Tu,t.Points=so,t.PointsMaterial=no,t.PolarGridHelper=Pu,t.PolyhedronBufferGeometry=Eo,t.PolyhedronGeometry=_s,t.PositionalAudio=Ul,t.PropertyBinding=tu,t.PropertyMixer=kl,t.QuadraticBezierCurve=Fc,t.QuadraticBezierCurve3=Uc,t.Quaternion=bt,t.QuaternionKeyframeTrack=oc,t.QuaternionLinearInterpolant=ac,t.REVISION="122",t.RGBADepthPacking=3201,t.RGBAFormat=T,t.RGBAIntegerFormat=1033,t.RGBA_ASTC_10x10_Format=37819,t.RGBA_ASTC_10x5_Format=37816,t.RGBA_ASTC_10x6_Format=37817,t.RGBA_ASTC_10x8_Format=37818,t.RGBA_ASTC_12x10_Format=37820,t.RGBA_ASTC_12x12_Format=37821,t.RGBA_ASTC_4x4_Format=37808,t.RGBA_ASTC_5x4_Format=37809,t.RGBA_ASTC_5x5_Format=37810,t.RGBA_ASTC_6x5_Format=37811,t.RGBA_ASTC_6x6_Format=37812,t.RGBA_ASTC_8x5_Format=37813,t.RGBA_ASTC_8x6_Format=37814,t.RGBA_ASTC_8x8_Format=37815,t.RGBA_BPTC_Format=36492,t.RGBA_ETC2_EAC_Format=z,t.RGBA_PVRTC_2BPPV1_Format=N,t.RGBA_PVRTC_4BPPV1_Format=O,t.RGBA_S3TC_DXT1_Format=R,t.RGBA_S3TC_DXT3_Format=C,t.RGBA_S3TC_DXT5_Format=P,t.RGBDEncoding=K,t.RGBEEncoding=Z,t.RGBEFormat=1023,t.RGBFormat=S,t.RGBIntegerFormat=1032,t.RGBM16Encoding=Q,t.RGBM7Encoding=J,t.RGB_ETC1_Format=36196,t.RGB_ETC2_Format=B,t.RGB_PVRTC_2BPPV1_Format=D,t.RGB_PVRTC_4BPPV1_Format=I,t.RGB_S3TC_DXT1_Format=L,t.RGFormat=1030,t.RGIntegerFormat=1031,t.RawShaderMaterial=Us,t.Ray=Zt,t.Raycaster=su,t.RectAreaLight=rl,t.RedFormat=1028,t.RedIntegerFormat=1029,t.ReinhardToneMapping=2,t.RepeatWrapping=l,t.ReplaceStencilOp=7681,t.ReverseSubtractEquation=102,t.RingBufferGeometry=bs,t.RingGeometry=ws,t.SRGB8_ALPHA8_ASTC_10x10_Format=37851,t.SRGB8_ALPHA8_ASTC_10x5_Format=37848,t.SRGB8_ALPHA8_ASTC_10x6_Format=37849,t.SRGB8_ALPHA8_ASTC_10x8_Format=37850,t.SRGB8_ALPHA8_ASTC_12x10_Format=37852,t.SRGB8_ALPHA8_ASTC_12x12_Format=37853,t.SRGB8_ALPHA8_ASTC_4x4_Format=37840,t.SRGB8_ALPHA8_ASTC_5x4_Format=37841,t.SRGB8_ALPHA8_ASTC_5x5_Format=37842,t.SRGB8_ALPHA8_ASTC_6x5_Format=37843,t.SRGB8_ALPHA8_ASTC_6x6_Format=37844,t.SRGB8_ALPHA8_ASTC_8x5_Format=37845,t.SRGB8_ALPHA8_ASTC_8x6_Format=37846,t.SRGB8_ALPHA8_ASTC_8x8_Format=37847,t.Scene=sa,t.SceneUtils=bh,t.ShaderChunk=er,t.ShaderLib=rr,t.ShaderMaterial=Hn,t.ShadowMaterial=Fs,t.Shape=jc,t.ShapeBufferGeometry=Ms,t.ShapeGeometry=Ss,t.ShapePath=yl,t.ShapeUtils=as,t.ShortType=1011,t.Skeleton=Ga,t.SkeletonHelper=Mu,t.SkinnedMesh=Na,t.SmoothShading=2,t.Sphere=Ht,t.SphereBufferGeometry=Ts,t.SphereGeometry=Es,t.Spherical=uu,t.SphericalHarmonics3=il,t.Spline=xh,t.SplineCurve=Hc,t.SplineCurve3=yh,t.SpotLight=Jc,t.SpotLightHelper=xu,t.Sprite=Ta,t.SpriteMaterial=da,t.SrcAlphaFactor=204,t.SrcAlphaSaturateFactor=210,t.SrcColorFactor=202,t.StaticCopyUsage=35046,t.StaticDrawUsage=tt,t.StaticReadUsage=35045,t.StereoCamera=Ll,t.StreamCopyUsage=35042,t.StreamDrawUsage=35040,t.StreamReadUsage=35041,t.StringKeyframeTrack=sc,t.SubtractEquation=101,t.SubtractiveBlending=3,t.TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},t.TangentSpaceNormalMap=0,t.TetrahedronBufferGeometry=As,t.TetrahedronGeometry=Ls,t.TextBufferGeometry=Rs,t.TextGeometry=Cs,t.Texture=gt,t.TextureLoader=wc,t.TorusBufferGeometry=Ps,t.TorusGeometry=Is,t.TorusKnotBufferGeometry=Ds,t.TorusKnotGeometry=Os,t.Triangle=Be,t.TriangleFanDrawMode=2,t.TriangleStripDrawMode=1,t.TrianglesDrawMode=0,t.TubeBufferGeometry=Ns,t.TubeGeometry=Bs,t.UVMapping=n,t.Uint16Attribute=function(t,e){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new en(t,e)},t.Uint16BufferAttribute=en,t.Uint32Attribute=function(t,e){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new rn(t,e)},t.Uint32BufferAttribute=rn,t.Uint8Attribute=function(t,e){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new Ke(t,e)},t.Uint8BufferAttribute=Ke,t.Uint8ClampedAttribute=function(t,e){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new $e(t,e)},t.Uint8ClampedBufferAttribute=$e,t.Uniform=iu,t.UniformsLib=nr,t.UniformsUtils=Un,t.UnsignedByteType=y,t.UnsignedInt248Type=M,t.UnsignedIntType=_,t.UnsignedShort4444Type=1017,t.UnsignedShort5551Type=1018,t.UnsignedShort565Type=1019,t.UnsignedShortType=x,t.VSMShadowMap=3,t.Vector2=pt,t.Vector3=wt,t.Vector4=yt,t.VectorKeyframeTrack=cc,t.Vertex=function(t,e,n){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new wt(t,e,n)},t.VertexColors=2,t.VideoTexture=lo,t.WebGL1Renderer=ia,t.WebGLCubeRenderTarget=Xn,t.WebGLMultisampleRenderTarget=_t,t.WebGLRenderTarget=xt,t.WebGLRenderTargetCube=function(t,e,n){return console.warn("THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options )."),new Xn(t,n)},t.WebGLRenderer=ra,t.WebGLUtils=Qi,t.WireframeGeometry=zs,t.WireframeHelper=function(t,e){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new to(new zs(t.geometry),new ja({color:void 0!==e?e:16777215}))},t.WrapAroundEnding=V,t.XHRLoader=function(t){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new vc(t)},t.ZeroCurvatureEnding=H,t.ZeroFactor=200,t.ZeroSlopeEnding=k,t.ZeroStencilOp=0,t.sRGBEncoding=X,Object.defineProperty(t,"__esModule",{value:!0})})); function
|
/plugin/c3chart/assets/ |
H A D | d3.min.js | 2 …Oa(e,t/o);return n}function n(t){if(!isNaN(t=+t))return r[ba(i,t)]}var e=[],r=[],i=[];return n.inv…
|
/plugin/bpmnioeditor/vendor/bpmnio-js/ |
H A D | bpmn-modeler.production.min.js | 33 …Oa(e){return function(t,n,i){var r={x:n.x,y:n.y};return["x","y"].forEach((function(o){var a=e[o];i… function
|
/plugin/amcharts/assets/amcharts/plugins/export/libs/pdfmake/ |
H A D | pdfmake.min.js | 8 …Oa;return g(p,d)}function ln(t,e,n,r,i,o,a){var s=-1,h=t.length,u=e.length,l=!0;if(h!=u&&!(i&&u>h)… function
|