diff --git a/lib/sequence-diagram.js b/lib/sequence-diagram.js index e378785..cd0c81f 100644 --- a/lib/sequence-diagram.js +++ b/lib/sequence-diagram.js @@ -3104,7 +3104,130 @@ define('svg/SVGTextBlock',['./SVGUtilities'], (svg) => { return SVGTextBlock; }); -define('svg/SVGShapes',['./SVGUtilities', './SVGTextBlock'], (svg, SVGTextBlock) => { +define('svg/PatternedLine',[],() => { + 'use strict'; + + return class PatternedLine { + constructor(pattern = null, phase = 0) { + this.pattern = pattern; + this.dw = pattern && pattern.partWidth; + this.points = []; + this.phase = phase; + this.x = null; + this.y = null; + this.disconnect = 0; + } + + _nextDelta() { + return this.pattern.getDelta(this.phase ++); + } + + _link() { + if(this.disconnect === 2) { + this.points.push(this.x + ' ' + this.y); + this.disconnect = 0; + } + } + + cap() { + if(this.disconnect > 0) { + this.points.push(this.x + ' ' + this.y); + this.disconnect = 0; + } + return this; + } + + move(x, y) { + this.cap(); + this.x = x; + this.y = y; + this.disconnect = 2; + return this; + } + + line(x, y) { + if(this.pattern) { + const len = Math.sqrt( + (x - this.x) * (x - this.x) + + (y - this.y) * (y - this.y) + ); + const dx1 = (x - this.x) / len; + const dy1 = (y - this.y) / len; + const dx2 = -dy1; + const dy2 = dx1; + + for(let pos = 0; pos + this.dw <= len; pos += this.dw) { + const delta = this._nextDelta(); + this.points.push( + (this.x + pos * dx1 + delta * dx2) + ' ' + + (this.y + pos * dy1 + delta * dy2) + ); + } + this.disconnect = 1; + } else { + this._link(); + this.disconnect = 2; + } + + this.x = x; + this.y = y; + return this; + } + + arc(cx, cy, theta) { + const radius = Math.sqrt( + (cx - this.x) * (cx - this.x) + + (cy - this.y) * (cy - this.y) + ); + const theta1 = Math.atan2(cx - this.x, cy - this.y); + const nextX = cx + Math.sin(theta1 + theta) * radius; + const nextY = cy - Math.cos(theta1 + theta) * radius; + + if(this.pattern) { + const dir = (theta < 0 ? 1 : -1); + const dt = this.dw / radius; + + for(let t = theta1; t + dt <= theta1 + theta; t += dt) { + const delta = this._nextDelta() * dir; + this.points.push( + (cx + Math.sin(t) * (radius + delta)) + ' ' + + (cy - Math.cos(t) * (radius + delta)) + ); + } + this.disconnect = 1; + } else { + this.points.push( + this.x + ' ' + this.y + + 'A' + radius + ' ' + radius + ' 0 ' + + ((theta < 0) ? '0 ' : '1 ') + + '1 ' + + nextX + ' ' + nextY + ); + this.disconnect = 0; + } + + this.x = nextX; + this.y = nextY; + + return this; + } + + asPath() { + this._link(); + return 'M' + this.points.join('L'); + } + }; +}); + +define('svg/SVGShapes',[ + './SVGUtilities', + './SVGTextBlock', + './PatternedLine', +], ( + svg, + SVGTextBlock, + PatternedLine +) => { 'use strict'; function renderBox(attrs, position) { @@ -3218,6 +3341,7 @@ define('svg/SVGShapes',['./SVGUtilities', './SVGTextBlock'], (svg, SVGTextBlock) renderNote, renderBoxedText, TextBlock: SVGTextBlock, + PatternedLine, }; }); @@ -5218,122 +5342,13 @@ define('sequence/Exporter',[],() => { }; }); -define('svg/PatternedLine',[],() => { - 'use strict'; - - return class PatternedLine { - constructor(pattern = null, phase = 0) { - this.pattern = pattern; - this.dw = pattern && pattern.partWidth; - this.points = []; - this.phase = phase; - this.x = null; - this.y = null; - this.disconnect = 0; - } - - _nextDelta() { - return this.pattern.getDelta(this.phase ++); - } - - _link() { - if(this.disconnect === 2) { - this.points.push(this.x + ' ' + this.y); - this.disconnect = 0; - } - } - - cap() { - if(this.disconnect > 0) { - this.points.push(this.x + ' ' + this.y); - this.disconnect = 0; - } - return this; - } - - move(x, y) { - this.cap(); - this.x = x; - this.y = y; - this.disconnect = 2; - return this; - } - - line(x, y) { - if(this.pattern) { - const len = Math.sqrt( - (x - this.x) * (x - this.x) + - (y - this.y) * (y - this.y) - ); - const dx1 = (x - this.x) / len; - const dy1 = (y - this.y) / len; - const dx2 = -dy1; - const dy2 = dx1; - - for(let pos = 0; pos + this.dw <= len; pos += this.dw) { - const delta = this._nextDelta(); - this.points.push( - (this.x + pos * dx1 + delta * dx2) + ' ' + - (this.y + pos * dy1 + delta * dy2) - ); - } - this.disconnect = 1; - } else { - this._link(); - this.disconnect = 2; - } - - this.x = x; - this.y = y; - return this; - } - - arc(cx, cy, theta) { - const radius = Math.sqrt( - (cx - this.x) * (cx - this.x) + - (cy - this.y) * (cy - this.y) - ); - const theta1 = Math.atan2(cx - this.x, cy - this.y); - const nextX = cx + Math.sin(theta1 + theta) * radius; - const nextY = cy - Math.cos(theta1 + theta) * radius; - - if(this.pattern) { - const dir = (theta < 0 ? 1 : -1); - const dt = this.dw / radius; - - for(let t = theta1; t + dt <= theta1 + theta; t += dt) { - const delta = this._nextDelta() * dir; - this.points.push( - (cx + Math.sin(t) * (radius + delta)) + ' ' + - (cy - Math.cos(t) * (radius + delta)) - ); - } - this.disconnect = 1; - } else { - this.points.push( - this.x + ' ' + this.y + - 'A' + radius + ' ' + radius + ' 0 ' + - ((theta < 0) ? '0 ' : '1 ') + - '1 ' + - nextX + ' ' + nextY - ); - this.disconnect = 0; - } - - this.x = nextX; - this.y = nextY; - - return this; - } - - asPath() { - this._link(); - return 'M' + this.points.join('L'); - } - }; -}); - -define('sequence/themes/BaseTheme',['svg/SVGUtilities', 'svg/PatternedLine'], (svg, PatternedLine) => { +define('sequence/themes/BaseTheme',[ + 'svg/SVGUtilities', + 'svg/SVGShapes', +], ( + svg, + SVGShapes +) => { 'use strict'; function deepCopy(o) { @@ -5446,16 +5461,20 @@ define('sequence/themes/BaseTheme',['svg/SVGUtilities', 'svg/PatternedLine'], (s BaseTheme.WavePattern = class WavePattern { constructor(width, height) { - this.deltas = [ - 0, - -height * 2 / 3, - -height, - -height * 2 / 3, - 0, - height * 2 / 3, - height, - height * 2 / 3, - ]; + if(Array.isArray(height)) { + this.deltas = height; + } else { + this.deltas = [ + 0, + -height * 2 / 3, + -height, + -height * 2 / 3, + 0, + height * 2 / 3, + height, + height * 2 / 3, + ]; + } this.partWidth = width / this.deltas.length; } @@ -5467,7 +5486,7 @@ define('sequence/themes/BaseTheme',['svg/SVGUtilities', 'svg/PatternedLine'], (s BaseTheme.renderFlatConnector = (pattern, attrs, {x1, dx1, x2, dx2, y}) => { return { shape: svg.make('path', Object.assign({ - d: new PatternedLine(pattern) + d: new SVGShapes.PatternedLine(pattern) .move(x1 + dx1, y) .line(x2 + dx2, y) .cap() @@ -5485,7 +5504,7 @@ define('sequence/themes/BaseTheme',['svg/SVGUtilities', 'svg/PatternedLine'], (s ) => { return { shape: svg.make('path', Object.assign({ - d: new PatternedLine(pattern) + d: new SVGShapes.PatternedLine(pattern) .move(xL + dx1, y1) .line(xR, y1) .arc(xR, (y1 + y2) / 2, Math.PI) @@ -6588,8 +6607,6 @@ define('sequence/themes/Sketch',[ 'stroke-linecap': 'round', }; - const WAVE = new BaseTheme.WavePattern(6, 0.5); - const SETTINGS = { titleMargin: 10, outerMargin: 5, @@ -6641,7 +6658,7 @@ define('sequence/themes/Sketch',[ 'fill': 'none', }, PENCIL), renderFlat: null, - renderRev: BaseTheme.renderRevConnector.bind(null, null), + renderRev: null, }, 'dash': { attrs: Object.assign({ @@ -6649,7 +6666,7 @@ define('sequence/themes/Sketch',[ 'stroke-dasharray': '4, 2', }, PENCIL), renderFlat: null, - renderRev: BaseTheme.renderRevConnector.bind(null, null), + renderRev: null, }, 'wave': { attrs: Object.assign({ @@ -6657,8 +6674,8 @@ define('sequence/themes/Sketch',[ 'stroke-linejoin': 'round', 'stroke-linecap': 'round', }, PENCIL), - renderFlat: BaseTheme.renderFlatConnector.bind(null, WAVE), - renderRev: BaseTheme.renderRevConnector.bind(null, WAVE), + renderFlat: null, + renderRev: null, }, }, arrow: { @@ -6849,6 +6866,31 @@ define('sequence/themes/Sketch',[ const RIGHT = {}; const LEFT = {}; + class SketchWavePattern extends BaseTheme.WavePattern { + constructor(width, handedness) { + const heights = [ + +0.0, + -0.3, + -0.6, + -0.75, + -0.45, + +0.0, + +0.45, + +0.75, + +0.6, + +0.3, + ]; + if(handedness !== RIGHT) { + heights.reverse(); + } + super(6, heights); + } + + getDelta(p) { + return super.getDelta(p) + Math.sin(p * 0.03) * 0.5; + } + } + class SketchTheme extends BaseTheme { constructor(handedness = RIGHT) { super({ @@ -6866,29 +6908,49 @@ define('sequence/themes/Sketch',[ this.handedness = -1; } this.random = new Random(); + this.wave = new SketchWavePattern(4, handedness); - this._assignFunctions(); + this._assignCapFunctions(); + this._assignConnectFunctions(); + this._assignNoteFunctions(); + this._assignBlockFunctions(); } - _assignFunctions() { + _assignCapFunctions() { this.renderBar = this.renderBar.bind(this); this.renderBox = this.renderBox.bind(this); - this.renderArrowHead = this.renderArrowHead.bind(this); - this.renderFlatConnector = this.renderFlatConnector.bind(this); - this.renderTag = this.renderTag.bind(this); this.agentCap.cross.render = this.renderCross.bind(this); this.agentCap.bar.render = this.renderBar; this.agentCap.box.boxRenderer = this.renderBox; + } + + _assignConnectFunctions() { + this.renderArrowHead = this.renderArrowHead.bind(this); + this.renderFlatConnector = this.renderFlatConnector.bind(this); + this.renderRevConnector = this.renderRevConnector.bind(this); this.connect.arrow.single.render = this.renderArrowHead; this.connect.arrow.double.render = this.renderArrowHead; this.connect.line.solid.renderFlat = this.renderFlatConnector; + this.connect.line.solid.renderRev = this.renderRevConnector; this.connect.line.dash.renderFlat = this.renderFlatConnector; + this.connect.line.dash.renderRev = this.renderRevConnector; + this.connect.line.wave.renderFlat = + this.renderFlatConnectorWave.bind(this); + this.connect.line.wave.renderRev = + this.renderRevConnectorWave.bind(this); + } + _assignNoteFunctions() { this.notes.note.boxRenderer = this.renderNote.bind(this); this.notes.state.boxRenderer = this.renderState.bind(this); + } + + _assignBlockFunctions() { + this.renderTag = this.renderTag.bind(this); + this.blocks.ref.boxRenderer = this.renderRefBlock.bind(this); this.blocks[''].boxRenderer = this.renderBlock.bind(this); this.blocks.ref.section.mode.boxRenderer = this.renderTag; @@ -7088,6 +7150,74 @@ define('sequence/themes/Sketch',[ }; } + renderRevConnector(attrs, {xL, dx1, dx2, y1, y2, xR}) { + const variance = Math.min((xR - xL) * 0.06, 3); + const overshoot = Math.min((xR - xL) * 0.5, 6); + const p1x = xL + dx1 + this.vary(variance, -1); + const p1y = y1 + this.vary(variance, -1); + const b1x = xR - overshoot * this.vary(0.2, 1); + const b1y = y1 - this.vary(1, 2); + const p2x = xR; + const p2y = y1 + this.vary(1, 1); + const b2x = xR; + const b2y = y2 + this.vary(2); + const p3x = xL + dx2 + this.vary(variance, -1); + const p3y = y2 + this.vary(variance, -1); + + return { + shape: svg.make('path', Object.assign({ + d: ( + 'M' + p1x + ' ' + p1y + + 'C' + p1x + ' ' + p1y + + ',' + b1x + ' ' + b1y + + ',' + p2x + ' ' + p2y + + 'S' + b2x + ' ' + b2y + + ',' + p3x + ' ' + p3y + ), + }, attrs)), + p1: {x: p1x - dx1, y: p1y}, + p2: {x: p3x - dx2, y: p3y}, + }; + } + + renderFlatConnectorWave(attrs, {x1, dx1, x2, dx2, y}) { + const x1v = x1 + this.vary(0.3); + const x2v = x2 + this.vary(0.3); + const y1v = y + this.vary(1); + const y2v = y + this.vary(1); + return { + shape: svg.make('path', Object.assign({ + d: new SVGShapes.PatternedLine(this.wave) + .move(x1v + dx1, y1v) + .line(x2v + dx2, y2v) + .cap() + .asPath(), + }, attrs)), + p1: {x: x1v, y: y1v}, + p2: {x: x2v, y: y2v}, + }; + } + + renderRevConnectorWave(attrs, {xL, dx1, dx2, y1, y2, xR}) { + const x1v = xL + this.vary(0.3); + const x2v = xL + this.vary(0.3); + const y1v = y1 + this.vary(1); + const y2v = y2 + this.vary(1); + return { + shape: svg.make('path', Object.assign({ + d: new SVGShapes.PatternedLine(this.wave) + .move(x1v + dx1, y1v) + .line(xR, y1) + .arc(xR, (y1 + y2) / 2, Math.PI) + .line(x2v + dx2, y2v) + .cap() + .asPath(), + }, attrs)), + p1: {x: x1v, y: y1v}, + p2: {x: x2v, y: y2v}, + }; + } + renderArrowHead(attrs, {x, y, dx, dy}) { const w = dx * this.vary(0.2, 1); const h = dy * this.vary(0.3, 1); diff --git a/lib/sequence-diagram.min.js b/lib/sequence-diagram.min.js index 3a5b98e..680c147 100644 --- a/lib/sequence-diagram.min.js +++ b/lib/sequence-diagram.min.js @@ -1 +1 @@ -!function(){var e,t,n;!function(s){function r(e,t){return y.call(e,t)}function i(e,t){var n,s,r,i,a,o,h,l,d,g,c,u=t&&t.split("/"),p=b.map,m=p&&p["*"]||{};if(e){for(a=(e=e.split("/")).length-1,b.nodeIdCompat&&w.test(e[a])&&(e[a]=e[a].replace(w,"")),"."===e[0].charAt(0)&&u&&(e=u.slice(0,u.length-1).concat(e)),d=0;d0&&(e.splice(d-1,2),d-=2)}e=e.join("/")}if((u||m)&&p){for(d=(n=e.split("/")).length;d>0;d-=1){if(s=n.slice(0,d).join("/"),u)for(g=u.length;g>0;g-=1)if((r=p[u.slice(0,g).join("/")])&&(r=r[s])){i=r,o=d;break}if(i)break;!h&&m&&m[s]&&(h=m[s],l=d)}!i&&h&&(i=h,o=l),i&&(n.splice(0,o,i),e=n.join("/"))}return e}function a(e,t){return function(){var n=k.call(arguments,0);return"string"!=typeof n[0]&&1===n.length&&n.push(null),c.apply(s,n.concat([e,t]))}}function o(e){return function(t){m[e]=t}}function h(e){if(r(f,e)){var t=f[e];delete f[e],x[e]=!0,g.apply(s,t)}if(!r(m,e)&&!r(x,e))throw new Error("No "+e);return m[e]}function l(e){var t,n=e?e.indexOf("!"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function d(e){return e?l(e):[]}var g,c,u,p,m={},f={},b={},x={},y=Object.prototype.hasOwnProperty,k=[].slice,w=/\.js$/;u=function(e,t){var n,s=l(e),r=s[0],a=t[1];return e=s[1],r&&(n=h(r=i(r,a))),r?e=n&&n.normalize?n.normalize(e,function(e){return function(t){return i(t,e)}}(a)):i(e,a):(r=(s=l(e=i(e,a)))[0],e=s[1],r&&(n=h(r))),{f:r?r+"!"+e:e,n:e,pr:r,p:n}},p={require:function(e){return a(e)},exports:function(e){var t=m[e];return void 0!==t?t:m[e]={}},module:function(e){return{id:e,uri:"",exports:m[e],config:function(e){return function(){return b&&b.config&&b.config[e]||{}}}(e)}}},g=function(e,t,n,i){var l,g,c,b,y,k,w,A=[],v=typeof n;if(i=i||e,k=d(i),"undefined"===v||"function"===v){for(t=!t.length&&n.length?["require","exports","module"]:t,y=0;y{"use strict";return class{constructor(){this.listeners=new Map,this.forwards=new Set}addEventListener(e,t){const n=this.listeners.get(e);n?n.push(t):this.listeners.set(e,[t])}removeEventListener(e,t){const n=this.listeners.get(e);if(!n)return;const s=n.indexOf(t);-1!==s&&n.splice(s,1)}countEventListeners(e){return(this.listeners.get(e)||[]).length}removeAllEventListeners(e){e?this.listeners.delete(e):this.listeners.clear()}addEventForwarding(e){this.forwards.add(e)}removeEventForwarding(e){this.forwards.delete(e)}removeAllEventForwardings(){this.forwards.clear()}trigger(e,t=[]){(this.listeners.get(e)||[]).forEach(e=>e.apply(null,t)),this.forwards.forEach(n=>n.trigger(e,t))}}}),n("core/ArrayUtilities",[],()=>{"use strict";function e(e,t,n=null){if(null===n)return e.indexOf(t);for(let s=0;s=e.length)return void r.push(s.slice());const i=e[n];if(!Array.isArray(i))return s.push(i),t(e,n+1,s,r),void s.pop();for(let a=0;a{n.push(...t(e))}),n}}}),n("sequence/CodeMirrorMode",["core/ArrayUtilities"],e=>{"use strict";function t(e,t,n,s){return""===t?function(e,t,n){return"object"==typeof n.suggest&&n.suggest.global?[n.suggest]:"string"!=typeof n.suggest||t.suggest===n.suggest?null:e["known"+n.suggest]}(e,n,s):!0===s.suggest?[function(e,t){return Object.keys(t.then).length>0?e+" ":e+"\n"}(t,s)]:Array.isArray(s.suggest)?s.suggest:s.suggest?[s.suggest]:null}function n(n,s){const r=[],i=e.last(s);return Object.keys(i.then).forEach(a=>{let o=i.then[a];"number"==typeof o&&(o=s[s.length-o-1]),e.mergeSets(r,t(n,a,i,o))}),r}function s(t,n,s,{suggest:r,override:i}){n.type&&r!==n.type&&(i&&(n.type=i),e.mergeSets(t["known"+n.type],[n.value+" "]),n.type="",n.value=""),"string"==typeof r&&t["known"+r]&&(n.type=r,n.value&&(n.value+=s.s),n.value+=s.v)}function r(t,r,i){const o={type:"",value:""};let h=i;const l=[h];return t.line.forEach((r,i)=>{i===t.line.length-1&&(t.completions=n(t,l));const d=r.q?"":r.v,g=h.then[d]||h.then[""];"number"==typeof g?l.length-=g:l.push(g||a),h=e.last(l),s(t,o,r,h)}),r&&s(t,o,null,{}),t.nextCompletions=n(t,l),t.valid=Boolean(h.then["\n"])||0===Object.keys(h.then).length,h.type}function i(e){const t=e.baseToken||{};return{value:t.v||"",quoted:t.q||!1}}const a={type:"error line-error",then:{"":0}},o=(()=>{function e(e){return{type:"string",then:Object.assign({"":0},e)}}function t(e){return{type:"variable",suggest:"Agent",then:Object.assign({},e,{"":0,",":{type:"operator",suggest:!0,then:{"":1}}})}}function n(e){return{type:"keyword",suggest:[e+" of ",e+": "],then:{of:{type:"keyword",suggest:!0,then:{"":h}},":":{type:"operator",suggest:!0,then:{"":i}},"":h}}}function s(e){const t={type:"operator",suggest:!0,then:{"+":a,"-":a,"*":a,"!":a,"":e}};return{"+":{type:"operator",suggest:!0,then:{"+":a,"-":a,"*":t,"!":a,"":e}},"-":{type:"operator",suggest:!0,then:{"+":a,"-":a,"*":t,"!":{type:"operator",then:{"+":a,"-":a,"*":a,"!":a,"":e}},"":e}},"*":{type:"operator",suggest:!0,then:{"+":t,"-":t,"*":a,"!":a,"":e}},"!":t,"":e}}const r={type:"",suggest:"\n",then:{}},i=e({"\n":r}),o={type:"variable",suggest:"Agent",then:{"":0,"\n":r,",":{type:"operator",suggest:!0,then:{"":1}},as:{type:"keyword",suggest:!0,then:{"":{type:"variable",suggest:"Agent",then:{"":0,",":{type:"operator",suggest:!0,then:{"":3}},"\n":r}}}}}},h=t({":":{type:"operator",suggest:!0,then:{"":i}}}),l={type:"variable",suggest:"Agent",then:{"":0,",":{type:"operator",suggest:!0,then:{"":h}},":":a}},d={type:"variable",suggest:"Agent",then:{"":0,",":a,":":{type:"operator",suggest:!0,then:{"":i}}}},g={type:"variable",suggest:"Agent",then:{"":0,":":{type:"operator",suggest:!0,then:{"":i,"\n":{type:"",then:{}}}},"\n":r}},c={":":{type:"operator",suggest:!0,then:{"":e({as:{type:"keyword",suggest:!0,then:{"":{type:"variable",suggest:"Agent",then:{"":0,"\n":r}}}}})}}},u={type:"keyword",suggest:!0,then:Object.assign({over:{type:"keyword",suggest:!0,then:{"":t(c)}}},c)},p={title:{type:"keyword",suggest:!0,then:{"":i}},theme:{type:"keyword",suggest:!0,then:{"":{type:"string",suggest:{global:"themes",suffix:"\n"},then:{"":0,"\n":r}}}},headers:{type:"keyword",suggest:!0,then:{none:{type:"keyword",suggest:!0,then:{}},cross:{type:"keyword",suggest:!0,then:{}},box:{type:"keyword",suggest:!0,then:{}},fade:{type:"keyword",suggest:!0,then:{}},bar:{type:"keyword",suggest:!0,then:{}}}},terminators:{type:"keyword",suggest:!0,then:{none:{type:"keyword",suggest:!0,then:{}},cross:{type:"keyword",suggest:!0,then:{}},box:{type:"keyword",suggest:!0,then:{}},fade:{type:"keyword",suggest:!0,then:{}},bar:{type:"keyword",suggest:!0,then:{}}}},define:{type:"keyword",suggest:!0,then:{"":o,as:a}},begin:{type:"keyword",suggest:!0,then:{"":o,reference:u,as:a}},end:{type:"keyword",suggest:!0,then:{"":o,as:a,"\n":r}},if:{type:"keyword",suggest:!0,then:{"":i,":":{type:"operator",suggest:!0,then:{"":i}},"\n":r}},else:{type:"keyword",suggest:["else\n","else if: "],then:{if:{type:"keyword",suggest:"if: ",then:{"":i,":":{type:"operator",suggest:!0,then:{"":i}}}},"\n":r}},repeat:{type:"keyword",suggest:!0,then:{"":i,":":{type:"operator",suggest:!0,then:{"":i}},"\n":r}},note:{type:"keyword",suggest:!0,then:{over:{type:"keyword",suggest:!0,then:{"":h}},left:n("left"),right:n("right"),between:{type:"keyword",suggest:!0,then:{"":l}}}},state:{type:"keyword",suggest:"state over ",then:{over:{type:"keyword",suggest:!0,then:{"":d}}}},text:{type:"keyword",suggest:!0,then:{left:n("left"),right:n("right")}},autolabel:{type:"keyword",suggest:!0,then:{off:{type:"keyword",suggest:!0,then:{}},"":i}},simultaneously:{type:"keyword",suggest:!0,then:{":":{type:"operator",suggest:!0,then:{}},with:{type:"keyword",suggest:!0,then:{"":{type:"variable",suggest:"Label",then:{"":0,":":{type:"operator",suggest:!0,then:{}}}}}}}}};return e=>({type:"error line-error",then:Object.assign({},p,function(e){const t={type:"keyword",suggest:!0,then:s(g)},n={"":0};return e.forEach(e=>n[e]=t),n[":"]={type:"operator",suggest:!0,override:"Label",then:{}},s({type:"variable",suggest:"Agent",then:n})}(e))})})();return class{constructor(e,t){this.tokenDefinitions=e,this.commands=o(t),this.lineComment="#"}startState(){return{currentType:-1,current:"",currentSpace:"",currentQuoted:!1,knownAgent:[],knownLabel:[],beginCompletions:n({},[this.commands]),completions:[],nextCompletions:[],valid:!0,line:[],indent:0}}_matchPattern(e,t,n){return t?(t.lastIndex=0,e.match(t,n)):null}_tokenBegin(e,t){t.currentSpace="";let n="";for(;;){if(e.eol())return!1;t.currentSpace+=n;for(let n=0;n{"use strict";function t(e,t,n){return t.lastIndex=n,t.exec(e)}function n(e){return"n"===e[1]?"\n":e[1]}function s(e,n,s){return s?function(e,n,s){if(s.escape){const r=t(e,s.escape,n);if(r)return{newBlock:null,end:!1,appendSpace:"",appendValue:s.escapeWith(r),skip:r[0].length}}const r=t(e,s.end,n);return r?{newBlock:null,end:!0,appendSpace:"",appendValue:"",skip:r[0].length}:{newBlock:null,end:!1,appendSpace:"",appendValue:e[n],skip:1}}(e,n,s):function(e,n){for(let s=0;s,])/y,end:/(?=[ \t\r\n:+\-~*!<>,])|$/y},{start:/(?=[\-~<>])/y,end:/(?=[^\-~<>])|$/y},{start:/,/y,baseToken:{v:","}},{start:/:/y,baseToken:{v:":"}},{start:/!/y,baseToken:{v:"!"}},{start:/\+/y,baseToken:{v:"+"}},{start:/\*/y,baseToken:{v:"*"}},{start:/\n/y,baseToken:{v:"\n"}}];class a{constructor(e){this.src=e,this.block=null,this.token=null,this.pos={i:0,ln:0,ch:0},this.reset()}isOver(){return this.pos.i>this.src.length}reset(){this.token={s:"",v:"",q:!1,b:null,e:null},this.block=null}beginToken(e){this.block=e.newBlock,Object.assign(this.token,this.block.baseToken),this.token.b=r(this.pos)}endToken(){let e=null;return this.block.omit||(this.token.e=r(this.pos),e=this.token),this.reset(),e}advance(){const e=s(this.src,this.pos.i,this.block);return e.newBlock&&this.beginToken(e),this.token.s+=e.appendSpace,this.token.v+=e.appendValue,function(e,t,n){for(let s=0;s{e.q||"\n"!==e.v?n.push(e):n.length>0&&(t.push(n),n=[])}),n.length>0&&t.push(n),t}}}),n("sequence/LabelPatternParser",[],()=>{"use strict";function e(e){const t=s.exec(e);return t&&t[1]?t[1].length:0}function t(t){if("label"===t)return{token:"label"};const n=t.indexOf(" ");let s=null,r=null;return-1===n?(s=t,r=[]):(s=t.substr(0,n),r=t.substr(n+1).split(",")),"inc"===s?function(t){let n=1,s=1,r=0;return t[0]&&(n=Number(t[0]),r=Math.max(r,e(t[0]))),t[1]&&(s=Number(t[1]),r=Math.max(r,e(t[1]))),{start:n,inc:s,dp:r}}(r):"<"+t+">"}const n=/(.*?)<([^<>]*)>/g,s=/\.([0-9]*)/;return function(e){const s=[];let r=null,i=0;for(n.lastIndex=0;r=n.exec(e);)r[1]&&s.push(r[1]),r[2]&&s.push(t(r[2])),i=n.lastIndex;const a=e.substr(i);return a&&s.push(a),s}}),n("sequence/CodeMirrorHints",["core/ArrayUtilities"],e=>{"use strict";function t(e,t){return{text:e,displayText:"\n"===e?"":e.trim(),className:"\n"===e?"pick-virtual":null,from:r.test(e)?t.squashFrom:t.wordFrom,to:i.test(e)?t.squashTo:t.wordTo}}function n({global:e,prefix:t="",suffix:n=""},s){const r=s[e];return r?r.map(e=>t+e+n):[]}const s=/^([ \t]*)(.*)$/,r=/^[ \t\r\n:,]/,i=/[ \t\r\n]$/;return{getHints:function(r,i){const a=r.getCursor(),o=r.getTokenAt(a);let h=o.string;o.end>a.ch&&(h=h.substr(0,a.ch-o.start));const l=s.exec(h);h=l[2];const d=o.start+l[1].length,g=a.ch>0&&o.state.line.length>0;let c=g?o.state.completions:o.state.beginCompletions;g||(c=c.concat(o.state.knownAgent)),function(t,s={}){for(let r=0;r0&&" "===r[n-1]&&i.squashFrom.ch--," "===r[s]&&i.squashTo.ch++,i}(r,a.line,d,o.end);let p=!1;const m=c.filter(e=>e.startsWith(h)).map(e=>e!==h+" "||i.completeSingle?t(e,u):(p=!0,null)).filter(e=>null!==e);return p&&m.length>0&&m.unshift(t(h+" ",u)),{list:m,from:u.wordFrom,to:u.wordTo}}}}),n("sequence/Parser",["core/ArrayUtilities","./Tokeniser","./LabelPatternParser","./CodeMirrorHints"],(e,t,n,s)=>{"use strict";function r(e,t=null){let n="";return t&&(n=" at line "+(t.b.ln+1)+", character "+t.b.ch),new Error(e+n)}function i(e,t=0,n=null){if(null===n&&(n=e.length),n<=t)return"";let s=e[t].v;for(let r=t+1;r=s)&&(o=s),n>=o)throw r("Missing agent name",function(t,n){if(n{const t=e.combine([[{tok:"",type:0},{tok:"<",type:1},{tok:"<<",type:2}],[{tok:"-",type:"solid"},{tok:"--",type:"dash"},{tok:"~",type:"wave"}],[{tok:"",type:0},{tok:">",type:1},{tok:">>",type:2}]]).filter(e=>0!==e[0].type||0!==e[2].type),n=new Map;return t.forEach(e=>{n.set(e.map(e=>e.tok).join(""),{line:e[1].type,left:e[0].type,right:e[2].type})}),n})(),p={"*":"begin","+":"start","-":"stop","!":"end"},m=["none","box","cross","fade","bar"],f={text:{mode:"text",types:{left:{type:"note left",skip:["of"],min:0,max:null},right:{type:"note right",skip:["of"],min:0,max:null}}},note:{mode:"note",types:{over:{type:"note over",skip:[],min:0,max:null},left:{type:"note left",skip:["of"],min:0,max:null},right:{type:"note right",skip:["of"],min:0,max:null},between:{type:"note between",skip:[],min:2,max:null}}},state:{mode:"state",types:{over:{type:"note over",skip:[],min:1,max:1}}}},b={define:{type:"agent define"},begin:{type:"agent begin",mode:"box"},end:{type:"agent end",mode:"cross"}},x=[(e,t)=>"title"!==a(e[0])?null:(t.title=i(e,1),!0),(e,t)=>"theme"!==a(e[0])?null:(t.theme=i(e,1),!0),(e,t)=>{if("terminators"!==a(e[0]))return null;const n=a(e[1]);if(!n)throw r("Unspecified termination",e[0]);if(-1===m.indexOf(n))throw r('Unknown termination "'+n+'"',e[1]);return t.terminators=n,!0},(e,t)=>{if("headers"!==a(e[0]))return null;const n=a(e[1]);if(!n)throw r("Unspecified header",e[0]);if(-1===m.indexOf(n))throw r('Unknown header "'+n+'"',e[1]);return t.headers=n,!0},e=>{if("autolabel"!==a(e[0]))return null;let t=null;return t="off"===a(e[1])?"