arcy.js 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -3
- package/dist/arcy.chat.ab181cf5a84b.js +1258 -0
- package/dist/arcy.flow.fef131718e42.js +3 -0
- package/dist/arcy.legacy.ab4e9266b657.js +567 -0
- package/dist/arcy.loader.js +2 -0
- package/dist/arcy.modern.60faeffc62a2.js +567 -0
- package/dist/arcy.picker.c598a581d964.js +59 -0
- package/dist/design-mode.cjs +135 -0
- package/dist/design-mode.d.cts +197 -0
- package/dist/design-mode.d.ts +197 -0
- package/dist/design-mode.js +127 -0
- package/dist/fonts/dm-sans-latin-ext.woff2 +0 -0
- package/dist/fonts/dm-sans-latin.woff2 +0 -0
- package/dist/fonts/ibm-plex-sans-latin-ext.woff2 +0 -0
- package/dist/fonts/ibm-plex-sans-latin.woff2 +0 -0
- package/dist/fonts/inter-latin-ext.woff2 +0 -0
- package/dist/fonts/inter-latin.woff2 +0 -0
- package/dist/fonts/lato-latin-ext.woff2 +0 -0
- package/dist/fonts/lato-latin.woff2 +0 -0
- package/dist/fonts/manrope-latin-ext.woff2 +0 -0
- package/dist/fonts/manrope-latin.woff2 +0 -0
- package/dist/fonts/montserrat-latin-ext.woff2 +0 -0
- package/dist/fonts/montserrat-latin.woff2 +0 -0
- package/dist/fonts/nunito-latin-ext.woff2 +0 -0
- package/dist/fonts/nunito-latin.woff2 +0 -0
- package/dist/fonts/open-sans-latin-ext.woff2 +0 -0
- package/dist/fonts/open-sans-latin.woff2 +0 -0
- package/dist/fonts/playfair-display-latin-ext.woff2 +0 -0
- package/dist/fonts/playfair-display-latin.woff2 +0 -0
- package/dist/fonts/poppins-latin-ext.woff2 +0 -0
- package/dist/fonts/poppins-latin.woff2 +0 -0
- package/dist/fonts/roboto-latin-ext.woff2 +0 -0
- package/dist/fonts/roboto-latin.woff2 +0 -0
- package/dist/fonts/source-sans-3-latin-ext.woff2 +0 -0
- package/dist/fonts/source-sans-3-latin.woff2 +0 -0
- package/dist/fonts/work-sans-latin-ext.woff2 +0 -0
- package/dist/fonts/work-sans-latin.woff2 +0 -0
- package/dist/index.cjs +5114 -0
- package/dist/index.d.cts +133 -0
- package/dist/index.d.ts +133 -0
- package/dist/index.js +5109 -0
- package/dist/snippet.cjs +46 -0
- package/dist/snippet.d.cts +39 -0
- package/dist/snippet.d.ts +39 -0
- package/dist/snippet.js +43 -0
- package/package.json +69 -5
- package/index.js +0 -5
|
@@ -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 Ae=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<Ae&&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<Ae&&r.push(...$(a.shadowRoot,t,n+1));}return r}var Ce=[/[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 Ce.some(t=>(t.lastIndex=0,t.test(e)))}var re=4096,lt=100,ut=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-lt):t.slice(0,r);}let n=t.replace(/\s+/g," ").trim();if(n){for(let r of Ce)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 ft=new Set(["button","input","select","textarea","label","summary"]),dt=new Set(["button","link","menuitem","tab","option"]);function oe(e){let t=e.tagName.toLowerCase();if(ft.has(t)||t==="a"&&e.hasAttribute("href"))return true;let n=e.getAttribute("role");if(n!==null&&dt.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 mt=["data-testid","data-test","data-cy","id","name","aria-label"],gt=["data-testid","data-test","data-cy"],pt=64;function ht(e){for(let t of gt){let n=e.getAttribute(t);if(n===null)continue;let r=n.trim();if(!(r===""||r.length>pt)&&!N(r))return r}}var wt=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 mt){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&&wt.has(r))return {tag:n,attr:"role",value:r};t=L(t);}}function yt(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:yt(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<=ut&&!N(u)&&(t.role=u);}let s=ht(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 bt(e){return e.getClientRects().length>0}var St=50,Tt=40,vt=10,At=15,Ct=15,Rt=10,xt=10,_t=10,It=5,Nt=5,kt=.6,Lt=.7,Pt={1:.3,2:.45,3:.6,4:.75,5:.9};function K(e){return e.split(j).join(" ").replace(/\s+/g," ").trim()}function Dt(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)?kt:0}function U(e,t){return t===e?1:0}function se(e){return e.includes(j)&&K(e)===""}function Mt(e,t,n){let r=0,i=0,o=(a,s)=>{r+=a,i+=a*s;};if(e.testId!==void 0&&o(St,U(e.testId,t.testId)),e.text!==void 0&&K(e.text)!==""&&o(n?vt:Tt,Dt(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(xt,U(e.placeholder,t.placeholder)),e.id!==void 0&&o(Ct,U(e.id,t.id)),e.role!==void 0&&o(It,U(e.role,t.role)),o(Rt,t.tag===e.tag?1:0),o(Nt,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:Lt),o(_t,a);}return r===0?0:i/r}function Ft(e,t){if(e.selector===null)return null;try{return $(t,e.selector)}catch{return null}}function Ot(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=Pt[e.precision],r=false,i=[];for(let a of t){if(!bt(a))continue;r=true;let s=Mt(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=Ft(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,Ot(e,t))}catch{return {status:"not_found",reason:"error",matchCount:0}}}var $t=1,Z=2,Ut=5,Ht=["data-testid","data-test","data-cy"],Bt=["name","for","aria-label"],Wt=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"]),Xt=/^-?(?: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)-(.+)$/,Vt=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 Gt(e){let t=e.startsWith("!")?e.slice(1):e;if(t.includes(":")||t.includes("[")||t.includes("]")||t.includes("/")||Wt.has(t))return true;let n=Xt.exec(t);if(n===null)return false;let r=n[1];return /\d/.test(r)?true:r.split("-").every(i=>Vt.has(i))}var qt=["css-","sc-","jss-"];function jt(e){for(let n of qt)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 zt(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 Yt=10,Kt=.02;function Zt(e){return Math.max(Yt,Math.ceil(e*Kt))}var Jt=80;function ae(e,t){let n=e.getAttribute(t);return n===null||n.trim()===""||n.length>Jt||/[\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 Qt(e,t,n){let r;try{r=$(e,t);}catch{return null}return r.includes(n)?r.length:null}var en="http://www.w3.org/1999/xhtml";function Ie(e){try{return tn(e)}catch{return {candidates:[],autoSelector:null}}}function tn(e){let t=e.ownerDocument,n=e.namespaceURI===null||e.namespaceURI===en?e.tagName.toLowerCase():e.tagName,r=[];for(let c of Ht){let f=ae(e,c);f!==null&&r.push({selector:ce(c,f),tier:$t});}let i=e.getAttribute("id");i!==null&&z(i)&&!N(i)&&r.push({selector:`#${_e(i)}`,tier:Z});for(let c of Bt){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}=zt(t),m=Zt(f),g=e.classList,p=new Set;for(let d=0;d<g.length;d+=1){let h=g[d];p.has(h)||(p.add(h),!(Gt(h)||jt(h)||N(h))&&((c.get(h)??0)>m||r.push({selector:`${n}.${_e(h)}`,tier:Ut})));}}let a=[];for(let c of r){let f=Qt(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}`);}var ke="arcy-widget",k="data-arcy",nn="2147483000",rn=[["position","fixed"],["inset","0"],["z-index",nn],["pointer-events","none"],["background","transparent"],["border","0"],["box-shadow","none"],["outline","0"]],on=[["margin","0"],["padding","0"]],Ne="data-arcy-style",H=new Map;function sn(e=ke){let t=H.get(e);return t!==void 0&&t.host.isConnected}function Le(e={}){if(typeof document>"u")return null;let t=e.id??ke,n=e.container;if(sn(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 rn)i.style.setProperty(l,u,"important");for(let[l,u]of on)i.style.setProperty(l,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{}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 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||ln(e.ownerDocument,e);});}catch{}}function ln(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 Pe(e,t){if(!e.isolated)return false;try{let n=e.root.querySelector(`[${Ne}]`);if(n)return n.textContent=`${n.textContent??""}
|
|
3
|
+
${t}`,!0;let r=e.host.ownerDocument.createElement("style");return r.setAttribute(Ne,""),r.textContent=t,e.root.appendChild(r),!0}catch(n){return x(`The widget could not apply its styles. ${String(n)}`),false}}var He="[modern-screenshot]",_=typeof window<"u",un=_&&"Worker"in window,fe=_?window.navigator?.userAgent:"",Be=fe.includes("Chrome"),J=fe.includes("AppleWebKit")&&!Be,de=fe.includes("Firefox"),fn=e=>e&&"__CONTEXT__"in e,dn=e=>e.constructor.name==="CSSFontFaceRule",mn=e=>e.constructor.name==="CSSImportRule",gn=e=>e.constructor.name==="CSSLayerBlockRule",C=e=>e.nodeType===1,V=e=>typeof e.className=="object",We=e=>e.tagName==="image",pn=e=>e.tagName==="use",B=e=>C(e)&&typeof e.style<"u"&&!V(e),hn=e=>e.nodeType===8,wn=e=>e.nodeType===3,D=e=>e.tagName==="IMG",Q=e=>e.tagName==="VIDEO",En=e=>e.tagName==="CANVAS",yn=e=>e.tagName==="TEXTAREA",bn=e=>e.tagName==="INPUT",Sn=e=>e.tagName==="STYLE",Tn=e=>e.tagName==="SCRIPT",vn=e=>e.tagName==="SELECT",An=e=>e.tagName==="SLOT",Cn=e=>e.tagName==="IFRAME",Rn=(...e)=>console.warn(He,...e);function xn(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 Xe(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&&C(e)?e?.ownerDocument:e)??window.document}var te="http://www.w3.org/2000/svg";function _n(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 In(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 Nn(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 kn=e=>Nn(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,g=p=>{a?.("Failed video load",f,p),o?.(p),c();};u=()=>{s.removeEventListener("loadeddata",m),s.removeEventListener("error",g);},s.addEventListener("loadeddata",m,{once:true}),s.addEventListener("error",g,{once:true});}else {let f=We(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(p){a?.("Failed to decode image, trying to render anyway",s.dataset.originalSrc||f,p);}c();},g=p=>{a?.("Failed image load",s.dataset.originalSrc||f,p),c();};if(D(s)&&s.complete)return m();u=()=>{s.removeEventListener("load",m),s.removeEventListener("error",g);},s.addEventListener("load",m,{once:true}),s.addEventListener("error",g,{once:true});}})}async function Ln(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 Ve=(function(){let t=0,n=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return ()=>(t+=1,`u${n()}${t}`)})();function Ge(e){return e?.split(",").map(t=>t.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}var De=0;function Pn(e){let t=`${He}[#${De}]`;return De++,{time:n=>e&&console.time(`${t} ${n}`),timeEnd:n=>e&&console.timeEnd(`${t} ${n}`),warn:(...n)=>e&&Rn(...n)}}function Dn(e){return {cache:e?"no-cache":"force-cache"}}async function qe(e,t){return fn(e)?e:Mn(e,{...t,autoDestruct:true})}async function Mn(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:Dn(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:Pn(o),node:e,ownerDocument:s,ownerWindow:l,dpi:n===1?null:96*n,svgStyleElement:je(s),svgDefsElement:s?.createElementNS(te,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:un&&r&&i?i:0})].map(()=>{try{let g=new Worker(r);return g.onmessage=async p=>{let{url:d,result:h}=p.data;h?u.get(d)?.resolve?.(h):u.get(d)?.reject?.(new Error(`Error receiving message from worker: ${d}`));},g.onmessageerror=p=>{let{url:d}=p.data;u.get(d)?.reject?.(new Error(`Error receiving message from worker: ${d}`));},g}catch(g){return c.log.warn("Failed to new Worker",g),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[xn(s)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:u,drawImageCount:0,tasks:[],features:a,isEnable:g=>g==="restoreScrollPosition"?typeof a=="boolean"?false:a[g]??false:typeof a=="boolean"?a:a[g]??true,shadowRoots:[]};c.log.time("wait until load"),await Ln(e,{timeout:c.timeout,onWarn:c.log.warn}),c.log.timeEnd("wait until load");let{width:f,height:m}=Fn(e,c);return c.width=f,c.height=m,c}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 Fn(e,t){let{width:n,height:r}=t;if(C(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 On(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}=$n(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 $n(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 ze(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 Un(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 Hn(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 Bn(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 ze(o,t)}return n}function Wn(e,t){return En(e)?ze(e,t):Cn(e)?Un(e,t):D(e)?Hn(e):Q(e)?Bn(e,t):e.cloneNode(false)}function Xn(e){let t=e.sandbox;if(!t){let{ownerDocument:n}=e;try{n&&(t=n.createElement("iframe"),t.id=`__SANDBOX__${Ve()}`,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 Vn=["width","height","-webkit-text-fill-color"],Gn=["stroke","fill"];function Ye(e,t,n){let{defaultComputedStyles:r}=n,i=e.nodeName.toLowerCase(),o=V(e)&&i!=="svg",a=o?Gn.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=Xn(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 g=u.getComputedStyle(m,t),p=new Map;for(let d=g.length,h=0;h<d;h++){let y=g.item(h);Vn.includes(y)||p.set(y,g.getPropertyValue(y));}return c.body.removeChild(f),r.set(s,p),p}function Ke(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 qn(e,t,n,r){let{ownerWindow:i,includeStyleProperties:o,currentParentNodeStyle:a}=r,s=t.style,l=i.getComputedStyle(e),u=Ye(e,null,r);a?.forEach((f,m)=>{u.delete(m);});let c=Ke(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"),Be&&(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],g)=>{s.setProperty(g,f,m);}),c}function jn(e,t){(yn(e)||bn(e)||vn(e))&&t.setAttribute("value",e.value);}var zn=["::before","::after"],Yn=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"];function Kn(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 g=[Ve()],p=Ye(e,c,r);l?.forEach((S,v)=>{p.delete(v);});let d=Ke(f,p,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],A)=>{h.push(`${A}: ${S}${v?" !important":""};`);}),h.length===1)return;try{t.className=[t.className,...g].join(" ");}catch(S){r.log.warn("Failed to copyPseudoClass",S);return}let y=h.join(`
|
|
9
|
+
`),b=s.get(y);b||(b=[],s.set(y,b)),b.push(`.${g[0]}${c}`);}zn.forEach(u),n&&Yn.forEach(u);}var Me=new Set(["symbol"]);async function Fe(e,t,n,r,i){if(C(n)&&(Sn(n)||Tn(n))||r.filter&&!r.filter(n))return;Me.has(t.nodeName)||Me.has(n.nodeName)?r.currentParentNodeStyle=void 0:r.currentParentNodeStyle=r.currentNodeStyle;let o=await me(n,r,false,i);r.isEnable("restoreScrollPosition")&&Zn(e,o),t.appendChild(o);}async function Oe(e,t,n,r){let i=e.firstChild;C(e)&&e.shadowRoot&&(i=e.shadowRoot?.firstChild,n.shadowRoots.push(e.shadowRoot));for(let o=i;o;o=o.nextSibling)if(!hn(o))if(C(o)&&An(o)&&typeof o.assignedNodes=="function"){let a=o.assignedNodes();for(let s=0;s<a.length;s++)await Fe(e,t,a[s],n,r);}else await Fe(e,t,o,n,r);}function Zn(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 Jn(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 Qn=/^[\w-:]+$/;async function me(e,t,n=false,r){let{ownerDocument:i,ownerWindow:o,fontFamilies:a,onCloneEachNode:s}=t;if(i&&wn(e))return r&&/\S/.test(e.data)&&r(e.data),i.createTextNode(e.data);if(i&&o&&C(e)&&(B(e)||V(e))){let u=await Wn(e,t);if(t.isEnable("removeAbnormalAttributes")){let d=u.getAttributeNames();for(let h=d.length,y=0;y<h;y++){let b=d[y];Qn.test(b)||u.removeAttribute(b);}}let c=t.currentNodeStyle=qn(e,u,n,t);n&&Jn(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],g=Ge(c.get("font-family")?.[0]),p=g?d=>{m==="uppercase"?d=d.toUpperCase():m==="lowercase"?d=d.toLowerCase():m==="capitalize"&&(d=d[0].toUpperCase()+d.substring(1)),g.forEach(h=>{let y=a.get(h);y||a.set(h,y=new Set),d.split("").forEach(b=>y.add(b));});}:void 0;return Kn(e,u,f,t,p),jn(e,u),Q(e)||await Oe(e,u,t,p),await s?.(u),u}let l=e.cloneNode(false);return await Oe(e,l,t),await s?.(l),l}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 tr(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(kn);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:g},font:p,workers:d,fontFamilies:h}=e;r==="image"&&(J||de)&&e.drawImageCount++;let y=u.get(n);if(!y){m&&m instanceof RegExp&&m.test(a)&&(a+=(/\?/.test(a)?"&":"?")+new Date().getTime());let b=r.startsWith("font")&&p&&p.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,A={url:a,timeout:s,responseType:v?"arrayBuffer":i,headers:r==="image"?{accept:l}:void 0,...f};y={type:r,resolve:void 0,reject:void 0,response:null},y.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,...A}),y.resolve=T,y.reject=I;}):tr(A)})().catch(T=>{if(u.delete(n),r==="image"&&g)return e.log.warn("Failed to fetch image base64, trying to use placeholder image",a),typeof g=="string"?g:g(o);throw T}),u.set(n,y);}return y.response}async function Ze(e,t,n,r){if(!Je(e))return e;for(let[i,o]of nr(e,t))try{let a=await X(n,{url:o,requestType:r?"image":"text",responseType:"dataUrl"});e=e.replace(rr(i),`$1${a}$3`);}catch(a){n.log.warn("Failed to fetch css data url",i,a);}return e}function Je(e){return /url\((['"]?)([^'"]+?)\1\)/.test(e)}var Qe=/url\((['"]?)([^'"]+?)\1\)/g;function nr(e,t){let n=[];return e.replace(Qe,(r,i,o)=>(n.push([o,Xe(o,t)]),r)),n.filter(([r])=>!le(r))}function rr(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}var or=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function ir(e,t){return or.map(n=>{let r=e.getPropertyValue(n);return !r||r==="none"?null:((J||de)&&t.drawImageCount++,Ze(r,null,t,true).then(i=>{!i||r===i||e.setProperty(n,i,e.getPropertyPriority(n));}))}).filter(Boolean)}function sr(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 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}`,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 et(e,t){let{tasks:n}=t;C(e)&&((D(e)||We(e))&&n.push(...sr(e,t)),pn(e)&&n.push(...ar(e,t))),B(e)&&n.push(...ir(e.style,t)),e.childNodes.forEach(r=>{et(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 l=Ue(s.cssText,t);r.appendChild(n.createTextNode(`${l}
|
|
10
|
+
`));}else {let l=Array.from(n.styleSheets).filter(g=>{try{return "cssRules"in g&&!!g.cssRules.length}catch(p){return t.log.warn(`Error while reading CSS rules from ${g.href}`,p),false}}),u=n.implementation.createHTMLDocument(""),c=u.createElement("style");u.head.appendChild(c);let f=c.sheet;await Promise.all(l.flatMap(g=>Array.from(g.cssRules).map(async p=>{if(mn(p)){let d=p.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 y=h.replace(Qe,(b,S,v)=>b.replace(v,Xe(v,d)));for(let b of ur(y))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(g=>{ue(g.cssRules,m);}),m.filter(g=>dn(g)&&Je(g.style.getPropertyValue("src"))&&Ge(g.style.getPropertyValue("font-family"))?.some(p=>i.has(p))).forEach(g=>{let p=g,d=o.get(p.cssText);d?r.appendChild(n.createTextNode(`${d}
|
|
11
|
+
`)):a.push(Ze(p.cssText,p.parentStyleSheet?p.parentStyleSheet.href:null,t).then(h=>{h=Ue(h,t),o.set(p.cssText,h),r.appendChild(n.createTextNode(`${h}
|
|
12
|
+
`));}));});}}var lr=/(\/\*[\s\S]*?\*\/)/g,$e=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function ur(e){if(e==null)return [];let t=[],n=e.replace(lr,"");for(;;){let o=$e.exec(n);if(!o)break;t.push(o[0]);}n=n.replace($e,"");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 fr=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,dr=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Ue(e,t){let{font:n}=t,r=n?n?.preferredFormat:void 0;return r?e.replace(dr,i=>{for(;;){let[o,,a]=fr.exec(i)||[];if(!a)return "";if(a===r)return `src: ${o};`}}):e}function ue(e,t=[]){for(let n of Array.from(e))gn(n)?t.push(...ue(n.cssRules)):"cssRules"in n?ue(n.cssRules,t):t.push(n);return t}var mr=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;function gr(e){return mr.test(e.innerHTML)}async function pr(e,t){let n=await qe(e,t);if(C(n.node)&&V(n.node)&&!gr(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:g,onCreateForeignObjectSvg:p}=n;i.time("clone node");let d=await me(n.node,n,true);if(a&&r){let v="";l.forEach((A,T)=>{v+=`${A.join(`,
|
|
13
|
+
`)} {
|
|
14
|
+
${T}
|
|
15
|
+
}
|
|
16
|
+
`;}),a.appendChild(r.createTextNode(v));}i.timeEnd("clone node"),await m?.(d),u!==false&&C(d)&&(i.time("embed web font"),await cr(d,n),i.timeEnd("embed web font")),i.time("embed node"),et(d,n);let h=o.length,y=0,b=async()=>{for(;;){let v=o.pop();if(!v)break;try{await v;}catch(A){n.log.warn("Failed to run task",A);}c?.(++y,h);}};c?.(y,h),await Promise.all([...Array.from({length:4})].map(b)),i.timeEnd("embed node"),await g?.(d);let S=hr(d,n);return s&&S.insertBefore(s,S.children[0]),a&&S.insertBefore(a,S.children[0]),f&&er(n),await p?.(S),S}function hr(e,t){let{width:n,height:r}=t,i=_n(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 tt(e,t){let n=await qe(e,t),r=await pr(n),i=In(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 On(o,n)}var wr=.25,Er=160,yr=28,br=1600,Sr=1200,Tr=2,vr=26e5,Ar=36e5,Cr=8e3,Rr=[/[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],rt="[masked]",xr="#f04e23";function ge(e){let t=e;for(let n of Rr)n.lastIndex=0,t=t.replace(n,rt);return t}function nt(e){return Math.min(Math.max(e*wr,yr),Er)}function _r(e,t,n){let r=nt(e.width),i=nt(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,br),c=Math.min(l-a,Sr);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 Ir(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 Nr(e){return !(e instanceof Element&&e.hasAttribute(k))}function kr(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=ge(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(Ir(a)){let s=a instanceof HTMLInputElement&&a.type==="password",l=a.getAttribute("value")??a.value??"",u=s&&l?rt:ge(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",ge(c));}}o=r.nextNode();}for(let a of i)a.parentNode?.removeChild(a);}function Lr(e,t,n,r){e.save(),e.strokeStyle=xr,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 Pr(e,t){let n=Math.min(e.devicePixelRatio||1,Tr),r=t.width*t.height;return r<=0?1:Math.max(.5,Math.min(n,Math.sqrt(vr/r)))}function Dr(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 ot(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=_r(i,n.innerWidth,n.innerHeight);if(o.width<=0||o.height<=0)return null;let a=Pr(n,o),s=-(o.left+(n.scrollX||0)),l=-(o.top+(n.scrollY||0)),u=await tt(t.documentElement,{width:o.width,height:o.height,scale:a,backgroundColor:"#ffffff",timeout:Cr,filter:Nr,onCloneNode:m=>{kr(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;Lr(c,i,o,a);let f=u.toDataURL("image/png");if(f.length>Ar){let m=Dr(u,t);if(!m)return null;f=m.toDataURL("image/png");}return f}catch{return null}}var Mr="arcy-picker",R="arcy-picker-banner",st="arcy-picker-highlight",Fr=`
|
|
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
|
+
.${st} {
|
|
57
|
+
border-radius: 3px;
|
|
58
|
+
}
|
|
59
|
+
`;function it(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 Or=[["box-sizing","border-box"],["border","2px solid #f04e23"],["background","rgba(240, 78, 35, 0.08)"]],$r=[["left","50%"],["bottom","24px"]],Ur=[["transform","translateX(-50%)"]];function Hr(e){let{text:t,tag:n}=e.core;return t?`Sent "${t}" to ARCY`:`Sent <${n}> to ARCY`}function at(e){let t=Le({id:Mr});if(!t)return null;let n=t.host.ownerDocument,r="pick",i=false,o=null,a=0;Pe(t,Fr);let s=n.createElement("div");s.className=st,it(s,"none");for(let[w,E]of Or)s.style.setProperty(w,E);d();let l=n.createElement("div");l.className=R,it(l,"auto",$r);for(let[w,E]of Ur)l.style.setProperty(w,E);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 g=n.createElement("button");g.type="button",g.textContent="Exit",l.append(u,c,f,m,g),t.root.append(s,l);function p(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 E=w.getBoundingClientRect();if(E.width===0&&E.height===0){d();return}s.style.setProperty("left",`${E.left}px`,"important"),s.style.setProperty("top",`${E.top}px`,"important"),s.style.setProperty("width",`${E.width}px`,"important"),s.style.setProperty("height",`${E.height}px`,"important"),s.style.setProperty("display","block","important");}catch{d();}}function y(w){return w instanceof Element&&Te(w,`[${k}]`)!==null}function b(w){if(typeof w.composedPath=="function"){let E=w.composedPath();if(E.length>0)return E[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 E=b(w);if(y(E)||!(E instanceof Element)){o=null,d();return}o=ie(E),h(o);}catch{}},A=()=>{try{if(S()||r!=="pick")return;o&&o.isConnected?h(o):d();}catch{}},T=w=>{try{if(S()||r!=="pick"||y(b(w)))return;w.preventDefault(),w.stopPropagation(),w.stopImmediatePropagation();}catch{}},I=w=>{try{if(S()||r!=="pick")return;let E=b(w);if(y(E)||(w.preventDefault(),w.stopPropagation(),w.stopImmediatePropagation(),!(E instanceof Element)))return;let M=ie(E),F=Se(Y(M)),we=Ie(M);F.selector=we.autoSelector,F.selectorCandidates=we.candidates,m.textContent=Hr(F),o=M,h(M);let Ee=0;try{Ee=xe(F,n).matchCount;}catch{}if(e.onPick(F,Ee),e.screenshotsEnabled===!1)return;let ct=++a;ot(M).then(ye=>{if(!(!ye||i||ct!==a))try{e.onScreenshot?.(ye);}catch{}});}catch(E){x(`The element picker could not read that element. ${String(E)}`);}};function G(w){if(!(w instanceof Element))return false;let E=w.tagName;return E==="INPUT"||E==="TEXTAREA"||E==="SELECT"?true:w.isContentEditable===true}let pe=w=>{try{if(S())return;let E=w;if(!E.altKey||E.code!=="KeyS"&&E.key.toLowerCase()!=="s"||G(b(E)))return;E.preventDefault(),p(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",pe,!0),n.defaultView?.removeEventListener("scroll",A,!0),n.defaultView?.removeEventListener("resize",A);}catch{}t?.destroy(),t=null;}}let he=w=>{try{w.preventDefault();}catch{}};return l.addEventListener("pointerdown",he),l.addEventListener("mousedown",he),c.addEventListener("click",()=>p("pick")),f.addEventListener("click",()=>p("browse")),g.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",pe,true),n.defaultView?.addEventListener("scroll",A,true),n.defaultView?.addEventListener("resize",A),p("pick"),{destroy:ne}}var Wr={contract:2,mount:e=>{try{return at(e)}catch{return null}}};if(typeof window<"u")try{window[be]=Wr;}catch{}})();
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* arcy.js — https://arcyai.com */
|
|
4
|
+
|
|
5
|
+
// src/fingerprint/model.ts
|
|
6
|
+
var FINGERPRINT_TEXT_MAX = 80;
|
|
7
|
+
var SELECTOR_CANDIDATES_MAX = 5;
|
|
8
|
+
|
|
9
|
+
// src/fingerprint/capture.ts
|
|
10
|
+
var MASK = "[masked]";
|
|
11
|
+
|
|
12
|
+
// src/picker/message.ts
|
|
13
|
+
var DESIGN_MODE_PROTOCOL = 2;
|
|
14
|
+
var DESIGN_MODE_READY = "arcy:design-mode:ready";
|
|
15
|
+
var DESIGN_MODE_PICK = "arcy:design-mode:pick";
|
|
16
|
+
var DESIGN_MODE_EXIT = "arcy:design-mode:exit";
|
|
17
|
+
var DESIGN_MODE_SCREENSHOT = "arcy:design-mode:screenshot";
|
|
18
|
+
var TAG_MAX = 64;
|
|
19
|
+
var ROUTE_MAX = 2048;
|
|
20
|
+
var SELECTOR_MAX = 512;
|
|
21
|
+
var ORDINAL_MAX = 1e4;
|
|
22
|
+
var SIBLING_INDEX_MAX = 1e5;
|
|
23
|
+
var SCREENSHOT_DATA_URL_MAX = 4e6;
|
|
24
|
+
var SCREENSHOT_PREFIX = "data:image/png;base64,";
|
|
25
|
+
var MATCH_COUNT_MAX = 1e6;
|
|
26
|
+
function isRecord(value) {
|
|
27
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28
|
+
}
|
|
29
|
+
function isBoundedString(value, max) {
|
|
30
|
+
return typeof value === "string" && value.length > 0 && value.length <= max;
|
|
31
|
+
}
|
|
32
|
+
function isOptionalBoundedString(value, max) {
|
|
33
|
+
return value === void 0 || isBoundedString(value, max);
|
|
34
|
+
}
|
|
35
|
+
function isBoundedInteger(value, min, max) {
|
|
36
|
+
return typeof value === "number" && Number.isInteger(value) && value >= min && value <= max;
|
|
37
|
+
}
|
|
38
|
+
function readCore(value) {
|
|
39
|
+
if (!isRecord(value)) return null;
|
|
40
|
+
if (!isBoundedString(value.tag, TAG_MAX)) return null;
|
|
41
|
+
if (!isBoundedInteger(value.siblingIndex, 0, SIBLING_INDEX_MAX)) return null;
|
|
42
|
+
const optional = [
|
|
43
|
+
"text",
|
|
44
|
+
"ariaLabel",
|
|
45
|
+
"placeholder",
|
|
46
|
+
"id",
|
|
47
|
+
"role",
|
|
48
|
+
"testId",
|
|
49
|
+
"ancestorTag",
|
|
50
|
+
"ancestorAttr",
|
|
51
|
+
"ancestorValue"
|
|
52
|
+
];
|
|
53
|
+
for (const key of optional) {
|
|
54
|
+
if (!isOptionalBoundedString(value[key], FINGERPRINT_TEXT_MAX)) return null;
|
|
55
|
+
}
|
|
56
|
+
const core = {
|
|
57
|
+
tag: value.tag,
|
|
58
|
+
siblingIndex: value.siblingIndex
|
|
59
|
+
};
|
|
60
|
+
for (const key of optional) {
|
|
61
|
+
const field = value[key];
|
|
62
|
+
if (typeof field === "string") core[key] = field;
|
|
63
|
+
}
|
|
64
|
+
return core;
|
|
65
|
+
}
|
|
66
|
+
function readTarget(value) {
|
|
67
|
+
if (!isRecord(value)) return null;
|
|
68
|
+
if (value.v !== 1) return null;
|
|
69
|
+
const core = readCore(value.core);
|
|
70
|
+
if (!core) return null;
|
|
71
|
+
const { selector, selectorCandidates, ordinal, precision, dynamicText } = value;
|
|
72
|
+
if (selector !== null && !isBoundedString(selector, SELECTOR_MAX)) return null;
|
|
73
|
+
if (!Array.isArray(selectorCandidates)) return null;
|
|
74
|
+
if (selectorCandidates.length > SELECTOR_CANDIDATES_MAX) return null;
|
|
75
|
+
if (!selectorCandidates.every((c) => isBoundedString(c, SELECTOR_MAX)))
|
|
76
|
+
return null;
|
|
77
|
+
if (!isBoundedInteger(ordinal, 1, ORDINAL_MAX)) return null;
|
|
78
|
+
if (!isBoundedInteger(precision, 1, 5)) return null;
|
|
79
|
+
if (typeof dynamicText !== "boolean") return null;
|
|
80
|
+
return {
|
|
81
|
+
v: 1,
|
|
82
|
+
core,
|
|
83
|
+
selector,
|
|
84
|
+
selectorCandidates,
|
|
85
|
+
ordinal,
|
|
86
|
+
precision,
|
|
87
|
+
dynamicText
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function readDesignModeMessage(data) {
|
|
91
|
+
if (!isRecord(data)) return null;
|
|
92
|
+
if (data.protocol !== DESIGN_MODE_PROTOCOL) return null;
|
|
93
|
+
switch (data.type) {
|
|
94
|
+
case DESIGN_MODE_READY:
|
|
95
|
+
return { type: DESIGN_MODE_READY, protocol: DESIGN_MODE_PROTOCOL };
|
|
96
|
+
case DESIGN_MODE_EXIT:
|
|
97
|
+
return { type: DESIGN_MODE_EXIT, protocol: DESIGN_MODE_PROTOCOL };
|
|
98
|
+
case DESIGN_MODE_PICK: {
|
|
99
|
+
const target = readTarget(data.target);
|
|
100
|
+
if (!target) return null;
|
|
101
|
+
const { route, matchCount } = data;
|
|
102
|
+
if (!isBoundedString(route, ROUTE_MAX)) return null;
|
|
103
|
+
if (!route.startsWith("/")) return null;
|
|
104
|
+
if (route.startsWith("//")) return null;
|
|
105
|
+
if (!isBoundedInteger(matchCount, 0, MATCH_COUNT_MAX)) return null;
|
|
106
|
+
return {
|
|
107
|
+
type: DESIGN_MODE_PICK,
|
|
108
|
+
protocol: DESIGN_MODE_PROTOCOL,
|
|
109
|
+
target,
|
|
110
|
+
route,
|
|
111
|
+
matchCount
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
case DESIGN_MODE_SCREENSHOT: {
|
|
115
|
+
const { screenshot } = data;
|
|
116
|
+
if (!isBoundedString(screenshot, SCREENSHOT_DATA_URL_MAX)) return null;
|
|
117
|
+
if (!screenshot.startsWith(SCREENSHOT_PREFIX)) return null;
|
|
118
|
+
return {
|
|
119
|
+
type: DESIGN_MODE_SCREENSHOT,
|
|
120
|
+
protocol: DESIGN_MODE_PROTOCOL,
|
|
121
|
+
screenshot
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
default:
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
exports.DESIGN_MODE_EXIT = DESIGN_MODE_EXIT;
|
|
130
|
+
exports.DESIGN_MODE_PICK = DESIGN_MODE_PICK;
|
|
131
|
+
exports.DESIGN_MODE_PROTOCOL = DESIGN_MODE_PROTOCOL;
|
|
132
|
+
exports.DESIGN_MODE_READY = DESIGN_MODE_READY;
|
|
133
|
+
exports.DESIGN_MODE_SCREENSHOT = DESIGN_MODE_SCREENSHOT;
|
|
134
|
+
exports.MASK = MASK;
|
|
135
|
+
exports.readDesignModeMessage = readDesignModeMessage;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The thin identity core: the fields an interaction event carries in
|
|
3
|
+
* `payload.fingerprint`, and the fields the backend hashes into
|
|
4
|
+
* `fingerprint_key` (sorted keys, canonical JSON, SHA-256; slice 19.0).
|
|
5
|
+
*
|
|
6
|
+
* This shape is a cross-repo contract, not a convenience type. The same
|
|
7
|
+
* object is captured in two places, by 7.3's collector on every interactive
|
|
8
|
+
* click and by the design-mode picker (15.4) when an operator selects an
|
|
9
|
+
* element, and the two must produce byte-identical JSON for the same element
|
|
10
|
+
* or match counts (15.9), the observed-element list (D180), and the
|
|
11
|
+
* fingerprint-confidence stats silently read zero. Three rules keep the hash
|
|
12
|
+
* stable, enforced by the golden-vector parity tests:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Flat.** `computeFingerprintKey` sorts only top-level keys, so a nested
|
|
15
|
+
* object would hash in whatever insertion order the client used. The
|
|
16
|
+
* semantic ancestor is three flat fields for exactly this reason.
|
|
17
|
+
* 2. **Absent keys are omitted, never `null` or `undefined`.**
|
|
18
|
+
* `JSON.stringify` drops `undefined` properties but keeps `null` ones, so
|
|
19
|
+
* the two spellings of "no value" would hash differently. There is one
|
|
20
|
+
* spelling: the key does not appear.
|
|
21
|
+
* 3. **No raw class string, anywhere.** G5 (PRODUCT_SCOPE §6.2.5.1.1): on a
|
|
22
|
+
* Tailwind app a class string is a presentational sentence that changes
|
|
23
|
+
* when a designer touches padding. Classes enter the system only through
|
|
24
|
+
* the ranked selector generator (15.2), after utility suppression.
|
|
25
|
+
*
|
|
26
|
+
* Changing this field set orphans every stored `fingerprint_key`. It is a
|
|
27
|
+
* migration, not an edit (see ADR 0059).
|
|
28
|
+
*/
|
|
29
|
+
interface EventFingerprint {
|
|
30
|
+
/** Lowercase tag name. The one field that is always present. */
|
|
31
|
+
tag: string;
|
|
32
|
+
/** Subtree text, whitespace-collapsed, PII-masked, capped. Primary matcher. */
|
|
33
|
+
text?: string;
|
|
34
|
+
/** The icon-only control's signal; masked and capped like text. */
|
|
35
|
+
ariaLabel?: string;
|
|
36
|
+
/** Form controls have no textContent; their placeholder stands in. */
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The element's own id, only when it looks author-written. Generated ids
|
|
40
|
+
* (React useId's `:r3:`, Radix) change per render and would fragment the
|
|
41
|
+
* key, turning one button into a new "element" every session.
|
|
42
|
+
*/
|
|
43
|
+
id?: string;
|
|
44
|
+
/** The explicit `role` attribute. No implicit-role table: not worth its bytes. */
|
|
45
|
+
role?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The element's own `data-testid`, `data-test`, or `data-cy`, first one
|
|
48
|
+
* present (ADR 0134). The strongest evidence a page can offer that two
|
|
49
|
+
* elements are the same element: it is written by a developer to be stable
|
|
50
|
+
* and survives a redesign, a copy edit, and a locale switch at once.
|
|
51
|
+
*
|
|
52
|
+
* Read from the element itself, unlike `ancestorAttr`/`ancestorValue`,
|
|
53
|
+
* which report the same attributes found on an ancestor. Absent on most
|
|
54
|
+
* elements, and absence is spelled the way every optional field here is
|
|
55
|
+
* spelled: the key does not appear.
|
|
56
|
+
*/
|
|
57
|
+
testId?: string;
|
|
58
|
+
/** 0-based index among same-tag element siblings. The structural tiebreak. */
|
|
59
|
+
siblingIndex: number;
|
|
60
|
+
/** Nearest ancestor carrying a semantic identifier, as three flat fields. */
|
|
61
|
+
ancestorTag?: string;
|
|
62
|
+
/** Which attribute won the ancestor walk (e.g. "data-testid", "id"). */
|
|
63
|
+
ancestorAttr?: string;
|
|
64
|
+
/** That attribute's value, masked and capped like text. */
|
|
65
|
+
ancestorValue?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* How strictly the runtime matcher (15.3) scores candidates. A discrete step,
|
|
69
|
+
* not a float: the mapping from step to score threshold lives in the matcher,
|
|
70
|
+
* so tuning the scoring function never migrates stored targets. 1 is loosest,
|
|
71
|
+
* 5 is strictest. The slider help text is the workflow: loosen when the
|
|
72
|
+
* element is not found, tighten when the wrong element is found.
|
|
73
|
+
*/
|
|
74
|
+
type Precision = 1 | 2 | 3 | 4 | 5;
|
|
75
|
+
/**
|
|
76
|
+
* The full element target: the identity core plus the authoring layer an
|
|
77
|
+
* operator sets in the picker (15.4) and edits in manual adjustment (15.9).
|
|
78
|
+
* Stored on a flow step, so this object outlives any single arcy.js version.
|
|
79
|
+
*/
|
|
80
|
+
interface TargetFingerprint {
|
|
81
|
+
/**
|
|
82
|
+
* Schema version. Durable data stored in customers' flows needs a
|
|
83
|
+
* discriminant before a v2 exists, or the v2 migration has nothing to
|
|
84
|
+
* dispatch on. Bump only with a migration plan for stored targets.
|
|
85
|
+
*/
|
|
86
|
+
v: 1;
|
|
87
|
+
/**
|
|
88
|
+
* The identity core, embedded as-is and never spread flat. Everything that
|
|
89
|
+
* hashes or matches reads `target.core`, structurally the same object shape
|
|
90
|
+
* an event carries, so a field can never be forgotten in translation.
|
|
91
|
+
*/
|
|
92
|
+
core: EventFingerprint;
|
|
93
|
+
/**
|
|
94
|
+
* The active selector refinement. Default null (§6.2.5.1: the reference
|
|
95
|
+
* leads with text, not a selector, and that default is preserved). Never
|
|
96
|
+
* hand-authored; 15.2's generator is the only writer, and it writes only
|
|
97
|
+
* when the top-ranked candidate is top-two-tier and matches exactly one
|
|
98
|
+
* element at pick time (D318).
|
|
99
|
+
*/
|
|
100
|
+
selector: string | null;
|
|
101
|
+
/**
|
|
102
|
+
* Ranked stable-selector candidates captured at pick time by 15.2, shown
|
|
103
|
+
* read-only in manual adjustment as a diagnostic. Capped so a pathological
|
|
104
|
+
* page cannot bloat a stored target.
|
|
105
|
+
*/
|
|
106
|
+
selectorCandidates: string[];
|
|
107
|
+
/**
|
|
108
|
+
* 1-based position among document-ordered candidates that survive the
|
|
109
|
+
* precision threshold: "if multiple matches, select 1st element". Always
|
|
110
|
+
* present. This is the G5 policy reversal (D013): a human pointed at the
|
|
111
|
+
* element and set this, so ties take the ordinal, never refuse-to-guess.
|
|
112
|
+
*/
|
|
113
|
+
ordinal: number;
|
|
114
|
+
precision: Precision;
|
|
115
|
+
/**
|
|
116
|
+
* Marks text as changing at runtime ("3 items in cart"), so the matcher
|
|
117
|
+
* down-weights text rather than treating its mismatch as disqualifying.
|
|
118
|
+
*/
|
|
119
|
+
dynamicText: boolean;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** The one masking token. Exported because the matcher (15.3) must treat it
|
|
123
|
+
* as an absent signal rather than a value: every masked email collapses to
|
|
124
|
+
* this same string, so scoring it as text would make any PII match any
|
|
125
|
+
* other PII exactly. */
|
|
126
|
+
declare const MASK = "[masked]";
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Bumped whenever a message shape changes incompatibly. A receiver that reads
|
|
130
|
+
* a number it does not speak refuses and says so, rather than guessing at a
|
|
131
|
+
* payload it half understands (the same posture ADR 0069 took for loading).
|
|
132
|
+
*/
|
|
133
|
+
declare const DESIGN_MODE_PROTOCOL = 2;
|
|
134
|
+
/** Posted once, when the overlay has mounted and the operator can click. */
|
|
135
|
+
declare const DESIGN_MODE_READY = "arcy:design-mode:ready";
|
|
136
|
+
/** Posted for every pick. The last one wins; there is no confirm (D502). */
|
|
137
|
+
declare const DESIGN_MODE_PICK = "arcy:design-mode:pick";
|
|
138
|
+
/** Posted when the operator leaves design mode. */
|
|
139
|
+
declare const DESIGN_MODE_EXIT = "arcy:design-mode:exit";
|
|
140
|
+
/**
|
|
141
|
+
* Posted once per pick, asynchronously, after rasterization finishes
|
|
142
|
+
* (15.7). Never gates `DESIGN_MODE_PICK`'s own delivery (D502): a receiver
|
|
143
|
+
* that has not built `DESIGN_MODE_SCREENSHOT` into its `switch` simply drops
|
|
144
|
+
* it via the same unknown-`type` path every other unrecognized message takes,
|
|
145
|
+
* so this needed no `DESIGN_MODE_PROTOCOL` bump to add.
|
|
146
|
+
*/
|
|
147
|
+
declare const DESIGN_MODE_SCREENSHOT = "arcy:design-mode:screenshot";
|
|
148
|
+
interface DesignModeReady {
|
|
149
|
+
type: typeof DESIGN_MODE_READY;
|
|
150
|
+
protocol: number;
|
|
151
|
+
}
|
|
152
|
+
interface DesignModePick {
|
|
153
|
+
type: typeof DESIGN_MODE_PICK;
|
|
154
|
+
protocol: number;
|
|
155
|
+
target: TargetFingerprint;
|
|
156
|
+
/**
|
|
157
|
+
* The path the element was picked on, read at pick time (D504). A target
|
|
158
|
+
* and the page it lives on are stored as two separate fields on a step, and
|
|
159
|
+
* browse mode means the operator can be somewhere else by the time they
|
|
160
|
+
* pick. Without this the step would keep whichever page was chosen in the
|
|
161
|
+
* dropdown, and a target filed under the wrong page reports zero forever.
|
|
162
|
+
*/
|
|
163
|
+
route: string;
|
|
164
|
+
/**
|
|
165
|
+
* How many elements on this page matched the target at the moment it was
|
|
166
|
+
* picked (ADR 0132). Scored here, where the live document and the matcher
|
|
167
|
+
* both already are, rather than asked for afterwards over a channel to a tab
|
|
168
|
+
* the pick is about to close.
|
|
169
|
+
*
|
|
170
|
+
* Information for the operator, never a gate: zero and forty are both real
|
|
171
|
+
* answers worth showing, and neither is a reason to refuse a save.
|
|
172
|
+
*/
|
|
173
|
+
matchCount: number;
|
|
174
|
+
}
|
|
175
|
+
interface DesignModeExit {
|
|
176
|
+
type: typeof DESIGN_MODE_EXIT;
|
|
177
|
+
protocol: number;
|
|
178
|
+
}
|
|
179
|
+
interface DesignModeScreenshot {
|
|
180
|
+
type: typeof DESIGN_MODE_SCREENSHOT;
|
|
181
|
+
protocol: number;
|
|
182
|
+
/** A `data:image/png;base64,...` artifact of the most recently picked
|
|
183
|
+
* element. Last one wins, same as the pick it decorates: a receiver simply
|
|
184
|
+
* overwrites whatever it is holding. */
|
|
185
|
+
screenshot: string;
|
|
186
|
+
}
|
|
187
|
+
type DesignModeMessage = DesignModeReady | DesignModePick | DesignModeExit | DesignModeScreenshot;
|
|
188
|
+
/**
|
|
189
|
+
* The receiver's only entry point: turns `event.data` into a message it can
|
|
190
|
+
* act on, or null. Says nothing about *who* sent it. The other two checks
|
|
191
|
+
* D501 requires, the source window and the origin, belong to the receiver,
|
|
192
|
+
* because only it knows which window it opened and which environment it is
|
|
193
|
+
* authoring in.
|
|
194
|
+
*/
|
|
195
|
+
declare function readDesignModeMessage(data: unknown): DesignModeMessage | null;
|
|
196
|
+
|
|
197
|
+
export { DESIGN_MODE_EXIT, DESIGN_MODE_PICK, DESIGN_MODE_PROTOCOL, DESIGN_MODE_READY, DESIGN_MODE_SCREENSHOT, type DesignModeExit, type DesignModeMessage, type DesignModePick, type DesignModeReady, type DesignModeScreenshot, MASK, readDesignModeMessage };
|