@appstorys/react-web 1.1.0 → 1.1.1

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 Yi=Object.defineProperty;var Nt=(t,e)=>()=>(t&&(e=t(t=0)),e);var Qi=(t,e)=>{for(var o in e)Yi(t,o,{get:e[o],enumerable:!0})};var tt,Kt=Nt(()=>{"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{}}}});import{create as Gi}from"zustand";function kt(){return lo.getState().userId}async function dt(){return tt.getItem("access_token")}function mn(t){if(!t)return;let e=String(t||"").trim();if(e)return lo.getState().variantMappings?.[e]}var lo,F,K=Nt(()=>{"use strict";Kt();lo=Gi(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})}));F=lo});async function qt(){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 Ae=Nt(()=>{"use strict"});async function Et(t,e,o){try{let i={account_id:t,app_id:e,user_id:o};if(await tt.getItem(hn))console.log("Device info already sent previously - skipping");else{let c=await qt();i.attributes={...c},console.log("First time verification - including device info in attributes")}let s=F.getState().baseUrl||"https://users.appstorys.co",a=await fetch(`${s}/${t}/validate-account`,{method:"POST",body:JSON.stringify(i),headers:{Accept:"application/json","Content-Type":"application/json"}});if(console.log("Verify account body",i),console.log("Verifying account",a.status,a.statusText),a.ok){let c=await a.json();console.log("Account verified",c);let{access_token:u,refresh_token:x}=c;if(u&&x)return await tt.setItem("access_token",u),await tt.setItem("refresh_token",x),i.attributes&&(await tt.setItem(hn,"true"),console.log("Device info sent flag set")),!0}return!1}catch(i){return console.error("Error when verifying AppStorys account",i),!1}}var hn,Ee=Nt(()=>{"use strict";Kt();Ae();K();hn="device_info_sent"});async function Ze(t,e){if(!e||e.length===0){console.info("AppStorys: identifyWidgetPositions called with empty positionList; skipping");return}let o=await dt();if(!o){console.error("AppStorys: identifyWidgetPositions - access token not found");return}try{let i="https://backend.appstorys.co/api/v2/appinfo/identify-positions/";console.info("AppStorys: identifyWidgetPositions payload",{screen_name:t,position_list:e});let n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`,Accept:"application/json"},body:JSON.stringify({screen_name:t,position_list:e})});n.ok?console.info("AppStorys: identifyWidgetPositions OK"):console.error("AppStorys: identifyWidgetPositions failed",n.status,await n.text())}catch(i){console.error("AppStorys: identifyWidgetPositions error",i)}}var Di=Nt(()=>{"use strict";K()});function to(t){return t&&(t.startsWith("widget_")?t:`widget_${t}`)}function $i(){try{let t=F.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 i=o.details;typeof i=="object"&&(i.id&&typeof i.id=="string"&&e.push(String(i.id)),i.variants&&typeof i.variants=="object"&&Object.values(i.variants).forEach(n=>{n&&n.id&&typeof n.id=="string"&&e.push(String(n.id))}))}}catch{}}),e.filter(o=>!!o).map(o=>to(String(o))).filter(o=>!!o)}catch{return[]}}function $s(t){try{let e=$i();if(!e||e.length===0)return[];let o=[];return e.forEach(i=>{let n=i.replace(/^widget_/,""),r=[`[data-as-id="${n}"]`,`#${n}`,`.${n}`,`[data-widget="${n}"]`],s=null;for(let a of r)if(s=document.querySelector(a),s)break;if(s){let a=s.getBoundingClientRect(),c={x:Math.round(a.left),y:Math.round(a.top),width:Math.round(a.width),height:Math.round(a.height),screenWidth:window.innerWidth,screenHeight:window.innerHeight};Qt.addLayoutInfo(t,n,c),o.push(n)}}),console.info("AppStorys: mapServerPositionsToDOM mapped",o.length,"server positions to DOM elements",o),o}catch(e){return console.warn("AppStorys: mapServerPositionsToDOM error",e),[]}}function Ws(t){return ke[t]||(ke[t]=[]),ke[t]}function _i(t,e,o,i){let n=new FormData,r=t.replace(/[^a-z0-9]/gi,"_"),s=`screenshot_${e}_${r}_${Date.now()}.png`,a=new File([i],s,{type:"image/png"});n.append("screenName",t),n.append("user_id",e),n.append("children",o),n.append("screenshot",a);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:",a.name,`(${a.size} bytes)`),console.groupEnd()}catch(c){console.warn("AppStorys: Could not run FormData diagnostics",c)}return n}var ke,Qt,Wi=Nt(()=>{"use strict";K();Ee();Di();K();ke={};Qt=class{static setup(e,o){let i=F.getState();i.setScreenCaptureEnabled(o),i.setCurrentScreen(e)}static addLayoutInfo(e,o,i){let n=Ws(e),r=n.findIndex(c=>c.id===o),s={...i,screenWidth:i.screenWidth||window.innerWidth,screenHeight:i.screenHeight||window.innerHeight},a={id:o,frame:s};r>=0?n[r]=a:n.push(a)}static collectElements(e){this.clearLayoutData(e);let o=document.querySelectorAll("[data-as-id]"),i=window.innerWidth,n=window.innerHeight,r=[];o.forEach(s=>{let a=s.getAttribute("data-as-id");if(a){r.push(a);let c=s.getBoundingClientRect();this.addLayoutInfo(e,a,{x:Math.round(c.left),y:Math.round(c.top),width:Math.round(c.width),height:Math.round(c.height),screenWidth:i,screenHeight:n})}}),console.info(`AppStorys: Identified ${o.length} elements:`,r)}static clearLayoutData(e){ke[e]=[]}static getLayoutData(e){return ke[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),F.getState().setCurrentScreen(e),this.collectElements(e);try{let g=$s(e);g&&g.length>0&&console.info("AppStorys: mapServerPositionsToDOM added",g.length,"elements")}catch{}await new Promise(g=>setTimeout(g,100));let n=window,r=null;if(typeof n.html2canvas!="function")try{await new Promise((g,v)=>{let f=document.createElement("script");f.src="https://html2canvas.hertzen.com/dist/html2canvas.min.js",f.onload=()=>g(),f.onerror=()=>v(new Error("Failed to load html2canvas")),document.head.appendChild(f)})}catch(g){console.warn("AppStorys: html2canvas load error",g)}if(typeof n.html2canvas=="function")try{let g=await n.html2canvas(document.documentElement,{useCORS:!0,allowTaint:!0,logging:!1,scale:window.devicePixelRatio||1});r=await new Promise(v=>g.toBlob(f=>v(f),"image/png"))}catch(g){console.warn("AppStorys: html2canvas capture failed (falling back to getDisplayMedia)",g),r=null}if(!r&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)try{let g=await navigator.mediaDevices.getDisplayMedia({video:!0}),v=document.createElement("video");v.srcObject=g,await v.play();let f=document.createElement("canvas");f.width=v.videoWidth||window.innerWidth,f.height=v.videoHeight||window.innerHeight;let b=f.getContext("2d");b&&b.drawImage(v,0,0,f.width,f.height),r=await new Promise(h=>f.toBlob(y=>h(y),"image/png")),v.pause(),g.getTracks().forEach(h=>h.stop())}catch(g){console.warn("AppStorys: getDisplayMedia capture failed",g)}if(!r)return console.warn("AppStorys: Capture failed \u2014 no blob generated"),!1;let s=await dt(),a=kt();if(!a)return console.warn("AppStorys: No userId"),!1;if(!s){let g=F.getState();g.accountId&&g.appId&&g.userId&&await Et(g.accountId,g.appId,g.userId)&&(s=await dt())}if(!s)return console.warn("AppStorys: No token available"),!1;let c="https://backend.appstorys.co/api/v1/appinfo/identify-elements/",u=JSON.stringify(this.getLayoutData(e)||[]),x=_i(e,a,u,r);console.info("AppStorys: Sending identify-elements with payload size:",u.length);let m=await fetch(c,{method:"POST",headers:{Authorization:`Bearer ${s}`,Accept:"application/json"},body:x});if(m.status===401){console.warn("AppStorys: 401 response \u2014 retrying once");let g=F.getState();if(g.accountId&&g.appId&&g.userId&&await Et(g.accountId,g.appId,g.userId)){let f=await dt();f&&(m=await fetch(c,{method:"POST",headers:{Authorization:`Bearer ${f}`,Accept:"application/json"},body:_i(e,a,u,r)}))}}if(!m.ok){let g=await m.text();return console.error("AppStorys: identify-elements failed",m.status,g),!1}console.info("AppStorys: identify-elements success \u2713");try{let g=o,v=[];!g||g.length===0?v=(this.getLayoutData(e)||[]).map(y=>to(y.id)).filter(y=>!!y):v=g.map(h=>to(h)).filter(h=>!!h);let f=$i(),b=Array.from(new Set([...v,...f]));console.info("AppStorys: identifyWidgetPositions will send",b.length,"positions (collected + server)",b),await Ze(e,b)}catch(g){console.warn("AppStorys: identifyWidgetPositions failed",g)}return!0}catch(i){return console.error("AppStorys: takeScreenshot error",i),!1}}};(function(){try{let e=window;e.AppStorysForceIdentifyPositions=async o=>{let i=F.getState(),n=o||i.currentScreen;if(!n){console.warn("AppStorys: AppStorysForceIdentifyPositions - no screen name available");return}let s=(Qt.getLayoutData(n)||[]).map(a=>to(a.id)).filter(a=>!!a);console.info("AppStorys: AppStorysForceIdentifyPositions sending",s.length,"positions for",n,s);try{await Ze(n,s),console.info("AppStorys: AppStorysForceIdentifyPositions completed")}catch(a){console.error("AppStorys: AppStorysForceIdentifyPositions error",a)}}}catch{}})()});var Oi={};Qi(Oi,{mountScreenCaptureButton:()=>Mi});function Ms(){if(document.getElementById("appstorys-capture-styles"))return;let t=document.createElement("style");t.id="appstorys-capture-styles",t.innerHTML=`
1
+ var Br=Object.defineProperty;var le=(t,e)=>()=>(t&&(e=t(t=0)),e);var Lr=(t,e)=>{for(var o in e)Br(t,o,{get:e[o],enumerable:!0})};var ct,Se=le(()=>{"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 Mr}from"zustand";function Dt(){return Po.getState().userId}async function bt(){return ct.getItem("access_token")}function Gn(t){if(!t)return;let e=String(t||"").trim();if(e)return Po.getState().variantMappings?.[e]}var Po,A,ot=le(()=>{"use strict";Se();Po=Mr(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})}));A=Po});async function de(){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 to=le(()=>{"use strict"});async function Ht(t,e,o){try{let i={account_id:t,app_id:e,user_id:o};if(await ct.getItem(ti))console.log("Device info already sent previously - skipping");else{let c=await de();i.attributes={...c},console.log("First time verification - including device info in attributes")}let l=A.getState().baseUrl||"https://users.appstorys.co",d=await fetch(`${l}/${t}/validate-account`,{method:"POST",body:JSON.stringify(i),headers:{Accept:"application/json","Content-Type":"application/json"}});if(console.log("Verify account body",i),console.log("Verifying account",d.status,d.statusText),d.ok){let c=await d.json();console.log("Account verified",c);let{access_token:y,refresh_token:b}=c;if(y&&b)return await ct.setItem("access_token",y),await ct.setItem("refresh_token",b),i.attributes&&(await ct.setItem(ti,"true"),console.log("Device info sent flag set")),!0}return!1}catch(i){return console.error("Error when verifying AppStorys account",i),!1}}var ti,eo=le(()=>{"use strict";Se();to();ot();ti="device_info_sent"});async function Eo(t,e){if(!e||e.length===0){console.info("AppStorys: identifyWidgetPositions called with empty positionList; skipping");return}let o=await bt();if(!o){console.error("AppStorys: identifyWidgetPositions - access token not found");return}try{let i="https://backend.appstorys.co/api/v2/appinfo/identify-positions/";console.info("AppStorys: identifyWidgetPositions payload",{screen_name:t,position_list:e});let n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`,Accept:"application/json"},body:JSON.stringify({screen_name:t,position_list:e})});n.ok?console.info("AppStorys: identifyWidgetPositions OK"):console.error("AppStorys: identifyWidgetPositions failed",n.status,await n.text())}catch(i){console.error("AppStorys: identifyWidgetPositions error",i)}}var vr=le(()=>{"use strict";ot()});function Do(t){return t&&(t.startsWith("widget_")?t:`widget_${t}`)}function Va(){try{let t=A.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 i=o.details;typeof i=="object"&&(i.id&&typeof i.id=="string"&&e.push(String(i.id)),i.variants&&typeof i.variants=="object"&&Object.values(i.variants).forEach(n=>{n&&n.id&&typeof n.id=="string"&&e.push(String(n.id))}))}}catch{}}),e.filter(o=>!!o).map(o=>Do(String(o))).filter(o=>!!o)}catch{return[]}}function Ua(t){try{let e=Va();if(!e||e.length===0)return[];let o=[];return e.forEach(i=>{let n=i.replace(/^widget_/,""),r=[`[data-as-id="${n}"]`,`#${n}`,`.${n}`,`[data-widget="${n}"]`],l=null;for(let d of r)if(l=document.querySelector(d),l)break;if(l){let d=l.getBoundingClientRect(),c={x:Math.round(d.left),y:Math.round(d.top),width:Math.round(d.width),height:Math.round(d.height),screenWidth:window.innerWidth,screenHeight:window.innerHeight};me.addLayoutInfo(t,n,c),o.push(n)}}),console.info("AppStorys: mapServerPositionsToDOM mapped",o.length,"server positions to DOM elements",o),o}catch(e){return console.warn("AppStorys: mapServerPositionsToDOM error",e),[]}}function Ya(t){return Qe[t]||(Qe[t]=[]),Qe[t]}function wr(t,e,o,i){let n=new FormData,r=t.replace(/[^a-z0-9]/gi,"_"),l=`screenshot_${e}_${r}_${Date.now()}.png`,d=new File([i],l,{type:"image/png"});n.append("screenName",t),n.append("user_id",e),n.append("children",o),n.append("screenshot",d);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:",d.name,`(${d.size} bytes)`),console.groupEnd()}catch(c){console.warn("AppStorys: Could not run FormData diagnostics",c)}return n}var Qe,me,kr=le(()=>{"use strict";ot();eo();vr();ot();Qe={};me=class{static setup(e,o){let i=A.getState();i.setScreenCaptureEnabled(o),i.setCurrentScreen(e)}static addLayoutInfo(e,o,i){let n=Ya(e),r=n.findIndex(c=>c.id===o),l={...i,screenWidth:i.screenWidth||window.innerWidth,screenHeight:i.screenHeight||window.innerHeight},d={id:o,frame:l};r>=0?n[r]=d:n.push(d)}static collectElements(e){this.clearLayoutData(e);let o=document.querySelectorAll("[data-as-id]"),i=window.innerWidth,n=window.innerHeight,r=[];o.forEach(l=>{let d=l.getAttribute("data-as-id");if(d){r.push(d);let c=l.getBoundingClientRect();this.addLayoutInfo(e,d,{x:Math.round(c.left),y:Math.round(c.top),width:Math.round(c.width),height:Math.round(c.height),screenWidth:i,screenHeight:n})}}),console.info(`AppStorys: Identified ${o.length} elements:`,r)}static clearLayoutData(e){Qe[e]=[]}static getLayoutData(e){return Qe[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),A.getState().setCurrentScreen(e),this.collectElements(e);try{let f=Ua(e);f&&f.length>0&&console.info("AppStorys: mapServerPositionsToDOM added",f.length,"elements")}catch{}await new Promise(f=>setTimeout(f,100));let n=window,r=null;if(typeof n.html2canvas!="function")try{await new Promise((f,v)=>{let S=document.createElement("script");S.src="https://html2canvas.hertzen.com/dist/html2canvas.min.js",S.onload=()=>f(),S.onerror=()=>v(new Error("Failed to load html2canvas")),document.head.appendChild(S)})}catch(f){console.warn("AppStorys: html2canvas load error",f)}if(typeof n.html2canvas=="function")try{let f=await n.html2canvas(document.documentElement,{useCORS:!0,allowTaint:!0,logging:!1,scale:window.devicePixelRatio||1});r=await new Promise(v=>f.toBlob(S=>v(S),"image/png"))}catch(f){console.warn("AppStorys: html2canvas capture failed (falling back to getDisplayMedia)",f),r=null}if(!r&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)try{let f=await navigator.mediaDevices.getDisplayMedia({video:!0}),v=document.createElement("video");v.srcObject=f,await v.play();let S=document.createElement("canvas");S.width=v.videoWidth||window.innerWidth,S.height=v.videoHeight||window.innerHeight;let u=S.getContext("2d");u&&u.drawImage(v,0,0,S.width,S.height),r=await new Promise(m=>S.toBlob(g=>m(g),"image/png")),v.pause(),f.getTracks().forEach(m=>m.stop())}catch(f){console.warn("AppStorys: getDisplayMedia capture failed",f)}if(!r)return console.warn("AppStorys: Capture failed \u2014 no blob generated"),!1;let l=await bt(),d=Dt();if(!d)return console.warn("AppStorys: No userId"),!1;if(!l){let f=A.getState();f.accountId&&f.appId&&f.userId&&await Ht(f.accountId,f.appId,f.userId)&&(l=await bt())}if(!l)return console.warn("AppStorys: No token available"),!1;let c="https://backend.appstorys.co/api/v1/appinfo/identify-elements/",y=JSON.stringify(this.getLayoutData(e)||[]),b=wr(e,d,y,r);console.info("AppStorys: Sending identify-elements with payload size:",y.length);let h=await fetch(c,{method:"POST",headers:{Authorization:`Bearer ${l}`,Accept:"application/json"},body:b});if(h.status===401){console.warn("AppStorys: 401 response \u2014 retrying once");let f=A.getState();if(f.accountId&&f.appId&&f.userId&&await Ht(f.accountId,f.appId,f.userId)){let S=await bt();S&&(h=await fetch(c,{method:"POST",headers:{Authorization:`Bearer ${S}`,Accept:"application/json"},body:wr(e,d,y,r)}))}}if(!h.ok){let f=await h.text();return console.error("AppStorys: identify-elements failed",h.status,f),!1}console.info("AppStorys: identify-elements success \u2713");try{let f=o,v=[];!f||f.length===0?v=(this.getLayoutData(e)||[]).map(u=>Do(u.id)).filter(u=>!!u):v=f.map(S=>Do(S)).filter(S=>!!S),console.info("AppStorys: identifyWidgetPositions will send",v.length,"positions (DOM-verified)",v),await Eo(e,v)}catch(f){console.warn("AppStorys: identifyWidgetPositions failed",f)}return!0}catch(i){return console.error("AppStorys: takeScreenshot error",i),!1}}};(function(){try{let e=window;e.AppStorysForceIdentifyPositions=async o=>{let i=A.getState(),n=o||i.currentScreen;if(!n){console.warn("AppStorys: AppStorysForceIdentifyPositions - no screen name available");return}let l=(me.getLayoutData(n)||[]).map(d=>Do(d.id)).filter(d=>!!d);console.info("AppStorys: AppStorysForceIdentifyPositions sending",l.length,"positions for",n,l);try{await Eo(n,l),console.info("AppStorys: AppStorysForceIdentifyPositions completed")}catch(d){console.error("AppStorys: AppStorysForceIdentifyPositions error",d)}}}catch{}})()});var Tr={};Lr(Tr,{mountScreenCaptureButton:()=>Rr});function Qa(){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 Yi=Object.defineProperty;var Nt=(t,e)=>()=>(t&&(e=t(t=0)),e);var Qi=(t,e)=>{
11
11
  border-radius: 50%;
12
12
  animation: appstorys-spin 0.8s linear infinite;
13
13
  }
14
- `,document.head.appendChild(t)}function Os(){Ms();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 Mi(){try{let t=F.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 i=Os();return i.addEventListener("click",async()=>{i.disabled=!0;let n=i.innerText;i.innerHTML='<div class="appstorys-spinner"></div>';let s=F.getState().currentScreen||(typeof window<"u"?window.location.pathname:"");try{await Qt.takeScreenshot(s)}catch(a){console.error("CaptureService error",a)}i.disabled=!1,i.innerText=n,i.animate([{transform:"scale(1.0)"},{transform:"scale(1.05)"},{transform:"scale(1.0)"}],{duration:300})}),document.body.appendChild(i),console.info("AppStorys: screen capture button mounted"),i}catch(t){return console.error("mountScreenCaptureButton error",t),null}}var ji=Nt(()=>{"use strict";K();Wi();try{window.AppStorysMountCapture=function(){try{return Mi()}catch(t){return console.error("AppStorysMountCapture failed",t),null}}}catch{}try{window.AppStorysDebugState=function(){try{let t=F.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 i=t.split(".");if(i.length===3){let n=JSON.parse(atob(i[1]));if(console.info("Token payload:",n),n.exp){let r=new Date(n.exp*1e3),s=new Date;console.info("Token expires:",r.toISOString(),"Expired:",s>r)}}}catch(i){console.warn("Could not decode JWT:",i)}return t?"Token present":"No token"}catch(t){return console.error("AppStorysDebugToken failed",t),null}}}catch{}});var fn=(n=>(n.uninitialized="uninitialized",n.initializing="initializing",n.initialized="initialized",n.error="error",n))(fn||{});K();import{useState as _e,useEffect as vn,useRef as sr}from"react";import*as Zt from"lottie-react";K();import{useMemo as Xi}from"react";K();var Ji=t=>F.getState().variantMappings[t];function co(t){return!!(t.details&&typeof t.details=="object"&&"variants"in t.details)}function yt(t){if(!co(t))return t;let e=Ji(t.id||"");if(!e)return t;let o=t.details?.variants;if(!o||typeof o!="object")return t;let i=o[e];if(!i)return t;let n=typeof t.details=="object"?Object.fromEntries(Object.entries(t.details).filter(([s])=>s!=="variants")):{};return{...t,details:{...n,...i},_variantId:e}}var Be="__back_press_triggered__";function yn(t){return(t||"").trim().toLowerCase()}function Ki(t,e){let o=yn(t),i=yn(e);return!o||o===i}function Zi(t,e,o){let i=Number(t),n=Number(o),r=!isNaN(i)&&!isNaN(n);switch(e){case"eq":return r?i===n:t===o;case"neq":return r?i!==n:t!==o;case"gt":return r?i>n:t>o;case"gte":return r?i>=n:t>=o;case"lt":return r?i<n:t<o;case"lte":return r?i<=n:t<=o;default:return!1}}function tr(t,e){let o=t.filter(i=>i.back_press==null);return o.length===0?!0:e.some(i=>o.every(n=>{let r=i[n.key];return r==null?!1:Zi(String(r),n.operator,n.value)}))}function er(t,e,o){let i=t,n=i.trigger_event??i.trigger,r=t.id;return!n}function po(){let{campaigns:t,trackedEvents:e,trackedEventMetadata:o,currentScreen:i}=F.getState();return t.some(n=>{if(n.screen&&n.screen!==i)return!1;let r=n.trigger_event;if(!r||typeof r=="string")return!1;let{event:s,event_config:a}=r;if(!(a??[]).some(x=>x.back_press===!0)||e.includes(Be)||!e.includes(s))return!1;let c=(a??[]).filter(x=>x.back_press==null);if(c.length===0)return!0;let u=o[s]||[];return tr(c,u)})}function pt(t,e){let o=F(c=>c.currentScreen),i=F(c=>c.campaigns),n=F(c=>c.allCampaigns),r=F(c=>c.trackedEvents),s=F(c=>c.trackedEventMetadata),a=F(c=>c.variantMappings);return Xi(()=>{let c=m=>m.find(g=>Ki(g.screen,o)&&g.campaign_type===t&&(e?.position?g.position===e.position:!0)&&er(g,r,s)),x=(i&&i.length>0?c(i):void 0)??c(n||[]);if(x)return yt(x)},[i,n,r,s,a,t,e,o])}K();Ae();Kt();K();Ee();var bn="appstorys_offline_queue";async function xn(){let t=await tt.getItem(bn);return t?JSON.parse(t):[]}async function Sn(t){await tt.setItem(bn,JSON.stringify(t))}function or(t){return Math.min(3e4*Math.pow(2,t),12e4)}function nr(t){let o=t.retryCount||0,i=t.lastAttempt||0,n=or(o);return o<3&&Date.now()-i>=n}async function ir(){let t=F.getState();return!t.accountId||!t.appId?!1:await Et(t.accountId,t.appId,t.userId)}async function Cn(t,e){if(await ir()){let i=await tt.getItem("access_token");i&&(t.headers={...t.headers,Authorization:`Bearer ${i}`}),t.authRetried=!0,t.lastAttempt=Date.now(),e(t)}}async function Le(t,e){let o=(t.retryCount||0)+1;o<=3&&(t.retryCount=o,t.lastAttempt=Date.now(),e(t))}async function Pe(t){let e=await xn();e.push(t),await Sn(e)}async function rr(){let t=await xn();if(t.length===0)return;let e=[];for(let o of t){if(!nr(o)){e.push(o);continue}try{let i=await fetch(o.url,{method:o.method,headers:o.headers,body:JSON.stringify(o.body)});if(i.ok)continue;i.status===401||i.status===403?o.authRetried||await Cn(o,n=>e.push(n)):i.status>=500&&await Le(o,n=>e.push(n))}catch{await Le(o,n=>e.push(n))}}await Sn(e)}async function De(t){if(!navigator.onLine){await Pe(t);return}await rr();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 Cn(t,Pe):e.status>=500&&await Le(t,Pe)),e}catch{await Le(t,Pe);return}}async function H(t,e,o){try{if(!t)return;let i=await dt(),n=F.getState(),r=["viewed","clicked","csat captured","survey captured","shared"];if(!r.includes(t)){let u=n.trackedEvents;if(!u.includes(t))n.setTrackedEvents([...u,t]);else{let x=u.filter(m=>m!==t);x.push(t),n.setTrackedEvents(x)}if(o&&Object.keys(o).length>0){let x=n.trackedEventMetadata||{},m=x[t]||[];n.setTrackedEventMetadata({...x,[t]:[...m,o]})}}let s={...o||{}};if(!r.includes(t)){let u=await qt();s={...s,...u}}if(e&&String(e).trim()!==""){let u=mn(e);u&&(s.variant_id=u)}let a={user_id:kt(),event:t,metadata:s};e&&(a.campaign_id=e);let c=n.trackingUrl||"https://tracking.appstorys.co";i&&await De({url:`${c}/capture-event`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:a})}catch(i){console.error("Error in trackEvent",i)}}K();function ht(t){if(!t)return!1;let e=F.getState(),o=e.allCampaigns||[],i=e.campaigns||[],n=String(t).trim(),r=o.find(c=>{if(!c)return!1;let u=String(c.id||"").trim(),x=c.details||{},m=String(x.campaign||x.id||"").trim();return!!(u&&u===n||m&&m===n||u&&n.includes(u)||m&&n.includes(m))});if(!r)return!1;let s={...r};delete s.trigger_event,delete s.trigger,s.display_trigger=!0;let a=i.findIndex(c=>String(c.id||"")===String(s.id||""));if(a===-1)e.saveCampaigns([s,...i]);else{let c=i[a];if(!!(c.trigger_event??c.trigger)){let x=[...i];x[a]=s,e.saveCampaigns(x)}}return!0}import{jsx as uo,jsxs as lr}from"react/jsx-runtime";var wn=Zt.default?.default??Zt.default??Zt.Lottie??Zt,ar=()=>{let t=pt("BAN"),e=F(w=>w.isVisible),[o,i]=_e(!1),[n,r]=_e(null),[s,a]=_e(null),c=sr(null),[u,x]=_e(0);if(vn(()=>{t&&(i(!1),H("viewed",t.id),t.details.lottie_data&&fetch(t.details.lottie_data).then(w=>w.json()).then(w=>{r(w),w.w&&w.h&&a(w.h/w.w)}).catch(w=>console.error("Error loading Lottie:",w)))},[t]),vn(()=>{let w=()=>{c.current&&x(c.current.offsetWidth)};return w(),window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[t,o]),!t||o||!e)return null;let{details:m}=t,g=m.styling||{},v=m.height||"auto";s&&u&&(v=u*s);let f={position:"fixed",left:g.marginLeft?`${g.marginLeft}px`:"10px",right:g.marginRight?`${g.marginRight}px`:"10px",bottom:g.marginBottom?`${g.marginBottom}px`:"10px",backgroundColor:"transparent",borderRadius:`${g.topRightRadius||0}px ${g.topLeftRadius||0}px ${g.bottomRightRadius||0}px ${g.bottomLeftRadius||0}px`,overflow:"hidden",zIndex:9999,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:m.link?"pointer":"default"},b={width:"100%",height:typeof v=="number"?`${v}px`:v,display:"block",objectFit:"cover"},h=w=>{w.stopPropagation(),i(!0),H("banner_closed",t.id)};return lr("div",{ref:c,style:f,onClick:()=>{if(m.link)if(H("clicked",t.id),m.link.startsWith("http"))window.open(m.link,"_blank");else{try{if(ht(m.link))return}catch(w){console.warn("revealCampaignFromLink error",w)}console.log("Internal link:",m.link)}},children:[n?(()=>{let w=wn.default||wn;return uo(w,{animationData:n,loop:!0,autoplay:e,style:b})})():m.image?uo("img",{src:m.image,alt:"Campaign Banner",style:b}):null,g.crossButton?.enabled&&uo("button",{onClick:h,style:{position:"absolute",top:"5px",right:"5px",background:"rgba(0,0,0,0.3)",color:"white",border:"none",borderRadius:"50%",width:"24px",height:"24px",lineHeight:"22px",textAlign:"center",cursor:"pointer",padding:"0",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10},children:"\u2715"})]})};import{useEffect as fo,useMemo as Fn,useRef as In,useState as pe}from"react";K();function We(t){let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")}function kn(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 Rn(t,e){if(typeof document>"u")return;let o=`appstorys-font-${t}`;if(document.getElementById(o))return;let i=document.createElement("style");i.id=o,i.type="text/css",i.textContent=`@font-face{font-family:"${t}";src:url("${e}");font-style:normal;font-weight:normal;font-display:swap;}`,document.head.appendChild(i)}var $e=new Map;async function dr(t,e){try{Rn(e.name,t);let o=globalThis.FontFace;if(typeof document<"u"&&o&&document.fonts?.add){let i=new o(e.name,`url(${t})`);await i.load(),document.fonts.add(i)}else typeof document<"u"&&document.fonts?.load&&await document.fonts.load(`1em "${e.name}"`);e.status="loaded",e.listeners.forEach(i=>i(e.name))}catch(o){console.warn(`[FontManager] Failed to load font from "${t}":`,o),e.status="failed",e.listeners.forEach(i=>i(void 0))}finally{e.listeners=[]}}var go={async load(t){if(!t||!We(t))return;let e=$e.get(t);if(e)return e.status==="loaded"?e.name:e.status==="failed"?void 0:new Promise(r=>e.listeners.push(r));let i={status:"pending",name:kn(t),listeners:[]};$e.set(t,i);let n=new Promise(r=>i.listeners.push(r));return dr(t,i),n},ensure(t){if(!t||!We(t))return;let e=kn(t);return Rn(e,t),go.load(t),e},getSync(t){if(!t)return;let e=$e.get(t);return e?.status==="loaded"?e.name:void 0},_clearCache(){$e.clear()}};function ct(t){if(t)return We(t)?go.ensure(t):t}function cr(t){let e=new Set,o=new WeakSet,i=n=>{if(n!=null&&typeof n!="string"){if(Array.isArray(n)){for(let r of n)i(r);return}if(typeof n=="object"){if(o.has(n))return;o.add(n);for(let[r,s]of Object.entries(n))r==="fontFamily"&&typeof s=="string"&&We(s)&&e.add(s),i(s)}}};return i(t),Array.from(e)}async function Tn(t){let e=new Set;for(let o of t)cr(o).forEach(i=>e.add(i));await Promise.all(Array.from(e).map(o=>go.load(o)))}import{jsx as at,jsxs as Ut}from"react/jsx-runtime";var mo=t=>(t||"").trim().toLowerCase(),It=(t,e)=>{let o=Number(t);return Number.isFinite(o)?o:e};function pr({iconType:t,color:e}){let o=e||"#FFFFFF";return t==="close"?Ut("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[at("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:o,strokeWidth:"2.2",strokeLinecap:"round"}),at("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:o,strokeWidth:"2.2",strokeLinecap:"round"})]}):t==="expand"?Ut("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[at("polyline",{points:"8,3 3,3 3,8",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),at("line",{x1:"3",y1:"3",x2:"9",y2:"9",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),at("polyline",{points:"16,21 21,21 21,16",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),at("line",{x1:"15",y1:"15",x2:"21",y2:"21",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):t==="minimize"?Ut("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[at("polyline",{points:"9,9 3,9 3,3",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),at("line",{x1:"3",y1:"9",x2:"9",y2:"3",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),at("polyline",{points:"15,15 21,15 21,21",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),at("line",{x1:"15",y1:"21",x2:"21",y2:"15",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):t==="mute"?Ut("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[at("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:o,strokeWidth:"2",strokeLinejoin:"round"}),at("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),at("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):Ut("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[at("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:o,strokeWidth:"2",strokeLinejoin:"round"}),at("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),at("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]})}function yo({iconType:t,config:e,imageOverride:o,onClick:i}){let n=It(e?.size,18),r=Math.max(24,n+10),s=e?.margin||{},a=o||e?.image,c=e?.color?.cross||"#FFFFFF",u=e?.color?.fill||"rgba(0,0,0,0.55)",x=e?.color?.stroke||"rgba(255,255,255,0.35)";return at("button",{"data-control-button":"true",type:"button",onPointerDown:m=>{m.preventDefault(),m.stopPropagation()},onPointerUp:m=>{m.preventDefault(),m.stopPropagation()},onMouseDown:m=>{m.preventDefault(),m.stopPropagation()},onTouchStart:m=>{m.preventDefault(),m.stopPropagation()},onClick:m=>{m.preventDefault(),m.stopPropagation(),i()},title:e?.selectedStyle||t,style:{width:r,height:r,borderRadius:999,pointerEvents:"auto",zIndex:10030,position:"relative",border:`1px solid ${x}`,background:u,color:c,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,marginTop:It(s.top,0),marginRight:It(s.right,0),marginBottom:It(s.bottom,0),marginLeft:It(s.left,0)},children:a?at("img",{src:a,alt:t,style:{width:n,height:n,objectFit:"contain"}}):at(pr,{iconType:t,color:c})})}var ur=()=>{let t=pt("PIP"),e=F(q=>q.campaigns),o=F(q=>q.allCampaigns),i=F(q=>q.currentScreen),n=F(q=>q.isVisible),[r,s]=pe(!1),[a,c]=pe(!1),[u,x]=pe(!0),[m,g]=pe(!1),[v,f]=pe(null),b=In({x:0,y:0}),h=In(null),y=Fn(()=>{if(t)return t;let q=mo(i),Q=lt=>lt.find(mt=>{let nt=mt,Ct=nt.campaign_type==="PIP",gt=!mo(nt.screen)||mo(nt.screen)===q,vt=!!(nt.trigger_event??nt.trigger),jt=nt.display_trigger!==!1&&!vt;return Ct&&gt&&jt}),Y=Q(e)??Q(o);return Y?yt(Y):void 0},[t,e,o,i]),w=Fn(()=>y,[y?.id,y?.details?.id]);if(fo(()=>{if(!w)return;let q=w.details||{},Q=q?.styling?.soundToggle?.defaultSound||q?.styling?.appearance?.defaultSound||"yes";x(String(Q).toLowerCase()!=="yes"),s(!1),c(!1),f(null),H("viewed",w.id)},[w]),fo(()=>{h.current&&(h.current.muted=u)},[u]),fo(()=>{if(!m)return;let q=Y=>{let lt=Y.clientX-b.current.x,mt=Y.clientY-b.current.y;f({x:Math.max(0,lt),y:Math.max(0,mt)})},Q=()=>{g(!1)};return window.addEventListener("mousemove",q),window.addEventListener("mouseup",Q),()=>{window.removeEventListener("mousemove",q),window.removeEventListener("mouseup",Q)}},[m]),!w||!w.details||r||!n)return null;let I=w.details,z=I.styling||{},R=z.appearance||{},d=It(I.width??R.pipWidth,150),T=It(I.height??R.pipHeight,300),l=Math.max(d,T),p=Math.min(d,T),M=z.cta?.container||{},B=z.cta?.text||{},L=!!(I.button_text&&I.button_text.trim().length>0),C=It(z.cta?.container?.height,42),S=L?C+24:0,_=It(z.pipBottomPadding,20),E=It(z.pipTopPadding,0),$=a?I.large_video||I.small_video:I.small_video||I.large_video,D=(I.position||w.position||"right").toLowerCase(),k=!!z.isMovable,P=z.soundToggle?.enabled!==!1,O=z.crossButton?.enabled!==!1,G=z.expandControls?.enabled!==!1&&String(z.expandablePip||"yes").toLowerCase()==="yes",ut=z.crossButton,j=a?z.expandControls?.minimise:z.expandControls?.maximise,X=u?z.soundToggle?.mute:z.soundToggle?.unmute,J={position:"fixed",zIndex:10020,width:a?"100vw":l,height:a?"100vh":p,borderRadius:0,overflow:"hidden",background:"#000",boxShadow:"0 16px 40px rgba(0,0,0,0.35)",cursor:m?"grabbing":k&&!a?"grab":"default",transition:m?"none":"width 180ms ease, height 180ms ease, transform 180ms ease"};v&&!a?(J.left=v.x,J.top=v.y):a?(J.left=0,J.top=0,J.right=0,J.bottom=0):(D==="left"?J.left=24:J.right=24,E>0?J.top=E:J.bottom=_+20);let V=q=>{if(!k||a||q.target.closest("[data-control-button='true']"))return;let Y=q.currentTarget.getBoundingClientRect();b.current={x:q.clientX-Y.left,y:q.clientY-Y.top},f({x:Y.left,y:Y.top}),g(!0)},et=()=>{if(!I.link)return;H("clicked",w.id);let q=String(I.link).trim();try{let Q=F.getState(),Y=Q.allCampaigns||[],lt=Q.campaigns||[],mt=Y.find(nt=>nt.id===q);if(console.log("[Pip] clicked link=",q,"allCount=",Y.length,"visibleCount=",lt.length,"referenced=",!!mt),mt){let nt={...mt};delete nt.trigger_event,delete nt.trigger,nt.display_trigger=!0;let Ct=lt.findIndex(gt=>gt.id===nt.id);if(Ct===-1)Q.saveCampaigns([nt,...lt]);else{let gt=lt[Ct];if(!!(gt.trigger_event??gt.trigger)){let jt=[...lt];jt[Ct]=nt,Q.saveCampaigns(jt)}}return}}catch{}window.open(I.link,"_blank")};return $?Ut("div",{style:J,onMouseDown:V,children:[at("video",{ref:h,src:$,autoPlay:!0,loop:!0,playsInline:!0,muted:u,style:{width:"100%",height:a&&L?`calc(100% - ${S}px)`:"100%",objectFit:a?"contain":"cover"},onClick:et,onEnded:()=>{y&&H("analyze",y.id)}}),Ut("div",{style:{position:"absolute",top:8,right:8,display:"flex",gap:8,zIndex:2},children:[P&&at(yo,{iconType:u?"mute":"unmute",config:X,imageOverride:u?I.muteImage:I.unmuteImage,onClick:()=>x(q=>!q)}),G&&at(yo,{iconType:a?"minimize":"expand",config:j,imageOverride:a?I.minimiseImage:I.maximiseImage,onClick:()=>{console.log("[Pip] expand button clicked - isExpanded before:",a),c(q=>{let Q=!q;return Q&&w?.id&&(H("viewed",w.id),H("analyze",w.id)),Q})}}),O&&at(yo,{iconType:"close",config:ut,imageOverride:I.crossButtonImage,onClick:()=>s(!0)})]}),a&&L&&at("button",{"data-control-button":"true",onClick:et,style:{position:"absolute",left:12,right:12,bottom:12,height:M.height||42,width:M.ctaFullWidth?"auto":M.ctaWidth||"auto",margin:M.ctaFullWidth?"0":"0 auto",background:M.backgroundColor||"#F7921C",color:B.color||"#fff",border:`${M.borderWidth||0}px solid ${M.borderColor||"transparent"}`,borderRadius:10,fontSize:B.fontSize||14,fontFamily:ct(B.fontFamily),fontWeight:600,cursor:I.link?"pointer":"default"},children:I.button_text})]}):null};import gr,{useEffect as ho,useRef as bo,useState as Me}from"react";import{LottiePlayer as fr}from"lottie-react";K();import{jsx as te}from"react/jsx-runtime";var xt=(t,e=0)=>{let o=Number(t);return Number.isFinite(o)?o:e},xo=t=>(t||"").trim().toLowerCase(),mr="appstorysmediabucketdev.s3.ap-south-1.amazonaws.com",yr=t=>{try{if(typeof window>"u")return[t];let e=new URL(t);if(e.hostname!==mr)return[t];let o=!!window.location.port,i=`/appstorys-media${e.pathname}${e.search}`;return o?[i,t]:[t]}catch{return[t]}},hr=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"},So=class extends gr.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}},br=()=>{let[t,e]=Me(null),[o,i]=Me([]),[n,r]=Me(!1),[s,a]=Me(!1),c=bo(null),u=bo(null),x=pt("FLT"),m=F(C=>C.campaigns),g=F(C=>C.allCampaigns),v=F(C=>C.currentScreen),f=F(C=>C.isVisible),b=bo(null),h=x??(()=>{let C=[...m,...g].find(S=>{let _=S;if(_.campaign_type!=="FLT")return!1;let E=!!(_.trigger_event??_.trigger);return _.display_trigger===!1||E?!1:!xo(_.screen)||xo(_.screen)===xo(v)});if(C)try{return yt(C)}catch{return C}})(),y=h?.id,w=F(C=>y?C.variantMappings[y]:void 0);if(ho(()=>{if(!h?.id||!f||co(h)&&!w)return;let S=`${h.id}:${w||""}`;b.current!==S&&(b.current=S,H("viewed",h.id))},[h?.id,w,f]),ho(()=>{let C=h?.details?.lottie_data;if(e(null),i([]),r(!1),a(!1),!C)return;if(hr(C)){e(C),a(!0);return}if(typeof C!="string"){r(!0);return}let S=yr(C);i(S),a(!0)},[h?.details?.lottie_data]),ho(()=>{if(!h?.details?.lottie_data||!c.current)return;let C=fr;if(!C||typeof C.loadAnimation!="function"){r(!0),a(!1);return}let S=!1,_=null,E=()=>{_&&typeof _.destroy=="function"&&_.destroy(),_=null,u.current=null},$=(D,k)=>{if(S)return;if(k>=D.length){r(!0),a(!1),console.error("[Floater] lottie load failed",{lottieUrls:D});return}E();let P=C.loadAnimation({container:c.current,renderer:"svg",loop:!0,autoplay:!0,path:D[k]});_=P,u.current=P,P.addEventListener("DOMLoaded",()=>{S||a(!1)}),P.addEventListener("data_failed",()=>{S||$(D,k+1)})};if(t){E();let D=C.loadAnimation({container:c.current,renderer:"svg",loop:!0,autoplay:!0,animationData:t});_=D,u.current=D,D.addEventListener("DOMLoaded",()=>{S||a(!1)}),D.addEventListener("data_failed",()=>{S||(r(!0),a(!1))})}else o.length>0&&$(o,0);return()=>{S=!0,E()}},[h?.details?.lottie_data,t,o]),!h||!h.details||!f)return null;let{details:I}=h,z=I.styling||{},d=(typeof I.position=="string"?I.position:typeof h.position=="string"?h.position:"right").toLowerCase()==="left"?"left":"right",T={position:"fixed",left:d==="left"?xt(z.marginLeft,12):void 0,right:d==="left"?void 0:xt(z.marginRight,12),top:xt(z.marginTop,0)>0?xt(z.marginTop,0):void 0,bottom:xt(z.marginTop,0)>0?void 0:xt(z.marginBottom,80),zIndex:10040,display:"flex"},l={width:xt(I.width,60),height:xt(I.height,60),background:"transparent",overflow:"hidden",borderBottomLeftRadius:xt(z.bottomLeftRadius,0),borderBottomRightRadius:xt(z.bottomRightRadius,0),borderTopLeftRadius:xt(z.topLeftRadius,0),borderTopRightRadius:xt(z.topRightRadius,0),display:"flex",alignItems:"center",justifyContent:"center",cursor:I.link?"pointer":"default",boxShadow:"0 8px 18px rgba(0,0,0,0.2)"},p=async()=>{if(!I.link)return;await H("clicked",h.id);let C=String(I.link).trim();try{let S=F.getState(),_=S.allCampaigns||[],E=S.campaigns||[],$=_.find(D=>{if(!D)return!1;let k=String(D.id||"").trim(),P=D.details||{},O=String(P.campaign||P.id||"").trim();return!!(k&&k===C||O&&O===C||k&&C.includes(k)||O&&C.includes(O))});if(console.log("[Floater] clicked link=",C,"allCampaignsCount=",_.length,"visibleCount=",E.length),console.log("[Floater] all ids=",_.map(D=>D.id).slice(0,50)),console.log("[Floater] referenced found=",!!$,$&&($.id||$.details?.campaign||$.details?.id)),$){let D={...$};delete D.trigger_event,delete D.trigger,D.display_trigger=!0;let k=E.findIndex(P=>P.id===D.id);if(k===-1)console.log("[Floater] revealing campaign (prepended)",D.id),S.saveCampaigns([D,...E]);else{let P=E[k];if(!!(P.trigger_event??P.trigger)){let G=[...E];G[k]=D,console.log("[Floater] replacing existing triggered campaign with revealed one",D.id),S.saveCampaigns(G)}else console.log("[Floater] campaign already visible and not trigger-driven",D.id)}return}}catch(S){console.warn("[Floater] error while resolving referenced campaign",S)}try{window.open(I.link,"_blank")}catch{}},M=!!(I.lottie_data&&!n),B=!!I.image,L=!!(I.lottie_data&&s&&!t&&!n);return!M&&!B&&!L?null:te("div",{style:T,children:te("div",{style:l,onClick:()=>{p()},children:M?te(So,{onError:()=>r(!0),children:te("div",{ref:c,style:{width:"100%",height:"100%",display:"block"}})},String(I.lottie_data)):L?te("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:"..."}):te("img",{src:I.image,alt:"floater",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})})})},xr=br;K();function zn(t){return(t||"").trim().toLowerCase()}function Co(t,e){let o=zn(t.screen),i=zn(e);return!o||o===i}async function vo(t){try{let e=F.getState(),o=await dt(),i=e.accountId;if(!o||!i)return;e.setCurrentScreen(t),e.setTrackedEvents([]);let n=e.baseUrl||"https://users.appstorys.co",r=await fetch(`${n}/v2/${i}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({user_id:kt(),screenName:t})});if(!r.ok)return;let s=await r.json();if(typeof s.screen_capture_enabled<"u"&&e.setScreenCaptureEnabled(!!s.screen_capture_enabled),s.variants&&s.variants.length>0){let y={};s.variants.forEach(w=>{y[w.id]=w.v_id}),e.setVariantMappings(y)}s.personalization_data&&e.setPersonalizationData(s.personalization_data);let a=e.allCampaigns||[],c=s.eligibleCampaignList||[],u=a.filter(y=>c.includes(y.id)&&Co(y,t)),x=u.map(y=>y.id),m=c.filter(y=>!x.includes(y)),g=[];if(m.length>0){let y=await fetch(`${n}/load-campaign-data`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(m)});y.ok&&(g=(await y.json()).filter(I=>Co(I,t)))}let v=[...u,...g],f=a.filter(y=>{let w=!!(y.trigger_event??y.trigger);return Co(y,t)&&y.display_trigger===!0&&!w}),b=[...v],h=new Set(b.map(y=>y.id));for(let y of f)h.has(y.id)||(b.push(y),h.add(y.id));e.saveCampaigns(b)}catch(e){console.error("Error when tracking screen:",t,e)}}Ee();K();Ae();async function wo(t){try{let e=await dt(),o=kt(),i=F.getState();if(!e||!o){console.warn("AppStorys: Missing accessToken or userId. Ensure SDK is initialized before setting user properties.");return}let n={...t||{}},r=await qt();n={...n,...r};let s={user_id:o,attributes:n},a=i.baseUrl||"https://users.appstorys.co";await De({url:`${a}/update-user-atr`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:s})}catch(e){console.error("AppStorys: Error in setUserProperties:",e)}}K();function Oe(t){if(!t||t.trim()==="")return t;let e=F.getState().personalizationData;if(!e||Object.keys(e).length===0)return Sr(t);let o=/\{\{([^|}\s]+)\s*\|\s*([^}]+)\}\}/g;return t.replace(o,(i,n,r)=>{let s=n.trim(),a=r.trim();return e[s]??a})}function Sr(t){let e=/\{\{[^|}\s]+\s*\|\s*([^}]+)\}\}/g;return t.replace(e,(o,i)=>i.trim())}Kt();K();K();var ko="appstorys_campaigns_cache",Bn="appstorys_campaigns_etag",Ro="appstorys_campaigns_version";async function To(t,e){try{let o=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),i=o?`/appstorys-campaigns/clients/${t}/campaigns.json`:`https://dev-cdn-campaign-appstorys.s3.ap-south-1.amazonaws.com/clients/${t}/campaigns.json`,n=await tt.getItem(ko),r=await tt.getItem(Bn),s=await tt.getItem(Ro),a={Accept:"application/json"};!o&&r&&(a["If-None-Match"]=r);let c=await fetch(i,{method:"GET",headers:a,...o?{cache:"no-store"}:{}});if(c.status===304)return{campaigns:n?JSON.parse(n):[],version:s?parseInt(s):1};let u=c.headers.get("ETag"),x=await c.json(),m=2,g=x,v=e;if(!v)try{let f=await dt(),b=kt(),y=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...f?{Authorization:`Bearer ${f}`}:{}},body:JSON.stringify({user_id:b,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(y.ok){let w=await y.json();console.info("AppStorys: fetchAllCampaigns track-user-res returned",w);let I=w?.screenName||w?.screen||w?.currentScreen||w?.screen_name||w?.current_screen;I&&(v=I);try{let z=F.getState();typeof w.screen_capture_enabled<"u"&&z.setScreenCaptureEnabled(!!w.screen_capture_enabled)}catch{}}}catch(f){console.warn("Could not fetch screen name from track-user-res:",f)}if(x.length>0&&x[0].version!==void 0&&(m=x[0].version,g=x.slice(1)),!g||g.length===0)try{let f=await dt(),b=kt(),y=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...f?{Authorization:`Bearer ${f}`}:{}},body:JSON.stringify({user_id:b,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(y.ok){let w=await y.json(),I=w?.user_id||w?.id||w?.userId||b;try{let z=F.getState();typeof w.screen_capture_enabled<"u"&&z.setScreenCaptureEnabled(!!w.screen_capture_enabled)}catch{}if(I){let R=await fetch(o?"/appstorys-users/load-campaign-data":"https://users.appstorys.com/load-campaign-data",{method:"POST",headers:{"Content-Type":"application/json",...f?{Authorization:`Bearer ${f}`}:{}},body:JSON.stringify({user_id:I})});if(R.ok){let d=await R.json();console.log(`Fetched ${d.length} missing campaigns from fallback`),console.log("Fallback campaigns:",JSON.stringify(d,null,2)),d&&d.length>0&&(g=d)}else console.error("Failed to fetch missing campaigns:",await R.text())}}}catch(f){console.error("Error fetching missing campaigns via fallback:",f)}if(v&&g&&g.length>0){let f=h=>(h||"").trim().toLowerCase(),b=f(v);g=g.filter(h=>!f(h.screen)||f(h.screen)===b)}return await tt.setItem(ko,JSON.stringify(g)),await tt.setItem(Ro,m.toString()),u&&await tt.setItem(Bn,u),{campaigns:g,version:m}}catch(o){console.error("Error fetching campaigns:",o);let i=await tt.getItem(ko),n=await tt.getItem(Ro);return{campaigns:i?JSON.parse(i):[],version:n?parseInt(n):1}}}K();K();K();async function je(t,e){try{let o=await dt(),i=F.getState();if(!o)return console.error("AppStorys: Access token not found for reconciliation"),!1;let n={anonymous_user_id:t,identified_user_id:e},r=i.baseUrl||"https://users.appstorys.co",s=await fetch(`${r}/reconcile-anonymous-user`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(n)});if(s.ok)return!0;{let a=await s.text();return console.error("AppStorys: Failed to reconcile anonymous user:",s.status,a),!1}}catch(o){return console.error("AppStorys: Error in reconcileAnonymousUser:",o),!1}}K();var Fo=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&&po()&&this.triggerCampaign()};handlePopState=()=>{po()&&(window.history.pushState("appstorys_navigation",""),this.triggerCampaign())};triggerCampaign(){let e=F.getState(),{trackedEvents:o}=e;o.includes(Be)||(console.log("AppStorys: Exit Intent triggered. Displaying campaign."),e.setTrackedEvents([...o,Be]))}},An=new Fo;K();var Io=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=F.getState();o.isVisible!==e&&(console.log(`AppStorys: SDK visibility changed to ${e?"visible":"hidden"}`),o.setVisibility(e))}},zo=new Io;Kt();var Ne="anonymous_user_id";async function En(){let t=Date.now(),e=navigator.userAgent.split(" ")[0].replace(/[^a-zA-Z0-9]/g,"_");return`${t}_${e}`}async function Pn(){try{let t=await tt.getItem(Ne);if(t)return t;let e=await En();return await tt.setItem(Ne,e),e}catch(t){return console.error("Error managing anonymous user ID:",t),await En()}}async function Bo(){try{await tt.removeItem(Ne)}catch(t){console.error("Error clearing anonymous user ID:",t)}}async function Ao(){try{return await tt.getItem(Ne)}catch(t){return console.error("Error getting stored anonymous user ID:",t),null}}function Cr(){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 Ga(){Qa();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 Rr(){try{let t=A.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 i=Ga();return i.addEventListener("click",async()=>{i.disabled=!0;let n=i.innerText;i.innerHTML='<div class="appstorys-spinner"></div>';let l=A.getState().currentScreen||(typeof window<"u"?window.location.pathname:"");try{await me.takeScreenshot(l)}catch(d){console.error("CaptureService error",d)}i.disabled=!1,i.innerText=n,i.animate([{transform:"scale(1.0)"},{transform:"scale(1.05)"},{transform:"scale(1.0)"}],{duration:300})}),document.body.appendChild(i),console.info("AppStorys: screen capture button mounted"),i}catch(t){return console.error("mountScreenCaptureButton error",t),null}}var Fr=le(()=>{"use strict";ot();kr();try{window.AppStorysMountCapture=function(){try{return Rr()}catch(t){return console.error("AppStorysMountCapture failed",t),null}}}catch{}try{window.AppStorysDebugState=function(){try{let t=A.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 i=t.split(".");if(i.length===3){let n=JSON.parse(atob(i[1]));if(console.info("Token payload:",n),n.exp){let r=new Date(n.exp*1e3),l=new Date;console.info("Token expires:",r.toISOString(),"Expired:",l>r)}}}catch(i){console.warn("Could not decode JWT:",i)}return t?"Token present":"No token"}catch(t){return console.error("AppStorysDebugToken failed",t),null}}}catch{}});var Qn=(n=>(n.uninitialized="uninitialized",n.initializing="initializing",n.initialized="initialized",n.error="error",n))(Qn||{});ot();import{useState as so,useEffect as ri,useRef as si}from"react";import*as Ce from"lottie-react";ot();import{useMemo as _r}from"react";ot();var Xn="appstorys_variant_mappings",Ee={};function Ar(t){let e=0;for(let o=0;o<t.length;o++){let i=t.charCodeAt(o);e=(e<<5)-e+i,e|=0}return Math.abs(e)}function Jn(){if(typeof window>"u")return{};try{let t=localStorage.getItem(Xn);if(t)return JSON.parse(t)}catch{}return{}}function Er(t,e){if(!(!t||!e)){Ee[t]=e;try{let o=A.getState(),i=o.variantMappings||{};i[t]!==e&&o.setVariantMappings({...i,[t]:e})}catch{}if(typeof window<"u")try{let o=Jn();o[t]=e,localStorage.setItem(Xn,JSON.stringify(o))}catch{}}}var Kn=t=>{if(!t)return;if(Ee[t])return Ee[t];let e=A.getState().variantMappings?.[t];if(e)return Ee[t]=e,e;let o=Jn();if(o[t]){Ee[t]=o[t];try{A.getState().setVariantMappings({...A.getState().variantMappings||{},[t]:o[t]})}catch{}return o[t]}};function Ke(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 Dr(t,e){let o=Object.keys(t);if(o.length===0)return;let i=o.filter(l=>t[l]&&t[l].isActive!==!1),n=i.length>0?i:o,r=n.reduce((l,d)=>l+(Number(t[d]?.weight)||0),0);if(r>0){let l=A.getState().userId||"default",d=`${e||"campaign"}_${l}`,y=Ar(d)%1e4/1e4*r;for(let b of n){let h=Number(t[b]?.weight)||0;if(y<h)return b;y-=h}}return n[0]}function Rt(t){if(!t||!Ke(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 i=Kn(e.id||"");if((!i||!o[i])&&(i=Dr(o,e.id),e.id&&i&&Er(e.id,i)),!i||!o[i])return t;let n=o[i],l={...e.details&&typeof e.details=="object"?Object.fromEntries(Object.entries(e.details).filter(([d])=>d!=="variants")):{},...n};return{...t,details:l,_variantId:i}}function rl(t){if(t){if("_variantId"in t)return t._variantId;if(Ke(t))return Kn(t.id||"")}}var Ze="__back_press_triggered__";function Zn(t){return(t||"").trim().toLowerCase()}function Pr(t,e){let o=Zn(t),i=Zn(e);return!o||o===i}function $r(t,e,o){let i=Number(t),n=Number(o),r=!isNaN(i)&&!isNaN(n);switch(e){case"eq":return r?i===n:t===o;case"neq":return r?i!==n:t!==o;case"gt":return r?i>n:t>o;case"gte":return r?i>=n:t>=o;case"lt":return r?i<n:t<o;case"lte":return r?i<=n:t<=o;default:return!1}}function Wr(t,e){let o=t.filter(i=>i.back_press==null);return o.length===0?!0:e.some(i=>o.every(n=>{let r=i[n.key];return r==null?!1:$r(String(r),n.operator,n.value)}))}function Or(t,e,o){let i=t,n=i.trigger_event??i.trigger,r=t.id;return!n}function $o(){let{campaigns:t,trackedEvents:e,trackedEventMetadata:o,currentScreen:i}=A.getState();return t.some(n=>{if(n.screen&&n.screen!==i)return!1;let r=n.trigger_event;if(!r||typeof r=="string")return!1;let{event:l,event_config:d}=r;if(!(d??[]).some(b=>b.back_press===!0)||e.includes(Ze)||!e.includes(l))return!1;let c=(d??[]).filter(b=>b.back_press==null);if(c.length===0)return!0;let y=o[l]||[];return Wr(c,y)})}function xt(t,e){let o=A(c=>c.currentScreen),i=A(c=>c.campaigns),n=A(c=>c.allCampaigns),r=A(c=>c.trackedEvents),l=A(c=>c.trackedEventMetadata),d=A(c=>c.variantMappings);return _r(()=>{let c=h=>h.find(f=>Pr(f.screen,o)&&f.campaign_type===t&&(e?.position?f.position===e.position:!0)&&Or(f,r,l)),b=(i&&i.length>0?c(i):void 0)??c(n||[]);if(b)return Rt(b)},[i,n,r,l,d,t,e,o])}ot();to();Se();ot();eo();var ei="appstorys_offline_queue";async function oi(){let t=await ct.getItem(ei);return t?JSON.parse(t):[]}async function ni(t){await ct.setItem(ei,JSON.stringify(t))}function Nr(t){return Math.min(3e4*Math.pow(2,t),12e4)}function jr(t){let o=t.retryCount||0,i=t.lastAttempt||0,n=Nr(o);return o<3&&Date.now()-i>=n}async function Hr(){let t=A.getState();return!t.accountId||!t.appId?!1:await Ht(t.accountId,t.appId,t.userId)}async function ii(t,e){if(await Hr()){let i=await ct.getItem("access_token");i&&(t.headers={...t.headers,Authorization:`Bearer ${i}`}),t.authRetried=!0,t.lastAttempt=Date.now(),e(t)}}async function no(t,e){let o=(t.retryCount||0)+1;o<=3&&(t.retryCount=o,t.lastAttempt=Date.now(),e(t))}async function oo(t){let e=await oi();e.push(t),await ni(e)}async function qr(){let t=await oi();if(t.length===0)return;let e=[];for(let o of t){if(!jr(o)){e.push(o);continue}try{let i=await fetch(o.url,{method:o.method,headers:o.headers,body:JSON.stringify(o.body)});if(i.ok)continue;i.status===401||i.status===403?o.authRetried||await ii(o,n=>e.push(n)):i.status>=500&&await no(o,n=>e.push(n))}catch{await no(o,n=>e.push(n))}}await ni(e)}async function io(t){if(!navigator.onLine){await oo(t);return}await qr();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 ii(t,oo):e.status>=500&&await no(t,oo)),e}catch{await no(t,oo);return}}async function G(t,e,o){try{if(!t)return;let i=await bt(),n=A.getState(),r=["viewed","clicked","csat captured","survey captured","shared"];if(!r.includes(t)){let y=n.trackedEvents;if(!y.includes(t))n.setTrackedEvents([...y,t]);else{let b=y.filter(h=>h!==t);b.push(t),n.setTrackedEvents(b)}if(o&&Object.keys(o).length>0){let b=n.trackedEventMetadata||{},h=b[t]||[];n.setTrackedEventMetadata({...b,[t]:[...h,o]})}}let l={...o||{}};if(!r.includes(t)){let y=await de();l={...l,...y}}if(e&&String(e).trim()!==""){let y=o?.variant_id||Gn(e);y&&(l.variant_id=y)}let d={user_id:Dt(),event:t,metadata:l};e&&(d.campaign_id=e);let c=n.trackingUrl||"https://tracking.appstorys.co";i&&await io({url:`${c}/capture-event`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:d})}catch(i){console.error("Error in trackEvent",i)}}ot();function wt(t){if(!t)return!1;let e=A.getState(),o=e.allCampaigns||[],i=e.campaigns||[],n=String(t).trim(),r=o.find(c=>{if(!c)return!1;let y=String(c.id||"").trim(),b=c.details||{},h=String(b.campaign||b.id||"").trim();return!!(y&&y===n||h&&h===n||y&&n.includes(y)||h&&n.includes(h))});if(!r)return!1;let l={...r};delete l.trigger_event,delete l.trigger,l.display_trigger=!0;let d=i.findIndex(c=>String(c.id||"")===String(l.id||""));if(d===-1)e.saveCampaigns([l,...i]);else{let c=i[d];if(!!(c.trigger_event??c.trigger)){let b=[...i];b[d]=l,e.saveCampaigns(b)}}return!0}import{jsx as ro,jsxs as Ur}from"react/jsx-runtime";var Vr=({config:t,onPress:e,style:o,ignoreSizeAndMargin:i=!1})=>{if(!t||!t.enabled)return null;let n=t.size,r=t.margin,l=t.color,d=t.image,c=t.selectedStyle,y=n!=null&&n>=0?n:18,b=i?40:y,h=r?.top!==void 0&&r?.top!==null&&r.top>=0?r.top:0,f=r?.bottom!==void 0&&r?.bottom!==null&&r.bottom>=0?r.bottom:0,v=r?.left!==void 0&&r?.left!==null&&r.left>=0?r.left:0,S=r?.right!==void 0&&r?.right!==null&&r.right>=0?r.right:0,u={marginTop:i?0:h,marginBottom:i?0:f,marginLeft:i?0:v,marginRight:i?0:S,width:b,height:b,backgroundColor:l?.fill||"transparent",borderColor:l?.stroke||"transparent",borderWidth:b*.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},m=()=>{let g=l?.cross||"#ffffff";return Ur("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[ro("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"}),ro("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"})]})};return ro("button",{type:"button",onClick:g=>{g.stopPropagation(),g.preventDefault(),e(g)},style:u,title:c||"",children:d&&d.trim()!==""?ro("img",{src:d,style:{width:b,height:b,objectFit:"contain"},alt:"close"}):m()})},Ft=Vr;import{jsx as ao,jsxs as Qr}from"react/jsx-runtime";var ai=Ce.default?.default??Ce.default??Ce.Lottie??Ce,Yr=()=>{let t=xt("BAN"),e=A(a=>a.isVisible),[o,i]=so(!1),[n,r]=so(null),[l,d]=so(null),c=si(null),[y,b]=so(0),h=si(null);if(ri(()=>{t?.id&&h.current!==t.id&&(h.current=t.id,i(!1),G("viewed",t.id),t.details?.lottie_data&&fetch(t.details.lottie_data).then(a=>a.json()).then(a=>{r(a),a.w&&a.h&&d(a.h/a.w)}).catch(a=>console.error("Error loading Lottie:",a)))},[t?.id]),ri(()=>{let a=()=>{c.current&&b(c.current.offsetWidth)};return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[t,o]),!t||o||!e)return null;let{details:f}=t,v=f.styling||{},S=f.height||"auto";l&&y&&(S=y*l);let u=parseFloat(String(f.height)),m=parseFloat(String(f.originalWidth??f.styling?.originalWidth)),g=parseFloat(String(f.originalHeight??f.styling?.originalHeight)),C=Number.isFinite(u)&&u>0&&Number.isFinite(m)&&m>0&&Number.isFinite(g)&&g>0?u*(m/g):null,I=C!==null?`${C}px`:void 0,z=typeof S=="number"?`${S}px`:S||void 0,E=Number(v.marginRight),w=Number(v.marginBottom),D={position:"fixed",right:Number.isFinite(E)?`${E}px`:"0px",bottom:Number.isFinite(w)?`${w}px`:"0px",zIndex:9999,display:"block",cursor:f.link?"pointer":"default"},_={position:"relative",width:I||"100%",height:z||"auto",backgroundColor:"transparent",borderRadius:`${v.topRightRadius||0}px ${v.topLeftRadius||0}px ${v.bottomRightRadius||0}px ${v.bottomLeftRadius||0}px`,overflow:"hidden"},P={width:"100%",height:"100%",display:"block",objectFit:"contain"},H=a=>{a.stopPropagation(),i(!0),G("banner_closed",t.id)};return ao("div",{ref:c,style:D,onClick:()=>{if(f.link)if(G("clicked",t.id),f.link.startsWith("http"))window.open(f.link,"_blank");else{try{if(wt(f.link))return}catch(a){console.warn("revealCampaignFromLink error",a)}console.log("Internal link:",f.link)}},children:Qr("div",{style:_,children:[n?(()=>{let a=ai.default||ai;return ao(a,{animationData:n,loop:!0,autoplay:e,style:P})})():f.image?ao("img",{src:f.image,alt:"Campaign Banner",style:P}):null,v.crossButton?.enabled&&ao(Ft,{config:v.crossButton,onPress:H,style:{top:v.crossButton?.margin?.top!==void 0?0:5,right:v.crossButton?.margin?.right!==void 0?0:5}})]})})};import{useEffect as Oo,useMemo as ui,useRef as uo,useState as De}from"react";ot();function co(t){let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")}function li(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 di(t,e){if(typeof document>"u")return;let o=`appstorys-font-${t}`;if(document.getElementById(o))return;let i=document.createElement("style");i.id=o,i.type="text/css",i.textContent=`@font-face{font-family:"${t}";src:url("${e}");font-style:normal;font-weight:normal;font-display:swap;}`,document.head.appendChild(i)}var lo=new Map;async function Gr(t,e){try{di(e.name,t);let o=globalThis.FontFace;if(typeof document<"u"&&o&&document.fonts?.add){let i=new o(e.name,`url(${t})`);await i.load(),document.fonts.add(i)}else typeof document<"u"&&document.fonts?.load&&await document.fonts.load(`1em "${e.name}"`);e.status="loaded",e.listeners.forEach(i=>i(e.name))}catch(o){console.warn(`[FontManager] Failed to load font from "${t}":`,o),e.status="failed",e.listeners.forEach(i=>i(void 0))}finally{e.listeners=[]}}var Wo={async load(t){if(!t||!co(t))return;let e=lo.get(t);if(e)return e.status==="loaded"?e.name:e.status==="failed"?void 0:new Promise(r=>e.listeners.push(r));let i={status:"pending",name:li(t),listeners:[]};lo.set(t,i);let n=new Promise(r=>i.listeners.push(r));return Gr(t,i),n},ensure(t){if(!t||!co(t))return;let e=li(t);return di(e,t),Wo.load(t),e},getSync(t){if(!t)return;let e=lo.get(t);return e?.status==="loaded"?e.name:void 0},_clearCache(){lo.clear()}};function gt(t){if(t)return co(t)?Wo.ensure(t):t}function Xr(t){let e=new Set,o=new WeakSet,i=n=>{if(n!=null&&typeof n!="string"){if(Array.isArray(n)){for(let r of n)i(r);return}if(typeof n=="object"){if(o.has(n))return;o.add(n);for(let[r,l]of Object.entries(n))r==="fontFamily"&&typeof l=="string"&&co(l)&&e.add(l),i(l)}}};return i(t),Array.from(e)}async function ci(t){let e=new Set;for(let o of t)Xr(o).forEach(i=>e.add(i));await Promise.all(Array.from(e).map(o=>Wo.load(o)))}import{jsx as mt,jsxs as ce}from"react/jsx-runtime";var No=t=>(t||"").trim().toLowerCase(),$t=(t,e)=>{let o=Number(t);return Number.isFinite(o)?o:e},Jr=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"};function Kr({iconType:t,color:e}){let o=e||"#FFFFFF";return t==="close"?ce("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[mt("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:o,strokeWidth:"2.2",strokeLinecap:"round"}),mt("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:o,strokeWidth:"2.2",strokeLinecap:"round"})]}):t==="expand"?ce("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[mt("polyline",{points:"8,3 3,3 3,8",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),mt("line",{x1:"3",y1:"3",x2:"9",y2:"9",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),mt("polyline",{points:"16,21 21,21 21,16",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),mt("line",{x1:"15",y1:"15",x2:"21",y2:"21",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):t==="minimize"?ce("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[mt("polyline",{points:"9,9 3,9 3,3",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),mt("line",{x1:"3",y1:"9",x2:"9",y2:"3",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),mt("polyline",{points:"15,15 21,15 21,21",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),mt("line",{x1:"15",y1:"21",x2:"21",y2:"15",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):t==="mute"?ce("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[mt("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:o,strokeWidth:"2",strokeLinejoin:"round"}),mt("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),mt("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):ce("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[mt("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:o,strokeWidth:"2",strokeLinejoin:"round"}),mt("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),mt("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]})}function jo({iconType:t,config:e,imageOverride:o,onClick:i}){let n=$t(e?.size,18),r=Math.max(24,n+10),l=e?.margin||{},d=o||e?.image,c=e?.color?.cross||"#FFFFFF",y=e?.color?.fill||"rgba(0,0,0,0.55)",b=e?.color?.stroke||"rgba(255,255,255,0.35)";return mt("button",{"data-control-button":"true",type:"button",onPointerDown:h=>{h.preventDefault(),h.stopPropagation()},onPointerUp:h=>{h.preventDefault(),h.stopPropagation()},onMouseDown:h=>{h.preventDefault(),h.stopPropagation()},onTouchStart:h=>{h.preventDefault(),h.stopPropagation()},onClick:h=>{h.preventDefault(),h.stopPropagation(),i()},title:e?.selectedStyle||t,style:{width:r,height:r,borderRadius:999,pointerEvents:"auto",zIndex:10030,position:"relative",border:`1px solid ${b}`,background:y,color:c,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,marginTop:$t(l.top,0),marginRight:$t(l.right,0),marginBottom:$t(l.bottom,0),marginLeft:$t(l.left,0)},children:d?mt("img",{src:d,alt:t,style:{width:n,height:n,objectFit:"contain"}}):mt(Kr,{iconType:t,color:c})})}var Zr=()=>{let t=xt("PIP"),e=A(W=>W.campaigns),o=A(W=>W.allCampaigns),i=A(W=>W.currentScreen),n=A(W=>W.isVisible),[r,l]=De(!1),[d,c]=De(!1),[y,b]=De(!0),[h,f]=De(!1),[v,S]=De(null),u=uo({x:0,y:0}),m=uo(null),g=uo({x:0,y:0}),C=uo(!1),I=ui(()=>{if(t)return t;let W=No(i),tt=St=>St.find(yt=>{let st=yt,kt=st.campaign_type==="PIP",It=!No(st.screen)||No(st.screen)===W,ye=!!(st.trigger_event??st.trigger),Ut=st.display_trigger!==!1&&!ye;return kt&&It&&Ut}),dt=tt(e)??tt(o);return dt?Rt(dt):void 0},[t,e,o,i]),z=ui(()=>I,[I?.id,I?.details?.id]);if(Oo(()=>{if(!z)return;let W=z.details||{},tt=W?.styling?.soundToggle?.defaultSound||W?.styling?.appearance?.defaultSound||"yes";b(String(tt).toLowerCase()!=="yes"),l(!1),c(!1),S(null),G("viewed",z.id)},[z]),Oo(()=>{m.current&&(m.current.muted=y)},[y]),Oo(()=>{if(!h)return;let W=dt=>{let St=dt.clientX-g.current.x,yt=dt.clientY-g.current.y;(Math.abs(St)>4||Math.abs(yt)>4)&&(C.current=!0);let st=dt.clientX-u.current.x,kt=dt.clientY-u.current.y;S({x:Math.max(0,st),y:Math.max(0,kt)})},tt=()=>{f(!1)};return window.addEventListener("mousemove",W),window.addEventListener("mouseup",tt),()=>{window.removeEventListener("mousemove",W),window.removeEventListener("mouseup",tt)}},[h]),!z||!z.details||r||!n)return null;let E=z.details,w=E.styling||{},D=w.appearance||{},_=$t(E.width??D.pipWidth,150),P=$t(E.height??D.pipHeight,300),H=_,B=P,a=w.cta?.container||{},x=w.cta?.text||{},s=!!(E.button_text&&E.button_text.trim().length>0),p=$t(w.cta?.container?.height,42),M=s?p+24:0,T=$t(w.pipBottomPadding,20),R=$t(w.pipTopPadding,0),$=d?E.large_video||E.small_video:E.small_video||E.large_video,N=(E.position||z.position||"right").toLowerCase(),V=!!w.isMovable,O=w.soundToggle?.enabled!==!1,q=w.crossButton?.enabled!==!1,Z=w.expandablePip??E.expandablePip??E.expandable_pip,it=Z!=null&&Z!==""?Jr(Z):w.expandControls?.enabled!==!1,et=w.crossButton,rt=d?w.expandControls?.minimise:w.expandControls?.maximise,k=y?w.soundToggle?.mute:w.soundToggle?.unmute,L=()=>{c(W=>{let tt=!W;return tt&&z?.id&&(G("viewed",z.id),G("analyze",z.id)),tt})},X={position:"fixed",zIndex:10020,width:d?"auto":H,height:d?"auto":B,borderRadius:0,overflow:"hidden",background:"#000",boxShadow:"0 16px 40px rgba(0,0,0,0.35)",cursor:h?"grabbing":V&&!d?"grab":"default",transition:h?"none":"width 180ms ease, height 180ms ease, transform 180ms ease"};v&&!d?(X.left=v.x,X.top=v.y):d?(X.left=0,X.top=0,X.right=0,X.bottom=0):(N==="left"?X.left=24:X.right=24,R>0?X.top=R:X.bottom=T+20);let ht=W=>{if(!V||d||W.target.closest("[data-control-button='true']"))return;let dt=W.currentTarget.getBoundingClientRect();u.current={x:W.clientX-dt.left,y:W.clientY-dt.top},g.current={x:W.clientX,y:W.clientY},C.current=!1,S({x:dt.left,y:dt.top}),f(!0)},U=()=>{if(!E.link)return;G("clicked",z.id);let W=String(E.link).trim();try{let tt=A.getState(),dt=tt.allCampaigns||[],St=tt.campaigns||[],yt=dt.find(st=>st.id===W);if(console.log("[Pip] clicked link=",W,"allCount=",dt.length,"visibleCount=",St.length,"referenced=",!!yt),yt){let st={...yt};delete st.trigger_event,delete st.trigger,st.display_trigger=!0;let kt=St.findIndex(It=>It.id===st.id);if(kt===-1)tt.saveCampaigns([st,...St]);else{let It=St[kt];if(!!(It.trigger_event??It.trigger)){let Ut=[...St];Ut[kt]=st,tt.saveCampaigns(Ut)}}return}}catch{}window.open(E.link,"_blank")};return $?ce("div",{style:X,onMouseDown:ht,children:[mt("video",{ref:m,src:$,autoPlay:!0,loop:!0,playsInline:!0,muted:y,style:{width:"100%",height:d&&s?`calc(100% - ${M}px)`:"100%",objectFit:d?"contain":"cover",cursor:it&&!d||E.link?"pointer":"default"},onClick:()=>{if(C.current){C.current=!1;return}if(it){L();return}U()},onEnded:()=>{I&&G("analyze",I.id)}}),ce("div",{style:{position:"absolute",top:8,right:8,display:"flex",gap:8,zIndex:2},children:[O&&mt(jo,{iconType:y?"mute":"unmute",config:k,imageOverride:y?E.muteImage:E.unmuteImage,onClick:()=>b(W=>!W)}),it&&mt(jo,{iconType:d?"minimize":"expand",config:rt,imageOverride:d?E.minimiseImage:E.maximiseImage,onClick:L}),q&&mt(jo,{iconType:"close",config:et,imageOverride:E.crossButtonImage,onClick:()=>l(!0)})]}),d&&s&&mt("button",{"data-control-button":"true",onClick:U,style:{position:"absolute",left:12,right:12,bottom:12,height:a.height||42,width:a.ctaFullWidth?"auto":a.ctaWidth||"auto",maxWidth:"calc(100% - 24px)",margin:a.ctaFullWidth?"0":"0 auto",background:a.backgroundColor||"#F7921C",color:x.color||"#fff",border:`${a.borderWidth||0}px solid ${a.borderColor||"transparent"}`,borderRadius:10,fontSize:x.fontSize||14,fontFamily:gt(x.fontFamily),fontWeight:600,cursor:E.link?"pointer":"default"},children:E.button_text})]}):null};import ts,{useEffect as Ho,useRef as qo,useState as po}from"react";import{LottiePlayer as es}from"lottie-react";ot();import{jsx as ve}from"react/jsx-runtime";var At=(t,e=0)=>{let o=Number(t);return Number.isFinite(o)?o:e},Vo=t=>(t||"").trim().toLowerCase(),os="appstorysmediabucketdev.s3.ap-south-1.amazonaws.com",ns=t=>{try{if(typeof window>"u")return[t];let e=new URL(t);if(e.hostname!==os)return[t];let o=!!window.location.port,i=`/appstorys-media${e.pathname}${e.search}`;return o?[i,t]:[t]}catch{return[t]}},is=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"},Uo=class extends ts.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}},rs=()=>{let[t,e]=po(null),[o,i]=po([]),[n,r]=po(!1),[l,d]=po(!1),c=qo(null),y=qo(null),b=xt("FLT"),h=A(x=>x.campaigns),f=A(x=>x.allCampaigns),v=A(x=>x.currentScreen),S=A(x=>x.isVisible),u=qo(null),m=b??(()=>{let x=[...h,...f].find(s=>{let p=s;if(p.campaign_type!=="FLT")return!1;let M=!!(p.trigger_event??p.trigger);return p.display_trigger===!1||M?!1:!Vo(p.screen)||Vo(p.screen)===Vo(v)});if(x)try{return Rt(x)}catch{return x}})(),g=m?.id,C=A(x=>g?x.variantMappings[g]:void 0);if(Ho(()=>{if(!m?.id||!S||Ke(m)&&!C)return;let s=`${m.id}:${C||""}`;u.current!==s&&(u.current=s,G("viewed",m.id))},[m?.id,C,S]),Ho(()=>{let x=m?.details?.lottie_data;if(e(null),i([]),r(!1),d(!1),!x)return;if(is(x)){e(x),d(!0);return}if(typeof x!="string"){r(!0);return}let s=ns(x);i(s),d(!0)},[m?.details?.lottie_data]),Ho(()=>{if(!m?.details?.lottie_data||!c.current)return;let x=es;if(!x||typeof x.loadAnimation!="function"){r(!0),d(!1);return}let s=!1,p=null,M=()=>{p&&typeof p.destroy=="function"&&p.destroy(),p=null,y.current=null},T=(R,$)=>{if(s)return;if($>=R.length){r(!0),d(!1),console.error("[Floater] lottie load failed",{lottieUrls:R});return}M();let N=x.loadAnimation({container:c.current,renderer:"svg",loop:!0,autoplay:!0,path:R[$]});p=N,y.current=N,N.addEventListener("DOMLoaded",()=>{s||d(!1)}),N.addEventListener("data_failed",()=>{s||T(R,$+1)})};if(t){M();let R=x.loadAnimation({container:c.current,renderer:"svg",loop:!0,autoplay:!0,animationData:t});p=R,y.current=R,R.addEventListener("DOMLoaded",()=>{s||d(!1)}),R.addEventListener("data_failed",()=>{s||(r(!0),d(!1))})}else o.length>0&&T(o,0);return()=>{s=!0,M()}},[m?.details?.lottie_data,t,o]),!m||!m.details||!S)return null;let{details:I}=m,z=I.styling||{},w=(typeof I.position=="string"?I.position:typeof m.position=="string"?m.position:"right").toLowerCase()==="left"?"left":"right",D={position:"fixed",left:w==="left"?At(z.marginLeft,12):void 0,right:w==="left"?void 0:At(z.marginRight,12),top:At(z.marginTop,0)>0?At(z.marginTop,0):void 0,bottom:At(z.marginTop,0)>0?void 0:At(z.marginBottom,80),zIndex:10040,display:"flex"},_={width:At(I.width,60),height:At(I.height,60),background:"transparent",overflow:"hidden",borderBottomLeftRadius:At(z.bottomLeftRadius,0),borderBottomRightRadius:At(z.bottomRightRadius,0),borderTopLeftRadius:At(z.topLeftRadius,0),borderTopRightRadius:At(z.topRightRadius,0),display:"flex",alignItems:"center",justifyContent:"center",cursor:I.link?"pointer":"default",boxShadow:"0 8px 18px rgba(0,0,0,0.2)"},P=async()=>{if(!I.link)return;await G("clicked",m.id);let x=String(I.link).trim();try{let s=A.getState(),p=s.allCampaigns||[],M=s.campaigns||[],T=p.find(R=>{if(!R)return!1;let $=String(R.id||"").trim(),N=R.details||{},V=String(N.campaign||N.id||"").trim();return!!($&&$===x||V&&V===x||$&&x.includes($)||V&&x.includes(V))});if(console.log("[Floater] clicked link=",x,"allCampaignsCount=",p.length,"visibleCount=",M.length),console.log("[Floater] all ids=",p.map(R=>R.id).slice(0,50)),console.log("[Floater] referenced found=",!!T,T&&(T.id||T.details?.campaign||T.details?.id)),T){let R={...T};delete R.trigger_event,delete R.trigger,R.display_trigger=!0;let $=M.findIndex(N=>N.id===R.id);if($===-1)console.log("[Floater] revealing campaign (prepended)",R.id),s.saveCampaigns([R,...M]);else{let N=M[$];if(!!(N.trigger_event??N.trigger)){let O=[...M];O[$]=R,console.log("[Floater] replacing existing triggered campaign with revealed one",R.id),s.saveCampaigns(O)}else console.log("[Floater] campaign already visible and not trigger-driven",R.id)}return}}catch(s){console.warn("[Floater] error while resolving referenced campaign",s)}try{window.open(I.link,"_blank")}catch{}},H=!!(I.lottie_data&&!n),B=!!I.image,a=!!(I.lottie_data&&l&&!t&&!n);return!H&&!B&&!a?null:ve("div",{style:D,children:ve("div",{style:_,onClick:()=>{P()},children:H?ve(Uo,{onError:()=>r(!0),children:ve("div",{ref:c,style:{width:"100%",height:"100%",display:"block"}})},String(I.lottie_data)):a?ve("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:"..."}):ve("img",{src:I.image,alt:"floater",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})})})},ss=rs;ot();function pi(t){return(t||"").trim().toLowerCase()}function Yo(t,e){let o=pi(t.screen),i=pi(e);return!o||o===i}async function Qo(t){try{let e=A.getState(),o=await bt(),i=e.accountId;if(!o||!i)return;e.setCurrentScreen(t),e.setTrackedEvents([]);let n=e.baseUrl||"https://users.appstorys.co",r=await fetch(`${n}/v2/${i}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({user_id:Dt(),screenName:t})});if(!r.ok)return;let l=await r.json();if(typeof l.screen_capture_enabled<"u"&&e.setScreenCaptureEnabled(!!l.screen_capture_enabled),l.variants&&l.variants.length>0){let g={};l.variants.forEach(C=>{g[C.id]=C.v_id}),e.setVariantMappings(g)}l.personalization_data&&e.setPersonalizationData(l.personalization_data);let d=e.allCampaigns||[],c=l.eligibleCampaignList||[],y=d.filter(g=>c.includes(g.id)&&Yo(g,t)),b=y.map(g=>g.id),h=c.filter(g=>!b.includes(g)),f=[];if(h.length>0){let g=await fetch(`${n}/load-campaign-data`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(h)});g.ok&&(f=(await g.json()).filter(I=>Yo(I,t)))}let v=[...y,...f],S=d.filter(g=>{let C=!!(g.trigger_event??g.trigger);return Yo(g,t)&&g.display_trigger===!0&&!C}),u=[...v],m=new Set(u.map(g=>g.id));for(let g of S)m.has(g.id)||(u.push(g),m.add(g.id));e.saveCampaigns(u)}catch(e){console.error("Error when tracking screen:",t,e)}}eo();ot();to();async function Go(t){try{let e=await bt(),o=Dt(),i=A.getState();if(!e||!o){console.warn("AppStorys: Missing accessToken or userId. Ensure SDK is initialized before setting user properties.");return}let n={...t||{}},r=await de();n={...n,...r};let l={user_id:o,attributes:n},d=i.baseUrl||"https://users.appstorys.co";await io({url:`${d}/update-user-atr`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:l})}catch(e){console.error("AppStorys: Error in setUserProperties:",e)}}ot();function Zt(t){if(!t||t.trim()==="")return t;let e=A.getState().personalizationData;if(!e||Object.keys(e).length===0)return as(t);let o=/\{\{([^|}\s]+)\s*\|\s*([^}]+)\}\}/g;return t.replace(o,(i,n,r)=>{let l=n.trim(),d=r.trim();return e[l]??d})}function as(t){let e=/\{\{[^|}\s]+\s*\|\s*([^}]+)\}\}/g;return t.replace(e,(o,i)=>i.trim())}Se();ot();ot();var Xo="appstorys_campaigns_cache",gi="appstorys_campaigns_etag",Jo="appstorys_campaigns_version";async function Ko(t,e){try{let o=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),i=o?`/appstorys-campaigns/clients/${t}/campaigns.json`:`https://dev-cdn-campaign-appstorys.s3.ap-south-1.amazonaws.com/clients/${t}/campaigns.json`,n=await ct.getItem(Xo),r=await ct.getItem(gi),l=await ct.getItem(Jo),d={Accept:"application/json"};!o&&r&&(d["If-None-Match"]=r);let c=await fetch(i,{method:"GET",headers:d,...o?{cache:"no-store"}:{}});if(c.status===304)return{campaigns:n?JSON.parse(n):[],version:l?parseInt(l):1};let y=c.headers.get("ETag"),b=await c.json(),h=2,f=b,v=e;if(!v)try{let S=await bt(),u=Dt(),g=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...S?{Authorization:`Bearer ${S}`}:{}},body:JSON.stringify({user_id:u,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(g.ok){let C=await g.json();console.info("AppStorys: fetchAllCampaigns track-user-res returned",C);let I=C?.screenName||C?.screen||C?.currentScreen||C?.screen_name||C?.current_screen;I&&(v=I);try{let z=A.getState();typeof C.screen_capture_enabled<"u"&&z.setScreenCaptureEnabled(!!C.screen_capture_enabled)}catch{}}}catch(S){console.warn("Could not fetch screen name from track-user-res:",S)}if(b.length>0&&b[0].version!==void 0&&(h=b[0].version,f=b.slice(1)),!f||f.length===0)try{let S=await bt(),u=Dt(),g=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...S?{Authorization:`Bearer ${S}`}:{}},body:JSON.stringify({user_id:u,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(g.ok){let C=await g.json(),I=C?.user_id||C?.id||C?.userId||u;try{let z=A.getState();typeof C.screen_capture_enabled<"u"&&z.setScreenCaptureEnabled(!!C.screen_capture_enabled)}catch{}if(I){let E=await fetch(o?"/appstorys-users/load-campaign-data":"https://users.appstorys.com/load-campaign-data",{method:"POST",headers:{"Content-Type":"application/json",...S?{Authorization:`Bearer ${S}`}:{}},body:JSON.stringify({user_id:I})});if(E.ok){let w=await E.json();console.log(`Fetched ${w.length} missing campaigns from fallback`),console.log("Fallback campaigns:",JSON.stringify(w,null,2)),w&&w.length>0&&(f=w)}else console.error("Failed to fetch missing campaigns:",await E.text())}}}catch(S){console.error("Error fetching missing campaigns via fallback:",S)}if(v&&f&&f.length>0){let S=m=>(m||"").trim().toLowerCase(),u=S(v);f=f.filter(m=>!S(m.screen)||S(m.screen)===u)}return await ct.setItem(Xo,JSON.stringify(f)),await ct.setItem(Jo,h.toString()),y&&await ct.setItem(gi,y),{campaigns:f,version:h}}catch(o){console.error("Error fetching campaigns:",o);let i=await ct.getItem(Xo),n=await ct.getItem(Jo);return{campaigns:i?JSON.parse(i):[],version:n?parseInt(n):1}}}ot();ot();ot();async function go(t,e){try{let o=await bt(),i=A.getState();if(!o)return console.error("AppStorys: Access token not found for reconciliation"),!1;let n={anonymous_user_id:t,identified_user_id:e},r=i.baseUrl||"https://users.appstorys.co",l=await fetch(`${r}/reconcile-anonymous-user`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(n)});if(l.ok)return!0;{let d=await l.text();return console.error("AppStorys: Failed to reconcile anonymous user:",l.status,d),!1}}catch(o){return console.error("AppStorys: Error in reconcileAnonymousUser:",o),!1}}ot();var Zo=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&&$o()&&this.triggerCampaign()};handlePopState=()=>{$o()&&(window.history.pushState("appstorys_navigation",""),this.triggerCampaign())};triggerCampaign(){let e=A.getState(),{trackedEvents:o}=e;o.includes(Ze)||(console.log("AppStorys: Exit Intent triggered. Displaying campaign."),e.setTrackedEvents([...o,Ze]))}},fi=new Zo;ot();var tn=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=A.getState();o.isVisible!==e&&(console.log(`AppStorys: SDK visibility changed to ${e?"visible":"hidden"}`),o.setVisibility(e))}},en=new tn;Se();var fo="anonymous_user_id";async function mi(){let t=Date.now(),e=navigator.userAgent.split(" ")[0].replace(/[^a-zA-Z0-9]/g,"_");return`${t}_${e}`}async function yi(){try{let t=await ct.getItem(fo);if(t)return t;let e=await mi();return await ct.setItem(fo,e),e}catch(t){return console.error("Error managing anonymous user ID:",t),await mi()}}async function on(){try{await ct.removeItem(fo)}catch(t){console.error("Error clearing anonymous user ID:",t)}}async function nn(){try{return await ct.getItem(fo)}catch(t){return console.error("Error getting stored anonymous user ID:",t),null}}function ls(){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,10 +30,40 @@ var Yi=Object.defineProperty;var Nt=(t,e)=>()=>(t&&(e=t(t=0)),e);var Qi=(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 Ln(t){let e=document.createElement("div");return e.className="appstorys-widget-debug-pill",e.textContent=t,e}function vr(t){let e=t,o=getComputedStyle(e);(o.position==="static"||!o.position)&&(e.style.position="relative")}window.AppStorysShowWidgetElements=function(){try{Cr();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(i=>{let n=document.querySelector(i);n&&e.push(n)}),!e.length){let o=Ln("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,i)=>{let n=o;vr(n),n.classList.add("appstorys-widget-debug-overlay");let r=n.querySelector(".appstorys-widget-debug-pill");r&&r.remove();let s=Ln("Widget "+(i+1));n.appendChild(s)})}catch(e){console.error("AppStorysShowWidgetElements error",e)}};K();import{useState as Ci,useEffect as vi}from"react";import{useEffect as wr,useState as Dn}from"react";import*as ee from"lottie-react";import{jsx as $n}from"react/jsx-runtime";var _n=ee.default?.default??ee.default??ee.Lottie??ee,zt=({src:t,alt:e,style:o,size:i})=>{let[n,r]=Dn(null),[s,a]=Dn(!1);wr(()=>{t&&t.toLowerCase().endsWith(".json")?fetch(t).then(u=>{if(!u.ok)throw new Error("Failed to fetch Lottie");return u.json()}).then(u=>{r(u),a(!1)}).catch(u=>{console.error("AppStorys: Error loading Lottie thumbnail:",u),a(!0)}):(r(null),a(!1))},[t]);let c={width:i?`${i}px`:o?.width||"100%",height:i?`${i}px`:o?.height||"100%",objectFit:"cover",display:"block",...o};if(n&&!s){let u=_n.default||_n;return $n(u,{animationData:n,loop:!0,autoplay:!0,style:c})}return $n("img",{src:t,alt:e||"story thumbnail",style:c,onError:()=>a(!0)})};import{jsx as Eo,jsxs as kr}from"react/jsx-runtime";var Wn=({story:t,isViewed:e,onClick:o})=>{let i=t.styling||{},n=i.size||80,r=i.ringWidth||3,s=e?"#E5E7EB":t.ringColor||"#FF0000",a=t.nameColor||"#333333",c=i.cornerRadius,u=c?`${c.topLeft||0}px ${c.topRight||0}px ${c.bottomRight||0}px ${c.bottomLeft||0}px`:"50%",x=c?`${Math.max(0,(c.topLeft||0)-3)}px ${Math.max(0,(c.topRight||0)-3)}px ${Math.max(0,(c.bottomRight||0)-3)}px ${Math.max(0,(c.bottomLeft||0)-3)}px`:"50%";return kr("div",{onClick:o,style:{display:"flex",flexDirection:"column",alignItems:"center",cursor:"pointer",flexShrink:0},children:[Eo("div",{style:{width:`${n}px`,height:`${n}px`,borderRadius:u,border:`${r}px solid ${s}`,padding:"3px",boxSizing:"border-box",transition:"transform 0.1s ease",overflow:"hidden",backgroundColor:"#f5f5f5"},children:Eo(zt,{src:t.thumbnail,alt:t.name,style:{borderRadius:x}})}),Eo("span",{style:{marginTop:"6px",fontSize:`${i.name?.size||12}px`,fontFamily:ct(i.name?.fontFamily)||"sans-serif",fontWeight:i.name?.font==="Bold"?"bold":"normal",color:a,maxWidth:`${n+10}px`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name})]})};import{jsx as Mn}from"react/jsx-runtime";var On=({stories:t,viewedStories:e,onStoryClick:o})=>Mn("div",{style:{display:"flex",gap:"18px",padding:"16px 20px",overflowX:"auto",WebkitOverflowScrolling:"touch",justifyContent:"flex-start"},children:t.sort((i,n)=>i.order-n.order).map((i,n)=>Mn(Wn,{story:i,isViewed:e.includes(i.id),onClick:()=>o(n)},i.id))});import bi,{useState as St,useEffect as he,useRef as Uo}from"react";K();import{jsx as jn,jsxs as Po}from"react/jsx-runtime";var Nn=({data:t,onInteraction:e,isEditing:o=!1})=>{let i=t.layout?.type==="horizontal",n={headerTextColor:"#000000",optionBgColor:"#1A1A1A",optionTextColor:"#FFFFFF",backgroundColor:"#FFFFFF",borderRadius:24,padding:20},r=t.styling||{},s={backgroundColor:r.backgroundColor||n.backgroundColor,borderRadius:`${r.borderRadius??n.borderRadius}px`,overflow:"hidden",boxShadow:r.shadow||"0 12px 24px rgba(0,0,0,0.1)",boxSizing:"border-box",width:"100%",opacity:r.opacity??1,padding:`${r.padding??n.padding}px`,display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},a={color:r.headerTextColor||n.headerTextColor,textAlign:"center",fontWeight:"800",fontSize:`${r.fontSize?r.fontSize+4:20}px`,lineHeight:"1.2",margin:"0",width:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},c={display:"flex",flexDirection:i?"row":"column",gap:"4px",width:"100%",backgroundColor:"#1A1A1A",borderRadius:"12px",overflow:"hidden",padding:"2px"},u={backgroundColor:r.optionBgColor||"transparent",color:r.optionTextColor||n.optionTextColor,padding:i?"14px 10px":"16px 20px",fontSize:`${r.fontSize?r.fontSize+1:16}px`,fontWeight:"700",cursor:"pointer",border:"none",width:"100%",textAlign:"center",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.2s",flex:1,borderRight:i?"1px solid rgba(255,255,255,0.1)":"none",borderBottom:i?"none":"1px solid rgba(255,255,255,0.1)"},x=g=>{o||e?.({type:"poll",pollId:t.id,optionId:g,stickerId:t.id})},m=Array.isArray(t.options)?t.options:[];return Po("div",{style:s,children:[jn("h3",{style:a,children:t.question||"Ask A Question..."}),jn("div",{style:c,children:m.map((g,v)=>Po("button",{style:{...u,borderRight:i&&v===m.length-1?"none":u.borderRight,borderBottom:!i&&v===m.length-1?"none":u.borderBottom},onClick:()=>x(g.id),onMouseOver:f=>{o||(f.currentTarget.style.backgroundColor="rgba(255,255,255,0.1)")},onMouseOut:f=>{o||(f.currentTarget.style.backgroundColor=r.optionBgColor||"transparent")},children:[g.text,g.percentage!==void 0&&Po("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"8px"},children:[g.percentage,"%"]})]},g.id))})]})};import{useState as Rr}from"react";import{jsx as qe,jsxs as qn}from"react/jsx-runtime";var Un=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=Rr(null),r={backgroundColor:"#FFFFFF",borderRadius:20,padding:16,questionTextColor:"#FFFFFF",questionBgColor:"#000000",optionBgColor:"#FFFFFF",optionTextColor:"#2B2B2B",borderColor:"#E5E7EB",activeColor:"#10b981",incorrectColor:"#ef4444",labelBgColor:"#FFFFFF",labelTextColor:"#111111",labelBorderColor:"#111111"},s=t.styling||{},a=s.padding??r.padding,c=s.fontSize?s.fontSize+6:22,u=s.optionFontSize||17,x=s.optionBorderRadius||14,m=s.borderColor||r.borderColor,g=Math.min(Math.max(Math.round(u*2.1),18),32),v={backgroundColor:s.backgroundColor||r.backgroundColor,borderRadius:`${s.borderRadius??r.borderRadius}px`,padding:`${a}px`,paddingTop:0,boxShadow:s.shadow||"0 10px 30px rgba(0,0,0,0.12)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",overflow:"hidden",opacity:s.opacity??1},f={color:s.questionTextColor||r.questionTextColor,backgroundColor:s.questionBgColor||r.questionBgColor,fontWeight:"900",fontSize:`${c}px`,lineHeight:1.25,margin:`0 -${a}px 16px -${a}px`,textAlign:"center",padding:`24px ${a}px`,borderTopLeftRadius:`${s.borderRadius??r.borderRadius}px`,borderTopRightRadius:`${s.borderRadius??r.borderRadius}px`,letterSpacing:"-0.01em"},b={backgroundColor:s.optionBgColor||r.optionBgColor,color:s.optionTextColor||r.optionTextColor,padding:`${s.optionPadding||Math.max(a*.7,10)}px ${Math.max(a*.8,12)}px`,borderRadius:`${x}px`,border:`1px solid ${m}`,display:"flex",alignItems:"center",gap:`${Math.max(Math.round(g*.45),8)}px`,cursor:i?"default":"pointer",width:"100%",textAlign:"left",boxSizing:"border-box",transition:"all 0.2s ease",boxShadow:"0 1px 2px rgba(15,23,42,0.03)"},h={width:`${g}px`,height:`${g}px`,minWidth:`${g}px`,borderRadius:"50%",backgroundColor:s.labelBgColor||r.labelBgColor,color:s.labelTextColor||r.labelTextColor,border:`${Math.max(Math.round(g*.08),1)}px solid ${s.labelBorderColor||r.labelBorderColor}`,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"700",fontSize:`${Math.max(Math.round(g*.46),10)}px`},y={backgroundColor:s.backgroundColor||r.backgroundColor,borderRadius:`0 0 ${s.borderRadius??r.borderRadius}px ${s.borderRadius??r.borderRadius}px`,display:"flex",flexDirection:"column",gap:`${Math.max(a*.55,8)}px`},w=R=>{o||i||(n(R),e?.({type:"quiz",quizId:t.id,optionId:R,stickerId:t.id}))},I=["A","B","C","D","E","F"],z=Array.isArray(t.options)?t.options:[];return z.length===0&&!o&&console.warn("AppStorys: QuizSticker has no options!",t.id),qn("div",{style:{...v,background:s.backgroundColor||r.backgroundColor},children:[t.question&&qe("h3",{style:f,children:t.question}),qe("div",{style:{...y,background:"transparent"},children:z.map((R,d)=>{let T=R.label||I[d]||"\u2022",l=R.id===i,p=R.isCorrect===!0,M={...b},B={...h};return i&&(p?(M.backgroundColor=s.activeColor||r.activeColor,M.borderColor=s.activeColor||r.activeColor,M.color="#FFFFFF"):l&&(M.backgroundColor=s.incorrectColor||r.incorrectColor,M.borderColor=s.incorrectColor||r.incorrectColor,M.color="#FFFFFF")),qn("button",{style:M,onClick:()=>w(R.id),disabled:!!i,children:[qe("div",{style:h,className:"letter-circle",children:T}),qe("span",{style:{fontWeight:"600",fontSize:`${u}px`},children:R.text})]},R.id)})})]})};import{useState as Tr,useEffect as Fr}from"react";import{jsx as $t,jsxs as Hn}from"react/jsx-runtime";var Vn=({data:t})=>{let[e,o]=Tr({days:"00",hours:"00",minutes:"00",seconds:"00"});Fr(()=>{if(!t.targetDate)return;let T=()=>{let p=+new Date(t.targetDate)-+new Date;if(p>0){let M=Math.floor(p/864e5),B=Math.floor(p/(1e3*60*60)%24),L=Math.floor(p/1e3/60%60),C=Math.floor(p/1e3%60);o({days:M.toString().padStart(2,"0"),hours:B.toString().padStart(2,"0"),minutes:L.toString().padStart(2,"0"),seconds:C.toString().padStart(2,"0")})}else o({days:"00",hours:"00",minutes:"00",seconds:"00"})},l=setInterval(T,1e3);return T(),()=>clearInterval(l)},[t.targetDate]);let i=t.styling||{},n=t.display||{showDays:!0,showHours:!0,showMinutes:!0,showSeconds:!0},r=Number(i.digitSize||18),s=!isNaN(r)&&r>0?r:18,a=typeof i.labelFontSize<"u"?Number(i.labelFontSize):Math.max(10,Math.round(s*.55)),c=Math.max(30,Math.round(s*1.8)),u=Math.max(24,Math.round(s*1.3)),x=Math.max(6,Math.round(s*.35)),m=Math.max(6,Math.round(s*.25)),g={backgroundColor:i.backgroundColor||"#FFFFFF",borderRadius:`${i.borderRadius!==void 0?i.borderRadius:16}px`,padding:`${i.padding!==void 0?i.padding:16}px`,boxShadow:i.shadow||"0 10px 30px rgba(0,0,0,0.08)",width:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",border:i.borderColor?`1px solid ${i.borderColor}`:"none",overflow:"hidden",opacity:i.opacity??1},v={color:i.titleColor||"#000000",fontWeight:"700",fontSize:`${i.fontSize?i.fontSize:14}px`,width:"100%",textAlign:"center",marginBottom:"4px"},f={display:"flex",gap:`${m}px`,width:"100%",justifyContent:"center",alignItems:"center",flexWrap:"nowrap"},b={display:"flex",flexDirection:"column",alignItems:"center",gap:"2px"},h={display:"flex",gap:"2px"},y={backgroundColor:i.digitBackground||"#F1F3F5",borderRadius:`${x}px`,minWidth:`${u}px`,height:`${c}px`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${s}px`,fontWeight:"bold",color:i.digitColor||"#1A202C",padding:"0 4px"},w={fontSize:`${Math.max(9,a)}px`,color:i.labelColor||"#A0AEC0",fontWeight:"600",textTransform:"lowercase"},I={fontSize:`${Math.max(14,Math.round(s*.9))}px`,fontWeight:"700",color:i.labelColor||"#A0AEC0",display:"flex",alignItems:"center",lineHeight:1},z=(T,l)=>Hn("div",{style:b,children:[$t("div",{style:h,children:T.split("").map((p,M)=>$t("div",{style:y,children:p},M))}),$t("span",{style:w,children:l})]}),R=[],d=0;return n.showDays!==!1&&(R.push(z(e.days,"days")),d++),n.showHours!==!1&&(d>0&&R.push($t("div",{style:I,children:":"},"sep-h")),R.push(z(e.hours,"hours")),d++),n.showMinutes!==!1&&(d>0&&R.push($t("div",{style:I,children:":"},"sep-m")),R.push(z(e.minutes,"min")),d++),n.showSeconds!==!1&&(d>0&&R.push($t("div",{style:I,children:":"},"sep-s")),R.push(z(e.seconds,"sec")),d++),Hn("div",{style:g,children:[t.title&&$t("div",{style:v,children:t.title}),$t("div",{style:f,children:R})]})};import{useState as Ir}from"react";import{jsx as oe,jsxs as Ue}from"react/jsx-runtime";var Yn=({data:t,onInteraction:e})=>{let[o,i]=Ir(!1),n=()=>{t.code&&(navigator.clipboard.writeText(t.code).catch(()=>{}),i(!0),e?.({type:"promo_code",value:"copied",stickerId:t.id,code:t.code}),setTimeout(()=>i(!1),2e3))},r=t.styling||{},s={backgroundColor:r.backgroundColor||"#FFFFFF",padding:"12px 18px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",height:"60px",boxSizing:"border-box",position:"relative",filter:"drop-shadow(0 8px 16px rgba(0,0,0,0.1))",cursor:"pointer",clipPath:"polygon(0% 0%, 0% 40%, 4% 50%, 0% 60%, 0% 100%, 100% 100%, 100% 60%, 96% 50%, 100% 40%, 100% 0%)",backgroundImage:`
34
- radial-gradient(circle at 0px 30px, transparent 8px, white 8.5px),
35
- radial-gradient(circle at 100% 30px, transparent 8px, white 8.5px)
36
- `,backgroundPosition:"0 0, 100% 0",backgroundSize:"100% 100%",backgroundRepeat:"no-repeat"},a={width:"36px",height:"36px",borderRadius:"8px",backgroundColor:"#F1F3F5",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"18px",fontWeight:"800",color:"#2D3748",border:"1px solid #E2E8F0"},c={fontSize:`${r.fontSize||18}px`,fontWeight:"800",color:"#1A202C",letterSpacing:"1px",flex:1,textAlign:"center"};return Ue("div",{style:s,onClick:n,children:[Ue("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[oe("div",{style:a,children:"%"}),oe("span",{style:c,children:t.code||"OFFER20"})]}),Ue("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[o&&oe("span",{style:{fontSize:"11px",color:"#10B981",fontWeight:"700"},children:"Copied!"}),oe("div",{style:{padding:"8px",display:"flex",alignItems:"center"},children:Ue("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#4A5568",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[oe("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),oe("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]})};import{jsx as Qn}from"react/jsx-runtime";var Gn=({data:t,onInteraction:e,isEditing:o=!1})=>{let i={emojis:["\u{1F60D}","\u{1F44D}"]},n=Array.isArray(t.emojis)?t.emojis:Array.isArray(i.emojis)?i.emojis:[],r=c=>{o||e?.({type:"reaction",reactionId:t.id,emoji:c,stickerId:t.id})},s={display:"flex",gap:"20px",justifyContent:"center",alignItems:"center",width:"100%",padding:"12px"},a={backgroundColor:"#FFFFFF",width:"64px",height:"64px",borderRadius:"100px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 8px 30px rgba(0,0,0,0.12)",fontSize:"32px",cursor:o?"default":"pointer",transition:"all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)",border:"none",outline:"none",padding:0,position:"relative",zIndex:1};return Qn("div",{style:s,children:n.map((c,u)=>Qn("button",{style:a,onClick:()=>r(c),onMouseOver:x=>{o||(x.currentTarget.style.transform="scale(1.15) translateY(-4px)")},onMouseOut:x=>{o||(x.currentTarget.style.transform="scale(1) translateY(0)")},children:c},u))})};import{useState as Jn,useRef as zr,useEffect as Br}from"react";import{jsx as Lo,jsxs as Xn}from"react/jsx-runtime";var Kn=({data:t,onInteraction:e,isEditing:o=!1})=>{let i=t.maxRating||5,n=t.currentRating??Math.floor(i/2),[r,s]=Jn(n),a=zr(null),[c,u]=Jn(!1),x={backgroundColor:"#FFFFFF",borderRadius:36,padding:24,titleColor:"#000000",titleFontSize:24,sliderTrackColor:"#F3F4F6",sliderFillColor:"#F97316",emojiSize:42},m=t.styling||{},g={backgroundColor:m.backgroundColor||x.backgroundColor,borderRadius:`${m.borderRadius??x.borderRadius}px`,padding:`${m.padding??x.padding}px`,boxShadow:m.shadow||"0 12px 30px rgba(0,0,0,0.08)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",cursor:"default",opacity:m.opacity??1},v={color:m.titleColor||x.titleColor,fontWeight:"900",fontSize:`${m.titleFontSize||x.titleFontSize}px`,margin:"0",textAlign:"center",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:"100%"},f={width:"100%",height:"18px",backgroundColor:m.sliderTrackColor||x.sliderTrackColor,borderRadius:"100px",position:"relative",cursor:o?"default":"pointer",marginTop:"24px",marginBottom:"8px",userSelect:"none"},b=r/i*100,h={width:`${b}%`,height:"100%",background:m.sliderFillColor||"linear-gradient(90deg, #FF4582, #e11d48)",borderRadius:"100px",transition:c?"none":"width 0.1s ease"},y=m.emojiSize||x.emojiSize,w={position:"absolute",left:`calc(${b}% - ${y/2}px)`,top:`-${y/4}px`,fontSize:`${y}px`,userSelect:"none",cursor:"grab",transition:c?"none":"left 0.1s ease",filter:"drop-shadow(0 4px 8px rgba(0,0,0,0.2))"},I=d=>{if(!a.current||o)return;let T=a.current.getBoundingClientRect(),l=d-T.left;l<0&&(l=0),l>T.width&&(l=T.width);let p=l/T.width,M=Math.round(p*i*10)/10;s(M)},z=d=>{o||(u(!0),I(d.clientX))},R=d=>{o||(u(!0),I(d.touches[0].clientX))};return Br(()=>{let d=p=>{c&&I(p.clientX)},T=()=>{c&&(u(!1),e?.({type:"rating",ratingId:t.id,value:r,stickerId:t.id}))},l=p=>{c&&I(p.touches[0].clientX)};return c&&(window.addEventListener("mousemove",d),window.addEventListener("mouseup",T),window.addEventListener("touchmove",l),window.addEventListener("touchend",T)),()=>{window.removeEventListener("mousemove",d),window.removeEventListener("mouseup",T),window.removeEventListener("touchmove",l),window.removeEventListener("touchend",T)}},[c,r]),Xn("div",{style:g,children:[Lo("h3",{style:v,children:t.title||"Do you like my space?"}),Xn("div",{ref:a,style:f,onMouseDown:z,onTouchStart:R,children:[Lo("div",{style:h}),Lo("div",{style:w,className:"interactive-emoji-thumb",children:t.emoji||"\u{1F60D}"})]})]})};import{useState as Ar}from"react";import{jsx as ue,jsxs as Do}from"react/jsx-runtime";var Zn=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=Ar(""),r={backgroundColor:"#FFFFFF",borderRadius:16,padding:16,promptColor:"#111111",inputBgColor:"#FFFFFF",borderColor:"#EFEFEF",textColor:"#333333",placeholderColor:"#A0AEC0"},s=t.styling||{},a={backgroundColor:s.backgroundColor||r.backgroundColor,borderRadius:`${s.borderRadius??r.borderRadius}px`,padding:`${s.padding??r.padding}px`,boxShadow:s.shadow||"0 8px 24px rgba(0,0,0,0.06)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",border:`1px solid ${s.borderColor||"#F0F0F0"}`},c={color:s.promptColor||r.promptColor,fontWeight:"700",fontSize:`${s.fontSize?s.fontSize+2:16}px`,textAlign:"center",marginBottom:"2px",width:"100%"},u={width:"100%",position:"relative",display:"flex",alignItems:"center"},x={backgroundColor:s.inputBgColor||"#F1F3F5",border:"none",borderRadius:"30px",padding:"14px 45px 14px 20px",width:"100%",boxSizing:"border-box",color:s.inputTextColor||"#1A202C",fontSize:`${s.fontSize||14}px`,outline:"none",textAlign:"left",cursor:o?"default":"text",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},m={position:"absolute",right:"10px",background:s.submitBackground||"#FE6B35",color:"white",border:"none",borderRadius:"50%",width:"32px",height:"32px",display:i.length>0?"flex":"none",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"transform 0.2s"},g=f=>{o||n(f.target.value)},v=()=>{o||!i.trim()||(e?.({type:"question",questionId:t.id,value:i.trim(),stickerId:t.id}),n(""))};return Do("div",{style:a,children:[ue("div",{style:c,children:t.question||"Ask me anything"}),Do("div",{style:u,children:[ue("input",{type:"text",value:i,placeholder:t.placeholder||"Type your answer...",style:x,disabled:o,onChange:g,onKeyDown:f=>f.key==="Enter"&&v()}),ue("button",{style:m,onClick:v,children:Do("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[ue("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),ue("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})};import{useState as Er}from"react";import{jsx as ge,jsxs as _o}from"react/jsx-runtime";var ti=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=Er(null),r={backgroundColor:"#FFFFFF",borderRadius:20,padding:16,questionTextColor:"#111111",optionBgColor:"#F7FAFC",optionTextColor:"#2D3748",borderColor:"#E2E8F0",activeColor:"#10B981",incorrectColor:"#EF4444"},s=t.styling||{},a={backgroundColor:s.backgroundColor||r.backgroundColor,borderRadius:`${s.borderRadius??r.borderRadius}px`,padding:`${s.padding??r.padding}px`,boxShadow:s.shadow||"0 8px 24px rgba(0,0,0,0.06)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",gap:"12px",border:s.borderColor?`1px solid ${s.borderColor}`:"none"},c={color:s.questionTextColor||r.questionTextColor,fontWeight:"800",fontSize:`${s.fontSize?s.fontSize+2:16}px`,margin:"0 0 4px 0",textAlign:"left"},u={display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"12px",width:"100%"},x={backgroundColor:s.optionBgColor||r.optionBgColor,color:s.optionTextColor||r.optionTextColor,borderRadius:"16px",border:`2px solid ${s.borderColor||r.borderColor}`,cursor:i?"default":"pointer",display:"flex",flexDirection:"column",alignItems:"center",padding:"8px",boxSizing:"border-box",transition:"all 0.2s ease",overflow:"hidden"},m=f=>{o||i||(n(f),e?.({type:"image",quizId:t.id,optionId:f,stickerId:t.id}))},g="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",v=Array.isArray(t.options)?t.options:[];return _o("div",{style:a,children:[t.question&&ge("h3",{style:c,children:t.question}),ge("div",{style:u,children:v.map(f=>{let b=f.id===i,h=f.isCorrect===!0,y={...x};return i&&(h?(y.borderColor=s.activeColor||r.activeColor,y.backgroundColor="rgba(16, 185, 129, 0.05)"):b&&(y.borderColor=s.incorrectColor||r.incorrectColor,y.backgroundColor="rgba(239, 68, 68, 0.05)")),_o("button",{style:y,onClick:()=>m(f.id),disabled:!!i,onMouseOver:w=>{!o&&!i&&(w.currentTarget.style.transform="translateY(-2px)")},onMouseOut:w=>{!o&&!i&&(w.currentTarget.style.transform="translateY(0)")},children:[_o("div",{style:{width:"100%",aspectRatio:"1",borderRadius:"12px",overflow:"hidden",backgroundColor:"#EDF2F7",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"8px",position:"relative"},children:[ge("img",{src:f.image||g,alt:f.text,style:{width:"100%",height:"100%",objectFit:"cover"}}),i&&ge("div",{style:{position:"absolute",top:"6px",right:"6px",width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:h?r.activeColor:b?r.incorrectColor:"#A0AEC0",color:"#FFFFFF",fontSize:"12px",fontWeight:"bold"},children:h?"\u2713":b?"\u2715":""})]}),ge("span",{style:{fontWeight:"600",fontSize:`${s.optionFontSize||13}px`,color:i&&h?r.activeColor:r.optionTextColor,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:f.text})]},f.id)})})]})};import{useState as ai}from"react";import{useState as fe,useEffect as Pr}from"react";import{jsx as U,jsxs as ot}from"react/jsx-runtime";var si=({product:t,styling:e,onClose:o,onAddToCart:i})=>{let[n,r]=fe(""),[s,a]=fe(0),[c,u]=fe(1),[x,m]=fe(!1),[g,v]=fe(!1),f=t.attributes||{},b=f.colors||[],h=f.sizes||[],y=f.imageUrls||[t.image],w=f.description||"";Pr(()=>{h.length>0&&r(h[0]),v(!0)},[h]);let I=()=>{let C={productId:t.productId||t.id,title:t.title,selectedSize:n,selectedColor:b[s]?.name,quantity:c,price:t.price};i(C);let S=t.redirectUrl||t.url;if(S){!S.startsWith("http")&&!S.startsWith("//")&&(S="https://"+S);try{window.open(S,"_blank","noopener,noreferrer")}catch(_){console.error("AppStorys: Redirect failed",_)}}m(!0)},z=()=>{v(!1),setTimeout(o,400)},R=e?.buttonBackground||"#000000",d=e?.buttonTextColor||"#ffffff",T=e?.titleColor||e?.textColor||"#1a1a2e",l=e?.priceColor||e?.textColor||"#1a1a2e",p=e?.mrpColor||"#8b8b98",M=e?.titleFontWeight||"600",B=e?.priceFontWeight||"700",L=e?.mrpFontWeight||"500";return x?ot("div",{className:"appstorys-shopable-success-overlay",style:ei,children:[U("div",{className:"appstorys-shopable-backdrop",style:oi,onClick:z}),ot("div",{className:"appstorys-shopable-sheet",style:{...ni,height:"auto",minHeight:"310px",animation:"appstorys-slide-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[U("div",{style:ii,onClick:z}),ot("div",{style:{padding:"0 20px 24px",textAlign:"center"},children:[ot("div",{style:{backgroundColor:"#F3F4F6",borderRadius:"20px",padding:"22px",marginTop:"16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[ot("h3",{style:{margin:0,fontSize:"16px",fontWeight:"600",lineHeight:"1.4"},children:["Added to your bag",U("br",{}),"successfully"]}),U("svg",{width:"44",height:"26",viewBox:"0 0 44 26",fill:"none",children:U("path",{d:"M4 4C4 4 11 22 22 22C33 22 40 4 40 4",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round"})})]}),ot("div",{style:{marginTop:"24px",display:"flex",flexDirection:"column",gap:"8px"},children:[U("button",{onClick:z,style:{...Mo,backgroundColor:"#000000",color:"#ffffff",padding:"17px",fontSize:"16px",fontWeight:"600"},children:ot("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[ot("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[U("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),U("path",{d:"M3 6h18"}),U("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),"Go to checkout"]})}),U("button",{onClick:z,style:{...Mo,backgroundColor:"transparent",color:"#000000",border:"1px solid rgba(0,0,0,0.1)",padding:"15px",fontSize:"16px"},children:"Continue with stories"})]})]})]})]}):ot("div",{className:`appstorys-shopable-overlay ${g?"visible":""}`,style:ei,children:[U("div",{className:"appstorys-shopable-backdrop",style:oi,onClick:z}),ot("div",{className:"appstorys-shopable-sheet",style:{...ni,transform:g?"translateY(0)":"translateY(100%)",opacity:g?1:0},children:[ot("div",{style:Lr,children:[U("div",{style:ii,onClick:z}),U("button",{style:Dr,onClick:z,children:ot("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[U("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),U("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),ot("div",{style:_r,children:[U("div",{style:$r,children:y.map((C,S)=>U("div",{style:{minWidth:y.length>1?"85%":"100%",aspectRatio:"1.2 / 1",maxHeight:"240px",borderRadius:"16px",overflow:"hidden",backgroundColor:"#F9FAFB"},children:U("img",{src:C,alt:t.title,style:{width:"100%",height:"100%",objectFit:"contain"}})},S))}),ot("div",{style:{padding:"0 20px 20px"},children:[U("h2",{style:{margin:"16px 0 4px",fontSize:e?.titleFontSize?`${e.titleFontSize}px`:"20px",fontWeight:M,color:T,lineHeight:"1.2"},children:t.title}),ot("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",marginBottom:"16px"},children:[U("span",{style:{fontSize:e?.priceFontSize?`${e.priceFontSize}px`:"18px",fontWeight:B,color:l},children:t.price}),t.oldPrice&&U("span",{style:{fontSize:e?.mrpFontSize?`${e.mrpFontSize}px`:"14px",color:p,textDecoration:"line-through",fontWeight:L},children:t.oldPrice})]}),b.length>0&&ot("div",{style:$o,children:[U("div",{style:Wo,children:"COLOR"}),U("div",{style:{display:"flex",gap:"14px",marginTop:"12px"},children:b.map((C,S)=>ot("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"5px"},children:[U("button",{onClick:()=>a(S),style:{width:"36px",height:"36px",borderRadius:"50%",border:"none",backgroundColor:C.hex||"#gray",position:"relative",cursor:"pointer",boxShadow:s===S?"0 0 0 2px #fff, 0 0 0 4px #000":"none",transition:"all 0.2s ease"}}),U("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:s===S?"#000":"transparent",transition:"all 0.2s ease"}})]},C.id))})]}),h.length>0&&ot("div",{style:$o,children:[U("div",{style:Wo,children:"SIZE"}),U("div",{style:{display:"flex",gap:"10px",marginTop:"12px",flexWrap:"wrap"},children:h.map(C=>ot("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},children:[U("button",{onClick:()=>r(C),style:{minWidth:"42px",height:"42px",borderRadius:"50%",backgroundColor:"transparent",border:`1px solid ${n===C?"#000":"rgba(0,0,0,0.1)"}`,color:n===C?"#000":"#8b8b98",fontSize:"13px",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:C}),U("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:n===C?"#000":"transparent",transition:"all 0.2s ease"}})]},C))})]}),w&&ot("div",{style:$o,children:[U("div",{style:Wo,children:"DESCRIPTION"}),U("p",{style:{margin:"8px 0 0",fontSize:"14px",lineHeight:"1.5",color:"#8b8b98",wordBreak:"break-word"},children:w})]})]})]}),ot("div",{style:Wr,children:[ot("div",{style:{display:"flex",flexDirection:"column",gap:"1px",minWidth:"75px"},children:[U("div",{style:{fontSize:"15px",fontWeight:B,color:l},children:t.price}),t.oldPrice&&U("div",{style:{fontSize:"11px",color:p,textDecoration:"line-through",fontWeight:L},children:t.oldPrice})]}),ot("div",{style:Mr,children:[U("button",{style:ri,onClick:()=>u(C=>Math.max(1,C-1)),children:U("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:U("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}),U("span",{style:{fontSize:"16px",fontWeight:"700",minWidth:"18px",textAlign:"center",color:"#000000",display:"inline-block"},children:c}),U("button",{style:ri,onClick:()=>u(C=>C+1),children:ot("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[U("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),U("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),(()=>{let C=f.availability?.toLowerCase()||"",S=C==="out of stock"||C==="out-of-stock";return ot("button",{onClick:S?void 0:I,disabled:S,style:{...Mo,backgroundColor:S?"#F3F4F6":R,color:S?"#9CA3AF":d,flex:"1",padding:"12px 8px",gap:"6px",cursor:S?"not-allowed":"pointer",opacity:S?.8:1},children:[!S&&ot("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[U("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),U("path",{d:"M3 6h18"}),U("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),U("span",{style:{fontSize:"12px",fontWeight:"700",whiteSpace:"nowrap"},children:S?"Out of Stock":"Add to cart"})]})})()]})]}),U("style",{children:`
33
+ `,document.head.appendChild(t)}function hi(t){let e=document.createElement("div");return e.className="appstorys-widget-debug-pill",e.textContent=t,e}function ds(t){let e=t,o=getComputedStyle(e);(o.position==="static"||!o.position)&&(e.style.position="relative")}window.AppStorysShowWidgetElements=function(){try{ls();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(i=>{let n=document.querySelector(i);n&&e.push(n)}),!e.length){let o=hi("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,i)=>{let n=o;ds(n),n.classList.add("appstorys-widget-debug-overlay");let r=n.querySelector(".appstorys-widget-debug-pill");r&&r.remove();let l=hi("Widget "+(i+1));n.appendChild(l)})}catch(e){console.error("AppStorysShowWidgetElements error",e)}};ot();import{useState as ir,useEffect as rr}from"react";import{useEffect as cs,useState as bi}from"react";import*as we from"lottie-react";import{jsx as Si}from"react/jsx-runtime";var xi=we.default?.default??we.default??we.Lottie??we,Wt=({src:t,alt:e,style:o,size:i})=>{let[n,r]=bi(null),[l,d]=bi(!1);cs(()=>{t&&t.toLowerCase().endsWith(".json")?fetch(t).then(y=>{if(!y.ok)throw new Error("Failed to fetch Lottie");return y.json()}).then(y=>{r(y),d(!1)}).catch(y=>{console.error("AppStorys: Error loading Lottie thumbnail:",y),d(!0)}):(r(null),d(!1))},[t]);let c={width:i?`${i}px`:o?.width||"100%",height:i?`${i}px`:o?.height||"100%",objectFit:"cover",display:"block",...o};if(n&&!l){let y=xi.default||xi;return Si(y,{animationData:n,loop:!0,autoplay:!0,style:c})}return Si("img",{src:t,alt:e||"story thumbnail",style:c,onError:()=>d(!0)})};import{jsx as rn,jsxs as us}from"react/jsx-runtime";var Ci=({story:t,isViewed:e,onClick:o})=>{let i=t.styling||{},n=i.size||80,r=i.ringWidth||3,l=e?"#E5E7EB":t.ringColor||"#FF0000",d=t.nameColor||"#333333",c=i.cornerRadius,y=c?`${c.topLeft||0}px ${c.topRight||0}px ${c.bottomRight||0}px ${c.bottomLeft||0}px`:"50%",b=c?`${Math.max(0,(c.topLeft||0)-3)}px ${Math.max(0,(c.topRight||0)-3)}px ${Math.max(0,(c.bottomRight||0)-3)}px ${Math.max(0,(c.bottomLeft||0)-3)}px`:"50%";return us("div",{onClick:o,style:{display:"flex",flexDirection:"column",alignItems:"center",cursor:"pointer",flexShrink:0},children:[rn("div",{style:{width:`${n}px`,height:`${n}px`,borderRadius:y,border:`${r}px solid ${l}`,padding:"3px",boxSizing:"border-box",transition:"transform 0.1s ease",overflow:"hidden",backgroundColor:"#f5f5f5"},children:rn(Wt,{src:t.thumbnail,alt:t.name,style:{borderRadius:b}})}),rn("span",{style:{marginTop:"6px",fontSize:`${i.name?.size||12}px`,fontFamily:gt(i.name?.fontFamily)||"sans-serif",fontWeight:i.name?.font==="Bold"?"bold":"normal",color:d,maxWidth:`${n+10}px`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name})]})};import{jsx as vi}from"react/jsx-runtime";var wi=({stories:t,viewedStories:e,onStoryClick:o})=>vi("div",{style:{display:"flex",gap:"18px",padding:"16px 20px",overflowX:"auto",WebkitOverflowScrolling:"touch",justifyContent:"flex-start"},children:t.sort((i,n)=>i.order-n.order).map((i,n)=>vi(Ci,{story:i,isViewed:e.includes(i.id),onClick:()=>o(n)},i.id))});import er,{useState as Tt,useEffect as Ne,useRef as vo}from"react";ot();var Q=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=Q(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}}},ut=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:i,to:n,stops:r=[]}=e.gradient,d={right:"to right",left:"to left",top:"to top",bottom:"to bottom"}[o]||o;if(r.length>0){let c=r.map(y=>{let b=y.offset,h="0%";if(b!=null){let f=String(b).trim();if(f.endsWith("%"))h=f;else{let v=Number(f);isNaN(v)||(h=v>1?`${v}%`:`${Math.round(v*100)}%`)}}return`${y.color} ${h}`}).join(", ");return`linear-gradient(${d}, ${c})`}return`linear-gradient(${d}, ${i}, ${n})`}return Q(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`},K=(t,e="px")=>{if(t==null||t==="")return"";let o=String(t).trim();return/^[\d.-]+$/.test(o)?`${o}${e}`:o};import ps from"react";import{jsx as yo,jsxs as ho}from"react/jsx-runtime";var ki=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=ps.useState(()=>{try{return localStorage.getItem(`appstorys_poll_${t.id}`)}catch{return null}}),r=t.layout?.type==="horizontal",l={headerTextColor:"#000000",optionBgColor:"#1A1A1A",optionTextColor:"#FFFFFF",backgroundColor:"#FFFFFF",borderRadius:24,padding:20},d=t.styling||{},c={backgroundColor:d.backgroundColor||l.backgroundColor,borderRadius:K(d.borderRadius??l.borderRadius),overflow:"hidden",boxShadow:d.shadow||"0 12px 24px rgba(0,0,0,0.1)",boxSizing:"border-box",width:"100%",opacity:d.opacity??1,padding:K(d.padding??l.padding),display:"flex",flexDirection:"column",alignItems:"center",gap:"10px"},y={color:d.headerTextColor||l.headerTextColor,textAlign:"center",fontWeight:"800",fontSize:typeof d.fontSize=="string"?`min(${d.fontSize}, 16px)`:`${d.fontSize?Math.min(Number(d.fontSize),16):15}px`,lineHeight:"1.25",margin:"0",width:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},b={display:"flex",flexDirection:r?"row":"column",gap:i&&r?"0px":"4px",width:"100%",backgroundColor:"#1A1A1A",borderRadius:"12px",overflow:"hidden",padding:"0px"},h={backgroundColor:d.optionBgColor||"transparent",color:d.optionTextColor||l.optionTextColor,padding:r?"10px 8px":"10px 14px",fontSize:typeof d.fontSize=="string"?`min(${d.fontSize}, 14px)`:`${d.fontSize?Math.min(Number(d.fontSize),14):13}px`,fontWeight:"700",cursor:i?"default":"pointer",border:"none",width:"100%",textAlign:"center",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.6s cubic-bezier(0.4, 0, 0.2, 1)",flex:1,borderRight:r?"1px solid rgba(255,255,255,0.1)":"none",borderBottom:r?"none":"1px solid rgba(255,255,255,0.1)",position:"relative",overflow:"hidden"},f=Array.isArray(t.options)?t.options:[],v=g=>{let C=f.find(I=>I.id===g);if(!C)return 0;if(C.percentage!==void 0)return C.percentage;if(C.votes!==void 0){let I=f.reduce((z,E)=>z+(E.votes||0),0);if(I>0)return Math.round(C.votes/I*100)}return i?g===i?f.length===1?100:60:Math.round(40/(f.length-1)):0},S=(g,C)=>{let I=g.replace("#","");I.length===3&&(I=I.split("").map(D=>D+D).join(""));let z=parseInt(I.substring(0,2),16)||0,E=parseInt(I.substring(2,4),16)||0,w=parseInt(I.substring(4,6),16)||0;return`rgba(${z}, ${E}, ${w}, ${C})`},u=g=>{let C=g===i,I=C?d.activeResultBarColor:d.inactiveResultBarColor,z=I?.color||(C?"#F97316":"#404040"),E=I?.opacity!==void 0?I.opacity/100:1;return z.startsWith("#")&&(z.length===7||z.length===4)?S(z,E):z},m=g=>{if(!(o||i)){n(g);try{localStorage.setItem(`appstorys_poll_${t.id}`,g)}catch{}e?.({type:"poll",pollId:t.id,optionId:g,stickerId:t.id})}};return ho("div",{style:c,children:[yo("h3",{style:y,children:t.question||"Ask A Question..."}),yo("div",{style:b,children:f.map((g,C)=>{let I=v(g.id),z=i!==null,E=g.id===i,w=z&&r?u(g.id):d.optionBgColor||"transparent";return ho("button",{style:{...h,flex:z&&r?I:1,backgroundColor:w,borderRight:z||r&&C===f.length-1?"none":h.borderRight,borderBottom:z||!r&&C===f.length-1?"none":h.borderBottom},onClick:()=>m(g.id),disabled:z,onMouseOver:D=>{!o&&!z&&(D.currentTarget.style.backgroundColor="rgba(255,255,255,0.1)")},onMouseOut:D=>{!o&&!z&&(D.currentTarget.style.backgroundColor=d.optionBgColor||"transparent")},children:[z&&!r&&yo("div",{style:{position:"absolute",top:0,left:0,bottom:0,width:`${I}%`,backgroundColor:u(g.id),transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)",zIndex:1}}),ho("div",{style:{display:"flex",flexDirection:r?"column":"row",justifyContent:r?"center":"space-between",alignItems:"center",width:"100%",zIndex:2,position:"relative"},children:[yo("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:g.text}),z&&ho("span",{style:{fontWeight:"800",fontSize:r?"12px":"15px",marginTop:r?"4px":"0"},children:[I,"%"]})]})]},g.id)})})]})};import{useState as gs}from"react";import{jsx as bo,jsxs as Ri}from"react/jsx-runtime";var Ti=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=gs(()=>{try{return localStorage.getItem(`appstorys_quiz_${t.id}`)}catch{return null}}),r={backgroundColor:"#FFFFFF",borderRadius:20,padding:16,questionTextColor:"#FFFFFF",questionBgColor:"#000000",optionBgColor:"#FFFFFF",optionTextColor:"#2B2B2B",borderColor:"#E5E7EB",activeColor:"#10b981",incorrectColor:"#ef4444",labelBgColor:"#FFFFFF",labelTextColor:"#111111",labelBorderColor:"#111111"},l=t.styling||{},d=K(l.padding??r.padding),y=typeof l.fontSize=="string"?`min(${l.fontSize}, 16px)`:`${l.fontSize?Math.min(Number(l.fontSize),16):15}px`,b=typeof l.optionFontSize=="string",h=K(l.optionFontSize||13),f=K(l.optionBorderRadius||14),v=l.borderColor||r.borderColor,S=b?`max(min(calc(${h} * 1.8), 24px), 16px)`:`${Math.min(Math.max(Math.round(Number(l.optionFontSize||13)*1.8),16),24)}px`,u=b?`max(calc(${S} * 0.08), 1px)`:`${Math.max(Math.round(Number(S.replace("px",""))*.08),1)}px`,m=b?`max(calc(${S} * 0.46), 10px)`:`${Math.max(Math.round(Number(S.replace("px",""))*.46),10)}px`,g=b?`max(calc(${S} * 0.45), 8px)`:`${Math.max(Math.round(Number(S.replace("px",""))*.45),8)}px`,C=b?`calc(${d} * 0.6) calc(${d} * 0.7)`:"11px 14px",I=b?`max(calc(${d} * 0.45), 8px)`:"8px",z={backgroundColor:l.backgroundColor||r.backgroundColor,borderRadius:K(l.borderRadius??r.borderRadius),padding:d,paddingTop:0,paddingBottom:"12px",boxShadow:l.shadow||"0 10px 30px rgba(0,0,0,0.12)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",overflow:"hidden",opacity:l.opacity??1},E={color:l.questionTextColor||r.questionTextColor,backgroundColor:l.questionBgColor||r.questionBgColor,fontWeight:"900",fontSize:y,lineHeight:1.25,margin:`0 calc(-1 * ${d}) 12px calc(-1 * ${d})`,textAlign:"center",padding:`16px ${d}`,borderTopLeftRadius:K(l.borderRadius??r.borderRadius),borderTopRightRadius:K(l.borderRadius??r.borderRadius),letterSpacing:"-0.01em"},w={backgroundColor:l.optionBgColor||r.optionBgColor,color:l.optionTextColor||r.optionTextColor,padding:C,borderRadius:f,border:`1px solid ${v}`,display:"flex",alignItems:"center",gap:g,cursor:i?"default":"pointer",width:"100%",textAlign:"left",boxSizing:"border-box",transition:"all 0.2s ease",boxShadow:"0 1px 2px rgba(15,23,42,0.03)"},D={width:S,height:S,minWidth:S,borderRadius:"50%",backgroundColor:l.labelBgColor||r.labelBgColor,color:l.labelTextColor||r.labelTextColor,border:`${u} solid ${l.labelBorderColor||r.labelBorderColor}`,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"700",fontSize:m},_={backgroundColor:l.backgroundColor||r.backgroundColor,borderRadius:`0 0 ${K(l.borderRadius??r.borderRadius)} ${K(l.borderRadius??r.borderRadius)}`,display:"flex",flexDirection:"column",gap:I},P=a=>{if(!(o||i)){n(a);try{localStorage.setItem(`appstorys_quiz_${t.id}`,a)}catch{}e?.({type:"quiz",quizId:t.id,optionId:a,stickerId:t.id})}},H=["A","B","C","D","E","F"],B=Array.isArray(t.options)?t.options:[];return B.length===0&&!o&&console.warn("AppStorys: QuizSticker has no options!",t.id),Ri("div",{style:{...z,background:l.backgroundColor||r.backgroundColor},children:[t.question&&bo("h3",{style:E,children:t.question}),bo("div",{style:{..._,background:"transparent"},children:B.map((a,x)=>{let s=a.label||H[x]||"\u2022",p=a.id===i,M=a.isCorrect===!0,T={...w},R={...D};return i&&(M?(T.backgroundColor=l.activeColor||r.activeColor,T.borderColor=l.activeColor||r.activeColor,T.color="#FFFFFF"):p&&(T.backgroundColor=l.incorrectColor||r.incorrectColor,T.borderColor=l.incorrectColor||r.incorrectColor,T.color="#FFFFFF")),Ri("button",{style:T,onClick:()=>P(a.id),disabled:!!i,children:[bo("div",{style:D,className:"letter-circle",children:s}),bo("span",{style:{fontWeight:"600",fontSize:h},children:a.text})]},a.id)})})]})};import{useState as fs,useEffect as ms}from"react";import{jsx as te,jsxs as Fi}from"react/jsx-runtime";var zi=({data:t})=>{let[e,o]=fs({days:"00",hours:"00",minutes:"00",seconds:"00"});ms(()=>{if(!t.targetDate)return;let P=()=>{let B=+new Date(t.targetDate)-+new Date;if(B>0){let a=Math.floor(B/864e5),x=Math.floor(B/(1e3*60*60)%24),s=Math.floor(B/1e3/60%60),p=Math.floor(B/1e3%60);o({days:a.toString().padStart(2,"0"),hours:x.toString().padStart(2,"0"),minutes:s.toString().padStart(2,"0"),seconds:p.toString().padStart(2,"0")})}else o({days:"00",hours:"00",minutes:"00",seconds:"00"})},H=setInterval(P,1e3);return P(),()=>clearInterval(H)},[t.targetDate]);let i=t.styling||{},n=t.display||{showDays:!0,showHours:!0,showMinutes:!0,showSeconds:!0},r=i.digitSize||i.fontSize,l=typeof r=="string",d=l?r:`${!isNaN(Number(r))&&Number(r)>0?Number(r):18}px`,c=i.labelFontSize?K(i.labelFontSize):l?`calc(${d} * 0.45)`:`${Math.max(10,Math.round(Number(r||18)*.45))}px`,y=l?`calc(${d} * 1.65)`:`${Math.max(36,Math.round(Number(r||18)*1.65))}px`,b=l?`calc(${d} * 0.95)`:`${Math.max(26,Math.round(Number(r||18)*.95))}px`,h=l?`calc(${d} * 0.25)`:`${Math.max(6,Math.round(Number(r||18)*.25))}px`,f=l?`calc(${d} * 0.15)`:`${Math.max(6,Math.round(Number(r||18)*.15))}px`,v=l?`calc(${d} * 0.75)`:`${Math.max(14,Math.round(Number(r||18)*.75))}px`,S={backgroundColor:i.backgroundColor||"#FFFFFF",borderRadius:K(i.borderRadius!==void 0?i.borderRadius:16),padding:i.padding?K(i.padding):"16px 18px",boxShadow:i.shadow||"0 10px 30px rgba(0,0,0,0.08)",width:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",gap:"10px",border:i.borderColor?`1px solid ${i.borderColor}`:"none",overflow:"hidden",opacity:i.opacity??1},u={color:i.titleColor||"#000000",fontWeight:"700",fontSize:K(i.fontSize||14),width:"100%",textAlign:"center",marginBottom:"4px"},m={display:"flex",gap:f,width:"100%",justifyContent:"center",alignItems:"center",flexWrap:"nowrap"},g={display:"flex",flexDirection:"column",alignItems:"center",gap:"2px"},C={display:"flex",gap:"2px"},I={backgroundColor:i.digitBackground||"#F1F3F5",borderRadius:h,minWidth:b,height:y,display:"flex",alignItems:"center",justifyContent:"center",fontSize:d,fontWeight:"bold",color:i.digitColor||"#1A202C",padding:"0 4px"},z={fontSize:l?c:`${Math.max(9,Number(String(c).replace("px","")))}px`,color:i.labelColor||"#A0AEC0",fontWeight:"600",textTransform:"lowercase"},E={fontSize:v,fontWeight:"700",color:i.labelColor||"#A0AEC0",display:"flex",alignItems:"center",lineHeight:1},w=(P,H)=>Fi("div",{style:g,children:[te("div",{style:C,children:P.split("").map((B,a)=>te("div",{style:I,children:B},a))}),te("span",{style:z,children:H})]}),D=[],_=0;return n.showDays!==!1&&(D.push(w(e.days,"days")),_++),n.showHours!==!1&&(_>0&&D.push(te("div",{style:E,children:":"},"sep-h")),D.push(w(e.hours,"hours")),_++),n.showMinutes!==!1&&(_>0&&D.push(te("div",{style:E,children:":"},"sep-m")),D.push(w(e.minutes,"minutes")),_++),n.showSeconds!==!1&&(_>0&&D.push(te("div",{style:E,children:":"},"sep-s")),D.push(w(e.seconds,"seconds")),_++),Fi("div",{style:S,children:[t.title&&te("div",{style:u,children:t.title}),te("div",{style:m,children:D})]})};import{useState as ys}from"react";import{jsx as ee,jsxs as Ii}from"react/jsx-runtime";var Bi=({data:t,onInteraction:e})=>{let[o,i]=ys(!1),n=b=>{b.stopPropagation(),t.code&&(navigator.clipboard.writeText(t.code).catch(()=>{}),i(!0),e?.({type:"promo_code",value:"copied",stickerId:t.id,code:t.code}),setTimeout(()=>i(!1),2e3))},r=t.styling||{},d={backgroundColor:r.backgroundColor||"#F4F4F6",padding:"8px 16px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",minHeight:"44px",boxSizing:"border-box",position:"relative",boxShadow:r.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 Ii("div",{style:d,onClick:n,children:[ee("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:"%"}),ee("div",{style:{flex:1,minWidth:0,padding:"0 8px",display:"flex",alignItems:"center",justifyContent:"center"},children:ee("span",{style:{fontSize:"13px",fontWeight:"700",color:o?"#10B981":"#000000",fontFamily:'"SF Mono", "Roboto Mono", Menlo, Consolas, "Courier New", monospace',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"})}),ee("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?ee("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#10B981",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:ee("polyline",{points:"20 6 9 17 4 12"})}):Ii("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[ee("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2.5",stroke:"#000000",strokeWidth:"2",fill:"none"}),ee("rect",{x:"4",y:"4",width:"12",height:"12",rx:"2.5",stroke:"#000000",strokeWidth:"2",fill:"none"})]})})]})};import{useState as Li,useEffect as hs}from"react";import{jsx as sn,jsxs as Mi}from"react/jsx-runtime";var Ai=({data:t,onInteraction:e,isEditing:o=!1})=>{let i={emojis:["\u{1F60D}","\u{1F44D}"]},n=Array.isArray(t.emojis)?t.emojis:Array.isArray(i.emojis)?i.emojis:[],[r,l]=Li(()=>{try{return localStorage.getItem(`appstorys_reaction_${t.id}`)!==null}catch{return!1}}),[d,c]=Li({});hs(()=>{let u={},m=(()=>{try{return localStorage.getItem(`appstorys_reaction_${t.id}`)}catch{return null}})();n.forEach(g=>{let C=Math.random()>.5?1999:2e3;m&&g===m&&(C+=1),u[g]=C}),c(u)},[t.emojis]);let y=(u,m)=>{if(!(o||r)){c(g=>({...g,[u]:(g[u]||0)+1})),l(!0);try{localStorage.setItem(`appstorys_reaction_${t.id}`,u)}catch{}e?.({type:"reaction",reactionId:t.id,optionId:`option${m+1}`,selected_option:`option${m+1}`,emoji:u,stickerId:t.id})}},b=u=>u>=1e3?(u/1e3).toFixed(0)+"k":String(u),h={display:"flex",gap:"12px",justifyContent:"center",alignItems:"center",width:"100%",padding:"12px",boxSizing:"border-box"},f={backgroundColor:"#FFFFFF",width:"60px",height:r?"90px":"60px",borderRadius:"100px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:r?"space-between":"center",padding:r?"10px 0":"0",boxShadow:"0 8px 30px rgba(0,0,0,0.12)",cursor:o||r?"default":"pointer",border:"none",outline:"none",position:"relative",zIndex:1,boxSizing:"border-box",flexShrink:0},v={fontSize:"35px",lineHeight:"1",userSelect:"none"},S={fontSize:"13px",fontWeight:"800",color:"#374151",animation:"appstorys-reaction-fade-in 0.3s ease forwards",lineHeight:"1",userSelect:"none",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'};return Mi("div",{style:h,children:[sn("style",{children:`
34
+ @keyframes appstorys-reaction-fade-in {
35
+ from { opacity: 0; transform: translateY(4px); }
36
+ to { opacity: 1; transform: translateY(0); }
37
+ }
38
+ .appstorys-reaction-btn {
39
+ transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
40
+ }
41
+ .appstorys-reaction-btn:not(.voted):not(.editing):hover {
42
+ transform: scale(1.15) translateY(-4px) !important;
43
+ }
44
+ .appstorys-reaction-btn.voted {
45
+ transform: scale(1) translateY(0) !important;
46
+ }
47
+ `}),n.map((u,m)=>{let g=d[u]||2e3;return Mi("button",{className:`appstorys-reaction-btn ${r?"voted":""} ${o?"editing":""}`,style:f,onClick:()=>y(u,m),children:[sn("span",{style:v,children:u}),r&&sn("span",{style:S,children:b(g)})]},m)})]})};import{useState as xo,useRef as bs,useEffect as xs}from"react";import{jsx as So,jsxs as an}from"react/jsx-runtime";var Ei=({data:t,onInteraction:e,isEditing:o=!1})=>{let i=t.maxRating||5,n=t.currentRating??Math.floor(i/2),[r,l]=xo(()=>{try{let x=localStorage.getItem(`appstorys_rating_${t.id}`);return x?Number(x):n}catch{return n}}),d=bs(null),[c,y]=xo(!1),[b,h]=xo(()=>{try{return localStorage.getItem(`appstorys_rating_${t.id}`)!==null}catch{return!1}}),[f,v]=xo([]),S={backgroundColor:"#FFFFFF",borderRadius:20,padding:14,titleColor:"#000000",titleFontSize:15,sliderTrackColor:"#F3F4F6",sliderFillColor:"#F97316",emojiSize:32},u=t.styling||{},m={backgroundColor:u.backgroundColor||S.backgroundColor,borderRadius:K(u.borderRadius??S.borderRadius),padding:u.padding?K(u.padding):"12px 14px",boxShadow:u.shadow||"0 10px 24px rgba(0,0,0,0.08)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",cursor:"default",opacity:u.opacity??1},g={color:u.titleColor||S.titleColor,fontWeight:"700",fontSize:typeof u.titleFontSize=="string"?`min(${u.titleFontSize}, 16px)`:`${u.titleFontSize?Math.min(Number(u.titleFontSize),16):15}px`,margin:"0",textAlign:"center",lineHeight:"1.25",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:"100%"},C={width:"100%",height:"16px",backgroundColor:u.sliderTrackColor||S.sliderTrackColor,borderRadius:"100px",position:"relative",cursor:o||b?"default":"pointer",marginTop:"4px",marginBottom:"2px",userSelect:"none"},I=r/i*100,z={width:`${I}%`,height:"100%",background:u.sliderFillColor||"linear-gradient(90deg, #FF4582, #e11d48)",borderRadius:"100px",transition:c?"none":"width 0.1s ease"},E=u.emojiSize||S.emojiSize,w=typeof E=="string",D=K(E),_={position:"absolute",left:w?`calc(${I}% - calc(${D} / 2))`:`calc(${I}% - ${Number(E)/2}px)`,top:w?`calc(50% - calc(${D} / 2))`:`calc(50% - ${Number(E)/2}px)`,fontSize:D,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",cursor:b||o?"default":"grab",transition:c?"none":"left 0.1s ease",filter:"drop-shadow(0 4px 8px rgba(0,0,0,0.2))",animation:b?"thumbPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards":"none"},P=x=>{if(!d.current||o||b)return;let s=d.current.getBoundingClientRect(),p=x-s.left;p<0&&(p=0),p>s.width&&(p=s.width);let M=p/s.width,T=Math.round(M*i*10)/10;l(T)},H=x=>{o||b||(y(!0),P(x.clientX))},B=x=>{o||b||(y(!0),P(x.touches[0].clientX))},a=()=>{let x=Array.from({length:16}).map((s,p)=>({id:Date.now()+p,scale:.5+Math.random()*.8,angle:p*22.5+(Math.random()*15-7.5),delay:Math.random()*.1}));v(x),setTimeout(()=>{v([])},1200)};return xs(()=>{let x=M=>{c&&P(M.clientX)},s=()=>{if(c){y(!1),h(!0);try{localStorage.setItem(`appstorys_rating_${t.id}`,String(r))}catch{}a(),e?.({type:"rating",ratingId:t.id,value:r,stickerId:t.id})}},p=M=>{c&&P(M.touches[0].clientX)};return c&&(window.addEventListener("mousemove",x),window.addEventListener("mouseup",s),window.addEventListener("touchmove",p),window.addEventListener("touchend",s)),()=>{window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",s),window.removeEventListener("touchmove",p),window.removeEventListener("touchend",s)}},[c,r]),an("div",{style:m,children:[So("style",{children:`
48
+ @keyframes emojiBurst {
49
+ 0% {
50
+ transform: translate(0, 0) scale(0.3);
51
+ opacity: 1;
52
+ }
53
+ 90% {
54
+ opacity: 0.9;
55
+ }
56
+ 100% {
57
+ transform: translate(var(--tx), var(--ty)) scale(var(--scale));
58
+ opacity: 0;
59
+ }
60
+ }
61
+ @keyframes thumbPop {
62
+ 0% { transform: scale(1); }
63
+ 50% { transform: scale(1.3); }
64
+ 100% { transform: scale(1); }
65
+ }
66
+ `}),So("h3",{style:g,children:t.title||"Do you like my space?"}),an("div",{ref:d,style:C,onMouseDown:H,onTouchStart:B,children:[So("div",{style:z}),an("div",{style:_,className:"interactive-emoji-thumb",children:[t.emoji||"\u{1F60D}",f.map(x=>{let s=60+Math.random()*80,p=x.angle*Math.PI/180,M=`${Math.cos(p)*s}px`,T=`${Math.sin(p)*s}px`;return So("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) ${x.delay}s forwards`,"--tx":M,"--ty":T,"--scale":x.scale},children:t.emoji||"\u{1F60D}"},x.id)})]})]})]})};import{useState as Di}from"react";import{jsx as _e,jsxs as ln}from"react/jsx-runtime";var _i=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=Di(()=>{try{return localStorage.getItem(`appstorys_question_${t.id}`)||""}catch{return""}}),[r,l]=Di(()=>{try{return localStorage.getItem(`appstorys_question_${t.id}`)!==null}catch{return!1}}),d={backgroundColor:"#FFFFFF",borderRadius:16,padding:16,promptColor:"#111111",inputBgColor:"#FFFFFF",borderColor:"#EFEFEF",textColor:"#333333",placeholderColor:"#A0AEC0"},c=t.styling||{},y={backgroundColor:c.backgroundColor||d.backgroundColor,borderRadius:K(c.borderRadius??d.borderRadius),padding:c.padding?K(c.padding):"15px 16px",boxShadow:c.shadow||"0 8px 24px rgba(0,0,0,0.06)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"10px",border:`1px solid ${c.borderColor||"#F0F0F0"}`},b={color:c.promptColor||d.promptColor,fontWeight:"700",fontSize:typeof c.fontSize=="string"?`min(${c.fontSize}, 16px)`:`${c.fontSize?Math.min(Number(c.fontSize),16):15}px`,textAlign:"center",marginBottom:"2px",width:"100%"},h={width:"100%",position:"relative",display:"flex",alignItems:"center"},f={backgroundColor:c.inputBgColor||"#F1F3F5",border:"none",borderRadius:"30px",padding:"12px 42px 12px 16px",width:"100%",boxSizing:"border-box",color:c.inputTextColor||"#1A202C",fontSize:"13px",outline:"none",textAlign:"left",cursor:o?"default":"text",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},v={position:"absolute",right:"10px",background:c.submitBackground||"#FE6B35",color:"white",border:"none",borderRadius:"50%",width:"32px",height:"32px",display:i.length>0&&!r?"flex":"none",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"transform 0.2s"},S=m=>{o||r||n(m.target.value)},u=()=>{if(!(o||!i.trim()||r)){l(!0);try{localStorage.setItem(`appstorys_question_${t.id}`,i.trim())}catch{}e?.({type:"question",questionId:t.id,value:i.trim(),stickerId:t.id})}};return ln("div",{style:y,children:[_e("div",{style:b,children:t.question||"Ask me anything"}),ln("div",{style:h,children:[_e("input",{type:"text",value:i,placeholder:r?"Submitted!":t.placeholder||"Type your answer...",style:f,disabled:o||r,onChange:S,onKeyDown:m=>m.key==="Enter"&&u()}),_e("button",{style:v,onClick:u,children:ln("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[_e("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),_e("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})};import{useState as Ss}from"react";import{jsx as Pe,jsxs as dn}from"react/jsx-runtime";var Pi=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=Ss(()=>{try{return localStorage.getItem(`appstorys_image_quiz_${t.id}`)}catch{return null}}),r={backgroundColor:"#FFFFFF",borderRadius:20,padding:16,questionTextColor:"#111111",optionBgColor:"#F7FAFC",optionTextColor:"#2D3748",borderColor:"#E2E8F0",activeColor:"#10B981",incorrectColor:"#EF4444"},l=t.styling||{},d=K(l.padding??r.padding),c=K(l.borderRadius??r.borderRadius),y={backgroundColor:l.backgroundColor||r.backgroundColor,borderRadius:c,padding:d,paddingTop:t.question?0:d,boxShadow:l.shadow||"0 8px 24px rgba(0,0,0,0.06)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",gap:"12px",border:l.borderColor?`1px solid ${l.borderColor}`:"none",overflow:"hidden"},b={color:l.questionTextColor||"#FFFFFF",backgroundColor:l.questionBgColor||"#000000",fontWeight:"800",fontSize:typeof l.fontSize=="string"?`min(${l.fontSize}, 16px)`:`${l.fontSize?Math.min(Number(l.fontSize),16):15}px`,margin:`0 calc(-1 * ${d}) 8px calc(-1 * ${d})`,padding:`10px ${d}`,textAlign:"center",borderTopLeftRadius:c,borderTopRightRadius:c},h={display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px",width:"100%"},f={backgroundColor:l.optionBgColor||r.optionBgColor,color:l.optionTextColor||r.optionTextColor,borderRadius:"16px",border:`2px solid ${l.borderColor||r.borderColor}`,cursor:i?"default":"pointer",display:"flex",flexDirection:"column",alignItems:"center",padding:"8px",boxSizing:"border-box",transition:"all 0.2s ease",overflow:"hidden"},v=m=>{if(!(o||i)){n(m);try{localStorage.setItem(`appstorys_image_quiz_${t.id}`,m)}catch{}e?.({type:"image",quizId:t.id,optionId:m,stickerId:t.id})}},S="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",u=Array.isArray(t.options)?t.options:[];return dn("div",{style:y,children:[t.question&&Pe("h3",{style:b,children:t.question}),Pe("div",{style:h,children:u.map(m=>{let g=m.id===i,C=m.isCorrect===!0,I={...f};return i&&(C?(I.borderColor=l.activeColor||r.activeColor,I.backgroundColor="rgba(16, 185, 129, 0.05)"):g&&(I.borderColor=l.incorrectColor||r.incorrectColor,I.backgroundColor="rgba(239, 68, 68, 0.05)")),dn("button",{style:I,onClick:()=>v(m.id),disabled:!!i,onMouseOver:z=>{!o&&!i&&(z.currentTarget.style.transform="translateY(-2px)")},onMouseOut:z=>{!o&&!i&&(z.currentTarget.style.transform="translateY(0)")},children:[dn("div",{style:{width:"100%",aspectRatio:"1",borderRadius:"12px",overflow:"hidden",backgroundColor:"#EDF2F7",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"8px",position:"relative"},children:[Pe("img",{src:m.image||S,alt:m.text,style:{width:"100%",height:"100%",objectFit:"cover"}}),i&&Pe("div",{style:{position:"absolute",top:"6px",right:"6px",width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:C?r.activeColor:g?r.incorrectColor:"#A0AEC0",color:"#FFFFFF",fontSize:"12px",fontWeight:"bold"},children:C?"\u2713":g?"\u2715":""})]}),Pe("span",{style:{fontWeight:"600",fontSize:K(l.optionFontSize||13),color:i&&C?r.activeColor:r.optionTextColor,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:m.text})]},m.id)})})]})};import{useState as qi}from"react";import{useState as $e,useEffect as Cs}from"react";import{jsx as J,jsxs as pt}from"react/jsx-runtime";var Hi=({product:t,styling:e,onClose:o,onAddToCart:i})=>{let[n,r]=$e(""),[l,d]=$e(0),[c,y]=$e(1),[b,h]=$e(!1),[f,v]=$e(!1),S=t.attributes||{},u=S.colors||[],m=S.sizes||[],g=S.imageUrls||[t.image],C=S.description||"";Cs(()=>{m.length>0&&r(m[0]),v(!0)},[m]);let I=()=>{let x={productId:t.productId||t.id,title:t.title,selectedSize:n,selectedColor:u[l]?.name,quantity:c,price:t.price};i(x);let s=t.redirectUrl||t.url;if(s){!s.startsWith("http")&&!s.startsWith("//")&&(s="https://"+s);try{window.open(s,"_blank","noopener,noreferrer")}catch(p){console.error("AppStorys: Redirect failed",p)}}h(!0)},z=()=>{v(!1),setTimeout(o,400)},E=e?.buttonBackground||"#000000",w=e?.buttonTextColor||"#ffffff",D=e?.titleColor||e?.textColor||"#1a1a2e",_=e?.priceColor||e?.textColor||"#1a1a2e",P=e?.mrpColor||"#8b8b98",H=e?.titleFontWeight||"600",B=e?.priceFontWeight||"700",a=e?.mrpFontWeight||"500";return b?pt("div",{className:"appstorys-shopable-success-overlay",style:$i,children:[J("div",{className:"appstorys-shopable-backdrop",style:Wi,onClick:z}),pt("div",{className:"appstorys-shopable-sheet",style:{...Oi,height:"auto",minHeight:"310px",animation:"appstorys-slide-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[J("div",{style:Ni,onClick:z}),pt("div",{style:{padding:"0 20px 24px",textAlign:"center"},children:[pt("div",{style:{backgroundColor:"#F3F4F6",borderRadius:"20px",padding:"22px",marginTop:"16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[pt("h3",{style:{margin:0,fontSize:"16px",fontWeight:"600",lineHeight:"1.4"},children:["Added to your bag",J("br",{}),"successfully"]}),J("svg",{width:"44",height:"26",viewBox:"0 0 44 26",fill:"none",children:J("path",{d:"M4 4C4 4 11 22 22 22C33 22 40 4 40 4",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round"})})]}),pt("div",{style:{marginTop:"24px",display:"flex",flexDirection:"column",gap:"8px"},children:[J("button",{onClick:z,style:{...pn,backgroundColor:"#000000",color:"#ffffff",padding:"17px",fontSize:"16px",fontWeight:"600"},children:pt("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[pt("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[J("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),J("path",{d:"M3 6h18"}),J("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),"Go to checkout"]})}),J("button",{onClick:z,style:{...pn,backgroundColor:"transparent",color:"#000000",border:"1px solid rgba(0,0,0,0.1)",padding:"15px",fontSize:"16px"},children:"Continue with stories"})]})]})]})]}):pt("div",{className:`appstorys-shopable-overlay ${f?"visible":""}`,style:$i,children:[J("div",{className:"appstorys-shopable-backdrop",style:Wi,onClick:z}),pt("div",{className:"appstorys-shopable-sheet",style:{...Oi,transform:f?"translateY(0)":"translateY(100%)",opacity:f?1:0},children:[pt("div",{style:vs,children:[J("div",{style:Ni,onClick:z}),J("button",{style:ws,onClick:z,children:pt("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[J("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),J("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),pt("div",{style:ks,children:[J("div",{style:Rs,children:g.map((x,s)=>J("div",{style:{minWidth:g.length>1?"85%":"100%",aspectRatio:"1.2 / 1",maxHeight:"240px",borderRadius:"16px",overflow:"hidden",backgroundColor:"#F9FAFB"},children:J("img",{src:x,alt:t.title,style:{width:"100%",height:"100%",objectFit:"contain"}})},s))}),pt("div",{style:{padding:"0 20px 20px"},children:[J("h2",{style:{margin:"16px 0 4px",fontSize:e?.titleFontSize?K(e.titleFontSize):"20px",fontWeight:H,color:D,lineHeight:"1.2"},children:t.title}),pt("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",marginBottom:"16px"},children:[J("span",{style:{fontSize:e?.priceFontSize?K(e.priceFontSize):"18px",fontWeight:B,color:_},children:t.price}),t.oldPrice&&J("span",{style:{fontSize:e?.mrpFontSize?K(e.mrpFontSize):"14px",color:P,textDecoration:"line-through",fontWeight:a},children:t.oldPrice})]}),u.length>0&&pt("div",{style:cn,children:[J("div",{style:un,children:"COLOR"}),J("div",{style:{display:"flex",gap:"14px",marginTop:"12px"},children:u.map((x,s)=>pt("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"5px"},children:[J("button",{onClick:()=>d(s),style:{width:"36px",height:"36px",borderRadius:"50%",border:"none",backgroundColor:x.hex||"#gray",position:"relative",cursor:"pointer",boxShadow:l===s?"0 0 0 2px #fff, 0 0 0 4px #000":"none",transition:"all 0.2s ease"}}),J("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:l===s?"#000":"transparent",transition:"all 0.2s ease"}})]},x.id))})]}),m.length>0&&pt("div",{style:cn,children:[J("div",{style:un,children:"SIZE"}),J("div",{style:{display:"flex",gap:"10px",marginTop:"12px",flexWrap:"wrap"},children:m.map(x=>pt("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},children:[J("button",{onClick:()=>r(x),style:{minWidth:"42px",height:"42px",borderRadius:"50%",backgroundColor:"transparent",border:`1px solid ${n===x?"#000":"rgba(0,0,0,0.1)"}`,color:n===x?"#000":"#8b8b98",fontSize:"13px",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:x}),J("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:n===x?"#000":"transparent",transition:"all 0.2s ease"}})]},x))})]}),C&&pt("div",{style:cn,children:[J("div",{style:un,children:"DESCRIPTION"}),J("p",{style:{margin:"8px 0 0",fontSize:"14px",lineHeight:"1.5",color:"#8b8b98",wordBreak:"break-word"},children:C})]})]})]}),pt("div",{style:Ts,children:[pt("div",{style:{display:"flex",flexDirection:"column",gap:"1px",minWidth:"75px"},children:[J("div",{style:{fontSize:"15px",fontWeight:B,color:_},children:t.price}),t.oldPrice&&J("div",{style:{fontSize:"11px",color:P,textDecoration:"line-through",fontWeight:a},children:t.oldPrice})]}),pt("div",{style:Fs,children:[J("button",{style:ji,onClick:()=>y(x=>Math.max(1,x-1)),children:J("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:J("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}),J("span",{style:{fontSize:"16px",fontWeight:"700",minWidth:"18px",textAlign:"center",color:"#000000",display:"inline-block"},children:c}),J("button",{style:ji,onClick:()=>y(x=>x+1),children:pt("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[J("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),J("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),(()=>{let x=S.availability?.toLowerCase()||"",s=x==="out of stock"||x==="out-of-stock";return pt("button",{onClick:s?void 0:I,disabled:s,style:{...pn,backgroundColor:s?"#F3F4F6":E,color:s?"#9CA3AF":w,flex:"1",padding:"12px 8px",gap:"6px",cursor:s?"not-allowed":"pointer",opacity:s?.8:1},children:[!s&&pt("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[J("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),J("path",{d:"M3 6h18"}),J("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),J("span",{style:{fontSize:"12px",fontWeight:"700",whiteSpace:"nowrap"},children:s?"Out of Stock":"Add to cart"})]})})()]})]}),J("style",{children:`
37
67
  @keyframes appstorys-slide-up {
38
68
  from { transform: translateY(100%); }
39
69
  to { transform: translateY(0); }
@@ -46,10 +76,22 @@ var Yi=Object.defineProperty;var Nt=(t,e)=>()=>(t&&(e=t(t=0)),e);var Qi=(t,e)=>{
46
76
  .appstorys-shopable-overlay.visible {
47
77
  visibility: visible;
48
78
  }
49
- `})]})},ei={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"},oi={position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.45)",cursor:"pointer"},ni={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"},Lr={height:"48px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0},ii={width:"36px",height:"5px",backgroundColor:"rgba(0,0,0,0.1)",borderRadius:"3px",cursor:"pointer"},Dr={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"},_r={flex:1,overflowY:"auto",WebkitOverflowScrolling:"touch"},$r={padding:"0 16px 20px",display:"flex",gap:"8px",overflowX:"auto",scrollSnapType:"x mandatory"},$o={marginTop:"20px"},Wo={fontSize:"11px",fontWeight:"600",color:"rgba(0,0,0,0.5)",letterSpacing:"1.4px"},Wr={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"},Mr={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"100px",border:"1px solid rgba(0,0,0,0.1)"},ri={border:"none",backgroundColor:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},Mo={border:"none",borderRadius:"100px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"};import{Fragment as Or,jsx as Wt,jsxs as me}from"react/jsx-runtime";var li=({data:t,onInteraction:e,isEditing:o})=>{let{products:i,styling:n}=t,[r,s]=ai(!1),[a,c]=ai(null),u=(b,h)=>{if(b.stopPropagation(),o)return;if(t.shopableType==="product"){c(h),s(!0),e&&e({type:"product_view",stickerId:t.id,productId:h.productId||h.id,value:h.title});return}let y=h.redirectUrl||h.url;if(y&&!y.startsWith("http")&&!y.startsWith("//")&&(y="https://"+y),e&&e({type:"buy",stickerId:t.id,productId:h.id,value:h.title,selected_option:y}),y)try{window.open(y,"_blank","noopener,noreferrer")}catch(w){console.error("AppStorys: Redirect failed",w),window.location.href=y}},x=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"},g={flex:"0 0 auto",width:"100%",backgroundColor:n?.cardBackground||"#ffffff",borderRadius:n?.cardBorderRadius!==void 0?`${n.cardBorderRadius}px`:n?.cardRadiusPercent!==void 0?`${n.cardRadiusPercent}%`:"12px",overflow:"hidden",boxShadow:n?.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:n?.opacity??1,marginBottom:0},v={width:"64px",height:"64px",borderRadius:n?.imageRadius!==void 0?`${n.imageRadius}px`:"12px",overflow:"hidden",backgroundColor:"#f5f5f5",flexShrink:0},f={flex:1,display:"flex",flexDirection:"column",justifyContent:"center",padding:"0 12px",minWidth:0};return me(Or,{children:[me("div",{style:m,className:"shopable-container",children:[Wt("style",{children:`
79
+ `})]})},$i={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"},Wi={position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.45)",cursor:"pointer"},Oi={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"},vs={height:"48px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0},Ni={width:"36px",height:"5px",backgroundColor:"rgba(0,0,0,0.1)",borderRadius:"3px",cursor:"pointer"},ws={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"},ks={flex:1,overflowY:"auto",WebkitOverflowScrolling:"touch"},Rs={padding:"0 16px 20px",display:"flex",gap:"8px",overflowX:"auto",scrollSnapType:"x mandatory"},cn={marginTop:"20px"},un={fontSize:"11px",fontWeight:"600",color:"rgba(0,0,0,0.5)",letterSpacing:"1.4px"},Ts={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"},Fs={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"100px",border:"1px solid rgba(0,0,0,0.1)"},ji={border:"none",backgroundColor:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},pn={border:"none",borderRadius:"100px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"};import{Fragment as zs,jsx as oe,jsxs as We}from"react/jsx-runtime";var Vi=({data:t,onInteraction:e,isEditing:o})=>{let{products:i,styling:n}=t,[r,l]=qi(!1),[d,c]=qi(null),y=(u,m)=>{if(u.stopPropagation(),o)return;if(t.shopableType==="product"){c(m),l(!0),e&&e({type:"product_view",stickerId:t.id,productId:m.productId||m.id,value:m.title});return}let g=m.redirectUrl||m.url;if(g&&!g.startsWith("http")&&!g.startsWith("//")&&(g="https://"+g),e&&e({type:"buy",stickerId:t.id,productId:m.id,value:m.title,selected_option:g}),g)try{window.open(g,"_blank","noopener,noreferrer")}catch(C){console.error("AppStorys: Redirect failed",C),window.location.href=g}},b=u=>{e&&e({type:"add_to_cart",stickerId:t.id,productId:u.productId,value:u.title,selected_option:JSON.stringify({size:u.selectedSize,color:u.selectedColor,quantity:u.quantity})})},h={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:n?.cardBackground||"#ffffff",borderRadius:n?.cardBorderRadius!==void 0?K(n.cardBorderRadius):n?.cardRadiusPercent!==void 0?`${n.cardRadiusPercent}%`:"12px",overflow:"hidden",boxShadow:n?.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:n?.opacity??1,marginBottom:0},v={width:"64px",height:"64px",borderRadius:n?.imageRadius!==void 0?K(n.imageRadius):"12px",overflow:"hidden",backgroundColor:"#f5f5f5",flexShrink:0},S={flex:1,display:"flex",flexDirection:"column",justifyContent:"center",padding:"0 12px",minWidth:0};return We(zs,{children:[We("div",{style:h,className:"shopable-container",children:[oe("style",{children:`
50
80
  .shopable-container::-webkit-scrollbar { display: none; }
51
81
  .shopable-card:active { transform: scale(0.98); }
52
- `}),i.map(b=>me("div",{style:g,className:"shopable-card",onClick:h=>u(h,b),children:[Wt("div",{style:v,children:Wt("img",{src:b.image,alt:b.title,style:{width:"100%",height:"100%",objectFit:"cover"}})}),me("div",{style:f,children:[Wt("span",{style:{color:n?.titleColor||n?.textColor||"#1a1b2e",fontSize:n?.titleFontSize?`${n.titleFontSize}px`:"15px",fontWeight:n?.titleFontWeight||"700",lineHeight:"1.2",display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"1px"},children:b.title}),me("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",flexWrap:"wrap"},children:[Wt("span",{style:{color:n?.priceColor||n?.textColor||"#1a1b2e",fontSize:n?.priceFontSize?`${n.priceFontSize}px`:"18px",fontWeight:n?.priceFontWeight||"800",display:"block"},children:b.price}),b.oldPrice&&Wt("span",{style:{color:n?.mrpColor||"#8b8b98",fontSize:n?.mrpFontSize?`${n.mrpFontSize}px`:"12px",fontWeight:n?.mrpFontWeight||"500",textDecoration:"line-through"},children:b.oldPrice})]})]}),Wt("div",{style:{backgroundColor:n?.buttonBackground||"#000000",color:n?.buttonTextColor||"#ffffff",fontSize:n?.buttonFontSize?`${n.buttonFontSize}px`:"14px",fontWeight:"700",padding:"10px 18px",borderRadius:n?.buttonBorderRadius!==void 0?`${n.buttonBorderRadius}px`:"100px",textAlign:"center",flexShrink:0,whiteSpace:"nowrap"},children:"Buy Now"})]},b.id))]}),r&&a&&Wt(si,{product:a,styling:n,onClose:()=>s(!1),onAddToCart:x})]})};import{jsx as bt,jsxs as jr}from"react/jsx-runtime";var di=({data:t,onInteraction:e,isEditing:o=!1})=>{let i={x:10,y:15,width:80,rotation:0},n=t.x??i.x,r=t.y??i.y,s=t.width??i.width,a=t.rotation??i.rotation,c={position:"absolute",top:`${r}%`,left:`${n}%`,width:`${s}%`,height:t.height?`${t.height}%`:"auto",transform:`rotate(${a}deg)`,zIndex:10,transformOrigin:"center center",boxSizing:"border-box",cursor:o?"move":"default",pointerEvents:"auto"},u={width:"100%",height:"100%",animation:t.styling?.animation,animationFillMode:"forwards"},x=()=>{switch(t.type){case"poll":return bt(Nn,{data:t,onInteraction:e,isEditing:o});case"quiz":return bt(Un,{data:t,onInteraction:e,isEditing:o});case"rating":return bt(Kn,{data:t,onInteraction:e,isEditing:o});case"question":case"input":return bt(Zn,{data:t,onInteraction:e,isEditing:o});case"image_quiz":return bt(ti,{data:t,onInteraction:e,isEditing:o});case"countdown":return bt(Vn,{data:t,onInteraction:e,isEditing:o});case"promo_code":case"promo":return bt(Yn,{data:t,onInteraction:e,isEditing:o});case"reaction":return bt(Gn,{data:t,onInteraction:e,isEditing:o});case"buy":case"shopable":return bt(li,{data:t,onInteraction:e,isEditing:o});case"image":return bt("img",{src:t.url,alt:"static overlay",style:{width:"100%",height:"100%",objectFit:"fill"}});case"text":{let g=t.styling||{};return bt("span",{style:{color:g.color||"#000000",fontSize:`${g.fontSize||14}px`,fontFamily:ct(g.fontFamily)||"Arial",fontStyle:g.fontStyle||"normal",fontWeight:g.fontWeight||"normal",wordBreak:"break-word",display:"inline-block"},children:t.text})}default:return jr("div",{style:{padding:"10px",background:"white",color:"black",borderRadius:"4px"},children:["Unsupported interactive element: ",t.type]})}};return bt("div",{style:c,className:`interactive-item-z${t.z??0}`,children:bt("div",{style:u,children:x()})})};var Pt=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}let e=t.color||{};if(e.type==="gradient"&&e.gradient){let{direction:o="right",from:i,to:n,stops:r=[]}=e.gradient,a={right:"to right",left:"to left",top:"to top",bottom:"to bottom"}[o]||o;if(r.length>0){let c=r.map(u=>`${u.color} ${Math.round((u.offset||0)*100)}%`).join(", ");return`linear-gradient(${a}, ${c})`}return`linear-gradient(${a}, ${i}, ${n})`}return e.solid||e.value||void 0},He=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`};import{jsx as fi,jsxs as Nr}from"react/jsx-runtime";var ci=(t,e)=>{let o=t?.styling?.editorSource||t?.styling?.meta?.editorSource||t?.style?.editorSource||e?.editorSource||e?.meta?.editorSource;return o==="studio"||o==="editor"?"studio":"dashboard"},Ht=(t,e)=>Array.isArray(t)?t.map((o,i)=>{let n=o?.id||o?.key||o?.value||`option_${i+1}`,r=o?.label||o?.optionLabel,s=typeof o=="string"?o:o?.text||o?.title||r||"";return{id:String(n),text:s,image:o?.image||o?.imageUrl||"",label:r,isCorrect:o?.isCorrect===!0||String(n)===String(e)}}):t&&typeof t=="object"?Object.entries(t).map(([o,i])=>{let n=typeof i=="string"?{text:i}:i||{};return{id:o,text:n.text||n.title||n.label||"",image:n.image||n.imageUrl||"",label:n.label,isCorrect:o===String(e)}}):[],pi=t=>Array.isArray(t?.emojis)?t.emojis.map(e=>String(e)):Ht(t?.options).map(e=>e.text).filter(Boolean),ui=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},gi=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()}},Oo=({content:t={},onInteraction:e,isEditing:o=!1,elapsedTime:i=0})=>{let n=t?.canva||{height:1920,width:1080},r=n?.width||1080,s=n?.height||1920,a=.352,c=t?.elements||[],u=t?.image||[],x=t?.text||[],m=t?.interactions||[],g=Array.isArray(t?.shopable)&&t.shopable.length>0?t.shopable:Array.isArray(t?.styling?.shopable)?t.styling.shopable:[],v=new Set(g.map(d=>d.id)),f=(t?.styling?.shopable||[]).concat(g.map(d=>d.styling).filter(Boolean));if(c.length===0&&u.length===0&&x.length===0&&m.length===0&&g.length===0)return null;let b=c.filter(d=>!v.has(d.id)).map(d=>{let T=d.custom||{},l=T.data||{},p=T.style||d.styling||{},M=ci(d,t),B=d.position||d.postion||{},L=d.size||{},C=d.x!==void 0?d.x:B.x,S=d.y!==void 0?d.y:B.y,_=d.width!==void 0?d.width:L.width,E=C!==void 0&&!isNaN(Number(C))?Number(C)/r*100:10,$=S!==void 0&&!isNaN(Number(S))?Number(S)/s*100:15,D=_!==void 0&&!isNaN(Number(_))?Number(_)/r*100:80,k={id:d.id||Math.random().toString(),type:ui(T.interactiveType||d.widgetType||d.type||"unknown"),x:E,y:$,width:D,rotation:p.rotation??d.rotation??0,z:d.z??d.position?.z??p.z??10,duration:l.duration||p.duration,styling:{backgroundColor:Pt(p.background||p.containerBgColor||p.backgroundColor),borderRadius:p.borderRadius!==void 0?p.borderRadius>=100?999:p.borderRadius*a:p.radius!==void 0?p.radius>=100?999:p.radius*a:0,padding:(p.containerPadding!==void 0?p.containerPadding:p.padding!==void 0?p.padding:0)*a,shadow:p.shadow,fontSize:p.questionFontSize?p.questionFontSize*a:void 0,opacity:p.opacity??1,animation:He(p.animation)}};if(k.type==="poll"){let P=Ht(l.options);return{...k,type:"poll",question:l.question||l.title||"Poll Question",options:P,layout:l.layout||{type:"vertical",columns:1},styling:{...k.styling,headerColor:p.headerBgColor||p.background,headerTextColor:p.questionColor||p.questionTextColor||p.question?.color,optionBgColor:p.optionBgColor||p.options?.background||"#1A1A1A",optionTextColor:p.optionTextColor||p.options?.textColor||"#ffffff",optionBorderRadius:p.optionBorderRadius!==void 0?p.optionBorderRadius*a:p.options?.radius!==void 0?p.options?.radius*a:0}}}if(k.type==="quiz"){let P=p.colors||{},O=Ht(l.options,l.isCorrect);return{...k,type:"quiz",question:l.question||l.title||"Quiz Question",options:O,showExplanation:l.showExplanation,url:l.url,styling:{...k.styling,backgroundColor:p.background||p.containerBgColor||p.backgroundColor||"transparent",questionTextColor:p.questionColor||P.questionColor||p.question?.color||p.colors?.questionText||"#FF0000",questionBgColor:p.questionBgColor||P.questionBackground||p.question?.background||p.colors?.questionBg||"#3BFF00",optionBgColor:p.optionBgColor||P.optionBackground||p.options?.background||p.colors?.optionBg||"#C100FF",optionTextColor:p.optionTextColor||P.optionTextColor||p.options?.textColor||p.colors?.optionText||"#ffffff",borderColor:p.borderColor||"transparent",activeColor:p.correctColor||P.correctColor||p.correctBorderColor||"#00D9FF",incorrectColor:p.incorrectColor||P.incorrectColor||"#ef4444",optionBorderRadius:p.optionRadius!==void 0?p.optionRadius>=100?999:p.optionRadius*a:p.optionBorderRadius!==void 0?p.optionBorderRadius>=100?999:p.optionBorderRadius*a:100,optionFontSize:(p.optionFontSize?p.optionFontSize:p.typography?.optionSize?p.typography?.optionSize:p.options?.fontSize?p.options?.fontSize:16)*a*1.25}}}if(k.type==="rating")return{...k,type:"rating",title:l.title||"Do you like my space?",emoji:l.emoji||"\u{1F60D}",currentRating:l.currentRating,maxRating:l.maxRating,styling:{...k.styling,sliderTrackColor:p.colors?.sliderTrack||p.sliderTrack,sliderFillColor:p.colors?.sliderFill||p.sliderFill,emojiSize:p.emojiSize?p.emojiSize*.45:void 0,titleColor:p.colors?.titleColor||p.titleColor,titleFontSize:p.titleFontSize?p.titleFontSize*.4:void 0}};if(k.type==="question")return{...k,type:"question",question:l.question||l.title||"Ask me a question",placeholder:l.placeholder||"Type your answer...",styling:{...k.styling,promptColor:p.questionColor||p.textColor,inputBgColor:p.inputBgColor,inputTextColor:p.inputTextColor,submitBackground:p.submitBackground}};if(k.type==="image_quiz"||k.type==="imageQuiz"||(T.interactiveType||"").toLowerCase()==="media_quiz")return{...k,type:"image_quiz",question:l.question||l.title||"Image Quiz",options:Ht(l.options||[]),styling:{...k.styling,questionTextColor:p.questionColor,activeColor:p.correctColor||p.correctBorderColor,incorrectColor:p.incorrectColor,imageRadius:p.imageRadius?p.imageRadius*a:void 0}};if(k.type==="countdown")return{...k,type:"countdown",title:l.title||"Ends in...",targetDate:gi(l),styling:{...k.styling,borderColor:p.borderColor,digitBackground:p.digitBackground,digitColor:p.digitColor,digitSize:p.digitSize?p.digitSize*a:void 0,labelColor:p.labelColor,titleColor:p.titleColor},display:l.display};if(k.type==="promo_code")return{...k,type:"promo_code",code:l.code||"CODE20",styling:{...k.styling,borderColor:p.borderColor}};if(k.type==="reaction"||k.type==="emoji_reaction"){let P=pi(l);return{...k,type:"reaction",emojis:P.length>0?P:["\u{1F60D}","\u{1F44D}"],source:M}}return k}),h=(t?.interactions||[]).filter(d=>!v.has(d.id)).map(d=>{let T=d.config||{},l=d.styling||d.style||{},p=ci(d,t),M=ui(d.interaction_type||d.type),B=l.position||d.position||{},L=l.size||d.size||{},C=B.x??d.x,S=B.y??d.y,_=L.width??d.width,E=L.height??d.height,$=C!==void 0&&!isNaN(Number(C))?Number(C)/r*100:10,D=S!==void 0&&!isNaN(Number(S))?Number(S)/s*100:15,k=_!==void 0&&!isNaN(Number(_))?Number(_)/r*100:80,P=E!==void 0&&!isNaN(Number(E))?Number(E)/s*100:void 0,O={id:d.id||Math.random().toString(),type:M,x:$,y:D,width:k,height:P,rotation:l.rotation??d.rotation??0,z:d.z??d.position?.z??l.z??10,source:p,duration:T.duration||l.duration,styling:{backgroundColor:Pt(l.background||l.containerBgColor||l.backgroundColor),borderRadius:l.borderRadius!==void 0?l.borderRadius>=100?999:l.borderRadius*a:l.radius!==void 0?l.radius>=100?999:l.radius*a:0,padding:(l.containerPadding!==void 0?l.containerPadding:l.padding!==void 0?l.padding:0)*a,shadow:l.shadow,fontSize:l.questionSize?l.questionSize*a:l.questionFontSize?l.questionFontSize*a:void 0,opacity:l.opacity??1,animation:He(l.animation)}};if(O.type==="rating"||O.type==="rate"){let G=l.colors||{};return{...O,type:"rating",title:T.title||"Do you like my space?",emoji:T.emoji||"\u{1F60D}",currentRating:T.currentRating,maxRating:T.maxRating,styling:{...O.styling,sliderTrackColor:G.sliderTrack||l.colors?.sliderTrack||l.colors?.sliderTrack,sliderFillColor:G.sliderFill||l.colors?.sliderFill||l.sliderFill,emojiSize:l.emojiSize?l.emojiSize*.45:void 0,titleColor:G.titleColor||l.colors?.titleColor||l.titleColor,titleFontSize:l.titleFontSize?l.titleFontSize*.4:void 0}}}if(O.type==="poll"){let G=Ht(T.options);return{...O,type:"poll",question:T.question||T.title||"Poll Question",options:G,layout:T.layout||{type:"vertical",columns:1},styling:{...O.styling,headerColor:l.headerBgColor||l.background,headerTextColor:l.questionColor||l.questionTextColor||l.question?.color,optionBgColor:l.optionBgColor||l.options?.background||"#1A1A1A",optionTextColor:l.optionTextColor||l.options?.textColor||"#ffffff",optionBorderRadius:l.optionBorderRadius!==void 0?l.optionBorderRadius*a:l.options?.radius!==void 0?l.options?.radius*a:0}}}if(O.type==="quiz"){let G=l.colors||{},ut=Ht(T.options,T.isCorrect);return{...O,type:"quiz",question:T.question||T.title||"Quiz Question",options:ut,showExplanation:T.showExplanation,url:T.url,styling:{...O.styling,backgroundColor:l.background||l.containerBgColor||l.backgroundColor||"transparent",questionTextColor:l.questionColor||G.questionColor||l.question?.color||l.colors?.questionText||"#FF0000",questionBgColor:l.questionBgColor||G.questionBackground||l.question?.background||l.colors?.questionBg||"#3BFF00",optionBgColor:l.optionBgColor||G.optionBackground||l.options?.background||l.colors?.optionBg||"#C100FF",optionTextColor:l.optionTextColor||G.optionTextColor||l.options?.textColor||l.colors?.optionText||"#ffffff",borderColor:l.borderColor||"transparent",activeColor:l.correctColor||G.correctColor||l.correctBorderColor||"#00D9FF",incorrectColor:l.incorrectColor||G.incorrectColor||"#ef4444",optionBorderRadius:l.optionRadius!==void 0?l.optionRadius>=100?999:l.optionRadius*a:l.optionBorderRadius!==void 0?l.optionBorderRadius>=100?999:l.optionBorderRadius*a:100,optionFontSize:(l.optionFontSize?l.optionFontSize:l.typography?.optionSize?l.typography?.optionSize:l.options?.fontSize?l.options?.fontSize:16)*a*1.25}}}if(O.type==="question")return{...O,type:"question",question:T.question||T.title||"Ask me a question",placeholder:T.placeholder||"Type your answer...",styling:{...O.styling,promptColor:l.questionColor||l.promptColor||l.textColor,inputBgColor:l.inputBackground||l.inputBgColor,inputTextColor:l.inputTextColor,submitBackground:l.submitBackground}};if(O.type==="image_quiz"||O.type==="imageQuiz"||M==="media_quiz")return{...O,type:"image_quiz",question:T.question||T.title||"Image Quiz",options:Ht(T.options||[]),styling:{...O.styling,questionTextColor:l.questionColor,activeColor:l.correctColor||l.correctBorderColor,incorrectColor:l.incorrectColor,imageRadius:l.imageRadius?l.imageRadius*a:void 0}};if(O.type==="countdown")return{...O,type:"countdown",title:T.title||"Ends in...",targetDate:gi(T),styling:{...O.styling,borderColor:l.borderColor,digitBackground:l.digitBackground,digitColor:l.digitColor,digitSize:l.digitSize||l.fontSize?Number(l.digitSize||l.fontSize):void 0,labelColor:l.labelColor,titleColor:l.titleColor,labelFontSize:l.labelFontSize?Number(l.labelFontSize):void 0},display:T.display||d.display};if(O.type==="promo_code")return{...O,type:"promo_code",code:T.code||"CODE20",styling:{...O.styling,borderColor:l.borderColor}};if(O.type==="reaction"||O.type==="emoji_reaction"){let G=pi(T);return{...O,type:"reaction",emojis:G.length>0?G:["\u{1F60D}","\u{1F44D}"]}}return O}),y=g.map(d=>{let T=f.find(j=>String(j?.id)===String(d?.id))||f.find(j=>j?.id===void 0)||{},l={position:d?.position,size:d?.size,rotation:d?.rotation,z:d?.z,background:d?.background,cardBackground:d?.cardBackground,cardBorderRadius:d?.cardBorderRadius,cardRadiusPercent:d?.cardRadiusPercent,transparent:d?.transparent,textColor:d?.textColor,buttonBackground:d?.buttonBackground,buttonTextColor:d?.buttonTextColor,buttonFontSize:d?.buttonFontSize,buttonBorderRadius:d?.buttonBorderRadius,titleColor:d?.titleColor,titleFontSize:d?.titleFontSize,titleFontWeight:d?.titleFontWeight,priceColor:d?.priceColor,priceFontSize:d?.priceFontSize,priceFontWeight:d?.priceFontWeight,mrpColor:d?.mrpColor,mrpFontSize:d?.mrpFontSize,mrpFontWeight:d?.mrpFontWeight,imageRadius:d?.imageRadius,opacity:d?.opacity,animation:d?.animation},p={...T,...d?.styling||{},...Object.fromEntries(Object.entries(l).filter(([,j])=>j!==void 0))},M=p.position||{},B=p.size||{},L=p.cardBorderRadius!==void 0?Number(p.cardBorderRadius):void 0,C=p.cardRadiusPercent!==void 0?Number(p.cardRadiusPercent):void 0,S=B.height!==void 0?Number(B.height):void 0,_=L===void 0&&C!==void 0&&S!==void 0?Math.max(0,Math.min(100,C))/100*(S/2):void 0,E=L??_,$=E!==void 0&&!isNaN(E)?E*a:void 0,D=M.x!==void 0?Number(M.x)/r*100:0,k=B.width!==void 0?Number(B.width)/r*100:100,P=B.height!==void 0?Number(B.height)/s*100:void 0,O=M.y!==void 0?Number(M.y)/s*100:P?100-P-2.5:85;P&&O+P>96?O=Math.max(0,100-P):O>75&&P&&O+P>91&&(O=Math.max(0,100-P-1));let G=Array.isArray(d.product)&&d.product.length>0,ut=G?d.product:d.static||[];return{id:d.id||Math.random().toString(),type:"buy",shopableType:G?"product":"static",x:D,y:O,width:k,height:P,rotation:p.rotation??0,z:p.z??10,products:ut.map(j=>{let X=j.productData||j||{},J=X.attributes||j.attributes||{},V=J.sales_price||X.price||J.price||j.price,et=J.sales_price?X.price||J.price||j.price:X.oldPrice||j.oldPrice,q=X.color||J.color||j.color,Q=X.size||J.size||j.size,Y=J.colors||[];Y.length===0&&q&&(Y=[{id:q,hex:q,name:q}]);let lt=J.sizes||[];lt.length===0&&Q&&(lt=typeof Q=="string"?Q.split(",").map(nt=>nt.trim()):[Q]);let mt={description:X.description||J.description||j.description,color:q,size:Q,colors:Y,sizes:lt,imageUrls:J.imageUrls||[J.image_link||X.imageUrl||X.image||j.imageUrl||j.image||j.url].filter(Boolean),availability:X.availability||J.availability||j.availability,tags:X.tags||J.tags||j.tags,...J};return{id:X.productId||X.id||j.productId||j.id||Math.random().toString(),image:J.image_link||X.imageUrl||X.image||j.imageUrl||j.image||j.url,url:X.link||X.url||j.link||j.url||j.redirectUrl,title:X.title||j.title,price:V,oldPrice:et,redirectUrl:j.redirectUrl||X.link||j.link||j.url,svg:X.svg||j.svg,productId:X.productId||j.productId,collectionId:X.collectionId||j.collectionId,feedId:X.feedId||j.feedId,attributes:mt}}),styling:{backgroundColor:Pt(p.background),cardBackground:Pt(p.cardBackground)||Pt(p.background)||"#ffffff",cardBorderRadius:$!==void 0?$:10,cardRadiusPercent:C,transparent:p.transparent===!0,textColor:p.textColor||"#ffffff",buttonBackground:p.buttonBackground||"#000000",buttonTextColor:p.buttonTextColor||"#ffffff",buttonFontSize:p.buttonFontSize||12,buttonBorderRadius:p.buttonBorderRadius!==void 0?p.buttonBorderRadius:100,titleColor:p.titleColor||p.textColor||"#1a1a2e",titleFontSize:p.titleFontSize||14,titleFontWeight:p.titleFontWeight?String(p.titleFontWeight):"600",priceColor:p.priceColor||p.textColor||"#1a1a2e",priceFontSize:p.priceFontSize||16,priceFontWeight:p.priceFontWeight?String(p.priceFontWeight):"700",mrpColor:p.mrpColor||"#8b8b98",mrpFontSize:p.mrpFontSize||12,mrpFontWeight:p.mrpFontWeight?String(p.mrpFontWeight):"500",imageRadius:p.imageRadius!==void 0?Number(p.imageRadius)*a:10,animation:He(p.animation)}}}),w=u.map(d=>{let T=d.position||d.postion||{x:0,y:0};return{id:d.id||Math.random().toString(),type:"image",x:T.x/r*100,y:T.y/s*100,width:d.width/r*100,height:d.height?d.height/s*100:void 0,url:d.link||d.url,z:d.z??0}}),I=x.map(d=>{let T=d.position||{x:0,y:0},l=d.font||{};return{id:d.id||Math.random().toString(),type:"text",x:T.x/r*100,y:T.y/s*100,width:d.size?.width?d.size.width/r*100:void 0,text:d.value,z:d.z??1,styling:{color:d.color||"#000000",fontSize:l.fontSize?l.fontSize*a:void 0,fontFamily:ct(l.fontFamily),fontStyle:l.fontStyle,fontWeight:l.fontWeight}}}),z=[...b,...h,...y,...w,...I].filter(d=>{if(!d.duration)return!0;let{start:T,end:l}=d.duration;return i>=T&&i<=l}).sort((d,T)=>(d.z??0)-(T.z??0));return Nr("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10,pointerEvents:"none",overflow:"hidden"},children:[fi("style",{children:`
82
+ `}),i.map(u=>We("div",{style:f,className:"shopable-card",onClick:m=>y(m,u),children:[oe("div",{style:v,children:oe("img",{src:u.image,alt:u.title,style:{width:"100%",height:"100%",objectFit:"cover"}})}),We("div",{style:S,children:[oe("span",{style:{color:n?.titleColor||n?.textColor||"#1a1b2e",fontSize:n?.titleFontSize?K(n.titleFontSize):"15px",fontWeight:n?.titleFontWeight||"700",lineHeight:"1.2",display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"1px"},children:u.title}),We("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",flexWrap:"wrap"},children:[oe("span",{style:{color:n?.priceColor||n?.textColor||"#1a1b2e",fontSize:n?.priceFontSize?K(n.priceFontSize):"18px",fontWeight:n?.priceFontWeight||"800",display:"block"},children:u.price}),u.oldPrice&&oe("span",{style:{color:n?.mrpColor||"#8b8b98",fontSize:n?.mrpFontSize?K(n.mrpFontSize):"12px",fontWeight:n?.mrpFontWeight||"500",textDecoration:"line-through"},children:u.oldPrice})]})]}),oe("div",{style:{backgroundColor:n?.buttonBackground||"#000000",color:n?.buttonTextColor||"#ffffff",fontSize:n?.buttonFontSize?K(n.buttonFontSize):"14px",fontWeight:"700",padding:"10px 18px",borderRadius:n?.buttonBorderRadius!==void 0?K(n.buttonBorderRadius):"100px",textAlign:"center",flexShrink:0,whiteSpace:"nowrap"},children:"Buy Now"})]},u.id))]}),r&&d&&oe(Hi,{product:d,styling:n,onClose:()=>l(!1),onAddToCart:b})]})};import{Fragment as Is,jsx as Ct,jsxs as gn}from"react/jsx-runtime";var Ui=({data:t,onInteraction:e,isEditing:o=!1})=>{let i={x:10,y:15,width:80,rotation:0},n=t.x??i.x,r=t.y??i.y,l=t.width??i.width,d=t.rotation??i.rotation,c={position:"absolute",top:`${r}%`,left:`${n}%`,width:`${l}%`,height:t.height?`${t.height}%`:"auto",transform:`rotate(${d}deg)`,zIndex:10,transformOrigin:"center center",boxSizing:"border-box",cursor:o?"move":"default",pointerEvents:"auto"},y={width:"100%",height:"100%",animation:t.styling?.animation,animationFillMode:"forwards"},b=()=>{switch(t.type){case"poll":return Ct(ki,{data:t,onInteraction:e,isEditing:o});case"quiz":return Ct(Ti,{data:t,onInteraction:e,isEditing:o});case"rating":return Ct(Ei,{data:t,onInteraction:e,isEditing:o});case"question":case"input":return Ct(_i,{data:t,onInteraction:e,isEditing:o});case"image_quiz":return Ct(Pi,{data:t,onInteraction:e,isEditing:o});case"countdown":return Ct(zi,{data:t,onInteraction:e,isEditing:o});case"promo_code":case"promo":return Ct(Bi,{data:t,onInteraction:e,isEditing:o});case"reaction":return Ct(Ai,{data:t,onInteraction:e,isEditing:o});case"buy":case"shopable":return Ct(Vi,{data:t,onInteraction:e,isEditing:o});case"shape":case"gif":case"svg":case"sticker":case"image":return Ct("img",{src:t.url,alt:"static overlay",style:{width:"100%",height:"100%",objectFit:"fill"}});case"text":{let f=t.styling||{},v=f.verticalAlignment,S=f.textAlign;return Ct("div",{style:{color:f.color||"#000000",fontSize:K(f.fontSize||14),fontFamily:gt(f.fontFamily)||"Arial",fontStyle:f.fontStyle||"normal",fontWeight:f.fontWeight||"normal",textDecoration:f.textDecoration||"none",lineHeight:f.lineHeight||"normal",letterSpacing:f.letterSpacing||"normal",opacity:f.opacity??1,wordBreak:"break-word",whiteSpace:"pre-wrap",width:"100%",height:"100%",display:"flex",alignItems:v==="center"?"center":v==="bottom"?"flex-end":"flex-start",justifyContent:S==="center"?"center":S==="right"?"flex-end":"flex-start",textAlign:S||"left"},children:t.text})}case"cta":{let f=t.styling||{};if(t.ctaType==="image")return Ct("button",{onClick:w=>{w.stopPropagation(),e&&e({type:"cta",stickerId:t.id,redirectUrl:t.redirectUrl})},style:{background:"none",border:"none",padding:0,width:"100%",height:"100%",cursor:"pointer",display:"block",outline:"none"},children:Ct("img",{src:t.url,alt:t.text,style:{width:"100%",height:"100%",objectFit:"contain"}})});let S=f.borderRadius,u=(t.text||"").trim(),m=u.toLowerCase().includes("swipe")||String(t.ctaType).toLowerCase().includes("swipe")||String(t.type).toLowerCase().includes("swipe")||String(t.id).toLowerCase().includes("swipe"),g={width:"100%",height:f.pillH?`${f.pillH}cqh`:"100%",backgroundColor:f.transparent?"transparent":f.backgroundColor||"#3B82F6",color:f.textColor||"#FFFFFF",border:f.borderWidth?`${K(f.borderWidth)} solid ${f.borderColor||"#FFFFFF"}`:"none",borderRadius:S||"4px",fontSize:K(f.fontSize||14),fontFamily:gt(f.fontFamily)||"Arial",fontStyle:f.fontStyle||"normal",fontWeight:f.fontWeight||"normal",textDecoration:f.textDecoration||"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",outline:"none",padding:"0 12px",wordBreak:"break-word",flexShrink:0},C={position:"relative",width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-end",boxSizing:"border-box",animation:m&&f.arrowAnimation!==!1?"appstorys-swipe-bounce 2.2s ease-in-out infinite":"none",transformOrigin:"bottom center"},I={display:"flex",alignItems:"center",justifyContent:"center",flexGrow:1,width:"100%",color:f.arrowColor||f.textColor||"#FFFFFF",pointerEvents:"none",boxSizing:"border-box"},z=f.arrowSize?`${f.arrowSize}cqh`:"1.5cqh";return gn("div",{style:C,children:[m&&gn(Is,{children:[Ct("style",{children:`
83
+ @keyframes appstorys-swipe-bounce {
84
+ 0%, 100% {
85
+ transform: translateY(0) scaleY(1) scaleX(1);
86
+ }
87
+ 40% {
88
+ transform: translateY(-3px) scaleY(1.04) scaleX(0.98);
89
+ }
90
+ 75% {
91
+ transform: translateY(1px) scaleY(0.97) scaleX(1.02);
92
+ }
93
+ }
94
+ `}),Ct("div",{style:I,children:Ct("svg",{style:{height:z,width:"auto"},viewBox:"0 0 28 18",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round",children:Ct("polyline",{points:"4 14 14 4 24 14"})})})]}),Ct("button",{onClick:w=>{w.stopPropagation(),e&&e({type:"cta",stickerId:t.id,redirectUrl:t.redirectUrl})},style:g,children:u||t.text})]})}default:return gn("div",{style:{padding:"10px",background:"white",color:"black",borderRadius:"4px"},children:["Unsupported interactive element: ",t.type]})}};return Ct("div",{style:c,className:`interactive-item-z${t.z??0}`,children:Ct("div",{style:y,children:b()})})};import{jsx as Ji,jsxs as Bs}from"react/jsx-runtime";var Co=(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"},ue=(t,e)=>Array.isArray(t)?t.map((o,i)=>{let n=o?.id||o?.key||o?.value||`option_${i+1}`,r=o?.label||o?.optionLabel,l=typeof o=="string"?o:o?.text||o?.title||r||"";return{id:String(n),text:l,image:o?.image||o?.imageUrl||"",label:r,isCorrect:o?.isCorrect===!0||String(n)===String(e)}}):t&&typeof t=="object"?Object.entries(t).map(([o,i])=>{let n=typeof i=="string"?{text:i}:i||{};return{id:o,text:n.text||n.title||n.label||"",image:n.image||n.imageUrl||"",label:n.label,isCorrect:o===String(e)}}):[],Yi=t=>Array.isArray(t?.emojis)?t.emojis.map(e=>String(e)):ue(t?.options).map(e=>e.text).filter(Boolean),Qi=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},Gi=(t,e,o)=>{let i=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 i=="string"&&i.trim()!==""?i.trim():"OFFER20"},Xi=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()}},fn=({content:t={},onInteraction:e,isEditing:o=!1,elapsedTime:i=0})=>{let n=t?.canva||{height:1920,width:1080},r=n?.width||1080,l=n?.height||1920,d=.352,c=t?.elements||[],y=t?.image||[],b=t?.text||[],h=t?.ctas||[],f=t?.interactions||[],v=Array.isArray(t?.shopable)&&t.shopable.length>0?t.shopable:Array.isArray(t?.styling?.shopable)?t.styling.shopable:[],S=new Set(v.map(a=>a.id)),u=(t?.styling?.shopable||[]).concat(v.map(a=>a.styling).filter(Boolean)),g=Co(null,t)==="studio",C=(a,x=g)=>{if(a==null||a==="")return;if(x)return`${a}cqh`;let s=Number(a);return isNaN(s)?String(a):`${s/l*100}cqh`},I=(a,x=g)=>{if(a==null||a==="")return;let s=Number(a);return isNaN(s)?String(a):s<10?`clamp(11px, ${s*.85}cqh, 18px)`:`clamp(11px, ${s/1920*100*1.5}cqh, 18px)`};if(c.length===0&&y.length===0&&b.length===0&&f.length===0&&v.length===0&&h.length===0)return null;let z=c.filter(a=>!S.has(a.id)).map(a=>{let x=a.custom||{},s=x.data||{},p=x.style||a.styling||{},M=Co(a,t),T=M==="studio",R=a.position||a.postion||{},$=a.size||{},N=a.x!==void 0?a.x:R.x,V=a.y!==void 0?a.y:R.y,O=a.width!==void 0?a.width:$.width,q=a.height!==void 0?a.height:$.height,Z=N!==void 0&&!isNaN(Number(N))?T?Number(N):Number(N)/r*100:10,it=V!==void 0&&!isNaN(Number(V))?T?Number(V):Number(V)/l*100:15,et=O!==void 0&&!isNaN(Number(O))?T?Number(O):Number(O)/r*100:80,rt=q!==void 0&&!isNaN(Number(q))?T?Number(q):Number(q)/l*100:void 0,k={id:a.id||Math.random().toString(),type:Qi(x.interactiveType||a.widgetType||a.type||"unknown"),x:Z,y:it,width:et,height:rt,url:a.url||s.url||a.link||s.link,rotation:p.rotation??a.rotation??0,z:a.z??a.position?.z??p.z??10,duration:s.duration||p.duration,styling:{backgroundColor:ut(p.background||p.containerBgColor||p.backgroundColor),borderRadius:p.borderRadius!==void 0?p.borderRadius>=100?"999px":C(p.borderRadius,T):p.radius!==void 0?p.radius>=100?"999px":C(p.radius,T):"0px",padding:C(p.containerPadding!==void 0?p.containerPadding:p.padding!==void 0?p.padding:0,T),shadow:p.shadow,fontSize:I(p.questionFontSize??p.questionFont?.fontSize??p.questionSize??p.fontSize,T),opacity:p.opacity??1,animation:mo(p.animation)}};if(k.type==="poll"){let L=ue(s.options);return{...k,type:"poll",question:s.question||s.title||"Poll Question",options:L,layout:s.layout||{type:"vertical",columns:1},styling:{...k.styling,headerColor:ut(p.headerBgColor||p.background),headerTextColor:Q(p.questionColor||p.questionTextColor||p.question?.color),optionBgColor:ut(p.optionBgColor||p.options?.background)||"#1A1A1A",optionTextColor:Q(p.optionTextColor||p.options?.textColor)||"#ffffff",optionBorderRadius:p.optionBorderRadius!==void 0?C(p.optionBorderRadius,T):p.options?.radius!==void 0?C(p.options?.radius,T):"0px"}}}if(k.type==="quiz"){let L=p.colors||{},X=ue(s.options,s.isCorrect),ht=p.optionFontSize??p.optionFont?.fontSize??p.typography?.optionSize??p.options?.fontSize??16;return{...k,type:"quiz",question:s.question||s.title||"Quiz Question",options:X,showExplanation:s.showExplanation,url:s.url,styling:{...k.styling,backgroundColor:ut(p.background||p.containerBgColor||p.backgroundColor)||"transparent",questionTextColor:Q(p.questionColor||L.questionColor||p.question?.color||p.colors?.questionText)||"#FFFFFF",questionBgColor:ut(p.questionBgColor||L.questionBackground||p.question?.background||p.colors?.questionBg)||"#000000",optionBgColor:ut(p.optionBgColor||L.optionBackground||p.options?.background||p.colors?.optionBg)||"#FFFFFF",optionTextColor:Q(p.optionTextColor||L.optionTextColor||p.options?.textColor||p.colors?.optionText)||"#2B2B2B",borderColor:Q(p.borderColor)||"transparent",activeColor:Q(p.correctColor||L.correctColor||p.correctBorderColor)||"#10b981",incorrectColor:Q(p.incorrectColor||L.incorrectColor)||"#ef4444",optionBorderRadius:p.optionRadius!==void 0?p.optionRadius>=100?"999px":C(p.optionRadius,T):p.optionBorderRadius!==void 0?p.optionBorderRadius>=100?"999px":C(p.optionBorderRadius,T):"100px",optionFontSize:I(ht,T)}}}if(k.type==="rating")return{...k,type:"rating",title:s.title||"Do you like my space?",emoji:s.emoji||"\u{1F60D}",currentRating:s.currentRating,maxRating:s.maxRating,styling:{...k.styling,sliderTrackColor:Q(p.colors?.sliderTrack||p.sliderTrack),sliderFillColor:Q(p.colors?.sliderFill||p.sliderFill),emojiSize:p.emojiSize?T?`${Math.min(Number(p.emojiSize),32)}px`:`${Math.min(p.emojiSize*.45,32)}px`:void 0,titleColor:Q(p.colors?.titleColor||p.titleColor),titleFontSize:p.titleFontSize?T?`${Math.min(Number(p.titleFontSize),16)}px`:`${Math.min(p.titleFontSize*.4,16)}px`:void 0}};if(k.type==="question")return{...k,type:"question",question:s.question||s.title||"Ask me a question",placeholder:s.placeholder||"Type your answer...",styling:{...k.styling,promptColor:Q(p.questionColor||p.textColor),inputBgColor:ut(p.inputBgColor),inputTextColor:Q(p.inputTextColor),submitBackground:ut(p.submitBackground)}};if(k.type==="image_quiz"||k.type==="imageQuiz"||(x.interactiveType||"").toLowerCase()==="media_quiz"){let L=p.optionFontSize??p.optionFont?.fontSize??p.typography?.optionSize??p.options?.fontSize??13;return{...k,type:"image_quiz",question:s.question||s.title||"Image Quiz",options:ue(s.options||[]),styling:{...k.styling,questionTextColor:Q(p.questionColor),activeColor:Q(p.correctColor||p.correctBorderColor),incorrectColor:Q(p.incorrectColor),imageRadius:p.imageRadius?C(p.imageRadius,T):void 0,optionFontSize:I(L,T)}}}if(k.type==="countdown")return{...k,type:"countdown",title:s.title||"Ends in...",targetDate:Xi(s),styling:{...k.styling,borderColor:Q(p.borderColor),digitBackground:ut(p.digitBackground),digitColor:Q(p.digitColor),digitSize:p.digitSize||p.fontSize?I(p.digitSize||p.fontSize,T):void 0,labelColor:Q(p.labelColor),titleColor:Q(p.titleColor)},display:s.display};if(k.type==="promo_code")return{...k,width:k.width?Math.max(k.width,65):75,type:"promo_code",code:Gi(a,s,x),styling:{...k.styling,borderColor:Q(p.borderColor)}};if(k.type==="reaction"||k.type==="emoji_reaction"){let L=Yi(s);return{...k,type:"reaction",emojis:L.length>0?L:["\u{1F60D}","\u{1F44D}"],source:M}}return k}),E=(t?.interactions||[]).filter(a=>!S.has(a.id)).map(a=>{let x=a.config||{},s=a.styling||a.style||{},p=Co(a,t),M=p==="studio",T=Qi(a.interaction_type||a.type),R=s.position||a.position||{},$=s.size||a.size||{},N=R.x??a.x,V=R.y??a.y,O=$.width??a.width,q=$.height??a.height,Z=N!==void 0&&!isNaN(Number(N))?M?Number(N):Number(N)/r*100:10,it=V!==void 0&&!isNaN(Number(V))?M?Number(V):Number(V)/l*100:15,et=O!==void 0&&!isNaN(Number(O))?M?Number(O):Number(O)/r*100:80,rt=q!==void 0&&!isNaN(Number(q))?M?Number(q):Number(q)/l*100:void 0,k={id:a.id||Math.random().toString(),type:T,x:Z,y:it,width:et,height:rt,rotation:s.rotation??a.rotation??0,z:a.z??a.position?.z??s.z??10,source:p,duration:x.duration||s.duration,styling:{backgroundColor:ut(s.background||s.containerBgColor||s.backgroundColor),borderRadius:s.borderRadius!==void 0?s.borderRadius>=100?"999px":C(s.borderRadius,M):s.radius!==void 0?s.radius>=100?"999px":C(s.radius,M):"0px",padding:C(s.containerPadding!==void 0?s.containerPadding:s.padding!==void 0?s.padding:0,M),shadow:s.shadow,fontSize:I(s.questionFontSize??s.questionFont?.fontSize??s.questionSize??s.fontSize,M),opacity:s.opacity??1,animation:mo(s.animation)}};if(k.type==="rating"||k.type==="rate"){let L=s.colors||{};return{...k,type:"rating",title:x.title||"Do you like my space?",emoji:x.emoji||"\u{1F60D}",currentRating:x.currentRating,maxRating:x.maxRating,styling:{...k.styling,sliderTrackColor:Q(L.sliderTrack||s.colors?.sliderTrack||s.colors?.sliderTrack),sliderFillColor:Q(L.sliderFill||s.colors?.sliderFill||s.colors?.sliderFill),emojiSize:s.emojiSize?M?`${Math.min(Number(s.emojiSize),32)}px`:`${Math.min(s.emojiSize*.45,32)}px`:void 0,titleColor:Q(L.titleColor||s.colors?.titleColor||s.titleColor),titleFontSize:s.titleFontSize?M?`${Math.min(Number(s.titleFontSize),16)}px`:`${Math.min(s.titleFontSize*.4,16)}px`:void 0}}}if(k.type==="poll"){let L=ue(x.options);return{...k,type:"poll",question:x.question||x.title||"Poll Question",options:L,layout:x.layout||{type:"vertical",columns:1},styling:{...k.styling,headerColor:ut(s.headerBgColor||s.background),headerTextColor:Q(s.questionColor||s.questionTextColor||s.question?.color),optionBgColor:ut(s.optionBgColor||s.options?.background)||"#1A1A1A",optionTextColor:Q(s.optionTextColor||s.options?.textColor)||"#ffffff",optionBorderRadius:s.optionBorderRadius!==void 0?C(s.optionBorderRadius,M):s.options?.radius!==void 0?C(s.options?.radius,M):"0px"}}}if(k.type==="quiz"){let L=s.colors||{},X=ue(x.options,x.isCorrect),ht=s.optionFontSize??s.optionFont?.fontSize??s.typography?.optionSize??s.options?.fontSize??16;return{...k,type:"quiz",question:x.question||x.title||"Quiz Question",options:X,showExplanation:x.showExplanation,url:x.url,styling:{...k.styling,backgroundColor:ut(s.background||s.containerBgColor||s.backgroundColor)||"transparent",questionTextColor:Q(s.questionColor||L.questionColor||s.question?.color||s.colors?.questionText)||"#FFFFFF",questionBgColor:ut(s.questionBgColor||L.questionBackground||s.question?.background||s.colors?.questionBg)||"#000000",optionBgColor:ut(s.optionBgColor||L.optionBackground||s.options?.background||s.colors?.optionBg)||"#FFFFFF",optionTextColor:Q(s.optionTextColor||L.optionTextColor||s.options?.textColor||s.colors?.optionText)||"#2B2B2B",borderColor:Q(s.borderColor)||"transparent",activeColor:Q(s.correctColor||L.correctColor||s.correctBorderColor)||"#10b981",incorrectColor:Q(s.incorrectColor||L.incorrectColor)||"#ef4444",optionBorderRadius:s.optionRadius!==void 0?s.optionRadius>=100?"999px":C(s.optionRadius,M):s.optionBorderRadius!==void 0?s.optionBorderRadius>=100?"999px":C(s.optionBorderRadius,M):"100px",optionFontSize:I(ht,M)}}}if(k.type==="question")return{...k,type:"question",question:x.question||x.title||"Ask me a question",placeholder:x.placeholder||"Type your answer...",styling:{...k.styling,promptColor:Q(s.questionColor||s.promptColor||s.textColor),inputBgColor:ut(s.inputBackground||s.inputBgColor),inputTextColor:Q(s.inputTextColor),submitBackground:ut(s.submitBackground)}};if(k.type==="image_quiz"||k.type==="imageQuiz"||T==="media_quiz"){let L=s.optionFontSize??s.optionFont?.fontSize??s.typography?.optionSize??s.options?.fontSize??13;return{...k,type:"image_quiz",question:x.question||x.title||"Image Quiz",options:ue(x.options||[]),styling:{...k.styling,questionTextColor:Q(s.questionColor),activeColor:Q(s.correctColor||s.correctBorderColor),incorrectColor:Q(s.incorrectColor),imageRadius:s.imageRadius?C(s.imageRadius,M):void 0,optionFontSize:I(L,M)}}}if(k.type==="countdown")return{...k,type:"countdown",title:x.title||"Ends in...",targetDate:Xi(x),styling:{...k.styling,borderColor:Q(s.borderColor),digitBackground:ut(s.digitBackground),digitColor:Q(s.digitColor),digitSize:s.digitSize||s.fontSize?I(s.digitSize||s.fontSize,M):void 0,labelColor:Q(s.labelColor),titleColor:Q(s.titleColor),labelFontSize:s.labelFontSize?I(s.labelFontSize,M):void 0},display:x.display||a.display};if(k.type==="promo_code")return{...k,width:k.width?Math.max(k.width,65):75,type:"promo_code",code:Gi(a,x,s),styling:{...k.styling,borderColor:Q(s.borderColor)}};if(k.type==="reaction"||k.type==="emoji_reaction"){let L=Yi(x);return{...k,type:"reaction",emojis:L.length>0?L:["\u{1F60D}","\u{1F44D}"]}}return k}),w=v.map(a=>{let x=u.find(U=>String(U?.id)===String(a?.id))||u.find(U=>U?.id===void 0)||{},p=Co(a,t)==="studio",M={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},T={...x,...a?.styling||{},...Object.fromEntries(Object.entries(M).filter(([,U])=>U!==void 0))},R=T.position||{},$=T.size||{},N=T.cardBorderRadius!==void 0?Number(T.cardBorderRadius):void 0,V=T.cardRadiusPercent!==void 0?Number(T.cardRadiusPercent):void 0,O=$.height!==void 0?Number($.height):void 0,q=N===void 0&&V!==void 0&&O!==void 0?Math.max(0,Math.min(100,V))/100*(O/2):void 0,Z=N??q,it=Z!==void 0&&!isNaN(Z)?Z*d:void 0,et=R.x!==void 0?p?Number(R.x):Number(R.x)/r*100:0,rt=$.width!==void 0?p?Number($.width):Number($.width)/r*100:100,k=$.height!==void 0?p?Number($.height):Number($.height)/l*100:void 0,L=R.y!==void 0?p?Number(R.y):Number(R.y)/l*100:k?100-k-2.5:85;k&&L+k>96?L=Math.max(0,100-k):L>75&&k&&L+k>91&&(L=Math.max(0,100-k-1));let X=Array.isArray(a.product)&&a.product.length>0,ht=X?a.product:a.static||[];return{id:a.id||Math.random().toString(),type:"buy",shopableType:X?"product":"static",x:et,y:L,width:rt,height:k,rotation:T.rotation??0,z:T.z??10,products:ht.map(U=>{let W=U.productData||U||{},tt=W.attributes||U.attributes||{},dt=tt.sales_price||W.price||tt.price||U.price,St=tt.sales_price?W.price||tt.price||U.price:W.oldPrice||U.oldPrice,yt=W.color||tt.color||U.color,st=W.size||tt.size||U.size,kt=tt.colors||[];kt.length===0&&yt&&(kt=[{id:yt,hex:yt,name:yt}]);let It=tt.sizes||[];It.length===0&&st&&(It=typeof st=="string"?st.split(",").map(Ut=>Ut.trim()):[st]);let ye={description:W.description||tt.description||U.description,color:yt,size:st,colors:kt,sizes:It,imageUrls:tt.imageUrls||[tt.image_link||W.imageUrl||W.image||U.imageUrl||U.image||U.url].filter(Boolean),availability:W.availability||tt.availability||U.availability,tags:W.tags||tt.tags||U.tags,...tt};return{id:W.productId||W.id||U.productId||U.id||Math.random().toString(),image:tt.image_link||W.imageUrl||W.image||U.imageUrl||U.image||U.url,url:W.link||W.url||U.link||U.url||U.redirectUrl,title:W.title||U.title,price:dt,oldPrice:St,redirectUrl:U.redirectUrl||W.link||U.link||U.url,svg:W.svg||U.svg,productId:W.productId||U.productId,collectionId:W.collectionId||U.collectionId,feedId:W.feedId||U.feedId,attributes:ye}}),styling:{backgroundColor:ut(T.background),cardBackground:ut(T.cardBackground)||ut(T.background)||"#ffffff",cardBorderRadius:Z!==void 0&&!isNaN(Z)?p?`${Z}cqh`:`${it}px`:p?"1cqh":"10px",cardRadiusPercent:V,transparent:T.transparent===!0,textColor:Q(T.textColor)||"#ffffff",buttonBackground:ut(T.buttonBackground)||"#000000",buttonTextColor:Q(T.buttonTextColor)||"#ffffff",buttonFontSize:I(T.buttonFontSize||12,p),buttonBorderRadius:T.buttonBorderRadius!==void 0?p?`${T.buttonBorderRadius}cqh`:`${T.buttonBorderRadius}px`:p?"10cqh":"100px",titleColor:Q(T.titleColor||T.textColor)||"#1a1a2e",titleFontSize:I(T.titleFontSize||14,p),titleFontWeight:T.titleFontWeight?String(T.titleFontWeight):"600",priceColor:Q(T.priceColor||T.textColor)||"#1a1a2e",priceFontSize:I(T.priceFontSize||16,p),priceFontWeight:T.priceFontWeight?String(T.priceFontWeight):"700",mrpColor:Q(T.mrpColor)||"#8b8b98",mrpFontSize:I(T.mrpFontSize||12,p),mrpFontWeight:T.mrpFontWeight?String(T.mrpFontWeight):"500",imageRadius:T.imageRadius!==void 0?p?`${T.imageRadius}cqh`:`${Number(T.imageRadius)*d}px`:p?"1cqh":"10px",animation:mo(T.animation)}}}),D=y.map(a=>{let x=a.position||a.postion||{x:0,y:0};return{id:a.id||Math.random().toString(),type:"image",x:g?Number(x.x):x.x/r*100,y:g?Number(x.y):x.y/l*100,width:g?Number(a.width):a.width/r*100,height:a.height?g?Number(a.height):a.height/l*100:void 0,url:a.link||a.url,z:a.z??0}}),_=b.map(a=>{let s=(t?.styling?.text||[]).find(q=>q.id===a.id)||{},p=a.position||s.position||{x:0,y:0},M=a.font||s.font||{},T=a.size||s.size||{},R=a.alignment||s.alignment||{},$=a.color||s.color,N=M.fontDecoration||[],V=N.includes("underline")?"underline":N.includes("line-through")?"line-through":void 0,O=a.rotation!==void 0?a.rotation:s.rotation;return{id:a.id||Math.random().toString(),type:"text",x:g?Number(p.x):p.x/r*100,y:g?Number(p.y):p.y/l*100,width:T.width?g?Number(T.width):T.width/r*100:void 0,height:T.height?g?Number(T.height):T.height/l*100:void 0,rotation:O??0,text:a.text||a.value||s.text||s.value||"",z:a.z??s.z??1,styling:{color:Q($)||"#000000",fontSize:M.fontSize?I(M.fontSize,g):void 0,fontFamily:M.fontFamily,fontStyle:M.fontStyle||(N.includes("italic")?"italic":"normal"),fontWeight:M.fontWeight||(N.includes("bold")?"bold":"normal"),textDecoration:V,lineHeight:a.lineHeight!==void 0?a.lineHeight:s.lineHeight,letterSpacing:(a.letterSpacing!==void 0?a.letterSpacing:s.letterSpacing)!==void 0?`${a.letterSpacing!==void 0?a.letterSpacing:s.letterSpacing}px`:void 0,opacity:(a.opacity!==void 0?a.opacity:s.opacity)!==void 0?Number(a.opacity!==void 0?a.opacity:s.opacity)/100:void 0,textAlign:R.horizontalAlignment||"left",verticalAlignment:R.verticalAlignment||"top"}}}),P=h.map(a=>{let s=(t?.styling?.ctas||[]).find(V=>V.id===a.id)||{},p=a.position||s.position||{x:0,y:0},M=a.size||s.size||{},T=a.font||s.font||{},R=T.fontDecoration||[],$=R.includes("underline")?"underline":R.includes("line-through")?"line-through":void 0,N=a.rotation!==void 0?a.rotation:s.rotation;return{id:a.id||Math.random().toString(),type:"cta",x:g?Number(p.x):p.x/r*100,y:g?Number(p.y):p.y/l*100,width:M.width?g?Number(M.width):M.width/r*100:void 0,height:M.height?g?Number(M.height):M.height/l*100:void 0,rotation:N??0,text:a.text||s.text||"Learn More",redirectUrl:a.redirectUrl||s.redirectUrl||a.link||s.link,ctaType:a.type||s.type||"classic",url:a.url||s.url,z:a.z??s.z??10,source:g?"studio":"dashboard",styling:{backgroundColor:ut(a.background||s.background),textColor:Q(a.textColor||s.textColor)||"#FFFFFF",borderColor:Q(a.borderColor||s.borderColor)||"transparent",borderWidth:a.borderWidth!==void 0?a.borderWidth:s.borderWidth,borderRadius:C(a.borderRadius!==void 0?a.borderRadius:s.borderRadius,g),fontSize:T.fontSize?I(T.fontSize,g):void 0,fontFamily:T.fontFamily,fontStyle:T.fontStyle||(R.includes("italic")?"italic":"normal"),fontWeight:T.fontWeight||(R.includes("bold")?"bold":"normal"),textDecoration:$,pillH:s.pillH,arrowAnimation:s.arrowAnimation,arrowColor:Q(s.arrowColor),arrowSize:s.arrowSize,transparent:s.transparent}}}),H=[...z,...E,...w,...D,..._,...P].filter(a=>{if(!a.duration)return!0;let{start:x,end:s}=a.duration;return i>=x&&i<=s}).sort((a,x)=>(a.z??0)-(x.z??0));return console.log("InteractiveOverlay Debug - content.ctas:",h,"displayCtas:",P,"displayItems:",H),Bs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10,pointerEvents:"none",overflow:"hidden",containerType:"size"},children:[Ji("style",{children:`
53
95
  @keyframes appstorys-fade-in {
54
96
  from { opacity: 0; transform: translateY(10px); }
55
97
  to { opacity: 1; transform: translateY(0); }
@@ -69,16 +111,16 @@ var Yi=Object.defineProperty;var Nt=(t,e)=>()=>(t&&(e=t(t=0)),e);var Qi=(t,e)=>{
69
111
  70% { opacity: 1; transform: scale(0.95); }
70
112
  100% { opacity: 1; transform: scale(1); }
71
113
  }
72
- `}),z.map(d=>!d||typeof d!="object"||!(d.type||"").toLowerCase()?null:fi(di,{data:d,onInteraction:e,isEditing:o},d.id))]})};import{useState as qr}from"react";import{jsx as ye,jsxs as Hr}from"react/jsx-runtime";var Ur=({isPaused:t,onPress:e,style:o,size:i=36})=>{let[n,r]=qr(!1);return ye("button",{onClick:e,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{width:`${i}px`,height:`${i}px`,background:n?"rgba(255, 255, 255, 0.15)":"rgba(255, 255, 255, 0.08)",border:n?"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?ye("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:ye("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"})}):Hr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:[ye("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),ye("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})})},mi=Ur;import{jsx as jo}from"react/jsx-runtime";var Vr=t=>{switch(t){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},Yr=({cta:t,buttonText:e,onPress:o})=>!t||!e||e.trim()===""?null:jo("div",{style:{position:"absolute",bottom:t?.margin?.bottom,left:t?.margin?.left,right:t?.margin?.right,display:"flex",justifyContent:Vr(t?.container?.alignment),width:"100%",pointerEvents:"none",boxSizing:"border-box",zIndex:10},children:jo("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:jo("span",{style:{color:t?.text?.color||"#ffffff",fontSize:t?.text?.fontSize||14,fontFamily:ct(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:Oe(e)})})}),No=Yr;import{jsx as Ve,jsxs as Gr}from"react/jsx-runtime";var Qr=({config:t,onPress:e,style:o,ignoreSizeAndMargin:i=!1})=>{if(!t||!t.enabled)return null;let{size:n=18,margin:r,color:s,image:a,selectedStyle:c}=t,u=i?40:n,x={marginTop:i?0:r?.top??0,marginBottom:i?0:r?.bottom??0,marginLeft:i?0:r?.left??0,marginRight:i?0:r?.right??0,width:u,height:u,backgroundColor:s?.fill||"transparent",borderColor:s?.stroke||"transparent",borderWidth:u*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"absolute",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:s?.stroke?"solid":"none",...o},m=()=>{let g=s?.cross||"#ffffff";return Gr("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[Ve("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"}),Ve("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"})]})};return Ve("button",{onClick:e,style:x,title:c||"",children:a&&a.trim()!==""?Ve("img",{src:a,style:{width:u,height:u,objectFit:"contain"},alt:"close"}):m()})},Lt=Qr;import{jsx as Mt,jsxs as yi}from"react/jsx-runtime";var qo=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:i,style:n,type:r})=>{if(!t||!i)return null;let{size:s=18,margin:a,color:c,image:u,selectedStyle:x}=t,m=o?40:s,g=o?0:a?.top??0,v=o?0:a?.bottom??0,f=o?0:a?.left??0,b=o?0:a?.right??0,h={marginTop:g,marginBottom:v,marginLeft:f,marginRight:b,width:m,height:m,backgroundColor:c?.fill||"transparent",borderColor:c?.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},...n},y=()=>{let w=c?.cross||"#ffffff";return r==="mute"?yi("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[Mt("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinejoin:"round"}),Mt("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"}),Mt("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"})]}):yi("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[Mt("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinejoin:"round"}),Mt("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"}),Mt("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"})]})};return Mt("button",{onClick:e,style:{...h,border:h.borderColor?`${h.borderWidth}px solid ${h.borderColor}`:"none",padding:0,cursor:"pointer",outline:"none"},title:x||"",children:u&&u.trim()!==""?Mt("img",{src:u,style:{width:m,height:m,objectFit:"contain"},alt:r}):y()})};import{jsx as Vt,jsxs as Xr}from"react/jsx-runtime";var Jr=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,style:i})=>{if(!t||t.enabled===!1)return null;let{size:n=18,margin:r,color:s,image:a,selectedStyle:c}=t,u=o?40:n,x={marginTop:o?0:r?.top??0,marginBottom:o?0:r?.bottom??0,marginLeft:o?0:r?.left??0,marginRight:o?0:r?.right??0,width:u,height:u,backgroundColor:s?.fill||"transparent",borderColor:s?.stroke||"transparent",borderWidth:u*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"absolute",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:s?.stroke?"solid":"none",...i},m=()=>{let g=s?.cross||"#ffffff";return Xr("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"none",stroke:g,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[Vt("circle",{cx:"18",cy:"5",r:"3"}),Vt("circle",{cx:"6",cy:"12",r:"3"}),Vt("circle",{cx:"18",cy:"19",r:"3"}),Vt("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),Vt("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})};return Vt("button",{onClick:e,style:x,title:c||"",children:a&&a.trim()!==""?Vt("img",{src:a,style:{width:u,height:u,objectFit:"contain"},alt:"share"}):m()})},hi=Jr;import{Fragment as Zr,jsx as W,jsxs as it}from"react/jsx-runtime";var be=.63,Ho=420,Dt=580,Vo="cubic-bezier(0.65, 0, 0.35, 1)",Yo="cubic-bezier(0.45, 0, 0.25, 1)";function Kr(t,e){let o=Ho+e*be+27;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(-${Ho}px) scale(${be})`,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(${Ho}px) scale(${be})`,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(-${o}px) scale(${be})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};case"far-right":return{transform:`translateX(${o}px) scale(${be})`,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 xi=({src:t,isActive:e,isAnimating:o,isMuted:i,onLoadedData:n,activeVideoRef:r})=>{let s=bi.useRef(null);return bi.useEffect(()=>{e&&!o?(r.current=s.current,s.current?.play().catch(()=>{}),s.current&&s.current.readyState>=2&&n?.()):(s.current?.pause(),r.current===s.current&&(r.current=null))},[e,o,t,r]),W("video",{ref:s,src:t,playsInline:!0,muted:i,onLoadedData:e&&!o?n:void 0,style:{width:"100%",height:"100%",objectFit:"cover"}})},Si=({stories:t,activeStoryIndex:e,dataId:o,viewedStories:i,setViewedStories:n,onNextStory:r,onPrevStory:s,onClose:a})=>{let[c,u]=St(0),[x,m]=St(0),[g,v]=St(!1),[f,b]=St(!1),[h,y]=St(!1),[w,I]=St(!1),[z,R]=St(null),[d,T]=St(typeof window<"u"?window.innerWidth>=1024:!1),[l,p]=St(!1),[M,B]=St(null),[L,C]=St(null),[S,_]=St(null);he(()=>{let A=()=>{T(window.innerWidth>=1024)};return window.addEventListener("resize",A),()=>window.removeEventListener("resize",A)},[]);let E=Uo(null),$=Uo(null),D=Uo(0),k=t[e],P=k?.slides[c],O=P?.styling,G=O?.editorSource||O?.meta?.editorSource,ut=G==="studio"||G==="editor",j=ut?O?.background?.media?.mediaUrl:P?.image,X=ut?P?.content?.button_text:P?.button_text,J=ut?P?.content?.link:P?.link,V=P?.video||(ut?P?.content?.video?.[0]?.link:void 0),et=P?.content?.canva,q=et&&et.width&&et.height?et.width/et.height:400/700,Q=700,Y=Math.round(Q*q),lt=async()=>{let A={title:k.name,text:`Check out this story: ${k.name}`,url:window.location.href};if(P?.id&&H("shared",o,{story_slide:P.id}),navigator.share)try{await navigator.share(A)}catch{}else if(navigator.clipboard)try{await navigator.clipboard.writeText(window.location.href),R("Story link copied to clipboard!"),setTimeout(()=>R(null),2500)}catch{}};if(he(()=>{u(0),m(0),b(!1),y(!1),p(!1),B(null),C(null),_(null)},[e]),he(()=>{let A=N=>{if(!(document.activeElement?.tagName==="INPUT"||document.activeElement?.tagName==="TEXTAREA"))switch(N.key){case"ArrowRight":nt();break;case"ArrowLeft":Ct();break;case" ":N.preventDefault(),y(st=>!st);break;case"Escape":a();break;case"s":case"S":N.preventDefault(),lt();break}};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[c,e,h,k,a]),he(()=>{k&&P&&H("viewed",o,{story_slide:P.id})},[c,k?.id,o]),he(()=>{if(k&&P){let A=k.styling?.slideShowTime||5,N=!!V;if(E.current&&clearInterval(E.current),h){$.current&&$.current.pause();return}else $.current&&$.current.play().catch(()=>{});return N&&!f||l?void 0:(E.current=setInterval(()=>{m(st=>st>=100?(nt(),100):st+100/(A*10))},100),()=>{E.current&&clearInterval(E.current)})}},[e,c,h,f,l]),!P)return null;let mt=(A,N)=>{l||(_(A),B(c),C(N),p(!0),setTimeout(()=>{u(N),m(0),b(!1),p(!1),B(null),C(null),_(null)},Dt+20))},nt=()=>{if(!l)if(c<k.slides.length-1)mt("next",c+1);else{if(!i.includes(k.id)){let A=[...i,k.id];n(A),localStorage.setItem("app_storys_viewed_stories",JSON.stringify(A))}r()}},Ct=()=>{l||(c>0?mt("prev",c-1):s())},gt=()=>{D.current=Date.now(),y(!0)},vt=A=>{y(!1),Date.now()-D.current<300&&(A==="next"?nt():Ct())},jt=()=>b(!0),sn=A=>{let N=A?.styling,st=N?.editorSource||N?.meta?.editorSource,ft=st==="studio"||st==="editor"?A.content?.link:A.link;ft&&(H("clicked",o,{story_slide:A.id}),ft.startsWith("http")?window.open(ft,"_blank"):window.location.href=ft)},an=A=>{A.stopPropagation(),v(!g)},ln=k?.styling?.crossButton,dn=k?.styling?.soundToggle,js=P?.styling?.cta,cn=A=>l?S==="next"?A===M?"left":A===L?"center":A===(M??0)-1?"far-left":A===(M??0)-2?"hidden":A===(L??0)+1?"right":A===(L??0)+2?"far-right":"hidden":A===M?"right":A===L?"center":A===(M??0)+1?"far-right":A===(M??0)+2?"hidden":A===(L??0)-1?"left":A===(L??0)-2?"far-left":"hidden":A===c?"center":A===c-1?"left":A===c-2?"far-left":A===c+1?"right":A===c+2?"far-right":"hidden",Ni=d?{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:"100vh",backgroundColor:"rgba(0,0,0,0.95)",zIndex:1e5,display:"flex",justifyContent:"center",alignItems:"center"},pn=d?{position:"absolute",width:`${Y}px`,height:`${Q}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:"100%",maxWidth:"450px",height:"100%",maxHeight:"850px",backgroundColor:"#000",borderRadius:"0px",overflow:"hidden",display:"flex",flexDirection:"column"},Ns={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"},qi=k.slides.reduce((A,N,st)=>(cn(st)!=="hidden"&&A.push(st),A),[]),Gt=new Set(qi);return Gt.add(c),c>0&&Gt.add(c-1),c>1&&Gt.add(c-2),c<k.slides.length-1&&Gt.add(c+1),c<k.slides.length-2&&Gt.add(c+2),it("div",{style:Ni,onClick:()=>!d&&nt(),children:[it("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:[V?W("video",{src:V,style:{width:"100%",height:"100%",objectFit:"cover",filter:"blur(120px) saturate(1.8) opacity(0.35)"},muted:!0}):W(zt,{src:j||k.thumbnail,style:{width:"100%",height:"100%",filter:"blur(120px) saturate(1.8) opacity(0.35)"}}),W("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(5, 5, 8, 0.4)"}})]},`${e}-${l?L:c}`),d&&it("div",{style:{width:"100%",display:"flex",flexDirection:"column",paddingTop:"20px",zIndex:10},children:[W("div",{style:{width:"100%",display:"flex",gap:"8px",padding:"0 20px",boxSizing:"border-box"},children:k.slides.map((A,N)=>{let st=l&&L!==null?L:c,Rt="0%";return N<st?Rt="100%":N===st&&(Rt=`${x}%`),W("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.15)",borderRadius:"2px",overflow:"hidden"},children:W("div",{style:{width:Rt,height:"100%",backgroundColor:"white",transition:N===st?"width 0.1s linear":"none"}})},N)})}),it("div",{style:{width:"100%",maxWidth:"1400px",margin:"0 auto",display:"grid",gridTemplateColumns:`minmax(0, 1fr) ${Y}px minmax(0, 1fr)`,gap:"12px",alignItems:"center",marginTop:"16px",padding:"0 20px",boxSizing:"border-box",zIndex:w?2e3:10},children:[W("div",{style:{paddingLeft:"0px"}}),it("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[it("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[W(zt,{src:k.thumbnail,alt:k.name,style:{width:"44px",height:"44px",borderRadius:"50%",border:"2px solid white",margin:0}}),W("span",{style:{color:"white",fontWeight:"bold",fontSize:"16px",whiteSpace:"nowrap"},children:k.name})]}),it("div",{style:{display:"flex",gap:"8px"},children:[W(hi,{config:{enabled:k?.styling?.share?.enabled??!0,image:k?.styling?.share?.image??"",color:{cross:k?.styling?.share?.color?.cross??"#ffffff",fill:k?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:k?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:k?.styling?.share?.size??44},onPress:lt,style:{position:"relative",borderRadius:"12px"}}),W(qo,{config:{size:44,color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:an,type:g?"mute":"unmute",enabled:!!dn?.enabled&&!!V,style:{position:"relative",borderRadius:"12px"}}),W(mi,{isPaused:h,onPress:()=>y(!h),size:44,style:{borderRadius:"12px"}})]})]}),it("div",{style:{display:"flex",gap:"10px",flex:1,justifyContent:"flex-end",paddingRight:"0px"},children:[it("div",{style:{position:"relative"},children:[W("button",{onClick:()=>{I(!w),y(!w)},style:{width:"44px",height:"44px",background:w?"rgba(255,255,255,0.15)":"rgba(255,255,255,0.08)",border:w?"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:it("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[W("rect",{x:"3",y:"3",width:"7",height:"7"}),W("rect",{x:"14",y:"3",width:"7",height:"7"}),W("rect",{x:"14",y:"14",width:"7",height:"7"}),W("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),w&&it(Zr,{children:[W("style",{children:`
114
+ `}),H.map(a=>!a||typeof a!="object"||!(a.type||"").toLowerCase()?null:Ji(Ui,{data:a,onInteraction:e,isEditing:o},a.id))]})};import{useState as Ls}from"react";import{jsx as Oe,jsxs as As}from"react/jsx-runtime";var Ms=({isPaused:t,onPress:e,style:o,size:i=36})=>{let[n,r]=Ls(!1);return Oe("button",{onClick:e,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{width:`${i}px`,height:`${i}px`,background:n?"rgba(255, 255, 255, 0.15)":"rgba(255, 255, 255, 0.08)",border:n?"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?Oe("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:Oe("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"})}):As("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:[Oe("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),Oe("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})})},Ki=Ms;import{jsx as mn}from"react/jsx-runtime";var Es=t=>{switch(t){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},Ds=({cta:t,buttonText:e,onPress:o})=>!t||!e||e.trim()===""?null:mn("div",{style:{position:"absolute",bottom:t?.margin?.bottom,left:t?.margin?.left,right:t?.margin?.right,display:"flex",justifyContent:Es(t?.container?.alignment),width:"100%",pointerEvents:"none",boxSizing:"border-box",zIndex:10},children:mn("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:mn("span",{style:{color:t?.text?.color||"#ffffff",fontSize:t?.text?.fontSize||14,fontFamily:gt(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:Zt(e)})})}),yn=Ds;import{jsx as ne,jsxs as Zi}from"react/jsx-runtime";var pe=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:i,style:n,type:r})=>{if(!t||!i)return null;let{size:l=18,margin:d,color:c,image:y,selectedStyle:b}=t,h=o?40:l,f=o?0:d?.top??0,v=o?0:d?.bottom??0,S=o?0:d?.left??0,u=o?0:d?.right??0,m={marginTop:f,marginBottom:v,marginLeft:S,marginRight:u,width:h,height:h,backgroundColor:c?.fill||"transparent",borderColor:c?.stroke||"transparent",borderWidth:h*.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},...n},g=()=>{let C=c?.cross||"#ffffff";return r==="mute"?Zi("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[ne("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:C,strokeWidth:"2.2",strokeLinejoin:"round"}),ne("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:C,strokeWidth:"2.2",strokeLinecap:"round"}),ne("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:C,strokeWidth:"2.2",strokeLinecap:"round"})]}):Zi("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[ne("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:C,strokeWidth:"2.2",strokeLinejoin:"round"}),ne("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:C,strokeWidth:"2.2",strokeLinecap:"round"}),ne("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:C,strokeWidth:"2.2",strokeLinecap:"round"})]})};return ne("button",{onClick:e,style:{...m,border:m.borderColor?`${m.borderWidth}px solid ${m.borderColor}`:"none",padding:0,cursor:"pointer",outline:"none"},title:b||"",children:y&&y.trim()!==""?ne("img",{src:y,style:{width:h,height:h,objectFit:"contain"},alt:r}):g()})};import{jsx as ge,jsxs as Ps}from"react/jsx-runtime";var _s=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,style:i})=>{if(!t||t.enabled===!1)return null;let{size:n=18,margin:r,color:l,image:d,selectedStyle:c}=t,y=o?40:n,b={marginTop:o?0:r?.top??0,marginBottom:o?0:r?.bottom??0,marginLeft:o?0:r?.left??0,marginRight:o?0:r?.right??0,width:y,height:y,backgroundColor:l?.fill||"transparent",borderColor:l?.stroke||"transparent",borderWidth:y*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"absolute",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:l?.stroke?"solid":"none",...i},h=()=>{let f=l?.cross||"#ffffff";return Ps("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"none",stroke:f,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[ge("circle",{cx:"18",cy:"5",r:"3"}),ge("circle",{cx:"6",cy:"12",r:"3"}),ge("circle",{cx:"18",cy:"19",r:"3"}),ge("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),ge("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})};return ge("button",{onClick:e,style:b,title:c||"",children:d&&d.trim()!==""?ge("img",{src:d,style:{width:y,height:y,objectFit:"contain"},alt:"share"}):h()})},tr=_s;import{Fragment as Ns,jsx as j,jsxs as ft}from"react/jsx-runtime";var je=.63;var qt=580,hn="cubic-bezier(0.65, 0, 0.35, 1)",bn="cubic-bezier(0.45, 0, 0.25, 1)";function $s(t,e){let o=Math.round(e*1.08),i=o+Math.round(e*je)+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(${je})`,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(${je})`,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(-${i}px) scale(${je})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};case"far-right":return{transform:`translateX(${i}px) scale(${je})`,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 or=({src:t,isActive:e,isAnimating:o,isMuted:i,onLoadedData:n,activeVideoRef:r,objectFit:l="cover"})=>{let d=er.useRef(null);return er.useEffect(()=>{e&&!o?(r.current=d.current,d.current?.play().catch(()=>{}),d.current&&d.current.readyState>=2&&n?.()):(d.current?.pause(),r.current===d.current&&(r.current=null))},[e,o,t,r]),j("video",{ref:d,src:t,playsInline:!0,muted:i,onLoadedData:e&&!o?n:void 0,style:{width:"100%",height:"100%",objectFit:l}})},Cn="appstorys_viewed_slide_ids",vn="appstorys_clicked_interaction_ids",Ws=t=>{try{let e=localStorage.getItem(Cn);if(!e)return!1;let o=JSON.parse(e);return Array.isArray(o)&&o.includes(t)}catch{return!1}},Os=t=>{try{let e=localStorage.getItem(Cn),o=e?JSON.parse(e):[];Array.isArray(o)&&!o.includes(t)&&(o.push(t),localStorage.setItem(Cn,JSON.stringify(o)))}catch{}},xn=t=>{try{let e=localStorage.getItem(vn);if(!e)return!1;let o=JSON.parse(e);return Array.isArray(o)&&o.includes(t)}catch{return!1}},Sn=t=>{try{let e=localStorage.getItem(vn),o=e?JSON.parse(e):[];Array.isArray(o)&&!o.includes(t)&&(o.push(t),localStorage.setItem(vn,JSON.stringify(o)))}catch{}},nr=({stories:t,activeStoryIndex:e,dataId:o,viewedStories:i,setViewedStories:n,onNextStory:r,onPrevStory:l,onClose:d})=>{let[c,y]=Tt(0),[b,h]=Tt(0),[f,v]=Tt(!1),[S,u]=Tt(!1),[m,g]=Tt(!1),[C,I]=Tt(!1),[z,E]=Tt(null),[w,D]=Tt({width:typeof window<"u"?window.innerWidth:1280,height:typeof window<"u"?window.innerHeight:800}),[_,P]=Tt(typeof window<"u"?window.innerWidth>=1024:!1),[H,B]=Tt(!1),[a,x]=Tt(null),[s,p]=Tt(null),[M,T]=Tt(null),[R,$]=Tt(!1),[N,V]=Tt("none"),[O,q]=Tt(null);Ne(()=>{let F=()=>{D({width:window.innerWidth,height:window.innerHeight}),P(window.innerWidth>=1024)};return window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[]);let Z=vo(null),it=vo(null),et=vo(0),rt=vo(null),k=t[e],L=k?.slides[c],X=L?.styling,ht=X?.editorSource||X?.meta?.editorSource,U=ht==="studio"||ht==="editor",W=U?X?.background?.media?.mediaUrl:L?.image,tt=U?L?.content?.button_text:L?.button_text,dt=U?L?.content?.link:L?.link,St=L?.video||(U?L?.content?.video?.[0]?.link:void 0),yt=L?.content?.canva,st=yt&&yt.width&&yt.height?yt.width/yt.height:9/16,kt=_?160:80,It=Math.max(350,w.height-kt),ye=_?w.width*.75:w.width*.95,Ut=Math.min(It,ye/st),he=Math.round(_?Math.max(450,Math.min(Ut,850)):Math.min(It,850)),Yt=Math.round(he*st),Pn=async()=>{let F={title:k.name,text:`Check out this story: ${k.name}`,url:window.location.href};if(L?.id&&G("shared",o,{story_slide:L.id}),navigator.share)try{await navigator.share(F)}catch{}else if(navigator.clipboard)try{await navigator.clipboard.writeText(window.location.href),E("Story link copied to clipboard!"),setTimeout(()=>E(null),2500)}catch{}};if(Ne(()=>{y(0),h(0),u(!1),g(!1),B(!1),x(null),p(null),T(null)},[e]),Ne(()=>{let F=Y=>{if(!(document.activeElement?.tagName==="INPUT"||document.activeElement?.tagName==="TEXTAREA"))switch(Y.key){case"ArrowRight":Ae();break;case"ArrowLeft":_o();break;case" ":Y.preventDefault(),g(at=>!at);break;case"Escape":d();break;case"s":case"S":Y.preventDefault(),Pn();break}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[c,e,m,k,d]),Ne(()=>{k&&L&&rt.current!==L.id&&(rt.current=L.id,Ws(L.id)||(Os(L.id),G("viewed",o,{story_slide:L.id})))},[c,k?.id,o,L?.id]),Ne(()=>{if(k&&L){let F=k.styling?.slideShowTime||5,Y=!!St;if(Z.current&&clearInterval(Z.current),m){it.current&&it.current.pause();return}else it.current&&it.current.play().catch(()=>{});return Y&&!S||H?void 0:(Z.current=setInterval(()=>{h(at=>at>=100?(Ae(),100):at+100/(F*10))},100),()=>{Z.current&&clearInterval(Z.current)})}},[e,c,m,S,H]),!L)return null;let $n=(F,Y)=>{H||(T(F),x(c),p(Y),B(!0),setTimeout(()=>{y(Y),h(0),u(!1),B(!1),x(null),p(null),T(null)},qt+20))},Ae=()=>{if(!(H||R))if(c<k.slides.length-1)$n("next",c+1);else{if(!i.includes(k.id)){let F=[...i,k.id];n(F),localStorage.setItem("app_storys_viewed_stories",JSON.stringify(F))}Ge("next")}},_o=()=>{H||R||(c>0?$n("prev",c-1):Ge("prev"))},Ge=F=>{if(!(R||H)){if(F==="next"){if(e>=t.length-1){r();return}}else if(e<=0){l();return}$(!0),q(F),V("out"),setTimeout(()=>{F==="next"?r():l(),V("prepare-in"),setTimeout(()=>{V("in"),setTimeout(()=>{$(!1),V("none"),q(null)},320)},35)},280)}},Wn=()=>N==="out"?{transform:`translateX(${O==="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"}:N==="prepare-in"?{transform:`translateX(${O==="next"?120:-120}px) scale(0.92)`,opacity:0,filter:"blur(6px)",transition:"none",willChange:"transform, opacity, filter"}:N==="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=()=>{et.current=Date.now(),g(!0)},Gt=F=>{g(!1),Date.now()-et.current<300&&(F==="next"?Ae():_o())},On=()=>u(!0),Nn=F=>{let Y=F?.styling,at=Y?.editorSource||Y?.meta?.editorSource,vt=at==="studio"||at==="editor"?F.content?.link:F.link;if(vt){let Pt=`cta_slide_${F.id}`;xn(Pt)||(Sn(Pt),G("clicked",o,{story_slide:F.id})),vt.startsWith("http")?window.open(vt,"_blank"):window.location.href=vt}},jn=async(F,Y)=>{let{type:at,questionId:Bt,pollId:vt,quizId:Pt,optionId:Lt,value:Nt,stickerId:jt,redirectUrl:Xt}=F;if(at==="cta"){if(Xt){let Mt=jt||`cta_sticker_${Y.id}`;xn(Mt)||(Sn(Mt),G("clicked",o,{story_slide:Y.id,cta_id:jt})),Xt.startsWith("http")?window.open(Xt,"_blank"):window.location.href=Xt}return}g(!0);let Et=at?.split("_")[0]||"interaction";Et==="quizz"&&(Et="quiz"),at?.startsWith("image_quiz")&&(Et="quiz");let Jt=jt||Bt||vt||Pt||Y.id;if(xn(Jt))return;Sn(Jt);let Kt=Lt||F.selected_option||F.emoji||"",zt=A.getState(),ae=zt.userId||"anonymous",Xe=zt.trackingUrl||"https://tracking.appstorys.co",xe=await bt(),Je={interaction_type:Et,interaction_id:Jt,story_slide:Y.id,selected_option:String(Kt)};Nt!=null&&Nt!==""&&(Je.value=String(Nt)),fetch(`${Xe}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...xe?{Authorization:`Bearer ${xe}`}:{}},body:JSON.stringify({user_id:ae,campaign_id:o,event:"clicked",metadata:Je})}).catch(Mt=>console.error("AppStorys: Instant Tracking Failed",Mt))},Hn=F=>{F.stopPropagation(),v(!f)},qn=k?.styling?.crossButton,Vn=k?.styling?.soundToggle,Xa=L?.styling?.cta,Un=F=>H?M==="next"?F===a?"left":F===s?"center":F===(a??0)-1?"far-left":F===(a??0)-2?"hidden":F===(s??0)+1?"right":F===(s??0)+2?"far-right":"hidden":F===a?"right":F===s?"center":F===(a??0)+1?"far-right":F===(a??0)+2?"hidden":F===(s??0)-1?"left":F===(s??0)-2?"far-left":"hidden":F===c?"center":F===c-1?"left":F===c-2?"far-left":F===c+1?"right":F===c+2?"far-right":"hidden",zr=_?{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:"100vh",backgroundColor:"rgba(0,0,0,0.95)",zIndex:1e5,display:"flex",justifyContent:"center",alignItems:"center"},Yn=_?{position:"absolute",width:`${Yt}px`,height:`${he}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:`${Yt}px`,maxWidth:"100vw",height:`${he}px`,maxHeight:"92vh",aspectRatio:`${st}`,backgroundColor:"#000",borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column"},Ja={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"},Ir=k.slides.reduce((F,Y,at)=>(Un(at)!=="hidden"&&F.push(at),F),[]),be=new Set(Ir);return be.add(c),c>0&&be.add(c-1),c>1&&be.add(c-2),c<k.slides.length-1&&be.add(c+1),c<k.slides.length-2&&be.add(c+2),ft("div",{style:zr,onClick:()=>!_&&Ae(),children:[ft("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:[St?j("video",{src:St,style:{width:"100%",height:"100%",objectFit:"cover",filter:"blur(120px) saturate(1.8) opacity(0.35)"},muted:!0}):j(Wt,{src:W||k.thumbnail,style:{width:"100%",height:"100%",filter:"blur(120px) saturate(1.8) opacity(0.35)"}}),j("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(5, 5, 8, 0.4)"}})]},`${e}-${H?s:c}`),_&&ft("div",{style:{width:"100%",display:"flex",flexDirection:"column",paddingTop:"20px",zIndex:10,...Wn()},children:[j("div",{style:{width:"100%",display:"flex",gap:"8px",padding:"0 20px",boxSizing:"border-box"},children:k.slides.map((F,Y)=>{let at=H&&s!==null?s:c,Bt="0%";return Y<at?Bt="100%":Y===at&&(Bt=`${b}%`),j("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.15)",borderRadius:"2px",overflow:"hidden"},children:j("div",{style:{width:Bt,height:"100%",backgroundColor:"white",transition:Y===at?"width 0.1s linear":"none"}})},Y)})}),ft("div",{style:{width:"100%",margin:"0 auto",display:"grid",gridTemplateColumns:`minmax(0, 1fr) ${Yt}px minmax(0, 1fr)`,gap:"12px",alignItems:"center",marginTop:"16px",padding:"0 20px",boxSizing:"border-box",zIndex:C?2e3:10},children:[j("div",{style:{paddingLeft:"0px"}}),ft("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[ft("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[j(Wt,{src:k.thumbnail,alt:k.name,style:{width:"44px",height:"44px",borderRadius:"50%",border:"2px solid white",margin:0}}),j("span",{style:{color:"white",fontWeight:"bold",fontSize:"16px",whiteSpace:"nowrap"},children:k.name})]}),ft("div",{style:{display:"flex",gap:"8px"},children:[j(tr,{config:{enabled:k?.styling?.share?.enabled??!0,image:k?.styling?.share?.image??"",color:{cross:k?.styling?.share?.color?.cross??"#ffffff",fill:k?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:k?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:k?.styling?.share?.size??44},onPress:Pn,style:{position:"relative",borderRadius:"12px"}}),j(pe,{config:{size:44,color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:Hn,type:f?"mute":"unmute",enabled:!!Vn?.enabled&&!!St,style:{position:"relative",borderRadius:"12px"}}),j(Ki,{isPaused:m,onPress:()=>g(!m),size:44,style:{borderRadius:"12px"}})]})]}),ft("div",{style:{display:"flex",gap:"10px",flex:1,justifyContent:"flex-end",paddingRight:"0px"},children:[ft("div",{style:{position:"relative"},children:[j("button",{onClick:()=>{I(!C),g(!C)},style:{width:"44px",height:"44px",background:C?"rgba(255,255,255,0.15)":"rgba(255,255,255,0.08)",border:C?"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:ft("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[j("rect",{x:"3",y:"3",width:"7",height:"7"}),j("rect",{x:"14",y:"3",width:"7",height:"7"}),j("rect",{x:"14",y:"14",width:"7",height:"7"}),j("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),C&&ft(Ns,{children:[j("style",{children:`
73
115
  @keyframes fadeUp {
74
116
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
75
117
  to { opacity: 1; transform: translateY(0) scale(1); }
76
118
  }
77
- `}),it("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:[W("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"}),W("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:A,label:N})=>it("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[W("span",{style:{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)"},children:A}),W("span",{style:{fontSize:"13px",color:"#E5E7EB",fontWeight:"500"},children:N})]},A))})]})]})]}),W(Lt,{config:{enabled:ln?.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:a,style:{position:"relative",borderRadius:"12px"}})]})]})]}),W("div",{style:{flex:1,width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"20px"},children:it("div",{style:{display:d?"grid":"flex",gridTemplateColumns:d?`minmax(0, 1fr) ${Y}px minmax(0, 1fr)`:"none",alignItems:"center",justifyContent:"center",gap:"12px",width:"100%",maxWidth:"1400px",position:"relative"},onClick:A=>d&&A.stopPropagation(),children:[d&&W("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(c>0||e>0)&&W("button",{onClick:Ct,style:{background:"rgba(0,0,0,0.5)",border:"none",color:"white",borderRadius:"50%",width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"18px",backdropFilter:"blur(5px)",transition:"background 0.2s"},onMouseEnter:A=>A.currentTarget.style.background="rgba(0,0,0,0.7)",onMouseLeave:A=>A.currentTarget.style.background="rgba(0,0,0,0.5)",children:"\u2039"})}),d?W("div",{style:{width:`${Y}px`,height:`${Q}px`,position:"relative",zIndex:5,overflow:"visible"},children:Array.from(Gt).sort((A,N)=>A-N).map(A=>{let N=k.slides[A];if(!N)return null;let st=cn(A),Rt=Kr(st,Y),ft=N?.styling,ae=ft?.editorSource||ft?.meta?.editorSource,Tt=ae==="studio"||ae==="editor",Re=ft?.background?.media?.mediaUrl||N?.image,le=N?.video||(Tt?N?.content?.video?.[0]?.link:void 0),eo=Pt(ft?.background)||"#000000",de=Tt?N?.content?.button_text:N?.button_text,wt=Tt?N?.content?.link:N?.link,ce=A===c&&!l||l&&A===L,oo={display:"flex",justifyContent:"center",alignItems:"center",background:Tt?eo:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"16px"};return it("div",{style:{...pn,position:"absolute",top:0,left:0,width:`${Y}px`,height:`${Q}px`,...Rt,transition:st==="hidden"||st==="far-left"||st==="far-right"?`opacity ${Dt}ms ease, transform ${Dt}ms ease`:A===M?`transform ${Dt}ms ${Vo}, opacity ${Dt}ms ${Vo}, filter ${Dt}ms ${Vo}`:`transform ${Dt}ms ${Yo}, opacity ${Dt}ms ${Yo}, filter ${Dt}ms ${Yo}`,transformOrigin:"center center",willChange:"transform, opacity, filter"},onClick:Ft=>Ft.stopPropagation(),children:[W("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:gt,onMouseUp:()=>vt("prev"),onTouchStart:gt,onTouchEnd:()=>vt("prev")}),W("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:gt,onMouseUp:()=>vt("next"),onTouchStart:gt,onTouchEnd:()=>vt("next")}),it("div",{style:oo,children:[le?W(xi,{src:le,isActive:ce,isAnimating:l,isMuted:g,onLoadedData:jt,activeVideoRef:$}):(Re||!Tt&&k?.thumbnail)&&W(zt,{src:Re||k?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:Tt?"contain":"cover"}}),W(Oo,{content:{...N.content,styling:{...N.content?.styling,...N?.styling},interactions:N.interactions},elapsedTime:ce?x/100*(k.styling?.slideShowTime||5):0,onInteraction:async Ft=>{if(!ce)return;y(!0);let{type:Fe,questionId:no,pollId:Jt,quizId:io,optionId:ro,value:Ie,stickerId:so}=Ft,Xt=Fe?.split("_")[0]||"interaction";Xt==="quizz"&&(Xt="quiz"),Fe?.startsWith("image_quiz")&&(Xt="quiz");let ze=so||no||Jt||io||N.id,ao=ro||Ft.selected_option||"",un=F.getState(),Ui=un.userId||"anonymous",Hi=un.trackingUrl||"https://tracking.appstorys.co",gn=await dt();fetch(`${Hi}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...gn?{Authorization:`Bearer ${gn}`}:{}},body:JSON.stringify({user_id:Ui,campaign_id:o,event:"interaction",metadata:{interaction_type:Xt,interaction_id:ze,slide_id:N.id,selected_option:String(ao),value:String(Ie||"")}})}).catch(Vi=>console.error("AppStorys: Instant Tracking Failed",Vi))}})]}),(de||wt)&&W(No,{cta:N?.styling?.cta,buttonText:de||"Learn More",onPress:Ft=>{Ft&&Ft.stopPropagation&&Ft.stopPropagation(),sn(N)}})]},N.id||A)})}):W("div",{style:{width:"100%",maxWidth:"450px",height:"100%",maxHeight:"850px",overflow:"hidden",position:"relative",zIndex:5,display:"flex",flexDirection:"column"},children:k.slides.map((A,N)=>{if(Math.abs(N-c)>1)return W("div",{style:{display:"none"}},A.id||N);let st=A?.styling,Rt=st?.editorSource||st?.meta?.editorSource,ft=Rt==="studio"||Rt==="editor",ae=st?.background?.media?.mediaUrl||A?.image,Tt=A?.video||(ft?A?.content?.video?.[0]?.link:void 0),Re=Pt(st?.background)||"#000000",le=ft?A?.content?.button_text:A?.button_text,eo=ft?A?.content?.link:A?.link,de=N===c;return de?W("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:it("div",{style:{...pn},onClick:wt=>wt.stopPropagation(),children:[W("div",{style:{position:"absolute",top:0,left:0,right:0,display:"flex",gap:"4px",padding:"10px",zIndex:10},children:k.slides.map((wt,_t)=>{let Te=_t<c?"100%":_t===c?`${x}%`:"0%";return W("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.3)",borderRadius:"2px",overflow:"hidden"},children:W("div",{style:{width:Te,height:"100%",backgroundColor:"white",transition:_t===c?"width 0.1s linear":"none"}})},_t)})}),it("div",{style:{position:"absolute",top:"20px",left:"10px",right:"10px",display:"flex",alignItems:"center",justifyContent:"space-between",zIndex:10,padding:"5px"},children:[it("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[W(zt,{src:k.thumbnail,alt:k.name,style:{width:"32px",height:"32px",borderRadius:"50%"}}),W("span",{style:{color:"white",fontWeight:"bold",fontSize:"14px",textShadow:"0 1px 3px rgba(0,0,0,0.8)"},children:k.name})]}),it("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[W(qo,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:an,type:g?"mute":"unmute",enabled:!!dn?.enabled&&!!Tt,style:{position:"relative",borderRadius:"10px"}}),W(Lt,{config:{enabled:ln?.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:a,style:{position:"relative",borderRadius:"10px"}})]})]}),W("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:gt,onMouseUp:()=>vt("prev"),onTouchStart:gt,onTouchEnd:()=>vt("prev")}),W("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:gt,onMouseUp:()=>vt("next"),onTouchStart:gt,onTouchEnd:()=>vt("next")}),it("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",background:ft?Re:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"0px"},children:[Tt?W(xi,{src:Tt,isActive:de,isAnimating:l,isMuted:g,onLoadedData:jt,activeVideoRef:$}):(ae||k?.thumbnail)&&W(zt,{src:ae||k?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:ft?"contain":"cover"}}),W(Oo,{content:{...A.content,styling:{...A.content?.styling,...A?.styling},interactions:A.interactions},elapsedTime:x/100*(k.styling?.slideShowTime||5),onInteraction:async wt=>{y(!0);let{type:_t,questionId:Te,pollId:ce,quizId:oo,optionId:Ft,value:Fe,stickerId:no}=wt,Jt=_t?.split("_")[0]||"interaction";Jt==="quizz"&&(Jt="quiz"),_t?.startsWith("image_quiz")&&(Jt="quiz");let io=no||Te||ce||oo||A.id,ro=Ft||wt.selected_option||"",Ie=F.getState(),so=Ie.userId||"anonymous",Xt=Ie.trackingUrl||"https://tracking.appstorys.co",ze=await dt();fetch(`${Xt}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...ze?{Authorization:`Bearer ${ze}`}:{}},body:JSON.stringify({user_id:so,campaign_id:o,event:"interaction",metadata:{interaction_type:Jt,interaction_id:io,slide_id:A.id,selected_option:String(ro),value:String(Fe||"")}})}).catch(ao=>console.error("AppStorys: Instant Tracking Failed",ao))}})]}),(le||eo)&&W(No,{cta:A?.styling?.cta,buttonText:le||"Learn More",onPress:wt=>{wt&&wt.stopPropagation&&wt.stopPropagation(),sn(A)}})]})},A.id||N):null})}),d&&W("div",{style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:W("button",{onClick:nt,style:{background:"rgba(0,0,0,0.5)",border:"none",color:"white",borderRadius:"50%",width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"18px",backdropFilter:"blur(5px)",transition:"background 0.2s"},onMouseEnter:A=>A.currentTarget.style.background="rgba(0,0,0,0.7)",onMouseLeave:A=>A.currentTarget.style.background="rgba(0,0,0,0.5)",children:"\u203A"})}),d&&e>0&&it("div",{style:{position:"absolute",bottom:"40px",left:"40px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"5px",zIndex:20},children:[W("span",{style:{fontSize:"11px",fontWeight:"bold",color:"rgba(255,255,255,0.75)",letterSpacing:"0.4px",paddingLeft:"2px"},children:"Previous Stories"}),it("div",{style:{background:"rgba(255, 255, 255, 0.06)",padding:"8px 14px",borderRadius:"14px",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(16px)",cursor:"pointer",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.25)",transition:"all 0.2s",maxWidth:"280px"},onClick:s,children:[W("span",{style:{color:"white",fontSize:"15px"},children:"\u2190"}),W("div",{style:{width:"40px",height:"40px",borderRadius:"50%",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0},children:W(zt,{src:t[e-1].thumbnail,style:{width:"36px",height:"36px",borderRadius:"50%"}})}),W("span",{style:{fontSize:"14px",color:"white",fontWeight:"500",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e-1].name})]})]}),d&&e<t.length-1&&it("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"5px",zIndex:20},children:[W("span",{style:{fontSize:"11px",fontWeight:"bold",color:"rgba(255,255,255,0.75)",letterSpacing:"0.4px",paddingLeft:"2px"},children:"Next Stories"}),it("div",{style:{background:"rgba(255, 255, 255, 0.06)",padding:"8px 14px",borderRadius:"14px",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(16px)",cursor:"pointer",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.25)",transition:"all 0.2s",maxWidth:"280px"},onClick:r,children:[W("div",{style:{width:"40px",height:"40px",borderRadius:"50%",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0},children:W(zt,{src:t[e+1].thumbnail,style:{width:"36px",height:"36px",borderRadius:"50%"}})}),W("span",{style:{fontSize:"14px",color:"white",fontWeight:"500",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e+1].name}),W("span",{style:{color:"white",fontSize:"15px"},children:"\u2192"})]})]}),z&&W("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:z})]})})]})};import{jsx as wi,jsxs as es}from"react/jsx-runtime";var ts=()=>{let t=pt("STR"),e=F(u=>u.isVisible),[o,i]=Ci(null),[n,r]=Ci([]);if(vi(()=>{try{let u=localStorage.getItem("app_storys_viewed_stories");u&&r(JSON.parse(u))}catch(u){console.error("Failed to load viewed stories:",u)}},[]),vi(()=>{t&&t.details&&H("story_module_viewed",t.id)},[t]),!t||!t.details||t.details.length===0||!e)return null;let s=u=>{i(u);let x=t.details[u];H("story_opened",t.id,{story_id:x.id,story_name:x.name})},a=()=>{o!==null&&(o<t.details.length-1?i(o+1):i(null))},c=()=>{o!==null&&o>0&&i(o-1)};return es("div",{className:"story-group-container",style:{width:"100vw",position:"relative",left:"50%",right:"50%",marginLeft:"-50vw",marginRight:"-50vw",boxSizing:"border-box"},children:[wi(On,{stories:t.details,viewedStories:n,onStoryClick:s}),o!==null&&wi(Si,{stories:t.details,activeStoryIndex:o,dataId:t.id,viewedStories:n,setViewedStories:r,onNextStory:a,onPrevStory:c,onClose:()=>i(null)})]})};import{useState as os,useRef as Qe,useEffect as Qo,useCallback as ns}from"react";import{createPortal as is}from"react-dom";K();import{useEffect as ki,useRef as Ye}from"react";function xe(t,e=.5){let o=Ye(t),i=Ye(!1),n=Ye(null),r=Ye(null);ki(()=>{o.current=t},[t]);let s=a=>{if(r.current&&(r.current.disconnect(),r.current=null),n.current=a,i.current=!1,!a)return;if(typeof IntersectionObserver>"u"){o.current();return}let c=null;r.current=new IntersectionObserver(u=>{u[0].isIntersecting&&!i.current?c||(c=setTimeout(()=>{i.current=!0,o.current(),r.current?.disconnect(),c=null},500)):c&&(clearTimeout(c),c=null)},{threshold:e}),r.current.observe(a)};return ki(()=>()=>{r.current?.disconnect()},[]),s}import{jsx as Ot,jsxs as ss}from"react/jsx-runtime";var rs=({position:t})=>{let e=pt("WID",{position:t}),o=F(B=>B.campaigns),i=F(B=>B.allCampaigns),n=F(B=>B.currentScreen),r=B=>(B||"").trim().toLowerCase(),s=e??(()=>{let B=r(n),L=[...o||[],...i||[]].find(C=>{let S=C;if(S.campaign_type!=="WID"||t&&S.position!==t)return!1;let _=!!(S.trigger_event??S.trigger),E=S.display_trigger!==!1&&!_,$=!r(S.screen)||r(S.screen)===B;return E&&$});if(L)try{return yt(L)}catch{return L}})(),[a,c]=os(0),u=Qe(null),x=Qe(null),m=s?.details||{},g=m.widget_images||[],v=m.styling||{},f=m.type||"full",b=f==="half",h=Qe([]),y=Qe(!1),w=ns(()=>{y.current=!0;let B=g[a];B?.id&&z(B.id)},[g,a]),I=xe(w),z=B=>{!s?.id||!B||y.current&&(h.current.includes(B)||(h.current.push(B),H("viewed",s.id,{widget_image:B})))};Qo(()=>{if(f==="full"&&g.length>1)return x.current=setInterval(()=>{c(B=>{let L=B+1;return L>=g.length?0:L})},5e3),()=>{x.current&&clearInterval(x.current)}},[f,g.length]);let R=(B,L)=>{if(s?.id&&H("clicked",s.id,{widget_image:B}),L){if(!L.startsWith("http")){try{if(ht(L))return}catch(C){console.warn("[Widget] revealCampaignFromLink error",C)}console.log("[Widget] Internal link:",L);return}window.open(L,"_blank")}},d=()=>{if(u.current&&b){let{scrollLeft:B,offsetWidth:L}=u.current,C=L/2+12,S=Math.round(B/C);c(S)}};Qo(()=>{if(!s?.id||f!=="full"||g.length===0)return;let B=g[a];B&&B.id&&z(B.id)},[a,s?.id,g,f]),Qo(()=>{if(!s?.id||!u.current||!b)return;let B=u.current,L=()=>{let{scrollLeft:C,offsetWidth:S}=B,_=S/2+12;g.forEach((E,$)=>{let D=$*_,k=D+_,P=C,O=C+S;Math.max(0,Math.min(k,O)-Math.max(D,P))/_>=.5&&z(E.id)})};return L(),B.addEventListener("scroll",L),()=>B.removeEventListener("scroll",L)},[s?.id,b,g]);let T={display:"flex",flexDirection:"row",flexWrap:b?"nowrap":"wrap",gap:"12px",width:"100%",height:b&&m.height?`${m.height}px`:"auto",marginTop:v.topMargin?`${v.topMargin}px`:"0px",marginBottom:v.bottomMargin?`${v.bottomMargin}px`:"0px",marginLeft:v.leftMargin?`${v.leftMargin}px`:"0px",marginRight:v.rightMargin?`${v.rightMargin}px`:"0px",boxSizing:"border-box",overflowX:b?"auto":"hidden",overflowY:"hidden",scrollSnapType:b?"x mandatory":void 0,msOverflowStyle:"none",scrollbarWidth:"none"},l=B=>({flex:b?"0 0 calc(50% - 6px)":"0 0 100%",height:b&&m.height?`${m.height}px`:"auto",cursor:"pointer",position:"relative",overflow:"hidden",borderRadius:v.borderRadius?`${v.borderRadius}px`:"0px",borderTopLeftRadius:v.topLeftRadius?`${v.topLeftRadius}px`:void 0,borderTopRightRadius:v.topRightRadius?`${v.topRightRadius}px`:void 0,borderBottomLeftRadius:v.bottomLeftRadius?`${v.bottomLeftRadius}px`:void 0,borderBottomRightRadius:v.bottomRightRadius?`${v.bottomRightRadius}px`:void 0,boxShadow:"0 4px 12px rgba(0,0,0,0.08)",scrollSnapAlign:"start"}),p=ss("div",{style:{width:"100%",position:"relative"},children:[Ot("style",{children:`
119
+ `}),ft("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:[j("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"}),j("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:Y})=>ft("div",{style:{display:"flex",alignItems:"center",gap:"14px",justifyContent:"flex-start"},children:[j("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}),j("span",{style:{fontSize:"13px",color:"#E5E7EB",fontWeight:"500",textAlign:"left"},children:Y})]},F))})]})]})]}),j(Ft,{config:{enabled:qn?.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:d,style:{position:"relative",borderRadius:"12px"}})]})]})]}),j("div",{style:{flex:1,width:"100%",display:"flex",flexDirection:"column",justifyContent:_?"flex-start":"center",alignItems:"center",paddingTop:_?"14px":"0px",...Wn()},children:ft("div",{style:{display:_?"grid":"flex",gridTemplateColumns:_?`minmax(0, 1fr) ${Yt}px minmax(0, 1fr)`:"none",alignItems:"center",justifyContent:"center",gap:"12px",width:"100%",maxWidth:"1400px",position:"relative"},onClick:F=>_&&F.stopPropagation(),children:[_&&j("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(c>0||e>0)&&j("button",{onClick:_o,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:j("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:j("polyline",{points:"15 18 9 12 15 6"})})})}),_?j("div",{style:{width:`${Yt}px`,height:`${he}px`,position:"relative",zIndex:5,overflow:"visible"},children:Array.from(be).sort((F,Y)=>F-Y).map(F=>{let Y=k.slides[F];if(!Y)return null;let at=Un(F),Bt=$s(at,Yt),vt=Y?.styling,Pt=vt?.editorSource||vt?.meta?.editorSource,Lt=Pt==="studio"||Pt==="editor",Nt=vt?.background?.media?.mediaUrl||Y?.image,jt=Y?.video||(Lt?Y?.content?.video?.[0]?.link:void 0),Xt=ut(vt?.background)||"#000000",Et=Lt?Y?.content?.button_text:Y?.button_text,Jt=Lt?Y?.content?.link:Y?.link,Kt=vt?.background?.media?.sizing,zt=Kt==="fill"?"cover":Kt==="fit"?"contain":Kt==="stretch"?"fill":Lt?"contain":"cover",xe=F===c&&!H||H&&F===s,Je={display:"flex",justifyContent:"center",alignItems:"center",background:Lt?Xt:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"16px"};return ft("div",{style:{...Yn,position:"absolute",top:0,left:0,width:`${Yt}px`,height:`${he}px`,...Bt,transition:at==="hidden"||at==="far-left"||at==="far-right"?`opacity ${qt}ms ease, transform ${qt}ms ease`:F===a?`transform ${qt}ms ${hn}, opacity ${qt}ms ${hn}, filter ${qt}ms ${hn}`:`transform ${qt}ms ${bn}, opacity ${qt}ms ${bn}, filter ${qt}ms ${bn}`,transformOrigin:"center center",willChange:"transform, opacity, filter"},onClick:Mt=>Mt.stopPropagation(),children:[j("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:Qt,onMouseUp:()=>Gt("prev"),onTouchStart:Qt,onTouchEnd:()=>Gt("prev")}),j("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:Qt,onMouseUp:()=>Gt("next"),onTouchStart:Qt,onTouchEnd:()=>Gt("next")}),ft("div",{style:Je,children:[jt?j(or,{src:jt,isActive:xe,isAnimating:H,isMuted:f,onLoadedData:On,activeVideoRef:it,objectFit:zt}):(Nt||!Lt&&k?.thumbnail)&&j(Wt,{src:Nt||k?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:zt}}),j(fn,{content:{...Y.content,styling:{...Y.content?.styling,...Y?.styling},interactions:Y.interactions},elapsedTime:xe?b/100*(k.styling?.slideShowTime||5):0,onInteraction:async Mt=>{xe&&jn(Mt,Y)}})]}),(Et||Jt)&&j(yn,{cta:Y?.styling?.cta,buttonText:Et||"Learn More",onPress:Mt=>{Mt&&Mt.stopPropagation&&Mt.stopPropagation(),Nn(Y)}})]},Y.id||F)})}):j("div",{style:{width:`${Yt}px`,maxWidth:"100vw",height:`${he}px`,maxHeight:"92vh",aspectRatio:`${st}`,overflow:"hidden",position:"relative",zIndex:5,display:"flex",flexDirection:"column"},children:k.slides.map((F,Y)=>{if(Math.abs(Y-c)>1)return j("div",{style:{display:"none"}},F.id||Y);let at=F?.styling,Bt=at?.editorSource||at?.meta?.editorSource,vt=Bt==="studio"||Bt==="editor",Pt=at?.background?.media?.mediaUrl||F?.image,Lt=F?.video||(vt?F?.content?.video?.[0]?.link:void 0),Nt=ut(at?.background)||"#000000",jt=vt?F?.content?.button_text:F?.button_text,Xt=vt?F?.content?.link:F?.link,Et=at?.background?.media?.sizing,Jt=Et==="fill"?"cover":Et==="fit"?"contain":Et==="stretch"?"fill":vt?"contain":"cover",Kt=Y===c;return Kt?j("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:ft("div",{style:{...Yn},onClick:zt=>zt.stopPropagation(),children:[j("div",{style:{position:"absolute",top:0,left:0,right:0,display:"flex",gap:"4px",padding:"10px",zIndex:10},children:k.slides.map((zt,ae)=>{let Xe=ae<c?"100%":ae===c?`${b}%`:"0%";return j("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.3)",borderRadius:"2px",overflow:"hidden"},children:j("div",{style:{width:Xe,height:"100%",backgroundColor:"white",transition:ae===c?"width 0.1s linear":"none"}})},ae)})}),ft("div",{style:{position:"absolute",top:"20px",left:"10px",right:"10px",display:"flex",alignItems:"center",justifyContent:"space-between",zIndex:10,padding:"5px"},children:[ft("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[j(Wt,{src:k.thumbnail,alt:k.name,style:{width:"32px",height:"32px",borderRadius:"50%"}}),j("span",{style:{color:"white",fontWeight:"bold",fontSize:"14px",textShadow:"0 1px 3px rgba(0,0,0,0.8)"},children:k.name})]}),ft("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[j(pe,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:Hn,type:f?"mute":"unmute",enabled:!!Vn?.enabled&&!!Lt,style:{position:"relative",borderRadius:"10px"}}),j(Ft,{config:{enabled:qn?.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:d,style:{position:"relative",borderRadius:"10px"}})]})]}),j("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:Qt,onMouseUp:()=>Gt("prev"),onTouchStart:Qt,onTouchEnd:()=>Gt("prev")}),j("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:Qt,onMouseUp:()=>Gt("next"),onTouchStart:Qt,onTouchEnd:()=>Gt("next")}),ft("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",background:vt?Nt:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"0px"},children:[Lt?j(or,{src:Lt,isActive:Kt,isAnimating:H,isMuted:f,onLoadedData:On,activeVideoRef:it,objectFit:Jt}):(Pt||k?.thumbnail)&&j(Wt,{src:Pt||k?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:Jt}}),j(fn,{content:{...F.content,styling:{...F.content?.styling,...F?.styling},interactions:F.interactions},elapsedTime:b/100*(k.styling?.slideShowTime||5),onInteraction:async zt=>{jn(zt,F)}})]}),(jt||Xt)&&j(yn,{cta:F?.styling?.cta,buttonText:jt||"Learn More",onPress:zt=>{zt&&zt.stopPropagation&&zt.stopPropagation(),Nn(F)}})]})},F.id||Y):null})}),_&&j("div",{style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:j("button",{onClick:Ae,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:j("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:j("polyline",{points:"9 18 15 12 9 6"})})})})]})}),_&&e>0&&ft("div",{style:{position:"absolute",bottom:"36px",left:"24px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"6px",zIndex:20},children:[j("span",{style:{fontSize:"11px",fontWeight:"600",color:"rgba(255,255,255,0.65)",letterSpacing:"0.6px",textTransform:"uppercase",paddingLeft:"2px"},children:"Previous Stories"}),ft("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:()=>Ge("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:[j("span",{style:{color:"white",fontSize:"14px",display:"flex"},children:"\u2190"}),j("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:j(Wt,{src:t[e-1].thumbnail,style:{width:"100%",height:"100%",borderRadius:"50%"}})}),j("span",{style:{fontSize:"13px",color:"white",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e-1].name})]})]}),_&&e<t.length-1&&ft("div",{style:{position:"absolute",bottom:"36px",right:"24px",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"6px",zIndex:20},children:[j("span",{style:{fontSize:"11px",fontWeight:"600",color:"rgba(255,255,255,0.65)",letterSpacing:"0.6px",textTransform:"uppercase",paddingRight:"2px"},children:"Next Stories"}),ft("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:()=>Ge("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:[j("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:j(Wt,{src:t[e+1].thumbnail,style:{width:"100%",height:"100%",borderRadius:"50%"}})}),j("span",{style:{fontSize:"13px",color:"white",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e+1].name}),j("span",{style:{color:"white",fontSize:"14px",display:"flex"},children:"\u2192"})]})]}),z&&j("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:z})]})};import{jsx as sr,jsxs as Hs}from"react/jsx-runtime";var js=()=>{let t=xt("STR"),e=A(y=>y.isVisible),[o,i]=ir(null),[n,r]=ir([]);if(rr(()=>{try{let y=localStorage.getItem("app_storys_viewed_stories");y&&r(JSON.parse(y))}catch(y){console.error("Failed to load viewed stories:",y)}},[]),rr(()=>{t&&t.details&&G("story_module_viewed",t.id)},[t]),!t||!t.details||t.details.length===0||!e)return null;let l=y=>{i(y)},d=()=>{o!==null&&(o<t.details.length-1?i(o+1):i(null))},c=()=>{o!==null&&o>0&&i(o-1)};return Hs("div",{className:"story-group-container",style:{width:"100vw",position:"relative",left:"50%",right:"50%",marginLeft:"-50vw",marginRight:"-50vw",boxSizing:"border-box"},children:[sr(wi,{stories:t.details,viewedStories:n,onStoryClick:l}),o!==null&&sr(nr,{stories:t.details,activeStoryIndex:o,dataId:t.id,viewedStories:n,setViewedStories:r,onNextStory:d,onPrevStory:c,onClose:()=>i(null)})]})};import{useState as Vs,useRef as Ro,useEffect as wn,useCallback as Us}from"react";import{createPortal as Ys}from"react-dom";ot();import{useEffect as ar,useRef as wo}from"react";function He(t,e=.5){let o=wo(t),i=wo(!1),n=wo(null),r=wo(null);ar(()=>{o.current=t},[t]);let l=d=>{if(r.current&&(r.current.disconnect(),r.current=null),n.current=d,i.current=!1,!d)return;if(typeof IntersectionObserver>"u"){o.current();return}let c=null;r.current=new IntersectionObserver(y=>{y[0].isIntersecting&&!i.current?c||(c=setTimeout(()=>{i.current=!0,o.current(),r.current?.disconnect(),c=null},500)):c&&(clearTimeout(c),c=null)},{threshold:e}),r.current.observe(d)};return ar(()=>()=>{r.current?.disconnect()},[]),l}var lr=new Set;function qs(){try{return globalThis?.process?.env?.NODE_ENV!=="production"}catch{return!0}}function dr(t,e,o){if(!qs()||o<=1)return;let i=`${e}::${t}`;lr.has(i)||(lr.add(i),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 ko(t){if(!t)return null;let e=[`[data-as-id="${t}"]`,`[data-id="${t}"]`,`[data-widget="${t}"]`];for(let i of e)try{let n=document.querySelectorAll(i);if(n.length>0)return dr(t,i,n.length),n[0]}catch{}let o=document.getElementById(t);if(o)return o;try{let i=`.${CSS&&CSS.escape?CSS.escape(t):t}`,n=document.querySelectorAll(i);if(n.length>0)return dr(t,i,n.length),n[0]}catch{}return null}import{jsx as ie,jsxs as Gs}from"react/jsx-runtime";var Qs=({position:t})=>{let e=xt("WID",{position:t}),o=A(B=>B.campaigns),i=A(B=>B.allCampaigns),n=A(B=>B.currentScreen),r=B=>(B||"").trim().toLowerCase(),l=e??(()=>{let B=r(n),a=[...o||[],...i||[]].find(x=>{let s=x;if(s.campaign_type!=="WID"||t&&s.position!==t)return!1;let p=!!(s.trigger_event??s.trigger),M=s.display_trigger!==!1&&!p,T=!r(s.screen)||r(s.screen)===B;return M&&T});if(a)try{return Rt(a)}catch{return a}})(),[d,c]=Vs(0),y=Ro(null),b=Ro(null),h=l?.details||{},f=h.widget_images||[],v=h.styling||{},S=h.type||"full",u=S==="half",m=Ro([]),g=Ro(!1),C=Us(()=>{g.current=!0;let B=f[d];B?.id&&z(B.id)},[f,d]),I=He(C),z=B=>{!l?.id||!B||g.current&&(m.current.includes(B)||(m.current.push(B),G("viewed",l.id,{widget_image:B})))};wn(()=>{if(S==="full"&&f.length>1)return b.current=setInterval(()=>{c(B=>{let a=B+1;return a>=f.length?0:a})},5e3),()=>{b.current&&clearInterval(b.current)}},[S,f.length]);let E=(B,a)=>{if(l?.id&&G("clicked",l.id,{widget_image:B}),a){if(!a.startsWith("http")){try{if(wt(a))return}catch(x){console.warn("[Widget] revealCampaignFromLink error",x)}console.log("[Widget] Internal link:",a);return}window.open(a,"_blank")}},w=()=>{if(y.current&&u){let{scrollLeft:B,offsetWidth:a}=y.current,x=a/2+12,s=Math.round(B/x);c(s)}};wn(()=>{if(!l?.id||S!=="full"||f.length===0)return;let B=f[d];B&&B.id&&z(B.id)},[d,l?.id,f,S]),wn(()=>{if(!l?.id||!y.current||!u)return;let B=y.current,a=()=>{let{scrollLeft:x,offsetWidth:s}=B,p=s/2+12;f.forEach((M,T)=>{let R=T*p,$=R+p,N=x,V=x+s;Math.max(0,Math.min($,V)-Math.max(R,N))/p>=.5&&z(M.id)})};return a(),B.addEventListener("scroll",a),()=>B.removeEventListener("scroll",a)},[l?.id,u,f]);let D={display:"flex",flexDirection:"row",flexWrap:u?"nowrap":"wrap",gap:"12px",width:"100%",height:u&&h.height?`${h.height}px`:"auto",marginTop:v.topMargin?`${v.topMargin}px`:"0px",marginBottom:v.bottomMargin?`${v.bottomMargin}px`:"0px",marginLeft:v.leftMargin?`${v.leftMargin}px`:"0px",marginRight:v.rightMargin?`${v.rightMargin}px`:"0px",boxSizing:"border-box",overflowX:u?"auto":"hidden",overflowY:"hidden",scrollSnapType:u?"x mandatory":void 0,msOverflowStyle:"none",scrollbarWidth:"none"},_=B=>({flex:u?"0 0 calc(50% - 6px)":"0 0 100%",height:u&&h.height?`${h.height}px`:"auto",cursor:"pointer",position:"relative",overflow:"hidden",borderRadius:v.borderRadius?`${v.borderRadius}px`:"0px",borderTopLeftRadius:v.topLeftRadius?`${v.topLeftRadius}px`:void 0,borderTopRightRadius:v.topRightRadius?`${v.topRightRadius}px`:void 0,borderBottomLeftRadius:v.bottomLeftRadius?`${v.bottomLeftRadius}px`:void 0,borderBottomRightRadius:v.bottomRightRadius?`${v.bottomRightRadius}px`:void 0,boxShadow:"0 4px 12px rgba(0,0,0,0.08)",scrollSnapAlign:"start"}),P=Gs("div",{style:{width:"100%",position:"relative"},children:[ie("style",{children:`
78
120
  .widget-scroll-container::-webkit-scrollbar {
79
121
  display: none;
80
122
  }
81
- `}),Ot("div",{ref:B=>{u.current=B,I(B)},className:"widget-scroll-container",style:T,onScroll:d,children:b?g.map((B,L)=>Ot("div",{style:l(L),children:Ot("img",{src:B.image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"},onClick:()=>R(B.id,B.link)})},B.id)):g.length>0&&Ot("div",{style:l(0),children:Ot("img",{src:g[a].image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"},onClick:()=>R(g[a].id,g[a].link)})},`slide-${a}`)}),f==="full"&&g.length>1&&Ot("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"8px",width:"100%"},children:g.map((B,L)=>Ot("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:L===a?"#333":"#ccc",transition:"background-color 0.2s ease"}},L))})]}),M=null;if(s?.position){let B=String(s.position||"").replace(/^widget_/,""),L=[`[data-as-id="${B}"]`,`#${B}`,`.${B}`,`[data-widget="${B}"]`];for(let C of L)try{let S=document.querySelector(C);if(S){M=S,console.log("[Widget] Portal target found:",C,"for campaign",s?.id);break}}catch{}M||console.log("[Widget] No portal target found for position:",s?.position,"rendering inline for campaign:",s?.id)}return M?is(p,M):p};import{useEffect as Ri,useLayoutEffect as as,useMemo as Ti,useRef as Go,useState as Ge,useCallback as ls}from"react";K();import{Fragment as ps,jsx as ne,jsxs as Fi}from"react/jsx-runtime";var Jo=t=>(t||"").trim().toLowerCase(),ds=()=>{let t=pt("TTP"),e=F(V=>V.campaigns),o=F(V=>V.allCampaigns),i=F(V=>V.currentScreen),n=F(V=>V.isVisible),[r,s]=Ge(0),[a,c]=Ge(!1),[u,x]=Ge(null),[m,g]=Ge({width:0,height:0}),v=Go(null),f=Go(null),b=Ti(()=>{if(t)return t;let V=Jo(i),et=q=>q.find(Q=>{let Y=Q,lt=Y.campaign_type==="TTP"||Y.campaign_type==="TLTP",mt=!Jo(Y.screen)||Jo(Y.screen)===V,nt=!!(Y.trigger_event??Y.trigger),Ct=Y.display_trigger!==!1&&!nt;return lt&&mt&&Ct});return et(e)??et(o)},[t,e,o,i]),h=Ti(()=>b?.details?.tooltips&&Array.isArray(b.details.tooltips)?[...b.details.tooltips].sort((V,et)=>(V.order??0)-(et.order??0)):b?.details?.target||b?.details?.titleText?[{...b.details,_id:b.id}]:[],[b]),y=h[r];Ri(()=>{},[b]);let w=Go(new Set),I=ls(()=>{if(!(!b||!y||a||!n))try{let V=y._id||y.id||void 0,et=String(b.id||"")+"::"+String(V||"");w.current.has(et)||(w.current.add(et),H("viewed",b.id,{tooltip_id:V}))}catch{}},[b,y,a,n]),z=xe(I);if(Ri(()=>{if(!y?.target||a)return;x(null);let V=(Q=!1)=>{let Y=y.target;if(!Y)return null;let lt=document.getElementById(Y)||document.querySelector(`[data-id="${Y}"]`)||document.querySelector(`.${Y}`);return lt?(x(lt.getBoundingClientRect()),Q&&lt.scrollIntoView({behavior:"smooth",block:"center"}),lt):null};V(!0)||(f.current=new MutationObserver(()=>{V(!0)&&f.current?.disconnect()}),f.current.observe(document.body,{childList:!0,subtree:!0}));let q=()=>{let Q=V(!1);Q&&x(Q.getBoundingClientRect())};return window.addEventListener("resize",q),window.addEventListener("scroll",q,{passive:!0}),()=>{f.current?.disconnect(),window.removeEventListener("resize",q),window.removeEventListener("scroll",q)}},[y,a,r]),as(()=>{if(v.current&&u){let{width:V,height:et}=v.current.getBoundingClientRect();g({width:V,height:et})}},[y,u]),!b||!y||a||!n||!u)return null;let R=y.styling||{},d=R.appearance||{},T=d.colors||{},l=R.cta||{},p=l.container||{},M=l.cornerRadius||{},B=l.text||{},L=y.arrowPosition||"left",S=(d.arrowStyle||{width:6,height:12}).width||6,_=u.top+window.scrollY,E=u.left+window.scrollX,$=0,D=0,k=8;L==="left"?($=E+u.width+k,D=_+u.height/2-m.height/2):L==="right"?($=E-m.width-k,D=_+u.height/2-m.height/2):L==="top"?(D=_+u.height+k,$=E+u.width/2-m.width/2):L==="bottom"&&(D=_-m.height-k,$=E+u.width/2-m.width/2);let P=8,O=window.scrollY,G=window.scrollY+window.innerHeight,ut=window.scrollX,j=window.scrollX+window.innerWidth;m.height>0&&(D=Math.max(O+P,Math.min(G-m.height-P,D))),m.width>0&&($=Math.max(ut+P,Math.min(j-m.width-P,$)));let X=()=>{let V=y.clickAction||"nextStep",et=y.link||y.url;try{let q=y._id||y.id||void 0;b?.id&&H("clicked",b.id,{tooltip_id:q})}catch{}if(V==="close"){c(!0),et&&window.open(et,"_blank");return}r<h.length-1?s(q=>q+1):(c(!0),et&&window.open(et,"_blank"))},J=()=>{y.enableBackdrop&&c(!0)};return Fi(ps,{children:[y.enableBackdrop&&ne("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:T.backdrop||"rgba(0, 0, 0, 0.7)",opacity:d.backdropOpacity?d.backdropOpacity/100:.7,zIndex:1e4},onClick:J}),Fi("div",{ref:V=>{v.current=V,z(V)},style:{position:"absolute",top:D,left:$,zIndex:10001,backgroundColor:T.tooltip||"#FE6B35",padding:`${d.padding?.top??8}px ${d.padding?.right??8}px ${d.padding?.bottom??8}px ${d.padding?.left??8}px`,borderRadius:`${d.cornerRadius?.topLeft??12}px ${d.cornerRadius?.topRight??12}px ${d.cornerRadius?.bottomRight??12}px ${d.cornerRadius?.bottomLeft??12}px`,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",maxWidth:300,minWidth:200,transition:"top 0.2s ease, left 0.2s ease"},children:[ne("div",{style:{position:"absolute",width:0,height:0,borderStyle:"solid",...L==="left"&&{left:-k,top:Math.max(12,Math.min(m.height-S*2-12,_+u.height/2-D-S)),borderWidth:`${S}px ${k}px ${S}px 0`,borderColor:`transparent ${T.tooltip||"#FE6B35"} transparent transparent`},...L==="right"&&{right:-k,top:Math.max(12,Math.min(m.height-S*2-12,_+u.height/2-D-S)),borderWidth:`${S}px 0 ${S}px ${k}px`,borderColor:`transparent transparent transparent ${T.tooltip||"#FE6B35"}`},...L==="top"&&{top:-k,left:Math.max(12,Math.min(m.width-S*2-12,E+u.width/2-$-S)),borderWidth:`0 ${S}px ${k}px ${S}px`,borderColor:`transparent transparent ${T.tooltip||"#FE6B35"} transparent`},...L==="bottom"&&{bottom:-k,left:Math.max(12,Math.min(m.width-S*2-12,E+u.width/2-$-S)),borderWidth:`${k}px ${S}px 0 ${S}px`,borderColor:`${T.tooltip||"#FE6B35"} transparent transparent transparent`}}}),y.titleText&&ne("div",{style:{color:R.title?.color||"#ffffff",fontFamily:ct(R.title?.fontFamily)||"Arial",fontSize:R.title?.fontSize||14,textAlign:R.title?.textAlign||"center",marginBottom:R.title?.margin?.bottom??4,marginTop:R.title?.margin?.top??0,marginLeft:R.title?.margin?.left??0,marginRight:R.title?.margin?.right??0,fontWeight:R.title?.fontDecoration?.includes("bold")?"bold":600,fontStyle:R.title?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:R.title?.fontDecoration?.includes("underline")?"underline":"none"},children:y.titleText}),y.subtitleText&&ne("div",{style:{color:R.subTitle?.color||"#ffffff",fontFamily:ct(R.subTitle?.fontFamily)||"Arial",fontSize:R.subTitle?.fontSize||12,textAlign:R.subTitle?.textAlign||"center",marginBottom:R.subTitle?.margin?.bottom??8,marginTop:R.subTitle?.margin?.top??0,marginLeft:R.subTitle?.margin?.left??0,marginRight:R.subTitle?.margin?.right??0,fontWeight:R.subTitle?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:R.subTitle?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:R.subTitle?.fontDecoration?.includes("underline")?"underline":"none"},children:y.subtitleText}),y.ctaText&&ne("div",{style:{display:"flex",justifyContent:p.alignment==="right"?"flex-end":p.alignment==="left"?"flex-start":"center",marginTop:8},children:ne("button",{onClick:X,style:{width:p.ctaFullWidth?"100%":p.ctaWidth||"auto",height:p.height||35,background:p.backgroundColor||"#F7921C",color:B.color||"#ffffff",border:`${p.borderWidth||0}px solid ${p.borderColor||"transparent"}`,borderRadius:`${M.topLeft??7}px ${M.topRight??7}px ${M.bottomRight??7}px ${M.bottomLeft??7}px`,fontSize:B.fontSize||14,fontFamily:ct(B.fontFamily)||"Arial",fontWeight:B.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:B.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:B.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:y.ctaText})})]})]})},cs=ds;import{useEffect as us,useState as gs}from"react";K();import{Fragment as ms,jsx as Bt,jsxs as Xo}from"react/jsx-runtime";var fs=()=>{let t=pt("BTS"),e=F(f=>f.campaigns),o=F(f=>f.allCampaigns),i=F(f=>f.currentScreen),n=t??(()=>{let f=(i||"").trim().toLowerCase(),b=[...e||[],...o||[]].find(h=>{if(!h||h.campaign_type!=="BTS")return!1;let y=!!(h.trigger_event??h.trigger);if(!(h.display_trigger!==!1&&!y))return!1;let I=(h.screen||"").trim().toLowerCase();return!I||I===f});if(b)try{return yt(b)}catch{return b}})(),r=F(f=>f.isVisible),[s,a]=gs(!1);us(()=>{n&&(a(!1),H("viewed",n.id))},[n]);let c=f=>{try{let b=F.getState(),y=(b.trackedEvents||[]).filter(w=>w!==f);b.setTrackedEvents(y)}catch{}};if(!n||s||!r)return null;let{details:u}=n,m=[...u.elements||[]].sort((f,b)=>(f.order||0)-(b.order||0)),g=u.backdropOpacity??.5;g>1&&(g=g/100);let v=f=>{switch(f.type){case"image":{let b={width:"100%",display:"block",objectFit:"contain",backgroundColor:f.imageBackgroundColor||"transparent",paddingBottom:f.paddingBottom??0,paddingLeft:f.paddingLeft??0,paddingRight:f.paddingRight??0,paddingTop:f.paddingTop??0,cursor:f.imageLink?"pointer":"default"};return Bt("div",{style:{textAlign:f.alignment||"left",width:"100%"},children:f.url&&Bt("img",{src:f.url,alt:"",style:b,onClick:()=>{if(f.imageLink){n?.id&&H("clicked",n.id);try{let h=String(f.imageLink||"").trim();if(h&&!h.startsWith("http")&&ht(h))return}catch(h){console.warn("revealCampaignFromLink error",h)}try{window.open(f.imageLink,"_blank")}catch{}}}})},f.id)}case"cta":{let b=f.cta||{},h=b.container||{},y=b.cornerRadius||{},w=b.margin||{},I=b.text||{};return Bt("div",{style:{display:"flex",justifyContent:h.alignment==="center"?"center":h.alignment==="right"?"flex-end":"flex-start",width:"100%",marginTop:w.top??0,marginBottom:w.bottom??0,marginLeft:w.left??0,marginRight:w.right??0},children:Bt("button",{style:{width:h.ctaFullWidth?"100%":h.ctaWidth||"auto",height:h.height||45,backgroundColor:h.ctaBoxColor||h.backgroundColor||"#FE6B35",color:I.color||"#ffffff",border:`${h.borderWidth||0}px solid ${h.borderColor||"transparent"}`,borderRadius:`${y.topLeft??12}px ${y.topRight??12}px ${y.bottomRight??12}px ${y.bottomLeft??12}px`,fontSize:I.fontSize||14,fontFamily:ct(I.fontFamily)||"Arial",fontWeight:I.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:I.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:I.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px"},onClick:()=>{let z=f.ctaLink||f.url;if(z){n?.id&&H("clicked",n.id);try{let R=String(z||"").trim();if(R&&!R.startsWith("http")&&ht(R))return}catch(R){console.warn("revealCampaignFromLink error",R)}try{window.open(z,"_blank")}catch{}}},children:f.ctaText||"Button"})},f.id)}case"body":{let b=f.titleFontStyle||{},h=f.descriptionFontStyle||{};return Xo("div",{style:{width:"100%",backgroundColor:f.bodyBackgroundColor||"transparent",marginTop:f.marginTop??0,marginBottom:f.marginBottom??20,marginLeft:f.marginLeft??4,marginRight:f.marginRight??4},children:[f.titleText&&Bt("div",{style:{color:b.colour||"#000000",fontSize:b.fontSize?`${b.fontSize}px`:f.titleFontSize?`${f.titleFontSize}px`:"16px",fontFamily:ct(b.fontFamily)||"inherit",textAlign:b.alignment||"left",lineHeight:f.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:f.spacingBetweenTitleDesc??4},children:f.titleText}),f.descriptionText&&Bt("div",{style:{color:h.colour||"#000000",fontSize:h.fontSize?`${h.fontSize}px`:f.descriptionFontSize?`${f.descriptionFontSize}px`:"14px",fontFamily:ct(h.fontFamily)||"inherit",textAlign:h.alignment||"left",lineHeight:f.descriptionLineHeight||1.5,fontWeight:h.decoration?.includes("bold")?"bold":"normal",fontStyle:h.decoration?.includes("italic")?"italic":"normal",textDecoration:h.decoration?.includes("underline")?"underline":"none"},children:f.descriptionText})]},f.id)}default:return null}};return Xo(ms,{children:[Bt("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:u.backdropColor||"rgba(0,0,0,0.5)",opacity:g,zIndex:999998,transition:"opacity 0.3s ease"},onClick:()=>{n?.id&&c(`viaAppStorys${n.id}`),a(!0)}}),Xo("div",{style:{position:"fixed",bottom:0,left:"50%",transform:"translateX(-50%)",width:"100%",maxWidth:"500px",backgroundColor:u.backgroundColor||"#FFFFFF",borderTopLeftRadius:`${u.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${u.cornerRadius?.topRight??16}px`,borderBottomLeftRadius:`${u.cornerRadius?.bottomLeft??0}px`,borderBottomRightRadius:`${u.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:[Bt("div",{style:{width:"40px",height:"5px",backgroundColor:"#E0E0E0",borderRadius:"2.5px",marginBottom:"16px",cursor:"pointer"},onClick:()=>a(!0)}),u.crossButton?.enabled&&Bt(Lt,{config:u.crossButton,onPress:()=>{n?.id&&c(`viaAppStorys${n.id}`),a(!0)},style:{top:u.crossButton?.margin?.top??12,right:u.crossButton?.margin?.right??12}}),Bt("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:"12px"},children:m.map(v)})]})]})};import{useEffect as ys,useMemo as hs,useState as ie}from"react";K();import{Fragment as en,jsx as Z,jsxs as Ce}from"react/jsx-runtime";var Ii=5,Ko=3;function At(t){if(t!=null)return`${t}px`}function Se(t){return{marginTop:At(t?.top),marginRight:At(t?.right),marginBottom:At(t?.bottom),marginLeft:At(t?.left)}}function on(t){return ct(t)}function re(t){return t?{color:t.color,fontSize:t.fontSize,fontFamily:on(t.fontFamily),textAlign:t.textAlign,fontWeight:t.fontDecoration?.includes("bold")?"bold":void 0,fontStyle:t.fontDecoration?.includes("italic")?"italic":void 0,textDecoration:t.fontDecoration?.includes("underline")?"underline":void 0}:{}}function Zo(t){return`${t?.topLeft??8}px ${t?.topRight??8}px ${t?.bottomRight??8}px ${t?.bottomLeft??8}px`}function bs(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function xs(t){let e=t.styling?.rating?.ratingType;return e==="number"||e==="emoji"||e==="star"?e:"star"}function Ss(t){let e=t.styling?.rating?.emoji;if(Array.isArray(e))return e.filter(o=>typeof o=="string"&&o.trim().length>0);if(e&&typeof e=="object"){let o=Object.values(e).filter(i=>typeof i=="string"&&i.trim().length>0);if(o.length>0)return o}if(typeof e=="string"&&e.trim()){if(e.includes(",")){let o=e.split(",").map(i=>i.trim()).filter(Boolean);if(o.length>0)return o}return[e]}return["\u{1F620}","\u{1F615}","\u{1F610}","\u{1F642}","\u{1F60D}"]}function Cs(t){return Array.from({length:5},(e,o)=>o+1)}function tn(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 vs(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];for(let n of o){let r=tn(n);if(r!=null)return r}let i=e?.number;if(i&&typeof i=="object"){let n=i,r=[n.spacing,n.gap,n.optionsSpacing,n.numberSpacing,n.numberGap];for(let s of r){let a=tn(s);if(a!=null)return a}}return 8}var ws=({fill:t,stroke:e})=>Z("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":!0,children:Z("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"})}),ks=({details:t,appearance:e,rating:o,selectedOptions:i,comments:n,isHighRating:r,feedbackOptions:s,onRate:a,onToggleOption:c,onCommentChange:u,onInlineSubmit:x,canSubmit:m})=>{let g=t.styling||{},v=g.feedbackPage||{},f=g.rating||{},b=g.initialFeedback||{},h=v.submitButton?.cta,y=xs(t),w=y==="number"?Cs(t):[],I=y==="emoji"?Ss(t):[],z=y==="number"?vs(t):8,R=r?f.star?.high:f.star?.low;return Ce(en,{children:[Z("div",{style:Se(b.title?.margin),children:Z("div",{style:{...re(b.title?.textStyle),color:b.title?.textStyle?.color||"#101828",fontSize:b.title?.textStyle?.fontSize||20,lineHeight:1.3},children:t.title||"How was your experience?"})}),Z("div",{style:Se(b.subtitle?.margin),children:Z("div",{style:{...re(b.subtitle?.textStyle),color:b.subtitle?.textStyle?.color||"#4b5563",fontSize:b.subtitle?.textStyle?.fontSize||14,lineHeight:1.4},children:t.description_text||"Your feedback helps us improve your experience."})}),Ce("div",{style:{marginTop:8,display:"flex",justifyContent:"center",gap:y==="number"?z:8,flexWrap:"wrap"},children:[y==="star"&&Array.from({length:Ii},(d,T)=>{let l=T+1,p=l<=o,M=p?R?.stylingContainer:f.star?.unselected?.stylingContainer,B=p?R?.stylingStar:f.star?.unselected?.stylingStar;return Z("button",{onClick:()=>a(l),style:{border:`${M?.borderWidth??1}px solid ${M?.border||"#d1d5db"}`,background:M?.background||"#ffffff",borderRadius:10,width:44,height:44,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0},"aria-label":`Rate ${l} out of ${Ii}`,children:Z(ws,{fill:B?.background||(p?"#f59e0b":"#e5e7eb"),stroke:B?.border||(p?"#d97706":"#9ca3af")})},l)}),y==="number"&&w.map((d,T)=>{let l=d===o;return Z("button",{onClick:()=>a(d),style:{border:`1px solid ${l?"#1d4ed8":"#d1d5db"}`,background:l?"#dbeafe":"#ffffff",color:l?"#1d4ed8":"#111827",borderRadius:8,minWidth:36,height:36,padding:"0 10px",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontWeight:600},"aria-label":`Rate ${d}`,children:d},`${d}-${T}`)}),y==="emoji"&&I.map((d,T)=>{let l=T+1,p=l===o;return Z("button",{onClick:()=>a(l),style:{border:`1px solid ${p?"#1d4ed8":"#d1d5db"}`,background:p?"#dbeafe":"#ffffff",borderRadius:"999px",width:44,height:44,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:22},"aria-label":`Emoji rating ${T+1}`,children:d},`${d}-${T}`)})]}),o>0&&Z("div",{style:{marginTop:6,textAlign:"center",color:"#374151",fontSize:14},children:r?t.highStarText||f.highRatingSubtitle:t.lowStarText||f.lowRatingSubtitle}),o>0&&o<=Ko&&Ce(en,{children:[s.length>0&&Z("div",{style:{...Se(v.options?.margin),display:"flex",flexDirection:"column",alignItems:"stretch",gap:v.options?.optionsSpacing??8,width:"100%"},children:s.map(d=>{let l=i.includes(d)?v.options?.selectedOptions:v.options?.nonSelectedOptions;return Z("button",{onClick:()=>c(d),style:{border:`${l?.borderWidth??1}px solid ${l?.colors?.border||"#d1d5db"}`,background:l?.colors?.background||"#f9fafb",color:l?.colors?.text||"#111827",width:"100%",height:v.options?.optionsHeight||38,borderRadius:Zo(v.options?.cornerRadius),padding:"0 14px",cursor:"pointer",textAlign:"center",...re(l?.textStyle)},children:d},d)})}),Z("textarea",{value:n,onChange:d=>u(d.target.value),placeholder:v.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:`${v.additionalComments?.borderWidth??1}px solid ${v.additionalComments?.colors?.border||"#d1d5db"}`,background:v.additionalComments?.colors?.background||"#ffffff",color:v.additionalComments?.colors?.text||"#111827",borderRadius:8,padding:"12px",...re(v.additionalComments?.textStyle)}}),Z("div",{style:{position:"sticky",bottom:0,marginTop:8,paddingTop:6,paddingBottom:6,background:e?.backgroundColor||"#2f6ef5",display:"flex",justifyContent:"center"},children:Z("button",{onClick:()=>x(),disabled:!m,style:{width:Math.max(140,Math.min(tn(h?.container?.ctaWidth)??180,220)),maxWidth:"100%",minHeight:30,height:Math.max(30,Math.min(Number(h?.container?.height)||34,34)),border:`${h?.container?.borderWidth??1}px solid ${h?.container?.borderColor||"#ff7a00"}`,background:h?.container?.backgroundColor||"#ff2bc2",color:h?.text?.color||"#ffffff",borderRadius:Zo(h?.cornerRadius),fontFamily:on(h?.text?.fontFamily),fontSize:Math.min(Number(h?.text?.fontSize)||14,14),fontWeight:h?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:m?"pointer":"not-allowed",opacity:m?1:.65,padding:"0 12px"},children:v.submitButton?.text||"Submit"})})]})]})},Rs=({details:t,isHighRating:e,onDone:o})=>{let i=t.styling||{},n=i.thankyouPage||{},r=i.rating||{},s=bs(n.doneButton?.cta?.container?.alignment);return Ce(en,{children:[t.thankyouImage&&Z("div",{style:{display:"flex",justifyContent:"center",marginTop:6},children:Z("img",{src:t.thankyouImage,alt:"thank you",style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80,objectFit:"cover",borderRadius:8}})}),Z("div",{style:{...Se(n.title?.margin),textAlign:"center"},children:Z("div",{style:{...re(n.title?.textStyle),color:n.title?.textStyle?.color||"#111827",fontSize:n.title?.textStyle?.fontSize||20,fontWeight:n.title?.textStyle?.fontDecoration?.includes("bold")?"bold":600},children:t.thankyouText||(e?r.highRatingTitle:r.lowRatingTitle)||"Thank you for your feedback"})}),Z("div",{style:{...Se(n.subtitle?.margin),textAlign:"center"},children:Z("div",{style:{...re(n.subtitle?.textStyle),color:n.subtitle?.textStyle?.color||"#4b5563",fontSize:n.subtitle?.textStyle?.fontSize||14},children:t.thankyouDescription||(e?r.highRatingSubtitle:r.lowRatingSubtitle)||"We appreciate your time."})}),Z("div",{style:{marginTop:n.doneButton?.cta?.margin?.top??14,marginBottom:n.doneButton?.cta?.margin?.bottom??0,marginLeft:n.doneButton?.cta?.margin?.left??0,marginRight:n.doneButton?.cta?.margin?.right??0,display:"flex",justifyContent:s},children:Z("button",{onClick:o,style:{width:n.doneButton?.cta?.container?.ctaFullWidth?"100%":n.doneButton?.cta?.container?.ctaWidth||"auto",height:n.doneButton?.cta?.container?.height||45,border:`${n.doneButton?.cta?.container?.borderWidth??0}px solid ${n.doneButton?.cta?.container?.borderColor||"transparent"}`,background:n.doneButton?.cta?.container?.backgroundColor||"#111827",color:n.doneButton?.cta?.text?.color||"#ffffff",borderRadius:Zo(n.doneButton?.cta?.cornerRadius),fontFamily:on(n.doneButton?.cta?.text?.fontFamily),fontSize:n.doneButton?.cta?.text?.fontSize||16,fontWeight:n.doneButton?.cta?.text?.fontDecoration?.includes("bold")?"bold":500,cursor:"pointer",padding:"0 16px"},children:n.doneButton?.text||(e?"Rate Now":"Done")})})]})},Ts=()=>{let t=pt("CSAT"),e=F(C=>C.isVisible),o=F(C=>C.campaigns),i=F(C=>C.allCampaigns),n=F(C=>C.currentScreen),r=t??(()=>{let C=(n||"").trim().toLowerCase(),S=[...o||[],...i||[]].find(_=>{if(!_||_.campaign_type!=="CSAT")return!1;let E=!!(_.trigger_event??_.trigger);if(!(_.display_trigger!==!1&&!E))return!1;let D=(_.screen||"").trim().toLowerCase();return!D||D===C});if(S)try{return yt(S)}catch{return S}})(),[s,a]=ie(!1),[c,u]=ie(!1),[x,m]=ie(0),[g,v]=ie([]),[f,b]=ie(""),[h,y]=ie(!1);ys(()=>{if(!r)return;a(!1),u(!1),m(0),v([]),b(""),y(!1);let C=r.details?.styling?.appearance?.displayDelay??0,S=globalThis.setTimeout(()=>{u(!0),H("viewed",r.id)},Math.max(0,C)*1e3);return()=>globalThis.clearTimeout(S)},[r]);let w=hs(()=>{let C=r?.details?.feedback_option||{};return Object.keys(C).sort((S,_)=>S.localeCompare(_)).map(S=>C[S]).filter(Boolean)},[r]);if(!r||!e||s||!c)return null;let I=r.details,z=I.styling||{},R=z.appearance||{},d=x>Ko,T=Number(I.width??80),l=Math.max(660,Math.min(1080,T*10)),p=C=>{v(S=>S.includes(C)?S.filter(_=>_!==C):[...S,C])},M=async C=>{let S=C?.rating??x;if(S<1)return;y(!0);let _=I.id||r.id,E=(C?.options??g)[0]||"",$=C?.comments??f??"";H("csat captured",_,{starCount:S,selectedOption:E,additionalComments:$})},B=C=>{if(m(C),C>Ko){v([]),b("");let S=I.id||r?.id;setTimeout(()=>{y(!0);try{H("csat captured",S,{starCount:C,selectedOption:"",additionalComments:""})}catch(_){console.warn("Error sending csat captured",_)}},1e3)}},L=()=>{if(d&&I.link){let C=r&&r.id||void 0;try{C&&H("clicked",C)}catch{}try{let S=String(I.link||"").trim();if(S&&!S.startsWith("http")&&ht(S)){a(!0);return}}catch(S){console.warn("revealCampaignFromLink error",S)}try{globalThis.open(I.link,"_blank")}catch{}}a(!0)};return Z("div",{style:{position:"fixed",left:0,right:0,bottom:0,zIndex:999999,display:"flex",justifyContent:"center",alignItems:"flex-end",paddingLeft:"10px",paddingRight:"10px",paddingBottom:"10px",pointerEvents:"none"},children:Ce("div",{style:{position:"relative",width:`min(${l}px, 96vw)`,maxWidth:"96vw",minWidth:"320px",minHeight:"220px",maxHeight:"55vh",overflow:"hidden",backgroundColor:R.backgroundColor||"#2f6ef5",borderRadius:`${R.borderRadius??12}px`,boxSizing:"border-box",paddingTop:"8px",paddingRight:At(R.padding?.right)||"12px",paddingBottom:"4px",paddingLeft:At(R.padding?.left)||"12px",marginTop:At(R.margin?.top),marginRight:At(R.margin?.right),marginBottom:At(R.margin?.bottom),marginLeft:At(R.margin?.left),pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"},children:[Z("style",{children:`
123
+ `}),ie("div",{ref:B=>{y.current=B,I(B)},className:"widget-scroll-container",style:D,onScroll:w,children:u?f.map((B,a)=>ie("div",{style:_(a),children:ie("img",{src:B.image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"},onClick:()=>E(B.id,B.link)})},B.id)):f.length>0&&ie("div",{style:_(0),children:ie("img",{src:f[d].image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"},onClick:()=>E(f[d].id,f[d].link)})},`slide-${d}`)}),S==="full"&&f.length>1&&ie("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"8px",width:"100%"},children:f.map((B,a)=>ie("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:a===d?"#333":"#ccc",transition:"background-color 0.2s ease"}},a))})]}),H=null;if(l?.position){let B=String(l.position||"").replace(/^widget_/,"");H=ko(B),H?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 H?Ys(P,H):P};import{useEffect as cr,useLayoutEffect as Xs,useMemo as ur,useRef as To,useState as Fo,useCallback as Js}from"react";ot();import{Fragment as ta,jsx as Vt,jsxs as Rn}from"react/jsx-runtime";var kn=t=>(t||"").trim().toLowerCase(),Ks=()=>{let t=xt("TTP"),e=A(L=>L.campaigns),o=A(L=>L.allCampaigns),i=A(L=>L.currentScreen),n=A(L=>L.isVisible),[r,l]=Fo(0),[d,c]=Fo(!1),[y,b]=Fo(null),[h,f]=Fo({width:0,height:0}),v=To(null),S=To(null),u=To(null),m=ur(()=>{if(t)return t;let L=kn(i),X=ht=>ht.find(U=>{let W=U,tt=W.campaign_type==="TTP"||W.campaign_type==="TLTP",dt=!kn(W.screen)||kn(W.screen)===L,St=!!(W.trigger_event??W.trigger),yt=W.display_trigger!==!1&&!St;return tt&&dt&&yt});return X(e)??X(o)},[t,e,o,i]),g=ur(()=>m?.details?.tooltips&&Array.isArray(m.details.tooltips)?[...m.details.tooltips].sort((L,X)=>(L.order??0)-(X.order??0)):m?.details?.target||m?.details?.titleText?[{...m.details,_id:m.id}]:[],[m]),C=g[r];cr(()=>{},[m]);let I=To(new Set),z=Js(()=>{if(!(!m||!C||d||!n))try{let L=C._id||C.id||void 0,X=String(m.id||"")+"::"+String(L||"");I.current.has(X)||(I.current.add(X),G("viewed",m.id,{tooltip_id:L}))}catch{}},[m,C,d,n]),E=He(z);if(cr(()=>{if(!C?.target||d)return;b(null);let L=(W=!1)=>{let tt=C.target;if(!tt)return null;let dt=ko(tt);return dt?(b(dt.getBoundingClientRect()),W&&dt.scrollIntoView({behavior:"smooth",block:"center"}),dt):null},X=W=>{u.current?.disconnect(),u.current=null,!(!W||typeof ResizeObserver>"u")&&(u.current=new ResizeObserver(()=>{b(W.getBoundingClientRect())}),u.current.observe(W))},ht=L(!0);X(ht),ht||(S.current=new MutationObserver(()=>{let W=L(!0);W&&(S.current?.disconnect(),X(W))}),S.current.observe(document.body,{childList:!0,subtree:!0}));let U=()=>{let W=L(!1);W&&b(W.getBoundingClientRect())};return window.addEventListener("resize",U),window.addEventListener("scroll",U,{passive:!0,capture:!0}),()=>{S.current?.disconnect(),u.current?.disconnect(),window.removeEventListener("resize",U),window.removeEventListener("scroll",U,{capture:!0})}},[C,d,r]),Xs(()=>{if(v.current&&y){let{width:L,height:X}=v.current.getBoundingClientRect();f({width:L,height:X})}},[C,y]),!m||!C||d||!n||!y)return null;let w=C.styling||{},D=w.appearance||{},_=D.colors||{},P=w.cta||{},H=P.container||{},B=P.cornerRadius||{},a=P.text||{},x=!!(D.imageDimensions?.width&&D.imageDimensions?.height),s,p;if(x){let L=D.imageDimensions.width,X=D.imageDimensions.height,ht=typeof window<"u"?window.innerWidth*.9:L;s=Math.min(L,ht),p=s===L?X:Math.round(X*(s/L))}let M=C.arrowPosition;!M&&C.position&&(C.position==="left"?M="right":C.position==="right"?M="left":C.position==="top"?M="bottom":C.position==="bottom"&&(M="top")),M||(M="left");let R=(D.arrowStyle||{width:6,height:12}).width||6,$=y.top+window.scrollY,N=y.left+window.scrollX,V=0,O=0,q=8;M==="left"?(V=N+y.width+q,O=$+y.height/2-h.height/2):M==="right"?(V=N-h.width-q,O=$+y.height/2-h.height/2):M==="top"?(O=$+y.height+q,V=N+y.width/2-h.width/2):M==="bottom"&&(O=$-h.height-q,V=N+y.width/2-h.width/2);let Z=8,it=typeof document<"u"?document.documentElement.scrollHeight:window.innerHeight,et=typeof document<"u"?document.documentElement.scrollWidth:window.innerWidth;h.height>0&&(O=Math.max(Z,Math.min(it-h.height-Z,O))),h.width>0&&(V=Math.max(Z,Math.min(et-h.width-Z,V)));let rt=()=>{let L=C.link||C.url;try{let X=C._id||C.id||void 0;m?.id&&G("clicked",m.id,{tooltip_id:X})}catch{}r<g.length-1?(l(X=>X+1),L&&window.open(L,"_blank")):(c(!0),L&&window.open(L,"_blank"))},k=()=>{C.enableBackdrop&&(r<g.length-1?l(L=>L+1):c(!0))};return Rn(ta,{children:[C.enableBackdrop&&Vt("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:_.backdrop||"rgba(0, 0, 0, 0.7)",opacity:D.backdropOpacity?D.backdropOpacity/100:.7,zIndex:1e4},onClick:k}),Rn("div",{ref:L=>{v.current=L,E(L)},style:{position:"absolute",top:O,left:V,zIndex:10001,backgroundColor:_.tooltip||"#FE6B35",padding:x?0:`${D.padding?.top??8}px ${D.padding?.right??8}px ${D.padding?.bottom??8}px ${D.padding?.left??8}px`,borderRadius:`${D.cornerRadius?.topLeft??12}px ${D.cornerRadius?.topRight??12}px ${D.cornerRadius?.bottomRight??12}px ${D.cornerRadius?.bottomLeft??12}px`,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",width:x?s:void 0,height:x?p:void 0,maxWidth:x?s:300,minWidth:x?void 0:200,transition:"top 0.2s ease, left 0.2s ease",cursor:C.ctaText?"default":"pointer"},onClick:L=>{L.target.tagName!=="BUTTON"&&(C.ctaText||rt())},children:[Vt("div",{style:{position:"absolute",width:0,height:0,borderStyle:"solid",...M==="left"&&{left:-q,top:Math.max(12,Math.min(h.height-R*2-12,$+y.height/2-O-R)),borderWidth:`${R}px ${q}px ${R}px 0`,borderColor:`transparent ${_.arrow||_.tooltip||"#FE6B35"} transparent transparent`},...M==="right"&&{right:-q,top:Math.max(12,Math.min(h.height-R*2-12,$+y.height/2-O-R)),borderWidth:`${R}px 0 ${R}px ${q}px`,borderColor:`transparent transparent transparent ${_.arrow||_.tooltip||"#FE6B35"}`},...M==="top"&&{top:-q,left:Math.max(12,Math.min(h.width-R*2-12,N+y.width/2-V-R)),borderWidth:`0 ${R}px ${q}px ${R}px`,borderColor:`transparent transparent ${_.arrow||_.tooltip||"#FE6B35"} transparent`},...M==="bottom"&&{bottom:-q,left:Math.max(12,Math.min(h.width-R*2-12,N+y.width/2-V-R)),borderWidth:`${q}px ${R}px 0 ${R}px`,borderColor:`${_.arrow||_.tooltip||"#FE6B35"} transparent transparent transparent`}}}),C.url&&(x?Vt("div",{style:{width:"100%",height:"100%",overflow:"hidden",borderRadius:`${D.cornerRadius?.topLeft??12}px ${D.cornerRadius?.topRight??12}px ${D.cornerRadius?.bottomRight??12}px ${D.cornerRadius?.bottomLeft??12}px`},children:Vt("img",{src:C.url,alt:"tooltip media",style:{width:"100%",height:"100%",display:"block",objectFit:"cover"}})}):Vt("img",{src:C.url,alt:"tooltip media",style:{width:"100%",borderRadius:6,marginBottom:8,display:"block",objectFit:"cover"}})),(C.titleText||C.subtitleText||C.ctaText)&&Rn("div",{style:x?{padding:`${D.padding?.top??8}px ${D.padding?.right??8}px ${D.padding?.bottom??8}px ${D.padding?.left??8}px`}:void 0,children:[C.titleText&&Vt("div",{style:{color:w.title?.color||"#ffffff",fontFamily:gt(w.title?.fontFamily)||"Arial",fontSize:w.title?.fontSize||14,textAlign:w.title?.textAlign||"center",marginBottom:w.title?.margin?.bottom??4,marginTop:w.title?.margin?.top??0,marginLeft:w.title?.margin?.left??0,marginRight:w.title?.margin?.right??0,fontWeight:w.title?.fontDecoration?.includes("bold")?"bold":600,fontStyle:w.title?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:w.title?.fontDecoration?.includes("underline")?"underline":"none"},children:C.titleText}),C.subtitleText&&Vt("div",{style:{color:w.subTitle?.color||"#ffffff",fontFamily:gt(w.subTitle?.fontFamily)||"Arial",fontSize:w.subTitle?.fontSize||12,textAlign:w.subTitle?.textAlign||"center",marginBottom:w.subTitle?.margin?.bottom??8,marginTop:w.subTitle?.margin?.top??0,marginLeft:w.subTitle?.margin?.left??0,marginRight:w.subTitle?.margin?.right??0,fontWeight:w.subTitle?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:w.subTitle?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:w.subTitle?.fontDecoration?.includes("underline")?"underline":"none"},children:C.subtitleText}),C.ctaText&&Vt("div",{style:{display:"flex",justifyContent:H.alignment==="right"?"flex-end":H.alignment==="left"?"flex-start":"center",marginTop:8},children:Vt("button",{onClick:rt,style:{width:H.ctaFullWidth?"100%":H.ctaWidth||"auto",height:H.height||35,background:H.backgroundColor||"#F7921C",color:a.color||"#ffffff",border:`${H.borderWidth||0}px solid ${H.borderColor||"transparent"}`,borderRadius:`${B.topLeft??7}px ${B.topRight??7}px ${B.bottomRight??7}px ${B.bottomLeft??7}px`,fontSize:a.fontSize||14,fontFamily:gt(a.fontFamily)||"Arial",fontWeight:a.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:a.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:a.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:C.ctaText})})]})]})]})},Zs=Ks;import{useEffect as ea,useState as oa,useRef as na}from"react";ot();import{Fragment as ra,jsx as Ot,jsxs as Tn}from"react/jsx-runtime";var ia=()=>{let t=xt("BTS"),e=A(u=>u.campaigns),o=A(u=>u.allCampaigns),i=A(u=>u.currentScreen),n=t??(()=>{let u=(i||"").trim().toLowerCase(),m=[...e||[],...o||[]].find(g=>{if(!g||g.campaign_type!=="BTS")return!1;let C=!!(g.trigger_event??g.trigger);if(!(g.display_trigger!==!1&&!C))return!1;let z=(g.screen||"").trim().toLowerCase();return!z||z===u});if(m)try{return Rt(m)}catch{return m}})(),r=A(u=>u.isVisible),[l,d]=oa(!1),c=na(null);ea(()=>{n?.id&&c.current!==n.id&&(c.current=n.id,d(!1),G("viewed",n.id))},[n?.id]);let y=u=>{try{let m=A.getState(),C=(m.trackedEvents||[]).filter(I=>I!==u);m.setTrackedEvents(C)}catch{}};if(!n||l||!r)return null;let{details:b}=n,f=[...b.elements||[]].sort((u,m)=>(u.order||0)-(m.order||0)),v=b.backdropOpacity??.5;v>1&&(v=v/100);let S=u=>{switch(u.type){case"image":{let m={width:"100%",display:"block",objectFit:"contain",backgroundColor:u.imageBackgroundColor||"transparent",paddingBottom:u.paddingBottom??0,paddingLeft:u.paddingLeft??0,paddingRight:u.paddingRight??0,paddingTop:u.paddingTop??0,cursor:u.imageLink?"pointer":"default"};return Ot("div",{style:{textAlign:u.alignment||"left",width:"100%"},children:u.url&&Ot("img",{src:u.url,alt:"",style:m,onClick:()=>{if(u.imageLink){n?.id&&G("clicked",n.id);try{let g=String(u.imageLink||"").trim();if(g&&!g.startsWith("http")&&wt(g))return}catch(g){console.warn("revealCampaignFromLink error",g)}try{window.open(u.imageLink,"_blank")}catch{}}}})},u.id)}case"cta":{let m=u.cta||{},g=m.container||{},C=m.cornerRadius||{},I=m.margin||{},z=m.text||{};return Ot("div",{style:{display:"flex",justifyContent:g.alignment==="center"?"center":g.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:Ot("button",{style:{width:g.ctaFullWidth?"100%":g.ctaWidth||"auto",height:g.height||45,backgroundColor:g.ctaBoxColor||g.backgroundColor||"#FE6B35",color:z.color||"#ffffff",border:`${g.borderWidth||0}px solid ${g.borderColor||"transparent"}`,borderRadius:`${C.topLeft??12}px ${C.topRight??12}px ${C.bottomRight??12}px ${C.bottomLeft??12}px`,fontSize:z.fontSize||14,fontFamily:gt(z.fontFamily)||"Arial",fontWeight:z.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:z.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:z.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px"},onClick:()=>{let E=u.ctaLink||u.url;if(E){n?.id&&G("clicked",n.id);try{let w=String(E||"").trim();if(w&&!w.startsWith("http")&&wt(w))return}catch(w){console.warn("revealCampaignFromLink error",w)}try{window.open(E,"_blank")}catch{}}},children:u.ctaText||"Button"})},u.id)}case"body":{let m=u.titleFontStyle||{},g=u.descriptionFontStyle||{};return Tn("div",{style:{width:"100%",backgroundColor:u.bodyBackgroundColor||"transparent",marginTop:u.marginTop??0,marginBottom:u.marginBottom??20,marginLeft:u.marginLeft??4,marginRight:u.marginRight??4},children:[u.titleText&&Ot("div",{style:{color:m.colour||"#000000",fontSize:m.fontSize?`${m.fontSize}px`:u.titleFontSize?`${u.titleFontSize}px`:"16px",fontFamily:gt(m.fontFamily)||"inherit",textAlign:m.alignment||"left",lineHeight:u.titleLineHeight||1.2,fontWeight:m.decoration?.includes("bold")?"bold":"600",fontStyle:m.decoration?.includes("italic")?"italic":"normal",textDecoration:m.decoration?.includes("underline")?"underline":"none",marginBottom:u.spacingBetweenTitleDesc??4},children:u.titleText}),u.descriptionText&&Ot("div",{style:{color:g.colour||"#000000",fontSize:g.fontSize?`${g.fontSize}px`:u.descriptionFontSize?`${u.descriptionFontSize}px`:"14px",fontFamily:gt(g.fontFamily)||"inherit",textAlign:g.alignment||"left",lineHeight:u.descriptionLineHeight||1.5,fontWeight:g.decoration?.includes("bold")?"bold":"normal",fontStyle:g.decoration?.includes("italic")?"italic":"normal",textDecoration:g.decoration?.includes("underline")?"underline":"none"},children:u.descriptionText})]},u.id)}default:return null}};return Tn(ra,{children:[Ot("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:b.backdropColor||"rgba(0,0,0,0.5)",opacity:v,zIndex:999998,transition:"opacity 0.3s ease"},onClick:()=>{n?.id&&y(`viaAppStorys${n.id}`),d(!0)}}),Tn("div",{style:{position:"fixed",bottom:0,left:"50%",transform:"translateX(-50%)",width:"100%",maxWidth:"500px",backgroundColor:b.backgroundColor||"#FFFFFF",borderTopLeftRadius:`${b.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${b.cornerRadius?.topRight??16}px`,borderBottomLeftRadius:`${b.cornerRadius?.bottomLeft??0}px`,borderBottomRightRadius:`${b.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:[Ot("div",{style:{width:"40px",height:"5px",backgroundColor:"#E0E0E0",borderRadius:"2.5px",marginBottom:"16px",cursor:"pointer"},onClick:()=>d(!0)}),b.crossButton?.enabled&&Ot(Ft,{config:b.crossButton,onPress:()=>{n?.id&&y(`viaAppStorys${n.id}`),d(!0)},style:{top:b.crossButton?.margin?.top??12,right:b.crossButton?.margin?.right??12}}),Ot("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:"12px"},children:f.map(S)})]})]})};import{useEffect as gr,useMemo as sa,useState as fe,useRef as aa}from"react";ot();import*as Te from"lottie-react";import{Fragment as In,jsx as nt,jsxs as Ve}from"react/jsx-runtime";var la=Te.default?.default??Te.default??Te.Lottie??Te,pr=5,Fn=3;function ke(t){if(t!=null)return`${t}px`}function qe(t){return{marginTop:ke(t?.top),marginRight:ke(t?.right),marginBottom:ke(t?.bottom),marginLeft:ke(t?.left)}}function Bn(t){return gt(t)}function Re(t){return t?{color:t.color,fontSize:t.fontSize,fontFamily:Bn(t.fontFamily),textAlign:t.textAlign,fontWeight:t.fontDecoration?.includes("bold")?"bold":void 0,fontStyle:t.fontDecoration?.includes("italic")?"italic":void 0,textDecoration:t.fontDecoration?.includes("underline")?"underline":void 0}:{}}function zo(t){return`${t?.topLeft??8}px ${t?.topRight??8}px ${t?.bottomRight??8}px ${t?.bottomLeft??8}px`}function da(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function ca(t){let e=t.styling?.rating?.ratingType;return e==="number"||e==="emoji"||e==="star"?e:"star"}function ua(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 i=o.map(n=>{if(typeof n=="string")return n.trim();if(n&&typeof n=="object"){let r=n.emoji||n.value||n.text||n.icon||n.name||"";if(typeof r=="string")return r.trim()}return""}).filter(Boolean);return i.length>0?i:["\u{1F620}","\u{1F615}","\u{1F610}","\u{1F642}","\u{1F60D}"]}function pa(t){return Array.from({length:5},(e,o)=>o+1)}function zn(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 ga(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];for(let n of o){let r=zn(n);if(r!=null)return r}let i=e?.number;if(i&&typeof i=="object"){let n=i,r=[n.spacing,n.gap,n.optionsSpacing,n.numberSpacing,n.numberGap];for(let l of r){let d=zn(l);if(d!=null)return d}}return 8}var fa=({fill:t,stroke:e})=>nt("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":!0,children:nt("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"})}),ma=({details:t,appearance:e,rating:o,selectedOptions:i,comments:n,isHighRating:r,feedbackOptions:l,onRate:d,onToggleOption:c,onCommentChange:y,onInlineSubmit:b,canSubmit:h})=>{let f=t.styling||{},v=f.feedbackPage||{},S=f.rating||{},u=f.initialFeedback||{},m=v.submitButton?.cta,g=ca(t),C=g==="number"?pa(t):[],I=g==="emoji"?ua(t):[],z=g==="number"?ga(t):8,E=r?S.star?.high:S.star?.low;return Ve(In,{children:[nt("div",{style:qe(u.title?.margin),children:nt("div",{style:{...Re(u.title?.textStyle),color:u.title?.textStyle?.color||"#101828",fontSize:u.title?.textStyle?.fontSize||20,lineHeight:1.3},children:t.title||"How was your experience?"})}),nt("div",{style:qe(u.subtitle?.margin),children:nt("div",{style:{...Re(u.subtitle?.textStyle),color:u.subtitle?.textStyle?.color||"#4b5563",fontSize:u.subtitle?.textStyle?.fontSize||14,lineHeight:1.4},children:t.description_text||"Your feedback helps us improve your experience."})}),Ve("div",{style:{marginTop:8,display:"flex",justifyContent:"center",gap:g==="number"?z:8,flexWrap:"wrap"},children:[g==="star"&&Array.from({length:pr},(w,D)=>{let _=D+1,P=_<=o,H=P?E?.stylingContainer:S.star?.unselected?.stylingContainer,B=P?E?.stylingStar:S.star?.unselected?.stylingStar;return nt("button",{onClick:()=>d(_),style:{border:`${H?.borderWidth??1}px solid ${H?.border||"#d1d5db"}`,background:H?.background||"#ffffff",borderRadius:10,width:44,height:44,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0},"aria-label":`Rate ${_} out of ${pr}`,children:nt(fa,{fill:B?.background||(P?"#f59e0b":"#e5e7eb"),stroke:B?.border||(P?"#d97706":"#9ca3af")})},_)}),g==="number"&&C.map((w,D)=>{let _=w===o;return nt("button",{onClick:()=>d(w),style:{border:`1px solid ${_?"#1d4ed8":"#d1d5db"}`,background:_?"#dbeafe":"#ffffff",color:_?"#1d4ed8":"#111827",borderRadius:8,minWidth:36,height:36,padding:"0 10px",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontWeight:600},"aria-label":`Rate ${w}`,children:w},`${w}-${D}`)}),g==="emoji"&&I.map((w,D)=>{let _=D+1,P=_===o,H=S.emoji,a=(P?H?.selected:H?.unselected)?.stylingContainer;return nt("button",{onClick:()=>d(_),style:{border:`${a?.borderWidth??1}px solid ${a?.border||(P?"#1d4ed8":"#d1d5db")}`,background:a?.fill||a?.background||(P?"#dbeafe":"#ffffff"),borderRadius:S.cornerRadius?zo(S.cornerRadius):"999px",width:44,height:44,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:22},"aria-label":`Emoji rating ${D+1}`,children:w},`${w}-${D}`)})]}),o>0&&nt("div",{style:{marginTop:6,textAlign:"center",color:"#374151",fontSize:14},children:r?t.highStarText||S.highRatingSubtitle:t.lowStarText||S.lowRatingSubtitle}),o>0&&o<=Fn&&Ve(In,{children:[l.length>0&&nt("div",{style:{...qe(v.options?.margin),display:"flex",flexDirection:"column",alignItems:"stretch",gap:v.options?.optionsSpacing??8,width:"100%"},children:l.map(w=>{let _=i.includes(w)?v.options?.selectedOptions:v.options?.nonSelectedOptions;return nt("button",{onClick:()=>c(w),style:{border:`${_?.borderWidth??1}px solid ${_?.colors?.border||"#d1d5db"}`,background:_?.colors?.background||"#f9fafb",color:_?.colors?.text||"#111827",width:"100%",height:v.options?.optionsHeight||38,borderRadius:zo(v.options?.cornerRadius),padding:"0 14px",cursor:"pointer",textAlign:"center",...Re(_?.textStyle)},children:w},w)})}),nt("textarea",{value:n,onChange:w=>y(w.target.value),placeholder:v.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:`${v.additionalComments?.borderWidth??1}px solid ${v.additionalComments?.colors?.border||"#d1d5db"}`,background:v.additionalComments?.colors?.background||"#ffffff",color:v.additionalComments?.colors?.text||"#111827",borderRadius:8,padding:"12px",...Re(v.additionalComments?.textStyle)}}),nt("div",{style:{position:"sticky",bottom:0,marginTop:8,paddingTop:6,paddingBottom:6,background:e?.backgroundColor||"#2f6ef5",display:"flex",justifyContent:"center"},children:nt("button",{onClick:()=>b(),disabled:!h,style:{width:Math.max(140,Math.min(zn(m?.container?.ctaWidth)??180,220)),maxWidth:"100%",minHeight:30,height:Math.max(30,Math.min(Number(m?.container?.height)||34,34)),border:`${m?.container?.borderWidth??1}px solid ${m?.container?.borderColor||"#ff7a00"}`,background:m?.container?.backgroundColor||"#ff2bc2",color:m?.text?.color||"#ffffff",borderRadius:zo(m?.cornerRadius),fontFamily:Bn(m?.text?.fontFamily),fontSize:Math.min(Number(m?.text?.fontSize)||14,14),fontWeight:m?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:h?"pointer":"not-allowed",opacity:h?1:.65,padding:"0 12px"},children:v.submitButton?.text||"Submit"})})]})]})},ya=({details:t,isHighRating:e,onDone:o})=>{let i=t.styling||{},n=i.thankyouPage||{},r=i.rating||{},l=da(n.doneButton?.cta?.container?.alignment),[d,c]=fe(null),y=t.thankyouImage?.endsWith(".json");return gr(()=>{y&&t.thankyouImage&&fetch(t.thankyouImage).then(b=>b.json()).then(b=>c(b)).catch(b=>console.error("Error loading Lottie:",b))},[t.thankyouImage,y]),Ve(In,{children:[t.thankyouImage&&nt("div",{style:{display:"flex",justifyContent:"center",marginTop:6},children:y?d?nt(la,{animationData:d,loop:!0,style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80}}):nt("div",{style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80}}):nt("img",{src:t.thankyouImage,alt:"thank you",style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80,objectFit:"cover",borderRadius:8}})}),nt("div",{style:{...qe(n.title?.margin),textAlign:"center"},children:nt("div",{style:{...Re(n.title?.textStyle),color:n.title?.textStyle?.color||"#111827",fontSize:n.title?.textStyle?.fontSize||20,fontWeight:n.title?.textStyle?.fontDecoration?.includes("bold")?"bold":600},children:t.thankyouText??(e?r.highRatingTitle:r.lowRatingTitle)??"Thank you for your feedback"})}),nt("div",{style:{...qe(n.subtitle?.margin),textAlign:"center"},children:nt("div",{style:{...Re(n.subtitle?.textStyle),color:n.subtitle?.textStyle?.color||"#4b5563",fontSize:n.subtitle?.textStyle?.fontSize||14},children:t.thankyouDescription??(e?r.highRatingSubtitle:r.lowRatingSubtitle)??"We appreciate your time."})}),nt("div",{style:{marginTop:n.doneButton?.cta?.margin?.top??14,marginBottom:n.doneButton?.cta?.margin?.bottom??0,marginLeft:n.doneButton?.cta?.margin?.left??0,marginRight:n.doneButton?.cta?.margin?.right??0,display:"flex",justifyContent:l},children:nt("button",{onClick:o,style:{width:n.doneButton?.cta?.container?.ctaFullWidth?"100%":n.doneButton?.cta?.container?.ctaWidth||"auto",height:n.doneButton?.cta?.container?.height||45,border:`${n.doneButton?.cta?.container?.borderWidth??0}px solid ${n.doneButton?.cta?.container?.borderColor||"transparent"}`,background:n.doneButton?.cta?.container?.backgroundColor||"#111827",color:n.doneButton?.cta?.text?.color||"#ffffff",borderRadius:zo(n.doneButton?.cta?.cornerRadius),fontFamily:Bn(n.doneButton?.cta?.text?.fontFamily),fontSize:n.doneButton?.cta?.text?.fontSize||16,fontWeight:n.doneButton?.cta?.text?.fontDecoration?.includes("bold")?"bold":500,cursor:"pointer",padding:"0 16px"},children:n.doneButton?.text||(e?"Rate Now":"Done")})})]})},ha=()=>{let t=xt("CSAT"),e=A(s=>s.isVisible),o=A(s=>s.campaigns),i=A(s=>s.allCampaigns),n=A(s=>s.currentScreen),r=t??(()=>{let s=(n||"").trim().toLowerCase(),p=[...o||[],...i||[]].find(M=>{if(!M||M.campaign_type!=="CSAT")return!1;let T=!!(M.trigger_event??M.trigger);if(!(M.display_trigger!==!1&&!T))return!1;let $=(M.screen||"").trim().toLowerCase();return!$||$===s});if(p)try{return Rt(p)}catch{return p}})(),[l,d]=fe(!1),[c,y]=fe(!1),[b,h]=fe(0),[f,v]=fe([]),[S,u]=fe(""),[m,g]=fe(!1),C=aa(null);gr(()=>{if(!r?.id||C.current===r.id)return;C.current=r.id,d(!1),y(!1),h(0),v([]),u(""),g(!1);let s=r.details?.styling?.appearance?.displayDelay??0,p=globalThis.setTimeout(()=>{y(!0),G("viewed",r.id)},Math.max(0,s)*1e3);return()=>globalThis.clearTimeout(p)},[r?.id]);let I=sa(()=>{let s=r?.details?.feedback_option||{};return Object.keys(s).sort((p,M)=>p.localeCompare(M)).map(p=>s[p]).filter(Boolean)},[r]);if(!r||!e||l||!c)return null;let z=r.details,E=z.styling||{},w=E.appearance||{},D=b>Fn,_=Number(z.width??80),P=Math.max(660,Math.min(1080,_*10)),H=s=>{v(p=>p.includes(s)?p.filter(M=>M!==s):[...p,s])},B=async s=>{let p=s?.rating??b;if(p<1)return;g(!0);let M=z.id||r.id,T=(s?.options??f)[0]||"",R=s?.comments??S??"";G("csat captured",M,{starCount:p,selectedOption:T,additionalComments:R})},a=s=>{if(h(s),s>Fn){v([]),u("");let p=z.id||r?.id;setTimeout(()=>{g(!0);try{G("csat captured",p,{starCount:s,selectedOption:"",additionalComments:""})}catch(M){console.warn("Error sending csat captured",M)}},1e3)}},x=()=>{if(D&&z.link){let s=r&&r.id||void 0;try{s&&G("clicked",s)}catch{}try{let p=String(z.link||"").trim();if(p&&!p.startsWith("http")&&wt(p)){d(!0);return}}catch(p){console.warn("revealCampaignFromLink error",p)}try{globalThis.open(z.link,"_blank")}catch{}}d(!0)};return nt("div",{style:{position:"fixed",right:`${w.margin?.right||20}px`,bottom:`${w.margin?.bottom||20}px`,zIndex:999999,pointerEvents:"none"},children:Ve("div",{style:{position:"relative",width:"min(450px, calc(100vw - 32px))",maxHeight:"85vh",overflow:"visible",backgroundColor:w.backgroundColor||"#2f6ef5",borderRadius:`${w.borderRadius??12}px`,boxSizing:"border-box",paddingTop:"8px",paddingRight:ke(w.padding?.right)||"12px",paddingBottom:"4px",paddingLeft:ke(w.padding?.left)||"12px",pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"},children:[nt("style",{children:`
82
124
  .appstorys-csat-scroll {
83
125
  scrollbar-width: none; /* Firefox */
84
126
  -ms-overflow-style: none; /* IE/Edge */
@@ -88,7 +130,7 @@ var Yi=Object.defineProperty;var Nt=(t,e)=>()=>(t&&(e=t(t=0)),e);var Qi=(t,e)=>{
88
130
  height: 0;
89
131
  display: none; /* Chrome/Safari */
90
132
  }
91
- `}),z.crossButton?.enabled&&Z(Lt,{config:z.crossButton,onPress:()=>a(!0),style:{top:z.crossButton?.margin?.top??10,right:z.crossButton?.margin?.right??10}}),Z("div",{className:"appstorys-csat-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:4},children:h?Z(Rs,{details:I,isHighRating:d,onDone:L}):Z(ks,{details:I,rating:x,selectedOptions:g,comments:f,isHighRating:d,feedbackOptions:w,onRate:B,onToggleOption:p,onCommentChange:b,onInlineSubmit:M,canSubmit:x>=1,appearance:R})})]})})},Fs=Ts;import{useEffect as zi,useMemo as Ei,useState as Yt}from"react";K();import{Fragment as Li,jsx as rt,jsxs as we}from"react/jsx-runtime";function Je(t){if(t!=null)return`${t}px`}function nn(t){return ct(t)}function se(t){return t?{color:t.color,fontSize:t.fontSize,fontFamily:nn(t.fontFamily),textAlign:t.textAlign,fontWeight:t.fontDecoration?.includes("bold")?"bold":void 0,fontStyle:t.fontDecoration?.includes("italic")?"italic":void 0,textDecoration:t.fontDecoration?.includes("underline")?"underline":void 0}:{}}function Xe(t){return{marginTop:Je(t?.top),marginRight:Je(t?.right),marginBottom:Je(t?.bottom),marginLeft:Je(t?.left)}}function Ke(t){return`${t?.topLeft??12}px ${t?.topRight??12}px ${t?.bottomRight??t?.topRight??12}px ${t?.bottomLeft??t?.topLeft??12}px`}function Pi(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function ve(t){return Math.max(0,Math.min(1,t))}function Is(t,e){let o=(t||"").trim().replace("#","");if(o.length===3){let i=Number.parseInt(o[0]+o[0],16),n=Number.parseInt(o[1]+o[1],16),r=Number.parseInt(o[2]+o[2],16);return`rgba(${i}, ${n}, ${r}, ${ve(e)})`}if(o.length===6){let i=Number.parseInt(o.slice(0,2),16),n=Number.parseInt(o.slice(2,4),16),r=Number.parseInt(o.slice(4,6),16);return`rgba(${i}, ${n}, ${r}, ${ve(e)})`}return`rgba(0, 0, 0, ${ve(e)})`}function zs(t){if(t==null)return .4;let e=Number(t);return Number.isFinite(e)?e>1?ve(e/100):ve(e):.4}function Bi(t){return[...t.slides||[]].sort((o,i)=>(o.order??0)-(i.order??0))}function Bs(t){let e=t?.options||{},o=Object.keys(e),i=n=>{let r=/(\d+)/.exec(n);if(!r)return;let s=Number(r[1]);return Number.isFinite(s)?s:void 0};return o.sort((n,r)=>{let s=i(n),a=i(r);return s!=null&&a!=null?s-a:s!=null?-1:a!=null?1:n.localeCompare(r)}),o.map(n=>e[n]).filter(n=>typeof n=="string"&&n.trim().length>0)}function As(t,e){if(!t)return null;if(t==="alphabet"){let o="A".codePointAt(0)??65;return String.fromCodePoint(o+e%26)}return t==="number"?String(e+1):null}function Es(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 Ai(t){return Es(t?.borderwidth)??1}var Ps=({details:t,slide:e,appearance:o,selectedOption:i,comment:n,onSelectOption:r,onCommentChange:s,onSubmit:a,canSubmit:c})=>{let u=t.styling||{},x=u.options||{},m=u.cta,g=Ei(()=>Bs(e),[e]),v=x.optionsSpacing??8,f=x.bulletSpacing??10,b=x.optionsHeight??44,h=Pi(m?.container?.alignment);return we(Li,{children:[rt("div",{style:Xe(u.title?.textStyle?.margin),children:rt("div",{style:{...se(u.title?.textStyle),color:u.title?.textStyle?.color||"#111827",fontSize:u.title?.textStyle?.fontSize||20,lineHeight:1.3,fontWeight:u.title?.textStyle?.fontDecoration?.includes("bold")?"bold":700},children:e.title||e.question||t.name||"Survey"})}),(e.subtitle||u.subtitle?.textStyle)&&rt("div",{style:Xe(u.subtitle?.textStyle?.margin),children:rt("div",{style:{...se(u.subtitle?.textStyle),color:u.subtitle?.textStyle?.color||"#6b7280",fontSize:u.subtitle?.textStyle?.fontSize||14,lineHeight:1.35},children:e.subtitle||""})}),g.length>0&&rt("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:v},children:g.map((y,w)=>{let I=i===y,z=I?x.selectedOptions:x.nonSelectedOptions,R=Ai(z?.textStyle),d=As(x.optionListStyle,w);return we("button",{onClick:()=>r(y),style:{width:"100%",boxSizing:"border-box",height:b,borderRadius:Ke(x.cornerRadius),border:`${R}px solid ${z?.colors?.border||"#e5e7eb"}`,background:z?.colors?.background||"#ffffff",color:z?.colors?.text||"#111827",cursor:"pointer",display:"flex",alignItems:"center",gap:f,paddingLeft:14,paddingRight:14,textAlign:"left",...se(z?.textStyle)},"aria-pressed":I,children:[rt("span",{"aria-hidden":!0,style:{width:16,height:16,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",border:`1.5px solid ${z?.colors?.border||"#111827"}`,background:"#ffffff",flex:"0 0 auto",fontSize:11,fontWeight:700,color:z?.colors?.text||"#111827"},children:I?"\u2713":d||""}),rt("span",{style:{flex:1,minWidth:0},children:y})]},`${y}-${w}`)})}),e.additionalComment?.enabled&&rt("textarea",{value:n,onChange:y=>s(y.target.value),placeholder:e.additionalComment?.placeholder||"",style:{marginTop:10,width:"100%",boxSizing:"border-box",minHeight:72,resize:"none",overflowY:"auto",border:`${Ai(x.additionalComments?.textStyle)}px solid ${x.additionalComments?.colors?.border||"#e5e7eb"}`,background:x.additionalComments?.colors?.background||"#ffffff",color:x.additionalComments?.colors?.text||"#111827",borderRadius:10,padding:"12px",...se(x.additionalComments?.textStyle)}}),rt("div",{style:{position:"sticky",bottom:0,marginTop:12,paddingTop:10,paddingBottom:6,background:o?.backgroundColor||"#ffffff"},children:rt("div",{style:{marginTop:m?.margin?.top??0,marginBottom:m?.margin?.bottom??0,marginLeft:m?.margin?.left??0,marginRight:m?.margin?.right??0,display:"flex",justifyContent:h},children:rt("button",{onClick:a,disabled:!c,style:{width:m?.container?.ctaFullWidth?"100%":m?.container?.ctaWidth??"100%",height:m?.container?.height??44,border:`${m?.container?.borderWidth??0}px solid ${m?.container?.borderColor||"transparent"}`,background:m?.container?.backgroundColor||"#111827",color:m?.text?.color||"#ffffff",borderRadius:Ke(m?.cornerRadius),fontFamily:nn(m?.text?.fontFamily),fontSize:m?.text?.fontSize||14,fontWeight:m?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:c?"pointer":"not-allowed",opacity:c?1:.6,padding:"0 16px"},children:e.submitButtonText||"Submit"})})})]})},Ls=({details:t,onDone:e})=>{let i=(t.styling||{}).thankyouPage||{},n=i.cta,r=Pi(n?.container?.alignment);return we(Li,{children:[t.thankYouImage&&rt("div",{style:{display:"flex",justifyContent:"center",marginTop:8},children:rt("img",{src:t.thankYouImage,alt:"thank you",style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80,objectFit:"cover",borderRadius:10}})}),rt("div",{style:{...Xe(i.title?.textStyle?.margin)},children:rt("div",{style:{...se(i.title?.textStyle),color:i.title?.textStyle?.color||"#111827",fontSize:i.title?.textStyle?.fontSize||20,lineHeight:1.3,fontWeight:i.title?.textStyle?.fontDecoration?.includes("bold")?"bold":700},children:t.thankYouTitle||"Thank you"})}),rt("div",{style:{...Xe(i.subtitle?.textStyle?.margin)},children:rt("div",{style:{...se(i.subtitle?.textStyle),color:i.subtitle?.textStyle?.color||"#6b7280",fontSize:i.subtitle?.textStyle?.fontSize||14,lineHeight:1.35},children:t.thankYouText||""})}),(t.thankYouButtonText||n)&&rt("div",{style:{marginTop:n?.margin?.top??14,marginBottom:n?.margin?.bottom??0,marginLeft:n?.margin?.left??0,marginRight:n?.margin?.right??0,display:"flex",justifyContent:r},children:rt("button",{onClick:e,style:{width:n?.container?.ctaFullWidth?"100%":n?.container?.ctaWidth??"auto",height:n?.container?.height??40,border:`${n?.container?.borderWidth??0}px solid ${n?.container?.borderColor||"transparent"}`,background:n?.container?.backgroundColor||"#111827",color:n?.text?.color||"#ffffff",borderRadius:Ke(n?.cornerRadius),fontFamily:nn(n?.text?.fontFamily),fontSize:n?.text?.fontSize||14,fontWeight:n?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:"pointer",padding:"0 16px"},children:t.thankYouButtonText||"Done"})})]})},Ds=()=>{let t=pt("SUR"),e=F(E=>E.isVisible),o=F(E=>E.campaigns),i=F(E=>E.allCampaigns),n=F(E=>E.currentScreen),r=t??(()=>{let E=(n||"").trim().toLowerCase(),$=[...o||[],...i||[]].find(D=>{if(!D||D.campaign_type!=="SUR")return!1;let k=!!(D.trigger_event??D.trigger);if(!(D.display_trigger!==!1&&!k))return!1;let O=(D.screen||"").trim().toLowerCase();return!O||O===E});if($)try{return yt($)}catch{return $}})(),[s,a]=Yt(!1),[c,u]=Yt(!1),[x,m]=Yt(0),[g,v]=Yt(null),[f,b]=Yt(""),[h,y]=Yt({}),[w,I]=Yt(!1);zi(()=>{if(!r)return;a(!1),u(!1),m(0),v(null),b(""),y({}),I(!1);let E=r.details?.styling?.appearance?.displayDelay??0,$=globalThis.setTimeout(()=>{u(!0);let D=r.details?.id,k=Bi(r.details),P=k.length>0?k[0].id:void 0;H("viewed",r.id,{survey_id:D,slide_id:P})},Math.max(0,E)*1e3);return()=>globalThis.clearTimeout($)},[r]);let z=Ei(()=>r?Bi(r.details):[],[r]),R=z[x];if(zi(()=>{if(!R)return;let E=h[R.id];v(E?.option??null),b(E?.comment??"")},[R?.id]),!r||!e||s||!c)return null;let d=r.details,T=d.styling||{},l=T.appearance||{},p=l.backdropColor||"#000000",M=zs(l.backdropOpacity),B=E=>{v($=>$===E?null:E)},L=async(E,$)=>{let D=z.map(j=>({slide_id:j.id,order:j.order,title:j.title,question:j.question,selected_options:E[j.id]?.option,comment:E[j.id]?.comment})),k=r.id,P=[];for(let j of z){let X=E[j.id]?.option;if(!X)continue;let J=Object.entries(j.options||{}).find(([,V])=>String(V)===String(X));J&&P.push(J[0])}let O=D.map(j=>j.comment).filter(Boolean).join(" || ")||"",G=d.id||k;H("survey captured",G,{survey_id:d.id,slide_id:$,selected_options:P,otherText:O}),T.content?.isThankyouPage!==!1?I(!0):a(!0)},C=async()=>{if(!R||!g)return;let E={...h,[R.id]:{option:g,comment:f}};y(E);try{let P=r.id,O=null;if(g&&R&&R.options){let ut=Object.entries(R.options).find(([,j])=>String(j)===String(g));ut&&(O=ut[0])}let G=d.id||P;H("survey captured",G,{survey_id:d.id,slide_id:R.id,selected_options:O?[O]:[],otherText:f||""})}catch(P){console.warn("Error sending per-slide survey captured",P)}if((R.logic||[]).find(P=>(P.selectOption||[]).includes(g))?.redirectTo==="thank-you"){await L(E,R.id);return}if(x>=z.length-1){await L(E,R.id);return}m(P=>Math.min(P+1,z.length-1))},S=()=>{let E=d.thankYouButtonConfig;if(E?.enabled&&E.redirectUrl){try{let $=String(E.redirectUrl||"").trim();if($&&!$.startsWith("http")&&ht($)){a(!0);return}}catch($){console.warn("revealCampaignFromLink error",$)}try{globalThis.open(E.redirectUrl,"_blank")}catch{}}a(!0)},_=async()=>{try{let E=r?.id,$=d?.id,D=R?.id;await H("SurveyDismissed",E,{survey_id:$,slide_id:D})}catch(E){console.warn("Error sending SurveyDismissed",E)}finally{a(!0)}};return R?we("div",{style:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"flex-end",alignItems:"flex-end",padding:12,pointerEvents:"none"},children:[rt("div",{"aria-hidden":!0,style:{position:"absolute",inset:0,background:Is(p,M)}}),we("div",{style:{position:"relative",width:"min(420px, 92vw)",maxWidth:"92vw",minWidth:"320px",maxHeight:"80vh",overflow:"hidden",backgroundColor:l.backgroundColor||"#ffffff",borderRadius:Ke(l.cornerRadius),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:[rt("style",{children:`
133
+ `}),E.crossButton?.enabled&&nt(Ft,{config:E.crossButton,onPress:()=>d(!0),style:{top:E.crossButton?.margin?.top??10,right:E.crossButton?.margin?.right??10}}),nt("div",{className:"appstorys-csat-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:4},children:m?nt(ya,{details:z,isHighRating:D,onDone:x}):nt(ma,{details:z,rating:b,selectedOptions:f,comments:S,isHighRating:D,feedbackOptions:I,onRate:a,onToggleOption:H,onCommentChange:u,onInlineSubmit:B,canSubmit:b>=1,appearance:w})})]})})},ba=ha;import{useEffect as Ln,useMemo as yr,useState as re,useRef as xa}from"react";ot();import*as Ie from"lottie-react";import{Fragment as Mn,jsx as lt,jsxs as ze}from"react/jsx-runtime";var Sa=Ie.default?.default??Ie.default??Ie.Lottie??Ie;function Io(t){if(t!=null)return`${t}px`}function An(t){return gt(t)}function Fe(t){return t?{color:t.color,fontSize:t.fontSize,fontFamily:An(t.fontFamily),textAlign:t.textAlign,fontWeight:t.fontDecoration?.includes("bold")?"bold":void 0,fontStyle:t.fontDecoration?.includes("italic")?"italic":void 0,textDecoration:t.fontDecoration?.includes("underline")?"underline":void 0}:{}}function Bo(t){return{marginTop:Io(t?.top),marginRight:Io(t?.right),marginBottom:Io(t?.bottom),marginLeft:Io(t?.left)}}function Ue(t){return`${t?.topLeft??12}px ${t?.topRight??12}px ${t?.bottomRight??t?.topRight??12}px ${t?.bottomLeft??t?.topLeft??12}px`}function hr(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function Ye(t){return Math.max(0,Math.min(1,t))}function Ca(t,e){let o=(t||"").trim().replace("#","");if(o.length===3){let i=Number.parseInt(o[0]+o[0],16),n=Number.parseInt(o[1]+o[1],16),r=Number.parseInt(o[2]+o[2],16);return`rgba(${i}, ${n}, ${r}, ${Ye(e)})`}if(o.length===6){let i=Number.parseInt(o.slice(0,2),16),n=Number.parseInt(o.slice(2,4),16),r=Number.parseInt(o.slice(4,6),16);return`rgba(${i}, ${n}, ${r}, ${Ye(e)})`}return`rgba(0, 0, 0, ${Ye(e)})`}function va(t){if(t==null)return .4;let e=Number(t);return Number.isFinite(e)?e>1?Ye(e/100):Ye(e):.4}function fr(t){return[...t.slides||[]].sort((o,i)=>(o.order??0)-(i.order??0))}function wa(t,e){let o=t.trim();if(!o)return{action:"none"};let i=o.toLowerCase().replace(/[\s_-]+/g,"");if(i==="thankyou"||i==="thankyoupage")return{action:"thankyou"};let n=/^question\s+(\d+)$/i.exec(o);if(n){let c=parseInt(n[1],10)-1;return c>=0&&c<e.length?{action:"jump",targetIndex:c}:{action:"none"}}let r=e.findIndex(d=>d.id===o);if(r!==-1)return{action:"jump",targetIndex:r};let l=Number(o);if(Number.isFinite(l)&&l>0){let d=e.findIndex(c=>c.order===l);if(d!==-1)return{action:"jump",targetIndex:d}}return{action:"none"}}function ka(t){let e=t?.options||{},o=Object.keys(e),i=n=>{let r=/(\d+)/.exec(n);if(!r)return;let l=Number(r[1]);return Number.isFinite(l)?l:void 0};return o.sort((n,r)=>{let l=i(n),d=i(r);return l!=null&&d!=null?l-d:l!=null?-1:d!=null?1:n.localeCompare(r)}),o.map(n=>e[n]).filter(n=>typeof n=="string"&&n.trim().length>0)}function Ra(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 Ta(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 mr(t){return Ta(t?.borderwidth)??1}var Fa=({details:t,slide:e,appearance:o,selectedOptions:i,comment:n,onSelectOption:r,onCommentChange:l,onSubmit:d,canSubmit:c})=>{let y=t.styling||{},b=y.options||{},h=y.cta,f=yr(()=>ka(e),[e]),v=b.optionsSpacing??8,S=b.bulletSpacing??10,u=b.optionsHeight??44,m=hr(h?.container?.alignment);return ze(Mn,{children:[lt("div",{style:Bo(y.title?.textStyle?.margin),children:lt("div",{style:{...Fe(y.title?.textStyle),color:y.title?.textStyle?.color||"#111827",fontSize:y.title?.textStyle?.fontSize||20,lineHeight:1.3,fontWeight:y.title?.textStyle?.fontDecoration?.includes("bold")?"bold":700},children:e.title||e.question||t.name||"Survey"})}),(e.subtitle||y.subtitle?.textStyle)&&lt("div",{style:Bo(y.subtitle?.textStyle?.margin),children:lt("div",{style:{...Fe(y.subtitle?.textStyle),color:y.subtitle?.textStyle?.color||"#6b7280",fontSize:y.subtitle?.textStyle?.fontSize||14,lineHeight:1.35},children:e.subtitle||""})}),f.length>0&&(()=>{let g="__others__",C=e.additionalComment?.placeholder?.trim()||"Others",I=f.map(E=>({value:E,label:E}));e.additionalComment?.enabled&&I.push({value:g,label:C});let z=i.includes(g);return ze(Mn,{children:[lt("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:v},children:I.map(({value:E,label:w},D)=>{let _=i.includes(E),P=_?b.selectedOptions:b.nonSelectedOptions,H=mr(P?.textStyle),B=Ra(b.optionListStyle,D),a=b.optionListStyle,x=a==="bulleted",s=a==="number"||a==="alphabet"||a==="roman";return ze("button",{onClick:()=>r(E),style:{width:"100%",boxSizing:"border-box",height:u,borderRadius:Ue(b.cornerRadius),border:`${H}px solid ${P?.colors?.border||"#e5e7eb"}`,background:P?.colors?.background||"#ffffff",color:P?.colors?.text||"#111827",cursor:"pointer",display:"flex",alignItems:"center",gap:S,paddingLeft:14,paddingRight:14,textAlign:"left",...Fe(P?.textStyle)},"aria-pressed":_,children:[x?lt("span",{"aria-hidden":!0,style:{width:18,height:18,borderRadius:"50%",border:`2px solid ${P?.colors?.text||"#111827"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:_&&lt("span",{style:{width:10,height:10,borderRadius:"50%",backgroundColor:P?.colors?.text||"#111827"}})}):s?lt("span",{"aria-hidden":!0,style:{fontSize:16,fontWeight:600,color:P?.colors?.text||"#111827",marginRight:2},children:B}):null,lt("span",{style:{flex:1,minWidth:0},children:w})]},`${E}-${D}`)})}),z&&lt("textarea",{value:n,onChange:E=>l(E.target.value),placeholder:e.additionalComment?.placeholder||"Type your response...",style:{marginTop:10,width:"100%",boxSizing:"border-box",minHeight:72,resize:"none",overflowY:"auto",border:`${mr(b.additionalComments?.textStyle)}px solid ${b.additionalComments?.colors?.border||"#e5e7eb"}`,background:b.additionalComments?.colors?.background||"#ffffff",color:b.additionalComments?.colors?.text||"#111827",borderRadius:Ue(b.cornerRadius),padding:"12px",...Fe(b.additionalComments?.textStyle)}})]})})(),lt("div",{style:{position:"sticky",bottom:0,marginTop:12,paddingTop:10,paddingBottom:6,background:o?.backgroundColor||"#ffffff"},children:lt("div",{style:{marginTop:h?.margin?.top??0,marginBottom:h?.margin?.bottom??0,marginLeft:h?.margin?.left??0,marginRight:h?.margin?.right??0,display:"flex",justifyContent:m},children:lt("button",{onClick:d,disabled:!c,style:{width:h?.container?.ctaFullWidth?"100%":h?.container?.ctaWidth??"100%",height:h?.container?.height??44,border:`${h?.container?.borderWidth??0}px solid ${h?.container?.borderColor||"transparent"}`,background:h?.container?.backgroundColor||"#111827",color:h?.text?.color||"#ffffff",borderRadius:Ue(h?.cornerRadius),fontFamily:An(h?.text?.fontFamily),fontSize:h?.text?.fontSize||14,fontWeight:h?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:c?"pointer":"not-allowed",opacity:c?1:.6,padding:"0 16px"},children:e.submitButtonText||"Submit"})})})]})},za=({details:t,onDone:e})=>{let i=(t.styling||{}).thankyouPage||{},n=i.cta,r=hr(n?.container?.alignment),l=t.thankYouImage?.endsWith(".json"),[d,c]=re(null);return Ln(()=>{l&&t.thankYouImage?fetch(t.thankYouImage).then(y=>y.json()).then(y=>c(y)).catch(y=>console.error("AppStorys Survey: Error loading Thank You Lottie:",y)):c(null)},[t.thankYouImage,l]),ze(Mn,{children:[t.thankYouImage&&lt("div",{style:{display:"flex",justifyContent:"center",marginTop:8},children:l?d?lt(Sa,{animationData:d,loop:!0,style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80}}):lt("div",{style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80}}):lt("img",{src:t.thankYouImage,alt:"thank you",style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80,objectFit:"cover",borderRadius:10}})}),lt("div",{style:{...Bo(i.title?.textStyle?.margin)},children:lt("div",{style:{...Fe(i.title?.textStyle),color:i.title?.textStyle?.color||"#111827",fontSize:i.title?.textStyle?.fontSize||20,lineHeight:1.3,fontWeight:i.title?.textStyle?.fontDecoration?.includes("bold")?"bold":700},children:t.thankYouTitle||"Thank you"})}),lt("div",{style:{...Bo(i.subtitle?.textStyle?.margin)},children:lt("div",{style:{...Fe(i.subtitle?.textStyle),color:i.subtitle?.textStyle?.color||"#6b7280",fontSize:i.subtitle?.textStyle?.fontSize||14,lineHeight:1.35},children:t.thankYouText||""})}),(t.thankYouButtonText||n)&&lt("div",{style:{marginTop:n?.margin?.top??14,marginBottom:n?.margin?.bottom??0,marginLeft:n?.margin?.left??0,marginRight:n?.margin?.right??0,display:"flex",justifyContent:r},children:lt("button",{onClick:e,style:{width:n?.container?.ctaFullWidth?"100%":n?.container?.ctaWidth??"auto",height:n?.container?.height??40,border:`${n?.container?.borderWidth??0}px solid ${n?.container?.borderColor||"transparent"}`,background:n?.container?.backgroundColor||"#111827",color:n?.text?.color||"#ffffff",borderRadius:Ue(n?.cornerRadius),fontFamily:An(n?.text?.fontFamily),fontSize:n?.text?.fontSize||14,fontWeight:n?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:"pointer",padding:"0 16px"},children:t.thankYouButtonText||"Done"})})]})},Ia=()=>{let t=xt("SUR"),e=A(R=>R.isVisible),o=A(R=>R.campaigns),i=A(R=>R.allCampaigns),n=A(R=>R.currentScreen),r=t??(()=>{let R=(n||"").trim().toLowerCase(),$=[...o||[],...i||[]].find(N=>{if(!N||N.campaign_type!=="SUR")return!1;let V=!!(N.trigger_event??N.trigger);if(!(N.display_trigger!==!1&&!V))return!1;let q=(N.screen||"").trim().toLowerCase();return!q||q===R});if($)try{return Rt($)}catch{return $}})(),[l,d]=re(!1),[c,y]=re(!1),[b,h]=re(0),[f,v]=re([]),[S,u]=re(""),[m,g]=re({}),[C,I]=re(!1),z=xa(null);Ln(()=>{if(!r?.id||z.current===r.id)return;z.current=r.id,d(!1),y(!1),h(0),v([]),u(""),g({}),I(!1);let R=r.details?.styling?.appearance?.displayDelay??0,$=globalThis.setTimeout(()=>{y(!0);let N=r.details?.id,V=fr(r.details),O=V.length>0?V[0].id:void 0;G("viewed",r.id,{survey_id:N,slide_id:O})},Math.max(0,R)*1e3);return()=>globalThis.clearTimeout($)},[r?.id]);let E=yr(()=>r?fr(r.details):[],[r]),w=E[b];if(Ln(()=>{if(!w)return;let R=m[w.id];v(R?.options??[]),u(R?.comment??"")},[w?.id]),!r||!e||l||!c)return null;let D=r.details,_=D.styling||{},P=_.appearance||{},H=P.backdropColor||"#000000",B=va(P.backdropOpacity),a=w?.multipleSelection!==!1&&w?.isMultiSelect!==!1&&_.options?.multipleSelection!==!1,x=R=>{v(a?$=>$.includes(R)?$.filter(N=>N!==R):[...$,R]:$=>$[0]===R?[]:[R])},s=async(R,$)=>{let N=E.map(et=>({slide_id:et.id,order:et.order,title:et.title,question:et.question,selected_options:R[et.id]?.options,comment:R[et.id]?.comment})),V=r.id,O=[];for(let et of E){let rt=R[et.id]?.options||[];for(let k of rt){let L=Object.entries(et.options||{}).find(([,X])=>String(X)===String(k));L&&O.push(L[0])}}let q=N.map(et=>et.comment).filter(Boolean).join(" || ")||"",Z=D.id||V;G("survey captured",Z,{survey_id:D.id,slide_id:$,selected_options:O,otherText:q}),_.content?.isThankyouPage!==!1?I(!0):d(!0)},p=async()=>{if(!w||f.length===0)return;let R={...m,[w.id]:{options:f,comment:S}};g(R);let $=[];if(w.options)for(let q of f){let Z=Object.entries(w.options).find(([,it])=>String(it)===String(q));Z&&$.push(Z[0])}try{let q=r.id,Z=D.id||q;G("survey captured",Z,{survey_id:D.id,slide_id:w.id,selected_options:$,otherText:S||""})}catch(q){console.warn("Error sending per-slide survey captured",q)}let N=f.includes("__others__"),V={action:"none"};for(let q of w.logic||[]){let Z=q.selectOption||[];if(Z.length===0)continue;let it=Z.some(k=>$.includes(k)),et=Z.some(k=>f.includes(k)),rt=N&&Z.some(k=>k==="others"||k==="__others__");if(!(!it&&!et&&!rt)&&q.redirectTo){let k=wa(q.redirectTo,E);if(k.action!=="none"){V=k;break}}}if(V.action==="thankyou"){await s(R,w.id);return}if(V.action==="jump"){h(V.targetIndex);return}if(b>=E.length-1){await s(R,w.id);return}h(q=>Math.min(q+1,E.length-1))},M=()=>{let R=D.thankYouButtonConfig;if(R?.enabled&&R.redirectUrl){try{let $=String(R.redirectUrl||"").trim();if($&&!$.startsWith("http")&&wt($)){d(!0);return}}catch($){console.warn("revealCampaignFromLink error",$)}try{globalThis.open(R.redirectUrl,"_blank")}catch{}}d(!0)},T=async()=>{try{let R=r?.id,$=D?.id,N=w?.id;await G("SurveyDismissed",R,{survey_id:$,slide_id:N})}catch(R){console.warn("Error sending SurveyDismissed",R)}finally{d(!0)}};return w?ze("div",{style:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"flex-end",alignItems:"flex-end",padding:12,pointerEvents:"none"},children:[lt("div",{"aria-hidden":!0,style:{position:"absolute",inset:0,background:Ca(H,B)}}),ze("div",{style:{position:"relative",width:"min(420px, 92vw)",maxWidth:"92vw",minWidth:"320px",maxHeight:"80vh",overflow:"hidden",backgroundColor:P.backgroundColor||"#ffffff",borderRadius:Ue(P.cornerRadius),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:[lt("style",{children:`
92
134
  .appstorys-survey-scroll {
93
135
  scrollbar-width: none; /* Firefox */
94
136
  -ms-overflow-style: none; /* IE/Edge */
@@ -98,5 +140,11 @@ var Yi=Object.defineProperty;var Nt=(t,e)=>()=>(t&&(e=t(t=0)),e);var Qi=(t,e)=>{
98
140
  height: 0;
99
141
  display: none; /* Chrome/Safari */
100
142
  }
101
- `}),T.crossButton?.enabled&&rt(Lt,{config:T.crossButton,onPress:_,style:{top:T.crossButton?.margin?.top??10,right:T.crossButton?.margin?.right??10}}),rt("div",{className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingRight:2},children:w?rt(Ls,{details:d,onDone:S}):rt(Ps,{details:d,slide:R,appearance:l,selectedOption:g,comment:f,onSelectOption:B,onCommentChange:b,onSubmit:C,canSubmit:g!=null})})]})]}):null},_s=Ds;var rn=class{state="uninitialized";navigateToScreen;async initialize(e){let{appId:o,accountId:i,userId:n}=e;if(this.navigateToScreen=e.navigateToScreen,this.state!=="initializing"){if(this.state==="initialized"){let r=F.getState();if(r.isAnonymousUser&&n&&n.trim()!==""){console.log("AppStorys: Reconciling anonymous user with identified user..."),await this.reconcileUser(r.userId,n,o,i);return}if(r.appId===o&&r.accountId===i&&r.userId===n)return}this.state="initializing";try{let r,s;if(!n||n.trim()==="")r=await Pn(),s=!0;else{let m=await Ao();m&&m!==n&&console.log("AppStorys: Found previous anonymous user, will reconcile after verification."),r=n,s=!1}if(!await Et(i,o,r)){this.state="error";return}if(!s){let m=await Ao();m&&m!==r&&(await je(m,r),await Bo())}try{let m=await dt(),g=e.baseUrl||"https://users.appstorys.co";fetch(`${g}/v2/${i}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...m?{Authorization:`Bearer ${m}`}:{}},body:JSON.stringify({user_id:r,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})}).then(async v=>{if(v.ok)try{let f=await v.json(),b=F.getState();if(typeof f.screen_capture_enabled<"u"){let h=!!f.screen_capture_enabled;console.info("AppStorys: track-user-res returned screen_capture_enabled=",h),b.setScreenCaptureEnabled(h)}}catch{}}).catch(v=>console.warn("track-user-res (init) failed",v))}catch(m){console.warn("track-user-res (init) setup failed",m)}let{campaigns:c,version:u}=await To(i);try{Tn(c)}catch(m){console.warn("Failed to preload campaign fonts",m)}let x=F.getState();x.setAppId(o),x.setAccountId(i),x.setUserId(r),x.setIsAnonymousUser(s),x.setBaseUrl(e.baseUrl),x.setTrackingUrl(e.trackingUrl),x.saveAllCampaigns(c),x.setCampaignVersion(u);try{F.getState().screenCaptureEnabled&&(await Promise.resolve().then(()=>(ji(),Oi))).mountScreenCaptureButton()}catch(m){console.warn("Failed to mount screen capture button",m)}An.setup(),zo.setup(),this.state="initialized"}catch(r){this.state="error",console.error("AppStorys initialization failed:",r)}}}async reconcileUser(e,o,i,n){try{if(!await Et(n,i,o)){console.error("AppStorys: Failed to verify identified user account during reconciliation.");return}if(!await je(e,o)){console.error("AppStorys: Failed to reconcile anonymous and identified users.");return}await Bo();let a=F.getState();a.setUserId(o),a.setIsAnonymousUser(!1)}catch(r){console.error("AppStorys: Error during user reconciliation:",r)}}async trackScreen(e){return await this.ensureInitialized(),vo(e)}async trackEvent(e,o,i){return await this.ensureInitialized(),H(e,o,i)}async setUserProperties(e){return await this.ensureInitialized(),wo(e)}handleLink(e){if(e){if(typeof e=="string"){try{if(!e.startsWith("http")&&ht(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(ht(e.value))return}catch{}this.navigateToScreen?.(e.value)}}}get visibility(){return F.getState().isVisible}set visibility(e){zo.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 Oe(e)}},jp=new rn;export{jp as AppStorys,ar as Banner,fs as BottomSheet,Fs as Csat,xr as Floater,ur as Pip,fn as SdkState,ts as Story,_s as Survey,cs as Tooltip,rs as Widget,Oe as personalizeText};
143
+ `}),_.crossButton?.enabled&&lt(Ft,{config:_.crossButton,onPress:T,style:{top:_.crossButton?.margin?.top??10,right:_.crossButton?.margin?.right??10}}),lt("div",{className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingRight:2},children:C?lt(za,{details:D,onDone:M}):lt(Fa,{details:D,slide:w,appearance:P,selectedOptions:f,comment:S,onSelectOption:x,onCommentChange:u,onSubmit:p,canSubmit:f.length>0})})]})]}):null},Ba=Ia;import{useEffect as Wa,useState as Oa,useRef as Na}from"react";ot();import{useEffect as Lo,useState as En,useRef as La}from"react";import*as Le from"lottie-react";import{Fragment as Ea,jsx as _t,jsxs as Be}from"react/jsx-runtime";var Ma=Le.default?.default??Le.default??Le.Lottie??Le,br=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},Aa=(t,e,o)=>{if(!t)return;if(e){let r=o?._variantId||o?.details?.id;G("clicked",e,r?{variant_id:r}:void 0)}let i=(t.url||"").trim(),n=(t.value||"").trim();if(n&&!n.startsWith("http"))try{if(wt(n))return}catch{}if(i){try{window.open(i,"_blank")}catch{}return}if(n)try{window.open(n,"_blank")}catch{}},xr=({campaign:t,onDismiss:e})=>{let[o,i]=En(typeof window<"u"?window.innerWidth:1024),[n,r]=En(null),[l,d]=En(!0),c=La(null);Lo(()=>{if(typeof window>"u")return;let O=()=>i(window.innerWidth);window.addEventListener("resize",O);let q=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("resize",O),document.body.style.overflow=q}},[]);let{details:y}=t,b=y?.modals?.[0],h=b?.content||{},f=b?.styling||{},v=h?.chooseMediaType||b?.chooseMediaType,S=v?.type,u=v?.url;if(Lo(()=>{S==="lottie"&&u?(r(null),fetch(u).then(O=>O.json()).then(O=>r(O)).catch(O=>console.error("Error fetching Lottie in ModalWithCta:",O))):r(null)},[S,u]),Lo(()=>{c.current&&(c.current.muted=l)},[l]),Lo(()=>{let O=c.current;if(!O||S!=="video")return;O.muted=!1;let q=O.play();q!==void 0&&q.then(()=>{d(!1)}).catch(()=>{O.muted=!0,d(!0),O.play().catch(()=>{})})},[u,S]),!b)return null;let m=f.appearance||{},g=f.crossButton,C=m.backdrop?.color||"rgba(0, 0, 0, 0.4)",I=m.backdrop?.opacity!==void 0&&m.backdrop?.opacity!==null?m.backdrop.opacity>1?m.backdrop.opacity/100:m.backdrop.opacity:0,z=m.enableBackdrop!==!1,E=m.dimension?.width!==void 0&&m.dimension?.width!==null&&m.dimension.width>0?m.dimension.width:300,w=o>=768,D=w?E*1.4:E,_=Math.min(D,o*.9),P=m.cornerRadius||{},H=m.backgroundColor||"#FFFFFF",B=h.titleText||"",a=h.subtitleText||"",x=h.primaryCtaText||"",s=h.secondaryCtaText||"",p=h.primaryCtaRedirection,M=h.secondaryCtaRedirection,T=f.title||{},R=f.subTitle||{},$=f.primaryCta||{},N=f.secondaryCta||{},V=(O,q,Z,it=!1)=>{if(!O||O.trim()==="")return null;let et=q?.container||{},rt=q?.cornerRadius||{},k=q?.margin||{},L=q?.text||{},X=kt=>kt==="left"?"flex-start":kt==="right"?"flex-end":"center",ht=et.ctaWidth,U=w&&ht?ht*1.4:ht,W=et.height||40,tt=w?W*1.2:W,dt=rt.topLeft!==void 0&&rt.topLeft>=0?rt.topLeft:8,St=rt.topRight!==void 0&&rt.topRight>=0?rt.topRight:8,yt=rt.bottomRight!==void 0&&rt.bottomRight>=0?rt.bottomRight:8,st=rt.bottomLeft!==void 0&&rt.bottomLeft>=0?rt.bottomLeft:8;return _t("div",{style:{display:"flex",justifyContent:X(et.alignment),width:it?"auto":"100%",flex:it?1:void 0,marginTop:k.top!==void 0&&k.top>=0?k.top:0,marginBottom:k.bottom!==void 0&&k.bottom>=0?k.bottom:0,marginLeft:k.left!==void 0&&k.left>=0?k.left:0,marginRight:k.right!==void 0&&k.right>=0?k.right:0,boxSizing:"border-box"},children:_t("button",{style:{width:it||et.ctaFullWidth?"100%":U?`${U}px`:"auto",height:tt,backgroundColor:et.backgroundColor||"#FE6B35",color:L.color||"#FFFFFF",border:`${et.borderWidth||0}px solid ${et.borderColor||"transparent"}`,borderRadius:`${dt}px ${St}px ${yt}px ${st}px`,fontSize:L.fontSize||14,fontFamily:gt(L.fontFamily)||"Arial",fontWeight:L.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:L.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:L.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px",outline:"none",boxSizing:"border-box"},onClick:()=>Aa(Z,t?.id,t),children:Zt(O)})})};return Be(Ea,{children:[_t("style",{children:`
144
+ .appstorys-modal-scroll::-webkit-scrollbar { display: none; }
145
+ .appstorys-modal-scroll { scrollbar-width: none; }
146
+ `}),_t("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:z?C:"transparent",opacity:z?I:1,zIndex:999998,transition:"opacity 0.3s ease"}}),Be("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:_,maxWidth:"95vw",zIndex:999999,overflow:"visible"},children:[(g?.enabled??!0)&&_t(Ft,{config:g||{enabled:!0},onPress:O=>{O&&typeof O.stopPropagation=="function"&&O.stopPropagation(),e()},style:{position:"absolute",zIndex:1e7,top:g?.margin?.top!==void 0&&g.margin?.top>=0?g.margin.top:8,right:g?.margin?.right!==void 0&&g.margin?.right>=0?g.margin.right:8}}),Be("div",{style:{width:"100%",backgroundColor:H,borderTopLeftRadius:P.topLeft!==void 0&&P.topLeft>=0?P.topLeft:0,borderTopRightRadius:P.topRight!==void 0&&P.topRight>=0?P.topRight:0,borderBottomLeftRadius:P.bottomLeft!==void 0&&P.bottomLeft>=0?P.bottomLeft:0,borderBottomRightRadius:P.bottomRight!==void 0&&P.bottomRight>=0?P.bottomRight:0,overflow:"hidden",boxShadow:"0 8px 32px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",maxHeight:"90vh"},children:[Be("div",{className:"appstorys-modal-scroll",style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",alignItems:"center",minHeight:0},children:[u&&(S==="image"||!S)&&_t("img",{src:u,alt:"",style:{width:"100%",display:"block"}}),u&&S==="video"&&Be("div",{style:{position:"relative",width:"100%"},children:[_t("video",{ref:c,src:u,autoPlay:!0,loop:!0,muted:l,playsInline:!0,controls:!1,style:{width:"100%",display:"block"}}),_t(pe,{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(),d(q=>!q)},type:l?"mute":"unmute",enabled:!0,style:{position:"absolute",zIndex:1e7,bottom:12,left:12,borderRadius:"50%"}})]}),u&&S==="lottie"&&n&&(()=>{let O=n.w,q=n.h,Z=O&&q&&O>0?q/O:void 0,it=_,et=Z?Math.round(it*Z):void 0;return _t(Ma,{animationData:n,loop:!0,autoplay:!0,style:{width:it,height:et,display:"block"}})})(),B.trim()!==""&&_t("div",{style:{width:"100%",padding:"12px 16px 0 16px",color:T.color||"#000000",fontSize:T.fontSize||26,fontFamily:gt(T.fontFamily)||"Helvetica",fontWeight:T.fontDecoration?.includes("bold")?"bold":"600",fontStyle:T.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:T.fontDecoration?.includes("underline")?"underline":"none",textAlign:br(T.textAlign)||"center",boxSizing:"border-box"},children:Zt(B)}),a.trim()!==""&&_t("div",{style:{width:"100%",padding:"4px 16px 0 16px",color:R.color||"#000000",fontSize:R.fontSize||20,fontFamily:gt(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:br(R.textAlign)||"center",boxSizing:"border-box"},children:Zt(a)})]}),(x.trim()!==""||s.trim()!=="")&&Be("div",{style:{flexShrink:0,width:"100%",padding:"0 12px 12px 12px",boxSizing:"border-box",display:"flex",flexDirection:x.trim()!==""&&s.trim()!==""?"row":"column",gap:"8px",justifyContent:"center"},children:[V(x,$,p,x.trim()!==""&&s.trim()!==""),V(s,N,M,x.trim()!==""&&s.trim()!=="")]})]})]})]})};import{useEffect as Mo,useState as Dn,useRef as Da}from"react";import*as Me from"lottie-react";import{Fragment as $a,jsx as se,jsxs as Ao}from"react/jsx-runtime";var _a=Me.default?.default??Me.default??Me.Lottie??Me,Pa=(t,e,o)=>{if(!t)return;if(e){let r=o?._variantId||o?.details?.id;G("clicked",e,r?{variant_id:r}:void 0)}let i=(t.url||"").trim(),n=(t.value||"").trim();if(n&&!n.startsWith("http"))try{if(wt(n))return}catch{}if(i){try{window.open(i,"_blank")}catch{}return}if(n)try{window.open(n,"_blank")}catch{}},Sr=({campaign:t,onDismiss:e})=>{let[o,i]=Dn(typeof window<"u"?window.innerWidth:1024),[n,r]=Dn(null),[l,d]=Dn(!0),c=Da(null);Mo(()=>{if(typeof window>"u")return;let B=()=>i(window.innerWidth);window.addEventListener("resize",B);let a=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("resize",B),document.body.style.overflow=a}},[]);let{details:y}=t,b=y?.modals?.[0],h=b?.chooseMediaType,f=b?.styling||{},v=b?.redirection,S=h?.type,u=h?.url;if(Mo(()=>{S==="lottie"&&u?(r(null),fetch(u).then(B=>B.json()).then(B=>r(B)).catch(B=>console.error("Error fetching Lottie in MediaOnlyModal:",B))):r(null)},[S,u]),Mo(()=>{c.current&&(c.current.muted=l)},[l]),Mo(()=>{let B=c.current;if(!B||S!=="video")return;B.muted=!1;let a=B.play();a!==void 0&&a.then(()=>{d(!1)}).catch(()=>{B.muted=!0,d(!0),B.play().catch(()=>{})})},[u,S]),!b||!h||!u)return null;let m=f.appearance||{},g=f.crossButton,C=m.backdrop?.color||"rgba(0, 0, 0, 0.4)",I=m.backdrop?.opacity!==void 0&&m.backdrop?.opacity!==null?m.backdrop.opacity>1?m.backdrop.opacity/100:m.backdrop.opacity:0,z=m.enableBackdrop!==!1,E=m.dimension?.width!==void 0&&m.dimension?.width!==null&&m.dimension.width>0?m.dimension.width:300,D=o>=768?E*1.4:E,_=Math.min(D,o*.9),P=m.cornerRadius||{},H=m.backgroundColor||(S==="lottie"?"transparent":"#FFFFFF");return Ao($a,{children:[se("style",{children:`
147
+ .appstorys-media-modal-scroll::-webkit-scrollbar { display: none; }
148
+ .appstorys-media-modal-scroll { scrollbar-width: none; }
149
+ `}),se("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:z?C:"transparent",opacity:z?I:1,zIndex:999998,transition:"opacity 0.3s ease"}}),Ao("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:_,maxWidth:"95vw",zIndex:999999,overflow:"visible"},children:[(g?.enabled??!0)&&se(Ft,{config:g||{enabled:!0},onPress:B=>{B&&typeof B.stopPropagation=="function"&&B.stopPropagation(),e()},style:{position:"absolute",zIndex:1e7,top:g?.margin?.top!==void 0&&g.margin?.top>=0?g.margin.top:8,right:g?.margin?.right!==void 0&&g.margin?.right>=0?g.margin.right:8}}),se("div",{className:"appstorys-media-modal-scroll",style:{width:"100%",backgroundColor:H,borderTopLeftRadius:P.topLeft!==void 0&&P.topLeft>=0?P.topLeft:0,borderTopRightRadius:P.topRight!==void 0&&P.topRight>=0?P.topRight:0,borderBottomLeftRadius:P.bottomLeft!==void 0&&P.bottomLeft>=0?P.bottomLeft:0,borderBottomRightRadius:P.bottomRight!==void 0&&P.bottomRight>=0?P.bottomRight:0,overflow:"hidden",boxShadow:H==="transparent"?"none":"0 8px 32px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",alignItems:"center",maxHeight:"90vh",overflowY:"auto"},children:Ao("div",{onClick:()=>Pa(v,t?.id,t),style:{width:"100%",cursor:v?"pointer":"default",minHeight:0},children:[u&&(S==="image"||!S)&&se("img",{src:u,alt:"",style:{width:"100%",display:"block"}}),u&&S==="video"&&Ao("div",{style:{position:"relative",width:"100%"},children:[se("video",{ref:c,src:u,autoPlay:!0,loop:!0,muted:l,playsInline:!0,controls:!1,style:{width:"100%",display:"block"}}),se(pe,{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:B=>{B.stopPropagation(),d(a=>!a)},type:l?"mute":"unmute",enabled:!0,style:{position:"absolute",zIndex:1e7,bottom:12,left:12,borderRadius:"50%"}})]}),u&&S==="lottie"&&n&&(()=>{let B=n.w,a=n.h,x=B&&a&&B>0?a/B:void 0,s=_,p=x?Math.round(s*x):void 0;return se(_a,{animationData:n,loop:!0,autoplay:!0,style:{width:s,height:p,display:"block"}})})()]})})]})]})};import{jsx as Cr}from"react/jsx-runtime";var ja=()=>{let t=xt("MOD"),e=A(v=>v.campaigns),o=A(v=>v.allCampaigns),i=A(v=>v.currentScreen),n=t??(()=>{let v=(i||"").trim().toLowerCase(),S=[...e||[],...o||[]].find(u=>{if(!u||u.campaign_type!=="MOD")return!1;let m=!!(u.trigger_event??u.trigger);if(!(u.display_trigger!==!1&&!m))return!1;let C=(u.screen||"").trim().toLowerCase();return!C||C===v});if(S)try{return Rt(S)}catch{return S}})(),r=A(v=>v.isVisible),[l,d]=Oa(!1),c=Na(null);Wa(()=>{if(n?.id&&c.current!==n.id){c.current=n.id,d(!1);let v=n._variantId||n.details?.id,S=v?{variant_id:v}:void 0;G("viewed",n.id,S)}},[n?.id]);let y=v=>{try{let S=A.getState(),m=(S.trackedEvents||[]).filter(g=>g!==v);S.setTrackedEvents(m)}catch{}};if(!n||l||!r)return null;let b=()=>{n?.id&&y(`viaAppStorys${n.id}`),d(!0)},h=n.details?.modal_type||n.details?.modals?.[0]?.modal_type||"";return h==="full-page-modal"||h==="media-only-modal"?Cr(Sr,{campaign:n,onDismiss:b}):Cr(xr,{campaign:n,onDismiss:b})};import{jsx as qa}from"react/jsx-runtime";var Ha=({id:t,children:e})=>qa("div",{"data-as-id":t,style:{display:"contents"},children:e});var _n=class{state="uninitialized";navigateToScreen;async initialize(e){let{appId:o,accountId:i,userId:n}=e;if(this.navigateToScreen=e.navigateToScreen,this.state!=="initializing"){if(this.state==="initialized"){let r=A.getState();if(r.isAnonymousUser&&n&&n.trim()!==""){console.log("AppStorys: Reconciling anonymous user with identified user..."),await this.reconcileUser(r.userId,n,o,i);return}if(r.appId===o&&r.accountId===i&&r.userId===n)return}this.state="initializing";try{let r,l;if(!n||n.trim()==="")r=await yi(),l=!0;else{let h=await nn();h&&h!==n&&console.log("AppStorys: Found previous anonymous user, will reconcile after verification."),r=n,l=!1}if(!await Ht(i,o,r)){this.state="error";return}if(!l){let h=await nn();h&&h!==r&&(await go(h,r),await on())}try{let h=await bt(),f=e.baseUrl||"https://users.appstorys.co";fetch(`${f}/v2/${i}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...h?{Authorization:`Bearer ${h}`}:{}},body:JSON.stringify({user_id:r,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})}).then(async v=>{if(v.ok)try{let S=await v.json(),u=A.getState();if(typeof S.screen_capture_enabled<"u"){let m=!!S.screen_capture_enabled;console.info("AppStorys: track-user-res returned screen_capture_enabled=",m),u.setScreenCaptureEnabled(m)}}catch{}}).catch(v=>console.warn("track-user-res (init) failed",v))}catch(h){console.warn("track-user-res (init) setup failed",h)}let{campaigns:c,version:y}=await Ko(i);try{ci(c)}catch(h){console.warn("Failed to preload campaign fonts",h)}let b=A.getState();b.setAppId(o),b.setAccountId(i),b.setUserId(r),b.setIsAnonymousUser(l),b.setBaseUrl(e.baseUrl),b.setTrackingUrl(e.trackingUrl),b.saveAllCampaigns(c),b.setCampaignVersion(y);try{A.getState().screenCaptureEnabled&&(await Promise.resolve().then(()=>(Fr(),Tr))).mountScreenCaptureButton()}catch(h){console.warn("Failed to mount screen capture button",h)}fi.setup(),en.setup(),this.state="initialized"}catch(r){this.state="error",console.error("AppStorys initialization failed:",r)}}}async reconcileUser(e,o,i,n){try{if(!await Ht(n,i,o)){console.error("AppStorys: Failed to verify identified user account during reconciliation.");return}if(!await go(e,o)){console.error("AppStorys: Failed to reconcile anonymous and identified users.");return}await on();let d=A.getState();d.setUserId(o),d.setIsAnonymousUser(!1)}catch(r){console.error("AppStorys: Error during user reconciliation:",r)}}async trackScreen(e){return await this.ensureInitialized(),Qo(e)}async trackEvent(e,o,i){return await this.ensureInitialized(),G(e,o,i)}async setUserProperties(e){return await this.ensureInitialized(),Go(e)}handleLink(e){if(e){if(typeof e=="string"){try{if(!e.startsWith("http")&&wt(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(wt(e.value))return}catch{}this.navigateToScreen?.(e.value)}}}get visibility(){return A.getState().isVisible}set visibility(e){en.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 Zt(e)}},Qg=new _n;export{Qg as AppStorys,Yr as Banner,ia as BottomSheet,ba as Csat,ss as Floater,ja as Modal,Zr as Pip,Qn as SdkState,js as Story,Ba as Survey,Zs as Tooltip,Ha as Trackable,Qs as Widget,rl as getCampaignVariantId,Kn as getVariantId,Ke as hasVariants,Zt as personalizeText,Rt as resolveCampaignVariant,Dr as selectVariantByWeight};
102
150
  //# sourceMappingURL=index.mjs.map