@livepreso/cdk 0.0.2 → 0.0.4

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.
@@ -1,13 +1,13 @@
1
- (()=>{"use strict";let e,t,r="[modern-screenshot]",n="u">typeof window,o=n&&"Worker"in window,a=n&&"atob"in window,l=n&&"btoa"in window,i=n?window.navigator?.userAgent:"",s=i.includes("Chrome"),c=i.includes("AppleWebKit")&&!s,u=i.includes("Firefox"),d=e=>"CSSLayerBlockRule"===e.constructor.name,f=e=>1===e.nodeType,g=e=>f(e)&&void 0!==e.style&&"object"!=typeof e.className,m=e=>8===e.nodeType,h=e=>"SLOT"===e.tagName;function p(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(n&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!n)return e;let r=w().implementation.createHTMLDocument(),o=r.createElement("base"),a=r.createElement("a");return r.head.appendChild(o),r.body.appendChild(a),t&&(o.href=t),a.href=e,a.href}function w(e){return(e&&f(e)?e?.ownerDocument:e)??window.document}let y="http://www.w3.org/2000/svg",b=e=>{var t;return t="dataUrl",new Promise((r,n)=>{let o=new FileReader;o.onload=()=>r(o.result),o.onerror=()=>n(o.error),o.onabort=()=>n(Error(`Failed read blob to ${t}`)),o.readAsDataURL(e)})};function v(e,t){let r=w(t).createElement("img");return r.decoding="sync",r.loading="eager",r.src=e,r}function S(e,t){return new Promise(r=>{let{timeout:n,ownerDocument:o,onError:a,onWarn:l}=t??{},i="string"==typeof e?v(e,w(o)):e,s=null,c=null;function u(){r(i),s&&clearTimeout(s),c?.()}if(n&&(s=setTimeout(u,n)),"VIDEO"===i.tagName){let e=i.currentSrc||i.src;if(!e)return i.poster?S(i.poster,t).then(r):u();if(i.readyState>=2)return u();let n=t=>{l?.("Failed video load",e,t),a?.(t),u()};c=()=>{i.removeEventListener("loadeddata",u),i.removeEventListener("error",n)},i.addEventListener("loadeddata",u,{once:!0}),i.addEventListener("error",n,{once:!0})}else{let e="image"===i.tagName?i.href.baseVal:i.currentSrc||i.src;if(!e)return u();let t=async()=>{if("IMG"===i.tagName&&"decode"in i)try{await i.decode()}catch(t){l?.("Failed to decode image, trying to render anyway",i.dataset.originalSrc||e,t)}u()},r=t=>{l?.("Failed image load",i.dataset.originalSrc||e,t),u()};if("IMG"===i.tagName&&i.complete)return t();c=()=>{i.removeEventListener("load",t),i.removeEventListener("error",r)},i.addEventListener("load",t,{once:!0}),i.addEventListener("error",r,{once:!0})}})}async function E(e,t){g(e)&&("IMG"===e.tagName||"VIDEO"===e.tagName?await S(e,t):await Promise.all(["img","video"].flatMap(r=>Array.from(e.querySelectorAll(r)).map(e=>S(e,t)))))}let x=(t=0,()=>(t+=1,`u${`0000${(1679616*Math.random()|0).toString(36)}`.slice(-4)}${t}`));function A(e){return e?.split(",").map(e=>e.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}let N=0;async function C(e,t){return e&&"__CONTEXT__"in e?e:k(e,{...t,autoDestruct:!0})}async function k(e,t){let a,l,{scale:i=1,workerUrl:s,workerNumber:c=1}=t||{},u=!!t?.debug,d=t?.features??!0,g=e.ownerDocument??(n?window.document:void 0),m=e.ownerDocument?.defaultView??(n?window:void 0),h=new Map,p={width:0,height:0,quality:1,type:"image/png",scale:i,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:u,fetch:{requestInit:{cache:t?.fetch?.bypassingCache?"no-cache":"force-cache"},placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:!1,...t?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:c,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1,...t,__CONTEXT__:!0,log:(a=`${r}[#${N}]`,N++,{time:e=>u&&console.time(`${a} ${e}`),timeEnd:e=>u&&console.timeEnd(`${a} ${e}`),warn:(...e)=>u&&((...e)=>console.warn(r,...e))(...e)}),node:e,ownerDocument:g,ownerWindow:m,dpi:1===i?null:96*i,svgStyleElement:T(g),svgDefsElement:g?.createElementNS(y,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:o&&s&&c?c:0})].map(()=>{try{let e=new Worker(s);return e.onmessage=async e=>{let{url:t,result:r}=e.data;r?h.get(t)?.resolve?.(r):h.get(t)?.reject?.(Error(`Error receiving message from worker: ${t}`))},e.onmessageerror=e=>{let{url:t}=e.data;h.get(t)?.reject?.(Error(`Error receiving message from worker: ${t}`))},e}catch(e){return p.log.warn("Failed to new Worker",e),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[((l=g?.createElement?.("canvas"))&&(l.height=l.width=1),!!l&&"toDataURL"in l&&!!l.toDataURL("image/webp").includes("image/webp")&&"image/webp"),"image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:h,drawImageCount:0,tasks:[],features:d,isEnable:e=>"restoreScrollPosition"===e?"boolean"!=typeof d&&(d[e]??!1):"boolean"==typeof d?d:d[e]??!0,shadowRoots:[]};p.log.time("wait until load"),await E(e,{timeout:p.timeout,onWarn:p.log.warn}),p.log.timeEnd("wait until load");let{width:w,height:b}=function(e,t){let{width:r,height:n}=t;if(f(e)&&(!r||!n)){let t=e.getBoundingClientRect();r=r||t.width||Number(e.getAttribute("width"))||0,n=n||t.height||Number(e.getAttribute("height"))||0}return{width:r,height:n}}(e,p);return p.width=w,p.height=b,p}function T(e){if(!e)return;let t=e.createElement("style"),r=t.ownerDocument.createTextNode(`
1
+ (()=>{"use strict";let e,t,r="[modern-screenshot]",n="u">typeof window,o=n&&"Worker"in window,a=n&&"atob"in window,l=n&&"btoa"in window,i=n?window.navigator?.userAgent:"",c=i.includes("Chrome"),s=i.includes("AppleWebKit")&&!c,u=i.includes("Firefox"),f=e=>"CSSLayerBlockRule"===e.constructor.name,d=e=>1===e.nodeType,h=e=>d(e)&&void 0!==e.style&&"object"!=typeof e.className,m=e=>8===e.nodeType,g=e=>"SLOT"===e.tagName;function p(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(n&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!n)return e;let r=y().implementation.createHTMLDocument(),o=r.createElement("base"),a=r.createElement("a");return r.head.appendChild(o),r.body.appendChild(a),t&&(o.href=t),a.href=e,a.href}function y(e){return(e&&d(e)?e?.ownerDocument:e)??window.document}let w="http://www.w3.org/2000/svg",b=e=>{var t;return t="dataUrl",new Promise((r,n)=>{let o=new FileReader;o.onload=()=>r(o.result),o.onerror=()=>n(o.error),o.onabort=()=>n(Error(`Failed read blob to ${t}`)),o.readAsDataURL(e)})};function v(e,t){let r=y(t).createElement("img");return r.decoding="sync",r.loading="eager",r.src=e,r}function S(e,t){return new Promise(r=>{let{timeout:n,ownerDocument:o,onError:a,onWarn:l}=t??{},i="string"==typeof e?v(e,y(o)):e,c=null,s=null;function u(){r(i),c&&clearTimeout(c),s?.()}if(n&&(c=setTimeout(u,n)),"VIDEO"===i.tagName){let e=i.currentSrc||i.src;if(!e)return i.poster?S(i.poster,t).then(r):u();if(i.readyState>=2)return u();let n=t=>{l?.("Failed video load",e,t),a?.(t),u()};s=()=>{i.removeEventListener("loadeddata",u),i.removeEventListener("error",n)},i.addEventListener("loadeddata",u,{once:!0}),i.addEventListener("error",n,{once:!0})}else{let e="image"===i.tagName?i.href.baseVal:i.currentSrc||i.src;if(!e)return u();let t=async()=>{if("IMG"===i.tagName&&"decode"in i)try{await i.decode()}catch(t){l?.("Failed to decode image, trying to render anyway",i.dataset.originalSrc||e,t)}u()},r=t=>{l?.("Failed image load",i.dataset.originalSrc||e,t),u()};if("IMG"===i.tagName&&i.complete)return t();s=()=>{i.removeEventListener("load",t),i.removeEventListener("error",r)},i.addEventListener("load",t,{once:!0}),i.addEventListener("error",r,{once:!0})}})}async function E(e,t){h(e)&&("IMG"===e.tagName||"VIDEO"===e.tagName?await S(e,t):await Promise.all(["img","video"].flatMap(r=>Array.from(e.querySelectorAll(r)).map(e=>S(e,t)))))}let A=(t=0,()=>(t+=1,`u${`0000${(1679616*Math.random()|0).toString(36)}`.slice(-4)}${t}`));function x(e){return e?.split(",").map(e=>e.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}let C=0;async function N(e,t){return e&&"__CONTEXT__"in e?e:k(e,{...t,autoDestruct:!0})}async function k(e,t){let a,l,{scale:i=1,workerUrl:c,workerNumber:s=1}=t||{},u=!!t?.debug,f=t?.features??!0,h=e.ownerDocument??(n?window.document:void 0),m=e.ownerDocument?.defaultView??(n?window:void 0),g=new Map,p={width:0,height:0,quality:1,type:"image/png",scale:i,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:u,fetch:{requestInit:{cache:t?.fetch?.bypassingCache?"no-cache":"force-cache"},placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:!1,...t?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:s,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1,...t,__CONTEXT__:!0,log:(a=`${r}[#${C}]`,C++,{time:e=>u&&console.time(`${a} ${e}`),timeEnd:e=>u&&console.timeEnd(`${a} ${e}`),warn:(...e)=>u&&((...e)=>console.warn(r,...e))(...e)}),node:e,ownerDocument:h,ownerWindow:m,dpi:1===i?null:96*i,svgStyleElement:T(h),svgDefsElement:h?.createElementNS(w,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:o&&c&&s?s:0})].map(()=>{try{let e=new Worker(c);return e.onmessage=async e=>{let{url:t,result:r}=e.data;r?g.get(t)?.resolve?.(r):g.get(t)?.reject?.(Error(`Error receiving message from worker: ${t}`))},e.onmessageerror=e=>{let{url:t}=e.data;g.get(t)?.reject?.(Error(`Error receiving message from worker: ${t}`))},e}catch(e){return p.log.warn("Failed to new Worker",e),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[((l=h?.createElement?.("canvas"))&&(l.height=l.width=1),!!l&&"toDataURL"in l&&!!l.toDataURL("image/webp").includes("image/webp")&&"image/webp"),"image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:g,drawImageCount:0,tasks:[],features:f,isEnable:e=>"restoreScrollPosition"===e?"boolean"!=typeof f&&(f[e]??!1):"boolean"==typeof f?f:f[e]??!0,shadowRoots:[]};p.log.time("wait until load"),await E(e,{timeout:p.timeout,onWarn:p.log.warn}),p.log.timeEnd("wait until load");let{width:y,height:b}=function(e,t){let{width:r,height:n}=t;if(d(e)&&(!r||!n)){let t=e.getBoundingClientRect();r=r||t.width||Number(e.getAttribute("width"))||0,n=n||t.height||Number(e.getAttribute("height"))||0}return{width:r,height:n}}(e,p);return p.width=y,p.height=b,p}function T(e){if(!e)return;let t=e.createElement("style"),r=t.ownerDocument.createTextNode(`
2
2
  .______background-clip--text {
3
3
  background-clip: text;
4
4
  -webkit-background-clip: text;
5
5
  }
6
- `);return t.appendChild(r),t}async function I(e,t){let{log:r,timeout:n,drawImageCount:o,drawImageInterval:a}=t;r.time("image to canvas");let l=await S(e,{timeout:n,onWarn:t.log.warn}),{canvas:i,context2d:s}=function(e,t){let{width:r,height:n,scale:o,backgroundColor:a,maximumCanvasSize:l}=t,i=e.createElement("canvas");i.width=Math.floor(r*o),i.height=Math.floor(n*o),i.style.width=`${r}px`,i.style.height=`${n}px`,l&&(i.width>l||i.height>l)&&(i.width>l&&i.height>l?i.width>i.height?(i.height*=l/i.width,i.width=l):(i.width*=l/i.height,i.height=l):i.width>l?(i.height*=l/i.width,i.width=l):(i.width*=l/i.height,i.height=l));let s=i.getContext("2d");return s&&a&&(s.fillStyle=a,s.fillRect(0,0,i.width,i.height)),{canvas:i,context2d:s}}(e.ownerDocument,t),c=()=>{try{s?.drawImage(l,0,0,i.width,i.height)}catch(e){t.log.warn("Failed to drawImage",e)}};if(c(),t.isEnable("fixSvgXmlDecode"))for(let e=0;e<o;e++)await new Promise(t=>{setTimeout(()=>{s?.clearRect(0,0,i.width,i.height),c(),t()},e+a)});return t.drawImageCount=0,r.timeEnd("image to canvas"),i}function D(e,t){if(e.ownerDocument)try{let t=e.toDataURL();if("data:,"!==t)return v(t,e.ownerDocument)}catch(e){t.log.warn("Failed to clone canvas",e)}let r=e.cloneNode(!1),n=e.getContext("2d"),o=r.getContext("2d");try{n&&o&&o.putImageData(n.getImageData(0,0,e.width,e.height),0,0)}catch(e){t.log.warn("Failed to clone canvas",e)}return r}async function $(e,t){if(e.ownerDocument&&!e.currentSrc&&e.poster)return v(e.poster,e.ownerDocument);let r=e.cloneNode(!1);r.crossOrigin="anonymous",e.currentSrc&&e.currentSrc!==e.src&&(r.src=e.currentSrc);let n=r.ownerDocument;if(n){let o=!0;if(await S(r,{onError:()=>o=!1,onWarn:t.log.warn}),!o)return e.poster?v(e.poster,e.ownerDocument):r;r.currentTime=e.currentTime,await new Promise(e=>{r.addEventListener("seeked",e,{once:!0})});let a=n.createElement("canvas");a.width=e.offsetWidth,a.height=e.offsetHeight;try{let e=a.getContext("2d");e&&e.drawImage(r,0,0,a.width,a.height)}catch(n){if(t.log.warn("Failed to clone video",n),e.poster)return v(e.poster,e.ownerDocument);return r}return D(a,t)}return r}let P=["width","height","-webkit-text-fill-color"],_=["stroke","fill"];function F(e,t,r){let n,o,{defaultComputedStyles:a}=r,l=e.nodeName.toLowerCase(),i="object"==typeof e.className&&"svg"!==l,s=i?_.map(t=>[t,e.getAttribute(t)]).filter(([,e])=>null!==e):[],c=[i&&"svg",l,s.map((e,t)=>`${e}=${t}`).join(","),t].filter(Boolean).join(":");if(a.has(c))return a.get(c);let u=function(e){let t=e.sandbox;if(!t){let{ownerDocument:r}=e;try{r&&((t=r.createElement("iframe")).id=`__SANDBOX__${x()}`,t.width="0",t.height="0",t.style.visibility="hidden",t.style.position="fixed",r.body.appendChild(t),t.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',e.sandbox=t)}catch(t){e.log.warn("Failed to getSandBox",t)}}return t}(r),d=u?.contentWindow;if(!d)return new Map;let f=d?.document;i?(o=(n=f.createElementNS(y,"svg")).ownerDocument.createElementNS(n.namespaceURI,l),s.forEach(([e,t])=>{o.setAttributeNS(null,e,t)}),n.appendChild(o)):n=o=f.createElement(l),o.textContent=" ",f.body.appendChild(n);let g=d.getComputedStyle(o,t),m=new Map;for(let e=g.length,t=0;t<e;t++){let e=g.item(t);P.includes(e)||m.set(e,g.getPropertyValue(e))}return f.body.removeChild(n),a.set(c,m),m}function M(e,t,r){let n=new Map,o=[],a=new Map;if(r)for(let e of r)l(e);else for(let t=e.length,r=0;r<t;r++)l(e.item(r));for(let e=o.length,t=0;t<e;t++)a.get(o[t])?.forEach((e,t)=>n.set(t,e));function l(r){let l=e.getPropertyValue(r),i=e.getPropertyPriority(r),s=r.lastIndexOf("-"),c=s>-1?r.substring(0,s):void 0;if(c){let e=a.get(c);e||(e=new Map,a.set(c,e)),e.set(r,[l,i])}(t.get(r)!==l||i)&&(c?o.push(c):n.set(r,[l,i]))}return n}let R=["::before","::after"],L=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"],O=new Set(["symbol"]);async function j(e,t,r,n,o){if(f(r)&&("STYLE"===r.tagName||"SCRIPT"===r.tagName)||n.filter&&!n.filter(r))return;O.has(t.nodeName)||O.has(r.nodeName)?n.currentParentNodeStyle=void 0:n.currentParentNodeStyle=n.currentNodeStyle;let a=await B(r,n,!1,o);n.isEnable("restoreScrollPosition")&&function(e,t){if(!g(e)||!g(t))return;let{scrollTop:r,scrollLeft:n}=e;if(!r&&!n)return;let{transform:o}=t.style,a=new DOMMatrix(o),{a:l,b:i,c:s,d:c}=a;a.a=1,a.b=0,a.c=0,a.d=1,a.translateSelf(-n,-r),a.a=l,a.b=i,a.c=s,a.d=c,t.style.transform=a.toString()}(e,a),t.appendChild(a)}async function U(e,t,r,n){let o=e.firstChild;f(e)&&e.shadowRoot&&(o=e.shadowRoot?.firstChild,r.shadowRoots.push(e.shadowRoot));for(let a=o;a;a=a.nextSibling)if(!m(a))if(f(a)&&h(a)&&"function"==typeof a.assignedNodes){let o=a.assignedNodes();for(let a=0;a<o.length;a++)await j(e,t,o[a],r,n)}else await j(e,t,a,r,n)}let W=/^[\w-:]+$/;async function B(e,t,r=!1,n){let{ownerDocument:o,ownerWindow:a,fontFamilies:l,onCloneEachNode:i}=t;if(o&&3===e.nodeType)return n&&/\S/.test(e.data)&&n(e.data),o.createTextNode(e.data);if(o&&a&&f(e)&&(g(e)||"object"==typeof e.className)){let n=await function(e,t){if("CANVAS"===e.tagName)return D(e,t);if("IFRAME"===e.tagName){try{if(e?.contentDocument?.documentElement)return B(e.contentDocument.documentElement,t)}catch(e){t.log.warn("Failed to clone iframe",e)}return e.cloneNode(!1)}if("IMG"===e.tagName){let t;return t=e.cloneNode(!1),e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager"),t}return"VIDEO"===e.tagName?$(e,t):e.cloneNode(!1)}(e,t);if(t.isEnable("removeAbnormalAttributes")){let e=n.getAttributeNames();for(let t=e.length,r=0;r<t;r++){let t=e[r];W.test(t)||n.removeAttribute(t)}}let o=t.currentNodeStyle=function(e,t,r,n){let{ownerWindow:o,includeStyleProperties:a,currentParentNodeStyle:l}=n,i=t.style,c=o.getComputedStyle(e),u=F(e,null,n);l?.forEach((e,t)=>{u.delete(t)});let d=M(c,u,a);d.delete("transition-property"),d.delete("all"),d.delete("d"),d.delete("content"),r&&(d.delete("position"),d.delete("margin-top"),d.delete("margin-right"),d.delete("margin-bottom"),d.delete("margin-left"),d.delete("margin-block-start"),d.delete("margin-block-end"),d.delete("margin-inline-start"),d.delete("margin-inline-end"),d.set("box-sizing",["border-box",""])),d.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text"),s&&(d.has("font-kerning")||d.set("font-kerning",["normal",""]),(d.get("overflow-x")?.[0]==="hidden"||d.get("overflow-y")?.[0]==="hidden")&&d.get("text-overflow")?.[0]==="ellipsis"&&e.scrollWidth===e.clientWidth&&d.set("text-overflow",["clip",""]));for(let e=i.length,t=0;t<e;t++)i.removeProperty(i.item(t));return d.forEach(([e,t],r)=>{i.setProperty(r,e,t)}),d}(e,n,r,t);r&&function(e,t){let{backgroundColor:r,width:n,height:o,style:a}=t,l=e.style;if(r&&l.setProperty("background-color",r,"important"),n&&l.setProperty("width",`${n}px`,"important"),o&&l.setProperty("height",`${o}px`,"important"),a)for(let e in a)l[e]=a[e]}(n,t);let a=!1;if(t.isEnable("copyScrollbar")){let t=[o.get("overflow-x")?.[0],o.get("overflow-y")?.[0]];a=t.includes("scroll")||(t.includes("auto")||t.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)}let c=o.get("text-transform")?.[0],u=A(o.get("font-family")?.[0]),d=u?e=>{"uppercase"===c?e=e.toUpperCase():"lowercase"===c?e=e.toLowerCase():"capitalize"===c&&(e=e[0].toUpperCase()+e.substring(1)),u.forEach(t=>{let r=l.get(t);r||l.set(t,r=new Set),e.split("").forEach(e=>r.add(e))})}:void 0;return!function(e,t,r,n,o){let{ownerWindow:a,svgStyleElement:l,svgStyles:i,currentNodeStyle:s}=n;function c(r){let l=a.getComputedStyle(e,r),c=l.getPropertyValue("content");if(!c||"none"===c)return;o?.(c),c=c.replace(/(')|(")|(counter\(.+\))/g,"");let u=[x()],d=F(e,r,n);s?.forEach((e,t)=>{d.delete(t)});let f=M(l,d,n.includeStyleProperties);f.delete("content"),f.delete("-webkit-locale"),f.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text");let g=[`content: '${c}';`];if(f.forEach(([e,t],r)=>{g.push(`${r}: ${e}${t?" !important":""};`)}),1===g.length)return;try{t.className=[t.className,...u].join(" ")}catch(e){n.log.warn("Failed to copyPseudoClass",e);return}let m=g.join("\n "),h=i.get(m);h||(h=[],i.set(m,h)),h.push(`.${u[0]}${r}`)}l&&a&&(R.forEach(c),r&&L.forEach(c))}(e,n,a,t,d),("TEXTAREA"===e.tagName||"INPUT"===e.tagName||"SELECT"===e.tagName)&&n.setAttribute("value",e.value),"VIDEO"!==e.tagName&&await U(e,n,t,d),await i?.(n),n}let c=e.cloneNode(!1);return await U(e,c,t),await i?.(c),c}function V(e,t){let{url:r,requestType:n="text",responseType:o="text",imageDom:a}=t,l=r,{timeout:i,acceptOfImage:s,requests:d,fetchFn:f,fetch:{requestInit:g,bypassingCache:m,placeholderImage:h},font:p,workers:w,fontFamilies:y}=e;"image"===n&&(c||u)&&e.drawImageCount++;let v=d.get(r);if(!v){m&&m instanceof RegExp&&m.test(l)&&(l+=(/\?/.test(l)?"&":"?")+(new Date).getTime());let t=n.startsWith("font")&&p&&p.minify,u=new Set;t&&n.split(";")[1].split(",").forEach(e=>{y.has(e)&&y.get(e).forEach(e=>u.add(e))});let S=t&&u.size,E={url:l,timeout:i,responseType:S?"arrayBuffer":o,headers:"image"===n?{accept:s}:void 0,...g};(v={type:n,resolve:void 0,reject:void 0,response:null}).response=(async()=>{if(f&&"image"===n){let e=await f(r);if(e)return e}return!c&&r.startsWith("http")&&w.length?new Promise((e,t)=>{w[d.size&w.length-1].postMessage({rawUrl:r,...E}),v.resolve=e,v.reject=t}):function(e){let{url:t,timeout:r,responseType:n,...o}=e,a=new AbortController,l=r?setTimeout(()=>a.abort(),r):void 0;return fetch(t,{signal:a.signal,...o}).then(e=>{if(!e.ok)throw Error("Failed fetch, not 2xx response",{cause:e});switch(n){case"arrayBuffer":return e.arrayBuffer();case"dataUrl":return e.blob().then(b);default:return e.text()}}).finally(()=>clearTimeout(l))}(E)})().catch(t=>{if(d.delete(r),"image"===n&&h)return e.log.warn("Failed to fetch image base64, trying to use placeholder image",l),"string"==typeof h?h:h(a);throw t}),d.set(r,v)}return v.response}async function z(e,t,r,n){var o,a;let l;if(!q(e))return e;for(let[i,s]of(o=e,a=t,l=[],o.replace(H,(e,t,r)=>(l.push([r,p(r,a)]),e)),l.filter(([e])=>!e.startsWith("data:"))))try{let t=await V(r,{url:s,requestType:n?"image":"text",responseType:"dataUrl"});e=e.replace(function(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}(i),`$1${t}$3`)}catch(e){r.log.warn("Failed to fetch css data url",i,e)}return e}function q(e){return/url\((['"]?)([^'"]+?)\1\)/.test(e)}let H=/url\((['"]?)([^'"]+?)\1\)/g,G=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];async function X(e,t){let{ownerDocument:r,svgStyleElement:n,fontFamilies:o,fontCssTexts:a,tasks:l,font:i}=t;if(r&&n&&o.size)if(i&&i.cssText){let e=Z(i.cssText,t);n.appendChild(r.createTextNode(`${e}
7
- `))}else{let e=Array.from(r.styleSheets).filter(e=>{try{return"cssRules"in e&&!!e.cssRules.length}catch(r){return t.log.warn(`Error while reading CSS rules from ${e.href}`,r),!1}}),i=r.implementation.createHTMLDocument(""),s=i.createElement("style");i.head.appendChild(s);let c=s.sheet;await Promise.all(e.flatMap(e=>Array.from(e.cssRules).map(async e=>{if("CSSImportRule"===e.constructor.name){let r=e.href,n="";try{n=await V(t,{url:r,requestType:"text",responseType:"text"})}catch(e){t.log.warn(`Error fetch remote css import from ${r}`,e)}for(let e of function(e){if(null==e)return[];let t=[],r=e.replace(J,"");for(;;){let e=Y.exec(r);if(!e)break;t.push(e[0])}r=r.replace(Y,"");let n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o=RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let e=n.exec(r);if(e)o.lastIndex=n.lastIndex;else if(e=o.exec(r))n.lastIndex=o.lastIndex;else break;t.push(e[0])}return t}(n.replace(H,(e,t,n)=>e.replace(n,p(n,r)))))try{c.insertRule(e,c.cssRules.length)}catch(r){t.log.warn("Error inserting rule from remote css import",{rule:e,error:r})}}}))),c.cssRules.length&&e.push(c);let u=[];e.forEach(e=>{!function e(t,r=[]){for(let n of Array.from(t))d(n)?r.push(...e(n.cssRules)):"cssRules"in n?e(n.cssRules,r):r.push(n);return r}(e.cssRules,u)}),u.filter(e=>"CSSFontFaceRule"===e.constructor.name&&q(e.style.getPropertyValue("src"))&&A(e.style.getPropertyValue("font-family"))?.some(e=>o.has(e))).forEach(e=>{let o=a.get(e.cssText);o?n.appendChild(r.createTextNode(`${o}
8
- `)):l.push(z(e.cssText,e.parentStyleSheet?e.parentStyleSheet.href:null,t).then(o=>{o=Z(o,t),a.set(e.cssText,o),n.appendChild(r.createTextNode(`${o}
9
- `))}))})}}let J=/(\/\*[\s\S]*?\*\/)/g,Y=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi,K=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Q=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Z(e,t){let{font:r}=t,n=r?r?.preferredFormat:void 0;return n?e.replace(Q,e=>{for(;;){let[t,,r]=K.exec(e)||[];if(!r)return"";if(r===n)return`src: ${t};`}}):e}let ee=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;async function et(e,t){var r;let n=await C(e,t);if(f(n.node)&&"object"==typeof n.node.className&&(r=n.node,!ee.test(r.innerHTML)))return n.node;let{ownerDocument:o,log:a,tasks:l,svgStyleElement:i,svgDefsElement:s,svgStyles:d,font:m,progress:h,autoDestruct:p,onCloneNode:b,onEmbedNode:v,onCreateForeignObjectSvg:S}=n;a.time("clone node");let E=await B(n.node,n,!0);if(i&&o){let e="";d.forEach((t,r)=>{e+=`${t.join(",\n")} {
6
+ `);return t.appendChild(r),t}async function I(e,t){let{log:r,timeout:n,drawImageCount:o,drawImageInterval:a}=t;r.time("image to canvas");let l=await S(e,{timeout:n,onWarn:t.log.warn}),{canvas:i,context2d:c}=function(e,t){let{width:r,height:n,scale:o,backgroundColor:a,maximumCanvasSize:l}=t,i=e.createElement("canvas");i.width=Math.floor(r*o),i.height=Math.floor(n*o),i.style.width=`${r}px`,i.style.height=`${n}px`,l&&(i.width>l||i.height>l)&&(i.width>l&&i.height>l?i.width>i.height?(i.height*=l/i.width,i.width=l):(i.width*=l/i.height,i.height=l):i.width>l?(i.height*=l/i.width,i.width=l):(i.width*=l/i.height,i.height=l));let c=i.getContext("2d");return c&&a&&(c.fillStyle=a,c.fillRect(0,0,i.width,i.height)),{canvas:i,context2d:c}}(e.ownerDocument,t),s=()=>{try{c?.drawImage(l,0,0,i.width,i.height)}catch(e){t.log.warn("Failed to drawImage",e)}};if(s(),t.isEnable("fixSvgXmlDecode"))for(let e=0;e<o;e++)await new Promise(t=>{setTimeout(()=>{c?.clearRect(0,0,i.width,i.height),s(),t()},e+a)});return t.drawImageCount=0,r.timeEnd("image to canvas"),i}function P(e,t){if(e.ownerDocument)try{let t=e.toDataURL();if("data:,"!==t)return v(t,e.ownerDocument)}catch(e){t.log.warn("Failed to clone canvas",e)}let r=e.cloneNode(!1),n=e.getContext("2d"),o=r.getContext("2d");try{n&&o&&o.putImageData(n.getImageData(0,0,e.width,e.height),0,0)}catch(e){t.log.warn("Failed to clone canvas",e)}return r}async function D(e,t){if(e.ownerDocument&&!e.currentSrc&&e.poster)return v(e.poster,e.ownerDocument);let r=e.cloneNode(!1);r.crossOrigin="anonymous",e.currentSrc&&e.currentSrc!==e.src&&(r.src=e.currentSrc);let n=r.ownerDocument;if(n){let o=!0;if(await S(r,{onError:()=>o=!1,onWarn:t.log.warn}),!o)return e.poster?v(e.poster,e.ownerDocument):r;r.currentTime=e.currentTime,await new Promise(e=>{r.addEventListener("seeked",e,{once:!0})});let a=n.createElement("canvas");a.width=e.offsetWidth,a.height=e.offsetHeight;try{let e=a.getContext("2d");e&&e.drawImage(r,0,0,a.width,a.height)}catch(n){if(t.log.warn("Failed to clone video",n),e.poster)return v(e.poster,e.ownerDocument);return r}return P(a,t)}return r}let $=["width","height","-webkit-text-fill-color"],F=["stroke","fill"];function M(e,t,r){let n,o,{defaultComputedStyles:a}=r,l=e.nodeName.toLowerCase(),i="object"==typeof e.className&&"svg"!==l,c=i?F.map(t=>[t,e.getAttribute(t)]).filter(([,e])=>null!==e):[],s=[i&&"svg",l,c.map((e,t)=>`${e}=${t}`).join(","),t].filter(Boolean).join(":");if(a.has(s))return a.get(s);let u=function(e){let t=e.sandbox;if(!t){let{ownerDocument:r}=e;try{r&&((t=r.createElement("iframe")).id=`__SANDBOX__${A()}`,t.width="0",t.height="0",t.style.visibility="hidden",t.style.position="fixed",r.body.appendChild(t),t.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',e.sandbox=t)}catch(t){e.log.warn("Failed to getSandBox",t)}}return t}(r),f=u?.contentWindow;if(!f)return new Map;let d=f?.document;i?(o=(n=d.createElementNS(w,"svg")).ownerDocument.createElementNS(n.namespaceURI,l),c.forEach(([e,t])=>{o.setAttributeNS(null,e,t)}),n.appendChild(o)):n=o=d.createElement(l),o.textContent=" ",d.body.appendChild(n);let h=f.getComputedStyle(o,t),m=new Map;for(let e=h.length,t=0;t<e;t++){let e=h.item(t);$.includes(e)||m.set(e,h.getPropertyValue(e))}return d.body.removeChild(n),a.set(s,m),m}function R(e,t,r){let n=new Map,o=[],a=new Map;if(r)for(let e of r)l(e);else for(let t=e.length,r=0;r<t;r++)l(e.item(r));for(let e=o.length,t=0;t<e;t++)a.get(o[t])?.forEach((e,t)=>n.set(t,e));function l(r){let l=e.getPropertyValue(r),i=e.getPropertyPriority(r),c=r.lastIndexOf("-"),s=c>-1?r.substring(0,c):void 0;if(s){let e=a.get(s);e||(e=new Map,a.set(s,e)),e.set(r,[l,i])}(t.get(r)!==l||i)&&(s?o.push(s):n.set(r,[l,i]))}return n}let _=["::before","::after"],j=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"],O=new Set(["symbol"]);async function L(e,t,r,n,o){if(d(r)&&("STYLE"===r.tagName||"SCRIPT"===r.tagName)||n.filter&&!n.filter(r))return;O.has(t.nodeName)||O.has(r.nodeName)?n.currentParentNodeStyle=void 0:n.currentParentNodeStyle=n.currentNodeStyle;let a=await B(r,n,!1,o);n.isEnable("restoreScrollPosition")&&function(e,t){if(!h(e)||!h(t))return;let{scrollTop:r,scrollLeft:n}=e;if(!r&&!n)return;let{transform:o}=t.style,a=new DOMMatrix(o),{a:l,b:i,c,d:s}=a;a.a=1,a.b=0,a.c=0,a.d=1,a.translateSelf(-n,-r),a.a=l,a.b=i,a.c=c,a.d=s,t.style.transform=a.toString()}(e,a),t.appendChild(a)}async function U(e,t,r,n){let o=e.firstChild;d(e)&&e.shadowRoot&&(o=e.shadowRoot?.firstChild,r.shadowRoots.push(e.shadowRoot));for(let a=o;a;a=a.nextSibling)if(!m(a))if(d(a)&&g(a)&&"function"==typeof a.assignedNodes){let o=a.assignedNodes();for(let a=0;a<o.length;a++)await L(e,t,o[a],r,n)}else await L(e,t,a,r,n)}let W=/^[\w-:]+$/;async function B(e,t,r=!1,n){let{ownerDocument:o,ownerWindow:a,fontFamilies:l,onCloneEachNode:i}=t;if(o&&3===e.nodeType)return n&&/\S/.test(e.data)&&n(e.data),o.createTextNode(e.data);if(o&&a&&d(e)&&(h(e)||"object"==typeof e.className)){let n=await function(e,t){if("CANVAS"===e.tagName)return P(e,t);if("IFRAME"===e.tagName){try{if(e?.contentDocument?.documentElement)return B(e.contentDocument.documentElement,t)}catch(e){t.log.warn("Failed to clone iframe",e)}return e.cloneNode(!1)}if("IMG"===e.tagName){let t;return t=e.cloneNode(!1),e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager"),t}return"VIDEO"===e.tagName?D(e,t):e.cloneNode(!1)}(e,t);if(t.isEnable("removeAbnormalAttributes")){let e=n.getAttributeNames();for(let t=e.length,r=0;r<t;r++){let t=e[r];W.test(t)||n.removeAttribute(t)}}let o=t.currentNodeStyle=function(e,t,r,n){let{ownerWindow:o,includeStyleProperties:a,currentParentNodeStyle:l}=n,i=t.style,s=o.getComputedStyle(e),u=M(e,null,n);l?.forEach((e,t)=>{u.delete(t)});let f=R(s,u,a);f.delete("transition-property"),f.delete("all"),f.delete("d"),f.delete("content"),r&&(f.delete("position"),f.delete("margin-top"),f.delete("margin-right"),f.delete("margin-bottom"),f.delete("margin-left"),f.delete("margin-block-start"),f.delete("margin-block-end"),f.delete("margin-inline-start"),f.delete("margin-inline-end"),f.set("box-sizing",["border-box",""])),f.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text"),c&&(f.has("font-kerning")||f.set("font-kerning",["normal",""]),(f.get("overflow-x")?.[0]==="hidden"||f.get("overflow-y")?.[0]==="hidden")&&f.get("text-overflow")?.[0]==="ellipsis"&&e.scrollWidth===e.clientWidth&&f.set("text-overflow",["clip",""]));for(let e=i.length,t=0;t<e;t++)i.removeProperty(i.item(t));return f.forEach(([e,t],r)=>{i.setProperty(r,e,t)}),f}(e,n,r,t);r&&function(e,t){let{backgroundColor:r,width:n,height:o,style:a}=t,l=e.style;if(r&&l.setProperty("background-color",r,"important"),n&&l.setProperty("width",`${n}px`,"important"),o&&l.setProperty("height",`${o}px`,"important"),a)for(let e in a)l[e]=a[e]}(n,t);let a=!1;if(t.isEnable("copyScrollbar")){let t=[o.get("overflow-x")?.[0],o.get("overflow-y")?.[0]];a=t.includes("scroll")||(t.includes("auto")||t.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)}let s=o.get("text-transform")?.[0],u=x(o.get("font-family")?.[0]),f=u?e=>{"uppercase"===s?e=e.toUpperCase():"lowercase"===s?e=e.toLowerCase():"capitalize"===s&&(e=e[0].toUpperCase()+e.substring(1)),u.forEach(t=>{let r=l.get(t);r||l.set(t,r=new Set),e.split("").forEach(e=>r.add(e))})}:void 0;return!function(e,t,r,n,o){let{ownerWindow:a,svgStyleElement:l,svgStyles:i,currentNodeStyle:c}=n;function s(r){let l=a.getComputedStyle(e,r),s=l.getPropertyValue("content");if(!s||"none"===s)return;o?.(s),s=s.replace(/(')|(")|(counter\(.+\))/g,"");let u=[A()],f=M(e,r,n);c?.forEach((e,t)=>{f.delete(t)});let d=R(l,f,n.includeStyleProperties);d.delete("content"),d.delete("-webkit-locale"),d.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text");let h=[`content: '${s}';`];if(d.forEach(([e,t],r)=>{h.push(`${r}: ${e}${t?" !important":""};`)}),1===h.length)return;try{t.className=[t.className,...u].join(" ")}catch(e){n.log.warn("Failed to copyPseudoClass",e);return}let m=h.join("\n "),g=i.get(m);g||(g=[],i.set(m,g)),g.push(`.${u[0]}${r}`)}l&&a&&(_.forEach(s),r&&j.forEach(s))}(e,n,a,t,f),("TEXTAREA"===e.tagName||"INPUT"===e.tagName||"SELECT"===e.tagName)&&n.setAttribute("value",e.value),"VIDEO"!==e.tagName&&await U(e,n,t,f),await i?.(n),n}let s=e.cloneNode(!1);return await U(e,s,t),await i?.(s),s}function q(e,t){let{url:r,requestType:n="text",responseType:o="text",imageDom:a}=t,l=r,{timeout:i,acceptOfImage:c,requests:f,fetchFn:d,fetch:{requestInit:h,bypassingCache:m,placeholderImage:g},font:p,workers:y,fontFamilies:w}=e;"image"===n&&(s||u)&&e.drawImageCount++;let v=f.get(r);if(!v){m&&m instanceof RegExp&&m.test(l)&&(l+=(/\?/.test(l)?"&":"?")+(new Date).getTime());let t=n.startsWith("font")&&p&&p.minify,u=new Set;t&&n.split(";")[1].split(",").forEach(e=>{w.has(e)&&w.get(e).forEach(e=>u.add(e))});let S=t&&u.size,E={url:l,timeout:i,responseType:S?"arrayBuffer":o,headers:"image"===n?{accept:c}:void 0,...h};(v={type:n,resolve:void 0,reject:void 0,response:null}).response=(async()=>{if(d&&"image"===n){let e=await d(r);if(e)return e}return!s&&r.startsWith("http")&&y.length?new Promise((e,t)=>{y[f.size&y.length-1].postMessage({rawUrl:r,...E}),v.resolve=e,v.reject=t}):function(e){let{url:t,timeout:r,responseType:n,...o}=e,a=new AbortController,l=r?setTimeout(()=>a.abort(),r):void 0;return fetch(t,{signal:a.signal,...o}).then(e=>{if(!e.ok)throw Error("Failed fetch, not 2xx response",{cause:e});switch(n){case"arrayBuffer":return e.arrayBuffer();case"dataUrl":return e.blob().then(b);default:return e.text()}}).finally(()=>clearTimeout(l))}(E)})().catch(t=>{if(f.delete(r),"image"===n&&g)return e.log.warn("Failed to fetch image base64, trying to use placeholder image",l),"string"==typeof g?g:g(a);throw t}),f.set(r,v)}return v.response}async function V(e,t,r,n){var o,a;let l;if(!z(e))return e;for(let[i,c]of(o=e,a=t,l=[],o.replace(G,(e,t,r)=>(l.push([r,p(r,a)]),e)),l.filter(([e])=>!e.startsWith("data:"))))try{let t=await q(r,{url:c,requestType:n?"image":"text",responseType:"dataUrl"});e=e.replace(function(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}(i),`$1${t}$3`)}catch(e){r.log.warn("Failed to fetch css data url",i,e)}return e}function z(e){return/url\((['"]?)([^'"]+?)\1\)/.test(e)}let G=/url\((['"]?)([^'"]+?)\1\)/g,H=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];async function X(e,t){let{ownerDocument:r,svgStyleElement:n,fontFamilies:o,fontCssTexts:a,tasks:l,font:i}=t;if(r&&n&&o.size)if(i&&i.cssText){let e=Z(i.cssText,t);n.appendChild(r.createTextNode(`${e}
7
+ `))}else{let e=Array.from(r.styleSheets).filter(e=>{try{return"cssRules"in e&&!!e.cssRules.length}catch(r){return t.log.warn(`Error while reading CSS rules from ${e.href}`,r),!1}}),i=r.implementation.createHTMLDocument(""),c=i.createElement("style");i.head.appendChild(c);let s=c.sheet;await Promise.all(e.flatMap(e=>Array.from(e.cssRules).map(async e=>{if("CSSImportRule"===e.constructor.name){let r=e.href,n="";try{n=await q(t,{url:r,requestType:"text",responseType:"text"})}catch(e){t.log.warn(`Error fetch remote css import from ${r}`,e)}for(let e of function(e){if(null==e)return[];let t=[],r=e.replace(J,"");for(;;){let e=Y.exec(r);if(!e)break;t.push(e[0])}r=r.replace(Y,"");let n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o=RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let e=n.exec(r);if(e)o.lastIndex=n.lastIndex;else if(e=o.exec(r))n.lastIndex=o.lastIndex;else break;t.push(e[0])}return t}(n.replace(G,(e,t,n)=>e.replace(n,p(n,r)))))try{s.insertRule(e,s.cssRules.length)}catch(r){t.log.warn("Error inserting rule from remote css import",{rule:e,error:r})}}}))),s.cssRules.length&&e.push(s);let u=[];e.forEach(e=>{!function e(t,r=[]){for(let n of Array.from(t))f(n)?r.push(...e(n.cssRules)):"cssRules"in n?e(n.cssRules,r):r.push(n);return r}(e.cssRules,u)}),u.filter(e=>"CSSFontFaceRule"===e.constructor.name&&z(e.style.getPropertyValue("src"))&&x(e.style.getPropertyValue("font-family"))?.some(e=>o.has(e))).forEach(e=>{let o=a.get(e.cssText);o?n.appendChild(r.createTextNode(`${o}
8
+ `)):l.push(V(e.cssText,e.parentStyleSheet?e.parentStyleSheet.href:null,t).then(o=>{o=Z(o,t),a.set(e.cssText,o),n.appendChild(r.createTextNode(`${o}
9
+ `))}))})}}let J=/(\/\*[\s\S]*?\*\/)/g,Y=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi,K=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Q=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Z(e,t){let{font:r}=t,n=r?r?.preferredFormat:void 0;return n?e.replace(Q,e=>{for(;;){let[t,,r]=K.exec(e)||[];if(!r)return"";if(r===n)return`src: ${t};`}}):e}let ee=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;async function et(e,t){var r;let n=await N(e,t);if(d(n.node)&&"object"==typeof n.node.className&&(r=n.node,!ee.test(r.innerHTML)))return n.node;let{ownerDocument:o,log:a,tasks:l,svgStyleElement:i,svgDefsElement:c,svgStyles:f,font:m,progress:g,autoDestruct:p,onCloneNode:b,onEmbedNode:v,onCreateForeignObjectSvg:S}=n;a.time("clone node");let E=await B(n.node,n,!0);if(i&&o){let e="";f.forEach((t,r)=>{e+=`${t.join(",\n")} {
10
10
  ${r}
11
11
  }
12
- `}),i.appendChild(o.createTextNode(e))}a.timeEnd("clone node"),await b?.(E),!1!==m&&f(E)&&(a.time("embed web font"),await X(E,n),a.timeEnd("embed web font")),a.time("embed node"),function e(t,r){var n;let{tasks:o}=r;f(t)&&(("IMG"===t.tagName||"image"===t.tagName)&&o.push(...function(e,t){if("IMG"===e.tagName){let r=e.currentSrc||e.src;if(!r.startsWith("data:"))return[V(t,{url:r,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(t=>{t&&(e.srcset="",e.dataset.originalSrc=r,e.src=t||"")})];(c||u)&&t.drawImageCount++}else if("object"==typeof e.className&&!e.href.baseVal.startsWith("data:")){let r=e.href.baseVal;return[V(t,{url:r,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(t=>{t&&(e.dataset.originalSrc=r,e.href.baseVal=t||"")})]}return[]}(t,r)),"use"===t.tagName&&o.push(...function(e,t){let{ownerDocument:r,svgDefsElement:n}=t,o=e.getAttribute("href")??e.getAttribute("xlink:href");if(!o)return[];let[a,l]=o.split("#");if(l){let o=`#${l}`,i=t.shadowRoots.reduce((e,t)=>e??t.querySelector(`svg ${o}`),r?.querySelector(`svg ${o}`));if(a&&e.setAttribute("href",o),n?.querySelector(o))return[];if(i)n?.appendChild(i.cloneNode(!0));else if(a)return[V(t,{url:a,responseType:"text"}).then(e=>{n?.insertAdjacentHTML("beforeend",e)})]}return[]}(t,r))),g(t)&&o.push(...(n=t.style,G.map(e=>{let t=n.getPropertyValue(e);return t&&"none"!==t?((c||u)&&r.drawImageCount++,z(t,null,r,!0).then(r=>{r&&t!==r&&n.setProperty(e,r,n.getPropertyPriority(e))})):null}).filter(Boolean))),t.childNodes.forEach(t=>{e(t,r)})}(E,n);let x=l.length,A=0,N=async()=>{for(;;){let e=l.pop();if(!e)break;try{await e}catch(e){n.log.warn("Failed to run task",e)}h?.(++A,x)}};h?.(A,x),await Promise.all([...Array.from({length:4})].map(N)),a.timeEnd("embed node"),await v?.(E);let k=function(e,t){let r,{width:n,height:o}=t,a=((r=w(e.ownerDocument).createElementNS(y,"svg")).setAttributeNS(null,"width",n.toString()),r.setAttributeNS(null,"height",o.toString()),r.setAttributeNS(null,"viewBox",`0 0 ${n} ${o}`),r),l=a.ownerDocument.createElementNS(a.namespaceURI,"foreignObject");return l.setAttributeNS(null,"x","0%"),l.setAttributeNS(null,"y","0%"),l.setAttributeNS(null,"width","100%"),l.setAttributeNS(null,"height","100%"),l.append(e),a.appendChild(l),a}(E,n);return s&&k.insertBefore(s,k.children[0]),i&&k.insertBefore(i,k.children[0]),p&&function(e){if(e.ownerDocument=void 0,e.ownerWindow=void 0,e.svgStyleElement=void 0,e.svgDefsElement=void 0,e.svgStyles.clear(),e.defaultComputedStyles.clear(),e.sandbox){try{e.sandbox.remove()}catch(t){e.log.warn("Failed to destroyContext",t)}e.sandbox=void 0}e.workers=[],e.fontFamilies.clear(),e.fontCssTexts.clear(),e.requests.clear(),e.tasks=[],e.shadowRoots=[]}(n),await S?.(k),k}async function er(e,t){var r;let n,o=await C(e,t),a=await et(o),l=(r=o.isEnable("removeControlCharacter"),n=new XMLSerializer().serializeToString(a),r&&(n=n.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`);o.autoDestruct||(o.svgStyleElement=T(o.ownerDocument),o.svgDefsElement=o.ownerDocument?.createElementNS(y,"defs"),o.svgStyles.clear());let i=v(l,a.ownerDocument);return await I(i,o)}async function en(t,r){let n=await C(t,r),{log:o,quality:i,type:s,dpi:c}=n,u=await er(n);o.time("canvas to data url");let d=u.toDataURL(s,i);if(["image/png","image/jpeg"].includes(s)&&c&&a&&l){let[t,r]=d.split(","),n=0,o=!1;if("image/png"===s){let e,t=(-1===(e=r.indexOf("AAlwSFlz"))&&(e=r.indexOf("AAAJcEhZ")),-1===e&&(e=r.indexOf("AAAACXBI")),e);t>=0?(n=4*Math.ceil((t+28)/3),o=!0):n=44}else"image/jpeg"===s&&(n=24);let a=r.substring(0,n),l=r.substring(n),i=window.atob(a),u=new Uint8Array(i.length);for(let e=0;e<u.length;e++)u[e]=i.charCodeAt(e);let f="image/png"===s?function(t,r,n=!1){let o=new Uint8Array(13);r*=39.3701,o[0]=112,o[1]=72,o[2]=89,o[3]=115,o[4]=r>>>24,o[5]=r>>>16,o[6]=r>>>8,o[7]=255&r,o[8]=o[4],o[9]=o[5],o[10]=o[6],o[11]=o[7],o[12]=1;let a=function(t){let r=-1;e||(e=function(){let e=new Int32Array(256);for(let t=0;t<256;t++){let r=t;for(let e=0;e<8;e++)r=1&r?0xedb88320^r>>>1:r>>>1;e[t]=r}return e}());for(let n=0;n<t.length;n++)r=e[(r^t[n])&255]^r>>>8;return -1^r}(o),l=new Uint8Array(4);if(l[0]=a>>>24,l[1]=a>>>16,l[2]=a>>>8,l[3]=255&a,n){let e=function(e){let t=e.length-1;for(let r=t;r>=4;r--)if(9===e[r-4]&&112===e[r-3]&&72===e[r-2]&&89===e[r-1]&&115===e[r])return r-3;return 0}(t);return t.set(o,e),t.set(l,e+13),t}{let e=new Uint8Array(4);e[0]=0,e[1]=0,e[2]=0,e[3]=9;let r=new Uint8Array(54);return r.set(t,0),r.set(e,33),r.set(o,37),r.set(l,50),r}}(u,c,o):(u[13]=1,u[14]=c>>8,u[15]=255&c,u[16]=c>>8,u[17]=255&c,u);d=[t,",",window.btoa(String.fromCharCode(...f)),l].join("")}return o.timeEnd("canvas to data url"),d}async function eo(e,t){return en(await C(e,{...t,type:"image/png"}))}function ea(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function el(e,t,r,n,o,a,l){try{var i=e[a](l),s=i.value}catch(e){r(e);return}i.done?t(s):Promise.resolve(s).then(n,o)}function ei(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function l(e){el(a,n,o,l,i,"next",e)}function i(e){el(a,n,o,l,i,"throw",e)}l(void 0)})}}function es(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(l,"next",{value:s(0)}),i(l,"throw",{value:s(1)}),i(l,"return",{value:s(2)}),"function"==typeof Symbol&&i(l,Symbol.iterator,{value:function(){return this}}),l;function s(i){return function(s){var c=[i,s];if(r)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var ec="".concat("https:"===location.protocol?"wss":"ws","://").concat(location.host,"/server/api/pages/socket"),eu="cdk-browser-id",ed=function(){for(var e,t,r=arguments.length,n=Array(r),o=0;o<r;o++)n[o]=arguments[o];return null==(t=window.__cdkConsole)||null==(e=t.info)?void 0:e.call.apply(e,[t,"MCP:"].concat(function(e){if(Array.isArray(e))return ea(e)}(n)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||function(e){if(e){if("string"==typeof e)return ea(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ea(e,void 0)}}(n)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))},ef={call:{prefix:"MCP ->",style:"color: #1971c2; font-weight: bold"},result:{prefix:"MCP <-",style:"color: #495057"},error:{prefix:"MCP !!",style:"color: #e03131; font-weight: bold"}},eg=null,em=1e3,eh=null,ep=null;function ew(e){(null==eg?void 0:eg.readyState)===WebSocket.OPEN&&eg.send(JSON.stringify(e))}var ey={evaluate:function(e){var t=e.code;return(0,eval)("(async () => (".concat(t,"))()"))},read_console:function(e){var t=e.since;return window.__cdkConsoleEntries(void 0===t?0:t)},screenshot:function(e){return ei(function(e){var t,r,n,o,a;return es(this,function(l){switch(l.label){case 0:if(t=e.selector,!(r=document.querySelector(t)))throw Error("Nothing matches ".concat(t,"."));if(n=r.offsetWidth,o=r.offsetHeight,!n||!o)throw Error("".concat(t," has no size (").concat(n,"x").concat(o,"); the deck may still be laying out."));return[4,eo(r,{scale:1,width:n,height:o,style:{transform:"none",transformOrigin:"0 0"}})];case 1:if((a=l.sent().replace(/^data:image\/png;base64,/,"")).length<100)throw Error("Screenshot of ".concat(t," came back empty; the deck may not be fully rendered."));return[2,{data:a,mimeType:"image/png"}]}})}).apply(this,arguments)},deck:function(e){var t=e.command,r=e.args;if(!window.__cdkMcp)throw Error("The cdk app has not finished loading in this browser. Wait for it and try again.");return window.__cdkMcp.run(t,r)}};setInterval(function(){(null==eg?void 0:eg.readyState)===WebSocket.OPEN&&location.href!==ep&&ew({type:"url_changed",url:ep=location.href})},250),!function e(){(eg=new WebSocket(ec)).addEventListener("open",function(){em=1e3,ep=location.href,ew({type:"hello",id:function(){var e=sessionStorage.getItem(eu);if(e)return e;var t="browser-".concat(Math.random().toString(36).slice(2,8));return sessionStorage.setItem(eu,t),t}(),url:ep})}),eg.addEventListener("message",function(e){var t,r;try{t=JSON.parse(e.data)}catch(e){return}if("welcome"===t.type){sessionStorage.setItem(eu,t.id),ed("connected as ".concat(t.id));return}"announce"===t.type?function(e){var t,r,n,o,a,l=e.text,i=e.value,s=e.kind,c=null!=(t=ef[s])?t:ef.call,u=c.prefix,d=c.style;if("result"===s){null==(a=window.__cdkConsole)||null==(o=a.info)||o.call(a,"%c".concat(u),d,i);return}null==(n=window.__cdkConsole)||null==(r=n.info)||r.call(n,"%c".concat(u," ").concat(l),d)}(t):(r=t,ei(function(){var e,t,n;return es(this,function(o){switch(o.label){case 0:if(!(e=ey[r.type]))return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),t={type:"result",id:r.id,ok:!0},[4,e(r)];case 2:return ew.apply(void 0,[(t.value=o.sent(),t)]),[3,4];case 3:var a;return n=o.sent(),ew({type:"result",id:r.id,ok:!1,error:(null!=(a=Error)&&"u">typeof Symbol&&a[Symbol.hasInstance]?!!a[Symbol.hasInstance](n):n instanceof a)?n.message:String(n)}),[3,4];case 4:return[2]}})})())}),eg.addEventListener("close",function(){null===eh&&(eh=setTimeout(function(){eh=null,em=Math.min(2*em,3e4),e()},em))})}()})();
12
+ `}),i.appendChild(o.createTextNode(e))}a.timeEnd("clone node"),await b?.(E),!1!==m&&d(E)&&(a.time("embed web font"),await X(E,n),a.timeEnd("embed web font")),a.time("embed node"),function e(t,r){var n;let{tasks:o}=r;d(t)&&(("IMG"===t.tagName||"image"===t.tagName)&&o.push(...function(e,t){if("IMG"===e.tagName){let r=e.currentSrc||e.src;if(!r.startsWith("data:"))return[q(t,{url:r,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(t=>{t&&(e.srcset="",e.dataset.originalSrc=r,e.src=t||"")})];(s||u)&&t.drawImageCount++}else if("object"==typeof e.className&&!e.href.baseVal.startsWith("data:")){let r=e.href.baseVal;return[q(t,{url:r,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(t=>{t&&(e.dataset.originalSrc=r,e.href.baseVal=t||"")})]}return[]}(t,r)),"use"===t.tagName&&o.push(...function(e,t){let{ownerDocument:r,svgDefsElement:n}=t,o=e.getAttribute("href")??e.getAttribute("xlink:href");if(!o)return[];let[a,l]=o.split("#");if(l){let o=`#${l}`,i=t.shadowRoots.reduce((e,t)=>e??t.querySelector(`svg ${o}`),r?.querySelector(`svg ${o}`));if(a&&e.setAttribute("href",o),n?.querySelector(o))return[];if(i)n?.appendChild(i.cloneNode(!0));else if(a)return[q(t,{url:a,responseType:"text"}).then(e=>{n?.insertAdjacentHTML("beforeend",e)})]}return[]}(t,r))),h(t)&&o.push(...(n=t.style,H.map(e=>{let t=n.getPropertyValue(e);return t&&"none"!==t?((s||u)&&r.drawImageCount++,V(t,null,r,!0).then(r=>{r&&t!==r&&n.setProperty(e,r,n.getPropertyPriority(e))})):null}).filter(Boolean))),t.childNodes.forEach(t=>{e(t,r)})}(E,n);let A=l.length,x=0,C=async()=>{for(;;){let e=l.pop();if(!e)break;try{await e}catch(e){n.log.warn("Failed to run task",e)}g?.(++x,A)}};g?.(x,A),await Promise.all([...Array.from({length:4})].map(C)),a.timeEnd("embed node"),await v?.(E);let k=function(e,t){let r,{width:n,height:o}=t,a=((r=y(e.ownerDocument).createElementNS(w,"svg")).setAttributeNS(null,"width",n.toString()),r.setAttributeNS(null,"height",o.toString()),r.setAttributeNS(null,"viewBox",`0 0 ${n} ${o}`),r),l=a.ownerDocument.createElementNS(a.namespaceURI,"foreignObject");return l.setAttributeNS(null,"x","0%"),l.setAttributeNS(null,"y","0%"),l.setAttributeNS(null,"width","100%"),l.setAttributeNS(null,"height","100%"),l.append(e),a.appendChild(l),a}(E,n);return c&&k.insertBefore(c,k.children[0]),i&&k.insertBefore(i,k.children[0]),p&&function(e){if(e.ownerDocument=void 0,e.ownerWindow=void 0,e.svgStyleElement=void 0,e.svgDefsElement=void 0,e.svgStyles.clear(),e.defaultComputedStyles.clear(),e.sandbox){try{e.sandbox.remove()}catch(t){e.log.warn("Failed to destroyContext",t)}e.sandbox=void 0}e.workers=[],e.fontFamilies.clear(),e.fontCssTexts.clear(),e.requests.clear(),e.tasks=[],e.shadowRoots=[]}(n),await S?.(k),k}async function er(e,t){var r;let n,o=await N(e,t),a=await et(o),l=(r=o.isEnable("removeControlCharacter"),n=new XMLSerializer().serializeToString(a),r&&(n=n.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`);o.autoDestruct||(o.svgStyleElement=T(o.ownerDocument),o.svgDefsElement=o.ownerDocument?.createElementNS(w,"defs"),o.svgStyles.clear());let i=v(l,a.ownerDocument);return await I(i,o)}async function en(t,r){let n=await N(t,r),{log:o,quality:i,type:c,dpi:s}=n,u=await er(n);o.time("canvas to data url");let f=u.toDataURL(c,i);if(["image/png","image/jpeg"].includes(c)&&s&&a&&l){let[t,r]=f.split(","),n=0,o=!1;if("image/png"===c){let e,t=(-1===(e=r.indexOf("AAlwSFlz"))&&(e=r.indexOf("AAAJcEhZ")),-1===e&&(e=r.indexOf("AAAACXBI")),e);t>=0?(n=4*Math.ceil((t+28)/3),o=!0):n=44}else"image/jpeg"===c&&(n=24);let a=r.substring(0,n),l=r.substring(n),i=window.atob(a),u=new Uint8Array(i.length);for(let e=0;e<u.length;e++)u[e]=i.charCodeAt(e);let d="image/png"===c?function(t,r,n=!1){let o=new Uint8Array(13);r*=39.3701,o[0]=112,o[1]=72,o[2]=89,o[3]=115,o[4]=r>>>24,o[5]=r>>>16,o[6]=r>>>8,o[7]=255&r,o[8]=o[4],o[9]=o[5],o[10]=o[6],o[11]=o[7],o[12]=1;let a=function(t){let r=-1;e||(e=function(){let e=new Int32Array(256);for(let t=0;t<256;t++){let r=t;for(let e=0;e<8;e++)r=1&r?0xedb88320^r>>>1:r>>>1;e[t]=r}return e}());for(let n=0;n<t.length;n++)r=e[(r^t[n])&255]^r>>>8;return -1^r}(o),l=new Uint8Array(4);if(l[0]=a>>>24,l[1]=a>>>16,l[2]=a>>>8,l[3]=255&a,n){let e=function(e){let t=e.length-1;for(let r=t;r>=4;r--)if(9===e[r-4]&&112===e[r-3]&&72===e[r-2]&&89===e[r-1]&&115===e[r])return r-3;return 0}(t);return t.set(o,e),t.set(l,e+13),t}{let e=new Uint8Array(4);e[0]=0,e[1]=0,e[2]=0,e[3]=9;let r=new Uint8Array(54);return r.set(t,0),r.set(e,33),r.set(o,37),r.set(l,50),r}}(u,s,o):(u[13]=1,u[14]=s>>8,u[15]=255&s,u[16]=s>>8,u[17]=255&s,u);f=[t,",",window.btoa(String.fromCharCode(...d)),l].join("")}return o.timeEnd("canvas to data url"),f}async function eo(e,t){return en(await N(e,{...t,type:"image/png"}))}function ea(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function el(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw n}}return a}}(e,t)||ei(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ei(e,t){if(e){if("string"==typeof e)return ea(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ea(e,t)}}function ec(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function es(e,t,r,n,o,a,l){try{var i=e[a](l),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,o)}function eu(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function l(e){es(a,n,o,l,i,"next",e)}function i(e){es(a,n,o,l,i,"throw",e)}l(void 0)})}}function ef(e){return function(e){if(Array.isArray(e))return ec(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return ec(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ec(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ed(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(l,"next",{value:c(0)}),i(l,"throw",{value:c(1)}),i(l,"return",{value:c(2)}),"function"==typeof Symbol&&i(l,Symbol.iterator,{value:function(){return this}}),l;function c(i){return function(c){var s=[i,c];if(r)throw TypeError("Generator is already executing.");for(;l&&(l=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}var eh=/url\(\s*(["']?)([^"')]+)\1\s*\)/g;function em(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function eg(e,t,r,n,o,a,l){try{var i=e[a](l),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,o)}function ep(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function l(e){eg(a,n,o,l,i,"next",e)}function i(e){eg(a,n,o,l,i,"throw",e)}l(void 0)})}}function ey(e){return function(e){if(Array.isArray(e))return em(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return em(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return em(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ew(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(l,"next",{value:c(0)}),i(l,"throw",{value:c(1)}),i(l,"return",{value:c(2)}),"function"==typeof Symbol&&i(l,Symbol.iterator,{value:function(){return this}}),l;function c(i){return function(c){var s=[i,c];if(r)throw TypeError("Generator is already executing.");for(;l&&(l=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}var eb="".concat("https:"===location.protocol?"wss":"ws","://").concat(location.host,"/server/api/pages/socket"),ev="cdk-browser-id",eS=function(){for(var e,t,r=arguments.length,n=Array(r),o=0;o<r;o++)n[o]=arguments[o];return null==(t=window.__cdkConsole)||null==(e=t.info)?void 0:e.call.apply(e,[t,"MCP:"].concat(ey(n)))},eE={call:{prefix:"MCP ->",style:"color: #1971c2; font-weight: bold"},result:{prefix:"MCP <-",style:"color: #495057"},error:{prefix:"MCP !!",style:"color: #e03131; font-weight: bold"}},eA=null,ex=1e3,eC=null,eN=null;function ek(e){(null==eA?void 0:eA.readyState)===WebSocket.OPEN&&eA.send(JSON.stringify(e))}function eT(e){return ep(function(){var t;return ew(this,function(r){switch(r.label){case 0:return[4,fetch(e).then(function(e){return e.blob()})];case 1:return t=r.sent(),[2,new Promise(function(e,r){var n=new FileReader;n.onload=function(){return e(n.result)},n.onerror=function(){return r(n.error)},n.readAsDataURL(t)})]}})})()}var eI={evaluate:function(e){var t=e.code;return(0,eval)("(async () => (".concat(t,"))()"))},read_console:function(e){var t=e.since;return window.__cdkConsoleEntries(void 0===t?0:t)},screenshot:function(e){return ep(function(e){var t,r,n,o,a;return ew(this,function(l){switch(l.label){case 0:var i;if(t=e.selector,!(r=document.querySelector(t)))throw Error("Nothing matches ".concat(t,"."));return[4,(i=r,ep(function(){var e,t;return ew(this,function(r){switch(r.label){case 0:return e=i.getAnimations({subtree:!0}).filter(function(e){var t;return(null==(t=e.effect)?void 0:t.getTiming().iterations)!==1/0}).map(function(e){return e.finished.catch(function(){})}),t=new Promise(function(e){setTimeout(e,3e3)}),[4,Promise.race([Promise.all(e),t])];case 1:return r.sent(),[2]}})})())];case 1:if(l.sent(),n=r.offsetWidth,o=r.offsetHeight,!n||!o)throw Error("".concat(t," has no size (").concat(n,"x").concat(o,"); the deck may still be laying out."));return[4,eo(r,{scale:1,width:n,height:o,style:{transform:"none",transformOrigin:"0 0"},onCloneNode:function(e){return function(e,t){var r=e.querySelectorAll("select"),n=t.querySelectorAll("select");if(n.length===r.length){var o=!0,a=!1,l=void 0;try{for(var i,c=r.entries()[Symbol.iterator]();!(o=(i=c.next()).done);o=!0){var s=el(i.value,2),u=s[0],f=s[1],d=!0,h=!1,m=void 0;try{for(var g,p,y=(g=n[u].options,function(e){if(Array.isArray(e))return ea(e)}(g)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(g)||ei(g)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).entries()[Symbol.iterator]();!(d=(p=y.next()).done);d=!0){var w=el(p.value,2),b=w[0];w[1].toggleAttribute("selected",b===f.selectedIndex)}}catch(e){h=!0,m=e}finally{try{d||null==y.return||y.return()}finally{if(h)throw m}}}}catch(e){a=!0,l=e}finally{try{o||null==c.return||c.return()}finally{if(a)throw l}}}}(r,e)},onCreateForeignObjectSvg:function(e){return eu(function(){var t,r,n,o,a,l,i;return ed(this,function(c){switch(c.label){case 0:t=!0,r=!1,n=void 0,c.label=1;case 1:c.trys.push([1,6,7,8]),o=function(){var e,t,r,n;return ed(this,function(o){switch(o.label){case 0:return t=ef((e=l.value).textContent.matchAll(eh)).map(function(e){return e[2]}).filter(function(e){return!e.startsWith("data:")}),n=Map.bind,[4,Promise.all(ef(new Set(t)).map(function(e){return eu(function(){var t;return ed(this,function(r){switch(r.label){case 0:return t=[e],[4,eT(e)];case 1:return[2,t.concat([r.sent()])]}})})()}))];case 1:return r=new(n.apply(Map,[void 0,o.sent()])),e.textContent=e.textContent.replace(eh,function(e,t,n){var o=r.get(n);return o?'url("'.concat(o,'")'):e}),[2]}})},a=e.querySelectorAll("style")[Symbol.iterator](),c.label=2;case 2:if(t=(l=a.next()).done)return[3,5];return[5,function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(o())];case 3:c.sent(),c.label=4;case 4:return t=!0,[3,2];case 5:return[3,8];case 6:return i=c.sent(),r=!0,n=i,[3,8];case 7:try{t||null==a.return||a.return()}finally{if(r)throw n}return[7];case 8:return[2]}})})()}})];case 2:if((a=l.sent().replace(/^data:image\/png;base64,/,"")).length<100)throw Error("Screenshot of ".concat(t," came back empty; the deck may not be fully rendered."));return[2,{data:a,mimeType:"image/png",blankFrames:ey(r.querySelectorAll("iframe")).map(function(e){return e.src})}]}})}).apply(this,arguments)},deck:function(e){var t=e.command,r=e.args;if(!window.cdk)throw Error("The cdk app has not finished loading in this browser. Wait for it and try again.");return window.cdk.run(t,r)}};function eP(){(eA=new WebSocket(eb)).addEventListener("open",function(){ex=1e3,eN=location.href,ek({type:"hello",id:function(){var e=sessionStorage.getItem(ev);if(e)return e;var t="browser-".concat(Math.random().toString(36).slice(2,8));return sessionStorage.setItem(ev,t),t}(),url:eN})}),eA.addEventListener("message",function(e){var t,r;try{t=JSON.parse(e.data)}catch(e){return}if("welcome"===t.type){sessionStorage.setItem(ev,t.id),eS("connected as ".concat(t.id));return}"announce"===t.type?function(e){var t,r,n,o,a,l=e.text,i=e.value,c=e.kind,s=null!=(t=eE[c])?t:eE.call,u=s.prefix,f=s.style;if("result"===c){null==(a=window.__cdkConsole)||null==(o=a.info)||o.call(a,"%c".concat(u),f,i);return}null==(n=window.__cdkConsole)||null==(r=n.info)||r.call(n,"%c".concat(u," ").concat(l),f)}(t):(r=t,ep(function(){var e,t,n;return ew(this,function(o){switch(o.label){case 0:if(!(e=eI[r.type]))return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),t={type:"result",id:r.id,ok:!0},[4,e(r)];case 2:return ek.apply(void 0,[(t.value=o.sent(),t)]),[3,4];case 3:var a;return n=o.sent(),ek({type:"result",id:r.id,ok:!1,error:(null!=(a=Error)&&"u">typeof Symbol&&a[Symbol.hasInstance]?!!a[Symbol.hasInstance](n):n instanceof a)?n.message:String(n)}),[3,4];case 4:return[2]}})})())}),eA.addEventListener("close",function(){null===eC&&(eC=setTimeout(function(){eC=null,ex=Math.min(2*ex,3e4),eP()},ex))})}setInterval(function(){(null==eA?void 0:eA.readyState)===WebSocket.OPEN&&location.href!==eN&&ek({type:"url_changed",url:eN=location.href})},250),window.addEventListener("pagehide",function(){clearTimeout(eC),eC=null,null==eA||eA.close()}),window.addEventListener("pageshow",function(e){e.persisted&&eP()}),eP()})();
13
13
  //# sourceMappingURL=mcp-page-client.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livepreso/cdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Content Development Kit",
5
5
  "bin": {
6
6
  "livepreso-cdk": "./dist/backend/cli.mjs"
@@ -13,7 +13,7 @@
13
13
  "dist/favicon.png",
14
14
  "dist/assets",
15
15
  "dist/backend",
16
- "src/shared/modes.mjs"
16
+ "src/shared"
17
17
  ],
18
18
  "devDependencies": {
19
19
  "html-webpack-plugin": "~5.5.3",
@@ -56,12 +56,12 @@
56
56
  "@rspack/core": "2.2.1",
57
57
  "@rspack/dev-server": "2.2.1",
58
58
  "@rspack/plugin-react-refresh": "2.0.2",
59
- "@livepreso/eslint-config": "1.0.0",
60
59
  "sp-get-port-by-name": "0.0.1",
61
- "@livepreso/presenter": "2.50.3",
62
60
  "sp-editable-components": "1.7.2",
63
- "@livepreso/deck-interface": "0.0.1",
64
- "sp-components": "3.1.1"
61
+ "@livepreso/eslint-config": "1.0.0",
62
+ "@livepreso/presenter": "2.50.3",
63
+ "sp-components": "3.1.1",
64
+ "@livepreso/deck-interface": "0.0.1"
65
65
  },
66
66
  "dependencies": {
67
67
  "@modelcontextprotocol/sdk": "~1.29.0",
@@ -85,7 +85,8 @@
85
85
  "@fastify/cors": "~10.0.0",
86
86
  "@fastify/static": "~8.0.0",
87
87
  "jsondiffpatch": "~0.6.0",
88
- "@livepreso/api": "6.58.2"
88
+ "playwright-core": "~1.64.0",
89
+ "@livepreso/api": "7.0.0"
89
90
  },
90
91
  "scripts": {
91
92
  "serve": "rspack serve --config webpack.development.js --env development",
@@ -0,0 +1,2 @@
1
+ // Where the deck's built files are served from.
2
+ export const DECK_ASSETS_PREFIX = "/server/deck/";
@@ -0,0 +1,35 @@
1
+ export const EMPTY_FIXTURE = "empty";
2
+
3
+ /**
4
+ * Selects the fixture called `name` in every context, feed, env and CMSVal set that has one. The rest
5
+ * stay empty.
6
+ */
7
+ export function selectFixturesNamed(
8
+ name,
9
+ { contexts, feeds, envs, cmsValSets = [] },
10
+ ) {
11
+ const selectedFeeds = {};
12
+ const selectedEnvs = {};
13
+
14
+ for (const feed of feeds) {
15
+ if (feed.testFeeds.some((testFeed) => testFeed.key === name)) {
16
+ selectedFeeds[feed.key] = name;
17
+ }
18
+ }
19
+
20
+ for (const [envType, options] of Object.entries(envs)) {
21
+ if (options.some((option) => option.key === name)) {
22
+ selectedEnvs[envType] = name;
23
+ }
24
+ }
25
+
26
+ const hasContext = contexts.some((context) => context.key === name);
27
+ const hasCmsVals = cmsValSets.some((cmsValSet) => cmsValSet.key === name);
28
+
29
+ return {
30
+ selectedContext: hasContext ? name : EMPTY_FIXTURE,
31
+ selectedCmsVals: hasCmsVals ? name : EMPTY_FIXTURE,
32
+ selectedFeeds,
33
+ selectedEnvs,
34
+ };
35
+ }
@@ -0,0 +1,38 @@
1
+ import { selectFixturesNamed } from "./fixtures.mjs";
2
+
3
+ describe("selectFixturesNamed", () => {
4
+ it("should select the name wherever a fixture has it", () => {
5
+ const onDisk = {
6
+ contexts: [{ key: "alpha" }],
7
+ feeds: [
8
+ { key: "one", testFeeds: [{ key: "alpha" }] },
9
+ { key: "two", testFeeds: [{ key: "beta" }] },
10
+ ],
11
+ envs: { user: [{ key: "alpha" }], tenancy: [{ key: "beta" }] },
12
+ };
13
+
14
+ expect(selectFixturesNamed("alpha", onDisk)).toEqual({
15
+ selectedContext: "alpha",
16
+ selectedCmsVals: "empty",
17
+ selectedFeeds: { one: "alpha" },
18
+ selectedEnvs: { user: "alpha" },
19
+ });
20
+ });
21
+
22
+ it("should leave the context empty where no context has the name", () => {
23
+ const onDisk = { contexts: [{ key: "beta" }], feeds: [], envs: {} };
24
+
25
+ expect(selectFixturesNamed("alpha", onDisk).selectedContext).toBe("empty");
26
+ });
27
+
28
+ it("should select the CMSVal fixture with the name", () => {
29
+ const onDisk = {
30
+ contexts: [],
31
+ feeds: [],
32
+ envs: {},
33
+ cmsValSets: [{ key: "alpha" }],
34
+ };
35
+
36
+ expect(selectFixturesNamed("alpha", onDisk).selectedCmsVals).toBe("alpha");
37
+ });
38
+ });
@@ -25,6 +25,7 @@ export const PRESENT_STATES = [
25
25
  title: "Preso",
26
26
  key: "preso",
27
27
  description: "Screens for a preso",
28
+ isAppointment: true,
28
29
  childrenDescription: "Preso present types",
29
30
  editStore: CONTEXT_OVERRIDES,
30
31
  children: [
@@ -195,6 +196,7 @@ export const PRESENT_STATES = [
195
196
  {
196
197
  title: "Link",
197
198
  key: "link",
199
+ isAppointment: true,
198
200
  description:
199
201
  "Links of various sorts for accessing LivePreso outside of the main app",
200
202
  childrenDescription: "What type of link",
@@ -212,6 +214,7 @@ export const PRESENT_STATES = [
212
214
  bodyClasses: ["screenshot", "share_online"],
213
215
  childrenDescription: "What type of screenshot",
214
216
  isScreenshot: true,
217
+ isAppointment: true,
215
218
  editStore: CONTEXT_OVERRIDES,
216
219
  isReadOnly: true,
217
220
  children: [
@@ -261,6 +264,8 @@ function collectModes(nodes, ancestors) {
261
264
  showEditables: nodes.some((state) => state.showEditables),
262
265
  isPresomanager: nodes.some((state) => state.key === "presomanager"),
263
266
  isScreenshot: nodes.some((state) => state.key === "screenshot"),
267
+ // Shows one preso, so a deck's selections hook has run on it.
268
+ isAppointment: nodes.some((state) => state.isAppointment),
264
269
  isEmptyPreview: nodes.some((state) =>
265
270
  state.bodyClasses?.includes("empty-preview"),
266
271
  ),
@@ -0,0 +1,87 @@
1
+ import {
2
+ MODES,
3
+ findModeByIndices,
4
+ findModeByPath,
5
+ PRESENT_STATES,
6
+ } from "./modes.mjs";
7
+
8
+ describe("MODES", () => {
9
+ it("only contains states with no children", () => {
10
+ const leaves = MODES.map((mode) => mode.path);
11
+
12
+ expect(leaves).toContain("app/preso/prep/prepping");
13
+ expect(leaves).not.toContain("app/preso/prep");
14
+ expect(leaves).not.toContain("app");
15
+ });
16
+
17
+ it("indexes each step by its position in PRESENT_STATES", () => {
18
+ const mode = findModeByPath("app/presomanager/edit");
19
+
20
+ expect(mode.indices).toEqual([0, 1, 0]);
21
+ expect(PRESENT_STATES[0].children[1].children[0].key).toBe("edit");
22
+ });
23
+
24
+ it("titles a mode with the states it came through", () => {
25
+ expect(findModeByPath("app/preso/prep/prepping").title).toBe(
26
+ "App > Preso > Prep > Prepping",
27
+ );
28
+ });
29
+
30
+ it("describes a mode with the nearest description above it", () => {
31
+ expect(findModeByPath("app/preso/prep/prepping").description).toBe(
32
+ "Test preparing a preso - contains editables and the like usually",
33
+ );
34
+ });
35
+
36
+ it("reports whether editables are shown", () => {
37
+ expect(findModeByPath("app/preso/prep/prepping").showEditables).toBe(true);
38
+ expect(findModeByPath("app/preso/prep/previewing").showEditables).toBe(
39
+ false,
40
+ );
41
+ });
42
+
43
+ it("offers no editables where a template is only being looked at", () => {
44
+ expect(
45
+ findModeByPath("app/preso/add-slides/template-preview").showEditables,
46
+ ).toBe(false);
47
+ expect(
48
+ findModeByPath("app/presomanager/template-preview").showEditables,
49
+ ).toBe(false);
50
+ });
51
+
52
+ it("inherits flags from the states above the leaf", () => {
53
+ expect(findModeByPath("app/presomanager/edit").isPresomanager).toBe(true);
54
+ expect(findModeByPath("screenshot/pdf").isScreenshot).toBe(true);
55
+ });
56
+
57
+ it("reports the modes rendering with no presentation behind them", () => {
58
+ expect(findModeByPath("app/presomanager/preview").isEmptyPreview).toBe(
59
+ true,
60
+ );
61
+ expect(findModeByPath("app/preset").isEmptyPreview).toBe(true);
62
+ });
63
+
64
+ it("leaves flags off modes outside those states", () => {
65
+ const present = findModeByPath("app/preso/present");
66
+
67
+ expect(present.isPresomanager).toBe(false);
68
+ expect(present.isScreenshot).toBe(false);
69
+ expect(present.isEmptyPreview).toBe(false);
70
+ });
71
+ });
72
+
73
+ describe("finding a mode", () => {
74
+ it("round trips between a path and indices", () => {
75
+ for (const mode of MODES) {
76
+ expect(findModeByIndices(mode.indices).path).toBe(mode.path);
77
+ }
78
+ });
79
+
80
+ it("returns null for an unknown path", () => {
81
+ expect(findModeByPath("app/nope")).toBeNull();
82
+ });
83
+
84
+ it("returns null for indices that stop above a leaf", () => {
85
+ expect(findModeByIndices([0, 0])).toBeNull();
86
+ });
87
+ });
@@ -0,0 +1,106 @@
1
+ import {
2
+ CMS_VALS,
3
+ CONTEXT_OVERRIDES,
4
+ findModeByPath,
5
+ findModesForTab,
6
+ isStateOnTab,
7
+ PRESENT_STATES,
8
+ } from "./modes.mjs";
9
+ import { SLIDES, TEMPLATES } from "./tabs.mjs";
10
+
11
+ function findState(key) {
12
+ return PRESENT_STATES[0].children.find((state) => state.key === key);
13
+ }
14
+
15
+ describe("findModesForTab", () => {
16
+ it("should offer the templates tab one mode per way the app shows a template", () => {
17
+ expect(findModesForTab(TEMPLATES).map((mode) => mode.path)).toEqual([
18
+ "app/preso/add-slides/template-preview",
19
+ "app/preso/add-slides/user-template",
20
+ "app/preso/add-slides/custom-slide",
21
+ "app/preso/add-slides/custom-slide-saved",
22
+ "app/presomanager/template-preview",
23
+ "app/presomanager/placed-template",
24
+ "app/presomanager/placed-template-saved",
25
+ "screenshot/thumbnail",
26
+ "screenshot/pdf",
27
+ ]);
28
+ });
29
+
30
+ it("should keep a template mode off the slides tab", () => {
31
+ const paths = findModesForTab(SLIDES).map((mode) => mode.path);
32
+
33
+ expect(paths).not.toContain("app/presomanager/template-preview");
34
+ });
35
+
36
+ it("should offer a screenshot on both tabs", () => {
37
+ expect(findModeByPath("screenshot/thumbnail").tabs).toEqual([
38
+ SLIDES,
39
+ TEMPLATES,
40
+ ]);
41
+ });
42
+ });
43
+
44
+ describe("isStateOnTab", () => {
45
+ it("should offer a parent wherever a state under it is offered", () => {
46
+ expect(isStateOnTab(findState("presomanager"), TEMPLATES)).toBe(true);
47
+ });
48
+
49
+ it("should hide a parent whose states are all for the other tab", () => {
50
+ expect(isStateOnTab(findState("preso"), TEMPLATES)).toBe(true);
51
+ expect(isStateOnTab(findState("preset"), TEMPLATES)).toBe(false);
52
+ });
53
+
54
+ it("should pass a tab down to states that name none of their own", () => {
55
+ expect(isStateOnTab(findState("preso").children[0], TEMPLATES)).toBe(false);
56
+ });
57
+ });
58
+
59
+ describe("MODES", () => {
60
+ it("should keep a prep edit in the context and a PresoManager one in the cmsvals", () => {
61
+ expect(findModeByPath("app/preso/prep/prepping").editStore).toBe(
62
+ CONTEXT_OVERRIDES,
63
+ );
64
+ expect(findModeByPath("app/presomanager/edit").editStore).toBe(CMS_VALS);
65
+ });
66
+
67
+ it.each([
68
+ ["app/preso/prep/prepping", true],
69
+ ["app/preso/present", true],
70
+ ["link/share", true],
71
+ ["screenshot/pdf", true],
72
+ ["app/presomanager/edit", false],
73
+ ["app/preset", false],
74
+ ])("should read %s as showing one appointment: %s", (path, isAppointment) => {
75
+ expect(findModeByPath(path).isAppointment).toBe(isAppointment);
76
+ });
77
+
78
+ it("should call a template preview read only", () => {
79
+ expect(findModeByPath("app/presomanager/template-preview").isReadOnly).toBe(
80
+ true,
81
+ );
82
+ });
83
+
84
+ it("should withhold the cmsvals from a template preview", () => {
85
+ expect(
86
+ findModeByPath("app/presomanager/template-preview").providesCmsVals,
87
+ ).toBe(false);
88
+ expect(
89
+ findModeByPath("app/preso/add-slides/template-preview").providesCmsVals,
90
+ ).toBe(false);
91
+ });
92
+
93
+ it("should pass the cmsvals to every other mode", () => {
94
+ expect(findModeByPath("app/presomanager/edit").providesCmsVals).toBe(true);
95
+ });
96
+
97
+ it("should place a saved instance under an autoadjunct", () => {
98
+ expect(
99
+ findModeByPath("app/presomanager/placed-template-saved").placement,
100
+ ).toEqual({ createdByTemplate: true, autoAdjunctID: 1 });
101
+ });
102
+
103
+ it("should leave a slide the deck declares unplaced", () => {
104
+ expect(findModeByPath("app/presomanager/edit").placement).toBeNull();
105
+ });
106
+ });
@@ -0,0 +1,22 @@
1
+ // Which half of a deck the stage is showing. Shared by the app and the dev
2
+ // server, so this file is .mjs alongside `modes.mjs`.
3
+ export const SLIDES = "slides";
4
+
5
+ export const TEMPLATES = "templates";
6
+
7
+ export const TABS = [SLIDES, TEMPLATES];
8
+
9
+ // A template is shown as a section under this prefix, and the deck interface keys it the same way.
10
+ const TEMPLATE_SECTION_PREFIX = "template-";
11
+
12
+ export function isTemplateSectionKey(key) {
13
+ return key.startsWith(TEMPLATE_SECTION_PREFIX);
14
+ }
15
+
16
+ export function toTemplateKey(sectionKey) {
17
+ return sectionKey.slice(TEMPLATE_SECTION_PREFIX.length);
18
+ }
19
+
20
+ export function toTemplateSectionKey(templateKey) {
21
+ return `${TEMPLATE_SECTION_PREFIX}${templateKey}`;
22
+ }