@appstorys/react-web 1.1.0 → 1.1.2

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.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var _i=Object.create;var Oe=Object.defineProperty;var $i=Object.getOwnPropertyDescriptor;var Wi=Object.getOwnPropertyNames;var Mi=Object.getPrototypeOf,Oi=Object.prototype.hasOwnProperty;var oe=(t,e)=>()=>(t&&(e=t(t=0)),e);var cn=(t,e)=>{for(var o in e)Oe(t,o,{get:e[o],enumerable:!0})},pn=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Wi(e))!Oi.call(t,n)&&n!==o&&Oe(t,n,{get:()=>e[n],enumerable:!(i=$i(e,n))||i.enumerable});return t};var je=(t,e,o)=>(o=t!=null?_i(Mi(t)):{},pn(e||!t||!t.__esModule?Oe(o,"default",{value:t,enumerable:!0}):o,t)),ji=t=>pn(Oe({},"__esModule",{value:!0}),t);var ot,fe=oe(()=>{"use strict";ot=class{static async getItem(e){try{return localStorage.getItem(e)}catch{return null}}static async setItem(e,o){try{localStorage.setItem(e,o)}catch{}}static async removeItem(e){try{localStorage.removeItem(e)}catch{}}}});function Pt(){return yo.getState().userId}async function lt(){return ot.getItem("access_token")}function gn(t){if(!t)return;let e=String(t||"").trim();if(e)return yo.getState().variantMappings?.[e]}var un,yo,F,et=oe(()=>{"use strict";un=require("zustand");fe();yo=(0,un.create)(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=yo});async function ne(){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 qe=oe(()=>{"use strict"});async function Vt(t,e,o){try{let i={account_id:t,app_id:e,user_id:o};if(await ot.getItem(yn))console.log("Device info already sent previously - skipping");else{let c=await ne();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 ot.setItem("access_token",u),await ot.setItem("refresh_token",x),i.attributes&&(await ot.setItem(yn,"true"),console.log("Device info sent flag set")),!0}return!1}catch(i){return console.error("Error when verifying AppStorys account",i),!1}}var yn,Ue=oe(()=>{"use strict";fe();qe();et();yn="device_info_sent"});async function ro(t,e){if(!e||e.length===0){console.info("AppStorys: identifyWidgetPositions called with empty positionList; skipping");return}let o=await lt();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 ki=oe(()=>{"use strict";et()});function so(t){return t&&(t.startsWith("widget_")?t:`widget_${t}`)}function Ti(){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=>so(String(o))).filter(o=>!!o)}catch{return[]}}function $r(t){try{let e=Ti();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};ce.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 Wr(t){return Le[t]||(Le[t]=[]),Le[t]}function Ri(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 Le,ce,Fi=oe(()=>{"use strict";et();Ue();ki();et();Le={};ce=class{static setup(e,o){let i=F.getState();i.setScreenCaptureEnabled(o),i.setCurrentScreen(e)}static addLayoutInfo(e,o,i){let n=Wr(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){Le[e]=[]}static getLayoutData(e){return Le[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=$r(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 lt(),a=Pt();if(!a)return console.warn("AppStorys: No userId"),!1;if(!s){let g=F.getState();g.accountId&&g.appId&&g.userId&&await Vt(g.accountId,g.appId,g.userId)&&(s=await lt())}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=Ri(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 Vt(g.accountId,g.appId,g.userId)){let f=await lt();f&&(m=await fetch(c,{method:"POST",headers:{Authorization:`Bearer ${f}`,Accept:"application/json"},body:Ri(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=>so(y.id)).filter(y=>!!y):v=g.map(h=>so(h)).filter(h=>!!h);let f=Ti(),b=Array.from(new Set([...v,...f]));console.info("AppStorys: identifyWidgetPositions will send",b.length,"positions (collected + server)",b),await ro(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=(ce.getLayoutData(n)||[]).map(a=>so(a.id)).filter(a=>!!a);console.info("AppStorys: AppStorysForceIdentifyPositions sending",s.length,"positions for",n,s);try{await ro(n,s),console.info("AppStorys: AppStorysForceIdentifyPositions completed")}catch(a){console.error("AppStorys: AppStorysForceIdentifyPositions error",a)}}}catch{}})()});var zi={};cn(zi,{mountScreenCaptureButton:()=>Ii});function Mr(){if(document.getElementById("appstorys-capture-styles"))return;let t=document.createElement("style");t.id="appstorys-capture-styles",t.innerHTML=`
1
+ "use strict";var Ur=Object.create;var jo=Object.defineProperty;var Yr=Object.getOwnPropertyDescriptor;var Gr=Object.getOwnPropertyNames;var Qr=Object.getPrototypeOf,Xr=Object.prototype.hasOwnProperty;var Ge=(t,e)=>()=>(t&&(e=t(t=0)),e);var ei=(t,e)=>{for(var o in e)jo(t,o,{get:e[o],enumerable:!0})},oi=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Gr(e))!Xr.call(t,i)&&i!==o&&jo(t,i,{get:()=>e[i],enumerable:!(n=Yr(e,i))||n.enumerable});return t};var ge=(t,e,o)=>(o=t!=null?Ur(Qr(t)):{},oi(e||!t||!t.__esModule?jo(o,"default",{value:t,enumerable:!0}):o,t)),Jr=t=>oi(jo({},"__esModule",{value:!0}),t);var kt,io=Ge(()=>{"use strict";kt=class{static async getItem(e){try{return localStorage.getItem(e)}catch{return null}}static async setItem(e,o){try{localStorage.setItem(e,o)}catch{}}static async removeItem(e){try{localStorage.removeItem(e)}catch{}}}});function fe(){return mn.getState().userId}async function At(){return kt.getItem("access_token")}function ii(t){if(!t)return;let e=String(t||"").trim();if(e)return mn.getState().variantMappings?.[e]}var ni,mn,P,bt=Ge(()=>{"use strict";ni=require("zustand");io();mn=(0,ni.create)(t=>({userId:"",appId:"",accountId:"",currentScreen:"",campaigns:[],allCampaigns:[],campaignVersion:2,trackedEvents:[],trackedEventMetadata:{},isVisible:!0,isAnonymousUser:!1,variantMappings:{},personalizationData:{},screenCaptureEnabled:!1,baseUrl:void 0,trackingUrl:void 0,saveCampaigns:e=>t({campaigns:e}),saveAllCampaigns:e=>t({allCampaigns:e}),setCampaignVersion:e=>t({campaignVersion:e}),setUserId:e=>t({userId:e}),setAppId:e=>t({appId:e}),setAccountId:e=>t({accountId:e}),setCurrentScreen:e=>t({currentScreen:e}),setAttributes:e=>t({attributes:e}),setTrackedEvents:e=>t({trackedEvents:e}),setTrackedEventMetadata:e=>t({trackedEventMetadata:e}),setVisibility:e=>t({isVisible:e}),setIsAnonymousUser:e=>t({isAnonymousUser:e}),setVariantMappings:e=>t({variantMappings:e}),setPersonalizationData:e=>t({personalizationData:e}),setScreenCaptureEnabled:e=>t({screenCaptureEnabled:e}),setBaseUrl:e=>t({baseUrl:e}),setTrackingUrl:e=>t({trackingUrl:e})}));P=mn});async function Qe(){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 Ho=Ge(()=>{"use strict"});async function Ae(t,e,o){try{let n={account_id:t,app_id:e,user_id:o};if(await kt.getItem(ci))console.log("Device info already sent previously - skipping");else{let d=await Qe();n.attributes={...d},console.log("First time verification - including device info in attributes")}let l=P.getState().baseUrl||"https://users.appstorys.co",c=await fetch(`${l}/${t}/validate-account`,{method:"POST",body:JSON.stringify(n),headers:{Accept:"application/json","Content-Type":"application/json"}});if(console.log("Verify account body",n),console.log("Verifying account",c.status,c.statusText),c.ok){let d=await c.json();console.log("Account verified",d);let{access_token:S,refresh_token:p}=d;if(S&&p)return await kt.setItem("access_token",S),await kt.setItem("refresh_token",p),n.attributes&&(await kt.setItem(ci,"true"),console.log("Device info sent flag set")),!0}return!1}catch(n){return console.error("Error when verifying AppStorys account",n),!1}}var ci,Vo=Ge(()=>{"use strict";io();Ho();bt();ci="device_info_sent"});async function cn(t,e){if(!e||e.length===0){console.info("AppStorys: identifyWidgetPositions called with empty positionList; skipping");return}let o=await At();if(!o){console.error("AppStorys: identifyWidgetPositions - access token not found");return}try{let n="https://backend.appstorys.co/api/v2/appinfo/identify-positions/";console.info("AppStorys: identifyWidgetPositions payload",{screen_name:t,position_list:e});let i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`,Accept:"application/json"},body:JSON.stringify({screen_name:t,position_list:e})});i.ok?console.info("AppStorys: identifyWidgetPositions OK"):console.error("AppStorys: identifyWidgetPositions failed",i.status,await i.text())}catch(n){console.error("AppStorys: identifyWidgetPositions error",n)}}var $r=Ge(()=>{"use strict";bt()});function un(t){return t&&(t.startsWith("widget_")?t:`widget_${t}`)}function la(){try{let t=P.getState().allCampaigns||[],e=[];return t.forEach(o=>{o&&o.position&&typeof o.position=="string"&&e.push(String(o.position));try{if(o&&o.campaign_type==="WID"&&o.details){let n=o.details;typeof n=="object"&&(n.id&&typeof n.id=="string"&&e.push(String(n.id)),n.variants&&typeof n.variants=="object"&&Object.values(n.variants).forEach(i=>{i&&i.id&&typeof i.id=="string"&&e.push(String(i.id))}))}}catch{}}),e.filter(o=>!!o).map(o=>un(String(o))).filter(o=>!!o)}catch{return[]}}function da(t){try{let e=la();if(!e||e.length===0)return[];let o=[];return e.forEach(n=>{let i=n.replace(/^widget_/,""),s=[`[data-as-id="${i}"]`,`#${i}`,`.${i}`,`[data-widget="${i}"]`],l=null;for(let c of s)if(l=document.querySelector(c),l)break;if(l){let c=l.getBoundingClientRect(),d={x:Math.round(c.left),y:Math.round(c.top),width:Math.round(c.width),height:Math.round(c.height),screenWidth:window.innerWidth,screenHeight:window.innerHeight};eo.addLayoutInfo(t,i,d),o.push(i)}}),console.info("AppStorys: mapServerPositionsToDOM mapped",o.length,"server positions to DOM elements",o),o}catch(e){return console.warn("AppStorys: mapServerPositionsToDOM error",e),[]}}function ca(t){return No[t]||(No[t]=[]),No[t]}function Nr(t,e,o,n){let i=new FormData,s=t.replace(/[^a-z0-9]/gi,"_"),l=`screenshot_${e}_${s}_${Date.now()}.png`,c=new File([n],l,{type:"image/png"});i.append("screenName",t),i.append("user_id",e),i.append("children",o),i.append("screenshot",c);try{console.groupCollapsed("AppStorys: FormData Payload Diagnostic"),console.info(" screenName:",t),console.info(" user_id:",e),console.info(" children:",JSON.parse(o)),console.info(" screenshot:",c.name,`(${c.size} bytes)`),console.groupEnd()}catch(d){console.warn("AppStorys: Could not run FormData diagnostics",d)}return i}var No,eo,Or=Ge(()=>{"use strict";bt();Vo();$r();bt();No={};eo=class{static setup(e,o){let n=P.getState();n.setScreenCaptureEnabled(o),n.setCurrentScreen(e)}static addLayoutInfo(e,o,n){let i=ca(e),s=i.findIndex(d=>d.id===o),l={...n,screenWidth:n.screenWidth||window.innerWidth,screenHeight:n.screenHeight||window.innerHeight},c={id:o,frame:l};s>=0?i[s]=c:i.push(c)}static collectElements(e){this.clearLayoutData(e);let o=document.querySelectorAll("[data-as-id]"),n=window.innerWidth,i=window.innerHeight,s=[];o.forEach(l=>{let c=l.getAttribute("data-as-id");if(c){s.push(c);let d=l.getBoundingClientRect();this.addLayoutInfo(e,c,{x:Math.round(d.left),y:Math.round(d.top),width:Math.round(d.width),height:Math.round(d.height),screenWidth:n,screenHeight:i})}}),console.info(`AppStorys: Identified ${o.length} elements:`,s)}static clearLayoutData(e){No[e]=[]}static getLayoutData(e){return No[e]||[]}static async takeScreenshot(e,o){try{if(!e)return console.error("AppStorys: Screen name is required"),!1;console.info("AppStorys: Starting takeScreenshot for",e),P.getState().setCurrentScreen(e),this.collectElements(e);try{let u=da(e);u&&u.length>0&&console.info("AppStorys: mapServerPositionsToDOM added",u.length,"elements")}catch{}await new Promise(u=>setTimeout(u,100));let i=window,s=null;if(typeof i.html2canvas!="function")try{await new Promise((u,C)=>{let h=document.createElement("script");h.src="https://html2canvas.hertzen.com/dist/html2canvas.min.js",h.onload=()=>u(),h.onerror=()=>C(new Error("Failed to load html2canvas")),document.head.appendChild(h)})}catch(u){console.warn("AppStorys: html2canvas load error",u)}if(typeof i.html2canvas=="function")try{let u=await i.html2canvas(document.documentElement,{useCORS:!0,allowTaint:!0,logging:!1,scale:window.devicePixelRatio||1});s=await new Promise(C=>u.toBlob(h=>C(h),"image/png"))}catch(u){console.warn("AppStorys: html2canvas capture failed (falling back to getDisplayMedia)",u),s=null}if(!s&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)try{let u=await navigator.mediaDevices.getDisplayMedia({video:!0}),C=document.createElement("video");C.srcObject=u,await C.play();let h=document.createElement("canvas");h.width=C.videoWidth||window.innerWidth,h.height=C.videoHeight||window.innerHeight;let g=h.getContext("2d");g&&g.drawImage(C,0,0,h.width,h.height),s=await new Promise(b=>h.toBlob(m=>b(m),"image/png")),C.pause(),u.getTracks().forEach(b=>b.stop())}catch(u){console.warn("AppStorys: getDisplayMedia capture failed",u)}if(!s)return console.warn("AppStorys: Capture failed \u2014 no blob generated"),!1;let l=await At(),c=fe();if(!c)return console.warn("AppStorys: No userId"),!1;if(!l){let u=P.getState();u.accountId&&u.appId&&u.userId&&await Ae(u.accountId,u.appId,u.userId)&&(l=await At())}if(!l)return console.warn("AppStorys: No token available"),!1;let d="https://backend.appstorys.co/api/v1/appinfo/identify-elements/",S=JSON.stringify(this.getLayoutData(e)||[]),p=Nr(e,c,S,s);console.info("AppStorys: Sending identify-elements with payload size:",S.length);let y=await fetch(d,{method:"POST",headers:{Authorization:`Bearer ${l}`,Accept:"application/json"},body:p});if(y.status===401){console.warn("AppStorys: 401 response \u2014 retrying once");let u=P.getState();if(u.accountId&&u.appId&&u.userId&&await Ae(u.accountId,u.appId,u.userId)){let h=await At();h&&(y=await fetch(d,{method:"POST",headers:{Authorization:`Bearer ${h}`,Accept:"application/json"},body:Nr(e,c,S,s)}))}}if(!y.ok){let u=await y.text();return console.error("AppStorys: identify-elements failed",y.status,u),!1}console.info("AppStorys: identify-elements success \u2713");try{let u=o,C=[];!u||u.length===0?C=(this.getLayoutData(e)||[]).map(g=>un(g.id)).filter(g=>!!g):C=u.map(h=>un(h)).filter(h=>!!h),console.info("AppStorys: identifyWidgetPositions will send",C.length,"positions (DOM-verified)",C),await cn(e,C)}catch(u){console.warn("AppStorys: identifyWidgetPositions failed",u)}return!0}catch(n){return console.error("AppStorys: takeScreenshot error",n),!1}}};(function(){try{let e=window;e.AppStorysForceIdentifyPositions=async o=>{let n=P.getState(),i=o||n.currentScreen;if(!i){console.warn("AppStorys: AppStorysForceIdentifyPositions - no screen name available");return}let l=(eo.getLayoutData(i)||[]).map(c=>un(c.id)).filter(c=>!!c);console.info("AppStorys: AppStorysForceIdentifyPositions sending",l.length,"positions for",i,l);try{await cn(i,l),console.info("AppStorys: AppStorysForceIdentifyPositions completed")}catch(c){console.error("AppStorys: AppStorysForceIdentifyPositions error",c)}}}catch{}})()});var qr={};ei(qr,{mountScreenCaptureButton:()=>jr});function ua(){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 @@
11
11
  border-radius: 50%;
12
12
  animation: appstorys-spin 0.8s linear infinite;
13
13
  }
14
- `,document.head.appendChild(t)}function Or(){Mr();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 Ii(){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=Or();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 ce.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 Bi=oe(()=>{"use strict";et();Fi();try{window.AppStorysMountCapture=function(){try{return Ii()}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 Nr={};cn(Nr,{AppStorys:()=>jr,Banner:()=>vn,BottomSheet:()=>hi,Csat:()=>xi,Floater:()=>In,Pip:()=>Tn,SdkState:()=>mo,Story:()=>gi,Survey:()=>wi,Tooltip:()=>yi,Widget:()=>mi,personalizeText:()=>Te});module.exports=ji(Nr);var mo=(n=>(n.uninitialized="uninitialized",n.initializing="initializing",n.initialized="initialized",n.error="error",n))(mo||{});var Mt=require("react"),ye=je(require("lottie-react"));et();var mn=require("react");et();et();var Ni=t=>F.getState().variantMappings[t];function ho(t){return!!(t.details&&typeof t.details=="object"&&"variants"in t.details)}function Ct(t){if(!ho(t))return t;let e=Ni(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 Ne="__back_press_triggered__";function fn(t){return(t||"").trim().toLowerCase()}function qi(t,e){let o=fn(t),i=fn(e);return!o||o===i}function Ui(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 Hi(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:Ui(String(r),n.operator,n.value)}))}function Vi(t,e,o){let i=t,n=i.trigger_event??i.trigger,r=t.id;return!n}function bo(){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(Ne)||!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 Hi(c,u)})}function ct(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(0,mn.useMemo)(()=>{let c=m=>m.find(g=>qi(g.screen,o)&&g.campaign_type===t&&(e?.position?g.position===e.position:!0)&&Vi(g,r,s)),x=(i&&i.length>0?c(i):void 0)??c(n||[]);if(x)return Ct(x)},[i,n,r,s,a,t,e,o])}et();qe();fe();et();Ue();var hn="appstorys_offline_queue";async function bn(){let t=await ot.getItem(hn);return t?JSON.parse(t):[]}async function xn(t){await ot.setItem(hn,JSON.stringify(t))}function Yi(t){return Math.min(3e4*Math.pow(2,t),12e4)}function Qi(t){let o=t.retryCount||0,i=t.lastAttempt||0,n=Yi(o);return o<3&&Date.now()-i>=n}async function Gi(){let t=F.getState();return!t.accountId||!t.appId?!1:await Vt(t.accountId,t.appId,t.userId)}async function Sn(t,e){if(await Gi()){let i=await ot.getItem("access_token");i&&(t.headers={...t.headers,Authorization:`Bearer ${i}`}),t.authRetried=!0,t.lastAttempt=Date.now(),e(t)}}async function Ve(t,e){let o=(t.retryCount||0)+1;o<=3&&(t.retryCount=o,t.lastAttempt=Date.now(),e(t))}async function He(t){let e=await bn();e.push(t),await xn(e)}async function Ji(){let t=await bn();if(t.length===0)return;let e=[];for(let o of t){if(!Qi(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 Sn(o,n=>e.push(n)):i.status>=500&&await Ve(o,n=>e.push(n))}catch{await Ve(o,n=>e.push(n))}}await xn(e)}async function Ye(t){if(!navigator.onLine){await He(t);return}await Ji();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 Sn(t,He):e.status>=500&&await Ve(t,He)),e}catch{await Ve(t,He);return}}async function H(t,e,o){try{if(!t)return;let i=await lt(),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 ne();s={...s,...u}}if(e&&String(e).trim()!==""){let u=gn(e);u&&(s.variant_id=u)}let a={user_id:Pt(),event:t,metadata:s};e&&(a.campaign_id=e);let c=n.trackingUrl||"https://tracking.appstorys.co";i&&await Ye({url:`${c}/capture-event`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:a})}catch(i){console.error("Error in trackEvent",i)}}et();function vt(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}var me=require("react/jsx-runtime"),Cn=ye.default?.default??ye.default??ye.Lottie??ye,vn=()=>{let t=ct("BAN"),e=F(w=>w.isVisible),[o,i]=(0,Mt.useState)(!1),[n,r]=(0,Mt.useState)(null),[s,a]=(0,Mt.useState)(null),c=(0,Mt.useRef)(null),[u,x]=(0,Mt.useState)(0);if((0,Mt.useEffect)(()=>{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]),(0,Mt.useEffect)(()=>{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(0,me.jsxs)("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(vt(m.link))return}catch(w){console.warn("revealCampaignFromLink error",w)}console.log("Internal link:",m.link)}},children:[n?(()=>{let w=Cn.default||Cn;return(0,me.jsx)(w,{animationData:n,loop:!0,autoplay:e,style:b})})():m.image?(0,me.jsx)("img",{src:m.image,alt:"Campaign Banner",style:b}):null,g.crossButton?.enabled&&(0,me.jsx)("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"})]})};var mt=require("react");et();function Ge(t){let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")}function wn(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 kn(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 Qe=new Map;async function Xi(t,e){try{kn(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 xo={async load(t){if(!t||!Ge(t))return;let e=Qe.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:wn(t),listeners:[]};Qe.set(t,i);let n=new Promise(r=>i.listeners.push(r));return Xi(t,i),n},ensure(t){if(!t||!Ge(t))return;let e=wn(t);return kn(e,t),xo.load(t),e},getSync(t){if(!t)return;let e=Qe.get(t);return e?.status==="loaded"?e.name:void 0},_clearCache(){Qe.clear()}};function dt(t){if(t)return Ge(t)?xo.ensure(t):t}function Ki(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"&&Ge(s)&&e.add(s),i(s)}}};return i(t),Array.from(e)}async function Rn(t){let e=new Set;for(let o of t)Ki(o).forEach(i=>e.add(i));await Promise.all(Array.from(e).map(o=>xo.load(o)))}var Z=require("react/jsx-runtime"),So=t=>(t||"").trim().toLowerCase(),Ot=(t,e)=>{let o=Number(t);return Number.isFinite(o)?o:e};function Zi({iconType:t,color:e}){let o=e||"#FFFFFF";return t==="close"?(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:o,strokeWidth:"2.2",strokeLinecap:"round"}),(0,Z.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:o,strokeWidth:"2.2",strokeLinecap:"round"})]}):t==="expand"?(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("polyline",{points:"8,3 3,3 3,8",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"3",y1:"3",x2:"9",y2:"9",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,Z.jsx)("polyline",{points:"16,21 21,21 21,16",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"15",y1:"15",x2:"21",y2:"21",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):t==="minimize"?(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("polyline",{points:"9,9 3,9 3,3",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"3",y1:"9",x2:"9",y2:"3",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,Z.jsx)("polyline",{points:"15,15 21,15 21,21",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"15",y1:"21",x2:"21",y2:"15",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):t==="mute"?(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:o,strokeWidth:"2",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,Z.jsx)("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:o,strokeWidth:"2",strokeLinejoin:"round"}),(0,Z.jsx)("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,Z.jsx)("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]})}function Co({iconType:t,config:e,imageOverride:o,onClick:i}){let n=Ot(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(0,Z.jsx)("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:Ot(s.top,0),marginRight:Ot(s.right,0),marginBottom:Ot(s.bottom,0),marginLeft:Ot(s.left,0)},children:a?(0,Z.jsx)("img",{src:a,alt:t,style:{width:n,height:n,objectFit:"contain"}}):(0,Z.jsx)(Zi,{iconType:t,color:c})})}var Tn=()=>{let t=ct("PIP"),e=F(U=>U.campaigns),o=F(U=>U.allCampaigns),i=F(U=>U.currentScreen),n=F(U=>U.isVisible),[r,s]=(0,mt.useState)(!1),[a,c]=(0,mt.useState)(!1),[u,x]=(0,mt.useState)(!0),[m,g]=(0,mt.useState)(!1),[v,f]=(0,mt.useState)(null),b=(0,mt.useRef)({x:0,y:0}),h=(0,mt.useRef)(null),y=(0,mt.useMemo)(()=>{if(t)return t;let U=So(i),G=at=>at.find(St=>{let rt=St,Bt=rt.campaign_type==="PIP",ht=!So(rt.screen)||So(rt.screen)===U,At=!!(rt.trigger_event??rt.trigger),ee=rt.display_trigger!==!1&&!At;return Bt&&ht&&ee}),Q=G(e)??G(o);return Q?Ct(Q):void 0},[t,e,o,i]),w=(0,mt.useMemo)(()=>y,[y?.id,y?.details?.id]);if((0,mt.useEffect)(()=>{if(!w)return;let U=w.details||{},G=U?.styling?.soundToggle?.defaultSound||U?.styling?.appearance?.defaultSound||"yes";x(String(G).toLowerCase()!=="yes"),s(!1),c(!1),f(null),H("viewed",w.id)},[w]),(0,mt.useEffect)(()=>{h.current&&(h.current.muted=u)},[u]),(0,mt.useEffect)(()=>{if(!m)return;let U=Q=>{let at=Q.clientX-b.current.x,St=Q.clientY-b.current.y;f({x:Math.max(0,at),y:Math.max(0,St)})},G=()=>{g(!1)};return window.addEventListener("mousemove",U),window.addEventListener("mouseup",G),()=>{window.removeEventListener("mousemove",U),window.removeEventListener("mouseup",G)}},[m]),!w||!w.details||r||!n)return null;let I=w.details,B=I.styling||{},R=B.appearance||{},d=Ot(I.width??R.pipWidth,150),T=Ot(I.height??R.pipHeight,300),l=Math.max(d,T),p=Math.min(d,T),O=B.cta?.container||{},A=B.cta?.text||{},_=!!(I.button_text&&I.button_text.trim().length>0),C=Ot(B.cta?.container?.height,42),S=_?C+24:0,W=Ot(B.pipBottomPadding,20),P=Ot(B.pipTopPadding,0),M=a?I.large_video||I.small_video:I.small_video||I.large_video,$=(I.position||w.position||"right").toLowerCase(),k=!!B.isMovable,L=B.soundToggle?.enabled!==!1,j=B.crossButton?.enabled!==!1,X=B.expandControls?.enabled!==!1&&String(B.expandablePip||"yes").toLowerCase()==="yes",ft=B.crossButton,N=a?B.expandControls?.minimise:B.expandControls?.maximise,tt=u?B.soundToggle?.mute:B.soundToggle?.unmute,K={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?(K.left=v.x,K.top=v.y):a?(K.left=0,K.top=0,K.right=0,K.bottom=0):($==="left"?K.left=24:K.right=24,P>0?K.top=P:K.bottom=W+20);let Y=U=>{if(!k||a||U.target.closest("[data-control-button='true']"))return;let Q=U.currentTarget.getBoundingClientRect();b.current={x:U.clientX-Q.left,y:U.clientY-Q.top},f({x:Q.left,y:Q.top}),g(!0)},nt=()=>{if(!I.link)return;H("clicked",w.id);let U=String(I.link).trim();try{let G=F.getState(),Q=G.allCampaigns||[],at=G.campaigns||[],St=Q.find(rt=>rt.id===U);if(console.log("[Pip] clicked link=",U,"allCount=",Q.length,"visibleCount=",at.length,"referenced=",!!St),St){let rt={...St};delete rt.trigger_event,delete rt.trigger,rt.display_trigger=!0;let Bt=at.findIndex(ht=>ht.id===rt.id);if(Bt===-1)G.saveCampaigns([rt,...at]);else{let ht=at[Bt];if(!!(ht.trigger_event??ht.trigger)){let ee=[...at];ee[Bt]=rt,G.saveCampaigns(ee)}}return}}catch{}window.open(I.link,"_blank")};return M?(0,Z.jsxs)("div",{style:K,onMouseDown:Y,children:[(0,Z.jsx)("video",{ref:h,src:M,autoPlay:!0,loop:!0,playsInline:!0,muted:u,style:{width:"100%",height:a&&_?`calc(100% - ${S}px)`:"100%",objectFit:a?"contain":"cover"},onClick:nt,onEnded:()=>{y&&H("analyze",y.id)}}),(0,Z.jsxs)("div",{style:{position:"absolute",top:8,right:8,display:"flex",gap:8,zIndex:2},children:[L&&(0,Z.jsx)(Co,{iconType:u?"mute":"unmute",config:tt,imageOverride:u?I.muteImage:I.unmuteImage,onClick:()=>x(U=>!U)}),X&&(0,Z.jsx)(Co,{iconType:a?"minimize":"expand",config:N,imageOverride:a?I.minimiseImage:I.maximiseImage,onClick:()=>{console.log("[Pip] expand button clicked - isExpanded before:",a),c(U=>{let G=!U;return G&&w?.id&&(H("viewed",w.id),H("analyze",w.id)),G})}}),j&&(0,Z.jsx)(Co,{iconType:"close",config:ft,imageOverride:I.crossButtonImage,onClick:()=>s(!0)})]}),a&&_&&(0,Z.jsx)("button",{"data-control-button":"true",onClick:nt,style:{position:"absolute",left:12,right:12,bottom:12,height:O.height||42,width:O.ctaFullWidth?"auto":O.ctaWidth||"auto",margin:O.ctaFullWidth?"0":"0 auto",background:O.backgroundColor||"#F7921C",color:A.color||"#fff",border:`${O.borderWidth||0}px solid ${O.borderColor||"transparent"}`,borderRadius:10,fontSize:A.fontSize||14,fontFamily:dt(A.fontFamily),fontWeight:600,cursor:I.link?"pointer":"default"},children:I.button_text})]}):null};var xt=je(require("react")),Fn=require("lottie-react");et();var ie=require("react/jsx-runtime"),Rt=(t,e=0)=>{let o=Number(t);return Number.isFinite(o)?o:e},vo=t=>(t||"").trim().toLowerCase(),tr="appstorysmediabucketdev.s3.ap-south-1.amazonaws.com",er=t=>{try{if(typeof window>"u")return[t];let e=new URL(t);if(e.hostname!==tr)return[t];let o=!!window.location.port,i=`/appstorys-media${e.pathname}${e.search}`;return o?[i,t]:[t]}catch{return[t]}},or=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"},wo=class extends xt.default.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}},nr=()=>{let[t,e]=(0,xt.useState)(null),[o,i]=(0,xt.useState)([]),[n,r]=(0,xt.useState)(!1),[s,a]=(0,xt.useState)(!1),c=(0,xt.useRef)(null),u=(0,xt.useRef)(null),x=ct("FLT"),m=F(C=>C.campaigns),g=F(C=>C.allCampaigns),v=F(C=>C.currentScreen),f=F(C=>C.isVisible),b=(0,xt.useRef)(null),h=x??(()=>{let C=[...m,...g].find(S=>{let W=S;if(W.campaign_type!=="FLT")return!1;let P=!!(W.trigger_event??W.trigger);return W.display_trigger===!1||P?!1:!vo(W.screen)||vo(W.screen)===vo(v)});if(C)try{return Ct(C)}catch{return C}})(),y=h?.id,w=F(C=>y?C.variantMappings[y]:void 0);if((0,xt.useEffect)(()=>{if(!h?.id||!f||ho(h)&&!w)return;let S=`${h.id}:${w||""}`;b.current!==S&&(b.current=S,H("viewed",h.id))},[h?.id,w,f]),(0,xt.useEffect)(()=>{let C=h?.details?.lottie_data;if(e(null),i([]),r(!1),a(!1),!C)return;if(or(C)){e(C),a(!0);return}if(typeof C!="string"){r(!0);return}let S=er(C);i(S),a(!0)},[h?.details?.lottie_data]),(0,xt.useEffect)(()=>{if(!h?.details?.lottie_data||!c.current)return;let C=Fn.LottiePlayer;if(!C||typeof C.loadAnimation!="function"){r(!0),a(!1);return}let S=!1,W=null,P=()=>{W&&typeof W.destroy=="function"&&W.destroy(),W=null,u.current=null},M=($,k)=>{if(S)return;if(k>=$.length){r(!0),a(!1),console.error("[Floater] lottie load failed",{lottieUrls:$});return}P();let L=C.loadAnimation({container:c.current,renderer:"svg",loop:!0,autoplay:!0,path:$[k]});W=L,u.current=L,L.addEventListener("DOMLoaded",()=>{S||a(!1)}),L.addEventListener("data_failed",()=>{S||M($,k+1)})};if(t){P();let $=C.loadAnimation({container:c.current,renderer:"svg",loop:!0,autoplay:!0,animationData:t});W=$,u.current=$,$.addEventListener("DOMLoaded",()=>{S||a(!1)}),$.addEventListener("data_failed",()=>{S||(r(!0),a(!1))})}else o.length>0&&M(o,0);return()=>{S=!0,P()}},[h?.details?.lottie_data,t,o]),!h||!h.details||!f)return null;let{details:I}=h,B=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"?Rt(B.marginLeft,12):void 0,right:d==="left"?void 0:Rt(B.marginRight,12),top:Rt(B.marginTop,0)>0?Rt(B.marginTop,0):void 0,bottom:Rt(B.marginTop,0)>0?void 0:Rt(B.marginBottom,80),zIndex:10040,display:"flex"},l={width:Rt(I.width,60),height:Rt(I.height,60),background:"transparent",overflow:"hidden",borderBottomLeftRadius:Rt(B.bottomLeftRadius,0),borderBottomRightRadius:Rt(B.bottomRightRadius,0),borderTopLeftRadius:Rt(B.topLeftRadius,0),borderTopRightRadius:Rt(B.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(),W=S.allCampaigns||[],P=S.campaigns||[],M=W.find($=>{if(!$)return!1;let k=String($.id||"").trim(),L=$.details||{},j=String(L.campaign||L.id||"").trim();return!!(k&&k===C||j&&j===C||k&&C.includes(k)||j&&C.includes(j))});if(console.log("[Floater] clicked link=",C,"allCampaignsCount=",W.length,"visibleCount=",P.length),console.log("[Floater] all ids=",W.map($=>$.id).slice(0,50)),console.log("[Floater] referenced found=",!!M,M&&(M.id||M.details?.campaign||M.details?.id)),M){let $={...M};delete $.trigger_event,delete $.trigger,$.display_trigger=!0;let k=P.findIndex(L=>L.id===$.id);if(k===-1)console.log("[Floater] revealing campaign (prepended)",$.id),S.saveCampaigns([$,...P]);else{let L=P[k];if(!!(L.trigger_event??L.trigger)){let X=[...P];X[k]=$,console.log("[Floater] replacing existing triggered campaign with revealed one",$.id),S.saveCampaigns(X)}else console.log("[Floater] campaign already visible and not trigger-driven",$.id)}return}}catch(S){console.warn("[Floater] error while resolving referenced campaign",S)}try{window.open(I.link,"_blank")}catch{}},O=!!(I.lottie_data&&!n),A=!!I.image,_=!!(I.lottie_data&&s&&!t&&!n);return!O&&!A&&!_?null:(0,ie.jsx)("div",{style:T,children:(0,ie.jsx)("div",{style:l,onClick:()=>{p()},children:O?(0,ie.jsx)(wo,{onError:()=>r(!0),children:(0,ie.jsx)("div",{ref:c,style:{width:"100%",height:"100%",display:"block"}})},String(I.lottie_data)):_?(0,ie.jsx)("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:"..."}):(0,ie.jsx)("img",{src:I.image,alt:"floater",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})})})},In=nr;et();function zn(t){return(t||"").trim().toLowerCase()}function ko(t,e){let o=zn(t.screen),i=zn(e);return!o||o===i}async function Ro(t){try{let e=F.getState(),o=await lt(),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:Pt(),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)&&ko(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=>ko(I,t)))}let v=[...u,...g],f=a.filter(y=>{let w=!!(y.trigger_event??y.trigger);return ko(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)}}Ue();et();qe();async function To(t){try{let e=await lt(),o=Pt(),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 ne();n={...n,...r};let s={user_id:o,attributes:n},a=i.baseUrl||"https://users.appstorys.co";await Ye({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)}}et();function Te(t){if(!t||t.trim()==="")return t;let e=F.getState().personalizationData;if(!e||Object.keys(e).length===0)return ir(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 ir(t){let e=/\{\{[^|}\s]+\s*\|\s*([^}]+)\}\}/g;return t.replace(e,(o,i)=>i.trim())}fe();et();et();var Fo="appstorys_campaigns_cache",Bn="appstorys_campaigns_etag",Io="appstorys_campaigns_version";async function zo(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 ot.getItem(Fo),r=await ot.getItem(Bn),s=await ot.getItem(Io),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 lt(),b=Pt(),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 B=F.getState();typeof w.screen_capture_enabled<"u"&&B.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 lt(),b=Pt(),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 B=F.getState();typeof w.screen_capture_enabled<"u"&&B.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 ot.setItem(Fo,JSON.stringify(g)),await ot.setItem(Io,m.toString()),u&&await ot.setItem(Bn,u),{campaigns:g,version:m}}catch(o){console.error("Error fetching campaigns:",o);let i=await ot.getItem(Fo),n=await ot.getItem(Io);return{campaigns:i?JSON.parse(i):[],version:n?parseInt(n):1}}}et();et();et();async function Je(t,e){try{let o=await lt(),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}}et();var Bo=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&&bo()&&this.triggerCampaign()};handlePopState=()=>{bo()&&(window.history.pushState("appstorys_navigation",""),this.triggerCampaign())};triggerCampaign(){let e=F.getState(),{trackedEvents:o}=e;o.includes(Ne)||(console.log("AppStorys: Exit Intent triggered. Displaying campaign."),e.setTrackedEvents([...o,Ne]))}},An=new Bo;et();var Ao=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))}},Eo=new Ao;fe();var Xe="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 ot.getItem(Xe);if(t)return t;let e=await En();return await ot.setItem(Xe,e),e}catch(t){return console.error("Error managing anonymous user ID:",t),await En()}}async function Po(){try{await ot.removeItem(Xe)}catch(t){console.error("Error clearing anonymous user ID:",t)}}async function Lo(){try{return await ot.getItem(Xe)}catch(t){return console.error("Error getting stored anonymous user ID:",t),null}}function rr(){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 pa(){ua();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 jr(){try{let t=P.getState(),o=!!window.__APPSTORYS_DEBUG_CAPTURE;if(console.info("AppStorys: mountScreenCaptureButton called, screenCaptureEnabled=",t.screenCaptureEnabled,"debugForce=",o),!t.screenCaptureEnabled&&!o||document.getElementById("appstorys-screen-capture-btn"))return null;let n=pa();return n.addEventListener("click",async()=>{n.disabled=!0;let i=n.innerText;n.innerHTML='<div class="appstorys-spinner"></div>';let l=P.getState().currentScreen||(typeof window<"u"?window.location.pathname:"");try{await eo.takeScreenshot(l)}catch(c){console.error("CaptureService error",c)}n.disabled=!1,n.innerText=i,n.animate([{transform:"scale(1.0)"},{transform:"scale(1.05)"},{transform:"scale(1.0)"}],{duration:300})}),document.body.appendChild(n),console.info("AppStorys: screen capture button mounted"),n}catch(t){return console.error("mountScreenCaptureButton error",t),null}}var Hr=Ge(()=>{"use strict";bt();Or();try{window.AppStorysMountCapture=function(){try{return jr()}catch(t){return console.error("AppStorysMountCapture failed",t),null}}}catch{}try{window.AppStorysDebugState=function(){try{let t=P.getState();return console.info("AppStorys store state:",t),t}catch(t){return console.error("AppStorysDebugState failed",t),null}}}catch{}try{window.AppStorysDebugToken=function(){try{let t=localStorage.getItem("access_token")||"",e=t.length,o=t?t.slice(0,20)+"..."+t.slice(-10):"(none)";if(console.info("Token length:",e,"masked:",o),t&&t.includes("."))try{let n=t.split(".");if(n.length===3){let i=JSON.parse(atob(n[1]));if(console.info("Token payload:",i),i.exp){let s=new Date(i.exp*1e3),l=new Date;console.info("Token expires:",s.toISOString(),"Expired:",l>s)}}}catch(n){console.warn("Could not decode JWT:",n)}return t?"Token present":"No token"}catch(t){return console.error("AppStorysDebugToken failed",t),null}}}catch{}});var fa={};ei(fa,{AppStorys:()=>ga,Banner:()=>yi,BottomSheet:()=>vr,Csat:()=>kr,Floater:()=>zi,Modal:()=>Dr,Pip:()=>Fi,SdkState:()=>fn,Story:()=>yr,Survey:()=>Lr,Tooltip:()=>Cr,Trackable:()=>_r,Widget:()=>Sr,getCampaignVariantId:()=>ts,getVariantId:()=>yn,hasVariants:()=>zo,personalizeText:()=>Pe,resolveCampaignVariant:()=>Ht,selectVariantByWeight:()=>ai});module.exports=Jr(fa);var fn=(i=>(i.uninitialized="uninitialized",i.initializing="initializing",i.initialized="initialized",i.error="error",i))(fn||{});var me=require("react"),ro=ge(require("lottie-react"));bt();var di=require("react");bt();bt();var ri="appstorys_variant_mappings",To={};function Kr(t){let e=0;for(let o=0;o<t.length;o++){let n=t.charCodeAt(o);e=(e<<5)-e+n,e|=0}return Math.abs(e)}function si(){if(typeof window>"u")return{};try{let t=localStorage.getItem(ri);if(t)return JSON.parse(t)}catch{}return{}}function Zr(t,e){if(!(!t||!e)){To[t]=e;try{let o=P.getState(),n=o.variantMappings||{};n[t]!==e&&o.setVariantMappings({...n,[t]:e})}catch{}if(typeof window<"u")try{let o=si();o[t]=e,localStorage.setItem(ri,JSON.stringify(o))}catch{}}}var yn=t=>{if(!t)return;if(To[t])return To[t];let e=P.getState().variantMappings?.[t];if(e)return To[t]=e,e;let o=si();if(o[t]){To[t]=o[t];try{P.getState().setVariantMappings({...P.getState().variantMappings||{},[t]:o[t]})}catch{}return o[t]}};function zo(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 ai(t,e){let o=Object.keys(t);if(o.length===0)return;let n=o.filter(l=>t[l]&&t[l].isActive!==!1),i=n.length>0?n:o,s=i.reduce((l,c)=>l+(Number(t[c]?.weight)||0),0);if(s>0){let l=P.getState().userId||"default",c=`${e||"campaign"}_${l}`,S=Kr(c)%1e4/1e4*s;for(let p of i){let y=Number(t[p]?.weight)||0;if(S<y)return p;S-=y}}return i[0]}function Ht(t){if(!t||!zo(t))return t;let e=t,o=e.variants||e.details?.variants;if(!o||typeof o!="object"||Object.keys(o).length===0)return t;let n=yn(e.id||"");if((!n||!o[n])&&(n=ai(o,e.id),e.id&&n&&Zr(e.id,n)),!n||!o[n])return t;let i=o[n],l={...e.details&&typeof e.details=="object"?Object.fromEntries(Object.entries(e.details).filter(([c])=>c!=="variants")):{},...i};return{...t,details:l,_variantId:n}}function ts(t){if(t){if("_variantId"in t)return t._variantId;if(zo(t))return yn(t.id||"")}}var qo="__back_press_triggered__";function li(t){return(t||"").trim().toLowerCase()}function es(t,e){let o=li(t),n=li(e);return!o||o===n}function os(t,e,o){let n=Number(t),i=Number(o),s=!isNaN(n)&&!isNaN(i);switch(e){case"eq":return s?n===i:t===o;case"neq":return s?n!==i:t!==o;case"gt":return s?n>i:t>o;case"gte":return s?n>=i:t>=o;case"lt":return s?n<i:t<o;case"lte":return s?n<=i:t<=o;default:return!1}}function ns(t,e){let o=t.filter(n=>n.back_press==null);return o.length===0?!0:e.some(n=>o.every(i=>{let s=n[i.key];return s==null?!1:os(String(s),i.operator,i.value)}))}function is(t,e,o){let n=t,i=n.trigger_event??n.trigger,s=t.id;return!i}function hn(){let{campaigns:t,trackedEvents:e,trackedEventMetadata:o,currentScreen:n}=P.getState();return t.some(i=>{if(i.screen&&i.screen!==n)return!1;let s=i.trigger_event;if(!s||typeof s=="string")return!1;let{event:l,event_config:c}=s;if(!(c??[]).some(p=>p.back_press===!0)||e.includes(qo)||!e.includes(l))return!1;let d=(c??[]).filter(p=>p.back_press==null);if(d.length===0)return!0;let S=o[l]||[];return ns(d,S)})}function bn(t){return Array.isArray(t)?[...t].sort((o,n)=>{let i=typeof o?.order=="number"?o.order:0,s=typeof n?.order=="number"?n.order:0;return i-s}).map(o=>{if(!o||!Array.isArray(o.slides))return o;let n=[...o.slides].sort((i,s)=>{let l=typeof i?.order=="number"?i.order:0,c=typeof s?.order=="number"?s.order:0;return l-c});return{...o,slides:n}}):[]}function Mt(t,e){let o=P(d=>d.currentScreen),n=P(d=>d.campaigns),i=P(d=>d.allCampaigns),s=P(d=>d.trackedEvents),l=P(d=>d.trackedEventMetadata),c=P(d=>d.variantMappings);return(0,di.useMemo)(()=>{let d=u=>u.find(C=>{if(C.campaign_type!==t||e?.position&&C.position!==e.position||!is(C,s,l))return!1;if(e?.screenContains){let h=(e.screenContains||"").trim().toLowerCase();return(C.screen||"").trim().toLowerCase().includes(h)}return es(C.screen,o)}),p=(n&&n.length>0?d(n):void 0)??d(i||[]);if(!p)return;let y=Ht(p);return y&&y.details&&Array.isArray(y.details)&&(y.details=bn(y.details)),y},[n,i,s,l,c,t,e,o])}bt();Ho();io();bt();Vo();var ui="appstorys_offline_queue";async function pi(){let t=await kt.getItem(ui);return t?JSON.parse(t):[]}async function gi(t){await kt.setItem(ui,JSON.stringify(t))}function rs(t){return Math.min(3e4*Math.pow(2,t),12e4)}function ss(t){let o=t.retryCount||0,n=t.lastAttempt||0,i=rs(o);return o<3&&Date.now()-n>=i}async function as(){let t=P.getState();return!t.accountId||!t.appId?!1:await Ae(t.accountId,t.appId,t.userId)}async function fi(t,e){if(await as()){let n=await kt.getItem("access_token");n&&(t.headers={...t.headers,Authorization:`Bearer ${n}`}),t.authRetried=!0,t.lastAttempt=Date.now(),e(t)}}async function Yo(t,e){let o=(t.retryCount||0)+1;o<=3&&(t.retryCount=o,t.lastAttempt=Date.now(),e(t))}async function Uo(t){let e=await pi();e.push(t),await gi(e)}async function ls(){let t=await pi();if(t.length===0)return;let e=[];for(let o of t){if(!ss(o)){e.push(o);continue}try{let n=await fetch(o.url,{method:o.method,headers:o.headers,body:JSON.stringify(o.body)});if(n.ok)continue;n.status===401||n.status===403?o.authRetried||await fi(o,i=>e.push(i)):n.status>=500&&await Yo(o,i=>e.push(i))}catch{await Yo(o,i=>e.push(i))}}await gi(e)}async function Go(t){if(!navigator.onLine){await Uo(t);return}await ls();try{let e=await fetch(t.url,{method:t.method,headers:t.headers,body:JSON.stringify(t.body)});return e.ok||(e.status===401||e.status===403?await fi(t,Uo):e.status>=500&&await Yo(t,Uo)),e}catch{await Yo(t,Uo);return}}async function st(t,e,o){try{if(!t)return;let n=await At(),i=P.getState(),s=["viewed","clicked","csat captured","survey captured","shared"];if(!s.includes(t)){let S=i.trackedEvents;if(!S.includes(t))i.setTrackedEvents([...S,t]);else{let p=S.filter(y=>y!==t);p.push(t),i.setTrackedEvents(p)}if(o&&Object.keys(o).length>0){let p=i.trackedEventMetadata||{},y=p[t]||[];i.setTrackedEventMetadata({...p,[t]:[...y,o]})}}let l={...o||{}};if(!s.includes(t)){let S=await Qe();l={...l,...S}}if(e&&String(e).trim()!==""){let S=o?.variant_id||ii(e);S&&(l.variant_id=S)}let c={user_id:fe(),event:t,metadata:l};e&&(c.campaign_id=e);let d=i.trackingUrl||"https://tracking.appstorys.co";n&&await Go({url:`${d}/capture-event`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:c})}catch(n){console.error("Error in trackEvent",n)}}bt();function Nt(t){if(!t)return!1;let e=P.getState(),o=e.allCampaigns||[],n=e.campaigns||[],i=String(t).trim(),s=o.find(d=>{if(!d)return!1;let S=String(d.id||"").trim(),p=d.details||{},y=String(p.campaign||p.id||"").trim();return!!(S&&S===i||y&&y===i||S&&i.includes(S)||y&&i.includes(y))});if(!s)return!1;let l={...s};delete l.trigger_event,delete l.trigger,l.display_trigger=!0;let c=n.findIndex(d=>String(d.id||"")===String(l.id||""));if(c===-1)e.saveCampaigns([l,...n]);else{let d=n[c];if(!!(d.trigger_event??d.trigger)){let p=[...n];p[c]=l,e.saveCampaigns(p)}}return!0}var Xe=require("react/jsx-runtime"),ds=({config:t,onPress:e,style:o,ignoreSizeAndMargin:n=!1})=>{if(!t||!t.enabled)return null;let i=t.size,s=t.margin,l=t.color,c=t.image,d=t.selectedStyle,S=i!=null&&i>=0?i:18,p=n?40:S,y=s?.top!==void 0&&s?.top!==null&&s.top>=0?s.top:0,u=s?.bottom!==void 0&&s?.bottom!==null&&s.bottom>=0?s.bottom:0,C=s?.left!==void 0&&s?.left!==null&&s.left>=0?s.left:0,h=s?.right!==void 0&&s?.right!==null&&s.right>=0?s.right:0,g={marginTop:n?0:y,marginBottom:n?0:u,marginLeft:n?0:C,marginRight:n?0:h,width:p,height:p,backgroundColor:l?.fill||"transparent",borderColor:l?.stroke||"transparent",borderWidth:p*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"absolute",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:l?.stroke?"solid":"none",...o},b=()=>{let m=l?.cross||"#ffffff";return(0,Xe.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Xe.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:m,strokeWidth:"2.2",strokeLinecap:"round"}),(0,Xe.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:m,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,Xe.jsx)("button",{type:"button","data-control-button":"true",onMouseDown:m=>m.stopPropagation(),onClick:m=>{m.stopPropagation(),m.preventDefault(),e(m)},style:g,children:c&&c.trim()!==""?(0,Xe.jsx)("img",{src:c,style:{width:p,height:p,objectFit:"contain"},alt:"close"}):b()})},Ot=ds;var Je=require("react/jsx-runtime"),mi=ro.default?.default??ro.default??ro.Lottie??ro,yi=()=>{let t=Mt("BAN"),e=P(T=>T.isVisible),[o,n]=(0,me.useState)(!1),[i,s]=(0,me.useState)(null),[l,c]=(0,me.useState)(null),d=(0,me.useRef)(null),[S,p]=(0,me.useState)(0),y=(0,me.useRef)(null);if((0,me.useEffect)(()=>{t?.id&&y.current!==t.id&&(y.current=t.id,n(!1),st("viewed",t.id),t.details?.lottie_data&&fetch(t.details.lottie_data).then(T=>T.json()).then(T=>{s(T),T.w&&T.h&&c(T.h/T.w)}).catch(T=>console.error("Error loading Lottie:",T)))},[t?.id]),(0,me.useEffect)(()=>{let T=()=>{d.current&&p(d.current.offsetWidth)};return T(),window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[t,o]),!t||o||!e)return null;let{details:u}=t,C=u.styling||{},h=u.height||"auto";l&&S&&(h=S*l);let g=parseFloat(String(u.height)),b=parseFloat(String(u.originalWidth??u.styling?.originalWidth)),m=parseFloat(String(u.originalHeight??u.styling?.originalHeight)),E=Number.isFinite(g)&&g>0&&Number.isFinite(b)&&b>0&&Number.isFinite(m)&&m>0?g*(b/m):null,j=E!==null?`${E}px`:void 0,D=typeof h=="number"?`${h}px`:h||void 0,L=Number(C.marginRight),v=Number(C.marginBottom),w={position:"fixed",right:Number.isFinite(L)?`${L}px`:"0px",bottom:Number.isFinite(v)?`${v}px`:"0px",zIndex:9999,display:"block",cursor:u.link?"pointer":"default"},_={position:"relative",width:j||"100%",height:D||"auto",backgroundColor:"transparent",borderRadius:`${C.topRightRadius||0}px ${C.topLeftRadius||0}px ${C.bottomRightRadius||0}px ${C.bottomLeftRadius||0}px`,overflow:"hidden"},N={width:"100%",height:"100%",display:"block",objectFit:"contain"},U=T=>{T.stopPropagation(),n(!0),st("banner_closed",t.id)};return(0,Je.jsx)("div",{ref:d,style:w,onClick:()=>{if(u.link)if(st("clicked",t.id),u.link.startsWith("http"))window.open(u.link,"_blank");else{try{if(Nt(u.link))return}catch(T){console.warn("revealCampaignFromLink error",T)}console.log("Internal link:",u.link)}},children:(0,Je.jsxs)("div",{style:_,children:[i?(()=>{let T=mi.default||mi;return(0,Je.jsx)(T,{animationData:i,loop:!0,autoplay:e,style:N})})():u.image?(0,Je.jsx)("img",{src:u.image,alt:"Campaign Banner",style:N}):null,C.crossButton?.enabled&&(0,Je.jsx)(Ot,{config:C.crossButton,onPress:U,style:{top:C.crossButton?.margin?.top!==void 0?0:5,right:C.crossButton?.margin?.right!==void 0?0:5}})]})})};var Pt=require("react");bt();function Xo(t){let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")}function hi(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 bi(t,e){if(typeof document>"u")return;let o=`appstorys-font-${t}`;if(document.getElementById(o))return;let n=document.createElement("style");n.id=o,n.type="text/css",n.textContent=`@font-face{font-family:"${t}";src:url("${e}");font-style:normal;font-weight:normal;font-display:swap;}`,document.head.appendChild(n)}var Qo=new Map;async function cs(t,e){try{bi(e.name,t);let o=globalThis.FontFace;if(typeof document<"u"&&o&&document.fonts?.add){let n=new o(e.name,`url(${t})`);await n.load(),document.fonts.add(n)}else typeof document<"u"&&document.fonts?.load&&await document.fonts.load(`1em "${e.name}"`);e.status="loaded",e.listeners.forEach(n=>n(e.name))}catch(o){console.warn(`[FontManager] Failed to load font from "${t}":`,o),e.status="failed",e.listeners.forEach(n=>n(void 0))}finally{e.listeners=[]}}var xn={async load(t){if(!t||!Xo(t))return;let e=Qo.get(t);if(e)return e.status==="loaded"?e.name:e.status==="failed"?void 0:new Promise(s=>e.listeners.push(s));let n={status:"pending",name:hi(t),listeners:[]};Qo.set(t,n);let i=new Promise(s=>n.listeners.push(s));return cs(t,n),i},ensure(t){if(!t||!Xo(t))return;let e=hi(t);return bi(e,t),xn.load(t),e},getSync(t){if(!t)return;let e=Qo.get(t);return e?.status==="loaded"?e.name:void 0},_clearCache(){Qo.clear()}};function lt(t,e){if(!t)return e;let o=String(t).trim();if(!o)return e;if(Xo(o)){let n=xn.ensure(o);return n?`"${n}", ${e||"sans-serif"}`:e}return o.includes(",")||o.includes('"')||o.includes("'")?o:`"${o}", ${e||"sans-serif"}`}function us(t){let e=new Set,o=new WeakSet,n=i=>{if(i!=null&&typeof i!="string"){if(Array.isArray(i)){for(let s of i)n(s);return}if(typeof i=="object"){if(o.has(i))return;o.add(i);for(let[s,l]of Object.entries(i))s==="fontFamily"&&typeof l=="string"&&Xo(l)&&e.add(l),n(l)}}};return n(t),Array.from(e)}async function xi(t){let e=new Set;for(let o of t)us(o).forEach(n=>e.add(n));await Promise.all(Array.from(e).map(o=>xn.load(o)))}var se=require("react/jsx-runtime"),Me=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:n,style:i,type:s})=>{if(!t||!n)return null;let{size:l=18,margin:c,color:d,image:S,selectedStyle:p}=t,y=o?40:l,u=o?0:c?.top??0,C=o?0:c?.bottom??0,h=o?0:c?.left??0,g=o?0:c?.right??0,b={marginTop:u,marginBottom:C,marginLeft:h,marginRight:g,width:y,height:y,backgroundColor:d?.fill||"transparent",borderColor:d?.stroke||"transparent",borderWidth:y*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,display:"flex",...o?{}:{marginTop:t.margin?.top??0,marginRight:t.margin?.right??0,marginBottom:t.margin?.bottom??0,marginLeft:t.margin?.left??0},...i},m=()=>{let E=d?.cross||"#ffffff";return s==="mute"?(0,se.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,se.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:E,strokeWidth:"2.2",strokeLinejoin:"round"}),(0,se.jsx)("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:E,strokeWidth:"2.2",strokeLinecap:"round"}),(0,se.jsx)("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:E,strokeWidth:"2.2",strokeLinecap:"round"})]}):(0,se.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,se.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:E,strokeWidth:"2.2",strokeLinejoin:"round"}),(0,se.jsx)("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:E,strokeWidth:"2.2",strokeLinecap:"round"}),(0,se.jsx)("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:E,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,se.jsx)("button",{type:"button","data-control-button":"true",onMouseDown:E=>E.stopPropagation(),onClick:E=>{E.stopPropagation(),E.preventDefault(),e(E)},style:{...b,border:b.borderColor?`${b.borderWidth}px solid ${b.borderColor}`:"none",padding:0,cursor:"pointer",outline:"none"},children:S&&S.trim()!==""?(0,se.jsx)("img",{src:S,style:{width:y,height:y,objectFit:"contain"},alt:s}):m()})};var ee=require("react/jsx-runtime"),Si=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:n,style:i,type:s})=>{if(!t||!n)return null;let{size:l=18,margin:c,color:d,image:S,selectedStyle:p}=t,y=o?40:l,u={marginTop:o?0:c?.top??0,marginBottom:o?0:c?.bottom??0,marginLeft:o?0:c?.left??0,marginRight:o?0:c?.right??0,width:y,height:y,backgroundColor:d?.fill||"transparent",borderColor:d?.stroke||d?.cross||"#ffffff",borderWidth:d?.stroke?Math.max(1,y*.05):2,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:"solid",boxSizing:"border-box",...o?{}:{marginTop:t.margin?.top??0,marginRight:t.margin?.right??0,marginBottom:t.margin?.bottom??0,marginLeft:t.margin?.left??0},...i},C=()=>{let h=d?.cross||"#ffffff";return s==="maximise"?(0,ee.jsxs)("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%","aria-hidden":!0,children:[(0,ee.jsx)("polyline",{points:"15,5 19,5 19,9",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("line",{x1:"19",y1:"5",x2:"14",y2:"10",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"}),(0,ee.jsx)("polyline",{points:"9,19 5,19 5,15",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("line",{x1:"5",y1:"19",x2:"10",y2:"14",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"})]}):(0,ee.jsxs)("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%","aria-hidden":!0,children:[(0,ee.jsx)("polyline",{points:"14,6 14,10 18,10",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("line",{x1:"14",y1:"10",x2:"19",y2:"5",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"}),(0,ee.jsx)("polyline",{points:"6,14 10,14 10,18",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("line",{x1:"10",y1:"14",x2:"5",y2:"19",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,ee.jsx)("button",{type:"button","data-control-button":"true",onMouseDown:h=>h.stopPropagation(),onClick:h=>{h.stopPropagation(),h.preventDefault(),e(h)},style:u,children:S&&S.trim()!==""?(0,ee.jsx)("img",{src:S,style:{width:y,height:y,objectFit:"contain"},alt:s}):C()})};var so=require("react/jsx-runtime"),ps=({styling:t,mode:e,muted:o,expanded:n,onClose:i,onToggleMute:s,onToggleExpand:l,containerStyle:c})=>{if(!t)return null;let d=e==="LARGE",S={position:"absolute",pointerEvents:"auto",...d?{top:15,right:15}:{top:0,right:0}},p={position:"absolute",pointerEvents:"auto",...d?{top:15,right:60}:{top:0,left:0}},y={position:"absolute",pointerEvents:"auto",...d?{top:15,left:15}:{bottom:0,right:0}},u=o?t.soundToggle?.unmute:t.soundToggle?.mute,C=n?t.expandControls?.minimise:t.expandControls?.maximise;return(0,so.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:9999999,pointerEvents:"none",...c},children:[t.crossButton?.enabled&&(0,so.jsx)(Ot,{config:{enabled:t.crossButton?.enabled??!1,image:t.crossButton?.image??"",color:{cross:t.crossButton?.color?.cross??"#ffffff",fill:t.crossButton?.color?.fill??"",stroke:t.crossButton?.color?.stroke??""},margin:{top:t.crossButton?.margin?.top??0,bottom:t.crossButton?.margin?.bottom??0,left:t.crossButton?.margin?.left??0,right:t.crossButton?.margin?.right??0},size:t.crossButton?.size&&t.crossButton.size>10?t.crossButton.size:20},onPress:i,ignoreSizeAndMargin:d,style:S}),t.soundToggle?.enabled&&u&&(0,so.jsx)(Me,{config:u,onPress:s,ignoreSizeAndMargin:d,style:p,enabled:t.soundToggle?.enabled,type:o?"unmute":"mute"}),t.expandControls?.enabled&&C&&(0,so.jsx)(Si,{config:C,onPress:l,ignoreSizeAndMargin:d,style:y,enabled:t.expandControls?.enabled,type:n?"minimise":"maximise"})]})},Ci=ps;var ao=require("react/jsx-runtime"),Sn=t=>(t||"").trim().toLowerCase(),Jo=(t,e)=>{let o=Number(t);return Number.isFinite(o)?o:e},vi=20,wi=20,ki=20,Ri=(t,e,o)=>{let n=window.innerWidth,i=window.innerHeight,s=vi,l=Math.max(s,n-o.width-vi),c=o.topInset,d=Math.max(c,i-o.height-o.bottomInset);return{x:Math.min(Math.max(t,s),l),y:Math.min(Math.max(e,c),d)}},gs=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"},Fi=()=>{let t=Mt("PIP"),e=P(Z=>Z.campaigns),o=P(Z=>Z.allCampaigns),n=P(Z=>Z.currentScreen),i=P(Z=>Z.isVisible),[s,l]=(0,Pt.useState)(!1),[c,d]=(0,Pt.useState)(!1),[S,p]=(0,Pt.useState)(!0),[y,u]=(0,Pt.useState)(!1),[C,h]=(0,Pt.useState)(null),g=(0,Pt.useRef)({x:0,y:0}),b=(0,Pt.useRef)({width:150,height:300,topInset:wi,bottomInset:ki}),m=(0,Pt.useRef)(null),E=(0,Pt.useRef)({x:0,y:0}),j=(0,Pt.useRef)(!1),D=(0,Pt.useMemo)(()=>{if(t)return t;let Z=Sn(n),rt=ht=>ht.find(mt=>{let R=mt,I=R.campaign_type==="PIP",O=!Sn(R.screen)||Sn(R.screen)===Z,tt=!!(R.trigger_event??R.trigger),St=R.display_trigger!==!1&&!tt;return I&&O&&St}),dt=rt(e)??rt(o);return dt?Ht(dt):void 0},[t,e,o,n]),L=(0,Pt.useMemo)(()=>D,[D?.id,D?.details?.id]);if((0,Pt.useEffect)(()=>{if(!L)return;let Z=L.details||{},rt=Z?.styling?.soundToggle?.defaultSound||Z?.styling?.appearance?.defaultSound||"yes";p(String(rt).toLowerCase()!=="yes"),l(!1),d(!1),h(null),st("viewed",L.id)},[L]),(0,Pt.useEffect)(()=>{let Z=m.current;if(!Z)return;Z.muted=S;let rt=Z.play();rt&&typeof rt.catch=="function"&&rt.catch(()=>{S||(Z.muted=!0,p(!0))})},[S]),(0,Pt.useEffect)(()=>{if(!c)return;let Z=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=Z}},[c]),(0,Pt.useEffect)(()=>{if(!y)return;let Z=dt=>{let ht=dt.clientX-E.current.x,mt=dt.clientY-E.current.y;(Math.abs(ht)>4||Math.abs(mt)>4)&&(j.current=!0);let R=dt.clientX-g.current.x,I=dt.clientY-g.current.y;h(Ri(R,I,b.current))},rt=()=>{u(!1)};return window.addEventListener("pointermove",Z),window.addEventListener("pointerup",rt),window.addEventListener("pointercancel",rt),()=>{window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",rt),window.removeEventListener("pointercancel",rt)}},[y]),(0,Pt.useEffect)(()=>{let Z=()=>{h(rt=>rt&&Ri(rt.x,rt.y,b.current))};return window.addEventListener("resize",Z),window.addEventListener("orientationchange",Z),()=>{window.removeEventListener("resize",Z),window.removeEventListener("orientationchange",Z)}},[]),!L||!L.details||s||!i)return null;let v=L.details,w=v.styling||{},_=w.appearance||{},N=Jo(v.width??_.pipWidth,150),U=Jo(v.height??_.pipHeight,300),A=N,T=U,k=w.cta?.container||{},B=w.cta?.text||{},$=w.cta?.cornerRadius,V=w.cta?.margin||{},G=!!(v.button_text&&v.button_text.trim().length>0),r=Jo(w.pipBottomPadding,20),M=Jo(w.pipTopPadding,0);b.current={width:A,height:T,topInset:wi+M,bottomInset:ki+r};let a=c?v.large_video||v.small_video:v.small_video||v.large_video,f=(v.position||L.position||"right").toLowerCase(),x=!!w.isMovable,z=w.soundToggle?.enabled!==!1,Y=w.crossButton?.enabled!==!1,ot=w.expandablePip??v.expandablePip??v.expandable_pip,J=ot!=null&&ot!==""?gs(ot):w.expandControls?.enabled!==!1,H={...w,crossButton:{...w.crossButton,enabled:Y,image:v.crossButtonImage||w.crossButton?.image},soundToggle:{...w.soundToggle,enabled:z,mute:{...w.soundToggle?.mute,image:v.muteImage||w.soundToggle?.mute?.image},unmute:{...w.soundToggle?.unmute,image:v.unmuteImage||w.soundToggle?.unmute?.image}},expandControls:{...w.expandControls,enabled:J,maximise:{...w.expandControls?.maximise,image:v.maximiseImage||w.expandControls?.maximise?.image},minimise:{...w.expandControls?.minimise,image:v.minimiseImage||w.expandControls?.minimise?.image}}},K=()=>{d(Z=>{let rt=!Z;return rt&&L?.id&&(st("viewed",L.id),st("analyze",L.id)),rt})},it={position:"fixed",zIndex:10020,width:c?"auto":A,height:c?"auto":T,borderRadius:c?0:5,overflow:"hidden",background:"#000",boxShadow:"0 16px 40px rgba(0,0,0,0.35)",cursor:y?"grabbing":x&&!c?"grab":"default",transition:y?"none":"width 180ms ease, height 180ms ease, transform 180ms ease",touchAction:c||x?"none":"auto",WebkitUserSelect:"none",userSelect:"none",WebkitTapHighlightColor:"transparent"};C&&!c?(it.left=C.x,it.top=C.y):c?(it.left=0,it.top=0,it.right=0,it.bottom=0):(f==="left"?it.left=24:it.right=24,M>0?it.top=M:it.bottom=r+20);let xt=Z=>{if(!x||c||Z.pointerType==="mouse"&&Z.button!==0||Z.target.closest("[data-control-button='true']"))return;let dt=Z.currentTarget.getBoundingClientRect();g.current={x:Z.clientX-dt.left,y:Z.clientY-dt.top},E.current={x:Z.clientX,y:Z.clientY},j.current=!1,h({x:dt.left,y:dt.top}),u(!0)},ut=()=>{if(!v.link)return;st("clicked",L.id);let Z=String(v.link).trim();try{let rt=P.getState(),dt=rt.allCampaigns||[],ht=rt.campaigns||[],mt=dt.find(R=>R.id===Z);if(console.log("[Pip] clicked link=",Z,"allCount=",dt.length,"visibleCount=",ht.length,"referenced=",!!mt),mt){let R={...mt};delete R.trigger_event,delete R.trigger,R.display_trigger=!0;let I=ht.findIndex(O=>O.id===R.id);if(I===-1)rt.saveCampaigns([R,...ht]);else{let O=ht[I];if(!!(O.trigger_event??O.trigger)){let St=[...ht];St[I]=R,rt.saveCampaigns(St)}}return}}catch{}window.open(v.link,"_blank")};return a?(0,ao.jsxs)("div",{style:it,onPointerDown:xt,children:[(0,ao.jsx)("video",{ref:m,src:a,autoPlay:!0,loop:!0,playsInline:!0,muted:S,style:{width:"100%",height:"100%",objectFit:c?"contain":"cover",cursor:J&&!c||v.link?"pointer":"default"},onClick:()=>{if(j.current){j.current=!1;return}if(J){K();return}ut()},onEnded:()=>{D&&st("analyze",D.id)}}),(0,ao.jsx)(Ci,{styling:H,mode:c?"LARGE":"SMALL",muted:!S,expanded:c,onClose:()=>l(!0),onToggleMute:()=>p(Z=>!Z),onToggleExpand:K,containerStyle:c?{paddingTop:"env(safe-area-inset-top, 0px)",paddingLeft:"env(safe-area-inset-left, 0px)",paddingRight:"env(safe-area-inset-right, 0px)"}:void 0}),c&&G&&(0,ao.jsx)("button",{"data-control-button":"true",onClick:ut,style:{position:"absolute",left:V.left??12,right:V.right??12,bottom:`calc(${V.bottom??12}px + env(safe-area-inset-bottom, 0px))`,height:k.height||42,width:k.ctaFullWidth?"auto":k.ctaWidth||"auto",maxWidth:`calc(100% - ${(V.left??12)+(V.right??12)}px)`,margin:k.ctaFullWidth?"0":"0 auto",background:k.backgroundColor||"#F7921C",color:B.color||"#fff",border:`${k.borderWidth||0}px solid ${k.borderColor||"transparent"}`,borderTopLeftRadius:typeof $=="number"?$:$?.topLeft??10,borderTopRightRadius:typeof $=="number"?$:$?.topRight??10,borderBottomRightRadius:typeof $=="number"?$:$?.bottomRight??10,borderBottomLeftRadius:typeof $=="number"?$:$?.bottomLeft??10,fontSize:B.fontSize||14,fontFamily:lt(B.fontFamily),fontWeight:600,cursor:v.link?"pointer":"default"},children:v.button_text})]}):null};var Kt=ge(require("react")),Ti=require("lottie-react");bt();var Ke=require("react/jsx-runtime"),ae=(t,e=0)=>{let o=Number(t);return Number.isFinite(o)?o:e},Cn=t=>(t||"").trim().toLowerCase(),fs="appstorysmediabucketdev.s3.ap-south-1.amazonaws.com",ms=t=>{try{if(typeof window>"u")return[t];let e=new URL(t);if(e.hostname!==fs)return[t];let o=!!window.location.port,n=`/appstorys-media${e.pathname}${e.search}`;return o?[n,t]:[t]}catch{return[t]}},ys=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"},vn=class extends Kt.default.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}},hs=()=>{let[t,e]=(0,Kt.useState)(null),[o,n]=(0,Kt.useState)([]),[i,s]=(0,Kt.useState)(!1),[l,c]=(0,Kt.useState)(!1),d=(0,Kt.useRef)(null),S=(0,Kt.useRef)(null),p=Mt("FLT"),y=P(k=>k.campaigns),u=P(k=>k.allCampaigns),C=P(k=>k.currentScreen),h=P(k=>k.isVisible),g=(0,Kt.useRef)(null),b=p??(()=>{let k=[...y,...u].find(B=>{let $=B;if($.campaign_type!=="FLT")return!1;let V=!!($.trigger_event??$.trigger);return $.display_trigger===!1||V?!1:!Cn($.screen)||Cn($.screen)===Cn(C)});if(k)try{return Ht(k)}catch{return k}})(),m=b?.id,E=P(k=>m?k.variantMappings[m]:void 0);if((0,Kt.useEffect)(()=>{if(!b?.id||!h||zo(b)&&!E)return;let B=`${b.id}:${E||""}`;g.current!==B&&(g.current=B,st("viewed",b.id))},[b?.id,E,h]),(0,Kt.useEffect)(()=>{let k=b?.details?.lottie_data;if(e(null),n([]),s(!1),c(!1),!k)return;if(ys(k)){e(k),c(!0);return}if(typeof k!="string"){s(!0);return}let B=ms(k);n(B),c(!0)},[b?.details?.lottie_data]),(0,Kt.useEffect)(()=>{if(!b?.details?.lottie_data||!d.current)return;let k=Ti.LottiePlayer;if(!k||typeof k.loadAnimation!="function"){s(!0),c(!1);return}let B=!1,$=null,V=()=>{$&&typeof $.destroy=="function"&&$.destroy(),$=null,S.current=null},G=(r,M)=>{if(B)return;if(M>=r.length){s(!0),c(!1),console.error("[Floater] lottie load failed",{lottieUrls:r});return}V();let a=k.loadAnimation({container:d.current,renderer:"svg",loop:!0,autoplay:!0,path:r[M]});$=a,S.current=a,a.addEventListener("DOMLoaded",()=>{B||c(!1)}),a.addEventListener("data_failed",()=>{B||G(r,M+1)})};if(t){V();let r=k.loadAnimation({container:d.current,renderer:"svg",loop:!0,autoplay:!0,animationData:t});$=r,S.current=r,r.addEventListener("DOMLoaded",()=>{B||c(!1)}),r.addEventListener("data_failed",()=>{B||(s(!0),c(!1))})}else o.length>0&&G(o,0);return()=>{B=!0,V()}},[b?.details?.lottie_data,t,o]),!b||!b.details||!h)return null;let{details:j}=b,D=j.styling||{},v=(typeof j.position=="string"?j.position:typeof b.position=="string"?b.position:"right").toLowerCase()==="left"?"left":"right",w={position:"fixed",left:v==="left"?ae(D.marginLeft,12):void 0,right:v==="left"?void 0:ae(D.marginRight,12),top:ae(D.marginTop,0)>0?ae(D.marginTop,0):void 0,bottom:ae(D.marginTop,0)>0?void 0:ae(D.marginBottom,80),zIndex:10040,display:"flex"},_={width:ae(j.width,60),height:ae(j.height,60),background:"transparent",overflow:"hidden",borderBottomLeftRadius:ae(D.bottomLeftRadius,0),borderBottomRightRadius:ae(D.bottomRightRadius,0),borderTopLeftRadius:ae(D.topLeftRadius,0),borderTopRightRadius:ae(D.topRightRadius,0),display:"flex",alignItems:"center",justifyContent:"center",cursor:j.link?"pointer":"default",boxShadow:"0 8px 18px rgba(0,0,0,0.2)"},N=async()=>{if(!j.link)return;await st("clicked",b.id);let k=String(j.link).trim();try{let B=P.getState(),$=B.allCampaigns||[],V=B.campaigns||[],G=$.find(r=>{if(!r)return!1;let M=String(r.id||"").trim(),a=r.details||{},f=String(a.campaign||a.id||"").trim();return!!(M&&M===k||f&&f===k||M&&k.includes(M)||f&&k.includes(f))});if(console.log("[Floater] clicked link=",k,"allCampaignsCount=",$.length,"visibleCount=",V.length),console.log("[Floater] all ids=",$.map(r=>r.id).slice(0,50)),console.log("[Floater] referenced found=",!!G,G&&(G.id||G.details?.campaign||G.details?.id)),G){let r={...G};delete r.trigger_event,delete r.trigger,r.display_trigger=!0;let M=V.findIndex(a=>a.id===r.id);if(M===-1)console.log("[Floater] revealing campaign (prepended)",r.id),B.saveCampaigns([r,...V]);else{let a=V[M];if(!!(a.trigger_event??a.trigger)){let x=[...V];x[M]=r,console.log("[Floater] replacing existing triggered campaign with revealed one",r.id),B.saveCampaigns(x)}else console.log("[Floater] campaign already visible and not trigger-driven",r.id)}return}}catch(B){console.warn("[Floater] error while resolving referenced campaign",B)}try{window.open(j.link,"_blank")}catch{}},U=!!(j.lottie_data&&!i),A=!!j.image,T=!!(j.lottie_data&&l&&!t&&!i);return!U&&!A&&!T?null:(0,Ke.jsx)("div",{style:w,children:(0,Ke.jsx)("div",{style:_,onClick:()=>{N()},children:U?(0,Ke.jsx)(vn,{onError:()=>s(!0),children:(0,Ke.jsx)("div",{ref:d,style:{width:"100%",height:"100%",display:"block"}})},String(j.lottie_data)):T?(0,Ke.jsx)("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:"..."}):(0,Ke.jsx)("img",{src:j.image,alt:"floater",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})})})},zi=hs;bt();function Ii(t){return(t||"").trim().toLowerCase()}function wn(t,e){let o=Ii(t.screen),n=Ii(e);return!o||o===n}async function kn(t){try{let e=P.getState(),o=await At(),n=e.accountId;if(!o||!n)return;e.setCurrentScreen(t),e.setTrackedEvents([]);let i=e.baseUrl||"https://users.appstorys.co",s=await fetch(`${i}/v2/${n}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({user_id:fe(),screenName:t})});if(!s.ok)return;let l=await s.json();if(typeof l.screen_capture_enabled<"u"&&e.setScreenCaptureEnabled(!!l.screen_capture_enabled),l.variants&&l.variants.length>0){let m={};l.variants.forEach(E=>{m[E.id]=E.v_id}),e.setVariantMappings(m)}l.personalization_data&&e.setPersonalizationData(l.personalization_data);let c=e.allCampaigns||[],d=l.eligibleCampaignList||[],S=c.filter(m=>d.includes(m.id)&&wn(m,t)),p=S.map(m=>m.id),y=d.filter(m=>!p.includes(m)),u=[];if(y.length>0){let m=await fetch(`${i}/load-campaign-data`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(y)});m.ok&&(u=(await m.json()).filter(j=>wn(j,t)))}let C=[...S,...u],h=c.filter(m=>{let E=!!(m.trigger_event??m.trigger);return wn(m,t)&&m.display_trigger===!0&&!E}),g=[...C],b=new Set(g.map(m=>m.id));for(let m of h)b.has(m.id)||(g.push(m),b.add(m.id));e.saveCampaigns(g)}catch(e){console.error("Error when tracking screen:",t,e)}}Vo();bt();Ho();async function Rn(t){try{let e=await At(),o=fe(),n=P.getState();if(!e||!o){console.warn("AppStorys: Missing accessToken or userId. Ensure SDK is initialized before setting user properties.");return}let i={...t||{}},s=await Qe();i={...i,...s};let l={user_id:o,attributes:i},c=n.baseUrl||"https://users.appstorys.co";await Go({url:`${c}/update-user-atr`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:l})}catch(e){console.error("AppStorys: Error in setUserProperties:",e)}}bt();function Pe(t){if(!t||t.trim()==="")return t;let e=P.getState().personalizationData;if(!e||Object.keys(e).length===0)return bs(t);let o=/\{\{([^|}\s]+)\s*\|\s*([^}]+)\}\}/g;return t.replace(o,(n,i,s)=>{let l=i.trim(),c=s.trim();return e[l]??c})}function bs(t){let e=/\{\{[^|}\s]+\s*\|\s*([^}]+)\}\}/g;return t.replace(e,(o,n)=>n.trim())}io();bt();bt();var Fn="appstorys_campaigns_cache",Bi="appstorys_campaigns_etag",Tn="appstorys_campaigns_version";async function zn(t,e){try{let o=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),n=o?`/appstorys-campaigns/clients/${t}/campaigns.json`:`https://dev-cdn-campaign-appstorys.s3.ap-south-1.amazonaws.com/clients/${t}/campaigns.json`,i=await kt.getItem(Fn),s=await kt.getItem(Bi),l=await kt.getItem(Tn),c={Accept:"application/json"};!o&&s&&(c["If-None-Match"]=s);let d=await fetch(n,{method:"GET",headers:c,...o?{cache:"no-store"}:{}});if(d.status===304)return{campaigns:i?JSON.parse(i):[],version:l?parseInt(l):1};let S=d.headers.get("ETag"),p=await d.json(),y=2,u=p,C=e;if(!C)try{let h=await At(),g=fe(),m=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...h?{Authorization:`Bearer ${h}`}:{}},body:JSON.stringify({user_id:g,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(m.ok){let E=await m.json();console.info("AppStorys: fetchAllCampaigns track-user-res returned",E);let j=E?.screenName||E?.screen||E?.currentScreen||E?.screen_name||E?.current_screen;j&&(C=j);try{let D=P.getState();typeof E.screen_capture_enabled<"u"&&D.setScreenCaptureEnabled(!!E.screen_capture_enabled)}catch{}}}catch(h){console.warn("Could not fetch screen name from track-user-res:",h)}if(p.length>0&&p[0].version!==void 0&&(y=p[0].version,u=p.slice(1)),!u||u.length===0)try{let h=await At(),g=fe(),m=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...h?{Authorization:`Bearer ${h}`}:{}},body:JSON.stringify({user_id:g,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(m.ok){let E=await m.json(),j=E?.user_id||E?.id||E?.userId||g;try{let D=P.getState();typeof E.screen_capture_enabled<"u"&&D.setScreenCaptureEnabled(!!E.screen_capture_enabled)}catch{}if(j){let L=await fetch(o?"/appstorys-users/load-campaign-data":"https://users.appstorys.co/load-campaign-data",{method:"POST",headers:{"Content-Type":"application/json",...h?{Authorization:`Bearer ${h}`}:{}},body:JSON.stringify({user_id:j})});if(L.ok){let v=await L.json();console.log(`Fetched ${v.length} missing campaigns from fallback`),console.log("Fallback campaigns:",JSON.stringify(v,null,2)),v&&v.length>0&&(u=v)}else console.error("Failed to fetch missing campaigns:",await L.text())}}}catch(h){console.error("Error fetching missing campaigns via fallback:",h)}if(C&&u&&u.length>0){let h=b=>(b||"").trim().toLowerCase(),g=h(C);u=u.filter(b=>!h(b.screen)||h(b.screen)===g)}return await kt.setItem(Fn,JSON.stringify(u)),await kt.setItem(Tn,y.toString()),S&&await kt.setItem(Bi,S),{campaigns:u,version:y}}catch(o){console.error("Error fetching campaigns:",o);let n=await kt.getItem(Fn),i=await kt.getItem(Tn);return{campaigns:n?JSON.parse(n):[],version:i?parseInt(i):1}}}bt();bt();bt();async function Ko(t,e){try{let o=await At(),n=P.getState();if(!o)return console.error("AppStorys: Access token not found for reconciliation"),!1;let i={anonymous_user_id:t,identified_user_id:e},s=n.baseUrl||"https://users.appstorys.co",l=await fetch(`${s}/reconcile-anonymous-user`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(i)});if(l.ok)return!0;{let c=await l.text();return console.error("AppStorys: Failed to reconcile anonymous user:",l.status,c),!1}}catch(o){return console.error("AppStorys: Error in reconcileAnonymousUser:",o),!1}}bt();var In=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&&hn()&&this.triggerCampaign()};handlePopState=()=>{hn()&&(window.history.pushState("appstorys_navigation",""),this.triggerCampaign())};triggerCampaign(){let e=P.getState(),{trackedEvents:o}=e;o.includes(qo)||(console.log("AppStorys: Exit Intent triggered. Displaying campaign."),e.setTrackedEvents([...o,qo]))}},Li=new In;bt();var Bn=class{isInitialized=!1;setup(){this.isInitialized||typeof document>"u"||(document.addEventListener("visibilitychange",this.handleVisibilityChange),this.updateVisibility(document.visibilityState==="visible"),this.isInitialized=!0)}destroy(){!this.isInitialized||typeof document>"u"||(document.removeEventListener("visibilitychange",this.handleVisibilityChange),this.isInitialized=!1)}handleVisibilityChange=()=>{this.updateVisibility(document.visibilityState==="visible")};updateVisibility(e){let o=P.getState();o.isVisible!==e&&(console.log(`AppStorys: SDK visibility changed to ${e?"visible":"hidden"}`),o.setVisibility(e))}},Ln=new Bn;io();var Zo="anonymous_user_id";async function Ei(){let t=Date.now(),e=navigator.userAgent.split(" ")[0].replace(/[^a-zA-Z0-9]/g,"_");return`${t}_${e}`}async function Ai(){try{let t=await kt.getItem(Zo);if(t)return t;let e=await Ei();return await kt.setItem(Zo,e),e}catch(t){return console.error("Error managing anonymous user ID:",t),await Ei()}}async function En(){try{await kt.removeItem(Zo)}catch(t){console.error("Error clearing anonymous user ID:",t)}}async function An(){try{return await kt.getItem(Zo)}catch(t){return console.error("Error getting stored anonymous user ID:",t),null}}function xs(){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,45 @@
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 sr(t){let e=t,o=getComputedStyle(e);(o.position==="static"||!o.position)&&(e.style.position="relative")}window.AppStorysShowWidgetElements=function(){try{rr();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;sr(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)}};var xe=require("react");et();var Fe=require("react"),he=je(require("lottie-react")),Do=require("react/jsx-runtime"),Dn=he.default?.default??he.default??he.Lottie??he,jt=({src:t,alt:e,style:o,size:i})=>{let[n,r]=(0,Fe.useState)(null),[s,a]=(0,Fe.useState)(!1);(0,Fe.useEffect)(()=>{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=Dn.default||Dn;return(0,Do.jsx)(u,{animationData:n,loop:!0,autoplay:!0,style:c})}return(0,Do.jsx)("img",{src:t,alt:e||"story thumbnail",style:c,onError:()=>a(!0)})};var be=require("react/jsx-runtime"),_n=({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(0,be.jsxs)("div",{onClick:o,style:{display:"flex",flexDirection:"column",alignItems:"center",cursor:"pointer",flexShrink:0},children:[(0,be.jsx)("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:(0,be.jsx)(jt,{src:t.thumbnail,alt:t.name,style:{borderRadius:x}})}),(0,be.jsx)("span",{style:{marginTop:"6px",fontSize:`${i.name?.size||12}px`,fontFamily:dt(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})]})};var _o=require("react/jsx-runtime"),$n=({stories:t,viewedStories:e,onStoryClick:o})=>(0,_o.jsx)("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)=>(0,_o.jsx)(_n,{story:i,isViewed:e.includes(i.id),onClick:()=>o(n)},i.id))});var it=je(require("react"));et();var re=require("react/jsx-runtime"),Wn=({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(0,re.jsxs)("div",{style:s,children:[(0,re.jsx)("h3",{style:a,children:t.question||"Ask A Question..."}),(0,re.jsx)("div",{style:c,children:m.map((g,v)=>(0,re.jsxs)("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&&(0,re.jsxs)("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"8px"},children:[g.percentage,"%"]})]},g.id))})]})};var Mn=require("react"),Xt=require("react/jsx-runtime"),On=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=(0,Mn.useState)(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"],B=Array.isArray(t.options)?t.options:[];return B.length===0&&!o&&console.warn("AppStorys: QuizSticker has no options!",t.id),(0,Xt.jsxs)("div",{style:{...v,background:s.backgroundColor||r.backgroundColor},children:[t.question&&(0,Xt.jsx)("h3",{style:f,children:t.question}),(0,Xt.jsx)("div",{style:{...y,background:"transparent"},children:B.map((R,d)=>{let T=R.label||I[d]||"\u2022",l=R.id===i,p=R.isCorrect===!0,O={...b},A={...h};return i&&(p?(O.backgroundColor=s.activeColor||r.activeColor,O.borderColor=s.activeColor||r.activeColor,O.color="#FFFFFF"):l&&(O.backgroundColor=s.incorrectColor||r.incorrectColor,O.borderColor=s.incorrectColor||r.incorrectColor,O.color="#FFFFFF")),(0,Xt.jsxs)("button",{style:O,onClick:()=>w(R.id),disabled:!!i,children:[(0,Xt.jsx)("div",{style:h,className:"letter-circle",children:T}),(0,Xt.jsx)("span",{style:{fontWeight:"600",fontSize:`${u}px`},children:R.text})]},R.id)})})]})};var Ke=require("react"),Tt=require("react/jsx-runtime"),jn=({data:t})=>{let[e,o]=(0,Ke.useState)({days:"00",hours:"00",minutes:"00",seconds:"00"});(0,Ke.useEffect)(()=>{if(!t.targetDate)return;let T=()=>{let p=+new Date(t.targetDate)-+new Date;if(p>0){let O=Math.floor(p/864e5),A=Math.floor(p/(1e3*60*60)%24),_=Math.floor(p/1e3/60%60),C=Math.floor(p/1e3%60);o({days:O.toString().padStart(2,"0"),hours:A.toString().padStart(2,"0"),minutes:_.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},B=(T,l)=>(0,Tt.jsxs)("div",{style:b,children:[(0,Tt.jsx)("div",{style:h,children:T.split("").map((p,O)=>(0,Tt.jsx)("div",{style:y,children:p},O))}),(0,Tt.jsx)("span",{style:w,children:l})]}),R=[],d=0;return n.showDays!==!1&&(R.push(B(e.days,"days")),d++),n.showHours!==!1&&(d>0&&R.push((0,Tt.jsx)("div",{style:I,children:":"},"sep-h")),R.push(B(e.hours,"hours")),d++),n.showMinutes!==!1&&(d>0&&R.push((0,Tt.jsx)("div",{style:I,children:":"},"sep-m")),R.push(B(e.minutes,"min")),d++),n.showSeconds!==!1&&(d>0&&R.push((0,Tt.jsx)("div",{style:I,children:":"},"sep-s")),R.push(B(e.seconds,"sec")),d++),(0,Tt.jsxs)("div",{style:g,children:[t.title&&(0,Tt.jsx)("div",{style:v,children:t.title}),(0,Tt.jsx)("div",{style:f,children:R})]})};var Nn=require("react"),Ft=require("react/jsx-runtime"),qn=({data:t,onInteraction:e})=>{let[o,i]=(0,Nn.useState)(!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(0,Ft.jsxs)("div",{style:s,onClick:n,children:[(0,Ft.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[(0,Ft.jsx)("div",{style:a,children:"%"}),(0,Ft.jsx)("span",{style:c,children:t.code||"OFFER20"})]}),(0,Ft.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[o&&(0,Ft.jsx)("span",{style:{fontSize:"11px",color:"#10B981",fontWeight:"700"},children:"Copied!"}),(0,Ft.jsx)("div",{style:{padding:"8px",display:"flex",alignItems:"center"},children:(0,Ft.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#4A5568",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,Ft.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,Ft.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]})};var $o=require("react/jsx-runtime"),Un=({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(0,$o.jsx)("div",{style:s,children:n.map((c,u)=>(0,$o.jsx)("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))})};var ae=require("react"),se=require("react/jsx-runtime"),Hn=({data:t,onInteraction:e,isEditing:o=!1})=>{let i=t.maxRating||5,n=t.currentRating??Math.floor(i/2),[r,s]=(0,ae.useState)(n),a=(0,ae.useRef)(null),[c,u]=(0,ae.useState)(!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,O=Math.round(p*i*10)/10;s(O)},B=d=>{o||(u(!0),I(d.clientX))},R=d=>{o||(u(!0),I(d.touches[0].clientX))};return(0,ae.useEffect)(()=>{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]),(0,se.jsxs)("div",{style:g,children:[(0,se.jsx)("h3",{style:v,children:t.title||"Do you like my space?"}),(0,se.jsxs)("div",{ref:a,style:f,onMouseDown:B,onTouchStart:R,children:[(0,se.jsx)("div",{style:h}),(0,se.jsx)("div",{style:w,className:"interactive-emoji-thumb",children:t.emoji||"\u{1F60D}"})]})]})};var Vn=require("react"),Nt=require("react/jsx-runtime"),Yn=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=(0,Vn.useState)(""),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(0,Nt.jsxs)("div",{style:a,children:[(0,Nt.jsx)("div",{style:c,children:t.question||"Ask me anything"}),(0,Nt.jsxs)("div",{style:u,children:[(0,Nt.jsx)("input",{type:"text",value:i,placeholder:t.placeholder||"Type your answer...",style:x,disabled:o,onChange:g,onKeyDown:f=>f.key==="Enter"&&v()}),(0,Nt.jsx)("button",{style:m,onClick:v,children:(0,Nt.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,Nt.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,Nt.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})};var Qn=require("react"),qt=require("react/jsx-runtime"),Gn=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=(0,Qn.useState)(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(0,qt.jsxs)("div",{style:a,children:[t.question&&(0,qt.jsx)("h3",{style:c,children:t.question}),(0,qt.jsx)("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)")),(0,qt.jsxs)("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:[(0,qt.jsxs)("div",{style:{width:"100%",aspectRatio:"1",borderRadius:"12px",overflow:"hidden",backgroundColor:"#EDF2F7",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"8px",position:"relative"},children:[(0,qt.jsx)("img",{src:f.image||g,alt:f.text,style:{width:"100%",height:"100%",objectFit:"cover"}}),i&&(0,qt.jsx)("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":""})]}),(0,qt.jsx)("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)})})]})};var jo=require("react");var Kt=require("react"),D=require("react/jsx-runtime"),ei=({product:t,styling:e,onClose:o,onAddToCart:i})=>{let[n,r]=(0,Kt.useState)(""),[s,a]=(0,Kt.useState)(0),[c,u]=(0,Kt.useState)(1),[x,m]=(0,Kt.useState)(!1),[g,v]=(0,Kt.useState)(!1),f=t.attributes||{},b=f.colors||[],h=f.sizes||[],y=f.imageUrls||[t.image],w=f.description||"";(0,Kt.useEffect)(()=>{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(W){console.error("AppStorys: Redirect failed",W)}}m(!0)},B=()=>{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",O=e?.titleFontWeight||"600",A=e?.priceFontWeight||"700",_=e?.mrpFontWeight||"500";return x?(0,D.jsxs)("div",{className:"appstorys-shopable-success-overlay",style:Jn,children:[(0,D.jsx)("div",{className:"appstorys-shopable-backdrop",style:Xn,onClick:B}),(0,D.jsxs)("div",{className:"appstorys-shopable-sheet",style:{...Kn,height:"auto",minHeight:"310px",animation:"appstorys-slide-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[(0,D.jsx)("div",{style:Zn,onClick:B}),(0,D.jsxs)("div",{style:{padding:"0 20px 24px",textAlign:"center"},children:[(0,D.jsxs)("div",{style:{backgroundColor:"#F3F4F6",borderRadius:"20px",padding:"22px",marginTop:"16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[(0,D.jsxs)("h3",{style:{margin:0,fontSize:"16px",fontWeight:"600",lineHeight:"1.4"},children:["Added to your bag",(0,D.jsx)("br",{}),"successfully"]}),(0,D.jsx)("svg",{width:"44",height:"26",viewBox:"0 0 44 26",fill:"none",children:(0,D.jsx)("path",{d:"M4 4C4 4 11 22 22 22C33 22 40 4 40 4",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round"})})]}),(0,D.jsxs)("div",{style:{marginTop:"24px",display:"flex",flexDirection:"column",gap:"8px"},children:[(0,D.jsx)("button",{onClick:B,style:{...Oo,backgroundColor:"#000000",color:"#ffffff",padding:"17px",fontSize:"16px",fontWeight:"600"},children:(0,D.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[(0,D.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,D.jsx)("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),(0,D.jsx)("path",{d:"M3 6h18"}),(0,D.jsx)("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),"Go to checkout"]})}),(0,D.jsx)("button",{onClick:B,style:{...Oo,backgroundColor:"transparent",color:"#000000",border:"1px solid rgba(0,0,0,0.1)",padding:"15px",fontSize:"16px"},children:"Continue with stories"})]})]})]})]}):(0,D.jsxs)("div",{className:`appstorys-shopable-overlay ${g?"visible":""}`,style:Jn,children:[(0,D.jsx)("div",{className:"appstorys-shopable-backdrop",style:Xn,onClick:B}),(0,D.jsxs)("div",{className:"appstorys-shopable-sheet",style:{...Kn,transform:g?"translateY(0)":"translateY(100%)",opacity:g?1:0},children:[(0,D.jsxs)("div",{style:ar,children:[(0,D.jsx)("div",{style:Zn,onClick:B}),(0,D.jsx)("button",{style:lr,onClick:B,children:(0,D.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,D.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,D.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),(0,D.jsxs)("div",{style:dr,children:[(0,D.jsx)("div",{style:cr,children:y.map((C,S)=>(0,D.jsx)("div",{style:{minWidth:y.length>1?"85%":"100%",aspectRatio:"1.2 / 1",maxHeight:"240px",borderRadius:"16px",overflow:"hidden",backgroundColor:"#F9FAFB"},children:(0,D.jsx)("img",{src:C,alt:t.title,style:{width:"100%",height:"100%",objectFit:"contain"}})},S))}),(0,D.jsxs)("div",{style:{padding:"0 20px 20px"},children:[(0,D.jsx)("h2",{style:{margin:"16px 0 4px",fontSize:e?.titleFontSize?`${e.titleFontSize}px`:"20px",fontWeight:O,color:T,lineHeight:"1.2"},children:t.title}),(0,D.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",marginBottom:"16px"},children:[(0,D.jsx)("span",{style:{fontSize:e?.priceFontSize?`${e.priceFontSize}px`:"18px",fontWeight:A,color:l},children:t.price}),t.oldPrice&&(0,D.jsx)("span",{style:{fontSize:e?.mrpFontSize?`${e.mrpFontSize}px`:"14px",color:p,textDecoration:"line-through",fontWeight:_},children:t.oldPrice})]}),b.length>0&&(0,D.jsxs)("div",{style:Wo,children:[(0,D.jsx)("div",{style:Mo,children:"COLOR"}),(0,D.jsx)("div",{style:{display:"flex",gap:"14px",marginTop:"12px"},children:b.map((C,S)=>(0,D.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"5px"},children:[(0,D.jsx)("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"}}),(0,D.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:s===S?"#000":"transparent",transition:"all 0.2s ease"}})]},C.id))})]}),h.length>0&&(0,D.jsxs)("div",{style:Wo,children:[(0,D.jsx)("div",{style:Mo,children:"SIZE"}),(0,D.jsx)("div",{style:{display:"flex",gap:"10px",marginTop:"12px",flexWrap:"wrap"},children:h.map(C=>(0,D.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},children:[(0,D.jsx)("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}),(0,D.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:n===C?"#000":"transparent",transition:"all 0.2s ease"}})]},C))})]}),w&&(0,D.jsxs)("div",{style:Wo,children:[(0,D.jsx)("div",{style:Mo,children:"DESCRIPTION"}),(0,D.jsx)("p",{style:{margin:"8px 0 0",fontSize:"14px",lineHeight:"1.5",color:"#8b8b98",wordBreak:"break-word"},children:w})]})]})]}),(0,D.jsxs)("div",{style:pr,children:[(0,D.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1px",minWidth:"75px"},children:[(0,D.jsx)("div",{style:{fontSize:"15px",fontWeight:A,color:l},children:t.price}),t.oldPrice&&(0,D.jsx)("div",{style:{fontSize:"11px",color:p,textDecoration:"line-through",fontWeight:_},children:t.oldPrice})]}),(0,D.jsxs)("div",{style:ur,children:[(0,D.jsx)("button",{style:ti,onClick:()=>u(C=>Math.max(1,C-1)),children:(0,D.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,D.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}),(0,D.jsx)("span",{style:{fontSize:"16px",fontWeight:"700",minWidth:"18px",textAlign:"center",color:"#000000",display:"inline-block"},children:c}),(0,D.jsx)("button",{style:ti,onClick:()=>u(C=>C+1),children:(0,D.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,D.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,D.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),(()=>{let C=f.availability?.toLowerCase()||"",S=C==="out of stock"||C==="out-of-stock";return(0,D.jsxs)("button",{onClick:S?void 0:I,disabled:S,style:{...Oo,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&&(0,D.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,D.jsx)("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),(0,D.jsx)("path",{d:"M3 6h18"}),(0,D.jsx)("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),(0,D.jsx)("span",{style:{fontSize:"12px",fontWeight:"700",whiteSpace:"nowrap"},children:S?"Out of Stock":"Add to cart"})]})})()]})]}),(0,D.jsx)("style",{children:`
33
+ `,document.head.appendChild(t)}function Mi(t){let e=document.createElement("div");return e.className="appstorys-widget-debug-pill",e.textContent=t,e}function Ss(t){let e=t,o=getComputedStyle(e);(o.position==="static"||!o.position)&&(e.style.position="relative")}window.AppStorysShowWidgetElements=function(){try{xs();let e=Array.from(document.querySelectorAll("[data-as-id], [data-widget], [data-widget-id]"));if(e.length||["#hero_section",".hero_section","#header_container",".header_container"].forEach(n=>{let i=document.querySelector(n);i&&e.push(i)}),!e.length){let o=Mi("Widget");o.style.position="fixed",o.style.top="12px",o.style.left="12px",o.style.pointerEvents="auto",document.body.appendChild(o);return}e.forEach((o,n)=>{let i=o;Ss(i),i.classList.add("appstorys-widget-debug-overlay");let s=i.querySelector(".appstorys-widget-debug-pill");s&&s.remove();let l=Mi("Widget "+(n+1));i.appendChild(l)})}catch(e){console.error("AppStorysShowWidgetElements error",e)}};var $e=ge(require("react"));bt();var Io=require("react"),lo=ge(require("lottie-react")),Mn=require("react/jsx-runtime"),Pi=lo.default?.default??lo.default??lo.Lottie??lo,ke=({src:t,alt:e,style:o,size:n})=>{let[i,s]=(0,Io.useState)(null),[l,c]=(0,Io.useState)(!1);(0,Io.useEffect)(()=>{t&&t.toLowerCase().endsWith(".json")?fetch(t).then(y=>{if(!y.ok)throw new Error("Failed to fetch Lottie");return y.json()}).then(y=>{s(y),c(!1)}).catch(y=>{console.error("AppStorys: Error loading Lottie thumbnail:",y),c(!0)}):(s(null),c(!1))},[t]);let d={width:n?`${n}px`:o?.width||"100%",height:n?`${n}px`:o?.height||"100%",objectFit:"cover",display:"block",...o},S=o?.objectFit||"cover",p=S==="contain"?"xMidYMid meet":S==="fill"?"none":"xMidYMid slice";if(i&&!l){let y=Pi.default||Pi;return(0,Mn.jsx)(y,{animationData:i,loop:!0,autoplay:!0,style:d,rendererSettings:{preserveAspectRatio:p}})}return(0,Mn.jsx)("img",{src:t,alt:e||"story thumbnail",style:d,onError:()=>c(!0)})};var co=require("react/jsx-runtime"),Di=({story:t,isViewed:e,onClick:o})=>{let n=t.styling||{},i=n.size||80,s=n.ringWidth!==void 0?n.ringWidth:3,l=n.ringAndImageSpace!==void 0?n.ringAndImageSpace:3,c=e?"#E5E7EB":t.ringColor||"#FF0000",d=t.nameColor||"#333333",S=n.storyGroupText||t.name,p=n.cornerRadius,y=p?`${p.topLeft||0}px ${p.topRight||0}px ${p.bottomRight||0}px ${p.bottomLeft||0}px`:"50%",u=p?`${Math.max(0,(p.topLeft||0)-s)}px ${Math.max(0,(p.topRight||0)-s)}px ${Math.max(0,(p.bottomRight||0)-s)}px ${Math.max(0,(p.bottomLeft||0)-s)}px`:"50%",h=lt(n.name?.fontFamily||n.name?.font)||n.name?.fontFamily||(n.name?.font&&n.name.font!=="Bold"&&n.name.font!=="Normal"?n.name.font:void 0)||"sans-serif",g=n.name?.font==="Bold"||n.name?.font==="bold"||n.name?.font?.toLowerCase()?.includes("bold");return(0,co.jsxs)("div",{onClick:o,style:{display:"flex",flexDirection:"column",alignItems:"center",cursor:"pointer",flexShrink:0},children:[(0,co.jsx)("div",{style:{width:`${i}px`,height:`${i}px`,borderRadius:y,border:`${s}px solid ${c}`,padding:`${l}px`,boxSizing:"border-box",transition:"transform 0.1s ease",overflow:"hidden",backgroundColor:"#f5f5f5"},children:(0,co.jsx)(ke,{src:t.thumbnail,alt:S,style:{borderRadius:u}})}),(0,co.jsx)("span",{style:{marginTop:"6px",fontSize:`${n.name?.size||12}px`,fontFamily:h,fontWeight:g?"bold":"normal",color:d,maxWidth:`${i+20}px`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textAlign:"center"},children:S})]})};var Pn=require("react/jsx-runtime"),_i=({stories:t,viewedStories:e,onStoryClick:o})=>(0,Pn.jsx)("div",{style:{display:"flex",gap:"18px",padding:"16px 20px",overflowX:"auto",WebkitOverflowScrolling:"touch",justifyContent:"flex-start"},children:t.sort((n,i)=>n.order-i.order).map((n,i)=>(0,Pn.jsx)(Di,{story:n,isViewed:e.includes(n.id),onClick:()=>o(i)},n.id))});var yt=ge(require("react"));bt();bt();var Wi=()=>P.getState().trackingUrl||"https://tracking.appstorys.co";var Eo=require("react"),po=ge(require("lottie-react"));var et=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=et(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}}},Ct=t=>{if(!t)return;if(typeof t=="string")return t;if(typeof t=="object"){if(typeof t.solid=="string"&&t.solid)return t.solid;if(typeof t.value=="string"&&t.value)return t.value;if(typeof t.color=="string"&&t.color)return t.color}let e=t.color||{};if(typeof e=="object"&&e&&e.type==="gradient"&&e.gradient){let{direction:o="right",from:n,to:i,stops:s=[]}=e.gradient,c={right:"to right",left:"to left",top:"to top",bottom:"to bottom"}[o]||o;if(s.length>0){let d=s.map(S=>{let p=S.offset,y="0%";if(p!=null){let u=String(p).trim();if(u.endsWith("%"))y=u;else{let C=Number(u);isNaN(C)||(y=C>1?`${C}%`:`${Math.round(C*100)}%`)}}return`${S.color} ${y}`}).join(", ");return`linear-gradient(${c}, ${d})`}return`linear-gradient(${c}, ${n}, ${i})`}return et(t)},Bo=t=>{if(!t||t.type==="none")return;let e=String(t.type).toLowerCase(),o=t.duration||.6;if(e==="fade")return`appstorys-fade-in ${o}s ease-out forwards`;if(e==="classic")return`appstorys-classic-in ${o}s cubic-bezier(0.34, 1.56, 0.64, 1) forwards`;if(e==="rotate")return`appstorys-rotate-in ${o}s ease-out forwards`;if(e==="bounce")return`appstorys-bounce-in ${o+.2}s cubic-bezier(0.68, -0.6, 0.32, 1.6) forwards`},nt=(t,e="px")=>{if(t==null||t==="")return"";let o=String(t).trim();return/^[\d.-]+$/.test(o)?`${o}${e}`:o},uo=t=>{if(!t||typeof t!="string")return"center center";let e=t.trim().toLowerCase().replace(/_/g,"-");switch(e){case"top-left":case"left-top":return"top left";case"top-center":case"center-top":case"top":return"top center";case"top-right":case"right-top":return"top right";case"center-left":case"left-center":case"left":return"center left";case"center":case"center-center":return"center center";case"center-right":case"right-center":case"right":return"center right";case"bottom-left":case"left-bottom":return"bottom left";case"bottom-center":case"center-bottom":case"bottom":return"bottom center";case"bottom-right":case"right-bottom":return"bottom right";default:return e.replace("-"," ")}};var $i=ge(require("react"));var Re=require("react/jsx-runtime"),Ni=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=$i.default.useState(()=>{try{return localStorage.getItem(`appstorys_poll_${t.id}`)}catch{return null}}),s=t.layout?.type==="horizontal",l={headerTextColor:"#000000",optionBgColor:"#1A1A1A",optionTextColor:"#FFFFFF",backgroundColor:"#FFFFFF",borderRadius:20,padding:12},c=t.styling||{},d=lt(c.questionFontFamily||c.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),S=lt(c.optionFontFamily||c.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),p=c.optionBorderRadius??c.optionRadius,y=p!==void 0?nt(p):"9999px",u=c.optionBgColor||"#1A1A1A",C={backgroundColor:c.backgroundColor||l.backgroundColor,borderRadius:nt(c.borderRadius??l.borderRadius),overflow:"hidden",boxShadow:c.shadow||"0 12px 24px rgba(0,0,0,0.1)",boxSizing:"border-box",width:"100%",maxWidth:"280px",margin:"0 auto",opacity:c.opacity??1,padding:"14px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"10px"},h={color:c.headerTextColor||l.headerTextColor,textAlign:"center",fontWeight:"700",fontSize:nt(c.fontSize||14),lineHeight:"1.25",margin:"0",width:"100%",fontFamily:d},g={display:"flex",flexDirection:s?"row":"column",gap:s?n?"0px":"4px":nt(c.gap??8),width:"100%",backgroundColor:s?u:"transparent",borderRadius:s?nt(y):"0px",overflow:s?"hidden":"visible",padding:"0px"},b={backgroundColor:s?"transparent":u,color:c.optionTextColor||l.optionTextColor,padding:s?"8px 12px":"10px 16px",fontSize:nt(c.optionFontSize||14),fontWeight:"700",fontFamily:S,cursor:n?"default":"pointer",border:"none",borderRadius:s?"0px":nt(y),width:"100%",textAlign:"center",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)",flex:s?1:void 0,borderRight:s?"1px solid rgba(255,255,255,0.1)":"none",borderBottom:"none",position:"relative",overflow:"hidden"},m=Array.isArray(t.options)?t.options:[],E=v=>{let w=m.find(_=>_.id===v);if(!w)return 0;if(w.percentage!==void 0)return w.percentage;if(w.votes!==void 0){let _=m.reduce((N,U)=>N+(U.votes||0),0);if(_>0)return Math.round(w.votes/_*100)}return n?v===n?m.length===1?100:60:Math.round(40/(m.length-1)):0},j=(v,w)=>{let _=v.replace("#","");_.length===3&&(_=_.split("").map(T=>T+T).join(""));let N=parseInt(_.substring(0,2),16)||0,U=parseInt(_.substring(2,4),16)||0,A=parseInt(_.substring(4,6),16)||0;return`rgba(${N}, ${U}, ${A}, ${w})`},D=v=>{let w=v===n,_=w?c.activeResultBarColor:c.inactiveResultBarColor,N=_?.color||(w?"#F97316":"#404040"),U=_?.opacity!==void 0?_.opacity/100:1;return N.startsWith("#")&&(N.length===7||N.length===4)?j(N,U):N},L=v=>{if(!(o||n)){i(v);try{localStorage.setItem(`appstorys_poll_${t.id}`,v)}catch{}e?.({type:"poll",pollId:t.id,optionId:v,stickerId:t.id})}};return(0,Re.jsxs)("div",{style:C,children:[(0,Re.jsx)("h3",{style:h,children:t.question||"Ask A Question..."}),(0,Re.jsx)("div",{style:g,children:m.map((v,w)=>{let _=E(v.id),N=n!==null,U=v.id===n,A=N?s?D(v.id):u:s?"transparent":u;return(0,Re.jsxs)("button",{style:{...b,flex:N&&s?_:s?1:void 0,backgroundColor:A,borderRight:N||s&&w===m.length-1?"none":b.borderRight},onClick:()=>L(v.id),disabled:N,onMouseOver:T=>{!o&&!N&&!s&&(T.currentTarget.style.opacity="0.9")},onMouseOut:T=>{!o&&!N&&!s&&(T.currentTarget.style.opacity="1")},children:[N&&!s&&(0,Re.jsx)("div",{style:{position:"absolute",top:0,left:0,bottom:0,width:`${_}%`,backgroundColor:D(v.id),transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)",zIndex:1,borderRadius:"inherit"}}),(0,Re.jsxs)("div",{style:{display:"flex",flexDirection:s?"column":"row",justifyContent:s?"center":"space-between",alignItems:"center",width:"100%",zIndex:2,position:"relative"},children:[(0,Re.jsx)("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.text}),N&&(0,Re.jsxs)("span",{style:{fontWeight:"800",fontSize:s?"12px":"15px",marginTop:s?"4px":"0"},children:[_,"%"]})]})]},v.id)})})]})};var Oi=require("react");var jt=require("react/jsx-runtime"),ji=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=(0,Oi.useState)(()=>{try{return localStorage.getItem(`appstorys_quiz_${t.id}`)}catch{return null}}),s={backgroundColor:"#FFFFFF",borderRadius:28,padding:16,questionTextColor:"#FFFFFF",questionBgColor:"#000000",optionBgColor:"#F8FAFC",optionTextColor:"#1E293B",borderColor:"#000000",activeColor:"#10b981",incorrectColor:"#ef4444",labelBgColor:"#FFFFFF",labelTextColor:"#111111",labelBorderColor:"#111111"},l=t.styling||{},c=nt(l.padding??s.padding),d=nt(l.fontSize||16),S=nt(l.optionFontSize||15),p=l.optionBorderRadius!==void 0?nt(l.optionBorderRadius):"9999px",y=l.optionBorderColor||"#CBD5E1",u=lt(l.questionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),C=lt(l.optionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),h={backgroundColor:l.backgroundColor||s.backgroundColor,borderRadius:nt(l.borderRadius??s.borderRadius),padding:0,boxShadow:l.shadow||"0 12px 32px rgba(0,0,0,0.14)",boxSizing:"border-box",width:"100%",maxWidth:"270px",margin:"0 auto",display:"flex",flexDirection:"column",overflow:"hidden",opacity:l.opacity??1},g={color:l.questionTextColor||s.questionTextColor,backgroundColor:l.questionBgColor||s.questionBgColor,fontWeight:"700",fontSize:d,fontFamily:u,lineHeight:1.3,margin:0,textAlign:"center",padding:"14px 16px",minHeight:"48px",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",borderTopLeftRadius:nt(l.borderRadius??s.borderRadius),borderTopRightRadius:nt(l.borderRadius??s.borderRadius),letterSpacing:"-0.01em"},b={backgroundColor:l.optionBgColor||s.optionBgColor,color:l.optionTextColor||s.optionTextColor,fontFamily:C,padding:"8px 14px",borderRadius:p,border:`1px solid ${y}`,display:"flex",alignItems:"center",justifyContent:"flex-start",cursor:n?"default":"pointer",width:"100%",textAlign:"left",boxSizing:"border-box",transition:"all 0.2s ease",fontSize:S,fontWeight:"500"},m={backgroundColor:l.backgroundColor||s.backgroundColor,borderRadius:`0 0 ${nt(l.borderRadius??s.borderRadius)} ${nt(l.borderRadius??s.borderRadius)}`,display:"flex",flexDirection:"column",gap:"6px",padding:"10px 14px 12px 14px"},E=_=>{if(!(o||n)){i(_);try{localStorage.setItem(`appstorys_quiz_${t.id}`,_)}catch{}e?.({type:"quiz",quizId:t.id,optionId:_,stickerId:t.id})}},j=["A","B","C","D","E","F"],D=Array.isArray(t.options)?t.options:[];D.length===0&&!o&&console.warn("AppStorys: QuizSticker has no options!",t.id);let L=D.find(_=>_.id===n),v=L?L.isCorrect===!0:!1,w=!!n&&t.showExplanation!==!1&&!!t.explanation;return(0,jt.jsxs)("div",{style:{...h,background:l.backgroundColor||s.backgroundColor},children:[(0,jt.jsx)("style",{children:`
34
+ @keyframes appstorys-quiz-fade-in {
35
+ from { opacity: 0; transform: translateY(4px); }
36
+ to { opacity: 1; transform: translateY(0); }
37
+ }
38
+ `}),t.question&&(0,jt.jsx)("h3",{style:g,children:t.question}),(0,jt.jsxs)("div",{style:{...m,background:"transparent"},children:[D.map((_,N)=>{let U=_.label||j[N]||"\u2022",A=_.id===n,T=_.isCorrect===!0,k={...b};return n&&(T?(k.backgroundColor=l.activeColor||s.activeColor,k.borderColor=l.activeColor||s.activeColor,k.color="#FFFFFF"):A&&(k.backgroundColor=l.incorrectColor||s.incorrectColor,k.borderColor=l.incorrectColor||s.incorrectColor,k.color="#FFFFFF")),(0,jt.jsx)("button",{style:k,onClick:()=>E(_.id),disabled:!!n,children:(0,jt.jsx)("span",{style:{fontWeight:"600",fontSize:S},children:_.text})},_.id)}),w&&(0,jt.jsxs)("div",{style:{marginTop:"8px",padding:"12px 14px",backgroundColor:v?"#E6F4EA":"#FCE8E6",borderRadius:"12px",border:`1px solid ${v?"rgba(16, 185, 129, 0.3)":"rgba(239, 68, 68, 0.3)"}`,display:"flex",flexDirection:"column",gap:"4px",textAlign:"left",animation:"appstorys-quiz-fade-in 0.3s ease forwards"},children:[(0,jt.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[v?(0,jt.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",style:{flexShrink:0},children:[(0,jt.jsx)("circle",{cx:"10",cy:"10",r:"10",fill:"#10B981"}),(0,jt.jsx)("path",{d:"M6 10L9 13L14 7",stroke:"white",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})]}):(0,jt.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",style:{flexShrink:0},children:[(0,jt.jsx)("circle",{cx:"10",cy:"10",r:"10",fill:"#EF4444"}),(0,jt.jsx)("path",{d:"M7 7L13 13M13 7L7 13",stroke:"white",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})]}),(0,jt.jsx)("span",{style:{fontWeight:"700",fontSize:"14px",color:v?"#0ABA73":"#EF4444",fontFamily:C},children:v?"Correct":"Incorrect"})]}),(0,jt.jsx)("div",{style:{fontSize:"13px",color:"#374151",fontFamily:C,lineHeight:"1.4",paddingLeft:"26px",wordBreak:"break-word"},children:t.explanation})]})]})]})};var tn=require("react");var le=require("react/jsx-runtime"),qi=({data:t})=>{let[e,o]=(0,tn.useState)({days:"00",hours:"00",minutes:"00",seconds:"00"});(0,tn.useEffect)(()=>{if(!t.targetDate)return;let U=()=>{let T=+new Date(t.targetDate)-+new Date;if(T>0){let k=Math.floor(T/864e5),B=Math.floor(T/(1e3*60*60)%24),$=Math.floor(T/1e3/60%60),V=Math.floor(T/1e3%60);o({days:k.toString().padStart(2,"0"),hours:B.toString().padStart(2,"0"),minutes:$.toString().padStart(2,"0"),seconds:V.toString().padStart(2,"0")})}else o({days:"00",hours:"00",minutes:"00",seconds:"00"})},A=setInterval(U,1e3);return U(),()=>clearInterval(A)},[t.targetDate]);let n=t.styling||{},i=t.display||{showDays:!0,showHours:!0,showMinutes:!0,showSeconds:!0},s=lt(n.questionFontFamily||n.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),l=n.digitSize||n.fontSize,c=typeof l=="string",d=c?l:`${!isNaN(Number(l))&&Number(l)>0?Number(l):18}px`,S=n.labelFontSize?nt(n.labelFontSize):c?`calc(${d} * 0.45)`:`${Math.max(10,Math.round(Number(l||18)*.45))}px`,p=c?`calc(${d} * 1.65)`:`${Math.max(36,Math.round(Number(l||18)*1.65))}px`,y=c?`calc(${d} * 0.95)`:`${Math.max(26,Math.round(Number(l||18)*.95))}px`,u=c?`calc(${d} * 0.25)`:`${Math.max(6,Math.round(Number(l||18)*.25))}px`,C=c?`calc(${d} * 0.15)`:`${Math.max(6,Math.round(Number(l||18)*.15))}px`,h=c?`calc(${d} * 0.75)`:`${Math.max(14,Math.round(Number(l||18)*.75))}px`,g={backgroundColor:n.backgroundColor||"#FFFFFF",borderRadius:nt(n.borderRadius!==void 0?n.borderRadius:16),padding:n.padding?nt(n.padding):"16px 18px",boxShadow:n.shadow||"0 10px 30px rgba(0,0,0,0.08)",width:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",gap:"10px",border:n.borderColor?`1px solid ${n.borderColor}`:"none",overflow:"hidden",opacity:n.opacity??1},b={color:n.titleColor||"#000000",fontWeight:"700",fontSize:nt(n.fontSize||14),fontFamily:s,width:"100%",textAlign:"center",marginBottom:"4px"},m={display:"flex",gap:C,width:"100%",justifyContent:"center",alignItems:"center",flexWrap:"nowrap"},E={display:"flex",flexDirection:"column",alignItems:"center",gap:"2px"},j={display:"flex",gap:"2px"},D={backgroundColor:n.digitBackground||"#F1F3F5",borderRadius:u,minWidth:y,height:p,display:"flex",alignItems:"center",justifyContent:"center",fontSize:d,fontWeight:"bold",color:n.digitColor||"#1A202C",padding:"0 4px"},L={fontSize:c?S:`${Math.max(9,Number(String(S).replace("px","")))}px`,color:n.labelColor||"#A0AEC0",fontWeight:"600",textTransform:"lowercase"},v={fontSize:h,fontWeight:"700",color:n.labelColor||"#A0AEC0",display:"flex",alignItems:"center",lineHeight:1},w=(U,A)=>(0,le.jsxs)("div",{style:E,children:[(0,le.jsx)("div",{style:j,children:U.split("").map((T,k)=>(0,le.jsx)("div",{style:D,children:T},k))}),(0,le.jsx)("span",{style:L,children:A})]}),_=[],N=0;return i.showDays!==!1&&(_.push(w(e.days,"days")),N++),i.showHours!==!1&&(N>0&&_.push((0,le.jsx)("div",{style:v,children:":"},"sep-h")),_.push(w(e.hours,"hours")),N++),i.showMinutes!==!1&&(N>0&&_.push((0,le.jsx)("div",{style:v,children:":"},"sep-m")),_.push(w(e.minutes,"minutes")),N++),i.showSeconds!==!1&&(N>0&&_.push((0,le.jsx)("div",{style:v,children:":"},"sep-s")),_.push(w(e.seconds,"seconds")),N++),(0,le.jsxs)("div",{style:g,children:[t.title&&(0,le.jsx)("div",{style:b,children:t.title}),(0,le.jsx)("div",{style:m,children:_})]})};var Hi=require("react");var de=require("react/jsx-runtime"),Vi=({data:t,onInteraction:e})=>{let[o,n]=(0,Hi.useState)(!1),i=y=>{y.stopPropagation(),t.code&&(navigator.clipboard.writeText(t.code).catch(()=>{}),n(!0),e?.({type:"promo_code",value:"copied",stickerId:t.id,code:t.code}),setTimeout(()=>n(!1),2e3))},s=t.styling||{},l=s.backgroundColor||"#F4F4F6",c=lt(s.fontFamily,'"SF Mono", "Roboto Mono", Menlo, Consolas, "Courier New", monospace'),d={backgroundColor:l,padding:"6px 14px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",minHeight:"36px",boxSizing:"border-box",position:"relative",boxShadow:s.shadow||"0 4px 16px rgba(0,0,0,0.08)",cursor:"pointer",WebkitMaskImage:"radial-gradient(circle at 0px 50%, transparent 6px, black 6.5px), radial-gradient(circle at 100% 50%, transparent 6px, black 6.5px)",maskImage:"radial-gradient(circle at 0px 50%, transparent 6px, black 6.5px), radial-gradient(circle at 100% 50%, transparent 6px, black 6.5px)",WebkitMaskComposite:"destination-in",maskComposite:"intersect"};return(0,de.jsxs)("div",{style:d,onClick:i,children:[(0,de.jsx)("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:"%"}),(0,de.jsx)("div",{style:{flex:1,minWidth:0,padding:"0 8px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,de.jsx)("span",{style:{fontSize:"13px",fontWeight:"700",color:o?"#10B981":"#000000",fontFamily:c,letterSpacing:"0.5px",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block",width:"100%",transition:"color 0.2s ease"},children:o?"Copied!":t.code||"OFFER20"})}),(0,de.jsx)("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?(0,de.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#10B981",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,de.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,de.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[(0,de.jsx)("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2.5",stroke:"#000000",strokeWidth:"2",fill:"none"}),(0,de.jsx)("rect",{x:"4",y:"4",width:"12",height:"12",rx:"2.5",stroke:"#000000",strokeWidth:"2",fill:"none"})]})})]})};var Lo=require("react");var Ze=require("react/jsx-runtime"),Ui=({data:t,onInteraction:e,isEditing:o=!1})=>{let n={emojis:["\u{1F60D}","\u{1F44D}"]},i=Array.isArray(t.emojis)?t.emojis:Array.isArray(n.emojis)?n.emojis:[],[s,l]=(0,Lo.useState)(()=>{try{return localStorage.getItem(`appstorys_reaction_${t.id}`)!==null}catch{return!1}}),[c,d]=(0,Lo.useState)({});(0,Lo.useEffect)(()=>{let g={},b=(()=>{try{return localStorage.getItem(`appstorys_reaction_${t.id}`)}catch{return null}})();i.forEach(m=>{let E=Math.random()>.5?1999:2e3;b&&m===b&&(E+=1),g[m]=E}),d(g)},[t.emojis]);let S=(g,b)=>{if(!(o||s)){d(m=>({...m,[g]:(m[g]||0)+1})),l(!0);try{localStorage.setItem(`appstorys_reaction_${t.id}`,g)}catch{}e?.({type:"reaction",reactionId:t.id,optionId:`option${b+1}`,selected_option:`option${b+1}`,emoji:g,stickerId:t.id})}},p=g=>g>=1e3?(g/1e3).toFixed(0)+"k":String(g),y={display:"flex",gap:"10px",justifyContent:"center",alignItems:"center",width:"100%",padding:"6px",boxSizing:"border-box"},u={backgroundColor:"#FFFFFF",width:"52px",height:s?"72px":"52px",borderRadius:"100px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:s?"space-between":"center",padding:s?"6px 0":"0",boxShadow:"0 8px 30px rgba(0,0,0,0.12)",cursor:o||s?"default":"pointer",border:"none",outline:"none",position:"relative",zIndex:1,boxSizing:"border-box",flexShrink:0},C={fontSize:"28px",lineHeight:"1",userSelect:"none"},h={fontSize:"13px",fontWeight:"800",color:"#374151",animation:"appstorys-reaction-fade-in 0.3s ease forwards",lineHeight:"1",userSelect:"none",fontFamily:lt(t.styling?.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif')};return(0,Ze.jsxs)("div",{style:y,children:[(0,Ze.jsx)("style",{children:`
39
+ @keyframes appstorys-reaction-fade-in {
40
+ from { opacity: 0; transform: translateY(4px); }
41
+ to { opacity: 1; transform: translateY(0); }
42
+ }
43
+ .appstorys-reaction-btn {
44
+ transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
45
+ }
46
+ .appstorys-reaction-btn:not(.voted):not(.editing):hover {
47
+ transform: scale(1.15) translateY(-4px) !important;
48
+ }
49
+ .appstorys-reaction-btn.voted {
50
+ transform: scale(1) translateY(0) !important;
51
+ }
52
+ `}),i.map((g,b)=>{let m=c[g]||2e3;return(0,Ze.jsxs)("button",{className:`appstorys-reaction-btn ${s?"voted":""} ${o?"editing":""}`,style:u,onClick:()=>S(g,b),children:[(0,Ze.jsx)("span",{style:C,children:g}),s&&(0,Ze.jsx)("span",{style:h,children:p(m)})]},b)})]})};var De=require("react");var _e=require("react/jsx-runtime"),Yi=({data:t,onInteraction:e,isEditing:o=!1})=>{let n=t.maxRating||5,i=t.currentRating??Math.floor(n/2),[s,l]=(0,De.useState)(()=>{try{let B=localStorage.getItem(`appstorys_rating_${t.id}`);return B?Number(B):i}catch{return i}}),c=(0,De.useRef)(null),[d,S]=(0,De.useState)(!1),[p,y]=(0,De.useState)(()=>{try{return localStorage.getItem(`appstorys_rating_${t.id}`)!==null}catch{return!1}}),[u,C]=(0,De.useState)([]),h={backgroundColor:"#FFFFFF",borderRadius:20,padding:14,titleColor:"#000000",titleFontSize:15,sliderTrackColor:"#F3F4F6",sliderFillColor:"#F97316",emojiSize:32},g=t.styling||{},b=lt(g.questionFontFamily||g.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),m={backgroundColor:g.backgroundColor||h.backgroundColor,borderRadius:nt(g.borderRadius??h.borderRadius),padding:g.padding?nt(g.padding):"8px 12px",boxShadow:g.shadow||"0 10px 24px rgba(0,0,0,0.08)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",cursor:"default",opacity:g.opacity??1},E={color:g.titleColor||h.titleColor,fontWeight:"700",fontSize:typeof g.titleFontSize=="string"?`min(${g.titleFontSize}, 16px)`:`${g.titleFontSize?Math.min(Number(g.titleFontSize),16):15}px`,margin:"0",textAlign:"center",lineHeight:"1.25",fontFamily:b,width:"100%"},j={width:"100%",height:"16px",backgroundColor:g.sliderTrackColor||h.sliderTrackColor,borderRadius:"100px",position:"relative",cursor:o||p?"default":"pointer",marginTop:"4px",marginBottom:"2px",userSelect:"none"},D=s/n*100,L={width:`${D}%`,height:"100%",background:g.sliderFillColor||"linear-gradient(90deg, #FF4582, #e11d48)",borderRadius:"100px",transition:d?"none":"width 0.1s ease"},v=g.emojiSize||h.emojiSize,w=typeof v=="string",_=nt(v),N={position:"absolute",left:w?`calc(${D}% - calc(${_} / 2))`:`calc(${D}% - ${Number(v)/2}px)`,top:w?`calc(50% - calc(${_} / 2))`:`calc(50% - ${Number(v)/2}px)`,fontSize:_,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",cursor:p||o?"default":"grab",transition:d?"none":"left 0.1s ease",filter:"drop-shadow(0 4px 8px rgba(0,0,0,0.2))",animation:p?"thumbPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards":"none"},U=B=>{if(!c.current||o||p)return;let $=c.current.getBoundingClientRect(),V=B-$.left;V<0&&(V=0),V>$.width&&(V=$.width);let G=V/$.width,r=Math.round(G*n*10)/10;l(r)},A=B=>{o||p||(S(!0),U(B.clientX))},T=B=>{o||p||(S(!0),U(B.touches[0].clientX))},k=()=>{let B=Array.from({length:16}).map(($,V)=>({id:Date.now()+V,scale:.5+Math.random()*.8,angle:V*22.5+(Math.random()*15-7.5),delay:Math.random()*.1}));C(B),setTimeout(()=>{C([])},1200)};return(0,De.useEffect)(()=>{let B=G=>{d&&U(G.clientX)},$=()=>{if(d){S(!1),y(!0);try{localStorage.setItem(`appstorys_rating_${t.id}`,String(s))}catch{}k(),e?.({type:"rating",ratingId:t.id,value:s,stickerId:t.id})}},V=G=>{d&&U(G.touches[0].clientX)};return d&&(window.addEventListener("mousemove",B),window.addEventListener("mouseup",$),window.addEventListener("touchmove",V),window.addEventListener("touchend",$)),()=>{window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",$),window.removeEventListener("touchmove",V),window.removeEventListener("touchend",$)}},[d,s]),(0,_e.jsxs)("div",{style:m,children:[(0,_e.jsx)("style",{children:`
53
+ @keyframes emojiBurst {
54
+ 0% {
55
+ transform: translate(0, 0) scale(0.3);
56
+ opacity: 1;
57
+ }
58
+ 90% {
59
+ opacity: 0.9;
60
+ }
61
+ 100% {
62
+ transform: translate(var(--tx), var(--ty)) scale(var(--scale));
63
+ opacity: 0;
64
+ }
65
+ }
66
+ @keyframes thumbPop {
67
+ 0% { transform: scale(1); }
68
+ 50% { transform: scale(1.3); }
69
+ 100% { transform: scale(1); }
70
+ }
71
+ `}),(0,_e.jsx)("h3",{style:E,children:t.title||"Do you like my space?"}),(0,_e.jsxs)("div",{ref:c,style:j,onMouseDown:A,onTouchStart:T,children:[(0,_e.jsx)("div",{style:L}),(0,_e.jsxs)("div",{style:N,className:"interactive-emoji-thumb",children:[t.emoji||"\u{1F60D}",u.map(B=>{let $=60+Math.random()*80,V=B.angle*Math.PI/180,G=`${Math.cos(V)*$}px`,r=`${Math.sin(V)*$}px`;return(0,_e.jsx)("span",{style:{position:"absolute",left:"50%",top:"50%",width:"30px",height:"30px",marginLeft:"-15px",marginTop:"-15px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"24px",pointerEvents:"none",zIndex:100,animation:`emojiBurst 1s cubic-bezier(0.15, 0.85, 0.35, 1) ${B.delay}s forwards`,"--tx":G,"--ty":r,"--scale":B.scale},children:t.emoji||"\u{1F60D}"},B.id)})]})]})]})};var Dn=require("react");var Fe=require("react/jsx-runtime"),Gi=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=(0,Dn.useState)(()=>{try{return localStorage.getItem(`appstorys_question_${t.id}`)||""}catch{return""}}),[s,l]=(0,Dn.useState)(()=>{try{return localStorage.getItem(`appstorys_question_${t.id}`)!==null}catch{return!1}}),c={backgroundColor:"#FFFFFF",borderRadius:16,padding:16,promptColor:"#111111",inputBgColor:"#FFFFFF",borderColor:"#EFEFEF",textColor:"#333333",placeholderColor:"#A0AEC0"},d=t.styling||{},S=lt(d.questionFontFamily||d.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),p=lt(d.optionFontFamily||d.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),y={backgroundColor:d.backgroundColor||c.backgroundColor,borderRadius:nt(d.borderRadius??c.borderRadius),padding:d.padding?nt(d.padding):"10px 12px",boxShadow:d.shadow||"0 8px 24px rgba(0,0,0,0.06)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",border:`1px solid ${d.borderColor||"#F0F0F0"}`},u={color:d.promptColor||c.promptColor,fontWeight:"700",fontSize:nt(d.fontSize||16),fontFamily:S,textAlign:"center",marginBottom:"2px",width:"100%"},C={width:"100%",position:"relative",display:"flex",alignItems:"center"},h=d.optionRadius??d.inputBorderRadius??d.optionBorderRadius??d.inputRadius,g=h!==void 0?typeof h=="number"&&h>=5?"9999px":nt(h):"9999px",b={backgroundColor:d.inputBgColor||"#F1F3F5",border:"none",borderRadius:g,padding:"8px 36px 8px 14px",width:"100%",boxSizing:"border-box",color:d.inputTextColor||"#1A202C",fontSize:"13px",fontFamily:p,outline:"none",textAlign:"left",cursor:o?"default":"text",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},m={position:"absolute",right:"4px",background:d.submitBackground||"#FE6B35",color:"white",border:"none",borderRadius:"50%",width:"24px",height:"24px",display:n.length>0&&!s?"flex":"none",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"transform 0.2s"},E=D=>{o||s||i(D.target.value)},j=()=>{if(!(o||!n.trim()||s)){l(!0);try{localStorage.setItem(`appstorys_question_${t.id}`,n.trim())}catch{}e?.({type:"question",questionId:t.id,value:n.trim(),stickerId:t.id})}};return(0,Fe.jsxs)("div",{style:y,children:[(0,Fe.jsx)("div",{style:u,children:t.question||"Ask me anything"}),(0,Fe.jsxs)("div",{style:C,children:[(0,Fe.jsx)("input",{type:"text",value:n,placeholder:s?"Submitted!":t.placeholder||"Type your answer...",style:b,disabled:o||s,onChange:E,onKeyDown:D=>D.key==="Enter"&&j()}),(0,Fe.jsx)("button",{style:m,onClick:j,children:(0,Fe.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,Fe.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,Fe.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})};var Qi=require("react");var Te=require("react/jsx-runtime"),Xi=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=(0,Qi.useState)(()=>{try{return localStorage.getItem(`appstorys_image_quiz_${t.id}`)}catch{return null}}),s={backgroundColor:"#FFFFFF",borderRadius:16,padding:10,optionBgColor:"#F8FAFC",optionTextColor:"#0F172A",borderColor:"#E2E8F0",activeColor:"#10B981",incorrectColor:"#EF4444"},l=t.styling||{},c=nt(l.padding??s.padding),d=nt(l.borderRadius??s.borderRadius),S=lt(l.questionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),p=lt(l.optionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),y={backgroundColor:l.backgroundColor||s.backgroundColor,borderRadius:d,padding:c,boxShadow:l.shadow||"0 12px 32px rgba(0,0,0,0.12)",boxSizing:"border-box",width:"100%",maxWidth:"280px",margin:"0 auto",display:"flex",flexDirection:"column",opacity:l.opacity??1,border:l.borderColor?`1px solid ${l.borderColor}`:"none",overflow:"hidden"},u={color:l.questionTextColor||"#FFFFFF",backgroundColor:l.questionBgColor||"#000000",fontWeight:"800",fontSize:nt(l.fontSize||15),fontFamily:S,margin:`calc(-1 * ${c}) calc(-1 * ${c}) 8px calc(-1 * ${c})`,padding:`12px ${c} 10px ${c}`,textAlign:"center",borderTopLeftRadius:d,borderTopRightRadius:d},g={display:"grid",gridTemplateColumns:`repeat(${(v=>{if(typeof v=="number"&&!isNaN(v)&&v>0)return v;if(typeof v=="string"){let w=parseInt(v,10);if(!isNaN(w)&&w>0)return w}if(typeof v=="object"&&v!==null){let w=v.columns||v.cols||v.columnCount;if(typeof w=="number"&&!isNaN(w)&&w>0)return w;if(typeof w=="string"){let _=parseInt(w,10);if(!isNaN(_)&&_>0)return _}}return 2})(t.layout??l.layout??l.columns)}, 1fr)`,gap:"6px",width:"100%"},b=nt(l.optionRadius??l.optionBorderRadius??l.imageRadius??14),m={backgroundColor:l.optionBgColor||s.optionBgColor,color:l.optionTextColor||s.optionTextColor,fontFamily:p,borderRadius:b,border:`2px solid ${l.borderColor||s.borderColor}`,cursor:n?"default":"pointer",display:"flex",flexDirection:"column",alignItems:"center",padding:"6px",boxSizing:"border-box",transition:"all 0.2s ease",overflow:"hidden"},E=v=>{if(!(o||n)){i(v);try{localStorage.setItem(`appstorys_image_quiz_${t.id}`,v)}catch{}e?.({type:"image",quizId:t.id,optionId:v,stickerId:t.id})}},j="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Crect width='100%25' height='100%25' fill='%23EDF2F7'/%3E%3Cpath d='M30 40 L40 30 L50 40 L60 30 L70 40 V60 H30 Z' fill='%23A0AEC0'/%3E%3Ccircle cx='40' cy='45' r='5' fill='%23FFFFFF'/%3E%3C/svg%3E",D=["A","B","C","D","E","F"],L=Array.isArray(t.options)?t.options:[];return L.length===0&&!o&&console.warn("AppStorys: ImageQuizSticker has no options!",t.id),(0,Te.jsxs)("div",{style:{...y,background:l.backgroundColor||s.backgroundColor},children:[t.question&&(0,Te.jsx)("h3",{style:u,children:t.question}),(0,Te.jsx)("div",{style:g,children:L.map((v,w)=>{let _=v.id===n,N=v.isCorrect===!0,U=l.borderColor||s.borderColor,A=l.optionBgColor||s.optionBgColor;n&&(N?(U=l.activeColor||s.activeColor,A="rgba(16, 185, 129, 0.08)"):_&&(U=l.incorrectColor||s.incorrectColor,A="rgba(239, 68, 68, 0.08)"));let T=n?N?l.activeColor||s.activeColor:_?l.incorrectColor||s.incorrectColor:l.labelColor||l.optionTextColor||s.optionTextColor:l.labelColor||l.optionTextColor||s.optionTextColor;return(0,Te.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%",boxSizing:"border-box"},children:[(0,Te.jsxs)("button",{style:{width:"100%",aspectRatio:"1",borderRadius:b,border:`2px solid ${U}`,backgroundColor:A,overflow:"hidden",cursor:n?"default":"pointer",position:"relative",padding:0,margin:0,outline:"none",transition:"transform 0.2s ease, border-color 0.2s ease",boxSizing:"border-box"},onClick:()=>E(v.id),disabled:!!n,onMouseOver:k=>{!o&&!n&&(k.currentTarget.style.transform="scale(1.02)")},onMouseOut:k=>{!o&&!n&&(k.currentTarget.style.transform="scale(1)")},children:[(0,Te.jsx)("img",{src:v.image||j,alt:v.text,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),n&&(0,Te.jsx)("div",{style:{position:"absolute",top:"6px",right:"6px",width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:N?l.activeColor||s.activeColor:_?l.incorrectColor||s.incorrectColor:"#A0AEC0",color:"#FFFFFF",fontSize:"12px",fontWeight:"bold",boxShadow:"0 2px 6px rgba(0,0,0,0.2)"},children:N?"\u2713":_?"\u2715":""})]}),(0,Te.jsx)("span",{style:{marginTop:"6px",fontWeight:"600",fontSize:nt(l.optionFontSize||13),color:T,fontFamily:p,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.text})]},v.id)})})]})};var Nn=require("react");var Ne=require("react");var Q=require("react/jsx-runtime"),or=({product:t,styling:e,onClose:o,onAddToCart:n})=>{let[i,s]=(0,Ne.useState)(""),[l,c]=(0,Ne.useState)(0),[d,S]=(0,Ne.useState)(1),[p,y]=(0,Ne.useState)(!1),[u,C]=(0,Ne.useState)(!1),h=t.attributes||{},g=h.colors||[],b=h.sizes||[],m=h.imageUrls||[t.image],E=h.description||"";(0,Ne.useEffect)(()=>{b.length>0&&s(b[0]),C(!0)},[b]);let j=()=>{let k={productId:t.productId||t.id,title:t.title,selectedSize:i,selectedColor:g[l]?.name,quantity:d,price:t.price};n(k);let B=t.redirectUrl||t.url;if(B){!B.startsWith("http")&&!B.startsWith("//")&&(B="https://"+B);try{window.open(B,"_blank","noopener,noreferrer")}catch($){console.error("AppStorys: Redirect failed",$)}}y(!0)},D=()=>{C(!1),setTimeout(o,400)},L=e?.buttonBackground||"#000000",v=e?.buttonTextColor||"#ffffff",w=e?.titleColor||e?.textColor||"#1a1a2e",_=e?.priceColor||e?.textColor||"#1a1a2e",N=e?.mrpColor||"#8b8b98",U=e?.titleFontWeight||"600",A=e?.priceFontWeight||"700",T=e?.mrpFontWeight||"500";return p?(0,Q.jsxs)("div",{className:"appstorys-shopable-success-overlay",style:Ji,children:[(0,Q.jsx)("div",{className:"appstorys-shopable-backdrop",style:Ki,onClick:D}),(0,Q.jsxs)("div",{className:"appstorys-shopable-sheet",style:{...Zi,height:"auto",minHeight:"310px",animation:"appstorys-slide-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[(0,Q.jsx)("div",{style:tr,onClick:D}),(0,Q.jsxs)("div",{style:{padding:"0 20px 24px",textAlign:"center"},children:[(0,Q.jsxs)("div",{style:{backgroundColor:"#F3F4F6",borderRadius:"20px",padding:"22px",marginTop:"16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[(0,Q.jsxs)("h3",{style:{margin:0,fontSize:"16px",fontWeight:"600",lineHeight:"1.4"},children:["Added to your bag",(0,Q.jsx)("br",{}),"successfully"]}),(0,Q.jsx)("svg",{width:"44",height:"26",viewBox:"0 0 44 26",fill:"none",children:(0,Q.jsx)("path",{d:"M4 4C4 4 11 22 22 22C33 22 40 4 40 4",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round"})})]}),(0,Q.jsxs)("div",{style:{marginTop:"24px",display:"flex",flexDirection:"column",gap:"8px"},children:[(0,Q.jsx)("button",{onClick:D,style:{...$n,backgroundColor:"#000000",color:"#ffffff",padding:"17px",fontSize:"16px",fontWeight:"600"},children:(0,Q.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[(0,Q.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,Q.jsx)("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),(0,Q.jsx)("path",{d:"M3 6h18"}),(0,Q.jsx)("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),"Go to checkout"]})}),(0,Q.jsx)("button",{onClick:D,style:{...$n,backgroundColor:"transparent",color:"#000000",border:"1px solid rgba(0,0,0,0.1)",padding:"15px",fontSize:"16px"},children:"Continue with stories"})]})]})]})]}):(0,Q.jsxs)("div",{className:`appstorys-shopable-overlay ${u?"visible":""}`,style:Ji,children:[(0,Q.jsx)("div",{className:"appstorys-shopable-backdrop",style:Ki,onClick:D}),(0,Q.jsxs)("div",{className:"appstorys-shopable-sheet",style:{...Zi,transform:u?"translateY(0)":"translateY(100%)",opacity:u?1:0},children:[(0,Q.jsxs)("div",{style:Cs,children:[(0,Q.jsx)("div",{style:tr,onClick:D}),(0,Q.jsx)("button",{style:vs,onClick:D,children:(0,Q.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,Q.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,Q.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),(0,Q.jsxs)("div",{style:ws,children:[(0,Q.jsx)("div",{style:ks,children:m.map((k,B)=>(0,Q.jsx)("div",{style:{minWidth:m.length>1?"85%":"100%",aspectRatio:"1.2 / 1",maxHeight:"240px",borderRadius:"16px",overflow:"hidden",backgroundColor:"#F9FAFB"},children:(0,Q.jsx)("img",{src:k,alt:t.title,style:{width:"100%",height:"100%",objectFit:"contain"}})},B))}),(0,Q.jsxs)("div",{style:{padding:"0 20px 20px"},children:[(0,Q.jsx)("h2",{style:{margin:"16px 0 4px",fontSize:e?.titleFontSize?nt(e.titleFontSize):"20px",fontWeight:U,color:w,lineHeight:"1.2"},children:t.title}),(0,Q.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",marginBottom:"16px"},children:[(0,Q.jsx)("span",{style:{fontSize:e?.priceFontSize?nt(e.priceFontSize):"18px",fontWeight:A,color:_},children:t.price}),t.oldPrice&&(0,Q.jsx)("span",{style:{fontSize:e?.mrpFontSize?nt(e.mrpFontSize):"14px",color:N,textDecoration:"line-through",fontWeight:T},children:t.oldPrice})]}),g.length>0&&(0,Q.jsxs)("div",{style:_n,children:[(0,Q.jsx)("div",{style:Wn,children:"COLOR"}),(0,Q.jsx)("div",{style:{display:"flex",gap:"14px",marginTop:"12px"},children:g.map((k,B)=>(0,Q.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"5px"},children:[(0,Q.jsx)("button",{onClick:()=>c(B),style:{width:"36px",height:"36px",borderRadius:"50%",border:"none",backgroundColor:k.hex||"#gray",position:"relative",cursor:"pointer",boxShadow:l===B?"0 0 0 2px #fff, 0 0 0 4px #000":"none",transition:"all 0.2s ease"}}),(0,Q.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:l===B?"#000":"transparent",transition:"all 0.2s ease"}})]},k.id))})]}),b.length>0&&(0,Q.jsxs)("div",{style:_n,children:[(0,Q.jsx)("div",{style:Wn,children:"SIZE"}),(0,Q.jsx)("div",{style:{display:"flex",gap:"10px",marginTop:"12px",flexWrap:"wrap"},children:b.map(k=>(0,Q.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},children:[(0,Q.jsx)("button",{onClick:()=>s(k),style:{minWidth:"42px",height:"42px",borderRadius:"50%",backgroundColor:"transparent",border:`1px solid ${i===k?"#000":"rgba(0,0,0,0.1)"}`,color:i===k?"#000":"#8b8b98",fontSize:"13px",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:k}),(0,Q.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:i===k?"#000":"transparent",transition:"all 0.2s ease"}})]},k))})]}),E&&(0,Q.jsxs)("div",{style:_n,children:[(0,Q.jsx)("div",{style:Wn,children:"DESCRIPTION"}),(0,Q.jsx)("p",{style:{margin:"8px 0 0",fontSize:"14px",lineHeight:"1.5",color:"#8b8b98",wordBreak:"break-word"},children:E})]})]})]}),(0,Q.jsxs)("div",{style:Rs,children:[(0,Q.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1px",minWidth:"75px"},children:[(0,Q.jsx)("div",{style:{fontSize:"15px",fontWeight:A,color:_},children:t.price}),t.oldPrice&&(0,Q.jsx)("div",{style:{fontSize:"11px",color:N,textDecoration:"line-through",fontWeight:T},children:t.oldPrice})]}),(0,Q.jsxs)("div",{style:Fs,children:[(0,Q.jsx)("button",{style:er,onClick:()=>S(k=>Math.max(1,k-1)),children:(0,Q.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,Q.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}),(0,Q.jsx)("span",{style:{fontSize:"16px",fontWeight:"700",minWidth:"18px",textAlign:"center",color:"#000000",display:"inline-block"},children:d}),(0,Q.jsx)("button",{style:er,onClick:()=>S(k=>k+1),children:(0,Q.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,Q.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,Q.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),(()=>{let k=h.availability?.toLowerCase()||"",B=k==="out of stock"||k==="out-of-stock";return(0,Q.jsxs)("button",{onClick:B?void 0:j,disabled:B,style:{...$n,backgroundColor:B?"#F3F4F6":L,color:B?"#9CA3AF":v,flex:"1",padding:"12px 8px",gap:"6px",cursor:B?"not-allowed":"pointer",opacity:B?.8:1},children:[!B&&(0,Q.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,Q.jsx)("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),(0,Q.jsx)("path",{d:"M3 6h18"}),(0,Q.jsx)("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),(0,Q.jsx)("span",{style:{fontSize:"12px",fontWeight:"700",whiteSpace:"nowrap"},children:B?"Out of Stock":"Add to cart"})]})})()]})]}),(0,Q.jsx)("style",{children:`
37
72
  @keyframes appstorys-slide-up {
38
73
  from { transform: translateY(100%); }
39
74
  to { transform: translateY(0); }
@@ -46,10 +81,22 @@
46
81
  .appstorys-shopable-overlay.visible {
47
82
  visibility: visible;
48
83
  }
49
- `})]})},Jn={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"},Xn={position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.45)",cursor:"pointer"},Kn={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"},ar={height:"48px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0},Zn={width:"36px",height:"5px",backgroundColor:"rgba(0,0,0,0.1)",borderRadius:"3px",cursor:"pointer"},lr={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"},dr={flex:1,overflowY:"auto",WebkitOverflowScrolling:"touch"},cr={padding:"0 16px 20px",display:"flex",gap:"8px",overflowX:"auto",scrollSnapType:"x mandatory"},Wo={marginTop:"20px"},Mo={fontSize:"11px",fontWeight:"600",color:"rgba(0,0,0,0.5)",letterSpacing:"1.4px"},pr={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"},ur={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"100px",border:"1px solid rgba(0,0,0,0.1)"},ti={border:"none",backgroundColor:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},Oo={border:"none",borderRadius:"100px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"};var ut=require("react/jsx-runtime"),oi=({data:t,onInteraction:e,isEditing:o})=>{let{products:i,styling:n}=t,[r,s]=(0,jo.useState)(!1),[a,c]=(0,jo.useState)(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(0,ut.jsxs)(ut.Fragment,{children:[(0,ut.jsxs)("div",{style:m,className:"shopable-container",children:[(0,ut.jsx)("style",{children:`
84
+ `})]})},Ji={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"},Ki={position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.45)",cursor:"pointer"},Zi={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"},Cs={height:"48px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0},tr={width:"36px",height:"5px",backgroundColor:"rgba(0,0,0,0.1)",borderRadius:"3px",cursor:"pointer"},vs={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"},ws={flex:1,overflowY:"auto",WebkitOverflowScrolling:"touch"},ks={padding:"0 16px 20px",display:"flex",gap:"8px",overflowX:"auto",scrollSnapType:"x mandatory"},_n={marginTop:"20px"},Wn={fontSize:"11px",fontWeight:"600",color:"rgba(0,0,0,0.5)",letterSpacing:"1.4px"},Rs={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)"},er={border:"none",backgroundColor:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},$n={border:"none",borderRadius:"100px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"};var Vt=require("react/jsx-runtime"),nr=({data:t,onInteraction:e,isEditing:o})=>{let{products:n,styling:i}=t,[s,l]=(0,Nn.useState)(!1),[c,d]=(0,Nn.useState)(null),S=(g,b)=>{if(g.stopPropagation(),o)return;if(t.shopableType==="product"){d(b),l(!0),e&&e({type:"product_view",stickerId:t.id,productId:b.productId||b.id,value:b.title});return}let m=b.redirectUrl||b.url;if(m&&!m.startsWith("http")&&!m.startsWith("//")&&(m="https://"+m),e&&e({type:"buy",stickerId:t.id,productId:b.id,value:b.title,selected_option:m}),m)try{window.open(m,"_blank","noopener,noreferrer")}catch(E){console.error("AppStorys: Redirect failed",E),window.location.href=m}},p=g=>{e&&e({type:"add_to_cart",stickerId:t.id,productId:g.productId,value:g.title,selected_option:JSON.stringify({size:g.selectedSize,color:g.selectedColor,quantity:g.quantity})})},y={width:"100%",height:"100%",display:"flex",gap:"12px",overflowX:"auto",padding:"0 1px",scrollSnapType:"x mandatory",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",pointerEvents:"auto"},u={flex:"0 0 auto",width:"100%",backgroundColor:i?.cardBackground||"#ffffff",borderRadius:i?.cardBorderRadius!==void 0?nt(i.cardBorderRadius):i?.cardRadiusPercent!==void 0?`${i.cardRadiusPercent}%`:"12px",overflow:"hidden",boxShadow:i?.shadow||"0 -2px 12px rgba(0,0,0,0.12)",display:"flex",flexDirection:"row",alignItems:"center",padding:"8px 12px",position:"relative",scrollSnapAlign:"center",transition:"transform 0.2s ease",cursor:"pointer",boxSizing:"border-box",pointerEvents:"auto",opacity:i?.opacity??1,marginBottom:0},C={width:"64px",height:"64px",borderRadius:i?.imageRadius!==void 0?nt(i.imageRadius):"12px",overflow:"hidden",backgroundColor:"#f5f5f5",flexShrink:0},h={flex:1,display:"flex",flexDirection:"column",justifyContent:"center",padding:"0 12px",minWidth:0};return(0,Vt.jsxs)(Vt.Fragment,{children:[(0,Vt.jsxs)("div",{style:y,className:"shopable-container",children:[(0,Vt.jsx)("style",{children:`
50
85
  .shopable-container::-webkit-scrollbar { display: none; }
51
86
  .shopable-card:active { transform: scale(0.98); }
52
- `}),i.map(b=>(0,ut.jsxs)("div",{style:g,className:"shopable-card",onClick:h=>u(h,b),children:[(0,ut.jsx)("div",{style:v,children:(0,ut.jsx)("img",{src:b.image,alt:b.title,style:{width:"100%",height:"100%",objectFit:"cover"}})}),(0,ut.jsxs)("div",{style:f,children:[(0,ut.jsx)("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}),(0,ut.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",flexWrap:"wrap"},children:[(0,ut.jsx)("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&&(0,ut.jsx)("span",{style:{color:n?.mrpColor||"#8b8b98",fontSize:n?.mrpFontSize?`${n.mrpFontSize}px`:"12px",fontWeight:n?.mrpFontWeight||"500",textDecoration:"line-through"},children:b.oldPrice})]})]}),(0,ut.jsx)("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&&(0,ut.jsx)(ei,{product:a,styling:n,onClose:()=>s(!1),onAddToCart:x})]})};var yt=require("react/jsx-runtime"),ni=({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(0,yt.jsx)(Wn,{data:t,onInteraction:e,isEditing:o});case"quiz":return(0,yt.jsx)(On,{data:t,onInteraction:e,isEditing:o});case"rating":return(0,yt.jsx)(Hn,{data:t,onInteraction:e,isEditing:o});case"question":case"input":return(0,yt.jsx)(Yn,{data:t,onInteraction:e,isEditing:o});case"image_quiz":return(0,yt.jsx)(Gn,{data:t,onInteraction:e,isEditing:o});case"countdown":return(0,yt.jsx)(jn,{data:t,onInteraction:e,isEditing:o});case"promo_code":case"promo":return(0,yt.jsx)(qn,{data:t,onInteraction:e,isEditing:o});case"reaction":return(0,yt.jsx)(Un,{data:t,onInteraction:e,isEditing:o});case"buy":case"shopable":return(0,yt.jsx)(oi,{data:t,onInteraction:e,isEditing:o});case"image":return(0,yt.jsx)("img",{src:t.url,alt:"static overlay",style:{width:"100%",height:"100%",objectFit:"fill"}});case"text":{let g=t.styling||{};return(0,yt.jsx)("span",{style:{color:g.color||"#000000",fontSize:`${g.fontSize||14}px`,fontFamily:dt(g.fontFamily)||"Arial",fontStyle:g.fontStyle||"normal",fontWeight:g.fontWeight||"normal",wordBreak:"break-word",display:"inline-block"},children:t.text})}default:return(0,yt.jsxs)("div",{style:{padding:"10px",background:"white",color:"black",borderRadius:"4px"},children:["Unsupported interactive element: ",t.type]})}};return(0,yt.jsx)("div",{style:c,className:`interactive-item-z${t.z??0}`,children:(0,yt.jsx)("div",{style:u,children:x()})})};var Yt=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},Ze=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`};var Ie=require("react/jsx-runtime"),ii=(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"},le=(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)}}):[],ri=t=>Array.isArray(t?.emojis)?t.emojis.map(e=>String(e)):le(t?.options).map(e=>e.text).filter(Boolean),si=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},ai=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()}},No=({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||{},O=ii(d,t),A=d.position||d.postion||{},_=d.size||{},C=d.x!==void 0?d.x:A.x,S=d.y!==void 0?d.y:A.y,W=d.width!==void 0?d.width:_.width,P=C!==void 0&&!isNaN(Number(C))?Number(C)/r*100:10,M=S!==void 0&&!isNaN(Number(S))?Number(S)/s*100:15,$=W!==void 0&&!isNaN(Number(W))?Number(W)/r*100:80,k={id:d.id||Math.random().toString(),type:si(T.interactiveType||d.widgetType||d.type||"unknown"),x:P,y:M,width:$,rotation:p.rotation??d.rotation??0,z:d.z??d.position?.z??p.z??10,duration:l.duration||p.duration,styling:{backgroundColor:Yt(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:Ze(p.animation)}};if(k.type==="poll"){let L=le(l.options);return{...k,type:"poll",question:l.question||l.title||"Poll Question",options:L,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 L=p.colors||{},j=le(l.options,l.isCorrect);return{...k,type:"quiz",question:l.question||l.title||"Quiz Question",options:j,showExplanation:l.showExplanation,url:l.url,styling:{...k.styling,backgroundColor:p.background||p.containerBgColor||p.backgroundColor||"transparent",questionTextColor:p.questionColor||L.questionColor||p.question?.color||p.colors?.questionText||"#FF0000",questionBgColor:p.questionBgColor||L.questionBackground||p.question?.background||p.colors?.questionBg||"#3BFF00",optionBgColor:p.optionBgColor||L.optionBackground||p.options?.background||p.colors?.optionBg||"#C100FF",optionTextColor:p.optionTextColor||L.optionTextColor||p.options?.textColor||p.colors?.optionText||"#ffffff",borderColor:p.borderColor||"transparent",activeColor:p.correctColor||L.correctColor||p.correctBorderColor||"#00D9FF",incorrectColor:p.incorrectColor||L.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:le(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:ai(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 L=ri(l);return{...k,type:"reaction",emojis:L.length>0?L:["\u{1F60D}","\u{1F44D}"],source:O}}return k}),h=(t?.interactions||[]).filter(d=>!v.has(d.id)).map(d=>{let T=d.config||{},l=d.styling||d.style||{},p=ii(d,t),O=si(d.interaction_type||d.type),A=l.position||d.position||{},_=l.size||d.size||{},C=A.x??d.x,S=A.y??d.y,W=_.width??d.width,P=_.height??d.height,M=C!==void 0&&!isNaN(Number(C))?Number(C)/r*100:10,$=S!==void 0&&!isNaN(Number(S))?Number(S)/s*100:15,k=W!==void 0&&!isNaN(Number(W))?Number(W)/r*100:80,L=P!==void 0&&!isNaN(Number(P))?Number(P)/s*100:void 0,j={id:d.id||Math.random().toString(),type:O,x:M,y:$,width:k,height:L,rotation:l.rotation??d.rotation??0,z:d.z??d.position?.z??l.z??10,source:p,duration:T.duration||l.duration,styling:{backgroundColor:Yt(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:Ze(l.animation)}};if(j.type==="rating"||j.type==="rate"){let X=l.colors||{};return{...j,type:"rating",title:T.title||"Do you like my space?",emoji:T.emoji||"\u{1F60D}",currentRating:T.currentRating,maxRating:T.maxRating,styling:{...j.styling,sliderTrackColor:X.sliderTrack||l.colors?.sliderTrack||l.colors?.sliderTrack,sliderFillColor:X.sliderFill||l.colors?.sliderFill||l.sliderFill,emojiSize:l.emojiSize?l.emojiSize*.45:void 0,titleColor:X.titleColor||l.colors?.titleColor||l.titleColor,titleFontSize:l.titleFontSize?l.titleFontSize*.4:void 0}}}if(j.type==="poll"){let X=le(T.options);return{...j,type:"poll",question:T.question||T.title||"Poll Question",options:X,layout:T.layout||{type:"vertical",columns:1},styling:{...j.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(j.type==="quiz"){let X=l.colors||{},ft=le(T.options,T.isCorrect);return{...j,type:"quiz",question:T.question||T.title||"Quiz Question",options:ft,showExplanation:T.showExplanation,url:T.url,styling:{...j.styling,backgroundColor:l.background||l.containerBgColor||l.backgroundColor||"transparent",questionTextColor:l.questionColor||X.questionColor||l.question?.color||l.colors?.questionText||"#FF0000",questionBgColor:l.questionBgColor||X.questionBackground||l.question?.background||l.colors?.questionBg||"#3BFF00",optionBgColor:l.optionBgColor||X.optionBackground||l.options?.background||l.colors?.optionBg||"#C100FF",optionTextColor:l.optionTextColor||X.optionTextColor||l.options?.textColor||l.colors?.optionText||"#ffffff",borderColor:l.borderColor||"transparent",activeColor:l.correctColor||X.correctColor||l.correctBorderColor||"#00D9FF",incorrectColor:l.incorrectColor||X.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(j.type==="question")return{...j,type:"question",question:T.question||T.title||"Ask me a question",placeholder:T.placeholder||"Type your answer...",styling:{...j.styling,promptColor:l.questionColor||l.promptColor||l.textColor,inputBgColor:l.inputBackground||l.inputBgColor,inputTextColor:l.inputTextColor,submitBackground:l.submitBackground}};if(j.type==="image_quiz"||j.type==="imageQuiz"||O==="media_quiz")return{...j,type:"image_quiz",question:T.question||T.title||"Image Quiz",options:le(T.options||[]),styling:{...j.styling,questionTextColor:l.questionColor,activeColor:l.correctColor||l.correctBorderColor,incorrectColor:l.incorrectColor,imageRadius:l.imageRadius?l.imageRadius*a:void 0}};if(j.type==="countdown")return{...j,type:"countdown",title:T.title||"Ends in...",targetDate:ai(T),styling:{...j.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(j.type==="promo_code")return{...j,type:"promo_code",code:T.code||"CODE20",styling:{...j.styling,borderColor:l.borderColor}};if(j.type==="reaction"||j.type==="emoji_reaction"){let X=ri(T);return{...j,type:"reaction",emojis:X.length>0?X:["\u{1F60D}","\u{1F44D}"]}}return j}),y=g.map(d=>{let T=f.find(N=>String(N?.id)===String(d?.id))||f.find(N=>N?.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(([,N])=>N!==void 0))},O=p.position||{},A=p.size||{},_=p.cardBorderRadius!==void 0?Number(p.cardBorderRadius):void 0,C=p.cardRadiusPercent!==void 0?Number(p.cardRadiusPercent):void 0,S=A.height!==void 0?Number(A.height):void 0,W=_===void 0&&C!==void 0&&S!==void 0?Math.max(0,Math.min(100,C))/100*(S/2):void 0,P=_??W,M=P!==void 0&&!isNaN(P)?P*a:void 0,$=O.x!==void 0?Number(O.x)/r*100:0,k=A.width!==void 0?Number(A.width)/r*100:100,L=A.height!==void 0?Number(A.height)/s*100:void 0,j=O.y!==void 0?Number(O.y)/s*100:L?100-L-2.5:85;L&&j+L>96?j=Math.max(0,100-L):j>75&&L&&j+L>91&&(j=Math.max(0,100-L-1));let X=Array.isArray(d.product)&&d.product.length>0,ft=X?d.product:d.static||[];return{id:d.id||Math.random().toString(),type:"buy",shopableType:X?"product":"static",x:$,y:j,width:k,height:L,rotation:p.rotation??0,z:p.z??10,products:ft.map(N=>{let tt=N.productData||N||{},K=tt.attributes||N.attributes||{},Y=K.sales_price||tt.price||K.price||N.price,nt=K.sales_price?tt.price||K.price||N.price:tt.oldPrice||N.oldPrice,U=tt.color||K.color||N.color,G=tt.size||K.size||N.size,Q=K.colors||[];Q.length===0&&U&&(Q=[{id:U,hex:U,name:U}]);let at=K.sizes||[];at.length===0&&G&&(at=typeof G=="string"?G.split(",").map(rt=>rt.trim()):[G]);let St={description:tt.description||K.description||N.description,color:U,size:G,colors:Q,sizes:at,imageUrls:K.imageUrls||[K.image_link||tt.imageUrl||tt.image||N.imageUrl||N.image||N.url].filter(Boolean),availability:tt.availability||K.availability||N.availability,tags:tt.tags||K.tags||N.tags,...K};return{id:tt.productId||tt.id||N.productId||N.id||Math.random().toString(),image:K.image_link||tt.imageUrl||tt.image||N.imageUrl||N.image||N.url,url:tt.link||tt.url||N.link||N.url||N.redirectUrl,title:tt.title||N.title,price:Y,oldPrice:nt,redirectUrl:N.redirectUrl||tt.link||N.link||N.url,svg:tt.svg||N.svg,productId:tt.productId||N.productId,collectionId:tt.collectionId||N.collectionId,feedId:tt.feedId||N.feedId,attributes:St}}),styling:{backgroundColor:Yt(p.background),cardBackground:Yt(p.cardBackground)||Yt(p.background)||"#ffffff",cardBorderRadius:M!==void 0?M: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:Ze(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:dt(l.fontFamily),fontStyle:l.fontStyle,fontWeight:l.fontWeight}}}),B=[...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(0,Ie.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10,pointerEvents:"none",overflow:"hidden"},children:[(0,Ie.jsx)("style",{children:`
87
+ `}),n.map(g=>(0,Vt.jsxs)("div",{style:u,className:"shopable-card",onClick:b=>S(b,g),children:[(0,Vt.jsx)("div",{style:C,children:(0,Vt.jsx)("img",{src:g.image,alt:g.title,style:{width:"100%",height:"100%",objectFit:"cover"}})}),(0,Vt.jsxs)("div",{style:h,children:[(0,Vt.jsx)("span",{style:{color:i?.titleColor||i?.textColor||"#1a1b2e",fontSize:i?.titleFontSize?nt(i.titleFontSize):"15px",fontWeight:i?.titleFontWeight||"700",lineHeight:"1.2",display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"1px"},children:g.title}),(0,Vt.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",flexWrap:"wrap"},children:[(0,Vt.jsx)("span",{style:{color:i?.priceColor||i?.textColor||"#1a1b2e",fontSize:i?.priceFontSize?nt(i.priceFontSize):"18px",fontWeight:i?.priceFontWeight||"800",display:"block"},children:g.price}),g.oldPrice&&(0,Vt.jsx)("span",{style:{color:i?.mrpColor||"#8b8b98",fontSize:i?.mrpFontSize?nt(i.mrpFontSize):"12px",fontWeight:i?.mrpFontWeight||"500",textDecoration:"line-through"},children:g.oldPrice})]})]}),(0,Vt.jsx)("div",{style:{backgroundColor:i?.buttonBackground||"#000000",color:i?.buttonTextColor||"#ffffff",fontSize:i?.buttonFontSize?nt(i.buttonFontSize):"14px",fontWeight:"700",padding:"10px 18px",borderRadius:i?.buttonBorderRadius!==void 0?nt(i.buttonBorderRadius):"100px",textAlign:"center",flexShrink:0,whiteSpace:"nowrap"},children:"Buy Now"})]},g.id))]}),s&&c&&(0,Vt.jsx)(or,{product:c,styling:i,onClose:()=>l(!1),onAddToCart:p})]})};var vt=require("react/jsx-runtime"),ir=po.default?.default??po.default??po.Lottie??po,Ts=({url:t,animationData:e,loop:o=!0,autoplay:n=!0,styling:i={}})=>{let[s,l]=(0,Eo.useState)(e||null),[c,d]=(0,Eo.useState)(!1);(0,Eo.useEffect)(()=>{if(e){l(e);return}t&&(d(!1),fetch(t).then(y=>{if(!y.ok)throw new Error(`Failed to fetch Lottie JSON (${y.status})`);return y.json()}).then(y=>{l(y),d(!1)}).catch(y=>{console.error("AppStorys: Error loading Lottie sticker from URL:",t,y),d(!0)}))},[t,e]);let S={width:"100%",height:"100%",display:"block",borderRadius:nt(i.borderRadius||"0px"),border:i.border||"none",boxShadow:i.boxShadow||"none",opacity:i.opacity??1,transform:i.transform||void 0,overflow:"hidden"};if(!s)return(0,vt.jsx)("div",{style:S});let p=ir.default||ir;return(0,vt.jsx)(p,{animationData:s,loop:o,autoplay:n,style:S,rendererSettings:{preserveAspectRatio:"xMidYMid meet"}})},rr=({data:t,onInteraction:e,isEditing:o=!1})=>{let n={x:10,y:15,width:80,rotation:0},i=t.x??n.x,s=t.y??n.y,l=t.width??n.width,c=t.rotation??n.rotation,d={position:"absolute",top:`${s}%`,left:`${i}%`,width:`${l}%`,height:t.height?`${t.height}%`:"auto",transform:`rotate(${c}deg)`,zIndex:10,transformOrigin:"center center",boxSizing:"border-box",cursor:o?"move":"default",pointerEvents:"auto"},S={width:"100%",height:"100%",animation:t.styling?.animation,animationFillMode:"forwards"},p=()=>{switch(t.type){case"poll":return(0,vt.jsx)(Ni,{data:t,onInteraction:e,isEditing:o});case"quiz":return(0,vt.jsx)(ji,{data:t,onInteraction:e,isEditing:o});case"rating":return(0,vt.jsx)(Yi,{data:t,onInteraction:e,isEditing:o});case"question":case"input":return(0,vt.jsx)(Gi,{data:t,onInteraction:e,isEditing:o});case"image_quiz":return(0,vt.jsx)(Xi,{data:t,onInteraction:e,isEditing:o});case"countdown":return(0,vt.jsx)(qi,{data:t,onInteraction:e,isEditing:o});case"promo_code":case"promo":return(0,vt.jsx)(Vi,{data:t,onInteraction:e,isEditing:o});case"reaction":return(0,vt.jsx)(Ui,{data:t,onInteraction:e,isEditing:o});case"lottie":return(0,vt.jsx)(Ts,{url:t.url,loop:t.loop,autoplay:t.autoplay,styling:t.styling});case"buy":case"shopable":return(0,vt.jsx)(nr,{data:t,onInteraction:e,isEditing:o});case"video":{let u=t.styling||{};return(0,vt.jsx)("video",{src:t.url,autoPlay:!0,loop:t.loop!==!1,muted:t.muted!==!1,playsInline:!0,style:{width:"100%",height:"100%",objectFit:u.objectFit||"cover",objectPosition:u.objectPosition||"center center",borderRadius:nt(u.borderRadius||"0px"),border:u.border||"none",boxShadow:u.boxShadow||"none",opacity:u.opacity??1,display:"block",overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"}})}case"shape":case"gif":case"svg":case"sticker":case"image":{let u=t.styling||{};return(0,vt.jsx)("img",{src:t.url,alt:"static overlay",style:{width:"100%",height:"100%",objectFit:u.objectFit||"cover",objectPosition:u.objectPosition||"center center",borderRadius:u.borderRadius||"0px",border:u.border||"none",boxShadow:u.boxShadow||"none",opacity:u.opacity??1,display:"block",overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"}})}case"text":{let u=t.styling||{},C=u.verticalAlignment,h=u.textAlign,g=u.lineHeight,b="1.25";if(g!=null&&g!==""){let m=Number(g);isNaN(m)?b=String(g):b=m<=5?String(m):"1.25"}return(0,vt.jsx)("div",{style:{color:u.color||"#000000",fontSize:nt(u.fontSize||14),fontFamily:lt(u.fontFamily)||"Arial",fontStyle:u.fontStyle||"normal",fontWeight:u.fontWeight||"normal",textDecoration:u.textDecoration||"none",lineHeight:b,letterSpacing:u.letterSpacing||"normal",opacity:u.opacity??1,wordBreak:"break-word",whiteSpace:"pre-wrap",width:"100%",height:"100%",display:"flex",alignItems:C==="middle"||C==="center"?"center":C==="bottom"?"flex-end":"flex-start",justifyContent:h==="center"?"center":h==="right"?"flex-end":"flex-start",textAlign:h||"left"},children:t.text})}case"cta":{let u=t.styling||{};if(t.ctaType==="image")return(0,vt.jsx)("button",{onClick:v=>{v.stopPropagation(),e&&e({type:"cta",stickerId:t.id,redirectUrl:t.redirectUrl})},style:{background:"none",border:u.borderWidth&&u.borderWidth!=="0px"&&u.borderWidth!=="0cqh"?`${nt(u.borderWidth)} solid ${u.borderColor||"#FFFFFF"}`:"none",padding:0,width:"100%",height:"100%",cursor:"pointer",display:"block",outline:"none",borderRadius:u.borderRadius||"0px",overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"},children:(0,vt.jsx)("img",{src:t.url,alt:t.text,style:{width:"100%",height:"100%",objectFit:u.objectFit||"cover",objectPosition:u.objectPosition||"center center",display:"block",borderRadius:u.borderRadius||"0px"}})});let h=u.borderRadius,g=(t.text||"").trim(),b=g.toLowerCase().includes("swipe")||String(t.ctaType).toLowerCase().includes("swipe")||String(t.type).toLowerCase().includes("swipe")||String(t.id).toLowerCase().includes("swipe"),m={width:"100%",height:u.pillH?`${u.pillH}cqh`:"100%",backgroundColor:u.transparent?"transparent":u.backgroundColor||"#3B82F6",color:u.textColor||"#FFFFFF",border:u.borderWidth&&u.borderWidth!=="0px"&&u.borderWidth!=="0cqh"?`${nt(u.borderWidth)} solid ${u.borderColor||"#FFFFFF"}`:"none",borderRadius:h||"4px",fontSize:nt(u.fontSize||14),fontFamily:lt(u.fontFamily)||"Arial",fontStyle:u.fontStyle||"normal",fontWeight:u.fontWeight||"normal",textDecoration:u.textDecoration||"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",outline:"none",padding:"0 12px",wordBreak:"break-word",flexShrink:0},E={position:"relative",width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-end",boxSizing:"border-box",animation:b&&u.arrowAnimation!==!1?"appstorys-swipe-bounce 2.2s ease-in-out infinite":"none",transformOrigin:"bottom center"},j={display:"flex",alignItems:"center",justifyContent:"center",flexGrow:1,width:"100%",color:u.arrowColor||u.textColor||"#FFFFFF",pointerEvents:"none",boxSizing:"border-box"},D=u.arrowSize?`${u.arrowSize}cqh`:"1.5cqh";return(0,vt.jsxs)("div",{style:E,children:[b&&(0,vt.jsxs)(vt.Fragment,{children:[(0,vt.jsx)("style",{children:`
88
+ @keyframes appstorys-swipe-bounce {
89
+ 0%, 100% {
90
+ transform: translateY(0) scaleY(1) scaleX(1);
91
+ }
92
+ 40% {
93
+ transform: translateY(-3px) scaleY(1.04) scaleX(0.98);
94
+ }
95
+ 75% {
96
+ transform: translateY(1px) scaleY(0.97) scaleX(1.02);
97
+ }
98
+ }
99
+ `}),(0,vt.jsx)("div",{style:j,children:(0,vt.jsx)("svg",{style:{height:D,width:"auto"},viewBox:"0 0 28 18",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round",children:(0,vt.jsx)("polyline",{points:"4 14 14 4 24 14"})})})]}),(0,vt.jsx)("button",{onClick:v=>{v.stopPropagation(),e&&e({type:"cta",stickerId:t.id,redirectUrl:t.redirectUrl})},style:m,children:g||t.text})]})}default:return(0,vt.jsxs)("div",{style:{padding:"10px",background:"white",color:"black",borderRadius:"4px"},children:["Unsupported interactive element: ",t.type]})}};return(0,vt.jsx)("div",{style:d,className:`interactive-item-z${t.z??0}`,children:(0,vt.jsx)("div",{style:S,children:p()})})};var Ao=require("react/jsx-runtime"),en=(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"},sr=t=>{if(!t)return!1;let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")},go=(...t)=>{for(let e of t)if(e){if(typeof e=="object"){let o=e.fontFamily||e.font_family||e.font?.fontFamily||e.font?.font_family;if(typeof o=="string"&&o.trim()){let n=o.trim();if(sr(n)||n.length<50&&!/[?!.,;:\n]/.test(n))return n}}if(typeof e=="string"){let o=e.trim();if(!o)continue;if(sr(o)||o.length<35&&!/[?!.,;:\n]/.test(o)&&o.split(/\s+/).length<=3)return o}}},to=(t,e)=>Array.isArray(t)?t.map((o,n)=>{let i=o?.id||o?.key||o?.value||`option_${n+1}`,s=o?.label||o?.optionLabel,l=typeof o=="string"?o:o?.text||o?.title||s||"";return{id:String(i),text:l,image:o?.image||o?.imageUrl||"",label:s,isCorrect:o?.isCorrect===!0||String(i)===String(e)}}):t&&typeof t=="object"?Object.entries(t).map(([o,n])=>{let i=typeof n=="string"?{text:n}:n||{};return{id:o,text:i.text||i.title||i.label||"",image:i.image||i.imageUrl||"",label:i.label,isCorrect:o===String(e)}}):[],ar=t=>Array.isArray(t?.emojis)?t.emojis.map(e=>String(e)):to(t?.options).map(e=>e.text).filter(Boolean),lr=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},dr=(t,e,o)=>{let n=e?.couponCode||e?.code||e?.coupon_code||e?.promoCode||e?.promocode||e?.coupon||e?.value||t?.couponCode||t?.code||t?.coupon_code||o?.couponCode||o?.code||o?.data?.couponCode||o?.data?.code;return typeof n=="string"&&n.trim()!==""?n.trim():"OFFER20"},cr=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()}},On=({content:t={},onInteraction:e,isEditing:o=!1,elapsedTime:n=0})=>{let i=t?.canva||t?.styling?.canva||t?.meta?.canva||{height:1920,width:1080},s=Number(i?.width)||1080,l=Number(i?.height)||1920,c=.352,d=t?.elements||[],S=t?.image||[],p=t?.video||t?.styling?.video||[],y=Array.isArray(p)?p:typeof p=="object"&&p!==null?[p]:[],u=t?.lottie||t?.styling?.lottie||t?.styling?.lotties||t?.meta?.lottie||[],C=Array.isArray(u)?u:typeof u=="object"&&u!==null?[u]:[],h=t?.text||[],g=t?.ctas||[],b=t?.interactions||[],m=Array.isArray(t?.shopable)&&t.shopable.length>0?t.shopable:Array.isArray(t?.styling?.shopable)?t.styling.shopable:[],E=new Set(m.map(r=>r.id)),j=(t?.styling?.shopable||[]).concat(m.map(r=>r.styling).filter(Boolean)),L=en(null,t)==="studio",v=(r,M=L)=>{if(r==null||r==="")return;if(typeof r=="string"&&(r.endsWith("cqh")||r.endsWith("px")||r.endsWith("%")||r.endsWith("em")||r.endsWith("rem")))return r;let a=Number(r);return isNaN(a)?String(r):a>=1e3?"999px":M||a<=100?`${a}cqh`:`${a/l*100}cqh`},w=(r,M=L)=>{if(r==null||r==="")return;if(typeof r=="string"&&(r.endsWith("cqh")||r.endsWith("px")||r.endsWith("%")||r.endsWith("em")||r.endsWith("rem")))return r;let a=Number(r);if(isNaN(a))return String(r);let f;return a<10?f=a:f=a/l*100,f<1.4?`clamp(11px, ${(f*1.25).toFixed(3)}cqh, 22px)`:f<2.5?`clamp(14px, ${(f*1.15).toFixed(3)}cqh, 32px)`:`clamp(16px, ${(f*1.05).toFixed(3)}cqh, 48px)`};if(d.length===0&&S.length===0&&y.length===0&&C.length===0&&h.length===0&&b.length===0&&m.length===0&&g.length===0)return null;let _=d.filter(r=>!E.has(r.id)).map(r=>{let M=r.custom||{},a=M.data||{},f=M.style||r.styling||{},x=en(r,t),z=x==="studio",Y=r.position||r.postion||{},ot=r.size||{},J=r.x!==void 0?r.x:Y.x,H=r.y!==void 0?r.y:Y.y,K=r.width!==void 0?r.width:ot.width,it=r.height!==void 0?r.height:ot.height,xt=J!==void 0&&!isNaN(Number(J))?z?Number(J):Number(J)/s*100:10,ut=H!==void 0&&!isNaN(Number(H))?z?Number(H):Number(H)/l*100:15,Z=K!==void 0&&!isNaN(Number(K))?z?Number(K):Number(K)/s*100:80,rt=it!==void 0&&!isNaN(Number(it))?z?Number(it):Number(it)/l*100:void 0,dt=go(a.question,a.prompt,a.title,f.question,r.question,f.prompt,r.font,f.font,a.font,a.fontFamily,r.fontFamily,f.fontFamily),ht=go(a.options,f.options,r.options,a.font,f.font,r.font,a.fontFamily,r.fontFamily,f.fontFamily),mt=go(a.font,f.font,r.font,a.fontFamily,r.fontFamily,f.fontFamily),R={id:r.id||Math.random().toString(),type:lr(M.interactiveType||r.widgetType||r.type||"unknown"),x:xt,y:ut,width:Z,height:rt,url:r.url||a.url||r.link||a.link,rotation:f.rotation??r.rotation??0,z:r.z??r.position?.z??f.z??10,duration:a.duration||f.duration,styling:{backgroundColor:Ct(f.background||f.containerBgColor||f.backgroundColor),borderRadius:f.borderRadius!==void 0?f.borderRadius>=100?"999px":v(f.borderRadius,z):f.radius!==void 0?f.radius>=100?"999px":v(f.radius,z):"0px",padding:v(f.containerPadding!==void 0?f.containerPadding:f.padding!==void 0?f.padding:0,z),shadow:f.shadow,fontSize:w(f.questionFontSize??f.questionFont?.fontSize??f.questionSize??f.fontSize,z),opacity:f.opacity??1,animation:Bo(f.animation),fontFamily:mt,questionFontFamily:dt||mt,optionFontFamily:ht||mt}};if(R.type==="poll"){let I=to(a.options);return{...R,type:"poll",question:a.question||a.title||"Poll Question",options:I,layout:a.layout||{type:"vertical",columns:1},styling:{...R.styling,headerColor:Ct(f.headerBgColor||f.background),headerTextColor:et(f.questionColor||f.questionTextColor||f.question?.color),optionBgColor:Ct(f.optionBgColor||f.options?.background)||"#1A1A1A",optionTextColor:et(f.optionTextColor||f.options?.textColor)||"#ffffff",optionBorderRadius:f.optionBorderRadius!==void 0?v(f.optionBorderRadius,z):f.options?.radius!==void 0?v(f.options?.radius,z):"0px"}}}if(R.type==="quiz"){let I=f.colors||{},O=to(a.options,a.isCorrect),tt=f.optionFontSize??f.optionFont?.fontSize??f.typography?.optionSize??f.options?.fontSize??16;return{...R,type:"quiz",question:a.question||a.title||"Quiz Question",options:O,showExplanation:a.showExplanation??r.showExplanation??f.showExplanation??M.showExplanation??!0,explanation:a.explanation||r.explanation||f.explanation||M.explanation,url:a.url,styling:{...R.styling,backgroundColor:Ct(f.background||f.containerBgColor||f.backgroundColor)||"transparent",questionTextColor:et(f.questionColor||I.questionColor||f.question?.color||f.colors?.questionText)||"#FFFFFF",questionBgColor:Ct(f.questionBgColor||I.questionBackground||f.question?.background||f.colors?.questionBg)||"#000000",optionBgColor:Ct(f.optionBgColor||I.optionBackground||f.options?.background||f.colors?.optionBg)||"#FFFFFF",optionTextColor:et(f.optionTextColor||I.optionTextColor||f.options?.textColor||f.colors?.optionText)||"#2B2B2B",borderColor:et(f.borderColor)||"transparent",activeColor:et(f.correctColor||I.correctColor||f.correctBorderColor)||"#10b981",incorrectColor:et(f.incorrectColor||I.incorrectColor)||"#ef4444",optionBorderRadius:f.optionRadius!==void 0?f.optionRadius>=100?"999px":v(f.optionRadius,z):f.optionBorderRadius!==void 0?f.optionBorderRadius>=100?"999px":v(f.optionBorderRadius,z):"100px",optionFontSize:w(tt,z)}}}if(R.type==="rating")return{...R,type:"rating",title:a.title||"Do you like my space?",emoji:a.emoji||"\u{1F60D}",currentRating:a.currentRating,maxRating:a.maxRating,styling:{...R.styling,sliderTrackColor:et(f.colors?.sliderTrack||f.sliderTrack),sliderFillColor:et(f.colors?.sliderFill||f.sliderFill),emojiSize:f.emojiSize?z?`${Math.min(Number(f.emojiSize),32)}px`:`${Math.min(f.emojiSize*.45,32)}px`:void 0,titleColor:et(f.colors?.titleColor||f.titleColor),titleFontSize:f.titleFontSize?z?`${Math.min(Number(f.titleFontSize),16)}px`:`${Math.min(f.titleFontSize*.4,16)}px`:void 0}};if(R.type==="question"){let I=f.optionRadius??f.optionBorderRadius??f.inputRadius??f.inputBorderRadius,O=f.borderRadius??f.radius??f.containerBorderRadius;return{...R,type:"question",question:a.question||a.title||"Ask me a question",placeholder:a.placeholder||"Type your answer...",styling:{...R.styling,borderRadius:O!==void 0?O>=100?"999px":v(O,z):"16px",promptColor:et(f.questionColor||f.promptColor||f.textColor),inputBgColor:Ct(f.inputBackground||f.inputBgColor),inputTextColor:et(f.inputTextColor),submitBackground:Ct(f.submitBackground),optionRadius:I!==void 0?I>=5?"9999px":v(I,z):"9999px",inputBorderRadius:I!==void 0?I>=5?"9999px":v(I,z):"9999px"}}}if(R.type==="image_quiz"||R.type==="imageQuiz"||(M.interactiveType||"").toLowerCase()==="media_quiz"){let I=f.optionFontSize??f.optionFont?.fontSize??f.typography?.optionSize??f.options?.fontSize??13,O=f.borderRadius??f.radius??f.containerBorderRadius,tt=f.optionRadius??f.optionBorderRadius??f.imageRadius;return{...R,type:"image_quiz",question:a.question||a.title||"Image Quiz",options:to(a.options||[]),layout:a.layout??f.layout??r.layout,styling:{...R.styling,borderRadius:O!==void 0?O>=100?"999px":v(O,z):void 0,optionRadius:tt!==void 0?tt>=100?"999px":v(tt,z):void 0,questionBgColor:Ct(f.questionBgColor||f.questionBackground),questionTextColor:et(f.questionColor||f.questionTextColor),optionBgColor:Ct(f.optionBgColor||f.optionBackground),optionTextColor:et(f.optionTextColor||f.textColor),labelColor:et(f.labelColor),borderColor:et(f.borderColor),activeColor:et(f.correctBorderColor||f.correctColor||f.activeColor),incorrectColor:et(f.incorrectColor),imageRadius:tt!==void 0?v(tt,z):void 0,optionFontSize:w(I,z)}}}if(R.type==="countdown")return{...R,type:"countdown",title:a.title||"Ends in...",targetDate:cr(a),styling:{...R.styling,borderColor:et(f.borderColor),digitBackground:Ct(f.digitBackground),digitColor:et(f.digitColor),digitSize:f.digitSize||f.fontSize?w(f.digitSize||f.fontSize,z):void 0,labelColor:et(f.labelColor),titleColor:et(f.titleColor)},display:a.display};if(R.type==="promo_code")return{...R,width:R.width?Math.max(R.width,65):75,type:"promo_code",code:dr(r,a,M),styling:{...R.styling,borderColor:et(f.borderColor)}};if(R.type==="reaction"||R.type==="emoji_reaction"){let I=ar(a);return{...R,type:"reaction",emojis:I.length>0?I:["\u{1F60D}","\u{1F44D}"],source:x}}return R}),N=(t?.interactions||[]).filter(r=>!E.has(r.id)).map(r=>{let M=r.config||{},a=r.styling||r.style||{},f=en(r,t),x=f==="studio",z=lr(r.interaction_type||r.type),Y=a.position||r.position||{},ot=a.size||r.size||{},J=Y.x??r.x,H=Y.y??r.y,K=ot.width??r.width,it=ot.height??r.height,xt=J!==void 0&&!isNaN(Number(J))?x?Number(J):Number(J)/s*100:10,ut=H!==void 0&&!isNaN(Number(H))?x?Number(H):Number(H)/l*100:15,Z=K!==void 0&&!isNaN(Number(K))?x?Number(K):Number(K)/s*100:80,rt=it!==void 0&&!isNaN(Number(it))?x?Number(it):Number(it)/l*100:void 0,dt=go(a.question,r.question,a.prompt,M.question,M.prompt,M.title,a.font,r.font,M.font,a.fontFamily,M.fontFamily,r.fontFamily),ht=go(a.options,r.options,M.options,a.font,r.font,M.font,a.fontFamily,M.fontFamily,r.fontFamily),mt=go(a.font,r.font,M.font,a.fontFamily,M.fontFamily,r.fontFamily),R={id:r.id||Math.random().toString(),type:z,x:xt,y:ut,width:Z,height:rt,rotation:a.rotation??r.rotation??0,z:r.z??r.position?.z??a.z??10,source:f,duration:M.duration||a.duration,styling:{backgroundColor:Ct(a.background||a.containerBgColor||a.backgroundColor),borderRadius:a.borderRadius!==void 0?a.borderRadius>=100?"999px":v(a.borderRadius,x):a.radius!==void 0?a.radius>=100?"999px":v(a.radius,x):"0px",padding:v(a.containerPadding!==void 0?a.containerPadding:a.padding!==void 0?a.padding:0,x),shadow:a.shadow,fontSize:w(a.questionFontSize??a.questionFont?.fontSize??a.questionSize??a.fontSize,x),opacity:a.opacity??1,animation:Bo(a.animation),fontFamily:mt,questionFontFamily:dt||mt,optionFontFamily:ht||mt}};if(R.type==="rating"||R.type==="rate"){let I=a.colors||{};return{...R,type:"rating",title:M.title||"Do you like my space?",emoji:M.emoji||"\u{1F60D}",currentRating:M.currentRating,maxRating:M.maxRating,styling:{...R.styling,sliderTrackColor:et(I.sliderTrack||a.colors?.sliderTrack||a.colors?.sliderTrack),sliderFillColor:et(I.sliderFill||a.colors?.sliderFill||a.colors?.sliderFill),emojiSize:a.emojiSize?x?`${Math.min(Number(a.emojiSize),32)}px`:`${Math.min(a.emojiSize*.45,32)}px`:void 0,titleColor:et(I.titleColor||a.colors?.titleColor||a.titleColor),titleFontSize:a.titleFontSize?x?`${Math.min(Number(a.titleFontSize),16)}px`:`${Math.min(a.titleFontSize*.4,16)}px`:void 0}}}if(R.type==="poll"){let I=to(M.options);return{...R,type:"poll",question:M.question||M.title||"Poll Question",options:I,layout:M.layout||{type:"vertical",columns:1},styling:{...R.styling,headerColor:Ct(a.headerBgColor||a.background),headerTextColor:et(a.questionColor||a.questionTextColor||a.question?.color),optionBgColor:Ct(a.optionBgColor||a.options?.background)||"#1A1A1A",optionTextColor:et(a.optionTextColor||a.options?.textColor)||"#ffffff",optionBorderRadius:a.optionBorderRadius!==void 0?v(a.optionBorderRadius,x):a.options?.radius!==void 0?v(a.options?.radius,x):"0px"}}}if(R.type==="quiz"){let I=a.colors||{},O=to(M.options,M.isCorrect),tt=a.optionFontSize??a.optionFont?.fontSize??a.typography?.optionSize??a.options?.fontSize??16;return{...R,type:"quiz",question:M.question||M.title||"Quiz Question",options:O,showExplanation:M.showExplanation??r.showExplanation??a.showExplanation??!0,explanation:M.explanation||r.explanation||a.explanation,url:M.url,styling:{...R.styling,backgroundColor:Ct(a.background||a.containerBgColor||a.backgroundColor)||"transparent",questionTextColor:et(a.questionColor||I.questionColor||a.question?.color||a.colors?.questionText)||"#FFFFFF",questionBgColor:Ct(a.questionBgColor||I.questionBackground||a.question?.background||a.colors?.questionBg)||"#000000",optionBgColor:Ct(a.optionBgColor||I.optionBackground||a.options?.background||a.colors?.optionBg)||"#FFFFFF",optionTextColor:et(a.optionTextColor||I.optionTextColor||a.options?.textColor||a.colors?.optionText)||"#2B2B2B",borderColor:et(a.borderColor)||"transparent",activeColor:et(a.correctColor||I.correctColor||a.correctBorderColor)||"#10b981",incorrectColor:et(a.incorrectColor||I.incorrectColor)||"#ef4444",optionBorderRadius:a.optionRadius!==void 0?a.optionRadius>=100?"999px":v(a.optionRadius,x):a.optionBorderRadius!==void 0?a.optionBorderRadius>=100?"999px":v(a.optionBorderRadius,x):"100px",optionFontSize:w(tt,x)}}}if(R.type==="question"){let I=a.optionRadius??a.optionBorderRadius??a.inputRadius??a.inputBorderRadius,O=a.borderRadius??a.radius??a.containerBorderRadius;return{...R,type:"question",question:M.question||M.title||"Ask me a question",placeholder:M.placeholder||"Type your answer...",styling:{...R.styling,borderRadius:O!==void 0?O>=100?"999px":v(O,x):"16px",promptColor:et(a.questionColor||a.promptColor||a.textColor),inputBgColor:Ct(a.inputBackground||a.inputBgColor),inputTextColor:et(a.inputTextColor),submitBackground:Ct(a.submitBackground),optionRadius:I!==void 0?I>=5?"9999px":v(I,x):"9999px",inputBorderRadius:I!==void 0?I>=5?"9999px":v(I,x):"9999px"}}}if(R.type==="image_quiz"||R.type==="imageQuiz"||z==="media_quiz"){let I=a.optionFontSize??a.optionFont?.fontSize??a.typography?.optionSize??a.options?.fontSize??13,O=a.borderRadius??a.radius??a.containerBorderRadius,tt=a.optionRadius??a.optionBorderRadius??a.imageRadius;return{...R,type:"image_quiz",question:M.question||M.title||"Image Quiz",options:to(M.options||[]),layout:M.layout??a.layout??r.layout,styling:{...R.styling,borderRadius:O!==void 0?O>=100?"999px":v(O,x):void 0,optionRadius:tt!==void 0?tt>=100?"999px":v(tt,x):void 0,questionBgColor:Ct(a.questionBgColor||a.questionBackground),questionTextColor:et(a.questionColor||a.questionTextColor),optionBgColor:Ct(a.optionBgColor||a.optionBackground),optionTextColor:et(a.optionTextColor||a.textColor),labelColor:et(a.labelColor),borderColor:et(a.borderColor),activeColor:et(a.correctBorderColor||a.correctColor||a.activeColor),incorrectColor:et(a.incorrectColor),imageRadius:tt!==void 0?v(tt,x):void 0,optionFontSize:w(I,x)}}}if(R.type==="countdown")return{...R,type:"countdown",title:M.title||"Ends in...",targetDate:cr(M),styling:{...R.styling,borderColor:et(a.borderColor),digitBackground:Ct(a.digitBackground),digitColor:et(a.digitColor),digitSize:a.digitSize||a.fontSize?w(a.digitSize||a.fontSize,x):void 0,labelColor:et(a.labelColor),titleColor:et(a.titleColor),labelFontSize:a.labelFontSize?w(a.labelFontSize,x):void 0},display:M.display||r.display};if(R.type==="promo_code")return{...R,width:R.width?Math.max(R.width,65):75,type:"promo_code",code:dr(r,M,a),styling:{...R.styling,borderColor:et(a.borderColor)}};if(R.type==="reaction"||R.type==="emoji_reaction"){let I=ar(M);return{...R,type:"reaction",emojis:I.length>0?I:["\u{1F60D}","\u{1F44D}"]}}return R}),U=m.map(r=>{let M=j.find(I=>String(I?.id)===String(r?.id))||j.find(I=>I?.id===void 0)||{},f=en(r,t)==="studio",x={position:r?.position,size:r?.size,rotation:r?.rotation,z:r?.z,background:r?.background,cardBackground:r?.cardBackground,cardBorderRadius:r?.cardBorderRadius,cardRadiusPercent:r?.cardRadiusPercent,transparent:r?.transparent,textColor:r?.textColor,buttonBackground:r?.buttonBackground,buttonTextColor:r?.buttonTextColor,buttonFontSize:r?.buttonFontSize,buttonBorderRadius:r?.buttonBorderRadius,titleColor:r?.titleColor,titleFontSize:r?.titleFontSize,titleFontWeight:r?.titleFontWeight,priceColor:r?.priceColor,priceFontSize:r?.priceFontSize,priceFontWeight:r?.priceFontWeight,mrpColor:r?.mrpColor,mrpFontSize:r?.mrpFontSize,mrpFontWeight:r?.mrpFontWeight,imageRadius:r?.imageRadius,opacity:r?.opacity,animation:r?.animation},z={...M,...r?.styling||{},...Object.fromEntries(Object.entries(x).filter(([,I])=>I!==void 0))},Y=z.position||{},ot=z.size||{},J=z.cardBorderRadius!==void 0?Number(z.cardBorderRadius):void 0,H=z.cardRadiusPercent!==void 0?Number(z.cardRadiusPercent):void 0,K=ot.height!==void 0?Number(ot.height):void 0,it=J===void 0&&H!==void 0&&K!==void 0?Math.max(0,Math.min(100,H))/100*(K/2):void 0,xt=J??it,ut=xt!==void 0&&!isNaN(xt)?xt*c:void 0,Z=Y.x!==void 0?f?Number(Y.x):Number(Y.x)/s*100:0,rt=ot.width!==void 0?f?Number(ot.width):Number(ot.width)/s*100:100,dt=ot.height!==void 0?f?Number(ot.height):Number(ot.height)/l*100:void 0,ht=Y.y!==void 0?f?Number(Y.y):Number(Y.y)/l*100:dt?100-dt-2.5:85;dt&&ht+dt>96?ht=Math.max(0,100-dt):ht>75&&dt&&ht+dt>91&&(ht=Math.max(0,100-dt-1));let mt=Array.isArray(r.product)&&r.product.length>0,R=mt?r.product:r.static||[];return{id:r.id||Math.random().toString(),type:"buy",shopableType:mt?"product":"static",x:Z,y:ht,width:rt,height:dt,rotation:z.rotation??0,z:z.z??10,products:R.map(I=>{let O=I.productData||I||{},tt=O.attributes||I.attributes||{},St=tt.sales_price||O.price||tt.price||I.price,zt=tt.sales_price?O.price||tt.price||I.price:O.oldPrice||I.oldPrice,Tt=O.color||tt.color||I.color,Yt=O.size||tt.size||I.size,Lt=tt.colors||[];Lt.length===0&&Tt&&(Lt=[{id:Tt,hex:Tt,name:Tt}]);let Zt=tt.sizes||[];Zt.length===0&&Yt&&(Zt=typeof Yt=="string"?Yt.split(",").map(ce=>ce.trim()):[Yt]);let It={description:O.description||tt.description||I.description,color:Tt,size:Yt,colors:Lt,sizes:Zt,imageUrls:tt.imageUrls||[tt.image_link||O.imageUrl||O.image||I.imageUrl||I.image||I.url].filter(Boolean),availability:O.availability||tt.availability||I.availability,tags:O.tags||tt.tags||I.tags,...tt};return{id:O.productId||O.id||I.productId||I.id||Math.random().toString(),image:tt.image_link||O.imageUrl||O.image||I.imageUrl||I.image||I.url,url:O.link||O.url||I.link||I.url||I.redirectUrl,title:O.title||I.title,price:St,oldPrice:zt,redirectUrl:I.redirectUrl||O.link||I.link||I.url,svg:O.svg||I.svg,productId:O.productId||I.productId,collectionId:O.collectionId||I.collectionId,feedId:O.feedId||I.feedId,attributes:It}}),styling:{backgroundColor:Ct(z.background),cardBackground:Ct(z.cardBackground)||Ct(z.background)||"#ffffff",cardBorderRadius:xt!==void 0&&!isNaN(xt)?f?`${xt}cqh`:`${ut}px`:f?"1cqh":"10px",cardRadiusPercent:H,transparent:z.transparent===!0,textColor:et(z.textColor)||"#ffffff",buttonBackground:Ct(z.buttonBackground)||"#000000",buttonTextColor:et(z.buttonTextColor)||"#ffffff",buttonFontSize:w(z.buttonFontSize||12,f),buttonBorderRadius:z.buttonBorderRadius!==void 0?f?`${z.buttonBorderRadius}cqh`:`${z.buttonBorderRadius}px`:f?"10cqh":"100px",titleColor:et(z.titleColor||z.textColor)||"#1a1a2e",titleFontSize:w(z.titleFontSize||14,f),titleFontWeight:z.titleFontWeight?String(z.titleFontWeight):"600",priceColor:et(z.priceColor||z.textColor)||"#1a1a2e",priceFontSize:w(z.priceFontSize||16,f),priceFontWeight:z.priceFontWeight?String(z.priceFontWeight):"700",mrpColor:et(z.mrpColor)||"#8b8b98",mrpFontSize:w(z.mrpFontSize||12,f),mrpFontWeight:z.mrpFontWeight?String(z.mrpFontWeight):"500",imageRadius:z.imageRadius!==void 0?f?`${z.imageRadius}cqh`:`${Number(z.imageRadius)*c}px`:f?"1cqh":"10px",animation:Bo(z.animation)}}}),A=S.map(r=>{let a=(t?.styling?.image||t?.styling?.images||[]).find(z=>z.id===r.id)||{},f=r.position||a.position||r.postion||{x:0,y:0},x=r.borderRadius??r.styling?.borderRadius??a.borderRadius??a.styling?.borderRadius??r.imageRadius??r.radius;return{id:r.id||Math.random().toString(),type:"image",x:L?Number(f.x):f.x/s*100,y:L?Number(f.y):f.y/l*100,width:L?Number(r.width):r.width/s*100,height:r.height?L?Number(r.height):r.height/l*100:void 0,url:r.link||r.url,z:r.z??a.z??0,styling:{borderRadius:x!==void 0?v(x,L):void 0,objectFit:r.objectFit||a.objectFit||r.sizing||a.sizing||"fill",objectPosition:uo(r.objectPosition||a.objectPosition||r.positionStr),border:r.border||r.styling?.border||a.border,boxShadow:r.shadow||r.styling?.shadow||a.shadow,opacity:(r.opacity!==void 0?r.opacity:a.opacity)!==void 0?Number(r.opacity!==void 0?r.opacity:a.opacity)/100:void 0}}}),T=y.map(r=>{let a=(t?.styling?.video||t?.styling?.videos||[]).find(K=>K.id===r.id)||{},f=r.position||a.position||{x:r.x,y:r.y},x=f.x??r.x,z=f.y??r.y,Y=r.width??a.width,ot=r.height??a.height,J=r.cornerRadius??r.borderRadius??a.cornerRadius??a.borderRadius??r.radius,H=r.rotation!==void 0?r.rotation:a.rotation;return{id:r.id||Math.random().toString(),type:"video",x:x!==void 0&&!isNaN(Number(x))?L?Number(x):Number(x)/s*100:0,y:z!==void 0&&!isNaN(Number(z))?L?Number(z):Number(z)/l*100:0,width:Y!==void 0&&!isNaN(Number(Y))?L?Number(Y):Number(Y)/s*100:100,height:ot!==void 0&&!isNaN(Number(ot))?L?Number(ot):Number(ot)/l*100:void 0,url:r.link||r.url||r.src||a.link||a.url,rotation:H??0,z:r.z??a.z??2,loop:r.loop??a.loop??!0,muted:r.muted??a.muted??!1,styling:{borderRadius:J!==void 0?v(J,L):void 0,objectFit:r.objectFit||a.objectFit||r.sizing||a.sizing||"cover",objectPosition:uo(r.objectPosition||a.objectPosition),border:r.border||r.styling?.border||a.border,boxShadow:r.shadow||r.styling?.shadow||a.shadow,opacity:(r.opacity!==void 0?r.opacity:a.opacity)!==void 0?Number(r.opacity!==void 0?r.opacity:a.opacity)/100:void 0}}}),k=C.map(r=>{let a=(t?.styling?.lottie||t?.styling?.lotties||[]).find(ut=>ut.id===r.id)||{},f=r.position||a.position||{x:r.x,y:r.y},x=f.x??r.x,z=f.y??r.y,Y=r.width??a.width,ot=r.height??a.height,J=r.cornerRadius??r.borderRadius??a.cornerRadius??a.borderRadius??r.radius,H=r.rotation!==void 0?r.rotation:a.rotation,K=r.flip||a.flip||{},it="";K.horizontal&&K.vertical?it="scale(-1, -1)":K.horizontal?it="scaleX(-1)":K.vertical&&(it="scaleY(-1)");let xt=r.duration||a.duration;return{id:r.id||Math.random().toString(),type:"lottie",x:x!==void 0&&!isNaN(Number(x))?L?Number(x):Number(x)/s*100:0,y:z!==void 0&&!isNaN(Number(z))?L?Number(z):Number(z)/l*100:0,width:Y!==void 0&&!isNaN(Number(Y))?L?Number(Y):Number(Y)/s*100:100,height:ot!==void 0&&!isNaN(Number(ot))?L?Number(ot):Number(ot)/l*100:void 0,url:r.link||r.url||r.src||r.lottie_url||a.link||a.url,rotation:H??0,z:r.z??a.z??3,duration:xt?.start!==void 0?xt:void 0,loop:r.loop??a.loop??!0,autoplay:r.autoplay??a.autoplay??!0,styling:{borderRadius:J!==void 0?v(J,L):void 0,border:r.border||r.styling?.border||a.border,boxShadow:r.shadow||r.styling?.shadow||a.shadow,opacity:(r.opacity!==void 0?r.opacity:a.opacity)!==void 0?Number(r.opacity!==void 0?r.opacity:a.opacity)/100:void 0,transform:it||void 0,animation:Bo(r.animation||a.animation)}}}),B=h.map(r=>{let a=(t?.styling?.text||[]).find(xt=>xt.id===r.id)||{},f=r.position||a.position||{x:0,y:0},x=r.font||a.font||{},z=r.size||a.size||{},Y=r.alignment||a.alignment||{},ot=r.color||a.color,J=x.fontDecoration||[],H=J.includes("underline")?"underline":J.includes("line-through")?"line-through":void 0,K=r.rotation!==void 0?r.rotation:a.rotation,it=x.fontSize??r.fontSize??a.fontSize??a.font?.fontSize;return{id:r.id||Math.random().toString(),type:"text",x:L?Number(f.x):f.x/s*100,y:L?Number(f.y):f.y/l*100,width:z.width?L?Number(z.width):z.width/s*100:void 0,height:z.height?L?Number(z.height):z.height/l*100:void 0,rotation:K??0,text:r.text||r.value||a.text||a.value||"",z:r.z??a.z??1,styling:{color:et(ot)||"#000000",fontSize:it?w(it,L):void 0,fontFamily:x.fontFamily,fontStyle:x.fontStyle||(J.includes("italic")?"italic":"normal"),fontWeight:x.fontWeight||(J.includes("bold")?"bold":"normal"),textDecoration:H,lineHeight:r.lineHeight!==void 0?r.lineHeight:a.lineHeight,letterSpacing:(r.letterSpacing!==void 0?r.letterSpacing:a.letterSpacing)!==void 0?`${r.letterSpacing!==void 0?r.letterSpacing:a.letterSpacing}px`:void 0,opacity:(r.opacity!==void 0?r.opacity:a.opacity)!==void 0?Number(r.opacity!==void 0?r.opacity:a.opacity)/100:void 0,textAlign:Y.horizontalAlignment||"left",verticalAlignment:Y.verticalAlignment||"top"}}}),$=g.map(r=>{let a=(t?.styling?.ctas||t?.styling?.cta||[]).find(xt=>xt.id===r.id)||{},f=r.position||a.position||{x:0,y:0},x=r.size||a.size||{},z=r.font||a.font||{},Y=z.fontDecoration||[],ot=Y.includes("underline")?"underline":Y.includes("line-through")?"line-through":void 0,J=r.rotation!==void 0?r.rotation:a.rotation,H=z.fontSize??r.fontSize??a.fontSize??a.font?.fontSize,K=r.borderRadius??r.styling?.borderRadius??a.borderRadius??a.styling?.borderRadius,it=r.borderWidth??r.styling?.borderWidth??a.borderWidth??a.styling?.borderWidth;return{id:r.id||Math.random().toString(),type:"cta",x:L?Number(f.x):f.x/s*100,y:L?Number(f.y):f.y/l*100,width:x.width?L?Number(x.width):x.width/s*100:void 0,height:x.height?L?Number(x.height):x.height/l*100:void 0,rotation:J??0,text:r.text||a.text||"Learn More",redirectUrl:r.redirectUrl||a.redirectUrl||r.link||a.link,ctaType:r.type||a.type||"classic",url:r.url||a.url,z:r.z??a.z??10,source:L?"studio":"dashboard",styling:{backgroundColor:Ct(r.background||a.background),textColor:et(r.textColor||a.textColor)||"#FFFFFF",borderColor:et(r.borderColor||a.borderColor||r.styling?.borderColor||a.styling?.borderColor)||"#FFFFFF",borderWidth:it!==void 0&&Number(it)>0?v(it,L):void 0,borderRadius:K!==void 0?v(K,L):void 0,fontSize:H?w(H,L):void 0,fontFamily:z.fontFamily,fontStyle:z.fontStyle||(Y.includes("italic")?"italic":"normal"),fontWeight:z.fontWeight||(Y.includes("bold")?"bold":"normal"),textDecoration:ot,pillH:r.pillH??a.pillH,arrowAnimation:r.arrowAnimation??a.arrowAnimation,arrowColor:et(r.arrowColor||a.arrowColor),arrowSize:r.arrowSize??a.arrowSize,transparent:r.transparent??a.transparent}}}),V=[..._,...N,...U,...A,...T,...k,...B,...$].filter(r=>{if(!r.duration)return!0;let{start:M,end:a}=r.duration;return n>=M&&n<=a}).sort((r,M)=>(r.z??0)-(M.z??0));return console.log("InteractiveOverlay Debug - content.ctas:",g,"displayCtas:",$,"displayItems:",V),(0,Ao.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10,pointerEvents:"none",overflow:"hidden",containerType:"size"},children:[(0,Ao.jsx)("style",{children:`
53
100
  @keyframes appstorys-fade-in {
54
101
  from { opacity: 0; transform: translateY(10px); }
55
102
  to { opacity: 1; transform: translateY(0); }
@@ -69,16 +116,16 @@
69
116
  70% { opacity: 1; transform: scale(0.95); }
70
117
  100% { opacity: 1; transform: scale(1); }
71
118
  }
72
- `}),B.map(d=>!d||typeof d!="object"||!(d.type||"").toLowerCase()?null:(0,Ie.jsx)(ni,{data:d,onInteraction:e,isEditing:o},d.id))]})};var li=require("react"),Zt=require("react/jsx-runtime"),gr=({isPaused:t,onPress:e,style:o,size:i=36})=>{let[n,r]=(0,li.useState)(!1);return(0,Zt.jsx)("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?(0,Zt.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:(0,Zt.jsx)("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"})}):(0,Zt.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:[(0,Zt.jsx)("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),(0,Zt.jsx)("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})})},di=gr;var to=require("react/jsx-runtime"),fr=t=>{switch(t){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},mr=({cta:t,buttonText:e,onPress:o})=>!t||!e||e.trim()===""?null:(0,to.jsx)("div",{style:{position:"absolute",bottom:t?.margin?.bottom,left:t?.margin?.left,right:t?.margin?.right,display:"flex",justifyContent:fr(t?.container?.alignment),width:"100%",pointerEvents:"none",boxSizing:"border-box",zIndex:10},children:(0,to.jsx)("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:(0,to.jsx)("span",{style:{color:t?.text?.color||"#ffffff",fontSize:t?.text?.fontSize||14,fontFamily:dt(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:Te(e)})})}),qo=mr;var de=require("react/jsx-runtime"),yr=({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(0,de.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,de.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"}),(0,de.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,de.jsx)("button",{onClick:e,style:x,title:c||"",children:a&&a.trim()!==""?(0,de.jsx)("img",{src:a,style:{width:u,height:u,objectFit:"contain"},alt:"close"}):m()})},Qt=yr;var It=require("react/jsx-runtime"),Uo=({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"?(0,It.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,It.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinejoin:"round"}),(0,It.jsx)("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"}),(0,It.jsx)("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"})]}):(0,It.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,It.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinejoin:"round"}),(0,It.jsx)("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"}),(0,It.jsx)("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,It.jsx)("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()!==""?(0,It.jsx)("img",{src:u,style:{width:m,height:m,objectFit:"contain"},alt:r}):y()})};var Ut=require("react/jsx-runtime"),hr=({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(0,Ut.jsxs)("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"none",stroke:g,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,Ut.jsx)("circle",{cx:"18",cy:"5",r:"3"}),(0,Ut.jsx)("circle",{cx:"6",cy:"12",r:"3"}),(0,Ut.jsx)("circle",{cx:"18",cy:"19",r:"3"}),(0,Ut.jsx)("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),(0,Ut.jsx)("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})};return(0,Ut.jsx)("button",{onClick:e,style:x,title:c||"",children:a&&a.trim()!==""?(0,Ut.jsx)("img",{src:a,style:{width:u,height:u,objectFit:"contain"},alt:"share"}):m()})},ci=hr;var z=require("react/jsx-runtime"),ze=.63,Ho=420,Gt=580,Vo="cubic-bezier(0.65, 0, 0.35, 1)",Yo="cubic-bezier(0.45, 0, 0.25, 1)";function br(t,e){let o=Ho+e*ze+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(${ze})`,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(${ze})`,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(${ze})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};case"far-right":return{transform:`translateX(${o}px) scale(${ze})`,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 pi=({src:t,isActive:e,isAnimating:o,isMuted:i,onLoadedData:n,activeVideoRef:r})=>{let s=it.default.useRef(null);return it.default.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]),(0,z.jsx)("video",{ref:s,src:t,playsInline:!0,muted:i,onLoadedData:e&&!o?n:void 0,style:{width:"100%",height:"100%",objectFit:"cover"}})},ui=({stories:t,activeStoryIndex:e,dataId:o,viewedStories:i,setViewedStories:n,onNextStory:r,onPrevStory:s,onClose:a})=>{let[c,u]=(0,it.useState)(0),[x,m]=(0,it.useState)(0),[g,v]=(0,it.useState)(!1),[f,b]=(0,it.useState)(!1),[h,y]=(0,it.useState)(!1),[w,I]=(0,it.useState)(!1),[B,R]=(0,it.useState)(null),[d,T]=(0,it.useState)(typeof window<"u"?window.innerWidth>=1024:!1),[l,p]=(0,it.useState)(!1),[O,A]=(0,it.useState)(null),[_,C]=(0,it.useState)(null),[S,W]=(0,it.useState)(null);(0,it.useEffect)(()=>{let E=()=>{T(window.innerWidth>=1024)};return window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[]);let P=(0,it.useRef)(null),M=(0,it.useRef)(null),$=(0,it.useRef)(0),k=t[e],L=k?.slides[c],j=L?.styling,X=j?.editorSource||j?.meta?.editorSource,ft=X==="studio"||X==="editor",N=ft?j?.background?.media?.mediaUrl:L?.image,tt=ft?L?.content?.button_text:L?.button_text,K=ft?L?.content?.link:L?.link,Y=L?.video||(ft?L?.content?.video?.[0]?.link:void 0),nt=L?.content?.canva,U=nt&&nt.width&&nt.height?nt.width/nt.height:400/700,G=700,Q=Math.round(G*U),at=async()=>{let E={title:k.name,text:`Check out this story: ${k.name}`,url:window.location.href};if(L?.id&&H("shared",o,{story_slide:L.id}),navigator.share)try{await navigator.share(E)}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((0,it.useEffect)(()=>{u(0),m(0),b(!1),y(!1),p(!1),A(null),C(null),W(null)},[e]),(0,it.useEffect)(()=>{let E=q=>{if(!(document.activeElement?.tagName==="INPUT"||document.activeElement?.tagName==="TEXTAREA"))switch(q.key){case"ArrowRight":rt();break;case"ArrowLeft":Bt();break;case" ":q.preventDefault(),y(st=>!st);break;case"Escape":a();break;case"s":case"S":q.preventDefault(),at();break}};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[c,e,h,k,a]),(0,it.useEffect)(()=>{k&&L&&H("viewed",o,{story_slide:L.id})},[c,k?.id,o]),(0,it.useEffect)(()=>{if(k&&L){let E=k.styling?.slideShowTime||5,q=!!Y;if(P.current&&clearInterval(P.current),h){M.current&&M.current.pause();return}else M.current&&M.current.play().catch(()=>{});return q&&!f||l?void 0:(P.current=setInterval(()=>{m(st=>st>=100?(rt(),100):st+100/(E*10))},100),()=>{P.current&&clearInterval(P.current)})}},[e,c,h,f,l]),!L)return null;let St=(E,q)=>{l||(W(E),A(c),C(q),p(!0),setTimeout(()=>{u(q),m(0),b(!1),p(!1),A(null),C(null),W(null)},Gt+20))},rt=()=>{if(!l)if(c<k.slides.length-1)St("next",c+1);else{if(!i.includes(k.id)){let E=[...i,k.id];n(E),localStorage.setItem("app_storys_viewed_stories",JSON.stringify(E))}r()}},Bt=()=>{l||(c>0?St("prev",c-1):s())},ht=()=>{$.current=Date.now(),y(!0)},At=E=>{y(!1),Date.now()-$.current<300&&(E==="next"?rt():Bt())},ee=()=>b(!0),en=E=>{let q=E?.styling,st=q?.editorSource||q?.meta?.editorSource,bt=st==="studio"||st==="editor"?E.content?.link:E.link;bt&&(H("clicked",o,{story_slide:E.id}),bt.startsWith("http")?window.open(bt,"_blank"):window.location.href=bt)},on=E=>{E.stopPropagation(),v(!g)},nn=k?.styling?.crossButton,rn=k?.styling?.soundToggle,qr=L?.styling?.cta,sn=E=>l?S==="next"?E===O?"left":E===_?"center":E===(O??0)-1?"far-left":E===(O??0)-2?"hidden":E===(_??0)+1?"right":E===(_??0)+2?"far-right":"hidden":E===O?"right":E===_?"center":E===(O??0)+1?"far-right":E===(O??0)+2?"hidden":E===(_??0)-1?"left":E===(_??0)-2?"far-left":"hidden":E===c?"center":E===c-1?"left":E===c-2?"far-left":E===c+1?"right":E===c+2?"far-right":"hidden",Ai=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"},an=d?{position:"absolute",width:`${Q}px`,height:`${G}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"},Ur={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"},Ei=k.slides.reduce((E,q,st)=>(sn(st)!=="hidden"&&E.push(st),E),[]),pe=new Set(Ei);return pe.add(c),c>0&&pe.add(c-1),c>1&&pe.add(c-2),c<k.slides.length-1&&pe.add(c+1),c<k.slides.length-2&&pe.add(c+2),(0,z.jsxs)("div",{style:Ai,onClick:()=>!d&&rt(),children:[(0,z.jsxs)("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:[Y?(0,z.jsx)("video",{src:Y,style:{width:"100%",height:"100%",objectFit:"cover",filter:"blur(120px) saturate(1.8) opacity(0.35)"},muted:!0}):(0,z.jsx)(jt,{src:N||k.thumbnail,style:{width:"100%",height:"100%",filter:"blur(120px) saturate(1.8) opacity(0.35)"}}),(0,z.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(5, 5, 8, 0.4)"}})]},`${e}-${l?_:c}`),d&&(0,z.jsxs)("div",{style:{width:"100%",display:"flex",flexDirection:"column",paddingTop:"20px",zIndex:10},children:[(0,z.jsx)("div",{style:{width:"100%",display:"flex",gap:"8px",padding:"0 20px",boxSizing:"border-box"},children:k.slides.map((E,q)=>{let st=l&&_!==null?_:c,_t="0%";return q<st?_t="100%":q===st&&(_t=`${x}%`),(0,z.jsx)("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.15)",borderRadius:"2px",overflow:"hidden"},children:(0,z.jsx)("div",{style:{width:_t,height:"100%",backgroundColor:"white",transition:q===st?"width 0.1s linear":"none"}})},q)})}),(0,z.jsxs)("div",{style:{width:"100%",maxWidth:"1400px",margin:"0 auto",display:"grid",gridTemplateColumns:`minmax(0, 1fr) ${Q}px minmax(0, 1fr)`,gap:"12px",alignItems:"center",marginTop:"16px",padding:"0 20px",boxSizing:"border-box",zIndex:w?2e3:10},children:[(0,z.jsx)("div",{style:{paddingLeft:"0px"}}),(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,z.jsx)(jt,{src:k.thumbnail,alt:k.name,style:{width:"44px",height:"44px",borderRadius:"50%",border:"2px solid white",margin:0}}),(0,z.jsx)("span",{style:{color:"white",fontWeight:"bold",fontSize:"16px",whiteSpace:"nowrap"},children:k.name})]}),(0,z.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[(0,z.jsx)(ci,{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:at,style:{position:"relative",borderRadius:"12px"}}),(0,z.jsx)(Uo,{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:on,type:g?"mute":"unmute",enabled:!!rn?.enabled&&!!Y,style:{position:"relative",borderRadius:"12px"}}),(0,z.jsx)(di,{isPaused:h,onPress:()=>y(!h),size:44,style:{borderRadius:"12px"}})]})]}),(0,z.jsxs)("div",{style:{display:"flex",gap:"10px",flex:1,justifyContent:"flex-end",paddingRight:"0px"},children:[(0,z.jsxs)("div",{style:{position:"relative"},children:[(0,z.jsx)("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:(0,z.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,z.jsx)("rect",{x:"3",y:"3",width:"7",height:"7"}),(0,z.jsx)("rect",{x:"14",y:"3",width:"7",height:"7"}),(0,z.jsx)("rect",{x:"14",y:"14",width:"7",height:"7"}),(0,z.jsx)("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),w&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("style",{children:`
119
+ `}),V.map(r=>!r||typeof r!="object"||!(r.type||"").toLowerCase()?null:(0,Ao.jsx)(rr,{data:r,onInteraction:e,isEditing:o},r.id))]})};var ur=require("react"),Oe=require("react/jsx-runtime"),zs=({isPaused:t,onPress:e,style:o,size:n=36})=>{let[i,s]=(0,ur.useState)(!1);return(0,Oe.jsx)("button",{onClick:e,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:`${n}px`,height:`${n}px`,background:i?"rgba(255, 255, 255, 0.15)":"rgba(255, 255, 255, 0.08)",border:i?"1px solid white":"1px solid rgba(255, 255, 255, 0.1)",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"10px",cursor:"pointer",transition:"all 0.2s ease",padding:0,outline:"none",...o},children:t?(0,Oe.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:(0,Oe.jsx)("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"})}):(0,Oe.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:[(0,Oe.jsx)("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),(0,Oe.jsx)("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})})},pr=zs;var on=require("react/jsx-runtime"),Is=t=>{switch(t){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},Bs=({cta:t,buttonText:e,onPress:o})=>!t||!e||e.trim()===""?null:(0,on.jsx)("div",{style:{position:"absolute",bottom:t?.margin?.bottom,left:t?.margin?.left,right:t?.margin?.right,display:"flex",justifyContent:Is(t?.container?.alignment),width:"100%",pointerEvents:"none",boxSizing:"border-box",zIndex:10},children:(0,on.jsx)("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:(0,on.jsx)("span",{style:{color:t?.text?.color||"#ffffff",fontSize:t?.text?.fontSize||14,fontFamily:lt(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:Pe(e)})})}),jn=Bs;var ze=require("react/jsx-runtime"),Ls=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,style:n})=>{if(!t||t.enabled===!1)return null;let{size:i=18,margin:s,color:l,image:c,selectedStyle:d}=t,S=o?40:i,p={marginTop:o?0:s?.top??0,marginBottom:o?0:s?.bottom??0,marginLeft:o?0:s?.left??0,marginRight:o?0:s?.right??0,width:S,height:S,backgroundColor:l?.fill||"transparent",borderColor:l?.stroke||"transparent",borderWidth:S*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"relative",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:l?.stroke?"solid":"none",...n},y=()=>{let u=l?.cross||"#ffffff";return(0,ze.jsxs)("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"none",stroke:u,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,ze.jsx)("circle",{cx:"18",cy:"5",r:"3"}),(0,ze.jsx)("circle",{cx:"6",cy:"12",r:"3"}),(0,ze.jsx)("circle",{cx:"18",cy:"19",r:"3"}),(0,ze.jsx)("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),(0,ze.jsx)("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})};return(0,ze.jsx)("button",{onClick:e,style:p,children:c&&c.trim()!==""?(0,ze.jsx)("img",{src:c,style:{width:S,height:S,objectFit:"contain"},alt:"share"}):y()})},qn=Ls;var W=require("react/jsx-runtime"),nn=t=>{if(t)return t.content?.canva||t.canva||t.styling?.canva||t.meta?.canva||t.content?.styling?.canva||t.content?.meta?.canva},Es=t=>{let e=nn(t),o=Number(e?.width),n=Number(e?.height);return o>0&&n>0?o/n:9/16},Mo=.63;var We=580,Hn="cubic-bezier(0.65, 0, 0.35, 1)",Vn="cubic-bezier(0.45, 0, 0.25, 1)";function As(t,e){let o=Math.round(e*1.08),n=o+Math.round(e*Mo)+20;switch(t){case"center":return{transform:"translateX(0px) scale(1)",opacity:1,zIndex:10,pointerEvents:"auto",boxShadow:"0 32px 64px -12px rgba(0,0,0,0.9)",filter:"brightness(1)"};case"left":return{transform:`translateX(-${o}px) scale(${Mo})`,opacity:1,filter:"brightness(0.55)",zIndex:5,pointerEvents:"auto",boxShadow:"0 8px 24px rgba(0,0,0,0.5)"};case"right":return{transform:`translateX(${o}px) scale(${Mo})`,opacity:1,filter:"brightness(0.55)",zIndex:5,pointerEvents:"auto",boxShadow:"0 8px 24px rgba(0,0,0,0.5)"};case"far-left":return{transform:`translateX(-${n}px) scale(${Mo})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};case"far-right":return{transform:`translateX(${n}px) scale(${Mo})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};default:return{opacity:0,zIndex:1,pointerEvents:"none",transform:"translateX(0px) scale(1)",filter:"brightness(1)"}}}var gr=({src:t,isActive:e,isAnimating:o,isMuted:n,onLoadedData:i,activeVideoRef:s,objectFit:l="cover",objectPosition:c="center center"})=>{let d=yt.default.useRef(null);return yt.default.useEffect(()=>{e&&!o?(s.current=d.current,d.current?.play().catch(()=>{}),d.current&&d.current.readyState>=1&&i?.()):(d.current?.pause(),s.current===d.current&&(s.current=null))},[e,o,t,s,i]),(0,W.jsx)("video",{ref:d,src:t,playsInline:!0,muted:n,onLoadedData:i,onCanPlay:i,onLoadedMetadata:i,style:{width:"100%",height:"100%",objectFit:l,objectPosition:c}})},fr="appstorys_viewed_slide_ids",Un="appstorys_clicked_interaction_ids";var Ms=t=>{try{let e=localStorage.getItem(fr),o=e?JSON.parse(e):[];Array.isArray(o)&&!o.includes(t)&&(o.push(t),localStorage.setItem(fr,JSON.stringify(o)))}catch{}},Ps=t=>{try{let e=localStorage.getItem(Un);if(!e)return!1;let o=JSON.parse(e);return Array.isArray(o)&&o.includes(t)}catch{return!1}},Ds=t=>{try{let e=localStorage.getItem(Un),o=e?JSON.parse(e):[];Array.isArray(o)&&!o.includes(t)&&(o.push(t),localStorage.setItem(Un,JSON.stringify(o)))}catch{}},mr=({stories:t,activeStoryIndex:e,dataId:o,viewedStories:n,setViewedStories:i,onNextStory:s,onPrevStory:l,onClose:c})=>{let d=t[e],S=F=>{if(!F?.id)return 0;try{let q=`appstorys_cta_redirect_${F.id}`,ft=sessionStorage.getItem(q);if(ft){let $t=JSON.parse(ft),Ft=Date.now()-($t.timestamp||0),Ee=F.slides?.length||1;if(sessionStorage.removeItem(q),Ft<=300*1e3&&typeof $t.slideIndex=="number"&&$t.slideIndex>=0&&$t.slideIndex<Ee)return $t.slideIndex}}catch{}return 0},[p,y]=(0,yt.useState)(()=>S(t[e])),[u,C]=(0,yt.useState)(0),[h,g]=(0,yt.useState)(t[e]?.styling?.soundToggle?.defaultSound==="no"),[b,m]=(0,yt.useState)(!1),[E,j]=(0,yt.useState)(!1),[D,L]=(0,yt.useState)(!1),[v,w]=(0,yt.useState)(null),[_,N]=(0,yt.useState)({width:typeof window<"u"?window.innerWidth:1280,height:typeof window<"u"?window.innerHeight:800}),[U,A]=(0,yt.useState)(typeof window<"u"?window.innerWidth>=1024:!1),[T,k]=(0,yt.useState)(!1),[B,$]=(0,yt.useState)(null),[V,G]=(0,yt.useState)(null),[r,M]=(0,yt.useState)(null),[a,f]=(0,yt.useState)(!1),[x,z]=(0,yt.useState)("none"),[Y,ot]=(0,yt.useState)(null),J=(0,yt.useRef)(null),H=(0,yt.useRef)(null),K=(0,yt.useRef)(0),it=(0,yt.useRef)(null),xt=(0,yt.useRef)(!1),ut=d?.slides[p],Z=ut?.styling,rt=Z?.editorSource||Z?.meta?.editorSource,dt=rt==="studio"||rt==="editor",ht=dt?Z?.background?.media?.mediaUrl:ut?.image,mt=dt?ut?.content?.button_text:ut?.button_text,R=dt?ut?.content?.link:ut?.link,I=F=>{if(!F)return;if(F.video&&typeof F.video=="string")return F.video;let q=F.styling?.background?.media||F.content?.styling?.background?.media||F.content?.background?.media;if(q&&(q.mediaType==="video"||q.type==="video"||q.isVideo))return q.mediaUrl||q.url||q.link},O=I(ut),tt=nn(ut),St=Es(ut),zt=U?160:80,Tt=Math.max(350,_.height-zt),Yt=U?_.width*.75:_.width*.95,Lt=Math.min(Tt,Yt/St),Zt=Math.round(U?Math.max(450,Math.min(Lt,850)):Math.min(Tt,850)),It=Math.round(Zt*St),ce=(F,q)=>{T||(C(0),M(F),$(p),G(q),k(!0),setTimeout(()=>{y(q),C(0),m(!1),k(!1),$(null),G(null),M(null)},We+20))},xe=F=>{if(!(a||T)){if(C(0),F==="next"){if(e>=t.length-1){s();return}}else if(e<=0){l();return}f(!0),ot(F),z("out"),setTimeout(()=>{F==="next"?s():l(),z("prepare-in"),setTimeout(()=>{z("in"),setTimeout(()=>{f(!1),z("none"),ot(null)},320)},35)},280)}},Ie=()=>{if(!(T||a))if(p<(d?.slides?.length||0)-1)ce("next",p+1);else{if(d&&!n.includes(d.id)){let F=[...n,d.id];i(F),localStorage.setItem("app_storys_viewed_stories",JSON.stringify(F))}xe("next")}},wo=()=>{T||a||(p>0?ce("prev",p-1):xe("prev"))},Oo=async()=>{if(!d)return;let F={title:d.name,text:`Check out this story: ${d.name}`,url:window.location.href};if(ut?.id&&st("shared",o,{story_slide:ut.id}),navigator.share)try{await navigator.share(F)}catch{}else if(navigator.clipboard)try{await navigator.clipboard.writeText(window.location.href),w("Story link copied to clipboard!"),setTimeout(()=>w(null),2500)}catch{}};if((0,yt.useEffect)(()=>{let F=()=>{N({width:window.innerWidth,height:window.innerHeight}),A(window.innerWidth>=1024)};return window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[]),(0,yt.useEffect)(()=>{let F=document.body.style.overflow,q=document.body.style.touchAction;return document.body.style.overflow="hidden",document.body.style.touchAction="none",()=>{document.body.style.overflow=F,document.body.style.touchAction=q}},[]),(0,yt.useEffect)(()=>{let F=S(d);y(F),C(0),m(!1),j(!1),k(!1),f(!1),z("none"),ot(null),$(null),G(null),M(null),g(d?.styling?.soundToggle?.defaultSound==="no")},[e]),(0,yt.useEffect)(()=>{let F=()=>{document.hidden?(xt.current=E,j(!0),H.current&&H.current.pause()):xt.current||(j(!1),H.current&&H.current.play().catch(()=>{}))};return document.addEventListener("visibilitychange",F),()=>document.removeEventListener("visibilitychange",F)},[E]),(0,yt.useEffect)(()=>{let F=q=>{if(!(document.activeElement?.tagName==="INPUT"||document.activeElement?.tagName==="TEXTAREA"))switch(q.key){case"ArrowRight":Ie();break;case"ArrowLeft":wo();break;case" ":q.preventDefault(),j(ft=>!ft);break;case"Escape":c();break;case"s":case"S":q.preventDefault(),Oo();break}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[p,e,E,d,c]),(0,yt.useEffect)(()=>{if(d&&ut){let F=ut.id?String(ut.id):`${d.id||o}_slide_${p}`,q=`${e}_${p}_${F}`;it.current!==q&&(it.current=q,Ms(F),st("viewed",o,{story_slide:F}))}},[e,p,d?.id,o,ut?.id]),(0,yt.useEffect)(()=>{if(d&&ut&&!!O&&!b){let q=setTimeout(()=>{m(!0)},2e3);return()=>clearTimeout(q)}},[e,p,O,b]),(0,yt.useEffect)(()=>{if(d&&ut){let F=d.styling?.slideShowTime||5,q=!!O;if(J.current&&clearInterval(J.current),E){H.current&&H.current.pause();return}else H.current&&H.current.play().catch(()=>{});return q&&!b||T||a?void 0:(J.current=setInterval(()=>{C(ft=>ft>=100?(Ie(),100):ft+100/(F*10))},100),()=>{J.current&&clearInterval(J.current)})}},[e,p,E,b,T,a,O]),!ut)return null;let ko=()=>x==="out"?{transform:`translateX(${Y==="next"?-120:120}px) scale(0.92)`,opacity:0,filter:"blur(6px)",transition:"transform 280ms cubic-bezier(0.4, 0, 0.2, 1), opacity 280ms cubic-bezier(0.4, 0, 0.2, 1), filter 280ms cubic-bezier(0.4, 0, 0.2, 1)",willChange:"transform, opacity, filter"}:x==="prepare-in"?{transform:`translateX(${Y==="next"?120:-120}px) scale(0.92)`,opacity:0,filter:"blur(6px)",transition:"none",willChange:"transform, opacity, filter"}:x==="in"?{transform:"translateX(0px) scale(1)",opacity:1,filter:"blur(0px)",transition:"transform 320ms cubic-bezier(0.16, 1, 0.3, 1), opacity 320ms cubic-bezier(0.16, 1, 0.3, 1), filter 320ms cubic-bezier(0.16, 1, 0.3, 1)",willChange:"transform, opacity, filter"}:{transition:"transform 320ms cubic-bezier(0.16, 1, 0.3, 1), opacity 320ms cubic-bezier(0.16, 1, 0.3, 1), filter 320ms cubic-bezier(0.16, 1, 0.3, 1)"},ie=()=>{K.current=Date.now(),j(!0)},Se=F=>{j(!1),Date.now()-K.current<300&&(F==="next"?Ie():wo())},Be=()=>m(!0),Le=()=>{if(d?.id)try{sessionStorage.setItem(`appstorys_cta_redirect_${d.id}`,JSON.stringify({slideIndex:p,timestamp:Date.now()}))}catch{}},X=F=>{let q=F?.styling,ft=q?.editorSource||q?.meta?.editorSource,Ft=ft==="studio"||ft==="editor"?F.content?.link:F.link;Ft&&(Le(),st("clicked",o,{story_slide:F.id}),Ft.startsWith("http")?window.open(Ft,"_blank"):window.location.href=Ft)},gt=async(F,q)=>{let{type:ft,questionId:$t,pollId:Ft,quizId:Ee,ratingId:ue,reactionId:no,productId:He,optionId:Ro,value:re,stickerId:Ve,redirectUrl:ve,code:Ue}=F;if(ft==="cta"){ve&&(Le(),st("clicked",o,{story_slide:q.id,cta_id:Ve}),ve.startsWith("http")?window.open(ve,"_blank"):window.location.href=ve);return}j(!0);let pe=ft||"interaction";pe==="quizz"&&(pe="quiz"),(pe==="image"||ft?.startsWith("image_quiz"))&&(pe="quiz"),ft?.startsWith("promo")&&(pe="promo_code");let Jt=Ve||$t||Ft||Ee||ue||no||He||q.id;if(Ps(Jt))return;Ds(Jt);let Ye=Ro||F.selected_option||F.emoji||re||Ue||"",Fo=P.getState().userId||"anonymous",gn=Wi(),we=await At(),ti={interaction_type:pe,interaction_id:Jt,story_slide:q.id,selected_option:String(Ye)};re!=null&&re!==""&&(ti.value=String(re)),fetch(`${gn}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...we?{Authorization:`Bearer ${we}`}:{}},body:JSON.stringify({user_id:Fo,campaign_id:o,event:"clicked",metadata:ti})}).catch(Vr=>console.error("AppStorys: Instant Tracking Failed",Vr))},Bt=F=>{F.stopPropagation(),g(!h)},te=d?.styling?.crossButton,pt=d?.styling?.soundToggle,Ce=ut?.styling?.cta,oo=F=>T?r==="next"?F===B?"left":F===V?"center":F===(B??0)-1?"far-left":F===(B??0)-2?"hidden":F===(V??0)+1?"right":F===(V??0)+2?"far-right":"hidden":F===B?"right":F===V?"center":F===(B??0)+1?"far-right":F===(B??0)+2?"hidden":F===(V??0)-1?"left":F===(V??0)-2?"far-left":"hidden":F===p?"center":F===p-1?"left":F===p-2?"far-left":F===p+1?"right":F===p+2?"far-right":"hidden",qe=U?{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",background:"radial-gradient(circle at center, #0B1424 0%, #03070E 100%)",zIndex:1e5,display:"flex",flexDirection:"column",alignItems:"center",overflow:"hidden",color:"white"}:{position:"fixed",top:0,left:0,width:"100vw",height:"100dvh",backgroundColor:"#000000",zIndex:1e5,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",touchAction:"none"},qt=U?{position:"absolute",width:`${It}px`,height:`${Zt}px`,backgroundColor:"#000",borderRadius:"20px",overflow:"hidden",display:"flex",flexDirection:"column",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.8)",border:"1px solid rgba(255, 255, 255, 0.1)"}:{position:"relative",width:`min(100vw, calc(100dvh * ${St}))`,height:`min(100dvh, calc(100vw / ${St}))`,aspectRatio:`${St}`,backgroundColor:"#000",borderRadius:"0px",overflow:"hidden",display:"flex",flexDirection:"column"},Gt={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"},Xt=d.slides.reduce((F,q,ft)=>(oo(ft)!=="hidden"&&F.push(ft),F),[]),Et=new Set(Xt);return Et.add(p),p>0&&Et.add(p-1),p>1&&Et.add(p-2),p<d.slides.length-1&&Et.add(p+1),p<d.slides.length-2&&Et.add(p+2),(0,W.jsxs)("div",{style:qe,onClick:()=>!U&&Ie(),children:[(0,W.jsxs)("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:[O?(0,W.jsx)("video",{src:O,style:{width:"100%",height:"100%",objectFit:"cover",filter:"blur(120px) saturate(1.8) opacity(0.35)"},muted:!0}):ht||!dt&&d.thumbnail?(0,W.jsx)(ke,{src:ht||d.thumbnail,style:{width:"100%",height:"100%",filter:"blur(120px) saturate(1.8) opacity(0.35)"}}):null,(0,W.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(5, 5, 8, 0.4)"}})]},`${e}-${T?V:p}`),U&&(0,W.jsxs)("div",{style:{width:"100%",display:"flex",flexDirection:"column",paddingTop:"20px",zIndex:10,...ko()},children:[(0,W.jsx)("div",{style:{width:"100%",display:"flex",gap:"8px",padding:"0 20px",boxSizing:"border-box"},children:d.slides.map((F,q)=>{let ft=T&&V!==null?V:p,$t="0%";return q<ft?$t="100%":q===ft&&($t=`${u}%`),(0,W.jsx)("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.15)",borderRadius:"2px",overflow:"hidden"},children:(0,W.jsx)("div",{style:{width:$t,height:"100%",backgroundColor:"white",transition:q===ft&&u>0&&!T?"width 0.1s linear":"none"}})},q)})}),(0,W.jsxs)("div",{style:{width:"100%",margin:"0 auto",display:"grid",gridTemplateColumns:`minmax(0, 1fr) ${It}px minmax(0, 1fr)`,gap:"12px",alignItems:"center",marginTop:"16px",padding:"0 20px",boxSizing:"border-box",zIndex:D?2e3:10},children:[(0,W.jsx)("div",{style:{paddingLeft:"0px"}}),(0,W.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,W.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,W.jsx)(ke,{src:d.thumbnail,alt:d.name,style:{width:"44px",height:"44px",borderRadius:"50%",border:"2px solid white",margin:0}}),(0,W.jsx)("span",{style:{color:"white",fontWeight:"bold",fontSize:"16px",whiteSpace:"nowrap"},children:d.name})]}),(0,W.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,W.jsx)(qn,{config:{enabled:d?.styling?.share?.enabled??!0,image:d?.styling?.share?.image??"",color:{cross:d?.styling?.share?.color?.cross??"#ffffff",fill:d?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:d?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:d?.styling?.share?.size??44},onPress:Oo,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"12px",width:"44px",height:"44px"}}),(0,W.jsx)(Me,{config:{size:(h?pt?.mute?.size:pt?.unmute?.size)||44,color:{cross:(h?pt?.mute?.color?.cross:pt?.unmute?.color?.cross)||"#ffffff",fill:(h?pt?.mute?.color?.fill:pt?.unmute?.color?.fill)||"rgba(255,255,255,0.08)",stroke:(h?pt?.mute?.color?.stroke:pt?.unmute?.color?.stroke)||"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:(h?pt?.mute?.image:pt?.unmute?.image)||""},onPress:Bt,type:h?"mute":"unmute",enabled:!!pt?.enabled&&!!O,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"12px",width:"44px",height:"44px"}}),(0,W.jsx)(pr,{isPaused:E,onPress:()=>j(!E),size:44,style:{borderRadius:"12px",margin:0}})]})]}),(0,W.jsxs)("div",{style:{display:"flex",gap:"10px",flex:1,justifyContent:"flex-end",paddingRight:"0px"},children:[(0,W.jsxs)("div",{style:{position:"relative"},children:[(0,W.jsx)("button",{onClick:()=>{L(!D),j(!D)},style:{width:"44px",height:"44px",background:D?"rgba(255,255,255,0.15)":"rgba(255,255,255,0.08)",border:D?"1px solid white":"1px solid rgba(255,255,255,0.1)",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"12px",cursor:"pointer",transition:"all 0.2s",padding:0,outline:"none"},children:(0,W.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,W.jsx)("rect",{x:"3",y:"3",width:"7",height:"7"}),(0,W.jsx)("rect",{x:"14",y:"3",width:"7",height:"7"}),(0,W.jsx)("rect",{x:"14",y:"14",width:"7",height:"7"}),(0,W.jsx)("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),D&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("style",{children:`
73
120
  @keyframes fadeUp {
74
121
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
75
122
  to { opacity: 1; transform: translateY(0) scale(1); }
76
123
  }
77
- `}),(0,z.jsxs)("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:[(0,z.jsx)("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"}),(0,z.jsx)("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:E,label:q})=>(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,z.jsx)("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:E}),(0,z.jsx)("span",{style:{fontSize:"13px",color:"#E5E7EB",fontWeight:"500"},children:q})]},E))})]})]})]}),(0,z.jsx)(Qt,{config:{enabled:nn?.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"}})]})]})]}),(0,z.jsx)("div",{style:{flex:1,width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"20px"},children:(0,z.jsxs)("div",{style:{display:d?"grid":"flex",gridTemplateColumns:d?`minmax(0, 1fr) ${Q}px minmax(0, 1fr)`:"none",alignItems:"center",justifyContent:"center",gap:"12px",width:"100%",maxWidth:"1400px",position:"relative"},onClick:E=>d&&E.stopPropagation(),children:[d&&(0,z.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(c>0||e>0)&&(0,z.jsx)("button",{onClick:Bt,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:E=>E.currentTarget.style.background="rgba(0,0,0,0.7)",onMouseLeave:E=>E.currentTarget.style.background="rgba(0,0,0,0.5)",children:"\u2039"})}),d?(0,z.jsx)("div",{style:{width:`${Q}px`,height:`${G}px`,position:"relative",zIndex:5,overflow:"visible"},children:Array.from(pe).sort((E,q)=>E-q).map(E=>{let q=k.slides[E];if(!q)return null;let st=sn(E),_t=br(st,Q),bt=q?.styling,ve=bt?.editorSource||bt?.meta?.editorSource,$t=ve==="studio"||ve==="editor",De=bt?.background?.media?.mediaUrl||q?.image,we=q?.video||($t?q?.content?.video?.[0]?.link:void 0),ao=Yt(bt?.background)||"#000000",ke=$t?q?.content?.button_text:q?.button_text,Et=$t?q?.content?.link:q?.link,Re=E===c&&!l||l&&E===_,lo={display:"flex",justifyContent:"center",alignItems:"center",background:$t?ao:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"16px"};return(0,z.jsxs)("div",{style:{...an,position:"absolute",top:0,left:0,width:`${Q}px`,height:`${G}px`,..._t,transition:st==="hidden"||st==="far-left"||st==="far-right"?`opacity ${Gt}ms ease, transform ${Gt}ms ease`:E===O?`transform ${Gt}ms ${Vo}, opacity ${Gt}ms ${Vo}, filter ${Gt}ms ${Vo}`:`transform ${Gt}ms ${Yo}, opacity ${Gt}ms ${Yo}, filter ${Gt}ms ${Yo}`,transformOrigin:"center center",willChange:"transform, opacity, filter"},onClick:Wt=>Wt.stopPropagation(),children:[(0,z.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:ht,onMouseUp:()=>At("prev"),onTouchStart:ht,onTouchEnd:()=>At("prev")}),(0,z.jsx)("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:ht,onMouseUp:()=>At("next"),onTouchStart:ht,onTouchEnd:()=>At("next")}),(0,z.jsxs)("div",{style:lo,children:[we?(0,z.jsx)(pi,{src:we,isActive:Re,isAnimating:l,isMuted:g,onLoadedData:ee,activeVideoRef:M}):(De||!$t&&k?.thumbnail)&&(0,z.jsx)(jt,{src:De||k?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:$t?"contain":"cover"}}),(0,z.jsx)(No,{content:{...q.content,styling:{...q.content?.styling,...q?.styling},interactions:q.interactions},elapsedTime:Re?x/100*(k.styling?.slideShowTime||5):0,onInteraction:async Wt=>{if(!Re)return;y(!0);let{type:$e,questionId:co,pollId:ue,quizId:po,optionId:uo,value:We,stickerId:go}=Wt,ge=$e?.split("_")[0]||"interaction";ge==="quizz"&&(ge="quiz"),$e?.startsWith("image_quiz")&&(ge="quiz");let Me=go||co||ue||po||q.id,fo=uo||Wt.selected_option||"",ln=F.getState(),Pi=ln.userId||"anonymous",Li=ln.trackingUrl||"https://tracking.appstorys.co",dn=await lt();fetch(`${Li}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...dn?{Authorization:`Bearer ${dn}`}:{}},body:JSON.stringify({user_id:Pi,campaign_id:o,event:"interaction",metadata:{interaction_type:ge,interaction_id:Me,slide_id:q.id,selected_option:String(fo),value:String(We||"")}})}).catch(Di=>console.error("AppStorys: Instant Tracking Failed",Di))}})]}),(ke||Et)&&(0,z.jsx)(qo,{cta:q?.styling?.cta,buttonText:ke||"Learn More",onPress:Wt=>{Wt&&Wt.stopPropagation&&Wt.stopPropagation(),en(q)}})]},q.id||E)})}):(0,z.jsx)("div",{style:{width:"100%",maxWidth:"450px",height:"100%",maxHeight:"850px",overflow:"hidden",position:"relative",zIndex:5,display:"flex",flexDirection:"column"},children:k.slides.map((E,q)=>{if(Math.abs(q-c)>1)return(0,z.jsx)("div",{style:{display:"none"}},E.id||q);let st=E?.styling,_t=st?.editorSource||st?.meta?.editorSource,bt=_t==="studio"||_t==="editor",ve=st?.background?.media?.mediaUrl||E?.image,$t=E?.video||(bt?E?.content?.video?.[0]?.link:void 0),De=Yt(st?.background)||"#000000",we=bt?E?.content?.button_text:E?.button_text,ao=bt?E?.content?.link:E?.link,ke=q===c;return ke?(0,z.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:(0,z.jsxs)("div",{style:{...an},onClick:Et=>Et.stopPropagation(),children:[(0,z.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,display:"flex",gap:"4px",padding:"10px",zIndex:10},children:k.slides.map((Et,Jt)=>{let _e=Jt<c?"100%":Jt===c?`${x}%`:"0%";return(0,z.jsx)("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.3)",borderRadius:"2px",overflow:"hidden"},children:(0,z.jsx)("div",{style:{width:_e,height:"100%",backgroundColor:"white",transition:Jt===c?"width 0.1s linear":"none"}})},Jt)})}),(0,z.jsxs)("div",{style:{position:"absolute",top:"20px",left:"10px",right:"10px",display:"flex",alignItems:"center",justifyContent:"space-between",zIndex:10,padding:"5px"},children:[(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,z.jsx)(jt,{src:k.thumbnail,alt:k.name,style:{width:"32px",height:"32px",borderRadius:"50%"}}),(0,z.jsx)("span",{style:{color:"white",fontWeight:"bold",fontSize:"14px",textShadow:"0 1px 3px rgba(0,0,0,0.8)"},children:k.name})]}),(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,z.jsx)(Uo,{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:on,type:g?"mute":"unmute",enabled:!!rn?.enabled&&!!$t,style:{position:"relative",borderRadius:"10px"}}),(0,z.jsx)(Qt,{config:{enabled:nn?.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"}})]})]}),(0,z.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:ht,onMouseUp:()=>At("prev"),onTouchStart:ht,onTouchEnd:()=>At("prev")}),(0,z.jsx)("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:ht,onMouseUp:()=>At("next"),onTouchStart:ht,onTouchEnd:()=>At("next")}),(0,z.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",background:bt?De:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"0px"},children:[$t?(0,z.jsx)(pi,{src:$t,isActive:ke,isAnimating:l,isMuted:g,onLoadedData:ee,activeVideoRef:M}):(ve||k?.thumbnail)&&(0,z.jsx)(jt,{src:ve||k?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:bt?"contain":"cover"}}),(0,z.jsx)(No,{content:{...E.content,styling:{...E.content?.styling,...E?.styling},interactions:E.interactions},elapsedTime:x/100*(k.styling?.slideShowTime||5),onInteraction:async Et=>{y(!0);let{type:Jt,questionId:_e,pollId:Re,quizId:lo,optionId:Wt,value:$e,stickerId:co}=Et,ue=Jt?.split("_")[0]||"interaction";ue==="quizz"&&(ue="quiz"),Jt?.startsWith("image_quiz")&&(ue="quiz");let po=co||_e||Re||lo||E.id,uo=Wt||Et.selected_option||"",We=F.getState(),go=We.userId||"anonymous",ge=We.trackingUrl||"https://tracking.appstorys.co",Me=await lt();fetch(`${ge}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...Me?{Authorization:`Bearer ${Me}`}:{}},body:JSON.stringify({user_id:go,campaign_id:o,event:"interaction",metadata:{interaction_type:ue,interaction_id:po,slide_id:E.id,selected_option:String(uo),value:String($e||"")}})}).catch(fo=>console.error("AppStorys: Instant Tracking Failed",fo))}})]}),(we||ao)&&(0,z.jsx)(qo,{cta:E?.styling?.cta,buttonText:we||"Learn More",onPress:Et=>{Et&&Et.stopPropagation&&Et.stopPropagation(),en(E)}})]})},E.id||q):null})}),d&&(0,z.jsx)("div",{style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(0,z.jsx)("button",{onClick:rt,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:E=>E.currentTarget.style.background="rgba(0,0,0,0.7)",onMouseLeave:E=>E.currentTarget.style.background="rgba(0,0,0,0.5)",children:"\u203A"})}),d&&e>0&&(0,z.jsxs)("div",{style:{position:"absolute",bottom:"40px",left:"40px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"5px",zIndex:20},children:[(0,z.jsx)("span",{style:{fontSize:"11px",fontWeight:"bold",color:"rgba(255,255,255,0.75)",letterSpacing:"0.4px",paddingLeft:"2px"},children:"Previous Stories"}),(0,z.jsxs)("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:[(0,z.jsx)("span",{style:{color:"white",fontSize:"15px"},children:"\u2190"}),(0,z.jsx)("div",{style:{width:"40px",height:"40px",borderRadius:"50%",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0},children:(0,z.jsx)(jt,{src:t[e-1].thumbnail,style:{width:"36px",height:"36px",borderRadius:"50%"}})}),(0,z.jsx)("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&&(0,z.jsxs)("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"5px",zIndex:20},children:[(0,z.jsx)("span",{style:{fontSize:"11px",fontWeight:"bold",color:"rgba(255,255,255,0.75)",letterSpacing:"0.4px",paddingLeft:"2px"},children:"Next Stories"}),(0,z.jsxs)("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:[(0,z.jsx)("div",{style:{width:"40px",height:"40px",borderRadius:"50%",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0},children:(0,z.jsx)(jt,{src:t[e+1].thumbnail,style:{width:"36px",height:"36px",borderRadius:"50%"}})}),(0,z.jsx)("span",{style:{fontSize:"14px",color:"white",fontWeight:"500",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e+1].name}),(0,z.jsx)("span",{style:{color:"white",fontSize:"15px"},children:"\u2192"})]})]}),B&&(0,z.jsx)("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:B})]})})]})};var Be=require("react/jsx-runtime"),gi=()=>{let t=ct("STR"),e=F(u=>u.isVisible),[o,i]=(0,xe.useState)(null),[n,r]=(0,xe.useState)([]);if((0,xe.useEffect)(()=>{try{let u=localStorage.getItem("app_storys_viewed_stories");u&&r(JSON.parse(u))}catch(u){console.error("Failed to load viewed stories:",u)}},[]),(0,xe.useEffect)(()=>{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(0,Be.jsxs)("div",{className:"story-group-container",style:{width:"100vw",position:"relative",left:"50%",right:"50%",marginLeft:"-50vw",marginRight:"-50vw",boxSizing:"border-box"},children:[(0,Be.jsx)($n,{stories:t.details,viewedStories:n,onStoryClick:s}),o!==null&&(0,Be.jsx)(ui,{stories:t.details,activeStoryIndex:o,dataId:t.id,viewedStories:n,setViewedStories:r,onNextStory:a,onPrevStory:c,onClose:()=>i(null)})]})};var kt=require("react"),fi=require("react-dom");et();var te=require("react");function Ae(t,e=.5){let o=(0,te.useRef)(t),i=(0,te.useRef)(!1),n=(0,te.useRef)(null),r=(0,te.useRef)(null);(0,te.useEffect)(()=>{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(0,te.useEffect)(()=>()=>{r.current?.disconnect()},[]),s}var Lt=require("react/jsx-runtime"),mi=({position:t})=>{let e=ct("WID",{position:t}),o=F(A=>A.campaigns),i=F(A=>A.allCampaigns),n=F(A=>A.currentScreen),r=A=>(A||"").trim().toLowerCase(),s=e??(()=>{let A=r(n),_=[...o||[],...i||[]].find(C=>{let S=C;if(S.campaign_type!=="WID"||t&&S.position!==t)return!1;let W=!!(S.trigger_event??S.trigger),P=S.display_trigger!==!1&&!W,M=!r(S.screen)||r(S.screen)===A;return P&&M});if(_)try{return Ct(_)}catch{return _}})(),[a,c]=(0,kt.useState)(0),u=(0,kt.useRef)(null),x=(0,kt.useRef)(null),m=s?.details||{},g=m.widget_images||[],v=m.styling||{},f=m.type||"full",b=f==="half",h=(0,kt.useRef)([]),y=(0,kt.useRef)(!1),w=(0,kt.useCallback)(()=>{y.current=!0;let A=g[a];A?.id&&B(A.id)},[g,a]),I=Ae(w),B=A=>{!s?.id||!A||y.current&&(h.current.includes(A)||(h.current.push(A),H("viewed",s.id,{widget_image:A})))};(0,kt.useEffect)(()=>{if(f==="full"&&g.length>1)return x.current=setInterval(()=>{c(A=>{let _=A+1;return _>=g.length?0:_})},5e3),()=>{x.current&&clearInterval(x.current)}},[f,g.length]);let R=(A,_)=>{if(s?.id&&H("clicked",s.id,{widget_image:A}),_){if(!_.startsWith("http")){try{if(vt(_))return}catch(C){console.warn("[Widget] revealCampaignFromLink error",C)}console.log("[Widget] Internal link:",_);return}window.open(_,"_blank")}},d=()=>{if(u.current&&b){let{scrollLeft:A,offsetWidth:_}=u.current,C=_/2+12,S=Math.round(A/C);c(S)}};(0,kt.useEffect)(()=>{if(!s?.id||f!=="full"||g.length===0)return;let A=g[a];A&&A.id&&B(A.id)},[a,s?.id,g,f]),(0,kt.useEffect)(()=>{if(!s?.id||!u.current||!b)return;let A=u.current,_=()=>{let{scrollLeft:C,offsetWidth:S}=A,W=S/2+12;g.forEach((P,M)=>{let $=M*W,k=$+W,L=C,j=C+S;Math.max(0,Math.min(k,j)-Math.max($,L))/W>=.5&&B(P.id)})};return _(),A.addEventListener("scroll",_),()=>A.removeEventListener("scroll",_)},[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=A=>({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=(0,Lt.jsxs)("div",{style:{width:"100%",position:"relative"},children:[(0,Lt.jsx)("style",{children:`
124
+ `}),(0,W.jsxs)("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:[(0,W.jsx)("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"}),(0,W.jsx)("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:q})=>(0,W.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"14px",justifyContent:"flex-start"},children:[(0,W.jsx)("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}),(0,W.jsx)("span",{style:{fontSize:"13px",color:"#E5E7EB",fontWeight:"500",textAlign:"left"},children:q})]},F))})]})]})]}),(0,W.jsx)(Ot,{config:{enabled:te?.enabled??!0,image:"",color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:44},onPress:c,style:{position:"relative",borderRadius:"12px"}})]})]})]}),(0,W.jsx)("div",{style:{flex:1,width:"100%",display:"flex",flexDirection:"column",justifyContent:U?"flex-start":"center",alignItems:"center",paddingTop:U?"14px":"0px",...ko()},children:(0,W.jsxs)("div",{style:{display:U?"grid":"flex",gridTemplateColumns:U?`minmax(0, 1fr) ${It}px minmax(0, 1fr)`:"none",alignItems:"center",justifyContent:"center",gap:"12px",width:"100%",maxWidth:"1400px",position:"relative"},onClick:F=>U&&F.stopPropagation(),children:[U&&(0,W.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(p>0||e>0)&&(0,W.jsx)("button",{onClick:wo,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:(0,W.jsx)("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,W.jsx)("polyline",{points:"15 18 9 12 15 6"})})})}),U?(0,W.jsx)("div",{style:{width:`${It}px`,height:`${Zt}px`,position:"relative",zIndex:5,overflow:"visible"},children:Array.from(Et).sort((F,q)=>F-q).map(F=>{let q=d.slides[F];if(!q)return null;let ft=oo(F),$t=As(ft,It),Ft=q?.styling,Ee=Ft?.editorSource||Ft?.meta?.editorSource,ue=Ee==="studio"||Ee==="editor",no=Ft?.background?.media?.mediaUrl||q?.image,He=I(q),Ro=Ct(Ft?.background)||"#000000",re=ue?q?.content?.button_text:q?.button_text,Ve=ue?q?.content?.link:q?.link,ve=Ft?.background?.media?.sizing||Ft?.background?.sizing||Ft?.media?.sizing||q?.sizing,Ue=ve==="fill"?"cover":ve==="fit"?"contain":ve==="stretch"?"fill":ue?"contain":"cover",pe=Ft?.background?.media?.position||Ft?.background?.position||Ft?.media?.position||q?.content?.background?.media?.position||q?.content?.media?.position||q?.position,Jt=uo(pe),Fo=F===p&&!T||T&&F===V,gn={display:"flex",justifyContent:"center",alignItems:"center",background:ue?Ro:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"16px"};return(0,W.jsxs)("div",{style:{...qt,position:"absolute",top:0,left:0,width:`${It}px`,height:`${Zt}px`,...$t,transition:ft==="hidden"||ft==="far-left"||ft==="far-right"?`opacity ${We}ms ease, transform ${We}ms ease`:F===B?`transform ${We}ms ${Hn}, opacity ${We}ms ${Hn}, filter ${We}ms ${Hn}`:`transform ${We}ms ${Vn}, opacity ${We}ms ${Vn}, filter ${We}ms ${Vn}`,transformOrigin:"center center",willChange:"transform, opacity, filter"},onClick:we=>we.stopPropagation(),children:[(0,W.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:ie,onMouseUp:()=>Se("prev"),onTouchStart:ie,onTouchEnd:()=>Se("prev")}),(0,W.jsx)("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:ie,onMouseUp:()=>Se("next"),onTouchStart:ie,onTouchEnd:()=>Se("next")}),(0,W.jsxs)("div",{style:gn,children:[He?(0,W.jsx)(gr,{src:He,isActive:Fo,isAnimating:T,isMuted:h,onLoadedData:Be,activeVideoRef:H,objectFit:Ue,objectPosition:Jt}):no||!ue&&d?.thumbnail?(0,W.jsx)(ke,{src:no||d?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:Ue,objectPosition:Jt}}):null,(0,W.jsx)(On,{content:{...q.content,lottie:q.content?.lottie||q?.lottie||q.styling?.lottie,video:q.content?.video||q?.videoOverlay||q.styling?.video,image:q.content?.image||q?.imageOverlay||q.styling?.image,canva:nn(q),editorSource:q.content?.editorSource||q.editorSource||q.styling?.editorSource||q.meta?.editorSource,styling:{...q.content?.styling,...q?.styling},interactions:q.interactions},elapsedTime:Fo?u/100*(d.styling?.slideShowTime||5):0,onInteraction:async we=>{Fo&&gt(we,q)}})]}),(re||Ve)&&(0,W.jsx)(jn,{cta:q?.styling?.cta,buttonText:re||"Learn More",onPress:we=>{we&&we.stopPropagation&&we.stopPropagation(),X(q)}})]},q.id||F)})}):(0,W.jsx)("div",{style:{width:"100vw",height:"100dvh",maxWidth:"100vw",maxHeight:"100dvh",overflow:"hidden",position:"relative",zIndex:5,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",backgroundColor:"#000000"},children:d.slides.map((F,q)=>{if(Math.abs(q-p)>1)return(0,W.jsx)("div",{style:{display:"none"}},F.id||q);let ft=F?.styling,$t=ft?.editorSource||ft?.meta?.editorSource,Ft=$t==="studio"||$t==="editor",Ee=ft?.background?.media?.mediaUrl||F?.image,ue=F?.video||(Ft?F?.content?.video?.[0]?.link:void 0),no=Ct(ft?.background)||"#000000",He=Ft?F?.content?.button_text:F?.button_text,Ro=Ft?F?.content?.link:F?.link,re=ft?.background?.media?.sizing||ft?.background?.sizing||ft?.media?.sizing||F?.sizing,Ve=re==="fill"?"cover":re==="fit"?"contain":re==="stretch"?"fill":Ft?"contain":"cover",ve=ft?.background?.media?.position||ft?.background?.position||ft?.media?.position||F?.content?.background?.media?.position||F?.content?.media?.position||F?.position,Ue=uo(ve),pe=q===p;return pe?(0,W.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:(0,W.jsxs)("div",{style:{...qt},onClick:Jt=>Jt.stopPropagation(),children:[(0,W.jsx)("div",{style:{position:"absolute",top:"calc(10px + env(safe-area-inset-top, 0px))",left:"10px",right:"10px",display:"flex",gap:"4px",padding:"0 4px",zIndex:10},children:d.slides.map((Jt,Ye)=>{let pn=Ye<p?"100%":Ye===p?`${u}%`:"0%";return(0,W.jsx)("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.3)",borderRadius:"2px",overflow:"hidden"},children:(0,W.jsx)("div",{style:{width:pn,height:"100%",backgroundColor:"white",transition:Ye===p&&u>0&&!T?"width 0.1s linear":"none"}})},Ye)})}),(0,W.jsxs)("div",{style:{position:"absolute",top:"calc(22px + env(safe-area-inset-top, 0px))",left:"10px",right:"10px",display:"flex",alignItems:"center",justifyContent:"space-between",zIndex:10,padding:"5px"},children:[(0,W.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,W.jsx)(ke,{src:d.thumbnail,alt:d.name,style:{width:"32px",height:"32px",borderRadius:"50%"}}),(0,W.jsx)("span",{style:{color:"white",fontWeight:"bold",fontSize:"14px",textShadow:"0 1px 3px rgba(0,0,0,0.8)"},children:d.name})]}),(0,W.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,W.jsx)(qn,{config:{enabled:d?.styling?.share?.enabled??!0,image:d?.styling?.share?.image??"",color:{cross:d?.styling?.share?.color?.cross??"#ffffff",fill:d?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:d?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:d?.styling?.share?.size??32},onPress:Oo,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"10px",width:"32px",height:"32px"}}),(0,W.jsx)(Me,{config:{size:(h?pt?.mute?.size:pt?.unmute?.size)||32,color:{cross:(h?pt?.mute?.color?.cross:pt?.unmute?.color?.cross)||"#ffffff",fill:(h?pt?.mute?.color?.fill:pt?.unmute?.color?.fill)||"rgba(255,255,255,0.08)",stroke:(h?pt?.mute?.color?.stroke:pt?.unmute?.color?.stroke)||"transparent"},margin:(h?pt?.mute?.margin:pt?.unmute?.margin)||{top:0,bottom:0,left:0,right:0},image:(h?pt?.mute?.image:pt?.unmute?.image)||""},onPress:Bt,type:h?"mute":"unmute",enabled:!!pt?.enabled&&!!ue,style:{position:"relative",borderRadius:"10px"}}),(0,W.jsx)(Ot,{config:{enabled:te?.enabled!==!1,image:"",color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:32},onPress:c,style:{position:"relative",borderRadius:"10px"}})]})]}),(0,W.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:ie,onMouseUp:()=>Se("prev"),onTouchStart:ie,onTouchEnd:()=>Se("prev")}),(0,W.jsx)("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:ie,onMouseUp:()=>Se("next"),onTouchStart:ie,onTouchEnd:()=>Se("next")}),(0,W.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",background:Ft?no:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"0px"},children:[ue?(0,W.jsx)(gr,{src:ue,isActive:pe,isAnimating:T,isMuted:h,onLoadedData:Be,activeVideoRef:H,objectFit:Ve,objectPosition:Ue}):(Ee||!Ft&&d?.thumbnail)&&(0,W.jsx)(ke,{src:Ee||d?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:Ve,objectPosition:Ue}}),(0,W.jsx)(On,{content:{...F.content,canva:nn(F),editorSource:F.content?.editorSource||F.editorSource||F.styling?.editorSource||F.meta?.editorSource,styling:{...F.content?.styling,...F?.styling},interactions:F.interactions},elapsedTime:u/100*(d.styling?.slideShowTime||5),onInteraction:async Jt=>{gt(Jt,F)}})]}),(He||Ro)&&(0,W.jsx)(jn,{cta:F?.styling?.cta,buttonText:He||"Learn More",onPress:Jt=>{Jt&&Jt.stopPropagation&&Jt.stopPropagation(),X(F)}})]})},F.id||q):null})}),U&&(0,W.jsx)("div",{style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(0,W.jsx)("button",{onClick:Ie,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:(0,W.jsx)("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,W.jsx)("polyline",{points:"9 18 15 12 9 6"})})})})]})}),U&&e>0&&(0,W.jsxs)("div",{style:{position:"absolute",bottom:"36px",left:"24px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"6px",zIndex:20},children:[(0,W.jsx)("span",{style:{fontSize:"11px",fontWeight:"600",color:"rgba(255,255,255,0.65)",letterSpacing:"0.6px",textTransform:"uppercase",paddingLeft:"2px"},children:"Previous Stories"}),(0,W.jsxs)("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:()=>xe("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:[(0,W.jsx)("span",{style:{color:"white",fontSize:"14px",display:"flex"},children:"\u2190"}),(0,W.jsx)("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:(0,W.jsx)(ke,{src:t[e-1].thumbnail,style:{width:"100%",height:"100%",borderRadius:"50%"}})}),(0,W.jsx)("span",{style:{fontSize:"13px",color:"white",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e-1].name})]})]}),U&&e<t.length-1&&(0,W.jsxs)("div",{style:{position:"absolute",bottom:"36px",right:"24px",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"6px",zIndex:20},children:[(0,W.jsx)("span",{style:{fontSize:"11px",fontWeight:"600",color:"rgba(255,255,255,0.65)",letterSpacing:"0.6px",textTransform:"uppercase",paddingRight:"2px"},children:"Next Stories"}),(0,W.jsxs)("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:()=>xe("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:[(0,W.jsx)("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:(0,W.jsx)(ke,{src:t[e+1].thumbnail,style:{width:"100%",height:"100%",borderRadius:"50%"}})}),(0,W.jsx)("span",{style:{fontSize:"13px",color:"white",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e+1].name}),(0,W.jsx)("span",{style:{color:"white",fontSize:"14px",display:"flex"},children:"\u2192"})]})]}),v&&(0,W.jsx)("div",{style:{position:"absolute",bottom:"40px",left:"50%",transform:"translateX(-50%)",background:"rgba(20, 20, 20, 0.96)",border:"1px solid rgba(255,255,255,0.08)",padding:"12px 24px",borderRadius:"12px",color:"white",fontSize:"13px",fontWeight:"500",boxShadow:"0 10px 20px rgba(0,0,0,0.5)",backdropFilter:"blur(10px)",zIndex:1e3},children:v})]})};var Po=require("react/jsx-runtime"),yr=()=>{let t=Mt("STR"),e=P(p=>p.isVisible),[o,n]=(0,$e.useState)(()=>{try{let p=sessionStorage.getItem("appstorys_active_story_index");if(p!==null){let y=parseInt(p,10);if(!isNaN(y)&&y>=0)return y}}catch{}return null}),[i,s]=(0,$e.useState)([]);(0,$e.useEffect)(()=>{try{o!==null?sessionStorage.setItem("appstorys_active_story_index",String(o)):sessionStorage.removeItem("appstorys_active_story_index")}catch{}},[o]),(0,$e.useEffect)(()=>{try{let p=localStorage.getItem("app_storys_viewed_stories");p&&s(JSON.parse(p))}catch(p){console.error("Failed to load viewed stories:",p)}},[]),(0,$e.useEffect)(()=>{t&&t.details&&st("story_module_viewed",t.id)},[t]);let l=$e.default.useMemo(()=>!t||!t.details?[]:bn(t.details),[t?.details]);if(!t||!l||l.length===0||!e)return null;let c=p=>{n(p)},d=()=>{o!==null&&(o<l.length-1?n(o+1):n(null))},S=()=>{o!==null&&o>0&&n(o-1)};return(0,Po.jsxs)("div",{className:"story-group-container",style:{width:"100vw",position:"relative",left:"50%",right:"50%",marginLeft:"-50vw",marginRight:"-50vw",boxSizing:"border-box"},children:[(0,Po.jsx)(_i,{stories:l,viewedStories:i,onStoryClick:c}),o!==null&&(0,Po.jsx)(mr,{stories:l,activeStoryIndex:o,dataId:t.id,viewedStories:i,setViewedStories:s,onNextStory:d,onPrevStory:S,onClose:()=>n(null)})]})};var ne=require("react"),xr=require("react-dom");bt();var je=require("react");function Do(t,e=.5){let o=(0,je.useRef)(t),n=(0,je.useRef)(!1),i=(0,je.useRef)(null),s=(0,je.useRef)(null);(0,je.useEffect)(()=>{o.current=t},[t]);let l=c=>{if(s.current&&(s.current.disconnect(),s.current=null),i.current=c,n.current=!1,!c)return;if(typeof IntersectionObserver>"u"){o.current();return}let d=null;s.current=new IntersectionObserver(S=>{S[0].isIntersecting&&!n.current?d||(d=setTimeout(()=>{n.current=!0,o.current(),s.current?.disconnect(),d=null},500)):d&&(clearTimeout(d),d=null)},{threshold:e}),s.current.observe(c)};return(0,je.useEffect)(()=>()=>{s.current?.disconnect()},[]),l}var hr=new Set;function _s(){try{return globalThis?.process?.env?.NODE_ENV!=="production"}catch{return!0}}function br(t,e,o){if(!_s()||o<=1)return;let n=`${e}::${t}`;hr.has(n)||(hr.add(n),console.warn(`AppStorys: Found ${o} elements matching target "${t}" (selector "${e}"). The first one in document order will be used. Target identifiers should be unique per screen.`))}function rn(t){if(!t)return null;let e=[`[data-as-id="${t}"]`,`[data-id="${t}"]`,`[data-widget="${t}"]`];for(let n of e)try{let i=document.querySelectorAll(n);if(i.length>0)return br(t,n,i.length),i[0]}catch{}let o=document.getElementById(t);if(o)return o;try{let n=`.${CSS&&CSS.escape?CSS.escape(t):t}`,i=document.querySelectorAll(n);if(i.length>0)return br(t,n,i.length),i[0]}catch{}return null}var ye=require("react/jsx-runtime"),Sr=({position:t})=>{let e=Mt("WID",{position:t}),o=P(A=>A.campaigns),n=P(A=>A.allCampaigns),i=P(A=>A.currentScreen),s=A=>(A||"").trim().toLowerCase(),l=e??(()=>{let A=s(i),T=[...o||[],...n||[]].find(k=>{let B=k;if(B.campaign_type!=="WID"||t&&B.position!==t)return!1;let $=!!(B.trigger_event??B.trigger),V=B.display_trigger!==!1&&!$,G=!s(B.screen)||s(B.screen)===A;return V&&G});if(T)try{return Ht(T)}catch{return T}})(),[c,d]=(0,ne.useState)(0),S=(0,ne.useRef)(null),p=(0,ne.useRef)(null),y=l?.details||{},u=y.widget_images||[],C=y.styling||{},h=y.type||"full",g=h==="half",b=(0,ne.useRef)([]),m=(0,ne.useRef)(!1),E=(0,ne.useCallback)(()=>{m.current=!0;let A=u[c];A?.id&&D(A.id)},[u,c]),j=Do(E),D=A=>{!l?.id||!A||m.current&&(b.current.includes(A)||(b.current.push(A),st("viewed",l.id,{widget_image:A})))};(0,ne.useEffect)(()=>{if(h==="full"&&u.length>1)return p.current=setInterval(()=>{d(A=>{let T=A+1;return T>=u.length?0:T})},5e3),()=>{p.current&&clearInterval(p.current)}},[h,u.length]);let L=(A,T)=>{let k=(T||"").trim();if(k){if(l?.id&&st("clicked",l.id,{widget_image:A}),!k.startsWith("http")){try{if(Nt(k))return}catch(B){console.warn("[Widget] revealCampaignFromLink error",B)}console.log("[Widget] Internal link:",k);return}window.open(k,"_blank")}},v=()=>{if(S.current&&g){let{scrollLeft:A,offsetWidth:T}=S.current,k=T/2+12,B=Math.round(A/k);d(B)}};(0,ne.useEffect)(()=>{if(!l?.id||h!=="full"||u.length===0)return;let A=u[c];A&&A.id&&D(A.id)},[c,l?.id,u,h]),(0,ne.useEffect)(()=>{if(!l?.id||!S.current||!g)return;let A=S.current,T=()=>{let{scrollLeft:k,offsetWidth:B}=A,$=B/2+12;u.forEach((V,G)=>{let r=G*$,M=r+$,a=k,f=k+B;Math.max(0,Math.min(M,f)-Math.max(r,a))/$>=.5&&D(V.id)})};return T(),A.addEventListener("scroll",T),()=>A.removeEventListener("scroll",T)},[l?.id,g,u]);let w={display:"flex",flexDirection:"row",flexWrap:g?"nowrap":"wrap",gap:"12px",width:"100%",height:g&&y.height?`${y.height}px`:"auto",marginTop:C.topMargin?`${C.topMargin}px`:"0px",marginBottom:C.bottomMargin?`${C.bottomMargin}px`:"0px",marginLeft:C.leftMargin?`${C.leftMargin}px`:"0px",marginRight:C.rightMargin?`${C.rightMargin}px`:"0px",boxSizing:"border-box",overflowX:g?"auto":"hidden",overflowY:"hidden",scrollSnapType:g?"x mandatory":void 0,msOverflowStyle:"none",scrollbarWidth:"none"},_=A=>({flex:g?"0 0 calc(50% - 6px)":"0 0 100%",height:g&&y.height?`${y.height}px`:"auto",cursor:"pointer",position:"relative",overflow:"hidden",borderRadius:C.borderRadius?`${C.borderRadius}px`:"0px",borderTopLeftRadius:C.topLeftRadius?`${C.topLeftRadius}px`:void 0,borderTopRightRadius:C.topRightRadius?`${C.topRightRadius}px`:void 0,borderBottomLeftRadius:C.bottomLeftRadius?`${C.bottomLeftRadius}px`:void 0,borderBottomRightRadius:C.bottomRightRadius?`${C.bottomRightRadius}px`:void 0,boxShadow:"0 4px 12px rgba(0,0,0,0.08)",scrollSnapAlign:"start"}),N=(0,ye.jsxs)("div",{style:{width:"100%",position:"relative"},children:[(0,ye.jsx)("style",{children:`
78
125
  .widget-scroll-container::-webkit-scrollbar {
79
126
  display: none;
80
127
  }
81
- `}),(0,Lt.jsx)("div",{ref:A=>{u.current=A,I(A)},className:"widget-scroll-container",style:T,onScroll:d,children:b?g.map((A,_)=>(0,Lt.jsx)("div",{style:l(_),children:(0,Lt.jsx)("img",{src:A.image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"},onClick:()=>R(A.id,A.link)})},A.id)):g.length>0&&(0,Lt.jsx)("div",{style:l(0),children:(0,Lt.jsx)("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&&(0,Lt.jsx)("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"8px",width:"100%"},children:g.map((A,_)=>(0,Lt.jsx)("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:_===a?"#333":"#ccc",transition:"background-color 0.2s ease"}},_))})]}),O=null;if(s?.position){let A=String(s.position||"").replace(/^widget_/,""),_=[`[data-as-id="${A}"]`,`#${A}`,`.${A}`,`[data-widget="${A}"]`];for(let C of _)try{let S=document.querySelector(C);if(S){O=S,console.log("[Widget] Portal target found:",C,"for campaign",s?.id);break}}catch{}O||console.log("[Widget] No portal target found for position:",s?.position,"rendering inline for campaign:",s?.id)}return O?(0,fi.createPortal)(p,O):p};var pt=require("react");et();var zt=require("react/jsx-runtime"),Qo=t=>(t||"").trim().toLowerCase(),xr=()=>{let t=ct("TTP"),e=F(Y=>Y.campaigns),o=F(Y=>Y.allCampaigns),i=F(Y=>Y.currentScreen),n=F(Y=>Y.isVisible),[r,s]=(0,pt.useState)(0),[a,c]=(0,pt.useState)(!1),[u,x]=(0,pt.useState)(null),[m,g]=(0,pt.useState)({width:0,height:0}),v=(0,pt.useRef)(null),f=(0,pt.useRef)(null),b=(0,pt.useMemo)(()=>{if(t)return t;let Y=Qo(i),nt=U=>U.find(G=>{let Q=G,at=Q.campaign_type==="TTP"||Q.campaign_type==="TLTP",St=!Qo(Q.screen)||Qo(Q.screen)===Y,rt=!!(Q.trigger_event??Q.trigger),Bt=Q.display_trigger!==!1&&!rt;return at&&St&&Bt});return nt(e)??nt(o)},[t,e,o,i]),h=(0,pt.useMemo)(()=>b?.details?.tooltips&&Array.isArray(b.details.tooltips)?[...b.details.tooltips].sort((Y,nt)=>(Y.order??0)-(nt.order??0)):b?.details?.target||b?.details?.titleText?[{...b.details,_id:b.id}]:[],[b]),y=h[r];(0,pt.useEffect)(()=>{},[b]);let w=(0,pt.useRef)(new Set),I=(0,pt.useCallback)(()=>{if(!(!b||!y||a||!n))try{let Y=y._id||y.id||void 0,nt=String(b.id||"")+"::"+String(Y||"");w.current.has(nt)||(w.current.add(nt),H("viewed",b.id,{tooltip_id:Y}))}catch{}},[b,y,a,n]),B=Ae(I);if((0,pt.useEffect)(()=>{if(!y?.target||a)return;x(null);let Y=(G=!1)=>{let Q=y.target;if(!Q)return null;let at=document.getElementById(Q)||document.querySelector(`[data-id="${Q}"]`)||document.querySelector(`.${Q}`);return at?(x(at.getBoundingClientRect()),G&&at.scrollIntoView({behavior:"smooth",block:"center"}),at):null};Y(!0)||(f.current=new MutationObserver(()=>{Y(!0)&&f.current?.disconnect()}),f.current.observe(document.body,{childList:!0,subtree:!0}));let U=()=>{let G=Y(!1);G&&x(G.getBoundingClientRect())};return window.addEventListener("resize",U),window.addEventListener("scroll",U,{passive:!0}),()=>{f.current?.disconnect(),window.removeEventListener("resize",U),window.removeEventListener("scroll",U)}},[y,a,r]),(0,pt.useLayoutEffect)(()=>{if(v.current&&u){let{width:Y,height:nt}=v.current.getBoundingClientRect();g({width:Y,height:nt})}},[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||{},O=l.cornerRadius||{},A=l.text||{},_=y.arrowPosition||"left",S=(d.arrowStyle||{width:6,height:12}).width||6,W=u.top+window.scrollY,P=u.left+window.scrollX,M=0,$=0,k=8;_==="left"?(M=P+u.width+k,$=W+u.height/2-m.height/2):_==="right"?(M=P-m.width-k,$=W+u.height/2-m.height/2):_==="top"?($=W+u.height+k,M=P+u.width/2-m.width/2):_==="bottom"&&($=W-m.height-k,M=P+u.width/2-m.width/2);let L=8,j=window.scrollY,X=window.scrollY+window.innerHeight,ft=window.scrollX,N=window.scrollX+window.innerWidth;m.height>0&&($=Math.max(j+L,Math.min(X-m.height-L,$))),m.width>0&&(M=Math.max(ft+L,Math.min(N-m.width-L,M)));let tt=()=>{let Y=y.clickAction||"nextStep",nt=y.link||y.url;try{let U=y._id||y.id||void 0;b?.id&&H("clicked",b.id,{tooltip_id:U})}catch{}if(Y==="close"){c(!0),nt&&window.open(nt,"_blank");return}r<h.length-1?s(U=>U+1):(c(!0),nt&&window.open(nt,"_blank"))},K=()=>{y.enableBackdrop&&c(!0)};return(0,zt.jsxs)(zt.Fragment,{children:[y.enableBackdrop&&(0,zt.jsx)("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:K}),(0,zt.jsxs)("div",{ref:Y=>{v.current=Y,B(Y)},style:{position:"absolute",top:$,left:M,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:[(0,zt.jsx)("div",{style:{position:"absolute",width:0,height:0,borderStyle:"solid",..._==="left"&&{left:-k,top:Math.max(12,Math.min(m.height-S*2-12,W+u.height/2-$-S)),borderWidth:`${S}px ${k}px ${S}px 0`,borderColor:`transparent ${T.tooltip||"#FE6B35"} transparent transparent`},..._==="right"&&{right:-k,top:Math.max(12,Math.min(m.height-S*2-12,W+u.height/2-$-S)),borderWidth:`${S}px 0 ${S}px ${k}px`,borderColor:`transparent transparent transparent ${T.tooltip||"#FE6B35"}`},..._==="top"&&{top:-k,left:Math.max(12,Math.min(m.width-S*2-12,P+u.width/2-M-S)),borderWidth:`0 ${S}px ${k}px ${S}px`,borderColor:`transparent transparent ${T.tooltip||"#FE6B35"} transparent`},..._==="bottom"&&{bottom:-k,left:Math.max(12,Math.min(m.width-S*2-12,P+u.width/2-M-S)),borderWidth:`${k}px ${S}px 0 ${S}px`,borderColor:`${T.tooltip||"#FE6B35"} transparent transparent transparent`}}}),y.titleText&&(0,zt.jsx)("div",{style:{color:R.title?.color||"#ffffff",fontFamily:dt(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&&(0,zt.jsx)("div",{style:{color:R.subTitle?.color||"#ffffff",fontFamily:dt(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&&(0,zt.jsx)("div",{style:{display:"flex",justifyContent:p.alignment==="right"?"flex-end":p.alignment==="left"?"flex-start":"center",marginTop:8},children:(0,zt.jsx)("button",{onClick:tt,style:{width:p.ctaFullWidth?"100%":p.ctaWidth||"auto",height:p.height||35,background:p.backgroundColor||"#F7921C",color:A.color||"#ffffff",border:`${p.borderWidth||0}px solid ${p.borderColor||"transparent"}`,borderRadius:`${O.topLeft??7}px ${O.topRight??7}px ${O.bottomRight??7}px ${O.bottomLeft??7}px`,fontSize:A.fontSize||14,fontFamily:dt(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:y.ctaText})})]})]})},yi=xr;var eo=require("react");et();var gt=require("react/jsx-runtime"),hi=()=>{let t=ct("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 Ct(b)}catch{return b}})(),r=F(f=>f.isVisible),[s,a]=(0,eo.useState)(!1);(0,eo.useEffect)(()=>{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(0,gt.jsx)("div",{style:{textAlign:f.alignment||"left",width:"100%"},children:f.url&&(0,gt.jsx)("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")&&vt(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(0,gt.jsx)("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:(0,gt.jsx)("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:dt(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 B=f.ctaLink||f.url;if(B){n?.id&&H("clicked",n.id);try{let R=String(B||"").trim();if(R&&!R.startsWith("http")&&vt(R))return}catch(R){console.warn("revealCampaignFromLink error",R)}try{window.open(B,"_blank")}catch{}}},children:f.ctaText||"Button"})},f.id)}case"body":{let b=f.titleFontStyle||{},h=f.descriptionFontStyle||{};return(0,gt.jsxs)("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&&(0,gt.jsx)("div",{style:{color:b.colour||"#000000",fontSize:b.fontSize?`${b.fontSize}px`:f.titleFontSize?`${f.titleFontSize}px`:"16px",fontFamily:dt(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&&(0,gt.jsx)("div",{style:{color:h.colour||"#000000",fontSize:h.fontSize?`${h.fontSize}px`:f.descriptionFontSize?`${f.descriptionFontSize}px`:"14px",fontFamily:dt(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(0,gt.jsxs)(gt.Fragment,{children:[(0,gt.jsx)("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)}}),(0,gt.jsxs)("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:[(0,gt.jsx)("div",{style:{width:"40px",height:"5px",backgroundColor:"#E0E0E0",borderRadius:"2.5px",marginBottom:"16px",cursor:"pointer"},onClick:()=>a(!0)}),u.crossButton?.enabled&&(0,gt.jsx)(Qt,{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}}),(0,gt.jsx)("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:"12px"},children:m.map(v)})]})]})};var Dt=require("react");et();var V=require("react/jsx-runtime"),bi=5,Go=3;function Ht(t){if(t!=null)return`${t}px`}function Ee(t){return{marginTop:Ht(t?.top),marginRight:Ht(t?.right),marginBottom:Ht(t?.bottom),marginLeft:Ht(t?.left)}}function Ko(t){return dt(t)}function Se(t){return t?{color:t.color,fontSize:t.fontSize,fontFamily:Ko(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 Jo(t){return`${t?.topLeft??8}px ${t?.topRight??8}px ${t?.bottomRight??8}px ${t?.bottomLeft??8}px`}function Sr(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function Cr(t){let e=t.styling?.rating?.ratingType;return e==="number"||e==="emoji"||e==="star"?e:"star"}function vr(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 wr(t){return Array.from({length:5},(e,o)=>o+1)}function Xo(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 kr(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=Xo(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=Xo(s);if(a!=null)return a}}return 8}var Rr=({fill:t,stroke:e})=>(0,V.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":!0,children:(0,V.jsx)("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"})}),Tr=({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=Cr(t),w=y==="number"?wr(t):[],I=y==="emoji"?vr(t):[],B=y==="number"?kr(t):8,R=r?f.star?.high:f.star?.low;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)("div",{style:Ee(b.title?.margin),children:(0,V.jsx)("div",{style:{...Se(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?"})}),(0,V.jsx)("div",{style:Ee(b.subtitle?.margin),children:(0,V.jsx)("div",{style:{...Se(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."})}),(0,V.jsxs)("div",{style:{marginTop:8,display:"flex",justifyContent:"center",gap:y==="number"?B:8,flexWrap:"wrap"},children:[y==="star"&&Array.from({length:bi},(d,T)=>{let l=T+1,p=l<=o,O=p?R?.stylingContainer:f.star?.unselected?.stylingContainer,A=p?R?.stylingStar:f.star?.unselected?.stylingStar;return(0,V.jsx)("button",{onClick:()=>a(l),style:{border:`${O?.borderWidth??1}px solid ${O?.border||"#d1d5db"}`,background:O?.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 ${bi}`,children:(0,V.jsx)(Rr,{fill:A?.background||(p?"#f59e0b":"#e5e7eb"),stroke:A?.border||(p?"#d97706":"#9ca3af")})},l)}),y==="number"&&w.map((d,T)=>{let l=d===o;return(0,V.jsx)("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(0,V.jsx)("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&&(0,V.jsx)("div",{style:{marginTop:6,textAlign:"center",color:"#374151",fontSize:14},children:r?t.highStarText||f.highRatingSubtitle:t.lowStarText||f.lowRatingSubtitle}),o>0&&o<=Go&&(0,V.jsxs)(V.Fragment,{children:[s.length>0&&(0,V.jsx)("div",{style:{...Ee(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(0,V.jsx)("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:Jo(v.options?.cornerRadius),padding:"0 14px",cursor:"pointer",textAlign:"center",...Se(l?.textStyle)},children:d},d)})}),(0,V.jsx)("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",...Se(v.additionalComments?.textStyle)}}),(0,V.jsx)("div",{style:{position:"sticky",bottom:0,marginTop:8,paddingTop:6,paddingBottom:6,background:e?.backgroundColor||"#2f6ef5",display:"flex",justifyContent:"center"},children:(0,V.jsx)("button",{onClick:()=>x(),disabled:!m,style:{width:Math.max(140,Math.min(Xo(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:Jo(h?.cornerRadius),fontFamily:Ko(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"})})]})]})},Fr=({details:t,isHighRating:e,onDone:o})=>{let i=t.styling||{},n=i.thankyouPage||{},r=i.rating||{},s=Sr(n.doneButton?.cta?.container?.alignment);return(0,V.jsxs)(V.Fragment,{children:[t.thankyouImage&&(0,V.jsx)("div",{style:{display:"flex",justifyContent:"center",marginTop:6},children:(0,V.jsx)("img",{src:t.thankyouImage,alt:"thank you",style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80,objectFit:"cover",borderRadius:8}})}),(0,V.jsx)("div",{style:{...Ee(n.title?.margin),textAlign:"center"},children:(0,V.jsx)("div",{style:{...Se(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"})}),(0,V.jsx)("div",{style:{...Ee(n.subtitle?.margin),textAlign:"center"},children:(0,V.jsx)("div",{style:{...Se(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."})}),(0,V.jsx)("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:(0,V.jsx)("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:Jo(n.doneButton?.cta?.cornerRadius),fontFamily:Ko(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")})})]})},Ir=()=>{let t=ct("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(W=>{if(!W||W.campaign_type!=="CSAT")return!1;let P=!!(W.trigger_event??W.trigger);if(!(W.display_trigger!==!1&&!P))return!1;let $=(W.screen||"").trim().toLowerCase();return!$||$===C});if(S)try{return Ct(S)}catch{return S}})(),[s,a]=(0,Dt.useState)(!1),[c,u]=(0,Dt.useState)(!1),[x,m]=(0,Dt.useState)(0),[g,v]=(0,Dt.useState)([]),[f,b]=(0,Dt.useState)(""),[h,y]=(0,Dt.useState)(!1);(0,Dt.useEffect)(()=>{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=(0,Dt.useMemo)(()=>{let C=r?.details?.feedback_option||{};return Object.keys(C).sort((S,W)=>S.localeCompare(W)).map(S=>C[S]).filter(Boolean)},[r]);if(!r||!e||s||!c)return null;let I=r.details,B=I.styling||{},R=B.appearance||{},d=x>Go,T=Number(I.width??80),l=Math.max(660,Math.min(1080,T*10)),p=C=>{v(S=>S.includes(C)?S.filter(W=>W!==C):[...S,C])},O=async C=>{let S=C?.rating??x;if(S<1)return;y(!0);let W=I.id||r.id,P=(C?.options??g)[0]||"",M=C?.comments??f??"";H("csat captured",W,{starCount:S,selectedOption:P,additionalComments:M})},A=C=>{if(m(C),C>Go){v([]),b("");let S=I.id||r?.id;setTimeout(()=>{y(!0);try{H("csat captured",S,{starCount:C,selectedOption:"",additionalComments:""})}catch(W){console.warn("Error sending csat captured",W)}},1e3)}},_=()=>{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")&&vt(S)){a(!0);return}}catch(S){console.warn("revealCampaignFromLink error",S)}try{globalThis.open(I.link,"_blank")}catch{}}a(!0)};return(0,V.jsx)("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:(0,V.jsxs)("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:Ht(R.padding?.right)||"12px",paddingBottom:"4px",paddingLeft:Ht(R.padding?.left)||"12px",marginTop:Ht(R.margin?.top),marginRight:Ht(R.margin?.right),marginBottom:Ht(R.margin?.bottom),marginLeft:Ht(R.margin?.left),pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"},children:[(0,V.jsx)("style",{children:`
128
+ `}),(0,ye.jsx)("div",{ref:A=>{S.current=A,j(A)},className:"widget-scroll-container",style:w,onScroll:v,children:g?u.map((A,T)=>(0,ye.jsx)("div",{style:_(T),children:(0,ye.jsx)("img",{src:A.image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block",cursor:(A.link||"").trim()?"pointer":"default"},onClick:()=>L(A.id,A.link)})},A.id)):u.length>0&&(0,ye.jsx)("div",{style:_(0),children:(0,ye.jsx)("img",{src:u[c].image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block",cursor:(u[c].link||"").trim()?"pointer":"default"},onClick:()=>L(u[c].id,u[c].link)})},`slide-${c}`)}),h==="full"&&u.length>1&&(0,ye.jsx)("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"8px",width:"100%"},children:u.map((A,T)=>(0,ye.jsx)("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:T===c?"#333":"#ccc",transition:"background-color 0.2s ease"}},T))})]}),U=null;if(l?.position){let A=String(l.position||"").replace(/^widget_/,"");U=rn(A),U?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 U?(0,xr.createPortal)(N,U):N};var Rt=require("react");bt();var _t=require("react/jsx-runtime"),Yn=t=>(t||"").trim().toLowerCase(),Ws=t=>{if(t==null)return"8px 8px 8px 8px";if(typeof t=="number")return`${t}px`;if(typeof t=="object"){let e=t.top??8,o=t.right??8,n=t.bottom??8,i=t.left??8;return`${e}px ${o}px ${n}px ${i}px`}return String(t)},$s=(t,e)=>{if(typeof t=="number")return`${t}px`;if(typeof e=="number")return`${e}px`;if(typeof t=="object"&&t!==null){let o=t.topLeft??12,n=t.topRight??12,i=t.bottomRight??12,s=t.bottomLeft??12;return`${o}px ${n}px ${i}px ${s}px`}return"12px"},Ns=()=>{let t=Mt("TTP"),e=P(X=>X.campaigns),o=P(X=>X.allCampaigns),n=P(X=>X.currentScreen),i=P(X=>X.isVisible),[s,l]=(0,Rt.useState)(0),[c,d]=(0,Rt.useState)(!1),[S,p]=(0,Rt.useState)(null),[y,u]=(0,Rt.useState)(null),[C,h]=(0,Rt.useState)({width:0,height:0}),[g,b]=(0,Rt.useState)(!1),m=(0,Rt.useRef)(null),E=(0,Rt.useRef)(null),j=(0,Rt.useRef)(null),D=(0,Rt.useCallback)(X=>{if(X)try{document.body.style.overflow="",document.documentElement.style.overflow="",X.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}catch{try{X.scrollIntoView()}catch{}}},[]),L=(0,Rt.useMemo)(()=>{if(t)return t;let X=Yn(n),gt=Bt=>Bt.find(te=>{let pt=te,Ce=pt.campaign_type==="TTP"||pt.campaign_type==="TLTP",oo=!Yn(pt.screen)||Yn(pt.screen)===X,qe=!!(pt.trigger_event??pt.trigger),qt=pt.display_trigger!==!1&&!qe;return Ce&&oo&&qt});return gt(e)??gt(o)},[t,e,o,n]);(0,Rt.useEffect)(()=>{b(!1)},[s,L?.id]);let v=(0,Rt.useMemo)(()=>L?.details?.tooltips&&Array.isArray(L.details.tooltips)?[...L.details.tooltips].sort((X,gt)=>(X.order??0)-(gt.order??0)):L?.details?.target||L?.details?.titleText?[{...L.details,_id:L.id}]:[],[L]),w=v[s];(0,Rt.useEffect)(()=>{},[L]);let _=(0,Rt.useRef)(new Set),N=(0,Rt.useCallback)(()=>{if(!(!L||!w||c||!i))try{let X=w._id||w.id||void 0,gt=String(L.id||"")+"::"+String(X||"");_.current.has(gt)||(_.current.add(gt),st("viewed",L.id,{tooltip_id:X}))}catch{}},[L,w,c,i]),U=Do(N);(0,Rt.useEffect)(()=>{if(!w||c)return;p(null),u(null);let X=null,gt=null,Bt=()=>{let Gt=typeof window<"u"?document.documentElement.clientWidth||window.innerWidth:1024,Xt=typeof window<"u"?document.documentElement.clientHeight||window.innerHeight:768;return new DOMRect(Gt/2-100,Xt/2-50,200,100)},te=Gt=>{if(!Gt||!(Gt instanceof HTMLElement))return!1;let Xt=Gt.getBoundingClientRect();if(Xt.width===0||Xt.height===0)return!1;try{let Et=window.getComputedStyle(Gt);if(Et.display==="none"||Et.visibility==="hidden"||Et.opacity==="0")return!1}catch{}return!0},pt=(Gt=!1)=>{let Xt=w.target||w.targetId||w.elementId;if(!Xt)return p(Bt()),u(null),null;let Et=rn(Xt);if(Et){if(u(Et),te(Et)){let F=Et.getBoundingClientRect();Gt?(D(Et),p(F),setTimeout(()=>{D(Et),p(Et.getBoundingClientRect())},50),setTimeout(()=>{p(Et.getBoundingClientRect())},150),setTimeout(()=>{p(Et.getBoundingClientRect())},350)):p(F)}else p(null);return Et}return u(null),p(null),null},Ce=()=>{b(!0)},oo=Gt=>{j.current?.disconnect(),j.current=null,!(!Gt||typeof ResizeObserver>"u")&&(j.current=new ResizeObserver(()=>{te(Gt)?p(Gt.getBoundingClientRect()):p(null)}),j.current.observe(Gt))},qe=(Gt=!1)=>{let Xt=pt(Gt);Xt&&Xt!==X&&(X&&X.removeEventListener("click",Ce),X=Xt,Xt.addEventListener("click",Ce),oo(Xt))};qe(!0),E.current=new MutationObserver(()=>{qe(!1)}),E.current.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let qt=()=>qe(!1);return window.addEventListener("resize",qt),window.addEventListener("scroll",qt,{passive:!0,capture:!0}),document.addEventListener("mouseenter",qt,!0),document.addEventListener("mouseover",qt,!0),document.addEventListener("mouseleave",qt,!0),document.addEventListener("click",qt,!0),()=>{gt&&clearTimeout(gt),X&&X.removeEventListener("click",Ce),E.current?.disconnect(),j.current?.disconnect(),window.removeEventListener("resize",qt),window.removeEventListener("scroll",qt,{capture:!0}),document.removeEventListener("mouseenter",qt,!0),document.removeEventListener("mouseover",qt,!0),document.removeEventListener("mouseleave",qt,!0),document.removeEventListener("click",qt,!0)}},[w,c,s,D]),(0,Rt.useEffect)(()=>{if(!w||c||!S)return;let X=w?.enableBackdrop??w?.enable_backdrop??L?.details?.enableBackdrop??L?.details?.enable_backdrop;if(!(X!==!1&&X!=="false"&&X!==0))return;let Bt=te=>{let pt=te.target;pt&&(m.current&&m.current.contains(pt)||y&&(y===pt||y.contains(pt))||(b(!0),s<v.length-1?l(Ce=>Ce+1):d(!0)))};return window.addEventListener("click",Bt,!0),()=>{window.removeEventListener("click",Bt,!0)}},[w,c,S,y,s,v.length,L]),(0,Rt.useEffect)(()=>{if(!y||!(y instanceof HTMLElement)||c)return;let X=y,gt=()=>{b(!0)};return X.addEventListener("click",gt),()=>{X.removeEventListener("click",gt)}},[y,s,c]),(0,Rt.useLayoutEffect)(()=>{if(m.current&&S){let{width:X,height:gt}=m.current.getBoundingClientRect();h({width:X,height:gt})}},[w,S]);let A=(0,Rt.useMemo)(()=>{let X=w?.styling?.appearance?.highlight?.radius;if(X!=null)return`${X}px`;if(y&&typeof window<"u")try{let gt=window.getComputedStyle(y);if(gt.borderRadius&&gt.borderRadius!=="0px")return gt.borderRadius}catch{}return"6px"},[w?.styling?.appearance?.highlight?.radius,y]);if(!L||!w||c||!i||!S)return null;let T=w.styling||{},k=T.appearance||{},B=k.colors||{},$=T.cta||{},V=$.container||{},G=$.cornerRadius||{},r=$.text||{},M=!!(k.imageDimensions?.width&&k.imageDimensions?.height),a,f;if(M){let X=k.imageDimensions.width,gt=k.imageDimensions.height,Bt=typeof window<"u"?window.innerWidth*.9:X;a=Math.min(X,Bt),f=a===X?gt:Math.round(gt*(a/X))}let x=w.arrowPosition;!x&&w.position&&(w.position==="left"?x="right":w.position==="right"?x="left":w.position==="top"?x="bottom":w.position==="bottom"&&(x="top")),x||(x="left");let Y=(k.arrowStyle||{width:6,height:12}).width||6,ot=S.top,J=S.left,H=8,K=8,it=typeof window<"u"?document.documentElement.clientWidth||window.innerWidth:1024,xt=typeof window<"u"?document.documentElement.clientHeight||window.innerHeight:768,ut=C.width||M&&a||250,Z=C.height||(M?f||150:100),rt=S.top,dt=xt-(S.top+S.height),ht=S.left,mt=it-(S.left+S.width),R=ut+H+K,I=Z+H+K;x?x==="left"&&mt<R?ht>=R?x="right":rt>=I||rt>=dt?x="bottom":x="top":x==="right"&&ht<R?mt>=R?x="left":rt>=I||rt>=dt?x="bottom":x="top":x==="top"&&dt<I?rt>=I?x="bottom":mt>=R||mt>=ht?x="left":x="right":x==="bottom"&&rt<I&&(dt>=I?x="top":mt>=R||mt>=ht?x="left":x="right"):mt>=R?x="left":ht>=R?x="right":rt>=I?x="bottom":x="top";let O=0,tt=0;x==="left"?(O=J+S.width+H,tt=ot+S.height/2-Z/2):x==="right"?(O=J-ut-H,tt=ot+S.height/2-Z/2):x==="top"?(tt=ot+S.height+H,O=J+S.width/2-ut/2):x==="bottom"&&(tt=ot-Z-H,O=J+S.width/2-ut/2);let St=Math.min(ut,Math.max(120,it-K*2)),zt=Math.min(Z,Math.max(80,xt-K*2)),Tt=K,Yt=Math.max(Tt,it-St-K),Lt=K,Zt=Math.max(Lt,xt-zt-K),It=Math.max(Tt,Math.min(Yt,O)),ce=Math.max(Lt,Math.min(Zt,tt)),xe=w?.enableBackdrop??w?.enable_backdrop??L?.details?.enableBackdrop??L?.details?.enable_backdrop,Ie=xe!==!1&&xe!=="false"&&xe!==0,wo=k.backdropOpacity!==void 0?k.backdropOpacity>1?k.backdropOpacity/100:k.backdropOpacity:.7,ko=((X,gt)=>{if(!X||X==="transparent")return"transparent";if(X.startsWith("rgba"))return X;if(X.startsWith("rgb"))return X.replace("rgb","rgba").replace(")",`, ${gt})`);if(X.startsWith("#")){let Bt=X.slice(1);if(Bt.length===3&&(Bt=Bt.split("").map(te=>te+te).join("")),Bt.length===6){let te=parseInt(Bt.slice(0,2),16),pt=parseInt(Bt.slice(2,4),16),Ce=parseInt(Bt.slice(4,6),16);return`rgba(${te}, ${pt}, ${Ce}, ${gt})`}}return X})(B.backdrop||"#000000",wo),ie=()=>{b(!0);let X=w.link;try{let gt=w._id||w.id||void 0;L?.id&&st("clicked",L.id,{tooltip_id:gt})}catch{}s<v.length-1?(l(gt=>gt+1),X&&window.open(X,"_blank")):(d(!0),X&&window.open(X,"_blank"))},Se=()=>{b(!0),Ie&&(s<v.length-1?l(X=>X+1):d(!0))},Be=w?.styling?.appearance?.highlight?.radius??w?.styling?.appearance?.radius,Le=0;if(typeof Be=="number"&&Be>0)Le=Be;else if(typeof Be=="string"&&Be!=="")Le=parseInt(Be,10)||0;else if(y&&typeof window<"u")try{let X=y,gt=window.getComputedStyle(X);if(gt.borderRadius&&gt.borderRadius!=="0px")Le=parseFloat(gt.borderRadius)||0;else if(X.firstElementChild){let Bt=window.getComputedStyle(X.firstElementChild);Bt.borderRadius&&Bt.borderRadius!=="0px"&&(Le=parseFloat(Bt.borderRadius)||0)}}catch{}return(0,_t.jsxs)("div",{style:{position:"relative",zIndex:99999},children:[Ie&&S&&(0,_t.jsxs)("svg",{style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",pointerEvents:"none",zIndex:1e4},children:[(0,_t.jsx)("defs",{children:(0,_t.jsxs)("mask",{id:"as-spotlight-mask",children:[(0,_t.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:"white"}),(0,_t.jsx)("rect",{x:S.left,y:S.top,width:S.width,height:S.height,rx:Le,ry:Le,fill:"black"})]})}),(0,_t.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:ko,mask:"url(#as-spotlight-mask)",style:{pointerEvents:"none",cursor:"default"}})]}),Ie&&!S&&(0,_t.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:ko,zIndex:1e4},onClick:Se}),(0,_t.jsxs)("div",{ref:X=>{m.current=X,U(X)},style:{position:"fixed",top:ce,left:It,zIndex:99999,backgroundColor:B.tooltip||"#FE6B35",padding:M?0:Ws(k.padding),borderRadius:$s(k.cornerRadius,k.radius),boxShadow:"0 4px 12px rgba(0,0,0,0.15)",width:M?a:k.width?Math.min(k.width,it-K*2):"auto",height:M?f:void 0,maxWidth:Math.max(160,it-K*2),minWidth:M?void 0:Math.min(200,it-K*2),boxSizing:"border-box",transition:"top 0.2s ease, left 0.2s ease",cursor:"default"},children:[(0,_t.jsx)("div",{style:{position:"absolute",width:0,height:0,borderStyle:"solid",...x==="left"&&{left:-H,top:Math.max(12,Math.min(C.height-Y*2-12,ot+S.height/2-ce-Y)),borderWidth:`${Y}px ${H}px ${Y}px 0`,borderColor:`transparent ${B.arrow||B.tooltip||"#FE6B35"} transparent transparent`},...x==="right"&&{right:-H,top:Math.max(12,Math.min(C.height-Y*2-12,ot+S.height/2-ce-Y)),borderWidth:`${Y}px 0 ${Y}px ${H}px`,borderColor:`transparent transparent transparent ${B.arrow||B.tooltip||"#FE6B35"}`},...x==="top"&&{top:-H,left:Math.max(12,Math.min(C.width-Y*2-12,J+S.width/2-It-Y)),borderWidth:`0 ${Y}px ${H}px ${Y}px`,borderColor:`transparent transparent ${B.arrow||B.tooltip||"#FE6B35"} transparent`},...x==="bottom"&&{bottom:-H,left:Math.max(12,Math.min(C.width-Y*2-12,J+S.width/2-It-Y)),borderWidth:`${H}px ${Y}px 0 ${Y}px`,borderColor:`${B.arrow||B.tooltip||"#FE6B35"} transparent transparent transparent`}}}),w.url&&(M?(0,_t.jsx)("div",{onClick:ie,style:{width:"100%",height:"100%",overflow:"hidden",borderRadius:`${k.cornerRadius?.topLeft??12}px ${k.cornerRadius?.topRight??12}px ${k.cornerRadius?.bottomRight??12}px ${k.cornerRadius?.bottomLeft??12}px`,cursor:"pointer"},children:(0,_t.jsx)("img",{src:w.url,alt:"tooltip media",style:{width:"100%",height:"100%",display:"block",objectFit:"cover",cursor:"pointer"}})}):(0,_t.jsx)("img",{src:w.url,alt:"tooltip media",onClick:ie,style:{width:"100%",borderRadius:6,marginBottom:8,display:"block",objectFit:"cover",cursor:"pointer"}})),(w.titleText||w.subtitleText||w.ctaText)&&(0,_t.jsxs)("div",{style:M?{padding:`${k.padding?.top??8}px ${k.padding?.right??8}px ${k.padding?.bottom??8}px ${k.padding?.left??8}px`}:void 0,children:[w.titleText&&(0,_t.jsx)("div",{style:{color:T.title?.color||"#ffffff",fontFamily:lt(T.title?.fontFamily)||"Arial",fontSize:T.title?.fontSize||14,textAlign:T.title?.textAlign||"center",marginBottom:T.title?.margin?.bottom??4,marginTop:T.title?.margin?.top??0,marginLeft:T.title?.margin?.left??0,marginRight:T.title?.margin?.right??0,fontWeight:T.title?.fontDecoration?.includes("bold")?"bold":600,fontStyle:T.title?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:T.title?.fontDecoration?.includes("underline")?"underline":"none"},children:w.titleText}),w.subtitleText&&(0,_t.jsx)("div",{style:{color:T.subTitle?.color||"#ffffff",fontFamily:lt(T.subTitle?.fontFamily)||"Arial",fontSize:T.subTitle?.fontSize||12,textAlign:T.subTitle?.textAlign||"center",marginBottom:T.subTitle?.margin?.bottom??8,marginTop:T.subTitle?.margin?.top??0,marginLeft:T.subTitle?.margin?.left??0,marginRight:T.subTitle?.margin?.right??0,fontWeight:T.subTitle?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:T.subTitle?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:T.subTitle?.fontDecoration?.includes("underline")?"underline":"none"},children:w.subtitleText}),w.ctaText&&(0,_t.jsx)("div",{style:{display:"flex",justifyContent:V.alignment==="right"?"flex-end":V.alignment==="left"?"flex-start":"center",marginTop:8},children:(0,_t.jsx)("button",{onClick:ie,style:{width:V.ctaFullWidth?"100%":V.ctaWidth||"auto",height:V.height||35,background:V.backgroundColor||"#F7921C",color:r.color||"#ffffff",border:`${V.borderWidth||0}px solid ${V.borderColor||"transparent"}`,borderRadius:`${G.topLeft??7}px ${G.topRight??7}px ${G.bottomRight??7}px ${G.bottomLeft??7}px`,fontSize:r.fontSize||14,fontFamily:lt(r.fontFamily)||"Arial",fontWeight:r.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:r.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:r.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:w.ctaText})})]})]})]})},Cr=Ns;var fo=require("react");bt();var Ut=require("react/jsx-runtime"),vr=()=>{let t=Mt("BTS"),e=P(g=>g.campaigns),o=P(g=>g.allCampaigns),n=P(g=>g.currentScreen),i=t??(()=>{let g=(n||"").trim().toLowerCase(),b=[...e||[],...o||[]].find(m=>{if(!m||m.campaign_type!=="BTS")return!1;let E=!!(m.trigger_event??m.trigger);if(!(m.display_trigger!==!1&&!E))return!1;let D=(m.screen||"").trim().toLowerCase();return!D||D===g});if(b)try{return Ht(b)}catch{return b}})(),s=P(g=>g.isVisible),[l,c]=(0,fo.useState)(!1),d=(0,fo.useRef)(null);(0,fo.useEffect)(()=>{i?.id&&d.current!==i.id&&(d.current=i.id,c(!1),st("viewed",i.id))},[i?.id]);let S=g=>{try{let b=P.getState(),E=(b.trackedEvents||[]).filter(j=>j!==g);b.setTrackedEvents(E)}catch{}};if(!i||l||!s)return null;let{details:p}=i,u=[...p.elements||[]].sort((g,b)=>(g.order||0)-(b.order||0)),C=p.backdropOpacity??.5;C>1&&(C=C/100);let h=g=>{switch(g.type){case"image":{let b={width:"100%",display:"block",objectFit:"contain",backgroundColor:g.imageBackgroundColor||"transparent",paddingBottom:g.paddingBottom??0,paddingLeft:g.paddingLeft??0,paddingRight:g.paddingRight??0,paddingTop:g.paddingTop??0,cursor:g.imageLink?"pointer":"default"};return(0,Ut.jsx)("div",{style:{textAlign:g.alignment||"left",width:"100%"},children:g.url&&(0,Ut.jsx)("img",{src:g.url,alt:"",style:b,onClick:()=>{if(g.imageLink){i?.id&&st("clicked",i.id);try{let m=String(g.imageLink||"").trim();if(m&&!m.startsWith("http")&&Nt(m))return}catch(m){console.warn("revealCampaignFromLink error",m)}try{window.open(g.imageLink,"_blank")}catch{}}}})},g.id)}case"cta":{let b=g.cta||{},m=b.container||{},E=b.cornerRadius||{},j=b.margin||{},D=b.text||{};return(0,Ut.jsx)("div",{style:{display:"flex",justifyContent:m.alignment==="center"?"center":m.alignment==="right"?"flex-end":"flex-start",width:"100%",marginTop:j.top??0,marginBottom:j.bottom??0,marginLeft:j.left??0,marginRight:j.right??0},children:(0,Ut.jsx)("button",{style:{width:m.ctaFullWidth?"100%":m.ctaWidth||"auto",height:m.height||45,backgroundColor:m.ctaBoxColor||m.backgroundColor||"#FE6B35",color:D.color||"#ffffff",border:`${m.borderWidth||0}px solid ${m.borderColor||"transparent"}`,borderRadius:`${E.topLeft??12}px ${E.topRight??12}px ${E.bottomRight??12}px ${E.bottomLeft??12}px`,fontSize:D.fontSize||14,fontFamily:lt(D.fontFamily)||"Arial",fontWeight:D.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:D.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:D.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px"},onClick:()=>{let L=g.ctaLink||g.url;if(L){i?.id&&st("clicked",i.id);try{let v=String(L||"").trim();if(v&&!v.startsWith("http")&&Nt(v))return}catch(v){console.warn("revealCampaignFromLink error",v)}try{window.open(L,"_blank")}catch{}}},children:g.ctaText||"Button"})},g.id)}case"body":{let b=g.titleFontStyle||{},m=g.descriptionFontStyle||{};return(0,Ut.jsxs)("div",{style:{width:"100%",backgroundColor:g.bodyBackgroundColor||"transparent",marginTop:g.marginTop??0,marginBottom:g.marginBottom??20,marginLeft:g.marginLeft??4,marginRight:g.marginRight??4},children:[g.titleText&&(0,Ut.jsx)("div",{style:{color:b.colour||"#000000",fontSize:b.fontSize?`${b.fontSize}px`:g.titleFontSize?`${g.titleFontSize}px`:"16px",fontFamily:lt(b.fontFamily)||"inherit",textAlign:b.alignment||"left",lineHeight:g.titleLineHeight||1.2,fontWeight:b.decoration?.includes("bold")?"bold":"600",fontStyle:b.decoration?.includes("italic")?"italic":"normal",textDecoration:b.decoration?.includes("underline")?"underline":"none",marginBottom:g.spacingBetweenTitleDesc??4},children:g.titleText}),g.descriptionText&&(0,Ut.jsx)("div",{style:{color:m.colour||"#000000",fontSize:m.fontSize?`${m.fontSize}px`:g.descriptionFontSize?`${g.descriptionFontSize}px`:"14px",fontFamily:lt(m.fontFamily)||"inherit",textAlign:m.alignment||"left",lineHeight:g.descriptionLineHeight||1.5,fontWeight:m.decoration?.includes("bold")?"bold":"normal",fontStyle:m.decoration?.includes("italic")?"italic":"normal",textDecoration:m.decoration?.includes("underline")?"underline":"none"},children:g.descriptionText})]},g.id)}default:return null}};return(0,Ut.jsxs)(Ut.Fragment,{children:[(0,Ut.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:p.backdropColor||"rgba(0,0,0,0.5)",opacity:C,zIndex:999998,transition:"opacity 0.3s ease"},onClick:()=>{i?.id&&S(`viaAppStorys${i.id}`),c(!0)}}),(0,Ut.jsxs)("div",{style:{position:"fixed",bottom:0,left:"50%",transform:"translateX(-50%)",width:"100%",maxWidth:"500px",backgroundColor:p.backgroundColor||"#FFFFFF",borderTopLeftRadius:`${p.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${p.cornerRadius?.topRight??16}px`,borderBottomLeftRadius:`${p.cornerRadius?.bottomLeft??0}px`,borderBottomRightRadius:`${p.cornerRadius?.bottomRight??0}px`,zIndex:999999,padding:"24px 16px",boxShadow:"0 -4px 16px rgba(0,0,0,0.15)",maxHeight:"85vh",overflowY:"auto",display:"flex",flexDirection:"column",alignItems:"center",transition:"transform 0.3s ease-out"},children:[(0,Ut.jsx)("div",{style:{width:"40px",height:"5px",backgroundColor:"#E0E0E0",borderRadius:"2.5px",marginBottom:"16px",cursor:"pointer"},onClick:()=>c(!0)}),p.crossButton?.enabled&&(0,Ut.jsx)(Ot,{config:p.crossButton,onPress:()=>{i?.id&&S(`viaAppStorys${i.id}`),c(!0)},style:{top:p.crossButton?.margin?.top??12,right:p.crossButton?.margin?.right??12}}),(0,Ut.jsx)("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:"12px"},children:u.map(h)})]})]})};var Wt=require("react");bt();var ho=ge(require("lottie-react")),ct=require("react/jsx-runtime"),Os=ho.default?.default??ho.default??ho.Lottie??ho,wr=5,Gn=3;function sn(t){if(t!=null)return`${t}px`}function oe(t,e="0px"){return t==null?e:`${t}px`}function yo(t){return{marginTop:sn(t?.top),marginRight:sn(t?.right),marginBottom:sn(t?.bottom),marginLeft:sn(t?.left)}}function Jn(t){return lt(t)}function mo(t){if(!t)return{};let e={};t.color&&(e.color=t.color),t.fontSize&&(e.fontSize=t.fontSize);let o=Jn(t.fontFamily);return o&&(e.fontFamily=o),t.textAlign&&(e.textAlign=t.textAlign),t.fontDecoration?.includes("bold")&&(e.fontWeight="bold"),t.fontDecoration?.includes("italic")&&(e.fontStyle="italic"),t.fontDecoration?.includes("underline")&&(e.textDecoration="underline"),e}function an(t){return`${t?.topLeft??8}px ${t?.topRight??8}px ${t?.bottomRight??8}px ${t?.bottomLeft??8}px`}function Qn(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function js(t){let e=t.styling?.rating?.ratingType;return e==="number"||e==="emoji"||e==="star"?e:"star"}function qs(t){let e=t.styling?.rating?.emoji,o=[];Array.isArray(e)?o=e:e&&typeof e=="object"?Array.isArray(e.values)?o=e.values:o=Object.values(e):typeof e=="string"&&e.trim()&&(o=e.split(","));let n=o.map(i=>{if(typeof i=="string")return i.trim();if(i&&typeof i=="object"){let s=i.emoji||i.value||i.text||i.icon||i.name||"";if(typeof s=="string")return s.trim()}return""}).filter(Boolean);return n.length>0?n:["\u{1F620}","\u{1F615}","\u{1F610}","\u{1F642}","\u{1F60D}"]}function Hs(t){return Array.from({length:5},(e,o)=>o+1)}function Xn(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,e?.spacing];for(let i of o){let s=Xn(i);if(s!=null)return s}let n=e?.number;if(n&&typeof n=="object"){let i=n,s=[i.spacing,i.gap,i.optionsSpacing,i.numberSpacing,i.numberGap];for(let l of s){let c=Xn(l);if(c!=null)return c}}return 8}var Us=({fill:t,stroke:e})=>(0,ct.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":!0,children:(0,ct.jsx)("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"})}),Ys=({details:t,appearance:e,rating:o,selectedOptions:n,comments:i,isHighRating:s,feedbackOptions:l,onRate:c,onToggleOption:d,onCommentChange:S,onInlineSubmit:p,canSubmit:y,isMobile:u})=>{let C=t.styling||{},h=C.feedbackPage||{},g=C.rating||{},b=C.initialFeedback||{},m=h.submitButton?.cta,E=js(t),j=E==="number"?Hs(t):[],D=E==="emoji"?qs(t):[],L=E==="number"?Vs(t):8,v=E==="number"?L:g.spacing??8,w=u?"clamp(32px, 11vw, 44px)":"44px",_=u?"clamp(16px, 4.5vw, 22px)":22,N=Qn(g.alignment),U=an(g.cornerRadius),A=s?g.star?.high:g.star?.low,T=typeof g.number=="object"&&g.number?g.number:void 0,k=s?T?.high:T?.low,B=m?.container?.ctaFullWidth?"100%":Math.max(140,Xn(m?.container?.ctaWidth)??180);return(0,ct.jsxs)(ct.Fragment,{children:[(0,ct.jsx)("div",{style:yo(b.title?.margin),children:(0,ct.jsx)("div",{style:{...mo(b.title?.textStyle),color:b.title?.textStyle?.color||"#101828",fontSize:b.title?.textStyle?.fontSize||20,lineHeight:1.3,wordBreak:"break-word",overflowWrap:"break-word",paddingRight:C.crossButton?.enabled?(C.crossButton.size??30)+(C.crossButton.margin?.right??4)+4:0},children:t.title||"How was your experience?"})}),(0,ct.jsx)("div",{style:yo(b.subtitle?.margin),children:(0,ct.jsx)("div",{style:{...mo(b.subtitle?.textStyle),color:b.subtitle?.textStyle?.color||"#4b5563",fontSize:b.subtitle?.textStyle?.fontSize||14,lineHeight:1.4,wordBreak:"break-word",overflowWrap:"break-word"},children:t.description_text||"Your feedback helps us improve your experience."})}),(0,ct.jsxs)("div",{style:{marginTop:8,display:"flex",justifyContent:N,gap:v,flexWrap:"wrap"},children:[E==="star"&&Array.from({length:wr},($,V)=>{let G=V+1,r=G<=o,M=r?A?.stylingContainer:g.star?.unselected?.stylingContainer,a=r?A?.stylingStar:g.star?.unselected?.stylingStar;return(0,ct.jsx)("button",{onClick:()=>c(G),style:{border:`${M?.borderWidth??1}px solid ${M?.border||"#d1d5db"}`,background:M?.background||"#ffffff",borderRadius:U,width:w,height:w,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,flexShrink:0},"aria-label":`Rate ${G} out of ${wr}`,children:(0,ct.jsx)(Us,{fill:a?.background||(r?"#f59e0b":"#e5e7eb"),stroke:a?.border||(r?"#d97706":"#9ca3af")})},G)}),E==="number"&&j.map(($,V)=>{let G=$===o,r=G?k?.stylingContainer:T?.unselected?.stylingContainer,M=G?T?.stylingNumber:T?.unselected?.stylingNumber;return(0,ct.jsx)("button",{onClick:()=>c($),style:{border:`${r?.borderWidth??1}px solid ${r?.border||(G?"#1d4ed8":"#d1d5db")}`,background:r?.fill||r?.background||(G?"#dbeafe":"#ffffff"),color:M?.text||(G?"#1d4ed8":"#111827"),fontSize:M?.textSize||void 0,borderRadius:U,minWidth:w,height:w,padding:"0 10px",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontWeight:600,flexShrink:0},"aria-label":`Rate ${$}`,children:$},`${$}-${V}`)}),E==="emoji"&&D.map(($,V)=>{let G=V+1,r=G===o,M=g.emoji,f=(r?M?.selected:M?.unselected)?.stylingContainer;return(0,ct.jsx)("button",{onClick:()=>c(G),style:{border:`${f?.borderWidth??1}px solid ${f?.border||(r?"#1d4ed8":"#d1d5db")}`,background:f?.fill||f?.background||(r?"#dbeafe":"#ffffff"),borderRadius:U,width:w,height:w,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:_,flexShrink:0},"aria-label":`Emoji rating ${V+1}`,children:$},`${$}-${V}`)})]}),o>0&&(0,ct.jsx)("div",{style:{marginTop:6,textAlign:"center",color:"#374151",fontSize:14},children:s?t.highStarText||g.highRatingSubtitle:t.lowStarText||g.lowRatingSubtitle}),o>0&&o<=Gn&&(0,ct.jsxs)(ct.Fragment,{children:[l.length>0&&(0,ct.jsx)("div",{style:{...yo(h.options?.margin),display:"flex",flexDirection:"column",alignItems:"stretch",gap:h.options?.optionsSpacing??8,width:"100%"},children:l.map($=>{let G=n.includes($)?h.options?.selectedOptions:h.options?.nonSelectedOptions;return(0,ct.jsx)("button",{onClick:()=>d($),style:{border:`${G?.borderWidth??1}px solid ${G?.colors?.border||"#d1d5db"}`,background:G?.colors?.background||"#f9fafb",color:G?.colors?.text||"#111827",width:"100%",height:h.options?.optionsHeight||38,borderRadius:an(h.options?.cornerRadius),padding:"0 14px",cursor:"pointer",textAlign:"center",...mo(G?.textStyle)},children:$},$)})}),h.additionalComments?.enabled!==!1&&(0,ct.jsx)("textarea",{value:i,onChange:$=>S($.target.value),placeholder:h.additionalComments?.placeholder||"Tell us what we can improve",style:{width:"100%",boxSizing:"border-box",minHeight:56,height:56,maxHeight:64,marginTop:8,resize:"none",overflowY:"auto",border:`${h.additionalComments?.borderWidth??1}px solid ${h.additionalComments?.colors?.border||"#d1d5db"}`,background:h.additionalComments?.colors?.background||"#ffffff",color:h.additionalComments?.colors?.text||"#111827",borderRadius:8,padding:"12px",...mo(h.additionalComments?.textStyle)}}),(0,ct.jsx)("div",{style:{position:"sticky",bottom:0,marginTop:m?.margin?.top??8,marginBottom:m?.margin?.bottom??0,marginLeft:m?.margin?.left??0,marginRight:m?.margin?.right??0,paddingTop:6,paddingBottom:6,background:e?.backgroundColor||"#ffffff",display:"flex",justifyContent:Qn(m?.container?.alignment)},children:(0,ct.jsx)("button",{onClick:()=>p(),disabled:!y,style:{width:B,maxWidth:"100%",height:Number(m?.container?.height)||40,border:`${m?.container?.borderWidth??0}px solid ${m?.container?.borderColor||"transparent"}`,background:m?.container?.backgroundColor||"#6848b1",color:m?.text?.color||"#ffffff",borderRadius:an(m?.cornerRadius),fontFamily:Jn(m?.text?.fontFamily),fontSize:Number(m?.text?.fontSize)||14,fontWeight:m?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:y?"pointer":"not-allowed",opacity:y?1:.65,padding:"0 12px",boxSizing:"border-box"},children:h.submitButton?.text||"Submit"})})]})]})},Gs=({details:t,isHighRating:e,onDone:o})=>{let n=t.styling||{},i=n.thankyouPage||{},s=n.rating||{},l=Qn(i.doneButton?.cta?.container?.alignment),[c,d]=(0,Wt.useState)(null),S=t.thankyouImage?.endsWith(".json");return(0,Wt.useEffect)(()=>{S&&t.thankyouImage&&fetch(t.thankyouImage).then(p=>p.json()).then(p=>d(p)).catch(p=>console.error("Error loading Lottie:",p))},[t.thankyouImage,S]),(0,ct.jsxs)(ct.Fragment,{children:[t.thankyouImage&&(0,ct.jsx)("div",{style:{display:"flex",justifyContent:"center",...yo(i.imageStyle?.margin)},children:S?c?(0,ct.jsx)(Os,{animationData:c,loop:!0,style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80}}):(0,ct.jsx)("div",{style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80}}):(0,ct.jsx)("img",{src:t.thankyouImage,alt:"thank you",style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80,objectFit:"cover",borderRadius:8}})}),(0,ct.jsx)("div",{style:yo(i.title?.margin),children:(0,ct.jsx)("div",{style:{color:"#111827",fontSize:20,lineHeight:1.3,...mo(i.title?.textStyle),wordBreak:"break-word",overflowWrap:"break-word"},children:t.thankyouText||(e?s.highRatingTitle:s.lowRatingTitle)||"Thank you for your feedback"})}),(0,ct.jsx)("div",{style:yo(i.subtitle?.margin),children:(0,ct.jsx)("div",{style:{color:"#4b5563",fontSize:14,lineHeight:1.4,...mo(i.subtitle?.textStyle),wordBreak:"break-word",overflowWrap:"break-word"},children:t.thankyouDescription||(e?s.highRatingSubtitle:s.lowRatingSubtitle)||"We appreciate your time."})}),(0,ct.jsx)("div",{style:{marginTop:i.doneButton?.cta?.margin?.top??14,marginBottom:i.doneButton?.cta?.margin?.bottom??0,marginLeft:i.doneButton?.cta?.margin?.left??0,marginRight:i.doneButton?.cta?.margin?.right??0,display:"flex",justifyContent:l},children:(0,ct.jsx)("button",{onClick:o,style:{width:i.doneButton?.cta?.container?.ctaFullWidth?"100%":i.doneButton?.cta?.container?.ctaWidth||"auto",height:i.doneButton?.cta?.container?.height||45,border:`${i.doneButton?.cta?.container?.borderWidth??0}px solid ${i.doneButton?.cta?.container?.borderColor||"transparent"}`,background:i.doneButton?.cta?.container?.backgroundColor||"#111827",color:i.doneButton?.cta?.text?.color||"#ffffff",borderRadius:an(i.doneButton?.cta?.cornerRadius),fontFamily:Jn(i.doneButton?.cta?.text?.fontFamily),fontSize:i.doneButton?.cta?.text?.fontSize||16,fontWeight:i.doneButton?.cta?.text?.fontDecoration?.includes("bold")?"bold":"normal",cursor:"pointer",padding:"0 16px",boxSizing:"border-box"},children:e?t.highStarText||i.doneButton?.text||"Rate Now":t.lowStarText||i.doneButton?.text||"Done"})})]})},Qs=()=>{let t=Mt("CSAT"),e=P(x=>x.isVisible),o=P(x=>x.campaigns),n=P(x=>x.allCampaigns),i=P(x=>x.currentScreen),[s,l]=(0,Wt.useState)(typeof window<"u"?window.innerWidth:1024);(0,Wt.useEffect)(()=>{if(typeof window>"u")return;let x=()=>l(window.innerWidth);return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);let c=s<768,d=t??(()=>{let x=(i||"").trim().toLowerCase(),z=[...o||[],...n||[]].find(Y=>{if(!Y||Y.campaign_type!=="CSAT")return!1;let ot=!!(Y.trigger_event??Y.trigger);if(!(Y.display_trigger!==!1&&!ot))return!1;let H=(Y.screen||"").trim().toLowerCase();return!H||H===x});if(z)try{return Ht(z)}catch{return z}})(),[S,p]=(0,Wt.useState)(!1),[y,u]=(0,Wt.useState)(!1),[C,h]=(0,Wt.useState)(!1),[g,b]=(0,Wt.useState)(!1),[m,E]=(0,Wt.useState)(0),[j,D]=(0,Wt.useState)([]),[L,v]=(0,Wt.useState)(""),[w,_]=(0,Wt.useState)(!1),N=(0,Wt.useRef)(null);(0,Wt.useEffect)(()=>{if(!d?.id||N.current===d.id)return;N.current=d.id,p(!1),u(!1),h(!1),b(!1),E(0),D([]),v(""),_(!1);let x=d.details?.styling?.appearance?.displayDelay??0,z=globalThis.setTimeout(()=>{u(!0),st("viewed",d.id)},Math.max(0,x)*1e3);return()=>globalThis.clearTimeout(z)},[d?.id]),(0,Wt.useEffect)(()=>{if(y){let x=setTimeout(()=>h(!0),30);return()=>clearTimeout(x)}},[y]);let U=(0,Wt.useMemo)(()=>{let x=d?.details?.feedback_option||{};return Object.keys(x).sort((z,Y)=>z.localeCompare(Y)).map(z=>typeof x[z]=="string"?x[z].trim():x[z]).filter(Boolean)},[d]);if(!d||!e||S||!y)return null;let A=d.details,T=A.styling||{},k=T.appearance||{},B=m>Gn,$=x=>{D(z=>z.includes(x)?z.filter(Y=>Y!==x):[...z,x])},V=async x=>{let z=x?.rating??m;if(z<1)return;_(!0);let Y=d.id,ot=(x?.options??j)[0]||"",J=x?.comments??L??"";st("csat captured",Y,{starCount:z,selectedOption:ot,additionalComments:J})},G=x=>{if(E(x),x>Gn){D([]),v("");let z=d?.id;setTimeout(()=>{_(!0);try{st("csat captured",z,{starCount:x,selectedOption:"",additionalComments:""})}catch(Y){console.warn("Error sending csat captured",Y)}},1e3)}},r=async()=>{b(!0);try{let x=d?.id;await st("csat closed",x)}catch(x){console.warn("Error sending csat closed",x)}finally{setTimeout(()=>{p(!0)},300)}},M=()=>{if(B&&A.link){let x=d&&d.id||void 0;try{x&&st("clicked",x)}catch{}try{let z=String(A.link||"").trim();if(z&&!z.startsWith("http")&&Nt(z)){b(!0),setTimeout(()=>{p(!0)},300);return}}catch(z){console.warn("revealCampaignFromLink error",z)}try{globalThis.open(A.link,"_blank")}catch{}}b(!0),setTimeout(()=>{p(!0)},300)},a=c?{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"center",alignItems:"flex-end",paddingLeft:oe(k.margin?.left,"0px"),paddingRight:oe(k.margin?.right,"0px"),pointerEvents:"none"}:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"flex-end",alignItems:"flex-end",paddingTop:oe(k.margin?.top),paddingRight:oe(k.margin?.right,"20px"),paddingBottom:oe(k.margin?.bottom,"20px"),paddingLeft:oe(k.margin?.left,"20px"),pointerEvents:"none"},f=c?{position:"relative",width:"100%",maxWidth:"none",maxHeight:"85vh",overflow:"visible",backgroundColor:k.backgroundColor||"#ffffff",borderTopLeftRadius:`${k.borderRadius??16}px`,borderTopRightRadius:`${k.borderRadius??16}px`,borderBottomLeftRadius:0,borderBottomRightRadius:0,boxSizing:"border-box",paddingTop:oe(k.padding?.top,"12px"),paddingRight:oe(k.padding?.right,"16px"),paddingBottom:`max(${oe(k.padding?.bottom,"16px")}, env(safe-area-inset-bottom, 16px))`,paddingLeft:oe(k.padding?.left,"16px"),pointerEvents:"auto",boxShadow:"0 -8px 32px rgba(0, 0, 0, 0.20)",display:"flex",flexDirection:"column",transform:g||!C?"translateY(100%)":"translateY(0)",transition:"transform 0.3s cubic-bezier(0.25, 1, 0.5, 1)"}:{position:"relative",width:"min(450px, 92vw)",maxHeight:"85vh",overflow:"visible",backgroundColor:k.backgroundColor||"#ffffff",borderRadius:`${k.borderRadius??12}px`,boxSizing:"border-box",paddingTop:oe(k.padding?.top,"8px"),paddingRight:oe(k.padding?.right,"12px"),paddingBottom:oe(k.padding?.bottom,"8px"),paddingLeft:oe(k.padding?.left,"12px"),pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column",transform:g||!C?"translateY(100%)":"translateY(0)",transition:"transform 0.3s cubic-bezier(0.25, 1, 0.5, 1)"};return(0,ct.jsx)("div",{style:a,children:(0,ct.jsxs)("div",{style:f,children:[(0,ct.jsx)("style",{children:`
82
129
  .appstorys-csat-scroll {
83
130
  scrollbar-width: none; /* Firefox */
84
131
  -ms-overflow-style: none; /* IE/Edge */
@@ -88,15 +135,31 @@
88
135
  height: 0;
89
136
  display: none; /* Chrome/Safari */
90
137
  }
91
- `}),B.crossButton?.enabled&&(0,V.jsx)(Qt,{config:B.crossButton,onPress:()=>a(!0),style:{top:B.crossButton?.margin?.top??10,right:B.crossButton?.margin?.right??10}}),(0,V.jsx)("div",{className:"appstorys-csat-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:4},children:h?(0,V.jsx)(Fr,{details:I,isHighRating:d,onDone:_}):(0,V.jsx)(Tr,{details:I,rating:x,selectedOptions:g,comments:f,isHighRating:d,feedbackOptions:w,onRate:A,onToggleOption:p,onCommentChange:b,onInlineSubmit:O,canSubmit:x>=1,appearance:R})})]})})},xi=Ir;var wt=require("react");et();var J=require("react/jsx-runtime");function oo(t){if(t!=null)return`${t}px`}function Zo(t){return dt(t)}function Ce(t){return t?{color:t.color,fontSize:t.fontSize,fontFamily:Zo(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 no(t){return{marginTop:oo(t?.top),marginRight:oo(t?.right),marginBottom:oo(t?.bottom),marginLeft:oo(t?.left)}}function io(t){return`${t?.topLeft??12}px ${t?.topRight??12}px ${t?.bottomRight??t?.topRight??12}px ${t?.bottomLeft??t?.topLeft??12}px`}function vi(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function Pe(t){return Math.max(0,Math.min(1,t))}function zr(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}, ${Pe(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}, ${Pe(e)})`}return`rgba(0, 0, 0, ${Pe(e)})`}function Br(t){if(t==null)return .4;let e=Number(t);return Number.isFinite(e)?e>1?Pe(e/100):Pe(e):.4}function Si(t){return[...t.slides||[]].sort((o,i)=>(o.order??0)-(i.order??0))}function Ar(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 Er(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 Pr(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 Ci(t){return Pr(t?.borderwidth)??1}var Lr=({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=(0,wt.useMemo)(()=>Ar(e),[e]),v=x.optionsSpacing??8,f=x.bulletSpacing??10,b=x.optionsHeight??44,h=vi(m?.container?.alignment);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("div",{style:no(u.title?.textStyle?.margin),children:(0,J.jsx)("div",{style:{...Ce(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)&&(0,J.jsx)("div",{style:no(u.subtitle?.textStyle?.margin),children:(0,J.jsx)("div",{style:{...Ce(u.subtitle?.textStyle),color:u.subtitle?.textStyle?.color||"#6b7280",fontSize:u.subtitle?.textStyle?.fontSize||14,lineHeight:1.35},children:e.subtitle||""})}),g.length>0&&(0,J.jsx)("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:v},children:g.map((y,w)=>{let I=i===y,B=I?x.selectedOptions:x.nonSelectedOptions,R=Ci(B?.textStyle),d=Er(x.optionListStyle,w);return(0,J.jsxs)("button",{onClick:()=>r(y),style:{width:"100%",boxSizing:"border-box",height:b,borderRadius:io(x.cornerRadius),border:`${R}px solid ${B?.colors?.border||"#e5e7eb"}`,background:B?.colors?.background||"#ffffff",color:B?.colors?.text||"#111827",cursor:"pointer",display:"flex",alignItems:"center",gap:f,paddingLeft:14,paddingRight:14,textAlign:"left",...Ce(B?.textStyle)},"aria-pressed":I,children:[(0,J.jsx)("span",{"aria-hidden":!0,style:{width:16,height:16,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",border:`1.5px solid ${B?.colors?.border||"#111827"}`,background:"#ffffff",flex:"0 0 auto",fontSize:11,fontWeight:700,color:B?.colors?.text||"#111827"},children:I?"\u2713":d||""}),(0,J.jsx)("span",{style:{flex:1,minWidth:0},children:y})]},`${y}-${w}`)})}),e.additionalComment?.enabled&&(0,J.jsx)("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:`${Ci(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",...Ce(x.additionalComments?.textStyle)}}),(0,J.jsx)("div",{style:{position:"sticky",bottom:0,marginTop:12,paddingTop:10,paddingBottom:6,background:o?.backgroundColor||"#ffffff"},children:(0,J.jsx)("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:(0,J.jsx)("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:io(m?.cornerRadius),fontFamily:Zo(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"})})})]})},Dr=({details:t,onDone:e})=>{let i=(t.styling||{}).thankyouPage||{},n=i.cta,r=vi(n?.container?.alignment);return(0,J.jsxs)(J.Fragment,{children:[t.thankYouImage&&(0,J.jsx)("div",{style:{display:"flex",justifyContent:"center",marginTop:8},children:(0,J.jsx)("img",{src:t.thankYouImage,alt:"thank you",style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80,objectFit:"cover",borderRadius:10}})}),(0,J.jsx)("div",{style:{...no(i.title?.textStyle?.margin)},children:(0,J.jsx)("div",{style:{...Ce(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"})}),(0,J.jsx)("div",{style:{...no(i.subtitle?.textStyle?.margin)},children:(0,J.jsx)("div",{style:{...Ce(i.subtitle?.textStyle),color:i.subtitle?.textStyle?.color||"#6b7280",fontSize:i.subtitle?.textStyle?.fontSize||14,lineHeight:1.35},children:t.thankYouText||""})}),(t.thankYouButtonText||n)&&(0,J.jsx)("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:(0,J.jsx)("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:io(n?.cornerRadius),fontFamily:Zo(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"})})]})},_r=()=>{let t=ct("SUR"),e=F(P=>P.isVisible),o=F(P=>P.campaigns),i=F(P=>P.allCampaigns),n=F(P=>P.currentScreen),r=t??(()=>{let P=(n||"").trim().toLowerCase(),M=[...o||[],...i||[]].find($=>{if(!$||$.campaign_type!=="SUR")return!1;let k=!!($.trigger_event??$.trigger);if(!($.display_trigger!==!1&&!k))return!1;let j=($.screen||"").trim().toLowerCase();return!j||j===P});if(M)try{return Ct(M)}catch{return M}})(),[s,a]=(0,wt.useState)(!1),[c,u]=(0,wt.useState)(!1),[x,m]=(0,wt.useState)(0),[g,v]=(0,wt.useState)(null),[f,b]=(0,wt.useState)(""),[h,y]=(0,wt.useState)({}),[w,I]=(0,wt.useState)(!1);(0,wt.useEffect)(()=>{if(!r)return;a(!1),u(!1),m(0),v(null),b(""),y({}),I(!1);let P=r.details?.styling?.appearance?.displayDelay??0,M=globalThis.setTimeout(()=>{u(!0);let $=r.details?.id,k=Si(r.details),L=k.length>0?k[0].id:void 0;H("viewed",r.id,{survey_id:$,slide_id:L})},Math.max(0,P)*1e3);return()=>globalThis.clearTimeout(M)},[r]);let B=(0,wt.useMemo)(()=>r?Si(r.details):[],[r]),R=B[x];if((0,wt.useEffect)(()=>{if(!R)return;let P=h[R.id];v(P?.option??null),b(P?.comment??"")},[R?.id]),!r||!e||s||!c)return null;let d=r.details,T=d.styling||{},l=T.appearance||{},p=l.backdropColor||"#000000",O=Br(l.backdropOpacity),A=P=>{v(M=>M===P?null:P)},_=async(P,M)=>{let $=B.map(N=>({slide_id:N.id,order:N.order,title:N.title,question:N.question,selected_options:P[N.id]?.option,comment:P[N.id]?.comment})),k=r.id,L=[];for(let N of B){let tt=P[N.id]?.option;if(!tt)continue;let K=Object.entries(N.options||{}).find(([,Y])=>String(Y)===String(tt));K&&L.push(K[0])}let j=$.map(N=>N.comment).filter(Boolean).join(" || ")||"",X=d.id||k;H("survey captured",X,{survey_id:d.id,slide_id:M,selected_options:L,otherText:j}),T.content?.isThankyouPage!==!1?I(!0):a(!0)},C=async()=>{if(!R||!g)return;let P={...h,[R.id]:{option:g,comment:f}};y(P);try{let L=r.id,j=null;if(g&&R&&R.options){let ft=Object.entries(R.options).find(([,N])=>String(N)===String(g));ft&&(j=ft[0])}let X=d.id||L;H("survey captured",X,{survey_id:d.id,slide_id:R.id,selected_options:j?[j]:[],otherText:f||""})}catch(L){console.warn("Error sending per-slide survey captured",L)}if((R.logic||[]).find(L=>(L.selectOption||[]).includes(g))?.redirectTo==="thank-you"){await _(P,R.id);return}if(x>=B.length-1){await _(P,R.id);return}m(L=>Math.min(L+1,B.length-1))},S=()=>{let P=d.thankYouButtonConfig;if(P?.enabled&&P.redirectUrl){try{let M=String(P.redirectUrl||"").trim();if(M&&!M.startsWith("http")&&vt(M)){a(!0);return}}catch(M){console.warn("revealCampaignFromLink error",M)}try{globalThis.open(P.redirectUrl,"_blank")}catch{}}a(!0)},W=async()=>{try{let P=r?.id,M=d?.id,$=R?.id;await H("SurveyDismissed",P,{survey_id:M,slide_id:$})}catch(P){console.warn("Error sending SurveyDismissed",P)}finally{a(!0)}};return R?(0,J.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"flex-end",alignItems:"flex-end",padding:12,pointerEvents:"none"},children:[(0,J.jsx)("div",{"aria-hidden":!0,style:{position:"absolute",inset:0,background:zr(p,O)}}),(0,J.jsxs)("div",{style:{position:"relative",width:"min(420px, 92vw)",maxWidth:"92vw",minWidth:"320px",maxHeight:"80vh",overflow:"hidden",backgroundColor:l.backgroundColor||"#ffffff",borderRadius:io(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:[(0,J.jsx)("style",{children:`
138
+ `}),T.crossButton?.enabled&&(0,ct.jsx)(Ot,{config:T.crossButton,onPress:()=>{r()},style:{top:T.crossButton?.margin?.top??10,right:T.crossButton?.margin?.right??10}}),(0,ct.jsx)("div",{className:"appstorys-csat-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:4},children:w?(0,ct.jsx)(Gs,{details:A,isHighRating:B,onDone:M}):(0,ct.jsx)(Ys,{details:A,rating:m,selectedOptions:j,comments:L,isHighRating:B,feedbackOptions:U,onRate:G,onToggleOption:$,onCommentChange:v,onInlineSubmit:V,canSubmit:m>=1,appearance:k,isMobile:c})})]})})},kr=Qs;var wt=require("react");bt();var xo=ge(require("lottie-react")),at=require("react/jsx-runtime"),Xs=xo.default?.default??xo.default??xo.Lottie??xo;function ln(t){if(t!=null)return`${t}px`}function dn(t){return lt(t)}function bo(t){if(!t)return{};let e={};t.color&&(e.color=t.color),t.fontSize&&(e.fontSize=t.fontSize);let o=dn(t.fontFamily);return o&&(e.fontFamily=o),t.textAlign&&(e.textAlign=t.textAlign),t.fontDecoration?.includes("bold")&&(e.fontWeight="bold"),t.fontDecoration?.includes("italic")&&(e.fontStyle="italic"),t.fontDecoration?.includes("underline")&&(e.textDecoration="underline"),e}function _o(t){return{marginTop:ln(t?.top),marginRight:ln(t?.right),marginBottom:ln(t?.bottom),marginLeft:ln(t?.left)}}function Wo(t,e=0){if(!t)return`${e}px`;let o=t.topLeft!==void 0&&t.topLeft!==null?t.topLeft:e,n=t.topRight!==void 0&&t.topRight!==null?t.topRight:e,i=t.bottomRight!==void 0&&t.bottomRight!==null?t.bottomRight:e,s=t.bottomLeft!==void 0&&t.bottomLeft!==null?t.bottomLeft:e;return`${o}px ${n}px ${i}px ${s}px`}function Br(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function $o(t){return Math.max(0,Math.min(1,t))}function Rr(t,e){let o=(t||"").trim().replace("#","");if(o.length===3){let n=Number.parseInt(o[0]+o[0],16),i=Number.parseInt(o[1]+o[1],16),s=Number.parseInt(o[2]+o[2],16);return`rgba(${n}, ${i}, ${s}, ${$o(e)})`}if(o.length===6){let n=Number.parseInt(o.slice(0,2),16),i=Number.parseInt(o.slice(2,4),16),s=Number.parseInt(o.slice(4,6),16);return`rgba(${n}, ${i}, ${s}, ${$o(e)})`}return`rgba(0, 0, 0, ${$o(e)})`}function Js(t){if(t==null)return .4;let e=Number(t);return Number.isFinite(e)?e>1?$o(e/100):$o(e):.4}function Fr(t){return[...t.slides||[]].sort((o,n)=>(o.order??0)-(n.order??0))}function Ks(t,e){let o=t.trim();if(!o)return{action:"none"};let n=o.toLowerCase().replace(/[\s_-]+/g,"");if(n==="thankyou"||n==="thankyoupage")return{action:"thankyou"};let i=/^question\s+(\d+)$/i.exec(o);if(i){let d=parseInt(i[1],10)-1;return d>=0&&d<e.length?{action:"jump",targetIndex:d}:{action:"none"}}let s=e.findIndex(c=>c.id===o);if(s!==-1)return{action:"jump",targetIndex:s};let l=Number(o);if(Number.isFinite(l)&&l>0){let c=e.findIndex(d=>d.order===l);if(c!==-1)return{action:"jump",targetIndex:c}}return{action:"none"}}function Zs(t){let e=t?.options||{},o=Object.keys(e),n=i=>{let s=/(\d+)/.exec(i);if(!s)return;let l=Number(s[1]);return Number.isFinite(l)?l:void 0};return o.sort((i,s)=>{let l=n(i),c=n(s);return l!=null&&c!=null?l-c:l!=null?-1:c!=null?1:i.localeCompare(s)}),o.map(i=>e[i]).filter(i=>typeof i=="string"&&i.trim().length>0)}function ta(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 ea(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 Tr(t){return ea(t?.borderwidth)??1}var zr=({details:t,slide:e,appearance:o,selectedOptions:n,comment:i,onSelectOption:s,onCommentChange:l,onSubmit:c,canSubmit:d})=>{let S=t.styling||{},p=S.options||{},y=S.cta,u=(0,wt.useMemo)(()=>Zs(e),[e]),C=p.optionsSpacing??6,h=p.bulletSpacing??12,g=p.optionsHeight??48,b=Br(y?.container?.alignment),m=S.title?.textStyle,E=S.subtitle?.textStyle;return(0,at.jsxs)(at.Fragment,{children:[(0,at.jsx)("div",{style:{width:"100%",..._o(m?.margin)},children:(0,at.jsx)("div",{style:{...bo(m),color:m?.color||"#111827",fontSize:m?.fontSize||22,lineHeight:1.3,textAlign:m?.textAlign||"left",fontWeight:m?.fontDecoration?.includes("bold")?"bold":m?.fontDecoration?"normal":600,fontStyle:m?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:m?.fontDecoration?.includes("underline")?"underline":"none"},children:e.title||e.question||t.name||"Survey"})}),(e.subtitle||E)&&(0,at.jsx)("div",{style:{width:"100%",..._o(E?.margin)},children:(0,at.jsx)("div",{style:{...bo(E),color:E?.color||"#6b7280",fontSize:E?.fontSize||16,lineHeight:1.35,textAlign:E?.textAlign||"left",fontWeight:E?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:E?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:E?.fontDecoration?.includes("underline")?"underline":"none"},children:e.subtitle||""})}),u.length>0&&(()=>{let j="__others__",D=e.additionalComment?.placeholder?.trim()||"Others",L=u.map(w=>({value:w,label:w}));e.additionalComment?.enabled&&L.push({value:j,label:D});let v=n.includes(j);return(0,at.jsxs)(at.Fragment,{children:[(0,at.jsx)("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:C},children:L.map(({value:w,label:_},N)=>{let U=n.includes(w),A=U?p.selectedOptions:p.nonSelectedOptions,T=Tr(A?.textStyle),k=ta(p.optionListStyle,N),B=p.optionListStyle,$=B==="bulleted",V=B==="number"||B==="alphabet"||B==="roman",G=A?.colors?.text||A?.textStyle?.color||(U?"#ffffff":"#111827"),r=A?.colors?.background||(U?"#1f35db":"#ffffff"),M=A?.colors?.border||(U?"#1f35db":"#e5e7eb");return(0,at.jsxs)("button",{onClick:()=>s(w),style:{width:"100%",boxSizing:"border-box",minHeight:g,height:"auto",borderRadius:Wo(p.cornerRadius,7),border:`${T}px solid ${M}`,background:r,color:G,cursor:"pointer",display:"flex",alignItems:"center",gap:h,paddingTop:8,paddingBottom:8,paddingLeft:14,paddingRight:14,textAlign:A?.textStyle?.textAlign||"left",...bo(A?.textStyle)},"aria-pressed":U,children:[$?(0,at.jsx)("span",{"aria-hidden":!0,style:{width:18,height:18,borderRadius:"50%",border:`2px solid ${U?p.selectedOptions?.colors?.border||M:p.nonSelectedOptions?.colors?.border||M}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:U&&(0,at.jsx)("span",{style:{width:10,height:10,borderRadius:"50%",backgroundColor:G}})}):V?(0,at.jsx)("span",{"aria-hidden":!0,style:{fontSize:A?.textStyle?.fontSize?A.textStyle.fontSize*.85:16,fontWeight:A?.textStyle?.fontDecoration?.includes("bold")?"bold":600,fontFamily:dn(A?.textStyle?.fontFamily),color:G,marginRight:2,flexShrink:0},children:k}):null,(0,at.jsx)("span",{style:{flex:1,minWidth:0,wordBreak:"break-word",lineHeight:1.35,color:G},children:_})]},`${w}-${N}`)})}),v&&(0,at.jsx)("textarea",{value:i,onChange:w=>l(w.target.value),placeholder:e.additionalComment?.placeholder||"Type your response...",style:{marginTop:10,width:"100%",boxSizing:"border-box",minHeight:72,resize:"none",overflowY:"auto",border:`${Tr(p.additionalComments?.textStyle)}px solid ${p.additionalComments?.colors?.border||"#e5e7eb"}`,background:p.additionalComments?.colors?.background||"#ffffff",color:p.additionalComments?.colors?.text||"#111827",borderRadius:Wo(p.cornerRadius,7),padding:"12px",...bo(p.additionalComments?.textStyle)}})]})})(),(0,at.jsx)("div",{style:{position:"sticky",bottom:0,marginTop:y?.margin?.top??12,marginBottom:y?.margin?.bottom??0,marginLeft:y?.margin?.left??0,marginRight:y?.margin?.right??0,paddingTop:10,paddingBottom:4,background:o?.backgroundColor||"#ffffff",display:"flex",justifyContent:b,width:"100%",boxSizing:"border-box"},children:(0,at.jsx)("button",{onClick:c,disabled:!d,style:{width:y?.container?.ctaFullWidth?"100%":y?.container?.ctaWidth?`${y.container.ctaWidth}px`:"140px",maxWidth:"100%",height:y?.container?.height??50,border:`${y?.container?.borderWidth??0}px solid ${y?.container?.borderColor||"transparent"}`,background:y?.container?.backgroundColor||"#1f35db",color:y?.text?.color||"#ffffff",borderRadius:Wo(y?.cornerRadius,7),fontFamily:dn(y?.text?.fontFamily)||"Arial",fontSize:y?.text?.fontSize||18,fontWeight:y?.text?.fontDecoration?.includes("bold")?"bold":600,fontStyle:y?.text?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:y?.text?.fontDecoration?.includes("underline")?"underline":"none",cursor:d?"pointer":"not-allowed",opacity:d?1:.6,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 20px",boxSizing:"border-box"},children:e.submitButtonText||"Submit"})})]})},Ir=({details:t,onDone:e})=>{let o=t.styling||{},n=o.thankyouPage||{},i=n.cta||o.cta,s=Br(i?.container?.alignment),l=t.thankYouImage?.endsWith(".json"),[c,d]=(0,wt.useState)(null);(0,wt.useEffect)(()=>{l&&t.thankYouImage?fetch(t.thankYouImage).then(u=>u.json()).then(u=>d(u)).catch(u=>console.error("AppStorys Survey: Error loading Thank You Lottie:",u)):d(null)},[t.thankYouImage,l]);let S=t.thankYouTitle||t?.thank_you_title||"Thank you",p=t.thankYouText||t?.thank_you_text||"",y=t.thankYouButtonText||t?.thank_you_button_text||"Done";return(0,at.jsxs)(at.Fragment,{children:[t.thankYouImage&&(0,at.jsx)("div",{style:{display:"flex",justifyContent:"center",..._o(n.imageStyle?.margin)},children:l?c?(0,at.jsx)(Xs,{animationData:c,loop:!0,style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80}}):(0,at.jsx)("div",{style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80}}):(0,at.jsx)("img",{src:t.thankYouImage,alt:"thank you",style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80,objectFit:"cover",borderRadius:10}})}),(0,at.jsx)("div",{style:{width:"100%",..._o(n.title?.textStyle?.margin)},children:(0,at.jsx)("div",{style:{...bo(n.title?.textStyle),color:n.title?.textStyle?.color||"#111827",fontSize:n.title?.textStyle?.fontSize||20,lineHeight:1.3,textAlign:n.title?.textStyle?.textAlign||"center",fontWeight:n.title?.textStyle?.fontDecoration?.includes("bold")?"bold":n.title?.textStyle?.fontDecoration?.length?"normal":700},children:S})}),p&&(0,at.jsx)("div",{style:{width:"100%",..._o(n.subtitle?.textStyle?.margin)},children:(0,at.jsx)("div",{style:{...bo(n.subtitle?.textStyle),color:n.subtitle?.textStyle?.color||"#6b7280",fontSize:n.subtitle?.textStyle?.fontSize||14,lineHeight:1.35,textAlign:n.subtitle?.textStyle?.textAlign||"center",fontWeight:n.subtitle?.textStyle?.fontDecoration?.includes("bold")?"bold":"normal"},children:p})}),(y||i)&&(0,at.jsx)("div",{style:{marginTop:i?.margin?.top??14,marginBottom:i?.margin?.bottom??0,marginLeft:i?.margin?.left??0,marginRight:i?.margin?.right??0,display:"flex",justifyContent:s,width:"100%",boxSizing:"border-box"},children:(0,at.jsx)("button",{onClick:e,style:{width:i?.container?.ctaFullWidth?"100%":i?.container?.ctaWidth?`${i.container.ctaWidth}px`:"auto",maxWidth:"100%",height:i?.container?.height??44,border:`${i?.container?.borderWidth??0}px solid ${i?.container?.borderColor||"transparent"}`,background:i?.container?.backgroundColor||"#1f35db",color:i?.text?.color||"#ffffff",borderRadius:Wo(i?.cornerRadius,12),fontFamily:dn(i?.text?.fontFamily)||"Arial",fontSize:i?.text?.fontSize||14,fontWeight:i?.text?.fontDecoration?.includes("bold")?"bold":600,fontStyle:i?.text?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:i?.text?.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",padding:"0 20px",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:y})})]})},oa=()=>{let t=Mt("SUR"),e=P(R=>R.isVisible),o=P(R=>R.campaigns),n=P(R=>R.allCampaigns),i=P(R=>R.currentScreen),[s,l]=(0,wt.useState)(typeof window<"u"?window.innerWidth:1024),[c,d]=(0,wt.useState)(0),[S,p]=(0,wt.useState)(!1),[y,u]=(0,wt.useState)(!1),[C,h]=(0,wt.useState)(!1),g=(0,wt.useRef)(0),b=(0,wt.useRef)(0),m=(0,wt.useRef)(null),E=(0,wt.useRef)(0),j=(0,wt.useRef)(!1);(0,wt.useEffect)(()=>{if(typeof window>"u")return;let R=()=>l(window.innerWidth);return window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[]);let D=s<768,L=t??(()=>{let R=(i||"").trim().toLowerCase(),I=[...o||[],...n||[]].find(O=>{if(!O||O.campaign_type!=="SUR")return!1;let tt=!!(O.trigger_event??O.trigger);if(!(O.display_trigger!==!1&&!tt))return!1;let zt=(O.screen||"").trim().toLowerCase();return!zt||zt===R});if(I)try{return Ht(I)}catch{return I}})(),[v,w]=(0,wt.useState)(!1),[_,N]=(0,wt.useState)(!1),[U,A]=(0,wt.useState)(0),[T,k]=(0,wt.useState)([]),[B,$]=(0,wt.useState)(""),[V,G]=(0,wt.useState)({}),[r,M]=(0,wt.useState)(!1),a=(0,wt.useRef)(null);(0,wt.useEffect)(()=>{if(!L?.id||a.current===L.id)return;a.current=L.id,w(!1),N(!1),A(0),k([]),$(""),G({}),M(!1),h(!1),u(!1),d(0);let R=L.details?.styling?.appearance?.displayDelay??0,I=globalThis.setTimeout(()=>{N(!0);let O=L.details?.id,tt=Fr(L.details),St=tt.length>0?tt[0].id:void 0;st("viewed",L.id,{survey_id:O,slide_id:St})},Math.max(0,R)*1e3);return()=>globalThis.clearTimeout(I)},[L?.id]),(0,wt.useEffect)(()=>{if(_){let R=setTimeout(()=>h(!0),30);return()=>clearTimeout(R)}},[_]);let f=(0,wt.useMemo)(()=>L?Fr(L.details):[],[L]),x=f[U];(0,wt.useEffect)(()=>{if(typeof window>"u"||!L||!e||v||!_)return;let R=window.scrollY||window.pageYOffset||0,I=document.body.style.position,O=document.body.style.top,tt=document.body.style.left,St=document.body.style.right,zt=document.body.style.width,Tt=document.body.style.overflow,Yt=document.documentElement.style.overflow;return document.body.style.position="fixed",document.body.style.top=`-${R}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%",document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",()=>{document.body.style.position=I,document.body.style.top=O,document.body.style.left=tt,document.body.style.right=St,document.body.style.width=zt,document.body.style.overflow=Tt,document.documentElement.style.overflow=Yt,window.scrollTo(0,R)}},[L,e,v,_]);let z=(R,I)=>{g.current=R,b.current=0,j.current=I,m.current?E.current=m.current.scrollTop:E.current=0,p(!0)},Y=R=>{if(!g.current)return;let I=R-g.current,O=m.current?m.current.scrollTop:0,tt=E.current<=0&&O<=0;(j.current||tt)&&I>0?(b.current=I,d(I)):(b.current=0,d(0))},ot=()=>{p(!1),j.current=!1,b.current>80?(u(!0),setTimeout(()=>{mt()},250)):(d(0),b.current=0),g.current=0};if((0,wt.useEffect)(()=>{if(!S)return;let R=St=>{Y(St.clientY)},I=()=>{ot()},O=St=>{St.cancelable&&St.preventDefault(),St.touches&&St.touches[0]&&Y(St.touches[0].clientY)},tt=()=>{ot()};return window.addEventListener("pointermove",R),window.addEventListener("pointerup",I),window.addEventListener("touchmove",O,{passive:!1}),window.addEventListener("touchend",tt),()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",I),window.removeEventListener("touchmove",O),window.removeEventListener("touchend",tt)}},[S]),!L||!e||v||!_)return null;let J=L.details,H=J.styling||{},K=H.appearance||{},it=K.backdropColor||"#000000",xt=Js(K.backdropOpacity),ut=x?.multipleSelection!==!1&&x?.isMultiSelect!==!1&&H.options?.multipleSelection!==!1,Z=R=>{k(ut?I=>I.includes(R)?I.filter(O=>O!==R):[...I,R]:I=>I[0]===R?[]:[R])},rt=async(R,I)=>{let O=f.map(Lt=>({slide_id:Lt.id,order:Lt.order,title:Lt.title,question:Lt.question,selected_options:R[Lt.id]?.options,comment:R[Lt.id]?.comment})),tt=L.id,St=[];for(let Lt of f){let Zt=R[Lt.id]?.options||[];for(let It of Zt){let ce=Object.entries(Lt.options||{}).find(([,xe])=>String(xe)===String(It));ce&&St.push(ce[0])}}let zt=O.map(Lt=>Lt.comment).filter(Boolean).join(" || ")||"",Tt=J.id||tt;st("survey captured",Tt,{survey_id:J.id,slide_id:I,selected_options:St,otherText:zt}),H.content?.isThankyouPage!==!1?M(!0):w(!0)},dt=async()=>{if(!x||T.length===0)return;let R={...V,[x.id]:{options:T,comment:B}};G(R);let I=[];if(x.options)for(let zt of T){let Tt=Object.entries(x.options).find(([,Yt])=>String(Yt)===String(zt));Tt&&I.push(Tt[0])}try{let zt=L.id,Tt=J.id||zt;st("survey captured",Tt,{survey_id:J.id,slide_id:x.id,selected_options:I,otherText:B||""})}catch(zt){console.warn("Error sending per-slide survey captured",zt)}let O=T.includes("__others__"),tt={action:"none"};for(let zt of x.logic||[]){let Tt=zt.selectOption||[];if(Tt.length===0)continue;let Yt=Tt.some(It=>I.includes(It)),Lt=Tt.some(It=>T.includes(It)),Zt=O&&Tt.some(It=>It==="others"||It==="__others__");if(!(!Yt&&!Lt&&!Zt)&&zt.redirectTo){let It=Ks(zt.redirectTo,f);if(It.action!=="none"){tt=It;break}}}if(tt.action==="thankyou"){await rt(R,x.id);return}if(tt.action==="jump"){A(tt.targetIndex);return}if(U>=f.length-1){await rt(R,x.id);return}A(zt=>Math.min(zt+1,f.length-1))},ht=()=>{let R=J.thankYouButtonConfig;if(R?.enabled&&R.redirectUrl){try{let I=String(R.redirectUrl||"").trim();if(I&&!I.startsWith("http")&&Nt(I)){w(!0);return}}catch(I){console.warn("revealCampaignFromLink error",I)}try{globalThis.open(R.redirectUrl,"_blank")}catch{}}w(!0)},mt=async()=>{try{let R=L?.id,I=J?.id,O=x?.id;await st("SurveyDismissed",R,{survey_id:I,slide_id:O})}catch(R){console.warn("Error sending SurveyDismissed",R)}finally{w(!0)}};return x?D?(0,at.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"center",alignItems:"flex-end",padding:0,boxSizing:"border-box",pointerEvents:"auto",touchAction:"none",overscrollBehavior:"none"},children:[(0,at.jsx)("div",{"aria-hidden":!0,onClick:()=>{u(!0),setTimeout(()=>mt(),250)},onTouchMove:R=>{R.cancelable&&R.preventDefault()},style:{position:"absolute",inset:0,background:Rr(it,y?0:xt),transition:S?"none":"background 0.25s ease-out",zIndex:1,touchAction:"none"}}),(0,at.jsxs)("div",{onPointerDown:R=>{let I=R.target;I&&I.closest("button, input, textarea, a")||z(R.clientY,!1)},onTouchStart:R=>{let I=R.target;I&&I.closest("button, input, textarea, a")||R.touches&&R.touches[0]&&z(R.touches[0].clientY,!1)},style:{position:"relative",zIndex:2,width:"100%",maxWidth:"520px",maxHeight:"85vh",backgroundColor:K.backgroundColor||"#ffffff",borderTopLeftRadius:`${K.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${K.cornerRadius?.topRight??16}px`,borderBottomLeftRadius:0,borderBottomRightRadius:0,boxSizing:"border-box",paddingTop:10,paddingRight:16,paddingBottom:"max(14px, env(safe-area-inset-bottom, 14px))",paddingLeft:16,boxShadow:"0 -8px 32px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column",overflow:"hidden",touchAction:"none",overscrollBehavior:"contain",transform:y?"translateY(100%)":C?`translateY(${c}px)`:"translateY(100%)",transition:S?"none":"transform 0.28s cubic-bezier(0.25, 1, 0.5, 1)"},children:[(0,at.jsx)("style",{children:`
92
139
  .appstorys-survey-scroll {
93
- scrollbar-width: none; /* Firefox */
94
- -ms-overflow-style: none; /* IE/Edge */
140
+ scrollbar-width: none;
141
+ -ms-overflow-style: none;
95
142
  }
96
143
  .appstorys-survey-scroll::-webkit-scrollbar {
97
144
  width: 0;
98
145
  height: 0;
99
- display: none; /* Chrome/Safari */
146
+ display: none;
100
147
  }
101
- `}),T.crossButton?.enabled&&(0,J.jsx)(Qt,{config:T.crossButton,onPress:W,style:{top:T.crossButton?.margin?.top??10,right:T.crossButton?.margin?.right??10}}),(0,J.jsx)("div",{className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingRight:2},children:w?(0,J.jsx)(Dr,{details:d,onDone:S}):(0,J.jsx)(Lr,{details:d,slide:R,appearance:l,selectedOption:g,comment:f,onSelectOption:A,onCommentChange:b,onSubmit:C,canSubmit:g!=null})})]})]}):null},wi=_r;var tn=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 Lo();m&&m!==n&&console.log("AppStorys: Found previous anonymous user, will reconcile after verification."),r=n,s=!1}if(!await Vt(i,o,r)){this.state="error";return}if(!s){let m=await Lo();m&&m!==r&&(await Je(m,r),await Po())}try{let m=await lt(),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 zo(i);try{Rn(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(()=>(Bi(),zi))).mountScreenCaptureButton()}catch(m){console.warn("Failed to mount screen capture button",m)}An.setup(),Eo.setup(),this.state="initialized"}catch(r){this.state="error",console.error("AppStorys initialization failed:",r)}}}async reconcileUser(e,o,i,n){try{if(!await Vt(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 Po();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(),Ro(e)}async trackEvent(e,o,i){return await this.ensureInitialized(),H(e,o,i)}async setUserProperties(e){return await this.ensureInitialized(),To(e)}handleLink(e){if(e){if(typeof e=="string"){try{if(!e.startsWith("http")&&vt(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(vt(e.value))return}catch{}this.navigateToScreen?.(e.value)}}}get visibility(){return F.getState().isVisible}set visibility(e){Eo.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 Te(e)}},jr=new tn;0&&(module.exports={AppStorys,Banner,BottomSheet,Csat,Floater,Pip,SdkState,Story,Survey,Tooltip,Widget,personalizeText});
148
+ `}),(0,at.jsx)("div",{onPointerDown:R=>{R.stopPropagation(),z(R.clientY,!0)},onTouchStart:R=>{R.stopPropagation(),R.touches&&R.touches[0]&&z(R.touches[0].clientY,!0)},style:{width:"40px",height:"4px",backgroundColor:"#D1D5DB",borderRadius:"2px",margin:"0 auto 8px auto",flexShrink:0,cursor:"grab",touchAction:"none",userSelect:"none"}}),H.crossButton?.enabled&&(0,at.jsx)(Ot,{config:H.crossButton,onPress:()=>{u(!0),setTimeout(()=>mt(),250)},style:{top:H.crossButton?.margin?.top!==void 0&&H.crossButton.margin.top>=0?H.crossButton.margin.top:10,right:H.crossButton?.margin?.right!==void 0&&H.crossButton.margin.right>=0?H.crossButton.margin.right:10,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0}}),(0,at.jsx)("div",{ref:m,className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",overscrollBehavior:"contain",touchAction:"pan-y",paddingRight:2,WebkitOverflowScrolling:"touch"},children:r?(0,at.jsx)(Ir,{details:J,onDone:ht}):(0,at.jsx)(zr,{details:J,slide:x,appearance:K,selectedOptions:T,comment:B,onSelectOption:Z,onCommentChange:$,onSubmit:dt,canSubmit:T.length>0})})]})]}):(0,at.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"flex-end",alignItems:"flex-end",padding:16,boxSizing:"border-box",pointerEvents:"none"},children:[(0,at.jsx)("div",{"aria-hidden":!0,onClick:mt,style:{position:"absolute",inset:0,background:Rr(it,xt),pointerEvents:xt>0?"auto":"none",zIndex:1}}),(0,at.jsxs)("div",{style:{position:"relative",zIndex:2,width:"min(420px, 92vw)",maxWidth:"92vw",minWidth:"320px",maxHeight:"80vh",overflow:"hidden",backgroundColor:K.backgroundColor||"#ffffff",borderRadius:Wo(K.cornerRadius,12),boxSizing:"border-box",paddingTop:14,paddingRight:16,paddingBottom:10,paddingLeft:16,pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"},children:[(0,at.jsx)("style",{children:`
149
+ .appstorys-survey-scroll {
150
+ scrollbar-width: none;
151
+ -ms-overflow-style: none;
152
+ }
153
+ .appstorys-survey-scroll::-webkit-scrollbar {
154
+ width: 0;
155
+ height: 0;
156
+ display: none;
157
+ }
158
+ `}),H.crossButton?.enabled&&(0,at.jsx)(Ot,{config:H.crossButton,onPress:mt,style:{top:H.crossButton?.margin?.top!==void 0&&H.crossButton.margin.top>=0?H.crossButton.margin.top:10,right:H.crossButton?.margin?.right!==void 0&&H.crossButton.margin.right>=0?H.crossButton.margin.right:10,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0}}),(0,at.jsx)("div",{className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingRight:2},children:r?(0,at.jsx)(Ir,{details:J,onDone:ht}):(0,at.jsx)(zr,{details:J,slide:x,appearance:K,selectedOptions:T,comment:B,onSelectOption:Z,onCommentChange:$,onSubmit:dt,canSubmit:T.length>0})})]})]}):null},Lr=oa;var vo=require("react");bt();var he=require("react");var So=ge(require("lottie-react")),Dt=require("react/jsx-runtime"),na=So.default?.default??So.default??So.Lottie??So,Er=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},ia=t=>{if(!t)return null;if(typeof t=="string"){let e=t.trim();return e.length>0?e:null}if(typeof t=="object"){let e=typeof t.url=="string"?t.url.trim():"";if(e)return e;let o=typeof t.value=="string"?t.value.trim():"";if(o)return o;let n=typeof t.pageName=="string"?t.pageName.trim():"";if(n)return n;let i=typeof t.key=="string"?t.key.trim():"";if(i)return i}return null},ra=(t,e,o)=>{let n=ia(t);if(n){if(e){let i=o?._variantId||o?.details?.id;st("clicked",e,i?{variant_id:i}:void 0)}if(!n.startsWith("http"))try{if(Nt(n))return}catch{}try{window.open(n,"_blank")}catch{}}},Ar=({campaign:t,onDismiss:e})=>{let[o,n]=(0,he.useState)(typeof window<"u"?window.innerWidth:1024),[i,s]=(0,he.useState)(null),[l,c]=(0,he.useState)(!0),d=(0,he.useRef)(null);(0,he.useEffect)(()=>{if(typeof window>"u")return;let x=()=>n(window.innerWidth);window.addEventListener("resize",x);let z=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("resize",x),document.body.style.overflow=z}},[]);let{details:S}=t,p=S?.modals?.[0],y=p?.content||{},u=p?.styling||{},C=y?.chooseMediaType||p?.chooseMediaType,h=C?.type,g=C?.url;if((0,he.useEffect)(()=>{h==="lottie"&&g?(s(null),fetch(g).then(x=>x.json()).then(x=>s(x)).catch(x=>console.error("Error fetching Lottie in ModalWithCta:",x))):s(null)},[h,g]),(0,he.useEffect)(()=>{d.current&&(d.current.muted=l)},[l]),(0,he.useEffect)(()=>{let x=d.current;if(!x||h!=="video")return;x.muted=!1;let z=x.play();z!==void 0&&z.then(()=>{c(!1)}).catch(()=>{x.muted=!0,c(!0),x.play().catch(()=>{})})},[g,h]),!p)return null;let b=u.appearance||{},m=u.crossButton,E=b.backdrop?.color||"rgba(0, 0, 0, 0.4)",j=b.backdrop?.opacity!==void 0&&b.backdrop?.opacity!==null?b.backdrop.opacity>1?b.backdrop.opacity/100:b.backdrop.opacity:0,D=b.enableBackdrop!==!1,L=b.dimension?.width!==void 0&&b.dimension?.width!==null&&b.dimension.width>0?b.dimension.width:300,v=o>=768,w=v?L*1.4:L,_=Math.min(w,o*.9),N=b.cornerRadius||{},U=b.backgroundColor||"#FFFFFF",A=y.titleText||"",T=y.subtitleText||"",k=y.primaryCtaText||"",B=y.secondaryCtaText||"",$=y.primaryCtaRedirection,V=y.secondaryCtaRedirection,G=u.title||{},r=u.subTitle||{},M=u.primaryCta||{},a=u.secondaryCta||{},f=(x,z,Y,ot=!1)=>{if(!x||x.trim()==="")return null;let J=z?.container||{},H=z?.cornerRadius||{},K=z?.margin||{},it=z?.text||{},xt=O=>O==="left"?"flex-start":O==="right"?"flex-end":"center",ut=J.ctaWidth,Z=v&&ut?ut*1.4:ut,rt=J.height||40,dt=v?rt*1.2:rt,ht=H.topLeft!==void 0&&H.topLeft>=0?H.topLeft:8,mt=H.topRight!==void 0&&H.topRight>=0?H.topRight:8,R=H.bottomRight!==void 0&&H.bottomRight>=0?H.bottomRight:8,I=H.bottomLeft!==void 0&&H.bottomLeft>=0?H.bottomLeft:8;return(0,Dt.jsx)("div",{style:{display:"flex",justifyContent:xt(J.alignment),width:ot?"auto":"100%",flex:ot?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:(0,Dt.jsx)("button",{style:{width:ot||J.ctaFullWidth?"100%":Z?`${Z}px`:"auto",height:dt,backgroundColor:J.backgroundColor||"#FE6B35",color:it.color||"#FFFFFF",border:`${J.borderWidth||0}px solid ${J.borderColor||"transparent"}`,borderRadius:`${ht}px ${mt}px ${R}px ${I}px`,fontSize:it.fontSize||14,fontFamily:lt(it.fontFamily)||"Arial",fontWeight:it.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:it.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:it.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px",outline:"none",boxSizing:"border-box"},onClick:()=>ra(Y,t?.id,t),children:Pe(x)})})};return(0,Dt.jsxs)(Dt.Fragment,{children:[(0,Dt.jsx)("style",{children:`
159
+ .appstorys-modal-scroll::-webkit-scrollbar { display: none; }
160
+ .appstorys-modal-scroll { scrollbar-width: none; }
161
+ `}),(0,Dt.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:D?E:"transparent",opacity:D?j:1,zIndex:999998,transition:"opacity 0.3s ease"}}),(0,Dt.jsxs)("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:_,maxWidth:"95vw",zIndex:999999,overflow:"visible"},children:[(m?.enabled??!0)&&(0,Dt.jsx)(Ot,{config:m||{enabled:!0},onPress:x=>{x&&typeof x.stopPropagation=="function"&&x.stopPropagation(),e()},style:{position:"absolute",zIndex:1e7,top:m?.margin?.top!==void 0&&m.margin?.top>=0?m.margin.top:8,right:m?.margin?.right!==void 0&&m.margin?.right>=0?m.margin.right:8}}),(0,Dt.jsxs)("div",{style:{width:"100%",backgroundColor:U,borderTopLeftRadius:N.topLeft!==void 0&&N.topLeft>=0?N.topLeft:0,borderTopRightRadius:N.topRight!==void 0&&N.topRight>=0?N.topRight:0,borderBottomLeftRadius:N.bottomLeft!==void 0&&N.bottomLeft>=0?N.bottomLeft:0,borderBottomRightRadius:N.bottomRight!==void 0&&N.bottomRight>=0?N.bottomRight:0,overflow:"hidden",boxShadow:"0 8px 32px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",maxHeight:"90vh"},children:[(0,Dt.jsxs)("div",{className:"appstorys-modal-scroll",style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",alignItems:"center",minHeight:0},children:[g&&(h==="image"||!h)&&(0,Dt.jsx)("img",{src:g,alt:"",style:{width:"100%",display:"block"}}),g&&h==="video"&&(0,Dt.jsxs)("div",{style:{position:"relative",width:"100%"},children:[(0,Dt.jsx)("video",{ref:d,src:g,autoPlay:!0,loop:!0,muted:l,playsInline:!0,controls:!1,style:{width:"100%",display:"block"}}),(0,Dt.jsx)(Me,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(0,0,0,0.45)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:x=>{x.stopPropagation(),c(z=>!z)},type:l?"mute":"unmute",enabled:!0,style:{position:"absolute",zIndex:1e7,bottom:12,left:12,borderRadius:"50%"}})]}),g&&h==="lottie"&&i&&(()=>{let x=i.w,z=i.h,Y=x&&z&&x>0?z/x:void 0,ot=_,J=Y?Math.round(ot*Y):void 0;return(0,Dt.jsx)(na,{animationData:i,loop:!0,autoplay:!0,style:{width:ot,height:J,display:"block"}})})(),A.trim()!==""&&(0,Dt.jsx)("div",{style:{width:"100%",padding:"12px 16px 0 16px",color:G.color||"#000000",fontSize:G.fontSize||26,fontFamily:lt(G.fontFamily)||"Helvetica",fontWeight:G.fontDecoration?.includes("bold")?"bold":"600",fontStyle:G.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:G.fontDecoration?.includes("underline")?"underline":"none",textAlign:Er(G.textAlign)||"center",boxSizing:"border-box"},children:Pe(A)}),T.trim()!==""&&(0,Dt.jsx)("div",{style:{width:"100%",padding:"4px 16px 0 16px",color:r.color||"#000000",fontSize:r.fontSize||20,fontFamily:lt(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:Er(r.textAlign)||"center",boxSizing:"border-box"},children:Pe(T)})]}),(k.trim()!==""||B.trim()!=="")&&(0,Dt.jsxs)("div",{style:{flexShrink:0,width:"100%",padding:"0 12px 12px 12px",boxSizing:"border-box",display:"flex",flexDirection:k.trim()!==""&&B.trim()!==""?"row":"column",gap:"8px",justifyContent:"center"},children:[f(k,M,$,k.trim()!==""&&B.trim()!==""),f(B,a,V,k.trim()!==""&&B.trim()!=="")]})]})]})]})};var be=require("react");var Co=ge(require("lottie-react")),Qt=require("react/jsx-runtime"),sa=Co.default?.default??Co.default??Co.Lottie??Co,Mr=t=>{if(!t)return null;if(typeof t=="string"){let e=t.trim();return e.length>0?e:null}if(typeof t=="object"){let e=typeof t.url=="string"?t.url.trim():"";if(e)return e;let o=typeof t.value=="string"?t.value.trim():"";if(o)return o;let n=typeof t.pageName=="string"?t.pageName.trim():"";if(n)return n;let i=typeof t.key=="string"?t.key.trim():"";if(i)return i}return null},aa=(t,e,o)=>{let n=Mr(t);if(n){if(e){let i=o?._variantId||o?.details?.id;st("clicked",e,i?{variant_id:i}:void 0)}if(!n.startsWith("http"))try{if(Nt(n))return}catch{}try{window.open(n,"_blank")}catch{}}},Pr=({campaign:t,onDismiss:e})=>{let[o,n]=(0,be.useState)(typeof window<"u"?window.innerWidth:1024),[i,s]=(0,be.useState)(null),[l,c]=(0,be.useState)(!0),d=(0,be.useRef)(null);(0,be.useEffect)(()=>{if(typeof window>"u")return;let A=()=>n(window.innerWidth);window.addEventListener("resize",A);let T=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("resize",A),document.body.style.overflow=T}},[]);let{details:S}=t,p=S?.modals?.[0],y=p?.chooseMediaType,u=p?.styling||{},C=p?.redirection,h=y?.type,g=y?.url;if((0,be.useEffect)(()=>{h==="lottie"&&g?(s(null),fetch(g).then(A=>A.json()).then(A=>s(A)).catch(A=>console.error("Error fetching Lottie in MediaOnlyModal:",A))):s(null)},[h,g]),(0,be.useEffect)(()=>{d.current&&(d.current.muted=l)},[l]),(0,be.useEffect)(()=>{let A=d.current;if(!A||h!=="video")return;A.muted=!1;let T=A.play();T!==void 0&&T.then(()=>{c(!1)}).catch(()=>{A.muted=!0,c(!0),A.play().catch(()=>{})})},[g,h]),!p||!y||!g)return null;let b=u.appearance||{},m=u.crossButton,E=b.backdrop?.color||"rgba(0, 0, 0, 0.4)",j=b.backdrop?.opacity!==void 0&&b.backdrop?.opacity!==null?b.backdrop.opacity>1?b.backdrop.opacity/100:b.backdrop.opacity:0,D=b.enableBackdrop!==!1,L=b.dimension?.width!==void 0&&b.dimension?.width!==null&&b.dimension.width>0?b.dimension.width:300,w=o>=768?L*1.4:L,_=Math.min(w,o*.9),N=b.cornerRadius||{},U=b.backgroundColor||(h==="lottie"?"transparent":"#FFFFFF");return(0,Qt.jsxs)(Qt.Fragment,{children:[(0,Qt.jsx)("style",{children:`
162
+ .appstorys-media-modal-scroll::-webkit-scrollbar { display: none; }
163
+ .appstorys-media-modal-scroll { scrollbar-width: none; }
164
+ `}),(0,Qt.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:D?E:"transparent",opacity:D?j:1,zIndex:999998,transition:"opacity 0.3s ease"}}),(0,Qt.jsxs)("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:_,maxWidth:"95vw",zIndex:999999,overflow:"visible"},children:[(m?.enabled??!0)&&(0,Qt.jsx)(Ot,{config:m||{enabled:!0},onPress:A=>{A&&typeof A.stopPropagation=="function"&&A.stopPropagation(),e()},style:{position:"absolute",zIndex:1e7,top:m?.margin?.top!==void 0&&m.margin?.top>=0?m.margin.top:8,right:m?.margin?.right!==void 0&&m.margin?.right>=0?m.margin.right:8}}),(0,Qt.jsx)("div",{className:"appstorys-media-modal-scroll",style:{width:"100%",backgroundColor:U,borderTopLeftRadius:N.topLeft!==void 0&&N.topLeft>=0?N.topLeft:0,borderTopRightRadius:N.topRight!==void 0&&N.topRight>=0?N.topRight:0,borderBottomLeftRadius:N.bottomLeft!==void 0&&N.bottomLeft>=0?N.bottomLeft:0,borderBottomRightRadius:N.bottomRight!==void 0&&N.bottomRight>=0?N.bottomRight:0,overflow:"hidden",boxShadow:U==="transparent"?"none":"0 8px 32px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",alignItems:"center",maxHeight:"90vh",overflowY:"auto"},children:(()=>{let A=!!Mr(C);return(0,Qt.jsxs)("div",{onClick:A?()=>aa(C,t?.id,t):void 0,style:{width:"100%",cursor:A?"pointer":"default",minHeight:0},children:[g&&(h==="image"||!h)&&(0,Qt.jsx)("img",{src:g,alt:"",style:{width:"100%",display:"block"}}),g&&h==="video"&&(0,Qt.jsxs)("div",{style:{position:"relative",width:"100%"},children:[(0,Qt.jsx)("video",{ref:d,src:g,autoPlay:!0,loop:!0,muted:l,playsInline:!0,controls:!1,style:{width:"100%",display:"block"}}),(0,Qt.jsx)(Me,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(0,0,0,0.45)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:T=>{T.stopPropagation(),c(k=>!k)},type:l?"mute":"unmute",enabled:!0,style:{position:"absolute",zIndex:1e7,bottom:12,left:12,borderRadius:"50%"}})]}),g&&h==="lottie"&&i&&(()=>{let T=i.w,k=i.h,B=T&&k&&T>0?k/T:void 0,$=_,V=B?Math.round($*B):void 0;return(0,Qt.jsx)(sa,{animationData:i,loop:!0,autoplay:!0,style:{width:$,height:V,display:"block"}})})()]})})()})]})]})};var Kn=require("react/jsx-runtime"),Dr=()=>{let t=Mt("MOD"),e=P(C=>C.campaigns),o=P(C=>C.allCampaigns),n=P(C=>C.currentScreen),i=t??(()=>{let C=(n||"").trim().toLowerCase(),h=[...e||[],...o||[]].find(g=>{if(!g||g.campaign_type!=="MOD")return!1;let b=!!(g.trigger_event??g.trigger);if(!(g.display_trigger!==!1&&!b))return!1;let E=(g.screen||"").trim().toLowerCase();return!E||E===C});if(h)try{return Ht(h)}catch{return h}})(),s=P(C=>C.isVisible),[l,c]=(0,vo.useState)(!1),d=(0,vo.useRef)(null);(0,vo.useEffect)(()=>{if(i?.id&&d.current!==i.id){d.current=i.id,c(!1);let C=i._variantId||i.details?.id,h=C?{variant_id:C}:void 0;st("viewed",i.id,h)}},[i?.id]);let S=C=>{try{let h=P.getState(),b=(h.trackedEvents||[]).filter(m=>m!==C);h.setTrackedEvents(b)}catch{}};if(!i||l||!s)return null;let p=()=>{i?.id&&S(`viaAppStorys${i.id}`),c(!0)},y=i.details?.modal_type||i.details?.modals?.[0]?.modal_type||"";return y==="full-page-modal"||y==="media-only-modal"?(0,Kn.jsx)(Pr,{campaign:i,onDismiss:p}):(0,Kn.jsx)(Ar,{campaign:i,onDismiss:p})};var Wr=require("react/jsx-runtime"),_r=({id:t,children:e})=>(0,Wr.jsx)("div",{"data-as-id":t,style:{display:"contents"},children:e});var Zn=class{state="uninitialized";navigateToScreen;async initialize(e){let{appId:o,accountId:n,userId:i}=e;if(this.navigateToScreen=e.navigateToScreen,this.state!=="initializing"){if(this.state==="initialized"){let s=P.getState();if(s.isAnonymousUser&&i&&i.trim()!==""){console.log("AppStorys: Reconciling anonymous user with identified user..."),await this.reconcileUser(s.userId,i,o,n);return}if(s.appId===o&&s.accountId===n&&s.userId===i)return}this.state="initializing";try{let s,l;if(!i||i.trim()==="")s=await Ai(),l=!0;else{let y=await An();y&&y!==i&&console.log("AppStorys: Found previous anonymous user, will reconcile after verification."),s=i,l=!1}if(!await Ae(n,o,s)){this.state="error";return}if(!l){let y=await An();y&&y!==s&&(await Ko(y,s),await En())}try{let y=await At(),u=e.baseUrl||"https://users.appstorys.co";fetch(`${u}/v2/${n}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...y?{Authorization:`Bearer ${y}`}:{}},body:JSON.stringify({user_id:s,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})}).then(async C=>{if(C.ok)try{let h=await C.json(),g=P.getState();if(typeof h.screen_capture_enabled<"u"){let b=!!h.screen_capture_enabled;console.info("AppStorys: track-user-res returned screen_capture_enabled=",b),g.setScreenCaptureEnabled(b)}}catch{}}).catch(C=>console.warn("track-user-res (init) failed",C))}catch(y){console.warn("track-user-res (init) setup failed",y)}let{campaigns:d,version:S}=await zn(n);try{xi(d)}catch(y){console.warn("Failed to preload campaign fonts",y)}let p=P.getState();p.setAppId(o),p.setAccountId(n),p.setUserId(s),p.setIsAnonymousUser(l),p.setBaseUrl(e.baseUrl),p.setTrackingUrl(e.trackingUrl),p.saveAllCampaigns(d),p.setCampaignVersion(S);try{P.getState().screenCaptureEnabled&&(await Promise.resolve().then(()=>(Hr(),qr))).mountScreenCaptureButton()}catch(y){console.warn("Failed to mount screen capture button",y)}Li.setup(),Ln.setup(),this.state="initialized"}catch(s){this.state="error",console.error("AppStorys initialization failed:",s)}}}async reconcileUser(e,o,n,i){try{if(!await Ae(i,n,o)){console.error("AppStorys: Failed to verify identified user account during reconciliation.");return}if(!await Ko(e,o)){console.error("AppStorys: Failed to reconcile anonymous and identified users.");return}await En();let c=P.getState();c.setUserId(o),c.setIsAnonymousUser(!1)}catch(s){console.error("AppStorys: Error during user reconciliation:",s)}}async trackScreen(e){return await this.ensureInitialized(),kn(e)}async trackEvent(e,o,n){return await this.ensureInitialized(),st(e,o,n)}async setUserProperties(e){return await this.ensureInitialized(),Rn(e)}handleLink(e){if(e){if(typeof e=="string"){try{if(!e.startsWith("http")&&Nt(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(Nt(e.value))return}catch{}this.navigateToScreen?.(e.value)}}}get visibility(){return P.getState().isVisible}set visibility(e){Ln.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 Pe(e)}},ga=new Zn;0&&(module.exports={AppStorys,Banner,BottomSheet,Csat,Floater,Modal,Pip,SdkState,Story,Survey,Tooltip,Trackable,Widget,getCampaignVariantId,getVariantId,hasVariants,personalizeText,resolveCampaignVariant,selectVariantByWeight});
102
165
  //# sourceMappingURL=index.js.map