@diagrammo/dgmo-standalone 0.81.0 → 0.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto.css +12 -5
- package/dist/auto.js +12 -5
- package/dist/element.js +12 -5
- package/package.json +1 -1
package/dist/auto.css
CHANGED
|
@@ -48,9 +48,16 @@ pre.dgmo, code.language-dgmo, pre > code.language-dgmo,
|
|
|
48
48
|
* swallowed into a rule they then emit as garbage. */
|
|
49
49
|
|
|
50
50
|
/* === Color-mode visibility (dual-render) ===
|
|
51
|
-
* The dark wrapper also carries
|
|
51
|
+
* The dark wrapper also carries an inline display:none, so a page that never
|
|
52
52
|
* loaded this stylesheet shows the light diagram rather than both of them.
|
|
53
|
-
*
|
|
53
|
+
* The two reveal rules are !important because of it: an inline declaration
|
|
54
|
+
* outranks every normal author rule, and only an important one beats it.
|
|
55
|
+
*
|
|
56
|
+
* That inline style replaced the "hidden" ATTRIBUTE in issue 647. Tailwind v4
|
|
57
|
+
* hides [hidden] with !important from inside a cascade layer, and a layered
|
|
58
|
+
* important declaration outranks an unlayered one at ANY specificity — so no
|
|
59
|
+
* rule here could reveal the dark wrapper, and every diagram on a Tailwind v4
|
|
60
|
+
* host was a zero-height empty box in dark mode.
|
|
54
61
|
* Keep the two host conventions in separate rule blocks — the adapters
|
|
55
62
|
* rewrite by literal replace and a folded rule would half-rewrite. */
|
|
56
63
|
.dgmo-dark {
|
|
@@ -60,13 +67,13 @@ pre.dgmo, code.language-dgmo, pre > code.language-dgmo,
|
|
|
60
67
|
display: none;
|
|
61
68
|
}
|
|
62
69
|
[data-theme="dark"] .dgmo-dark {
|
|
63
|
-
display: block;
|
|
70
|
+
display: block !important;
|
|
64
71
|
}
|
|
65
72
|
html.dark .dgmo-light {
|
|
66
73
|
display: none;
|
|
67
74
|
}
|
|
68
75
|
html.dark .dgmo-dark {
|
|
69
|
-
display: block;
|
|
76
|
+
display: block !important;
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
/* === Diagram sizing ===
|
|
@@ -506,7 +513,7 @@ html.dark .dgmo-dark {
|
|
|
506
513
|
display: none;
|
|
507
514
|
}
|
|
508
515
|
.dgmo-theme-dark .dgmo-dark {
|
|
509
|
-
display: block;
|
|
516
|
+
display: block !important;
|
|
510
517
|
}
|
|
511
518
|
.dgmo-theme-dark .dgmo-lightbox-svg {
|
|
512
519
|
background: #1e1e1e;
|
package/dist/auto.js
CHANGED
|
@@ -466,9 +466,16 @@ days ${t.clockDays}`:""),n=lm(e).work;return n?{startMin:n.startMin,endMin:n.end
|
|
|
466
466
|
* swallowed into a rule they then emit as garbage. */
|
|
467
467
|
|
|
468
468
|
/* === Color-mode visibility (dual-render) ===
|
|
469
|
-
* The dark wrapper also carries
|
|
469
|
+
* The dark wrapper also carries an inline display:none, so a page that never
|
|
470
470
|
* loaded this stylesheet shows the light diagram rather than both of them.
|
|
471
|
-
*
|
|
471
|
+
* The two reveal rules are !important because of it: an inline declaration
|
|
472
|
+
* outranks every normal author rule, and only an important one beats it.
|
|
473
|
+
*
|
|
474
|
+
* That inline style replaced the "hidden" ATTRIBUTE in issue 647. Tailwind v4
|
|
475
|
+
* hides [hidden] with !important from inside a cascade layer, and a layered
|
|
476
|
+
* important declaration outranks an unlayered one at ANY specificity \u2014 so no
|
|
477
|
+
* rule here could reveal the dark wrapper, and every diagram on a Tailwind v4
|
|
478
|
+
* host was a zero-height empty box in dark mode.
|
|
472
479
|
* Keep the two host conventions in separate rule blocks \u2014 the adapters
|
|
473
480
|
* rewrite by literal replace and a folded rule would half-rewrite. */
|
|
474
481
|
.dgmo-dark {
|
|
@@ -478,13 +485,13 @@ days ${t.clockDays}`:""),n=lm(e).work;return n?{startMin:n.startMin,endMin:n.end
|
|
|
478
485
|
display: none;
|
|
479
486
|
}
|
|
480
487
|
[data-theme="dark"] .dgmo-dark {
|
|
481
|
-
display: block;
|
|
488
|
+
display: block !important;
|
|
482
489
|
}
|
|
483
490
|
html.dark .dgmo-light {
|
|
484
491
|
display: none;
|
|
485
492
|
}
|
|
486
493
|
html.dark .dgmo-dark {
|
|
487
|
-
display: block;
|
|
494
|
+
display: block !important;
|
|
488
495
|
}
|
|
489
496
|
|
|
490
497
|
/* === Diagram sizing ===
|
|
@@ -962,7 +969,7 @@ pre.dgmo, code.language-dgmo, pre > code.language-dgmo,
|
|
|
962
969
|
`)}var iX=c6t+`
|
|
963
970
|
`+Kk+`
|
|
964
971
|
`+d6t(Kk)+`
|
|
965
|
-
`;R1();var ub="0.
|
|
972
|
+
`;R1();var ub="0.82.0",u6t=200,f6t=1500,m6t="[dgmo]",p6t=/[\x00-\x1F--]/g,Zk="dgmoAutoStyles";function h6t(...t){typeof console<"u"&&console.warn&&console.warn(m6t,...t)}function lX(t){t.querySelectorAll("script, foreignObject").forEach(r=>r.remove());let n=[t,...Array.from(t.querySelectorAll("*"))];for(let r of n){for(let o of Array.from(r.attributes))o.name.toLowerCase().startsWith("on")&&r.removeAttribute(o.name);if(r.hasAttribute("href")&&xs(r.getAttribute("href"))===null&&r.removeAttribute("href"),r.hasAttributeNS("http://www.w3.org/1999/xlink","href")){let o=r.getAttributeNS("http://www.w3.org/1999/xlink","href");xs(o)===null&&r.removeAttributeNS("http://www.w3.org/1999/xlink","href")}}}function Qk(t){if(t==="light"||t==="dark"||t==="transparent")return t;if(typeof document>"u")return"light";let e=document.documentElement,n=e.getAttribute("data-theme");return n==="dark"?"dark":n==="light"?"light":e.classList.contains("dark")?"dark":e.classList.contains("light")?"light":typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Jk(){if(typeof document>"u")return;let t=document.documentElement;if(t?.dataset?.[Zk]==="1")return;if(document.querySelector('link[rel="stylesheet"][href*="auto.css"]')){t&&t.dataset&&(t.dataset[Zk]="1");return}let n=document.createElement("style");n.setAttribute("data-dgmo-auto",""),n.textContent=iX,document.head.appendChild(n),t&&t.dataset&&(t.dataset[Zk]="1")}function cX(t){let e=t.split(`
|
|
966
973
|
`).map(n=>n.trim()).find(n=>n.length>0);return e?e.replace(p6t,"").slice(0,u6t):"DGMO diagram"}function dX(t){let e=t.showSource||t.showCopy||t.showExpand||t.showEditorLink,n=oX(t.source,'<div class="dgmo-svg"></div>',{mode:e?"showcase":"diagram",showSource:t.showSource,showCopy:t.showCopy,showExpand:t.showExpand,showOpenInEditor:t.showEditorLink,legacyClassNames:["dgmo-rendered",t.themeClass]}),r=document.createElement("div");r.innerHTML=n;let o=r.firstElementChild;o.querySelector(".dgmo-svg")?.appendChild(t.svgEl);let a=o.querySelector("a.dgmo-open");return a&&(t.shareUrl?a.href=t.shareUrl:a.remove()),g6t(o),o}function g6t(t){t.addEventListener("click",n=>{y6t(n)});let e=()=>{t.querySelectorAll("details.dgmo-source-wrap[open]").forEach(n=>{n.open=!1})};t.addEventListener("mouseleave",()=>{t.contains(document.activeElement)||e()}),t.addEventListener("focusout",n=>{let r=n.relatedTarget;r&&t.contains(r)||t.matches(":hover")||e()})}async function y6t(t){let e=t.target;if(!e||typeof e.closest!="function")return;let n=e.closest(".dgmo-toolbar-btn");if(!n)return;let r=!!n.closest("summary");if(r&&t.preventDefault(),n.matches("button.dgmo-expand")){S6t(n);return}if(n.matches("button.dgmo-copy")){await b6t(n.dataset.dgmoSource??"")?(n.classList.add("dgmo-copy--success"),setTimeout(()=>n.classList.remove("dgmo-copy--success"),f6t)):h6t("clipboard write failed");return}if(r&&n.matches("a.dgmo-open")){let o=n;o.href&&window.open(o.href,o.target||"_blank","noopener,noreferrer")}}async function b6t(t){try{if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}if(typeof document<"u")try{let e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="absolute",e.style.left="-9999px",document.body.appendChild(e),e.select();let n=document.execCommand("copy");return document.body.removeChild(e),n}catch{return!1}return!1}var sX="http://www.w3.org/1999/xlink",x6t=["clip-path","mask","filter","fill","stroke","marker-start","marker-mid","marker-end"],w6t=0,E6t='<svg width="20" height="20" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m4 4 8 8"/><path d="m12 4-8 8"/></svg>';function k6t(t,e){let n=new Map;if(t.querySelectorAll("[id]").forEach(o=>{let a=o.getAttribute("id");if(!a)return;let i=e+a;n.set(a,i),o.setAttribute("id",i)}),n.size===0)return;let r=o=>o.replace(/url\(#([^)]+)\)/g,(a,i)=>{let s=n.get(i);return s?`url(#${s})`:a});t.querySelectorAll("*").forEach(o=>{for(let l of x6t){let c=o.getAttribute(l);c&&c.includes("url(#")&&o.setAttribute(l,r(c))}let a=o.getAttribute("style");a&&a.includes("url(#")&&o.setAttribute("style",r(a));let i=o.getAttribute("href");i&&i.startsWith("#")&&n.has(i.slice(1))&&o.setAttribute("href","#"+n.get(i.slice(1)));let s=o.getAttributeNS(sX,"href");s&&s.startsWith("#")&&n.has(s.slice(1))&&o.setAttributeNS(sX,"href","#"+n.get(s.slice(1)))})}function S6t(t){if(typeof document>"u")return;let e=t.closest(".dgmo");if(!e)return;let n=e.querySelectorAll(".dgmo-light, .dgmo-dark, .dgmo-svg"),r=null;for(let c of Array.from(n)){if(window.getComputedStyle(c).display==="none")continue;let d=c.querySelector("svg");if(d){r=d;break}}if(r||(r=e.querySelector("svg")),!r)return;let o=r.cloneNode(!0);k6t(o,`dgmo-lb-${++w6t}-`);let a=document.createElement("dialog");a.className="dgmo-lightbox",a.setAttribute("aria-label","Diagram, full screen");let i=document.createElement("button");i.type="button",i.className="dgmo-lightbox-close",i.setAttribute("aria-label","Close full screen"),i.innerHTML=E6t;let s=document.createElement("div");s.className="dgmo-lightbox-svg",s.appendChild(o),a.appendChild(i),a.appendChild(s),document.body.appendChild(a);let l=()=>{a.open&&a.close()};i.addEventListener("click",l),a.addEventListener("click",c=>{c.target===a&&l()}),a.addEventListener("close",()=>a.remove()),a.showModal()}function uX(t){let e=t.severity&&t.severity!=="error"?`${t.severity}: ${t.message}`:t.message;t.line!==void 0&&t.line>0&&(e+=t.column!==void 0?` (at ${t.line}:${t.column})`:` (at line ${t.line})`);let n=document.createElement("div");n.innerHTML=aX(new Error(e),t.source);let r=n.firstElementChild;return r.setAttribute("data-dgmo-processed","true"),r}function fX(t,e){let n=Wy(t,{baseUrl:e.editorBase,palette:e.palette,theme:e.theme});if(!n.url)return null;let r=`utm_source=${encodeURIComponent(e.utmSource)}&utm_medium=html&utm_campaign=${encodeURIComponent(e.campaign)}`,o=n.url.indexOf("#"),a;if(o===-1){let i=n.url.includes("?")?"&":"?";a=n.url+i+r}else{let i=n.url.slice(0,o),s=n.url.slice(o+1),l=i.includes("?")?"&":"?",c=s.length>0?"&":"";a=i+l+r+"#"+s+c+r}return xs(a)?a:null}var v6t={theme:"auto",palette:"slate",showSource:!0,showCopy:!0,showExpand:!0,showEditorLink:!0},mb={...v6t},Zp=new Set,mX=256*1024,M6t="[dgmo:auto]";function aa(...t){typeof console<"u"&&console.warn&&console.warn(M6t,...t)}function hX(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function fb(t,e,n){let r=t.dataset[e];return r==="true"?!0:r==="false"?!1:(r!==void 0&&aa(`${n}: invalid value`,r,'\u2014 expected "true" or "false"'),null)}function gX(t){try{return Ch().some(e=>e.id===t)}catch{return!1}}function yX(){if(typeof document>"u")return null;let t=document.currentScript;if(t&&t instanceof HTMLScriptElement)return t;let e=document.querySelectorAll('script[src*="auto.js"], script[src*="auto.min.js"]');return e.length===0?null:e[e.length-1]}var L6t=["theme","palette","showSource","showCopy","showExpand","showEditorLink"],bX=["__proto__","constructor","prototype"],C6t=["auto","light","dark","transparent"];function xX(t){return typeof t=="string"&&C6t.includes(t)}function wX(t){if(!t)return{};let e;try{e=JSON.parse(t)}catch(r){return aa("data-config: invalid JSON",r),{}}if(!hX(e))return aa("data-config: not an object"),{};for(let r of bX)if(Object.prototype.hasOwnProperty.call(e,r))return aa("data-config: rejected (prototype-pollution key:",r,")"),{};let n={};for(let[r,o]of Object.entries(e)){if(!L6t.includes(r)){aa("data-config: dropping unknown key",r);continue}if(r==="theme"){if(!xX(o)){aa("data-config: rejected theme",o);continue}n.theme=o}else if(r==="palette"){if(typeof o!="string"||!gX(o)){aa("data-config: rejected palette",o);continue}n.palette=o}else if(r==="showSource"){if(typeof o!="boolean"){aa("data-config: rejected showSource",o);continue}n.showSource=o}else if(r==="showCopy"){if(typeof o!="boolean"){aa("data-config: rejected showCopy",o);continue}n.showCopy=o}else if(r==="showExpand"){if(typeof o!="boolean"){aa("data-config: rejected showExpand",o);continue}n.showExpand=o}else if(r==="showEditorLink"){if(typeof o!="boolean"){aa("data-config: rejected showEditorLink",o);continue}n.showEditorLink=o}}return n}function EX(t=document){let e=t.querySelectorAll(".dgmo:not([data-dgmo-processed]), .language-dgmo:not([data-dgmo-processed])");return Array.from(e).filter(n=>!n.closest(".dgmo-rendered"))}function kX(t){if(t.tagName==="CODE"){let e=t.parentElement;if(e?.tagName==="PRE"){let n=Array.from(e.childNodes).filter(r=>r.nodeType===1||r.nodeType===3&&(r.textContent||"").trim().length>0);if(n.length===1&&n[0]===t)return e}}return t}function Kp(t,e,n){let r=uX({...n,source:e});kX(t).replaceWith(r)}async function SX(t){if(!(t instanceof HTMLElement))return{};if(t.dataset.dgmoProcessed==="true")return{};t.dataset.dgmoProcessed="true";let e=t.textContent||"";if(new TextEncoder().encode(e).byteLength>mX)return Kp(t,e,{message:`DGMO source too large to render \u2014 ${mX/1024} KB max`,severity:"error"}),aa("source exceeds 256 KB cap"),{};let r=mb,o=r.theme==="transparent"?"transparent":Qk(r.theme),a=o==="transparent"?"transparent":o,i=cX(e),s={showSource:fb(t,"showSource","data-show-source"),showCopy:fb(t,"showCopy","data-show-copy"),showExpand:fb(t,"showExpand","data-show-expand"),showEditorLink:fb(t,"showEditorLink","data-show-editor-link")},l=s.showSource??r.showSource,c=s.showCopy??r.showCopy,d=s.showExpand??r.showExpand,u=s.showEditorLink??r.showEditorLink,f;try{f=await TU(e,{theme:a,palette:r.palette})}catch(k){let E=k instanceof Error?k.message:"Render failed unexpectedly";return Kp(t,e,{message:E,severity:"error"}),aa("render() rejected:",k),{}}if(f.diagnostics&&f.diagnostics.length>0){let k=f.diagnostics[0];return Kp(t,e,{message:k.message,severity:k.severity,line:k.line,...k.column!==void 0&&{column:k.column}}),aa("diagnostic:",k.message,k.line,k.column),{}}if(!f.svg)return Kp(t,e,{message:"Empty SVG returned from renderer",severity:"error"}),{};let m=o==="dark"?"dgmo-theme-dark":o==="transparent"?"dgmo-theme-transparent":"dgmo-theme-light",p=document.createElement("div");p.innerHTML=f.svg;let h=p.querySelector("svg");if(!h)return Kp(t,e,{message:"Empty SVG returned from renderer",severity:"error"}),{};lX(h),h.setAttribute("role","img"),h.setAttribute("aria-label",i);let g=null;u&&(g=fX(e,{palette:r.palette,theme:o==="dark"?"dark":"light",editorBase:db,campaign:ub,utmSource:"auto-embed"}));let w=dX({source:e,svgEl:h,themeClass:m,showSource:l,showCopy:c,showExpand:d,showEditorLink:u,shareUrl:g});w.dataset.dgmoProcessed="true";let y={wrapper:w,source:e,overrides:s};return Zp.add(y),kX(t).replaceWith(w),IU(w),OU(w),{wrapper:w}}function eS(t={}){if(!hX(t))return;for(let n of bX)if(Object.prototype.hasOwnProperty.call(t,n)){aa("initialize: rejected (prototype-pollution key:",n,")");return}let e={...mb};xX(t.theme)&&(e.theme=t.theme),typeof t.palette=="string"&&gX(t.palette)&&(e.palette=t.palette),typeof t.showSource=="boolean"&&(e.showSource=t.showSource),typeof t.showEditorLink=="boolean"&&(e.showEditorLink=t.showEditorLink),mb=e}async function nS(t={}){Jk();for(let n of Array.from(Zp))document.contains(n.wrapper)||Zp.delete(n);let e;if(t.nodes){e=("length"in t.nodes&&typeof t.nodes!="string"?Array.from(t.nodes):[]).filter(o=>o instanceof Element&&(o.matches(".dgmo, .language-dgmo")||o.querySelector(".dgmo, .language-dgmo")!==null));let r=[];for(let o of e)o.matches(".dgmo, .language-dgmo")&&r.push(o),o.querySelectorAll(".dgmo:not([data-dgmo-processed]), .language-dgmo:not([data-dgmo-processed])").forEach(i=>r.push(i));e=Array.from(new Set(r)).filter(o=>!o.closest(".dgmo-rendered"))}else e=EX();await Promise.all(e.map(n=>SX(n).catch(()=>({}))))}function T6t(){if(mb.theme==="auto")for(let t of Array.from(Zp)){let e=document.createElement("pre");e.className="dgmo",e.textContent=t.source,t.overrides.showSource!==null&&(e.dataset.showSource=String(t.overrides.showSource)),t.overrides.showCopy!==null&&(e.dataset.showCopy=String(t.overrides.showCopy)),t.overrides.showExpand!==null&&(e.dataset.showExpand=String(t.overrides.showExpand)),t.overrides.showEditorLink!==null&&(e.dataset.showEditorLink=String(t.overrides.showEditorLink)),t.wrapper.replaceWith(e),Zp.delete(t),SX(e)}}function N6t(){if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>T6t();t.addEventListener?t.addEventListener("change",e):"addListener"in t&&typeof t.addListener=="function"&&t.addListener(e)}function tS(){if(typeof document>"u")return;document.querySelectorAll(".dgmo:not(.dgmo-rendered), .language-dgmo").forEach(e=>{e.closest(".dgmo-rendered")||(e.style.visibility="visible")}),document.documentElement&&document.documentElement.dataset&&(document.documentElement.dataset.dgmoAutoFailed="1")}function A6t(){try{Jk();let t=yX(),e=t?.getAttribute("data-auto"),n=t?.getAttribute("data-config");if(n){let o=wX(n);eS(o)}if(N6t(),typeof window<"u"&&window.setTimeout(()=>{document.querySelectorAll(".dgmo:not(.dgmo-rendered):not([data-dgmo-processed])").length>0&&(aa("safety timeout: un-hiding unrendered sources"),tS())},3e4),e==="false")return;let r=()=>{nS().catch(o=>{aa("run() crashed:",o),tS()})};typeof document<"u"&&document.readyState!=="loading"?r():typeof document<"u"&&document.addEventListener("DOMContentLoaded",r,{once:!0})}catch(t){aa("bootstrap failed:",t),tS()}}var vX=Object.freeze({initialize:eS,run:nS,version:ub});function pX(t,e){try{Object.defineProperty(t,e,{value:vX,writable:!1,configurable:!1,enumerable:!0})}catch{}}typeof window<"u"&&(pX(window,"dgmo"),pX(window,"diagrammo"),A6t());var _6t=vX;return cS(R6t);})();
|
|
967
974
|
/*! Bundled license information:
|
|
968
975
|
|
package/dist/element.js
CHANGED
|
@@ -466,9 +466,16 @@ days ${t.clockDays}`:""),n=cm(e).work;return n?{startMin:n.startMin,endMin:n.end
|
|
|
466
466
|
* swallowed into a rule they then emit as garbage. */
|
|
467
467
|
|
|
468
468
|
/* === Color-mode visibility (dual-render) ===
|
|
469
|
-
* The dark wrapper also carries
|
|
469
|
+
* The dark wrapper also carries an inline display:none, so a page that never
|
|
470
470
|
* loaded this stylesheet shows the light diagram rather than both of them.
|
|
471
|
-
*
|
|
471
|
+
* The two reveal rules are !important because of it: an inline declaration
|
|
472
|
+
* outranks every normal author rule, and only an important one beats it.
|
|
473
|
+
*
|
|
474
|
+
* That inline style replaced the "hidden" ATTRIBUTE in issue 647. Tailwind v4
|
|
475
|
+
* hides [hidden] with !important from inside a cascade layer, and a layered
|
|
476
|
+
* important declaration outranks an unlayered one at ANY specificity \u2014 so no
|
|
477
|
+
* rule here could reveal the dark wrapper, and every diagram on a Tailwind v4
|
|
478
|
+
* host was a zero-height empty box in dark mode.
|
|
472
479
|
* Keep the two host conventions in separate rule blocks \u2014 the adapters
|
|
473
480
|
* rewrite by literal replace and a folded rule would half-rewrite. */
|
|
474
481
|
.dgmo-dark {
|
|
@@ -478,13 +485,13 @@ days ${t.clockDays}`:""),n=cm(e).work;return n?{startMin:n.startMin,endMin:n.end
|
|
|
478
485
|
display: none;
|
|
479
486
|
}
|
|
480
487
|
[data-theme="dark"] .dgmo-dark {
|
|
481
|
-
display: block;
|
|
488
|
+
display: block !important;
|
|
482
489
|
}
|
|
483
490
|
html.dark .dgmo-light {
|
|
484
491
|
display: none;
|
|
485
492
|
}
|
|
486
493
|
html.dark .dgmo-dark {
|
|
487
|
-
display: block;
|
|
494
|
+
display: block !important;
|
|
488
495
|
}
|
|
489
496
|
|
|
490
497
|
/* === Diagram sizing ===
|
|
@@ -962,7 +969,7 @@ pre.dgmo, code.language-dgmo, pre > code.language-dgmo,
|
|
|
962
969
|
`)}var lX=o6t+`
|
|
963
970
|
`+jk+`
|
|
964
971
|
`+a6t(jk)+`
|
|
965
|
-
`;R1();var Zk="0.
|
|
972
|
+
`;R1();var Zk="0.82.0",i6t=200,s6t=1500,l6t="[dgmo]",c6t=/[\x00-\x1F--]/g,Kk="dgmoAutoStyles";function Qp(...t){typeof console<"u"&&console.warn&&console.warn(l6t,...t)}function Qk(t){t.querySelectorAll("script, foreignObject").forEach(r=>r.remove());let n=[t,...Array.from(t.querySelectorAll("*"))];for(let r of n){for(let o of Array.from(r.attributes))o.name.toLowerCase().startsWith("on")&&r.removeAttribute(o.name);if(r.hasAttribute("href")&&bs(r.getAttribute("href"))===null&&r.removeAttribute("href"),r.hasAttributeNS("http://www.w3.org/1999/xlink","href")){let o=r.getAttributeNS("http://www.w3.org/1999/xlink","href");bs(o)===null&&r.removeAttributeNS("http://www.w3.org/1999/xlink","href")}}}function Jk(t){if(t==="light"||t==="dark"||t==="transparent")return t;if(typeof document>"u")return"light";let e=document.documentElement,n=e.getAttribute("data-theme");return n==="dark"?"dark":n==="light"?"light":e.classList.contains("dark")?"dark":e.classList.contains("light")?"light":typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function dX(){if(typeof document>"u")return;let t=document.documentElement;if(t?.dataset?.[Kk]==="1")return;if(document.querySelector('link[rel="stylesheet"][href*="auto.css"]')){t&&t.dataset&&(t.dataset[Kk]="1");return}let n=document.createElement("style");n.setAttribute("data-dgmo-auto",""),n.textContent=lX,document.head.appendChild(n),t&&t.dataset&&(t.dataset[Kk]="1")}function uX(t){let e=t.split(`
|
|
966
973
|
`).map(n=>n.trim()).find(n=>n.length>0);return e?e.replace(c6t,"").slice(0,i6t):"DGMO diagram"}function fX(t){let e=t.showSource||t.showCopy||t.showExpand||t.showEditorLink,n=iX(t.source,'<div class="dgmo-svg"></div>',{mode:e?"showcase":"diagram",showSource:t.showSource,showCopy:t.showCopy,showExpand:t.showExpand,showOpenInEditor:t.showEditorLink,legacyClassNames:["dgmo-rendered",t.themeClass]}),r=document.createElement("div");r.innerHTML=n;let o=r.firstElementChild;o.querySelector(".dgmo-svg")?.appendChild(t.svgEl);let a=o.querySelector("a.dgmo-open");return a&&(t.shareUrl?a.href=t.shareUrl:a.remove()),d6t(o),o}function d6t(t){t.addEventListener("click",n=>{u6t(n)});let e=()=>{t.querySelectorAll("details.dgmo-source-wrap[open]").forEach(n=>{n.open=!1})};t.addEventListener("mouseleave",()=>{t.contains(document.activeElement)||e()}),t.addEventListener("focusout",n=>{let r=n.relatedTarget;r&&t.contains(r)||t.matches(":hover")||e()})}async function u6t(t){let e=t.target;if(!e||typeof e.closest!="function")return;let n=e.closest(".dgmo-toolbar-btn");if(!n)return;let r=!!n.closest("summary");if(r&&t.preventDefault(),n.matches("button.dgmo-expand")){y6t(n);return}if(n.matches("button.dgmo-copy")){await f6t(n.dataset.dgmoSource??"")?(n.classList.add("dgmo-copy--success"),setTimeout(()=>n.classList.remove("dgmo-copy--success"),s6t)):Qp("clipboard write failed");return}if(r&&n.matches("a.dgmo-open")){let o=n;o.href&&window.open(o.href,o.target||"_blank","noopener,noreferrer")}}async function f6t(t){try{if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}if(typeof document<"u")try{let e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="absolute",e.style.left="-9999px",document.body.appendChild(e),e.select();let n=document.execCommand("copy");return document.body.removeChild(e),n}catch{return!1}return!1}var cX="http://www.w3.org/1999/xlink",m6t=["clip-path","mask","filter","fill","stroke","marker-start","marker-mid","marker-end"],p6t=0,h6t='<svg width="20" height="20" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m4 4 8 8"/><path d="m12 4-8 8"/></svg>';function g6t(t,e){let n=new Map;if(t.querySelectorAll("[id]").forEach(o=>{let a=o.getAttribute("id");if(!a)return;let i=e+a;n.set(a,i),o.setAttribute("id",i)}),n.size===0)return;let r=o=>o.replace(/url\(#([^)]+)\)/g,(a,i)=>{let s=n.get(i);return s?`url(#${s})`:a});t.querySelectorAll("*").forEach(o=>{for(let l of m6t){let c=o.getAttribute(l);c&&c.includes("url(#")&&o.setAttribute(l,r(c))}let a=o.getAttribute("style");a&&a.includes("url(#")&&o.setAttribute("style",r(a));let i=o.getAttribute("href");i&&i.startsWith("#")&&n.has(i.slice(1))&&o.setAttribute("href","#"+n.get(i.slice(1)));let s=o.getAttributeNS(cX,"href");s&&s.startsWith("#")&&n.has(s.slice(1))&&o.setAttributeNS(cX,"href","#"+n.get(s.slice(1)))})}function y6t(t){if(typeof document>"u")return;let e=t.closest(".dgmo");if(!e)return;let n=e.querySelectorAll(".dgmo-light, .dgmo-dark, .dgmo-svg"),r=null;for(let c of Array.from(n)){if(window.getComputedStyle(c).display==="none")continue;let d=c.querySelector("svg");if(d){r=d;break}}if(r||(r=e.querySelector("svg")),!r)return;let o=r.cloneNode(!0);g6t(o,`dgmo-lb-${++p6t}-`);let a=document.createElement("dialog");a.className="dgmo-lightbox",a.setAttribute("aria-label","Diagram, full screen");let i=document.createElement("button");i.type="button",i.className="dgmo-lightbox-close",i.setAttribute("aria-label","Close full screen"),i.innerHTML=h6t;let s=document.createElement("div");s.className="dgmo-lightbox-svg",s.appendChild(o),a.appendChild(i),a.appendChild(s),document.body.appendChild(a);let l=()=>{a.open&&a.close()};i.addEventListener("click",l),a.addEventListener("click",c=>{c.target===a&&l()}),a.addEventListener("close",()=>a.remove()),a.showModal()}function mX(t){let e=t.severity&&t.severity!=="error"?`${t.severity}: ${t.message}`:t.message;t.line!==void 0&&t.line>0&&(e+=t.column!==void 0?` (at ${t.line}:${t.column})`:` (at line ${t.line})`);let n=document.createElement("div");n.innerHTML=sX(new Error(e),t.source);let r=n.firstElementChild;return r.setAttribute("data-dgmo-processed","true"),r}function pX(t,e){let n=zy(t,{baseUrl:e.editorBase,palette:e.palette,theme:e.theme});if(!n.url)return null;let r=`utm_source=${encodeURIComponent(e.utmSource)}&utm_medium=html&utm_campaign=${encodeURIComponent(e.campaign)}`,o=n.url.indexOf("#"),a;if(o===-1){let i=n.url.includes("?")?"&":"?";a=n.url+i+r}else{let i=n.url.slice(0,o),s=n.url.slice(o+1),l=i.includes("?")?"&":"?",c=s.length>0?"&":"";a=i+l+r+"#"+s+c+r}return bs(a)?a:null}var b6t=`https://unpkg.com/@diagrammo/dgmo@${Zk}/dist/map-data/`,fb={worldCoarse:"world-coarse.json",worldDetail:"world-detail.json",usStates:"us-states.json",gazetteer:"gazetteer.json"},x6t={lakes:"lakes.json",rivers:"rivers.json",mountainRanges:"mountain-ranges.json",naLand:"na-land.json",naLakes:"na-lakes.json",waterBodies:"water-bodies.json",airports:"airports.json"},tS=new Map;function w6t(t){return t.endsWith("/")?t:t+"/"}async function Jp(t,e){let n=await fetch(t+e);if(!n.ok)throw new Error(`map asset ${e} \u2192 HTTP ${n.status}`);return await n.json()}async function E6t(t){let e=w6t(t),n=tS.get(e);if(n)return n;let r=(async()=>{let[o,a,i,s]=await Promise.all([Jp(e,fb.worldCoarse),Jp(e,fb.worldDetail),Jp(e,fb.usStates),Jp(e,fb.gazetteer)]),l=await Promise.all(Object.entries(x6t).map(async([d,u])=>{try{return[d,await Jp(e,u)]}catch{return[d,void 0]}})),c={};for(let[d,u]of l)u!==void 0&&(c[d]=u);return{worldCoarse:o,worldDetail:a,usStates:i,gazetteer:s,...c}})().catch(o=>{throw tS.delete(e),o});return tS.set(e,r),r}function eS(t){let e=t.replace(/\t/g," ").split(`
|
|
967
974
|
`);for(;e.length&&e[0].trim()==="";)e.shift();for(;e.length&&e[e.length-1].trim()==="";)e.pop();if(e.length===0)return"";let n=1/0;for(let r of e){if(r.trim()==="")continue;let o=r.length-r.trimStart().length;o<n&&(n=o)}return!Number.isFinite(n)||n===0?e.join(`
|
|
968
975
|
`):e.map(r=>r.slice(n)).join(`
|