arcy.js 0.1.0 → 0.1.2

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.
@@ -0,0 +1,59 @@
1
+ (function(){'use strict';/* arcy.js — https://arcyai.com */
2
+ var be="__arcyPicker";function Se(e){return {v:1,core:e,selector:null,selectorCandidates:[],ordinal:1,precision:3,dynamicText:false}}function L(e){if(e.parentElement!==null)return e.parentElement;let t=e.parentNode;return t!==null&&"host"in t?t.host:null}function Te(e,t){let n=e;for(;n!==null;){if(n.matches(t))return n;n=L(n);}return null}function ve(e,t){let n=t;for(;n!==null;){if(n===e)return true;n=L(n);}return false}var Ce=100;function O(e,t=0){let n=[],r=e.querySelectorAll("*");for(let i=0;i<r.length;i+=1){let o=r[i];n.push(o),o.shadowRoot!==null&&t<Ce&&n.push(...O(o.shadowRoot,t+1));}return n}function $(e,t,n=0){let r=Array.from(e.querySelectorAll(t)),i=e.querySelectorAll("*");for(let o=0;o<i.length;o+=1){let a=i[o];a.shadowRoot!==null&&n<Ce&&r.push(...$(a.shadowRoot,t,n+1));}return r}var Ae=[/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,/\b\d{3}-\d{2}-\d{4}\b/g,/\b\d(?:[ -]?\d){12,18}\b/g],j="[masked]";function N(e){return Ae.some(t=>(t.lastIndex=0,t.test(e)))}var re=4096,ut=100,ft=64;function q(e){if(!e)return;let t=e.slice(0,re);if(e.length>re){let r=t.search(/\s\S*$/);t=r===-1?t.slice(0,re-ut):t.slice(0,r);}let n=t.replace(/\s+/g," ").trim();if(n){for(let r of Ae)n=n.replace(r,j);return n.slice(0,80)}}function z(e){return !(e.length===0||e.length>64||e.includes(":")||e.startsWith("radix-")||/^\d+$/.test(e)||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e))}var dt=new Set(["button","input","select","textarea","label","summary"]),mt=new Set(["button","link","menuitem","tab","option"]);function oe(e){let t=e.tagName.toLowerCase();if(dt.has(t)||t==="a"&&e.hasAttribute("href"))return true;let n=e.getAttribute("role");if(n!==null&&mt.has(n))return true;let r=e.getAttribute("contenteditable");return r===""||r==="true"}function ie(e){let t=e;for(;t!==null&&t!==t.ownerDocument.documentElement;){if(oe(t))return t;t=L(t);}return e}var pt=["data-testid","data-test","data-cy","id","name","aria-label"],gt=["data-testid","data-test","data-cy"],ht=64;function wt(e){for(let t of gt){let n=e.getAttribute(t);if(n===null)continue;let r=n.trim();if(!(r===""||r.length>ht)&&!N(r))return r}}var yt=new Set(["navigation","main","banner","contentinfo","search","form","region","dialog"]);function Et(e){let t=L(e);for(;t!==null;){let n=t.tagName.toLowerCase();if(n==="body"||n==="html")return;for(let i of pt){let o=t.getAttribute(i);if(o===null||i==="id"&&!z(o))continue;let a=q(o);if(a!==void 0)return {tag:n,attr:i,value:a}}let r=t.getAttribute("role");if(r!==null&&yt.has(r))return {tag:n,attr:"role",value:r};t=L(t);}}function bt(e){let t=0,n=e.previousElementSibling;for(;n!==null;)n.tagName===e.tagName&&(t+=1),n=n.previousElementSibling;return t}function Y(e){let t={tag:e.tagName.toLowerCase(),siblingIndex:bt(e)},n=q(e.textContent);n!==void 0&&(t.text=n);let r=q(e.getAttribute("aria-label"));r!==void 0&&(t.ariaLabel=r);let i=q(e.getAttribute("placeholder"));i!==void 0&&(t.placeholder=i);let o=e.getAttribute("id");o!==null&&z(o)&&!N(o)&&(t.id=o);let a=e.getAttribute("role");if(a!==null){let u=a.trim();u!==""&&u.length<=ft&&!N(u)&&(t.role=u);}let s=wt(e);s!==void 0&&(t.testId=s);let l=Et(e);return l!==void 0&&(t.ancestorTag=l.tag,t.ancestorAttr=l.attr,t.ancestorValue=l.value),t}function St(e){return e.getClientRects().length>0}var Tt=50,vt=40,Ct=10,At=15,Rt=15,xt=10,_t=10,It=10,Nt=5,kt=5,Lt=.6,Pt=.7,Dt={1:.3,2:.45,3:.6,4:.75,5:.9};function K(e){return e.split(j).join(" ").replace(/\s+/g," ").trim()}function Mt(e,t){if(t===void 0)return 0;let n=K(e),r=K(t);return n===""||r===""?0:r===n?1:r.includes(n)||n.includes(r)?Lt:0}function U(e,t){return t===e?1:0}function se(e){return e.includes(j)&&K(e)===""}function Ft(e,t,n){let r=0,i=0,o=(a,s)=>{r+=a,i+=a*s;};if(e.testId!==void 0&&o(Tt,U(e.testId,t.testId)),e.text!==void 0&&K(e.text)!==""&&o(n?Ct:vt,Mt(e.text,t.text)),e.ariaLabel!==void 0&&!se(e.ariaLabel)&&o(At,U(e.ariaLabel,t.ariaLabel)),e.placeholder!==void 0&&!se(e.placeholder)&&o(_t,U(e.placeholder,t.placeholder)),e.id!==void 0&&o(Rt,U(e.id,t.id)),e.role!==void 0&&o(Nt,U(e.role,t.role)),o(xt,t.tag===e.tag?1:0),o(kt,t.siblingIndex===e.siblingIndex?1:0),e.ancestorAttr!==void 0&&e.ancestorValue!==void 0&&!se(e.ancestorValue)){let a=0;t.ancestorAttr===e.ancestorAttr&&t.ancestorValue===e.ancestorValue&&(a=t.ancestorTag===e.ancestorTag?1:Pt),o(It,a);}return r===0?0:i/r}function Ot(e,t){if(e.selector===null)return null;try{return $(t,e.selector)}catch{return null}}function $t(e,t){let n=e.core.tag,r=[];for(let i of O(t))(i.tagName.toLowerCase()===n||oe(i))&&r.push(i);return r}function Re(e,t){if(t.length===0)return {status:"not_found",reason:"no_candidates",matchCount:0};let n=Dt[e.precision],r=false,i=[];for(let a of t){if(!St(a))continue;r=true;let s=Ft(e.core,Y(a),e.dynamicText);s>=n&&i.push({element:a,score:s});}if(i=i.filter((a,s)=>{let l=i[s+1];return l===void 0?true:!(ve(a.element,l.element)&&a.score<=l.score)}),i.length===0)return {status:"not_found",reason:r?"below_threshold":"not_visible",matchCount:0};let o=e.ordinal>=1?i[e.ordinal-1]:void 0;return o===void 0?{status:"not_found",reason:"ordinal_out_of_range",matchCount:i.length}:{status:"matched",element:o.element,score:o.score,matchCount:i.length}}function xe(e,t){try{let n=Ot(e,t);if(n!==null&&n.length>0){let r=Re(e,n);if(r.status==="matched"||r.reason==="ordinal_out_of_range")return r}return Re(e,$t(e,t))}catch{return {status:"not_found",reason:"error",matchCount:0}}}var Ut=1,Z=2,Ht=5,Bt=["data-testid","data-test","data-cy"],Wt=["name","for","aria-label"],Xt=new Set(["flex","grid","block","hidden","inline","contents","table","isolate","static","fixed","absolute","relative","sticky","visible","invisible","truncate","italic","uppercase","lowercase","capitalize","antialiased","container","border","rounded","shadow","ring","outline","transition","underline","grow","shrink","sr-only"]),Vt=/^-?(?:p|px|py|pt|pr|pb|pl|m|mx|my|mt|mr|mb|ml|gap|space|w|h|min-w|min-h|max-w|max-h|inset|top|right|bottom|left|z|text|font|leading|tracking|bg|border|rounded|shadow|opacity|flex|grid|col|row|order|basis|justify|items|content|self|place|overflow|object|aspect|size|translate|scale|rotate|duration|delay|ease|transition|ring|outline|fill|stroke|divide|decoration|cursor|select|list|align|whitespace|break|animate|blur|backdrop)-(.+)$/,Gt=new Set(["xs","sm","md","lg","xl","full","auto","none","center","start","end","between","around","evenly","baseline","stretch","wrap","nowrap","reverse","col","row","bold","semibold","medium","normal","light","thin","black","white","transparent","current","scroll","clip","ellipsis","pointer","left","right","top","bottom","middle","justify","screen","fit","min","max","visible","hidden","dashed","dotted","solid","double","in","out","border","background","foreground","muted","primary","secondary","accent","destructive","card","popover","input"]);function qt(e){let t=e.startsWith("!")?e.slice(1):e;if(t.includes(":")||t.includes("[")||t.includes("]")||t.includes("/")||Xt.has(t))return true;let n=Vt.exec(t);if(n===null)return false;let r=n[1];return /\d/.test(r)?true:r.split("-").every(i=>Gt.has(i))}var jt=["css-","sc-","jss-"];function zt(e){for(let n of jt)if(e.startsWith(n))return true;let t=e.split(/[_-]/).pop()??"";return t.length>=5&&/\d/.test(t)&&/[a-z]/.test(t)&&/[A-Z]/.test(t)}function Yt(e){let t=O(e),n=new Map;for(let r of t){let i=r.classList;for(let o=0;o<i.length;o+=1){let a=i[o];n.set(a,(n.get(a)??0)+1);}}return {counts:n,total:t.length}}var Kt=10,Zt=.02;function Jt(e){return Math.max(Kt,Math.ceil(e*Zt))}var Qt=80;function ae(e,t){let n=e.getAttribute(t);return n===null||n.trim()===""||n.length>Qt||/[\n\r\t\f]/.test(n)||N(n)?null:n}function ce(e,t){return `[${e}="${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"]`}function _e(e){if(typeof CSS<"u"&&typeof CSS.escape=="function")return CSS.escape(e);let t=e.replace(/[^a-zA-Z0-9_\u00A0-\uFFFF-]/g,n=>"\\"+n);return /^\d/.test(t)?t=`\\3${t[0]} ${t.slice(1)}`:/^-\d/.test(t)?t=`-\\3${t[1]} ${t.slice(2)}`:t==="-"&&(t="\\-"),t}function en(e,t,n){let r;try{r=$(e,t);}catch{return null}return r.includes(n)?r.length:null}var tn="http://www.w3.org/1999/xhtml";function Ie(e){try{return nn(e)}catch{return {candidates:[],autoSelector:null}}}function nn(e){let t=e.ownerDocument,n=e.namespaceURI===null||e.namespaceURI===tn?e.tagName.toLowerCase():e.tagName,r=[];for(let c of Bt){let f=ae(e,c);f!==null&&r.push({selector:ce(c,f),tier:Ut});}let i=e.getAttribute("id");i!==null&&z(i)&&!N(i)&&r.push({selector:`#${_e(i)}`,tier:Z});for(let c of Wt){let f=ae(e,c);f!==null&&r.push({selector:ce(c,f),tier:Z});}let o=ae(e,"role");if(o!==null&&r.push({selector:`${n}${ce("role",o)}`,tier:Z}),e.classList.length>0){let{counts:c,total:f}=Yt(t),m=Jt(f),p=e.classList,g=new Set;for(let d=0;d<p.length;d+=1){let h=p[d];g.has(h)||(g.add(h),!(qt(h)||zt(h)||N(h))&&((c.get(h)??0)>m||r.push({selector:`${n}.${_e(h)}`,tier:Ht})));}}let a=[];for(let c of r){let f=en(t,c.selector,e);f!==null&&a.push({selector:c.selector,tier:c.tier,matchCount:f});}a.sort((c,f)=>c.tier-f.tier||c.matchCount-f.matchCount);let s=a.slice(0,5),l=s[0],u=l!==void 0&&l.tier<=Z&&l.matchCount===1?l.selector:null;return {candidates:s.map(c=>c.selector),autoSelector:u}}function x(e){typeof console<"u"&&console.warn&&console.warn(`[arcy] ${e}`);}function rn(e){try{let n=e.currentScript?.nonce;if(typeof n=="string"&&n.length>0)return n;let r=e.getElementsByTagName("script");for(let i=0;i<r.length;i++){let o=r[i].nonce;if(typeof o=="string"&&o.length>0)return o}return null}catch{return null}}var on=typeof document<"u"?rn(document):null;function an(){return on}function Ne(e){let t=an();if(t)try{e.nonce=t,e.setAttribute("nonce",t);}catch{}}var Le="arcy-widget",k="data-arcy",cn="2147483000",ln=[["position","fixed"],["inset","0"],["z-index",cn],["pointer-events","none"],["background","transparent"],["border","0"],["box-shadow","none"],["outline","0"]],un=[["margin","0"],["padding","0"]],ke="data-arcy-style",H=new Map;function fn(e=Le){let t=H.get(e);return t!==void 0&&t.host.isConnected}function Pe(e={}){if(typeof document>"u")return null;let t=e.id??Le,n=e.container;if(fn(t))return x("This ARCY surface is already on this page. Ignoring the second mount."),null;H.delete(t);let r=n??document.body??document.documentElement;if(!r)return x("The page has no <body> to mount into yet. The widget will not render."),null;if(!n){let i=document.querySelectorAll(`[${k}]`);for(let o=0;o<i.length;o+=1)if(i[o]?.id===t)return x("Another copy of ARCY is already on this page. Ignoring this one."),null}try{let i=document.createElement("div");i.id=t,i.setAttribute(k,"");for(let[l,u]of ln)i.style.setProperty(l,u,"important");for(let[l,u]of un)i.style.setProperty(l,u);let o=i,a=!1;try{i.attachShadow&&(o=i.attachShadow({mode:"closed"}),a=!0);}catch{}r.appendChild(i),mn(i);let s={host:i,root:o,isolated:a,destroy(){try{i.parentNode&&i.parentNode.removeChild(i);}catch{}H.get(t)===s&&H.delete(t);}};return H.set(t,s),s}catch(i){return x(`The widget could not mount. ${String(i)}`),null}}var dn=["pointerdown","pointerup","pointercancel","mousedown","mouseup","click","dblclick","auxclick","contextmenu","touchstart","touchend","touchcancel","focusin","focusout","keydown","keyup","keypress","beforeinput","input","change","compositionstart","compositionupdate","compositionend","cut","copy","paste"];function mn(e){let t=n=>{try{n.stopPropagation();}catch{}};for(let n of dn)try{e.addEventListener(n,t);}catch{}try{e.addEventListener("mousedown",n=>{n.defaultPrevented||pn(e.ownerDocument,e);});}catch{}}function pn(e,t){try{let n=e.activeElement;if(!n||n===t||t.contains(n)||n===e.body||n===e.documentElement)return;let r=n.blur;typeof r=="function"&&r.call(n);}catch{}}function De(e,t){if(!e.isolated)return false;try{let n=e.root.querySelector(`[${ke}]`);if(n)return n.textContent=`${n.textContent??""}
3
+ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Ne(r),r.setAttribute(ke,""),r.textContent=t,e.root.appendChild(r),!0}catch(n){return x(`The widget could not apply its styles. ${String(n)}`),false}}var Be="[modern-screenshot]",_=typeof window<"u",gn=_&&"Worker"in window,fe=_?window.navigator?.userAgent:"",We=fe.includes("Chrome"),J=fe.includes("AppleWebKit")&&!We,de=fe.includes("Firefox"),hn=e=>e&&"__CONTEXT__"in e,wn=e=>e.constructor.name==="CSSFontFaceRule",yn=e=>e.constructor.name==="CSSImportRule",En=e=>e.constructor.name==="CSSLayerBlockRule",A=e=>e.nodeType===1,V=e=>typeof e.className=="object",Xe=e=>e.tagName==="image",bn=e=>e.tagName==="use",B=e=>A(e)&&typeof e.style<"u"&&!V(e),Sn=e=>e.nodeType===8,Tn=e=>e.nodeType===3,D=e=>e.tagName==="IMG",Q=e=>e.tagName==="VIDEO",vn=e=>e.tagName==="CANVAS",Cn=e=>e.tagName==="TEXTAREA",An=e=>e.tagName==="INPUT",Rn=e=>e.tagName==="STYLE",xn=e=>e.tagName==="SCRIPT",_n=e=>e.tagName==="SELECT",In=e=>e.tagName==="SLOT",Nn=e=>e.tagName==="IFRAME",kn=(...e)=>console.warn(Be,...e);function Ln(e){let t=e?.createElement?.("canvas");return t&&(t.height=t.width=1),!!t&&"toDataURL"in t&&!!t.toDataURL("image/webp").includes("image/webp")}var le=e=>e.startsWith("data:");function Ve(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(_&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!_)return e;let n=ee().implementation.createHTMLDocument(),r=n.createElement("base"),i=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}function ee(e){return (e&&A(e)?e?.ownerDocument:e)??window.document}var te="http://www.w3.org/2000/svg";function Pn(e,t,n){let r=ee(n).createElementNS(te,"svg");return r.setAttributeNS(null,"width",e.toString()),r.setAttributeNS(null,"height",t.toString()),r.setAttributeNS(null,"viewBox",`0 0 ${e} ${t}`),r}function Dn(e,t){let n=new XMLSerializer().serializeToString(e);return t&&(n=n.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}function Mn(e,t){return new Promise((n,r)=>{let i=new FileReader;i.onload=()=>n(i.result),i.onerror=()=>r(i.error),i.onabort=()=>r(new Error(`Failed read blob to ${t}`)),i.readAsDataURL(e);})}var Fn=e=>Mn(e,"dataUrl");function P(e,t){let n=ee(t).createElement("img");return n.decoding="sync",n.loading="eager",n.src=e,n}function W(e,t){return new Promise(n=>{let{timeout:r,ownerDocument:i,onError:o,onWarn:a}=t??{},s=typeof e=="string"?P(e,ee(i)):e,l=null,u=null;function c(){n(s),l&&clearTimeout(l),u?.();}if(r&&(l=setTimeout(c,r)),Q(s)){let f=s.currentSrc||s.src;if(!f)return s.poster?W(s.poster,t).then(n):c();if(s.readyState>=2)return c();let m=c,p=g=>{a?.("Failed video load",f,g),o?.(g),c();};u=()=>{s.removeEventListener("loadeddata",m),s.removeEventListener("error",p);},s.addEventListener("loadeddata",m,{once:true}),s.addEventListener("error",p,{once:true});}else {let f=Xe(s)?s.href.baseVal:s.currentSrc||s.src;if(!f)return c();let m=async()=>{if(D(s)&&"decode"in s)try{await s.decode();}catch(g){a?.("Failed to decode image, trying to render anyway",s.dataset.originalSrc||f,g);}c();},p=g=>{a?.("Failed image load",s.dataset.originalSrc||f,g),c();};if(D(s)&&s.complete)return m();u=()=>{s.removeEventListener("load",m),s.removeEventListener("error",p);},s.addEventListener("load",m,{once:true}),s.addEventListener("error",p,{once:true});}})}async function On(e,t){B(e)&&(D(e)||Q(e)?await W(e,t):await Promise.all(["img","video"].flatMap(n=>Array.from(e.querySelectorAll(n)).map(r=>W(r,t)))));}var Ge=(function(){let t=0,n=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return ()=>(t+=1,`u${n()}${t}`)})();function qe(e){return e?.split(",").map(t=>t.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}var Me=0;function $n(e){let t=`${Be}[#${Me}]`;return Me++,{time:n=>e&&console.time(`${t} ${n}`),timeEnd:n=>e&&console.timeEnd(`${t} ${n}`),warn:(...n)=>e&&kn(...n)}}function Un(e){return {cache:e?"no-cache":"force-cache"}}async function je(e,t){return hn(e)?e:Hn(e,{...t,autoDestruct:true})}async function Hn(e,t){let{scale:n=1,workerUrl:r,workerNumber:i=1}=t||{},o=!!t?.debug,a=t?.features??true,s=e.ownerDocument??(_?window.document:void 0),l=e.ownerDocument?.defaultView??(_?window:void 0),u=new Map,c={width:0,height:0,quality:1,type:"image/png",scale:n,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:o,fetch:{requestInit:Un(t?.fetch?.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:false,...t?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:i,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:false,...t,__CONTEXT__:true,log:$n(o),node:e,ownerDocument:s,ownerWindow:l,dpi:n===1?null:96*n,svgStyleElement:ze(s),svgDefsElement:s?.createElementNS(te,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:gn&&r&&i?i:0})].map(()=>{try{let p=new Worker(r);return p.onmessage=async g=>{let{url:d,result:h}=g.data;h?u.get(d)?.resolve?.(h):u.get(d)?.reject?.(new Error(`Error receiving message from worker: ${d}`));},p.onmessageerror=g=>{let{url:d}=g.data;u.get(d)?.reject?.(new Error(`Error receiving message from worker: ${d}`));},p}catch(p){return c.log.warn("Failed to new Worker",p),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[Ln(s)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:u,drawImageCount:0,tasks:[],features:a,isEnable:p=>p==="restoreScrollPosition"?typeof a=="boolean"?false:a[p]??false:typeof a=="boolean"?a:a[p]??true,shadowRoots:[]};c.log.time("wait until load"),await On(e,{timeout:c.timeout,onWarn:c.log.warn}),c.log.timeEnd("wait until load");let{width:f,height:m}=Bn(e,c);return c.width=f,c.height=m,c}function ze(e){if(!e)return;let t=e.createElement("style"),n=t.ownerDocument.createTextNode(`
4
+ .______background-clip--text {
5
+ background-clip: text;
6
+ -webkit-background-clip: text;
7
+ }
8
+ `);return t.appendChild(n),t}function Bn(e,t){let{width:n,height:r}=t;if(A(e)&&(!n||!r)){let i=e.getBoundingClientRect();n=n||i.width||Number(e.getAttribute("width"))||0,r=r||i.height||Number(e.getAttribute("height"))||0;}return {width:n,height:r}}async function Wn(e,t){let{log:n,timeout:r,drawImageCount:i,drawImageInterval:o}=t;n.time("image to canvas");let a=await W(e,{timeout:r,onWarn:t.log.warn}),{canvas:s,context2d:l}=Xn(e.ownerDocument,t),u=()=>{try{l?.drawImage(a,0,0,s.width,s.height);}catch(c){t.log.warn("Failed to drawImage",c);}};if(u(),t.isEnable("fixSvgXmlDecode"))for(let c=0;c<i;c++)await new Promise(f=>{setTimeout(()=>{l?.clearRect(0,0,s.width,s.height),u(),f();},c+o);});return t.drawImageCount=0,n.timeEnd("image to canvas"),s}function Xn(e,t){let{width:n,height:r,scale:i,backgroundColor:o,maximumCanvasSize:a}=t,s=e.createElement("canvas");s.width=Math.floor(n*i),s.height=Math.floor(r*i),s.style.width=`${n}px`,s.style.height=`${r}px`,a&&(s.width>a||s.height>a)&&(s.width>a&&s.height>a?s.width>s.height?(s.height*=a/s.width,s.width=a):(s.width*=a/s.height,s.height=a):s.width>a?(s.height*=a/s.width,s.width=a):(s.width*=a/s.height,s.height=a));let l=s.getContext("2d");return l&&o&&(l.fillStyle=o,l.fillRect(0,0,s.width,s.height)),{canvas:s,context2d:l}}function Ye(e,t){if(e.ownerDocument)try{let o=e.toDataURL();if(o!=="data:,")return P(o,e.ownerDocument)}catch(o){t.log.warn("Failed to clone canvas",o);}let n=e.cloneNode(false),r=e.getContext("2d"),i=n.getContext("2d");try{return r&&i&&i.putImageData(r.getImageData(0,0,e.width,e.height),0,0),n}catch(o){t.log.warn("Failed to clone canvas",o);}return n}function Vn(e,t){try{if(e?.contentDocument?.documentElement)return me(e.contentDocument.documentElement,t)}catch(n){t.log.warn("Failed to clone iframe",n);}return e.cloneNode(false)}function Gn(e){let t=e.cloneNode(false);return e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager"),t}async function qn(e,t){if(e.ownerDocument&&!e.currentSrc&&e.poster)return P(e.poster,e.ownerDocument);let n=e.cloneNode(false);n.crossOrigin="anonymous",e.currentSrc&&e.currentSrc!==e.src&&(n.src=e.currentSrc);let r=n.ownerDocument;if(r){let i=true;if(await W(n,{onError:()=>i=false,onWarn:t.log.warn}),!i)return e.poster?P(e.poster,e.ownerDocument):n;n.currentTime=e.currentTime,await new Promise(a=>{n.addEventListener("seeked",a,{once:true});});let o=r.createElement("canvas");o.width=e.offsetWidth,o.height=e.offsetHeight;try{let a=o.getContext("2d");a&&a.drawImage(n,0,0,o.width,o.height);}catch(a){return t.log.warn("Failed to clone video",a),e.poster?P(e.poster,e.ownerDocument):n}return Ye(o,t)}return n}function jn(e,t){return vn(e)?Ye(e,t):Nn(e)?Vn(e,t):D(e)?Gn(e):Q(e)?qn(e,t):e.cloneNode(false)}function zn(e){let t=e.sandbox;if(!t){let{ownerDocument:n}=e;try{n&&(t=n.createElement("iframe"),t.id=`__SANDBOX__${Ge()}`,t.width="0",t.height="0",t.style.visibility="hidden",t.style.position="fixed",n.body.appendChild(t),t.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',e.sandbox=t);}catch(r){e.log.warn("Failed to getSandBox",r);}}return t}var Yn=["width","height","-webkit-text-fill-color"],Kn=["stroke","fill"];function Ke(e,t,n){let{defaultComputedStyles:r}=n,i=e.nodeName.toLowerCase(),o=V(e)&&i!=="svg",a=o?Kn.map(d=>[d,e.getAttribute(d)]).filter(([,d])=>d!==null):[],s=[o&&"svg",i,a.map((d,h)=>`${d}=${h}`).join(","),t].filter(Boolean).join(":");if(r.has(s))return r.get(s);let u=zn(n)?.contentWindow;if(!u)return new Map;let c=u?.document,f,m;o?(f=c.createElementNS(te,"svg"),m=f.ownerDocument.createElementNS(f.namespaceURI,i),a.forEach(([d,h])=>{m.setAttributeNS(null,d,h);}),f.appendChild(m)):f=m=c.createElement(i),m.textContent=" ",c.body.appendChild(f);let p=u.getComputedStyle(m,t),g=new Map;for(let d=p.length,h=0;h<d;h++){let E=p.item(h);Yn.includes(E)||g.set(E,p.getPropertyValue(E));}return c.body.removeChild(f),r.set(s,g),g}function Ze(e,t,n){let r=new Map,i=[],o=new Map;if(n)for(let s of n)a(s);else for(let s=e.length,l=0;l<s;l++){let u=e.item(l);a(u);}for(let s=i.length,l=0;l<s;l++)o.get(i[l])?.forEach((u,c)=>r.set(c,u));function a(s){let l=e.getPropertyValue(s),u=e.getPropertyPriority(s),c=s.lastIndexOf("-"),f=c>-1?s.substring(0,c):void 0;if(f){let m=o.get(f);m||(m=new Map,o.set(f,m)),m.set(s,[l,u]);}t.get(s)===l&&!u||(f?i.push(f):r.set(s,[l,u]));}return r}function Zn(e,t,n,r){let{ownerWindow:i,includeStyleProperties:o,currentParentNodeStyle:a}=r,s=t.style,l=i.getComputedStyle(e),u=Ke(e,null,r);a?.forEach((f,m)=>{u.delete(m);});let c=Ze(l,u,o);c.delete("transition-property"),c.delete("all"),c.delete("d"),c.delete("content"),n&&(c.delete("position"),c.delete("margin-top"),c.delete("margin-right"),c.delete("margin-bottom"),c.delete("margin-left"),c.delete("margin-block-start"),c.delete("margin-block-end"),c.delete("margin-inline-start"),c.delete("margin-inline-end"),c.set("box-sizing",["border-box",""])),c.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text"),We&&(c.has("font-kerning")||c.set("font-kerning",["normal",""]),(c.get("overflow-x")?.[0]==="hidden"||c.get("overflow-y")?.[0]==="hidden")&&c.get("text-overflow")?.[0]==="ellipsis"&&e.scrollWidth===e.clientWidth&&c.set("text-overflow",["clip",""]));for(let f=s.length,m=0;m<f;m++)s.removeProperty(s.item(m));return c.forEach(([f,m],p)=>{s.setProperty(p,f,m);}),c}function Jn(e,t){(Cn(e)||An(e)||_n(e))&&t.setAttribute("value",e.value);}var Qn=["::before","::after"],er=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"];function tr(e,t,n,r,i){let{ownerWindow:o,svgStyleElement:a,svgStyles:s,currentNodeStyle:l}=r;if(!a||!o)return;function u(c){let f=o.getComputedStyle(e,c),m=f.getPropertyValue("content");if(!m||m==="none")return;i?.(m),m=m.replace(/(')|(")|(counter\(.+\))/g,"");let p=[Ge()],g=Ke(e,c,r);l?.forEach((S,v)=>{g.delete(v);});let d=Ze(f,g,r.includeStyleProperties);d.delete("content"),d.delete("-webkit-locale"),d.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text");let h=[`content: '${m}';`];if(d.forEach(([S,v],C)=>{h.push(`${C}: ${S}${v?" !important":""};`);}),h.length===1)return;try{t.className=[t.className,...p].join(" ");}catch(S){r.log.warn("Failed to copyPseudoClass",S);return}let E=h.join(`
9
+ `),b=s.get(E);b||(b=[],s.set(E,b)),b.push(`.${p[0]}${c}`);}Qn.forEach(u),n&&er.forEach(u);}var Fe=new Set(["symbol"]);async function Oe(e,t,n,r,i){if(A(n)&&(Rn(n)||xn(n))||r.filter&&!r.filter(n))return;Fe.has(t.nodeName)||Fe.has(n.nodeName)?r.currentParentNodeStyle=void 0:r.currentParentNodeStyle=r.currentNodeStyle;let o=await me(n,r,false,i);r.isEnable("restoreScrollPosition")&&nr(e,o),t.appendChild(o);}async function $e(e,t,n,r){let i=e.firstChild;A(e)&&e.shadowRoot&&(i=e.shadowRoot?.firstChild,n.shadowRoots.push(e.shadowRoot));for(let o=i;o;o=o.nextSibling)if(!Sn(o))if(A(o)&&In(o)&&typeof o.assignedNodes=="function"){let a=o.assignedNodes();for(let s=0;s<a.length;s++)await Oe(e,t,a[s],n,r);}else await Oe(e,t,o,n,r);}function nr(e,t){if(!B(e)||!B(t))return;let{scrollTop:n,scrollLeft:r}=e;if(!n&&!r)return;let{transform:i}=t.style,o=new DOMMatrix(i),{a,b:s,c:l,d:u}=o;o.a=1,o.b=0,o.c=0,o.d=1,o.translateSelf(-r,-n),o.a=a,o.b=s,o.c=l,o.d=u,t.style.transform=o.toString();}function rr(e,t){let{backgroundColor:n,width:r,height:i,style:o}=t,a=e.style;if(n&&a.setProperty("background-color",n,"important"),r&&a.setProperty("width",`${r}px`,"important"),i&&a.setProperty("height",`${i}px`,"important"),o)for(let s in o)a[s]=o[s];}var or=/^[\w-:]+$/;async function me(e,t,n=false,r){let{ownerDocument:i,ownerWindow:o,fontFamilies:a,onCloneEachNode:s}=t;if(i&&Tn(e))return r&&/\S/.test(e.data)&&r(e.data),i.createTextNode(e.data);if(i&&o&&A(e)&&(B(e)||V(e))){let u=await jn(e,t);if(t.isEnable("removeAbnormalAttributes")){let d=u.getAttributeNames();for(let h=d.length,E=0;E<h;E++){let b=d[E];or.test(b)||u.removeAttribute(b);}}let c=t.currentNodeStyle=Zn(e,u,n,t);n&&rr(u,t);let f=false;if(t.isEnable("copyScrollbar")){let d=[c.get("overflow-x")?.[0],c.get("overflow-y")?.[0]];f=d.includes("scroll")||(d.includes("auto")||d.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth);}let m=c.get("text-transform")?.[0],p=qe(c.get("font-family")?.[0]),g=p?d=>{m==="uppercase"?d=d.toUpperCase():m==="lowercase"?d=d.toLowerCase():m==="capitalize"&&(d=d[0].toUpperCase()+d.substring(1)),p.forEach(h=>{let E=a.get(h);E||a.set(h,E=new Set),d.split("").forEach(b=>E.add(b));});}:void 0;return tr(e,u,f,t,g),Jn(e,u),Q(e)||await $e(e,u,t,g),await s?.(u),u}let l=e.cloneNode(false);return await $e(e,l,t),await s?.(l),l}function ir(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=[];}function sr(e){let{url:t,timeout:n,responseType:r,...i}=e,o=new AbortController,a=n?setTimeout(()=>o.abort(),n):void 0;return fetch(t,{signal:o.signal,...i}).then(s=>{if(!s.ok)throw new Error("Failed fetch, not 2xx response",{cause:s});switch(r){case "arrayBuffer":return s.arrayBuffer();case "dataUrl":return s.blob().then(Fn);default:return s.text()}}).finally(()=>clearTimeout(a))}function X(e,t){let{url:n,requestType:r="text",responseType:i="text",imageDom:o}=t,a=n,{timeout:s,acceptOfImage:l,requests:u,fetchFn:c,fetch:{requestInit:f,bypassingCache:m,placeholderImage:p},font:g,workers:d,fontFamilies:h}=e;r==="image"&&(J||de)&&e.drawImageCount++;let E=u.get(n);if(!E){m&&m instanceof RegExp&&m.test(a)&&(a+=(/\?/.test(a)?"&":"?")+new Date().getTime());let b=r.startsWith("font")&&g&&g.minify,S=new Set;b&&r.split(";")[1].split(",").forEach(I=>{h.has(I)&&h.get(I).forEach(G=>S.add(G));});let v=b&&S.size,C={url:a,timeout:s,responseType:v?"arrayBuffer":i,headers:r==="image"?{accept:l}:void 0,...f};E={type:r,resolve:void 0,reject:void 0,response:null},E.response=(async()=>{if(c&&r==="image"){let T=await c(n);if(T)return T}return !J&&n.startsWith("http")&&d.length?new Promise((T,I)=>{d[u.size&d.length-1].postMessage({rawUrl:n,...C}),E.resolve=T,E.reject=I;}):sr(C)})().catch(T=>{if(u.delete(n),r==="image"&&p)return e.log.warn("Failed to fetch image base64, trying to use placeholder image",a),typeof p=="string"?p:p(o);throw T}),u.set(n,E);}return E.response}async function Je(e,t,n,r){if(!Qe(e))return e;for(let[i,o]of ar(e,t))try{let a=await X(n,{url:o,requestType:r?"image":"text",responseType:"dataUrl"});e=e.replace(cr(i),`$1${a}$3`);}catch(a){n.log.warn("Failed to fetch css data url",i,a);}return e}function Qe(e){return /url\((['"]?)([^'"]+?)\1\)/.test(e)}var et=/url\((['"]?)([^'"]+?)\1\)/g;function ar(e,t){let n=[];return e.replace(et,(r,i,o)=>(n.push([o,Ve(o,t)]),r)),n.filter(([r])=>!le(r))}function cr(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}var lr=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function ur(e,t){return lr.map(n=>{let r=e.getPropertyValue(n);return !r||r==="none"?null:((J||de)&&t.drawImageCount++,Je(r,null,t,true).then(i=>{!i||r===i||e.setProperty(n,i,e.getPropertyPriority(n));}))}).filter(Boolean)}function fr(e,t){if(D(e)){let n=e.currentSrc||e.src;if(!le(n))return [X(t,{url:n,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(r=>{r&&(e.srcset="",e.dataset.originalSrc=n,e.src=r||"");})];(J||de)&&t.drawImageCount++;}else if(V(e)&&!le(e.href.baseVal)){let n=e.href.baseVal;return [X(t,{url:n,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(r=>{r&&(e.dataset.originalSrc=n,e.href.baseVal=r||"");})]}return []}function dr(e,t){let{ownerDocument:n,svgDefsElement:r}=t,i=e.getAttribute("href")??e.getAttribute("xlink:href");if(!i)return [];let[o,a]=i.split("#");if(a){let s=`#${a}`,l=t.shadowRoots.reduce((u,c)=>u??c.querySelector(`svg ${s}`),n?.querySelector(`svg ${s}`));if(o&&e.setAttribute("href",s),r?.querySelector(s))return [];if(l)return r?.appendChild(l.cloneNode(true)),[];if(o)return [X(t,{url:o,responseType:"text"}).then(u=>{r?.insertAdjacentHTML("beforeend",u);})]}return []}function tt(e,t){let{tasks:n}=t;A(e)&&((D(e)||Xe(e))&&n.push(...fr(e,t)),bn(e)&&n.push(...dr(e,t))),B(e)&&n.push(...ur(e.style,t)),e.childNodes.forEach(r=>{tt(r,t);});}async function mr(e,t){let{ownerDocument:n,svgStyleElement:r,fontFamilies:i,fontCssTexts:o,tasks:a,font:s}=t;if(!(!n||!r||!i.size))if(s&&s.cssText){let l=He(s.cssText,t);r.appendChild(n.createTextNode(`${l}
10
+ `));}else {let l=Array.from(n.styleSheets).filter(p=>{try{return "cssRules"in p&&!!p.cssRules.length}catch(g){return t.log.warn(`Error while reading CSS rules from ${p.href}`,g),false}}),u=n.implementation.createHTMLDocument(""),c=u.createElement("style");u.head.appendChild(c);let f=c.sheet;await Promise.all(l.flatMap(p=>Array.from(p.cssRules).map(async g=>{if(yn(g)){let d=g.href,h="";try{h=await X(t,{url:d,requestType:"text",responseType:"text"});}catch(b){t.log.warn(`Error fetch remote css import from ${d}`,b);}let E=h.replace(et,(b,S,v)=>b.replace(v,Ve(v,d)));for(let b of gr(E))try{f.insertRule(b,f.cssRules.length);}catch(S){t.log.warn("Error inserting rule from remote css import",{rule:b,error:S});}}}))),f.cssRules.length&&l.push(f);let m=[];l.forEach(p=>{ue(p.cssRules,m);}),m.filter(p=>wn(p)&&Qe(p.style.getPropertyValue("src"))&&qe(p.style.getPropertyValue("font-family"))?.some(g=>i.has(g))).forEach(p=>{let g=p,d=o.get(g.cssText);d?r.appendChild(n.createTextNode(`${d}
11
+ `)):a.push(Je(g.cssText,g.parentStyleSheet?g.parentStyleSheet.href:null,t).then(h=>{h=He(h,t),o.set(g.cssText,h),r.appendChild(n.createTextNode(`${h}
12
+ `));}));});}}var pr=/(\/\*[\s\S]*?\*\/)/g,Ue=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function gr(e){if(e==null)return [];let t=[],n=e.replace(pr,"");for(;;){let o=Ue.exec(n);if(!o)break;t.push(o[0]);}n=n.replace(Ue,"");let r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,i=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let o=r.exec(n);if(o)i.lastIndex=r.lastIndex;else if(o=i.exec(n),o)r.lastIndex=i.lastIndex;else break;t.push(o[0]);}return t}var hr=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,wr=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function He(e,t){let{font:n}=t,r=n?n?.preferredFormat:void 0;return r?e.replace(wr,i=>{for(;;){let[o,,a]=hr.exec(i)||[];if(!a)return "";if(a===r)return `src: ${o};`}}):e}function ue(e,t=[]){for(let n of Array.from(e))En(n)?t.push(...ue(n.cssRules)):"cssRules"in n?ue(n.cssRules,t):t.push(n);return t}var yr=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;function Er(e){return yr.test(e.innerHTML)}async function br(e,t){let n=await je(e,t);if(A(n.node)&&V(n.node)&&!Er(n.node))return n.node;let{ownerDocument:r,log:i,tasks:o,svgStyleElement:a,svgDefsElement:s,svgStyles:l,font:u,progress:c,autoDestruct:f,onCloneNode:m,onEmbedNode:p,onCreateForeignObjectSvg:g}=n;i.time("clone node");let d=await me(n.node,n,true);if(a&&r){let v="";l.forEach((C,T)=>{v+=`${C.join(`,
13
+ `)} {
14
+ ${T}
15
+ }
16
+ `;}),a.appendChild(r.createTextNode(v));}i.timeEnd("clone node"),await m?.(d),u!==false&&A(d)&&(i.time("embed web font"),await mr(d,n),i.timeEnd("embed web font")),i.time("embed node"),tt(d,n);let h=o.length,E=0,b=async()=>{for(;;){let v=o.pop();if(!v)break;try{await v;}catch(C){n.log.warn("Failed to run task",C);}c?.(++E,h);}};c?.(E,h),await Promise.all([...Array.from({length:4})].map(b)),i.timeEnd("embed node"),await p?.(d);let S=Sr(d,n);return s&&S.insertBefore(s,S.children[0]),a&&S.insertBefore(a,S.children[0]),f&&ir(n),await g?.(S),S}function Sr(e,t){let{width:n,height:r}=t,i=Pn(n,r,e.ownerDocument),o=i.ownerDocument.createElementNS(i.namespaceURI,"foreignObject");return o.setAttributeNS(null,"x","0%"),o.setAttributeNS(null,"y","0%"),o.setAttributeNS(null,"width","100%"),o.setAttributeNS(null,"height","100%"),o.append(e),i.appendChild(o),i}async function nt(e,t){let n=await je(e,t),r=await br(n),i=Dn(r,n.isEnable("removeControlCharacter"));n.autoDestruct||(n.svgStyleElement=ze(n.ownerDocument),n.svgDefsElement=n.ownerDocument?.createElementNS(te,"defs"),n.svgStyles.clear());let o=P(i,r.ownerDocument);return await Wn(o,n)}var Tr=.25,vr=160,Cr=28,Ar=1600,Rr=1200,xr=2,_r=26e5,Ir=36e5,Nr=8e3,kr=[/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,/\b\d{3}-\d{2}-\d{4}\b/g,/\b\d(?:[ -]?\d){12,18}\b/g],ot="[masked]",Lr="#f04e23";function pe(e){let t=e;for(let n of kr)n.lastIndex=0,t=t.replace(n,ot);return t}function rt(e){return Math.min(Math.max(e*Tr,Cr),vr)}function Pr(e,t,n){let r=rt(e.width),i=rt(e.height),o=Math.max(0,e.left-r),a=Math.max(0,e.top-i),s=Math.min(t,e.left+e.width+r),l=Math.min(n,e.top+e.height+i),u=Math.min(s-o,Ar),c=Math.min(l-a,Rr);return s-o>u&&(o+=(s-o-u)/2),l-a>c&&(a+=(l-a-c)/2),{left:o,top:a,width:Math.max(0,u),height:Math.max(0,c)}}function Dr(e){if(e instanceof HTMLTextAreaElement)return true;if(!(e instanceof HTMLInputElement))return false;let t=e.type;return t!=="checkbox"&&t!=="radio"&&t!=="hidden"&&t!=="file"}function Mr(e){return !(e instanceof Element&&e.hasAttribute(k))}function Fr(e){let t=e.ownerDocument??e,n=t.defaultView,r=t.createTreeWalker(e,(n?.NodeFilter??NodeFilter).SHOW_ELEMENT|(n?.NodeFilter??NodeFilter).SHOW_TEXT),i=[],o=r.currentNode;for(;o;){if(o.nodeType===3){let a=o.nodeValue;if(a&&a.trim()){let s=pe(a);s!==a&&(o.nodeValue=s);}}else if(o instanceof Element||o.tagName){let a=o;if(a.hasAttribute(k))i.push(a);else if(Dr(a)){let s=a instanceof HTMLInputElement&&a.type==="password",l=a.getAttribute("value")??a.value??"",u=s&&l?ot:pe(l);a instanceof HTMLTextAreaElement?(a.textContent=u,a.value=u):(a.setAttribute("value",u),a.value=u);let c=a.getAttribute("placeholder");c&&a.setAttribute("placeholder",pe(c));}}o=r.nextNode();}for(let a of i)a.parentNode?.removeChild(a);}function Or(e,t,n,r){e.save(),e.strokeStyle=Lr,e.lineWidth=2*r;let i=r;e.strokeRect((t.left-n.left)*r+i,(t.top-n.top)*r+i,t.width*r-i*2,t.height*r-i*2),e.restore();}function $r(e,t){let n=Math.min(e.devicePixelRatio||1,xr),r=t.width*t.height;return r<=0?1:Math.max(.5,Math.min(n,Math.sqrt(_r/r)))}function Ur(e,t){let n=t.createElement("canvas");n.width=Math.max(1,Math.round(e.width/2)),n.height=Math.max(1,Math.round(e.height/2));let r=n.getContext("2d");return r?(r.drawImage(e,0,0,n.width,n.height),n):null}async function it(e){try{let t=e.ownerDocument,n=t.defaultView;if(!n||!t.documentElement||!e.isConnected)return null;let r=e.getBoundingClientRect(),i={left:r.left,top:r.top,width:r.width,height:r.height};if(i.width<=0||i.height<=0)return null;let o=Pr(i,n.innerWidth,n.innerHeight);if(o.width<=0||o.height<=0)return null;let a=$r(n,o),s=-(o.left+(n.scrollX||0)),l=-(o.top+(n.scrollY||0)),u=await nt(t.documentElement,{width:o.width,height:o.height,scale:a,backgroundColor:"#ffffff",timeout:Nr,filter:Mr,onCloneNode:m=>{Fr(m);},font:{preferredFormat:"woff2"},style:{transform:`translate(${s}px, ${l}px)`,transformOrigin:"top left",width:`${n.innerWidth}px`,minHeight:`${n.innerHeight}px`,margin:"0",overflow:"visible"}}),c=u.getContext("2d");if(!c)return null;Or(c,i,o,a);let f=u.toDataURL("image/png");if(f.length>Ir){let m=Ur(u,t);if(!m)return null;f=m.toDataURL("image/png");}return f}catch{return null}}var Hr="arcy-picker",R="arcy-picker-banner",at="arcy-picker-highlight",Br=`
17
+ .${R} {
18
+ display: flex;
19
+ align-items: center;
20
+ gap: 10px;
21
+ padding: 10px 14px;
22
+ border-radius: 999px;
23
+ background: #101828;
24
+ color: #ffffff;
25
+ font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
26
+ box-shadow: 0 8px 24px rgba(16, 24, 40, 0.28);
27
+ white-space: nowrap;
28
+ }
29
+ .${R}__title {
30
+ font-weight: 600;
31
+ margin-right: 2px;
32
+ }
33
+ .${R}__status {
34
+ max-width: 260px;
35
+ overflow: hidden;
36
+ text-overflow: ellipsis;
37
+ color: #d0d5dd;
38
+ }
39
+ .${R} button {
40
+ appearance: none;
41
+ border: 1px solid rgba(255, 255, 255, 0.25);
42
+ border-radius: 999px;
43
+ background: transparent;
44
+ color: #ffffff;
45
+ font: inherit;
46
+ padding: 4px 12px;
47
+ cursor: pointer;
48
+ }
49
+ .${R} button:hover {
50
+ background: rgba(255, 255, 255, 0.1);
51
+ }
52
+ .${R} button.is-active {
53
+ background: #f04e23;
54
+ border-color: #f04e23;
55
+ }
56
+ .${at} {
57
+ border-radius: 3px;
58
+ }
59
+ `;function st(e,t,n=[]){e.style.setProperty("position","absolute","important"),e.style.setProperty("pointer-events",t,"important");for(let[r,i]of n)e.style.setProperty(r,i,"important");}var Wr=[["box-sizing","border-box"],["border","2px solid #f04e23"],["background","rgba(240, 78, 35, 0.08)"]],Xr=[["left","50%"],["bottom","24px"]],Vr=[["transform","translateX(-50%)"]];function Gr(e){let{text:t,tag:n}=e.core;return t?`Sent "${t}" to ARCY`:`Sent <${n}> to ARCY`}function ct(e){let t=Pe({id:Hr});if(!t)return null;let n=t.host.ownerDocument,r="pick",i=false,o=null,a=0;De(t,Br);let s=n.createElement("div");s.className=at,st(s,"none");for(let[w,y]of Wr)s.style.setProperty(w,y);d();let l=n.createElement("div");l.className=R,st(l,"auto",Xr);for(let[w,y]of Vr)l.style.setProperty(w,y);let u=n.createElement("span");u.className=`${R}__title`,u.textContent="ARCY element picker";let c=n.createElement("button");c.type="button",c.textContent="Pick";let f=n.createElement("button");f.type="button",f.textContent="Browse";let m=n.createElement("span");m.className=`${R}__status`,m.textContent="Click the element you want this step to target.";let p=n.createElement("button");p.type="button",p.textContent="Exit",l.append(u,c,f,m,p),t.root.append(s,l);function g(w){r=w,c.classList.toggle("is-active",w==="pick"),f.classList.toggle("is-active",w==="browse"),m.textContent=w==="pick"?"Click the element you want this step to target.":"Browsing. Clicks work normally; switch back to pick.",w==="browse"&&d();}function d(){s.style.setProperty("display","none","important");}function h(w){try{let y=w.getBoundingClientRect();if(y.width===0&&y.height===0){d();return}s.style.setProperty("left",`${y.left}px`,"important"),s.style.setProperty("top",`${y.top}px`,"important"),s.style.setProperty("width",`${y.width}px`,"important"),s.style.setProperty("height",`${y.height}px`,"important"),s.style.setProperty("display","block","important");}catch{d();}}function E(w){return w instanceof Element&&Te(w,`[${k}]`)!==null}function b(w){if(typeof w.composedPath=="function"){let y=w.composedPath();if(y.length>0)return y[0]}return w.target}function S(){return t!==null&&t.host.isConnected?false:(ne(),true)}let v=w=>{try{if(S()||r!=="pick")return;let y=b(w);if(E(y)||!(y instanceof Element)){o=null,d();return}o=ie(y),h(o);}catch{}},C=()=>{try{if(S()||r!=="pick")return;o&&o.isConnected?h(o):d();}catch{}},T=w=>{try{if(S()||r!=="pick"||E(b(w)))return;w.preventDefault(),w.stopPropagation(),w.stopImmediatePropagation();}catch{}},I=w=>{try{if(S()||r!=="pick")return;let y=b(w);if(E(y)||(w.preventDefault(),w.stopPropagation(),w.stopImmediatePropagation(),!(y instanceof Element)))return;let M=ie(y),F=Se(Y(M)),we=Ie(M);F.selector=we.autoSelector,F.selectorCandidates=we.candidates,m.textContent=Gr(F),o=M,h(M);let ye=0;try{ye=xe(F,n).matchCount;}catch{}if(e.onPick(F,ye),e.screenshotsEnabled===!1)return;let lt=++a;it(M).then(Ee=>{if(!(!Ee||i||lt!==a))try{e.onScreenshot?.(Ee);}catch{}});}catch(y){x(`The element picker could not read that element. ${String(y)}`);}};function G(w){if(!(w instanceof Element))return false;let y=w.tagName;return y==="INPUT"||y==="TEXTAREA"||y==="SELECT"?true:w.isContentEditable===true}let ge=w=>{try{if(S())return;let y=w;if(!y.altKey||y.code!=="KeyS"&&y.key.toLowerCase()!=="s"||G(b(y)))return;y.preventDefault(),g(r==="pick"?"browse":"pick");}catch{}};function ne(){if(!i){i=true;try{n.removeEventListener("pointerdown",T,!0),n.removeEventListener("mousedown",T,!0),n.removeEventListener("mouseup",T,!0),n.removeEventListener("auxclick",T,!0),n.removeEventListener("click",I,!0),n.removeEventListener("mousemove",v,!0),n.removeEventListener("keydown",ge,!0),n.defaultView?.removeEventListener("scroll",C,!0),n.defaultView?.removeEventListener("resize",C);}catch{}t?.destroy(),t=null;}}let he=w=>{try{w.preventDefault();}catch{}};return l.addEventListener("pointerdown",he),l.addEventListener("mousedown",he),c.addEventListener("click",()=>g("pick")),f.addEventListener("click",()=>g("browse")),p.addEventListener("click",()=>{ne();try{e.onExit();}catch{}}),n.addEventListener("pointerdown",T,true),n.addEventListener("mousedown",T,true),n.addEventListener("mouseup",T,true),n.addEventListener("auxclick",T,true),n.addEventListener("click",I,true),n.addEventListener("mousemove",v,true),n.addEventListener("keydown",ge,true),n.defaultView?.addEventListener("scroll",C,true),n.defaultView?.addEventListener("resize",C),g("pick"),{destroy:ne}}var jr={contract:2,mount:e=>{try{return ct(e)}catch{return null}}};if(typeof window<"u")try{window[be]=jr;}catch{}})();