Presentations-revealjs/custom_plugins/mermaid/mermaid.js

14 lines
841 KiB
JavaScript
Raw Normal View History

2023-02-23 17:11:38 +01:00
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).RevealMermaid=e()}(this,(function(){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var t={exports:{}};!function(t,e){t.exports=function(){var e;function n(){return e.apply(null,arguments)}function i(t){return t instanceof Array||"[object Array]"===Object.prototype.toString.call(t)}function r(t){return null!=t&&"[object Object]"===Object.prototype.toString.call(t)}function a(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function s(t){if(Object.getOwnPropertyNames)return 0===Object.getOwnPropertyNames(t).length;for(var e in t)if(a(t,e))return;return 1}function o(t){return void 0===t}function l(t){return"number"==typeof t||"[object Number]"===Object.prototype.toString.call(t)}function c(t){return t instanceof Date||"[object Date]"===Object.prototype.toString.call(t)}function h(t,e){for(var n=[],i=t.length,r=0;r<i;++r)n.push(e(t[r],r));return n}function u(t,e){for(var n in e)a(e,n)&&(t[n]=e[n]);return a(e,"toString")&&(t.toString=e.toString),a(e,"valueOf")&&(t.valueOf=e.valueOf),t}function d(t,e,n,i){return De(t,e,n,i,!0).utc()}function p(t){return null==t._pf&&(t._pf={empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidEra:null,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],era:null,meridiem:null,rfc2822:!1,weekdayMismatch:!1}),t._pf}function f(t){if(null==t._isValid){var e=p(t),n=y.call(e.parsedDateParts,(function(t){return null!=t}));if(n=!isNaN(t._d.getTime())&&e.overflow<0&&!e.empty&&!e.invalidEra&&!e.invalidMonth&&!e.invalidWeekday&&!e.weekdayMismatch&&!e.nullInput&&!e.invalidFormat&&!e.userInvalidated&&(!e.meridiem||e.meridiem&&n),t._strict&&(n=n&&0===e.charsLeftOver&&0===e.unusedTokens.length&&void 0===e.bigHour),null!=Object.isFrozen&&Object.isFrozen(t))return n;t._isValid=n}return t._isValid}function g(t){var e=d(NaN);return null!=t?u(p(e),t):p(e).userInvalidated=!0,e}var y=Array.prototype.some||function(t){for(var e=Object(this),n=e.length>>>0,i=0;i<n;i++)if(i in e&&t.call(this,e[i],i,e))return!0;return!1},m=n.momentProperties=[],b=!1;function _(t,e){var n,i,r,a=m.length;if(o(e._isAMomentObject)||(t._isAMomentObject=e._isAMomentObject),o(e._i)||(t._i=e._i),o(e._f)||(t._f=e._f),o(e._l)||(t._l=e._l),o(e._strict)||(t._strict=e._strict),o(e._tzm)||(t._tzm=e._tzm),o(e._isUTC)||(t._isUTC=e._isUTC),o(e._offset)||(t._offset=e._offset),o(e._pf)||(t._pf=p(e)),o(e._locale)||(t._locale=e._locale),0<a)for(n=0;n<a;n++)o(r=e[i=m[n]])||(t[i]=r);return t}function x(t){_(this,t),this._d=new Date(null!=t._d?t._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),!1===b&&(b=!0,n.updateOffset(this),b=!1)}function v(t){return t instanceof x||null!=t&&null!=t._isAMomentObject}function k(t){!1===n.suppressDeprecationWarnings&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+t)}function w(t,e){var i=!0;return u((function(){if(null!=n.deprecationHandler&&n.deprecationHandler(null,t),i){for(var r,s,o=[],l=arguments.length,c=0;c<l;c++){if(r="","object"==typeof arguments[c]){for(s in r+="\n["+c+"] ",arguments[0])a(arguments[0],s)&&(r+=s+": "+arguments[0][s]+", ");r=r.slice(0,-2)}else r=arguments[c];o.push(r)}k(t+"\nArguments: "+Array.prototype.slice.call(o).join("")+"\n"+(new Error).stack),i=!1}return e.apply(this,arguments)}),e)}var T={};function C(t,e){null!=n.deprecationHandler&&n.deprecationHandler(t,e),T[t]||(k(e),T[t]=!0)}function E(t){return"undefined"!=typeof Function&&t instanceof Function||"[object Function]"===Object.prototype.toString.call(t)}function S(t,e){var n,i=u({},t);for(n in e)a(e,n)&&(r(t[n])&&r(e[n])?(i[n]={},u(i[n],t[n]),u(i[n],e[n])):null!=e[n]?i[n]=e[n]:delete i[n]);for(n in t)a(t,n)&&!a(e,n)&&r(t[n])&&(i[n]=u({},i[n]));return i}function A(t){null!=t&&this.set(t)}n.suppressDeprecationWarnings=!1,n.deprecationHandler=
/*! @license DOMPurify 2.4.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.1/LICENSE */
function vo(t){return vo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vo(t)}function ko(t,e){return ko=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},ko(t,e)}function wo(t,e,n){return wo=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);var r=new(Function.bind.apply(t,i));return n&&ko(r,n.prototype),r},wo.apply(null,arguments)}function To(t){return function(t){if(Array.isArray(t))return Co(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return Co(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Co(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Co(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}Xs.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e)}}},ro.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:io(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:io(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},so.prototype={areaStart:no,areaEnd:no,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x2=t,this._y2=e;break;case 1:this._point=2,this._x3=t,this._y3=e;break;case 2:this._point=3,this._x4=t,this._y4=e,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+e)/6);break;default:io(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},oo.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+t)/6,i=(this._y0+4*this._y1+e)/6;this._line?this._context
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
function Cb(t){return null==t}var Eb=function(t){return 0===t&&Number.NEGATIVE_INFINITY===1/t},Sb=function(t,e){var n,i,r,a;if(e)for(n=0,i=(a=Object.keys(e)).length;n<i;n+=1)t[r=a[n]]=e[r];return t},Ab={isNothing:Cb,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:Cb(t)?[]:[t]},repeat:function(t,e){var n,i="";for(n=0;n<e;n+=1)i+=t;return i},isNegativeZero:Eb,extend:Sb};function Db(t,e){var n="",i=t.reason||"(unknown reason)";return t.mark?(t.mark.name&&(n+='in "'+t.mark.name+'" '),n+="("+(t.mark.line+1)+":"+(t.mark.column+1)+")",!e&&t.mark.snippet&&(n+="\n\n"+t.mark.snippet),i+" "+n):i}function Lb(t,e){Error.call(this),this.name="YAMLException",this.reason=t,this.mark=e,this.message=Db(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||""}Lb.prototype=Object.create(Error.prototype),Lb.prototype.constructor=Lb,Lb.prototype.toString=function(t){return this.name+": "+Db(this,t)};var Ob=Lb;function Nb(t,e,n,i,r){var a="",s="",o=Math.floor(r/2)-1;return i-e>o&&(e=i-o+(a=" ... ").length),n-i>o&&(n=i+o-(s=" ...").length),{str:a+t.slice(e,n).replace(/\t/g,"→")+s,pos:i-e+a.length}}function Mb(t,e){return Ab.repeat(" ",e-t.length)+t}var Bb=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var n,i=/\r?\n|\r|\0/g,r=[0],a=[],s=-1;n=i.exec(t.buffer);)a.push(n.index),r.push(n.index+n[0].length),t.position<=n.index&&s<0&&(s=r.length-2);s<0&&(s=r.length-1);var o,l,c="",h=Math.min(t.line+e.linesAfter,a.length).toString().length,u=e.maxLength-(e.indent+h+3);for(o=1;o<=e.linesBefore&&!(s-o<0);o++)l=Nb(t.buffer,r[s-o],a[s-o],t.position-(r[s]-r[s-o]),u),c=Ab.repeat(" ",e.indent)+Mb((t.line-o+1).toString(),h)+" | "+l.str+"\n"+c;for(l=Nb(t.buffer,r[s],a[s],t.position,u),c+=Ab.repeat(" ",e.indent)+Mb((t.line+1).toString(),h)+" | "+l.str+"\n",c+=Ab.repeat("-",e.indent+h+3+l.pos)+"^\n",o=1;o<=e.linesAfter&&!(s+o>=a.length);o++)l=Nb(t.buffer,r[s+o],a[s+o],t.position-(r[s]-r[s+o]),u),c+=Ab.repeat(" ",e.indent)+Mb((t.line+o+1).toString(),h)+" | "+l.str+"\n";return c.replace(/\n$/,"")},Ib=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Fb=["scalar","sequence","mapping"];var Rb=function(t,e){var n,i;if(e=e||{},Object.keys(e).forEach((function(e){if(-1===Ib.indexOf(e))throw new Ob('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=(n=e.styleAliases||null,i={},null!==n&&Object.keys(n).forEach((function(t){n[t].forEach((function(e){i[String(e)]=t}))})),i),-1===Fb.indexOf(this.kind))throw new Ob('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function $b(t,e){var n=[];return t[e].forEach((function(t){var e=n.length;n.forEach((function(n,i){n.tag===t.tag&&n.kind===t.kind&&n.multi===t.multi&&(e=i)})),n[e]=t})),n}function Pb(t){return this.extend(t)}Pb.prototype.extend=function(t){var e=[],n=[];if(t instanceof Rb)n.push(t);else if(Array.isArray(t))n=n.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new Ob("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(n=n.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Rb))throw new Ob("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new Ob("There is a non-scalar type in the implicit list of a schema. Implicit reso
/*! Check if previously processed */
if(tb.info("Rendering diagram: "+t.id),t.getAttribute("data-processed"))continue;t.setAttribute("data-processed","true");const e=`mermaid-${a.next()}`;s=t.innerHTML,s=Dx.entityDecode(s).trim().replace(/<br\s*\/?>/gi,"<br/>");const i=Dx.detectInit(s);i&&tb.debug("Detected early reinit: ",i);try{nL.render(e,s,((i,r)=>{t.innerHTML=i,void 0!==n&&n(e),r&&r(t)}),t)}catch(t){rL(t,o,uL.parseError)}}if(o.length>0)throw o[0]},sL=async function(t,e,n){const i=nL.getConfig();let r;if(t&&(uL.sequenceConfig=t),tb.debug((n?"":"No ")+"Callback function found"),void 0===e)r=document.querySelectorAll(".mermaid");else if("string"==typeof e)r=document.querySelectorAll(e);else if(e instanceof HTMLElement)r=[e];else{if(!(e instanceof NodeList))throw new Error("Invalid argument nodes for mermaid.init");r=e}tb.debug(`Found ${r.length} diagrams`),void 0!==(null==t?void 0:t.startOnLoad)&&(tb.debug("Start On Load: "+(null==t?void 0:t.startOnLoad)),nL.updateSiteConfig({startOnLoad:null==t?void 0:t.startOnLoad}));const a=new Dx.initIdGenerator(i.deterministicIds,i.deterministicIDSeed);let s;const o=[];for(const t of Array.from(r)){
/*! Check if previously processed */
if(tb.info("Rendering diagram: "+t.id),t.getAttribute("data-processed"))continue;t.setAttribute("data-processed","true");const e=`mermaid-${a.next()}`;s=t.innerHTML,s=Dx.entityDecode(s).trim().replace(/<br\s*\/?>/gi,"<br/>");const i=Dx.detectInit(s);i&&tb.debug("Detected early reinit: ",i);try{await nL.renderAsync(e,s,((i,r)=>{t.innerHTML=i,void 0!==n&&n(e),r&&r(t)}),t)}catch(t){rL(t,o,uL.parseError)}}if(o.length>0)throw o[0]},oL=function(){if(uL.startOnLoad){const{startOnLoad:t}=nL.getConfig();t&&uL.init()}};"undefined"!=typeof document&&
/*!
* Wait for document loaded before starting the execution
*/
window.addEventListener("load",oL,!1);const lL=[];let cL=!1;const hL=async()=>{if(!cL){for(cL=!0;lL.length>0;){const t=lL.shift();if(t)try{await t()}catch(t){tb.error("Error executing queue",t)}}cL=!1}},uL={startOnLoad:!0,diagrams:{},mermaidAPI:nL,parse:t=>nL.parse(t,uL.parseError),parseAsync:t=>new Promise(((e,n)=>{lL.push((()=>new Promise(((i,r)=>{nL.parseAsync(t,uL.parseError).then((t=>{i(t),e(t)}),(t=>{tb.error("Error parsing",t),r(t),n(t)}))})))),hL()})),render:nL.render,renderAsync:(t,e,n,i)=>new Promise(((r,a)=>{lL.push((()=>new Promise(((s,o)=>{nL.renderAsync(t,e,n,i).then((t=>{s(t),r(t)}),(t=>{tb.error("Error parsing",t),o(t),a(t)}))})))),hL()})),init:async function(t,e,n){try{iL?await sL(t,e,n):aL(t,e,n)}catch(t){tb.warn("Syntax Error rendering"),Ax(t)&&tb.warn(t.str),uL.parseError&&uL.parseError(t)}},initThrowsErrors:aL,initThrowsErrorsAsync:sL,registerExternalDiagrams:async(t,{lazyLoad:e=!0}={})=>{e?(t=>{for(const{id:e,detector:n,loader:i}of t)sx(e,n,i)})(t):await(async t=>{tb.debug(`Loading ${t.length} external diagrams`);const e=await Promise.allSettled(t.map((async({id:t,detector:e,loader:n})=>{const{diagram:i}=await n();yv(t,i,e)}))),n=e.filter((t=>"rejected"===t.status));if(n.length>0){tb.error(`Failed to load ${n.length} external diagrams`);for(const t of n)tb.error(t);throw new Error(`Failed to load ${n.length} external diagrams`)}})(t),iL=!0},initialize:function(t){nL.initialize(t)},parseError:void 0,contentLoaded:oL,setParseErrorHandler:function(t){uL.parseError=t}},dL={id:"mermaid",init:function(t){let{...e}=t.getConfig().mermaid||{};uL.mermaidAPI.initialize({startOnLoad:!1,...e});const n=t.getRevealElement().querySelectorAll(".mermaid");Array.from(n).forEach((function(t){var e=t.textContent.trim();try{uL.mermaidAPI.render(`mermaid-${Math.random().toString(36).substring(2)}`,e,(function(e,n){t.innerHTML=e}))}catch(n){let i="";n?.str&&(i=n.str),n?.message&&(i=n.message),console.error(i,{error:n,graphDefinition:e,el:t}),t.innerHTML=i}}))}};return()=>dL}));