@aikaara/chat-sdk 1.4.34 → 1.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/{AikaaraLinkButton-Cxbk_vrf.mjs → AikaaraLinkButton-CnvirM17.mjs} +1 -1
- package/dist/{AikaaraLinkButton-BdjjiK9B.cjs → AikaaraLinkButton-DFT_nAv9.cjs} +1 -1
- package/dist/AikaaraPaymentLink-CL4O6gbc.mjs +263 -0
- package/dist/AikaaraPaymentLink-D_SZ081m.cjs +1 -0
- package/dist/{MountTenant-C7jZ30qM.mjs → MountTenant-YqTsrEgP.mjs} +2 -2
- package/dist/{MountTenant-CnfYUT2t.cjs → MountTenant-wJ3Clo04.cjs} +2 -2
- package/dist/cdn/aikaara-chat.iife.js +55 -55
- package/dist/headless.cjs +1 -1
- package/dist/headless.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/ui.cjs +1 -1
- package/dist/ui.mjs +1 -1
- package/package.json +1 -1
- package/dist/AikaaraPaymentLink-C-GhGZ4c.cjs +0 -1
- package/dist/AikaaraPaymentLink-C82ApGKH.mjs +0 -155
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./MountTenant-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./MountTenant-wJ3Clo04.cjs");class l extends HTMLElement{shadow;payload=null;constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.render()}setPayload(e){this.payload=e,this.render()}render(){const e=this.payload;this.shadow.innerHTML=`
|
|
2
2
|
<style>
|
|
3
3
|
:host { display: block; margin-top: 8px; }
|
|
4
4
|
button {
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
const k = "https://checkout.razorpay.com/v1/checkout.js";
|
|
2
|
+
let m = null;
|
|
3
|
+
function y() {
|
|
4
|
+
return window;
|
|
5
|
+
}
|
|
6
|
+
class w extends HTMLElement {
|
|
7
|
+
shadow;
|
|
8
|
+
payloadData = [];
|
|
9
|
+
message = "";
|
|
10
|
+
// Per-payload-index lock so a successful payment disables only that
|
|
11
|
+
// button (other rows in the same template remain clickable).
|
|
12
|
+
paidIdx = {};
|
|
13
|
+
constructor() {
|
|
14
|
+
super(), this.shadow = this.attachShadow({ mode: "open" });
|
|
15
|
+
}
|
|
16
|
+
setPayload(t, n) {
|
|
17
|
+
this.payloadData = Array.isArray(t) ? t : [], this.message = n ?? "", this.render();
|
|
18
|
+
}
|
|
19
|
+
render() {
|
|
20
|
+
const t = this.payloadData.filter(
|
|
21
|
+
(e) => !!e && typeof e == "object" && e.type === "link" && typeof e.url == "string"
|
|
22
|
+
), n = t.map((e, s) => {
|
|
23
|
+
const o = e.name || "Open link", r = !!this.paidIdx[s];
|
|
24
|
+
return `<button class="link${r ? " paid" : ""}" data-i="${s}" type="button"${r ? " disabled" : ""}><span class="lbl">${g(r ? "Paid" : o)}</span>` + (r ? '<svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 8.5 L7 12 L13 5"/></svg>' : '<svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M5 11 L11 5 M6 5 H11 V10"/></svg>') + "</button>";
|
|
25
|
+
}).join("");
|
|
26
|
+
this.shadow.innerHTML = "<style>:host { display:block; margin:6px 0; font-family:inherit; }.bubble { padding:12px 16px; border-radius:14px; background:var(--aikaara-bot-bubble-bg, #d8e5f5); color:var(--aikaara-bot-bubble-text, #1a2845); font-size:14px; line-height:1.55; margin-bottom:10px; }.links { display:flex; flex-direction:column; gap:8px; }.link { display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:11px 22px; border:1.5px solid var(--aikaara-primary, #1849a9); background:var(--aikaara-primary, #1849a9); color:var(--aikaara-primary-contrast, #fff); border-radius:24px; font-size:14px; font-weight:600; cursor:pointer; font-family:inherit; text-decoration:none; transition: filter 120ms; width:150px; align-self:flex-start; }.link:hover:not(:disabled) { filter: brightness(0.94); }.link.paid, .link:disabled { background:#e7f5ec; color:#0e7c3a; border-color:#0e7c3a; cursor:default; }.icon { width:13px; height:13px; }</style>" + (this.message ? `<div class="bubble">${this.message}</div>` : "") + `<div class="links">${n}</div>`, this.shadow.querySelectorAll(".link").forEach((e) => {
|
|
27
|
+
e.addEventListener("click", () => {
|
|
28
|
+
if (e.disabled) return;
|
|
29
|
+
const s = Number(e.dataset.i || 0), o = t[s];
|
|
30
|
+
o && this.handleClick(s, o);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
handleClick(t, n) {
|
|
35
|
+
const e = b(n), s = y().__aikaara_descriptor__, o = s?.partnerPayment, r = s?.razorpay;
|
|
36
|
+
if (e && o?.paymentLinkUrl) {
|
|
37
|
+
this.openPartnerPaymentLink(t, e, n, o);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!e || !r?.keyId) {
|
|
41
|
+
I(n.url, n.name || "Pay"), this.dispatchEvent(
|
|
42
|
+
new CustomEvent("template-action", {
|
|
43
|
+
detail: {
|
|
44
|
+
text: n.name || "link-click",
|
|
45
|
+
attributes: {
|
|
46
|
+
action: { type: "link", url: n.url, orderId: e || n.orderId, openedIn: "modal" }
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
bubbles: !0,
|
|
50
|
+
composed: !0
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
_(r.preferredBanksUrl, e, r.preferredBanksMethod, r.preferredBanksHeaders).catch((c) => (console.warn("[payment_link] preferred-banks fetch failed; continuing with default UI", c), [])).then((c) => P().then(() => this.openRazorpay(t, e, r, c))).catch((c) => {
|
|
56
|
+
console.error("[payment_link] Razorpay launch failed", c);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
openPartnerPaymentLink(t, n, e, s) {
|
|
60
|
+
v(n, s).then((o) => {
|
|
61
|
+
if (!o) {
|
|
62
|
+
f("Failed to generate payment link, please try again later");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const r = (o.paymentStatus ?? "").toLowerCase();
|
|
66
|
+
if (r === "paid" || r === "success" || r === "completed") {
|
|
67
|
+
this.paidIdx[t] = !0, this.render(), f("Payment already completed");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const c = o.vendorPaymentLink;
|
|
71
|
+
if (!c) {
|
|
72
|
+
f("Failed to generate payment link, please try again later");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const l = navigator.userAgent.toLowerCase();
|
|
76
|
+
if (l.includes("iphone") || l.includes("ipad") || l.includes("ipod")) {
|
|
77
|
+
window.location.href = c;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const d = x(c);
|
|
81
|
+
if (!d) {
|
|
82
|
+
window.open(c, "_blank"), f("Allow popups for the best payment experience");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.dispatchEvent(
|
|
86
|
+
new CustomEvent("template-action", {
|
|
87
|
+
detail: {
|
|
88
|
+
text: e.name || "link-click",
|
|
89
|
+
attributes: {
|
|
90
|
+
action: { type: "partner-payment", url: c, orderId: n, openedIn: "popup" }
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
bubbles: !0,
|
|
94
|
+
composed: !0
|
|
95
|
+
})
|
|
96
|
+
), C(d, s.checkoutOrigin, {
|
|
97
|
+
onSuccess: () => {
|
|
98
|
+
this.paidIdx[t] = !0, this.render();
|
|
99
|
+
},
|
|
100
|
+
onError: (p) => {
|
|
101
|
+
f(p || "Payment failed, please try again");
|
|
102
|
+
},
|
|
103
|
+
onClose: () => {
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}).catch((o) => {
|
|
107
|
+
console.error("[payment_link] partner payment link fetch failed", o), f("Failed to generate payment link, please try again later");
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
openRazorpay(t, n, e, s) {
|
|
111
|
+
const o = y(), r = o.__aikaara_runtime__?.identity ?? {}, c = {
|
|
112
|
+
key: e.keyId,
|
|
113
|
+
order_id: n,
|
|
114
|
+
name: e.name || o.__aikaara_descriptor__?.title || "Payment",
|
|
115
|
+
prefill: {},
|
|
116
|
+
handler: () => {
|
|
117
|
+
this.paidIdx[t] = !0, this.render();
|
|
118
|
+
},
|
|
119
|
+
modal: {
|
|
120
|
+
// No auto-hide on dismiss: user can re-click Pay Now. Per spec,
|
|
121
|
+
// button only locks on confirmed success.
|
|
122
|
+
ondismiss: () => {
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
typeof r.mobile == "string" ? c.prefill.contact = r.mobile : typeof r.phone == "string" && (c.prefill.contact = r.phone), typeof r.email == "string" && (c.prefill.email = r.email), typeof r.name == "string" ? c.prefill.name = r.name : typeof r.userName == "string" && (c.prefill.name = r.userName), Array.isArray(s) && s.length && (c.config = {
|
|
127
|
+
display: {
|
|
128
|
+
blocks: {
|
|
129
|
+
utib: {
|
|
130
|
+
name: "Pay Using Preferred Netbanking",
|
|
131
|
+
instruments: [{ method: "netbanking", banks: s }]
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
sequence: ["block.utib", "netbanking", "card", "upi"],
|
|
135
|
+
preferences: { show_default_blocks: !0 }
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
const l = o.Razorpay;
|
|
139
|
+
if (typeof l != "function")
|
|
140
|
+
throw new Error("Razorpay Checkout script not available");
|
|
141
|
+
const i = new l(c);
|
|
142
|
+
i.on("payment.failed", (d) => {
|
|
143
|
+
console.warn("[payment_link] payment.failed", d?.error);
|
|
144
|
+
}), i.open();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function g(a) {
|
|
148
|
+
return String(a ?? "").replace(/[&<>]/g, (t) => t === "&" ? "&" : t === "<" ? "<" : ">");
|
|
149
|
+
}
|
|
150
|
+
function b(a) {
|
|
151
|
+
if (typeof a.orderId == "string" && a.orderId) return a.orderId;
|
|
152
|
+
try {
|
|
153
|
+
const t = new URL(a.url, window.location.origin), n = t.searchParams.get("orderId") || t.searchParams.get("order_id");
|
|
154
|
+
if (n) return n;
|
|
155
|
+
if (t.hash && t.hash.length > 1) {
|
|
156
|
+
const e = new URLSearchParams(t.hash.replace(/^#/, "")), s = e.get("orderId") || e.get("order_id");
|
|
157
|
+
if (s) return s;
|
|
158
|
+
}
|
|
159
|
+
} catch {
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
function P() {
|
|
164
|
+
return typeof y().Razorpay == "function" ? Promise.resolve() : m || (m = new Promise((a, t) => {
|
|
165
|
+
const n = document.querySelector('script[data-aikaara-razorpay="1"]');
|
|
166
|
+
if (n) {
|
|
167
|
+
n.addEventListener("load", () => a()), n.addEventListener("error", () => t(new Error("checkout.js failed to load")));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const e = document.createElement("script");
|
|
171
|
+
e.src = k, e.async = !0, e.dataset.aikaaraRazorpay = "1", e.onload = () => a(), e.onerror = () => {
|
|
172
|
+
m = null, t(new Error("checkout.js failed to load"));
|
|
173
|
+
}, document.head.appendChild(e);
|
|
174
|
+
}), m);
|
|
175
|
+
}
|
|
176
|
+
function _(a, t, n, e) {
|
|
177
|
+
if (!a) return Promise.resolve([]);
|
|
178
|
+
const s = String(n || "GET").toUpperCase() === "POST" ? "POST" : "GET", o = a.includes("{orderId}") ? a.replace("{orderId}", encodeURIComponent(t)) : a + (a.includes("?") ? "&" : "?") + "orderId=" + encodeURIComponent(t), r = y().__aikaara_runtime__ ?? {};
|
|
179
|
+
return (typeof r.getSessionToken == "function" ? r.getSessionToken() : typeof r.getChatJwt == "function" ? r.getChatJwt() : Promise.resolve(null)).then((l) => {
|
|
180
|
+
const i = { Accept: "application/json", ...e ?? {} };
|
|
181
|
+
l && (i.Authorization = `Bearer ${l}`);
|
|
182
|
+
const d = { method: s, headers: i, credentials: "omit" };
|
|
183
|
+
return s === "POST" && (i["Content-Type"] = "application/json", d.body = JSON.stringify({ orderId: t })), fetch(o, d);
|
|
184
|
+
}).then((l) => {
|
|
185
|
+
if (!l.ok) throw new Error(`preferred-banks ${l.status}`);
|
|
186
|
+
return l.json();
|
|
187
|
+
}).then((l) => {
|
|
188
|
+
const i = l, d = i?.data && typeof i.data == "object" && !Array.isArray(i.data) ? i.data : null;
|
|
189
|
+
return (Array.isArray(l) ? l : Array.isArray(i?.banks) ? i.banks : Array.isArray(i?.data) ? i.data : Array.isArray(d?.preferredPaymentBank) ? d.preferredPaymentBank : Array.isArray(d?.banks) ? d.banks : []).map((u) => {
|
|
190
|
+
if (typeof u == "string") return u;
|
|
191
|
+
if (u && typeof u == "object") {
|
|
192
|
+
const h = u;
|
|
193
|
+
return h.code || h.bankCode || h.bank_code || null;
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
}).filter((u) => !!u);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
async function v(a, t) {
|
|
200
|
+
const n = String(t.method || "GET").toUpperCase() === "POST" ? "POST" : "GET", e = t.paymentLinkUrl, s = e.includes("{orderId}") ? e.replace("{orderId}", encodeURIComponent(a)) : e + (e.includes("?") ? "&" : "?") + "orderId=" + encodeURIComponent(a), o = y().__aikaara_runtime__ ?? {}, r = typeof o.getSessionToken == "function" ? await o.getSessionToken() : typeof o.getChatJwt == "function" ? await o.getChatJwt() : null, c = { Accept: "application/json", ...t.headers ?? {} };
|
|
201
|
+
r && (c.Authorization = `Bearer ${r}`);
|
|
202
|
+
const l = { method: n, headers: c, credentials: "omit" };
|
|
203
|
+
n === "POST" && (c["Content-Type"] = "application/json", l.body = JSON.stringify({ orderId: a }));
|
|
204
|
+
const i = await fetch(s, l);
|
|
205
|
+
if (!i.ok) throw new Error(`partner-payment-link ${i.status}`);
|
|
206
|
+
const p = (await i.json())?.data;
|
|
207
|
+
return !p || typeof p.vendorPaymentLink != "string" ? null : { vendorPaymentLink: p.vendorPaymentLink, paymentStatus: p.paymentStatus ?? "" };
|
|
208
|
+
}
|
|
209
|
+
function x(a) {
|
|
210
|
+
const e = window.screenX + Math.round((window.outerWidth - 520) / 2), s = window.screenY + Math.round((window.outerHeight - 680) / 2);
|
|
211
|
+
return window.open(
|
|
212
|
+
a,
|
|
213
|
+
"taxbuddy_payment",
|
|
214
|
+
`width=520,height=680,left=${e},top=${s},scrollbars=yes,resizable=yes`
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
function C(a, t, n) {
|
|
218
|
+
let e = !1;
|
|
219
|
+
function s() {
|
|
220
|
+
clearInterval(c), window.removeEventListener("message", r);
|
|
221
|
+
}
|
|
222
|
+
function o(l) {
|
|
223
|
+
e || (e = !0, s(), l());
|
|
224
|
+
}
|
|
225
|
+
function r(l) {
|
|
226
|
+
if (t && l.origin !== t) return;
|
|
227
|
+
const i = l.data;
|
|
228
|
+
if (!(!i || typeof i != "object")) {
|
|
229
|
+
if (i.type === "payment-completed" && i.success === !0) {
|
|
230
|
+
o(() => n.onSuccess());
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
i.type === "payment-error" && i.success === !1 && o(() => n.onError(i.error ?? "Payment failed"));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const c = setInterval(() => {
|
|
237
|
+
a.closed && o(() => n.onClose());
|
|
238
|
+
}, 500);
|
|
239
|
+
window.addEventListener("message", r);
|
|
240
|
+
}
|
|
241
|
+
function f(a) {
|
|
242
|
+
try {
|
|
243
|
+
const t = document.querySelector("aikaara-error-banner");
|
|
244
|
+
if (t && typeof t.show == "function") {
|
|
245
|
+
t.show(a);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
} catch {
|
|
249
|
+
}
|
|
250
|
+
console.warn("[payment_link]", a);
|
|
251
|
+
}
|
|
252
|
+
function I(a, t) {
|
|
253
|
+
if (!a) return;
|
|
254
|
+
let n = document.querySelector("aikaara-link-modal");
|
|
255
|
+
n || (n = document.createElement("aikaara-link-modal"), document.body.appendChild(n)), typeof n.show == "function" ? n.show(a, t) : window.open(a, "_blank", "noopener,noreferrer");
|
|
256
|
+
}
|
|
257
|
+
function S() {
|
|
258
|
+
typeof customElements > "u" || customElements.get("aikaara-template-payment-link") || customElements.define("aikaara-template-payment-link", w);
|
|
259
|
+
}
|
|
260
|
+
export {
|
|
261
|
+
w as AikaaraPaymentLink,
|
|
262
|
+
S as registerAikaaraPaymentLink
|
|
263
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g="https://checkout.razorpay.com/v1/checkout.js";let m=null;function y(){return window}class k extends HTMLElement{shadow;payloadData=[];message="";paidIdx={};constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}setPayload(t,n){this.payloadData=Array.isArray(t)?t:[],this.message=n??"",this.render()}render(){const t=this.payloadData.filter(e=>!!e&&typeof e=="object"&&e.type==="link"&&typeof e.url=="string"),n=t.map((e,s)=>{const o=e.name||"Open link",r=!!this.paidIdx[s];return`<button class="link${r?" paid":""}" data-i="${s}" type="button"${r?" disabled":""}><span class="lbl">${w(r?"Paid":o)}</span>`+(r?'<svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 8.5 L7 12 L13 5"/></svg>':'<svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M5 11 L11 5 M6 5 H11 V10"/></svg>')+"</button>"}).join("");this.shadow.innerHTML="<style>:host { display:block; margin:6px 0; font-family:inherit; }.bubble { padding:12px 16px; border-radius:14px; background:var(--aikaara-bot-bubble-bg, #d8e5f5); color:var(--aikaara-bot-bubble-text, #1a2845); font-size:14px; line-height:1.55; margin-bottom:10px; }.links { display:flex; flex-direction:column; gap:8px; }.link { display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:11px 22px; border:1.5px solid var(--aikaara-primary, #1849a9); background:var(--aikaara-primary, #1849a9); color:var(--aikaara-primary-contrast, #fff); border-radius:24px; font-size:14px; font-weight:600; cursor:pointer; font-family:inherit; text-decoration:none; transition: filter 120ms; width:150px; align-self:flex-start; }.link:hover:not(:disabled) { filter: brightness(0.94); }.link.paid, .link:disabled { background:#e7f5ec; color:#0e7c3a; border-color:#0e7c3a; cursor:default; }.icon { width:13px; height:13px; }</style>"+(this.message?`<div class="bubble">${this.message}</div>`:"")+`<div class="links">${n}</div>`,this.shadow.querySelectorAll(".link").forEach(e=>{e.addEventListener("click",()=>{if(e.disabled)return;const s=Number(e.dataset.i||0),o=t[s];o&&this.handleClick(s,o)})})}handleClick(t,n){const e=b(n),s=y().__aikaara_descriptor__,o=s?.partnerPayment,r=s?.razorpay;if(e&&o?.paymentLinkUrl){this.openPartnerPaymentLink(t,e,n,o);return}if(!e||!r?.keyId){S(n.url,n.name||"Pay"),this.dispatchEvent(new CustomEvent("template-action",{detail:{text:n.name||"link-click",attributes:{action:{type:"link",url:n.url,orderId:e||n.orderId,openedIn:"modal"}}},bubbles:!0,composed:!0}));return}_(r.preferredBanksUrl,e,r.preferredBanksMethod,r.preferredBanksHeaders).catch(c=>(console.warn("[payment_link] preferred-banks fetch failed; continuing with default UI",c),[])).then(c=>P().then(()=>this.openRazorpay(t,e,r,c))).catch(c=>{console.error("[payment_link] Razorpay launch failed",c)})}openPartnerPaymentLink(t,n,e,s){v(n,s).then(o=>{if(!o){f("Failed to generate payment link, please try again later");return}const r=(o.paymentStatus??"").toLowerCase();if(r==="paid"||r==="success"||r==="completed"){this.paidIdx[t]=!0,this.render(),f("Payment already completed");return}const c=o.vendorPaymentLink;if(!c){f("Failed to generate payment link, please try again later");return}const l=navigator.userAgent.toLowerCase();if(l.includes("iphone")||l.includes("ipad")||l.includes("ipod")){window.location.href=c;return}const d=x(c);if(!d){window.open(c,"_blank"),f("Allow popups for the best payment experience");return}this.dispatchEvent(new CustomEvent("template-action",{detail:{text:e.name||"link-click",attributes:{action:{type:"partner-payment",url:c,orderId:n,openedIn:"popup"}}},bubbles:!0,composed:!0})),C(d,s.checkoutOrigin,{onSuccess:()=>{this.paidIdx[t]=!0,this.render()},onError:p=>{f(p||"Payment failed, please try again")},onClose:()=>{}})}).catch(o=>{console.error("[payment_link] partner payment link fetch failed",o),f("Failed to generate payment link, please try again later")})}openRazorpay(t,n,e,s){const o=y(),r=o.__aikaara_runtime__?.identity??{},c={key:e.keyId,order_id:n,name:e.name||o.__aikaara_descriptor__?.title||"Payment",prefill:{},handler:()=>{this.paidIdx[t]=!0,this.render()},modal:{ondismiss:()=>{}}};typeof r.mobile=="string"?c.prefill.contact=r.mobile:typeof r.phone=="string"&&(c.prefill.contact=r.phone),typeof r.email=="string"&&(c.prefill.email=r.email),typeof r.name=="string"?c.prefill.name=r.name:typeof r.userName=="string"&&(c.prefill.name=r.userName),Array.isArray(s)&&s.length&&(c.config={display:{blocks:{utib:{name:"Pay Using Preferred Netbanking",instruments:[{method:"netbanking",banks:s}]}},sequence:["block.utib","netbanking","card","upi"],preferences:{show_default_blocks:!0}}});const l=o.Razorpay;if(typeof l!="function")throw new Error("Razorpay Checkout script not available");const i=new l(c);i.on("payment.failed",d=>{console.warn("[payment_link] payment.failed",d?.error)}),i.open()}}function w(a){return String(a??"").replace(/[&<>]/g,t=>t==="&"?"&":t==="<"?"<":">")}function b(a){if(typeof a.orderId=="string"&&a.orderId)return a.orderId;try{const t=new URL(a.url,window.location.origin),n=t.searchParams.get("orderId")||t.searchParams.get("order_id");if(n)return n;if(t.hash&&t.hash.length>1){const e=new URLSearchParams(t.hash.replace(/^#/,"")),s=e.get("orderId")||e.get("order_id");if(s)return s}}catch{}return null}function P(){return typeof y().Razorpay=="function"?Promise.resolve():m||(m=new Promise((a,t)=>{const n=document.querySelector('script[data-aikaara-razorpay="1"]');if(n){n.addEventListener("load",()=>a()),n.addEventListener("error",()=>t(new Error("checkout.js failed to load")));return}const e=document.createElement("script");e.src=g,e.async=!0,e.dataset.aikaaraRazorpay="1",e.onload=()=>a(),e.onerror=()=>{m=null,t(new Error("checkout.js failed to load"))},document.head.appendChild(e)}),m)}function _(a,t,n,e){if(!a)return Promise.resolve([]);const s=String(n||"GET").toUpperCase()==="POST"?"POST":"GET",o=a.includes("{orderId}")?a.replace("{orderId}",encodeURIComponent(t)):a+(a.includes("?")?"&":"?")+"orderId="+encodeURIComponent(t),r=y().__aikaara_runtime__??{};return(typeof r.getSessionToken=="function"?r.getSessionToken():typeof r.getChatJwt=="function"?r.getChatJwt():Promise.resolve(null)).then(l=>{const i={Accept:"application/json",...e??{}};l&&(i.Authorization=`Bearer ${l}`);const d={method:s,headers:i,credentials:"omit"};return s==="POST"&&(i["Content-Type"]="application/json",d.body=JSON.stringify({orderId:t})),fetch(o,d)}).then(l=>{if(!l.ok)throw new Error(`preferred-banks ${l.status}`);return l.json()}).then(l=>{const i=l,d=i?.data&&typeof i.data=="object"&&!Array.isArray(i.data)?i.data:null;return(Array.isArray(l)?l:Array.isArray(i?.banks)?i.banks:Array.isArray(i?.data)?i.data:Array.isArray(d?.preferredPaymentBank)?d.preferredPaymentBank:Array.isArray(d?.banks)?d.banks:[]).map(u=>{if(typeof u=="string")return u;if(u&&typeof u=="object"){const h=u;return h.code||h.bankCode||h.bank_code||null}return null}).filter(u=>!!u)})}async function v(a,t){const n=String(t.method||"GET").toUpperCase()==="POST"?"POST":"GET",e=t.paymentLinkUrl,s=e.includes("{orderId}")?e.replace("{orderId}",encodeURIComponent(a)):e+(e.includes("?")?"&":"?")+"orderId="+encodeURIComponent(a),o=y().__aikaara_runtime__??{},r=typeof o.getSessionToken=="function"?await o.getSessionToken():typeof o.getChatJwt=="function"?await o.getChatJwt():null,c={Accept:"application/json",...t.headers??{}};r&&(c.Authorization=`Bearer ${r}`);const l={method:n,headers:c,credentials:"omit"};n==="POST"&&(c["Content-Type"]="application/json",l.body=JSON.stringify({orderId:a}));const i=await fetch(s,l);if(!i.ok)throw new Error(`partner-payment-link ${i.status}`);const p=(await i.json())?.data;return!p||typeof p.vendorPaymentLink!="string"?null:{vendorPaymentLink:p.vendorPaymentLink,paymentStatus:p.paymentStatus??""}}function x(a){const e=window.screenX+Math.round((window.outerWidth-520)/2),s=window.screenY+Math.round((window.outerHeight-680)/2);return window.open(a,"taxbuddy_payment",`width=520,height=680,left=${e},top=${s},scrollbars=yes,resizable=yes`)}function C(a,t,n){let e=!1;function s(){clearInterval(c),window.removeEventListener("message",r)}function o(l){e||(e=!0,s(),l())}function r(l){if(t&&l.origin!==t)return;const i=l.data;if(!(!i||typeof i!="object")){if(i.type==="payment-completed"&&i.success===!0){o(()=>n.onSuccess());return}i.type==="payment-error"&&i.success===!1&&o(()=>n.onError(i.error??"Payment failed"))}}const c=setInterval(()=>{a.closed&&o(()=>n.onClose())},500);window.addEventListener("message",r)}function f(a){try{const t=document.querySelector("aikaara-error-banner");if(t&&typeof t.show=="function"){t.show(a);return}}catch{}console.warn("[payment_link]",a)}function S(a,t){if(!a)return;let n=document.querySelector("aikaara-link-modal");n||(n=document.createElement("aikaara-link-modal"),document.body.appendChild(n)),typeof n.show=="function"?n.show(a,t):window.open(a,"_blank","noopener,noreferrer")}function I(){typeof customElements>"u"||customElements.get("aikaara-template-payment-link")||customElements.define("aikaara-template-payment-link",k)}exports.AikaaraPaymentLink=k;exports.registerAikaaraPaymentLink=I;
|
|
@@ -14491,7 +14491,7 @@ function Ed(s, e = 5e3) {
|
|
|
14491
14491
|
});
|
|
14492
14492
|
}
|
|
14493
14493
|
const Ad = {
|
|
14494
|
-
"aikaara-template-payment-link": () => import("./AikaaraPaymentLink-
|
|
14494
|
+
"aikaara-template-payment-link": () => import("./AikaaraPaymentLink-CL4O6gbc.mjs").then(({ registerAikaaraPaymentLink: s }) => s())
|
|
14495
14495
|
};
|
|
14496
14496
|
function Id(s) {
|
|
14497
14497
|
const e = `template:${s}`, t = window.__aikaara_descriptor__?.components?.[e];
|
|
@@ -14685,7 +14685,7 @@ class Td extends HTMLElement {
|
|
|
14685
14685
|
*/
|
|
14686
14686
|
mountLinkButton(e) {
|
|
14687
14687
|
const t = this.renderGen;
|
|
14688
|
-
import("./AikaaraLinkButton-
|
|
14688
|
+
import("./AikaaraLinkButton-CnvirM17.mjs").then(({ registerAikaaraLinkButton: r, AikaaraLinkButton: o }) => {
|
|
14689
14689
|
if (t !== this.renderGen) return;
|
|
14690
14690
|
r();
|
|
14691
14691
|
const n = document.createElement("aikaara-link-button");
|
|
@@ -743,7 +743,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
743
743
|
<span class="message"></span>
|
|
744
744
|
<button class="dismiss">Dismiss</button>
|
|
745
745
|
</div>
|
|
746
|
-
`,this.container=this.shadow.querySelector(".banner"),this.shadow.querySelector(".dismiss")?.addEventListener("click",()=>this.hide())}show(e,t){const r=this.container.querySelector(".message");r&&(r.textContent=e),this.container.classList.add("visible"),this.dismissTimer&&clearTimeout(this.dismissTimer),t&&(this.dismissTimer=setTimeout(()=>this.hide(),t))}hide(){this.container.classList.remove("visible"),this.dismissTimer&&(clearTimeout(this.dismissTimer),this.dismissTimer=null)}}const an=new Map;function ic(s){const e=an.get(s);if(e)return e;const t=new Promise((r,o)=>{const n=document.querySelector(`script[data-aikaara-src="${CSS.escape(s)}"]`);if(n){n.dataset.aikaaraReady==="1"?r():(n.addEventListener("load",()=>r(),{once:!0}),n.addEventListener("error",()=>o(new Error(`Failed to load ${s}`)),{once:!0}));return}const i=document.createElement("script");i.src=s,i.async=!0,i.crossOrigin="anonymous",i.dataset.aikaaraSrc=s,i.addEventListener("load",()=>{i.dataset.aikaaraReady="1",r()},{once:!0}),i.addEventListener("error",()=>{an.delete(s),o(new Error(`Failed to load ${s}`))},{once:!0}),document.head.appendChild(i)});return an.set(s,t),t}function Wd(s,e=5e3){return new Promise((t,r)=>{const o=setTimeout(()=>r(new Error(`Custom element <${s}> not registered within ${e}ms`)),e);customElements.whenDefined(s).then(()=>{clearTimeout(o),t()})})}const zd={"aikaara-template-payment-link":()=>Promise.resolve().then(()=>require("./AikaaraPaymentLink-
|
|
746
|
+
`,this.container=this.shadow.querySelector(".banner"),this.shadow.querySelector(".dismiss")?.addEventListener("click",()=>this.hide())}show(e,t){const r=this.container.querySelector(".message");r&&(r.textContent=e),this.container.classList.add("visible"),this.dismissTimer&&clearTimeout(this.dismissTimer),t&&(this.dismissTimer=setTimeout(()=>this.hide(),t))}hide(){this.container.classList.remove("visible"),this.dismissTimer&&(clearTimeout(this.dismissTimer),this.dismissTimer=null)}}const an=new Map;function ic(s){const e=an.get(s);if(e)return e;const t=new Promise((r,o)=>{const n=document.querySelector(`script[data-aikaara-src="${CSS.escape(s)}"]`);if(n){n.dataset.aikaaraReady==="1"?r():(n.addEventListener("load",()=>r(),{once:!0}),n.addEventListener("error",()=>o(new Error(`Failed to load ${s}`)),{once:!0}));return}const i=document.createElement("script");i.src=s,i.async=!0,i.crossOrigin="anonymous",i.dataset.aikaaraSrc=s,i.addEventListener("load",()=>{i.dataset.aikaaraReady="1",r()},{once:!0}),i.addEventListener("error",()=>{an.delete(s),o(new Error(`Failed to load ${s}`))},{once:!0}),document.head.appendChild(i)});return an.set(s,t),t}function Wd(s,e=5e3){return new Promise((t,r)=>{const o=setTimeout(()=>r(new Error(`Custom element <${s}> not registered within ${e}ms`)),e);customElements.whenDefined(s).then(()=>{clearTimeout(o),t()})})}const zd={"aikaara-template-payment-link":()=>Promise.resolve().then(()=>require("./AikaaraPaymentLink-D_SZ081m.cjs")).then(({registerAikaaraPaymentLink:s})=>s())};function Vd(s){const e=`template:${s}`,t=window.__aikaara_descriptor__?.components?.[e];return t&&t.kind==="iife-element"?{render:t.tag,scriptUrl:t.scriptUrl,props:t.props}:window.__aikaara_descriptor__?.templates?.[s]}class oc extends HTMLElement{shadow;payloadData=null;innerMessage="";renderGen=0;_consumedValues=null;static get observedAttributes(){return["content-type","template-id","message-id"]}constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.render(),this.addEventListener("template-action",e=>{const t=e.detail,r=this.getAttribute("message-id");if(r&&t?.attributes?.action){const o=Yd(t.attributes.action);if(Object.keys(o).length>0)try{localStorage.setItem(`aikaara_form:${r}`,JSON.stringify(o))}catch{}}this.dataset.consumed="true",this._applyConsumedToChildren()})}attributeChangedCallback(){this.render()}setPayload(e,t){this.payloadData=e,t!==void 0&&(this.innerMessage=t),this.render()}setConsumedValues(e){this._consumedValues=e,this._applyConsumedToChildren()}_applyConsumedToChildren(){let e=this._consumedValues;if(!e){const r=this.getAttribute("message-id");if(r)try{const o=localStorage.getItem(`aikaara_form:${r}`);o&&(e=JSON.parse(o))}catch{}}if(e){const r=e;this.querySelectorAll("aikaara-option-list").forEach(o=>{const n=o,i=n.getName?.();i&&r[i]?.length&&n.setPreSelected?.(r[i])})}this.querySelectorAll("aikaara-submit-action, aikaara-modal-action, aikaara-link-button").forEach(r=>{r.style.display="none"});const t=new Set(["aikaara-option-list","aikaara-submit-action","aikaara-modal-action","aikaara-link-button"]);this.querySelectorAll("*").forEach(r=>{if(t.has(r.tagName.toLowerCase()))return;e&&r.setConsumedValues?.(e),r.dataset.consumed="true"})}render(){const e=this.getAttribute("content-type")??"",t=this.getAttribute("template-id")??"";for(this.renderGen+=1,this.shadow.innerHTML=`
|
|
747
747
|
<style>
|
|
748
748
|
:host { display: block; }
|
|
749
749
|
::slotted(*) { display: block; }
|
|
@@ -757,7 +757,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
757
757
|
}
|
|
758
758
|
</style>
|
|
759
759
|
<slot></slot>
|
|
760
|
-
`;this.firstChild;)this.removeChild(this.firstChild);if(!e)return;const r=t?Vd(t):void 0,o=r?.render??(t?`aikaara-template-${t}`:`aikaara-template-${e}`),n=zd[o];if(n&&!customElements.get(o)?n().then(()=>this.render()).catch(i=>console.warn(`[aikaara-template-renderer] native template ${o} failed to load`,i)):r?.scriptUrl&&!customElements.get(o)&&ic(r.scriptUrl).then(()=>Wd(o)).then(()=>this.render()).catch(i=>console.warn(`[aikaara-template-renderer] failed to lazy-load ${r.scriptUrl}`,i)),customElements.get(o)){const i=document.createElement(o);if(r?.props){for(const[a,l]of Object.entries(r.props))if(typeof i[a]=="function")try{i[a](l)}catch(c){console.warn(`[aikaara-template-renderer] props.${a} threw on <${o}>`,c)}}i.setPayload?.(this.payloadData,this.innerMessage),this.appendChild(i),this.dataset.consumed==="true"&&(this._consumedValues&&Object.keys(this._consumedValues).length>0&&i.setConsumedValues?.(this._consumedValues),i.dataset.consumed="true");return}if(Array.isArray(this.payloadData)){const i=this.payloadData;if(i.length>0&&i.every(l=>l&&typeof l=="object"&&!Array.isArray(l)&&!("type"in l)&&!("data"in l)&&typeof l.message=="string")){const l=document.createElement("aikaara-option-list");l.setPayload({name:"quick-reply",type:"button",options:i.map(c=>{const u=typeof c.title=="string"?c.title:"",h=c.message;return{label:u||h,value:h}})}),this.appendChild(l);return}for(const l of i)this.mountField(l)}else if(this.payloadData&&typeof this.payloadData=="object"){const i=this.payloadData;typeof i.message=="string"&&(i.okLabel||i.action||i.ok)&&this.mountModal(i)}this.dataset.consumed==="true"&&this._applyConsumedToChildren()}mountField(e){if(!e||typeof e!="object")return;const t=e.type??e.data?.type;if(t==="link"){this.mountLinkButton(e);return}const r=e.data;if(r){if(t==="text"){const o=document.createElement("aikaara-text-input");o.setPayload(r),this.appendChild(o);return}if(t==="checkbox"||t==="radio"||t==="button"){const o=document.createElement("aikaara-option-list");o.setPayload({name:r.name??"",title:r.title,options:r.options??[],type:t}),this.appendChild(o);return}if(t==="submit"){const o=document.createElement("aikaara-submit-action"),n=this.getAttribute("message-id")??void 0;o.setPayload({name:r.name??"Submit",action:r.action??{message:r.name??"Submit"},messageId:n}),this.appendChild(o);return}t==="modal"&&this.mountModal({message:r.message??"",okLabel:r.okLabel,cancelLabel:r.cancelLabel,action:r.action})}}mountLinkButton(e){const t=this.renderGen;Promise.resolve().then(()=>require("./AikaaraLinkButton-
|
|
760
|
+
`;this.firstChild;)this.removeChild(this.firstChild);if(!e)return;const r=t?Vd(t):void 0,o=r?.render??(t?`aikaara-template-${t}`:`aikaara-template-${e}`),n=zd[o];if(n&&!customElements.get(o)?n().then(()=>this.render()).catch(i=>console.warn(`[aikaara-template-renderer] native template ${o} failed to load`,i)):r?.scriptUrl&&!customElements.get(o)&&ic(r.scriptUrl).then(()=>Wd(o)).then(()=>this.render()).catch(i=>console.warn(`[aikaara-template-renderer] failed to lazy-load ${r.scriptUrl}`,i)),customElements.get(o)){const i=document.createElement(o);if(r?.props){for(const[a,l]of Object.entries(r.props))if(typeof i[a]=="function")try{i[a](l)}catch(c){console.warn(`[aikaara-template-renderer] props.${a} threw on <${o}>`,c)}}i.setPayload?.(this.payloadData,this.innerMessage),this.appendChild(i),this.dataset.consumed==="true"&&(this._consumedValues&&Object.keys(this._consumedValues).length>0&&i.setConsumedValues?.(this._consumedValues),i.dataset.consumed="true");return}if(Array.isArray(this.payloadData)){const i=this.payloadData;if(i.length>0&&i.every(l=>l&&typeof l=="object"&&!Array.isArray(l)&&!("type"in l)&&!("data"in l)&&typeof l.message=="string")){const l=document.createElement("aikaara-option-list");l.setPayload({name:"quick-reply",type:"button",options:i.map(c=>{const u=typeof c.title=="string"?c.title:"",h=c.message;return{label:u||h,value:h}})}),this.appendChild(l);return}for(const l of i)this.mountField(l)}else if(this.payloadData&&typeof this.payloadData=="object"){const i=this.payloadData;typeof i.message=="string"&&(i.okLabel||i.action||i.ok)&&this.mountModal(i)}this.dataset.consumed==="true"&&this._applyConsumedToChildren()}mountField(e){if(!e||typeof e!="object")return;const t=e.type??e.data?.type;if(t==="link"){this.mountLinkButton(e);return}const r=e.data;if(r){if(t==="text"){const o=document.createElement("aikaara-text-input");o.setPayload(r),this.appendChild(o);return}if(t==="checkbox"||t==="radio"||t==="button"){const o=document.createElement("aikaara-option-list");o.setPayload({name:r.name??"",title:r.title,options:r.options??[],type:t}),this.appendChild(o);return}if(t==="submit"){const o=document.createElement("aikaara-submit-action"),n=this.getAttribute("message-id")??void 0;o.setPayload({name:r.name??"Submit",action:r.action??{message:r.name??"Submit"},messageId:n}),this.appendChild(o);return}t==="modal"&&this.mountModal({message:r.message??"",okLabel:r.okLabel,cancelLabel:r.cancelLabel,action:r.action})}}mountLinkButton(e){const t=this.renderGen;Promise.resolve().then(()=>require("./AikaaraLinkButton-DFT_nAv9.cjs")).then(({registerAikaaraLinkButton:r,AikaaraLinkButton:o})=>{if(t!==this.renderGen)return;r();const n=document.createElement("aikaara-link-button");n.setPayload({name:e.name??"Open",url:e.url??"",openLinkInNewTab:e.openLinkInNewTab,orderId:e.orderId,extra:Gd(e),messageId:this.getAttribute("message-id")??void 0}),this.appendChild(n)})}mountModal(e){const t=document.createElement("aikaara-modal-action");t.setPayload(e),this.appendChild(t)}}const Kd=new Set(["type","url","name","openLinkInNewTab","orderId"]);function Gd(s){const e={};for(const[t,r]of Object.entries(s))Kd.has(t)||(e[t]=r);return e}function Yd(s){const e=new Set(["message_id","formAction","requestType","serviceType"]),t={};for(const[r,o]of Object.entries(s))e.has(r)||(Array.isArray(o)&&o.every(n=>typeof n=="string")?t[r]=o:typeof o=="string"&&(t[r]=[o]));return t}class sc extends HTMLElement{shadow;static get observedAttributes(){return["text","subtext"]}constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}render(){const e=this.getAttribute("text")??this.textContent??"",t=this.getAttribute("subtext")??"";this.shadow.innerHTML=`
|
|
761
761
|
<style>
|
|
762
762
|
:host {
|
|
763
763
|
display: flex;
|