@enjoys/pinglet 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@enjoys/pinglet",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Lightweight Customizable Web & CustomPush Notification SDK for modern web apps. Supports customizable layouts, secure delivery, and real-time updates via SSE.",
5
5
  "main": "./v0.0.2/pinglet-sse.js",
6
6
  "types": "./v0.0.2/pinglet-sse.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "import": "./pinglet-sse.js",
10
- "require": "./pinglet-sse.js"
9
+ "import": "./v0.0.2/pinglet-sse.js",
10
+ "require": "./v0.0.2/pinglet-sse.js"
11
11
  }
12
12
  },
13
13
  "files": ["*" ],
@@ -1 +1 @@
1
- (function(){"use strict";function _showPopup(title,description,buttons=[{text:"See Docs",onClick:()=>window.open("https://pinglet.enjoys.in/docs","_blank")}],icon="⚠️"){const containerId="toastContainer";let container=document.getElementById(containerId);container||(container=document.createElement("div"),container.id=containerId,Object.assign(container.style,{position:"fixed",bottom:"24px",right:"24px",zIndex:"9999",display:"flex",flexDirection:"column",gap:"4px",alignItems:"flex-end",fontFamily:"Manrope, sans-serif"}),document.body.appendChild(container));const toast=document.createElement("div");Object.assign(toast.style,{background:"#1f1f1f",color:"#fff",padding:"16px 20px",borderRadius:"12px",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.25)",fontFamily:"'Inter', sans-serif",minWidth:"260px",maxWidth:"340px",opacity:"0",transform:"translateX(100%)",transition:"opacity 0.3s ease, transform 0.3s ease",display:"flex",flexDirection:"column",gap:"10px",fontFamily:"Manrope, sans-serif"});const iconTitleRow=document.createElement("div");Object.assign(iconTitleRow.style,{display:"flex",alignItems:"center",gap:"10px",fontSize:"16px",fontWeight:"600",fontFamily:"Manrope, sans-serif"});const iconEl=document.createElement("div");iconEl.textContent=icon;const titleEl=document.createElement("div");if(titleEl.textContent=title,iconTitleRow.appendChild(iconEl),iconTitleRow.appendChild(titleEl),toast.appendChild(iconTitleRow),description){const t=document.createElement("div");t.textContent=description,Object.assign(t.style,{fontSize:"13.5px",fontWeight:"400",color:"#ddd",lineHeight:"1.5"}),toast.appendChild(t)}if(Array.isArray(buttons)&&buttons.length){const btnRow=document.createElement("div");Object.assign(btnRow.style,{marginTop:"8px",display:"flex",gap:"10px",justifyContent:"flex-start"});for(const btn of buttons){const btnEl=document.createElement("button");if(btnEl.textContent=btn.text||"Click Here",Object.assign(btnEl.style,{padding:"8px 14px",background:"#333",color:"#fff",border:"1px solid #444",borderRadius:"6px",fontSize:"13px",cursor:"pointer",transition:"background 0.3s",fontFamily:"Manrope, sans-serif"}),btnEl.onmouseover=()=>btnEl.style.background="#444",btnEl.onmouseout=()=>btnEl.style.background="#333","function"==typeof btn.onClick)btnEl.addEventListener("click",btn.onClick);else if("string"==typeof btn.onClick&&btn.onClick.trim())try{if(btn.onClick.trim().startsWith("() =>")){const fn=eval(btn.onClick);"function"==typeof fn&&btnEl.addEventListener("click",fn)}else{const t=new Function(btn.onClick);btnEl.addEventListener("click",t)}}catch(t){}btnRow.appendChild(btnEl)}toast.appendChild(btnRow)}container.appendChild(toast);const footer=document.createElement("div");return footer.innerHTML='Notifications by <a href="https://pinglet.enjoys.in" target="_blank" style="color:#4da6ff;text-decoration:none;">Pinglet</a> - Enjoys',Object.assign(footer.style,{fontSize:"11px",color:"#999",marginTop:"4px",textAlign:"right",fontFamily:"Manrope, sans-serif"}),container.appendChild(footer),requestAnimationFrame((()=>{toast.style.opacity="1",toast.style.transform="translateX(0)"})),setTimeout((()=>{toast.style.opacity="0",toast.style.transform="translateX(100%)",setTimeout((()=>{toast.remove(),footer.remove()}),500)}),5e3),container}function injectFont(){const t=document.createElement("link");t.rel="stylesheet",t.href="https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&display=swap",document.head.appendChild(t);const e=document.createElement("style");e.innerHTML='\n [class^="pinglet-"],\n [class*=" pinglet-"] {\n font-family: \'Manrope\', sans-serif !important;\n font-weight: 400 !important;\n }\n ',document.head.appendChild(e)}const defaultStyles={duration:3e3,btn1:{color:"#ffffff",backgroundColor:"#007bff",padding:"6px 10px",borderRadius:"6px",fontSize:"14px",fontWeight:"600",border:"none",boxShadow:"0 2px 6px rgba(0,0,0,0.15)"},btn2:{color:"#333333",backgroundColor:"#f0f0f0",padding:"6px 10px",borderRadius:"6px",fontSize:"14px",fontWeight:"600",border:"1px solid #ccc"},title:{color:"#111111",fontSize:"14px",fontWeight:"500",lineHeight:"1.4",margin:"0 0 0 0",textAlign:"left"},description:{color:"#444444",fontSize:"13px",fontWeight:"400",lineHeight:"1.5",margin:"0 0 10px 0",textAlign:"left"},controls:{video:{autoplay:!1,muted:!1,loop:!1,controls:!1},audio:{autoplay:!1,muted:!1,loop:!1,controls:!1}},media:{image:{width:"100%",height:"200px",borderRadius:"6px",objectFit:"cover",margin:"0 0 8px 0"},icon:{width:"24px",height:"24px",margin:"0 8px 0 0",objectFit:"contain"},logo:{width:"50px",height:"50px",margin:"0 8px 0 0",objectFit:"contain"},video:{width:"100%",height:"140px",borderRadius:"6px",objectFit:"cover",margin:"0 0 10px 0"},iframe:{width:"100%",height:"140px",borderRadius:"6px",objectFit:"cover",margin:"0 0 10px 0"},audio:{width:"100%",margin:"8px 0"}}},defaultConfig={position:"bottom-left",transition:"fade",branding:{show:!0,html:'Notifications by <a href="https://pinglet.enjoys.in" style="color:#4da6ff;text-decoration:none;" target="_blank">Pinglet</a> - Enjoys'},sound:{play:!1,src:"https://pinglet.enjoys.in/api/v1/pinglet-sound.mp3?v=1&ext=mp3",volume:.6},duration:2e3,maxVisible:3,stacking:!0,auto_dismiss:!0,dismissible:!0,website:"https://pinglet.enjoys.in",time:!0,favicon:!0,pauseOnHover:!0,theme:{mode:"light",customClass:"",rounded:!0,shadow:!0,border:!1},iconDefaults:{show:!0,size:20,position:"left"},progressBar:{show:!0,color:"#4da6ff",height:3}};let soundPlayer,toastContainer,toastStack=null,brandingElement=null;function initWidget(t){if(soundPlayer)return soundPlayer;t.sound?.play&&t.sound.src&&(soundPlayer=new Audio(t.sound.src),soundPlayer.volume=t.sound.volume??.5)}function createBrandingElement(t){return brandingElement||(brandingElement=document.createElement("div"),brandingElement.className="pinglet-branding",brandingElement.innerHTML=t?.html||'Notifications by <a href="https://pinglet.enjoys.in" class="pinglet-link" target="_blank" style="color:#4da6ff;text-decoration:none;">Pinglet</a>',brandingElement.style="\n font-size: 11px;\n color: #999;\n text-align: center;\n width: 100%;\n pointer-events: auto;\n ",brandingElement)}function createPingletToastContainer(t){if(toastContainer&&toastStack)return{toastContainer:toastContainer,toastStack:toastStack};const e=document.getElementById("pinglet-widget-container");return e?(toastContainer=e,toastStack=toastContainer.querySelector(".pinglet-widget-stack"),{toastContainer:toastContainer,toastStack:toastStack}):(toastContainer=document.createElement("div"),toastContainer.id="pinglet-widget-container",toastContainer.style.position="fixed",toastContainer.style.bottom="20px",toastContainer.style.left="20px",toastContainer.style.zIndex="9999",toastContainer.style.display="flex",toastContainer.style.flexDirection="column",toastContainer.style.alignItems="flex-start",toastContainer.style.gap="8px",toastContainer.style.maxWidth="360px",toastContainer.style.width="calc(100vw - 40px)",toastContainer.style.boxSizing="border-box",toastContainer.style.pointerEvents="none",toastContainer.style.padding="4px",toastContainer.style.borderRadius="8px",toastStack=document.createElement("div"),toastStack.className="pinglet-widget-stack",toastStack.style.display="flex",toastStack.style.flexDirection="column",toastStack.style.gap="12px",toastStack.style.pointerEvents="none",toastStack.style.overflow="visible",toastStack.style.flexShrink="0",toastContainer.appendChild(toastStack),t?.show&&toastContainer.appendChild(createBrandingElement(t)),document.body.appendChild(toastContainer),{toastContainer:toastContainer,toastStack:toastStack})}function renderToast(t,e){const n=e.config,{toastContainer:o,toastStack:i}=createPingletToastContainer(n.branding);o.appendChild(brandingElement),applyTransition(t,n.transition),t.style.pointerEvents="auto",i.appendChild(t),n.sound?.play&&soundPlayer&&soundPlayer.play(),n?.auto_dismiss&&setTimeout((()=>{removeToast(t,n?.transition||"fade")}),n.duration||3e3)}function applyTransition(t,e){t.style.opacity="0",t.style.transition="all 0.4s ease","fade"===e?(t.style.transform="translateX(20px)",requestAnimationFrame((()=>{t.style.opacity="1",t.style.transform="translateX(0)"}))):"slide"===e?(t.style.transform="translateX(100%)",requestAnimationFrame((()=>{t.style.opacity="1",t.style.transform="translateX(0)"}))):"zoom"===e?(t.style.transform="scale(0.8)",requestAnimationFrame((()=>{t.style.opacity="1",t.style.transform="scale(1)"}))):t.style.opacity="1"}function removeToast(t,e){t&&(t.style.transition="all 0.4s ease",brandingElement.style.transition="all 0.4s ease",brandingElement.style.transform="translateX(-40px)","fade"===e?(t.style.opacity="0",t.style.transform="translateX(-40px)"):"slide"===e?(t.style.transform="translateX(-100%)",t.style.opacity="0"):"zoom"===e?(t.style.transform="scale(0.8)",t.style.opacity="0"):t.style.opacity="0",t.addEventListener("transitionend",(()=>{t.remove(),toastStack&&0===toastStack.children.length&&brandingElement?.remove()}),{once:!0}))}function createNotificationHeader(t=defaultConfig,e=window.location.hostname,n="just now"){const o=document.createElement("div");o.className="pinglet-row",Object.assign(o.style,{display:"flex",justifyContent:"space-between",alignItems:"center",background:"#fff",fontFamily:"system-ui, sans-serif",fontSize:"10px"});const i=document.createElement("div");i.className="pinglet-left",Object.assign(i.style,{display:"flex",alignItems:"center",gap:"6px",flexGrow:"1"});const s=document.createElement("div");s.className="pinglet-icon",Object.assign(s.style,{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#007bff",flexShrink:"0"});const a=document.createElement("span");a.className="pinglet-domain",a.textContent=e,a.style.color="#333";const l=document.createElement("span");l.className="pinglet-time",l.textContent=`- ${n}`,l.style.color="#666";const r=document.createElement("button");return r.className="pinglet-close",r.textContent="✕",Object.assign(r.style,{background:"none",border:"none",fontSize:"12px",cursor:"pointer",color:"#888"}),r.addEventListener("mouseenter",(()=>{r.style.color="#e00"})),r.addEventListener("mouseleave",(()=>{r.style.color="#888"})),t?.website&&i.appendChild(a),t?.time&&i.appendChild(l),t?.favicon&&i.appendChild(s),o.appendChild(i),t?.dismissible&&o.appendChild(r),r.onclick=()=>{r.parentElement.parentElement.remove(),toastStack&&0===toastStack.children.length&&brandingElement?.remove()},o}function createVariant(t,e){const n=e.style,o=e.config,i=document.createElement("div");if(i.className=`pinglet-variant pinglet-${t.variant||"default"}`,i.style.display="flex",i.style.flexDirection="column",i.style.alignItems="stretch",i.style.width="100%",i.style.maxHeight="calc(100vh - 40px)",i.style.borderRadius="8px",i.style.overflowY="auto",i.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",i.style.padding="4px",i.style.backgroundColor="rgba(255, 255, 255, 0.9)",i.style.gap="4px",i.style.pointerEvents="none",i.style.overflow="visible",i.style.flexShrink="0",i.appendChild(createNotificationHeader(o)),t.media?.type){const e=createMediaElement(t.media,n.media,n.controls);e&&i.appendChild(e)}if(t.title){const e=document.createElement("div");e.className="pinglet-title",e.innerText=t.title,Object.assign(e.style,n.title||defaultStyles.title),i.appendChild(e)}if(t.description){const e=document.createElement("p");e.className="pinglet-desc",e.innerText=t.description,Object.assign(e.style,n.description||defaultStyles.description),i.appendChild(e)}if(t.buttons){const e=document.createElement("div");e.className="pinglet-buttons",e.style.fontFamily="Manrope",t.buttons.forEach(((t,o)=>{const i=document.createElement("button");i.innerText=t.text,i.className="pinglet-btn",i.style.cursor="pointer",i.style.padding="6px 10px",i.style.fontFamily="Manrope, sans-serif",i.style.margin="1px 4px",Object.assign(i.style,0===o?n.btn1:n.btn2),i.onclick=new Function(t.onClick),e.appendChild(i)})),i.appendChild(e)}return i}function createMediaElement(t,e,n){switch(t.type){case"logo":{const n=document.createElement("img");return n.src=t.src,Object.assign(n.style,e?.logo||defaultStyles.media.logo),n}case"image":{const n=document.createElement("img");return n.src=t.src,Object.assign(n.style,e?.image||defaultStyles.media.image),n}case"video":{const o=document.createElement("video");return o.src=t.src,o.autoplay=n?.video?.autoplay||defaultStyles.controls.video.autoplay||!1,o.muted=n?.video?.muted||defaultStyles.controls.video.muted||!1,o.loop=n?.video?.loop||defaultStyles.controls.video.loop||!1,o.controls=n?.video?.controls||defaultStyles.controls.video.controls||!1,o.style=e?.video||defaultStyles.media.video,Object.assign(o.style,e?.video||defaultStyles.media.video),o}case"audio":{const e=document.createElement("audio");return e.src=t.src,e.autoplay=n?.audio?.controls||defaultStyles.controls?.audio.autoplay||!1,e.muted=n?.audio?.muted||defaultStyles.controls?.audio.muted||!1,e.loop=n?.audio?.loop||defaultStyles.controls?.audio?.loop||!1,e.controls=n?.audio?.controls||defaultStyles.controls?.audio?.controls||!1,Object.assign(e.style,e?.video||defaultStyles.media.audio),e}case"icon":{const t=document.createElement("span");return t.className="pinglet-icon",t.style={width:"40px",height:"40px",backgroundPosition:"center",borderRadius:"8px"},t}default:return null}}async function loadAllTemplates(t,e,n,o,i){const s=await fetch(`${t}/load/templates?projectId=${e}`,{headers:{"X-Project-ID":e,"X-Timestamp":Date.now(),"X-Pinglet-Signature":n,"X-Pinglet-Checksum":o,"X-Pinglet-Version":i},credentials:"omit"}),a=await s.json();return a&&a.success?a.result:null}const publicVapidKey="BJ9GvEJAs47DOgqw-rN80ZGIVvIvcp-xE4ZNweCT4eJ0B-rIzMtfhLWh8ySUCeKgiW_Fym69h0Fx3vhAcAy6C2k";async function subscribeUser(t,e){try{const n=await navigator.serviceWorker.register(t+"/sw.js");if(await n.pushManager.getSubscription())return;const o=await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:urlBase64ToUint8Array(publicVapidKey)}),i=await fetch(`${t}/subscribe?projectId=${e}`,{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}}),s=await i.json();if(s.success)return localStorage.getItem("subscription")?void 0:(localStorage.setItem("subscription","true"),_showPopup("Notifications Enabled","You can now receive notifications from this site.",[{text:"See Demo",onClick:"() => DemoNotification()"}],"🎉"));_showPopup("Something Went Wrong",s.message,[],"❌")}catch(t){}}function urlBase64ToUint8Array(t){const e=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),n=window.atob(e);return Uint8Array.from([...n].map((t=>t.charCodeAt(0))))}function createNotificationPermissionDialog(t={}){const{title:e="Stay updated with notifications",description:n="Get notified about important updates, new features, and exclusive content. We'll only send you valuable notifications.",site:o=window.location.hostname,onAllow:i=()=>{},onDeny:s=()=>{}}=t,a=document.createElement("div");a.className="notification-dialog",Object.assign(a.style,{position:"fixed",bottom:"24px",right:"24px",width:"380px",background:"#fff",borderRadius:"16px",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255,255,255,0.1)",zIndex:"1000",overflow:"hidden",transform:"translateX(420px)",animation:"slideIn 0.6s ease-out 1s forwards",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"});const l=document.createElement("style");l.textContent="\n @keyframes slideIn { to { transform: translateX(0); } }\n @keyframes pulse {\n 0%, 100% { box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3); }\n 50% { box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5); }\n }\n @media (max-width: 480px) {\n .notification-dialog {\n width: calc(100vw - 32px) !important;\n right: 16px !important;\n bottom: 16px !important;\n transform: translateY(420px) !important;\n }\n @keyframes slideIn { to { transform: translateY(0); } }\n }\n ",document.head.appendChild(l);const r=document.createElement("div");r.style.display="flex",r.style.justifyContent="space-between",r.style.padding="20px 20px 0 20px";const c=document.createElement("div");c.style.display="flex",c.style.alignItems="center",c.style.gap="8px",c.style.color="#6b7280",c.style.fontSize="14px",c.style.fontWeight="500";const d=document.createElement("div");d.style.width="16px",d.style.height="16px",d.style.borderRadius="4px",d.style.background="linear-gradient(135deg, #667eea 0%, #764ba2 100%)",d.style.display="flex",d.style.alignItems="center",d.style.justifyContent="center",d.innerHTML='<svg viewBox="0 0 16 16" fill="white" width="10" height="10"><path d="M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8z"/></svg>';const p=document.createElement("span");p.textContent=o,c.append(d,p);const m=document.createElement("button");m.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor" width="12" height="12">\n <path d="M12.854 4.854a.5.5 0 0 0-.708-.708L8 8.293 3.854 4.146a.5.5 0 1 0-.708.708L7.293 9l-4.147 4.146a.5.5 0 0 0 .708.708L8 9.707l4.146 4.147a.5.5 0 0 0 .708-.708L8.707 9l4.147-4.146z"/>\n </svg>',Object.assign(m.style,{width:"24px",height:"24px",background:"#f3f4f6",border:"none",borderRadius:"6px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280"}),m.onclick=()=>a.remove(),r.append(c,m);const u=document.createElement("div");u.style.padding="16px 24px 24px 24px";const y=document.createElement("div");y.style.width="48px",y.style.height="48px",y.style.borderRadius="12px",y.style.marginBottom="16px",y.style.animation="pulse 2s infinite",y.style.background="linear-gradient(135deg, #667eea 0%, #764ba2 100%)",y.style.display="flex",y.style.alignItems="center",y.style.justifyContent="center",y.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" width="24" height="24">\n <path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.73 21a2 2 0 0 1-3.46 0"/>\n </svg>';const g=document.createElement("h3");g.textContent=e,Object.assign(g.style,{fontSize:"18px",fontWeight:"600",color:"#111827",marginBottom:"8px"});const f=document.createElement("p");f.textContent=n,Object.assign(f.style,{fontSize:"14px",color:"#6b7280",lineHeight:"1.5",marginBottom:"20px"});const x=document.createElement("div");x.style.display="flex",x.style.gap="8px";const h=document.createElement("button");h.textContent="Not now",Object.assign(h.style,{flex:1,padding:"10px 16px",borderRadius:"8px",fontSize:"14px",fontWeight:"500",border:"1px solid #e5e7eb",background:"#f9fafb",color:"#6b7280",cursor:"pointer"}),h.onclick=()=>{s(),a.remove()};const b=document.createElement("button");b.textContent="Allow notifications",Object.assign(b.style,{flex:1,padding:"10px 16px",borderRadius:"8px",fontSize:"14px",fontWeight:"500",border:"none",background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",boxShadow:"0 2px 8px rgba(102, 126, 234, 0.3)",cursor:"pointer"}),b.onclick=()=>{i(),a.remove()},x.append(h,b);const w=document.createElement("div");w.style.marginTop="12px",w.style.display="flex",w.style.alignItems="center",w.style.justifyContent="center",w.style.gap="6px",w.style.color="#9ca3af",w.style.fontSize="12px",w.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor" width="12" height="12"><path d="M8 0c-.69 0-1.843.265-2.928.56-1.11.3-2.229.655-2.887.87a1.54 1.54 0 0 0-1.044 1.262c-.596 4.477.787 7.795 2.465 9.99a11.777 11.777 0 0 0 2.517 2.453c.386.273.744.482 1.048.625.28.132.581.24.829.24s.548-.108.829-.24a7.159 7.159 0 0 0 1.048-.625 11.775 11.775 0 0 0 2.517-2.453c1.678-2.195 3.061-5.513 2.465-9.99a1.541 1.541 0 0 0-1.044-1.263 62.467 62.467 0 0 0-2.887-.87C9.843.266 8.69 0 8 0z"/></svg><span>Secure & private • Unsubscribe anytime</span>',u.append(y,g,f,x,w),a.append(r,u),document.body.appendChild(a)}function askNotificationPermissionFunction(t,e){"Notification"in window?"granted"===Notification.permission||createNotificationPermissionDialog({site:window.location.hostname,onAllow:()=>{Notification.requestPermission().then((async n=>{"granted"===n?(await subscribeUser(t,e),_showPopup("Notifications Enabled","You can now receive notifications from this site.",[{text:"See Demo",onClick:"() => DemoNotification()"}],"🎉")):_showPopup("Permission Denied","You blocked notifications!",[],"😭")})).catch((t=>_showPopup("Permission Error","Error requesting notification permission:",[],"😭")))},onDeny:()=>_showPopup("Permission Denied","You blocked notifications!",[],"❌")}):_showPopup("Unsupported Browser","Notifications not supported.",[],"🚫")}function TriggerBrowserNotificationApi(t,e,n){return new Notification(t,{badge:"🎉",body:e,actions:[{action:"pinglet",title:"Pinglet"}],icon:n,dir:"rtl",lang:"en",silent:!1,tag:"pinglet",vibrate:[100,50,100],requireInteraction:!0}).onclick=()=>{}}function ShowTestimonials(){const t=document.getElementById("pinglet-testimonials");if(t)return t;const e=document.createElement("div");e.className="pinglet-floating-btn",e.style.position="fixed",e.style.bottom="30px",e.style.right="30px",e.style.display="flex",e.style.alignItems="center",e.style.background="#667EEA",e.style.borderRadius="50px",e.style.padding="0",e.style.cursor="pointer",e.style.boxShadow="0 4px 14px 0 rgba(102, 126, 234, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05)",e.style.transition="all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",e.style.overflow="hidden",e.style.width="24px",e.style.height="24px",e.style.zIndex="1000",e.style.backdropFilter="blur(10px)",e.style.border="1px solid rgba(255, 255, 255, 0.1)";const n=document.createElement("div");n.textContent="❔",n.className="icon",n.style.fontSize="20px",n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.transition="all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",n.style.width="24px",n.style.height="24px",n.style.flexShrink="0",n.style.color="white";const o=document.createElement("span");o.textContent="View",o.className="label",o.style.color="white",o.style.fontWeight="500",o.style.fontSize="14px",o.style.marginLeft="8px",o.style.marginRight="16px",o.style.opacity="0",o.style.transform="translateX(-8px)",o.style.transition="all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",o.style.whiteSpace="nowrap",o.style.letterSpacing="0.025em",e.appendChild(n),e.appendChild(o),document.body.appendChild(e),e.addEventListener("mouseenter",(()=>{e.style.width="100px",e.style.borderRadius="28px",e.style.boxShadow="0 8px 25px 0 rgba(102, 126, 234, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1)",e.style.transform="translateY(-2px)",o.style.opacity="1",o.style.transform="translateX(0)",n.style.transform="scale(1.05)"})),e.addEventListener("mouseleave",(()=>{e.style.width="40px",e.style.height="40px",e.style.borderRadius="50px",e.style.boxShadow="0 4px 14px 0 rgba(102, 126, 234, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05)",e.style.transform="translateY(0)",o.style.opacity="0",o.style.transform="translateX(-8px)",n.style.transform="scale(1)"})),e.addEventListener("mousedown",(()=>{e.style.transform="translateY(0) scale(0.98)",e.style.boxShadow="0 2px 8px 0 rgba(102, 126, 234, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05)"})),e.addEventListener("mouseup",(()=>{e.style.transform="translateY(-2px)",e.style.boxShadow="0 8px 25px 0 rgba(102, 126, 234, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1)"})),o.addEventListener("click",(()=>{_showPopup("Testimonials Error","There was an error loading testimonials. Please try again later. If the issue persists, please contact support.",[],"❌")}));const i=()=>{window.innerWidth<=768?(e.style.bottom="16px",e.style.right="16px",e.style.width="48px",e.style.height="48px",n.style.width="48px",n.style.height="48px",n.style.fontSize="18px",o.style.fontSize="13px",o.style.marginLeft="6px",o.style.marginRight="12px"):(e.style.bottom="30px",e.style.right="30px",e.style.width="40px",e.style.height="40px",n.style.width="40px",n.style.height="40px",n.style.fontSize="20px",o.style.fontSize="14px",o.style.marginLeft="8px",o.style.marginRight="16px")};i(),window.addEventListener("resize",i)}const scriptEl=Array.from(document.scripts).find((t=>t.src.includes("pinglet-sse")&&t.dataset.endpoint)),currentScript=scriptEl||document.currentScript,endpoint=currentScript?.dataset.endpoint,configuredDomain=currentScript?.dataset.configuredDomain,projectId=currentScript?.dataset.projectId,pingletId=currentScript?.dataset.pingletId,loadTemplates=currentScript?.dataset.loadTemplates,checksum=currentScript?.dataset.checksum,testimonials=currentScript?.dataset.testimonials;(async t=>{if(t.PingletWidget)return void console.warn("PingletWidget is already initialized.");injectFont(),askNotificationPermissionFunction(endpoint,projectId),testimonials&&ShowTestimonials();let e={};const n={version:"0.0.2",checksum:checksum.replace("sha384-",""),async init({endpoint:t,configuredDomain:n,projectId:o,pingletId:i}){if("0.0.2"!==this.version)return _showPopup("Unsupported Version",`PingletWidget version ${this.version} is not supported. Please update to the latest version.`,[{text:"See Docs",onClick:'window.open("https://pinglet.enjoys.in/docs", "_blank")'}],"⚠️"),void console.warn("Unsupported version detected.");if(!this.checksum||!checksum)return _showPopup("Configuration Error","Missing checksum.");const s=await fetch(`${t}/load/projects?projectId=${o}&domain=${n}`,{headers:{"X-Project-ID":o,"X-Timestamp":Date.now(),"X-Pinglet-Signature":i,"X-Pinglet-Checksum":this.checksum,"X-Pinglet-Version":this.version,"X-Configured-Domain":n,"X-Pinglet-Id":i},credentials:"omit"}),a=await s.json();if(!a||!a.success)return _showPopup("Configuration Error",`Failed to load configuration for PingletWidget. ${a.message||"Unknown error"}`,[{text:"Retry",onClick:"window.location.reload()"},{text:"See Docs",onClick:'window.open("https://pinglet.enjoys.in/docs", "_blank")'}],"❌"),console.error("Failed to load configuration for PingletWidget.");if("true"===loadTemplates){const n=await loadAllTemplates(t,o,i,this.checksum,this.version);n||_showPopup("Configuration Error","Failed to load templates for PingletWidget."),e=n}const l={is_tff:a.result?.is_premium??!1,templates:Object.assign({},{default:{compiled_text:_showPopup.toString(),config:defaultConfig,is_active:!0,is_default:!0}},"true"===loadTemplates?e:{[String(a.result.template?.id.toString())]:a.result.template}),style:Object.assign({},defaultStyles,a.result.template?.config),config:Object.assign({},defaultConfig,a.result.config)};initWidget(l);new EventSource(`${t}/sse?projectId=${o}&pingletId=${i}`,{withCredentials:!1}).onmessage=t=>{const e=JSON.parse(t.data),n=e.data;if(l?.is_tdd&&Object.assign(l.config,l.config,n?.overrides??{}),"1"===e?.type&&e?.template_id&&e?.data){return renderToast(interPolateTemplateWithData("",e?.data),l)}if("0"===e?.type&&e?.body){renderToast(createVariant(e.body,l),l)}else TriggerBrowserNotificationApi(body.title,body.description,body.type?.icon?.src||"")}}};t.PingletWidget=n,document.addEventListener("DOMContentLoaded",(()=>{n.init({endpoint:endpoint,configuredDomain:configuredDomain,projectId:projectId,pingletId:pingletId})})),console.log("%cPingletWidget initialized successfully.","color: #1e90ff; font-weight: bold;")})(window)})();
1
+ (function(){"use strict";function _showPopup(title,description,buttons=[{text:"See Docs",onClick:()=>window.open("https://pinglet.enjoys.in/docs","_blank")}],icon="⚠️"){const containerId="toastContainer";let container=document.getElementById(containerId);container||(container=document.createElement("div"),container.id=containerId,Object.assign(container.style,{position:"fixed",bottom:"24px",right:"24px",zIndex:"9999",display:"flex",flexDirection:"column",gap:"4px",alignItems:"flex-end",fontFamily:"Manrope, sans-serif"}),document.body.appendChild(container));const toast=document.createElement("div");Object.assign(toast.style,{background:"#1f1f1f",color:"#fff",padding:"16px 20px",borderRadius:"12px",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.25)",fontFamily:"'Inter', sans-serif",minWidth:"260px",maxWidth:"340px",opacity:"0",transform:"translateX(100%)",transition:"opacity 0.3s ease, transform 0.3s ease",display:"flex",flexDirection:"column",gap:"10px",fontFamily:"Manrope, sans-serif"});const iconTitleRow=document.createElement("div");Object.assign(iconTitleRow.style,{display:"flex",alignItems:"center",gap:"10px",fontSize:"16px",fontWeight:"600",fontFamily:"Manrope, sans-serif"});const iconEl=document.createElement("div");iconEl.textContent=icon;const titleEl=document.createElement("div");if(titleEl.textContent=title,iconTitleRow.appendChild(iconEl),iconTitleRow.appendChild(titleEl),toast.appendChild(iconTitleRow),description){const t=document.createElement("div");t.textContent=description,Object.assign(t.style,{fontSize:"13.5px",fontWeight:"400",color:"#ddd",lineHeight:"1.5"}),toast.appendChild(t)}if(Array.isArray(buttons)&&buttons.length){const btnRow=document.createElement("div");Object.assign(btnRow.style,{marginTop:"8px",display:"flex",gap:"10px",justifyContent:"flex-start"});for(const btn of buttons){const btnEl=document.createElement("button");if(btnEl.textContent=btn.text||"Click Here",Object.assign(btnEl.style,{padding:"8px 14px",background:"#333",color:"#fff",border:"1px solid #444",borderRadius:"6px",fontSize:"13px",cursor:"pointer",transition:"background 0.3s",fontFamily:"Manrope, sans-serif"}),btnEl.onmouseover=()=>btnEl.style.background="#444",btnEl.onmouseout=()=>btnEl.style.background="#333","function"==typeof btn.onClick)btnEl.addEventListener("click",btn.onClick);else if("string"==typeof btn.onClick&&btn.onClick.trim())try{if(btn.onClick.trim().startsWith("() =>")){const fn=eval(btn.onClick);"function"==typeof fn&&btnEl.addEventListener("click",fn)}else{const t=new Function(btn.onClick);btnEl.addEventListener("click",t)}}catch(t){}btnRow.appendChild(btnEl)}toast.appendChild(btnRow)}container.appendChild(toast);const footer=document.createElement("div");return footer.innerHTML='Notifications by <a href="https://pinglet.enjoys.in" target="_blank" style="color:#4da6ff;text-decoration:none;">Pinglet</a> - Enjoys',Object.assign(footer.style,{fontSize:"11px",color:"#999",marginTop:"4px",textAlign:"right",fontFamily:"Manrope, sans-serif"}),container.appendChild(footer),requestAnimationFrame((()=>{toast.style.opacity="1",toast.style.transform="translateX(0)"})),setTimeout((()=>{toast.style.opacity="0",toast.style.transform="translateX(100%)",setTimeout((()=>{toast.remove(),footer.remove()}),500)}),5e3),container}function injectFont(){const t=document.createElement("link");t.rel="stylesheet",t.href="https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&display=swap",document.head.appendChild(t);const e=document.createElement("style");e.innerHTML='\n [class^="pinglet-"],\n [class*=" pinglet-"] {\n font-family: \'Manrope\', sans-serif !important;\n font-weight: 400 !important;\n }\n ',document.head.appendChild(e)}const defaultStyles={duration:3e3,btn1:{color:"#ffffff",backgroundColor:"#007bff",padding:"6px 10px",borderRadius:"6px",fontSize:"14px",fontWeight:"600",border:"none",boxShadow:"0 2px 6px rgba(0,0,0,0.15)"},btn2:{color:"#333333",backgroundColor:"#f0f0f0",padding:"6px 10px",borderRadius:"6px",fontSize:"14px",fontWeight:"600",border:"1px solid #ccc"},title:{color:"#111111",fontSize:"14px",fontWeight:"500",lineHeight:"1.4",margin:"0 0 0 0",textAlign:"left"},description:{color:"#444444",fontSize:"13px",fontWeight:"400",lineHeight:"1.5",margin:"0 0 10px 0",textAlign:"left"},controls:{video:{autoplay:!1,muted:!1,loop:!1,controls:!1},audio:{autoplay:!1,muted:!1,loop:!1,controls:!1}},media:{image:{width:"100%",height:"200px",borderRadius:"6px",objectFit:"cover",margin:"0 0 8px 0"},icon:{width:"24px",height:"24px",margin:"0 8px 0 0",objectFit:"contain"},logo:{width:"50px",height:"50px",margin:"0 8px 0 0",objectFit:"contain"},video:{width:"100%",height:"140px",borderRadius:"6px",objectFit:"cover",margin:"0 0 10px 0"},iframe:{width:"100%",height:"140px",borderRadius:"6px",objectFit:"cover",margin:"0 0 10px 0"},audio:{width:"100%",margin:"8px 0"}}},defaultConfig={position:"bottom-left",transition:"fade",branding:{show:!0,html:'Notifications by <a href="https://pinglet.enjoys.in" style="color:#4da6ff;text-decoration:none;" target="_blank">Pinglet</a> - Enjoys'},sound:{play:!1,src:"https://pinglet.enjoys.in/api/v1/pinglet-sound.mp3?v=1&ext=mp3",volume:.6},duration:2e3,maxVisible:3,stacking:!0,auto_dismiss:!0,dismissible:!0,website:"https://pinglet.enjoys.in",time:!0,favicon:!0,pauseOnHover:!0,theme:{mode:"light",customClass:"",rounded:!0,shadow:!0,border:!1},iconDefaults:{show:!0,size:20,position:"left"},progressBar:{show:!0,color:"#4da6ff",height:3}};let soundPlayer,toastContainer,toastStack=null,brandingElement=null;function initWidget(t){if(soundPlayer)return soundPlayer;t.sound?.play&&t.sound.src&&(soundPlayer=new Audio(t.sound.src),soundPlayer.volume=t.sound.volume??.5)}function createBrandingElement(t){return brandingElement||(brandingElement=document.createElement("div"),brandingElement.className="pinglet-branding",brandingElement.innerHTML=t?.html||'Notifications by <a href="https://pinglet.enjoys.in" class="pinglet-link" target="_blank" style="color:#4da6ff;text-decoration:none;">Pinglet</a>',brandingElement.style="\n font-size: 11px;\n color: #999;\n text-align: center;\n width: 100%;\n pointer-events: auto;\n ",brandingElement)}function createPingletToastContainer(t){if(toastContainer&&toastStack)return{toastContainer:toastContainer,toastStack:toastStack};const e=document.getElementById("pinglet-widget-container");return e?(toastContainer=e,toastStack=toastContainer.querySelector(".pinglet-widget-stack"),{toastContainer:toastContainer,toastStack:toastStack}):(toastContainer=document.createElement("div"),toastContainer.id="pinglet-widget-container",toastContainer.style.position="fixed",toastContainer.style.bottom="20px",toastContainer.style.left="20px",toastContainer.style.zIndex="9999",toastContainer.style.display="flex",toastContainer.style.flexDirection="column",toastContainer.style.alignItems="flex-start",toastContainer.style.gap="8px",toastContainer.style.maxWidth="360px",toastContainer.style.width="calc(100vw - 40px)",toastContainer.style.boxSizing="border-box",toastContainer.style.pointerEvents="none",toastContainer.style.padding="4px",toastContainer.style.borderRadius="8px",toastStack=document.createElement("div"),toastStack.className="pinglet-widget-stack",toastStack.style.display="flex",toastStack.style.flexDirection="column",toastStack.style.gap="12px",toastStack.style.pointerEvents="none",toastStack.style.overflow="visible",toastStack.style.flexShrink="0",toastContainer.appendChild(toastStack),t?.show&&toastContainer.appendChild(createBrandingElement(t)),document.body.appendChild(toastContainer),{toastContainer:toastContainer,toastStack:toastStack})}function renderToast(t,e){const n=e.config,{toastContainer:o,toastStack:i}=createPingletToastContainer(n.branding);o.appendChild(brandingElement),applyTransition(t,n.transition),t.style.pointerEvents="auto",i.appendChild(t),n.sound?.play&&soundPlayer&&soundPlayer.play(),n?.auto_dismiss&&setTimeout((()=>{removeToast(t,n?.transition||"fade")}),n.duration||3e3)}function applyTransition(t,e){t.style.opacity="0",t.style.transition="all 0.4s ease","fade"===e?(t.style.transform="translateX(20px)",requestAnimationFrame((()=>{t.style.opacity="1",t.style.transform="translateX(0)"}))):"slide"===e?(t.style.transform="translateX(100%)",requestAnimationFrame((()=>{t.style.opacity="1",t.style.transform="translateX(0)"}))):"zoom"===e?(t.style.transform="scale(0.8)",requestAnimationFrame((()=>{t.style.opacity="1",t.style.transform="scale(1)"}))):t.style.opacity="1"}function removeToast(t,e){t&&(t.style.transition="all 0.4s ease",brandingElement.style.transition="all 0.4s ease",brandingElement.style.transform="translateX(-40px)","fade"===e?(t.style.opacity="0",t.style.transform="translateX(-40px)"):"slide"===e?(t.style.transform="translateX(-100%)",t.style.opacity="0"):"zoom"===e?(t.style.transform="scale(0.8)",t.style.opacity="0"):t.style.opacity="0",t.addEventListener("transitionend",(()=>{t.remove(),toastStack&&0===toastStack.children.length&&brandingElement?.remove()}),{once:!0}))}function createNotificationHeader(t=defaultConfig,e=window.location.hostname,n="just now"){const o=document.createElement("div");o.className="pinglet-row",Object.assign(o.style,{display:"flex",justifyContent:"space-between",alignItems:"center",background:"#fff",fontFamily:"system-ui, sans-serif",fontSize:"10px"});const i=document.createElement("div");i.className="pinglet-left",Object.assign(i.style,{display:"flex",alignItems:"center",gap:"6px",flexGrow:"1"});const s=document.createElement("div");s.className="pinglet-icon",Object.assign(s.style,{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#007bff",flexShrink:"0"});const a=document.createElement("span");a.className="pinglet-domain",a.textContent=e,a.style.color="#333";const l=document.createElement("span");l.className="pinglet-time",l.textContent=`- ${n}`,l.style.color="#666";const r=document.createElement("button");return r.className="pinglet-close",r.textContent="✕",Object.assign(r.style,{background:"none",border:"none",fontSize:"12px",cursor:"pointer",color:"#888"}),r.addEventListener("mouseenter",(()=>{r.style.color="#e00"})),r.addEventListener("mouseleave",(()=>{r.style.color="#888"})),t?.website&&i.appendChild(a),t?.time&&i.appendChild(l),t?.favicon&&i.appendChild(s),o.appendChild(i),t?.dismissible&&o.appendChild(r),r.onclick=()=>{r.parentElement.parentElement.remove(),toastStack&&0===toastStack.children.length&&brandingElement?.remove()},o}function createVariant(t,e){const n=e.style,o=e.config,i=document.createElement("div");if(i.className=`pinglet-variant pinglet-${t.variant||"default"}`,i.style.display="flex",i.style.flexDirection="column",i.style.alignItems="stretch",i.style.width="100%",i.style.maxHeight="calc(100vh - 40px)",i.style.borderRadius="8px",i.style.overflowY="auto",i.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",i.style.padding="4px",i.style.backgroundColor="rgba(255, 255, 255, 0.9)",i.style.gap="4px",i.style.pointerEvents="none",i.style.overflow="visible",i.style.flexShrink="0",i.appendChild(createNotificationHeader(o)),t.media?.type){const e=createMediaElement(t.media,n.media,n.controls);e&&i.appendChild(e)}if(t.title){const e=document.createElement("div");e.className="pinglet-title",e.innerText=t.title,Object.assign(e.style,n.title||defaultStyles.title),i.appendChild(e)}if(t.description){const e=document.createElement("p");e.className="pinglet-desc",e.innerText=t.description,Object.assign(e.style,n.description||defaultStyles.description),i.appendChild(e)}if(t.buttons){const e=document.createElement("div");e.className="pinglet-buttons",e.style.fontFamily="Manrope",t.buttons.forEach(((t,o)=>{const i=document.createElement("button");i.innerText=t.text,i.className="pinglet-btn",i.style.cursor="pointer",i.style.padding="6px 10px",i.style.fontFamily="Manrope, sans-serif",i.style.margin="1px 4px",Object.assign(i.style,0===o?n.btn1:n.btn2),i.onclick=new Function(t.onClick),e.appendChild(i)})),i.appendChild(e)}return i}function createMediaElement(t,e,n){switch(t.type){case"logo":{const n=document.createElement("img");return n.src=t.src,Object.assign(n.style,e?.logo||defaultStyles.media.logo),n}case"image":{const n=document.createElement("img");return n.src=t.src,Object.assign(n.style,e?.image||defaultStyles.media.image),n}case"video":{const o=document.createElement("video");return o.src=t.src,o.autoplay=n?.video?.autoplay||defaultStyles.controls.video.autoplay||!1,o.muted=n?.video?.muted||defaultStyles.controls.video.muted||!1,o.loop=n?.video?.loop||defaultStyles.controls.video.loop||!1,o.controls=n?.video?.controls||defaultStyles.controls.video.controls||!1,o.style=e?.video||defaultStyles.media.video,Object.assign(o.style,e?.video||defaultStyles.media.video),o}case"audio":{const e=document.createElement("audio");return e.src=t.src,e.autoplay=n?.audio?.controls||defaultStyles.controls?.audio.autoplay||!1,e.muted=n?.audio?.muted||defaultStyles.controls?.audio.muted||!1,e.loop=n?.audio?.loop||defaultStyles.controls?.audio?.loop||!1,e.controls=n?.audio?.controls||defaultStyles.controls?.audio?.controls||!1,Object.assign(e.style,e?.video||defaultStyles.media.audio),e}case"icon":{const t=document.createElement("span");return t.className="pinglet-icon",t.style={width:"40px",height:"40px",backgroundPosition:"center",borderRadius:"8px"},t}default:return null}}async function loadAllTemplates(t,e,n,o,i){const s=await fetch(`${t}/load/templates?projectId=${e}`,{headers:{"X-Project-ID":e,"X-Timestamp":Date.now(),"X-Pinglet-Signature":n,"X-Pinglet-Checksum":o,"X-Pinglet-Version":i},credentials:"omit"}),a=await s.json();return a&&a.success?a.result:null}const publicVapidKey="BJ9GvEJAs47DOgqw-rN80ZGIVvIvcp-xE4ZNweCT4eJ0B-rIzMtfhLWh8ySUCeKgiW_Fym69h0Fx3vhAcAy6C2k";async function subscribeUser(t,e){try{const n=await navigator.serviceWorker.register(t+"/sw.js");if(await n.pushManager.getSubscription())return;const o=await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:urlBase64ToUint8Array(publicVapidKey)}),i=await fetch(`${t}/subscribe?projectId=${e}`,{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"},credentials:"omit"}),s=await i.json();if(s.success)return localStorage.getItem("subscription")?void 0:(localStorage.setItem("subscription","true"),_showPopup("Notifications Enabled","You can now receive notifications from this site.",[{text:"See Demo",onClick:"() => DemoNotification()"}],"🎉"));_showPopup("Something Went Wrong",s.message,[],"❌")}catch(t){}}function urlBase64ToUint8Array(t){const e=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),n=window.atob(e);return Uint8Array.from([...n].map((t=>t.charCodeAt(0))))}function createNotificationPermissionDialog(t={}){const{title:e="Stay updated with notifications",description:n="Get notified about important updates, new features, and exclusive content. We'll only send you valuable notifications.",site:o=window.location.hostname,onAllow:i=()=>{},onDeny:s=()=>{}}=t,a=document.createElement("div");a.className="notification-dialog",Object.assign(a.style,{position:"fixed",bottom:"24px",right:"24px",width:"380px",background:"#fff",borderRadius:"16px",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255,255,255,0.1)",zIndex:"1000",overflow:"hidden",transform:"translateX(420px)",animation:"slideIn 0.6s ease-out 1s forwards",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"});const l=document.createElement("style");l.textContent="\n @keyframes slideIn { to { transform: translateX(0); } }\n @keyframes pulse {\n 0%, 100% { box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3); }\n 50% { box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5); }\n }\n @media (max-width: 480px) {\n .notification-dialog {\n width: calc(100vw - 32px) !important;\n right: 16px !important;\n bottom: 16px !important;\n transform: translateY(420px) !important;\n }\n @keyframes slideIn { to { transform: translateY(0); } }\n }\n ",document.head.appendChild(l);const r=document.createElement("div");r.style.display="flex",r.style.justifyContent="space-between",r.style.padding="20px 20px 0 20px";const c=document.createElement("div");c.style.display="flex",c.style.alignItems="center",c.style.gap="8px",c.style.color="#6b7280",c.style.fontSize="14px",c.style.fontWeight="500";const d=document.createElement("div");d.style.width="16px",d.style.height="16px",d.style.borderRadius="4px",d.style.background="linear-gradient(135deg, #667eea 0%, #764ba2 100%)",d.style.display="flex",d.style.alignItems="center",d.style.justifyContent="center",d.innerHTML='<svg viewBox="0 0 16 16" fill="white" width="10" height="10"><path d="M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8z"/></svg>';const p=document.createElement("span");p.textContent=o,c.append(d,p);const m=document.createElement("button");m.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor" width="12" height="12">\n <path d="M12.854 4.854a.5.5 0 0 0-.708-.708L8 8.293 3.854 4.146a.5.5 0 1 0-.708.708L7.293 9l-4.147 4.146a.5.5 0 0 0 .708.708L8 9.707l4.146 4.147a.5.5 0 0 0 .708-.708L8.707 9l4.147-4.146z"/>\n </svg>',Object.assign(m.style,{width:"24px",height:"24px",background:"#f3f4f6",border:"none",borderRadius:"6px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280"}),m.onclick=()=>a.remove(),r.append(c,m);const u=document.createElement("div");u.style.padding="16px 24px 24px 24px";const y=document.createElement("div");y.style.width="48px",y.style.height="48px",y.style.borderRadius="12px",y.style.marginBottom="16px",y.style.animation="pulse 2s infinite",y.style.background="linear-gradient(135deg, #667eea 0%, #764ba2 100%)",y.style.display="flex",y.style.alignItems="center",y.style.justifyContent="center",y.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" width="24" height="24">\n <path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.73 21a2 2 0 0 1-3.46 0"/>\n </svg>';const g=document.createElement("h3");g.textContent=e,Object.assign(g.style,{fontSize:"18px",fontWeight:"600",color:"#111827",marginBottom:"8px"});const f=document.createElement("p");f.textContent=n,Object.assign(f.style,{fontSize:"14px",color:"#6b7280",lineHeight:"1.5",marginBottom:"20px"});const x=document.createElement("div");x.style.display="flex",x.style.gap="8px";const h=document.createElement("button");h.textContent="Not now",Object.assign(h.style,{flex:1,padding:"10px 16px",borderRadius:"8px",fontSize:"14px",fontWeight:"500",border:"1px solid #e5e7eb",background:"#f9fafb",color:"#6b7280",cursor:"pointer"}),h.onclick=()=>{s(),a.remove()};const b=document.createElement("button");b.textContent="Allow notifications",Object.assign(b.style,{flex:1,padding:"10px 16px",borderRadius:"8px",fontSize:"14px",fontWeight:"500",border:"none",background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",boxShadow:"0 2px 8px rgba(102, 126, 234, 0.3)",cursor:"pointer"}),b.onclick=()=>{i(),a.remove()},x.append(h,b);const w=document.createElement("div");w.style.marginTop="12px",w.style.display="flex",w.style.alignItems="center",w.style.justifyContent="center",w.style.gap="6px",w.style.color="#9ca3af",w.style.fontSize="12px",w.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor" width="12" height="12"><path d="M8 0c-.69 0-1.843.265-2.928.56-1.11.3-2.229.655-2.887.87a1.54 1.54 0 0 0-1.044 1.262c-.596 4.477.787 7.795 2.465 9.99a11.777 11.777 0 0 0 2.517 2.453c.386.273.744.482 1.048.625.28.132.581.24.829.24s.548-.108.829-.24a7.159 7.159 0 0 0 1.048-.625 11.775 11.775 0 0 0 2.517-2.453c1.678-2.195 3.061-5.513 2.465-9.99a1.541 1.541 0 0 0-1.044-1.263 62.467 62.467 0 0 0-2.887-.87C9.843.266 8.69 0 8 0z"/></svg><span>Secure & private • Unsubscribe anytime</span>',u.append(y,g,f,x,w),a.append(r,u),document.body.appendChild(a)}function askNotificationPermissionFunction(t,e){"Notification"in window?"granted"===Notification.permission||createNotificationPermissionDialog({site:window.location.hostname,onAllow:()=>{Notification.requestPermission().then((async n=>"granted"===n?subscribeUser(t,e):_showPopup("Permission Denied","You blocked notifications!",[],"😭"))).catch((t=>_showPopup("Permission Error","Error requesting notification permission:",[],"😭")))},onDeny:()=>_showPopup("Permission Denied","You blocked notifications!",[],"❌")}):_showPopup("Unsupported Browser","Notifications not supported.",[],"🚫")}function TriggerBrowserNotificationApi(t,e,n){return new Notification(t,{badge:"🎉",body:e,actions:[{action:"pinglet",title:"Pinglet"}],icon:n,dir:"rtl",lang:"en",silent:!1,tag:"pinglet",vibrate:[100,50,100],requireInteraction:!0}).onclick=()=>{}}function ShowTestimonials(){const t=document.getElementById("pinglet-testimonials");if(t)return t;const e=document.createElement("div");e.className="pinglet-floating-btn",e.style.position="fixed",e.style.bottom="30px",e.style.right="30px",e.style.display="flex",e.style.alignItems="center",e.style.background="#667EEA",e.style.borderRadius="50px",e.style.padding="0",e.style.cursor="pointer",e.style.boxShadow="0 4px 14px 0 rgba(102, 126, 234, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05)",e.style.transition="all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",e.style.overflow="hidden",e.style.width="24px",e.style.height="24px",e.style.zIndex="1000",e.style.backdropFilter="blur(10px)",e.style.border="1px solid rgba(255, 255, 255, 0.1)";const n=document.createElement("div");n.textContent="❔",n.className="icon",n.style.fontSize="20px",n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.transition="all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",n.style.width="24px",n.style.height="24px",n.style.flexShrink="0",n.style.color="white";const o=document.createElement("span");o.textContent="View",o.className="label",o.style.color="white",o.style.fontWeight="500",o.style.fontSize="14px",o.style.marginLeft="8px",o.style.marginRight="16px",o.style.opacity="0",o.style.transform="translateX(-8px)",o.style.transition="all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",o.style.whiteSpace="nowrap",o.style.letterSpacing="0.025em",e.appendChild(n),e.appendChild(o),document.body.appendChild(e),e.addEventListener("mouseenter",(()=>{e.style.width="100px",e.style.borderRadius="28px",e.style.boxShadow="0 8px 25px 0 rgba(102, 126, 234, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1)",e.style.transform="translateY(-2px)",o.style.opacity="1",o.style.transform="translateX(0)",n.style.transform="scale(1.05)"})),e.addEventListener("mouseleave",(()=>{e.style.width="40px",e.style.height="40px",e.style.borderRadius="50px",e.style.boxShadow="0 4px 14px 0 rgba(102, 126, 234, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05)",e.style.transform="translateY(0)",o.style.opacity="0",o.style.transform="translateX(-8px)",n.style.transform="scale(1)"})),e.addEventListener("mousedown",(()=>{e.style.transform="translateY(0) scale(0.98)",e.style.boxShadow="0 2px 8px 0 rgba(102, 126, 234, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05)"})),e.addEventListener("mouseup",(()=>{e.style.transform="translateY(-2px)",e.style.boxShadow="0 8px 25px 0 rgba(102, 126, 234, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1)"})),o.addEventListener("click",(()=>{_showPopup("Testimonials Error","There was an error loading testimonials. Please try again later. If the issue persists, please contact support.",[],"❌")}));const i=()=>{window.innerWidth<=768?(e.style.bottom="16px",e.style.right="16px",e.style.width="48px",e.style.height="48px",n.style.width="48px",n.style.height="48px",n.style.fontSize="18px",o.style.fontSize="13px",o.style.marginLeft="6px",o.style.marginRight="12px"):(e.style.bottom="30px",e.style.right="30px",e.style.width="40px",e.style.height="40px",n.style.width="40px",n.style.height="40px",n.style.fontSize="20px",o.style.fontSize="14px",o.style.marginLeft="8px",o.style.marginRight="16px")};i(),window.addEventListener("resize",i)}const scriptEl=Array.from(document.scripts).find((t=>t.src.includes("pinglet-sse")&&t.dataset.endpoint)),currentScript=scriptEl||document.currentScript,endpoint=currentScript?.dataset.endpoint,configuredDomain=currentScript?.dataset.configuredDomain,projectId=currentScript?.dataset.projectId,pingletId=currentScript?.dataset.pingletId,loadTemplates=currentScript?.dataset.loadTemplates,checksum=currentScript?.dataset.checksum,testimonials=currentScript?.dataset.testimonials;(async t=>{if(t.PingletWidget)return void console.warn("PingletWidget is already initialized.");injectFont(),askNotificationPermissionFunction(endpoint,projectId),testimonials&&ShowTestimonials();let e={};const n={version:"0.0.2",checksum:checksum.replace("sha384-",""),async init({endpoint:t,configuredDomain:n,projectId:o,pingletId:i}){if("0.0.2"!==this.version)return _showPopup("Unsupported Version",`PingletWidget version ${this.version} is not supported. Please update to the latest version.`,[{text:"See Docs",onClick:'window.open("https://pinglet.enjoys.in/docs", "_blank")'}],"⚠️"),void console.warn("Unsupported version detected.");if(!this.checksum||!checksum)return _showPopup("Configuration Error","Missing checksum.");const s=await fetch(`${t}/load/projects?projectId=${o}&domain=${n}`,{headers:{"X-Project-ID":o,"X-Timestamp":Date.now(),"X-Pinglet-Signature":i,"X-Pinglet-Checksum":this.checksum,"X-Pinglet-Version":this.version,"X-Configured-Domain":n,"X-Pinglet-Id":i},credentials:"omit"}),a=await s.json();if(!a||!a.success)return _showPopup("Configuration Error",`Failed to load configuration for PingletWidget. ${a.message||"Unknown error"}`,[{text:"Retry",onClick:"window.location.reload()"},{text:"See Docs",onClick:'window.open("https://pinglet.enjoys.in/docs", "_blank")'}],"❌"),console.error("Failed to load configuration for PingletWidget.");if("true"===loadTemplates){const n=await loadAllTemplates(t,o,i,this.checksum,this.version);n||_showPopup("Configuration Error","Failed to load templates for PingletWidget."),e=n}const l={is_tff:a.result?.is_premium??!1,templates:Object.assign({},{default:{compiled_text:_showPopup.toString(),config:defaultConfig,is_active:!0,is_default:!0}},"true"===loadTemplates?e:{[String(a.result.template?.id.toString())]:a.result.template}),style:Object.assign({},defaultStyles,a.result.template?.config),config:Object.assign({},defaultConfig,a.result.config)};initWidget(l);new EventSource(`${t}/sse?projectId=${o}&pingletId=${i}`,{withCredentials:!1}).onmessage=t=>{const e=JSON.parse(t.data),n=e.data;if(l?.is_tdd&&Object.assign(l.config,l.config,n?.overrides??{}),"1"===e?.type&&e?.template_id&&e?.data){return renderToast(interPolateTemplateWithData("",e?.data),l)}if("0"===e?.type&&e?.body){renderToast(createVariant(e.body,l),l)}else TriggerBrowserNotificationApi(body.title,body.description,body.type?.icon?.src||"")}}};t.PingletWidget=n,document.addEventListener("DOMContentLoaded",(()=>{n.init({endpoint:endpoint,configuredDomain:configuredDomain,projectId:projectId,pingletId:pingletId})})),console.log("%cPingletWidget initialized successfully.","color: #1e90ff; font-weight: bold;")})(window)})();