@ctrl/dom 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aria/_chunks/roles-list-B0OTIKQA.js +4 -0
- package/dist/aria/_chunks/roles-list-CkmykU-H.cjs +4 -0
- package/dist/aria/index.cjs +1 -1
- package/dist/aria/index.js +1 -1
- package/dist/aria/internal.cjs +1 -1
- package/dist/aria/internal.js +1 -1
- package/dist/aria/types/forms.d.ts +5 -0
- package/dist/aria/types/internal.d.ts +2 -2
- package/dist/aria/types/role.d.ts +8 -1
- package/dist/bridge/internal.js +1 -1
- package/dist/dom/_chunks/src-BbkJRbbx.js +49 -0
- package/dist/dom/index.js +1 -1
- package/dist/dom/internal.js +1 -1
- package/dist/dom/types/css/CSSStyleDeclaration.d.ts +10 -1
- package/dist/dom/types/css/cascade.d.ts +14 -4
- package/dist/dom/types/css/declarations.d.ts +5 -0
- package/dist/dom/types/css/internal.d.ts +1 -1
- package/dist/dom/types/events/listeners.d.ts +8 -1
- package/dist/dom/types/internal.d.ts +1 -1
- package/dist/dom/types/nodes/attributes.d.ts +4 -0
- package/dist/dom/types/nodes/cache.d.ts +5 -1
- package/dist/dom/types/nodes/constants.d.ts +8 -0
- package/dist/dom/types/selectors/filter.d.ts +5 -3
- package/dist/dom/types/window/clock.d.ts +5 -1
- package/dist/dom/types/window/compat.d.ts +3 -1
- package/dist/dom/types/window/geometry.d.ts +3 -9
- package/dist/jest-dom/_chunks/{matchers-CGTk9GX9.cjs → matchers-CkxM783o.cjs} +1 -1
- package/dist/jest-dom/_chunks/{matchers-Chf0yHoo.js → matchers-Dt7W4g5X.js} +1 -1
- package/dist/jest-dom/index.cjs +1 -1
- package/dist/jest-dom/index.js +1 -1
- package/dist/jest-dom/jest-globals.cjs +1 -1
- package/dist/jest-dom/jest-globals.js +1 -1
- package/dist/jest-dom/matchers.cjs +1 -1
- package/dist/jest-dom/matchers.js +1 -1
- package/dist/jest-dom/vitest.cjs +1 -1
- package/dist/jest-dom/vitest.js +1 -1
- package/dist/react/_chunks/{pure-DQzwul4s.cjs → pure-DR8LsIAA.cjs} +1 -1
- package/dist/react/_chunks/{pure-CCeTO5Mk.js → pure-ajnRI-Fp.js} +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/pure.cjs +1 -1
- package/dist/react/pure.js +1 -1
- package/dist/testing-library/_chunks/aria-snapshot-diff-BXYf4D_D.cjs +14 -0
- package/dist/testing-library/_chunks/aria-snapshot-diff-DejA3Rdn.js +14 -0
- package/dist/testing-library/agent.cjs +1 -1
- package/dist/testing-library/agent.js +1 -1
- package/dist/testing-library/index.cjs +5 -5
- package/dist/testing-library/index.js +8 -8
- package/dist/testing-library/types/pretty-dom.d.ts +2 -1
- package/dist/testing-library/types/pretty-format.d.ts +125 -0
- package/dist/testing-library/types/screen.d.ts +2 -1
- package/dist/user-event/index.cjs +15 -15
- package/dist/user-event/index.js +15 -15
- package/dist/user-event/types/setup/setup.d.ts +12 -2
- package/dist/user-event/types/system/pointer/mouse.d.ts +0 -3
- package/dist/vitest-environment/index.js +1 -1
- package/package.json +6 -4
- package/dist/aria/_chunks/roles-list-BXCvPLJT.cjs +0 -4
- package/dist/aria/_chunks/roles-list-rVVxaIPs.js +0 -4
- package/dist/dom/_chunks/src-sZY6a2LC.js +0 -49
- package/dist/testing-library/_chunks/aria-snapshot-diff--o7AL030.cjs +0 -14
- package/dist/testing-library/_chunks/aria-snapshot-diff-BV9IkeNc.js +0 -14
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
var e=Object.defineProperty,__name=(t,n)=>e(t,`name`,{value:n,configurable:!0}),__exportAll=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};let t=require("@ctrl/dom/internal"),n=require("node:module"),r=require("node:fs"),i=require("@ctrl/dom/aria"),a=require("@ctrl/dom/aria/internal");const o=new URL(`./`,require("url").pathToFileURL(__filename).href).pathname;let s;function loadDeps(){if(s!==void 0)return s;try{let e=(0,n.createRequire)(require("url").pathToFileURL(__filename).href);s={codeFrameColumns:e(`@babel/code-frame`).codeFrameColumns,picocolors:e(`picocolors`)}}catch{s=null}return s}function getCodeFrame(e){let{codeFrameColumns:t,picocolors:n}=loadDeps(),i=e.indexOf(`(`)+1,a=e.indexOf(`)`),o=e.slice(i,a),s=o.split(`:`),[c,l,u]=[s[0],parseInt(s[1],10),parseInt(s[2],10)],d=``;try{d=(0,r.readFileSync)(c,`utf-8`)}catch{return``}let f=t(d,{start:{line:l,column:u-1}},{highlightCode:!0,linesBelow:0});return`${n.dim(o)}\n${f}\n`}function getUserCodeFrame(){let e=loadDeps();return!e||!r.readFileSync||!e.codeFrameColumns?``:getCodeFrame((/* @__PURE__ */ Error()).stack.split(`
|
|
2
|
-
`).slice(1).find(e=>!e.includes(`node_modules/`)&&!e.includes(o)))}function jestFakeTimersAreEnabled(){if(typeof jest<`u`&&jest!==null)return setTimeout._isMockFunction===!0||Object.hasOwn(setTimeout,`clock`);let e=setTimeout.clock;return e!=null&&typeof e.tick==`function`}function advanceFakeTimersByTime(e){if(typeof jest<`u`&&jest!==null){jest.advanceTimersByTime(e);return}let t=globalThis.vi;t!=null&&typeof t.advanceTimersByTime==`function`&&typeof t.isFakeTimers==`function`&&t.isFakeTimers()?t.advanceTimersByTime(e):setTimeout.clock.tick(e)}function getDocument(){if(typeof window>`u`)throw Error(`Could not find default container`);return window.document}function getWindowFromNode(e){if(e.defaultView)return e.defaultView;if(e.ownerDocument&&e.ownerDocument.defaultView)return e.ownerDocument.defaultView;if(e.window)return e.window;throw e.ownerDocument&&e.ownerDocument.defaultView===null?Error(`It looks like the window object is not available for the provided node.`):e.then instanceof Function?Error("It looks like you passed a Promise object instead of a DOM node. Did you do something like `fireEvent.click(screen.findBy...` when you meant to use a `getBy` query `fireEvent.click(screen.getBy...`, or await the findBy query `fireEvent.click(await screen.findBy...`?"):Array.isArray(e)?Error("It looks like you passed an Array instead of a DOM node. Did you do something like `fireEvent.click(screen.getAllBy...` when you meant to use a `getBy` query `fireEvent.click(screen.getBy...`?"):typeof e.debug==`function`&&typeof e.logTestingPlaygroundURL==`function`?Error("It looks like you passed a `screen` object. Did you do something like `fireEvent.click(screen, ...` when you meant to use a query, e.g. `fireEvent.click(screen.getBy..., `?"):Error(`The given node is not an Element, the node type is: ${typeof e}.`)}function checkContainerType(e){if(!e||typeof e.querySelector!=`function`||typeof e.querySelectorAll!=`function`)throw TypeError(`Expected container to be an Element, a Document or a DocumentFragment but got ${getTypeName(e)}.`)}function getTypeName(e){return typeof e==`object`?e===null?`null`:e.constructor.name:typeof e}function implOf(e){let n=e[t.$impl];if(n===void 0)throw TypeError(`@ctrl/dom/testing-library requires nodes created by @ctrl/dom.`);return n}function matchesSelector(e,n){return e.type===t.ELEMENT_NODE&&(0,t.matches)(e,n)}function envDebugFormat(){let e=typeof process<`u`?process.env?.CTRL_DOM_DEBUG:void 0;if(e===void 0||e===``)return null;let t=String(e).trim().toLowerCase();return t===`aria`?`aria`:t===`compact`||t===`html`?`compact`:null}function containerLabel(e){let n=e?.[t.$impl];return n===void 0?`the container`:n.type===9?`the document`:describeElement(n)}function agentErrorContext(e,t,n){return t===`aria`?`Accessibility snapshot of ${containerLabel(e)} (CTRL_DOM_DEBUG=aria):\n${ariaSnapshot(e,{maxLines:envMaxLines()??100})}`:`DOM of ${containerLabel(e)} without class/style/SVG internals (CTRL_DOM_DEBUG=compact):\n${n(e,void 0,{format:`compact`})}`}function agentElementSummary(e){return ariaSnapshot(e,{maxLines:12})}function envMaxLines(){let e=typeof process<`u`?process.env?.CTRL_DOM_DEBUG_LINES:void 0,t=e?Number(e):NaN;return t>0?t:void 0}function ariaSnapshot(e,t={}){let{header:n,lines:r,empty:i}=ariaSnapshotLines(e,t);return i===null?n+budgetLines(r,t.maxLines??envMaxLines()??200).join(`
|
|
3
|
-
`):n+i}(0,t.setFailureSnapshot)(e=>ariaSnapshot(e,{maxLines:2e3}));function buildTree(e,n){let r=rootImpl(e),i=new SnapshotContext(r,n),o=[],s=``;return!i.includeHidden&&r.type===t.ELEMENT_NODE&&(0,a.isInaccessibleImpl)(r)&&(s=`# hidden from the accessibility tree: ${hiddenReason(r)}\n`,i.includeHidden=!0,i.forceHidden=!0),r.type===t.ELEMENT_NODE&&r!==bodyOf(r)?i.visitElement(r,o,i.forceHidden):i.visitChildren(r,o,!1,!1),finishChildren(o,null),{root:r,ctx:i,children:o,header:s}}function ariaSnapshotTree(e,t={}){return buildTree(e,t).children}function ariaSnapshotLines(e,t={}){let{root:n,ctx:r,children:i,header:a}=buildTree(e,t),o=[];r.renderList(i,``,o);let s=o.length>0?null:r.sawHidden?`# no accessible content (hidden elements exist: pass { hidden: true })`:`# no accessible content`;return n===bodyOf(n)&&envDebugFormat()!==null&&recordBodySnapshot(n.doc,s??o.join(`
|
|
4
|
-
`)),{header:a,lines:o,empty:s}}function budgetLines(e,t){if(e.length<=t)return e;let n=e.length-t,r=e.slice(0,t);return r.push(`# … ${n} more line${n===1?``:`s`} (raise maxLines or CTRL_DOM_DEBUG_LINES)`),r}const c=Symbol.for(`ctrl-dom.agent.lastBodySnapshot`);function recordBodySnapshot(e,t){e!=null&&Object.defineProperty(e,c,{value:t,configurable:!0,writable:!0,enumerable:!1})}function lastBodySnapshot(e){return e?.[c]}function resetBodySnapshot(e){e!=null&&Object.hasOwn(e,c)&&delete e[c]}function rootImpl(e){let n=e??getDocument().body,r=n?.[t.$impl];if(r===void 0)throw TypeError(`Expected an element, document or fragment but got ${n===null?`null`:typeof n}`);if(r.type===t.DOCUMENT_NODE||r.tag===t.T.html&&r.ns===t.HTML_NS){let e=r.doc?.body;return e?e[t.$impl]:r}return r}function bodyOf(e){let n=e.doc?.body;return n?n[t.$impl]:null}function normalizeSpace(e){return e.replace(/[\t\n\f\r ]+/g,` `)}function truncate(e,t){return e.length>t?e.slice(0,Math.max(1,t-1))+`…`:e}function quote(e){return JSON.stringify(e)}const l=/^$|^[\s\-?:,[\]{}#&*!|>'"%@`]|[\s]$|:$|: | #|^(true|false|null|yes|no|on|off|~)$|^[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i;function yamlValue(e){return l.test(e)?quote(e):e}function nodeKey(e,t){let n=e.role;e.name!==``&&(n+=` `+quote(truncate(e.name,t)));for(let t=0;t<e.props.length;t++)n+=` `+e.props[t];return n}function describeElement(e){let n=e.name;if(e.id!==``)return`<${n} id="${e.id}">`;let r=(0,t.attr)(e,`data-testid`);return r===null?`<${n}>`:`<${n} data-testid="${r}">`}function hiddenReason(e){let t=hiddenChainReason(e);return t===``?(0,a.isVisibilityHidden)(e)?`visibility: hidden on ${describeElement(e)}`:``:t}function hiddenChainReason(e){for(let n=e;n!==null&&n.type===t.ELEMENT_NODE;n=n.parent){if(n.ns===t.HTML_NS&&(0,t.attr)(n,`hidden`)!==null)return`hidden attribute on ${describeElement(n)}`;if((0,t.attr)(n,`aria-hidden`)===`true`)return`aria-hidden="true" on ${describeElement(n)}`;if((0,a.isDisplayNone)(n))return`display: none on ${describeElement(n)}`}return``}const u=/* @__PURE__ */ new Set([``,`generic`,`none`,`presentation`]);function isSkippedTag(e){if(e.ns!==t.HTML_NS)return!1;switch(e.tag){case t.T.script:case t.T.style:case t.T.template:case t.T.noscript:case t.T.head:return!0}return!1}function nodeProps(e,t,n,r){let o=[];if((0,i.roleSupportsProp)(t,`aria-checked`)){let t=(0,a.ariaCheckedState)(e);t===!0?o.push(`[checked]`):t===`mixed`&&o.push(`[checked=mixed]`)}(0,a.isDisabledImpl)(e)&&o.push(`[disabled]`);let s=(0,a.computeAriaExpanded)(e);s===!0?o.push(`[expanded]`):s===!1&&o.push(`[expanded=false]`),n&&o.push(`[active]`);let c=t===`heading`?(0,a.computeHeadingLevel)(e):levelAttr(e);c!==void 0&&o.push(`[level=${c}]`);let l=(0,a.ariaPressedState)(e);l===!0?o.push(`[pressed]`):l===`mixed`?o.push(`[pressed=mixed]`):l===!1&&o.push(`[pressed=false]`),(0,a.computeAriaSelected)(e)===!0&&o.push(`[selected]`);let u=(0,a.computeAriaCurrent)(e);return u===!0?o.push(`[current]`):typeof u==`string`&&u!==``&&o.push(`[current=${u}]`),(0,a.computeAriaBusy)(e)&&o.push(`[busy]`),r&&o.push(`[hidden]`),o}function levelAttr(e){let n=(0,t.attr)(e,`aria-level`),r=n===null?NaN:Number(n);return r>0?r:void 0}const d=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`spinbutton`,`slider`,`progressbar`,`meter`,`scrollbar`,`separator`]);function nodeValue(e,n){if(!d.has(n))return null;let r=(0,t.attr)(e,`aria-valuetext`);if(r!==null)return r;let i=(0,t.attr)(e,`aria-valuenow`);if(i!==null)return i;if(e.ns!==t.HTML_NS)return null;if(e.tag===t.T.input||e.tag===t.T.textarea){let t=String(e.node.value??``);return t===``?null:t}return null}var SnapshotContext=class{includeHidden;forceHidden=!1;sawHidden=!1;maxText;collapseAfter;urls;active;constructor(e,n){this.includeHidden=n.hidden===!0,this.maxText=n.maxTextLength??100,this.collapseAfter=n.collapseAfter??5,this.urls=n.urls===!0;let r=e.doc?.activeElement,i=r?r[t.$impl]??null:null;this.active=i!==null&&i===bodyOf(e)?null:i}visitChildren(e,n,r,i){for(let a=e.first;a!==null;a=a.next)a.type===t.TEXT_NODE?i||appendText(n,a.data):a.type===t.ELEMENT_NODE?this.visitElement(a,n,r):a.type===t.DOCUMENT_FRAGMENT_NODE&&this.visitChildren(a,n,r,i)}visitElement(e,n,r){if(isSkippedTag(e))return;let i=r;if(!i&&(0,a.isSubtreeInaccessibleImpl)(e)){if(this.sawHidden=!0,!this.includeHidden)return;i=!0}let o=i;if(!i&&(0,a.isVisibilityHidden)(e)){if(this.sawHidden=!0,!this.includeHidden){this.visitChildren(e,n,!1,!0);return}o=!0}let s=(0,a.tlRole)(e);if(u.has(s)){let t=!(0,a.isDisplayInline)(e);t&&appendBreak(n),this.visitChildren(e,n,i,!1),t&&appendBreak(n);return}let c={role:s,name:normalizeSpace((0,a.computeAccessibleNameImpl)(e,void 0,5)).trim(),props:nodeProps(e,s,e===this.active,o&&this.includeHidden),value:nodeValue(e,s),url:null,children:[],element:e};this.urls&&s===`link`&&(c.url=(0,t.attr)(e,`href`)),(e.ns!==t.HTML_NS||e.tag!==t.T.textarea)&&this.visitChildren(e,c.children,i,!1),finishChildren(c.children,c.name),n.push(c)}renderList(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(typeof i==`string`){n.push(`${t}- text: ${yamlValue(truncate(i,this.maxText))}`);continue}let a=1;for(;r+a<e.length&&typeof e[r+a]!=`string`&&e[r+a].role===i.role;)a++;if(a>this.collapseAfter+1){for(let i=0;i<this.collapseAfter;i++)this.renderNode(e[r+i],t,n);n.push(`${t}- ${i.role} … (+${a-this.collapseAfter} more)`),r+=a-1}else this.renderNode(i,t,n)}}renderNode(e,t,n){let r=nodeKey(e,this.maxText),i=e.children;if(e.url===null&&(i.length===0||i.length===1&&typeof i[0]==`string`&&e.value===null)){let a=e.value??(i.length===1?i[0]:null);n.push(a===null?`${t}- ${r}`:`${t}- ${r}: ${yamlValue(truncate(a,this.maxText))}`);return}n.push(e.value===null?`${t}- ${r}:`:`${t}- ${r}: ${yamlValue(truncate(e.value,this.maxText))}`);let a=t+` `;e.url!==null&&n.push(`${a}- /url: ${yamlValue(e.url)}`),this.renderList(i,a,n)}};function appendText(e,t){if(t===``)return;let n=e.length-1;n>=0&&typeof e[n]==`string`&&e[n]!==`\0`?e[n]=e[n]+t:e.push(t)}function appendBreak(e){let t=e.length-1;t>=0&&typeof e[t]==`string`&&e[t]!==`\0`&&e.push(`\0`)}function finishChildren(e,t){let n=0;for(let t=0;t<e.length;t++){let r=e[t];typeof r==`string`&&(r===`\0`||(r=normalizeSpace(r).trim(),r===``))||(e[n++]=r)}e.length=n,e.length>0&&typeof e[0]==`string`&&e[0]===t&&e.splice(0,1),n=0;for(let t=0;t<e.length;t++){let r=e[t];(typeof r!=`string`||!labels(e[t-1],r)&&!labels(e[t+1],r))&&(e[n++]=r)}e.length=n}const f=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`listbox`,`checkbox`,`radio`,`switch`,`slider`,`spinbutton`,`meter`,`progressbar`]);function labels(e,t){return e!==void 0&&typeof e!=`string`&&e.name===t&&f.has(e.role)}let p=null;function loadPrettyFormat(){return p??=(0,n.createRequire)(require("url").pathToFileURL(__filename).href)(`pretty-format`)}const m=Object.defineProperties({},{format:{enumerable:!0,get:()=>loadPrettyFormat().format},default:{enumerable:!0,get:()=>loadPrettyFormat().default},plugins:{enumerable:!0,get:()=>loadPrettyFormat().plugins},DEFAULT_OPTIONS:{enumerable:!0,get:()=>loadPrettyFormat().DEFAULT_OPTIONS}}),shouldHighlight=()=>{if(typeof process>`u`)return!1;let e;try{let t=process.env?.COLORS;t&&(e=JSON.parse(t))}catch{}return typeof e==`boolean`?e:process.versions!==void 0&&process.versions.node!==void 0};function filterCommentsAndDefaultIgnoreTagsTags(e){return e.nodeType!==t.COMMENT_NODE&&(e.nodeType!==t.ELEMENT_NODE||!e.matches(getConfig().defaultIgnore))}const h={open:``,close:``},g={comment:h,content:h,prop:h,tag:h,value:h},_={comment:{open:`\x1B[90m`,close:`\x1B[39m`},content:{open:`\x1B[0m`,close:`\x1B[0m`},prop:{open:`\x1B[33m`,close:`\x1B[39m`},tag:{open:`\x1B[36m`,close:`\x1B[39m`},value:{open:`\x1B[32m`,close:`\x1B[39m`}},v=/* @__PURE__ */ new Set([`callToJSON`,`compareKeys`,`escapeRegex`,`escapeString`,`highlight`,`indent`,`maxDepth`,`min`,`plugins`,`printBasicPrototype`,`printFunctionName`,`theme`]),y=Symbol(`delegate`),b=/^((HTML|SVG)\w*)?Element$/,x=/* @__PURE__ */ new WeakMap;function isCustomElement(e){let{tagName:t}=e;return!!(typeof t==`string`&&t.includes(`-`)||typeof e.hasAttribute==`function`&&e.hasAttribute(`is`))}function pluginHandles(e){let n=e.node,r=n.constructor,i=r?.name;switch(e.type){case t.ELEMENT_NODE:{if(!i&&!isCustomElement(n))return!1;if(typeof r!=`function`)return b.test(i)||isCustomElement(n);let e=x.get(r);return e===void 0&&x.set(r,e=b.test(i)),e||isCustomElement(n)}case t.TEXT_NODE:return i===`Text`;case t.COMMENT_NODE:return i===`Comment`;case t.DOCUMENT_FRAGMENT_NODE:return i===`DocumentFragment`}return!1}function escapeHTML(e){return e.indexOf(`<`)===-1&&e.indexOf(`>`)===-1?e:e.replace(/</g,`<`).replace(/>/g,`>`)}function printString(e,t){return t.escapeString?`"`+e.replace(/"|\\/g,`\\$&`)+`"`:`"`+e+`"`}function keepChild(e,n){return n.filterNode===null?e.type===t.COMMENT_NODE?!1:e.type===t.ELEMENT_NODE?n.scriptStyleIgnore?e.name!==`script`&&e.name!==`style`:!matchesSelector(e,n.defaultIgnore):!0:!!n.filterNode(e.node)}function tagNameLower(e){return e.node.tagName.toLowerCase()}function printProps(e,t,n){let r=e.attrs;if(r===null||r.length===0)return``;let i=[],a=/* @__PURE__ */ new Map;for(let n=0;n<r.length;n++)t.compact&&isNoiseAttribute(e,r[n].name)||(i.push(r[n].name),a.set(r[n].name,r[n].value));i.sort();let o=t.colors,s=``;for(let e=0;e<i.length;e++){let r=i[e];s+=t.spacingInner+n+o.prop.open+r+o.prop.close+`=`+o.value.open+printString(a.get(r),t)+o.value.close}return s}function isNoiseAttribute(e,n){return n===`class`||n===`style`||e.ns===t.SVG_NS&&n!==`role`&&n!==`id`&&!n.startsWith(`aria-`)&&!n.startsWith(`data-`)}function printChildren(e,n,r,i){if(n.compact&&e.ns===t.SVG_NS&&e.name===`svg`)return``;let a=``;for(let o=e.first;o!==null;o=o.next)keepChild(o,n)&&(n.compact&&o.type===t.TEXT_NODE&&o.data.trim()===``||(a+=n.spacingOuter+r+printNode(o,n,r,i)));return a}function printNode(e,n,r,i){if(!pluginHandles(e))throw y;if(e.type===t.TEXT_NODE){let t=n.compact&&e.data.length>200?e.data.slice(0,199)+`…`:e.data;return n.colors.content.open+escapeHTML(t)+n.colors.content.close}if(e.type===t.COMMENT_NODE){let t=n.colors.comment;return t.open+`<!--`+escapeHTML(e.data)+`-->`+t.close}let a=e.type===t.DOCUMENT_FRAGMENT_NODE?`DocumentFragment`:tagNameLower(e),o=n.colors.tag;if(++i>n.maxDepth)return o.open+`<`+a+o.close+` …`+o.open+` />`+o.close;let s=r+n.indent,c=e.type===t.DOCUMENT_FRAGMENT_NODE?``:printProps(e,n,s),l=printChildren(e,n,s,i);return o.open+`<`+a+(c&&o.close+c+n.spacingOuter+r+o.open)+(l?`>`+o.close+l+n.spacingOuter+r+o.open+`</`+a:(c&&!n.min?``:` `)+`/`)+`>`+o.close}function makePrintConfig(e,t){for(let t of Object.keys(e))if(!v.has(t))return null;if(e.plugins!==void 0||e.theme!==void 0||e.min&&e.indent!==void 0&&e.indent!==0)return null;let n=!!e.min,r=e.indent===void 0?2:e.indent,i=getConfig().defaultIgnore;return{colors:e.highlight?_:g,escapeString:e.escapeString===void 0||e.escapeString,indent:n?``:Array(r+1).join(` `),maxDepth:e.maxDepth===void 0?1/0:e.maxDepth,min:n,spacingInner:n?` `:`
|
|
5
|
-
`,spacingOuter:n?``:`
|
|
6
|
-
`,filterNode:t,scriptStyleIgnore:i===`script, style`,defaultIgnore:i,compact:!1}}function formatDOM(e,n,r,i=!1){let a={printFunctionName:!1,highlight:shouldHighlight(),...r},o=e[t.$impl],s=n??filterCommentsAndDefaultIgnoreTagsTags;if(o!==void 0){let e=makePrintConfig(a,n===void 0?null:n);if(e!==null){e.compact=i;try{return printNode(o,e,``,0)}catch(e){if(e!==y)throw e}}}return formatWithPrettyFormat(e,s,a)}function formatWithPrettyFormat(e,t,n){let r=loadPrettyFormat();return r.format(e,{plugins:[createDOMElementFilter(t),r.plugins.DOMCollection],...n})}function prettyDOM(e,t,n={}){e||=getDocument().body;let r=typeof t==`number`?t:void 0;if(typeof t!=`number`&&(t=typeof process<`u`&&process.env!==void 0&&process.env.DEBUG_PRINT_LIMIT||7e3),t===0)return``;e.documentElement&&(e=e.documentElement);let i=typeof e;if(i===`object`?i=e.constructor.name:e={},!(`outerHTML`in e))throw TypeError(`Expected an element or document but got ${i}`);let a=n.format??envDebugFormat();if(a!==null||`format`in n){let{format:i,hidden:o,maxLines:s,maxTextLength:c,collapseAfter:l,urls:u,...d}=n;if(a===`aria`){let t=ariaSnapshot(e,{hidden:o,maxLines:s,maxTextLength:c,collapseAfter:l,urls:u});return r!==void 0&&t.length>r?`${t.slice(0,r)}...`:t}if(n=d,a===`compact`){let{filterNode:r,...i}={highlight:!1,...n},a=formatDOM(e,r,i,!0);return a.length>t?`${a.slice(0,t)}...`:a}}let{filterNode:o,...s}=n,c=formatDOM(e,o,s);return t!==void 0&&outerHTMLLength(e)>t?`${c.slice(0,t)}...`:c}function outerHTMLLength(e){let n=e[t.$impl];return n!==void 0&&n.type===t.ELEMENT_NODE?(0,t.serializeNode)(n).length:e.outerHTML.length}const logDOM=(...e)=>{let t=getUserCodeFrame();console.log(t?`${prettyDOM(...e)}\n\n${t}`:prettyDOM(...e))};function createDOMElementFilter(e){let printPropsPF=(e,t,n,r,i,a,o)=>{let s=r+n.indent,c=n.colors;return e.map(e=>{let l=t[e],u=o(l,n,s,i,a);return typeof l!=`string`&&(u.indexOf(`
|
|
7
|
-
`)!==-1&&(u=n.spacingOuter+s+u+n.spacingOuter+r),u=`{`+u+`}`),n.spacingInner+r+c.prop.open+e+c.prop.close+`=`+c.value.open+u+c.value.close}).join(``)},printText=(e,t)=>t.colors.content.open+escapeHTML(e)+t.colors.content.close,printChildrenPF=(e,n,r,i,a,o)=>e.map(e=>{let s=typeof e==`string`?printText(e,n):o(e,n,r,i,a);return s===``&&typeof e==`object`&&e&&e.nodeType!==t.TEXT_NODE?``:n.spacingOuter+r+s}).join(``),printElement=(e,t,n,r,i)=>{let a=r.colors.tag;return a.open+`<`+e+(t&&a.close+t+r.spacingOuter+i+a.open)+(n?`>`+a.close+n+r.spacingOuter+i+a.open+`</`+e:(t&&!r.min?``:` `)+`/`)+`>`+a.close},testNode=e=>{let n=e.constructor.name,{nodeType:r}=e;return r===t.ELEMENT_NODE&&(b.test(n)||isCustomElement(e))||r===t.TEXT_NODE&&n===`Text`||r===t.COMMENT_NODE&&n===`Comment`||r===t.DOCUMENT_FRAGMENT_NODE&&n===`DocumentFragment`};return{test:e=>(e?.constructor?.name||isCustomElement(e))&&testNode(e),serialize:(n,r,i,a,o,s)=>{if(n.nodeType===t.TEXT_NODE)return printText(n.data,r);if(n.nodeType===t.COMMENT_NODE){let e=r.colors.comment;return e.open+`<!--`+escapeHTML(n.data)+`-->`+e.close}let c=n.nodeType===t.DOCUMENT_FRAGMENT_NODE,l=c?`DocumentFragment`:n.tagName.toLowerCase();if(++a>r.maxDepth){let e=r.colors.tag;return e.open+`<`+l+e.close+` …`+e.open+` />`+e.close}return printElement(l,printPropsPF(c?[]:Array.from(n.attributes).map(e=>e.name).sort(),c?{}:Array.from(n.attributes).reduce((e,t)=>(e[t.name]=t.value,e),{}),r,i+r.indent,a,o,s),printChildrenPF(Array.prototype.slice.call(n.childNodes||n.children).filter(e),r,i+r.indent,a,o,s),r,i)}}}let S={testIdAttribute:`data-testid`,asyncUtilTimeout:1e3,asyncWrapper:e=>e(),unstable_advanceTimersWrapper:e=>e(),eventWrapper:e=>e(),defaultHidden:!1,defaultIgnore:`script, style`,showOriginalStackTrace:!1,throwSuggestions:!1,getElementError(e,t){let n=envDebugFormat();if(n!==null){let r=Error([e,agentErrorContext(t,n,prettyDOM)].filter(Boolean).join(`
|
|
8
|
-
|
|
9
|
-
`));return r.name=`TestingLibraryElementError`,r}let r=prettyDOM(t),i=Error([e,`Ignored nodes: comments, ${S.defaultIgnore}\n${r}`].filter(Boolean).join(`
|
|
10
|
-
|
|
11
|
-
`));return i.name=`TestingLibraryElementError`,i},_disableExpensiveErrorDiagnostics:!1,computedStyleSupportsPseudoElements:!1};function runWithExpensiveErrorDiagnosticsDisabled(e){try{return S._disableExpensiveErrorDiagnostics=!0,e()}finally{S._disableExpensiveErrorDiagnostics=!1}}function configure(e){typeof e==`function`&&(e=e(S)),S={...S,...e}}function getConfig(){return S}function diffAriaSnapshots(e,t){let n=diffLines(e.split(`
|
|
12
|
-
`),t.split(`
|
|
13
|
-
`)),r=new Uint8Array(n.length),i=!1;for(let e=0;e<n.length;e++){if(n[e].kind===`=`)continue;i=!0,r[e]=1;let t=indentOf(n[e].text);for(let i=e-1;i>=0&&t>0;i--){if(n[i].kind!==`=`)continue;let e=indentOf(n[i].text);e<t&&(r[i]=1,t=e)}}if(!i)return`(no changes)`;let a=[],o=-1;for(let e=0;e<n.length;e++)r[e]!==0&&(o!==-1&&e!==o+1&&a.push(` …`),a.push(`${n[e].kind===`=`?` `:n[e].kind} ${n[e].text}`),o=e);return a.join(`
|
|
14
|
-
`)}function indentOf(e){let t=0;for(;t<e.length&&e.charCodeAt(t)===32;)t++;return t}function diffLines(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=e.length,i=t.length;for(;r>n&&i>n&&e[r-1]===t[i-1];)r--,i--;let a=[];for(let t=0;t<n;t++)a.push({kind:`=`,text:e[t]});let o=r-n,s=i-n;if(o*s>4e6){for(let t=n;t<r;t++)a.push({kind:`-`,text:e[t]});for(let e=n;e<i;e++)a.push({kind:`+`,text:t[e]})}else{let r=s+1,i=new Uint32Array((o+1)*r);for(let a=o-1;a>=0;a--)for(let o=s-1;o>=0;o--)i[a*r+o]=e[n+a]===t[n+o]?i[(a+1)*r+o+1]+1:Math.max(i[(a+1)*r+o],i[a*r+o+1]);let c=0,l=0;for(;c<o||l<s;)c<o&&l<s&&e[n+c]===t[n+l]?(a.push({kind:`=`,text:e[n+c]}),c++,l++):c<o&&(l===s||i[(c+1)*r+l]>=i[c*r+l+1])?(a.push({kind:`-`,text:e[n+c]}),c++):(a.push({kind:`+`,text:t[n+l]}),l++)}for(let t=r;t<e.length;t++)a.push({kind:`=`,text:e[t]});return a}Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return implOf}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return agentElementSummary}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return checkContainerType}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return advanceFakeTimersByTime}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return __exportAll}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return __name}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return getDocument}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return yamlValue}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return matchesSelector}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return nodeKey}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return runWithExpensiveErrorDiagnosticsDisabled}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return resetBodySnapshot}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return ariaSnapshotTree}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return budgetLines}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return lastBodySnapshot}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return hiddenReason}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return getConfig}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return jestFakeTimersAreEnabled}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return getWindowFromNode}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return ariaSnapshot}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return envMaxLines}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return diffLines}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return logDOM}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return describeElement}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return configure}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return prettyDOM}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return diffAriaSnapshots}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return ariaSnapshotLines}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return nodeProps}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return envDebugFormat}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return truncate}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return quote}});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";import{$impl as t,COMMENT_NODE as n,DOCUMENT_FRAGMENT_NODE as r,DOCUMENT_NODE as i,ELEMENT_NODE as a,HTML_NS as o,SVG_NS as s,T as c,TEXT_NODE as l,attr as u,matches as d,serializeNode as f,setFailureSnapshot as p}from"@ctrl/dom/internal";import{readFileSync as m}from"node:fs";import{roleSupportsProp as h}from"@ctrl/dom/aria";import{ariaCheckedState as g,ariaPressedState as _,computeAccessibleNameImpl as v,computeAriaBusy as y,computeAriaCurrent as b,computeAriaExpanded as x,computeAriaSelected as S,computeHeadingLevel as C,isDisabledImpl as w,isDisplayInline as T,isDisplayNone as E,isInaccessibleImpl as D,isSubtreeInaccessibleImpl as O,isVisibilityHidden as k,tlRole as A}from"@ctrl/dom/aria/internal";var j=Object.defineProperty,__name=(e,t)=>j(e,`name`,{value:t,configurable:!0}),__exportAll=(e,t)=>{let n={};for(var r in e)j(n,r,{get:e[r],enumerable:!0});return t||j(n,Symbol.toStringTag,{value:`Module`}),n};const M=new URL(`./`,import.meta.url).pathname;let N;function loadDeps(){if(N!==void 0)return N;try{let t=e(import.meta.url);N={codeFrameColumns:t(`@babel/code-frame`).codeFrameColumns,picocolors:t(`picocolors`)}}catch{N=null}return N}function getCodeFrame(e){let{codeFrameColumns:t,picocolors:n}=loadDeps(),r=e.indexOf(`(`)+1,i=e.indexOf(`)`),a=e.slice(r,i),o=a.split(`:`),[s,c,l]=[o[0],parseInt(o[1],10),parseInt(o[2],10)],u=``;try{u=m(s,`utf-8`)}catch{return``}let d=t(u,{start:{line:c,column:l-1}},{highlightCode:!0,linesBelow:0});return`${n.dim(a)}\n${d}\n`}function getUserCodeFrame(){let e=loadDeps();return!e||!m||!e.codeFrameColumns?``:getCodeFrame((/* @__PURE__ */ Error()).stack.split(`
|
|
2
|
-
`).slice(1).find(e=>!e.includes(`node_modules/`)&&!e.includes(M)))}function jestFakeTimersAreEnabled(){if(typeof jest<`u`&&jest!==null)return setTimeout._isMockFunction===!0||Object.hasOwn(setTimeout,`clock`);let e=setTimeout.clock;return e!=null&&typeof e.tick==`function`}function advanceFakeTimersByTime(e){if(typeof jest<`u`&&jest!==null){jest.advanceTimersByTime(e);return}let t=globalThis.vi;t!=null&&typeof t.advanceTimersByTime==`function`&&typeof t.isFakeTimers==`function`&&t.isFakeTimers()?t.advanceTimersByTime(e):setTimeout.clock.tick(e)}function getDocument(){if(typeof window>`u`)throw Error(`Could not find default container`);return window.document}function getWindowFromNode(e){if(e.defaultView)return e.defaultView;if(e.ownerDocument&&e.ownerDocument.defaultView)return e.ownerDocument.defaultView;if(e.window)return e.window;throw e.ownerDocument&&e.ownerDocument.defaultView===null?Error(`It looks like the window object is not available for the provided node.`):e.then instanceof Function?Error("It looks like you passed a Promise object instead of a DOM node. Did you do something like `fireEvent.click(screen.findBy...` when you meant to use a `getBy` query `fireEvent.click(screen.getBy...`, or await the findBy query `fireEvent.click(await screen.findBy...`?"):Array.isArray(e)?Error("It looks like you passed an Array instead of a DOM node. Did you do something like `fireEvent.click(screen.getAllBy...` when you meant to use a `getBy` query `fireEvent.click(screen.getBy...`?"):typeof e.debug==`function`&&typeof e.logTestingPlaygroundURL==`function`?Error("It looks like you passed a `screen` object. Did you do something like `fireEvent.click(screen, ...` when you meant to use a query, e.g. `fireEvent.click(screen.getBy..., `?"):Error(`The given node is not an Element, the node type is: ${typeof e}.`)}function checkContainerType(e){if(!e||typeof e.querySelector!=`function`||typeof e.querySelectorAll!=`function`)throw TypeError(`Expected container to be an Element, a Document or a DocumentFragment but got ${getTypeName(e)}.`)}function getTypeName(e){return typeof e==`object`?e===null?`null`:e.constructor.name:typeof e}function implOf(e){let n=e[t];if(n===void 0)throw TypeError(`@ctrl/dom/testing-library requires nodes created by @ctrl/dom.`);return n}function matchesSelector(e,t){return e.type===a&&d(e,t)}function envDebugFormat(){let e=typeof process<`u`?process.env?.CTRL_DOM_DEBUG:void 0;if(e===void 0||e===``)return null;let t=String(e).trim().toLowerCase();return t===`aria`?`aria`:t===`compact`||t===`html`?`compact`:null}function containerLabel(e){let n=e?.[t];return n===void 0?`the container`:n.type===9?`the document`:describeElement(n)}function agentErrorContext(e,t,n){return t===`aria`?`Accessibility snapshot of ${containerLabel(e)} (CTRL_DOM_DEBUG=aria):\n${ariaSnapshot(e,{maxLines:envMaxLines()??100})}`:`DOM of ${containerLabel(e)} without class/style/SVG internals (CTRL_DOM_DEBUG=compact):\n${n(e,void 0,{format:`compact`})}`}function agentElementSummary(e){return ariaSnapshot(e,{maxLines:12})}function envMaxLines(){let e=typeof process<`u`?process.env?.CTRL_DOM_DEBUG_LINES:void 0,t=e?Number(e):NaN;return t>0?t:void 0}function ariaSnapshot(e,t={}){let{header:n,lines:r,empty:i}=ariaSnapshotLines(e,t);return i===null?n+budgetLines(r,t.maxLines??envMaxLines()??200).join(`
|
|
3
|
-
`):n+i}p(e=>ariaSnapshot(e,{maxLines:2e3}));function buildTree(e,t){let n=rootImpl(e),r=new SnapshotContext(n,t),i=[],o=``;return!r.includeHidden&&n.type===a&&D(n)&&(o=`# hidden from the accessibility tree: ${hiddenReason(n)}\n`,r.includeHidden=!0,r.forceHidden=!0),n.type===a&&n!==bodyOf(n)?r.visitElement(n,i,r.forceHidden):r.visitChildren(n,i,!1,!1),finishChildren(i,null),{root:n,ctx:r,children:i,header:o}}function ariaSnapshotTree(e,t={}){return buildTree(e,t).children}function ariaSnapshotLines(e,t={}){let{root:n,ctx:r,children:i,header:a}=buildTree(e,t),o=[];r.renderList(i,``,o);let s=o.length>0?null:r.sawHidden?`# no accessible content (hidden elements exist: pass { hidden: true })`:`# no accessible content`;return n===bodyOf(n)&&envDebugFormat()!==null&&recordBodySnapshot(n.doc,s??o.join(`
|
|
4
|
-
`)),{header:a,lines:o,empty:s}}function budgetLines(e,t){if(e.length<=t)return e;let n=e.length-t,r=e.slice(0,t);return r.push(`# … ${n} more line${n===1?``:`s`} (raise maxLines or CTRL_DOM_DEBUG_LINES)`),r}const P=Symbol.for(`ctrl-dom.agent.lastBodySnapshot`);function recordBodySnapshot(e,t){e!=null&&Object.defineProperty(e,P,{value:t,configurable:!0,writable:!0,enumerable:!1})}function lastBodySnapshot(e){return e?.[P]}function resetBodySnapshot(e){e!=null&&Object.hasOwn(e,P)&&delete e[P]}function rootImpl(e){let n=e??getDocument().body,r=n?.[t];if(r===void 0)throw TypeError(`Expected an element, document or fragment but got ${n===null?`null`:typeof n}`);if(r.type===i||r.tag===c.html&&r.ns===o){let e=r.doc?.body;return e?e[t]:r}return r}function bodyOf(e){let n=e.doc?.body;return n?n[t]:null}function normalizeSpace(e){return e.replace(/[\t\n\f\r ]+/g,` `)}function truncate(e,t){return e.length>t?e.slice(0,Math.max(1,t-1))+`…`:e}function quote(e){return JSON.stringify(e)}const F=/^$|^[\s\-?:,[\]{}#&*!|>'"%@`]|[\s]$|:$|: | #|^(true|false|null|yes|no|on|off|~)$|^[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i;function yamlValue(e){return F.test(e)?quote(e):e}function nodeKey(e,t){let n=e.role;e.name!==``&&(n+=` `+quote(truncate(e.name,t)));for(let t=0;t<e.props.length;t++)n+=` `+e.props[t];return n}function describeElement(e){let t=e.name;if(e.id!==``)return`<${t} id="${e.id}">`;let n=u(e,`data-testid`);return n===null?`<${t}>`:`<${t} data-testid="${n}">`}function hiddenReason(e){let t=hiddenChainReason(e);return t===``?k(e)?`visibility: hidden on ${describeElement(e)}`:``:t}function hiddenChainReason(e){for(let t=e;t!==null&&t.type===a;t=t.parent){if(t.ns===o&&u(t,`hidden`)!==null)return`hidden attribute on ${describeElement(t)}`;if(u(t,`aria-hidden`)===`true`)return`aria-hidden="true" on ${describeElement(t)}`;if(E(t))return`display: none on ${describeElement(t)}`}return``}const I=/* @__PURE__ */ new Set([``,`generic`,`none`,`presentation`]);function isSkippedTag(e){if(e.ns!==o)return!1;switch(e.tag){case c.script:case c.style:case c.template:case c.noscript:case c.head:return!0}return!1}function nodeProps(e,t,n,r){let i=[];if(h(t,`aria-checked`)){let t=g(e);t===!0?i.push(`[checked]`):t===`mixed`&&i.push(`[checked=mixed]`)}w(e)&&i.push(`[disabled]`);let a=x(e);a===!0?i.push(`[expanded]`):a===!1&&i.push(`[expanded=false]`),n&&i.push(`[active]`);let o=t===`heading`?C(e):levelAttr(e);o!==void 0&&i.push(`[level=${o}]`);let s=_(e);s===!0?i.push(`[pressed]`):s===`mixed`?i.push(`[pressed=mixed]`):s===!1&&i.push(`[pressed=false]`),S(e)===!0&&i.push(`[selected]`);let c=b(e);return c===!0?i.push(`[current]`):typeof c==`string`&&c!==``&&i.push(`[current=${c}]`),y(e)&&i.push(`[busy]`),r&&i.push(`[hidden]`),i}function levelAttr(e){let t=u(e,`aria-level`),n=t===null?NaN:Number(t);return n>0?n:void 0}const L=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`spinbutton`,`slider`,`progressbar`,`meter`,`scrollbar`,`separator`]);function nodeValue(e,t){if(!L.has(t))return null;let n=u(e,`aria-valuetext`);if(n!==null)return n;let r=u(e,`aria-valuenow`);if(r!==null)return r;if(e.ns!==o)return null;if(e.tag===c.input||e.tag===c.textarea){let t=String(e.node.value??``);return t===``?null:t}return null}var SnapshotContext=class{includeHidden;forceHidden=!1;sawHidden=!1;maxText;collapseAfter;urls;active;constructor(e,n){this.includeHidden=n.hidden===!0,this.maxText=n.maxTextLength??100,this.collapseAfter=n.collapseAfter??5,this.urls=n.urls===!0;let r=e.doc?.activeElement,i=r?r[t]??null:null;this.active=i!==null&&i===bodyOf(e)?null:i}visitChildren(e,t,n,i){for(let o=e.first;o!==null;o=o.next)o.type===l?i||appendText(t,o.data):o.type===a?this.visitElement(o,t,n):o.type===r&&this.visitChildren(o,t,n,i)}visitElement(e,t,n){if(isSkippedTag(e))return;let r=n;if(!r&&O(e)){if(this.sawHidden=!0,!this.includeHidden)return;r=!0}let i=r;if(!r&&k(e)){if(this.sawHidden=!0,!this.includeHidden){this.visitChildren(e,t,!1,!0);return}i=!0}let a=A(e);if(I.has(a)){let n=!T(e);n&&appendBreak(t),this.visitChildren(e,t,r,!1),n&&appendBreak(t);return}let s={role:a,name:normalizeSpace(v(e,void 0,5)).trim(),props:nodeProps(e,a,e===this.active,i&&this.includeHidden),value:nodeValue(e,a),url:null,children:[],element:e};this.urls&&a===`link`&&(s.url=u(e,`href`)),(e.ns!==o||e.tag!==c.textarea)&&this.visitChildren(e,s.children,r,!1),finishChildren(s.children,s.name),t.push(s)}renderList(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(typeof i==`string`){n.push(`${t}- text: ${yamlValue(truncate(i,this.maxText))}`);continue}let a=1;for(;r+a<e.length&&typeof e[r+a]!=`string`&&e[r+a].role===i.role;)a++;if(a>this.collapseAfter+1){for(let i=0;i<this.collapseAfter;i++)this.renderNode(e[r+i],t,n);n.push(`${t}- ${i.role} … (+${a-this.collapseAfter} more)`),r+=a-1}else this.renderNode(i,t,n)}}renderNode(e,t,n){let r=nodeKey(e,this.maxText),i=e.children;if(e.url===null&&(i.length===0||i.length===1&&typeof i[0]==`string`&&e.value===null)){let a=e.value??(i.length===1?i[0]:null);n.push(a===null?`${t}- ${r}`:`${t}- ${r}: ${yamlValue(truncate(a,this.maxText))}`);return}n.push(e.value===null?`${t}- ${r}:`:`${t}- ${r}: ${yamlValue(truncate(e.value,this.maxText))}`);let a=t+` `;e.url!==null&&n.push(`${a}- /url: ${yamlValue(e.url)}`),this.renderList(i,a,n)}};function appendText(e,t){if(t===``)return;let n=e.length-1;n>=0&&typeof e[n]==`string`&&e[n]!==`\0`?e[n]=e[n]+t:e.push(t)}function appendBreak(e){let t=e.length-1;t>=0&&typeof e[t]==`string`&&e[t]!==`\0`&&e.push(`\0`)}function finishChildren(e,t){let n=0;for(let t=0;t<e.length;t++){let r=e[t];typeof r==`string`&&(r===`\0`||(r=normalizeSpace(r).trim(),r===``))||(e[n++]=r)}e.length=n,e.length>0&&typeof e[0]==`string`&&e[0]===t&&e.splice(0,1),n=0;for(let t=0;t<e.length;t++){let r=e[t];(typeof r!=`string`||!labels(e[t-1],r)&&!labels(e[t+1],r))&&(e[n++]=r)}e.length=n}const R=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`listbox`,`checkbox`,`radio`,`switch`,`slider`,`spinbutton`,`meter`,`progressbar`]);function labels(e,t){return e!==void 0&&typeof e!=`string`&&e.name===t&&R.has(e.role)}let z=null;function loadPrettyFormat(){return z??=e(import.meta.url)(`pretty-format`)}const B=Object.defineProperties({},{format:{enumerable:!0,get:()=>loadPrettyFormat().format},default:{enumerable:!0,get:()=>loadPrettyFormat().default},plugins:{enumerable:!0,get:()=>loadPrettyFormat().plugins},DEFAULT_OPTIONS:{enumerable:!0,get:()=>loadPrettyFormat().DEFAULT_OPTIONS}}),shouldHighlight=()=>{if(typeof process>`u`)return!1;let e;try{let t=process.env?.COLORS;t&&(e=JSON.parse(t))}catch{}return typeof e==`boolean`?e:process.versions!==void 0&&process.versions.node!==void 0};function filterCommentsAndDefaultIgnoreTagsTags(e){return e.nodeType!==n&&(e.nodeType!==a||!e.matches(getConfig().defaultIgnore))}const V={open:``,close:``},H={comment:V,content:V,prop:V,tag:V,value:V},U={comment:{open:`\x1B[90m`,close:`\x1B[39m`},content:{open:`\x1B[0m`,close:`\x1B[0m`},prop:{open:`\x1B[33m`,close:`\x1B[39m`},tag:{open:`\x1B[36m`,close:`\x1B[39m`},value:{open:`\x1B[32m`,close:`\x1B[39m`}},W=/* @__PURE__ */ new Set([`callToJSON`,`compareKeys`,`escapeRegex`,`escapeString`,`highlight`,`indent`,`maxDepth`,`min`,`plugins`,`printBasicPrototype`,`printFunctionName`,`theme`]),G=Symbol(`delegate`),K=/^((HTML|SVG)\w*)?Element$/,q=/* @__PURE__ */ new WeakMap;function isCustomElement(e){let{tagName:t}=e;return!!(typeof t==`string`&&t.includes(`-`)||typeof e.hasAttribute==`function`&&e.hasAttribute(`is`))}function pluginHandles(e){let t=e.node,i=t.constructor,o=i?.name;switch(e.type){case a:{if(!o&&!isCustomElement(t))return!1;if(typeof i!=`function`)return K.test(o)||isCustomElement(t);let e=q.get(i);return e===void 0&&q.set(i,e=K.test(o)),e||isCustomElement(t)}case l:return o===`Text`;case n:return o===`Comment`;case r:return o===`DocumentFragment`}return!1}function escapeHTML(e){return e.indexOf(`<`)===-1&&e.indexOf(`>`)===-1?e:e.replace(/</g,`<`).replace(/>/g,`>`)}function printString(e,t){return t.escapeString?`"`+e.replace(/"|\\/g,`\\$&`)+`"`:`"`+e+`"`}function keepChild(e,t){return t.filterNode===null?e.type===n?!1:e.type===a?t.scriptStyleIgnore?e.name!==`script`&&e.name!==`style`:!matchesSelector(e,t.defaultIgnore):!0:!!t.filterNode(e.node)}function tagNameLower(e){return e.node.tagName.toLowerCase()}function printProps(e,t,n){let r=e.attrs;if(r===null||r.length===0)return``;let i=[],a=/* @__PURE__ */ new Map;for(let n=0;n<r.length;n++)t.compact&&isNoiseAttribute(e,r[n].name)||(i.push(r[n].name),a.set(r[n].name,r[n].value));i.sort();let o=t.colors,s=``;for(let e=0;e<i.length;e++){let r=i[e];s+=t.spacingInner+n+o.prop.open+r+o.prop.close+`=`+o.value.open+printString(a.get(r),t)+o.value.close}return s}function isNoiseAttribute(e,t){return t===`class`||t===`style`||e.ns===s&&t!==`role`&&t!==`id`&&!t.startsWith(`aria-`)&&!t.startsWith(`data-`)}function printChildren(e,t,n,r){if(t.compact&&e.ns===s&&e.name===`svg`)return``;let i=``;for(let a=e.first;a!==null;a=a.next)keepChild(a,t)&&(t.compact&&a.type===l&&a.data.trim()===``||(i+=t.spacingOuter+n+printNode(a,t,n,r)));return i}function printNode(e,t,i,a){if(!pluginHandles(e))throw G;if(e.type===l){let n=t.compact&&e.data.length>200?e.data.slice(0,199)+`…`:e.data;return t.colors.content.open+escapeHTML(n)+t.colors.content.close}if(e.type===n){let n=t.colors.comment;return n.open+`<!--`+escapeHTML(e.data)+`-->`+n.close}let o=e.type===r?`DocumentFragment`:tagNameLower(e),s=t.colors.tag;if(++a>t.maxDepth)return s.open+`<`+o+s.close+` …`+s.open+` />`+s.close;let c=i+t.indent,u=e.type===r?``:printProps(e,t,c),d=printChildren(e,t,c,a);return s.open+`<`+o+(u&&s.close+u+t.spacingOuter+i+s.open)+(d?`>`+s.close+d+t.spacingOuter+i+s.open+`</`+o:(u&&!t.min?``:` `)+`/`)+`>`+s.close}function makePrintConfig(e,t){for(let t of Object.keys(e))if(!W.has(t))return null;if(e.plugins!==void 0||e.theme!==void 0||e.min&&e.indent!==void 0&&e.indent!==0)return null;let n=!!e.min,r=e.indent===void 0?2:e.indent,i=getConfig().defaultIgnore;return{colors:e.highlight?U:H,escapeString:e.escapeString===void 0||e.escapeString,indent:n?``:Array(r+1).join(` `),maxDepth:e.maxDepth===void 0?1/0:e.maxDepth,min:n,spacingInner:n?` `:`
|
|
5
|
-
`,spacingOuter:n?``:`
|
|
6
|
-
`,filterNode:t,scriptStyleIgnore:i===`script, style`,defaultIgnore:i,compact:!1}}function formatDOM(e,n,r,i=!1){let a={printFunctionName:!1,highlight:shouldHighlight(),...r},o=e[t],s=n??filterCommentsAndDefaultIgnoreTagsTags;if(o!==void 0){let e=makePrintConfig(a,n===void 0?null:n);if(e!==null){e.compact=i;try{return printNode(o,e,``,0)}catch(e){if(e!==G)throw e}}}return formatWithPrettyFormat(e,s,a)}function formatWithPrettyFormat(e,t,n){let r=loadPrettyFormat();return r.format(e,{plugins:[createDOMElementFilter(t),r.plugins.DOMCollection],...n})}function prettyDOM(e,t,n={}){e||=getDocument().body;let r=typeof t==`number`?t:void 0;if(typeof t!=`number`&&(t=typeof process<`u`&&process.env!==void 0&&process.env.DEBUG_PRINT_LIMIT||7e3),t===0)return``;e.documentElement&&(e=e.documentElement);let i=typeof e;if(i===`object`?i=e.constructor.name:e={},!(`outerHTML`in e))throw TypeError(`Expected an element or document but got ${i}`);let a=n.format??envDebugFormat();if(a!==null||`format`in n){let{format:i,hidden:o,maxLines:s,maxTextLength:c,collapseAfter:l,urls:u,...d}=n;if(a===`aria`){let t=ariaSnapshot(e,{hidden:o,maxLines:s,maxTextLength:c,collapseAfter:l,urls:u});return r!==void 0&&t.length>r?`${t.slice(0,r)}...`:t}if(n=d,a===`compact`){let{filterNode:r,...i}={highlight:!1,...n},a=formatDOM(e,r,i,!0);return a.length>t?`${a.slice(0,t)}...`:a}}let{filterNode:o,...s}=n,c=formatDOM(e,o,s);return t!==void 0&&outerHTMLLength(e)>t?`${c.slice(0,t)}...`:c}function outerHTMLLength(e){let n=e[t];return n!==void 0&&n.type===a?f(n).length:e.outerHTML.length}const logDOM=(...e)=>{let t=getUserCodeFrame();console.log(t?`${prettyDOM(...e)}\n\n${t}`:prettyDOM(...e))};function createDOMElementFilter(e){let printPropsPF=(e,t,n,r,i,a,o)=>{let s=r+n.indent,c=n.colors;return e.map(e=>{let l=t[e],u=o(l,n,s,i,a);return typeof l!=`string`&&(u.indexOf(`
|
|
7
|
-
`)!==-1&&(u=n.spacingOuter+s+u+n.spacingOuter+r),u=`{`+u+`}`),n.spacingInner+r+c.prop.open+e+c.prop.close+`=`+c.value.open+u+c.value.close}).join(``)},printText=(e,t)=>t.colors.content.open+escapeHTML(e)+t.colors.content.close,printChildrenPF=(e,t,n,r,i,a)=>e.map(e=>{let o=typeof e==`string`?printText(e,t):a(e,t,n,r,i);return o===``&&typeof e==`object`&&e&&e.nodeType!==l?``:t.spacingOuter+n+o}).join(``),printElement=(e,t,n,r,i)=>{let a=r.colors.tag;return a.open+`<`+e+(t&&a.close+t+r.spacingOuter+i+a.open)+(n?`>`+a.close+n+r.spacingOuter+i+a.open+`</`+e:(t&&!r.min?``:` `)+`/`)+`>`+a.close},testNode=e=>{let t=e.constructor.name,{nodeType:i}=e;return i===a&&(K.test(t)||isCustomElement(e))||i===l&&t===`Text`||i===n&&t===`Comment`||i===r&&t===`DocumentFragment`};return{test:e=>(e?.constructor?.name||isCustomElement(e))&&testNode(e),serialize:(t,i,a,o,s,c)=>{if(t.nodeType===l)return printText(t.data,i);if(t.nodeType===n){let e=i.colors.comment;return e.open+`<!--`+escapeHTML(t.data)+`-->`+e.close}let u=t.nodeType===r,d=u?`DocumentFragment`:t.tagName.toLowerCase();if(++o>i.maxDepth){let e=i.colors.tag;return e.open+`<`+d+e.close+` …`+e.open+` />`+e.close}return printElement(d,printPropsPF(u?[]:Array.from(t.attributes).map(e=>e.name).sort(),u?{}:Array.from(t.attributes).reduce((e,t)=>(e[t.name]=t.value,e),{}),i,a+i.indent,o,s,c),printChildrenPF(Array.prototype.slice.call(t.childNodes||t.children).filter(e),i,a+i.indent,o,s,c),i,a)}}}let J={testIdAttribute:`data-testid`,asyncUtilTimeout:1e3,asyncWrapper:e=>e(),unstable_advanceTimersWrapper:e=>e(),eventWrapper:e=>e(),defaultHidden:!1,defaultIgnore:`script, style`,showOriginalStackTrace:!1,throwSuggestions:!1,getElementError(e,t){let n=envDebugFormat();if(n!==null){let r=Error([e,agentErrorContext(t,n,prettyDOM)].filter(Boolean).join(`
|
|
8
|
-
|
|
9
|
-
`));return r.name=`TestingLibraryElementError`,r}let r=prettyDOM(t),i=Error([e,`Ignored nodes: comments, ${J.defaultIgnore}\n${r}`].filter(Boolean).join(`
|
|
10
|
-
|
|
11
|
-
`));return i.name=`TestingLibraryElementError`,i},_disableExpensiveErrorDiagnostics:!1,computedStyleSupportsPseudoElements:!1};function runWithExpensiveErrorDiagnosticsDisabled(e){try{return J._disableExpensiveErrorDiagnostics=!0,e()}finally{J._disableExpensiveErrorDiagnostics=!1}}function configure(e){typeof e==`function`&&(e=e(J)),J={...J,...e}}function getConfig(){return J}function diffAriaSnapshots(e,t){let n=diffLines(e.split(`
|
|
12
|
-
`),t.split(`
|
|
13
|
-
`)),r=new Uint8Array(n.length),i=!1;for(let e=0;e<n.length;e++){if(n[e].kind===`=`)continue;i=!0,r[e]=1;let t=indentOf(n[e].text);for(let i=e-1;i>=0&&t>0;i--){if(n[i].kind!==`=`)continue;let e=indentOf(n[i].text);e<t&&(r[i]=1,t=e)}}if(!i)return`(no changes)`;let a=[],o=-1;for(let e=0;e<n.length;e++)r[e]!==0&&(o!==-1&&e!==o+1&&a.push(` …`),a.push(`${n[e].kind===`=`?` `:n[e].kind} ${n[e].text}`),o=e);return a.join(`
|
|
14
|
-
`)}function indentOf(e){let t=0;for(;t<e.length&&e.charCodeAt(t)===32;)t++;return t}function diffLines(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=e.length,i=t.length;for(;r>n&&i>n&&e[r-1]===t[i-1];)r--,i--;let a=[];for(let t=0;t<n;t++)a.push({kind:`=`,text:e[t]});let o=r-n,s=i-n;if(o*s>4e6){for(let t=n;t<r;t++)a.push({kind:`-`,text:e[t]});for(let e=n;e<i;e++)a.push({kind:`+`,text:t[e]})}else{let r=s+1,i=new Uint32Array((o+1)*r);for(let a=o-1;a>=0;a--)for(let o=s-1;o>=0;o--)i[a*r+o]=e[n+a]===t[n+o]?i[(a+1)*r+o+1]+1:Math.max(i[(a+1)*r+o],i[a*r+o+1]);let c=0,l=0;for(;c<o||l<s;)c<o&&l<s&&e[n+c]===t[n+l]?(a.push({kind:`=`,text:e[n+c]}),c++,l++):c<o&&(l===s||i[(c+1)*r+l]>=i[c*r+l+1])?(a.push({kind:`-`,text:e[n+c]}),c++):(a.push({kind:`+`,text:t[n+l]}),l++)}for(let t=r;t<e.length;t++)a.push({kind:`=`,text:e[t]});return a}export{implOf as A,agentElementSummary as C,checkContainerType as D,advanceFakeTimersByTime as E,__exportAll as M,__name as N,getDocument as O,yamlValue as S,matchesSelector as T,nodeKey as _,runWithExpensiveErrorDiagnosticsDisabled as a,resetBodySnapshot as b,B as c,ariaSnapshotTree as d,budgetLines as f,lastBodySnapshot as g,hiddenReason as h,getConfig as i,jestFakeTimersAreEnabled as j,getWindowFromNode as k,ariaSnapshot as l,envMaxLines as m,diffLines as n,logDOM as o,describeElement as p,configure as r,prettyDOM as s,diffAriaSnapshots as t,ariaSnapshotLines as u,nodeProps as v,envDebugFormat as w,truncate as x,quote as y};
|