Files
mermaid-live-editor/_app/chunks/state-6b35c395.js
T
2021-10-02 08:23:10 +00:00

10 lines
2.8 KiB
JavaScript

var h=Object.defineProperty,v=Object.defineProperties;var b=Object.getOwnPropertyDescriptors;var d=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var u=(t,e,a)=>e in t?h(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,s=(t,e)=>{for(var a in e||(e={}))_.call(e,a)&&u(t,a,e[a]);if(d)for(var a of d(e))C.call(e,a)&&u(t,a,e[a]);return t},i=(t,e)=>v(t,b(e));import{C as m,J as L,K as O,L as T,M as k,N as l,O as A}from"./vendor-96614ef2.js";import{_ as f}from"./preload-helper-1db36302.js";const J={loading:!1},g=m(J),R=async(t,e)=>{g.set({loading:!0,message:t});const a=await e;return g.set({loading:!1}),a};let n;const $=async()=>{if(!n)try{const{Analytics:t}=await f(()=>import("./analytics.browser.es-b9bb2b82.js"),[]),e=await f(()=>import("./analytics-plugin-ga.browser.es-1cdb0512.js"),[]);n=t({app:"mermaid-live-editor",plugins:[e.init({trackingId:"UA-153180559-1"})]})}catch{console.info("Analytics blocked ;)")}},N=t=>t.replace(/^\s*%%.*\n/g,`
`).trimStart().split(" ")[0];let p;const E=t=>{n&&(clearTimeout(p),p=setTimeout(function(){const e=N(t);console.debug("ga:","send","event","render",e),n.track("render",{graphType:e})},5e3))},w={code:`graph TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[fa:fa-car Car]
`,mermaid:JSON.stringify({theme:"default"},null,2),updateEditor:!1,autoSync:!0,updateDiagram:!0},r=L(m(w),O(),"codeStore"),D=T([r],([t],e)=>{e(k(JSON.stringify(t),!0))}),B=t=>{let e;try{const a=A(t);console.log(`Trying to load state: ${a}`),e=JSON.parse(a);const o=typeof e.mermaid=="string"?JSON.parse(e.mermaid):e.mermaid;o.securityLevel&&o.securityLevel!=="strict"&&confirm(`Removing "securityLevel":"${o.securityLevel}" from the config for safety.
Click Cancel if you trust the source of this Diagram.`)&&delete o.securityLevel,e.mermaid=JSON.stringify(o,null,2)}catch(a){t&&console.error("Init error",a),e=l(r),console.log(e)}y(i(s({},e),{updateEditor:!0}))},y=t=>{r.update(e=>s(s({},e),t))};let S=!1;const G=(t,e,a=!1)=>{if(E(t),(t.match(/\n/g)||"").length+1>50&&!S&&l(r).autoSync){const c=confirm("Long diagram detected. Turn off Auto Sync? Click the sync logo to manually sync.");S=!0,c&&y({autoSync:!1})}r.update(c=>i(s({},c),{code:t,updateEditor:e,updateDiagram:a}))},U=(t,e)=>{r.update(a=>i(s({},a),{mermaid:t,updateEditor:e}))},V=t=>{r.update(e=>{const a=JSON.parse(e.mermaid);return(!a.theme||["dark","default"].includes(a.theme))&&(a.theme=t?"dark":"default"),i(s({},e),{mermaid:JSON.stringify(a,null,2),updateEditor:!0})})},x=()=>{D.subscribe(t=>{history.replaceState(void 0,void 0,`#${t}`)})},F=()=>JSON.stringify(l(r));export{n as a,D as b,r as c,U as d,w as e,y as f,F as g,x as h,R as i,$ as j,B as k,g as l,V as t,G as u};