import{S as st,i as rt,s as at,a as lt,k as I,c as ut,l as T,m as k,h as b,n as C,P as B,b as E,I as q,L as W,H,o as ht,a2 as ct,v as X,q as N,r as D,a3 as pt,e as j,a4 as ft}from"./index-02874a89.js";import{s as F,j as Y,z as mt,y as K,x as dt,b as vt}from"./state-81e9bfc5.js";import{c as J}from"./_commonjsHelpers-35101cd5.js";var gt=function(){var t="",e,o,i,s=[],n={passive:!0};window.addEventListener?(e="addEventListener",o="removeEventListener"):(e="attachEvent",o="detachEvent",t="on"),i="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";function r(m,u){var g=function(v){!v&&(v=window.event);var y={originalEvent:v,target:v.target||v.srcElement,type:"wheel",deltaMode:v.type=="MozMousePixelScroll"?0:1,deltaX:0,delatZ:0,preventDefault:function(){v.preventDefault?v.preventDefault():v.returnValue=!1}};return i=="mousewheel"?(y.deltaY=-.025*v.wheelDelta,v.wheelDeltaX&&(y.deltaX=-.025*v.wheelDeltaX)):y.deltaY=v.detail,u(y)};return s.push({element:m,fn:g}),g}function a(m){for(var u=0;ue?(clearTimeout(a),a=null,p=l,r=t.apply(s,n),a||(s=n=null)):!a&&o.trailing!==!1&&(a=setTimeout(w,f)),r}},createRequestAnimationFrame:function(t){var e=null;return t!=="auto"&&t<60&&t>1&&(e=Math.floor(1e3/t)),e===null?window.requestAnimationFrame||Q(33):Q(e)}};function Q(t){return function(e){window.setTimeout(e,t)}}var O=U,tt="unknown";document.documentMode&&(tt="ie");var G={svgNS:"http://www.w3.org/2000/svg",xmlNS:"http://www.w3.org/XML/1998/namespace",xmlnsNS:"http://www.w3.org/2000/xmlns/",xlinkNS:"http://www.w3.org/1999/xlink",evNS:"http://www.w3.org/2001/xml-events",getBoundingClientRectNormalized:function(t){if(t.clientWidth&&t.clientHeight)return{width:t.clientWidth,height:t.clientHeight};if(t.getBoundingClientRect())return t.getBoundingClientRect();throw new Error("Cannot get BoundingClientRect for SVG.")},getOrCreateViewport:function(t,e){var o=null;if(O.isElement(e)?o=e:o=t.querySelector(e),!o){var i=Array.prototype.slice.call(t.childNodes||t.children).filter(function(p){return p.nodeName!=="defs"&&p.nodeName!=="#text"});i.length===1&&i[0].nodeName==="g"&&i[0].getAttribute("transform")===null&&(o=i[0])}if(!o){var s="viewport-"+new Date().toISOString().replace(/\D/g,"");o=document.createElementNS(this.svgNS,"g"),o.setAttribute("id",s);var n=t.childNodes||t.children;if(n&&n.length>0)for(var r=n.length;r>0;r--)n[n.length-r].nodeName!=="defs"&&o.appendChild(n[n.length-r]);t.appendChild(o)}var a=[];return o.getAttribute("class")&&(a=o.getAttribute("class").split(" ")),~a.indexOf("svg-pan-zoom_viewport")||(a.push("svg-pan-zoom_viewport"),o.setAttribute("class",a.join(" "))),o},setupSvgAttributes:function(t){if(t.setAttribute("xmlns",this.svgNS),t.setAttributeNS(this.xmlnsNS,"xmlns:xlink",this.xlinkNS),t.setAttributeNS(this.xmlnsNS,"xmlns:ev",this.evNS),t.parentNode!==null){var e=t.getAttribute("style")||"";e.toLowerCase().indexOf("overflow")===-1&&t.setAttribute("style","overflow: hidden; "+e)}},internetExplorerRedisplayInterval:300,refreshDefsGlobal:O.throttle(function(){for(var t=document.querySelectorAll("defs"),e=t.length,o=0;o=0;i--)this.eventListeners.hasOwnProperty(o[i])&&delete this.eventListeners[o[i]]}for(var s in this.eventListeners)(this.options.eventsListenerElement||this.svg).addEventListener(s,this.eventListeners[s],this.options.preventMouseEventsDefault?!1:ot);this.options.mouseWheelZoomEnabled&&(this.options.mouseWheelZoomEnabled=!1,this.enableMouseWheelZoom())};c.prototype.enableMouseWheelZoom=function(){if(!this.options.mouseWheelZoomEnabled){var t=this;this.wheelListener=function(o){return t.handleMouseWheel(o)};var e=!this.options.preventMouseEventsDefault;et.on(this.options.eventsListenerElement||this.svg,this.wheelListener,e),this.options.mouseWheelZoomEnabled=!0}};c.prototype.disableMouseWheelZoom=function(){if(this.options.mouseWheelZoomEnabled){var t=!this.options.preventMouseEventsDefault;et.off(this.options.eventsListenerElement||this.svg,this.wheelListener,t),this.options.mouseWheelZoomEnabled=!1}};c.prototype.handleMouseWheel=function(t){if(!(!this.options.zoomEnabled||this.state!=="none")){this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1);var e=t.deltaY||1,o=Date.now()-this.lastMouseWheelEventTime,i=3+Math.max(0,30-o);this.lastMouseWheelEventTime=Date.now(),"deltaMode"in t&&t.deltaMode===0&&t.wheelDelta&&(e=t.deltaY===0?0:Math.abs(t.wheelDelta)/t.deltaY),e=-.30?1:-1)*Math.log(Math.abs(e)+10)/i;var s=this.svg.getScreenCTM().inverse(),n=M.getEventPoint(t,this.svg).matrixTransform(s),r=Math.pow(1+this.options.zoomScaleSensitivity,-1*e);this.zoomAtPoint(r,n)}};c.prototype.zoomAtPoint=function(t,e,o){var i=this.viewport.getOriginalState();o?(t=Math.max(this.options.minZoom*i.zoom,Math.min(this.options.maxZoom*i.zoom,t)),t=t/this.getZoom()):this.getZoom()*tthis.options.maxZoom*i.zoom&&(t=this.options.maxZoom*i.zoom/this.getZoom());var s=this.viewport.getCTM(),n=e.matrixTransform(s.inverse()),r=this.svg.createSVGMatrix().translate(n.x,n.y).scale(t).translate(-n.x,-n.y),a=s.multiply(r);a.a!==s.a&&this.viewport.setCTM(a)};c.prototype.zoom=function(t,e){this.zoomAtPoint(t,M.getSvgCenterPoint(this.svg,this.width,this.height),e)};c.prototype.publicZoom=function(t,e){e&&(t=this.computeFromRelativeZoom(t)),this.zoom(t,e)};c.prototype.publicZoomAtPoint=function(t,e,o){if(o&&(t=this.computeFromRelativeZoom(t)),x.getType(e)!=="SVGPoint")if("x"in e&&"y"in e)e=M.createSVGPoint(this.svg,e.x,e.y);else throw new Error("Given point is invalid");this.zoomAtPoint(t,e,o)};c.prototype.getZoom=function(){return this.viewport.getZoom()};c.prototype.getRelativeZoom=function(){return this.viewport.getRelativeZoom()};c.prototype.computeFromRelativeZoom=function(t){return t*this.viewport.getOriginalState().zoom};c.prototype.resetZoom=function(){var t=this.viewport.getOriginalState();this.zoom(t.zoom,!0)};c.prototype.resetPan=function(){this.pan(this.viewport.getOriginalState())};c.prototype.reset=function(){this.resetZoom(),this.resetPan()};c.prototype.handleDblClick=function(t){if(this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),this.options.controlIconsEnabled){var e=t.target.getAttribute("class")||"";if(e.indexOf("svg-pan-zoom-control")>-1)return!1}var o;t.shiftKey?o=1/((1+this.options.zoomScaleSensitivity)*2):o=(1+this.options.zoomScaleSensitivity)*2;var i=M.getEventPoint(t,this.svg).matrixTransform(this.svg.getScreenCTM().inverse());this.zoomAtPoint(o,i)};c.prototype.handleMouseDown=function(t,e){this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),x.mouseAndTouchNormalize(t,this.svg),this.options.dblClickZoomEnabled&&x.isDblClick(t,e)?this.handleDblClick(t):(this.state="pan",this.firstEventCTM=this.viewport.getCTM(),this.stateOrigin=M.getEventPoint(t,this.svg).matrixTransform(this.firstEventCTM.inverse()))};c.prototype.handleMouseMove=function(t){if(this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),this.state==="pan"&&this.options.panEnabled){var e=M.getEventPoint(t,this.svg).matrixTransform(this.firstEventCTM.inverse()),o=this.firstEventCTM.translate(e.x-this.stateOrigin.x,e.y-this.stateOrigin.y);this.viewport.setCTM(o)}};c.prototype.handleMouseUp=function(t){this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),this.state==="pan"&&(this.state="none")};c.prototype.fit=function(){var t=this.viewport.getViewBox(),e=Math.min(this.width/t.width,this.height/t.height);this.zoom(e,!0)};c.prototype.contain=function(){var t=this.viewport.getViewBox(),e=Math.max(this.width/t.width,this.height/t.height);this.zoom(e,!0)};c.prototype.center=function(){var t=this.viewport.getViewBox(),e=(this.width-(t.width+t.x*2)*this.getZoom())*.5,o=(this.height-(t.height+t.y*2)*this.getZoom())*.5;this.getPublicInstance().pan({x:e,y:o})};c.prototype.updateBBox=function(){this.viewport.simpleViewBoxCache()};c.prototype.pan=function(t){var e=this.viewport.getCTM();e.e=t.x,e.f=t.y,this.viewport.setCTM(e)};c.prototype.panBy=function(t){var e=this.viewport.getCTM();e.e+=t.x,e.f+=t.y,this.viewport.setCTM(e)};c.prototype.getPan=function(){var t=this.viewport.getState();return{x:t.x,y:t.y}};c.prototype.resize=function(){var t=M.getBoundingClientRectNormalized(this.svg);this.width=t.width,this.height=t.height;var e=this.viewport;e.options.width=this.width,e.options.height=this.height,e.processCTM(),this.options.controlIconsEnabled&&(this.getPublicInstance().disableControlIcons(),this.getPublicInstance().enableControlIcons())};c.prototype.destroy=function(){var t=this;this.beforeZoom=null,this.onZoom=null,this.beforePan=null,this.onPan=null,this.onUpdatedCTM=null,this.options.customEventsHandler!=null&&this.options.customEventsHandler.destroy({svgElement:this.svg,eventsListenerElement:this.options.eventsListenerElement,instance:this.getPublicInstance()});for(var e in this.eventListeners)(this.options.eventsListenerElement||this.svg).removeEventListener(e,this.eventListeners[e],this.options.preventMouseEventsDefault?!1:ot);this.disableMouseWheelZoom(),this.getPublicInstance().disableControlIcons(),this.reset(),z=z.filter(function(o){return o.svg!==t.svg}),delete this.options,delete this.viewport,delete this.publicInstance,delete this.pi,this.getPublicInstance=function(){return null}};c.prototype.getPublicInstance=function(){var t=this;return this.publicInstance||(this.publicInstance=this.pi={enablePan:function(){return t.options.panEnabled=!0,t.pi},disablePan:function(){return t.options.panEnabled=!1,t.pi},isPanEnabled:function(){return!!t.options.panEnabled},pan:function(e){return t.pan(e),t.pi},panBy:function(e){return t.panBy(e),t.pi},getPan:function(){return t.getPan()},setBeforePan:function(e){return t.options.beforePan=e===null?null:x.proxy(e,t.publicInstance),t.pi},setOnPan:function(e){return t.options.onPan=e===null?null:x.proxy(e,t.publicInstance),t.pi},enableZoom:function(){return t.options.zoomEnabled=!0,t.pi},disableZoom:function(){return t.options.zoomEnabled=!1,t.pi},isZoomEnabled:function(){return!!t.options.zoomEnabled},enableControlIcons:function(){return t.options.controlIconsEnabled||(t.options.controlIconsEnabled=!0,R.enable(t)),t.pi},disableControlIcons:function(){return t.options.controlIconsEnabled&&(t.options.controlIconsEnabled=!1,R.disable(t)),t.pi},isControlIconsEnabled:function(){return!!t.options.controlIconsEnabled},enableDblClickZoom:function(){return t.options.dblClickZoomEnabled=!0,t.pi},disableDblClickZoom:function(){return t.options.dblClickZoomEnabled=!1,t.pi},isDblClickZoomEnabled:function(){return!!t.options.dblClickZoomEnabled},enableMouseWheelZoom:function(){return t.enableMouseWheelZoom(),t.pi},disableMouseWheelZoom:function(){return t.disableMouseWheelZoom(),t.pi},isMouseWheelZoomEnabled:function(){return!!t.options.mouseWheelZoomEnabled},setZoomScaleSensitivity:function(e){return t.options.zoomScaleSensitivity=e,t.pi},setMinZoom:function(e){return t.options.minZoom=e,t.pi},setMaxZoom:function(e){return t.options.maxZoom=e,t.pi},setBeforeZoom:function(e){return t.options.beforeZoom=e===null?null:x.proxy(e,t.publicInstance),t.pi},setOnZoom:function(e){return t.options.onZoom=e===null?null:x.proxy(e,t.publicInstance),t.pi},zoom:function(e){return t.publicZoom(e,!0),t.pi},zoomBy:function(e){return t.publicZoom(e,!1),t.pi},zoomAtPoint:function(e,o){return t.publicZoomAtPoint(e,o,!0),t.pi},zoomAtPointBy:function(e,o){return t.publicZoomAtPoint(e,o,!1),t.pi},zoomIn:function(){return this.zoomBy(1+t.options.zoomScaleSensitivity),t.pi},zoomOut:function(){return this.zoomBy(1/(1+t.options.zoomScaleSensitivity)),t.pi},getZoom:function(){return t.getRelativeZoom()},setOnUpdatedCTM:function(e){return t.options.onUpdatedCTM=e===null?null:x.proxy(e,t.publicInstance),t.pi},resetZoom:function(){return t.resetZoom(),t.pi},resetPan:function(){return t.resetPan(),t.pi},reset:function(){return t.reset(),t.pi},fit:function(){return t.fit(),t.pi},contain:function(){return t.contain(),t.pi},center:function(){return t.center(),t.pi},updateBBox:function(){return t.updateBBox(),t.pi},resize:function(){return t.resize(),t.pi},getSizes:function(){return{width:t.width,height:t.height,realZoom:t.getZoom(),viewBox:t.viewport.getViewBox()}},destroy:function(){return t.destroy(),t.pi}}),this.publicInstance};var z=[],xt=function(t,e){var o=x.getSvg(t);if(o===null)return null;for(var i=z.length-1;i>=0;i--)if(z[i].svg===o)return z[i].instance.getPublicInstance();return z.push({svg:o,instance:new c(o,e)}),z[z.length-1].instance.getPublicInstance()},Mt=xt;function $(t){let e,o;function i(r,a){return r[2]?zt:Zt}let s=i(t),n=s(t);return{c(){e=I("div"),n.c(),this.h()},l(r){e=T(r,"DIV",{class:!0,id:!0});var a=k(e);n.l(a),a.forEach(b),this.h()},h(){C(e,"class",o="absolute w-full p-2 z-10 font-mono "+(t[2]?"text-red-600":"text-yellow-600")+" bg-base-100 bg-opacity-80 text-center"),C(e,"id","errorContainer")},m(r,a){E(r,e,a),n.m(e,null)},p(r,a){s===(s=i(r))&&n?n.p(r,a):(n.d(1),n=s(r),n&&(n.c(),n.m(e,null))),a&4&&o!==(o="absolute w-full p-2 z-10 font-mono "+(r[2]?"text-red-600":"text-yellow-600")+" bg-base-100 bg-opacity-80 text-center")&&C(e,"class",o)},d(r){r&&b(e),n.d()}}}function Zt(t){let e,o,i,s,n,r,a,p,w;return{c(){e=N("Diagram out of sync. "),o=I("br"),i=N(` Press `),s=I("i"),n=N(" (Sync button) or "),r=I("kbd"),a=N(K),p=N(" + Enter"),w=N(" to sync."),this.h()},l(l){e=D(l,"Diagram out of sync. "),o=T(l,"BR",{}),i=D(l,` Press `),s=T(l,"I",{class:!0}),k(s).forEach(b),n=D(l," (Sync button) or "),r=T(l,"KBD",{});var f=k(r);a=D(f,K),p=D(f," + Enter"),f.forEach(b),w=D(l," to sync."),this.h()},h(){C(s,"class","fas fa-sync")},m(l,f){E(l,e,f),E(l,o,f),E(l,i,f),E(l,s,f),E(l,n,f),E(l,r,f),q(r,a),q(r,p),E(l,w,f)},p:W,d(l){l&&b(e),l&&b(o),l&&b(i),l&&b(s),l&&b(n),l&&b(r),l&&b(w)}}}function zt(t){let e,o=t[5].error.toString().replace(/\n/g,"
")+"",i;return{c(){e=new pt(!1),i=j(),this.h()},l(s){e=ft(s,!1),i=j(),this.h()},h(){e.a=i},m(s,n){e.m(o,s,n),E(s,i,n)},p(s,n){n&32&&o!==(o=s[5].error.toString().replace(/\n/g,"
")+"")&&e.p(o)},d(s){s&&b(i),s&&e.d()}}}function Ct(t){let e,o,i,s=(t[2]&&t[5].error instanceof Error||t[3])&&$(t);return{c(){s&&s.c(),e=lt(),o=I("div"),i=I("div"),this.h()},l(n){s&&s.l(n),e=ut(n),o=T(n,"DIV",{id:!0,class:!0});var r=k(o);i=T(r,"DIV",{id:!0,class:!0}),k(i).forEach(b),r.forEach(b),this.h()},h(){C(i,"id","container"),C(i,"class","h-full overflow-auto svelte-1ewr4tw"),B(i,"hide",t[4]),C(o,"id","view"),C(o,"class","p-2 h-full svelte-1ewr4tw"),B(o,"error",t[2]),B(o,"outOfSync",t[3])},m(n,r){s&&s.m(n,r),E(n,e,r),E(n,o,r),q(o,i),t[6](i),t[7](o)},p(n,[r]){n[2]&&n[5].error instanceof Error||n[3]?s?s.p(n,r):(s=$(n),s.c(),s.m(e.parentNode,e)):s&&(s.d(1),s=null),r&16&&B(i,"hide",n[4]),r&4&&B(o,"error",n[2]),r&8&&B(o,"outOfSync",n[3])},i:W,o:W,d(n){s&&s.d(n),n&&b(e),n&&b(o),t[6](null),t[7](null)}}}function Pt(t,e,o){let i,s;H(t,F,h=>o(5,i=h)),H(t,Y,h=>o(13,s=h));let n="",r="",a,p,w=!1,l=!1,f=!1,_=!0,m=i.panZoom,u;const g=()=>{if(!u)return;const h=u.getPan(),Z=u.getZoom();dt({pan:h,zoom:Z}),vt("panZoom")},v=h=>{h.panZoom&&(o(4,f=!0),u==null||u.destroy(),u=void 0,Promise.resolve().then(()=>{const Z=document.getElementById("graph-div");if(!Z)return;u=Mt(Z,{onPan:g,onZoom:g,controlIconsEnabled:!0,fit:!0,center:!0});const{pan:V,zoom:A}=h;V!==void 0&&A!==void 0&&Number.isFinite(A)&&(u.zoom(A),u.pan(V)),o(4,f=!1)}))},y=async h=>{if(h.error!==void 0){o(2,w=!0);return}o(2,w=!1);try{if(a&&h&&(h.updateDiagram||h.autoSync)){if(h.autoSync||ct(Y,s.updateDiagram=!1,s),o(3,l=!1),_=!0,n===h.code&&r===h.mermaid&&m===h.panZoom)return;n=h.code,r=h.mermaid,m=h.panZoom;const Z=p.parentElement.scrollTop;delete a.dataset.processed,await mt(Object.assign({},JSON.parse(h.mermaid)),n,"graph-div",(V,A)=>{if(V.length>0){v(h),o(0,a.innerHTML=V,a);const L=document.getElementById("graph-div");if(!L)throw new Error("graph-div not found");L.setAttribute("height","100%"),L.style.maxWidth="100%",A&&A(L)}}),o(1,p.parentElement.scrollTop=Z,p),o(2,w=!1)}else _?_=!1:(n!==h.code||r!==h.mermaid)&&o(3,l=!0)}catch(Z){console.error("view fail",Z),o(2,w=!0)}};ht(()=>{F.subscribe(h=>{y(h)}),window.addEventListener("resize",()=>{i.panZoom&&u&&u.resize()}),console.log("View mounted")});function it(h){X[h?"unshift":"push"](()=>{a=h,o(0,a)})}function nt(h){X[h?"unshift":"push"](()=>{p=h,o(1,p)})}return[a,p,w,l,f,i,it,nt]}class Dt extends st{constructor(e){super(),rt(this,e,Pt,Ct,at,{})}}export{Dt as V};