arcy.js 0.1.4 → 0.1.6

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,95 @@
1
+ (function(){'use strict';/* arcy.js — https://arcyai.com */
2
+ var Ae="__arcyPicker";function Ce(e){return {v:1,core:e,selector:null,selectorCandidates:[],ordinal:1,precision:3,dynamicText:false}}function x(e){if(e.parentElement!==null)return e.parentElement;let t=e.parentNode;return t!==null&&"host"in t?t.host:null}function _e(e,t){let n=e;for(;n!==null;){if(n.matches(t))return n;n=x(n);}return null}function xe(e,t){let n=t;for(;n!==null;){if(n===e)return true;n=x(n);}return false}var ve=100;function F(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<ve&&n.push(...F(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<ve&&r.push(...$(a.shadowRoot,t,n+1));}return r}var Ie=[/[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 L(e){return Ie.some(t=>(t.lastIndex=0,t.test(e)))}var re=4096,Tt=100,Rt=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-Tt):t.slice(0,r);}let n=t.replace(/\s+/g," ").trim();if(n){for(let r of Ie)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 At=new Set(["button","input","select","textarea","label","summary"]),Ct=new Set(["button","link","menuitem","tab","option"]);function oe(e){let t=e.tagName.toLowerCase();if(At.has(t)||t==="a"&&e.hasAttribute("href"))return true;let n=e.getAttribute("role");if(n!==null&&Ct.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=x(t);}return e}var _t=["data-testid","data-test","data-cy","id","name","aria-label"],xt=["data-testid","data-test","data-cy"],vt=64;function It(e){for(let t of xt){let n=e.getAttribute(t);if(n===null)continue;let r=n.trim();if(!(r===""||r.length>vt)&&!L(r))return r}}var Nt=new Set(["navigation","main","banner","contentinfo","search","form","region","dialog"]);function kt(e){let t=x(e);for(;t!==null;){let n=t.tagName.toLowerCase();if(n==="body"||n==="html")return;for(let i of _t){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&&Nt.has(r))return {tag:n,attr:"role",value:r};t=x(t);}}function Dt(e){let t=0,n=e.previousElementSibling;for(;n!==null;)n.tagName===e.tagName&&(t+=1),n=n.previousElementSibling;return t}function K(e){let t={tag:e.tagName.toLowerCase(),siblingIndex:Dt(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)&&!L(o)&&(t.id=o);let a=e.getAttribute("role");if(a!==null){let u=a.trim();u!==""&&u.length<=Rt&&!L(u)&&(t.role=u);}let s=It(e);s!==void 0&&(t.testId=s);let c=kt(e);return c!==void 0&&(t.ancestorTag=c.tag,t.ancestorAttr=c.attr,t.ancestorValue=c.value),t}function Mt(e){return e.getClientRects().length>0}var Lt=50,Pt=40,Ot=10,Ft=15,$t=15,Ut=10,Bt=10,Ht=10,Wt=5,Xt=5,Gt=.6,Vt=.7,qt={1:.3,2:.45,3:.6,4:.75,5:.9};function Y(e){return e.split(j).join(" ").replace(/\s+/g," ").trim()}function jt(e,t){if(t===void 0)return 0;let n=Y(e),r=Y(t);return n===""||r===""?0:r===n?1:r.includes(n)||n.includes(r)?Gt:0}function U(e,t){return t===e?1:0}function se(e){return e.includes(j)&&Y(e)===""}function zt(e,t,n){let r=0,i=0,o=(a,s)=>{r+=a,i+=a*s;};if(e.testId!==void 0&&o(Lt,U(e.testId,t.testId)),e.text!==void 0&&Y(e.text)!==""&&o(n?Ot:Pt,jt(e.text,t.text)),e.ariaLabel!==void 0&&!se(e.ariaLabel)&&o(Ft,U(e.ariaLabel,t.ariaLabel)),e.placeholder!==void 0&&!se(e.placeholder)&&o(Bt,U(e.placeholder,t.placeholder)),e.id!==void 0&&o($t,U(e.id,t.id)),e.role!==void 0&&o(Wt,U(e.role,t.role)),o(Ut,t.tag===e.tag?1:0),o(Xt,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:Vt),o(Ht,a);}return r===0?0:i/r}function Kt(e,t){if(e.selector===null)return null;try{return $(t,e.selector)}catch{return null}}function Yt(e,t){let n=e.core.tag,r=[];for(let i of F(t))(i.tagName.toLowerCase()===n||oe(i))&&r.push(i);return r}function Ne(e,t){if(t.length===0)return {status:"not_found",reason:"no_candidates",matchCount:0};let n=qt[e.precision],r=false,i=[];for(let a of t){if(!Mt(a))continue;r=true;let s=zt(e.core,K(a),e.dynamicText);s>=n&&i.push({element:a,score:s});}if(i=i.filter((a,s)=>{let c=i[s+1];return c===void 0?true:!(xe(a.element,c.element)&&a.score<=c.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 ke(e,t){try{let n=Kt(e,t);if(n!==null&&n.length>0){let r=Ne(e,n);if(r.status==="matched"||r.reason==="ordinal_out_of_range")return r}return Ne(e,Yt(e,t))}catch{return {status:"not_found",reason:"error",matchCount:0}}}var Zt=1,Z=2,Jt=5,Qt=["data-testid","data-test","data-cy"],en=["name","for","aria-label"],tn=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"]),nn=/^-?(?: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)-(.+)$/,rn=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 on(e){let t=e.startsWith("!")?e.slice(1):e;if(t.includes(":")||t.includes("[")||t.includes("]")||t.includes("/")||tn.has(t))return true;let n=nn.exec(t);if(n===null)return false;let r=n[1];return /\d/.test(r)?true:r.split("-").every(i=>rn.has(i))}var sn=["css-","sc-","jss-"];function an(e){for(let n of sn)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 ln(e){let t=F(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 cn=10,un=.02;function fn(e){return Math.max(cn,Math.ceil(e*un))}var dn=80;function ae(e,t){let n=e.getAttribute(t);return n===null||n.trim()===""||n.length>dn||/[\n\r\t\f]/.test(n)||L(n)?null:n}function le(e,t){return `[${e}="${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"]`}function De(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 mn(e,t,n){let r;try{r=$(e,t);}catch{return null}return r.includes(n)?r.length:null}var pn="http://www.w3.org/1999/xhtml";function Me(e){try{return gn(e)}catch{return {candidates:[],autoSelector:null}}}function gn(e){let t=e.ownerDocument,n=e.namespaceURI===null||e.namespaceURI===pn?e.tagName.toLowerCase():e.tagName,r=[];for(let l of Qt){let f=ae(e,l);f!==null&&r.push({selector:le(l,f),tier:Zt});}let i=e.getAttribute("id");i!==null&&z(i)&&!L(i)&&r.push({selector:`#${De(i)}`,tier:Z});for(let l of en){let f=ae(e,l);f!==null&&r.push({selector:le(l,f),tier:Z});}let o=ae(e,"role");if(o!==null&&r.push({selector:`${n}${le("role",o)}`,tier:Z}),e.classList.length>0){let{counts:l,total:f}=ln(t),m=fn(f),p=e.classList,h=new Set;for(let d=0;d<p.length;d+=1){let g=p[d];h.has(g)||(h.add(g),!(on(g)||an(g)||L(g))&&((l.get(g)??0)>m||r.push({selector:`${n}.${De(g)}`,tier:Jt})));}}let a=[];for(let l of r){let f=mn(t,l.selector,e);f!==null&&a.push({selector:l.selector,tier:l.tier,matchCount:f});}a.sort((l,f)=>l.tier-f.tier||l.matchCount-f.matchCount);let s=a.slice(0,5),c=s[0],u=c!==void 0&&c.tier<=Z&&c.matchCount===1?c.selector:null;return {candidates:s.map(l=>l.selector),autoSelector:u}}function k(e){typeof console<"u"&&console.warn&&console.warn(`[arcy] ${e}`);}function hn(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 En=typeof document<"u"?hn(document):null;function wn(){return En}function Le(e){let t=wn();if(t)try{e.nonce=t,e.setAttribute("nonce",t);}catch{}}var Oe="arcy-widget",D="data-arcy",bn="2147483000",Sn=[["position","fixed"],["inset","0"],["z-index",bn],["pointer-events","none"],["background","transparent"],["border","0"],["box-shadow","none"],["outline","0"]],Tn=[["margin","0"],["padding","0"]],Pe="data-arcy-style",B=new Map;function Rn(e=Oe){let t=B.get(e);return t!==void 0&&t.host.isConnected}function Fe(e={}){if(typeof document>"u")return null;let t=e.id??Oe,n=e.container;if(Rn(t))return k("This ARCY surface is already on this page. Ignoring the second mount."),null;B.delete(t);let r=n??document.body??document.documentElement;if(!r)return k("The page has no <body> to mount into yet. The widget will not render."),null;if(!n){let i=document.querySelectorAll(`[${D}]`);for(let o=0;o<i.length;o+=1)if(i[o]?.id===t)return k("Another copy of ARCY is already on this page. Ignoring this one."),null}try{let i=document.createElement("div");i.id=t,i.setAttribute(D,"");for(let[c,u]of Sn)i.style.setProperty(c,u,"important");for(let[c,u]of Tn)i.style.setProperty(c,u);let o=i,a=!1;try{i.attachShadow&&(o=i.attachShadow({mode:"closed"}),a=!0);}catch{}r.appendChild(i),Cn(i);let s={host:i,root:o,isolated:a,destroy(){try{i.parentNode&&i.parentNode.removeChild(i);}catch{}B.get(t)===s&&B.delete(t);}};return B.set(t,s),s}catch(i){return k(`The widget could not mount. ${String(i)}`),null}}var An=["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 Cn(e){let t=n=>{try{n.stopPropagation();}catch{}};for(let n of An)try{e.addEventListener(n,t);}catch{}try{e.addEventListener("mousedown",n=>{n.defaultPrevented||_n(e.ownerDocument,e);});}catch{}}function _n(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 $e(e,t){if(!e.isolated)return false;try{let n=e.root.querySelector(`[${Pe}]`);if(n)return n.textContent=`${n.textContent??""}
3
+ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAttribute(Pe,""),r.textContent=t,e.root.appendChild(r),!0}catch(n){return k(`The widget could not apply its styles. ${String(n)}`),false}}var Ve="[modern-screenshot]",M=typeof window<"u",xn=M&&"Worker"in window,fe=M?window.navigator?.userAgent:"",qe=fe.includes("Chrome"),J=fe.includes("AppleWebKit")&&!qe,de=fe.includes("Firefox"),vn=e=>e&&"__CONTEXT__"in e,In=e=>e.constructor.name==="CSSFontFaceRule",Nn=e=>e.constructor.name==="CSSImportRule",kn=e=>e.constructor.name==="CSSLayerBlockRule",v=e=>e.nodeType===1,G=e=>typeof e.className=="object",je=e=>e.tagName==="image",Dn=e=>e.tagName==="use",H=e=>v(e)&&typeof e.style<"u"&&!G(e),Mn=e=>e.nodeType===8,Ln=e=>e.nodeType===3,O=e=>e.tagName==="IMG",Q=e=>e.tagName==="VIDEO",Pn=e=>e.tagName==="CANVAS",On=e=>e.tagName==="TEXTAREA",Fn=e=>e.tagName==="INPUT",$n=e=>e.tagName==="STYLE",Un=e=>e.tagName==="SCRIPT",Bn=e=>e.tagName==="SELECT",Hn=e=>e.tagName==="SLOT",Wn=e=>e.tagName==="IFRAME",Xn=(...e)=>console.warn(Ve,...e);function Gn(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 ce=e=>e.startsWith("data:");function ze(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(M&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!M)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&&v(e)?e?.ownerDocument:e)??window.document}var te="http://www.w3.org/2000/svg";function Vn(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 qn(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 jn(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 zn=e=>jn(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,c=null,u=null;function l(){n(s),c&&clearTimeout(c),u?.();}if(r&&(c=setTimeout(l,r)),Q(s)){let f=s.currentSrc||s.src;if(!f)return s.poster?W(s.poster,t).then(n):l();if(s.readyState>=2)return l();let m=l,p=h=>{a?.("Failed video load",f,h),o?.(h),l();};u=()=>{s.removeEventListener("loadeddata",m),s.removeEventListener("error",p);},s.addEventListener("loadeddata",m,{once:true}),s.addEventListener("error",p,{once:true});}else {let f=je(s)?s.href.baseVal:s.currentSrc||s.src;if(!f)return l();let m=async()=>{if(O(s)&&"decode"in s)try{await s.decode();}catch(h){a?.("Failed to decode image, trying to render anyway",s.dataset.originalSrc||f,h);}l();},p=h=>{a?.("Failed image load",s.dataset.originalSrc||f,h),l();};if(O(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 Kn(e,t){H(e)&&(O(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 Ke=(function(){let t=0,n=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return ()=>(t+=1,`u${n()}${t}`)})();function Ye(e){return e?.split(",").map(t=>t.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}var Ue=0;function Yn(e){let t=`${Ve}[#${Ue}]`;return Ue++,{time:n=>e&&console.time(`${t} ${n}`),timeEnd:n=>e&&console.timeEnd(`${t} ${n}`),warn:(...n)=>e&&Xn(...n)}}function Zn(e){return {cache:e?"no-cache":"force-cache"}}async function Ze(e,t){return vn(e)?e:Jn(e,{...t,autoDestruct:true})}async function Jn(e,t){let{scale:n=1,workerUrl:r,workerNumber:i=1}=t||{},o=!!t?.debug,a=t?.features??true,s=e.ownerDocument??(M?window.document:void 0),c=e.ownerDocument?.defaultView??(M?window:void 0),u=new Map,l={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:Zn(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:Yn(o),node:e,ownerDocument:s,ownerWindow:c,dpi:n===1?null:96*n,svgStyleElement:Je(s),svgDefsElement:s?.createElementNS(te,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:xn&&r&&i?i:0})].map(()=>{try{let p=new Worker(r);return p.onmessage=async h=>{let{url:d,result:g}=h.data;g?u.get(d)?.resolve?.(g):u.get(d)?.reject?.(new Error(`Error receiving message from worker: ${d}`));},p.onmessageerror=h=>{let{url:d}=h.data;u.get(d)?.reject?.(new Error(`Error receiving message from worker: ${d}`));},p}catch(p){return l.log.warn("Failed to new Worker",p),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[Gn(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:[]};l.log.time("wait until load"),await Kn(e,{timeout:l.timeout,onWarn:l.log.warn}),l.log.timeEnd("wait until load");let{width:f,height:m}=Qn(e,l);return l.width=f,l.height=m,l}function Je(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 Qn(e,t){let{width:n,height:r}=t;if(v(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 er(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:c}=tr(e.ownerDocument,t),u=()=>{try{c?.drawImage(a,0,0,s.width,s.height);}catch(l){t.log.warn("Failed to drawImage",l);}};if(u(),t.isEnable("fixSvgXmlDecode"))for(let l=0;l<i;l++)await new Promise(f=>{setTimeout(()=>{c?.clearRect(0,0,s.width,s.height),u(),f();},l+o);});return t.drawImageCount=0,n.timeEnd("image to canvas"),s}function tr(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 c=s.getContext("2d");return c&&o&&(c.fillStyle=o,c.fillRect(0,0,s.width,s.height)),{canvas:s,context2d:c}}function Qe(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 nr(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 rr(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 or(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 Qe(o,t)}return n}function ir(e,t){return Pn(e)?Qe(e,t):Wn(e)?nr(e,t):O(e)?rr(e):Q(e)?or(e,t):e.cloneNode(false)}function sr(e){let t=e.sandbox;if(!t){let{ownerDocument:n}=e;try{n&&(t=n.createElement("iframe"),t.id=`__SANDBOX__${Ke()}`,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 ar=["width","height","-webkit-text-fill-color"],lr=["stroke","fill"];function et(e,t,n){let{defaultComputedStyles:r}=n,i=e.nodeName.toLowerCase(),o=G(e)&&i!=="svg",a=o?lr.map(d=>[d,e.getAttribute(d)]).filter(([,d])=>d!==null):[],s=[o&&"svg",i,a.map((d,g)=>`${d}=${g}`).join(","),t].filter(Boolean).join(":");if(r.has(s))return r.get(s);let u=sr(n)?.contentWindow;if(!u)return new Map;let l=u?.document,f,m;o?(f=l.createElementNS(te,"svg"),m=f.ownerDocument.createElementNS(f.namespaceURI,i),a.forEach(([d,g])=>{m.setAttributeNS(null,d,g);}),f.appendChild(m)):f=m=l.createElement(i),m.textContent=" ",l.body.appendChild(f);let p=u.getComputedStyle(m,t),h=new Map;for(let d=p.length,g=0;g<d;g++){let w=p.item(g);ar.includes(w)||h.set(w,p.getPropertyValue(w));}return l.body.removeChild(f),r.set(s,h),h}function tt(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,c=0;c<s;c++){let u=e.item(c);a(u);}for(let s=i.length,c=0;c<s;c++)o.get(i[c])?.forEach((u,l)=>r.set(l,u));function a(s){let c=e.getPropertyValue(s),u=e.getPropertyPriority(s),l=s.lastIndexOf("-"),f=l>-1?s.substring(0,l):void 0;if(f){let m=o.get(f);m||(m=new Map,o.set(f,m)),m.set(s,[c,u]);}t.get(s)===c&&!u||(f?i.push(f):r.set(s,[c,u]));}return r}function cr(e,t,n,r){let{ownerWindow:i,includeStyleProperties:o,currentParentNodeStyle:a}=r,s=t.style,c=i.getComputedStyle(e),u=et(e,null,r);a?.forEach((f,m)=>{u.delete(m);});let l=tt(c,u,o);l.delete("transition-property"),l.delete("all"),l.delete("d"),l.delete("content"),n&&(l.delete("position"),l.delete("margin-top"),l.delete("margin-right"),l.delete("margin-bottom"),l.delete("margin-left"),l.delete("margin-block-start"),l.delete("margin-block-end"),l.delete("margin-inline-start"),l.delete("margin-inline-end"),l.set("box-sizing",["border-box",""])),l.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text"),qe&&(l.has("font-kerning")||l.set("font-kerning",["normal",""]),(l.get("overflow-x")?.[0]==="hidden"||l.get("overflow-y")?.[0]==="hidden")&&l.get("text-overflow")?.[0]==="ellipsis"&&e.scrollWidth===e.clientWidth&&l.set("text-overflow",["clip",""]));for(let f=s.length,m=0;m<f;m++)s.removeProperty(s.item(m));return l.forEach(([f,m],p)=>{s.setProperty(p,f,m);}),l}function ur(e,t){(On(e)||Fn(e)||Bn(e))&&t.setAttribute("value",e.value);}var fr=["::before","::after"],dr=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"];function mr(e,t,n,r,i){let{ownerWindow:o,svgStyleElement:a,svgStyles:s,currentNodeStyle:c}=r;if(!a||!o)return;function u(l){let f=o.getComputedStyle(e,l),m=f.getPropertyValue("content");if(!m||m==="none")return;i?.(m),m=m.replace(/(')|(")|(counter\(.+\))/g,"");let p=[Ke()],h=et(e,l,r);c?.forEach((S,T)=>{h.delete(T);});let d=tt(f,h,r.includeStyleProperties);d.delete("content"),d.delete("-webkit-locale"),d.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text");let g=[`content: '${m}';`];if(d.forEach(([S,T],A)=>{g.push(`${A}: ${S}${T?" !important":""};`);}),g.length===1)return;try{t.className=[t.className,...p].join(" ");}catch(S){r.log.warn("Failed to copyPseudoClass",S);return}let w=g.join(`
9
+ `),b=s.get(w);b||(b=[],s.set(w,b)),b.push(`.${p[0]}${l}`);}fr.forEach(u),n&&dr.forEach(u);}var Be=new Set(["symbol"]);async function He(e,t,n,r,i){if(v(n)&&($n(n)||Un(n))||r.filter&&!r.filter(n))return;Be.has(t.nodeName)||Be.has(n.nodeName)?r.currentParentNodeStyle=void 0:r.currentParentNodeStyle=r.currentNodeStyle;let o=await me(n,r,false,i);r.isEnable("restoreScrollPosition")&&pr(e,o),t.appendChild(o);}async function We(e,t,n,r){let i=e.firstChild;v(e)&&e.shadowRoot&&(i=e.shadowRoot?.firstChild,n.shadowRoots.push(e.shadowRoot));for(let o=i;o;o=o.nextSibling)if(!Mn(o))if(v(o)&&Hn(o)&&typeof o.assignedNodes=="function"){let a=o.assignedNodes();for(let s=0;s<a.length;s++)await He(e,t,a[s],n,r);}else await He(e,t,o,n,r);}function pr(e,t){if(!H(e)||!H(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,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=c,o.d=u,t.style.transform=o.toString();}function gr(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 hr=/^[\w-:]+$/;async function me(e,t,n=false,r){let{ownerDocument:i,ownerWindow:o,fontFamilies:a,onCloneEachNode:s}=t;if(i&&Ln(e))return r&&/\S/.test(e.data)&&r(e.data),i.createTextNode(e.data);if(i&&o&&v(e)&&(H(e)||G(e))){let u=await ir(e,t);if(t.isEnable("removeAbnormalAttributes")){let d=u.getAttributeNames();for(let g=d.length,w=0;w<g;w++){let b=d[w];hr.test(b)||u.removeAttribute(b);}}let l=t.currentNodeStyle=cr(e,u,n,t);n&&gr(u,t);let f=false;if(t.isEnable("copyScrollbar")){let d=[l.get("overflow-x")?.[0],l.get("overflow-y")?.[0]];f=d.includes("scroll")||(d.includes("auto")||d.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth);}let m=l.get("text-transform")?.[0],p=Ye(l.get("font-family")?.[0]),h=p?d=>{m==="uppercase"?d=d.toUpperCase():m==="lowercase"?d=d.toLowerCase():m==="capitalize"&&(d=d[0].toUpperCase()+d.substring(1)),p.forEach(g=>{let w=a.get(g);w||a.set(g,w=new Set),d.split("").forEach(b=>w.add(b));});}:void 0;return mr(e,u,f,t,h),ur(e,u),Q(e)||await We(e,u,t,h),await s?.(u),u}let c=e.cloneNode(false);return await We(e,c,t),await s?.(c),c}function Er(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 yr(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(zn);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:c,requests:u,fetchFn:l,fetch:{requestInit:f,bypassingCache:m,placeholderImage:p},font:h,workers:d,fontFamilies:g}=e;r==="image"&&(J||de)&&e.drawImageCount++;let w=u.get(n);if(!w){m&&m instanceof RegExp&&m.test(a)&&(a+=(/\?/.test(a)?"&":"?")+new Date().getTime());let b=r.startsWith("font")&&h&&h.minify,S=new Set;b&&r.split(";")[1].split(",").forEach(I=>{g.has(I)&&g.get(I).forEach(_=>S.add(_));});let T=b&&S.size,A={url:a,timeout:s,responseType:T?"arrayBuffer":i,headers:r==="image"?{accept:c}:void 0,...f};w={type:r,resolve:void 0,reject:void 0,response:null},w.response=(async()=>{if(l&&r==="image"){let C=await l(n);if(C)return C}return !J&&n.startsWith("http")&&d.length?new Promise((C,I)=>{d[u.size&d.length-1].postMessage({rawUrl:n,...A}),w.resolve=C,w.reject=I;}):yr(A)})().catch(C=>{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 C}),u.set(n,w);}return w.response}async function nt(e,t,n,r){if(!rt(e))return e;for(let[i,o]of wr(e,t))try{let a=await X(n,{url:o,requestType:r?"image":"text",responseType:"dataUrl"});e=e.replace(br(i),`$1${a}$3`);}catch(a){n.log.warn("Failed to fetch css data url",i,a);}return e}function rt(e){return /url\((['"]?)([^'"]+?)\1\)/.test(e)}var ot=/url\((['"]?)([^'"]+?)\1\)/g;function wr(e,t){let n=[];return e.replace(ot,(r,i,o)=>(n.push([o,ze(o,t)]),r)),n.filter(([r])=>!ce(r))}function br(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}var Sr=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function Tr(e,t){return Sr.map(n=>{let r=e.getPropertyValue(n);return !r||r==="none"?null:((J||de)&&t.drawImageCount++,nt(r,null,t,true).then(i=>{!i||r===i||e.setProperty(n,i,e.getPropertyPriority(n));}))}).filter(Boolean)}function Rr(e,t){if(O(e)){let n=e.currentSrc||e.src;if(!ce(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(G(e)&&!ce(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 Ar(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}`,c=t.shadowRoots.reduce((u,l)=>u??l.querySelector(`svg ${s}`),n?.querySelector(`svg ${s}`));if(o&&e.setAttribute("href",s),r?.querySelector(s))return [];if(c)return r?.appendChild(c.cloneNode(true)),[];if(o)return [X(t,{url:o,responseType:"text"}).then(u=>{r?.insertAdjacentHTML("beforeend",u);})]}return []}function it(e,t){let{tasks:n}=t;v(e)&&((O(e)||je(e))&&n.push(...Rr(e,t)),Dn(e)&&n.push(...Ar(e,t))),H(e)&&n.push(...Tr(e.style,t)),e.childNodes.forEach(r=>{it(r,t);});}async function Cr(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 c=Ge(s.cssText,t);r.appendChild(n.createTextNode(`${c}
10
+ `));}else {let c=Array.from(n.styleSheets).filter(p=>{try{return "cssRules"in p&&!!p.cssRules.length}catch(h){return t.log.warn(`Error while reading CSS rules from ${p.href}`,h),false}}),u=n.implementation.createHTMLDocument(""),l=u.createElement("style");u.head.appendChild(l);let f=l.sheet;await Promise.all(c.flatMap(p=>Array.from(p.cssRules).map(async h=>{if(Nn(h)){let d=h.href,g="";try{g=await X(t,{url:d,requestType:"text",responseType:"text"});}catch(b){t.log.warn(`Error fetch remote css import from ${d}`,b);}let w=g.replace(ot,(b,S,T)=>b.replace(T,ze(T,d)));for(let b of xr(w))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&&c.push(f);let m=[];c.forEach(p=>{ue(p.cssRules,m);}),m.filter(p=>In(p)&&rt(p.style.getPropertyValue("src"))&&Ye(p.style.getPropertyValue("font-family"))?.some(h=>i.has(h))).forEach(p=>{let h=p,d=o.get(h.cssText);d?r.appendChild(n.createTextNode(`${d}
11
+ `)):a.push(nt(h.cssText,h.parentStyleSheet?h.parentStyleSheet.href:null,t).then(g=>{g=Ge(g,t),o.set(h.cssText,g),r.appendChild(n.createTextNode(`${g}
12
+ `));}));});}}var _r=/(\/\*[\s\S]*?\*\/)/g,Xe=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function xr(e){if(e==null)return [];let t=[],n=e.replace(_r,"");for(;;){let o=Xe.exec(n);if(!o)break;t.push(o[0]);}n=n.replace(Xe,"");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 vr=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Ir=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Ge(e,t){let{font:n}=t,r=n?n?.preferredFormat:void 0;return r?e.replace(Ir,i=>{for(;;){let[o,,a]=vr.exec(i)||[];if(!a)return "";if(a===r)return `src: ${o};`}}):e}function ue(e,t=[]){for(let n of Array.from(e))kn(n)?t.push(...ue(n.cssRules)):"cssRules"in n?ue(n.cssRules,t):t.push(n);return t}var Nr=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;function kr(e){return Nr.test(e.innerHTML)}async function Dr(e,t){let n=await Ze(e,t);if(v(n.node)&&G(n.node)&&!kr(n.node))return n.node;let{ownerDocument:r,log:i,tasks:o,svgStyleElement:a,svgDefsElement:s,svgStyles:c,font:u,progress:l,autoDestruct:f,onCloneNode:m,onEmbedNode:p,onCreateForeignObjectSvg:h}=n;i.time("clone node");let d=await me(n.node,n,true);if(a&&r){let T="";c.forEach((A,C)=>{T+=`${A.join(`,
13
+ `)} {
14
+ ${C}
15
+ }
16
+ `;}),a.appendChild(r.createTextNode(T));}i.timeEnd("clone node"),await m?.(d),u!==false&&v(d)&&(i.time("embed web font"),await Cr(d,n),i.timeEnd("embed web font")),i.time("embed node"),it(d,n);let g=o.length,w=0,b=async()=>{for(;;){let T=o.pop();if(!T)break;try{await T;}catch(A){n.log.warn("Failed to run task",A);}l?.(++w,g);}};l?.(w,g),await Promise.all([...Array.from({length:4})].map(b)),i.timeEnd("embed node"),await p?.(d);let S=Mr(d,n);return s&&S.insertBefore(s,S.children[0]),a&&S.insertBefore(a,S.children[0]),f&&Er(n),await h?.(S),S}function Mr(e,t){let{width:n,height:r}=t,i=Vn(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 st(e,t){let n=await Ze(e,t),r=await Dr(n),i=qn(r,n.isEnable("removeControlCharacter"));n.autoDestruct||(n.svgStyleElement=Je(n.ownerDocument),n.svgDefsElement=n.ownerDocument?.createElementNS(te,"defs"),n.svgStyles.clear());let o=P(i,r.ownerDocument);return await er(o,n)}var at=5e3;var Lr=.25,Pr=160,Or=28,Fr=1600,$r=1200,Ur=2,Br=26e5,Hr=36e5,Wr=at,Xr=1500,Gr=[/[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],ut="[masked]",Vr="#f04e23";function pe(e){let t=e;for(let n of Gr)n.lastIndex=0,t=t.replace(n,ut);return t}function lt(e){return Math.min(Math.max(e*Lr,Or),Pr)}function qr(e,t,n){let r=lt(e.width),i=lt(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),c=Math.min(n,e.top+e.height+i),u=Math.min(s-o,Fr),l=Math.min(c-a,$r);return s-o>u&&(o+=(s-o-u)/2),c-a>l&&(a+=(c-a-l)/2),{left:o,top:a,width:Math.max(0,u),height:Math.max(0,l)}}var jr=900,zr=2;function Kr(e,t){let n=1,r=e,i=0;for(;r!==null&&i<64;){try{let o=Number.parseFloat(t.getComputedStyle(r).opacity);Number.isNaN(o)||(n*=o);}catch{break}if(n<=.001)return 0;r=x(r),i++;}return n}function Yr(e,t){return new Promise(n=>{let r=t.requestAnimationFrame;if(typeof r!="function"){n();return}let i=Date.now(),o=null,a=0,s=()=>{try{if(Date.now()-i>=jr){n();return}let c=e.getBoundingClientRect(),u=`${Math.round(c.left)},${Math.round(c.top)},${Math.round(c.width)},${Math.round(c.height)}`;if(a=Kr(e,t)>=.99&&u===o?a+1:0,o=u,a>=zr){n();return}r.call(t,s);}catch{n();}};r.call(t,s);})}function Zr(e,t,n,r){let i=null,o=null,a=e,s=0;for(;a!==null&&a!==n&&s<64;){if(oo(a,r))i=null,o=null;else {let c=a.getBoundingClientRect();i===null&&io(c,t)&&(i=a),o===null&&no(c,t)>=to&&(o=a);}a=x(a),s++;}return i!==null&&Jr(i,r)?i:o??i??n}function Jr(e,t){if(ro(e)>Qr)return false;let n=e.getBoundingClientRect(),r=Math.max(1,t.innerWidth*t.innerHeight);return n.width*n.height/r<=eo}var Qr=800,eo=3,to=.4;function no(e,t){let n=t.width*t.height;if(n<=0)return 0;let r=ft(t,{left:e.left,top:e.top,width:e.width,height:e.height});return r.width*r.height/n}function ro(e){try{return e.getElementsByTagName("*").length}catch{return Number.MAX_SAFE_INTEGER}}function ft(e,t){let n=Math.max(e.left,t.left),r=Math.max(e.top,t.top),i=Math.min(e.left+e.width,t.left+t.width),o=Math.min(e.top+e.height,t.top+t.height);return {left:n,top:r,width:Math.max(0,i-n),height:Math.max(0,o-r)}}function oo(e,t){try{let n=t.getComputedStyle(e);return n.transform!==""&&n.transform!=="none"||n.perspective!==""&&n.perspective!=="none"||n.translate!==""&&n.translate!=="none"||n.rotate!==""&&n.rotate!=="none"||n.scale!==""&&n.scale!=="none"}catch{return false}}function io(e,t){return e.left<=t.left+.5&&e.top<=t.top+.5&&e.right>=t.left+t.width-.5&&e.bottom>=t.top+t.height-.5}function so(e,t,n,r){let i=[[t.left+t.width/2,t.top+t.height/2],[t.left+1,t.top+1],[t.left+t.width-1,t.top+t.height-1]];for(let[s,c]of i){let u=[];try{u=n.elementsFromPoint(s,c)??[];}catch{break}for(let l of u){if(l===e||e.contains(l)||l.hasAttribute(D))continue;let f=ct(l,r);if(f)return f}}let o=e,a=0;for(;o!==null&&a<64;){let s=ct(o,r);if(s)return s;o=x(o),a++;}return "#ffffff"}function ct(e,t){try{let n=t.getComputedStyle(e).backgroundColor;return !n||n==="transparent"||n.replace(/\s/g,"").startsWith("rgba(0,0,0,0)")?null:n}catch{return null}}function ao(e,t,n,r,i,o){let a={transform:`translate(${i}px, ${o}px)`,transformOrigin:"top left",margin:"0"};return e===n.documentElement?{...a,width:`${r.innerWidth}px`,minHeight:`${r.innerHeight}px`,overflow:"visible"}:{...a,position:"static",inset:"auto",float:"none",boxSizing:"border-box",width:`${t.width}px`,minHeight:`${t.height}px`}}function lo(e,t,n){return Promise.race([e,new Promise(r=>{try{n.setTimeout(()=>r(null),t);}catch{}})])}function co(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 uo(e){return !(e instanceof Element&&e.hasAttribute(D))}function fo(e,t,n){let r=0,i=(o,a,s)=>{if(s>64||r>2e3)return;let c=o.children,u=a.children,l=0,f=0;for(;l<c.length&&f<u.length;){let m=c[l],p=u[f];if(m.tagName!==p.tagName){l++;continue}po(o,m,p,n)&&r++,i(m,p,s+1),l++,f++;}};try{i(e,t,0);}catch{}}var mo=new Set(["block","flow-root","list-item","table-cell"]);function po(e,t,n,r){try{let i=r.getComputedStyle(t);if(i.marginLeft!=="0px"||i.marginRight!=="0px"||i.position!=="static"&&i.position!=="relative"||i.float!=="none")return !1;let o=r.getComputedStyle(e);if(!mo.has(o.display))return !1;let a=t.getBoundingClientRect(),s=e.getBoundingClientRect(),c=s.left+parseFloat(o.borderLeftWidth||"0")+parseFloat(o.paddingLeft||"0"),u=s.right-parseFloat(o.borderRightWidth||"0")-parseFloat(o.paddingRight||"0"),l=a.left-c,f=u-a.right;if(l<.5||f<.5||Math.abs(l-f)>1)return !1;let m=n;return m.style?(m.style.setProperty("margin-left",`${l}px`),m.style.setProperty("margin-right",`${f}px`),!0):!1}catch{return false}}function go(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(D))i.push(a);else if(co(a)){let s=a instanceof HTMLInputElement&&a.type==="password",c=a.getAttribute("value")??a.value??"",u=s&&c?ut:pe(c);a instanceof HTMLTextAreaElement?(a.textContent=u,a.value=u):(a.setAttribute("value",u),a.value=u);let l=a.getAttribute("placeholder");l&&a.setAttribute("placeholder",pe(l));}}o=r.nextNode();}for(let a of i)a.parentNode?.removeChild(a);}function ho(e,t,n,r){e.save(),e.strokeStyle=Vr,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 Eo(e,t){let n=Math.min(e.devicePixelRatio||1,Ur),r=t.width*t.height;return r<=0?1:Math.max(.5,Math.min(n,Math.sqrt(Br/r)))}function yo(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 dt(e){try{let t=e.ownerDocument,n=t.defaultView;if(!n||!t.documentElement||!e.isConnected||(await Yr(e,n),!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=qr(i,n.innerWidth,n.innerHeight);if(o.width<=0||o.height<=0)return null;let a=Zr(e,o,t.documentElement,n),s=a.getBoundingClientRect(),c={left:s.left,top:s.top,width:s.width,height:s.height},u=ft(o,c);if(u.width<=0||u.height<=0)return null;let l=Eo(n,u),f=-(u.left-s.left),m=-(u.top-s.top),p=await lo(st(a,{width:u.width,height:u.height,scale:l,backgroundColor:so(a,u,t,n),timeout:Xr,filter:uo,onCloneNode:g=>{g instanceof Element&&fo(a,g,n),go(g);},font:{},style:ao(a,c,t,n,f,m)}),Wr,n);if(!p)return null;let h=p.getContext("2d");if(!h)return null;ho(h,i,u,l);let d=p.toDataURL("image/png");if(d.length>Hr){let g=yo(p,t);if(!g)return null;d=g.toDataURL("image/png");}return d}catch{return null}}var wo="arcy-picker",R="arcy-picker-banner",yt="arcy-picker-highlight",bo="#17131A",mt="#201B23",pt="#332B33",gt="#F3EEE8",ht="#9E959A",he="#FF5A3C",Et="#17131A",So=`
17
+ .${R} {
18
+ display: flex;
19
+ align-items: center;
20
+ gap: 12px;
21
+ padding: 7px 8px 7px 16px;
22
+ border-radius: 999px;
23
+ background: ${bo};
24
+ border: 1px solid ${pt};
25
+ color: ${gt};
26
+ font: 400 14px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
27
+ box-shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
28
+ white-space: nowrap;
29
+ }
30
+ .${R}__mark {
31
+ display: flex;
32
+ align-items: baseline;
33
+ gap: 7px;
34
+ }
35
+ .${R}__brand {
36
+ font-weight: 600;
37
+ letter-spacing: 0.02em;
38
+ }
39
+ /* The label role from DESIGN.md: 600, 12px, uppercase, tracked wide. */
40
+ .${R}__label {
41
+ font-size: 12px;
42
+ font-weight: 600;
43
+ letter-spacing: 0.14em;
44
+ text-transform: uppercase;
45
+ color: ${ht};
46
+ }
47
+ /* Pick and Browse are one control with two states, not two buttons that
48
+ * happen to disagree. The old bar drew both as outlines and coloured whichever
49
+ * was on, which reads as two things you can press rather than as a switch. */
50
+ .${R}__modes {
51
+ display: flex;
52
+ align-items: center;
53
+ gap: 2px;
54
+ padding: 3px;
55
+ border-radius: 999px;
56
+ background: ${mt};
57
+ }
58
+ .${R} button {
59
+ appearance: none;
60
+ border: 1px solid transparent;
61
+ border-radius: 999px;
62
+ background: transparent;
63
+ color: ${ht};
64
+ font: inherit;
65
+ font-weight: 500;
66
+ padding: 5px 14px;
67
+ cursor: pointer;
68
+ transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
69
+ }
70
+ .${R} button:hover {
71
+ color: ${gt};
72
+ }
73
+ .${R} button:focus-visible {
74
+ outline: 2px solid ${he};
75
+ outline-offset: 2px;
76
+ }
77
+ /* The one filled control on the bar (DESIGN.md, one accent fill per surface). */
78
+ .${R}__modes button.is-active {
79
+ background: ${he};
80
+ color: ${Et};
81
+ font-weight: 600;
82
+ }
83
+ .${R}__modes button.is-active:hover {
84
+ color: ${Et};
85
+ }
86
+ .${R}__exit {
87
+ border-color: ${pt} !important;
88
+ }
89
+ .${R}__exit:hover {
90
+ background: ${mt};
91
+ }
92
+ .${yt} {
93
+ border-radius: 4px;
94
+ }
95
+ `;function ge(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 To=[["box-sizing","border-box"],["border",`2px solid ${he}`],["background","rgba(255, 90, 60, 0.1)"]],Ro=[["left","50%"],["bottom","24px"]],Ao=[["transform","translateX(-50%)"]];function wt(e){let t=Fe({id:wo});if(!t)return null;let n=t.host.ownerDocument,r="pick",i=false,o=null,a=0;$e(t,So);let s=n.createElement("div");s.className=yt,ge(s,"none");for(let[E,y]of To)s.style.setProperty(E,y);w();let c=n.createElement("div");c.className=R,ge(c,"auto",Ro);for(let[E,y]of Ao)c.style.setProperty(E,y);let u=n.createElement("span");u.className=`${R}__mark`;let l=n.createElement("span");l.className=`${R}__brand`,l.textContent="ARCY";let f=n.createElement("span");f.className=`${R}__label`,f.textContent="Element picker",u.append(l,f);let m=n.createElement("span");m.className=`${R}__modes`,ge(m,"auto"),m.style.setProperty("position","relative","important");let p=n.createElement("button");p.type="button",p.textContent="Pick";let h=n.createElement("button");h.type="button",h.textContent="Browse",m.append(p,h);let d=n.createElement("button");d.type="button",d.className=`${R}__exit`,d.textContent="Exit",c.append(u,m,d),t.root.append(s,c);function g(E){r=E,p.classList.toggle("is-active",E==="pick"),h.classList.toggle("is-active",E==="browse"),E==="browse"&&w();}function w(){s.style.setProperty("display","none","important");}function b(E){try{let y=E.getBoundingClientRect();if(y.width===0&&y.height===0){w();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{w();}}function S(E){return E instanceof Element&&_e(E,`[${D}]`)!==null}function T(E){if(typeof E.composedPath=="function"){let y=E.composedPath();if(y.length>0)return y[0]}return E.target}function A(){return t!==null&&t.host.isConnected?false:(ne(),true)}let C=E=>{try{if(A()||r!=="pick")return;let y=T(E);if(S(y)||!(y instanceof Element)){o=null,w();return}o=ie(y),b(o);}catch{}},I=()=>{try{if(A()||r!=="pick")return;o&&o.isConnected?b(o):w();}catch{}},_=E=>{try{if(A()||r!=="pick"||S(T(E)))return;E.preventDefault(),E.stopPropagation(),E.stopImmediatePropagation();}catch{}},Ee=E=>{try{if(A()||r!=="pick")return;let y=T(E);if(S(y)||(E.preventDefault(),E.stopPropagation(),E.stopImmediatePropagation(),!(y instanceof Element)))return;let N=ie(y),V=Ce(K(N)),be=Me(N);V.selector=be.autoSelector,V.selectorCandidates=be.candidates,o=N,b(N);let Se=0;try{Se=ke(V,n).matchCount;}catch{}if(e.onPick(V,Se),e.screenshotsEnabled===!1)return;let Te=++a;bt(()=>{i||Te!==a||dt(N).then(Re=>{if(!(!Re||i||Te!==a))try{e.onScreenshot?.(Re);}catch{}});});}catch(y){k(`The element picker could not read that element. ${String(y)}`);}};function bt(E){let y=n.defaultView,N=y?.requestAnimationFrame;if(typeof N!="function"){setTimeout(E,0);return}N.call(y,()=>N.call(y,E));}function St(E){if(!(E instanceof Element))return false;let y=E.tagName;return y==="INPUT"||y==="TEXTAREA"||y==="SELECT"?true:E.isContentEditable===true}let ye=E=>{try{if(A())return;let y=E;if(!y.altKey||y.code!=="KeyS"&&y.key.toLowerCase()!=="s"||St(T(y)))return;y.preventDefault(),g(r==="pick"?"browse":"pick");}catch{}};function ne(){if(!i){i=true;try{n.removeEventListener("pointerdown",_,!0),n.removeEventListener("mousedown",_,!0),n.removeEventListener("mouseup",_,!0),n.removeEventListener("auxclick",_,!0),n.removeEventListener("click",Ee,!0),n.removeEventListener("mousemove",C,!0),n.removeEventListener("keydown",ye,!0),n.defaultView?.removeEventListener("scroll",I,!0),n.defaultView?.removeEventListener("resize",I);}catch{}t?.destroy(),t=null;}}let we=E=>{try{E.preventDefault();}catch{}};return c.addEventListener("pointerdown",we),c.addEventListener("mousedown",we),p.addEventListener("click",()=>g("pick")),h.addEventListener("click",()=>g("browse")),d.addEventListener("click",()=>{ne();try{e.onExit();}catch{}}),n.addEventListener("pointerdown",_,true),n.addEventListener("mousedown",_,true),n.addEventListener("mouseup",_,true),n.addEventListener("auxclick",_,true),n.addEventListener("click",Ee,true),n.addEventListener("mousemove",C,true),n.addEventListener("keydown",ye,true),n.defaultView?.addEventListener("scroll",I,true),n.defaultView?.addEventListener("resize",I),g("pick"),{destroy:ne}}var _o={contract:2,mount:e=>{try{return wt(e)}catch{return null}}};if(typeof window<"u")try{window[Ae]=_o;}catch{}})();
@@ -3075,9 +3075,6 @@ function mount(context) {
3075
3075
  flowOffers: result.flowsOffered
3076
3076
  });
3077
3077
  context.touchConversation?.();
3078
- if (result.isFallback) {
3079
- context.track?.("fallback_triggered", {}, { question: text });
3080
- }
3081
3078
  for (const offer of result.flowsOffered) {
3082
3079
  context.track?.(
3083
3080
  "flow_suggested",
@@ -1,4 +1,4 @@
1
- import { SELECTOR_CANDIDATES_MAX, FINGERPRINT_TEXT_MAX } from './chunk-NY3NXM2V.js';
1
+ import { SELECTOR_CANDIDATES_MAX, FINGERPRINT_TEXT_MAX } from './chunk-AW7DHYSA.js';
2
2
 
3
3
  /* arcy.js — https://arcyai.com */
4
4
 
@@ -8,7 +8,7 @@ var DESIGN_MODE_READY = "arcy:design-mode:ready";
8
8
  var DESIGN_MODE_PICK = "arcy:design-mode:pick";
9
9
  var DESIGN_MODE_EXIT = "arcy:design-mode:exit";
10
10
  var DESIGN_MODE_SCREENSHOT = "arcy:design-mode:screenshot";
11
- var SCREENSHOT_RENDER_BUDGET_MS = 8e3;
11
+ var SCREENSHOT_RENDER_BUDGET_MS = 5e3;
12
12
  var TAG_MAX = 64;
13
13
  var ROUTE_MAX = 2048;
14
14
  var SELECTOR_MAX = 512;
@@ -210,4 +210,4 @@ function captureEventFingerprint(el) {
210
210
  return fingerprint;
211
211
  }
212
212
 
213
- export { FINGERPRINT_TEXT_MAX, MASK, SELECTOR_CANDIDATES_MAX, captureEventFingerprint, closestAcrossShadow, collectElementsDeep, containsAcrossShadow, containsPii, createTargetFingerprint, isInteractive, isStableId, querySelectorAllDeep, resolveInteractiveTarget };
213
+ export { FINGERPRINT_TEXT_MAX, MASK, SELECTOR_CANDIDATES_MAX, captureEventFingerprint, closestAcrossShadow, collectElementsDeep, containsAcrossShadow, containsPii, createTargetFingerprint, isInteractive, isStableId, parentOrHost, querySelectorAllDeep, resolveInteractiveTarget };
@@ -1,4 +1,4 @@
1
- import { querySelectorAllDeep, captureEventFingerprint, containsAcrossShadow, collectElementsDeep, isInteractive, MASK } from './chunk-NY3NXM2V.js';
1
+ import { querySelectorAllDeep, captureEventFingerprint, containsAcrossShadow, collectElementsDeep, isInteractive, MASK } from './chunk-AW7DHYSA.js';
2
2
 
3
3
  /* arcy.js — https://arcyai.com */
4
4
 
@@ -15,7 +15,7 @@ var DESIGN_MODE_READY = "arcy:design-mode:ready";
15
15
  var DESIGN_MODE_PICK = "arcy:design-mode:pick";
16
16
  var DESIGN_MODE_EXIT = "arcy:design-mode:exit";
17
17
  var DESIGN_MODE_SCREENSHOT = "arcy:design-mode:screenshot";
18
- var SCREENSHOT_RENDER_BUDGET_MS = 8e3;
18
+ var SCREENSHOT_RENDER_BUDGET_MS = 5e3;
19
19
  var TAG_MAX = 64;
20
20
  var ROUTE_MAX = 2048;
21
21
  var SELECTOR_MAX = 512;
@@ -161,8 +161,16 @@ declare const DESIGN_MODE_SCREENSHOT = "arcy:design-mode:screenshot";
161
161
  * with its computed styles, its pseudo-elements and its web fonts embedded as
162
162
  * data URLs, which on a real marketing page takes several. Nobody revisited
163
163
  * the two seconds, because nothing in either file mentioned the other.
164
+ *
165
+ * Then 8s turned out to be a floor rather than a ceiling, because the
166
+ * rasterizer spends its `timeout` per resource and one lazy image below the
167
+ * fold always ran it out (D1258). With that fixed and the render scoped to
168
+ * the crop's covering ancestor, a real capture is around 200ms, so this
169
+ * number stopped being something an operator waits on. It is now only the
170
+ * ceiling on the worst case left: a target nothing smaller than the document
171
+ * covers, on a heavy page, which measured 2.6s of real work.
164
172
  */
165
- declare const SCREENSHOT_RENDER_BUDGET_MS = 8000;
173
+ declare const SCREENSHOT_RENDER_BUDGET_MS = 5000;
166
174
  interface DesignModeReady {
167
175
  type: typeof DESIGN_MODE_READY;
168
176
  protocol: number;
@@ -1,2 +1,2 @@
1
- export { DESIGN_MODE_EXIT, DESIGN_MODE_PICK, DESIGN_MODE_PROTOCOL, DESIGN_MODE_READY, DESIGN_MODE_SCREENSHOT, SCREENSHOT_RENDER_BUDGET_MS, readDesignModeMessage } from './chunk-GDGE3HLE.js';
2
- export { MASK } from './chunk-NY3NXM2V.js';
1
+ export { DESIGN_MODE_EXIT, DESIGN_MODE_PICK, DESIGN_MODE_PROTOCOL, DESIGN_MODE_READY, DESIGN_MODE_SCREENSHOT, SCREENSHOT_RENDER_BUDGET_MS, readDesignModeMessage } from './chunk-7S5DA67F.js';
2
+ export { MASK } from './chunk-AW7DHYSA.js';
@@ -1,7 +1,7 @@
1
1
  import { FLOW_CONTRACT, FLOW_GLOBAL, createFlowRunState, createPreviewRunState, uuidV4 } from './chunk-FR6SJSDU.js';
2
2
  import { readFlowDetail, normalizeOptionReply, validateFillReply, fetchFlowRun } from './chunk-CQ2DESAJ.js';
3
- import { matchTarget } from './chunk-NIHUDSWK.js';
4
- import { collectElementsDeep, isInteractive, captureEventFingerprint } from './chunk-NY3NXM2V.js';
3
+ import { matchTarget } from './chunk-QDCO2MRA.js';
4
+ import { collectElementsDeep, isInteractive, captureEventFingerprint } from './chunk-AW7DHYSA.js';
5
5
 
6
6
  /* arcy.js — https://arcyai.com */
7
7
 
@@ -171,6 +171,26 @@ function evaluateCurrentPage(node, href) {
171
171
  if (node.matches.length === 0) return true;
172
172
  return node.matches.some((pattern) => globMatches(pattern, href));
173
173
  }
174
+ var DATE_SHAPED = /^\d{4}-\d{2}-\d{2}/;
175
+ function parseInstant(value) {
176
+ if (!DATE_SHAPED.test(value)) return null;
177
+ const ms = new Date(value).getTime();
178
+ return Number.isFinite(ms) ? ms : null;
179
+ }
180
+ function compareOrdered(live, expected) {
181
+ if (live.trim() === "" || expected.trim() === "") return null;
182
+ const liveNumber = Number(live);
183
+ const expectedNumber = Number(expected);
184
+ if (Number.isFinite(liveNumber) && Number.isFinite(expectedNumber)) {
185
+ return liveNumber - expectedNumber;
186
+ }
187
+ const liveInstant = parseInstant(live);
188
+ const expectedInstant = parseInstant(expected);
189
+ if (liveInstant !== null && expectedInstant !== null) {
190
+ return liveInstant - expectedInstant;
191
+ }
192
+ return null;
193
+ }
174
194
  function compareText(operator, live, expected) {
175
195
  if (live === void 0) return false;
176
196
  switch (operator) {
@@ -192,16 +212,14 @@ function compareText(operator, live, expected) {
192
212
  return live === "";
193
213
  case "is_not_empty":
194
214
  return live !== "";
195
- // Numeric compares parse both sides; either side not a number means the
196
- // condition cannot hold (never throw, never coerce NaN into an answer).
215
+ // Ordered compares read both sides as numbers, then as instants; either
216
+ // side unreadable means the condition cannot hold (never throw, never
217
+ // coerce NaN into an answer).
197
218
  case "greater_than":
198
219
  case "less_than": {
199
- const liveNumber = Number(live);
200
- const expectedNumber = Number(expected);
201
- if (live.trim() === "" || !Number.isFinite(liveNumber) || !Number.isFinite(expectedNumber)) {
202
- return false;
203
- }
204
- return operator === "greater_than" ? liveNumber > expectedNumber : liveNumber < expectedNumber;
220
+ const ordered = compareOrdered(live, expected);
221
+ if (ordered === null) return false;
222
+ return operator === "greater_than" ? ordered > 0 : ordered < 0;
205
223
  }
206
224
  // The same `*` glob `current_page` uses, applied to a field value.
207
225
  case "matches_pattern":
@@ -270,15 +288,22 @@ function evaluateElement(node, ctx) {
270
288
  return false;
271
289
  }
272
290
  }
291
+ function isEmptyValue(live) {
292
+ if (live === void 0 || live === null || live === "") return true;
293
+ if (Array.isArray(live)) return live.length === 0;
294
+ if (typeof live === "object") return Object.keys(live).length === 0;
295
+ return false;
296
+ }
273
297
  function evaluateAttribute(node, ctx) {
274
298
  const live = ctx.getTrait?.(node.codeName);
275
299
  switch (node.operator) {
276
300
  case "has_any_value":
277
- return live !== void 0 && live !== null && live !== "";
301
+ return !isEmptyValue(live);
278
302
  case "is_empty":
279
- return live === void 0 || live === null || live === "";
303
+ return isEmptyValue(live);
280
304
  }
281
305
  if (live === void 0) return false;
306
+ if (typeof live === "object") return false;
282
307
  const liveText = String(live);
283
308
  const expected = node.value === void 0 ? "" : String(node.value);
284
309
  return compareText(node.operator, liveText, expected);
@@ -398,6 +423,21 @@ var ActiveRun = class {
398
423
  /** ADR 0166: true while a fill question is awaiting the end user's
399
424
  * answer. Suspends trigger evaluation for the duration. */
400
425
  this.inputPending = false;
426
+ /**
427
+ * True from the moment a step is entered until its own action has
428
+ * settled. Suspends trigger evaluation for exactly that window, the same
429
+ * posture `inputPending` takes around a fill question.
430
+ *
431
+ * **This is what makes a step's type mean anything.** The builder's
432
+ * default condition for a new trigger is `always_true` with no wait
433
+ * (`flow-draft.ts`'s `newTrigger`), so the ordinary way to say "then go to
434
+ * step 2" is a trigger that is true the instant the step mounts. Without
435
+ * this flag `startWatch`'s initial pass fired that trigger before the step
436
+ * had clicked, filled or navigated anything, and the action never ran at
437
+ * all: a two-step flow counted to step 2 and quietly ended, having done
438
+ * nothing. A step acts first; its triggers are how it is left.
439
+ */
440
+ this.actionPending = false;
401
441
  /** Extra capture-phase listeners `startWatch` installs alongside the
402
442
  * click listener (D1297): typing, focus moves and checkbox flips change
403
443
  * nothing a MutationObserver can see, yet `text_input`, `is_focused`
@@ -534,6 +574,7 @@ var ActiveRun = class {
534
574
  }
535
575
  this.activityListeners = [];
536
576
  this.inputPending = false;
577
+ this.actionPending = false;
537
578
  this.trueSince.clear();
538
579
  this.clicked.clear();
539
580
  this.initialValues.clear();
@@ -623,7 +664,7 @@ var ActiveRun = class {
623
664
  }
624
665
  checkTriggers(step, ctx) {
625
666
  if (this.stopped) return;
626
- if (this.inputPending) return;
667
+ const mayFire = !this.inputPending && !this.actionPending;
627
668
  const now = this.now();
628
669
  for (const trigger of [...step.triggers].sort((a, b) => a.position - b.position)) {
629
670
  const parsed = this.parsedTrigger(trigger);
@@ -637,7 +678,7 @@ var ActiveRun = class {
637
678
  const since = this.trueSince.get(key) ?? now;
638
679
  if (!this.trueSince.has(key)) this.trueSince.set(key, since);
639
680
  const waitMs = (trigger.waitSeconds ?? 0) * 1e3;
640
- if (now - since >= waitMs) {
681
+ if (now - since >= waitMs && mayFire) {
641
682
  this.fireTrigger(trigger);
642
683
  return;
643
684
  }
@@ -723,8 +764,7 @@ var ActiveRun = class {
723
764
  }
724
765
  this.checkTriggers(step, this.conditionContext());
725
766
  }
726
- async runExecutor(step) {
727
- const startIndex = this.stepIndex;
767
+ async runExecutor(step, startIndex) {
728
768
  try {
729
769
  const outcome = await this.executor(step, {
730
770
  doc: this.doc,
@@ -736,6 +776,7 @@ var ActiveRun = class {
736
776
  }
737
777
  });
738
778
  if (this.stopped || this.stepIndex !== startIndex) return;
779
+ this.actionPending = false;
739
780
  if (outcome.status === "advance") {
740
781
  this.emit("flow_step_completed");
741
782
  if (step.isCompletion) {
@@ -780,11 +821,14 @@ var ActiveRun = class {
780
821
  );
781
822
  return;
782
823
  }
824
+ this.scheduleCheck(step);
783
825
  } catch {
826
+ this.actionPending = false;
784
827
  }
785
828
  }
786
829
  enterStep() {
787
830
  const step = this.currentStep();
831
+ const stepIndex = this.stepIndex;
788
832
  if (!step || this.stopped) {
789
833
  this.finish(step ? "completed" : "error", step ? void 0 : { reason: "missing_step" });
790
834
  return;
@@ -799,8 +843,9 @@ var ActiveRun = class {
799
843
  });
800
844
  const begin = () => {
801
845
  if (this.stopped) return;
846
+ this.actionPending = true;
802
847
  this.startWatch(step);
803
- void this.runExecutor(step);
848
+ void this.runExecutor(step, stepIndex);
804
849
  };
805
850
  this.waitForPageReady(begin);
806
851
  }