@active-reach/web-sdk 1.30.0 → 1.31.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/dist/aegis.min.js +1 -1
- package/dist/aegis.min.js.map +1 -1
- package/dist/inapp/renderers/reviews.d.ts +9 -9
- package/dist/inapp/renderers/reviews.d.ts.map +1 -1
- package/dist/index.js +308 -284
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -585,13 +585,13 @@ function paintRating(card) {
|
|
|
585
585
|
const count = Number(meta.review_count ?? 0);
|
|
586
586
|
const rr = document.createElement("div");
|
|
587
587
|
rr.style.cssText = "display:flex;align-items:center;gap:3px;font-size:11px;line-height:1;";
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
|
|
588
|
+
const star2 = document.createElement("span");
|
|
589
|
+
star2.textContent = "★";
|
|
590
|
+
star2.style.cssText = "color:#059669;";
|
|
591
591
|
const val = document.createElement("span");
|
|
592
592
|
val.textContent = avg.toFixed(1);
|
|
593
593
|
val.style.cssText = "color:#059669;font-weight:700;";
|
|
594
|
-
rr.appendChild(
|
|
594
|
+
rr.appendChild(star2);
|
|
595
595
|
rr.appendChild(val);
|
|
596
596
|
if (count > 0) {
|
|
597
597
|
const c = document.createElement("span");
|
|
@@ -841,15 +841,15 @@ function renderNpsReasonStep(wrap, el2, ctx, score, fg, accent) {
|
|
|
841
841
|
const chipRow = document.createElement("div");
|
|
842
842
|
chipRow.style.cssText = "display:flex;flex-wrap:wrap;gap:6px;justify-content:center;margin-bottom:8px;";
|
|
843
843
|
chips.slice(0, 8).forEach((c) => {
|
|
844
|
-
const
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
844
|
+
const chip = document.createElement("button");
|
|
845
|
+
chip.type = "button";
|
|
846
|
+
chip.textContent = c;
|
|
847
|
+
chip.style.cssText = `padding:5px 11px;border-radius:999px;border:1px solid color-mix(in srgb, ${accent} 35%, transparent);background:transparent;color:${fg};font-size:12px;cursor:pointer;`;
|
|
848
|
+
chip.addEventListener("click", () => {
|
|
849
849
|
ta.value = ta.value ? `${ta.value}, ${c}` : c;
|
|
850
850
|
ta.focus();
|
|
851
851
|
});
|
|
852
|
-
chipRow.appendChild(
|
|
852
|
+
chipRow.appendChild(chip);
|
|
853
853
|
});
|
|
854
854
|
wrap.appendChild(chipRow);
|
|
855
855
|
}
|
|
@@ -1171,10 +1171,10 @@ function renderCardFromTemplate(card, opts) {
|
|
|
1171
1171
|
case "category": {
|
|
1172
1172
|
const cat = meta.category;
|
|
1173
1173
|
if (typeof cat !== "string" || !cat) break;
|
|
1174
|
-
const
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
container.appendChild(
|
|
1174
|
+
const chip = document.createElement("span");
|
|
1175
|
+
chip.textContent = cat;
|
|
1176
|
+
chip.style.cssText = "align-self:flex-start;background:#f3f4f6;color:#6b7280;font-size:10px;font-weight:500;padding:2px 7px;border-radius:6px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;";
|
|
1177
|
+
container.appendChild(chip);
|
|
1178
1178
|
break;
|
|
1179
1179
|
}
|
|
1180
1180
|
// ── rich-card-editor elements (P0) ──────────────────────────────────
|
|
@@ -2748,10 +2748,10 @@ function renderStreak(ctx) {
|
|
|
2748
2748
|
s.content.appendChild(gEl("div", "font-size:22px;font-weight:800;margin:4px 0 2px", `${count}-day streak!`));
|
|
2749
2749
|
const chips = gEl("div", "display:flex;justify-content:center;gap:8px;margin:12px 0");
|
|
2750
2750
|
for (let i = 0; i < 7; i++) {
|
|
2751
|
-
const
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
chips.appendChild(
|
|
2751
|
+
const chip = gEl("div", "display:inline-flex;flex-direction:column;align-items:center;gap:3px;font-size:11px;opacity:0.8");
|
|
2752
|
+
chip.appendChild(gEl("span", "", days[i]));
|
|
2753
|
+
chip.appendChild(gEl("span", "font-size:16px", i < count % 7 || count >= 7 && i < 7 ? "✅" : i === count % 7 ? "🔥" : "⚪"));
|
|
2754
|
+
chips.appendChild(chip);
|
|
2755
2755
|
}
|
|
2756
2756
|
s.content.appendChild(chips);
|
|
2757
2757
|
const note = gEl("div", "font-size:13px;opacity:0.8");
|
|
@@ -4116,15 +4116,15 @@ class AegisChat {
|
|
|
4116
4116
|
row.className = "aegis-chat-quickreplies";
|
|
4117
4117
|
for (const label of this.quickReplies) {
|
|
4118
4118
|
if (typeof label !== "string" || !label.trim()) continue;
|
|
4119
|
-
const
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4119
|
+
const chip = document.createElement("button");
|
|
4120
|
+
chip.type = "button";
|
|
4121
|
+
chip.className = "aegis-chat-chip";
|
|
4122
|
+
chip.textContent = label;
|
|
4123
|
+
chip.addEventListener("click", () => {
|
|
4124
4124
|
row.remove();
|
|
4125
4125
|
void this.send(label);
|
|
4126
4126
|
});
|
|
4127
|
-
row.appendChild(
|
|
4127
|
+
row.appendChild(chip);
|
|
4128
4128
|
}
|
|
4129
4129
|
if (row.childElementCount > 0) this.thread.appendChild(row);
|
|
4130
4130
|
}
|
|
@@ -5033,74 +5033,107 @@ function el(tag, css, text) {
|
|
|
5033
5033
|
if (text != null) e.textContent = text;
|
|
5034
5034
|
return e;
|
|
5035
5035
|
}
|
|
5036
|
-
function
|
|
5037
|
-
const
|
|
5036
|
+
function star(filled, size) {
|
|
5037
|
+
const svg = document.createElementNS(SVG_NS, "svg");
|
|
5038
|
+
svg.setAttribute("viewBox", "0 0 24 24");
|
|
5039
|
+
svg.setAttribute("width", String(size));
|
|
5040
|
+
svg.setAttribute("height", String(size));
|
|
5041
|
+
const p = document.createElementNS(SVG_NS, "path");
|
|
5042
|
+
p.setAttribute(
|
|
5043
|
+
"d",
|
|
5044
|
+
"M12 2l2.9 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l7.1-1.01L12 2z"
|
|
5045
|
+
);
|
|
5046
|
+
p.setAttribute("fill", filled ? "#f59e0b" : "#e5e7eb");
|
|
5047
|
+
svg.appendChild(p);
|
|
5048
|
+
return svg;
|
|
5049
|
+
}
|
|
5050
|
+
function stars(rating, size = 15) {
|
|
5051
|
+
const wrap = el("span", "display:inline-flex;gap:2px;vertical-align:middle;");
|
|
5038
5052
|
wrap.setAttribute("aria-label", `${rating} out of 5`);
|
|
5039
|
-
for (let i = 1; i <= 5; i++)
|
|
5040
|
-
const svg = document.createElementNS(SVG_NS, "svg");
|
|
5041
|
-
svg.setAttribute("viewBox", "0 0 24 24");
|
|
5042
|
-
svg.setAttribute("width", String(size));
|
|
5043
|
-
svg.setAttribute("height", String(size));
|
|
5044
|
-
const path = document.createElementNS(SVG_NS, "path");
|
|
5045
|
-
path.setAttribute(
|
|
5046
|
-
"d",
|
|
5047
|
-
"M12 2l2.9 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l7.1-1.01L12 2z"
|
|
5048
|
-
);
|
|
5049
|
-
path.setAttribute("fill", i <= rating ? "#f59e0b" : "#e2e8f0");
|
|
5050
|
-
svg.appendChild(path);
|
|
5051
|
-
wrap.appendChild(svg);
|
|
5052
|
-
}
|
|
5053
|
+
for (let i = 1; i <= 5; i++) wrap.appendChild(star(i <= rating, size));
|
|
5053
5054
|
return wrap;
|
|
5054
5055
|
}
|
|
5055
|
-
function
|
|
5056
|
-
const
|
|
5057
|
-
return el(
|
|
5056
|
+
function verifiedBadge() {
|
|
5057
|
+
const b = el(
|
|
5058
5058
|
"span",
|
|
5059
|
-
|
|
5060
|
-
text
|
|
5059
|
+
"display:inline-flex;align-items:center;gap:3px;font-size:12px;font-weight:600;color:#059669;"
|
|
5061
5060
|
);
|
|
5062
|
-
}
|
|
5063
|
-
function sparkles() {
|
|
5064
5061
|
const svg = document.createElementNS(SVG_NS, "svg");
|
|
5065
5062
|
svg.setAttribute("viewBox", "0 0 24 24");
|
|
5066
|
-
svg.setAttribute("width", "
|
|
5067
|
-
svg.setAttribute("height", "
|
|
5063
|
+
svg.setAttribute("width", "13");
|
|
5064
|
+
svg.setAttribute("height", "13");
|
|
5068
5065
|
const p = document.createElementNS(SVG_NS, "path");
|
|
5069
|
-
p.setAttribute("d", "
|
|
5070
|
-
p.setAttribute("fill", "
|
|
5066
|
+
p.setAttribute("d", "M9 12l2 2 4-4M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z");
|
|
5067
|
+
p.setAttribute("fill", "none");
|
|
5068
|
+
p.setAttribute("stroke", "#059669");
|
|
5069
|
+
p.setAttribute("stroke-width", "2");
|
|
5070
|
+
p.setAttribute("stroke-linecap", "round");
|
|
5071
|
+
p.setAttribute("stroke-linejoin", "round");
|
|
5071
5072
|
svg.appendChild(p);
|
|
5072
|
-
|
|
5073
|
+
b.appendChild(svg);
|
|
5074
|
+
b.appendChild(el("span", "", "Verified purchase"));
|
|
5075
|
+
return b;
|
|
5073
5076
|
}
|
|
5074
|
-
function
|
|
5077
|
+
function avatar(name, accent) {
|
|
5078
|
+
const initial = (name.trim()[0] || "?").toUpperCase();
|
|
5079
|
+
const a = el(
|
|
5080
|
+
"span",
|
|
5081
|
+
`flex:0 0 auto;width:34px;height:34px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;font-size:14px;font-weight:700;color:${accent};background:${accent}1a;`,
|
|
5082
|
+
initial
|
|
5083
|
+
);
|
|
5084
|
+
return a;
|
|
5085
|
+
}
|
|
5086
|
+
function thumbBtn(up, count, reviewId, creds) {
|
|
5087
|
+
const btn = el(
|
|
5088
|
+
"button",
|
|
5089
|
+
"display:inline-flex;align-items:center;gap:5px;font-size:13px;color:#6b7280;background:none;border:none;cursor:pointer;padding:4px 6px;border-radius:8px;font-family:inherit;"
|
|
5090
|
+
);
|
|
5075
5091
|
const svg = document.createElementNS(SVG_NS, "svg");
|
|
5076
5092
|
svg.setAttribute("viewBox", "0 0 24 24");
|
|
5077
|
-
svg.setAttribute("width", "
|
|
5078
|
-
svg.setAttribute("height", "
|
|
5093
|
+
svg.setAttribute("width", "15");
|
|
5094
|
+
svg.setAttribute("height", "15");
|
|
5095
|
+
if (!up) svg.style.cssText = "transform:rotate(180deg);";
|
|
5079
5096
|
const p = document.createElementNS(SVG_NS, "path");
|
|
5080
5097
|
p.setAttribute(
|
|
5081
5098
|
"d",
|
|
5082
|
-
"
|
|
5099
|
+
"M2 21h4V9H2v12zM23 10a2 2 0 0 0-2-2h-6.31l.95-4.57.03-.32a1.5 1.5 0 0 0-.44-1.06L14.17 1 7.59 7.59A2 2 0 0 0 7 9v10a2 2 0 0 0 2 2h9a2 2 0 0 0 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-1z"
|
|
5083
5100
|
);
|
|
5084
|
-
p.setAttribute("fill", "
|
|
5101
|
+
p.setAttribute("fill", "currentColor");
|
|
5085
5102
|
svg.appendChild(p);
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
const
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
const label = el("span", "width:26px;display:inline-flex;align-items:center;gap:2px;color:#334155;", String(r));
|
|
5095
|
-
label.appendChild(miniStar());
|
|
5096
|
-
row.appendChild(label);
|
|
5097
|
-
const track = el("div", "flex:1;height:6px;background:#f1f5f9;border-radius:999px;overflow:hidden;");
|
|
5098
|
-
track.appendChild(el("div", `width:${pct}%;height:100%;background:#f59e0b;`));
|
|
5099
|
-
row.appendChild(track);
|
|
5100
|
-
row.appendChild(el("span", "width:28px;text-align:right;", String(n)));
|
|
5101
|
-
box.appendChild(row);
|
|
5103
|
+
btn.appendChild(svg);
|
|
5104
|
+
const c = el("span", "", String(count));
|
|
5105
|
+
btn.appendChild(c);
|
|
5106
|
+
const key = `aegis_rv_voted_${reviewId}`;
|
|
5107
|
+
let voted = false;
|
|
5108
|
+
try {
|
|
5109
|
+
voted = typeof localStorage !== "undefined" && localStorage.getItem(key) != null;
|
|
5110
|
+
} catch {
|
|
5102
5111
|
}
|
|
5103
|
-
|
|
5112
|
+
if (voted) btn.style.opacity = "0.5";
|
|
5113
|
+
btn.addEventListener("mouseenter", () => {
|
|
5114
|
+
if (!voted) btn.style.color = "#111827";
|
|
5115
|
+
});
|
|
5116
|
+
btn.addEventListener("mouseleave", () => {
|
|
5117
|
+
btn.style.color = "#6b7280";
|
|
5118
|
+
});
|
|
5119
|
+
btn.addEventListener("click", () => {
|
|
5120
|
+
try {
|
|
5121
|
+
if (localStorage.getItem(key) != null) return;
|
|
5122
|
+
localStorage.setItem(key, up ? "up" : "down");
|
|
5123
|
+
} catch {
|
|
5124
|
+
}
|
|
5125
|
+
voted = true;
|
|
5126
|
+
c.textContent = String(count + 1);
|
|
5127
|
+
btn.style.opacity = "0.5";
|
|
5128
|
+
const url = new URL(`/v1/reviews/${reviewId}/helpful`, creds.apiHost);
|
|
5129
|
+
void fetch(url.toString(), {
|
|
5130
|
+
method: "POST",
|
|
5131
|
+
headers: { "X-Aegis-Write-Key": creds.writeKey, "Content-Type": "application/json" },
|
|
5132
|
+
body: JSON.stringify({ direction: up ? "up" : "down" })
|
|
5133
|
+
}).catch(() => {
|
|
5134
|
+
});
|
|
5135
|
+
});
|
|
5136
|
+
return btn;
|
|
5104
5137
|
}
|
|
5105
5138
|
function injectJsonLd(target, data, productId) {
|
|
5106
5139
|
if (!data.aggregate.count || data.aggregate.avg_rating == null) return;
|
|
@@ -5128,116 +5161,21 @@ function injectJsonLd(target, data, productId) {
|
|
|
5128
5161
|
script.textContent = JSON.stringify(ld);
|
|
5129
5162
|
target.appendChild(script);
|
|
5130
5163
|
}
|
|
5131
|
-
function thumbSvg(up) {
|
|
5132
|
-
const svg = document.createElementNS(SVG_NS, "svg");
|
|
5133
|
-
svg.setAttribute("viewBox", "0 0 24 24");
|
|
5134
|
-
svg.setAttribute("width", "14");
|
|
5135
|
-
svg.setAttribute("height", "14");
|
|
5136
|
-
if (!up) svg.style.cssText = "transform:rotate(180deg);";
|
|
5137
|
-
const p = document.createElementNS(SVG_NS, "path");
|
|
5138
|
-
p.setAttribute(
|
|
5139
|
-
"d",
|
|
5140
|
-
"M2 21h4V9H2v12zM23 10a2 2 0 0 0-2-2h-6.31l.95-4.57.03-.32a1.5 1.5 0 0 0-.44-1.06L14.17 1 7.59 7.59A2 2 0 0 0 7 9v10a2 2 0 0 0 2 2h9a2 2 0 0 0 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-1z"
|
|
5141
|
-
);
|
|
5142
|
-
p.setAttribute("fill", "currentColor");
|
|
5143
|
-
svg.appendChild(p);
|
|
5144
|
-
return svg;
|
|
5145
|
-
}
|
|
5146
|
-
function helpfulButton(reviewId, up, count, creds) {
|
|
5147
|
-
const btn = el(
|
|
5148
|
-
"button",
|
|
5149
|
-
"display:inline-flex;align-items:center;gap:4px;font-size:12px;color:#64748b;background:none;border:none;cursor:pointer;padding:2px 4px;"
|
|
5150
|
-
);
|
|
5151
|
-
btn.appendChild(thumbSvg(up));
|
|
5152
|
-
const countEl = el("span", "", String(count));
|
|
5153
|
-
btn.appendChild(countEl);
|
|
5154
|
-
const voteKey = `aegis_rv_voted_${reviewId}`;
|
|
5155
|
-
const already = (() => {
|
|
5156
|
-
try {
|
|
5157
|
-
return typeof localStorage !== "undefined" && localStorage.getItem(voteKey) != null;
|
|
5158
|
-
} catch {
|
|
5159
|
-
return false;
|
|
5160
|
-
}
|
|
5161
|
-
})();
|
|
5162
|
-
if (already) btn.style.opacity = "0.5";
|
|
5163
|
-
btn.addEventListener("click", () => {
|
|
5164
|
-
try {
|
|
5165
|
-
if (localStorage.getItem(voteKey) != null) return;
|
|
5166
|
-
localStorage.setItem(voteKey, up ? "up" : "down");
|
|
5167
|
-
} catch {
|
|
5168
|
-
}
|
|
5169
|
-
countEl.textContent = String(count + 1);
|
|
5170
|
-
btn.style.opacity = "0.5";
|
|
5171
|
-
const url = new URL(`/v1/reviews/${reviewId}/helpful`, creds.apiHost);
|
|
5172
|
-
void fetch(url.toString(), {
|
|
5173
|
-
method: "POST",
|
|
5174
|
-
headers: { "X-Aegis-Write-Key": creds.writeKey, "Content-Type": "application/json" },
|
|
5175
|
-
body: JSON.stringify({ direction: up ? "up" : "down" })
|
|
5176
|
-
}).catch(() => {
|
|
5177
|
-
});
|
|
5178
|
-
});
|
|
5179
|
-
return btn;
|
|
5180
|
-
}
|
|
5181
|
-
function reviewCard(ctx, r, creds) {
|
|
5182
|
-
var _a, _b;
|
|
5183
|
-
const li = el("li", "padding:14px 0;border-top:1px solid #e2e8f0;");
|
|
5184
|
-
const meta = el("div", "display:flex;flex-wrap:wrap;align-items:center;gap:8px;");
|
|
5185
|
-
meta.appendChild(stars(r.rating ?? 0));
|
|
5186
|
-
meta.appendChild(el("span", "font-size:14px;font-weight:600;", ((_a = r.reviewer_snapshot) == null ? void 0 : _a.name) ?? "Customer"));
|
|
5187
|
-
if (r.verified_purchase) meta.appendChild(chip("Verified purchase", "verified"));
|
|
5188
|
-
if (r.is_incentivized) meta.appendChild(chip("Reward included", "reward"));
|
|
5189
|
-
if (r.created_at) {
|
|
5190
|
-
const d = new Date(r.created_at);
|
|
5191
|
-
if (!Number.isNaN(d.getTime())) {
|
|
5192
|
-
meta.appendChild(el("span", "margin-left:auto;font-size:12px;color:#94a3b8;", d.toLocaleDateString()));
|
|
5193
|
-
}
|
|
5194
|
-
}
|
|
5195
|
-
li.appendChild(meta);
|
|
5196
|
-
if (r.review_text) {
|
|
5197
|
-
li.appendChild(el("p", "margin:6px 0 0;font-size:14px;line-height:1.5;color:#334155;", r.review_text));
|
|
5198
|
-
}
|
|
5199
|
-
if (r.media && r.media.length > 0) {
|
|
5200
|
-
const gallery = el("div", "display:flex;gap:6px;margin-top:8px;");
|
|
5201
|
-
for (const m2 of r.media.slice(0, 6)) {
|
|
5202
|
-
const safe = ctx.sanitizeUrl(m2.url);
|
|
5203
|
-
if (!safe) continue;
|
|
5204
|
-
const img = document.createElement("img");
|
|
5205
|
-
img.src = safe;
|
|
5206
|
-
img.loading = "lazy";
|
|
5207
|
-
img.alt = "";
|
|
5208
|
-
img.style.cssText = "width:56px;height:56px;object-fit:cover;border-radius:8px;";
|
|
5209
|
-
gallery.appendChild(img);
|
|
5210
|
-
}
|
|
5211
|
-
if (gallery.childElementCount) li.appendChild(gallery);
|
|
5212
|
-
}
|
|
5213
|
-
if ((_b = r.operator_reply) == null ? void 0 : _b.text) {
|
|
5214
|
-
const reply = el(
|
|
5215
|
-
"div",
|
|
5216
|
-
"margin-top:8px;padding:8px 10px;background:#f8fafc;border-radius:8px;font-size:13px;color:#475569;"
|
|
5217
|
-
);
|
|
5218
|
-
reply.appendChild(el("span", "font-weight:600;margin-right:6px;", "Reply"));
|
|
5219
|
-
reply.appendChild(el("span", "", r.operator_reply.text));
|
|
5220
|
-
li.appendChild(reply);
|
|
5221
|
-
}
|
|
5222
|
-
const votes = el("div", "display:flex;align-items:center;gap:10px;margin-top:8px;");
|
|
5223
|
-
votes.appendChild(el("span", "font-size:12px;color:#94a3b8;", "Helpful?"));
|
|
5224
|
-
votes.appendChild(helpfulButton(r.id, true, r.helpful_count ?? 0, creds));
|
|
5225
|
-
votes.appendChild(helpfulButton(r.id, false, r.not_helpful_count ?? 0, creds));
|
|
5226
|
-
li.appendChild(votes);
|
|
5227
|
-
return li;
|
|
5228
|
-
}
|
|
5229
5164
|
const SORTS = [
|
|
5230
5165
|
{ key: "recent", label: "Most recent" },
|
|
5231
5166
|
{ key: "helpful", label: "Most helpful" },
|
|
5232
5167
|
{ key: "rating", label: "Highest rated" }
|
|
5233
5168
|
];
|
|
5234
5169
|
function renderReviewsInline(ctx, target, creds) {
|
|
5235
|
-
var _a;
|
|
5236
5170
|
if (typeof document === "undefined" || !(creds == null ? void 0 : creds.apiHost) || !(creds == null ? void 0 : creds.writeKey)) return false;
|
|
5171
|
+
ensureInAppFont();
|
|
5172
|
+
const ic = ctx.campaign.interactive_config || {};
|
|
5173
|
+
const accent = ctx.sanitizeColor(ctx.campaign.background_color || "#4169e1");
|
|
5174
|
+
const brand = String(ic.brand_name || "").trim() || "The store";
|
|
5237
5175
|
const productId = target.getAttribute("data-product-id") || ctx.campaign.product_id || null;
|
|
5238
5176
|
const state = { sort: "recent", withPhotos: false };
|
|
5239
5177
|
target.innerHTML = "";
|
|
5240
|
-
target.appendChild(el("div",
|
|
5178
|
+
target.appendChild(el("div", `font-family:${IN_APP_FONT_STACK};font-size:13px;color:#9ca3af;padding:10px 0;`, "Loading reviews…"));
|
|
5241
5179
|
function buildUrl() {
|
|
5242
5180
|
const url = new URL("/v1/reviews/public", creds.apiHost);
|
|
5243
5181
|
if (productId) url.searchParams.set("product_id", productId);
|
|
@@ -5250,125 +5188,211 @@ function renderReviewsInline(ctx, target, creds) {
|
|
|
5250
5188
|
return fetch(buildUrl(), { method: "GET", headers: { "X-Aegis-Write-Key": creds.writeKey } }).then((r) => r.ok ? r.json() : null).catch(() => null);
|
|
5251
5189
|
}
|
|
5252
5190
|
let listContainer = null;
|
|
5191
|
+
function reviewCard(r) {
|
|
5192
|
+
var _a, _b, _c;
|
|
5193
|
+
const li = el("li", "padding:22px 0;border-top:1px solid #f0f1f3;");
|
|
5194
|
+
const head = el("div", "display:flex;align-items:center;gap:10px;");
|
|
5195
|
+
head.appendChild(avatar(((_a = r.reviewer_snapshot) == null ? void 0 : _a.name) ?? "Customer", accent));
|
|
5196
|
+
const idn = el("div", "display:flex;flex-direction:column;gap:2px;min-width:0;");
|
|
5197
|
+
const nameRow = el("div", "display:flex;flex-wrap:wrap;align-items:center;gap:8px;");
|
|
5198
|
+
nameRow.appendChild(el("span", "font-size:15px;font-weight:700;color:#111827;", ((_b = r.reviewer_snapshot) == null ? void 0 : _b.name) ?? "Customer"));
|
|
5199
|
+
if (r.verified_purchase) nameRow.appendChild(verifiedBadge());
|
|
5200
|
+
idn.appendChild(nameRow);
|
|
5201
|
+
idn.appendChild(stars(r.rating ?? 0, 14));
|
|
5202
|
+
head.appendChild(idn);
|
|
5203
|
+
if (r.created_at) {
|
|
5204
|
+
const d = new Date(r.created_at);
|
|
5205
|
+
if (!Number.isNaN(d.getTime())) {
|
|
5206
|
+
head.appendChild(el(
|
|
5207
|
+
"span",
|
|
5208
|
+
"margin-left:auto;font-size:12px;color:#9ca3af;white-space:nowrap;",
|
|
5209
|
+
d.toLocaleDateString(void 0, { day: "numeric", month: "short", year: "numeric" })
|
|
5210
|
+
));
|
|
5211
|
+
}
|
|
5212
|
+
}
|
|
5213
|
+
li.appendChild(head);
|
|
5214
|
+
if (r.review_text) {
|
|
5215
|
+
li.appendChild(el("p", "margin:12px 0 0;font-size:15px;line-height:1.6;color:#374151;", r.review_text));
|
|
5216
|
+
}
|
|
5217
|
+
if (r.media && r.media.length > 0) {
|
|
5218
|
+
const gallery = el("div", "display:flex;flex-wrap:wrap;gap:8px;margin-top:12px;");
|
|
5219
|
+
for (const m2 of r.media.slice(0, 6)) {
|
|
5220
|
+
const safe = ctx.sanitizeUrl(m2.url);
|
|
5221
|
+
if (!safe) continue;
|
|
5222
|
+
const img = document.createElement("img");
|
|
5223
|
+
img.src = safe;
|
|
5224
|
+
img.loading = "lazy";
|
|
5225
|
+
img.alt = "";
|
|
5226
|
+
img.style.cssText = "width:72px;height:72px;object-fit:cover;border-radius:12px;border:1px solid #f0f1f3;";
|
|
5227
|
+
gallery.appendChild(img);
|
|
5228
|
+
}
|
|
5229
|
+
if (gallery.childElementCount) li.appendChild(gallery);
|
|
5230
|
+
}
|
|
5231
|
+
const foot = el("div", "display:flex;align-items:center;gap:6px;margin-top:12px;");
|
|
5232
|
+
foot.appendChild(el("span", "font-size:13px;color:#9ca3af;margin-right:2px;", "Was this helpful?"));
|
|
5233
|
+
foot.appendChild(thumbBtn(true, r.helpful_count ?? 0, r.id, creds));
|
|
5234
|
+
foot.appendChild(thumbBtn(false, r.not_helpful_count ?? 0, r.id, creds));
|
|
5235
|
+
li.appendChild(foot);
|
|
5236
|
+
if ((_c = r.operator_reply) == null ? void 0 : _c.text) {
|
|
5237
|
+
const reply = el(
|
|
5238
|
+
"div",
|
|
5239
|
+
`margin-top:14px;margin-left:44px;border-left:3px solid ${accent};background:${accent}0d;border-radius:0 12px 12px 0;padding:12px 14px;`
|
|
5240
|
+
);
|
|
5241
|
+
const rlabel = el("div", "display:flex;align-items:center;gap:6px;margin-bottom:5px;");
|
|
5242
|
+
rlabel.appendChild(el("span", `width:7px;height:7px;border-radius:999px;background:${accent};display:inline-block;`));
|
|
5243
|
+
rlabel.appendChild(el("span", `font-size:12px;font-weight:700;color:${accent};`, brand));
|
|
5244
|
+
rlabel.appendChild(el("span", "font-size:12px;color:#9ca3af;", "· replied"));
|
|
5245
|
+
reply.appendChild(rlabel);
|
|
5246
|
+
reply.appendChild(el("p", "margin:0;font-size:14px;line-height:1.55;color:#4b5563;", r.operator_reply.text));
|
|
5247
|
+
li.appendChild(reply);
|
|
5248
|
+
}
|
|
5249
|
+
return li;
|
|
5250
|
+
}
|
|
5253
5251
|
function renderList(items) {
|
|
5254
5252
|
if (!listContainer) return;
|
|
5255
5253
|
listContainer.innerHTML = "";
|
|
5256
5254
|
if (items.length === 0) {
|
|
5257
|
-
listContainer.appendChild(el("p", "padding:
|
|
5255
|
+
listContainer.appendChild(el("p", "padding:20px 0;font-size:14px;color:#9ca3af;text-align:center;", "No reviews match this filter."));
|
|
5258
5256
|
return;
|
|
5259
5257
|
}
|
|
5260
5258
|
const ul = el("ul", "list-style:none;margin:0;padding:0;");
|
|
5261
|
-
for (const r of items) ul.appendChild(reviewCard(
|
|
5259
|
+
for (const r of items) ul.appendChild(reviewCard(r));
|
|
5262
5260
|
listContainer.appendChild(ul);
|
|
5263
5261
|
}
|
|
5264
|
-
function
|
|
5265
|
-
const
|
|
5262
|
+
function pill(label, active, onClick) {
|
|
5263
|
+
const b = el(
|
|
5264
|
+
"button",
|
|
5265
|
+
`font-size:13px;font-weight:600;padding:7px 16px;border-radius:999px;cursor:pointer;font-family:inherit;` + (active ? `background:${accent};color:#fff;border:1px solid ${accent};` : "background:#fff;color:#374151;border:1px solid #e5e7eb;"),
|
|
5266
|
+
label
|
|
5267
|
+
);
|
|
5268
|
+
b.addEventListener("click", onClick);
|
|
5269
|
+
return b;
|
|
5270
|
+
}
|
|
5271
|
+
function controls(rerender) {
|
|
5272
|
+
const bar = el("div", "display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:18px 0 4px;");
|
|
5266
5273
|
const sel = document.createElement("select");
|
|
5267
|
-
sel.style.cssText =
|
|
5274
|
+
sel.style.cssText = `font-size:13px;font-weight:600;padding:7px 30px 7px 14px;border:1px solid #e5e7eb;border-radius:999px;background:#fff;color:#374151;cursor:pointer;font-family:inherit;appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center;`;
|
|
5268
5275
|
for (const s of SORTS) {
|
|
5269
|
-
const
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
sel.appendChild(
|
|
5276
|
+
const o = document.createElement("option");
|
|
5277
|
+
o.value = s.key;
|
|
5278
|
+
o.textContent = s.label;
|
|
5279
|
+
sel.appendChild(o);
|
|
5273
5280
|
}
|
|
5274
5281
|
sel.value = state.sort;
|
|
5275
5282
|
sel.addEventListener("change", () => {
|
|
5276
5283
|
state.sort = sel.value;
|
|
5277
|
-
|
|
5284
|
+
rerender();
|
|
5278
5285
|
});
|
|
5279
5286
|
bar.appendChild(sel);
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
"font-size:13px;padding:4px 12px;border:1px solid #e2e8f0;border-radius:999px;background:#fff;color:#334155;cursor:pointer;",
|
|
5283
|
-
"With photos"
|
|
5284
|
-
);
|
|
5285
|
-
photos.addEventListener("click", () => {
|
|
5287
|
+
let photosBtn = null;
|
|
5288
|
+
photosBtn = pill("With photos", state.withPhotos, () => {
|
|
5286
5289
|
state.withPhotos = !state.withPhotos;
|
|
5287
|
-
|
|
5288
|
-
|
|
5290
|
+
if (photosBtn) {
|
|
5291
|
+
photosBtn.style.cssText = `font-size:13px;font-weight:600;padding:7px 16px;border-radius:999px;cursor:pointer;font-family:inherit;` + (state.withPhotos ? `background:${accent};color:#fff;border:1px solid ${accent};` : "background:#fff;color:#374151;border:1px solid #e5e7eb;");
|
|
5292
|
+
}
|
|
5293
|
+
rerender();
|
|
5289
5294
|
});
|
|
5290
|
-
bar.appendChild(
|
|
5295
|
+
bar.appendChild(photosBtn);
|
|
5291
5296
|
return bar;
|
|
5292
5297
|
}
|
|
5298
|
+
function distributionPanel(dist, total) {
|
|
5299
|
+
const box = el("div", "flex:1 1 260px;max-width:340px;display:flex;flex-direction:column;gap:7px;");
|
|
5300
|
+
for (let r = 5; r >= 1; r--) {
|
|
5301
|
+
const n = dist[String(r)] ?? 0;
|
|
5302
|
+
const pct = total > 0 ? Math.round(n / total * 100) : 0;
|
|
5303
|
+
const row = el("div", "display:flex;align-items:center;gap:10px;font-size:13px;color:#6b7280;");
|
|
5304
|
+
const lbl = el("span", "width:30px;display:inline-flex;align-items:center;gap:3px;color:#374151;font-weight:600;", String(r));
|
|
5305
|
+
lbl.appendChild(star(true, 11));
|
|
5306
|
+
row.appendChild(lbl);
|
|
5307
|
+
const track = el("div", "flex:1;height:8px;background:#f0f1f3;border-radius:999px;overflow:hidden;");
|
|
5308
|
+
track.appendChild(el("div", `width:${pct}%;height:100%;background:${accent};border-radius:999px;`));
|
|
5309
|
+
row.appendChild(track);
|
|
5310
|
+
row.appendChild(el("span", "width:24px;text-align:right;font-variant-numeric:tabular-nums;", String(n)));
|
|
5311
|
+
box.appendChild(row);
|
|
5312
|
+
}
|
|
5313
|
+
return box;
|
|
5314
|
+
}
|
|
5315
|
+
function aiSummaryCard(summary) {
|
|
5316
|
+
const card = el(
|
|
5317
|
+
"div",
|
|
5318
|
+
"position:relative;border-radius:18px;padding:18px 20px;margin-bottom:24px;background:linear-gradient(135deg,#faf5ff 0%,#f5f3ff 100%);border:1px solid #ede9fe;"
|
|
5319
|
+
);
|
|
5320
|
+
const head = el("div", "display:flex;align-items:center;justify-content:space-between;margin-bottom:8px;");
|
|
5321
|
+
const left = el("div", "display:flex;align-items:center;gap:7px;");
|
|
5322
|
+
const sp = document.createElementNS(SVG_NS, "svg");
|
|
5323
|
+
sp.setAttribute("viewBox", "0 0 24 24");
|
|
5324
|
+
sp.setAttribute("width", "16");
|
|
5325
|
+
sp.setAttribute("height", "16");
|
|
5326
|
+
const spp = document.createElementNS(SVG_NS, "path");
|
|
5327
|
+
spp.setAttribute("d", "M12 3l1.6 4.4L18 9l-4.4 1.6L12 15l-1.6-4.4L6 9l4.4-1.6L12 3z");
|
|
5328
|
+
spp.setAttribute("fill", "#7c3aed");
|
|
5329
|
+
sp.appendChild(spp);
|
|
5330
|
+
left.appendChild(sp);
|
|
5331
|
+
left.appendChild(el("span", "font-size:12px;font-weight:800;letter-spacing:.07em;color:#6d28d9;text-transform:uppercase;", "What customers say"));
|
|
5332
|
+
head.appendChild(left);
|
|
5333
|
+
head.appendChild(el("span", "font-size:11px;font-weight:600;color:#a78bda;", "AI-generated"));
|
|
5334
|
+
card.appendChild(head);
|
|
5335
|
+
card.appendChild(el("p", "margin:0;font-size:15px;line-height:1.6;color:#3b2a63;", summary.text));
|
|
5336
|
+
card.appendChild(el("p", "margin:8px 0 0;font-size:12px;color:#a78bda;text-align:right;", `from ${summary.review_count} reviews`));
|
|
5337
|
+
return card;
|
|
5338
|
+
}
|
|
5293
5339
|
function renderWall(data) {
|
|
5294
5340
|
target.innerHTML = "";
|
|
5295
5341
|
const root = el(
|
|
5296
5342
|
"section",
|
|
5297
|
-
|
|
5343
|
+
`font-family:${IN_APP_FONT_STACK};color:#111827;max-width:860px;margin:0 auto;-webkit-font-smoothing:antialiased;`
|
|
5298
5344
|
);
|
|
5299
5345
|
root.setAttribute("data-aegis-reviews", "true");
|
|
5300
5346
|
const summary = data.aggregate.ai_summary;
|
|
5301
|
-
if (summary && summary.text)
|
|
5302
|
-
const card = el(
|
|
5303
|
-
"div",
|
|
5304
|
-
"border:1px solid #ede9fe;background:#faf5ff;border-radius:12px;padding:12px 14px;margin-bottom:14px;"
|
|
5305
|
-
);
|
|
5306
|
-
const h = el("div", "display:flex;align-items:center;gap:6px;margin-bottom:6px;");
|
|
5307
|
-
h.appendChild(sparkles());
|
|
5308
|
-
h.appendChild(el("span", "font-size:12px;font-weight:700;color:#7c3aed;text-transform:uppercase;letter-spacing:.04em;", "AI summary"));
|
|
5309
|
-
card.appendChild(h);
|
|
5310
|
-
card.appendChild(el("p", "margin:0;font-size:14px;line-height:1.5;color:#334155;", summary.text));
|
|
5311
|
-
card.appendChild(
|
|
5312
|
-
el("p", "margin:6px 0 0;font-size:11px;color:#a78bda;text-align:right;", `summarized from ${summary.review_count} reviews`)
|
|
5313
|
-
);
|
|
5314
|
-
root.appendChild(card);
|
|
5315
|
-
}
|
|
5316
|
-
const head = el("div", "display:flex;align-items:center;gap:8px;");
|
|
5317
|
-
const avg = data.aggregate.avg_rating ?? 0;
|
|
5318
|
-
head.appendChild(stars(Math.round(avg), 18));
|
|
5319
|
-
head.appendChild(el("span", "font-size:20px;font-weight:700;", avg ? avg.toFixed(1) : "—"));
|
|
5320
|
-
head.appendChild(
|
|
5321
|
-
el("span", "font-size:13px;color:#64748b;", `${data.aggregate.count} review${data.aggregate.count === 1 ? "" : "s"}`)
|
|
5322
|
-
);
|
|
5323
|
-
root.appendChild(head);
|
|
5347
|
+
if (summary && summary.text) root.appendChild(aiSummaryCard(summary));
|
|
5324
5348
|
if (data.aggregate.count === 0) {
|
|
5325
|
-
root.appendChild(el("p", "
|
|
5349
|
+
root.appendChild(el("p", "font-size:15px;color:#9ca3af;padding:6px 0;", "No reviews yet — be the first to share your experience."));
|
|
5326
5350
|
target.appendChild(root);
|
|
5327
5351
|
return;
|
|
5328
5352
|
}
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
);
|
|
5335
|
-
|
|
5353
|
+
const header = el("div", "display:flex;flex-wrap:wrap;align-items:center;gap:24px 40px;padding-bottom:4px;");
|
|
5354
|
+
const ratingBlock = el("div", "display:flex;flex-direction:column;gap:4px;");
|
|
5355
|
+
const topRow = el("div", "display:flex;align-items:center;gap:12px;");
|
|
5356
|
+
const avg = data.aggregate.avg_rating ?? 0;
|
|
5357
|
+
topRow.appendChild(stars(Math.round(avg), 20));
|
|
5358
|
+
topRow.appendChild(el("span", "font-size:32px;font-weight:800;line-height:1;letter-spacing:-0.02em;", avg ? avg.toFixed(1) : "—"));
|
|
5359
|
+
ratingBlock.appendChild(topRow);
|
|
5360
|
+
ratingBlock.appendChild(el("span", "font-size:13px;color:#6b7280;", `${data.aggregate.count} review${data.aggregate.count === 1 ? "" : "s"} · 100% verified`));
|
|
5361
|
+
header.appendChild(ratingBlock);
|
|
5362
|
+
header.appendChild(distributionPanel(data.aggregate.distribution, data.aggregate.count));
|
|
5363
|
+
root.appendChild(header);
|
|
5364
|
+
root.appendChild(controls(() => {
|
|
5365
|
+
void fetchReviews().then((d) => renderList((d == null ? void 0 : d.items) ?? []));
|
|
5366
|
+
}));
|
|
5367
|
+
listContainer = el("div", "margin-top:2px;");
|
|
5336
5368
|
root.appendChild(listContainer);
|
|
5337
5369
|
renderList(data.items);
|
|
5338
5370
|
target.appendChild(root);
|
|
5339
5371
|
injectJsonLd(target, data, productId);
|
|
5340
5372
|
ctx.trackEvent(ctx.campaign.id, "impression");
|
|
5341
5373
|
}
|
|
5342
|
-
const
|
|
5343
|
-
const compact = displayStyle === "compact";
|
|
5374
|
+
const compact = ic.display_style === "compact";
|
|
5344
5375
|
function renderCompact(data) {
|
|
5345
|
-
var
|
|
5376
|
+
var _a;
|
|
5346
5377
|
target.innerHTML = "";
|
|
5347
5378
|
if (data.aggregate.count === 0) return;
|
|
5348
5379
|
const root = el(
|
|
5349
5380
|
"section",
|
|
5350
|
-
|
|
5381
|
+
`font-family:${IN_APP_FONT_STACK};color:#111827;max-width:860px;margin:0 auto;border:1px solid #f0f1f3;border-radius:16px;padding:16px 18px;`
|
|
5351
5382
|
);
|
|
5352
5383
|
const line = el("div", "display:flex;align-items:center;gap:8px;");
|
|
5353
5384
|
const avg = data.aggregate.avg_rating ?? 0;
|
|
5354
5385
|
line.appendChild(stars(Math.round(avg), 16));
|
|
5355
|
-
line.appendChild(el("span", "font-size:
|
|
5356
|
-
line.appendChild(el("span", "font-size:13px;color:#
|
|
5357
|
-
line.appendChild(
|
|
5386
|
+
line.appendChild(el("span", "font-size:16px;font-weight:700;", avg ? avg.toFixed(1) : "—"));
|
|
5387
|
+
line.appendChild(el("span", "font-size:13px;color:#6b7280;", `(${data.aggregate.count})`));
|
|
5388
|
+
line.appendChild(verifiedBadge());
|
|
5358
5389
|
root.appendChild(line);
|
|
5359
5390
|
const top = data.items.find((i) => i.review_text);
|
|
5360
5391
|
if (top && top.review_text) {
|
|
5361
|
-
|
|
5362
|
-
root.appendChild(
|
|
5363
|
-
root.appendChild(
|
|
5364
|
-
el("span", "font-size:12px;color:#94a3b8;", `— ${((_a2 = top.reviewer_snapshot) == null ? void 0 : _a2.name) ?? "Customer"}`)
|
|
5365
|
-
);
|
|
5392
|
+
root.appendChild(el("p", "margin:10px 0 0;font-size:15px;color:#374151;line-height:1.5;", `“${top.review_text}”`));
|
|
5393
|
+
root.appendChild(el("span", "font-size:13px;color:#9ca3af;", `— ${((_a = top.reviewer_snapshot) == null ? void 0 : _a.name) ?? "Customer"}`));
|
|
5366
5394
|
}
|
|
5367
|
-
const seeAll = el(
|
|
5368
|
-
"button",
|
|
5369
|
-
"margin-top:10px;font-size:13px;font-weight:600;color:#4169e1;background:none;border:none;cursor:pointer;padding:0;",
|
|
5370
|
-
"See all reviews"
|
|
5371
|
-
);
|
|
5395
|
+
const seeAll = el("button", `margin-top:12px;font-size:14px;font-weight:700;color:${accent};background:none;border:none;cursor:pointer;padding:0;font-family:inherit;`, "See all reviews →");
|
|
5372
5396
|
seeAll.addEventListener("click", () => renderWall(data));
|
|
5373
5397
|
root.appendChild(seeAll);
|
|
5374
5398
|
target.appendChild(root);
|
|
@@ -5386,27 +5410,27 @@ function renderReviewsInline(ctx, target, creds) {
|
|
|
5386
5410
|
}
|
|
5387
5411
|
function renderReviewsOverlay(ctx, creds) {
|
|
5388
5412
|
if (typeof document === "undefined" || !(creds == null ? void 0 : creds.apiHost) || !(creds == null ? void 0 : creds.writeKey)) return;
|
|
5413
|
+
ensureInAppFont();
|
|
5389
5414
|
const overlay = document.createElement("div");
|
|
5390
5415
|
overlay.setAttribute("data-campaign-id", ctx.campaign.id);
|
|
5391
|
-
overlay.style.cssText = "position:fixed;inset:0;background:rgba(
|
|
5416
|
+
overlay.style.cssText = "position:fixed;inset:0;background:rgba(17,24,39,0.5);display:flex;align-items:flex-end;justify-content:center;z-index:99999;";
|
|
5392
5417
|
const sheet = document.createElement("div");
|
|
5393
|
-
sheet.style.cssText =
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
const
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
xsvg.setAttribute("height", "18");
|
|
5418
|
+
sheet.style.cssText = `background:#fff;color:#111827;max-width:680px;width:100%;max-height:84vh;overflow-y:auto;border-radius:24px 24px 0 0;padding:18px 18px 28px;font-family:${IN_APP_FONT_STACK};box-shadow:0 -16px 40px rgba(0,0,0,0.14);`;
|
|
5419
|
+
sheet.appendChild(el("div", "width:38px;height:4px;border-radius:999px;background:#e5e7eb;margin:0 auto 14px;"));
|
|
5420
|
+
const bar = el("div", "display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;");
|
|
5421
|
+
bar.appendChild(el("div", "font-weight:800;font-size:17px;", ctx.campaign.title || "Customer reviews"));
|
|
5422
|
+
const close = el("button", "background:none;border:none;cursor:pointer;padding:4px 8px;color:#6b7280;");
|
|
5423
|
+
const x = document.createElementNS(SVG_NS, "svg");
|
|
5424
|
+
x.setAttribute("viewBox", "0 0 24 24");
|
|
5425
|
+
x.setAttribute("width", "20");
|
|
5426
|
+
x.setAttribute("height", "20");
|
|
5403
5427
|
const xp = document.createElementNS(SVG_NS, "path");
|
|
5404
5428
|
xp.setAttribute("d", "M18 6L6 18M6 6l12 12");
|
|
5405
5429
|
xp.setAttribute("stroke", "currentColor");
|
|
5406
5430
|
xp.setAttribute("stroke-width", "2");
|
|
5407
5431
|
xp.setAttribute("stroke-linecap", "round");
|
|
5408
|
-
|
|
5409
|
-
close.appendChild(
|
|
5432
|
+
x.appendChild(xp);
|
|
5433
|
+
close.appendChild(x);
|
|
5410
5434
|
close.setAttribute("aria-label", "Close");
|
|
5411
5435
|
close.addEventListener("click", () => {
|
|
5412
5436
|
ctx.trackEvent(ctx.campaign.id, "dismissed");
|
|
@@ -6677,10 +6701,10 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
6677
6701
|
cbody.appendChild(b);
|
|
6678
6702
|
}
|
|
6679
6703
|
if (couponCode) {
|
|
6680
|
-
const
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
cbody.appendChild(
|
|
6704
|
+
const chip = document.createElement("span");
|
|
6705
|
+
chip.style.cssText = `align-self: flex-start; border: 1px dashed ${text}66; border-radius: 6px; padding: 2px 8px; font-family: monospace; font-size: 11px; letter-spacing: 0.04em;`;
|
|
6706
|
+
chip.textContent = couponCode;
|
|
6707
|
+
cbody.appendChild(chip);
|
|
6684
6708
|
}
|
|
6685
6709
|
if (buttonText) {
|
|
6686
6710
|
const btn = document.createElement("button");
|
|
@@ -7263,19 +7287,19 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
7263
7287
|
ov.appendChild(eyebrow);
|
|
7264
7288
|
ov.appendChild(big);
|
|
7265
7289
|
if (r.code) {
|
|
7266
|
-
const
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7290
|
+
const chip = document.createElement("button");
|
|
7291
|
+
chip.type = "button";
|
|
7292
|
+
chip.textContent = `${r.code} ⧉`;
|
|
7293
|
+
chip.style.cssText = `margin-top: 4px; padding: 9px 16px; border-radius: 999px; border: 1.5px dashed ${text}66; background: transparent; color: ${text}; font-weight: 800; font-size: 14px; letter-spacing: 1px; cursor: pointer;`;
|
|
7294
|
+
chip.addEventListener("click", () => {
|
|
7271
7295
|
var _a;
|
|
7272
7296
|
try {
|
|
7273
7297
|
void ((_a = navigator.clipboard) == null ? void 0 : _a.writeText(r.code));
|
|
7274
|
-
|
|
7298
|
+
chip.textContent = "Copied";
|
|
7275
7299
|
} catch {
|
|
7276
7300
|
}
|
|
7277
7301
|
});
|
|
7278
|
-
ov.appendChild(
|
|
7302
|
+
ov.appendChild(chip);
|
|
7279
7303
|
} else if (r.kind === "freebie") {
|
|
7280
7304
|
const hint = document.createElement("div");
|
|
7281
7305
|
hint.textContent = "🎟️ Show this screen to claim";
|
|
@@ -7309,20 +7333,20 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
7309
7333
|
result.textContent = "";
|
|
7310
7334
|
const tag = document.createElement("span");
|
|
7311
7335
|
tag.textContent = `${r.label} — `;
|
|
7312
|
-
const
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7336
|
+
const chip = document.createElement("button");
|
|
7337
|
+
chip.type = "button";
|
|
7338
|
+
chip.textContent = `${r.code} ⧉`;
|
|
7339
|
+
chip.style.cssText = `padding: 2px 8px; border-radius: 999px; border: 1.5px dashed ${text}66; background: transparent; color: ${text}; font-weight: 800; font-size: 12px; letter-spacing: 0.5px; cursor: pointer;`;
|
|
7340
|
+
chip.addEventListener("click", () => {
|
|
7317
7341
|
var _a;
|
|
7318
7342
|
try {
|
|
7319
7343
|
void ((_a = navigator.clipboard) == null ? void 0 : _a.writeText(r.code));
|
|
7320
|
-
|
|
7344
|
+
chip.textContent = "Copied";
|
|
7321
7345
|
} catch {
|
|
7322
7346
|
}
|
|
7323
7347
|
});
|
|
7324
7348
|
result.appendChild(tag);
|
|
7325
|
-
result.appendChild(
|
|
7349
|
+
result.appendChild(chip);
|
|
7326
7350
|
} else result.textContent = r.label || "Thanks for playing!";
|
|
7327
7351
|
retireCta();
|
|
7328
7352
|
};
|
|
@@ -7974,19 +7998,19 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
7974
7998
|
ov.appendChild(eb);
|
|
7975
7999
|
ov.appendChild(big);
|
|
7976
8000
|
if (code) {
|
|
7977
|
-
const
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
8001
|
+
const chip = document.createElement("button");
|
|
8002
|
+
chip.type = "button";
|
|
8003
|
+
chip.textContent = `${code} ⧉`;
|
|
8004
|
+
chip.style.cssText = `margin-top: 4px; padding: 8px 14px; border-radius: 999px; border: 1.5px dashed ${text}66; background: transparent; color: ${text}; font-weight: 800; font-size: 13px; letter-spacing: 1px; cursor: pointer;`;
|
|
8005
|
+
chip.addEventListener("click", () => {
|
|
7982
8006
|
var _a;
|
|
7983
8007
|
try {
|
|
7984
8008
|
void ((_a = navigator.clipboard) == null ? void 0 : _a.writeText(code));
|
|
7985
|
-
|
|
8009
|
+
chip.textContent = "Copied";
|
|
7986
8010
|
} catch {
|
|
7987
8011
|
}
|
|
7988
8012
|
});
|
|
7989
|
-
ov.appendChild(
|
|
8013
|
+
ov.appendChild(chip);
|
|
7990
8014
|
}
|
|
7991
8015
|
card.appendChild(ov);
|
|
7992
8016
|
try {
|
|
@@ -7996,10 +8020,10 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
7996
8020
|
} else {
|
|
7997
8021
|
prizeText.textContent = icoVal && !isUrl(icoVal) ? `${icoVal} ${label}` : label;
|
|
7998
8022
|
if (code) {
|
|
7999
|
-
const
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
body.appendChild(
|
|
8023
|
+
const chip = document.createElement("div");
|
|
8024
|
+
chip.style.cssText = `margin-top: 6px; font-family: ui-monospace, monospace; font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 6px; background: ${text}14; color: ${text};`;
|
|
8025
|
+
chip.textContent = code;
|
|
8026
|
+
body.appendChild(chip);
|
|
8003
8027
|
}
|
|
8004
8028
|
this._playReaction(body, "celebrate", "gift.json", ic);
|
|
8005
8029
|
}
|