@tap-payments/connect-v2 0.0.32-test β†’ 0.0.34-test

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/README.md CHANGED
@@ -42,10 +42,6 @@ const App = () => {
42
42
  merchantDomain="https://example.com"
43
43
  theme={ConnectTheme.DARK}
44
44
  scope={ConnectScope.MERCHANT}
45
- appInfo={{
46
- name: 'My App',
47
- version: '1.0.0',
48
- }}
49
45
  onClose={() => setOpen(false)}
50
46
  features={{ poweredBy: true, closeButton: true }}
51
47
  mode={ConnectMode.POPUP}
@@ -86,9 +82,6 @@ You can also use the SDK without a React build setup by including the UMD bundle
86
82
  publicKey: 'pk_test_lat64TEDSvHrUOYAxVRe28PQ',
87
83
  merchantDomain: 'https://connect.dev.tap.company',
88
84
  language: TapConnectSDK.ConnectLanguage.EN,
89
- appInfo: {
90
- name: 'My App',
91
- },
92
85
  theme: TapConnectSDK.ConnectTheme.DARK,
93
86
  scope: TapConnectSDK.ConnectScope.MERCHANT,
94
87
  data: ['brand', 'entity'],
@@ -105,51 +98,61 @@ You can also use the SDK without a React build setup by including the UMD bundle
105
98
 
106
99
  ## 🧠 Props
107
100
 
108
- | Prop | Type | Required | Description |
109
- | ----------------------- | ------------------------------------------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
110
- | **open** | `boolean` | βœ… | Controls whether Connect element is open or closed. |
111
- | **publicKey** | `string` | βœ… | Your public API key provided by Tap Payments. |
112
- | **merchantDomain** | `string` | βœ… | Merchant's domain (e.g. `https://expamle.com`). |
113
- | **scope** | `ConnectScope` | βœ… | Defines the integration scope [**auth**, **merchant**]. |
114
- | **appInfo** | `ConnectAppInfo` | βœ… | Information about the merchant’s host application. |
115
- | β€” name | `string` | βœ… | The display name of your application. |
116
- | β€” identifier | `string` | ❌ | A unique identifier for your application (e.g., bundle ID or package name). |
117
- | β€” version | `string` | ❌ | The current version of your application (e.g., `1.0.0`). |
118
- | **onReady** | `() => void` | ❌ | Called when the app configurations are loaded successfully initializing. |
119
- | **onClose** | `() => void` | ❌ | Triggered when the Connect element is closed by the user. |
120
- | **onError** | `(eror: CustomError) => void` | ❌ | Triggered on any error. |
121
- | **onSuccess** | `(response: Record<string, string \| number>) => void` | ❌ | Callback triggered when the flow completes successfully. |
122
- | **theme** | `ConnectTheme` | ❌ | Customize the app theme [**light**, **dark**]. |
123
- | **language** | `ConnectLanguage` | ❌ | Language code for localization [**en**, **ar**]. |
124
- | **businessCountryCode** | `string` | ❌ | Country ISO2 code of the merchant country. |
125
- | **showBoard** | `boolean` | ❌ | Show the merchant board UI. |
126
- | **leadId** | `string` | ❌ | Optional lead ID for loading lead data. |
127
- | **platforms** | `string` | ❌ | - |
128
- | **paymentProvider** | `ConnectPaymentProvider` | ❌ | Information about the payment provider configuration. |
129
- | β€” technologyId | `string` | βœ… | - |
130
- | β€” settlementBy | `string` | βœ… | - |
131
- | **features** | `ConnectAppFeatures` | ❌ | Additional configuration options for appearance and UI. |
132
- | β€” poweredBy | `boolean` | ❌ | Show or hide the β€œPowered by Tap” logo. |
133
- | β€” merchantLogo | `boolean` | ❌ | Show or hide the merchant’s logo in the widget. |
134
- | β€” closeButton | `boolean` | ❌ | Display a close button on the widget. |
135
- | β€” dialogStartTransition | `ConnectDialogTransition` | ❌ | Transition animation when the dialog opens [**left**,**right**,**up**,**down**]. |
136
- | β€” dialogEndTransition | `ConnectDialogTransition` | ❌ | Transition animation when the dialog closes [**left**,**right**,**up**,**down**]. |
137
- | β€” dialogEdgeFormat | `ConnectDialogEdgeFormat` | ❌ | Controls the shape/format of the dialog edges [**curved**, **straight**]. |
138
- | **postUrl** | `string` | ❌ | Endpoint to post our data to merchant's server. |
139
- | **redirectUrl** | `string` | ❌ | Redirect URL after success. |
140
- | **data** | `string[]` | ❌ | Merchant data array (e.g. **operator**, **brand**, **entity**, etc.). |
141
- | **mode** | `ConnectMode` | ❌ | Controls the display behavior of the Connect Element, using the ConnectMode enum to specify whether it appears as a full page, popup, or display content only. |
142
- | **notification** | `ConnectNotification` | ❌ | Notification configuration to notify the user after account creation. |
143
- | β€” email | `boolean` | βœ… | Enable or disable email notifications. |
144
- | β€” mobile | `boolean` | ❌ | Enable or disable mobile (SMS) notifications. |
145
- | **boardEditable** | `boolean` | ❌ | Allow merchant board to be editable. |
146
- | **boardId** | `string` | ❌ | Specify existing board ID. |
147
- | **boardInfoId** | `string` | ❌ | Specify board info ID for password kit. |
148
- | **userId** | `string` | ❌ | User ID for password kit. |
149
- | **userType** | `string` | ❌ | Type of the user for password kit. |
150
- | **operationType** | `ConnectPasswordOperationType` | ❌ | Operation type for password kit. |
151
- | **loginMode** | `boolean` | ❌ | Opens Connect in login/auth mode. |
152
- | **region** | `string` | ❌ | Region code that changes the target middlware (e.g., **sa** for Saudi). |
101
+ | Prop | Type | Required | Description |
102
+ | ----------------------- | ------------------------------------------------------ | -------- | ---------------------------------------------------------------------------------------------- |
103
+ | **open** | `boolean` | βœ… | Controls whether the Connect element is open or closed. |
104
+ | **publicKey** | `string` | βœ… | Your public API key provided by Tap Payments. |
105
+ | **merchantDomain** | `string` | βœ… | Merchant's domain (e.g. `https://example.com`). |
106
+ | **scope** | `ConnectScope` | βœ… | Defines the integration scope. |
107
+ | **onReady** | `() => void` | ❌ | Called when the app configurations are loaded successfully. |
108
+ | **onClose** | `() => void` | ❌ | Triggered when the Connect element is closed. |
109
+ | **onError** | `(error: CustomError) => void` | ❌ | Triggered when an error occurs. |
110
+ | **onSuccess** | `(response: Record<string, string \| number>) => void` | ❌ | Triggered when the flow completes successfully. |
111
+ | **theme** | `ConnectTheme` | ❌ | UI theme configuration. |
112
+ | **language** | `ConnectLanguage` | ❌ | Localization language. |
113
+ | **businessCountryCode** | `string` | ❌ | ISO2 country code of the merchant. |
114
+ | **leadId** | `string` | ❌ | ID to Load an existing lead. |
115
+ | **showBoard** | `boolean` | ❌ | Show merchant board UI. |
116
+ | **boardEditable** | `boolean` | ❌ | Allow merchant board editing. |
117
+ | **platforms** | `string[]` | ❌ | List of merchant platforms. |
118
+ | **features** | `ConnectAppFeatures` | ❌ | UI and behavior customization options. |
119
+ | **paymentProvider** | `ConnectPaymentProvider` | ❌ | Payment provider configuration. |
120
+ | **postUrl** | `string` | ❌ | Endpoint to post collected data to your backend. |
121
+ | **redirectUrl** | `string` | ❌ | Redirect URL after success. |
122
+ | **data** | `string[]` | ❌ | Data modules to collect (e.g. `brand`, `entity`). |
123
+ | **mode** | `ConnectMode` | ❌ | Controls display behavior (page, popup, content). |
124
+ | **notification** | `ConnectNotification` | ❌ | Notification configuration. |
125
+ | **flow** | `ConnectFlows` | ❌ | Specifies a predefined flow to open directly (e.g., `brand`, `entity`, `kyc`, etc.). |
126
+ | **token** | `string` | ❌ | Connect session token. Required when `flow` is provided and the flow is not `board` or `auth`. |
127
+ | **boardId** | `string` | ❌ | Identifier of the board to load. Required when `flow` is set to `board`. |
128
+ | **configToken** | `string` | ❌ | Pre-generated configuration token from backend. |
129
+ | **region** | `ConnectRegions` | ❌ | Region code determining middleware domain. |
130
+
131
+ ##### `ConnectAppFeatures`
132
+
133
+ | Field | Type | Description |
134
+ | --------------------- | ------------------------- | ------------------------------ |
135
+ | poweredBy | `boolean` | Show or hide β€œPowered by Tap”. |
136
+ | embedded | `boolean` | Enable embedded layout mode. |
137
+ | merchantLogo | `boolean` | Show or hide merchant logo. |
138
+ | closeButton | `boolean` | Display close button. |
139
+ | dialogStartTransition | `ConnectDialogTransition` | Dialog opening animation. |
140
+ | dialogEndTransition | `ConnectDialogTransition` | Dialog closing animation. |
141
+ | dialogEdgeFormat | `ConnectDialogEdgeFormat` | Dialog edge style. |
142
+
143
+ ##### `ConnectPaymentProvider`
144
+
145
+ | Field | Type | Required | Description |
146
+ | ------------- | -------- | -------- | --------------------------------- |
147
+ | technologyId | `string` | βœ… | Payment technology identifier. |
148
+ | institutionId | `string` | βœ… | Financial institution identifier. |
149
+
150
+ ##### `ConnectNotification`
151
+
152
+ | Field | Type | Required | Description |
153
+ | ----- | --------- | -------- | --------------------------- |
154
+ | email | `boolean` | βœ… | Enable email notifications. |
155
+ | sms | `boolean` | ❌ | Enable SMS notifications. |
153
156
 
154
157
  ---
155
158
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),p=require("react"),A=require("react-dom");function R(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const u=R(p);var g=(e=>(e.PAGE="page",e.POPUP="popup",e.CONTENT="content",e))(g||{}),j=(e=>(e.AUTH="auth",e.MERCHANT="merchant",e))(j||{}),C=(e=>(e.SET_PASSWORD="set_password",e.RESET_PASSWORD="reset_password",e))(C||{}),v=(e=>(e.DARK="dark",e.LIGHT="light",e))(v||{}),b=(e=>(e.AR="ar",e.EN="en",e))(b||{}),E=(e=>(e.STRAIGHT="straight",e.CURVED="curved",e))(E||{}),O=(e=>(e.LEFT="left",e.RIGHT="right",e.UP="up",e.DOWN="down",e))(O||{}),d=(e=>(e.ON_CLOSE="connect:onClose",e.ON_ERROR="connect:onError",e.ON_SUCCESS="connect:onSuccess",e.ON_READY="connect:onReady",e.ON_LOADED="connect:onLoaded",e))(d||{}),f=(e=>(e.PROFILE_TOKEN="profile_token",e.CONFIG_TOKEN="config_token",e.THEME="theme",e.LANGUAGE="lang",e))(f||{});const T=({outerStartColor:e="rgba(244, 244, 244, 1)",outerEndColor:n="rgba(238, 238, 238, 1)",innerStartColor:t="rgba(244, 244, 244, 1)",innerEndColor:o="rgba(238, 238, 238, 1)",duration:s=3,toggleAnimation:i=!1})=>r.jsx("div",{style:{position:"relative",width:"135px",height:"135px"},children:r.jsx("div",{style:{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",opacity:.9},children:r.jsxs("svg",{width:"199",height:"197",viewBox:"0 0 199 197",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsxs("g",{children:[r.jsx("circle",{cx:"89.5",cy:"86.5",r:"67.5",fill:"none",stroke:"url(#strokeGradientOuter_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"425 125",children:i&&r.jsxs(r.Fragment,{children:[r.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 89.5 86.5",to:"360 89.5 86.5",dur:`${s/3}s`,repeatCount:"indefinite"}),r.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; 425; 425; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${s}s`,repeatCount:"indefinite"})]})}),r.jsx("circle",{cx:"89.5",cy:"86.5",r:"48",fill:"none",stroke:"url(#strokeGradientInner_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"300 100",children:i&&r.jsxs(r.Fragment,{children:[r.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"360 89.5 86.5",to:"0 89.5 86.5",dur:`${s/3}s`,repeatCount:"indefinite"}),r.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; -300; -300; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${s}s`,repeatCount:"indefinite"})]})})]}),r.jsxs("defs",{children:[r.jsxs("filter",{id:"filter0_dddi_1427_22275",x:"0.882668",y:"0.899429",width:"198.08",height:"195.314",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[r.jsx("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dy:"1.68224"}),r.jsx("feGaussianBlur",{stdDeviation:"4.20656"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 1 0"}),r.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_1427_22275"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dx:"22.3542",dy:"22.6047"}),r.jsx("feGaussianBlur",{stdDeviation:"9.80447"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0.6 0"}),r.jsx("feBlend",{mode:"normal",in2:"effect1_dropShadow_1427_22275",result:"effect2_dropShadow_1427_22275"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dx:"-6.03352",dy:"-3.01676"}),r.jsx("feGaussianBlur",{stdDeviation:"7.5419"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.7 0"}),r.jsx("feBlend",{mode:"normal",in2:"effect2_dropShadow_1427_22275",result:"effect3_dropShadow_1427_22275"}),r.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect3_dropShadow_1427_22275",result:"shape"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dy:"1.50838"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"arithmetic",k2:"-1",k3:"1"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"}),r.jsx("feBlend",{mode:"normal",in2:"shape",result:"effect4_innerShadow_1427_22275"})]}),r.jsxs("linearGradient",{id:"strokeGradientOuter_1427_22275",x1:"89.5",y1:"19",x2:"89.5",y2:"154",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:e}),r.jsx("stop",{offset:"1",stopColor:n})]}),r.jsxs("linearGradient",{id:"strokeGradientInner_1427_22275",x1:"89.4991",y1:"38.2849",x2:"89.4991",y2:"134.713",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:t}),r.jsx("stop",{offset:"1",stopColor:o})]})]})]})})}),L=p.memo(T),N=p.createContext({}),y=()=>p.useContext(N);function I({children:e,props:n}){const[t,o]=p.useState(!1),s=a=>{o(a)},i=()=>{o(!1)};return r.jsx(N.Provider,{value:{...n,onLoadingHandler:s,loading:t,onLoaded:i},children:e})}const U="https://connect-mw.dev.tap.company/middleware/v3/connect",G="https://connect-mw.dev.tap.company/middleware/v3/connect",B="https://connect-mw.dev.tap.company/middleware/v3/connect",D="tap-connect-sdk-iframe",x="https://connect.alpha.tap.company",F=({src:e})=>{const{loading:n}=y();return r.jsxs(r.Fragment,{children:[n&&r.jsx(L,{toggleAnimation:!0}),e&&r.jsx("iframe",{id:D,title:"connect",src:e,style:{width:"100%",height:"100%",border:"none",position:"absolute",top:0,left:0}})]})};var M=function(e){var n,t;return((t=(n=e==null?void 0:e.response)===null||n===void 0?void 0:n.data)===null||t===void 0?void 0:t.errors)!==void 0},$=function(e){return e instanceof Error},H=function(e){return typeof e=="string"},W=function(e){try{var n=e.response.data.errors,t=n[0],o=t.description,s=t.code;return{message:o,code:s}}catch(i){return{message:i.message,code:"UNKNOWN"}}},K=function(e){try{var n=e.message,t=n.split("::"),o=t[0],s=t[1];return{message:s,code:o}}catch(i){return{message:i.message,code:"UNKNOWN"}}},P=function(e){try{var n=e.split("::"),t=n[0],o=n[1];return{message:o,code:t}}catch(s){return{message:s,code:"UNKNOWN"}}},q=function(){function e(n){if(Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"message",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),M(n)){var t=W(n);this.code=t.code,this.message=t.message}else if($(n)){var t=K(n);this.code=t.code,this.message=t.message}else if(H(n)){var t=P(n);this.code=t.code,this.message=t.message}else this.code="UNKNOWN",this.message="Unknown error"}return Object.defineProperty(e.prototype,"getCode",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.code}}),Object.defineProperty(e.prototype,"getMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.message}}),Object.defineProperty(e.prototype,"getClientError",{enumerable:!1,configurable:!0,writable:!0,value:function(){return{message:this.message,code:this.code}}}),e}();const z=(e="tap-connect-sdk-element")=>{const n=document.getElementById(e);if(n)return n;const t=document.createElement("div");return t.setAttribute("id",e),document.body.prepend(t),t},Y=e=>e?["sa","sau"].includes(e.toLowerCase()):!1,J=e=>e==="dr",V=(e="")=>{const[n,t]=e.split("-");return Y(n)?J(t)?B:G:U},Q=({features:e,notification:n,paymentProvider:t,...o})=>{var s;return{open:o.open,operator:{public_key:o.publicKey},domain:o.merchantDomain,app_info:o.appInfo,country:o.businessCountryCode,scope:o.scope,board:{display:o.showBoard,editable:o.boardEditable},...o.leadId&&{lead:{id:o.leadId}},...((s=o.platforms)==null?void 0:s.length)&&{platforms:o.platforms},...((t==null?void 0:t.technologyId)||(t==null?void 0:t.settlementBy))&&{payment_provider:{...t.technologyId&&{technology:{id:t.technologyId}},...t.settlementBy&&{institution:{id:t.settlementBy}}}},features:e&&{poweredby:e.poweredBy,close_button:e.closeButton},...o.postUrl&&{post:{url:o.postUrl}},...o.redirectUrl&&{redirect:{url:o.redirectUrl}},data:o.data,mode:o.mode,notification:n&&{sms:n.mobile,email:n.email},interface:{...(e==null?void 0:e.dialogEdgeFormat)&&{edges:e.dialogEdgeFormat},locale:o.language,theme:o.theme,partner_logo:e==null?void 0:e.merchantLogo,...(e==null?void 0:e.dialogEndTransition)&&(e==null?void 0:e.dialogStartTransition)&&{dialog_transition:{start:e.dialogStartTransition,end:e.dialogEndTransition}}}}},X=()=>{const[e,n]=u.useState(""),{onError:t,onLoadingHandler:o,loginMode:s,region:i,...a}=y(),m=async()=>{o(!0);try{const l=await fetch(V(i),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.publicKey}`,mdn:a.merchantDomain||x},body:JSON.stringify(Q(a))});if(!l.ok)throw new Error(`${l.status}::${l.statusText}`);const c=await l.json(),h=new URLSearchParams;a!=null&&a.theme&&h.append(f.THEME,a.theme),a!=null&&a.language&&h.append(f.LANGUAGE,a.language);const k=s?`${x}/auth`:x;if(h.append(f.CONFIG_TOKEN,c.token),c.connect.url=`${k}?${h.toString()}`,a.mode!==g.PAGE)return n(c.connect.url);window.location.href=c.connect.url}catch(l){const c=new q(l);t==null||t(c.getClientError()),o(!1)}};return u.useEffect(()=>{m()},[]),{connectLink:e}},Z=()=>{const{onSuccess:e,onClose:n,onError:t,onReady:o,onLoaded:s}=y(),i=u.useCallback(async a=>{if(a.origin!==x)return;const{data:m,event:l}=a.data;switch(l){case d.ON_CLOSE:n==null||n();break;case d.ON_ERROR:t==null||t(m);break;case d.ON_SUCCESS:e(m);break;case d.ON_LOADED:s();break;case d.ON_READY:o==null||o();break}},[n,t,s,o,e]);u.useEffect(()=>(window.addEventListener("message",i,!1),()=>{window.removeEventListener("message",i)}),[i])},ee=()=>{const{connectLink:e}=X();return Z(),r.jsx("div",{id:"tap-connect-main-container",style:{display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.5)",position:"fixed",top:0,left:0,width:"100%",height:"100%"},children:r.jsx(F,{src:e})})},te=e=>r.jsx(I,{props:e,children:e.open&&r.jsx(ee,{})}),w=u.memo(te);var S,_=A;S=_.createRoot,_.hydrateRoot;const re=(e,n)=>{const t=z(e),o=S(t);return o.render(r.jsx(w,{...n})),{unmount:()=>o.unmount()}};exports.ConnectDialogEdgeFormat=E;exports.ConnectDialogTransition=O;exports.ConnectElement=w;exports.ConnectLanguage=b;exports.ConnectMode=g;exports.ConnectPasswordOperationType=C;exports.ConnectScope=j;exports.ConnectTheme=v;exports.renderConnectElement=re;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),f=require("react"),D=require("react-dom");function L(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const m=L(f);var y=(e=>(e.PAGE="page",e.POPUP="popup",e.CONTENT="content",e))(y||{}),I=(e=>(e.AUTH="auth",e.MERCHANT="merchant",e))(I||{}),h=(e=>(e.AUTH="auth",e.BANK="bank",e.BOARD="board",e.BRAND="brand",e.ENTITY="entity",e.INDIVIDUAL="individual",e.KYC="kyc",e.TAX="tax",e.TERMINAL="terminal",e))(h||{}),T=(e=>(e.SA="sa",e.SA_DR="sa-dr",e))(T||{}),v=(e=>(e.DARK="dark",e.LIGHT="light",e.DYNAMIC="dynamic",e))(v||{}),b=(e=>(e.AR="ar",e.EN="en",e.DYNAMIC="dynamic",e))(b||{}),g=(e=>(e.STRAIGHT="straight",e.CURVED="curved",e))(g||{}),x=(e=>(e.LEFT="left",e.RIGHT="right",e.UP="up",e.DOWN="down",e))(x||{}),c=(e=>(e.ON_CLOSE="connect:onClose",e.ON_ERROR="connect:onError",e.ON_SUCCESS="connect:onSuccess",e.ON_READY="connect:onReady",e.ON_LOADED="connect:onLoaded",e))(c||{}),u=(e=>(e.AUTH_TOKEN="token",e.CONFIG_TOKEN="config_token",e.THEME="theme",e.LANGUAGE="lang",e.BOARD_ID="board_id",e))(u||{});const G=({outerStartColor:e="rgba(244, 244, 244, 1)",outerEndColor:n="rgba(238, 238, 238, 1)",innerStartColor:t="rgba(244, 244, 244, 1)",innerEndColor:o="rgba(238, 238, 238, 1)",duration:a=3,toggleAnimation:s=!1})=>r.jsx("div",{style:{position:"relative",width:"135px",height:"135px"},children:r.jsx("div",{style:{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",opacity:.9},children:r.jsxs("svg",{width:"199",height:"197",viewBox:"0 0 199 197",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsxs("g",{children:[r.jsx("circle",{cx:"89.5",cy:"86.5",r:"67.5",fill:"none",stroke:"url(#strokeGradientOuter_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"425 125",children:s&&r.jsxs(r.Fragment,{children:[r.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 89.5 86.5",to:"360 89.5 86.5",dur:`${a/3}s`,repeatCount:"indefinite"}),r.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; 425; 425; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${a}s`,repeatCount:"indefinite"})]})}),r.jsx("circle",{cx:"89.5",cy:"86.5",r:"48",fill:"none",stroke:"url(#strokeGradientInner_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"300 100",children:s&&r.jsxs(r.Fragment,{children:[r.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"360 89.5 86.5",to:"0 89.5 86.5",dur:`${a/3}s`,repeatCount:"indefinite"}),r.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; -300; -300; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${a}s`,repeatCount:"indefinite"})]})})]}),r.jsxs("defs",{children:[r.jsxs("filter",{id:"filter0_dddi_1427_22275",x:"0.882668",y:"0.899429",width:"198.08",height:"195.314",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[r.jsx("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dy:"1.68224"}),r.jsx("feGaussianBlur",{stdDeviation:"4.20656"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 1 0"}),r.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_1427_22275"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dx:"22.3542",dy:"22.6047"}),r.jsx("feGaussianBlur",{stdDeviation:"9.80447"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0.6 0"}),r.jsx("feBlend",{mode:"normal",in2:"effect1_dropShadow_1427_22275",result:"effect2_dropShadow_1427_22275"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dx:"-6.03352",dy:"-3.01676"}),r.jsx("feGaussianBlur",{stdDeviation:"7.5419"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.7 0"}),r.jsx("feBlend",{mode:"normal",in2:"effect2_dropShadow_1427_22275",result:"effect3_dropShadow_1427_22275"}),r.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect3_dropShadow_1427_22275",result:"shape"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dy:"1.50838"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"arithmetic",k2:"-1",k3:"1"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"}),r.jsx("feBlend",{mode:"normal",in2:"shape",result:"effect4_innerShadow_1427_22275"})]}),r.jsxs("linearGradient",{id:"strokeGradientOuter_1427_22275",x1:"89.5",y1:"19",x2:"89.5",y2:"154",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:e}),r.jsx("stop",{offset:"1",stopColor:n})]}),r.jsxs("linearGradient",{id:"strokeGradientInner_1427_22275",x1:"89.4991",y1:"38.2849",x2:"89.4991",y2:"134.713",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:t}),r.jsx("stop",{offset:"1",stopColor:o})]})]})]})})}),B=f.memo(G),S=f.createContext({}),_=()=>f.useContext(S);function P({children:e,props:n}){const[t,o]=f.useState(!1),a=i=>{o(i)},s=()=>{o(!1)};return r.jsx(S.Provider,{value:{...n,onLoadingHandler:a,loading:t,onLoaded:s},children:e})}const M="https://connect-mw.dev.tap.company/middleware/v3/connect",H="https://connect-mw.dev.tap.company/middleware/v3/connect",$="https://connect-mw.dev.tap.company/middleware/v3/connect",K="tap-connect-sdk-iframe",j="https://connect.alpha.tap.company",W=({src:e})=>{const{loading:n}=_();return r.jsxs(r.Fragment,{children:[n&&r.jsx(B,{toggleAnimation:!0}),e&&r.jsx("iframe",{id:K,title:"connect",src:e,style:{width:"100%",height:"100%",border:"none",position:"absolute",top:0,left:0}})]})};var F=function(e){var n,t;return((t=(n=e==null?void 0:e.response)===null||n===void 0?void 0:n.data)===null||t===void 0?void 0:t.errors)!==void 0},Y=function(e){return e instanceof Error},q=function(e){return typeof e=="string"},V=function(e){try{var n=e.response.data.errors,t=n[0],o=t.description,a=t.code;return{message:o,code:a}}catch(s){return{message:s.message,code:"UNKNOWN"}}},z=function(e){try{var n=e.message,t=n.split("::"),o=t[0],a=t[1];return{message:a,code:o}}catch(s){return{message:s.message,code:"UNKNOWN"}}},J=function(e){try{var n=e.split("::"),t=n[0],o=n[1];return{message:o,code:t}}catch(a){return{message:a,code:"UNKNOWN"}}},X=function(){function e(n){if(Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"message",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),F(n)){var t=V(n);this.code=t.code,this.message=t.message}else if(Y(n)){var t=z(n);this.code=t.code,this.message=t.message}else if(q(n)){var t=J(n);this.code=t.code,this.message=t.message}else this.code="UNKNOWN",this.message="Unknown error"}return Object.defineProperty(e.prototype,"getCode",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.code}}),Object.defineProperty(e.prototype,"getMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.message}}),Object.defineProperty(e.prototype,"getClientError",{enumerable:!1,configurable:!0,writable:!0,value:function(){return{message:this.message,code:this.code}}}),e}();const Q=(e="tap-connect-sdk-element")=>{const n=document.getElementById(e);if(n)return n;const t=document.createElement("div");return t.setAttribute("id",e),document.body.prepend(t),t},Z=e=>e?["sa","sau"].includes(e.toLowerCase()):!1,ee=e=>e==="dr",te=(e="")=>{const[n,t]=e.split("-");return Z(n)?ee(t)?$:H:M},re=e=>{var n,t,o,a,s,i,l,d,p,C,N,E,O,A,w;return{operator:{public_key:e.publicKey},scope:e.scope,mode:e.mode||y.PAGE,domain:e.merchantDomain,...e.businessCountryCode&&{country:e.businessCountryCode},...e.data&&{data:e.data},board:{display:e.showBoard??!0,editable:e.boardEditable??!0},interface:{theme:e.theme||v.DYNAMIC,locale:e.language||b.DYNAMIC,edges:((n=e.features)==null?void 0:n.dialogEdgeFormat)||g.CURVED,parnter_logo:((t=e.features)==null?void 0:t.merchantLogo)??!1,dialog_transition:{start:((o=e.features)==null?void 0:o.dialogStartTransition)||x.UP,end:((a=e.features)==null?void 0:a.dialogEndTransition)||x.DOWN}},notification:{email:((s=e.notification)==null?void 0:s.email)??!1,sms:((i=e.notification)==null?void 0:i.sms)??!1},features:{poweredby:((l=e.features)==null?void 0:l.poweredBy)??!0,close_button:((d=e.features)==null?void 0:d.closeButton)??!1,embedded:((p=e.features)==null?void 0:p.embedded)??!1},...e.leadId&&{lead:{id:e.leadId}},...e.postUrl&&{post:{url:e.postUrl}},...e.redirectUrl&&{redirect:{url:e.redirectUrl}},...e.platforms&&{platforms:e.platforms},...(((C=e.paymentProvider)==null?void 0:C.institutionId)||((N=e.paymentProvider)==null?void 0:N.technologyId))&&{payment_provider:{...((E=e.paymentProvider)==null?void 0:E.institutionId)&&{institution:{id:(O=e.paymentProvider)==null?void 0:O.institutionId}},...((A=e.paymentProvider)==null?void 0:A.technologyId)&&{technology:{id:(w=e.paymentProvider)==null?void 0:w.technologyId}}}},app_info:{name:window.location.hostname||window.location.origin,version:"0.0.34-test"}}},ne=({theme:e,language:n,configToken:t,flow:o,token:a,boardId:s})=>{const i=new URLSearchParams;let l="";return o&&(l=o,o===h.BOARD&&s?i.append(u.BOARD_ID,s):o!==h.AUTH&&a&&i.append(u.AUTH_TOKEN,a)),e&&i.append(u.THEME,e),n&&i.append(u.LANGUAGE,n),i.append(u.CONFIG_TOKEN,t),`${j}/${l}?${i.toString()}`},oe=async e=>{const n=await fetch(te(e.region),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.publicKey}`,mdn:e.merchantDomain||j},body:JSON.stringify(re(e))});if(!n.ok)throw new Error(`${n.status}::${n.statusText}`);return n.json()},ae=()=>{const[e,n]=m.useState(""),t=_(),o=async()=>{var a,s,i;t.onLoadingHandler(!0);try{let l=t.configToken,d;if(!l){if(d=await oe(t),!d.token)throw new Error("500::Config token is missing");l=d.token}const p=ne({theme:(a=d==null?void 0:d.interface)==null?void 0:a.theme,language:(s=d==null?void 0:d.interface)==null?void 0:s.locale,configToken:l,flow:t.flow,token:t.token,boardId:t.boardId});if(t.mode!==y.PAGE)return n(p);window.location.href=p}catch(l){const d=new X(l);(i=t.onError)==null||i.call(t,d.getClientError()),t.onLoadingHandler(!1)}};return m.useEffect(()=>{o()},[]),{connectLink:e}},se=()=>{const{onSuccess:e,onClose:n,onError:t,onReady:o,onLoaded:a}=_(),s=m.useCallback(async i=>{if(i.origin!==j)return;const{data:l,event:d}=i.data;switch(d){case c.ON_CLOSE:n==null||n();break;case c.ON_ERROR:t==null||t(l);break;case c.ON_SUCCESS:e==null||e(l);break;case c.ON_LOADED:a();break;case c.ON_READY:o==null||o();break}},[n,t,a,o,e]);m.useEffect(()=>(window.addEventListener("message",s,!1),()=>{window.removeEventListener("message",s)}),[s])},ie=()=>{const{connectLink:e}=ae();return se(),r.jsx("div",{id:"tap-connect-main-container",style:{display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.5)",position:"fixed",top:0,left:0,width:"100%",height:"100%"},children:r.jsx(W,{src:e})})},de=e=>r.jsx(P,{props:e,children:e.open&&r.jsx(ie,{})}),R=m.memo(de);var U,k=D;U=k.createRoot,k.hydrateRoot;const le=(e,n)=>{const t=Q(e),o=U(t);return o.render(r.jsx(R,{...n})),{unmount:()=>o.unmount()}};exports.ConnectDialogEdgeFormat=g;exports.ConnectDialogTransition=x;exports.ConnectElement=R;exports.ConnectFlows=h;exports.ConnectLanguage=b;exports.ConnectMode=y;exports.ConnectRegions=T;exports.ConnectScope=I;exports.ConnectTheme=v;exports.renderConnectElement=le;
package/build/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import * as React_2 from 'react';
3
3
 
4
4
  declare type ConnectAppFeatures = {
5
5
  poweredBy?: boolean;
6
+ embedded?: boolean;
6
7
  merchantLogo?: boolean;
7
8
  closeButton?: boolean;
8
9
  dialogStartTransition?: ConnectDialogTransition;
@@ -10,12 +11,6 @@ declare type ConnectAppFeatures = {
10
11
  dialogEdgeFormat?: ConnectDialogEdgeFormat;
11
12
  };
12
13
 
13
- export declare type ConnectAppInfo = {
14
- name: string;
15
- identifier?: string;
16
- version?: string;
17
- };
18
-
19
14
  export declare enum ConnectDialogEdgeFormat {
20
15
  STRAIGHT = "straight",
21
16
  CURVED = "curved"
@@ -30,9 +25,22 @@ export declare enum ConnectDialogTransition {
30
25
 
31
26
  export declare const ConnectElement: React_2.MemoExoticComponent<(props: ConnectProps) => JSX_2.Element>;
32
27
 
28
+ export declare enum ConnectFlows {
29
+ AUTH = "auth",
30
+ BANK = "bank",
31
+ BOARD = "board",
32
+ BRAND = "brand",
33
+ ENTITY = "entity",
34
+ INDIVIDUAL = "individual",
35
+ KYC = "kyc",
36
+ TAX = "tax",
37
+ TERMINAL = "terminal"
38
+ }
39
+
33
40
  export declare enum ConnectLanguage {
34
41
  AR = "ar",
35
- EN = "en"
42
+ EN = "en",
43
+ DYNAMIC = "dynamic"
36
44
  }
37
45
 
38
46
  export declare enum ConnectMode {
@@ -43,52 +51,49 @@ export declare enum ConnectMode {
43
51
 
44
52
  export declare type ConnectNotification = {
45
53
  email: boolean;
46
- mobile?: boolean;
54
+ sms?: boolean;
47
55
  };
48
56
 
49
- export declare enum ConnectPasswordOperationType {
50
- SET_PASSWORD = "set_password",
51
- RESET_PASSWORD = "reset_password"
52
- }
53
-
54
57
  export declare type ConnectPaymentProvider = {
55
58
  technologyId: string;
56
- settlementBy: string;
59
+ institutionId: string;
57
60
  };
58
61
 
59
62
  export declare type ConnectProps = {
60
63
  onClose?: () => void;
61
- onSuccess: (res: Record<string, string | number>) => void;
64
+ onSuccess?: (res: Record<string, string | number>) => void;
62
65
  onError?: (error: CustomError) => void;
63
66
  onReady?: () => void;
64
67
  open: boolean;
65
- theme?: ConnectTheme;
66
- language?: ConnectLanguage;
67
68
  publicKey: string;
69
+ scope: ConnectScope;
68
70
  merchantDomain: string;
69
- appInfo: ConnectAppInfo;
71
+ theme?: ConnectTheme;
72
+ language?: ConnectLanguage;
70
73
  businessCountryCode?: string;
71
- scope: ConnectScope;
72
- showBoard?: boolean;
73
74
  leadId?: string;
75
+ showBoard?: boolean;
76
+ boardEditable?: boolean;
74
77
  platforms?: Array<string>;
75
- paymentProvider?: ConnectPaymentProvider;
76
78
  features?: ConnectAppFeatures;
79
+ paymentProvider?: ConnectPaymentProvider;
77
80
  postUrl?: string;
78
81
  redirectUrl?: string;
79
82
  data?: Array<string>;
80
83
  mode?: ConnectMode;
81
84
  notification?: ConnectNotification;
82
- boardEditable?: boolean;
85
+ token?: string;
83
86
  boardId?: string;
84
- boardInfoId?: string;
85
- userId?: string;
86
- userType?: string;
87
- operationType?: ConnectPasswordOperationType;
88
- loginMode?: boolean;
89
- region?: string;
87
+ flow?: ConnectFlows;
88
+ configToken?: string;
89
+ region?: ConnectRegions;
90
90
  };
91
91
 
92
+ export declare enum ConnectRegions {
93
+ SA = "sa",
94
+ SA_DR = "sa-dr"
95
+ }
96
+
92
97
  export declare enum ConnectScope {
93
98
  AUTH = "auth",
94
99
  MERCHANT = "merchant"
@@ -96,10 +101,11 @@ export declare enum ConnectScope {
96
101
 
97
102
  export declare enum ConnectTheme {
98
103
  DARK = "dark",
99
- LIGHT = "light"
104
+ LIGHT = "light",
105
+ DYNAMIC = "dynamic"
100
106
  }
101
107
 
102
- declare type CustomError = {
108
+ export declare type CustomError = {
103
109
  code: string;
104
110
  message: string;
105
111
  };
@@ -1,16 +1,16 @@
1
- import { jsx as r, jsxs as l, Fragment as y } from "react/jsx-runtime";
2
- import * as p from "react";
3
- import _ from "react";
4
- import w from "react-dom";
5
- var C = /* @__PURE__ */ ((e) => (e.PAGE = "page", e.POPUP = "popup", e.CONTENT = "content", e))(C || {}), x = /* @__PURE__ */ ((e) => (e.AUTH = "auth", e.MERCHANT = "merchant", e))(x || {}), k = /* @__PURE__ */ ((e) => (e.SET_PASSWORD = "set_password", e.RESET_PASSWORD = "reset_password", e))(k || {}), S = /* @__PURE__ */ ((e) => (e.DARK = "dark", e.LIGHT = "light", e))(S || {}), A = /* @__PURE__ */ ((e) => (e.AR = "ar", e.EN = "en", e))(A || {}), R = /* @__PURE__ */ ((e) => (e.STRAIGHT = "straight", e.CURVED = "curved", e))(R || {}), L = /* @__PURE__ */ ((e) => (e.LEFT = "left", e.RIGHT = "right", e.UP = "up", e.DOWN = "down", e))(L || {}), u = /* @__PURE__ */ ((e) => (e.ON_CLOSE = "connect:onClose", e.ON_ERROR = "connect:onError", e.ON_SUCCESS = "connect:onSuccess", e.ON_READY = "connect:onReady", e.ON_LOADED = "connect:onLoaded", e))(u || {}), f = /* @__PURE__ */ ((e) => (e.PROFILE_TOKEN = "profile_token", e.CONFIG_TOKEN = "config_token", e.THEME = "theme", e.LANGUAGE = "lang", e))(f || {});
6
- const I = ({
1
+ import { jsx as n, jsxs as u, Fragment as y } from "react/jsx-runtime";
2
+ import * as f from "react";
3
+ import h from "react";
4
+ import D from "react-dom";
5
+ var N = /* @__PURE__ */ ((e) => (e.PAGE = "page", e.POPUP = "popup", e.CONTENT = "content", e))(N || {}), L = /* @__PURE__ */ ((e) => (e.AUTH = "auth", e.MERCHANT = "merchant", e))(L || {}), v = /* @__PURE__ */ ((e) => (e.AUTH = "auth", e.BANK = "bank", e.BOARD = "board", e.BRAND = "brand", e.ENTITY = "entity", e.INDIVIDUAL = "individual", e.KYC = "kyc", e.TAX = "tax", e.TERMINAL = "terminal", e))(v || {}), G = /* @__PURE__ */ ((e) => (e.SA = "sa", e.SA_DR = "sa-dr", e))(G || {}), I = /* @__PURE__ */ ((e) => (e.DARK = "dark", e.LIGHT = "light", e.DYNAMIC = "dynamic", e))(I || {}), U = /* @__PURE__ */ ((e) => (e.AR = "ar", e.EN = "en", e.DYNAMIC = "dynamic", e))(U || {}), R = /* @__PURE__ */ ((e) => (e.STRAIGHT = "straight", e.CURVED = "curved", e))(R || {}), _ = /* @__PURE__ */ ((e) => (e.LEFT = "left", e.RIGHT = "right", e.UP = "up", e.DOWN = "down", e))(_ || {}), c = /* @__PURE__ */ ((e) => (e.ON_CLOSE = "connect:onClose", e.ON_ERROR = "connect:onError", e.ON_SUCCESS = "connect:onSuccess", e.ON_READY = "connect:onReady", e.ON_LOADED = "connect:onLoaded", e))(c || {}), p = /* @__PURE__ */ ((e) => (e.AUTH_TOKEN = "token", e.CONFIG_TOKEN = "config_token", e.THEME = "theme", e.LANGUAGE = "lang", e.BOARD_ID = "board_id", e))(p || {});
6
+ const B = ({
7
7
  outerStartColor: e = "rgba(244, 244, 244, 1)",
8
- outerEndColor: o = "rgba(238, 238, 238, 1)",
8
+ outerEndColor: r = "rgba(238, 238, 238, 1)",
9
9
  innerStartColor: t = "rgba(244, 244, 244, 1)",
10
- innerEndColor: n = "rgba(238, 238, 238, 1)",
10
+ innerEndColor: o = "rgba(238, 238, 238, 1)",
11
11
  duration: a = 3,
12
- toggleAnimation: i = !1
13
- }) => /* @__PURE__ */ r(
12
+ toggleAnimation: s = !1
13
+ }) => /* @__PURE__ */ n(
14
14
  "div",
15
15
  {
16
16
  style: {
@@ -18,7 +18,7 @@ const I = ({
18
18
  width: "135px",
19
19
  height: "135px"
20
20
  },
21
- children: /* @__PURE__ */ r(
21
+ children: /* @__PURE__ */ n(
22
22
  "div",
23
23
  {
24
24
  style: {
@@ -30,9 +30,9 @@ const I = ({
30
30
  height: "100%",
31
31
  opacity: 0.9
32
32
  },
33
- children: /* @__PURE__ */ l("svg", { width: "199", height: "197", viewBox: "0 0 199 197", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
34
- /* @__PURE__ */ l("g", { children: [
35
- /* @__PURE__ */ r(
33
+ children: /* @__PURE__ */ u("svg", { width: "199", height: "197", viewBox: "0 0 199 197", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
34
+ /* @__PURE__ */ u("g", { children: [
35
+ /* @__PURE__ */ n(
36
36
  "circle",
37
37
  {
38
38
  cx: "89.5",
@@ -43,8 +43,8 @@ const I = ({
43
43
  strokeWidth: "9.6",
44
44
  strokeLinecap: "round",
45
45
  strokeDasharray: "425 125",
46
- children: i && /* @__PURE__ */ l(y, { children: [
47
- /* @__PURE__ */ r(
46
+ children: s && /* @__PURE__ */ u(y, { children: [
47
+ /* @__PURE__ */ n(
48
48
  "animateTransform",
49
49
  {
50
50
  attributeName: "transform",
@@ -55,7 +55,7 @@ const I = ({
55
55
  repeatCount: "indefinite"
56
56
  }
57
57
  ),
58
- /* @__PURE__ */ r(
58
+ /* @__PURE__ */ n(
59
59
  "animate",
60
60
  {
61
61
  attributeName: "stroke-dashoffset",
@@ -68,7 +68,7 @@ const I = ({
68
68
  ] })
69
69
  }
70
70
  ),
71
- /* @__PURE__ */ r(
71
+ /* @__PURE__ */ n(
72
72
  "circle",
73
73
  {
74
74
  cx: "89.5",
@@ -79,8 +79,8 @@ const I = ({
79
79
  strokeWidth: "9.6",
80
80
  strokeLinecap: "round",
81
81
  strokeDasharray: "300 100",
82
- children: i && /* @__PURE__ */ l(y, { children: [
83
- /* @__PURE__ */ r(
82
+ children: s && /* @__PURE__ */ u(y, { children: [
83
+ /* @__PURE__ */ n(
84
84
  "animateTransform",
85
85
  {
86
86
  attributeName: "transform",
@@ -91,7 +91,7 @@ const I = ({
91
91
  repeatCount: "indefinite"
92
92
  }
93
93
  ),
94
- /* @__PURE__ */ r(
94
+ /* @__PURE__ */ n(
95
95
  "animate",
96
96
  {
97
97
  attributeName: "stroke-dashoffset",
@@ -105,8 +105,8 @@ const I = ({
105
105
  }
106
106
  )
107
107
  ] }),
108
- /* @__PURE__ */ l("defs", { children: [
109
- /* @__PURE__ */ l(
108
+ /* @__PURE__ */ u("defs", { children: [
109
+ /* @__PURE__ */ u(
110
110
  "filter",
111
111
  {
112
112
  id: "filter0_dddi_1427_22275",
@@ -117,8 +117,8 @@ const I = ({
117
117
  filterUnits: "userSpaceOnUse",
118
118
  colorInterpolationFilters: "sRGB",
119
119
  children: [
120
- /* @__PURE__ */ r("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }),
121
- /* @__PURE__ */ r(
120
+ /* @__PURE__ */ n("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }),
121
+ /* @__PURE__ */ n(
122
122
  "feColorMatrix",
123
123
  {
124
124
  in: "SourceAlpha",
@@ -127,12 +127,12 @@ const I = ({
127
127
  result: "hardAlpha"
128
128
  }
129
129
  ),
130
- /* @__PURE__ */ r("feOffset", { dy: "1.68224" }),
131
- /* @__PURE__ */ r("feGaussianBlur", { stdDeviation: "4.20656" }),
132
- /* @__PURE__ */ r("feComposite", { in2: "hardAlpha", operator: "out" }),
133
- /* @__PURE__ */ r("feColorMatrix", { type: "matrix", values: "0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 1 0" }),
134
- /* @__PURE__ */ r("feBlend", { mode: "normal", in2: "BackgroundImageFix", result: "effect1_dropShadow_1427_22275" }),
135
- /* @__PURE__ */ r(
130
+ /* @__PURE__ */ n("feOffset", { dy: "1.68224" }),
131
+ /* @__PURE__ */ n("feGaussianBlur", { stdDeviation: "4.20656" }),
132
+ /* @__PURE__ */ n("feComposite", { in2: "hardAlpha", operator: "out" }),
133
+ /* @__PURE__ */ n("feColorMatrix", { type: "matrix", values: "0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 1 0" }),
134
+ /* @__PURE__ */ n("feBlend", { mode: "normal", in2: "BackgroundImageFix", result: "effect1_dropShadow_1427_22275" }),
135
+ /* @__PURE__ */ n(
136
136
  "feColorMatrix",
137
137
  {
138
138
  in: "SourceAlpha",
@@ -141,12 +141,12 @@ const I = ({
141
141
  result: "hardAlpha"
142
142
  }
143
143
  ),
144
- /* @__PURE__ */ r("feOffset", { dx: "22.3542", dy: "22.6047" }),
145
- /* @__PURE__ */ r("feGaussianBlur", { stdDeviation: "9.80447" }),
146
- /* @__PURE__ */ r("feComposite", { in2: "hardAlpha", operator: "out" }),
147
- /* @__PURE__ */ r("feColorMatrix", { type: "matrix", values: "0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0.6 0" }),
148
- /* @__PURE__ */ r("feBlend", { mode: "normal", in2: "effect1_dropShadow_1427_22275", result: "effect2_dropShadow_1427_22275" }),
149
- /* @__PURE__ */ r(
144
+ /* @__PURE__ */ n("feOffset", { dx: "22.3542", dy: "22.6047" }),
145
+ /* @__PURE__ */ n("feGaussianBlur", { stdDeviation: "9.80447" }),
146
+ /* @__PURE__ */ n("feComposite", { in2: "hardAlpha", operator: "out" }),
147
+ /* @__PURE__ */ n("feColorMatrix", { type: "matrix", values: "0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0.6 0" }),
148
+ /* @__PURE__ */ n("feBlend", { mode: "normal", in2: "effect1_dropShadow_1427_22275", result: "effect2_dropShadow_1427_22275" }),
149
+ /* @__PURE__ */ n(
150
150
  "feColorMatrix",
151
151
  {
152
152
  in: "SourceAlpha",
@@ -155,13 +155,13 @@ const I = ({
155
155
  result: "hardAlpha"
156
156
  }
157
157
  ),
158
- /* @__PURE__ */ r("feOffset", { dx: "-6.03352", dy: "-3.01676" }),
159
- /* @__PURE__ */ r("feGaussianBlur", { stdDeviation: "7.5419" }),
160
- /* @__PURE__ */ r("feComposite", { in2: "hardAlpha", operator: "out" }),
161
- /* @__PURE__ */ r("feColorMatrix", { type: "matrix", values: "0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.7 0" }),
162
- /* @__PURE__ */ r("feBlend", { mode: "normal", in2: "effect2_dropShadow_1427_22275", result: "effect3_dropShadow_1427_22275" }),
163
- /* @__PURE__ */ r("feBlend", { mode: "normal", in: "SourceGraphic", in2: "effect3_dropShadow_1427_22275", result: "shape" }),
164
- /* @__PURE__ */ r(
158
+ /* @__PURE__ */ n("feOffset", { dx: "-6.03352", dy: "-3.01676" }),
159
+ /* @__PURE__ */ n("feGaussianBlur", { stdDeviation: "7.5419" }),
160
+ /* @__PURE__ */ n("feComposite", { in2: "hardAlpha", operator: "out" }),
161
+ /* @__PURE__ */ n("feColorMatrix", { type: "matrix", values: "0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.7 0" }),
162
+ /* @__PURE__ */ n("feBlend", { mode: "normal", in2: "effect2_dropShadow_1427_22275", result: "effect3_dropShadow_1427_22275" }),
163
+ /* @__PURE__ */ n("feBlend", { mode: "normal", in: "SourceGraphic", in2: "effect3_dropShadow_1427_22275", result: "shape" }),
164
+ /* @__PURE__ */ n(
165
165
  "feColorMatrix",
166
166
  {
167
167
  in: "SourceAlpha",
@@ -170,14 +170,14 @@ const I = ({
170
170
  result: "hardAlpha"
171
171
  }
172
172
  ),
173
- /* @__PURE__ */ r("feOffset", { dy: "1.50838" }),
174
- /* @__PURE__ */ r("feComposite", { in2: "hardAlpha", operator: "arithmetic", k2: "-1", k3: "1" }),
175
- /* @__PURE__ */ r("feColorMatrix", { type: "matrix", values: "0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0" }),
176
- /* @__PURE__ */ r("feBlend", { mode: "normal", in2: "shape", result: "effect4_innerShadow_1427_22275" })
173
+ /* @__PURE__ */ n("feOffset", { dy: "1.50838" }),
174
+ /* @__PURE__ */ n("feComposite", { in2: "hardAlpha", operator: "arithmetic", k2: "-1", k3: "1" }),
175
+ /* @__PURE__ */ n("feColorMatrix", { type: "matrix", values: "0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0" }),
176
+ /* @__PURE__ */ n("feBlend", { mode: "normal", in2: "shape", result: "effect4_innerShadow_1427_22275" })
177
177
  ]
178
178
  }
179
179
  ),
180
- /* @__PURE__ */ l(
180
+ /* @__PURE__ */ u(
181
181
  "linearGradient",
182
182
  {
183
183
  id: "strokeGradientOuter_1427_22275",
@@ -187,12 +187,12 @@ const I = ({
187
187
  y2: "154",
188
188
  gradientUnits: "userSpaceOnUse",
189
189
  children: [
190
- /* @__PURE__ */ r("stop", { stopColor: e }),
191
- /* @__PURE__ */ r("stop", { offset: "1", stopColor: o })
190
+ /* @__PURE__ */ n("stop", { stopColor: e }),
191
+ /* @__PURE__ */ n("stop", { offset: "1", stopColor: r })
192
192
  ]
193
193
  }
194
194
  ),
195
- /* @__PURE__ */ l(
195
+ /* @__PURE__ */ u(
196
196
  "linearGradient",
197
197
  {
198
198
  id: "strokeGradientInner_1427_22275",
@@ -202,8 +202,8 @@ const I = ({
202
202
  y2: "134.713",
203
203
  gradientUnits: "userSpaceOnUse",
204
204
  children: [
205
- /* @__PURE__ */ r("stop", { stopColor: t }),
206
- /* @__PURE__ */ r("stop", { offset: "1", stopColor: n })
205
+ /* @__PURE__ */ n("stop", { stopColor: t }),
206
+ /* @__PURE__ */ n("stop", { offset: "1", stopColor: o })
207
207
  ]
208
208
  }
209
209
  )
@@ -212,23 +212,23 @@ const I = ({
212
212
  }
213
213
  )
214
214
  }
215
- ), U = _.memo(I), b = _.createContext({}), v = () => _.useContext(b);
216
- function T({ children: e, props: o }) {
217
- const [t, n] = _.useState(!1), a = (s) => {
218
- n(s);
219
- }, i = () => {
220
- n(!1);
215
+ ), P = h.memo(B), T = h.createContext({}), E = () => h.useContext(T);
216
+ function H({ children: e, props: r }) {
217
+ const [t, o] = h.useState(!1), a = (i) => {
218
+ o(i);
219
+ }, s = () => {
220
+ o(!1);
221
221
  };
222
- return /* @__PURE__ */ r(b.Provider, { value: { ...o, onLoadingHandler: a, loading: t, onLoaded: i }, children: e });
222
+ return /* @__PURE__ */ n(T.Provider, { value: { ...r, onLoadingHandler: a, loading: t, onLoaded: s }, children: e });
223
223
  }
224
- const G = "https://connect-mw.dev.tap.company/middleware/v3/connect", B = "https://connect-mw.dev.tap.company/middleware/v3/connect", D = "https://connect-mw.dev.tap.company/middleware/v3/connect", F = "tap-connect-sdk-iframe", g = "https://connect.alpha.tap.company", $ = ({ src: e }) => {
225
- const { loading: o } = v();
226
- return /* @__PURE__ */ l(y, { children: [
227
- o && /* @__PURE__ */ r(U, { toggleAnimation: !0 }),
228
- e && /* @__PURE__ */ r(
224
+ const M = "https://connect-mw.dev.tap.company/middleware/v3/connect", $ = "https://connect-mw.dev.tap.company/middleware/v3/connect", K = "https://connect-mw.dev.tap.company/middleware/v3/connect", j = "tap-connect-sdk-iframe", b = "https://connect.alpha.tap.company", W = ({ src: e }) => {
225
+ const { loading: r } = E();
226
+ return /* @__PURE__ */ u(y, { children: [
227
+ r && /* @__PURE__ */ n(P, { toggleAnimation: !0 }),
228
+ e && /* @__PURE__ */ n(
229
229
  "iframe",
230
230
  {
231
- id: F,
231
+ id: j,
232
232
  title: "connect",
233
233
  src: e,
234
234
  style: {
@@ -243,44 +243,44 @@ const G = "https://connect-mw.dev.tap.company/middleware/v3/connect", B = "https
243
243
  )
244
244
  ] });
245
245
  };
246
- var j = function(e) {
247
- var o, t;
248
- return ((t = (o = e == null ? void 0 : e.response) === null || o === void 0 ? void 0 : o.data) === null || t === void 0 ? void 0 : t.errors) !== void 0;
249
- }, M = function(e) {
246
+ var Y = function(e) {
247
+ var r, t;
248
+ return ((t = (r = e == null ? void 0 : e.response) === null || r === void 0 ? void 0 : r.data) === null || t === void 0 ? void 0 : t.errors) !== void 0;
249
+ }, F = function(e) {
250
250
  return e instanceof Error;
251
- }, H = function(e) {
251
+ }, V = function(e) {
252
252
  return typeof e == "string";
253
- }, W = function(e) {
253
+ }, q = function(e) {
254
254
  try {
255
- var o = e.response.data.errors, t = o[0], n = t.description, a = t.code;
255
+ var r = e.response.data.errors, t = r[0], o = t.description, a = t.code;
256
256
  return {
257
- message: n,
257
+ message: o,
258
258
  code: a
259
259
  };
260
- } catch (i) {
260
+ } catch (s) {
261
261
  return {
262
- message: i.message,
262
+ message: s.message,
263
263
  code: "UNKNOWN"
264
264
  };
265
265
  }
266
- }, K = function(e) {
266
+ }, z = function(e) {
267
267
  try {
268
- var o = e.message, t = o.split("::"), n = t[0], a = t[1];
268
+ var r = e.message, t = r.split("::"), o = t[0], a = t[1];
269
269
  return {
270
270
  message: a,
271
- code: n
271
+ code: o
272
272
  };
273
- } catch (i) {
273
+ } catch (s) {
274
274
  return {
275
- message: i.message,
275
+ message: s.message,
276
276
  code: "UNKNOWN"
277
277
  };
278
278
  }
279
- }, P = function(e) {
279
+ }, J = function(e) {
280
280
  try {
281
- var o = e.split("::"), t = o[0], n = o[1];
281
+ var r = e.split("::"), t = r[0], o = r[1];
282
282
  return {
283
- message: n,
283
+ message: o,
284
284
  code: t
285
285
  };
286
286
  } catch (a) {
@@ -289,8 +289,8 @@ var j = function(e) {
289
289
  code: "UNKNOWN"
290
290
  };
291
291
  }
292
- }, Y = function() {
293
- function e(o) {
292
+ }, X = function() {
293
+ function e(r) {
294
294
  if (Object.defineProperty(this, "code", {
295
295
  enumerable: !0,
296
296
  configurable: !0,
@@ -301,14 +301,14 @@ var j = function(e) {
301
301
  configurable: !0,
302
302
  writable: !0,
303
303
  value: void 0
304
- }), j(o)) {
305
- var t = W(o);
304
+ }), Y(r)) {
305
+ var t = q(r);
306
306
  this.code = t.code, this.message = t.message;
307
- } else if (M(o)) {
308
- var t = K(o);
307
+ } else if (F(r)) {
308
+ var t = z(r);
309
309
  this.code = t.code, this.message = t.message;
310
- } else if (H(o)) {
311
- var t = P(o);
310
+ } else if (V(r)) {
311
+ var t = J(r);
312
312
  this.code = t.code, this.message = t.message;
313
313
  } else
314
314
  this.code = "UNKNOWN", this.message = "Unknown error";
@@ -339,126 +339,137 @@ var j = function(e) {
339
339
  }
340
340
  }), e;
341
341
  }();
342
- const q = (e = "tap-connect-sdk-element") => {
343
- const o = document.getElementById(e);
344
- if (o) return o;
342
+ const Q = (e = "tap-connect-sdk-element") => {
343
+ const r = document.getElementById(e);
344
+ if (r) return r;
345
345
  const t = document.createElement("div");
346
346
  return t.setAttribute("id", e), document.body.prepend(t), t;
347
- }, z = (e) => e ? ["sa", "sau"].includes(e.toLowerCase()) : !1, J = (e) => e === "dr", V = (e = "") => {
348
- const [o, t] = e.split("-");
349
- return z(o) ? J(t) ? D : B : G;
350
- }, Q = ({
351
- features: e,
352
- notification: o,
353
- paymentProvider: t,
354
- ...n
355
- }) => {
356
- var a;
347
+ }, Z = (e) => e ? ["sa", "sau"].includes(e.toLowerCase()) : !1, ee = (e) => e === "dr", te = (e = "") => {
348
+ const [r, t] = e.split("-");
349
+ return Z(r) ? ee(t) ? K : $ : M;
350
+ }, re = (e) => {
351
+ var r, t, o, a, s, i, l, d, m, O, C, g, A, w, k;
357
352
  return {
358
- open: n.open,
359
- operator: { public_key: n.publicKey },
360
- domain: n.merchantDomain,
361
- app_info: n.appInfo,
362
- country: n.businessCountryCode,
363
- scope: n.scope,
364
- board: { display: n.showBoard, editable: n.boardEditable },
365
- ...n.leadId && { lead: { id: n.leadId } },
366
- ...((a = n.platforms) == null ? void 0 : a.length) && { platforms: n.platforms },
367
- ...((t == null ? void 0 : t.technologyId) || (t == null ? void 0 : t.settlementBy)) && {
368
- payment_provider: {
369
- ...t.technologyId && {
370
- technology: {
371
- id: t.technologyId
372
- }
373
- },
374
- ...t.settlementBy && {
375
- institution: {
376
- id: t.settlementBy
377
- }
378
- }
353
+ operator: { public_key: e.publicKey },
354
+ scope: e.scope,
355
+ mode: e.mode || N.PAGE,
356
+ domain: e.merchantDomain,
357
+ ...e.businessCountryCode && { country: e.businessCountryCode },
358
+ ...e.data && { data: e.data },
359
+ board: {
360
+ display: e.showBoard ?? !0,
361
+ editable: e.boardEditable ?? !0
362
+ },
363
+ interface: {
364
+ theme: e.theme || I.DYNAMIC,
365
+ locale: e.language || U.DYNAMIC,
366
+ edges: ((r = e.features) == null ? void 0 : r.dialogEdgeFormat) || R.CURVED,
367
+ parnter_logo: ((t = e.features) == null ? void 0 : t.merchantLogo) ?? !1,
368
+ dialog_transition: {
369
+ start: ((o = e.features) == null ? void 0 : o.dialogStartTransition) || _.UP,
370
+ end: ((a = e.features) == null ? void 0 : a.dialogEndTransition) || _.DOWN
379
371
  }
380
372
  },
381
- features: e && {
382
- poweredby: e.poweredBy,
383
- close_button: e.closeButton
373
+ notification: {
374
+ email: ((s = e.notification) == null ? void 0 : s.email) ?? !1,
375
+ sms: ((i = e.notification) == null ? void 0 : i.sms) ?? !1
384
376
  },
385
- ...n.postUrl && { post: { url: n.postUrl } },
386
- ...n.redirectUrl && { redirect: { url: n.redirectUrl } },
387
- data: n.data,
388
- mode: n.mode,
389
- notification: o && {
390
- sms: o.mobile,
391
- email: o.email
377
+ features: {
378
+ poweredby: ((l = e.features) == null ? void 0 : l.poweredBy) ?? !0,
379
+ close_button: ((d = e.features) == null ? void 0 : d.closeButton) ?? !1,
380
+ embedded: ((m = e.features) == null ? void 0 : m.embedded) ?? !1
392
381
  },
393
- interface: {
394
- ...(e == null ? void 0 : e.dialogEdgeFormat) && { edges: e.dialogEdgeFormat },
395
- locale: n.language,
396
- theme: n.theme,
397
- partner_logo: e == null ? void 0 : e.merchantLogo,
398
- ...(e == null ? void 0 : e.dialogEndTransition) && (e == null ? void 0 : e.dialogStartTransition) && {
399
- dialog_transition: { start: e.dialogStartTransition, end: e.dialogEndTransition }
382
+ ...e.leadId && { lead: { id: e.leadId } },
383
+ ...e.postUrl && { post: { url: e.postUrl } },
384
+ ...e.redirectUrl && { redirect: { url: e.redirectUrl } },
385
+ ...e.platforms && { platforms: e.platforms },
386
+ ...(((O = e.paymentProvider) == null ? void 0 : O.institutionId) || ((C = e.paymentProvider) == null ? void 0 : C.technologyId)) && {
387
+ payment_provider: {
388
+ ...((g = e.paymentProvider) == null ? void 0 : g.institutionId) && { institution: { id: (A = e.paymentProvider) == null ? void 0 : A.institutionId } },
389
+ ...((w = e.paymentProvider) == null ? void 0 : w.technologyId) && { technology: { id: (k = e.paymentProvider) == null ? void 0 : k.technologyId } }
400
390
  }
391
+ },
392
+ app_info: {
393
+ name: window.location.hostname || window.location.origin,
394
+ version: "0.0.34-test"
401
395
  }
402
396
  };
403
- }, X = () => {
404
- const [e, o] = p.useState(""), { onError: t, onLoadingHandler: n, loginMode: a, region: i, ...s } = v(), m = async () => {
405
- n(!0);
397
+ }, ne = ({ theme: e, language: r, configToken: t, flow: o, token: a, boardId: s }) => {
398
+ const i = new URLSearchParams();
399
+ let l = "";
400
+ return o && (l = o, o === v.BOARD && s ? i.append(p.BOARD_ID, s) : o !== v.AUTH && a && i.append(p.AUTH_TOKEN, a)), e && i.append(p.THEME, e), r && i.append(p.LANGUAGE, r), i.append(p.CONFIG_TOKEN, t), `${b}/${l}?${i.toString()}`;
401
+ }, oe = async (e) => {
402
+ const r = await fetch(te(e.region), {
403
+ method: "POST",
404
+ headers: {
405
+ "Content-Type": "application/json",
406
+ Authorization: `Bearer ${e.publicKey}`,
407
+ mdn: e.merchantDomain || b
408
+ },
409
+ body: JSON.stringify(re(e))
410
+ });
411
+ if (!r.ok)
412
+ throw new Error(`${r.status}::${r.statusText}`);
413
+ return r.json();
414
+ }, ae = () => {
415
+ const [e, r] = f.useState(""), t = E(), o = async () => {
416
+ var a, s, i;
417
+ t.onLoadingHandler(!0);
406
418
  try {
407
- const d = await fetch(V(i), {
408
- method: "POST",
409
- headers: {
410
- "Content-Type": "application/json",
411
- Authorization: `Bearer ${s.publicKey}`,
412
- mdn: s.merchantDomain || g
413
- },
414
- body: JSON.stringify(Q(s))
419
+ let l = t.configToken, d;
420
+ if (!l) {
421
+ if (d = await oe(t), !d.token) throw new Error("500::Config token is missing");
422
+ l = d.token;
423
+ }
424
+ const m = ne({
425
+ theme: (a = d == null ? void 0 : d.interface) == null ? void 0 : a.theme,
426
+ language: (s = d == null ? void 0 : d.interface) == null ? void 0 : s.locale,
427
+ configToken: l,
428
+ flow: t.flow,
429
+ token: t.token,
430
+ boardId: t.boardId
415
431
  });
416
- if (!d.ok)
417
- throw new Error(`${d.status}::${d.statusText}`);
418
- const c = await d.json(), h = new URLSearchParams();
419
- s != null && s.theme && h.append(f.THEME, s.theme), s != null && s.language && h.append(f.LANGUAGE, s.language);
420
- const O = a ? `${g}/auth` : g;
421
- if (h.append(f.CONFIG_TOKEN, c.token), c.connect.url = `${O}?${h.toString()}`, s.mode !== C.PAGE) return o(c.connect.url);
422
- window.location.href = c.connect.url;
423
- } catch (d) {
424
- const c = new Y(d);
425
- t == null || t(c.getClientError()), n(!1);
432
+ if (t.mode !== N.PAGE) return r(m);
433
+ window.location.href = m;
434
+ } catch (l) {
435
+ const d = new X(l);
436
+ (i = t.onError) == null || i.call(t, d.getClientError()), t.onLoadingHandler(!1);
426
437
  }
427
438
  };
428
- return p.useEffect(() => {
429
- m();
439
+ return f.useEffect(() => {
440
+ o();
430
441
  }, []), { connectLink: e };
431
- }, Z = () => {
432
- const { onSuccess: e, onClose: o, onError: t, onReady: n, onLoaded: a } = v(), i = p.useCallback(
433
- async (s) => {
434
- if (s.origin !== g) return;
435
- const { data: m, event: d } = s.data;
442
+ }, se = () => {
443
+ const { onSuccess: e, onClose: r, onError: t, onReady: o, onLoaded: a } = E(), s = f.useCallback(
444
+ async (i) => {
445
+ if (i.origin !== b) return;
446
+ const { data: l, event: d } = i.data;
436
447
  switch (d) {
437
- case u.ON_CLOSE:
438
- o == null || o();
448
+ case c.ON_CLOSE:
449
+ r == null || r();
439
450
  break;
440
- case u.ON_ERROR:
441
- t == null || t(m);
451
+ case c.ON_ERROR:
452
+ t == null || t(l);
442
453
  break;
443
- case u.ON_SUCCESS:
444
- e(m);
454
+ case c.ON_SUCCESS:
455
+ e == null || e(l);
445
456
  break;
446
- case u.ON_LOADED:
457
+ case c.ON_LOADED:
447
458
  a();
448
459
  break;
449
- case u.ON_READY:
450
- n == null || n();
460
+ case c.ON_READY:
461
+ o == null || o();
451
462
  break;
452
463
  }
453
464
  },
454
- [o, t, a, n, e]
465
+ [r, t, a, o, e]
455
466
  );
456
- p.useEffect(() => (window.addEventListener("message", i, !1), () => {
457
- window.removeEventListener("message", i);
458
- }), [i]);
459
- }, ee = () => {
460
- const { connectLink: e } = X();
461
- return Z(), /* @__PURE__ */ r(
467
+ f.useEffect(() => (window.addEventListener("message", s, !1), () => {
468
+ window.removeEventListener("message", s);
469
+ }), [s]);
470
+ }, ie = () => {
471
+ const { connectLink: e } = ae();
472
+ return se(), /* @__PURE__ */ n(
462
473
  "div",
463
474
  {
464
475
  id: "tap-connect-main-container",
@@ -473,24 +484,25 @@ const q = (e = "tap-connect-sdk-element") => {
473
484
  width: "100%",
474
485
  height: "100%"
475
486
  },
476
- children: /* @__PURE__ */ r($, { src: e })
487
+ children: /* @__PURE__ */ n(W, { src: e })
477
488
  }
478
489
  );
479
- }, te = (e) => /* @__PURE__ */ r(T, { props: e, children: e.open && /* @__PURE__ */ r(ee, {}) }), re = p.memo(te);
480
- var N, E = w;
481
- N = E.createRoot, E.hydrateRoot;
482
- const se = (e, o) => {
483
- const t = q(e), n = N(t);
484
- return n.render(/* @__PURE__ */ r(re, { ...o })), { unmount: () => n.unmount() };
490
+ }, de = (e) => /* @__PURE__ */ n(H, { props: e, children: e.open && /* @__PURE__ */ n(ie, {}) }), le = f.memo(de);
491
+ var S, x = D;
492
+ S = x.createRoot, x.hydrateRoot;
493
+ const me = (e, r) => {
494
+ const t = Q(e), o = S(t);
495
+ return o.render(/* @__PURE__ */ n(le, { ...r })), { unmount: () => o.unmount() };
485
496
  };
486
497
  export {
487
498
  R as ConnectDialogEdgeFormat,
488
- L as ConnectDialogTransition,
489
- re as ConnectElement,
490
- A as ConnectLanguage,
491
- C as ConnectMode,
492
- k as ConnectPasswordOperationType,
493
- x as ConnectScope,
494
- S as ConnectTheme,
495
- se as renderConnectElement
499
+ _ as ConnectDialogTransition,
500
+ le as ConnectElement,
501
+ v as ConnectFlows,
502
+ U as ConnectLanguage,
503
+ N as ConnectMode,
504
+ G as ConnectRegions,
505
+ L as ConnectScope,
506
+ I as ConnectTheme,
507
+ me as renderConnectElement
496
508
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tap-payments/connect-v2",
3
3
  "private": false,
4
- "version": "0.0.32-test",
4
+ "version": "0.0.34-test",
5
5
  "type": "module",
6
6
  "main": "build/index.cjs.js",
7
7
  "module": "build/index.esm.js",