@behold/widget 0.5.55 → 0.5.57
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/ElasticCarousel-WWMTzi-V.js +1032 -0
- package/dist/ErrorMessage-tHLrPf_h.js +110 -0
- package/dist/GalleryWall-Jlau7S7U.js +354 -0
- package/dist/Grid-2Aag90e0.js +338 -0
- package/dist/PopoverGallery-pssVDO_O.js +1905 -0
- package/dist/Widget.d.ts.map +1 -1
- package/dist/base-GZO73SkY.js +1220 -0
- package/dist/caret-right-S2XSTDFy.js +5 -0
- package/dist/index-R4lEDZFo.js +985 -0
- package/dist/index.js +1 -1
- package/dist/resizeObserver-OlrW1x9X.js +454 -0
- package/package.json +1 -1
- package/dist/PopoverGallery-8G1aF271.js +0 -1
- package/dist/index-EcHlmDLY.js +0 -1
- package/dist/resizeObserver--rsjm-GV.js +0 -1
package/dist/index-EcHlmDLY.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
if("replaceChildren"in Element.prototype==0){function K(...t){for(;this.firstChild;)this.removeChild(this.firstChild);this.append(...t)}Object.defineProperty(Element.prototype,"beholdReplaceChildren",{configurable:!0,writable:!0,value:K}),Object.defineProperty(DocumentFragment.prototype,"beholdReplaceChildren",{configurable:!0,writable:!0,value:K})}else Object.defineProperty(Element.prototype,"beholdReplaceChildren",{configurable:!0,writable:!0,value:Element.prototype.replaceChildren}),Object.defineProperty(DocumentFragment.prototype,"beholdReplaceChildren",{configurable:!0,writable:!0,value:DocumentFragment.prototype.replaceChildren});function t(t){return JSON.parse(JSON.stringify(t,((t,e)=>void 0===e?null:e)))}function e(){return document.body.offsetTop}async function s(t,e){const s=document.createElement(t);return new Promise(((i,o)=>{switch(t){case"img":s.addEventListener("load",(()=>{i(e)}));break;case"video":s.addEventListener("loadeddata",(()=>i(e)))}s.addEventListener("error",(t=>{o(t)})),s.src=e}))}function i({text:t,maxLines:e=2,maxChars:s=50}){if(!t)return;const i=t.match(/.*/g).filter((t=>t.length>0)).slice(0,e).join("").length,o=Math.min(i,s);return t.slice(0,o)}function o(t,e){return`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' x='0px' y='0px' width='${t}' height='${e}'%3E%3C/svg%3E%0A`}function a(t){return new Promise((e=>{let s=new IntersectionObserver((t=>{let i=t.reduce(((t,e,s)=>e.intersectionRatio>t.intersectionRatio?{index:s,intersectionRatio:e.intersectionRatio}:t),{intersectionRatio:0,index:null});s.disconnect(),s=null,e(i.index)}));t.forEach((t=>s.observe(t)))}))}function h(t){return t.isConnected?"#document"===t.nodeName||t instanceof ShadowRoot?t:h(t.parentNode):document}function r(t,e,s=null,i=!1){let o=i?performance.now():0,a=null;return(...i)=>{let h=performance.now();clearTimeout(a),a=setTimeout((()=>t.apply(s,i)),e),h-o>e&&(clearTimeout(a),o=h,t.apply(s,i))}}function n(t,e){Object.entries(e).forEach((([e,s])=>{s?t.classList.add(e):t.classList.remove(e)}))}function l(t,e){Object.keys(e).forEach((s=>{t.style.setProperty(s,e[s])}))}function c(t,e,s,i=0){if("string"==typeof s&&(s=[s]),i>0){let i=!1;return Object.keys(t).length!==Object.keys(e).length||(Object.keys(t).forEach((o=>{c(t[o],e[o],s)&&(i=!0)})),i)}return s.reduce(((s,i)=>!d(t?.[i],e?.[i])||s),!1)}function d(t,e,s=!1,i=!1){if(i&&(Array.isArray(t)&&(t=t.sort()),Array.isArray(e)&&(e=e.sort())),s&&("number"==typeof t&&(t=t.toString()),"number"==typeof e&&(e=e.toString())),typeof t!=typeof e)return!1;if(null===t&&null===e)return!0;if(null===t&&null!==e)return!1;if(null!==t&&null===e)return!1;if(void 0===t&&void 0===e)return!0;if(void 0===t&&void 0!==e)return!1;if(void 0!==t&&void 0===e)return!1;if("object"==typeof t)return Object.keys(t).length===Object.keys(e).length&&Object.entries(t).reduce(((t,[o,a])=>!!d(a,e[o],s,i)&&t),!0);if(Array.isArray(t)){let o=!0;return t.forEach(((t,a)=>{d(t,e[a],s,i)||(o=!1)})),o}return t===e}function p(t,e="assertive"){const s=document.createElement("div");s.innerHTML=t,s.setAttribute("aria-live",e),s.setAttribute("aria-atomic","true"),s.style.cssText="\n position: absolute;\n position: absolute !important;\n width: 1px !important;\n height: 1px !important;\n padding: 0 !important;\n margin: -1px !important;\n overflow: hidden !important;\n clip: rect(0,0,0,0) !important;\n white-space: nowrap !important;\n border: 0 !important;\n ",requestAnimationFrame((()=>{document.body.appendChild(s),setTimeout((()=>{s.remove()}),500)}))}function u(t,e,s){t.length===s&&t.shift(),t.push(e)}let f={isMuted:!0,keyboardNavEnabled:!1,popoverOverlayHslArray:[0,0,0],popoverOverlayOpacity:.6},g=!1,b=null,m=null;const v=new Map,w=new Map,y=new Map,x=new Set;!function t(){y.forEach((t=>{const e=performance.now(),{minWait:s,lastInvocation:i,callback:o}=t,a=e-i;a>s&&(o(a),y.set(o,{...t,lastInvocation:e}))})),requestAnimationFrame(t)}();class k extends HTMLElement{label="BaseElement";storedProperties=new Map;requiredProperties=[];hasRequiredProps=!1;propChangeHandlers=new Map;delayedPropChangeHandlers=new Map;queuedPropUpdates=new Set;localState=Object.freeze({});localStateChangeHandlers=new Set;connectHandlers=new Set;disconnectHandlers=new Set;rafs=new Map;timeouts=new Map;constructor(){if(super(),this.t=this.t.bind(this),this.i=this.i.bind(this),this.o=this.o.bind(this),!b){let t=window.ResizeObserver;"ResizeObserver"in window==0&&(t=window.BeholdResizeObserver),b=new t((t=>{t.forEach((t=>{const e=v.get(t.target);e&&e(t)}))}))}m||(m=new IntersectionObserver((t=>{t.forEach((t=>{const e=w.get(t.target);e&&e(t)}))})))}connectedCallback(){g||(g=!0,document.addEventListener("keydown",this.t),document.addEventListener("mousedown",this.i),document.addEventListener("mousemove",this.o,{passive:!0})),this.connectHandlers.forEach((t=>t()))}disconnectedCallback(){g&&(g=!1,document.removeEventListener("keydown",this.t),document.removeEventListener("mousedown",this.i),document.removeEventListener("mousemove",this.o)),this.rafs.forEach((t=>cancelAnimationFrame(t))),this.rafs.clear(),this.timeouts.forEach((t=>clearTimeout(t))),this.timeouts.clear(),this.disconnectHandlers.forEach((t=>t()))}onConnect(t){this.connectHandlers.add(t)}onDisconnect(t){this.disconnectHandlers.add(t)}onResize(t,e,s){v.set(e,s.bind(t)),b.observe(e),this.disconnectHandlers.add((()=>{v.delete(e),b.unobserve(e)}))}onIntersection(t,e){w.set(t,e),m.observe(t),this.disconnectHandlers.add((()=>{w.delete(t),m.unobserve(t)}))}onLoop(t,e=50){y.set(t,{minWait:e,lastInvocation:0,callback:t}),this.disconnectHandlers.add((()=>{y.delete(t)}))}onPropChange(e,s,i=null,o=null){i?this.requiredProperties.push(...i):this.requiredProperties.push(...s),s.forEach((s=>{void 0!==this[s]&&this.storedProperties.set(s,this[s]),this.propChangeHandlers.get(s)||(this.propChangeHandlers.set(s,[]),this.delayedPropChangeHandlers.set(s,[])),o?this.delayedPropChangeHandlers.get(s).push(e):this.propChangeHandlers.get(s).push(e),Object.defineProperty(this,s,{set(e){void 0===e&&(e=null,console.warn(`Attempted to set value of ${s} as "undefined" on ${this.label}. ${s} was coerced to null instead.`)),e=t(e);const i=this.storedProperties.has(s)?t(this.storedProperties.get(s)):null;this.storedProperties.set(s,e),this.hasRequiredProps=this.requiredProperties.every((t=>this.storedProperties.has(t))),this.queueHandlers({prop:s,oldValue:i,newValue:e})},get(){return this.storedProperties.get(s)}})})),o&&(o=o.bind(this),queueMicrotask((()=>{this.hasRequiredProps&&(o(),this.delayedPropChangeHandlers.forEach(((t,e)=>{this.propChangeHandlers.set(e,[...this.propChangeHandlers.get(e),...t])})))}))),this.queueMissingPropsCheck()}queueHandlers({prop:t,oldValue:e,newValue:s}){this.hasRequiredProps?(this.queuedPropUpdates.size&&(this.queuedPropUpdates.delete(t),this.runQueuedPropHandlers()),this.propChangeHandlers.get(t).forEach((i=>{i.call(this,{changedProp:t,oldValue:e,newValue:s})}))):this.queuedPropUpdates.add(t)}runQueuedPropHandlers(){this.queuedPropUpdates.forEach((t=>{this.propChangeHandlers.get(t).forEach((e=>{e.call(this,{changedProp:t,oldValue:null,newValue:this[t]})}))})),this.queuedPropUpdates.clear()}updateLocalState(e){const s=Object.freeze(t(this.localState));this.localState=Object.freeze({...this.localState,...e}),this.localStateChangeHandlers.forEach((t=>t({changedProps:Object.keys(e),oldState:s,newState:this.localState})))}onLocalStateChange(t,e){this.localState={...this.localState,...e};const s=t.bind(this);this.localStateChangeHandlers.add(s)}updateGlobalState(e){const s=t(f);f={...f,...e},x.forEach((t=>t({changedProps:Object.keys(e),oldState:s,newState:f})))}onGlobalStateChange(t){this.connectHandlers.add((()=>{const e=t.bind(this);x.add(e),this.disconnectHandlers.add((()=>x.delete(e)))}))}t(t){"Tab"===t.key&&this.updateGlobalState({keyboardNavEnabled:!0})}i(t){0===t.clientX&&0===t.clientY||this.updateGlobalState({keyboardNavEnabled:!1})}o(t){t.ctrlKey||t.altKey||t.shiftKey||t.metaKey||0===t.movementX||0===t.movementY||this.updateGlobalState({keyboardNavEnabled:!1})}get globalState(){return f}set globalState(t){throw new Error("Shared state cannot be set directly. Use this.updateGlobalState() instead.")}raf(t,e,s=!0){s&&cancelAnimationFrame(this.rafs.get(e));const i=requestAnimationFrame((()=>{t(),this.rafs.delete(e)}));return this.rafs.set(e,i),i}cancelRaf(t){cancelAnimationFrame(this.rafs.get(t)),this.rafs.delete(t)}to(t,e,s){const i=setTimeout((()=>{t(),this.timeouts.delete(s)}),e);return this.timeouts.set(s,i),i}cancelTo(t){clearTimeout(this.timeouts.get(t)),this.timeouts.delete(t)}queueMissingPropsCheck(){queueMicrotask((()=>{if(this.requiredProperties.length&&!this.hasRequiredProps){const t=this.requiredProperties.filter((t=>!this.storedProperties.has(t)));console.error(`${this.label||this.tagName} is missing required props: ${t.join(", ")}`)}}))}}function z(t){let{type:e="div",classes:s=[],contents:i=[],attributes:o={},props:a={},style:h={},listeners:r={}}=t;s=Array.isArray(s)?s:[s];const n=document.createElement(e);return Array.isArray(i)||(i=[i]),i=i.filter((t=>null!=t)).map((t=>{if("string"==typeof t&&t.includes("</svg>")){const e=document.createElement("template");return e.innerHTML=t,e.content}return t})),n.beholdReplaceChildren(...i),s.length&&(n.className=s.join(" ")),Object.keys(o).forEach((t=>{null!==o[t]&&void 0!==o[t]?n.setAttribute(t,o[t]):n.removeAttribute(t)})),Object.assign(n,a),Object.keys(h).forEach((t=>{"--"===t.substring(0,2)?n.style.setProperty(t,h[t]):n.style[t]=h[t]})),Object.keys(r).forEach((t=>{n.addEventListener(t,r[t])})),n}function F(t){if(!t)return t;let[e,s,i]=t.split(",");e/=255,s/=255,i/=255;const o=Math.max(e,s,i),a=o-Math.min(e,s,i),h=a?o===e?(s-i)/a:o===s?2+(i-e)/a:4+(e-s)/a:0;return[60*h<0?60*h+360:60*h,100*(a?o<=.5?a/(2*o-a):a/(2-(2*o-a)):0),100*(2*o-a)/2]}function M(t,e){const s=(i=t,o="dominant",i.filter((t=>t[o])).map((t=>t[o]))).map((t=>F(t).join(",")));var i,o;return[C(P(s,0)),C(P(s,1)),C(P(s,2))]}function C(t){const e=[...t];e.sort((function(t,e){return t-e}));const s=Math.floor((e.length-1)/2);return e.length%2?e[s]:(e[s]+e[s+1])/2}function P(t,e){return t.map((t=>parseInt(t.split(",")[e])))}class _ extends k{label="BaseWidget";shadow;styleEl;contents;stylesAdded;constructor(){super(),this.shadow=this.attachShadow({mode:"open"}),this.handleKeydown=this.handleKeydown.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleFocusout=this.handleFocusout.bind(this),this.handleShadowFocusout=this.handleShadowFocusout.bind(this),this.onGlobalStateChange((()=>{n(this,{"keyboard-nav":this.globalState.keyboardNavEnabled})})),this.onConnect((()=>{this.styleEl=document.createElement("style"),n(this,{"keyboard-nav":this.globalState.keyboardNavEnabled}),this.addEventListener("focus",this.handleFocus),this.addEventListener("focusout",this.handleFocusout),this.shadow.addEventListener("focusout",this.handleShadowFocusout),this.addEventListener("keydown",this.handleKeydown)}))}focusPreviousPost(){this.dispatchEvent(new CustomEvent("post-focus-previous"))}focusNextPost(){this.dispatchEvent(new CustomEvent("post-focus-next"))}handleKeydown(t){"ArrowLeft"===t.key&&t.shiftKey&&this.focusPreviousPost(),"ArrowRight"===t.key&&t.shiftKey&&this.focusNextPost(),this.shadow.activeElement&&this.classList.remove("has-focus")}handleFocus(t){this.shadow.activeElement||this.classList.add("has-focus")}handleFocusout(){this.classList.remove("has-focus")}handleShadowFocusout(t){t.relatedTarget===this&&this.classList.add("has-focus")}renderWidget(t,e){this.stylesAdded&&this.contents?this.contents.replaceWith(t):(this.contents=t,this.styleEl.beholdReplaceChildren(...e.map((t=>t.toString()))),this.shadow.beholdReplaceChildren(this.contents,this.styleEl),this.stylesAdded=!0)}}function S(t){return t?`hsl(${t[0]}, ${t[1]}%, ${t[2]}%, ${Math.max(1*Math.random(),.3)})`:""}class E extends k{label="BasePost";post;widgetSettings;feedMetadata;medianPaletteHSL;hasRowGap=!1;isLastRow=!1;onClick;previewLoadingColors=null;aspectRatio;index;totalPosts;h;l;constructor(){super(),this.onPropChange(this.p,["post","widgetSettings","feedMetadata","medianPaletteHSL","hasRowGap","isLastRow","previewLoadingColors","aspectRatio","index","totalPosts"],["post","widgetSettings","feedMetadata","medianPaletteHSL","index","totalPosts"]),this.u=this.u.bind(this),this.onConnect((()=>{this.onResize(this,this,this.m)}))}p({changedProp:t,oldValue:e,newValue:s}){switch(t){case"post":c(s,e,["colorPalette"])&&this.v();break;case"widgetSettings":c(s,e,["loadingColor","loadingColorTone"])&&this.v(),this.h&&c(s,e,["linkTarget"])&&s?.onPostClick?.toLowerCase().includes("link")&&this.h.setAttribute("target",s.linkTarget),this.h&&c(s,e,["customLinkURL"])&&"customLink"===s.onPostClick&&this.h.setAttribute("href",s.customLinkURL),c(s,e,["hoverOverlayColor","hoverOverlayCustomColor","hoverOverlayOpacity"])&&this.k(),this.F();break;case"previewLoadingColors":this.v();break;case"hasRowGap":case"isLastRow":this.F()}}k(){let t="rgba(0, 0, 0, 0.3)",e=this.widgetSettings.hoverOverlayCustomColor??"0,0,0",s=this.widgetSettings.hoverOverlayOpacity??65;if("auto"===this.widgetSettings.hoverOverlayColor){const e=F(this.post.colorPalette?.dominant||"100,100,100").map((t=>Math.round(t)));t=`hsl(${e[0]} ${Math.min(e[1],50)}% ${Math.min(e[2],40)}% / ${s/100})`}if("custom"===this.widgetSettings.hoverOverlayColor){const i=e.split(",");t=`hsl(${i[0]} ${i[1]}% ${i[2]}% / ${s/100})`}l(this,{"--overlay-color":t})}F(){n(this,{post:!0,"post--hover-icon":"showIcon"===this.widgetSettings.onHover,"post--hover-caption":"showCaption"===this.widgetSettings.onHover,"post--has-row-gap":this.hasRowGap,"post--last-row":this.isLastRow}),this.k()}renderPost(t){let e="div",s=this.post.permalink;this.F(),"linkToProfile"===this.widgetSettings.onPostClick&&this.feedMetadata.username&&(s=`https://instagram.com/${this.feedMetadata.username}`),"customLink"===this.widgetSettings.onPostClick&&this.widgetSettings.customLinkURL&&(s=this.widgetSettings?.customLinkURL),this.widgetSettings.onPostClick.toLowerCase().includes("link")&&(e="a"),this.widgetSettings.onPostClick.toLowerCase().includes("popup")&&(e="button");let i=null;if("showCaption"===this.widgetSettings.onHover){const t=z({contents:this.post.prunedCaption?.length?this.post.prunedCaption:this.post.caption,classes:"post-caption__inner"});i=z({contents:t,classes:"post-caption"})}let o="image";switch(this.post?.mediaType){case"VIDEO":o=this.post.isReel?"reel":"video";break;case"CAROUSEL_ALBUM":o="album";break;default:o="image"}this.h=z({type:e,contents:[t,i||""],attributes:{draggable:"false","aria-label":`${o}, post ${this.index+1} of ${this.totalPosts}`,tabindex:-1,..."a"===e?{href:s,target:this.widgetSettings.linkTarget}:{}},listeners:{..."button"===e?{click:this.u}:{}}}),this.beholdReplaceChildren(this.h)}v(){const t=this.previewLoadingColors??this.widgetSettings.loadingColor;this.style.backgroundColor=function(t,e,s,i){let o="";switch(t){case"dominant":case"vibrant":case"muted":case"vibrantLight":case"mutedLight":case"vibrantDark":case"mutedDark":o=e?`rgb(${e[t]})`:S(i);break;case"tone":if(s){const t=s.split(",");if(e){const s=(a=F(e.dominant)[2]-i[2],Math.log(Math.abs(a))/Math.log(1.6)*Math.sign(a));o=`hsl(${t[0]},${t[1]}%,${parseInt(t[2])+s}%)`}else o=`hsl(${t[0]},${t[1]}%,${t[2]}%, ${Math.max(1*Math.random(),.3)})`}else o=S(i)}var a;return o}(t,this.post.colorPalette,this.widgetSettings.loadingColorTone,this.medianPaletteHSL)}m(t){const e=t?.borderBoxSize?.[0]?.inlineSize||t?.contentRect?.width||0;l(this,{"--post-width":e+"px","--post-height":(t?.borderBoxSize?.[0]?.blockSize||t?.contentRect?.height||0)+"px"});let s="xlarge";e<600&&(s="large"),e<400&&(s="medium"),e<250&&(s="small"),e<175&&(s="xsmall"),["xsmall","small","medium","large","xlarge"].forEach((t=>{n(this,{[`post--${t}`]:t===s})}))}u(){this.onClick&&this.onClick(this)}focus(){this.h.focus()}}class G extends k{label="Image";sizes;mediaUrl;aspectRatio;showLoader=!1;M;C;P={isLoaded:!1,isVisible:!1,didError:!1,shouldPreload:!1,loaderIsShowing:!1,imageSrc:null,sizeObj:null};_;constructor(){super(),this.onPropChange(this.S,["sizes","mediaUrl","aspectRatio","showLoader"],["sizes","mediaUrl","aspectRatio"]),this.onLocalStateChange(this.G,this.P),this.R=this.R.bind(this),this.L=this.L.bind(this),this.$=this.$.bind(this),this._=r(this.m,50,this),this.preload=this.preload.bind(this),this.onConnect((()=>{const t=this.aspectRatio?300:this.sizes?.full.height??300,s=this.aspectRatio?300*this.aspectRatio:this.sizes?.full.width??300;this.style.aspectRatio=this.aspectRatio?`${this.aspectRatio}`:`${s}/${t}`;let i=this.sizes?.full.height?o(s,t):this.mediaUrl??o(s,t);this.M=z({type:"img",attributes:{alt:"",role:"presentation",height:t+"px",width:s+"px",tabindex:-1,src:i,draggable:"false"},listeners:{load:this.L,error:this.$}}),this.showLoader?(this.C=z({classes:"ldr"}),this.beholdReplaceChildren(this.C,this.M)):this.beholdReplaceChildren(this.M),e(),this.raf((()=>{this.onResize(this,this,this._),this.onIntersection(this,this.R)}),"connect")})),this.onDisconnect((()=>{this.updateLocalState({isVisible:!1,isLoaded:!1}),this.M&&(this.M.removeEventListener("load",this.L),this.M.removeEventListener("error",this.$))}))}S({changedProp:t,oldValue:e,newValue:s}){switch(t){case"showLoader":!e&&s&&this.M&&(this.C=z({classes:"ldr"}),this.beholdReplaceChildren(this.C,this.M));break;case"sizes":if(d(e,s))return;this.updateLocalState({isLoaded:!1,sizeObj:this.M?.isConnected?this.j(this.offsetWidth,this.offsetHeight):null})}}G({changedProps:t,newState:e}){if(t.includes("loaderIsShowing")&&this.C&&n(this.C,{"ldr--visible":e.loaderIsShowing&&!e.isLoaded}),t.includes("imageSrc")&&this.M&&(e.isVisible||e.shouldPreload)&&e.imageSrc!==this.M.src&&(this.M.src=e.imageSrc),t.includes("sizeObj")&&!e.didError){const t=this.mediaUrl;this.updateLocalState({imageSrc:e.sizeObj?.mediaUrl??t})}}R(t){t.isIntersecting?(this.updateLocalState({isVisible:!0}),!this.localState.isLoaded&&this.showLoader&&this.to((()=>{this.updateLocalState({loaderIsShowing:!0})}),50,"loader"),this.localState.imageSrc&&this.M.src!==this.localState.imageSrc&&(this.M.src=this.localState.imageSrc)):this.updateLocalState({isVisible:!1})}m(t){let e=t.borderBoxSize?t.borderBoxSize[0].inlineSize:t.contentRect.width||0,s=t.borderBoxSize?t.borderBoxSize[0].blockSize:t.contentRect.height||0;const i=this.j(e,s);(!this.localState.sizeObj?.width||this.localState.sizeObj?.width<i?.width||this.localState.sizeObj?.height<i?.height)&&this.updateLocalState({sizeObj:i})}L(){this.M.src!==this.localState.imageSrc&&!this.localState.shouldPreload&&this.sizes?.full.height||(this.cancelTo("loader"),this.updateLocalState({isLoaded:!0,loaderIsShowing:!1}),this.dispatchEvent(new Event("load")),this.classList.add("is-loaded"))}$(){this.localState.imageSrc===this.mediaUrl||this.localState.didError||(this.updateLocalState({didError:!0}),this.updateLocalState({imageSrc:this.mediaUrl}))}j(t,e){if(this.sizes)return this.sizes?Object.values(this.sizes).reduce((function(s,i){return Math.abs(i.width/2-t)<Math.abs(s.width/2-t)||Math.abs(i.height/2-e)<Math.abs(s.height/2-e)?i:s})):null}preload(){this.localState.isLoaded||(this.localState.imageSrc&&this.localState.sizeObj&&this.M.src!==this.localState.imageSrc?this.M.src=this.localState.imageSrc:this.updateLocalState({shouldPreload:!0}))}static register(t="behold-image"){return customElements.get(t)||customElements.define(t,G),t}}class R extends E{label="ImagePost";M;constructor(){super(),G.register(),this.onPropChange(this.S,["post","widgetSettings","aspectRatio"],null,this.O)}S({changedProp:t,oldValue:e,newValue:s}){switch(t){case"widgetSettings":c(s,e,["onHover","onPostClick"])&&this.O();break;case"post":case"aspectRatio":this.O()}}O(){const{sizes:t,mediaUrl:e}=this.post;this.M=z({type:"behold-image",props:{sizes:t,mediaUrl:e,aspectRatio:this.aspectRatio.reduce(((t,e)=>t/e))}}),this.renderPost(this.M)}static register(t="behold-image-post"){return customElements.get(t)||customElements.define(t,R),t}}class L extends k{label="Video";mediaUrl;sizes;autoplay;aspectRatio;renderPlaceholder;V;B;I;M;constructor(){super(),this.V=this.autoplay||!1,this.B=!1,this.R=this.R.bind(this),this.T=this.T.bind(this),this.H=this.H.bind(this),this.A=this.A.bind(this),this.U=this.U.bind(this),this.preload=this.preload.bind(this),document.addEventListener("visibilitychange",this.H),this.onLoop((async()=>{if(this.I&&this.isLoaded){if(!this.B&&this.V&&!this.W)try{this.B=!0,await this.I.play(),this.B=!1}catch(t){this.B=!1}!this.V&&this.W&&(this.I.pause(),this.B=!1)}}),15),this.onPropChange((({changedProp:t,newValue:e})=>{this.localState.shouldPreload&&this.mediaUrl&&s("video",this.mediaUrl),"autoplay"===t&&(e?this.play():this.pause())}),["mediaUrl","sizes","autoplay","aspectRatio","renderPlaceholder"],["mediaUrl","sizes","renderPlaceholder"]),this.onLocalStateChange((()=>{}),{isMuted:!0,isLoaded:!1,shouldPreload:!1}),this.onConnect((()=>{this.onIntersection(this,this.R),this.render()})),this.onDisconnect((()=>{document.removeEventListener("visibilitychange",this.H),this.I&&(this.I.removeEventListener("play",this.A),this.I.removeEventListener("pause",this.U),this.I.removeEventListener("loadeddata",this.T))}))}get isPlaying(){return this.V||!1}get W(){return!!(this.I.currentTime>0&&!this.I.paused&&!this.I.ended&&this.I.readyState>2)}get paused(){return this.I?.paused}get muted(){return this.I?.muted}get isLoaded(){return this.localState.isLoaded}render(){this.I=z({type:"video",attributes:{loop:!0,playsinline:!0,crossorigin:"anonymous",tabIndex:-1,disablePictureInPicture:!0,disableremoteplayback:!0,height:this.sizes?.full.height||100,width:this.sizes?.full.width||100},props:{muted:this.localState.isMuted,autoplay:this.autoplay||!1},listeners:{play:this.A,pause:this.U}}),this.renderPlaceholder&&(this.M=z({type:"img",attributes:{height:this.sizes.full.height,width:this.sizes.full.width,src:o(this.sizes.full.width,this.sizes.full.height)}}),this.beholdReplaceChildren(this.M))}R(t){t.isIntersecting&&this.I?this.I.src!==this.mediaUrl&&(this.I.addEventListener("loadeddata",this.T,{once:!0}),this.I.src=this.mediaUrl,this.I.load()):this.autoplay||this.pause()}T(){this.updateLocalState({isLoaded:!0}),this.autoplay||(this.I.currentTime=.25,this.I.pause()),this.dispatchEvent(new Event("load")),this.beholdReplaceChildren(this.I),e(),this.raf((()=>{this.classList.add("is-loaded")}),"_handleVideoLoad")}A(){this.dispatchEvent(new Event("play"))}U(){this.dispatchEvent(new Event("pause"))}play(){this.V=!0}pause(){this.V=!1}mute(){this.updateLocalState({isMuted:!0}),this.I&&(this.I.muted=!0)}unmute(){this.updateLocalState({isMuted:!1}),this.I&&(this.I.muted=!1)}H(){document.hidden&&(this.pause(),this.I&&this.I.pause()),!document.hidden&&this.autoplay&&this.play()}preload(){!this.localState.isLoaded&&this.mediaUrl?s("video",this.mediaUrl):this.updateLocalState({shouldPreload:!0})}static register(t="behold-video"){return customElements.get(t)||customElements.define(t,L),t}}class $ extends E{label="VideoPost";I;M;constructor(){super(),this.onPropChange(this.S,["post","widgetSettings","aspectRatio"],null,this.O),L.register(),G.register(),this.q=this.q.bind(this),this.D=this.D.bind(this),this.onDisconnect((()=>{this.removeEventListener("mouseover",this.q),this.removeEventListener("mouseleave",this.D)}))}S({changedProp:t,oldValue:e,newValue:s}){switch(t){case"widgetSettings":c(e,s,["onHover","onPostClick","previewVideosOnHover"])&&this.O(),c(e,s,["autoplayVideos"])&&(this.widgetSettings.previewVideosOnHover?this.I.autoplay=s.autoplayVideos:this.O());break;case"post":case"aspectRatio":this.O()}}q(){this.I?.play()}D(){this.widgetSettings.autoplayVideos||this.I?.pause()}O(){const{sizes:t,mediaUrl:e,thumbnailUrl:s}=this.post;(this.widgetSettings.previewVideosOnHover||this.widgetSettings.autoplayVideos)&&e||!t.full.mediaUrl&&!s&&e?(this.I=z({type:"behold-video",props:{mediaUrl:e,sizes:t,autoplay:this.widgetSettings.autoplayVideos,aspectRatio:this.aspectRatio.reduce(((t,e)=>t/e)),renderPlaceholder:!1},listeners:{mouseover:this.q,mouseleave:this.D}}),this.renderPost(this.I)):(this.M=z({type:"behold-image",props:{sizes:t,mediaUrl:s,aspectRatio:this.aspectRatio.reduce(((t,e)=>t/e))}}),this.renderPost(this.M))}static register(t="behold-video-post"){return customElements.get(t)||customElements.define(t,$),t}}class j extends E{label="AlbumPost";N;constructor(){super(),G.register(),L.register(),this.onPropChange(this.S,["post","widgetSettings"],null,this.O)}S({changedProp:t,oldValue:e,newValue:s}){switch(t){case"widgetSettings":c(s,e,["onHover","onPostClick"])&&this.O();break;case"post":case"aspectRatio":this.O()}}O(){let{sizes:t,mediaUrl:e,children:s}=this.post;if(!t.full.mediaUrl&&!e){const i=s.reduce(((t,e)=>"VIDEO"===e.mediaType?e.sizes.full.mediaUrl||e.thumbnailUrl?e:t:e.sizes.full.mediaUrl||e.mediaUrl?e:t));t=i.sizes,e=i.thumbnailUrl??i.mediaUrl}this.post.mediaUrlIsVideo?this.N=z({type:"behold-video",props:{sizes:t,mediaUrl:e,aspectRatio:this.aspectRatio.reduce(((t,e)=>t/e)),renderPlaceholder:!1}}):this.N=z({type:"behold-image",props:{sizes:t,mediaUrl:e,aspectRatio:this.aspectRatio.reduce(((t,e)=>t/e))}}),this.renderPost(this.N)}static register(t="behold-album-post"){return customElements.get(t)||customElements.define(t,j),t}}var O=":host{--post-border-radius:0;--post-aspect-ratio:1;--icon-instagram:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 35 35' xml:space='preserve'%3E%3Cpath fill='%23FFF' d='M17.6 3.2c4.7 0 5.2 0 7.1.1 1.7.1 2.6.4 3.2.6.8.3 1.4.7 2 1.3.6.6 1 1.2 1.3 2 .2.6.5 1.5.6 3.3.1 1.8.1 2.4.1 7.1s0 5.2-.1 7.1c-.1 1.7-.4 2.6-.6 3.2-.6 1.5-1.8 2.7-3.3 3.3-.6.2-1.5.5-3.2.6-1.8.1-2.4.1-7.1.1s-5.2 0-7.1-.1c-1.7-.1-2.6-.4-3.2-.6-.8-.3-1.4-.7-2-1.3-.6-.6-1-1.2-1.3-2-.2-.6-.5-1.5-.6-3.2-.1-1.8-.1-2.4-.1-7.1s0-5.2.1-7.1c0-1.8.3-2.7.6-3.3.3-.8.7-1.4 1.3-2 .6-.6 1.2-1 2-1.3.6-.2 1.5-.5 3.2-.6 1.9-.1 2.4-.1 7.1-.1m0-3.2c-4.8 0-5.3 0-7.2.1-1.9.1-3.2.4-4.3.8C5 1.4 3.9 2 3 2.9c-.9.9-1.5 2-2 3.1C.6 7.1.3 8.4.2 10.2c-.1 1.9-.1 2.5-.1 7.2s0 5.3.1 7.2c.1 2 .4 3.2.8 4.4.4 1.2 1.1 2.2 2 3.1.9.9 1.9 1.6 3.1 2 1.1.4 2.4.7 4.2.8s2.5.1 7.2.1 5.3 0 7.2-.1c1.9-.1 3.1-.4 4.2-.8 2.3-.9 4.2-2.8 5.1-5.1.4-1.1.7-2.4.8-4.2.1-1.9.1-2.5.1-7.2s0-5.3-.1-7.2c-.1-1.9-.4-3.1-.8-4.2-.4-1.2-1.1-2.2-2-3.1-.9-.9-1.9-1.6-3.1-2-1.1-.4-2.4-.7-4.2-.8-1.8-.3-2.4-.3-7.1-.3z'/%3E%3Cpath fill='%23FFF' d='M17.6 8.5c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 14.8c-3.2 0-5.8-2.6-5.8-5.8s2.6-5.8 5.8-5.8 5.8 2.6 5.8 5.8-2.6 5.8-5.8 5.8z'/%3E%3Ccircle fill='%23FFF' cx='26.9' cy='8.2' r='2.1'/%3E%3C/svg%3E\");--icon-video:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 35 35' xml:space='preserve'%3E%3Cpath fill='%23FFF' d='M30.1 15.5 7.2 2.3c-1.5-.9-3.5.2-3.5 1.9v26.5c0 1.7 1.9 2.9 3.4 1.9L30 19.4c1.7-.8 1.7-3 .1-3.9z'/%3E%3C/svg%3E\");--icon-album:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 35 35' xml:space='preserve'%3E%3Cpath fill='%23FFF' d='M27.3 22.7v-17c0-2.6-2.1-4.7-4.7-4.7H5.7C3.1 1 1 3.1 1 5.7v17c0 2.6 2.1 4.7 4.7 4.7h17c2.5-.1 4.6-2.2 4.6-4.7zm4-13.4v14.6c0 4.1-3.4 7.4-7.4 7.4H9.2c-.5 0-.8.6-.5 1 .9 1 2.2 1.6 3.7 1.6h12.1c5.2 0 9.3-4.2 9.3-9.3V12.5c0-1.5-.6-2.8-1.6-3.7-.3-.4-.9 0-.9.5z'/%3E%3C/svg%3E\");align-items:center;border:none;box-shadow:none;box-sizing:border-box;display:flex;flex-wrap:wrap;justify-content:center;margin:0;min-width:50px;outline:none;position:relative;width:100%}:host *{box-sizing:border-box}:host(.keyboard-nav.has-focus){outline:none}:host(.keyboard-nav.has-focus):before{background-color:rgba(0,0,0,.25);border-radius:6px;content:\"\";display:block;height:100%;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:100%;z-index:1}:host(.keyboard-nav.has-focus):after{background-color:#222;border-radius:6px;box-shadow:0 0 0 2px #4169e1,0 0 0 3px #fff,0 .6px .4px rgba(0,0,0,.042),0 1.3px 1px rgba(0,0,0,.061),0 2.5px 1.9px rgba(0,0,0,.075),0 4.5px 3.4px rgba(0,0,0,.089),0 8.4px 6.3px rgba(0,0,0,.108),0 20px 15px rgba(0,0,0,.15);color:#fff;content:\"Shift + arrow keys to navigate posts\";font-family:sans-serif;font-size:16px;max-width:80%;padding:15px;position:absolute;text-align:center;z-index:1}@media (max-width:1300px){:host(.keyboard-nav.has-focus):after{font-size:15px}}:host(.keyboard-nav.has-focus) .posts{opacity:.65}.posts{display:grid;margin:0;max-width:100%;padding:0;width:100%}.post{-webkit-font-smoothing:inherit;-moz-osx-font-smoothing:inherit;align-self:stretch;border:none;border-radius:var(--post-border-radius) /calc(var(--post-border-radius)*var(--post-aspect-ratio));color:inherit;font:inherit;isolation:isolate;line-height:normal;margin:0 0 -1px;overflow:hidden;transform:translateZ(0);transition:background .3s ease;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:calc(100% + .5px)}:host(.keyboard-nav) .post.post:focus-within{box-shadow:0 0 0 1px #fff,0 0 0 3px #4169e1,0 0 0 4px #fff;z-index:1}:host(.is-previewing-loading-colors) .post *{opacity:0}.post.post--has-row-gap,.post.post--last-row{margin:0}.post:before{background-color:transparent;border-radius:var(--post-border-radius) /calc(var(--post-border-radius)*var(--post-aspect-ratio));content:\"\";height:100%;left:0;pointer-events:none;position:absolute;top:0;transition:all 2s cubic-bezier(.215,.61,.355,1);width:100%;z-index:2}@supports ((-webkit-backdrop-filter:blur(3px)) or (backdrop-filter:blur(3px))){[data-hover-effect*=blur i] .post:before{height:calc(100% - 1px);left:0;opacity:0;top:0;transition:all .6s cubic-bezier(.215,.61,.355,1);width:100%}}.post.post--hover-icon:after{background-image:var(--icon);background-position:50%;background-repeat:no-repeat;background-size:auto 100%;border-radius:var(--post-border-radius) /calc(var(--post-border-radius)*var(--post-aspect-ratio));content:\"\";height:12%;height:calc(min(var(--post-width), var(--post-height))*.12);left:0;max-height:30px;min-height:20px;opacity:0;pointer-events:none;position:absolute;top:50%;transform:translateY(-50%) scale(.75);transition:all .6s cubic-bezier(.215,.61,.355,1);width:100%;will-change:transform;z-index:3}@media (prefers-reduced-motion){.post.post--hover-icon:after{transition:none}}.post behold-album,.post behold-image,.post behold-video{height:100%;width:100%}.post>a,.post>button,.post>div{background-color:transparent;border:0;box-shadow:none;color:inherit;display:block;font:inherit;height:100%;line-height:inherit;outline:none;padding:0;transition:opacity .3s ease;width:100%}.post a,.post button{cursor:pointer}behold-image-post{--icon:var(--icon-instagram)}behold-video-post{--icon:var(--icon-video)}behold-album-post{--icon:var(--icon-album)}.post-caption{align-items:center;background-color:var(--overlay-color);display:flex;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;font-size:15px;height:100%;justify-content:center;left:0;line-height:1.5;opacity:0;padding:15%;pointer-events:none;position:absolute;top:0;transition:opacity .4s ease;width:100%;z-index:2}.post:hover .post-caption,:host(:host(.keyboard-nav)) .post:focus-within .post-caption{opacity:1}.post--xlarge .post-caption{--lines:12;--innerScale:scale(0.98);padding:20%}.post--large .post-caption{--lines:9;--innerScale:scale(0.98)}.post--medium .post-caption{--lines:6;--innerScale:scale(0.97);font-size:14px}.post--small .post-caption{--lines:4;--innerScale:scale(0.95);font-size:13px;line-height:1.25}.post--xsmall .post-caption{--lines:3;--innerScale:scale(0.95);font-size:12px;line-height:1.25}.post-caption__inner{-webkit-line-clamp:var(--lines);-webkit-box-orient:vertical;color:#fff;display:-webkit-box;opacity:0;overflow:hidden;text-align:center;transform:var(--innerScale);transition:all .3s ease;white-space:pre-line;will-change:transform,opacity;word-break:none}@media (prefers-reduced-motion){.post-caption__inner{transform:none}}.post:hover .post-caption__inner,:host(.keyboard-nav) .post:focus-within .post-caption__inner{opacity:1;transform:none;transition:all .3s ease}:host(.keyboard-nav) .post:focus-within:before{background-color:var(--overlay-color);transition:all .6s cubic-bezier(.215,.61,.355,1)}:host(.keyboard-nav) .post:focus-within:after{opacity:1;transform:translateY(-50%)}:host(.keyboard-nav) [data-hover-effect=fade] .post:focus-within:before,[data-hover-effect=fade] .post:hover:before{background-color:var(--overlay-color);transition:all .6s cubic-bezier(.215,.61,.355,1)}:host(.keyboard-nav) [data-hover-effect=fade] .post:focus-within:after,[data-hover-effect=fade] .post:hover:after{opacity:1;transform:translateY(-50%)}:host(.keyboard-nav) [data-hover-effect=zoomFade] .post:focus-within behold-image img,:host(.keyboard-nav) [data-hover-effect=zoomFade] .post:focus-within behold-video video,[data-hover-effect=zoomFade] .post:hover behold-image img,[data-hover-effect=zoomFade] .post:hover behold-video video{transform:scale(1.05)}@media (prefers-reduced-motion){:host(.keyboard-nav) [data-hover-effect=zoomFade] .post:focus-within behold-image img,:host(.keyboard-nav) [data-hover-effect=zoomFade] .post:focus-within behold-video video,[data-hover-effect=zoomFade] .post:hover behold-image img,[data-hover-effect=zoomFade] .post:hover behold-video video{transform:none}}:host(.keyboard-nav) [data-hover-effect=zoomFade] .post:focus-within:before,[data-hover-effect=zoomFade] .post:hover:before{background-color:var(--overlay-color);transition:all .6s cubic-bezier(.215,.61,.355,1)}:host(.keyboard-nav) [data-hover-effect=zoomFade] .post:focus-within:after,[data-hover-effect=zoomFade] .post:hover:after{opacity:1;transform:translateY(-50%)}@supports not ((-webkit-backdrop-filter:blur(3px)) or (backdrop-filter:blur(3px))){:host(.keyboard-nav) [data-hover-effect=blur] .post:focus-within behold-image,:host(.keyboard-nav) [data-hover-effect=blur] .post:focus-within behold-video,[data-hover-effect=blur] .post:hover behold-image,[data-hover-effect=blur] .post:hover behold-video{filter:brightness(97%) blur(3px);transition:all .6s cubic-bezier(.215,.61,.355,1)}}@supports ((-webkit-backdrop-filter:blur(3px)) or (backdrop-filter:blur(3px))){:host(.keyboard-nav) [data-hover-effect=blur] .post:focus-within:before,[data-hover-effect=blur] .post:hover:before{-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);background-color:rgba(0,0,0,.002);opacity:1}}:host(.keyboard-nav) [data-hover-effect=blur] .post:focus-within:after,[data-hover-effect=blur] .post:hover:after{opacity:1;transform:translateY(-50%)}:host(.keyboard-nav) [data-hover-effect=zoomBlur] .post:focus-within behold-image,:host(.keyboard-nav) [data-hover-effect=zoomBlur] .post:focus-within behold-video,[data-hover-effect=zoomBlur] .post:hover behold-image,[data-hover-effect=zoomBlur] .post:hover behold-video{transform:scale(1.05);transition:all .6s cubic-bezier(.215,.61,.355,1)}@media (prefers-reduced-motion){:host(.keyboard-nav) [data-hover-effect=zoomBlur] .post:focus-within behold-image,:host(.keyboard-nav) [data-hover-effect=zoomBlur] .post:focus-within behold-video,[data-hover-effect=zoomBlur] .post:hover behold-image,[data-hover-effect=zoomBlur] .post:hover behold-video{transform:none}}@supports not ((-webkit-backdrop-filter:blur(3px)) or (backdrop-filter:blur(3px))){:host(.keyboard-nav) [data-hover-effect=zoomBlur] .post:focus-within behold-image,:host(.keyboard-nav) [data-hover-effect=zoomBlur] .post:focus-within behold-video,[data-hover-effect=zoomBlur] .post:hover behold-image,[data-hover-effect=zoomBlur] .post:hover behold-video{filter:brightness(97%) blur(3px)}}@supports ((-webkit-backdrop-filter:blur(3px)) or (backdrop-filter:blur(3px))){:host(.keyboard-nav) [data-hover-effect=zoomBlur] .post:focus-within:before,[data-hover-effect=zoomBlur] .post:hover:before{-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);background-color:rgba(0,0,0,.002);opacity:1}}:host(.keyboard-nav) [data-hover-effect=zoomBlur] .post:focus-within:after,[data-hover-effect=zoomBlur] .post:hover:after{opacity:1;transform:translateY(-50%)}:host(.keyboard-nav) [data-hover-effect=toGreyscale] .post:focus-within behold-image,:host(.keyboard-nav) [data-hover-effect=toGreyscale] .post:focus-within behold-video,[data-hover-effect=toGreyscale] .post:hover behold-image,[data-hover-effect=toGreyscale] .post:hover behold-video{filter:grayscale(100%);transition:all .6s cubic-bezier(.215,.61,.355,1)}:host(.keyboard-nav) [data-hover-effect=toGreyscale] .post:focus-within:after,[data-hover-effect=toGreyscale] .post:hover:after{opacity:1;transform:translateY(-50%)}:host(.keyboard-nav) [data-hover-effect=zoomToGreyscale] .post:focus-within behold-image,:host(.keyboard-nav) [data-hover-effect=zoomToGreyscale] .post:focus-within behold-video,[data-hover-effect=zoomToGreyscale] .post:hover behold-image,[data-hover-effect=zoomToGreyscale] .post:hover behold-video{filter:grayscale(100%);transform:scale(1.05);transition:all .6s cubic-bezier(.215,.61,.355,1)}@media (prefers-reduced-motion){:host(.keyboard-nav) [data-hover-effect=zoomToGreyscale] .post:focus-within behold-image,:host(.keyboard-nav) [data-hover-effect=zoomToGreyscale] .post:focus-within behold-video,[data-hover-effect=zoomToGreyscale] .post:hover behold-image,[data-hover-effect=zoomToGreyscale] .post:hover behold-video{transform:none}}:host(.keyboard-nav) [data-hover-effect=zoomToGreyscale] .post:focus-within:after,[data-hover-effect=zoomToGreyscale] .post:hover:after{opacity:1;transform:translateY(-50%)}:host(.keyboard-nav) [data-hover-effect=fromGreyscale] .post,[data-hover-effect=fromGreyscale] .post{filter:grayscale(100%)}:host(.keyboard-nav) [data-hover-effect=fromGreyscale] .post:focus,:host(.keyboard-nav) [data-hover-effect=fromGreyscale] .post:hover,[data-hover-effect=fromGreyscale] .post:focus,[data-hover-effect=fromGreyscale] .post:hover{filter:grayscale(0);transition:all .6s cubic-bezier(.215,.61,.355,1)}:host(.keyboard-nav) [data-hover-effect=fromGreyscale] .post:focus.post--hover-caption:before,:host(.keyboard-nav) [data-hover-effect=fromGreyscale] .post:hover.post--hover-caption:before,[data-hover-effect=fromGreyscale] .post:focus.post--hover-caption:before,[data-hover-effect=fromGreyscale] .post:hover.post--hover-caption:before{background-color:var(--overlay-color);transition:all .6s cubic-bezier(.215,.61,.355,1)}:host(.keyboard-nav) [data-hover-effect=fromGreyscale] .post:focus:after,:host(.keyboard-nav) [data-hover-effect=fromGreyscale] .post:hover:after,[data-hover-effect=fromGreyscale] .post:focus:after,[data-hover-effect=fromGreyscale] .post:hover:after{opacity:1;transform:translateY(-50%)}:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post,[data-hover-effect=zoomFromGreyscale] .post{filter:grayscale(100%)}:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post:focus,:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post:hover,[data-hover-effect=zoomFromGreyscale] .post:focus,[data-hover-effect=zoomFromGreyscale] .post:hover{filter:grayscale(0)}:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post:focus behold-image,:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post:focus behold-video,:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post:hover behold-image,:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post:hover behold-video,[data-hover-effect=zoomFromGreyscale] .post:focus behold-image,[data-hover-effect=zoomFromGreyscale] .post:focus behold-video,[data-hover-effect=zoomFromGreyscale] .post:hover behold-image,[data-hover-effect=zoomFromGreyscale] .post:hover behold-video{transform:scale(1.05);transition:all .6s cubic-bezier(.215,.61,.355,1)}@media (prefers-reduced-motion){:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post:focus behold-image,:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post:focus behold-video,:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post:hover behold-image,:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post:hover behold-video,[data-hover-effect=zoomFromGreyscale] .post:focus behold-image,[data-hover-effect=zoomFromGreyscale] .post:focus behold-video,[data-hover-effect=zoomFromGreyscale] .post:hover behold-image,[data-hover-effect=zoomFromGreyscale] .post:hover behold-video{transform:none}}:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post:focus.post--hover-caption:before,:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post:hover.post--hover-caption:before,[data-hover-effect=zoomFromGreyscale] .post:focus.post--hover-caption:before,[data-hover-effect=zoomFromGreyscale] .post:hover.post--hover-caption:before{background-color:var(--overlay-color);transition:all .6s cubic-bezier(.215,.61,.355,1)}:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post:focus:after,:host(.keyboard-nav) [data-hover-effect=zoomFromGreyscale] .post:hover:after,[data-hover-effect=zoomFromGreyscale] .post:focus:after,[data-hover-effect=zoomFromGreyscale] .post:hover:after{opacity:1;transform:translateY(-50%)}behold-image{display:block;height:0;overflow:hidden;padding:0;padding-bottom:calc(100%/var(--post-aspect-ratio));position:relative;transition:all .6s cubic-bezier(.215,.61,.355,1);width:100%}behold-image img{border-radius:0;height:100%;left:0;-o-object-fit:cover;object-fit:cover;-o-object-position:center center;object-position:center center;opacity:0;pointer-events:none;position:absolute;top:0;transition:all .6s cubic-bezier(.215,.61,.355,1),opacity .6s ease;vertical-align:middle;width:100%;will-change:transform;z-index:1}@supports not ((-webkit-backdrop-filter:blur(3px)) or (backdrop-filter:blur(3px))){[data-hover-effect=blur] behold-image img,[data-hover-effect=zoomBlur] behold-image img{height:calc(100% + 6px);left:-3px;top:-3px;width:calc(100% + 6px)}}.post--reel behold-image img{-o-object-position:center 25%;object-position:center 25%}behold-image.is-loaded img{opacity:1}behold-video{display:block;height:0;overflow:hidden;padding:0;padding-bottom:calc(100%/var(--post-aspect-ratio));position:relative;transition:all .6s cubic-bezier(.215,.61,.355,1);width:100%}behold-video video{height:100%;left:0;-o-object-fit:cover;object-fit:cover;-o-object-position:center center;object-position:center center;opacity:0;pointer-events:none;position:absolute;top:0;transition:all .6s cubic-bezier(.215,.61,.355,1),opacity .6s ease;vertical-align:middle;width:100%;will-change:transform}.post--reel behold-video video{-o-object-position:center 25%;object-position:center 25%}behold-video.is-loaded video{opacity:1}";class V extends _{label="Grid";widgetSettings;feedMetadata;posts;previewLoadingColors=null;containerEl;postEls;popoverGalleryEl;appliedBreakpoint;medianPaletteHSL;constructor(){super(),R.register(),$.register(),j.register(),this.Y=this.Y.bind(this),this.addEventListener("post-focus-next",this.J),this.addEventListener("post-focus-previous",this.Z),this.onPropChange(this.S,["widgetSettings","feedMetadata","posts","previewLoadingColors"],["widgetSettings","feedMetadata","posts"],this.setup),this.onConnect((()=>{this.containerEl=z({type:"figure",classes:"posts"}),this.renderWidget(this.containerEl,[O,".post--placeholder{background-color:#dedede;height:0;padding-bottom:calc(100%/var(--post-aspect-ratio))}"]),this.setAttribute("tabindex","0"),this.setAttribute("aria-label","Gallery of Instagram posts. Shift + arrow keys to navigate"),this.onResize(this,this,this.m)}))}setup(){if("transparent"!==this.widgetSettings.loadingColor){const t=this.posts.filter((t=>t.colorPalette)).map((t=>t.colorPalette));this.medianPaletteHSL=M(t,this.widgetSettings.loadingColor)}const t=this.getMatchingBreakpoint(this.offsetWidth,this.widgetSettings.breakpoints);this.renderBreakpoint(t),this.postEls&&this.postEls.forEach((t=>{t.widgetSettings=this.widgetSettings,t.feedMetadata=this.feedMetadata})),"openPopupGallery"===this.widgetSettings.onPostClick&&this.enablePopoverGallery()}S({changedProp:t,oldValue:e,newValue:s}){switch(t){case"posts":this.K({oldValue:e,newValue:s});break;case"widgetSettings":this.X(e,s);break;case"feedMetadata":this.tt();break;case"previewLoadingColors":this.postEls.forEach((t=>{t.previewLoadingColors=this.previewLoadingColors})),n(this,{"is-previewing-loading-colors":!!this.previewLoadingColors})}}K({oldValue:t,newValue:e}){this.postEls=[],this.renderBreakpoint(this.getMatchingBreakpoint(this.offsetWidth,this.widgetSettings.breakpoints),!0),this.popoverGalleryEl&&(this.popoverGalleryEl.posts=this.posts)}X(t,e){"openPopupGallery"!==t?.onPostClick&&"openPopupGallery"===e?.onPostClick&&this.enablePopoverGallery();const s=this.getMatchingBreakpoint(this.offsetWidth,this.widgetSettings.breakpoints);this.renderBreakpoint(s),this.postEls.forEach((t=>{t.widgetSettings=this.widgetSettings})),this.popoverGalleryEl&&(this.popoverGalleryEl.widgetSettings=this.widgetSettings)}tt(){let t=`from @${this.feedMetadata.username}`;this.feedMetadata.hashtags?.length&&(t=`from hashtag${this.feedMetadata.hashtags.length>1?"s":""} ${this.feedMetadata.hashtags.join(", ")}`),this.setAttribute("aria-label",`Gallery of Instagram posts ${t}. Shift + arrow keys to navigate`),this.postEls.forEach((t=>{t.feedMetadata=this.feedMetadata})),this.popoverGalleryEl&&(this.popoverGalleryEl.feedMetadata=this.feedMetadata)}async enablePopoverGallery(){if(this.popoverGalleryEl)return;const{default:t}=await import("./PopoverGallery-8G1aF271.js");t.register(),this.popoverGalleryEl=document.createElement("behold-popover-gallery"),Object.assign(this.popoverGalleryEl,{widgetSettings:this.widgetSettings,feedMetadata:this.feedMetadata,posts:this.posts,closeFocusEl:this,onSlideChange:t=>{this.popoverGalleryEl.closeFocusEl=this.postEls[t]}})}m(t){const e=t.contentBoxSize?.[0]?.inlineSize,s=this.widgetSettings.breakpoints,i=this.getMatchingBreakpoint(e,s);this.renderBreakpoint(i)}Z(){if(!this.postEls.length)return;let t=[...this.containerEl.children].indexOf(this.shadow.activeElement?.parentElement);t>0?t-=1:t=this.postEls.length-1,this.postEls[t].focus()}J(){if(!this.postEls.length)return;let t=[...this.containerEl.children].indexOf(this.shadow.activeElement?.parentElement);t>-1&&t<this.postEls.length-1?t+=1:t=0,this.postEls[t].focus()}Y(t){this.popoverGalleryEl.open(this.postEls.indexOf(t),t)}renderPosts(t){this.postEls=this.createPostEls(t),this.raf((()=>{this.containerEl.beholdReplaceChildren(...this.postEls)}),"renderPosts")}getMatchingBreakpoint(t,e){return Object.entries(e).map((([t,e])=>({width:t,...e}))).filter((t=>"default"!==t.width)).sort(((t,e)=>parseInt(e.width)-parseInt(t.width))).reduce(((e,s)=>t<=parseInt(s.width)?s:e),{numPosts:this.posts.length,...e.default})}renderBreakpoint(t,s=!1){if(!this.posts||!this.containerEl)return;this.postEls?.length||(s=!0);const i=this.appliedBreakpoint,{numColumns:o,gap:a,borderRadius:h,numPosts:r,postAspectRatio:n}=t;switch(i?.numPosts>r&&(this.containerEl.beholdReplaceChildren(),e()),this.widgetSettings.alignment){case"left":this.style.justifyContent="flex-start";break;case"right":this.style.justifyContent="flex-end";break;default:this.style.justifyContent="center"}this.widgetSettings.maxWidth&&this.widgetSettings.constrainWidth&&this.containerEl.style.maxWidth!==`${this.widgetSettings.maxWidth}px`&&(this.containerEl.style.maxWidth=`${this.widgetSettings.maxWidth}px`),this.widgetSettings.constrainWidth||(this.containerEl.style.maxWidth=""),this.containerEl.style.gridTemplateColumns=`repeat(${o}, 1fr)`,this.containerEl.style.gap=`${a.y}px ${a.x}px`,this.containerEl.setAttribute("data-hover-effect",this.widgetSettings.hoverEffect);let c=(n||[1,1]).reduce(((t,e)=>t/e));l(this.containerEl,{"--post-border-radius":`${h}%`,"--post-aspect-ratio":`${c}`}),(i?.numPosts!==r||s)&&this.renderPosts(t),this.postEls.forEach(((e,s)=>{e.hasRowGap="0"!=`${t.gap.y}`})),this.appliedBreakpoint=t}createPostEls(t){const{numPosts:e,numColumns:s,gap:i,postAspectRatio:o}=t,a=this.posts.filter(((e,s)=>s<(t?.numPosts||this.posts?.length||200))),h=a.map(((t,h)=>{const r=Math.ceil((e||this.posts.length)/s);let n="behold-image-post";return"VIDEO"===t.mediaType&&(n="behold-video-post"),"CAROUSEL_ALBUM"===t.mediaType&&(n="behold-album-post"),z({type:n,props:{post:t,widgetSettings:this.widgetSettings,feedMetadata:this.feedMetadata,medianPaletteHSL:this.medianPaletteHSL,onClick:this.Y,hasRowGap:"0"!=`${i.y}`,isLastRow:Math.ceil((h+1)/s)===r,index:h,aspectRatio:o||[1,1],totalPosts:a?.length||e||this.posts?.length||0}})}));for(;h.length<t.numPosts;){const t=z({classes:"post post--placeholder"});h.push(t)}return h}static register(t="behold-grid"){return customElements.get(t)||customElements.define(t,V),t}}var B=Object.freeze({__proto__:null,default:V});class I extends _{label="GalleryWall";widgetSettings;feedMetadata;posts;previewLoadingColors=null;containerEl;heightRefEl;postEls;popoverGalleryEl;appliedBreakpoint;medianPaletteHSL;constructor(){super(),this.onPropChange(this.S,["widgetSettings","feedMetadata","posts","previewLoadingColors"],["widgetSettings","feedMetadata","posts"],this.setup),R.register(),$.register(),j.register(),this.Y=this.Y.bind(this),this.addEventListener("post-focus-next",this.J),this.addEventListener("post-focus-previous",this.Z),this.onConnect((()=>{this.style.opacity="0",this.heightRefEl=z({classes:"height-ref"}),this.containerEl=z({type:"figure",classes:"posts",contents:[this.heightRefEl]}),this.renderWidget(this.containerEl,[O,".posts{display:block;min-height:100%;width:100%}.height-ref{position:relative}.post{-webkit-font-smoothing:inherit;-moz-osx-font-smoothing:inherit;border:none;color:inherit;display:block;font:inherit;height:100px;left:0;line-height:normal;overflow:hidden;position:absolute;top:0;transform-origin:top left;transition:background .3s ease;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100px}.post--placeholder{background-color:#dedede;position:absolute}"]),this.setAttribute("tabindex","0"),this.setAttribute("aria-label","Gallery of Instagram posts. Shift + arrow keys to navigate"),this.onResize(this,this.containerEl,this.m)}))}setup(){if("transparent"!==this.widgetSettings.loadingColor){const t=this.posts.filter((t=>t.colorPalette)).map((t=>t.colorPalette));this.medianPaletteHSL=M(t,this.widgetSettings.loadingColor)}const t=this.getMatchingBreakpoint(this.offsetWidth,this.widgetSettings.breakpoints);this.renderBreakpoint(t),this.style.opacity="","openPopupGallery"===this.widgetSettings.onPostClick&&this.enablePopoverGallery()}S({changedProp:t,oldValue:e,newValue:s}){switch(t){case"posts":this.K();break;case"widgetSettings":this.X(e,s);break;case"feedMetadata":this.tt();break;case"previewLoadingColors":this.postEls.forEach((t=>{t.previewLoadingColors=this.previewLoadingColors})),n(this,{"is-previewing-loading-colors":!!this.previewLoadingColors})}}K(){this.postEls=[],this.renderBreakpoint(this.appliedBreakpoint,!0),this.popoverGalleryEl&&(this.popoverGalleryEl.posts=this.posts)}X(t,e){"openPopupGallery"!==t?.onPostClick&&"openPopupGallery"===e?.onPostClick&&this.enablePopoverGallery(),this.renderBreakpoint(this.getMatchingBreakpoint(this.offsetWidth,this.widgetSettings.breakpoints)),this.postEls.forEach((t=>{t.widgetSettings=this.widgetSettings})),this.popoverGalleryEl&&(this.popoverGalleryEl.widgetSettings=this.widgetSettings)}tt(){let t=`from @${this.feedMetadata.username}`;this.feedMetadata.hashtags?.length&&(t=`from hashtag${this.feedMetadata.hashtags.length>1?"s":""} ${this.feedMetadata.hashtags.join(", ")}`),this.setAttribute("aria-label",`Gallery of Instagram posts ${t}. Shift + arrow keys to navigate`),this.postEls.forEach((t=>{t.feedMetadata=this.feedMetadata})),this.popoverGalleryEl&&(this.popoverGalleryEl.feedMetadata=this.feedMetadata)}async enablePopoverGallery(){const{default:t}=await import("./PopoverGallery-8G1aF271.js");t.register(),this.popoverGalleryEl=document.createElement("behold-popover-gallery"),Object.assign(this.popoverGalleryEl,{widgetSettings:this.widgetSettings,feedMetadata:this.feedMetadata,posts:this.posts,closeFocusEl:this,onSlideChange:t=>{this.popoverGalleryEl.closeFocusEl=this.postEls[t]}})}m(t){const e=t.contentBoxSize?.[0]?.inlineSize,s=this.widgetSettings.breakpoints,i=this.getMatchingBreakpoint(e,s);this.renderBreakpoint(i)}Z(){if(!this.postEls.length)return;let t=[...this.heightRefEl.children].indexOf(this.shadow.activeElement?.parentElement);t>0?t-=1:t=this.postEls.length-1,this.postEls[t].focus()}J(){if(!this.postEls.length)return;let t=[...this.heightRefEl.children].indexOf(this.shadow.activeElement?.parentElement);t>-1&&t<this.postEls.length-1?t+=1:t=0,this.postEls[t].focus()}Y(t){this.popoverGalleryEl.open(this.postEls.indexOf(t),t)}renderPosts(t){this.postEls=this.createPostEls(t),this.raf((()=>{this.heightRefEl.beholdReplaceChildren(...this.postEls)}),"renderPosts")}getMatchingBreakpoint(t,e){return Object.entries(e).map((([t,e])=>({width:t,...e}))).filter((t=>"default"!==t.width)).sort(((t,e)=>e.width.localeCompare(t.width))).reduce(((e,s)=>t<=parseInt(s.width)?s:e),{...e.default,numPosts:e.default.galleryWallLayout.length})}renderBreakpoint(t,s=!1){this.cancelRaf("setContainerHeight"),this.postEls||(s=!0);const i=this.appliedBreakpoint;this.appliedBreakpoint=t;const{gap:o,borderRadius:a,numPosts:h,galleryWallLayout:r,galleryWallNamedLayout:n}=t;switch(this.widgetSettings.alignment){case"left":this.style.justifyContent="flex-start";break;case"right":this.style.justifyContent="flex-end";break;default:this.style.justifyContent="center"}this.widgetSettings.maxWidth&&this.widgetSettings.constrainWidth&&this.containerEl.style.maxWidth!==`${this.widgetSettings.maxWidth}px`&&(this.containerEl.style.maxWidth=`${this.widgetSettings.maxWidth}px`),this.widgetSettings.constrainWidth||(this.containerEl.style.maxWidth=""),this.containerEl.setAttribute("data-hover-effect",this.widgetSettings.hoverEffect),l(this.containerEl,{"--post-border-radius":`${a}%`}),(i?.numPosts!==h||i?.galleryWallNamedLayout!==n.toString()||s)&&this.renderPosts(t);const c=this.containerEl.offsetWidth,d=o.x/1e3*c,p=o.y/1e3*c;this.postEls.forEach(((t,e)=>{const[s,i,o,a]=r?.[e]?r[e].split(",").map((t=>parseInt(t))):[0,0,10,10],h=s*(c/100)+d/2,n=i*(c/100);t.style.transform=`translate(${h}px, ${n}px`,t.style.width=o*(c/100)-d+"px",t.style.height=a*(c/100)-p+"px"})),e(),this.raf((()=>{this.setContainerHeight()}),"setContainerHeight")}createPostEls(t){const{gap:e,postAspectRatio:s}=t,i=t?.numPosts||this.posts?.length||200,o=this.posts.filter(((t,e)=>e<i)),a=o.map(((i,a)=>{let h="behold-image-post";return"VIDEO"===i.mediaType&&(h="behold-video-post"),"CAROUSEL_ALBUM"===i.mediaType&&(h="behold-album-post"),z({type:h,props:{post:i,widgetSettings:this.widgetSettings,feedMetadata:this.feedMetadata,medianPaletteHSL:this.medianPaletteHSL,onClick:this.Y,hasRowGap:"0"!=`${e.y}`,index:a,aspectRatio:s||[1,1],totalPosts:o?.length||t?.numPosts||this.posts?.length||0}})}));return a.length<t.galleryWallLayout.length&&t.galleryWallLayout.filter(((t,e)=>e>=a.length)).forEach((t=>{const e=z({classes:"post post--placeholder"});a.push(e)})),a}setContainerHeight=r((()=>{this.style.height=`${this.heightRefEl.scrollHeight}px`}),10,this);static register(t="behold-gallery-wall"){return customElements.get(t)||customElements.define(t,I),t}}var T=Object.freeze({__proto__:null,default:I});class H{containerEl;slideEls;height;gap;borderRadius;applyBorderRadiusToContainer;snapToSlide;bindToScrollPos;resizeObserver;onSlideChange;et;st;it;ot;ht;rt;nt;lt;ct;dt;ut;ft;gt;bt;vt;wt;yt;xt;kt;zt;Ft;Mt;Ct;Pt;_t;St;anchorSlide;finalAnchorSlide;constructor({onSlideChange:t}){this.ot=[],this.ht=!1,this.rt=!1,this.nt=!1,this.lt=0,this.ct=0,this.dt=0,this.anchorSlide=0,this.ut=0,this.ft={start:0,previous:0},this.gt=[],this.bt=0,this.xt=1/60,this.kt=3,this.zt=2,this.borderRadius=20,this.applyBorderRadiusToContainer=!1,this.gap=20,this.height=300,this.snapToSlide=!1,this.bindToScrollPos=!1,this.vt=40,this.wt=0,this.yt=0,this.Ft=window.innerHeight,this.Mt=null,this.Ct=0,this.Pt=()=>{},this._t=!1,this.onSlideChange=t;let e=window.ResizeObserver;"ResizeObserver"in window==0&&(e=window.BeholdResizeObserver),this.resizeObserver=new e((t=>this.handleResize(t))),this.handlePointerdown=this.handlePointerdown.bind(this),this.handlePointermove=this.handlePointermove.bind(this),this.handlePointerup=this.handlePointerup.bind(this)}init({containerEl:t,slideEls:e,height:s=300,gap:i=20,borderRadius:o=40,applyBorderRadiusToContainer:a=!0,snapToSlide:h=!1,bindToScrollPos:r=!1}){this.containerEl=t,this.slideEls=e.map((t=>z({classes:"ec-slide",contents:t}))),this.it=e,this.et=t.offsetWidth,this.st=t?.scrollWidth||0,this.updateSettings({height:s,gap:i,borderRadius:o,applyBorderRadiusToContainer:a,snapToSlide:h,bindToScrollPos:r}),this.addEventListeners(),this.containerEl.style.setProperty("--ec-container-width",`${this.et}px`),this.containerEl.beholdReplaceChildren(...this.slideEls),this.updateDimensions(),this.ht=!0,this.loop()}updateSettings({height:t=300,gap:e=20,borderRadius:s=40,applyBorderRadiusToContainer:i=!0,snapToSlide:o=!1,bindToScrollPos:a=!1}){cancelAnimationFrame(this.St),this.St=requestAnimationFrame((()=>{this.height=t,this.gap=e,this.borderRadius=Math.min(s/100*this.height,.45*this.et/2),this.vt=Math.max(this.borderRadius,40),this.applyBorderRadiusToContainer=i,this.snapToSlide=o,this.bindToScrollPos=a,this.containerEl.style.setProperty("--ec-height",`${this.height}px`),this.containerEl.style.setProperty("--ec-border-radius",this.applyBorderRadiusToContainer?`${this.borderRadius}px`:"0px"),this.snapToSlide&&(this.ut=-this.getClosestSlideToPoint(this.ut).leftEdge)}))}destroy(){this.ht=!1,cancelAnimationFrame(this.St),this.removeEventListeners(),this.slideEls?.length&&this.slideEls.forEach((t=>{t.remove()})),this.slideEls=null,this.containerEl=null}handleResize(t){let e=null;t&&t.forEach((t=>{t.target===this.containerEl&&(e=t.borderBoxSize?t.borderBoxSize[0].inlineSize:t.contentRect.width)})),this.updateDimensions(e),this.ut=Math.max(Math.min(0,this.ut),this.et-this.st)}addEventListeners(){this.removeEventListeners(),this.slideEls.length&&this.slideEls.forEach((t=>{this.resizeObserver.observe(t)})),this.containerEl&&(this.resizeObserver.observe(this.containerEl),this.containerEl.addEventListener("pointerdown",this.handlePointerdown),document.addEventListener("pointermove",this.handlePointermove,{passive:!0}),document.addEventListener("pointerup",this.handlePointerup),document.body.addEventListener("pointerleave",this.handlePointerup))}removeEventListeners(){this.resizeObserver.disconnect(),this.containerEl&&(this.containerEl.removeEventListener("pointerdown",this.handlePointerdown),document.removeEventListener("pointermove",this.handlePointermove),document.removeEventListener("pointerup",this.handlePointerup))}handlePointerdown(t){this.rt=!0,this.ct=this.dt,this.ut=this.dt,this.ft.start=t.clientX,this.ft.previous=t.clientX,this.updateDimensions()}handlePointermove(t){if(!this.rt)return;const e=t.clientX-this.ft.start;Math.abs(e)>10&&this.containerEl.classList.add("ec-is-dragging"),this.ut=this.ct+e,u(this.gt,t.clientX-this.ft.previous,10),this.ft.previous=t.clientX}handlePointerup(){var t;this.containerEl.classList.remove("ec-is-dragging"),this.rt=!1,this.ut+=10*((t=this.gt).length?t.reduce(((t,e)=>t+e),0)/t.length:0),this.ut=Math.max(Math.min(0,this.ut),this.et-this.st),this.snapToSlide&&(this.ut=-this.getClosestSlideToPoint(this.ut).leftEdge)}updateDimensions(t){this.et=t||this.containerEl.offsetWidth;let e=0;this.ot=this.slideEls.map(((t,s)=>{let i=t.offsetWidth,o=e;return e+=i,s<this.ot.length-1&&(e+=this.gap),{width:i,x:o}})),this.st=e,this.finalAnchorSlide=this.getFinalAnchorSlide(),this.containerEl.style.setProperty("--ec-container-width",`${this.et}px`)}getAcceleration({displacement:t,lt:e,stiffness:s=7,mass:i=17,friction:o=1.25}){let a=-s*t/i-o*e;return Math.abs(a)<.001&&(a=0),a*this.xt}getClosestSlideToPoint(t){return this.ot.reduce(((e,s,i)=>{const o=Math.abs(e.cumulativeWidth+t);return o<e.distanceFromTarget?{index:i,distanceFromTarget:o,leftEdge:e.cumulativeWidth,cumulativeWidth:e.cumulativeWidth+s.width+this.gap}:{...e,cumulativeWidth:e.cumulativeWidth+s.width+this.gap}}),{index:0,distanceFromTarget:1/0,leftEdge:0,cumulativeWidth:0})}getFinalAnchorSlide(){return this.slideEls.reduceRight(((t,e,s)=>(t.cumulativeWidth<this.et&&(t.index=s,t.cumulativeWidth+=this.ot[s]?.width||0),t)),{index:0,cumulativeWidth:0}).index}updateScrollPos(){this.Pt(),this.Pt=function(t,e){let s=!1,i=new IntersectionObserver((t=>{s||(i.disconnect(),i=null,e(t[0].boundingClientRect))}));return i.observe(t),function(){s||(s=!0,i&&(i.disconnect(),i=null))}}(this.containerEl,(t=>{this.et=t.width;const e=Math.max(Math.min((this.Ft-t.top)/(this.Ft+t.height),1),0);if(e!==this.Ct){this.nt=!0;const t=this.Ct-e,s=this.Ft*t*.5;this.ut+=s,this.ut=Math.max(Math.min(0,this.ut),this.et-this.st),this.Ct=e}this.Mt=t}))}updatePosition(){const t=this.dt-this.ut;let e=200,s=23,i=80;this.nt&&(e=600,s=40,i=40),(0===this.ut||this.ut<=this.et-this.st)&&(e=100,s=16,i=45);const o=this.getAcceleration({displacement:t,lt:this.lt,stiffness:e,friction:s,mass:i});this.lt+=o,this.dt+=A(this.lt)}getSlidePositions(){const t=A(this.dt);let e=t,s=!1;const i=this.slideEls.map(((i,o)=>{const a=this.it[o],h=this.ot[o]?.width;o>0&&(e+=this.ot[o-1]?.width+this.gap);let r=0,n=0,l=0,c=0,d=Math.min(h*this.kt,this.et);const p=this.ot[o];p&&p.x+p.width*this.kt>this.st&&(d=h*(this.slideEls.length-o)+Math.round(this.wt));let u=Math.min(Math.max(d-Math.max(this.et-e+Math.round(this.wt),0),0)/(d-this.vt),1);const f=(h-this.vt)*u;if(l=f,r=-f/2,c-=f,e<this.et&&e+h-l+this.gap>=this.et&&t<=0){const t=h-n-l,i=this.vt-(this.et-e)<=0?t:this.et-e,a=this.et-(e+i);a>0&&!this.wt&&(this.wt=a*this.zt,this.yt=o+1,s=!0),i<this.vt/2&&!this.wt&&(this.wt=(i+this.gap)*this.zt,this.yt=o+1,s=!0)}Math.round(e-this.gap)<=0&&Math.round(h+e)>0&&(o!==this.anchorSlide&&this.onSlideChange&&this.onSlideChange(o),this.anchorSlide=o),e<=0&&(n=Math.min(Math.abs(e),h-this.vt),r=e/-2),this._t&&(e>this.et+250||e+h<-250?a.remove():a.isConnected||i.append(a));const g={el:i,contentEl:a,xPos:e,rightClipInset:l,leftClipInset:n,innerTranslate:r};return e+=c,g}));return s?this.getSlidePositions():i}positionSlides(){this.getSlidePositions().forEach((({el:t,contentEl:e,xPos:s,rightClipInset:i,leftClipInset:o,innerTranslate:a},h)=>{const r=Math.min(this.borderRadius,this.ot[h]?.width/2);t.style.transform=`translate3d(${s}px, 0 ,0)`,t.style.clipPath=`inset(0 ${i}px 0 ${o}px round ${r}px)`,e.style.transform=`translate3d(${a}px, 0, 0)`}))}goToSlide(t){this.updateDimensions(),this.ut=-this.ot[t]?.x??this.ut,this.ut=Math.max(Math.min(0,this.ut),this.et-this.st)}advance(){this.goToSlide(Math.min(this.getClosestSlideToPoint(this.ut).index+1,this.slideEls.length-1))}retreat(){this.goToSlide(Math.max(this.getClosestSlideToPoint(this.ut).index-1,0))}render(){this.gt.shift(),this.slideEls&&(this.bindToScrollPos&&this.updateScrollPos(),this.updatePosition(),this.positionSlides(),this.nt=!1)}loop(){if(!this.ht)return;const t=performance.now();t-this.bt>16&&(this.render(),this.bt=t),requestAnimationFrame((()=>this.loop()))}}function A(t,e=3){return parseFloat(t.toFixed(e))}var U='<?xml version="1.0" encoding="utf-8"?>\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\n\t viewBox="0 0 12.1 20" enable-background="new 0 0 12.1 20" xml:space="preserve">\n<path d="M12.1,17.9L4.2,10l7.9-7.9L10,0L0,10l10,10L12.1,17.9z"/>\n</svg>',W='<?xml version="1.0" encoding="utf-8"?>\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\n\t viewBox="0 0 12.1 20" enable-background="new 0 0 12.1 20" xml:space="preserve">\n<path d="M0,2.1L7.9,10L0,17.9L2.1,20l10-10L2.1,0L0,2.1z"/>\n</svg>';class q extends _{label="ElasticCarousel";widgetSettings;feedMetadata;posts;previewLoadingColors=null;containerEl;headerEl;innerEl;footerEl;instagramLogoEl;labelEl;leftArrowEl;rightArrowEl;slidesContainerEl;postEls;popoverGalleryEl;appliedBreakpoint;medianPaletteHSL;gyre;constructor(){super(),this.onPropChange(this.S,["widgetSettings","feedMetadata","posts","previewLoadingColors"],["widgetSettings","feedMetadata","posts"],this.setup),R.register(),$.register(),j.register(),this.gyre=new H({onSlideChange:t=>this.Et(t)}),this.Y=this.Y.bind(this),this.addEventListener("post-focus-next",this.J),this.addEventListener("post-focus-previous",this.Z),this.onConnect((()=>{this.slidesContainerEl=z({classes:"ec-slides"}),this.headerEl=z({type:"header",classes:"ec-header"}),this.innerEl=z({classes:"ec-inner",contents:[this.slidesContainerEl]}),this.footerEl=z({type:"footer",classes:"ec-footer"}),this.labelEl=z({classes:"ec-label"}),this.leftArrowEl=z({type:"button",classes:"ec-button ec-retreat",contents:[U],listeners:{click:()=>this.Gt()},attributes:{tabindex:-1,disabled:!0}}),this.rightArrowEl=z({type:"button",classes:"ec-button ec-advance",contents:[W],listeners:{click:()=>this.Rt()},attributes:{tabindex:-1}}),this.containerEl=z({type:"figure",classes:"ec-carousel",contents:[this.innerEl]}),this.renderWidget(this.containerEl,[O,'.ec-carousel{--ec-controls-margin:20px;--ec-button-border-radius:40%;--ec-icon-color:#4a4a4a;--ec-text-color:#4a4a4a;--ec-button-color:#f4f4f4;--ec-button-hover-color:#ececec;--ec-button-icon-color:#4a4a4a;--ec-button-icon-hover-color:#2e2e2e;--ec-button-gap:min(calc(var(--ec-controls-margin)/2),5px);flex-direction:column;height:var(--ec-height);margin:0;overflow:hidden;width:100%}.ec-carousel,.ec-inner{display:flex;justify-content:center}.ec-inner{align-items:center}.ec-slides{border-radius:var(--ec-border-radius);contain:style paint;cursor:grab;height:var(--ec-height);justify-content:flex-start;overflow:hidden;position:relative;touch-action:none;width:100%}.ec-slide,.ec-slides{display:flex;isolation:isolate}.ec-slide{contain:content;flex-shrink:0;height:100%;left:0;max-width:calc(var(--ec-container-width)*.45);position:absolute;top:0;-moz-user-select:none;user-select:none;-webkit-user-select:none;will-change:clip-path,transform}.ec-is-dragging{cursor:grabbing}.ec-is-dragging .ec-slide{pointer-events:none}.ec-footer,.ec-header{display:flex;justify-content:center}.ec-carousel--controls-sides .ec-footer,.ec-carousel--controls-sides .ec-header{padding:0 64px}.ec-header{margin-bottom:var(--ec-controls-margin)}.ec-footer{margin-top:var(--ec-controls-margin)}.ec-label{align-items:center;display:flex;flex-shrink:1;gap:7px 5px;line-height:1.2;min-width:0;overflow:hidden;text-overflow:ellipsis;-moz-user-select:none;user-select:none;-webkit-user-select:none}.ec-carousel--controls-center .ec-button+.ec-label,.ec-carousel--controls-split .ec-button+.ec-label{margin:0 max(calc(var(--ec-controls-margin)*1.5),20px)}.ec-carousel--label-right .ec-label{margin-left:auto}.ec-carousel--label-left .ec-label{margin-right:auto}.ec-label svg{flex-shrink:0;height:24px;margin-right:5px;width:24px}.ec-label svg path{fill:var(--ec-icon-color)}.ec-label a,.ec-label div{color:var(--ec-text-color);display:inline-block;font-family:inherit;font-size:19px;overflow:hidden;text-decoration:none;text-overflow:ellipsis;white-space:nowrap}.ec-button,.ec-carousel--controls-center .ec-footer,.ec-carousel--controls-center .ec-header{justify-content:center}.ec-button{align-items:center;background-color:transparent;border:none;cursor:pointer;display:flex;flex-shrink:0;height:44px;padding:0;transition:all .3s ease;width:44px}.ec-carousel--controls-sides .ec-button{height:var(--ec-height);width:64px}.ec-button:disabled{cursor:default;opacity:.5}.ec-button:before{background-color:var(--ec-button-color);border-radius:var(--ec-button-border-radius);content:"";height:44px;position:absolute;transition:all .3s ease;width:44px}.ec-button:not(:disabled):hover:before{background-color:var(--ec-button-hover-color)}.ec-button svg{height:14px;position:relative;width:auto;z-index:1}.ec-button svg path{fill:var(--ec-button-icon-color);transition:all .3s ease}.ec-button:not(:disabled):hover svg path{fill:var(--ec-button-icon-hover-color)}.ec-retreat{padding-right:var(--ec-button-gap);width:calc(44px + var(--ec-button-gap))}.ec-carousel--controls-split .ec-retreat{margin-right:auto}.ec-carousel--controls-right .ec-retreat{margin-left:auto}.ec-advance{padding-left:var(--ec-button-gap);width:calc(44px + var(--ec-button-gap))}.ec-carousel--controls-split .ec-advance{margin-left:auto}.ec-carousel--controls-left .ec-advance{margin-right:auto}.ec-carousel--controls-sides .ec-retreat{padding-right:20px}.ec-carousel--controls-sides .ec-advance{padding-left:20px}.post{height:100%;max-width:calc(var(--ec-container-width)*.45)}.post a{-webkit-user-drag:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.post--placeholder{background-color:#dedede;height:0;padding-bottom:calc(100%/var(--post-aspect-ratio))}']),this.setAttribute("tabindex","0"),this.setAttribute("aria-label","Gallery of Instagram posts. Shift + arrow keys to navigate"),this.onResize(this,this,this.m)}))}setup(){if("transparent"!==this.widgetSettings.loadingColor){const t=this.posts.filter((t=>t.colorPalette)).map((t=>t.colorPalette));this.medianPaletteHSL=M(t,this.widgetSettings.loadingColor)}const t=this.getMatchingBreakpoint(this.offsetWidth,this.widgetSettings.breakpoints);this.renderBreakpoint(t),l(this.containerEl,{"--ec-icon-color":this.widgetSettings.iconColor,"--ec-text-color":this.widgetSettings.textColor,"--ec-button-color":this.widgetSettings.buttonColor,"--ec-button-hover-color":this.widgetSettings.buttonHoverColor,"--ec-button-icon-color":this.widgetSettings.buttonIconColor,"--ec-button-icon-hover-color":this.widgetSettings.buttonIconHoverColor}),this.postEls&&this.postEls.forEach((t=>{t.widgetSettings=this.widgetSettings,t.feedMetadata=this.feedMetadata})),this.Lt(),"openPopupGallery"===this.widgetSettings.onPostClick&&this.enablePopoverGallery()}Lt(){const t=document.createElement("template");if(t.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><path d="M295.42,6c-53.2,2.51-89.53,11-121.29,23.48-32.87,12.81-60.73,30-88.45,57.82S40.89,143,28.17,175.92c-12.31,31.83-20.65,68.19-23,121.42S2.3,367.68,2.56,503.46,3.42,656.26,6,709.6c2.54,53.19,11,89.51,23.48,121.28,12.83,32.87,30,60.72,57.83,88.45S143,964.09,176,976.83c31.8,12.29,68.17,20.67,121.39,23s70.35,2.87,206.09,2.61,152.83-.86,206.16-3.39S799.1,988,830.88,975.58c32.87-12.86,60.74-30,88.45-57.84S964.1,862,976.81,829.06c12.32-31.8,20.69-68.17,23-121.35,2.33-53.37,2.88-70.41,2.62-206.17s-.87-152.78-3.4-206.1-11-89.53-23.47-121.32c-12.85-32.87-30-60.7-57.82-88.45S862,40.87,829.07,28.19c-31.82-12.31-68.17-20.7-121.39-23S637.33,2.3,501.54,2.56,348.75,3.4,295.42,6m5.84,903.88c-48.75-2.12-75.22-10.22-92.86-17-23.36-9-40-19.88-57.58-37.29s-28.38-34.11-37.5-57.42c-6.85-17.64-15.1-44.08-17.38-92.83-2.48-52.69-3-68.51-3.29-202s.22-149.29,2.53-202c2.08-48.71,10.23-75.21,17-92.84,9-23.39,19.84-40,37.29-57.57s34.1-28.39,57.43-37.51c17.62-6.88,44.06-15.06,92.79-17.38,52.73-2.5,68.53-3,202-3.29s149.31.21,202.06,2.53c48.71,2.12,75.22,10.19,92.83,17,23.37,9,40,19.81,57.57,37.29s28.4,34.07,37.52,57.45c6.89,17.57,15.07,44,17.37,92.76,2.51,52.73,3.08,68.54,3.32,202s-.23,149.31-2.54,202c-2.13,48.75-10.21,75.23-17,92.89-9,23.35-19.85,40-37.31,57.56s-34.09,28.38-57.43,37.5c-17.6,6.87-44.07,15.07-92.76,17.39-52.73,2.48-68.53,3-202.05,3.29s-149.27-.25-202-2.53m407.6-674.61a60,60,0,1,0,59.88-60.1,60,60,0,0,0-59.88,60.1M245.77,503c.28,141.8,115.44,256.49,257.21,256.22S759.52,643.8,759.25,502,643.79,245.48,502,245.76,245.5,361.22,245.77,503m90.06-.18a166.67,166.67,0,1,1,167,166.34,166.65,166.65,0,0,1-167-166.34" transform="translate(-2.5 -2.5)"/><title>Instagram</title></svg>',this.widgetSettings.label){const e=z({type:this.widgetSettings.labelLink?"a":"div",contents:this.widgetSettings.label,attributes:{href:this.widgetSettings.labelLink||null,target:this.widgetSettings.labelLink?"_blank":null}});this.labelEl.beholdReplaceChildren(t.content,e)}else if(this.feedMetadata.hashtags?.length){const e=this.feedMetadata.hashtags.map(((t,e,s)=>z({type:"a",contents:["#",t,e<s.length-1?", ":""],attributes:{target:"_blank",href:`https://instagram.com/explore/tags/${t}`}})));this.labelEl.beholdReplaceChildren(t.content,...e)}else{const e=z({type:"a",contents:[this.feedMetadata.username],attributes:{target:"_blank",href:`https://instagram.com/${this.feedMetadata.username}`}});this.labelEl.beholdReplaceChildren(t.content,e)}}Et(t){0===t&&this.leftArrowEl?this.leftArrowEl.disabled=!0:this.leftArrowEl.disabled=!1,t>=this.gyre.finalAnchorSlide?this.rightArrowEl.disabled=!0:this.rightArrowEl.disabled=!1}S({changedProp:t,oldValue:e,newValue:s}){switch(t){case"posts":this.K({oldValue:e,newValue:s});break;case"widgetSettings":this.X(e,s);break;case"feedMetadata":this.tt();break;case"previewLoadingColors":this.postEls.forEach((t=>{t.previewLoadingColors=this.previewLoadingColors})),n(this,{"is-previewing-loading-colors":!!this.previewLoadingColors})}}K({oldValue:t,newValue:e}){this.postEls=[],this.renderBreakpoint(this.getMatchingBreakpoint(this.offsetWidth,this.widgetSettings.breakpoints),!0),this.postEls.forEach((t=>{t.widgetSettings=this.widgetSettings,t.feedMetadata=this.feedMetadata})),this.popoverGalleryEl&&(this.popoverGalleryEl.posts=this.posts)}X(t,e){let s=!1;this.postEls?.length&&!c(t.breakpoints,e.breakpoints,["postHeight"],1)||(s=!0),l(this.containerEl,{"--ec-icon-color":this.widgetSettings.iconColor,"--ec-text-color":this.widgetSettings.textColor,"--ec-button-color":this.widgetSettings.buttonColor,"--ec-button-hover-color":this.widgetSettings.buttonHoverColor,"--ec-button-icon-color":this.widgetSettings.buttonIconColor,"--ec-button-icon-hover-color":this.widgetSettings.buttonIconHoverColor}),c(t,e,["label","labelLink"])&&this.Lt(),"openPopupGallery"!==t?.onPostClick&&"openPopupGallery"===e?.onPostClick&&this.enablePopoverGallery();const i=this.getMatchingBreakpoint(this.offsetWidth,this.widgetSettings.breakpoints);this.renderBreakpoint(i,s),this.postEls.forEach((t=>{t.widgetSettings=this.widgetSettings})),this.popoverGalleryEl&&(this.popoverGalleryEl.widgetSettings=this.widgetSettings)}tt(){let t=`from @${this.feedMetadata.username}`;this.feedMetadata.hashtags?.length&&(t=`from hashtag${this.feedMetadata.hashtags.length>1?"s":""} ${this.feedMetadata.hashtags.join(", ")}`),this.setAttribute("aria-label",`Gallery of Instagram posts ${t}. Shift + arrow keys to navigate`),this.postEls.forEach((t=>{t.feedMetadata=this.feedMetadata})),this.popoverGalleryEl&&(this.popoverGalleryEl.feedMetadata=this.feedMetadata)}async enablePopoverGallery(){if(this.popoverGalleryEl)return;const{default:t}=await import("./PopoverGallery-8G1aF271.js");t.register(),this.popoverGalleryEl=document.createElement("behold-popover-gallery"),Object.assign(this.popoverGalleryEl,{widgetSettings:this.widgetSettings,feedMetadata:this.feedMetadata,posts:this.posts,closeFocusEl:this,onSlideChange:t=>{this.gyre.goToSlide(t),this.popoverGalleryEl.closeFocusEl=this.postEls[t]}})}m(t){const e=t.contentBoxSize?.[0]?.inlineSize,s=this.widgetSettings.breakpoints,i=this.getMatchingBreakpoint(e,s);this.renderBreakpoint(i)}Z(){if(!this.postEls.length)return;let t=[...this.postEls].indexOf(this.shadow.activeElement?.parentElement);t>0&&(t-=1),this.postEls[t].focus(),this.gyre.goToSlide(t)}J(){if(!this.postEls.length)return;let t=[...this.postEls].indexOf(this.shadow.activeElement?.parentElement);this.gyre.anchorSlide>0&&t<this.gyre.anchorSlide&&(t=this.gyre.anchorSlide),t>-1&&t<this.postEls.length-1&&(t+=1),t<0&&(t=0),this.postEls[t].focus(),this.gyre.goToSlide(t)}Y(t){this.popoverGalleryEl.open(this.postEls.indexOf(t),t)}Rt(){this.gyre&&this.gyre.advance()}Gt(){this.gyre&&this.gyre.retreat()}renderPosts(t){this.postEls=this.createPostEls(t),this.raf((()=>{this.gyre.destroy(),this.gyre.init({containerEl:this.slidesContainerEl,slideEls:this.postEls,height:t.postHeight,gap:t.gap.x,borderRadius:parseInt(t.borderRadius),applyBorderRadiusToContainer:t.applyBorderRadiusToContainer||!0,snapToSlide:t.snapToSlide||!1,bindToScrollPos:t.bindToScrollPos||!1})}),"renderPosts")}getMatchingBreakpoint(t,e){return Object.entries(e).map((([t,e])=>({width:t,...e}))).filter((t=>"default"!==t.width)).sort(((t,e)=>parseInt(e.width)-parseInt(t.width))).reduce(((e,s)=>t<=parseInt(s.width)?s:e),e.default)}renderBreakpoint(t,e=!1){if(!this.posts||!this.containerEl)return;const s=this.appliedBreakpoint,{showControls:i,controlsPosition:o,controlsJustification:a,showLabel:h,labelPosition:r,labelJustification:d,buttonBorderRadius:p,controlsMargin:u}=t;if(this.postEls?.length&&!c(s,t,["numPosts","forcePostAspectRatio","postAspectRatio","postHeight"])||(e=!0),this.widgetSettings.maxWidth&&this.widgetSettings.constrainWidth&&this.containerEl.style.maxWidth!==`${this.widgetSettings.maxWidth}px`&&(this.containerEl.style.maxWidth=`${this.widgetSettings.maxWidth}px`),this.widgetSettings.constrainWidth||(this.containerEl.style.maxWidth=""),this.leftArrowEl.remove(),this.rightArrowEl.remove(),c(s,t,["showControls","controlsPosition","controlsJustification","showLabel","labelPosition","labelJustification"])||i&&!this.leftArrowEl.isConnected||h&&!this.labelEl.isConnected){this.leftArrowEl.remove(),this.rightArrowEl.remove(),this.labelEl.remove(),this.headerEl.remove(),this.footerEl.remove(),l(this.containerEl,{"--ec-button-border-radius":`${p}%`,"--ec-controls-margin":`${u}px`}),n(this.containerEl,{"ec-carousel--controls-sides":"sides"===o,"ec-carousel--controls-left":"left"===a,"ec-carousel--controls-right":"right"===a,"ec-carousel--controls-center":"center"===a,"ec-carousel--controls-split":"split"===a,"ec-carousel--label-left":"left"===d,"ec-carousel--label-right":"right"===d,"ec-carousel--label-center":"left"===d}),h&&("top"===r&&this.headerEl.append(this.labelEl),"bottom"===r&&this.footerEl.append(this.labelEl));let t=this.innerEl;if("top"===o&&(t=this.headerEl),"bottom"===o&&(t=this.footerEl),i&&"sides"===o)t.prepend(this.leftArrowEl),t.append(this.rightArrowEl);else if(i)switch(a){case"left":t.prepend(this.rightArrowEl),t.prepend(this.leftArrowEl);break;case"right":t.append(this.leftArrowEl),t.append(this.rightArrowEl);break;default:t.prepend(this.leftArrowEl),t.append(this.rightArrowEl)}this.headerEl.childElementCount&&this.containerEl.prepend(this.headerEl),this.footerEl.childElementCount&&this.containerEl.append(this.footerEl)}this.containerEl.setAttribute("data-hover-effect",this.widgetSettings.hoverEffect),e?this.renderPosts(t):this.gyre.updateSettings({height:t.postHeight,gap:t.gap.x,borderRadius:parseInt(t.borderRadius),applyBorderRadiusToContainer:t.applyBorderRadiusToContainer,snapToSlide:t.snapToSlide,bindToScrollPos:t.bindToScrollPos}),this.appliedBreakpoint=t}createPostEls(t){const{numPosts:e,postHeight:s,postAspectRatio:i,forcePostAspectRatio:o}=t,a=this.posts.filter(((e,s)=>s<(t?.numPosts||this.posts?.length||12))),h=a.map(((t,h)=>{const r=[t.sizes.full.width,t.sizes.full.height],n=o?i||[1,1]:r,l=n.reduce(((t,e)=>t/e));let c="behold-image-post";return"VIDEO"===t.mediaType&&(c="behold-video-post"),"CAROUSEL_ALBUM"===t.mediaType&&(c="behold-album-post"),z({type:c,props:{post:t,widgetSettings:this.widgetSettings,feedMetadata:this.feedMetadata,medianPaletteHSL:this.medianPaletteHSL,onClick:this.Y,hasRowGap:!0,isLastRow:!1,index:h,aspectRatio:n,totalPosts:a?.length||e||this.posts?.length||0},style:{width:s*l+"px","--post-aspect-ratio":l}})}));for(;h.length<t.numPosts;){const t=z({classes:"post post--placeholder",style:{width:`${s}px`,"--post-aspect-ratio":1}});h.push(t)}return h}static register(t="behold-elastic-carousel"){return customElements.get(t)||customElements.define(t,q),t}}var D=Object.freeze({__proto__:null,default:q});class N extends k{label="ErrorMessage";shadow;logoEl;styleEl;errorTitleEl;errorMessageEl;errorMessageTextEl;errorMessage;constructor(){super(),this.shadow=this.attachShadow({mode:"open"}),this.onPropChange(this.S,["errorMessage"]),this.onConnect((()=>{this.onResize(this,this,r(this.m,50,this))})),this.onConnect((()=>{this.render()}))}S({changedProp:t}){this.render()}render(){if(!this.errorMessage)return;let t='<?xml version="1.0" encoding="utf-8"?>\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\n\t viewBox="0 0 20.5 20.5" enable-background="new 0 0 20.5 20.5" xml:space="preserve">\n<g>\n\t<path fill="#010101" d="M10.2,20.5c-1.2,0-2.4-0.2-3.8-0.5c-2.9-0.7-5.3-3.1-6-6.1C0.2,12.7,0,11.4,0,10.3C0,9.2,0.1,8,0.4,6.8\n\t\tC1.1,3.6,3.7,1,6.9,0.4c2.4-0.5,4.4-0.5,6.8,0c3.3,0.7,5.8,3.2,6.5,6.5c0.2,1.1,0.4,2.3,0.4,3.3c0,1.1-0.1,2.3-0.4,3.5l0,0\n\t\tc-0.7,3.2-3.2,5.7-6.4,6.4C12.5,20.4,11.3,20.5,10.2,20.5z M10.2,1.5c-0.9,0-2,0.1-3,0.3C4.5,2.4,2.5,4.5,1.9,7.1\n\t\tc-0.2,1.1-0.4,2.2-0.4,3.1c0,1,0.1,2.2,0.4,3.4c0.6,2.4,2.5,4.4,4.9,5c2.3,0.6,4.2,0.6,6.6,0.1c2.6-0.6,4.7-2.7,5.2-5.3\n\t\tc0.2-1.1,0.3-2.1,0.3-3.2c0-1-0.1-2-0.3-3c-0.5-2.7-2.6-4.7-5.3-5.3C12.2,1.6,11.2,1.5,10.2,1.5z"/>\n</g>\n<g>\n\t<g>\n\t\t<path fill="#010101" d="M10.2,13.5c0.6,0,1,0.5,1,1.1c0,0.6-0.5,1.1-1,1.1s-1-0.5-1-1.1C9.2,14,9.7,13.5,10.2,13.5z M9.6,12.3\n\t\t\tL9.3,4.7h1.9l-0.3,7.5H9.6z"/>\n\t</g>\n</g>\n</svg>',e="Error";this.errorMessage.includes("Upgrade")&&(t='<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17.54 17.54"><path d="M8.77,17.54c-2.35,0-4.7-.81-6.33-2.44C-.81,11.84-.81,5.69,2.44,2.44,5.69-.81,11.84-.81,15.1,2.44c3.26,3.25,3.25,9.4,0,12.66-1.63,1.63-3.98,2.44-6.33,2.44ZM8.77,1.51c-1.97,0-3.94,.67-5.27,1.99C.84,6.16,.84,11.38,3.5,14.04c2.66,2.66,7.88,2.66,10.54,0,2.66-2.66,2.66-7.88,0-10.54-1.33-1.33-3.3-1.99-5.27-1.99Z"/><path d="M8.76,13.02c-.41,0-.75-.34-.75-.75V5.26c0-.41,.34-.75,.75-.75s.75,.34,.75,.75v7.01c0,.41-.34,.75-.75,.75Z"/><path d="M6.36,8.42c-.19,0-.38-.07-.53-.22-.29-.29-.29-.77,0-1.06l2.41-2.41c.29-.29,.77-.29,1.06,0s.29,.77,0,1.06l-2.41,2.41c-.15,.15-.34,.22-.53,.22Z"/><path d="M11.17,8.42c-.19,0-.38-.07-.53-.22l-2.41-2.41c-.29-.29-.29-.77,0-1.06s.77-.29,1.06,0l2.41,2.41c.29,.29,.29,.77,0,1.06-.15,.15-.34,.22-.53,.22Z"/></svg>',e="Upgrade Required"),this.logoEl=z({type:"a",classes:"logo",contents:'<?xml version="1.0" encoding="utf-8"?>\n<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\n\t viewBox="0 0 91.5 29.5" enable-background="new 0 0 91.5 29.5" xml:space="preserve">\n<g>\n\t<path fill="#3BA566" d="M12,11.7c0.8,0,1.8,0.1,2.8,0.3c1.3,0.3,2.4,1.3,2.6,2.6c0.2,1,0.3,1.9,0.3,2.8s-0.1,1.9-0.3,2.9\n\t\tc-0.3,1.3-1.3,2.3-2.6,2.6c-1,0.2-2,0.4-2.8,0.4c-0.9,0-1.9-0.1-3-0.4s-2-1.2-2.3-2.3s-0.4-2.1-0.4-3c0-0.8,0.1-1.8,0.3-2.8\n\t\tc0.3-1.3,1.3-2.4,2.6-2.6C10.2,11.9,11.2,11.7,12,11.7 M12,5.5c-1.4,0-2.8,0.2-4,0.5c-3.8,0.7-6.7,3.6-7.5,7.4\n\t\tC0.2,14.7,0,16.1,0,17.5c0,1.6,0.2,3.1,0.6,4.5c0.8,3.4,3.5,6.1,6.9,7c1.4,0.3,2.9,0.5,4.5,0.5c1.5,0,2.9-0.2,4.2-0.5\n\t\tc3.7-0.8,6.5-3.7,7.3-7.4c0.3-1.3,0.5-2.7,0.5-4.2c0-1.4-0.2-2.8-0.4-4c-0.8-3.8-3.7-6.6-7.5-7.4C14.8,5.7,13.4,5.5,12,5.5L12,5.5z\n\t\t"/>\n</g>\n<g id="type">\n\t<path fill="#FFFFFF" d="M42.2,20.8c0,2.6-1.9,4.3-5.1,4.3h-5.2c0.5-1.4,0.6-2.5,0.6-3.9v-7.7c0-1.4-0.1-2.5-0.6-3.9H37\n\t\tc2.4,0,4.7,1,4.7,3.6c0,2.1-1.4,3.4-3.1,3.9C40.5,17.5,42.2,18.5,42.2,20.8z M35.2,10.4c0,1.1-0.1,2-0.1,3v3.4h1.4\n\t\tc1.7,0,2.5-1.2,2.5-3.1c0-2.2-1-3.4-3.2-3.4C35.6,10.4,35.4,10.4,35.2,10.4z M39.5,21.3c0-2.4-1.4-3.6-3.3-3.6\n\t\tc-0.2,0-0.6,0-1.1,0.1v3.5c0,0.9,0,2,0.1,2.9c0.5,0.1,0.9,0.1,1.4,0.1C38.6,24.3,39.5,23.2,39.5,21.3z"/>\n\t<path fill="#FFFFFF" d="M52.7,19.1h-6.5c0.2,2.5,1.2,4.1,3.8,4.1c1.1,0,1.8-0.3,2.6-0.9c-0.2,1.6-1.5,3.1-3.9,3.1c-3,0-5-2.4-5-6.2\n\t\tc0-3.4,1.6-6.4,5-6.4c2.9,0,4,2.1,4,4.5C52.7,17.3,52.7,19.1,52.7,19.1z M50.2,17.3c0-2.5-0.7-3.6-1.8-3.6c-1.3,0-2.1,1.5-2.1,4.3\n\t\tv0.3h3C50,18.4,50.2,18.3,50.2,17.3z"/>\n\t<path fill="#FFFFFF" d="M64,25.2h-2.8c-0.2-1.1-0.3-2.4-0.3-3.8v-4.6c0-1.4-0.5-2.1-1.5-2.1c-0.6,0-1.3,0.2-2.1,1.2v5.6\n\t\tc0,1.3,0.1,2.3,0.6,3.6h-3.6c0.5-1.3,0.6-2.3,0.6-3.6v-8.2c0-1.5,0-2.9-0.6-4c1.1-0.3,2-0.7,3-1.2v7c0.9-1.6,2.2-2.2,3.4-2.2\n\t\tc1.6,0,2.6,1,2.6,3.4v5C63.4,22.7,63.5,23.8,64,25.2z"/>\n\t<path fill="#FFFFFF" d="M65.4,19.2c0-3.8,2-6.3,5-6.3c2.9,0,4.8,2.7,4.8,6.3c0,3.8-2,6.3-5,6.3C67.3,25.4,65.4,22.8,65.4,19.2z\n\t\t M72.4,19.9c0-3.1-0.7-6.1-2.4-6.1c-1.3,0-1.9,1.7-1.9,4.6c0,3.2,0.7,6.1,2.4,6.1C71.8,24.5,72.4,23,72.4,19.9z"/>\n\t<path fill="#FFFFFF" d="M77.3,21.5v-8.2c0-1.5,0-2.9-0.6-4c1.1-0.3,2-0.7,3-1.2v13.4c0,1.3,0.1,2.3,0.6,3.6h-3.6\n\t\tC77.2,23.8,77.3,22.8,77.3,21.5z"/>\n\t<path fill="#FFFFFF" d="M89,25.2c-0.2-0.3-0.4-0.8-0.4-1.4c-0.7,1.1-1.6,1.5-2.8,1.5c-2.2,0-4-1.9-4-5.6c0-4.4,2.4-6.8,5-6.8\n\t\tc0.7,0,1.2,0.1,1.7,0.4l0,0c0-1.4,0-2.9-0.6-3.9c1.1-0.3,2-0.7,3-1.2v13.3c0,1.3,0.1,2.2,0.6,3.6H89V25.2z M88.5,23.1v-6.6\n\t\tc0-2-0.8-2.6-1.7-2.6c-1.4,0-2.3,1.5-2.3,4.8c0,3.4,1.1,4.9,2.8,4.9C87.8,23.5,88.2,23.4,88.5,23.1z"/>\n</g>\n<g>\n\t<path fill="#FFFFFF" d="M32.3,4.7V0.1h2.2c1,0,1.6,0.7,1.6,1.5c0,0.8-0.6,1.5-1.6,1.5h-1.2v1.7H32.3z M34.3,0.9h-1.1v1.3h1.1\n\t\tC34.7,2.2,35,2,35,1.6C35,1.2,34.7,0.9,34.3,0.9z"/>\n\t<path fill="#FFFFFF" d="M39.5,0C41,0,42,1,42,2.4c0,1.4-1,2.4-2.4,2.4c-1.4,0-2.4-1-2.4-2.4C37.1,1,38.1,0,39.5,0z M39.5,0.9\n\t\tc-0.9,0-1.4,0.7-1.4,1.5c0,0.9,0.6,1.5,1.4,1.5S41,3.3,41,2.4C41,1.5,40.4,0.9,39.5,0.9z"/>\n\t<path fill="#FFFFFF" d="M46.8,4.7L46,1.5l-0.8,3.2h-1.1l-1.3-4.7h1.1l0.8,3.4l0.9-3.4h0.8l0.9,3.4l0.8-3.4h1.1l-1.3,4.7H46.8z"/>\n\t<path fill="#FFFFFF" d="M50.4,4.7V0.1h3.3v0.9h-2.3v1h2.3v0.9h-2.3v1.1h2.3v0.9H50.4z"/>\n\t<path fill="#FFFFFF" d="M57.8,4.7l-0.9-1.7h-0.7v1.7h-1V0.1h2.2c1,0,1.6,0.6,1.6,1.5c0,0.8-0.5,1.3-1,1.4l1.1,1.8H57.8z M57.2,0.9\n\t\th-1v1.3h1c0.4,0,0.7-0.3,0.7-0.6C57.9,1.2,57.6,0.9,57.2,0.9z"/>\n\t<path fill="#FFFFFF" d="M60.4,4.7V0.1h3.3v0.9h-2.3v1h2.3v0.9h-2.3v1.1h2.3v0.9H60.4z"/>\n\t<path fill="#FFFFFF" d="M65.1,4.7V0.1H67c1.5,0,2.5,0.9,2.5,2.3c0,1.4-1,2.3-2.5,2.3H65.1z M66.1,3.9H67c0.9,0,1.5-0.7,1.5-1.5\n\t\tC68.4,1.6,67.9,1,67,1h-0.8V3.9z"/>\n\t<path fill="#FFFFFF" d="M73.3,4.7V0.1h2.5c0.9,0,1.3,0.6,1.3,1.2c0,0.6-0.4,1-0.8,1.1c0.5,0.1,0.9,0.6,0.9,1.1\n\t\tc0,0.7-0.5,1.3-1.4,1.3H73.3z M74.3,2h1.2c0.3,0,0.5-0.2,0.5-0.5c0-0.3-0.2-0.5-0.5-0.5h-1.2V2z M74.3,3.9h1.3\n\t\tc0.4,0,0.6-0.2,0.6-0.6c0-0.3-0.2-0.5-0.6-0.5h-1.3V3.9z"/>\n\t<path fill="#FFFFFF" d="M79.8,4.7V2.8L78,0.1h1.1L80.3,2l1.1-1.9h1.1l-1.8,2.8v1.9H79.8z"/>\n</g>\n</svg>',attributes:{href:"https://behold.so",target:"_blank","aria-label":"behold"}}),this.errorTitleEl=z({classes:"message__title",contents:[t,e]}),this.errorMessageTextEl=z({classes:"message__inner"}),this.errorMessageTextEl.innerHTML=this.errorMessage?.replace("Upgrade your plan",'<a href="https://app.behold.so/account" target="blank">Upgrade your plan</a>'),this.errorMessageEl=z({classes:"message",contents:[this.errorTitleEl,this.errorMessageTextEl]}),this.styleEl=z({type:"style",contents:":host{align-items:center;background:#f1f1f1 url(https://behold.pictures/widget:error-background.webp) 0 no-repeat;background-size:auto 100%;border:none;border-radius:20px;box-shadow:none;box-sizing:border-box;color:#000;display:flex;height:200px;justify-content:space-between;margin:0;max-width:750px;min-width:50px;outline:none;overflow:hidden;width:100%}:host *{box-sizing:border-box}:host(.large){height:180px}:host(.medium),:host(.small){background:#f1f1f1 url(https://behold.pictures/widget:error-background-small.webp) top no-repeat;background-size:auto 186px;flex-direction:column;height:auto}.logo{align-items:center;background:linear-gradient(90deg,rgba(0,0,0,.75) 10%,rgba(0,0,0,.5) 75%,transparent);display:flex;flex-grow:0;flex-shrink:0;height:100%;justify-content:center;padding:0 10px 5px 0;width:220px}.logo svg{height:40px;width:auto}:host(.large) .logo{width:180px}:host(.large) .logo svg{height:35px}:host(.medium) .logo,:host(.small) .logo{background:linear-gradient(180deg,rgba(0,0,0,.75) 10%,rgba(0,0,0,.5) 40%,transparent);height:150px;width:100%}.message{align-items:center;display:flex;flex-direction:column;flex-grow:1;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:16px;gap:15px;justify-content:center;line-height:1.5;padding:20px 60px 20px 80px;text-align:center}.message a{color:#000;display:inline-block;text-decoration:underline}:host(.large) .message{font-size:15px;gap:10px;padding:20px 30px 20px 70px}:host(.medium) .message{font-size:16px;gap:15px;padding:40px 30px}:host(.small) .message{font-size:15px;gap:15px;padding:30px 20px}.message__title{align-items:center;display:flex;font-size:20px;font-weight:500;justify-content:center}.message__title svg{height:25px;margin-right:15px;width:25px}:host(.large) .message__title{font-size:18px}:host(.large) .message__title svg{height:20px;margin-right:10px;width:20px}:host(.medium) .message__title,:host(.small) .message__title{flex-direction:column;font-size:17px}:host(.medium) .message__title svg,:host(.small) .message__title svg{margin-bottom:7px;margin-right:0}".toString()}),this.shadow.beholdReplaceChildren(this.logoEl,this.errorMessageEl,this.styleEl)}m(t){const e=t?.borderBoxSize?.[0]?.inlineSize||t?.contentRect?.width||0;let s="xlarge";e<600&&(s="large"),e<500&&(s="medium"),e<250&&(s="small"),["small","medium","large","xlarge"].forEach((t=>{n(this,{[`${t}`]:t===s})}))}static register(t="behold-error-message"){return customElements.get(t)||customElements.define(t,N),t}}var Y=Object.freeze({__proto__:null,default:N});class J extends k{label="BeholdWidget";shadow;abortController;loadedWidget;static get observedAttributes(){return["feed-id"]}constructor(){super(),function(...t){window?.location.search.includes("behold-debug-mode")&&console.log(...t)}("v 0.5.55"),this.shadow=this.attachShadow({mode:"open"}),this.abortController=null,this.onPropChange(this.S,["widgetSettings","feedMetadata","posts","previewLoadingColors","errorMessage"],[])}attributeChangedCallback(t,e,s){"feed-id"===t&&s!==e&&this.getFeed(s)}S({changedProp:t,oldValue:e,newValue:s}){"errorMessage"!==t||e||!s?"widgetSettings"===t&&c(s,e,"type")&&s?.type?this.loadWidget(s.type):this.loadedWidget&&!d(s,e)&&(this.loadedWidget[t]=s):this.loadWidget("ErrorMessage")}async loadWidget(t){if("ResizeObserver"in window==0){const{ResizeObserver:t}=await import("./resizeObserver--rsjm-GV.js");window.BeholdResizeObserver=t}let e=null;switch(t){case"grid":e=V;break;case"galleryWall":e=I;break;case"elasticCarousel":e=q;break;case"ErrorMessage":e=N}const s=e.register();await customElements.whenDefined(s);const i=z({type:s});window?.location.search.includes("behold-debug-mode")&&console.log(Object.getPrototypeOf(i)?.constructor?.name);const o=z({type:"style",contents:":host{align-items:center;box-sizing:border-box;display:flex;flex-wrap:wrap;justify-content:center;margin:0;min-width:50px;overflow:hidden;position:relative;width:100%}:host *{box-sizing:border-box}:host([hidden]){display:none}".toString()});this.shadow.beholdReplaceChildren(i,o),this.loadedWidget=i,window?.location.search.includes("behold-debug-mode")&&console.log(Object.getPrototypeOf(this.loadedWidget)?.constructor?.name),this.widgetSettings&&(this.loadedWidget.widgetSettings=this.widgetSettings),this.feedMetadata&&(this.loadedWidget.feedMetadata=this.feedMetadata),this.posts&&(this.loadedWidget.posts=this.posts),this.loadedWidget.errorMessage=this.errorMessage||null,this.dispatchEvent(new Event("load")),window.dispatchEvent(new CustomEvent("behold:widget-loaded",{detail:{id:this["feed-id"]}}))}async getFeed(t){if(t){this.abortController&&this.abortController.abort(),this.abortController=new AbortController;try{const e=await fetch(`https://feeds.behold.so/${t}`,{mode:"cors",signal:this.abortController.signal});if(e.ok){const t=await e.json();if(!t.widgetSettings)throw new Error("JSON feeds cannot be used as a widget");if(t.widgetSettings.klaviyoWebFeedId)throw new Error("Klaviyo feeds cannot be used as an embedded widget");this.widgetSettings=t.widgetSettings,this.feedMetadata={username:t.username,profilePictureUrl:t.profilePictureUrl,website:t.website,followersCount:t.followersCount,hashtags:t.hashtags},this.posts=t.posts||t.media}else{const t=await e.text();this.errorMessage=t}}catch(t){"The user aborted a request."!==t.message&&(this.errorMessage=t.message)}}else this.errorMessage="No feed ID provided"}async importWidget(t){const{default:e}=await function(t){switch(t){case"./widgets/ElasticCarousel.ts":return Promise.resolve().then((function(){return D}));case"./widgets/ErrorMessage.ts":return Promise.resolve().then((function(){return Y}));case"./widgets/GalleryWall.ts":return Promise.resolve().then((function(){return T}));case"./widgets/Grid.ts":return Promise.resolve().then((function(){return B}));default:return new Promise((function(e,s){("function"==typeof queueMicrotask?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}(`./widgets/${t}.ts`);return e}}var Z={register:(t="behold-widget")=>{customElements.get(t)||customElements.define(t,class extends J{})},element:J};export{k as B,G as I,F as R,L as V,Z as W,a,p as b,z as c,U as d,W as e,e as f,h as g,i as h,c as i,u as p,n as s,r as t};
|
@@ -1 +0,0 @@
|
|
1
|
-
var t,e=[],n="ResizeObserver loop completed with undelivered notifications.";!function(t){t.BORDER_BOX="border-box",t.CONTENT_BOX="content-box",t.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"}(t||(t={}));var i,r=function(t){return Object.freeze(t)},o=function(t,e){this.inlineSize=t,this.blockSize=e,r(this)},u=function(){function t(t,e,n,i){return this.x=t,this.y=e,this.width=n,this.height=i,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,r(this)}return t.prototype.toJSON=function(){var t=this;return{x:t.x,y:t.y,top:t.top,right:t.right,bottom:t.bottom,left:t.left,width:t.width,height:t.height}},t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t}(),s=function(t){return t instanceof SVGElement&&"getBBox"in t},c=function(t){if(s(t)){var e=t.getBBox(),n=e.width,i=e.height;return!n&&!i}var r=t,o=r.offsetWidth,u=r.offsetHeight;return!(o||u||t.getClientRects().length)},a=function(t){var e;if(t instanceof Element)return!0;var n=null===(e=null==t?void 0:t.ownerDocument)||void 0===e?void 0:e.defaultView;return!!(n&&t instanceof n.Element)},f="undefined"!=typeof window?window:{},h=new WeakMap,v=/auto|scroll/,d=/^tb|vertical/,l=/msie|trident/i.test(f.navigator&&f.navigator.userAgent),b=function(t){return parseFloat(t||"0")},w=function(t,e,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=!1),new o((n?e:t)||0,(n?t:e)||0)},p=r({devicePixelContentBoxSize:w(),borderBoxSize:w(),contentBoxSize:w(),contentRect:new u(0,0,0,0)}),m=function(t,e){if(void 0===e&&(e=!1),h.has(t)&&!e)return h.get(t);if(c(t))return h.set(t,p),p;var n=getComputedStyle(t),i=s(t)&&t.ownerSVGElement&&t.getBBox(),o=!l&&"border-box"===n.boxSizing,a=d.test(n.writingMode||""),f=!i&&v.test(n.overflowY||""),m=!i&&v.test(n.overflowX||""),y=i?0:b(n.paddingTop),x=i?0:b(n.paddingRight),z=i?0:b(n.paddingBottom),E=i?0:b(n.paddingLeft),O=i?0:b(n.borderTopWidth),R=i?0:b(n.borderRightWidth),S=i?0:b(n.borderBottomWidth),g=E+x,B=y+z,M=(i?0:b(n.borderLeftWidth))+R,F=O+S,T=m?t.offsetHeight-F-t.clientHeight:0,k=f?t.offsetWidth-M-t.clientWidth:0,C=o?g+M:0,D=o?B+F:0,A=i?i.width:b(n.width)-C-k,I=i?i.height:b(n.height)-D-T,P=A+g+k+M,q=I+B+T+F,V=r({devicePixelContentBoxSize:w(Math.round(A*devicePixelRatio),Math.round(I*devicePixelRatio),a),borderBoxSize:w(P,q,a),contentBoxSize:w(A,I,a),contentRect:new u(E,y,A,I)});return h.set(t,V),V},y=function(e,n,i){var r=m(e,i),o=r.borderBoxSize,u=r.contentBoxSize,s=r.devicePixelContentBoxSize;switch(n){case t.DEVICE_PIXEL_CONTENT_BOX:return s;case t.BORDER_BOX:return o;default:return u}},x=function(t){var e=m(t);this.target=t,this.contentRect=e.contentRect,this.borderBoxSize=r([e.borderBoxSize]),this.contentBoxSize=r([e.contentBoxSize]),this.devicePixelContentBoxSize=r([e.devicePixelContentBoxSize])},z=function(t){if(c(t))return 1/0;for(var e=0,n=t.parentNode;n;)e+=1,n=n.parentNode;return e},E=function(){var t=1/0,n=[];e.forEach((function(e){if(0!==e.activeTargets.length){var i=[];e.activeTargets.forEach((function(e){var n=new x(e.target),r=z(e.target);i.push(n),e.lastReportedSize=y(e.target,e.observedBox),r<t&&(t=r)})),n.push((function(){e.callback.call(e.observer,i,e.observer)})),e.activeTargets.splice(0,e.activeTargets.length)}}));for(var i=0,r=n;i<r.length;i++)(0,r[i])();return t},O=function(t){e.forEach((function(e){e.activeTargets.splice(0,e.activeTargets.length),e.skippedTargets.splice(0,e.skippedTargets.length),e.observationTargets.forEach((function(n){n.isActive()&&(z(n.target)>t?e.activeTargets.push(n):e.skippedTargets.push(n))}))}))},R=function(){var t,i=0;for(O(i);e.some((function(t){return t.activeTargets.length>0}));)i=E(),O(i);return e.some((function(t){return t.skippedTargets.length>0}))&&("function"==typeof ErrorEvent?t=new ErrorEvent("error",{message:n}):((t=document.createEvent("Event")).initEvent("error",!1,!1),t.message=n),window.dispatchEvent(t)),i>0},S=[],g=function(t){if(!i){var e=0,n=document.createTextNode("");new MutationObserver((function(){return S.splice(0).forEach((function(t){return t()}))})).observe(n,{characterData:!0}),i=function(){n.textContent="".concat(e?e--:e++)}}S.push(t),i()},B=0,M={attributes:!0,characterData:!0,childList:!0,subtree:!0},F=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],T=function(t){return void 0===t&&(t=0),Date.now()+t},k=!1,C=new(function(){function t(){var t=this;this.stopped=!0,this.listener=function(){return t.schedule()}}return t.prototype.run=function(t){var e=this;if(void 0===t&&(t=250),!k){k=!0;var n,i=T(t);n=function(){var n=!1;try{n=R()}finally{if(k=!1,t=i-T(),!B)return;n?e.run(1e3):t>0?e.run(t):e.start()}},g((function(){requestAnimationFrame(n)}))}},t.prototype.schedule=function(){this.stop(),this.run()},t.prototype.observe=function(){var t=this,e=function(){return t.observer&&t.observer.observe(document.body,M)};document.body?e():f.addEventListener("DOMContentLoaded",e)},t.prototype.start=function(){var t=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),F.forEach((function(e){return f.addEventListener(e,t.listener,!0)})))},t.prototype.stop=function(){var t=this;this.stopped||(this.observer&&this.observer.disconnect(),F.forEach((function(e){return f.removeEventListener(e,t.listener,!0)})),this.stopped=!0)},t}()),D=function(t){!B&&t>0&&C.start(),!(B+=t)&&C.stop()},A=function(){function e(e,n){this.target=e,this.observedBox=n||t.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var t,e=y(this.target,this.observedBox,!0);return t=this.target,s(t)||function(t){switch(t.tagName){case"INPUT":if("image"!==t.type)break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1}(t)||"inline"!==getComputedStyle(t).display||(this.lastReportedSize=e),this.lastReportedSize.inlineSize!==e.inlineSize||this.lastReportedSize.blockSize!==e.blockSize},e}(),I=function(t,e){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=t,this.callback=e},P=new WeakMap,q=function(t,e){for(var n=0;n<t.length;n+=1)if(t[n].target===e)return n;return-1},V=function(){function t(){}return t.connect=function(t,e){var n=new I(t,e);P.set(t,n)},t.observe=function(t,n,i){var r=P.get(t),o=0===r.observationTargets.length;q(r.observationTargets,n)<0&&(o&&e.push(r),r.observationTargets.push(new A(n,i&&i.box)),D(1),C.schedule())},t.unobserve=function(t,n){var i=P.get(t),r=q(i.observationTargets,n),o=1===i.observationTargets.length;r>=0&&(o&&e.splice(e.indexOf(i),1),i.observationTargets.splice(r,1),D(-1))},t.disconnect=function(t){var e=this,n=P.get(t);n.observationTargets.slice().forEach((function(n){return e.unobserve(t,n.target)})),n.activeTargets.splice(0,n.activeTargets.length)},t}(),G=function(){function t(t){if(0===arguments.length)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if("function"!=typeof t)throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");V.connect(this,t)}return t.prototype.observe=function(t,e){if(0===arguments.length)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!a(t))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");V.observe(this,t,e)},t.prototype.unobserve=function(t){if(0===arguments.length)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!a(t))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");V.unobserve(this,t)},t.prototype.disconnect=function(){V.disconnect(this)},t.toString=function(){return"function ResizeObserver () { [polyfill code] }"},t}();export{G as ResizeObserver,x as ResizeObserverEntry,o as ResizeObserverSize};
|