@tekibo/feedpulse-sdk 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.mjs +223 -69
- package/dist/nuxt.js +1 -1
- package/dist/nuxt.mjs +160 -46
- package/dist/react.js +2 -2
- package/dist/react.mjs +235 -160
- package/package.json +5 -1
package/dist/nuxt.mjs
CHANGED
|
@@ -1,88 +1,202 @@
|
|
|
1
|
-
import { inject as
|
|
2
|
-
import { FeedPulseTracker as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
return
|
|
1
|
+
import { inject as B, defineComponent as _, ref as g, onMounted as D, onBeforeUnmount as E, createBlock as P, openBlock as l, Teleport as M, createElementBlock as u, createCommentVNode as x, createElementVNode as n, createTextVNode as b, withDirectives as C, vModelCheckbox as A, toDisplayString as $, provide as T, Fragment as h, renderSlot as L, normalizeStyle as z, renderList as V, vModelText as R } from "vue";
|
|
2
|
+
import { CookieManager as F, FeedPulseTracker as U } from "./index.mjs";
|
|
3
|
+
const S = /* @__PURE__ */ Symbol("feedpulse");
|
|
4
|
+
function j() {
|
|
5
|
+
return B(S, null);
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const K = {
|
|
8
|
+
key: 0,
|
|
9
|
+
style: { position: "fixed", bottom: "0", left: "0", right: "0", "z-index": "99999", background: "#1a1a1a", color: "#fff", padding: "20px 24px", "border-top": "1px solid #333", "font-family": "sans-serif" }
|
|
10
|
+
}, N = { style: { "max-width": "900px", margin: "0 auto" } }, q = {
|
|
11
|
+
key: 0,
|
|
12
|
+
style: { "margin-bottom": "12px", "font-size": "13px" }
|
|
13
|
+
}, W = { style: { display: "flex", "align-items": "center", gap: "8px", "margin-bottom": "6px" } }, H = { style: { display: "flex", "align-items": "center", gap: "8px" } }, O = { style: { display: "flex", gap: "8px", "flex-wrap": "wrap", "align-items": "center" } }, Y = /* @__PURE__ */ _({
|
|
14
|
+
__name: "consent-banner",
|
|
15
|
+
emits: ["consent"],
|
|
16
|
+
setup(d, { emit: r }) {
|
|
17
|
+
const o = r, t = new F(), i = g(!1), e = g(!1), a = g(!1), p = g(!1);
|
|
18
|
+
function v() {
|
|
19
|
+
i.value = !0, e.value = !0;
|
|
20
|
+
}
|
|
21
|
+
D(() => {
|
|
22
|
+
const y = t.getConsent();
|
|
23
|
+
i.value = !y || t.isConsentExpired(), y && (a.value = y.analytics, p.value = y.marketing), typeof window < "u" && (window.addEventListener("feedpulse:open-consent", v), window.addEventListener("feedpulse:withdraw-consent", w));
|
|
24
|
+
});
|
|
25
|
+
function m() {
|
|
26
|
+
t.setConsent({ analytics: !0, marketing: !0, version: "1.0" }), o("consent", { analytics: !0, marketing: !0, action: "accept_all" }), i.value = !1;
|
|
27
|
+
}
|
|
28
|
+
function c() {
|
|
29
|
+
t.setConsent({ analytics: !1, marketing: !1, version: "1.0" }), t.clearAnalyticsCookies(), o("consent", { analytics: !1, marketing: !1, action: "reject_all" }), i.value = !1;
|
|
30
|
+
}
|
|
31
|
+
function f() {
|
|
32
|
+
t.setConsent({ analytics: a.value, marketing: p.value, version: "1.0" }), a.value || t.clearAnalyticsCookies(), o("consent", { analytics: a.value, marketing: p.value, action: "custom" }), i.value = !1;
|
|
33
|
+
}
|
|
34
|
+
function w() {
|
|
35
|
+
t.setConsent({ analytics: !1, marketing: !1, version: "1.0" }), t.clearAnalyticsCookies(), a.value = !1, p.value = !1, o("consent", { analytics: !1, marketing: !1, action: "withdraw" }), i.value = !0;
|
|
36
|
+
}
|
|
37
|
+
return E(() => {
|
|
38
|
+
typeof window < "u" && (window.removeEventListener("feedpulse:open-consent", v), window.removeEventListener("feedpulse:withdraw-consent", w));
|
|
39
|
+
}), (y, s) => (l(), P(M, { to: "body" }, [
|
|
40
|
+
i.value ? (l(), u("div", K, [
|
|
41
|
+
n("div", N, [
|
|
42
|
+
s[6] || (s[6] = n("p", { style: { margin: "0 0 12px", "font-size": "14px", "line-height": "1.5" } }, [
|
|
43
|
+
b(" We use cookies to improve reliability and understand usage. "),
|
|
44
|
+
n("a", {
|
|
45
|
+
href: "/privacy",
|
|
46
|
+
style: { color: "#818cf8" }
|
|
47
|
+
}, "Privacy Policy")
|
|
48
|
+
], -1)),
|
|
49
|
+
e.value ? (l(), u("div", q, [
|
|
50
|
+
s[5] || (s[5] = n("label", { style: { display: "flex", "align-items": "center", gap: "8px", "margin-bottom": "6px", opacity: "0.75" } }, [
|
|
51
|
+
n("input", {
|
|
52
|
+
type: "checkbox",
|
|
53
|
+
checked: "",
|
|
54
|
+
disabled: ""
|
|
55
|
+
}),
|
|
56
|
+
b(" Necessary (always on) ")
|
|
57
|
+
], -1)),
|
|
58
|
+
n("label", W, [
|
|
59
|
+
C(n("input", {
|
|
60
|
+
"onUpdate:modelValue": s[0] || (s[0] = (k) => a.value = k),
|
|
61
|
+
type: "checkbox"
|
|
62
|
+
}, null, 512), [
|
|
63
|
+
[A, a.value]
|
|
64
|
+
]),
|
|
65
|
+
s[3] || (s[3] = b(" Analytics ", -1))
|
|
66
|
+
]),
|
|
67
|
+
n("label", H, [
|
|
68
|
+
C(n("input", {
|
|
69
|
+
"onUpdate:modelValue": s[1] || (s[1] = (k) => p.value = k),
|
|
70
|
+
type: "checkbox"
|
|
71
|
+
}, null, 512), [
|
|
72
|
+
[A, p.value]
|
|
73
|
+
]),
|
|
74
|
+
s[4] || (s[4] = b(" Marketing ", -1))
|
|
75
|
+
])
|
|
76
|
+
])) : x("", !0),
|
|
77
|
+
n("div", O, [
|
|
78
|
+
n("button", {
|
|
79
|
+
style: { width: "130px", padding: "9px 12px", background: "#4f46e5", color: "#fff", border: "1px solid #4f46e5", "border-radius": "6px", "font-size": "13px", "font-weight": "600", cursor: "pointer" },
|
|
80
|
+
onClick: m
|
|
81
|
+
}, " Accept All "),
|
|
82
|
+
n("button", {
|
|
83
|
+
style: { width: "130px", padding: "9px 12px", background: "transparent", color: "#fff", border: "1px solid #555", "border-radius": "6px", "font-size": "13px", "font-weight": "600", cursor: "pointer" },
|
|
84
|
+
onClick: c
|
|
85
|
+
}, " Reject All "),
|
|
86
|
+
n("button", {
|
|
87
|
+
style: { padding: "9px 16px", background: "transparent", color: "#aaa", border: "1px solid #333", "border-radius": "6px", "font-size": "13px", cursor: "pointer" },
|
|
88
|
+
onClick: s[2] || (s[2] = (k) => e.value ? f() : e.value = !0)
|
|
89
|
+
}, $(e.value ? "Save Preferences" : "Customize"), 1)
|
|
90
|
+
])
|
|
91
|
+
])
|
|
92
|
+
])) : x("", !0)
|
|
93
|
+
]));
|
|
94
|
+
}
|
|
95
|
+
}), te = /* @__PURE__ */ _({
|
|
8
96
|
__name: "FeedPulseProvider",
|
|
9
97
|
props: {
|
|
10
98
|
apiKey: {},
|
|
11
99
|
endpoint: {},
|
|
12
|
-
debug: { type: Boolean }
|
|
100
|
+
debug: { type: Boolean },
|
|
101
|
+
consentRequired: { type: Boolean, default: !0 }
|
|
13
102
|
},
|
|
14
|
-
setup(
|
|
15
|
-
const
|
|
16
|
-
apiKey:
|
|
17
|
-
endpoint:
|
|
18
|
-
debug:
|
|
103
|
+
setup(d) {
|
|
104
|
+
const r = d, o = new F(), t = new U({
|
|
105
|
+
apiKey: r.apiKey,
|
|
106
|
+
endpoint: r.endpoint,
|
|
107
|
+
debug: r.debug
|
|
19
108
|
});
|
|
20
|
-
|
|
109
|
+
T(S, t);
|
|
110
|
+
function i(e) {
|
|
111
|
+
const a = o.setConsent({
|
|
112
|
+
analytics: e.analytics,
|
|
113
|
+
marketing: e.marketing,
|
|
114
|
+
version: "1.0"
|
|
115
|
+
});
|
|
116
|
+
e.analytics || o.clearAnalyticsCookies(), t.updateCookieData(o.getAllData(e.analytics)), t.track("consent", "__consent__", {
|
|
117
|
+
analytics: e.analytics,
|
|
118
|
+
marketing: e.marketing,
|
|
119
|
+
action: e.action,
|
|
120
|
+
userAgent: navigator.userAgent,
|
|
121
|
+
version: a.version
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return D(() => {
|
|
125
|
+
const e = o.getConsent();
|
|
126
|
+
r.consentRequired === !1 ? (o.setConsent({ analytics: !0, marketing: !0, version: "1.0" }), t.updateCookieData(o.getAllData(!0))) : e && !o.isConsentExpired() ? t.updateCookieData(o.getAllData(e.analytics)) : t.updateCookieData(o.getAllData(!1)), t.init();
|
|
127
|
+
}), E(() => t.destroy()), (e, a) => (l(), u(h, null, [
|
|
128
|
+
L(e.$slots, "default"),
|
|
129
|
+
d.consentRequired !== !1 ? (l(), P(Y, {
|
|
130
|
+
key: 0,
|
|
131
|
+
onConsent: i
|
|
132
|
+
})) : x("", !0)
|
|
133
|
+
], 64));
|
|
21
134
|
}
|
|
22
|
-
}),
|
|
135
|
+
}), G = {
|
|
23
136
|
key: 1,
|
|
24
137
|
style: { background: "#fff", border: "1px solid #e5e7eb", "border-radius": "12px", padding: "16px", width: "280px", "box-shadow": "0 10px 25px rgba(0,0,0,0.15)" }
|
|
25
|
-
},
|
|
138
|
+
}, I = { style: { margin: "0 0 12px", "font-weight": "600", color: "#111" } }, J = { style: { display: "flex", gap: "6px", "margin-bottom": "12px" } }, Q = ["onClick"], X = {
|
|
26
139
|
key: 1,
|
|
27
140
|
style: { "text-align": "center", padding: "16px", color: "#111" }
|
|
28
|
-
},
|
|
141
|
+
}, ne = /* @__PURE__ */ _({
|
|
29
142
|
__name: "FeedPulseWidget",
|
|
30
143
|
props: {
|
|
31
144
|
id: {},
|
|
32
145
|
placeholder: {},
|
|
33
146
|
position: { default: "bottom-right" }
|
|
34
147
|
},
|
|
35
|
-
setup(
|
|
36
|
-
const
|
|
37
|
-
function
|
|
38
|
-
|
|
148
|
+
setup(d) {
|
|
149
|
+
const r = d, o = j(), t = g(r.position === "inline"), i = g(null), e = g(""), a = g(!1);
|
|
150
|
+
function p(m) {
|
|
151
|
+
i.value = m;
|
|
39
152
|
}
|
|
40
|
-
function
|
|
41
|
-
!
|
|
42
|
-
|
|
153
|
+
function v() {
|
|
154
|
+
!i.value && !e.value.trim() || (o?.trackFeedback(r.id ?? null, i.value, e.value || null), a.value = !0, setTimeout(() => {
|
|
155
|
+
t.value = r.position === "inline", a.value = !1, i.value = null, e.value = "";
|
|
43
156
|
}, 2e3));
|
|
44
157
|
}
|
|
45
|
-
return (
|
|
158
|
+
return (m, c) => (l(), u("div", {
|
|
46
159
|
class: "feedpulse-widget",
|
|
47
|
-
style:
|
|
160
|
+
style: z(d.position !== "inline" ? `position:fixed; ${d.position === "bottom-right" ? "right:24px" : "left:24px"}; bottom:24px; z-index:9999;` : "")
|
|
48
161
|
}, [
|
|
49
|
-
|
|
162
|
+
d.position !== "inline" ? (l(), u("button", {
|
|
50
163
|
key: 0,
|
|
51
164
|
style: { background: "#6366f1", color: "#fff", border: "none", "border-radius": "50%", width: "48px", height: "48px", "font-size": "20px", cursor: "pointer" },
|
|
52
|
-
onClick:
|
|
53
|
-
}, " 💬 ")) :
|
|
54
|
-
|
|
55
|
-
|
|
165
|
+
onClick: c[0] || (c[0] = (f) => t.value = !t.value)
|
|
166
|
+
}, " 💬 ")) : x("", !0),
|
|
167
|
+
t.value ? (l(), u("div", G, [
|
|
168
|
+
a.value ? (l(), u("div", X, [...c[2] || (c[2] = [
|
|
56
169
|
n("p", { style: { "font-size": "28px", margin: "0" } }, " 🎉 ", -1),
|
|
57
170
|
n("p", { style: { margin: "8px 0 0", "font-weight": "600" } }, " Thanks for your feedback! ", -1)
|
|
58
|
-
])])) : (
|
|
59
|
-
n("p",
|
|
60
|
-
n("div",
|
|
61
|
-
(
|
|
62
|
-
key:
|
|
63
|
-
style:
|
|
64
|
-
onClick: (
|
|
65
|
-
}, " ⭐ ", 12,
|
|
171
|
+
])])) : (l(), u(h, { key: 0 }, [
|
|
172
|
+
n("p", I, $(d.placeholder ?? "How was your experience?"), 1),
|
|
173
|
+
n("div", J, [
|
|
174
|
+
(l(), u(h, null, V(5, (f) => n("button", {
|
|
175
|
+
key: f,
|
|
176
|
+
style: z({ background: "none", border: "none", cursor: "pointer", fontSize: "24px", opacity: i.value !== null && f <= i.value ? 1 : 0.3 }),
|
|
177
|
+
onClick: (w) => p(f)
|
|
178
|
+
}, " ⭐ ", 12, Q)), 64))
|
|
66
179
|
]),
|
|
67
|
-
|
|
68
|
-
"onUpdate:modelValue":
|
|
180
|
+
C(n("textarea", {
|
|
181
|
+
"onUpdate:modelValue": c[1] || (c[1] = (f) => e.value = f),
|
|
69
182
|
placeholder: "Tell us more (optional)...",
|
|
70
183
|
rows: "3",
|
|
71
184
|
style: { width: "100%", padding: "8px", border: "1px solid #d1d5db", "border-radius": "8px", resize: "none", "font-size": "14px" }
|
|
72
185
|
}, null, 512), [
|
|
73
|
-
[
|
|
186
|
+
[R, e.value]
|
|
74
187
|
]),
|
|
75
188
|
n("button", {
|
|
76
189
|
style: { "margin-top": "10px", width: "100%", background: "#6366f1", color: "#fff", border: "none", "border-radius": "8px", padding: "10px", "font-weight": "600", cursor: "pointer" },
|
|
77
|
-
onClick:
|
|
190
|
+
onClick: v
|
|
78
191
|
}, " Submit Feedback ")
|
|
79
192
|
], 64))
|
|
80
|
-
])) :
|
|
193
|
+
])) : x("", !0)
|
|
81
194
|
], 4));
|
|
82
195
|
}
|
|
83
196
|
});
|
|
84
197
|
export {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
198
|
+
Y as ConsentBanner,
|
|
199
|
+
te as FeedPulseProvider,
|
|
200
|
+
ne as FeedPulseWidget,
|
|
201
|
+
j as useFeedPulse
|
|
88
202
|
};
|
package/dist/react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),N=require("./index.js");var j={exports:{}},_={};var Y;function se(){if(Y)return _;Y=1;var d=Symbol.for("react.transitional.element"),y=Symbol.for("react.fragment");function o(g,i,s){var m=null;if(s!==void 0&&(m=""+s),i.key!==void 0&&(m=""+i.key),"key"in i){s={};for(var b in i)b!=="key"&&(s[b]=i[b])}else s=i;return i=s.ref,{$$typeof:d,type:g,key:m,ref:i!==void 0?i:null,props:s}}return _.Fragment=y,_.jsx=o,_.jsxs=o,_}var R={};var $;function ie(){return $||($=1,process.env.NODE_ENV!=="production"&&(function(){function d(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ne?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case S:return"Fragment";case X:return"Profiler";case G:return"StrictMode";case K:return"Suspense";case ee:return"SuspenseList";case re:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case J:return"Portal";case Z:return e.displayName||"Context";case H:return(e._context.displayName||"Context")+".Consumer";case Q:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case te:return t=e.displayName||null,t!==null?t:d(e.type)||"Memo";case T:t=e._payload,e=e._init;try{return d(e(t))}catch{}}return null}function y(e){return""+e}function o(e){try{y(e);var t=!1}catch{t=!0}if(t){t=console;var a=t.error,l=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return a.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",l),y(e)}}function g(e){if(e===S)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===T)return"<...>";try{var t=d(e);return t?"<"+t+">":"<...>"}catch{return"<...>"}}function i(){var e=A.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function m(e){if(F.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function b(e,t){function a(){D||(D=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}function x(){var e=d(this.type);return I[e]||(I[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function h(e,t,a,l,w,C){var c=a.ref;return e={$$typeof:v,type:e,key:t,props:a,_owner:l},(c!==void 0?c:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:x}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:w}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:C}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function n(e,t,a,l,w,C){var c=t.children;if(c!==void 0)if(l)if(ae(c)){for(l=0;l<c.length;l++)f(c[l]);Object.freeze&&Object.freeze(c)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(c);if(F.call(t,"key")){c=d(e);var E=Object.keys(t).filter(function(oe){return oe!=="key"});l=0<E.length?"{key: someKey, "+E.join(": ..., ")+": ...}":"{key: someKey}",z[c+l]||(E=0<E.length?"{"+E.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,
|
|
6
|
+
<%s key={someKey} {...props} />`,l,c,E,c),z[c+l]=!0)}if(c=null,a!==void 0&&(o(a),c=""+a),m(t)&&(o(t.key),c=""+t.key),"key"in t){a={};for(var O in t)O!=="key"&&(a[O]=t[O])}else a=t;return c&&b(a,typeof e=="function"?e.displayName||e.name||"Unknown":e),h(e,c,a,i(),w,C)}function f(e){k(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===T&&(e._payload.status==="fulfilled"?k(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function k(e){return typeof e=="object"&&e!==null&&e.$$typeof===v}var p=u,v=Symbol.for("react.transitional.element"),J=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),X=Symbol.for("react.profiler"),H=Symbol.for("react.consumer"),Z=Symbol.for("react.context"),Q=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),ee=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),re=Symbol.for("react.activity"),ne=Symbol.for("react.client.reference"),A=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,ae=Array.isArray,P=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(e){return e()}};var D,I={},M=p.react_stack_bottom_frame.bind(p,s)(),W=P(g(s)),z={};R.Fragment=S,R.jsx=function(e,t,a){var l=1e4>A.recentlyCreatedOwnerStacks++;return n(e,t,a,!1,l?Error("react-stack-top-frame"):M,l?P(g(e)):W)},R.jsxs=function(e,t,a){var l=1e4>A.recentlyCreatedOwnerStacks++;return n(e,t,a,!0,l?Error("react-stack-top-frame"):M,l?P(g(e)):W)}})()),R}var L;function le(){return L||(L=1,process.env.NODE_ENV==="production"?j.exports=se():j.exports=ie()),j.exports}var r=le();const U=new N.CookieManager;function V({onConsent:d}){const[y,o]=u.useState(!1),[g,i]=u.useState(!1),[s,m]=u.useState(!1),[b,x]=u.useState(!1);u.useEffect(()=>{const p=U.getConsent();o(!p||U.isConsentExpired()),p&&(m(p.analytics),x(p.marketing))},[]);const h=()=>{d({analytics:!0,marketing:!0,action:"accept_all"}),o(!1)},n=()=>{d({analytics:!1,marketing:!1,action:"reject_all"}),o(!1)},f=()=>{d({analytics:s,marketing:b,action:"custom"}),o(!1)},k=u.useCallback(()=>{d({analytics:!1,marketing:!1,action:"withdraw"}),m(!1),x(!1),o(!0)},[d]);return u.useEffect(()=>{const p=()=>{o(!0),i(!0)};return window.addEventListener("feedpulse:open-consent",p),window.addEventListener("feedpulse:withdraw-consent",k),()=>{window.removeEventListener("feedpulse:open-consent",p),window.removeEventListener("feedpulse:withdraw-consent",k)}},[k]),y?r.jsx("div",{style:{position:"fixed",bottom:0,left:0,right:0,zIndex:99999,background:"#1a1a1a",color:"#fff",padding:"20px 24px",borderTop:"1px solid #333",fontFamily:"sans-serif"},children:r.jsxs("div",{style:{maxWidth:900,margin:"0 auto"},children:[r.jsxs("p",{style:{margin:"0 0 12px",fontSize:14,lineHeight:1.5},children:["We use cookies to improve reliability and understand usage."," ",r.jsx("a",{href:"/privacy",style:{color:"#818cf8"},children:"Privacy Policy"})]}),g&&r.jsxs("div",{style:{marginBottom:12,fontSize:13},children:[r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6,opacity:.75},children:[r.jsx("input",{type:"checkbox",checked:!0,disabled:!0}),"Necessary (always on)"]}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[r.jsx("input",{type:"checkbox",checked:s,onChange:p=>m(p.target.checked)}),"Analytics"]}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("input",{type:"checkbox",checked:b,onChange:p=>x(p.target.checked)}),"Marketing"]})]}),r.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[r.jsx("button",{type:"button",style:{width:130,padding:"9px 12px",background:"#4f46e5",color:"#fff",border:"1px solid #4f46e5",borderRadius:6,fontSize:13,fontWeight:600,cursor:"pointer"},onClick:h,children:"Accept All"}),r.jsx("button",{type:"button",style:{width:130,padding:"9px 12px",background:"transparent",color:"#fff",border:"1px solid #555",borderRadius:6,fontSize:13,fontWeight:600,cursor:"pointer"},onClick:n,children:"Reject All"}),r.jsx("button",{type:"button",style:{padding:"9px 16px",background:"transparent",color:"#aaa",border:"1px solid #333",borderRadius:6,fontSize:13,cursor:"pointer"},onClick:()=>g?f():i(!0),children:g?"Save Preferences":"Customize"})]})]})}):null}const q=u.createContext({tracker:null});function ce({apiKey:d,endpoint:y,debug:o,consentRequired:g=!0,children:i}){const s=u.useRef(null),m=u.useRef(new N.CookieManager),[b,x]=u.useState(null),h=u.useCallback(n=>{const f=m.current,k=f.setConsent({analytics:n.analytics,marketing:n.marketing,version:"1.0"});n.analytics||f.clearAnalyticsCookies(),s.current?.updateCookieData(f.getAllData(n.analytics)),s.current?.track("consent","__consent__",{analytics:n.analytics,marketing:n.marketing,action:n.action,userAgent:navigator.userAgent,version:k.version})},[]);return u.useEffect(()=>{const n=new N.FeedPulseTracker({apiKey:d,endpoint:y,debug:o});s.current=n,x(n);const f=m.current,k=f.getConsent();return g?k&&!f.isConsentExpired()?n.updateCookieData(f.getAllData(k.analytics)):n.updateCookieData(f.getAllData(!1)):(f.setConsent({analytics:!0,marketing:!0,version:"1.0"}),n.updateCookieData(f.getAllData(!0))),n.init(),()=>{n.destroy(),s.current=null,x(null)}},[d,y,o,g]),r.jsxs(q.Provider,{value:{tracker:b},children:[i,g&&r.jsx(V,{onConsent:h})]})}function B(){return u.useContext(q)}function ue({id:d,placeholder:y,position:o="bottom-right"}){const{tracker:g}=B(),[i,s]=u.useState(o==="inline"),[m,b]=u.useState(null),[x,h]=u.useState(""),[n,f]=u.useState(!1),k=()=>{!m&&!x.trim()||(g?.trackFeedback(d??null,m,x||null),f(!0),setTimeout(()=>{s(o==="inline"),f(!1),b(null),h("")},2e3))},p=o!=="inline"?{position:"fixed",bottom:24,[o==="bottom-right"?"right":"left"]:24,zIndex:9999}:{};return r.jsxs("div",{style:p,children:[o!=="inline"&&r.jsx("button",{onClick:()=>s(!i),style:{background:"#6366f1",color:"#fff",border:"none",borderRadius:"50%",width:48,height:48,fontSize:20,cursor:"pointer"},children:"💬"}),i&&r.jsx("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:12,padding:16,width:280,boxShadow:"0 10px 25px rgba(0,0,0,0.15)"},children:n?r.jsxs("div",{style:{textAlign:"center",padding:16},children:[r.jsx("p",{style:{fontSize:28,margin:0},children:"🎉"}),r.jsx("p",{style:{margin:"8px 0 0",fontWeight:600},children:"Thanks for your feedback!"})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{style:{margin:"0 0 12px",fontWeight:600},children:y??"How was your experience?"}),r.jsx("div",{style:{display:"flex",gap:6,marginBottom:12},children:[1,2,3,4,5].map(v=>r.jsx("button",{onClick:()=>b(v),style:{background:"none",border:"none",cursor:"pointer",fontSize:24,opacity:m!==null&&v<=m?1:.3},children:"⭐"},v))}),r.jsx("textarea",{value:x,onChange:v=>h(v.target.value),placeholder:"Tell us more (optional)...",rows:3,style:{width:"100%",padding:8,border:"1px solid #d1d5db",borderRadius:8,resize:"none",fontSize:14}}),r.jsx("button",{onClick:k,style:{marginTop:10,width:"100%",background:"#6366f1",color:"#fff",border:"none",borderRadius:8,padding:10,fontWeight:600,cursor:"pointer"},children:"Submit Feedback"})]})})]})}exports.ConsentBanner=V;exports.FeedPulseProvider=ce;exports.FeedPulseWidget=ue;exports.useFeedPulse=B;
|