{"version":3,"file":"BrowserTabNotify.CsG2CIVE.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/Bp7lHrnXmIrDJtFo5QP8/HY4pFTdcgxGM5DpSChEz/BrowserTabNotify.js"],"sourcesContent":["// Browser Tab Notify - Capture attention with rotating tab notifications and custom favicons\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n * @framerDisableUnlink\n */export default function BrowserTabNotify(props){const{notifications=[{message:\"Don't miss out! 👀\"},{message:\"Limited time offer! 🎯\"}],rotationInterval=2e3,delayBeforeNotification=0,maxRotationCount=0,enableWelcomeBack=true,welcomeNotification={message:\"Thanks for coming back! 🎉\"},welcomeDuration=3e3}=props;// Store original page title and favicon\nconst originalTitleRef=useRef(\"\");const originalFaviconRef=useRef(\"\");const welcomeTimeoutRef=useRef(null);const rotationIntervalRef=useRef(null);const delayTimerRef=useRef(null);const currentIndexRef=useRef(0);const rotationCountRef=useRef(0);// Detect canvas mode\nconst renderContext=RenderTarget.current();const isCanvasMode=renderContext===RenderTarget.canvas;/**\n     * Updates the browser favicon dynamically\n     * @param iconUrl - URL of the new favicon image\n     */const updateFavicon=iconUrl=>{if(typeof document===\"undefined\")return;// Find existing favicon link element\nlet faviconLink=document.querySelector(\"link[rel*='icon']\");if(!faviconLink){// Create new favicon link if none exists\nfaviconLink=document.createElement(\"link\");faviconLink.rel=\"icon\";document.head.appendChild(faviconLink);}faviconLink.href=iconUrl;};/**\n     * Restores the original browser favicon\n     */const restoreFavicon=()=>{if(originalFaviconRef.current){updateFavicon(originalFaviconRef.current);}};/**\n     * Clears the delay timer\n     */const clearDelayTimer=()=>{if(delayTimerRef.current){window.clearTimeout(delayTimerRef.current);delayTimerRef.current=null;}};useEffect(()=>{// Skip in canvas or static contexts\nif(isCanvasMode||typeof document===\"undefined\")return;// Store original page title\noriginalTitleRef.current=document.title;// Store original favicon URL\nconst existingFavicon=document.querySelector(\"link[rel*='icon']\");if(existingFavicon){originalFaviconRef.current=existingFavicon.href;}/**\n         * Cycles through notification messages and updates favicon if provided\n         * Only active when user has left the page\n         */const startNotificationCycle=()=>{// Clear any existing rotation\nif(rotationIntervalRef.current){window.clearInterval(rotationIntervalRef.current);rotationIntervalRef.current=null;}// Reset rotation count and index\nrotationCountRef.current=1// Start at 1 since we're showing the first cycle\n;currentIndexRef.current=0;// Filter out empty notifications\nconst validNotifications=notifications.filter(n=>n.message&&n.message.trim()!==\"\");if(validNotifications.length===0)return;// Display first notification immediately\nconst firstNotif=validNotifications[0];document.title=firstNotif.message;// Update favicon if provided\nif(firstNotif.favicon?.src){updateFavicon(firstNotif.favicon.src);}// Only set up rotation if multiple notifications exist\nif(validNotifications.length>1){rotationIntervalRef.current=window.setInterval(()=>{// Move to next notification\ncurrentIndexRef.current=(currentIndexRef.current+1)%validNotifications.length;// If we've cycled back to the first message, increment the cycle count\nif(currentIndexRef.current===0){rotationCountRef.current++;}// Check if max rotation count is reached BEFORE showing the message\nif(maxRotationCount>0&&rotationCountRef.current>maxRotationCount){// Stop rotation and restore original state\nstopNotificationCycle();document.title=originalTitleRef.current;restoreFavicon();return;}const notification=validNotifications[currentIndexRef.current];document.title=notification.message;// Update favicon if provided, otherwise restore original\nif(notification.favicon?.src){updateFavicon(notification.favicon.src);}else{restoreFavicon();}},rotationInterval);}};/**\n         * Stops notification cycle and clears interval\n         */const stopNotificationCycle=()=>{if(rotationIntervalRef.current){window.clearInterval(rotationIntervalRef.current);rotationIntervalRef.current=null;}};/**\n         * Handles tab visibility changes\n         * Manages notifications based on user presence\n         */const handleVisibilityChange=()=>{// Clear welcome message timeout\nif(welcomeTimeoutRef.current){window.clearTimeout(welcomeTimeoutRef.current);welcomeTimeoutRef.current=null;}if(document.hidden){// User switched away\nclearDelayTimer();// Apply delay before showing notifications if configured\nif(delayBeforeNotification>0){delayTimerRef.current=window.setTimeout(()=>{startNotificationCycle();},delayBeforeNotification);}else{// Start notifications immediately\nstartNotificationCycle();}}else{// User returned - stop notifications\nclearDelayTimer();stopNotificationCycle();if(enableWelcomeBack){// Show welcome message with optional custom favicon\ndocument.title=welcomeNotification.message;// Update favicon if provided in welcome notification\nif(welcomeNotification.favicon?.src){updateFavicon(welcomeNotification.favicon.src);}else{restoreFavicon();}// Reset to original title and favicon after duration\nwelcomeTimeoutRef.current=window.setTimeout(()=>{document.title=originalTitleRef.current;restoreFavicon();welcomeTimeoutRef.current=null;},welcomeDuration);}else{// Immediately restore original title and favicon\ndocument.title=originalTitleRef.current;restoreFavicon();}}};// Attach visibility listener\ndocument.addEventListener(\"visibilitychange\",handleVisibilityChange);// Cleanup on unmount\nreturn()=>{document.removeEventListener(\"visibilitychange\",handleVisibilityChange);// Clear all timers\nstopNotificationCycle();clearDelayTimer();if(welcomeTimeoutRef.current){window.clearTimeout(welcomeTimeoutRef.current);}// Restore original state\ndocument.title=originalTitleRef.current;restoreFavicon();};},[notifications,rotationInterval,delayBeforeNotification,maxRotationCount,enableWelcomeBack,welcomeNotification,welcomeDuration,isCanvasMode]);// Return invisible component\nreturn /*#__PURE__*/_jsx(\"div\",{style:{display:\"none\"}});}// Set display name for Framer canvas\nBrowserTabNotify.displayName=\"Browser Tab Notify\";// Property controls configuration\naddPropertyControls(BrowserTabNotify,{notifications:{type:ControlType.Array,title:\"Notifications\",description:\"Create eye-catching tab alerts with custom messages and optional favicons. Each notification will rotate when visitors switch away from your page.\",control:{type:ControlType.Object,controls:{message:{type:ControlType.String,title:\"Message\",description:\"The attention-grabbing text displayed in the browser tab\",defaultValue:\"Don't miss out! 👀\",placeholder:\"e.g., Come back for 20% off!\"},favicon:{type:ControlType.ResponsiveImage,title:\"Favicon\",description:\"Optional custom favicon (16x16px recommended). If not provided, the default favicon will be used.\",optional:true}}},defaultValue:[{message:\"Don't miss out! 👀\"},{message:\"Limited time offer! 🎯\"}],maxCount:10},rotationInterval:{type:ControlType.Number,title:\"Rotation Speed\",description:\"How long each notification displays before switching to the next (only applies with 2+ notifications)\",defaultValue:2e3,min:500,max:1e4,step:500,unit:\"ms\",displayStepper:true,hidden:props=>!props.notifications||props.notifications.length<2},delayBeforeNotification:{type:ControlType.Number,title:\"Activation Delay\",description:\"Wait this long after user switches tabs before showing notifications. Set to 0 for instant display. Helps avoid alerts during quick tab switches.\",defaultValue:0,min:0,max:1e4,step:500,unit:\"ms\",displayStepper:true},maxRotationCount:{type:ControlType.Number,title:\"Max Cycles\",description:\"Limit how many times notifications cycle through before stopping. Set to 0 for unlimited rotation. Prevents user annoyance.\",defaultValue:0,min:0,max:50,step:1,displayStepper:true,hidden:props=>!props.notifications||props.notifications.length<2},enableWelcomeBack:{type:ControlType.Boolean,title:\"Welcome Back\",description:\"Show a friendly message when visitors return to re-engage them\",defaultValue:true,enabledTitle:\"Enabled\",disabledTitle:\"Disabled\"},welcomeNotification:{type:ControlType.Object,title:\"Welcome Notification\",description:\"Configure the message and optional favicon shown when visitors return\",controls:{message:{type:ControlType.String,title:\"Message\",description:\"The welcome text displayed in the browser tab\",defaultValue:\"Thanks for coming back! 🎉\",placeholder:\"e.g., Welcome back!\"},favicon:{type:ControlType.ResponsiveImage,title:\"Favicon\",description:\"Optional custom favicon for welcome message (16x16px recommended). If not provided, the original favicon will be restored.\",optional:true}},defaultValue:{message:\"Thanks for coming back! 🎉\"},hidden:props=>!props.enableWelcomeBack},welcomeDuration:{type:ControlType.Number,title:\"Welcome Duration\",description:\"How long to display the welcome notification before reverting to the original page title and favicon. Maximize conversions with eye-catching flashing tabs!\\n\\nMade with ❤️ by [Soyeb](https://framer.link/MBYIDPK)\",defaultValue:3e3,min:1e3,max:15e3,step:500,unit:\"ms\",displayStepper:true,hidden:props=>!props.enableWelcomeBack}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"BrowserTabNotify\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerContract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