objs-core 2.2.1 → 2.4.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 +561 -601
- package/objs-extension/README.md +32 -0
- package/objs-extension/background.js +110 -0
- package/objs-extension/bridge.js +193 -0
- package/objs-extension/icons/icon128.png +0 -0
- package/objs-extension/lib/objs-inject.js +5308 -0
- package/objs-extension/manifest.json +18 -0
- package/objs-extension/sidepanel.css +455 -0
- package/objs-extension/sidepanel.html +56 -0
- package/objs-extension/sidepanel.js +908 -0
- package/objs.built.js +793 -127
- package/objs.built.min.js +69 -44
- package/objs.d.ts +584 -507
- package/objs.js +954 -137
- package/package.json +71 -70
package/objs.built.min.js
CHANGED
|
@@ -1,76 +1,101 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Objs-core library
|
|
3
|
-
* @version 2.
|
|
3
|
+
* @version 2.4.0
|
|
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",x="object",C="function",_="string",D="number",R="notEmptyString",v="undefined",$="dangerouslySetInnerHTML",u,f=t.D,j=-1,O=0,I=0,m=typeof process<"u"||t.D===t.DocumentMVP,s=0,d=0;const N=e,g=o=>typeof o,y=(o,a)=>{for(const b in o)Object.hasOwn(o,b)&&a(b,o)},E=t.onError,S=o=>t.verify(o),w=(o,a="")=>(...b)=>{(t.debug||e.isDebug)&&console.log(a?`${a}()`:o,b.length?"with "+b.join(", "):"without parameters");try{const h=o(b[0],b[i],b[r],b[p]);return h!==u?h:e}catch(h){E(h,a)}},A=o=>{for(s=O;s<=j;s++)o()},B=o=>o?.els?o.el:(g(o)!==x&&(o=t.first(o).el),o),q=(o=!0,a=e.els)=>{const b=a.length;if(e.length=b,j=b-i,O=0,e.el=b?a[0]:u,e.last=b?a[j]:u,o&&(y(e.states,(h,l)=>{delete e[l[h]]}),e.states=[],e.ie={}),Array.isArray(e._refsByIndex)){const h=e._refsByIndex.length;if(h>b)y(e._refsByIndex,l=>{const c=+l;c>=b&&delete e._refsByIndex[c]}),e._refsByIndex.length=b;else if(h<b)for(let l=h;l<b;l++)e._refsByIndex[l]={}}};e.reset=t;const F=o=>{if(m||!o.querySelectorAll)return;const a=o.querySelectorAll("[data-o-init]"),b={};a.forEach(h=>{const l=h.getAttribute("data-o-init");l!==null&&(b[l]||(b[l]=[]),b[l].push(h))}),y(b,h=>{const l=t.inits[h];l&&l.getSSR(Number(h),b[h])})},P=(o,a,b)=>{y(a,h=>{let l=a[h];g(l)===C&&(l=l(b)),h==="append"&&g(l)===x&&(l.els&&(l=[l]),l[0]?.els&&(valueBuff=[],y(l,c=>{valueBuff.push(...l[c].els)}),l=valueBuff)),l!==u&&o.getAttribute(h)!==l&&!["tag","tagName","name","sample","state","events","ssr","nodeName","revertChildren","root","ref"].includes(h)&&(["html","innerHTML"].includes(h)?(o.innerHTML=l,!m&&F(o)):h==="className"?o.setAttribute("class",l):h==="dataset"&&g(l)===x?y(l,c=>{o.dataset[c]=l[c]}):h==="toggleClass"?o.classList.toggle(l):h==="addClass"?g(l)===x?o.classList.add(...l):o.classList.add(l):h==="removeClass"?o.classList.remove(l):h==="style"&&g(l)===x?y(l,c=>{o.style[c]=l[c]}):(h==="append"||h==="children"||h==="childNodes")&&g(l)===x?y(l.length?l:[l],c=>{h==="append"||!o.childNodes[c]?o.appendChild(l[c]):o.childNodes[c]!==l[c]&&o.childNodes[c].replaceWith(l[c])}):o.setAttribute(h,l))}),o.dataset.oState=a.state,t.autotag&&a.name&&(o.dataset[t.autotag]=t.camelToKebab(a.name))};e.debug=w(()=>{e.isDebug=!0},"debug ON"),e.saveAs=w(o=>{S([[o,[R]]]),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),g(e.remove)===C?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=w(o=>{S([[o,[x,C]]]);const a=e.initID||t.inits.length||0;if(e.initID=a,q(),t.inits[e.initID]=e,g(o)==="function"){e.render=w(c=>{const T=f.createElement("div");setTimeout(()=>{t.reactRender(o,T,c)}),e.add(T)});return}(g(o)!==x||o.render===u)&&(o={render:o}),y(o,c=>{e?.render&&c==="render"||(e.states.push(c),e[c]=w((T=[{}])=>{e.currentState=c;const k=o[c]||{tag:"div"},M=Array.isArray(e.els)?e.els.slice(O,j+i):[],U=M.length?M:e.els||[];g(k)===x&&(k.state=c,k["data-o-init"]=a);const z=(W,V={})=>{const X=g(k)===C?k(V):k;if(g(X)===x)return f.createElement(X.tag||X.tagName||"div");const K=f.createElement("div");return K.innerHTML=X,K.children.length>i||!K.firstElementChild?(K.dataset.oInit=W,K):(K.firstElementChild.dataset.oInit=W,K.firstElementChild)},J=T;Array.isArray(T)||(T=[T]),T.length||(T=[T]);const H=!U[0]&&c==="render";T=T.map((W,V)=>{const X=Object.assign({},g(W)===x?W:{},{self:e,o:t,i:W.i===u?V:W.i,parent:e._parent,data:Array.isArray(J)?J[V]:J});return H&&(!k.ssr||m)&&U.push(z(a,X)),X}),H&&(e.els=U,q(!1));const Y=()=>{y(k.events,W=>{e.on(W,k.events[W])})};U&&(d=U.length===T.length,U.map((W,V)=>{T[d?V:0].i=V+O;const X=g(k)===C?k(T[d?V:0]):k;g(X)===x&&(X.state=c,H&&(X["data-o-init"]=a,X["data-o-init-i"]=V,X.events&&(e._hydrateEvents=e._hydrateEvents||[],e._hydrateEvents[V]=X.events)),P(W,X,T[d?V:0]))}),H&&(e._refsByIndex=[],e.refs={},e.els.forEach((W,V)=>{if(!W.querySelectorAll)return;const X={};W.querySelectorAll("[ref]").forEach(K=>{const Q=K.getAttribute("ref"),Z=t(K);X[Q]=Z,V===0&&(e.refs[Q]=Z)}),e._refsByIndex[V]=X}),!m&&e._hydrateEvents&&(e._hydrateEvents.forEach((W,V)=>{W&&(e.select(V),y(W,X=>{const K=W[X];if(g(K)===x&&K.targetRef&&g(K.handler)===C){const Z=(e._refsByIndex?.[V]??e.refs)?.[K.targetRef];Z&&Z.on(X,K.handler)}else g(K)===C&&e.on(X,K)}))}),e.all()))),H&&g(k)===x&&k.events&&!m&&!k.ssr&&Y()}))});const b=o.render||o,h=!m&&g(b)===x&&b.events,l=!m&&e._hydrateEvents&&e._hydrateEvents.length;(h||l)&&(e.initSSRAfterGettingSSR=()=>{e._refsByIndex=[],e.refs={},e.els.forEach((c,T)=>{if(!c.querySelectorAll)return;const k={};c.querySelectorAll("[ref]").forEach(M=>{const U=M.getAttribute("ref"),z=t(M);k[U]=z,T===0&&(e.refs[U]=z),M.removeAttribute("ref")}),e._refsByIndex[T]=k,T===0&&(e.refs=k)}),h&&y(b.events,c=>{e.on(c,b.events[c])}),e._hydrateEvents&&(e._hydrateEvents.forEach((c,T)=>{c&&(e.select(T),y(c,k=>{const M=c[k];if(g(M)===x&&M.targetRef&&g(M.handler)===C){const z=(e._refsByIndex?.[T]??e.refs)?.[M.targetRef];z&&z.on(k,M.handler)}else g(M)===C&&e.on(k,M)}))}),e.all())})},"init"),e.connect=w((o,a="render",b)=>{S([[o,[x]],[a,[R]],[b,[_,v]]]),o.connect(N,a,b)},"connect"),e.getSSR=w((o,a)=>{S([[o,[D,v]]]);const b=o!==void 0?o:e.initID;if(m||g(o)===v&&g(e.initID)===v)return;const h=a&&a.length?a:t.D.querySelectorAll(`[data-o-init="${b}"]`);h.length&&(e.els=Array.from(h),o!==void 0&&(e.initID=o,t.inits[o]=e),q(!1),g(e.initSSRAfterGettingSSR)===C?e.initSSRAfterGettingSSR():a&&a.length&&(e._refsByIndex=[],e.refs={},e.els.forEach((l,c)=>{if(!l.querySelectorAll)return;const T={};l.querySelectorAll("[ref]").forEach(k=>{const M=k.getAttribute("ref");T[M]=t(k),c===0&&(e.refs[M]=T[M]),k.removeAttribute("ref")}),e._refsByIndex[c]=T,c===0&&(e.refs=T)})))},"getSSR"),e.initState=w((o,a)=>{S([[o,[x]],[a,[x,v]]]),e.init(o).render(a)},"initState");const G=(o,a,b)=>{const h=o.attributes,l={tagName:o.tagName.toLowerCase()};for(const c of h)l[c.nodeName]=c.value;if(b){l.innerHTML=o.innerHTML,l.revertChildren=[];const c=o.querySelectorAll("[data-o-init]");for(const T of c){const k=T.getAttribute("data-o-init");l.revertChildren.push(k),t.inits[k]?.saveState(a,!1)}}return l};return e.saveState=w((o,a=!0)=>{if(S([[o,[R,v]],[a,[L]]]),!e.el)throw Error("saveState(): There are no elements to save");const b=o||"fastSavedState",h={els:[],parentNode:e.el.parentNode,root:a};A(()=>{h.els.push(G(e.els[s],b,a))}),h.ie=Object.assign({},e.ie),h.delegated=Object.assign({},e.delegated),h.store=Object.assign({},e.store),e.isRoot=e.isRoot||a,e.savedStates[b]=h},"saveState"),e.revertState=w(o=>{S([[o,[R,v]]]);const a=o||"fastSavedState";if(!e.savedStates[a])throw Error(`revertState(): The state "${a}" should have been saved by saveState()`);const b=e.savedStates[a];e.offAll(),e.offDelegate(),e.store=Object.assign({},b.store),b.els.forEach((h,l)=>{if(!e.els[l]){const c=t.D.createElement(h.tagName);b.parentNode&&(l?e.els[l-1].after(c):b.parentNode.append(c)),e.add(c)}P(e.els[l],h)}),e.delegated=Object.assign({},b.delegated),e.ie=Object.assign({},b.ie),e.onAll(),y(b.delegated,h=>{b.delegated[h].forEach(l=>{A(()=>{e.els[s].addEventListener(h,l)})})}),e.currentState=a,b.root&&b.els.forEach(({rootElement:h})=>{h.revertChildren.forEach(l=>{t.inits[l]?.revertState(a),t('[data-o-init="'+l+'"]').els.forEach((c,T)=>{c.replaceWith(t.inits[l]?.els[T])})})})},"revertState"),e.loseState=w(o=>{S([[o,[R]]]),e.savedStates[o]&&(delete e.savedStates[o],A(()=>{const a=e.els[s].querySelectorAll("[data-o-init]");for(const b of a){const h=b.getAttribute("data-o-init");t.inits[h]?.loseState(o)}}))},"sample"),e.sample=w((o="render")=>(S([[o,[R]]]),{[o]:G(e.els[O])}),"sample"),e.select=w(o=>{let a=o;a!=null&&g(a)===x&&a.target&&e.els.length&&(a=e.els.findIndex(b=>b===a.target||b.contains(a.target)),a<0&&(a=0)),S([[a,[D,v]]]),a===u&&(a=e.length-i),j=a,O=a,e.el=e.els[a],I=i,Array.isArray(e._refsByIndex)&&e._refsByIndex[a]&&(e.refs=e._refsByIndex[a])},"select"),e.all=w(()=>{j=e.length-i,O=0,e.el=e.els[0],I=0,Array.isArray(e._refsByIndex)&&e._refsByIndex.length&&(e.refs=e._refsByIndex[0]||{})},"all"),e.remove=w(o=>{if(S([[o,[D,v]]]),o===u&&I&&(o=O),o!==u){const a=e.els[o];a?.parentNode?a.parentNode.removeChild(a):a===void 0&&o>=e.els.length&&t.onError&&t.onError("remove("+o+"): index out of bounds","remove")}else A(()=>{const a=e.els[s];a?.parentNode&&a.parentNode.removeChild(a)});q(!1)},"remove"),e.skip=w(o=>{S([[o,[D,v]]]),o===u&&(o=O),e.els.splice(o,i),Array.isArray(e._refsByIndex)&&e._refsByIndex.splice(o,i),q()},"skip"),e.add=w(o=>{S([[o,[_,x,D]]]),e.initID===u&&(g(o)==="string"&&o!==""?e.els.push(...Array.from(f.querySelectorAll(o))):g(o)===x?o.tagName?e.els.push(o):o.els?e.els.push(...o.els):o.length&&o[0].tagName&&e.els.push(...o):g(o)==="number"&&t.inits[o]&&(e=t.inits[o]),q(!1),e.initID!==u&&e.dataset({oInit:e.initID}))},"add"),e.appendInside=w(o=>{S([[o,[x,R]]]),o?.els&&(e._parent=o),A(()=>{B(o).appendChild(e.els[s])})},"appendInside"),e.appendBefore=w(o=>{S([[o,[x,R]]]),A(()=>{B(o).parentNode.insertBefore(e.els[s],B(o))})},"appendBefore"),e.appendAfter=w(o=>{S([[o,[x,R]]]),A(()=>{B(o).after(...e.els)})},"appendAfter"),e.find=w((o="")=>{S([[o,_]]);const a=[];return A(()=>{a.push(...Array.from(e.els[s].querySelectorAll(":scope "+o)))}),t(a)},"find"),e.first=w((o="")=>{S([[o,_]]);let a=u;const b=[];return A(()=>{a=e.els[s].querySelector(o),a&&b.push(a)}),t(b)},"first"),e.attr=w((o,a)=>{if(a!==null&&S([[o,_],[a,[_,v]]]),a===u){const b=[];return A(()=>{b[s]=e.els[s].getAttribute(o)}),I?b[0]:b}else A(a!==null?()=>{e.els[s].setAttribute(o,a)}:()=>{e.els[s].removeAttribute(o)})},"attr"),e.attrs=w(()=>{const o=[];return A(()=>{const a={};[...e.els[s].attributes].forEach(b=>{a[b.nodeName]=b.nodeValue}),o.push(a)}),I?o[0]:o},"attrs"),e.dataset=w(o=>{if(S([[o,[x,v]]]),typeof o===x)A(()=>{y(o,a=>{e.els[s].dataset[a]=o[a]})});else{const a=[];return A(()=>{a.push({...e.els[s].dataset})}),I?a[0]:a}},"dataset"),e.style=w(o=>{o!==null&&S([[o,[_,v]]]),e.attr("style",o)},"style"),e.css=w((o={})=>{if(o===null){e.style(null);return}S([[o,x]]);let a="";y(o,b=>{a+=b+":"+o[b].replace('"',"'")+";"}),e.style(a||null)},"css"),e.cssMerge=w((o={})=>{if(o===null){e.style(null);return}S([[o,x]]);const a=h=>h.indexOf("-")!==-1?h:t.camelToKebab(h),b=h=>{const l={};if(!h||typeof h!==_)return l;const c=h.split(";");for(let T=0;T<c.length;T++){const k=c[T],M=k.indexOf(":");if(M===-1)continue;const U=k.slice(0,M).trim(),z=k.slice(M+1).trim();U&&(l[U]=z)}return l};A(()=>{const h=e.els[s],l=b(h.getAttribute("style"));y(o,T=>{const k=a(T),M=o[T];M===null||M===u?delete l[k]:l[k]=String(M).replace('"',"'")});let c="";y(l,T=>{c+=T+":"+l[T]+";"}),c?h.setAttribute("style",c):h.removeAttribute("style")})},"cssMerge"),e.setClass=w(o=>{S([[o,_]]),A(()=>{e.els[s].setAttribute("class",o)})},"setClass"),e.addClass=w((...o)=>{A(()=>{e.els[s].classList.add(...o)})},"addClass"),e.removeClass=w((...o)=>{A(()=>{e.els[s].classList.remove(...o)})},"removeClass"),e.toggleClass=w((o,a)=>{S([[o,R],[a,[L,v]]]),A(()=>{e.els[s].classList.toggle(o,a)})},"toggleClass"),e.haveClass=o=>{S([[o,R]]);let a=!0;return A(()=>{e.els[s].classList.contains(o)||(a=!1)}),(e.isDebug||t.debug)&&console.log("haveClass() with",o),a},e.innerHTML=w(o=>{if(S([[o,[_,v]]]),o!==u)A(()=>{e.els[s].innerHTML=o});else{let a="";return A(()=>{a+=m&&e.els[s].innerHTML.length===0?t.D.parseElement(e.els[s],!1):e.els[s].innerHTML}),a}},"innerHTML"),e.innerText=w(o=>{S([[o,[_]]]),A(()=>{e.els[s].innerText=o})},"innerText"),e.textContent=w(o=>{S([[o,[_]]]),A(()=>{e.els[s].textContent=o})},"textContent"),e.html=w(o=>{if(S([[o,[_,v]]]),o!==void 0)e.innerHTML(o);else{let a="";return A(()=>{a+=m?e.els[s].outerHTML():e.els[s].outerHTML}),a}},"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=w(o=>{if(o===void 0)return e.el?.value;A(()=>{e.els[s].value=o})},"val"),e.forEach=w(o=>{S([[o,[C]]]),A(()=>{o({self:e,i:s,o:t,el:e.els[s]})})},"forEach"),e.prepareFor=w((o,a)=>{S([[o,[x,C,v]],[a,[C,v]]]);const b=o&&g(o)===x&&o.createElement;if(!b&&g(o)!==C)throw Error("prepareFor(): pass React (full object) or React.createElement as first argument");const h=b?o.createElement:o,l=b?o.useEffect:void 0;return c=>{if(c.ref===u)throw Error("No ref property to convert Objs to React");const T=Object.assign({},c),k=h("div",{ref:c.ref});return delete T.ref,l(()=>{y(T,M=>{if(M.substring(0,1)==="on"){const U=t.camelToKebab(M).split("-")[1];e.on(U,T[M]),delete T[M]}}),e.render(T),e.appendInside(k.ref.current)},[]),k}},"prepareFor"),e.on=w((o,a,b,h)=>{S([[o,[R]],[a,[C]],[b,[x,v]],[h,[L,v]]]),o.split(", ").forEach(l=>{A(()=>{e.els[s].addEventListener(l,a,b,h)}),e.ie[l]||(e.ie[l]=[]),e.ie[l].push([a,b,h])})},"on"),e.off=w((o,a,b)=>{S([[o,[R]],[a,[C]],[b,[x,v]]]),o.split(", ").forEach(h=>{A(()=>{e.els[s].removeEventListener(h,a,b)}),e.ie[h]&&(e.ie[h]=e.ie[h].filter(l=>l[0]!==a))})},"off"),e.onDelegate=w((o,a,b)=>{S([[o,[R]],[a,[R]],[b,[C]]]),o.split(", ").forEach(h=>{const l=c=>{const T=c.target.closest(a);T&&(c.delegate=T,c.objs=e,b(c))};A(()=>{e.els[s].addEventListener(h,l)}),e.delegated[h]||(e.delegated[h]=[]),e.delegated[h].push(l)})},"onDelegate"),e.offDelegate=w(o=>{S([[o,[R]]]),y(e.delegated,a=>{if(!o||o===a)for(;e.delegated[a].length;){const b=e.delegated[a].pop();A(()=>{e.els[s].removeEventListener(a,b)})}}),e.delegated={}},"offDelegate"),e.onParent=w((o,a,b)=>{S([[o,[R]],[a,[R,x]],[b,[C]]]);const h=g(a)===x?a:t.D.querySelector(a);o.split(", ").forEach(l=>{const c=T=>{T.objs=e,b(T)};h.addEventListener(l,c),e.parented[l]||(e.parented[l]=[]),e.parented[l].push(c)})},"onParent"),e.offParent=w((o,a)=>{S([[o,[R]],[a,[R,x]]]);const b=g(a)===x?a:t.D.querySelector(a);y(e.parented,h=>{(!o||o===h)&&(e.parented[h].forEach(l=>{b.removeEventListener(h,l)}),delete e.parented[h])})},"offParent"),e.onAll=w((o,a)=>{S([[o,[R,v]],[a,[L,v]]]),y(e.ie,(b,h)=>{(!o||o===b)&&h[b].forEach(l=>{A(()=>{a?e.els[s].removeEventListener(b,l[0]):e.els[s].addEventListener(b,l[0],l[i],l[r])})})})},"onAll"),e.offAll=w(o=>{S([[o,[R]]]),e.onAll(o,i)},"offAll"),n&&e.add(n),e.take=o=>{if(S([[o,[_,x,D]]]),e.add(o),e.el){const a=e.el.dataset.oInit;if(a!==u&&t.inits[a])return e.length===i?(d=e.els[0],Object.assign(e,t.inits[a]),e.els=[d]):e=t.inits[a],q(!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(x=>!!t.specialTypes[x]);for(const x of p)if(L=t.specialTypes[x](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 x in r)t.C(r,x)&&(L+=` ${p}${t.camelToKebab(x)}="${typeof r[x]!="object"?r[x]:Object.entries(r[x]).map(C=>`${C[0]}: ${C[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"],x=L!==void 0?` data-o-init="${L}"`:"";return`<${p}${n.className?` class="${n.className}"`:""}${i(n.attributes)}${x}${i(n.dataset,"data-")}${r.includes(p)?"/":""}>${r.includes(p)?"":n.innerHTML.length?n.innerHTML:n.children.map(C=>t.D.parseElement(C)).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=x=>{r=!1,p=!1,i=null,setTimeout(()=>{x.then(C=>{r=!0,!C.ok&&typeof C.ok<"u"?(p=!0,e.forEach(([_,D,R])=>{R&&_[R](C)})):typeof C.json=="function"?C.json().then(_=>{i=_,e.forEach(([D,R])=>{D[R](i)})}):(i=C,e.forEach(([_,D])=>{_[D](i)}))}).catch(C=>{p=!0,e.forEach(([_,D,R])=>{R&&_[R](C)})})},33)};return n&&L(n),{reload:L,isObjsLoader:!0,listeners:e,isFinished:()=>r,getStore:()=>i,connect:(x,C="render",_)=>{t.verify([[x,["object"]],[C,["notEmptyString"]],[_,["string","undefined"]]]),r?p?_&&x[_]():typeof x[C]=="function"&&x[C](i):e.push([x,C,_])},disconnect:x=>{t.verify([[x,["object"]]]),e=e.filter(([C])=>C!==x)}}},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="",x=!1;const C="function",_=-1;if(typeof n!="object"||!n)return t.incSet[0];t.incSet[0]++;const D=t.incSet[0];t.incSet[D]=e||0,t.incReady[D]=[];const R=t.incReady[D];R[0]=1;const v={};for(const $ in n)if(t.C(n,$)){if($==="preload"){x=!0;continue}L=t.incGetHash(n[$]),r++,t.incN++;const u=n[$].indexOf(".css")>_?"style":"script";if(n[$]=(t.incSource?t.incSource+"/":"")+n[$],Number.isNaN(Number($))&&t.C(t.incFns,$)&&t.incFns[$]&&!t.incForce){R[r]={name:$,loaded:1},p++;continue}if(R[r]={name:$,loaded:0},Number.isNaN(Number($))&&(t.incFns[$]=0),Number.isNaN(Number($))&&t.incCache&&(n[$].substring(0,4)!=="http"||!t.incCors)&&window.location.protocol!=="file:"&&(n[$].indexOf(".css")>_||n[$].indexOf(".js")>_)){const f=localStorage,j=f.getItem("oInc-"+$),O=f.getItem("oInc-"+$+"-expires"),I=f.getItem("oInc-"+$+"-hash");j&&O&&Date.now()<O&&I===L?(x||t.initState({tag:u,id:"oInc-"+D+"-"+r,innerHTML:j,"data-o-inc":D}).appendInside("head"),R[r].loaded=1,t.incFns[$]=1,p++):(v[$]=r,t.get(n[$],{mode:t.incCors?"cors":"same-origin"}).then(m=>{if(m.status!==200){t.onError&&t.onError({message:t.incSource+n[$]+" was not loaded"});return}m.text().then(s=>{f.setItem("oInc-"+$,s),f.setItem("oInc-"+$+"-expires",Date.now()+t.incCacheExp),f.setItem("oInc-"+$+"-hash",L),x||t.initState({tag:u,id:"oInc-"+D+"-"+v[$],innerHTML:s,"data-o-inc":D}).appendInside("head"),t.incCheck(D,v[$],1)})}))}else{const f={tag:u,id:"oInc-"+D+"-"+r,"data-o-inc":D,async:t.incAsync,onload:"o.incCheck("+D+","+r+",1)"};n[$].indexOf(".css")>_?(f.tag="link",f.rel="stylesheet",f.href=n[$]):(n[$].indexOf(".js")>_||(f.tag="img",f.style="display:none;"),f.src=n[$]),t.initState(f).appendInside(f.style?"body":"head")}}return R[0]+=p,r!==0&&(p===r?typeof e===C&&e(D):setTimeout($=>{t.incReady[$]&&t.incReady[$].length<t.incReady[$][0]&&(t.incSet[$]=0,typeof i===C&&i(D))},t.incTimeout,D)),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 x=n.useContext(e);return n.useEffect(()=>{if(typeof r[p]=="function"){const C=i(x);r[p](C!==null&&typeof C=="object"?C:{value:C})}},[x]),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: ",x="\u251C \u2718 ",C=`
|
|
7
|
+
`,_=`
|
|
8
|
+
`,D="",R=e.length,v=0;const $=(O="",I=!1,m=!1)=>{t.tAutolog&&(I?console.error(O):(t.tShowOk||m)&&console.log(O))};let u={};if(typeof e[R-1]=="function"&&(t.tFns[r]=e[R-1],R--),R>0&&typeof e[R-1]=="object"&&!Array.isArray(e[R-1])&&(e[R-1].sync!==void 0||e[R-1].confirmOnFailure!==void 0)&&(u=e[R-1],R--),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 I=t.tStatus[r][O];(I===!0||I===!1)&&v++}}t.tStyled&&(L=t.tPre+t.tOk,x=t.tPre+t.tXx,C=t.tDc,_=C+C),(!i||t.tLog[r].length===0)&&($("\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]=R,t.tFinalized[r]=!1;const f=(O,I)=>new Promise(m=>{const s=t.overlay({innerHTML:`<div style="display:flex;flex-direction:column;gap:8px;"><div style="cursor:grab;">Step ${O+1} failed: ${I||"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:u.confirmOnFailureTimeout||void 0,onClose:d=>m(d||{continue:!1}),excludeDragSelector:".o-cf-continue, .o-cf-stop"});s.first(".o-cf-continue").on("click",()=>{s._overlayCleanup(),m({continue:!0})}),s.first(".o-cf-stop").on("click",()=>{s._overlayCleanup(),m({continue:!1})})}),j=()=>{if(t.tFinalized[r])return;if(p>0){D="\u251C ",D+="DONE "+v+"/"+R+", waiting: "+p,$(D,!0),t.tStyled?t.tLog[r]+=t.tPre+'<div style="color:orange;"><b>DONE '+v+"/"+R+", waiting: "+p+"</b>"+t.tDc+t.tDc:t.tLog[r]+=D+`
|
|
10
|
+
`;return}t.tFinalized[r]=!0;const O=t.tStatus[r].some(I=>I===!1);t.tRes[r]=!O&&v===R,D="\u2558 ",D+="DONE "+v+"/"+R,$(D,v!==R),$(),t.tStyled?t.tLog[r]+=t.tPre+'<div style="color:'+(v!==R?"red":"green")+';"><b>DONE '+v+"/"+R+"</b>"+t.tDc+t.tDc:t.tLog[r]+=D+`
|
|
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(u.sync||u.confirmOnFailure)return(async()=>{for(let O=t.tStatus[r].length;O<R;O++){const I={n:r,i:O,title:e[O][0],tShowOk:t.tShowOk,tStyled:t.tStyled};let m=e[O][1];if(typeof m>"u"){t.tStyled?t.tLog[r]+="<div>"+I.title+"</div>":t.tLog[r]+=I.title+`
|
|
12
|
+
`,$("\u251C "+I.title,!1,!0),t.tStatus[r][O]=!0,v++;continue}if(typeof t.tBeforeEach=="function"&&t.tBeforeEach(I),typeof m=="function")try{m=m(I)}catch(s){m=s.message,t.onError&&t.onError(s)}if(typeof t.tAfterEach=="function"&&t.tAfterEach(I,m),m&&typeof m.then=="function"){try{const s=await m,d=s===!0||s==null||s&&typeof s=="object"&&s.ok===!0,N=s&&s.errors&&s.errors.length?s.errors.join("; "):typeof s=="string"?s:"";if(t.testUpdate(I,d,d?"":N?": "+N:""),v++,!d&&u.confirmOnFailure&&!(await f(O,N)).continue)break}catch(s){if(t.testUpdate(I,!1,s.message||"Promise rejected"),u.confirmOnFailure&&!(await f(O,s.message||"Promise rejected")).continue)break}continue}if(typeof t.tStatus[r][O]>"u")t.tStatus[r][O]=typeof m=="string"?t.F:m;else{sessionStorage.setItem(`oTest-Status-${r}`,JSON.stringify(t.tStatus[r]));return}if(m===!0)v++,t.tShowOk&&(t.tLog[r]+=L+e[O][0]+C,$("\u251C OK: "+e[O][0]));else if(m!==t.U){if(t.tLog[r]+=x+e[O][0]+(m!==t.F?": "+m:"")+_,$("\u251C \u2718 "+e[O][0]+(m!==t.F?": "+m:""),!0),u.confirmOnFailure&&!(await f(O,typeof m=="string"?m:"")).continue)break}else{p++,setTimeout(s=>{s.title+=" (timeout)",t.testUpdate(s)},t.tTime,I);return}}j()})(),r;for(let O=t.tStatus[r].length;O<R;O++){const I={n:r,i:O,title:e[O][0],tShowOk:t.tShowOk,tStyled:t.tStyled};let m=e[O][1];if(typeof m>"u"){t.tStyled?t.tLog[r]+="<div>"+I.title+"</div>":t.tLog[r]+=I.title+`
|
|
13
|
+
`,$("\u251C "+I.title,!1,!0),t.tStatus[r][O]=!0,v++;continue}if(typeof t.tBeforeEach=="function"&&t.tBeforeEach(I),typeof m=="function")try{m=m(I)}catch(s){m=s.message,t.onError&&t.onError(s)}if(typeof t.tAfterEach=="function"&&t.tAfterEach(I,m),m&&typeof m.then=="function"){p++;const s=setTimeout(()=>{I.title+=" (timeout)",t.testUpdate(I)},t.tTime);m.then(d=>{clearTimeout(s);const N=d===!0||d&&d.ok===!0,g=d&&d.errors&&d.errors.length?d.errors.join("; "):typeof d=="string"?d:"";t.testUpdate(I,N,N?"":g?": "+g:"")}).catch(d=>{clearTimeout(s),t.testUpdate(I,!1,d.message||"Promise rejected")});continue}if(typeof t.tStatus[r][O]>"u")t.tStatus[r][O]=typeof m=="string"?t.F:m;else{sessionStorage.setItem(`oTest-Status-${r}`,JSON.stringify(t.tStatus[r]));return}m===!0?(v++,t.tShowOk&&(t.tLog[r]+=L+e[O][0]+C,$("\u251C OK: "+e[O][0]))):m!==t.U?(t.tLog[r]+=x+e[O][0]+(m!==t.F?": "+m:"")+_,$("\u251C \u2718 "+e[O][0]+(m!==t.F?": "+m:""),!0)):(p++,setTimeout(s=>{s.title+=" (timeout)",t.testUpdate(s)},t.tTime,I))}return j(),r},t.testUpdate=(n,e=t.F,i="")=>{t.verify([[n,["object"]],[e,["boolean","string"]],[i,["string"]]]);let r="";const p=n.n,L=(x="",C=!1)=>{t.tAutolog&&(C?console.error(x):console.log(x))};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 x=0,C=0;for(const D of t.tStatus[p]){if(D===t.U||D===null)return;D||x++,C++}const _=t.tests[p]?.tests?.length??t.tExpectedSteps[p]??Number.MAX_SAFE_INTEGER;if(C<_){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]=!x,r=x?"FAILED "+x+"/"+C:"DONE "+C+"/"+C,L("\u2558 "+r,!!x),L(),n.tStyled?t.tLog[p]+=t.tPre+'<b style="color:'+(x?"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,strictCapture:null,_originalFetch:null,_listeners:[],_observer:null},t.recordingAssertionDebug=!1,t.startRecording=(n,e,i)=>{if(t.recorder.active)return;let r,p,L,x=null;if(n!=null&&typeof n=="object"&&!Array.isArray(n)&&(t.C(n,"observe")||t.C(n,"events")||t.C(n,"timeouts")||t.C(n,"strictCaptureAssertions")||t.C(n,"strictCaptureNetwork")||t.C(n,"strictCaptureWebSocket"))){const s=n;r=s.observe!=null?String(s.observe):void 0,p=s.events,L=s.timeouts,(t.C(s,"strictCaptureAssertions")||t.C(s,"strictCaptureNetwork")||t.C(s,"strictCaptureWebSocket"))&&(x={assertions:!!s.strictCaptureAssertions,network:!!s.strictCaptureNetwork,websocket:!!s.strictCaptureWebSocket})}else r=typeof n=="string"?n:void 0,p=e,L=i;const _=["click","mouseover","scroll","input","change","submit","keydown","focus","blur"],D={click:100,mouseover:50,scroll:30,input:50,change:50,submit:100,keydown:50,focus:50,blur:50},R=p||_,v=Object.assign({},D,L||{}),$={scroll:30,mouseover:50,keydown:50,focus:50,blur:50},u=t.recorder;u.active=!0,u.actions=[],u.mocks={},u.stepDelays=v,u.initialData={url:window.location.href,timestamp:Date.now()},u.strictCapture=x,u.observeRoot=r||null,u.assertions=[],u.removedElements=[],t.inits.forEach((s,d)=>{s?.store&&(u.initialData["init_"+d]=JSON.parse(JSON.stringify(s.store)))}),u._originalFetch=window.fetch,window.fetch=async(s,d={})=>{const N=(d.method||"GET").toUpperCase();let g;try{g=d.body?JSON.parse(d.body):void 0}catch{g=d.body}const y=await u._originalFetch(s,d),E=y.clone();let S;try{S=await E.json()}catch{S=await E.text().catch(()=>null)}const w=N+":"+s;return u.mocks[w]={url:s,method:N,request:g,response:S,status:y.status},y},u._originalXHROpen=XMLHttpRequest.prototype.open,u._originalXHRSend=XMLHttpRequest.prototype.send,XMLHttpRequest.prototype.open=function(s,d){return this._oMethod=(s||"GET").toUpperCase(),this._oUrl=d,u._originalXHROpen.apply(this,arguments)},XMLHttpRequest.prototype.send=function(s){const d=()=>{if(this.readyState!==4)return;let N;try{N=s?JSON.parse(s):void 0}catch{N=s}let g;try{const E=this.responseText;g=E?JSON.parse(E):null}catch{g=this.responseText??null}const y=(this._oMethod||"GET")+":"+(this._oUrl||"");u.mocks[y]={url:this._oUrl,method:this._oMethod,request:N,response:g,status:this.status}};return this.addEventListener("readystatechange",d),u._originalXHRSend.apply(this,arguments)},u.websocketEvents=[],u._originalWebSocket=window.WebSocket,window.WebSocket=function(s,d){const N=new u._originalWebSocket(s,d),g=u.websocketEvents.length;u.websocketEvents.push({url:typeof s=="string"?s:String(s),protocol:Array.isArray(d)?d[0]:d,open:!0,messages:[]}),N.addEventListener("message",E=>{const S=typeof E.data=="string"?E.data:String(E.data);u.websocketEvents[g].messages.push({dir:"in",data:S})}),N.addEventListener("close",()=>{u.websocketEvents[g].open=!1});const y=N.send.bind(N);return N.send=function(E){const S=typeof E=="string"?E:String(E);return u.websocketEvents[g].messages.push({dir:"out",data:S}),y(E)},N};const f={"data-o-init":1,"data-o-init-i":1,"data-o-state":1},j=(s,d)=>{if(t.D.querySelectorAll(s).length<=1)return s;let N=d;for(;N&&N!==t.D.body;){let g=N.id?"#"+N.id:null;if(!g&&N.attributes){const y=t.autotag?"data-"+t.autotag:null;if(y){const E=N.getAttribute(y);E!=null&&(g=`[${y}="${E}"]`)}if(!g){for(const E of N.attributes)if(E.name.startsWith("data-")&&!f[E.name]){g=`[${E.name}="${E.value}"]`;break}}}if(g){const y=g+" "+s;if(t.D.querySelectorAll(y).length===1)return y}N=N.parentElement}return s},O=s=>{if(!s||s.nodeType!==1)return"";let d="";if(s.dataset){const N=t.autotag&&s.dataset[t.autotag];N&&(d=j(`[data-${t.autotag}="${N}"]`,s.parentElement))}if(!d&&s.tagName){const N=s.id?"#"+s.id:s.className?s.tagName.toLowerCase()+"."+[...s.classList].join("."):s.tagName.toLowerCase();d=s.id?N:j(N,s.parentElement)}return d},I=r&&t.D.querySelector(r)||t.D.body;u._observer=new MutationObserver(s=>{const d=u.actions.length-1;if(d<0)return;const N=u.actions[d];t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] MutationObserver batch:",{actionIdx:d,lastAction:N?{type:N.type,target:N.target}:null,mutationTypes:s.map(g=>g.type),addedCount:s.reduce((g,y)=>g+(y.addedNodes?.length||0),0),removedCount:s.reduce((g,y)=>g+(y.removedNodes?.length||0),0)}),s.forEach(g=>{const y=(E,S)=>{let w,A;if(E&&I){const B=I.querySelectorAll(E);if(B.length>1){const q=[...B].indexOf(S);if(q!==-1)w=E,A=q;else{let F=S;for(;F&&F!==I&&F.nodeType===1;){const P=t.autotag&&F.dataset&&F.dataset[t.autotag];if(P){const G=`[data-${t.autotag}="${P}"]`,o=I.querySelectorAll(G);if(o.length>1){const a=[...o].indexOf(F);if(a!==-1){w=G,A=a;break}}}F=F.parentElement}}}}return{listSelector:w,index:A}};if(g.type==="childList"&&(g.addedNodes.forEach(E=>{if(E.nodeType!==1||!E.offsetParent)return;const S=O(E);if(!S||u.assertions.some(F=>F.actionIdx===d&&F.selector===S&&F.type==="visible"))return;const w=(E.textContent?.trim()||"").slice(0,80)||void 0,{listSelector:A,index:B}=y(S,E),q={actionIdx:d,type:"visible",selector:S,text:w};A!=null&&(q.listSelector=A),B!=null&&(q.index=B),u.assertions.push(q),t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] +visible assertion:",{actionIdx:d,lastAction:N?.type+" "+N?.target,selector:S,text:(w||"").slice(0,40),index:B,listSelector:A})}),g.removedNodes.forEach(E=>{if(E.nodeType!==1)return;const S=O(E);if(!S)return;const w=(E.textContent?.trim()||"").slice(0,80)||void 0,A=g.target;let B;E.previousSibling?B=Array.from(A.children).indexOf(E.previousSibling)+1:E.nextSibling?B=Array.from(A.children).indexOf(E.nextSibling):B=0;let q;if(t.autotag&&E.dataset?.[t.autotag]){const P=E.dataset[t.autotag];q=`[data-${t.autotag}="${P}"]`}const F={actionIdx:d,type:"removed",selector:S,text:w};q&&(F.listSelector=q),F.index=B,u.removedElements.push(F),t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] +removed element:",{actionIdx:d,lastAction:N?.type+" "+N?.target,selector:S,text:(w||"").slice(0,40),index:B,listSelector:q})})),g.type==="attributes"){const E=g.attributeName;if(!E)return;const S=O(g.target);if(!S)return;const A={class:"class",style:"style",hidden:"hidden",disabled:"disabled","aria-expanded":"aria-expanded","aria-checked":"aria-checked"}[E];if(!A||u.assertions.some(o=>o.actionIdx===d&&o.selector===S&&o.type===A))return;const{listSelector:B,index:q}=y(S,g.target),F=g.target;let P;A==="class"?P=F.className:A==="style"?P=F.style?.cssText||F.getAttribute("style")||"":A==="hidden"?P=F.hidden:A==="disabled"?P=F.disabled===!0:A==="aria-expanded"?P=F.getAttribute("aria-expanded"):A==="aria-checked"&&(P=F.getAttribute("aria-checked"));const G={actionIdx:d,type:A,selector:S};A==="class"?G.className=P:A==="style"?G.style=P:A==="hidden"?G.hidden=P:A==="disabled"?G.disabled=P:A==="aria-expanded"?G.ariaExpanded=P:A==="aria-checked"&&(G.ariaChecked=P),B!=null&&(G.listSelector=B),q!=null&&(G.index=q),u.assertions.push(G),t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] +attr assertion:",{actionIdx:d,lastAction:N?.type+" "+N?.target,selector:S,type:A,value:P,index:q,listSelector:B})}})}),u._observer.observe(I,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","disabled","aria-expanded","aria-checked"]});const m={};R.forEach(s=>{const d=N=>{const g=N.target;if(r&&I&&g?.nodeType===1&&!I.contains(g))return;let y="";if(g?.dataset){const a=t.autotag&&g.dataset[t.autotag];a&&(y=j(`[data-${t.autotag}="${a}"]`,g.parentElement))}if(!y&&g?.tagName){const a=g.id?"#"+g.id:g.className?g.tagName.toLowerCase()+"."+[...g.classList].join("."):g.tagName.toLowerCase();y=g.id?a:j(a,g.parentElement)}let E,S;if(y&&I){const a=I.querySelectorAll(y);if(a.length>1){const b=[...a].indexOf(g);if(b!==-1)E=y,S=b;else{let h=g;for(;h&&h!==I&&h.nodeType===1;){const l=t.autotag&&h.dataset&&h.dataset[t.autotag];if(l){const c=`[data-${t.autotag}="${l}"]`,T=I.querySelectorAll(c);if(T.length>1){const k=[...T].indexOf(h);if(k!==-1){E=c,S=k;break}}}h=h.parentElement}}}}const w=g?.tagName?g.tagName.toLowerCase()+(g.type?":"+g.type:""):void 0,A=s==="scroll"?window.scrollY:void 0,B=s==="input"||s==="change"?g?.value:void 0,q=s==="change"&&(g?.type==="checkbox"||g?.type==="radio")?g?.checked:void 0,F=s==="keydown"?g?.key:void 0,P=s==="keydown"?g?.code:void 0,G=s==="click"||s==="change"||s==="submit"?0:v[s]!==void 0?v[s]:$[s]??0,o=()=>{if((s==="blur"||s==="focus")&&y){const b=u.actions.length-1,h=b>=0?u.actions[b]:null;if(h){if(h.target===y&&h.listSelector==null==(E==null)&&h.targetIndex==null==(S==null)&&(h.targetIndex==null||h.targetIndex===S))return;for(const c of u.removedElements)if(c.actionIdx===b&&(c.selector===y||y.startsWith(c.selector+" ")||y.startsWith(c.selector+">")))return}}const a={type:s,target:y,time:Date.now()};w&&(a.targetType=w),A!==void 0&&(a.scrollY=A),B!==void 0&&(a.value=B),q!==void 0&&(a.checked=q),F!==void 0&&(a.key=F),P!==void 0&&(a.code=P),E!=null&&(a.listSelector=E),S!=null&&(a.targetIndex=S),u.actions.push(a)};G===0?o():(clearTimeout(m[s]),m[s]=setTimeout(o,G))};t.D.addEventListener(s,d,!0),u._listeners.push({ev:s,handler:d})})},t.stopRecording=()=>{const n=t.recorder;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:i,handler:r})=>{t.D.removeEventListener(i,r,!0)}),n._listeners=[],n._observer&&(n._observer.disconnect(),n._observer=null);const e={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||[]]};return n.strictCapture&&(e.strictCapture={...n.strictCapture}),e},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.strictAssertions),L=r&&r.strictRemoved!==void 0?!!r.strictRemoved:p,x=r&&r.assertions,C=x??(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:C.length,assertions:C.map(s=>({actionIdx:s.actionIdx,type:s.type,selector:s.selector,index:s.index,text:(s.text||"").slice(0,40)}))});const _=new Set,D=C.filter(s=>{const d=`${s.selector}|${s.type}|${s.actionIdx}|${s.index??""}`;return _.has(d)?!1:(_.add(d),!0)}),v=(()=>{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})(),$=s=>(s||"").trim().replace(/\s+/g," "),u=s=>$(String(s||"").replace(/\s*:\s*/g,": ").replace(/\s*;\s*/g,"; ")),f=s=>s?$(s.textContent||""):"",j=r?.removedElements||[],O=s=>{if(!j.length||i==null)return!1;const d=$(s.text||"");for(const N of j)if(!(N.actionIdx>i)&&$(N.text||"")===d&&N.selector===s.selector&&!(s.listSelector!=null&&N.listSelector!==s.listSelector)&&!(s.index!=null&&N.index!==s.index))return!0;return!1};let I=0;const m=[];for(const s of D){if(O(s)){if(!L){I+=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 y=null;const E=$(s.text||"");if(s.listSelector!=null&&s.index!=null){const S=v.querySelectorAll(s.listSelector);let w=S[s.index];if(!w&&s.index>0&&(w=S[s.index-1]),w&&(y=s.selector!==s.listSelector&&w.querySelector(s.selector)||w),!y&&E&&s.type==="visible")for(let A=0;A<S.length;A++){const B=S[A],q=s.selector!==s.listSelector&&B.querySelector(s.selector)||B;if(q&&f(q).indexOf(E)!==-1){y=q;break}}}else{const S=v.querySelectorAll(s.selector);y=S.length>0?S[0]:t.D.querySelector(s.selector)}if(y&&s.type==="visible"){const S=y.nodeType===1&&(y.offsetParent!==null||y.getBoundingClientRect&&y.getBoundingClientRect().width>0),w=f(y);if(S&&(!E||w.indexOf(E)!==-1||E.indexOf(w)!==-1)){m.push({selector:s.selector,message:"expected absent (recorded removed) but matching content still visible"});continue}}else if(y&&s.type!=="visible"){m.push({selector:s.selector,message:"expected absent (recorded removed) but element still present"});continue}I+=1;continue}let d=null,N=!1,g=-1;if(s.listSelector!=null&&s.index!=null){const y=v.querySelectorAll(s.listSelector);g=y.length;const E=$(s.text||""),S=A=>{const B=y[A];return B?(s.selector!==s.listSelector?B.querySelector(s.selector):B)||(s.selector!==s.listSelector?B:null):null};let w;if(p)w=y[s.index],w&&(d=S(s.index),!d&&s.selector!==s.listSelector&&(d=w));else if(w=y[s.index],!w&&s.index>0&&(w=y[s.index-1]),w&&(d=S(s.index)||(s.index>0?S(s.index-1):null),!d&&s.selector!==s.listSelector&&(d=w),s.type==="visible"&&E&&d)){const A=f(d);if(A.indexOf(E)===-1&&E.indexOf(A)===-1)for(let q=0;q<y.length;q++){const F=S(q);if(F&&f(F).indexOf(E)!==-1){d=F,w=y[q];break}}}w||(N=!0)}else{const y=v.querySelectorAll(s.selector);d=y.length>0?y[0]:t.D.querySelector(s.selector)}if(s.type==="visible"){const y=d&&d.nodeType===1&&(d.offsetParent!==null||d.getBoundingClientRect&&d.getBoundingClientRect().width>0),E=$(s.text||""),S=f(d),w=p?!E||S===E:!E||S.indexOf(E)!==-1||E.length>0&&E.indexOf(S)!==-1;if(y&&w)I+=1;else{const A=g>=0?g:v.querySelectorAll(s.listSelector||s.selector).length,B=N?`index out of bounds (list has ${A} items, assertion expected index ${s.index})`:d?y?w?"fail":"text mismatch":"not visible":"element not found";m.push({selector:s.selector,message:B}),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:S.slice(0,80),message:B})}}else if(s.type==="class"){const y=(s.className||"").trim().split(/\s+/).filter(Boolean),E=d&&(y.length===0||y.every(w=>d.classList?.contains(w))),S=!p||!s.className||$((d?.className||"").trim())===$((s.className||"").trim());if(E&&S)I+=1;else{const w=N?`index out of bounds (list has ${v.querySelectorAll(s.listSelector).length} items, expected index ${s.index})`:d?E&&!S?`expected exact className "${s.className}" (strict)`:`expected class "${s.className}"`:"element not found";m.push({selector:s.selector,message:w}),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?v.querySelectorAll(s.listSelector).length:"-",message:w})}}else if(s.type==="style"){const y=(s.style||"").trim(),E=(d?.style?.cssText||d?.getAttribute?.("style")||"").trim();if(d&&(!y||(p?u(E)===u(y):E.indexOf(y)!==-1||y===E)))I+=1;else{const w=d?`expected style "${y.slice(0,60)}..."`:"element not found";m.push({selector:s.selector,message:w})}}else if(s.type==="hidden")if(d&&d.hidden===s.hidden)I+=1;else{const E=d?`expected hidden=${s.hidden}`:"element not found";m.push({selector:s.selector,message:E})}else if(s.type==="disabled")if(d&&d.disabled===s.disabled)I+=1;else{const E=d?`expected disabled=${s.disabled}`:"element not found";m.push({selector:s.selector,message:E})}else if(s.type==="aria-expanded"){const y=d?.getAttribute?.("aria-expanded");if(d&&(s.ariaExpanded==null||String(y)===String(s.ariaExpanded)))I+=1;else{const S=d?`expected aria-expanded="${s.ariaExpanded}"`:"element not found";m.push({selector:s.selector,message:S})}}else if(s.type==="aria-checked"){const y=d?.getAttribute?.("aria-checked");if(d&&(s.ariaChecked==null||String(y)===String(s.ariaChecked)))I+=1;else{const S=d?`expected aria-checked="${s.ariaChecked}"`:"element not found";m.push({selector:s.selector,message:S})}}}return{passed:I,total:D.length,failures:m}},t.exportTest=(n,e={})=>{const i=e.delay!==void 0?e.delay:16,r=e.extensionExport===!0,p={actions:n.actions,assertions:n.assertions||[],observeRoot:n.observeRoot||null},L=n.observeRoot?`(o.D.querySelector('${n.observeRoot.replace(/'/g,"\\'")}') || o.D.body)`:"o.D.body",x=u=>{if(u.listSelector!=null&&u.targetIndex!=null){const f=JSON.stringify(u.listSelector),j=u.target===u.listSelector,O=j?f:JSON.stringify(u.target);return` const items = o.D.querySelectorAll(${f});
|
|
17
|
+
const item = items[${u.targetIndex}];
|
|
17
18
|
let el = null;
|
|
18
|
-
if (item) { el = ${
|
|
19
|
+
if (item) { el = ${j?"item":`item.querySelector(${O}) || item`}; }`}return` const el = o.D.querySelector(${JSON.stringify(u.target)});`},C=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
|
+
`,_=i>0?"async () =>":"() =>",D=[];for(let u=0;u<n.actions.length;u++){const f=n.actions[u];let j;f.type==="scroll"?j=` window.scrollTo(0, ${f.scrollY||0});${C}`:f.type==="input"||f.type==="change"?j=(f.value!==void 0?` el.value = ${JSON.stringify(f.value)};
|
|
24
|
+
`:"")+(f.checked!==void 0?` el.checked = ${f.checked};
|
|
25
|
+
`:"")+` el.dispatchEvent(new Event('${f.type}', {bubbles:true}));${C}`:f.type==="submit"?j=` (el.requestSubmit && el.requestSubmit()) || el.submit();${C}`:f.type==="keydown"?j=` el.dispatchEvent(new KeyboardEvent('keydown', {key:${JSON.stringify(f.key||"")}, code:${JSON.stringify(f.code||"")}, bubbles:true, cancelable:true}));${C}`:f.type==="focus"?j=` el.focus();${C}`:f.type==="blur"?j=` el.blur();${C}`:j=f.type==="click"?` el.click();${C}`:` el.dispatchEvent(new MouseEvent('${f.type}', {bubbles:true,cancelable:true}));${C}`;const O=f.type==="blur"||f.type==="focus";D.push(` ['${f.type} on ${f.target}', ${_} {
|
|
26
|
+
`+x(f)+`
|
|
27
|
+
if (!el && '${f.type}' !== 'scroll') { if (${O}) return true; return 'element not found: ${f.target.replace(/'/g,"\\'")}'; }
|
|
28
|
+
`+j+" }]"),(n.assertions||[]).filter(m=>m.actionIdx===u).length>0&&D.push(` ['assert after ${f.type}', () => {
|
|
29
|
+
const r = o.runRecordingAssertions(recordingData, ${L}, ${u});
|
|
29
30
|
return r.passed === r.total ? true : r.failures.map(f => f.selector + ': ' + f.message).join('; ');
|
|
30
|
-
}]`)}
|
|
31
|
+
}]`)}const v=`// 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
|
-
o.
|
|
35
|
-
${
|
|
35
|
+
`,$=" // Add manual checks: ['Manual: label', () => o.testConfirm('label', ['item1'])],";return r?v+`const __objsExtensionTestRun = o.test('Recorded test',
|
|
36
|
+
${D.join(`,
|
|
37
|
+
`)},
|
|
38
|
+
${$}
|
|
39
|
+
{ sync: true }, () => {
|
|
40
|
+
// teardown
|
|
41
|
+
});
|
|
42
|
+
`:v+`o.addTest('Recorded test', [
|
|
43
|
+
${D.join(`,
|
|
36
44
|
`)}
|
|
37
|
-
|
|
45
|
+
${$}
|
|
38
46
|
], () => {
|
|
39
47
|
// teardown
|
|
40
48
|
});
|
|
41
|
-
`},t.exportPlaywrightTest=(n,e={})=>{const i=e.testName||"Recorded session",r=n.initialData?.url??"/";let
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
`},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,x=Object.values(n.mocks).map(f=>{let j=f.url;try{j=new URL(f.url).pathname||j}catch{}j.startsWith("/")||(j="/"+j);const O=JSON.stringify(f.response),I=JSON.stringify(f.request),m=(f.method||"GET").toUpperCase();let s=` if (route.request().method() !== ${JSON.stringify(m)}) { await route.continue(); return; }
|
|
50
|
+
`;return f.request!=null&&(m==="POST"||m==="PUT"||m==="PATCH")&&(s+=` const postData = route.request().postData();
|
|
51
|
+
const body = (() => { try { return JSON.parse(postData || '{}'); } catch { return {}; } })();
|
|
52
|
+
expect(body).toEqual(${I});
|
|
53
|
+
`),` await page.route('**${j}', async route => {
|
|
54
|
+
`+s+` await route.fulfill({ status: ${f.status||200}, contentType: 'application/json',
|
|
55
|
+
body: JSON.stringify(${O}) });
|
|
44
56
|
});`}).join(`
|
|
45
|
-
`),
|
|
57
|
+
`),C=Object.assign({click:100,mouseover:50,scroll:30,input:50,change:50,submit:100,keydown:50,focus:50,blur:50},n.stepDelays||{}),_=n.actions.map((f,j)=>{const O=f.listSelector!=null&&f.targetIndex!=null?f.target!==f.listSelector?`page.locator(${JSON.stringify(f.listSelector)}).nth(${f.targetIndex}).locator(${JSON.stringify(f.target)})`:`page.locator(${JSON.stringify(f.listSelector)}).nth(${f.targetIndex})`:`page.locator(${JSON.stringify(f.target)})`,I=` await page.waitForTimeout(${C[f.type]||50});`;let m;if(f.type==="scroll")m=` await page.evaluate(() => window.scrollTo(0, ${f.scrollY||0}));`;else if(f.type==="mouseover")m=` await ${O}.hover();
|
|
46
58
|
// 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(f.type==="input")
|
|
48
|
-
await expect(${
|
|
49
|
-
`);return y
|
|
50
|
-
|
|
51
|
-
`+
|
|
52
|
-
|
|
59
|
+
// Fix: toggle a class in a mouseover handler, or add a page.screenshot() visual check.`;else if(f.type==="input")m=` await ${O}.fill(${JSON.stringify(f.value||"")});`;else if(f.type==="change"){const d=f.targetType||"";if(d.indexOf(":checkbox")!==-1||d.indexOf(":radio")!==-1){const N=f.checked!==void 0?f.checked:f.value==="true"||f.value==="on";m=` await ${O}.${N?"check":"uncheck"}();`}else d.indexOf("select")!==-1?m=` await ${O}.selectOption(${JSON.stringify(f.value||"")});`:m=` await ${O}.fill(${JSON.stringify(f.value||"")});`}else if(f.type==="submit")m=` await ${O}.evaluate((el) => el.requestSubmit?.() || el.submit());`;else if(f.type==="keydown"){const d=f.key||"";m=d==="Enter"?` await ${O}.press("Enter");`:d?` await ${O}.press(${JSON.stringify(d)});`:` await ${O}.press(${JSON.stringify(f.code||"")});`}else f.type==="focus"?m=` if (await ${O}.count() > 0) await ${O}.focus();`:f.type==="blur"?m=` if (await ${O}.count() > 0) await ${O}.blur();`:m=` await ${O}.click();`;const s=(n.assertions||[]).filter(d=>d.actionIdx===j).filter((d,N,g)=>g.findIndex(y=>y.selector===d.selector&&y.type===d.type&&y.index===d.index)===N).map(d=>{const N=d.listSelector!=null&&d.index!=null?d.selector!==d.listSelector?`page.locator(${JSON.stringify(d.listSelector)}).nth(${d.index}).locator(${JSON.stringify(d.selector)})`:`page.locator(${JSON.stringify(d.listSelector)}).nth(${d.index})`:`page.locator(${JSON.stringify(d.selector)})`;if(d.type==="visible"){let g=` await expect(${N}).toBeVisible();`;return d.text&&(g+=`
|
|
60
|
+
await expect(${N}).toContainText(${JSON.stringify(d.text)});`),g}if(d.type==="class"){const g=(d.className||"").trim().split(/\s+/).filter(Boolean);return g.length>0?g.map(y=>` await expect(${N}).toHaveClass(${JSON.stringify(y)});`).join(`
|
|
61
|
+
`):` // class on ${d.selector} (no specific classes asserted)`}if(d.type==="style"){const g=(d.style||"").trim();if(g){const y=g.match(/(\w+)\s*:\s*([^;]+)/);return y?` await expect(${N}).toHaveCSS(${JSON.stringify(y[1])}, ${JSON.stringify(y[2].trim())});`:` await expect(${N}).toHaveAttribute("style", ${JSON.stringify(g)});`}return""}return d.type==="hidden"?d.hidden?` await expect(${N}).toBeHidden();`:` await expect(${N}).toBeVisible();`:d.type==="disabled"?d.disabled?` await expect(${N}).toBeDisabled();`:` await expect(${N}).toBeEnabled();`:d.type==="aria-expanded"&&d.ariaExpanded!=null?` await expect(${N}).toHaveAttribute("aria-expanded", ${JSON.stringify(String(d.ariaExpanded))});`:d.type==="aria-checked"&&d.ariaChecked!=null?` await expect(${N}).toHaveAttribute("aria-checked", ${JSON.stringify(String(d.ariaChecked))});`:""}).filter(Boolean).join(`
|
|
62
|
+
`);return m+`
|
|
63
|
+
`+I+(s?`
|
|
64
|
+
`+s:"")}).join(`
|
|
65
|
+
`),D=(n.assertions||[]).length>0,R=n.websocketEvents||[],v=R.length>0&&R.some(f=>f.messages?.length>0),$=v?` const wsCollected = [];
|
|
66
|
+
page.on('websocket', ws => {
|
|
67
|
+
ws.on('framereceived', ev => wsCollected.push({ dir: 'in', payload: typeof ev.payload === 'string' ? ev.payload : String(ev.payload) }));
|
|
68
|
+
ws.on('framesent', ev => wsCollected.push({ dir: 'out', payload: typeof ev.payload === 'string' ? ev.payload : String(ev.payload) }));
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
`:"",u=v?R.flatMap(f=>(f.messages||[]).map(j=>({dir:j.dir,data:j.data}))).map(f=>` expect(wsCollected).toContainEqual({ dir: ${JSON.stringify(f.dir)}, payload: ${JSON.stringify(f.data)} });`).join(`
|
|
72
|
+
`)+`
|
|
73
|
+
|
|
74
|
+
`:"";return`// Auto-generated by o.exportPlaywrightTest() \u2014 review and anonymize mocks before committing
|
|
53
75
|
// Prerequisites: npm install @playwright/test && npx playwright install chromium
|
|
54
76
|
// Run: npx playwright test recorded.spec.ts
|
|
55
77
|
import { test, expect } from '@playwright/test';
|
|
56
78
|
|
|
57
79
|
test(${JSON.stringify(i)}, async ({ page }) => {
|
|
58
|
-
`+(
|
|
59
|
-
`+
|
|
80
|
+
`+(x?` // Network mocks \u2014 edit/anonymize before committing
|
|
81
|
+
`+x+`
|
|
60
82
|
|
|
61
|
-
`:"")
|
|
62
|
-
await page.goto(${JSON.stringify(
|
|
83
|
+
`:"")+$+` // Set baseURL in playwright.config.ts: { use: { baseURL: 'https://staging.example.com' } }
|
|
84
|
+
await page.goto(${JSON.stringify(L)});
|
|
63
85
|
|
|
64
|
-
`+(
|
|
86
|
+
`+(_?_+`
|
|
65
87
|
|
|
66
|
-
`:"")+(
|
|
67
|
-
|
|
88
|
+
`:"")+(u?` // WebSocket verifications
|
|
89
|
+
`+u:"")+(!D&&!v?` // TODO: Add assertions before committing, e.g.:
|
|
68
90
|
// await expect(page.locator('[data-qa="success-panel"]')).toBeVisible();
|
|
69
91
|
// await expect(page).toHaveURL(/\\/confirmation/);
|
|
70
92
|
// await expect(page.locator('[data-qa="error-banner"]')).not.toBeVisible();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
93
|
+
`:D||v?` // Auto-generated assertions above \u2014 review for correctness before committing
|
|
94
|
+
`:"")+`});
|
|
95
|
+
`},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||e.skipWebSocketMock!==void 0||e.skipNetworkMocks!==void 0||e.recordingAssertionDebug!==void 0||e.strictPlay!==void 0||e.strictAssertions!==void 0||e.strictNetwork!==void 0||e.strictWebSocket!==void 0||e.strictRemoved!==void 0||e.onComplete!==void 0),r=i?e.mockOverrides||{}:e,p=i&&e.runAssertions,L=i?e.root:void 0,x=i&&e.manualChecks||[],C=i&&e.actionDelay!==void 0?e.actionDelay:16,_=i&&e.skipWebSocketMock,D=i&&e.skipNetworkMocks;i&&e.recordingAssertionDebug!==void 0&&(t.recordingAssertionDebug=!!e.recordingAssertionDebug);const R=n.strictCapture||{},v=i&&e.strictPlay===!0,$=i&&e.strictAssertions!==void 0?!!e.strictAssertions:v?!0:!!R.assertions,u=i&&e.strictNetwork!==void 0?!!e.strictNetwork:v?!0:!!R.network,f=i&&e.strictWebSocket!==void 0?!!e.strictWebSocket:v?!0:!!R.websocket,j=i&&e.strictRemoved!==void 0?!!e.strictRemoved:$,O=l=>{if(!(l==null||l==="")){if(typeof l=="string")try{return JSON.parse(l)}catch{return l}return l}},I=(l,c)=>{const T=O(c);return l===T||l==null&&T==null?!0:l==null||T==null?!1:typeof l=="object"&&typeof T=="object"?JSON.stringify(l)===JSON.stringify(T):String(l)===String(T)},m=l=>String(l||"").trim().replace(/\s+/g," "),s=Object.assign({},n.mocks,r),d=window.fetch,N=XMLHttpRequest.prototype.open,g=XMLHttpRequest.prototype.send;D||(window.fetch=(l,c={})=>{const k=(c.method||"GET").toUpperCase()+":"+l;if(s[k]){const M=s[k];if(u&&t.C(M,"request")&&!I(M.request,c.body))return Promise.reject(new Error("[Objs playRecording] strictNetwork: request body does not match recording for "+k));const U=typeof M.response=="string"?M.response:JSON.stringify(M.response);return Promise.resolve(new Response(U,{status:M.status||200}))}return d(l,c)},XMLHttpRequest.prototype.open=function(l,c){return this._oMethod=(l||"GET").toUpperCase(),this._oUrl=c,N.apply(this,arguments)},XMLHttpRequest.prototype.send=function(l){const c=this,T=(c._oMethod||"GET")+":"+(c._oUrl||""),k=s[T];if(k){if(u&&t.C(k,"request")&&!I(k.request,l)){setTimeout(()=>{c.readyState=4,c.status=0,c.statusText="Objs strictNetwork mismatch",c.dispatchEvent(new Event("readystatechange")),c.dispatchEvent(new Event("error"))},0);return}const M=typeof k.response=="string"?k.response:JSON.stringify(k.response);setTimeout(()=>{c.readyState=4,c.status=k.status||200,c.statusText="OK",c.responseText=M,c.response=M,c.dispatchEvent(new Event("readystatechange")),c.dispatchEvent(new Event("load"))},0);return}return g.apply(this,arguments)});let y=null;const E=n.websocketEvents||[];if(!_&&E.length>0&&E.some(l=>l.messages&&l.messages.length>0)&&typeof window.WebSocket=="function"){y=window.WebSocket;let l=0;const c=z=>{const J=typeof z=="string"?z:String(z);try{return new URL(J,window.location.href).href}catch{return J}},T=z=>{const J=c(z);for(let H=l;H<E.length;H++)if(c(E[H].url)===J)return l=H+1,E[H];for(let H=l;H<E.length;H++)if(String(E[H].url)===String(z))return l=H+1,E[H];return null},k=y;class M extends EventTarget{constructor(J,H,Y){super();const W=typeof J=="string"?J:String(J);this.url=W,this.readyState=k.CONNECTING;const V=H;this.protocol=Array.isArray(V)?V[0]||"":V?String(V):"",this.extensions="",this.binaryType="blob",this._messages=(Y.messages||[]).slice(),this._pos=0;const X=this;setTimeout(()=>{X.readyState!==k.CLOSED&&(X.readyState=k.OPEN,X._dispatchOpen(),X._drainInbound())},0)}_dispatchOpen(){const J=new Event("open");this.dispatchEvent(J),typeof this.onopen=="function"&&this.onopen(J)}_dispatchMessage(J){const H=new MessageEvent("message",{data:J});this.dispatchEvent(H),typeof this.onmessage=="function"&&this.onmessage(H)}_drainInbound(){for(;this._pos<this._messages.length&&this._messages[this._pos].dir==="in";){const J=this._messages[this._pos++];this._dispatchMessage(J.data)}}send(J){if(this.readyState!==k.OPEN)throw typeof DOMException<"u"?new DOMException("Still in CONNECTING state.","InvalidStateError"):new Error("InvalidStateError");if(this._pos>=this._messages.length){if(f)throw new Error("[Objs playRecording] strictWebSocket: unexpected send() after recorded frames exhausted");this._drainInbound();return}const H=this._messages[this._pos];if(H.dir==="out"){if(f){const Y=typeof J=="string"?J:String(J),W=String(H.data!=null?H.data:"");if(m(Y)!==m(W))throw new Error("[Objs playRecording] strictWebSocket: outbound frame mismatch")}this._pos++}this._drainInbound()}close(J,H){if(this.readyState===k.CLOSING||this.readyState===k.CLOSED)return;this.readyState=k.CLOSING;const Y=this;setTimeout(()=>{Y.readyState=k.CLOSED;const W=typeof CloseEvent<"u"?new CloseEvent("close",{code:J!==void 0?J:1e3,reason:H!==void 0?String(H):"",wasClean:!0}):new Event("close");Y.dispatchEvent(W),typeof Y.onclose=="function"&&Y.onclose(W)},0)}}const U=function(J,H){const Y=typeof J=="string"?J:String(J),W=T(Y);return!W||!W.messages||W.messages.length===0?new y(J,H):new M(J,H,W)};U.CONNECTING=k.CONNECTING,U.OPEN=k.OPEN,U.CLOSING=k.CLOSING,U.CLOSED=k.CLOSED,window.WebSocket=U}const w=()=>{if(L!=null)return typeof L=="string"?t.D.querySelector(L)||t.D.body:L;const l=n.observeRoot;return l&&t.D.querySelector(l)||t.D.body},A=p?w():null,B=L!=null?w():t.D,q=n.actions,F=n.assertions||[],P={};for(const l of F){const c=l.actionIdx;P[c]||(P[c]=[]),P[c].push(l)}if(t.recordingAssertionDebug&&p&&typeof console<"u"&&console.log){const l=q.map((c,T)=>({i:T,action:c.type+" "+(c.target||""),assertions:(P[T]||[]).length,assertionDetails:(P[T]||[]).map(k=>({type:k.type,index:k.index,text:(k.text||"").slice(0,30)}))}));console.log("[playRecording] assertions by action:",l)}const G={};for(const l of x){const c=l.afterAction;G[c]||(G[c]=[]),G[c].push(l)}const o=[];let a={passed:0,total:0,failures:[]};for(let l=0;l<q.length;l++){const c=q[l];o.push([`${c.type} on ${c.target}`,async()=>{let k=null;const M=B;if(c.target)if(c.listSelector!=null&&c.targetIndex!=null){const z=M.querySelectorAll(c.listSelector)[c.targetIndex];z&&(k=c.target!==c.listSelector?z.querySelector(c.target):z,!k&&c.target!==c.listSelector&&(k=z))}else k=M.querySelector(c.target);return!k&&c.type!=="scroll"?c.type==="blur"||c.type==="focus"?!0:`element not found: ${c.target}`:(c.type==="scroll"?window.scrollTo(0,c.scrollY||0):c.type==="input"||c.type==="change"?(c.value!==void 0&&(k.value=c.value),c.checked!==void 0&&(k.checked=c.checked),k.dispatchEvent(new Event(c.type,{bubbles:!0}))):c.type==="submit"?typeof k.requestSubmit=="function"?k.requestSubmit():k.submit():c.type==="keydown"?k.dispatchEvent(new KeyboardEvent("keydown",{key:c.key||"",code:c.code||"",bubbles:!0,cancelable:!0})):c.type==="focus"?k.focus():c.type==="blur"?k.blur():c.type==="click"?k.click():k.dispatchEvent(new MouseEvent(c.type,{bubbles:!0,cancelable:!0})),C>0&&await t.sleep(C),!0)}]);const T=P[l];p&&T&&T.length>0&&o.push([`assert after ${c.type}`,()=>new Promise(k=>{const M=()=>{const U=t.runRecordingAssertions(n,A,l,{assertions:T,removedElements:n.removedElements,strictAssertions:$,strictRemoved:j});a.passed+=U.passed,a.total+=U.total,a.failures.push(...U.failures),k(U.passed===U.total?!0:U.failures.map(z=>z.selector+": "+z.message).join("; "))};requestAnimationFrame(()=>requestAnimationFrame(M))})]);for(const k of G[l]||[])o.push([`Manual: ${k.label}`,()=>typeof t.testConfirm=="function"?t.testConfirm(k.label,k.items||[]):{ok:!0}])}for(const l of G.end||[])o.push([`Manual: ${l.label}`,()=>typeof t.testConfirm=="function"?t.testConfirm(l.label,l.items||[]):{ok:!0}]);const b=i&&e.onComplete,h=t.test("Recorded playback",...o,{sync:!0},l=>{window.fetch=d,XMLHttpRequest.prototype.open=N,XMLHttpRequest.prototype.send=g,y&&(window.WebSocket=y);const c=p&&F.length>0?a:void 0;if(c?.failures?.length>0){t.tRes[l]=!1;const T=c.failures.map(M=>`${M.selector}: ${M.message}`).join("; "),k=t.tStyled?t.tPre+t.tXx+"Assertions failed: "+T+t.tDc:`
|
|
96
|
+
\u2718 Assertions failed: `+T;t.tLog[l]=(t.tLog[l]||"")+k}typeof b=="function"&&b(c)});return p?{testId:h}:h},t.testOverlay=()=>{const n="o-test-overlay-btn",e="o-test-overlay-panel";if(t("#"+n).el)return;const i="o-test-overlay-scroll",r="o-test-export-objs",p="o-test-copy-txt",L="padding:6px 10px;background:#334155;color:#e2e8f0;border:none;border-radius:6px;cursor:pointer;font-size:12px;",x=()=>t.tLog.map((v,$)=>(v!=null&&v!==""?String(v):"Test #"+$)+(t.tRes[$]?" \u2713":" \u2717")).join(`
|
|
97
|
+
|
|
98
|
+
`),C=()=>{const v=t("#"+i);if(!v.el)return;let $="";t.tLog.forEach((u,f)=>{const j=t.tRes[f];$+=`<div style="margin:2px 0;padding:2px 4px;border-radius:3px;background:${j?"#14532d":"#450a0a"};color:${j?"#86efac":"#fca5a5"};font-size:11px;white-space:pre-wrap">${u||"Test #"+f}</div>`}),v.html($)},_=`<div class="o-test-overlay-root" style="display:flex;flex-direction:column;gap:4px;max-height:min(88vh,560px);overflow:hidden;"><div style="display:flex;align-items:center;gap:12px;flex-shrink:0;"><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="${L}">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;flex-direction:column;margin-top:4px;max-height:min(52vh,420px);background:#0a0f1e;border:1px solid #1e293b;border-radius:6px;box-shadow:0 2px 8px rgba(0,0,0,.35);overflow:hidden;"><div id="${i}" style="box-sizing:border-box;height:min(48vh,380px);overflow-y:scroll;padding:8px;font-size:11px;user-select:text;cursor:text;"></div><div id="o-test-overlay-footer" style="display:flex;flex-wrap:wrap;gap:8px;padding:8px;border-top:1px solid #1e293b;background:#0f172a;flex-shrink:0;"><button type="button" id="${r}" class="o-test-overlay-export-btn" style="${L}">Export (objs)</button><button type="button" id="${p}" class="o-test-overlay-export-btn" style="${L}">Copy (txt)</button></div></div></div>`,D=t.overlay({innerHTML:_,removeExisting:!1,className:"o-test-overlay",id:n,excludeDragSelector:".o-test-overlay-close, .o-test-overlay-toggle, #"+e+", #"+i+", #o-test-overlay-footer, .o-test-overlay-export-btn"});t("#"+r).on("click",()=>{const v=JSON.stringify({results:t.tRes,logs:t.tLog},null,2),$=new Blob([v],{type:"application/json"}),u=t.D.createElement("a");u.href=URL.createObjectURL($),u.download="objs-test-results.json",u.click()}),t("#"+p).on("click",()=>{const v=x(),$=()=>{const u=t.D.createElement("textarea");u.value=v,u.setAttribute("readonly",""),u.style.cssText="position:fixed;left:-9999px;top:0",t.D.body.appendChild(u),u.select(),t.D.execCommand("copy"),u.remove()};typeof navigator<"u"&&navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(v).catch($):$()});const R=()=>{const v=t(".o-test-overlay-summary");v.els.length&&v.innerText(`Tests: ${t.tRes.filter(Boolean).length}/${t.tRes.length}`)};D.first(".o-test-overlay-toggle").on("click",()=>{const v=t("#"+e);if(!v.el)return;v.el.style.display!=="none"?v.el.style.display="none":(v.el.style.display="flex",C())}),D.first(".o-test-overlay-close").on("click",()=>{D._overlayCleanup()}),t.testOverlay.showPanel=()=>{const v=t("#"+e);v.el&&(v.el.style.display="flex",C(),R())},t._testOverlayBase||(t._testOverlayBase=t.test),t.test=(...v)=>{const $=t._testOverlayBase(...v),u=t.tFns[$];return t.tFns[$]=f=>{typeof u=="function"&&u(f);const j=t("#"+e);j.el&&j.el.style.display!=="none"&&C(),R()},$}},t.overlay=(n={})=>{const{innerHTML:e,onClose:i,timeout:r,excludeDragSelector:p,removeExisting:L=!0,className:x="o-overlay-common",id:C}=n;if(L)t("."+x).remove();else if(C&&t("#"+C).el)return t("#"+C);const _={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"},D="o-overlay-countdown",R='<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="${D}" style="margin-top:6px;font-size:11px;color:#94a3b8;"></div>`:"")+"</div>",v=t.initState({tag:"div",className:x,id:C||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:R}).appendInside("body"),$=()=>v.css(_);let u=null;const f=m=>{u&&(_.left=u.left+(m.clientX-u.startX)+"px",_.top=u.top+(m.clientY-u.startY)+"px",delete _.bottom,_.transform="none",$())},j=()=>{u&&(delete _.cursor,$()),u=null};v.on("mousedown",m=>{if(p&&m.target.closest(p))return;const s=v.el.getBoundingClientRect();u={startX:m.clientX,startY:m.clientY,left:s.left,top:s.top},_.cursor="grabbing",$()}),t.D.addEventListener("mousemove",f),t.D.addEventListener("mouseup",j);let O;const I=()=>{t.D.removeEventListener("mousemove",f),t.D.removeEventListener("mouseup",j),O&&clearInterval(O),v.remove()};if(r&&r>0){let m=Math.ceil(r/1e3);const s=t("#"+D);s.el&&(s.el.textContent=m?`Continue in ${m}s`:""),O=setInterval(()=>{m-=1,s.el&&(s.el.textContent=m>0?`Continue in ${m}s`:""),m<=0&&(clearInterval(O),O=null,I(),typeof i=="function"&&i({ok:!1,errors:["timeout"]}))},1e3)}return v._overlayCleanup=I,v._overlayOnClose=i,v},t.testConfirm=(n,e=[],i={})=>new Promise(r=>{const p=i.confirm||"Continue",L=e.length>0,x=L?"#dc2626":"#2563eb",C=e.map((u,f)=>"o-tc-cb-"+f),D=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((u,f)=>`<li style="margin-bottom:4px;"><label for="${C[f]}" style="display:flex;align-items:center;gap:8px;cursor:pointer;user-select:none;"><input type="checkbox" id="${C[f]}" class="o-tc-item-cb"> <span>${u}</span></label></li>`).join("")+"</ul>":"",R=`<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:${x};color:#fff;border:none;border-radius:6px;font-weight:600;cursor:pointer;font-size:13px;flex-shrink:0;">${p}</button></div>`+D,v=t.overlay({innerHTML:R,timeout:i.timeout,excludeDragSelector:".o-tc-ok",onClose:u=>r(u||{ok:!0})}),$={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 u=v.first(".o-tc-ok"),f=t(".o-overlay-common .o-tc-item-cb"),j=()=>{const O=f.length>0&&f.els.every(I=>I.checked);u.css({...$,background:O?"#16a34a":"#dc2626"})};f.on("change",j)}v.first(".o-tc-ok").on("click",()=>{let u=[];if(L){const f=t(".o-overlay-common .o-tc-item-cb");f.els.length&&f.els.forEach((j,O)=>{!j.checked&&e[O]!==void 0&&u.push(e[O])})}v._overlayCleanup(),r(u.length===0?{ok:!0}:{ok:!1,errors:u})})});
|
|
74
99
|
|
|
75
100
|
export { o };
|
|
76
101
|
export default o;
|