import{r as e,h as t,c as i}from"./p-083180bf.js";import{b as r,n as s,k as n,f as a}from"./p-a7fc1e02.js";import{I as o,b as c,i as d}from"./p-d0993bb9.js";import{a as l}from"./p-38c7775a.js";const p=r("sq:widget-verification"),f=class{constructor(t){e(this,t),this.stateController="{}",s(this)}disconnectedCallback(){}render(){var e;const[r,s]=o({namespace:l,initialValue:!1}),f=JSON.parse(this.stateController),v=d()&&(null===(e=f["sqm-widget-verification-controller"])||void 0===e?void 0:e.isAuth),[u,b]=n(void 0),[m,x]=n(void 0),h=c((()=>{const e=v||r,t=m.querySelectorAll("template"),i=Array.from(t).find((t=>t.slot===(e?"verified":"not-verified")));if(i){const e=i.innerHTML||i.firstElementChild.outerHTML;e===u.innerHTML?p("don't rerender"):i&&(u.innerHTML=e)}const s=Array.from(m.children).filter((e=>"RAISINS-PLOP-TARGET"===e.tagName));if(s.length){const t=s.filter((e=>"verified"===e.slot)),i=s.filter((e=>"not-verified"===e.slot));i.forEach(((t,r)=>{e?t.style.display="none":(r===i.length-1&&(t.style.bottom="0px",t.style.left="0px",t.style.right="0px",t.style.position="absolute"),t.style.height="25px")})),t.forEach(((i,r)=>{e?(r===t.length-1&&(i.style.bottom="0px",i.style.left="0px",i.style.right="0px",i.style.position="absolute"),i.style.height="25px"):i.style.display="none"}))}}),[u,m,r,v]);return a((()=>{if(u&&m)return h(),function({parent:e,callback:t}){const i=new MutationObserver(s),r=new MutationObserver(t);function s(e){var t;null===(t=e.addedNodes)||void 0===t||t.forEach((e=>{r.observe(e.content,{childList:!0,attributes:!0,subtree:!0})}))}return i.observe(e,{childList:!0,subtree:!1}),s({addedNodes:e.querySelectorAll("template")}),()=>{i.disconnect(),r.disconnect()}}({parent:m,callback:h});p("DOM not ready:")}),[m,u,r,v]),t(i,null,t("div",{ref:x,style:{display:"contents"}},t("slot",{name:"not-verified"}),t("slot",{name:"verified"})),t("div",{ref:b},t("slot",{name:"shown"})))}};export{f as sqm_widget_verification_controller}