straumur-web-component 2.0.0-alpha.14 → 2.0.0-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
`);var Oe=require("preact/hooks"),ve=({children:e,content:t,placement:r="bottom"})=>{let[o,a]=(0,Oe.useState)(!1),n=(0,Oe.useRef)(null);return(0,Le.h)("div",{style:{position:"relative"}},(0,Le.h)("div",{ref:n,onMouseEnter:()=>{a(!0)},onMouseLeave:()=>{a(!1)}},e),o&&n&&(0,Le.h)("div",{className:`straumur__tooltip__content straumur__tooltip__content--${r}`},t))};var He=require("preact/hooks");function ht(e){let t=()=>window.matchMedia(e).matches,[r,o]=(0,He.useState)(t);return(0,He.useEffect)(()=>{let a=window.matchMedia(e),n=i=>o(i.matches);return o(a.matches),a.addEventListener("change",n),()=>{a.removeEventListener("change",n)}},[e]),r}var Jt=["visa","mc","maestro","amex","jcb","cup"],$t=e=>{let t=Jt.indexOf(e);return t===-1?Jt.length:t};function Ze({brands:e,brandHidden:t=[],limit:r=4,theme:o="light"}){let a=ht("(max-width: 380px)"),i=ht("(max-width: 335px)")?1:a?2:r,l=e.filter(d=>!t.some(m=>m.brand===d.brand)).sort((d,m)=>$t(d.brand)-$t(m.brand));return(0,M.h)(M.Fragment,null,l.map(({brand:d},m)=>m>=Math.min(r,i)?m===Math.min(r,i)?(0,M.h)(ve,{content:(0,M.h)("span",{style:{display:"flex",gap:"4px",overflow:"visible"}},l.slice(Math.min(r,i)).map(({brand:p})=>(0,M.h)(Ue,{key:p,brand:p,theme:o})))},(0,M.h)("span",{key:d,className:"straumur__render-brand-icons__overflow"},"+",l.length-Math.min(r,i))):null:(0,M.h)(Ue,{key:d,brand:d,theme:o})))}var ft=(e,t)=>t?(0,M.h)("span",{className:"straumur__brand-chip"},e):e,Ue=({brand:e,theme:t="light",defaultToBrandName:r=!0})=>{let o=t==="dark";switch(e){case"visa":return(0,M.h)(Ut,{reversed:o});case"mc":return(0,M.h)(Ht,{reversed:o});case"maestro":return(0,M.h)(Zt,{reversed:o});case"discover":return(0,M.h)(jt,{reversed:o});case"amex":return(0,M.h)(Gt,null);case"jcb":return ft((0,M.h)(Vt,null),o);case"diners":return ft((0,M.h)(Wt,null),o);case"cup":return ft((0,M.h)(Kt,null),o);default:return r?(0,M.h)("span",null,e):(0,M.h)(M.Fragment,null)}};var h=require("preact"),T=require("preact/hooks");var $e=require("@adyen/adyen-web");var re=require("preact"),Xr=()=>(0,re.h)("svg",{width:"21",height:"20",viewBox:"0 0 21 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,re.h)("g",{"clip-path":"url(#clip0_10626_39119)"},(0,re.h)("path",{d:"M10.6641 7.5C11.3543 7.5 11.9141 6.94023 11.9141 6.25C11.9141 5.55977 11.3543 5 10.6641 5C9.97383 5 9.41406 5.55859 9.41406 6.25C9.41406 6.94141 9.97266 7.5 10.6641 7.5ZM12.2266 13.125H11.6016V9.6875C11.6016 9.17188 11.1836 8.75 10.6641 8.75H9.41406C8.89844 8.75 8.47656 9.17188 8.47656 9.6875C8.47656 10.2031 8.89844 10.625 9.41406 10.625H9.72656V13.125H9.10156C8.58594 13.125 8.16406 13.5469 8.16406 14.0625C8.16406 14.5781 8.58594 15 9.10156 15H12.2266C12.7441 15 13.1641 14.5801 13.1641 14.0625C13.1641 13.5449 12.7461 13.125 12.2266 13.125Z",fill:"currentColor"}),(0,re.h)("path",{opacity:"0.4",d:"M10.6641 0C5.14062 0 0.664062 4.47656 0.664062 10C0.664062 15.5234 5.14062 20 10.6641 20C16.1875 20 20.6641 15.5234 20.6641 10C20.6641 4.47656 16.1875 0 10.6641 0ZM10.6641 5C11.3543 5 11.9141 5.55977 11.9141 6.25C11.9141 6.94023 11.3543 7.5 10.6641 7.5C9.97383 7.5 9.41406 6.94141 9.41406 6.25C9.41406 5.55859 9.97266 5 10.6641 5ZM12.2266 15H9.10156C8.58594 15 8.16406 14.582 8.16406 14.0625C8.16406 13.543 8.58398 13.125 9.10156 13.125H9.72656V10.625H9.41406C8.89648 10.625 8.47656 10.2051 8.47656 9.6875C8.47656 9.16992 8.89844 8.75 9.41406 8.75H10.6641C11.1816 8.75 11.6016 9.16992 11.6016 9.6875V13.125H12.2266C12.7441 13.125 13.1641 13.5449 13.1641 14.0625C13.1641 14.5801 12.7461 15 12.2266 15Z",fill:"currentColor"})),(0,re.h)("defs",null,(0,re.h)("clipPath",{id:"clip0_10626_39119"},(0,re.h)("rect",{width:"20",height:"20",fill:"white",transform:"translate(0.664062)"})))),Ge=Xr;var ce=require("preact"),qr=()=>(0,ce.h)("svg",{width:"40",height:"40",viewBox:"0 0 40 40",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor"},(0,ce.h)("g",{fill:"none","fill-rule":"evenodd"},(0,ce.h)("g",{transform:"translate(2 2)","stroke-width":"4"},(0,ce.h)("circle",{"stroke-opacity":".3",cx:"18",cy:"18",r:"18"}),(0,ce.h)("path",{d:"M36 18c0-9.94-8.06-18-18-18"},(0,ce.h)("animateTransform",{attributeName:"transform",type:"rotate",from:"0 18 18",to:"360 18 18",dur:"1s",repeatCount:"indefinite"}))))),$=qr;var _t=require("preact"),Yr=({color:e="var(--straumur__color-primary)"})=>(0,_t.h)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"13",viewBox:"0 0 16 13",fill:"none"},(0,_t.h)("path",{d:"M2 7L6 11L14 2",stroke:e,"stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round"})),Ve=Yr;var oe=require("preact");function Xt({brand:e,brandName:t,isSelected:r,onBrandClick:o}){let a=n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),n.currentTarget.click())};return(0,oe.h)("span",{className:"straumur__card-component__dual-branding--logo"+(r?" straumur__card-component__dual-branding--logo--selected":""),title:e,"data-value":e,onClick:o,onKeyDown:a,role:"radio","aria-checked":r,"aria-label":t??e,tabIndex:0},(0,oe.h)("div",{className:"straumur__card-component__dual-branding--logo--item"},(0,oe.h)(Ue,{brand:e,defaultToBrandName:!1}),"\xA0",t??""),r&&(0,oe.h)(Ve,{color:"var(--straumur__color-neon-green-zeta)"}))}function qt({dualBrandConfiguration:e,selectedBrand:t,onBrandClick:r}){return(0,oe.h)("div",{className:"straumur__card-component__dual-branding",role:"radiogroup","aria-label":"Card brand"},(0,oe.h)(Xt,{brand:e.brand1,brandName:e.brand1Name,isSelected:t===e.brand1,onBrandClick:r}),(0,oe.h)(Xt,{brand:e.brand2,brandName:e.brand2Name,isSelected:t===e.brand2,onBrandClick:r}))}var Qr=["AuthenticationFinished","AuthenticationNotRequired","Authorised","Cancelled","ChallengeShopper","Error","IdentifyShopper","PartiallyAuthorised","Pending","PresentToShopper","Received","RedirectShopper","Refused"];function yt(e){return e&&Qr.includes(e)?e:"Error"}var L=class extends Error{messageKey;messageText;constructor(t,r){super(r??t),this.messageKey=t,this.messageText=r}};function Me(e,t){return e instanceof L?e.messageText?{text:e.messageText}:{key:e.messageKey}:{key:t}}function Yt(e,t){return{async submitPayment(r){let o={...r,sessionId:t},a=await wt(e,o);if(!a.ok)throw new L("error.failedToSubmitPayment");let n=await a.json();if(!n.resultCode)throw new L("error.paymentFailed");return{resultCode:n.resultCode,action:n.action}},async submitAdditionalDetails(r){let o={...r,sessionId:t},a=await kt(e,o);if(!a.ok)throw new L("error.failedToSubmitPaymentDetails");let n=await a.json();if(!n.resultCode)throw new L("error.paymentDetailsFailed");return{resultCode:n.resultCode,action:n.action}},async disableToken(r){let a=await It(e,{storedPaymentMethodId:r,sessionId:t});if(!a.ok)throw new L("error.failedToSubmitRemoveStoredPaymentCard");if(!(await a.json()).success)throw new L("error.failedToRemoveStoredPaymentCard")}}}function Qt(e){function t(a,n,i,l){let d=m=>i(m instanceof L?m:new L(l));try{Promise.resolve(a(n,i)).catch(d)}catch(m){d(m)}}let r={submitPayment(a){return new Promise((n,i)=>{t((l,d)=>e.onSubmit({data:a},{resolve:l,reject:m=>d(new L("error.failedToSubmitPayment",m))}),n,i,"error.failedToSubmitPayment")})},submitAdditionalDetails(a){return new Promise((n,i)=>{t((l,d)=>e.onAdditionalDetails({data:a},{resolve:l,reject:m=>d(new L("error.failedToSubmitPaymentDetails",m))}),n,i,"error.failedToSubmitPaymentDetails")})},beforeSubmit:e.onBeforeSubmit},{onDisableToken:o}=e;return o&&(r.disableToken=a=>new Promise((n,i)=>{t((l,d)=>o({storedPaymentMethodId:a},{resolve:()=>l(),reject:()=>d(new L("error.failedToRemoveStoredPaymentCard"))}),n,i,"error.failedToSubmitRemoveStoredPaymentCard")})),r}async function vt(e){let{beforeSubmit:t}=e;return!t||await t()}async function We(e,t){t()&&await vt(e)&&t()?.submit()}function gt(e){return(t,r)=>{let{beforeSubmit:o}=e;if(!o){t();return}let a=o();if(a instanceof Promise){a.then(n=>n?t():r()).catch(()=>r());return}if(a){t();return}r()}}var eo=["Refused","Cancelled","Error"];function ae(e){let{configuration:t,handleSuccess:r,handleError:o,setThreeDSecureActive:a,enrichSubmitData:n,onSubmitStart:i,dispatchResultFromAdditionalDetails:l}=e,d;function m(){return d?{text:d}:{key:"error.paymentUnsuccessful"}}function p(g){g==="Authorised"?r({key:"success.paymentAuthorized"}):o(m()),eo.includes(g)?t.onPaymentFailed?.({resultCode:g}):t.onPaymentCompleted?.({resultCode:g})}async function u(g,b,R){i?.();let{paymentFlow:A}=t;if(!await vt(A)){R.reject();return}try{let F=n?n(g.data):g.data,{resultCode:f,action:j,errorMessage:O}=await A.submitPayment(F);d=O,(f==="ChallengeShopper"||f==="IdentifyShopper")&&a(!0),R.resolve({resultCode:f,action:j})}catch(F){R.reject(),o(Me(F,"error.failedToSubmitPayment"))}}async function P(g,b,R){try{let{resultCode:A,action:F,errorMessage:f}=await t.paymentFlow.submitAdditionalDetails(g.data);d=f,R.resolve({resultCode:A,action:F}),l&&p(A)}catch(A){R.reject(),o(Me(A,"error.failedToSubmitPaymentDetails")),l&&t.onPaymentFailed?.({resultCode:"Error"})}}function C(g,b){p(yt(g.resultCode))}function D(g,b){p(g?yt(g.resultCode):"Error")}return{handleOnSubmit:u,handleOnSubmitAdditionalData:P,handlePaymentCompleted:C,handlePaymentFailed:D}}var er=require("preact/hooks");function ge(e,t,r){(0,er.useEffect)(()=>{t()&&r()},[e])}var tr=require("preact/hooks");function je(e,t){(0,tr.useEffect)(()=>{t&&e.current?.focus()},[t,e])}var Ke=require("preact/hooks"),rr="(prefers-color-scheme: dark)";function to(){return typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(rr).matches:!1}function X(e){let[t,r]=(0,Ke.useState)(to);return(0,Ke.useEffect)(()=>{if(e!=="system"||typeof window>"u"||typeof window.matchMedia!="function")return;let o=window.matchMedia(rr),a=n=>r(n.matches);return r(o.matches),o.addEventListener("change",a),()=>o.removeEventListener("change",a)},[e]),e==="system"?t?"dark":"light":e}function Je(e){return e==="dark"?{base:{color:"#e8edf2"},placeholder:{color:"#aab4bf"},error:{color:"#e08a8a"}}:{base:{color:"#00112c"},placeholder:{color:"#72889d"},error:{color:"#d96666"}}}function ro({configuration:e,paymentMethods:t,onBrandHidden:r}){let o=(0,T.useRef)(null),a=(0,T.useRef)(),n=(0,T.useRef)(),{i18n:i}=V(),[l,d]=(0,T.useState)(!0),[m,p]=(0,T.useState)("required"),[u,P]=(0,T.useState)(!1),[C,D]=(0,T.useState)(!1),[g,b]=(0,T.useState)(null),[R,A]=(0,T.useState)(null),F=(0,T.useRef)(!1),[f,j]=(0,T.useState)({encryptedCardNumber:{visible:!1},encryptedExpiryDate:{visible:!1},encryptedSecurityCode:{visible:!1}}),{activePaymentMethod:O,isPaymentMethodInitialized:B,updatePaymentMethodInitialization:ee,handleSuccess:z,handleError:K,setThreeDSecureActive:J,threeDSecureActive:N,isObscuredByThreeDS:G,hasCard:ie,registerSubmitHandler:te,unregisterSubmitHandler:S}=k(),le=X(e.theme);async function q(){await We(e.paymentFlow,()=>n.current)}(0,T.useEffect)(()=>{if(!(O==="card"&&B.card&&!N)){e.onCardValidityChanged?.(!1,!1);return}return te(q),e.onCardValidityChanged?.(!1,!0),()=>{S(q),e.onCardValidityChanged?.(!1,!1)}},[O,B.card,N,te,S]);let Se=t.paymentMethods?.paymentMethods?.find(_=>_.type==="scheme")?.brands??[],{handleOnSubmit:it,handleOnSubmitAdditionalData:Ae,handlePaymentCompleted:lt,handlePaymentFailed:mt}=ae({configuration:e,handleSuccess:z,handleError:K,setThreeDSecureActive:J,enrichSubmitData:_=>({..._,storePaymentMethod:F.current})});function dt(_,x){K({key:"error.unknownError"})}let Re=async()=>{n.current?.remove(),a.current=await(0,$e.AdyenCheckout)({clientKey:t.clientKey,environment:e.environment,locale:e.locale,countryCode:e.countryCode,paymentMethodsResponse:t.paymentMethods,amount:{value:t.minorUnitsAmount,currency:t.currency},onSubmit:it,onAdditionalDetails:Ae,onError:dt,onPaymentCompleted:lt,onPaymentFailed:mt}),n.current=new $e.CustomCard(a.current,{brands:Se,placeholders:e.placeholders,styles:Je(le),challengeWindowSize:"05",onBinLookup:_=>{_.supportedBrandsRaw&&_.supportedBrandsRaw.length>1&&(D(!0),b({brand1:_.supportedBrandsRaw[0].brand,brand1Name:_.supportedBrandsRaw[0].localeBrand,brand1ImageUrl:_.supportedBrandsRaw[0].brandImageUrl,brand2:_.supportedBrandsRaw[1].brand,brand2Name:_.supportedBrandsRaw[1].localeBrand,brand2ImageUrl:_.supportedBrandsRaw[1].brandImageUrl}))},onBrand:_=>{if(p(_.cvcPolicy),_.brand==="card"){r([]),A(null);return}let x=Se.filter(w=>w!==_.brand).map(w=>({brand:w}));r(x),Se.filter(w=>w===_.brand).map(w=>({brand:w})).length===1&&A(_.brand)},onConfigSuccess(){ee("card",!0)},onValidationError:_=>{let x={encryptedCardNumber:{visible:!1,message:void 0},encryptedExpiryDate:{visible:!1,message:void 0},encryptedSecurityCode:{visible:!1,message:void 0}};_.filter(w=>w.error).forEach(w=>{x[w.fieldType].visible=!0,x[w.fieldType].message=w.errorI18n}),j(x)},onAllValid:_=>{d(!_.allValid),e.onCardValidityChanged?.(_.allValid,!0)}}),o.current&&n.current.mount(o.current)};(0,T.useEffect)(()=>{ie&&O==="card"&&!B.card&&Re()},[e,O]),ge(e,()=>!!(n.current&&B.card),()=>{Re(),j({encryptedCardNumber:{visible:!1,message:void 0},encryptedExpiryDate:{visible:!1,message:void 0},encryptedSecurityCode:{visible:!1,message:void 0}})}),(0,T.useEffect)(()=>{F.current=u},[u]);function xt(_){n.current.dualBrandingChangeHandler(_)}function ct(_){P(_.currentTarget.checked)}return je(o,N&&O==="card"),!ie||G("card")||t.paymentMethods?.paymentMethods?.length===0?null:(0,h.h)("div",{className:"straumur__card-component__expandable",ref:o,tabIndex:-1,style:{height:N?"600px":"auto",minWidth:N?"350px":"auto"}},!B.card&&(0,h.h)("div",{className:"straumur__card-component__loading-text"},(0,h.h)($,null)),(0,h.h)("div",{className:"straumur__card-component__form",style:{opacity:B.card&&!N?1:0,position:B.card&&!N?"relative":"absolute",transition:"opacity 0.3s ease-in-out"}},(0,h.h)("div",{className:"straumur__card-component__form--wrapper"},(0,h.h)("label",{className:`straumur__card-component__form--wrapper--label ${f.encryptedCardNumber.visible?"straumur__card-component__form--wrapper--label--error":""}`},i.t("cards.cardNumber")),(0,h.h)("span",{className:`straumur__card-component__form--wrapper--input ${f.encryptedCardNumber.visible?"straumur__card-component__form--wrapper--input--error":""}`,"data-cse":"encryptedCardNumber",role:"group","aria-label":i.t("cards.cardNumber")}),f.encryptedCardNumber.visible&&(0,h.h)("span",{className:"straumur__card-component__form--wrapper--error"},f.encryptedCardNumber.message)),(0,h.h)("div",{className:"straumur__card-component__form--field-wrapper"},(0,h.h)("div",{className:"straumur__card-component__form--wrapper"},(0,h.h)("label",{className:`straumur__card-component__form--wrapper--label ${f.encryptedExpiryDate.visible?"straumur__card-component__form--wrapper--label--error":""}`},i.t("cards.expiryDate")),(0,h.h)("span",{className:`straumur__card-component__form--wrapper--input ${f.encryptedExpiryDate.visible?"straumur__card-component__form--wrapper--input--error":""}`,"data-cse":"encryptedExpiryDate",role:"group","aria-label":i.t("cards.expiryDate")}),f.encryptedExpiryDate.visible&&(0,h.h)("span",{className:"straumur__card-component__form--wrapper--error"},f.encryptedExpiryDate.message)),(0,h.h)("div",{className:"straumur__card-component__form--wrapper"},(m==="optional"||m==="required")&&(0,h.h)(h.Fragment,null,(0,h.h)("label",{className:`straumur__card-component__form--wrapper--label ${f.encryptedSecurityCode.visible?"straumur__card-component__form--wrapper--label--error":""}`},m==="optional"?i.t("cards.securityCode3DigitsOptional"):i.t("cards.securityCode3Digits")),(0,h.h)("span",{className:`straumur__card-component__form--wrapper--input ${f.encryptedSecurityCode.visible?"straumur__card-component__form--wrapper--input--error":""}`,"data-cse":"encryptedSecurityCode",role:"group","aria-label":i.t("cards.securityCode3Digits")}),f.encryptedSecurityCode.visible&&(0,h.h)("span",{className:"straumur__card-component__form--wrapper--error"},f.encryptedSecurityCode.message),(0,h.h)("div",{className:"straumur__card-component__form--wrapper--label--info"},(0,h.h)(ve,{content:(0,h.h)("span",null,i.t("cards.securityCode3DigitsInfo")),placement:"top"},(0,h.h)(Ge,null)))))),C&&g&&(0,h.h)(qt,{dualBrandConfiguration:g,selectedBrand:R,onBrandClick:xt}),t.enableStoreDetails==="AskForConsent"&&(0,h.h)("label",{className:"straumur__card-component__form--wrapper--label-checkbox"},(0,h.h)("div",{className:`straumur__card-component__form--wrapper--label-checkbox--checkmark ${u?"straumur__card-component__form--wrapper--label-checkbox--checkmark--checked":""}`},(0,h.h)("div",{className:`straumur__card-component__form--wrapper--label-checkbox--checkmark--icon ${u?"straumur__card-component__form--wrapper--label-checkbox--checkmark--icon--checked":""}`},(0,h.h)(Ve,null))),(0,h.h)("input",{type:"checkbox",className:"straumur__card-component__form--wrapper--label-checkbox--checkbox",checked:u,onChange:ct}),i.t("cards.storePaymentMethod")),!e.hideSubmitButton&&(0,h.h)("button",{className:"straumur__card-component__submit-button",disabled:l,onClick:q},t.minorUnitsAmount===0?i.t("cards.saveCardDetails"):t.formattedAmount)))}var or=ro;var ue=require("preact");v(`.straumur__payment-method-item{position:relative;cursor:pointer;background:var(--straumur__color-white);border-radius:var(--straumur__border-radius-lg);transition:all .3s ease;padding:var(--straumur__space-xxlg) var(--straumur__space-5xlg)}.straumur__payment-method-item--sole{cursor:default}.straumur__payment-method-item:has(.straumur__payment-method-item__radio-selector:checked){cursor:default}.straumur__payment-method-item__radio-selector{position:absolute;opacity:0;cursor:pointer}.straumur__payment-method-item__content{display:flex;align-items:center;gap:var(--straumur__space-lg);transition:background-color .3s ease}.straumur__payment-method-item__radio-selector:checked+.straumur__payment-method-item__content{padding-bottom:var(--straumur__space-xxlg)}.straumur__payment-method-item__content--expanded{padding-bottom:var(--straumur__space-xxlg)}.straumur__payment-method-item--circle{width:var(--straumur__space-5xlg);height:var(--straumur__space-5xlg);border:1px solid var(--straumur__color-cosmos-blue-gamma);background:var(--straumur__color-secondary-gamma);border-radius:50%;position:relative;transition:all .3s ease;flex-shrink:0}.straumur__payment-method-item__content:hover .straumur__payment-method-item--circle{border:1px solid var(--straumur__color-cosmos-blue-delta)}.straumur__payment-method-item--circle:after{content:"";position:absolute;width:100%;height:100%;border-radius:50%;top:50%;left:50%;transform:translate(-50%,-50%) scale(0);transition:transform .2s ease}.straumur__payment-method-item__radio-selector:checked+.straumur__payment-method-item__content .straumur__payment-method-item--circle{background:var(--straumur__color-blue-beta);border-color:var(--straumur__color-transparent)}.straumur__payment-method-item__radio-selector:checked+.straumur__payment-method-item__content .straumur__payment-method-item--circle:after{transform:translate(-50%,-50%) scale(1);background:var(--straumur__color-primary);height:var(--straumur__space-md);width:var(--straumur__space-md)}.straumur__payment-method-item--title{color:var(--straumur__color-text);font-size:16px;user-select:none}.straumur__payment-method-item__expandable{background:var(--straumur__color-white);max-height:0;overflow:hidden;transition:all .3s ease;opacity:0}.straumur__payment-method-item__radio-selector:checked~.straumur__payment-method-item__expandable{max-height:600px;opacity:1}.straumur__payment-method-item__expandable--visible{max-height:600px;opacity:1}
|
|
5
5
|
`);function oo({icon:e,title:t,isActive:r,isSole:o,onChange:a,children:n,headerRight:i,confirmSection:l}){return(0,ue.h)("label",{className:`straumur__payment-method-item${o?" straumur__payment-method-item--sole":""}`},!o&&(0,ue.h)("input",{type:"radio",className:"straumur__payment-method-item__radio-selector",checked:r,onChange:a}),(0,ue.h)("span",{className:`straumur__payment-method-item__content${o?" straumur__payment-method-item__content--expanded":""}`},!o&&(0,ue.h)("span",{className:"straumur__payment-method-item--circle"}),e,(0,ue.h)("span",{className:"straumur__payment-method-item--title"},t),i),l,(0,ue.h)("div",{className:`straumur__payment-method-item__expandable${o?" straumur__payment-method-item__expandable--visible":""}`},n))}var ne=oo;function ao({configuration:e,paymentMethods:t}){let{i18n:r}=V(),[o,a]=(0,ar.useState)([]),n=X(e.theme),{activePaymentMethod:i,setActivePaymentMethod:l,isObscuredByThreeDS:d,isSolePaymentMethod:m,hasCard:p}=k();if(!p||d("card"))return null;let P=t.paymentMethods.paymentMethods.find(C=>C.type==="scheme").brands.map(C=>({brand:C,brandFullName:C}));return(0,be.h)(ne,{icon:(0,be.h)(Ot,null),title:r.t("cards.title"),isActive:i==="card",isSole:m,onChange:()=>l("card"),headerRight:(0,be.h)("span",{className:"straumur__card-component--brands"},(0,be.h)(Ze,{brands:P,brandHidden:o,theme:n}))},(0,be.h)(or,{configuration:e,paymentMethods:t,onBrandHidden:a}))}var nr=ao;var Ye=require("preact"),cr=require("preact/hooks");v(`.adyen-checkout__paywithgoogle{height:var(--straumur__space-8xlg)}
|
|
6
6
|
`);var Y=require("preact"),no=()=>(0,Y.h)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"26",fill:"none",viewBox:"0 0 40 26"},(0,Y.h)("path",{fill:"#fff",d:"M29.13 2.41H10.87C5.17 2.41.5 7.18.5 13.01a10.5 10.5 0 0 0 10.37 10.58h18.26c5.7 0 10.37-4.76 10.37-10.59 0-5.82-4.67-10.59-10.37-10.59Z"}),(0,Y.h)("path",{fill:"#3C4043",d:"M29.13 3.27c1.28 0 2.52.26 3.7.77a9.6 9.6 0 0 1 5.08 5.19 9.78 9.78 0 0 1 0 7.55 9.83 9.83 0 0 1-5.08 5.18 9.26 9.26 0 0 1-3.7.77H10.87a9.24 9.24 0 0 1-3.7-.77 9.6 9.6 0 0 1-5.08-5.18 9.78 9.78 0 0 1 0-7.55 9.83 9.83 0 0 1 5.08-5.19 9.24 9.24 0 0 1 3.7-.77h18.26Zm0-.86H10.87C5.17 2.41.5 7.18.5 13.01a10.5 10.5 0 0 0 10.37 10.58h18.26c5.7 0 10.37-4.76 10.37-10.59 0-5.82-4.67-10.59-10.37-10.59Z"}),(0,Y.h)("path",{fill:"#3C4043",d:"M19.1 13.75v3.2h-1v-7.9h2.64c.67 0 1.24.23 1.7.68.49.46.72 1.01.72 1.67a2.2 2.2 0 0 1-.71 1.68c-.46.45-1.03.67-1.7.67H19.1Zm0-3.73v2.76h1.66c.4 0 .73-.14.99-.4.26-.28.4-.6.4-.98 0-.36-.14-.68-.4-.95a1.28 1.28 0 0 0-.99-.42H19.1Zm6.67 1.35c.73 0 1.31.2 1.74.6.42.4.64.95.64 1.65v3.34h-.95v-.76h-.04a1.9 1.9 0 0 1-1.65.93 2.1 2.1 0 0 1-1.46-.53c-.4-.35-.6-.8-.6-1.32 0-.56.21-1 .63-1.34.41-.33.97-.5 1.66-.5.59 0 1.07.12 1.45.34v-.23c0-.36-.13-.65-.4-.9a1.4 1.4 0 0 0-.97-.37c-.56 0-1 .24-1.32.72l-.88-.56a2.42 2.42 0 0 1 2.15-1.07Zm-1.29 3.92c0 .27.11.5.33.67.22.17.48.26.78.26.42 0 .79-.16 1.12-.48.32-.31.49-.68.49-1.11a2.02 2.02 0 0 0-1.3-.38c-.4 0-.74.1-1.01.3a.9.9 0 0 0-.4.74Zm9.08-3.75-3.32 7.8h-1.02l1.23-2.73-2.19-5.07h1.09l1.57 3.89h.02l1.54-3.89h1.08Z"}),(0,Y.h)("path",{fill:"#4285F4",d:"M15.14 13.1c0-.32-.03-.64-.09-.95h-4.17v1.75h2.4a2.1 2.1 0 0 1-.89 1.4v1.14h1.43a4.49 4.49 0 0 0 1.32-3.33Z"}),(0,Y.h)("path",{fill:"#34A853",d:"M12.4 15.3a2.66 2.66 0 0 1-4-1.44H6.9v1.18a4.43 4.43 0 0 0 6.91 1.4l-1.43-1.13Z"}),(0,Y.h)("path",{fill:"#FABB05",d:"M8.25 13c0-.3.05-.59.14-.86v-1.17H6.9a4.59 4.59 0 0 0 0 4.07l1.48-1.17a2.79 2.79 0 0 1-.14-.86Z"}),(0,Y.h)("path",{fill:"#E94235",d:"M10.88 10.27c.66 0 1.24.23 1.7.68l1.27-1.3a4.22 4.22 0 0 0-2.97-1.18 4.44 4.44 0 0 0-3.97 2.5l1.48 1.17a2.66 2.66 0 0 1 2.5-1.87Z"})),sr=no;v(`.straumur__google-pay-button__loading{display:flex;justify-content:center}
|
|
7
|
-
`);var dr=require("preact");var pe=require("preact"),Ce=require("preact/hooks"),Pe=require("@adyen/adyen-web");var ir="CANCEL";function lr(e,t){return(t??(e==="dark"?"dark":"white"))==="dark"?"black":"white"}function mr(e,t){return(t??(e==="dark"?"dark":"light"))==="dark"?"black":"white-outline"}var so={applepay:{loadingClassName:"straumur__apple-pay-button__loading",createElement(e,{configuration:t,paymentMethods:r,walletConfig:o,handleOnSubmit:a,resolvedTheme:n}){let i={amount:{value:r.minorUnitsAmount,currency:r.currency},environment:t.environment,onSubmit:a,onClick:gt(t.paymentFlow),buttonColor:mr(n,t.applePayButtonTheme),configuration:{...o,merchantName:r.merchantName}};return new Pe.ApplePay(e,i)}},googlepay:{loadingClassName:"straumur__google-pay-button__loading",createElement(e,{configuration:t,paymentMethods:r,walletConfig:o,handleOnSubmit:a,resolvedTheme:n}){let i={amount:{value:r.minorUnitsAmount,currency:r.currency},challengeWindowSize:"05",countryCode:t.countryCode,environment:t.environment,onSubmit:a,onClick:gt(t.paymentFlow),buttonColor:lr(n,t.googlePayButtonTheme),buttonSizeMode:"fill",buttonRadius:12,configuration:{...o,merchantName:r.merchantName}};return new Pe.GooglePay(e,i)}}};function io({method:e,configuration:t,paymentMethods:r,isInstantPayment:o,onUnavailable:a}){let n=so[e],i=X(t.theme),l=(0,Ce.useRef)(null),d=(0,Ce.useRef)(),m=(0,Ce.useRef)(),{isPaymentMethodInitialized:p,updatePaymentMethodInitialization:u,handleSuccess:P,handleError:C,setThreeDSecureActive:D,threeDSecureActive:g,isObscuredByThreeDS:b,setActivePaymentMethod:R,activePaymentMethod:A}=k(),{handleOnSubmit:F,handleOnSubmitAdditionalData:f,handlePaymentCompleted:j,handlePaymentFailed:O}=ae({configuration:t,handleSuccess:P,handleError:C,setThreeDSecureActive:D,onSubmitStart:()=>{o&&R(e)}});function B(K,J){K.name!==ir&&C({key:"error.unknownError"})}function ee(){u(e,!0),A===e&&R(null),a?.()}let z=async()=>{d.current=await(0,Pe.AdyenCheckout)({clientKey:r.clientKey,environment:t.environment,locale:t.locale,countryCode:t.countryCode,paymentMethodsResponse:r.paymentMethods,amount:{value:r.minorUnitsAmount,currency:r.currency},onError:B,onAdditionalDetails:f,onPaymentCompleted:j,onPaymentFailed:O});let J=r.paymentMethods.paymentMethods?.find(N=>N.type===e)?.configuration;if(!J){ee();return}m.current=n.createElement(d.current,{configuration:t,paymentMethods:r,walletConfig:J,handleOnSubmit:F,resolvedTheme:i}),m.current.isAvailable().then(()=>{m.current.mount(l.current),u(e,!0)}).catch(()=>{ee()})};return(0,Ce.useEffect)(()=>{p[e]||z()},[t]),ge(t,()=>!!(m.current&&p[e]),()=>{m.current.remove(),z()}),b(e)?null:(0,pe.h)(pe.Fragment,null,p[e]===!1&&(0,pe.h)("div",{className:n.loadingClassName},(0,pe.h)($,null)),(0,pe.h)("div",{ref:l,style:{height:g?"600px":"
|
|
7
|
+
`);var dr=require("preact");var pe=require("preact"),Ce=require("preact/hooks"),Pe=require("@adyen/adyen-web");var ir="CANCEL";function lr(e,t){return(t??(e==="dark"?"dark":"white"))==="dark"?"black":"white"}function mr(e,t){return(t??(e==="dark"?"dark":"light"))==="dark"?"black":"white-outline"}var so={applepay:{loadingClassName:"straumur__apple-pay-button__loading",createElement(e,{configuration:t,paymentMethods:r,walletConfig:o,handleOnSubmit:a,resolvedTheme:n}){let i={amount:{value:r.minorUnitsAmount,currency:r.currency},environment:t.environment,onSubmit:a,onClick:gt(t.paymentFlow),buttonColor:mr(n,t.applePayButtonTheme),configuration:{...o,merchantName:r.merchantName}};return new Pe.ApplePay(e,i)}},googlepay:{loadingClassName:"straumur__google-pay-button__loading",createElement(e,{configuration:t,paymentMethods:r,walletConfig:o,handleOnSubmit:a,resolvedTheme:n}){let i={amount:{value:r.minorUnitsAmount,currency:r.currency},challengeWindowSize:"05",countryCode:t.countryCode,environment:t.environment,onSubmit:a,onClick:gt(t.paymentFlow),buttonColor:lr(n,t.googlePayButtonTheme),buttonSizeMode:"fill",buttonRadius:12,configuration:{...o,merchantName:r.merchantName}};return new Pe.GooglePay(e,i)}}};function io({method:e,configuration:t,paymentMethods:r,isInstantPayment:o,onUnavailable:a}){let n=so[e],i=X(t.theme),l=(0,Ce.useRef)(null),d=(0,Ce.useRef)(),m=(0,Ce.useRef)(),{isPaymentMethodInitialized:p,updatePaymentMethodInitialization:u,handleSuccess:P,handleError:C,setThreeDSecureActive:D,threeDSecureActive:g,isObscuredByThreeDS:b,setActivePaymentMethod:R,activePaymentMethod:A}=k(),{handleOnSubmit:F,handleOnSubmitAdditionalData:f,handlePaymentCompleted:j,handlePaymentFailed:O}=ae({configuration:t,handleSuccess:P,handleError:C,setThreeDSecureActive:D,onSubmitStart:()=>{o&&R(e)}});function B(K,J){K.name!==ir&&C({key:"error.unknownError"})}function ee(){u(e,!0),A===e&&R(null),a?.()}let z=async()=>{d.current=await(0,Pe.AdyenCheckout)({clientKey:r.clientKey,environment:t.environment,locale:t.locale,countryCode:t.countryCode,paymentMethodsResponse:r.paymentMethods,amount:{value:r.minorUnitsAmount,currency:r.currency},onError:B,onAdditionalDetails:f,onPaymentCompleted:j,onPaymentFailed:O});let J=r.paymentMethods.paymentMethods?.find(N=>N.type===e)?.configuration;if(!J){ee();return}m.current=n.createElement(d.current,{configuration:t,paymentMethods:r,walletConfig:J,handleOnSubmit:F,resolvedTheme:i}),m.current.isAvailable().then(()=>{m.current.mount(l.current),u(e,!0)}).catch(()=>{ee()})};return(0,Ce.useEffect)(()=>{p[e]||z()},[t]),ge(t,()=>!!(m.current&&p[e]),()=>{m.current.remove(),z()}),b(e)?null:(0,pe.h)(pe.Fragment,null,p[e]===!1&&(0,pe.h)("div",{className:n.loadingClassName},(0,pe.h)($,null)),(0,pe.h)("div",{ref:l,style:{height:g?"600px":"48px",minWidth:g?"350px":"auto",position:p[e]?"static":"absolute"}}))}var Xe=io;function lo(e){return(0,dr.h)(Xe,{method:"googlepay",...e})}var qe=lo;function mo({configuration:e,paymentMethods:t}){let{i18n:r}=V(),{activePaymentMethod:o,setActivePaymentMethod:a,isObscuredByThreeDS:n,isSolePaymentMethod:i,hasGooglePay:l}=k(),[d,m]=(0,cr.useState)(!1);return!l||d||e.instantPayments&&e.instantPayments.some(p=>p==="googlepay")||n("googlepay")?null:(0,Ye.h)(ne,{icon:(0,Ye.h)(sr,null),title:r.t("googlePay.title"),isActive:o==="googlepay",isSole:i,onChange:()=>a("googlepay")},(0,Ye.h)(qe,{configuration:e,paymentMethods:t,isInstantPayment:!1,onUnavailable:()=>m(!0)}))}var ur=mo;var et=require("preact"),fr=require("preact/hooks");v("");var we=require("preact"),co=()=>(0,we.h)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"26",fill:"none",viewBox:"0 0 40 26"},(0,we.h)("path",{fill:"#000",d:"M36.42 0H3.58a69.25 69.25 0 0 0-.75 0c-.25.01-.5.03-.76.07a2.51 2.51 0 0 0-1.32.7A2.43 2.43 0 0 0 .07 2.1 5.14 5.14 0 0 0 0 3.22v19.91c.01.25.03.51.07.76a2.6 2.6 0 0 0 .68 1.35 2.39 2.39 0 0 0 1.32.69 4.98 4.98 0 0 0 1.1.07h34a5 5 0 0 0 .76-.07 2.5 2.5 0 0 0 1.32-.7 2.44 2.44 0 0 0 .68-1.34 5.13 5.13 0 0 0 .07-1.11V2.87a6.5 6.5 0 0 0-.07-.76 2.58 2.58 0 0 0-.68-1.35 2.4 2.4 0 0 0-1.32-.69 4.96 4.96 0 0 0-1.1-.07h-.41Z"}),(0,we.h)("path",{fill:"#fff",d:"M36.42.87h.73c.2 0 .42.02.62.06a1.67 1.67 0 0 1 .88.44 1.58 1.58 0 0 1 .44.89 4.38 4.38 0 0 1 .06.97v19.55a14.67 14.67 0 0 1-.06.96 1.7 1.7 0 0 1-.44.89 1.54 1.54 0 0 1-.87.44 4.27 4.27 0 0 1-.96.06H2.85a3.7 3.7 0 0 1-.63-.06 1.66 1.66 0 0 1-.87-.45 1.56 1.56 0 0 1-.44-.88 4.35 4.35 0 0 1-.06-.97V2.9c.01-.2.02-.42.06-.63.03-.18.08-.34.16-.49A1.56 1.56 0 0 1 2.22.93a4.2 4.2 0 0 1 .96-.06h33.24"}),(0,we.h)("path",{fill:"#000",d:"M10.92 8.61c.34-.43.57-1 .51-1.59a2.21 2.21 0 0 0-1.99 2.3c.56.04 1.12-.3 1.48-.7Zm.51.81c-.82-.05-1.52.46-1.9.46-.4 0-1-.43-1.64-.42-.84 0-1.62.48-2.05 1.24-.88 1.52-.23 3.76.62 5 .42.6.92 1.27 1.58 1.25.62-.02.86-.4 1.62-.4.75 0 .97.4 1.63.39.69-.01 1.11-.61 1.53-1.22.47-.7.67-1.37.68-1.4-.01-.02-1.32-.52-1.33-2.02-.01-1.26 1.03-1.85 1.07-1.9a2.34 2.34 0 0 0-1.81-.98Zm7.11-1.7a2.87 2.87 0 0 1 3.02 3c0 1.8-1.27 3.03-3.06 3.03h-1.97v3.12h-1.42V7.72h3.43Zm-2 4.83h1.62c1.24 0 1.94-.66 1.94-1.82 0-1.15-.7-1.81-1.93-1.81h-1.64v3.63Zm5.39 2.43c0-1.17.9-1.89 2.48-1.98l1.83-.1v-.52c0-.74-.5-1.18-1.34-1.18-.8 0-1.3.38-1.41.97h-1.3c.08-1.2 1.1-2.09 2.76-2.09 1.62 0 2.65.86 2.65 2.2v4.6h-1.31v-1.1h-.04a2.38 2.38 0 0 1-2.1 1.2c-1.3 0-2.22-.8-2.22-2Zm4.3-.6v-.53l-1.64.1c-.82.06-1.28.42-1.28.99 0 .58.48.96 1.22.96.96 0 1.7-.66 1.7-1.52Zm2.61 4.95v-1.11c.1.03.33.03.44.03.64 0 .98-.27 1.19-.96l.12-.4-2.41-6.69h1.48l1.7 5.43h.02l1.69-5.43h1.44l-2.5 7.02c-.57 1.62-1.23 2.14-2.61 2.14a5.3 5.3 0 0 1-.56-.03Z"})),pr=co;v(`.straumur__apple-pay-button__loading{display:flex;justify-content:center}
|
|
8
8
|
`);var hr=require("preact");function uo(e){return(0,hr.h)(Xe,{method:"applepay",...e})}var Qe=uo;function po({configuration:e,paymentMethods:t}){let{i18n:r}=V(),{activePaymentMethod:o,setActivePaymentMethod:a,isObscuredByThreeDS:n,isSolePaymentMethod:i,hasApplePay:l}=k(),[d,m]=(0,fr.useState)(!1);return!l||d||e.instantPayments&&e.instantPayments.some(p=>p==="applepay")||n("applepay")?null:(0,et.h)(ne,{icon:(0,et.h)(pr,null),title:r.t("applePay.title"),isActive:o==="applepay",isSole:i,onChange:()=>a("applepay")},(0,et.h)(Qe,{configuration:e,paymentMethods:t,isInstantPayment:!1,onUnavailable:()=>m(!0)}))}var _r=po;var ke=require("preact");var y=require("preact"),H=require("preact/hooks");v(`.straumur__stored-card-component__remove-stored-card-button{margin-left:auto}.straumur__stored-card-component__remove-stored-card-button--text{color:var(--straumur__color-danger-text);text-decoration:none;background:none;border:none;cursor:pointer;transition:all .2s ease}.straumur__stored-card-component__remove-stored-card-button--text:disabled{cursor:not-allowed;color:var(--straumur__color-secondary)}.straumur__stored-card-component__confirm-remove-stored-card{background-color:var(--straumur__color-warning-bg);border-radius:var(--straumur__border-radius-s);max-height:0;overflow:hidden;transition:all .3s ease;opacity:0}.straumur__stored-card-component__confirm-remove-stored-card--expanded{padding:var(--straumur__space-xxlg);max-height:600px;opacity:1}.straumur__stored-card-component__confirm-remove-stored-card--header{display:flex;align-items:center;gap:var(--straumur__space-lg);color:var(--straumur__color-text);padding-bottom:var(--straumur__space-xxlg)}.straumur__stored-card-component__confirm-remove-stored-card--actions{display:flex;gap:var(--straumur__space-lg);justify-content:end}.straumur__stored-card-component__confirm-remove-stored-card--actions--button{color:var(--straumur__color-warning-text);background:none;border:none;cursor:pointer;text-decoration:none;font-weight:700}.straumur__stored-card-component__loading-text{display:flex;justify-content:center}.straumur__stored-card-component__form{display:flex;padding-top:var(--straumur__space-xxlg);flex-direction:column;gap:var(--straumur__space-5xlg)}.straumur__stored-card-component__form--wrapper{display:flex;flex-direction:column;justify-items:start;position:relative;width:100%}.straumur__stored-card-component__form--wrapper--error{color:var(--straumur__color-red-beta);font-size:12px}.straumur__stored-card-component__form--wrapper--label{transform:translate(10px) translateY(-50%);z-index:1;background:linear-gradient(to top,var(--straumur__color-secondary-gamma) 53%,var(--straumur__color-transparent) 50%);position:absolute;font-weight:500;font-size:14px;padding:0 var(--straumur__space-xxs)}.straumur__stored-card-component__form--wrapper--label--readonly{background:linear-gradient(to top,var(--straumur__color-gray-epsilon) 53%,var(--straumur__color-transparent) 50%)}.straumur__stored-card-component__form--wrapper--label--error{color:var(--straumur__color-red-beta);background:linear-gradient(to top,var(--straumur__color-red-gamma) 53%,var(--straumur__color-transparent) 50%);font-size:13px;font-weight:500}.straumur__stored-card-component__form--wrapper--label--info{position:absolute;top:33%;right:var(--straumur__space-md)}.straumur__stored-card-component__form--wrapper--input{background:var(--straumur__color-secondary-gamma);color:var(--straumur__color-text);display:flex;align-items:center;border:1px solid var(--straumur__color-transparent);border-radius:var(--straumur__border-radius-s);font-size:16px;height:48px;outline:none;padding-left:var(--straumur__space-lg);transition:border .2s ease-out,box-shadow .2s ease-out;position:relative}.straumur__stored-card-component__form--wrapper--input--readonly{background-color:var(--straumur__color-gray-epsilon)}.straumur__stored-card-component__form--wrapper--input:hover{border:1px solid var(--straumur__color-cosmos-blue-delta)}.straumur__stored-card-component__form--wrapper--input--readonly:hover{border:1px solid var(--straumur__color-transparent)}.straumur__stored-card-component__form--wrapper--input--error{background:var(--straumur__color-red-gamma);border:1px solid var(--straumur__color-red-beta)}.straumur__stored-card-component__form--wrapper--input--error:hover{border:1px solid var(--straumur__color-red-beta)}.straumur__stored-card-component__form--field-wrapper{display:flex;width:100%;gap:var(--straumur__space-lg)}.straumur__stored-card-component__submit-button{background:var(--straumur__color-primary);border:none;border-radius:var(--straumur__border-radius-s);color:var(--straumur__color-white);cursor:pointer;font-size:16px;height:40px;outline:none;padding:0 var(--straumur__space-xxlg);transition:background .2s ease-out;width:100%}.straumur__stored-card-component__submit-button:hover{background:var(--straumur__color-primary);border:1px solid var(--straumur__color-border)}.straumur__stored-card-component__submit-button:disabled{background:var(--straumur__color-gray-epsilon);color:var(--straumur__color-secondary);border:1px solid var(--straumur__color-border);cursor:not-allowed}
|
|
9
9
|
`);var tt=require("@adyen/adyen-web");var se=require("preact"),ho=()=>(0,se.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,se.h)("g",{"clip-path":"url(#clip0_10650_34968)"},(0,se.h)("path",{d:"M12.0011 15C12.6245 15 13.1261 14.4984 13.1261 13.875V7.875C13.1261 7.25391 12.6222 6.75 12.0433 6.75C11.4644 6.75 10.8761 7.25625 10.8761 7.875V13.875C10.8761 14.4984 11.3823 15 12.0011 15ZM12.0011 16.5516C11.1873 16.5516 10.5273 17.2116 10.5273 18.0253C10.5292 18.8391 11.1855 19.5 12.0011 19.5C12.8167 19.5 13.4748 18.84 13.4748 18.0262C13.473 17.2125 12.8167 16.5516 12.0011 16.5516Z",fill:"#DFAE00"}),(0,se.h)("path",{opacity:"0.4",d:"M23.7312 19.5469L13.7328 2.48438C12.9673 1.17188 11.0356 1.17188 10.2649 2.48438L0.271188 19.5469C-0.49803 20.8547 0.460048 22.5 2.00181 22.5H21.9987C23.5343 22.5 24.4953 20.8594 23.7312 19.5469ZM10.8734 7.875C10.8734 7.25391 11.3773 6.75 11.9984 6.75C12.6195 6.75 13.1234 7.25625 13.1234 7.875V13.875C13.1234 14.4961 12.6195 15 12.0406 15C11.4617 15 10.8734 14.4984 10.8734 13.875V7.875ZM11.9984 19.5C11.1846 19.5 10.5246 18.84 10.5246 18.0262C10.5246 17.2125 11.1842 16.5525 11.9984 16.5525C12.8126 16.5525 13.4721 17.2125 13.4721 18.0262C13.4703 18.8391 12.814 19.5 11.9984 19.5Z",fill:"#DFAE00"})),(0,se.h)("defs",null,(0,se.h)("clipPath",{id:"clip0_10650_34968"},(0,se.h)("rect",{width:"24",height:"24",fill:"white"})))),yr=ho;function fo({configuration:e,paymentMethods:t,storedPaymentMethod:r,onStoredCardRemoved:o}){let a=(0,H.useRef)(null),n=(0,H.useRef)(),i=(0,H.useRef)(),{i18n:l}=V(),[d,m]=(0,H.useState)(!0),[p,u]=(0,H.useState)("required"),[P,C]=(0,H.useState)(!1),[D,g]=(0,H.useState)({encryptedSecurityCode:{visible:!1}}),{activePaymentMethod:b,setActivePaymentMethod:R,activeStoredPaymentMethodId:A,setActiveStoredPaymentMethodId:F,isStoredCardInitialized:f,updateStoredCardInitialization:j,handleSuccess:O,handleError:B,setThreeDSecureActive:ee,threeDSecureActive:z,isSolePaymentMethod:K,registerSubmitHandler:J,unregisterSubmitHandler:N}=k(),G=K?b==="storedcard":b==="storedcard"&&A===r.id,ie=X(e.theme);async function te(){await We(e.paymentFlow,()=>i.current)}(0,H.useEffect)(()=>{if(!(G&&f[r.id]&&!z)){e.onCardValidityChanged?.(!1,!1);return}return J(te),e.onCardValidityChanged?.(!1,!0),()=>{N(te),e.onCardValidityChanged?.(!1,!1)}},[G,f[r.id],z,J,N]);let{handleOnSubmit:S,handleOnSubmitAdditionalData:le,handlePaymentCompleted:q,handlePaymentFailed:Se}=ae({configuration:e,handleSuccess:O,handleError:B,setThreeDSecureActive:ee,enrichSubmitData:x=>({...x,paymentMethod:{...x.paymentMethod,storedPaymentMethodId:r.id}})});function it(x,w){B({key:"error.unknownError"})}let Ae=async()=>{n.current=await(0,tt.AdyenCheckout)({clientKey:t.clientKey,environment:e.environment,locale:e.locale,countryCode:e.countryCode,amount:{value:t.minorUnitsAmount,currency:t.currency},paymentMethodsResponse:t.paymentMethods,onError:it,onAdditionalDetails:le,onPaymentCompleted:q,onPaymentFailed:Se}),i.current=new tt.CustomCard(n.current,{brands:[r.brand],styles:Je(ie),onSubmit:S,onConfigSuccess(){j(r.id,!0)},onBrand:x=>{u(x.cvcPolicy)},onValidationError:x=>{let w={encryptedSecurityCode:{visible:!1,message:void 0}};x.filter(xe=>xe.error).forEach(xe=>{w[xe.fieldType].visible=!0,w[xe.fieldType].message=xe.errorI18n}),g(w)},onAllValid:x=>{m(!x.allValid),e.onCardValidityChanged?.(x.allValid,!0)},placeholders:e.placeholders,challengeWindowSize:"05"}),a.current&&i.current.mount(a.current)};if((0,H.useEffect)(()=>{G&&!f[r.id]&&Ae()},[e,G]),ge(e,()=>!!(i.current&&f[A]),()=>{Ae(),g({encryptedSecurityCode:{visible:!1,message:void 0}})}),(0,H.useEffect)(()=>{C(!1)},[b,A]),je(a,z&&G),z&&!G)return null;function lt(){R("storedcard"),F(r.id)}function mt(){C(!0)}function dt(){C(!1)}async function Re(){let{disableToken:x}=e.paymentFlow;if(x)try{await x(r.id),o(r.id)}catch(w){B(Me(w,"error.failedToSubmitRemoveStoredPaymentCard"))}}let ct=e.paymentFlow.disableToken!==void 0&&G&&f[r.id]?(0,y.h)("div",{className:"straumur__stored-card-component__remove-stored-card-button"},(0,y.h)("button",{onClick:mt,className:"straumur__stored-card-component__remove-stored-card-button--text",disabled:P},l.t("stored-cards.removeStoredCard"))):null,_=(0,y.h)("div",{className:`straumur__stored-card-component__confirm-remove-stored-card ${P?"straumur__stored-card-component__confirm-remove-stored-card--expanded":""}`},(0,y.h)("div",{className:"straumur__stored-card-component__confirm-remove-stored-card--header"},(0,y.h)(yr,null),(0,y.h)("span",{className:"straumur__stored-card-component__confirm-remove-stored-card--header--title"},l.t("stored-cards.removeStoredCardQuestion"))),(0,y.h)("div",{className:"straumur__stored-card-component__confirm-remove-stored-card--actions"},(0,y.h)("button",{className:"straumur__stored-card-component__confirm-remove-stored-card--actions--button",onClick:Re},l.t("stored-cards.removeStoredCardQuestionYesRemove")),(0,y.h)("button",{className:"straumur__stored-card-component__confirm-remove-stored-card--actions--button",onClick:dt},l.t("stored-cards.removeStoredCardQuestionCancel"))));return(0,y.h)(ne,{icon:(0,y.h)(Ze,{brands:[{brand:r.brand,brandFullName:r.name}],theme:ie}),title:`\u2022\u2022\u2022\u2022 ${r.lastFour}`,isActive:G,isSole:K,onChange:lt,headerRight:ct,confirmSection:_},(0,y.h)("div",{ref:a,tabIndex:-1,style:{height:z?"600px":"auto",minWidth:z?"350px":"auto"}},!f[r.id]&&(0,y.h)("div",{className:"straumur__stored-card-component__loading-text"},(0,y.h)($,null)),(0,y.h)("div",{className:"straumur__stored-card-component__form",style:{opacity:f[r.id]&&!z?1:0,position:f[r.id]&&!z?"relative":"absolute",transition:"opacity 0.3s ease-in-out"}},(0,y.h)("div",{className:"straumur__stored-card-component__form--field-wrapper"},(0,y.h)("div",{className:"straumur__stored-card-component__form--wrapper"},(0,y.h)("label",{className:"straumur__stored-card-component__form--wrapper--label straumur__stored-card-component__form--wrapper--label--readonly"},l.t("stored-cards.expiryDate")),(0,y.h)("span",{className:"straumur__stored-card-component__form--wrapper--input straumur__stored-card-component__form--wrapper--input--readonly"},r.expiryMonth,"/",r.expiryYear)),(0,y.h)("div",{className:"straumur__stored-card-component__form--wrapper"},(p==="optional"||p==="required")&&(0,y.h)(y.Fragment,null,(0,y.h)("label",{className:`straumur__stored-card-component__form--wrapper--label ${D.encryptedSecurityCode.visible?"straumur__stored-card-component__form--wrapper--label--error":""}`},p==="optional"?l.t("stored-cards.securityCode3DigitsOptional"):l.t("stored-cards.securityCode3Digits")),(0,y.h)("span",{className:`straumur__stored-card-component__form--wrapper--input ${D.encryptedSecurityCode.visible?"straumur__stored-card-component__form--wrapper--input--error":""}`,"data-cse":"encryptedSecurityCode",role:"group","aria-label":l.t("stored-cards.securityCode3Digits")},(0,y.h)("div",{className:"straumur__stored-card-component__form--wrapper--label--info"},(0,y.h)(ve,{content:l.t("stored-cards.securityCode3DigitsInfo"),placement:"top"},(0,y.h)(Ge,null))))),D.encryptedSecurityCode.visible&&(0,y.h)("span",{className:"straumur__stored-card-component__form--wrapper--error"},D.encryptedSecurityCode.message))),!e.hideSubmitButton&&(0,y.h)("button",{className:"straumur__stored-card-component__submit-button",disabled:d,onClick:te},t.minorUnitsAmount===0?l.t("stored-cards.saveCardDetails"):t.formattedAmount))))}var vr=fo;var gr=require("preact/hooks");function _o({configuration:e,paymentMethods:t}){let[r,o]=(0,gr.useState)(t.paymentMethods.storedPaymentMethods??[]),{isObscuredByThreeDS:a,hasStoredPaymentMethods:n}=k();if(!n||a("storedcard"))return null;function i(l){o(d=>d.filter(m=>m.id!==l))}return(0,ke.h)(ke.Fragment,null,r?.map(l=>(0,ke.h)(vr,{key:l.id,configuration:e,storedPaymentMethod:l,paymentMethods:t,onStoredCardRemoved:i})))}var br=_o;var bt=require("preact");v(`.straumur__payment-method-group{display:flex;flex-direction:column;gap:var(--straumur__space-xxlg);width:100%;position:relative}
|
|
10
10
|
`);function yo({children:e,initialValue:t,initialStoredPaymentMethodId:r,isSolePaymentMethod:o,hasCard:a,hasGooglePay:n,hasApplePay:i,hasStoredPaymentMethods:l,onSubmitApiReady:d}){return(0,bt.h)(Dt,{initialValue:t,initialStoredPaymentMethodId:r,isSolePaymentMethod:o,hasCard:a,hasGooglePay:n,hasApplePay:i,hasStoredPaymentMethods:l,onSubmitApiReady:d},(0,bt.h)("div",{className:"straumur__payment-method-group"},e))}var Cr=yo;var U=require("preact");v(`.straumur__result-component{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--straumur__space-5xlg);padding:var(--straumur__space-6xlg);width:100%;min-height:300px;background-color:var(--straumur__color-white);border-radius:var(--straumur__border-radius-xxlg)}
|
|
11
11
|
`);var Ie=require("preact");v(`.straumur__result-icon{display:block}.straumur__result-icon__ring,.straumur__result-icon__check,.straumur__result-icon__x,.straumur__result-icon__halo,.straumur__result-icon__cross{transform-box:fill-box;transform-origin:center}.straumur__result-icon__ring{fill:none;stroke-width:5;stroke-linecap:round;stroke-dasharray:100;stroke-dashoffset:100;animation:straumur-result-draw .6s cubic-bezier(.65,0,.35,1) forwards}.straumur__result-icon__halo{opacity:0;animation:straumur-result-halo .9s .45s ease-out}.straumur__result-icon__check{fill:none;stroke-width:7;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:100;stroke-dashoffset:100;animation:straumur-result-draw .4s .55s cubic-bezier(.65,0,.35,1) forwards,straumur-result-pop .45s .9s ease-out}.straumur__result-icon__x{fill:none;stroke-width:7;stroke-linecap:round;stroke-dasharray:100;stroke-dashoffset:100;animation:straumur-result-draw .3s cubic-bezier(.65,0,.35,1) forwards}.straumur__result-icon__x--1{animation-delay:.6s}.straumur__result-icon__x--2{animation-delay:.82s}.straumur__result-icon__cross{animation:straumur-result-shake .4s 1.15s ease-in-out}.straumur__result-icon--success .straumur__result-icon__ring,.straumur__result-icon--success .straumur__result-icon__check{stroke:var(--straumur__color-success)}.straumur__result-icon--success .straumur__result-icon__halo{fill:var(--straumur__color-success)}.straumur__result-icon--failure .straumur__result-icon__ring,.straumur__result-icon--failure .straumur__result-icon__x{stroke:var(--straumur__color-danger-text)}.straumur__result-icon--failure .straumur__result-icon__halo{fill:var(--straumur__color-danger-text)}@keyframes straumur-result-draw{to{stroke-dashoffset:0}}@keyframes straumur-result-pop{0%{transform:scale(1)}45%{transform:scale(1.12)}to{transform:scale(1)}}@keyframes straumur-result-halo{0%{opacity:.35;transform:scale(.55)}to{opacity:0;transform:scale(1.35)}}@keyframes straumur-result-shake{0%,to{transform:translate(0)}25%{transform:translate(-3px)}75%{transform:translate(3px)}}@media(prefers-reduced-motion:reduce){.straumur__result-icon__ring,.straumur__result-icon__check,.straumur__result-icon__x,.straumur__result-icon__halo,.straumur__result-icon__cross{animation:none}.straumur__result-icon__ring,.straumur__result-icon__check,.straumur__result-icon__x{stroke-dashoffset:0}.straumur__result-icon__halo{opacity:0}}
|
|
12
12
|
`);var vo=()=>(0,Ie.h)("svg",{className:"straumur__result-icon straumur__result-icon--success",xmlns:"http://www.w3.org/2000/svg",width:"120",height:"120",viewBox:"0 0 120 120",role:"img"},(0,Ie.h)("circle",{className:"straumur__result-icon__halo",cx:"60",cy:"60",r:"52"}),(0,Ie.h)("circle",{className:"straumur__result-icon__ring",cx:"60",cy:"60",r:"50",pathLength:"100"}),(0,Ie.h)("path",{className:"straumur__result-icon__check",d:"M37 62 L53 78 L84 44",pathLength:"100"})),rt=vo;var he=require("preact");var go=()=>(0,he.h)("svg",{className:"straumur__result-icon straumur__result-icon--failure",xmlns:"http://www.w3.org/2000/svg",width:"120",height:"120",viewBox:"0 0 120 120",role:"img"},(0,he.h)("circle",{className:"straumur__result-icon__halo",cx:"60",cy:"60",r:"52"}),(0,he.h)("circle",{className:"straumur__result-icon__ring",cx:"60",cy:"60",r:"50",pathLength:"100"}),(0,he.h)("g",{className:"straumur__result-icon__cross"},(0,he.h)("line",{className:"straumur__result-icon__x straumur__result-icon__x--1",x1:"42",y1:"42",x2:"78",y2:"78",pathLength:"100"}),(0,he.h)("line",{className:"straumur__result-icon__x straumur__result-icon__x--2",x1:"78",y1:"42",x2:"42",y2:"78",pathLength:"100"}))),ot=go;function bo(){let{error:e,success:t}=k(),{i18n:r}=V();if(!e&&!t)return null;let o=a=>"key"in a?r.t(a.key):a.text;return(0,U.h)("div",{className:"straumur__result-component"},e&&(0,U.h)(U.Fragment,null,(0,U.h)("span",{"aria-hidden":"true"},(0,U.h)(ot,null)),(0,U.h)("p",{className:"straumur__result-component__error--message straumur__result-message",role:"alert"},o(e))),t&&(0,U.h)(U.Fragment,null,(0,U.h)("span",{"aria-hidden":"true"},(0,U.h)(rt,null)),(0,U.h)("p",{className:"straumur__result-component__success--message straumur__result-message",role:"status"},o(t))))}var Pr=bo;var fe=require("preact"),Ee=require("preact/hooks");v(`.straumur__master-loader{display:flex;align-items:center;justify-content:center;width:100%;min-height:240px}.straumur__methods{display:flex;flex-direction:column;gap:var(--straumur__space-xxlg)}.straumur__methods--loading{position:absolute;top:0;left:0;width:100%;opacity:0;pointer-events:none}
|
|
13
|
-
`);var Co=4e3;function Po({children:e}){let{error:t,success:r,hasGooglePay:o,hasApplePay:a,isPaymentMethodInitialized:n,isStoredCardInitialized:i,activePaymentMethod:l,activeStoredPaymentMethodId:d}=k(),[m,p]=(0,Ee.useState)(!1),u=(!o||n.googlepay)&&(!a||n.applepay),P=!0;l==="card"?P=n.card:l==="storedcard"&&(P=d?!!i[d]:!0);let C=u&&P;return(0,Ee.useEffect)(()=>{C&&p(!0)},[C]),(0,Ee.useEffect)(()=>{let D=setTimeout(()=>p(!0),Co);return()=>clearTimeout(D)},[]),t||r?null:(0,fe.h)(fe.Fragment,null,!m&&(0,fe.h)("div",{className:"straumur__master-loader",role:"status"},(0,fe.h)($,null)),(0,fe.h)("div",{className:`straumur__methods${m?"":" straumur__methods--loading"}`},e))}var Sr=Po;var at=require("preact"),xr=require("preact/hooks");v(`.instant-payments{display:grid;gap:var(--straumur__space-lg);grid-template-columns:1fr 1fr}.instant-payments--single{grid-template-columns:1fr}@container straumur (max-width:
|
|
14
|
-
`);function So({configuration:e,paymentMethods:t}){let{hasGooglePay:r,hasApplePay:o}=k(),[a,n]=(0,xr.useState)(new Set),i=u=>{n(P=>new Set(P).add(u))};if(!e.instantPayments)return null;let l=["googlepay","applepay"],m=e.instantPayments.filter(u=>l.includes(u)).filter(u=>u==="googlepay"?r:o),p=m.filter(u=>!a.has(u));return m.length===0?null:(0,at.h)("div",{className:`straumur__instant-payments instant-payments ${p.length>1?"straumur__instant-payments--multiple instant-payments--multiple":"straumur__instant-payments--single instant-payments--single"}`,style:{display:p.length===0?"none":void 0}},
|
|
13
|
+
`);var Co=4e3;function Po({children:e}){let{error:t,success:r,hasGooglePay:o,hasApplePay:a,isPaymentMethodInitialized:n,isStoredCardInitialized:i,activePaymentMethod:l,activeStoredPaymentMethodId:d}=k(),[m,p]=(0,Ee.useState)(!1),u=(!o||n.googlepay)&&(!a||n.applepay),P=!0;l==="card"?P=n.card:l==="storedcard"&&(P=d?!!i[d]:!0);let C=u&&P;return(0,Ee.useEffect)(()=>{C&&p(!0)},[C]),(0,Ee.useEffect)(()=>{let D=setTimeout(()=>p(!0),Co);return()=>clearTimeout(D)},[]),t||r?null:(0,fe.h)(fe.Fragment,null,!m&&(0,fe.h)("div",{className:"straumur__master-loader",role:"status"},(0,fe.h)($,null)),(0,fe.h)("div",{className:`straumur__methods${m?"":" straumur__methods--loading"}`},e))}var Sr=Po;var at=require("preact"),xr=require("preact/hooks");v(`.instant-payments{display:grid;gap:var(--straumur__space-lg);grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.instant-payments--single{grid-template-columns:1fr}@container straumur (max-width: 499px){.instant-payments{grid-template-columns:1fr}}
|
|
14
|
+
`);function So({configuration:e,paymentMethods:t}){let{hasGooglePay:r,hasApplePay:o}=k(),[a,n]=(0,xr.useState)(new Set),i=u=>{n(P=>new Set(P).add(u))};if(!e.instantPayments)return null;let l=["googlepay","applepay"],m=e.instantPayments.filter(u=>l.includes(u)).filter(u=>u==="googlepay"?r:o),p=m.filter(u=>!a.has(u));return m.length===0?null:(0,at.h)("div",{className:`straumur__instant-payments instant-payments ${p.length>1?"straumur__instant-payments--multiple instant-payments--multiple":"straumur__instant-payments--single instant-payments--single"}`,style:{display:p.length===0?"none":void 0}},p.map(u=>u==="googlepay"?(0,at.h)(qe,{key:u,configuration:e,paymentMethods:t,isInstantPayment:!0,onUnavailable:()=>i("googlepay")}):u==="applepay"?(0,at.h)(Qe,{key:u,configuration:e,paymentMethods:t,isInstantPayment:!0,onUnavailable:()=>i("applepay")}):null))}var Mr=So;var Ct=["instantpayments","storedcard","card","googlepay","applepay"],xo=new Set(Ct);function wr(e){if(!e)return[...Ct];let t=new Set,r=[];for(let o of e)xo.has(o)&&!t.has(o)&&(t.add(o),r.push(o));for(let o of Ct)t.has(o)||r.push(o);return r}function Mo(e,t,r,o,a,n){let i=t&&!a?.some(m=>m==="googlepay"),l=r&&!a?.some(m=>m==="applepay");return o+(e?1:0)+(i?1:0)+(l?1:0)===1?o===1?{initialPaymentMethod:"storedcard",isSolePaymentMethod:!0}:e?{initialPaymentMethod:"card",isSolePaymentMethod:!0}:i?{initialPaymentMethod:"googlepay",isSolePaymentMethod:!0}:l?{initialPaymentMethod:"applepay",isSolePaymentMethod:!0}:{initialPaymentMethod:null,isSolePaymentMethod:!1}:n==="card"&&e?{initialPaymentMethod:"card",isSolePaymentMethod:!1}:n==="googlepay"&&i?{initialPaymentMethod:"googlepay",isSolePaymentMethod:!1}:n==="applepay"&&l?{initialPaymentMethod:"applepay",isSolePaymentMethod:!1}:n==="firstStoredCard"&&o>0?{initialPaymentMethod:"storedcard",isSolePaymentMethod:!1}:{initialPaymentMethod:null,isSolePaymentMethod:!1}}function wo({configuration:e,paymentMethods:t,onSubmitApiReady:r}){let o=t.paymentMethods.paymentMethods??[],a=t.paymentMethods.storedPaymentMethods??[],n=b=>!e.allowedPaymentMethods||e.allowedPaymentMethods.includes(b),i=o.some(b=>b.type==="scheme")&&n("card"),l=o.some(b=>b.type==="googlepay")&&n("googlepay"),d=o.some(b=>b.type==="applepay")&&n("applepay"),m=n("storedcard")?a.length:0,p=m>0,{initialPaymentMethod:u,isSolePaymentMethod:P}=Mo(i,l,d,m,e.instantPayments,e.openDefaultPaymentMethod),C=u==="storedcard"&&!P?a[0]?.id??null:null,D={instantpayments:(0,Q.h)(Mr,{key:"instantpayments",configuration:e,paymentMethods:t}),storedcard:(0,Q.h)(br,{key:"storedcard",configuration:e,paymentMethods:t}),card:(0,Q.h)(nr,{key:"card",configuration:e,paymentMethods:t}),googlepay:(0,Q.h)(ur,{key:"googlepay",configuration:e,paymentMethods:t}),applepay:(0,Q.h)(_r,{key:"applepay",configuration:e,paymentMethods:t})},g=wr(e.orderPaymentMethods);return(0,Q.h)(Cr,{initialValue:u,initialStoredPaymentMethodId:C,isSolePaymentMethod:P,hasCard:i,hasGooglePay:l,hasApplePay:d,hasStoredPaymentMethods:p,onSubmitApiReady:r},(0,Q.h)(Sr,null,g.map(b=>D[b])),(0,Q.h)(Pr,null))}var kr=wo;var Rr=require("@adyen/adyen-web");var nt=class{constructor(t,r){this.language=t;this.customLocalizations=r}t(t){return this.customLocalizations?.[this.language]?.[t]||De[this.language][t]||t}setLanguage(t){this.language=t}updateCustomLocalizations(t){this.customLocalizations=t}};var W=require("preact");function st({children:e,theme:t="light"}){let r=X(t);return(0,W.h)("div",{className:"straumur__root-component","data-theme":r},e)}function Ir({theme:e}){return(0,W.h)(st,{theme:e},(0,W.h)("div",{className:"straumur__component"},(0,W.h)($,null)))}function Pt({variant:e,message:t,i18n:r,theme:o}){return(0,W.h)(st,{theme:o},(0,W.h)("div",{className:"straumur__component"},(0,W.h)("span",{"aria-hidden":"true"},e==="success"?(0,W.h)(rt,null):(0,W.h)(ot,null)),(0,W.h)("p",{className:"straumur__result-message",role:e==="success"?"status":"alert"},"key"in t?r.t(t.key):t.text)))}function Er(e,t){return{resultCode:"Success",clientKey:e.clientKey,paymentMethods:e.paymentMethods,minorUnitsAmount:e.amount.value,currency:e.amount.currency,amount:e.amount.value/100,formattedAmount:e.formattedAmount,merchantName:e.merchantName,enableStoreDetails:e.enableStoreDetails,locale:t}}var ko="IS";function Io(e){return typeof e.sessionId=="string"&&e.sessionId.length>0}function Eo(e){return typeof e=="object"?{theme:e.theme??"light",googlePayButtonTheme:e.googlePayButtonTheme,applePayButtonTheme:e.applePayButtonTheme}:{theme:e??"light"}}function Ao(e){return typeof e.clientKey=="string"&&e.clientKey.length>0&&typeof e.countryCode=="string"&&e.countryCode.length>0&&typeof e.paymentMethods=="object"&&e.paymentMethods!==null&&typeof e.amount=="object"&&e.amount!==null&&typeof e.amount.value=="number"&&typeof e.amount.currency=="string"&&typeof e.onSubmit=="function"&&typeof e.onAdditionalDetails=="function"}function Ar(e){let t=e,r=Be(t.locale),o=Io(t),a=Eo(t.theme),n={mode:o?"session":"advanced",sessionId:t.sessionId,environment:t.environment,countryCode:o?ko:t.countryCode,paymentFlow:o?Yt(t.environment,t.sessionId):Qt(t),onPaymentCompleted:t.onPaymentCompleted,onPaymentFailed:t.onPaymentFailed,placeholders:t.placeholders,locale:r,customLocalizations:t.localizations,instantPayments:t.instantPayments,hideSubmitButton:t.hideSubmitButton,onCardValidityChanged:t.onCardValidityChanged,allowedPaymentMethods:t.allowedPaymentMethods,orderPaymentMethods:t.orderPaymentMethods,openDefaultPaymentMethod:t.openDefaultPaymentMethod,theme:a.theme,googlePayButtonTheme:a.googlePayButtonTheme,applePayButtonTheme:a.applePayButtonTheme};return o?{configuration:n,advancedConfiguration:null,paymentMethods:null,initializationFailed:!1}:Ao(t)?{configuration:n,advancedConfiguration:t,paymentMethods:Er(t,r),initializationFailed:!1}:{configuration:n,advancedConfiguration:null,paymentMethods:null,initializationFailed:!0}}var St=class{configuration;advancedConfiguration=null;paymentMethods=null;mountElement=null;i18n;submitApi=null;initializationFailed=!1;constructor(t){let r=Ar(t);this.configuration=r.configuration,this.advancedConfiguration=r.advancedConfiguration,this.paymentMethods=r.paymentMethods,this.initializationFailed=r.initializationFailed,this.i18n=new nt(this.configuration.locale,this.configuration.customLocalizations)}async mount(t){try{if(this.mountElement=typeof t=="string"?document.querySelector(t):t,!this.mountElement)return;if(this.initializationFailed){this.handleError({key:"error.failedToInitializeStraumurWebComponent"});return}if(this.configuration.mode==="advanced"){this.renderComponent();return}(0,Z.render)((0,Z.h)(Ir,{theme:this.configuration.theme}),this.mountElement);let r=await pt(this.configuration.environment,this.configuration.sessionId);if(r.resultCode==="Error"){this.handleError({key:r.error});return}this.paymentMethods=r,this.renderComponent()}catch(r){console.error("[StraumurCheckout] mount() failed:",r)}}renderComponent(){this.mountElement&&(0,Z.render)((0,Z.h)(st,{theme:this.configuration.theme},(0,Z.h)(Lt,{i18nService:this.i18n,onLanguageChange:t=>{this.configuration.locale=t,this.renderComponent()}},(0,Z.h)(kr,{configuration:this.configuration,paymentMethods:this.paymentMethods,onSubmitApiReady:t=>{this.submitApi=t}}))),this.mountElement)}handleSuccess(t){this.mountElement&&(0,Z.render)((0,Z.h)(Pt,{variant:"success",message:t,i18n:this.i18n,theme:this.configuration.theme}),this.mountElement)}handleError(t){this.mountElement&&(0,Z.render)((0,Z.h)(Pt,{variant:"failure",message:t,i18n:this.i18n,theme:this.configuration.theme}),this.mountElement)}async resolveRedirectContext(){if(this.configuration.mode==="advanced")return this.initializationFailed||!this.advancedConfiguration?(this.handleError({key:"error.failedToInitializeStraumurWebComponent"}),null):{clientKey:this.advancedConfiguration.clientKey,paymentMethods:this.advancedConfiguration.paymentMethods};let t=await pt(this.configuration.environment,this.configuration.sessionId);return t.resultCode==="Error"?(this.handleError({key:t.error}),null):{clientKey:t.clientKey,paymentMethods:t.paymentMethods}}async submitDetails(t,r){try{r&&(this.mountElement=typeof r=="string"?document.querySelector(r):r);let o=await this.resolveRedirectContext();if(!o)return;let{handleOnSubmitAdditionalData:a}=ae({configuration:this.configuration,handleSuccess:i=>this.handleSuccess(i),handleError:i=>this.handleError(i),setThreeDSecureActive:()=>{},dispatchResultFromAdditionalDetails:!0});(await(0,Rr.AdyenCheckout)({environment:this.configuration.environment,clientKey:o.clientKey,paymentMethodsResponse:o.paymentMethods,countryCode:this.configuration.countryCode,onAdditionalDetails:a})).submitDetails({details:{redirectResult:t}})}catch(o){console.error("[StraumurCheckout] submitDetails() failed:",o),this.handleError({key:"error.failedToSubmitPaymentDetails"}),this.configuration.onPaymentFailed?.({resultCode:"Error"})}}updateConfig(t){let{locale:r,...o}=t;this.configuration={...this.configuration,...o,...r?{locale:Be(r)}:{}},r&&this.i18n.setLanguage(this.configuration.locale),t.customLocalizations&&this.i18n.updateCustomLocalizations(t.customLocalizations),this.mountElement&&this.renderComponent()}setLanguage(t){this.updateConfig({locale:t})}destroy(){this.mountElement&&((0,Z.render)(null,this.mountElement),this.mountElement=null),this.submitApi=null}submitCard(){if(!this.mountElement)return console.warn("[StraumurCheckout] submitCard() called before the component was mounted."),!1;if(!this.submitApi)return console.warn("[StraumurCheckout] submitCard() called but the component is not ready yet."),!1;let t=this.submitApi.triggerSubmit();return t||console.warn("[StraumurCheckout] submitCard() called but no card-type payment method is currently active and initialized."),t}},Tr=St;0&&(module.exports={StraumurCheckout});
|
|
15
15
|
//# sourceMappingURL=index.cjs.map
|