@aikaara/chat-sdk 1.3.4 → 1.4.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/{AikaaraLinkButton-C1S7MfVT.mjs → AikaaraLinkButton--t5yyst9.mjs} +20 -17
- package/dist/AikaaraLinkButton-DtbxlRUu.cjs +25 -0
- package/dist/AikaaraPaymentLink-BlxQSATl.cjs +1 -0
- package/dist/AikaaraPaymentLink-BuQX9XAE.mjs +155 -0
- package/dist/{MountTenant-DYhDyux6.cjs → MountTenant-DUSZye2K.cjs} +71 -71
- package/dist/{MountTenant-a_9ZUVQQ.mjs → MountTenant-xtZIgPSM.mjs} +1717 -1691
- package/dist/cdn/aikaara-chat.iife.js +56 -56
- package/dist/headless.cjs +1 -1
- package/dist/headless.d.ts +12 -6
- package/dist/headless.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +12 -6
- package/dist/index.mjs +2 -2
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.ts +5 -3
- package/dist/ui.mjs +1 -1
- package/package.json +1 -1
- package/dist/AikaaraLinkButton-VDNx7RfC.cjs +0 -25
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { H as p } from "./MountTenant-xtZIgPSM.mjs";
|
|
2
|
+
class c extends HTMLElement {
|
|
2
3
|
shadow;
|
|
3
4
|
payload = null;
|
|
4
5
|
constructor() {
|
|
@@ -33,25 +34,27 @@ class u extends HTMLElement {
|
|
|
33
34
|
button[disabled] { opacity: 0.5; cursor: not-allowed; }
|
|
34
35
|
</style>
|
|
35
36
|
<button type="button" ${e ? "" : "disabled"}>
|
|
36
|
-
${
|
|
37
|
+
${m(e?.name ?? "Open")}
|
|
37
38
|
<span aria-hidden="true">↗</span>
|
|
38
39
|
</button>
|
|
39
40
|
`, this.shadow.querySelector("button")?.addEventListener("click", () => this.handleClick());
|
|
40
41
|
}
|
|
41
42
|
handleClick() {
|
|
42
43
|
if (!this.payload) return;
|
|
43
|
-
const { url: e, name: a, openLinkInNewTab: o,
|
|
44
|
-
detail: { url: e, name: a, orderId:
|
|
44
|
+
const { url: e, name: a, openLinkInNewTab: o, openInPopup: r, orderId: i, extra: s, messageId: n } = this.payload, d = r ? "popup" : o ? "tab" : "modal", l = new CustomEvent("aikaara-link-action", {
|
|
45
|
+
detail: { url: e, name: a, orderId: i, openedIn: d, extra: s, messageId: n },
|
|
45
46
|
bubbles: !0,
|
|
46
47
|
composed: !0,
|
|
47
48
|
cancelable: !0
|
|
48
49
|
});
|
|
49
|
-
if (this.dispatchEvent(
|
|
50
|
-
if (
|
|
50
|
+
if (this.dispatchEvent(l))
|
|
51
|
+
if (r)
|
|
52
|
+
p(e);
|
|
53
|
+
else if (o)
|
|
51
54
|
window.open(e, "_blank", "noopener,noreferrer");
|
|
52
55
|
else {
|
|
53
|
-
const
|
|
54
|
-
requestAnimationFrame(() =>
|
|
56
|
+
const u = b();
|
|
57
|
+
requestAnimationFrame(() => u?.show?.(e, a));
|
|
55
58
|
}
|
|
56
59
|
this.dispatchEvent(
|
|
57
60
|
new CustomEvent("template-action", {
|
|
@@ -61,9 +64,9 @@ class u extends HTMLElement {
|
|
|
61
64
|
action: {
|
|
62
65
|
type: "link",
|
|
63
66
|
url: e,
|
|
64
|
-
orderId:
|
|
65
|
-
openedIn:
|
|
66
|
-
...
|
|
67
|
+
orderId: i,
|
|
68
|
+
openedIn: d,
|
|
69
|
+
...s ?? {}
|
|
67
70
|
},
|
|
68
71
|
...n ? { message_id: n } : {}
|
|
69
72
|
}
|
|
@@ -74,13 +77,13 @@ class u extends HTMLElement {
|
|
|
74
77
|
);
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
|
-
function
|
|
80
|
+
function m(t) {
|
|
78
81
|
return t.replace(
|
|
79
82
|
/[&<>"']/g,
|
|
80
83
|
(e) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[e]
|
|
81
84
|
);
|
|
82
85
|
}
|
|
83
|
-
function
|
|
86
|
+
function b() {
|
|
84
87
|
if (typeof document > "u") return null;
|
|
85
88
|
let t = document.querySelector("aikaara-link-modal");
|
|
86
89
|
if (!t) {
|
|
@@ -89,10 +92,10 @@ function p() {
|
|
|
89
92
|
}
|
|
90
93
|
return t;
|
|
91
94
|
}
|
|
92
|
-
function
|
|
93
|
-
typeof customElements > "u" || customElements.get("aikaara-link-button") || customElements.define("aikaara-link-button",
|
|
95
|
+
function f() {
|
|
96
|
+
typeof customElements > "u" || customElements.get("aikaara-link-button") || customElements.define("aikaara-link-button", c);
|
|
94
97
|
}
|
|
95
98
|
export {
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
c as AikaaraLinkButton,
|
|
100
|
+
f as registerAikaaraLinkButton
|
|
98
101
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./MountTenant-DUSZye2K.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
|
+
<style>
|
|
3
|
+
:host { display: block; margin-top: 8px; }
|
|
4
|
+
button {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: 6px;
|
|
8
|
+
padding: 10px 16px;
|
|
9
|
+
background: var(--aikaara-primary, #0f2e5c);
|
|
10
|
+
color: var(--aikaara-primary-contrast, #fff);
|
|
11
|
+
border: none;
|
|
12
|
+
border-radius: var(--aikaara-button-radius, 8px);
|
|
13
|
+
font-family: var(--aikaara-font, system-ui);
|
|
14
|
+
font-size: 14px;
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
}
|
|
18
|
+
button:hover { background: var(--aikaara-primary-hover, #0a2347); }
|
|
19
|
+
button[disabled] { opacity: 0.5; cursor: not-allowed; }
|
|
20
|
+
</style>
|
|
21
|
+
<button type="button" ${e?"":"disabled"}>
|
|
22
|
+
${m(e?.name??"Open")}
|
|
23
|
+
<span aria-hidden="true">↗</span>
|
|
24
|
+
</button>
|
|
25
|
+
`,this.shadow.querySelector("button")?.addEventListener("click",()=>this.handleClick())}handleClick(){if(!this.payload)return;const{url:e,name:a,openLinkInNewTab:o,openInPopup:r,orderId:i,extra:s,messageId:n}=this.payload,d=r?"popup":o?"tab":"modal",u=new CustomEvent("aikaara-link-action",{detail:{url:e,name:a,orderId:i,openedIn:d,extra:s,messageId:n},bubbles:!0,composed:!0,cancelable:!0});if(this.dispatchEvent(u))if(r)p.openInPopupWindow(e);else if(o)window.open(e,"_blank","noopener,noreferrer");else{const c=k();requestAnimationFrame(()=>c?.show?.(e,a))}this.dispatchEvent(new CustomEvent("template-action",{detail:{text:a,attributes:{action:{type:"link",url:e,orderId:i,openedIn:d,...s??{}},...n?{message_id:n}:{}}},bubbles:!0,composed:!0}))}}function m(t){return t.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e])}function k(){if(typeof document>"u")return null;let t=document.querySelector("aikaara-link-modal");if(!t){const e=document.createElement("aikaara-link-modal");document.body.appendChild(e),t=e}return t}function b(){typeof customElements>"u"||customElements.get("aikaara-link-button")||customElements.define("aikaara-link-button",l)}exports.AikaaraLinkButton=l;exports.registerAikaaraLinkButton=b;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h="https://checkout.razorpay.com/v1/checkout.js";let p=null;function u(){return window}class m extends HTMLElement{shadow;payloadData=[];message="";paidIdx={};constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}setPayload(r,t){this.payloadData=Array.isArray(r)?r:[],this.message=t??"",this.render()}render(){const r=this.payloadData.filter(e=>!!e&&typeof e=="object"&&e.type==="link"&&typeof e.url=="string"),t=r.map((e,n)=>{const i=e.name||"Open link",s=!!this.paidIdx[n];return`<button class="link${s?" paid":""}" data-i="${n}" type="button"${s?" disabled":""}><span class="lbl">${y(s?"Paid":i)}</span>`+(s?'<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">${t}</div>`,this.shadow.querySelectorAll(".link").forEach(e=>{e.addEventListener("click",()=>{if(e.disabled)return;const n=Number(e.dataset.i||0),i=r[n];i&&this.handleClick(n,i)})})}handleClick(r,t){const e=k(t),n=u().__aikaara_descriptor__?.razorpay;if(!e||!n?.keyId){w(t.url,t.name||"Pay"),this.dispatchEvent(new CustomEvent("template-action",{detail:{text:t.name||"link-click",attributes:{action:{type:"link",url:t.url,orderId:e||t.orderId,openedIn:"modal"}}},bubbles:!0,composed:!0}));return}g(n.preferredBanksUrl,e,n.preferredBanksMethod).catch(i=>(console.warn("[payment_link] preferred-banks fetch failed; continuing with default UI",i),[])).then(i=>b().then(()=>this.openRazorpay(r,e,n,i))).catch(i=>{console.error("[payment_link] Razorpay launch failed",i)})}openRazorpay(r,t,e,n){const i=u(),s=i.__aikaara_runtime__?.identity??{},o={key:e.keyId,order_id:t,name:e.name||i.__aikaara_descriptor__?.title||"Payment",prefill:{},handler:()=>{this.paidIdx[r]=!0,this.render()},modal:{ondismiss:()=>{}}};typeof s.mobile=="string"?o.prefill.contact=s.mobile:typeof s.phone=="string"&&(o.prefill.contact=s.phone),typeof s.email=="string"&&(o.prefill.email=s.email),typeof s.name=="string"?o.prefill.name=s.name:typeof s.userName=="string"&&(o.prefill.name=s.userName),Array.isArray(n)&&n.length&&(o.config={display:{blocks:{banks:{name:"Preferred Netbanking",instruments:[{method:"netbanking",banks:n}]}},sequence:["block.banks","netbanking","card","upi"],preferences:{show_default_blocks:!0}}});const d=i.Razorpay;if(typeof d!="function")throw new Error("Razorpay Checkout script not available");const c=new d(o);c.on("payment.failed",l=>{console.warn("[payment_link] payment.failed",l?.error)}),c.open()}}function y(a){return String(a??"").replace(/[&<>]/g,r=>r==="&"?"&":r==="<"?"<":">")}function k(a){if(typeof a.orderId=="string"&&a.orderId)return a.orderId;try{const r=new URL(a.url,window.location.origin),t=r.searchParams.get("orderId")||r.searchParams.get("order_id");if(t)return t;if(r.hash&&r.hash.length>1){const e=new URLSearchParams(r.hash.replace(/^#/,"")),n=e.get("orderId")||e.get("order_id");if(n)return n}}catch{}return null}function b(){return typeof u().Razorpay=="function"?Promise.resolve():p||(p=new Promise((a,r)=>{const t=document.querySelector('script[data-aikaara-razorpay="1"]');if(t){t.addEventListener("load",()=>a()),t.addEventListener("error",()=>r(new Error("checkout.js failed to load")));return}const e=document.createElement("script");e.src=h,e.async=!0,e.dataset.aikaaraRazorpay="1",e.onload=()=>a(),e.onerror=()=>{p=null,r(new Error("checkout.js failed to load"))},document.head.appendChild(e)}),p)}function g(a,r,t){if(!a)return Promise.resolve([]);const e=String(t||"GET").toUpperCase()==="POST"?"POST":"GET",n=a.includes("{orderId}")?a.replace("{orderId}",encodeURIComponent(r)):a+(a.includes("?")?"&":"?")+"orderId="+encodeURIComponent(r),i=u().__aikaara_runtime__??{};return(typeof i.getChatJwt=="function"?i.getChatJwt():Promise.resolve(null)).then(o=>{const d={Accept:"application/json"};o&&(d.Authorization=`Bearer ${o}`);const c={method:e,headers:d,credentials:"omit"};return e==="POST"&&(d["Content-Type"]="application/json",c.body=JSON.stringify({orderId:r})),fetch(n,c)}).then(o=>{if(!o.ok)throw new Error(`preferred-banks ${o.status}`);return o.json()}).then(o=>{const d=o;return(Array.isArray(o)?o:Array.isArray(d?.banks)?d.banks:Array.isArray(d?.data)?d.data:Array.isArray(d?.data?.banks)?d.data.banks:[]).map(l=>{if(typeof l=="string")return l;if(l&&typeof l=="object"){const f=l;return f.code||f.bankCode||f.bank_code||null}return null}).filter(l=>!!l)})}function w(a,r){if(!a)return;let t=document.querySelector("aikaara-link-modal");t||(t=document.createElement("aikaara-link-modal"),document.body.appendChild(t)),typeof t.show=="function"?t.show(a,r):window.open(a,"_blank","noopener,noreferrer")}function _(){typeof customElements>"u"||customElements.get("aikaara-template-payment-link")||customElements.define("aikaara-template-payment-link",m)}exports.AikaaraPaymentLink=m;exports.registerAikaaraPaymentLink=_;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
const h = "https://checkout.razorpay.com/v1/checkout.js";
|
|
2
|
+
let p = null;
|
|
3
|
+
function u() {
|
|
4
|
+
return window;
|
|
5
|
+
}
|
|
6
|
+
class m 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(r, t) {
|
|
17
|
+
this.payloadData = Array.isArray(r) ? r : [], this.message = t ?? "", this.render();
|
|
18
|
+
}
|
|
19
|
+
render() {
|
|
20
|
+
const r = this.payloadData.filter(
|
|
21
|
+
(e) => !!e && typeof e == "object" && e.type === "link" && typeof e.url == "string"
|
|
22
|
+
), t = r.map((e, a) => {
|
|
23
|
+
const i = e.name || "Open link", s = !!this.paidIdx[a];
|
|
24
|
+
return `<button class="link${s ? " paid" : ""}" data-i="${a}" type="button"${s ? " disabled" : ""}><span class="lbl">${y(s ? "Paid" : i)}</span>` + (s ? '<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">${t}</div>`, this.shadow.querySelectorAll(".link").forEach((e) => {
|
|
27
|
+
e.addEventListener("click", () => {
|
|
28
|
+
if (e.disabled) return;
|
|
29
|
+
const a = Number(e.dataset.i || 0), i = r[a];
|
|
30
|
+
i && this.handleClick(a, i);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
handleClick(r, t) {
|
|
35
|
+
const e = k(t), a = u().__aikaara_descriptor__?.razorpay;
|
|
36
|
+
if (!e || !a?.keyId) {
|
|
37
|
+
w(t.url, t.name || "Pay"), this.dispatchEvent(
|
|
38
|
+
new CustomEvent("template-action", {
|
|
39
|
+
detail: {
|
|
40
|
+
text: t.name || "link-click",
|
|
41
|
+
attributes: {
|
|
42
|
+
action: { type: "link", url: t.url, orderId: e || t.orderId, openedIn: "modal" }
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
bubbles: !0,
|
|
46
|
+
composed: !0
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
g(a.preferredBanksUrl, e, a.preferredBanksMethod).catch((i) => (console.warn("[payment_link] preferred-banks fetch failed; continuing with default UI", i), [])).then((i) => b().then(() => this.openRazorpay(r, e, a, i))).catch((i) => {
|
|
52
|
+
console.error("[payment_link] Razorpay launch failed", i);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
openRazorpay(r, t, e, a) {
|
|
56
|
+
const i = u(), s = i.__aikaara_runtime__?.identity ?? {}, o = {
|
|
57
|
+
key: e.keyId,
|
|
58
|
+
order_id: t,
|
|
59
|
+
name: e.name || i.__aikaara_descriptor__?.title || "Payment",
|
|
60
|
+
prefill: {},
|
|
61
|
+
handler: () => {
|
|
62
|
+
this.paidIdx[r] = !0, this.render();
|
|
63
|
+
},
|
|
64
|
+
modal: {
|
|
65
|
+
// No auto-hide on dismiss: user can re-click Pay Now. Per spec,
|
|
66
|
+
// button only locks on confirmed success.
|
|
67
|
+
ondismiss: () => {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
typeof s.mobile == "string" ? o.prefill.contact = s.mobile : typeof s.phone == "string" && (o.prefill.contact = s.phone), typeof s.email == "string" && (o.prefill.email = s.email), typeof s.name == "string" ? o.prefill.name = s.name : typeof s.userName == "string" && (o.prefill.name = s.userName), Array.isArray(a) && a.length && (o.config = {
|
|
72
|
+
display: {
|
|
73
|
+
blocks: {
|
|
74
|
+
banks: {
|
|
75
|
+
name: "Preferred Netbanking",
|
|
76
|
+
instruments: [{ method: "netbanking", banks: a }]
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
sequence: ["block.banks", "netbanking", "card", "upi"],
|
|
80
|
+
preferences: { show_default_blocks: !0 }
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const d = i.Razorpay;
|
|
84
|
+
if (typeof d != "function")
|
|
85
|
+
throw new Error("Razorpay Checkout script not available");
|
|
86
|
+
const c = new d(o);
|
|
87
|
+
c.on("payment.failed", (l) => {
|
|
88
|
+
console.warn("[payment_link] payment.failed", l?.error);
|
|
89
|
+
}), c.open();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function y(n) {
|
|
93
|
+
return String(n ?? "").replace(/[&<>]/g, (r) => r === "&" ? "&" : r === "<" ? "<" : ">");
|
|
94
|
+
}
|
|
95
|
+
function k(n) {
|
|
96
|
+
if (typeof n.orderId == "string" && n.orderId) return n.orderId;
|
|
97
|
+
try {
|
|
98
|
+
const r = new URL(n.url, window.location.origin), t = r.searchParams.get("orderId") || r.searchParams.get("order_id");
|
|
99
|
+
if (t) return t;
|
|
100
|
+
if (r.hash && r.hash.length > 1) {
|
|
101
|
+
const e = new URLSearchParams(r.hash.replace(/^#/, "")), a = e.get("orderId") || e.get("order_id");
|
|
102
|
+
if (a) return a;
|
|
103
|
+
}
|
|
104
|
+
} catch {
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
function b() {
|
|
109
|
+
return typeof u().Razorpay == "function" ? Promise.resolve() : p || (p = new Promise((n, r) => {
|
|
110
|
+
const t = document.querySelector('script[data-aikaara-razorpay="1"]');
|
|
111
|
+
if (t) {
|
|
112
|
+
t.addEventListener("load", () => n()), t.addEventListener("error", () => r(new Error("checkout.js failed to load")));
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const e = document.createElement("script");
|
|
116
|
+
e.src = h, e.async = !0, e.dataset.aikaaraRazorpay = "1", e.onload = () => n(), e.onerror = () => {
|
|
117
|
+
p = null, r(new Error("checkout.js failed to load"));
|
|
118
|
+
}, document.head.appendChild(e);
|
|
119
|
+
}), p);
|
|
120
|
+
}
|
|
121
|
+
function g(n, r, t) {
|
|
122
|
+
if (!n) return Promise.resolve([]);
|
|
123
|
+
const e = String(t || "GET").toUpperCase() === "POST" ? "POST" : "GET", a = n.includes("{orderId}") ? n.replace("{orderId}", encodeURIComponent(r)) : n + (n.includes("?") ? "&" : "?") + "orderId=" + encodeURIComponent(r), i = u().__aikaara_runtime__ ?? {};
|
|
124
|
+
return (typeof i.getChatJwt == "function" ? i.getChatJwt() : Promise.resolve(null)).then((o) => {
|
|
125
|
+
const d = { Accept: "application/json" };
|
|
126
|
+
o && (d.Authorization = `Bearer ${o}`);
|
|
127
|
+
const c = { method: e, headers: d, credentials: "omit" };
|
|
128
|
+
return e === "POST" && (d["Content-Type"] = "application/json", c.body = JSON.stringify({ orderId: r })), fetch(a, c);
|
|
129
|
+
}).then((o) => {
|
|
130
|
+
if (!o.ok) throw new Error(`preferred-banks ${o.status}`);
|
|
131
|
+
return o.json();
|
|
132
|
+
}).then((o) => {
|
|
133
|
+
const d = o;
|
|
134
|
+
return (Array.isArray(o) ? o : Array.isArray(d?.banks) ? d.banks : Array.isArray(d?.data) ? d.data : Array.isArray(d?.data?.banks) ? d.data.banks : []).map((l) => {
|
|
135
|
+
if (typeof l == "string") return l;
|
|
136
|
+
if (l && typeof l == "object") {
|
|
137
|
+
const f = l;
|
|
138
|
+
return f.code || f.bankCode || f.bank_code || null;
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}).filter((l) => !!l);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function w(n, r) {
|
|
145
|
+
if (!n) return;
|
|
146
|
+
let t = document.querySelector("aikaara-link-modal");
|
|
147
|
+
t || (t = document.createElement("aikaara-link-modal"), document.body.appendChild(t)), typeof t.show == "function" ? t.show(n, r) : window.open(n, "_blank", "noopener,noreferrer");
|
|
148
|
+
}
|
|
149
|
+
function x() {
|
|
150
|
+
typeof customElements > "u" || customElements.get("aikaara-template-payment-link") || customElements.define("aikaara-template-payment-link", m);
|
|
151
|
+
}
|
|
152
|
+
export {
|
|
153
|
+
m as AikaaraPaymentLink,
|
|
154
|
+
x as registerAikaaraPaymentLink
|
|
155
|
+
};
|