@flourish/sdk
Version:
The Flourish SDK
4 lines (3 loc) • 34.3 kB
JavaScript
!function(){"use strict";var e=!1;function t(t){if(e&&window.top!==window.self){var n=window;"srcdoc"===n.location.pathname&&(n=n.parent);var o,i=(o={},window._Flourish_template_id&&(o.template_id=window._Flourish_template_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_template_id&&(o.template_id=window.Flourish.app.loaded_template_id),window._Flourish_visualisation_id&&(o.visualisation_id=window._Flourish_visualisation_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_visualisation&&(o.visualisation_id=window.Flourish.app.loaded_visualisation.id),window.Flourish&&window.Flourish.app&&window.Flourish.app.story&&(o.story_id=window.Flourish.app.story.id,o.slide_count=window.Flourish.app.story.slides.length),window.Flourish&&window.Flourish.app&&window.Flourish.app.current_slide&&(o.slide_index=window.Flourish.app.current_slide.index+1),o),r={sender:"Flourish",method:"customerAnalytics"};for(var a in i)i.hasOwnProperty(a)&&(r[a]=i[a]);for(var a in t)t.hasOwnProperty(a)&&(r[a]=t[a]);n.parent.postMessage(JSON.stringify(r),"*")}}function n(e){if("function"!=typeof e)throw new Error("Analytics callback is not a function");window.Flourish._analytics_listeners.push(e)}function o(){e=!0;[{event_name:"click",action_name:"click",use_capture:!0},{event_name:"keydown",action_name:"key_down",use_capture:!0},{event_name:"mouseenter",action_name:"mouse_enter",use_capture:!1},{event_name:"mouseleave",action_name:"mouse_leave",use_capture:!1}].forEach(function(e){document.body.addEventListener(e.event_name,function(){t({action:e.action_name})},e.use_capture)})}
/*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */const{entries:i,setPrototypeOf:r,isFrozen:a,getPrototypeOf:l,getOwnPropertyDescriptor:s}=Object;let{freeze:c,seal:u,create:d}=Object,{apply:m,construct:p}="undefined"!=typeof Reflect&&Reflect;c||(c=function(e){return e}),u||(u=function(e){return e}),m||(m=function(e,t,n){return e.apply(t,n)}),p||(p=function(e,t){return new e(...t)});const f=L(Array.prototype.forEach),h=L(Array.prototype.lastIndexOf),g=L(Array.prototype.pop),y=L(Array.prototype.push),w=L(Array.prototype.splice),_=L(String.prototype.toLowerCase),v=L(String.prototype.toString),T=L(String.prototype.match),A=L(String.prototype.replace),E=L(String.prototype.indexOf),b=L(String.prototype.trim),S=L(Object.prototype.hasOwnProperty),x=L(RegExp.prototype.test),N=(O=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return p(O,t)});var O;function L(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return m(e,t,o)}}function R(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_;r&&r(e,null);let o=t.length;for(;o--;){let i=t[o];if("string"==typeof i){const e=n(i);e!==i&&(a(t)||(t[o]=e),i=e)}e[i]=!0}return e}function C(e){for(let t=0;t<e.length;t++){S(e,t)||(e[t]=null)}return e}function M(e){const t=d(null);for(const[n,o]of i(e)){S(e,n)&&(Array.isArray(o)?t[n]=C(o):o&&"object"==typeof o&&o.constructor===Object?t[n]=M(o):t[n]=o)}return t}function F(e,t){for(;null!==e;){const n=s(e,t);if(n){if(n.get)return L(n.get);if("function"==typeof n.value)return L(n.value)}e=l(e)}return function(){return null}}const k=c(["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","section","select","shadow","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"]),D=c(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),I=c(["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"]),z=c(["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"]),P=c(["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=c(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),H=c(["#text"]),W=c(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","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","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),B=c(["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","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"]),G=c(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","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=c(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),q=u(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Y=u(/<%[\w\W]*|[\w\W]*%>/gm),$=u(/\$\{[\w\W]*/gm),X=u(/^data-[\-\w.\u00B7-\uFFFF]+$/),J=u(/^aria-[\-\w]+$/),V=u(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),K=u(/^(?:\w+script|data):/i),Z=u(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Q=u(/^html$/i),ee=u(/^[a-z][.\w]*(-[.\w]+)+$/i);var te=Object.freeze({__proto__:null,ARIA_ATTR:J,ATTR_WHITESPACE:Z,CUSTOM_ELEMENT:ee,DATA_ATTR:X,DOCTYPE_NAME:Q,ERB_EXPR:Y,IS_ALLOWED_URI:V,IS_SCRIPT_OR_DATA:K,MUSTACHE_EXPR:q,TMPLIT_EXPR:$});const ne=1,oe=3,ie=7,re=8,ae=9,le=function(){return"undefined"==typeof window?null:window};var se,ce,ue=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:le();const n=t=>e(t);if(n.version="3.2.4",n.removed=[],!t||!t.document||t.document.nodeType!==ae||!t.Element)return n.isSupported=!1,n;let{document:o}=t;const r=o,a=r.currentScript,{DocumentFragment:l,HTMLTemplateElement:s,Node:u,Element:m,NodeFilter:p,NamedNodeMap:O=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:L,DOMParser:C,trustedTypes:q}=t,Y=m.prototype,$=F(Y,"cloneNode"),X=F(Y,"remove"),J=F(Y,"nextSibling"),K=F(Y,"childNodes"),Z=F(Y,"parentNode");if("function"==typeof s){const e=o.createElement("template");e.content&&e.content.ownerDocument&&(o=e.content.ownerDocument)}let ee,se="";const{implementation:ce,createNodeIterator:ue,createDocumentFragment:de,getElementsByTagName:me}=o,{importNode:pe}=r;let fe={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof i&&"function"==typeof Z&&ce&&void 0!==ce.createHTMLDocument;const{MUSTACHE_EXPR:he,ERB_EXPR:ge,TMPLIT_EXPR:ye,DATA_ATTR:we,ARIA_ATTR:_e,IS_SCRIPT_OR_DATA:ve,ATTR_WHITESPACE:Te,CUSTOM_ELEMENT:Ae}=te;let{IS_ALLOWED_URI:Ee}=te,be=null;const Se=R({},[...k,...D,...I,...P,...H]);let xe=null;const Ne=R({},[...W,...B,...G,...j]);let Oe=Object.seal(d(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}})),Le=null,Re=null,Ce=!0,Me=!0,Fe=!1,ke=!0,De=!1,Ie=!0,ze=!1,Pe=!1,Ue=!1,He=!1,We=!1,Be=!1,Ge=!0,je=!1,qe=!0,Ye=!1,$e={},Xe=null;const Je=R({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ve=null;const Ke=R({},["audio","video","img","source","image","track"]);let Ze=null;const Qe=R({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),et="http://www.w3.org/1998/Math/MathML",tt="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml";let ot=nt,it=!1,rt=null;const at=R({},[et,tt,nt],v);let lt=R({},["mi","mo","mn","ms","mtext"]),st=R({},["annotation-xml"]);const ct=R({},["title","style","font","a","script"]);let ut=null;const dt=["application/xhtml+xml","text/html"];let mt=null,pt=null;const ft=o.createElement("form"),ht=function(e){return e instanceof RegExp||e instanceof Function},gt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!pt||pt!==e){if(e&&"object"==typeof e||(e={}),e=M(e),ut=-1===dt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,mt="application/xhtml+xml"===ut?v:_,be=S(e,"ALLOWED_TAGS")?R({},e.ALLOWED_TAGS,mt):Se,xe=S(e,"ALLOWED_ATTR")?R({},e.ALLOWED_ATTR,mt):Ne,rt=S(e,"ALLOWED_NAMESPACES")?R({},e.ALLOWED_NAMESPACES,v):at,Ze=S(e,"ADD_URI_SAFE_ATTR")?R(M(Qe),e.ADD_URI_SAFE_ATTR,mt):Qe,Ve=S(e,"ADD_DATA_URI_TAGS")?R(M(Ke),e.ADD_DATA_URI_TAGS,mt):Ke,Xe=S(e,"FORBID_CONTENTS")?R({},e.FORBID_CONTENTS,mt):Je,Le=S(e,"FORBID_TAGS")?R({},e.FORBID_TAGS,mt):{},Re=S(e,"FORBID_ATTR")?R({},e.FORBID_ATTR,mt):{},$e=!!S(e,"USE_PROFILES")&&e.USE_PROFILES,Ce=!1!==e.ALLOW_ARIA_ATTR,Me=!1!==e.ALLOW_DATA_ATTR,Fe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ke=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,De=e.SAFE_FOR_TEMPLATES||!1,Ie=!1!==e.SAFE_FOR_XML,ze=e.WHOLE_DOCUMENT||!1,He=e.RETURN_DOM||!1,We=e.RETURN_DOM_FRAGMENT||!1,Be=e.RETURN_TRUSTED_TYPE||!1,Ue=e.FORCE_BODY||!1,Ge=!1!==e.SANITIZE_DOM,je=e.SANITIZE_NAMED_PROPS||!1,qe=!1!==e.KEEP_CONTENT,Ye=e.IN_PLACE||!1,Ee=e.ALLOWED_URI_REGEXP||V,ot=e.NAMESPACE||nt,lt=e.MATHML_TEXT_INTEGRATION_POINTS||lt,st=e.HTML_INTEGRATION_POINTS||st,Oe=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Oe.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Oe.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Oe.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),De&&(Me=!1),We&&(He=!0),$e&&(be=R({},H),xe=[],!0===$e.html&&(R(be,k),R(xe,W)),!0===$e.svg&&(R(be,D),R(xe,B),R(xe,j)),!0===$e.svgFilters&&(R(be,I),R(xe,B),R(xe,j)),!0===$e.mathMl&&(R(be,P),R(xe,G),R(xe,j))),e.ADD_TAGS&&(be===Se&&(be=M(be)),R(be,e.ADD_TAGS,mt)),e.ADD_ATTR&&(xe===Ne&&(xe=M(xe)),R(xe,e.ADD_ATTR,mt)),e.ADD_URI_SAFE_ATTR&&R(Ze,e.ADD_URI_SAFE_ATTR,mt),e.FORBID_CONTENTS&&(Xe===Je&&(Xe=M(Xe)),R(Xe,e.FORBID_CONTENTS,mt)),qe&&(be["#text"]=!0),ze&&R(be,["html","head","body"]),be.table&&(R(be,["tbody"]),delete Le.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw N('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw N('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');ee=e.TRUSTED_TYPES_POLICY,se=ee.createHTML("")}else void 0===ee&&(ee=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 i="dompurify"+(n?"#"+n:"");try{return e.createPolicy(i,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+i+" could not be created."),null}}(q,a)),null!==ee&&"string"==typeof se&&(se=ee.createHTML(""));c&&c(e),pt=e}},yt=R({},[...D,...I,...z]),wt=R({},[...P,...U]),_t=function(e){y(n.removed,{element:e});try{Z(e).removeChild(e)}catch(t){X(e)}},vt=function(e,t){try{y(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){y(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(He||We)try{_t(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Tt=function(e){let t=null,n=null;if(Ue)e="<remove></remove>"+e;else{const t=T(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===ut&&ot===nt&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const i=ee?ee.createHTML(e):e;if(ot===nt)try{t=(new C).parseFromString(i,ut)}catch(e){}if(!t||!t.documentElement){t=ce.createDocument(ot,"template",null);try{t.documentElement.innerHTML=it?se:i}catch(e){}}const r=t.body||t.documentElement;return e&&n&&r.insertBefore(o.createTextNode(n),r.childNodes[0]||null),ot===nt?me.call(t,ze?"html":"body")[0]:ze?t.documentElement:r},At=function(e){return ue.call(e.ownerDocument||e,e,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Et=function(e){return e instanceof L&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof O)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},bt=function(e){return"function"==typeof u&&e instanceof u};function St(e,t,o){f(e,e=>{e.call(n,t,o,pt)})}const xt=function(e){let t=null;if(St(fe.beforeSanitizeElements,e,null),Et(e))return _t(e),!0;const o=mt(e.nodeName);if(St(fe.uponSanitizeElement,e,{tagName:o,allowedTags:be}),e.hasChildNodes()&&!bt(e.firstElementChild)&&x(/<[/\w]/g,e.innerHTML)&&x(/<[/\w]/g,e.textContent))return _t(e),!0;if(e.nodeType===ie)return _t(e),!0;if(Ie&&e.nodeType===re&&x(/<[/\w]/g,e.data))return _t(e),!0;if(!be[o]||Le[o]){if(!Le[o]&&Ot(o)){if(Oe.tagNameCheck instanceof RegExp&&x(Oe.tagNameCheck,o))return!1;if(Oe.tagNameCheck instanceof Function&&Oe.tagNameCheck(o))return!1}if(qe&&!Xe[o]){const t=Z(e)||e.parentNode,n=K(e)||e.childNodes;if(n&&t){for(let o=n.length-1;o>=0;--o){const i=$(n[o],!0);i.__removalCount=(e.__removalCount||0)+1,t.insertBefore(i,J(e))}}}return _t(e),!0}return e instanceof m&&!function(e){let t=Z(e);t&&t.tagName||(t={namespaceURI:ot,tagName:"template"});const n=_(e.tagName),o=_(t.tagName);return!!rt[e.namespaceURI]&&(e.namespaceURI===tt?t.namespaceURI===nt?"svg"===n:t.namespaceURI===et?"svg"===n&&("annotation-xml"===o||lt[o]):Boolean(yt[n]):e.namespaceURI===et?t.namespaceURI===nt?"math"===n:t.namespaceURI===tt?"math"===n&&st[o]:Boolean(wt[n]):e.namespaceURI===nt?!(t.namespaceURI===tt&&!st[o])&&!(t.namespaceURI===et&&!lt[o])&&!wt[n]&&(ct[n]||!yt[n]):!("application/xhtml+xml"!==ut||!rt[e.namespaceURI]))}(e)?(_t(e),!0):"noscript"!==o&&"noembed"!==o&&"noframes"!==o||!x(/<\/no(script|embed|frames)/i,e.innerHTML)?(De&&e.nodeType===oe&&(t=e.textContent,f([he,ge,ye],e=>{t=A(t,e," ")}),e.textContent!==t&&(y(n.removed,{element:e.cloneNode()}),e.textContent=t)),St(fe.afterSanitizeElements,e,null),!1):(_t(e),!0)},Nt=function(e,t,n){if(Ge&&("id"===t||"name"===t)&&(n in o||n in ft))return!1;if(Me&&!Re[t]&&x(we,t));else if(Ce&&x(_e,t));else if(!xe[t]||Re[t]){if(!(Ot(e)&&(Oe.tagNameCheck instanceof RegExp&&x(Oe.tagNameCheck,e)||Oe.tagNameCheck instanceof Function&&Oe.tagNameCheck(e))&&(Oe.attributeNameCheck instanceof RegExp&&x(Oe.attributeNameCheck,t)||Oe.attributeNameCheck instanceof Function&&Oe.attributeNameCheck(t))||"is"===t&&Oe.allowCustomizedBuiltInElements&&(Oe.tagNameCheck instanceof RegExp&&x(Oe.tagNameCheck,n)||Oe.tagNameCheck instanceof Function&&Oe.tagNameCheck(n))))return!1}else if(Ze[t]);else if(x(Ee,A(n,Te,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==E(n,"data:")||!Ve[e]){if(Fe&&!x(ve,A(n,Te,"")));else if(n)return!1}else;return!0},Ot=function(e){return"annotation-xml"!==e&&T(e,Ae)},Lt=function(e){St(fe.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||Et(e))return;const o={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe,forceKeepAttr:void 0};let i=t.length;for(;i--;){const r=t[i],{name:a,namespaceURI:l,value:s}=r,c=mt(a);let u="value"===a?s:b(s);if(o.attrName=c,o.attrValue=u,o.keepAttr=!0,o.forceKeepAttr=void 0,St(fe.uponSanitizeAttribute,e,o),u=o.attrValue,!je||"id"!==c&&"name"!==c||(vt(a,e),u="user-content-"+u),Ie&&x(/((--!?|])>)|<\/(style|title)/i,u)){vt(a,e);continue}if(o.forceKeepAttr)continue;if(vt(a,e),!o.keepAttr)continue;if(!ke&&x(/\/>/i,u)){vt(a,e);continue}De&&f([he,ge,ye],e=>{u=A(u,e," ")});const d=mt(e.nodeName);if(Nt(d,c,u)){if(ee&&"object"==typeof q&&"function"==typeof q.getAttributeType)if(l);else switch(q.getAttributeType(d,c)){case"TrustedHTML":u=ee.createHTML(u);break;case"TrustedScriptURL":u=ee.createScriptURL(u)}try{l?e.setAttributeNS(l,a,u):e.setAttribute(a,u),Et(e)?_t(e):g(n.removed)}catch(e){}}}St(fe.afterSanitizeAttributes,e,null)},Rt=function e(t){let n=null;const o=At(t);for(St(fe.beforeSanitizeShadowDOM,t,null);n=o.nextNode();)St(fe.uponSanitizeShadowNode,n,null),xt(n),Lt(n),n.content instanceof l&&e(n.content);St(fe.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=null,i=null,a=null,s=null;if(it=!e,it&&(e="\x3c!--\x3e"),"string"!=typeof e&&!bt(e)){if("function"!=typeof e.toString)throw N("toString is not a function");if("string"!=typeof(e=e.toString()))throw N("dirty is not a string, aborting")}if(!n.isSupported)return e;if(Pe||gt(t),n.removed=[],"string"==typeof e&&(Ye=!1),Ye){if(e.nodeName){const t=mt(e.nodeName);if(!be[t]||Le[t])throw N("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof u)o=Tt("\x3c!----\x3e"),i=o.ownerDocument.importNode(e,!0),i.nodeType===ne&&"BODY"===i.nodeName||"HTML"===i.nodeName?o=i:o.appendChild(i);else{if(!He&&!De&&!ze&&-1===e.indexOf("<"))return ee&&Be?ee.createHTML(e):e;if(o=Tt(e),!o)return He?null:Be?se:""}o&&Ue&&_t(o.firstChild);const c=At(Ye?e:o);for(;a=c.nextNode();)xt(a),Lt(a),a.content instanceof l&&Rt(a.content);if(Ye)return e;if(He){if(We)for(s=de.call(o.ownerDocument);o.firstChild;)s.appendChild(o.firstChild);else s=o;return(xe.shadowroot||xe.shadowrootmode)&&(s=pe.call(r,s,!0)),s}let d=ze?o.outerHTML:o.innerHTML;return ze&&be["!doctype"]&&o.ownerDocument&&o.ownerDocument.doctype&&o.ownerDocument.doctype.name&&x(Q,o.ownerDocument.doctype.name)&&(d="<!DOCTYPE "+o.ownerDocument.doctype.name+">\n"+d),De&&f([he,ge,ye],e=>{d=A(d,e," ")}),ee&&Be?ee.createHTML(d):d},n.setConfig=function(){gt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Pe=!0},n.clearConfig=function(){pt=null,Pe=!1},n.isValidAttribute=function(e,t,n){pt||gt({});const o=mt(e),i=mt(t);return Nt(o,i,n)},n.addHook=function(e,t){"function"==typeof t&&y(fe[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=h(fe[e],t);return-1===n?void 0:w(fe[e],n,1)[0]}return g(fe[e])},n.removeHooks=function(e){fe[e]=[]},n.removeAllHooks=function(){fe={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();function de(){if(null==se){var e=function(){var e=window.location;"about:srcdoc"==e.href&&(e=window.parent.location);var t={};return function(e,n,o){for(;o=n.exec(e);)t[decodeURIComponent(o[1])]=decodeURIComponent(o[2])}(e.search.substring(1).replace(/\+/g,"%20"),/([^&=]+)=?([^&]*)/g),t}();se="referrer"in e?/^https:\/\/medium.com\//.test(e.referrer):!("auto"in e)}return se}function me(e){var t=e||window.innerWidth;return t>999?650:t>599?575:400}function pe(e){if(e&&window.top!==window.self){var t=window;"srcdoc"==t.location.pathname&&(t=t.parent);var n={sender:"Flourish",method:"scrolly",captions:e.captions,hasScrollyTransformFix:e.hasScrollyTransformFix};t.parent.postMessage(JSON.stringify(n),"*")}}function fe(e,t){if(window.top!==window.self){var n=window;if("srcdoc"==n.location.pathname&&(n=n.parent),ce)return e=parseInt(e,10),void n.parent.postMessage({sentinel:"amp",type:"embed-size",height:e},"*");var o={sender:"Flourish",context:"iframe.resize",method:"resize",height:e,src:n.location.toString()};if(t)for(var i in t)o[i]=t[i];n.parent.postMessage(JSON.stringify(o),"*")}}function he(){return(-1!==navigator.userAgent.indexOf("Safari")||-1!==navigator.userAgent.indexOf("iPhone"))&&-1==navigator.userAgent.indexOf("Chrome")}function ge(e){return"string"==typeof e||e instanceof String}function ye(e){return"warn"!==e.method?(console.warn("BUG: validateWarnMessage called for method"+e.method),!1):!(null!=e.message&&!ge(e.message))&&!(null!=e.explanation&&!ge(e.explanation))}function we(e){return"resize"!==e.method?(console.warn("BUG: validateResizeMessage called for method"+e.method),!1):!!ge(e.src)&&(!!ge(e.context)&&!!("number"==typeof(t=e.height)?!isNaN(t)&&t>=0:ge(t)&&/\d/.test(t)&&/^[0-9]*(\.[0-9]*)?(cm|mm|Q|in|pc|pt|px|em|ex|ch|rem|lh|vw|vh|vmin|vmax|%)?$/i.test(t)));var t}function _e(e){throw new Error("Validation for setSetting is not implemented yet; see issue #4328")}function ve(e){return"scrolly"!==e.method?(console.warn("BUG: validateScrolly called for method"+e.method),!1):!!Array.isArray(e.captions)}function Te(e){return"customerAnalytics"===e.method||(console.warn("BUG: validateCustomerAnalyticsMessage called for method"+e.method),!1)}function Ae(e){return"request-upload"!==e.method?(console.warn("BUG: validateResizeMessage called for method"+e.method),!1):!!ge(e.name)&&!(null!=e.accept&&!ge(e.accept))}function Ee(e,t,n){var o=function(e){for(var t={warn:ye,resize:we,setSetting:_e,customerAnalytics:Te,"request-upload":Ae,scrolly:ve},n={},o=0;o<e.length;o++){var i=e[o];if(!t[i])throw new Error("No validator found for method "+i);n[i]=t[i]}return n}(t);window.addEventListener("message",function(t){var i=function(){if(t.origin==document.location.origin)return!0;if(n){const e=t.origin.toLowerCase();if(n=n.toLowerCase(),e.endsWith("//"+n))return!0;if(e.endsWith("."+n))return!0}return!!t.origin.match(/\/\/localhost:\d+$|\/\/(?:public|app)\.local\.flourish-internal\.com$|\/\/flourish-api\.com$|\.flourish\.(?:local(:\d+)?|net|rocks|studio)$|\.uri\.sh$|\/\/flourish-user-templates\.com$/)}();if(null!=t.source&&i){var r;try{r="object"==typeof t.data?t.data:JSON.parse(t.data)}catch(e){return void console.warn("Unexpected non-JSON message: "+JSON.stringify(t.data))}if("Flourish"===r.sender)if(r.method)if(Object.prototype.hasOwnProperty.call(o,r.method))if(o[r.method](r)){for(var a=document.querySelectorAll("iframe"),l=0;l<a.length;l++)if(a[l].contentWindow==t.source||a[l].contentWindow==t.source.parent)return void e(r,a[l]);console.warn("could not find frame",r)}else console.warn("Validation failed for the message",r);else console.warn("No validator implemented for message",r);else console.warn("The 'method' property was missing from message",r)}}),he()&&(window.addEventListener("resize",be),be())}function be(){for(var e=document.querySelectorAll(".flourish-embed"),t=0;t<e.length;t++){var n=e[t];if(!n.getAttribute("data-width")){var o=n.querySelector("iframe");if(o){var i=window.getComputedStyle(n),r=n.offsetWidth-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight);o.style.width=r+"px"}}}}function Se(e,t,n){var o=e.parentNode;if(o.classList.contains("fl-scrolly-wrapper"))return void console.warn("createScrolly is being called more than once per story. This should not happen.");o.classList.add("fl-scrolly-wrapper"),o.style.position="relative",o.style.paddingBottom="1px",o.style.transform="translate3d(0, 0, 0)";const i=navigator.platform.indexOf("Win")>-1,r=!!window.chrome&&(navigator.userAgent.indexOf("Chrome")>-1||navigator.userAgent.indexOf("Edg")>-1||navigator.userAgent.indexOf("OPR")>-1);if(i&&r&&n){let e,t=0;window.addEventListener("scroll",function(){clearTimeout(e),e=setTimeout(()=>{t=0===t?1:0,o.style.transform=`translateZ(${t}px)`},100)})}e.style.position="sticky";var a=o.getAttribute("data-height")||null;a||(a="80vh",e.style.height=a),e.style.top="calc(50vh - "+a+"/2)";var l=o.querySelector(".flourish-credit");l&&(l.style.position="sticky",l.style.top="calc(50vh + "+a+"/2)"),t.forEach(function(e,t){var n="string"==typeof e&&""!=e.trim(),i=document.createElement("div");i.setAttribute("data-slide",t),i.classList.add("fl-scrolly-caption"),i.style.position="relative",i.style.transform="translate3d(0,0,0)",i.style.textAlign="center",i.style.maxWidth="500px",i.style.height="auto",i.style.marginTop="0",i.style.marginBottom=n?"100vh":"50vh",i.style.marginLeft="auto",i.style.marginRight="auto";var r=document.createElement("div");r.innerHTML=ue.sanitize(e,{ADD_ATTR:["target"]}),r.style.visibility=n?"":"hidden",r.style.display="inline-block",r.style.paddingTop="1.25em",r.style.paddingRight="1.25em",r.style.paddingBottom="1.25em",r.style.paddingLeft="1.25em",r.style.background="rgba(255,255,255,0.9)",r.style.boxShadow="0px 0px 10px rgba(0,0,0,0.2)",r.style.borderRadius="10px",r.style.textAlign="center",r.style.maxWidth="100%",r.style.margin="0 20px",r.style.overflowX="hidden",i.appendChild(r),o.appendChild(i)}),function(e){for(var t=new IntersectionObserver(function(t){t.forEach(function(t){if(t.isIntersecting){var n=e.querySelector("iframe");n&&(n.src=n.src.replace(/#slide-.*/,"")+"#slide-"+t.target.getAttribute("data-slide"))}})},{rootMargin:"0px 0px -0% 0px"}),n=e.querySelectorAll(".fl-scrolly-caption"),o=0;o<n.length;o++)t.observe(n[o]);e.querySelectorAll(".fl-scrolly-caption img").forEach(function(e){e.style.maxWidth="100%"})}(o)}function xe(e,t,n,o,i){var r=document.createElement("iframe");if(r.setAttribute("scrolling","no"),r.setAttribute("frameborder","0"),r.setAttribute("title","Interactive or visual content"),r.setAttribute("sandbox","allow-same-origin allow-forms allow-scripts allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"),t.appendChild(r),r.offsetParent||"fixed"===getComputedStyle(r).position)Ne(e,t,r,n,o,i);else{var a={embed_url:e,container:t,iframe:r,width:n,height:o,play_on_load:i};if(window._flourish_poll_items?window._flourish_poll_items.push(a):window._flourish_poll_items=[a],window._flourish_poll_items.length>1)return r;var l=setInterval(function(){window._flourish_poll_items=window._flourish_poll_items.filter(function(e){return!e.iframe.offsetParent||(Ne(e.embed_url,e.container,e.iframe,e.width,e.height,e.play_on_load),!1)}),window._flourish_poll_items.length||clearInterval(l)},500)}return r}function Ne(e,t,n,o,i,r){var a;return o&&"number"==typeof o?(a=o,o+="px"):o&&o.match(/^[ \t\r\n\f]*([+-]?\d+|\d*\.\d+(?:[eE][+-]?\d+)?)(?:\\?[Pp]|\\0{0,4}[57]0(?:\r\n|[ \t\r\n\f])?)(?:\\?[Xx]|\\0{0,4}[57]8(?:\r\n|[ \t\r\n\f])?)[ \t\r\n\f]*$/)&&(a=parseFloat(o)),i&&"number"==typeof i&&(i+="px"),o?n.style.width=o:he()?n.style.width=t.offsetWidth+"px":n.style.width="100%",!!i||(e.match(/\?/)?e+="&auto=1":e+="?auto=1",i=me(a||n.offsetWidth)+"px"),i&&("%"===i.charAt(i.length-1)&&(i=parseFloat(i)/100*t.parentNode.offsetHeight+"px"),n.style.height=i),n.setAttribute("src",e+(r?"#play-on-load":"")),n.addEventListener("load",function(){try{n.contentWindow.postMessage({sender:"Flourish",method:"flourish:creditHandledExternally"},"*")}catch(e){console&&console.warn&&console.warn("Could not send credit postMessage:",e)}},{once:!0}),n}function Oe(e){return!Array.isArray(e)&&"object"==typeof e&&null!=e}function Le(e,t){for(const n in t)Oe(e[n])&&Oe(t[n])?Le(e[n],t[n]):e[n]=t[n];return e}!function(){var e,i=window.top===window.self,r=i?null:(ce="#amp=1"==window.location.hash,{createEmbedIframe:xe,isFixedHeight:de,getHeightForBreakpoint:me,startEventListeners:Ee,notifyParentWindow:fe,initScrolly:pe,createScrolly:Se,isSafari:he,initCustomerAnalytics:o,addAnalyticsListener:n,sendCustomerAnalyticsMessage:t}),a=!0;function l(){var t;Flourish.fixed_height||(null!=e?t=e:a&&(t=r.getHeightForBreakpoint()),t!==window.innerHeight&&r.notifyParentWindow(t))}function s(){-1!==window.location.search.indexOf("enable_customer_analytics=1")&&Flourish.enableCustomerAnalytics(),l(),window.addEventListener("resize",l)}Flourish.warn=function(e){if("string"==typeof e&&(e={message:e}),i||"editor"!==Flourish.environment)console.warn(e.message);else{var t={sender:"Flourish",method:"warn",message:e.message,explanation:e.explanation};window.parent.postMessage(JSON.stringify(t),"*")}},Flourish.uploadImage=function(e){if(i||"story_editor"!==Flourish.environment)throw"Invalid upload request";var t={sender:"Flourish",method:"request-upload",name:e.name,accept:e.accept};window.parent.postMessage(JSON.stringify(t),"*")},Flourish.setSetting=function(e,t){if("editor"===Flourish.environment||"sdk"===Flourish.environment){var n={sender:"Flourish",method:"setSetting",name:e,value:t};window.parent.postMessage(JSON.stringify(n),"*")}else if("story_editor"===Flourish.environment){var o={};o[e]=t,Le(window.template.state,function(e){var t=Object.create(null);for(var n in e){for(var o=t,i=n.indexOf("."),r=0;i>=0;i=n.indexOf(".",r=i+1)){var a=n.substring(r,i);a in o||(o[a]=Object.create(null)),o=o[a]}o[n.substring(r)]=e[n]}return t}(o))}},Flourish.setHeight=function(t){Flourish.fixed_height||(e=t,a=null==t,l())},Flourish.checkHeight=function(){if(!i){var e=Flourish.__container_height;null!=e?(Flourish.fixed_height=!0,r.notifyParentWindow(e)):r.isFixedHeight()?Flourish.fixed_height=!0:(Flourish.fixed_height=!1,l())}},Flourish.fixed_height=i||r.isFixedHeight(),Flourish.enableCustomerAnalytics=function(){r&&r.initCustomerAnalytics()},window.addEventListener("message",function(e){try{var t="object"==typeof e.data?e.data:JSON.parse(e.data)}catch(e){return}if("Flourish"===t.sender&&"flourish:creditHandledExternally"===t.method)for(var n=document.querySelectorAll(".flourish-credit"),o=0;o<n.length;o++)n[o].style.display="none"}),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",s):s()}()}();
//# sourceMappingURL=embedded.js.map