@appstorys/react-web 1.1.2 → 1.1.3

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/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var ls=Object.defineProperty;var Me=(t,e)=>()=>(t&&(e=t(t=0)),e);var ds=(t,e)=>{for(var o in e)ls(t,o,{get:e[o],enumerable:!0})};var Ct,Oe=Me(()=>{"use strict";Ct=class{static async getItem(e){try{return localStorage.getItem(e)}catch{return null}}static async setItem(e,o){try{localStorage.setItem(e,o)}catch{}}static async removeItem(e){try{localStorage.removeItem(e)}catch{}}}});import{create as cs}from"zustand";function ee(){return hn.getState().userId}async function Et(){return Ct.getItem("access_token")}function hi(t){if(!t)return;let e=String(t||"").trim();if(e)return hn.getState().variantMappings?.[e]}var hn,P,yt=Me(()=>{"use strict";Oe();hn=cs(t=>({userId:"",appId:"",accountId:"",currentScreen:"",campaigns:[],allCampaigns:[],campaignVersion:2,trackedEvents:[],trackedEventMetadata:{},isVisible:!0,isAnonymousUser:!1,variantMappings:{},personalizationData:{},screenCaptureEnabled:!1,baseUrl:void 0,trackingUrl:void 0,saveCampaigns:e=>t({campaigns:e}),saveAllCampaigns:e=>t({allCampaigns:e}),setCampaignVersion:e=>t({campaignVersion:e}),setUserId:e=>t({userId:e}),setAppId:e=>t({appId:e}),setAccountId:e=>t({accountId:e}),setCurrentScreen:e=>t({currentScreen:e}),setAttributes:e=>t({attributes:e}),setTrackedEvents:e=>t({trackedEvents:e}),setTrackedEventMetadata:e=>t({trackedEventMetadata:e}),setVisibility:e=>t({isVisible:e}),setIsAnonymousUser:e=>t({isAnonymousUser:e}),setVariantMappings:e=>t({variantMappings:e}),setPersonalizationData:e=>t({personalizationData:e}),setScreenCaptureEnabled:e=>t({screenCaptureEnabled:e}),setBaseUrl:e=>t({baseUrl:e}),setTrackingUrl:e=>t({trackingUrl:e})}));P=hn});async function Pe(){try{return{browser:navigator.userAgent,language:navigator.language,platform:"web",screen_width_px:window.innerWidth,screen_height_px:window.innerHeight,screen_density:window.devicePixelRatio,orientation:window.innerWidth<window.innerHeight?"portrait":"landscape",timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}}catch(t){return console.error("Error fetching device info:",t),{}}}var Mo=Me(()=>{"use strict"});async function he(t,e,o){try{let n={account_id:t,app_id:e,user_id:o};if(await Ct.getItem(vi))console.log("Device info already sent previously - skipping");else{let d=await Pe();n.attributes={...d},console.log("First time verification - including device info in attributes")}let l=P.getState().baseUrl||"https://users.appstorys.co",c=await fetch(`${l}/${t}/validate-account`,{method:"POST",body:JSON.stringify(n),headers:{Accept:"application/json","Content-Type":"application/json"}});if(console.log("Verify account body",n),console.log("Verifying account",c.status,c.statusText),c.ok){let d=await c.json();console.log("Account verified",d);let{access_token:S,refresh_token:p}=d;if(S&&p)return await Ct.setItem("access_token",S),await Ct.setItem("refresh_token",p),n.attributes&&(await Ct.setItem(vi,"true"),console.log("Device info sent flag set")),!0}return!1}catch(n){return console.error("Error when verifying AppStorys account",n),!1}}var vi,Po=Me(()=>{"use strict";Oe();Mo();yt();vi="device_info_sent"});async function gn(t,e){if(!e||e.length===0){console.info("AppStorys: identifyWidgetPositions called with empty positionList; skipping");return}let o=await Et();if(!o){console.error("AppStorys: identifyWidgetPositions - access token not found");return}try{let n="https://backend.appstorys.co/api/v2/appinfo/identify-positions/";console.info("AppStorys: identifyWidgetPositions payload",{screen_name:t,position_list:e});let i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`,Accept:"application/json"},body:JSON.stringify({screen_name:t,position_list:e})});i.ok?console.info("AppStorys: identifyWidgetPositions OK"):console.error("AppStorys: identifyWidgetPositions failed",i.status,await i.text())}catch(n){console.error("AppStorys: identifyWidgetPositions error",n)}}var es=Me(()=>{"use strict";yt()});function fn(t){return t&&(t.startsWith("widget_")?t:`widget_${t}`)}function Fl(){try{let t=P.getState().allCampaigns||[],e=[];return t.forEach(o=>{o&&o.position&&typeof o.position=="string"&&e.push(String(o.position));try{if(o&&o.campaign_type==="WID"&&o.details){let n=o.details;typeof n=="object"&&(n.id&&typeof n.id=="string"&&e.push(String(n.id)),n.variants&&typeof n.variants=="object"&&Object.values(n.variants).forEach(i=>{i&&i.id&&typeof i.id=="string"&&e.push(String(i.id))}))}}catch{}}),e.filter(o=>!!o).map(o=>fn(String(o))).filter(o=>!!o)}catch{return[]}}function Tl(t){try{let e=Fl();if(!e||e.length===0)return[];let o=[];return e.forEach(n=>{let i=n.replace(/^widget_/,""),s=[`[data-as-id="${i}"]`,`#${i}`,`.${i}`,`[data-widget="${i}"]`],l=null;for(let c of s)if(l=document.querySelector(c),l)break;if(l){let c=l.getBoundingClientRect(),d={x:Math.round(c.left),y:Math.round(c.top),width:Math.round(c.width),height:Math.round(c.height),screenWidth:window.innerWidth,screenHeight:window.innerHeight};We.addLayoutInfo(t,i,d),o.push(i)}}),console.info("AppStorys: mapServerPositionsToDOM mapped",o.length,"server positions to DOM elements",o),o}catch(e){return console.warn("AppStorys: mapServerPositionsToDOM error",e),[]}}function zl(t){return Bo[t]||(Bo[t]=[]),Bo[t]}function os(t,e,o,n){let i=new FormData,s=t.replace(/[^a-z0-9]/gi,"_"),l=`screenshot_${e}_${s}_${Date.now()}.png`,c=new File([n],l,{type:"image/png"});i.append("screenName",t),i.append("user_id",e),i.append("children",o),i.append("screenshot",c);try{console.groupCollapsed("AppStorys: FormData Payload Diagnostic"),console.info(" screenName:",t),console.info(" user_id:",e),console.info(" children:",JSON.parse(o)),console.info(" screenshot:",c.name,`(${c.size} bytes)`),console.groupEnd()}catch(d){console.warn("AppStorys: Could not run FormData diagnostics",d)}return i}var Bo,We,ns=Me(()=>{"use strict";yt();Po();es();yt();Bo={};We=class{static setup(e,o){let n=P.getState();n.setScreenCaptureEnabled(o),n.setCurrentScreen(e)}static addLayoutInfo(e,o,n){let i=zl(e),s=i.findIndex(d=>d.id===o),l={...n,screenWidth:n.screenWidth||window.innerWidth,screenHeight:n.screenHeight||window.innerHeight},c={id:o,frame:l};s>=0?i[s]=c:i.push(c)}static collectElements(e){this.clearLayoutData(e);let o=document.querySelectorAll("[data-as-id]"),n=window.innerWidth,i=window.innerHeight,s=[];o.forEach(l=>{let c=l.getAttribute("data-as-id");if(c){s.push(c);let d=l.getBoundingClientRect();this.addLayoutInfo(e,c,{x:Math.round(d.left),y:Math.round(d.top),width:Math.round(d.width),height:Math.round(d.height),screenWidth:n,screenHeight:i})}}),console.info(`AppStorys: Identified ${o.length} elements:`,s)}static clearLayoutData(e){Bo[e]=[]}static getLayoutData(e){return Bo[e]||[]}static async takeScreenshot(e,o){try{if(!e)return console.error("AppStorys: Screen name is required"),!1;console.info("AppStorys: Starting takeScreenshot for",e),P.getState().setCurrentScreen(e),this.collectElements(e);try{let u=Tl(e);u&&u.length>0&&console.info("AppStorys: mapServerPositionsToDOM added",u.length,"elements")}catch{}await new Promise(u=>setTimeout(u,100));let i=window,s=null;if(typeof i.html2canvas!="function")try{await new Promise((u,C)=>{let h=document.createElement("script");h.src="https://html2canvas.hertzen.com/dist/html2canvas.min.js",h.onload=()=>u(),h.onerror=()=>C(new Error("Failed to load html2canvas")),document.head.appendChild(h)})}catch(u){console.warn("AppStorys: html2canvas load error",u)}if(typeof i.html2canvas=="function")try{let u=await i.html2canvas(document.documentElement,{useCORS:!0,allowTaint:!0,logging:!1,scale:window.devicePixelRatio||1});s=await new Promise(C=>u.toBlob(h=>C(h),"image/png"))}catch(u){console.warn("AppStorys: html2canvas capture failed (falling back to getDisplayMedia)",u),s=null}if(!s&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)try{let u=await navigator.mediaDevices.getDisplayMedia({video:!0}),C=document.createElement("video");C.srcObject=u,await C.play();let h=document.createElement("canvas");h.width=C.videoWidth||window.innerWidth,h.height=C.videoHeight||window.innerHeight;let g=h.getContext("2d");g&&g.drawImage(C,0,0,h.width,h.height),s=await new Promise(b=>h.toBlob(m=>b(m),"image/png")),C.pause(),u.getTracks().forEach(b=>b.stop())}catch(u){console.warn("AppStorys: getDisplayMedia capture failed",u)}if(!s)return console.warn("AppStorys: Capture failed \u2014 no blob generated"),!1;let l=await Et(),c=ee();if(!c)return console.warn("AppStorys: No userId"),!1;if(!l){let u=P.getState();u.accountId&&u.appId&&u.userId&&await he(u.accountId,u.appId,u.userId)&&(l=await Et())}if(!l)return console.warn("AppStorys: No token available"),!1;let d="https://backend.appstorys.co/api/v1/appinfo/identify-elements/",S=JSON.stringify(this.getLayoutData(e)||[]),p=os(e,c,S,s);console.info("AppStorys: Sending identify-elements with payload size:",S.length);let y=await fetch(d,{method:"POST",headers:{Authorization:`Bearer ${l}`,Accept:"application/json"},body:p});if(y.status===401){console.warn("AppStorys: 401 response \u2014 retrying once");let u=P.getState();if(u.accountId&&u.appId&&u.userId&&await he(u.accountId,u.appId,u.userId)){let h=await Et();h&&(y=await fetch(d,{method:"POST",headers:{Authorization:`Bearer ${h}`,Accept:"application/json"},body:os(e,c,S,s)}))}}if(!y.ok){let u=await y.text();return console.error("AppStorys: identify-elements failed",y.status,u),!1}console.info("AppStorys: identify-elements success \u2713");try{let u=o,C=[];!u||u.length===0?C=(this.getLayoutData(e)||[]).map(g=>fn(g.id)).filter(g=>!!g):C=u.map(h=>fn(h)).filter(h=>!!h),console.info("AppStorys: identifyWidgetPositions will send",C.length,"positions (DOM-verified)",C),await gn(e,C)}catch(u){console.warn("AppStorys: identifyWidgetPositions failed",u)}return!0}catch(n){return console.error("AppStorys: takeScreenshot error",n),!1}}};(function(){try{let e=window;e.AppStorysForceIdentifyPositions=async o=>{let n=P.getState(),i=o||n.currentScreen;if(!i){console.warn("AppStorys: AppStorysForceIdentifyPositions - no screen name available");return}let l=(We.getLayoutData(i)||[]).map(c=>fn(c.id)).filter(c=>!!c);console.info("AppStorys: AppStorysForceIdentifyPositions sending",l.length,"positions for",i,l);try{await gn(i,l),console.info("AppStorys: AppStorysForceIdentifyPositions completed")}catch(c){console.error("AppStorys: AppStorysForceIdentifyPositions error",c)}}}catch{}})()});var rs={};ds(rs,{mountScreenCaptureButton:()=>is});function Il(){if(document.getElementById("appstorys-capture-styles"))return;let t=document.createElement("style");t.id="appstorys-capture-styles",t.innerHTML=`
1
+ var Fs=Object.defineProperty;var Be=(t,e)=>()=>(t&&(e=t(t=0)),e);var Is=(t,e)=>{for(var o in e)Fs(t,o,{get:e[o],enumerable:!0})};var Tt,Ke=Be(()=>{"use strict";Tt=class{static async getItem(e){try{return localStorage.getItem(e)}catch{return null}}static async setItem(e,o){try{localStorage.setItem(e,o)}catch{}}static async removeItem(e){try{localStorage.removeItem(e)}catch{}}}});function zn(t){if(!t)return{priority:9999,hasExplicitPriority:!1};let e=t.priority??t.details?.priority;if(e!=null&&e!==""){let i=Number(e);if(!isNaN(i)&&i>0)return{priority:i,hasExplicitPriority:!0}}let o=(t.campaign_type||"").toUpperCase();return{priority:zi[o]??999,hasExplicitPriority:!1}}function Bs(t,e){if(!t&&!e)return 0;if(!t)return 1;if(!e)return-1;let o=zn(t),n=zn(e);return o.hasExplicitPriority&&n.hasExplicitPriority||o.priority!==n.priority?o.priority-n.priority:o.hasExplicitPriority&&!n.hasExplicitPriority?-1:!o.hasExplicitPriority&&n.hasExplicitPriority?1:0}function Lt(t){return Array.isArray(t)?[...t].sort(Bs):[]}function Et(t,e,o=zs){if(!t&&!e)return o;let n=1;return t?n=zn(t).priority:e&&(n=zi[e.toUpperCase()]??1),o+n*100}var zi,zs,Vt=Be(()=>{"use strict";zi={BAN:1,FLT:2,PIP:3,CSAT:4,WID:5,SCRT:6,BTS:7,SUR:8,TTP:9,TLTP:9,MOD:10},zs=1e4});import{create as As}from"zustand";function le(){return Bn.getState().userId}async function Pt(){return Tt.getItem("access_token")}function Bi(t){if(!t)return;let e=String(t||"").trim();if(e)return Bn.getState().variantMappings?.[e]}var Bn,W,vt=Be(()=>{"use strict";Ke();Vt();Bn=As(t=>({userId:"",appId:"",accountId:"",currentScreen:"",campaigns:[],allCampaigns:[],campaignVersion:2,trackedEvents:[],trackedEventMetadata:{},isVisible:!0,isAnonymousUser:!1,variantMappings:{},personalizationData:{},screenCaptureEnabled:!1,baseUrl:void 0,trackingUrl:void 0,saveCampaigns:e=>t({campaigns:Lt(e)}),saveAllCampaigns:e=>t({allCampaigns:Lt(e)}),setCampaignVersion:e=>t({campaignVersion:e}),setUserId:e=>t({userId:e}),setAppId:e=>t({appId:e}),setAccountId:e=>t({accountId:e}),setCurrentScreen:e=>t({currentScreen:e}),setAttributes:e=>t({attributes:e}),setTrackedEvents:e=>t({trackedEvents:e}),setTrackedEventMetadata:e=>t({trackedEventMetadata:e}),setVisibility:e=>t({isVisible:e}),setIsAnonymousUser:e=>t({isAnonymousUser:e}),setVariantMappings:e=>t({variantMappings:e}),setPersonalizationData:e=>t({personalizationData:e}),setScreenCaptureEnabled:e=>t({screenCaptureEnabled:e}),setBaseUrl:e=>t({baseUrl:e}),setTrackingUrl:e=>t({trackingUrl:e})}));W=Bn});async function Ue(){try{return{browser:navigator.userAgent,language:navigator.language,platform:"web",screen_width_px:window.innerWidth,screen_height_px:window.innerHeight,screen_density:window.devicePixelRatio,orientation:window.innerWidth<window.innerHeight?"portrait":"landscape",timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}}catch(t){return console.error("Error fetching device info:",t),{}}}var Yo=Be(()=>{"use strict"});async function ke(t,e,o){try{let n={account_id:t,app_id:e,user_id:o};if(await Tt.getItem(Mi))console.log("Device info already sent previously - skipping");else{let l=await Ue();n.attributes={...l},console.log("First time verification - including device info in attributes")}let d=W.getState().baseUrl||"https://users.appstorys.co",c=await fetch(`${d}/${t}/validate-account`,{method:"POST",body:JSON.stringify(n),headers:{Accept:"application/json","Content-Type":"application/json"}});if(console.log("Verify account body",n),console.log("Verifying account",c.status,c.statusText),c.ok){let l=await c.json();console.log("Account verified",l);let{access_token:y,refresh_token:u}=l;if(y&&u)return await Tt.setItem("access_token",y),await Tt.setItem("refresh_token",u),n.attributes&&(await Tt.setItem(Mi,"true"),console.log("Device info sent flag set")),!0}return!1}catch(n){return console.error("Error when verifying AppStorys account",n),!1}}var Mi,Go=Be(()=>{"use strict";Ke();Yo();vt();Mi="device_info_sent"});async function Rn(t,e){if(!e||e.length===0){console.info("AppStorys: identifyWidgetPositions called with empty positionList; skipping");return}let o=await Pt();if(!o){console.error("AppStorys: identifyWidgetPositions - access token not found");return}try{let n="https://backend.appstorys.co/api/v2/appinfo/identify-positions/";console.info("AppStorys: identifyWidgetPositions payload",{screen_name:t,position_list:e});let i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`,Accept:"application/json"},body:JSON.stringify({screen_name:t,position_list:e})});i.ok?console.info("AppStorys: identifyWidgetPositions OK"):console.error("AppStorys: identifyWidgetPositions failed",i.status,await i.text())}catch(n){console.error("AppStorys: identifyWidgetPositions error",n)}}var xs=Be(()=>{"use strict";vt()});function Cs(t){return t&&t.trim()}function Vl(t){return qo[t]||(qo[t]=[]),qo[t]}function Ss(t,e,o,n){let i=new FormData,s=t.replace(/[^a-z0-9]/gi,"_"),d=`screenshot_${e}_${s}_${Date.now()}.png`,c=new File([n],d,{type:"image/png"});i.append("screenName",t),i.append("user_id",e),i.append("children",o),i.append("screenshot",c);try{console.groupCollapsed("AppStorys: FormData Payload Diagnostic"),console.info(" screenName:",t),console.info(" user_id:",e),console.info(" children:",JSON.parse(o)),console.info(" screenshot:",c.name,`(${c.size} bytes)`),console.groupEnd()}catch(l){console.warn("AppStorys: Could not run FormData diagnostics",l)}return i}var qo,So,vs=Be(()=>{"use strict";vt();Go();xs();vt();qo={};So=class{static setup(e,o){let n=W.getState();n.setScreenCaptureEnabled(o),n.setCurrentScreen(e)}static addLayoutInfo(e,o,n){let i=Vl(e),s=i.findIndex(l=>l.id===o),d={...n,screenWidth:n.screenWidth||window.innerWidth,screenHeight:n.screenHeight||window.innerHeight},c={id:o,frame:d};s>=0?i[s]=c:i.push(c)}static collectElements(e){this.clearLayoutData(e);let o=document.querySelectorAll("[data-as-id]"),n=window.innerWidth,i=window.innerHeight,s=[];o.forEach(d=>{let c=d.getAttribute("data-as-id");if(c){s.push(c);let l=d.getBoundingClientRect();this.addLayoutInfo(e,c,{x:Math.round(l.left),y:Math.round(l.top),width:Math.round(l.width),height:Math.round(l.height),screenWidth:n,screenHeight:i})}}),console.info(`AppStorys: Identified ${o.length} elements:`,s)}static clearLayoutData(e){qo[e]=[]}static getLayoutData(e){return qo[e]||[]}static async takeScreenshot(e,o){try{if(!e)return console.error("AppStorys: Screen name is required"),!1;console.info("AppStorys: Starting takeScreenshot for",e),W.getState().setCurrentScreen(e),this.collectElements(e),await new Promise(f=>setTimeout(f,100));let i=window,s=null;if(typeof i.html2canvas!="function")try{await new Promise((f,P)=>{let g=document.createElement("script");g.src="https://html2canvas.hertzen.com/dist/html2canvas.min.js",g.onload=()=>f(),g.onerror=()=>P(new Error("Failed to load html2canvas")),document.head.appendChild(g)})}catch(f){console.warn("AppStorys: html2canvas load error",f)}if(typeof i.html2canvas=="function")try{let f=await i.html2canvas(document.documentElement,{useCORS:!0,allowTaint:!0,logging:!1,scale:window.devicePixelRatio||1});s=await new Promise(P=>f.toBlob(g=>P(g),"image/png"))}catch(f){console.warn("AppStorys: html2canvas capture failed (falling back to getDisplayMedia)",f),s=null}if(!s&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)try{let f=await navigator.mediaDevices.getDisplayMedia({video:!0}),P=document.createElement("video");P.srcObject=f,await P.play();let g=document.createElement("canvas");g.width=P.videoWidth||window.innerWidth,g.height=P.videoHeight||window.innerHeight;let b=g.getContext("2d");b&&b.drawImage(P,0,0,g.width,g.height),s=await new Promise(R=>g.toBlob(C=>R(C),"image/png")),P.pause(),f.getTracks().forEach(R=>R.stop())}catch(f){console.warn("AppStorys: getDisplayMedia capture failed",f)}if(!s)return console.warn("AppStorys: Capture failed \u2014 no blob generated"),!1;let d=await Pt(),c=le();if(!c)return console.warn("AppStorys: No userId"),!1;if(!d){let f=W.getState();f.accountId&&f.appId&&f.userId&&await ke(f.accountId,f.appId,f.userId)&&(d=await Pt())}if(!d)return console.warn("AppStorys: No token available"),!1;let l="https://backend.appstorys.co/api/v1/appinfo/identify-elements/",y=JSON.stringify(this.getLayoutData(e)||[]),u=Ss(e,c,y,s);console.info("AppStorys: Sending identify-elements with payload size:",y.length);let m=await fetch(l,{method:"POST",headers:{Authorization:`Bearer ${d}`,Accept:"application/json"},body:u});if(m.status===401){console.warn("AppStorys: 401 response \u2014 retrying once");let f=W.getState();if(f.accountId&&f.appId&&f.userId&&await ke(f.accountId,f.appId,f.userId)){let g=await Pt();g&&(m=await fetch(l,{method:"POST",headers:{Authorization:`Bearer ${g}`,Accept:"application/json"},body:Ss(e,c,y,s)}))}}if(!m.ok){let f=await m.text();return console.error("AppStorys: identify-elements failed",m.status,f),!1}console.info("AppStorys: identify-elements success \u2713");try{let f=o?[...o]:[];document.querySelectorAll("[data-widget]").forEach(b=>{let R=b.getAttribute("data-widget");R&&f.push(R)});let g=Array.from(new Set(f)).map(b=>Cs(b)).filter(b=>!!b);console.info("AppStorys: identifyWidgetPositions will send",g.length,"positions",g),g.length>0&&await Rn(e,g)}catch(f){console.warn("AppStorys: identifyWidgetPositions failed",f)}return!0}catch(n){return console.error("AppStorys: takeScreenshot error",n),!1}}};(function(){try{let e=window;e.AppStorysForceIdentifyPositions=async o=>{let n=W.getState(),i=o||n.currentScreen;if(!i){console.warn("AppStorys: AppStorysForceIdentifyPositions - no screen name available");return}let d=(So.getLayoutData(i)||[]).map(c=>Cs(c.id)).filter(c=>!!c);console.info("AppStorys: AppStorysForceIdentifyPositions sending",d.length,"positions for",i,d);try{await Rn(i,d),console.info("AppStorys: AppStorysForceIdentifyPositions completed")}catch(c){console.error("AppStorys: AppStorysForceIdentifyPositions error",c)}}}catch{}})()});var ks={};Is(ks,{mountScreenCaptureButton:()=>ws});function Yl(){if(document.getElementById("appstorys-capture-styles"))return;let t=document.createElement("style");t.id="appstorys-capture-styles",t.innerHTML=`
2
2
  @keyframes appstorys-spin {
3
3
  0% { transform: rotate(0deg); }
4
4
  100% { transform: rotate(360deg); }
@@ -11,7 +11,7 @@ var ls=Object.defineProperty;var Me=(t,e)=>()=>(t&&(e=t(t=0)),e);var ds=(t,e)=>{
11
11
  border-radius: 50%;
12
12
  animation: appstorys-spin 0.8s linear infinite;
13
13
  }
14
- `,document.head.appendChild(t)}function Bl(){Il();let t=document.createElement("button");return t.id="appstorys-screen-capture-btn",t.title="Capture screen",Object.assign(t.style,{position:"fixed",left:"16px",bottom:"16px",width:"100px",height:"56px",borderRadius:"28px",background:"#ff6a00",color:"#fff",border:"none",boxShadow:"0 6px 18px rgba(0,0,0,0.2)",zIndex:"2147483647",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",fontWeight:"600",fontFamily:"sans-serif",transition:"all 0.2s ease"}),t.innerText="Capture",t}function is(){try{let t=P.getState(),o=!!window.__APPSTORYS_DEBUG_CAPTURE;if(console.info("AppStorys: mountScreenCaptureButton called, screenCaptureEnabled=",t.screenCaptureEnabled,"debugForce=",o),!t.screenCaptureEnabled&&!o||document.getElementById("appstorys-screen-capture-btn"))return null;let n=Bl();return n.addEventListener("click",async()=>{n.disabled=!0;let i=n.innerText;n.innerHTML='<div class="appstorys-spinner"></div>';let l=P.getState().currentScreen||(typeof window<"u"?window.location.pathname:"");try{await We.takeScreenshot(l)}catch(c){console.error("CaptureService error",c)}n.disabled=!1,n.innerText=i,n.animate([{transform:"scale(1.0)"},{transform:"scale(1.05)"},{transform:"scale(1.0)"}],{duration:300})}),document.body.appendChild(n),console.info("AppStorys: screen capture button mounted"),n}catch(t){return console.error("mountScreenCaptureButton error",t),null}}var ss=Me(()=>{"use strict";yt();ns();try{window.AppStorysMountCapture=function(){try{return is()}catch(t){return console.error("AppStorysMountCapture failed",t),null}}}catch{}try{window.AppStorysDebugState=function(){try{let t=P.getState();return console.info("AppStorys store state:",t),t}catch(t){return console.error("AppStorysDebugState failed",t),null}}}catch{}try{window.AppStorysDebugToken=function(){try{let t=localStorage.getItem("access_token")||"",e=t.length,o=t?t.slice(0,20)+"..."+t.slice(-10):"(none)";if(console.info("Token length:",e,"masked:",o),t&&t.includes("."))try{let n=t.split(".");if(n.length===3){let i=JSON.parse(atob(n[1]));if(console.info("Token payload:",i),i.exp){let s=new Date(i.exp*1e3),l=new Date;console.info("Token expires:",s.toISOString(),"Expired:",l>s)}}}catch(n){console.warn("Could not decode JWT:",n)}return t?"Token present":"No token"}catch(t){return console.error("AppStorysDebugToken failed",t),null}}}catch{}});var yi=(i=>(i.uninitialized="uninitialized",i.initializing="initializing",i.initialized="initialized",i.error="error",i))(yi||{});yt();import{useState as No,useEffect as Ti,useRef as zi}from"react";import*as je from"lottie-react";yt();import{useMemo as fs}from"react";yt();var bi="appstorys_variant_mappings",uo={};function us(t){let e=0;for(let o=0;o<t.length;o++){let n=t.charCodeAt(o);e=(e<<5)-e+n,e|=0}return Math.abs(e)}function xi(){if(typeof window>"u")return{};try{let t=localStorage.getItem(bi);if(t)return JSON.parse(t)}catch{}return{}}function ps(t,e){if(!(!t||!e)){uo[t]=e;try{let o=P.getState(),n=o.variantMappings||{};n[t]!==e&&o.setVariantMappings({...n,[t]:e})}catch{}if(typeof window<"u")try{let o=xi();o[t]=e,localStorage.setItem(bi,JSON.stringify(o))}catch{}}}var Si=t=>{if(!t)return;if(uo[t])return uo[t];let e=P.getState().variantMappings?.[t];if(e)return uo[t]=e,e;let o=xi();if(o[t]){uo[t]=o[t];try{P.getState().setVariantMappings({...P.getState().variantMappings||{},[t]:o[t]})}catch{}return o[t]}};function Eo(t){if(!t)return!1;if(t.hasVariants===!0||t.variants&&typeof t.variants=="object"&&Object.keys(t.variants).length>0)return!0;if(t.details&&typeof t.details=="object"&&t.details.variants){let e=t.details.variants;if(typeof e=="object"&&Object.keys(e).length>0)return!0}return!1}function gs(t,e){let o=Object.keys(t);if(o.length===0)return;let n=o.filter(l=>t[l]&&t[l].isActive!==!1),i=n.length>0?n:o,s=i.reduce((l,c)=>l+(Number(t[c]?.weight)||0),0);if(s>0){let l=P.getState().userId||"default",c=`${e||"campaign"}_${l}`,S=us(c)%1e4/1e4*s;for(let p of i){let y=Number(t[p]?.weight)||0;if(S<y)return p;S-=y}}return i[0]}function Nt(t){if(!t||!Eo(t))return t;let e=t,o=e.variants||e.details?.variants;if(!o||typeof o!="object"||Object.keys(o).length===0)return t;let n=Si(e.id||"");if((!n||!o[n])&&(n=gs(o,e.id),e.id&&n&&ps(e.id,n)),!n||!o[n])return t;let i=o[n],l={...e.details&&typeof e.details=="object"?Object.fromEntries(Object.entries(e.details).filter(([c])=>c!=="variants")):{},...i};return{...t,details:l,_variantId:n}}function Wl(t){if(t){if("_variantId"in t)return t._variantId;if(Eo(t))return Si(t.id||"")}}var Ao="__back_press_triggered__";function Ci(t){return(t||"").trim().toLowerCase()}function ms(t,e){let o=Ci(t),n=Ci(e);return!o||o===n}function ys(t,e,o){let n=Number(t),i=Number(o),s=!isNaN(n)&&!isNaN(i);switch(e){case"eq":return s?n===i:t===o;case"neq":return s?n!==i:t!==o;case"gt":return s?n>i:t>o;case"gte":return s?n>=i:t>=o;case"lt":return s?n<i:t<o;case"lte":return s?n<=i:t<=o;default:return!1}}function hs(t,e){let o=t.filter(n=>n.back_press==null);return o.length===0?!0:e.some(n=>o.every(i=>{let s=n[i.key];return s==null?!1:ys(String(s),i.operator,i.value)}))}function bs(t,e,o){let n=t,i=n.trigger_event??n.trigger,s=t.id;return!i}function bn(){let{campaigns:t,trackedEvents:e,trackedEventMetadata:o,currentScreen:n}=P.getState();return t.some(i=>{if(i.screen&&i.screen!==n)return!1;let s=i.trigger_event;if(!s||typeof s=="string")return!1;let{event:l,event_config:c}=s;if(!(c??[]).some(p=>p.back_press===!0)||e.includes(Ao)||!e.includes(l))return!1;let d=(c??[]).filter(p=>p.back_press==null);if(d.length===0)return!0;let S=o[l]||[];return hs(d,S)})}function xn(t){return Array.isArray(t)?[...t].sort((o,n)=>{let i=typeof o?.order=="number"?o.order:0,s=typeof n?.order=="number"?n.order:0;return i-s}).map(o=>{if(!o||!Array.isArray(o.slides))return o;let n=[...o.slides].sort((i,s)=>{let l=typeof i?.order=="number"?i.order:0,c=typeof s?.order=="number"?s.order:0;return l-c});return{...o,slides:n}}):[]}function At(t,e){let o=P(d=>d.currentScreen),n=P(d=>d.campaigns),i=P(d=>d.allCampaigns),s=P(d=>d.trackedEvents),l=P(d=>d.trackedEventMetadata),c=P(d=>d.variantMappings);return fs(()=>{let d=u=>u.find(C=>{if(C.campaign_type!==t||e?.position&&C.position!==e.position||!bs(C,s,l))return!1;if(e?.screenContains){let h=(e.screenContains||"").trim().toLowerCase();return(C.screen||"").trim().toLowerCase().includes(h)}return ms(C.screen,o)}),p=(n&&n.length>0?d(n):void 0)??d(i||[]);if(!p)return;let y=Nt(p);return y&&y.details&&Array.isArray(y.details)&&(y.details=xn(y.details)),y},[n,i,s,l,c,t,e,o])}yt();Mo();Oe();yt();Po();var wi="appstorys_offline_queue";async function ki(){let t=await Ct.getItem(wi);return t?JSON.parse(t):[]}async function Ri(t){await Ct.setItem(wi,JSON.stringify(t))}function xs(t){return Math.min(3e4*Math.pow(2,t),12e4)}function Ss(t){let o=t.retryCount||0,n=t.lastAttempt||0,i=xs(o);return o<3&&Date.now()-n>=i}async function Cs(){let t=P.getState();return!t.accountId||!t.appId?!1:await he(t.accountId,t.appId,t.userId)}async function Fi(t,e){if(await Cs()){let n=await Ct.getItem("access_token");n&&(t.headers={...t.headers,Authorization:`Bearer ${n}`}),t.authRetried=!0,t.lastAttempt=Date.now(),e(t)}}async function _o(t,e){let o=(t.retryCount||0)+1;o<=3&&(t.retryCount=o,t.lastAttempt=Date.now(),e(t))}async function Do(t){let e=await ki();e.push(t),await Ri(e)}async function vs(){let t=await ki();if(t.length===0)return;let e=[];for(let o of t){if(!Ss(o)){e.push(o);continue}try{let n=await fetch(o.url,{method:o.method,headers:o.headers,body:JSON.stringify(o.body)});if(n.ok)continue;n.status===401||n.status===403?o.authRetried||await Fi(o,i=>e.push(i)):n.status>=500&&await _o(o,i=>e.push(i))}catch{await _o(o,i=>e.push(i))}}await Ri(e)}async function Wo(t){if(!navigator.onLine){await Do(t);return}await vs();try{let e=await fetch(t.url,{method:t.method,headers:t.headers,body:JSON.stringify(t.body)});return e.ok||(e.status===401||e.status===403?await Fi(t,Do):e.status>=500&&await _o(t,Do)),e}catch{await _o(t,Do);return}}async function rt(t,e,o){try{if(!t)return;let n=await Et(),i=P.getState(),s=["viewed","clicked","csat captured","survey captured","shared"];if(!s.includes(t)){let S=i.trackedEvents;if(!S.includes(t))i.setTrackedEvents([...S,t]);else{let p=S.filter(y=>y!==t);p.push(t),i.setTrackedEvents(p)}if(o&&Object.keys(o).length>0){let p=i.trackedEventMetadata||{},y=p[t]||[];i.setTrackedEventMetadata({...p,[t]:[...y,o]})}}let l={...o||{}};if(!s.includes(t)){let S=await Pe();l={...l,...S}}if(e&&String(e).trim()!==""){let S=o?.variant_id||hi(e);S&&(l.variant_id=S)}let c={user_id:ee(),event:t,metadata:l};e&&(c.campaign_id=e);let d=i.trackingUrl||"https://tracking.appstorys.co";n&&await Wo({url:`${d}/capture-event`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:c})}catch(n){console.error("Error in trackEvent",n)}}yt();function Pt(t){if(!t)return!1;let e=P.getState(),o=e.allCampaigns||[],n=e.campaigns||[],i=String(t).trim(),s=o.find(d=>{if(!d)return!1;let S=String(d.id||"").trim(),p=d.details||{},y=String(p.campaign||p.id||"").trim();return!!(S&&S===i||y&&y===i||S&&i.includes(S)||y&&i.includes(y))});if(!s)return!1;let l={...s};delete l.trigger_event,delete l.trigger,l.display_trigger=!0;let c=n.findIndex(d=>String(d.id||"")===String(l.id||""));if(c===-1)e.saveCampaigns([l,...n]);else{let d=n[c];if(!!(d.trigger_event??d.trigger)){let p=[...n];p[c]=l,e.saveCampaigns(p)}}return!0}import{jsx as $o,jsxs as ks}from"react/jsx-runtime";var ws=({config:t,onPress:e,style:o,ignoreSizeAndMargin:n=!1})=>{if(!t||!t.enabled)return null;let i=t.size,s=t.margin,l=t.color,c=t.image,d=t.selectedStyle,S=i!=null&&i>=0?i:18,p=n?40:S,y=s?.top!==void 0&&s?.top!==null&&s.top>=0?s.top:0,u=s?.bottom!==void 0&&s?.bottom!==null&&s.bottom>=0?s.bottom:0,C=s?.left!==void 0&&s?.left!==null&&s.left>=0?s.left:0,h=s?.right!==void 0&&s?.right!==null&&s.right>=0?s.right:0,g={marginTop:n?0:y,marginBottom:n?0:u,marginLeft:n?0:C,marginRight:n?0:h,width:p,height:p,backgroundColor:l?.fill||"transparent",borderColor:l?.stroke||"transparent",borderWidth:p*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"absolute",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:l?.stroke?"solid":"none",...o},b=()=>{let m=l?.cross||"#ffffff";return ks("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[$o("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:m,strokeWidth:"2.2",strokeLinecap:"round"}),$o("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:m,strokeWidth:"2.2",strokeLinecap:"round"})]})};return $o("button",{type:"button","data-control-button":"true",onMouseDown:m=>m.stopPropagation(),onClick:m=>{m.stopPropagation(),m.preventDefault(),e(m)},style:g,children:c&&c.trim()!==""?$o("img",{src:c,style:{width:p,height:p,objectFit:"contain"},alt:"close"}):b()})},Dt=ws;import{jsx as Oo,jsxs as Fs}from"react/jsx-runtime";var Ii=je.default?.default??je.default??je.Lottie??je,Rs=()=>{let t=At("BAN"),e=P(T=>T.isVisible),[o,n]=No(!1),[i,s]=No(null),[l,c]=No(null),d=zi(null),[S,p]=No(0),y=zi(null);if(Ti(()=>{t?.id&&y.current!==t.id&&(y.current=t.id,n(!1),rt("viewed",t.id),t.details?.lottie_data&&fetch(t.details.lottie_data).then(T=>T.json()).then(T=>{s(T),T.w&&T.h&&c(T.h/T.w)}).catch(T=>console.error("Error loading Lottie:",T)))},[t?.id]),Ti(()=>{let T=()=>{d.current&&p(d.current.offsetWidth)};return T(),window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[t,o]),!t||o||!e)return null;let{details:u}=t,C=u.styling||{},h=u.height||"auto";l&&S&&(h=S*l);let g=parseFloat(String(u.height)),b=parseFloat(String(u.originalWidth??u.styling?.originalWidth)),m=parseFloat(String(u.originalHeight??u.styling?.originalHeight)),E=Number.isFinite(g)&&g>0&&Number.isFinite(b)&&b>0&&Number.isFinite(m)&&m>0?g*(b/m):null,O=E!==null?`${E}px`:void 0,D=typeof h=="number"?`${h}px`:h||void 0,L=Number(C.marginRight),v=Number(C.marginBottom),w={position:"fixed",right:Number.isFinite(L)?`${L}px`:"0px",bottom:Number.isFinite(v)?`${v}px`:"0px",zIndex:9999,display:"block",cursor:u.link?"pointer":"default"},_={position:"relative",width:O||"100%",height:D||"auto",backgroundColor:"transparent",borderRadius:`${C.topRightRadius||0}px ${C.topLeftRadius||0}px ${C.bottomRightRadius||0}px ${C.bottomLeftRadius||0}px`,overflow:"hidden"},$={width:"100%",height:"100%",display:"block",objectFit:"contain"},V=T=>{T.stopPropagation(),n(!0),rt("banner_closed",t.id)};return Oo("div",{ref:d,style:w,onClick:()=>{if(u.link)if(rt("clicked",t.id),u.link.startsWith("http"))window.open(u.link,"_blank");else{try{if(Pt(u.link))return}catch(T){console.warn("revealCampaignFromLink error",T)}console.log("Internal link:",u.link)}},children:Fs("div",{style:_,children:[i?(()=>{let T=Ii.default||Ii;return Oo(T,{animationData:i,loop:!0,autoplay:e,style:$})})():u.image?Oo("img",{src:u.image,alt:"Campaign Banner",style:$}):null,C.crossButton?.enabled&&Oo(Dt,{config:C.crossButton,onPress:V,style:{top:C.crossButton?.margin?.top!==void 0?0:5,right:C.crossButton?.margin?.right!==void 0?0:5}})]})})};import{useEffect as po,useMemo as _i,useRef as go,useState as fo}from"react";yt();function qo(t){let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")}function Bi(t){try{let o=new URL(t).pathname.split("/").pop()||t;return o.split("?")[0].replace(/\.[^.]+$/,"")||`font_${o.length}`}catch{return(t.split("/").pop()??t).split("?")[0].replace(/\.[^.]+$/,"")||`font_${t.length}`}}function Li(t,e){if(typeof document>"u")return;let o=`appstorys-font-${t}`;if(document.getElementById(o))return;let n=document.createElement("style");n.id=o,n.type="text/css",n.textContent=`@font-face{font-family:"${t}";src:url("${e}");font-style:normal;font-weight:normal;font-display:swap;}`,document.head.appendChild(n)}var jo=new Map;async function Ts(t,e){try{Li(e.name,t);let o=globalThis.FontFace;if(typeof document<"u"&&o&&document.fonts?.add){let n=new o(e.name,`url(${t})`);await n.load(),document.fonts.add(n)}else typeof document<"u"&&document.fonts?.load&&await document.fonts.load(`1em "${e.name}"`);e.status="loaded",e.listeners.forEach(n=>n(e.name))}catch(o){console.warn(`[FontManager] Failed to load font from "${t}":`,o),e.status="failed",e.listeners.forEach(n=>n(void 0))}finally{e.listeners=[]}}var Sn={async load(t){if(!t||!qo(t))return;let e=jo.get(t);if(e)return e.status==="loaded"?e.name:e.status==="failed"?void 0:new Promise(s=>e.listeners.push(s));let n={status:"pending",name:Bi(t),listeners:[]};jo.set(t,n);let i=new Promise(s=>n.listeners.push(s));return Ts(t,n),i},ensure(t){if(!t||!qo(t))return;let e=Bi(t);return Li(e,t),Sn.load(t),e},getSync(t){if(!t)return;let e=jo.get(t);return e?.status==="loaded"?e.name:void 0},_clearCache(){jo.clear()}};function st(t,e){if(!t)return e;let o=String(t).trim();if(!o)return e;if(qo(o)){let n=Sn.ensure(o);return n?`"${n}", ${e||"sans-serif"}`:e}return o.includes(",")||o.includes('"')||o.includes("'")?o:`"${o}", ${e||"sans-serif"}`}function zs(t){let e=new Set,o=new WeakSet,n=i=>{if(i!=null&&typeof i!="string"){if(Array.isArray(i)){for(let s of i)n(s);return}if(typeof i=="object"){if(o.has(i))return;o.add(i);for(let[s,l]of Object.entries(i))s==="fontFamily"&&typeof l=="string"&&qo(l)&&e.add(l),n(l)}}};return n(t),Array.from(e)}async function Ei(t){let e=new Set;for(let o of t)zs(o).forEach(n=>e.add(n));await Promise.all(Array.from(e).map(o=>Sn.load(o)))}import{jsx as Se,jsxs as Ai}from"react/jsx-runtime";var be=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:n,style:i,type:s})=>{if(!t||!n)return null;let{size:l=18,margin:c,color:d,image:S,selectedStyle:p}=t,y=o?40:l,u=o?0:c?.top??0,C=o?0:c?.bottom??0,h=o?0:c?.left??0,g=o?0:c?.right??0,b={marginTop:u,marginBottom:C,marginLeft:h,marginRight:g,width:y,height:y,backgroundColor:d?.fill||"transparent",borderColor:d?.stroke||"transparent",borderWidth:y*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,display:"flex",...o?{}:{marginTop:t.margin?.top??0,marginRight:t.margin?.right??0,marginBottom:t.margin?.bottom??0,marginLeft:t.margin?.left??0},...i},m=()=>{let E=d?.cross||"#ffffff";return s==="mute"?Ai("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[Se("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:E,strokeWidth:"2.2",strokeLinejoin:"round"}),Se("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:E,strokeWidth:"2.2",strokeLinecap:"round"}),Se("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:E,strokeWidth:"2.2",strokeLinecap:"round"})]}):Ai("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[Se("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:E,strokeWidth:"2.2",strokeLinejoin:"round"}),Se("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:E,strokeWidth:"2.2",strokeLinecap:"round"}),Se("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:E,strokeWidth:"2.2",strokeLinecap:"round"})]})};return Se("button",{type:"button","data-control-button":"true",onMouseDown:E=>E.stopPropagation(),onClick:E=>{E.stopPropagation(),E.preventDefault(),e(E)},style:{...b,border:b.borderColor?`${b.borderWidth}px solid ${b.borderColor}`:"none",padding:0,cursor:"pointer",outline:"none"},children:S&&S.trim()!==""?Se("img",{src:S,style:{width:y,height:y,objectFit:"contain"},alt:s}):m()})};import{jsx as le,jsxs as Mi}from"react/jsx-runtime";var Pi=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:n,style:i,type:s})=>{if(!t||!n)return null;let{size:l=18,margin:c,color:d,image:S,selectedStyle:p}=t,y=o?40:l,u={marginTop:o?0:c?.top??0,marginBottom:o?0:c?.bottom??0,marginLeft:o?0:c?.left??0,marginRight:o?0:c?.right??0,width:y,height:y,backgroundColor:d?.fill||"transparent",borderColor:d?.stroke||d?.cross||"#ffffff",borderWidth:d?.stroke?Math.max(1,y*.05):2,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:"solid",boxSizing:"border-box",...o?{}:{marginTop:t.margin?.top??0,marginRight:t.margin?.right??0,marginBottom:t.margin?.bottom??0,marginLeft:t.margin?.left??0},...i},C=()=>{let h=d?.cross||"#ffffff";return s==="maximise"?Mi("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%","aria-hidden":!0,children:[le("polyline",{points:"15,5 19,5 19,9",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),le("line",{x1:"19",y1:"5",x2:"14",y2:"10",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"}),le("polyline",{points:"9,19 5,19 5,15",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),le("line",{x1:"5",y1:"19",x2:"10",y2:"14",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"})]}):Mi("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%","aria-hidden":!0,children:[le("polyline",{points:"14,6 14,10 18,10",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),le("line",{x1:"14",y1:"10",x2:"19",y2:"5",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"}),le("polyline",{points:"6,14 10,14 10,18",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),le("line",{x1:"10",y1:"14",x2:"5",y2:"19",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"})]})};return le("button",{type:"button","data-control-button":"true",onMouseDown:h=>h.stopPropagation(),onClick:h=>{h.stopPropagation(),h.preventDefault(),e(h)},style:u,children:S&&S.trim()!==""?le("img",{src:S,style:{width:y,height:y,objectFit:"contain"},alt:s}):C()})};import{jsx as Cn,jsxs as Bs}from"react/jsx-runtime";var Is=({styling:t,mode:e,muted:o,expanded:n,onClose:i,onToggleMute:s,onToggleExpand:l,containerStyle:c})=>{if(!t)return null;let d=e==="LARGE",S={position:"absolute",pointerEvents:"auto",...d?{top:15,right:15}:{top:0,right:0}},p={position:"absolute",pointerEvents:"auto",...d?{top:15,right:60}:{top:0,left:0}},y={position:"absolute",pointerEvents:"auto",...d?{top:15,left:15}:{bottom:0,right:0}},u=o?t.soundToggle?.unmute:t.soundToggle?.mute,C=n?t.expandControls?.minimise:t.expandControls?.maximise;return Bs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:9999999,pointerEvents:"none",...c},children:[t.crossButton?.enabled&&Cn(Dt,{config:{enabled:t.crossButton?.enabled??!1,image:t.crossButton?.image??"",color:{cross:t.crossButton?.color?.cross??"#ffffff",fill:t.crossButton?.color?.fill??"",stroke:t.crossButton?.color?.stroke??""},margin:{top:t.crossButton?.margin?.top??0,bottom:t.crossButton?.margin?.bottom??0,left:t.crossButton?.margin?.left??0,right:t.crossButton?.margin?.right??0},size:t.crossButton?.size&&t.crossButton.size>10?t.crossButton.size:20},onPress:i,ignoreSizeAndMargin:d,style:S}),t.soundToggle?.enabled&&u&&Cn(be,{config:u,onPress:s,ignoreSizeAndMargin:d,style:p,enabled:t.soundToggle?.enabled,type:o?"unmute":"mute"}),t.expandControls?.enabled&&C&&Cn(Pi,{config:C,onPress:l,ignoreSizeAndMargin:d,style:y,enabled:t.expandControls?.enabled,type:n?"minimise":"maximise"})]})},Di=Is;import{jsx as wn,jsxs as As}from"react/jsx-runtime";var vn=t=>(t||"").trim().toLowerCase(),Ho=(t,e)=>{let o=Number(t);return Number.isFinite(o)?o:e},Wi=20,$i=20,Ni=20,Oi=(t,e,o)=>{let n=window.innerWidth,i=window.innerHeight,s=Wi,l=Math.max(s,n-o.width-Wi),c=o.topInset,d=Math.max(c,i-o.height-o.bottomInset);return{x:Math.min(Math.max(t,s),l),y:Math.min(Math.max(e,c),d)}},Ls=t=>{if(t===!0||t===1)return!0;if(t===!1||t===0||t==null||t==="")return!1;let e=String(t).trim().toLowerCase();return e==="yes"||e==="true"||e==="1"},Es=()=>{let t=At("PIP"),e=P(K=>K.campaigns),o=P(K=>K.allCampaigns),n=P(K=>K.currentScreen),i=P(K=>K.isVisible),[s,l]=fo(!1),[c,d]=fo(!1),[S,p]=fo(!0),[y,u]=fo(!1),[C,h]=fo(null),g=go({x:0,y:0}),b=go({width:150,height:300,topInset:$i,bottomInset:Ni}),m=go(null),E=go({x:0,y:0}),O=go(!1),D=_i(()=>{if(t)return t;let K=vn(n),it=mt=>mt.find(gt=>{let R=gt,I=R.campaign_type==="PIP",N=!vn(R.screen)||vn(R.screen)===K,Z=!!(R.trigger_event??R.trigger),xt=R.display_trigger!==!1&&!Z;return I&&N&&xt}),lt=it(e)??it(o);return lt?Nt(lt):void 0},[t,e,o,n]),L=_i(()=>D,[D?.id,D?.details?.id]);if(po(()=>{if(!L)return;let K=L.details||{},it=K?.styling?.soundToggle?.defaultSound||K?.styling?.appearance?.defaultSound||"yes";p(String(it).toLowerCase()!=="yes"),l(!1),d(!1),h(null),rt("viewed",L.id)},[L]),po(()=>{let K=m.current;if(!K)return;K.muted=S;let it=K.play();it&&typeof it.catch=="function"&&it.catch(()=>{S||(K.muted=!0,p(!0))})},[S]),po(()=>{if(!c)return;let K=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=K}},[c]),po(()=>{if(!y)return;let K=lt=>{let mt=lt.clientX-E.current.x,gt=lt.clientY-E.current.y;(Math.abs(mt)>4||Math.abs(gt)>4)&&(O.current=!0);let R=lt.clientX-g.current.x,I=lt.clientY-g.current.y;h(Oi(R,I,b.current))},it=()=>{u(!1)};return window.addEventListener("pointermove",K),window.addEventListener("pointerup",it),window.addEventListener("pointercancel",it),()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",it),window.removeEventListener("pointercancel",it)}},[y]),po(()=>{let K=()=>{h(it=>it&&Oi(it.x,it.y,b.current))};return window.addEventListener("resize",K),window.addEventListener("orientationchange",K),()=>{window.removeEventListener("resize",K),window.removeEventListener("orientationchange",K)}},[]),!L||!L.details||s||!i)return null;let v=L.details,w=v.styling||{},_=w.appearance||{},$=Ho(v.width??_.pipWidth,150),V=Ho(v.height??_.pipHeight,300),A=$,T=V,k=w.cta?.container||{},B=w.cta?.text||{},W=w.cta?.cornerRadius,H=w.cta?.margin||{},Y=!!(v.button_text&&v.button_text.trim().length>0),r=Ho(w.pipBottomPadding,20),M=Ho(w.pipTopPadding,0);b.current={width:A,height:T,topInset:$i+M,bottomInset:Ni+r};let a=c?v.large_video||v.small_video:v.small_video||v.large_video,f=(v.position||L.position||"right").toLowerCase(),x=!!w.isMovable,z=w.soundToggle?.enabled!==!1,U=w.crossButton?.enabled!==!1,et=w.expandablePip??v.expandablePip??v.expandable_pip,X=et!=null&&et!==""?Ls(et):w.expandControls?.enabled!==!1,q={...w,crossButton:{...w.crossButton,enabled:U,image:v.crossButtonImage||w.crossButton?.image},soundToggle:{...w.soundToggle,enabled:z,mute:{...w.soundToggle?.mute,image:v.muteImage||w.soundToggle?.mute?.image},unmute:{...w.soundToggle?.unmute,image:v.unmuteImage||w.soundToggle?.unmute?.image}},expandControls:{...w.expandControls,enabled:X,maximise:{...w.expandControls?.maximise,image:v.maximiseImage||w.expandControls?.maximise?.image},minimise:{...w.expandControls?.minimise,image:v.minimiseImage||w.expandControls?.minimise?.image}}},J=()=>{d(K=>{let it=!K;return it&&L?.id&&(rt("viewed",L.id),rt("analyze",L.id)),it})},nt={position:"fixed",zIndex:10020,width:c?"auto":A,height:c?"auto":T,borderRadius:c?0:5,overflow:"hidden",background:"#000",boxShadow:"0 16px 40px rgba(0,0,0,0.35)",cursor:y?"grabbing":x&&!c?"grab":"default",transition:y?"none":"width 180ms ease, height 180ms ease, transform 180ms ease",touchAction:c||x?"none":"auto",WebkitUserSelect:"none",userSelect:"none",WebkitTapHighlightColor:"transparent"};C&&!c?(nt.left=C.x,nt.top=C.y):c?(nt.left=0,nt.top=0,nt.right=0,nt.bottom=0):(f==="left"?nt.left=24:nt.right=24,M>0?nt.top=M:nt.bottom=r+20);let ht=K=>{if(!x||c||K.pointerType==="mouse"&&K.button!==0||K.target.closest("[data-control-button='true']"))return;let lt=K.currentTarget.getBoundingClientRect();g.current={x:K.clientX-lt.left,y:K.clientY-lt.top},E.current={x:K.clientX,y:K.clientY},O.current=!1,h({x:lt.left,y:lt.top}),u(!0)},dt=()=>{if(!v.link)return;rt("clicked",L.id);let K=String(v.link).trim();try{let it=P.getState(),lt=it.allCampaigns||[],mt=it.campaigns||[],gt=lt.find(R=>R.id===K);if(console.log("[Pip] clicked link=",K,"allCount=",lt.length,"visibleCount=",mt.length,"referenced=",!!gt),gt){let R={...gt};delete R.trigger_event,delete R.trigger,R.display_trigger=!0;let I=mt.findIndex(N=>N.id===R.id);if(I===-1)it.saveCampaigns([R,...mt]);else{let N=mt[I];if(!!(N.trigger_event??N.trigger)){let xt=[...mt];xt[I]=R,it.saveCampaigns(xt)}}return}}catch{}window.open(v.link,"_blank")};return a?As("div",{style:nt,onPointerDown:ht,children:[wn("video",{ref:m,src:a,autoPlay:!0,loop:!0,playsInline:!0,muted:S,style:{width:"100%",height:"100%",objectFit:c?"contain":"cover",cursor:X&&!c||v.link?"pointer":"default"},onClick:()=>{if(O.current){O.current=!1;return}if(X){J();return}dt()},onEnded:()=>{D&&rt("analyze",D.id)}}),wn(Di,{styling:q,mode:c?"LARGE":"SMALL",muted:!S,expanded:c,onClose:()=>l(!0),onToggleMute:()=>p(K=>!K),onToggleExpand:J,containerStyle:c?{paddingTop:"env(safe-area-inset-top, 0px)",paddingLeft:"env(safe-area-inset-left, 0px)",paddingRight:"env(safe-area-inset-right, 0px)"}:void 0}),c&&Y&&wn("button",{"data-control-button":"true",onClick:dt,style:{position:"absolute",left:H.left??12,right:H.right??12,bottom:`calc(${H.bottom??12}px + env(safe-area-inset-bottom, 0px))`,height:k.height||42,width:k.ctaFullWidth?"auto":k.ctaWidth||"auto",maxWidth:`calc(100% - ${(H.left??12)+(H.right??12)}px)`,margin:k.ctaFullWidth?"0":"0 auto",background:k.backgroundColor||"#F7921C",color:B.color||"#fff",border:`${k.borderWidth||0}px solid ${k.borderColor||"transparent"}`,borderTopLeftRadius:typeof W=="number"?W:W?.topLeft??10,borderTopRightRadius:typeof W=="number"?W:W?.topRight??10,borderBottomRightRadius:typeof W=="number"?W:W?.bottomRight??10,borderBottomLeftRadius:typeof W=="number"?W:W?.bottomLeft??10,fontSize:B.fontSize||14,fontFamily:st(B.fontFamily),fontWeight:600,cursor:v.link?"pointer":"default"},children:v.button_text})]}):null};import Ms,{useEffect as kn,useRef as Rn,useState as Vo}from"react";import{LottiePlayer as Ps}from"lottie-react";yt();import{jsx as qe}from"react/jsx-runtime";var Jt=(t,e=0)=>{let o=Number(t);return Number.isFinite(o)?o:e},Fn=t=>(t||"").trim().toLowerCase(),Ds="appstorysmediabucketdev.s3.ap-south-1.amazonaws.com",_s=t=>{try{if(typeof window>"u")return[t];let e=new URL(t);if(e.hostname!==Ds)return[t];let o=!!window.location.port,n=`/appstorys-media${e.pathname}${e.search}`;return o?[n,t]:[t]}catch{return[t]}},Ws=t=>{if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return Array.isArray(e.layers)||Array.isArray(e.assets)||typeof e.v=="string"},Tn=class extends Ms.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(){this.props.onError()}render(){return this.state.hasError?null:this.props.children}},$s=()=>{let[t,e]=Vo(null),[o,n]=Vo([]),[i,s]=Vo(!1),[l,c]=Vo(!1),d=Rn(null),S=Rn(null),p=At("FLT"),y=P(k=>k.campaigns),u=P(k=>k.allCampaigns),C=P(k=>k.currentScreen),h=P(k=>k.isVisible),g=Rn(null),b=p??(()=>{let k=[...y,...u].find(B=>{let W=B;if(W.campaign_type!=="FLT")return!1;let H=!!(W.trigger_event??W.trigger);return W.display_trigger===!1||H?!1:!Fn(W.screen)||Fn(W.screen)===Fn(C)});if(k)try{return Nt(k)}catch{return k}})(),m=b?.id,E=P(k=>m?k.variantMappings[m]:void 0);if(kn(()=>{if(!b?.id||!h||Eo(b)&&!E)return;let B=`${b.id}:${E||""}`;g.current!==B&&(g.current=B,rt("viewed",b.id))},[b?.id,E,h]),kn(()=>{let k=b?.details?.lottie_data;if(e(null),n([]),s(!1),c(!1),!k)return;if(Ws(k)){e(k),c(!0);return}if(typeof k!="string"){s(!0);return}let B=_s(k);n(B),c(!0)},[b?.details?.lottie_data]),kn(()=>{if(!b?.details?.lottie_data||!d.current)return;let k=Ps;if(!k||typeof k.loadAnimation!="function"){s(!0),c(!1);return}let B=!1,W=null,H=()=>{W&&typeof W.destroy=="function"&&W.destroy(),W=null,S.current=null},Y=(r,M)=>{if(B)return;if(M>=r.length){s(!0),c(!1),console.error("[Floater] lottie load failed",{lottieUrls:r});return}H();let a=k.loadAnimation({container:d.current,renderer:"svg",loop:!0,autoplay:!0,path:r[M]});W=a,S.current=a,a.addEventListener("DOMLoaded",()=>{B||c(!1)}),a.addEventListener("data_failed",()=>{B||Y(r,M+1)})};if(t){H();let r=k.loadAnimation({container:d.current,renderer:"svg",loop:!0,autoplay:!0,animationData:t});W=r,S.current=r,r.addEventListener("DOMLoaded",()=>{B||c(!1)}),r.addEventListener("data_failed",()=>{B||(s(!0),c(!1))})}else o.length>0&&Y(o,0);return()=>{B=!0,H()}},[b?.details?.lottie_data,t,o]),!b||!b.details||!h)return null;let{details:O}=b,D=O.styling||{},v=(typeof O.position=="string"?O.position:typeof b.position=="string"?b.position:"right").toLowerCase()==="left"?"left":"right",w={position:"fixed",left:v==="left"?Jt(D.marginLeft,12):void 0,right:v==="left"?void 0:Jt(D.marginRight,12),top:Jt(D.marginTop,0)>0?Jt(D.marginTop,0):void 0,bottom:Jt(D.marginTop,0)>0?void 0:Jt(D.marginBottom,80),zIndex:10040,display:"flex"},_={width:Jt(O.width,60),height:Jt(O.height,60),background:"transparent",overflow:"hidden",borderBottomLeftRadius:Jt(D.bottomLeftRadius,0),borderBottomRightRadius:Jt(D.bottomRightRadius,0),borderTopLeftRadius:Jt(D.topLeftRadius,0),borderTopRightRadius:Jt(D.topRightRadius,0),display:"flex",alignItems:"center",justifyContent:"center",cursor:O.link?"pointer":"default",boxShadow:"0 8px 18px rgba(0,0,0,0.2)"},$=async()=>{if(!O.link)return;await rt("clicked",b.id);let k=String(O.link).trim();try{let B=P.getState(),W=B.allCampaigns||[],H=B.campaigns||[],Y=W.find(r=>{if(!r)return!1;let M=String(r.id||"").trim(),a=r.details||{},f=String(a.campaign||a.id||"").trim();return!!(M&&M===k||f&&f===k||M&&k.includes(M)||f&&k.includes(f))});if(console.log("[Floater] clicked link=",k,"allCampaignsCount=",W.length,"visibleCount=",H.length),console.log("[Floater] all ids=",W.map(r=>r.id).slice(0,50)),console.log("[Floater] referenced found=",!!Y,Y&&(Y.id||Y.details?.campaign||Y.details?.id)),Y){let r={...Y};delete r.trigger_event,delete r.trigger,r.display_trigger=!0;let M=H.findIndex(a=>a.id===r.id);if(M===-1)console.log("[Floater] revealing campaign (prepended)",r.id),B.saveCampaigns([r,...H]);else{let a=H[M];if(!!(a.trigger_event??a.trigger)){let x=[...H];x[M]=r,console.log("[Floater] replacing existing triggered campaign with revealed one",r.id),B.saveCampaigns(x)}else console.log("[Floater] campaign already visible and not trigger-driven",r.id)}return}}catch(B){console.warn("[Floater] error while resolving referenced campaign",B)}try{window.open(O.link,"_blank")}catch{}},V=!!(O.lottie_data&&!i),A=!!O.image,T=!!(O.lottie_data&&l&&!t&&!i);return!V&&!A&&!T?null:qe("div",{style:w,children:qe("div",{style:_,onClick:()=>{$()},children:V?qe(Tn,{onError:()=>s(!0),children:qe("div",{ref:d,style:{width:"100%",height:"100%",display:"block"}})},String(O.lottie_data)):T?qe("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.08)",color:"#333",fontSize:10,fontWeight:600},children:"..."}):qe("img",{src:O.image,alt:"floater",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})})})},Ns=$s;yt();function ji(t){return(t||"").trim().toLowerCase()}function zn(t,e){let o=ji(t.screen),n=ji(e);return!o||o===n}async function In(t){try{let e=P.getState(),o=await Et(),n=e.accountId;if(!o||!n)return;e.setCurrentScreen(t),e.setTrackedEvents([]);let i=e.baseUrl||"https://users.appstorys.co",s=await fetch(`${i}/v2/${n}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({user_id:ee(),screenName:t})});if(!s.ok)return;let l=await s.json();if(typeof l.screen_capture_enabled<"u"&&e.setScreenCaptureEnabled(!!l.screen_capture_enabled),l.variants&&l.variants.length>0){let m={};l.variants.forEach(E=>{m[E.id]=E.v_id}),e.setVariantMappings(m)}l.personalization_data&&e.setPersonalizationData(l.personalization_data);let c=e.allCampaigns||[],d=l.eligibleCampaignList||[],S=c.filter(m=>d.includes(m.id)&&zn(m,t)),p=S.map(m=>m.id),y=d.filter(m=>!p.includes(m)),u=[];if(y.length>0){let m=await fetch(`${i}/load-campaign-data`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(y)});m.ok&&(u=(await m.json()).filter(O=>zn(O,t)))}let C=[...S,...u],h=c.filter(m=>{let E=!!(m.trigger_event??m.trigger);return zn(m,t)&&m.display_trigger===!0&&!E}),g=[...C],b=new Set(g.map(m=>m.id));for(let m of h)b.has(m.id)||(g.push(m),b.add(m.id));e.saveCampaigns(g)}catch(e){console.error("Error when tracking screen:",t,e)}}Po();yt();Mo();async function Bn(t){try{let e=await Et(),o=ee(),n=P.getState();if(!e||!o){console.warn("AppStorys: Missing accessToken or userId. Ensure SDK is initialized before setting user properties.");return}let i={...t||{}},s=await Pe();i={...i,...s};let l={user_id:o,attributes:i},c=n.baseUrl||"https://users.appstorys.co";await Wo({url:`${c}/update-user-atr`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:l})}catch(e){console.error("AppStorys: Error in setUserProperties:",e)}}yt();function Ce(t){if(!t||t.trim()==="")return t;let e=P.getState().personalizationData;if(!e||Object.keys(e).length===0)return Os(t);let o=/\{\{([^|}\s]+)\s*\|\s*([^}]+)\}\}/g;return t.replace(o,(n,i,s)=>{let l=i.trim(),c=s.trim();return e[l]??c})}function Os(t){let e=/\{\{[^|}\s]+\s*\|\s*([^}]+)\}\}/g;return t.replace(e,(o,n)=>n.trim())}Oe();yt();yt();var Ln="appstorys_campaigns_cache",qi="appstorys_campaigns_etag",En="appstorys_campaigns_version";async function An(t,e){try{let o=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),n=o?`/appstorys-campaigns/clients/${t}/campaigns.json`:`https://dev-cdn-campaign-appstorys.s3.ap-south-1.amazonaws.com/clients/${t}/campaigns.json`,i=await Ct.getItem(Ln),s=await Ct.getItem(qi),l=await Ct.getItem(En),c={Accept:"application/json"};!o&&s&&(c["If-None-Match"]=s);let d=await fetch(n,{method:"GET",headers:c,...o?{cache:"no-store"}:{}});if(d.status===304)return{campaigns:i?JSON.parse(i):[],version:l?parseInt(l):1};let S=d.headers.get("ETag"),p=await d.json(),y=2,u=p,C=e;if(!C)try{let h=await Et(),g=ee(),m=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...h?{Authorization:`Bearer ${h}`}:{}},body:JSON.stringify({user_id:g,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(m.ok){let E=await m.json();console.info("AppStorys: fetchAllCampaigns track-user-res returned",E);let O=E?.screenName||E?.screen||E?.currentScreen||E?.screen_name||E?.current_screen;O&&(C=O);try{let D=P.getState();typeof E.screen_capture_enabled<"u"&&D.setScreenCaptureEnabled(!!E.screen_capture_enabled)}catch{}}}catch(h){console.warn("Could not fetch screen name from track-user-res:",h)}if(p.length>0&&p[0].version!==void 0&&(y=p[0].version,u=p.slice(1)),!u||u.length===0)try{let h=await Et(),g=ee(),m=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...h?{Authorization:`Bearer ${h}`}:{}},body:JSON.stringify({user_id:g,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(m.ok){let E=await m.json(),O=E?.user_id||E?.id||E?.userId||g;try{let D=P.getState();typeof E.screen_capture_enabled<"u"&&D.setScreenCaptureEnabled(!!E.screen_capture_enabled)}catch{}if(O){let L=await fetch(o?"/appstorys-users/load-campaign-data":"https://users.appstorys.co/load-campaign-data",{method:"POST",headers:{"Content-Type":"application/json",...h?{Authorization:`Bearer ${h}`}:{}},body:JSON.stringify({user_id:O})});if(L.ok){let v=await L.json();console.log(`Fetched ${v.length} missing campaigns from fallback`),console.log("Fallback campaigns:",JSON.stringify(v,null,2)),v&&v.length>0&&(u=v)}else console.error("Failed to fetch missing campaigns:",await L.text())}}}catch(h){console.error("Error fetching missing campaigns via fallback:",h)}if(C&&u&&u.length>0){let h=b=>(b||"").trim().toLowerCase(),g=h(C);u=u.filter(b=>!h(b.screen)||h(b.screen)===g)}return await Ct.setItem(Ln,JSON.stringify(u)),await Ct.setItem(En,y.toString()),S&&await Ct.setItem(qi,S),{campaigns:u,version:y}}catch(o){console.error("Error fetching campaigns:",o);let n=await Ct.getItem(Ln),i=await Ct.getItem(En);return{campaigns:n?JSON.parse(n):[],version:i?parseInt(i):1}}}yt();yt();yt();async function Uo(t,e){try{let o=await Et(),n=P.getState();if(!o)return console.error("AppStorys: Access token not found for reconciliation"),!1;let i={anonymous_user_id:t,identified_user_id:e},s=n.baseUrl||"https://users.appstorys.co",l=await fetch(`${s}/reconcile-anonymous-user`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(i)});if(l.ok)return!0;{let c=await l.text();return console.error("AppStorys: Failed to reconcile anonymous user:",l.status,c),!1}}catch(o){return console.error("AppStorys: Error in reconcileAnonymousUser:",o),!1}}yt();var Mn=class{isInitialized=!1;setup(){this.isInitialized||typeof window>"u"||(document.addEventListener("mouseleave",this.handleMouseLeave),window.addEventListener("popstate",this.handlePopState),window.history.state!=="appstorys_navigation"&&window.history.pushState("appstorys_navigation",""),this.isInitialized=!0)}destroy(){!this.isInitialized||typeof window>"u"||(document.removeEventListener("mouseleave",this.handleMouseLeave),window.removeEventListener("popstate",this.handlePopState),this.isInitialized=!1)}handleMouseLeave=e=>{e.clientY<=0&&bn()&&this.triggerCampaign()};handlePopState=()=>{bn()&&(window.history.pushState("appstorys_navigation",""),this.triggerCampaign())};triggerCampaign(){let e=P.getState(),{trackedEvents:o}=e;o.includes(Ao)||(console.log("AppStorys: Exit Intent triggered. Displaying campaign."),e.setTrackedEvents([...o,Ao]))}},Hi=new Mn;yt();var Pn=class{isInitialized=!1;setup(){this.isInitialized||typeof document>"u"||(document.addEventListener("visibilitychange",this.handleVisibilityChange),this.updateVisibility(document.visibilityState==="visible"),this.isInitialized=!0)}destroy(){!this.isInitialized||typeof document>"u"||(document.removeEventListener("visibilitychange",this.handleVisibilityChange),this.isInitialized=!1)}handleVisibilityChange=()=>{this.updateVisibility(document.visibilityState==="visible")};updateVisibility(e){let o=P.getState();o.isVisible!==e&&(console.log(`AppStorys: SDK visibility changed to ${e?"visible":"hidden"}`),o.setVisibility(e))}},Dn=new Pn;Oe();var Yo="anonymous_user_id";async function Vi(){let t=Date.now(),e=navigator.userAgent.split(" ")[0].replace(/[^a-zA-Z0-9]/g,"_");return`${t}_${e}`}async function Ui(){try{let t=await Ct.getItem(Yo);if(t)return t;let e=await Vi();return await Ct.setItem(Yo,e),e}catch(t){return console.error("Error managing anonymous user ID:",t),await Vi()}}async function _n(){try{await Ct.removeItem(Yo)}catch(t){console.error("Error clearing anonymous user ID:",t)}}async function Wn(){try{return await Ct.getItem(Yo)}catch(t){return console.error("Error getting stored anonymous user ID:",t),null}}function js(){if(document.getElementById("appstorys-widget-debug-styles"))return;let t=document.createElement("style");t.id="appstorys-widget-debug-styles",t.innerHTML=`
14
+ `,document.head.appendChild(t)}function Gl(){Yl();let t=document.createElement("button");return t.id="appstorys-screen-capture-btn",t.title="Capture screen",Object.assign(t.style,{position:"fixed",left:"16px",bottom:"16px",width:"100px",height:"56px",borderRadius:"28px",background:"#ff6a00",color:"#fff",border:"none",boxShadow:"0 6px 18px rgba(0,0,0,0.2)",zIndex:"2147483647",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",fontWeight:"600",fontFamily:"sans-serif",transition:"all 0.2s ease"}),t.innerText="Capture",t}function ws(){try{let t=W.getState(),o=!!window.__APPSTORYS_DEBUG_CAPTURE;if(console.info("AppStorys: mountScreenCaptureButton called, screenCaptureEnabled=",t.screenCaptureEnabled,"debugForce=",o),!t.screenCaptureEnabled&&!o||document.getElementById("appstorys-screen-capture-btn"))return null;let n=Gl();return n.addEventListener("click",async()=>{n.disabled=!0;let i=n.innerText;n.innerHTML='<div class="appstorys-spinner"></div>';let d=W.getState().currentScreen||(typeof window<"u"?window.location.pathname:"");try{await So.takeScreenshot(d)}catch(c){console.error("CaptureService error",c)}n.disabled=!1,n.innerText=i,n.animate([{transform:"scale(1.0)"},{transform:"scale(1.05)"},{transform:"scale(1.0)"}],{duration:300})}),document.body.appendChild(n),console.info("AppStorys: screen capture button mounted"),n}catch(t){return console.error("mountScreenCaptureButton error",t),null}}var Rs=Be(()=>{"use strict";vt();vs();try{window.AppStorysMountCapture=function(){try{return ws()}catch(t){return console.error("AppStorysMountCapture failed",t),null}}}catch{}try{window.AppStorysDebugState=function(){try{let t=W.getState();return console.info("AppStorys store state:",t),t}catch(t){return console.error("AppStorysDebugState failed",t),null}}}catch{}try{window.AppStorysDebugToken=function(){try{let t=localStorage.getItem("access_token")||"",e=t.length,o=t?t.slice(0,20)+"..."+t.slice(-10):"(none)";if(console.info("Token length:",e,"masked:",o),t&&t.includes("."))try{let n=t.split(".");if(n.length===3){let i=JSON.parse(atob(n[1]));if(console.info("Token payload:",i),i.exp){let s=new Date(i.exp*1e3),d=new Date;console.info("Token expires:",s.toISOString(),"Expired:",d>s)}}}catch(n){console.warn("Could not decode JWT:",n)}return t?"Token present":"No token"}catch(t){return console.error("AppStorysDebugToken failed",t),null}}}catch{}});var Ii=(i=>(i.uninitialized="uninitialized",i.initializing="initializing",i.initialized="initialized",i.error="error",i))(Ii||{});vt();import{useState as Zo,useEffect as Ni,useRef as Oi}from"react";import*as Ze from"lottie-react";vt();import{useMemo as Ms}from"react";vt();var Ai="appstorys_variant_mappings",ko={};function Ls(t){let e=0;for(let o=0;o<t.length;o++){let n=t.charCodeAt(o);e=(e<<5)-e+n,e|=0}return Math.abs(e)}function Li(){if(typeof window>"u")return{};try{let t=localStorage.getItem(Ai);if(t)return JSON.parse(t)}catch{}return{}}function Es(t,e){if(!(!t||!e)){ko[t]=e;try{let o=W.getState(),n=o.variantMappings||{};n[t]!==e&&o.setVariantMappings({...n,[t]:e})}catch{}if(typeof window<"u")try{let o=Li();o[t]=e,localStorage.setItem(Ai,JSON.stringify(o))}catch{}}}var Ei=t=>{if(!t)return;if(ko[t])return ko[t];let e=W.getState().variantMappings?.[t];if(e)return ko[t]=e,e;let o=Li();if(o[t]){ko[t]=o[t];try{W.getState().setVariantMappings({...W.getState().variantMappings||{},[t]:o[t]})}catch{}return o[t]}};function Ho(t){if(!t)return!1;if(t.hasVariants===!0||t.variants&&typeof t.variants=="object"&&Object.keys(t.variants).length>0)return!0;if(t.details&&typeof t.details=="object"&&t.details.variants){let e=t.details.variants;if(typeof e=="object"&&Object.keys(e).length>0)return!0}return!1}function Ps(t,e){let o=Object.keys(t);if(o.length===0)return;let n=o.filter(d=>t[d]&&t[d].isActive!==!1),i=n.length>0?n:o,s=i.reduce((d,c)=>d+(Number(t[c]?.weight)||0),0);if(s>0){let d=W.getState().userId||"default",c=`${e||"campaign"}_${d}`,y=Ls(c)%1e4/1e4*s;for(let u of i){let m=Number(t[u]?.weight)||0;if(y<m)return u;y-=m}}return i[0]}function Kt(t){if(!t||!Ho(t))return t;let e=t,o=e.variants||e.details?.variants;if(!o||typeof o!="object"||Object.keys(o).length===0)return t;let n=Ei(e.id||"");if((!n||!o[n])&&(n=Ps(o,e.id),e.id&&n&&Es(e.id,n)),!n||!o[n])return t;let i=o[n],d={...e.details&&typeof e.details=="object"?Object.fromEntries(Object.entries(e.details).filter(([c])=>c!=="variants")):{},...i};return{...t,details:d,_variantId:n}}function id(t){if(t){if("_variantId"in t)return t._variantId;if(Ho(t))return Ei(t.id||"")}}Vt();vt();function Ot(t,e){return t?t.isTesting===!0||Array.isArray(t.testUsers)&&t.testUsers.length>0?!e||typeof e!="string"||e.trim()===""?!1:(Array.isArray(t.testUsers)?t.testUsers:[]).includes(e):!0:!1}function wt(t){return!t||(typeof t=="object"&&(t=t.url||t.value||t.key||t.link||""),typeof t!="string")?!1:t.trim().toUpperCase()==="APPSTORYS-CLOSE"}function qt(t){if(!t||wt(t))return!1;let e=W.getState(),o=e.allCampaigns||[],n=e.campaigns||[],i=String(t).trim(),s=o.find(l=>{if(!l)return!1;let y=String(l.id||"").trim(),u=l.details||{},m=String(u.campaign||u.id||"").trim();return!!(y&&y===i||m&&m===i||y&&i.includes(y)||m&&i.includes(m))});if(!s)return!1;let d={...s};delete d.trigger_event,delete d.trigger,d.display_trigger=!0;let c=n.findIndex(l=>String(l.id||"")===String(d.id||""));if(c===-1)e.saveCampaigns([d,...n]);else{let l=n[c];if(!!(l.trigger_event??l.trigger)){let u=[...n];u[c]=d,e.saveCampaigns(u)}}return!0}var Vo="__back_press_triggered__";function Pi(t){return(t||"").trim().toLowerCase()}function _s(t,e){let o=Pi(t),n=Pi(e);return!o||o===n}function Ws(t,e,o){let n=Number(t),i=Number(o),s=!isNaN(n)&&!isNaN(i);switch(e){case"eq":return s?n===i:t===o;case"neq":return s?n!==i:t!==o;case"gt":return s?n>i:t>o;case"gte":return s?n>=i:t>=o;case"lt":return s?n<i:t<o;case"lte":return s?n<=i:t<=o;default:return!1}}function Ds(t,e){let o=t.filter(n=>n.back_press==null);return o.length===0?!0:e.some(n=>o.every(i=>{let s=n[i.key];return s==null?!1:Ws(String(s),i.operator,i.value)}))}function $s(t,e,o){let n=t,i=n.trigger_event??n.trigger,s=t.id;return!i}function An(){let{campaigns:t,trackedEvents:e,trackedEventMetadata:o,currentScreen:n}=W.getState();return t.some(i=>{if(i.screen&&i.screen!==n)return!1;let s=i.trigger_event;if(!s||typeof s=="string")return!1;let{event:d,event_config:c}=s;if(!(c??[]).some(u=>u.back_press===!0)||e.includes(Vo)||!e.includes(d))return!1;let l=(c??[]).filter(u=>u.back_press==null);if(l.length===0)return!0;let y=o[d]||[];return Ds(l,y)})}function Ln(t){return Array.isArray(t)?[...t].sort((o,n)=>{let i=typeof o?.order=="number"?o.order:0,s=typeof n?.order=="number"?n.order:0;return i-s}).map(o=>{if(!o||!Array.isArray(o.slides))return o;let n=[...o.slides].sort((i,s)=>{let d=typeof i?.order=="number"?i.order:0,c=typeof s?.order=="number"?s.order:0;return d-c});return{...o,slides:n}}):[]}function Mt(t,e){let o=W(y=>y.currentScreen),n=W(y=>y.campaigns),i=W(y=>y.allCampaigns),s=W(y=>y.userId),d=W(y=>y.trackedEvents),c=W(y=>y.trackedEventMetadata),l=W(y=>y.variantMappings);return Ms(()=>{let y=P=>{let g=P.filter(R=>{if(!Ot(R,s))return!1;let C=R.campaign_type;if(!(t==="TTP"||t==="TLTP"?C==="TTP"||C==="TLTP":C===t)||e?.position&&R.position!==e.position||!$s(R,d,c))return!1;if(e?.screenContains){let T=(e.screenContains||"").trim().toLowerCase();return(R.screen||"").trim().toLowerCase().includes(T)}return _s(R.screen,o)});return g.length===0?void 0:Lt(g)[0]},m=(n&&n.length>0?y(n):void 0)??y(i||[]);if(!m)return;let f=Kt(m);return f&&f.details&&Array.isArray(f.details)&&(f.details=Ln(f.details)),f},[n,i,s,d,c,l,t,e,o])}vt();Yo();Ke();vt();Go();var _i="appstorys_offline_queue";async function Wi(){let t=await Tt.getItem(_i);return t?JSON.parse(t):[]}async function Di(t){await Tt.setItem(_i,JSON.stringify(t))}function Ns(t){return Math.min(3e4*Math.pow(2,t),12e4)}function Os(t){let o=t.retryCount||0,n=t.lastAttempt||0,i=Ns(o);return o<3&&Date.now()-n>=i}async function js(){let t=W.getState();return!t.accountId||!t.appId?!1:await ke(t.accountId,t.appId,t.userId)}async function $i(t,e){if(await js()){let n=await Tt.getItem("access_token");n&&(t.headers={...t.headers,Authorization:`Bearer ${n}`}),t.authRetried=!0,t.lastAttempt=Date.now(),e(t)}}async function Jo(t,e){let o=(t.retryCount||0)+1;o<=3&&(t.retryCount=o,t.lastAttempt=Date.now(),e(t))}async function Qo(t){let e=await Wi();e.push(t),await Di(e)}async function qs(){let t=await Wi();if(t.length===0)return;let e=[];for(let o of t){if(!Os(o)){e.push(o);continue}try{let n=await fetch(o.url,{method:o.method,headers:o.headers,body:JSON.stringify(o.body)});if(n.ok)continue;n.status===401||n.status===403?o.authRetried||await $i(o,i=>e.push(i)):n.status>=500&&await Jo(o,i=>e.push(i))}catch{await Jo(o,i=>e.push(i))}}await Di(e)}async function Xo(t){if(!navigator.onLine){await Qo(t);return}await qs();try{let e=await fetch(t.url,{method:t.method,headers:t.headers,body:JSON.stringify(t.body)});return e.ok||(e.status===401||e.status===403?await $i(t,Qo):e.status>=500&&await Jo(t,Qo)),e}catch{await Jo(t,Qo);return}}async function st(t,e,o){try{if(!t)return;let n=await Pt(),i=W.getState(),s=["viewed","clicked","csat captured","survey captured","shared"];if(!s.includes(t)){let y=i.trackedEvents;if(!y.includes(t))i.setTrackedEvents([...y,t]);else{let u=y.filter(m=>m!==t);u.push(t),i.setTrackedEvents(u)}if(o&&Object.keys(o).length>0){let u=i.trackedEventMetadata||{},m=u[t]||[];i.setTrackedEventMetadata({...u,[t]:[...m,o]})}}let d={...o||{}};if(!s.includes(t)){let y=await Ue();d={...d,...y}}if(e&&String(e).trim()!==""){let y=o?.variant_id||Bi(e);y&&(d.variant_id=y)}let c={user_id:le(),event:t,metadata:d};e&&(c.campaign_id=e);let l=i.trackingUrl||"https://tracking.appstorys.co";n&&await Xo({url:`${l}/capture-event`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:c})}catch(n){console.error("Error in trackEvent",n)}}import{jsx as Ko,jsxs as Hs}from"react/jsx-runtime";var Us=({config:t,onPress:e,style:o,ignoreSizeAndMargin:n=!1})=>{if(!t||!t.enabled)return null;let i=t.size,s=t.margin,d=t.color,c=t.image,l=t.selectedStyle,y=i!=null&&i>=0?i:18,u=n?40:y,m=s?.top!==void 0&&s?.top!==null&&s.top>=0?s.top:0,f=s?.bottom!==void 0&&s?.bottom!==null&&s.bottom>=0?s.bottom:0,P=s?.left!==void 0&&s?.left!==null&&s.left>=0?s.left:0,g=s?.right!==void 0&&s?.right!==null&&s.right>=0?s.right:0,b={marginTop:n?0:m,marginBottom:n?0:f,marginLeft:n?0:P,marginRight:n?0:g,width:u,height:u,backgroundColor:d?.fill||"transparent",borderColor:d?.stroke||"transparent",borderWidth:u*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"absolute",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:d?.stroke?"solid":"none",...o},R=()=>{let C=d?.cross||"#ffffff";return Hs("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[Ko("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:C,strokeWidth:"2.2",strokeLinecap:"round"}),Ko("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:C,strokeWidth:"2.2",strokeLinecap:"round"})]})};return Ko("button",{type:"button","data-control-button":"true",onMouseDown:C=>C.stopPropagation(),onClick:C=>{C.stopPropagation(),C.preventDefault(),e(C)},style:b,children:c&&c.trim()!==""?Ko("img",{src:c,style:{width:u,height:u,objectFit:"contain"},alt:"close"}):R()})},Ut=Us;Vt();import{jsx as tn,jsxs as Ys}from"react/jsx-runtime";var ji=Ze.default?.default??Ze.default??Ze.Lottie??Ze,Vs=()=>{let t=Mt("BAN"),e=W(z=>z.isVisible),[o,n]=Zo(!1),[i,s]=Zo(null),[d,c]=Zo(null),l=Oi(null),[y,u]=Zo(0),m=Oi(null);if(Ni(()=>{t?.id&&m.current!==t.id&&(m.current=t.id,n(!1),st("viewed",t.id),t.details?.lottie_data&&fetch(t.details.lottie_data).then(z=>z.json()).then(z=>{s(z),z.w&&z.h&&c(z.h/z.w)}).catch(z=>console.error("Error loading Lottie:",z)))},[t?.id]),Ni(()=>{let z=()=>{l.current&&u(l.current.offsetWidth)};return z(),window.addEventListener("resize",z),()=>window.removeEventListener("resize",z)},[t,o]),!t||o||!e)return null;let{details:f}=t,P=f.styling||{},g=f.height||"auto";d&&y&&(g=y*d);let b=parseFloat(String(f.height)),R=parseFloat(String(f.originalWidth??f.styling?.originalWidth)),C=parseFloat(String(f.originalHeight??f.styling?.originalHeight)),h=Number.isFinite(b)&&b>0&&Number.isFinite(R)&&R>0&&Number.isFinite(C)&&C>0?b*(R/C):null,T=h!==null?`${h}px`:void 0,E=typeof g=="number"?`${g}px`:g||void 0,X=Number(P.marginRight),I=Number(P.marginBottom),S={position:"fixed",right:Number.isFinite(X)?`${X}px`:"0px",bottom:Number.isFinite(I)?`${I}px`:"0px",zIndex:Et(t,"BAN"),display:"block",cursor:f.link?"pointer":"default"},M={position:"relative",width:T||"100%",height:E||"auto",backgroundColor:"transparent",borderRadius:`${P.topRightRadius||0}px ${P.topLeftRadius||0}px ${P.bottomRightRadius||0}px ${P.bottomLeftRadius||0}px`,overflow:"hidden"},x={width:"100%",height:"100%",display:"block",objectFit:"contain"},N=z=>{z.stopPropagation(),n(!0),st("banner_closed",t.id)};return tn("div",{ref:l,style:S,onClick:()=>{if(f.link){if(st("clicked",t.id),wt(f.link)){n(!0),st("banner_closed",t.id);return}if(f.link.startsWith("http"))window.open(f.link,"_blank");else{try{if(qt(f.link))return}catch(z){console.warn("revealCampaignFromLink error",z)}console.log("Internal link:",f.link)}}},children:Ys("div",{style:M,children:[i?(()=>{let z=ji.default||ji;return tn(z,{animationData:i,loop:!0,autoplay:e,style:x})})():f.image?tn("img",{src:f.image,alt:"Campaign Banner",style:x}):null,P.crossButton?.enabled&&tn(Ut,{config:P.crossButton,onPress:N,style:{top:P.crossButton?.margin?.top!==void 0?0:5,right:P.crossButton?.margin?.right!==void 0?0:5}})]})})};import{useEffect as Ro,useMemo as Ji,useRef as To,useState as Fo}from"react";vt();function on(t){let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")}function qi(t){try{let o=new URL(t).pathname.split("/").pop()||t;return o.split("?")[0].replace(/\.[^.]+$/,"")||`font_${o.length}`}catch{return(t.split("/").pop()??t).split("?")[0].replace(/\.[^.]+$/,"")||`font_${t.length}`}}function Ui(t,e){if(typeof document>"u")return;let o=`appstorys-font-${t}`;if(document.getElementById(o))return;let n=document.createElement("style");n.id=o,n.type="text/css",n.textContent=`@font-face{font-family:"${t}";src:url("${e}");font-style:normal;font-weight:normal;font-display:swap;}`,document.head.appendChild(n)}var en=new Map;async function Gs(t,e){try{Ui(e.name,t);let o=globalThis.FontFace;if(typeof document<"u"&&o&&document.fonts?.add){let n=new o(e.name,`url(${t})`);await n.load(),document.fonts.add(n)}else typeof document<"u"&&document.fonts?.load&&await document.fonts.load(`1em "${e.name}"`);e.status="loaded",e.listeners.forEach(n=>n(e.name))}catch(o){console.warn(`[FontManager] Failed to load font from "${t}":`,o),e.status="failed",e.listeners.forEach(n=>n(void 0))}finally{e.listeners=[]}}var En={async load(t){if(!t||!on(t))return;let e=en.get(t);if(e)return e.status==="loaded"?e.name:e.status==="failed"?void 0:new Promise(s=>e.listeners.push(s));let n={status:"pending",name:qi(t),listeners:[]};en.set(t,n);let i=new Promise(s=>n.listeners.push(s));return Gs(t,n),i},ensure(t){if(!t||!on(t))return;let e=qi(t);return Ui(e,t),En.load(t),e},getSync(t){if(!t)return;let e=en.get(t);return e?.status==="loaded"?e.name:void 0},_clearCache(){en.clear()}};function ut(t,e){if(!t)return e;let o=String(t).trim();if(!o)return e;if(on(o)){let n=En.ensure(o);return n?`"${n}", ${e||"sans-serif"}`:e}return o.includes(",")||o.includes('"')||o.includes("'")?o:`"${o}", ${e||"sans-serif"}`}function Qs(t){let e=new Set,o=new WeakSet,n=i=>{if(i!=null&&typeof i!="string"){if(Array.isArray(i)){for(let s of i)n(s);return}if(typeof i=="object"){if(o.has(i))return;o.add(i);for(let[s,d]of Object.entries(i))s==="fontFamily"&&typeof d=="string"&&on(d)&&e.add(d),n(d)}}};return n(t),Array.from(e)}async function Hi(t){let e=new Set;for(let o of t)Qs(o).forEach(n=>e.add(n));await Promise.all(Array.from(e).map(o=>En.load(o)))}import{jsx as Ae,jsxs as Vi}from"react/jsx-runtime";var Re=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:n,style:i,type:s})=>{if(!t||!n)return null;let{size:d=18,margin:c,color:l,image:y,selectedStyle:u}=t,m=o?40:d,f=o?0:c?.top??0,P=o?0:c?.bottom??0,g=o?0:c?.left??0,b=o?0:c?.right??0,R={marginTop:f,marginBottom:P,marginLeft:g,marginRight:b,width:m,height:m,backgroundColor:l?.fill||"transparent",borderColor:l?.stroke||"transparent",borderWidth:m*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,display:"flex",...o?{}:{marginTop:t.margin?.top??0,marginRight:t.margin?.right??0,marginBottom:t.margin?.bottom??0,marginLeft:t.margin?.left??0},...i},C=()=>{let h=l?.cross||"#ffffff";return s==="mute"?Vi("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[Ae("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinejoin:"round"}),Ae("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"}),Ae("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"})]}):Vi("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[Ae("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinejoin:"round"}),Ae("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"}),Ae("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"})]})};return Ae("button",{type:"button","data-control-button":"true",onMouseDown:h=>h.stopPropagation(),onClick:h=>{h.stopPropagation(),h.preventDefault(),e(h)},style:{...R,border:R.borderColor?`${R.borderWidth}px solid ${R.borderColor}`:"none",padding:0,cursor:"pointer",outline:"none"},children:y&&y.trim()!==""?Ae("img",{src:y,style:{width:m,height:m,objectFit:"contain"},alt:s}):C()})};import{jsx as me,jsxs as Yi}from"react/jsx-runtime";var Gi=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:n,style:i,type:s})=>{if(!t||!n)return null;let{size:d=18,margin:c,color:l,image:y,selectedStyle:u}=t,m=o?40:d,f={marginTop:o?0:c?.top??0,marginBottom:o?0:c?.bottom??0,marginLeft:o?0:c?.left??0,marginRight:o?0:c?.right??0,width:m,height:m,backgroundColor:l?.fill||"transparent",borderColor:l?.stroke||l?.cross||"#ffffff",borderWidth:l?.stroke?Math.max(1,m*.05):2,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:"solid",boxSizing:"border-box",...o?{}:{marginTop:t.margin?.top??0,marginRight:t.margin?.right??0,marginBottom:t.margin?.bottom??0,marginLeft:t.margin?.left??0},...i},P=()=>{let g=l?.cross||"#ffffff";return s==="maximise"?Yi("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%","aria-hidden":!0,children:[me("polyline",{points:"15,5 19,5 19,9",fill:"none",stroke:g,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),me("line",{x1:"19",y1:"5",x2:"14",y2:"10",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"}),me("polyline",{points:"9,19 5,19 5,15",fill:"none",stroke:g,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),me("line",{x1:"5",y1:"19",x2:"10",y2:"14",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"})]}):Yi("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%","aria-hidden":!0,children:[me("polyline",{points:"14,6 14,10 18,10",fill:"none",stroke:g,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),me("line",{x1:"14",y1:"10",x2:"19",y2:"5",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"}),me("polyline",{points:"6,14 10,14 10,18",fill:"none",stroke:g,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),me("line",{x1:"10",y1:"14",x2:"5",y2:"19",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"})]})};return me("button",{type:"button","data-control-button":"true",onMouseDown:g=>g.stopPropagation(),onClick:g=>{g.stopPropagation(),g.preventDefault(),e(g)},style:f,children:y&&y.trim()!==""?me("img",{src:y,style:{width:m,height:m,objectFit:"contain"},alt:s}):P()})};import{jsx as Pn,jsxs as Xs}from"react/jsx-runtime";var Js=({styling:t,mode:e,muted:o,expanded:n,onClose:i,onToggleMute:s,onToggleExpand:d,containerStyle:c})=>{if(!t)return null;let l=e==="LARGE",y={position:"absolute",pointerEvents:"auto",...l?{top:15,right:15}:{top:0,right:0}},u={position:"absolute",pointerEvents:"auto",...l?{top:15,right:60}:{top:0,left:0}},m={position:"absolute",pointerEvents:"auto",...l?{top:15,left:15}:{bottom:0,right:0}},f=o?t.soundToggle?.unmute:t.soundToggle?.mute,P=n?t.expandControls?.minimise:t.expandControls?.maximise;return Xs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:9999999,pointerEvents:"none",...c},children:[t.crossButton?.enabled&&Pn(Ut,{config:{enabled:t.crossButton?.enabled??!1,image:t.crossButton?.image??"",color:{cross:t.crossButton?.color?.cross??"#ffffff",fill:t.crossButton?.color?.fill??"",stroke:t.crossButton?.color?.stroke??""},margin:{top:t.crossButton?.margin?.top??0,bottom:t.crossButton?.margin?.bottom??0,left:t.crossButton?.margin?.left??0,right:t.crossButton?.margin?.right??0},size:t.crossButton?.size&&t.crossButton.size>10?t.crossButton.size:20},onPress:i,ignoreSizeAndMargin:l,style:y}),t.soundToggle?.enabled&&f&&Pn(Re,{config:f,onPress:s,ignoreSizeAndMargin:l,style:u,enabled:t.soundToggle?.enabled,type:o?"unmute":"mute"}),t.expandControls?.enabled&&P&&Pn(Gi,{config:P,onPress:d,ignoreSizeAndMargin:l,style:m,enabled:t.expandControls?.enabled,type:n?"minimise":"maximise"})]})},Qi=Js;Vt();import{jsx as _n,jsxs as ta}from"react/jsx-runtime";var Mn=t=>(t||"").trim().toLowerCase(),nn=(t,e)=>{let o=Number(t);return Number.isFinite(o)?o:e},Xi=20,Ki=20,Zi=20,tr=(t,e,o)=>{let n=window.innerWidth,i=window.innerHeight,s=Xi,d=Math.max(s,n-o.width-Xi),c=o.topInset,l=Math.max(c,i-o.height-o.bottomInset);return{x:Math.min(Math.max(t,s),d),y:Math.min(Math.max(e,c),l)}},Ks=t=>{if(t===!0||t===1)return!0;if(t===!1||t===0||t==null||t==="")return!1;let e=String(t).trim().toLowerCase();return e==="yes"||e==="true"||e==="1"},Zs=()=>{let t=Mt("PIP"),e=W(Q=>Q.campaigns),o=W(Q=>Q.allCampaigns),n=W(Q=>Q.currentScreen),i=W(Q=>Q.userId),s=W(Q=>Q.isVisible),[d,c]=Fo(!1),[l,y]=Fo(!1),[u,m]=Fo(!0),[f,P]=Fo(!1),[g,b]=Fo(null),R=To({x:0,y:0}),C=To({width:150,height:300,topInset:Ki,bottomInset:Zi}),h=To(null),T=To({x:0,y:0}),E=To(!1),X=Ji(()=>{if(t)return t;let Q=Mn(n),yt=($=>$.filter(_=>{let D=_,L=D.campaign_type==="PIP",Y=!Mn(D.screen)||Mn(D.screen)===Q,ot=!!(D.trigger_event??D.trigger),ft=D.display_trigger!==!1&&!ot;return L&&Y&&ft&&Ot(D,i)}))(e&&e.length>0?e:o||[]);if(yt.length===0)return;let mt=Lt(yt)[0];return mt?Kt(mt):void 0},[t,e,o,i,n]),I=Ji(()=>X,[X?.id,X?.details?.id]);if(Ro(()=>{if(!I)return;let Q=I.details||{},dt=Q?.styling?.soundToggle?.defaultSound||Q?.styling?.appearance?.defaultSound||"yes";m(String(dt).toLowerCase()!=="yes"),c(!1),y(!1),b(null),st("viewed",I.id)},[I]),Ro(()=>{let Q=h.current;if(!Q)return;Q.muted=u;let dt=Q.play();dt&&typeof dt.catch=="function"&&dt.catch(()=>{u||(Q.muted=!0,m(!0))})},[u]),Ro(()=>{if(!l)return;let Q=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=Q}},[l]),Ro(()=>{if(!f)return;let Q=yt=>{let ct=yt.clientX-T.current.x,mt=yt.clientY-T.current.y;(Math.abs(ct)>4||Math.abs(mt)>4)&&(E.current=!0);let $=yt.clientX-R.current.x,_=yt.clientY-R.current.y;b(tr($,_,C.current))},dt=()=>{P(!1)};return window.addEventListener("pointermove",Q),window.addEventListener("pointerup",dt),window.addEventListener("pointercancel",dt),()=>{window.removeEventListener("pointermove",Q),window.removeEventListener("pointerup",dt),window.removeEventListener("pointercancel",dt)}},[f]),Ro(()=>{let Q=()=>{b(dt=>dt&&tr(dt.x,dt.y,C.current))};return window.addEventListener("resize",Q),window.addEventListener("orientationchange",Q),()=>{window.removeEventListener("resize",Q),window.removeEventListener("orientationchange",Q)}},[]),!I||!I.details||d||!s)return null;let S=I.details,M=S.styling||{},x=M.appearance||{},N=nn(S.width??x.pipWidth,150),U=nn(S.height??x.pipHeight,300),z=N,O=U,B=M.cta?.container||{},K=M.cta?.text||{},v=M.cta?.cornerRadius,A=M.cta?.margin||{},H=!!(S.button_text&&S.button_text.trim().length>0),it=nn(M.pipBottomPadding,20),at=nn(M.pipTopPadding,0);C.current={width:z,height:O,topInset:Ki+at,bottomInset:Zi+it};let a=l?S.large_video||S.small_video:S.small_video||S.large_video,F=(S.position||I.position||"right").toLowerCase(),r=!!M.isMovable,p=M.soundToggle?.enabled!==!1,j=M.crossButton?.enabled!==!1,k=M.expandablePip??S.expandablePip??S.expandable_pip,G=k!=null&&k!==""?Ks(k):M.expandControls?.enabled!==!1,V={...M,crossButton:{...M.crossButton,enabled:j,image:S.crossButtonImage||M.crossButton?.image},soundToggle:{...M.soundToggle,enabled:p,mute:{...M.soundToggle?.mute,image:S.muteImage||M.soundToggle?.mute?.image},unmute:{...M.soundToggle?.unmute,image:S.unmuteImage||M.soundToggle?.unmute?.image}},expandControls:{...M.expandControls,enabled:G,maximise:{...M.expandControls?.maximise,image:S.maximiseImage||M.expandControls?.maximise?.image},minimise:{...M.expandControls?.minimise,image:S.minimiseImage||M.expandControls?.minimise?.image}}},rt=()=>{y(Q=>{let dt=!Q;return dt&&I?.id&&(st("viewed",I.id),st("analyze",I.id)),dt})},lt={position:"fixed",zIndex:l?1e5:Et(I,"PIP"),width:l?"auto":z,height:l?"auto":O,borderRadius:l?0:5,overflow:"hidden",background:"#000",boxShadow:"0 16px 40px rgba(0,0,0,0.35)",cursor:f?"grabbing":r&&!l?"grab":"default",transition:f?"none":"width 180ms ease, height 180ms ease, transform 180ms ease",touchAction:l||r?"none":"auto",WebkitUserSelect:"none",userSelect:"none",WebkitTapHighlightColor:"transparent"};g&&!l?(lt.left=g.x,lt.top=g.y):l?(lt.left=0,lt.top=0,lt.right=0,lt.bottom=0):(F==="left"?lt.left=24:lt.right=24,at>0?lt.top=at:lt.bottom=it+20);let Z=Q=>{if(!r||l||Q.pointerType==="mouse"&&Q.button!==0||Q.target.closest("[data-control-button='true']"))return;let yt=Q.currentTarget.getBoundingClientRect();R.current={x:Q.clientX-yt.left,y:Q.clientY-yt.top},T.current={x:Q.clientX,y:Q.clientY},E.current=!1,b({x:yt.left,y:yt.top}),P(!0)},gt=()=>{if(!S.link)return;st("clicked",I.id);let Q=String(S.link).trim();if(wt(Q)){c(!0),st("pip_closed",I.id);return}try{let dt=W.getState(),yt=dt.allCampaigns||[],ct=dt.campaigns||[],mt=yt.find($=>$.id===Q);if(console.log("[Pip] clicked link=",Q,"allCount=",yt.length,"visibleCount=",ct.length,"referenced=",!!mt),mt){let $={...mt};delete $.trigger_event,delete $.trigger,$.display_trigger=!0;let _=ct.findIndex(D=>D.id===$.id);if(_===-1)dt.saveCampaigns([$,...ct]);else{let D=ct[_];if(!!(D.trigger_event??D.trigger)){let Y=[...ct];Y[_]=$,dt.saveCampaigns(Y)}}return}}catch{}window.open(S.link,"_blank")};return a?ta("div",{style:lt,onPointerDown:Z,children:[_n("video",{ref:h,src:a,autoPlay:!0,loop:!0,playsInline:!0,muted:u,style:{width:"100%",height:"100%",objectFit:l?"contain":"cover",cursor:G&&!l||S.link?"pointer":"default"},onClick:()=>{if(E.current){E.current=!1;return}if(G){rt();return}gt()},onEnded:()=>{X&&st("analyze",X.id)}}),_n(Qi,{styling:V,mode:l?"LARGE":"SMALL",muted:!u,expanded:l,onClose:()=>c(!0),onToggleMute:()=>m(Q=>!Q),onToggleExpand:rt,containerStyle:l?{paddingTop:"env(safe-area-inset-top, 0px)",paddingLeft:"env(safe-area-inset-left, 0px)",paddingRight:"env(safe-area-inset-right, 0px)"}:void 0}),l&&H&&_n("button",{"data-control-button":"true",onClick:gt,style:{position:"absolute",left:A.left??12,right:A.right??12,bottom:`calc(${A.bottom??12}px + env(safe-area-inset-bottom, 0px))`,height:B.height||42,width:B.ctaFullWidth?"auto":B.ctaWidth||"auto",maxWidth:`calc(100% - ${(A.left??12)+(A.right??12)}px)`,margin:B.ctaFullWidth?"0":"0 auto",background:B.backgroundColor||"#F7921C",color:K.color||"#fff",border:`${B.borderWidth||0}px solid ${B.borderColor||"transparent"}`,borderTopLeftRadius:typeof v=="number"?v:v?.topLeft??10,borderTopRightRadius:typeof v=="number"?v:v?.topRight??10,borderBottomRightRadius:typeof v=="number"?v:v?.bottomRight??10,borderBottomLeftRadius:typeof v=="number"?v:v?.bottomLeft??10,fontSize:K.fontSize||14,fontFamily:ut(K.fontFamily),fontWeight:600,cursor:S.link?"pointer":"default"},children:S.button_text})]}):null};import ea,{useEffect as Wn,useRef as Dn,useState as Io}from"react";import{LottiePlayer as oa}from"lottie-react";vt();Vt();import{jsx as to}from"react/jsx-runtime";var ae=(t,e=0)=>{let o=Number(t);return Number.isFinite(o)?o:e},$n=t=>(t||"").trim().toLowerCase(),na="appstorysmediabucketdev.s3.ap-south-1.amazonaws.com",ia=t=>{try{if(typeof window>"u")return[t];let e=new URL(t);if(e.hostname!==na)return[t];let o=!!window.location.port,n=`/appstorys-media${e.pathname}${e.search}`;return o?[n,t]:[t]}catch{return[t]}},ra=t=>{if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return Array.isArray(e.layers)||Array.isArray(e.assets)||typeof e.v=="string"},Nn=class extends ea.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(){this.props.onError()}render(){return this.state.hasError?null:this.props.children}},sa=()=>{let[t,e]=Io(null),[o,n]=Io([]),[i,s]=Io(!1),[d,c]=Io(!1),[l,y]=Io(!1),u=Dn(null),m=Dn(null),f=Mt("FLT"),P=W(v=>v.campaigns),g=W(v=>v.allCampaigns),b=W(v=>v.currentScreen),R=W(v=>v.userId),C=W(v=>v.isVisible),h=Dn(null),T=f??(()=>{let v=[...P,...g].filter(it=>{let at=it;if(at.campaign_type!=="FLT"||!Ot(at,R))return!1;let a=!!(at.trigger_event??at.trigger);return at.display_trigger===!1||a?!1:!$n(at.screen)||$n(at.screen)===$n(b)});if(v.length===0)return;let H=Lt(v)[0];if(H)try{return Kt(H)}catch{return H}})(),E=T?.id,X=W(v=>E?v.variantMappings[E]:void 0);if(Wn(()=>{if(!T?.id||!C||Ho(T)&&!X)return;let A=`${T.id}:${X||""}`;h.current!==A&&(h.current=A,st("viewed",T.id))},[T?.id,X,C]),Wn(()=>{let v=T?.details?.lottie_data;if(e(null),n([]),s(!1),c(!1),!v)return;if(ra(v)){e(v),c(!0);return}if(typeof v!="string"){s(!0);return}let A=ia(v);n(A),c(!0)},[T?.details?.lottie_data]),Wn(()=>{if(!T?.details?.lottie_data||!u.current)return;let v=oa;if(!v||typeof v.loadAnimation!="function"){s(!0),c(!1);return}let A=!1,H=null,it=()=>{H&&typeof H.destroy=="function"&&H.destroy(),H=null,m.current=null},at=(a,F)=>{if(A)return;if(F>=a.length){s(!0),c(!1),console.error("[Floater] lottie load failed",{lottieUrls:a});return}it();let r=v.loadAnimation({container:u.current,renderer:"svg",loop:!0,autoplay:!0,path:a[F]});H=r,m.current=r,r.addEventListener("DOMLoaded",()=>{A||c(!1)}),r.addEventListener("data_failed",()=>{A||at(a,F+1)})};if(t){it();let a=v.loadAnimation({container:u.current,renderer:"svg",loop:!0,autoplay:!0,animationData:t});H=a,m.current=a,a.addEventListener("DOMLoaded",()=>{A||c(!1)}),a.addEventListener("data_failed",()=>{A||(s(!0),c(!1))})}else o.length>0&&at(o,0);return()=>{A=!0,it()}},[T?.details?.lottie_data,t,o]),!T||!T.details||!C)return null;let{details:I}=T,S=I.styling||{},x=(typeof I.position=="string"?I.position:typeof T.position=="string"?T.position:"right").toLowerCase()==="left"?"left":"right",N={position:"fixed",left:x==="left"?ae(S.marginLeft,12):void 0,right:x==="left"?void 0:ae(S.marginRight,12),top:ae(S.marginTop,0)>0?ae(S.marginTop,0):void 0,bottom:ae(S.marginTop,0)>0?void 0:ae(S.marginBottom,80),zIndex:Et(T,"FLT"),display:"flex"},U={width:ae(I.width,60),height:ae(I.height,60),background:"transparent",overflow:"hidden",borderBottomLeftRadius:ae(S.bottomLeftRadius,0),borderBottomRightRadius:ae(S.bottomRightRadius,0),borderTopLeftRadius:ae(S.topLeftRadius,0),borderTopRightRadius:ae(S.topRightRadius,0),display:"flex",alignItems:"center",justifyContent:"center",cursor:I.link?"pointer":"default",boxShadow:"0 8px 18px rgba(0,0,0,0.2)"},z=async()=>{if(!I.link)return;await st("clicked",T.id);let v=String(I.link).trim();if(wt(v)){y(!0),st("floater_closed",T.id);return}try{let A=W.getState(),H=A.allCampaigns||[],it=A.campaigns||[],at=H.find(a=>{if(!a)return!1;let F=String(a.id||"").trim(),r=a.details||{},p=String(r.campaign||r.id||"").trim();return!!(F&&F===v||p&&p===v||F&&v.includes(F)||p&&v.includes(p))});if(console.log("[Floater] clicked link=",v,"allCampaignsCount=",H.length,"visibleCount=",it.length),console.log("[Floater] all ids=",H.map(a=>a.id).slice(0,50)),console.log("[Floater] referenced found=",!!at,at&&(at.id||at.details?.campaign||at.details?.id)),at){let a={...at};delete a.trigger_event,delete a.trigger,a.display_trigger=!0;let F=it.findIndex(r=>r.id===a.id);if(F===-1)console.log("[Floater] revealing campaign (prepended)",a.id),A.saveCampaigns([a,...it]);else{let r=it[F];if(!!(r.trigger_event??r.trigger)){let j=[...it];j[F]=a,console.log("[Floater] replacing existing triggered campaign with revealed one",a.id),A.saveCampaigns(j)}else console.log("[Floater] campaign already visible and not trigger-driven",a.id)}return}}catch(A){console.warn("[Floater] error while resolving referenced campaign",A)}try{window.open(I.link,"_blank")}catch{}},O=!!(I.lottie_data&&!i),B=!!I.image,K=!!(I.lottie_data&&d&&!t&&!i);return l||!O&&!B&&!K?null:to("div",{style:N,children:to("div",{style:U,onClick:()=>{z()},children:O?to(Nn,{onError:()=>s(!0),children:to("div",{ref:u,style:{width:"100%",height:"100%",display:"block"}})},String(I.lottie_data)):K?to("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.08)",color:"#333",fontSize:10,fontWeight:600},children:"..."}):to("img",{src:I.image,alt:"floater",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})})})},aa=sa;vt();Vt();function er(t){return(t||"").trim().toLowerCase()}function On(t,e){let o=er(t.screen),n=er(e);return!o||o===n}async function jn(t){try{let e=W.getState(),o=await Pt(),n=e.accountId,i=le();if(!o||!n)return;e.setCurrentScreen(t),e.setTrackedEvents([]);let s=e.baseUrl||"https://users.appstorys.co",d=await fetch(`${s}/v2/${n}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({user_id:i,screenName:t})});if(!d.ok)return;let c=await d.json();if(typeof c.screen_capture_enabled<"u"&&e.setScreenCaptureEnabled(!!c.screen_capture_enabled),c.variants&&c.variants.length>0){let T={};c.variants.forEach(E=>{T[E.id]=E.v_id}),e.setVariantMappings(T)}c.personalization_data&&e.setPersonalizationData(c.personalization_data);let l=(e.allCampaigns||[]).filter(T=>Ot(T,i)),y=c.eligibleCampaignList||[],u=l.filter(T=>y.includes(T.id)&&On(T,t)),m=u.map(T=>T.id),f=y.filter(T=>!m.includes(T)),P=[];if(f.length>0){let T=await fetch(`${s}/load-campaign-data`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(f)});T.ok&&(P=(await T.json()).filter(X=>On(X,t)&&Ot(X,i)))}let g=[...u,...P],b=l.filter(T=>{let E=!!(T.trigger_event??T.trigger);return On(T,t)&&T.display_trigger===!0&&!E}),R=[...g],C=new Set(R.map(T=>T.id));for(let T of b)C.has(T.id)||(R.push(T),C.add(T.id));let h=Lt(R);e.saveCampaigns(h)}catch(e){console.error("Error when tracking screen:",t,e)}}Go();vt();Yo();async function qn(t){try{let e=await Pt(),o=le(),n=W.getState();if(!e||!o){console.warn("AppStorys: Missing accessToken or userId. Ensure SDK is initialized before setting user properties.");return}let i={...t||{}},s=await Ue();i={...i,...s};let d={user_id:o,attributes:i},c=n.baseUrl||"https://users.appstorys.co";await Xo({url:`${c}/update-user-atr`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:d})}catch(e){console.error("AppStorys: Error in setUserProperties:",e)}}vt();function Le(t){if(!t||t.trim()==="")return t;let e=W.getState().personalizationData;if(!e||Object.keys(e).length===0)return la(t);let o=/\{\{([^|}\s]+)\s*\|\s*([^}]+)\}\}/g;return t.replace(o,(n,i,s)=>{let d=i.trim(),c=s.trim();return e[d]??c})}function la(t){let e=/\{\{[^|}\s]+\s*\|\s*([^}]+)\}\}/g;return t.replace(e,(o,n)=>n.trim())}Ke();vt();vt();Vt();var Un="appstorys_campaigns_cache",or="appstorys_campaigns_etag",Hn="appstorys_campaigns_version";async function Vn(t,e){try{let o=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),n=`https://dev-cdn-campaign-appstorys.s3.ap-south-1.amazonaws.com/clients/${t}/campaigns.json`,i=await Tt.getItem(Un),s=await Tt.getItem(or),d=await Tt.getItem(Hn),c={Accept:"application/json"};!o&&s&&(c["If-None-Match"]=s);let l=await fetch(n,{method:"GET",headers:c,...o?{cache:"no-store"}:{}});if(l.status===304)return{campaigns:i?Lt(JSON.parse(i)):[],version:d?parseInt(d):1};let y=l.headers.get("ETag"),u=await l.json(),m=2,f=u,P=e;if(!P)try{let g=await Pt(),b=le(),R=W.getState().baseUrl||"https://users.appstorys.co",C=await fetch(`${R}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...g?{Authorization:`Bearer ${g}`}:{}},body:JSON.stringify({user_id:b,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(C.ok){let h=await C.json();console.info("AppStorys: fetchAllCampaigns track-user-res returned",h);let T=h?.screenName||h?.screen||h?.currentScreen||h?.screen_name||h?.current_screen;T&&(P=T);try{let E=W.getState();typeof h.screen_capture_enabled<"u"&&E.setScreenCaptureEnabled(!!h.screen_capture_enabled)}catch{}}}catch(g){console.warn("Could not fetch screen name from track-user-res:",g)}if(u.length>0&&u[0].version!==void 0&&(m=u[0].version,f=u.slice(1)),!f||f.length===0)try{let g=await Pt(),b=le(),R=W.getState().baseUrl||"https://users.appstorys.co",C=await fetch(`${R}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...g?{Authorization:`Bearer ${g}`}:{}},body:JSON.stringify({user_id:b,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(C.ok){let h=await C.json(),T=h?.user_id||h?.id||h?.userId||b;try{let E=W.getState();typeof h.screen_capture_enabled<"u"&&E.setScreenCaptureEnabled(!!h.screen_capture_enabled)}catch{}if(T){let E=`${R}/load-campaign-data`,X=await fetch(E,{method:"POST",headers:{"Content-Type":"application/json",...g?{Authorization:`Bearer ${g}`}:{}},body:JSON.stringify({user_id:T})});if(X.ok){let I=await X.json();console.log(`Fetched ${I.length} missing campaigns from fallback`),console.log("Fallback campaigns:",JSON.stringify(I,null,2)),I&&I.length>0&&(f=I)}else console.error("Failed to fetch missing campaigns:",await X.text())}}}catch(g){console.error("Error fetching missing campaigns via fallback:",g)}if(e&&f&&f.length>0){let g=R=>(R||"").trim().toLowerCase(),b=g(e);f=f.filter(R=>!g(R.screen)||g(R.screen)===b)}return f=Lt(f),await Tt.setItem(Un,JSON.stringify(f)),await Tt.setItem(Hn,m.toString()),y&&await Tt.setItem(or,y),{campaigns:f,version:m}}catch(o){console.error("Error fetching campaigns:",o);let n=await Tt.getItem(Un),i=await Tt.getItem(Hn);return{campaigns:n?JSON.parse(n):[],version:i?parseInt(i):1}}}vt();vt();vt();async function rn(t,e){try{let o=await Pt(),n=W.getState();if(!o)return console.error("AppStorys: Access token not found for reconciliation"),!1;let i={anonymous_user_id:t,identified_user_id:e},s=n.baseUrl||"https://users.appstorys.co",d=await fetch(`${s}/reconcile-anonymous-user`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(i)});if(d.ok)return!0;{let c=await d.text();return console.error("AppStorys: Failed to reconcile anonymous user:",d.status,c),!1}}catch(o){return console.error("AppStorys: Error in reconcileAnonymousUser:",o),!1}}vt();var Yn=class{isInitialized=!1;setup(){this.isInitialized||typeof window>"u"||(document.addEventListener("mouseleave",this.handleMouseLeave),window.addEventListener("popstate",this.handlePopState),window.history.state!=="appstorys_navigation"&&window.history.pushState("appstorys_navigation",""),this.isInitialized=!0)}destroy(){!this.isInitialized||typeof window>"u"||(document.removeEventListener("mouseleave",this.handleMouseLeave),window.removeEventListener("popstate",this.handlePopState),this.isInitialized=!1)}handleMouseLeave=e=>{e.clientY<=0&&An()&&this.triggerCampaign()};handlePopState=()=>{An()&&(window.history.pushState("appstorys_navigation",""),this.triggerCampaign())};triggerCampaign(){let e=W.getState(),{trackedEvents:o}=e;o.includes(Vo)||(console.log("AppStorys: Exit Intent triggered. Displaying campaign."),e.setTrackedEvents([...o,Vo]))}},nr=new Yn;vt();var Gn=class{isInitialized=!1;setup(){this.isInitialized||typeof document>"u"||(document.addEventListener("visibilitychange",this.handleVisibilityChange),this.updateVisibility(document.visibilityState==="visible"),this.isInitialized=!0)}destroy(){!this.isInitialized||typeof document>"u"||(document.removeEventListener("visibilitychange",this.handleVisibilityChange),this.isInitialized=!1)}handleVisibilityChange=()=>{this.updateVisibility(document.visibilityState==="visible")};updateVisibility(e){let o=W.getState();o.isVisible!==e&&(console.log(`AppStorys: SDK visibility changed to ${e?"visible":"hidden"}`),o.setVisibility(e))}},Qn=new Gn;Ke();var sn="anonymous_user_id";async function ir(){let t=Date.now(),e=navigator.userAgent.split(" ")[0].replace(/[^a-zA-Z0-9]/g,"_");return`${t}_${e}`}async function rr(){try{let t=await Tt.getItem(sn);if(t)return t;let e=await ir();return await Tt.setItem(sn,e),e}catch(t){return console.error("Error managing anonymous user ID:",t),await ir()}}async function Jn(){try{await Tt.removeItem(sn)}catch(t){console.error("Error clearing anonymous user ID:",t)}}async function Xn(){try{return await Tt.getItem(sn)}catch(t){return console.error("Error getting stored anonymous user ID:",t),null}}function da(){if(document.getElementById("appstorys-widget-debug-styles"))return;let t=document.createElement("style");t.id="appstorys-widget-debug-styles",t.innerHTML=`
15
15
  .appstorys-widget-debug-pill {
16
16
  position: absolute;
17
17
  top: 8px;
@@ -30,12 +30,12 @@ var ls=Object.defineProperty;var Me=(t,e)=>()=>(t&&(e=t(t=0)),e);var ds=(t,e)=>{
30
30
  outline: 3px dashed rgba(255,122,24,0.85);
31
31
  outline-offset: 6px;
32
32
  }
33
- `,document.head.appendChild(t)}function Yi(t){let e=document.createElement("div");return e.className="appstorys-widget-debug-pill",e.textContent=t,e}function qs(t){let e=t,o=getComputedStyle(e);(o.position==="static"||!o.position)&&(e.style.position="relative")}window.AppStorysShowWidgetElements=function(){try{js();let e=Array.from(document.querySelectorAll("[data-as-id], [data-widget], [data-widget-id]"));if(e.length||["#hero_section",".hero_section","#header_container",".header_container"].forEach(n=>{let i=document.querySelector(n);i&&e.push(i)}),!e.length){let o=Yi("Widget");o.style.position="fixed",o.style.top="12px",o.style.left="12px",o.style.pointerEvents="auto",document.body.appendChild(o);return}e.forEach((o,n)=>{let i=o;qs(i),i.classList.add("appstorys-widget-debug-overlay");let s=i.querySelector(".appstorys-widget-debug-pill");s&&s.remove();let l=Yi("Widget "+(n+1));i.appendChild(l)})}catch(e){console.error("AppStorysShowWidgetElements error",e)}};yt();import Fa,{useState as Dr,useEffect as ei}from"react";import{useEffect as Hs,useState as Gi}from"react";import*as He from"lottie-react";import{jsx as Xi}from"react/jsx-runtime";var Qi=He.default?.default??He.default??He.Lottie??He,de=({src:t,alt:e,style:o,size:n})=>{let[i,s]=Gi(null),[l,c]=Gi(!1);Hs(()=>{t&&t.toLowerCase().endsWith(".json")?fetch(t).then(y=>{if(!y.ok)throw new Error("Failed to fetch Lottie");return y.json()}).then(y=>{s(y),c(!1)}).catch(y=>{console.error("AppStorys: Error loading Lottie thumbnail:",y),c(!0)}):(s(null),c(!1))},[t]);let d={width:n?`${n}px`:o?.width||"100%",height:n?`${n}px`:o?.height||"100%",objectFit:"cover",display:"block",...o},S=o?.objectFit||"cover",p=S==="contain"?"xMidYMid meet":S==="fill"?"none":"xMidYMid slice";if(i&&!l){let y=Qi.default||Qi;return Xi(y,{animationData:i,loop:!0,autoplay:!0,style:d,rendererSettings:{preserveAspectRatio:p}})}return Xi("img",{src:t,alt:e||"story thumbnail",style:d,onError:()=>c(!0)})};import{jsx as $n,jsxs as Vs}from"react/jsx-runtime";var Ji=({story:t,isViewed:e,onClick:o})=>{let n=t.styling||{},i=n.size||80,s=n.ringWidth!==void 0?n.ringWidth:3,l=n.ringAndImageSpace!==void 0?n.ringAndImageSpace:3,c=e?"#E5E7EB":t.ringColor||"#FF0000",d=t.nameColor||"#333333",S=n.storyGroupText||t.name,p=n.cornerRadius,y=p?`${p.topLeft||0}px ${p.topRight||0}px ${p.bottomRight||0}px ${p.bottomLeft||0}px`:"50%",u=p?`${Math.max(0,(p.topLeft||0)-s)}px ${Math.max(0,(p.topRight||0)-s)}px ${Math.max(0,(p.bottomRight||0)-s)}px ${Math.max(0,(p.bottomLeft||0)-s)}px`:"50%",h=st(n.name?.fontFamily||n.name?.font)||n.name?.fontFamily||(n.name?.font&&n.name.font!=="Bold"&&n.name.font!=="Normal"?n.name.font:void 0)||"sans-serif",g=n.name?.font==="Bold"||n.name?.font==="bold"||n.name?.font?.toLowerCase()?.includes("bold");return Vs("div",{onClick:o,style:{display:"flex",flexDirection:"column",alignItems:"center",cursor:"pointer",flexShrink:0},children:[$n("div",{style:{width:`${i}px`,height:`${i}px`,borderRadius:y,border:`${s}px solid ${c}`,padding:`${l}px`,boxSizing:"border-box",transition:"transform 0.1s ease",overflow:"hidden",backgroundColor:"#f5f5f5"},children:$n(de,{src:t.thumbnail,alt:S,style:{borderRadius:u}})}),$n("span",{style:{marginTop:"6px",fontSize:`${n.name?.size||12}px`,fontFamily:h,fontWeight:g?"bold":"normal",color:d,maxWidth:`${i+20}px`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textAlign:"center"},children:S})]})};import{jsx as Ki}from"react/jsx-runtime";var Zi=({stories:t,viewedStories:e,onStoryClick:o})=>Ki("div",{style:{display:"flex",gap:"18px",padding:"16px 20px",overflowX:"auto",WebkitOverflowScrolling:"touch",justifyContent:"flex-start"},children:t.sort((n,i)=>n.order-i.order).map((n,i)=>Ki(Ji,{story:n,isViewed:e.includes(n.id),onClick:()=>o(i)},n.id))});import Er,{useState as Ot,useEffect as Re,useRef as Co}from"react";yt();yt();var tr=()=>P.getState().trackingUrl||"https://tracking.appstorys.co";import{useState as vr,useEffect as da}from"react";import*as Ye from"lottie-react";var tt=t=>{if(t){if(typeof t=="string")return t;if(typeof t=="object"){if(typeof t.color=="string")return t.color;if(typeof t.color=="object"&&t.color){let e=tt(t.color);if(e)return e}if(typeof t.solid=="string"&&t.solid)return t.solid;if(typeof t.value=="string"&&t.value)return t.value;if(typeof t.hex=="string"&&t.hex)return t.hex}}},St=t=>{if(!t)return;if(typeof t=="string")return t;if(typeof t=="object"){if(typeof t.solid=="string"&&t.solid)return t.solid;if(typeof t.value=="string"&&t.value)return t.value;if(typeof t.color=="string"&&t.color)return t.color}let e=t.color||{};if(typeof e=="object"&&e&&e.type==="gradient"&&e.gradient){let{direction:o="right",from:n,to:i,stops:s=[]}=e.gradient,c={right:"to right",left:"to left",top:"to top",bottom:"to bottom"}[o]||o;if(s.length>0){let d=s.map(S=>{let p=S.offset,y="0%";if(p!=null){let u=String(p).trim();if(u.endsWith("%"))y=u;else{let C=Number(u);isNaN(C)||(y=C>1?`${C}%`:`${Math.round(C*100)}%`)}}return`${S.color} ${y}`}).join(", ");return`linear-gradient(${c}, ${d})`}return`linear-gradient(${c}, ${n}, ${i})`}return tt(t)},mo=t=>{if(!t||t.type==="none")return;let e=String(t.type).toLowerCase(),o=t.duration||.6;if(e==="fade")return`appstorys-fade-in ${o}s ease-out forwards`;if(e==="classic")return`appstorys-classic-in ${o}s cubic-bezier(0.34, 1.56, 0.64, 1) forwards`;if(e==="rotate")return`appstorys-rotate-in ${o}s ease-out forwards`;if(e==="bounce")return`appstorys-bounce-in ${o+.2}s cubic-bezier(0.68, -0.6, 0.32, 1.6) forwards`},ot=(t,e="px")=>{if(t==null||t==="")return"";let o=String(t).trim();return/^[\d.-]+$/.test(o)?`${o}${e}`:o},Ve=t=>{if(!t||typeof t!="string")return"center center";let e=t.trim().toLowerCase().replace(/_/g,"-");switch(e){case"top-left":case"left-top":return"top left";case"top-center":case"center-top":case"top":return"top center";case"top-right":case"right-top":return"top right";case"center-left":case"left-center":case"left":return"center left";case"center":case"center-center":return"center center";case"center-right":case"right-center":case"right":return"center right";case"bottom-left":case"left-bottom":return"bottom left";case"bottom-center":case"center-bottom":case"bottom":return"bottom center";case"bottom-right":case"right-bottom":return"bottom right";default:return e.replace("-"," ")}};import Us from"react";import{jsx as Go,jsxs as Qo}from"react/jsx-runtime";var er=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=Us.useState(()=>{try{return localStorage.getItem(`appstorys_poll_${t.id}`)}catch{return null}}),s=t.layout?.type==="horizontal",l={headerTextColor:"#000000",optionBgColor:"#1A1A1A",optionTextColor:"#FFFFFF",backgroundColor:"#FFFFFF",borderRadius:20,padding:12},c=t.styling||{},d=st(c.questionFontFamily||c.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),S=st(c.optionFontFamily||c.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),p=c.optionBorderRadius??c.optionRadius,y=p!==void 0?ot(p):"9999px",u=c.optionBgColor||"#1A1A1A",C={backgroundColor:c.backgroundColor||l.backgroundColor,borderRadius:ot(c.borderRadius??l.borderRadius),overflow:"hidden",boxShadow:c.shadow||"0 12px 24px rgba(0,0,0,0.1)",boxSizing:"border-box",width:"100%",maxWidth:"280px",margin:"0 auto",opacity:c.opacity??1,padding:"14px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"10px"},h={color:c.headerTextColor||l.headerTextColor,textAlign:"center",fontWeight:"700",fontSize:ot(c.fontSize||14),lineHeight:"1.25",margin:"0",width:"100%",fontFamily:d},g={display:"flex",flexDirection:s?"row":"column",gap:s?n?"0px":"4px":ot(c.gap??8),width:"100%",backgroundColor:s?u:"transparent",borderRadius:s?ot(y):"0px",overflow:s?"hidden":"visible",padding:"0px"},b={backgroundColor:s?"transparent":u,color:c.optionTextColor||l.optionTextColor,padding:s?"8px 12px":"10px 16px",fontSize:ot(c.optionFontSize||14),fontWeight:"700",fontFamily:S,cursor:n?"default":"pointer",border:"none",borderRadius:s?"0px":ot(y),width:"100%",textAlign:"center",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)",flex:s?1:void 0,borderRight:s?"1px solid rgba(255,255,255,0.1)":"none",borderBottom:"none",position:"relative",overflow:"hidden"},m=Array.isArray(t.options)?t.options:[],E=v=>{let w=m.find(_=>_.id===v);if(!w)return 0;if(w.percentage!==void 0)return w.percentage;if(w.votes!==void 0){let _=m.reduce(($,V)=>$+(V.votes||0),0);if(_>0)return Math.round(w.votes/_*100)}return n?v===n?m.length===1?100:60:Math.round(40/(m.length-1)):0},O=(v,w)=>{let _=v.replace("#","");_.length===3&&(_=_.split("").map(T=>T+T).join(""));let $=parseInt(_.substring(0,2),16)||0,V=parseInt(_.substring(2,4),16)||0,A=parseInt(_.substring(4,6),16)||0;return`rgba(${$}, ${V}, ${A}, ${w})`},D=v=>{let w=v===n,_=w?c.activeResultBarColor:c.inactiveResultBarColor,$=_?.color||(w?"#F97316":"#404040"),V=_?.opacity!==void 0?_.opacity/100:1;return $.startsWith("#")&&($.length===7||$.length===4)?O($,V):$},L=v=>{if(!(o||n)){i(v);try{localStorage.setItem(`appstorys_poll_${t.id}`,v)}catch{}e?.({type:"poll",pollId:t.id,optionId:v,stickerId:t.id})}};return Qo("div",{style:C,children:[Go("h3",{style:h,children:t.question||"Ask A Question..."}),Go("div",{style:g,children:m.map((v,w)=>{let _=E(v.id),$=n!==null,V=v.id===n,A=$?s?D(v.id):u:s?"transparent":u;return Qo("button",{style:{...b,flex:$&&s?_:s?1:void 0,backgroundColor:A,borderRight:$||s&&w===m.length-1?"none":b.borderRight},onClick:()=>L(v.id),disabled:$,onMouseOver:T=>{!o&&!$&&!s&&(T.currentTarget.style.opacity="0.9")},onMouseOut:T=>{!o&&!$&&!s&&(T.currentTarget.style.opacity="1")},children:[$&&!s&&Go("div",{style:{position:"absolute",top:0,left:0,bottom:0,width:`${_}%`,backgroundColor:D(v.id),transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)",zIndex:1,borderRadius:"inherit"}}),Qo("div",{style:{display:"flex",flexDirection:s?"column":"row",justifyContent:s?"center":"space-between",alignItems:"center",width:"100%",zIndex:2,position:"relative"},children:[Go("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.text}),$&&Qo("span",{style:{fontWeight:"800",fontSize:s?"12px":"15px",marginTop:s?"4px":"0"},children:[_,"%"]})]})]},v.id)})})]})};import{useState as Ys}from"react";import{jsx as ce,jsxs as Ue}from"react/jsx-runtime";var or=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=Ys(()=>{try{return localStorage.getItem(`appstorys_quiz_${t.id}`)}catch{return null}}),s={backgroundColor:"#FFFFFF",borderRadius:28,padding:16,questionTextColor:"#FFFFFF",questionBgColor:"#000000",optionBgColor:"#F8FAFC",optionTextColor:"#1E293B",borderColor:"#000000",activeColor:"#10b981",incorrectColor:"#ef4444",labelBgColor:"#FFFFFF",labelTextColor:"#111111",labelBorderColor:"#111111"},l=t.styling||{},c=ot(l.padding??s.padding),d=ot(l.fontSize||16),S=ot(l.optionFontSize||15),p=l.optionBorderRadius!==void 0?ot(l.optionBorderRadius):"9999px",y=l.optionBorderColor||"#CBD5E1",u=st(l.questionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),C=st(l.optionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),h={backgroundColor:l.backgroundColor||s.backgroundColor,borderRadius:ot(l.borderRadius??s.borderRadius),padding:0,boxShadow:l.shadow||"0 12px 32px rgba(0,0,0,0.14)",boxSizing:"border-box",width:"100%",maxWidth:"270px",margin:"0 auto",display:"flex",flexDirection:"column",overflow:"hidden",opacity:l.opacity??1},g={color:l.questionTextColor||s.questionTextColor,backgroundColor:l.questionBgColor||s.questionBgColor,fontWeight:"700",fontSize:d,fontFamily:u,lineHeight:1.3,margin:0,textAlign:"center",padding:"14px 16px",minHeight:"48px",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",borderTopLeftRadius:ot(l.borderRadius??s.borderRadius),borderTopRightRadius:ot(l.borderRadius??s.borderRadius),letterSpacing:"-0.01em"},b={backgroundColor:l.optionBgColor||s.optionBgColor,color:l.optionTextColor||s.optionTextColor,fontFamily:C,padding:"8px 14px",borderRadius:p,border:`1px solid ${y}`,display:"flex",alignItems:"center",justifyContent:"flex-start",cursor:n?"default":"pointer",width:"100%",textAlign:"left",boxSizing:"border-box",transition:"all 0.2s ease",fontSize:S,fontWeight:"500"},m={backgroundColor:l.backgroundColor||s.backgroundColor,borderRadius:`0 0 ${ot(l.borderRadius??s.borderRadius)} ${ot(l.borderRadius??s.borderRadius)}`,display:"flex",flexDirection:"column",gap:"6px",padding:"10px 14px 12px 14px"},E=_=>{if(!(o||n)){i(_);try{localStorage.setItem(`appstorys_quiz_${t.id}`,_)}catch{}e?.({type:"quiz",quizId:t.id,optionId:_,stickerId:t.id})}},O=["A","B","C","D","E","F"],D=Array.isArray(t.options)?t.options:[];D.length===0&&!o&&console.warn("AppStorys: QuizSticker has no options!",t.id);let L=D.find(_=>_.id===n),v=L?L.isCorrect===!0:!1,w=!!n&&t.showExplanation!==!1&&!!t.explanation;return Ue("div",{style:{...h,background:l.backgroundColor||s.backgroundColor},children:[ce("style",{children:`
33
+ `,document.head.appendChild(t)}function sr(t){let e=document.createElement("div");return e.className="appstorys-widget-debug-pill",e.textContent=t,e}function ca(t){let e=t,o=getComputedStyle(e);(o.position==="static"||!o.position)&&(e.style.position="relative")}window.AppStorysShowWidgetElements=function(){try{da();let e=Array.from(document.querySelectorAll("[data-as-id], [data-widget], [data-widget-id]"));if(e.length||["#hero_section",".hero_section","#header_container",".header_container"].forEach(n=>{let i=document.querySelector(n);i&&e.push(i)}),!e.length){let o=sr("Widget");o.style.position="fixed",o.style.top="12px",o.style.left="12px",o.style.pointerEvents="auto",document.body.appendChild(o);return}e.forEach((o,n)=>{let i=o;ca(i),i.classList.add("appstorys-widget-debug-overlay");let s=i.querySelector(".appstorys-widget-debug-pill");s&&s.remove();let d=sr("Widget "+(n+1));i.appendChild(d)})}catch(e){console.error("AppStorysShowWidgetElements error",e)}};vt();import Ga,{useState as Jr,useEffect as fi}from"react";import{useEffect as ua,useState as ar}from"react";import*as eo from"lottie-react";import{jsx as dr}from"react/jsx-runtime";var lr=eo.default?.default??eo.default??eo.Lottie??eo,ye=({src:t,alt:e,style:o,size:n})=>{let[i,s]=ar(null),[d,c]=ar(!1);ua(()=>{t&&t.toLowerCase().endsWith(".json")?fetch(t).then(m=>{if(!m.ok)throw new Error("Failed to fetch Lottie");return m.json()}).then(m=>{s(m),c(!1)}).catch(m=>{console.error("AppStorys: Error loading Lottie thumbnail:",m),c(!0)}):(s(null),c(!1))},[t]);let l={width:n?`${n}px`:o?.width||"100%",height:n?`${n}px`:o?.height||"100%",objectFit:"contain",display:"block",...o},y=o?.objectFit||"contain",u=y==="contain"?"xMidYMid meet":y==="fill"?"none":"xMidYMid slice";if(i&&!d){let m=lr.default||lr;return dr(m,{animationData:i,loop:!0,autoplay:!0,style:l,rendererSettings:{preserveAspectRatio:u}})}return dr("img",{src:t,alt:e||"story thumbnail",style:l,onError:()=>c(!0)})};import{jsx as Kn,jsxs as pa}from"react/jsx-runtime";var cr=({story:t,isViewed:e,onClick:o})=>{let n=t.styling||{},i=n.size||80,s=n.ringWidth!==void 0?n.ringWidth:3,d=n.ringAndImageSpace!==void 0?n.ringAndImageSpace:3,c=e?"#E5E7EB":t.ringColor||"#FF0000",l=t.nameColor||"#333333",y=n.storyGroupText||t.name,u=n.cornerRadius,m=u?`${u.topLeft||0}px ${u.topRight||0}px ${u.bottomRight||0}px ${u.bottomLeft||0}px`:"50%",f=u?`${Math.max(0,(u.topLeft||0)-s)}px ${Math.max(0,(u.topRight||0)-s)}px ${Math.max(0,(u.bottomRight||0)-s)}px ${Math.max(0,(u.bottomLeft||0)-s)}px`:"50%",g=ut(n.name?.fontFamily||n.name?.font)||n.name?.fontFamily||(n.name?.font&&n.name.font!=="Bold"&&n.name.font!=="Normal"?n.name.font:void 0)||"sans-serif",b=n.name?.font==="Bold"||n.name?.font==="bold"||n.name?.font?.toLowerCase()?.includes("bold");return pa("div",{onClick:o,style:{display:"flex",flexDirection:"column",alignItems:"center",cursor:"pointer",flexShrink:0},children:[Kn("div",{style:{width:`${i}px`,height:`${i}px`,borderRadius:m,border:`${s}px solid ${c}`,padding:`${d}px`,boxSizing:"border-box",transition:"transform 0.1s ease",overflow:"hidden",backgroundColor:"#f5f5f5"},children:Kn(ye,{src:t.thumbnail,alt:y,style:{borderRadius:f}})}),Kn("span",{style:{marginTop:"6px",fontSize:`${n.name?.size||12}px`,fontFamily:g,fontWeight:b?"bold":"normal",color:l,maxWidth:`${i+20}px`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textAlign:"center"},children:y})]})};import{jsx as ur}from"react/jsx-runtime";var pr=({stories:t,viewedStories:e,onStoryClick:o})=>ur("div",{style:{display:"flex",gap:"18px",padding:"16px 20px",overflowX:"auto",WebkitOverflowScrolling:"touch",justifyContent:"flex-start"},children:t.sort((n,i)=>n.order-i.order).map((n,i)=>ur(cr,{story:n,isViewed:e.includes(n.id),onClick:()=>o(i)},n.id))});import Vr,{useState as Yt,useEffect as Te,useRef as be}from"react";vt();vt();var gr=()=>W.getState().trackingUrl||"https://tracking.appstorys.co";import Mr,{useState as _r,useEffect as Ba}from"react";import*as io from"lottie-react";var an=(t,e)=>{if(!t||e===void 0||e===null||e==="")return t;let o=Number(e);if(isNaN(o))return t;let n=o>1?Math.min(Math.max(o/100,0),1):Math.min(Math.max(o,0),1),i=t.trim();if(i.startsWith("#")){let d=i.slice(1);if(d.length===3&&(d=d.split("").map(c=>c+c).join("")),d.length===6||d.length===8){let c=parseInt(d.slice(0,2),16),l=parseInt(d.slice(2,4),16),y=parseInt(d.slice(4,6),16);if(!isNaN(c)&&!isNaN(l)&&!isNaN(y))return`rgba(${c}, ${l}, ${y}, ${n})`}}let s=i.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);return s?`rgba(${s[1]}, ${s[2]}, ${s[3]}, ${n})`:t},et=t=>{if(t){if(typeof t=="string")return t;if(typeof t=="object"){let e,o=t.opacity;if(typeof t.color=="string")e=t.color;else if(typeof t.color=="object"&&t.color){let n=et(t.color);n&&(e=n),o===void 0&&t.color.opacity!==void 0&&(o=t.color.opacity)}else typeof t.solid=="string"&&t.solid?e=t.solid:typeof t.value=="string"&&t.value?e=t.value:typeof t.hex=="string"&&t.hex&&(e=t.hex);if(e)return an(e,o)}}},Ct=t=>{if(!t)return;if(typeof t=="string")return t;if(typeof t=="object"){let o=t.opacity;if(typeof t.solid=="string"&&t.solid)return an(t.solid,o);if(typeof t.value=="string"&&t.value)return an(t.value,o);if(typeof t.color=="string"&&t.color)return an(t.color,o)}let e=t.color||{};if(typeof e=="object"&&e&&e.type==="gradient"&&e.gradient){let{direction:o="right",from:n,to:i,stops:s=[]}=e.gradient,c={right:"to right",left:"to left",top:"to top",bottom:"to bottom"}[o]||o;if(s.length>0){let u=s.map(m=>{let f=m.offset,P="0%";if(f!=null){let b=String(f).trim();if(b.endsWith("%"))P=b;else{let R=Number(b);isNaN(R)||(P=R>1?`${R}%`:`${Math.round(R*100)}%`)}}return`${et(m.color)||m.color} ${P}`}).join(", ");return`linear-gradient(${c}, ${u})`}let l=et(n)||n,y=et(i)||i;return`linear-gradient(${c}, ${l}, ${y})`}return et(t)},zo=t=>{if(!t||t.type==="none")return;let e=String(t.type).toLowerCase(),o=t.duration||.6;if(e==="fade")return`appstorys-fade-in ${o}s ease-out forwards`;if(e==="classic")return`appstorys-classic-in ${o}s cubic-bezier(0.34, 1.56, 0.64, 1) forwards`;if(e==="rotate")return`appstorys-rotate-in ${o}s ease-out forwards`;if(e==="bounce")return`appstorys-bounce-in ${o+.2}s cubic-bezier(0.68, -0.6, 0.32, 1.6) forwards`},nt=(t,e="px")=>{if(t==null||t==="")return"";let o=String(t).trim();return/^[\d.-]+$/.test(o)?`${o}${e}`:o},oo=t=>{if(!t||typeof t!="string")return"center center";let e=t.trim().toLowerCase().replace(/_/g,"-");switch(e){case"top-left":case"left-top":return"top left";case"top-center":case"center-top":case"top":return"top center";case"top-right":case"right-top":return"top right";case"center-left":case"left-center":case"left":return"center left";case"center":case"center-center":return"center center";case"center-right":case"right-center":case"right":return"center right";case"bottom-left":case"left-bottom":return"bottom left";case"bottom-center":case"center-bottom":case"bottom":return"bottom center";case"bottom-right":case"right-bottom":return"bottom right";default:return e.replace("-"," ")}};import ga from"react";import{jsx as ln,jsxs as dn}from"react/jsx-runtime";var fr=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=ga.useState(()=>{try{return localStorage.getItem(`appstorys_poll_${t.id}`)}catch{return null}}),s=t.layout?.type==="horizontal",d={headerTextColor:"#000000",optionBgColor:"#1A1A1A",optionTextColor:"#FFFFFF",backgroundColor:"#FFFFFF",borderRadius:20,padding:12},c=t.styling||{},l=ut(c.questionFontFamily||c.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),y=ut(c.optionFontFamily||c.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),u=c.optionBorderRadius??c.optionRadius,m=u!==void 0?nt(u):"9999px",f=c.optionBgColor||"#1A1A1A",P={backgroundColor:c.backgroundColor||d.backgroundColor,borderRadius:nt(c.borderRadius??d.borderRadius),overflow:"hidden",boxShadow:c.shadow||"0 12px 24px rgba(0,0,0,0.1)",boxSizing:"border-box",width:"100%",maxWidth:"280px",margin:"0 auto",opacity:c.opacity??1,padding:"14px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"10px"},g={color:c.headerTextColor||d.headerTextColor,textAlign:"center",fontWeight:"700",fontSize:nt(c.fontSize||14),lineHeight:"1.25",margin:"0",width:"100%",fontFamily:l},b={display:"flex",flexDirection:s?"row":"column",gap:s?n?"0px":"4px":nt(c.gap??8),width:"100%",backgroundColor:s?f:"transparent",borderRadius:s?nt(m):"0px",overflow:s?"hidden":"visible",padding:"0px"},C=c.optionTextAlign||c.optionFont?.textAlign||c.options?.font?.textAlign||c.options?.textAlign||"center",h=x=>{switch(x){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},T={backgroundColor:s?"transparent":f,color:c.optionTextColor||d.optionTextColor,padding:s?"8px 12px":"10px 16px",fontSize:nt(c.optionFontSize||14),fontWeight:"700",fontFamily:y,cursor:n?"default":"pointer",border:"none",borderRadius:s?"0px":nt(m),width:"100%",textAlign:C||"center",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:h(C),transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)",flex:s?1:void 0,borderRight:s?"1px solid rgba(255,255,255,0.1)":"none",borderBottom:"none",position:"relative",overflow:"hidden"},E=Array.isArray(t.options)?t.options:[],X=x=>{let N=E.find(U=>U.id===x);if(!N)return 0;if(N.percentage!==void 0)return N.percentage;if(N.votes!==void 0){let U=E.reduce((z,O)=>z+(O.votes||0),0);if(U>0)return Math.round(N.votes/U*100)}return n?x===n?E.length===1?100:60:Math.round(40/(E.length-1)):0},I=(x,N)=>{let U=x.replace("#","");U.length===3&&(U=U.split("").map(K=>K+K).join(""));let z=parseInt(U.substring(0,2),16)||0,O=parseInt(U.substring(2,4),16)||0,B=parseInt(U.substring(4,6),16)||0;return`rgba(${z}, ${O}, ${B}, ${N})`},S=x=>{let N=x===n,U=N?c.activeResultBarColor:c.inactiveResultBarColor,z=U?.color||(N?"#F97316":"#404040"),O=U?.opacity!==void 0?U.opacity/100:1;return z.startsWith("#")&&(z.length===7||z.length===4)?I(z,O):z},M=x=>{if(!(o||n)){i(x);try{localStorage.setItem(`appstorys_poll_${t.id}`,x)}catch{}e?.({type:"poll",pollId:t.id,optionId:x,stickerId:t.id})}};return dn("div",{style:P,children:[ln("h3",{style:g,children:t.question||"Ask A Question..."}),ln("div",{style:b,children:E.map((x,N)=>{let U=X(x.id),z=n!==null,O=x.id===n,B=z?s?S(x.id):f:s?"transparent":f;return dn("button",{style:{...T,flex:z&&s?U:s?1:void 0,backgroundColor:B,borderRight:z||s&&N===E.length-1?"none":T.borderRight},onClick:()=>M(x.id),disabled:z,onMouseOver:K=>{!o&&!z&&!s&&(K.currentTarget.style.opacity="0.9")},onMouseOut:K=>{!o&&!z&&!s&&(K.currentTarget.style.opacity="1")},children:[z&&!s&&ln("div",{style:{position:"absolute",top:0,left:0,bottom:0,width:`${U}%`,backgroundColor:S(x.id),transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)",zIndex:1,borderRadius:"inherit"}}),dn("div",{style:{display:"flex",flexDirection:s?"column":"row",justifyContent:s?"center":z?"space-between":h(C),alignItems:"center",width:"100%",zIndex:2,position:"relative"},children:[ln("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:C||"center",flex:s||!z?1:void 0},children:x.text}),z&&dn("span",{style:{fontWeight:"800",fontSize:s?"12px":"15px",marginTop:s?"4px":"0"},children:[U,"%"]})]})]},x.id)})})]})};import{useState as fa}from"react";import{jsx as he,jsxs as no}from"react/jsx-runtime";var mr=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=fa(()=>{try{return localStorage.getItem(`appstorys_quiz_${t.id}`)}catch{return null}}),s={backgroundColor:"#FFFFFF",borderRadius:28,padding:16,questionTextColor:"#FFFFFF",questionBgColor:"#000000",optionBgColor:"#F8FAFC",optionTextColor:"#1E293B",borderColor:"#000000",activeColor:"#10b981",incorrectColor:"#ef4444",labelBgColor:"#FFFFFF",labelTextColor:"#111111",labelBorderColor:"#111111"},d=t.styling||{},c=nt(d.padding??s.padding),l=nt(d.fontSize||16),y=nt(d.optionFontSize||15),u=d.optionBorderRadius!==void 0?nt(d.optionBorderRadius):"9999px",m=d.optionBorderColor||"#CBD5E1",f=ut(d.questionFontFamily||d.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),P=ut(d.optionFontFamily||d.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),g={backgroundColor:d.backgroundColor||s.backgroundColor,borderRadius:nt(d.borderRadius??s.borderRadius),padding:0,boxShadow:d.shadow||"0 12px 32px rgba(0,0,0,0.14)",boxSizing:"border-box",width:"100%",maxWidth:"270px",margin:"0 auto",display:"flex",flexDirection:"column",overflow:"hidden",opacity:d.opacity??1},b={color:d.questionTextColor||s.questionTextColor,backgroundColor:d.questionBgColor||s.questionBgColor,fontWeight:"700",fontSize:l,fontFamily:f,lineHeight:1.3,margin:0,textAlign:"center",padding:"14px 16px",minHeight:"48px",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",borderTopLeftRadius:nt(d.borderRadius??s.borderRadius),borderTopRightRadius:nt(d.borderRadius??s.borderRadius),letterSpacing:"-0.01em"},C=d.optionTextAlign||d.optionFont?.textAlign||d.options?.font?.textAlign||d.options?.textAlign||"center",h=U=>{switch(U){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},T={backgroundColor:d.optionBgColor||s.optionBgColor,color:d.optionTextColor||s.optionTextColor,fontFamily:P,padding:"8px 14px",borderRadius:u,border:`1px solid ${m}`,display:"flex",alignItems:"center",justifyContent:h(C),cursor:n?"default":"pointer",width:"100%",textAlign:C||"center",boxSizing:"border-box",transition:"all 0.2s ease",fontSize:y,fontWeight:"500"},E={backgroundColor:d.backgroundColor||s.backgroundColor,borderRadius:`0 0 ${nt(d.borderRadius??s.borderRadius)} ${nt(d.borderRadius??s.borderRadius)}`,display:"flex",flexDirection:"column",gap:"6px",padding:"10px 14px 12px 14px"},X=U=>{if(!(o||n)){i(U);try{localStorage.setItem(`appstorys_quiz_${t.id}`,U)}catch{}e?.({type:"quiz",quizId:t.id,optionId:U,stickerId:t.id})}},I=["A","B","C","D","E","F"],S=Array.isArray(t.options)?t.options:[];S.length===0&&!o&&console.warn("AppStorys: QuizSticker has no options!",t.id);let M=S.find(U=>U.id===n),x=M?M.isCorrect===!0:!1,N=!!n&&t.showExplanation!==!1&&!!t.explanation;return no("div",{style:{...g,background:d.backgroundColor||s.backgroundColor},children:[he("style",{children:`
34
34
  @keyframes appstorys-quiz-fade-in {
35
35
  from { opacity: 0; transform: translateY(4px); }
36
36
  to { opacity: 1; transform: translateY(0); }
37
37
  }
38
- `}),t.question&&ce("h3",{style:g,children:t.question}),Ue("div",{style:{...m,background:"transparent"},children:[D.map((_,$)=>{let V=_.label||O[$]||"\u2022",A=_.id===n,T=_.isCorrect===!0,k={...b};return n&&(T?(k.backgroundColor=l.activeColor||s.activeColor,k.borderColor=l.activeColor||s.activeColor,k.color="#FFFFFF"):A&&(k.backgroundColor=l.incorrectColor||s.incorrectColor,k.borderColor=l.incorrectColor||s.incorrectColor,k.color="#FFFFFF")),ce("button",{style:k,onClick:()=>E(_.id),disabled:!!n,children:ce("span",{style:{fontWeight:"600",fontSize:S},children:_.text})},_.id)}),w&&Ue("div",{style:{marginTop:"8px",padding:"12px 14px",backgroundColor:v?"#E6F4EA":"#FCE8E6",borderRadius:"12px",border:`1px solid ${v?"rgba(16, 185, 129, 0.3)":"rgba(239, 68, 68, 0.3)"}`,display:"flex",flexDirection:"column",gap:"4px",textAlign:"left",animation:"appstorys-quiz-fade-in 0.3s ease forwards"},children:[Ue("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[v?Ue("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",style:{flexShrink:0},children:[ce("circle",{cx:"10",cy:"10",r:"10",fill:"#10B981"}),ce("path",{d:"M6 10L9 13L14 7",stroke:"white",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})]}):Ue("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",style:{flexShrink:0},children:[ce("circle",{cx:"10",cy:"10",r:"10",fill:"#EF4444"}),ce("path",{d:"M7 7L13 13M13 7L7 13",stroke:"white",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})]}),ce("span",{style:{fontWeight:"700",fontSize:"14px",color:v?"#0ABA73":"#EF4444",fontFamily:C},children:v?"Correct":"Incorrect"})]}),ce("div",{style:{fontSize:"13px",color:"#374151",fontFamily:C,lineHeight:"1.4",paddingLeft:"26px",wordBreak:"break-word"},children:t.explanation})]})]})]})};import{useState as Gs,useEffect as Qs}from"react";import{jsx as ve,jsxs as nr}from"react/jsx-runtime";var ir=({data:t})=>{let[e,o]=Gs({days:"00",hours:"00",minutes:"00",seconds:"00"});Qs(()=>{if(!t.targetDate)return;let V=()=>{let T=+new Date(t.targetDate)-+new Date;if(T>0){let k=Math.floor(T/864e5),B=Math.floor(T/(1e3*60*60)%24),W=Math.floor(T/1e3/60%60),H=Math.floor(T/1e3%60);o({days:k.toString().padStart(2,"0"),hours:B.toString().padStart(2,"0"),minutes:W.toString().padStart(2,"0"),seconds:H.toString().padStart(2,"0")})}else o({days:"00",hours:"00",minutes:"00",seconds:"00"})},A=setInterval(V,1e3);return V(),()=>clearInterval(A)},[t.targetDate]);let n=t.styling||{},i=t.display||{showDays:!0,showHours:!0,showMinutes:!0,showSeconds:!0},s=st(n.questionFontFamily||n.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),l=n.digitSize||n.fontSize,c=typeof l=="string",d=c?l:`${!isNaN(Number(l))&&Number(l)>0?Number(l):18}px`,S=n.labelFontSize?ot(n.labelFontSize):c?`calc(${d} * 0.45)`:`${Math.max(10,Math.round(Number(l||18)*.45))}px`,p=c?`calc(${d} * 1.65)`:`${Math.max(36,Math.round(Number(l||18)*1.65))}px`,y=c?`calc(${d} * 0.95)`:`${Math.max(26,Math.round(Number(l||18)*.95))}px`,u=c?`calc(${d} * 0.25)`:`${Math.max(6,Math.round(Number(l||18)*.25))}px`,C=c?`calc(${d} * 0.15)`:`${Math.max(6,Math.round(Number(l||18)*.15))}px`,h=c?`calc(${d} * 0.75)`:`${Math.max(14,Math.round(Number(l||18)*.75))}px`,g={backgroundColor:n.backgroundColor||"#FFFFFF",borderRadius:ot(n.borderRadius!==void 0?n.borderRadius:16),padding:n.padding?ot(n.padding):"16px 18px",boxShadow:n.shadow||"0 10px 30px rgba(0,0,0,0.08)",width:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",gap:"10px",border:n.borderColor?`1px solid ${n.borderColor}`:"none",overflow:"hidden",opacity:n.opacity??1},b={color:n.titleColor||"#000000",fontWeight:"700",fontSize:ot(n.fontSize||14),fontFamily:s,width:"100%",textAlign:"center",marginBottom:"4px"},m={display:"flex",gap:C,width:"100%",justifyContent:"center",alignItems:"center",flexWrap:"nowrap"},E={display:"flex",flexDirection:"column",alignItems:"center",gap:"2px"},O={display:"flex",gap:"2px"},D={backgroundColor:n.digitBackground||"#F1F3F5",borderRadius:u,minWidth:y,height:p,display:"flex",alignItems:"center",justifyContent:"center",fontSize:d,fontWeight:"bold",color:n.digitColor||"#1A202C",padding:"0 4px"},L={fontSize:c?S:`${Math.max(9,Number(String(S).replace("px","")))}px`,color:n.labelColor||"#A0AEC0",fontWeight:"600",textTransform:"lowercase"},v={fontSize:h,fontWeight:"700",color:n.labelColor||"#A0AEC0",display:"flex",alignItems:"center",lineHeight:1},w=(V,A)=>nr("div",{style:E,children:[ve("div",{style:O,children:V.split("").map((T,k)=>ve("div",{style:D,children:T},k))}),ve("span",{style:L,children:A})]}),_=[],$=0;return i.showDays!==!1&&(_.push(w(e.days,"days")),$++),i.showHours!==!1&&($>0&&_.push(ve("div",{style:v,children:":"},"sep-h")),_.push(w(e.hours,"hours")),$++),i.showMinutes!==!1&&($>0&&_.push(ve("div",{style:v,children:":"},"sep-m")),_.push(w(e.minutes,"minutes")),$++),i.showSeconds!==!1&&($>0&&_.push(ve("div",{style:v,children:":"},"sep-s")),_.push(w(e.seconds,"seconds")),$++),nr("div",{style:g,children:[t.title&&ve("div",{style:b,children:t.title}),ve("div",{style:m,children:_})]})};import{useState as Xs}from"react";import{jsx as we,jsxs as rr}from"react/jsx-runtime";var sr=({data:t,onInteraction:e})=>{let[o,n]=Xs(!1),i=y=>{y.stopPropagation(),t.code&&(navigator.clipboard.writeText(t.code).catch(()=>{}),n(!0),e?.({type:"promo_code",value:"copied",stickerId:t.id,code:t.code}),setTimeout(()=>n(!1),2e3))},s=t.styling||{},l=s.backgroundColor||"#F4F4F6",c=st(s.fontFamily,'"SF Mono", "Roboto Mono", Menlo, Consolas, "Courier New", monospace'),d={backgroundColor:l,padding:"6px 14px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",minHeight:"36px",boxSizing:"border-box",position:"relative",boxShadow:s.shadow||"0 4px 16px rgba(0,0,0,0.08)",cursor:"pointer",WebkitMaskImage:"radial-gradient(circle at 0px 50%, transparent 6px, black 6.5px), radial-gradient(circle at 100% 50%, transparent 6px, black 6.5px)",maskImage:"radial-gradient(circle at 0px 50%, transparent 6px, black 6.5px), radial-gradient(circle at 100% 50%, transparent 6px, black 6.5px)",WebkitMaskComposite:"destination-in",maskComposite:"intersect"};return rr("div",{style:d,onClick:i,children:[we("div",{style:{width:"26px",height:"26px",borderRadius:"6px",backgroundColor:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",fontWeight:"900",color:"#000000",border:"1.8px solid #000000",flexShrink:0},children:"%"}),we("div",{style:{flex:1,minWidth:0,padding:"0 8px",display:"flex",alignItems:"center",justifyContent:"center"},children:we("span",{style:{fontSize:"13px",fontWeight:"700",color:o?"#10B981":"#000000",fontFamily:c,letterSpacing:"0.5px",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block",width:"100%",transition:"color 0.2s ease"},children:o?"Copied!":t.code||"OFFER20"})}),we("div",{style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderLeft:"1.5px dashed rgba(0,0,0,0.2)",paddingLeft:"10px",marginLeft:"4px",height:"24px"},children:o?we("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#10B981",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:we("polyline",{points:"20 6 9 17 4 12"})}):rr("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[we("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2.5",stroke:"#000000",strokeWidth:"2",fill:"none"}),we("rect",{x:"4",y:"4",width:"12",height:"12",rx:"2.5",stroke:"#000000",strokeWidth:"2",fill:"none"})]})})]})};import{useState as ar,useEffect as Js}from"react";import{jsx as Nn,jsxs as lr}from"react/jsx-runtime";var dr=({data:t,onInteraction:e,isEditing:o=!1})=>{let n={emojis:["\u{1F60D}","\u{1F44D}"]},i=Array.isArray(t.emojis)?t.emojis:Array.isArray(n.emojis)?n.emojis:[],[s,l]=ar(()=>{try{return localStorage.getItem(`appstorys_reaction_${t.id}`)!==null}catch{return!1}}),[c,d]=ar({});Js(()=>{let g={},b=(()=>{try{return localStorage.getItem(`appstorys_reaction_${t.id}`)}catch{return null}})();i.forEach(m=>{let E=Math.random()>.5?1999:2e3;b&&m===b&&(E+=1),g[m]=E}),d(g)},[t.emojis]);let S=(g,b)=>{if(!(o||s)){d(m=>({...m,[g]:(m[g]||0)+1})),l(!0);try{localStorage.setItem(`appstorys_reaction_${t.id}`,g)}catch{}e?.({type:"reaction",reactionId:t.id,optionId:`option${b+1}`,selected_option:`option${b+1}`,emoji:g,stickerId:t.id})}},p=g=>g>=1e3?(g/1e3).toFixed(0)+"k":String(g),y={display:"flex",gap:"10px",justifyContent:"center",alignItems:"center",width:"100%",padding:"6px",boxSizing:"border-box"},u={backgroundColor:"#FFFFFF",width:"52px",height:s?"72px":"52px",borderRadius:"100px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:s?"space-between":"center",padding:s?"6px 0":"0",boxShadow:"0 8px 30px rgba(0,0,0,0.12)",cursor:o||s?"default":"pointer",border:"none",outline:"none",position:"relative",zIndex:1,boxSizing:"border-box",flexShrink:0},C={fontSize:"28px",lineHeight:"1",userSelect:"none"},h={fontSize:"13px",fontWeight:"800",color:"#374151",animation:"appstorys-reaction-fade-in 0.3s ease forwards",lineHeight:"1",userSelect:"none",fontFamily:st(t.styling?.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif')};return lr("div",{style:y,children:[Nn("style",{children:`
38
+ `}),t.question&&he("h3",{style:b,children:t.question}),no("div",{style:{...E,background:"transparent"},children:[S.map((U,z)=>{let O=U.label||I[z]||"\u2022",B=U.id===n,K=U.isCorrect===!0,v={...T};return n&&(K?(v.backgroundColor=d.activeColor||s.activeColor,v.borderColor=d.activeColor||s.activeColor,v.color="#FFFFFF"):B&&(v.backgroundColor=d.incorrectColor||s.incorrectColor,v.borderColor=d.incorrectColor||s.incorrectColor,v.color="#FFFFFF")),he("button",{style:v,onClick:()=>X(U.id),disabled:!!n,children:he("span",{style:{fontWeight:"600",fontSize:y,width:"100%",textAlign:C||"center"},children:U.text})},U.id)}),N&&no("div",{style:{marginTop:"8px",padding:"12px 14px",backgroundColor:x?"#E6F4EA":"#FCE8E6",borderRadius:"12px",border:`1px solid ${x?"rgba(16, 185, 129, 0.3)":"rgba(239, 68, 68, 0.3)"}`,display:"flex",flexDirection:"column",gap:"4px",textAlign:"left",animation:"appstorys-quiz-fade-in 0.3s ease forwards"},children:[no("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x?no("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",style:{flexShrink:0},children:[he("circle",{cx:"10",cy:"10",r:"10",fill:"#10B981"}),he("path",{d:"M6 10L9 13L14 7",stroke:"white",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})]}):no("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",style:{flexShrink:0},children:[he("circle",{cx:"10",cy:"10",r:"10",fill:"#EF4444"}),he("path",{d:"M7 7L13 13M13 7L7 13",stroke:"white",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})]}),he("span",{style:{fontWeight:"700",fontSize:"14px",color:x?"#0ABA73":"#EF4444",fontFamily:P},children:x?"Correct":"Incorrect"})]}),he("div",{style:{fontSize:"13px",color:"#374151",fontFamily:P,lineHeight:"1.4",paddingLeft:"26px",wordBreak:"break-word"},children:t.explanation})]})]})]})};import{useState as ma,useEffect as ya}from"react";import{jsx as Ee,jsxs as yr}from"react/jsx-runtime";var hr=({data:t})=>{let[e,o]=ma({days:"00",hours:"00",minutes:"00",seconds:"00"});ya(()=>{if(!t.targetDate)return;let N=()=>{let z=+new Date(t.targetDate)-+new Date;if(z>0){let O=Math.floor(z/864e5),B=Math.floor(z/(1e3*60*60)%24),K=Math.floor(z/1e3/60%60),v=Math.floor(z/1e3%60);o({days:O.toString().padStart(2,"0"),hours:B.toString().padStart(2,"0"),minutes:K.toString().padStart(2,"0"),seconds:v.toString().padStart(2,"0")})}else o({days:"00",hours:"00",minutes:"00",seconds:"00"})},U=setInterval(N,1e3);return N(),()=>clearInterval(U)},[t.targetDate]);let n=t.styling||{},i=t.display||{showDays:!0,showHours:!0,showMinutes:!0,showSeconds:!0},s=ut(n.questionFontFamily||n.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),d=n.digitSize||n.fontSize,c=typeof d=="string",l=c?d:`${!isNaN(Number(d))&&Number(d)>0?Number(d):18}px`,y=n.labelFontSize?nt(n.labelFontSize):c?`calc(${l} * 0.45)`:`${Math.max(10,Math.round(Number(d||18)*.45))}px`,u=c?`calc(${l} * 1.65)`:`${Math.max(36,Math.round(Number(d||18)*1.65))}px`,m=c?`calc(${l} * 0.95)`:`${Math.max(26,Math.round(Number(d||18)*.95))}px`,f=c?`calc(${l} * 0.25)`:`${Math.max(6,Math.round(Number(d||18)*.25))}px`,P=c?`calc(${l} * 0.15)`:`${Math.max(6,Math.round(Number(d||18)*.15))}px`,g=c?`calc(${l} * 0.75)`:`${Math.max(14,Math.round(Number(d||18)*.75))}px`,b={backgroundColor:n.backgroundColor||"#FFFFFF",borderRadius:nt(n.borderRadius!==void 0?n.borderRadius:16),padding:n.padding?nt(n.padding):"16px 18px",boxShadow:n.shadow||"0 10px 30px rgba(0,0,0,0.08)",width:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",gap:"10px",border:n.borderColor?`1px solid ${n.borderColor}`:"none",overflow:"hidden",opacity:n.opacity??1},R={color:n.titleColor||"#000000",fontWeight:"700",fontSize:nt(n.fontSize||14),fontFamily:s,width:"100%",textAlign:"center",marginBottom:"4px"},C={display:"flex",gap:P,width:"100%",justifyContent:"center",alignItems:"center",flexWrap:"nowrap"},h={display:"flex",flexDirection:"column",alignItems:"center",gap:"2px"},T={display:"flex",gap:"2px"},E={backgroundColor:n.digitBackground||"#F1F3F5",borderRadius:f,minWidth:m,height:u,display:"flex",alignItems:"center",justifyContent:"center",fontSize:l,fontWeight:"bold",color:n.digitColor||"#1A202C",padding:"0 4px"},X={fontSize:c?y:`${Math.max(9,Number(String(y).replace("px","")))}px`,color:n.labelColor||"#A0AEC0",fontWeight:"600",textTransform:"lowercase"},I={fontSize:g,fontWeight:"700",color:n.labelColor||"#A0AEC0",display:"flex",alignItems:"center",lineHeight:1},S=(N,U)=>yr("div",{style:h,children:[Ee("div",{style:T,children:N.split("").map((z,O)=>Ee("div",{style:E,children:z},O))}),Ee("span",{style:X,children:U})]}),M=[],x=0;return i.showDays!==!1&&(M.push(S(e.days,"days")),x++),i.showHours!==!1&&(x>0&&M.push(Ee("div",{style:I,children:":"},"sep-h")),M.push(S(e.hours,"hours")),x++),i.showMinutes!==!1&&(x>0&&M.push(Ee("div",{style:I,children:":"},"sep-m")),M.push(S(e.minutes,"minutes")),x++),i.showSeconds!==!1&&(x>0&&M.push(Ee("div",{style:I,children:":"},"sep-s")),M.push(S(e.seconds,"seconds")),x++),yr("div",{style:b,children:[t.title&&Ee("div",{style:R,children:t.title}),Ee("div",{style:C,children:M})]})};import{useState as ha}from"react";import{jsx as Pe,jsxs as br}from"react/jsx-runtime";var xr=({data:t,onInteraction:e})=>{let[o,n]=ha(!1),i=m=>{m.stopPropagation(),t.code&&(navigator.clipboard.writeText(t.code).catch(()=>{}),n(!0),e?.({type:"promo_code",value:"copied",stickerId:t.id,code:t.code}),setTimeout(()=>n(!1),2e3))},s=t.styling||{},d=s.backgroundColor||"#F4F4F6",c=ut(s.fontFamily,'"SF Mono", "Roboto Mono", Menlo, Consolas, "Courier New", monospace'),l={backgroundColor:d,padding:"6px 14px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",minHeight:"36px",boxSizing:"border-box",position:"relative",boxShadow:s.shadow||"0 4px 16px rgba(0,0,0,0.08)",cursor:"pointer",WebkitMaskImage:"radial-gradient(circle at 0px 50%, transparent 6px, black 6.5px), radial-gradient(circle at 100% 50%, transparent 6px, black 6.5px)",maskImage:"radial-gradient(circle at 0px 50%, transparent 6px, black 6.5px), radial-gradient(circle at 100% 50%, transparent 6px, black 6.5px)",WebkitMaskComposite:"destination-in",maskComposite:"intersect"};return br("div",{style:l,onClick:i,children:[Pe("div",{style:{width:"26px",height:"26px",borderRadius:"6px",backgroundColor:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",fontWeight:"900",color:"#000000",border:"1.8px solid #000000",flexShrink:0},children:"%"}),Pe("div",{style:{flex:1,minWidth:0,padding:"0 8px",display:"flex",alignItems:"center",justifyContent:"center"},children:Pe("span",{style:{fontSize:"13px",fontWeight:"700",color:o?"#10B981":"#000000",fontFamily:c,letterSpacing:"0.5px",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block",width:"100%",transition:"color 0.2s ease"},children:o?"Copied!":t.code||"OFFER20"})}),Pe("div",{style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderLeft:"1.5px dashed rgba(0,0,0,0.2)",paddingLeft:"10px",marginLeft:"4px",height:"24px"},children:o?Pe("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#10B981",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:Pe("polyline",{points:"20 6 9 17 4 12"})}):br("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[Pe("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2.5",stroke:"#000000",strokeWidth:"2",fill:"none"}),Pe("rect",{x:"4",y:"4",width:"12",height:"12",rx:"2.5",stroke:"#000000",strokeWidth:"2",fill:"none"})]})})]})};import{useState as Sr,useEffect as ba}from"react";import{jsx as Zn,jsxs as Cr}from"react/jsx-runtime";var vr=({data:t,onInteraction:e,isEditing:o=!1})=>{let n={emojis:["\u{1F60D}","\u{1F44D}"]},i=Array.isArray(t.emojis)?t.emojis:Array.isArray(n.emojis)?n.emojis:[],[s,d]=Sr(()=>{try{return localStorage.getItem(`appstorys_reaction_${t.id}`)!==null}catch{return!1}}),[c,l]=Sr({});ba(()=>{let b={},R=(()=>{try{return localStorage.getItem(`appstorys_reaction_${t.id}`)}catch{return null}})();i.forEach(C=>{let h=Math.random()>.5?1999:2e3;R&&C===R&&(h+=1),b[C]=h}),l(b)},[t.emojis]);let y=(b,R)=>{if(!(o||s)){l(C=>({...C,[b]:(C[b]||0)+1})),d(!0);try{localStorage.setItem(`appstorys_reaction_${t.id}`,b)}catch{}e?.({type:"reaction",reactionId:t.id,optionId:`option${R+1}`,selected_option:`option${R+1}`,emoji:b,stickerId:t.id})}},u=b=>b>=1e3?(b/1e3).toFixed(0)+"k":String(b),m={display:"flex",gap:"10px",justifyContent:"center",alignItems:"center",width:"100%",padding:"6px",boxSizing:"border-box"},f={backgroundColor:"#FFFFFF",width:"52px",height:s?"72px":"52px",borderRadius:"100px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:s?"space-between":"center",padding:s?"6px 0":"0",boxShadow:"0 8px 30px rgba(0,0,0,0.12)",cursor:o||s?"default":"pointer",border:"none",outline:"none",position:"relative",zIndex:1,boxSizing:"border-box",flexShrink:0},P={fontSize:"28px",lineHeight:"1",userSelect:"none"},g={fontSize:"13px",fontWeight:"800",color:"#374151",animation:"appstorys-reaction-fade-in 0.3s ease forwards",lineHeight:"1",userSelect:"none",fontFamily:ut(t.styling?.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif')};return Cr("div",{style:m,children:[Zn("style",{children:`
39
39
  @keyframes appstorys-reaction-fade-in {
40
40
  from { opacity: 0; transform: translateY(4px); }
41
41
  to { opacity: 1; transform: translateY(0); }
@@ -49,7 +49,7 @@ var ls=Object.defineProperty;var Me=(t,e)=>()=>(t&&(e=t(t=0)),e);var ds=(t,e)=>{
49
49
  .appstorys-reaction-btn.voted {
50
50
  transform: scale(1) translateY(0) !important;
51
51
  }
52
- `}),i.map((g,b)=>{let m=c[g]||2e3;return lr("button",{className:`appstorys-reaction-btn ${s?"voted":""} ${o?"editing":""}`,style:u,onClick:()=>S(g,b),children:[Nn("span",{style:C,children:g}),s&&Nn("span",{style:h,children:p(m)})]},b)})]})};import{useState as Xo,useRef as Ks,useEffect as Zs}from"react";import{jsx as Jo,jsxs as On}from"react/jsx-runtime";var cr=({data:t,onInteraction:e,isEditing:o=!1})=>{let n=t.maxRating||5,i=t.currentRating??Math.floor(n/2),[s,l]=Xo(()=>{try{let B=localStorage.getItem(`appstorys_rating_${t.id}`);return B?Number(B):i}catch{return i}}),c=Ks(null),[d,S]=Xo(!1),[p,y]=Xo(()=>{try{return localStorage.getItem(`appstorys_rating_${t.id}`)!==null}catch{return!1}}),[u,C]=Xo([]),h={backgroundColor:"#FFFFFF",borderRadius:20,padding:14,titleColor:"#000000",titleFontSize:15,sliderTrackColor:"#F3F4F6",sliderFillColor:"#F97316",emojiSize:32},g=t.styling||{},b=st(g.questionFontFamily||g.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),m={backgroundColor:g.backgroundColor||h.backgroundColor,borderRadius:ot(g.borderRadius??h.borderRadius),padding:g.padding?ot(g.padding):"8px 12px",boxShadow:g.shadow||"0 10px 24px rgba(0,0,0,0.08)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",cursor:"default",opacity:g.opacity??1},E={color:g.titleColor||h.titleColor,fontWeight:"700",fontSize:typeof g.titleFontSize=="string"?`min(${g.titleFontSize}, 16px)`:`${g.titleFontSize?Math.min(Number(g.titleFontSize),16):15}px`,margin:"0",textAlign:"center",lineHeight:"1.25",fontFamily:b,width:"100%"},O={width:"100%",height:"16px",backgroundColor:g.sliderTrackColor||h.sliderTrackColor,borderRadius:"100px",position:"relative",cursor:o||p?"default":"pointer",marginTop:"4px",marginBottom:"2px",userSelect:"none"},D=s/n*100,L={width:`${D}%`,height:"100%",background:g.sliderFillColor||"linear-gradient(90deg, #FF4582, #e11d48)",borderRadius:"100px",transition:d?"none":"width 0.1s ease"},v=g.emojiSize||h.emojiSize,w=typeof v=="string",_=ot(v),$={position:"absolute",left:w?`calc(${D}% - calc(${_} / 2))`:`calc(${D}% - ${Number(v)/2}px)`,top:w?`calc(50% - calc(${_} / 2))`:`calc(50% - ${Number(v)/2}px)`,fontSize:_,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",cursor:p||o?"default":"grab",transition:d?"none":"left 0.1s ease",filter:"drop-shadow(0 4px 8px rgba(0,0,0,0.2))",animation:p?"thumbPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards":"none"},V=B=>{if(!c.current||o||p)return;let W=c.current.getBoundingClientRect(),H=B-W.left;H<0&&(H=0),H>W.width&&(H=W.width);let Y=H/W.width,r=Math.round(Y*n*10)/10;l(r)},A=B=>{o||p||(S(!0),V(B.clientX))},T=B=>{o||p||(S(!0),V(B.touches[0].clientX))},k=()=>{let B=Array.from({length:16}).map((W,H)=>({id:Date.now()+H,scale:.5+Math.random()*.8,angle:H*22.5+(Math.random()*15-7.5),delay:Math.random()*.1}));C(B),setTimeout(()=>{C([])},1200)};return Zs(()=>{let B=Y=>{d&&V(Y.clientX)},W=()=>{if(d){S(!1),y(!0);try{localStorage.setItem(`appstorys_rating_${t.id}`,String(s))}catch{}k(),e?.({type:"rating",ratingId:t.id,value:s,stickerId:t.id})}},H=Y=>{d&&V(Y.touches[0].clientX)};return d&&(window.addEventListener("mousemove",B),window.addEventListener("mouseup",W),window.addEventListener("touchmove",H),window.addEventListener("touchend",W)),()=>{window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",W),window.removeEventListener("touchmove",H),window.removeEventListener("touchend",W)}},[d,s]),On("div",{style:m,children:[Jo("style",{children:`
52
+ `}),i.map((b,R)=>{let C=c[b]||2e3;return Cr("button",{className:`appstorys-reaction-btn ${s?"voted":""} ${o?"editing":""}`,style:f,onClick:()=>y(b,R),children:[Zn("span",{style:P,children:b}),s&&Zn("span",{style:g,children:u(C)})]},R)})]})};import{useState as cn,useRef as xa,useEffect as Sa}from"react";import{jsx as un,jsxs as ti}from"react/jsx-runtime";var wr=({data:t,onInteraction:e,isEditing:o=!1})=>{let n=t.maxRating||5,i=t.currentRating??Math.floor(n/2),[s,d]=cn(()=>{try{let B=localStorage.getItem(`appstorys_rating_${t.id}`);return B?Number(B):i}catch{return i}}),c=xa(null),[l,y]=cn(!1),[u,m]=cn(()=>{try{return localStorage.getItem(`appstorys_rating_${t.id}`)!==null}catch{return!1}}),[f,P]=cn([]),g={backgroundColor:"#FFFFFF",borderRadius:20,padding:14,titleColor:"#000000",titleFontSize:15,sliderTrackColor:"#F3F4F6",sliderFillColor:"#F97316",emojiSize:32},b=t.styling||{},R=ut(b.questionFontFamily||b.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),C={backgroundColor:b.backgroundColor||g.backgroundColor,borderRadius:nt(b.borderRadius??g.borderRadius),padding:b.padding?nt(b.padding):"8px 12px",boxShadow:b.shadow||"0 10px 24px rgba(0,0,0,0.08)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",cursor:"default",opacity:b.opacity??1},h={color:b.titleColor||g.titleColor,fontWeight:"700",fontSize:typeof b.titleFontSize=="string"?`min(${b.titleFontSize}, 16px)`:`${b.titleFontSize?Math.min(Number(b.titleFontSize),16):15}px`,margin:"0",textAlign:"center",lineHeight:"1.25",fontFamily:R,width:"100%"},T={width:"100%",height:"16px",backgroundColor:b.sliderTrackColor||g.sliderTrackColor,borderRadius:"100px",position:"relative",cursor:o||u?"default":"pointer",marginTop:"4px",marginBottom:"2px",userSelect:"none"},E=s/n*100,X={width:`${E}%`,height:"100%",background:b.sliderFillColor||"linear-gradient(90deg, #FF4582, #e11d48)",borderRadius:"100px",transition:l?"none":"width 0.1s ease"},I=b.emojiSize||g.emojiSize,S=typeof I=="string",M=nt(I),x={position:"absolute",left:S?`calc(${E}% - calc(${M} / 2))`:`calc(${E}% - ${Number(I)/2}px)`,top:S?`calc(50% - calc(${M} / 2))`:`calc(50% - ${Number(I)/2}px)`,fontSize:M,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",cursor:u||o?"default":"grab",transition:l?"none":"left 0.1s ease",filter:"drop-shadow(0 4px 8px rgba(0,0,0,0.2))",animation:u?"thumbPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards":"none"},N=B=>{if(!c.current||o||u)return;let K=c.current.getBoundingClientRect(),v=B-K.left;v<0&&(v=0),v>K.width&&(v=K.width);let A=v/K.width,H=Math.round(A*n*10)/10;d(H)},U=B=>{o||u||(y(!0),N(B.clientX))},z=B=>{o||u||(y(!0),N(B.touches[0].clientX))},O=()=>{let B=Array.from({length:16}).map((K,v)=>({id:Date.now()+v,scale:.5+Math.random()*.8,angle:v*22.5+(Math.random()*15-7.5),delay:Math.random()*.1}));P(B),setTimeout(()=>{P([])},1200)};return Sa(()=>{let B=A=>{l&&N(A.clientX)},K=()=>{if(l){y(!1),m(!0);try{localStorage.setItem(`appstorys_rating_${t.id}`,String(s))}catch{}O(),e?.({type:"rating",ratingId:t.id,value:s,stickerId:t.id})}},v=A=>{l&&N(A.touches[0].clientX)};return l&&(window.addEventListener("mousemove",B),window.addEventListener("mouseup",K),window.addEventListener("touchmove",v),window.addEventListener("touchend",K)),()=>{window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",K),window.removeEventListener("touchmove",v),window.removeEventListener("touchend",K)}},[l,s]),ti("div",{style:C,children:[un("style",{children:`
53
53
  @keyframes emojiBurst {
54
54
  0% {
55
55
  transform: translate(0, 0) scale(0.3);
@@ -68,7 +68,7 @@ var ls=Object.defineProperty;var Me=(t,e)=>()=>(t&&(e=t(t=0)),e);var ds=(t,e)=>{
68
68
  50% { transform: scale(1.3); }
69
69
  100% { transform: scale(1); }
70
70
  }
71
- `}),Jo("h3",{style:E,children:t.title||"Do you like my space?"}),On("div",{ref:c,style:O,onMouseDown:A,onTouchStart:T,children:[Jo("div",{style:L}),On("div",{style:$,className:"interactive-emoji-thumb",children:[t.emoji||"\u{1F60D}",u.map(B=>{let W=60+Math.random()*80,H=B.angle*Math.PI/180,Y=`${Math.cos(H)*W}px`,r=`${Math.sin(H)*W}px`;return Jo("span",{style:{position:"absolute",left:"50%",top:"50%",width:"30px",height:"30px",marginLeft:"-15px",marginTop:"-15px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"24px",pointerEvents:"none",zIndex:100,animation:`emojiBurst 1s cubic-bezier(0.15, 0.85, 0.35, 1) ${B.delay}s forwards`,"--tx":Y,"--ty":r,"--scale":B.scale},children:t.emoji||"\u{1F60D}"},B.id)})]})]})]})};import{useState as ur}from"react";import{jsx as yo,jsxs as jn}from"react/jsx-runtime";var pr=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=ur(()=>{try{return localStorage.getItem(`appstorys_question_${t.id}`)||""}catch{return""}}),[s,l]=ur(()=>{try{return localStorage.getItem(`appstorys_question_${t.id}`)!==null}catch{return!1}}),c={backgroundColor:"#FFFFFF",borderRadius:16,padding:16,promptColor:"#111111",inputBgColor:"#FFFFFF",borderColor:"#EFEFEF",textColor:"#333333",placeholderColor:"#A0AEC0"},d=t.styling||{},S=st(d.questionFontFamily||d.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),p=st(d.optionFontFamily||d.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),y={backgroundColor:d.backgroundColor||c.backgroundColor,borderRadius:ot(d.borderRadius??c.borderRadius),padding:d.padding?ot(d.padding):"10px 12px",boxShadow:d.shadow||"0 8px 24px rgba(0,0,0,0.06)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",border:`1px solid ${d.borderColor||"#F0F0F0"}`},u={color:d.promptColor||c.promptColor,fontWeight:"700",fontSize:ot(d.fontSize||16),fontFamily:S,textAlign:"center",marginBottom:"2px",width:"100%"},C={width:"100%",position:"relative",display:"flex",alignItems:"center"},h=d.optionRadius??d.inputBorderRadius??d.optionBorderRadius??d.inputRadius,g=h!==void 0?typeof h=="number"&&h>=5?"9999px":ot(h):"9999px",b={backgroundColor:d.inputBgColor||"#F1F3F5",border:"none",borderRadius:g,padding:"8px 36px 8px 14px",width:"100%",boxSizing:"border-box",color:d.inputTextColor||"#1A202C",fontSize:"13px",fontFamily:p,outline:"none",textAlign:"left",cursor:o?"default":"text",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},m={position:"absolute",right:"4px",background:d.submitBackground||"#FE6B35",color:"white",border:"none",borderRadius:"50%",width:"24px",height:"24px",display:n.length>0&&!s?"flex":"none",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"transform 0.2s"},E=D=>{o||s||i(D.target.value)},O=()=>{if(!(o||!n.trim()||s)){l(!0);try{localStorage.setItem(`appstorys_question_${t.id}`,n.trim())}catch{}e?.({type:"question",questionId:t.id,value:n.trim(),stickerId:t.id})}};return jn("div",{style:y,children:[yo("div",{style:u,children:t.question||"Ask me anything"}),jn("div",{style:C,children:[yo("input",{type:"text",value:n,placeholder:s?"Submitted!":t.placeholder||"Type your answer...",style:b,disabled:o||s,onChange:E,onKeyDown:D=>D.key==="Enter"&&O()}),yo("button",{style:m,onClick:O,children:jn("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[yo("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),yo("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})};import{useState as ta}from"react";import{jsx as ho,jsxs as qn}from"react/jsx-runtime";var gr=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=ta(()=>{try{return localStorage.getItem(`appstorys_image_quiz_${t.id}`)}catch{return null}}),s={backgroundColor:"#FFFFFF",borderRadius:16,padding:10,optionBgColor:"#F8FAFC",optionTextColor:"#0F172A",borderColor:"#E2E8F0",activeColor:"#10B981",incorrectColor:"#EF4444"},l=t.styling||{},c=ot(l.padding??s.padding),d=ot(l.borderRadius??s.borderRadius),S=st(l.questionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),p=st(l.optionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),y={backgroundColor:l.backgroundColor||s.backgroundColor,borderRadius:d,padding:c,boxShadow:l.shadow||"0 12px 32px rgba(0,0,0,0.12)",boxSizing:"border-box",width:"100%",maxWidth:"280px",margin:"0 auto",display:"flex",flexDirection:"column",opacity:l.opacity??1,border:l.borderColor?`1px solid ${l.borderColor}`:"none",overflow:"hidden"},u={color:l.questionTextColor||"#FFFFFF",backgroundColor:l.questionBgColor||"#000000",fontWeight:"800",fontSize:ot(l.fontSize||15),fontFamily:S,margin:`calc(-1 * ${c}) calc(-1 * ${c}) 8px calc(-1 * ${c})`,padding:`12px ${c} 10px ${c}`,textAlign:"center",borderTopLeftRadius:d,borderTopRightRadius:d},g={display:"grid",gridTemplateColumns:`repeat(${(v=>{if(typeof v=="number"&&!isNaN(v)&&v>0)return v;if(typeof v=="string"){let w=parseInt(v,10);if(!isNaN(w)&&w>0)return w}if(typeof v=="object"&&v!==null){let w=v.columns||v.cols||v.columnCount;if(typeof w=="number"&&!isNaN(w)&&w>0)return w;if(typeof w=="string"){let _=parseInt(w,10);if(!isNaN(_)&&_>0)return _}}return 2})(t.layout??l.layout??l.columns)}, 1fr)`,gap:"6px",width:"100%"},b=ot(l.optionRadius??l.optionBorderRadius??l.imageRadius??14),m={backgroundColor:l.optionBgColor||s.optionBgColor,color:l.optionTextColor||s.optionTextColor,fontFamily:p,borderRadius:b,border:`2px solid ${l.borderColor||s.borderColor}`,cursor:n?"default":"pointer",display:"flex",flexDirection:"column",alignItems:"center",padding:"6px",boxSizing:"border-box",transition:"all 0.2s ease",overflow:"hidden"},E=v=>{if(!(o||n)){i(v);try{localStorage.setItem(`appstorys_image_quiz_${t.id}`,v)}catch{}e?.({type:"image",quizId:t.id,optionId:v,stickerId:t.id})}},O="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Crect width='100%25' height='100%25' fill='%23EDF2F7'/%3E%3Cpath d='M30 40 L40 30 L50 40 L60 30 L70 40 V60 H30 Z' fill='%23A0AEC0'/%3E%3Ccircle cx='40' cy='45' r='5' fill='%23FFFFFF'/%3E%3C/svg%3E",D=["A","B","C","D","E","F"],L=Array.isArray(t.options)?t.options:[];return L.length===0&&!o&&console.warn("AppStorys: ImageQuizSticker has no options!",t.id),qn("div",{style:{...y,background:l.backgroundColor||s.backgroundColor},children:[t.question&&ho("h3",{style:u,children:t.question}),ho("div",{style:g,children:L.map((v,w)=>{let _=v.id===n,$=v.isCorrect===!0,V=l.borderColor||s.borderColor,A=l.optionBgColor||s.optionBgColor;n&&($?(V=l.activeColor||s.activeColor,A="rgba(16, 185, 129, 0.08)"):_&&(V=l.incorrectColor||s.incorrectColor,A="rgba(239, 68, 68, 0.08)"));let T=n?$?l.activeColor||s.activeColor:_?l.incorrectColor||s.incorrectColor:l.labelColor||l.optionTextColor||s.optionTextColor:l.labelColor||l.optionTextColor||s.optionTextColor;return qn("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%",boxSizing:"border-box"},children:[qn("button",{style:{width:"100%",aspectRatio:"1",borderRadius:b,border:`2px solid ${V}`,backgroundColor:A,overflow:"hidden",cursor:n?"default":"pointer",position:"relative",padding:0,margin:0,outline:"none",transition:"transform 0.2s ease, border-color 0.2s ease",boxSizing:"border-box"},onClick:()=>E(v.id),disabled:!!n,onMouseOver:k=>{!o&&!n&&(k.currentTarget.style.transform="scale(1.02)")},onMouseOut:k=>{!o&&!n&&(k.currentTarget.style.transform="scale(1)")},children:[ho("img",{src:v.image||O,alt:v.text,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),n&&ho("div",{style:{position:"absolute",top:"6px",right:"6px",width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:$?l.activeColor||s.activeColor:_?l.incorrectColor||s.incorrectColor:"#A0AEC0",color:"#FFFFFF",fontSize:"12px",fontWeight:"bold",boxShadow:"0 2px 6px rgba(0,0,0,0.2)"},children:$?"\u2713":_?"\u2715":""})]}),ho("span",{style:{marginTop:"6px",fontWeight:"600",fontSize:ot(l.optionFontSize||13),color:T,fontFamily:p,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.text})]},v.id)})})]})};import{useState as Sr}from"react";import{useState as bo,useEffect as ea}from"react";import{jsx as at,jsxs as wt}from"react/jsx-runtime";var xr=({product:t,styling:e,onClose:o,onAddToCart:n})=>{let[i,s]=bo(""),[l,c]=bo(0),[d,S]=bo(1),[p,y]=bo(!1),[u,C]=bo(!1),h=t.attributes||{},g=h.colors||[],b=h.sizes||[],m=h.imageUrls||[t.image],E=h.description||"";ea(()=>{b.length>0&&s(b[0]),C(!0)},[b]);let O=()=>{let k={productId:t.productId||t.id,title:t.title,selectedSize:i,selectedColor:g[l]?.name,quantity:d,price:t.price};n(k);let B=t.redirectUrl||t.url;if(B){!B.startsWith("http")&&!B.startsWith("//")&&(B="https://"+B);try{window.open(B,"_blank","noopener,noreferrer")}catch(W){console.error("AppStorys: Redirect failed",W)}}y(!0)},D=()=>{C(!1),setTimeout(o,400)},L=e?.buttonBackground||"#000000",v=e?.buttonTextColor||"#ffffff",w=e?.titleColor||e?.textColor||"#1a1a2e",_=e?.priceColor||e?.textColor||"#1a1a2e",$=e?.mrpColor||"#8b8b98",V=e?.titleFontWeight||"600",A=e?.priceFontWeight||"700",T=e?.mrpFontWeight||"500";return p?wt("div",{className:"appstorys-shopable-success-overlay",style:fr,children:[at("div",{className:"appstorys-shopable-backdrop",style:mr,onClick:D}),wt("div",{className:"appstorys-shopable-sheet",style:{...yr,height:"auto",minHeight:"310px",animation:"appstorys-slide-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[at("div",{style:hr,onClick:D}),wt("div",{style:{padding:"0 20px 24px",textAlign:"center"},children:[wt("div",{style:{backgroundColor:"#F3F4F6",borderRadius:"20px",padding:"22px",marginTop:"16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[wt("h3",{style:{margin:0,fontSize:"16px",fontWeight:"600",lineHeight:"1.4"},children:["Added to your bag",at("br",{}),"successfully"]}),at("svg",{width:"44",height:"26",viewBox:"0 0 44 26",fill:"none",children:at("path",{d:"M4 4C4 4 11 22 22 22C33 22 40 4 40 4",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round"})})]}),wt("div",{style:{marginTop:"24px",display:"flex",flexDirection:"column",gap:"8px"},children:[at("button",{onClick:D,style:{...Un,backgroundColor:"#000000",color:"#ffffff",padding:"17px",fontSize:"16px",fontWeight:"600"},children:wt("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[wt("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[at("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),at("path",{d:"M3 6h18"}),at("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),"Go to checkout"]})}),at("button",{onClick:D,style:{...Un,backgroundColor:"transparent",color:"#000000",border:"1px solid rgba(0,0,0,0.1)",padding:"15px",fontSize:"16px"},children:"Continue with stories"})]})]})]})]}):wt("div",{className:`appstorys-shopable-overlay ${u?"visible":""}`,style:fr,children:[at("div",{className:"appstorys-shopable-backdrop",style:mr,onClick:D}),wt("div",{className:"appstorys-shopable-sheet",style:{...yr,transform:u?"translateY(0)":"translateY(100%)",opacity:u?1:0},children:[wt("div",{style:oa,children:[at("div",{style:hr,onClick:D}),at("button",{style:na,onClick:D,children:wt("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[at("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),at("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),wt("div",{style:ia,children:[at("div",{style:ra,children:m.map((k,B)=>at("div",{style:{minWidth:m.length>1?"85%":"100%",aspectRatio:"1.2 / 1",maxHeight:"240px",borderRadius:"16px",overflow:"hidden",backgroundColor:"#F9FAFB"},children:at("img",{src:k,alt:t.title,style:{width:"100%",height:"100%",objectFit:"contain"}})},B))}),wt("div",{style:{padding:"0 20px 20px"},children:[at("h2",{style:{margin:"16px 0 4px",fontSize:e?.titleFontSize?ot(e.titleFontSize):"20px",fontWeight:V,color:w,lineHeight:"1.2"},children:t.title}),wt("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",marginBottom:"16px"},children:[at("span",{style:{fontSize:e?.priceFontSize?ot(e.priceFontSize):"18px",fontWeight:A,color:_},children:t.price}),t.oldPrice&&at("span",{style:{fontSize:e?.mrpFontSize?ot(e.mrpFontSize):"14px",color:$,textDecoration:"line-through",fontWeight:T},children:t.oldPrice})]}),g.length>0&&wt("div",{style:Hn,children:[at("div",{style:Vn,children:"COLOR"}),at("div",{style:{display:"flex",gap:"14px",marginTop:"12px"},children:g.map((k,B)=>wt("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"5px"},children:[at("button",{onClick:()=>c(B),style:{width:"36px",height:"36px",borderRadius:"50%",border:"none",backgroundColor:k.hex||"#gray",position:"relative",cursor:"pointer",boxShadow:l===B?"0 0 0 2px #fff, 0 0 0 4px #000":"none",transition:"all 0.2s ease"}}),at("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:l===B?"#000":"transparent",transition:"all 0.2s ease"}})]},k.id))})]}),b.length>0&&wt("div",{style:Hn,children:[at("div",{style:Vn,children:"SIZE"}),at("div",{style:{display:"flex",gap:"10px",marginTop:"12px",flexWrap:"wrap"},children:b.map(k=>wt("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},children:[at("button",{onClick:()=>s(k),style:{minWidth:"42px",height:"42px",borderRadius:"50%",backgroundColor:"transparent",border:`1px solid ${i===k?"#000":"rgba(0,0,0,0.1)"}`,color:i===k?"#000":"#8b8b98",fontSize:"13px",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:k}),at("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:i===k?"#000":"transparent",transition:"all 0.2s ease"}})]},k))})]}),E&&wt("div",{style:Hn,children:[at("div",{style:Vn,children:"DESCRIPTION"}),at("p",{style:{margin:"8px 0 0",fontSize:"14px",lineHeight:"1.5",color:"#8b8b98",wordBreak:"break-word"},children:E})]})]})]}),wt("div",{style:sa,children:[wt("div",{style:{display:"flex",flexDirection:"column",gap:"1px",minWidth:"75px"},children:[at("div",{style:{fontSize:"15px",fontWeight:A,color:_},children:t.price}),t.oldPrice&&at("div",{style:{fontSize:"11px",color:$,textDecoration:"line-through",fontWeight:T},children:t.oldPrice})]}),wt("div",{style:aa,children:[at("button",{style:br,onClick:()=>S(k=>Math.max(1,k-1)),children:at("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:at("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}),at("span",{style:{fontSize:"16px",fontWeight:"700",minWidth:"18px",textAlign:"center",color:"#000000",display:"inline-block"},children:d}),at("button",{style:br,onClick:()=>S(k=>k+1),children:wt("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[at("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),at("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),(()=>{let k=h.availability?.toLowerCase()||"",B=k==="out of stock"||k==="out-of-stock";return wt("button",{onClick:B?void 0:O,disabled:B,style:{...Un,backgroundColor:B?"#F3F4F6":L,color:B?"#9CA3AF":v,flex:"1",padding:"12px 8px",gap:"6px",cursor:B?"not-allowed":"pointer",opacity:B?.8:1},children:[!B&&wt("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[at("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),at("path",{d:"M3 6h18"}),at("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),at("span",{style:{fontSize:"12px",fontWeight:"700",whiteSpace:"nowrap"},children:B?"Out of Stock":"Add to cart"})]})})()]})]}),at("style",{children:`
71
+ `}),un("h3",{style:h,children:t.title||"Do you like my space?"}),ti("div",{ref:c,style:T,onMouseDown:U,onTouchStart:z,children:[un("div",{style:X}),ti("div",{style:x,className:"interactive-emoji-thumb",children:[t.emoji||"\u{1F60D}",f.map(B=>{let K=60+Math.random()*80,v=B.angle*Math.PI/180,A=`${Math.cos(v)*K}px`,H=`${Math.sin(v)*K}px`;return un("span",{style:{position:"absolute",left:"50%",top:"50%",width:"30px",height:"30px",marginLeft:"-15px",marginTop:"-15px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"24px",pointerEvents:"none",zIndex:100,animation:`emojiBurst 1s cubic-bezier(0.15, 0.85, 0.35, 1) ${B.delay}s forwards`,"--tx":A,"--ty":H,"--scale":B.scale},children:t.emoji||"\u{1F60D}"},B.id)})]})]})]})};import{useState as kr}from"react";import{jsx as Bo,jsxs as ei}from"react/jsx-runtime";var Rr=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=kr(()=>{try{return localStorage.getItem(`appstorys_question_${t.id}`)||""}catch{return""}}),[s,d]=kr(()=>{try{return localStorage.getItem(`appstorys_question_${t.id}`)!==null}catch{return!1}}),c={backgroundColor:"#FFFFFF",borderRadius:16,padding:16,promptColor:"#111111",inputBgColor:"#FFFFFF",borderColor:"#EFEFEF",textColor:"#333333",placeholderColor:"#A0AEC0"},l=t.styling||{},y=ut(l.questionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),u=ut(l.optionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),m={backgroundColor:l.backgroundColor||c.backgroundColor,borderRadius:nt(l.borderRadius??c.borderRadius),padding:l.padding?nt(l.padding):"10px 12px",boxShadow:l.shadow||"0 8px 24px rgba(0,0,0,0.06)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",border:`1px solid ${l.borderColor||"#F0F0F0"}`},f={color:l.promptColor||c.promptColor,fontWeight:"700",fontSize:nt(l.fontSize||16),fontFamily:y,textAlign:"center",marginBottom:"2px",width:"100%"},P={width:"100%",position:"relative",display:"flex",alignItems:"center"},g=l.optionRadius??l.inputBorderRadius??l.optionBorderRadius??l.inputRadius,b=g!==void 0?typeof g=="number"&&g>=5?"9999px":nt(g):"9999px",R={backgroundColor:l.inputBgColor||"#F1F3F5",border:"none",borderRadius:b,padding:"8px 36px 8px 14px",width:"100%",boxSizing:"border-box",color:l.inputTextColor||"#1A202C",fontSize:"13px",fontFamily:u,outline:"none",textAlign:"left",cursor:o?"default":"text",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},C={position:"absolute",right:"4px",background:l.submitBackground||"#FE6B35",color:"white",border:"none",borderRadius:"50%",width:"24px",height:"24px",display:n.length>0&&!s?"flex":"none",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"transform 0.2s"},h=E=>{o||s||i(E.target.value)},T=()=>{if(!(o||!n.trim()||s)){d(!0);try{localStorage.setItem(`appstorys_question_${t.id}`,n.trim())}catch{}e?.({type:"question",questionId:t.id,value:n.trim(),stickerId:t.id})}};return ei("div",{style:m,children:[Bo("div",{style:f,children:t.question||"Ask me anything"}),ei("div",{style:P,children:[Bo("input",{type:"text",value:n,placeholder:s?"Submitted!":t.placeholder||"Type your answer...",style:R,disabled:o||s,onChange:h,onKeyDown:E=>E.key==="Enter"&&T()}),Bo("button",{style:C,onClick:T,children:ei("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[Bo("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),Bo("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})};import{useState as Ca}from"react";import{jsx as Ao,jsxs as oi}from"react/jsx-runtime";var Tr=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=Ca(()=>{try{return localStorage.getItem(`appstorys_image_quiz_${t.id}`)}catch{return null}}),s={backgroundColor:"#FFFFFF",borderRadius:16,padding:10,optionBgColor:"#F8FAFC",optionTextColor:"#0F172A",borderColor:"#E2E8F0",activeColor:"#10B981",incorrectColor:"#EF4444"},d=t.styling||{},c=nt(d.padding??s.padding),l=nt(d.borderRadius??s.borderRadius),y=ut(d.questionFontFamily||d.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),u=ut(d.optionFontFamily||d.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),m={backgroundColor:d.backgroundColor||s.backgroundColor,borderRadius:l,padding:c,boxShadow:d.shadow||"0 12px 32px rgba(0,0,0,0.12)",boxSizing:"border-box",width:"100%",maxWidth:"280px",margin:"0 auto",display:"flex",flexDirection:"column",opacity:d.opacity??1,border:d.borderColor?`1px solid ${d.borderColor}`:"none",overflow:"hidden"},f={color:d.questionTextColor||"#FFFFFF",backgroundColor:d.questionBgColor||"#000000",fontWeight:"800",fontSize:nt(d.fontSize||15),fontFamily:y,margin:`calc(-1 * ${c}) calc(-1 * ${c}) 8px calc(-1 * ${c})`,padding:`12px ${c} 10px ${c}`,textAlign:"center",borderTopLeftRadius:l,borderTopRightRadius:l},b={display:"grid",gridTemplateColumns:`repeat(${(I=>{if(typeof I=="number"&&!isNaN(I)&&I>0)return I;if(typeof I=="string"){let S=parseInt(I,10);if(!isNaN(S)&&S>0)return S}if(typeof I=="object"&&I!==null){let S=I.columns||I.cols||I.columnCount;if(typeof S=="number"&&!isNaN(S)&&S>0)return S;if(typeof S=="string"){let M=parseInt(S,10);if(!isNaN(M)&&M>0)return M}}return 2})(t.layout??d.layout??d.columns)}, 1fr)`,gap:"6px",width:"100%"},R=nt(d.optionRadius??d.optionBorderRadius??d.imageRadius??14),C={backgroundColor:d.optionBgColor||s.optionBgColor,color:d.optionTextColor||s.optionTextColor,fontFamily:u,borderRadius:R,border:`2px solid ${d.borderColor||s.borderColor}`,cursor:n?"default":"pointer",display:"flex",flexDirection:"column",alignItems:"center",padding:"6px",boxSizing:"border-box",transition:"all 0.2s ease",overflow:"hidden"},h=I=>{if(!(o||n)){i(I);try{localStorage.setItem(`appstorys_image_quiz_${t.id}`,I)}catch{}e?.({type:"image",quizId:t.id,optionId:I,stickerId:t.id})}},T="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Crect width='100%25' height='100%25' fill='%23EDF2F7'/%3E%3Cpath d='M30 40 L40 30 L50 40 L60 30 L70 40 V60 H30 Z' fill='%23A0AEC0'/%3E%3Ccircle cx='40' cy='45' r='5' fill='%23FFFFFF'/%3E%3C/svg%3E",E=["A","B","C","D","E","F"],X=Array.isArray(t.options)?t.options:[];return X.length===0&&!o&&console.warn("AppStorys: ImageQuizSticker has no options!",t.id),oi("div",{style:{...m,background:d.backgroundColor||s.backgroundColor},children:[t.question&&Ao("h3",{style:f,children:t.question}),Ao("div",{style:b,children:X.map((I,S)=>{let M=I.id===n,x=I.isCorrect===!0,N=d.borderColor||s.borderColor,U=d.optionBgColor||s.optionBgColor;n&&(x?(N=d.activeColor||s.activeColor,U="rgba(16, 185, 129, 0.08)"):M&&(N=d.incorrectColor||s.incorrectColor,U="rgba(239, 68, 68, 0.08)"));let z=n?x?d.activeColor||s.activeColor:M?d.incorrectColor||s.incorrectColor:d.labelColor||d.optionTextColor||s.optionTextColor:d.labelColor||d.optionTextColor||s.optionTextColor;return oi("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%",boxSizing:"border-box"},children:[oi("button",{style:{width:"100%",aspectRatio:"1",borderRadius:R,border:`2px solid ${N}`,backgroundColor:U,overflow:"hidden",cursor:n?"default":"pointer",position:"relative",padding:0,margin:0,outline:"none",transition:"transform 0.2s ease, border-color 0.2s ease",boxSizing:"border-box"},onClick:()=>h(I.id),disabled:!!n,onMouseOver:O=>{!o&&!n&&(O.currentTarget.style.transform="scale(1.02)")},onMouseOut:O=>{!o&&!n&&(O.currentTarget.style.transform="scale(1)")},children:[Ao("img",{src:I.image||T,alt:I.text,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),n&&Ao("div",{style:{position:"absolute",top:"6px",right:"6px",width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:x?d.activeColor||s.activeColor:M?d.incorrectColor||s.incorrectColor:"#A0AEC0",color:"#FFFFFF",fontSize:"12px",fontWeight:"bold",boxShadow:"0 2px 6px rgba(0,0,0,0.2)"},children:x?"\u2713":M?"\u2715":""})]}),Ao("span",{style:{marginTop:"6px",fontWeight:"600",fontSize:nt(d.optionFontSize||13),color:z,fontFamily:u,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:I.text})]},I.id)})})]})};import{useState as Er}from"react";import{useState as Lo,useEffect as va}from"react";import{jsx as pt,jsxs as zt}from"react/jsx-runtime";var Lr=({product:t,styling:e,onClose:o,onAddToCart:n})=>{let[i,s]=Lo(""),[d,c]=Lo(0),[l,y]=Lo(1),[u,m]=Lo(!1),[f,P]=Lo(!1),g=t.attributes||{},b=g.colors||[],R=g.sizes||[],C=g.imageUrls||[t.image],h=g.description||"";va(()=>{R.length>0&&s(R[0]),P(!0)},[R]);let T=()=>{let O={productId:t.productId||t.id,title:t.title,selectedSize:i,selectedColor:b[d]?.name,quantity:l,price:t.price};n(O);let B=t.redirectUrl||t.url;if(B){if(wt(B)){E();return}!B.startsWith("http")&&!B.startsWith("//")&&(B="https://"+B);try{window.open(B,"_blank","noopener,noreferrer")}catch(K){console.error("AppStorys: Redirect failed",K)}}m(!0)},E=()=>{P(!1),setTimeout(o,400)},X=e?.buttonBackground||"#000000",I=e?.buttonTextColor||"#ffffff",S=e?.titleColor||e?.textColor||"#1a1a2e",M=e?.priceColor||e?.textColor||"#1a1a2e",x=e?.mrpColor||"#8b8b98",N=e?.titleFontWeight||"600",U=e?.priceFontWeight||"700",z=e?.mrpFontWeight||"500";return u?zt("div",{className:"appstorys-shopable-success-overlay",style:Fr,children:[pt("div",{className:"appstorys-shopable-backdrop",style:Ir,onClick:E}),zt("div",{className:"appstorys-shopable-sheet",style:{...zr,height:"auto",minHeight:"310px",animation:"appstorys-slide-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[pt("div",{style:Br,onClick:E}),zt("div",{style:{padding:"0 20px 24px",textAlign:"center"},children:[zt("div",{style:{backgroundColor:"#F3F4F6",borderRadius:"20px",padding:"22px",marginTop:"16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[zt("h3",{style:{margin:0,fontSize:"16px",fontWeight:"600",lineHeight:"1.4"},children:["Added to your bag",pt("br",{}),"successfully"]}),pt("svg",{width:"44",height:"26",viewBox:"0 0 44 26",fill:"none",children:pt("path",{d:"M4 4C4 4 11 22 22 22C33 22 40 4 40 4",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round"})})]}),zt("div",{style:{marginTop:"24px",display:"flex",flexDirection:"column",gap:"8px"},children:[pt("button",{onClick:E,style:{...ri,backgroundColor:"#000000",color:"#ffffff",padding:"17px",fontSize:"16px",fontWeight:"600"},children:zt("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[zt("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[pt("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),pt("path",{d:"M3 6h18"}),pt("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),"Go to checkout"]})}),pt("button",{onClick:E,style:{...ri,backgroundColor:"transparent",color:"#000000",border:"1px solid rgba(0,0,0,0.1)",padding:"15px",fontSize:"16px"},children:"Continue with stories"})]})]})]})]}):zt("div",{className:`appstorys-shopable-overlay ${f?"visible":""}`,style:Fr,children:[pt("div",{className:"appstorys-shopable-backdrop",style:Ir,onClick:E}),zt("div",{className:"appstorys-shopable-sheet",style:{...zr,transform:f?"translateY(0)":"translateY(100%)",opacity:f?1:0},children:[zt("div",{style:wa,children:[pt("div",{style:Br,onClick:E}),pt("button",{style:ka,onClick:E,children:zt("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[pt("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),pt("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),zt("div",{style:Ra,children:[pt("div",{style:Ta,children:C.map((O,B)=>pt("div",{style:{minWidth:C.length>1?"85%":"100%",aspectRatio:"1.2 / 1",maxHeight:"240px",borderRadius:"16px",overflow:"hidden",backgroundColor:"#F9FAFB"},children:pt("img",{src:O,alt:t.title,style:{width:"100%",height:"100%",objectFit:"contain"}})},B))}),zt("div",{style:{padding:"0 20px 20px"},children:[pt("h2",{style:{margin:"16px 0 4px",fontSize:e?.titleFontSize?nt(e.titleFontSize):"20px",fontWeight:N,color:S,lineHeight:"1.2"},children:t.title}),zt("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",marginBottom:"16px"},children:[pt("span",{style:{fontSize:e?.priceFontSize?nt(e.priceFontSize):"18px",fontWeight:U,color:M},children:t.price}),t.oldPrice&&pt("span",{style:{fontSize:e?.mrpFontSize?nt(e.mrpFontSize):"14px",color:x,textDecoration:"line-through",fontWeight:z},children:t.oldPrice})]}),b.length>0&&zt("div",{style:ni,children:[pt("div",{style:ii,children:"COLOR"}),pt("div",{style:{display:"flex",gap:"14px",marginTop:"12px"},children:b.map((O,B)=>zt("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"5px"},children:[pt("button",{onClick:()=>c(B),style:{width:"36px",height:"36px",borderRadius:"50%",border:"none",backgroundColor:O.hex||"#gray",position:"relative",cursor:"pointer",boxShadow:d===B?"0 0 0 2px #fff, 0 0 0 4px #000":"none",transition:"all 0.2s ease"}}),pt("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:d===B?"#000":"transparent",transition:"all 0.2s ease"}})]},O.id))})]}),R.length>0&&zt("div",{style:ni,children:[pt("div",{style:ii,children:"SIZE"}),pt("div",{style:{display:"flex",gap:"10px",marginTop:"12px",flexWrap:"wrap"},children:R.map(O=>zt("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},children:[pt("button",{onClick:()=>s(O),style:{minWidth:"42px",height:"42px",borderRadius:"50%",backgroundColor:"transparent",border:`1px solid ${i===O?"#000":"rgba(0,0,0,0.1)"}`,color:i===O?"#000":"#8b8b98",fontSize:"13px",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:O}),pt("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:i===O?"#000":"transparent",transition:"all 0.2s ease"}})]},O))})]}),h&&zt("div",{style:ni,children:[pt("div",{style:ii,children:"DESCRIPTION"}),pt("p",{style:{margin:"8px 0 0",fontSize:"14px",lineHeight:"1.5",color:"#8b8b98",wordBreak:"break-word"},children:h})]})]})]}),zt("div",{style:Fa,children:[zt("div",{style:{display:"flex",flexDirection:"column",gap:"1px",minWidth:"75px"},children:[pt("div",{style:{fontSize:"15px",fontWeight:U,color:M},children:t.price}),t.oldPrice&&pt("div",{style:{fontSize:"11px",color:x,textDecoration:"line-through",fontWeight:z},children:t.oldPrice})]}),zt("div",{style:Ia,children:[pt("button",{style:Ar,onClick:()=>y(O=>Math.max(1,O-1)),children:pt("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:pt("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}),pt("span",{style:{fontSize:"16px",fontWeight:"700",minWidth:"18px",textAlign:"center",color:"#000000",display:"inline-block"},children:l}),pt("button",{style:Ar,onClick:()=>y(O=>O+1),children:zt("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[pt("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),pt("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),(()=>{let O=g.availability?.toLowerCase()||"",B=O==="out of stock"||O==="out-of-stock";return zt("button",{onClick:B?void 0:T,disabled:B,style:{...ri,backgroundColor:B?"#F3F4F6":X,color:B?"#9CA3AF":I,flex:"1",padding:"12px 8px",gap:"6px",cursor:B?"not-allowed":"pointer",opacity:B?.8:1},children:[!B&&zt("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[pt("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),pt("path",{d:"M3 6h18"}),pt("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),pt("span",{style:{fontSize:"12px",fontWeight:"700",whiteSpace:"nowrap"},children:B?"Out of Stock":"Add to cart"})]})})()]})]}),pt("style",{children:`
72
72
  @keyframes appstorys-slide-up {
73
73
  from { transform: translateY(100%); }
74
74
  to { transform: translateY(0); }
@@ -81,10 +81,10 @@ var ls=Object.defineProperty;var Me=(t,e)=>()=>(t&&(e=t(t=0)),e);var ds=(t,e)=>{
81
81
  .appstorys-shopable-overlay.visible {
82
82
  visibility: visible;
83
83
  }
84
- `})]})},fr={position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4,display:"flex",alignItems:"flex-end",justifyContent:"center",pointerEvents:"auto",fontFamily:"'Inter', system-ui, -apple-system, sans-serif",width:"100%",height:"100%",boxSizing:"border-box"},mr={position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.45)",cursor:"pointer"},yr={position:"relative",width:"100%",maxWidth:"500px",backgroundColor:"#fff",borderTopLeftRadius:"28px",borderTopRightRadius:"28px",borderBottomLeftRadius:0,borderBottomRightRadius:0,maxHeight:"60vh",display:"flex",flexDirection:"column",margin:0,transition:"transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s ease",boxShadow:"0 -8px 24px rgba(0,0,0,0.15)",overflow:"hidden",boxSizing:"border-box"},oa={height:"48px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0},hr={width:"36px",height:"5px",backgroundColor:"rgba(0,0,0,0.1)",borderRadius:"3px",cursor:"pointer"},na={position:"absolute",right:"18px",top:"16px",border:"none",width:"28px",height:"28px",borderRadius:"50%",backgroundColor:"#F3F4F6",display:"flex",alignItems:"center",justifyContent:"center",color:"#666",cursor:"pointer"},ia={flex:1,overflowY:"auto",WebkitOverflowScrolling:"touch"},ra={padding:"0 16px 20px",display:"flex",gap:"8px",overflowX:"auto",scrollSnapType:"x mandatory"},Hn={marginTop:"20px"},Vn={fontSize:"11px",fontWeight:"600",color:"rgba(0,0,0,0.5)",letterSpacing:"1.4px"},sa={padding:"12px 16px calc(20px + env(safe-area-inset-bottom, 0px))",borderTop:"1px solid rgba(0,0,0,0.05)",display:"flex",alignItems:"center",gap:"8px",backgroundColor:"#fff",boxShadow:"0 -4px 12px rgba(0,0,0,0.06)",zIndex:10,boxSizing:"border-box"},aa={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"100px",border:"1px solid rgba(0,0,0,0.1)"},br={border:"none",backgroundColor:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},Un={border:"none",borderRadius:"100px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"};import{Fragment as la,jsx as ke,jsxs as xo}from"react/jsx-runtime";var Cr=({data:t,onInteraction:e,isEditing:o})=>{let{products:n,styling:i}=t,[s,l]=Sr(!1),[c,d]=Sr(null),S=(g,b)=>{if(g.stopPropagation(),o)return;if(t.shopableType==="product"){d(b),l(!0),e&&e({type:"product_view",stickerId:t.id,productId:b.productId||b.id,value:b.title});return}let m=b.redirectUrl||b.url;if(m&&!m.startsWith("http")&&!m.startsWith("//")&&(m="https://"+m),e&&e({type:"buy",stickerId:t.id,productId:b.id,value:b.title,selected_option:m}),m)try{window.open(m,"_blank","noopener,noreferrer")}catch(E){console.error("AppStorys: Redirect failed",E),window.location.href=m}},p=g=>{e&&e({type:"add_to_cart",stickerId:t.id,productId:g.productId,value:g.title,selected_option:JSON.stringify({size:g.selectedSize,color:g.selectedColor,quantity:g.quantity})})},y={width:"100%",height:"100%",display:"flex",gap:"12px",overflowX:"auto",padding:"0 1px",scrollSnapType:"x mandatory",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",pointerEvents:"auto"},u={flex:"0 0 auto",width:"100%",backgroundColor:i?.cardBackground||"#ffffff",borderRadius:i?.cardBorderRadius!==void 0?ot(i.cardBorderRadius):i?.cardRadiusPercent!==void 0?`${i.cardRadiusPercent}%`:"12px",overflow:"hidden",boxShadow:i?.shadow||"0 -2px 12px rgba(0,0,0,0.12)",display:"flex",flexDirection:"row",alignItems:"center",padding:"8px 12px",position:"relative",scrollSnapAlign:"center",transition:"transform 0.2s ease",cursor:"pointer",boxSizing:"border-box",pointerEvents:"auto",opacity:i?.opacity??1,marginBottom:0},C={width:"64px",height:"64px",borderRadius:i?.imageRadius!==void 0?ot(i.imageRadius):"12px",overflow:"hidden",backgroundColor:"#f5f5f5",flexShrink:0},h={flex:1,display:"flex",flexDirection:"column",justifyContent:"center",padding:"0 12px",minWidth:0};return xo(la,{children:[xo("div",{style:y,className:"shopable-container",children:[ke("style",{children:`
84
+ `})]})},Fr={position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4,display:"flex",alignItems:"flex-end",justifyContent:"center",pointerEvents:"auto",fontFamily:"'Inter', system-ui, -apple-system, sans-serif",width:"100%",height:"100%",boxSizing:"border-box"},Ir={position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.45)",cursor:"pointer"},zr={position:"relative",width:"100%",maxWidth:"500px",backgroundColor:"#fff",borderTopLeftRadius:"28px",borderTopRightRadius:"28px",borderBottomLeftRadius:0,borderBottomRightRadius:0,maxHeight:"60vh",display:"flex",flexDirection:"column",margin:0,transition:"transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s ease",boxShadow:"0 -8px 24px rgba(0,0,0,0.15)",overflow:"hidden",boxSizing:"border-box"},wa={height:"48px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0},Br={width:"36px",height:"5px",backgroundColor:"rgba(0,0,0,0.1)",borderRadius:"3px",cursor:"pointer"},ka={position:"absolute",right:"18px",top:"16px",border:"none",width:"28px",height:"28px",borderRadius:"50%",backgroundColor:"#F3F4F6",display:"flex",alignItems:"center",justifyContent:"center",color:"#666",cursor:"pointer"},Ra={flex:1,overflowY:"auto",WebkitOverflowScrolling:"touch"},Ta={padding:"0 16px 20px",display:"flex",gap:"8px",overflowX:"auto",scrollSnapType:"x mandatory"},ni={marginTop:"20px"},ii={fontSize:"11px",fontWeight:"600",color:"rgba(0,0,0,0.5)",letterSpacing:"1.4px"},Fa={padding:"12px 16px calc(20px + env(safe-area-inset-bottom, 0px))",borderTop:"1px solid rgba(0,0,0,0.05)",display:"flex",alignItems:"center",gap:"8px",backgroundColor:"#fff",boxShadow:"0 -4px 12px rgba(0,0,0,0.06)",zIndex:10,boxSizing:"border-box"},Ia={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"100px",border:"1px solid rgba(0,0,0,0.1)"},Ar={border:"none",backgroundColor:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},ri={border:"none",borderRadius:"100px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"};import{Fragment as za,jsx as Me,jsxs as Eo}from"react/jsx-runtime";var Pr=({data:t,onInteraction:e,isEditing:o})=>{let{products:n,styling:i}=t,[s,d]=Er(!1),[c,l]=Er(null),y=(b,R)=>{if(b.stopPropagation(),o)return;if(t.shopableType==="product"){l(R),d(!0),e&&e({type:"product_view",stickerId:t.id,productId:R.productId||R.id,value:R.title});return}let C=R.redirectUrl||R.url;if(!(C&&wt(C))&&(C&&!C.startsWith("http")&&!C.startsWith("//")&&(C="https://"+C),e&&e({type:"buy",stickerId:t.id,productId:R.id,value:R.title,selected_option:C}),C))try{window.open(C,"_blank","noopener,noreferrer")}catch(h){console.error("AppStorys: Redirect failed",h),window.location.href=C}},u=b=>{e&&e({type:"add_to_cart",stickerId:t.id,productId:b.productId,value:b.title,selected_option:JSON.stringify({size:b.selectedSize,color:b.selectedColor,quantity:b.quantity})})},m={width:"100%",height:"100%",display:"flex",gap:"12px",overflowX:"auto",padding:"0 1px",scrollSnapType:"x mandatory",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",pointerEvents:"auto"},f={flex:"0 0 auto",width:"100%",backgroundColor:i?.cardBackground||"#ffffff",borderRadius:i?.cardBorderRadius!==void 0?nt(i.cardBorderRadius):i?.cardRadiusPercent!==void 0?`${i.cardRadiusPercent}%`:"12px",overflow:"hidden",boxShadow:i?.shadow||"0 -2px 12px rgba(0,0,0,0.12)",display:"flex",flexDirection:"row",alignItems:"center",padding:"8px 12px",position:"relative",scrollSnapAlign:"center",transition:"transform 0.2s ease",cursor:"pointer",boxSizing:"border-box",pointerEvents:"auto",opacity:i?.opacity??1,marginBottom:0},P={width:"64px",height:"64px",borderRadius:i?.imageRadius!==void 0?nt(i.imageRadius):"12px",overflow:"hidden",backgroundColor:"#f5f5f5",flexShrink:0},g={flex:1,display:"flex",flexDirection:"column",justifyContent:"center",padding:"0 12px",minWidth:0};return Eo(za,{children:[Eo("div",{style:m,className:"shopable-container",children:[Me("style",{children:`
85
85
  .shopable-container::-webkit-scrollbar { display: none; }
86
86
  .shopable-card:active { transform: scale(0.98); }
87
- `}),n.map(g=>xo("div",{style:u,className:"shopable-card",onClick:b=>S(b,g),children:[ke("div",{style:C,children:ke("img",{src:g.image,alt:g.title,style:{width:"100%",height:"100%",objectFit:"cover"}})}),xo("div",{style:h,children:[ke("span",{style:{color:i?.titleColor||i?.textColor||"#1a1b2e",fontSize:i?.titleFontSize?ot(i.titleFontSize):"15px",fontWeight:i?.titleFontWeight||"700",lineHeight:"1.2",display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"1px"},children:g.title}),xo("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",flexWrap:"wrap"},children:[ke("span",{style:{color:i?.priceColor||i?.textColor||"#1a1b2e",fontSize:i?.priceFontSize?ot(i.priceFontSize):"18px",fontWeight:i?.priceFontWeight||"800",display:"block"},children:g.price}),g.oldPrice&&ke("span",{style:{color:i?.mrpColor||"#8b8b98",fontSize:i?.mrpFontSize?ot(i.mrpFontSize):"12px",fontWeight:i?.mrpFontWeight||"500",textDecoration:"line-through"},children:g.oldPrice})]})]}),ke("div",{style:{backgroundColor:i?.buttonBackground||"#000000",color:i?.buttonTextColor||"#ffffff",fontSize:i?.buttonFontSize?ot(i.buttonFontSize):"14px",fontWeight:"700",padding:"10px 18px",borderRadius:i?.buttonBorderRadius!==void 0?ot(i.buttonBorderRadius):"100px",textAlign:"center",flexShrink:0,whiteSpace:"nowrap"},children:"Buy Now"})]},g.id))]}),s&&c&&ke(xr,{product:c,styling:i,onClose:()=>l(!1),onAddToCart:p})]})};import{Fragment as ua,jsx as It,jsxs as Yn}from"react/jsx-runtime";var wr=Ye.default?.default??Ye.default??Ye.Lottie??Ye,ca=({url:t,animationData:e,loop:o=!0,autoplay:n=!0,styling:i={}})=>{let[s,l]=vr(e||null),[c,d]=vr(!1);da(()=>{if(e){l(e);return}t&&(d(!1),fetch(t).then(y=>{if(!y.ok)throw new Error(`Failed to fetch Lottie JSON (${y.status})`);return y.json()}).then(y=>{l(y),d(!1)}).catch(y=>{console.error("AppStorys: Error loading Lottie sticker from URL:",t,y),d(!0)}))},[t,e]);let S={width:"100%",height:"100%",display:"block",borderRadius:ot(i.borderRadius||"0px"),border:i.border||"none",boxShadow:i.boxShadow||"none",opacity:i.opacity??1,transform:i.transform||void 0,overflow:"hidden"};if(!s)return It("div",{style:S});let p=wr.default||wr;return It(p,{animationData:s,loop:o,autoplay:n,style:S,rendererSettings:{preserveAspectRatio:"xMidYMid meet"}})},kr=({data:t,onInteraction:e,isEditing:o=!1})=>{let n={x:10,y:15,width:80,rotation:0},i=t.x??n.x,s=t.y??n.y,l=t.width??n.width,c=t.rotation??n.rotation,d={position:"absolute",top:`${s}%`,left:`${i}%`,width:`${l}%`,height:t.height?`${t.height}%`:"auto",transform:`rotate(${c}deg)`,zIndex:10,transformOrigin:"center center",boxSizing:"border-box",cursor:o?"move":"default",pointerEvents:"auto"},S={width:"100%",height:"100%",animation:t.styling?.animation,animationFillMode:"forwards"},p=()=>{switch(t.type){case"poll":return It(er,{data:t,onInteraction:e,isEditing:o});case"quiz":return It(or,{data:t,onInteraction:e,isEditing:o});case"rating":return It(cr,{data:t,onInteraction:e,isEditing:o});case"question":case"input":return It(pr,{data:t,onInteraction:e,isEditing:o});case"image_quiz":return It(gr,{data:t,onInteraction:e,isEditing:o});case"countdown":return It(ir,{data:t,onInteraction:e,isEditing:o});case"promo_code":case"promo":return It(sr,{data:t,onInteraction:e,isEditing:o});case"reaction":return It(dr,{data:t,onInteraction:e,isEditing:o});case"lottie":return It(ca,{url:t.url,loop:t.loop,autoplay:t.autoplay,styling:t.styling});case"buy":case"shopable":return It(Cr,{data:t,onInteraction:e,isEditing:o});case"video":{let u=t.styling||{};return It("video",{src:t.url,autoPlay:!0,loop:t.loop!==!1,muted:t.muted!==!1,playsInline:!0,style:{width:"100%",height:"100%",objectFit:u.objectFit||"cover",objectPosition:u.objectPosition||"center center",borderRadius:ot(u.borderRadius||"0px"),border:u.border||"none",boxShadow:u.boxShadow||"none",opacity:u.opacity??1,display:"block",overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"}})}case"shape":case"gif":case"svg":case"sticker":case"image":{let u=t.styling||{};return It("img",{src:t.url,alt:"static overlay",style:{width:"100%",height:"100%",objectFit:u.objectFit||"cover",objectPosition:u.objectPosition||"center center",borderRadius:u.borderRadius||"0px",border:u.border||"none",boxShadow:u.boxShadow||"none",opacity:u.opacity??1,display:"block",overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"}})}case"text":{let u=t.styling||{},C=u.verticalAlignment,h=u.textAlign,g=u.lineHeight,b="1.25";if(g!=null&&g!==""){let m=Number(g);isNaN(m)?b=String(g):b=m<=5?String(m):"1.25"}return It("div",{style:{color:u.color||"#000000",fontSize:ot(u.fontSize||14),fontFamily:st(u.fontFamily)||"Arial",fontStyle:u.fontStyle||"normal",fontWeight:u.fontWeight||"normal",textDecoration:u.textDecoration||"none",lineHeight:b,letterSpacing:u.letterSpacing||"normal",opacity:u.opacity??1,wordBreak:"break-word",whiteSpace:"pre-wrap",width:"100%",height:"100%",display:"flex",alignItems:C==="middle"||C==="center"?"center":C==="bottom"?"flex-end":"flex-start",justifyContent:h==="center"?"center":h==="right"?"flex-end":"flex-start",textAlign:h||"left"},children:t.text})}case"cta":{let u=t.styling||{};if(t.ctaType==="image")return It("button",{onClick:v=>{v.stopPropagation(),e&&e({type:"cta",stickerId:t.id,redirectUrl:t.redirectUrl})},style:{background:"none",border:u.borderWidth&&u.borderWidth!=="0px"&&u.borderWidth!=="0cqh"?`${ot(u.borderWidth)} solid ${u.borderColor||"#FFFFFF"}`:"none",padding:0,width:"100%",height:"100%",cursor:"pointer",display:"block",outline:"none",borderRadius:u.borderRadius||"0px",overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"},children:It("img",{src:t.url,alt:t.text,style:{width:"100%",height:"100%",objectFit:u.objectFit||"cover",objectPosition:u.objectPosition||"center center",display:"block",borderRadius:u.borderRadius||"0px"}})});let h=u.borderRadius,g=(t.text||"").trim(),b=g.toLowerCase().includes("swipe")||String(t.ctaType).toLowerCase().includes("swipe")||String(t.type).toLowerCase().includes("swipe")||String(t.id).toLowerCase().includes("swipe"),m={width:"100%",height:u.pillH?`${u.pillH}cqh`:"100%",backgroundColor:u.transparent?"transparent":u.backgroundColor||"#3B82F6",color:u.textColor||"#FFFFFF",border:u.borderWidth&&u.borderWidth!=="0px"&&u.borderWidth!=="0cqh"?`${ot(u.borderWidth)} solid ${u.borderColor||"#FFFFFF"}`:"none",borderRadius:h||"4px",fontSize:ot(u.fontSize||14),fontFamily:st(u.fontFamily)||"Arial",fontStyle:u.fontStyle||"normal",fontWeight:u.fontWeight||"normal",textDecoration:u.textDecoration||"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",outline:"none",padding:"0 12px",wordBreak:"break-word",flexShrink:0},E={position:"relative",width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-end",boxSizing:"border-box",animation:b&&u.arrowAnimation!==!1?"appstorys-swipe-bounce 2.2s ease-in-out infinite":"none",transformOrigin:"bottom center"},O={display:"flex",alignItems:"center",justifyContent:"center",flexGrow:1,width:"100%",color:u.arrowColor||u.textColor||"#FFFFFF",pointerEvents:"none",boxSizing:"border-box"},D=u.arrowSize?`${u.arrowSize}cqh`:"1.5cqh";return Yn("div",{style:E,children:[b&&Yn(ua,{children:[It("style",{children:`
87
+ `}),n.map(b=>Eo("div",{style:f,className:"shopable-card",onClick:R=>y(R,b),children:[Me("div",{style:P,children:Me("img",{src:b.image,alt:b.title,style:{width:"100%",height:"100%",objectFit:"cover"}})}),Eo("div",{style:g,children:[Me("span",{style:{color:i?.titleColor||i?.textColor||"#1a1b2e",fontSize:i?.titleFontSize?nt(i.titleFontSize):"15px",fontWeight:i?.titleFontWeight||"700",lineHeight:"1.2",display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"1px"},children:b.title}),Eo("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",flexWrap:"wrap"},children:[Me("span",{style:{color:i?.priceColor||i?.textColor||"#1a1b2e",fontSize:i?.priceFontSize?nt(i.priceFontSize):"18px",fontWeight:i?.priceFontWeight||"800",display:"block"},children:b.price}),b.oldPrice&&Me("span",{style:{color:i?.mrpColor||"#8b8b98",fontSize:i?.mrpFontSize?nt(i.mrpFontSize):"12px",fontWeight:i?.mrpFontWeight||"500",textDecoration:"line-through"},children:b.oldPrice})]})]}),Me("div",{style:{backgroundColor:i?.buttonBackground||"#000000",color:i?.buttonTextColor||"#ffffff",fontSize:i?.buttonFontSize?nt(i.buttonFontSize):"14px",fontWeight:"700",padding:"10px 18px",borderRadius:i?.buttonBorderRadius!==void 0?nt(i.buttonBorderRadius):"100px",textAlign:"center",flexShrink:0,whiteSpace:"nowrap"},children:"Buy Now"})]},b.id))]}),s&&c&&Me(Lr,{product:c,styling:i,onClose:()=>d(!1),onAddToCart:u})]})};import{Fragment as Ea,jsx as Bt,jsxs as si}from"react/jsx-runtime";var Wr=io.default?.default??io.default??io.Lottie??io,Aa=({url:t,animationData:e,loop:o=!0,autoplay:n=!0,styling:i={}})=>{let[s,d]=_r(e||null),[c,l]=_r(!1);Ba(()=>{if(e){d(e);return}t&&(l(!1),fetch(t).then(m=>{if(!m.ok)throw new Error(`Failed to fetch Lottie JSON (${m.status})`);return m.json()}).then(m=>{d(m),l(!1)}).catch(m=>{console.error("AppStorys: Error loading Lottie sticker from URL:",t,m),l(!0)}))},[t,e]);let y={width:"100%",height:"100%",display:"block",borderRadius:nt(i.borderRadius||"0px"),border:i.border||"none",boxShadow:i.boxShadow||"none",opacity:i.opacity??1,transform:i.transform||void 0,overflow:"hidden"};if(!s)return Bt("div",{style:y});let u=Wr.default||Wr;return Bt(u,{animationData:s,loop:o,autoplay:n,style:y,rendererSettings:{preserveAspectRatio:"xMidYMid meet"}})},La=({url:t,loop:e=!0,muted:o=!1,isActive:n=!0,isMuted:i=!1,styling:s={}})=>{let d=Mr.useRef(null);return Mr.useEffect(()=>{let l=d.current;l&&(n?l.play().catch(()=>{}):l.pause())},[n,t]),Bt("video",{ref:d,src:t,autoPlay:n,loop:e,muted:!n||i||o,playsInline:!0,style:{width:"100%",height:"100%",objectFit:s.objectFit||"contain",objectPosition:s.objectPosition||"center center",borderRadius:nt(s.borderRadius||"0px"),border:s.border||"none",boxShadow:s.boxShadow||"none",opacity:s.opacity??1,display:"block",overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"}})},Dr=({data:t,onInteraction:e,isEditing:o=!1,isActive:n=!0,isMuted:i=!1})=>{let s={x:10,y:15,width:80,rotation:0},d=t.x??s.x,c=t.y??s.y,l=t.width??s.width,y=t.rotation??s.rotation,u={position:"absolute",top:`${c}%`,left:`${d}%`,width:`${l}%`,height:t.height?`${t.height}%`:"auto",transform:`rotate(${y}deg)`,zIndex:10,transformOrigin:"center center",boxSizing:"border-box",cursor:o?"move":"default",pointerEvents:"auto",opacity:t.styling?.opacity!==void 0?t.styling.opacity:1},m={width:"100%",height:"100%",animation:t.styling?.animation,animationFillMode:"forwards"},f=()=>{switch(t.type){case"poll":return Bt(fr,{data:t,onInteraction:e,isEditing:o});case"quiz":return Bt(mr,{data:t,onInteraction:e,isEditing:o});case"rating":return Bt(wr,{data:t,onInteraction:e,isEditing:o});case"question":case"input":return Bt(Rr,{data:t,onInteraction:e,isEditing:o});case"image_quiz":return Bt(Tr,{data:t,onInteraction:e,isEditing:o});case"countdown":return Bt(hr,{data:t,onInteraction:e,isEditing:o});case"promo_code":case"promo":return Bt(xr,{data:t,onInteraction:e,isEditing:o});case"reaction":return Bt(vr,{data:t,onInteraction:e,isEditing:o});case"lottie":return Bt(Aa,{url:t.url,loop:t.loop,autoplay:t.autoplay,styling:t.styling});case"buy":case"shopable":return Bt(Pr,{data:t,onInteraction:e,isEditing:o});case"video":{let g=t.isActive!==void 0?t.isActive:n,b=t.isMuted!==void 0?t.isMuted:i;return Bt(La,{url:t.url,loop:t.loop!==!1,muted:t.muted===!0,isActive:g,isMuted:b,styling:t.styling})}case"shape":case"gif":case"svg":case"sticker":case"image":{let g=t.styling||{};return Bt("img",{src:t.url,alt:"static overlay",style:{width:"100%",height:"100%",objectFit:g.objectFit||"contain",objectPosition:g.objectPosition||"center center",borderRadius:g.borderRadius||"0px",border:g.border||"none",boxShadow:g.boxShadow||"none",opacity:g.opacity??1,display:"block",overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"}})}case"text":{let g=t.styling||{},b=g.verticalAlignment,R=g.textAlign,C=g.lineHeight,h="1.25";if(C!=null&&C!==""){let T=Number(C);isNaN(T)?h=String(C):h=T<=5?String(T):"1.25"}return Bt("div",{style:{color:g.color||"#000000",fontSize:nt(g.fontSize||14),fontFamily:ut(g.fontFamily)||"Arial",fontStyle:g.fontStyle||"normal",fontWeight:g.fontWeight||"normal",textDecoration:g.textDecoration||"none",lineHeight:h,letterSpacing:g.letterSpacing||"normal",opacity:g.opacity??1,wordBreak:"break-word",whiteSpace:"pre-wrap",width:"100%",height:"100%",display:"flex",alignItems:b==="middle"||b==="center"?"center":b==="bottom"?"flex-end":"flex-start",justifyContent:R==="center"?"center":R==="right"?"flex-end":"flex-start",textAlign:R||"left"},children:t.text})}case"cta":{let g=t.styling||{};if(t.ctaType==="image"||!!(t.url&&!t.text)){let x=g.borderRadius||"0px";return Bt("button",{onClick:N=>{N.stopPropagation(),e&&e({type:"cta",stickerId:t.id,redirectUrl:t.redirectUrl})},style:{background:"none",border:g.borderWidth&&g.borderWidth!=="0px"&&g.borderWidth!=="0cqh"?`${nt(g.borderWidth)} solid ${g.borderColor||"#FFFFFF"}`:"none",padding:0,width:"100%",height:"100%",cursor:"pointer",display:"block",outline:"none",borderRadius:x,overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"},children:Bt("img",{src:t.url,alt:t.text||"cta",style:{width:"100%",height:"100%",objectFit:g.objectFit||"contain",objectPosition:g.objectPosition||"center center",display:"block",borderRadius:x}})})}let R=g.borderRadius,C=(t.text||"").trim(),h=C.toLowerCase().includes("swipe")||String(t.ctaType).toLowerCase().includes("swipe")||String(t.type).toLowerCase().includes("swipe")||String(t.id).toLowerCase().includes("swipe"),T={width:"100%",height:g.pillH?`${g.pillH}cqh`:"100%",backgroundColor:g.transparent?"transparent":g.backgroundColor||"#3B82F6",color:g.textColor||"#FFFFFF",border:g.borderWidth&&g.borderWidth!=="0px"&&g.borderWidth!=="0cqh"?`${nt(g.borderWidth)} solid ${g.borderColor||"#FFFFFF"}`:"none",borderRadius:R||"4px",fontSize:nt(g.fontSize||14),fontFamily:ut(g.fontFamily)||"Arial",fontStyle:g.fontStyle||"normal",fontWeight:g.fontWeight||"normal",textDecoration:g.textDecoration||"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",outline:"none",padding:"0 12px",wordBreak:"break-word",flexShrink:0},E={position:"relative",width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-end",boxSizing:"border-box",animation:h&&g.arrowAnimation!==!1?"appstorys-swipe-bounce 2.2s ease-in-out infinite":"none",transformOrigin:"bottom center"},X={display:"flex",alignItems:"center",justifyContent:"center",flexGrow:1,width:"100%",color:g.arrowColor||g.textColor||"#FFFFFF",pointerEvents:"none",boxSizing:"border-box"},I=g.arrowSize,S=I?typeof I=="string"?I:nt(I,"cqh"):"clamp(12px, 1.5cqh, 24px)";return si("div",{style:E,children:[h&&si(Ea,{children:[Bt("style",{children:`
88
88
  @keyframes appstorys-swipe-bounce {
89
89
  0%, 100% {
90
90
  transform: translateY(0) scaleY(1) scaleX(1);
@@ -96,7 +96,7 @@ var ls=Object.defineProperty;var Me=(t,e)=>()=>(t&&(e=t(t=0)),e);var ds=(t,e)=>{
96
96
  transform: translateY(1px) scaleY(0.97) scaleX(1.02);
97
97
  }
98
98
  }
99
- `}),It("div",{style:O,children:It("svg",{style:{height:D,width:"auto"},viewBox:"0 0 28 18",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round",children:It("polyline",{points:"4 14 14 4 24 14"})})})]}),It("button",{onClick:v=>{v.stopPropagation(),e&&e({type:"cta",stickerId:t.id,redirectUrl:t.redirectUrl})},style:m,children:g||t.text})]})}default:return Yn("div",{style:{padding:"10px",background:"white",color:"black",borderRadius:"4px"},children:["Unsupported interactive element: ",t.type]})}};return It("div",{style:d,className:`interactive-item-z${t.z??0}`,children:It("div",{style:S,children:p()})})};import{jsx as Br,jsxs as pa}from"react/jsx-runtime";var Ko=(t,e)=>{let o=t?.styling?.editorSource||t?.styling?.meta?.editorSource||t?.style?.editorSource||e?.editorSource||e?.meta?.editorSource||e?.styling?.editorSource||e?.styling?.meta?.editorSource;return o==="studio"||o==="editor"?"studio":"dashboard"},Rr=t=>{if(!t)return!1;let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")},Ge=(...t)=>{for(let e of t)if(e){if(typeof e=="object"){let o=e.fontFamily||e.font_family||e.font?.fontFamily||e.font?.font_family;if(typeof o=="string"&&o.trim()){let n=o.trim();if(Rr(n)||n.length<50&&!/[?!.,;:\n]/.test(n))return n}}if(typeof e=="string"){let o=e.trim();if(!o)continue;if(Rr(o)||o.length<35&&!/[?!.,;:\n]/.test(o)&&o.split(/\s+/).length<=3)return o}}},De=(t,e)=>Array.isArray(t)?t.map((o,n)=>{let i=o?.id||o?.key||o?.value||`option_${n+1}`,s=o?.label||o?.optionLabel,l=typeof o=="string"?o:o?.text||o?.title||s||"";return{id:String(i),text:l,image:o?.image||o?.imageUrl||"",label:s,isCorrect:o?.isCorrect===!0||String(i)===String(e)}}):t&&typeof t=="object"?Object.entries(t).map(([o,n])=>{let i=typeof n=="string"?{text:n}:n||{};return{id:o,text:i.text||i.title||i.label||"",image:i.image||i.imageUrl||"",label:i.label,isCorrect:o===String(e)}}):[],Fr=t=>Array.isArray(t?.emojis)?t.emojis.map(e=>String(e)):De(t?.options).map(e=>e.text).filter(Boolean),Tr=t=>{let e=String(t||"").toLowerCase();return e==="quizz"?"quiz":e==="rate"?"rating":e==="input"||e==="ask_question"||e==="askquestion"?"question":e==="promo"||e==="promocode"?"promo_code":e},zr=(t,e,o)=>{let n=e?.couponCode||e?.code||e?.coupon_code||e?.promoCode||e?.promocode||e?.coupon||e?.value||t?.couponCode||t?.code||t?.coupon_code||o?.couponCode||o?.code||o?.data?.couponCode||o?.data?.code;return typeof n=="string"&&n.trim()!==""?n.trim():"OFFER20"},Ir=t=>{if(t.targetDate)return t.targetDate;if(!t.endDate)return new Date(Date.now()+864e5).toISOString();try{let e=`${t.endDate}${t.endTime?`T${t.endTime}`:""}`;return new Date(e).toISOString()}catch{return t.endDate||new Date(Date.now()+864e5).toISOString()}},Gn=({content:t={},onInteraction:e,isEditing:o=!1,elapsedTime:n=0})=>{let i=t?.canva||t?.styling?.canva||t?.meta?.canva||{height:1920,width:1080},s=Number(i?.width)||1080,l=Number(i?.height)||1920,c=.352,d=t?.elements||[],S=t?.image||[],p=t?.video||t?.styling?.video||[],y=Array.isArray(p)?p:typeof p=="object"&&p!==null?[p]:[],u=t?.lottie||t?.styling?.lottie||t?.styling?.lotties||t?.meta?.lottie||[],C=Array.isArray(u)?u:typeof u=="object"&&u!==null?[u]:[],h=t?.text||[],g=t?.ctas||[],b=t?.interactions||[],m=Array.isArray(t?.shopable)&&t.shopable.length>0?t.shopable:Array.isArray(t?.styling?.shopable)?t.styling.shopable:[],E=new Set(m.map(r=>r.id)),O=(t?.styling?.shopable||[]).concat(m.map(r=>r.styling).filter(Boolean)),L=Ko(null,t)==="studio",v=(r,M=L)=>{if(r==null||r==="")return;if(typeof r=="string"&&(r.endsWith("cqh")||r.endsWith("px")||r.endsWith("%")||r.endsWith("em")||r.endsWith("rem")))return r;let a=Number(r);return isNaN(a)?String(r):a>=1e3?"999px":M||a<=100?`${a}cqh`:`${a/l*100}cqh`},w=(r,M=L)=>{if(r==null||r==="")return;if(typeof r=="string"&&(r.endsWith("cqh")||r.endsWith("px")||r.endsWith("%")||r.endsWith("em")||r.endsWith("rem")))return r;let a=Number(r);if(isNaN(a))return String(r);let f;return a<10?f=a:f=a/l*100,f<1.4?`clamp(11px, ${(f*1.25).toFixed(3)}cqh, 22px)`:f<2.5?`clamp(14px, ${(f*1.15).toFixed(3)}cqh, 32px)`:`clamp(16px, ${(f*1.05).toFixed(3)}cqh, 48px)`};if(d.length===0&&S.length===0&&y.length===0&&C.length===0&&h.length===0&&b.length===0&&m.length===0&&g.length===0)return null;let _=d.filter(r=>!E.has(r.id)).map(r=>{let M=r.custom||{},a=M.data||{},f=M.style||r.styling||{},x=Ko(r,t),z=x==="studio",U=r.position||r.postion||{},et=r.size||{},X=r.x!==void 0?r.x:U.x,q=r.y!==void 0?r.y:U.y,J=r.width!==void 0?r.width:et.width,nt=r.height!==void 0?r.height:et.height,ht=X!==void 0&&!isNaN(Number(X))?z?Number(X):Number(X)/s*100:10,dt=q!==void 0&&!isNaN(Number(q))?z?Number(q):Number(q)/l*100:15,K=J!==void 0&&!isNaN(Number(J))?z?Number(J):Number(J)/s*100:80,it=nt!==void 0&&!isNaN(Number(nt))?z?Number(nt):Number(nt)/l*100:void 0,lt=Ge(a.question,a.prompt,a.title,f.question,r.question,f.prompt,r.font,f.font,a.font,a.fontFamily,r.fontFamily,f.fontFamily),mt=Ge(a.options,f.options,r.options,a.font,f.font,r.font,a.fontFamily,r.fontFamily,f.fontFamily),gt=Ge(a.font,f.font,r.font,a.fontFamily,r.fontFamily,f.fontFamily),R={id:r.id||Math.random().toString(),type:Tr(M.interactiveType||r.widgetType||r.type||"unknown"),x:ht,y:dt,width:K,height:it,url:r.url||a.url||r.link||a.link,rotation:f.rotation??r.rotation??0,z:r.z??r.position?.z??f.z??10,duration:a.duration||f.duration,styling:{backgroundColor:St(f.background||f.containerBgColor||f.backgroundColor),borderRadius:f.borderRadius!==void 0?f.borderRadius>=100?"999px":v(f.borderRadius,z):f.radius!==void 0?f.radius>=100?"999px":v(f.radius,z):"0px",padding:v(f.containerPadding!==void 0?f.containerPadding:f.padding!==void 0?f.padding:0,z),shadow:f.shadow,fontSize:w(f.questionFontSize??f.questionFont?.fontSize??f.questionSize??f.fontSize,z),opacity:f.opacity??1,animation:mo(f.animation),fontFamily:gt,questionFontFamily:lt||gt,optionFontFamily:mt||gt}};if(R.type==="poll"){let I=De(a.options);return{...R,type:"poll",question:a.question||a.title||"Poll Question",options:I,layout:a.layout||{type:"vertical",columns:1},styling:{...R.styling,headerColor:St(f.headerBgColor||f.background),headerTextColor:tt(f.questionColor||f.questionTextColor||f.question?.color),optionBgColor:St(f.optionBgColor||f.options?.background)||"#1A1A1A",optionTextColor:tt(f.optionTextColor||f.options?.textColor)||"#ffffff",optionBorderRadius:f.optionBorderRadius!==void 0?v(f.optionBorderRadius,z):f.options?.radius!==void 0?v(f.options?.radius,z):"0px"}}}if(R.type==="quiz"){let I=f.colors||{},N=De(a.options,a.isCorrect),Z=f.optionFontSize??f.optionFont?.fontSize??f.typography?.optionSize??f.options?.fontSize??16;return{...R,type:"quiz",question:a.question||a.title||"Quiz Question",options:N,showExplanation:a.showExplanation??r.showExplanation??f.showExplanation??M.showExplanation??!0,explanation:a.explanation||r.explanation||f.explanation||M.explanation,url:a.url,styling:{...R.styling,backgroundColor:St(f.background||f.containerBgColor||f.backgroundColor)||"transparent",questionTextColor:tt(f.questionColor||I.questionColor||f.question?.color||f.colors?.questionText)||"#FFFFFF",questionBgColor:St(f.questionBgColor||I.questionBackground||f.question?.background||f.colors?.questionBg)||"#000000",optionBgColor:St(f.optionBgColor||I.optionBackground||f.options?.background||f.colors?.optionBg)||"#FFFFFF",optionTextColor:tt(f.optionTextColor||I.optionTextColor||f.options?.textColor||f.colors?.optionText)||"#2B2B2B",borderColor:tt(f.borderColor)||"transparent",activeColor:tt(f.correctColor||I.correctColor||f.correctBorderColor)||"#10b981",incorrectColor:tt(f.incorrectColor||I.incorrectColor)||"#ef4444",optionBorderRadius:f.optionRadius!==void 0?f.optionRadius>=100?"999px":v(f.optionRadius,z):f.optionBorderRadius!==void 0?f.optionBorderRadius>=100?"999px":v(f.optionBorderRadius,z):"100px",optionFontSize:w(Z,z)}}}if(R.type==="rating")return{...R,type:"rating",title:a.title||"Do you like my space?",emoji:a.emoji||"\u{1F60D}",currentRating:a.currentRating,maxRating:a.maxRating,styling:{...R.styling,sliderTrackColor:tt(f.colors?.sliderTrack||f.sliderTrack),sliderFillColor:tt(f.colors?.sliderFill||f.sliderFill),emojiSize:f.emojiSize?z?`${Math.min(Number(f.emojiSize),32)}px`:`${Math.min(f.emojiSize*.45,32)}px`:void 0,titleColor:tt(f.colors?.titleColor||f.titleColor),titleFontSize:f.titleFontSize?z?`${Math.min(Number(f.titleFontSize),16)}px`:`${Math.min(f.titleFontSize*.4,16)}px`:void 0}};if(R.type==="question"){let I=f.optionRadius??f.optionBorderRadius??f.inputRadius??f.inputBorderRadius,N=f.borderRadius??f.radius??f.containerBorderRadius;return{...R,type:"question",question:a.question||a.title||"Ask me a question",placeholder:a.placeholder||"Type your answer...",styling:{...R.styling,borderRadius:N!==void 0?N>=100?"999px":v(N,z):"16px",promptColor:tt(f.questionColor||f.promptColor||f.textColor),inputBgColor:St(f.inputBackground||f.inputBgColor),inputTextColor:tt(f.inputTextColor),submitBackground:St(f.submitBackground),optionRadius:I!==void 0?I>=5?"9999px":v(I,z):"9999px",inputBorderRadius:I!==void 0?I>=5?"9999px":v(I,z):"9999px"}}}if(R.type==="image_quiz"||R.type==="imageQuiz"||(M.interactiveType||"").toLowerCase()==="media_quiz"){let I=f.optionFontSize??f.optionFont?.fontSize??f.typography?.optionSize??f.options?.fontSize??13,N=f.borderRadius??f.radius??f.containerBorderRadius,Z=f.optionRadius??f.optionBorderRadius??f.imageRadius;return{...R,type:"image_quiz",question:a.question||a.title||"Image Quiz",options:De(a.options||[]),layout:a.layout??f.layout??r.layout,styling:{...R.styling,borderRadius:N!==void 0?N>=100?"999px":v(N,z):void 0,optionRadius:Z!==void 0?Z>=100?"999px":v(Z,z):void 0,questionBgColor:St(f.questionBgColor||f.questionBackground),questionTextColor:tt(f.questionColor||f.questionTextColor),optionBgColor:St(f.optionBgColor||f.optionBackground),optionTextColor:tt(f.optionTextColor||f.textColor),labelColor:tt(f.labelColor),borderColor:tt(f.borderColor),activeColor:tt(f.correctBorderColor||f.correctColor||f.activeColor),incorrectColor:tt(f.incorrectColor),imageRadius:Z!==void 0?v(Z,z):void 0,optionFontSize:w(I,z)}}}if(R.type==="countdown")return{...R,type:"countdown",title:a.title||"Ends in...",targetDate:Ir(a),styling:{...R.styling,borderColor:tt(f.borderColor),digitBackground:St(f.digitBackground),digitColor:tt(f.digitColor),digitSize:f.digitSize||f.fontSize?w(f.digitSize||f.fontSize,z):void 0,labelColor:tt(f.labelColor),titleColor:tt(f.titleColor)},display:a.display};if(R.type==="promo_code")return{...R,width:R.width?Math.max(R.width,65):75,type:"promo_code",code:zr(r,a,M),styling:{...R.styling,borderColor:tt(f.borderColor)}};if(R.type==="reaction"||R.type==="emoji_reaction"){let I=Fr(a);return{...R,type:"reaction",emojis:I.length>0?I:["\u{1F60D}","\u{1F44D}"],source:x}}return R}),$=(t?.interactions||[]).filter(r=>!E.has(r.id)).map(r=>{let M=r.config||{},a=r.styling||r.style||{},f=Ko(r,t),x=f==="studio",z=Tr(r.interaction_type||r.type),U=a.position||r.position||{},et=a.size||r.size||{},X=U.x??r.x,q=U.y??r.y,J=et.width??r.width,nt=et.height??r.height,ht=X!==void 0&&!isNaN(Number(X))?x?Number(X):Number(X)/s*100:10,dt=q!==void 0&&!isNaN(Number(q))?x?Number(q):Number(q)/l*100:15,K=J!==void 0&&!isNaN(Number(J))?x?Number(J):Number(J)/s*100:80,it=nt!==void 0&&!isNaN(Number(nt))?x?Number(nt):Number(nt)/l*100:void 0,lt=Ge(a.question,r.question,a.prompt,M.question,M.prompt,M.title,a.font,r.font,M.font,a.fontFamily,M.fontFamily,r.fontFamily),mt=Ge(a.options,r.options,M.options,a.font,r.font,M.font,a.fontFamily,M.fontFamily,r.fontFamily),gt=Ge(a.font,r.font,M.font,a.fontFamily,M.fontFamily,r.fontFamily),R={id:r.id||Math.random().toString(),type:z,x:ht,y:dt,width:K,height:it,rotation:a.rotation??r.rotation??0,z:r.z??r.position?.z??a.z??10,source:f,duration:M.duration||a.duration,styling:{backgroundColor:St(a.background||a.containerBgColor||a.backgroundColor),borderRadius:a.borderRadius!==void 0?a.borderRadius>=100?"999px":v(a.borderRadius,x):a.radius!==void 0?a.radius>=100?"999px":v(a.radius,x):"0px",padding:v(a.containerPadding!==void 0?a.containerPadding:a.padding!==void 0?a.padding:0,x),shadow:a.shadow,fontSize:w(a.questionFontSize??a.questionFont?.fontSize??a.questionSize??a.fontSize,x),opacity:a.opacity??1,animation:mo(a.animation),fontFamily:gt,questionFontFamily:lt||gt,optionFontFamily:mt||gt}};if(R.type==="rating"||R.type==="rate"){let I=a.colors||{};return{...R,type:"rating",title:M.title||"Do you like my space?",emoji:M.emoji||"\u{1F60D}",currentRating:M.currentRating,maxRating:M.maxRating,styling:{...R.styling,sliderTrackColor:tt(I.sliderTrack||a.colors?.sliderTrack||a.colors?.sliderTrack),sliderFillColor:tt(I.sliderFill||a.colors?.sliderFill||a.colors?.sliderFill),emojiSize:a.emojiSize?x?`${Math.min(Number(a.emojiSize),32)}px`:`${Math.min(a.emojiSize*.45,32)}px`:void 0,titleColor:tt(I.titleColor||a.colors?.titleColor||a.titleColor),titleFontSize:a.titleFontSize?x?`${Math.min(Number(a.titleFontSize),16)}px`:`${Math.min(a.titleFontSize*.4,16)}px`:void 0}}}if(R.type==="poll"){let I=De(M.options);return{...R,type:"poll",question:M.question||M.title||"Poll Question",options:I,layout:M.layout||{type:"vertical",columns:1},styling:{...R.styling,headerColor:St(a.headerBgColor||a.background),headerTextColor:tt(a.questionColor||a.questionTextColor||a.question?.color),optionBgColor:St(a.optionBgColor||a.options?.background)||"#1A1A1A",optionTextColor:tt(a.optionTextColor||a.options?.textColor)||"#ffffff",optionBorderRadius:a.optionBorderRadius!==void 0?v(a.optionBorderRadius,x):a.options?.radius!==void 0?v(a.options?.radius,x):"0px"}}}if(R.type==="quiz"){let I=a.colors||{},N=De(M.options,M.isCorrect),Z=a.optionFontSize??a.optionFont?.fontSize??a.typography?.optionSize??a.options?.fontSize??16;return{...R,type:"quiz",question:M.question||M.title||"Quiz Question",options:N,showExplanation:M.showExplanation??r.showExplanation??a.showExplanation??!0,explanation:M.explanation||r.explanation||a.explanation,url:M.url,styling:{...R.styling,backgroundColor:St(a.background||a.containerBgColor||a.backgroundColor)||"transparent",questionTextColor:tt(a.questionColor||I.questionColor||a.question?.color||a.colors?.questionText)||"#FFFFFF",questionBgColor:St(a.questionBgColor||I.questionBackground||a.question?.background||a.colors?.questionBg)||"#000000",optionBgColor:St(a.optionBgColor||I.optionBackground||a.options?.background||a.colors?.optionBg)||"#FFFFFF",optionTextColor:tt(a.optionTextColor||I.optionTextColor||a.options?.textColor||a.colors?.optionText)||"#2B2B2B",borderColor:tt(a.borderColor)||"transparent",activeColor:tt(a.correctColor||I.correctColor||a.correctBorderColor)||"#10b981",incorrectColor:tt(a.incorrectColor||I.incorrectColor)||"#ef4444",optionBorderRadius:a.optionRadius!==void 0?a.optionRadius>=100?"999px":v(a.optionRadius,x):a.optionBorderRadius!==void 0?a.optionBorderRadius>=100?"999px":v(a.optionBorderRadius,x):"100px",optionFontSize:w(Z,x)}}}if(R.type==="question"){let I=a.optionRadius??a.optionBorderRadius??a.inputRadius??a.inputBorderRadius,N=a.borderRadius??a.radius??a.containerBorderRadius;return{...R,type:"question",question:M.question||M.title||"Ask me a question",placeholder:M.placeholder||"Type your answer...",styling:{...R.styling,borderRadius:N!==void 0?N>=100?"999px":v(N,x):"16px",promptColor:tt(a.questionColor||a.promptColor||a.textColor),inputBgColor:St(a.inputBackground||a.inputBgColor),inputTextColor:tt(a.inputTextColor),submitBackground:St(a.submitBackground),optionRadius:I!==void 0?I>=5?"9999px":v(I,x):"9999px",inputBorderRadius:I!==void 0?I>=5?"9999px":v(I,x):"9999px"}}}if(R.type==="image_quiz"||R.type==="imageQuiz"||z==="media_quiz"){let I=a.optionFontSize??a.optionFont?.fontSize??a.typography?.optionSize??a.options?.fontSize??13,N=a.borderRadius??a.radius??a.containerBorderRadius,Z=a.optionRadius??a.optionBorderRadius??a.imageRadius;return{...R,type:"image_quiz",question:M.question||M.title||"Image Quiz",options:De(M.options||[]),layout:M.layout??a.layout??r.layout,styling:{...R.styling,borderRadius:N!==void 0?N>=100?"999px":v(N,x):void 0,optionRadius:Z!==void 0?Z>=100?"999px":v(Z,x):void 0,questionBgColor:St(a.questionBgColor||a.questionBackground),questionTextColor:tt(a.questionColor||a.questionTextColor),optionBgColor:St(a.optionBgColor||a.optionBackground),optionTextColor:tt(a.optionTextColor||a.textColor),labelColor:tt(a.labelColor),borderColor:tt(a.borderColor),activeColor:tt(a.correctBorderColor||a.correctColor||a.activeColor),incorrectColor:tt(a.incorrectColor),imageRadius:Z!==void 0?v(Z,x):void 0,optionFontSize:w(I,x)}}}if(R.type==="countdown")return{...R,type:"countdown",title:M.title||"Ends in...",targetDate:Ir(M),styling:{...R.styling,borderColor:tt(a.borderColor),digitBackground:St(a.digitBackground),digitColor:tt(a.digitColor),digitSize:a.digitSize||a.fontSize?w(a.digitSize||a.fontSize,x):void 0,labelColor:tt(a.labelColor),titleColor:tt(a.titleColor),labelFontSize:a.labelFontSize?w(a.labelFontSize,x):void 0},display:M.display||r.display};if(R.type==="promo_code")return{...R,width:R.width?Math.max(R.width,65):75,type:"promo_code",code:zr(r,M,a),styling:{...R.styling,borderColor:tt(a.borderColor)}};if(R.type==="reaction"||R.type==="emoji_reaction"){let I=Fr(M);return{...R,type:"reaction",emojis:I.length>0?I:["\u{1F60D}","\u{1F44D}"]}}return R}),V=m.map(r=>{let M=O.find(I=>String(I?.id)===String(r?.id))||O.find(I=>I?.id===void 0)||{},f=Ko(r,t)==="studio",x={position:r?.position,size:r?.size,rotation:r?.rotation,z:r?.z,background:r?.background,cardBackground:r?.cardBackground,cardBorderRadius:r?.cardBorderRadius,cardRadiusPercent:r?.cardRadiusPercent,transparent:r?.transparent,textColor:r?.textColor,buttonBackground:r?.buttonBackground,buttonTextColor:r?.buttonTextColor,buttonFontSize:r?.buttonFontSize,buttonBorderRadius:r?.buttonBorderRadius,titleColor:r?.titleColor,titleFontSize:r?.titleFontSize,titleFontWeight:r?.titleFontWeight,priceColor:r?.priceColor,priceFontSize:r?.priceFontSize,priceFontWeight:r?.priceFontWeight,mrpColor:r?.mrpColor,mrpFontSize:r?.mrpFontSize,mrpFontWeight:r?.mrpFontWeight,imageRadius:r?.imageRadius,opacity:r?.opacity,animation:r?.animation},z={...M,...r?.styling||{},...Object.fromEntries(Object.entries(x).filter(([,I])=>I!==void 0))},U=z.position||{},et=z.size||{},X=z.cardBorderRadius!==void 0?Number(z.cardBorderRadius):void 0,q=z.cardRadiusPercent!==void 0?Number(z.cardRadiusPercent):void 0,J=et.height!==void 0?Number(et.height):void 0,nt=X===void 0&&q!==void 0&&J!==void 0?Math.max(0,Math.min(100,q))/100*(J/2):void 0,ht=X??nt,dt=ht!==void 0&&!isNaN(ht)?ht*c:void 0,K=U.x!==void 0?f?Number(U.x):Number(U.x)/s*100:0,it=et.width!==void 0?f?Number(et.width):Number(et.width)/s*100:100,lt=et.height!==void 0?f?Number(et.height):Number(et.height)/l*100:void 0,mt=U.y!==void 0?f?Number(U.y):Number(U.y)/l*100:lt?100-lt-2.5:85;lt&&mt+lt>96?mt=Math.max(0,100-lt):mt>75&&lt&&mt+lt>91&&(mt=Math.max(0,100-lt-1));let gt=Array.isArray(r.product)&&r.product.length>0,R=gt?r.product:r.static||[];return{id:r.id||Math.random().toString(),type:"buy",shopableType:gt?"product":"static",x:K,y:mt,width:it,height:lt,rotation:z.rotation??0,z:z.z??10,products:R.map(I=>{let N=I.productData||I||{},Z=N.attributes||I.attributes||{},xt=Z.sales_price||N.price||Z.price||I.price,Ft=Z.sales_price?N.price||Z.price||I.price:N.oldPrice||I.oldPrice,kt=N.color||Z.color||I.color,Wt=N.size||Z.size||I.size,Bt=Z.colors||[];Bt.length===0&&kt&&(Bt=[{id:kt,hex:kt,name:kt}]);let Ht=Z.sizes||[];Ht.length===0&&Wt&&(Ht=typeof Wt=="string"?Wt.split(",").map(Kt=>Kt.trim()):[Wt]);let Tt={description:N.description||Z.description||I.description,color:kt,size:Wt,colors:Bt,sizes:Ht,imageUrls:Z.imageUrls||[Z.image_link||N.imageUrl||N.image||I.imageUrl||I.image||I.url].filter(Boolean),availability:N.availability||Z.availability||I.availability,tags:N.tags||Z.tags||I.tags,...Z};return{id:N.productId||N.id||I.productId||I.id||Math.random().toString(),image:Z.image_link||N.imageUrl||N.image||I.imageUrl||I.image||I.url,url:N.link||N.url||I.link||I.url||I.redirectUrl,title:N.title||I.title,price:xt,oldPrice:Ft,redirectUrl:I.redirectUrl||N.link||I.link||I.url,svg:N.svg||I.svg,productId:N.productId||I.productId,collectionId:N.collectionId||I.collectionId,feedId:N.feedId||I.feedId,attributes:Tt}}),styling:{backgroundColor:St(z.background),cardBackground:St(z.cardBackground)||St(z.background)||"#ffffff",cardBorderRadius:ht!==void 0&&!isNaN(ht)?f?`${ht}cqh`:`${dt}px`:f?"1cqh":"10px",cardRadiusPercent:q,transparent:z.transparent===!0,textColor:tt(z.textColor)||"#ffffff",buttonBackground:St(z.buttonBackground)||"#000000",buttonTextColor:tt(z.buttonTextColor)||"#ffffff",buttonFontSize:w(z.buttonFontSize||12,f),buttonBorderRadius:z.buttonBorderRadius!==void 0?f?`${z.buttonBorderRadius}cqh`:`${z.buttonBorderRadius}px`:f?"10cqh":"100px",titleColor:tt(z.titleColor||z.textColor)||"#1a1a2e",titleFontSize:w(z.titleFontSize||14,f),titleFontWeight:z.titleFontWeight?String(z.titleFontWeight):"600",priceColor:tt(z.priceColor||z.textColor)||"#1a1a2e",priceFontSize:w(z.priceFontSize||16,f),priceFontWeight:z.priceFontWeight?String(z.priceFontWeight):"700",mrpColor:tt(z.mrpColor)||"#8b8b98",mrpFontSize:w(z.mrpFontSize||12,f),mrpFontWeight:z.mrpFontWeight?String(z.mrpFontWeight):"500",imageRadius:z.imageRadius!==void 0?f?`${z.imageRadius}cqh`:`${Number(z.imageRadius)*c}px`:f?"1cqh":"10px",animation:mo(z.animation)}}}),A=S.map(r=>{let a=(t?.styling?.image||t?.styling?.images||[]).find(z=>z.id===r.id)||{},f=r.position||a.position||r.postion||{x:0,y:0},x=r.borderRadius??r.styling?.borderRadius??a.borderRadius??a.styling?.borderRadius??r.imageRadius??r.radius;return{id:r.id||Math.random().toString(),type:"image",x:L?Number(f.x):f.x/s*100,y:L?Number(f.y):f.y/l*100,width:L?Number(r.width):r.width/s*100,height:r.height?L?Number(r.height):r.height/l*100:void 0,url:r.link||r.url,z:r.z??a.z??0,styling:{borderRadius:x!==void 0?v(x,L):void 0,objectFit:r.objectFit||a.objectFit||r.sizing||a.sizing||"fill",objectPosition:Ve(r.objectPosition||a.objectPosition||r.positionStr),border:r.border||r.styling?.border||a.border,boxShadow:r.shadow||r.styling?.shadow||a.shadow,opacity:(r.opacity!==void 0?r.opacity:a.opacity)!==void 0?Number(r.opacity!==void 0?r.opacity:a.opacity)/100:void 0}}}),T=y.map(r=>{let a=(t?.styling?.video||t?.styling?.videos||[]).find(J=>J.id===r.id)||{},f=r.position||a.position||{x:r.x,y:r.y},x=f.x??r.x,z=f.y??r.y,U=r.width??a.width,et=r.height??a.height,X=r.cornerRadius??r.borderRadius??a.cornerRadius??a.borderRadius??r.radius,q=r.rotation!==void 0?r.rotation:a.rotation;return{id:r.id||Math.random().toString(),type:"video",x:x!==void 0&&!isNaN(Number(x))?L?Number(x):Number(x)/s*100:0,y:z!==void 0&&!isNaN(Number(z))?L?Number(z):Number(z)/l*100:0,width:U!==void 0&&!isNaN(Number(U))?L?Number(U):Number(U)/s*100:100,height:et!==void 0&&!isNaN(Number(et))?L?Number(et):Number(et)/l*100:void 0,url:r.link||r.url||r.src||a.link||a.url,rotation:q??0,z:r.z??a.z??2,loop:r.loop??a.loop??!0,muted:r.muted??a.muted??!1,styling:{borderRadius:X!==void 0?v(X,L):void 0,objectFit:r.objectFit||a.objectFit||r.sizing||a.sizing||"cover",objectPosition:Ve(r.objectPosition||a.objectPosition),border:r.border||r.styling?.border||a.border,boxShadow:r.shadow||r.styling?.shadow||a.shadow,opacity:(r.opacity!==void 0?r.opacity:a.opacity)!==void 0?Number(r.opacity!==void 0?r.opacity:a.opacity)/100:void 0}}}),k=C.map(r=>{let a=(t?.styling?.lottie||t?.styling?.lotties||[]).find(dt=>dt.id===r.id)||{},f=r.position||a.position||{x:r.x,y:r.y},x=f.x??r.x,z=f.y??r.y,U=r.width??a.width,et=r.height??a.height,X=r.cornerRadius??r.borderRadius??a.cornerRadius??a.borderRadius??r.radius,q=r.rotation!==void 0?r.rotation:a.rotation,J=r.flip||a.flip||{},nt="";J.horizontal&&J.vertical?nt="scale(-1, -1)":J.horizontal?nt="scaleX(-1)":J.vertical&&(nt="scaleY(-1)");let ht=r.duration||a.duration;return{id:r.id||Math.random().toString(),type:"lottie",x:x!==void 0&&!isNaN(Number(x))?L?Number(x):Number(x)/s*100:0,y:z!==void 0&&!isNaN(Number(z))?L?Number(z):Number(z)/l*100:0,width:U!==void 0&&!isNaN(Number(U))?L?Number(U):Number(U)/s*100:100,height:et!==void 0&&!isNaN(Number(et))?L?Number(et):Number(et)/l*100:void 0,url:r.link||r.url||r.src||r.lottie_url||a.link||a.url,rotation:q??0,z:r.z??a.z??3,duration:ht?.start!==void 0?ht:void 0,loop:r.loop??a.loop??!0,autoplay:r.autoplay??a.autoplay??!0,styling:{borderRadius:X!==void 0?v(X,L):void 0,border:r.border||r.styling?.border||a.border,boxShadow:r.shadow||r.styling?.shadow||a.shadow,opacity:(r.opacity!==void 0?r.opacity:a.opacity)!==void 0?Number(r.opacity!==void 0?r.opacity:a.opacity)/100:void 0,transform:nt||void 0,animation:mo(r.animation||a.animation)}}}),B=h.map(r=>{let a=(t?.styling?.text||[]).find(ht=>ht.id===r.id)||{},f=r.position||a.position||{x:0,y:0},x=r.font||a.font||{},z=r.size||a.size||{},U=r.alignment||a.alignment||{},et=r.color||a.color,X=x.fontDecoration||[],q=X.includes("underline")?"underline":X.includes("line-through")?"line-through":void 0,J=r.rotation!==void 0?r.rotation:a.rotation,nt=x.fontSize??r.fontSize??a.fontSize??a.font?.fontSize;return{id:r.id||Math.random().toString(),type:"text",x:L?Number(f.x):f.x/s*100,y:L?Number(f.y):f.y/l*100,width:z.width?L?Number(z.width):z.width/s*100:void 0,height:z.height?L?Number(z.height):z.height/l*100:void 0,rotation:J??0,text:r.text||r.value||a.text||a.value||"",z:r.z??a.z??1,styling:{color:tt(et)||"#000000",fontSize:nt?w(nt,L):void 0,fontFamily:x.fontFamily,fontStyle:x.fontStyle||(X.includes("italic")?"italic":"normal"),fontWeight:x.fontWeight||(X.includes("bold")?"bold":"normal"),textDecoration:q,lineHeight:r.lineHeight!==void 0?r.lineHeight:a.lineHeight,letterSpacing:(r.letterSpacing!==void 0?r.letterSpacing:a.letterSpacing)!==void 0?`${r.letterSpacing!==void 0?r.letterSpacing:a.letterSpacing}px`:void 0,opacity:(r.opacity!==void 0?r.opacity:a.opacity)!==void 0?Number(r.opacity!==void 0?r.opacity:a.opacity)/100:void 0,textAlign:U.horizontalAlignment||"left",verticalAlignment:U.verticalAlignment||"top"}}}),W=g.map(r=>{let a=(t?.styling?.ctas||t?.styling?.cta||[]).find(ht=>ht.id===r.id)||{},f=r.position||a.position||{x:0,y:0},x=r.size||a.size||{},z=r.font||a.font||{},U=z.fontDecoration||[],et=U.includes("underline")?"underline":U.includes("line-through")?"line-through":void 0,X=r.rotation!==void 0?r.rotation:a.rotation,q=z.fontSize??r.fontSize??a.fontSize??a.font?.fontSize,J=r.borderRadius??r.styling?.borderRadius??a.borderRadius??a.styling?.borderRadius,nt=r.borderWidth??r.styling?.borderWidth??a.borderWidth??a.styling?.borderWidth;return{id:r.id||Math.random().toString(),type:"cta",x:L?Number(f.x):f.x/s*100,y:L?Number(f.y):f.y/l*100,width:x.width?L?Number(x.width):x.width/s*100:void 0,height:x.height?L?Number(x.height):x.height/l*100:void 0,rotation:X??0,text:r.text||a.text||"Learn More",redirectUrl:r.redirectUrl||a.redirectUrl||r.link||a.link,ctaType:r.type||a.type||"classic",url:r.url||a.url,z:r.z??a.z??10,source:L?"studio":"dashboard",styling:{backgroundColor:St(r.background||a.background),textColor:tt(r.textColor||a.textColor)||"#FFFFFF",borderColor:tt(r.borderColor||a.borderColor||r.styling?.borderColor||a.styling?.borderColor)||"#FFFFFF",borderWidth:nt!==void 0&&Number(nt)>0?v(nt,L):void 0,borderRadius:J!==void 0?v(J,L):void 0,fontSize:q?w(q,L):void 0,fontFamily:z.fontFamily,fontStyle:z.fontStyle||(U.includes("italic")?"italic":"normal"),fontWeight:z.fontWeight||(U.includes("bold")?"bold":"normal"),textDecoration:et,pillH:r.pillH??a.pillH,arrowAnimation:r.arrowAnimation??a.arrowAnimation,arrowColor:tt(r.arrowColor||a.arrowColor),arrowSize:r.arrowSize??a.arrowSize,transparent:r.transparent??a.transparent}}}),H=[..._,...$,...V,...A,...T,...k,...B,...W].filter(r=>{if(!r.duration)return!0;let{start:M,end:a}=r.duration;return n>=M&&n<=a}).sort((r,M)=>(r.z??0)-(M.z??0));return console.log("InteractiveOverlay Debug - content.ctas:",g,"displayCtas:",W,"displayItems:",H),pa("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10,pointerEvents:"none",overflow:"hidden",containerType:"size"},children:[Br("style",{children:`
99
+ `}),Bt("div",{style:X,children:Bt("svg",{style:{height:S,width:"auto"},viewBox:"0 0 28 18",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round",children:Bt("polyline",{points:"4 14 14 4 24 14"})})})]}),Bt("button",{onClick:x=>{x.stopPropagation(),e&&e({type:"cta",stickerId:t.id,redirectUrl:t.redirectUrl})},style:T,children:C||t.text})]})}default:return si("div",{style:{padding:"10px",background:"white",color:"black",borderRadius:"4px"},children:["Unsupported interactive element: ",t.type]})}};return Bt("div",{style:u,className:`interactive-item-z${t.z??0}`,children:Bt("div",{style:m,children:f()})})};import{jsx as Ur,jsxs as Pa}from"react/jsx-runtime";var pn=(t,e)=>{let o=t?.styling?.editorSource||t?.styling?.meta?.editorSource||t?.style?.editorSource||e?.editorSource||e?.meta?.editorSource||e?.styling?.editorSource||e?.styling?.meta?.editorSource;return o==="studio"||o==="editor"?"studio":"dashboard"},$r=t=>{if(!t)return!1;let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")},ro=(...t)=>{for(let e of t)if(e){if(typeof e=="object"){let o=e.fontFamily||e.font_family||e.font?.fontFamily||e.font?.font_family;if(typeof o=="string"&&o.trim()){let n=o.trim();if($r(n)||n.length<50&&!/[?!.,;:\n]/.test(n))return n}}if(typeof e=="string"){let o=e.trim();if(!o)continue;if($r(o)||o.length<35&&!/[?!.,;:\n]/.test(o)&&o.split(/\s+/).length<=3)return o}}},He=(t,e)=>Array.isArray(t)?t.map((o,n)=>{let i=o?.id||o?.key||o?.value||`option_${n+1}`,s=o?.label||o?.optionLabel,d=typeof o=="string"?o:o?.text||o?.title||s||"",c=o?.isCorrect===!0||String(o?.isCorrect)==="true"||o?.is_correct===!0||String(o?.is_correct)==="true",l=e!=null&&(String(i)===String(e)||String(n+1)===String(e)||o?.key&&String(o.key)===String(e)||o?.value&&String(o.value)===String(e));return{id:String(i),text:d,image:o?.image||o?.imageUrl||o?.image_url||o?.url||"",label:s,isCorrect:c||l}}):t&&typeof t=="object"?Object.entries(t).map(([o,n])=>{let i=typeof n=="string"?{text:n}:n||{},s=i?.isCorrect===!0||String(i?.isCorrect)==="true"||i?.is_correct===!0||String(i?.is_correct)==="true",d=e!=null&&(o===String(e)||i?.id===String(e)||i?.key===String(e));return{id:o,text:i.text||i.title||i.label||"",image:i.image||i.imageUrl||i.image_url||i.url||"",label:i.label,isCorrect:s||d}}):[],Nr=t=>Array.isArray(t?.emojis)?t.emojis.map(e=>String(e)):He(t?.options).map(e=>e.text).filter(Boolean),Or=t=>{let e=String(t||"").toLowerCase();return e==="quizz"?"quiz":e==="rate"?"rating":e==="input"||e==="ask_question"||e==="askquestion"?"question":e==="promo"||e==="promocode"?"promo_code":e},jr=(t,e,o)=>{let n=e?.couponCode||e?.code||e?.coupon_code||e?.promoCode||e?.promocode||e?.coupon||e?.value||t?.couponCode||t?.code||t?.coupon_code||o?.couponCode||o?.code||o?.data?.couponCode||o?.data?.code;return typeof n=="string"&&n.trim()!==""?n.trim():"OFFER20"},qr=t=>{if(t.targetDate)return t.targetDate;if(!t.endDate)return new Date(Date.now()+864e5).toISOString();try{let e=`${t.endDate}${t.endTime?`T${t.endTime}`:""}`;return new Date(e).toISOString()}catch{return t.endDate||new Date(Date.now()+864e5).toISOString()}},ai=({content:t={},onInteraction:e,isEditing:o=!1,elapsedTime:n=0,isActive:i=!0,isMuted:s=!1})=>{let d=t?.canva||t?.styling?.canva||t?.meta?.canva||{height:1920,width:1080},c=Number(d?.width)||1080,l=Number(d?.height)||1920,y=.352,u=t?.elements||[],m=t?.image||[],f=t?.video||t?.styling?.video||[],P=Array.isArray(f)?f:typeof f=="object"&&f!==null?[f]:[],g=t?.lottie||t?.styling?.lottie||t?.styling?.lotties||t?.meta?.lottie||[],b=Array.isArray(g)?g:typeof g=="object"&&g!==null?[g]:[],R=t?.text||[],C=t?.ctas||[],h=t?.interactions||[],T=Array.isArray(t?.shopable)&&t.shopable.length>0?t.shopable:Array.isArray(t?.styling?.shopable)?t.styling.shopable:[],E=new Set(T.map(a=>a.id)),X=(t?.styling?.shopable||[]).concat(T.map(a=>a.styling).filter(Boolean)),S=pn(null,t)==="studio",M=(a,F=S)=>{if(a==null||a==="")return;if(typeof a=="string"&&(a.endsWith("cqh")||a.endsWith("px")||a.endsWith("%")||a.endsWith("em")||a.endsWith("rem")))return a;let r=Number(a);return isNaN(r)?String(a):r>=1e3?"999px":F||r<=100?`${r}cqh`:`${r/l*100}cqh`},x=(a,F,r=S)=>{if(a==null||a==="")return;if(typeof a=="string"&&(a.endsWith("cqh")||a.endsWith("px")||a.endsWith("%")||a.endsWith("em")||a.endsWith("rem")))return a;let p=Number(a);if(isNaN(p))return String(a);if(p>=1e3)return"999px";let j=r||p<=100?p:p/l*100;return j>=100?"999px":F&&F>0?`${j*F/100}cqh`:`${j}cqh`},N=(a,F=S)=>{if(a==null||a==="")return;if(typeof a=="string"&&(a.endsWith("cqh")||a.endsWith("px")||a.endsWith("%")||a.endsWith("em")||a.endsWith("rem")))return a;let r=Number(a);if(isNaN(r))return String(a);let p;return r<10?p=r:p=r/l*100,p<1.4?`clamp(11px, ${(p*1.25).toFixed(3)}cqh, 22px)`:p<2.5?`clamp(14px, ${(p*1.15).toFixed(3)}cqh, 32px)`:`clamp(16px, ${(p*1.05).toFixed(3)}cqh, 48px)`};if(u.length===0&&m.length===0&&P.length===0&&b.length===0&&R.length===0&&h.length===0&&T.length===0&&C.length===0)return null;let U=u.filter(a=>!E.has(a.id)).map(a=>{let F=a.custom||{},r=F.data||{},p=F.style||a.styling||{},j=pn(a,t),k=j==="studio",G=a.position||a.postion||{},V=a.size||{},rt=a.x!==void 0?a.x:G.x,lt=a.y!==void 0?a.y:G.y,Z=a.width!==void 0?a.width:V.width,gt=a.height!==void 0?a.height:V.height,Q=rt!==void 0&&!isNaN(Number(rt))?k?Number(rt):Number(rt)/c*100:10,dt=lt!==void 0&&!isNaN(Number(lt))?k?Number(lt):Number(lt)/l*100:15,yt=Z!==void 0&&!isNaN(Number(Z))?k?Number(Z):Number(Z)/c*100:80,ct=gt!==void 0&&!isNaN(Number(gt))?k?Number(gt):Number(gt)/l*100:void 0,mt=ro(r.question,r.prompt,r.title,p.question,a.question,p.prompt,a.font,p.font,r.font,r.fontFamily,a.fontFamily,p.fontFamily),$=ro(r.options,p.options,a.options,r.font,p.font,a.font,r.fontFamily,a.fontFamily,p.fontFamily),_=ro(r.font,p.font,a.font,r.fontFamily,a.fontFamily,p.fontFamily),D={id:a.id||Math.random().toString(),type:Or(F.interactiveType||a.widgetType||a.type||"unknown"),x:Q,y:dt,width:yt,height:ct,url:a.url||r.url||a.link||r.link,rotation:p.rotation??a.rotation??0,z:a.z??a.position?.z??p.z??10,duration:r.duration||p.duration,styling:{backgroundColor:Ct(p.background||p.containerBgColor||p.backgroundColor),borderRadius:p.borderRadius!==void 0?p.borderRadius>=100?"999px":M(p.borderRadius,k):p.radius!==void 0?p.radius>=100?"999px":M(p.radius,k):"0px",padding:M(p.containerPadding!==void 0?p.containerPadding:p.padding!==void 0?p.padding:0,k),shadow:p.shadow,fontSize:N(p.questionFontSize??p.questionFont?.fontSize??p.questionSize??p.fontSize,k),opacity:p.opacity??1,animation:zo(p.animation),fontFamily:_,questionFontFamily:mt||_,optionFontFamily:$||_}};if(D.type==="poll"){let L=He(r.options),Y=p.options?.font?.textAlign||p.optionFont?.textAlign||p.optionTextAlign||p.options?.textAlign||p.textAlign;return{...D,type:"poll",question:r.question||r.title||"Poll Question",options:L,layout:r.layout||{type:"vertical",columns:1},styling:{...D.styling,headerColor:Ct(p.headerBgColor||p.background),headerTextColor:et(p.questionColor||p.questionTextColor||p.question?.color),optionBgColor:Ct(p.optionBgColor||p.options?.background)||"#1A1A1A",optionTextColor:et(p.optionTextColor||p.options?.textColor)||"#ffffff",optionBorderRadius:p.optionBorderRadius!==void 0?x(p.optionBorderRadius,ct,k):p.options?.radius!==void 0?x(p.options?.radius,ct,k):"0px",optionTextAlign:Y}}}if(D.type==="quiz"){let L=p.colors||{},Y=r.correctAnswerId??r.correctOption??r.correct_answer_id??r.correct_option??r.correctAnswer??r.correctOptionId??r.isCorrect??a.correctAnswerId??a.correctOption,ot=He(r.options,Y),ft=p.optionFontSize??p.optionFont?.fontSize??p.typography?.optionSize??p.options?.fontSize??16,Dt=p.optionFont?.textAlign||p.optionTextAlign||p.options?.font?.textAlign||p.options?.textAlign||p.textAlign;return{...D,type:"quiz",question:r.question||r.title||"Quiz Question",options:ot,showExplanation:r.showExplanation??a.showExplanation??p.showExplanation??F.showExplanation??!0,explanation:r.explanation||a.explanation||p.explanation||F.explanation,url:r.url,styling:{...D.styling,backgroundColor:Ct(p.background||p.containerBgColor||p.backgroundColor)||"transparent",questionTextColor:et(p.questionColor||L.questionColor||p.question?.color||p.colors?.questionText)||"#FFFFFF",questionBgColor:Ct(p.questionBgColor||L.questionBackground||p.question?.background||p.colors?.questionBg)||"#000000",optionBgColor:Ct(p.optionBgColor||L.optionBackground||p.options?.background||p.colors?.optionBg)||"#FFFFFF",optionTextColor:et(p.optionTextColor||L.optionTextColor||p.options?.textColor||p.colors?.optionText)||"#2B2B2B",borderColor:et(p.borderColor)||"transparent",activeColor:et(p.correctColor||L.correctColor||p.correctBorderColor)||"#10b981",incorrectColor:et(p.incorrectColor||L.incorrectColor)||"#ef4444",optionBorderRadius:p.optionRadius!==void 0?p.optionRadius>=100?"999px":x(p.optionRadius,ct,k):p.optionBorderRadius!==void 0?p.optionBorderRadius>=100?"999px":x(p.optionBorderRadius,ct,k):"100px",optionFontSize:N(ft,k),optionTextAlign:Dt}}}if(D.type==="rating")return{...D,type:"rating",title:r.title||"Do you like my space?",emoji:r.emoji||"\u{1F60D}",currentRating:r.currentRating,maxRating:r.maxRating,styling:{...D.styling,sliderTrackColor:et(p.colors?.sliderTrack||p.sliderTrack),sliderFillColor:et(p.colors?.sliderFill||p.sliderFill),emojiSize:p.emojiSize?k?`${Math.min(Number(p.emojiSize),32)}px`:`${Math.min(p.emojiSize*.45,32)}px`:void 0,titleColor:et(p.colors?.titleColor||p.titleColor),titleFontSize:p.titleFontSize?k?`${Math.min(Number(p.titleFontSize),16)}px`:`${Math.min(p.titleFontSize*.4,16)}px`:void 0}};if(D.type==="question"){let L=p.optionRadius??p.optionBorderRadius??p.inputRadius??p.inputBorderRadius,Y=p.borderRadius??p.radius??p.containerBorderRadius;return{...D,type:"question",question:r.question||r.title||"Ask me a question",placeholder:r.placeholder||"Type your answer...",styling:{...D.styling,borderRadius:Y!==void 0?Y>=100?"999px":M(Y,k):"16px",promptColor:et(p.questionColor||p.promptColor||p.textColor),inputBgColor:Ct(p.inputBackground||p.inputBgColor),inputTextColor:et(p.inputTextColor),submitBackground:Ct(p.submitBackground),optionRadius:L!==void 0?L>=5?"9999px":x(L,ct,k):"9999px",inputBorderRadius:L!==void 0?L>=5?"9999px":x(L,ct,k):"9999px"}}}if(D.type==="image_quiz"||D.type==="imageQuiz"||D.type==="media_quiz"||(F.interactiveType||"").toLowerCase()==="media_quiz"){let L=r.correctAnswerId??r.correctOption??r.correct_answer_id??r.correct_option??r.correctAnswer??r.correctOptionId??r.isCorrect??a.correctAnswerId??a.correctOption,Y=p.optionFontSize??p.optionFont?.fontSize??p.typography?.optionSize??p.options?.fontSize??13,ot=p.borderRadius??p.radius??p.containerBorderRadius,ft=p.optionRadius??p.optionBorderRadius??p.imageRadius;return{...D,type:"image_quiz",question:r.question||r.title||"Image Quiz",options:He(r.options||[],L),layout:r.layout??p.layout??a.layout,styling:{...D.styling,borderRadius:ot!==void 0?ot>=100?"999px":M(ot,k):void 0,optionRadius:ft!==void 0?ft>=100?"999px":x(ft,ct,k):void 0,questionBgColor:Ct(p.questionBgColor||p.questionBackground),questionTextColor:et(p.questionColor||p.questionTextColor),optionBgColor:Ct(p.optionBgColor||p.optionBackground),optionTextColor:et(p.optionTextColor||p.textColor),labelColor:et(p.labelColor),borderColor:et(p.borderColor),activeColor:et(p.correctBorderColor||p.correctColor||p.activeColor),incorrectColor:et(p.incorrectColor),imageRadius:ft!==void 0?x(ft,ct,k):void 0,optionFontSize:N(Y,k)}}}if(D.type==="countdown")return{...D,type:"countdown",title:r.title||"Ends in...",targetDate:qr(r),styling:{...D.styling,borderColor:et(p.borderColor),digitBackground:Ct(p.digitBackground),digitColor:et(p.digitColor),digitSize:p.digitSize||p.fontSize?N(p.digitSize||p.fontSize,k):void 0,labelColor:et(p.labelColor),titleColor:et(p.titleColor)},display:r.display};if(D.type==="promo_code")return{...D,width:D.width?Math.max(D.width,65):75,type:"promo_code",code:jr(a,r,F),styling:{...D.styling,borderColor:et(p.borderColor)}};if(D.type==="reaction"||D.type==="emoji_reaction"){let L=Nr(r);return{...D,type:"reaction",emojis:L.length>0?L:["\u{1F60D}","\u{1F44D}"],source:j}}return D}),z=(t?.interactions||[]).filter(a=>!E.has(a.id)).map(a=>{let F=a.config||{},r=a.styling||a.style||{},p=pn(a,t),j=p==="studio",k=Or(a.interaction_type||a.type),G=r.position||a.position||{},V=r.size||a.size||{},rt=G.x??a.x,lt=G.y??a.y,Z=V.width??a.width,gt=V.height??a.height,Q=rt!==void 0&&!isNaN(Number(rt))?j?Number(rt):Number(rt)/c*100:10,dt=lt!==void 0&&!isNaN(Number(lt))?j?Number(lt):Number(lt)/l*100:15,yt=Z!==void 0&&!isNaN(Number(Z))?j?Number(Z):Number(Z)/c*100:80,ct=gt!==void 0&&!isNaN(Number(gt))?j?Number(gt):Number(gt)/l*100:void 0,mt=ro(r.question,a.question,r.prompt,F.question,F.prompt,F.title,r.font,a.font,F.font,r.fontFamily,F.fontFamily,a.fontFamily),$=ro(r.options,a.options,F.options,r.font,a.font,F.font,r.fontFamily,F.fontFamily,a.fontFamily),_=ro(r.font,a.font,F.font,r.fontFamily,F.fontFamily,a.fontFamily),D={id:a.id||Math.random().toString(),type:k,x:Q,y:dt,width:yt,height:ct,rotation:r.rotation??a.rotation??0,z:a.z??a.position?.z??r.z??10,source:p,duration:F.duration||r.duration,styling:{backgroundColor:Ct(r.background||r.containerBgColor||r.backgroundColor),borderRadius:r.borderRadius!==void 0?r.borderRadius>=100?"999px":M(r.borderRadius,j):r.radius!==void 0?r.radius>=100?"999px":M(r.radius,j):"0px",padding:M(r.containerPadding!==void 0?r.containerPadding:r.padding!==void 0?r.padding:0,j),shadow:r.shadow,fontSize:N(r.questionFontSize??r.questionFont?.fontSize??r.questionSize??r.fontSize,j),opacity:r.opacity??1,animation:zo(r.animation),fontFamily:_,questionFontFamily:mt||_,optionFontFamily:$||_}};if(D.type==="rating"||D.type==="rate"){let L=r.colors||{};return{...D,type:"rating",title:F.title||"Do you like my space?",emoji:F.emoji||"\u{1F60D}",currentRating:F.currentRating,maxRating:F.maxRating,styling:{...D.styling,sliderTrackColor:et(L.sliderTrack||r.colors?.sliderTrack||r.colors?.sliderTrack),sliderFillColor:et(L.sliderFill||r.colors?.sliderFill||r.colors?.sliderFill),emojiSize:r.emojiSize?j?`${Math.min(Number(r.emojiSize),32)}px`:`${Math.min(r.emojiSize*.45,32)}px`:void 0,titleColor:et(L.titleColor||r.colors?.titleColor||r.titleColor),titleFontSize:r.titleFontSize?j?`${Math.min(Number(r.titleFontSize),16)}px`:`${Math.min(r.titleFontSize*.4,16)}px`:void 0}}}if(D.type==="poll"){let L=He(F.options),Y=r.options?.font?.textAlign||r.optionFont?.textAlign||r.optionTextAlign||r.options?.textAlign||r.textAlign;return{...D,type:"poll",question:F.question||F.title||"Poll Question",options:L,layout:F.layout||{type:"vertical",columns:1},styling:{...D.styling,headerColor:Ct(r.headerBgColor||r.background),headerTextColor:et(r.questionColor||r.questionTextColor||r.question?.color),optionBgColor:Ct(r.optionBgColor||r.options?.background)||"#1A1A1A",optionTextColor:et(r.optionTextColor||r.options?.textColor)||"#ffffff",optionBorderRadius:r.optionBorderRadius!==void 0?x(r.optionBorderRadius,ct,j):r.options?.radius!==void 0?x(r.options?.radius,ct,j):"0px",optionTextAlign:Y}}}if(D.type==="quiz"){let L=r.colors||{},Y=F.correctAnswerId??F.correctOption??F.correct_answer_id??F.correct_option??F.correctAnswer??F.correctOptionId??F.isCorrect??a.correctAnswerId??a.correctOption,ot=He(F.options,Y),ft=r.optionFontSize??r.optionFont?.fontSize??r.typography?.optionSize??r.options?.fontSize??16,Dt=r.optionFont?.textAlign||r.optionTextAlign||r.options?.font?.textAlign||r.options?.textAlign||r.textAlign;return{...D,type:"quiz",question:F.question||F.title||"Quiz Question",options:ot,showExplanation:F.showExplanation??a.showExplanation??r.showExplanation??!0,explanation:F.explanation||a.explanation||r.explanation,url:F.url,styling:{...D.styling,backgroundColor:Ct(r.background||r.containerBgColor||r.backgroundColor)||"transparent",questionTextColor:et(r.questionColor||L.questionColor||r.question?.color||r.colors?.questionText)||"#FFFFFF",questionBgColor:Ct(r.questionBgColor||L.questionBackground||r.question?.background||r.colors?.questionBg)||"#000000",optionBgColor:Ct(r.optionBgColor||L.optionBackground||r.options?.background||r.colors?.optionBg)||"#FFFFFF",optionTextColor:et(r.optionTextColor||L.optionTextColor||r.options?.textColor||r.colors?.optionText)||"#2B2B2B",borderColor:et(r.borderColor)||"transparent",activeColor:et(r.correctColor||L.correctColor||r.correctBorderColor)||"#10b981",incorrectColor:et(r.incorrectColor||L.incorrectColor)||"#ef4444",optionBorderRadius:r.optionRadius!==void 0?r.optionRadius>=100?"999px":x(r.optionRadius,ct,j):r.optionBorderRadius!==void 0?r.optionBorderRadius>=100?"999px":x(r.optionBorderRadius,ct,j):"100px",optionFontSize:N(ft,j),optionTextAlign:Dt}}}if(D.type==="question"){let L=r.optionRadius??r.optionBorderRadius??r.inputRadius??r.inputBorderRadius,Y=r.borderRadius??r.radius??r.containerBorderRadius;return{...D,type:"question",question:F.question||F.title||"Ask me a question",placeholder:F.placeholder||"Type your answer...",styling:{...D.styling,borderRadius:Y!==void 0?Y>=100?"999px":M(Y,j):"16px",promptColor:et(r.questionColor||r.promptColor||r.textColor),inputBgColor:Ct(r.inputBackground||r.inputBgColor),inputTextColor:et(r.inputTextColor),submitBackground:Ct(r.submitBackground),optionRadius:L!==void 0?L>=5?"9999px":x(L,ct,j):"9999px",inputBorderRadius:L!==void 0?L>=5?"9999px":x(L,ct,j):"9999px"}}}if(D.type==="image_quiz"||D.type==="imageQuiz"||k==="media_quiz"||D.type==="media_quiz"){let L=F.correctAnswerId??F.correctOption??F.correct_answer_id??F.correct_option??F.correctAnswer??F.correctOptionId??F.isCorrect??a.correctAnswerId??a.correctOption,Y=r.optionFontSize??r.optionFont?.fontSize??r.typography?.optionSize??r.options?.fontSize??13,ot=r.borderRadius??r.radius??r.containerBorderRadius,ft=r.optionRadius??r.optionBorderRadius??r.imageRadius;return{...D,type:"image_quiz",question:F.question||F.title||"Image Quiz",options:He(F.options||[],L),layout:F.layout??r.layout??a.layout,styling:{...D.styling,borderRadius:ot!==void 0?ot>=100?"999px":M(ot,j):void 0,optionRadius:ft!==void 0?ft>=100?"999px":x(ft,ct,j):void 0,questionBgColor:Ct(r.questionBgColor||r.questionBackground),questionTextColor:et(r.questionColor||r.questionTextColor),optionBgColor:Ct(r.optionBgColor||r.optionBackground),optionTextColor:et(r.optionTextColor||r.textColor),labelColor:et(r.labelColor),borderColor:et(r.borderColor),activeColor:et(r.correctBorderColor||r.correctColor||r.activeColor),incorrectColor:et(r.incorrectColor),imageRadius:ft!==void 0?x(ft,ct,j):void 0,optionFontSize:N(Y,j)}}}if(D.type==="countdown")return{...D,type:"countdown",title:F.title||"Ends in...",targetDate:qr(F),styling:{...D.styling,borderColor:et(r.borderColor),digitBackground:Ct(r.digitBackground),digitColor:et(r.digitColor),digitSize:r.digitSize||r.fontSize?N(r.digitSize||r.fontSize,j):void 0,labelColor:et(r.labelColor),titleColor:et(r.titleColor),labelFontSize:r.labelFontSize?N(r.labelFontSize,j):void 0},display:F.display||a.display};if(D.type==="promo_code")return{...D,width:D.width?Math.max(D.width,65):75,type:"promo_code",code:jr(a,F,r),styling:{...D.styling,borderColor:et(r.borderColor)}};if(D.type==="reaction"||D.type==="emoji_reaction"){let L=Nr(F);return{...D,type:"reaction",emojis:L.length>0?L:["\u{1F60D}","\u{1F44D}"]}}return D}),O=T.map(a=>{let F=X.find(L=>String(L?.id)===String(a?.id))||X.find(L=>L?.id===void 0)||{},p=pn(a,t)==="studio",j={position:a?.position,size:a?.size,rotation:a?.rotation,z:a?.z,background:a?.background,cardBackground:a?.cardBackground,cardBorderRadius:a?.cardBorderRadius,cardRadiusPercent:a?.cardRadiusPercent,transparent:a?.transparent,textColor:a?.textColor,buttonBackground:a?.buttonBackground,buttonTextColor:a?.buttonTextColor,buttonFontSize:a?.buttonFontSize,buttonBorderRadius:a?.buttonBorderRadius,titleColor:a?.titleColor,titleFontSize:a?.titleFontSize,titleFontWeight:a?.titleFontWeight,priceColor:a?.priceColor,priceFontSize:a?.priceFontSize,priceFontWeight:a?.priceFontWeight,mrpColor:a?.mrpColor,mrpFontSize:a?.mrpFontSize,mrpFontWeight:a?.mrpFontWeight,imageRadius:a?.imageRadius,opacity:a?.opacity,animation:a?.animation},k={...F,...a?.styling||{},...Object.fromEntries(Object.entries(j).filter(([,L])=>L!==void 0))},G=k.position||{},V=k.size||{},rt=k.cardBorderRadius!==void 0?Number(k.cardBorderRadius):void 0,lt=k.cardRadiusPercent!==void 0?Number(k.cardRadiusPercent):void 0,Z=V.height!==void 0?Number(V.height):void 0,gt=rt===void 0&&lt!==void 0&&Z!==void 0?Math.max(0,Math.min(100,lt))/100*(Z/2):void 0,Q=rt??gt,dt=Q!==void 0&&!isNaN(Q)?Q*y:void 0,yt=G.x!==void 0?p?Number(G.x):Number(G.x)/c*100:0,ct=V.width!==void 0?p?Number(V.width):Number(V.width)/c*100:100,mt=V.height!==void 0?p?Number(V.height):Number(V.height)/l*100:void 0,$=G.y!==void 0?p?Number(G.y):Number(G.y)/l*100:mt?100-mt-2.5:85;mt&&$+mt>96?$=Math.max(0,100-mt):$>75&&mt&&$+mt>91&&($=Math.max(0,100-mt-1));let _=Array.isArray(a.product)&&a.product.length>0,D=_?a.product:a.static||[];return{id:a.id||Math.random().toString(),type:"buy",shopableType:_?"product":"static",x:yt,y:$,width:ct,height:mt,rotation:k.rotation??0,z:k.z??10,products:D.map(L=>{let Y=L.productData||L||{},ot=Y.attributes||L.attributes||{},ft=ot.sales_price||Y.price||ot.price||L.price,Dt=ot.sales_price?Y.price||ot.price||L.price:Y.oldPrice||L.oldPrice,Ft=Y.color||ot.color||L.color,$t=Y.size||ot.size||L.size,_t=ot.colors||[];_t.length===0&&Ft&&(_t=[{id:Ft,hex:Ft,name:Ft}]);let Jt=ot.sizes||[];Jt.length===0&&$t&&(Jt=typeof $t=="string"?$t.split(",").map(ce=>ce.trim()):[$t]);let re={description:Y.description||ot.description||L.description,color:Ft,size:$t,colors:_t,sizes:Jt,imageUrls:ot.imageUrls||[ot.image_link||Y.imageUrl||Y.image||L.imageUrl||L.image||L.url].filter(Boolean),availability:Y.availability||ot.availability||L.availability,tags:Y.tags||ot.tags||L.tags,...ot};return{id:Y.productId||Y.id||L.productId||L.id||Math.random().toString(),image:ot.image_link||Y.imageUrl||Y.image||L.imageUrl||L.image||L.url,url:Y.link||Y.url||L.link||L.url||L.redirectUrl,title:Y.title||L.title,price:ft,oldPrice:Dt,redirectUrl:L.redirectUrl||Y.link||L.link||L.url,svg:Y.svg||L.svg,productId:Y.productId||L.productId,collectionId:Y.collectionId||L.collectionId,feedId:Y.feedId||L.feedId,attributes:re}}),styling:{backgroundColor:Ct(k.background),cardBackground:Ct(k.cardBackground)||Ct(k.background)||"#ffffff",cardBorderRadius:Q!==void 0&&!isNaN(Q)?p?`${Q}cqh`:`${dt}px`:p?"1cqh":"10px",cardRadiusPercent:lt,transparent:k.transparent===!0,textColor:et(k.textColor)||"#ffffff",buttonBackground:Ct(k.buttonBackground)||"#000000",buttonTextColor:et(k.buttonTextColor)||"#ffffff",buttonFontSize:N(k.buttonFontSize||12,p),buttonBorderRadius:k.buttonBorderRadius!==void 0?p?`${k.buttonBorderRadius}cqh`:`${k.buttonBorderRadius}px`:p?"10cqh":"100px",titleColor:et(k.titleColor||k.textColor)||"#1a1a2e",titleFontSize:N(k.titleFontSize||14,p),titleFontWeight:k.titleFontWeight?String(k.titleFontWeight):"600",priceColor:et(k.priceColor||k.textColor)||"#1a1a2e",priceFontSize:N(k.priceFontSize||16,p),priceFontWeight:k.priceFontWeight?String(k.priceFontWeight):"700",mrpColor:et(k.mrpColor)||"#8b8b98",mrpFontSize:N(k.mrpFontSize||12,p),mrpFontWeight:k.mrpFontWeight?String(k.mrpFontWeight):"500",imageRadius:k.imageRadius!==void 0?p?`${k.imageRadius}cqh`:`${Number(k.imageRadius)*y}px`:p?"1cqh":"10px",animation:zo(k.animation)}}}),B=m.map(a=>{let r=(t?.styling?.image||t?.styling?.images||[]).find(k=>k.id===a.id)||{},p=a.position||r.position||a.postion||{x:0,y:0},j=a.borderRadius??a.styling?.borderRadius??r.borderRadius??r.styling?.borderRadius??a.imageRadius??a.radius;return{id:a.id||Math.random().toString(),type:"image",x:S?Number(p.x):p.x/c*100,y:S?Number(p.y):p.y/l*100,width:S?Number(a.width):a.width/c*100,height:a.height?S?Number(a.height):a.height/l*100:void 0,url:a.link||a.url,z:a.z??r.z??0,styling:{borderRadius:j!==void 0?M(j,S):void 0,objectFit:(()=>{let k=a.objectFit||r.objectFit||a.sizing||r.sizing;return k==="fill"||k==="cover"?"cover":k==="fit"||k==="contain"?"contain":k==="stretch"?"fill":"contain"})(),objectPosition:oo(a.objectPosition||r.objectPosition||a.positionStr),border:a.border||a.styling?.border||r.border,boxShadow:a.shadow||a.styling?.shadow||r.shadow,opacity:(a.opacity!==void 0?a.opacity:r.opacity)!==void 0?Number(a.opacity!==void 0?a.opacity:r.opacity)/100:void 0}}}),K=P.map(a=>{let r=(t?.styling?.video||t?.styling?.videos||[]).find(Z=>Z.id===a.id)||{},p=a.position||r.position||{x:a.x,y:a.y},j=p.x??a.x,k=p.y??a.y,G=a.width??r.width,V=a.height??r.height,rt=a.cornerRadius??a.borderRadius??r.cornerRadius??r.borderRadius??a.radius,lt=a.rotation!==void 0?a.rotation:r.rotation;return{id:a.id||Math.random().toString(),type:"video",x:j!==void 0&&!isNaN(Number(j))?S?Number(j):Number(j)/c*100:0,y:k!==void 0&&!isNaN(Number(k))?S?Number(k):Number(k)/l*100:0,width:G!==void 0&&!isNaN(Number(G))?S?Number(G):Number(G)/c*100:100,height:V!==void 0&&!isNaN(Number(V))?S?Number(V):Number(V)/l*100:void 0,url:a.link||a.url||a.src||r.link||r.url,rotation:lt??0,z:a.z??r.z??2,loop:a.loop??r.loop??!0,muted:a.muted??r.muted??!1,isActive:i,isMuted:s,styling:{borderRadius:rt!==void 0?M(rt,S):void 0,objectFit:(()=>{let Z=a.objectFit||r.objectFit||a.sizing||r.sizing;return Z==="fill"||Z==="cover"?"cover":Z==="fit"||Z==="contain"?"contain":Z==="stretch"?"fill":"contain"})(),objectPosition:oo(a.objectPosition||r.objectPosition),border:a.border||a.styling?.border||r.border,boxShadow:a.shadow||a.styling?.shadow||r.shadow,opacity:(a.opacity!==void 0?a.opacity:r.opacity)!==void 0?Number(a.opacity!==void 0?a.opacity:r.opacity)/100:void 0}}}),v=b.map(a=>{let r=(t?.styling?.lottie||t?.styling?.lotties||[]).find(dt=>dt.id===a.id)||{},p=a.position||r.position||{x:a.x,y:a.y},j=p.x??a.x,k=p.y??a.y,G=a.width??r.width,V=a.height??r.height,rt=a.cornerRadius??a.borderRadius??r.cornerRadius??r.borderRadius??a.radius,lt=a.rotation!==void 0?a.rotation:r.rotation,Z=a.flip||r.flip||{},gt="";Z.horizontal&&Z.vertical?gt="scale(-1, -1)":Z.horizontal?gt="scaleX(-1)":Z.vertical&&(gt="scaleY(-1)");let Q=a.duration||r.duration;return{id:a.id||Math.random().toString(),type:"lottie",x:j!==void 0&&!isNaN(Number(j))?S?Number(j):Number(j)/c*100:0,y:k!==void 0&&!isNaN(Number(k))?S?Number(k):Number(k)/l*100:0,width:G!==void 0&&!isNaN(Number(G))?S?Number(G):Number(G)/c*100:100,height:V!==void 0&&!isNaN(Number(V))?S?Number(V):Number(V)/l*100:void 0,url:a.link||a.url||a.src||a.lottie_url||r.link||r.url,rotation:lt??0,z:a.z??r.z??3,duration:Q?.start!==void 0?Q:void 0,loop:a.loop??r.loop??!0,autoplay:a.autoplay??r.autoplay??!0,styling:{borderRadius:rt!==void 0?M(rt,S):void 0,border:a.border||a.styling?.border||r.border,boxShadow:a.shadow||a.styling?.shadow||r.shadow,opacity:(a.opacity!==void 0?a.opacity:r.opacity)!==void 0?Number(a.opacity!==void 0?a.opacity:r.opacity)/100:void 0,transform:gt||void 0,animation:zo(a.animation||r.animation)}}}),A=R.map(a=>{let r=(t?.styling?.text||[]).find(Q=>Q.id===a.id)||{},p=a.position||r.position||{x:0,y:0},j=a.font||r.font||{},k=a.size||r.size||{},G=a.alignment||r.alignment||{},V=a.color||r.color,rt=j.fontDecoration||[],lt=rt.includes("underline")?"underline":rt.includes("line-through")?"line-through":void 0,Z=a.rotation!==void 0?a.rotation:r.rotation,gt=j.fontSize??a.fontSize??r.fontSize??r.font?.fontSize;return{id:a.id||Math.random().toString(),type:"text",x:S?Number(p.x):p.x/c*100,y:S?Number(p.y):p.y/l*100,width:k.width?S?Number(k.width):k.width/c*100:void 0,height:k.height?S?Number(k.height):k.height/l*100:void 0,rotation:Z??0,text:a.text||a.value||r.text||r.value||"",z:a.z??r.z??1,styling:{color:et(V)||"#000000",fontSize:gt?N(gt,S):void 0,fontFamily:j.fontFamily,fontStyle:j.fontStyle||(rt.includes("italic")?"italic":"normal"),fontWeight:j.fontWeight||(rt.includes("bold")?"bold":"normal"),textDecoration:lt,lineHeight:a.lineHeight!==void 0?a.lineHeight:r.lineHeight,letterSpacing:(a.letterSpacing!==void 0?a.letterSpacing:r.letterSpacing)!==void 0?`${a.letterSpacing!==void 0?a.letterSpacing:r.letterSpacing}px`:void 0,opacity:(a.opacity!==void 0?a.opacity:r.opacity)!==void 0?Number(a.opacity!==void 0?a.opacity:r.opacity)/100:void 0,textAlign:G.horizontalAlignment||"left",verticalAlignment:G.verticalAlignment||"top"}}}),H=C.map(a=>{let r=(t?.styling?.ctas||t?.styling?.cta||[]).find(_=>_.id===a.id)||{},p=a.position||r.position||{x:0,y:0},j=a.size||r.size||{},k=a.font||r.font||{},G=k.fontDecoration||[],V=G.includes("underline")?"underline":G.includes("line-through")?"line-through":void 0,rt=a.rotation!==void 0?a.rotation:r.rotation,lt=k.fontSize??a.fontSize??r.fontSize??r.font?.fontSize,Z=a.borderRadius??a.cornerRadius??a.imageRadius??a.radius??a.styling?.borderRadius??a.styling?.cornerRadius??a.styling?.imageRadius??r.borderRadius??r.cornerRadius??r.imageRadius??r.styling?.borderRadius??r.styling?.cornerRadius,Q=(_=>{if(!(_==null||_==="")){if(typeof _=="number"||typeof _=="string"&&/^[\d.-]+$/.test(_.trim()))return M(_,S);if(typeof _=="string")return _;if(typeof _=="object"){let D=M(_.topLeft??_.top_left??0,S)||"0px",L=M(_.topRight??_.top_right??0,S)||"0px",Y=M(_.bottomRight??_.bottom_right??0,S)||"0px",ot=M(_.bottomLeft??_.bottom_left??0,S)||"0px";return`${D} ${L} ${Y} ${ot}`}}})(Z),dt=_=>{if(_==null||_==="")return;if(typeof _=="string"&&(_.endsWith("cqh")||_.endsWith("px")||_.endsWith("%")||_.endsWith("em")||_.endsWith("rem")||_.includes("clamp")))return _;let D=Number(_);if(isNaN(D))return String(_);let L=D<1?D*2.5:D;return`clamp(12px, ${Math.max(L,1.2).toFixed(2)}cqh, 28px)`},yt=a.borderWidth??a.styling?.borderWidth??r.borderWidth??r.styling?.borderWidth,ct=a.opacity!==void 0?a.opacity:a.styling?.opacity!==void 0?a.styling?.opacity:r.opacity,mt=ct!==void 0?Number(ct)>1?Number(ct)/100:Number(ct):void 0,$=a.ctaType||a.type||r.ctaType||r.type||((a.url||a.image||a.imageUrl)&&!a.text?"image":"classic");return{id:a.id||Math.random().toString(),type:"cta",x:S?Number(p.x):p.x/c*100,y:S?Number(p.y):p.y/l*100,width:j.width?S?Number(j.width):j.width/c*100:void 0,height:j.height?S?Number(j.height):j.height/l*100:void 0,rotation:rt??0,text:a.text||r.text||"",redirectUrl:a.redirectUrl||r.redirectUrl||a.link||r.link,ctaType:$,url:a.url||a.image||a.imageUrl||r.url||r.image||r.imageUrl,z:a.z??r.z??10,source:S?"studio":"dashboard",styling:{backgroundColor:Ct(a.background||r.background||a.color),textColor:et(a.textColor||r.textColor)||"#FFFFFF",borderColor:et(a.borderColor||r.borderColor||a.styling?.borderColor||r.styling?.borderColor)||"#FFFFFF",borderWidth:yt!==void 0&&Number(yt)>0?M(yt,S):void 0,borderRadius:Q,fontSize:lt?N(lt,S):void 0,fontFamily:k.fontFamily,fontStyle:k.fontStyle||(G.includes("italic")?"italic":"normal"),fontWeight:k.fontWeight||(G.includes("bold")?"bold":"normal"),textDecoration:V,pillH:a.pillH??r.pillH,arrowAnimation:a.arrowAnimation??r.arrowAnimation,arrowColor:et(a.arrowColor||r.arrowColor),arrowSize:dt(a.arrowSize??r.arrowSize),transparent:a.transparent??r.transparent,opacity:mt}}}),it=[...U,...z,...O,...B,...K,...v,...A,...H].filter(a=>{if(!a.duration)return!0;let{start:F,end:r}=a.duration;return n>=F&&n<=r}).sort((a,F)=>(a.z??0)-(F.z??0));return console.log("InteractiveOverlay Debug - content.ctas:",C,"displayCtas:",H,"displayItems:",it),Pa("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10,pointerEvents:"none",overflow:"hidden",containerType:"size"},children:[Ur("style",{children:`
100
100
  @keyframes appstorys-fade-in {
101
101
  from { opacity: 0; transform: translateY(10px); }
102
102
  to { opacity: 1; transform: translateY(0); }
@@ -116,16 +116,16 @@ var ls=Object.defineProperty;var Me=(t,e)=>()=>(t&&(e=t(t=0)),e);var ds=(t,e)=>{
116
116
  70% { opacity: 1; transform: scale(0.95); }
117
117
  100% { opacity: 1; transform: scale(1); }
118
118
  }
119
- `}),H.map(r=>!r||typeof r!="object"||!(r.type||"").toLowerCase()?null:Br(kr,{data:r,onInteraction:e,isEditing:o},r.id))]})};import{useState as ga}from"react";import{jsx as So,jsxs as ma}from"react/jsx-runtime";var fa=({isPaused:t,onPress:e,style:o,size:n=36})=>{let[i,s]=ga(!1);return So("button",{onClick:e,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:`${n}px`,height:`${n}px`,background:i?"rgba(255, 255, 255, 0.15)":"rgba(255, 255, 255, 0.08)",border:i?"1px solid white":"1px solid rgba(255, 255, 255, 0.1)",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"10px",cursor:"pointer",transition:"all 0.2s ease",padding:0,outline:"none",...o},children:t?So("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:So("path",{d:"M5 3.867v16.266c0 .54.58.88 1.05.61l14.133-8.133c.46-.27.46-.94 0-1.21L6.05 3.257C5.58 2.987 5 3.327 5 3.867z"})}):ma("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:[So("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),So("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})})},Lr=fa;import{jsx as Qn}from"react/jsx-runtime";var ya=t=>{switch(t){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},ha=({cta:t,buttonText:e,onPress:o})=>!t||!e||e.trim()===""?null:Qn("div",{style:{position:"absolute",bottom:t?.margin?.bottom,left:t?.margin?.left,right:t?.margin?.right,display:"flex",justifyContent:ya(t?.container?.alignment),width:"100%",pointerEvents:"none",boxSizing:"border-box",zIndex:10},children:Qn("button",{style:{backgroundColor:t?.container?.backgroundColor||"#F7921C",borderColor:t?.container?.borderColor||"transparent",borderWidth:t?.container?.borderWidth??0,borderStyle:t?.container?.borderWidth?"solid":"none",borderTopRightRadius:t?.cornerRadius?.topRight,borderTopLeftRadius:t?.cornerRadius?.topLeft,borderBottomRightRadius:t?.cornerRadius?.bottomRight,borderBottomLeftRadius:t?.cornerRadius?.bottomLeft,height:t?.container?.height||42,width:t?.container?.ctaFullWidth?"100%":t?.container?.ctaWidth||"auto",justifyContent:"center",alignItems:"center",display:"flex",cursor:"pointer",outline:"none",pointerEvents:"auto",padding:"0 12px",boxSizing:"border-box"},onClick:o,children:Qn("span",{style:{color:t?.text?.color||"#ffffff",fontSize:t?.text?.fontSize||14,fontFamily:st(t?.text?.fontFamily),fontWeight:t?.text?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:t?.text?.fontDecoration?.includes("italic")?"italic":"normal",textDecorationLine:t?.text?.fontDecoration?.includes("underline")?"underline":"none",textAlign:"center"},children:Ce(e)})})}),Xn=ha;import{jsx as _e,jsxs as xa}from"react/jsx-runtime";var ba=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,style:n})=>{if(!t||t.enabled===!1)return null;let{size:i=18,margin:s,color:l,image:c,selectedStyle:d}=t,S=o?40:i,p={marginTop:o?0:s?.top??0,marginBottom:o?0:s?.bottom??0,marginLeft:o?0:s?.left??0,marginRight:o?0:s?.right??0,width:S,height:S,backgroundColor:l?.fill||"transparent",borderColor:l?.stroke||"transparent",borderWidth:S*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"relative",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:l?.stroke?"solid":"none",...n},y=()=>{let u=l?.cross||"#ffffff";return xa("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"none",stroke:u,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[_e("circle",{cx:"18",cy:"5",r:"3"}),_e("circle",{cx:"6",cy:"12",r:"3"}),_e("circle",{cx:"18",cy:"19",r:"3"}),_e("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),_e("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})};return _e("button",{onClick:e,style:p,children:c&&c.trim()!==""?_e("img",{src:c,style:{width:S,height:S,objectFit:"contain"},alt:"share"}):y()})},Jn=ba;import{Fragment as Ra,jsx as Q,jsxs as Rt}from"react/jsx-runtime";var Zo=t=>{if(t)return t.content?.canva||t.canva||t.styling?.canva||t.meta?.canva||t.content?.styling?.canva||t.content?.meta?.canva},Sa=t=>{let e=Zo(t),o=Number(e?.width),n=Number(e?.height);return o>0&&n>0?o/n:9/16},vo=.63;var xe=580,Kn="cubic-bezier(0.65, 0, 0.35, 1)",Zn="cubic-bezier(0.45, 0, 0.25, 1)";function Ca(t,e){let o=Math.round(e*1.08),n=o+Math.round(e*vo)+20;switch(t){case"center":return{transform:"translateX(0px) scale(1)",opacity:1,zIndex:10,pointerEvents:"auto",boxShadow:"0 32px 64px -12px rgba(0,0,0,0.9)",filter:"brightness(1)"};case"left":return{transform:`translateX(-${o}px) scale(${vo})`,opacity:1,filter:"brightness(0.55)",zIndex:5,pointerEvents:"auto",boxShadow:"0 8px 24px rgba(0,0,0,0.5)"};case"right":return{transform:`translateX(${o}px) scale(${vo})`,opacity:1,filter:"brightness(0.55)",zIndex:5,pointerEvents:"auto",boxShadow:"0 8px 24px rgba(0,0,0,0.5)"};case"far-left":return{transform:`translateX(-${n}px) scale(${vo})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};case"far-right":return{transform:`translateX(${n}px) scale(${vo})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};default:return{opacity:0,zIndex:1,pointerEvents:"none",transform:"translateX(0px) scale(1)",filter:"brightness(1)"}}}var Ar=({src:t,isActive:e,isAnimating:o,isMuted:n,onLoadedData:i,activeVideoRef:s,objectFit:l="cover",objectPosition:c="center center"})=>{let d=Er.useRef(null);return Er.useEffect(()=>{e&&!o?(s.current=d.current,d.current?.play().catch(()=>{}),d.current&&d.current.readyState>=1&&i?.()):(d.current?.pause(),s.current===d.current&&(s.current=null))},[e,o,t,s,i]),Q("video",{ref:d,src:t,playsInline:!0,muted:n,onLoadedData:i,onCanPlay:i,onLoadedMetadata:i,style:{width:"100%",height:"100%",objectFit:l,objectPosition:c}})},Mr="appstorys_viewed_slide_ids",ti="appstorys_clicked_interaction_ids";var va=t=>{try{let e=localStorage.getItem(Mr),o=e?JSON.parse(e):[];Array.isArray(o)&&!o.includes(t)&&(o.push(t),localStorage.setItem(Mr,JSON.stringify(o)))}catch{}},wa=t=>{try{let e=localStorage.getItem(ti);if(!e)return!1;let o=JSON.parse(e);return Array.isArray(o)&&o.includes(t)}catch{return!1}},ka=t=>{try{let e=localStorage.getItem(ti),o=e?JSON.parse(e):[];Array.isArray(o)&&!o.includes(t)&&(o.push(t),localStorage.setItem(ti,JSON.stringify(o)))}catch{}},Pr=({stories:t,activeStoryIndex:e,dataId:o,viewedStories:n,setViewedStories:i,onNextStory:s,onPrevStory:l,onClose:c})=>{let d=t[e],S=F=>{if(!F?.id)return 0;try{let j=`appstorys_cta_redirect_${F.id}`,pt=sessionStorage.getItem(j);if(pt){let Mt=JSON.parse(pt),vt=Date.now()-(Mt.timestamp||0),ye=F.slides?.length||1;if(sessionStorage.removeItem(j),vt<=300*1e3&&typeof Mt.slideIndex=="number"&&Mt.slideIndex>=0&&Mt.slideIndex<ye)return Mt.slideIndex}}catch{}return 0},[p,y]=Ot(()=>S(t[e])),[u,C]=Ot(0),[h,g]=Ot(t[e]?.styling?.soundToggle?.defaultSound==="no"),[b,m]=Ot(!1),[E,O]=Ot(!1),[D,L]=Ot(!1),[v,w]=Ot(null),[_,$]=Ot({width:typeof window<"u"?window.innerWidth:1280,height:typeof window<"u"?window.innerHeight:800}),[V,A]=Ot(typeof window<"u"?window.innerWidth>=1024:!1),[T,k]=Ot(!1),[B,W]=Ot(null),[H,Y]=Ot(null),[r,M]=Ot(null),[a,f]=Ot(!1),[x,z]=Ot("none"),[U,et]=Ot(null),X=Co(null),q=Co(null),J=Co(0),nt=Co(null),ht=Co(!1),dt=d?.slides[p],K=dt?.styling,it=K?.editorSource||K?.meta?.editorSource,lt=it==="studio"||it==="editor",mt=lt?K?.background?.media?.mediaUrl:dt?.image,gt=lt?dt?.content?.button_text:dt?.button_text,R=lt?dt?.content?.link:dt?.link,I=F=>{if(!F)return;if(F.video&&typeof F.video=="string")return F.video;let j=F.styling?.background?.media||F.content?.styling?.background?.media||F.content?.background?.media;if(j&&(j.mediaType==="video"||j.type==="video"||j.isVideo))return j.mediaUrl||j.url||j.link},N=I(dt),Z=Zo(dt),xt=Sa(dt),Ft=V?160:80,kt=Math.max(350,_.height-Ft),Wt=V?_.width*.75:_.width*.95,Bt=Math.min(kt,Wt/xt),Ht=Math.round(V?Math.max(450,Math.min(Bt,850)):Math.min(kt,850)),Tt=Math.round(Ht*xt),Kt=(F,j)=>{T||(C(0),M(F),W(p),Y(j),k(!0),setTimeout(()=>{y(j),C(0),m(!1),k(!1),W(null),Y(null),M(null)},xe+20))},ne=F=>{if(!(a||T)){if(C(0),F==="next"){if(e>=t.length-1){s();return}}else if(e<=0){l();return}f(!0),et(F),z("out"),setTimeout(()=>{F==="next"?s():l(),z("prepare-in"),setTimeout(()=>{z("in"),setTimeout(()=>{f(!1),z("none"),et(null)},320)},35)},280)}},ge=()=>{if(!(T||a))if(p<(d?.slides?.length||0)-1)Kt("next",p+1);else{if(d&&!n.includes(d.id)){let F=[...n,d.id];i(F),localStorage.setItem("app_storys_viewed_stories",JSON.stringify(F))}ne("next")}},so=()=>{T||a||(p>0?Kt("prev",p-1):ne("prev"))},Lo=async()=>{if(!d)return;let F={title:d.name,text:`Check out this story: ${d.name}`,url:window.location.href};if(dt?.id&&rt("shared",o,{story_slide:dt.id}),navigator.share)try{await navigator.share(F)}catch{}else if(navigator.clipboard)try{await navigator.clipboard.writeText(window.location.href),w("Story link copied to clipboard!"),setTimeout(()=>w(null),2500)}catch{}};if(Re(()=>{let F=()=>{$({width:window.innerWidth,height:window.innerHeight}),A(window.innerWidth>=1024)};return window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[]),Re(()=>{let F=document.body.style.overflow,j=document.body.style.touchAction;return document.body.style.overflow="hidden",document.body.style.touchAction="none",()=>{document.body.style.overflow=F,document.body.style.touchAction=j}},[]),Re(()=>{let F=S(d);y(F),C(0),m(!1),O(!1),k(!1),f(!1),z("none"),et(null),W(null),Y(null),M(null),g(d?.styling?.soundToggle?.defaultSound==="no")},[e]),Re(()=>{let F=()=>{document.hidden?(ht.current=E,O(!0),q.current&&q.current.pause()):ht.current||(O(!1),q.current&&q.current.play().catch(()=>{}))};return document.addEventListener("visibilitychange",F),()=>document.removeEventListener("visibilitychange",F)},[E]),Re(()=>{let F=j=>{if(!(document.activeElement?.tagName==="INPUT"||document.activeElement?.tagName==="TEXTAREA"))switch(j.key){case"ArrowRight":ge();break;case"ArrowLeft":so();break;case" ":j.preventDefault(),O(pt=>!pt);break;case"Escape":c();break;case"s":case"S":j.preventDefault(),Lo();break}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[p,e,E,d,c]),Re(()=>{if(d&&dt){let F=dt.id?String(dt.id):`${d.id||o}_slide_${p}`,j=`${e}_${p}_${F}`;nt.current!==j&&(nt.current=j,va(F),rt("viewed",o,{story_slide:F}))}},[e,p,d?.id,o,dt?.id]),Re(()=>{if(d&&dt&&!!N&&!b){let j=setTimeout(()=>{m(!0)},2e3);return()=>clearTimeout(j)}},[e,p,N,b]),Re(()=>{if(d&&dt){let F=d.styling?.slideShowTime||5,j=!!N;if(X.current&&clearInterval(X.current),E){q.current&&q.current.pause();return}else q.current&&q.current.play().catch(()=>{});return j&&!b||T||a?void 0:(X.current=setInterval(()=>{C(pt=>pt>=100?(ge(),100):pt+100/(F*10))},100),()=>{X.current&&clearInterval(X.current)})}},[e,p,E,b,T,a,N]),!dt)return null;let ao=()=>x==="out"?{transform:`translateX(${U==="next"?-120:120}px) scale(0.92)`,opacity:0,filter:"blur(6px)",transition:"transform 280ms cubic-bezier(0.4, 0, 0.2, 1), opacity 280ms cubic-bezier(0.4, 0, 0.2, 1), filter 280ms cubic-bezier(0.4, 0, 0.2, 1)",willChange:"transform, opacity, filter"}:x==="prepare-in"?{transform:`translateX(${U==="next"?120:-120}px) scale(0.92)`,opacity:0,filter:"blur(6px)",transition:"none",willChange:"transform, opacity, filter"}:x==="in"?{transform:"translateX(0px) scale(1)",opacity:1,filter:"blur(0px)",transition:"transform 320ms cubic-bezier(0.16, 1, 0.3, 1), opacity 320ms cubic-bezier(0.16, 1, 0.3, 1), filter 320ms cubic-bezier(0.16, 1, 0.3, 1)",willChange:"transform, opacity, filter"}:{transition:"transform 320ms cubic-bezier(0.16, 1, 0.3, 1), opacity 320ms cubic-bezier(0.16, 1, 0.3, 1), filter 320ms cubic-bezier(0.16, 1, 0.3, 1)"},Qt=()=>{J.current=Date.now(),O(!0)},ie=F=>{O(!1),Date.now()-J.current<300&&(F==="next"?ge():so())},fe=()=>m(!0),me=()=>{if(d?.id)try{sessionStorage.setItem(`appstorys_cta_redirect_${d.id}`,JSON.stringify({slideIndex:p,timestamp:Date.now()}))}catch{}},G=F=>{let j=F?.styling,pt=j?.editorSource||j?.meta?.editorSource,vt=pt==="studio"||pt==="editor"?F.content?.link:F.link;vt&&(me(),rt("clicked",o,{story_slide:F.id}),vt.startsWith("http")?window.open(vt,"_blank"):window.location.href=vt)},ut=async(F,j)=>{let{type:pt,questionId:Mt,pollId:vt,quizId:ye,ratingId:Zt,reactionId:Ne,productId:Be,optionId:lo,value:Xt,stickerId:Le,redirectUrl:se,code:Ee}=F;if(pt==="cta"){se&&(me(),rt("clicked",o,{story_slide:j.id,cta_id:Le}),se.startsWith("http")?window.open(se,"_blank"):window.location.href=se);return}O(!0);let te=pt||"interaction";te==="quizz"&&(te="quiz"),(te==="image"||pt?.startsWith("image_quiz"))&&(te="quiz"),pt?.startsWith("promo")&&(te="promo_code");let qt=Le||Mt||vt||ye||Zt||Ne||Be||j.id;if(wa(qt))return;ka(qt);let Ae=lo||F.selected_option||F.emoji||Xt||Ee||"",co=P.getState().userId||"anonymous",yn=tr(),ae=await Et(),mi={interaction_type:te,interaction_id:qt,story_slide:j.id,selected_option:String(Ae)};Xt!=null&&Xt!==""&&(mi.value=String(Xt)),fetch(`${yn}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...ae?{Authorization:`Bearer ${ae}`}:{}},body:JSON.stringify({user_id:co,campaign_id:o,event:"clicked",metadata:mi})}).catch(as=>console.error("AppStorys: Instant Tracking Failed",as))},zt=F=>{F.stopPropagation(),g(!h)},Vt=d?.styling?.crossButton,ct=d?.styling?.soundToggle,re=dt?.styling?.cta,$e=F=>T?r==="next"?F===B?"left":F===H?"center":F===(B??0)-1?"far-left":F===(B??0)-2?"hidden":F===(H??0)+1?"right":F===(H??0)+2?"far-right":"hidden":F===B?"right":F===H?"center":F===(B??0)+1?"far-right":F===(B??0)+2?"hidden":F===(H??0)-1?"left":F===(H??0)-2?"far-left":"hidden":F===p?"center":F===p-1?"left":F===p-2?"far-left":F===p+1?"right":F===p+2?"far-right":"hidden",Ie=V?{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",background:"radial-gradient(circle at center, #0B1424 0%, #03070E 100%)",zIndex:1e5,display:"flex",flexDirection:"column",alignItems:"center",overflow:"hidden",color:"white"}:{position:"fixed",top:0,left:0,width:"100vw",height:"100dvh",backgroundColor:"#000000",zIndex:1e5,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",touchAction:"none"},_t=V?{position:"absolute",width:`${Tt}px`,height:`${Ht}px`,backgroundColor:"#000",borderRadius:"20px",overflow:"hidden",display:"flex",flexDirection:"column",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.8)",border:"1px solid rgba(255, 255, 255, 0.1)"}:{position:"relative",width:`min(100vw, calc(100dvh * ${xt}))`,height:`min(100dvh, calc(100vw / ${xt}))`,aspectRatio:`${xt}`,backgroundColor:"#000",borderRadius:"0px",overflow:"hidden",display:"flex",flexDirection:"column"},$t={width:"240px",height:"420px",backgroundColor:"#000",borderRadius:"16px",overflow:"hidden",opacity:1,filter:"brightness(0.6)",display:"flex",flexDirection:"column",boxShadow:"0 10px 20px rgba(0,0,0,0.5)",border:"1px solid rgba(255, 255, 255, 0.05)",transform:"scale(0.9)",transition:"all 0.3s ease",cursor:"pointer"},jt=d.slides.reduce((F,j,pt)=>($e(pt)!=="hidden"&&F.push(pt),F),[]),Lt=new Set(jt);return Lt.add(p),p>0&&Lt.add(p-1),p>1&&Lt.add(p-2),p<d.slides.length-1&&Lt.add(p+1),p<d.slides.length-2&&Lt.add(p+2),Rt("div",{style:Ie,onClick:()=>!V&&ge(),children:[Rt("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:0,overflow:"hidden",pointerEvents:"none",transition:"all 0.6s ease-in-out"},children:[N?Q("video",{src:N,style:{width:"100%",height:"100%",objectFit:"cover",filter:"blur(120px) saturate(1.8) opacity(0.35)"},muted:!0}):mt||!lt&&d.thumbnail?Q(de,{src:mt||d.thumbnail,style:{width:"100%",height:"100%",filter:"blur(120px) saturate(1.8) opacity(0.35)"}}):null,Q("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(5, 5, 8, 0.4)"}})]},`${e}-${T?H:p}`),V&&Rt("div",{style:{width:"100%",display:"flex",flexDirection:"column",paddingTop:"20px",zIndex:10,...ao()},children:[Q("div",{style:{width:"100%",display:"flex",gap:"8px",padding:"0 20px",boxSizing:"border-box"},children:d.slides.map((F,j)=>{let pt=T&&H!==null?H:p,Mt="0%";return j<pt?Mt="100%":j===pt&&(Mt=`${u}%`),Q("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.15)",borderRadius:"2px",overflow:"hidden"},children:Q("div",{style:{width:Mt,height:"100%",backgroundColor:"white",transition:j===pt&&u>0&&!T?"width 0.1s linear":"none"}})},j)})}),Rt("div",{style:{width:"100%",margin:"0 auto",display:"grid",gridTemplateColumns:`minmax(0, 1fr) ${Tt}px minmax(0, 1fr)`,gap:"12px",alignItems:"center",marginTop:"16px",padding:"0 20px",boxSizing:"border-box",zIndex:D?2e3:10},children:[Q("div",{style:{paddingLeft:"0px"}}),Rt("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[Rt("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[Q(de,{src:d.thumbnail,alt:d.name,style:{width:"44px",height:"44px",borderRadius:"50%",border:"2px solid white",margin:0}}),Q("span",{style:{color:"white",fontWeight:"bold",fontSize:"16px",whiteSpace:"nowrap"},children:d.name})]}),Rt("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Q(Jn,{config:{enabled:d?.styling?.share?.enabled??!0,image:d?.styling?.share?.image??"",color:{cross:d?.styling?.share?.color?.cross??"#ffffff",fill:d?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:d?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:d?.styling?.share?.size??44},onPress:Lo,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"12px",width:"44px",height:"44px"}}),Q(be,{config:{size:(h?ct?.mute?.size:ct?.unmute?.size)||44,color:{cross:(h?ct?.mute?.color?.cross:ct?.unmute?.color?.cross)||"#ffffff",fill:(h?ct?.mute?.color?.fill:ct?.unmute?.color?.fill)||"rgba(255,255,255,0.08)",stroke:(h?ct?.mute?.color?.stroke:ct?.unmute?.color?.stroke)||"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:(h?ct?.mute?.image:ct?.unmute?.image)||""},onPress:zt,type:h?"mute":"unmute",enabled:!!ct?.enabled&&!!N,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"12px",width:"44px",height:"44px"}}),Q(Lr,{isPaused:E,onPress:()=>O(!E),size:44,style:{borderRadius:"12px",margin:0}})]})]}),Rt("div",{style:{display:"flex",gap:"10px",flex:1,justifyContent:"flex-end",paddingRight:"0px"},children:[Rt("div",{style:{position:"relative"},children:[Q("button",{onClick:()=>{L(!D),O(!D)},style:{width:"44px",height:"44px",background:D?"rgba(255,255,255,0.15)":"rgba(255,255,255,0.08)",border:D?"1px solid white":"1px solid rgba(255,255,255,0.1)",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"12px",cursor:"pointer",transition:"all 0.2s",padding:0,outline:"none"},children:Rt("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Q("rect",{x:"3",y:"3",width:"7",height:"7"}),Q("rect",{x:"14",y:"3",width:"7",height:"7"}),Q("rect",{x:"14",y:"14",width:"7",height:"7"}),Q("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),D&&Rt(Ra,{children:[Q("style",{children:`
119
+ `}),it.map(a=>!a||typeof a!="object"||!(a.type||"").toLowerCase()?null:Ur(Dr,{data:a,onInteraction:e,isEditing:o,isActive:i,isMuted:s},a.id))]})};import{useState as Ma}from"react";import{jsx as Po,jsxs as Wa}from"react/jsx-runtime";var _a=({isPaused:t,onPress:e,style:o,size:n=36})=>{let[i,s]=Ma(!1);return Po("button",{onClick:e,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:`${n}px`,height:`${n}px`,background:i?"rgba(255, 255, 255, 0.15)":"rgba(255, 255, 255, 0.08)",border:i?"1px solid white":"1px solid rgba(255, 255, 255, 0.1)",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"10px",cursor:"pointer",transition:"all 0.2s ease",padding:0,outline:"none",...o},children:t?Po("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:Po("path",{d:"M5 3.867v16.266c0 .54.58.88 1.05.61l14.133-8.133c.46-.27.46-.94 0-1.21L6.05 3.257C5.58 2.987 5 3.327 5 3.867z"})}):Wa("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:[Po("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),Po("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})})},Hr=_a;import{jsx as li}from"react/jsx-runtime";var Da=t=>{switch(t){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},$a=({cta:t,buttonText:e,onPress:o})=>{if(!t||!e||e.trim()==="")return null;let n=t?.opacity,i=n!==void 0?Number(n)>1?Number(n)/100:Number(n):void 0;return li("div",{style:{position:"absolute",bottom:t?.margin?.bottom,left:t?.margin?.left,right:t?.margin?.right,display:"flex",justifyContent:Da(t?.container?.alignment),width:"100%",pointerEvents:"none",boxSizing:"border-box",zIndex:10,opacity:i},children:li("button",{style:{backgroundColor:Ct(t?.container?.backgroundColor)||"#F7921C",borderColor:et(t?.container?.borderColor)||"transparent",borderWidth:t?.container?.borderWidth??0,borderStyle:t?.container?.borderWidth?"solid":"none",borderTopRightRadius:t?.cornerRadius?.topRight,borderTopLeftRadius:t?.cornerRadius?.topLeft,borderBottomRightRadius:t?.cornerRadius?.bottomRight,borderBottomLeftRadius:t?.cornerRadius?.bottomLeft,height:t?.container?.height||42,width:t?.container?.ctaFullWidth?"100%":t?.container?.ctaWidth||"auto",justifyContent:"center",alignItems:"center",display:"flex",cursor:"pointer",outline:"none",pointerEvents:"auto",padding:"0 12px",boxSizing:"border-box"},onClick:o,children:li("span",{style:{color:et(t?.text?.color)||"#ffffff",fontSize:t?.text?.fontSize||14,fontFamily:ut(t?.text?.fontFamily),fontWeight:t?.text?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:t?.text?.fontDecoration?.includes("italic")?"italic":"normal",textDecorationLine:t?.text?.fontDecoration?.includes("underline")?"underline":"none",textAlign:"center"},children:Le(e)})})})},di=$a;import{jsx as Ve,jsxs as Oa}from"react/jsx-runtime";var Na=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,style:n})=>{if(!t||t.enabled===!1)return null;let{size:i=18,margin:s,color:d,image:c,selectedStyle:l}=t,y=o?40:i,u={marginTop:o?0:s?.top??0,marginBottom:o?0:s?.bottom??0,marginLeft:o?0:s?.left??0,marginRight:o?0:s?.right??0,width:y,height:y,backgroundColor:d?.fill||"transparent",borderColor:d?.stroke||"transparent",borderWidth:y*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"relative",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:d?.stroke?"solid":"none",...n},m=()=>{let f=d?.cross||"#ffffff";return Oa("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"none",stroke:f,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[Ve("circle",{cx:"18",cy:"5",r:"3"}),Ve("circle",{cx:"6",cy:"12",r:"3"}),Ve("circle",{cx:"18",cy:"19",r:"3"}),Ve("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),Ve("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})};return Ve("button",{onClick:e,style:u,children:c&&c.trim()!==""?Ve("img",{src:c,style:{width:y,height:y,objectFit:"contain"},alt:"share"}):m()})},ci=Na;import{Fragment as Ya,jsx as tt,jsxs as At}from"react/jsx-runtime";var gn=t=>{if(t)return t.content?.canva||t.canva||t.styling?.canva||t.meta?.canva||t.content?.styling?.canva||t.content?.meta?.canva},ja=t=>{let e=gn(t),o=Number(e?.width),n=Number(e?.height);return o>0&&n>0?o/n:9/16},Mo=.63;var Fe=580,ui="cubic-bezier(0.65, 0, 0.35, 1)",pi="cubic-bezier(0.45, 0, 0.25, 1)";function qa(t,e){let o=Math.round(e*1.08),n=o+Math.round(e*Mo)+20;switch(t){case"center":return{transform:"translateX(0px) scale(1)",opacity:1,zIndex:10,pointerEvents:"auto",boxShadow:"0 32px 64px -12px rgba(0,0,0,0.9)",filter:"brightness(1)"};case"left":return{transform:`translateX(-${o}px) scale(${Mo})`,opacity:1,filter:"brightness(0.55)",zIndex:5,pointerEvents:"auto",boxShadow:"0 8px 24px rgba(0,0,0,0.5)"};case"right":return{transform:`translateX(${o}px) scale(${Mo})`,opacity:1,filter:"brightness(0.55)",zIndex:5,pointerEvents:"auto",boxShadow:"0 8px 24px rgba(0,0,0,0.5)"};case"far-left":return{transform:`translateX(-${n}px) scale(${Mo})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};case"far-right":return{transform:`translateX(${n}px) scale(${Mo})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};default:return{opacity:0,zIndex:1,pointerEvents:"none",transform:"translateX(0px) scale(1)",filter:"brightness(1)"}}}var Yr=({src:t,isActive:e,isAnimating:o,isMuted:n,onLoadedData:i,activeVideoRef:s,objectFit:d="contain",objectPosition:c="center center"})=>{let l=Vr.useRef(null);return Vr.useEffect(()=>{e&&!o?(s.current=l.current,l.current?.play().catch(()=>{}),l.current&&l.current.readyState>=1&&i?.()):(l.current?.pause(),s.current===l.current&&(s.current=null))},[e,o,t,s,i]),tt("video",{ref:l,src:t,playsInline:!0,muted:n,onLoadedData:i,onCanPlay:i,onLoadedMetadata:i,style:{width:"100%",height:"100%",objectFit:d,objectPosition:c}})},Gr="appstorys_viewed_slide_ids",gi="appstorys_clicked_interaction_ids";var Ua=t=>{try{let e=localStorage.getItem(Gr),o=e?JSON.parse(e):[];Array.isArray(o)&&!o.includes(t)&&(o.push(t),localStorage.setItem(Gr,JSON.stringify(o)))}catch{}},Ha=t=>{try{let e=localStorage.getItem(gi);if(!e)return!1;let o=JSON.parse(e);return Array.isArray(o)&&o.includes(t)}catch{return!1}},Va=t=>{try{let e=localStorage.getItem(gi),o=e?JSON.parse(e):[];Array.isArray(o)&&!o.includes(t)&&(o.push(t),localStorage.setItem(gi,JSON.stringify(o)))}catch{}},Qr=({stories:t,activeStoryIndex:e,dataId:o,viewedStories:n,setViewedStories:i,onNextStory:s,onPrevStory:d,onClose:c})=>{let l=t[e],y=w=>{if(!w?.id)return 0;try{let q=`appstorys_cta_redirect_${w.id}`,ht=sessionStorage.getItem(q);if(ht){let jt=JSON.parse(ht),It=Date.now()-(jt.timestamp||0),we=w.slides?.length||1;if(sessionStorage.removeItem(q),It<=300*1e3&&typeof jt.slideIndex=="number"&&jt.slideIndex>=0&&jt.slideIndex<we)return jt.slideIndex}}catch{}return 0},[u,m]=Yt(()=>y(t[e])),[f,P]=Yt(0),[g,b]=Yt(t[e]?.styling?.soundToggle?.defaultSound==="no"),[R,C]=Yt(!1),[h,T]=Yt(!1),[E,X]=Yt(!1),[I,S]=Yt(null),[M,x]=Yt({width:typeof window<"u"?window.innerWidth:1280,height:typeof window<"u"?window.innerHeight:800}),[N,U]=Yt(typeof window<"u"?window.innerWidth>=1024:!1),[z,O]=Yt(!1),[B,K]=Yt(null),[v,A]=Yt(null),[H,it]=Yt(null),[at,a]=Yt(!1),[F,r]=Yt("none"),[p,j]=Yt(null),k=be(null),G=be(null),V=be(0),rt=be(null),lt=be(!1),Z=l?.slides[u],gt=Z?.styling,Q=gt?.editorSource||gt?.meta?.editorSource,dt=Q==="studio"||Q==="editor",yt=dt?gt?.background?.media?.mediaUrl:Z?.image,ct=dt?Z?.content?.button_text:Z?.button_text,mt=dt?Z?.content?.link:Z?.link,$=w=>{if(!w)return;if(w.video&&typeof w.video=="string")return w.video;let q=w.styling?.background?.media||w.content?.styling?.background?.media||w.content?.background?.media;if(q&&(q.mediaType==="video"||q.type==="video"||q.isVideo))return q.mediaUrl||q.url||q.link},_=$(Z),D=gn(Z),L=ja(Z),Y=N?160:80,ot=Math.max(350,M.height-Y),ft=N?M.width*.75:M.width*.95,Dt=Math.min(ot,ft/L),Ft=Math.round(N?Math.max(450,Math.min(Dt,850)):Math.min(ot,850)),$t=Math.round(Ft*L),_t=(w,q)=>{z||(P(0),it(w),K(u),A(q),O(!0),setTimeout(()=>{m(q),P(0),C(!1),O(!1),K(null),A(null),it(null)},Fe+20))},Jt=w=>{if(!(at||z)){if(P(0),w==="next"){if(e>=t.length-1){s();return}}else if(e<=0){d();return}a(!0),j(w),r("out"),setTimeout(()=>{w==="next"?s():d(),r("prepare-in"),setTimeout(()=>{r("in"),setTimeout(()=>{a(!1),r("none"),j(null)},320)},35)},280)}},re=()=>{if(!(z||at))if(u<(l?.slides?.length||0)-1)_t("next",u+1);else{if(l&&!n.includes(l.id)){let w=[...n,l.id];i(w),localStorage.setItem("app_storys_viewed_stories",JSON.stringify(w))}Jt("next")}},ce=()=>{z||at||(u>0?_t("prev",u-1):Jt("prev"))},Ie=async()=>{if(!l)return;let w={title:l.name,text:`Check out this story: ${l.name}`,url:window.location.href};if(Z?.id&&st("shared",o,{story_slide:Z.id}),navigator.share)try{await navigator.share(w)}catch{}else if(navigator.clipboard)try{await navigator.clipboard.writeText(window.location.href),S("Story link copied to clipboard!"),setTimeout(()=>S(null),2500)}catch{}};Te(()=>{let w=()=>{x({width:window.innerWidth,height:window.innerHeight}),U(window.innerWidth>=1024)};return window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[]),Te(()=>{let w=document.body.style.overflow,q=document.body.style.touchAction;return document.body.style.overflow="hidden",document.body.style.touchAction="none",()=>{document.body.style.overflow=w,document.body.style.touchAction=q}},[]);let Ge=be(e),Qe=be(re),Uo=be(ce),Tn=be(Ie),Co=be(c);if(Te(()=>{Qe.current=re,Uo.current=ce,Tn.current=Ie,Co.current=c}),Te(()=>{let w=e<Ge.current;Ge.current=e;let q=w&&l?.slides?.length?l.slides.length-1:y(l);m(q),P(0),C(!1),T(!1),O(!1),a(!1),r("none"),j(null),K(null),A(null),it(null),b(l?.styling?.soundToggle?.defaultSound==="no")},[e]),Te(()=>{let w=()=>{document.hidden?(lt.current=h,T(!0),G.current&&G.current.pause()):lt.current||(T(!1),G.current&&G.current.play().catch(()=>{}))};return document.addEventListener("visibilitychange",w),()=>document.removeEventListener("visibilitychange",w)},[h]),Te(()=>{let w=q=>{if(!(document.activeElement?.tagName==="INPUT"||document.activeElement?.tagName==="TEXTAREA"))switch(q.key){case"ArrowRight":Qe.current();break;case"ArrowLeft":Uo.current();break;case" ":q.preventDefault(),T(ht=>!ht);break;case"Escape":Co.current();break;case"s":case"S":q.preventDefault(),Tn.current();break}};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[]),Te(()=>{if(l&&Z){let w=Z.id?String(Z.id):`${l.id||o}_slide_${u}`,q=`${e}_${u}_${w}`;rt.current!==q&&(rt.current=q,Ua(w),st("viewed",o,{story_slide:w}))}},[e,u,l?.id,o,Z?.id]),Te(()=>{if(l&&Z&&!!_&&!R){let q=setTimeout(()=>{C(!0)},2e3);return()=>clearTimeout(q)}},[e,u,_,R]),Te(()=>{if(l&&Z){let w=l.styling?.slideShowTime||5,q=!!_;if(k.current&&clearInterval(k.current),h){G.current&&G.current.pause();return}else G.current&&G.current.play().catch(()=>{});return q&&!R||z||at?void 0:(k.current=setInterval(()=>{P(ht=>ht>=100?(re(),100):ht+100/(w*10))},100),()=>{k.current&&clearInterval(k.current)})}},[e,u,h,R,z,at,_]),!Z)return null;let vo=()=>F==="out"?{transform:`translateX(${p==="next"?-120:120}px) scale(0.92)`,opacity:0,filter:"blur(6px)",transition:"transform 280ms cubic-bezier(0.4, 0, 0.2, 1), opacity 280ms cubic-bezier(0.4, 0, 0.2, 1), filter 280ms cubic-bezier(0.4, 0, 0.2, 1)",willChange:"transform, opacity, filter"}:F==="prepare-in"?{transform:`translateX(${p==="next"?120:-120}px) scale(0.92)`,opacity:0,filter:"blur(6px)",transition:"none",willChange:"transform, opacity, filter"}:F==="in"?{transform:"translateX(0px) scale(1)",opacity:1,filter:"blur(0px)",transition:"transform 320ms cubic-bezier(0.16, 1, 0.3, 1), opacity 320ms cubic-bezier(0.16, 1, 0.3, 1), filter 320ms cubic-bezier(0.16, 1, 0.3, 1)",willChange:"transform, opacity, filter"}:{transition:"transform 320ms cubic-bezier(0.16, 1, 0.3, 1), opacity 320ms cubic-bezier(0.16, 1, 0.3, 1), filter 320ms cubic-bezier(0.16, 1, 0.3, 1)"},ue=()=>{V.current=Date.now(),T(!0)},Gt=w=>{T(!1),Date.now()-V.current<300&&(w==="next"?re():ce())},ve=()=>C(!0),De=()=>{if(l?.id)try{sessionStorage.setItem(`appstorys_cta_redirect_${l.id}`,JSON.stringify({slideIndex:u,timestamp:Date.now()}))}catch{}},J=w=>{let q=w?.styling,ht=q?.editorSource||q?.meta?.editorSource,It=ht==="studio"||ht==="editor"?w.content?.link:w.link;if(It){if(De(),st("clicked",o,{story_slide:w.id}),wt(It)){c();return}It.startsWith("http")?window.open(It,"_blank"):window.location.href=It}},bt=async(w,q)=>{let{type:ht,questionId:jt,pollId:It,quizId:we,ratingId:ge,reactionId:Je,productId:Ne,optionId:wo,value:Xt,stickerId:Oe,redirectUrl:oe,code:je}=w;if(ht==="cta"){if(oe){if(De(),st("clicked",o,{story_slide:q.id,cta_id:Oe}),wt(oe)){c();return}oe.startsWith("http")?window.open(oe,"_blank"):window.location.href=oe}return}T(!0);let se=ht||"interaction";se==="quizz"&&(se="quiz"),(se==="image"||ht?.startsWith("image_quiz"))&&(se="quiz"),ht?.startsWith("promo")&&(se="promo_code");let Qt=Oe||jt||It||we||ge||Je||Ne||q.id;if(Ha(Qt))return;Va(Qt);let qe=wo||w.selected_option||w.emoji||Xt||je||"",Xe=W.getState().userId||"anonymous",In=gr(),fe=await Pt(),Fi={interaction_type:se,interaction_id:Qt,story_slide:q.id,selected_option:String(qe)};Xt!=null&&Xt!==""&&(Fi.value=String(Xt)),fetch(`${In}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...fe?{Authorization:`Bearer ${fe}`}:{}},body:JSON.stringify({user_id:Xe,campaign_id:o,event:"clicked",metadata:Fi})}).catch(Ts=>console.error("AppStorys: Instant Tracking Failed",Ts))},Rt=w=>{w.stopPropagation(),b(!g)},te=l?.styling?.crossButton,xt=l?.styling?.soundToggle,pe=Z?.styling?.cta,ee=w=>z?H==="next"?w===B?"left":w===v?"center":w===(B??0)-1?"far-left":w===(B??0)-2?"hidden":w===(v??0)+1?"right":w===(v??0)+2?"far-right":"hidden":w===B?"right":w===v?"center":w===(B??0)+1?"far-right":w===(B??0)+2?"hidden":w===(v??0)-1?"left":w===(v??0)-2?"far-left":"hidden":w===u?"center":w===u-1?"left":w===u-2?"far-left":w===u+1?"right":w===u+2?"far-right":"hidden",ze=N?{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",background:"radial-gradient(circle at center, #0B1424 0%, #03070E 100%)",zIndex:1e5,display:"flex",flexDirection:"column",alignItems:"center",overflow:"hidden",color:"white"}:{position:"fixed",top:0,left:0,width:"100vw",height:"100dvh",backgroundColor:"#000000",zIndex:1e5,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",touchAction:"none"},Ht=N?{position:"absolute",width:`${$t}px`,height:`${Ft}px`,backgroundColor:"#000",borderRadius:"20px",overflow:"hidden",display:"flex",flexDirection:"column",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.8)",border:"1px solid rgba(255, 255, 255, 0.1)"}:{position:"relative",width:`min(100vw, calc(100dvh * ${L}))`,height:`min(100dvh, calc(100vw / ${L}))`,aspectRatio:`${L}`,backgroundColor:"#000",borderRadius:"0px",overflow:"hidden",display:"flex",flexDirection:"column"},$e={width:"240px",height:"420px",backgroundColor:"#000",borderRadius:"16px",overflow:"hidden",opacity:1,filter:"brightness(0.6)",display:"flex",flexDirection:"column",boxShadow:"0 10px 20px rgba(0,0,0,0.5)",border:"1px solid rgba(255, 255, 255, 0.05)",transform:"scale(0.9)",transition:"all 0.3s ease",cursor:"pointer"},Nt=l.slides.reduce((w,q,ht)=>(ee(ht)!=="hidden"&&w.push(ht),w),[]),Wt=new Set(Nt);return Wt.add(u),u>0&&Wt.add(u-1),u>1&&Wt.add(u-2),u<l.slides.length-1&&Wt.add(u+1),u<l.slides.length-2&&Wt.add(u+2),At("div",{style:ze,onClick:()=>!N&&re(),children:[At("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:0,overflow:"hidden",pointerEvents:"none",transition:"all 0.6s ease-in-out"},children:[_?tt("video",{src:_,style:{width:"100%",height:"100%",objectFit:"cover",filter:"blur(120px) saturate(1.8) opacity(0.35)"},muted:!0}):yt||!dt&&l.thumbnail?tt(ye,{src:yt||l.thumbnail,style:{width:"100%",height:"100%",filter:"blur(120px) saturate(1.8) opacity(0.35)"}}):null,tt("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(5, 5, 8, 0.4)"}})]},`${e}-${z?v:u}`),N&&At("div",{style:{width:"100%",display:"flex",flexDirection:"column",paddingTop:"20px",zIndex:10,...vo()},children:[tt("div",{style:{width:"100%",display:"flex",gap:"8px",padding:"0 20px",boxSizing:"border-box"},children:l.slides.map((w,q)=>{let ht=z&&v!==null?v:u,jt="0%";return q<ht?jt="100%":q===ht&&(jt=`${f}%`),tt("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.15)",borderRadius:"2px",overflow:"hidden"},children:tt("div",{style:{width:jt,height:"100%",backgroundColor:"white",transition:q===ht&&f>0&&!z?"width 0.1s linear":"none"}})},q)})}),At("div",{style:{width:"100%",margin:"0 auto",display:"grid",gridTemplateColumns:`minmax(0, 1fr) ${$t}px minmax(0, 1fr)`,gap:"12px",alignItems:"center",marginTop:"16px",padding:"0 20px",boxSizing:"border-box",zIndex:E?2e3:10},children:[tt("div",{style:{paddingLeft:"0px"}}),At("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[At("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[tt(ye,{src:l.thumbnail,alt:l.name,style:{width:"44px",height:"44px",borderRadius:"50%",border:"2px solid white",margin:0}}),tt("span",{style:{color:"white",fontWeight:"bold",fontSize:"16px",whiteSpace:"nowrap"},children:l.name})]}),At("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[tt(ci,{config:{enabled:l?.styling?.share?.enabled??!0,image:l?.styling?.share?.image??"",color:{cross:l?.styling?.share?.color?.cross??"#ffffff",fill:l?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:l?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:l?.styling?.share?.size??44},onPress:Ie,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"12px",width:"44px",height:"44px"}}),tt(Re,{config:{size:(g?xt?.mute?.size:xt?.unmute?.size)||44,color:{cross:(g?xt?.mute?.color?.cross:xt?.unmute?.color?.cross)||"#ffffff",fill:(g?xt?.mute?.color?.fill:xt?.unmute?.color?.fill)||"rgba(255,255,255,0.08)",stroke:(g?xt?.mute?.color?.stroke:xt?.unmute?.color?.stroke)||"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:(g?xt?.mute?.image:xt?.unmute?.image)||""},onPress:Rt,type:g?"mute":"unmute",enabled:!!xt?.enabled&&!!_,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"12px",width:"44px",height:"44px"}}),tt(Hr,{isPaused:h,onPress:()=>T(!h),size:44,style:{borderRadius:"12px",margin:0}})]})]}),At("div",{style:{display:"flex",gap:"10px",flex:1,justifyContent:"flex-end",paddingRight:"0px"},children:[At("div",{style:{position:"relative"},children:[tt("button",{onClick:()=>{X(!E),T(!E)},style:{width:"44px",height:"44px",background:E?"rgba(255,255,255,0.15)":"rgba(255,255,255,0.08)",border:E?"1px solid white":"1px solid rgba(255,255,255,0.1)",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"12px",cursor:"pointer",transition:"all 0.2s",padding:0,outline:"none"},children:At("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[tt("rect",{x:"3",y:"3",width:"7",height:"7"}),tt("rect",{x:"14",y:"3",width:"7",height:"7"}),tt("rect",{x:"14",y:"14",width:"7",height:"7"}),tt("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),E&&At(Ya,{children:[tt("style",{children:`
120
120
  @keyframes fadeUp {
121
121
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
122
122
  to { opacity: 1; transform: translateY(0) scale(1); }
123
123
  }
124
- `}),Rt("div",{style:{position:"absolute",top:"46px",right:0,width:"260px",background:"rgba(25, 25, 25, 0.98)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:"16px",padding:"18px",boxShadow:"0 20px 25px -5px rgba(0,0,0,0.4), 0 10px 10px -5px rgba(0,0,0,0.4)",zIndex:1001,animation:"fadeUp 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards"},children:[Q("div",{style:{fontSize:"11px",fontWeight:"bold",color:"#9CA3AF",letterSpacing:"1px",textTransform:"uppercase",marginBottom:"16px",paddingBottom:"10px",borderBottom:"1px solid rgba(255,255,255,0.06)"},children:"Keyboard Shortcuts"}),Q("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[{key:"\u2192",label:"Next slide"},{key:"\u2190",label:"Previous slide"},{key:"space",label:"Play/Pause"},{key:"esc",label:"Close story"},{key:"S",label:"Share story link"}].map(({key:F,label:j})=>Rt("div",{style:{display:"flex",alignItems:"center",gap:"14px",justifyContent:"flex-start"},children:[Q("span",{style:{minWidth:"54px",display:"inline-flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.08)",padding:"5px 8px",borderRadius:"5px",fontSize:"12px",color:"white",border:"1px solid rgba(255,255,255,0.1)",boxSizing:"border-box"},children:F}),Q("span",{style:{fontSize:"13px",color:"#E5E7EB",fontWeight:"500",textAlign:"left"},children:j})]},F))})]})]})]}),Q(Dt,{config:{enabled:Vt?.enabled??!0,image:"",color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:44},onPress:c,style:{position:"relative",borderRadius:"12px"}})]})]})]}),Q("div",{style:{flex:1,width:"100%",display:"flex",flexDirection:"column",justifyContent:V?"flex-start":"center",alignItems:"center",paddingTop:V?"14px":"0px",...ao()},children:Rt("div",{style:{display:V?"grid":"flex",gridTemplateColumns:V?`minmax(0, 1fr) ${Tt}px minmax(0, 1fr)`:"none",alignItems:"center",justifyContent:"center",gap:"12px",width:"100%",maxWidth:"1400px",position:"relative"},onClick:F=>V&&F.stopPropagation(),children:[V&&Q("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(p>0||e>0)&&Q("button",{onClick:so,style:{background:"rgba(0,0,0,0.45)",border:"1px solid rgba(255,255,255,0.1)",color:"white",borderRadius:"50%",width:"44px",height:"44px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",backdropFilter:"blur(10px)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 8px 16px rgba(0,0,0,0.3)",outline:"none"},onMouseEnter:F=>{F.currentTarget.style.background="rgba(0,0,0,0.75)",F.currentTarget.style.transform="scale(1.1)",F.currentTarget.style.borderColor="rgba(255,255,255,0.25)"},onMouseLeave:F=>{F.currentTarget.style.background="rgba(0,0,0,0.45)",F.currentTarget.style.transform="scale(1)",F.currentTarget.style.borderColor="rgba(255,255,255,0.1)"},children:Q("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:Q("polyline",{points:"15 18 9 12 15 6"})})})}),V?Q("div",{style:{width:`${Tt}px`,height:`${Ht}px`,position:"relative",zIndex:5,overflow:"visible"},children:Array.from(Lt).sort((F,j)=>F-j).map(F=>{let j=d.slides[F];if(!j)return null;let pt=$e(F),Mt=Ca(pt,Tt),vt=j?.styling,ye=vt?.editorSource||vt?.meta?.editorSource,Zt=ye==="studio"||ye==="editor",Ne=vt?.background?.media?.mediaUrl||j?.image,Be=I(j),lo=St(vt?.background)||"#000000",Xt=Zt?j?.content?.button_text:j?.button_text,Le=Zt?j?.content?.link:j?.link,se=vt?.background?.media?.sizing||vt?.background?.sizing||vt?.media?.sizing||j?.sizing,Ee=se==="fill"?"cover":se==="fit"?"contain":se==="stretch"?"fill":Zt?"contain":"cover",te=vt?.background?.media?.position||vt?.background?.position||vt?.media?.position||j?.content?.background?.media?.position||j?.content?.media?.position||j?.position,qt=Ve(te),co=F===p&&!T||T&&F===H,yn={display:"flex",justifyContent:"center",alignItems:"center",background:Zt?lo:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"16px"};return Rt("div",{style:{..._t,position:"absolute",top:0,left:0,width:`${Tt}px`,height:`${Ht}px`,...Mt,transition:pt==="hidden"||pt==="far-left"||pt==="far-right"?`opacity ${xe}ms ease, transform ${xe}ms ease`:F===B?`transform ${xe}ms ${Kn}, opacity ${xe}ms ${Kn}, filter ${xe}ms ${Kn}`:`transform ${xe}ms ${Zn}, opacity ${xe}ms ${Zn}, filter ${xe}ms ${Zn}`,transformOrigin:"center center",willChange:"transform, opacity, filter"},onClick:ae=>ae.stopPropagation(),children:[Q("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:Qt,onMouseUp:()=>ie("prev"),onTouchStart:Qt,onTouchEnd:()=>ie("prev")}),Q("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:Qt,onMouseUp:()=>ie("next"),onTouchStart:Qt,onTouchEnd:()=>ie("next")}),Rt("div",{style:yn,children:[Be?Q(Ar,{src:Be,isActive:co,isAnimating:T,isMuted:h,onLoadedData:fe,activeVideoRef:q,objectFit:Ee,objectPosition:qt}):Ne||!Zt&&d?.thumbnail?Q(de,{src:Ne||d?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:Ee,objectPosition:qt}}):null,Q(Gn,{content:{...j.content,lottie:j.content?.lottie||j?.lottie||j.styling?.lottie,video:j.content?.video||j?.videoOverlay||j.styling?.video,image:j.content?.image||j?.imageOverlay||j.styling?.image,canva:Zo(j),editorSource:j.content?.editorSource||j.editorSource||j.styling?.editorSource||j.meta?.editorSource,styling:{...j.content?.styling,...j?.styling},interactions:j.interactions},elapsedTime:co?u/100*(d.styling?.slideShowTime||5):0,onInteraction:async ae=>{co&&ut(ae,j)}})]}),(Xt||Le)&&Q(Xn,{cta:j?.styling?.cta,buttonText:Xt||"Learn More",onPress:ae=>{ae&&ae.stopPropagation&&ae.stopPropagation(),G(j)}})]},j.id||F)})}):Q("div",{style:{width:"100vw",height:"100dvh",maxWidth:"100vw",maxHeight:"100dvh",overflow:"hidden",position:"relative",zIndex:5,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",backgroundColor:"#000000"},children:d.slides.map((F,j)=>{if(Math.abs(j-p)>1)return Q("div",{style:{display:"none"}},F.id||j);let pt=F?.styling,Mt=pt?.editorSource||pt?.meta?.editorSource,vt=Mt==="studio"||Mt==="editor",ye=pt?.background?.media?.mediaUrl||F?.image,Zt=F?.video||(vt?F?.content?.video?.[0]?.link:void 0),Ne=St(pt?.background)||"#000000",Be=vt?F?.content?.button_text:F?.button_text,lo=vt?F?.content?.link:F?.link,Xt=pt?.background?.media?.sizing||pt?.background?.sizing||pt?.media?.sizing||F?.sizing,Le=Xt==="fill"?"cover":Xt==="fit"?"contain":Xt==="stretch"?"fill":vt?"contain":"cover",se=pt?.background?.media?.position||pt?.background?.position||pt?.media?.position||F?.content?.background?.media?.position||F?.content?.media?.position||F?.position,Ee=Ve(se),te=j===p;return te?Q("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:Rt("div",{style:{..._t},onClick:qt=>qt.stopPropagation(),children:[Q("div",{style:{position:"absolute",top:"calc(10px + env(safe-area-inset-top, 0px))",left:"10px",right:"10px",display:"flex",gap:"4px",padding:"0 4px",zIndex:10},children:d.slides.map((qt,Ae)=>{let mn=Ae<p?"100%":Ae===p?`${u}%`:"0%";return Q("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.3)",borderRadius:"2px",overflow:"hidden"},children:Q("div",{style:{width:mn,height:"100%",backgroundColor:"white",transition:Ae===p&&u>0&&!T?"width 0.1s linear":"none"}})},Ae)})}),Rt("div",{style:{position:"absolute",top:"calc(22px + env(safe-area-inset-top, 0px))",left:"10px",right:"10px",display:"flex",alignItems:"center",justifyContent:"space-between",zIndex:10,padding:"5px"},children:[Rt("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Q(de,{src:d.thumbnail,alt:d.name,style:{width:"32px",height:"32px",borderRadius:"50%"}}),Q("span",{style:{color:"white",fontWeight:"bold",fontSize:"14px",textShadow:"0 1px 3px rgba(0,0,0,0.8)"},children:d.name})]}),Rt("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Q(Jn,{config:{enabled:d?.styling?.share?.enabled??!0,image:d?.styling?.share?.image??"",color:{cross:d?.styling?.share?.color?.cross??"#ffffff",fill:d?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:d?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:d?.styling?.share?.size??32},onPress:Lo,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"10px",width:"32px",height:"32px"}}),Q(be,{config:{size:(h?ct?.mute?.size:ct?.unmute?.size)||32,color:{cross:(h?ct?.mute?.color?.cross:ct?.unmute?.color?.cross)||"#ffffff",fill:(h?ct?.mute?.color?.fill:ct?.unmute?.color?.fill)||"rgba(255,255,255,0.08)",stroke:(h?ct?.mute?.color?.stroke:ct?.unmute?.color?.stroke)||"transparent"},margin:(h?ct?.mute?.margin:ct?.unmute?.margin)||{top:0,bottom:0,left:0,right:0},image:(h?ct?.mute?.image:ct?.unmute?.image)||""},onPress:zt,type:h?"mute":"unmute",enabled:!!ct?.enabled&&!!Zt,style:{position:"relative",borderRadius:"10px"}}),Q(Dt,{config:{enabled:Vt?.enabled!==!1,image:"",color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:32},onPress:c,style:{position:"relative",borderRadius:"10px"}})]})]}),Q("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:Qt,onMouseUp:()=>ie("prev"),onTouchStart:Qt,onTouchEnd:()=>ie("prev")}),Q("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:Qt,onMouseUp:()=>ie("next"),onTouchStart:Qt,onTouchEnd:()=>ie("next")}),Rt("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",background:vt?Ne:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"0px"},children:[Zt?Q(Ar,{src:Zt,isActive:te,isAnimating:T,isMuted:h,onLoadedData:fe,activeVideoRef:q,objectFit:Le,objectPosition:Ee}):(ye||!vt&&d?.thumbnail)&&Q(de,{src:ye||d?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:Le,objectPosition:Ee}}),Q(Gn,{content:{...F.content,canva:Zo(F),editorSource:F.content?.editorSource||F.editorSource||F.styling?.editorSource||F.meta?.editorSource,styling:{...F.content?.styling,...F?.styling},interactions:F.interactions},elapsedTime:u/100*(d.styling?.slideShowTime||5),onInteraction:async qt=>{ut(qt,F)}})]}),(Be||lo)&&Q(Xn,{cta:F?.styling?.cta,buttonText:Be||"Learn More",onPress:qt=>{qt&&qt.stopPropagation&&qt.stopPropagation(),G(F)}})]})},F.id||j):null})}),V&&Q("div",{style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:Q("button",{onClick:ge,style:{background:"rgba(0,0,0,0.45)",border:"1px solid rgba(255,255,255,0.1)",color:"white",borderRadius:"50%",width:"44px",height:"44px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",backdropFilter:"blur(10px)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 8px 16px rgba(0,0,0,0.3)",outline:"none"},onMouseEnter:F=>{F.currentTarget.style.background="rgba(0,0,0,0.75)",F.currentTarget.style.transform="scale(1.1)",F.currentTarget.style.borderColor="rgba(255,255,255,0.25)"},onMouseLeave:F=>{F.currentTarget.style.background="rgba(0,0,0,0.45)",F.currentTarget.style.transform="scale(1)",F.currentTarget.style.borderColor="rgba(255,255,255,0.1)"},children:Q("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:Q("polyline",{points:"9 18 15 12 9 6"})})})})]})}),V&&e>0&&Rt("div",{style:{position:"absolute",bottom:"36px",left:"24px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"6px",zIndex:20},children:[Q("span",{style:{fontSize:"11px",fontWeight:"600",color:"rgba(255,255,255,0.65)",letterSpacing:"0.6px",textTransform:"uppercase",paddingLeft:"2px"},children:"Previous Stories"}),Rt("div",{style:{background:"rgba(255, 255, 255, 0.08)",border:"1px solid rgba(255, 255, 255, 0.12)",padding:"8px 16px",borderRadius:"16px",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(20px)",cursor:"pointer",boxShadow:"0 10px 24px rgba(0, 0, 0, 0.3)",transition:"all 0.25s cubic-bezier(0.4, 0, 0.2, 1)",maxWidth:"280px"},onClick:()=>ne("prev"),onMouseEnter:F=>{F.currentTarget.style.transform="translateY(-2px) scale(1.03)",F.currentTarget.style.background="rgba(255, 255, 255, 0.12)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.25)"},onMouseLeave:F=>{F.currentTarget.style.transform="translateY(0px) scale(1)",F.currentTarget.style.background="rgba(255, 255, 255, 0.08)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.12)"},children:[Q("span",{style:{color:"white",fontSize:"14px",display:"flex"},children:"\u2190"}),Q("div",{style:{width:"36px",height:"36px",borderRadius:"50%",border:"2px solid rgba(255,255,255,0.8)",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0,overflow:"hidden"},children:Q(de,{src:t[e-1].thumbnail,style:{width:"100%",height:"100%",borderRadius:"50%"}})}),Q("span",{style:{fontSize:"13px",color:"white",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e-1].name})]})]}),V&&e<t.length-1&&Rt("div",{style:{position:"absolute",bottom:"36px",right:"24px",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"6px",zIndex:20},children:[Q("span",{style:{fontSize:"11px",fontWeight:"600",color:"rgba(255,255,255,0.65)",letterSpacing:"0.6px",textTransform:"uppercase",paddingRight:"2px"},children:"Next Stories"}),Rt("div",{style:{background:"rgba(255, 255, 255, 0.08)",border:"1px solid rgba(255, 255, 255, 0.12)",padding:"8px 16px",borderRadius:"16px",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(20px)",cursor:"pointer",boxShadow:"0 10px 24px rgba(0, 0, 0, 0.3)",transition:"all 0.25s cubic-bezier(0.4, 0, 0.2, 1)",maxWidth:"280px"},onClick:()=>ne("next"),onMouseEnter:F=>{F.currentTarget.style.transform="translateY(-2px) scale(1.03)",F.currentTarget.style.background="rgba(255, 255, 255, 0.12)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.25)"},onMouseLeave:F=>{F.currentTarget.style.transform="translateY(0px) scale(1)",F.currentTarget.style.background="rgba(255, 255, 255, 0.08)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.12)"},children:[Q("div",{style:{width:"36px",height:"36px",borderRadius:"50%",border:"2px solid rgba(255,255,255,0.8)",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0,overflow:"hidden"},children:Q(de,{src:t[e+1].thumbnail,style:{width:"100%",height:"100%",borderRadius:"50%"}})}),Q("span",{style:{fontSize:"13px",color:"white",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e+1].name}),Q("span",{style:{color:"white",fontSize:"14px",display:"flex"},children:"\u2192"})]})]}),v&&Q("div",{style:{position:"absolute",bottom:"40px",left:"50%",transform:"translateX(-50%)",background:"rgba(20, 20, 20, 0.96)",border:"1px solid rgba(255,255,255,0.08)",padding:"12px 24px",borderRadius:"12px",color:"white",fontSize:"13px",fontWeight:"500",boxShadow:"0 10px 20px rgba(0,0,0,0.5)",backdropFilter:"blur(10px)",zIndex:1e3},children:v})]})};import{jsx as _r,jsxs as za}from"react/jsx-runtime";var Ta=()=>{let t=At("STR"),e=P(p=>p.isVisible),[o,n]=Dr(()=>{try{let p=sessionStorage.getItem("appstorys_active_story_index");if(p!==null){let y=parseInt(p,10);if(!isNaN(y)&&y>=0)return y}}catch{}return null}),[i,s]=Dr([]);ei(()=>{try{o!==null?sessionStorage.setItem("appstorys_active_story_index",String(o)):sessionStorage.removeItem("appstorys_active_story_index")}catch{}},[o]),ei(()=>{try{let p=localStorage.getItem("app_storys_viewed_stories");p&&s(JSON.parse(p))}catch(p){console.error("Failed to load viewed stories:",p)}},[]),ei(()=>{t&&t.details&&rt("story_module_viewed",t.id)},[t]);let l=Fa.useMemo(()=>!t||!t.details?[]:xn(t.details),[t?.details]);if(!t||!l||l.length===0||!e)return null;let c=p=>{n(p)},d=()=>{o!==null&&(o<l.length-1?n(o+1):n(null))},S=()=>{o!==null&&o>0&&n(o-1)};return za("div",{className:"story-group-container",style:{width:"100vw",position:"relative",left:"50%",right:"50%",marginLeft:"-50vw",marginRight:"-50vw",boxSizing:"border-box"},children:[_r(Zi,{stories:l,viewedStories:i,onStoryClick:c}),o!==null&&_r(Pr,{stories:l,activeStoryIndex:o,dataId:t.id,viewedStories:i,setViewedStories:s,onNextStory:d,onPrevStory:S,onClose:()=>n(null)})]})};import{useState as Ba,useRef as on,useEffect as oi,useCallback as La}from"react";import{createPortal as Ea}from"react-dom";yt();import{useEffect as Wr,useRef as tn}from"react";function wo(t,e=.5){let o=tn(t),n=tn(!1),i=tn(null),s=tn(null);Wr(()=>{o.current=t},[t]);let l=c=>{if(s.current&&(s.current.disconnect(),s.current=null),i.current=c,n.current=!1,!c)return;if(typeof IntersectionObserver>"u"){o.current();return}let d=null;s.current=new IntersectionObserver(S=>{S[0].isIntersecting&&!n.current?d||(d=setTimeout(()=>{n.current=!0,o.current(),s.current?.disconnect(),d=null},500)):d&&(clearTimeout(d),d=null)},{threshold:e}),s.current.observe(c)};return Wr(()=>()=>{s.current?.disconnect()},[]),l}var $r=new Set;function Ia(){try{return globalThis?.process?.env?.NODE_ENV!=="production"}catch{return!0}}function Nr(t,e,o){if(!Ia()||o<=1)return;let n=`${e}::${t}`;$r.has(n)||($r.add(n),console.warn(`AppStorys: Found ${o} elements matching target "${t}" (selector "${e}"). The first one in document order will be used. Target identifiers should be unique per screen.`))}function en(t){if(!t)return null;let e=[`[data-as-id="${t}"]`,`[data-id="${t}"]`,`[data-widget="${t}"]`];for(let n of e)try{let i=document.querySelectorAll(n);if(i.length>0)return Nr(t,n,i.length),i[0]}catch{}let o=document.getElementById(t);if(o)return o;try{let n=`.${CSS&&CSS.escape?CSS.escape(t):t}`,i=document.querySelectorAll(n);if(i.length>0)return Nr(t,n,i.length),i[0]}catch{}return null}import{jsx as Fe,jsxs as Ma}from"react/jsx-runtime";var Aa=({position:t})=>{let e=At("WID",{position:t}),o=P(A=>A.campaigns),n=P(A=>A.allCampaigns),i=P(A=>A.currentScreen),s=A=>(A||"").trim().toLowerCase(),l=e??(()=>{let A=s(i),T=[...o||[],...n||[]].find(k=>{let B=k;if(B.campaign_type!=="WID"||t&&B.position!==t)return!1;let W=!!(B.trigger_event??B.trigger),H=B.display_trigger!==!1&&!W,Y=!s(B.screen)||s(B.screen)===A;return H&&Y});if(T)try{return Nt(T)}catch{return T}})(),[c,d]=Ba(0),S=on(null),p=on(null),y=l?.details||{},u=y.widget_images||[],C=y.styling||{},h=y.type||"full",g=h==="half",b=on([]),m=on(!1),E=La(()=>{m.current=!0;let A=u[c];A?.id&&D(A.id)},[u,c]),O=wo(E),D=A=>{!l?.id||!A||m.current&&(b.current.includes(A)||(b.current.push(A),rt("viewed",l.id,{widget_image:A})))};oi(()=>{if(h==="full"&&u.length>1)return p.current=setInterval(()=>{d(A=>{let T=A+1;return T>=u.length?0:T})},5e3),()=>{p.current&&clearInterval(p.current)}},[h,u.length]);let L=(A,T)=>{let k=(T||"").trim();if(k){if(l?.id&&rt("clicked",l.id,{widget_image:A}),!k.startsWith("http")){try{if(Pt(k))return}catch(B){console.warn("[Widget] revealCampaignFromLink error",B)}console.log("[Widget] Internal link:",k);return}window.open(k,"_blank")}},v=()=>{if(S.current&&g){let{scrollLeft:A,offsetWidth:T}=S.current,k=T/2+12,B=Math.round(A/k);d(B)}};oi(()=>{if(!l?.id||h!=="full"||u.length===0)return;let A=u[c];A&&A.id&&D(A.id)},[c,l?.id,u,h]),oi(()=>{if(!l?.id||!S.current||!g)return;let A=S.current,T=()=>{let{scrollLeft:k,offsetWidth:B}=A,W=B/2+12;u.forEach((H,Y)=>{let r=Y*W,M=r+W,a=k,f=k+B;Math.max(0,Math.min(M,f)-Math.max(r,a))/W>=.5&&D(H.id)})};return T(),A.addEventListener("scroll",T),()=>A.removeEventListener("scroll",T)},[l?.id,g,u]);let w={display:"flex",flexDirection:"row",flexWrap:g?"nowrap":"wrap",gap:"12px",width:"100%",height:g&&y.height?`${y.height}px`:"auto",marginTop:C.topMargin?`${C.topMargin}px`:"0px",marginBottom:C.bottomMargin?`${C.bottomMargin}px`:"0px",marginLeft:C.leftMargin?`${C.leftMargin}px`:"0px",marginRight:C.rightMargin?`${C.rightMargin}px`:"0px",boxSizing:"border-box",overflowX:g?"auto":"hidden",overflowY:"hidden",scrollSnapType:g?"x mandatory":void 0,msOverflowStyle:"none",scrollbarWidth:"none"},_=A=>({flex:g?"0 0 calc(50% - 6px)":"0 0 100%",height:g&&y.height?`${y.height}px`:"auto",cursor:"pointer",position:"relative",overflow:"hidden",borderRadius:C.borderRadius?`${C.borderRadius}px`:"0px",borderTopLeftRadius:C.topLeftRadius?`${C.topLeftRadius}px`:void 0,borderTopRightRadius:C.topRightRadius?`${C.topRightRadius}px`:void 0,borderBottomLeftRadius:C.bottomLeftRadius?`${C.bottomLeftRadius}px`:void 0,borderBottomRightRadius:C.bottomRightRadius?`${C.bottomRightRadius}px`:void 0,boxShadow:"0 4px 12px rgba(0,0,0,0.08)",scrollSnapAlign:"start"}),$=Ma("div",{style:{width:"100%",position:"relative"},children:[Fe("style",{children:`
124
+ `}),At("div",{style:{position:"absolute",top:"46px",right:0,width:"260px",background:"rgba(25, 25, 25, 0.98)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:"16px",padding:"18px",boxShadow:"0 20px 25px -5px rgba(0,0,0,0.4), 0 10px 10px -5px rgba(0,0,0,0.4)",zIndex:1001,animation:"fadeUp 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards"},children:[tt("div",{style:{fontSize:"11px",fontWeight:"bold",color:"#9CA3AF",letterSpacing:"1px",textTransform:"uppercase",marginBottom:"16px",paddingBottom:"10px",borderBottom:"1px solid rgba(255,255,255,0.06)"},children:"Keyboard Shortcuts"}),tt("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[{key:"\u2192",label:"Next slide"},{key:"\u2190",label:"Previous slide"},{key:"space",label:"Play/Pause"},{key:"esc",label:"Close story"},{key:"S",label:"Share story link"}].map(({key:w,label:q})=>At("div",{style:{display:"flex",alignItems:"center",gap:"14px",justifyContent:"flex-start"},children:[tt("span",{style:{minWidth:"54px",display:"inline-flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.08)",padding:"5px 8px",borderRadius:"5px",fontSize:"12px",color:"white",border:"1px solid rgba(255,255,255,0.1)",boxSizing:"border-box"},children:w}),tt("span",{style:{fontSize:"13px",color:"#E5E7EB",fontWeight:"500",textAlign:"left"},children:q})]},w))})]})]})]}),tt(Ut,{config:{enabled:te?.enabled??!0,image:"",color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:44},onPress:c,style:{position:"relative",borderRadius:"12px"}})]})]})]}),tt("div",{style:{flex:1,width:"100%",display:"flex",flexDirection:"column",justifyContent:N?"flex-start":"center",alignItems:"center",paddingTop:N?"14px":"0px",...vo()},children:At("div",{style:{display:N?"grid":"flex",gridTemplateColumns:N?`minmax(0, 1fr) ${$t}px minmax(0, 1fr)`:"none",alignItems:"center",justifyContent:"center",gap:"12px",width:"100%",maxWidth:"1400px",position:"relative"},onClick:w=>N&&w.stopPropagation(),children:[N&&tt("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(u>0||e>0)&&tt("button",{onClick:ce,style:{background:"rgba(0,0,0,0.45)",border:"1px solid rgba(255,255,255,0.1)",color:"white",borderRadius:"50%",width:"44px",height:"44px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",backdropFilter:"blur(10px)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 8px 16px rgba(0,0,0,0.3)",outline:"none"},onMouseEnter:w=>{w.currentTarget.style.background="rgba(0,0,0,0.75)",w.currentTarget.style.transform="scale(1.1)",w.currentTarget.style.borderColor="rgba(255,255,255,0.25)"},onMouseLeave:w=>{w.currentTarget.style.background="rgba(0,0,0,0.45)",w.currentTarget.style.transform="scale(1)",w.currentTarget.style.borderColor="rgba(255,255,255,0.1)"},children:tt("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:tt("polyline",{points:"15 18 9 12 15 6"})})})}),N?tt("div",{style:{width:`${$t}px`,height:`${Ft}px`,position:"relative",zIndex:5,overflow:"visible"},children:Array.from(Wt).sort((w,q)=>w-q).map(w=>{let q=l.slides[w];if(!q)return null;let ht=ee(w),jt=qa(ht,$t),It=q?.styling,we=It?.editorSource||It?.meta?.editorSource,ge=we==="studio"||we==="editor",Je=It?.background?.media?.mediaUrl||q?.image,Ne=$(q),wo=Ct(It?.background)||"#000000",Xt=ge?q?.content?.button_text:q?.button_text,Oe=ge?q?.content?.link:q?.link,oe=It?.background?.media?.sizing||It?.background?.sizing||It?.media?.sizing||q?.sizing,je=oe==="fill"||oe==="cover"?"cover":oe==="fit"||oe==="contain"?"contain":oe==="stretch"?"fill":"contain",se=It?.background?.media?.position||It?.background?.position||It?.media?.position||q?.content?.background?.media?.position||q?.content?.media?.position||q?.position,Qt=oo(se),Xe=w===u&&!z||z&&w===v,In={display:"flex",justifyContent:"center",alignItems:"center",background:ge?wo:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"16px"};return At("div",{style:{...Ht,position:"absolute",top:0,left:0,width:`${$t}px`,height:`${Ft}px`,...jt,transition:ht==="hidden"||ht==="far-left"||ht==="far-right"?`opacity ${Fe}ms ease, transform ${Fe}ms ease`:w===B?`transform ${Fe}ms ${ui}, opacity ${Fe}ms ${ui}, filter ${Fe}ms ${ui}`:`transform ${Fe}ms ${pi}, opacity ${Fe}ms ${pi}, filter ${Fe}ms ${pi}`,transformOrigin:"center center",willChange:"transform, opacity, filter"},onClick:fe=>fe.stopPropagation(),children:[tt("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:ue,onMouseUp:()=>Gt("prev"),onTouchStart:ue,onTouchEnd:()=>Gt("prev")}),tt("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:ue,onMouseUp:()=>Gt("next"),onTouchStart:ue,onTouchEnd:()=>Gt("next")}),At("div",{style:In,children:[Ne?tt(Yr,{src:Ne,isActive:Xe,isAnimating:z,isMuted:g,onLoadedData:ve,activeVideoRef:G,objectFit:je,objectPosition:Qt}):Je||!ge&&l?.thumbnail?tt(ye,{src:Je||l?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:je,objectPosition:Qt}}):null,tt(ai,{content:{...q.content,lottie:q.content?.lottie||q?.lottie||q.styling?.lottie,video:q.content?.video||q?.videoOverlay||q.styling?.video,image:q.content?.image||q?.imageOverlay||q.styling?.image,canva:gn(q),editorSource:q.content?.editorSource||q.editorSource||q.styling?.editorSource||q.meta?.editorSource,styling:{...q.content?.styling,...q?.styling},interactions:q.interactions},elapsedTime:Xe?f/100*(l.styling?.slideShowTime||5):0,onInteraction:async fe=>{Xe&&bt(fe,q)},isActive:Xe,isMuted:g})]}),(Xt||Oe)&&tt(di,{cta:q?.styling?.cta,buttonText:Xt||"Learn More",onPress:fe=>{fe&&fe.stopPropagation&&fe.stopPropagation(),J(q)}})]},q.id||w)})}):tt("div",{style:{width:"100vw",height:"100dvh",maxWidth:"100vw",maxHeight:"100dvh",overflow:"hidden",position:"relative",zIndex:5,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",backgroundColor:"#000000"},children:l.slides.map((w,q)=>{if(Math.abs(q-u)>1)return tt("div",{style:{display:"none"}},w.id||q);let ht=w?.styling,jt=ht?.editorSource||ht?.meta?.editorSource,It=jt==="studio"||jt==="editor",we=ht?.background?.media?.mediaUrl||w?.image,ge=w?.video||(It?w?.content?.video?.[0]?.link:void 0),Je=Ct(ht?.background)||"#000000",Ne=It?w?.content?.button_text:w?.button_text,wo=It?w?.content?.link:w?.link,Xt=ht?.background?.media?.sizing||ht?.background?.sizing||ht?.media?.sizing||w?.sizing,Oe=Xt==="fill"||Xt==="cover"?"cover":Xt==="fit"||Xt==="contain"?"contain":Xt==="stretch"?"fill":"contain",oe=ht?.background?.media?.position||ht?.background?.position||ht?.media?.position||w?.content?.background?.media?.position||w?.content?.media?.position||w?.position,je=oo(oe),se=q===u;return se?tt("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:At("div",{style:{...Ht},onClick:Qt=>Qt.stopPropagation(),children:[tt("div",{style:{position:"absolute",top:"calc(10px + env(safe-area-inset-top, 0px))",left:"10px",right:"10px",display:"flex",gap:"4px",padding:"0 4px",zIndex:10},children:l.slides.map((Qt,qe)=>{let Fn=qe<u?"100%":qe===u?`${f}%`:"0%";return tt("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.3)",borderRadius:"2px",overflow:"hidden"},children:tt("div",{style:{width:Fn,height:"100%",backgroundColor:"white",transition:qe===u&&f>0&&!z?"width 0.1s linear":"none"}})},qe)})}),At("div",{style:{position:"absolute",top:"calc(22px + env(safe-area-inset-top, 0px))",left:"10px",right:"10px",display:"flex",alignItems:"center",justifyContent:"space-between",zIndex:10,padding:"5px"},children:[At("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[tt(ye,{src:l.thumbnail,alt:l.name,style:{width:"32px",height:"32px",borderRadius:"50%"}}),tt("span",{style:{color:"white",fontWeight:"bold",fontSize:"14px",textShadow:"0 1px 3px rgba(0,0,0,0.8)"},children:l.name})]}),At("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[tt(ci,{config:{enabled:l?.styling?.share?.enabled??!0,image:l?.styling?.share?.image??"",color:{cross:l?.styling?.share?.color?.cross??"#ffffff",fill:l?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:l?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:l?.styling?.share?.size??32},onPress:Ie,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"10px",width:"32px",height:"32px"}}),tt(Re,{config:{size:(g?xt?.mute?.size:xt?.unmute?.size)||32,color:{cross:(g?xt?.mute?.color?.cross:xt?.unmute?.color?.cross)||"#ffffff",fill:(g?xt?.mute?.color?.fill:xt?.unmute?.color?.fill)||"rgba(255,255,255,0.08)",stroke:(g?xt?.mute?.color?.stroke:xt?.unmute?.color?.stroke)||"transparent"},margin:(g?xt?.mute?.margin:xt?.unmute?.margin)||{top:0,bottom:0,left:0,right:0},image:(g?xt?.mute?.image:xt?.unmute?.image)||""},onPress:Rt,type:g?"mute":"unmute",enabled:!!xt?.enabled&&!!ge,style:{position:"relative",borderRadius:"10px"}}),tt(Ut,{config:{enabled:te?.enabled!==!1,image:"",color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:32},onPress:c,style:{position:"relative",borderRadius:"10px"}})]})]}),tt("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:ue,onMouseUp:()=>Gt("prev"),onTouchStart:ue,onTouchEnd:()=>Gt("prev")}),tt("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:ue,onMouseUp:()=>Gt("next"),onTouchStart:ue,onTouchEnd:()=>Gt("next")}),At("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",background:It?Je:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"0px"},children:[ge?tt(Yr,{src:ge,isActive:se,isAnimating:z,isMuted:g,onLoadedData:ve,activeVideoRef:G,objectFit:Oe,objectPosition:je}):(we||!It&&l?.thumbnail)&&tt(ye,{src:we||l?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:Oe,objectPosition:je}}),tt(ai,{content:{...w.content,canva:gn(w),editorSource:w.content?.editorSource||w.editorSource||w.styling?.editorSource||w.meta?.editorSource,styling:{...w.content?.styling,...w?.styling},interactions:w.interactions},elapsedTime:f/100*(l.styling?.slideShowTime||5),onInteraction:async Qt=>{bt(Qt,w)},isActive:se,isMuted:g})]}),(Ne||wo)&&tt(di,{cta:w?.styling?.cta,buttonText:Ne||"Learn More",onPress:Qt=>{Qt&&Qt.stopPropagation&&Qt.stopPropagation(),J(w)}})]})},w.id||q):null})}),N&&tt("div",{style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:tt("button",{onClick:re,style:{background:"rgba(0,0,0,0.45)",border:"1px solid rgba(255,255,255,0.1)",color:"white",borderRadius:"50%",width:"44px",height:"44px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",backdropFilter:"blur(10px)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 8px 16px rgba(0,0,0,0.3)",outline:"none"},onMouseEnter:w=>{w.currentTarget.style.background="rgba(0,0,0,0.75)",w.currentTarget.style.transform="scale(1.1)",w.currentTarget.style.borderColor="rgba(255,255,255,0.25)"},onMouseLeave:w=>{w.currentTarget.style.background="rgba(0,0,0,0.45)",w.currentTarget.style.transform="scale(1)",w.currentTarget.style.borderColor="rgba(255,255,255,0.1)"},children:tt("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:tt("polyline",{points:"9 18 15 12 9 6"})})})})]})}),N&&e>0&&At("div",{style:{position:"absolute",bottom:"36px",left:"24px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"6px",zIndex:20},children:[tt("span",{style:{fontSize:"11px",fontWeight:"600",color:"rgba(255,255,255,0.65)",letterSpacing:"0.6px",textTransform:"uppercase",paddingLeft:"2px"},children:"Previous Stories"}),At("div",{style:{background:"rgba(255, 255, 255, 0.08)",border:"1px solid rgba(255, 255, 255, 0.12)",padding:"8px 16px",borderRadius:"16px",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(20px)",cursor:"pointer",boxShadow:"0 10px 24px rgba(0, 0, 0, 0.3)",transition:"all 0.25s cubic-bezier(0.4, 0, 0.2, 1)",maxWidth:"280px"},onClick:()=>Jt("prev"),onMouseEnter:w=>{w.currentTarget.style.transform="translateY(-2px) scale(1.03)",w.currentTarget.style.background="rgba(255, 255, 255, 0.12)",w.currentTarget.style.borderColor="rgba(255, 255, 255, 0.25)"},onMouseLeave:w=>{w.currentTarget.style.transform="translateY(0px) scale(1)",w.currentTarget.style.background="rgba(255, 255, 255, 0.08)",w.currentTarget.style.borderColor="rgba(255, 255, 255, 0.12)"},children:[tt("span",{style:{color:"white",fontSize:"14px",display:"flex"},children:"\u2190"}),tt("div",{style:{width:"36px",height:"36px",borderRadius:"50%",border:"2px solid rgba(255,255,255,0.8)",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0,overflow:"hidden"},children:tt(ye,{src:t[e-1].thumbnail,style:{width:"100%",height:"100%",borderRadius:"50%"}})}),tt("span",{style:{fontSize:"13px",color:"white",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e-1].name})]})]}),N&&e<t.length-1&&At("div",{style:{position:"absolute",bottom:"36px",right:"24px",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"6px",zIndex:20},children:[tt("span",{style:{fontSize:"11px",fontWeight:"600",color:"rgba(255,255,255,0.65)",letterSpacing:"0.6px",textTransform:"uppercase",paddingRight:"2px"},children:"Next Stories"}),At("div",{style:{background:"rgba(255, 255, 255, 0.08)",border:"1px solid rgba(255, 255, 255, 0.12)",padding:"8px 16px",borderRadius:"16px",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(20px)",cursor:"pointer",boxShadow:"0 10px 24px rgba(0, 0, 0, 0.3)",transition:"all 0.25s cubic-bezier(0.4, 0, 0.2, 1)",maxWidth:"280px"},onClick:()=>Jt("next"),onMouseEnter:w=>{w.currentTarget.style.transform="translateY(-2px) scale(1.03)",w.currentTarget.style.background="rgba(255, 255, 255, 0.12)",w.currentTarget.style.borderColor="rgba(255, 255, 255, 0.25)"},onMouseLeave:w=>{w.currentTarget.style.transform="translateY(0px) scale(1)",w.currentTarget.style.background="rgba(255, 255, 255, 0.08)",w.currentTarget.style.borderColor="rgba(255, 255, 255, 0.12)"},children:[tt("div",{style:{width:"36px",height:"36px",borderRadius:"50%",border:"2px solid rgba(255,255,255,0.8)",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0,overflow:"hidden"},children:tt(ye,{src:t[e+1].thumbnail,style:{width:"100%",height:"100%",borderRadius:"50%"}})}),tt("span",{style:{fontSize:"13px",color:"white",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e+1].name}),tt("span",{style:{color:"white",fontSize:"14px",display:"flex"},children:"\u2192"})]})]}),I&&tt("div",{style:{position:"absolute",bottom:"40px",left:"50%",transform:"translateX(-50%)",background:"rgba(20, 20, 20, 0.96)",border:"1px solid rgba(255,255,255,0.08)",padding:"12px 24px",borderRadius:"12px",color:"white",fontSize:"13px",fontWeight:"500",boxShadow:"0 10px 20px rgba(0,0,0,0.5)",backdropFilter:"blur(10px)",zIndex:1e3},children:I})]})};import{jsx as Xr,jsxs as Ja}from"react/jsx-runtime";var Qa=()=>{let t=Mt("STR"),e=W(u=>u.isVisible),[o,n]=Jr(()=>{try{let u=sessionStorage.getItem("appstorys_active_story_index");if(u!==null){let m=parseInt(u,10);if(!isNaN(m)&&m>=0)return m}}catch{}return null}),[i,s]=Jr([]);fi(()=>{try{o!==null?sessionStorage.setItem("appstorys_active_story_index",String(o)):sessionStorage.removeItem("appstorys_active_story_index")}catch{}},[o]),fi(()=>{try{let u=localStorage.getItem("app_storys_viewed_stories");u&&s(JSON.parse(u))}catch(u){console.error("Failed to load viewed stories:",u)}},[]),fi(()=>{t&&t.details&&st("story_module_viewed",t.id)},[t]);let d=Ga.useMemo(()=>!t||!t.details?[]:Ln(t.details),[t?.details]);if(!t||!d||d.length===0||!e)return null;let c=u=>{n(u)},l=()=>{o!==null&&(o<d.length-1?n(o+1):n(null))},y=()=>{o!==null&&o>0&&n(o-1)};return Ja("div",{className:"story-group-container",style:{width:"100vw",position:"relative",left:"50%",right:"50%",marginLeft:"-50vw",marginRight:"-50vw",boxSizing:"border-box"},children:[Xr(pr,{stories:d,viewedStories:i,onStoryClick:c}),o!==null&&Xr(Qr,{stories:d,activeStoryIndex:o,dataId:t.id,viewedStories:i,setViewedStories:s,onNextStory:l,onPrevStory:y,onClose:()=>n(null)})]})};import{useState as es,useRef as mn,useEffect as Wo,useCallback as Xa}from"react";import*as so from"lottie-react";import{useEffect as Kr,useRef as fn}from"react";function _o(t,e=.5){let o=fn(t),n=fn(!1),i=fn(null),s=fn(null);Kr(()=>{o.current=t},[t]);let d=c=>{if(s.current&&(s.current.disconnect(),s.current=null),i.current=c,n.current=!1,!c)return;if(typeof IntersectionObserver>"u"){o.current();return}let l=null;s.current=new IntersectionObserver(y=>{y[0].isIntersecting&&!n.current?l||(l=setTimeout(()=>{n.current=!0,o.current(),s.current?.disconnect(),l=null},500)):l&&(clearTimeout(l),l=null)},{threshold:e}),s.current.observe(c)};return Kr(()=>()=>{s.current?.disconnect()},[]),d}import{Fragment as Za,jsx as xe,jsxs as ts}from"react/jsx-runtime";var Zr=so.default?.default??so.default??so.Lottie??so,Ka=({item:t,onClick:e})=>{let[o,n]=es(null);Wo(()=>{t.lottie_data&&(typeof t.lottie_data=="object"?n(t.lottie_data):typeof t.lottie_data=="string"&&fetch(t.lottie_data).then(d=>d.json()).then(d=>n(d)).catch(d=>console.error("[Widget] Failed to load Lottie JSON:",d)))},[t.lottie_data]);let i=!!(t.link||"").trim(),s=Zr.default||Zr;return t.lottie_data&&o?xe("div",{onClick:e,style:{width:"100%",height:"100%",cursor:i?"pointer":"default"},children:xe(s,{animationData:o,loop:!0,autoplay:!0,style:{width:"100%",height:"100%",objectFit:"contain"}})}):!t.image&&!t.lottie_data?xe("div",{onClick:e,style:{width:"100%",height:"100%",backgroundColor:"#f3f4f6",display:"flex",alignItems:"center",justifyContent:"center",color:"#9ca3af",fontSize:"14px",fontWeight:500},children:"No Image Provided"}):xe("img",{src:t.image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block",cursor:i?"pointer":"default"},onClick:e})},yn=({position:t,leftPadding:e=0,rightPadding:o=0})=>{let n=Mt("WID",{position:t});Wo(()=>{t&&console.info(`[AppStorys Widget] Position "${t}":`,n?`Matched campaign "${n.id}"`:"No matching campaign found in store",n)},[t,n]);let[i,s]=es(0),d=mn(null),c=mn(null),l=n?.details||{},y=l.widget_images||[],u=l.styling||{},m=l.type||"full",f=m==="half",P=mn([]),g=mn(!1),b=Xa(()=>{g.current=!0;let v=y[i];v?.id&&C(v.id)},[y,i]),R=_o(b),C=v=>{!n?.id||!v||g.current&&(P.current.includes(v)||(P.current.push(v),st("viewed",n.id,{widget_image:v})))};Wo(()=>{if(m==="full"&&y.length>1)return c.current=setInterval(()=>{if(!d.current)return;let v=d.current.clientWidth;v<=0||s(A=>{let H=(A+1)%y.length;return d.current?.scrollTo({left:H*v,behavior:"smooth"}),H})},5e3),()=>{c.current&&clearInterval(c.current)}},[m,y.length]);let h=(v,A)=>{let H=(A||"").trim();if(H&&(n?.id&&st("clicked",n.id,{widget_image:v}),!wt(H))){if(!H.startsWith("http")){try{if(qt(H))return}catch(it){console.warn("[Widget] revealCampaignFromLink error",it)}console.log("[Widget] Internal link:",H);return}window.open(H,"_blank")}},T=()=>{if(!d.current)return;let{scrollLeft:v,clientWidth:A}=d.current;if(!(A<=0))if(f){let H=A/2+12,it=Math.round(v/H);it!==i&&it>=0&&it<y.length&&s(it)}else{let H=Math.round(v/A);H!==i&&H>=0&&H<y.length&&s(H)}},E=v=>{if(s(v),d.current){let A=d.current.clientWidth;d.current.scrollTo({left:v*A,behavior:"smooth"})}};Wo(()=>{if(!n?.id||m!=="full"||y.length===0)return;let v=y[i];v&&v.id&&C(v.id)},[i,n?.id,y,m]),Wo(()=>{if(!n?.id||!d.current||!f)return;let v=d.current,A=()=>{let{scrollLeft:H,offsetWidth:it}=v,at=it/2+12;y.forEach((a,F)=>{let r=F*at,p=r+at,j=H,k=H+it;Math.max(0,Math.min(p,k)-Math.max(r,j))/at>=.5&&C(a.id)})};return A(),v.addEventListener("scroll",A),()=>v.removeEventListener("scroll",A)},[n?.id,f,y]);let X=!!(l.width&&l.height&&Number(l.width)>0&&Number(l.height)>0),I=X?`${l.width} / ${l.height}`:void 0,S=Number(u.borderRadius)||0,M=typeof u.topLeftRadius<"u"?Number(u.topLeftRadius):S,x=typeof u.topRightRadius<"u"?Number(u.topRightRadius):S,N=typeof u.bottomLeftRadius<"u"?Number(u.bottomLeftRadius):S,U=typeof u.bottomRightRadius<"u"?Number(u.bottomRightRadius):S,z={display:"flex",flexDirection:"row",flexWrap:"nowrap",gap:f?"12px":"0px",width:"100%",height:"auto",marginTop:u.topMargin?`${u.topMargin}px`:"0px",marginBottom:u.bottomMargin?`${u.bottomMargin}px`:"0px",marginLeft:u.leftMargin?`${u.leftMargin}px`:"0px",marginRight:u.rightMargin?`${u.rightMargin}px`:"0px",paddingLeft:e?`${e}px`:"0px",paddingRight:o?`${o}px`:"0px",boxSizing:"border-box",overflowX:"auto",overflowY:"hidden",scrollSnapType:"x mandatory",scrollBehavior:"smooth",msOverflowStyle:"none",scrollbarWidth:"none"},O=v=>({flex:f?"0 0 calc(50% - 6px)":"0 0 100%",width:f?"calc(50% - 6px)":"100%",minWidth:f?"calc(50% - 6px)":"100%",maxWidth:f?"calc(50% - 6px)":"100%",boxSizing:"border-box",aspectRatio:I,height:!X&&l.height?`${l.height}px`:"auto",cursor:"pointer",position:"relative",overflow:"hidden",borderTopLeftRadius:`${M}px`,borderTopRightRadius:`${x}px`,borderBottomLeftRadius:`${N}px`,borderBottomRightRadius:`${U}px`,WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)",boxShadow:"0 4px 12px rgba(0,0,0,0.08)",scrollSnapAlign:"start"}),B=!!(n&&y&&y.length>0);return!B&&!t?null:ts("div",{"data-widget":t,style:{width:"100%",position:"relative"},children:[xe("style",{children:`
125
125
  .widget-scroll-container::-webkit-scrollbar {
126
126
  display: none;
127
127
  }
128
- `}),Fe("div",{ref:A=>{S.current=A,O(A)},className:"widget-scroll-container",style:w,onScroll:v,children:g?u.map((A,T)=>Fe("div",{style:_(T),children:Fe("img",{src:A.image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block",cursor:(A.link||"").trim()?"pointer":"default"},onClick:()=>L(A.id,A.link)})},A.id)):u.length>0&&Fe("div",{style:_(0),children:Fe("img",{src:u[c].image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block",cursor:(u[c].link||"").trim()?"pointer":"default"},onClick:()=>L(u[c].id,u[c].link)})},`slide-${c}`)}),h==="full"&&u.length>1&&Fe("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"8px",width:"100%"},children:u.map((A,T)=>Fe("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:T===c?"#333":"#ccc",transition:"background-color 0.2s ease"}},T))})]}),V=null;if(l?.position){let A=String(l.position||"").replace(/^widget_/,"");V=en(A),V?console.log("[Widget] Portal target found for campaign",l?.id):console.log("[Widget] No portal target found for position:",l?.position,"rendering inline for campaign:",l?.id)}return V?Ea($,V):$};import{useEffect as ko,useLayoutEffect as Pa,useMemo as ni,useRef as nn,useState as Qe,useCallback as Or}from"react";yt();import{jsx as Yt,jsxs as Ro}from"react/jsx-runtime";var ii=t=>(t||"").trim().toLowerCase(),Da=t=>{if(t==null)return"8px 8px 8px 8px";if(typeof t=="number")return`${t}px`;if(typeof t=="object"){let e=t.top??8,o=t.right??8,n=t.bottom??8,i=t.left??8;return`${e}px ${o}px ${n}px ${i}px`}return String(t)},_a=(t,e)=>{if(typeof t=="number")return`${t}px`;if(typeof e=="number")return`${e}px`;if(typeof t=="object"&&t!==null){let o=t.topLeft??12,n=t.topRight??12,i=t.bottomRight??12,s=t.bottomLeft??12;return`${o}px ${n}px ${i}px ${s}px`}return"12px"},Wa=()=>{let t=At("TTP"),e=P(G=>G.campaigns),o=P(G=>G.allCampaigns),n=P(G=>G.currentScreen),i=P(G=>G.isVisible),[s,l]=Qe(0),[c,d]=Qe(!1),[S,p]=Qe(null),[y,u]=Qe(null),[C,h]=Qe({width:0,height:0}),[g,b]=Qe(!1),m=nn(null),E=nn(null),O=nn(null),D=Or(G=>{if(G)try{document.body.style.overflow="",document.documentElement.style.overflow="",G.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}catch{try{G.scrollIntoView()}catch{}}},[]),L=ni(()=>{if(t)return t;let G=ii(n),ut=zt=>zt.find(Vt=>{let ct=Vt,re=ct.campaign_type==="TTP"||ct.campaign_type==="TLTP",$e=!ii(ct.screen)||ii(ct.screen)===G,Ie=!!(ct.trigger_event??ct.trigger),_t=ct.display_trigger!==!1&&!Ie;return re&&$e&&_t});return ut(e)??ut(o)},[t,e,o,n]);ko(()=>{b(!1)},[s,L?.id]);let v=ni(()=>L?.details?.tooltips&&Array.isArray(L.details.tooltips)?[...L.details.tooltips].sort((G,ut)=>(G.order??0)-(ut.order??0)):L?.details?.target||L?.details?.titleText?[{...L.details,_id:L.id}]:[],[L]),w=v[s];ko(()=>{},[L]);let _=nn(new Set),$=Or(()=>{if(!(!L||!w||c||!i))try{let G=w._id||w.id||void 0,ut=String(L.id||"")+"::"+String(G||"");_.current.has(ut)||(_.current.add(ut),rt("viewed",L.id,{tooltip_id:G}))}catch{}},[L,w,c,i]),V=wo($);ko(()=>{if(!w||c)return;p(null),u(null);let G=null,ut=null,zt=()=>{let $t=typeof window<"u"?document.documentElement.clientWidth||window.innerWidth:1024,jt=typeof window<"u"?document.documentElement.clientHeight||window.innerHeight:768;return new DOMRect($t/2-100,jt/2-50,200,100)},Vt=$t=>{if(!$t||!($t instanceof HTMLElement))return!1;let jt=$t.getBoundingClientRect();if(jt.width===0||jt.height===0)return!1;try{let Lt=window.getComputedStyle($t);if(Lt.display==="none"||Lt.visibility==="hidden"||Lt.opacity==="0")return!1}catch{}return!0},ct=($t=!1)=>{let jt=w.target||w.targetId||w.elementId;if(!jt)return p(zt()),u(null),null;let Lt=en(jt);if(Lt){if(u(Lt),Vt(Lt)){let F=Lt.getBoundingClientRect();$t?(D(Lt),p(F),setTimeout(()=>{D(Lt),p(Lt.getBoundingClientRect())},50),setTimeout(()=>{p(Lt.getBoundingClientRect())},150),setTimeout(()=>{p(Lt.getBoundingClientRect())},350)):p(F)}else p(null);return Lt}return u(null),p(null),null},re=()=>{b(!0)},$e=$t=>{O.current?.disconnect(),O.current=null,!(!$t||typeof ResizeObserver>"u")&&(O.current=new ResizeObserver(()=>{Vt($t)?p($t.getBoundingClientRect()):p(null)}),O.current.observe($t))},Ie=($t=!1)=>{let jt=ct($t);jt&&jt!==G&&(G&&G.removeEventListener("click",re),G=jt,jt.addEventListener("click",re),$e(jt))};Ie(!0),E.current=new MutationObserver(()=>{Ie(!1)}),E.current.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let _t=()=>Ie(!1);return window.addEventListener("resize",_t),window.addEventListener("scroll",_t,{passive:!0,capture:!0}),document.addEventListener("mouseenter",_t,!0),document.addEventListener("mouseover",_t,!0),document.addEventListener("mouseleave",_t,!0),document.addEventListener("click",_t,!0),()=>{ut&&clearTimeout(ut),G&&G.removeEventListener("click",re),E.current?.disconnect(),O.current?.disconnect(),window.removeEventListener("resize",_t),window.removeEventListener("scroll",_t,{capture:!0}),document.removeEventListener("mouseenter",_t,!0),document.removeEventListener("mouseover",_t,!0),document.removeEventListener("mouseleave",_t,!0),document.removeEventListener("click",_t,!0)}},[w,c,s,D]),ko(()=>{if(!w||c||!S)return;let G=w?.enableBackdrop??w?.enable_backdrop??L?.details?.enableBackdrop??L?.details?.enable_backdrop;if(!(G!==!1&&G!=="false"&&G!==0))return;let zt=Vt=>{let ct=Vt.target;ct&&(m.current&&m.current.contains(ct)||y&&(y===ct||y.contains(ct))||(b(!0),s<v.length-1?l(re=>re+1):d(!0)))};return window.addEventListener("click",zt,!0),()=>{window.removeEventListener("click",zt,!0)}},[w,c,S,y,s,v.length,L]),ko(()=>{if(!y||!(y instanceof HTMLElement)||c)return;let G=y,ut=()=>{b(!0)};return G.addEventListener("click",ut),()=>{G.removeEventListener("click",ut)}},[y,s,c]),Pa(()=>{if(m.current&&S){let{width:G,height:ut}=m.current.getBoundingClientRect();h({width:G,height:ut})}},[w,S]);let A=ni(()=>{let G=w?.styling?.appearance?.highlight?.radius;if(G!=null)return`${G}px`;if(y&&typeof window<"u")try{let ut=window.getComputedStyle(y);if(ut.borderRadius&&ut.borderRadius!=="0px")return ut.borderRadius}catch{}return"6px"},[w?.styling?.appearance?.highlight?.radius,y]);if(!L||!w||c||!i||!S)return null;let T=w.styling||{},k=T.appearance||{},B=k.colors||{},W=T.cta||{},H=W.container||{},Y=W.cornerRadius||{},r=W.text||{},M=!!(k.imageDimensions?.width&&k.imageDimensions?.height),a,f;if(M){let G=k.imageDimensions.width,ut=k.imageDimensions.height,zt=typeof window<"u"?window.innerWidth*.9:G;a=Math.min(G,zt),f=a===G?ut:Math.round(ut*(a/G))}let x=w.arrowPosition;!x&&w.position&&(w.position==="left"?x="right":w.position==="right"?x="left":w.position==="top"?x="bottom":w.position==="bottom"&&(x="top")),x||(x="left");let U=(k.arrowStyle||{width:6,height:12}).width||6,et=S.top,X=S.left,q=8,J=8,nt=typeof window<"u"?document.documentElement.clientWidth||window.innerWidth:1024,ht=typeof window<"u"?document.documentElement.clientHeight||window.innerHeight:768,dt=C.width||M&&a||250,K=C.height||(M?f||150:100),it=S.top,lt=ht-(S.top+S.height),mt=S.left,gt=nt-(S.left+S.width),R=dt+q+J,I=K+q+J;x?x==="left"&&gt<R?mt>=R?x="right":it>=I||it>=lt?x="bottom":x="top":x==="right"&&mt<R?gt>=R?x="left":it>=I||it>=lt?x="bottom":x="top":x==="top"&&lt<I?it>=I?x="bottom":gt>=R||gt>=mt?x="left":x="right":x==="bottom"&&it<I&&(lt>=I?x="top":gt>=R||gt>=mt?x="left":x="right"):gt>=R?x="left":mt>=R?x="right":it>=I?x="bottom":x="top";let N=0,Z=0;x==="left"?(N=X+S.width+q,Z=et+S.height/2-K/2):x==="right"?(N=X-dt-q,Z=et+S.height/2-K/2):x==="top"?(Z=et+S.height+q,N=X+S.width/2-dt/2):x==="bottom"&&(Z=et-K-q,N=X+S.width/2-dt/2);let xt=Math.min(dt,Math.max(120,nt-J*2)),Ft=Math.min(K,Math.max(80,ht-J*2)),kt=J,Wt=Math.max(kt,nt-xt-J),Bt=J,Ht=Math.max(Bt,ht-Ft-J),Tt=Math.max(kt,Math.min(Wt,N)),Kt=Math.max(Bt,Math.min(Ht,Z)),ne=w?.enableBackdrop??w?.enable_backdrop??L?.details?.enableBackdrop??L?.details?.enable_backdrop,ge=ne!==!1&&ne!=="false"&&ne!==0,so=k.backdropOpacity!==void 0?k.backdropOpacity>1?k.backdropOpacity/100:k.backdropOpacity:.7,ao=((G,ut)=>{if(!G||G==="transparent")return"transparent";if(G.startsWith("rgba"))return G;if(G.startsWith("rgb"))return G.replace("rgb","rgba").replace(")",`, ${ut})`);if(G.startsWith("#")){let zt=G.slice(1);if(zt.length===3&&(zt=zt.split("").map(Vt=>Vt+Vt).join("")),zt.length===6){let Vt=parseInt(zt.slice(0,2),16),ct=parseInt(zt.slice(2,4),16),re=parseInt(zt.slice(4,6),16);return`rgba(${Vt}, ${ct}, ${re}, ${ut})`}}return G})(B.backdrop||"#000000",so),Qt=()=>{b(!0);let G=w.link;try{let ut=w._id||w.id||void 0;L?.id&&rt("clicked",L.id,{tooltip_id:ut})}catch{}s<v.length-1?(l(ut=>ut+1),G&&window.open(G,"_blank")):(d(!0),G&&window.open(G,"_blank"))},ie=()=>{b(!0),ge&&(s<v.length-1?l(G=>G+1):d(!0))},fe=w?.styling?.appearance?.highlight?.radius??w?.styling?.appearance?.radius,me=0;if(typeof fe=="number"&&fe>0)me=fe;else if(typeof fe=="string"&&fe!=="")me=parseInt(fe,10)||0;else if(y&&typeof window<"u")try{let G=y,ut=window.getComputedStyle(G);if(ut.borderRadius&&ut.borderRadius!=="0px")me=parseFloat(ut.borderRadius)||0;else if(G.firstElementChild){let zt=window.getComputedStyle(G.firstElementChild);zt.borderRadius&&zt.borderRadius!=="0px"&&(me=parseFloat(zt.borderRadius)||0)}}catch{}return Ro("div",{style:{position:"relative",zIndex:99999},children:[ge&&S&&Ro("svg",{style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",pointerEvents:"none",zIndex:1e4},children:[Yt("defs",{children:Ro("mask",{id:"as-spotlight-mask",children:[Yt("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:"white"}),Yt("rect",{x:S.left,y:S.top,width:S.width,height:S.height,rx:me,ry:me,fill:"black"})]})}),Yt("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:ao,mask:"url(#as-spotlight-mask)",style:{pointerEvents:"none",cursor:"default"}})]}),ge&&!S&&Yt("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:ao,zIndex:1e4},onClick:ie}),Ro("div",{ref:G=>{m.current=G,V(G)},style:{position:"fixed",top:Kt,left:Tt,zIndex:99999,backgroundColor:B.tooltip||"#FE6B35",padding:M?0:Da(k.padding),borderRadius:_a(k.cornerRadius,k.radius),boxShadow:"0 4px 12px rgba(0,0,0,0.15)",width:M?a:k.width?Math.min(k.width,nt-J*2):"auto",height:M?f:void 0,maxWidth:Math.max(160,nt-J*2),minWidth:M?void 0:Math.min(200,nt-J*2),boxSizing:"border-box",transition:"top 0.2s ease, left 0.2s ease",cursor:"default"},children:[Yt("div",{style:{position:"absolute",width:0,height:0,borderStyle:"solid",...x==="left"&&{left:-q,top:Math.max(12,Math.min(C.height-U*2-12,et+S.height/2-Kt-U)),borderWidth:`${U}px ${q}px ${U}px 0`,borderColor:`transparent ${B.arrow||B.tooltip||"#FE6B35"} transparent transparent`},...x==="right"&&{right:-q,top:Math.max(12,Math.min(C.height-U*2-12,et+S.height/2-Kt-U)),borderWidth:`${U}px 0 ${U}px ${q}px`,borderColor:`transparent transparent transparent ${B.arrow||B.tooltip||"#FE6B35"}`},...x==="top"&&{top:-q,left:Math.max(12,Math.min(C.width-U*2-12,X+S.width/2-Tt-U)),borderWidth:`0 ${U}px ${q}px ${U}px`,borderColor:`transparent transparent ${B.arrow||B.tooltip||"#FE6B35"} transparent`},...x==="bottom"&&{bottom:-q,left:Math.max(12,Math.min(C.width-U*2-12,X+S.width/2-Tt-U)),borderWidth:`${q}px ${U}px 0 ${U}px`,borderColor:`${B.arrow||B.tooltip||"#FE6B35"} transparent transparent transparent`}}}),w.url&&(M?Yt("div",{onClick:Qt,style:{width:"100%",height:"100%",overflow:"hidden",borderRadius:`${k.cornerRadius?.topLeft??12}px ${k.cornerRadius?.topRight??12}px ${k.cornerRadius?.bottomRight??12}px ${k.cornerRadius?.bottomLeft??12}px`,cursor:"pointer"},children:Yt("img",{src:w.url,alt:"tooltip media",style:{width:"100%",height:"100%",display:"block",objectFit:"cover",cursor:"pointer"}})}):Yt("img",{src:w.url,alt:"tooltip media",onClick:Qt,style:{width:"100%",borderRadius:6,marginBottom:8,display:"block",objectFit:"cover",cursor:"pointer"}})),(w.titleText||w.subtitleText||w.ctaText)&&Ro("div",{style:M?{padding:`${k.padding?.top??8}px ${k.padding?.right??8}px ${k.padding?.bottom??8}px ${k.padding?.left??8}px`}:void 0,children:[w.titleText&&Yt("div",{style:{color:T.title?.color||"#ffffff",fontFamily:st(T.title?.fontFamily)||"Arial",fontSize:T.title?.fontSize||14,textAlign:T.title?.textAlign||"center",marginBottom:T.title?.margin?.bottom??4,marginTop:T.title?.margin?.top??0,marginLeft:T.title?.margin?.left??0,marginRight:T.title?.margin?.right??0,fontWeight:T.title?.fontDecoration?.includes("bold")?"bold":600,fontStyle:T.title?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:T.title?.fontDecoration?.includes("underline")?"underline":"none"},children:w.titleText}),w.subtitleText&&Yt("div",{style:{color:T.subTitle?.color||"#ffffff",fontFamily:st(T.subTitle?.fontFamily)||"Arial",fontSize:T.subTitle?.fontSize||12,textAlign:T.subTitle?.textAlign||"center",marginBottom:T.subTitle?.margin?.bottom??8,marginTop:T.subTitle?.margin?.top??0,marginLeft:T.subTitle?.margin?.left??0,marginRight:T.subTitle?.margin?.right??0,fontWeight:T.subTitle?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:T.subTitle?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:T.subTitle?.fontDecoration?.includes("underline")?"underline":"none"},children:w.subtitleText}),w.ctaText&&Yt("div",{style:{display:"flex",justifyContent:H.alignment==="right"?"flex-end":H.alignment==="left"?"flex-start":"center",marginTop:8},children:Yt("button",{onClick:Qt,style:{width:H.ctaFullWidth?"100%":H.ctaWidth||"auto",height:H.height||35,background:H.backgroundColor||"#F7921C",color:r.color||"#ffffff",border:`${H.borderWidth||0}px solid ${H.borderColor||"transparent"}`,borderRadius:`${Y.topLeft??7}px ${Y.topRight??7}px ${Y.bottomRight??7}px ${Y.bottomLeft??7}px`,fontSize:r.fontSize||14,fontFamily:st(r.fontFamily)||"Arial",fontWeight:r.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:r.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:r.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:w.ctaText})})]})]})]})},$a=Wa;import{useEffect as Na,useState as Oa,useRef as ja}from"react";yt();import{Fragment as Ha,jsx as ue,jsxs as ri}from"react/jsx-runtime";var qa=()=>{let t=At("BTS"),e=P(g=>g.campaigns),o=P(g=>g.allCampaigns),n=P(g=>g.currentScreen),i=t??(()=>{let g=(n||"").trim().toLowerCase(),b=[...e||[],...o||[]].find(m=>{if(!m||m.campaign_type!=="BTS")return!1;let E=!!(m.trigger_event??m.trigger);if(!(m.display_trigger!==!1&&!E))return!1;let D=(m.screen||"").trim().toLowerCase();return!D||D===g});if(b)try{return Nt(b)}catch{return b}})(),s=P(g=>g.isVisible),[l,c]=Oa(!1),d=ja(null);Na(()=>{i?.id&&d.current!==i.id&&(d.current=i.id,c(!1),rt("viewed",i.id))},[i?.id]);let S=g=>{try{let b=P.getState(),E=(b.trackedEvents||[]).filter(O=>O!==g);b.setTrackedEvents(E)}catch{}};if(!i||l||!s)return null;let{details:p}=i,u=[...p.elements||[]].sort((g,b)=>(g.order||0)-(b.order||0)),C=p.backdropOpacity??.5;C>1&&(C=C/100);let h=g=>{switch(g.type){case"image":{let b={width:"100%",display:"block",objectFit:"contain",backgroundColor:g.imageBackgroundColor||"transparent",paddingBottom:g.paddingBottom??0,paddingLeft:g.paddingLeft??0,paddingRight:g.paddingRight??0,paddingTop:g.paddingTop??0,cursor:g.imageLink?"pointer":"default"};return ue("div",{style:{textAlign:g.alignment||"left",width:"100%"},children:g.url&&ue("img",{src:g.url,alt:"",style:b,onClick:()=>{if(g.imageLink){i?.id&&rt("clicked",i.id);try{let m=String(g.imageLink||"").trim();if(m&&!m.startsWith("http")&&Pt(m))return}catch(m){console.warn("revealCampaignFromLink error",m)}try{window.open(g.imageLink,"_blank")}catch{}}}})},g.id)}case"cta":{let b=g.cta||{},m=b.container||{},E=b.cornerRadius||{},O=b.margin||{},D=b.text||{};return ue("div",{style:{display:"flex",justifyContent:m.alignment==="center"?"center":m.alignment==="right"?"flex-end":"flex-start",width:"100%",marginTop:O.top??0,marginBottom:O.bottom??0,marginLeft:O.left??0,marginRight:O.right??0},children:ue("button",{style:{width:m.ctaFullWidth?"100%":m.ctaWidth||"auto",height:m.height||45,backgroundColor:m.ctaBoxColor||m.backgroundColor||"#FE6B35",color:D.color||"#ffffff",border:`${m.borderWidth||0}px solid ${m.borderColor||"transparent"}`,borderRadius:`${E.topLeft??12}px ${E.topRight??12}px ${E.bottomRight??12}px ${E.bottomLeft??12}px`,fontSize:D.fontSize||14,fontFamily:st(D.fontFamily)||"Arial",fontWeight:D.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:D.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:D.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px"},onClick:()=>{let L=g.ctaLink||g.url;if(L){i?.id&&rt("clicked",i.id);try{let v=String(L||"").trim();if(v&&!v.startsWith("http")&&Pt(v))return}catch(v){console.warn("revealCampaignFromLink error",v)}try{window.open(L,"_blank")}catch{}}},children:g.ctaText||"Button"})},g.id)}case"body":{let b=g.titleFontStyle||{},m=g.descriptionFontStyle||{};return ri("div",{style:{width:"100%",backgroundColor:g.bodyBackgroundColor||"transparent",marginTop:g.marginTop??0,marginBottom:g.marginBottom??20,marginLeft:g.marginLeft??4,marginRight:g.marginRight??4},children:[g.titleText&&ue("div",{style:{color:b.colour||"#000000",fontSize:b.fontSize?`${b.fontSize}px`:g.titleFontSize?`${g.titleFontSize}px`:"16px",fontFamily:st(b.fontFamily)||"inherit",textAlign:b.alignment||"left",lineHeight:g.titleLineHeight||1.2,fontWeight:b.decoration?.includes("bold")?"bold":"600",fontStyle:b.decoration?.includes("italic")?"italic":"normal",textDecoration:b.decoration?.includes("underline")?"underline":"none",marginBottom:g.spacingBetweenTitleDesc??4},children:g.titleText}),g.descriptionText&&ue("div",{style:{color:m.colour||"#000000",fontSize:m.fontSize?`${m.fontSize}px`:g.descriptionFontSize?`${g.descriptionFontSize}px`:"14px",fontFamily:st(m.fontFamily)||"inherit",textAlign:m.alignment||"left",lineHeight:g.descriptionLineHeight||1.5,fontWeight:m.decoration?.includes("bold")?"bold":"normal",fontStyle:m.decoration?.includes("italic")?"italic":"normal",textDecoration:m.decoration?.includes("underline")?"underline":"none"},children:g.descriptionText})]},g.id)}default:return null}};return ri(Ha,{children:[ue("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:p.backdropColor||"rgba(0,0,0,0.5)",opacity:C,zIndex:999998,transition:"opacity 0.3s ease"},onClick:()=>{i?.id&&S(`viaAppStorys${i.id}`),c(!0)}}),ri("div",{style:{position:"fixed",bottom:0,left:"50%",transform:"translateX(-50%)",width:"100%",maxWidth:"500px",backgroundColor:p.backgroundColor||"#FFFFFF",borderTopLeftRadius:`${p.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${p.cornerRadius?.topRight??16}px`,borderBottomLeftRadius:`${p.cornerRadius?.bottomLeft??0}px`,borderBottomRightRadius:`${p.cornerRadius?.bottomRight??0}px`,zIndex:999999,padding:"24px 16px",boxShadow:"0 -4px 16px rgba(0,0,0,0.15)",maxHeight:"85vh",overflowY:"auto",display:"flex",flexDirection:"column",alignItems:"center",transition:"transform 0.3s ease-out"},children:[ue("div",{style:{width:"40px",height:"5px",backgroundColor:"#E0E0E0",borderRadius:"2.5px",marginBottom:"16px",cursor:"pointer"},onClick:()=>c(!0)}),p.crossButton?.enabled&&ue(Dt,{config:p.crossButton,onPress:()=>{i?.id&&S(`viaAppStorys${i.id}`),c(!0)},style:{top:p.crossButton?.margin?.top??12,right:p.crossButton?.margin?.right??12}}),ue("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:"12px"},children:u.map(h)})]})]})};import{useEffect as sn,useMemo as Va,useState as pe,useRef as Ua}from"react";yt();import*as Ke from"lottie-react";import{Fragment as di,jsx as bt,jsxs as Fo}from"react/jsx-runtime";var Ya=Ke.default?.default??Ke.default??Ke.Lottie??Ke,jr=5,si=3;function rn(t){if(t!=null)return`${t}px`}function Ut(t,e="0px"){return t==null?e:`${t}px`}function Je(t){return{marginTop:rn(t?.top),marginRight:rn(t?.right),marginBottom:rn(t?.bottom),marginLeft:rn(t?.left)}}function ci(t){return st(t)}function Xe(t){if(!t)return{};let e={};t.color&&(e.color=t.color),t.fontSize&&(e.fontSize=t.fontSize);let o=ci(t.fontFamily);return o&&(e.fontFamily=o),t.textAlign&&(e.textAlign=t.textAlign),t.fontDecoration?.includes("bold")&&(e.fontWeight="bold"),t.fontDecoration?.includes("italic")&&(e.fontStyle="italic"),t.fontDecoration?.includes("underline")&&(e.textDecoration="underline"),e}function an(t){return`${t?.topLeft??8}px ${t?.topRight??8}px ${t?.bottomRight??8}px ${t?.bottomLeft??8}px`}function ai(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function Ga(t){let e=t.styling?.rating?.ratingType;return e==="number"||e==="emoji"||e==="star"?e:"star"}function Qa(t){let e=t.styling?.rating?.emoji,o=[];Array.isArray(e)?o=e:e&&typeof e=="object"?Array.isArray(e.values)?o=e.values:o=Object.values(e):typeof e=="string"&&e.trim()&&(o=e.split(","));let n=o.map(i=>{if(typeof i=="string")return i.trim();if(i&&typeof i=="object"){let s=i.emoji||i.value||i.text||i.icon||i.name||"";if(typeof s=="string")return s.trim()}return""}).filter(Boolean);return n.length>0?n:["\u{1F620}","\u{1F615}","\u{1F610}","\u{1F642}","\u{1F60D}"]}function Xa(t){return Array.from({length:5},(e,o)=>o+1)}function li(t){if(typeof t=="number"&&Number.isFinite(t)&&t>=0)return t;if(typeof t=="string"&&t.trim().length>0){let e=Number(t);if(Number.isFinite(e)&&e>=0)return e}}function Ja(t){let e=t.styling?.rating||void 0,o=[e?.numberSpacing,e?.numberGap,e?.number_spacing,e?.number_gap,e?.spacingBetweenNumbers,e?.spaceBetweenNumbers,e?.numberOptionsSpacing,e?.spacing];for(let i of o){let s=li(i);if(s!=null)return s}let n=e?.number;if(n&&typeof n=="object"){let i=n,s=[i.spacing,i.gap,i.optionsSpacing,i.numberSpacing,i.numberGap];for(let l of s){let c=li(l);if(c!=null)return c}}return 8}var Ka=({fill:t,stroke:e})=>bt("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":!0,children:bt("path",{d:"M12 2.25l2.91 5.89 6.5.95-4.7 4.58 1.11 6.46L12 17.03 6.18 20.13l1.11-6.46-4.7-4.58 6.5-.95L12 2.25z",fill:t,stroke:e,strokeWidth:"1.4",strokeLinejoin:"round"})}),Za=({details:t,appearance:e,rating:o,selectedOptions:n,comments:i,isHighRating:s,feedbackOptions:l,onRate:c,onToggleOption:d,onCommentChange:S,onInlineSubmit:p,canSubmit:y,isMobile:u})=>{let C=t.styling||{},h=C.feedbackPage||{},g=C.rating||{},b=C.initialFeedback||{},m=h.submitButton?.cta,E=Ga(t),O=E==="number"?Xa(t):[],D=E==="emoji"?Qa(t):[],L=E==="number"?Ja(t):8,v=E==="number"?L:g.spacing??8,w=u?"clamp(32px, 11vw, 44px)":"44px",_=u?"clamp(16px, 4.5vw, 22px)":22,$=ai(g.alignment),V=an(g.cornerRadius),A=s?g.star?.high:g.star?.low,T=typeof g.number=="object"&&g.number?g.number:void 0,k=s?T?.high:T?.low,B=m?.container?.ctaFullWidth?"100%":Math.max(140,li(m?.container?.ctaWidth)??180);return Fo(di,{children:[bt("div",{style:Je(b.title?.margin),children:bt("div",{style:{...Xe(b.title?.textStyle),color:b.title?.textStyle?.color||"#101828",fontSize:b.title?.textStyle?.fontSize||20,lineHeight:1.3,wordBreak:"break-word",overflowWrap:"break-word",paddingRight:C.crossButton?.enabled?(C.crossButton.size??30)+(C.crossButton.margin?.right??4)+4:0},children:t.title||"How was your experience?"})}),bt("div",{style:Je(b.subtitle?.margin),children:bt("div",{style:{...Xe(b.subtitle?.textStyle),color:b.subtitle?.textStyle?.color||"#4b5563",fontSize:b.subtitle?.textStyle?.fontSize||14,lineHeight:1.4,wordBreak:"break-word",overflowWrap:"break-word"},children:t.description_text||"Your feedback helps us improve your experience."})}),Fo("div",{style:{marginTop:8,display:"flex",justifyContent:$,gap:v,flexWrap:"wrap"},children:[E==="star"&&Array.from({length:jr},(W,H)=>{let Y=H+1,r=Y<=o,M=r?A?.stylingContainer:g.star?.unselected?.stylingContainer,a=r?A?.stylingStar:g.star?.unselected?.stylingStar;return bt("button",{onClick:()=>c(Y),style:{border:`${M?.borderWidth??1}px solid ${M?.border||"#d1d5db"}`,background:M?.background||"#ffffff",borderRadius:V,width:w,height:w,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,flexShrink:0},"aria-label":`Rate ${Y} out of ${jr}`,children:bt(Ka,{fill:a?.background||(r?"#f59e0b":"#e5e7eb"),stroke:a?.border||(r?"#d97706":"#9ca3af")})},Y)}),E==="number"&&O.map((W,H)=>{let Y=W===o,r=Y?k?.stylingContainer:T?.unselected?.stylingContainer,M=Y?T?.stylingNumber:T?.unselected?.stylingNumber;return bt("button",{onClick:()=>c(W),style:{border:`${r?.borderWidth??1}px solid ${r?.border||(Y?"#1d4ed8":"#d1d5db")}`,background:r?.fill||r?.background||(Y?"#dbeafe":"#ffffff"),color:M?.text||(Y?"#1d4ed8":"#111827"),fontSize:M?.textSize||void 0,borderRadius:V,minWidth:w,height:w,padding:"0 10px",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontWeight:600,flexShrink:0},"aria-label":`Rate ${W}`,children:W},`${W}-${H}`)}),E==="emoji"&&D.map((W,H)=>{let Y=H+1,r=Y===o,M=g.emoji,f=(r?M?.selected:M?.unselected)?.stylingContainer;return bt("button",{onClick:()=>c(Y),style:{border:`${f?.borderWidth??1}px solid ${f?.border||(r?"#1d4ed8":"#d1d5db")}`,background:f?.fill||f?.background||(r?"#dbeafe":"#ffffff"),borderRadius:V,width:w,height:w,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:_,flexShrink:0},"aria-label":`Emoji rating ${H+1}`,children:W},`${W}-${H}`)})]}),o>0&&bt("div",{style:{marginTop:6,textAlign:"center",color:"#374151",fontSize:14},children:s?t.highStarText||g.highRatingSubtitle:t.lowStarText||g.lowRatingSubtitle}),o>0&&o<=si&&Fo(di,{children:[l.length>0&&bt("div",{style:{...Je(h.options?.margin),display:"flex",flexDirection:"column",alignItems:"stretch",gap:h.options?.optionsSpacing??8,width:"100%"},children:l.map(W=>{let Y=n.includes(W)?h.options?.selectedOptions:h.options?.nonSelectedOptions;return bt("button",{onClick:()=>d(W),style:{border:`${Y?.borderWidth??1}px solid ${Y?.colors?.border||"#d1d5db"}`,background:Y?.colors?.background||"#f9fafb",color:Y?.colors?.text||"#111827",width:"100%",height:h.options?.optionsHeight||38,borderRadius:an(h.options?.cornerRadius),padding:"0 14px",cursor:"pointer",textAlign:"center",...Xe(Y?.textStyle)},children:W},W)})}),h.additionalComments?.enabled!==!1&&bt("textarea",{value:i,onChange:W=>S(W.target.value),placeholder:h.additionalComments?.placeholder||"Tell us what we can improve",style:{width:"100%",boxSizing:"border-box",minHeight:56,height:56,maxHeight:64,marginTop:8,resize:"none",overflowY:"auto",border:`${h.additionalComments?.borderWidth??1}px solid ${h.additionalComments?.colors?.border||"#d1d5db"}`,background:h.additionalComments?.colors?.background||"#ffffff",color:h.additionalComments?.colors?.text||"#111827",borderRadius:8,padding:"12px",...Xe(h.additionalComments?.textStyle)}}),bt("div",{style:{position:"sticky",bottom:0,marginTop:m?.margin?.top??8,marginBottom:m?.margin?.bottom??0,marginLeft:m?.margin?.left??0,marginRight:m?.margin?.right??0,paddingTop:6,paddingBottom:6,background:e?.backgroundColor||"#ffffff",display:"flex",justifyContent:ai(m?.container?.alignment)},children:bt("button",{onClick:()=>p(),disabled:!y,style:{width:B,maxWidth:"100%",height:Number(m?.container?.height)||40,border:`${m?.container?.borderWidth??0}px solid ${m?.container?.borderColor||"transparent"}`,background:m?.container?.backgroundColor||"#6848b1",color:m?.text?.color||"#ffffff",borderRadius:an(m?.cornerRadius),fontFamily:ci(m?.text?.fontFamily),fontSize:Number(m?.text?.fontSize)||14,fontWeight:m?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:y?"pointer":"not-allowed",opacity:y?1:.65,padding:"0 12px",boxSizing:"border-box"},children:h.submitButton?.text||"Submit"})})]})]})},tl=({details:t,isHighRating:e,onDone:o})=>{let n=t.styling||{},i=n.thankyouPage||{},s=n.rating||{},l=ai(i.doneButton?.cta?.container?.alignment),[c,d]=pe(null),S=t.thankyouImage?.endsWith(".json");return sn(()=>{S&&t.thankyouImage&&fetch(t.thankyouImage).then(p=>p.json()).then(p=>d(p)).catch(p=>console.error("Error loading Lottie:",p))},[t.thankyouImage,S]),Fo(di,{children:[t.thankyouImage&&bt("div",{style:{display:"flex",justifyContent:"center",...Je(i.imageStyle?.margin)},children:S?c?bt(Ya,{animationData:c,loop:!0,style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80}}):bt("div",{style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80}}):bt("img",{src:t.thankyouImage,alt:"thank you",style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80,objectFit:"cover",borderRadius:8}})}),bt("div",{style:Je(i.title?.margin),children:bt("div",{style:{color:"#111827",fontSize:20,lineHeight:1.3,...Xe(i.title?.textStyle),wordBreak:"break-word",overflowWrap:"break-word"},children:t.thankyouText||(e?s.highRatingTitle:s.lowRatingTitle)||"Thank you for your feedback"})}),bt("div",{style:Je(i.subtitle?.margin),children:bt("div",{style:{color:"#4b5563",fontSize:14,lineHeight:1.4,...Xe(i.subtitle?.textStyle),wordBreak:"break-word",overflowWrap:"break-word"},children:t.thankyouDescription||(e?s.highRatingSubtitle:s.lowRatingSubtitle)||"We appreciate your time."})}),bt("div",{style:{marginTop:i.doneButton?.cta?.margin?.top??14,marginBottom:i.doneButton?.cta?.margin?.bottom??0,marginLeft:i.doneButton?.cta?.margin?.left??0,marginRight:i.doneButton?.cta?.margin?.right??0,display:"flex",justifyContent:l},children:bt("button",{onClick:o,style:{width:i.doneButton?.cta?.container?.ctaFullWidth?"100%":i.doneButton?.cta?.container?.ctaWidth||"auto",height:i.doneButton?.cta?.container?.height||45,border:`${i.doneButton?.cta?.container?.borderWidth??0}px solid ${i.doneButton?.cta?.container?.borderColor||"transparent"}`,background:i.doneButton?.cta?.container?.backgroundColor||"#111827",color:i.doneButton?.cta?.text?.color||"#ffffff",borderRadius:an(i.doneButton?.cta?.cornerRadius),fontFamily:ci(i.doneButton?.cta?.text?.fontFamily),fontSize:i.doneButton?.cta?.text?.fontSize||16,fontWeight:i.doneButton?.cta?.text?.fontDecoration?.includes("bold")?"bold":"normal",cursor:"pointer",padding:"0 16px",boxSizing:"border-box"},children:e?t.highStarText||i.doneButton?.text||"Rate Now":t.lowStarText||i.doneButton?.text||"Done"})})]})},el=()=>{let t=At("CSAT"),e=P(x=>x.isVisible),o=P(x=>x.campaigns),n=P(x=>x.allCampaigns),i=P(x=>x.currentScreen),[s,l]=pe(typeof window<"u"?window.innerWidth:1024);sn(()=>{if(typeof window>"u")return;let x=()=>l(window.innerWidth);return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);let c=s<768,d=t??(()=>{let x=(i||"").trim().toLowerCase(),z=[...o||[],...n||[]].find(U=>{if(!U||U.campaign_type!=="CSAT")return!1;let et=!!(U.trigger_event??U.trigger);if(!(U.display_trigger!==!1&&!et))return!1;let q=(U.screen||"").trim().toLowerCase();return!q||q===x});if(z)try{return Nt(z)}catch{return z}})(),[S,p]=pe(!1),[y,u]=pe(!1),[C,h]=pe(!1),[g,b]=pe(!1),[m,E]=pe(0),[O,D]=pe([]),[L,v]=pe(""),[w,_]=pe(!1),$=Ua(null);sn(()=>{if(!d?.id||$.current===d.id)return;$.current=d.id,p(!1),u(!1),h(!1),b(!1),E(0),D([]),v(""),_(!1);let x=d.details?.styling?.appearance?.displayDelay??0,z=globalThis.setTimeout(()=>{u(!0),rt("viewed",d.id)},Math.max(0,x)*1e3);return()=>globalThis.clearTimeout(z)},[d?.id]),sn(()=>{if(y){let x=setTimeout(()=>h(!0),30);return()=>clearTimeout(x)}},[y]);let V=Va(()=>{let x=d?.details?.feedback_option||{};return Object.keys(x).sort((z,U)=>z.localeCompare(U)).map(z=>typeof x[z]=="string"?x[z].trim():x[z]).filter(Boolean)},[d]);if(!d||!e||S||!y)return null;let A=d.details,T=A.styling||{},k=T.appearance||{},B=m>si,W=x=>{D(z=>z.includes(x)?z.filter(U=>U!==x):[...z,x])},H=async x=>{let z=x?.rating??m;if(z<1)return;_(!0);let U=d.id,et=(x?.options??O)[0]||"",X=x?.comments??L??"";rt("csat captured",U,{starCount:z,selectedOption:et,additionalComments:X})},Y=x=>{if(E(x),x>si){D([]),v("");let z=d?.id;setTimeout(()=>{_(!0);try{rt("csat captured",z,{starCount:x,selectedOption:"",additionalComments:""})}catch(U){console.warn("Error sending csat captured",U)}},1e3)}},r=async()=>{b(!0);try{let x=d?.id;await rt("csat closed",x)}catch(x){console.warn("Error sending csat closed",x)}finally{setTimeout(()=>{p(!0)},300)}},M=()=>{if(B&&A.link){let x=d&&d.id||void 0;try{x&&rt("clicked",x)}catch{}try{let z=String(A.link||"").trim();if(z&&!z.startsWith("http")&&Pt(z)){b(!0),setTimeout(()=>{p(!0)},300);return}}catch(z){console.warn("revealCampaignFromLink error",z)}try{globalThis.open(A.link,"_blank")}catch{}}b(!0),setTimeout(()=>{p(!0)},300)},a=c?{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"center",alignItems:"flex-end",paddingLeft:Ut(k.margin?.left,"0px"),paddingRight:Ut(k.margin?.right,"0px"),pointerEvents:"none"}:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"flex-end",alignItems:"flex-end",paddingTop:Ut(k.margin?.top),paddingRight:Ut(k.margin?.right,"20px"),paddingBottom:Ut(k.margin?.bottom,"20px"),paddingLeft:Ut(k.margin?.left,"20px"),pointerEvents:"none"},f=c?{position:"relative",width:"100%",maxWidth:"none",maxHeight:"85vh",overflow:"visible",backgroundColor:k.backgroundColor||"#ffffff",borderTopLeftRadius:`${k.borderRadius??16}px`,borderTopRightRadius:`${k.borderRadius??16}px`,borderBottomLeftRadius:0,borderBottomRightRadius:0,boxSizing:"border-box",paddingTop:Ut(k.padding?.top,"12px"),paddingRight:Ut(k.padding?.right,"16px"),paddingBottom:`max(${Ut(k.padding?.bottom,"16px")}, env(safe-area-inset-bottom, 16px))`,paddingLeft:Ut(k.padding?.left,"16px"),pointerEvents:"auto",boxShadow:"0 -8px 32px rgba(0, 0, 0, 0.20)",display:"flex",flexDirection:"column",transform:g||!C?"translateY(100%)":"translateY(0)",transition:"transform 0.3s cubic-bezier(0.25, 1, 0.5, 1)"}:{position:"relative",width:"min(450px, 92vw)",maxHeight:"85vh",overflow:"visible",backgroundColor:k.backgroundColor||"#ffffff",borderRadius:`${k.borderRadius??12}px`,boxSizing:"border-box",paddingTop:Ut(k.padding?.top,"8px"),paddingRight:Ut(k.padding?.right,"12px"),paddingBottom:Ut(k.padding?.bottom,"8px"),paddingLeft:Ut(k.padding?.left,"12px"),pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column",transform:g||!C?"translateY(100%)":"translateY(0)",transition:"transform 0.3s cubic-bezier(0.25, 1, 0.5, 1)"};return bt("div",{style:a,children:Fo("div",{style:f,children:[bt("style",{children:`
128
+ `}),B&&ts(Za,{children:[xe("div",{ref:v=>{d.current=v,R(v)},className:"widget-scroll-container",style:z,onScroll:T,children:y.map((v,A)=>xe("div",{style:O(A),children:xe(Ka,{item:v,onClick:()=>h(v.id,v.link)})},v.id||A))}),m==="full"&&y.length>1&&xe("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"6px",marginTop:"8px",width:"100%"},children:y.map((v,A)=>xe("div",{onClick:()=>E(A),style:{width:A===i?"14px":"6px",height:"6px",borderRadius:"50px",backgroundColor:A===i?"#101010":"#d1d5db",transition:"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",cursor:"pointer"}},A))})]})]})};import{useEffect as ao,useLayoutEffect as el,useMemo as mi,useRef as Ye,useState as lo,useCallback as rs}from"react";vt();var os=new Set;function tl(){try{return globalThis?.process?.env?.NODE_ENV!=="production"}catch{return!0}}function ns(t,e,o){if(!tl()||o<=1)return;let n=`${e}::${t}`;os.has(n)||(os.add(n),console.warn(`AppStorys: Found ${o} elements matching target "${t}" (selector "${e}"). The first one in document order will be used. Target identifiers should be unique per screen.`))}function is(t){if(!t)return null;let e=[`[data-as-id="${t}"]`,`[data-id="${t}"]`,`[data-widget="${t}"]`];for(let n of e)try{let i=document.querySelectorAll(n);if(i.length>0)return ns(t,n,i.length),i[0]}catch{}let o=document.getElementById(t);if(o)return o;try{let n=`.${CSS&&CSS.escape?CSS.escape(t):t}`,i=document.querySelectorAll(n);if(i.length>0)return ns(t,n,i.length),i[0]}catch{}return null}Vt();import{jsx as ne,jsxs as Do}from"react/jsx-runtime";var yi=t=>(t||"").trim().toLowerCase(),ol=t=>{if(t==null)return"8px 8px 8px 8px";if(typeof t=="number")return`${t}px`;if(typeof t=="object"){let e=t.top??8,o=t.right??8,n=t.bottom??8,i=t.left??8;return`${e}px ${o}px ${n}px ${i}px`}return String(t)},nl=(t,e)=>{if(typeof t=="number")return`${t}px`;if(typeof e=="number")return`${e}px`;if(typeof t=="object"&&t!==null){let o=t.topLeft??12,n=t.topRight??12,i=t.bottomRight??12,s=t.bottomLeft??12;return`${o}px ${n}px ${i}px ${s}px`}return"12px"},il=()=>{let t=Mt("TTP"),e=W(J=>J.campaigns),o=W(J=>J.allCampaigns),n=W(J=>J.currentScreen),i=W(J=>J.userId),s=W(J=>J.isVisible),[d,c]=lo(0),[l,y]=lo(!1),[u,m]=lo(null),[f,P]=lo(null),[g,b]=lo({width:0,height:0}),[R,C]=lo(!1),h=Ye(null),T=Ye(null),E=Ye(null),X=Ye(!1),I=rs(J=>{if(J)try{J.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}catch{try{J.scrollIntoView()}catch{}}},[]),S=mi(()=>{if(t)return t;let J=yi(n),Rt=(xt=>xt.filter(pe=>{let ee=pe,ze=ee.campaign_type==="TTP"||ee.campaign_type==="TLTP",Ht=!yi(ee.screen)||yi(ee.screen)===J,$e=!!(ee.trigger_event??ee.trigger),Nt=ee.display_trigger!==!1&&!$e;return ze&&Ht&&Nt&&Ot(ee,i)}))(e&&e.length>0?e:o||[]);return Rt.length===0?void 0:Lt(Rt)[0]},[t,e,o,i,n]);ao(()=>{c(0),y(!1),C(!1)},[S?.id]);let M=mi(()=>S?.details?.tooltips&&Array.isArray(S.details.tooltips)?[...S.details.tooltips].sort((J,bt)=>(J.order??0)-(bt.order??0)):S?.details?.target||S?.details?.titleText?[{...S.details,_id:S.id}]:[],[S]),x=M[d];ao(()=>{},[S]);let N=Ye(new Set),U=rs(()=>{if(!(!S||!x||l||!s))try{let J=x._id||x.id||void 0,bt=String(S.id||"")+"::"+String(J||"");N.current.has(bt)||(N.current.add(bt),st("viewed",S.id,{tooltip_id:J}))}catch{}},[S,x,l,s]),z=_o(U);ao(()=>{if(!x||l)return;m(null),P(null);let J=null,bt=null,Rt=()=>{let Nt=typeof window<"u"?document.documentElement.clientWidth||window.innerWidth:1024,Wt=typeof window<"u"?document.documentElement.clientHeight||window.innerHeight:768;return new DOMRect(Nt/2-100,Wt/2-50,200,100)},te=Nt=>{if(!Nt||!(Nt instanceof HTMLElement))return!1;let Wt=Nt.getBoundingClientRect();if(Wt.width===0||Wt.height===0)return!1;try{let w=window.getComputedStyle(Nt);if(w.display==="none"||w.visibility==="hidden"||w.opacity==="0")return!1}catch{}return!0},xt=(Nt=!1)=>{let Wt=x.target||x.targetId||x.elementId;if(!Wt)return m(Rt()),P(null),null;let w=is(Wt);if(w){if(P(w),te(w)){let q=w.getBoundingClientRect();Nt?(I(w),m(q),setTimeout(()=>{I(w),m(w.getBoundingClientRect())},50),setTimeout(()=>{m(w.getBoundingClientRect())},150),setTimeout(()=>{m(w.getBoundingClientRect())},350)):m(Rt())}else m(Rt());return w}return P(null),m(Rt()),null},pe=()=>{C(!0)},ee=Nt=>{E.current?.disconnect(),E.current=null,!(!Nt||typeof ResizeObserver>"u")&&(E.current=new ResizeObserver(()=>{te(Nt)?m(Nt.getBoundingClientRect()):m(null)}),E.current.observe(Nt))},ze=(Nt=!1)=>{let Wt=xt(Nt);Wt&&Wt!==J&&(J&&J.removeEventListener("click",pe),J=Wt,Wt.addEventListener("click",pe),ee(Wt))};ze(!0),T.current=new MutationObserver(()=>{ze(!1)}),T.current.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let Ht=()=>ze(!1),$e=()=>{typeof document<"u"&&document.visibilityState==="hidden"||ze(!0)};return window.addEventListener("resize",Ht),window.addEventListener("scroll",Ht,{passive:!0,capture:!0}),window.addEventListener("focus",$e),document.addEventListener("visibilitychange",$e),document.addEventListener("mouseenter",Ht,!0),document.addEventListener("mouseover",Ht,!0),document.addEventListener("mouseleave",Ht,!0),document.addEventListener("click",Ht,!0),()=>{bt&&clearTimeout(bt),J&&J.removeEventListener("click",pe),T.current?.disconnect(),E.current?.disconnect(),window.removeEventListener("resize",Ht),window.removeEventListener("scroll",Ht,{capture:!0}),window.removeEventListener("focus",$e),document.removeEventListener("visibilitychange",$e),document.removeEventListener("mouseenter",Ht,!0),document.removeEventListener("mouseover",Ht,!0),document.removeEventListener("mouseleave",Ht,!0),document.removeEventListener("click",Ht,!0)}},[x,l,d,I]),ao(()=>{if(!x||l||!u)return;let J=x?.enableBackdrop??x?.enable_backdrop??S?.details?.enableBackdrop??S?.details?.enable_backdrop;if(!(J!==!1&&J!=="false"&&J!==0))return;let Rt=te=>{let xt=te.target;xt&&(h.current&&h.current.contains(xt)||f&&(f===xt||f.contains(xt))||(C(!0),d<M.length-1?c(pe=>pe+1):y(!0)))};return window.addEventListener("click",Rt,!0),()=>{window.removeEventListener("click",Rt,!0)}},[x,l,u,f,d,M.length,S]);let O=Ye(null),B=Ye(null);ao(()=>{if(!S||!x||l||!s||!u){O.current!==null&&(document.body.style.overflow=O.current,O.current=null),B.current!==null&&(document.documentElement.style.overflow=B.current,B.current=null);return}return O.current===null&&(O.current=document.body.style.overflow!=="hidden"?document.body.style.overflow:""),B.current===null&&(B.current=document.documentElement.style.overflow!=="hidden"?document.documentElement.style.overflow:""),document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",()=>{O.current!==null&&(document.body.style.overflow=O.current,O.current=null),B.current!==null&&(document.documentElement.style.overflow=B.current,B.current=null)}},[S,x,l,s,!!u]),ao(()=>{if(!f||!(f instanceof HTMLElement)||l)return;let J=f,bt=()=>{C(!0)};return J.addEventListener("click",bt),()=>{J.removeEventListener("click",bt)}},[f,d,l]),el(()=>{if(h.current&&u){let{width:J,height:bt}=h.current.getBoundingClientRect();b({width:J,height:bt})}},[x,u]);let K=mi(()=>{let J=x?.styling?.appearance?.highlight?.radius;if(J!=null)return`${J}px`;if(f&&typeof window<"u")try{let bt=window.getComputedStyle(f);if(bt.borderRadius&&bt.borderRadius!=="0px")return bt.borderRadius}catch{}return"6px"},[x?.styling?.appearance?.highlight?.radius,f]);if(!S||!x||l||!s||!u)return null;let v=x.styling||{},A=v.appearance||{},H=A.colors||{},it=v.cta||{},at=it.container||{},a=it.cornerRadius||{},F=it.text||{},r=!!(A.imageDimensions?.width&&A.imageDimensions?.height),p,j;if(r){let J=A.imageDimensions.width,bt=A.imageDimensions.height,Rt=typeof window<"u"?window.innerWidth*.9:J;p=Math.min(J,Rt),j=p===J?bt:Math.round(bt*(p/J))}let k=x.arrowPosition;!k&&x.position&&(x.position==="left"?k="right":x.position==="right"?k="left":x.position==="top"?k="bottom":x.position==="bottom"&&(k="top")),k||(k="left");let V=(A.arrowStyle||{width:6,height:12}).width||6,rt=u.top,lt=u.left,Z=8,gt=8,Q=typeof window<"u"?document.documentElement.clientWidth||window.innerWidth:1024,dt=typeof window<"u"?document.documentElement.clientHeight||window.innerHeight:768,yt=g.width||r&&p||250,ct=g.height||(r?j||150:100),mt=u.top,$=dt-(u.top+u.height),_=u.left,D=Q-(u.left+u.width),L=yt+Z+gt,Y=ct+Z+gt;k?k==="left"&&D<L?_>=L?k="right":mt>=Y||mt>=$?k="bottom":k="top":k==="right"&&_<L?D>=L?k="left":mt>=Y||mt>=$?k="bottom":k="top":k==="top"&&$<Y?mt>=Y?k="bottom":D>=L||D>=_?k="left":k="right":k==="bottom"&&mt<Y&&($>=Y?k="top":D>=L||D>=_?k="left":k="right"):D>=L?k="left":_>=L?k="right":mt>=Y?k="bottom":k="top";let ot=0,ft=0;k==="left"?(ot=lt+u.width+Z,ft=rt+u.height/2-ct/2):k==="right"?(ot=lt-yt-Z,ft=rt+u.height/2-ct/2):k==="top"?(ft=rt+u.height+Z,ot=lt+u.width/2-yt/2):k==="bottom"&&(ft=rt-ct-Z,ot=lt+u.width/2-yt/2);let Dt=Math.min(yt,Math.max(120,Q-gt*2)),Ft=Math.min(ct,Math.max(80,dt-gt*2)),$t=gt,_t=Math.max($t,Q-Dt-gt),Jt=gt,re=Math.max(Jt,dt-Ft-gt),ce=Math.max($t,Math.min(_t,ot)),Ie=Math.max(Jt,Math.min(re,ft)),Ge=x?.enableBackdrop??x?.enable_backdrop??S?.details?.enableBackdrop??S?.details?.enable_backdrop,Qe=Ge!==!1&&Ge!=="false"&&Ge!==0,Uo=A.backdropOpacity!==void 0?A.backdropOpacity>1?A.backdropOpacity/100:A.backdropOpacity:.7,Co=((J,bt)=>{if(!J||J==="transparent")return"transparent";if(J.startsWith("rgba"))return J;if(J.startsWith("rgb"))return J.replace("rgb","rgba").replace(")",`, ${bt})`);if(J.startsWith("#")){let Rt=J.slice(1);if(Rt.length===3&&(Rt=Rt.split("").map(te=>te+te).join("")),Rt.length===6){let te=parseInt(Rt.slice(0,2),16),xt=parseInt(Rt.slice(2,4),16),pe=parseInt(Rt.slice(4,6),16);return`rgba(${te}, ${xt}, ${pe}, ${bt})`}}return J})(H.backdrop||"#000000",Uo),vo=()=>{if(X.current)return;X.current=!0,setTimeout(()=>{X.current=!1},400),C(!0);let J=x.link;try{let bt=x._id||x.id||void 0;S?.id&&st("clicked",S.id,{tooltip_id:bt})}catch{}if(J&&wt(J)){y(!0);return}d<M.length-1?(c(bt=>bt+1),J&&window.open(J,"_blank")):(y(!0),J&&window.open(J,"_blank"))},ue=()=>{C(!0),Qe&&(d<M.length-1?c(J=>J+1):y(!0))},Gt=x?.styling?.appearance?.highlight?.radius??x?.styling?.appearance?.radius,ve=0;if(typeof Gt=="number"&&Gt>0)ve=Gt;else if(typeof Gt=="string"&&Gt!=="")ve=parseInt(Gt,10)||0;else if(f&&typeof window<"u")try{let J=f,bt=window.getComputedStyle(J);if(bt.borderRadius&&bt.borderRadius!=="0px")ve=parseFloat(bt.borderRadius)||0;else if(J.firstElementChild){let Rt=window.getComputedStyle(J.firstElementChild);Rt.borderRadius&&Rt.borderRadius!=="0px"&&(ve=parseFloat(Rt.borderRadius)||0)}}catch{}let De=Et(S,"TTP");return Do("div",{style:{position:"relative",zIndex:De},children:[Qe&&u&&Do("svg",{style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",pointerEvents:"none",zIndex:De-1},children:[ne("defs",{children:Do("mask",{id:"as-spotlight-mask",children:[ne("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:"white"}),ne("rect",{x:u.left,y:u.top,width:u.width,height:u.height,rx:ve,ry:ve,fill:"black"})]})}),ne("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:Co,mask:"url(#as-spotlight-mask)",style:{pointerEvents:"none",cursor:"default"}})]}),Qe&&!u&&ne("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:Co,zIndex:De-1},onClick:ue}),Do("div",{ref:J=>{h.current=J,z(J)},onClick:J=>{J.stopPropagation(),J.target.tagName!=="BUTTON"&&vo()},style:{position:"fixed",top:Ie,left:ce,zIndex:De,backgroundColor:H.tooltip||"#FE6B35",padding:r?0:ol(A.padding),borderRadius:nl(A.cornerRadius,A.radius),boxShadow:"0 4px 12px rgba(0,0,0,0.15)",width:r?p:A.width?Math.min(A.width,Q-gt*2):"auto",height:r?j:void 0,maxWidth:Math.max(160,Q-gt*2),minWidth:r?void 0:Math.min(200,Q-gt*2),boxSizing:"border-box",transition:"top 0.2s ease, left 0.2s ease",cursor:"pointer"},children:[ne("div",{style:{position:"absolute",width:0,height:0,borderStyle:"solid",...k==="left"&&{left:-Z,top:Math.max(12,Math.min(g.height-V*2-12,rt+u.height/2-Ie-V)),borderWidth:`${V}px ${Z}px ${V}px 0`,borderColor:`transparent ${H.arrow||H.tooltip||"#FE6B35"} transparent transparent`},...k==="right"&&{right:-Z,top:Math.max(12,Math.min(g.height-V*2-12,rt+u.height/2-Ie-V)),borderWidth:`${V}px 0 ${V}px ${Z}px`,borderColor:`transparent transparent transparent ${H.arrow||H.tooltip||"#FE6B35"}`},...k==="top"&&{top:-Z,left:Math.max(12,Math.min(g.width-V*2-12,lt+u.width/2-ce-V)),borderWidth:`0 ${V}px ${Z}px ${V}px`,borderColor:`transparent transparent ${H.arrow||H.tooltip||"#FE6B35"} transparent`},...k==="bottom"&&{bottom:-Z,left:Math.max(12,Math.min(g.width-V*2-12,lt+u.width/2-ce-V)),borderWidth:`${Z}px ${V}px 0 ${V}px`,borderColor:`${H.arrow||H.tooltip||"#FE6B35"} transparent transparent transparent`}}}),x.url&&(r?ne("div",{style:{width:"100%",height:"100%",overflow:"hidden",borderRadius:`${A.cornerRadius?.topLeft??12}px ${A.cornerRadius?.topRight??12}px ${A.cornerRadius?.bottomRight??12}px ${A.cornerRadius?.bottomLeft??12}px`,cursor:"pointer"},children:ne("img",{src:x.url,alt:"tooltip media",style:{width:"100%",height:"100%",display:"block",objectFit:"cover",cursor:"pointer"}})}):ne("img",{src:x.url,alt:"tooltip media",style:{width:"100%",borderRadius:6,marginBottom:8,display:"block",objectFit:"cover",cursor:"pointer"}})),(x.titleText||x.subtitleText||x.ctaText)&&Do("div",{style:r?{padding:`${A.padding?.top??8}px ${A.padding?.right??8}px ${A.padding?.bottom??8}px ${A.padding?.left??8}px`}:void 0,children:[x.titleText&&ne("div",{style:{color:v.title?.color||"#ffffff",fontFamily:ut(v.title?.fontFamily)||"Arial",fontSize:v.title?.fontSize||14,textAlign:v.title?.textAlign||"center",marginBottom:v.title?.margin?.bottom??4,marginTop:v.title?.margin?.top??0,marginLeft:v.title?.margin?.left??0,marginRight:v.title?.margin?.right??0,fontWeight:v.title?.fontDecoration?.includes("bold")?"bold":600,fontStyle:v.title?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:v.title?.fontDecoration?.includes("underline")?"underline":"none"},children:x.titleText}),x.subtitleText&&ne("div",{style:{color:v.subTitle?.color||"#ffffff",fontFamily:ut(v.subTitle?.fontFamily)||"Arial",fontSize:v.subTitle?.fontSize||12,textAlign:v.subTitle?.textAlign||"center",marginBottom:v.subTitle?.margin?.bottom??8,marginTop:v.subTitle?.margin?.top??0,marginLeft:v.subTitle?.margin?.left??0,marginRight:v.subTitle?.margin?.right??0,fontWeight:v.subTitle?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:v.subTitle?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:v.subTitle?.fontDecoration?.includes("underline")?"underline":"none"},children:x.subtitleText}),x.ctaText&&ne("div",{style:{display:"flex",justifyContent:at.alignment==="right"?"flex-end":at.alignment==="left"?"flex-start":"center",marginTop:8},children:ne("button",{onClick:J=>{J.stopPropagation(),vo()},style:{width:at.ctaFullWidth?"100%":at.ctaWidth||"auto",height:at.height||35,background:at.backgroundColor||"#F7921C",color:F.color||"#ffffff",border:`${at.borderWidth||0}px solid ${at.borderColor||"transparent"}`,borderRadius:`${a.topLeft??7}px ${a.topRight??7}px ${a.bottomRight??7}px ${a.bottomLeft??7}px`,fontSize:F.fontSize||14,fontFamily:ut(F.fontFamily)||"Arial",fontWeight:F.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:F.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:F.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:x.ctaText})})]})]})]})},rl=il;import{useEffect as sl,useState as al,useRef as ll}from"react";vt();Vt();import{Fragment as cl,jsx as Se,jsxs as hi}from"react/jsx-runtime";var dl=()=>{let t=Mt("BTS"),e=W(h=>h.campaigns),o=W(h=>h.allCampaigns),n=W(h=>h.currentScreen),i=W(h=>h.userId),s=t??(()=>{let h=(n||"").trim().toLowerCase(),T=[...e||[],...o||[]].filter(I=>{if(!I||I.campaign_type!=="BTS"||!Ot(I,i))return!1;let S=!!(I.trigger_event??I.trigger);if(!(I.display_trigger!==!1&&!S))return!1;let x=(I.screen||"").trim().toLowerCase();return!x||x===h});if(T.length===0)return;let X=Lt(T)[0];if(X)try{return Kt(X)}catch{return X}})(),d=W(h=>h.isVisible),[c,l]=al(!1),y=ll(null);sl(()=>{s?.id&&y.current!==s.id&&(y.current=s.id,l(!1),st("viewed",s.id))},[s?.id]);let u=h=>{try{let T=W.getState(),X=(T.trackedEvents||[]).filter(I=>I!==h);T.setTrackedEvents(X)}catch{}},m=()=>{if(l(!0),s?.id){st("bottomsheet_closed",s.id);let h=[...e||[],...o||[]].find(E=>E?.id===s.id),T=h?.trigger_event??h?.trigger;T&&u(T)}};if(!s||c||!d)return null;let{details:f}=s,g=[...f.elements||[]].sort((h,T)=>(h.order||0)-(T.order||0)),b=f.backdropOpacity??.5;b>1&&(b=b/100);let R=h=>{switch(h.type){case"image":{let T={width:"100%",display:"block",objectFit:"contain",backgroundColor:h.imageBackgroundColor||"transparent",paddingBottom:h.paddingBottom??0,paddingLeft:h.paddingLeft??0,paddingRight:h.paddingRight??0,paddingTop:h.paddingTop??0,cursor:h.imageLink?"pointer":"default"};return Se("div",{style:{textAlign:h.alignment||"left",width:"100%"},children:h.url&&Se("img",{src:h.url,alt:"",style:T,onClick:()=>{if(h.imageLink){if(s?.id&&st("clicked",s.id),wt(h.imageLink)){m();return}try{let E=String(h.imageLink||"").trim();if(E&&!E.startsWith("http")&&qt(E))return}catch(E){console.warn("revealCampaignFromLink error",E)}try{window.open(h.imageLink,"_blank")}catch{}}}})},h.id)}case"cta":{let T=h.cta||{},E=T.container||{},X=T.cornerRadius||{},I=T.margin||{},S=T.text||{};return Se("div",{style:{display:"flex",justifyContent:E.alignment==="center"?"center":E.alignment==="right"?"flex-end":"flex-start",width:"100%",marginTop:I.top??0,marginBottom:I.bottom??0,marginLeft:I.left??0,marginRight:I.right??0},children:Se("button",{style:{width:E.ctaFullWidth?"100%":E.ctaWidth||"auto",height:E.height||45,backgroundColor:E.ctaBoxColor||E.backgroundColor||"#FE6B35",color:S.color||"#ffffff",border:`${E.borderWidth||0}px solid ${E.borderColor||"transparent"}`,borderRadius:`${X.topLeft??12}px ${X.topRight??12}px ${X.bottomRight??12}px ${X.bottomLeft??12}px`,fontSize:S.fontSize||14,fontFamily:ut(S.fontFamily)||"Arial",fontWeight:S.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:S.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:S.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px"},onClick:()=>{let M=h.ctaLink||h.url;if(M){if(s?.id&&st("clicked",s.id),wt(M)){m();return}try{let x=String(M||"").trim();if(x&&!x.startsWith("http")&&qt(x))return}catch(x){console.warn("revealCampaignFromLink error",x)}try{window.open(M,"_blank")}catch{}}},children:h.ctaText||"Button"})},h.id)}case"body":{let T=h.titleFontStyle||{},E=h.descriptionFontStyle||{};return hi("div",{style:{width:"100%",backgroundColor:h.bodyBackgroundColor||"transparent",marginTop:h.marginTop??0,marginBottom:h.marginBottom??20,marginLeft:h.marginLeft??4,marginRight:h.marginRight??4},children:[h.titleText&&Se("div",{style:{color:T.colour||"#000000",fontSize:T.fontSize?`${T.fontSize}px`:h.titleFontSize?`${h.titleFontSize}px`:"16px",fontFamily:ut(T.fontFamily)||"inherit",textAlign:T.alignment||"left",lineHeight:h.titleLineHeight||1.2,fontWeight:T.decoration?.includes("bold")?"bold":"600",fontStyle:T.decoration?.includes("italic")?"italic":"normal",textDecoration:T.decoration?.includes("underline")?"underline":"none",marginBottom:h.spacingBetweenTitleDesc??4},children:h.titleText}),h.descriptionText&&Se("div",{style:{color:E.colour||"#000000",fontSize:E.fontSize?`${E.fontSize}px`:h.descriptionFontSize?`${h.descriptionFontSize}px`:"14px",fontFamily:ut(E.fontFamily)||"inherit",textAlign:E.alignment||"left",lineHeight:h.descriptionLineHeight||1.5,fontWeight:E.decoration?.includes("bold")?"bold":"normal",fontStyle:E.decoration?.includes("italic")?"italic":"normal",textDecoration:E.decoration?.includes("underline")?"underline":"none"},children:h.descriptionText})]},h.id)}default:return null}},C=Et(s,"BTS");return hi(cl,{children:[Se("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:f.backdropColor||"rgba(0,0,0,0.5)",opacity:b,zIndex:C-1,transition:"opacity 0.3s ease"},onClick:()=>{s?.id&&u(`viaAppStorys${s.id}`),l(!0)}}),hi("div",{style:{position:"fixed",bottom:0,left:"50%",transform:"translateX(-50%)",width:"100%",maxWidth:"500px",backgroundColor:f.backgroundColor||"#FFFFFF",borderTopLeftRadius:`${f.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${f.cornerRadius?.topRight??16}px`,borderBottomLeftRadius:`${f.cornerRadius?.bottomLeft??0}px`,borderBottomRightRadius:`${f.cornerRadius?.bottomRight??0}px`,zIndex:C,padding:"24px 16px",boxShadow:"0 -4px 16px rgba(0,0,0,0.15)",maxHeight:"85vh",overflowY:"auto",display:"flex",flexDirection:"column",alignItems:"center",transition:"transform 0.3s ease-out"},children:[Se("div",{style:{width:"40px",height:"5px",backgroundColor:"#E0E0E0",borderRadius:"2.5px",marginBottom:"16px",cursor:"pointer"},onClick:()=>l(!0)}),f.crossButton?.enabled&&Se(Ut,{config:f.crossButton,onPress:()=>{s?.id&&u(`viaAppStorys${s.id}`),l(!0)},style:{top:f.crossButton?.margin?.top??12,right:f.crossButton?.margin?.right??12}}),Se("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:"12px"},children:g.map(R)})]})]})};import{useEffect as bn,useMemo as ul,useState as Ce,useRef as pl}from"react";vt();Vt();import*as po from"lottie-react";import{Fragment as Ci,jsx as kt,jsxs as $o}from"react/jsx-runtime";var gl=po.default?.default??po.default??po.Lottie??po,ss=5,bi=3;function hn(t){if(t!=null)return`${t}px`}function Zt(t,e="0px"){return t==null?e:`${t}px`}function uo(t){return{marginTop:hn(t?.top),marginRight:hn(t?.right),marginBottom:hn(t?.bottom),marginLeft:hn(t?.left)}}function vi(t){return ut(t)}function co(t){if(!t)return{};let e={};t.color&&(e.color=t.color),t.fontSize&&(e.fontSize=t.fontSize);let o=vi(t.fontFamily);return o&&(e.fontFamily=o),t.textAlign&&(e.textAlign=t.textAlign),t.fontDecoration?.includes("bold")&&(e.fontWeight="bold"),t.fontDecoration?.includes("italic")&&(e.fontStyle="italic"),t.fontDecoration?.includes("underline")&&(e.textDecoration="underline"),e}function xn(t){return`${t?.topLeft??8}px ${t?.topRight??8}px ${t?.bottomRight??8}px ${t?.bottomLeft??8}px`}function xi(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function fl(t){let e=t.styling?.rating?.ratingType;return e==="number"||e==="emoji"||e==="star"?e:"star"}function ml(t){let e=t.styling?.rating?.emoji,o=[];Array.isArray(e)?o=e:e&&typeof e=="object"?Array.isArray(e.values)?o=e.values:o=Object.values(e):typeof e=="string"&&e.trim()&&(o=e.split(","));let n=o.map(i=>{if(typeof i=="string")return i.trim();if(i&&typeof i=="object"){let s=i.emoji||i.value||i.text||i.icon||i.name||"";if(typeof s=="string")return s.trim()}return""}).filter(Boolean);return n.length>0?n:["\u{1F620}","\u{1F615}","\u{1F610}","\u{1F642}","\u{1F60D}"]}function yl(t){return Array.from({length:5},(e,o)=>o+1)}function Si(t){if(typeof t=="number"&&Number.isFinite(t)&&t>=0)return t;if(typeof t=="string"&&t.trim().length>0){let e=Number(t);if(Number.isFinite(e)&&e>=0)return e}}function hl(t){let e=t.styling?.rating||void 0,o=[e?.numberSpacing,e?.numberGap,e?.number_spacing,e?.number_gap,e?.spacingBetweenNumbers,e?.spaceBetweenNumbers,e?.numberOptionsSpacing,e?.spacing];for(let i of o){let s=Si(i);if(s!=null)return s}let n=e?.number;if(n&&typeof n=="object"){let i=n,s=[i.spacing,i.gap,i.optionsSpacing,i.numberSpacing,i.numberGap];for(let d of s){let c=Si(d);if(c!=null)return c}}return 8}var bl=({fill:t,stroke:e})=>kt("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":!0,children:kt("path",{d:"M12 2.25l2.91 5.89 6.5.95-4.7 4.58 1.11 6.46L12 17.03 6.18 20.13l1.11-6.46-4.7-4.58 6.5-.95L12 2.25z",fill:t,stroke:e,strokeWidth:"1.4",strokeLinejoin:"round"})}),xl=({details:t,appearance:e,rating:o,selectedOptions:n,comments:i,isHighRating:s,feedbackOptions:d,onRate:c,onToggleOption:l,onCommentChange:y,onInlineSubmit:u,canSubmit:m,isMobile:f})=>{let P=t.styling||{},g=P.feedbackPage||{},b=P.rating||{},R=P.initialFeedback||{},C=g.submitButton?.cta,h=fl(t),T=h==="number"?yl(t):[],E=h==="emoji"?ml(t):[],X=h==="number"?hl(t):8,I=h==="number"?X:b.spacing??8,S=f?"clamp(32px, 11vw, 44px)":"44px",M=f?"clamp(16px, 4.5vw, 22px)":22,x=xi(b.alignment),N=xn(b.cornerRadius),U=s?b.star?.high:b.star?.low,z=typeof b.number=="object"&&b.number?b.number:void 0,O=s?z?.high:z?.low,B=C?.container?.ctaFullWidth?"100%":Math.max(140,Si(C?.container?.ctaWidth)??180);return $o(Ci,{children:[kt("div",{style:uo(R.title?.margin),children:kt("div",{style:{...co(R.title?.textStyle),color:R.title?.textStyle?.color||"#101828",fontSize:R.title?.textStyle?.fontSize||20,lineHeight:1.3,wordBreak:"break-word",overflowWrap:"break-word",paddingRight:P.crossButton?.enabled?(P.crossButton.size??30)+(P.crossButton.margin?.right??4)+4:0},children:t.title||"How was your experience?"})}),kt("div",{style:uo(R.subtitle?.margin),children:kt("div",{style:{...co(R.subtitle?.textStyle),color:R.subtitle?.textStyle?.color||"#4b5563",fontSize:R.subtitle?.textStyle?.fontSize||14,lineHeight:1.4,wordBreak:"break-word",overflowWrap:"break-word"},children:t.description_text||"Your feedback helps us improve your experience."})}),$o("div",{style:{marginTop:8,display:"flex",justifyContent:x,gap:I,flexWrap:"wrap"},children:[h==="star"&&Array.from({length:ss},(K,v)=>{let A=v+1,H=A<=o,it=H?U?.stylingContainer:b.star?.unselected?.stylingContainer,at=H?U?.stylingStar:b.star?.unselected?.stylingStar;return kt("button",{onClick:()=>c(A),style:{border:`${it?.borderWidth??1}px solid ${it?.border||"#d1d5db"}`,background:it?.background||"#ffffff",borderRadius:N,width:S,height:S,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,flexShrink:0},"aria-label":`Rate ${A} out of ${ss}`,children:kt(bl,{fill:at?.background||(H?"#f59e0b":"#e5e7eb"),stroke:at?.border||(H?"#d97706":"#9ca3af")})},A)}),h==="number"&&T.map((K,v)=>{let A=K===o,H=A?O?.stylingContainer:z?.unselected?.stylingContainer,it=A?z?.stylingNumber:z?.unselected?.stylingNumber;return kt("button",{onClick:()=>c(K),style:{border:`${H?.borderWidth??1}px solid ${H?.border||(A?"#1d4ed8":"#d1d5db")}`,background:H?.fill||H?.background||(A?"#dbeafe":"#ffffff"),color:it?.text||(A?"#1d4ed8":"#111827"),fontSize:it?.textSize||void 0,borderRadius:N,minWidth:S,height:S,padding:"0 10px",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontWeight:600,flexShrink:0},"aria-label":`Rate ${K}`,children:K},`${K}-${v}`)}),h==="emoji"&&E.map((K,v)=>{let A=v+1,H=A===o,it=b.emoji,a=(H?it?.selected:it?.unselected)?.stylingContainer;return kt("button",{onClick:()=>c(A),style:{border:`${a?.borderWidth??1}px solid ${a?.border||(H?"#1d4ed8":"#d1d5db")}`,background:a?.fill||a?.background||(H?"#dbeafe":"#ffffff"),borderRadius:N,width:S,height:S,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:M,flexShrink:0},"aria-label":`Emoji rating ${v+1}`,children:K},`${K}-${v}`)})]}),o>0&&kt("div",{style:{marginTop:6,textAlign:"center",color:"#374151",fontSize:14},children:s?t.highStarText||b.highRatingSubtitle:t.lowStarText||b.lowRatingSubtitle}),o>0&&o<=bi&&$o(Ci,{children:[d.length>0&&kt("div",{style:{...uo(g.options?.margin),display:"flex",flexDirection:"column",alignItems:"stretch",gap:g.options?.optionsSpacing??8,width:"100%"},children:d.map(K=>{let A=n.includes(K)?g.options?.selectedOptions:g.options?.nonSelectedOptions;return kt("button",{onClick:()=>l(K),style:{border:`${A?.borderWidth??1}px solid ${A?.colors?.border||"#d1d5db"}`,background:A?.colors?.background||"#f9fafb",color:A?.colors?.text||"#111827",width:"100%",height:g.options?.optionsHeight||38,borderRadius:xn(g.options?.cornerRadius),padding:"0 14px",cursor:"pointer",textAlign:"center",...co(A?.textStyle)},children:K},K)})}),g.additionalComments?.enabled!==!1&&kt("textarea",{value:i,onChange:K=>y(K.target.value),placeholder:g.additionalComments?.placeholder||"Tell us what we can improve",style:{width:"100%",boxSizing:"border-box",minHeight:56,height:56,maxHeight:64,marginTop:8,resize:"none",overflowY:"auto",border:`${g.additionalComments?.borderWidth??1}px solid ${g.additionalComments?.colors?.border||"#d1d5db"}`,background:g.additionalComments?.colors?.background||"#ffffff",color:g.additionalComments?.colors?.text||"#111827",borderRadius:8,padding:"12px",...co(g.additionalComments?.textStyle)}}),kt("div",{style:{position:"sticky",bottom:0,marginTop:C?.margin?.top??8,marginBottom:C?.margin?.bottom??0,marginLeft:C?.margin?.left??0,marginRight:C?.margin?.right??0,paddingTop:6,paddingBottom:6,background:e?.backgroundColor||"#ffffff",display:"flex",justifyContent:xi(C?.container?.alignment)},children:kt("button",{onClick:()=>u(),disabled:!m,style:{width:B,maxWidth:"100%",height:Number(C?.container?.height)||40,border:`${C?.container?.borderWidth??0}px solid ${C?.container?.borderColor||"transparent"}`,background:C?.container?.backgroundColor||"#6848b1",color:C?.text?.color||"#ffffff",borderRadius:xn(C?.cornerRadius),fontFamily:vi(C?.text?.fontFamily),fontSize:Number(C?.text?.fontSize)||14,fontWeight:C?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:m?"pointer":"not-allowed",opacity:m?1:.65,padding:"0 12px",boxSizing:"border-box"},children:g.submitButton?.text||"Submit"})})]})]})},Sl=({details:t,isHighRating:e,onDone:o})=>{let n=t.styling||{},i=n.thankyouPage||{},s=n.rating||{},d=xi(i.doneButton?.cta?.container?.alignment),[c,l]=Ce(null),y=t.thankyouImage?.endsWith(".json");return bn(()=>{y&&t.thankyouImage&&fetch(t.thankyouImage).then(u=>u.json()).then(u=>l(u)).catch(u=>console.error("Error loading Lottie:",u))},[t.thankyouImage,y]),$o(Ci,{children:[t.thankyouImage&&kt("div",{style:{display:"flex",justifyContent:"center",...uo(i.imageStyle?.margin)},children:y?c?kt(gl,{animationData:c,loop:!0,style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80}}):kt("div",{style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80}}):kt("img",{src:t.thankyouImage,alt:"thank you",style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80,objectFit:"cover",borderRadius:8}})}),kt("div",{style:uo(i.title?.margin),children:kt("div",{style:{color:"#111827",fontSize:20,lineHeight:1.3,...co(i.title?.textStyle),wordBreak:"break-word",overflowWrap:"break-word"},children:t.thankyouText||(e?s.highRatingTitle:s.lowRatingTitle)||"Thank you for your feedback"})}),kt("div",{style:uo(i.subtitle?.margin),children:kt("div",{style:{color:"#4b5563",fontSize:14,lineHeight:1.4,...co(i.subtitle?.textStyle),wordBreak:"break-word",overflowWrap:"break-word"},children:t.thankyouDescription||(e?s.highRatingSubtitle:s.lowRatingSubtitle)||"We appreciate your time."})}),kt("div",{style:{marginTop:i.doneButton?.cta?.margin?.top??14,marginBottom:i.doneButton?.cta?.margin?.bottom??0,marginLeft:i.doneButton?.cta?.margin?.left??0,marginRight:i.doneButton?.cta?.margin?.right??0,display:"flex",justifyContent:d},children:kt("button",{onClick:o,style:{width:i.doneButton?.cta?.container?.ctaFullWidth?"100%":i.doneButton?.cta?.container?.ctaWidth||"auto",height:i.doneButton?.cta?.container?.height||45,border:`${i.doneButton?.cta?.container?.borderWidth??0}px solid ${i.doneButton?.cta?.container?.borderColor||"transparent"}`,background:i.doneButton?.cta?.container?.backgroundColor||"#111827",color:i.doneButton?.cta?.text?.color||"#ffffff",borderRadius:xn(i.doneButton?.cta?.cornerRadius),fontFamily:vi(i.doneButton?.cta?.text?.fontFamily),fontSize:i.doneButton?.cta?.text?.fontSize||16,fontWeight:i.doneButton?.cta?.text?.fontDecoration?.includes("bold")?"bold":"normal",cursor:"pointer",padding:"0 16px",boxSizing:"border-box"},children:e?t.highStarText||i.doneButton?.text||"Rate Now":t.lowStarText||i.doneButton?.text||"Done"})})]})},Cl=()=>{let t=Mt("CSAT"),e=W(r=>r.isVisible),o=W(r=>r.campaigns),n=W(r=>r.allCampaigns),i=W(r=>r.currentScreen),s=W(r=>r.userId),[d,c]=Ce(typeof window<"u"?window.innerWidth:1024);bn(()=>{if(typeof window>"u")return;let r=()=>c(window.innerWidth);return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]);let l=d<768,y=t??(()=>{let r=(i||"").trim().toLowerCase(),p=[...o||[],...n||[]].filter(G=>{if(!G||G.campaign_type!=="CSAT"||!Ot(G,s))return!1;let V=!!(G.trigger_event??G.trigger);if(!(G.display_trigger!==!1&&!V))return!1;let lt=(G.screen||"").trim().toLowerCase();return!lt||lt===r});if(p.length===0)return;let k=Lt(p)[0];if(k)try{return Kt(k)}catch{return k}})(),[u,m]=Ce(!1),[f,P]=Ce(!1),[g,b]=Ce(!1),[R,C]=Ce(!1),[h,T]=Ce(0),[E,X]=Ce([]),[I,S]=Ce(""),[M,x]=Ce(!1),N=pl(null);bn(()=>{if(!y?.id||N.current===y.id)return;N.current=y.id,m(!1),P(!1),b(!1),C(!1),T(0),X([]),S(""),x(!1);let r=y.details?.styling?.appearance?.displayDelay??0,p=globalThis.setTimeout(()=>{P(!0),st("viewed",y.id)},Math.max(0,r)*1e3);return()=>globalThis.clearTimeout(p)},[y?.id]),bn(()=>{if(f){let r=setTimeout(()=>b(!0),30);return()=>clearTimeout(r)}},[f]);let U=ul(()=>{let r=y?.details?.feedback_option||{};return Object.keys(r).sort((p,j)=>p.localeCompare(j)).map(p=>typeof r[p]=="string"?r[p].trim():r[p]).filter(Boolean)},[y]);if(!y||!e||u||!f)return null;let z=y.details,O=z.styling||{},B=O.appearance||{},K=h>bi,v=r=>{X(p=>p.includes(r)?p.filter(j=>j!==r):[...p,r])},A=async r=>{let p=r?.rating??h;if(p<1)return;x(!0);let j=y.id,k=(r?.options??E)[0]||"",G=r?.comments??I??"";st("csat captured",j,{starCount:p,selectedOption:k,additionalComments:G})},H=r=>{if(T(r),r>bi){X([]),S("");let p=y?.id;setTimeout(()=>{x(!0);try{st("csat captured",p,{starCount:r,selectedOption:"",additionalComments:""})}catch(j){console.warn("Error sending csat captured",j)}},1e3)}},it=async()=>{C(!0);try{let r=y?.id;await st("csat closed",r)}catch(r){console.warn("Error sending csat closed",r)}finally{setTimeout(()=>{m(!0)},300)}},at=()=>{if(K&&z.link){let r=y&&y.id||void 0;try{r&&st("clicked",r)}catch{}try{let p=String(z.link||"").trim();if(wt(p)){C(!0),setTimeout(()=>{m(!0)},300);return}if(p&&!p.startsWith("http")&&qt(p)){C(!0),setTimeout(()=>{m(!0)},300);return}}catch(p){console.warn("revealCampaignFromLink error",p)}try{globalThis.open(z.link,"_blank")}catch{}}C(!0),setTimeout(()=>{m(!0)},300)},a=l?{position:"fixed",inset:0,zIndex:Et(y,"CSAT"),display:"flex",justifyContent:"center",alignItems:"flex-end",paddingLeft:Zt(B.margin?.left,"0px"),paddingRight:Zt(B.margin?.right,"0px"),pointerEvents:"none"}:{position:"fixed",inset:0,zIndex:Et(y,"CSAT"),display:"flex",justifyContent:"flex-end",alignItems:"flex-end",paddingTop:Zt(B.margin?.top),paddingRight:Zt(B.margin?.right,"20px"),paddingBottom:Zt(B.margin?.bottom,"20px"),paddingLeft:Zt(B.margin?.left,"20px"),pointerEvents:"none"},F=l?{position:"relative",width:"100%",maxWidth:"none",maxHeight:"85vh",overflow:"visible",backgroundColor:B.backgroundColor||"#ffffff",borderTopLeftRadius:`${B.borderRadius??16}px`,borderTopRightRadius:`${B.borderRadius??16}px`,borderBottomLeftRadius:0,borderBottomRightRadius:0,boxSizing:"border-box",paddingTop:Zt(B.padding?.top,"12px"),paddingRight:Zt(B.padding?.right,"16px"),paddingBottom:`max(${Zt(B.padding?.bottom,"16px")}, env(safe-area-inset-bottom, 16px))`,paddingLeft:Zt(B.padding?.left,"16px"),pointerEvents:"auto",boxShadow:"0 -8px 32px rgba(0, 0, 0, 0.20)",display:"flex",flexDirection:"column",transform:R||!g?"translateY(100%)":"translateY(0)",transition:"transform 0.3s cubic-bezier(0.25, 1, 0.5, 1)"}:{position:"relative",width:"min(450px, 92vw)",maxHeight:"85vh",overflow:"visible",backgroundColor:B.backgroundColor||"#ffffff",borderRadius:`${B.borderRadius??12}px`,boxSizing:"border-box",paddingTop:Zt(B.padding?.top,"8px"),paddingRight:Zt(B.padding?.right,"12px"),paddingBottom:Zt(B.padding?.bottom,"8px"),paddingLeft:Zt(B.padding?.left,"12px"),pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column",transform:R||!g?"translateY(100%)":"translateY(0)",transition:"transform 0.3s cubic-bezier(0.25, 1, 0.5, 1)"};return kt("div",{style:a,children:$o("div",{style:F,children:[kt("style",{children:`
129
129
  .appstorys-csat-scroll {
130
130
  scrollbar-width: none; /* Firefox */
131
131
  -ms-overflow-style: none; /* IE/Edge */
@@ -135,7 +135,7 @@ var ls=Object.defineProperty;var Me=(t,e)=>()=>(t&&(e=t(t=0)),e);var ds=(t,e)=>{
135
135
  height: 0;
136
136
  display: none; /* Chrome/Safari */
137
137
  }
138
- `}),T.crossButton?.enabled&&bt(Dt,{config:T.crossButton,onPress:()=>{r()},style:{top:T.crossButton?.margin?.top??10,right:T.crossButton?.margin?.right??10}}),bt("div",{className:"appstorys-csat-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:4},children:w?bt(tl,{details:A,isHighRating:B,onDone:M}):bt(Za,{details:A,rating:m,selectedOptions:O,comments:L,isHighRating:B,feedbackOptions:V,onRate:Y,onToggleOption:W,onCommentChange:v,onInlineSubmit:H,canSubmit:m>=1,appearance:k,isMobile:c})})]})})},ol=el;import{useEffect as to,useMemo as Gr,useState as Gt,useRef as Ze}from"react";yt();import*as oo from"lottie-react";import{Fragment as ui,jsx as ft,jsxs as Te}from"react/jsx-runtime";var nl=oo.default?.default??oo.default??oo.Lottie??oo;function ln(t){if(t!=null)return`${t}px`}function dn(t){return st(t)}function eo(t){if(!t)return{};let e={};t.color&&(e.color=t.color),t.fontSize&&(e.fontSize=t.fontSize);let o=dn(t.fontFamily);return o&&(e.fontFamily=o),t.textAlign&&(e.textAlign=t.textAlign),t.fontDecoration?.includes("bold")&&(e.fontWeight="bold"),t.fontDecoration?.includes("italic")&&(e.fontStyle="italic"),t.fontDecoration?.includes("underline")&&(e.textDecoration="underline"),e}function To(t){return{marginTop:ln(t?.top),marginRight:ln(t?.right),marginBottom:ln(t?.bottom),marginLeft:ln(t?.left)}}function zo(t,e=0){if(!t)return`${e}px`;let o=t.topLeft!==void 0&&t.topLeft!==null?t.topLeft:e,n=t.topRight!==void 0&&t.topRight!==null?t.topRight:e,i=t.bottomRight!==void 0&&t.bottomRight!==null?t.bottomRight:e,s=t.bottomLeft!==void 0&&t.bottomLeft!==null?t.bottomLeft:e;return`${o}px ${n}px ${i}px ${s}px`}function Qr(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function Io(t){return Math.max(0,Math.min(1,t))}function qr(t,e){let o=(t||"").trim().replace("#","");if(o.length===3){let n=Number.parseInt(o[0]+o[0],16),i=Number.parseInt(o[1]+o[1],16),s=Number.parseInt(o[2]+o[2],16);return`rgba(${n}, ${i}, ${s}, ${Io(e)})`}if(o.length===6){let n=Number.parseInt(o.slice(0,2),16),i=Number.parseInt(o.slice(2,4),16),s=Number.parseInt(o.slice(4,6),16);return`rgba(${n}, ${i}, ${s}, ${Io(e)})`}return`rgba(0, 0, 0, ${Io(e)})`}function il(t){if(t==null)return .4;let e=Number(t);return Number.isFinite(e)?e>1?Io(e/100):Io(e):.4}function Hr(t){return[...t.slides||[]].sort((o,n)=>(o.order??0)-(n.order??0))}function rl(t,e){let o=t.trim();if(!o)return{action:"none"};let n=o.toLowerCase().replace(/[\s_-]+/g,"");if(n==="thankyou"||n==="thankyoupage")return{action:"thankyou"};let i=/^question\s+(\d+)$/i.exec(o);if(i){let d=parseInt(i[1],10)-1;return d>=0&&d<e.length?{action:"jump",targetIndex:d}:{action:"none"}}let s=e.findIndex(c=>c.id===o);if(s!==-1)return{action:"jump",targetIndex:s};let l=Number(o);if(Number.isFinite(l)&&l>0){let c=e.findIndex(d=>d.order===l);if(c!==-1)return{action:"jump",targetIndex:c}}return{action:"none"}}function sl(t){let e=t?.options||{},o=Object.keys(e),n=i=>{let s=/(\d+)/.exec(i);if(!s)return;let l=Number(s[1]);return Number.isFinite(l)?l:void 0};return o.sort((i,s)=>{let l=n(i),c=n(s);return l!=null&&c!=null?l-c:l!=null?-1:c!=null?1:i.localeCompare(s)}),o.map(i=>e[i]).filter(i=>typeof i=="string"&&i.trim().length>0)}function al(t,e){if(!t)return null;if(t==="alphabet"){let o="a".codePointAt(0)??97;return String.fromCodePoint(o+e%26)+"."}return t==="number"?String(e+1)+".":t==="roman"?(["i","ii","iii","iv","v","vi","vii","viii","ix","x","xi","xii","xiii","xiv","xv"][e]||String(e+1))+".":null}function ll(t){if(typeof t=="number"&&Number.isFinite(t)&&t>=0)return t;if(typeof t=="string"&&t.trim().length>0){let e=Number(t);if(Number.isFinite(e)&&e>=0)return e}}function Vr(t){return ll(t?.borderwidth)??1}var Ur=({details:t,slide:e,appearance:o,selectedOptions:n,comment:i,onSelectOption:s,onCommentChange:l,onSubmit:c,canSubmit:d})=>{let S=t.styling||{},p=S.options||{},y=S.cta,u=Gr(()=>sl(e),[e]),C=p.optionsSpacing??6,h=p.bulletSpacing??12,g=p.optionsHeight??48,b=Qr(y?.container?.alignment),m=S.title?.textStyle,E=S.subtitle?.textStyle;return Te(ui,{children:[ft("div",{style:{width:"100%",...To(m?.margin)},children:ft("div",{style:{...eo(m),color:m?.color||"#111827",fontSize:m?.fontSize||22,lineHeight:1.3,textAlign:m?.textAlign||"left",fontWeight:m?.fontDecoration?.includes("bold")?"bold":m?.fontDecoration?"normal":600,fontStyle:m?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:m?.fontDecoration?.includes("underline")?"underline":"none"},children:e.title||e.question||t.name||"Survey"})}),(e.subtitle||E)&&ft("div",{style:{width:"100%",...To(E?.margin)},children:ft("div",{style:{...eo(E),color:E?.color||"#6b7280",fontSize:E?.fontSize||16,lineHeight:1.35,textAlign:E?.textAlign||"left",fontWeight:E?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:E?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:E?.fontDecoration?.includes("underline")?"underline":"none"},children:e.subtitle||""})}),u.length>0&&(()=>{let O="__others__",D=e.additionalComment?.placeholder?.trim()||"Others",L=u.map(w=>({value:w,label:w}));e.additionalComment?.enabled&&L.push({value:O,label:D});let v=n.includes(O);return Te(ui,{children:[ft("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:C},children:L.map(({value:w,label:_},$)=>{let V=n.includes(w),A=V?p.selectedOptions:p.nonSelectedOptions,T=Vr(A?.textStyle),k=al(p.optionListStyle,$),B=p.optionListStyle,W=B==="bulleted",H=B==="number"||B==="alphabet"||B==="roman",Y=A?.colors?.text||A?.textStyle?.color||(V?"#ffffff":"#111827"),r=A?.colors?.background||(V?"#1f35db":"#ffffff"),M=A?.colors?.border||(V?"#1f35db":"#e5e7eb");return Te("button",{onClick:()=>s(w),style:{width:"100%",boxSizing:"border-box",minHeight:g,height:"auto",borderRadius:zo(p.cornerRadius,7),border:`${T}px solid ${M}`,background:r,color:Y,cursor:"pointer",display:"flex",alignItems:"center",gap:h,paddingTop:8,paddingBottom:8,paddingLeft:14,paddingRight:14,textAlign:A?.textStyle?.textAlign||"left",...eo(A?.textStyle)},"aria-pressed":V,children:[W?ft("span",{"aria-hidden":!0,style:{width:18,height:18,borderRadius:"50%",border:`2px solid ${V?p.selectedOptions?.colors?.border||M:p.nonSelectedOptions?.colors?.border||M}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:V&&ft("span",{style:{width:10,height:10,borderRadius:"50%",backgroundColor:Y}})}):H?ft("span",{"aria-hidden":!0,style:{fontSize:A?.textStyle?.fontSize?A.textStyle.fontSize*.85:16,fontWeight:A?.textStyle?.fontDecoration?.includes("bold")?"bold":600,fontFamily:dn(A?.textStyle?.fontFamily),color:Y,marginRight:2,flexShrink:0},children:k}):null,ft("span",{style:{flex:1,minWidth:0,wordBreak:"break-word",lineHeight:1.35,color:Y},children:_})]},`${w}-${$}`)})}),v&&ft("textarea",{value:i,onChange:w=>l(w.target.value),placeholder:e.additionalComment?.placeholder||"Type your response...",style:{marginTop:10,width:"100%",boxSizing:"border-box",minHeight:72,resize:"none",overflowY:"auto",border:`${Vr(p.additionalComments?.textStyle)}px solid ${p.additionalComments?.colors?.border||"#e5e7eb"}`,background:p.additionalComments?.colors?.background||"#ffffff",color:p.additionalComments?.colors?.text||"#111827",borderRadius:zo(p.cornerRadius,7),padding:"12px",...eo(p.additionalComments?.textStyle)}})]})})(),ft("div",{style:{position:"sticky",bottom:0,marginTop:y?.margin?.top??12,marginBottom:y?.margin?.bottom??0,marginLeft:y?.margin?.left??0,marginRight:y?.margin?.right??0,paddingTop:10,paddingBottom:4,background:o?.backgroundColor||"#ffffff",display:"flex",justifyContent:b,width:"100%",boxSizing:"border-box"},children:ft("button",{onClick:c,disabled:!d,style:{width:y?.container?.ctaFullWidth?"100%":y?.container?.ctaWidth?`${y.container.ctaWidth}px`:"140px",maxWidth:"100%",height:y?.container?.height??50,border:`${y?.container?.borderWidth??0}px solid ${y?.container?.borderColor||"transparent"}`,background:y?.container?.backgroundColor||"#1f35db",color:y?.text?.color||"#ffffff",borderRadius:zo(y?.cornerRadius,7),fontFamily:dn(y?.text?.fontFamily)||"Arial",fontSize:y?.text?.fontSize||18,fontWeight:y?.text?.fontDecoration?.includes("bold")?"bold":600,fontStyle:y?.text?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:y?.text?.fontDecoration?.includes("underline")?"underline":"none",cursor:d?"pointer":"not-allowed",opacity:d?1:.6,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 20px",boxSizing:"border-box"},children:e.submitButtonText||"Submit"})})]})},Yr=({details:t,onDone:e})=>{let o=t.styling||{},n=o.thankyouPage||{},i=n.cta||o.cta,s=Qr(i?.container?.alignment),l=t.thankYouImage?.endsWith(".json"),[c,d]=Gt(null);to(()=>{l&&t.thankYouImage?fetch(t.thankYouImage).then(u=>u.json()).then(u=>d(u)).catch(u=>console.error("AppStorys Survey: Error loading Thank You Lottie:",u)):d(null)},[t.thankYouImage,l]);let S=t.thankYouTitle||t?.thank_you_title||"Thank you",p=t.thankYouText||t?.thank_you_text||"",y=t.thankYouButtonText||t?.thank_you_button_text||"Done";return Te(ui,{children:[t.thankYouImage&&ft("div",{style:{display:"flex",justifyContent:"center",...To(n.imageStyle?.margin)},children:l?c?ft(nl,{animationData:c,loop:!0,style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80}}):ft("div",{style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80}}):ft("img",{src:t.thankYouImage,alt:"thank you",style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80,objectFit:"cover",borderRadius:10}})}),ft("div",{style:{width:"100%",...To(n.title?.textStyle?.margin)},children:ft("div",{style:{...eo(n.title?.textStyle),color:n.title?.textStyle?.color||"#111827",fontSize:n.title?.textStyle?.fontSize||20,lineHeight:1.3,textAlign:n.title?.textStyle?.textAlign||"center",fontWeight:n.title?.textStyle?.fontDecoration?.includes("bold")?"bold":n.title?.textStyle?.fontDecoration?.length?"normal":700},children:S})}),p&&ft("div",{style:{width:"100%",...To(n.subtitle?.textStyle?.margin)},children:ft("div",{style:{...eo(n.subtitle?.textStyle),color:n.subtitle?.textStyle?.color||"#6b7280",fontSize:n.subtitle?.textStyle?.fontSize||14,lineHeight:1.35,textAlign:n.subtitle?.textStyle?.textAlign||"center",fontWeight:n.subtitle?.textStyle?.fontDecoration?.includes("bold")?"bold":"normal"},children:p})}),(y||i)&&ft("div",{style:{marginTop:i?.margin?.top??14,marginBottom:i?.margin?.bottom??0,marginLeft:i?.margin?.left??0,marginRight:i?.margin?.right??0,display:"flex",justifyContent:s,width:"100%",boxSizing:"border-box"},children:ft("button",{onClick:e,style:{width:i?.container?.ctaFullWidth?"100%":i?.container?.ctaWidth?`${i.container.ctaWidth}px`:"auto",maxWidth:"100%",height:i?.container?.height??44,border:`${i?.container?.borderWidth??0}px solid ${i?.container?.borderColor||"transparent"}`,background:i?.container?.backgroundColor||"#1f35db",color:i?.text?.color||"#ffffff",borderRadius:zo(i?.cornerRadius,12),fontFamily:dn(i?.text?.fontFamily)||"Arial",fontSize:i?.text?.fontSize||14,fontWeight:i?.text?.fontDecoration?.includes("bold")?"bold":600,fontStyle:i?.text?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:i?.text?.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",padding:"0 20px",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:y})})]})},dl=()=>{let t=At("SUR"),e=P(R=>R.isVisible),o=P(R=>R.campaigns),n=P(R=>R.allCampaigns),i=P(R=>R.currentScreen),[s,l]=Gt(typeof window<"u"?window.innerWidth:1024),[c,d]=Gt(0),[S,p]=Gt(!1),[y,u]=Gt(!1),[C,h]=Gt(!1),g=Ze(0),b=Ze(0),m=Ze(null),E=Ze(0),O=Ze(!1);to(()=>{if(typeof window>"u")return;let R=()=>l(window.innerWidth);return window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[]);let D=s<768,L=t??(()=>{let R=(i||"").trim().toLowerCase(),I=[...o||[],...n||[]].find(N=>{if(!N||N.campaign_type!=="SUR")return!1;let Z=!!(N.trigger_event??N.trigger);if(!(N.display_trigger!==!1&&!Z))return!1;let Ft=(N.screen||"").trim().toLowerCase();return!Ft||Ft===R});if(I)try{return Nt(I)}catch{return I}})(),[v,w]=Gt(!1),[_,$]=Gt(!1),[V,A]=Gt(0),[T,k]=Gt([]),[B,W]=Gt(""),[H,Y]=Gt({}),[r,M]=Gt(!1),a=Ze(null);to(()=>{if(!L?.id||a.current===L.id)return;a.current=L.id,w(!1),$(!1),A(0),k([]),W(""),Y({}),M(!1),h(!1),u(!1),d(0);let R=L.details?.styling?.appearance?.displayDelay??0,I=globalThis.setTimeout(()=>{$(!0);let N=L.details?.id,Z=Hr(L.details),xt=Z.length>0?Z[0].id:void 0;rt("viewed",L.id,{survey_id:N,slide_id:xt})},Math.max(0,R)*1e3);return()=>globalThis.clearTimeout(I)},[L?.id]),to(()=>{if(_){let R=setTimeout(()=>h(!0),30);return()=>clearTimeout(R)}},[_]);let f=Gr(()=>L?Hr(L.details):[],[L]),x=f[V];to(()=>{if(typeof window>"u"||!L||!e||v||!_)return;let R=window.scrollY||window.pageYOffset||0,I=document.body.style.position,N=document.body.style.top,Z=document.body.style.left,xt=document.body.style.right,Ft=document.body.style.width,kt=document.body.style.overflow,Wt=document.documentElement.style.overflow;return document.body.style.position="fixed",document.body.style.top=`-${R}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%",document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",()=>{document.body.style.position=I,document.body.style.top=N,document.body.style.left=Z,document.body.style.right=xt,document.body.style.width=Ft,document.body.style.overflow=kt,document.documentElement.style.overflow=Wt,window.scrollTo(0,R)}},[L,e,v,_]);let z=(R,I)=>{g.current=R,b.current=0,O.current=I,m.current?E.current=m.current.scrollTop:E.current=0,p(!0)},U=R=>{if(!g.current)return;let I=R-g.current,N=m.current?m.current.scrollTop:0,Z=E.current<=0&&N<=0;(O.current||Z)&&I>0?(b.current=I,d(I)):(b.current=0,d(0))},et=()=>{p(!1),O.current=!1,b.current>80?(u(!0),setTimeout(()=>{gt()},250)):(d(0),b.current=0),g.current=0};if(to(()=>{if(!S)return;let R=xt=>{U(xt.clientY)},I=()=>{et()},N=xt=>{xt.cancelable&&xt.preventDefault(),xt.touches&&xt.touches[0]&&U(xt.touches[0].clientY)},Z=()=>{et()};return window.addEventListener("pointermove",R),window.addEventListener("pointerup",I),window.addEventListener("touchmove",N,{passive:!1}),window.addEventListener("touchend",Z),()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",I),window.removeEventListener("touchmove",N),window.removeEventListener("touchend",Z)}},[S]),!L||!e||v||!_)return null;let X=L.details,q=X.styling||{},J=q.appearance||{},nt=J.backdropColor||"#000000",ht=il(J.backdropOpacity),dt=x?.multipleSelection!==!1&&x?.isMultiSelect!==!1&&q.options?.multipleSelection!==!1,K=R=>{k(dt?I=>I.includes(R)?I.filter(N=>N!==R):[...I,R]:I=>I[0]===R?[]:[R])},it=async(R,I)=>{let N=f.map(Bt=>({slide_id:Bt.id,order:Bt.order,title:Bt.title,question:Bt.question,selected_options:R[Bt.id]?.options,comment:R[Bt.id]?.comment})),Z=L.id,xt=[];for(let Bt of f){let Ht=R[Bt.id]?.options||[];for(let Tt of Ht){let Kt=Object.entries(Bt.options||{}).find(([,ne])=>String(ne)===String(Tt));Kt&&xt.push(Kt[0])}}let Ft=N.map(Bt=>Bt.comment).filter(Boolean).join(" || ")||"",kt=X.id||Z;rt("survey captured",kt,{survey_id:X.id,slide_id:I,selected_options:xt,otherText:Ft}),q.content?.isThankyouPage!==!1?M(!0):w(!0)},lt=async()=>{if(!x||T.length===0)return;let R={...H,[x.id]:{options:T,comment:B}};Y(R);let I=[];if(x.options)for(let Ft of T){let kt=Object.entries(x.options).find(([,Wt])=>String(Wt)===String(Ft));kt&&I.push(kt[0])}try{let Ft=L.id,kt=X.id||Ft;rt("survey captured",kt,{survey_id:X.id,slide_id:x.id,selected_options:I,otherText:B||""})}catch(Ft){console.warn("Error sending per-slide survey captured",Ft)}let N=T.includes("__others__"),Z={action:"none"};for(let Ft of x.logic||[]){let kt=Ft.selectOption||[];if(kt.length===0)continue;let Wt=kt.some(Tt=>I.includes(Tt)),Bt=kt.some(Tt=>T.includes(Tt)),Ht=N&&kt.some(Tt=>Tt==="others"||Tt==="__others__");if(!(!Wt&&!Bt&&!Ht)&&Ft.redirectTo){let Tt=rl(Ft.redirectTo,f);if(Tt.action!=="none"){Z=Tt;break}}}if(Z.action==="thankyou"){await it(R,x.id);return}if(Z.action==="jump"){A(Z.targetIndex);return}if(V>=f.length-1){await it(R,x.id);return}A(Ft=>Math.min(Ft+1,f.length-1))},mt=()=>{let R=X.thankYouButtonConfig;if(R?.enabled&&R.redirectUrl){try{let I=String(R.redirectUrl||"").trim();if(I&&!I.startsWith("http")&&Pt(I)){w(!0);return}}catch(I){console.warn("revealCampaignFromLink error",I)}try{globalThis.open(R.redirectUrl,"_blank")}catch{}}w(!0)},gt=async()=>{try{let R=L?.id,I=X?.id,N=x?.id;await rt("SurveyDismissed",R,{survey_id:I,slide_id:N})}catch(R){console.warn("Error sending SurveyDismissed",R)}finally{w(!0)}};return x?D?Te("div",{style:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"center",alignItems:"flex-end",padding:0,boxSizing:"border-box",pointerEvents:"auto",touchAction:"none",overscrollBehavior:"none"},children:[ft("div",{"aria-hidden":!0,onClick:()=>{u(!0),setTimeout(()=>gt(),250)},onTouchMove:R=>{R.cancelable&&R.preventDefault()},style:{position:"absolute",inset:0,background:qr(nt,y?0:ht),transition:S?"none":"background 0.25s ease-out",zIndex:1,touchAction:"none"}}),Te("div",{onPointerDown:R=>{let I=R.target;I&&I.closest("button, input, textarea, a")||z(R.clientY,!1)},onTouchStart:R=>{let I=R.target;I&&I.closest("button, input, textarea, a")||R.touches&&R.touches[0]&&z(R.touches[0].clientY,!1)},style:{position:"relative",zIndex:2,width:"100%",maxWidth:"520px",maxHeight:"85vh",backgroundColor:J.backgroundColor||"#ffffff",borderTopLeftRadius:`${J.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${J.cornerRadius?.topRight??16}px`,borderBottomLeftRadius:0,borderBottomRightRadius:0,boxSizing:"border-box",paddingTop:10,paddingRight:16,paddingBottom:"max(14px, env(safe-area-inset-bottom, 14px))",paddingLeft:16,boxShadow:"0 -8px 32px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column",overflow:"hidden",touchAction:"none",overscrollBehavior:"contain",transform:y?"translateY(100%)":C?`translateY(${c}px)`:"translateY(100%)",transition:S?"none":"transform 0.28s cubic-bezier(0.25, 1, 0.5, 1)"},children:[ft("style",{children:`
138
+ `}),O.crossButton?.enabled&&kt(Ut,{config:O.crossButton,onPress:()=>{it()},style:{top:O.crossButton?.margin?.top??10,right:O.crossButton?.margin?.right??10}}),kt("div",{className:"appstorys-csat-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:4},children:M?kt(Sl,{details:z,isHighRating:K,onDone:at}):kt(xl,{details:z,rating:h,selectedOptions:E,comments:I,isHighRating:K,feedbackOptions:U,onRate:H,onToggleOption:v,onCommentChange:S,onInlineSubmit:A,canSubmit:h>=1,appearance:B,isMobile:l})})]})})},vl=Cl;import{useEffect as fo,useMemo as ps,useState as ie,useRef as go}from"react";vt();Vt();import*as yo from"lottie-react";import{Fragment as wi,jsx as St,jsxs as _e}from"react/jsx-runtime";var wl=yo.default?.default??yo.default??yo.Lottie??yo;function Sn(t){if(t!=null)return`${t}px`}function Cn(t){return ut(t)}function mo(t){if(!t)return{};let e={};t.color&&(e.color=t.color),t.fontSize&&(e.fontSize=t.fontSize);let o=Cn(t.fontFamily);return o&&(e.fontFamily=o),t.textAlign&&(e.textAlign=t.textAlign),t.fontDecoration?.includes("bold")&&(e.fontWeight="bold"),t.fontDecoration?.includes("italic")&&(e.fontStyle="italic"),t.fontDecoration?.includes("underline")&&(e.textDecoration="underline"),e}function No(t){return{marginTop:Sn(t?.top),marginRight:Sn(t?.right),marginBottom:Sn(t?.bottom),marginLeft:Sn(t?.left)}}function Oo(t,e=0){if(!t)return`${e}px`;let o=t.topLeft!==void 0&&t.topLeft!==null?t.topLeft:e,n=t.topRight!==void 0&&t.topRight!==null?t.topRight:e,i=t.bottomRight!==void 0&&t.bottomRight!==null?t.bottomRight:e,s=t.bottomLeft!==void 0&&t.bottomLeft!==null?t.bottomLeft:e;return`${o}px ${n}px ${i}px ${s}px`}function gs(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function jo(t){return Math.max(0,Math.min(1,t))}function as(t,e){let o=(t||"").trim().replace("#","");if(o.length===3){let n=Number.parseInt(o[0]+o[0],16),i=Number.parseInt(o[1]+o[1],16),s=Number.parseInt(o[2]+o[2],16);return`rgba(${n}, ${i}, ${s}, ${jo(e)})`}if(o.length===6){let n=Number.parseInt(o.slice(0,2),16),i=Number.parseInt(o.slice(2,4),16),s=Number.parseInt(o.slice(4,6),16);return`rgba(${n}, ${i}, ${s}, ${jo(e)})`}return`rgba(0, 0, 0, ${jo(e)})`}function kl(t){if(t==null)return .4;let e=Number(t);return Number.isFinite(e)?e>1?jo(e/100):jo(e):.4}function ls(t){return[...t.slides||[]].sort((o,n)=>(o.order??0)-(n.order??0))}function Rl(t,e){let o=t.trim();if(!o)return{action:"none"};let n=o.toLowerCase().replace(/[\s_-]+/g,"");if(n==="thankyou"||n==="thankyoupage")return{action:"thankyou"};let i=/^question\s+(\d+)$/i.exec(o);if(i){let l=parseInt(i[1],10)-1;return l>=0&&l<e.length?{action:"jump",targetIndex:l}:{action:"none"}}let s=e.findIndex(c=>c.id===o);if(s!==-1)return{action:"jump",targetIndex:s};let d=Number(o);if(Number.isFinite(d)&&d>0){let c=e.findIndex(l=>l.order===d);if(c!==-1)return{action:"jump",targetIndex:c}}return{action:"none"}}function Tl(t){let e=t?.options||{},o=Object.keys(e),n=i=>{let s=/(\d+)/.exec(i);if(!s)return;let d=Number(s[1]);return Number.isFinite(d)?d:void 0};return o.sort((i,s)=>{let d=n(i),c=n(s);return d!=null&&c!=null?d-c:d!=null?-1:c!=null?1:i.localeCompare(s)}),o.map(i=>e[i]).filter(i=>typeof i=="string"&&i.trim().length>0)}function Fl(t,e){if(!t)return null;if(t==="alphabet"){let o="a".codePointAt(0)??97;return String.fromCodePoint(o+e%26)+"."}return t==="number"?String(e+1)+".":t==="roman"?(["i","ii","iii","iv","v","vi","vii","viii","ix","x","xi","xii","xiii","xiv","xv"][e]||String(e+1))+".":null}function Il(t){if(typeof t=="number"&&Number.isFinite(t)&&t>=0)return t;if(typeof t=="string"&&t.trim().length>0){let e=Number(t);if(Number.isFinite(e)&&e>=0)return e}}function ds(t){return Il(t?.borderwidth)??1}var cs=({details:t,slide:e,appearance:o,selectedOptions:n,comment:i,onSelectOption:s,onCommentChange:d,onSubmit:c,canSubmit:l})=>{let y=t.styling||{},u=y.options||{},m=y.cta,f=ps(()=>Tl(e),[e]),P=u.optionsSpacing??6,g=u.bulletSpacing??12,b=u.optionsHeight??48,R=gs(m?.container?.alignment),C=y.title?.textStyle,h=y.subtitle?.textStyle;return _e(wi,{children:[St("div",{style:{width:"100%",...No(C?.margin)},children:St("div",{style:{...mo(C),color:C?.color||"#111827",fontSize:C?.fontSize||22,lineHeight:1.3,textAlign:C?.textAlign||"left",fontWeight:C?.fontDecoration?.includes("bold")?"bold":C?.fontDecoration?"normal":600,fontStyle:C?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:C?.fontDecoration?.includes("underline")?"underline":"none"},children:e.title||e.question||t.name||"Survey"})}),(e.subtitle||h)&&St("div",{style:{width:"100%",...No(h?.margin)},children:St("div",{style:{...mo(h),color:h?.color||"#6b7280",fontSize:h?.fontSize||16,lineHeight:1.35,textAlign:h?.textAlign||"left",fontWeight:h?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:h?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:h?.fontDecoration?.includes("underline")?"underline":"none"},children:e.subtitle||""})}),f.length>0&&(()=>{let T="__others__",E=e.additionalComment?.placeholder?.trim()||"Others",X=f.map(S=>({value:S,label:S}));e.additionalComment?.enabled&&X.push({value:T,label:E});let I=n.includes(T);return _e(wi,{children:[St("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:P},children:X.map(({value:S,label:M},x)=>{let N=n.includes(S),U=N?u.selectedOptions:u.nonSelectedOptions,z=ds(U?.textStyle),O=Fl(u.optionListStyle,x),B=u.optionListStyle,K=B==="bulleted",v=B==="number"||B==="alphabet"||B==="roman",A=U?.colors?.text||U?.textStyle?.color||(N?"#ffffff":"#111827"),H=U?.colors?.background||(N?"#1f35db":"#ffffff"),it=U?.colors?.border||(N?"#1f35db":"#e5e7eb");return _e("button",{onClick:()=>s(S),style:{width:"100%",boxSizing:"border-box",minHeight:b,height:"auto",borderRadius:Oo(u.cornerRadius,7),border:`${z}px solid ${it}`,background:H,color:A,cursor:"pointer",display:"flex",alignItems:"center",gap:g,paddingTop:8,paddingBottom:8,paddingLeft:14,paddingRight:14,textAlign:U?.textStyle?.textAlign||"left",...mo(U?.textStyle)},"aria-pressed":N,children:[K?St("span",{"aria-hidden":!0,style:{width:18,height:18,borderRadius:"50%",border:`2px solid ${N?u.selectedOptions?.colors?.border||it:u.nonSelectedOptions?.colors?.border||it}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:N&&St("span",{style:{width:10,height:10,borderRadius:"50%",backgroundColor:A}})}):v?St("span",{"aria-hidden":!0,style:{fontSize:U?.textStyle?.fontSize?U.textStyle.fontSize*.85:16,fontWeight:U?.textStyle?.fontDecoration?.includes("bold")?"bold":600,fontFamily:Cn(U?.textStyle?.fontFamily),color:A,marginRight:2,flexShrink:0},children:O}):null,St("span",{style:{flex:1,minWidth:0,wordBreak:"break-word",lineHeight:1.35,color:A},children:M})]},`${S}-${x}`)})}),I&&St("textarea",{value:i,onChange:S=>d(S.target.value),placeholder:e.additionalComment?.placeholder||"Type your response...",style:{marginTop:10,width:"100%",boxSizing:"border-box",minHeight:72,resize:"none",overflowY:"auto",border:`${ds(u.additionalComments?.textStyle)}px solid ${u.additionalComments?.colors?.border||"#e5e7eb"}`,background:u.additionalComments?.colors?.background||"#ffffff",color:u.additionalComments?.colors?.text||"#111827",borderRadius:Oo(u.cornerRadius,7),padding:"12px",...mo(u.additionalComments?.textStyle)}})]})})(),St("div",{style:{position:"sticky",bottom:0,marginTop:m?.margin?.top??12,marginBottom:m?.margin?.bottom??0,marginLeft:m?.margin?.left??0,marginRight:m?.margin?.right??0,paddingTop:10,paddingBottom:4,background:o?.backgroundColor||"#ffffff",display:"flex",justifyContent:R,width:"100%",boxSizing:"border-box"},children:St("button",{onClick:c,disabled:!l,style:{width:m?.container?.ctaFullWidth?"100%":m?.container?.ctaWidth?`${m.container.ctaWidth}px`:"140px",maxWidth:"100%",height:m?.container?.height??50,border:`${m?.container?.borderWidth??0}px solid ${m?.container?.borderColor||"transparent"}`,background:m?.container?.backgroundColor||"#1f35db",color:m?.text?.color||"#ffffff",borderRadius:Oo(m?.cornerRadius,7),fontFamily:Cn(m?.text?.fontFamily)||"Arial",fontSize:m?.text?.fontSize||18,fontWeight:m?.text?.fontDecoration?.includes("bold")?"bold":600,fontStyle:m?.text?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:m?.text?.fontDecoration?.includes("underline")?"underline":"none",cursor:l?"pointer":"not-allowed",opacity:l?1:.6,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 20px",boxSizing:"border-box"},children:e.submitButtonText||"Submit"})})]})},us=({details:t,onDone:e})=>{let o=t.styling||{},n=o.thankyouPage||{},i=n.cta||o.cta,s=gs(i?.container?.alignment),d=t.thankYouImage?.endsWith(".json"),[c,l]=ie(null);fo(()=>{d&&t.thankYouImage?fetch(t.thankYouImage).then(f=>f.json()).then(f=>l(f)).catch(f=>console.error("AppStorys Survey: Error loading Thank You Lottie:",f)):l(null)},[t.thankYouImage,d]);let y=t.thankYouTitle||t?.thank_you_title||"Thank you",u=t.thankYouText||t?.thank_you_text||"",m=t.thankYouButtonText||t?.thank_you_button_text||"Done";return _e(wi,{children:[t.thankYouImage&&St("div",{style:{display:"flex",justifyContent:"center",...No(n.imageStyle?.margin)},children:d?c?St(wl,{animationData:c,loop:!0,style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80}}):St("div",{style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80}}):St("img",{src:t.thankYouImage,alt:"thank you",style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80,objectFit:"cover",borderRadius:10}})}),St("div",{style:{width:"100%",...No(n.title?.textStyle?.margin)},children:St("div",{style:{...mo(n.title?.textStyle),color:n.title?.textStyle?.color||"#111827",fontSize:n.title?.textStyle?.fontSize||20,lineHeight:1.3,textAlign:n.title?.textStyle?.textAlign||"center",fontWeight:n.title?.textStyle?.fontDecoration?.includes("bold")?"bold":n.title?.textStyle?.fontDecoration?.length?"normal":700},children:y})}),u&&St("div",{style:{width:"100%",...No(n.subtitle?.textStyle?.margin)},children:St("div",{style:{...mo(n.subtitle?.textStyle),color:n.subtitle?.textStyle?.color||"#6b7280",fontSize:n.subtitle?.textStyle?.fontSize||14,lineHeight:1.35,textAlign:n.subtitle?.textStyle?.textAlign||"center",fontWeight:n.subtitle?.textStyle?.fontDecoration?.includes("bold")?"bold":"normal"},children:u})}),(m||i)&&St("div",{style:{marginTop:i?.margin?.top??14,marginBottom:i?.margin?.bottom??0,marginLeft:i?.margin?.left??0,marginRight:i?.margin?.right??0,display:"flex",justifyContent:s,width:"100%",boxSizing:"border-box"},children:St("button",{onClick:e,style:{width:i?.container?.ctaFullWidth?"100%":i?.container?.ctaWidth?`${i.container.ctaWidth}px`:"auto",maxWidth:"100%",height:i?.container?.height??44,border:`${i?.container?.borderWidth??0}px solid ${i?.container?.borderColor||"transparent"}`,background:i?.container?.backgroundColor||"#1f35db",color:i?.text?.color||"#ffffff",borderRadius:Oo(i?.cornerRadius,12),fontFamily:Cn(i?.text?.fontFamily)||"Arial",fontSize:i?.text?.fontSize||14,fontWeight:i?.text?.fontDecoration?.includes("bold")?"bold":600,fontStyle:i?.text?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:i?.text?.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",padding:"0 20px",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:m})})]})},zl=()=>{let t=Mt("SUR"),e=W($=>$.isVisible),o=W($=>$.campaigns),n=W($=>$.allCampaigns),i=W($=>$.currentScreen),s=W($=>$.userId),[d,c]=ie(typeof window<"u"?window.innerWidth:1024),[l,y]=ie(0),[u,m]=ie(!1),[f,P]=ie(!1),[g,b]=ie(!1),R=go(0),C=go(0),h=go(null),T=go(0),E=go(!1);fo(()=>{if(typeof window>"u")return;let $=()=>c(window.innerWidth);return window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)},[]);let X=d<768,I=t??(()=>{let $=(i||"").trim().toLowerCase(),_=[...o||[],...n||[]].filter(Y=>{if(!Y||Y.campaign_type!=="SUR"||!Ot(Y,s))return!1;let ot=!!(Y.trigger_event??Y.trigger);if(!(Y.display_trigger!==!1&&!ot))return!1;let Dt=(Y.screen||"").trim().toLowerCase();return!Dt||Dt===$});if(_.length===0)return;let L=Lt(_)[0];if(L)try{return Kt(L)}catch{return L}})(),[S,M]=ie(!1),[x,N]=ie(!1),[U,z]=ie(0),[O,B]=ie([]),[K,v]=ie(""),[A,H]=ie({}),[it,at]=ie(!1),a=go(null);fo(()=>{if(!I?.id||a.current===I.id)return;a.current=I.id,M(!1),N(!1),z(0),B([]),v(""),H({}),at(!1),b(!1),P(!1),y(0);let $=I.details?.styling?.appearance?.displayDelay??0,_=globalThis.setTimeout(()=>{N(!0);let D=I.details?.id,L=ls(I.details),Y=L.length>0?L[0].id:void 0;st("viewed",I.id,{survey_id:D,slide_id:Y})},Math.max(0,$)*1e3);return()=>globalThis.clearTimeout(_)},[I?.id]),fo(()=>{if(x){let $=setTimeout(()=>b(!0),30);return()=>clearTimeout($)}},[x]);let F=ps(()=>I?ls(I.details):[],[I]),r=F[U];fo(()=>{if(typeof window>"u"||!I||!e||S||!x)return;let $=window.scrollY||window.pageYOffset||0,_=document.body.style.position,D=document.body.style.top,L=document.body.style.left,Y=document.body.style.right,ot=document.body.style.width,ft=document.body.style.overflow,Dt=document.documentElement.style.overflow;return document.body.style.position="fixed",document.body.style.top=`-${$}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%",document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",()=>{document.body.style.position=_,document.body.style.top=D,document.body.style.left=L,document.body.style.right=Y,document.body.style.width=ot,document.body.style.overflow=ft,document.documentElement.style.overflow=Dt,window.scrollTo(0,$)}},[I,e,S,x]);let p=($,_)=>{R.current=$,C.current=0,E.current=_,h.current?T.current=h.current.scrollTop:T.current=0,m(!0)},j=$=>{if(!R.current)return;let _=$-R.current,D=h.current?h.current.scrollTop:0,L=T.current<=0&&D<=0;(E.current||L)&&_>0?(C.current=_,y(_)):(C.current=0,y(0))},k=()=>{m(!1),E.current=!1,C.current>80?(P(!0),setTimeout(()=>{mt()},250)):(y(0),C.current=0),R.current=0};if(fo(()=>{if(!u)return;let $=Y=>{j(Y.clientY)},_=()=>{k()},D=Y=>{Y.cancelable&&Y.preventDefault(),Y.touches&&Y.touches[0]&&j(Y.touches[0].clientY)},L=()=>{k()};return window.addEventListener("pointermove",$),window.addEventListener("pointerup",_),window.addEventListener("touchmove",D,{passive:!1}),window.addEventListener("touchend",L),()=>{window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",_),window.removeEventListener("touchmove",D),window.removeEventListener("touchend",L)}},[u]),!I||!e||S||!x)return null;let G=I.details,V=G.styling||{},rt=V.appearance||{},lt=rt.backdropColor||"#000000",Z=kl(rt.backdropOpacity),gt=r?.multipleSelection!==!1&&r?.isMultiSelect!==!1&&V.options?.multipleSelection!==!1,Q=$=>{B(gt?_=>_.includes($)?_.filter(D=>D!==$):[..._,$]:_=>_[0]===$?[]:[$])},dt=async($,_)=>{let D=F.map(Ft=>({slide_id:Ft.id,order:Ft.order,title:Ft.title,question:Ft.question,selected_options:$[Ft.id]?.options,comment:$[Ft.id]?.comment})),L=I.id,Y=[];for(let Ft of F){let $t=$[Ft.id]?.options||[];for(let _t of $t){let Jt=Object.entries(Ft.options||{}).find(([,re])=>String(re)===String(_t));Jt&&Y.push(Jt[0])}}let ot=D.map(Ft=>Ft.comment).filter(Boolean).join(" || ")||"",ft=G.id||L;st("survey captured",ft,{survey_id:G.id,slide_id:_,selected_options:Y,otherText:ot}),V.content?.isThankyouPage!==!1?at(!0):M(!0)},yt=async()=>{if(!r||O.length===0)return;let $={...A,[r.id]:{options:O,comment:K}};H($);let _=[];if(r.options)for(let ot of O){let ft=Object.entries(r.options).find(([,Dt])=>String(Dt)===String(ot));ft&&_.push(ft[0])}try{let ot=I.id,ft=G.id||ot;st("survey captured",ft,{survey_id:G.id,slide_id:r.id,selected_options:_,otherText:K||""})}catch(ot){console.warn("Error sending per-slide survey captured",ot)}let D=O.includes("__others__"),L={action:"none"};for(let ot of r.logic||[]){let ft=ot.selectOption||[];if(ft.length===0)continue;let Dt=ft.some(_t=>_.includes(_t)),Ft=ft.some(_t=>O.includes(_t)),$t=D&&ft.some(_t=>_t==="others"||_t==="__others__");if(!(!Dt&&!Ft&&!$t)&&ot.redirectTo){let _t=Rl(ot.redirectTo,F);if(_t.action!=="none"){L=_t;break}}}if(L.action==="thankyou"){await dt($,r.id);return}if(L.action==="jump"){z(L.targetIndex);return}if(U>=F.length-1){await dt($,r.id);return}z(ot=>Math.min(ot+1,F.length-1))},ct=()=>{let $=G.thankYouButtonConfig;if($?.enabled&&$.redirectUrl){try{let _=String($.redirectUrl||"").trim();if(wt(_)){M(!0);return}if(_&&!_.startsWith("http")&&qt(_)){M(!0);return}}catch(_){console.warn("revealCampaignFromLink error",_)}try{globalThis.open($.redirectUrl,"_blank")}catch{}}M(!0)},mt=async()=>{try{let $=I?.id,_=G?.id,D=r?.id;await st("SurveyDismissed",$,{survey_id:_,slide_id:D})}catch($){console.warn("Error sending SurveyDismissed",$)}finally{M(!0)}};return r?X?_e("div",{style:{position:"fixed",inset:0,zIndex:Et(I,"SUR"),display:"flex",justifyContent:"center",alignItems:"flex-end",padding:0,boxSizing:"border-box",pointerEvents:"auto",touchAction:"none",overscrollBehavior:"none"},children:[St("div",{"aria-hidden":!0,onClick:()=>{P(!0),setTimeout(()=>mt(),250)},onTouchMove:$=>{$.cancelable&&$.preventDefault()},style:{position:"absolute",inset:0,background:as(lt,f?0:Z),transition:u?"none":"background 0.25s ease-out",zIndex:1,touchAction:"none"}}),_e("div",{onPointerDown:$=>{let _=$.target;_&&_.closest("button, input, textarea, a")||p($.clientY,!1)},onTouchStart:$=>{let _=$.target;_&&_.closest("button, input, textarea, a")||$.touches&&$.touches[0]&&p($.touches[0].clientY,!1)},style:{position:"relative",zIndex:2,width:"100%",maxWidth:"520px",maxHeight:"85vh",backgroundColor:rt.backgroundColor||"#ffffff",borderTopLeftRadius:`${rt.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${rt.cornerRadius?.topRight??16}px`,borderBottomLeftRadius:0,borderBottomRightRadius:0,boxSizing:"border-box",paddingTop:10,paddingRight:16,paddingBottom:"max(14px, env(safe-area-inset-bottom, 14px))",paddingLeft:16,boxShadow:"0 -8px 32px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column",overflow:"hidden",touchAction:"none",overscrollBehavior:"contain",transform:f?"translateY(100%)":g?`translateY(${l}px)`:"translateY(100%)",transition:u?"none":"transform 0.28s cubic-bezier(0.25, 1, 0.5, 1)"},children:[St("style",{children:`
139
139
  .appstorys-survey-scroll {
140
140
  scrollbar-width: none;
141
141
  -ms-overflow-style: none;
@@ -145,7 +145,7 @@ var ls=Object.defineProperty;var Me=(t,e)=>()=>(t&&(e=t(t=0)),e);var ds=(t,e)=>{
145
145
  height: 0;
146
146
  display: none;
147
147
  }
148
- `}),ft("div",{onPointerDown:R=>{R.stopPropagation(),z(R.clientY,!0)},onTouchStart:R=>{R.stopPropagation(),R.touches&&R.touches[0]&&z(R.touches[0].clientY,!0)},style:{width:"40px",height:"4px",backgroundColor:"#D1D5DB",borderRadius:"2px",margin:"0 auto 8px auto",flexShrink:0,cursor:"grab",touchAction:"none",userSelect:"none"}}),q.crossButton?.enabled&&ft(Dt,{config:q.crossButton,onPress:()=>{u(!0),setTimeout(()=>gt(),250)},style:{top:q.crossButton?.margin?.top!==void 0&&q.crossButton.margin.top>=0?q.crossButton.margin.top:10,right:q.crossButton?.margin?.right!==void 0&&q.crossButton.margin.right>=0?q.crossButton.margin.right:10,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0}}),ft("div",{ref:m,className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",overscrollBehavior:"contain",touchAction:"pan-y",paddingRight:2,WebkitOverflowScrolling:"touch"},children:r?ft(Yr,{details:X,onDone:mt}):ft(Ur,{details:X,slide:x,appearance:J,selectedOptions:T,comment:B,onSelectOption:K,onCommentChange:W,onSubmit:lt,canSubmit:T.length>0})})]})]}):Te("div",{style:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"flex-end",alignItems:"flex-end",padding:16,boxSizing:"border-box",pointerEvents:"none"},children:[ft("div",{"aria-hidden":!0,onClick:gt,style:{position:"absolute",inset:0,background:qr(nt,ht),pointerEvents:ht>0?"auto":"none",zIndex:1}}),Te("div",{style:{position:"relative",zIndex:2,width:"min(420px, 92vw)",maxWidth:"92vw",minWidth:"320px",maxHeight:"80vh",overflow:"hidden",backgroundColor:J.backgroundColor||"#ffffff",borderRadius:zo(J.cornerRadius,12),boxSizing:"border-box",paddingTop:14,paddingRight:16,paddingBottom:10,paddingLeft:16,pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"},children:[ft("style",{children:`
148
+ `}),St("div",{onPointerDown:$=>{$.stopPropagation(),p($.clientY,!0)},onTouchStart:$=>{$.stopPropagation(),$.touches&&$.touches[0]&&p($.touches[0].clientY,!0)},style:{width:"40px",height:"4px",backgroundColor:"#D1D5DB",borderRadius:"2px",margin:"0 auto 8px auto",flexShrink:0,cursor:"grab",touchAction:"none",userSelect:"none"}}),V.crossButton?.enabled&&St(Ut,{config:V.crossButton,onPress:()=>{P(!0),setTimeout(()=>mt(),250)},style:{top:V.crossButton?.margin?.top!==void 0&&V.crossButton.margin.top>=0?V.crossButton.margin.top:10,right:V.crossButton?.margin?.right!==void 0&&V.crossButton.margin.right>=0?V.crossButton.margin.right:10,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0}}),St("div",{ref:h,className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",overscrollBehavior:"contain",touchAction:"pan-y",paddingRight:2,WebkitOverflowScrolling:"touch"},children:it?St(us,{details:G,onDone:ct}):St(cs,{details:G,slide:r,appearance:rt,selectedOptions:O,comment:K,onSelectOption:Q,onCommentChange:v,onSubmit:yt,canSubmit:O.length>0})})]})]}):_e("div",{style:{position:"fixed",inset:0,zIndex:Et(I,"SUR"),display:"flex",justifyContent:"flex-end",alignItems:"flex-end",padding:16,boxSizing:"border-box",pointerEvents:"none"},children:[St("div",{"aria-hidden":!0,onClick:mt,style:{position:"absolute",inset:0,background:as(lt,Z),pointerEvents:Z>0?"auto":"none",zIndex:1}}),_e("div",{style:{position:"relative",zIndex:2,width:"min(420px, 92vw)",maxWidth:"92vw",minWidth:"320px",maxHeight:"80vh",overflow:"hidden",backgroundColor:rt.backgroundColor||"#ffffff",borderRadius:Oo(rt.cornerRadius,12),pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"},children:[St("style",{children:`
149
149
  .appstorys-survey-scroll {
150
150
  scrollbar-width: none;
151
151
  -ms-overflow-style: none;
@@ -155,11 +155,11 @@ var ls=Object.defineProperty;var Me=(t,e)=>()=>(t&&(e=t(t=0)),e);var ds=(t,e)=>{
155
155
  height: 0;
156
156
  display: none;
157
157
  }
158
- `}),q.crossButton?.enabled&&ft(Dt,{config:q.crossButton,onPress:gt,style:{top:q.crossButton?.margin?.top!==void 0&&q.crossButton.margin.top>=0?q.crossButton.margin.top:10,right:q.crossButton?.margin?.right!==void 0&&q.crossButton.margin.right>=0?q.crossButton.margin.right:10,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0}}),ft("div",{className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingRight:2},children:r?ft(Yr,{details:X,onDone:mt}):ft(Ur,{details:X,slide:x,appearance:J,selectedOptions:T,comment:B,onSelectOption:K,onCommentChange:W,onSubmit:lt,canSubmit:T.length>0})})]})]}):null},cl=dl;import{useEffect as Sl,useState as Cl,useRef as vl}from"react";yt();import{useEffect as cn,useState as pi,useRef as ul}from"react";import*as io from"lottie-react";import{Fragment as ml,jsx as oe,jsxs as no}from"react/jsx-runtime";var pl=io.default?.default??io.default??io.Lottie??io,Xr=t=>{if(!t)return;let e=t.trim().toLowerCase();if(e==="middle")return"center";if(e==="left"||e==="right"||e==="center"||e==="justify")return e},gl=t=>{if(!t)return null;if(typeof t=="string"){let e=t.trim();return e.length>0?e:null}if(typeof t=="object"){let e=typeof t.url=="string"?t.url.trim():"";if(e)return e;let o=typeof t.value=="string"?t.value.trim():"";if(o)return o;let n=typeof t.pageName=="string"?t.pageName.trim():"";if(n)return n;let i=typeof t.key=="string"?t.key.trim():"";if(i)return i}return null},fl=(t,e,o)=>{let n=gl(t);if(n){if(e){let i=o?._variantId||o?.details?.id;rt("clicked",e,i?{variant_id:i}:void 0)}if(!n.startsWith("http"))try{if(Pt(n))return}catch{}try{window.open(n,"_blank")}catch{}}},Jr=({campaign:t,onDismiss:e})=>{let[o,n]=pi(typeof window<"u"?window.innerWidth:1024),[i,s]=pi(null),[l,c]=pi(!0),d=ul(null);cn(()=>{if(typeof window>"u")return;let x=()=>n(window.innerWidth);window.addEventListener("resize",x);let z=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("resize",x),document.body.style.overflow=z}},[]);let{details:S}=t,p=S?.modals?.[0],y=p?.content||{},u=p?.styling||{},C=y?.chooseMediaType||p?.chooseMediaType,h=C?.type,g=C?.url;if(cn(()=>{h==="lottie"&&g?(s(null),fetch(g).then(x=>x.json()).then(x=>s(x)).catch(x=>console.error("Error fetching Lottie in ModalWithCta:",x))):s(null)},[h,g]),cn(()=>{d.current&&(d.current.muted=l)},[l]),cn(()=>{let x=d.current;if(!x||h!=="video")return;x.muted=!1;let z=x.play();z!==void 0&&z.then(()=>{c(!1)}).catch(()=>{x.muted=!0,c(!0),x.play().catch(()=>{})})},[g,h]),!p)return null;let b=u.appearance||{},m=u.crossButton,E=b.backdrop?.color||"rgba(0, 0, 0, 0.4)",O=b.backdrop?.opacity!==void 0&&b.backdrop?.opacity!==null?b.backdrop.opacity>1?b.backdrop.opacity/100:b.backdrop.opacity:0,D=b.enableBackdrop!==!1,L=b.dimension?.width!==void 0&&b.dimension?.width!==null&&b.dimension.width>0?b.dimension.width:300,v=o>=768,w=v?L*1.4:L,_=Math.min(w,o*.9),$=b.cornerRadius||{},V=b.backgroundColor||"#FFFFFF",A=y.titleText||"",T=y.subtitleText||"",k=y.primaryCtaText||"",B=y.secondaryCtaText||"",W=y.primaryCtaRedirection,H=y.secondaryCtaRedirection,Y=u.title||{},r=u.subTitle||{},M=u.primaryCta||{},a=u.secondaryCta||{},f=(x,z,U,et=!1)=>{if(!x||x.trim()==="")return null;let X=z?.container||{},q=z?.cornerRadius||{},J=z?.margin||{},nt=z?.text||{},ht=N=>N==="left"?"flex-start":N==="right"?"flex-end":"center",dt=X.ctaWidth,K=v&&dt?dt*1.4:dt,it=X.height||40,lt=v?it*1.2:it,mt=q.topLeft!==void 0&&q.topLeft>=0?q.topLeft:8,gt=q.topRight!==void 0&&q.topRight>=0?q.topRight:8,R=q.bottomRight!==void 0&&q.bottomRight>=0?q.bottomRight:8,I=q.bottomLeft!==void 0&&q.bottomLeft>=0?q.bottomLeft:8;return oe("div",{style:{display:"flex",justifyContent:ht(X.alignment),width:et?"auto":"100%",flex:et?1:void 0,marginTop:J.top!==void 0&&J.top>=0?J.top:0,marginBottom:J.bottom!==void 0&&J.bottom>=0?J.bottom:0,marginLeft:J.left!==void 0&&J.left>=0?J.left:0,marginRight:J.right!==void 0&&J.right>=0?J.right:0,boxSizing:"border-box"},children:oe("button",{style:{width:et||X.ctaFullWidth?"100%":K?`${K}px`:"auto",height:lt,backgroundColor:X.backgroundColor||"#FE6B35",color:nt.color||"#FFFFFF",border:`${X.borderWidth||0}px solid ${X.borderColor||"transparent"}`,borderRadius:`${mt}px ${gt}px ${R}px ${I}px`,fontSize:nt.fontSize||14,fontFamily:st(nt.fontFamily)||"Arial",fontWeight:nt.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:nt.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:nt.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px",outline:"none",boxSizing:"border-box"},onClick:()=>fl(U,t?.id,t),children:Ce(x)})})};return no(ml,{children:[oe("style",{children:`
158
+ `}),V.crossButton?.enabled&&St(Ut,{config:V.crossButton,onPress:mt,style:{top:V.crossButton?.margin?.top!==void 0&&V.crossButton.margin.top>=0?V.crossButton.margin.top:10,right:V.crossButton?.margin?.right!==void 0&&V.crossButton.margin.right>=0?V.crossButton.margin.right:10,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0}}),St("div",{className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingRight:2},children:it?St(us,{details:G,onDone:ct}):St(cs,{details:G,slide:r,appearance:rt,selectedOptions:O,comment:K,onSelectOption:Q,onCommentChange:v,onSubmit:yt,canSubmit:O.length>0})})]})]}):null},Bl=zl;import{useEffect as Nl,useState as Ol,useRef as jl}from"react";vt();import{useEffect as vn,useState as ki,useRef as Al}from"react";Vt();import*as bo from"lottie-react";import{Fragment as Ml,jsx as de,jsxs as ho}from"react/jsx-runtime";var Ll=bo.default?.default??bo.default??bo.Lottie??bo,fs=t=>{if(!t)return;let e=t.trim().toLowerCase();if(e==="middle")return"center";if(e==="left"||e==="right"||e==="center"||e==="justify")return e},El=t=>{if(!t)return null;if(typeof t=="string"){let e=t.trim();return e.length>0?e:null}if(typeof t=="object"){let e=typeof t.url=="string"?t.url.trim():"";if(e)return e;let o=typeof t.value=="string"?t.value.trim():"";if(o)return o;let n=typeof t.pageName=="string"?t.pageName.trim():"";if(n)return n;let i=typeof t.key=="string"?t.key.trim():"";if(i)return i}return null},Pl=(t,e,o,n)=>{let i=El(t);if(i){if(e){let s=o?._variantId||o?.details?.id;st("clicked",e,s?{variant_id:s}:void 0)}if(wt(i)){n?.();return}if(!i.startsWith("http"))try{if(qt(i))return}catch{}try{window.open(i,"_blank")}catch{}}},ms=({campaign:t,onDismiss:e})=>{let[o,n]=ki(typeof window<"u"?window.innerWidth:1024),[i,s]=ki(null),[d,c]=ki(!0),l=Al(null);vn(()=>{if(typeof window>"u")return;let F=()=>n(window.innerWidth);window.addEventListener("resize",F);let r=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("resize",F),document.body.style.overflow=r}},[]);let{details:y}=t,u=y?.modals?.[0],m=u?.content||{},f=u?.styling||{},P=m?.chooseMediaType||u?.chooseMediaType,g=P?.type,b=P?.url;if(vn(()=>{g==="lottie"&&b?(s(null),fetch(b).then(F=>F.json()).then(F=>s(F)).catch(F=>console.error("Error fetching Lottie in ModalWithCta:",F))):s(null)},[g,b]),vn(()=>{l.current&&(l.current.muted=d)},[d]),vn(()=>{let F=l.current;if(!F||g!=="video")return;F.muted=!1;let r=F.play();r!==void 0&&r.then(()=>{c(!1)}).catch(()=>{F.muted=!0,c(!0),F.play().catch(()=>{})})},[b,g]),!u)return null;let R=f.appearance||{},C=f.crossButton,h=R.backdrop?.color||"rgba(0, 0, 0, 0.4)",T=R.backdrop?.opacity!==void 0&&R.backdrop?.opacity!==null?R.backdrop.opacity>1?R.backdrop.opacity/100:R.backdrop.opacity:0,E=R.enableBackdrop!==!1,X=R.dimension?.width!==void 0&&R.dimension?.width!==null&&R.dimension.width>0?R.dimension.width:300,I=o>=768,S=I?X*1.4:X,M=Math.min(S,o*.9),x=R.cornerRadius||{},N=R.backgroundColor||"#FFFFFF",U=m.titleText||"",z=m.subtitleText||"",O=m.primaryCtaText||"",B=m.secondaryCtaText||"",K=m.primaryCtaRedirection,v=m.secondaryCtaRedirection,A=f.title||{},H=f.subTitle||{},it=f.primaryCta||{},at=f.secondaryCta||{},a=(F,r,p,j=!1)=>{if(!F||F.trim()==="")return null;let k=r?.container||{},G=r?.cornerRadius||{},V=r?.margin||{},rt=r?.text||{},lt=_=>_==="left"?"flex-start":_==="right"?"flex-end":"center",Z=k.ctaWidth,gt=I&&Z?Z*1.4:Z,Q=k.height||40,dt=I?Q*1.2:Q,yt=G.topLeft!==void 0&&G.topLeft>=0?G.topLeft:8,ct=G.topRight!==void 0&&G.topRight>=0?G.topRight:8,mt=G.bottomRight!==void 0&&G.bottomRight>=0?G.bottomRight:8,$=G.bottomLeft!==void 0&&G.bottomLeft>=0?G.bottomLeft:8;return de("div",{style:{display:"flex",justifyContent:lt(k.alignment),width:j?"auto":"100%",flex:j?1:void 0,marginTop:V.top!==void 0&&V.top>=0?V.top:0,marginBottom:V.bottom!==void 0&&V.bottom>=0?V.bottom:0,marginLeft:V.left!==void 0&&V.left>=0?V.left:0,marginRight:V.right!==void 0&&V.right>=0?V.right:0,boxSizing:"border-box"},children:de("button",{style:{width:j||k.ctaFullWidth?"100%":gt?`${gt}px`:"auto",height:dt,backgroundColor:k.backgroundColor||"#FE6B35",color:rt.color||"#FFFFFF",border:`${k.borderWidth||0}px solid ${k.borderColor||"transparent"}`,borderRadius:`${yt}px ${ct}px ${mt}px ${$}px`,fontSize:rt.fontSize||14,fontFamily:ut(rt.fontFamily)||"Arial",fontWeight:rt.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:rt.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:rt.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px",outline:"none",boxSizing:"border-box"},onClick:()=>Pl(p,t?.id,t,e),children:Le(F)})})};return ho(Ml,{children:[de("style",{children:`
159
159
  .appstorys-modal-scroll::-webkit-scrollbar { display: none; }
160
160
  .appstorys-modal-scroll { scrollbar-width: none; }
161
- `}),oe("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:D?E:"transparent",opacity:D?O:1,zIndex:999998,transition:"opacity 0.3s ease"}}),no("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:_,maxWidth:"95vw",zIndex:999999,overflow:"visible"},children:[(m?.enabled??!0)&&oe(Dt,{config:m||{enabled:!0},onPress:x=>{x&&typeof x.stopPropagation=="function"&&x.stopPropagation(),e()},style:{position:"absolute",zIndex:1e7,top:m?.margin?.top!==void 0&&m.margin?.top>=0?m.margin.top:8,right:m?.margin?.right!==void 0&&m.margin?.right>=0?m.margin.right:8}}),no("div",{style:{width:"100%",backgroundColor:V,borderTopLeftRadius:$.topLeft!==void 0&&$.topLeft>=0?$.topLeft:0,borderTopRightRadius:$.topRight!==void 0&&$.topRight>=0?$.topRight:0,borderBottomLeftRadius:$.bottomLeft!==void 0&&$.bottomLeft>=0?$.bottomLeft:0,borderBottomRightRadius:$.bottomRight!==void 0&&$.bottomRight>=0?$.bottomRight:0,overflow:"hidden",boxShadow:"0 8px 32px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",maxHeight:"90vh"},children:[no("div",{className:"appstorys-modal-scroll",style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",alignItems:"center",minHeight:0},children:[g&&(h==="image"||!h)&&oe("img",{src:g,alt:"",style:{width:"100%",display:"block"}}),g&&h==="video"&&no("div",{style:{position:"relative",width:"100%"},children:[oe("video",{ref:d,src:g,autoPlay:!0,loop:!0,muted:l,playsInline:!0,controls:!1,style:{width:"100%",display:"block"}}),oe(be,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(0,0,0,0.45)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:x=>{x.stopPropagation(),c(z=>!z)},type:l?"mute":"unmute",enabled:!0,style:{position:"absolute",zIndex:1e7,bottom:12,left:12,borderRadius:"50%"}})]}),g&&h==="lottie"&&i&&(()=>{let x=i.w,z=i.h,U=x&&z&&x>0?z/x:void 0,et=_,X=U?Math.round(et*U):void 0;return oe(pl,{animationData:i,loop:!0,autoplay:!0,style:{width:et,height:X,display:"block"}})})(),A.trim()!==""&&oe("div",{style:{width:"100%",padding:"12px 16px 0 16px",color:Y.color||"#000000",fontSize:Y.fontSize||26,fontFamily:st(Y.fontFamily)||"Helvetica",fontWeight:Y.fontDecoration?.includes("bold")?"bold":"600",fontStyle:Y.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:Y.fontDecoration?.includes("underline")?"underline":"none",textAlign:Xr(Y.textAlign)||"center",boxSizing:"border-box"},children:Ce(A)}),T.trim()!==""&&oe("div",{style:{width:"100%",padding:"4px 16px 0 16px",color:r.color||"#000000",fontSize:r.fontSize||20,fontFamily:st(r.fontFamily)||"Helvetica",fontWeight:r.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:r.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:r.fontDecoration?.includes("underline")?"underline":"none",textAlign:Xr(r.textAlign)||"center",boxSizing:"border-box"},children:Ce(T)})]}),(k.trim()!==""||B.trim()!=="")&&no("div",{style:{flexShrink:0,width:"100%",padding:"0 12px 12px 12px",boxSizing:"border-box",display:"flex",flexDirection:k.trim()!==""&&B.trim()!==""?"row":"column",gap:"8px",justifyContent:"center"},children:[f(k,M,W,k.trim()!==""&&B.trim()!==""),f(B,a,H,k.trim()!==""&&B.trim()!=="")]})]})]})]})};import{useEffect as un,useState as gi,useRef as yl}from"react";import*as ro from"lottie-react";import{Fragment as xl,jsx as ze,jsxs as pn}from"react/jsx-runtime";var hl=ro.default?.default??ro.default??ro.Lottie??ro,Kr=t=>{if(!t)return null;if(typeof t=="string"){let e=t.trim();return e.length>0?e:null}if(typeof t=="object"){let e=typeof t.url=="string"?t.url.trim():"";if(e)return e;let o=typeof t.value=="string"?t.value.trim():"";if(o)return o;let n=typeof t.pageName=="string"?t.pageName.trim():"";if(n)return n;let i=typeof t.key=="string"?t.key.trim():"";if(i)return i}return null},bl=(t,e,o)=>{let n=Kr(t);if(n){if(e){let i=o?._variantId||o?.details?.id;rt("clicked",e,i?{variant_id:i}:void 0)}if(!n.startsWith("http"))try{if(Pt(n))return}catch{}try{window.open(n,"_blank")}catch{}}},Zr=({campaign:t,onDismiss:e})=>{let[o,n]=gi(typeof window<"u"?window.innerWidth:1024),[i,s]=gi(null),[l,c]=gi(!0),d=yl(null);un(()=>{if(typeof window>"u")return;let A=()=>n(window.innerWidth);window.addEventListener("resize",A);let T=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("resize",A),document.body.style.overflow=T}},[]);let{details:S}=t,p=S?.modals?.[0],y=p?.chooseMediaType,u=p?.styling||{},C=p?.redirection,h=y?.type,g=y?.url;if(un(()=>{h==="lottie"&&g?(s(null),fetch(g).then(A=>A.json()).then(A=>s(A)).catch(A=>console.error("Error fetching Lottie in MediaOnlyModal:",A))):s(null)},[h,g]),un(()=>{d.current&&(d.current.muted=l)},[l]),un(()=>{let A=d.current;if(!A||h!=="video")return;A.muted=!1;let T=A.play();T!==void 0&&T.then(()=>{c(!1)}).catch(()=>{A.muted=!0,c(!0),A.play().catch(()=>{})})},[g,h]),!p||!y||!g)return null;let b=u.appearance||{},m=u.crossButton,E=b.backdrop?.color||"rgba(0, 0, 0, 0.4)",O=b.backdrop?.opacity!==void 0&&b.backdrop?.opacity!==null?b.backdrop.opacity>1?b.backdrop.opacity/100:b.backdrop.opacity:0,D=b.enableBackdrop!==!1,L=b.dimension?.width!==void 0&&b.dimension?.width!==null&&b.dimension.width>0?b.dimension.width:300,w=o>=768?L*1.4:L,_=Math.min(w,o*.9),$=b.cornerRadius||{},V=b.backgroundColor||(h==="lottie"?"transparent":"#FFFFFF");return pn(xl,{children:[ze("style",{children:`
161
+ `}),de("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:E?h:"transparent",opacity:E?T:1,zIndex:Et(t,"MOD")-1,transition:"opacity 0.3s ease"}}),ho("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:M,maxWidth:"95vw",zIndex:Et(t,"MOD"),overflow:"visible"},children:[(C?.enabled??!0)&&de(Ut,{config:C||{enabled:!0},onPress:F=>{F&&typeof F.stopPropagation=="function"&&F.stopPropagation(),e()},style:{position:"absolute",zIndex:1e7,top:C?.margin?.top!==void 0&&C.margin?.top>=0?C.margin.top:8,right:C?.margin?.right!==void 0&&C.margin?.right>=0?C.margin.right:8}}),ho("div",{style:{width:"100%",backgroundColor:N,borderTopLeftRadius:x.topLeft!==void 0&&x.topLeft>=0?x.topLeft:0,borderTopRightRadius:x.topRight!==void 0&&x.topRight>=0?x.topRight:0,borderBottomLeftRadius:x.bottomLeft!==void 0&&x.bottomLeft>=0?x.bottomLeft:0,borderBottomRightRadius:x.bottomRight!==void 0&&x.bottomRight>=0?x.bottomRight:0,overflow:"hidden",boxShadow:"0 8px 32px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",maxHeight:"90vh"},children:[ho("div",{className:"appstorys-modal-scroll",style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",alignItems:"center",minHeight:0},children:[b&&(g==="image"||!g)&&de("img",{src:b,alt:"",style:{width:"100%",display:"block"}}),b&&g==="video"&&ho("div",{style:{position:"relative",width:"100%"},children:[de("video",{ref:l,src:b,autoPlay:!0,loop:!0,muted:d,playsInline:!0,controls:!1,style:{width:"100%",display:"block"}}),de(Re,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(0,0,0,0.45)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:F=>{F.stopPropagation(),c(r=>!r)},type:d?"mute":"unmute",enabled:!0,style:{position:"absolute",zIndex:1e7,bottom:12,left:12,borderRadius:"50%"}})]}),b&&g==="lottie"&&i&&(()=>{let F=i.w,r=i.h,p=F&&r&&F>0?r/F:void 0,j=M,k=p?Math.round(j*p):void 0;return de(Ll,{animationData:i,loop:!0,autoplay:!0,style:{width:j,height:k,display:"block"}})})(),U.trim()!==""&&de("div",{style:{width:"100%",padding:"12px 16px 0 16px",color:A.color||"#000000",fontSize:A.fontSize||26,fontFamily:ut(A.fontFamily)||"Helvetica",fontWeight:A.fontDecoration?.includes("bold")?"bold":"600",fontStyle:A.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:A.fontDecoration?.includes("underline")?"underline":"none",textAlign:fs(A.textAlign)||"center",boxSizing:"border-box"},children:Le(U)}),z.trim()!==""&&de("div",{style:{width:"100%",padding:"4px 16px 0 16px",color:H.color||"#000000",fontSize:H.fontSize||20,fontFamily:ut(H.fontFamily)||"Helvetica",fontWeight:H.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:H.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:H.fontDecoration?.includes("underline")?"underline":"none",textAlign:fs(H.textAlign)||"center",boxSizing:"border-box"},children:Le(z)})]}),(O.trim()!==""||B.trim()!=="")&&ho("div",{style:{flexShrink:0,width:"100%",padding:"0 12px 12px 12px",boxSizing:"border-box",display:"flex",flexDirection:O.trim()!==""&&B.trim()!==""?"row":"column",gap:"8px",justifyContent:"center"},children:[a(O,it,K,O.trim()!==""&&B.trim()!==""),a(B,at,v,O.trim()!==""&&B.trim()!=="")]})]})]})]})};import{useEffect as wn,useState as Ri,useRef as _l}from"react";Vt();import*as xo from"lottie-react";import{Fragment as $l,jsx as We,jsxs as kn}from"react/jsx-runtime";var Wl=xo.default?.default??xo.default??xo.Lottie??xo,ys=t=>{if(!t)return null;if(typeof t=="string"){let e=t.trim();return e.length>0?e:null}if(typeof t=="object"){let e=typeof t.url=="string"?t.url.trim():"";if(e)return e;let o=typeof t.value=="string"?t.value.trim():"";if(o)return o;let n=typeof t.pageName=="string"?t.pageName.trim():"";if(n)return n;let i=typeof t.key=="string"?t.key.trim():"";if(i)return i}return null},Dl=(t,e,o,n)=>{let i=ys(t);if(i){if(e){let s=o?._variantId||o?.details?.id;st("clicked",e,s?{variant_id:s}:void 0)}if(wt(i)){n?.();return}if(!i.startsWith("http"))try{if(qt(i))return}catch{}try{window.open(i,"_blank")}catch{}}},hs=({campaign:t,onDismiss:e})=>{let[o,n]=Ri(typeof window<"u"?window.innerWidth:1024),[i,s]=Ri(null),[d,c]=Ri(!0),l=_l(null);wn(()=>{if(typeof window>"u")return;let z=()=>n(window.innerWidth);window.addEventListener("resize",z);let O=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("resize",z),document.body.style.overflow=O}},[]);let{details:y}=t,u=y?.modals?.[0],m=u?.chooseMediaType,f=u?.styling||{},P=u?.redirection,g=m?.type,b=m?.url;if(wn(()=>{g==="lottie"&&b?(s(null),fetch(b).then(z=>z.json()).then(z=>s(z)).catch(z=>console.error("Error fetching Lottie in MediaOnlyModal:",z))):s(null)},[g,b]),wn(()=>{l.current&&(l.current.muted=d)},[d]),wn(()=>{let z=l.current;if(!z||g!=="video")return;z.muted=!1;let O=z.play();O!==void 0&&O.then(()=>{c(!1)}).catch(()=>{z.muted=!0,c(!0),z.play().catch(()=>{})})},[b,g]),!u||!m||!b)return null;let R=f.appearance||{},C=f.crossButton,h=R.backdrop?.color||"rgba(0, 0, 0, 0.4)",T=R.backdrop?.opacity!==void 0&&R.backdrop?.opacity!==null?R.backdrop.opacity>1?R.backdrop.opacity/100:R.backdrop.opacity:0,E=R.enableBackdrop!==!1,X=R.dimension?.width!==void 0&&R.dimension?.width!==null&&R.dimension.width>0?R.dimension.width:300,S=o>=768?X*1.4:X,M=Math.min(S,o*.9),x=R.cornerRadius||{},N=R.backgroundColor||(g==="lottie"?"transparent":"#FFFFFF"),U=Et(t,"MOD");return kn($l,{children:[We("style",{children:`
162
162
  .appstorys-media-modal-scroll::-webkit-scrollbar { display: none; }
163
163
  .appstorys-media-modal-scroll { scrollbar-width: none; }
164
- `}),ze("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:D?E:"transparent",opacity:D?O:1,zIndex:999998,transition:"opacity 0.3s ease"}}),pn("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:_,maxWidth:"95vw",zIndex:999999,overflow:"visible"},children:[(m?.enabled??!0)&&ze(Dt,{config:m||{enabled:!0},onPress:A=>{A&&typeof A.stopPropagation=="function"&&A.stopPropagation(),e()},style:{position:"absolute",zIndex:1e7,top:m?.margin?.top!==void 0&&m.margin?.top>=0?m.margin.top:8,right:m?.margin?.right!==void 0&&m.margin?.right>=0?m.margin.right:8}}),ze("div",{className:"appstorys-media-modal-scroll",style:{width:"100%",backgroundColor:V,borderTopLeftRadius:$.topLeft!==void 0&&$.topLeft>=0?$.topLeft:0,borderTopRightRadius:$.topRight!==void 0&&$.topRight>=0?$.topRight:0,borderBottomLeftRadius:$.bottomLeft!==void 0&&$.bottomLeft>=0?$.bottomLeft:0,borderBottomRightRadius:$.bottomRight!==void 0&&$.bottomRight>=0?$.bottomRight:0,overflow:"hidden",boxShadow:V==="transparent"?"none":"0 8px 32px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",alignItems:"center",maxHeight:"90vh",overflowY:"auto"},children:(()=>{let A=!!Kr(C);return pn("div",{onClick:A?()=>bl(C,t?.id,t):void 0,style:{width:"100%",cursor:A?"pointer":"default",minHeight:0},children:[g&&(h==="image"||!h)&&ze("img",{src:g,alt:"",style:{width:"100%",display:"block"}}),g&&h==="video"&&pn("div",{style:{position:"relative",width:"100%"},children:[ze("video",{ref:d,src:g,autoPlay:!0,loop:!0,muted:l,playsInline:!0,controls:!1,style:{width:"100%",display:"block"}}),ze(be,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(0,0,0,0.45)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:T=>{T.stopPropagation(),c(k=>!k)},type:l?"mute":"unmute",enabled:!0,style:{position:"absolute",zIndex:1e7,bottom:12,left:12,borderRadius:"50%"}})]}),g&&h==="lottie"&&i&&(()=>{let T=i.w,k=i.h,B=T&&k&&T>0?k/T:void 0,W=_,H=B?Math.round(W*B):void 0;return ze(hl,{animationData:i,loop:!0,autoplay:!0,style:{width:W,height:H,display:"block"}})})()]})})()})]})]})};import{jsx as ts}from"react/jsx-runtime";var wl=()=>{let t=At("MOD"),e=P(C=>C.campaigns),o=P(C=>C.allCampaigns),n=P(C=>C.currentScreen),i=t??(()=>{let C=(n||"").trim().toLowerCase(),h=[...e||[],...o||[]].find(g=>{if(!g||g.campaign_type!=="MOD")return!1;let b=!!(g.trigger_event??g.trigger);if(!(g.display_trigger!==!1&&!b))return!1;let E=(g.screen||"").trim().toLowerCase();return!E||E===C});if(h)try{return Nt(h)}catch{return h}})(),s=P(C=>C.isVisible),[l,c]=Cl(!1),d=vl(null);Sl(()=>{if(i?.id&&d.current!==i.id){d.current=i.id,c(!1);let C=i._variantId||i.details?.id,h=C?{variant_id:C}:void 0;rt("viewed",i.id,h)}},[i?.id]);let S=C=>{try{let h=P.getState(),b=(h.trackedEvents||[]).filter(m=>m!==C);h.setTrackedEvents(b)}catch{}};if(!i||l||!s)return null;let p=()=>{i?.id&&S(`viaAppStorys${i.id}`),c(!0)},y=i.details?.modal_type||i.details?.modals?.[0]?.modal_type||"";return y==="full-page-modal"||y==="media-only-modal"?ts(Zr,{campaign:i,onDismiss:p}):ts(Jr,{campaign:i,onDismiss:p})};import{jsx as Rl}from"react/jsx-runtime";var kl=({id:t,children:e})=>Rl("div",{"data-as-id":t,style:{display:"contents"},children:e});var fi=class{state="uninitialized";navigateToScreen;async initialize(e){let{appId:o,accountId:n,userId:i}=e;if(this.navigateToScreen=e.navigateToScreen,this.state!=="initializing"){if(this.state==="initialized"){let s=P.getState();if(s.isAnonymousUser&&i&&i.trim()!==""){console.log("AppStorys: Reconciling anonymous user with identified user..."),await this.reconcileUser(s.userId,i,o,n);return}if(s.appId===o&&s.accountId===n&&s.userId===i)return}this.state="initializing";try{let s,l;if(!i||i.trim()==="")s=await Ui(),l=!0;else{let y=await Wn();y&&y!==i&&console.log("AppStorys: Found previous anonymous user, will reconcile after verification."),s=i,l=!1}if(!await he(n,o,s)){this.state="error";return}if(!l){let y=await Wn();y&&y!==s&&(await Uo(y,s),await _n())}try{let y=await Et(),u=e.baseUrl||"https://users.appstorys.co";fetch(`${u}/v2/${n}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...y?{Authorization:`Bearer ${y}`}:{}},body:JSON.stringify({user_id:s,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})}).then(async C=>{if(C.ok)try{let h=await C.json(),g=P.getState();if(typeof h.screen_capture_enabled<"u"){let b=!!h.screen_capture_enabled;console.info("AppStorys: track-user-res returned screen_capture_enabled=",b),g.setScreenCaptureEnabled(b)}}catch{}}).catch(C=>console.warn("track-user-res (init) failed",C))}catch(y){console.warn("track-user-res (init) setup failed",y)}let{campaigns:d,version:S}=await An(n);try{Ei(d)}catch(y){console.warn("Failed to preload campaign fonts",y)}let p=P.getState();p.setAppId(o),p.setAccountId(n),p.setUserId(s),p.setIsAnonymousUser(l),p.setBaseUrl(e.baseUrl),p.setTrackingUrl(e.trackingUrl),p.saveAllCampaigns(d),p.setCampaignVersion(S);try{P.getState().screenCaptureEnabled&&(await Promise.resolve().then(()=>(ss(),rs))).mountScreenCaptureButton()}catch(y){console.warn("Failed to mount screen capture button",y)}Hi.setup(),Dn.setup(),this.state="initialized"}catch(s){this.state="error",console.error("AppStorys initialization failed:",s)}}}async reconcileUser(e,o,n,i){try{if(!await he(i,n,o)){console.error("AppStorys: Failed to verify identified user account during reconciliation.");return}if(!await Uo(e,o)){console.error("AppStorys: Failed to reconcile anonymous and identified users.");return}await _n();let c=P.getState();c.setUserId(o),c.setIsAnonymousUser(!1)}catch(s){console.error("AppStorys: Error during user reconciliation:",s)}}async trackScreen(e){return await this.ensureInitialized(),In(e)}async trackEvent(e,o,n){return await this.ensureInitialized(),rt(e,o,n)}async setUserProperties(e){return await this.ensureInitialized(),Bn(e)}handleLink(e){if(e){if(typeof e=="string"){try{if(!e.startsWith("http")&&Pt(e))return}catch(o){console.warn("revealCampaignFromLink error",o)}e.startsWith("http")?window.open(e,"_blank"):this.navigateToScreen?.(e)}else if(typeof e=="object"&&e.value){try{if(Pt(e.value))return}catch{}this.navigateToScreen?.(e.value)}}}get visibility(){return P.getState().isVisible}set visibility(e){Dn.updateVisibility(e)}async ensureInitialized(){if(this.state==="initialized")return;let e=Date.now();for(;this.state!=="initialized";){if(this.state==="error")throw new Error("AppStorys SDK error");if(Date.now()-e>1e4)throw new Error("AppStorys SDK initialization timeout");await new Promise(o=>setTimeout(o,100))}}personalizeText(e){return Ce(e)}},Gf=new fi;export{Gf as AppStorys,Rs as Banner,qa as BottomSheet,ol as Csat,Ns as Floater,wl as Modal,Es as Pip,yi as SdkState,Ta as Story,cl as Survey,$a as Tooltip,kl as Trackable,Aa as Widget,Wl as getCampaignVariantId,Si as getVariantId,Eo as hasVariants,Ce as personalizeText,Nt as resolveCampaignVariant,gs as selectVariantByWeight};
164
+ `}),We("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:E?h:"transparent",opacity:E?T:1,zIndex:U-1,transition:"opacity 0.3s ease"}}),kn("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:M,maxWidth:"95vw",zIndex:U,overflow:"visible"},children:[(C?.enabled??!0)&&We(Ut,{config:C||{enabled:!0},onPress:z=>{z&&typeof z.stopPropagation=="function"&&z.stopPropagation(),e()},style:{position:"absolute",zIndex:1e7,top:C?.margin?.top!==void 0&&C.margin?.top>=0?C.margin.top:8,right:C?.margin?.right!==void 0&&C.margin?.right>=0?C.margin.right:8}}),We("div",{className:"appstorys-media-modal-scroll",style:{width:"100%",backgroundColor:N,borderTopLeftRadius:x.topLeft!==void 0&&x.topLeft>=0?x.topLeft:0,borderTopRightRadius:x.topRight!==void 0&&x.topRight>=0?x.topRight:0,borderBottomLeftRadius:x.bottomLeft!==void 0&&x.bottomLeft>=0?x.bottomLeft:0,borderBottomRightRadius:x.bottomRight!==void 0&&x.bottomRight>=0?x.bottomRight:0,overflow:"hidden",boxShadow:N==="transparent"?"none":"0 8px 32px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",alignItems:"center",maxHeight:"90vh",overflowY:"auto"},children:(()=>{let z=!!ys(P);return kn("div",{onClick:z?()=>Dl(P,t?.id,t,e):void 0,style:{width:"100%",cursor:z?"pointer":"default",minHeight:0},children:[b&&(g==="image"||!g)&&We("img",{src:b,alt:"",style:{width:"100%",display:"block"}}),b&&g==="video"&&kn("div",{style:{position:"relative",width:"100%"},children:[We("video",{ref:l,src:b,autoPlay:!0,loop:!0,muted:d,playsInline:!0,controls:!1,style:{width:"100%",display:"block"}}),We(Re,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(0,0,0,0.45)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:O=>{O.stopPropagation(),c(B=>!B)},type:d?"mute":"unmute",enabled:!0,style:{position:"absolute",zIndex:1e7,bottom:12,left:12,borderRadius:"50%"}})]}),b&&g==="lottie"&&i&&(()=>{let O=i.w,B=i.h,K=O&&B&&O>0?B/O:void 0,v=M,A=K?Math.round(v*K):void 0;return We(Wl,{animationData:i,loop:!0,autoplay:!0,style:{width:v,height:A,display:"block"}})})()]})})()})]})]})};Vt();import{jsx as bs}from"react/jsx-runtime";var ql=()=>{let t=Mt("MOD"),e=W(g=>g.campaigns),o=W(g=>g.allCampaigns),n=W(g=>g.currentScreen),i=W(g=>g.userId),s=t??(()=>{let g=(n||"").trim().toLowerCase(),b=[...e||[],...o||[]].filter(h=>{if(!h||h.campaign_type!=="MOD"||!Ot(h,i))return!1;let T=!!(h.trigger_event??h.trigger);if(!(h.display_trigger!==!1&&!T))return!1;let X=(h.screen||"").trim().toLowerCase();return!X||X===g});if(b.length===0)return;let C=Lt(b)[0];if(C)try{return Kt(C)}catch{return C}})(),d=W(g=>g.isVisible),[c,l]=Ol(!1),y=jl(null);Nl(()=>{if(s?.id&&y.current!==s.id){y.current=s.id,l(!1);let g=s._variantId||s.details?.id,b=g?{variant_id:g}:void 0;st("viewed",s.id,b)}},[s?.id]);let u=g=>{try{let b=W.getState(),C=(b.trackedEvents||[]).filter(h=>h!==g);b.setTrackedEvents(C)}catch{}};if(!s||c||!d)return null;let m=()=>{s?.id&&u(`viaAppStorys${s.id}`),l(!0)},f=s.details?.modal_type||s.details?.modals?.[0]?.modal_type||"";return f==="full-page-modal"||f==="media-only-modal"?bs(hs,{campaign:s,onDismiss:m}):bs(ms,{campaign:s,onDismiss:m})};import{jsx as Hl}from"react/jsx-runtime";var Ul=({id:t,children:e})=>Hl("div",{"data-as-id":t,style:{display:"contents"},children:e});Vt();var Ti=class{state="uninitialized";navigateToScreen;async initialize(e){let{appId:o,accountId:n,userId:i}=e;if(this.navigateToScreen=e.navigateToScreen,this.state!=="initializing"){if(this.state==="initialized"){let s=W.getState();if(s.isAnonymousUser&&i&&i.trim()!==""){console.log("AppStorys: Reconciling anonymous user with identified user..."),await this.reconcileUser(s.userId,i,o,n);return}if(s.appId===o&&s.accountId===n&&s.userId===i)return}this.state="initializing";try{let s,d;if(!i||i.trim()==="")s=await rr(),d=!0;else{let m=await Xn();m&&m!==i&&console.log("AppStorys: Found previous anonymous user, will reconcile after verification."),s=i,d=!1}if(!await ke(n,o,s)){this.state="error";return}if(!d){let m=await Xn();m&&m!==s&&(await rn(m,s),await Jn())}try{let m=await Pt(),f=e.baseUrl||"https://users.appstorys.co";fetch(`${f}/v2/${n}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...m?{Authorization:`Bearer ${m}`}:{}},body:JSON.stringify({user_id:s,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})}).then(async P=>{if(P.ok)try{let g=await P.json(),b=W.getState();if(typeof g.screen_capture_enabled<"u"){let R=!!g.screen_capture_enabled;console.info("AppStorys: track-user-res returned screen_capture_enabled=",R),b.setScreenCaptureEnabled(R)}}catch{}}).catch(P=>console.warn("track-user-res (init) failed",P))}catch(m){console.warn("track-user-res (init) setup failed",m)}let{campaigns:l,version:y}=await Vn(n);try{Hi(l)}catch(m){console.warn("Failed to preload campaign fonts",m)}let u=W.getState();u.setAppId(o),u.setAccountId(n),u.setUserId(s),u.setIsAnonymousUser(d),u.setBaseUrl(e.baseUrl),u.setTrackingUrl(e.trackingUrl),u.saveAllCampaigns(l),u.setCampaignVersion(y);try{W.getState().screenCaptureEnabled&&(await Promise.resolve().then(()=>(Rs(),ks))).mountScreenCaptureButton()}catch(m){console.warn("Failed to mount screen capture button",m)}nr.setup(),Qn.setup(),this.state="initialized"}catch(s){this.state="error",console.error("AppStorys initialization failed:",s)}}}async reconcileUser(e,o,n,i){try{if(!await ke(i,n,o)){console.error("AppStorys: Failed to verify identified user account during reconciliation.");return}if(!await rn(e,o)){console.error("AppStorys: Failed to reconcile anonymous and identified users.");return}await Jn();let c=W.getState();c.setUserId(o),c.setIsAnonymousUser(!1)}catch(s){console.error("AppStorys: Error during user reconciliation:",s)}}async trackScreen(e){return await this.ensureInitialized(),jn(e)}async trackEvent(e,o,n){return await this.ensureInitialized(),st(e,o,n)}async setUserProperties(e){return await this.ensureInitialized(),qn(e)}handleLink(e){if(e&&!wt(e)){if(typeof e=="string"){try{if(!e.startsWith("http")&&qt(e))return}catch(o){console.warn("revealCampaignFromLink error",o)}e.startsWith("http")?window.open(e,"_blank"):this.navigateToScreen?.(e)}else if(typeof e=="object"&&e.value){if(wt(e.value))return;try{if(qt(e.value))return}catch{}this.navigateToScreen?.(e.value)}}}get visibility(){return W.getState().isVisible}set visibility(e){Qn.updateVisibility(e)}async ensureInitialized(){if(this.state==="initialized")return;let e=Date.now();for(;this.state!=="initialized";){if(this.state==="error")throw new Error("AppStorys SDK error");if(Date.now()-e>1e4)throw new Error("AppStorys SDK initialization timeout");await new Promise(o=>setTimeout(o,100))}}personalizeText(e){return Le(e)}Widget=yn;Widgets=yn},Lm=new Ti;export{Lm as AppStorys,zs as BASE_OVERLAY_Z_INDEX,Vs as Banner,dl as BottomSheet,vl as Csat,zi as DEFAULT_OVERLAY_PRIORITIES,aa as Floater,ql as Modal,Zs as Pip,Ii as SdkState,Qa as Story,Bl as Survey,rl as Tooltip,Ul as Trackable,yn as Widget,yn as Widgets,Bs as compareCampaignPriority,id as getCampaignVariantId,Et as getCampaignZIndex,Ei as getVariantId,Ho as hasVariants,zn as parseCampaignPriority,Le as personalizeText,Kt as resolveCampaignVariant,Ps as selectVariantByWeight,Lt as sortCampaignsByPriority};
165
165
  //# sourceMappingURL=index.mjs.map