@growth-rail/core 2.0.0 → 2.1.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # @growth-rail/core
2
+
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Updated new fields
8
+
9
+ ## 2.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - added read me
14
+
15
+ ## 2.0.0
16
+
17
+ ### Major Changes
18
+
19
+ - d4cc14b: build size reduction
20
+
21
+ ## 1.0.0
22
+
23
+ ### Major Changes
24
+
25
+ - Initial SDK Version
package/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # @growth-rail/core
2
+
3
+ The foundation of the Growth Rail SDK. A platform-agnostic, pure TypeScript library for tracking referrals, managing user sessions, and interacting with the Growth Rail API.
4
+
5
+ ## 🚀 Features
6
+
7
+ - **Platform Agnostic**: Works in Node.js, Browsers, and React Native.
8
+ - **Lightweight**: Zero dependencies (except for environment-specific polyfills).
9
+ - **Isomorphic**: Unified API for client and server-side tracking.
10
+ - **Type-Safe**: First-class TypeScript support.
11
+ - **Modular**: Easy to extend or wrap with framework-specific adapters.
12
+
13
+ ## 📦 Installation
14
+
15
+ ```bash
16
+ # npm
17
+ npm install @growth-rail/core
18
+
19
+ # yarn
20
+ yarn add @growth-rail/core
21
+
22
+ # pnpm
23
+ pnpm add @growth-rail/core
24
+ ```
25
+
26
+ ## 🛠 Usage
27
+
28
+ ### Initialization
29
+
30
+ Initialize the singleton instance with your API Key.
31
+
32
+ ```typescript
33
+ import { GrowthRail } from '@growth-rail/core';
34
+
35
+ GrowthRail.init({
36
+ apiKey: 'your_api_key_here'
37
+ });
38
+
39
+ // Initialize a user session
40
+ await GrowthRail.initAppUser('user_external_id_123');
41
+ ```
42
+
43
+ ### Tracking Referrals
44
+
45
+ Track when a new user arrives with a referral code.
46
+
47
+ ```typescript
48
+ import { GrowthRail } from '@growth-rail/core';
49
+
50
+ async function handleReferral(code: string) {
51
+ const result = await GrowthRail.trackReferral(code);
52
+ console.log('Referral success:', result.success);
53
+ }
54
+ ```
55
+
56
+ ### Creating Referral Links
57
+
58
+ Generate a referral link for a user to share.
59
+
60
+ ```typescript
61
+ import { GrowthRail } from '@growth-rail/core';
62
+
63
+ async function getLink() {
64
+ const { referralLink } = await GrowthRail.createReferralLink(
65
+ GrowthRail.getUserId()
66
+ );
67
+ return referralLink;
68
+ }
69
+ ```
70
+
71
+ ## 🔌 Framework Wrappers
72
+
73
+ Looking for a framework-specific version?
74
+ - [React SDK (@growth-rail/react)](https://www.npmjs.com/package/@growth-rail/react)
75
+ - [React Native SDK (@growth-rail/react-native)](https://www.npmjs.com/package/@growth-rail/react-native)
76
+
77
+ ## 📖 Documentation
78
+
79
+ For full documentation and advanced configuration, visit [docs.growthrail.com](https://docs.growthrail.com).
80
+
81
+ ## 📄 License
82
+
83
+ MIT © [Growth Rail](https://growthrail.com)
package/dist/index.d.mts CHANGED
@@ -33,15 +33,16 @@ type TriggerButtonPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top
33
33
  type ReferrerTriggerButton = {
34
34
  show: boolean;
35
35
  position: TriggerButtonPosition;
36
- type: 'floating' | 'edge';
36
+ displayMode: 'floating' | 'edge';
37
37
  };
38
38
  type ReferrerModalOptions = {
39
39
  title: string;
40
40
  description: string;
41
- type: 'modal' | 'drawer';
41
+ componentType: 'modal' | 'drawer';
42
42
  theme: {
43
43
  primaryColor: string;
44
44
  tintColor: string;
45
+ tintAlpha: number;
45
46
  backgroundColor: string;
46
47
  };
47
48
  };
@@ -84,7 +85,6 @@ declare class GrowthRail {
84
85
  static isUserReady(): boolean;
85
86
  static ensureUserReady(): Promise<AppUserType>;
86
87
  static showReferralDashboard(options?: Partial<ReferrerModalOptions>): Promise<void>;
87
- private static createPromotionalBanner;
88
88
  static createTriggerButton(options: Partial<ReferrerTriggerButton>): void;
89
89
  static destroyTriggerButton(): void;
90
90
  }
package/dist/index.d.ts CHANGED
@@ -33,15 +33,16 @@ type TriggerButtonPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top
33
33
  type ReferrerTriggerButton = {
34
34
  show: boolean;
35
35
  position: TriggerButtonPosition;
36
- type: 'floating' | 'edge';
36
+ displayMode: 'floating' | 'edge';
37
37
  };
38
38
  type ReferrerModalOptions = {
39
39
  title: string;
40
40
  description: string;
41
- type: 'modal' | 'drawer';
41
+ componentType: 'modal' | 'drawer';
42
42
  theme: {
43
43
  primaryColor: string;
44
44
  tintColor: string;
45
+ tintAlpha: number;
45
46
  backgroundColor: string;
46
47
  };
47
48
  };
@@ -84,7 +85,6 @@ declare class GrowthRail {
84
85
  static isUserReady(): boolean;
85
86
  static ensureUserReady(): Promise<AppUserType>;
86
87
  static showReferralDashboard(options?: Partial<ReferrerModalOptions>): Promise<void>;
87
- private static createPromotionalBanner;
88
88
  static createTriggerButton(options: Partial<ReferrerTriggerButton>): void;
89
89
  static destroyTriggerButton(): void;
90
90
  }
package/dist/index.js CHANGED
@@ -1,11 +1,70 @@
1
- "use strict";var y=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var E=(d,e,r)=>e in d?y(d,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):d[e]=r;var C=(d,e)=>{for(var r in e)y(d,r,{get:e[r],enumerable:!0})},T=(d,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of R(e))!k.call(d,n)&&n!==r&&y(d,n,{get:()=>e[n],enumerable:!(i=w(e,n))||i.enumerable});return d};var P=d=>T(y({},"__esModule",{value:!0}),d);var a=(d,e,r)=>E(d,typeof e!="symbol"?e+"":e,r);var U={};C(U,{GrowthRail:()=>m,ReferralModal:()=>u});module.exports=P(U);var b=class{constructor(e){a(this,"baseUrl");a(this,"apiKey");let r=typeof process<"u"&&process.env?.ENV_BASE_URL;this.baseUrl=r||"http://hw84ko0ok4ccws4sws8gos0o.193.31.30.10.sslip.io",this.apiKey=e.apiKey}async request(e,r,i){let n={"Content-Type":"application/json","X-GrowthRail-ProjectSecret":this.apiKey};try{let o=await fetch(`${this.baseUrl}${e}`,{method:r,headers:n,body:i?JSON.stringify(i):void 0});if(!o.ok)throw new Error(`GrowthRail API Error: ${o.statusText}`);return o.json()}catch(o){throw console.error("GrowthRail SDK Error:",o),o}}async getNewUserExperience(){return this.request("/api/v1/sdk/new-user-experience","POST")}async initAppUser(e){return this.request("/api/v1/sdk/init-app-user","POST",{clientProvidedId:e})}async createReferralLink(e,r){return this.request("/api/v1/sdk/create-referral-link","POST",{referrerId:e,rewardEventName:r})}async trackReferral(e,r){return this.request("/api/v1/sdk/track-referral","POST",{referralCode:e,rewardEventName:r})}async trackRewardEvent(e,r,i){return this.request("/api/v1/sdk/track-reward-event","POST",{refereeId:e,referralTrackingId:r,eventName:i})}};var f=class f{constructor(e){a(this,"options",{});e&&(this.options=e)}setCookie(e,r,i=30){if(typeof document>"u")return;let n="";if(i){let s=new Date;s.setTime(s.getTime()+i*24*60*60*1e3),n=`; expires=${s.toUTCString()}`}let o="";this.options.cookieDomain&&(o=`; domain=${this.options.cookieDomain}`),document.cookie=`${e}=${r||""}${n}${o}; path=/; SameSite=Lax`}getCookie(e){if(typeof document>"u")return null;let r=`${e}=`,i=document.cookie.split(";");for(let n=0;n<i.length;n++){let o=i[n];for(;o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(r)===0)return o.substring(r.length,o.length)}return null}getReferralCode(){return this.getCookie(f.REFERRAL_CODE_KEY)}setReferralCode(e){this.setCookie(f.REFERRAL_CODE_KEY,e,30)}setTrackedReferral(e){this.setCookie(f.TRACKED_REFERRAL_KEY,e,30)}getTrackedReferral(){return this.getCookie(f.TRACKED_REFERRAL_KEY)}};a(f,"REFERRAL_CODE_KEY","gr_ref_code"),a(f,"TRACKED_REFERRAL_KEY","gr_tracked_referral");var x=f;var u=class{constructor(e,r){a(this,"referrerExperience");a(this,"deps");a(this,"host",null);a(this,"shadow",null);a(this,"overlay",null);a(this,"content",null);this.deps=e,this.referrerExperience=r}show(e,r){this.host||(this.createDom(e,r),this.bindEvents(),r||(document.body.style.overflow="hidden"))}hide(){this.host&&(this.host&&this.host.parentNode&&this.host.parentNode.removeChild(this.host),this.host=null,this.overlay=null,this.content=null,this.shadow=null,document.body.style.overflow="")}createDom(e,r){let i={...this.referrerExperience,...e??{}},n=this.getTheme(),o={...n,colorPrimary:i.modal?.theme?.primaryColor||n.colorPrimary,colorBackground:i.modal?.theme?.backgroundColor||n.colorBackground,colorTint:i.modal?.theme?.tintColor||n.colorTint},s=!!r;this.host=document.createElement("div"),this.host.style.all="initial",s?(this.host.style.display="block",this.host.style.width="100%",this.host.style.height="100%"):(this.host.style.position="absolute",this.host.style.zIndex="2147483647"),this.host.id="growth-rail-modal-host",this.host.style.setProperty("--gr-primary",o.colorPrimary),this.host.style.setProperty("--gr-text",o.colorText),this.host.style.setProperty("--gr-text-secondary",o.colorTextSecondary),this.host.style.setProperty("--gr-bg",o.colorBackground),this.host.style.setProperty("--gr-tint",o.colorTint),this.host.style.setProperty("--gr-surface",o.colorSurface),this.host.style.setProperty("--gr-border",o.colorBorder),this.host.style.setProperty("--gr-error",o.colorError),this.host.style.setProperty("--gr-radius",o.borderRadius),this.host.style.setProperty("--gr-font",'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),this.shadow=this.host.attachShadow({mode:"open"});let c=document.createElement("style");c.textContent=":host{all:initial;display:block}*{box-sizing:border-box}@keyframes gr-fade-in{from{opacity:0}to{opacity:1}}@keyframes gr-slide-up{from{opacity:0;transform:translateY(20px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes gr-slide-in-right{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}@keyframes gr-slide-in-left{from{opacity:0;transform:translateX(-100%)}to{opacity:1;transform:translateX(0)}}.gr-overlay{position:fixed;top:0;left:0;width:100vw;height:100vh;display:flex;z-index:2147483647;font-family:var(--gr-font);animation:gr-fade-in .2s ease-out forwards;backdrop-filter:blur(4px)}.gr-overlay--modal{background-color:var(--gr-tint);align-items:center;justify-content:center}.gr-overlay--drawer{background-color:var(--gr-tint);align-items:flex-start;justify-content:flex-start}.gr-container{position:relative;background-color:var(--gr-bg);color:var(--gr-text);padding:32px;box-shadow:0 20px 25px -5px rgba(0,0,0,.1),0 10px 10px -5px rgba(0,0,0,.04)}.gr-container--embedded{width:100%;height:100%;box-shadow:none;border:1px solid var(--gr-border);border-radius:var(--gr-radius)}.gr-container--modal{width:90%;max-width:480px;border-radius:var(--gr-radius);animation:gr-slide-up .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--drawer{position:absolute;width:400px;max-width:calc(100vw - 20px);max-height:calc(100vh - 40px);overflow-y:auto}.gr-container--right{right:0;border-top-left-radius:var(--gr-radius);border-bottom-left-radius:var(--gr-radius);animation:gr-slide-in-right .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--left{left:0;border-top-right-radius:var(--gr-radius);border-bottom-right-radius:var(--gr-radius);animation:gr-slide-in-left .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--top{top:100px}.gr-container--bottom{bottom:100px}.gr-close-btn{position:absolute;top:20px;right:20px;background:0 0;border:none;cursor:pointer;color:#9ca3af;padding:4px;border-radius:50%;display:flex;align-items:center;justify-content:center;transition:all .2s}.gr-close-btn:hover{background-color:var(--gr-surface);color:var(--gr-text)}.gr-header{text-align:center;margin-bottom:28px}.gr-icon-lg{font-size:32px;margin-bottom:12px}.gr-title{margin:0 0 8px 0;font-size:22px;font-weight:700;letter-spacing:-.02em}.gr-subtitle{margin:0;font-size:14px;line-height:1.5;color:var(--gr-text-secondary)}.gr-loading{padding:16px;background-color:var(--gr-surface);border-radius:8px;text-align:center;color:var(--gr-text-secondary);font-size:14px}.gr-label{display:block;font-size:12px;font-weight:600;color:var(--gr-text-secondary);margin-bottom:8px;text-transform:uppercase;letter-spacing:.05em}.gr-share-label{text-align:center;margin-bottom:16px;font-size:13px;font-weight:500;color:var(--gr-text-secondary);display:flex;align-items:center;gap:12px}.gr-divider{flex:1;height:1px;background:var(--gr-border)}.gr-social-container{display:flex;gap:16px;justify-content:center;flex-wrap:wrap}.gr-btn{padding:14px;font-size:15px;font-weight:600;background-color:var(--gr-primary);color:#fff;border:none;border-radius:var(--gr-radius);cursor:pointer;transition:all .2s ease;text-align:center;width:100%;display:block}.gr-btn:hover{transform:translateY(-1px);filter:brightness(1.05)}.gr-btn:active{transform:translateY(0);filter:brightness(.95)}.gr-btn:disabled{opacity:.7;cursor:not-allowed}.gr-btn--sm{padding:8px 16px;font-size:13px;width:auto;border-radius:calc(var(--gr-radius) - 4px)}.gr-input-group{display:flex;align-items:center;background-color:var(--gr-surface);border:1px solid var(--gr-border);border-radius:var(--gr-radius);padding:4px;margin-bottom:24px}.gr-input-group:focus-within{border-color:var(--gr-primary);box-shadow:0 0 0 3px var(--gr-surface)}.gr-input{flex:1;padding:10px 12px;font-size:14px;border:none;background:0 0;color:var(--gr-text);outline:none;font-family:monospace}.gr-social-btn{display:flex;align-items:center;justify-content:center;width:42px;height:42px;border-radius:50%;background-color:var(--gr-surface);color:var(--gr-text-secondary);border:1px solid var(--gr-border);transition:transform .2s cubic-bezier(.34,1.56,.64,1);cursor:pointer}.gr-social-btn:hover{transform:scale(1.15) rotate(3deg);color:#fff}.gr-powered-by{margin-top:24px;text-align:center;font-size:11px;color:#9ca3af;display:flex;align-items:center;justify-content:center;gap:4px;opacity:.8}.gr-powered-by a{color:inherit;text-decoration:none;font-weight:600;transition:opacity .2s}.gr-powered-by a:hover{opacity:1;text-decoration:underline}",this.shadow.appendChild(c),this.content=document.createElement("div");let p=i.modal.type==="drawer",l=i.trigger.position||"top-right",h=["gr-container"];s?(h.push("gr-container--embedded"),this.content.className=h.join(" "),this.renderInternalContent(o,e,s),this.shadow.appendChild(this.content),r&&r.appendChild(this.host)):(this.overlay=document.createElement("div"),this.overlay.className=`gr-overlay ${p?"gr-overlay--drawer":"gr-overlay--modal"}`,p?(h.push("gr-container--drawer"),l.includes("right")?h.push("gr-container--right"):h.push("gr-container--left"),l.includes("bottom")?h.push("gr-container--bottom"):h.push("gr-container--top")):h.push("gr-container--modal"),this.content.className=h.join(" "),this.renderInternalContent(o,e,s),this.overlay.appendChild(this.content),this.shadow.appendChild(this.overlay),document.body.appendChild(this.host),this.overlay.onclick=g=>{g.target===this.overlay&&this.hide()})}getTheme(){return{colorPrimary:"#2563eb",colorText:"#111827",colorTextSecondary:"#6b7280",colorBackground:"#ffffff",colorTint:"#f9fafb",colorSurface:"#f9fafb",colorBorder:"#e5e7eb",colorError:"#ef4444",borderRadius:"16px"}}async renderInternalContent(e,r,i=!1){if(!this.content)return;if(this.content.innerHTML="",!i){let g=document.createElement("button");g.className="gr-close-btn",g.innerHTML=`
1
+ "use strict";var b=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var z=(p,e,r)=>e in p?b(p,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):p[e]=r;var U=(p,e)=>{for(var r in e)b(p,r,{get:e[r],enumerable:!0})},M=(p,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of T(e))!P.call(p,i)&&i!==r&&b(p,i,{get:()=>e[i],enumerable:!(n=C(e,i))||n.enumerable});return p};var L=p=>M(b({},"__esModule",{value:!0}),p);var a=(p,e,r)=>z(p,typeof e!="symbol"?e+"":e,r);var A={};U(A,{GrowthRail:()=>x,ReferralModal:()=>m});module.exports=L(A);var y=class{constructor(e){a(this,"baseUrl");a(this,"apiKey");let r=typeof process<"u"&&process.env?.ENV_BASE_URL;this.baseUrl=r||"https://api.growthrail.dev",this.apiKey=e.apiKey}async request(e,r,n){let i={"Content-Type":"application/json","X-GrowthRail-ProjectSecret":this.apiKey};try{let o=await fetch(`${this.baseUrl}${e}`,{method:r,headers:i,body:n?JSON.stringify(n):void 0});if(!o.ok)throw new Error(`GrowthRail API Error: ${o.statusText}`);return o.json()}catch(o){throw console.error("GrowthRail SDK Error:",o),o}}async getNewUserExperience(){return this.request("/api/v1/sdk/new-user-experience","POST")}async initAppUser(e){return this.request("/api/v1/sdk/init-app-user","POST",{clientProvidedId:e})}async createReferralLink(e,r){return this.request("/api/v1/sdk/create-referral-link","POST",{referrerId:e,rewardEventName:r})}async trackReferral(e,r){return this.request("/api/v1/sdk/track-referral","POST",{referralCode:e,rewardEventName:r})}async trackRewardEvent(e,r,n){return this.request("/api/v1/sdk/track-reward-event","POST",{refereeId:e,referralTrackingId:r,eventName:n})}};var u=class u{constructor(e){a(this,"options",{});e&&(this.options=e)}setCookie(e,r,n=30){if(typeof document>"u")return;let i="";if(n){let s=new Date;s.setTime(s.getTime()+n*24*60*60*1e3),i=`; expires=${s.toUTCString()}`}let o="";this.options.cookieDomain&&(o=`; domain=${this.options.cookieDomain}`),document.cookie=`${e}=${r||""}${i}${o}; path=/; SameSite=Lax`}getCookie(e){if(typeof document>"u")return null;let r=`${e}=`,n=document.cookie.split(";");for(let i=0;i<n.length;i++){let o=n[i];for(;o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(r)===0)return o.substring(r.length,o.length)}return null}getReferralCode(){return this.getCookie(u.REFERRAL_CODE_KEY)}setReferralCode(e){this.setCookie(u.REFERRAL_CODE_KEY,e,30)}setTrackedReferral(e){this.setCookie(u.TRACKED_REFERRAL_KEY,e,30)}getTrackedReferral(){return this.getCookie(u.TRACKED_REFERRAL_KEY)}};a(u,"REFERRAL_CODE_KEY","gr_ref_code"),a(u,"TRACKED_REFERRAL_KEY","gr_tracked_referral");var v=u;var m=class{constructor(e,r){a(this,"referrerExperience");a(this,"deps");a(this,"host",null);a(this,"shadow",null);a(this,"overlay",null);a(this,"content",null);this.deps=e,this.referrerExperience=r}show(e,r){this.host||(this.createDom(e,r),this.bindEvents(),r||(document.body.style.overflow="hidden"))}hide(){this.host&&(this.host&&this.host.parentNode&&this.host.parentNode.removeChild(this.host),this.host=null,this.overlay=null,this.content=null,this.shadow=null,document.body.style.overflow="")}createDom(e,r){let n={...this.referrerExperience,modal:{...this.referrerExperience.modal,...e??{},theme:{...this.referrerExperience.modal?.theme,...e?.theme??{}}}},i=this.getTheme(),o={...i,colorPrimary:n.modal?.theme?.primaryColor||i.colorPrimary,colorBackground:n.modal?.theme?.backgroundColor||i.colorBackground,colorTint:n.modal?.theme?.tintColor||i.colorTint,tintAlpha:n.modal?.theme?.tintAlpha??i.tintAlpha},s=!!r;this.host=document.createElement("div"),this.host.style.all="initial",s?(this.host.style.display="block",this.host.style.width="100%",this.host.style.height="100%"):(this.host.style.position="absolute",this.host.style.zIndex="2147483647"),this.host.id="growth-rail-modal-host",this.host.style.setProperty("--gr-primary",o.colorPrimary),this.host.style.setProperty("--gr-text",o.colorText),this.host.style.setProperty("--gr-text-secondary",o.colorTextSecondary),this.host.style.setProperty("--gr-bg",o.colorBackground),this.host.style.setProperty("--gr-tint",o.colorTint);let l=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(o.colorTint),d=o.tintAlpha>1?o.tintAlpha/100:o.tintAlpha,c=l?`rgba(${parseInt(l[1],16)}, ${parseInt(l[2],16)}, ${parseInt(l[3],16)}, ${d})`:`rgba(0, 0, 0, ${d})`;this.host.style.setProperty("--gr-tint-rgba",c),this.host.style.setProperty("--gr-surface",o.colorSurface),this.host.style.setProperty("--gr-border",o.colorBorder),this.host.style.setProperty("--gr-error",o.colorError),this.host.style.setProperty("--gr-radius",o.borderRadius),this.host.style.setProperty("--gr-font",'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),this.shadow=this.host.attachShadow({mode:"open"});let h=document.createElement("style");h.textContent=":host{all:initial;display:block}*{box-sizing:border-box}@keyframes gr-fade-in{from{opacity:0}to{opacity:1}}@keyframes gr-slide-up{from{opacity:0;transform:translateY(20px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes gr-slide-in-right{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}@keyframes gr-slide-in-left{from{opacity:0;transform:translateX(-100%)}to{opacity:1;transform:translateX(0)}}.gr-overlay{position:fixed;top:0;left:0;width:100vw;height:100vh;display:flex;z-index:2147483647;font-family:var(--gr-font);animation:gr-fade-in .2s ease-out forwards;backdrop-filter:blur(4px);background-color:var(--gr-tint-rgba)}.gr-overlay--modal{align-items:center;justify-content:center}.gr-overlay--drawer{align-items:flex-start;justify-content:flex-start}.gr-container{position:relative;background-color:var(--gr-bg);color:var(--gr-text);padding:32px;box-shadow:0 0 50px -12px rgba(0,0,0,0.25), 0 0 30px -10px rgba(0,0,0,0.15)}.gr-container--embedded{width:100%;height:100%;box-shadow:none;border:1px solid var(--gr-border);border-radius:var(--gr-radius)}.gr-container--modal{width:90%;max-width:480px;border-radius:var(--gr-radius);animation:gr-slide-up .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--drawer{position:absolute;width:400px;max-width:calc(100vw - 20px);max-height:calc(100vh - 40px);overflow-y:auto}.gr-container--right{right:0;border-top-left-radius:var(--gr-radius);border-bottom-left-radius:var(--gr-radius);animation:gr-slide-in-right .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--left{left:0;border-top-right-radius:var(--gr-radius);border-bottom-right-radius:var(--gr-radius);animation:gr-slide-in-left .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--top{top:100px}.gr-container--bottom{bottom:100px}.gr-close-btn{position:absolute;top:20px;right:20px;background:0 0;border:none;cursor:pointer;color:#9ca3af;padding:4px;border-radius:50%;display:flex;align-items:center;justify-content:center;transition:all .2s}.gr-close-btn:hover{background-color:var(--gr-surface);color:var(--gr-text)}.gr-header{text-align:center;margin-bottom:28px}.gr-icon-lg{font-size:32px;margin-bottom:12px}.gr-title{margin:0 0 8px 0;font-size:22px;font-weight:700;letter-spacing:-.02em}.gr-subtitle{margin:0;font-size:14px;line-height:1.5;color:var(--gr-text-secondary)}.gr-loading{padding:16px;background-color:var(--gr-surface);border-radius:8px;text-align:center;color:var(--gr-text-secondary);font-size:14px}.gr-label{display:block;font-size:12px;font-weight:600;color:var(--gr-text-secondary);margin-bottom:8px;text-transform:uppercase;letter-spacing:.05em}.gr-share-label{text-align:center;margin-bottom:16px;font-size:13px;font-weight:500;color:var(--gr-text-secondary);display:flex;align-items:center;gap:12px}.gr-divider{flex:1;height:1px;background:var(--gr-border)}.gr-social-container{display:flex;gap:16px;justify-content:center;flex-wrap:wrap}.gr-btn{padding:14px;font-size:15px;font-weight:600;background-color:var(--gr-primary);color:#fff;border:none;border-radius:var(--gr-radius);cursor:pointer;transition:all .2s ease;text-align:center;width:100%;display:block}.gr-btn:hover{transform:translateY(-1px);filter:brightness(1.05)}.gr-btn:active{transform:translateY(0);filter:brightness(.95)}.gr-btn:disabled{opacity:.7;cursor:not-allowed}.gr-btn--sm{padding:8px 16px;font-size:13px;width:auto;border-radius:calc(var(--gr-radius) - 4px)}.gr-input-group{display:flex;align-items:center;background-color:var(--gr-surface);border:1px solid var(--gr-border);border-radius:var(--gr-radius);padding:4px;margin-bottom:24px}.gr-input-group:focus-within{border-color:var(--gr-primary);box-shadow:0 0 0 3px var(--gr-surface)}.gr-input{flex:1;padding:10px 12px;font-size:14px;border:none;background:0 0;color:var(--gr-text);outline:none;font-family:monospace}.gr-social-btn{display:flex;align-items:center;justify-content:center;width:42px;height:42px;border-radius:50%;background-color:var(--gr-surface);color:var(--gr-text-secondary);border:1px solid var(--gr-border);transition:transform .2s cubic-bezier(.34,1.56,.64,1);cursor:pointer}.gr-social-btn:hover{transform:scale(1.15) rotate(3deg);color:#fff}.gr-powered-by{margin-top:24px;text-align:center;font-size:11px;color:#9ca3af;display:flex;align-items:center;justify-content:center;gap:4px;opacity:.8}.gr-powered-by a{color:inherit;text-decoration:none;font-weight:600;transition:opacity .2s}.gr-powered-by a:hover{opacity:1;text-decoration:underline}",this.shadow.appendChild(h),this.content=document.createElement("div");let g=n.modal.componentType==="drawer",R=n.trigger.position||"top-right",f=["gr-container"];s?(f.push("gr-container--embedded"),this.content.className=f.join(" "),this.renderInternalContent(o,e,s),this.shadow.appendChild(this.content),r&&r.appendChild(this.host)):(this.overlay=document.createElement("div"),this.overlay.className=`gr-overlay ${g?"gr-overlay--drawer":"gr-overlay--modal"}`,g?(f.push("gr-container--drawer"),R.includes("right")?f.push("gr-container--right"):f.push("gr-container--left"),R.includes("bottom")?f.push("gr-container--bottom"):f.push("gr-container--top")):f.push("gr-container--modal"),this.content.className=f.join(" "),this.renderInternalContent(o,e,s),this.overlay.appendChild(this.content),this.shadow.appendChild(this.overlay),document.body.appendChild(this.host),this.overlay.onclick=E=>{E.target===this.overlay&&this.hide()})}getTheme(){return{colorPrimary:"#2563eb",colorText:"#111827",colorTextSecondary:"#6b7280",colorBackground:"#ffffff",colorTint:"#f9fafb",tintAlpha:.8,colorSurface:"#f9fafb",colorBorder:"#e5e7eb",colorError:"#ef4444",borderRadius:"16px"}}async renderInternalContent(e,r,n=!1){if(!this.content)return;if(this.content.innerHTML="",!n){let g=document.createElement("button");g.className="gr-close-btn",g.innerHTML=`
2
2
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
3
3
  <line x1="18" y1="6" x2="6" y2="18"></line>
4
4
  <line x1="6" y1="6" x2="18" y2="18"></line>
5
5
  </svg>
6
- `,g.onclick=()=>this.hide(),this.content.appendChild(g)}let n=document.createElement("div");n.className="gr-header";let o=document.createElement("div");o.className="gr-icon-lg",o.innerHTML="\u{1F381}",n.appendChild(o);let s=document.createElement("h3");s.className="gr-title",s.textContent=r?.title??this.referrerExperience.modal.title??"Invite Friends & Earn",n.appendChild(s);let c=document.createElement("p");if(c.className="gr-subtitle",c.textContent="Share your unique link and earn rewards for every friend who signs up.",n.appendChild(c),this.content.appendChild(n),!this.deps.isUserReady()){let g=document.createElement("div");g.className="gr-loading",g.textContent="Please log in to view your referral dashboard.",this.content.appendChild(g);return}let p=this.deps.getReferralLink(),l=document.createElement("div");this.renderLinkView(l,p,e),this.content.appendChild(l),p&&this.renderSocialShare(this.content,p,e);let h=document.createElement("div");h.className="gr-powered-by",h.innerHTML=`
6
+ `,g.onclick=()=>this.hide(),this.content.appendChild(g)}let i=document.createElement("div");i.className="gr-header";let o=document.createElement("div");o.className="gr-icon-lg",o.innerHTML="\u{1F381}",i.appendChild(o);let s=document.createElement("h3");s.className="gr-title",s.textContent=r?.title??this.referrerExperience.modal.title??"Invite Friends & Earn",i.appendChild(s);let l=document.createElement("p");if(l.className="gr-subtitle",l.textContent="Share your unique link and earn rewards for every friend who signs up.",i.appendChild(l),this.content.appendChild(i),!this.deps.isUserReady()){let g=document.createElement("div");g.className="gr-loading",g.textContent="Please log in to view your referral dashboard.",this.content.appendChild(g);return}let d=this.deps.getReferralLink(),c=document.createElement("div");this.renderLinkView(c,d,e),this.content.appendChild(c),d&&this.renderSocialShare(this.content,d,e);let h=document.createElement("div");h.className="gr-powered-by",h.innerHTML=`
7
7
  Powered by <a href="https://growthrail.com" target="_blank" rel="noopener noreferrer">Growth Rail</a>
8
- `,this.content.appendChild(h)}renderLinkView(e,r,i){let n=document.createElement("label");n.className="gr-label",n.textContent="Your unique link",e.appendChild(n);let o=document.createElement("div");o.className="gr-input-group";let s=document.createElement("input");s.className="gr-input",s.type="text",s.value=r,s.readOnly=!0;let c=document.createElement("button");c.className="gr-btn gr-btn--sm",c.textContent="Copy",c.onclick=async()=>{try{await navigator.clipboard.writeText(r);let p=c.textContent;c.textContent="Copied!",c.style.backgroundColor="#10b981",setTimeout(()=>{c.textContent=p,c.style.backgroundColor=""},2e3)}catch(p){console.error("Failed to copy",p)}},o.appendChild(s),o.appendChild(c),e.appendChild(o)}renderSocialShare(e,r,i){let n=document.createElement("div"),o=document.createElement("div");o.className="gr-share-label",o.innerHTML='<span class="gr-divider"></span>Share via<span class="gr-divider"></span>',n.appendChild(o);let s=document.createElement("div");s.className="gr-social-container",[{name:"Twitter",color:"#000000",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>',url:`https://twitter.com/intent/tweet?url=${encodeURIComponent(r)}&text=Check+this+out!`},{name:"Facebook",color:"#1877F2",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036c-2.648 0-2.928 1.67-2.928 3.403v1.596h3.949l-.577 3.667h-3.372v7.98h-4.938z"/></svg>',url:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(r)}`},{name:"LinkedIn",color:"#0A66C2",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>',url:`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(r)}`},{name:"WhatsApp",color:"#25D366",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/></svg>',url:`https://api.whatsapp.com/send?text=${encodeURIComponent(r)}`},{name:"Email",color:"#888888",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"/></svg>',url:`mailto:?subject=Check this out&body=${encodeURIComponent(r)}`}].forEach(p=>{let l=document.createElement("a");l.href=p.url,l.target="_blank",l.rel="noopener noreferrer",l.className="gr-social-btn",l.innerHTML=p.icon,l.title=`Share on ${p.name}`,l.onmouseenter=()=>{l.style.backgroundColor=p.color,l.style.color="#ffffff",l.style.borderColor=p.color},l.onmouseleave=()=>{l.style.backgroundColor="",l.style.color="",l.style.borderColor=""},s.appendChild(l)}),n.appendChild(s),e.appendChild(n)}bindEvents(){this.overlay&&(this.overlay.onclick=e=>{e.target===this.overlay&&this.hide()})}};var v=class{constructor(e){a(this,"options");a(this,"host",null);a(this,"shadow",null);a(this,"element",null);this.options=e}mount(){this.host||this.createDom()}unmount(){this.host&&this.host.parentNode&&document.body.removeChild(this.host),this.host=null,this.shadow=null,this.element=null}createDom(){this.host=document.createElement("div"),this.host.style.all="initial",this.host.style.position="absolute",this.host.style.zIndex="2147483646";let e={x:0,y:100};this.host.style.setProperty("--gr-offset-y",`${e.y}px`),this.shadow=this.host.attachShadow({mode:"open"});let r=document.createElement("style");r.textContent=":host{all:initial;display:block}@keyframes gr-shimmer{0%{transform:translateX(-150%) skewX(-15deg)}50%{transform:translateX(150%) skewX(-15deg)}100% {transform:translateX(150%) skewX(-15deg)}}.gr-floating-btn{position:fixed;width:50px;height:50px;background:linear-gradient(135deg,#6366f1 0%,#a855f7 100%);box-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,0.06);cursor:pointer;z-index:2147483646;display:flex;align-items:center;justify-content:center;transition:transform .2s cubic-bezier(.34,1.56,.64,1),box-shadow .2s ease,width .2s;overflow:hidden;font-family:system-ui,-apple-system,sans-serif;box-sizing:border-box}.gr-floating-btn *{box-sizing:border-box}.gr-floating-btn:hover{transform:scale(1.05);box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05)}.gr-floating-btn--right{right:0;border-top-left-radius:8px;border-bottom-left-radius:8px;border-top-right-radius:0;border-bottom-right-radius:0;padding-left:4px}.gr-floating-btn--left{left:0;border-top-right-radius:8px;border-bottom-right-radius:8px;border-top-left-radius:0;border-bottom-left-radius:0;padding-right:4px}.gr-floating-btn--bottom{bottom:var(--gr-offset-y)}.gr-floating-btn--top{top:var(--gr-offset-y)}.gr-floating-btn::after{content:'';position:absolute;top:0;left:0;width:100%;height:100%;background:linear-gradient(to right,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);transform:translateX(-150%) skewX(-15deg);animation:gr-shimmer 3s infinite}.gr-icon{color:#fff;width:24px;height:24px;position:relative;z-index:10}",this.shadow.appendChild(r),this.element=document.createElement("div");let i=this.options.position||"bottom-right",n=["gr-floating-btn"];i.includes("right")?n.push("gr-floating-btn--right"):n.push("gr-floating-btn--left"),i.includes("bottom")?n.push("gr-floating-btn--bottom"):n.push("gr-floating-btn--top"),this.element.className=n.join(" "),this.element.innerHTML=`
8
+ `,this.content.appendChild(h)}renderLinkView(e,r,n){let i=document.createElement("label");i.className="gr-label",i.textContent="Your unique link",e.appendChild(i);let o=document.createElement("div");o.className="gr-input-group";let s=document.createElement("input");s.className="gr-input",s.type="text",s.value=r,s.readOnly=!0;let l=document.createElement("button");l.className="gr-btn gr-btn--sm",l.textContent="Copy",l.onclick=async()=>{try{await navigator.clipboard.writeText(r);let d=l.textContent;l.textContent="Copied!",l.style.backgroundColor="#10b981",setTimeout(()=>{l.textContent=d,l.style.backgroundColor=""},2e3)}catch(d){console.error("Failed to copy",d)}},o.appendChild(s),o.appendChild(l),e.appendChild(o)}renderSocialShare(e,r,n){let i=document.createElement("div"),o=document.createElement("div");o.className="gr-share-label",o.innerHTML='<span class="gr-divider"></span>Share via<span class="gr-divider"></span>',i.appendChild(o);let s=document.createElement("div");s.className="gr-social-container",[{name:"Twitter",color:"#000000",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>',url:`https://twitter.com/intent/tweet?url=${encodeURIComponent(r)}&text=Check+this+out!`},{name:"Facebook",color:"#1877F2",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036c-2.648 0-2.928 1.67-2.928 3.403v1.596h3.949l-.577 3.667h-3.372v7.98h-4.938z"/></svg>',url:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(r)}`},{name:"LinkedIn",color:"#0A66C2",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>',url:`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(r)}`},{name:"WhatsApp",color:"#25D366",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/></svg>',url:`https://api.whatsapp.com/send?text=${encodeURIComponent(r)}`},{name:"Email",color:"#888888",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"/></svg>',url:`mailto:?subject=Check this out&body=${encodeURIComponent(r)}`}].forEach(d=>{let c=document.createElement("a");c.href=d.url,c.target="_blank",c.rel="noopener noreferrer",c.className="gr-social-btn",c.innerHTML=d.icon,c.title=`Share on ${d.name}`,c.onmouseenter=()=>{c.style.backgroundColor=d.color,c.style.color="#ffffff",c.style.borderColor=d.color},c.onmouseleave=()=>{c.style.backgroundColor="",c.style.color="",c.style.borderColor=""},s.appendChild(c)}),i.appendChild(s),e.appendChild(i)}bindEvents(){this.overlay&&(this.overlay.onclick=e=>{e.target===this.overlay&&this.hide()})}};var w=class{constructor(e){a(this,"options");a(this,"host",null);a(this,"shadow",null);a(this,"element",null);this.options=e}mount(){this.host||this.createDom()}unmount(){this.host&&this.host.parentNode&&document.body.removeChild(this.host),this.host=null,this.shadow=null,this.element=null}createDom(){this.host=document.createElement("div"),this.host.style.all="initial",this.host.style.position="absolute",this.host.style.zIndex="2147483646";let e={x:0,y:100};this.host.style.setProperty("--gr-offset-y",`${e.y}px`),this.shadow=this.host.attachShadow({mode:"open"});let r=document.createElement("style"),n=this.options.trigger?.displayMode||"edge";r.textContent=`
9
+ :host { all: initial; display: block; }
10
+ @keyframes gr-shimmer {
11
+ 0% { transform: translateX(-150%) skewX(-15deg); }
12
+ 50% { transform: translateX(150%) skewX(-15deg); }
13
+ 100% { transform: translateX(150%) skewX(-15deg); }
14
+ }
15
+ .gr-btn {
16
+ position: fixed;
17
+ width: 50px;
18
+ height: 50px;
19
+ background: ${this.options.modal?.theme?.primaryColor||"#000"};
20
+ box-shadow: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,0.06);
21
+ cursor: pointer;
22
+ z-index: 2147483646;
23
+ display: flex;
24
+ align-items: center;
25
+ justify-content: center;
26
+ transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, width .2s, border-radius .2s;
27
+ overflow: hidden;
28
+ font-family: system-ui, -apple-system, sans-serif;
29
+ box-sizing: border-box;
30
+ }
31
+ .gr-btn * { box-sizing: border-box; }
32
+ .gr-btn:hover {
33
+ transform: scale(1.05);
34
+ box-shadow: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,0.05);
35
+ }
36
+
37
+ /* Edge Mode Radii */
38
+ .gr-btn--edge.gr-btn--right { border-radius: 8px 0 0 8px; padding-left: 4px; right: 0; }
39
+ .gr-btn--edge.gr-btn--left { border-radius: 0 8px 8px 0; padding-right: 4px; left: 0; }
40
+
41
+ /* Floating Mode Radii & Position */
42
+ .gr-btn--floating {
43
+ border-radius: 50%;
44
+ box-shadow: 0 8px 24px color-mix(in srgb, ${this.options.modal?.theme?.primaryColor||"#000"}, transparent 60%);
45
+ }
46
+ .gr-btn--floating:hover {
47
+ box-shadow: 0 12px 32px color-mix(in srgb, ${this.options.modal?.theme?.primaryColor||"#000"}, transparent 40%);
48
+ }
49
+ .gr-btn--floating.gr-btn--right { right: 20px; }
50
+ .gr-btn--floating.gr-btn--left { left: 20px; }
51
+
52
+ .gr-btn--bottom { bottom: var(--gr-offset-y); }
53
+ .gr-btn--top { top: var(--gr-offset-y); }
54
+
55
+ .gr-btn::after {
56
+ content: '';
57
+ position: absolute;
58
+ top: 0;
59
+ left: 0;
60
+ width: 100%;
61
+ height: 100%;
62
+ background: linear-gradient(to right, transparent 0%, rgba(255,255,255,0.4) 50%, transparent 100%);
63
+ transform: translateX(-150%) skewX(-15deg);
64
+ animation: gr-shimmer 3s infinite;
65
+ }
66
+ .gr-icon { color: #fff; width: 24px; height: 24px; position: relative; z-index: 10; }
67
+ `,this.shadow.appendChild(r),this.element=document.createElement("div");let i=this.options.trigger?.position||"bottom-right",o=["gr-btn",`gr-btn--${n}`];i.includes("right")?o.push("gr-btn--right"):o.push("gr-btn--left"),i.includes("bottom")?o.push("gr-btn--bottom"):o.push("gr-btn--top"),this.element.className=o.join(" "),this.element.innerHTML=`
9
68
  <svg class="gr-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
10
69
  <polyline points="20 12 20 22 4 22 4 12"></polyline>
11
70
  <rect x="2" y="7" width="20" height="5"></rect>
@@ -13,5 +72,74 @@
13
72
  <path d="M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7z"></path>
14
73
  <path d="M12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7z"></path>
15
74
  </svg>
16
- `,this.element.onclick=()=>{m.showReferralDashboard()},this.shadow.appendChild(this.element),document.body.appendChild(this.host)}};var t=class t{constructor(){}static init(e){t.initialized||(t.options=e,t.api=new b(e),t.storage=new x({cookieDomain:e.cookieDomain}),t.initialized=!0,t.autoTrackReferral())}static isInitialized(){return t.initialized}static ensureInitialized(){if(!t.initialized)throw new Error("GrowthRail.init() must be called before using the SDK")}static async loadReferrerExperience(e){try{t.createReferralModal(e),e.trigger.show&&t.createTriggerButton(e.trigger)}catch(r){throw console.error("GrowthRail: Failed to load referrer experience",r),r}}static createReferralModal(e){t.referralModal=new u({isUserReady:()=>t.isUserReady(),getReferralLink:()=>t.currentUser?.referralLink||""},e)}static async autoTrackReferral(){if(typeof window>"u")return;let e=new URLSearchParams(window.location.search),r=e.get("referralCode"),i=e.get("rewardEventName");if(r){let n=await t.api.getNewUserExperience(),o=await t.trackReferral(r,i??void 0);t.storage.setTrackedReferral(o.referralTrackingId),o.promotionalText&&n.banner.show&&t.createPromotionalBanner(o.promotionalText,n)}}static async initAppUser(e){t.ensureInitialized();let r=await t.api.initAppUser(e);return t.currentUser={...r,id:e},t.experience=r.referrerExperience,t.loadReferrerExperience(r.referrerExperience),t.userReadyResolver?t.userReadyResolver(t.currentUser):t.userReadyPromise=Promise.resolve(t.currentUser),r}static async trackReferral(e,r){return t.ensureInitialized(),t.api.trackReferral(e,r)}static async trackRewardEvent(e){t.ensureInitialized();let r=t.currentUser?.id;if(!r)throw new Error("GrowthRail: User must be initialized before tracking a reward event.");let i=t.storage.getTrackedReferral();if(!i)throw new Error("GrowthRail: Referral Tracking Id must be initialized before tracking a reward event.");return t.api.trackRewardEvent(r,i,e)}static getReferralLink(){if(!t.currentUser?.referralLink)throw new Error("GrowthRail: Referral Link not loaded or user not initialized");return t.currentUser.referralLink}static getReferralCode(){return t.currentUser?.referralCode}static getUserId(){return t.currentUser?.id}static isUserReady(){return t.currentUser!==null}static ensureUserReady(){return t.currentUser?Promise.resolve(t.currentUser):(t.userReadyPromise||(t.userReadyPromise=new Promise(e=>{t.userReadyResolver=e})),t.userReadyPromise)}static async showReferralDashboard(e){if(t.ensureInitialized(),!t.experience)throw new Error("GrowthRail: Experience not loaded");t.referralModal&&t.referralModal.hide(),t.referralModal?.show(e)}static createPromotionalBanner(e,r){if(typeof document>"u")return;let i=document.createElement("div");i.style.position="fixed",i.style.top=r.banner.position.split("-")[1]==="top"?"0":"auto",i.style.bottom=r.banner.position.split("-")[1]==="bottom"?"0":"auto",i.style.left=r.banner.position.split("-")[0]==="left"?"0":"auto",i.style.right=r.banner.position.split("-")[0]==="right"?"0":"auto",i.style.width="100%",i.style.margin="auto",i.style.backgroundColor="#f0f0f0",i.style.padding="10px",i.style.textAlign="center",i.style.zIndex="10000",i.textContent=e,document.body.appendChild(i)}static createTriggerButton(e){if(typeof window>"u")return;if(!t.experience)throw new Error("GrowthRail: Experience not loaded");t.floatingButton&&t.floatingButton.unmount();let r={...t.experience?.trigger,...e};t.floatingButton=new v(r),t.floatingButton.mount()}static destroyTriggerButton(){t.floatingButton&&(t.floatingButton.unmount(),t.floatingButton=null)}};a(t,"api"),a(t,"storage"),a(t,"options"),a(t,"currentUser",null),a(t,"initialized",!1),a(t,"referralModal",null),a(t,"floatingButton",null),a(t,"experience",null),a(t,"userReadyPromise",null),a(t,"userReadyResolver",null);var m=t;0&&(module.exports={GrowthRail,ReferralModal});
17
- //# sourceMappingURL=index.js.map
75
+ `,this.element.onclick=()=>{x.showReferralDashboard()},this.shadow.appendChild(this.element),document.body.appendChild(this.host)}};var k=class{static show(e){if(typeof document>"u")return;let r=document.createElement("div");r.id="gr-banner-host",document.body.appendChild(r);let n=r.attachShadow({mode:"open"}),i=(e.banner.position||"center-top").toLowerCase(),o=i.includes("bottom")?"bottom":"top",s=i.includes("left")?"left":i.includes("right")?"right":"center",l="",d="";s==="center"?(l="left: 50%;",d="translateX(-50%)"):(l=`${s}: 20px;`,d="translateX(0)");let c=document.createElement("style");c.textContent=`
76
+ .gr-banner {
77
+ position: fixed;
78
+ ${o}: 20px;
79
+ ${l}
80
+ z-index: 2147483647;
81
+ font-family: Inter, system-ui, -apple-system, sans-serif;
82
+ background: #ffffff;
83
+ color: #111827;
84
+ padding: 12px 20px;
85
+ border-radius: 12px;
86
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
87
+ display: flex;
88
+ align-items: center;
89
+ gap: 12px;
90
+ width: max-content;
91
+ max-width: 500px;
92
+ border: 1px solid #e5e7eb;
93
+ animation: gr-slide-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
94
+ box-sizing: border-box;
95
+ }
96
+
97
+ @keyframes gr-slide-in {
98
+ from {
99
+ opacity: 0;
100
+ transform: ${d} translateY(${o==="top"?"-20px":"20px"});
101
+ }
102
+ to {
103
+ opacity: 1;
104
+ transform: ${d} translateY(0);
105
+ }
106
+ }
107
+
108
+ .gr-icon {
109
+ width: 22px;
110
+ height: 22px;
111
+ color: #0070f3; /* Premium blue for the gift icon */
112
+ flex-shrink: 0;
113
+ }
114
+ .gr-text { font-size: 14px; font-weight: 500; line-height: 1.4; margin: 0; color: #1f2937; flex: 1; }
115
+ .gr-close {
116
+ background: transparent;
117
+ border: none;
118
+ color: #9ca3af;
119
+ cursor: pointer;
120
+ padding: 4px;
121
+ margin-left: 8px;
122
+ border-radius: 6px;
123
+ display: flex;
124
+ align-items: center;
125
+ justify-content: center;
126
+ transition: all 0.2s;
127
+ flex-shrink: 0;
128
+ }
129
+ .gr-close:hover { background: #f3f4f6; color: #4b5563; }
130
+ `;let h=document.createElement("div");h.className="gr-banner",h.innerHTML=`
131
+ <svg class="gr-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
132
+ <polyline points="20 12 20 22 4 22 4 12"></polyline>
133
+ <rect x="2" y="7" width="20" height="5"></rect>
134
+ <line x1="12" y1="22" x2="12" y2="7"></line>
135
+ <path d="M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7z"></path>
136
+ <path d="M12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7z"></path>
137
+ </svg>
138
+ <p class="gr-text">${e.banner.text}</p>
139
+ <button class="gr-close" aria-label="Close banner">
140
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
141
+ <line x1="18" y1="6" x2="6" y2="18"></line>
142
+ <line x1="6" y1="6" x2="18" y2="18"></line>
143
+ </svg>
144
+ </button>
145
+ `,h.querySelector(".gr-close")?.addEventListener("click",()=>{r.remove()}),n.appendChild(c),n.appendChild(h)}};var t=class t{constructor(){}static init(e){t.initialized||(t.options=e,t.api=new y(e),t.storage=new v({cookieDomain:e.cookieDomain}),t.initialized=!0,t.autoTrackReferral())}static isInitialized(){return t.initialized}static ensureInitialized(){if(!t.initialized)throw new Error("GrowthRail.init() must be called before using the SDK")}static async loadReferrerExperience(e){try{t.createReferralModal(e),e.trigger.show&&t.createTriggerButton(e.trigger)}catch(r){throw console.error("GrowthRail: Failed to load referrer experience",r),r}}static createReferralModal(e){t.referralModal=new m({isUserReady:()=>t.isUserReady(),getReferralLink:()=>t.currentUser?.referralLink||""},e)}static async autoTrackReferral(){if(typeof window>"u")return;let e=new URLSearchParams(window.location.search),r=e.get("referralCode"),n=e.get("rewardEventName");if(r){let i=await t.api.getNewUserExperience(),o=await t.trackReferral(r,n??void 0);t.storage.setTrackedReferral(o.referralTrackingId),i.banner.show&&k.show(i)}}static async initAppUser(e){t.ensureInitialized();let r=await t.api.initAppUser(e);return t.currentUser={...r,id:e},t.experience=r.referrerExperience,t.loadReferrerExperience(r.referrerExperience),t.userReadyResolver?t.userReadyResolver(t.currentUser):t.userReadyPromise=Promise.resolve(t.currentUser),r}static async trackReferral(e,r){return t.ensureInitialized(),t.api.trackReferral(e,r)}static async trackRewardEvent(e){t.ensureInitialized();let r=t.currentUser?.id;if(!r)throw new Error("GrowthRail: User must be initialized before tracking a reward event.");let n=t.storage.getTrackedReferral();if(!n)throw new Error("GrowthRail: Referral Tracking Id must be initialized before tracking a reward event.");return t.api.trackRewardEvent(r,n,e)}static getReferralLink(){if(!t.currentUser?.referralLink)throw new Error("GrowthRail: Referral Link not loaded or user not initialized");return t.currentUser.referralLink}static getReferralCode(){return t.currentUser?.referralCode}static getUserId(){return t.currentUser?.id}static isUserReady(){return t.currentUser!==null}static ensureUserReady(){return t.currentUser?Promise.resolve(t.currentUser):(t.userReadyPromise||(t.userReadyPromise=new Promise(e=>{t.userReadyResolver=e})),t.userReadyPromise)}static async showReferralDashboard(e){if(t.ensureInitialized(),!t.experience)throw new Error("GrowthRail: Experience not loaded");t.referralModal&&t.referralModal.hide(),t.referralModal?.show(e)}static createTriggerButton(e){if(typeof window>"u")return;if(!t.experience)throw new Error("GrowthRail: Experience not loaded");t.floatingButton&&t.floatingButton.unmount();let r={...t.experience?.trigger,...e},n={modal:{...t.experience.modal},trigger:r};t.floatingButton=new w(n),t.floatingButton.mount()}static destroyTriggerButton(){t.floatingButton&&(t.floatingButton.unmount(),t.floatingButton=null)}};a(t,"api"),a(t,"storage"),a(t,"options"),a(t,"currentUser",null),a(t,"initialized",!1),a(t,"referralModal",null),a(t,"floatingButton",null),a(t,"experience",null),a(t,"userReadyPromise",null),a(t,"userReadyResolver",null);var x=t;0&&(module.exports={GrowthRail,ReferralModal});
package/dist/index.mjs CHANGED
@@ -1,11 +1,70 @@
1
- var v=Object.defineProperty;var w=(g,e,t)=>e in g?v(g,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):g[e]=t;var a=(g,e,t)=>w(g,typeof e!="symbol"?e+"":e,t);var u=class{constructor(e){a(this,"baseUrl");a(this,"apiKey");let t=typeof process<"u"&&process.env?.ENV_BASE_URL;this.baseUrl=t||"http://hw84ko0ok4ccws4sws8gos0o.193.31.30.10.sslip.io",this.apiKey=e.apiKey}async request(e,t,i){let n={"Content-Type":"application/json","X-GrowthRail-ProjectSecret":this.apiKey};try{let o=await fetch(`${this.baseUrl}${e}`,{method:t,headers:n,body:i?JSON.stringify(i):void 0});if(!o.ok)throw new Error(`GrowthRail API Error: ${o.statusText}`);return o.json()}catch(o){throw console.error("GrowthRail SDK Error:",o),o}}async getNewUserExperience(){return this.request("/api/v1/sdk/new-user-experience","POST")}async initAppUser(e){return this.request("/api/v1/sdk/init-app-user","POST",{clientProvidedId:e})}async createReferralLink(e,t){return this.request("/api/v1/sdk/create-referral-link","POST",{referrerId:e,rewardEventName:t})}async trackReferral(e,t){return this.request("/api/v1/sdk/track-referral","POST",{referralCode:e,rewardEventName:t})}async trackRewardEvent(e,t,i){return this.request("/api/v1/sdk/track-reward-event","POST",{refereeId:e,referralTrackingId:t,eventName:i})}};var f=class f{constructor(e){a(this,"options",{});e&&(this.options=e)}setCookie(e,t,i=30){if(typeof document>"u")return;let n="";if(i){let s=new Date;s.setTime(s.getTime()+i*24*60*60*1e3),n=`; expires=${s.toUTCString()}`}let o="";this.options.cookieDomain&&(o=`; domain=${this.options.cookieDomain}`),document.cookie=`${e}=${t||""}${n}${o}; path=/; SameSite=Lax`}getCookie(e){if(typeof document>"u")return null;let t=`${e}=`,i=document.cookie.split(";");for(let n=0;n<i.length;n++){let o=i[n];for(;o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(t)===0)return o.substring(t.length,o.length)}return null}getReferralCode(){return this.getCookie(f.REFERRAL_CODE_KEY)}setReferralCode(e){this.setCookie(f.REFERRAL_CODE_KEY,e,30)}setTrackedReferral(e){this.setCookie(f.TRACKED_REFERRAL_KEY,e,30)}getTrackedReferral(){return this.getCookie(f.TRACKED_REFERRAL_KEY)}};a(f,"REFERRAL_CODE_KEY","gr_ref_code"),a(f,"TRACKED_REFERRAL_KEY","gr_tracked_referral");var m=f;var y=class{constructor(e,t){a(this,"referrerExperience");a(this,"deps");a(this,"host",null);a(this,"shadow",null);a(this,"overlay",null);a(this,"content",null);this.deps=e,this.referrerExperience=t}show(e,t){this.host||(this.createDom(e,t),this.bindEvents(),t||(document.body.style.overflow="hidden"))}hide(){this.host&&(this.host&&this.host.parentNode&&this.host.parentNode.removeChild(this.host),this.host=null,this.overlay=null,this.content=null,this.shadow=null,document.body.style.overflow="")}createDom(e,t){let i={...this.referrerExperience,...e??{}},n=this.getTheme(),o={...n,colorPrimary:i.modal?.theme?.primaryColor||n.colorPrimary,colorBackground:i.modal?.theme?.backgroundColor||n.colorBackground,colorTint:i.modal?.theme?.tintColor||n.colorTint},s=!!t;this.host=document.createElement("div"),this.host.style.all="initial",s?(this.host.style.display="block",this.host.style.width="100%",this.host.style.height="100%"):(this.host.style.position="absolute",this.host.style.zIndex="2147483647"),this.host.id="growth-rail-modal-host",this.host.style.setProperty("--gr-primary",o.colorPrimary),this.host.style.setProperty("--gr-text",o.colorText),this.host.style.setProperty("--gr-text-secondary",o.colorTextSecondary),this.host.style.setProperty("--gr-bg",o.colorBackground),this.host.style.setProperty("--gr-tint",o.colorTint),this.host.style.setProperty("--gr-surface",o.colorSurface),this.host.style.setProperty("--gr-border",o.colorBorder),this.host.style.setProperty("--gr-error",o.colorError),this.host.style.setProperty("--gr-radius",o.borderRadius),this.host.style.setProperty("--gr-font",'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),this.shadow=this.host.attachShadow({mode:"open"});let c=document.createElement("style");c.textContent=":host{all:initial;display:block}*{box-sizing:border-box}@keyframes gr-fade-in{from{opacity:0}to{opacity:1}}@keyframes gr-slide-up{from{opacity:0;transform:translateY(20px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes gr-slide-in-right{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}@keyframes gr-slide-in-left{from{opacity:0;transform:translateX(-100%)}to{opacity:1;transform:translateX(0)}}.gr-overlay{position:fixed;top:0;left:0;width:100vw;height:100vh;display:flex;z-index:2147483647;font-family:var(--gr-font);animation:gr-fade-in .2s ease-out forwards;backdrop-filter:blur(4px)}.gr-overlay--modal{background-color:var(--gr-tint);align-items:center;justify-content:center}.gr-overlay--drawer{background-color:var(--gr-tint);align-items:flex-start;justify-content:flex-start}.gr-container{position:relative;background-color:var(--gr-bg);color:var(--gr-text);padding:32px;box-shadow:0 20px 25px -5px rgba(0,0,0,.1),0 10px 10px -5px rgba(0,0,0,.04)}.gr-container--embedded{width:100%;height:100%;box-shadow:none;border:1px solid var(--gr-border);border-radius:var(--gr-radius)}.gr-container--modal{width:90%;max-width:480px;border-radius:var(--gr-radius);animation:gr-slide-up .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--drawer{position:absolute;width:400px;max-width:calc(100vw - 20px);max-height:calc(100vh - 40px);overflow-y:auto}.gr-container--right{right:0;border-top-left-radius:var(--gr-radius);border-bottom-left-radius:var(--gr-radius);animation:gr-slide-in-right .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--left{left:0;border-top-right-radius:var(--gr-radius);border-bottom-right-radius:var(--gr-radius);animation:gr-slide-in-left .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--top{top:100px}.gr-container--bottom{bottom:100px}.gr-close-btn{position:absolute;top:20px;right:20px;background:0 0;border:none;cursor:pointer;color:#9ca3af;padding:4px;border-radius:50%;display:flex;align-items:center;justify-content:center;transition:all .2s}.gr-close-btn:hover{background-color:var(--gr-surface);color:var(--gr-text)}.gr-header{text-align:center;margin-bottom:28px}.gr-icon-lg{font-size:32px;margin-bottom:12px}.gr-title{margin:0 0 8px 0;font-size:22px;font-weight:700;letter-spacing:-.02em}.gr-subtitle{margin:0;font-size:14px;line-height:1.5;color:var(--gr-text-secondary)}.gr-loading{padding:16px;background-color:var(--gr-surface);border-radius:8px;text-align:center;color:var(--gr-text-secondary);font-size:14px}.gr-label{display:block;font-size:12px;font-weight:600;color:var(--gr-text-secondary);margin-bottom:8px;text-transform:uppercase;letter-spacing:.05em}.gr-share-label{text-align:center;margin-bottom:16px;font-size:13px;font-weight:500;color:var(--gr-text-secondary);display:flex;align-items:center;gap:12px}.gr-divider{flex:1;height:1px;background:var(--gr-border)}.gr-social-container{display:flex;gap:16px;justify-content:center;flex-wrap:wrap}.gr-btn{padding:14px;font-size:15px;font-weight:600;background-color:var(--gr-primary);color:#fff;border:none;border-radius:var(--gr-radius);cursor:pointer;transition:all .2s ease;text-align:center;width:100%;display:block}.gr-btn:hover{transform:translateY(-1px);filter:brightness(1.05)}.gr-btn:active{transform:translateY(0);filter:brightness(.95)}.gr-btn:disabled{opacity:.7;cursor:not-allowed}.gr-btn--sm{padding:8px 16px;font-size:13px;width:auto;border-radius:calc(var(--gr-radius) - 4px)}.gr-input-group{display:flex;align-items:center;background-color:var(--gr-surface);border:1px solid var(--gr-border);border-radius:var(--gr-radius);padding:4px;margin-bottom:24px}.gr-input-group:focus-within{border-color:var(--gr-primary);box-shadow:0 0 0 3px var(--gr-surface)}.gr-input{flex:1;padding:10px 12px;font-size:14px;border:none;background:0 0;color:var(--gr-text);outline:none;font-family:monospace}.gr-social-btn{display:flex;align-items:center;justify-content:center;width:42px;height:42px;border-radius:50%;background-color:var(--gr-surface);color:var(--gr-text-secondary);border:1px solid var(--gr-border);transition:transform .2s cubic-bezier(.34,1.56,.64,1);cursor:pointer}.gr-social-btn:hover{transform:scale(1.15) rotate(3deg);color:#fff}.gr-powered-by{margin-top:24px;text-align:center;font-size:11px;color:#9ca3af;display:flex;align-items:center;justify-content:center;gap:4px;opacity:.8}.gr-powered-by a{color:inherit;text-decoration:none;font-weight:600;transition:opacity .2s}.gr-powered-by a:hover{opacity:1;text-decoration:underline}",this.shadow.appendChild(c),this.content=document.createElement("div");let d=i.modal.type==="drawer",l=i.trigger.position||"top-right",p=["gr-container"];s?(p.push("gr-container--embedded"),this.content.className=p.join(" "),this.renderInternalContent(o,e,s),this.shadow.appendChild(this.content),t&&t.appendChild(this.host)):(this.overlay=document.createElement("div"),this.overlay.className=`gr-overlay ${d?"gr-overlay--drawer":"gr-overlay--modal"}`,d?(p.push("gr-container--drawer"),l.includes("right")?p.push("gr-container--right"):p.push("gr-container--left"),l.includes("bottom")?p.push("gr-container--bottom"):p.push("gr-container--top")):p.push("gr-container--modal"),this.content.className=p.join(" "),this.renderInternalContent(o,e,s),this.overlay.appendChild(this.content),this.shadow.appendChild(this.overlay),document.body.appendChild(this.host),this.overlay.onclick=h=>{h.target===this.overlay&&this.hide()})}getTheme(){return{colorPrimary:"#2563eb",colorText:"#111827",colorTextSecondary:"#6b7280",colorBackground:"#ffffff",colorTint:"#f9fafb",colorSurface:"#f9fafb",colorBorder:"#e5e7eb",colorError:"#ef4444",borderRadius:"16px"}}async renderInternalContent(e,t,i=!1){if(!this.content)return;if(this.content.innerHTML="",!i){let h=document.createElement("button");h.className="gr-close-btn",h.innerHTML=`
1
+ var E=Object.defineProperty;var C=(g,e,t)=>e in g?E(g,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):g[e]=t;var a=(g,e,t)=>C(g,typeof e!="symbol"?e+"":e,t);var m=class{constructor(e){a(this,"baseUrl");a(this,"apiKey");let t=typeof process<"u"&&process.env?.ENV_BASE_URL;this.baseUrl=t||"https://api.growthrail.dev",this.apiKey=e.apiKey}async request(e,t,n){let i={"Content-Type":"application/json","X-GrowthRail-ProjectSecret":this.apiKey};try{let o=await fetch(`${this.baseUrl}${e}`,{method:t,headers:i,body:n?JSON.stringify(n):void 0});if(!o.ok)throw new Error(`GrowthRail API Error: ${o.statusText}`);return o.json()}catch(o){throw console.error("GrowthRail SDK Error:",o),o}}async getNewUserExperience(){return this.request("/api/v1/sdk/new-user-experience","POST")}async initAppUser(e){return this.request("/api/v1/sdk/init-app-user","POST",{clientProvidedId:e})}async createReferralLink(e,t){return this.request("/api/v1/sdk/create-referral-link","POST",{referrerId:e,rewardEventName:t})}async trackReferral(e,t){return this.request("/api/v1/sdk/track-referral","POST",{referralCode:e,rewardEventName:t})}async trackRewardEvent(e,t,n){return this.request("/api/v1/sdk/track-reward-event","POST",{refereeId:e,referralTrackingId:t,eventName:n})}};var u=class u{constructor(e){a(this,"options",{});e&&(this.options=e)}setCookie(e,t,n=30){if(typeof document>"u")return;let i="";if(n){let s=new Date;s.setTime(s.getTime()+n*24*60*60*1e3),i=`; expires=${s.toUTCString()}`}let o="";this.options.cookieDomain&&(o=`; domain=${this.options.cookieDomain}`),document.cookie=`${e}=${t||""}${i}${o}; path=/; SameSite=Lax`}getCookie(e){if(typeof document>"u")return null;let t=`${e}=`,n=document.cookie.split(";");for(let i=0;i<n.length;i++){let o=n[i];for(;o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(t)===0)return o.substring(t.length,o.length)}return null}getReferralCode(){return this.getCookie(u.REFERRAL_CODE_KEY)}setReferralCode(e){this.setCookie(u.REFERRAL_CODE_KEY,e,30)}setTrackedReferral(e){this.setCookie(u.TRACKED_REFERRAL_KEY,e,30)}getTrackedReferral(){return this.getCookie(u.TRACKED_REFERRAL_KEY)}};a(u,"REFERRAL_CODE_KEY","gr_ref_code"),a(u,"TRACKED_REFERRAL_KEY","gr_tracked_referral");var x=u;var b=class{constructor(e,t){a(this,"referrerExperience");a(this,"deps");a(this,"host",null);a(this,"shadow",null);a(this,"overlay",null);a(this,"content",null);this.deps=e,this.referrerExperience=t}show(e,t){this.host||(this.createDom(e,t),this.bindEvents(),t||(document.body.style.overflow="hidden"))}hide(){this.host&&(this.host&&this.host.parentNode&&this.host.parentNode.removeChild(this.host),this.host=null,this.overlay=null,this.content=null,this.shadow=null,document.body.style.overflow="")}createDom(e,t){let n={...this.referrerExperience,modal:{...this.referrerExperience.modal,...e??{},theme:{...this.referrerExperience.modal?.theme,...e?.theme??{}}}},i=this.getTheme(),o={...i,colorPrimary:n.modal?.theme?.primaryColor||i.colorPrimary,colorBackground:n.modal?.theme?.backgroundColor||i.colorBackground,colorTint:n.modal?.theme?.tintColor||i.colorTint,tintAlpha:n.modal?.theme?.tintAlpha??i.tintAlpha},s=!!t;this.host=document.createElement("div"),this.host.style.all="initial",s?(this.host.style.display="block",this.host.style.width="100%",this.host.style.height="100%"):(this.host.style.position="absolute",this.host.style.zIndex="2147483647"),this.host.id="growth-rail-modal-host",this.host.style.setProperty("--gr-primary",o.colorPrimary),this.host.style.setProperty("--gr-text",o.colorText),this.host.style.setProperty("--gr-text-secondary",o.colorTextSecondary),this.host.style.setProperty("--gr-bg",o.colorBackground),this.host.style.setProperty("--gr-tint",o.colorTint);let l=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(o.colorTint),d=o.tintAlpha>1?o.tintAlpha/100:o.tintAlpha,c=l?`rgba(${parseInt(l[1],16)}, ${parseInt(l[2],16)}, ${parseInt(l[3],16)}, ${d})`:`rgba(0, 0, 0, ${d})`;this.host.style.setProperty("--gr-tint-rgba",c),this.host.style.setProperty("--gr-surface",o.colorSurface),this.host.style.setProperty("--gr-border",o.colorBorder),this.host.style.setProperty("--gr-error",o.colorError),this.host.style.setProperty("--gr-radius",o.borderRadius),this.host.style.setProperty("--gr-font",'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),this.shadow=this.host.attachShadow({mode:"open"});let p=document.createElement("style");p.textContent=":host{all:initial;display:block}*{box-sizing:border-box}@keyframes gr-fade-in{from{opacity:0}to{opacity:1}}@keyframes gr-slide-up{from{opacity:0;transform:translateY(20px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes gr-slide-in-right{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}@keyframes gr-slide-in-left{from{opacity:0;transform:translateX(-100%)}to{opacity:1;transform:translateX(0)}}.gr-overlay{position:fixed;top:0;left:0;width:100vw;height:100vh;display:flex;z-index:2147483647;font-family:var(--gr-font);animation:gr-fade-in .2s ease-out forwards;backdrop-filter:blur(4px);background-color:var(--gr-tint-rgba)}.gr-overlay--modal{align-items:center;justify-content:center}.gr-overlay--drawer{align-items:flex-start;justify-content:flex-start}.gr-container{position:relative;background-color:var(--gr-bg);color:var(--gr-text);padding:32px;box-shadow:0 0 50px -12px rgba(0,0,0,0.25), 0 0 30px -10px rgba(0,0,0,0.15)}.gr-container--embedded{width:100%;height:100%;box-shadow:none;border:1px solid var(--gr-border);border-radius:var(--gr-radius)}.gr-container--modal{width:90%;max-width:480px;border-radius:var(--gr-radius);animation:gr-slide-up .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--drawer{position:absolute;width:400px;max-width:calc(100vw - 20px);max-height:calc(100vh - 40px);overflow-y:auto}.gr-container--right{right:0;border-top-left-radius:var(--gr-radius);border-bottom-left-radius:var(--gr-radius);animation:gr-slide-in-right .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--left{left:0;border-top-right-radius:var(--gr-radius);border-bottom-right-radius:var(--gr-radius);animation:gr-slide-in-left .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--top{top:100px}.gr-container--bottom{bottom:100px}.gr-close-btn{position:absolute;top:20px;right:20px;background:0 0;border:none;cursor:pointer;color:#9ca3af;padding:4px;border-radius:50%;display:flex;align-items:center;justify-content:center;transition:all .2s}.gr-close-btn:hover{background-color:var(--gr-surface);color:var(--gr-text)}.gr-header{text-align:center;margin-bottom:28px}.gr-icon-lg{font-size:32px;margin-bottom:12px}.gr-title{margin:0 0 8px 0;font-size:22px;font-weight:700;letter-spacing:-.02em}.gr-subtitle{margin:0;font-size:14px;line-height:1.5;color:var(--gr-text-secondary)}.gr-loading{padding:16px;background-color:var(--gr-surface);border-radius:8px;text-align:center;color:var(--gr-text-secondary);font-size:14px}.gr-label{display:block;font-size:12px;font-weight:600;color:var(--gr-text-secondary);margin-bottom:8px;text-transform:uppercase;letter-spacing:.05em}.gr-share-label{text-align:center;margin-bottom:16px;font-size:13px;font-weight:500;color:var(--gr-text-secondary);display:flex;align-items:center;gap:12px}.gr-divider{flex:1;height:1px;background:var(--gr-border)}.gr-social-container{display:flex;gap:16px;justify-content:center;flex-wrap:wrap}.gr-btn{padding:14px;font-size:15px;font-weight:600;background-color:var(--gr-primary);color:#fff;border:none;border-radius:var(--gr-radius);cursor:pointer;transition:all .2s ease;text-align:center;width:100%;display:block}.gr-btn:hover{transform:translateY(-1px);filter:brightness(1.05)}.gr-btn:active{transform:translateY(0);filter:brightness(.95)}.gr-btn:disabled{opacity:.7;cursor:not-allowed}.gr-btn--sm{padding:8px 16px;font-size:13px;width:auto;border-radius:calc(var(--gr-radius) - 4px)}.gr-input-group{display:flex;align-items:center;background-color:var(--gr-surface);border:1px solid var(--gr-border);border-radius:var(--gr-radius);padding:4px;margin-bottom:24px}.gr-input-group:focus-within{border-color:var(--gr-primary);box-shadow:0 0 0 3px var(--gr-surface)}.gr-input{flex:1;padding:10px 12px;font-size:14px;border:none;background:0 0;color:var(--gr-text);outline:none;font-family:monospace}.gr-social-btn{display:flex;align-items:center;justify-content:center;width:42px;height:42px;border-radius:50%;background-color:var(--gr-surface);color:var(--gr-text-secondary);border:1px solid var(--gr-border);transition:transform .2s cubic-bezier(.34,1.56,.64,1);cursor:pointer}.gr-social-btn:hover{transform:scale(1.15) rotate(3deg);color:#fff}.gr-powered-by{margin-top:24px;text-align:center;font-size:11px;color:#9ca3af;display:flex;align-items:center;justify-content:center;gap:4px;opacity:.8}.gr-powered-by a{color:inherit;text-decoration:none;font-weight:600;transition:opacity .2s}.gr-powered-by a:hover{opacity:1;text-decoration:underline}",this.shadow.appendChild(p),this.content=document.createElement("div");let h=n.modal.componentType==="drawer",k=n.trigger.position||"top-right",f=["gr-container"];s?(f.push("gr-container--embedded"),this.content.className=f.join(" "),this.renderInternalContent(o,e,s),this.shadow.appendChild(this.content),t&&t.appendChild(this.host)):(this.overlay=document.createElement("div"),this.overlay.className=`gr-overlay ${h?"gr-overlay--drawer":"gr-overlay--modal"}`,h?(f.push("gr-container--drawer"),k.includes("right")?f.push("gr-container--right"):f.push("gr-container--left"),k.includes("bottom")?f.push("gr-container--bottom"):f.push("gr-container--top")):f.push("gr-container--modal"),this.content.className=f.join(" "),this.renderInternalContent(o,e,s),this.overlay.appendChild(this.content),this.shadow.appendChild(this.overlay),document.body.appendChild(this.host),this.overlay.onclick=R=>{R.target===this.overlay&&this.hide()})}getTheme(){return{colorPrimary:"#2563eb",colorText:"#111827",colorTextSecondary:"#6b7280",colorBackground:"#ffffff",colorTint:"#f9fafb",tintAlpha:.8,colorSurface:"#f9fafb",colorBorder:"#e5e7eb",colorError:"#ef4444",borderRadius:"16px"}}async renderInternalContent(e,t,n=!1){if(!this.content)return;if(this.content.innerHTML="",!n){let h=document.createElement("button");h.className="gr-close-btn",h.innerHTML=`
2
2
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
3
3
  <line x1="18" y1="6" x2="6" y2="18"></line>
4
4
  <line x1="6" y1="6" x2="18" y2="18"></line>
5
5
  </svg>
6
- `,h.onclick=()=>this.hide(),this.content.appendChild(h)}let n=document.createElement("div");n.className="gr-header";let o=document.createElement("div");o.className="gr-icon-lg",o.innerHTML="\u{1F381}",n.appendChild(o);let s=document.createElement("h3");s.className="gr-title",s.textContent=t?.title??this.referrerExperience.modal.title??"Invite Friends & Earn",n.appendChild(s);let c=document.createElement("p");if(c.className="gr-subtitle",c.textContent="Share your unique link and earn rewards for every friend who signs up.",n.appendChild(c),this.content.appendChild(n),!this.deps.isUserReady()){let h=document.createElement("div");h.className="gr-loading",h.textContent="Please log in to view your referral dashboard.",this.content.appendChild(h);return}let d=this.deps.getReferralLink(),l=document.createElement("div");this.renderLinkView(l,d,e),this.content.appendChild(l),d&&this.renderSocialShare(this.content,d,e);let p=document.createElement("div");p.className="gr-powered-by",p.innerHTML=`
6
+ `,h.onclick=()=>this.hide(),this.content.appendChild(h)}let i=document.createElement("div");i.className="gr-header";let o=document.createElement("div");o.className="gr-icon-lg",o.innerHTML="\u{1F381}",i.appendChild(o);let s=document.createElement("h3");s.className="gr-title",s.textContent=t?.title??this.referrerExperience.modal.title??"Invite Friends & Earn",i.appendChild(s);let l=document.createElement("p");if(l.className="gr-subtitle",l.textContent="Share your unique link and earn rewards for every friend who signs up.",i.appendChild(l),this.content.appendChild(i),!this.deps.isUserReady()){let h=document.createElement("div");h.className="gr-loading",h.textContent="Please log in to view your referral dashboard.",this.content.appendChild(h);return}let d=this.deps.getReferralLink(),c=document.createElement("div");this.renderLinkView(c,d,e),this.content.appendChild(c),d&&this.renderSocialShare(this.content,d,e);let p=document.createElement("div");p.className="gr-powered-by",p.innerHTML=`
7
7
  Powered by <a href="https://growthrail.com" target="_blank" rel="noopener noreferrer">Growth Rail</a>
8
- `,this.content.appendChild(p)}renderLinkView(e,t,i){let n=document.createElement("label");n.className="gr-label",n.textContent="Your unique link",e.appendChild(n);let o=document.createElement("div");o.className="gr-input-group";let s=document.createElement("input");s.className="gr-input",s.type="text",s.value=t,s.readOnly=!0;let c=document.createElement("button");c.className="gr-btn gr-btn--sm",c.textContent="Copy",c.onclick=async()=>{try{await navigator.clipboard.writeText(t);let d=c.textContent;c.textContent="Copied!",c.style.backgroundColor="#10b981",setTimeout(()=>{c.textContent=d,c.style.backgroundColor=""},2e3)}catch(d){console.error("Failed to copy",d)}},o.appendChild(s),o.appendChild(c),e.appendChild(o)}renderSocialShare(e,t,i){let n=document.createElement("div"),o=document.createElement("div");o.className="gr-share-label",o.innerHTML='<span class="gr-divider"></span>Share via<span class="gr-divider"></span>',n.appendChild(o);let s=document.createElement("div");s.className="gr-social-container",[{name:"Twitter",color:"#000000",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>',url:`https://twitter.com/intent/tweet?url=${encodeURIComponent(t)}&text=Check+this+out!`},{name:"Facebook",color:"#1877F2",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036c-2.648 0-2.928 1.67-2.928 3.403v1.596h3.949l-.577 3.667h-3.372v7.98h-4.938z"/></svg>',url:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(t)}`},{name:"LinkedIn",color:"#0A66C2",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>',url:`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(t)}`},{name:"WhatsApp",color:"#25D366",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/></svg>',url:`https://api.whatsapp.com/send?text=${encodeURIComponent(t)}`},{name:"Email",color:"#888888",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"/></svg>',url:`mailto:?subject=Check this out&body=${encodeURIComponent(t)}`}].forEach(d=>{let l=document.createElement("a");l.href=d.url,l.target="_blank",l.rel="noopener noreferrer",l.className="gr-social-btn",l.innerHTML=d.icon,l.title=`Share on ${d.name}`,l.onmouseenter=()=>{l.style.backgroundColor=d.color,l.style.color="#ffffff",l.style.borderColor=d.color},l.onmouseleave=()=>{l.style.backgroundColor="",l.style.color="",l.style.borderColor=""},s.appendChild(l)}),n.appendChild(s),e.appendChild(n)}bindEvents(){this.overlay&&(this.overlay.onclick=e=>{e.target===this.overlay&&this.hide()})}};var b=class{constructor(e){a(this,"options");a(this,"host",null);a(this,"shadow",null);a(this,"element",null);this.options=e}mount(){this.host||this.createDom()}unmount(){this.host&&this.host.parentNode&&document.body.removeChild(this.host),this.host=null,this.shadow=null,this.element=null}createDom(){this.host=document.createElement("div"),this.host.style.all="initial",this.host.style.position="absolute",this.host.style.zIndex="2147483646";let e={x:0,y:100};this.host.style.setProperty("--gr-offset-y",`${e.y}px`),this.shadow=this.host.attachShadow({mode:"open"});let t=document.createElement("style");t.textContent=":host{all:initial;display:block}@keyframes gr-shimmer{0%{transform:translateX(-150%) skewX(-15deg)}50%{transform:translateX(150%) skewX(-15deg)}100% {transform:translateX(150%) skewX(-15deg)}}.gr-floating-btn{position:fixed;width:50px;height:50px;background:linear-gradient(135deg,#6366f1 0%,#a855f7 100%);box-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,0.06);cursor:pointer;z-index:2147483646;display:flex;align-items:center;justify-content:center;transition:transform .2s cubic-bezier(.34,1.56,.64,1),box-shadow .2s ease,width .2s;overflow:hidden;font-family:system-ui,-apple-system,sans-serif;box-sizing:border-box}.gr-floating-btn *{box-sizing:border-box}.gr-floating-btn:hover{transform:scale(1.05);box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05)}.gr-floating-btn--right{right:0;border-top-left-radius:8px;border-bottom-left-radius:8px;border-top-right-radius:0;border-bottom-right-radius:0;padding-left:4px}.gr-floating-btn--left{left:0;border-top-right-radius:8px;border-bottom-right-radius:8px;border-top-left-radius:0;border-bottom-left-radius:0;padding-right:4px}.gr-floating-btn--bottom{bottom:var(--gr-offset-y)}.gr-floating-btn--top{top:var(--gr-offset-y)}.gr-floating-btn::after{content:'';position:absolute;top:0;left:0;width:100%;height:100%;background:linear-gradient(to right,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);transform:translateX(-150%) skewX(-15deg);animation:gr-shimmer 3s infinite}.gr-icon{color:#fff;width:24px;height:24px;position:relative;z-index:10}",this.shadow.appendChild(t),this.element=document.createElement("div");let i=this.options.position||"bottom-right",n=["gr-floating-btn"];i.includes("right")?n.push("gr-floating-btn--right"):n.push("gr-floating-btn--left"),i.includes("bottom")?n.push("gr-floating-btn--bottom"):n.push("gr-floating-btn--top"),this.element.className=n.join(" "),this.element.innerHTML=`
8
+ `,this.content.appendChild(p)}renderLinkView(e,t,n){let i=document.createElement("label");i.className="gr-label",i.textContent="Your unique link",e.appendChild(i);let o=document.createElement("div");o.className="gr-input-group";let s=document.createElement("input");s.className="gr-input",s.type="text",s.value=t,s.readOnly=!0;let l=document.createElement("button");l.className="gr-btn gr-btn--sm",l.textContent="Copy",l.onclick=async()=>{try{await navigator.clipboard.writeText(t);let d=l.textContent;l.textContent="Copied!",l.style.backgroundColor="#10b981",setTimeout(()=>{l.textContent=d,l.style.backgroundColor=""},2e3)}catch(d){console.error("Failed to copy",d)}},o.appendChild(s),o.appendChild(l),e.appendChild(o)}renderSocialShare(e,t,n){let i=document.createElement("div"),o=document.createElement("div");o.className="gr-share-label",o.innerHTML='<span class="gr-divider"></span>Share via<span class="gr-divider"></span>',i.appendChild(o);let s=document.createElement("div");s.className="gr-social-container",[{name:"Twitter",color:"#000000",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>',url:`https://twitter.com/intent/tweet?url=${encodeURIComponent(t)}&text=Check+this+out!`},{name:"Facebook",color:"#1877F2",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036c-2.648 0-2.928 1.67-2.928 3.403v1.596h3.949l-.577 3.667h-3.372v7.98h-4.938z"/></svg>',url:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(t)}`},{name:"LinkedIn",color:"#0A66C2",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>',url:`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(t)}`},{name:"WhatsApp",color:"#25D366",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/></svg>',url:`https://api.whatsapp.com/send?text=${encodeURIComponent(t)}`},{name:"Email",color:"#888888",icon:'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"/></svg>',url:`mailto:?subject=Check this out&body=${encodeURIComponent(t)}`}].forEach(d=>{let c=document.createElement("a");c.href=d.url,c.target="_blank",c.rel="noopener noreferrer",c.className="gr-social-btn",c.innerHTML=d.icon,c.title=`Share on ${d.name}`,c.onmouseenter=()=>{c.style.backgroundColor=d.color,c.style.color="#ffffff",c.style.borderColor=d.color},c.onmouseleave=()=>{c.style.backgroundColor="",c.style.color="",c.style.borderColor=""},s.appendChild(c)}),i.appendChild(s),e.appendChild(i)}bindEvents(){this.overlay&&(this.overlay.onclick=e=>{e.target===this.overlay&&this.hide()})}};var y=class{constructor(e){a(this,"options");a(this,"host",null);a(this,"shadow",null);a(this,"element",null);this.options=e}mount(){this.host||this.createDom()}unmount(){this.host&&this.host.parentNode&&document.body.removeChild(this.host),this.host=null,this.shadow=null,this.element=null}createDom(){this.host=document.createElement("div"),this.host.style.all="initial",this.host.style.position="absolute",this.host.style.zIndex="2147483646";let e={x:0,y:100};this.host.style.setProperty("--gr-offset-y",`${e.y}px`),this.shadow=this.host.attachShadow({mode:"open"});let t=document.createElement("style"),n=this.options.trigger?.displayMode||"edge";t.textContent=`
9
+ :host { all: initial; display: block; }
10
+ @keyframes gr-shimmer {
11
+ 0% { transform: translateX(-150%) skewX(-15deg); }
12
+ 50% { transform: translateX(150%) skewX(-15deg); }
13
+ 100% { transform: translateX(150%) skewX(-15deg); }
14
+ }
15
+ .gr-btn {
16
+ position: fixed;
17
+ width: 50px;
18
+ height: 50px;
19
+ background: ${this.options.modal?.theme?.primaryColor||"#000"};
20
+ box-shadow: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,0.06);
21
+ cursor: pointer;
22
+ z-index: 2147483646;
23
+ display: flex;
24
+ align-items: center;
25
+ justify-content: center;
26
+ transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, width .2s, border-radius .2s;
27
+ overflow: hidden;
28
+ font-family: system-ui, -apple-system, sans-serif;
29
+ box-sizing: border-box;
30
+ }
31
+ .gr-btn * { box-sizing: border-box; }
32
+ .gr-btn:hover {
33
+ transform: scale(1.05);
34
+ box-shadow: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,0.05);
35
+ }
36
+
37
+ /* Edge Mode Radii */
38
+ .gr-btn--edge.gr-btn--right { border-radius: 8px 0 0 8px; padding-left: 4px; right: 0; }
39
+ .gr-btn--edge.gr-btn--left { border-radius: 0 8px 8px 0; padding-right: 4px; left: 0; }
40
+
41
+ /* Floating Mode Radii & Position */
42
+ .gr-btn--floating {
43
+ border-radius: 50%;
44
+ box-shadow: 0 8px 24px color-mix(in srgb, ${this.options.modal?.theme?.primaryColor||"#000"}, transparent 60%);
45
+ }
46
+ .gr-btn--floating:hover {
47
+ box-shadow: 0 12px 32px color-mix(in srgb, ${this.options.modal?.theme?.primaryColor||"#000"}, transparent 40%);
48
+ }
49
+ .gr-btn--floating.gr-btn--right { right: 20px; }
50
+ .gr-btn--floating.gr-btn--left { left: 20px; }
51
+
52
+ .gr-btn--bottom { bottom: var(--gr-offset-y); }
53
+ .gr-btn--top { top: var(--gr-offset-y); }
54
+
55
+ .gr-btn::after {
56
+ content: '';
57
+ position: absolute;
58
+ top: 0;
59
+ left: 0;
60
+ width: 100%;
61
+ height: 100%;
62
+ background: linear-gradient(to right, transparent 0%, rgba(255,255,255,0.4) 50%, transparent 100%);
63
+ transform: translateX(-150%) skewX(-15deg);
64
+ animation: gr-shimmer 3s infinite;
65
+ }
66
+ .gr-icon { color: #fff; width: 24px; height: 24px; position: relative; z-index: 10; }
67
+ `,this.shadow.appendChild(t),this.element=document.createElement("div");let i=this.options.trigger?.position||"bottom-right",o=["gr-btn",`gr-btn--${n}`];i.includes("right")?o.push("gr-btn--right"):o.push("gr-btn--left"),i.includes("bottom")?o.push("gr-btn--bottom"):o.push("gr-btn--top"),this.element.className=o.join(" "),this.element.innerHTML=`
9
68
  <svg class="gr-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
10
69
  <polyline points="20 12 20 22 4 22 4 12"></polyline>
11
70
  <rect x="2" y="7" width="20" height="5"></rect>
@@ -13,5 +72,74 @@ var v=Object.defineProperty;var w=(g,e,t)=>e in g?v(g,e,{enumerable:!0,configura
13
72
  <path d="M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7z"></path>
14
73
  <path d="M12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7z"></path>
15
74
  </svg>
16
- `,this.element.onclick=()=>{x.showReferralDashboard()},this.shadow.appendChild(this.element),document.body.appendChild(this.host)}};var r=class r{constructor(){}static init(e){r.initialized||(r.options=e,r.api=new u(e),r.storage=new m({cookieDomain:e.cookieDomain}),r.initialized=!0,r.autoTrackReferral())}static isInitialized(){return r.initialized}static ensureInitialized(){if(!r.initialized)throw new Error("GrowthRail.init() must be called before using the SDK")}static async loadReferrerExperience(e){try{r.createReferralModal(e),e.trigger.show&&r.createTriggerButton(e.trigger)}catch(t){throw console.error("GrowthRail: Failed to load referrer experience",t),t}}static createReferralModal(e){r.referralModal=new y({isUserReady:()=>r.isUserReady(),getReferralLink:()=>r.currentUser?.referralLink||""},e)}static async autoTrackReferral(){if(typeof window>"u")return;let e=new URLSearchParams(window.location.search),t=e.get("referralCode"),i=e.get("rewardEventName");if(t){let n=await r.api.getNewUserExperience(),o=await r.trackReferral(t,i??void 0);r.storage.setTrackedReferral(o.referralTrackingId),o.promotionalText&&n.banner.show&&r.createPromotionalBanner(o.promotionalText,n)}}static async initAppUser(e){r.ensureInitialized();let t=await r.api.initAppUser(e);return r.currentUser={...t,id:e},r.experience=t.referrerExperience,r.loadReferrerExperience(t.referrerExperience),r.userReadyResolver?r.userReadyResolver(r.currentUser):r.userReadyPromise=Promise.resolve(r.currentUser),t}static async trackReferral(e,t){return r.ensureInitialized(),r.api.trackReferral(e,t)}static async trackRewardEvent(e){r.ensureInitialized();let t=r.currentUser?.id;if(!t)throw new Error("GrowthRail: User must be initialized before tracking a reward event.");let i=r.storage.getTrackedReferral();if(!i)throw new Error("GrowthRail: Referral Tracking Id must be initialized before tracking a reward event.");return r.api.trackRewardEvent(t,i,e)}static getReferralLink(){if(!r.currentUser?.referralLink)throw new Error("GrowthRail: Referral Link not loaded or user not initialized");return r.currentUser.referralLink}static getReferralCode(){return r.currentUser?.referralCode}static getUserId(){return r.currentUser?.id}static isUserReady(){return r.currentUser!==null}static ensureUserReady(){return r.currentUser?Promise.resolve(r.currentUser):(r.userReadyPromise||(r.userReadyPromise=new Promise(e=>{r.userReadyResolver=e})),r.userReadyPromise)}static async showReferralDashboard(e){if(r.ensureInitialized(),!r.experience)throw new Error("GrowthRail: Experience not loaded");r.referralModal&&r.referralModal.hide(),r.referralModal?.show(e)}static createPromotionalBanner(e,t){if(typeof document>"u")return;let i=document.createElement("div");i.style.position="fixed",i.style.top=t.banner.position.split("-")[1]==="top"?"0":"auto",i.style.bottom=t.banner.position.split("-")[1]==="bottom"?"0":"auto",i.style.left=t.banner.position.split("-")[0]==="left"?"0":"auto",i.style.right=t.banner.position.split("-")[0]==="right"?"0":"auto",i.style.width="100%",i.style.margin="auto",i.style.backgroundColor="#f0f0f0",i.style.padding="10px",i.style.textAlign="center",i.style.zIndex="10000",i.textContent=e,document.body.appendChild(i)}static createTriggerButton(e){if(typeof window>"u")return;if(!r.experience)throw new Error("GrowthRail: Experience not loaded");r.floatingButton&&r.floatingButton.unmount();let t={...r.experience?.trigger,...e};r.floatingButton=new b(t),r.floatingButton.mount()}static destroyTriggerButton(){r.floatingButton&&(r.floatingButton.unmount(),r.floatingButton=null)}};a(r,"api"),a(r,"storage"),a(r,"options"),a(r,"currentUser",null),a(r,"initialized",!1),a(r,"referralModal",null),a(r,"floatingButton",null),a(r,"experience",null),a(r,"userReadyPromise",null),a(r,"userReadyResolver",null);var x=r;export{x as GrowthRail,y as ReferralModal};
17
- //# sourceMappingURL=index.mjs.map
75
+ `,this.element.onclick=()=>{v.showReferralDashboard()},this.shadow.appendChild(this.element),document.body.appendChild(this.host)}};var w=class{static show(e){if(typeof document>"u")return;let t=document.createElement("div");t.id="gr-banner-host",document.body.appendChild(t);let n=t.attachShadow({mode:"open"}),i=(e.banner.position||"center-top").toLowerCase(),o=i.includes("bottom")?"bottom":"top",s=i.includes("left")?"left":i.includes("right")?"right":"center",l="",d="";s==="center"?(l="left: 50%;",d="translateX(-50%)"):(l=`${s}: 20px;`,d="translateX(0)");let c=document.createElement("style");c.textContent=`
76
+ .gr-banner {
77
+ position: fixed;
78
+ ${o}: 20px;
79
+ ${l}
80
+ z-index: 2147483647;
81
+ font-family: Inter, system-ui, -apple-system, sans-serif;
82
+ background: #ffffff;
83
+ color: #111827;
84
+ padding: 12px 20px;
85
+ border-radius: 12px;
86
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
87
+ display: flex;
88
+ align-items: center;
89
+ gap: 12px;
90
+ width: max-content;
91
+ max-width: 500px;
92
+ border: 1px solid #e5e7eb;
93
+ animation: gr-slide-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
94
+ box-sizing: border-box;
95
+ }
96
+
97
+ @keyframes gr-slide-in {
98
+ from {
99
+ opacity: 0;
100
+ transform: ${d} translateY(${o==="top"?"-20px":"20px"});
101
+ }
102
+ to {
103
+ opacity: 1;
104
+ transform: ${d} translateY(0);
105
+ }
106
+ }
107
+
108
+ .gr-icon {
109
+ width: 22px;
110
+ height: 22px;
111
+ color: #0070f3; /* Premium blue for the gift icon */
112
+ flex-shrink: 0;
113
+ }
114
+ .gr-text { font-size: 14px; font-weight: 500; line-height: 1.4; margin: 0; color: #1f2937; flex: 1; }
115
+ .gr-close {
116
+ background: transparent;
117
+ border: none;
118
+ color: #9ca3af;
119
+ cursor: pointer;
120
+ padding: 4px;
121
+ margin-left: 8px;
122
+ border-radius: 6px;
123
+ display: flex;
124
+ align-items: center;
125
+ justify-content: center;
126
+ transition: all 0.2s;
127
+ flex-shrink: 0;
128
+ }
129
+ .gr-close:hover { background: #f3f4f6; color: #4b5563; }
130
+ `;let p=document.createElement("div");p.className="gr-banner",p.innerHTML=`
131
+ <svg class="gr-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
132
+ <polyline points="20 12 20 22 4 22 4 12"></polyline>
133
+ <rect x="2" y="7" width="20" height="5"></rect>
134
+ <line x1="12" y1="22" x2="12" y2="7"></line>
135
+ <path d="M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7z"></path>
136
+ <path d="M12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7z"></path>
137
+ </svg>
138
+ <p class="gr-text">${e.banner.text}</p>
139
+ <button class="gr-close" aria-label="Close banner">
140
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
141
+ <line x1="18" y1="6" x2="6" y2="18"></line>
142
+ <line x1="6" y1="6" x2="18" y2="18"></line>
143
+ </svg>
144
+ </button>
145
+ `,p.querySelector(".gr-close")?.addEventListener("click",()=>{t.remove()}),n.appendChild(c),n.appendChild(p)}};var r=class r{constructor(){}static init(e){r.initialized||(r.options=e,r.api=new m(e),r.storage=new x({cookieDomain:e.cookieDomain}),r.initialized=!0,r.autoTrackReferral())}static isInitialized(){return r.initialized}static ensureInitialized(){if(!r.initialized)throw new Error("GrowthRail.init() must be called before using the SDK")}static async loadReferrerExperience(e){try{r.createReferralModal(e),e.trigger.show&&r.createTriggerButton(e.trigger)}catch(t){throw console.error("GrowthRail: Failed to load referrer experience",t),t}}static createReferralModal(e){r.referralModal=new b({isUserReady:()=>r.isUserReady(),getReferralLink:()=>r.currentUser?.referralLink||""},e)}static async autoTrackReferral(){if(typeof window>"u")return;let e=new URLSearchParams(window.location.search),t=e.get("referralCode"),n=e.get("rewardEventName");if(t){let i=await r.api.getNewUserExperience(),o=await r.trackReferral(t,n??void 0);r.storage.setTrackedReferral(o.referralTrackingId),i.banner.show&&w.show(i)}}static async initAppUser(e){r.ensureInitialized();let t=await r.api.initAppUser(e);return r.currentUser={...t,id:e},r.experience=t.referrerExperience,r.loadReferrerExperience(t.referrerExperience),r.userReadyResolver?r.userReadyResolver(r.currentUser):r.userReadyPromise=Promise.resolve(r.currentUser),t}static async trackReferral(e,t){return r.ensureInitialized(),r.api.trackReferral(e,t)}static async trackRewardEvent(e){r.ensureInitialized();let t=r.currentUser?.id;if(!t)throw new Error("GrowthRail: User must be initialized before tracking a reward event.");let n=r.storage.getTrackedReferral();if(!n)throw new Error("GrowthRail: Referral Tracking Id must be initialized before tracking a reward event.");return r.api.trackRewardEvent(t,n,e)}static getReferralLink(){if(!r.currentUser?.referralLink)throw new Error("GrowthRail: Referral Link not loaded or user not initialized");return r.currentUser.referralLink}static getReferralCode(){return r.currentUser?.referralCode}static getUserId(){return r.currentUser?.id}static isUserReady(){return r.currentUser!==null}static ensureUserReady(){return r.currentUser?Promise.resolve(r.currentUser):(r.userReadyPromise||(r.userReadyPromise=new Promise(e=>{r.userReadyResolver=e})),r.userReadyPromise)}static async showReferralDashboard(e){if(r.ensureInitialized(),!r.experience)throw new Error("GrowthRail: Experience not loaded");r.referralModal&&r.referralModal.hide(),r.referralModal?.show(e)}static createTriggerButton(e){if(typeof window>"u")return;if(!r.experience)throw new Error("GrowthRail: Experience not loaded");r.floatingButton&&r.floatingButton.unmount();let t={...r.experience?.trigger,...e},n={modal:{...r.experience.modal},trigger:t};r.floatingButton=new y(n),r.floatingButton.mount()}static destroyTriggerButton(){r.floatingButton&&(r.floatingButton.unmount(),r.floatingButton=null)}};a(r,"api"),a(r,"storage"),a(r,"options"),a(r,"currentUser",null),a(r,"initialized",!1),a(r,"referralModal",null),a(r,"floatingButton",null),a(r,"experience",null),a(r,"userReadyPromise",null),a(r,"userReadyResolver",null);var v=r;export{v as GrowthRail,b as ReferralModal};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growth-rail/core",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Growth Rail SDK",
5
5
  "keywords": [
6
6
  "sdk",
@@ -17,7 +17,9 @@
17
17
  }
18
18
  },
19
19
  "files": [
20
- "dist"
20
+ "dist",
21
+ "README.md",
22
+ "CHANGELOG.md"
21
23
  ],
22
24
  "scripts": {
23
25
  "build": "tsup",
@@ -37,4 +39,4 @@
37
39
  "publishConfig": {
38
40
  "access": "public"
39
41
  }
40
- }
42
+ }
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../src/api.ts","../src/storage.ts","../src/referral-modal.ts","../src/trigger-button.ts","../src/core.ts"],"sourcesContent":["export * from './types';\nexport * from './core';\nexport * from './referral-modal';\n// We don't export StorageManager or APIClient directly unless needed for advanced usage\n\n\n","import { GrowthRailOptions, AppUserType, TrackReferralResponse, ReferrerExperience, NewUserExperience } from './types';\n\nexport class APIClient {\n private baseUrl: string;\n private apiKey: string;\n\n constructor(options: GrowthRailOptions) {\n const envBaseUrl = \n (typeof process !== 'undefined' && process.env?.ENV_BASE_URL)\n\n this.baseUrl = envBaseUrl || 'http://hw84ko0ok4ccws4sws8gos0o.193.31.30.10.sslip.io' || 'https://api.growthrail.com/v1'; // Default to prod\n this.apiKey = options.apiKey;\n }\n\n private async request(endpoint: string, method: string, body?: any) {\n const headers = {\n 'Content-Type': 'application/json',\n 'X-GrowthRail-ProjectSecret': this.apiKey,\n };\n\n try {\n const response = await fetch(`${this.baseUrl}${endpoint}`, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n throw new Error(`GrowthRail API Error: ${response.statusText}`);\n }\n\n return response.json();\n } catch (error) {\n console.error('GrowthRail SDK Error:', error);\n throw error;\n }\n }\n\n async getNewUserExperience(): Promise<NewUserExperience> {\n return this.request('/api/v1/sdk/new-user-experience', 'POST');\n }\n\n async initAppUser(clientProvidedId: string): Promise<AppUserType> {\n return this.request('/api/v1/sdk/init-app-user', 'POST', { clientProvidedId });\n }\n\n async createReferralLink(referrerId: string, rewardEventName?: string): Promise<{ referralCode: string; referralLink: string }> {\n return this.request('/api/v1/sdk/create-referral-link', 'POST', { referrerId,\n rewardEventName });\n }\n\n async trackReferral(referralCode: string, rewardEventName?: string): Promise<TrackReferralResponse> {\n return this.request('/api/v1/sdk/track-referral', 'POST', { referralCode,\n rewardEventName });\n }\n\n async trackRewardEvent(refereeId: string, referralTrackingId: string, eventName?: string) {\n return this.request('/api/v1/sdk/track-reward-event', 'POST', {\n refereeId, referralTrackingId, eventName\n });\n }\n \n}\n","export class StorageManager {\n private static REFERRAL_CODE_KEY = 'gr_ref_code';\n private static TRACKED_REFERRAL_KEY = 'gr_tracked_referral';\n\n private options: { cookieDomain?: string } = {};\n\n constructor(options?: { cookieDomain?: string }) {\n if (options) {\n this.options = options;\n }\n }\n\n // Helper to set a cookie\n private setCookie(name: string, value: string, days: number = 30): void {\n if (typeof document === 'undefined') return;\n \n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));\n expires = `; expires=${date.toUTCString()}`;\n }\n\n let domain = '';\n if (this.options.cookieDomain) {\n domain = `; domain=${this.options.cookieDomain}`;\n }\n\n document.cookie = `${name}=${(value || '')}${expires}${domain}; path=/; SameSite=Lax`;\n }\n\n // Helper to get a cookie\n private getCookie(name: string): string | null {\n if (typeof document === 'undefined') return null;\n \n const nameEQ = `${name}=`;\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n\n getReferralCode(): string | null {\n // We prefer cookies for referral codes to support cross-subdomain attribution\n return this.getCookie(StorageManager.REFERRAL_CODE_KEY);\n }\n\n setReferralCode(code: string): void {\n // Persist referral code for 30 days (typical attribution window)\n this.setCookie(StorageManager.REFERRAL_CODE_KEY, code, 30);\n }\n\n setTrackedReferral(trackingId: string): void {\n this.setCookie(StorageManager.TRACKED_REFERRAL_KEY, trackingId, 30);\n }\n\n getTrackedReferral(): string | null {\n return this.getCookie(StorageManager.TRACKED_REFERRAL_KEY);\n }\n}\n","import { ReferrerExperience, ReferrerModalOptions } from './types';\n\nexport interface ReferralModalDependencies {\n isUserReady: () => boolean;\n getReferralLink: () => string;\n}\n\nexport class ReferralModal {\n private referrerExperience: ReferrerExperience;\n private deps: ReferralModalDependencies;\n private host: HTMLElement | null = null;\n private shadow: ShadowRoot | null = null;\n private overlay: HTMLDivElement | null = null;\n private content: HTMLDivElement | null = null;\n\n constructor(deps: ReferralModalDependencies, referrerExperience: ReferrerExperience) {\n this.deps = deps;\n this.referrerExperience = referrerExperience;\n }\n\n public show(options?: Partial<ReferrerModalOptions>, container?: HTMLElement): void {\n if (this.host) return;\n\n this.createDom(options, container);\n this.bindEvents();\n \n if (!container) {\n document.body.style.overflow = 'hidden';\n }\n }\n\n public hide(): void {\n if (!this.host) return;\n\n if (this.host && this.host.parentNode) {\n this.host.parentNode.removeChild(this.host);\n }\n\n this.host = null;\n this.overlay = null;\n this.content = null;\n this.shadow = null;\n document.body.style.overflow = '';\n }\n \n private createDom(options?: Partial<ReferrerModalOptions>, container?: HTMLElement): void {\n const resolvedOptions = {\n ...this.referrerExperience,\n ...(options ?? {}),\n };\n\n const baseTheme = this.getTheme();\n const theme = {\n ...baseTheme,\n colorPrimary: resolvedOptions.modal?.theme?.primaryColor || baseTheme.colorPrimary,\n colorBackground: resolvedOptions.modal?.theme?.backgroundColor || baseTheme.colorBackground,\n colorTint: resolvedOptions.modal?.theme?.tintColor || baseTheme.colorTint,\n };\n\n const isEmbedded = !!container;\n\n // 1. Create Host & Set Variables\n this.host = document.createElement('div');\n this.host.style.all = 'initial';\n \n if (!isEmbedded) {\n this.host.style.position = 'absolute';\n this.host.style.zIndex = '2147483647';\n } else {\n this.host.style.display = 'block';\n this.host.style.width = '100%';\n this.host.style.height = '100%';\n }\n\n this.host.id = 'growth-rail-modal-host';\n \n // Set Theme Variables\n this.host.style.setProperty('--gr-primary', theme.colorPrimary);\n this.host.style.setProperty('--gr-text', theme.colorText);\n this.host.style.setProperty('--gr-text-secondary', theme.colorTextSecondary);\n this.host.style.setProperty('--gr-bg', theme.colorBackground);\n this.host.style.setProperty('--gr-tint', theme.colorTint);\n this.host.style.setProperty('--gr-surface', theme.colorSurface);\n this.host.style.setProperty('--gr-border', theme.colorBorder);\n this.host.style.setProperty('--gr-error', theme.colorError);\n this.host.style.setProperty('--gr-radius', theme.borderRadius);\n this.host.style.setProperty('--gr-font', 'Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif');\n\n // 2. Attach Shadow\n this.shadow = this.host.attachShadow({ mode: 'open' });\n\n // 3. Inject Styles\n const style = document.createElement('style');\n style.textContent = `:host{all:initial;display:block}*{box-sizing:border-box}@keyframes gr-fade-in{from{opacity:0}to{opacity:1}}@keyframes gr-slide-up{from{opacity:0;transform:translateY(20px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes gr-slide-in-right{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}@keyframes gr-slide-in-left{from{opacity:0;transform:translateX(-100%)}to{opacity:1;transform:translateX(0)}}.gr-overlay{position:fixed;top:0;left:0;width:100vw;height:100vh;display:flex;z-index:2147483647;font-family:var(--gr-font);animation:gr-fade-in .2s ease-out forwards;backdrop-filter:blur(4px)}.gr-overlay--modal{background-color:var(--gr-tint);align-items:center;justify-content:center}.gr-overlay--drawer{background-color:var(--gr-tint);align-items:flex-start;justify-content:flex-start}.gr-container{position:relative;background-color:var(--gr-bg);color:var(--gr-text);padding:32px;box-shadow:0 20px 25px -5px rgba(0,0,0,.1),0 10px 10px -5px rgba(0,0,0,.04)}.gr-container--embedded{width:100%;height:100%;box-shadow:none;border:1px solid var(--gr-border);border-radius:var(--gr-radius)}.gr-container--modal{width:90%;max-width:480px;border-radius:var(--gr-radius);animation:gr-slide-up .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--drawer{position:absolute;width:400px;max-width:calc(100vw - 20px);max-height:calc(100vh - 40px);overflow-y:auto}.gr-container--right{right:0;border-top-left-radius:var(--gr-radius);border-bottom-left-radius:var(--gr-radius);animation:gr-slide-in-right .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--left{left:0;border-top-right-radius:var(--gr-radius);border-bottom-right-radius:var(--gr-radius);animation:gr-slide-in-left .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--top{top:100px}.gr-container--bottom{bottom:100px}.gr-close-btn{position:absolute;top:20px;right:20px;background:0 0;border:none;cursor:pointer;color:#9ca3af;padding:4px;border-radius:50%;display:flex;align-items:center;justify-content:center;transition:all .2s}.gr-close-btn:hover{background-color:var(--gr-surface);color:var(--gr-text)}.gr-header{text-align:center;margin-bottom:28px}.gr-icon-lg{font-size:32px;margin-bottom:12px}.gr-title{margin:0 0 8px 0;font-size:22px;font-weight:700;letter-spacing:-.02em}.gr-subtitle{margin:0;font-size:14px;line-height:1.5;color:var(--gr-text-secondary)}.gr-loading{padding:16px;background-color:var(--gr-surface);border-radius:8px;text-align:center;color:var(--gr-text-secondary);font-size:14px}.gr-label{display:block;font-size:12px;font-weight:600;color:var(--gr-text-secondary);margin-bottom:8px;text-transform:uppercase;letter-spacing:.05em}.gr-share-label{text-align:center;margin-bottom:16px;font-size:13px;font-weight:500;color:var(--gr-text-secondary);display:flex;align-items:center;gap:12px}.gr-divider{flex:1;height:1px;background:var(--gr-border)}.gr-social-container{display:flex;gap:16px;justify-content:center;flex-wrap:wrap}.gr-btn{padding:14px;font-size:15px;font-weight:600;background-color:var(--gr-primary);color:#fff;border:none;border-radius:var(--gr-radius);cursor:pointer;transition:all .2s ease;text-align:center;width:100%;display:block}.gr-btn:hover{transform:translateY(-1px);filter:brightness(1.05)}.gr-btn:active{transform:translateY(0);filter:brightness(.95)}.gr-btn:disabled{opacity:.7;cursor:not-allowed}.gr-btn--sm{padding:8px 16px;font-size:13px;width:auto;border-radius:calc(var(--gr-radius) - 4px)}.gr-input-group{display:flex;align-items:center;background-color:var(--gr-surface);border:1px solid var(--gr-border);border-radius:var(--gr-radius);padding:4px;margin-bottom:24px}.gr-input-group:focus-within{border-color:var(--gr-primary);box-shadow:0 0 0 3px var(--gr-surface)}.gr-input{flex:1;padding:10px 12px;font-size:14px;border:none;background:0 0;color:var(--gr-text);outline:none;font-family:monospace}.gr-social-btn{display:flex;align-items:center;justify-content:center;width:42px;height:42px;border-radius:50%;background-color:var(--gr-surface);color:var(--gr-text-secondary);border:1px solid var(--gr-border);transition:transform .2s cubic-bezier(.34,1.56,.64,1);cursor:pointer}.gr-social-btn:hover{transform:scale(1.15) rotate(3deg);color:#fff}.gr-powered-by{margin-top:24px;text-align:center;font-size:11px;color:#9ca3af;display:flex;align-items:center;justify-content:center;gap:4px;opacity:.8}.gr-powered-by a{color:inherit;text-decoration:none;font-weight:600;transition:opacity .2s}.gr-powered-by a:hover{opacity:1;text-decoration:underline}`;\n this.shadow.appendChild(style);\n this.content = document.createElement('div');\n \n // Default to modal if no mode set\n const isDrawer = resolvedOptions.modal.type === 'drawer';\n const position = resolvedOptions.trigger.position || 'top-right';\n\n // Apply classes\n const contentClasses = ['gr-container'];\n \n if (isEmbedded) {\n contentClasses.push('gr-container--embedded');\n this.content.className = contentClasses.join(' ');\n // Render Content directly\n this.renderInternalContent(theme, options, isEmbedded);\n \n this.shadow.appendChild(this.content);\n if (container) {\n container.appendChild(this.host);\n }\n } else {\n this.overlay = document.createElement('div');\n this.overlay.className = `gr-overlay ${isDrawer ? 'gr-overlay--drawer' : 'gr-overlay--modal'}`;\n \n if (isDrawer) {\n contentClasses.push('gr-container--drawer');\n if (position.includes('right')) contentClasses.push('gr-container--right');\n else contentClasses.push('gr-container--left');\n \n if (position.includes('bottom')) contentClasses.push('gr-container--bottom');\n else contentClasses.push('gr-container--top');\n } else {\n contentClasses.push('gr-container--modal');\n }\n this.content.className = contentClasses.join(' ');\n\n this.renderInternalContent(theme, options, isEmbedded);\n \n this.overlay.appendChild(this.content);\n this.shadow.appendChild(this.overlay); \n document.body.appendChild(this.host);\n\n this.overlay.onclick = (e) => {\n if (e.target === this.overlay) this.hide();\n };\n }\n }\n\n private getTheme() {\n return {\n colorPrimary: '#2563eb',\n colorText: '#111827',\n colorTextSecondary: '#6b7280',\n colorBackground: '#ffffff',\n colorTint: '#f9fafb',\n colorSurface: '#f9fafb', \n colorBorder: '#e5e7eb',\n colorError: '#ef4444',\n borderRadius: '16px',\n };\n }\n\n private async renderInternalContent(theme: ReturnType<typeof ReferralModal.prototype.getTheme>, options?: Partial<ReferrerModalOptions>, isEmbedded = false) {\n if (!this.content) return;\n\n this.content.innerHTML = '';\n\n // Close Button\n if (!isEmbedded) {\n const closeBtn = document.createElement('button');\n closeBtn.className = 'gr-close-btn';\n closeBtn.innerHTML = `\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\n </svg>\n `;\n closeBtn.onclick = () => this.hide();\n this.content.appendChild(closeBtn);\n }\n\n // Header Container\n const header = document.createElement('div');\n header.className = 'gr-header';\n\n // Icon/Logo placeholder (optional, adds visuals)\n const icon = document.createElement('div');\n icon.className = 'gr-icon-lg';\n icon.innerHTML = '🎁';\n header.appendChild(icon);\n\n // Title\n const title = document.createElement('h3');\n title.className = 'gr-title';\n title.textContent = options?.title ?? this.referrerExperience.modal.title ?? 'Invite Friends & Earn';\n header.appendChild(title);\n\n // Subtitle\n const subtitle = document.createElement('p');\n subtitle.className = 'gr-subtitle';\n subtitle.textContent = 'Share your unique link and earn rewards for every friend who signs up.';\n header.appendChild(subtitle);\n\n this.content.appendChild(header);\n\n // Loading State\n if (!this.deps.isUserReady()) {\n const msg = document.createElement('div');\n msg.className = 'gr-loading';\n msg.textContent = 'Please log in to view your referral dashboard.';\n this.content.appendChild(msg);\n return;\n }\n\n let referralLink = this.deps.getReferralLink();\n \n // Main Action Area\n const actionContainer = document.createElement('div');\n \n this.renderLinkView(actionContainer, referralLink, theme);\n \n this.content.appendChild(actionContainer);\n\n // Social Share Section (only if link exists)\n if (referralLink) {\n this.renderSocialShare(this.content, referralLink, theme);\n }\n\n // Powered By Footer\n const poweredBy = document.createElement('div');\n poweredBy.className = 'gr-powered-by';\n poweredBy.innerHTML = `\n Powered by <a href=\"https://growthrail.com\" target=\"_blank\" rel=\"noopener noreferrer\">Growth Rail</a>\n `;\n this.content.appendChild(poweredBy);\n }\n\n private renderLinkView(container: HTMLDivElement, link: string, theme: ReturnType<typeof ReferralModal.prototype.getTheme>) {\n const label = document.createElement('label');\n label.className = 'gr-label';\n label.textContent = 'Your unique link';\n container.appendChild(label);\n\n const linkGroup = document.createElement('div');\n linkGroup.className = 'gr-input-group';\n\n const input = document.createElement('input');\n input.className = 'gr-input';\n input.type = 'text';\n input.value = link;\n input.readOnly = true;\n \n const copyBtn = document.createElement('button');\n copyBtn.className = 'gr-btn gr-btn--sm';\n copyBtn.textContent = 'Copy';\n \n copyBtn.onclick = async () => {\n try {\n await navigator.clipboard.writeText(link);\n const originalText = copyBtn.textContent;\n copyBtn.textContent = 'Copied!';\n copyBtn.style.backgroundColor = '#10b981'; // Success green (keep inline for dynamic state change, or add .gr-btn--success class)\n setTimeout(() => {\n copyBtn.textContent = originalText;\n copyBtn.style.backgroundColor = ''; // Revert to class style\n }, 2000);\n } catch (err) {\n console.error('Failed to copy', err);\n }\n };\n\n linkGroup.appendChild(input);\n linkGroup.appendChild(copyBtn);\n container.appendChild(linkGroup);\n }\n\n private renderSocialShare(container: HTMLDivElement, link: string, theme: ReturnType<typeof ReferralModal.prototype.getTheme>) {\n const shareContainer = document.createElement('div');\n \n const label = document.createElement('div');\n label.className = 'gr-share-label';\n label.innerHTML = `<span class=\"gr-divider\"></span>Share via<span class=\"gr-divider\"></span>`;\n shareContainer.appendChild(label);\n\n const buttonsContainer = document.createElement('div');\n buttonsContainer.className = 'gr-social-container';\n\n const platforms = [\n { name: 'Twitter', color: '#000000', icon: '<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z\"/></svg>', url: `https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}&text=Check+this+out!` },\n { name: 'Facebook', color: '#1877F2', icon: '<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036c-2.648 0-2.928 1.67-2.928 3.403v1.596h3.949l-.577 3.667h-3.372v7.98h-4.938z\"/></svg>', url: `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}` },\n { name: 'LinkedIn', color: '#0A66C2', icon: '<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z\"/></svg>', url: `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(link)}` },\n { name: 'WhatsApp', color: '#25D366', icon: '<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z\"/></svg>', url: `https://api.whatsapp.com/send?text=${encodeURIComponent(link)}` },\n { name: 'Email', color: '#888888', icon: '<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z\"/></svg>', url: `mailto:?subject=Check this out&body=${encodeURIComponent(link)}` }\n ];\n\n platforms.forEach(p => {\n const btn = document.createElement('a');\n btn.href = p.url;\n btn.target = '_blank';\n btn.rel = 'noopener noreferrer';\n btn.className = 'gr-social-btn';\n btn.innerHTML = p.icon;\n btn.title = `Share on ${p.name}`;\n \n btn.onmouseenter = () => { \n btn.style.backgroundColor = p.color; \n btn.style.color = '#ffffff'; \n btn.style.borderColor = p.color;\n };\n btn.onmouseleave = () => { \n btn.style.backgroundColor = ''; // Revert to CSS class style\n btn.style.color = ''; \n btn.style.borderColor = '';\n };\n \n buttonsContainer.appendChild(btn);\n });\n\n shareContainer.appendChild(buttonsContainer);\n container.appendChild(shareContainer);\n }\n\n private bindEvents(): void {\n if (this.overlay) {\n this.overlay.onclick = (e) => {\n if (e.target === this.overlay) {\n this.hide();\n }\n };\n }\n }\n}\n","import { GrowthRail } from './core';\nimport { ReferrerExperience } from './types';\n\nexport class TriggerButton {\n private options: ReferrerExperience['trigger'];\n private host: HTMLElement | null = null;\n private shadow: ShadowRoot | null = null;\n private element: HTMLElement | null = null;\n\n constructor(options: ReferrerExperience['trigger']) {\n this.options = options;\n }\n\n public mount(): void {\n if (this.host) return;\n\n this.createDom();\n }\n\n public unmount(): void {\n if (this.host && this.host.parentNode) {\n document.body.removeChild(this.host);\n }\n this.host = null;\n this.shadow = null;\n this.element = null;\n }\n\n private createDom(): void {\n // 1. Create Host\n this.host = document.createElement('div');\n this.host.style.all = 'initial'; // Reset inherited styles\n this.host.style.position = 'absolute';\n this.host.style.zIndex = '2147483646';\n \n // Positioning via CSS Variables\n const offset = { x: 0, y: 100 };\n this.host.style.setProperty('--gr-offset-y', `${offset.y}px`);\n \n // 2. Attach Shadow\n this.shadow = this.host.attachShadow({ mode: 'open' });\n\n // 3. Inject Styles\n const style = document.createElement('style');\n style.textContent = `:host{all:initial;display:block}@keyframes gr-shimmer{0%{transform:translateX(-150%) skewX(-15deg)}50%{transform:translateX(150%) skewX(-15deg)}100% {transform:translateX(150%) skewX(-15deg)}}.gr-floating-btn{position:fixed;width:50px;height:50px;background:linear-gradient(135deg,#6366f1 0%,#a855f7 100%);box-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,0.06);cursor:pointer;z-index:2147483646;display:flex;align-items:center;justify-content:center;transition:transform .2s cubic-bezier(.34,1.56,.64,1),box-shadow .2s ease,width .2s;overflow:hidden;font-family:system-ui,-apple-system,sans-serif;box-sizing:border-box}.gr-floating-btn *{box-sizing:border-box}.gr-floating-btn:hover{transform:scale(1.05);box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05)}.gr-floating-btn--right{right:0;border-top-left-radius:8px;border-bottom-left-radius:8px;border-top-right-radius:0;border-bottom-right-radius:0;padding-left:4px}.gr-floating-btn--left{left:0;border-top-right-radius:8px;border-bottom-right-radius:8px;border-top-left-radius:0;border-bottom-left-radius:0;padding-right:4px}.gr-floating-btn--bottom{bottom:var(--gr-offset-y)}.gr-floating-btn--top{top:var(--gr-offset-y)}.gr-floating-btn::after{content:'';position:absolute;top:0;left:0;width:100%;height:100%;background:linear-gradient(to right,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);transform:translateX(-150%) skewX(-15deg);animation:gr-shimmer 3s infinite}.gr-icon{color:#fff;width:24px;height:24px;position:relative;z-index:10}`;\n this.shadow.appendChild(style);\n\n // 4. Create Button Element\n this.element = document.createElement('div');\n \n const position = this.options.position || 'bottom-right';\n const classes = ['gr-floating-btn'];\n\n if (position.includes('right')) classes.push('gr-floating-btn--right');\n else classes.push('gr-floating-btn--left');\n\n if (position.includes('bottom')) classes.push('gr-floating-btn--bottom');\n else classes.push('gr-floating-btn--top');\n \n this.element.className = classes.join(' ');\n\n // Icon\n this.element.innerHTML = `\n <svg class=\"gr-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <polyline points=\"20 12 20 22 4 22 4 12\"></polyline>\n <rect x=\"2\" y=\"7\" width=\"20\" height=\"5\"></rect>\n <line x1=\"12\" y1=\"22\" x2=\"12\" y2=\"7\"></line>\n <path d=\"M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7z\"></path>\n <path d=\"M12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7z\"></path>\n </svg>\n `;\n\n this.element.onclick = () => {\n GrowthRail.showReferralDashboard();\n };\n\n this.shadow.appendChild(this.element);\n document.body.appendChild(this.host);\n }\n}\n","import { APIClient } from './api';\nimport { StorageManager } from './storage';\nimport { GrowthRailOptions, AppUserTypeWithId, AppUserType, ReferralLink, TrackReferralResponse, ReferrerExperience, ReferrerTriggerButton, ReferrerModalOptions, NewUserExperience } from './types';\nimport { ReferralModal } from './referral-modal';\nimport { TriggerButton } from './trigger-button';\n\nexport class GrowthRail {\n private static api: APIClient;\n private static storage: StorageManager;\n private static options: GrowthRailOptions;\n private static currentUser: AppUserTypeWithId | null = null;\n private static initialized: boolean = false;\n private static referralModal: ReferralModal | null = null;\n private static floatingButton: TriggerButton | null = null;\n private static experience: ReferrerExperience | null = null;\n private static userReadyPromise: Promise<AppUserType> | null = null;\n private static userReadyResolver: ((user: AppUserType) => void) | null = null;\n\n private constructor() {}\n\n static init(options: GrowthRailOptions): void {\n if (GrowthRail.initialized) return;\n \n GrowthRail.options = options;\n GrowthRail.api = new APIClient(options);\n GrowthRail.storage = new StorageManager({ cookieDomain: options.cookieDomain });\n GrowthRail.initialized = true;\n GrowthRail.autoTrackReferral();\n }\n\n static isInitialized(): boolean {\n return GrowthRail.initialized;\n }\n\n private static ensureInitialized(): void {\n if (!GrowthRail.initialized) {\n throw new Error('GrowthRail.init() must be called before using the SDK');\n }\n }\n\n private static async loadReferrerExperience(experience: ReferrerExperience) {\n try {\n GrowthRail.createReferralModal(experience);\n if (experience.trigger.show) {\n GrowthRail.createTriggerButton(experience.trigger);\n }\n } catch (error) {\n console.error('GrowthRail: Failed to load referrer experience', error);\n throw error;\n }\n }\n\n private static createReferralModal(referrerExperience: ReferrerExperience) {\n GrowthRail.referralModal = new ReferralModal({\n isUserReady: () => GrowthRail.isUserReady(),\n getReferralLink: () => GrowthRail.currentUser?.referralLink || '',\n }, referrerExperience);\n }\n\n private static async autoTrackReferral() {\n if (typeof window === 'undefined') return;\n\n const urlParams = new URLSearchParams(window.location.search);\n const refCode = urlParams.get('referralCode');\n const refEventName = urlParams.get('rewardEventName');\n\n if (refCode) {\n\n const newUserExperience = await GrowthRail.api.getNewUserExperience();\n\n const trackingResult = await GrowthRail.trackReferral(refCode, refEventName ?? undefined);\n GrowthRail.storage.setTrackedReferral(trackingResult.referralTrackingId);\n trackingResult.promotionalText && newUserExperience.banner.show && GrowthRail.createPromotionalBanner(trackingResult.promotionalText, newUserExperience);\n }\n }\n\n static async initAppUser(clientProvidedId: string): Promise<AppUserType> {\n GrowthRail.ensureInitialized();\n const appUser = await GrowthRail.api.initAppUser(clientProvidedId);\n GrowthRail.currentUser = { ...appUser, id: clientProvidedId };\n GrowthRail.experience = appUser.referrerExperience;\n GrowthRail.loadReferrerExperience(appUser.referrerExperience);\n\n if (GrowthRail.userReadyResolver) {\n GrowthRail.userReadyResolver(GrowthRail.currentUser);\n } else {\n GrowthRail.userReadyPromise = Promise.resolve(GrowthRail.currentUser);\n }\n\n return appUser;\n }\n\n static async trackReferral(referralCode: string, rewardEventName?: string): Promise<TrackReferralResponse> {\n GrowthRail.ensureInitialized();\n return GrowthRail.api.trackReferral(referralCode, rewardEventName);\n }\n\n static async trackRewardEvent(eventName?: string): Promise<void> {\n GrowthRail.ensureInitialized();\n \n const refereeId = GrowthRail.currentUser?.id;\n if (!refereeId) {\n throw new Error('GrowthRail: User must be initialized before tracking a reward event.');\n }\n\n const referralTrackingId = GrowthRail.storage.getTrackedReferral();\n if (!referralTrackingId) {\n throw new Error('GrowthRail: Referral Tracking Id must be initialized before tracking a reward event.');\n }\n\n return GrowthRail.api.trackRewardEvent(refereeId, referralTrackingId, eventName);\n }\n\n static getReferralLink(): string {\n if(!GrowthRail.currentUser?.referralLink) {\n throw new Error('GrowthRail: Referral Link not loaded or user not initialized');\n }\n return GrowthRail.currentUser.referralLink;\n }\n\n static getReferralCode(): string | undefined {\n return GrowthRail.currentUser?.referralCode;\n }\n\n static getUserId(): string | undefined {\n return GrowthRail.currentUser?.id;\n }\n\n static isUserReady(): boolean {\n return GrowthRail.currentUser !== null;\n }\n\n static ensureUserReady(): Promise<AppUserType> {\n if (GrowthRail.currentUser) {\n return Promise.resolve(GrowthRail.currentUser);\n }\n if (!GrowthRail.userReadyPromise) {\n GrowthRail.userReadyPromise = new Promise((resolve) => {\n GrowthRail.userReadyResolver = resolve;\n });\n }\n return GrowthRail.userReadyPromise;\n }\n\n static async showReferralDashboard(options?: Partial<ReferrerModalOptions>): Promise<void> {\n GrowthRail.ensureInitialized();\n\n if(!GrowthRail.experience) {\n throw new Error('GrowthRail: Experience not loaded');\n }\n \n // Always create a new instance to allow options update, or we could reuse and update options if we added that method.\n // For simplicity and to ensure fresh state/options, let's create a new one or handle singleton behavior carefully.\n // Since we handle DOM manually, if we want to reuse, we should check if it's already open. \n // But the modal handles \"already open\" check in show(). \n // Given the options might change (theme, callbacks), re-instantiating or updating is needed.\n // Let's re-instantiate for now as the simplest robust approach for changing options.\n // If there is an existing modal open, we should probably close it or update it.\n // Ideally hide() current if exists.\n\n if (GrowthRail.referralModal) {\n // If already open, maybe just focus or do nothing.\n // But if options changed, we might want to re-render.\n // For now, let's close and re-open to be safe with new config.\n GrowthRail.referralModal.hide();\n }\n \n GrowthRail.referralModal?.show(options);\n }\n\n private static createPromotionalBanner(promotionalText: string, newUserExperience: NewUserExperience) {\n if (typeof document === 'undefined') return;\n \n const banner = document.createElement('div');\n banner.style.position = 'fixed';\n banner.style.top = newUserExperience.banner.position.split('-')[1] === 'top' ? '0' : 'auto';\n banner.style.bottom = newUserExperience.banner.position.split('-')[1] === 'bottom' ? '0' : 'auto';\n banner.style.left = newUserExperience.banner.position.split('-')[0] === 'left' ? '0' : 'auto';\n banner.style.right = newUserExperience.banner.position.split('-')[0] === 'right' ? '0' : 'auto';\n banner.style.width = '100%';\n banner.style.margin = 'auto';\n banner.style.backgroundColor = '#f0f0f0';\n banner.style.padding = '10px';\n banner.style.textAlign = 'center';\n banner.style.zIndex = '10000';\n banner.textContent = promotionalText;\n document.body.appendChild(banner);\n }\n\n static createTriggerButton(options: Partial<ReferrerTriggerButton>): void {\n if (typeof window === 'undefined') return;\n\n if(!GrowthRail.experience) {\n throw new Error('GrowthRail: Experience not loaded');\n }\n\n if (GrowthRail.floatingButton) {\n GrowthRail.floatingButton.unmount();\n }\n\n const finalOptions = {...GrowthRail.experience?.trigger, ...options};\n\n GrowthRail.floatingButton = new TriggerButton(finalOptions);\n GrowthRail.floatingButton.mount();\n }\n\n static destroyTriggerButton(): void {\n if (GrowthRail.floatingButton) {\n GrowthRail.floatingButton.unmount();\n GrowthRail.floatingButton = null;\n }\n }\n}\n"],"mappings":"ijBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,kBAAAC,IAAA,eAAAC,EAAAJ,GCEO,IAAMK,EAAN,KAAgB,CAIrB,YAAYC,EAA4B,CAHxCC,EAAA,KAAQ,WACRA,EAAA,KAAQ,UAGN,IAAMC,EACH,OAAO,QAAY,KAAe,QAAQ,KAAK,aAElD,KAAK,QAAUA,GAAc,wDAC7B,K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AO,EAEnED,EAAW,eAAiB,IAAIwB,EAAcD,CAAY,EAC1DvB,EAAW,eAAe,MAAM,CAClC,CAEA,OAAO,sBAA6B,CAC9BA,EAAW,iBACbA,EAAW,eAAe,QAAQ,EAClCA,EAAW,eAAiB,KAEhC,CACF,EA7MEyB,EADWzB,EACI,OACfyB,EAFWzB,EAEI,WACfyB,EAHWzB,EAGI,WACfyB,EAJWzB,EAII,cAAwC,MACvDyB,EALWzB,EAKI,cAAuB,IACtCyB,EANWzB,EAMI,gBAAsC,MACrDyB,EAPWzB,EAOI,iBAAuC,MACtDyB,EARWzB,EAQI,aAAwC,MACvDyB,EATWzB,EASI,mBAAgD,MAC/DyB,EAVWzB,EAUI,oBAA0D,MAVpE,IAAM0B,EAAN1B","names":["index_exports","__export","GrowthRail","ReferralModal","__toCommonJS","APIClient","options","__publicField","envBaseUrl","endpoint","method","body","headers","response","error","clientProvidedId","referrerId","rewardEventName","referralCode","refereeId","referralTrackingId","eventName","_StorageManager","options","__publicField","name","value","days","expires","date","domain","nameEQ","ca","i","c","code","trackingId","StorageManager","ReferralModal","deps","referrerExperience","__publicField","options","container","resolvedOptions","baseTheme","theme","isEmbedded","style","isDrawer","position","contentClasses","e","closeBtn","header","icon","title","subtitle","msg","referralLink","actionContainer","poweredBy","link","label","linkGroup","input","copyBtn","originalText","err","shareContainer","buttonsContainer","btn","TriggerButton","options","__publicField","offset","style","position","classes","GrowthRail","_GrowthRail","options","APIClient","StorageManager","experience","error","referrerExperience","ReferralModal","urlParams","refCode","refEventName","newUserExperience","trackingResult","clientProvidedId","appUser","referralCode","rewardEventName","eventName","refereeId","referralTrackingId","resolve","promotionalText","banner","finalOptions","TriggerButton","__publicField","GrowthRail"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/api.ts","../src/storage.ts","../src/referral-modal.ts","../src/trigger-button.ts","../src/core.ts"],"sourcesContent":["import { GrowthRailOptions, AppUserType, TrackReferralResponse, ReferrerExperience, NewUserExperience } from './types';\n\nexport class APIClient {\n private baseUrl: string;\n private apiKey: string;\n\n constructor(options: GrowthRailOptions) {\n const envBaseUrl = \n (typeof process !== 'undefined' && process.env?.ENV_BASE_URL)\n\n this.baseUrl = envBaseUrl || 'http://hw84ko0ok4ccws4sws8gos0o.193.31.30.10.sslip.io' || 'https://api.growthrail.com/v1'; // Default to prod\n this.apiKey = options.apiKey;\n }\n\n private async request(endpoint: string, method: string, body?: any) {\n const headers = {\n 'Content-Type': 'application/json',\n 'X-GrowthRail-ProjectSecret': this.apiKey,\n };\n\n try {\n const response = await fetch(`${this.baseUrl}${endpoint}`, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n throw new Error(`GrowthRail API Error: ${response.statusText}`);\n }\n\n return response.json();\n } catch (error) {\n console.error('GrowthRail SDK Error:', error);\n throw error;\n }\n }\n\n async getNewUserExperience(): Promise<NewUserExperience> {\n return this.request('/api/v1/sdk/new-user-experience', 'POST');\n }\n\n async initAppUser(clientProvidedId: string): Promise<AppUserType> {\n return this.request('/api/v1/sdk/init-app-user', 'POST', { clientProvidedId });\n }\n\n async createReferralLink(referrerId: string, rewardEventName?: string): Promise<{ referralCode: string; referralLink: string }> {\n return this.request('/api/v1/sdk/create-referral-link', 'POST', { referrerId,\n rewardEventName });\n }\n\n async trackReferral(referralCode: string, rewardEventName?: string): Promise<TrackReferralResponse> {\n return this.request('/api/v1/sdk/track-referral', 'POST', { referralCode,\n rewardEventName });\n }\n\n async trackRewardEvent(refereeId: string, referralTrackingId: string, eventName?: string) {\n return this.request('/api/v1/sdk/track-reward-event', 'POST', {\n refereeId, referralTrackingId, eventName\n });\n }\n \n}\n","export class StorageManager {\n private static REFERRAL_CODE_KEY = 'gr_ref_code';\n private static TRACKED_REFERRAL_KEY = 'gr_tracked_referral';\n\n private options: { cookieDomain?: string } = {};\n\n constructor(options?: { cookieDomain?: string }) {\n if (options) {\n this.options = options;\n }\n }\n\n // Helper to set a cookie\n private setCookie(name: string, value: string, days: number = 30): void {\n if (typeof document === 'undefined') return;\n \n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));\n expires = `; expires=${date.toUTCString()}`;\n }\n\n let domain = '';\n if (this.options.cookieDomain) {\n domain = `; domain=${this.options.cookieDomain}`;\n }\n\n document.cookie = `${name}=${(value || '')}${expires}${domain}; path=/; SameSite=Lax`;\n }\n\n // Helper to get a cookie\n private getCookie(name: string): string | null {\n if (typeof document === 'undefined') return null;\n \n const nameEQ = `${name}=`;\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n\n getReferralCode(): string | null {\n // We prefer cookies for referral codes to support cross-subdomain attribution\n return this.getCookie(StorageManager.REFERRAL_CODE_KEY);\n }\n\n setReferralCode(code: string): void {\n // Persist referral code for 30 days (typical attribution window)\n this.setCookie(StorageManager.REFERRAL_CODE_KEY, code, 30);\n }\n\n setTrackedReferral(trackingId: string): void {\n this.setCookie(StorageManager.TRACKED_REFERRAL_KEY, trackingId, 30);\n }\n\n getTrackedReferral(): string | null {\n return this.getCookie(StorageManager.TRACKED_REFERRAL_KEY);\n }\n}\n","import { ReferrerExperience, ReferrerModalOptions } from './types';\n\nexport interface ReferralModalDependencies {\n isUserReady: () => boolean;\n getReferralLink: () => string;\n}\n\nexport class ReferralModal {\n private referrerExperience: ReferrerExperience;\n private deps: ReferralModalDependencies;\n private host: HTMLElement | null = null;\n private shadow: ShadowRoot | null = null;\n private overlay: HTMLDivElement | null = null;\n private content: HTMLDivElement | null = null;\n\n constructor(deps: ReferralModalDependencies, referrerExperience: ReferrerExperience) {\n this.deps = deps;\n this.referrerExperience = referrerExperience;\n }\n\n public show(options?: Partial<ReferrerModalOptions>, container?: HTMLElement): void {\n if (this.host) return;\n\n this.createDom(options, container);\n this.bindEvents();\n \n if (!container) {\n document.body.style.overflow = 'hidden';\n }\n }\n\n public hide(): void {\n if (!this.host) return;\n\n if (this.host && this.host.parentNode) {\n this.host.parentNode.removeChild(this.host);\n }\n\n this.host = null;\n this.overlay = null;\n this.content = null;\n this.shadow = null;\n document.body.style.overflow = '';\n }\n \n private createDom(options?: Partial<ReferrerModalOptions>, container?: HTMLElement): void {\n const resolvedOptions = {\n ...this.referrerExperience,\n ...(options ?? {}),\n };\n\n const baseTheme = this.getTheme();\n const theme = {\n ...baseTheme,\n colorPrimary: resolvedOptions.modal?.theme?.primaryColor || baseTheme.colorPrimary,\n colorBackground: resolvedOptions.modal?.theme?.backgroundColor || baseTheme.colorBackground,\n colorTint: resolvedOptions.modal?.theme?.tintColor || baseTheme.colorTint,\n };\n\n const isEmbedded = !!container;\n\n // 1. Create Host & Set Variables\n this.host = document.createElement('div');\n this.host.style.all = 'initial';\n \n if (!isEmbedded) {\n this.host.style.position = 'absolute';\n this.host.style.zIndex = '2147483647';\n } else {\n this.host.style.display = 'block';\n this.host.style.width = '100%';\n this.host.style.height = '100%';\n }\n\n this.host.id = 'growth-rail-modal-host';\n \n // Set Theme Variables\n this.host.style.setProperty('--gr-primary', theme.colorPrimary);\n this.host.style.setProperty('--gr-text', theme.colorText);\n this.host.style.setProperty('--gr-text-secondary', theme.colorTextSecondary);\n this.host.style.setProperty('--gr-bg', theme.colorBackground);\n this.host.style.setProperty('--gr-tint', theme.colorTint);\n this.host.style.setProperty('--gr-surface', theme.colorSurface);\n this.host.style.setProperty('--gr-border', theme.colorBorder);\n this.host.style.setProperty('--gr-error', theme.colorError);\n this.host.style.setProperty('--gr-radius', theme.borderRadius);\n this.host.style.setProperty('--gr-font', 'Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif');\n\n // 2. Attach Shadow\n this.shadow = this.host.attachShadow({ mode: 'open' });\n\n // 3. Inject Styles\n const style = document.createElement('style');\n style.textContent = `:host{all:initial;display:block}*{box-sizing:border-box}@keyframes gr-fade-in{from{opacity:0}to{opacity:1}}@keyframes gr-slide-up{from{opacity:0;transform:translateY(20px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes gr-slide-in-right{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}@keyframes gr-slide-in-left{from{opacity:0;transform:translateX(-100%)}to{opacity:1;transform:translateX(0)}}.gr-overlay{position:fixed;top:0;left:0;width:100vw;height:100vh;display:flex;z-index:2147483647;font-family:var(--gr-font);animation:gr-fade-in .2s ease-out forwards;backdrop-filter:blur(4px)}.gr-overlay--modal{background-color:var(--gr-tint);align-items:center;justify-content:center}.gr-overlay--drawer{background-color:var(--gr-tint);align-items:flex-start;justify-content:flex-start}.gr-container{position:relative;background-color:var(--gr-bg);color:var(--gr-text);padding:32px;box-shadow:0 20px 25px -5px rgba(0,0,0,.1),0 10px 10px -5px rgba(0,0,0,.04)}.gr-container--embedded{width:100%;height:100%;box-shadow:none;border:1px solid var(--gr-border);border-radius:var(--gr-radius)}.gr-container--modal{width:90%;max-width:480px;border-radius:var(--gr-radius);animation:gr-slide-up .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--drawer{position:absolute;width:400px;max-width:calc(100vw - 20px);max-height:calc(100vh - 40px);overflow-y:auto}.gr-container--right{right:0;border-top-left-radius:var(--gr-radius);border-bottom-left-radius:var(--gr-radius);animation:gr-slide-in-right .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--left{left:0;border-top-right-radius:var(--gr-radius);border-bottom-right-radius:var(--gr-radius);animation:gr-slide-in-left .3s cubic-bezier(.16,1,.3,1) forwards}.gr-container--top{top:100px}.gr-container--bottom{bottom:100px}.gr-close-btn{position:absolute;top:20px;right:20px;background:0 0;border:none;cursor:pointer;color:#9ca3af;padding:4px;border-radius:50%;display:flex;align-items:center;justify-content:center;transition:all .2s}.gr-close-btn:hover{background-color:var(--gr-surface);color:var(--gr-text)}.gr-header{text-align:center;margin-bottom:28px}.gr-icon-lg{font-size:32px;margin-bottom:12px}.gr-title{margin:0 0 8px 0;font-size:22px;font-weight:700;letter-spacing:-.02em}.gr-subtitle{margin:0;font-size:14px;line-height:1.5;color:var(--gr-text-secondary)}.gr-loading{padding:16px;background-color:var(--gr-surface);border-radius:8px;text-align:center;color:var(--gr-text-secondary);font-size:14px}.gr-label{display:block;font-size:12px;font-weight:600;color:var(--gr-text-secondary);margin-bottom:8px;text-transform:uppercase;letter-spacing:.05em}.gr-share-label{text-align:center;margin-bottom:16px;font-size:13px;font-weight:500;color:var(--gr-text-secondary);display:flex;align-items:center;gap:12px}.gr-divider{flex:1;height:1px;background:var(--gr-border)}.gr-social-container{display:flex;gap:16px;justify-content:center;flex-wrap:wrap}.gr-btn{padding:14px;font-size:15px;font-weight:600;background-color:var(--gr-primary);color:#fff;border:none;border-radius:var(--gr-radius);cursor:pointer;transition:all .2s ease;text-align:center;width:100%;display:block}.gr-btn:hover{transform:translateY(-1px);filter:brightness(1.05)}.gr-btn:active{transform:translateY(0);filter:brightness(.95)}.gr-btn:disabled{opacity:.7;cursor:not-allowed}.gr-btn--sm{padding:8px 16px;font-size:13px;width:auto;border-radius:calc(var(--gr-radius) - 4px)}.gr-input-group{display:flex;align-items:center;background-color:var(--gr-surface);border:1px solid var(--gr-border);border-radius:var(--gr-radius);padding:4px;margin-bottom:24px}.gr-input-group:focus-within{border-color:var(--gr-primary);box-shadow:0 0 0 3px var(--gr-surface)}.gr-input{flex:1;padding:10px 12px;font-size:14px;border:none;background:0 0;color:var(--gr-text);outline:none;font-family:monospace}.gr-social-btn{display:flex;align-items:center;justify-content:center;width:42px;height:42px;border-radius:50%;background-color:var(--gr-surface);color:var(--gr-text-secondary);border:1px solid var(--gr-border);transition:transform .2s cubic-bezier(.34,1.56,.64,1);cursor:pointer}.gr-social-btn:hover{transform:scale(1.15) rotate(3deg);color:#fff}.gr-powered-by{margin-top:24px;text-align:center;font-size:11px;color:#9ca3af;display:flex;align-items:center;justify-content:center;gap:4px;opacity:.8}.gr-powered-by a{color:inherit;text-decoration:none;font-weight:600;transition:opacity .2s}.gr-powered-by a:hover{opacity:1;text-decoration:underline}`;\n this.shadow.appendChild(style);\n this.content = document.createElement('div');\n \n // Default to modal if no mode set\n const isDrawer = resolvedOptions.modal.type === 'drawer';\n const position = resolvedOptions.trigger.position || 'top-right';\n\n // Apply classes\n const contentClasses = ['gr-container'];\n \n if (isEmbedded) {\n contentClasses.push('gr-container--embedded');\n this.content.className = contentClasses.join(' ');\n // Render Content directly\n this.renderInternalContent(theme, options, isEmbedded);\n \n this.shadow.appendChild(this.content);\n if (container) {\n container.appendChild(this.host);\n }\n } else {\n this.overlay = document.createElement('div');\n this.overlay.className = `gr-overlay ${isDrawer ? 'gr-overlay--drawer' : 'gr-overlay--modal'}`;\n \n if (isDrawer) {\n contentClasses.push('gr-container--drawer');\n if (position.includes('right')) contentClasses.push('gr-container--right');\n else contentClasses.push('gr-container--left');\n \n if (position.includes('bottom')) contentClasses.push('gr-container--bottom');\n else contentClasses.push('gr-container--top');\n } else {\n contentClasses.push('gr-container--modal');\n }\n this.content.className = contentClasses.join(' ');\n\n this.renderInternalContent(theme, options, isEmbedded);\n \n this.overlay.appendChild(this.content);\n this.shadow.appendChild(this.overlay); \n document.body.appendChild(this.host);\n\n this.overlay.onclick = (e) => {\n if (e.target === this.overlay) this.hide();\n };\n }\n }\n\n private getTheme() {\n return {\n colorPrimary: '#2563eb',\n colorText: '#111827',\n colorTextSecondary: '#6b7280',\n colorBackground: '#ffffff',\n colorTint: '#f9fafb',\n colorSurface: '#f9fafb', \n colorBorder: '#e5e7eb',\n colorError: '#ef4444',\n borderRadius: '16px',\n };\n }\n\n private async renderInternalContent(theme: ReturnType<typeof ReferralModal.prototype.getTheme>, options?: Partial<ReferrerModalOptions>, isEmbedded = false) {\n if (!this.content) return;\n\n this.content.innerHTML = '';\n\n // Close Button\n if (!isEmbedded) {\n const closeBtn = document.createElement('button');\n closeBtn.className = 'gr-close-btn';\n closeBtn.innerHTML = `\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\n </svg>\n `;\n closeBtn.onclick = () => this.hide();\n this.content.appendChild(closeBtn);\n }\n\n // Header Container\n const header = document.createElement('div');\n header.className = 'gr-header';\n\n // Icon/Logo placeholder (optional, adds visuals)\n const icon = document.createElement('div');\n icon.className = 'gr-icon-lg';\n icon.innerHTML = '🎁';\n header.appendChild(icon);\n\n // Title\n const title = document.createElement('h3');\n title.className = 'gr-title';\n title.textContent = options?.title ?? this.referrerExperience.modal.title ?? 'Invite Friends & Earn';\n header.appendChild(title);\n\n // Subtitle\n const subtitle = document.createElement('p');\n subtitle.className = 'gr-subtitle';\n subtitle.textContent = 'Share your unique link and earn rewards for every friend who signs up.';\n header.appendChild(subtitle);\n\n this.content.appendChild(header);\n\n // Loading State\n if (!this.deps.isUserReady()) {\n const msg = document.createElement('div');\n msg.className = 'gr-loading';\n msg.textContent = 'Please log in to view your referral dashboard.';\n this.content.appendChild(msg);\n return;\n }\n\n let referralLink = this.deps.getReferralLink();\n \n // Main Action Area\n const actionContainer = document.createElement('div');\n \n this.renderLinkView(actionContainer, referralLink, theme);\n \n this.content.appendChild(actionContainer);\n\n // Social Share Section (only if link exists)\n if (referralLink) {\n this.renderSocialShare(this.content, referralLink, theme);\n }\n\n // Powered By Footer\n const poweredBy = document.createElement('div');\n poweredBy.className = 'gr-powered-by';\n poweredBy.innerHTML = `\n Powered by <a href=\"https://growthrail.com\" target=\"_blank\" rel=\"noopener noreferrer\">Growth Rail</a>\n `;\n this.content.appendChild(poweredBy);\n }\n\n private renderLinkView(container: HTMLDivElement, link: string, theme: ReturnType<typeof ReferralModal.prototype.getTheme>) {\n const label = document.createElement('label');\n label.className = 'gr-label';\n label.textContent = 'Your unique link';\n container.appendChild(label);\n\n const linkGroup = document.createElement('div');\n linkGroup.className = 'gr-input-group';\n\n const input = document.createElement('input');\n input.className = 'gr-input';\n input.type = 'text';\n input.value = link;\n input.readOnly = true;\n \n const copyBtn = document.createElement('button');\n copyBtn.className = 'gr-btn gr-btn--sm';\n copyBtn.textContent = 'Copy';\n \n copyBtn.onclick = async () => {\n try {\n await navigator.clipboard.writeText(link);\n const originalText = copyBtn.textContent;\n copyBtn.textContent = 'Copied!';\n copyBtn.style.backgroundColor = '#10b981'; // Success green (keep inline for dynamic state change, or add .gr-btn--success class)\n setTimeout(() => {\n copyBtn.textContent = originalText;\n copyBtn.style.backgroundColor = ''; // Revert to class style\n }, 2000);\n } catch (err) {\n console.error('Failed to copy', err);\n }\n };\n\n linkGroup.appendChild(input);\n linkGroup.appendChild(copyBtn);\n container.appendChild(linkGroup);\n }\n\n private renderSocialShare(container: HTMLDivElement, link: string, theme: ReturnType<typeof ReferralModal.prototype.getTheme>) {\n const shareContainer = document.createElement('div');\n \n const label = document.createElement('div');\n label.className = 'gr-share-label';\n label.innerHTML = `<span class=\"gr-divider\"></span>Share via<span class=\"gr-divider\"></span>`;\n shareContainer.appendChild(label);\n\n const buttonsContainer = document.createElement('div');\n buttonsContainer.className = 'gr-social-container';\n\n const platforms = [\n { name: 'Twitter', color: '#000000', icon: '<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z\"/></svg>', url: `https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}&text=Check+this+out!` },\n { name: 'Facebook', color: '#1877F2', icon: '<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036c-2.648 0-2.928 1.67-2.928 3.403v1.596h3.949l-.577 3.667h-3.372v7.98h-4.938z\"/></svg>', url: `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}` },\n { name: 'LinkedIn', color: '#0A66C2', icon: '<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z\"/></svg>', url: `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(link)}` },\n { name: 'WhatsApp', color: '#25D366', icon: '<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z\"/></svg>', url: `https://api.whatsapp.com/send?text=${encodeURIComponent(link)}` },\n { name: 'Email', color: '#888888', icon: '<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z\"/></svg>', url: `mailto:?subject=Check this out&body=${encodeURIComponent(link)}` }\n ];\n\n platforms.forEach(p => {\n const btn = document.createElement('a');\n btn.href = p.url;\n btn.target = '_blank';\n btn.rel = 'noopener noreferrer';\n btn.className = 'gr-social-btn';\n btn.innerHTML = p.icon;\n btn.title = `Share on ${p.name}`;\n \n btn.onmouseenter = () => { \n btn.style.backgroundColor = p.color; \n btn.style.color = '#ffffff'; \n btn.style.borderColor = p.color;\n };\n btn.onmouseleave = () => { \n btn.style.backgroundColor = ''; // Revert to CSS class style\n btn.style.color = ''; \n btn.style.borderColor = '';\n };\n \n buttonsContainer.appendChild(btn);\n });\n\n shareContainer.appendChild(buttonsContainer);\n container.appendChild(shareContainer);\n }\n\n private bindEvents(): void {\n if (this.overlay) {\n this.overlay.onclick = (e) => {\n if (e.target === this.overlay) {\n this.hide();\n }\n };\n }\n }\n}\n","import { GrowthRail } from './core';\nimport { ReferrerExperience } from './types';\n\nexport class TriggerButton {\n private options: ReferrerExperience['trigger'];\n private host: HTMLElement | null = null;\n private shadow: ShadowRoot | null = null;\n private element: HTMLElement | null = null;\n\n constructor(options: ReferrerExperience['trigger']) {\n this.options = options;\n }\n\n public mount(): void {\n if (this.host) return;\n\n this.createDom();\n }\n\n public unmount(): void {\n if (this.host && this.host.parentNode) {\n document.body.removeChild(this.host);\n }\n this.host = null;\n this.shadow = null;\n this.element = null;\n }\n\n private createDom(): void {\n // 1. Create Host\n this.host = document.createElement('div');\n this.host.style.all = 'initial'; // Reset inherited styles\n this.host.style.position = 'absolute';\n this.host.style.zIndex = '2147483646';\n \n // Positioning via CSS Variables\n const offset = { x: 0, y: 100 };\n this.host.style.setProperty('--gr-offset-y', `${offset.y}px`);\n \n // 2. Attach Shadow\n this.shadow = this.host.attachShadow({ mode: 'open' });\n\n // 3. Inject Styles\n const style = document.createElement('style');\n style.textContent = `:host{all:initial;display:block}@keyframes gr-shimmer{0%{transform:translateX(-150%) skewX(-15deg)}50%{transform:translateX(150%) skewX(-15deg)}100% {transform:translateX(150%) skewX(-15deg)}}.gr-floating-btn{position:fixed;width:50px;height:50px;background:linear-gradient(135deg,#6366f1 0%,#a855f7 100%);box-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,0.06);cursor:pointer;z-index:2147483646;display:flex;align-items:center;justify-content:center;transition:transform .2s cubic-bezier(.34,1.56,.64,1),box-shadow .2s ease,width .2s;overflow:hidden;font-family:system-ui,-apple-system,sans-serif;box-sizing:border-box}.gr-floating-btn *{box-sizing:border-box}.gr-floating-btn:hover{transform:scale(1.05);box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05)}.gr-floating-btn--right{right:0;border-top-left-radius:8px;border-bottom-left-radius:8px;border-top-right-radius:0;border-bottom-right-radius:0;padding-left:4px}.gr-floating-btn--left{left:0;border-top-right-radius:8px;border-bottom-right-radius:8px;border-top-left-radius:0;border-bottom-left-radius:0;padding-right:4px}.gr-floating-btn--bottom{bottom:var(--gr-offset-y)}.gr-floating-btn--top{top:var(--gr-offset-y)}.gr-floating-btn::after{content:'';position:absolute;top:0;left:0;width:100%;height:100%;background:linear-gradient(to right,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);transform:translateX(-150%) skewX(-15deg);animation:gr-shimmer 3s infinite}.gr-icon{color:#fff;width:24px;height:24px;position:relative;z-index:10}`;\n this.shadow.appendChild(style);\n\n // 4. Create Button Element\n this.element = document.createElement('div');\n \n const position = this.options.position || 'bottom-right';\n const classes = ['gr-floating-btn'];\n\n if (position.includes('right')) classes.push('gr-floating-btn--right');\n else classes.push('gr-floating-btn--left');\n\n if (position.includes('bottom')) classes.push('gr-floating-btn--bottom');\n else classes.push('gr-floating-btn--top');\n \n this.element.className = classes.join(' ');\n\n // Icon\n this.element.innerHTML = `\n <svg class=\"gr-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <polyline points=\"20 12 20 22 4 22 4 12\"></polyline>\n <rect x=\"2\" y=\"7\" width=\"20\" height=\"5\"></rect>\n <line x1=\"12\" y1=\"22\" x2=\"12\" y2=\"7\"></line>\n <path d=\"M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7z\"></path>\n <path d=\"M12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7z\"></path>\n </svg>\n `;\n\n this.element.onclick = () => {\n GrowthRail.showReferralDashboard();\n };\n\n this.shadow.appendChild(this.element);\n document.body.appendChild(this.host);\n }\n}\n","import { APIClient } from './api';\nimport { StorageManager } from './storage';\nimport { GrowthRailOptions, AppUserTypeWithId, AppUserType, ReferralLink, TrackReferralResponse, ReferrerExperience, ReferrerTriggerButton, ReferrerModalOptions, NewUserExperience } from './types';\nimport { ReferralModal } from './referral-modal';\nimport { TriggerButton } from './trigger-button';\n\nexport class GrowthRail {\n private static api: APIClient;\n private static storage: StorageManager;\n private static options: GrowthRailOptions;\n private static currentUser: AppUserTypeWithId | null = null;\n private static initialized: boolean = false;\n private static referralModal: ReferralModal | null = null;\n private static floatingButton: TriggerButton | null = null;\n private static experience: ReferrerExperience | null = null;\n private static userReadyPromise: Promise<AppUserType> | null = null;\n private static userReadyResolver: ((user: AppUserType) => void) | null = null;\n\n private constructor() {}\n\n static init(options: GrowthRailOptions): void {\n if (GrowthRail.initialized) return;\n \n GrowthRail.options = options;\n GrowthRail.api = new APIClient(options);\n GrowthRail.storage = new StorageManager({ cookieDomain: options.cookieDomain });\n GrowthRail.initialized = true;\n GrowthRail.autoTrackReferral();\n }\n\n static isInitialized(): boolean {\n return GrowthRail.initialized;\n }\n\n private static ensureInitialized(): void {\n if (!GrowthRail.initialized) {\n throw new Error('GrowthRail.init() must be called before using the SDK');\n }\n }\n\n private static async loadReferrerExperience(experience: ReferrerExperience) {\n try {\n GrowthRail.createReferralModal(experience);\n if (experience.trigger.show) {\n GrowthRail.createTriggerButton(experience.trigger);\n }\n } catch (error) {\n console.error('GrowthRail: Failed to load referrer experience', error);\n throw error;\n }\n }\n\n private static createReferralModal(referrerExperience: ReferrerExperience) {\n GrowthRail.referralModal = new ReferralModal({\n isUserReady: () => GrowthRail.isUserReady(),\n getReferralLink: () => GrowthRail.currentUser?.referralLink || '',\n }, referrerExperience);\n }\n\n private static async autoTrackReferral() {\n if (typeof window === 'undefined') return;\n\n const urlParams = new URLSearchParams(window.location.search);\n const refCode = urlParams.get('referralCode');\n const refEventName = urlParams.get('rewardEventName');\n\n if (refCode) {\n\n const newUserExperience = await GrowthRail.api.getNewUserExperience();\n\n const trackingResult = await GrowthRail.trackReferral(refCode, refEventName ?? undefined);\n GrowthRail.storage.setTrackedReferral(trackingResult.referralTrackingId);\n trackingResult.promotionalText && newUserExperience.banner.show && GrowthRail.createPromotionalBanner(trackingResult.promotionalText, newUserExperience);\n }\n }\n\n static async initAppUser(clientProvidedId: string): Promise<AppUserType> {\n GrowthRail.ensureInitialized();\n const appUser = await GrowthRail.api.initAppUser(clientProvidedId);\n GrowthRail.currentUser = { ...appUser, id: clientProvidedId };\n GrowthRail.experience = appUser.referrerExperience;\n GrowthRail.loadReferrerExperience(appUser.referrerExperience);\n\n if (GrowthRail.userReadyResolver) {\n GrowthRail.userReadyResolver(GrowthRail.currentUser);\n } else {\n GrowthRail.userReadyPromise = Promise.resolve(GrowthRail.currentUser);\n }\n\n return appUser;\n }\n\n static async trackReferral(referralCode: string, rewardEventName?: string): Promise<TrackReferralResponse> {\n GrowthRail.ensureInitialized();\n return GrowthRail.api.trackReferral(referralCode, rewardEventName);\n }\n\n static async trackRewardEvent(eventName?: string): Promise<void> {\n GrowthRail.ensureInitialized();\n \n const refereeId = GrowthRail.currentUser?.id;\n if (!refereeId) {\n throw new Error('GrowthRail: User must be initialized before tracking a reward event.');\n }\n\n const referralTrackingId = GrowthRail.storage.getTrackedReferral();\n if (!referralTrackingId) {\n throw new Error('GrowthRail: Referral Tracking Id must be initialized before tracking a reward event.');\n }\n\n return GrowthRail.api.trackRewardEvent(refereeId, referralTrackingId, eventName);\n }\n\n static getReferralLink(): string {\n if(!GrowthRail.currentUser?.referralLink) {\n throw new Error('GrowthRail: Referral Link not loaded or user not initialized');\n }\n return GrowthRail.currentUser.referralLink;\n }\n\n static getReferralCode(): string | undefined {\n return GrowthRail.currentUser?.referralCode;\n }\n\n static getUserId(): string | undefined {\n return GrowthRail.currentUser?.id;\n }\n\n static isUserReady(): boolean {\n return GrowthRail.currentUser !== null;\n }\n\n static ensureUserReady(): Promise<AppUserType> {\n if (GrowthRail.currentUser) {\n return Promise.resolve(GrowthRail.currentUser);\n }\n if (!GrowthRail.userReadyPromise) {\n GrowthRail.userReadyPromise = new Promise((resolve) => {\n GrowthRail.userReadyResolver = resolve;\n });\n }\n return GrowthRail.userReadyPromise;\n }\n\n static async showReferralDashboard(options?: Partial<ReferrerModalOptions>): Promise<void> {\n GrowthRail.ensureInitialized();\n\n if(!GrowthRail.experience) {\n throw new Error('GrowthRail: Experience not loaded');\n }\n \n // Always create a new instance to allow options update, or we could reuse and update options if we added that method.\n // For simplicity and to ensure fresh state/options, let's create a new one or handle singleton behavior carefully.\n // Since we handle DOM manually, if we want to reuse, we should check if it's already open. \n // But the modal handles \"already open\" check in show(). \n // Given the options might change (theme, callbacks), re-instantiating or updating is needed.\n // Let's re-instantiate for now as the simplest robust approach for changing options.\n // If there is an existing modal open, we should probably close it or update it.\n // Ideally hide() current if exists.\n\n if (GrowthRail.referralModal) {\n // If already open, maybe just focus or do nothing.\n // But if options changed, we might want to re-render.\n // For now, let's close and re-open to be safe with new config.\n GrowthRail.referralModal.hide();\n }\n \n GrowthRail.referralModal?.show(options);\n }\n\n private static createPromotionalBanner(promotionalText: string, newUserExperience: NewUserExperience) {\n if (typeof document === 'undefined') return;\n \n const banner = document.createElement('div');\n banner.style.position = 'fixed';\n banner.style.top = newUserExperience.banner.position.split('-')[1] === 'top' ? '0' : 'auto';\n banner.style.bottom = newUserExperience.banner.position.split('-')[1] === 'bottom' ? '0' : 'auto';\n banner.style.left = newUserExperience.banner.position.split('-')[0] === 'left' ? '0' : 'auto';\n banner.style.right = newUserExperience.banner.position.split('-')[0] === 'right' ? '0' : 'auto';\n banner.style.width = '100%';\n banner.style.margin = 'auto';\n banner.style.backgroundColor = '#f0f0f0';\n banner.style.padding = '10px';\n banner.style.textAlign = 'center';\n banner.style.zIndex = '10000';\n banner.textContent = promotionalText;\n document.body.appendChild(banner);\n }\n\n static createTriggerButton(options: Partial<ReferrerTriggerButton>): void {\n if (typeof window === 'undefined') return;\n\n if(!GrowthRail.experience) {\n throw new Error('GrowthRail: Experience not loaded');\n }\n\n if (GrowthRail.floatingButton) {\n GrowthRail.floatingButton.unmount();\n }\n\n const finalOptions = {...GrowthRail.experience?.trigger, ...options};\n\n GrowthRail.floatingButton = new TriggerButton(finalOptions);\n GrowthRail.floatingButton.mount();\n }\n\n static destroyTriggerButton(): void {\n if (GrowthRail.floatingButton) {\n GrowthRail.floatingButton.unmount();\n GrowthRail.floatingButton = null;\n }\n }\n}\n"],"mappings":"oKAEO,IAAMA,EAAN,KAAgB,CAIrB,YAAYC,EAA4B,CAHxCC,EAAA,KAAQ,WACRA,EAAA,KAAQ,UAGN,IAAMC,EACH,OAAO,QAAY,KAAe,QAAQ,KAAK,aAElD,KAAK,QAAUA,GAAc,wDAC7B,KAAK,OAASF,EAAQ,MACxB,CAEA,MAAc,QAAQG,EAAkBC,EAAgBC,EAAY,CAClE,IAAMC,EAAU,CACd,eAAgB,mBAChB,6BAA8B,KAAK,MACrC,EAEA,GAAI,CACF,IAAMC,EAAW,MAAM,MAAM,GAAG,KAAK,OAAO,GAAGJ,CAAQ,GAAI,CACzD,OAAAC,EACA,QAAAE,EACA,KAAMD,EAAO,KAAK,UAAUA,CAAI,EAAI,MACtC,CAAC,EAED,GAAI,CAACE,EAAS,GACZ,MAAM,IAAI,MAAM,yBAAyBA,EAAS,UAAU,EAAE,EAGhE,OAAOA,EAAS,KAAK,CACvB,OAASC,EAAO,CACd,cAAQ,MAAM,wBAAyBA,CAAK,EACtCA,CACR,CACF,CAEA,MAAM,sBAAmD,CACvD,OAAO,KAAK,QAAQ,kCAAmC,MAAM,CAC/D,CAEA,MAAM,YAAYC,EAAgD,CAChE,OAAO,KAAK,QAAQ,4BAA6B,OAAQ,CAAE,iBAAAA,CAAiB,CAAC,CAC/E,CAEA,MAAM,mBAAmBC,EAAoBC,EAAmF,CAC9H,OAAO,KAAK,QAAQ,mCAAoC,OAAQ,CAAE,WAAAD,EACpE,gBAAAC,CAAgB,CAAC,CACjB,CAEA,MAAM,cAAcC,EAAsBD,EAA0D,CAClG,OAAO,KAAK,QAAQ,6BAA8B,OAAQ,CAAE,aAAAC,EAC9D,gBAAAD,CAAgB,CAAC,CACjB,CAEA,MAA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BA,EAAO,MAAM,QAAU,OACvBA,EAAO,MAAM,UAAY,SACzBA,EAAO,MAAM,OAAS,QACtBA,EAAO,YAAcD,EACrB,SAAS,KAAK,YAAYC,CAAM,CAClC,CAEA,OAAO,oBAAoBrB,EAA+C,CACxE,GAAI,OAAO,OAAW,IAAa,OAEnC,GAAG,CAACD,EAAW,WACb,MAAM,IAAI,MAAM,mCAAmC,EAGjDA,EAAW,gBACbA,EAAW,eAAe,QAAQ,EAGpC,IAAMuB,EAAe,CAAC,GAAGvB,EAAW,YAAY,QAAS,GAAGC,CAAO,EAEnED,EAAW,eAAiB,IAAIwB,EAAcD,CAAY,EAC1DvB,EAAW,eAAe,MAAM,CAClC,CAEA,OAAO,sBAA6B,CAC9BA,EAAW,iBACbA,EAAW,eAAe,QAAQ,EAClCA,EAAW,eAAiB,KAEhC,CACF,EA7MEyB,EADWzB,EACI,OACfyB,EAFWzB,EAEI,WACfyB,EAHWzB,EAGI,WACfyB,EAJWzB,EAII,cAAwC,MACvDyB,EALWzB,EAKI,cAAuB,IACtCyB,EANWzB,EAMI,gBAAsC,MACrDyB,EAPWzB,EAOI,iBAAuC,MACtDyB,EARWzB,EAQI,aAAwC,MACvDyB,EATWzB,EASI,mBAAgD,MAC/DyB,EAVWzB,EAUI,oBAA0D,MAVpE,IAAM0B,EAAN1B","names":["APIClient","options","__publicField","envBaseUrl","endpoint","method","body","headers","response","error","clientProvidedId","referrerId","rewardEventName","referralCode","refereeId","referralTrackingId","eventName","_StorageManager","options","__publicField","name","value","days","expires","date","domain","nameEQ","ca","i","c","code","trackingId","StorageManager","ReferralModal","deps","referrerExperience","__publicField","options","container","resolvedOptions","baseTheme","theme","isEmbedded","style","isDrawer","position","contentClasses","e","closeBtn","header","icon","title","subtitle","msg","referralLink","actionContainer","poweredBy","link","label","linkGroup","input","copyBtn","originalText","err","shareContainer","buttonsContainer","p","btn","TriggerButton","options","__publicField","offset","style","position","classes","GrowthRail","_GrowthRail","options","APIClient","StorageManager","experience","error","referrerExperience","ReferralModal","urlParams","refCode","refEventName","newUserExperience","trackingResult","clientProvidedId","appUser","referralCode","rewardEventName","eventName","refereeId","referralTrackingId","resolve","promotionalText","banner","finalOptions","TriggerButton","__publicField","GrowthRail"]}