objs-core 2.2.1 → 2.3.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 +17 -0
- package/objs.built.js +344 -33
- package/objs.built.min.js +56 -40
- package/objs.d.ts +19 -1
- package/objs.js +388 -30
- package/package.json +1 -1
package/objs.built.min.js
CHANGED
|
@@ -3,74 +3,90 @@
|
|
|
3
3
|
* @version 2.2
|
|
4
4
|
* @author Roman Torshin
|
|
5
5
|
* @license Apache-2.0
|
|
6
|
-
*/const ee=!0,t=n=>{let e={els:[],ie:{},delegated:{},parented:{},store:{},refs:{},_refsByIndex:[],states:[],isDebug:!1,currentState:"",savedStates:{},isRoot:!1,_parent:null},i=1,r=2,d=3,w="boolean",u="object",x="function",v="string",I="number",f="notEmptyString",S="undefined",m="dangerouslySetInnerHTML",O,y=t.D,C=-1,s=0,c=0,g=typeof process<"u"||t.D===t.DocumentMVP,a=0,L=0;const k=e,p=o=>typeof o,D=(o,l)=>{for(const h in o)Object.hasOwn(o,h)&&l(h,o)},N=t.onError,$=o=>t.verify(o),T=(o,l="")=>(...h)=>{(t.debug||e.isDebug)&&console.log(l?`${l}()`:o,h.length?"with "+h.join(", "):"without parameters");try{const E=o(h[0],h[i],h[r],h[d]);return E!==O?E:e}catch(E){N(E,l)}},R=o=>{for(a=s;a<=C;a++)o()},U=o=>o?.els?o.el:(p(o)!==u&&(o=t.first(o).el),o),J=(o=!0,l=e.els)=>{const h=l.length;if(e.length=h,C=h-i,s=0,e.el=h?l[0]:O,e.last=h?l[C]:O,o&&(D(e.states,(E,b)=>{delete e[b[E]]}),e.states=[],e.ie={}),Array.isArray(e._refsByIndex)){const E=e._refsByIndex.length;if(E>h)D(e._refsByIndex,b=>{const A=+b;A>=h&&delete e._refsByIndex[A]}),e._refsByIndex.length=h;else if(E<h)for(let b=E;b<h;b++)e._refsByIndex[b]={}}};e.reset=t;const G=o=>{if(g||!o.querySelectorAll)return;const l=o.querySelectorAll("[data-o-init]"),h={};l.forEach(E=>{const b=E.getAttribute("data-o-init");b!==null&&(h[b]||(h[b]=[]),h[b].push(E))}),D(h,E=>{const b=t.inits[E];b&&b.getSSR(Number(E),h[E])})},V=(o,l,h)=>{D(l,E=>{let b=l[E];p(b)===x&&(b=b(h)),E==="append"&&p(b)===u&&(b.els&&(b=[b]),b[0]?.els&&(valueBuff=[],D(b,A=>{valueBuff.push(...b[A].els)}),b=valueBuff)),b!==O&&o.getAttribute(E)!==b&&!["tag","tagName","name","sample","state","events","ssr","nodeName","revertChildren","root","ref"].includes(E)&&(["html","innerHTML"].includes(E)?(o.innerHTML=b,!g&&G(o)):E==="className"?o.setAttribute("class",b):E==="dataset"&&p(b)===u?D(b,A=>{o.dataset[A]=b[A]}):E==="toggleClass"?o.classList.toggle(b):E==="addClass"?p(b)===u?o.classList.add(...b):o.classList.add(b):E==="removeClass"?o.classList.remove(b):E==="style"&&p(b)===u?D(b,A=>{o.style[A]=b[A]}):(E==="append"||E==="children"||E==="childNodes")&&p(b)===u?D(b.length?b:[b],A=>{E==="append"||!o.childNodes[A]?o.appendChild(b[A]):o.childNodes[A]!==b[A]&&o.childNodes[A].replaceWith(b[A])}):o.setAttribute(E,b))}),o.dataset.oState=l.state,t.autotag&&l.name&&(o.dataset[t.autotag]=t.camelToKebab(l.name))};e.debug=T(()=>{e.isDebug=!0},"debug ON"),e.saveAs=T(o=>{$([[o,[f]]]),t.getSaved[o]?(t.debug||e.isDebug)&&console.warn("the key exists (not saved):"+o):t.getSaved[o]=e},"saveAs"),e.unmount=()=>((t.debug||e.isDebug)&&console.log("unmount() for initID:"+e.initID),p(e.remove)===x?e.remove():e.els?.length&&e.els.forEach(o=>{o?.parentNode&&o.parentNode.removeChild(o)}),t.inits[e.initID]=void 0,e={},!0),e.init=T(o=>{$([[o,[u,x]]]);const l=e.initID||t.inits.length||0;if(e.initID=l,J(),t.inits[e.initID]=e,p(o)==="function"){e.render=T(A=>{const _=y.createElement("div");setTimeout(()=>{t.reactRender(o,_,A)}),e.add(_)});return}(p(o)!==u||o.render===O)&&(o={render:o}),D(o,A=>{e?.render&&A==="render"||(e.states.push(A),e[A]=T((_=[{}])=>{e.currentState=A;const F=o[A]||{tag:"div"},j=Array.isArray(e.els)?e.els.slice(s,C+i):[],H=j.length?j:e.els||[];p(F)===u&&(F.state=A,F["data-o-init"]=l);const z=(q,P={})=>{const B=p(F)===x?F(P):F;if(p(B)===u)return y.createElement(B.tag||B.tagName||"div");const M=y.createElement("div");return M.innerHTML=B,M.children.length>i||!M.firstElementChild?(M.dataset.oInit=q,M):(M.firstElementChild.dataset.oInit=q,M.firstElementChild)},W=_;Array.isArray(_)||(_=[_]),_.length||(_=[_]);const K=!H[0]&&A==="render";_=_.map((q,P)=>{const B=Object.assign({},p(q)===u?q:{},{self:e,o:t,i:q.i===O?P:q.i,parent:e._parent,data:Array.isArray(W)?W[P]:W});return K&&(!F.ssr||g)&&H.push(z(l,B)),B}),K&&(e.els=H,J(!1));const Q=()=>{D(F.events,q=>{e.on(q,F.events[q])})};H&&(L=H.length===_.length,H.map((q,P)=>{_[L?P:0].i=P+s;const B=p(F)===x?F(_[L?P:0]):F;p(B)===u&&(B.state=A,K&&(B["data-o-init"]=l,B["data-o-init-i"]=P,B.events&&(e._hydrateEvents=e._hydrateEvents||[],e._hydrateEvents[P]=B.events)),V(q,B,_[L?P:0]))}),K&&(e._refsByIndex=[],e.refs={},e.els.forEach((q,P)=>{if(!q.querySelectorAll)return;const B={};q.querySelectorAll("[ref]").forEach(M=>{const Z=M.getAttribute("ref"),Y=t(M);B[Z]=Y,P===0&&(e.refs[Z]=Y)}),e._refsByIndex[P]=B}),!g&&e._hydrateEvents&&(e._hydrateEvents.forEach((q,P)=>{q&&(e.select(P),D(q,B=>{const M=q[B];if(p(M)===u&&M.targetRef&&p(M.handler)===x){const Y=(e._refsByIndex?.[P]??e.refs)?.[M.targetRef];Y&&Y.on(B,M.handler)}else p(M)===x&&e.on(B,M)}))}),e.all()))),K&&p(F)===u&&F.events&&!g&&!F.ssr&&Q()}))});const h=o.render||o,E=!g&&p(h)===u&&h.events,b=!g&&e._hydrateEvents&&e._hydrateEvents.length;(E||b)&&(e.initSSRAfterGettingSSR=()=>{e._refsByIndex=[],e.refs={},e.els.forEach((A,_)=>{if(!A.querySelectorAll)return;const F={};A.querySelectorAll("[ref]").forEach(j=>{const H=j.getAttribute("ref"),z=t(j);F[H]=z,_===0&&(e.refs[H]=z),j.removeAttribute("ref")}),e._refsByIndex[_]=F,_===0&&(e.refs=F)}),E&&D(h.events,A=>{e.on(A,h.events[A])}),e._hydrateEvents&&(e._hydrateEvents.forEach((A,_)=>{A&&(e.select(_),D(A,F=>{const j=A[F];if(p(j)===u&&j.targetRef&&p(j.handler)===x){const z=(e._refsByIndex?.[_]??e.refs)?.[j.targetRef];z&&z.on(F,j.handler)}else p(j)===x&&e.on(F,j)}))}),e.all())})},"init"),e.connect=T((o,l="render",h)=>{$([[o,[u]],[l,[f]],[h,[v,S]]]),o.connect(k,l,h)},"connect"),e.getSSR=T((o,l)=>{$([[o,[I,S]]]);const h=o!==void 0?o:e.initID;if(g||p(o)===S&&p(e.initID)===S)return;const E=l&&l.length?l:t.D.querySelectorAll(`[data-o-init="${h}"]`);E.length&&(e.els=Array.from(E),o!==void 0&&(e.initID=o,t.inits[o]=e),J(!1),p(e.initSSRAfterGettingSSR)===x?e.initSSRAfterGettingSSR():l&&l.length&&(e._refsByIndex=[],e.refs={},e.els.forEach((b,A)=>{if(!b.querySelectorAll)return;const _={};b.querySelectorAll("[ref]").forEach(F=>{const j=F.getAttribute("ref");_[j]=t(F),A===0&&(e.refs[j]=_[j]),F.removeAttribute("ref")}),e._refsByIndex[A]=_,A===0&&(e.refs=_)})))},"getSSR"),e.initState=T((o,l)=>{$([[o,[u]],[l,[u,S]]]),e.init(o).render(l)},"initState");const X=(o,l,h)=>{const E=o.attributes,b={tagName:o.tagName.toLowerCase()};for(const A of E)b[A.nodeName]=A.value;if(h){b.innerHTML=o.innerHTML,b.revertChildren=[];const A=o.querySelectorAll("[data-o-init]");for(const _ of A){const F=_.getAttribute("data-o-init");b.revertChildren.push(F),t.inits[F]?.saveState(l,!1)}}return b};return e.saveState=T((o,l=!0)=>{if($([[o,[f,S]],[l,[w]]]),!e.el)throw Error("saveState(): There are no elements to save");const h=o||"fastSavedState",E={els:[],parentNode:e.el.parentNode,root:l};R(()=>{E.els.push(X(e.els[a],h,l))}),E.ie=Object.assign({},e.ie),E.delegated=Object.assign({},e.delegated),E.store=Object.assign({},e.store),e.isRoot=e.isRoot||l,e.savedStates[h]=E},"saveState"),e.revertState=T(o=>{$([[o,[f,S]]]);const l=o||"fastSavedState";if(!e.savedStates[l])throw Error(`revertState(): The state "${l}" should have been saved by saveState()`);const h=e.savedStates[l];e.offAll(),e.offDelegate(),e.store=Object.assign({},h.store),h.els.forEach((E,b)=>{if(!e.els[b]){const A=t.D.createElement(E.tagName);h.parentNode&&(b?e.els[b-1].after(A):h.parentNode.append(A)),e.add(A)}V(e.els[b],E)}),e.delegated=Object.assign({},h.delegated),e.ie=Object.assign({},h.ie),e.onAll(),D(h.delegated,E=>{h.delegated[E].forEach(b=>{R(()=>{e.els[a].addEventListener(E,b)})})}),e.currentState=l,h.root&&h.els.forEach(({rootElement:E})=>{E.revertChildren.forEach(b=>{t.inits[b]?.revertState(l),t('[data-o-init="'+b+'"]').els.forEach((A,_)=>{A.replaceWith(t.inits[b]?.els[_])})})})},"revertState"),e.loseState=T(o=>{$([[o,[f]]]),e.savedStates[o]&&(delete e.savedStates[o],R(()=>{const l=e.els[a].querySelectorAll("[data-o-init]");for(const h of l){const E=h.getAttribute("data-o-init");t.inits[E]?.loseState(o)}}))},"sample"),e.sample=T((o="render")=>($([[o,[f]]]),{[o]:X(e.els[s])}),"sample"),e.select=T(o=>{let l=o;l!=null&&p(l)===u&&l.target&&e.els.length&&(l=e.els.findIndex(h=>h===l.target||h.contains(l.target)),l<0&&(l=0)),$([[l,[I,S]]]),l===O&&(l=e.length-i),C=l,s=l,e.el=e.els[l],c=i,Array.isArray(e._refsByIndex)&&e._refsByIndex[l]&&(e.refs=e._refsByIndex[l])},"select"),e.all=T(()=>{C=e.length-i,s=0,e.el=e.els[0],c=0,Array.isArray(e._refsByIndex)&&e._refsByIndex.length&&(e.refs=e._refsByIndex[0]||{})},"all"),e.remove=T(o=>{if($([[o,[I,S]]]),o===O&&c&&(o=s),o!==O){const l=e.els[o];l?.parentNode?l.parentNode.removeChild(l):l===void 0&&o>=e.els.length&&t.onError&&t.onError("remove("+o+"): index out of bounds","remove")}else R(()=>{const l=e.els[a];l?.parentNode&&l.parentNode.removeChild(l)});J(!1)},"remove"),e.skip=T(o=>{$([[o,[I,S]]]),o===O&&(o=s),e.els.splice(o,i),Array.isArray(e._refsByIndex)&&e._refsByIndex.splice(o,i),J()},"skip"),e.add=T(o=>{$([[o,[v,u,I]]]),e.initID===O&&(p(o)==="string"&&o!==""?e.els.push(...Array.from(y.querySelectorAll(o))):p(o)===u?o.tagName?e.els.push(o):o.els?e.els.push(...o.els):o.length&&o[0].tagName&&e.els.push(...o):p(o)==="number"&&t.inits[o]&&(e=t.inits[o]),J(!1),e.initID!==O&&e.dataset({oInit:e.initID}))},"add"),e.appendInside=T(o=>{$([[o,[u,f]]]),o?.els&&(e._parent=o),R(()=>{U(o).appendChild(e.els[a])})},"appendInside"),e.appendBefore=T(o=>{$([[o,[u,f]]]),R(()=>{U(o).parentNode.insertBefore(e.els[a],U(o))})},"appendBefore"),e.appendAfter=T(o=>{$([[o,[u,f]]]),R(()=>{U(o).after(...e.els)})},"appendAfter"),e.find=T((o="")=>{$([[o,v]]);const l=[];return R(()=>{l.push(...Array.from(e.els[a].querySelectorAll(":scope "+o)))}),t(l)},"find"),e.first=T((o="")=>{$([[o,v]]);let l=O;const h=[];return R(()=>{l=e.els[a].querySelector(o),l&&h.push(l)}),t(h)},"first"),e.attr=T((o,l)=>{if(l!==null&&$([[o,v],[l,[v,S]]]),l===O){const h=[];return R(()=>{h[a]=e.els[a].getAttribute(o)}),c?h[0]:h}else R(l!==null?()=>{e.els[a].setAttribute(o,l)}:()=>{e.els[a].removeAttribute(o)})},"attr"),e.attrs=T(()=>{const o=[];return R(()=>{const l={};[...e.els[a].attributes].forEach(h=>{l[h.nodeName]=h.nodeValue}),o.push(l)}),c?o[0]:o},"attrs"),e.dataset=T(o=>{if($([[o,[u,S]]]),typeof o===u)R(()=>{D(o,l=>{e.els[a].dataset[l]=o[l]})});else{const l=[];return R(()=>{l.push({...e.els[a].dataset})}),c?l[0]:l}},"dataset"),e.style=T(o=>{o!==null&&$([[o,[v,S]]]),e.attr("style",o)},"style"),e.css=T((o={})=>{if(o===null){e.style(null);return}$([[o,u]]);let l="";D(o,h=>{l+=h+":"+o[h].replace('"',"'")+";"}),e.style(l||null)},"css"),e.setClass=T(o=>{$([[o,v]]),R(()=>{e.els[a].setAttribute("class",o)})},"setClass"),e.addClass=T((...o)=>{R(()=>{e.els[a].classList.add(...o)})},"addClass"),e.removeClass=T((...o)=>{R(()=>{e.els[a].classList.remove(...o)})},"removeClass"),e.toggleClass=T((o,l)=>{$([[o,f],[l,[w,S]]]),R(()=>{e.els[a].classList.toggle(o,l)})},"toggleClass"),e.haveClass=o=>{$([[o,f]]);let l=!0;return R(()=>{e.els[a].classList.contains(o)||(l=!1)}),(e.isDebug||t.debug)&&console.log("haveClass() with",o),l},e.innerHTML=T(o=>{if($([[o,[v,S]]]),o!==O)R(()=>{e.els[a].innerHTML=o});else{let l="";return R(()=>{l+=g&&e.els[a].innerHTML.length===0?t.D.parseElement(e.els[a],!1):e.els[a].innerHTML}),l}},"innerHTML"),e.innerText=T(o=>{$([[o,[v]]]),R(()=>{e.els[a].innerText=o})},"innerText"),e.textContent=T(o=>{$([[o,[v]]]),R(()=>{e.els[a].textContent=o})},"textContent"),e.html=T(o=>{if($([[o,[v,S]]]),o!==void 0)e.innerHTML(o);else{let l="";return R(()=>{l+=g?e.els[a].outerHTML():e.els[a].outerHTML}),l}},"html"),e.toString=function(){return e.html()},e[Symbol.toPrimitive]=function(o){return o==="string"||o==="default"?e.html():o==="number"?e.els?.length??0:e.html()},e.val=T(o=>{if(o===void 0)return e.el?.value;R(()=>{e.els[a].value=o})},"val"),e.forEach=T(o=>{$([[o,[x]]]),R(()=>{o({self:e,i:a,o:t,el:e.els[a]})})},"forEach"),e.prepareFor=T((o,l)=>{$([[o,[u,x,S]],[l,[x,S]]]);const h=o&&p(o)===u&&o.createElement;if(!h&&p(o)!==x)throw Error("prepareFor(): pass React (full object) or React.createElement as first argument");const E=h?o.createElement:o,b=h?o.useEffect:void 0;return A=>{if(A.ref===O)throw Error("No ref property to convert Objs to React");const _=Object.assign({},A),F=E("div",{ref:A.ref});return delete _.ref,b(()=>{D(_,j=>{if(j.substring(0,1)==="on"){const H=t.camelToKebab(j).split("-")[1];e.on(H,_[j]),delete _[j]}}),e.render(_),e.appendInside(F.ref.current)},[]),F}},"prepareFor"),e.on=T((o,l,h,E)=>{$([[o,[f]],[l,[x]],[h,[u,S]],[E,[w,S]]]),o.split(", ").forEach(b=>{R(()=>{e.els[a].addEventListener(b,l,h,E)}),e.ie[b]||(e.ie[b]=[]),e.ie[b].push([l,h,E])})},"on"),e.off=T((o,l,h)=>{$([[o,[f]],[l,[x]],[h,[u,S]]]),o.split(", ").forEach(E=>{R(()=>{e.els[a].removeEventListener(E,l,h)}),e.ie[E]&&(e.ie[E]=e.ie[E].filter(b=>b[0]!==l))})},"off"),e.onDelegate=T((o,l,h)=>{$([[o,[f]],[l,[f]],[h,[x]]]),o.split(", ").forEach(E=>{const b=A=>{const _=A.target.closest(l);_&&(A.delegate=_,A.objs=e,h(A))};R(()=>{e.els[a].addEventListener(E,b)}),e.delegated[E]||(e.delegated[E]=[]),e.delegated[E].push(b)})},"onDelegate"),e.offDelegate=T(o=>{$([[o,[f]]]),D(e.delegated,l=>{if(!o||o===l)for(;e.delegated[l].length;){const h=e.delegated[l].pop();R(()=>{e.els[a].removeEventListener(l,h)})}}),e.delegated={}},"offDelegate"),e.onParent=T((o,l,h)=>{$([[o,[f]],[l,[f,u]],[h,[x]]]);const E=p(l)===u?l:t.D.querySelector(l);o.split(", ").forEach(b=>{const A=_=>{_.objs=e,h(_)};E.addEventListener(b,A),e.parented[b]||(e.parented[b]=[]),e.parented[b].push(A)})},"onParent"),e.offParent=T((o,l)=>{$([[o,[f]],[l,[f,u]]]);const h=p(l)===u?l:t.D.querySelector(l);D(e.parented,E=>{(!o||o===E)&&(e.parented[E].forEach(b=>{h.removeEventListener(E,b)}),delete e.parented[E])})},"offParent"),e.onAll=T((o,l)=>{$([[o,[f,S]],[l,[w,S]]]),D(e.ie,(h,E)=>{(!o||o===h)&&E[h].forEach(b=>{R(()=>{l?e.els[a].removeEventListener(h,b[0]):e.els[a].addEventListener(h,b[0],b[i],b[r])})})})},"onAll"),e.offAll=T(o=>{$([[o,[f]]]),e.onAll(o,i)},"offAll"),n&&e.add(n),e.take=o=>{if($([[o,[v,u,I]]]),e.add(o),e.el){const l=e.el.dataset.oInit;if(l!==O&&t.inits[l])return e.length===i?(L=e.els[0],Object.assign(e,t.inits[l]),e.els=[L]):e=t.inits[l],J(!1,e.els),e}},e};t.first=n=>(t.verify([[n,["notEmptyString"]]]),t.debug&&console.log(n," -> ","o.first()"),t(t.D.querySelector(n)).select(0)),t.inits=[],t.getSaved={},t.errors=[],t.showErrors=!1,t.logErrors=()=>{t.errors.length?t.errors.forEach(n=>console.error(n)):console.log("No errors")},t.onError=(n,e)=>{t.showErrors?console.error(n,e):(t.errors.push(n),e&&t.errors.push(e))},t.reactRender=()=>new Error("React render function is not defined"),t.autotag=void 0,t.reactQA=n=>({["data-"+(t.autotag||"qa")]:n.replace(/([A-Z])/g,(e,i)=>"-"+i.toLowerCase()).replace(/^-/,"")}),t.specialTypes={notEmptyString:(n,e)=>e==="string"&&n.length,array:n=>Array.isArray(n),promise:n=>n instanceof Promise||!!(n&&typeof n.then=="function")},t.verify=(n,e=!1)=>{for(const i of n){const r=typeof i[0];let d=Array.isArray(i[1])?i[1]:[i[1]],w=!1;if(d.includes(r))return!0;d=d.filter(u=>!!t.specialTypes[u]);for(const u of d)if(w=t.specialTypes[u](i[0],r),w)return!0}return e?!1:new Error("Type verification failed")},t.safeVerify=n=>t.verify(n,!0),t.init=(n,e)=>t().init(n,e),t.initState=(n,e)=>t().init(n).render(e),t.take=n=>t().take(n),t.getStates=()=>t.inits.reduce((n,e)=>(n.push(e?.states),n),[]),t.getStores=()=>t.inits.reduce((n,e)=>(n.push(e?.store),n),[]),t.getListeners=()=>t.inits.reduce((n,e)=>(n.push(e?.ie),n),[]),t.createStore=n=>{const e=Object.assign({},n);return e._defaults=Object.assign({},n),e._listeners=[],e.subscribe=function(i,r){return this._listeners.push(d=>i[r]?.(d)),this},e.notify=function(){this._listeners.forEach(i=>i(this))},e.reset=function(){const i={_listeners:1,subscribe:1,notify:1,_defaults:1,reset:1};for(const r of Object.keys(this._defaults))i[r]||(this[r]=this._defaults[r])},e},t.U=void 0,t.W=2,t.H=100,t.F=!1,t.C=(n,e)=>Object.hasOwn(n,e),t.kebabToCamel=n=>n.replace(/-./g,e=>e.toUpperCase()[1]),t.camelToKebab=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),t.route=(n,e)=>{t.verify([[n,["notEmptyString","function","boolean"]],[e,["function","object"]]]);const i=typeof n=="function"?n(window.location.pathname):n;return i===!0||window.location.pathname===i?e?typeof e=="function"?(e(),!0):e:t:typeof e=="function"?!1:{}},t.router=(n={})=>{t.verify([[n,["object"]]]);for(const e in n)if(t.C(n,e)&&window.location.pathname===e)return typeof n[e]=="function"?(n[e](),!0):n[e];return!1},t.DocumentMVP={addEventListener:()=>{},parseElement:(n,e=!0)=>{t.verify([[n,["object","string"]],[e,["boolean"]]]);const i=(r,d="")=>{let w="";for(const u in r)t.C(r,u)&&(w+=` ${d}${t.camelToKebab(u)}="${typeof r[u]!="object"?r[u]:Object.entries(r[u]).map(x=>`${x[0]}: ${x[1]};`).join(" ")}"`);return w};if(typeof n=="string")return n;if(e){const r=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],d=n.tagName.toLowerCase(),w=n.attributes["data-o-init"],u=w!==void 0?` data-o-init="${w}"`:"";return`<${d}${n.className?` class="${n.className}"`:""}${i(n.attributes)}${u}${i(n.dataset,"data-")}${r.includes(d)?"/":""}>${r.includes(d)?"":n.innerHTML.length?n.innerHTML:n.children.map(x=>t.D.parseElement(x)).join("")}${r.includes(d)?"":`</${d}>`}`}return n.innerHTML.length?n.innerHTML:n.children.map(r=>t.D.parseElement(r)).join("")},createElement:n=>{t.verify([[n,["notEmptyString"]]]);const e={tagName:n.toUpperCase(),attributes:{},innerHTML:"",children:[],dataset:{},className:"",classArray:[],style:{},addEventListener:()=>{},removeEventListener:()=>{}};return e.classList={add:(...i)=>{t.verify([[i,["array"]]]),e.classArray.push(i),e.className=e.classArray.join(" ")},has:i=>(t.verify([[i,["notEmptyString"]]]),e.classArray.includes(i)),remove:i=>{t.verify([[i,["notEmptyString"]]]),e.classArray=e.classArray.filter(r=>i!==r),e.className=e.classArray.join(" ")}},e.classList.toggle=i=>{t.verify([[i,["notEmptyString"]]]),e.classList.has(i)?e.classList.remove(i):e.classList.add(i)},e.setAttribute=(i,r)=>{t.verify([[i,["notEmptyString"]],[r,["string","number","boolean","undefined"]]]),e.attributes[i]=r},e.getAttribute=i=>(t.verify([[i,["notEmptyString"]]]),e.attributes[i]),e.removeAttribute=i=>{t.verify([[i,["notEmptyString"]]]),delete e.attributes[i]},e.appendChild=i=>{t.verify([[i,["object"]]]),e.children.push(i),e.firstElementChild=e.children[0]},e.outerHTML=()=>t.D.parseElement(e),e}},t.D=typeof document<"u"&&typeof process>"u"?document:t.DocumentMVP,t.setCookie=(n,e="",i={})=>{if(t.verify([[n,["notEmptyString"]],[e,["string","number","boolean"]],[i,["object"]]]),t.D.cookie===void 0){console.log("Cookies are not supported on server side");return}let r=encodeURIComponent(n)+"="+encodeURIComponent(e);i={path:"/",...i},i.expires instanceof Date?i.expires=i.expires.toUTCString():typeof i.expires=="number"&&(i.expires=new Date(i.expires).toUTCString());for(const d in i){r+="; "+d;const w=i[d];w!==!0&&(r+="="+w)}t.D.cookie=r},t.getCookie=n=>{if(t.verify([[n,["notEmptyString"]]]),t.D.cookie===void 0){console.log("Cookies are not supported on server side");return}const e=t.D.cookie.match(RegExp("(?:^|; )"+n.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0},t.deleteCookie=n=>{t.verify([[n,["notEmptyString"]]]),t.setCookie(n,"",{"max-age":0})},t.clearCookies=()=>{if(t.D.cookie===void 0){console.log("Cookies are not supported on server side");return}const n=t.D.cookie.split(";");for(;n.length;){let e=n.pop();for(;e.charAt(0)===" ";)e=e.substring(1);const i=e.split("=")[0];t.deleteCookie(i)}},t.clearLocalStorage=n=>{if(t.verify([[n,["boolean","undefined"]]]),!(typeof localStorage>"u"))if(n)localStorage.clear();else for(let e=localStorage.length-1;e>=0;e--){const i=localStorage.key(e);i.indexOf("oInc-")===-1&&i.indexOf("oTest-")===-1&&localStorage.removeItem(i)}},t.clearSessionStorage=n=>{if(t.verify([[n,["boolean","undefined"]]]),!(typeof sessionStorage>"u"))if(!n)sessionStorage.clear();else for(let e=sessionStorage.length-1;e>=0;e--){const i=sessionStorage.key(e);i&&i.indexOf("oTest-")===0&&sessionStorage.removeItem(i)}},t.clearTestsStorage=()=>{t.clearSessionStorage(1)},t.clearAfterTests=()=>{t.clearCookies(),t.clearLocalStorage(!1),t.clearTestsStorage()},t.ajax=(n,e={})=>{t.verify([[n,["notEmptyString"]],[e,["object"]]]);const i=new URLSearchParams;if(e.data&&typeof e.data=="object"){for(const r in e.data)t.C(e.data,r)&&(typeof e.data[r]=="object"?i.set(r,encodeURIComponent(JSON.stringify(e.data[r]))):i.set(r,e.data[r]));e.method.toLowerCase()==="get"?n+="?"+i.toString():e.body||(e.body=i),delete e.data}return e.headers||(e.headers={"X-Requested-With":"XMLHttpRequest"}),fetch(n,e)},t.get=(n,e={})=>(t.verify([[n,["notEmptyString"]],[e,["object"]]]),t.ajax(n,{...e,method:"GET"})),t.post=(n,e={})=>(t.verify([[n,["notEmptyString"]],[e,["object"]]]),t.ajax(n,{...e,method:"POST"})),t.newLoader=n=>{t.verify([[n,["promise","undefined"]]]);let e=[],i=null,r=!1,d=!1;const w=u=>{r=!1,d=!1,i=null,setTimeout(()=>{u.then(x=>{r=!0,!x.ok&&typeof x.ok<"u"?(d=!0,e.forEach(([v,I,f])=>{f&&v[f](x)})):typeof x.json=="function"?x.json().then(v=>{i=v,e.forEach(([I,f])=>{I[f](i)})}):(i=x,e.forEach(([v,I])=>{v[I](i)}))}).catch(x=>{d=!0,e.forEach(([v,I,f])=>{f&&v[f](x)})})},33)};return n&&w(n),{reload:w,isObjsLoader:!0,listeners:e,isFinished:()=>r,getStore:()=>i,connect:(u,x="render",v)=>{t.verify([[u,["object"]],[x,["notEmptyString"]],[v,["string","undefined"]]]),r?d?v&&u[v]():typeof u[x]=="function"&&u[x](i):e.push([u,x,v])},disconnect:u=>{t.verify([[u,["object"]]]),e=e.filter(([x])=>x!==u)}}},t.getParams=n=>{t.verify([[n,["string","undefined"]]]);const e={},i=new URLSearchParams(window.location.search).entries();for(const r of i)e[r[0]]=r[1];return n?e[n]:e},t.incCache=!0,t.incCacheExp=1e3*60*60*24,t.incTimeout=6e3,t.incSource="",t.incForce=t.F,t.incAsync=!0,t.incCors=t.F,t.incSeparator="?",t.incFns={},t.incSet=[0],t.incReady=[0],t.incN=0,t.incGetHash=n=>n.split(t.incSeparator)[1]||"",t.incCheck=(n=0,e,i=0)=>(t.verify([[n,["number"]],[e,["number","undefined"]],[i,["number"]]]),!i&&n&&e===t.U&&t.incReady[n]?t.incSet[n]===1:t.incReady[n]===t.U||t.incReady[n][e]===t.U?t.F:(t.incReady[n][e].loaded=i,t.incFns[t.incReady[n][e].name]=i,t.incReady[n][0]+=i,n&&t.incReady[n].length===t.incReady[n][0]&&(typeof t.incSet[n]=="function"&&t.incSet[n](n),t.incSet[n]=1),t.incSet[n]===1)),t.incCacheClear=(n=t.F)=>{t.verify([[n,["boolean"]]]);for(const e in t.incFns)t.C(t.incFns,e)&&(localStorage.removeItem("oInc-"+e),localStorage.removeItem("oInc-"+e+"-expires"));return n&&(t.incReady.forEach((e,i)=>{i&&e.forEach((r,d)=>{d&&t("#oInc-"+i+"-"+d).remove()})}),t.incN=0,t.incFns={},t.incSet=[0],t.incReady=[0]),!0},t.inc=(n,e,i)=>{if(t.verify([[n,["object","undefined"]],[e,["function","undefined"]],[i,["function","undefined"]]]),typeof localStorage>"u")return;let r=0,d=0,w="",u=!1;const x="function",v=-1;if(typeof n!="object"||!n)return t.incSet[0];t.incSet[0]++;const I=t.incSet[0];t.incSet[I]=e||0,t.incReady[I]=[];const f=t.incReady[I];f[0]=1;const S={};for(const m in n)if(t.C(n,m)){if(m==="preload"){u=!0;continue}w=t.incGetHash(n[m]),r++,t.incN++;const O=n[m].indexOf(".css")>v?"style":"script";if(n[m]=(t.incSource?t.incSource+"/":"")+n[m],Number.isNaN(Number(m))&&t.C(t.incFns,m)&&t.incFns[m]&&!t.incForce){f[r]={name:m,loaded:1},d++;continue}if(f[r]={name:m,loaded:0},Number.isNaN(Number(m))&&(t.incFns[m]=0),Number.isNaN(Number(m))&&t.incCache&&(n[m].substring(0,4)!=="http"||!t.incCors)&&window.location.protocol!=="file:"&&(n[m].indexOf(".css")>v||n[m].indexOf(".js")>v)){const y=localStorage,C=y.getItem("oInc-"+m),s=y.getItem("oInc-"+m+"-expires"),c=y.getItem("oInc-"+m+"-hash");C&&s&&Date.now()<s&&c===w?(u||t.initState({tag:O,id:"oInc-"+I+"-"+r,innerHTML:C,"data-o-inc":I}).appendInside("head"),f[r].loaded=1,t.incFns[m]=1,d++):(S[m]=r,t.get(n[m],{mode:t.incCors?"cors":"same-origin"}).then(g=>{if(g.status!==200){t.onError&&t.onError({message:t.incSource+n[m]+" was not loaded"});return}g.text().then(a=>{y.setItem("oInc-"+m,a),y.setItem("oInc-"+m+"-expires",Date.now()+t.incCacheExp),y.setItem("oInc-"+m+"-hash",w),u||t.initState({tag:O,id:"oInc-"+I+"-"+S[m],innerHTML:a,"data-o-inc":I}).appendInside("head"),t.incCheck(I,S[m],1)})}))}else{const y={tag:O,id:"oInc-"+I+"-"+r,"data-o-inc":I,async:t.incAsync,onload:"o.incCheck("+I+","+r+",1)"};n[m].indexOf(".css")>v?(y.tag="link",y.rel="stylesheet",y.href=n[m]):(n[m].indexOf(".js")>v||(y.tag="img",y.style="display:none;"),y.src=n[m]),t.initState(y).appendInside(y.style?"body":"head")}}return f[0]+=d,r!==0&&(d===r?typeof e===x&&e(I):setTimeout(m=>{t.incReady[m]&&t.incReady[m].length<t.incReady[m][0]&&(t.incSet[m]=0,typeof i===x&&i(I))},t.incTimeout,I)),t.incSet[0]},t.connectRedux=(n,e,i,r="render")=>{t.verify([[n,["object"]],[e,["function"]],[i,["object"]],[r,["notEmptyString"]]]);const d=()=>{if(typeof i[r]=="function"){const w=e(n.getState());i[r](w!==null&&typeof w=="object"?w:{value:w})}};return d(),n.subscribe(d)},t.connectMobX=(n,e,i,r,d="render")=>(t.verify([[n,["object"]],[e,["object"]],[i,["function"]],[r,["object"]],[d,["notEmptyString"]]]),n.autorun(()=>{if(typeof r[d]=="function"){const w=i(e);r[d](w!==null&&typeof w=="object"?w:{value:w})}})),t.ObjsContext=null,t.withReactContext=(n,e,i,r,d="render")=>function(){const u=n.useContext(e);return n.useEffect(()=>{if(typeof r[d]=="function"){const x=i(u);r[d](x!==null&&typeof x=="object"?x:{value:x})}},[u]),null},t.debug=!1,t.sleep=n=>new Promise(e=>setTimeout(e,n)),t.tLog=[],t.tRes=[],t.tStatus=[],t.tFns=[],t.tShowOk=t.F,t.tStyled=t.F,t.tTime=2e3,t.tests=[],t.tExpectedSteps={},t.tFinalized={},t.tAutolog=t.F,t.tBeforeEach=void 0,t.tAfterEach=void 0,t.addTest=(n,...e)=>{t.verify([[n,["notEmptyString"]],[e,["array"]]]);let i={};e.length&&typeof e[e.length-1]=="object"&&!Array.isArray(e[e.length-1])&&(i=e.pop());const r=t.tests.length;return t.tests[r]={title:n,tests:e,hooks:i},{run:()=>{typeof i.before=="function"&&(t.tBeforeEach=i.before),typeof i.after=="function"&&(t.tAfterEach=i.after),t.runTest(r)},autorun:()=>{typeof i.before=="function"&&(t.tBeforeEach=i.before),typeof i.after=="function"&&(t.tAfterEach=i.after),t.runTest(r,!0)},testId:r}},t.updateLogs=()=>{for(let n=0;n<t.tests.length;n++)t.tLog[n]=t.tLog[testN]=sessionStorage.getItem(`oTest-Log-${testN}`)||"";return t.tLog},t.runTest=(n=0,e,i)=>{if(t.verify([[n,["number"]],[e,["boolean","undefined"]],[i,["boolean","undefined"]]]),!t.tests[n])return;i||(sessionStorage?.removeItem(`oTest-Log-${n}`),sessionStorage?.removeItem(`oTest-Res-${n}`),sessionStorage?.removeItem(`oTest-Status-${n}`)),sessionStorage?.setItem("oTest-Run",n),e?sessionStorage?.setItem("oTest-Autorun",e):sessionStorage?.removeItem("oTest-Autorun");const r=t.tests[n];let d=r.tests.pop();typeof d!="function"&&(r.tests.push(d),d=()=>{}),r.tests.push(w=>{d(w),sessionStorage.setItem("dddd",1),sessionStorage?.removeItem("oTest-Run"),e&&t.runTest(n+1,e)}),t.test(r.title,...r.tests)},t.tPre='<div style="font-family:monospace;text-align:left;">',t.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',t.tXx='<div style="background:#fcc;padding:3px;">',t.tDc="</div>",t.test=(n="",...e)=>{t.verify([[n,["notEmptyString"]],[e,["array"]]]);const i=sessionStorage?.getItem("oTest-Run"),r=i||t.tLog.length;let d=0,w="\u251C OK: ",u="\u251C \u2718 ",x=`
|
|
7
|
-
`,
|
|
8
|
-
`,
|
|
9
|
-
`,t.tRes[r]=t.F,t.tStatus[r]=[]),t.tExpectedSteps[r]=
|
|
10
|
-
|
|
11
|
-
`,
|
|
12
|
-
`,
|
|
13
|
-
|
|
14
|
-
`)
|
|
15
|
-
`,typeof t.tFns[d]=="function"&&t.tFns[d](d)}},sessionStorage?.getItem("oTest-Run")&&window?.addEventListener("load",()=>{t.runTest(sessionStorage?.getItem("oTest-Run"),sessionStorage?.getItem("oTest-Autorun")||t.F,!0)},!1),t.measure=n=>{if(!n)return{};const e=n.getBoundingClientRect(),i=window.getComputedStyle(n);return{width:e.width,height:e.height,top:e.top,left:e.left,visible:i.display!=="none"&&i.visibility!=="hidden"&&e.width>0,opacity:i.opacity,zIndex:i.zIndex}},t.assertVisible=n=>!!t.measure(n).visible,t.assertSize=(n,e={})=>{if(!n)return"element is null";const i=t.measure(n);if(e.w!==void 0&&Math.round(i.width)!==e.w)return`width: expected ${e.w}, got ${Math.round(i.width)}`;if(e.h!==void 0&&Math.round(i.height)!==e.h)return`height: expected ${e.h}, got ${Math.round(i.height)}`;const r=d=>{const w=window.getComputedStyle(n).getPropertyValue(d);return w?parseFloat(w):0};return e.padding!==void 0&&r("padding-top")!==e.padding?`padding: expected ${e.padding}, got ${r("padding-top")}`:e.paddingTop!==void 0&&r("padding-top")!==e.paddingTop?`paddingTop: expected ${e.paddingTop}, got ${r("padding-top")}`:e.paddingRight!==void 0&&r("padding-right")!==e.paddingRight?`paddingRight: expected ${e.paddingRight}, got ${r("padding-right")}`:e.paddingBottom!==void 0&&r("padding-bottom")!==e.paddingBottom?`paddingBottom: expected ${e.paddingBottom}, got ${r("padding-bottom")}`:e.paddingLeft!==void 0&&r("padding-left")!==e.paddingLeft?`paddingLeft: expected ${e.paddingLeft}, got ${r("padding-left")}`:e.margin!==void 0&&r("margin-top")!==e.margin?`margin: expected ${e.margin}, got ${r("margin-top")}`:e.marginTop!==void 0&&r("margin-top")!==e.marginTop?`marginTop: expected ${e.marginTop}, got ${r("margin-top")}`:e.marginRight!==void 0&&r("margin-right")!==e.marginRight?`marginRight: expected ${e.marginRight}, got ${r("margin-right")}`:e.marginBottom!==void 0&&r("margin-bottom")!==e.marginBottom?`marginBottom: expected ${e.marginBottom}, got ${r("margin-bottom")}`:e.marginLeft!==void 0&&r("margin-left")!==e.marginLeft?`marginLeft: expected ${e.marginLeft}, got ${r("margin-left")}`:!0},t.recorder={active:!1,actions:[],mocks:{},initialData:{},assertions:[],observeRoot:null,_originalFetch:null,_listeners:[],_observer:null},t.recordingAssertionDebug=!1,t.startRecording=(n,e,i)=>{if(t.recorder.active)return;const r=["click","mouseover","scroll","input","change"],d={click:100,mouseover:50,scroll:30,input:50,change:50},w=e||r,u=Object.assign({},d,i||{}),x={scroll:30,mouseover:50},v=t.recorder;v.active=!0,v.actions=[],v.mocks={},v.stepDelays=u,v.initialData={url:window.location.href,timestamp:Date.now()},v.observeRoot=n||null,v.assertions=[],v.removedElements=[],t.inits.forEach((y,C)=>{y?.store&&(v.initialData["init_"+C]=JSON.parse(JSON.stringify(y.store)))}),v._originalFetch=window.fetch,window.fetch=async(y,C={})=>{const s=(C.method||"GET").toUpperCase();let c;try{c=C.body?JSON.parse(C.body):void 0}catch{c=C.body}const g=await v._originalFetch(y,C),a=g.clone();let L;try{L=await a.json()}catch{L=await a.text().catch(()=>null)}const k=s+":"+y;return v.mocks[k]={url:y,method:s,request:c,response:L,status:g.status},g};const I={"data-o-init":1,"data-o-init-i":1,"data-o-state":1},f=(y,C)=>{if(t.D.querySelectorAll(y).length<=1)return y;let s=C;for(;s&&s!==t.D.body;){let c=s.id?"#"+s.id:null;if(!c&&s.attributes){const g=t.autotag?"data-"+t.autotag:null;if(g){const a=s.getAttribute(g);a!=null&&(c=`[${g}="${a}"]`)}if(!c){for(const a of s.attributes)if(a.name.startsWith("data-")&&!I[a.name]){c=`[${a.name}="${a.value}"]`;break}}}if(c){const g=c+" "+y;if(t.D.querySelectorAll(g).length===1)return g}s=s.parentElement}return y},S=y=>{if(!y||y.nodeType!==1)return"";let C="";if(y.dataset){const s=t.autotag&&y.dataset[t.autotag];s&&(C=f(`[data-${t.autotag}="${s}"]`,y.parentElement))}if(!C&&y.tagName){const s=y.id?"#"+y.id:y.className?y.tagName.toLowerCase()+"."+[...y.classList].join("."):y.tagName.toLowerCase();C=y.id?s:f(s,y.parentElement)}return C},m=n&&t.D.querySelector(n)||t.D.body;v._observer=new MutationObserver(y=>{const C=v.actions.length-1;if(C<0)return;const s=v.actions[C];t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] MutationObserver batch:",{actionIdx:C,lastAction:s?{type:s.type,target:s.target}:null,mutationTypes:y.map(c=>c.type),addedCount:y.reduce((c,g)=>c+(g.addedNodes?.length||0),0),removedCount:y.reduce((c,g)=>c+(g.removedNodes?.length||0),0)}),y.forEach(c=>{const g=(a,L)=>{let k,p;if(a&&m&&m.querySelectorAll(a).length>1){let N=L;for(;N&&N!==m&&N.nodeType===1;){const $=t.autotag&&N.dataset&&N.dataset[t.autotag];if($){const T=`[data-${t.autotag}="${$}"]`,R=m.querySelectorAll(T);if(R.length>1){const U=[...R].indexOf(N);if(U!==-1){k=T,p=U;break}}}N=N.parentElement}}return{listSelector:k,index:p}};if(c.type==="childList"&&(c.addedNodes.forEach(a=>{if(a.nodeType!==1||!a.offsetParent)return;const L=S(a);if(!L||v.assertions.some($=>$.actionIdx===C&&$.selector===L&&$.type==="visible"))return;const k=(a.textContent?.trim()||"").slice(0,80)||void 0,{listSelector:p,index:D}=g(L,a),N={actionIdx:C,type:"visible",selector:L,text:k};p!=null&&(N.listSelector=p),D!=null&&(N.index=D),v.assertions.push(N),t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] +visible assertion:",{actionIdx:C,lastAction:s?.type+" "+s?.target,selector:L,text:(k||"").slice(0,40),index:D,listSelector:p})}),c.removedNodes.forEach(a=>{if(a.nodeType!==1)return;const L=S(a);if(!L)return;const k=(a.textContent?.trim()||"").slice(0,80)||void 0,p=c.target;let D;a.previousSibling?D=Array.from(p.children).indexOf(a.previousSibling)+1:a.nextSibling?D=Array.from(p.children).indexOf(a.nextSibling):D=0;let N;if(t.autotag&&a.dataset?.[t.autotag]){const T=a.dataset[t.autotag];N=`[data-${t.autotag}="${T}"]`}const $={actionIdx:C,type:"removed",selector:L,text:k};N&&($.listSelector=N),$.index=D,v.removedElements.push($),t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] +removed element:",{actionIdx:C,lastAction:s?.type+" "+s?.target,selector:L,text:(k||"").slice(0,40),index:D,listSelector:N})})),c.type==="attributes"){const a=S(c.target);if(!a||v.assertions.some(D=>D.actionIdx===C&&D.selector===a&&D.type==="class"))return;const{listSelector:L,index:k}=g(a,c.target),p={actionIdx:C,type:"class",selector:a,className:c.target.className};L!=null&&(p.listSelector=L),k!=null&&(p.index=k),v.assertions.push(p),t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] +class assertion:",{actionIdx:C,lastAction:s?.type+" "+s?.target,selector:a,className:c.target.className,index:k,listSelector:L})}})}),v._observer.observe(m,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","disabled","aria-expanded","aria-checked"]});const O={};w.forEach(y=>{const C=s=>{const c=s.target;if(n&&m&&c?.nodeType===1&&!m.contains(c))return;let g="";if(c?.dataset){const R=t.autotag&&c.dataset[t.autotag];R&&(g=f(`[data-${t.autotag}="${R}"]`,c.parentElement))}if(!g&&c?.tagName){const R=c.id?"#"+c.id:c.className?c.tagName.toLowerCase()+"."+[...c.classList].join("."):c.tagName.toLowerCase();g=c.id?R:f(R,c.parentElement)}let a,L;if(g&&m&&m.querySelectorAll(g).length>1){let U=c;for(;U&&U!==m&&U.nodeType===1;){const J=t.autotag&&U.dataset&&U.dataset[t.autotag];if(J){const G=`[data-${t.autotag}="${J}"]`,V=m.querySelectorAll(G);if(V.length>1){const X=[...V].indexOf(U);if(X!==-1){a=G,L=X;break}}}U=U.parentElement}}const k=c?.tagName?c.tagName.toLowerCase()+(c.type?":"+c.type:""):void 0,p=y==="scroll"?window.scrollY:void 0,D=y==="input"||y==="change"?c?.value:void 0,N=y==="change"&&(c?.type==="checkbox"||c?.type==="radio")?c?.checked:void 0,$=y==="click"||y==="change"?0:u[y]!==void 0?u[y]:x[y]??0,T=()=>{const R={type:y,target:g,time:Date.now()};k&&(R.targetType=k),p!==void 0&&(R.scrollY=p),D!==void 0&&(R.value=D),N!==void 0&&(R.checked=N),a!=null&&(R.listSelector=a),L!=null&&(R.targetIndex=L),v.actions.push(R)};$===0?T():(clearTimeout(O[y]),O[y]=setTimeout(T,$))};t.D.addEventListener(y,C,!0),v._listeners.push({ev:y,handler:C})})},t.stopRecording=()=>{const n=t.recorder;return n.active=!1,n._originalFetch&&(window.fetch=n._originalFetch,n._originalFetch=null),n._listeners.forEach(({ev:e,handler:i})=>{t.D.removeEventListener(e,i,!0)}),n._listeners=[],n._observer&&(n._observer.disconnect(),n._observer=null),{actions:[...n.actions],mocks:{...n.mocks},initialData:{...n.initialData},stepDelays:{...n.stepDelays},assertions:[...n.assertions||[]],removedElements:[...n.removedElements||[]],observeRoot:n.observeRoot||null}},t.clearRecording=n=>{if(n!==void 0)sessionStorage?.removeItem("oTest-Recording-"+n);else for(let e=sessionStorage?.length-1;e>=0;e--){const i=sessionStorage?.key(e);i&&i.indexOf("oTest-Recording-")===0&&sessionStorage?.removeItem(i)}},t.runRecordingAssertions=(n,e,i,r)=>{const d=r&&r.assertions,w=d??(n.assertions||[]).filter(s=>i==null||s.actionIdx===i);t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[runRecordingAssertions] run:",{actionIdx:i,scope:i==null?"teardown (all)":"per-action",assertionsCount:w.length,assertions:w.map(s=>({actionIdx:s.actionIdx,type:s.type,selector:s.selector,index:s.index,text:(s.text||"").slice(0,40)}))});const u=new Set,x=w.filter(s=>{const c=`${s.selector}|${s.type}|${s.actionIdx}|${s.index??""}`;return u.has(c)?!1:(u.add(c),!0)}),I=(()=>{if(e!=null)return typeof e=="string"?t.D.querySelector(e)||t.D.body:e;const s=n.observeRoot;return s&&t.D.querySelector(s)||t.D.body})(),f=s=>(s||"").trim().replace(/\s+/g," "),S=s=>s?f(s.textContent||""):"",m=r?.removedElements||[],O=s=>{if(!m.length||i==null)return!1;const c=f(s.text||"");for(const g of m)if(!(g.actionIdx>i)&&f(g.text||"")===c&&g.selector===s.selector&&!(s.listSelector!=null&&g.listSelector!==s.listSelector)&&!(s.index!=null&&g.index!==s.index))return!0;return!1};let y=0;const C=[];for(const s of x){if(O(s)){y+=1,t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[runRecordingAssertions] skip (explicit removed):",{actionIdx:s.actionIdx,selector:s.selector,text:(s.text||"").slice(0,40)});continue}let c=null,g=!1;if(s.listSelector!=null&&s.index!=null){const a=I.querySelectorAll(s.listSelector),L=f(s.text||""),k=D=>{const N=a[D];return N?(s.selector!==s.listSelector?N.querySelector(s.selector):N)||(s.selector!==s.listSelector?N:null):null};let p=a[s.index];if(!p&&s.index>0&&(p=a[s.index-1]),p){if(c=k(s.index)||(s.index>0?k(s.index-1):null),!c&&s.selector!==s.listSelector&&(c=p),s.type==="visible"&&L&&c){const D=S(c);if(D.indexOf(L)===-1&&L.indexOf(D)===-1)for(let $=0;$<a.length;$++){const T=k($);if(T&&S(T).indexOf(L)!==-1){c=T,p=a[$];break}}}}else g=!0}else{const a=I.querySelectorAll(s.selector);c=a.length>0?a[0]:t.D.querySelector(s.selector)}if(s.type==="visible"){const a=c&&c.nodeType===1&&(c.offsetParent!==null||c.getBoundingClientRect&&c.getBoundingClientRect().width>0),L=f(s.text||""),k=S(c),p=k,D=!L||k.indexOf(L)!==-1||p.indexOf(L)!==-1||L.length>0&&L.indexOf(k)!==-1;if(a&&D)y+=1;else{const N=g?`index out of bounds (list has ${I.querySelectorAll(s.listSelector||s.selector).length} items, assertion expected index ${s.index})`:c?a?D?"fail":"text mismatch":"not visible":"element not found";C.push({selector:s.selector,message:N}),typeof console<"u"&&console.warn&&console.warn("[runRecordingAssertions] visible failed:",{actionIdx:s.actionIdx,selector:s.selector,listSelector:s.listSelector,index:s.index,expectedText:s.text||"(any)",actualText:k.slice(0,80),message:N})}}else if(s.type==="class"){const a=(s.className||"").trim().split(/\s+/).filter(Boolean);if(c&&(a.length===0||a.every(k=>c.classList?.contains(k))))y+=1;else{const k=g?`index out of bounds (list has ${I.querySelectorAll(s.listSelector).length} items, expected index ${s.index})`:c?`expected class "${s.className}"`:"element not found";C.push({selector:s.selector,message:k}),typeof console<"u"&&console.warn&&console.warn("[runRecordingAssertions] failed:",{type:s.type,selector:s.selector,actionIdx:s.actionIdx,listSelector:s.listSelector,index:s.index,itemsInRoot:s.listSelector?I.querySelectorAll(s.listSelector).length:"-",message:k})}}}return{passed:y,total:x.length,failures:C}},t.exportTest=(n,e={})=>{const i=e.delay!==void 0?e.delay:16,r={actions:n.actions,assertions:n.assertions||[],observeRoot:n.observeRoot||null},d=n.observeRoot?`(o.D.querySelector('${n.observeRoot.replace(/'/g,"\\'")}') || o.D.body)`:"o.D.body",w=f=>{if(f.listSelector!=null&&f.targetIndex!=null){const S=JSON.stringify(f.listSelector),m=f.target===f.listSelector,O=m?S:JSON.stringify(f.target);return` const items = o.D.querySelectorAll(${S});
|
|
16
|
-
const item = items[${f.targetIndex}];
|
|
6
|
+
*/const ee=!0,t=n=>{let e={els:[],ie:{},delegated:{},parented:{},store:{},refs:{},_refsByIndex:[],states:[],isDebug:!1,currentState:"",savedStates:{},isRoot:!1,_parent:null},i=1,r=2,p=3,L="boolean",g="object",k="function",m="string",R="number",b="notEmptyString",h="undefined",v="dangerouslySetInnerHTML",I,l=t.D,T=-1,o=0,c=0,f=typeof process<"u"||t.D===t.DocumentMVP,a=0,u=0;const D=e,w=s=>typeof s,$=(s,d)=>{for(const x in s)Object.hasOwn(s,x)&&d(x,s)},S=t.onError,A=s=>t.verify(s),y=(s,d="")=>(...x)=>{(t.debug||e.isDebug)&&console.log(d?`${d}()`:s,x.length?"with "+x.join(", "):"without parameters");try{const O=s(x[0],x[i],x[r],x[p]);return O!==I?O:e}catch(O){S(O,d)}},N=s=>{for(a=o;a<=T;a++)s()},q=s=>s?.els?s.el:(w(s)!==g&&(s=t.first(s).el),s),j=(s=!0,d=e.els)=>{const x=d.length;if(e.length=x,T=x-i,o=0,e.el=x?d[0]:I,e.last=x?d[T]:I,s&&($(e.states,(O,E)=>{delete e[E[O]]}),e.states=[],e.ie={}),Array.isArray(e._refsByIndex)){const O=e._refsByIndex.length;if(O>x)$(e._refsByIndex,E=>{const C=+E;C>=x&&delete e._refsByIndex[C]}),e._refsByIndex.length=x;else if(O<x)for(let E=O;E<x;E++)e._refsByIndex[E]={}}};e.reset=t;const P=s=>{if(f||!s.querySelectorAll)return;const d=s.querySelectorAll("[data-o-init]"),x={};d.forEach(O=>{const E=O.getAttribute("data-o-init");E!==null&&(x[E]||(x[E]=[]),x[E].push(O))}),$(x,O=>{const E=t.inits[O];E&&E.getSSR(Number(O),x[O])})},X=(s,d,x)=>{$(d,O=>{let E=d[O];w(E)===k&&(E=E(x)),O==="append"&&w(E)===g&&(E.els&&(E=[E]),E[0]?.els&&(valueBuff=[],$(E,C=>{valueBuff.push(...E[C].els)}),E=valueBuff)),E!==I&&s.getAttribute(O)!==E&&!["tag","tagName","name","sample","state","events","ssr","nodeName","revertChildren","root","ref"].includes(O)&&(["html","innerHTML"].includes(O)?(s.innerHTML=E,!f&&P(s)):O==="className"?s.setAttribute("class",E):O==="dataset"&&w(E)===g?$(E,C=>{s.dataset[C]=E[C]}):O==="toggleClass"?s.classList.toggle(E):O==="addClass"?w(E)===g?s.classList.add(...E):s.classList.add(E):O==="removeClass"?s.classList.remove(E):O==="style"&&w(E)===g?$(E,C=>{s.style[C]=E[C]}):(O==="append"||O==="children"||O==="childNodes")&&w(E)===g?$(E.length?E:[E],C=>{O==="append"||!s.childNodes[C]?s.appendChild(E[C]):s.childNodes[C]!==E[C]&&s.childNodes[C].replaceWith(E[C])}):s.setAttribute(O,E))}),s.dataset.oState=d.state,t.autotag&&d.name&&(s.dataset[t.autotag]=t.camelToKebab(d.name))};e.debug=y(()=>{e.isDebug=!0},"debug ON"),e.saveAs=y(s=>{A([[s,[b]]]),t.getSaved[s]?(t.debug||e.isDebug)&&console.warn("the key exists (not saved):"+s):t.getSaved[s]=e},"saveAs"),e.unmount=()=>((t.debug||e.isDebug)&&console.log("unmount() for initID:"+e.initID),w(e.remove)===k?e.remove():e.els?.length&&e.els.forEach(s=>{s?.parentNode&&s.parentNode.removeChild(s)}),t.inits[e.initID]=void 0,e={},!0),e.init=y(s=>{A([[s,[g,k]]]);const d=e.initID||t.inits.length||0;if(e.initID=d,j(),t.inits[e.initID]=e,w(s)==="function"){e.render=y(C=>{const _=l.createElement("div");setTimeout(()=>{t.reactRender(s,_,C)}),e.add(_)});return}(w(s)!==g||s.render===I)&&(s={render:s}),$(s,C=>{e?.render&&C==="render"||(e.states.push(C),e[C]=y((_=[{}])=>{e.currentState=C;const F=s[C]||{tag:"div"},B=Array.isArray(e.els)?e.els.slice(o,T+i):[],z=B.length?B:e.els||[];w(F)===g&&(F.state=C,F["data-o-init"]=d);const V=(H,U={})=>{const M=w(F)===k?F(U):F;if(w(M)===g)return l.createElement(M.tag||M.tagName||"div");const J=l.createElement("div");return J.innerHTML=M,J.children.length>i||!J.firstElementChild?(J.dataset.oInit=H,J):(J.firstElementChild.dataset.oInit=H,J.firstElementChild)},Y=_;Array.isArray(_)||(_=[_]),_.length||(_=[_]);const G=!z[0]&&C==="render";_=_.map((H,U)=>{const M=Object.assign({},w(H)===g?H:{},{self:e,o:t,i:H.i===I?U:H.i,parent:e._parent,data:Array.isArray(Y)?Y[U]:Y});return G&&(!F.ssr||f)&&z.push(V(d,M)),M}),G&&(e.els=z,j(!1));const Q=()=>{$(F.events,H=>{e.on(H,F.events[H])})};z&&(u=z.length===_.length,z.map((H,U)=>{_[u?U:0].i=U+o;const M=w(F)===k?F(_[u?U:0]):F;w(M)===g&&(M.state=C,G&&(M["data-o-init"]=d,M["data-o-init-i"]=U,M.events&&(e._hydrateEvents=e._hydrateEvents||[],e._hydrateEvents[U]=M.events)),X(H,M,_[u?U:0]))}),G&&(e._refsByIndex=[],e.refs={},e.els.forEach((H,U)=>{if(!H.querySelectorAll)return;const M={};H.querySelectorAll("[ref]").forEach(J=>{const Z=J.getAttribute("ref"),K=t(J);M[Z]=K,U===0&&(e.refs[Z]=K)}),e._refsByIndex[U]=M}),!f&&e._hydrateEvents&&(e._hydrateEvents.forEach((H,U)=>{H&&(e.select(U),$(H,M=>{const J=H[M];if(w(J)===g&&J.targetRef&&w(J.handler)===k){const K=(e._refsByIndex?.[U]??e.refs)?.[J.targetRef];K&&K.on(M,J.handler)}else w(J)===k&&e.on(M,J)}))}),e.all()))),G&&w(F)===g&&F.events&&!f&&!F.ssr&&Q()}))});const x=s.render||s,O=!f&&w(x)===g&&x.events,E=!f&&e._hydrateEvents&&e._hydrateEvents.length;(O||E)&&(e.initSSRAfterGettingSSR=()=>{e._refsByIndex=[],e.refs={},e.els.forEach((C,_)=>{if(!C.querySelectorAll)return;const F={};C.querySelectorAll("[ref]").forEach(B=>{const z=B.getAttribute("ref"),V=t(B);F[z]=V,_===0&&(e.refs[z]=V),B.removeAttribute("ref")}),e._refsByIndex[_]=F,_===0&&(e.refs=F)}),O&&$(x.events,C=>{e.on(C,x.events[C])}),e._hydrateEvents&&(e._hydrateEvents.forEach((C,_)=>{C&&(e.select(_),$(C,F=>{const B=C[F];if(w(B)===g&&B.targetRef&&w(B.handler)===k){const V=(e._refsByIndex?.[_]??e.refs)?.[B.targetRef];V&&V.on(F,B.handler)}else w(B)===k&&e.on(F,B)}))}),e.all())})},"init"),e.connect=y((s,d="render",x)=>{A([[s,[g]],[d,[b]],[x,[m,h]]]),s.connect(D,d,x)},"connect"),e.getSSR=y((s,d)=>{A([[s,[R,h]]]);const x=s!==void 0?s:e.initID;if(f||w(s)===h&&w(e.initID)===h)return;const O=d&&d.length?d:t.D.querySelectorAll(`[data-o-init="${x}"]`);O.length&&(e.els=Array.from(O),s!==void 0&&(e.initID=s,t.inits[s]=e),j(!1),w(e.initSSRAfterGettingSSR)===k?e.initSSRAfterGettingSSR():d&&d.length&&(e._refsByIndex=[],e.refs={},e.els.forEach((E,C)=>{if(!E.querySelectorAll)return;const _={};E.querySelectorAll("[ref]").forEach(F=>{const B=F.getAttribute("ref");_[B]=t(F),C===0&&(e.refs[B]=_[B]),F.removeAttribute("ref")}),e._refsByIndex[C]=_,C===0&&(e.refs=_)})))},"getSSR"),e.initState=y((s,d)=>{A([[s,[g]],[d,[g,h]]]),e.init(s).render(d)},"initState");const W=(s,d,x)=>{const O=s.attributes,E={tagName:s.tagName.toLowerCase()};for(const C of O)E[C.nodeName]=C.value;if(x){E.innerHTML=s.innerHTML,E.revertChildren=[];const C=s.querySelectorAll("[data-o-init]");for(const _ of C){const F=_.getAttribute("data-o-init");E.revertChildren.push(F),t.inits[F]?.saveState(d,!1)}}return E};return e.saveState=y((s,d=!0)=>{if(A([[s,[b,h]],[d,[L]]]),!e.el)throw Error("saveState(): There are no elements to save");const x=s||"fastSavedState",O={els:[],parentNode:e.el.parentNode,root:d};N(()=>{O.els.push(W(e.els[a],x,d))}),O.ie=Object.assign({},e.ie),O.delegated=Object.assign({},e.delegated),O.store=Object.assign({},e.store),e.isRoot=e.isRoot||d,e.savedStates[x]=O},"saveState"),e.revertState=y(s=>{A([[s,[b,h]]]);const d=s||"fastSavedState";if(!e.savedStates[d])throw Error(`revertState(): The state "${d}" should have been saved by saveState()`);const x=e.savedStates[d];e.offAll(),e.offDelegate(),e.store=Object.assign({},x.store),x.els.forEach((O,E)=>{if(!e.els[E]){const C=t.D.createElement(O.tagName);x.parentNode&&(E?e.els[E-1].after(C):x.parentNode.append(C)),e.add(C)}X(e.els[E],O)}),e.delegated=Object.assign({},x.delegated),e.ie=Object.assign({},x.ie),e.onAll(),$(x.delegated,O=>{x.delegated[O].forEach(E=>{N(()=>{e.els[a].addEventListener(O,E)})})}),e.currentState=d,x.root&&x.els.forEach(({rootElement:O})=>{O.revertChildren.forEach(E=>{t.inits[E]?.revertState(d),t('[data-o-init="'+E+'"]').els.forEach((C,_)=>{C.replaceWith(t.inits[E]?.els[_])})})})},"revertState"),e.loseState=y(s=>{A([[s,[b]]]),e.savedStates[s]&&(delete e.savedStates[s],N(()=>{const d=e.els[a].querySelectorAll("[data-o-init]");for(const x of d){const O=x.getAttribute("data-o-init");t.inits[O]?.loseState(s)}}))},"sample"),e.sample=y((s="render")=>(A([[s,[b]]]),{[s]:W(e.els[o])}),"sample"),e.select=y(s=>{let d=s;d!=null&&w(d)===g&&d.target&&e.els.length&&(d=e.els.findIndex(x=>x===d.target||x.contains(d.target)),d<0&&(d=0)),A([[d,[R,h]]]),d===I&&(d=e.length-i),T=d,o=d,e.el=e.els[d],c=i,Array.isArray(e._refsByIndex)&&e._refsByIndex[d]&&(e.refs=e._refsByIndex[d])},"select"),e.all=y(()=>{T=e.length-i,o=0,e.el=e.els[0],c=0,Array.isArray(e._refsByIndex)&&e._refsByIndex.length&&(e.refs=e._refsByIndex[0]||{})},"all"),e.remove=y(s=>{if(A([[s,[R,h]]]),s===I&&c&&(s=o),s!==I){const d=e.els[s];d?.parentNode?d.parentNode.removeChild(d):d===void 0&&s>=e.els.length&&t.onError&&t.onError("remove("+s+"): index out of bounds","remove")}else N(()=>{const d=e.els[a];d?.parentNode&&d.parentNode.removeChild(d)});j(!1)},"remove"),e.skip=y(s=>{A([[s,[R,h]]]),s===I&&(s=o),e.els.splice(s,i),Array.isArray(e._refsByIndex)&&e._refsByIndex.splice(s,i),j()},"skip"),e.add=y(s=>{A([[s,[m,g,R]]]),e.initID===I&&(w(s)==="string"&&s!==""?e.els.push(...Array.from(l.querySelectorAll(s))):w(s)===g?s.tagName?e.els.push(s):s.els?e.els.push(...s.els):s.length&&s[0].tagName&&e.els.push(...s):w(s)==="number"&&t.inits[s]&&(e=t.inits[s]),j(!1),e.initID!==I&&e.dataset({oInit:e.initID}))},"add"),e.appendInside=y(s=>{A([[s,[g,b]]]),s?.els&&(e._parent=s),N(()=>{q(s).appendChild(e.els[a])})},"appendInside"),e.appendBefore=y(s=>{A([[s,[g,b]]]),N(()=>{q(s).parentNode.insertBefore(e.els[a],q(s))})},"appendBefore"),e.appendAfter=y(s=>{A([[s,[g,b]]]),N(()=>{q(s).after(...e.els)})},"appendAfter"),e.find=y((s="")=>{A([[s,m]]);const d=[];return N(()=>{d.push(...Array.from(e.els[a].querySelectorAll(":scope "+s)))}),t(d)},"find"),e.first=y((s="")=>{A([[s,m]]);let d=I;const x=[];return N(()=>{d=e.els[a].querySelector(s),d&&x.push(d)}),t(x)},"first"),e.attr=y((s,d)=>{if(d!==null&&A([[s,m],[d,[m,h]]]),d===I){const x=[];return N(()=>{x[a]=e.els[a].getAttribute(s)}),c?x[0]:x}else N(d!==null?()=>{e.els[a].setAttribute(s,d)}:()=>{e.els[a].removeAttribute(s)})},"attr"),e.attrs=y(()=>{const s=[];return N(()=>{const d={};[...e.els[a].attributes].forEach(x=>{d[x.nodeName]=x.nodeValue}),s.push(d)}),c?s[0]:s},"attrs"),e.dataset=y(s=>{if(A([[s,[g,h]]]),typeof s===g)N(()=>{$(s,d=>{e.els[a].dataset[d]=s[d]})});else{const d=[];return N(()=>{d.push({...e.els[a].dataset})}),c?d[0]:d}},"dataset"),e.style=y(s=>{s!==null&&A([[s,[m,h]]]),e.attr("style",s)},"style"),e.css=y((s={})=>{if(s===null){e.style(null);return}A([[s,g]]);let d="";$(s,x=>{d+=x+":"+s[x].replace('"',"'")+";"}),e.style(d||null)},"css"),e.setClass=y(s=>{A([[s,m]]),N(()=>{e.els[a].setAttribute("class",s)})},"setClass"),e.addClass=y((...s)=>{N(()=>{e.els[a].classList.add(...s)})},"addClass"),e.removeClass=y((...s)=>{N(()=>{e.els[a].classList.remove(...s)})},"removeClass"),e.toggleClass=y((s,d)=>{A([[s,b],[d,[L,h]]]),N(()=>{e.els[a].classList.toggle(s,d)})},"toggleClass"),e.haveClass=s=>{A([[s,b]]);let d=!0;return N(()=>{e.els[a].classList.contains(s)||(d=!1)}),(e.isDebug||t.debug)&&console.log("haveClass() with",s),d},e.innerHTML=y(s=>{if(A([[s,[m,h]]]),s!==I)N(()=>{e.els[a].innerHTML=s});else{let d="";return N(()=>{d+=f&&e.els[a].innerHTML.length===0?t.D.parseElement(e.els[a],!1):e.els[a].innerHTML}),d}},"innerHTML"),e.innerText=y(s=>{A([[s,[m]]]),N(()=>{e.els[a].innerText=s})},"innerText"),e.textContent=y(s=>{A([[s,[m]]]),N(()=>{e.els[a].textContent=s})},"textContent"),e.html=y(s=>{if(A([[s,[m,h]]]),s!==void 0)e.innerHTML(s);else{let d="";return N(()=>{d+=f?e.els[a].outerHTML():e.els[a].outerHTML}),d}},"html"),e.toString=function(){return e.html()},e[Symbol.toPrimitive]=function(s){return s==="string"||s==="default"?e.html():s==="number"?e.els?.length??0:e.html()},e.val=y(s=>{if(s===void 0)return e.el?.value;N(()=>{e.els[a].value=s})},"val"),e.forEach=y(s=>{A([[s,[k]]]),N(()=>{s({self:e,i:a,o:t,el:e.els[a]})})},"forEach"),e.prepareFor=y((s,d)=>{A([[s,[g,k,h]],[d,[k,h]]]);const x=s&&w(s)===g&&s.createElement;if(!x&&w(s)!==k)throw Error("prepareFor(): pass React (full object) or React.createElement as first argument");const O=x?s.createElement:s,E=x?s.useEffect:void 0;return C=>{if(C.ref===I)throw Error("No ref property to convert Objs to React");const _=Object.assign({},C),F=O("div",{ref:C.ref});return delete _.ref,E(()=>{$(_,B=>{if(B.substring(0,1)==="on"){const z=t.camelToKebab(B).split("-")[1];e.on(z,_[B]),delete _[B]}}),e.render(_),e.appendInside(F.ref.current)},[]),F}},"prepareFor"),e.on=y((s,d,x,O)=>{A([[s,[b]],[d,[k]],[x,[g,h]],[O,[L,h]]]),s.split(", ").forEach(E=>{N(()=>{e.els[a].addEventListener(E,d,x,O)}),e.ie[E]||(e.ie[E]=[]),e.ie[E].push([d,x,O])})},"on"),e.off=y((s,d,x)=>{A([[s,[b]],[d,[k]],[x,[g,h]]]),s.split(", ").forEach(O=>{N(()=>{e.els[a].removeEventListener(O,d,x)}),e.ie[O]&&(e.ie[O]=e.ie[O].filter(E=>E[0]!==d))})},"off"),e.onDelegate=y((s,d,x)=>{A([[s,[b]],[d,[b]],[x,[k]]]),s.split(", ").forEach(O=>{const E=C=>{const _=C.target.closest(d);_&&(C.delegate=_,C.objs=e,x(C))};N(()=>{e.els[a].addEventListener(O,E)}),e.delegated[O]||(e.delegated[O]=[]),e.delegated[O].push(E)})},"onDelegate"),e.offDelegate=y(s=>{A([[s,[b]]]),$(e.delegated,d=>{if(!s||s===d)for(;e.delegated[d].length;){const x=e.delegated[d].pop();N(()=>{e.els[a].removeEventListener(d,x)})}}),e.delegated={}},"offDelegate"),e.onParent=y((s,d,x)=>{A([[s,[b]],[d,[b,g]],[x,[k]]]);const O=w(d)===g?d:t.D.querySelector(d);s.split(", ").forEach(E=>{const C=_=>{_.objs=e,x(_)};O.addEventListener(E,C),e.parented[E]||(e.parented[E]=[]),e.parented[E].push(C)})},"onParent"),e.offParent=y((s,d)=>{A([[s,[b]],[d,[b,g]]]);const x=w(d)===g?d:t.D.querySelector(d);$(e.parented,O=>{(!s||s===O)&&(e.parented[O].forEach(E=>{x.removeEventListener(O,E)}),delete e.parented[O])})},"offParent"),e.onAll=y((s,d)=>{A([[s,[b,h]],[d,[L,h]]]),$(e.ie,(x,O)=>{(!s||s===x)&&O[x].forEach(E=>{N(()=>{d?e.els[a].removeEventListener(x,E[0]):e.els[a].addEventListener(x,E[0],E[i],E[r])})})})},"onAll"),e.offAll=y(s=>{A([[s,[b]]]),e.onAll(s,i)},"offAll"),n&&e.add(n),e.take=s=>{if(A([[s,[m,g,R]]]),e.add(s),e.el){const d=e.el.dataset.oInit;if(d!==I&&t.inits[d])return e.length===i?(u=e.els[0],Object.assign(e,t.inits[d]),e.els=[u]):e=t.inits[d],j(!1,e.els),e}},e};t.first=n=>(t.verify([[n,["notEmptyString"]]]),t.debug&&console.log(n," -> ","o.first()"),t(t.D.querySelector(n)).select(0)),t.inits=[],t.getSaved={},t.errors=[],t.showErrors=!1,t.logErrors=()=>{t.errors.length?t.errors.forEach(n=>console.error(n)):console.log("No errors")},t.onError=(n,e)=>{t.showErrors?console.error(n,e):(t.errors.push(n),e&&t.errors.push(e))},t.reactRender=()=>new Error("React render function is not defined"),t.autotag=void 0,t.reactQA=n=>({["data-"+(t.autotag||"qa")]:n.replace(/([A-Z])/g,(e,i)=>"-"+i.toLowerCase()).replace(/^-/,"")}),t.specialTypes={notEmptyString:(n,e)=>e==="string"&&n.length,array:n=>Array.isArray(n),promise:n=>n instanceof Promise||!!(n&&typeof n.then=="function")},t.verify=(n,e=!1)=>{for(const i of n){const r=typeof i[0];let p=Array.isArray(i[1])?i[1]:[i[1]],L=!1;if(p.includes(r))return!0;p=p.filter(g=>!!t.specialTypes[g]);for(const g of p)if(L=t.specialTypes[g](i[0],r),L)return!0}return e?!1:new Error("Type verification failed")},t.safeVerify=n=>t.verify(n,!0),t.init=(n,e)=>t().init(n,e),t.initState=(n,e)=>t().init(n).render(e),t.take=n=>t().take(n),t.getStates=()=>t.inits.reduce((n,e)=>(n.push(e?.states),n),[]),t.getStores=()=>t.inits.reduce((n,e)=>(n.push(e?.store),n),[]),t.getListeners=()=>t.inits.reduce((n,e)=>(n.push(e?.ie),n),[]),t.createStore=n=>{const e=Object.assign({},n);return e._defaults=Object.assign({},n),e._listeners=[],e.subscribe=function(i,r){return this._listeners.push(p=>i[r]?.(p)),this},e.notify=function(){this._listeners.forEach(i=>i(this))},e.reset=function(){const i={_listeners:1,subscribe:1,notify:1,_defaults:1,reset:1};for(const r of Object.keys(this._defaults))i[r]||(this[r]=this._defaults[r])},e},t.U=void 0,t.W=2,t.H=100,t.F=!1,t.C=(n,e)=>Object.hasOwn(n,e),t.kebabToCamel=n=>n.replace(/-./g,e=>e.toUpperCase()[1]),t.camelToKebab=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),t.route=(n,e)=>{t.verify([[n,["notEmptyString","function","boolean"]],[e,["function","object"]]]);const i=typeof n=="function"?n(window.location.pathname):n;return i===!0||window.location.pathname===i?e?typeof e=="function"?(e(),!0):e:t:typeof e=="function"?!1:{}},t.router=(n={})=>{t.verify([[n,["object"]]]);for(const e in n)if(t.C(n,e)&&window.location.pathname===e)return typeof n[e]=="function"?(n[e](),!0):n[e];return!1},t.DocumentMVP={addEventListener:()=>{},parseElement:(n,e=!0)=>{t.verify([[n,["object","string"]],[e,["boolean"]]]);const i=(r,p="")=>{let L="";for(const g in r)t.C(r,g)&&(L+=` ${p}${t.camelToKebab(g)}="${typeof r[g]!="object"?r[g]:Object.entries(r[g]).map(k=>`${k[0]}: ${k[1]};`).join(" ")}"`);return L};if(typeof n=="string")return n;if(e){const r=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],p=n.tagName.toLowerCase(),L=n.attributes["data-o-init"],g=L!==void 0?` data-o-init="${L}"`:"";return`<${p}${n.className?` class="${n.className}"`:""}${i(n.attributes)}${g}${i(n.dataset,"data-")}${r.includes(p)?"/":""}>${r.includes(p)?"":n.innerHTML.length?n.innerHTML:n.children.map(k=>t.D.parseElement(k)).join("")}${r.includes(p)?"":`</${p}>`}`}return n.innerHTML.length?n.innerHTML:n.children.map(r=>t.D.parseElement(r)).join("")},createElement:n=>{t.verify([[n,["notEmptyString"]]]);const e={tagName:n.toUpperCase(),attributes:{},innerHTML:"",children:[],dataset:{},className:"",classArray:[],style:{},addEventListener:()=>{},removeEventListener:()=>{}};return e.classList={add:(...i)=>{t.verify([[i,["array"]]]),e.classArray.push(i),e.className=e.classArray.join(" ")},has:i=>(t.verify([[i,["notEmptyString"]]]),e.classArray.includes(i)),remove:i=>{t.verify([[i,["notEmptyString"]]]),e.classArray=e.classArray.filter(r=>i!==r),e.className=e.classArray.join(" ")}},e.classList.toggle=i=>{t.verify([[i,["notEmptyString"]]]),e.classList.has(i)?e.classList.remove(i):e.classList.add(i)},e.setAttribute=(i,r)=>{t.verify([[i,["notEmptyString"]],[r,["string","number","boolean","undefined"]]]),e.attributes[i]=r},e.getAttribute=i=>(t.verify([[i,["notEmptyString"]]]),e.attributes[i]),e.removeAttribute=i=>{t.verify([[i,["notEmptyString"]]]),delete e.attributes[i]},e.appendChild=i=>{t.verify([[i,["object"]]]),e.children.push(i),e.firstElementChild=e.children[0]},e.outerHTML=()=>t.D.parseElement(e),e}},t.D=typeof document<"u"&&typeof process>"u"?document:t.DocumentMVP,t.setCookie=(n,e="",i={})=>{if(t.verify([[n,["notEmptyString"]],[e,["string","number","boolean"]],[i,["object"]]]),t.D.cookie===void 0){console.log("Cookies are not supported on server side");return}let r=encodeURIComponent(n)+"="+encodeURIComponent(e);i={path:"/",...i},i.expires instanceof Date?i.expires=i.expires.toUTCString():typeof i.expires=="number"&&(i.expires=new Date(i.expires).toUTCString());for(const p in i){r+="; "+p;const L=i[p];L!==!0&&(r+="="+L)}t.D.cookie=r},t.getCookie=n=>{if(t.verify([[n,["notEmptyString"]]]),t.D.cookie===void 0){console.log("Cookies are not supported on server side");return}const e=t.D.cookie.match(RegExp("(?:^|; )"+n.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0},t.deleteCookie=n=>{t.verify([[n,["notEmptyString"]]]),t.setCookie(n,"",{"max-age":0})},t.clearCookies=()=>{if(t.D.cookie===void 0){console.log("Cookies are not supported on server side");return}const n=t.D.cookie.split(";");for(;n.length;){let e=n.pop();for(;e.charAt(0)===" ";)e=e.substring(1);const i=e.split("=")[0];t.deleteCookie(i)}},t.clearLocalStorage=n=>{if(t.verify([[n,["boolean","undefined"]]]),!(typeof localStorage>"u"))if(n)localStorage.clear();else for(let e=localStorage.length-1;e>=0;e--){const i=localStorage.key(e);i.indexOf("oInc-")===-1&&i.indexOf("oTest-")===-1&&localStorage.removeItem(i)}},t.clearSessionStorage=n=>{if(t.verify([[n,["boolean","undefined"]]]),!(typeof sessionStorage>"u"))if(!n)sessionStorage.clear();else for(let e=sessionStorage.length-1;e>=0;e--){const i=sessionStorage.key(e);i&&i.indexOf("oTest-")===0&&sessionStorage.removeItem(i)}},t.clearTestsStorage=()=>{t.clearSessionStorage(1)},t.clearAfterTests=()=>{t.clearCookies(),t.clearLocalStorage(!1),t.clearTestsStorage()},t.ajax=(n,e={})=>{t.verify([[n,["notEmptyString"]],[e,["object"]]]);const i=new URLSearchParams;if(e.data&&typeof e.data=="object"){for(const r in e.data)t.C(e.data,r)&&(typeof e.data[r]=="object"?i.set(r,encodeURIComponent(JSON.stringify(e.data[r]))):i.set(r,e.data[r]));e.method.toLowerCase()==="get"?n+="?"+i.toString():e.body||(e.body=i),delete e.data}return e.headers||(e.headers={"X-Requested-With":"XMLHttpRequest"}),fetch(n,e)},t.get=(n,e={})=>(t.verify([[n,["notEmptyString"]],[e,["object"]]]),t.ajax(n,{...e,method:"GET"})),t.post=(n,e={})=>(t.verify([[n,["notEmptyString"]],[e,["object"]]]),t.ajax(n,{...e,method:"POST"})),t.newLoader=n=>{t.verify([[n,["promise","undefined"]]]);let e=[],i=null,r=!1,p=!1;const L=g=>{r=!1,p=!1,i=null,setTimeout(()=>{g.then(k=>{r=!0,!k.ok&&typeof k.ok<"u"?(p=!0,e.forEach(([m,R,b])=>{b&&m[b](k)})):typeof k.json=="function"?k.json().then(m=>{i=m,e.forEach(([R,b])=>{R[b](i)})}):(i=k,e.forEach(([m,R])=>{m[R](i)}))}).catch(k=>{p=!0,e.forEach(([m,R,b])=>{b&&m[b](k)})})},33)};return n&&L(n),{reload:L,isObjsLoader:!0,listeners:e,isFinished:()=>r,getStore:()=>i,connect:(g,k="render",m)=>{t.verify([[g,["object"]],[k,["notEmptyString"]],[m,["string","undefined"]]]),r?p?m&&g[m]():typeof g[k]=="function"&&g[k](i):e.push([g,k,m])},disconnect:g=>{t.verify([[g,["object"]]]),e=e.filter(([k])=>k!==g)}}},t.getParams=n=>{t.verify([[n,["string","undefined"]]]);const e={},i=new URLSearchParams(window.location.search).entries();for(const r of i)e[r[0]]=r[1];return n?e[n]:e},t.incCache=!0,t.incCacheExp=1e3*60*60*24,t.incTimeout=6e3,t.incSource="",t.incForce=t.F,t.incAsync=!0,t.incCors=t.F,t.incSeparator="?",t.incFns={},t.incSet=[0],t.incReady=[0],t.incN=0,t.incGetHash=n=>n.split(t.incSeparator)[1]||"",t.incCheck=(n=0,e,i=0)=>(t.verify([[n,["number"]],[e,["number","undefined"]],[i,["number"]]]),!i&&n&&e===t.U&&t.incReady[n]?t.incSet[n]===1:t.incReady[n]===t.U||t.incReady[n][e]===t.U?t.F:(t.incReady[n][e].loaded=i,t.incFns[t.incReady[n][e].name]=i,t.incReady[n][0]+=i,n&&t.incReady[n].length===t.incReady[n][0]&&(typeof t.incSet[n]=="function"&&t.incSet[n](n),t.incSet[n]=1),t.incSet[n]===1)),t.incCacheClear=(n=t.F)=>{t.verify([[n,["boolean"]]]);for(const e in t.incFns)t.C(t.incFns,e)&&(localStorage.removeItem("oInc-"+e),localStorage.removeItem("oInc-"+e+"-expires"));return n&&(t.incReady.forEach((e,i)=>{i&&e.forEach((r,p)=>{p&&t("#oInc-"+i+"-"+p).remove()})}),t.incN=0,t.incFns={},t.incSet=[0],t.incReady=[0]),!0},t.inc=(n,e,i)=>{if(t.verify([[n,["object","undefined"]],[e,["function","undefined"]],[i,["function","undefined"]]]),typeof localStorage>"u")return;let r=0,p=0,L="",g=!1;const k="function",m=-1;if(typeof n!="object"||!n)return t.incSet[0];t.incSet[0]++;const R=t.incSet[0];t.incSet[R]=e||0,t.incReady[R]=[];const b=t.incReady[R];b[0]=1;const h={};for(const v in n)if(t.C(n,v)){if(v==="preload"){g=!0;continue}L=t.incGetHash(n[v]),r++,t.incN++;const I=n[v].indexOf(".css")>m?"style":"script";if(n[v]=(t.incSource?t.incSource+"/":"")+n[v],Number.isNaN(Number(v))&&t.C(t.incFns,v)&&t.incFns[v]&&!t.incForce){b[r]={name:v,loaded:1},p++;continue}if(b[r]={name:v,loaded:0},Number.isNaN(Number(v))&&(t.incFns[v]=0),Number.isNaN(Number(v))&&t.incCache&&(n[v].substring(0,4)!=="http"||!t.incCors)&&window.location.protocol!=="file:"&&(n[v].indexOf(".css")>m||n[v].indexOf(".js")>m)){const l=localStorage,T=l.getItem("oInc-"+v),o=l.getItem("oInc-"+v+"-expires"),c=l.getItem("oInc-"+v+"-hash");T&&o&&Date.now()<o&&c===L?(g||t.initState({tag:I,id:"oInc-"+R+"-"+r,innerHTML:T,"data-o-inc":R}).appendInside("head"),b[r].loaded=1,t.incFns[v]=1,p++):(h[v]=r,t.get(n[v],{mode:t.incCors?"cors":"same-origin"}).then(f=>{if(f.status!==200){t.onError&&t.onError({message:t.incSource+n[v]+" was not loaded"});return}f.text().then(a=>{l.setItem("oInc-"+v,a),l.setItem("oInc-"+v+"-expires",Date.now()+t.incCacheExp),l.setItem("oInc-"+v+"-hash",L),g||t.initState({tag:I,id:"oInc-"+R+"-"+h[v],innerHTML:a,"data-o-inc":R}).appendInside("head"),t.incCheck(R,h[v],1)})}))}else{const l={tag:I,id:"oInc-"+R+"-"+r,"data-o-inc":R,async:t.incAsync,onload:"o.incCheck("+R+","+r+",1)"};n[v].indexOf(".css")>m?(l.tag="link",l.rel="stylesheet",l.href=n[v]):(n[v].indexOf(".js")>m||(l.tag="img",l.style="display:none;"),l.src=n[v]),t.initState(l).appendInside(l.style?"body":"head")}}return b[0]+=p,r!==0&&(p===r?typeof e===k&&e(R):setTimeout(v=>{t.incReady[v]&&t.incReady[v].length<t.incReady[v][0]&&(t.incSet[v]=0,typeof i===k&&i(R))},t.incTimeout,R)),t.incSet[0]},t.connectRedux=(n,e,i,r="render")=>{t.verify([[n,["object"]],[e,["function"]],[i,["object"]],[r,["notEmptyString"]]]);const p=()=>{if(typeof i[r]=="function"){const L=e(n.getState());i[r](L!==null&&typeof L=="object"?L:{value:L})}};return p(),n.subscribe(p)},t.connectMobX=(n,e,i,r,p="render")=>(t.verify([[n,["object"]],[e,["object"]],[i,["function"]],[r,["object"]],[p,["notEmptyString"]]]),n.autorun(()=>{if(typeof r[p]=="function"){const L=i(e);r[p](L!==null&&typeof L=="object"?L:{value:L})}})),t.ObjsContext=null,t.withReactContext=(n,e,i,r,p="render")=>function(){const g=n.useContext(e);return n.useEffect(()=>{if(typeof r[p]=="function"){const k=i(g);r[p](k!==null&&typeof k=="object"?k:{value:k})}},[g]),null},t.debug=!1,t.sleep=n=>new Promise(e=>setTimeout(e,n)),t.tLog=[],t.tRes=[],t.tStatus=[],t.tFns=[],t.tShowOk=t.F,t.tStyled=t.F,t.tTime=2e3,t.tests=[],t.tExpectedSteps={},t.tFinalized={},t.tAutolog=t.F,t.tBeforeEach=void 0,t.tAfterEach=void 0,t.addTest=(n,...e)=>{t.verify([[n,["notEmptyString"]],[e,["array"]]]);let i={};e.length&&typeof e[e.length-1]=="object"&&!Array.isArray(e[e.length-1])&&(i=e.pop());const r=t.tests.length;return t.tests[r]={title:n,tests:e,hooks:i},{run:()=>{typeof i.before=="function"&&(t.tBeforeEach=i.before),typeof i.after=="function"&&(t.tAfterEach=i.after),t.runTest(r)},autorun:()=>{typeof i.before=="function"&&(t.tBeforeEach=i.before),typeof i.after=="function"&&(t.tAfterEach=i.after),t.runTest(r,!0)},testId:r}},t.updateLogs=()=>{for(let n=0;n<t.tests.length;n++)t.tLog[n]=t.tLog[testN]=sessionStorage.getItem(`oTest-Log-${testN}`)||"";return t.tLog},t.runTest=(n=0,e,i)=>{if(t.verify([[n,["number"]],[e,["boolean","undefined"]],[i,["boolean","undefined"]]]),!t.tests[n])return;i||(sessionStorage?.removeItem(`oTest-Log-${n}`),sessionStorage?.removeItem(`oTest-Res-${n}`),sessionStorage?.removeItem(`oTest-Status-${n}`)),sessionStorage?.setItem("oTest-Run",n),e?sessionStorage?.setItem("oTest-Autorun",e):sessionStorage?.removeItem("oTest-Autorun");const r=t.tests[n];let p=r.tests.pop();typeof p!="function"&&(r.tests.push(p),p=()=>{}),r.tests.push(L=>{p(L),sessionStorage.setItem("dddd",1),sessionStorage?.removeItem("oTest-Run"),e&&t.runTest(n+1,e)}),t.test(r.title,...r.tests)},t.tPre='<div style="font-family:monospace;text-align:left;">',t.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',t.tXx='<div style="background:#fcc;padding:3px;">',t.tDc="</div>",t.test=(n="",...e)=>{t.verify([[n,["notEmptyString"]],[e,["array"]]]);const i=sessionStorage?.getItem("oTest-Run"),r=i||t.tLog.length;let p=0,L="\u251C OK: ",g="\u251C \u2718 ",k=`
|
|
7
|
+
`,m=`
|
|
8
|
+
`,R="",b=e.length,h=0;const v=(o="",c=!1,f=!1)=>{t.tAutolog&&(c?console.error(o):(t.tShowOk||f)&&console.log(o))};let I={};if(typeof e[b-1]=="function"&&(t.tFns[r]=e[b-1],b--),b>0&&typeof e[b-1]=="object"&&!Array.isArray(e[b-1])&&(e[b-1].sync!==void 0||e[b-1].confirmOnFailure!==void 0)&&(I=e[b-1],b--),i){t.tLog[r]=sessionStorage.getItem(`oTest-Log-${r}`)||"",t.tRes[r]=sessionStorage.getItem(`oTest-Res-${r}`)||!1,t.tStatus[r]=JSON.parse(sessionStorage.getItem(`oTest-Status-${r}`)||"[]");for(let o=0;o<t.tStatus[r].length;o++){const c=t.tStatus[r][o];(c===!0||c===!1)&&h++}}t.tStyled&&(L=t.tPre+t.tOk,g=t.tPre+t.tXx,k=t.tDc,m=k+k),(!i||t.tLog[r].length===0)&&(v("\u2552 "+n+" #"+r,!1,!0),t.tStyled?t.tLog[r]="<div><b>"+n+" #"+r+"</b></div>":t.tLog[r]="\u2552 "+n+" #"+r+`
|
|
9
|
+
`,t.tRes[r]=t.F,t.tStatus[r]=[]),t.tExpectedSteps[r]=b,t.tFinalized[r]=!1;const l=(o,c)=>new Promise(f=>{const a=t.overlay({innerHTML:`<div style="display:flex;flex-direction:column;gap:8px;"><div style="cursor:grab;">Step ${o+1} failed: ${c||"error"}. Continue testing?</div><div style="display:flex;gap:8px;"><button class="o-cf-continue" style="padding:6px 12px;background:#2563eb;color:#fff;border:none;border-radius:6px;cursor:pointer;">Continue</button><button class="o-cf-stop" style="padding:6px 12px;background:#dc2626;color:#fff;border:none;border-radius:6px;cursor:pointer;">Stop</button></div></div>`,timeout:I.confirmOnFailureTimeout||void 0,onClose:u=>f(u||{continue:!1}),excludeDragSelector:".o-cf-continue, .o-cf-stop"});a.first(".o-cf-continue").on("click",()=>{a._overlayCleanup(),f({continue:!0})}),a.first(".o-cf-stop").on("click",()=>{a._overlayCleanup(),f({continue:!1})})}),T=()=>{if(t.tFinalized[r])return;if(p>0){R="\u251C ",R+="DONE "+h+"/"+b+", waiting: "+p,v(R,!0),t.tStyled?t.tLog[r]+=t.tPre+'<div style="color:orange;"><b>DONE '+h+"/"+b+", waiting: "+p+"</b>"+t.tDc+t.tDc:t.tLog[r]+=R+`
|
|
10
|
+
`;return}t.tFinalized[r]=!0;const o=t.tStatus[r].some(c=>c===!1);t.tRes[r]=!o&&h===b,R="\u2558 ",R+="DONE "+h+"/"+b,v(R,h!==b),v(),t.tStyled?t.tLog[r]+=t.tPre+'<div style="color:'+(h!==b?"red":"green")+';"><b>DONE '+h+"/"+b+"</b>"+t.tDc+t.tDc:t.tLog[r]+=R+`
|
|
11
|
+
`,i&&(sessionStorage.setItem(`oTest-Log-${r}`,t.tLog[r]),sessionStorage.setItem(`oTest-Res-${r}`,t.tRes[r]),sessionStorage.setItem(`oTest-Status-${r}`,JSON.stringify(t.tStatus[r]))),typeof t.tFns[r]=="function"&&t.tFns[r](r)};if(I.sync||I.confirmOnFailure)return(async()=>{for(let o=t.tStatus[r].length;o<b;o++){const c={n:r,i:o,title:e[o][0],tShowOk:t.tShowOk,tStyled:t.tStyled};let f=e[o][1];if(typeof f>"u"){t.tStyled?t.tLog[r]+="<div>"+c.title+"</div>":t.tLog[r]+=c.title+`
|
|
12
|
+
`,v("\u251C "+c.title,!1,!0),t.tStatus[r][o]=!0,h++;continue}if(typeof t.tBeforeEach=="function"&&t.tBeforeEach(c),typeof f=="function")try{f=f(c)}catch(a){f=a.message,t.onError&&t.onError(a)}if(typeof t.tAfterEach=="function"&&t.tAfterEach(c,f),f&&typeof f.then=="function"){try{const a=await f,u=a===!0||a==null||a&&typeof a=="object"&&a.ok===!0,D=a&&a.errors&&a.errors.length?a.errors.join("; "):typeof a=="string"?a:"";if(t.testUpdate(c,u,u?"":D?": "+D:""),h++,!u&&I.confirmOnFailure&&!(await l(o,D)).continue)break}catch(a){if(t.testUpdate(c,!1,a.message||"Promise rejected"),I.confirmOnFailure&&!(await l(o,a.message||"Promise rejected")).continue)break}continue}if(typeof t.tStatus[r][o]>"u")t.tStatus[r][o]=typeof f=="string"?t.F:f;else{sessionStorage.setItem(`oTest-Status-${r}`,JSON.stringify(t.tStatus[r]));return}if(f===!0)h++,t.tShowOk&&(t.tLog[r]+=L+e[o][0]+k,v("\u251C OK: "+e[o][0]));else if(f!==t.U){if(t.tLog[r]+=g+e[o][0]+(f!==t.F?": "+f:"")+m,v("\u251C \u2718 "+e[o][0]+(f!==t.F?": "+f:""),!0),I.confirmOnFailure&&!(await l(o,typeof f=="string"?f:"")).continue)break}else{p++,setTimeout(a=>{a.title+=" (timeout)",t.testUpdate(a)},t.tTime,c);return}}T()})(),r;for(let o=t.tStatus[r].length;o<b;o++){const c={n:r,i:o,title:e[o][0],tShowOk:t.tShowOk,tStyled:t.tStyled};let f=e[o][1];if(typeof f>"u"){t.tStyled?t.tLog[r]+="<div>"+c.title+"</div>":t.tLog[r]+=c.title+`
|
|
13
|
+
`,v("\u251C "+c.title,!1,!0),t.tStatus[r][o]=!0,h++;continue}if(typeof t.tBeforeEach=="function"&&t.tBeforeEach(c),typeof f=="function")try{f=f(c)}catch(a){f=a.message,t.onError&&t.onError(a)}if(typeof t.tAfterEach=="function"&&t.tAfterEach(c,f),f&&typeof f.then=="function"){p++;const a=setTimeout(()=>{c.title+=" (timeout)",t.testUpdate(c)},t.tTime);f.then(u=>{clearTimeout(a);const D=u===!0||u&&u.ok===!0,w=u&&u.errors&&u.errors.length?u.errors.join("; "):typeof u=="string"?u:"";t.testUpdate(c,D,D?"":w?": "+w:"")}).catch(u=>{clearTimeout(a),t.testUpdate(c,!1,u.message||"Promise rejected")});continue}if(typeof t.tStatus[r][o]>"u")t.tStatus[r][o]=typeof f=="string"?t.F:f;else{sessionStorage.setItem(`oTest-Status-${r}`,JSON.stringify(t.tStatus[r]));return}f===!0?(h++,t.tShowOk&&(t.tLog[r]+=L+e[o][0]+k,v("\u251C OK: "+e[o][0]))):f!==t.U?(t.tLog[r]+=g+e[o][0]+(f!==t.F?": "+f:"")+m,v("\u251C \u2718 "+e[o][0]+(f!==t.F?": "+f:""),!0)):(p++,setTimeout(a=>{a.title+=" (timeout)",t.testUpdate(a)},t.tTime,c))}return T(),r},t.testUpdate=(n,e=t.F,i="")=>{t.verify([[n,["object"]],[e,["boolean","string"]],[i,["string"]]]);let r="";const p=n.n,L=(g="",k=!1)=>{t.tAutolog&&(k?console.error(g):console.log(g))};if(t.tStatus[p][n.i]===t.U||t.tStatus[p][n.i]===null){t.tStatus[p][n.i]=e===!0,e===!0?n.tShowOk&&(r="\u251C OK: "+n.title+i,L(r),n.tStyled?t.tLog[p]+=t.tPre+t.tOk+n.title+i+t.tDc:t.tLog[p]+=r+`
|
|
14
|
+
`):(t.tRes[p]=t.F,r="\u251C \u2718 "+n.title+(e?": "+e:"")+i,L(r,!0),n.tStyled?t.tLog[p]+=t.tPre+t.tXx+n.title+i+(e?": "+e:"")+t.tDc+t.tDc:t.tLog[p]+=r+`
|
|
15
|
+
`);let g=0,k=0;for(const R of t.tStatus[p]){if(R===t.U||R===null)return;R||g++,k++}const m=t.tests[p]?.tests?.length??t.tExpectedSteps[p]??Number.MAX_SAFE_INTEGER;if(k<m){sessionStorage?.getItem("oTest-Run")===p&&(sessionStorage.setItem(`oTest-Log-${p}`,t.tLog[p]),sessionStorage.setItem(`oTest-Res-${p}`,t.tRes[p]),sessionStorage.setItem(`oTest-Status-${p}`,JSON.stringify(t.tStatus[p])));return}if(t.tFinalized[p])return;t.tFinalized[p]=!0,sessionStorage?.getItem("oTest-Run")===p&&(sessionStorage.setItem(`oTest-Log-${p}`,t.tLog[p]),sessionStorage.setItem(`oTest-Res-${p}`,t.tRes[p]),sessionStorage.setItem(`oTest-Status-${p}`,JSON.stringify(t.tStatus[p]))),t.tRes[p]=!g,r=g?"FAILED "+g+"/"+k:"DONE "+k+"/"+k,L("\u2558 "+r,!!g),L(),n.tStyled?t.tLog[p]+=t.tPre+'<b style="color:'+(g?"red":"green")+';">'+r+"</b>"+t.tDc:t.tLog[p]+="\u2558 "+r+`
|
|
16
|
+
`,typeof t.tFns[p]=="function"&&t.tFns[p](p)}},sessionStorage?.getItem("oTest-Run")&&window?.addEventListener("load",()=>{t.runTest(sessionStorage?.getItem("oTest-Run"),sessionStorage?.getItem("oTest-Autorun")||t.F,!0)},!1),t.measure=n=>{if(!n)return{};const e=n.getBoundingClientRect(),i=window.getComputedStyle(n);return{width:e.width,height:e.height,top:e.top,left:e.left,visible:i.display!=="none"&&i.visibility!=="hidden"&&e.width>0,opacity:i.opacity,zIndex:i.zIndex}},t.assertVisible=n=>!!t.measure(n).visible,t.assertSize=(n,e={})=>{if(!n)return"element is null";const i=t.measure(n);if(e.w!==void 0&&Math.round(i.width)!==e.w)return`width: expected ${e.w}, got ${Math.round(i.width)}`;if(e.h!==void 0&&Math.round(i.height)!==e.h)return`height: expected ${e.h}, got ${Math.round(i.height)}`;const r=p=>{const L=window.getComputedStyle(n).getPropertyValue(p);return L?parseFloat(L):0};return e.padding!==void 0&&r("padding-top")!==e.padding?`padding: expected ${e.padding}, got ${r("padding-top")}`:e.paddingTop!==void 0&&r("padding-top")!==e.paddingTop?`paddingTop: expected ${e.paddingTop}, got ${r("padding-top")}`:e.paddingRight!==void 0&&r("padding-right")!==e.paddingRight?`paddingRight: expected ${e.paddingRight}, got ${r("padding-right")}`:e.paddingBottom!==void 0&&r("padding-bottom")!==e.paddingBottom?`paddingBottom: expected ${e.paddingBottom}, got ${r("padding-bottom")}`:e.paddingLeft!==void 0&&r("padding-left")!==e.paddingLeft?`paddingLeft: expected ${e.paddingLeft}, got ${r("padding-left")}`:e.margin!==void 0&&r("margin-top")!==e.margin?`margin: expected ${e.margin}, got ${r("margin-top")}`:e.marginTop!==void 0&&r("margin-top")!==e.marginTop?`marginTop: expected ${e.marginTop}, got ${r("margin-top")}`:e.marginRight!==void 0&&r("margin-right")!==e.marginRight?`marginRight: expected ${e.marginRight}, got ${r("margin-right")}`:e.marginBottom!==void 0&&r("margin-bottom")!==e.marginBottom?`marginBottom: expected ${e.marginBottom}, got ${r("margin-bottom")}`:e.marginLeft!==void 0&&r("margin-left")!==e.marginLeft?`marginLeft: expected ${e.marginLeft}, got ${r("margin-left")}`:!0},t.recorder={active:!1,actions:[],mocks:{},initialData:{},assertions:[],observeRoot:null,_originalFetch:null,_listeners:[],_observer:null},t.recordingAssertionDebug=!1,t.startRecording=(n,e,i)=>{if(t.recorder.active)return;const r=["click","mouseover","scroll","input","change","submit","keydown","focus","blur"],p={click:100,mouseover:50,scroll:30,input:50,change:50,submit:100,keydown:50,focus:50,blur:50},L=e||r,g=Object.assign({},p,i||{}),k={scroll:30,mouseover:50,keydown:50,focus:50,blur:50},m=t.recorder;m.active=!0,m.actions=[],m.mocks={},m.stepDelays=g,m.initialData={url:window.location.href,timestamp:Date.now()},m.observeRoot=n||null,m.assertions=[],m.removedElements=[],t.inits.forEach((l,T)=>{l?.store&&(m.initialData["init_"+T]=JSON.parse(JSON.stringify(l.store)))}),m._originalFetch=window.fetch,window.fetch=async(l,T={})=>{const o=(T.method||"GET").toUpperCase();let c;try{c=T.body?JSON.parse(T.body):void 0}catch{c=T.body}const f=await m._originalFetch(l,T),a=f.clone();let u;try{u=await a.json()}catch{u=await a.text().catch(()=>null)}const D=o+":"+l;return m.mocks[D]={url:l,method:o,request:c,response:u,status:f.status},f},m._originalXHROpen=XMLHttpRequest.prototype.open,m._originalXHRSend=XMLHttpRequest.prototype.send,XMLHttpRequest.prototype.open=function(l,T){return this._oMethod=(l||"GET").toUpperCase(),this._oUrl=T,m._originalXHROpen.apply(this,arguments)},XMLHttpRequest.prototype.send=function(l){const T=()=>{if(this.readyState!==4)return;let o;try{o=l?JSON.parse(l):void 0}catch{o=l}let c;try{const a=this.responseText;c=a?JSON.parse(a):null}catch{c=this.responseText??null}const f=(this._oMethod||"GET")+":"+(this._oUrl||"");m.mocks[f]={url:this._oUrl,method:this._oMethod,request:o,response:c,status:this.status}};return this.addEventListener("readystatechange",T),m._originalXHRSend.apply(this,arguments)},m.websocketEvents=[],m._originalWebSocket=window.WebSocket,window.WebSocket=function(l,T){const o=new m._originalWebSocket(l,T),c=m.websocketEvents.length;m.websocketEvents.push({url:typeof l=="string"?l:String(l),protocol:Array.isArray(T)?T[0]:T,open:!0,messages:[]}),o.addEventListener("message",a=>{const u=typeof a.data=="string"?a.data:String(a.data);m.websocketEvents[c].messages.push({dir:"in",data:u})}),o.addEventListener("close",()=>{m.websocketEvents[c].open=!1});const f=o.send.bind(o);return o.send=function(a){const u=typeof a=="string"?a:String(a);return m.websocketEvents[c].messages.push({dir:"out",data:u}),f(a)},o};const R={"data-o-init":1,"data-o-init-i":1,"data-o-state":1},b=(l,T)=>{if(t.D.querySelectorAll(l).length<=1)return l;let o=T;for(;o&&o!==t.D.body;){let c=o.id?"#"+o.id:null;if(!c&&o.attributes){const f=t.autotag?"data-"+t.autotag:null;if(f){const a=o.getAttribute(f);a!=null&&(c=`[${f}="${a}"]`)}if(!c){for(const a of o.attributes)if(a.name.startsWith("data-")&&!R[a.name]){c=`[${a.name}="${a.value}"]`;break}}}if(c){const f=c+" "+l;if(t.D.querySelectorAll(f).length===1)return f}o=o.parentElement}return l},h=l=>{if(!l||l.nodeType!==1)return"";let T="";if(l.dataset){const o=t.autotag&&l.dataset[t.autotag];o&&(T=b(`[data-${t.autotag}="${o}"]`,l.parentElement))}if(!T&&l.tagName){const o=l.id?"#"+l.id:l.className?l.tagName.toLowerCase()+"."+[...l.classList].join("."):l.tagName.toLowerCase();T=l.id?o:b(o,l.parentElement)}return T},v=n&&t.D.querySelector(n)||t.D.body;m._observer=new MutationObserver(l=>{const T=m.actions.length-1;if(T<0)return;const o=m.actions[T];t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] MutationObserver batch:",{actionIdx:T,lastAction:o?{type:o.type,target:o.target}:null,mutationTypes:l.map(c=>c.type),addedCount:l.reduce((c,f)=>c+(f.addedNodes?.length||0),0),removedCount:l.reduce((c,f)=>c+(f.removedNodes?.length||0),0)}),l.forEach(c=>{const f=(a,u)=>{let D,w;if(a&&v&&v.querySelectorAll(a).length>1){let S=u;for(;S&&S!==v&&S.nodeType===1;){const A=t.autotag&&S.dataset&&S.dataset[t.autotag];if(A){const y=`[data-${t.autotag}="${A}"]`,N=v.querySelectorAll(y);if(N.length>1){const q=[...N].indexOf(S);if(q!==-1){D=y,w=q;break}}}S=S.parentElement}}return{listSelector:D,index:w}};if(c.type==="childList"&&(c.addedNodes.forEach(a=>{if(a.nodeType!==1||!a.offsetParent)return;const u=h(a);if(!u||m.assertions.some(A=>A.actionIdx===T&&A.selector===u&&A.type==="visible"))return;const D=(a.textContent?.trim()||"").slice(0,80)||void 0,{listSelector:w,index:$}=f(u,a),S={actionIdx:T,type:"visible",selector:u,text:D};w!=null&&(S.listSelector=w),$!=null&&(S.index=$),m.assertions.push(S),t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] +visible assertion:",{actionIdx:T,lastAction:o?.type+" "+o?.target,selector:u,text:(D||"").slice(0,40),index:$,listSelector:w})}),c.removedNodes.forEach(a=>{if(a.nodeType!==1)return;const u=h(a);if(!u)return;const D=(a.textContent?.trim()||"").slice(0,80)||void 0,w=c.target;let $;a.previousSibling?$=Array.from(w.children).indexOf(a.previousSibling)+1:a.nextSibling?$=Array.from(w.children).indexOf(a.nextSibling):$=0;let S;if(t.autotag&&a.dataset?.[t.autotag]){const y=a.dataset[t.autotag];S=`[data-${t.autotag}="${y}"]`}const A={actionIdx:T,type:"removed",selector:u,text:D};S&&(A.listSelector=S),A.index=$,m.removedElements.push(A),t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] +removed element:",{actionIdx:T,lastAction:o?.type+" "+o?.target,selector:u,text:(D||"").slice(0,40),index:$,listSelector:S})})),c.type==="attributes"){const a=c.attributeName;if(!a)return;const u=h(c.target);if(!u)return;const w={class:"class",style:"style",hidden:"hidden",disabled:"disabled","aria-expanded":"aria-expanded","aria-checked":"aria-checked"}[a];if(!w||m.assertions.some(q=>q.actionIdx===T&&q.selector===u&&q.type===w))return;const{listSelector:$,index:S}=f(u,c.target),A=c.target;let y;w==="class"?y=A.className:w==="style"?y=A.style?.cssText||A.getAttribute("style")||"":w==="hidden"?y=A.hidden:w==="disabled"?y=A.disabled===!0:w==="aria-expanded"?y=A.getAttribute("aria-expanded"):w==="aria-checked"&&(y=A.getAttribute("aria-checked"));const N={actionIdx:T,type:w,selector:u};w==="class"?N.className=y:w==="style"?N.style=y:w==="hidden"?N.hidden=y:w==="disabled"?N.disabled=y:w==="aria-expanded"?N.ariaExpanded=y:w==="aria-checked"&&(N.ariaChecked=y),$!=null&&(N.listSelector=$),S!=null&&(N.index=S),m.assertions.push(N),t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] +attr assertion:",{actionIdx:T,lastAction:o?.type+" "+o?.target,selector:u,type:w,value:y,index:S,listSelector:$})}})}),m._observer.observe(v,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","disabled","aria-expanded","aria-checked"]});const I={};L.forEach(l=>{const T=o=>{const c=o.target;if(n&&v&&c?.nodeType===1&&!v.contains(c))return;let f="";if(c?.dataset){const j=t.autotag&&c.dataset[t.autotag];j&&(f=b(`[data-${t.autotag}="${j}"]`,c.parentElement))}if(!f&&c?.tagName){const j=c.id?"#"+c.id:c.className?c.tagName.toLowerCase()+"."+[...c.classList].join("."):c.tagName.toLowerCase();f=c.id?j:b(j,c.parentElement)}let a,u;if(f&&v&&v.querySelectorAll(f).length>1){let P=c;for(;P&&P!==v&&P.nodeType===1;){const X=t.autotag&&P.dataset&&P.dataset[t.autotag];if(X){const W=`[data-${t.autotag}="${X}"]`,s=v.querySelectorAll(W);if(s.length>1){const d=[...s].indexOf(P);if(d!==-1){a=W,u=d;break}}}P=P.parentElement}}const D=c?.tagName?c.tagName.toLowerCase()+(c.type?":"+c.type:""):void 0,w=l==="scroll"?window.scrollY:void 0,$=l==="input"||l==="change"?c?.value:void 0,S=l==="change"&&(c?.type==="checkbox"||c?.type==="radio")?c?.checked:void 0,A=l==="keydown"?c?.key:void 0,y=l==="keydown"?c?.code:void 0,N=l==="click"||l==="change"||l==="submit"?0:g[l]!==void 0?g[l]:k[l]??0,q=()=>{if((l==="blur"||l==="focus")&&f){const P=m.actions.length-1,X=P>=0?m.actions[P]:null;if(X){if(X.target===f&&X.listSelector==null==(a==null)&&X.targetIndex==null==(u==null)&&(X.targetIndex==null||X.targetIndex===u))return;for(const s of m.removedElements)if(s.actionIdx===P&&(s.selector===f||f.startsWith(s.selector+" ")||f.startsWith(s.selector+">")))return}}const j={type:l,target:f,time:Date.now()};D&&(j.targetType=D),w!==void 0&&(j.scrollY=w),$!==void 0&&(j.value=$),S!==void 0&&(j.checked=S),A!==void 0&&(j.key=A),y!==void 0&&(j.code=y),a!=null&&(j.listSelector=a),u!=null&&(j.targetIndex=u),m.actions.push(j)};N===0?q():(clearTimeout(I[l]),I[l]=setTimeout(q,N))};t.D.addEventListener(l,T,!0),m._listeners.push({ev:l,handler:T})})},t.stopRecording=()=>{const n=t.recorder;return n.active=!1,n._originalFetch&&(window.fetch=n._originalFetch,n._originalFetch=null),n._originalXHROpen&&(XMLHttpRequest.prototype.open=n._originalXHROpen,XMLHttpRequest.prototype.send=n._originalXHRSend,n._originalXHROpen=null,n._originalXHRSend=null),n._originalWebSocket&&(window.WebSocket=n._originalWebSocket,n._originalWebSocket=null),n._listeners.forEach(({ev:e,handler:i})=>{t.D.removeEventListener(e,i,!0)}),n._listeners=[],n._observer&&(n._observer.disconnect(),n._observer=null),{actions:[...n.actions],mocks:{...n.mocks},initialData:{...n.initialData},stepDelays:{...n.stepDelays},assertions:[...n.assertions||[]],removedElements:[...n.removedElements||[]],observeRoot:n.observeRoot||null,websocketEvents:[...n.websocketEvents||[]]}},t.clearRecording=n=>{if(n!==void 0)sessionStorage?.removeItem("oTest-Recording-"+n);else for(let e=sessionStorage?.length-1;e>=0;e--){const i=sessionStorage?.key(e);i&&i.indexOf("oTest-Recording-")===0&&sessionStorage?.removeItem(i)}},t.runRecordingAssertions=(n,e,i,r)=>{const p=r&&r.assertions,L=p??(n.assertions||[]).filter(o=>i==null||o.actionIdx===i);t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[runRecordingAssertions] run:",{actionIdx:i,scope:i==null?"teardown (all)":"per-action",assertionsCount:L.length,assertions:L.map(o=>({actionIdx:o.actionIdx,type:o.type,selector:o.selector,index:o.index,text:(o.text||"").slice(0,40)}))});const g=new Set,k=L.filter(o=>{const c=`${o.selector}|${o.type}|${o.actionIdx}|${o.index??""}`;return g.has(c)?!1:(g.add(c),!0)}),R=(()=>{if(e!=null)return typeof e=="string"?t.D.querySelector(e)||t.D.body:e;const o=n.observeRoot;return o&&t.D.querySelector(o)||t.D.body})(),b=o=>(o||"").trim().replace(/\s+/g," "),h=o=>o?b(o.textContent||""):"",v=r?.removedElements||[],I=o=>{if(!v.length||i==null)return!1;const c=b(o.text||"");for(const f of v)if(!(f.actionIdx>i)&&b(f.text||"")===c&&f.selector===o.selector&&!(o.listSelector!=null&&f.listSelector!==o.listSelector)&&!(o.index!=null&&f.index!==o.index))return!0;return!1};let l=0;const T=[];for(const o of k){if(I(o)){l+=1,t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[runRecordingAssertions] skip (explicit removed):",{actionIdx:o.actionIdx,selector:o.selector,text:(o.text||"").slice(0,40)});continue}let c=null,f=!1;if(o.listSelector!=null&&o.index!=null){const a=R.querySelectorAll(o.listSelector),u=b(o.text||""),D=$=>{const S=a[$];return S?(o.selector!==o.listSelector?S.querySelector(o.selector):S)||(o.selector!==o.listSelector?S:null):null};let w=a[o.index];if(!w&&o.index>0&&(w=a[o.index-1]),w){if(c=D(o.index)||(o.index>0?D(o.index-1):null),!c&&o.selector!==o.listSelector&&(c=w),o.type==="visible"&&u&&c){const $=h(c);if($.indexOf(u)===-1&&u.indexOf($)===-1)for(let A=0;A<a.length;A++){const y=D(A);if(y&&h(y).indexOf(u)!==-1){c=y,w=a[A];break}}}}else f=!0}else{const a=R.querySelectorAll(o.selector);c=a.length>0?a[0]:t.D.querySelector(o.selector)}if(o.type==="visible"){const a=c&&c.nodeType===1&&(c.offsetParent!==null||c.getBoundingClientRect&&c.getBoundingClientRect().width>0),u=b(o.text||""),D=h(c),w=D,$=!u||D.indexOf(u)!==-1||w.indexOf(u)!==-1||u.length>0&&u.indexOf(D)!==-1;if(a&&$)l+=1;else{const S=f?`index out of bounds (list has ${R.querySelectorAll(o.listSelector||o.selector).length} items, assertion expected index ${o.index})`:c?a?$?"fail":"text mismatch":"not visible":"element not found";T.push({selector:o.selector,message:S}),typeof console<"u"&&console.warn&&console.warn("[runRecordingAssertions] visible failed:",{actionIdx:o.actionIdx,selector:o.selector,listSelector:o.listSelector,index:o.index,expectedText:o.text||"(any)",actualText:D.slice(0,80),message:S})}}else if(o.type==="class"){const a=(o.className||"").trim().split(/\s+/).filter(Boolean);if(c&&(a.length===0||a.every(D=>c.classList?.contains(D))))l+=1;else{const D=f?`index out of bounds (list has ${R.querySelectorAll(o.listSelector).length} items, expected index ${o.index})`:c?`expected class "${o.className}"`:"element not found";T.push({selector:o.selector,message:D}),typeof console<"u"&&console.warn&&console.warn("[runRecordingAssertions] failed:",{type:o.type,selector:o.selector,actionIdx:o.actionIdx,listSelector:o.listSelector,index:o.index,itemsInRoot:o.listSelector?R.querySelectorAll(o.listSelector).length:"-",message:D})}}else if(o.type==="style"){const a=(o.style||"").trim(),u=(c?.style?.cssText||c?.getAttribute?.("style")||"").trim();if(c&&(!a||u.indexOf(a)!==-1||a===u))l+=1;else{const w=c?`expected style "${a.slice(0,60)}..."`:"element not found";T.push({selector:o.selector,message:w})}}else if(o.type==="hidden")if(c&&c.hidden===o.hidden)l+=1;else{const u=c?`expected hidden=${o.hidden}`:"element not found";T.push({selector:o.selector,message:u})}else if(o.type==="disabled")if(c&&c.disabled===o.disabled)l+=1;else{const u=c?`expected disabled=${o.disabled}`:"element not found";T.push({selector:o.selector,message:u})}else if(o.type==="aria-expanded"){const a=c?.getAttribute?.("aria-expanded");if(c&&(o.ariaExpanded==null||String(a)===String(o.ariaExpanded)))l+=1;else{const D=c?`expected aria-expanded="${o.ariaExpanded}"`:"element not found";T.push({selector:o.selector,message:D})}}else if(o.type==="aria-checked"){const a=c?.getAttribute?.("aria-checked");if(c&&(o.ariaChecked==null||String(a)===String(o.ariaChecked)))l+=1;else{const D=c?`expected aria-checked="${o.ariaChecked}"`:"element not found";T.push({selector:o.selector,message:D})}}}return{passed:l,total:k.length,failures:T}},t.exportTest=(n,e={})=>{const i=e.delay!==void 0?e.delay:16,r={actions:n.actions,assertions:n.assertions||[],observeRoot:n.observeRoot||null},p=n.observeRoot?`(o.D.querySelector('${n.observeRoot.replace(/'/g,"\\'")}') || o.D.body)`:"o.D.body",L=b=>{if(b.listSelector!=null&&b.targetIndex!=null){const h=JSON.stringify(b.listSelector),v=b.target===b.listSelector,I=v?h:JSON.stringify(b.target);return` const items = o.D.querySelectorAll(${h});
|
|
17
|
+
const item = items[${b.targetIndex}];
|
|
17
18
|
let el = null;
|
|
18
|
-
if (item) { el = ${
|
|
19
|
+
if (item) { el = ${v?"item":`item.querySelector(${I}) || item`}; }`}return` const el = o.D.querySelector(${JSON.stringify(b.target)});`},g=i>0?`
|
|
19
20
|
await o.sleep(${i});
|
|
20
21
|
return true;
|
|
21
22
|
`:` return true;
|
|
22
|
-
`,
|
|
23
|
-
`:"")+(
|
|
24
|
-
`:"")+` el.dispatchEvent(new Event('${
|
|
25
|
-
`+
|
|
26
|
-
if (!el && '${
|
|
27
|
-
`+
|
|
28
|
-
const r = o.runRecordingAssertions(recordingData, ${
|
|
23
|
+
`,k=i>0?"async () =>":"() =>",m=[];for(let b=0;b<n.actions.length;b++){const h=n.actions[b];let v;h.type==="scroll"?v=` window.scrollTo(0, ${h.scrollY||0});${g}`:h.type==="input"||h.type==="change"?v=(h.value!==void 0?` el.value = ${JSON.stringify(h.value)};
|
|
24
|
+
`:"")+(h.checked!==void 0?` el.checked = ${h.checked};
|
|
25
|
+
`:"")+` el.dispatchEvent(new Event('${h.type}', {bubbles:true}));${g}`:h.type==="submit"?v=` (el.requestSubmit && el.requestSubmit()) || el.submit();${g}`:h.type==="keydown"?v=` el.dispatchEvent(new KeyboardEvent('keydown', {key:${JSON.stringify(h.key||"")}, code:${JSON.stringify(h.code||"")}, bubbles:true, cancelable:true}));${g}`:h.type==="focus"?v=` el.focus();${g}`:h.type==="blur"?v=` el.blur();${g}`:v=h.type==="click"?` el.click();${g}`:` el.dispatchEvent(new MouseEvent('${h.type}', {bubbles:true,cancelable:true}));${g}`;const I=h.type==="blur"||h.type==="focus";m.push(` ['${h.type} on ${h.target}', ${k} {
|
|
26
|
+
`+L(h)+`
|
|
27
|
+
if (!el && '${h.type}' !== 'scroll') { if (${I}) return true; return 'element not found: ${h.target.replace(/'/g,"\\'")}'; }
|
|
28
|
+
`+v+" }]"),(n.assertions||[]).filter(T=>T.actionIdx===b).length>0&&m.push(` ['assert after ${h.type}', () => {
|
|
29
|
+
const r = o.runRecordingAssertions(recordingData, ${p}, ${b});
|
|
29
30
|
return r.passed === r.total ? true : r.failures.map(f => f.selector + ': ' + f.message).join('; ');
|
|
30
31
|
}]`)}return`// Auto-generated by o.exportTest() \u2014 review and anonymize mocks before committing
|
|
31
32
|
const recordingMocks = ${Object.keys(n.mocks||{}).length?JSON.stringify(n.mocks,null,2):"{}"};
|
|
32
33
|
const recordingData = { actions: ${JSON.stringify(n.actions)}, assertions: ${JSON.stringify(n.assertions||[])}, observeRoot: ${JSON.stringify(n.observeRoot||null)} };
|
|
33
34
|
|
|
34
35
|
o.addTest('Recorded test', [
|
|
35
|
-
${
|
|
36
|
+
${m.join(`,
|
|
36
37
|
`)}
|
|
37
38
|
// Add manual checks: ['Manual: label', () => o.testConfirm('label', ['item1'])],
|
|
38
39
|
], () => {
|
|
39
40
|
// teardown
|
|
40
41
|
});
|
|
41
|
-
`},t.exportPlaywrightTest=(n,e={})=>{const i=e.testName||"Recorded session",r=n.initialData?.url??"/";let
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
`},t.exportPlaywrightTest=(n,e={})=>{const i=e.testName||"Recorded session",r=n.initialData?.url??"/";let p="/";try{p=new URL(r).pathname||"/"}catch{p=r}const L=e.baseUrl||p,g=Object.values(n.mocks).map(l=>{let T=l.url;try{T=new URL(l.url).pathname||T}catch{}T.startsWith("/")||(T="/"+T);const o=JSON.stringify(l.response),c=JSON.stringify(l.request),f=(l.method||"GET").toUpperCase();let a=` if (route.request().method() !== ${JSON.stringify(f)}) { await route.continue(); return; }
|
|
43
|
+
`;return l.request!=null&&(f==="POST"||f==="PUT"||f==="PATCH")&&(a+=` const postData = route.request().postData();
|
|
44
|
+
const body = (() => { try { return JSON.parse(postData || '{}'); } catch { return {}; } })();
|
|
45
|
+
expect(body).toEqual(${c});
|
|
46
|
+
`),` await page.route('**${T}', async route => {
|
|
47
|
+
`+a+` await route.fulfill({ status: ${l.status||200}, contentType: 'application/json',
|
|
48
|
+
body: JSON.stringify(${o}) });
|
|
44
49
|
});`}).join(`
|
|
45
|
-
`),
|
|
50
|
+
`),k=Object.assign({click:100,mouseover:50,scroll:30,input:50,change:50,submit:100,keydown:50,focus:50,blur:50},n.stepDelays||{}),m=n.actions.map((l,T)=>{const o=l.listSelector!=null&&l.targetIndex!=null?l.target!==l.listSelector?`page.locator(${JSON.stringify(l.listSelector)}).nth(${l.targetIndex}).locator(${JSON.stringify(l.target)})`:`page.locator(${JSON.stringify(l.listSelector)}).nth(${l.targetIndex})`:`page.locator(${JSON.stringify(l.target)})`,c=` await page.waitForTimeout(${k[l.type]||50});`;let f;if(l.type==="scroll")f=` await page.evaluate(() => window.scrollTo(0, ${l.scrollY||0}));`;else if(l.type==="mouseover")f=` await ${o}.hover();
|
|
46
51
|
// Pure CSS :hover \u2014 no DOM mutation to assert.
|
|
47
|
-
// Fix: toggle a class in a mouseover handler, or add a page.screenshot() visual check.`;else if(
|
|
48
|
-
await expect(${
|
|
49
|
-
`);return
|
|
50
|
-
|
|
51
|
-
`+
|
|
52
|
-
|
|
52
|
+
// Fix: toggle a class in a mouseover handler, or add a page.screenshot() visual check.`;else if(l.type==="input")f=` await ${o}.fill(${JSON.stringify(l.value||"")});`;else if(l.type==="change"){const u=l.targetType||"";if(u.indexOf(":checkbox")!==-1||u.indexOf(":radio")!==-1){const D=l.checked!==void 0?l.checked:l.value==="true"||l.value==="on";f=` await ${o}.${D?"check":"uncheck"}();`}else u.indexOf("select")!==-1?f=` await ${o}.selectOption(${JSON.stringify(l.value||"")});`:f=` await ${o}.fill(${JSON.stringify(l.value||"")});`}else if(l.type==="submit")f=` await ${o}.evaluate((el) => el.requestSubmit?.() || el.submit());`;else if(l.type==="keydown"){const u=l.key||"";f=u==="Enter"?` await ${o}.press("Enter");`:u?` await ${o}.press(${JSON.stringify(u)});`:` await ${o}.press(${JSON.stringify(l.code||"")});`}else l.type==="focus"?f=` if (await ${o}.count() > 0) await ${o}.focus();`:l.type==="blur"?f=` if (await ${o}.count() > 0) await ${o}.blur();`:f=` await ${o}.click();`;const a=(n.assertions||[]).filter(u=>u.actionIdx===T).filter((u,D,w)=>w.findIndex($=>$.selector===u.selector&&$.type===u.type&&$.index===u.index)===D).map(u=>{const D=u.listSelector!=null&&u.index!=null?u.selector!==u.listSelector?`page.locator(${JSON.stringify(u.listSelector)}).nth(${u.index}).locator(${JSON.stringify(u.selector)})`:`page.locator(${JSON.stringify(u.listSelector)}).nth(${u.index})`:`page.locator(${JSON.stringify(u.selector)})`;if(u.type==="visible"){let w=` await expect(${D}).toBeVisible();`;return u.text&&(w+=`
|
|
53
|
+
await expect(${D}).toContainText(${JSON.stringify(u.text)});`),w}if(u.type==="class"){const w=(u.className||"").trim().split(/\s+/).filter(Boolean);return w.length>0?w.map($=>` await expect(${D}).toHaveClass(${JSON.stringify($)});`).join(`
|
|
54
|
+
`):` // class on ${u.selector} (no specific classes asserted)`}if(u.type==="style"){const w=(u.style||"").trim();if(w){const $=w.match(/(\w+)\s*:\s*([^;]+)/);return $?` await expect(${D}).toHaveCSS(${JSON.stringify($[1])}, ${JSON.stringify($[2].trim())});`:` await expect(${D}).toHaveAttribute("style", ${JSON.stringify(w)});`}return""}return u.type==="hidden"?u.hidden?` await expect(${D}).toBeHidden();`:` await expect(${D}).toBeVisible();`:u.type==="disabled"?u.disabled?` await expect(${D}).toBeDisabled();`:` await expect(${D}).toBeEnabled();`:u.type==="aria-expanded"&&u.ariaExpanded!=null?` await expect(${D}).toHaveAttribute("aria-expanded", ${JSON.stringify(String(u.ariaExpanded))});`:u.type==="aria-checked"&&u.ariaChecked!=null?` await expect(${D}).toHaveAttribute("aria-checked", ${JSON.stringify(String(u.ariaChecked))});`:""}).filter(Boolean).join(`
|
|
55
|
+
`);return f+`
|
|
56
|
+
`+c+(a?`
|
|
57
|
+
`+a:"")}).join(`
|
|
58
|
+
`),R=(n.assertions||[]).length>0,b=n.websocketEvents||[],h=b.length>0&&b.some(l=>l.messages?.length>0),v=h?` const wsCollected = [];
|
|
59
|
+
page.on('websocket', ws => {
|
|
60
|
+
ws.on('framereceived', ev => wsCollected.push({ dir: 'in', payload: typeof ev.payload === 'string' ? ev.payload : String(ev.payload) }));
|
|
61
|
+
ws.on('framesent', ev => wsCollected.push({ dir: 'out', payload: typeof ev.payload === 'string' ? ev.payload : String(ev.payload) }));
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
`:"",I=h?b.flatMap(l=>(l.messages||[]).map(T=>({dir:T.dir,data:T.data}))).map(l=>` expect(wsCollected).toContainEqual({ dir: ${JSON.stringify(l.dir)}, payload: ${JSON.stringify(l.data)} });`).join(`
|
|
65
|
+
`)+`
|
|
66
|
+
|
|
67
|
+
`:"";return`// Auto-generated by o.exportPlaywrightTest() \u2014 review and anonymize mocks before committing
|
|
53
68
|
// Prerequisites: npm install @playwright/test && npx playwright install chromium
|
|
54
69
|
// Run: npx playwright test recorded.spec.ts
|
|
55
70
|
import { test, expect } from '@playwright/test';
|
|
56
71
|
|
|
57
72
|
test(${JSON.stringify(i)}, async ({ page }) => {
|
|
58
|
-
`+(
|
|
59
|
-
`+
|
|
73
|
+
`+(g?` // Network mocks \u2014 edit/anonymize before committing
|
|
74
|
+
`+g+`
|
|
60
75
|
|
|
61
|
-
`:"")+` // Set baseURL in playwright.config.ts: { use: { baseURL: 'https://staging.example.com' } }
|
|
62
|
-
await page.goto(${JSON.stringify(
|
|
76
|
+
`:"")+v+` // Set baseURL in playwright.config.ts: { use: { baseURL: 'https://staging.example.com' } }
|
|
77
|
+
await page.goto(${JSON.stringify(L)});
|
|
63
78
|
|
|
64
|
-
`+(
|
|
79
|
+
`+(m?m+`
|
|
65
80
|
|
|
66
|
-
`:"")+(I?` //
|
|
67
|
-
|
|
81
|
+
`:"")+(I?` // WebSocket verifications
|
|
82
|
+
`+I:"")+(!R&&!h?` // TODO: Add assertions before committing, e.g.:
|
|
68
83
|
// await expect(page.locator('[data-qa="success-panel"]')).toBeVisible();
|
|
69
84
|
// await expect(page).toHaveURL(/\\/confirmation/);
|
|
70
85
|
// await expect(page.locator('[data-qa="error-banner"]')).not.toBeVisible();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
86
|
+
`:R||h?` // Auto-generated assertions above \u2014 review for correctness before committing
|
|
87
|
+
`:"")+`});
|
|
88
|
+
`},t.playRecording=(n,e={})=>{const i=e&&typeof e=="object"&&(e.runAssertions!==void 0||e.root!==void 0||e.manualChecks!==void 0||e.actionDelay!==void 0),r=i?e.mockOverrides||{}:e,p=i&&e.runAssertions,L=i?e.root:void 0,g=i&&e.manualChecks||[],k=i&&e.actionDelay!==void 0?e.actionDelay:16,m=Object.assign({},n.mocks,r),R=window.fetch;window.fetch=($,S={})=>{const y=(S.method||"GET").toUpperCase()+":"+$;if(m[y]){const N=m[y],q=typeof N.response=="string"?N.response:JSON.stringify(N.response);return Promise.resolve(new Response(q,{status:N.status||200}))}return R($,S)};const b=XMLHttpRequest.prototype.open,h=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function($,S){return this._oMethod=($||"GET").toUpperCase(),this._oUrl=S,b.apply(this,arguments)},XMLHttpRequest.prototype.send=function($){const S=this,A=(S._oMethod||"GET")+":"+(S._oUrl||""),y=m[A];if(y){const N=typeof y.response=="string"?y.response:JSON.stringify(y.response);setTimeout(()=>{S.readyState=4,S.status=y.status||200,S.statusText="OK",S.responseText=N,S.response=N,S.dispatchEvent(new Event("readystatechange")),S.dispatchEvent(new Event("load"))},0);return}return h.apply(this,arguments)};const v=()=>{if(L!=null)return typeof L=="string"?t.D.querySelector(L)||t.D.body:L;const $=n.observeRoot;return $&&t.D.querySelector($)||t.D.body},I=p?v():null,l=L!=null?v():t.D,T=n.actions,o=n.assertions||[],c={};for(const $ of o){const S=$.actionIdx;c[S]||(c[S]=[]),c[S].push($)}if(t.recordingAssertionDebug&&p&&typeof console<"u"&&console.log){const $=T.map((S,A)=>({i:A,action:S.type+" "+(S.target||""),assertions:(c[A]||[]).length,assertionDetails:(c[A]||[]).map(y=>({type:y.type,index:y.index,text:(y.text||"").slice(0,30)}))}));console.log("[playRecording] assertions by action:",$)}const f={};for(const $ of g){const S=$.afterAction;f[S]||(f[S]=[]),f[S].push($)}const a=[];let u={passed:0,total:0,failures:[]};for(let $=0;$<T.length;$++){const S=T[$];a.push([`${S.type} on ${S.target}`,async()=>{let y=null;const N=l;if(S.target)if(S.listSelector!=null&&S.targetIndex!=null){const j=N.querySelectorAll(S.listSelector)[S.targetIndex];j&&(y=S.target!==S.listSelector?j.querySelector(S.target):j,!y&&S.target!==S.listSelector&&(y=j))}else y=N.querySelector(S.target);return!y&&S.type!=="scroll"?S.type==="blur"||S.type==="focus"?!0:`element not found: ${S.target}`:(S.type==="scroll"?window.scrollTo(0,S.scrollY||0):S.type==="input"||S.type==="change"?(S.value!==void 0&&(y.value=S.value),S.checked!==void 0&&(y.checked=S.checked),y.dispatchEvent(new Event(S.type,{bubbles:!0}))):S.type==="submit"?typeof y.requestSubmit=="function"?y.requestSubmit():y.submit():S.type==="keydown"?y.dispatchEvent(new KeyboardEvent("keydown",{key:S.key||"",code:S.code||"",bubbles:!0,cancelable:!0})):S.type==="focus"?y.focus():S.type==="blur"?y.blur():S.type==="click"?y.click():y.dispatchEvent(new MouseEvent(S.type,{bubbles:!0,cancelable:!0})),k>0&&await t.sleep(k),!0)}]);const A=c[$];p&&A&&A.length>0&&a.push([`assert after ${S.type}`,()=>new Promise(y=>{const N=()=>{const q=t.runRecordingAssertions(n,I,$,{assertions:A,removedElements:n.removedElements});u.passed+=q.passed,u.total+=q.total,u.failures.push(...q.failures),y(q.passed===q.total?!0:q.failures.map(j=>j.selector+": "+j.message).join("; "))};requestAnimationFrame(()=>requestAnimationFrame(N))})]);for(const y of f[$]||[])a.push([`Manual: ${y.label}`,()=>typeof t.testConfirm=="function"?t.testConfirm(y.label,y.items||[]):{ok:!0}])}for(const $ of f.end||[])a.push([`Manual: ${$.label}`,()=>typeof t.testConfirm=="function"?t.testConfirm($.label,$.items||[]):{ok:!0}]);const D=i&&e.onComplete,w=t.test("Recorded playback",...a,{sync:!0},$=>{window.fetch=R,XMLHttpRequest.prototype.open=b,XMLHttpRequest.prototype.send=h;const S=p&&o.length>0?u:void 0;if(S?.failures?.length>0){t.tRes[$]=!1;const A=S.failures.map(N=>`${N.selector}: ${N.message}`).join("; "),y=t.tStyled?t.tPre+t.tXx+"Assertions failed: "+A+t.tDc:`
|
|
89
|
+
\u2718 Assertions failed: `+A;t.tLog[$]=(t.tLog[$]||"")+y}typeof D=="function"&&D(S)});return p?{testId:w}:w},t.testOverlay=()=>{const n="o-test-overlay-btn",e="o-test-overlay-panel";if(t("#"+n).el)return;const i=()=>{const g=t("#"+e);if(!g.el)return;const k=t.tRes.length;let R=`<b>Tests: ${t.tRes.filter(Boolean).length}/${k}</b><hr style="margin:4px 0">`;t.tLog.forEach((b,h)=>{const v=t.tRes[h];R+=`<div style="margin:2px 0;padding:2px 4px;border-radius:3px;background:${v?"#d4edda":"#f8d7da"};color:${v?"#155724":"#721c24"};font-size:11px;white-space:pre-wrap">${b||"Test #"+h}</div>`}),R+='<button id="o-test-export" style="margin-top:6px;padding:4px 8px;font-size:11px;cursor:pointer">Export results</button>',g.html(R),t("#o-test-export").on("click",()=>{const b=JSON.stringify({results:t.tRes,logs:t.tLog},null,2),h=new Blob([b],{type:"application/json"}),v=t.D.createElement("a");v.href=URL.createObjectURL(h),v.download="objs-test-results.json",v.click()})},r=`<div style="display:flex;align-items:center;gap:12px;"><span class="o-test-overlay-summary" style="flex:1;font-size:13px;cursor:grab;">Tests: 0/0</span><button type="button" class="o-test-overlay-toggle" style="padding:6px 10px;background:#334155;color:#e2e8f0;border:none;border-radius:6px;cursor:pointer;font-size:12px;">List</button><button type="button" class="o-test-overlay-close" style="padding:4px 8px;background:transparent;color:#94a3b8;border:none;border-radius:4px;cursor:pointer;font-size:16px;line-height:1;" title="Close">\xD7</button></div><div id="${e}" style="display:none;margin-top:4px;padding:8px;background:#fff;border:1px solid #334155;border-radius:6px;max-height:240px;overflow-y:auto;box-shadow:0 2px 8px rgba(0,0,0,.15);font-size:11px;user-select:text;cursor:text;"></div>`,p=t.overlay({innerHTML:r,removeExisting:!1,className:"o-test-overlay",id:n,excludeDragSelector:".o-test-overlay-close, .o-test-overlay-toggle, #"+e}),L=()=>{const g=t(".o-test-overlay-summary");g.els.length&&g.innerText(`Tests: ${t.tRes.filter(Boolean).length}/${t.tRes.length}`)};p.first(".o-test-overlay-toggle").on("click",()=>{const g=t("#"+e);if(!g.el)return;const k=g.el.style.display!=="none";g.css({display:k?"none":"block"}),k||i()}),p.first(".o-test-overlay-close").on("click",()=>{p._overlayCleanup()}),t.testOverlay.showPanel=()=>{const g=t("#"+e);g.el&&(g.css({display:"block"}),i(),L())},t._testOverlayBase||(t._testOverlayBase=t.test),t.test=(...g)=>{const k=t._testOverlayBase(...g),m=t.tFns[k];return t.tFns[k]=R=>{typeof m=="function"&&m(R);const b=t("#"+e);b.el&&b.el.style.display!=="none"&&i(),L()},k}},t.overlay=(n={})=>{const{innerHTML:e,onClose:i,timeout:r,excludeDragSelector:p,removeExisting:L=!0,className:g="o-overlay-common",id:k}=n;if(L)t("."+g).remove();else if(k&&t("#"+k).el)return t("#"+k);const m={position:"fixed",left:"50%",bottom:"50px",transform:"translateX(-50%)","z-index":"999999",width:"fit-content","max-width":"min(90vw, 420px)","font-family":"system-ui,sans-serif","user-select":"text"},R="o-overlay-countdown",b='<div class="o-overlay-bar" style="display:flex;flex-direction:column;align-items:stretch;padding:10px 14px;background:#1e293b;color:#e2e8f0;border:1px solid #334155;border-radius:8px;font-size:14px;min-width:200px;max-height:90vh;overflow-y:auto;">'+e+(r?`<div id="${R}" style="margin-top:6px;font-size:11px;color:#94a3b8;"></div>`:"")+"</div>",h=t.initState({tag:"div",className:g,id:k||void 0,style:"position:fixed;left:50%;bottom:50px;transform:translateX(-50%);z-index:999999;width:fit-content;max-width:min(90vw,420px);font-family:system-ui,sans-serif;user-select:text;",html:b}).appendInside("body"),v=()=>h.css(m);let I=null;const l=f=>{I&&(m.left=I.left+(f.clientX-I.startX)+"px",m.top=I.top+(f.clientY-I.startY)+"px",delete m.bottom,m.transform="none",v())},T=()=>{I&&(delete m.cursor,v()),I=null};h.on("mousedown",f=>{if(p&&f.target.closest(p))return;const a=h.el.getBoundingClientRect();I={startX:f.clientX,startY:f.clientY,left:a.left,top:a.top},m.cursor="grabbing",v()}),t.D.addEventListener("mousemove",l),t.D.addEventListener("mouseup",T);let o;const c=()=>{t.D.removeEventListener("mousemove",l),t.D.removeEventListener("mouseup",T),o&&clearInterval(o),h.remove()};if(r&&r>0){let f=Math.ceil(r/1e3);const a=t("#"+R);a.el&&(a.el.textContent=f?`Continue in ${f}s`:""),o=setInterval(()=>{f-=1,a.el&&(a.el.textContent=f>0?`Continue in ${f}s`:""),f<=0&&(clearInterval(o),o=null,c(),typeof i=="function"&&i({ok:!1,errors:["timeout"]}))},1e3)}return h._overlayCleanup=c,h._overlayOnClose=i,h},t.testConfirm=(n,e=[],i={})=>new Promise(r=>{const p=i.confirm||"Continue",L=e.length>0,g=L?"#dc2626":"#2563eb",k=e.map((I,l)=>"o-tc-cb-"+l),R=L?`<style>.o-tc-item-cb{appearance:none;-webkit-appearance:none;width:16px;height:16px;border:2px solid #ef4444;border-radius:3px;background:#fef2f2;flex-shrink:0;cursor:pointer;}.o-tc-item-cb:checked{border-color:#22c55e;background:#22c55e;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");background-size:12px 12px;background-position:center;}</style><ul class="o-tc-list" style="margin:8px 0 0;padding:0;list-style:none;font-size:13px;color:#cbd5e1;cursor:grab;">`+e.map((I,l)=>`<li style="margin-bottom:4px;"><label for="${k[l]}" style="display:flex;align-items:center;gap:8px;cursor:pointer;user-select:none;"><input type="checkbox" id="${k[l]}" class="o-tc-item-cb"> <span>${I}</span></label></li>`).join("")+"</ul>":"",b=`<div style="display:flex;align-items:center;gap:12px;"><span class="o-tc-label" style="flex:1;cursor:grab;">${n}: Paused</span><button type="button" class="o-tc-ok" style="padding:6px 14px;background:${g};color:#fff;border:none;border-radius:6px;font-weight:600;cursor:pointer;font-size:13px;flex-shrink:0;">${p}</button></div>`+R,h=t.overlay({innerHTML:b,timeout:i.timeout,excludeDragSelector:".o-tc-ok",onClose:I=>r(I||{ok:!0})}),v={padding:"6px 14px",background:L?"#dc2626":"#2563eb",color:"#fff",border:"none","border-radius":"6px","font-weight":"600",cursor:"pointer","font-size":"13px","flex-shrink":"0"};if(L){const I=h.first(".o-tc-ok"),l=t(".o-overlay-common .o-tc-item-cb"),T=()=>{const o=l.length>0&&l.els.every(c=>c.checked);I.css({...v,background:o?"#16a34a":"#dc2626"})};l.on("change",T)}h.first(".o-tc-ok").on("click",()=>{let I=[];if(L){const l=t(".o-overlay-common .o-tc-item-cb");l.els.length&&l.els.forEach((T,o)=>{!T.checked&&e[o]!==void 0&&I.push(e[o])})}h._overlayCleanup(),r(I.length===0?{ok:!0}:{ok:!1,errors:I})})});
|
|
74
90
|
|
|
75
91
|
export { o };
|
|
76
92
|
export default o;
|
package/objs.d.ts
CHANGED
|
@@ -103,6 +103,10 @@ export interface RecordedAction {
|
|
|
103
103
|
time: number;
|
|
104
104
|
scrollY?: number;
|
|
105
105
|
value?: string;
|
|
106
|
+
checked?: boolean;
|
|
107
|
+
key?: string;
|
|
108
|
+
code?: string;
|
|
109
|
+
targetType?: string;
|
|
106
110
|
/** When target matches multiple elements, selector for the repeated list item container */
|
|
107
111
|
listSelector?: string;
|
|
108
112
|
/** Index within listSelector matches for replay by index */
|
|
@@ -111,16 +115,29 @@ export interface RecordedAction {
|
|
|
111
115
|
|
|
112
116
|
export type Assertion = {
|
|
113
117
|
actionIdx: number;
|
|
114
|
-
type: 'visible' | 'class';
|
|
118
|
+
type: 'visible' | 'class' | 'style' | 'hidden' | 'disabled' | 'aria-expanded' | 'aria-checked';
|
|
115
119
|
selector: string;
|
|
116
120
|
text?: string;
|
|
117
121
|
className?: string;
|
|
122
|
+
style?: string;
|
|
123
|
+
hidden?: boolean;
|
|
124
|
+
disabled?: boolean;
|
|
125
|
+
ariaExpanded?: string | null;
|
|
126
|
+
ariaChecked?: string | null;
|
|
118
127
|
/** When selector matches multiple, selector for the list item container */
|
|
119
128
|
listSelector?: string;
|
|
120
129
|
/** Index within listSelector matches */
|
|
121
130
|
index?: number;
|
|
122
131
|
};
|
|
123
132
|
|
|
133
|
+
/** WebSocket connection and message capture */
|
|
134
|
+
export interface WebSocketEvent {
|
|
135
|
+
url: string;
|
|
136
|
+
protocol?: string;
|
|
137
|
+
open: boolean;
|
|
138
|
+
messages: Array<{ dir: 'in' | 'out'; data: string }>;
|
|
139
|
+
}
|
|
140
|
+
|
|
124
141
|
/** Full recording object */
|
|
125
142
|
export interface Recording {
|
|
126
143
|
actions: RecordedAction[];
|
|
@@ -129,6 +146,7 @@ export interface Recording {
|
|
|
129
146
|
stepDelays?: Record<string, number>;
|
|
130
147
|
assertions: Assertion[];
|
|
131
148
|
observeRoot: string | null;
|
|
149
|
+
websocketEvents?: WebSocketEvent[];
|
|
132
150
|
}
|
|
133
151
|
|
|
134
152
|
/**
|