@returningai/widget-sdk 1.7.0 → 1.7.2

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/CHANGELOG.md CHANGED
@@ -9,8 +9,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ---
13
+
14
+ ## [1.7.2] — 2026-07-20
15
+
16
+ ### Fixed
17
+
18
+ - MFE-served custom widgets in iframe mode now wait for the SDK's authenticated
19
+ `postMessage` token instead of initializing with an SSR guest token.
20
+ - Custom widgets now use their configured theme when the embed omits
21
+ `theme` / `data-theme`; an explicitly supplied light or dark theme still
22
+ overrides the widget configuration in both iframe and bundle modes.
23
+ - Concurrent custom widgets in bundle mode no longer overwrite or prematurely
24
+ restore the host page's automatic-theme setting during mount and teardown.
25
+ - Widget-mounted banners now resolve CSS color tokens from the owning widget
26
+ before the document or sibling widgets, preventing cross-widget theme colors.
27
+
28
+ ---
29
+
30
+ ## [1.7.1] — 2026-07-14
31
+
12
32
  ### Fixed
13
33
 
34
+ - Bundle mode now caches a snapshot of each widget runtime's `mount` callable
35
+ by its global name and normalized `bundle-url`. Pages can move between split
36
+ custom-widget bundles without a later loader overwriting an earlier cached
37
+ `window.RaiCustomWidget.mount` callable.
38
+ - Repeated and simultaneous requests reuse the correct captured runtime, while
39
+ failed bundle loads are evicted so a later mount can retry.
14
40
  - Bundle-mode loaders can now remain visible until a compatible widget bundle
15
41
  reports that its deepest micro-frontend is ready. Existing bundles without a
16
42
  deep-ready handle keep the previous first-paint fallback.
package/README.md CHANGED
@@ -374,7 +374,7 @@ All attributes can be provided with or without the `data-` prefix — both work.
374
374
  | `api-url` | No | ReturningAI widget auth server | Optional widget auth server override |
375
375
  | `widget-url` | **Yes**\* | — | Widget URL (from dashboard). \*Not required when using `data-bundle-url` |
