@adyen/adyen-document-viewer
Version:
Adyen Document Viewer
6 lines (5 loc) • 23.9 kB
JavaScript
(function($,d){typeof exports=="object"&&typeof module<"u"?module.exports=d():typeof define=="function"&&define.amd?define(d):($=typeof globalThis<"u"?globalThis:$||self,$.AdyenDocumentViewer=d())})(this,function(){"use strict";var $,d,se,P,le,ae,J,ue,D={},fe=[],Ye=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Q=Array.isArray;function C(e,t){for(var n in t)e[n]=t[n];return e}function de(e){var t=e.parentNode;t&&t.removeChild(e)}function pe(e,t,n){var o,_,r,c={};for(r in t)r=="key"?o=t[r]:r=="ref"?_=t[r]:c[r]=t[r];if(arguments.length>2&&(c.children=arguments.length>3?$.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(r in e.defaultProps)c[r]===void 0&&(c[r]=e.defaultProps[r]);return U(e,c,o,_,null)}function U(e,t,n,o,_){var r={type:e,props:t,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:_??++se,__i:-1,__u:0};return _==null&&d.vnode!=null&&d.vnode(r),r}function V(e){return e.children}function O(e,t){this.props=e,this.context=t}function L(e,t){if(t==null)return e.__?L(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?L(e):null}function he(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return he(e)}}function X(e){(!e.__d&&(e.__d=!0)&&P.push(e)&&!W.__r++||le!==d.debounceRendering)&&((le=d.debounceRendering)||ae)(W)}function W(){var e,t,n,o,_,r,c,s,u;for(P.sort(J);e=P.shift();)e.__d&&(t=P.length,o=void 0,r=(_=(n=e).__v).__e,s=[],u=[],(c=n.__P)&&((o=C({},_)).__v=_.__v+1,d.vnode&&d.vnode(o),Z(c,o,_,n.__n,c.ownerSVGElement!==void 0,32&_.__u?[r]:null,s,r??L(_),!!(32&_.__u),u),o.__.__k[o.__i]=o,we(s,o,u),o.__e!=r&&he(o)),P.length>t&&P.sort(J));W.__r=0}function ve(e,t,n,o,_,r,c,s,u,l,p){var i,h,f,m,w,b=o&&o.__k||fe,y=t.length;for(n.__d=u,Ke(n,t,b),u=n.__d,i=0;i<y;i++)(f=n.__k[i])!=null&&typeof f!="boolean"&&typeof f!="function"&&(h=f.__i===-1?D:b[f.__i]||D,f.__i=i,Z(e,f,h,_,r,c,s,u,l,p),m=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&ee(h.ref,null,f),p.push(f.ref,f.__c||m,f)),w==null&&m!=null&&(w=m),65536&f.__u||h.__k===f.__k?u=me(f,u,e):typeof f.type=="function"&&f.__d!==void 0?u=f.__d:m&&(u=m.nextSibling),f.__d=void 0,f.__u&=-196609);n.__d=u,n.__e=w}function Ke(e,t,n){var o,_,r,c,s,u=t.length,l=n.length,p=l,i=0;for(e.__k=[],o=0;o<u;o++)(_=e.__k[o]=(_=t[o])==null||typeof _=="boolean"||typeof _=="function"?null:typeof _=="string"||typeof _=="number"||typeof _=="bigint"||_.constructor==String?U(null,_,null,null,_):Q(_)?U(V,{children:_},null,null,null):_.constructor===void 0&&_.__b>0?U(_.type,_.props,_.key,_.ref?_.ref:null,_.__v):_)!=null?(_.__=e,_.__b=e.__b+1,s=Je(_,n,c=o+i,p),_.__i=s,r=null,s!==-1&&(p--,(r=n[s])&&(r.__u|=131072)),r==null||r.__v===null?(s==-1&&i--,typeof _.type!="function"&&(_.__u|=65536)):s!==c&&(s===c+1?i++:s>c?p>u-c?i+=s-c:i--:i=s<c&&s==c-1?s-c:0,s!==o+i&&(_.__u|=65536))):(r=n[o])&&r.key==null&&r.__e&&(r.__e==e.__d&&(e.__d=L(r)),te(r,r,!1),n[o]=null,p--);if(p)for(o=0;o<l;o++)(r=n[o])!=null&&!(131072&r.__u)&&(r.__e==e.__d&&(e.__d=L(r)),te(r,r))}function me(e,t,n){var o,_;if(typeof e.type=="function"){for(o=e.__k,_=0;o&&_<o.length;_++)o[_]&&(o[_].__=e,t=me(o[_],t,n));return t}return e.__e!=t&&(n.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function Je(e,t,n,o){var _=e.key,r=e.type,c=n-1,s=n+1,u=t[n];if(u===null||u&&_==u.key&&r===u.type)return n;if(o>(u!=null&&!(131072&u.__u)?1:0))for(;c>=0||s<t.length;){if(c>=0){if((u=t[c])&&!(131072&u.__u)&&_==u.key&&r===u.type)return c;c--}if(s<t.length){if((u=t[s])&&!(131072&u.__u)&&_==u.key&&r===u.type)return s;s++}}return-1}function ye(e,t,n){t[0]==="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||Ye.test(t)?n:n+"px"}function M(e,t,n,o,_){var r;e:if(t==="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof o=="string"&&(e.style.cssText=o=""),o)for(t in o)n&&t in n||ye(e.style,t,"");if(n)for(t in n)o&&n[t]===o[t]||ye(e.style,t,n[t])}else if(t[0]==="o"&&t[1]==="n")r=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=n,n?o?n.u=o.u:(n.u=Date.now(),e.addEventListener(t,r?ge:be,r)):e.removeEventListener(t,r?ge:be,r);else{if(_)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!=="width"&&t!=="height"&&t!=="href"&&t!=="list"&&t!=="form"&&t!=="tabIndex"&&t!=="download"&&t!=="rowSpan"&&t!=="colSpan"&&t!=="role"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!=="-"?e.removeAttribute(t):e.setAttribute(t,n))}}function be(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(d.event?d.event(e):e)}function ge(e){return this.l[e.type+!0](d.event?d.event(e):e)}function Z(e,t,n,o,_,r,c,s,u,l){var p,i,h,f,m,w,b,y,g,E,G,R,Ge,Y,ce,k=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),r=[s=t.__e=n.__e]),(p=d.__b)&&p(t);e:if(typeof k=="function")try{if(y=t.props,g=(p=k.contextType)&&o[p.__c],E=p?g?g.props.value:p.__:o,n.__c?b=(i=t.__c=n.__c).__=i.__E:("prototype"in k&&k.prototype.render?t.__c=i=new k(y,E):(t.__c=i=new O(y,E),i.constructor=k,i.render=Xe),g&&g.sub(i),i.props=y,i.state||(i.state={}),i.context=E,i.__n=o,h=i.__d=!0,i.__h=[],i._sb=[]),i.__s==null&&(i.__s=i.state),k.getDerivedStateFromProps!=null&&(i.__s==i.state&&(i.__s=C({},i.__s)),C(i.__s,k.getDerivedStateFromProps(y,i.__s))),f=i.props,m=i.state,i.__v=t,h)k.getDerivedStateFromProps==null&&i.componentWillMount!=null&&i.componentWillMount(),i.componentDidMount!=null&&i.__h.push(i.componentDidMount);else{if(k.getDerivedStateFromProps==null&&y!==f&&i.componentWillReceiveProps!=null&&i.componentWillReceiveProps(y,E),!i.__e&&(i.shouldComponentUpdate!=null&&i.shouldComponentUpdate(y,i.__s,E)===!1||t.__v===n.__v)){for(t.__v!==n.__v&&(i.props=y,i.state=i.__s,i.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.forEach(function(K){K&&(K.__=t)}),G=0;G<i._sb.length;G++)i.__h.push(i._sb[G]);i._sb=[],i.__h.length&&c.push(i);break e}i.componentWillUpdate!=null&&i.componentWillUpdate(y,i.__s,E),i.componentDidUpdate!=null&&i.__h.push(function(){i.componentDidUpdate(f,m,w)})}if(i.context=E,i.props=y,i.__P=e,i.__e=!1,R=d.__r,Ge=0,"prototype"in k&&k.prototype.render){for(i.state=i.__s,i.__d=!1,R&&R(t),p=i.render(i.props,i.state,i.context),Y=0;Y<i._sb.length;Y++)i.__h.push(i._sb[Y]);i._sb=[]}else do i.__d=!1,R&&R(t),p=i.render(i.props,i.state,i.context),i.state=i.__s;while(i.__d&&++Ge<25);i.state=i.__s,i.getChildContext!=null&&(o=C(C({},o),i.getChildContext())),h||i.getSnapshotBeforeUpdate==null||(w=i.getSnapshotBeforeUpdate(f,m)),ve(e,Q(ce=p!=null&&p.type===V&&p.key==null?p.props.children:p)?ce:[ce],t,n,o,_,r,c,s,u,l),i.base=t.__e,t.__u&=-161,i.__h.length&&c.push(i),b&&(i.__E=i.__=null)}catch(K){t.__v=null,u||r!=null?(t.__e=s,t.__u|=u?160:32,r[r.indexOf(s)]=null):(t.__e=n.__e,t.__k=n.__k),d.__e(K,t,n)}else r==null&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=Qe(n.__e,t,n,o,_,r,c,u,l);(p=d.diffed)&&p(t)}function we(e,t,n){t.__d=void 0;for(var o=0;o<n.length;o++)ee(n[o],n[++o],n[++o]);d.__c&&d.__c(t,e),e.some(function(_){try{e=_.__h,_.__h=[],e.some(function(r){r.call(_)})}catch(r){d.__e(r,_.__v)}})}function Qe(e,t,n,o,_,r,c,s,u){var l,p,i,h,f,m,w,b=n.props,y=t.props,g=t.type;if(g==="svg"&&(_=!0),r!=null){for(l=0;l<r.length;l++)if((f=r[l])&&"setAttribute"in f==!!g&&(g?f.localName===g:f.nodeType===3)){e=f,r[l]=null;break}}if(e==null){if(g===null)return document.createTextNode(y);e=_?document.createElementNS("http://www.w3.org/2000/svg",g):document.createElement(g,y.is&&y),r=null,s=!1}if(g===null)b===y||s&&e.data===y||(e.data=y);else{if(r=r&&$.call(e.childNodes),b=n.props||D,!s&&r!=null)for(b={},l=0;l<e.attributes.length;l++)b[(f=e.attributes[l]).name]=f.value;for(l in b)f=b[l],l=="children"||(l=="dangerouslySetInnerHTML"?i=f:l==="key"||l in y||M(e,l,null,f,_));for(l in y)f=y[l],l=="children"?h=f:l=="dangerouslySetInnerHTML"?p=f:l=="value"?m=f:l=="checked"?w=f:l==="key"||s&&typeof f!="function"||b[l]===f||M(e,l,f,b[l],_);if(p)s||i&&(p.__html===i.__html||p.__html===e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(i&&(e.innerHTML=""),ve(e,Q(h)?h:[h],t,n,o,_&&g!=="foreignObject",r,c,r?r[0]:n.__k&&L(n,0),s,u),r!=null)for(l=r.length;l--;)r[l]!=null&&de(r[l]);s||(l="value",m!==void 0&&(m!==e[l]||g==="progress"&&!m||g==="option"&&m!==b[l])&&M(e,l,m,b[l],!1),l="checked",w!==void 0&&w!==e[l]&&M(e,l,w,b[l],!1))}return e}function ee(e,t,n){try{typeof e=="function"?e(t):e.current=t}catch(o){d.__e(o,n)}}function te(e,t,n){var o,_;if(d.unmount&&d.unmount(e),(o=e.ref)&&(o.current&&o.current!==e.__e||ee(o,null,t)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(r){d.__e(r,t)}o.base=o.__P=null,e.__c=void 0}if(o=e.__k)for(_=0;_<o.length;_++)o[_]&&te(o[_],t,n||typeof e.type!="function");n||e.__e==null||de(e.__e),e.__=e.__e=e.__d=void 0}function Xe(e,t,n){return this.constructor(e,n)}function Ze(e,t,n){var o,_,r,c;d.__&&d.__(e,t),_=(o=typeof n=="function")?null:n&&n.__k||t.__k,r=[],c=[],Z(t,e=(!o&&n||t).__k=pe(V,null,[e]),_||D,D,t.ownerSVGElement!==void 0,!o&&n?[n]:_?null:t.firstChild?$.call(t.childNodes):null,r,!o&&n?n:_?_.__e:t.firstChild,o,c),we(r,e,c)}function ke(e,t){var n={__c:t="__cC"+ue++,__:e,Consumer:function(o,_){return o.children(_)},Provider:function(o){var _,r;return this.getChildContext||(_=[],(r={})[t]=this,this.getChildContext=function(){return r},this.shouldComponentUpdate=function(c){this.props.value!==c.value&&_.some(function(s){s.__e=!0,X(s)})},this.sub=function(c){_.push(c);var s=c.componentWillUnmount;c.componentWillUnmount=function(){_.splice(_.indexOf(c),1),s&&s.call(c)}}),o.children}};return n.Provider.__=n.Consumer.contextType=n}$=fe.slice,d={__e:function(e,t,n,o){for(var _,r,c;t=t.__;)if((_=t.__c)&&!_.__)try{if((r=_.constructor)&&r.getDerivedStateFromError!=null&&(_.setState(r.getDerivedStateFromError(e)),c=_.__d),_.componentDidCatch!=null&&(_.componentDidCatch(e,o||{}),c=_.__d),c)return _.__E=_}catch(s){e=s}throw e}},se=0,O.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=C({},this.state),typeof e=="function"&&(e=e(C({},n),this.props)),e&&C(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),X(this))},O.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),X(this))},O.prototype.render=V,P=[],ae=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,J=function(e,t){return e.__v.__b-t.__v.__b},W.__r=0,ue=0;var et=0;function a(e,t,n,o,_,r){var c,s,u={};for(s in t)s=="ref"?c=t[s]:u[s]=t[s];var l={type:e,props:u,key:n,ref:c,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--et,__i:-1,__u:0,__source:_,__self:r};if(typeof e=="function"&&(c=e.defaultProps))for(s in c)u[s]===void 0&&(u[s]=c[s]);return d.vnode&&d.vnode(l),l}const Lt="";function tt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ne={exports:{}};/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r="",c=0;c<arguments.length;c++){var s=arguments[c];s&&(r=_(r,o(s)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var c="";for(var s in r)t.call(r,s)&&r[s]&&(c=_(c,s));return c}function _(r,c){return c?r?r+" "+c:r+c:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Ne);var nt=Ne.exports;const x=tt(nt);var N=(e=>(e.Chapter="chapter",e.Section="section",e.Paragraph="paragraph",e.Text="text",e.Weblink="weblink",e.List="list",e.Table="table",e.InternalReference="internalReference",e))(N||{}),ne=(e=>(e.Bold="BOLD",e.Italic="ITALIC",e))(ne||{});let xe=Date.now();const $e=(e="id")=>(xe+=1,`${e}-${xe}`),Tt="";var T,v,oe,Ce,F=0,Se=[],B=[],Ee=d.__b,Pe=d.__r,He=d.diffed,Le=d.__c,Te=d.unmount;function q(e,t){d.__h&&d.__h(v,e,F||t),F=0;var n=v.__H||(v.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({__V:B}),n.__[e]}function I(e){return F=1,ot(Ue,e)}function ot(e,t,n){var o=q(T++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):Ue(void 0,t),function(s){var u=o.__N?o.__N[0]:o.__[0],l=o.t(u,s);u!==l&&(o.__N=[l,o.__[1]],o.__c.setState({}))}],o.__c=v,!v.u)){var _=function(s,u,l){if(!o.__c.__H)return!0;var p=o.__c.__H.__.filter(function(h){return h.__c});if(p.every(function(h){return!h.__N}))return!r||r.call(this,s,u,l);var i=!1;return p.forEach(function(h){if(h.__N){var f=h.__[0];h.__=h.__N,h.__N=void 0,f!==h.__[0]&&(i=!0)}}),!(!i&&o.__c.props===s)&&(!r||r.call(this,s,u,l))};v.u=!0;var r=v.shouldComponentUpdate,c=v.componentWillUpdate;v.componentWillUpdate=function(s,u,l){if(this.__e){var p=r;r=void 0,_(s,u,l),r=p}c&&c.call(this,s,u,l)},v.shouldComponentUpdate=_}return o.__N||o.__}function A(e,t){var n=q(T++,3);!d.__s&&Re(n.__H,t)&&(n.__=e,n.i=t,v.__H.__h.push(n))}function rt(e){return F=5,Ie(function(){return{current:e}},[])}function Ie(e,t){var n=q(T++,7);return Re(n.__H,t)?(n.__V=e(),n.i=t,n.__h=e,n.__V):n.__}function Ae(e){var t=v.context[e.__c],n=q(T++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(v)),t.props.value):e.__}function _t(){for(var e;e=Se.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(z),e.__H.__h.forEach(re),e.__H.__h=[]}catch(t){e.__H.__h=[],d.__e(t,e.__v)}}d.__b=function(e){v=null,Ee&&Ee(e)},d.__r=function(e){Pe&&Pe(e),T=0;var t=(v=e.__c).__H;t&&(oe===v?(t.__h=[],v.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=B,n.__N=n.i=void 0})):(t.__h.forEach(z),t.__h.forEach(re),t.__h=[],T=0)),oe=v},d.diffed=function(e){He&&He(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Se.push(t)!==1&&Ce===d.requestAnimationFrame||((Ce=d.requestAnimationFrame)||it)(_t)),t.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==B&&(n.__=n.__V),n.i=void 0,n.__V=B})),oe=v=null},d.__c=function(e,t){t.some(function(n){try{n.__h.forEach(z),n.__h=n.__h.filter(function(o){return!o.__||re(o)})}catch(o){t.some(function(_){_.__h&&(_.__h=[])}),t=[],d.__e(o,n.__v)}}),Le&&Le(e,t)},d.unmount=function(e){Te&&Te(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{z(o)}catch(_){t=_}}),n.__H=void 0,t&&d.__e(t,n.__v))};var De=typeof requestAnimationFrame=="function";function it(e){var t,n=function(){clearTimeout(o),De&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,100);De&&(t=requestAnimationFrame(n))}function z(e){var t=v,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),v=t}function re(e){var t=v;e.__c=e.__(),v=t}function Re(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function Ue(e,t){return typeof t=="function"?t(e):t}const Ve=ke(null);function ct({children:e,className:t,expand:n=!1,type:o,onExpandSection:_}){const[r,c]=I([]),s=x("adv-accordion",t,{"adv-accordion--container":o==="container"});return a(Ve.Provider,{value:{expand:n,items:r,setItems:c,onExpandSection:_},children:a("div",{className:s,children:e})})}const It="",Oe={1:"h1",2:"h2"};function _e({className:e,level:t,children:n}){const o=Oe[t]||Oe[1],_=x("adv-heading",`adv-heading--${t}`,e);return pe(o,{className:_},n)}function H({content:e,styles:t}){const n=x({"adv-u-font-weight-semi-bold":t==null?void 0:t.includes(ne.Bold),"adv-u-font-italic":t==null?void 0:t.includes(ne.Italic)});return a("span",{className:n,children:e})}function st({title:e,contentElements:t}){return a("section",{className:"adv-u-margin-bottom-48",children:[a(_e,{level:2,className:"adv-u-margin-top-24 adv-u-margin-bottom-16",children:a(H,{content:e.content,styles:e.styles})}),a(S,{contentElements:t,isTopLevel:!0})]})}const We=ke({references:{},addReference:()=>{}});function Me(){const e=Ae(We);if(e===void 0)throw new Error("useReferenceContext must be used within a ReferenceProvider");return e}const lt=e=>new Promise(t=>{setTimeout(t,e)}),j=e=>e?`adyen-document-viewer-${e.replace(/[^\w-]/g,"").slice(0,32)}`:void 0,Fe=e=>{if(!e)return null;const t=e instanceof HTMLElement,n=t&&window.getComputedStyle(e).overflowY;return t&&(n!=="visible"&&n!=="hidden")?e:Fe(e.parentNode)??document.body},At="",at=({onClick:e,label:t})=>a("button",{className:"adv-link",type:"button",onClick:e,title:t,children:t});function ut({referencedLabel:e,displayText:t}){const n=t?t.content:e,o=j(e)??"",{references:_}=Me();return a(at,{onClick:async()=>{_&&o&&_[o]&&(_[o].openSection(),await lt(150));const c=Fe(document.getElementById(o)),s=c==null?void 0:c.querySelector(`#${o}`);s==null||s.scrollIntoView({behavior:"smooth"})},label:n})}const Dt="";function ft({className:e,nested:t,ordered:n,noMarkers:o,children:_}){const r=x(["adv-list",t&&"adv-list--nested",n&&"adv-list--ordered",o&&"adv-list--no-markers",e]);return a("ul",{className:r,children:_})}function dt({className:e,children:t,noMarkers:n}){const o=x(["adv-list__item",n&&"adv-list__item--no-markers",e]);return a("li",{className:o,children:t})}function Be({items:e,style:t}){return a(ft,{ordered:t.ordered,children:e.map((n,o)=>a(dt,{children:[a(S,{contentElements:n.content}),n.subList&&a(Be,{style:n.subList.style,items:n.subList.items})]},o))})}const Rt="";function pt({isTopLevel:e,contentElements:t}){const n=x("adv-paragraph",{"adv-u-margin-bottom-16":e});return a("p",{className:n,children:a(S,{contentElements:t})})}const Ut="",Vt="",Ot="";function ht({children:e,collapsed:t=!1}){const n=rt(null),[o,_]=I(t?0:void 0);return A(()=>{var r;_(t?0:(r=n.current)==null?void 0:r.scrollHeight)},[t]),a("div",{className:"adv-collapsible-container","aria-hidden":t,ref:n,style:{height:o},children:e})}const Wt="",vt=({className:e="",name:t})=>{const n={"chevron-up":a("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 15 15",width:"15",height:"15",children:a("path",{fillRule:"evenodd",d:"M13 10a1 1 0 0 1-1.743.669L7.5 6.495 3.743 10.67a1 1 0 0 1-1.486-1.338l4.5-5a1 1 0 0 1 1.486 0l4.5 5a.998.998 0 0 1 .257.67z"})}),"chevron-down":a("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 15 15",width:"15",height:"15",children:a("path",{fillRule:"evenodd",d:"M2 5a1 1 0 0 1 1.743-.669L7.5 8.505l3.757-4.174a1 1 0 0 1 1.486 1.338l-4.5 5a1 1 0 0 1-1.486 0l-4.5-5A.998.998 0 0 1 2 4.999z"})})};return a("i",{className:x("adv-icon",e),role:"img","aria-hidden":!0,children:n[t]})};function mt(){return Ae(Ve)}function yt({children:e,open:t=!1,title:n="",onOpen:o=()=>{},onClose:_=()=>{}}){const{expand:r,items:c,setItems:s,onExpandSection:u}=mt(),[l,p]=I(t),[i]=I($e),h=()=>{const f=!l,m=[...c];r?(m.find(w=>w.id===i).isOpen=f,s(m)):s(m.map(w=>({...w,isOpen:w.id===i?f:!1})))};return A(()=>{s(f=>[...f,{id:i,isOpen:l}])},[]),A(()=>{p(t)},[t]),A(()=>{var f;p(((f=c.find(m=>m.id===i))==null?void 0:f.isOpen)??!1)},[c]),A(()=>{l?(u==null||u(n),o()):_()},[l]),a("div",{className:"adv-accordion__item",children:[a("div",{role:"button",className:"adv-accordion__header",tabIndex:0,onClick:h,children:[a(vt,{name:l?"chevron-up":"chevron-down",className:"adv-accordion__toggle"}),a("div",{className:"adv-accordion__title-wrapper",children:a("div",{className:"adv-accordion__title",children:n})})]}),a(ht,{collapsed:!l,children:a("div",{className:"adv-accordion__content",children:e})})]})}const qe=e=>{if(typeof e!="object"||e===null)return[];const t=[];"label"in e&&typeof e.label=="string"&&e.label!==""&&t.push(e.label);for(const n in e){const o=e[n];(Array.isArray(o)||typeof o=="object"&&o!==null)&&t.push(...qe(o))}return t};function bt({title:e,label:t,isTopLevel:n,contentElements:o}){const[_,r]=I(!1),{addReference:c}=Me(),s=j(t);return A(()=>{if(n){const u=qe(o).map(j);s&&u.push(s),u.length&&u.forEach(l=>{c({[l]:{openSection:()=>r(!0)}})})}},[]),n?a(yt,{title:e.content,open:_,onOpen:()=>{r(!0)},onClose:()=>{r(!1)},children:a("section",{className:"adv-section-box",id:s,children:a(S,{contentElements:o})})}):a("section",{id:s,children:[a(_e,{level:2,className:"adv-u-margin-top-24 adv-u-margin-bottom-16",children:a(H,{content:e.content,styles:e.styles})}),a(S,{contentElements:o})]})}const Mt="";function gt({rows:e,label:t,captions:n,titlePrefix:o,title:_}){const r=j(t);return a("div",{id:r,children:[a("div",{className:"adv-u-margin-y-8 adv-u-text-align-center",children:[o&&a(H,{...o}),o&&_&&" ",_&&a(H,{..._})]}),a("table",{className:"adv-table adv-table--condensed",children:[n&&a("caption",{children:a(S,{contentElements:n})}),a("tbody",{className:"adv-table__body",children:e.map((c,s)=>a("tr",{className:"adv-table__row",children:c.map((u,l)=>a("td",{className:"adv-table__cell",children:a(S,{contentElements:u.elements})},l))},s))})]})]})}const wt=({className:e,children:t,href:n,underline:o,inheritStyles:_,onClick:r})=>{const c=x("adv-link",e,{"adv-link--underline":o,"adv-link--inherit":_});return a("a",{href:n,className:c,target:"_blank",rel:"noopener noreferrer",onClick:r,children:a("span",{className:"adv-link__text",children:t})})},kt={chapter:st,section:bt,paragraph:pt,text:H,weblink:({url:e,displayText:t})=>a(wt,{href:e,children:t?a(H,{...t}):e}),list:Be,table:gt,internalReference:ut,breakline:"br"},Nt=e=>`key-${e}-${$e()}`,xt=(e,t)=>{if(!("type"in e))return null;switch(e.type){case N.Chapter:return{title:e.title,contentElements:e.contentElements};case N.Section:return{isTopLevel:t,title:e.title,label:e.label,contentElements:e.contentElements};case N.Paragraph:return{isTopLevel:t,contentElements:e.contentElements};case N.Text:return{content:e.content,styles:e.styles};case N.Weblink:return{url:e.url,displayText:e.displayText};case N.List:return{items:e.items,style:e.style};case N.Table:return{rows:e.rows,label:e.label,captions:e.captions,titlePrefix:e.titlePrefix,title:e.title};case N.InternalReference:return{referencedLabel:e.referencedLabel,displayText:e.displayText};default:return null}};function S({contentElements:e,isTopLevel:t=!1,onExpandSection:n,multiple:o}){const _=e.map(r=>{if(!("type"in r))return null;const c=kt[r.type];return a(c,{...xt(r,t)},Nt(r.type))});return t?a(ct,{onExpandSection:n,expand:o,children:_}):a("span",{children:_})}function $t({children:e}){const[t,n]=I({}),o=Ie(()=>({addReference:_=>{n(r=>({...r,..._}))},references:t}),[t,n]);return a(We.Provider,{value:o,children:e})}function Ct({document:e,className:t,onExpandSection:n,multiple:o}){const _=x("adyen-document-viewer",t);return a($t,{children:a("div",{className:_,children:[a(_e,{level:1,className:"adv-u-margin-top-24 adv-u-margin-bottom-16",children:a(H,{content:e.title.content,styles:e.title.styles})}),a(S,{contentElements:e.contentElements,onExpandSection:n,multiple:o,isTopLevel:!0})]})})}function ze(e){return"type"in e&&e.type===N.Section}function je(e){return"contentElements"in e&&Array.isArray(e.contentElements)}function St(e){return e.isTopLevel?`${e.counter}`:`${e.prefix}${e.counter}`}function Et(e,t){return`${e} ${t}`}function ie(e,t){if(ze(e)){const n=St(t),o={...e,title:{...e.title,content:Et(n,e.title.content)}};if(t.counter+=1,je(e)){let _=1;o.contentElements=e.contentElements.map(r=>{if(ze(r)){const c={prefix:`${n}.`,counter:_,isTopLevel:!1};return _+=1,ie(r,c)}return r})}return o}return je(e)?{...e,contentElements:e.contentElements.map(n=>ie(n,t))}:e}function Pt(e){const t={prefix:"",counter:1,isTopLevel:!0};return{...e,contentElements:e.contentElements.map(n=>ie(n,t))}}class Ht{constructor(t,n={}){if(typeof t=="object"&&"nodeType"in t)this.target=t;else{const o=window.document.querySelector(t);if(o instanceof HTMLElement)this.target=o;else throw new Error("Target element was not found")}this.options={onExpandSection:n.onExpandSection??void 0,multiple:n.multiple??!1,showSectionNumbering:n.showSectionNumbering??!1}}render(t){const n=this.options.showSectionNumbering?Pt(t):t;Ze(a(Ct,{document:n,onExpandSection:this.options.onExpandSection,multiple:this.options.multiple}),this.target)}}return Ht});