"use strict";Liferay.Loader.define("@liferay!analytics-settings-web$testing-library/dom@8.20.0/dist/query-helpers",["module","exports","require","./suggestions","./matches","./wait-for","./config"],(function(e,t,r){window;{var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};Object.defineProperty(t,"__esModule",{value:!0}),t.buildQueries=function buildQueries(e,t,r){const n=wrapSingleQueryWithSuggestion(makeSingleQuery(e,t),e.name,"query"),i=makeGetAllQuery(e,r),u=makeSingleQuery(i,t),l=wrapSingleQueryWithSuggestion(u,e.name,"get"),o=wrapAllByQueryWithSuggestion(i,e.name.replace("query","get"),"getAll"),g=makeFindQuery(wrapAllByQueryWithSuggestion(i,e.name,"findAll")),s=makeFindQuery(wrapSingleQueryWithSuggestion(u,e.name,"find"));return[n,o,l,g,s]},t.getElementError=getElementError,t.getMultipleElementsFoundError=getMultipleElementsFoundError,t.makeFindQuery=makeFindQuery,t.makeGetAllQuery=makeGetAllQuery,t.makeSingleQuery=makeSingleQuery,t.queryAllByAttribute=queryAllByAttribute,t.queryByAttribute=function queryByAttribute(e,t,r,n){const i=queryAllByAttribute(e,t,r,n);if(i.length>1)throw getMultipleElementsFoundError(`Found multiple elements by [${e}=${r}]`,t);return i[0]||null},t.wrapSingleQueryWithSuggestion=t.wrapAllByQueryWithSuggestion=void 0;var i=r("./suggestions"),u=r("./matches"),l=r("./wait-for"),o=r("./config");function getElementError(e,t){return(0,o.getConfig)().getElementError(e,t)}function getMultipleElementsFoundError(e,t){return getElementError(e+"\n\n(If this is intentional, then use the `*AllBy*` variant of the query (like `queryAllByText`, `getAllByText`, or `findAllByText`)).",t)}function queryAllByAttribute(e,t,r,{exact:n=!0,collapseWhitespace:i,trim:l,normalizer:o}={}){const g=n?u.matches:u.fuzzyMatches,s=(0,u.makeNormalizer)({collapseWhitespace:i,trim:l,normalizer:o});return Array.from(t.querySelectorAll(`[${e}]`)).filter((t=>g(t.getAttribute(e),t,r,s)))}function makeSingleQuery(e,t){return(r,...n)=>{const i=e(r,...n);if(i.length>1){const e=i.map((e=>getElementError(null,e).message)).join("\n\n");throw getMultipleElementsFoundError(`${t(r,...n)}\n\nHere are the matching elements:\n\n${e}`,r)}return i[0]||null}}function getSuggestionError(e,t){return(0,o.getConfig)().getElementError(`A better query is available, try this:\n${e.toString()}\n`,t)}function makeGetAllQuery(e,t){return(r,...n)=>{const i=e(r,...n);if(!i.length)throw(0,o.getConfig)().getElementError(t(r,...n),r);return i}}function makeFindQuery(e){return(t,r,i,u)=>(0,l.waitFor)((()=>e(t,r,i)),n({container:t},u))}const wrapSingleQueryWithSuggestion=(e,t,r)=>(n,...u)=>{const l=e(n,...u),[{suggest:g=(0,o.getConfig)().throwSuggestions}={}]=u.slice(-1);if(l&&g){const e=(0,i.getSuggestedQuery)(l,r);if(e&&!t.endsWith(e.queryName))throw getSuggestionError(e.toString(),n)}return l};t.wrapSingleQueryWithSuggestion=wrapSingleQueryWithSuggestion;const wrapAllByQueryWithSuggestion=(e,t,r)=>(n,...u)=>{const l=e(n,...u),[{suggest:g=(0,o.getConfig)().throwSuggestions}={}]=u.slice(-1);if(l.length&&g){const e=[...new Set(l.map((e=>{var t;return null==(t=(0,i.getSuggestedQuery)(e,r))?void 0:t.toString()})))];if(1===e.length&&!t.endsWith((0,i.getSuggestedQuery)(l[0],r).queryName))throw getSuggestionError(e[0],n)}return l};t.wrapAllByQueryWithSuggestion=wrapAllByQueryWithSuggestion}}));
//# sourceMappingURL=query-helpers.js.map