376
376
  | `data-bundle-url` | No | — | URL to the widget bundle loader (`widget.js`) — triggers [bundle mode](#bundle-mode) (non-iframe) |
377
- | `data-theme` | No | `light` | `light` or `dark` |
377
+ | `data-theme` | No | See note below | `light` or `dark`; explicit values override custom widget settings |
378
378
  | `data-email` | Public Embed only | — | User's email for identification. **Access Key Embed:** omit — identity is signed into `data-embed-token` |
379
379
  | `data-embed-token` | Access Key Embed only | — | Short-lived JWT from your server. Carries signed user identifiers — no `data-*` identifier attributes needed |
380
380
  | `data-locale` | No | — | BCP 47 locale tag (e.g. `fr-FR`) |
@@ -394,7 +394,7 @@ All attributes can be provided with or without the `data-` prefix — both work.
394
394
  | `api-url` | No | ReturningAI widget auth server | Optional widget auth server override |
395
395
  | `widget-url` | **Yes**\* | — | Widget URL (from dashboard). \*Not required when using `bundle-url` |
396
396
  | `bundle-url` | No | — | URL to the widget bundle loader (`widget.js`) — triggers [bundle mode](#bundle-mode) (non-iframe) |
397
- | `theme` | No | `light` | `light` or `dark` |
397
+ | `theme` | No | See note below | `light` or `dark`; explicit values override custom widget settings |
398
398
  | `data-email` | Public Embed only | — | User's email for identification. **Access Key Embed:** omit — identity is signed into `embed-token` |
399
399
  | `embed-token` | Access Key Embed only | — | Short-lived JWT from your server. Carries signed user identifiers — no `data-*` identifier attributes needed |
400
400
  | `width` | No | `100%` | CSS width |
@@ -409,6 +409,10 @@ All attributes can be provided with or without the `data-` prefix — both work.
409
409
 
410
410
  > **`widget-id` vs `community-id`:** The script-tag method uses `data-widget-id` which is a pre-encoded identifier (base64). The custom element method uses raw ObjectIds — `community-id` for most widget types, plus `channel-id` for channel widgets. The SDK handles the encoding internally.
411
411
 
412
+ > **Custom widget themes:** Omit `theme` / `data-theme` to use the custom
413
+ > widget's configured default theme in iframe and bundle modes. Set it
414
+ > explicitly when the host page needs to force light or dark mode.
415
+
412
416
  ### Container `<div>` (script-tag method only)
413
417
 
414
418
  The SDK looks for a `<div>` with `id="returning-ai-widget-{YOUR_WIDGET_ID}"`. Size the div to control the widget dimensions:
@@ -1,3 +1,3 @@
1
1
  var RaiBanner=function(e){"use strict";var t=Object.defineProperty,n=(e,n,o)=>((e,n,o)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o)(e,"symbol"!=typeof n?n+"":n,o);
2
2
  /*! @license DOMPurify 3.4.9 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.9/LICENSE */
3
- function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,r,i,a,l=[],s=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(s=(o=i.call(n)).done)&&(l.push(o.value),l.length!==t);s=!0);}catch(u){c=!0,r=u}finally{try{if(!s&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const i=Object.entries,a=Object.setPrototypeOf,l=Object.isFrozen,s=Object.getPrototypeOf,c=Object.getOwnPropertyDescriptor;let u=Object.freeze,d=Object.seal,p=Object.create,f="undefined"!=typeof Reflect&&Reflect,m=f.apply,h=f.construct;u||(u=function(e){return e}),d||(d=function(e){return e}),m||(m=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];return e.apply(t,o)}),h||(h=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return new e(...n)});const g=U(Array.prototype.forEach),y=U(Array.prototype.lastIndexOf),b=U(Array.prototype.pop),A=U(Array.prototype.push),T=U(Array.prototype.splice),S=Array.isArray,x=U(String.prototype.toLowerCase),v=U(String.prototype.toString),w=U(String.prototype.match),E=U(String.prototype.replace),_=U(String.prototype.indexOf),N=U(String.prototype.trim),C=U(Number.prototype.toString),O=U(Boolean.prototype.toString),k="undefined"==typeof BigInt?null:U(BigInt.prototype.toString),D="undefined"==typeof Symbol?null:U(Symbol.prototype.toString),R=U(Object.prototype.hasOwnProperty),I=U(Object.prototype.toString),L=U(RegExp.prototype.test),M=(z=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return h(z,t)});var z;function U(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return m(e,t,o)}}function P(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:x;if(a&&a(e,null),!S(t))return e;let o=t.length;for(;o--;){let r=t[o];if("string"==typeof r){const e=n(r);e!==r&&(l(t)||(t[o]=e),r=e)}e[r]=!0}return e}function F(e){for(let t=0;t<e.length;t++){R(e,t)||(e[t]=null)}return e}function H(e){const t=p(null);for(const o of i(e)){var n=r(o,2);const i=n[0],a=n[1];R(e,i)&&(S(a)?t[i]=F(a):a&&"object"==typeof a&&a.constructor===Object?t[i]=H(a):t[i]=a)}return t}function j(e,t){for(;null!==e;){const n=c(e,t);if(n){if(n.get)return U(n.get);if("function"==typeof n.value)return U(n.value)}e=s(e)}return function(){return null}}const W=u(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),B=u(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),G=u(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Y=u(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),q=u(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),$=u(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),X=u(["#text"]),V=u(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),K=u(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Z=u(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),J=u(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Q=d(/{{[\w\W]*|^[\w\W]*}}/g),ee=d(/<%[\w\W]*|^[\w\W]*%>/g),te=d(/\${[\w\W]*/g),ne=d(/^data-[\-\w.\u00B7-\uFFFF]+$/),oe=d(/^aria-[\-\w]+$/),re=d(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ie=d(/^(?:\w+script|data):/i),ae=d(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),le=d(/^html$/i),se=d(/^[a-z][.\w]*(-[.\w]+)+$/i),ce=1,ue=3,de=7,pe=8,fe=9,me=11;var he=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window;const n=t=>e(t);if(n.version="3.4.9",n.removed=[],!t||!t.document||t.document.nodeType!==fe||!t.Element)return n.isSupported=!1,n;let o=t.document;const r=o,a=r.currentScript;t.DocumentFragment;const l=t.HTMLTemplateElement,s=t.Node,c=t.Element,d=t.NodeFilter,f=t.NamedNodeMap;void 0===f&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const m=t.DOMParser,h=t.trustedTypes,z=c.prototype,U=j(z,"cloneNode"),F=j(z,"remove"),he=j(z,"nextSibling"),ge=j(z,"childNodes"),ye=j(z,"parentNode"),be=j(z,"shadowRoot"),Ae=j(z,"attributes"),Te=s&&s.prototype?j(s.prototype,"nodeType"):null,Se=s&&s.prototype?j(s.prototype,"nodeName"):null;if("function"==typeof l){const e=o.createElement("template");e.content&&e.content.ownerDocument&&(o=e.content.ownerDocument)}let xe,ve,we="",Ee=!1,_e=0;const Ne=function(){if(_e>0)throw M('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Ce=function(e){Ne(),_e++;try{return xe.createHTML(e)}finally{_e--}},Oe=function(e){Ne(),_e++;try{return xe.createScriptURL(e)}finally{_e--}},ke=function(){return Ee||(ve=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(i){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(h,a),Ee=!0),ve},De=o,Re=De.implementation,Ie=De.createNodeIterator,Le=De.createDocumentFragment,Me=De.getElementsByTagName,ze=r.importNode;let Ue={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof i&&"function"==typeof ye&&Re&&void 0!==Re.createHTMLDocument;const Pe=Q,Fe=ee,He=te,je=ne,We=oe,Be=ie,Ge=ae,Ye=se;let qe=re,$e=null;const Xe=P({},[...W,...B,...G,...q,...X]);let Ve=null;const Ke=P({},[...V,...K,...Z,...J]);let Ze=Object.seal(p(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Je=null,Qe=null;const et=Object.seal(p(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let tt=!0,nt=!0,ot=!1,rt=!0,it=!1,at=!0,lt=!1,st=!1,ct=!1,ut=!1,dt=!1,pt=!1,ft=!0,mt=!1;const ht="user-content-";let gt=!0,yt=!1,bt={},At=null;const Tt=P({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let St=null;const xt=P({},["audio","video","img","source","image","track"]);let vt=null;const wt=P({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Et="http://www.w3.org/1998/Math/MathML",_t="http://www.w3.org/2000/svg",Nt="http://www.w3.org/1999/xhtml";let Ct=Nt,Ot=!1,kt=null;const Dt=P({},[Et,_t,Nt],v);let Rt=P({},["mi","mo","mn","ms","mtext"]),It=P({},["annotation-xml"]);const Lt=P({},["title","style","font","a","script"]);let Mt=null;const zt=["application/xhtml+xml","text/html"];let Ut=null,Pt=null;const Ft=o.createElement("form"),Ht=function(e){return e instanceof RegExp||e instanceof Function},jt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Pt&&Pt===e)return;e&&"object"==typeof e||(e={}),e=H(e),Mt=-1===zt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Ut="application/xhtml+xml"===Mt?v:x,$e=R(e,"ALLOWED_TAGS")&&S(e.ALLOWED_TAGS)?P({},e.ALLOWED_TAGS,Ut):Xe,Ve=R(e,"ALLOWED_ATTR")&&S(e.ALLOWED_ATTR)?P({},e.ALLOWED_ATTR,Ut):Ke,kt=R(e,"ALLOWED_NAMESPACES")&&S(e.ALLOWED_NAMESPACES)?P({},e.ALLOWED_NAMESPACES,v):Dt,vt=R(e,"ADD_URI_SAFE_ATTR")&&S(e.ADD_URI_SAFE_ATTR)?P(H(wt),e.ADD_URI_SAFE_ATTR,Ut):wt,St=R(e,"ADD_DATA_URI_TAGS")&&S(e.ADD_DATA_URI_TAGS)?P(H(xt),e.ADD_DATA_URI_TAGS,Ut):xt,At=R(e,"FORBID_CONTENTS")&&S(e.FORBID_CONTENTS)?P({},e.FORBID_CONTENTS,Ut):Tt,Je=R(e,"FORBID_TAGS")&&S(e.FORBID_TAGS)?P({},e.FORBID_TAGS,Ut):H({}),Qe=R(e,"FORBID_ATTR")&&S(e.FORBID_ATTR)?P({},e.FORBID_ATTR,Ut):H({}),bt=!!R(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?H(e.USE_PROFILES):e.USE_PROFILES),tt=!1!==e.ALLOW_ARIA_ATTR,nt=!1!==e.ALLOW_DATA_ATTR,ot=e.ALLOW_UNKNOWN_PROTOCOLS||!1,rt=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,it=e.SAFE_FOR_TEMPLATES||!1,at=!1!==e.SAFE_FOR_XML,lt=e.WHOLE_DOCUMENT||!1,ut=e.RETURN_DOM||!1,dt=e.RETURN_DOM_FRAGMENT||!1,pt=e.RETURN_TRUSTED_TYPE||!1,ct=e.FORCE_BODY||!1,ft=!1!==e.SANITIZE_DOM,mt=e.SANITIZE_NAMED_PROPS||!1,gt=!1!==e.KEEP_CONTENT,yt=e.IN_PLACE||!1,qe=function(e){try{return L(e,""),!0}catch(t){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:re,Ct="string"==typeof e.NAMESPACE?e.NAMESPACE:Nt,Rt=R(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?H(e.MATHML_TEXT_INTEGRATION_POINTS):P({},["mi","mo","mn","ms","mtext"]),It=R(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?H(e.HTML_INTEGRATION_POINTS):P({},["annotation-xml"]);const t=R(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?H(e.CUSTOM_ELEMENT_HANDLING):p(null);if(Ze=p(null),R(t,"tagNameCheck")&&Ht(t.tagNameCheck)&&(Ze.tagNameCheck=t.tagNameCheck),R(t,"attributeNameCheck")&&Ht(t.attributeNameCheck)&&(Ze.attributeNameCheck=t.attributeNameCheck),R(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(Ze.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),it&&(nt=!1),dt&&(ut=!0),bt&&($e=P({},X),Ve=p(null),!0===bt.html&&(P($e,W),P(Ve,V)),!0===bt.svg&&(P($e,B),P(Ve,K),P(Ve,J)),!0===bt.svgFilters&&(P($e,G),P(Ve,K),P(Ve,J)),!0===bt.mathMl&&(P($e,q),P(Ve,Z),P(Ve,J))),et.tagCheck=null,et.attributeCheck=null,R(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?et.tagCheck=e.ADD_TAGS:S(e.ADD_TAGS)&&($e===Xe&&($e=H($e)),P($e,e.ADD_TAGS,Ut))),R(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?et.attributeCheck=e.ADD_ATTR:S(e.ADD_ATTR)&&(Ve===Ke&&(Ve=H(Ve)),P(Ve,e.ADD_ATTR,Ut))),R(e,"ADD_URI_SAFE_ATTR")&&S(e.ADD_URI_SAFE_ATTR)&&P(vt,e.ADD_URI_SAFE_ATTR,Ut),R(e,"FORBID_CONTENTS")&&S(e.FORBID_CONTENTS)&&(At===Tt&&(At=H(At)),P(At,e.FORBID_CONTENTS,Ut)),R(e,"ADD_FORBID_CONTENTS")&&S(e.ADD_FORBID_CONTENTS)&&(At===Tt&&(At=H(At)),P(At,e.ADD_FORBID_CONTENTS,Ut)),gt&&($e["#text"]=!0),lt&&P($e,["html","head","body"]),$e.table&&(P($e,["tbody"]),delete Je.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw M('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw M('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=xe;xe=e.TRUSTED_TYPES_POLICY;try{we=Ce("")}catch(n){throw xe=t,n}}else null===e.TRUSTED_TYPES_POLICY?(xe=void 0,we=""):(void 0===xe&&(xe=ke()),xe&&"string"==typeof we&&(we=Ce("")));(Ue.uponSanitizeElement.length>0||Ue.uponSanitizeAttribute.length>0)&&$e===Xe&&($e=H($e)),Ue.uponSanitizeAttribute.length>0&&Ve===Ke&&(Ve=H(Ve)),u&&u(e),Pt=e},Wt=P({},[...B,...G,...Y]),Bt=P({},[...q,...$]),Gt=function(e){A(n.removed,{element:e});try{ye(e).removeChild(e)}catch(t){if(F(e),!ye(e))throw M("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Yt=function(e){const t=ge?ge(e):e.childNodes;if(t){const e=[];g(t,t=>{A(e,t)}),g(e,e=>{try{F(e)}catch(t){}})}const n=Ae?Ae(e):null;if(n)for(let r=n.length-1;r>=0;--r){const t=n[r],i=t&&t.name;if("string"==typeof i)try{e.removeAttribute(i)}catch(o){}}},qt=function(e,t){try{A(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(o){A(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ut||dt)try{Gt(t)}catch(o){}else try{t.setAttribute(e,"")}catch(o){}},$t=function(e){const t=Ae?Ae(e):e.attributes;if(t)for(let o=t.length-1;o>=0;--o){const r=t[o],i=r&&r.name;if("string"==typeof i&&!Ve[Ut(i)])try{e.removeAttribute(i)}catch(n){}}},Xt=function(e){let t=null,n=null;if(ct)e="<remove></remove>"+e;else{const t=w(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Mt&&Ct===Nt&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const r=xe?Ce(e):e;if(Ct===Nt)try{t=(new m).parseFromString(r,Mt)}catch(a){}if(!t||!t.documentElement){t=Re.createDocument(Ct,"template",null);try{t.documentElement.innerHTML=Ot?we:r}catch(a){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(o.createTextNode(n),i.childNodes[0]||null),Ct===Nt?Me.call(t,lt?"html":"body")[0]:lt?t.documentElement:i},Vt=function(e){return Ie.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Kt=function(e){var t,n;e.normalize();const o=Ie.call(e.ownerDocument||e,e,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null);let r=o.nextNode();for(;r;){let e=r.data;g([Pe,Fe,He],t=>{e=E(e,t," ")}),r.data=e,r=o.nextNode()}const i=null!==(t=null===(n=e.querySelectorAll)||void 0===n?void 0:n.call(e,"template"))&&void 0!==t?t:[];g(Array.from(i),e=>{Jt(e.content)&&Kt(e.content)})},Zt=function(e){const t=Se?Se(e):null;return"string"==typeof t&&("form"===Ut(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==Ae(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==Te(e)||e.childNodes!==ge(e)))},Jt=function(e){if(!Te||"object"!=typeof e||null===e)return!1;try{return Te(e)===me}catch(t){return!1}},Qt=function(e){if(!Te||"object"!=typeof e||null===e)return!1;try{return"number"==typeof Te(e)}catch(t){return!1}};function en(e,t,o){g(e,e=>{e.call(n,t,o,Pt)})}const tn=function(e){let t=null;if(en(Ue.beforeSanitizeElements,e,null),Zt(e))return Gt(e),!0;const o=Ut(Se?Se(e):e.nodeName);if(en(Ue.uponSanitizeElement,e,{tagName:o,allowedTags:$e}),at&&e.hasChildNodes()&&!Qt(e.firstElementChild)&&L(/<[/\w!]/g,e.innerHTML)&&L(/<[/\w!]/g,e.textContent))return Gt(e),!0;if(at&&e.namespaceURI===Nt&&"style"===o&&Qt(e.firstElementChild))return Gt(e),!0;if(e.nodeType===de)return Gt(e),!0;if(at&&e.nodeType===pe&&L(/<[/\w]/g,e.data))return Gt(e),!0;if(Je[o]||!(et.tagCheck instanceof Function&&et.tagCheck(o))&&!$e[o]){if(!Je[o]&&rn(o)){if(Ze.tagNameCheck instanceof RegExp&&L(Ze.tagNameCheck,o))return!1;if(Ze.tagNameCheck instanceof Function&&Ze.tagNameCheck(o))return!1}if(gt&&!At[o]){const t=ye(e),n=ge(e);if(n&&t){for(let o=n.length-1;o>=0;--o){const r=yt?n[o]:U(n[o],!0);t.insertBefore(r,he(e))}}}return Gt(e),!0}return((Te?Te(e):e.nodeType)!==ce||function(e){let t=ye(e);t&&t.tagName||(t={namespaceURI:Ct,tagName:"template"});const n=x(e.tagName),o=x(t.tagName);return!!kt[e.namespaceURI]&&(e.namespaceURI===_t?t.namespaceURI===Nt?"svg"===n:t.namespaceURI===Et?"svg"===n&&("annotation-xml"===o||Rt[o]):Boolean(Wt[n]):e.namespaceURI===Et?t.namespaceURI===Nt?"math"===n:t.namespaceURI===_t?"math"===n&&It[o]:Boolean(Bt[n]):e.namespaceURI===Nt?!(t.namespaceURI===_t&&!It[o])&&!(t.namespaceURI===Et&&!Rt[o])&&!Bt[n]&&(Lt[n]||!Wt[n]):!("application/xhtml+xml"!==Mt||!kt[e.namespaceURI]))}(e))&&("noscript"!==o&&"noembed"!==o&&"noframes"!==o||!L(/<\/no(script|embed|frames)/i,e.innerHTML))?(it&&e.nodeType===ue&&(t=e.textContent,g([Pe,Fe,He],e=>{t=E(t,e," ")}),e.textContent!==t&&(A(n.removed,{element:e.cloneNode()}),e.textContent=t)),en(Ue.afterSanitizeElements,e,null),!1):(Gt(e),!0)},nn=function(e,t,n){if(Qe[t])return!1;if(ft&&("id"===t||"name"===t)&&(n in o||n in Ft))return!1;const r=Ve[t]||et.attributeCheck instanceof Function&&et.attributeCheck(t,e);if(nt&&!Qe[t]&&L(je,t));else if(tt&&L(We,t));else if(!r||Qe[t]){if(!(rn(e)&&(Ze.tagNameCheck instanceof RegExp&&L(Ze.tagNameCheck,e)||Ze.tagNameCheck instanceof Function&&Ze.tagNameCheck(e))&&(Ze.attributeNameCheck instanceof RegExp&&L(Ze.attributeNameCheck,t)||Ze.attributeNameCheck instanceof Function&&Ze.attributeNameCheck(t,e))||"is"===t&&Ze.allowCustomizedBuiltInElements&&(Ze.tagNameCheck instanceof RegExp&&L(Ze.tagNameCheck,n)||Ze.tagNameCheck instanceof Function&&Ze.tagNameCheck(n))))return!1}else if(vt[t]);else if(L(qe,E(n,Ge,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==_(n,"data:")||!St[e]){if(ot&&!L(Be,E(n,Ge,"")));else if(n)return!1}else;return!0},on=P({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),rn=function(e){return!on[x(e)]&&L(Ye,e)},an=function(e){en(Ue.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||Zt(e))return;const o={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ve,forceKeepAttr:void 0};let r=t.length;for(;r--;){const a=t[r],l=a.name,s=a.namespaceURI,c=a.value,u=Ut(l),d=c;let p="value"===l?d:N(d);if(o.attrName=u,o.attrValue=p,o.keepAttr=!0,o.forceKeepAttr=void 0,en(Ue.uponSanitizeAttribute,e,o),p=o.attrValue,!mt||"id"!==u&&"name"!==u||0===_(p,ht)||(qt(l,e),p=ht+p),at&&L(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,p)){qt(l,e);continue}if("attributename"===u&&w(p,"href")){qt(l,e);continue}if(o.forceKeepAttr)continue;if(!o.keepAttr){qt(l,e);continue}if(!rt&&L(/\/>/i,p)){qt(l,e);continue}it&&g([Pe,Fe,He],e=>{p=E(p,e," ")});const f=Ut(e.nodeName);if(nn(f,u,p)){if(xe&&"object"==typeof h&&"function"==typeof h.getAttributeType)if(s);else switch(h.getAttributeType(f,u)){case"TrustedHTML":p=Ce(p);break;case"TrustedScriptURL":p=Oe(p)}if(p!==d)try{s?e.setAttributeNS(s,l,p):e.setAttribute(l,p),Zt(e)?Gt(e):b(n.removed)}catch(i){qt(l,e)}}else qt(l,e)}en(Ue.afterSanitizeAttributes,e,null)},ln=function(e){let t=null;const n=Vt(e);for(en(Ue.beforeSanitizeShadowDOM,e,null);t=n.nextNode();){en(Ue.uponSanitizeShadowNode,t,null),tn(t),an(t),Jt(t.content)&&ln(t.content);if((Te?Te(t):t.nodeType)===ce){const e=be?be(t):t.shadowRoot;Jt(e)&&(sn(e),ln(e))}}en(Ue.afterSanitizeShadowDOM,e,null)},sn=function(e){const t=[{node:e,shadow:null}];for(;t.length>0;){const e=t.pop();if(e.shadow){ln(e.shadow);continue}const n=e.node,o=(Te?Te(n):n.nodeType)===ce,r=ge?ge(n):n.childNodes;if(r)for(let i=r.length-1;i>=0;--i)t.push({node:r[i],shadow:null});if(o){const e=Se?Se(n):null;if("string"==typeof e&&"template"===Ut(e)){const e=n.content;Jt(e)&&t.push({node:e,shadow:null})}}if(o){const e=be?be(n):n.shadowRoot;Jt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=null,i=null,a=null,l=null;if(Ot=!e,Ot&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Qt(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return C(e);case"boolean":return O(e);case"bigint":return k?k(e):"0";case"symbol":return D?D(e):"Symbol()";case"undefined":default:return I(e);case"function":case"object":{if(null===e)return I(e);const t=e,n=j(t,"toString");if("function"==typeof n){const e=n(t);return"string"==typeof e?e:I(e)}return I(e)}}}(e)))throw M("dirty is not a string, aborting");if(!n.isSupported)return e;st||jt(t),n.removed=[];const s=yt&&"string"!=typeof e&&Qt(e);if(s){const t=Se?Se(e):e.nodeName;if("string"==typeof t){const e=Ut(t);if(!$e[e]||Je[e])throw M("root node is forbidden and cannot be sanitized in-place")}if(Zt(e))throw M("root node is clobbered and cannot be sanitized in-place");try{sn(e)}catch(d){throw Yt(e),d}}else if(Qt(e))o=Xt("\x3c!----\x3e"),i=o.ownerDocument.importNode(e,!0),i.nodeType===ce&&"BODY"===i.nodeName||"HTML"===i.nodeName?o=i:o.appendChild(i),sn(i);else{if(!ut&&!it&&!lt&&-1===e.indexOf("<"))return xe&&pt?Ce(e):e;if(o=Xt(e),!o)return ut?null:pt?we:""}o&&ct&&Gt(o.firstChild);const c=Vt(s?e:o);try{for(;a=c.nextNode();)tn(a),an(a),Jt(a.content)&&ln(a.content)}catch(d){throw s&&Yt(e),d}if(s)return g(n.removed,e=>{e.element&&function(e){const t=[e];for(;t.length>0;){const e=t.pop();(Te?Te(e):e.nodeType)===ce&&$t(e);const n=ge?ge(e):e.childNodes;if(n)for(let o=n.length-1;o>=0;--o)t.push(n[o])}}(e.element)}),it&&Kt(e),e;if(ut){if(it&&Kt(o),dt)for(l=Le.call(o.ownerDocument);o.firstChild;)l.appendChild(o.firstChild);else l=o;return(Ve.shadowroot||Ve.shadowrootmode)&&(l=ze.call(r,l,!0)),l}let u=lt?o.outerHTML:o.innerHTML;return lt&&$e["!doctype"]&&o.ownerDocument&&o.ownerDocument.doctype&&o.ownerDocument.doctype.name&&L(le,o.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+o.ownerDocument.doctype.name+">\n"+u),it&&g([Pe,Fe,He],e=>{u=E(u,e," ")}),xe&&pt?Ce(u):u},n.setConfig=function(){jt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),st=!0},n.clearConfig=function(){Pt=null,st=!1,xe=ve,we=""},n.isValidAttribute=function(e,t,n){Pt||jt({});const o=Ut(e),r=Ut(t);return nn(o,r,n)},n.addHook=function(e,t){"function"==typeof t&&A(Ue[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=y(Ue[e],t);return-1===n?void 0:T(Ue[e],n,1)[0]}return b(Ue[e])},n.removeHooks=function(e){Ue[e]=[]},n.removeAllHooks=function(){Ue={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();function ge(e){const t=e.startsWith("--")?e:`--${e}`,n=[document.documentElement,document.body,...Array.from(document.querySelectorAll(["rai-widget","rai-custom-widget","rai-channel-widget","rai-store-widget","rai-milestone-widget","rai-social-widget","rai-currency-widget","rai-referral-widget",".rai-widget-root",'[data-rai-widget-root="true"]'].join(",")))].filter(Boolean);for(const o of n){const e=getComputedStyle(o).getPropertyValue(t).trim();if(e)return e}for(const o of Array.from(document.querySelectorAll("*"))){const e=getComputedStyle(o).getPropertyValue(t).trim();if(e)return e}}he.addHook("afterSanitizeAttributes",e=>{"A"===e.tagName&&"_blank"===e.getAttribute("target")&&e.setAttribute("rel","noopener noreferrer")});const ye=e=>{if(!e)return;const t=e.trim();if(/^(#|rgb|hsl)/i.test(t))return t;if(/^(--)?[a-z0-9-]+$/i.test(t)){return ge(t)}const n=t.match(/^var\((--[a-z0-9-]+)\)$/i);if(n){return ge(n[1])}};function be(e,t,n){const o=document.createElement(e);if(Object.assign(o.style,t),n)for(const r of Object.keys(n))o.setAttribute(r,n[r]);return o}function Ae(e){return"left"===e||"top"===e?"flex-start":"right"===e||"bottom"===e?"flex-end":"center"}function Te(e,t){var n;const o=[null==(n=e.cta)?void 0:n.style,e.cta,e.ctaStyle];for(const r of o)for(const e of t){const t=null==r?void 0:r[e];if(t)return t}}function Se(e,t){var n,o,r,i,a,l,s,c,u,d,p,f,m,h;const g=e.placement||{},y=g.mode||"overlay",b=g.position||"top",A=String(g.zIndex||2147483e3),T=function(e){var t,n;return"image"===e.type&&Boolean((null==(t=e.image)?void 0:t.desktopUrl)||(null==(n=e.image)?void 0:n.mobileUrl))}(e),S=T?"transparent":ye(null==(n=e.style)?void 0:n.backgroundColor)||"#1f2024",x=ye(null==(o=e.style)?void 0:o.color)||"#ffffff",v="overlay"===y||"popup"===y,w=Te(e,["position"])||"center",E=Ae(null==(r=e.image)?void 0:r.horizontalAlignment),_=Ae(null==(i=e.image)?void 0:i.verticalAlignment),N=(null==(a=e.image)?void 0:a.horizontalAlignment)||"center",C=(null==(l=e.image)?void 0:l.verticalAlignment)||"center",O=T?"#ffffff":x,k=be("div",{boxSizing:"border-box",fontFamily:"Roboto, sans-serif",fontSize:"14px",lineHeight:"1.35",background:S,color:x,borderRadius:v&&!T?"6px":"0",boxShadow:v&&!T?"0 8px 24px rgba(0,0,0,0.22)":"none",padding:T?"0":v?"12px 42px 12px 24px":"8px 42px 8px 16px",display:"flex",alignItems:T?_:"flex-start",justifyContent:"center",gap:T?"0":"16px"});if(k.setAttribute("role",v?"dialog":"region"),k.setAttribute("aria-label","community banner"),k.setAttribute("data-renderer-version","sdk-banner-preview-layout"),v)if(Object.assign(k.style,{position:"fixed",left:"50%",width:"fit-content",maxWidth:T?"70vw":"min(700px, 80vw)",height:"auto",minHeight:T?"0":"80px",maxHeight:T?"70vh":"calc(100vh - 300px)",overflowY:T?"visible":"auto",zIndex:A}),T){const e=[];"left"===N?k.style.left="24px":"right"===N?(k.style.left="",k.style.right="24px"):(k.style.left="50%",e.push("-50%")),"top"===C?k.style.top="10px":"bottom"===C?k.style.bottom="24px":(k.style.top="50%",e.push("-50%")),2===e.length?k.style.transform=`translate(${e[0]}, ${e[1]})`:1===e.length&&"center"===N?k.style.transform=`translateX(${e[0]})`:1===e.length?k.style.transform=`translateY(${e[0]})`:k.style.transform=""}else"bottom"===b?(k.style.bottom="24px",k.style.transform="translateX(-50%)"):"center"===b?(k.style.top="50%",k.style.transform="translate(-50%, -50%)"):(k.style.top="10px",k.style.transform="translateX(-50%)");else Object.assign(k.style,{position:"relative",width:"100%",zIndex:A});const D=be("div",{display:"flex",width:T||v?"auto":"100%",maxWidth:"100%",flexDirection:"column",gap:T?"0":"12px",overflow:"hidden"}),R=be("div",{display:"flex",width:T||v?"auto":"100%",justifyContent:T?E:"space-between",alignItems:T?_:"flex-start",gap:"12px"}),I=be("div",{width:T||v?"auto":"100%",maxWidth:T?"70vw":v?"calc(min(700px, 80vw) - 66px)":"100%",overflow:"hidden",wordBreak:"normal",overflowWrap:"anywhere",whiteSpace:"normal",color:x}),L=(null==(s=e.image)?void 0:s.desktopUrl)||(null==(c=e.image)?void 0:c.mobileUrl);if(T&&L){const t=null==(u=e.image)?void 0:u.linkUrl,n=null==(d=e.image)?void 0:d.openInNewTab,o=be("img",{display:"block",maxWidth:"70vw",maxHeight:"70vh",width:"auto",height:"auto",objectFit:"contain",objectPosition:(P=null==(p=e.image)?void 0:p.horizontalAlignment,F=null==(f=e.image)?void 0:f.verticalAlignment,`${"left"===P?"left":"right"===P?"right":"center"} ${"top"===F?"top":"bottom"===F?"bottom":"center"}`),cursor:t?"pointer":"",borderRadius:"rounded"===(null==(m=e.image)?void 0:m.cornerRadius)?"8px":"0"},{src:L,alt:e.title||"banner"});t&&o.addEventListener("click",()=>{n?window.open(t,"_blank","noopener,noreferrer"):window.location.href=t}),I.appendChild(o)}else{I.innerHTML=(U=e.text)?he.sanitize(U,{ALLOWED_TAGS:["p","strong","em","u","img","span","div","a","br"],ALLOWED_ATTR:["style","src","class","href","target","alt","width","height"],ADD_ATTR:["target"],ALLOW_DATA_ATTR:!1}):"",(z=I).querySelectorAll("p").forEach(e=>{e.style.margin="0",e.style.whiteSpace="normal",e.style.overflowWrap="anywhere"}),z.querySelectorAll("strong").forEach(e=>{e.style.fontWeight="700",e.style.whiteSpace="normal"}),z.querySelectorAll("em").forEach(e=>{e.style.fontStyle="italic",e.style.whiteSpace="normal"}),z.querySelectorAll("u").forEach(e=>{e.style.textDecoration="underline",e.style.whiteSpace="normal"}),z.querySelectorAll("a").forEach(e=>{e.style.color="#3b82f6",e.style.textDecoration="underline",e.style.whiteSpace="normal",e.style.overflowWrap="anywhere","_blank"===e.getAttribute("target")&&e.setAttribute("rel","noopener noreferrer")}),z.querySelectorAll("img").forEach(e=>{e.style.maxWidth="100%",e.style.height="auto"});const t=function(e){const t=e.querySelector('[style*="text-align"]'),n=((null==t?void 0:t.style.textAlign)||e.style.textAlign||"").toLowerCase().trim();return"center"===n||"right"===n||"justify"===n?n:"left"}(I);I.style.textAlign=t,v&&(R.style.justifyContent="center"===(M=t)?"center":"right"===M?"flex-end":"flex-start")}var M,z,U,P,F,H;if(!T&&(null==(h=e.cta)?void 0:h.enabled)){const n=be("button",{cursor:"pointer",border:"none",borderRadius:"6px",height:"36px",minHeight:"36px",padding:"0 16px",fontFamily:"Roboto, sans-serif",fontSize:"12px",fontWeight:"600",lineHeight:"20px",backgroundColor:ye(Te(e,["backgroundColor","buttonColor","aColor"]))||"#2f6df6",color:ye(Te(e,["textColor","color"]))||"#ffffff",boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center"});if(n.type="button",n.textContent=e.cta.label||"CTA Button",n.addEventListener("click",t.onCtaClick),"inline"===w){R.appendChild(I);const e=be("div",{display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"center",flexShrink:"0"});e.appendChild(n),R.appendChild(e),D.appendChild(R)}else{R.appendChild(I),D.appendChild(R);const e=be("div",{display:"flex",width:"100%",justifyContent:(H=w,"left"===H?"flex-start":"right"===H?"flex-end":"center")});e.appendChild(n),D.appendChild(e)}}else R.appendChild(I),D.appendChild(R);k.appendChild(D);const j=be("button",{position:v?"absolute":"",top:v?T?"16px":"12px":"",right:v?T?"16px":"12px":"",marginTop:v?"0":"8px",width:"20px",minWidth:"20px",height:"20px",cursor:"pointer",border:"none",borderRadius:"50%",background:"rgba(0,0,0,0.25)",color:O,fontSize:"16px",lineHeight:"1",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",flexShrink:"0"});return j.type="button",j.setAttribute("aria-label","dismiss banner"),j.innerHTML="&times;",j.addEventListener("click",t.onDismiss),k.appendChild(j),k}function xe(){try{if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function ve(e){if(e)try{(new Image).src=e}catch{}}const we={LOCAL:"http://localhost:1335",SGTR:"https://api-v2.genesiv.org",STG:"https://staging-api-v2.genesiv.org",GEN:"https://api-v2.returning.ai"};class Ee extends HTMLElement{constructor(){super(...arguments),n(this,"rendered",null),n(this,"impressionFired",!1)}connectedCallback(){this.init()}disconnectedCallback(){this.cleanup()}resolveApiUrl(){const e=this.getAttribute("api-url")||this.getAttribute("data-api-url");if(e)return e.replace(/\/+$/,"");const t=this.getAttribute("domain-key")||this.getAttribute("data-domain-key");return t&&we[t]?we[t]:we.LOCAL}device(){const e=window.innerWidth;return e<640?"mobile":e<1024?"tablet":"desktop"}async init(){var e;try{const t=this.getAttribute("community-id")||this.getAttribute("data-community-id");if(!t)return void console.error('[rai-banner] missing required "community-id" attribute');const n=this.resolveApiUrl(),o=this.getAttribute("storage-prefix")||this.getAttribute("data-storage-prefix")||"returning-ai-widget",r=this.getAttribute("surface")||"sdk",i=function(e,t){const n=`${t}-rai-banner-visitor-${e}`;try{let e=localStorage.getItem(n);return e||(e=xe(),localStorage.setItem(n,e)),e}catch{return xe()}}(t,o),a=this.getAttribute("page-path")||window.location.pathname,l=this.getAttribute("page-hostname")||window.location.hostname,s=this.getAttribute("page-url")||window.location.href,c=this.getAttribute("embed-token")||this.getAttribute("data-embed-token")||void 0,u=await async function(e,t){try{const n=await fetch(`${e}/v2/api/banner-sdk/eligible`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await n.json();return o&&o.meta&&"success"===o.meta.status?o.data||{banner:null}:{banner:null,reason:o&&o.detail||"request_failed"}}catch{return{banner:null,reason:"network_error"}}}(n,{communityId:t,surface:r,embedToken:c,page:{url:s,hostname:l,path:a},viewport:{width:window.innerWidth,height:window.innerHeight,device:this.device()},identifier:{type:"anonymous_session",value:i}}),d=u.banner;if(!d)return void this.dispatch("rai-banner-empty",{reason:u.reason});if("hide"===(null==(e=d.placement)?void 0:e.mobileBehavior)&&"mobile"===this.device())return void this.dispatch("rai-banner-empty",{reason:"hidden_on_mobile"});this.mount(d)}catch(t){this.dispatch("rai-banner-error",{error:null==t?void 0:t.message})}}mount(e){var t,n,o,r,i,a,l;if(!this.isConnected)return;const s=Se(e,{onCtaClick:()=>{var t,n,o;ve(null==(t=e.tracking)?void 0:t.clickUrl),this.dispatch("rai-banner-click",{bannerId:e.id});const r=null==(n=e.cta)?void 0:n.url;r&&((null==(o=e.cta)?void 0:o.openInNewTab)?window.open(r,"_blank","noopener,noreferrer"):window.location.href=r)},onDismiss:()=>{var t;ve(null==(t=e.tracking)?void 0:t.dismissUrl),this.dispatch("rai-banner-dismiss",{bannerId:e.id}),this.cleanup()}});this.rendered=s;if("overlay"===(null==(t=e.placement)?void 0:t.mode)||"popup"===(null==(n=e.placement)?void 0:n.mode))document.body.appendChild(s);else{const t=null==(o=e.placement)?void 0:o.targetSelector,n=t?document.querySelector(t):null;if(n){const t=(null==(r=e.placement)?void 0:r.insertion)||"append";"prepend"===t?n.insertBefore(s,n.firstChild):"before"===t?null==(i=n.parentNode)||i.insertBefore(s,n):"after"===t?null==(a=n.parentNode)||a.insertBefore(s,n.nextSibling):n.appendChild(s)}else this.style.display="block",this.style.width="100%",this.appendChild(s)}this.impressionFired||(this.impressionFired=!0,ve(null==(l=e.tracking)?void 0:l.impressionUrl),this.dispatch("rai-banner-impression",{bannerId:e.id}))}cleanup(){this.rendered&&this.rendered.parentNode&&this.rendered.parentNode.removeChild(this.rendered),this.rendered=null}dispatch(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}}function _e(){var e;const t=((null==(e=document.currentScript)?void 0:e.hasAttribute("data-rai-banner"))?document.currentScript:null)||document.querySelector("script[data-rai-banner]");if(!t)return;if(!t.getAttribute("data-community-id"))return;if(document.querySelector("rai-banner"))return;const n=document.createElement("rai-banner"),o={"data-community-id":"community-id","data-api-url":"api-url","data-domain-key":"domain-key","data-surface":"surface","data-storage-prefix":"storage-prefix","data-page-path":"page-path","data-embed-token":"embed-token"};for(const[r,i]of Object.entries(o)){const e=t.getAttribute(r);e&&n.setAttribute(i,e)}document.body.appendChild(n)}return console.log("[rai-banner] v1.7.0"),"undefined"==typeof customElements||customElements.get("rai-banner")||customElements.define("rai-banner",Ee),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",_e):_e(),e.BannerRuntime=Ee,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
3
+ function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,r,i,a,l=[],s=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(s=(o=i.call(n)).done)&&(l.push(o.value),l.length!==t);s=!0);}catch(u){c=!0,r=u}finally{try{if(!s&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const i=Object.entries,a=Object.setPrototypeOf,l=Object.isFrozen,s=Object.getPrototypeOf,c=Object.getOwnPropertyDescriptor;let u=Object.freeze,d=Object.seal,p=Object.create,f="undefined"!=typeof Reflect&&Reflect,m=f.apply,h=f.construct;u||(u=function(e){return e}),d||(d=function(e){return e}),m||(m=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];return e.apply(t,o)}),h||(h=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return new e(...n)});const g=U(Array.prototype.forEach),y=U(Array.prototype.lastIndexOf),b=U(Array.prototype.pop),A=U(Array.prototype.push),T=U(Array.prototype.splice),S=Array.isArray,x=U(String.prototype.toLowerCase),v=U(String.prototype.toString),w=U(String.prototype.match),E=U(String.prototype.replace),_=U(String.prototype.indexOf),N=U(String.prototype.trim),C=U(Number.prototype.toString),O=U(Boolean.prototype.toString),k="undefined"==typeof BigInt?null:U(BigInt.prototype.toString),D="undefined"==typeof Symbol?null:U(Symbol.prototype.toString),R=U(Object.prototype.hasOwnProperty),I=U(Object.prototype.toString),L=U(RegExp.prototype.test),M=(z=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return h(z,t)});var z;function U(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return m(e,t,o)}}function P(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:x;if(a&&a(e,null),!S(t))return e;let o=t.length;for(;o--;){let r=t[o];if("string"==typeof r){const e=n(r);e!==r&&(l(t)||(t[o]=e),r=e)}e[r]=!0}return e}function F(e){for(let t=0;t<e.length;t++){R(e,t)||(e[t]=null)}return e}function H(e){const t=p(null);for(const o of i(e)){var n=r(o,2);const i=n[0],a=n[1];R(e,i)&&(S(a)?t[i]=F(a):a&&"object"==typeof a&&a.constructor===Object?t[i]=H(a):t[i]=a)}return t}function j(e,t){for(;null!==e;){const n=c(e,t);if(n){if(n.get)return U(n.get);if("function"==typeof n.value)return U(n.value)}e=s(e)}return function(){return null}}const W=u(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),B=u(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),G=u(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Y=u(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),q=u(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),$=u(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),X=u(["#text"]),V=u(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),K=u(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Z=u(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),J=u(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Q=d(/{{[\w\W]*|^[\w\W]*}}/g),ee=d(/<%[\w\W]*|^[\w\W]*%>/g),te=d(/\${[\w\W]*/g),ne=d(/^data-[\-\w.\u00B7-\uFFFF]+$/),oe=d(/^aria-[\-\w]+$/),re=d(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ie=d(/^(?:\w+script|data):/i),ae=d(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),le=d(/^html$/i),se=d(/^[a-z][.\w]*(-[.\w]+)+$/i),ce=1,ue=3,de=7,pe=8,fe=9,me=11;var he=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window;const n=t=>e(t);if(n.version="3.4.9",n.removed=[],!t||!t.document||t.document.nodeType!==fe||!t.Element)return n.isSupported=!1,n;let o=t.document;const r=o,a=r.currentScript;t.DocumentFragment;const l=t.HTMLTemplateElement,s=t.Node,c=t.Element,d=t.NodeFilter,f=t.NamedNodeMap;void 0===f&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const m=t.DOMParser,h=t.trustedTypes,z=c.prototype,U=j(z,"cloneNode"),F=j(z,"remove"),he=j(z,"nextSibling"),ge=j(z,"childNodes"),ye=j(z,"parentNode"),be=j(z,"shadowRoot"),Ae=j(z,"attributes"),Te=s&&s.prototype?j(s.prototype,"nodeType"):null,Se=s&&s.prototype?j(s.prototype,"nodeName"):null;if("function"==typeof l){const e=o.createElement("template");e.content&&e.content.ownerDocument&&(o=e.content.ownerDocument)}let xe,ve,we="",Ee=!1,_e=0;const Ne=function(){if(_e>0)throw M('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Ce=function(e){Ne(),_e++;try{return xe.createHTML(e)}finally{_e--}},Oe=function(e){Ne(),_e++;try{return xe.createScriptURL(e)}finally{_e--}},ke=function(){return Ee||(ve=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(i){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(h,a),Ee=!0),ve},De=o,Re=De.implementation,Ie=De.createNodeIterator,Le=De.createDocumentFragment,Me=De.getElementsByTagName,ze=r.importNode;let Ue={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof i&&"function"==typeof ye&&Re&&void 0!==Re.createHTMLDocument;const Pe=Q,Fe=ee,He=te,je=ne,We=oe,Be=ie,Ge=ae,Ye=se;let qe=re,$e=null;const Xe=P({},[...W,...B,...G,...q,...X]);let Ve=null;const Ke=P({},[...V,...K,...Z,...J]);let Ze=Object.seal(p(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Je=null,Qe=null;const et=Object.seal(p(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let tt=!0,nt=!0,ot=!1,rt=!0,it=!1,at=!0,lt=!1,st=!1,ct=!1,ut=!1,dt=!1,pt=!1,ft=!0,mt=!1;const ht="user-content-";let gt=!0,yt=!1,bt={},At=null;const Tt=P({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let St=null;const xt=P({},["audio","video","img","source","image","track"]);let vt=null;const wt=P({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Et="http://www.w3.org/1998/Math/MathML",_t="http://www.w3.org/2000/svg",Nt="http://www.w3.org/1999/xhtml";let Ct=Nt,Ot=!1,kt=null;const Dt=P({},[Et,_t,Nt],v);let Rt=P({},["mi","mo","mn","ms","mtext"]),It=P({},["annotation-xml"]);const Lt=P({},["title","style","font","a","script"]);let Mt=null;const zt=["application/xhtml+xml","text/html"];let Ut=null,Pt=null;const Ft=o.createElement("form"),Ht=function(e){return e instanceof RegExp||e instanceof Function},jt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Pt&&Pt===e)return;e&&"object"==typeof e||(e={}),e=H(e),Mt=-1===zt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Ut="application/xhtml+xml"===Mt?v:x,$e=R(e,"ALLOWED_TAGS")&&S(e.ALLOWED_TAGS)?P({},e.ALLOWED_TAGS,Ut):Xe,Ve=R(e,"ALLOWED_ATTR")&&S(e.ALLOWED_ATTR)?P({},e.ALLOWED_ATTR,Ut):Ke,kt=R(e,"ALLOWED_NAMESPACES")&&S(e.ALLOWED_NAMESPACES)?P({},e.ALLOWED_NAMESPACES,v):Dt,vt=R(e,"ADD_URI_SAFE_ATTR")&&S(e.ADD_URI_SAFE_ATTR)?P(H(wt),e.ADD_URI_SAFE_ATTR,Ut):wt,St=R(e,"ADD_DATA_URI_TAGS")&&S(e.ADD_DATA_URI_TAGS)?P(H(xt),e.ADD_DATA_URI_TAGS,Ut):xt,At=R(e,"FORBID_CONTENTS")&&S(e.FORBID_CONTENTS)?P({},e.FORBID_CONTENTS,Ut):Tt,Je=R(e,"FORBID_TAGS")&&S(e.FORBID_TAGS)?P({},e.FORBID_TAGS,Ut):H({}),Qe=R(e,"FORBID_ATTR")&&S(e.FORBID_ATTR)?P({},e.FORBID_ATTR,Ut):H({}),bt=!!R(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?H(e.USE_PROFILES):e.USE_PROFILES),tt=!1!==e.ALLOW_ARIA_ATTR,nt=!1!==e.ALLOW_DATA_ATTR,ot=e.ALLOW_UNKNOWN_PROTOCOLS||!1,rt=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,it=e.SAFE_FOR_TEMPLATES||!1,at=!1!==e.SAFE_FOR_XML,lt=e.WHOLE_DOCUMENT||!1,ut=e.RETURN_DOM||!1,dt=e.RETURN_DOM_FRAGMENT||!1,pt=e.RETURN_TRUSTED_TYPE||!1,ct=e.FORCE_BODY||!1,ft=!1!==e.SANITIZE_DOM,mt=e.SANITIZE_NAMED_PROPS||!1,gt=!1!==e.KEEP_CONTENT,yt=e.IN_PLACE||!1,qe=function(e){try{return L(e,""),!0}catch(t){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:re,Ct="string"==typeof e.NAMESPACE?e.NAMESPACE:Nt,Rt=R(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?H(e.MATHML_TEXT_INTEGRATION_POINTS):P({},["mi","mo","mn","ms","mtext"]),It=R(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?H(e.HTML_INTEGRATION_POINTS):P({},["annotation-xml"]);const t=R(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?H(e.CUSTOM_ELEMENT_HANDLING):p(null);if(Ze=p(null),R(t,"tagNameCheck")&&Ht(t.tagNameCheck)&&(Ze.tagNameCheck=t.tagNameCheck),R(t,"attributeNameCheck")&&Ht(t.attributeNameCheck)&&(Ze.attributeNameCheck=t.attributeNameCheck),R(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(Ze.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),it&&(nt=!1),dt&&(ut=!0),bt&&($e=P({},X),Ve=p(null),!0===bt.html&&(P($e,W),P(Ve,V)),!0===bt.svg&&(P($e,B),P(Ve,K),P(Ve,J)),!0===bt.svgFilters&&(P($e,G),P(Ve,K),P(Ve,J)),!0===bt.mathMl&&(P($e,q),P(Ve,Z),P(Ve,J))),et.tagCheck=null,et.attributeCheck=null,R(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?et.tagCheck=e.ADD_TAGS:S(e.ADD_TAGS)&&($e===Xe&&($e=H($e)),P($e,e.ADD_TAGS,Ut))),R(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?et.attributeCheck=e.ADD_ATTR:S(e.ADD_ATTR)&&(Ve===Ke&&(Ve=H(Ve)),P(Ve,e.ADD_ATTR,Ut))),R(e,"ADD_URI_SAFE_ATTR")&&S(e.ADD_URI_SAFE_ATTR)&&P(vt,e.ADD_URI_SAFE_ATTR,Ut),R(e,"FORBID_CONTENTS")&&S(e.FORBID_CONTENTS)&&(At===Tt&&(At=H(At)),P(At,e.FORBID_CONTENTS,Ut)),R(e,"ADD_FORBID_CONTENTS")&&S(e.ADD_FORBID_CONTENTS)&&(At===Tt&&(At=H(At)),P(At,e.ADD_FORBID_CONTENTS,Ut)),gt&&($e["#text"]=!0),lt&&P($e,["html","head","body"]),$e.table&&(P($e,["tbody"]),delete Je.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw M('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw M('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=xe;xe=e.TRUSTED_TYPES_POLICY;try{we=Ce("")}catch(n){throw xe=t,n}}else null===e.TRUSTED_TYPES_POLICY?(xe=void 0,we=""):(void 0===xe&&(xe=ke()),xe&&"string"==typeof we&&(we=Ce("")));(Ue.uponSanitizeElement.length>0||Ue.uponSanitizeAttribute.length>0)&&$e===Xe&&($e=H($e)),Ue.uponSanitizeAttribute.length>0&&Ve===Ke&&(Ve=H(Ve)),u&&u(e),Pt=e},Wt=P({},[...B,...G,...Y]),Bt=P({},[...q,...$]),Gt=function(e){A(n.removed,{element:e});try{ye(e).removeChild(e)}catch(t){if(F(e),!ye(e))throw M("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Yt=function(e){const t=ge?ge(e):e.childNodes;if(t){const e=[];g(t,t=>{A(e,t)}),g(e,e=>{try{F(e)}catch(t){}})}const n=Ae?Ae(e):null;if(n)for(let r=n.length-1;r>=0;--r){const t=n[r],i=t&&t.name;if("string"==typeof i)try{e.removeAttribute(i)}catch(o){}}},qt=function(e,t){try{A(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(o){A(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ut||dt)try{Gt(t)}catch(o){}else try{t.setAttribute(e,"")}catch(o){}},$t=function(e){const t=Ae?Ae(e):e.attributes;if(t)for(let o=t.length-1;o>=0;--o){const r=t[o],i=r&&r.name;if("string"==typeof i&&!Ve[Ut(i)])try{e.removeAttribute(i)}catch(n){}}},Xt=function(e){let t=null,n=null;if(ct)e="<remove></remove>"+e;else{const t=w(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Mt&&Ct===Nt&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const r=xe?Ce(e):e;if(Ct===Nt)try{t=(new m).parseFromString(r,Mt)}catch(a){}if(!t||!t.documentElement){t=Re.createDocument(Ct,"template",null);try{t.documentElement.innerHTML=Ot?we:r}catch(a){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(o.createTextNode(n),i.childNodes[0]||null),Ct===Nt?Me.call(t,lt?"html":"body")[0]:lt?t.documentElement:i},Vt=function(e){return Ie.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Kt=function(e){var t,n;e.normalize();const o=Ie.call(e.ownerDocument||e,e,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null);let r=o.nextNode();for(;r;){let e=r.data;g([Pe,Fe,He],t=>{e=E(e,t," ")}),r.data=e,r=o.nextNode()}const i=null!==(t=null===(n=e.querySelectorAll)||void 0===n?void 0:n.call(e,"template"))&&void 0!==t?t:[];g(Array.from(i),e=>{Jt(e.content)&&Kt(e.content)})},Zt=function(e){const t=Se?Se(e):null;return"string"==typeof t&&("form"===Ut(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==Ae(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==Te(e)||e.childNodes!==ge(e)))},Jt=function(e){if(!Te||"object"!=typeof e||null===e)return!1;try{return Te(e)===me}catch(t){return!1}},Qt=function(e){if(!Te||"object"!=typeof e||null===e)return!1;try{return"number"==typeof Te(e)}catch(t){return!1}};function en(e,t,o){g(e,e=>{e.call(n,t,o,Pt)})}const tn=function(e){let t=null;if(en(Ue.beforeSanitizeElements,e,null),Zt(e))return Gt(e),!0;const o=Ut(Se?Se(e):e.nodeName);if(en(Ue.uponSanitizeElement,e,{tagName:o,allowedTags:$e}),at&&e.hasChildNodes()&&!Qt(e.firstElementChild)&&L(/<[/\w!]/g,e.innerHTML)&&L(/<[/\w!]/g,e.textContent))return Gt(e),!0;if(at&&e.namespaceURI===Nt&&"style"===o&&Qt(e.firstElementChild))return Gt(e),!0;if(e.nodeType===de)return Gt(e),!0;if(at&&e.nodeType===pe&&L(/<[/\w]/g,e.data))return Gt(e),!0;if(Je[o]||!(et.tagCheck instanceof Function&&et.tagCheck(o))&&!$e[o]){if(!Je[o]&&rn(o)){if(Ze.tagNameCheck instanceof RegExp&&L(Ze.tagNameCheck,o))return!1;if(Ze.tagNameCheck instanceof Function&&Ze.tagNameCheck(o))return!1}if(gt&&!At[o]){const t=ye(e),n=ge(e);if(n&&t){for(let o=n.length-1;o>=0;--o){const r=yt?n[o]:U(n[o],!0);t.insertBefore(r,he(e))}}}return Gt(e),!0}return((Te?Te(e):e.nodeType)!==ce||function(e){let t=ye(e);t&&t.tagName||(t={namespaceURI:Ct,tagName:"template"});const n=x(e.tagName),o=x(t.tagName);return!!kt[e.namespaceURI]&&(e.namespaceURI===_t?t.namespaceURI===Nt?"svg"===n:t.namespaceURI===Et?"svg"===n&&("annotation-xml"===o||Rt[o]):Boolean(Wt[n]):e.namespaceURI===Et?t.namespaceURI===Nt?"math"===n:t.namespaceURI===_t?"math"===n&&It[o]:Boolean(Bt[n]):e.namespaceURI===Nt?!(t.namespaceURI===_t&&!It[o])&&!(t.namespaceURI===Et&&!Rt[o])&&!Bt[n]&&(Lt[n]||!Wt[n]):!("application/xhtml+xml"!==Mt||!kt[e.namespaceURI]))}(e))&&("noscript"!==o&&"noembed"!==o&&"noframes"!==o||!L(/<\/no(script|embed|frames)/i,e.innerHTML))?(it&&e.nodeType===ue&&(t=e.textContent,g([Pe,Fe,He],e=>{t=E(t,e," ")}),e.textContent!==t&&(A(n.removed,{element:e.cloneNode()}),e.textContent=t)),en(Ue.afterSanitizeElements,e,null),!1):(Gt(e),!0)},nn=function(e,t,n){if(Qe[t])return!1;if(ft&&("id"===t||"name"===t)&&(n in o||n in Ft))return!1;const r=Ve[t]||et.attributeCheck instanceof Function&&et.attributeCheck(t,e);if(nt&&!Qe[t]&&L(je,t));else if(tt&&L(We,t));else if(!r||Qe[t]){if(!(rn(e)&&(Ze.tagNameCheck instanceof RegExp&&L(Ze.tagNameCheck,e)||Ze.tagNameCheck instanceof Function&&Ze.tagNameCheck(e))&&(Ze.attributeNameCheck instanceof RegExp&&L(Ze.attributeNameCheck,t)||Ze.attributeNameCheck instanceof Function&&Ze.attributeNameCheck(t,e))||"is"===t&&Ze.allowCustomizedBuiltInElements&&(Ze.tagNameCheck instanceof RegExp&&L(Ze.tagNameCheck,n)||Ze.tagNameCheck instanceof Function&&Ze.tagNameCheck(n))))return!1}else if(vt[t]);else if(L(qe,E(n,Ge,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==_(n,"data:")||!St[e]){if(ot&&!L(Be,E(n,Ge,"")));else if(n)return!1}else;return!0},on=P({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),rn=function(e){return!on[x(e)]&&L(Ye,e)},an=function(e){en(Ue.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||Zt(e))return;const o={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ve,forceKeepAttr:void 0};let r=t.length;for(;r--;){const a=t[r],l=a.name,s=a.namespaceURI,c=a.value,u=Ut(l),d=c;let p="value"===l?d:N(d);if(o.attrName=u,o.attrValue=p,o.keepAttr=!0,o.forceKeepAttr=void 0,en(Ue.uponSanitizeAttribute,e,o),p=o.attrValue,!mt||"id"!==u&&"name"!==u||0===_(p,ht)||(qt(l,e),p=ht+p),at&&L(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,p)){qt(l,e);continue}if("attributename"===u&&w(p,"href")){qt(l,e);continue}if(o.forceKeepAttr)continue;if(!o.keepAttr){qt(l,e);continue}if(!rt&&L(/\/>/i,p)){qt(l,e);continue}it&&g([Pe,Fe,He],e=>{p=E(p,e," ")});const f=Ut(e.nodeName);if(nn(f,u,p)){if(xe&&"object"==typeof h&&"function"==typeof h.getAttributeType)if(s);else switch(h.getAttributeType(f,u)){case"TrustedHTML":p=Ce(p);break;case"TrustedScriptURL":p=Oe(p)}if(p!==d)try{s?e.setAttributeNS(s,l,p):e.setAttribute(l,p),Zt(e)?Gt(e):b(n.removed)}catch(i){qt(l,e)}}else qt(l,e)}en(Ue.afterSanitizeAttributes,e,null)},ln=function(e){let t=null;const n=Vt(e);for(en(Ue.beforeSanitizeShadowDOM,e,null);t=n.nextNode();){en(Ue.uponSanitizeShadowNode,t,null),tn(t),an(t),Jt(t.content)&&ln(t.content);if((Te?Te(t):t.nodeType)===ce){const e=be?be(t):t.shadowRoot;Jt(e)&&(sn(e),ln(e))}}en(Ue.afterSanitizeShadowDOM,e,null)},sn=function(e){const t=[{node:e,shadow:null}];for(;t.length>0;){const e=t.pop();if(e.shadow){ln(e.shadow);continue}const n=e.node,o=(Te?Te(n):n.nodeType)===ce,r=ge?ge(n):n.childNodes;if(r)for(let i=r.length-1;i>=0;--i)t.push({node:r[i],shadow:null});if(o){const e=Se?Se(n):null;if("string"==typeof e&&"template"===Ut(e)){const e=n.content;Jt(e)&&t.push({node:e,shadow:null})}}if(o){const e=be?be(n):n.shadowRoot;Jt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=null,i=null,a=null,l=null;if(Ot=!e,Ot&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Qt(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return C(e);case"boolean":return O(e);case"bigint":return k?k(e):"0";case"symbol":return D?D(e):"Symbol()";case"undefined":default:return I(e);case"function":case"object":{if(null===e)return I(e);const t=e,n=j(t,"toString");if("function"==typeof n){const e=n(t);return"string"==typeof e?e:I(e)}return I(e)}}}(e)))throw M("dirty is not a string, aborting");if(!n.isSupported)return e;st||jt(t),n.removed=[];const s=yt&&"string"!=typeof e&&Qt(e);if(s){const t=Se?Se(e):e.nodeName;if("string"==typeof t){const e=Ut(t);if(!$e[e]||Je[e])throw M("root node is forbidden and cannot be sanitized in-place")}if(Zt(e))throw M("root node is clobbered and cannot be sanitized in-place");try{sn(e)}catch(d){throw Yt(e),d}}else if(Qt(e))o=Xt("\x3c!----\x3e"),i=o.ownerDocument.importNode(e,!0),i.nodeType===ce&&"BODY"===i.nodeName||"HTML"===i.nodeName?o=i:o.appendChild(i),sn(i);else{if(!ut&&!it&&!lt&&-1===e.indexOf("<"))return xe&&pt?Ce(e):e;if(o=Xt(e),!o)return ut?null:pt?we:""}o&&ct&&Gt(o.firstChild);const c=Vt(s?e:o);try{for(;a=c.nextNode();)tn(a),an(a),Jt(a.content)&&ln(a.content)}catch(d){throw s&&Yt(e),d}if(s)return g(n.removed,e=>{e.element&&function(e){const t=[e];for(;t.length>0;){const e=t.pop();(Te?Te(e):e.nodeType)===ce&&$t(e);const n=ge?ge(e):e.childNodes;if(n)for(let o=n.length-1;o>=0;--o)t.push(n[o])}}(e.element)}),it&&Kt(e),e;if(ut){if(it&&Kt(o),dt)for(l=Le.call(o.ownerDocument);o.firstChild;)l.appendChild(o.firstChild);else l=o;return(Ve.shadowroot||Ve.shadowrootmode)&&(l=ze.call(r,l,!0)),l}let u=lt?o.outerHTML:o.innerHTML;return lt&&$e["!doctype"]&&o.ownerDocument&&o.ownerDocument.doctype&&o.ownerDocument.doctype.name&&L(le,o.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+o.ownerDocument.doctype.name+">\n"+u),it&&g([Pe,Fe,He],e=>{u=E(u,e," ")}),xe&&pt?Ce(u):u},n.setConfig=function(){jt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),st=!0},n.clearConfig=function(){Pt=null,st=!1,xe=ve,we=""},n.isValidAttribute=function(e,t,n){Pt||jt({});const o=Ut(e),r=Ut(t);return nn(o,r,n)},n.addHook=function(e,t){"function"==typeof t&&A(Ue[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=y(Ue[e],t);return-1===n?void 0:T(Ue[e],n,1)[0]}return b(Ue[e])},n.removeHooks=function(e){Ue[e]=[]},n.removeAllHooks=function(){Ue={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();function ge(e,t){const n=e.startsWith("--")?e:`--${e}`,o=[t,document.documentElement,document.body,...Array.from(document.querySelectorAll(["rai-widget","rai-custom-widget","rai-channel-widget","rai-store-widget","rai-milestone-widget","rai-social-widget","rai-currency-widget","rai-referral-widget",".rai-widget-root",'[data-rai-widget-root="true"]'].join(",")))].filter(Boolean),r=new Set;for(const i of o){if(r.has(i))continue;r.add(i);const e=getComputedStyle(i).getPropertyValue(n).trim();if(e)return e}for(const i of Array.from(document.querySelectorAll("*"))){if(r.has(i))continue;const e=getComputedStyle(i).getPropertyValue(n).trim();if(e)return e}}function ye(e,t){if(!e)return;const n=e.trim();if(/^(#|rgb|hsl)/i.test(n))return n;if(/^(--)?[a-z0-9-]+$/i.test(n))return ge(n,t);const o=n.match(/^var\((--[a-z0-9-]+)\)$/i);return o?ge(o[1],t):void 0}function be(e,t,n){const o=document.createElement(e);if(Object.assign(o.style,t),n)for(const r of Object.keys(n))o.setAttribute(r,n[r]);return o}function Ae(e){return"left"===e||"top"===e?"flex-start":"right"===e||"bottom"===e?"flex-end":"center"}function Te(e,t){var n;const o=[null==(n=e.cta)?void 0:n.style,e.cta,e.ctaStyle];for(const r of o)for(const e of t){const t=null==r?void 0:r[e];if(t)return t}}function Se(e,t,n){var o,r,i,a,l,s,c,u,d,p,f,m,h,g;const y=e.placement||{},b=y.mode||"overlay",A=y.position||"top",T=String(y.zIndex||2147483e3),S=function(e){var t,n;return"image"===e.type&&Boolean((null==(t=e.image)?void 0:t.desktopUrl)||(null==(n=e.image)?void 0:n.mobileUrl))}(e),x=S?"transparent":ye(null==(o=e.style)?void 0:o.backgroundColor,n)||"#1f2024",v=ye(null==(r=e.style)?void 0:r.color,n)||"#ffffff",w="overlay"===b||"popup"===b,E=Te(e,["position"])||"center",_=Ae(null==(i=e.image)?void 0:i.horizontalAlignment),N=Ae(null==(a=e.image)?void 0:a.verticalAlignment),C=(null==(l=e.image)?void 0:l.horizontalAlignment)||"center",O=(null==(s=e.image)?void 0:s.verticalAlignment)||"center",k=S?"#ffffff":v,D=be("div",{boxSizing:"border-box",fontFamily:"Roboto, sans-serif",fontSize:"14px",lineHeight:"1.35",background:x,color:v,borderRadius:w&&!S?"6px":"0",boxShadow:w&&!S?"0 8px 24px rgba(0,0,0,0.22)":"none",padding:S?"0":w?"12px 42px 12px 24px":"8px 42px 8px 16px",display:"flex",alignItems:S?N:"flex-start",justifyContent:"center",gap:S?"0":"16px"});if(D.setAttribute("role",w?"dialog":"region"),D.setAttribute("aria-label","community banner"),D.setAttribute("data-renderer-version","sdk-banner-preview-layout"),w)if(Object.assign(D.style,{position:"fixed",left:"50%",width:"fit-content",maxWidth:S?"70vw":"min(700px, 80vw)",height:"auto",minHeight:S?"0":"80px",maxHeight:S?"70vh":"calc(100vh - 300px)",overflowY:S?"visible":"auto",zIndex:T}),S){const e=[];"left"===C?D.style.left="24px":"right"===C?(D.style.left="",D.style.right="24px"):(D.style.left="50%",e.push("-50%")),"top"===O?D.style.top="10px":"bottom"===O?D.style.bottom="24px":(D.style.top="50%",e.push("-50%")),2===e.length?D.style.transform=`translate(${e[0]}, ${e[1]})`:1===e.length&&"center"===C?D.style.transform=`translateX(${e[0]})`:1===e.length?D.style.transform=`translateY(${e[0]})`:D.style.transform=""}else"bottom"===A?(D.style.bottom="24px",D.style.transform="translateX(-50%)"):"center"===A?(D.style.top="50%",D.style.transform="translate(-50%, -50%)"):(D.style.top="10px",D.style.transform="translateX(-50%)");else Object.assign(D.style,{position:"relative",width:"100%",zIndex:T});const R=be("div",{display:"flex",width:S||w?"auto":"100%",maxWidth:"100%",flexDirection:"column",gap:S?"0":"12px",overflow:"hidden"}),I=be("div",{display:"flex",width:S||w?"auto":"100%",justifyContent:S?_:"space-between",alignItems:S?N:"flex-start",gap:"12px"}),L=be("div",{width:S||w?"auto":"100%",maxWidth:S?"70vw":w?"calc(min(700px, 80vw) - 66px)":"100%",overflow:"hidden",wordBreak:"normal",overflowWrap:"anywhere",whiteSpace:"normal",color:v}),M=(null==(c=e.image)?void 0:c.desktopUrl)||(null==(u=e.image)?void 0:u.mobileUrl);if(S&&M){const t=null==(d=e.image)?void 0:d.linkUrl,n=null==(p=e.image)?void 0:p.openInNewTab,o=be("img",{display:"block",maxWidth:"70vw",maxHeight:"70vh",width:"auto",height:"auto",objectFit:"contain",objectPosition:(F=null==(f=e.image)?void 0:f.horizontalAlignment,H=null==(m=e.image)?void 0:m.verticalAlignment,`${"left"===F?"left":"right"===F?"right":"center"} ${"top"===H?"top":"bottom"===H?"bottom":"center"}`),cursor:t?"pointer":"",borderRadius:"rounded"===(null==(h=e.image)?void 0:h.cornerRadius)?"8px":"0"},{src:M,alt:e.title||"banner"});t&&o.addEventListener("click",()=>{n?window.open(t,"_blank","noopener,noreferrer"):window.location.href=t}),L.appendChild(o)}else{L.innerHTML=(P=e.text)?he.sanitize(P,{ALLOWED_TAGS:["p","strong","em","u","img","span","div","a","br"],ALLOWED_ATTR:["style","src","class","href","target","alt","width","height"],ADD_ATTR:["target"],ALLOW_DATA_ATTR:!1}):"",(U=L).querySelectorAll("p").forEach(e=>{e.style.margin="0",e.style.whiteSpace="normal",e.style.overflowWrap="anywhere"}),U.querySelectorAll("strong").forEach(e=>{e.style.fontWeight="700",e.style.whiteSpace="normal"}),U.querySelectorAll("em").forEach(e=>{e.style.fontStyle="italic",e.style.whiteSpace="normal"}),U.querySelectorAll("u").forEach(e=>{e.style.textDecoration="underline",e.style.whiteSpace="normal"}),U.querySelectorAll("a").forEach(e=>{e.style.color="#3b82f6",e.style.textDecoration="underline",e.style.whiteSpace="normal",e.style.overflowWrap="anywhere","_blank"===e.getAttribute("target")&&e.setAttribute("rel","noopener noreferrer")}),U.querySelectorAll("img").forEach(e=>{e.style.maxWidth="100%",e.style.height="auto"});const t=function(e){const t=e.querySelector('[style*="text-align"]'),n=((null==t?void 0:t.style.textAlign)||e.style.textAlign||"").toLowerCase().trim();return"center"===n||"right"===n||"justify"===n?n:"left"}(L);L.style.textAlign=t,w&&(I.style.justifyContent="center"===(z=t)?"center":"right"===z?"flex-end":"flex-start")}var z,U,P,F,H,j;if(!S&&(null==(g=e.cta)?void 0:g.enabled)){const o=be("button",{cursor:"pointer",border:"none",borderRadius:"6px",height:"36px",minHeight:"36px",padding:"0 16px",fontFamily:"Roboto, sans-serif",fontSize:"12px",fontWeight:"600",lineHeight:"20px",backgroundColor:ye(Te(e,["backgroundColor","buttonColor","aColor"]),n)||"#2f6df6",color:ye(Te(e,["textColor","color"]),n)||"#ffffff",boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center"});if(o.type="button",o.textContent=e.cta.label||"CTA Button",o.addEventListener("click",t.onCtaClick),"inline"===E){I.appendChild(L);const e=be("div",{display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"center",flexShrink:"0"});e.appendChild(o),I.appendChild(e),R.appendChild(I)}else{I.appendChild(L),R.appendChild(I);const e=be("div",{display:"flex",width:"100%",justifyContent:(j=E,"left"===j?"flex-start":"right"===j?"flex-end":"center")});e.appendChild(o),R.appendChild(e)}}else I.appendChild(L),R.appendChild(I);D.appendChild(R);const W=be("button",{position:w?"absolute":"",top:w?S?"16px":"12px":"",right:w?S?"16px":"12px":"",marginTop:w?"0":"8px",width:"20px",minWidth:"20px",height:"20px",cursor:"pointer",border:"none",borderRadius:"50%",background:"rgba(0,0,0,0.25)",color:k,fontSize:"16px",lineHeight:"1",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",flexShrink:"0"});return W.type="button",W.setAttribute("aria-label","dismiss banner"),W.innerHTML="&times;",W.addEventListener("click",t.onDismiss),D.appendChild(W),D}he.addHook("afterSanitizeAttributes",e=>{"A"===e.tagName&&"_blank"===e.getAttribute("target")&&e.setAttribute("rel","noopener noreferrer")});function xe(){try{if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function ve(e){if(e)try{(new Image).src=e}catch{}}const we={LOCAL:"http://localhost:1335",SGTR:"https://api-v2.genesiv.org",STG:"https://staging-api-v2.genesiv.org",GEN:"https://api-v2.returning.ai"};class Ee extends HTMLElement{constructor(){super(...arguments),n(this,"rendered",null),n(this,"impressionFired",!1)}connectedCallback(){this.init()}disconnectedCallback(){this.cleanup()}resolveApiUrl(){const e=this.getAttribute("api-url")||this.getAttribute("data-api-url");if(e)return e.replace(/\/+$/,"");const t=this.getAttribute("domain-key")||this.getAttribute("data-domain-key");return t&&we[t]?we[t]:we.LOCAL}device(){const e=window.innerWidth;return e<640?"mobile":e<1024?"tablet":"desktop"}async init(){var e;try{const t=this.getAttribute("community-id")||this.getAttribute("data-community-id");if(!t)return void console.error('[rai-banner] missing required "community-id" attribute');const n=this.resolveApiUrl(),o=this.getAttribute("storage-prefix")||this.getAttribute("data-storage-prefix")||"returning-ai-widget",r=this.getAttribute("surface")||"sdk",i=function(e,t){const n=`${t}-rai-banner-visitor-${e}`;try{let e=localStorage.getItem(n);return e||(e=xe(),localStorage.setItem(n,e)),e}catch{return xe()}}(t,o),a=this.getAttribute("page-path")||window.location.pathname,l=this.getAttribute("page-hostname")||window.location.hostname,s=this.getAttribute("page-url")||window.location.href,c=this.getAttribute("embed-token")||this.getAttribute("data-embed-token")||void 0,u=await async function(e,t){try{const n=await fetch(`${e}/v2/api/banner-sdk/eligible`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await n.json();return o&&o.meta&&"success"===o.meta.status?o.data||{banner:null}:{banner:null,reason:o&&o.detail||"request_failed"}}catch{return{banner:null,reason:"network_error"}}}(n,{communityId:t,surface:r,embedToken:c,page:{url:s,hostname:l,path:a},viewport:{width:window.innerWidth,height:window.innerHeight,device:this.device()},identifier:{type:"anonymous_session",value:i}}),d=u.banner;if(!d)return void this.dispatch("rai-banner-empty",{reason:u.reason});if("hide"===(null==(e=d.placement)?void 0:e.mobileBehavior)&&"mobile"===this.device())return void this.dispatch("rai-banner-empty",{reason:"hidden_on_mobile"});this.mount(d)}catch(t){this.dispatch("rai-banner-error",{error:null==t?void 0:t.message})}}mount(e){var t,n,o,r,i,a,l;if(!this.isConnected)return;const s=Se(e,{onCtaClick:()=>{var t,n,o;ve(null==(t=e.tracking)?void 0:t.clickUrl),this.dispatch("rai-banner-click",{bannerId:e.id});const r=null==(n=e.cta)?void 0:n.url;r&&((null==(o=e.cta)?void 0:o.openInNewTab)?window.open(r,"_blank","noopener,noreferrer"):window.location.href=r)},onDismiss:()=>{var t;ve(null==(t=e.tracking)?void 0:t.dismissUrl),this.dispatch("rai-banner-dismiss",{bannerId:e.id}),this.cleanup()}},this);this.rendered=s;if("overlay"===(null==(t=e.placement)?void 0:t.mode)||"popup"===(null==(n=e.placement)?void 0:n.mode))document.body.appendChild(s);else{const t=null==(o=e.placement)?void 0:o.targetSelector,n=t?document.querySelector(t):null;if(n){const t=(null==(r=e.placement)?void 0:r.insertion)||"append";"prepend"===t?n.insertBefore(s,n.firstChild):"before"===t?null==(i=n.parentNode)||i.insertBefore(s,n):"after"===t?null==(a=n.parentNode)||a.insertBefore(s,n.nextSibling):n.appendChild(s)}else this.style.display="block",this.style.width="100%",this.appendChild(s)}this.impressionFired||(this.impressionFired=!0,ve(null==(l=e.tracking)?void 0:l.impressionUrl),this.dispatch("rai-banner-impression",{bannerId:e.id}))}cleanup(){this.rendered&&this.rendered.parentNode&&this.rendered.parentNode.removeChild(this.rendered),this.rendered=null}dispatch(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}}function _e(){var e;const t=((null==(e=document.currentScript)?void 0:e.hasAttribute("data-rai-banner"))?document.currentScript:null)||document.querySelector("script[data-rai-banner]");if(!t)return;if(!t.getAttribute("data-community-id"))return;if(document.querySelector("rai-banner"))return;const n=document.createElement("rai-banner"),o={"data-community-id":"community-id","data-api-url":"api-url","data-domain-key":"domain-key","data-surface":"surface","data-storage-prefix":"storage-prefix","data-page-path":"page-path","data-embed-token":"embed-token"};for(const[r,i]of Object.entries(o)){const e=t.getAttribute(r);e&&n.setAttribute(i,e)}document.body.appendChild(n)}return console.log("[rai-banner] v1.7.2"),"undefined"==typeof customElements||customElements.get("rai-banner")||customElements.define("rai-banner",Ee),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",_e):_e(),e.BannerRuntime=Ee,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
@@ -1407,9 +1407,10 @@ function sanitizeBannerHtml(html2) {
1407
1407
  ALLOW_DATA_ATTR: false
1408
1408
  });
1409
1409
  }
1410
- function resolveCssToken(token) {
1410
+ function resolveCssToken(token, preferredScope) {
1411
1411
  const normalizedToken = token.startsWith("--") ? token : `--${token}`;
1412
1412
  const candidates = [
1413
+ preferredScope,
1413
1414
  document.documentElement,
1414
1415
  document.body,
1415
1416
  ...Array.from(
@@ -1429,32 +1430,33 @@ function resolveCssToken(token) {
1429
1430
  )
1430
1431
  )
1431
1432
  ].filter(Boolean);
1433
+ const checked = /* @__PURE__ */ new Set();
1432
1434
  for (const node of candidates) {
1435
+ if (checked.has(node)) continue;
1436
+ checked.add(node);
1433
1437
  const value = getComputedStyle(node).getPropertyValue(normalizedToken).trim();
1434
1438
  if (value) return value;
1435
1439
  }
1436
1440
  for (const node of Array.from(document.querySelectorAll("*"))) {
1441
+ if (checked.has(node)) continue;
1437
1442
  const value = getComputedStyle(node).getPropertyValue(normalizedToken).trim();
1438
1443
  if (value) return value;
1439
1444
  }
1440
1445
  return void 0;
1441
1446
  }
1442
- const safeColor = (v) => {
1447
+ function safeColor(v, preferredScope) {
1443
1448
  if (!v) return void 0;
1444
1449
  const value = v.trim();
1445
1450
  if (/^(#|rgb|hsl)/i.test(value)) return value;
1446
1451
  if (/^(--)?[a-z0-9-]+$/i.test(value)) {
1447
- const resolved = resolveCssToken(value);
1448
- return resolved;
1452
+ return resolveCssToken(value, preferredScope);
1449
1453
  }
1450
1454
  const varMatch = value.match(/^var\((--[a-z0-9-]+)\)$/i);
1451
1455
  if (varMatch) {
1452
- const token = varMatch[1];
1453
- const resolved = resolveCssToken(token);
1454
- return resolved;
1456
+ return resolveCssToken(varMatch[1], preferredScope);
1455
1457
  }
1456
1458
  return void 0;
1457
- };
1459
+ }
1458
1460
  function el(tag, styles, attrs) {
1459
1461
  const node = document.createElement(tag);
1460
1462
  Object.assign(node.style, styles);
@@ -1538,15 +1540,15 @@ function justifyFromTextAlign(align) {
1538
1540
  if (align === "right") return "flex-end";
1539
1541
  return "flex-start";
1540
1542
  }
1541
- function renderBanner(banner, handlers) {
1543
+ function renderBanner(banner, handlers, colorScope) {
1542
1544
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
1543
1545
  const placement = banner.placement || {};
1544
1546
  const mode = placement.mode || "overlay";
1545
1547
  const position = placement.position || "top";
1546
1548
  const zIndex = String(placement.zIndex || 2147483e3);
1547
1549
  const imageBanner = isImageBanner(banner);
1548
- const bg = imageBanner ? "transparent" : safeColor((_a = banner.style) == null ? void 0 : _a.backgroundColor) || "#1f2024";
1549
- const color = safeColor((_b = banner.style) == null ? void 0 : _b.color) || "#ffffff";
1550
+ const bg = imageBanner ? "transparent" : safeColor((_a = banner.style) == null ? void 0 : _a.backgroundColor, colorScope) || "#1f2024";
1551
+ const color = safeColor((_b = banner.style) == null ? void 0 : _b.color, colorScope) || "#ffffff";
1550
1552
  const isCard = mode === "overlay" || mode === "popup";
1551
1553
  const ctaPosition = getCtaStyleValue(banner, ["position"]) || "center";
1552
1554
  const imageHorizontal = imageAlign((_c = banner.image) == null ? void 0 : _c.horizontalAlignment);
@@ -1687,9 +1689,13 @@ function renderBanner(banner, handlers) {
1687
1689
  }
1688
1690
  if (!imageBanner && ((_n = banner.cta) == null ? void 0 : _n.enabled)) {
1689
1691
  const ctaBg = safeColor(
1690
- getCtaStyleValue(banner, ["backgroundColor", "buttonColor", "aColor"])
1692
+ getCtaStyleValue(banner, ["backgroundColor", "buttonColor", "aColor"]),
1693
+ colorScope
1691
1694
  ) || "#2f6df6";
1692
- const ctaColor = safeColor(getCtaStyleValue(banner, ["textColor", "color"])) || "#ffffff";
1695
+ const ctaColor = safeColor(
1696
+ getCtaStyleValue(banner, ["textColor", "color"]),
1697
+ colorScope
1698
+ ) || "#ffffff";
1693
1699
  const btn = el("button", {
1694
1700
  cursor: "pointer",
1695
1701
  border: "none",
@@ -1875,23 +1881,27 @@ class BannerRuntime extends HTMLElement {
1875
1881
  mount(banner) {
1876
1882
  var _a, _b, _c, _d, _e, _f, _g;
1877
1883
  if (!this.isConnected) return;
1878
- const node = renderBanner(banner, {
1879
- onCtaClick: () => {
1880
- var _a2, _b2, _c2;
1881
- fireTracking((_a2 = banner.tracking) == null ? void 0 : _a2.clickUrl);
1882
- this.dispatch("rai-banner-click", { bannerId: banner.id });
1883
- const u = (_b2 = banner.cta) == null ? void 0 : _b2.url;
1884
- if (!u) return;
1885
- if ((_c2 = banner.cta) == null ? void 0 : _c2.openInNewTab) window.open(u, "_blank", "noopener,noreferrer");
1886
- else window.location.href = u;
1884
+ const node = renderBanner(
1885
+ banner,
1886
+ {
1887
+ onCtaClick: () => {
1888
+ var _a2, _b2, _c2;
1889
+ fireTracking((_a2 = banner.tracking) == null ? void 0 : _a2.clickUrl);
1890
+ this.dispatch("rai-banner-click", { bannerId: banner.id });
1891
+ const u = (_b2 = banner.cta) == null ? void 0 : _b2.url;
1892
+ if (!u) return;
1893
+ if ((_c2 = banner.cta) == null ? void 0 : _c2.openInNewTab) window.open(u, "_blank", "noopener,noreferrer");
1894
+ else window.location.href = u;
1895
+ },
1896
+ onDismiss: () => {
1897
+ var _a2;
1898
+ fireTracking((_a2 = banner.tracking) == null ? void 0 : _a2.dismissUrl);
1899
+ this.dispatch("rai-banner-dismiss", { bannerId: banner.id });
1900
+ this.cleanup();
1901
+ }
1887
1902
  },
1888
- onDismiss: () => {
1889
- var _a2;
1890
- fireTracking((_a2 = banner.tracking) == null ? void 0 : _a2.dismissUrl);
1891
- this.dispatch("rai-banner-dismiss", { bannerId: banner.id });
1892
- this.cleanup();
1893
- }
1894
- });
1903
+ this
1904
+ );
1895
1905
  this.rendered = node;
1896
1906
  const isCard = ((_a = banner.placement) == null ? void 0 : _a.mode) === "overlay" || ((_b = banner.placement) == null ? void 0 : _b.mode) === "popup";
1897
1907
  if (isCard) {
@@ -1927,7 +1937,7 @@ class BannerRuntime extends HTMLElement {
1927
1937
  this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));
1928
1938
  }
1929
1939
  }
1930
- console.log(`[rai-banner] v${"1.7.0"}`);
1940
+ console.log(`[rai-banner] v${"1.7.2"}`);
1931
1941
  if (typeof customElements !== "undefined" && !customElements.get("rai-banner")) {
1932
1942
  customElements.define("rai-banner", BannerRuntime);
1933
1943
  }