import{m as h,h as _,o,ba as X,d as L,f as T,i as e,a9 as $,k as i,bg as B,b as K,r as V,J as P,aj as G,bQ as S,al as F,C as z,D as x,L as A,t as g,j as w,V as D,Y as Z,B as U,bR as ee,ag as N,E as j,q as O,bS as te,bv as ne,bT as se,ao as oe,bU as ae,W as ie}from"./Cvzsf6pb.js";import{_ as le}from"./C1GjbExY.js";const re={},ce={xmlns:"http://www.w3.org/2000/svg",width:"848",height:"446",viewBox:"0 0 848 446",class:"inspector__logo"};function pe(f,s){return o(),_("svg",ce,s[0]||(s[0]=[X('',1)]))}const ue=Object.assign(h(re,[["render",pe],["__scopeId","data-v-5dccb25d"]]),{__name:"InspectorLogo"}),_e={class:"inspector__nav"},de=L({__name:"InspectorNavbar",props:{modelValue:{}},emits:["update:modelValue"],setup(f,{emit:s}){const a=f,r=s,p=T({get:()=>a.modelValue,set:t=>r("update:modelValue",t)});function u(){const t=B("inspector-enabled",{default:()=>!1});t.value=!1}return(t,m)=>(o(),_("nav",_e,[e("div",null,[e("button",{class:$([{"inspector__nav-item--active":i(p)==="optimizely"},"inspector__nav-item"]),onClick:m[0]||(m[0]=b=>p.value="optimizely")}," Optimizely ",2),e("button",{class:$([{"inspector__nav-item--active":i(p)==="form"},"inspector__nav-item"]),onClick:m[1]||(m[1]=b=>p.value="form")}," Form ",2),e("button",{class:$([{"inspector__nav-item--active":i(p)==="config"},"inspector__nav-item"]),onClick:m[2]||(m[2]=b=>p.value="config")}," Config ",2)]),e("button",{class:"inspector__nav-item",onClick:u},"Close")]))}}),me=Object.assign(h(de,[["__scopeId","data-v-34a14fcf"]]),{__name:"InspectorNavbar"}),ye={},ve={class:"inspector-optimizely-disabled"};function be(f,s){return o(),_("div",ve,"Optimizely is disabled")}const fe=Object.assign(h(ye,[["render",be],["__scopeId","data-v-05d16681"]]),{__name:"InspectorOptimizelyDisabled"});async function q(){var t;const{$optimizely:f}=K(),s=await((t=f==null?void 0:f.getOptimizelyConfig())==null?void 0:t.getDatafile()),a=s?JSON.parse(s):null,r=V([]);a||r.value.push("Error parsing datafile");const p=(a==null?void 0:a.experiments)??[],u=(a==null?void 0:a.featureFlags)??[];return{experiments:p,featureFlags:u,datafileErrors:r}}const ge={class:"inspector-optimizely-active"},he={class:"inspector-optimizely-active__table"},ke={colspan:"2"},Ce={class:"button-group"},xe=["value","onChange"],$e={class:"button-group__label-holder"},Ie={class:"button-group__label","aria-hidden":"true"},ze={class:"button-group__label"},we=["href","onMouseenter","onMouseleave"],Oe={class:"button-group"},Le=["name","value","checked","onChange"],Me={class:"button-group__label-holder"},Te={class:"button-group__label","aria-hidden":"true"},Ve={class:"button-group__label"},Ae={class:"footer"},je={key:0,class:"messages"},De={class:"actions"},Ee=L({__name:"InspectorOptimizelyActive",async setup(f){let s,a;const r=V(new Map),{experiments:p,datafileErrors:u}=([s,a]=P(()=>q()),s=await s,a(),s),t=G("optimizely"),m=V({}),b=T(()=>t.value?p.filter(n=>t.value[n.key]!==void 0).map(n=>{var l;return{key:n.key,variations:n.variations,currentVariation:((l=t.value[n.key])==null?void 0:l.variation)||"",isDisabled:t.value[n.key].variation===null}}):[]),y=T(()=>{var n;return[...new Set((n=b.value)==null?void 0:n.flatMap(({variations:l})=>l.map(({key:v})=>v)))]}),I=T(()=>{var n;return new Map(((n=b.value)==null?void 0:n.map(({key:l,variations:v})=>[l,new Set(v.map(({key:c})=>c))]))??[])}),E=T(()=>{const n=S();for(const[l,v]of Object.entries(m.value))n.searchParams.set(`optimizely_force_variation[${l}]`,v);return n});F(b,n=>{for(const{key:l,currentVariation:v}of n??[])Object.keys(m.value).includes(l)||M(l,v)},{immediate:!0});function k(n){var l;for(const v of Object.keys(m.value))(l=I.value.get(v))!=null&&l.has(n)?M(v,n):M(v,"control")}function M(n,l){m.value[n]=l}async function H(){const n={...Z().query};for(const[l,v]of Object.entries(m.value))n[`optimizely_force_variation[${l}]`]=v;await U().push({query:n}),window.location.reload()}async function J(){const n=crypto.randomUUID();try{await navigator.clipboard.writeText(E.value.href),r.value.set(n,{type:"success",message:"Successfully put link with this setup on clipboard"})}catch(l){r.value.set(n,{type:"error",message:`Something went wrong when putting link on clipboard: ${l}`})}finally{ee(()=>r.value.delete(n),3e3)}}function W(n){document.querySelectorAll(`[data-dpg-devtools-optimizely-feature-key="${n}"]`).forEach(v=>{const c=v.getBoundingClientRect(),d=document.createElement("div");d.style.position="absolute",d.style.top=`${window.scrollY+c.top}px`,d.style.left=`${window.scrollX+c.left}px`,d.style.width=`${c.width}px`,d.style.height=`${c.height}px`,d.style.outline="2px solid var(--link-text-color)",d.style.opacity="0.25",d.style.borderRadius="8px",d.style.backgroundColor="var(--link-text-color)",d.style.outlineOffset="2px",d.style.pointerEvents="none",d.style.zIndex="10000",d.setAttribute("data-highlight-overlay",n),document.body.appendChild(d)})}function Y(n){document.querySelectorAll(`[data-highlight-overlay="${n}"]`).forEach(v=>v.remove())}return(n,l)=>{const v=D;return o(),_("div",ge,[e("div",he,[e("table",null,[l[1]||(l[1]=e("thead",null,[e("tr",null,[e("th",{width:"99%"},"Test Key"),e("th",null,"Current Variation")])],-1)),e("tbody",null,[(o(!0),_(x,null,A(i(u),(c,d)=>(o(),_("tr",{key:d},[e("td",ke,g(c),1)]))),128)),i(u).length===0?(o(),_(x,{key:0},[e("tr",null,[l[0]||(l[0]=e("td",null,"Bulk change all tests:",-1)),e("td",null,[e("div",Ce,[(o(!0),_(x,null,A(i(y),c=>(o(),_("label",{key:c,class:"button-group__element"},[e("input",{type:"radio",name:"modify-all",value:c,class:"button-group__input",onChange:d=>k(c)},null,40,xe),e("span",$e,[e("strong",Ie,g(c),1),e("span",ze,g(c),1)])]))),128))])])]),(o(!0),_(x,null,A(i(b),c=>{var d;return o(),_("tr",{key:c.key},[e("td",{class:$({"is-disabled":c.isDisabled}),width:"99%"},[e("a",{class:"test-link",target:"_blank",href:`https://app.optimizely.com/v2/projects/15080820342/flags/manage/${(d=c.key)==null?void 0:d.replace("_test","")}/`,onMouseenter:C=>W(c.key),onMouseleave:C=>Y(c.key)},[e("span",null,g(c.key),1),w(v,{icon:"external-link"})],40,we)],2),e("td",null,[e("div",Oe,[(o(!0),_(x,null,A(c.variations,C=>(o(),_("label",{key:c.key+C.key,class:"button-group__element"},[e("input",{type:"radio",name:c.key,value:C.key,class:"button-group__input",checked:i(m)[c.key]===C.key,onChange:Q=>{var R;return M(c.key,(R=Q.target)==null?void 0:R.value)}},null,40,Le),e("span",Me,[e("strong",Te,g(C.key),1),e("span",Ve,g(C.key),1)])]))),128))])])])}),128))],64)):z("",!0)])])]),e("div",Ae,[i(r).size>0?(o(),_("div",je,[(o(!0),_(x,null,A(i(r),([c,{message:d,type:C}])=>(o(),_("div",{key:c,class:$(["message",[`message--${C}`]])},g(d),3))),128))])):z("",!0),e("div",De,[e("button",{class:"action",onClick:H},[w(v,{icon:"refresh-cw"}),l[2]||(l[2]=e("span",null,"Reload page with this setup",-1))]),e("button",{class:"action",onClick:J},[w(v,{icon:"clipboard"})])])])])}}}),Se=Object.assign(h(Ee,[["__scopeId","data-v-80baca36"]]),{__name:"InspectorOptimizelyActive"}),Ne=["href"],Re=L({__name:"InspectorOptimizelyAll",async setup(f){let s,a;const r=V(""),{experiments:p,featureFlags:u}=([s,a]=P(()=>q()),s=await s,a(),s),t=p.map(b=>{const y=u.find(I=>I.experimentIds.includes(b.id));return{experimentKey:b.key,featureKey:y==null?void 0:y.key,experimentDetails:b}}),m=T(()=>t.filter(b=>{var y;return b.experimentKey.toLowerCase().includes(r.value.toLowerCase())||((y=b.featureKey)==null?void 0:y.toLowerCase().includes(r.value.toLowerCase()))}));return(b,y)=>{const I=le,E=D;return o(),_("div",null,[w(I,{id:"search",modelValue:i(r),"onUpdate:modelValue":y[0]||(y[0]=k=>N(r)?r.value=k:null),type:"text",placeholder:"Search..."},null,8,["modelValue"]),e("table",null,[y[4]||(y[4]=e("thead",null,[e("tr",null,[e("th",null,"Key"),e("th",null,"Status")])],-1)),e("tbody",null,[(o(!0),_(x,null,A(i(m),k=>{var M;return o(),_("tr",{key:k.experimentKey},[e("td",null,[y[1]||(y[1]=e("b",null,"Experiment key: ",-1)),e("code",null,g(k.experimentKey),1),y[2]||(y[2]=e("br",null,null,-1)),y[3]||(y[3]=e("b",null,"Feature Key: ",-1)),e("code",null,g(k.featureKey),1)]),e("td",null,[e("a",{target:"_blank",href:`https://app.optimizely.com/v2/projects/15080820342/flags/manage/${(M=k.experimentKey)==null?void 0:M.replace("_test","")}/`},[j(g(k.experimentDetails.status)+" ",1),w(E,{icon:"external-link"})],8,Ne)])])}),128))])])])}}}),Be=Object.assign(h(Re,[["__scopeId","data-v-1c4f4f2f"]]),{__name:"InspectorOptimizelyAll"}),Ke={class:"inspector-optimizely"},Pe={class:"inspector-optimizely__subnav"},Fe=L({__name:"InspectorOptimizely",setup(f){const s=V("active"),a=T(()=>S().searchParams.has("disable_optimizely","true"));async function r(){const p=S();if(a.value)p.searchParams.delete("disable_optimizely","true");else{for(const[u,t]of[...p.searchParams.entries()])u.startsWith("optimizely_force_variation")&&p.searchParams.delete(u,t);p.searchParams.set("disable_optimizely","true")}await U().push({query:{...Object.fromEntries([...p.searchParams.entries()])}}),window.location.reload()}return(p,u)=>{const t=D,m=fe;return o(),_("div",Ke,[e("nav",Pe,[e("button",{class:$([{"inspector-optimizely__subnav-item--active":i(s)==="active"},"inspector-optimizely__subnav-item"]),onClick:u[0]||(u[0]=b=>s.value="active")}," Active Experiments ",2),e("button",{class:$([{"inspector-optimizely__subnav-item--active":i(s)==="all"},"inspector-optimizely__subnav-item"]),onClick:u[1]||(u[1]=b=>s.value="all")}," All Experiments ",2),e("button",{class:$([{"inspector-optimizely__subnav-item--green":i(a),"inspector-optimizely__subnav-item--red":!i(a)},"inspector-optimizely__subnav-item"]),onClick:r},[w(t,{icon:"power"}),j(" "+g(i(a)?"Enable":"Disable")+" Optimizely ",1)],2)]),i(a)?(o(),O(m,{key:0})):i(s)==="active"?(o(),O(Se,{key:1})):i(s)==="all"?(o(),O(Be,{key:2})):z("",!0)])}}}),Ue=Object.assign(h(Fe,[["__scopeId","data-v-9e0a30e1"]]),{__name:"InspectorOptimizely"}),qe={class:"tapp-inspector-form"},He=L({__name:"InspectorForm",setup(f){return(s,a)=>(o(),_("div",qe,[e("button",{onClick:a[0]||(a[0]=r=>i(te)())},"Fill form data")]))}}),Je=Object.assign(h(He,[["__scopeId","data-v-4e131250"]]),{__name:"InspectorForm"}),We={class:"tapp-inspector__config"},Ye={class:"tapp-inspector__config-item"},Qe={class:"tapp-inspector__config-value"},Xe={class:"tapp-inspector__config-item"},Ge={class:"tapp-inspector__config-value"},Ze={class:"tapp-inspector__config"},et={class:"tapp-inspector__config-item"},tt={class:"tapp-inspector__config"},nt={class:"tapp-inspector__config-item"},st=L({__name:"InspectorConfig",setup(f){const s=ne(),r=K().$config.public.API_URL,p=B("storyblok-inspector-enabled",{default:()=>!1});return F(p,()=>window.location.reload()),(u,t)=>(o(),_(x,null,[e("div",We,[e("div",Ye,[t[2]||(t[2]=j(" MID ",-1)),e("div",Qe,g(i(s)),1)]),e("div",Xe,[t[3]||(t[3]=j(" API ",-1)),e("div",Ge,g(i(r)),1)])]),t[6]||(t[6]=e("hr",{class:"tapp-inspector__config-divider"},null,-1)),e("div",Ze,[e("div",et,[t[4]||(t[4]=j(" Refresh Nuxt Data ",-1)),e("button",{class:"tapp-inspector__config-button",onClick:t[0]||(t[0]=()=>("refreshNuxtData"in u?u.refreshNuxtData:i(se))())},"Refetch Data")])]),e("div",tt,[e("div",nt,[t[5]||(t[5]=j(" Enable Storyblok Inspector ",-1)),oe(e("input",{"onUpdate:modelValue":t[1]||(t[1]=m=>N(p)?p.value=m:null),type:"checkbox",class:"tapp-inspector__config-checkbox"},null,512),[[ae,i(p)]])])])],64))}}),ot=Object.assign(h(st,[["__scopeId","data-v-c12498a7"]]),{__name:"InspectorConfig"}),at={class:"inspector__body"},it=L({__name:"InspectorBody",props:{currentTab:{}},setup(f){return(s,a)=>{const r=Ue,p=Je,u=ot;return o(),_("div",at,[s.currentTab==="optimizely"?(o(),O(r,{key:0})):z("",!0),s.currentTab==="form"?(o(),O(p,{key:1})):z("",!0),s.currentTab==="config"?(o(),O(u,{key:2})):z("",!0)])}}}),lt=Object.assign(h(it,[["__scopeId","data-v-05e6968e"]]),{__name:"InspectorBody"}),rt={key:2,class:"inspector__button-label"},ct={key:0,class:"inspector"},pt={class:"app-version"},ut=L({__name:"InspectorContainer",setup(f){const{public:s}=ie(),a=V(!1),r=V("optimizely");return(p,u)=>{const t=ue,m=D,b=me,y=lt;return o(),_(x,null,[e("button",{class:$(["inspector__button bounce-in",{"inspector__button--active":i(a)}]),title:"Inspect TAPP Site",onClick:u[0]||(u[0]=I=>a.value=!i(a))},[i(a)?(o(),O(m,{key:1,class:"inspector__button-x-icon",icon:"x"})):(o(),O(t,{key:0})),i(a)?z("",!0):(o(),_("span",rt,"Devtools"))],2),i(a)?(o(),_("div",ct,[w(b,{modelValue:i(r),"onUpdate:modelValue":u[1]||(u[1]=I=>N(r)?r.value=I:null)},null,8,["modelValue"]),w(y,{"current-tab":i(r)},null,8,["current-tab"]),e("p",pt,"version: "+g(i(s).VERSION),1)])):z("",!0)],64)}}}),mt=Object.assign(h(ut,[["__scopeId","data-v-8c0924ea"]]),{__name:"InspectorContainer"});export{mt as default}; //# sourceMappingURL=DbY56O8J.js.map