@trycourier/courier-ui-inbox 1.0.6-beta → 1.0.8-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/courier-inbox-header-title.d.ts +12 -8
- package/dist/components/courier-inbox-header.d.ts +11 -8
- package/dist/components/courier-inbox-list-item-menu.d.ts +9 -7
- package/dist/components/courier-inbox-list-item.d.ts +11 -11
- package/dist/components/courier-inbox-list.d.ts +11 -5
- package/dist/components/courier-inbox-menu-button.d.ts +10 -5
- package/dist/components/courier-inbox-option-menu-item.d.ts +9 -8
- package/dist/components/courier-inbox-option-menu.d.ts +11 -8
- package/dist/components/courier-inbox-pagination-list-item.d.ts +12 -7
- package/dist/components/{courier-inbox-menu.d.ts → courier-inbox-popup-menu.d.ts} +10 -7
- package/dist/components/courier-inbox-skeleton-list-item.d.ts +10 -4
- package/dist/components/courier-inbox-skeleton-list.d.ts +7 -3
- package/dist/components/courier-inbox.d.ts +9 -7
- package/dist/components/courier-unread-count-badge.d.ts +10 -5
- package/dist/datastore/__tests__/datastore.test.d.ts +1 -0
- package/dist/datastore/datastore.d.ts +1 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1025 -849
- package/dist/index.mjs.map +1 -1
- package/dist/jest.setup.d.ts +0 -0
- package/dist/types/courier-inbox-theme.d.ts +52 -52
- package/dist/types/snapshots.d.ts +2 -2
- package/dist/utils/utils.d.ts +1 -1
- package/package.json +8 -5
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@trycourier/courier-js")):"function"==typeof define&&define.amd?define(["exports","@trycourier/courier-js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CourierUIInbox={},e.CourierJS)}(this,(function(e,t){"use strict";var n=Object.defineProperty,i=(e,t,i)=>((e,t,i)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i),o=Object.defineProperty,s=(e,t,n)=>((e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const l={500:"#171717",50010:"#1717171A",50020:"#17171733"},a={200:"#F5F5F5",400:"#3A3A3A",500:"#E5E5E5",600:"#737373"},r={500:"#FFFFFF",50010:"#FFFFFF1A",50020:"#FFFFFF33"},d={400:"#60A5FA",500:"#2563EB"},h={light:{colors:{primary:l[500],secondary:r[500],border:a[500],link:d[500],icon:l[500]},button:{cornerRadius:"4px"}},dark:{colors:{primary:r[500],secondary:l[500],border:a[400],link:d[400],icon:r[500]},button:{cornerRadius:"4px"}}},u=()=>"undefined"==typeof window?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",c=e=>{if("undefined"==typeof window)return()=>{};const t=window.matchMedia("(prefers-color-scheme: dark)"),n=t=>{e(t.matches?"dark":"light")};return t.addEventListener("change",n),()=>{t.removeEventListener("change",n)}};class v extends HTMLElement{constructor(){super(),s(this,"_currentSystemTheme"),s(this,"_systemThemeCleanup"),this._currentSystemTheme=u(),this._systemThemeCleanup=c((e=>{this._currentSystemTheme=e,this.onSystemThemeChange(e)}))}get currentSystemTheme(){return this._currentSystemTheme}disconnectedCallback(){this._systemThemeCleanup&&this._systemThemeCleanup()}onSystemThemeChange(e){}}const p={borderRadius:"4px",fontSize:"14px"},g=e=>({...p,backgroundColor:h[e].colors.secondary,textColor:h[e].colors.primary,fontWeight:"500",border:`1px solid ${h[e].colors.border}`,shadow:"light"===e?"0px 1px 2px 0px rgba(0, 0, 0, 0.06)":"0px 1px 2px 0px rgba(255, 255, 255, 0.1)"});class m extends v{constructor(e){super(),s(this,"_button"),s(this,"_style");const t=this.attachShadow({mode:"open"});this._button=document.createElement("button"),this._button.setAttribute("part","button"),this._style=document.createElement("style"),this._style.textContent=this.getStyles(e),t.appendChild(this._style),t.appendChild(this._button),this.updateButton(e),this._button.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),e.onClick&&e.onClick()}))}getStyles(e){return`\n :host {\n display: inline-block;\n }\n\n button {\n border: none;\n border-radius: ${e.borderRadius??(()=>g(this.currentSystemTheme).borderRadius)()};\n font-weight: ${e.fontWeight??(()=>g(this.currentSystemTheme).fontWeight)()};\n font-family: ${e.fontFamily??"inherit"};\n font-size: ${e.fontSize??(()=>g(this.currentSystemTheme).fontSize)()};\n padding: 6px 10px;\n cursor: pointer;\n width: 100%;\n height: 100%;\n background-color: ${e.backgroundColor??(()=>g(this.currentSystemTheme).backgroundColor)()};\n color: ${e.textColor??(()=>g(this.currentSystemTheme).textColor)()};\n border: ${e.border??(()=>g(this.currentSystemTheme).border)()};\n box-shadow: ${e.shadow??(()=>g(this.currentSystemTheme).shadow)()};\n touch-action: manipulation;\n }\n\n button:hover {\n ${e.hoverBackgroundColor?`background-color: ${e.hoverBackgroundColor};`:"filter: brightness(0.9);"}\n }\n\n button:active {\n ${e.activeBackgroundColor?`background-color: ${e.activeBackgroundColor};`:"filter: brightness(0.8);"}\n }\n\n button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n `}updateButton(e){e.text&&(this._button.textContent=e.text),this._style.textContent=this.getStyles(e)}}customElements.get("courier-button")||customElements.define("courier-button",m);const b={inbox:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.5 14.5V17C5.5 17.2812 5.71875 17.5 6 17.5H18C18.25 17.5 18.5 17.2812 18.5 17V14.5H15.9375L15.2812 15.8125C15.0938 16.25 14.6562 16.5 14.1875 16.5H9.78125C9.3125 16.5 8.875 16.25 8.6875 15.8125L8.03125 14.5H5.5ZM18.1875 13L16.6562 6.90625C16.5938 6.65625 16.4062 6.5 16.1875 6.5H7.8125C7.5625 6.5 7.375 6.65625 7.3125 6.90625L5.78125 13H8.1875C8.65625 13 9.09375 13.2812 9.3125 13.7188L9.9375 15H14.0312L14.6875 13.7188C14.875 13.2812 15.3125 13 15.7812 13H18.1875ZM4 14.25C4 14.0938 4 13.9375 4.03125 13.7812L5.84375 6.53125C6.09375 5.625 6.875 5 7.8125 5H16.1875C17.0938 5 17.9062 5.625 18.125 6.53125L19.9375 13.7812C19.9688 13.9375 20 14.0938 20 14.25V17C20 18.125 19.0938 19 18 19H6C4.875 19 4 18.125 4 17V14.25Z" fill="currentColor"/>\n</svg>',archive:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.5 6.5V8H18.5V6.5H5.5ZM5 5H19C19.5312 5 20 5.46875 20 6V8.5C20 9.0625 19.5312 9.5 19 9.5H5C4.4375 9.5 4 9.0625 4 8.5V6C4 5.46875 4.4375 5 5 5ZM9 11.75C9 11.3438 9.3125 11 9.75 11H14.25C14.6562 11 15 11.3438 15 11.75C15 12.1875 14.6562 12.5 14.25 12.5H9.75C9.3125 12.5 9 12.1875 9 11.75ZM5 17V10.5H6.5V17C6.5 17.2812 6.71875 17.5 7 17.5H17C17.25 17.5 17.5 17.2812 17.5 17V10.5H19V17C19 18.125 18.0938 19 17 19H7C5.875 19 5 18.125 5 17Z" fill="currentColor"/>\n</svg>',check:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M18.793 7.33203C19.0742 7.64453 19.0742 8.11328 18.793 8.39453L10.543 16.6445C10.2305 16.957 9.76172 16.957 9.48047 16.6445L5.23047 12.3945C4.91797 12.1133 4.91797 11.6445 5.23047 11.3633C5.51172 11.0508 5.98047 11.0508 6.26172 11.3633L9.98047 15.082L17.7305 7.33203C18.0117 7.05078 18.4805 7.05078 18.7617 7.33203H18.793Z" fill="currentColor"/>\n</svg>',filter:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5 7C5 6.59375 5.3125 6.25 5.75 6.25H18.25C18.6562 6.25 19 6.59375 19 7C19 7.4375 18.6562 7.75 18.25 7.75H5.75C5.3125 7.75 5 7.4375 5 7ZM7 12C7 11.5938 7.3125 11.25 7.75 11.25H16.25C16.6562 11.25 17 11.5938 17 12C17 12.4375 16.6562 12.75 16.25 12.75H7.75C7.3125 12.75 7 12.4375 7 12ZM14 17C14 17.4375 13.6562 17.75 13.25 17.75H10.75C10.3125 17.75 10 17.4375 10 17C10 16.5938 10.3125 16.25 10.75 16.25H13.25C13.6562 16.25 14 16.5938 14 17Z" fill="currentColor"/>\n</svg>',overflow:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M18.5117 11.9883C18.5117 12.5508 18.1992 13.0195 17.7617 13.3008C17.293 13.582 16.6992 13.582 16.2617 13.3008C15.793 13.0195 15.5117 12.5508 15.5117 11.9883C15.5117 11.457 15.793 10.9883 16.2617 10.707C16.6992 10.4258 17.293 10.4258 17.7617 10.707C18.1992 10.9883 18.5117 11.457 18.5117 11.9883ZM13.5117 11.9883C13.5117 12.5508 13.1992 13.0195 12.7617 13.3008C12.293 13.582 11.6992 13.582 11.2617 13.3008C10.793 13.0195 10.5117 12.5508 10.5117 11.9883C10.5117 11.457 10.793 10.9883 11.2617 10.707C11.6992 10.4258 12.293 10.4258 12.7617 10.707C13.1992 10.9883 13.5117 11.457 13.5117 11.9883ZM7.01172 13.4883C6.44922 13.4883 5.98047 13.207 5.69922 12.7383C5.41797 12.3008 5.41797 11.707 5.69922 11.2383C5.98047 10.8008 6.44922 10.4883 7.01172 10.4883C7.54297 10.4883 8.01172 10.8008 8.29297 11.2383C8.57422 11.707 8.57422 12.3008 8.29297 12.7383C8.01172 13.207 7.54297 13.4883 7.01172 13.4883Z" fill="currentColor"/>\n</svg>',read:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M7 6.5C6.71875 6.5 6.5 6.75 6.5 7V17C6.5 17.2812 6.71875 17.5 7 17.5H17C17.25 17.5 17.5 17.2812 17.5 17V7C17.5 6.75 17.25 6.5 17 6.5H7ZM5 7C5 5.90625 5.875 5 7 5H17C18.0938 5 19 5.90625 19 7V17C19 18.125 18.0938 19 17 19H7C5.875 19 5 18.125 5 17V7ZM15.5312 10.5312L11.5312 14.5312C11.2188 14.8438 10.75 14.8438 10.4688 14.5312L8.46875 12.5312C8.15625 12.25 8.15625 11.7812 8.46875 11.5C8.75 11.1875 9.21875 11.1875 9.53125 11.5L11 12.9688L14.4688 9.46875C14.75 9.1875 15.2188 9.1875 15.5 9.46875C15.8125 9.78125 15.8125 10.25 15.5 10.5312H15.5312Z" fill="currentColor"/>\n</svg>',archiveRead:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M7.5 6.5V15.25H16.5V6.5H7.5ZM6 15.25V6.5C6 5.6875 6.65625 5 7.5 5H16.5C17.3125 5 18 5.6875 18 6.5V15.25C18.4062 15.25 18.75 15.5938 18.75 16C18.75 16.4375 18.4062 16.75 18 16.75H6C5.5625 16.75 5.25 16.4375 5.25 16C5.25 15.5938 5.5625 15.25 6 15.25ZM5 13V14.5H4.5V17.5H19.5V14.5H19V13H19.5C20.3125 13 21 13.6875 21 14.5V17.5C21 18.3438 20.3125 19 19.5 19H4.5C3.65625 19 3 18.3438 3 17.5V14.5C3 13.6875 3.65625 13 4.5 13H5ZM15.0312 9.625L11.6875 12.9688C11.5312 13.0938 11.3438 13.1875 11.1562 13.1875C10.9375 13.1875 10.75 13.0938 10.625 12.9688L8.96875 11.2812C8.65625 11 8.65625 10.5312 8.96875 10.25C9.25 9.9375 9.71875 9.9375 10 10.25L11.1562 11.375L13.9688 8.5625C14.25 8.28125 14.7188 8.28125 15 8.5625C15.3125 8.875 15.3125 9.34375 15 9.625H15.0312Z" fill="currentColor"/>\n</svg>',unread:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M17 6.5H7C6.71875 6.5 6.5 6.75 6.5 7V17C6.5 17.2812 6.71875 17.5 7 17.5H17C17.25 17.5 17.5 17.2812 17.5 17V7C17.5 6.75 17.25 6.5 17 6.5ZM7 5H17C18.0938 5 19 5.90625 19 7V17C19 18.125 18.0938 19 17 19H7C5.875 19 5 18.125 5 17V7C5 5.90625 5.875 5 7 5Z" fill="currentColor"/>\n</svg>',unarchive:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.5 11C5.0625 11 4.75 10.6875 4.75 10.25V5.75C4.75 5.34375 5.0625 5 5.5 5C5.90625 5 6.25 5.34375 6.25 5.75V8.28125L6.875 7.53125C8.15625 6 10.0625 5 12.25 5C16.0938 5 19.25 8.15625 19.25 12C19.25 15.875 16.0938 19 12.25 19C10.6562 19 9.21875 18.5 8.03125 17.625C7.71875 17.375 7.625 16.9062 7.875 16.5625C8.125 16.2188 8.59375 16.1562 8.9375 16.4062C9.84375 17.0938 11 17.5 12.25 17.5C15.2812 17.5 17.75 15.0625 17.75 12C17.75 8.96875 15.2812 6.5 12.25 6.5C10.5312 6.5 9.03125 7.28125 8 8.5L7.15625 9.5H10C10.4062 9.5 10.75 9.84375 10.75 10.25C10.75 10.6875 10.4062 11 10 11H5.5Z" fill="currentColor"/>\n</svg>'};class _ extends HTMLElement{constructor(e,t){super(),s(this,"_color"),s(this,"_svg"),s(this,"_iconContainer"),s(this,"_style"),this._color=e??l[500],this._svg=t;const n=this.attachShadow({mode:"open"});this._iconContainer=document.createElement("div"),n.appendChild(this._iconContainer),this._style=document.createElement("style"),this._style.textContent=this.getStyles(this._color),n.appendChild(this._style),this.refresh()}getStyles(e){return`\n :host {\n display: inline-block;\n line-height: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n svg {\n width: 24px;\n height: 24px;\n color: ${e};\n }\n `}refresh(){this._svg&&(this._iconContainer.innerHTML=this._svg),this._color&&(this._style.textContent=this.getStyles(this._color))}updateColor(e){this._color=e,this.refresh()}updateSVG(e){this._svg=e,this.refresh()}}customElements.get("courier-icon")||customElements.define("courier-icon",_);class x extends HTMLElement{constructor(){super(),s(this,"link");const e=this.attachShadow({mode:"open"});this.link=document.createElement("a"),this.link.setAttribute("part","link");const t=document.createElement("style");t.textContent=`\n :host {\n display: inline-block;\n }\n\n a {\n text-decoration: none;\n border-radius: 4px;\n cursor: pointer;\n font-weight: 500;\n transition: all 0.2s ease;\n font-family: var(--courier-link-font-family, inherit);\n font-size: var(--courier-link-font-size, inherit);\n }\n\n /* Variants */\n a[data-variant="primary"][data-mode="light"] {\n color: var(--courier-link-color, ${h.light.colors.link});\n }\n\n a[data-variant="primary"][data-mode="light"]:hover {\n opacity: 0.8;\n }\n\n a[data-variant="primary"][data-mode="light"]:active {\n opacity: 0.6;\n }\n\n a[data-variant="primary"][data-mode="dark"] {\n color: var(--courier-link-color, ${h.dark.colors.link});\n }\n\n a[data-variant="primary"][data-mode="dark"]:hover {\n opacity: 0.8;\n }\n\n a[data-variant="primary"][data-mode="dark"]:active {\n opacity: 0.6;\n }\n\n a[data-underline="true"] {\n text-decoration: underline;\n }\n\n a:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n pointer-events: none;\n }\n `,e.appendChild(t),e.appendChild(this.link),this.updateVariant(),this.updateUnderline(),this.updateMode()}connectedCallback(){const e=document.createElement("slot");this.link.appendChild(e),this.updateHref()}attributeChangedCallback(e,t,n){if(t!==n)switch(e){case"href":this.updateHref();break;case"variant":case"mode":this.updateVariant();break;case"disabled":this.link.style.pointerEvents=this.hasAttribute("disabled")?"none":"auto",this.link.style.opacity=this.hasAttribute("disabled")?"0.6":"1";break;case"color":this.updateColor();break;case"underline":this.updateUnderline();break;case"target":this.updateTarget();break;case"font-family":this.updateFontFamily();break;case"font-size":this.updateFontSize()}}updateHref(){const e=this.getAttribute("href");e&&(this.link.href=e)}updateVariant(){const e=this.getAttribute("variant")||"primary",t=this.getAttribute("mode")||"light";this.link.setAttribute("data-variant",e),this.link.setAttribute("data-mode",t)}updateColor(){const e=this.getAttribute("color");e?this.link.style.setProperty("--courier-link-color",e):this.link.style.removeProperty("--courier-link-color")}updateUnderline(){const e="true"===this.getAttribute("underline");this.link.setAttribute("data-underline",e.toString())}updateMode(){const e=this.getAttribute("mode")||"light";this.link.setAttribute("data-mode",e)}updateTarget(){const e=this.getAttribute("target");e&&(this.link.target=e)}updateFontFamily(){const e=this.getAttribute("font-family");e?this.link.style.setProperty("--courier-link-font-family",e):this.link.style.removeProperty("--courier-link-font-family")}updateFontSize(){const e=this.getAttribute("font-size");e?this.link.style.setProperty("--courier-link-font-size",e):this.link.style.removeProperty("--courier-link-font-size")}}s(x,"observedAttributes",["href","variant","disabled","color","underline","mode","target","font-family","font-size"]),customElements.get("courier-link")||customElements.define("courier-link",x);class C extends v{constructor(){super(),s(this,"shadow"),this.shadow=this.attachShadow({mode:"open"})}build(e){if(null===e)return void this.shadow.replaceChildren();const t=e??this.defaultElement();this.shadow.replaceChildren(t)}defaultElement(){const e=document.createElement("div");return e.textContent="Default Element Factory",e.style.cssText="\n background-color: red;\n text-align: center;\n padding: 12px;\n ",e}}class f extends C{constructor(e){super(),s(this,"_props"),s(this,"_title"),s(this,"_button"),s(this,"_style"),s(this,"_buttonClickCallback",null),this._props=e}defaultElement(){var e,t;const n=document.createElement("div");return this._title=document.createElement("h2"),(null==(e=this._props.title)?void 0:e.text)&&(this._title.textContent=this._props.title.text),this._button=new m(this._props.button??g(this.currentSystemTheme)),this._style=document.createElement("style"),this._style.textContent=this.getStyles(this._props),n.className="container",n.appendChild(this._style),n.appendChild(this._title),n.appendChild(this._button),this.shadow.appendChild(n),null==(t=this._button)||t.addEventListener("click",(()=>{this._buttonClickCallback&&this._buttonClickCallback()})),n}onSystemThemeChange(e){this.updateStyles(this._props)}getStyles(e){var t,n,i,o;return`\n :host {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n width: 100%;\n }\n\n .container {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 16px;\n text-align: center;\n padding: 24px;\n }\n\n .container h2 {\n margin: 0;\n color: ${(null==(t=e.title)?void 0:t.textColor)??"red"};\n font-size: ${(null==(n=e.title)?void 0:n.fontSize)??"16px"};\n font-weight: ${(null==(i=e.title)?void 0:i.fontWeight)??"500"};\n font-family: ${(null==(o=e.title)?void 0:o.fontFamily)??"inherit"};\n }\n `}updateStyles(e){this._props=e,this._style&&(this._style.textContent=this.getStyles(e)),this._button&&this._button.updateButton(e.button)}setButtonClickCallback(e){this._buttonClickCallback=e}}customElements.get("courier-info-state")||customElements.define("courier-info-state",f);class y extends HTMLElement{constructor(e,t,n,i,o,l,a,r){super(),s(this,"_backgroundColor"),s(this,"_hoverBackgroundColor"),s(this,"_activeBackgroundColor"),s(this,"_borderRadius"),s(this,"_height"),s(this,"_width"),s(this,"_style"),s(this,"_button"),s(this,"_icon"),this._borderRadius=l,this._backgroundColor=n,this._hoverBackgroundColor=i,this._activeBackgroundColor=o,this._height=a,this._width=r;const d=this.attachShadow({mode:"open"});this._button=document.createElement("button"),this._button.setAttribute("part","button"),this._icon=new _(t,e),this._style=document.createElement("style"),this.refresh(),d.appendChild(this._style),this._button.appendChild(this._icon),d.appendChild(this._button)}refresh(){this._style.textContent=this.getStyles()}getStyles(){return`\n :host {\n display: inline-block;\n border-radius: ${this._borderRadius??"50%"};\n }\n\n button {\n border: none;\n border-radius: ${this._borderRadius??"50%"};\n cursor: pointer;\n width: ${this._width??"36px"};\n height: ${this._height??"36px"};\n display: flex;\n align-items: center;\n justify-content: center;\n background: ${this._backgroundColor??"transparent"};\n transition: background-color 0.2s ease;\n touch-action: manipulation;\n }\n\n button:hover {\n background-color: ${this._hoverBackgroundColor??"red"};\n }\n\n button:active {\n background-color: ${this._activeBackgroundColor??"red"};\n }\n\n button:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n }\n\n [part="icon"] {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n }\n `}updateIconColor(e){this._icon.updateColor(e)}updateIconSVG(e){this._icon.updateSVG(e)}updateBackgroundColor(e){this._backgroundColor=e,this.refresh()}updateHoverBackgroundColor(e){this._hoverBackgroundColor=e,this.refresh()}updateActiveBackgroundColor(e){this._activeBackgroundColor=e,this.refresh()}}customElements.get("courier-icon-button")||customElements.define("courier-icon-button",y);function k(e){const t={...e};return e.actions&&(t.actions=e.actions.map((e=>function(e){const t={...e};e.data&&(t.data=JSON.parse(JSON.stringify(e.data)));return t}(e)))),e.data&&(t.data=JSON.parse(JSON.stringify(e.data))),e.tags&&(t.tags=[...e.tags]),e.trackingIds&&(t.trackingIds={...e.trackingIds}),t}function S(e){return{...e,messages:e.messages.map((e=>k(e)))}}[{name:"courier-button",class:m},{name:"courier-icon",class:_},{name:"courier-link",class:x},{name:"courier-info-state",class:f},{name:"courier-icon-button",class:y}].forEach((({name:e,class:t})=>{customElements.get(e)||customElements.define(e,t)}));class w extends HTMLElement{constructor(e){super(),i(this,"_theme"),i(this,"_options",[]),i(this,"_style"),this._theme=e;const t=this.attachShadow({mode:"open"});this._style=document.createElement("style"),this._style.textContent=this.getStyles(),t.appendChild(this._style);const n=document.createElement("ul");n.className="menu",t.appendChild(n)}getStyles(){var e,t,n;const i=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.menu;return`\n :host {\n display: block;\n position: absolute;\n background: ${(null==i?void 0:i.backgroundColor)??"red"};\n border: ${(null==i?void 0:i.border)??"1px solid red"};\n border-radius: ${(null==i?void 0:i.borderRadius)??"0px"};\n box-shadow: ${(null==i?void 0:i.shadow)??"0 2px 8px red"};\n user-select: none;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s;\n overflow: hidden;\n }\n\n :host(.visible) {\n opacity: 1;\n pointer-events: auto;\n }\n\n ul.menu {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: row;\n }\n\n li.menu-item {\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n border-bottom: none;\n background: transparent;\n }\n `}setOptions(e){this._options=e,this.renderMenu()}renderMenu(){var e,t,n,i;const o=null==(e=this.shadowRoot)?void 0:e.querySelector("ul.menu");if(!o)return;o.innerHTML="";const s=null==(i=null==(n=null==(t=this._theme.inbox)?void 0:t.list)?void 0:n.item)?void 0:i.menu,l=e=>{e.stopPropagation(),e.preventDefault()};this._options.forEach((e=>{var t,n,i;const a=new y(e.icon.svg,e.icon.color,null==s?void 0:s.backgroundColor,null==(t=null==s?void 0:s.item)?void 0:t.hoverBackgroundColor,null==(n=null==s?void 0:s.item)?void 0:n.activeBackgroundColor,null==(i=null==s?void 0:s.item)?void 0:i.borderRadius),r=t=>{l(t),e.onClick()};a.addEventListener("click",r),a.addEventListener("touchstart",l),a.addEventListener("touchend",r),a.addEventListener("touchmove",l),a.addEventListener("mousedown",l),a.addEventListener("mouseup",l),o.appendChild(a)}))}show(){this.classList.add("visible")}hide(){this.classList.remove("visible")}}customElements.get("courier-list-item-menu")||customElements.define("courier-list-item-menu",w);const M=class e{constructor(){i(this,"_inboxDataSet"),i(this,"_archiveDataSet"),i(this,"_dataStoreListeners",[]),i(this,"_unreadCount"),i(this,"isPaginatingInbox",!1),i(this,"isPaginatingArchive",!1)}static get shared(){return e.instance||(e.instance=new e),e.instance}get unreadCount(){return this._unreadCount??0}get inboxDataSet(){return this._inboxDataSet??{feedType:"inbox",messages:[],canPaginate:!1,paginationCursor:null}}get archiveDataSet(){return this._archiveDataSet??{feedType:"archive",messages:[],canPaginate:!1,paginationCursor:null}}addDataStoreListener(e){this._dataStoreListeners.push(e)}removeDataStoreListener(e){this._dataStoreListeners=this._dataStoreListeners.filter((t=>t!==e))}async fetchDataSet(e){var n,i,o,s,l,a,r,d,h,u;if(e.canUseCache)switch(e.feedType){case"inbox":if(this._inboxDataSet)return this._inboxDataSet;break;case"archive":if(this._archiveDataSet)return this._archiveDataSet}const c="inbox"===e.feedType?await(null==(n=t.Courier.shared.client)?void 0:n.inbox.getMessages()):await(null==(i=t.Courier.shared.client)?void 0:i.inbox.getArchivedMessages());return{feedType:e.feedType,messages:(null==(s=null==(o=null==c?void 0:c.data)?void 0:o.messages)?void 0:s.nodes)??[],canPaginate:(null==(r=null==(a=null==(l=null==c?void 0:c.data)?void 0:l.messages)?void 0:a.pageInfo)?void 0:r.hasNextPage)??!1,paginationCursor:(null==(u=null==(h=null==(d=null==c?void 0:c.data)?void 0:d.messages)?void 0:h.pageInfo)?void 0:u.startCursor)??null}}async fetchUnreadCount(e){var n;if(e.canUseCache&&void 0!==this._unreadCount)return this._unreadCount;return await(null==(n=t.Courier.shared.client)?void 0:n.inbox.getUnreadMessageCount())??0}async load(e){var n,i,o;try{if(!(null==(n=t.Courier.shared.client)?void 0:n.options.userId))throw new Error("User is not signed in");const i=e??{feedType:"inbox",canUseCache:!0},[o,s]=await Promise.all([this.fetchDataSet(i),this.fetchUnreadCount(i)]);switch(i.feedType){case"inbox":this._inboxDataSet=o;break;case"archive":this._archiveDataSet=o}this._unreadCount=s,this._dataStoreListeners.forEach((e=>{var t,n,s,l;null==(n=(t=e.events).onDataSetChange)||n.call(t,o,i.feedType),null==(l=(s=e.events).onUnreadCountChange)||l.call(s,this._unreadCount??0)}))}catch(s){null==(o=null==(i=t.Courier.shared.client)?void 0:i.options.logger)||o.error("Error loading inbox:",s),this._dataStoreListeners.forEach((e=>{var t,n;null==(n=(t=e.events).onError)||n.call(t,s)}))}}async listenForUpdates(){var e,n;try{await this.ensureDataSetsLoaded(),await this.connectSocket()}catch(i){null==(n=null==(e=t.Courier.shared.client)?void 0:e.options.logger)||n.error("Error listening for updates:",i),this._dataStoreListeners.forEach((e=>{var t,n;null==(n=(t=e.events).onError)||n.call(t,i)}))}}async ensureDataSetsLoaded(){let e=[];this._inboxDataSet||e.push(this.load({feedType:"inbox",canUseCache:!0})),this._archiveDataSet||e.push(this.load({feedType:"archive",canUseCache:!0})),await Promise.all(e)}async connectSocket(){var e,n,i,o,s,l,a,r,d,h,u,c;const v=null==(e=t.Courier.shared.client)?void 0:e.inbox.socket;try{if(!v)return void(null==(i=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||i.info("CourierInbox socket not available"));if(null==(l=null==(o=t.Courier.shared.client)?void 0:o.options.logger)||l.info("CourierInbox socket connectionId:",null==(s=t.Courier.shared.client)?void 0:s.options.connectionId),v.isConnected)return void(null==(r=null==(a=t.Courier.shared.client)?void 0:a.options.logger)||r.info("CourierInbox socket already connected. Socket will not attempt reconnection."));v.receivedMessage=e=>{this.addMessage(e,0,"inbox")},v.receivedMessageEvent=e=>{let t;switch(e.messageId&&(t=this.getMessage({messageId:e.messageId})),e.event){case"mark-all-read":this.readAllMessages({canCallApi:!1});break;case"read":t&&this.readMessage({message:t,canCallApi:!1});break;case"unread":t&&this.unreadMessage({message:t,canCallApi:!1});break;case"opened":t&&this.openMessage({message:t,canCallApi:!1});break;case"archive":t&&this.archiveMessage({message:t,canCallApi:!1});break;case"archive-read":this.archiveReadMessages({canCallApi:!1});break;case"click":t&&this.clickMessage({message:t,canCallApi:!1});break;case"unarchive":t&&this.unarchiveMessage({message:t,canCallApi:!1})}},await v.connect(),await v.sendSubscribe(),v.keepAlive(),null==(h=null==(d=t.Courier.shared.client)?void 0:d.options.logger)||h.info("CourierInbox socket connected")}catch(p){null==(c=null==(u=t.Courier.shared.client)?void 0:u.options.logger)||c.error("Failed to connect socket:",p)}}getMessage(e){var t,n;return(null==(t=this._inboxDataSet)?void 0:t.messages.find((t=>t.messageId===e.messageId)))??(null==(n=this._archiveDataSet)?void 0:n.messages.find((t=>t.messageId===e.messageId)))}async fetchNextPageOfMessages(e){var n,i,o,s,l,a,r,d,h,u,c,v,p,g,m,b,_,x,C,f,y,k,S,w;switch(e.feedType){case"inbox":if(this.isPaginatingInbox)return null;if((null==(n=this._inboxDataSet)?void 0:n.canPaginate)&&this._inboxDataSet.paginationCursor)try{this.isPaginatingInbox=!0;const e=await(null==(i=t.Courier.shared.client)?void 0:i.inbox.getMessages({paginationLimit:t.Courier.shared.paginationLimit,startCursor:this._inboxDataSet.paginationCursor})),n={feedType:"inbox",messages:(null==(s=null==(o=null==e?void 0:e.data)?void 0:o.messages)?void 0:s.nodes)??[],canPaginate:(null==(r=null==(a=null==(l=null==e?void 0:e.data)?void 0:l.messages)?void 0:a.pageInfo)?void 0:r.hasNextPage)??!1,paginationCursor:(null==(u=null==(h=null==(d=null==e?void 0:e.data)?void 0:d.messages)?void 0:h.pageInfo)?void 0:u.startCursor)??null};return this.addPage(n),n}catch(M){return null==(v=null==(c=t.Courier.shared.client)?void 0:c.options.logger)||v.error("Error fetching next page of inbox messages:",M),null}finally{this.isPaginatingInbox=!1}break;case"archive":if(this.isPaginatingArchive)return null;if((null==(p=this._archiveDataSet)?void 0:p.canPaginate)&&this._archiveDataSet.paginationCursor)try{this.isPaginatingArchive=!0;const e=await(null==(g=t.Courier.shared.client)?void 0:g.inbox.getArchivedMessages({paginationLimit:t.Courier.shared.paginationLimit,startCursor:this._archiveDataSet.paginationCursor})),n={feedType:"archive",messages:(null==(b=null==(m=null==e?void 0:e.data)?void 0:m.messages)?void 0:b.nodes)??[],canPaginate:(null==(C=null==(x=null==(_=null==e?void 0:e.data)?void 0:_.messages)?void 0:x.pageInfo)?void 0:C.hasNextPage)??!1,paginationCursor:(null==(k=null==(y=null==(f=null==e?void 0:e.data)?void 0:f.messages)?void 0:y.pageInfo)?void 0:k.startCursor)??null};return this.addPage(n),n}catch(M){return null==(w=null==(S=t.Courier.shared.client)?void 0:S.options.logger)||w.error("Error fetching next page of archived messages:",M),null}finally{this.isPaginatingArchive=!1}}return null}canMutate(){return!!(t.Courier.shared.client&&this._inboxDataSet&&this._archiveDataSet)}async readMessage({message:e,canCallApi:n=!0}){var i,o,s;if(!this.canMutate())return;const l=this.getDatastoreSnapshot(this.unreadCount,this._inboxDataSet,this._archiveDataSet),a=this.getMessageSnapshot(e);if(!a.message.read)try{a.message.read=(new Date).toISOString(),this.applyMessageSnapshot(a),this._unreadCount=l.unreadCount-1,this._dataStoreListeners.forEach((e=>{var t,n;null==(n=(t=e.events).onUnreadCountChange)||n.call(t,this._unreadCount)})),n&&await(null==(i=t.Courier.shared.client)?void 0:i.inbox.read({messageId:e.messageId}))}catch(r){null==(s=null==(o=t.Courier.shared.client)?void 0:o.options.logger)||s.error("Error reading message:",r),this.applyDatastoreSnapshot(l)}}async unreadMessage({message:e,canCallApi:n=!0}){var i,o,s;if(!this.canMutate())return;const l=this.getDatastoreSnapshot(this.unreadCount,this._inboxDataSet,this._archiveDataSet),a=this.getMessageSnapshot(e);if(a.message.read)try{a.message.read=void 0,this.applyMessageSnapshot(a),this._unreadCount=l.unreadCount+1,this._dataStoreListeners.forEach((e=>{var t,n;null==(n=(t=e.events).onUnreadCountChange)||n.call(t,this._unreadCount)})),n&&await(null==(i=t.Courier.shared.client)?void 0:i.inbox.unread({messageId:e.messageId}))}catch(r){null==(s=null==(o=t.Courier.shared.client)?void 0:o.options.logger)||s.error("Error unreading message:",r),this.applyDatastoreSnapshot(l)}}async openMessage({message:e,canCallApi:n=!0}){var i,o,s;if(!this.canMutate())return;const l=this.getMessageSnapshot(e);if((void 0!==l.inboxIndex||void 0!==l.archiveIndex)&&!l.message.opened)try{e.opened=(new Date).toISOString(),this.applyMessageSnapshot(l),n&&await(null==(i=t.Courier.shared.client)?void 0:i.inbox.open({messageId:e.messageId}))}catch(a){this.applyMessageSnapshot(l),null==(s=null==(o=t.Courier.shared.client)?void 0:o.options.logger)||s.error("Error opening message:",a)}}async clickMessage({message:e,canCallApi:n=!0}){var i,o,s,l,a;if(this.canMutate())try{(null==(i=e.trackingIds)?void 0:i.clickTrackingId)&&n&&await(null==(s=t.Courier.shared.client)?void 0:s.inbox.click({messageId:e.messageId,trackingId:null==(o=e.trackingIds)?void 0:o.clickTrackingId}))}catch(r){null==(a=null==(l=t.Courier.shared.client)?void 0:l.options.logger)||a.error("Error clicking message:",r)}}async archiveMessage({message:e,canCallApi:n=!0}){var i,o,s,l;if(!this.canMutate())return;const a=this.getMessageSnapshot(e);if(void 0===a.inboxIndex)return;const r=this.getDatastoreSnapshot(this.unreadCount,this._inboxDataSet,this._archiveDataSet);try{if(e.archived=(new Date).toISOString(),this.removeMessage(e,a.inboxIndex,"inbox"),null==(i=this._archiveDataSet)?void 0:i.messages){const t=this.findInsertIndex(e,this._archiveDataSet);this.addMessage(e,t,"archive")}n&&await(null==(o=t.Courier.shared.client)?void 0:o.inbox.archive({messageId:e.messageId}))}catch(d){null==(l=null==(s=t.Courier.shared.client)?void 0:s.options.logger)||l.error("Error archiving message:",d),this.applyDatastoreSnapshot(r)}}async unarchiveMessage({message:e,canCallApi:n=!0}){var i,o,s,l;if(!this.canMutate())return;const a=this.getDatastoreSnapshot(this.unreadCount,this._inboxDataSet,this._archiveDataSet),r=this.getMessageSnapshot(e);if(void 0!==r.archiveIndex)try{if(r.message.archived=void 0,this.removeMessage(e,r.archiveIndex,"archive"),null==(i=this._inboxDataSet)?void 0:i.messages){const t=this.findInsertIndex(e,this._inboxDataSet);this.addMessage(e,t,"inbox")}n&&await(null==(o=t.Courier.shared.client)?void 0:o.inbox.unarchive({messageId:e.messageId}))}catch(d){null==(l=null==(s=t.Courier.shared.client)?void 0:s.options.logger)||l.error("Error unarchiving message:",d),this.applyDatastoreSnapshot(a)}}async archiveReadMessages({canCallApi:e=!0}={}){var n,i,o,s;if(!this.canMutate())return;const l=this.getDatastoreSnapshot(this.unreadCount,this._inboxDataSet,this._archiveDataSet);try{const o=(new Date).toISOString();((null==(n=this._inboxDataSet)?void 0:n.messages.filter((e=>e.read)))??[]).forEach((e=>{var t,n,i;e.archived=o;const s=null==(t=this._inboxDataSet)?void 0:t.messages.findIndex((t=>t.messageId===e.messageId));if(void 0!==s&&-1!==s&&(null==(n=this._inboxDataSet)||n.messages.splice(s,1)),null==(i=this._archiveDataSet)?void 0:i.messages){const t=this.findInsertIndex(e,this._archiveDataSet);this._archiveDataSet.messages.splice(t,0,e)}})),this._dataStoreListeners.forEach((e=>{var t,n,i,o;this._inboxDataSet&&(null==(n=(t=e.events).onDataSetChange)||n.call(t,this._inboxDataSet,"inbox")),this._archiveDataSet&&(null==(o=(i=e.events).onDataSetChange)||o.call(i,this._archiveDataSet,"archive"))})),e&&await(null==(i=t.Courier.shared.client)?void 0:i.inbox.archiveRead())}catch(a){null==(s=null==(o=t.Courier.shared.client)?void 0:o.options.logger)||s.error("Error archiving read messages:",a),this.applyDatastoreSnapshot(l)}}async archiveAllMessages({canCallApi:e=!0}={}){var n,i,o,s;if(!this.canMutate())return;const l=this.getDatastoreSnapshot(this.unreadCount,this._inboxDataSet,this._archiveDataSet);try{const o=(new Date).toISOString();null==(n=this._inboxDataSet)||n.messages.forEach((e=>{var t;if(e.archived=o,null==(t=this._archiveDataSet)?void 0:t.messages){const t=this.findInsertIndex(e,this._archiveDataSet);this._archiveDataSet.messages.splice(t,0,e)}})),this._inboxDataSet={messages:[],canPaginate:!1,paginationCursor:null,feedType:"inbox"},this._unreadCount=0,this._dataStoreListeners.forEach((e=>{var t,n,i,o,s,l;this._inboxDataSet&&(null==(n=(t=e.events).onDataSetChange)||n.call(t,this._inboxDataSet,"inbox")),this._archiveDataSet&&(null==(o=(i=e.events).onDataSetChange)||o.call(i,this._archiveDataSet,"archive")),null==(l=(s=e.events).onUnreadCountChange)||l.call(s,this._unreadCount)})),e&&await(null==(i=t.Courier.shared.client)?void 0:i.inbox.archiveAll())}catch(a){null==(s=null==(o=t.Courier.shared.client)?void 0:o.options.logger)||s.error("Error archiving all messages:",a),this.applyDatastoreSnapshot(l)}}async readAllMessages({canCallApi:e=!0}={}){var n,i,o,s,l;if(!this.canMutate())return;const a=this.getDatastoreSnapshot(this.unreadCount,this._inboxDataSet,this._archiveDataSet);try{const s=(new Date).toISOString();null==(n=this._inboxDataSet)||n.messages.forEach((e=>{e.read||(e.read=s)})),null==(i=this._archiveDataSet)||i.messages.forEach((e=>{e.read||(e.read=s)})),this._unreadCount=0,this._dataStoreListeners.forEach((e=>{var t,n,i,o,s,l;this._inboxDataSet&&(null==(n=(t=e.events).onDataSetChange)||n.call(t,this._inboxDataSet,"inbox")),this._archiveDataSet&&(null==(o=(i=e.events).onDataSetChange)||o.call(i,this._archiveDataSet,"archive")),null==(l=(s=e.events).onUnreadCountChange)||l.call(s,this._unreadCount)})),e&&await(null==(o=t.Courier.shared.client)?void 0:o.inbox.readAll())}catch(r){null==(l=null==(s=t.Courier.shared.client)?void 0:s.options.logger)||l.error("Error reading all messages:",r),this.applyDatastoreSnapshot(a)}}findInsertIndex(e,t){const n=t.messages;for(let i=0;i<n.length;i++){const t=n[i];if(t.created&&e.created&&t.created<e.created)return i}return n.length}addPage(e){switch(e.feedType){case"inbox":this._inboxDataSet&&(this._inboxDataSet.canPaginate=e.canPaginate,this._inboxDataSet.paginationCursor=e.paginationCursor,this._inboxDataSet.messages=[...this._inboxDataSet.messages,...e.messages]);break;case"archive":this._archiveDataSet&&(this._archiveDataSet.canPaginate=e.canPaginate,this._archiveDataSet.paginationCursor=e.paginationCursor,this._archiveDataSet.messages=[...this._archiveDataSet.messages,...e.messages])}this._dataStoreListeners.forEach((t=>{var n,i;return null==(i=(n=t.events).onPageAdded)?void 0:i.call(n,e,e.feedType)}))}addMessage(e,t,n){var i,o;switch(n){case"inbox":e.read||void 0===this._unreadCount||(this._unreadCount=this._unreadCount+1),null==(i=this._inboxDataSet)||i.messages.splice(t,0,e);break;case"archive":null==(o=this._archiveDataSet)||o.messages.splice(t,0,e)}this._dataStoreListeners.forEach((i=>{var o,s,l,a;null==(s=(o=i.events).onMessageAdd)||s.call(o,e,t,n),null==(a=(l=i.events).onUnreadCountChange)||a.call(l,this._unreadCount??0)}))}removeMessage(e,t,n){var i,o;switch(n){case"inbox":e.read||void 0===this._unreadCount||(this._unreadCount=this._unreadCount-1),null==(i=this._inboxDataSet)||i.messages.splice(t,1);break;case"archive":null==(o=this._archiveDataSet)||o.messages.splice(t,1)}this._dataStoreListeners.forEach((i=>{var o,s,l,a;null==(s=(o=i.events).onMessageRemove)||s.call(o,e,t,n),null==(a=(l=i.events).onUnreadCountChange)||a.call(l,this._unreadCount??0)}))}applyMessageSnapshot(e){void 0!==e.archiveIndex&&this.updateMessage(e.message,e.archiveIndex,"archive"),void 0!==e.inboxIndex&&this.updateMessage(e.message,e.inboxIndex,"inbox")}applyDatastoreSnapshot(e){const{unreadCount:t,inbox:n,archive:i}=e;this._inboxDataSet=n,this._archiveDataSet=i,this._dataStoreListeners.forEach((e=>{var o,s,l,a,r,d;null==(s=(o=e.events).onDataSetChange)||s.call(o,n,"inbox"),null==(a=(l=e.events).onDataSetChange)||a.call(l,i,"archive"),null==(d=(r=e.events).onUnreadCountChange)||d.call(r,t)}))}updateMessage(e,t,n){switch(n){case"inbox":void 0===this._unreadCount||e.archived||(e.read&&(this._unreadCount=Math.max(0,this._unreadCount-1)),e.read||(this._unreadCount=this._unreadCount+1)),this._inboxDataSet&&(this._inboxDataSet.messages[t]=e);break;case"archive":this._archiveDataSet&&(this._archiveDataSet.messages[t]=e)}this._dataStoreListeners.forEach((i=>{var o,s,l,a;null==(s=(o=i.events).onMessageUpdate)||s.call(o,e,t,n),null==(a=(l=i.events).onUnreadCountChange)||a.call(l,this._unreadCount??0)}))}getDatastoreSnapshot(e,t,n){return{unreadCount:e,inbox:S(t),archive:S(n)}}getMessageSnapshot(e){const t=this._archiveDataSet?this._archiveDataSet.messages.findIndex((t=>t.messageId===e.messageId)):void 0,n=this._inboxDataSet?this._inboxDataSet.messages.findIndex((t=>t.messageId===e.messageId)):void 0;return{message:k(e),archiveIndex:t,inboxIndex:n}}};i(M,"instance");let E=M;class T extends HTMLElement{constructor(e){super(),i(this,"_theme"),i(this,"_message",null),i(this,"_feedType","inbox"),i(this,"_isMobile",!1),i(this,"_titleElement"),i(this,"_subtitleElement"),i(this,"_timeElement"),i(this,"_style"),i(this,"_menu"),i(this,"_unreadIndicator"),i(this,"_actionsContainer"),i(this,"_longPressTimeout",null),i(this,"_isLongPress",!1),i(this,"onItemClick",null),i(this,"onItemLongPress",null),i(this,"onItemActionClick",null),this._theme=e,this._isMobile="ontouchstart"in window;const t=this.attachShadow({mode:"open"}),n=document.createElement("div");n.className="content-container",this._titleElement=document.createElement("p"),this._titleElement.setAttribute("part","title"),this._subtitleElement=document.createElement("p"),this._subtitleElement.setAttribute("part","subtitle"),this._actionsContainer=document.createElement("div"),this._actionsContainer.className="actions-container",n.appendChild(this._titleElement),n.appendChild(this._subtitleElement),n.appendChild(this._actionsContainer),this._timeElement=document.createElement("p"),this._timeElement.setAttribute("part","time"),this._unreadIndicator=document.createElement("div"),this._unreadIndicator.className="unread-indicator",this._style=document.createElement("style"),this._refreshStyles(),this._menu=new w(this._theme),this._menu.setOptions(this._getMenuOptions()),t.append(this._style,this._unreadIndicator,n,this._timeElement,this._menu);const o=e=>{e.stopPropagation(),e.preventDefault()};this._menu.addEventListener("mousedown",o),this._menu.addEventListener("pointerdown",o),this._menu.addEventListener("click",o),this.addEventListener("click",(e=>{this._menu.contains(e.target)||e.composedPath().includes(this._menu)||!this._message||!this.onItemClick||e.target instanceof _||this._isLongPress||this.onItemClick(this._message)})),this._setupHoverBehavior(),this._setupLongPressBehavior()}_setupHoverBehavior(){this._isMobile||(this.addEventListener("mouseenter",(()=>{this._isLongPress=!1,this._showMenu()})),this.addEventListener("mouseleave",(()=>this._hideMenu())))}_setupLongPressBehavior(){var e,t,n;const i=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.menu;if(!(null==i?void 0:i.enabled))return;const o=i.longPress;this.addEventListener("touchstart",(()=>{this._longPressTimeout=window.setTimeout((()=>{this._isLongPress=!0,this._showMenu(),this._message&&this.onItemLongPress&&(this.onItemLongPress(this._message),navigator.vibrate&&navigator.vibrate((null==o?void 0:o.vibrationDuration)??50)),setTimeout((()=>{this._hideMenu(),this._isLongPress=!1}),(null==o?void 0:o.displayDuration)??2e3)}),650)}),{passive:!0}),this.addEventListener("touchend",(()=>{this._longPressTimeout&&(window.clearTimeout(this._longPressTimeout),this._longPressTimeout=null)}))}setOnLongPress(e){this.onItemLongPress=e}_getMenuOptions(){var e,t,n,i,o,s,l,a,r,d,h,u,c,v,p;const g=null==(i=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.menu)?void 0:i.item;let m=[];const b="archive"===this._feedType;return b||m.push({id:(null==(o=this._message)?void 0:o.read)?"unread":"read",icon:{svg:(null==(s=this._message)?void 0:s.read)?null==(l=null==g?void 0:g.unread)?void 0:l.svg:null==(a=null==g?void 0:g.read)?void 0:a.svg,color:(null==(r=this._message)?void 0:r.read)?null==(d=null==g?void 0:g.unread)?void 0:d.color:(null==(h=null==g?void 0:g.read)?void 0:h.color)??"red"},onClick:()=>{this._message&&(this._message.read?E.shared.unreadMessage({message:this._message}):E.shared.readMessage({message:this._message}))}}),m.push({id:b?"unarchive":"archive",icon:{svg:b?null==(u=null==g?void 0:g.unarchive)?void 0:u.svg:null==(c=null==g?void 0:g.archive)?void 0:c.svg,color:b?null==(v=null==g?void 0:g.unarchive)?void 0:v.color:(null==(p=null==g?void 0:g.archive)?void 0:p.color)??"red"},onClick:()=>{this._message&&(b?E.shared.unarchiveMessage({message:this._message}):E.shared.archiveMessage({message:this._message}))}}),m}_showMenu(){var e,t,n;const i=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.menu;i&&i.enabled&&(this._menu.setOptions(this._getMenuOptions()),this._menu.style.display="block",this._menu.show(),this._timeElement.style.opacity="0")}_hideMenu(){var e,t,n;const i=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.menu;i&&i.enabled&&(this._menu.hide(),this._menu.style.display="none",this._timeElement.style.opacity="1")}_getStyles(){var e,t,n,i,o,s,l,a,r,d,h;const u=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item;return`\n :host {\n display: flex;\n flex-direction: row;\n align-items: flex-start;\n justify-content: space-between;\n border-bottom: ${(null==u?void 0:u.divider)??"1px solid red"};\n font-family: inherit;\n cursor: pointer;\n transition: background-color 0.2s ease;\n margin: 0;\n width: 100%;\n box-sizing: border-box;\n padding: 12px 20px;\n position: relative;\n background-color: ${(null==u?void 0:u.backgroundColor)??"transparent"};\n user-select: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n touch-action: manipulation;\n }\n\n /* ───────────────────────── Base hover / active ────────────────── */\n @media (hover: hover) {\n :host(:hover) {\n background-color: ${(null==u?void 0:u.hoverBackgroundColor)??"red"};\n }\n }\n :host(:active) {\n background-color: ${(null==u?void 0:u.activeBackgroundColor)??"red"};\n }\n\n /* ───────────────────────── Menu hover / active ────────────────── */\n @media (hover: hover) {\n :host(:hover):has(courier-list-item-menu:hover, courier-list-item-menu *:hover, courier-button:hover, courier-button *:hover) {\n background-color: ${(null==u?void 0:u.backgroundColor)??"transparent"};\n }\n }\n :host(:active):has(courier-list-item-menu:active, courier-list-item-menu *:active, courier-button:active, courier-button *:active) {\n background-color: ${(null==u?void 0:u.backgroundColor)??"transparent"};\n }\n\n :host(:last-child) {\n border-bottom: none;\n }\n\n .unread-indicator {\n position: absolute;\n top: 28px;\n left: 6px;\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background-color: ${(null==u?void 0:u.unreadIndicatorColor)??"red"};\n display: none;\n }\n\n :host(.unread) .unread-indicator {\n display: block;\n }\n\n .content-container {\n flex: 1;\n display: flex;\n flex-direction: column;\n margin-right: 12px;\n }\n\n p {\n margin: 0;\n overflow-wrap: break-word;\n word-break: break-word;\n hyphens: auto;\n line-height: 1.4;\n user-select: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n text-align: left;\n }\n\n p[part='title'] {\n font-family: ${(null==(n=null==u?void 0:u.title)?void 0:n.family)??"inherit"};\n font-size: ${(null==(i=null==u?void 0:u.title)?void 0:i.size)??"14px"};\n color: ${(null==(o=null==u?void 0:u.title)?void 0:o.color)??"red"};\n margin-bottom: 4px;\n }\n\n p[part='subtitle'] {\n font-family: ${(null==(s=null==u?void 0:u.subtitle)?void 0:s.family)??"inherit"};\n font-size: ${(null==(l=null==u?void 0:u.subtitle)?void 0:l.size)??"14px"};\n color: ${(null==(a=null==u?void 0:u.subtitle)?void 0:a.color)??"red"};\n }\n\n p[part='time'] {\n font-family: ${(null==(r=null==u?void 0:u.time)?void 0:r.family)??"inherit"};\n font-size: ${(null==(d=null==u?void 0:u.time)?void 0:d.size)??"14px"};\n color: ${(null==(h=null==u?void 0:u.time)?void 0:h.color)??"red"};\n text-align: right;\n white-space: nowrap;\n }\n\n courier-list-item-menu {\n z-index: 1;\n position: absolute;\n top: 8px;\n right: 8px;\n display: none; /* becomes block while visible */\n }\n\n .actions-container {\n display: flex;\n margin-top: 10px;\n flex-wrap: wrap;\n flex-direction: row;\n align-items: center;\n gap: 8px;\n display: none;\n }\n\n `}_refreshStyles(){this._style.textContent=this._getStyles()}connectedCallback(){var e,n;const i=this.getAttribute("message"),o=this.getAttribute("feed-type");if(o&&(this._feedType=o),i)try{this._message=JSON.parse(i),this._updateContent()}catch(s){null==(n=null==(e=t.Courier.shared.client)?void 0:e.options.logger)||n.error("CourierListItem – failed to parse message:",s)}}setMessage(e,t){this._message=e,this._feedType=t,this._updateContent()}setOnItemClick(e){this.onItemClick=e}setOnItemActionClick(e){this.onItemActionClick=e}setOnItemLongPress(e){this.onItemLongPress=e}_updateContent(){var e,t,n,i,o,s;if(!this._message)return this._titleElement.textContent="",void(this._subtitleElement.textContent="");this.classList.toggle("unread",!this._message.read&&"archive"!==this._feedType),this._titleElement.textContent=this._message.title||"Untitled Message",this._subtitleElement.textContent=this._message.preview||this._message.body||"",this._timeElement.textContent=function(e){if(!e.created)return"Now";const t=new Date,n=new Date(e.created),i=Math.floor((t.getTime()-n.getTime())/1e3);return i<60?`${i}s`:i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:i<604800?`${Math.floor(i/86400)}d`:i<31536e3?`${Math.floor(i/604800)}w`:`${Math.floor(i/31536e3)}y`}(this._message),this._menu.setOptions(this._getMenuOptions());const l=(null==(e=this._message)?void 0:e.actions)&&this._message.actions.length>0;this._actionsContainer.style.display=l?"flex":"none";const a=null==(i=null==(n=null==(t=this._theme.inbox)?void 0:t.list)?void 0:n.item)?void 0:i.actions;null==(s=null==(o=this._message)?void 0:o.actions)||s.forEach((e=>{var t,n,i,o;const s=new m({text:e.content,variant:"secondary",backgroundColor:null==a?void 0:a.backgroundColor,hoverBackgroundColor:null==a?void 0:a.hoverBackgroundColor,activeBackgroundColor:null==a?void 0:a.activeBackgroundColor,border:null==a?void 0:a.border,borderRadius:null==a?void 0:a.borderRadius,shadow:null==a?void 0:a.shadow,fontFamily:null==(t=null==a?void 0:a.font)?void 0:t.family,fontSize:null==(n=null==a?void 0:a.font)?void 0:n.size,fontWeight:null==(i=null==a?void 0:a.font)?void 0:i.weight,textColor:null==(o=null==a?void 0:a.font)?void 0:o.color,onClick:()=>{this._message&&this.onItemActionClick&&this.onItemActionClick(this._message,e)}});this._actionsContainer.appendChild(s)}))}}customElements.get("courier-list-item")||customElements.define("courier-list-item",T);class I extends HTMLElement{constructor(e,t){super(),i(this,"_shadow"),this._shadow=this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=this.getStyles(t),this._shadow.appendChild(n);const o=new L(e,35),s=new L(e,100),l=new L(e,82);this._shadow.appendChild(o),this._shadow.appendChild(s),this._shadow.appendChild(l)}getStyles(e){return`\n :host {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 12px;\n width: 100%;\n box-sizing: border-box;\n opacity: ${e};\n }\n `}}customElements.get("courier-inbox-skeleton-list-item")||customElements.define("courier-inbox-skeleton-list-item",I);class L extends HTMLElement{constructor(e,t){super(),i(this,"_shadow"),this._shadow=this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=this.getStyles(e,t),this._shadow.appendChild(n);const o=document.createElement("div");o.className="skeleton-item",this._shadow.appendChild(o)}getStyles(e,t){var n,i,o,s,l,a,r,d,h,u,c,v;const p=(null==(o=null==(i=null==(n=e.inbox)?void 0:n.loading)?void 0:i.animation)?void 0:o.barColor)??"#000",g=4===p.length?`#${p[1]}${p[1]}${p[2]}${p[2]}${p[3]}${p[3]}`:p,m=parseInt(g.slice(1,3),16),b=parseInt(g.slice(3,5),16),_=parseInt(g.slice(5,7),16),x=`rgba(${m}, ${b}, ${_}, 0.8)`,C=`rgba(${m}, ${b}, ${_}, 0.4)`;return`\n :host {\n display: flex;\n height: 100%;\n width: ${t}%;\n align-items: flex-start;\n justify-content: flex-start;\n }\n\n .skeleton-item {\n height: ${(null==(a=null==(l=null==(s=e.inbox)?void 0:s.loading)?void 0:l.animation)?void 0:a.barHeight)??"14px"};\n width: 100%;\n background: linear-gradient(\n 90deg,\n ${x} 25%,\n ${C} 50%,\n ${x} 75%\n );\n background-size: 200% 100%;\n animation: shimmer ${(null==(h=null==(d=null==(r=e.inbox)?void 0:r.loading)?void 0:d.animation)?void 0:h.duration)??"2s"} ease-in-out infinite;\n border-radius: ${(null==(v=null==(c=null==(u=e.inbox)?void 0:u.loading)?void 0:c.animation)?void 0:v.barBorderRadius)??"14px"};\n }\n\n @keyframes shimmer {\n 0% {\n background-position: 200% 0;\n }\n 100% {\n background-position: -200% 0;\n }\n }\n `}}customElements.get("courier-skeleton-animated-row")||customElements.define("courier-skeleton-animated-row",L);class D extends C{constructor(e){super(),i(this,"_theme"),this._theme=e}defaultElement(){const e=document.createElement("div");e.className="list";const t=document.createElement("style");t.textContent=this.getStyles(),e.appendChild(t);for(let n=0;n<3;n++){const t=new I(this._theme,1/(n+1));e.appendChild(t)}return this.shadow.appendChild(e),e}getStyles(){var e,t;return`\n :host {\n display: flex;\n height: 100%;\n width: 100%;\n align-items: flex-start;\n justify-content: flex-start;\n overflow: hidden;\n }\n\n .list {\n display: flex;\n flex-direction: column;\n gap: 8px;\n width: 100%;\n overflow: hidden;\n }\n\n .list > * {\n border-bottom: ${(null==(t=null==(e=this._theme.inbox)?void 0:e.loading)?void 0:t.divider)??"1px solid red"};\n }\n\n .list > *:last-child {\n border-bottom: none;\n }\n `}}customElements.get("courier-inbox-skeleton-list")||customElements.define("courier-inbox-skeleton-list",D);class A extends HTMLElement{constructor(e){super(),i(this,"skeletonLoadingList"),i(this,"observer"),i(this,"customItem"),i(this,"onPaginationTrigger"),this.onPaginationTrigger=e.onPaginationTrigger,this.customItem=e.customItem;const t=this.attachShadow({mode:"open"}),n=document.createElement("style");if(n.textContent=this.getStyles(),t.appendChild(n),this.customItem)t.appendChild(this.customItem);else{const n=document.createElement("div");n.className="skeleton-container",this.skeletonLoadingList=new D(e.theme),this.skeletonLoadingList.build(void 0),n.appendChild(this.skeletonLoadingList),t.appendChild(n)}this.observer=new IntersectionObserver((e=>{e.forEach((e=>{e.isIntersecting&&this.onPaginationTrigger()}))})),this.observer.observe(this)}getStyles(){return"\n :host {\n padding: 0;\n margin: 0;\n box-sizing: border-box;\n }\n\n .skeleton-container {\n height: 150%;\n }\n "}disconnectedCallback(){this.observer.disconnect()}}customElements.get("courier-inbox-pagination-list-item")||customElements.define("courier-inbox-pagination-list-item",A);class B extends HTMLElement{constructor(e){super(),i(this,"_themeSubscription"),i(this,"_messages",[]),i(this,"_feedType","inbox"),i(this,"_isLoading",!0),i(this,"_error",null),i(this,"_canPaginate",!1),i(this,"_onMessageClick",null),i(this,"_onMessageActionClick",null),i(this,"_onMessageLongPress",null),i(this,"_onRefresh"),i(this,"_onPaginationTrigger"),i(this,"_listItemFactory"),i(this,"_paginationItemFactory"),i(this,"_loadingStateFactory"),i(this,"_emptyStateFactory"),i(this,"_errorStateFactory"),this._themeSubscription=e.themeManager.subscribe((e=>{this.refreshTheme()})),this._onRefresh=e.onRefresh,this._onPaginationTrigger=e.onPaginationTrigger,this._onMessageClick=e.onMessageClick,this._onMessageActionClick=e.onMessageActionClick,this._onMessageLongPress=e.onMessageLongPress;const t=this.attachShadow({mode:"open"}),n=document.createElement("style");n.textContent=this.getStyles(),t.appendChild(n)}get messages(){return this._messages}getStyles(){var e;const t=null==(e=this._themeSubscription.manager.getTheme().inbox)?void 0:e.list;return`\n :host {\n flex: 1;\n width: 100%;\n background-color: ${(null==t?void 0:t.backgroundColor)??r[500]};\n }\n\n ul {\n list-style: none;\n padding: 0;\n margin: 0;\n height: 100%;\n }\n `}reset(){for(var e,t;null==(e=this.shadowRoot)?void 0:e.firstChild;)this.shadowRoot.removeChild(this.shadowRoot.firstChild);const n=document.createElement("style");n.textContent=this.getStyles(),null==(t=this.shadowRoot)||t.appendChild(n)}setDataSet(e){this._messages=[...e.messages],this._canPaginate=Boolean(e.canPaginate),this._error=null,this._isLoading=!1,this.render()}addPage(e){this._messages=[...this._messages,...e.messages],this._canPaginate=Boolean(e.canPaginate),this._error=null,this._isLoading=!1,this.render()}addMessage(e,t=0){this._messages.splice(t,0,e),this.render()}removeMessage(e=0){this._messages.splice(e,1),this.render()}updateMessage(e,t=0){this._messages[t]=e,this.render()}setFeedType(e){this._feedType=e,this._error=null,this._isLoading=!0,this.render()}setLoading(e){this._error=null,this._isLoading=e,this.render()}setError(e){this._error=e,this._isLoading=!1,this._messages=[],this.render()}setErrorNoClient(){this.setError(new Error("No user signed in"))}handleRetry(){this._onRefresh()}handleRefresh(){this._onRefresh()}render(){var e,t,n,i,o,s,l,a,r,d,h,u,c,v,p,g,m,b,_,x,C,y,k,S,w,M,E,I,L,B,P,$,F,H,R,z,O,V,N,U,Z,j,G,J,W,q,X,Y,K,Q,ee,te,ne,ie,oe,se,le,ae;this.reset();const re=this._themeSubscription.manager.getTheme();if(this._error){const T=null==(e=re.inbox)?void 0:e.error,I=new f({title:{text:(null==(t=null==T?void 0:T.title)?void 0:t.text)??this._error.message,textColor:null==(i=null==(n=null==T?void 0:T.title)?void 0:n.font)?void 0:i.color,fontFamily:null==(s=null==(o=null==T?void 0:T.title)?void 0:o.font)?void 0:s.family,fontSize:null==(a=null==(l=null==T?void 0:T.title)?void 0:l.font)?void 0:a.size,fontWeight:null==(d=null==(r=null==T?void 0:T.title)?void 0:r.font)?void 0:d.weight},button:{text:null==(h=null==T?void 0:T.button)?void 0:h.text,backgroundColor:null==(u=null==T?void 0:T.button)?void 0:u.backgroundColor,hoverBackgroundColor:null==(c=null==T?void 0:T.button)?void 0:c.hoverBackgroundColor,activeBackgroundColor:null==(v=null==T?void 0:T.button)?void 0:v.activeBackgroundColor,textColor:null==(g=null==(p=null==T?void 0:T.button)?void 0:p.font)?void 0:g.color,fontFamily:null==(b=null==(m=null==T?void 0:T.button)?void 0:m.font)?void 0:b.family,fontSize:null==(x=null==(_=null==T?void 0:T.button)?void 0:_.font)?void 0:x.size,fontWeight:null==(y=null==(C=null==T?void 0:T.button)?void 0:C.font)?void 0:y.weight,shadow:null==(k=null==T?void 0:T.button)?void 0:k.shadow,border:null==(S=null==T?void 0:T.button)?void 0:S.border,borderRadius:null==(w=null==T?void 0:T.button)?void 0:w.borderRadius}});return I.build(null==(M=this._errorStateFactory)?void 0:M.call(this,{feedType:this._feedType,error:this._error})),I.setButtonClickCallback((()=>this.handleRetry())),void(null==(E=this.shadowRoot)||E.appendChild(I))}if(this._isLoading){const e=new D(re);return e.build(null==(I=this._loadingStateFactory)?void 0:I.call(this,{feedType:this._feedType})),void(null==(L=this.shadowRoot)||L.appendChild(e))}if(0===this._messages.length){const e=null==(B=re.inbox)?void 0:B.empty,t=new f({title:{text:(null==(P=null==e?void 0:e.title)?void 0:P.text)??`No ${this._feedType} messages yet`,textColor:null==(F=null==($=null==e?void 0:e.title)?void 0:$.font)?void 0:F.color,fontFamily:null==(R=null==(H=null==e?void 0:e.title)?void 0:H.font)?void 0:R.family,fontSize:null==(O=null==(z=null==e?void 0:e.title)?void 0:z.font)?void 0:O.size,fontWeight:null==(N=null==(V=null==e?void 0:e.title)?void 0:V.font)?void 0:N.weight},button:{text:null==(U=null==e?void 0:e.button)?void 0:U.text,backgroundColor:null==(Z=null==e?void 0:e.button)?void 0:Z.backgroundColor,hoverBackgroundColor:null==(j=null==e?void 0:e.button)?void 0:j.hoverBackgroundColor,activeBackgroundColor:null==(G=null==e?void 0:e.button)?void 0:G.activeBackgroundColor,textColor:null==(W=null==(J=null==e?void 0:e.button)?void 0:J.font)?void 0:W.color,fontFamily:null==(X=null==(q=null==e?void 0:e.button)?void 0:q.font)?void 0:X.family,fontSize:null==(K=null==(Y=null==e?void 0:e.button)?void 0:Y.font)?void 0:K.size,fontWeight:null==(ee=null==(Q=null==e?void 0:e.button)?void 0:Q.font)?void 0:ee.weight,shadow:null==(te=null==e?void 0:e.button)?void 0:te.shadow,border:null==(ne=null==e?void 0:e.button)?void 0:ne.border,borderRadius:null==(ie=null==e?void 0:e.button)?void 0:ie.borderRadius}});return t.build(null==(oe=this._emptyStateFactory)?void 0:oe.call(this,{feedType:this._feedType})),t.setButtonClickCallback((()=>this.handleRefresh())),void(null==(se=this.shadowRoot)||se.appendChild(t))}const de=document.createElement("ul");if(null==(le=this.shadowRoot)||le.appendChild(de),this._messages.forEach(((e,t)=>{if(this._listItemFactory)return void de.appendChild(this._listItemFactory({message:e,index:t}));const n=new T(re);n.setMessage(e,this._feedType),n.setOnItemClick((e=>{var n;return null==(n=this._onMessageClick)?void 0:n.call(this,e,t)})),n.setOnItemActionClick(((e,n)=>{var i;return null==(i=this._onMessageActionClick)?void 0:i.call(this,e,n,t)})),n.setOnItemLongPress((e=>{var n;return null==(n=this._onMessageLongPress)?void 0:n.call(this,e,t)})),de.appendChild(n)})),this._canPaginate){const e=new A({theme:re,customItem:null==(ae=this._paginationItemFactory)?void 0:ae.call(this,{feedType:this._feedType}),onPaginationTrigger:()=>{var e;return null==(e=this._onPaginationTrigger)?void 0:e.call(this,this._feedType)}});de.appendChild(e)}}setLoadingStateFactory(e){this._loadingStateFactory=e,this.render()}setEmptyStateFactory(e){this._emptyStateFactory=e,this.render()}setErrorStateFactory(e){this._errorStateFactory=e,this.render()}setListItemFactory(e){this._listItemFactory=e,this.render()}setPaginationItemFactory(e){this._paginationItemFactory=e,this.render()}refreshTheme(){this.render()}disconnectedCallback(){this._themeSubscription.unsubscribe()}}customElements.get("courier-inbox-list")||customElements.define("courier-inbox-list",B);class P extends HTMLElement{constructor(e){super(),i(this,"_option"),i(this,"_isSelected"),i(this,"_content"),i(this,"_itemIcon"),i(this,"_title"),i(this,"_selectionIcon"),i(this,"_style"),i(this,"_themeManager"),this._option=e.option,this._isSelected=e.isSelected,this._themeManager=e.themeManager;const t=this.attachShadow({mode:"open"});this._style=document.createElement("style"),this._content=document.createElement("div"),this._content.className="menu-item",this._itemIcon=new _(this._option.icon.svg??b.inbox),this._itemIcon.setAttribute("size","16"),this._title=document.createElement("p"),this._title.textContent=this._option.text;const n=document.createElement("div");n.className="spacer",this._selectionIcon=new _(b.check),this._content.appendChild(this._itemIcon),this._content.appendChild(this._title),this._content.appendChild(n),e.selectable&&this._content.appendChild(this._selectionIcon),t.appendChild(this._style),t.appendChild(this._content),this._selectionIcon.style.display=this._isSelected?"block":"none",this.refreshTheme()}getStyles(){var e,t,n,i,o,s,l,a,r,d,h,u,c,v,p,g,m,b,_,x,C,f,y,k,S,w,M,E,T,I,L,D,A,B;const P=this._themeManager.getTheme();return`\n :host {\n display: flex;\n flex-direction: row;\n padding: 6px 12px;\n cursor: pointer;\n }\n\n :host(:hover) {\n background-color: ${(null==(o=null==(i=null==(n=null==(t=null==(e=P.inbox)?void 0:e.header)?void 0:t.menus)?void 0:n.popup)?void 0:i.list)?void 0:o.hoverBackgroundColor)??"red"};\n }\n\n :host(:active) {\n background-color: ${(null==(d=null==(r=null==(a=null==(l=null==(s=P.inbox)?void 0:s.header)?void 0:l.menus)?void 0:a.popup)?void 0:r.list)?void 0:d.activeBackgroundColor)??"red"};\n }\n\n .menu-item {\n display: flex;\n align-items: center;\n width: 100%;\n gap: 12px;\n }\n\n .spacer {\n flex: 1;\n }\n\n p {\n margin: 0;\n font-family: ${(null==(g=null==(p=null==(v=null==(c=null==(u=null==(h=P.inbox)?void 0:h.header)?void 0:u.menus)?void 0:c.popup)?void 0:v.list)?void 0:p.font)?void 0:g.family)??"inherit"};\n font-weight: ${(null==(f=null==(C=null==(x=null==(_=null==(b=null==(m=P.inbox)?void 0:m.header)?void 0:b.menus)?void 0:_.popup)?void 0:x.list)?void 0:C.font)?void 0:f.weight)??"inherit"};\n font-size: ${(null==(E=null==(M=null==(w=null==(S=null==(k=null==(y=P.inbox)?void 0:y.header)?void 0:k.menus)?void 0:S.popup)?void 0:w.list)?void 0:M.font)?void 0:E.size)??"14px"};\n color: ${(null==(B=null==(A=null==(D=null==(L=null==(I=null==(T=P.inbox)?void 0:T.header)?void 0:I.menus)?void 0:L.popup)?void 0:D.list)?void 0:A.font)?void 0:B.color)??"red"};\n white-space: nowrap;\n }\n\n .check-icon {\n display: none;\n }\n `}refreshTheme(){var e,t,n,i;this._style.textContent=this.getStyles(),this._selectionIcon.updateColor((null==(e=this._option.selectionIcon)?void 0:e.color)??"red"),this._selectionIcon.updateSVG((null==(t=this._option.selectionIcon)?void 0:t.svg)??b.check),this._title.textContent=this._option.text??"Missing Text",this._itemIcon.updateColor((null==(n=this._option.icon)?void 0:n.color)??"red"),this._itemIcon.updateSVG((null==(i=this._option.icon)?void 0:i.svg)??b.inbox)}}customElements.get("courier-inbox-filter-menu-item")||customElements.define("courier-inbox-filter-menu-item",P);class $ extends HTMLElement{constructor(e,t,n,o,s){super(),i(this,"_themeSubscription"),i(this,"_type"),i(this,"_selectedIndex",0),i(this,"_options"),i(this,"_selectable"),i(this,"_onMenuOpen"),i(this,"_menuButton"),i(this,"_menu"),i(this,"_style"),this._type=t,this._selectable=n,this._options=o,this._selectedIndex=0,this._onMenuOpen=s;const l=this.attachShadow({mode:"open"});this._menuButton=new y("filters"===t?b.filter:b.overflow),this._menu=document.createElement("div"),this._menu.className=`menu ${t}`,this._style=document.createElement("style"),l.appendChild(this._style),l.appendChild(this._menuButton),l.appendChild(this._menu),this._menuButton.addEventListener("click",this.toggleMenu.bind(this)),document.addEventListener("click",this.handleOutsideClick.bind(this)),this._themeSubscription=e.subscribe((e=>{this.refreshTheme()})),this.refreshTheme()}getStyles(){var e,t,n,i,o,s,l,a,r,d,h,u,c,v,p,g,m,b,_,x,C;const f=this._themeSubscription.manager.getTheme();return`\n :host {\n position: relative;\n display: inline-block;\n }\n\n .menu {\n display: none;\n position: absolute;\n top: 42px;\n right: -6px;\n border-radius: ${(null==(i=null==(n=null==(t=null==(e=f.inbox)?void 0:e.header)?void 0:t.menus)?void 0:n.popup)?void 0:i.borderRadius)??"6px"};\n border: ${(null==(a=null==(l=null==(s=null==(o=f.inbox)?void 0:o.header)?void 0:s.menus)?void 0:l.popup)?void 0:a.border)??"1px solid red"};\n background: ${(null==(u=null==(h=null==(d=null==(r=f.inbox)?void 0:r.header)?void 0:d.menus)?void 0:h.popup)?void 0:u.backgroundColor)??"red"};\n box-shadow: ${(null==(g=null==(p=null==(v=null==(c=f.inbox)?void 0:c.header)?void 0:v.menus)?void 0:p.popup)?void 0:g.shadow)??"0 4px 12px 0 red"};\n z-index: 1000;\n min-width: 200px;\n overflow: hidden;\n padding: 4px 0;\n }\n\n courier-inbox-filter-menu-item {\n border-bottom: ${(null==(C=null==(x=null==(_=null==(b=null==(m=f.inbox)?void 0:m.header)?void 0:b.menus)?void 0:_.popup)?void 0:x.list)?void 0:C.divider)??"none"};\n }\n\n courier-inbox-filter-menu-item:last-child {\n border-bottom: none;\n }\n `}refreshTheme(){var e,t,n,i,o,s;this._style.textContent=this.getStyles();const l=null==(t=null==(e=this._themeSubscription.manager.getTheme().inbox)?void 0:e.header)?void 0:t.menus,a="filters"===this._type,r=a?null==(n=null==l?void 0:l.filters)?void 0:n.button:null==(i=null==l?void 0:l.actions)?void 0:i.button,d=a?b.filter:b.overflow;this._menuButton.updateIconSVG((null==(o=null==r?void 0:r.icon)?void 0:o.svg)??d),this._menuButton.updateIconColor((null==(s=null==r?void 0:r.icon)?void 0:s.color)??"red"),this._menuButton.updateBackgroundColor((null==r?void 0:r.backgroundColor)??"transparent"),this._menuButton.updateHoverBackgroundColor((null==r?void 0:r.hoverBackgroundColor)??"red"),this._menuButton.updateActiveBackgroundColor((null==r?void 0:r.activeBackgroundColor)??"red"),this.refreshMenuItems()}setOptions(e){this._options=e,this.refreshMenuItems()}refreshMenuItems(){this._menu.innerHTML="",this._options.forEach(((e,t)=>{const n=new P({option:e,selectable:this._selectable,isSelected:this._selectedIndex===t,themeManager:this._themeSubscription.manager});n.addEventListener("click",(()=>{this._selectedIndex=t,e.onClick(e),this.refreshMenuItems(),this.closeMenu()})),this._menu.appendChild(n)}))}toggleMenu(e){e.stopPropagation();const t="block"!==this._menu.style.display;this._menu.style.display=t?"block":"none",t&&this._onMenuOpen()}handleOutsideClick(e){this.contains(e.target)||this.closeMenu()}closeMenu(){this._menu.style.display="none"}selectOption(e){this._selectedIndex=this._options.findIndex((t=>t.id===e.id)),this.refreshMenuItems()}disconnectedCallback(){this._themeSubscription.unsubscribe()}}customElements.get("courier-inbox-option-menu")||customElements.define("courier-inbox-option-menu",$);class F extends HTMLElement{constructor(e){super(),i(this,"_themeSubscription"),i(this,"_location"),i(this,"_count",0),i(this,"_badge"),i(this,"_style"),this._location=e.location,this._themeSubscription=e.themeBus.subscribe((e=>{this.refreshTheme(this._location)}));const t=this.attachShadow({mode:"open"});this._badge=document.createElement("span"),this._badge.className="unread-badge",this._style=document.createElement("style"),this._style.textContent=this.getStyles(this._location),t.appendChild(this._style),t.appendChild(this._badge)}getStyles(e){var t,n,i,o,s,l,a;const r=this._themeSubscription.manager.getTheme(),d="button"===e?null==(n=null==(t=r.popup)?void 0:t.button)?void 0:n.unreadIndicator:null==(s=null==(o=null==(i=r.inbox)?void 0:i.header)?void 0:o.filters)?void 0:s.unreadIndicator,h=null==d?void 0:d.backgroundColor,u=null==d?void 0:d.borderRadius;return`\n :host {\n display: inline-block;\n }\n\n .unread-badge {\n background-color: ${h};\n color: ${null==(l=null==d?void 0:d.font)?void 0:l.color};\n border-radius: ${u};\n padding: 4px 8px;\n font-size: ${null==(a=null==d?void 0:d.font)?void 0:a.size};\n text-align: center;\n display: none;\n pointer-events: none;\n }\n `}setCount(e){this._count=e,this.updateBadge()}refreshTheme(e){this._location=e,this.updateBadge()}updateBadge(){this._style.textContent=this.getStyles(this._location),this._count>0?(this._badge.textContent=this._count.toString(),this._badge.style.display="block"):this._badge.style.display="none"}disconnectedCallback(){this._themeSubscription.unsubscribe()}}customElements.get("courier-unread-count-badge")||customElements.define("courier-unread-count-badge",F);class H extends HTMLElement{constructor(e,t){super(),i(this,"_themeSubscription"),i(this,"_option"),i(this,"_feedType"),i(this,"_titleElement"),i(this,"_iconElement"),i(this,"_unreadBadge"),i(this,"_container"),i(this,"_style"),this._option=t;const n=this.attachShadow({mode:"open"});this._style=document.createElement("style"),this._container=document.createElement("div"),this._container.className="title-section",this._iconElement=new _(void 0,this._option.icon.svg),this._titleElement=document.createElement("h2"),this._unreadBadge=new F({themeBus:e,location:"header"}),this._container.appendChild(this._iconElement),this._container.appendChild(this._titleElement),this._container.appendChild(this._unreadBadge),n.appendChild(this._style),n.appendChild(this._container),this._themeSubscription=e.subscribe((e=>{this.refreshTheme(this._feedType??"inbox")})),this.refreshTheme(this._feedType??"inbox")}getStyles(){var e,t,n,i,o,s,l,a,r,d,h,u,c,v,p,g;const m=this._themeSubscription.manager.getTheme();return`\n .title-section {\n display: flex;\n align-items: center;\n gap: 8px;\n position: relative;\n }\n\n courier-icon {\n display: flex;\n align-items: center;\n }\n\n h2 {\n margin: 0;\n font-family: ${(null==(i=null==(n=null==(t=null==(e=m.inbox)?void 0:e.header)?void 0:t.filters)?void 0:n.font)?void 0:i.family)??"inherit"};\n font-size: ${(null==(a=null==(l=null==(s=null==(o=m.inbox)?void 0:o.header)?void 0:s.filters)?void 0:l.font)?void 0:a.size)??"18px"};\n font-weight: ${(null==(u=null==(h=null==(d=null==(r=m.inbox)?void 0:r.header)?void 0:d.filters)?void 0:h.font)?void 0:u.weight)??"500"};\n color: ${(null==(g=null==(p=null==(v=null==(c=m.inbox)?void 0:c.header)?void 0:v.filters)?void 0:p.font)?void 0:g.color)??"red"};\n }\n\n courier-unread-count-badge {\n margin-left: 4px;\n }\n `}refreshTheme(e){this._feedType=e,this._style.textContent=this.getStyles(),this._unreadBadge.refreshTheme("header"),this.updateFilter()}updateSelectedOption(e,t,n){this._option=e,this._feedType=t,this._unreadBadge.setCount(n),this.updateFilter()}updateFilter(){var e,t,n,i,o,s,l,a,r,d,h,u,c,v,p,g,m,_,x,C,f,y,k,S,w,M,E,T;const I=this._themeSubscription.manager.getTheme();switch(this._feedType){case"inbox":this._titleElement.textContent=(null==(i=null==(n=null==(t=null==(e=I.inbox)?void 0:e.header)?void 0:t.filters)?void 0:n.inbox)?void 0:i.text)??"Inbox",this._iconElement.updateSVG((null==(r=null==(a=null==(l=null==(s=null==(o=I.inbox)?void 0:o.header)?void 0:s.filters)?void 0:l.inbox)?void 0:a.icon)?void 0:r.svg)??b.inbox),this._iconElement.updateColor((null==(v=null==(c=null==(u=null==(h=null==(d=I.inbox)?void 0:d.header)?void 0:h.filters)?void 0:u.inbox)?void 0:c.icon)?void 0:v.color)??"red");break;case"archive":this._titleElement.textContent=(null==(_=null==(m=null==(g=null==(p=I.inbox)?void 0:p.header)?void 0:g.filters)?void 0:m.archive)?void 0:_.text)??"Archive",this._iconElement.updateSVG((null==(k=null==(y=null==(f=null==(C=null==(x=I.inbox)?void 0:x.header)?void 0:C.filters)?void 0:f.archive)?void 0:y.icon)?void 0:k.svg)??b.archive),this._iconElement.updateColor((null==(T=null==(E=null==(M=null==(w=null==(S=I.inbox)?void 0:S.header)?void 0:w.filters)?void 0:M.archive)?void 0:E.icon)?void 0:T.color)??"red")}}disconnectedCallback(){this._themeSubscription.unsubscribe()}}customElements.get("courier-inbox-header-title")||customElements.define("courier-inbox-header-title",H);class R extends C{constructor(e){super(),i(this,"_themeSubscription"),i(this,"_feedType","inbox"),i(this,"_unreadCount",0),i(this,"_titleSection"),i(this,"_filterMenu"),i(this,"_actionMenu"),i(this,"_style"),i(this,"_onFeedTypeChange"),this._themeSubscription=e.themeManager.subscribe((e=>{this.refreshTheme()})),this._onFeedTypeChange=e.onFeedTypeChange}getFilterOptions(){var e,t,n,i,o,s,l,a,r,d,h,u,c,v,p,g,m,_,x,C,f,y,k,S,w,M,E,T,I,L,D,A,B,P,$,F,H;const R=this._themeSubscription.manager.getTheme(),z=null==(n=null==(t=null==(e=R.inbox)?void 0:e.header)?void 0:t.menus)?void 0:n.filters;return[{id:"inbox",text:(null==(i=null==z?void 0:z.inbox)?void 0:i.text)??"Inbox",icon:{color:(null==(s=null==(o=null==z?void 0:z.inbox)?void 0:o.icon)?void 0:s.color)??"red",svg:(null==(a=null==(l=null==z?void 0:z.inbox)?void 0:l.icon)?void 0:a.svg)??b.inbox},selectionIcon:{color:(null==(v=null==(c=null==(u=null==(h=null==(d=null==(r=R.inbox)?void 0:r.header)?void 0:d.menus)?void 0:h.popup)?void 0:u.list)?void 0:c.selectionIcon)?void 0:v.color)??"red",svg:(null==(C=null==(x=null==(_=null==(m=null==(g=null==(p=R.inbox)?void 0:p.header)?void 0:g.menus)?void 0:m.popup)?void 0:_.list)?void 0:x.selectionIcon)?void 0:C.svg)??b.check},onClick:e=>{this.handleOptionMenuItemClick("inbox",e)}},{id:"archive",text:(null==(f=null==z?void 0:z.archive)?void 0:f.text)??"Archive",icon:{color:(null==(k=null==(y=null==z?void 0:z.archive)?void 0:y.icon)?void 0:k.color)??"red",svg:(null==(w=null==(S=null==z?void 0:z.archive)?void 0:S.icon)?void 0:w.svg)??b.archive},selectionIcon:{color:(null==(D=null==(L=null==(I=null==(T=null==(E=null==(M=R.inbox)?void 0:M.header)?void 0:E.menus)?void 0:T.popup)?void 0:I.list)?void 0:L.selectionIcon)?void 0:D.color)??"red",svg:(null==(H=null==(F=null==($=null==(P=null==(B=null==(A=R.inbox)?void 0:A.header)?void 0:B.menus)?void 0:P.popup)?void 0:$.list)?void 0:F.selectionIcon)?void 0:H.svg)??b.check},onClick:e=>{this.handleOptionMenuItemClick("archive",e)}}]}getActionOptions(){var e,t,n,i,o,s,l,a,r,d,h,u,c,v,p,g,m,_;const x=null==(n=null==(t=null==(e=this._themeSubscription.manager.getTheme().inbox)?void 0:e.header)?void 0:t.menus)?void 0:n.actions;return[{id:"markAllRead",text:(null==(i=null==x?void 0:x.markAllRead)?void 0:i.text)??"Mark All as Read",icon:{color:(null==(s=null==(o=null==x?void 0:x.markAllRead)?void 0:o.icon)?void 0:s.color)??"red",svg:(null==(a=null==(l=null==x?void 0:x.markAllRead)?void 0:l.icon)?void 0:a.svg)??b.inbox},selectionIcon:null,onClick:e=>{E.shared.readAllMessages({canCallApi:!0})}},{id:"archiveAll",text:(null==(r=null==x?void 0:x.archiveAll)?void 0:r.text)??"Archive All",icon:{color:(null==(h=null==(d=null==x?void 0:x.archiveAll)?void 0:d.icon)?void 0:h.color)??"red",svg:(null==(c=null==(u=null==x?void 0:x.archiveAll)?void 0:u.icon)?void 0:c.svg)??b.archive},selectionIcon:null,onClick:e=>{E.shared.archiveAllMessages({canCallApi:!0})}},{id:"archiveRead",text:(null==(v=null==x?void 0:x.archiveRead)?void 0:v.text)??"Archive Read",icon:{color:(null==(g=null==(p=null==x?void 0:x.archiveRead)?void 0:p.icon)?void 0:g.color)??"red",svg:(null==(_=null==(m=null==x?void 0:x.archiveRead)?void 0:m.icon)?void 0:_.svg)??b.archive},selectionIcon:null,onClick:e=>{E.shared.archiveReadMessages({canCallApi:!0})}}]}static get observedAttributes(){return["icon","title","feed-type"]}refreshTheme(){var e,t,n,i,o,s,l;const d=this._themeSubscription.manager.getTheme(),h=null==(e=this.shadow)?void 0:e.querySelector(".courier-inbox-header");h&&(h.style.backgroundColor=(null==(n=null==(t=d.inbox)?void 0:t.header)?void 0:n.backgroundColor)??r[500],h.style.boxShadow=(null==(o=null==(i=d.inbox)?void 0:i.header)?void 0:o.shadow)??`0px 1px 0px 0px ${a[500]}`),null==(s=this._filterMenu)||s.setOptions(this.getFilterOptions()),null==(l=this._actionMenu)||l.setOptions(this.getActionOptions())}handleOptionMenuItemClick(e,t){this._feedType=e,this._titleSection&&this._titleSection.updateSelectedOption(t,this._feedType,"inbox"===this._feedType?this._unreadCount:0),this._onFeedTypeChange(e)}render(e){this._feedType=e.feedType,this._unreadCount=e.unreadCount,this.refreshTitleSection()}refreshTitleSection(){var e,t;const n=this.getFilterOptions().find((e=>["inbox","archive"].includes(e.id)&&e.id===this._feedType));n&&(null==(e=this._titleSection)||e.updateSelectedOption(n,this._feedType,"inbox"===this._feedType?this._unreadCount:0),null==(t=this._filterMenu)||t.selectOption(n))}build(e){var t;super.build(e),this._style=document.createElement("style"),this._style.textContent=this.getStyles(),null==(t=this.shadow)||t.appendChild(this._style),this.refreshTheme()}defaultElement(){const e=this.getFilterOptions();this._titleSection=new H(this._themeSubscription.manager,e[0]),this._filterMenu=new $(this._themeSubscription.manager,"filters",!0,e,(()=>{var e;null==(e=this._actionMenu)||e.closeMenu()})),this._actionMenu=new $(this._themeSubscription.manager,"actions",!1,this.getActionOptions(),(()=>{var e;null==(e=this._filterMenu)||e.closeMenu()})),this._filterMenu.selectOption(e[0]);const t=document.createElement("div");t.className="spacer";const n=document.createElement("div");n.className="actions",n.appendChild(this._filterMenu),n.appendChild(this._actionMenu);const i=document.createElement("div");return i.className="courier-inbox-header",i.appendChild(this._titleSection),i.appendChild(t),i.appendChild(n),i}getStyles(){return`\n :host {\n z-index: 100;\n }\n\n .courier-inbox-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 10px 10px 10px 16px;\n background-color: ${r[500]};\n box-shadow: 0px 1px 0px 0px ${a[500]};\n }\n\n .header-content {\n display: flex;\n align-items: center;\n flex: 1;\n }\n\n .spacer {\n flex: 1;\n }\n\n .actions {\n display: flex;\n align-items: center;\n gap: 4px;\n }\n `}disconnectedCallback(){this._themeSubscription.unsubscribe()}}customElements.get("courier-inbox-header")||customElements.define("courier-inbox-header",R);class z{constructor(e){i(this,"events"),this.events=e}remove(){E.shared.removeDataStoreListener(this)}}const O={popup:{button:{icon:{color:l[500],svg:b.inbox},backgroundColor:"transparent",hoverBackgroundColor:l[50010],activeBackgroundColor:l[50020],unreadIndicator:{font:{color:r[500],size:"14px",family:void 0,weight:void 0},backgroundColor:d[500],borderRadius:"12px"}},window:{backgroundColor:r[500],borderRadius:"8px",border:`1px solid ${a[500]}`,shadow:`0px 8px 16px -4px ${a[500]}`}},inbox:{header:{backgroundColor:r[500],shadow:`0px 1px 0px 0px ${a[500]}`,filters:{font:{color:l[500],family:void 0,size:"18px"},inbox:{icon:{color:l[500],svg:b.inbox},text:"Inbox"},archive:{icon:{color:l[500],svg:b.archive},text:"Archive"},unreadIndicator:{font:{color:r[500],family:void 0,size:"14px"},backgroundColor:d[500],borderRadius:"12px"}},menus:{popup:{backgroundColor:r[500],border:`1px solid ${a[500]}`,borderRadius:"4px",shadow:`0px 4px 8px -2px ${a[500]}`,list:{hoverBackgroundColor:a[200],activeBackgroundColor:a[500],divider:"none",font:{color:l[500],family:void 0,size:"14px"},selectionIcon:{color:l[500],svg:b.check}}},filters:{button:{icon:{color:l[500],svg:b.filter},backgroundColor:"transparent",hoverBackgroundColor:l[50010],activeBackgroundColor:l[50020]},inbox:{icon:{color:l[500],svg:b.inbox},text:"Inbox"},archive:{icon:{color:l[500],svg:b.archive},text:"Archive"}},actions:{button:{icon:{color:l[500],svg:b.overflow},backgroundColor:"transparent",hoverBackgroundColor:l[50010],activeBackgroundColor:l[50020]},markAllRead:{icon:{color:l[500],svg:b.read},text:"Read All"},archiveAll:{icon:{color:l[500],svg:b.archive},text:"Archive All"},archiveRead:{icon:{color:l[500],svg:b.archiveRead},text:"Archive Read"}}}},list:{backgroundColor:r[500],item:{backgroundColor:"transparent",unreadIndicatorColor:d[500],hoverBackgroundColor:a[200],activeBackgroundColor:a[500],actions:{backgroundColor:"transparent",hoverBackgroundColor:a[200],activeBackgroundColor:a[500],border:`1px solid ${a[500]}`,borderRadius:"4px",shadow:"0px 1px 2px 0px rgba(0, 0, 0, 0.06)",font:{color:l[500],family:void 0,size:"14px"}},title:{color:l[500],family:void 0,size:"14px"},subtitle:{color:a[600],family:void 0,size:"14px"},time:{color:a[600],family:void 0,size:"14px"},divider:`1px solid ${a[200]}`,menu:{enabled:!0,backgroundColor:r[500],border:`1px solid ${a[500]}`,borderRadius:"4px",shadow:`0px 2px 4px -2px ${a[500]}`,longPress:{displayDuration:4e3,vibrationDuration:50},item:{hoverBackgroundColor:a[200],activeBackgroundColor:a[500],borderRadius:"0px",read:{color:l[500],svg:b.read},unread:{color:l[500],svg:b.unread},archive:{color:l[500],svg:b.archive},unarchive:{color:l[500],svg:b.unarchive}}}}},loading:{animation:{barColor:a[500],barHeight:"14px",barBorderRadius:"14px",duration:"2s"},divider:`1px solid ${a[200]}`},empty:{title:{font:{size:"16px",weight:"500",color:l[500]}},button:{text:"Refresh"}},error:{title:{font:{size:"16px",weight:"500",color:l[500]}},button:{text:"Retry"}}}},V={popup:{button:{icon:{color:r[500],svg:b.inbox},backgroundColor:"transparent",hoverBackgroundColor:r[50010],activeBackgroundColor:r[50020],unreadIndicator:{font:{color:r[500],size:"14px",family:void 0,weight:void 0},backgroundColor:d[500],borderRadius:"12px"}},window:{backgroundColor:l[500],borderRadius:"8px",border:`1px solid ${a[400]}`,shadow:`0px 4px 8px -2px ${r[50020]}`}},inbox:{header:{backgroundColor:l[500],shadow:`0px 1px 0px 0px ${a[400]}`,filters:{font:{color:r[500],family:void 0,size:"18px"},inbox:{icon:{color:r[500],svg:b.inbox},text:"Inbox"},archive:{icon:{color:r[500],svg:b.archive},text:"Archive"},unreadIndicator:{font:{color:r[500],family:void 0,size:"14px"},backgroundColor:d[500],borderRadius:"12px"}},menus:{popup:{backgroundColor:l[500],border:`1px solid ${a[400]}`,borderRadius:"4px",shadow:`0px 4px 8px -2px ${r[50020]}`,list:{hoverBackgroundColor:r[50010],activeBackgroundColor:r[50020],divider:"none",font:{color:r[500],family:void 0,size:"14px"},selectionIcon:{color:r[500],svg:b.check}}},filters:{button:{icon:{color:r[500],svg:b.filter},backgroundColor:"transparent",hoverBackgroundColor:r[50010],activeBackgroundColor:r[50020]},inbox:{icon:{color:r[500],svg:b.inbox},text:"Inbox"},archive:{icon:{color:r[500],svg:b.archive},text:"Archive"}},actions:{button:{icon:{color:r[500],svg:b.overflow},backgroundColor:"transparent",hoverBackgroundColor:r[50010],activeBackgroundColor:r[50020]},markAllRead:{icon:{color:r[500],svg:b.read},text:"Read All"},archiveAll:{icon:{color:r[500],svg:b.archive},text:"Archive All"},archiveRead:{icon:{color:r[500],svg:b.archiveRead},text:"Archive Read"}}}},list:{backgroundColor:l[500],item:{backgroundColor:"transparent",unreadIndicatorColor:d[500],hoverBackgroundColor:r[50010],activeBackgroundColor:r[50020],actions:{backgroundColor:"transparent",hoverBackgroundColor:r[50010],activeBackgroundColor:r[50020],border:`1px solid ${a[400]}`,borderRadius:"4px",shadow:`0px 1px 2px 0px ${r[50010]}`,font:{color:r[500],family:void 0,size:"14px"}},title:{color:r[500],family:void 0,size:"14px"},subtitle:{color:a[500],family:void 0,size:"14px"},time:{color:a[500],family:void 0,size:"12px"},divider:`1px solid ${a[400]}`,menu:{enabled:!0,backgroundColor:l[500],border:`1px solid ${a[400]}`,borderRadius:"4px",shadow:`0px 2px 4px -2px ${r[50020]}`,longPress:{displayDuration:4e3,vibrationDuration:50},item:{hoverBackgroundColor:r[50010],activeBackgroundColor:r[50020],borderRadius:"0px",read:{color:r[500],svg:b.read},unread:{color:r[500],svg:b.unread},archive:{color:r[500],svg:b.archive},unarchive:{color:r[500],svg:b.unarchive}}}}},loading:{animation:{barColor:r[500],barHeight:"14px",barBorderRadius:"14px",duration:"2s"},divider:`1px solid ${a[400]}`},empty:{title:{font:{size:"16px",weight:"500",color:r[500]}},button:{text:"Refresh"}},error:{title:{font:{size:"16px",weight:"500",color:r[500]}},button:{text:"Retry"}}}},N=(e,t)=>{var n,i,o,s,l,a,r,d,h,u,c,v,p,g,m,b,_,x,C,f,y,k,S,w,M,E,T,I,L,D,A,B,P,$,F,H,R,z,N,U,Z,j,G,J,W,q,X,Y,K,Q,ee,te,ne,ie,oe,se,le,ae,re,de,he,ue,ce,ve,pe,ge,me,be,_e,xe,Ce,fe,ye,ke,Se,we,Me,Ee,Te,Ie,Le,De,Ae,Be,Pe,$e,Fe,He,Re,ze,Oe,Ve,Ne,Ue,Ze,je,Ge,Je,We,qe,Xe,Ye,Ke,Qe,et,tt,nt,it,ot,st,lt,at,rt,dt,ht,ut,ct,vt,pt,gt,mt,bt,_t,xt,Ct,ft,yt,kt,St,wt,Mt,Et,Tt,It,Lt,Dt,At,Bt,Pt,$t,Ft,Ht,Rt,zt,Ot,Vt,Nt,Ut,Zt,jt,Gt,Jt,Wt,qt,Xt,Yt,Kt,Qt,en,tn,nn,on,sn,ln,an,rn,dn,hn,un,cn,vn,pn,gn,mn,bn,_n,xn,Cn,fn,yn,kn,Sn,wn,Mn,En,Tn,In,Ln,Dn,An,Bn,Pn,$n,Fn,Hn,Rn,zn,On,Vn,Nn,Un,Zn,jn,Gn,Jn,Wn,qn,Xn,Yn,Kn,Qn,ei,ti,ni,ii,oi,si,li,ai,ri,di,hi,ui,ci,vi,pi,gi,mi,bi,_i,xi,Ci,fi,yi,ki,Si,wi,Mi,Ei,Ti,Ii,Li,Di,Ai,Bi,Pi,$i,Fi,Hi,Ri,zi,Oi,Vi,Ni,Ui,Zi,ji,Gi;const Ji="light"===e?O:V;return{popup:{button:{...null==(n=Ji.popup)?void 0:n.button,...null==(i=t.popup)?void 0:i.button,icon:{...null==(s=null==(o=Ji.popup)?void 0:o.button)?void 0:s.icon,...null==(a=null==(l=t.popup)?void 0:l.button)?void 0:a.icon},unreadIndicator:{...null==(d=null==(r=Ji.popup)?void 0:r.button)?void 0:d.unreadIndicator,...null==(u=null==(h=t.popup)?void 0:h.button)?void 0:u.unreadIndicator}},window:{...null==(c=Ji.popup)?void 0:c.window,...null==(v=t.popup)?void 0:v.window}},inbox:{header:{...null==(p=Ji.inbox)?void 0:p.header,...null==(g=t.inbox)?void 0:g.header,filters:{...null==(b=null==(m=Ji.inbox)?void 0:m.header)?void 0:b.filters,...null==(x=null==(_=t.inbox)?void 0:_.header)?void 0:x.filters,inbox:{...null==(y=null==(f=null==(C=Ji.inbox)?void 0:C.header)?void 0:f.filters)?void 0:y.inbox,...null==(w=null==(S=null==(k=t.inbox)?void 0:k.header)?void 0:S.filters)?void 0:w.inbox,icon:{...null==(I=null==(T=null==(E=null==(M=Ji.inbox)?void 0:M.header)?void 0:E.filters)?void 0:T.inbox)?void 0:I.icon,...null==(B=null==(A=null==(D=null==(L=t.inbox)?void 0:L.header)?void 0:D.filters)?void 0:A.inbox)?void 0:B.icon}},archive:{...null==(F=null==($=null==(P=Ji.inbox)?void 0:P.header)?void 0:$.filters)?void 0:F.archive,...null==(z=null==(R=null==(H=t.inbox)?void 0:H.header)?void 0:R.filters)?void 0:z.archive,icon:{...null==(j=null==(Z=null==(U=null==(N=Ji.inbox)?void 0:N.header)?void 0:U.filters)?void 0:Z.archive)?void 0:j.icon,...null==(q=null==(W=null==(J=null==(G=t.inbox)?void 0:G.header)?void 0:J.filters)?void 0:W.archive)?void 0:q.icon}},unreadIndicator:{...null==(K=null==(Y=null==(X=Ji.inbox)?void 0:X.header)?void 0:Y.filters)?void 0:K.unreadIndicator,...null==(te=null==(ee=null==(Q=t.inbox)?void 0:Q.header)?void 0:ee.filters)?void 0:te.unreadIndicator}},menus:{...null==(ie=null==(ne=Ji.inbox)?void 0:ne.header)?void 0:ie.menus,...null==(se=null==(oe=t.inbox)?void 0:oe.header)?void 0:se.menus,popup:{...null==(re=null==(ae=null==(le=Ji.inbox)?void 0:le.header)?void 0:ae.menus)?void 0:re.popup,...null==(ue=null==(he=null==(de=t.inbox)?void 0:de.header)?void 0:he.menus)?void 0:ue.popup,list:{...null==(ge=null==(pe=null==(ve=null==(ce=Ji.inbox)?void 0:ce.header)?void 0:ve.menus)?void 0:pe.popup)?void 0:ge.list,...null==(xe=null==(_e=null==(be=null==(me=t.inbox)?void 0:me.header)?void 0:be.menus)?void 0:_e.popup)?void 0:xe.list,font:{...null==(Se=null==(ke=null==(ye=null==(fe=null==(Ce=Ji.inbox)?void 0:Ce.header)?void 0:fe.menus)?void 0:ye.popup)?void 0:ke.list)?void 0:Se.font,...null==(Ie=null==(Te=null==(Ee=null==(Me=null==(we=t.inbox)?void 0:we.header)?void 0:Me.menus)?void 0:Ee.popup)?void 0:Te.list)?void 0:Ie.font},selectionIcon:{...null==(Pe=null==(Be=null==(Ae=null==(De=null==(Le=Ji.inbox)?void 0:Le.header)?void 0:De.menus)?void 0:Ae.popup)?void 0:Be.list)?void 0:Pe.selectionIcon,...null==(ze=null==(Re=null==(He=null==(Fe=null==($e=t.inbox)?void 0:$e.header)?void 0:Fe.menus)?void 0:He.popup)?void 0:Re.list)?void 0:ze.selectionIcon}}},filters:{...null==(Ne=null==(Ve=null==(Oe=Ji.inbox)?void 0:Oe.header)?void 0:Ve.menus)?void 0:Ne.filters,...null==(je=null==(Ze=null==(Ue=t.inbox)?void 0:Ue.header)?void 0:Ze.menus)?void 0:je.filters,inbox:{...null==(qe=null==(We=null==(Je=null==(Ge=Ji.inbox)?void 0:Ge.header)?void 0:Je.menus)?void 0:We.filters)?void 0:qe.inbox,...null==(Qe=null==(Ke=null==(Ye=null==(Xe=t.inbox)?void 0:Xe.header)?void 0:Ye.menus)?void 0:Ke.filters)?void 0:Qe.inbox,icon:{...null==(ot=null==(it=null==(nt=null==(tt=null==(et=Ji.inbox)?void 0:et.header)?void 0:tt.menus)?void 0:nt.filters)?void 0:it.inbox)?void 0:ot.icon,...null==(dt=null==(rt=null==(at=null==(lt=null==(st=t.inbox)?void 0:st.header)?void 0:lt.menus)?void 0:at.filters)?void 0:rt.inbox)?void 0:dt.icon}},archive:{...null==(vt=null==(ct=null==(ut=null==(ht=Ji.inbox)?void 0:ht.header)?void 0:ut.menus)?void 0:ct.filters)?void 0:vt.archive,...null==(bt=null==(mt=null==(gt=null==(pt=t.inbox)?void 0:pt.header)?void 0:gt.menus)?void 0:mt.filters)?void 0:bt.archive,icon:{...null==(yt=null==(ft=null==(Ct=null==(xt=null==(_t=Ji.inbox)?void 0:_t.header)?void 0:xt.menus)?void 0:Ct.filters)?void 0:ft.archive)?void 0:yt.icon,...null==(Et=null==(Mt=null==(wt=null==(St=null==(kt=t.inbox)?void 0:kt.header)?void 0:St.menus)?void 0:wt.filters)?void 0:Mt.archive)?void 0:Et.icon}}},actions:{...null==(Lt=null==(It=null==(Tt=Ji.inbox)?void 0:Tt.header)?void 0:It.menus)?void 0:Lt.actions,...null==(Bt=null==(At=null==(Dt=t.inbox)?void 0:Dt.header)?void 0:At.menus)?void 0:Bt.actions,markAllRead:{...null==(Ht=null==(Ft=null==($t=null==(Pt=Ji.inbox)?void 0:Pt.header)?void 0:$t.menus)?void 0:Ft.actions)?void 0:Ht.markAllRead,...null==(Vt=null==(Ot=null==(zt=null==(Rt=t.inbox)?void 0:Rt.header)?void 0:zt.menus)?void 0:Ot.actions)?void 0:Vt.markAllRead,icon:{...null==(Gt=null==(jt=null==(Zt=null==(Ut=null==(Nt=Ji.inbox)?void 0:Nt.header)?void 0:Ut.menus)?void 0:Zt.actions)?void 0:jt.markAllRead)?void 0:Gt.icon,...null==(Yt=null==(Xt=null==(qt=null==(Wt=null==(Jt=t.inbox)?void 0:Jt.header)?void 0:Wt.menus)?void 0:qt.actions)?void 0:Xt.markAllRead)?void 0:Yt.icon}},archiveAll:{...null==(tn=null==(en=null==(Qt=null==(Kt=Ji.inbox)?void 0:Kt.header)?void 0:Qt.menus)?void 0:en.actions)?void 0:tn.archiveAll,...null==(ln=null==(sn=null==(on=null==(nn=t.inbox)?void 0:nn.header)?void 0:on.menus)?void 0:sn.actions)?void 0:ln.archiveAll,icon:{...null==(un=null==(hn=null==(dn=null==(rn=null==(an=Ji.inbox)?void 0:an.header)?void 0:rn.menus)?void 0:dn.actions)?void 0:hn.archiveAll)?void 0:un.icon,...null==(mn=null==(gn=null==(pn=null==(vn=null==(cn=t.inbox)?void 0:cn.header)?void 0:vn.menus)?void 0:pn.actions)?void 0:gn.archiveAll)?void 0:mn.icon}},archiveRead:{...null==(Cn=null==(xn=null==(_n=null==(bn=Ji.inbox)?void 0:bn.header)?void 0:_n.menus)?void 0:xn.actions)?void 0:Cn.archiveRead,...null==(Sn=null==(kn=null==(yn=null==(fn=t.inbox)?void 0:fn.header)?void 0:yn.menus)?void 0:kn.actions)?void 0:Sn.archiveRead,icon:{...null==(In=null==(Tn=null==(En=null==(Mn=null==(wn=Ji.inbox)?void 0:wn.header)?void 0:Mn.menus)?void 0:En.actions)?void 0:Tn.archiveRead)?void 0:In.icon,...null==(Pn=null==(Bn=null==(An=null==(Dn=null==(Ln=t.inbox)?void 0:Ln.header)?void 0:Dn.menus)?void 0:An.actions)?void 0:Bn.archiveRead)?void 0:Pn.icon}}}}},list:{...null==($n=Ji.inbox)?void 0:$n.list,...null==(Fn=t.inbox)?void 0:Fn.list,item:{...null==(Rn=null==(Hn=Ji.inbox)?void 0:Hn.list)?void 0:Rn.item,...null==(On=null==(zn=t.inbox)?void 0:zn.list)?void 0:On.item,menu:{...null==(Un=null==(Nn=null==(Vn=Ji.inbox)?void 0:Vn.list)?void 0:Nn.item)?void 0:Un.menu,...null==(Gn=null==(jn=null==(Zn=t.inbox)?void 0:Zn.list)?void 0:jn.item)?void 0:Gn.menu,item:{...null==(Xn=null==(qn=null==(Wn=null==(Jn=Ji.inbox)?void 0:Jn.list)?void 0:Wn.item)?void 0:qn.menu)?void 0:Xn.item,...null==(ei=null==(Qn=null==(Kn=null==(Yn=t.inbox)?void 0:Yn.list)?void 0:Kn.item)?void 0:Qn.menu)?void 0:ei.item,read:{...null==(si=null==(oi=null==(ii=null==(ni=null==(ti=Ji.inbox)?void 0:ti.list)?void 0:ni.item)?void 0:ii.menu)?void 0:oi.item)?void 0:si.read,...null==(hi=null==(di=null==(ri=null==(ai=null==(li=t.inbox)?void 0:li.list)?void 0:ai.item)?void 0:ri.menu)?void 0:di.item)?void 0:hi.read},unread:{...null==(gi=null==(pi=null==(vi=null==(ci=null==(ui=Ji.inbox)?void 0:ui.list)?void 0:ci.item)?void 0:vi.menu)?void 0:pi.item)?void 0:gi.unread,...null==(Ci=null==(xi=null==(_i=null==(bi=null==(mi=t.inbox)?void 0:mi.list)?void 0:bi.item)?void 0:_i.menu)?void 0:xi.item)?void 0:Ci.unread},archive:{...null==(wi=null==(Si=null==(ki=null==(yi=null==(fi=Ji.inbox)?void 0:fi.list)?void 0:yi.item)?void 0:ki.menu)?void 0:Si.item)?void 0:wi.archive,...null==(Li=null==(Ii=null==(Ti=null==(Ei=null==(Mi=t.inbox)?void 0:Mi.list)?void 0:Ei.item)?void 0:Ti.menu)?void 0:Ii.item)?void 0:Li.archive},unarchive:{...null==($i=null==(Pi=null==(Bi=null==(Ai=null==(Di=Ji.inbox)?void 0:Di.list)?void 0:Ai.item)?void 0:Bi.menu)?void 0:Pi.item)?void 0:$i.unarchive,...null==(Oi=null==(zi=null==(Ri=null==(Hi=null==(Fi=t.inbox)?void 0:Fi.list)?void 0:Hi.item)?void 0:Ri.menu)?void 0:zi.item)?void 0:Oi.unarchive}}}}},loading:{...null==(Vi=Ji.inbox)?void 0:Vi.loading,...null==(Ni=t.inbox)?void 0:Ni.loading},empty:{...null==(Ui=Ji.inbox)?void 0:Ui.empty,...null==(Zi=t.inbox)?void 0:Zi.empty},error:{...null==(ji=Ji.inbox)?void 0:ji.error,...null==(Gi=t.inbox)?void 0:Gi.error}}}};class U{constructor(e){i(this,"THEME_CHANGE_EVENT","courier_inbox_theme_change"),i(this,"_theme"),i(this,"_lightTheme",O),i(this,"_darkTheme",V),i(this,"_target"),i(this,"_subscriptions",[]),i(this,"_userMode"),i(this,"_systemMode"),i(this,"_systemThemeCleanup"),this._theme=e,this._target=new EventTarget,this._userMode="system",this._systemMode=u(),this.setLightTheme(O),this.setDarkTheme(V),this._systemThemeCleanup=c((e=>{this._systemMode=e,this.updateTheme()}))}setLightTheme(e){this._lightTheme=e,"light"===this._systemMode&&this.updateTheme()}setDarkTheme(e){this._darkTheme=e,"dark"===this._systemMode&&this.updateTheme()}get currentSystemTheme(){return this._systemMode}getTheme(){return this._theme}updateTheme(){const e="system"===this._userMode?this._systemMode:this._userMode,t="light"===e?this._lightTheme:this._darkTheme,n=N(e,t);this.setTheme(n)}setTheme(e){e!==this._theme&&(this._theme=e,this._target.dispatchEvent(new CustomEvent(this.THEME_CHANGE_EVENT,{detail:{theme:e}})))}setMode(e){this._userMode=e,this.updateTheme()}subscribe(e){const t=new AbortController;this._target.addEventListener(this.THEME_CHANGE_EVENT,(t=>{e(t.detail.theme)}),{signal:t.signal});const n={manager:this,unsubscribe:()=>{t.abort();const e=this._subscriptions.indexOf(n);e>-1&&this._subscriptions.splice(e,1)}};return this._subscriptions.push(n),n}cleanup(){this._systemThemeCleanup&&this._systemThemeCleanup(),this._subscriptions.forEach((e=>e.unsubscribe())),this._subscriptions=[]}}class Z extends HTMLElement{constructor(e){var n;super(),i(this,"_currentFeed","inbox"),i(this,"_themeManager"),i(this,"_shadow"),i(this,"_list"),i(this,"_datastoreListener"),i(this,"_authListener"),i(this,"_style"),i(this,"_header"),i(this,"_headerFactory"),i(this,"_onMessageClick"),i(this,"_onMessageActionClick"),i(this,"_onMessageLongPress"),i(this,"_defaultProps",{title:"Inbox",icon:b.inbox,feedType:this._currentFeed,height:"768px"}),this._shadow=this.attachShadow({mode:"open"}),this._themeManager=e??new U(O),this._header=new R({themeManager:this._themeManager,onFeedTypeChange:e=>{this.setFeedType(e)}}),this._header.build(void 0),this._shadow.appendChild(this._header),this._list=new B({themeManager:this._themeManager,onRefresh:()=>{this.refresh()},onPaginationTrigger:async e=>{var n,i;try{await E.shared.fetchNextPageOfMessages({feedType:e})}catch(o){null==(i=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||i.error("Failed to fetch next page of messages:",o)}},onMessageClick:(e,t)=>{var n;E.shared.clickMessage({message:e}),this.dispatchEvent(new CustomEvent("message-click",{detail:{message:e,index:t},bubbles:!0,composed:!0})),null==(n=this._onMessageClick)||n.call(this,{message:e,index:t})},onMessageActionClick:(e,t,n)=>{var i;this.dispatchEvent(new CustomEvent("message-action-click",{detail:{message:e,action:t,index:n},bubbles:!0,composed:!0})),null==(i=this._onMessageActionClick)||i.call(this,{message:e,action:t,index:n})},onMessageLongPress:(e,t)=>{var n;this.dispatchEvent(new CustomEvent("message-long-press",{detail:{message:e,index:t},bubbles:!0,composed:!0})),null==(n=this._onMessageLongPress)||n.call(this,{message:e,index:t})}}),this._style=document.createElement("style"),this.refreshTheme(),this._shadow.appendChild(this._style),this._shadow.appendChild(this._list),this._datastoreListener=new z({onError:e=>{this._list.setError(e)},onDataSetChange:(e,t)=>{this._currentFeed===t&&(this._list.setDataSet(e),this.updateHeader())},onPageAdded:(e,t)=>{this._currentFeed===t&&(this._list.addPage(e),this.updateHeader())},onMessageAdd:(e,t,n)=>{this._currentFeed===n&&(this._list.addMessage(e,t),this.updateHeader())},onMessageRemove:(e,t,n)=>{this._currentFeed===n&&(this._list.removeMessage(t),this.updateHeader())},onMessageUpdate:(e,t,n)=>{this._currentFeed===n&&(this._list.updateMessage(e,t),this.updateHeader())},onUnreadCountChange:e=>{this.updateHeader()}}),E.shared.addDataStoreListener(this._datastoreListener),this._themeManager.subscribe((e=>{this.refreshTheme()})),this._authListener=t.Courier.shared.addAuthenticationListener((e=>{this.refresh()})),(null==(n=t.Courier.shared.client)?void 0:n.options.userId)&&this.refresh()}get theme(){return this._themeManager.getTheme()}setLightTheme(e){this._themeManager.setLightTheme(e)}setDarkTheme(e){this._themeManager.setDarkTheme(e)}static get observedAttributes(){return["height","light-theme","dark-theme","mode","message-click","message-action-click","message-long-press"]}refreshTheme(){this._style.textContent=this.getStyles()}getStyles(){return`\n :host {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: ${this._defaultProps.height};\n }\n\n courier-inbox-header {\n flex-shrink: 0;\n }\n\n courier-inbox-list {\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n }\n `}setHeader(e){this._headerFactory=e,this.updateHeader()}removeHeader(){this._headerFactory=null,this.updateHeader()}setLoadingState(e){this._list.setLoadingStateFactory(e)}setEmptyState(e){this._list.setEmptyStateFactory(e)}setErrorState(e){this._list.setErrorStateFactory(e)}setListItem(e){this._list.setListItemFactory(e)}setPaginationItem(e){this._list.setPaginationItemFactory(e)}onMessageClick(e){this._onMessageClick=e}onMessageActionClick(e){this._onMessageActionClick=e}onMessageLongPress(e){this._onMessageLongPress=e}setFeedType(e){this._currentFeed=e,this._list.setFeedType(e),this.updateHeader(),this.load({feedType:this._currentFeed,canUseCache:!0})}updateHeader(){const e={feedType:this._currentFeed,unreadCount:E.shared.unreadCount,messageCount:this._list.messages.length};switch(this._headerFactory){case void 0:this._header.render(e);break;case null:this._header.build(null);break;default:const t=this._headerFactory(e);this._header.build(t)}}async load(e){await E.shared.load(e),await E.shared.listenForUpdates()}refresh(){this.load({feedType:this._currentFeed,canUseCache:!1})}connectedCallback(){this.refresh()}disconnectedCallback(){var e,t;this._themeManager.cleanup(),null==(e=this._datastoreListener)||e.remove(),null==(t=this._authListener)||t.remove()}attributeChangedCallback(e,n,i){var o,s,l,a,r,d;if(n!==i)switch(e){case"height":const e=i||this._defaultProps.height;this.style.height=e;break;case"message-click":if(i)try{this._onMessageClick=new Function("props",i)}catch(h){null==(s=null==(o=t.Courier.shared.client)?void 0:o.options.logger)||s.error("Failed to parse message-click handler:",h)}else this._onMessageClick=void 0;break;case"message-action-click":if(i)try{this._onMessageActionClick=new Function("props",i)}catch(h){null==(a=null==(l=t.Courier.shared.client)?void 0:l.options.logger)||a.error("Failed to parse message-action-click handler:",h)}else this._onMessageActionClick=void 0;break;case"message-long-press":if(i)try{this._onMessageLongPress=new Function("props",i)}catch(h){null==(d=null==(r=t.Courier.shared.client)?void 0:r.options.logger)||d.error("Failed to parse message-long-press handler:",h)}else this._onMessageLongPress=void 0;break;case"light-theme":i&&this.setLightTheme(JSON.parse(i));break;case"dark-theme":i&&this.setDarkTheme(JSON.parse(i));break;case"mode":this._themeManager.setMode(i)}}}customElements.get("courier-inbox")||customElements.define("courier-inbox",Z);class j extends C{constructor(e){super(),i(this,"_themeSubscription"),i(this,"_container"),i(this,"_triggerButton"),i(this,"_unreadCountBadge"),this._themeSubscription=e.subscribe((e=>{this.updateTheme()}))}defaultElement(){this._container=document.createElement("div"),this._container.className="menu-button-container",this._triggerButton=new y(b.inbox),this._unreadCountBadge=new F({themeBus:this._themeSubscription.manager,location:"button"}),this._unreadCountBadge.id="unread-badge";const e=document.createElement("style");return e.textContent=this.getStyles(),this._container.appendChild(e),this._container.appendChild(this._triggerButton),this._container.appendChild(this._unreadCountBadge),this.shadow.appendChild(this._container),this.updateTheme(),this._container}getStyles(){return"\n .menu-button-container {\n position: relative;\n display: inline-block;\n }\n \n #unread-badge {\n position: absolute;\n top: -8px;\n left: 50%;\n pointer-events: none;\n }\n "}onUnreadCountChange(e){var t;null==(t=this._unreadCountBadge)||t.setCount(e),this.updateTheme()}updateTheme(){var e,t,n,i,o,s,a,r,d,h,u,c,v,p,g,m,_,x;const C=this._themeSubscription.manager.getTheme();null==(i=this._triggerButton)||i.updateIconColor((null==(n=null==(t=null==(e=null==C?void 0:C.popup)?void 0:e.button)?void 0:t.icon)?void 0:n.color)??l[500]),null==(r=this._triggerButton)||r.updateIconSVG((null==(a=null==(s=null==(o=null==C?void 0:C.popup)?void 0:o.button)?void 0:s.icon)?void 0:a.svg)??b.inbox),null==(u=this._triggerButton)||u.updateBackgroundColor((null==(h=null==(d=null==C?void 0:C.popup)?void 0:d.button)?void 0:h.backgroundColor)??"transparent"),null==(p=this._triggerButton)||p.updateHoverBackgroundColor((null==(v=null==(c=null==C?void 0:C.popup)?void 0:c.button)?void 0:v.hoverBackgroundColor)??l[50010]),null==(_=this._triggerButton)||_.updateActiveBackgroundColor((null==(m=null==(g=null==C?void 0:C.popup)?void 0:g.button)?void 0:m.activeBackgroundColor)??l[50020]),null==(x=this._unreadCountBadge)||x.refreshTheme("button")}disconnectedCallback(){this._themeSubscription.unsubscribe()}}customElements.get("courier-inbox-menu-button")||customElements.define("courier-inbox-menu-button",j);class G extends HTMLElement{constructor(){super(),i(this,"_width","440px"),i(this,"_height","440px"),i(this,"_popupAlignment","top-right"),i(this,"_top","40px"),i(this,"_right","0"),i(this,"_bottom","40px"),i(this,"_left","0"),i(this,"_themeManager",new U(O)),i(this,"_triggerButton"),i(this,"_popup"),i(this,"_inbox"),i(this,"_style"),i(this,"_datastoreListener"),i(this,"_popupMenuButtonFactory");const e=this.attachShadow({mode:"open"});this._triggerButton=new j(this._themeManager),this._triggerButton.build(void 0),this._popup=document.createElement("div"),this._popup.className="popup",this._inbox=new Z(this._themeManager),this._inbox.setAttribute("height","100%"),this._style=document.createElement("style"),this.refreshTheme(),e.appendChild(this._style),e.appendChild(this._triggerButton),e.appendChild(this._popup),this._popup.appendChild(this._inbox),this._triggerButton.addEventListener("click",this.togglePopup.bind(this)),document.addEventListener("click",this.handleOutsideClick.bind(this)),this.updatePopupPosition(),this._datastoreListener=new z(this),E.shared.addDataStoreListener(this._datastoreListener),this._themeManager.subscribe((e=>{this.refreshTheme()}))}get theme(){return this._themeManager.getTheme()}setLightTheme(e){this._themeManager.setLightTheme(e)}setDarkTheme(e){this._themeManager.setDarkTheme(e)}static get observedAttributes(){return["popup-alignment","message-click","message-action-click","message-long-press","popup-width","popup-height","top","right","bottom","left","light-theme","dark-theme","mode"]}refreshTheme(){this._style.textContent=this.getStyles()}getStyles(){var e,t,n,i,o,s,l,a;return`\n :host {\n display: inline-block;\n position: relative;\n }\n\n .menu-button-container {\n position: relative;\n display: inline-block;\n }\n\n .popup {\n display: none;\n position: absolute;\n background: ${(null==(t=null==(e=this.theme.popup)?void 0:e.window)?void 0:t.backgroundColor)??"red"};\n border-radius: ${(null==(i=null==(n=this.theme.popup)?void 0:n.window)?void 0:i.borderRadius)??"8px"};\n border: ${(null==(s=null==(o=this.theme.popup)?void 0:o.window)?void 0:s.border)??"1px solid red"};\n box-shadow: ${(null==(a=null==(l=this.theme.popup)?void 0:l.window)?void 0:a.shadow)??"0px 8px 16px -4px red"};\n z-index: 1000;\n width: ${this._width};\n height: ${this._height};\n overflow: hidden;\n transform: translateZ(0);\n will-change: transform;\n }\n \n #unread-badge {\n position: absolute;\n top: -8px;\n left: 50%;\n pointer-events: none;\n }\n\n courier-inbox {\n height: 100%;\n }\n `}attributeChangedCallback(e,t,n){switch(e){case"popup-alignment":this.isValidPosition(n)&&(this._popupAlignment=n,this.updatePopupPosition());break;case"popup-width":this._width=n,this.setSize(n,this._height);break;case"popup-height":this._height=n,this.setSize(this._width,n);break;case"top":this._top=n,this.updatePopupPosition();break;case"right":this._right=n,this.updatePopupPosition();break;case"bottom":this._bottom=n,this.updatePopupPosition();break;case"left":this._left=n,this.updatePopupPosition();break;case"light-theme":n&&this.setLightTheme(JSON.parse(n));break;case"dark-theme":n&&this.setDarkTheme(JSON.parse(n));break;case"mode":this._themeManager.setMode(n)}}onUnreadCountChange(e){this.render()}onMessageClick(e){this._inbox.onMessageClick(e)}onMessageActionClick(e){this._inbox.onMessageActionClick(e)}onMessageLongPress(e){this._inbox.onMessageLongPress(e)}isValidPosition(e){return["top-right","top-left","top-center","bottom-right","bottom-left","bottom-center","center-right","center-left","center-center"].includes(e)}updatePopupPosition(){switch(this._popup.style.top="",this._popup.style.bottom="",this._popup.style.left="",this._popup.style.right="",this._popup.style.margin="",this._popup.style.transform="",this._popupAlignment){case"top-right":this._popup.style.top=this._top,this._popup.style.right=this._right;break;case"top-left":this._popup.style.top=this._top,this._popup.style.left=this._left;break;case"top-center":this._popup.style.top=this._top,this._popup.style.left="50%",this._popup.style.transform="translateX(-50%)";break;case"bottom-right":this._popup.style.bottom=this._bottom,this._popup.style.right=this._right;break;case"bottom-left":this._popup.style.bottom=this._bottom,this._popup.style.left=this._left;break;case"bottom-center":this._popup.style.bottom=this._bottom,this._popup.style.left="50%",this._popup.style.transform="translateX(-50%)";break;case"center-right":this._popup.style.top="50%",this._popup.style.right=this._right,this._popup.style.transform="translateY(-50%)";break;case"center-left":this._popup.style.top="50%",this._popup.style.left=this._left,this._popup.style.transform="translateY(-50%)";break;case"center-center":this._popup.style.top="50%",this._popup.style.left="50%",this._popup.style.transform="translate(-50%, -50%)"}}togglePopup(e){e.stopPropagation();const t="block"===this._popup.style.display;this._popup.style.display=t?"none":"block"}handleOutsideClick(e){this.contains(e.target)||(this._popup.style.display="none")}setContent(e){this._inbox.innerHTML="",this._inbox.appendChild(e)}setSize(e,t){this._width=e,this._height=t,this._popup.style.width=e,this._popup.style.height=t}setPosition(e){var n,i;this.isValidPosition(e)?(this._popupAlignment=e,this.updatePopupPosition()):null==(i=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||i.error(`Invalid position: ${e}`)}setFeedType(e){this._inbox.setFeedType(e)}setPopupHeader(e){this._inbox.setHeader(e)}removePopupHeader(){this._inbox.removeHeader()}setPopupLoadingState(e){this._inbox.setLoadingState(e)}setPopupEmptyState(e){this._inbox.setEmptyState(e)}setPopupErrorState(e){this._inbox.setErrorState(e)}setPopupListItem(e){this._inbox.setListItem(e)}setPopupPaginationItem(e){this._inbox.setPaginationItem(e)}setPopupMenuButton(e){this._popupMenuButtonFactory=e,this.render()}render(){const e=E.shared.unreadCount;switch(this._popupMenuButtonFactory){case void 0:case null:this._triggerButton.build(void 0),this._triggerButton.onUnreadCountChange(e);break;default:const t=this._popupMenuButtonFactory({unreadCount:e});this._triggerButton.build(t)}}disconnectedCallback(){var e;null==(e=this._datastoreListener)||e.remove(),this._themeManager.cleanup()}}customElements.get("courier-inbox-menu")||customElements.define("courier-inbox-menu",G);e.CourierInbox=Z,e.CourierInboxDataStoreListener=z,e.CourierInboxDatastore=E,e.CourierInboxDatastoreEvents=class{onDataSetChange(e,t){}onPageAdded(e,t){}onUnreadCountChange(e){}onMessageAdd(e,t,n){}onMessageRemove(e,t,n){}onMessageUpdate(e,t,n){}onError(e){}},e.CourierInboxHeader=R,e.CourierInboxMenu=G,e.CourierInboxThemeManager=U,e.CourierListItem=T,e.archiveMessage=function(e){return E.shared.archiveMessage({message:e})},e.clickMessage=function(e){return E.shared.clickMessage({message:e})},e.defaultDarkTheme=V,e.defaultLightTheme=O,e.markAsRead=function(e){return E.shared.readMessage({message:e})},e.markAsUnread=function(e){return E.shared.unreadMessage({message:e})},e.mergeTheme=N,e.openMessage=function(e){return E.shared.openMessage({message:e})},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@trycourier/courier-js")):"function"==typeof define&&define.amd?define(["exports","@trycourier/courier-js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CourierUIInbox={},e.CourierJS)}(this,(function(e,t){"use strict";var n,i=Object.defineProperty,o=(e,t,n)=>((e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),s=Object.defineProperty,l=e=>{throw TypeError(e)},r=(e,t,n)=>((e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),a=(e,t,n)=>t.has(e)||l("Cannot "+n),d=(e,t,n,i)=>(a(e,t,"write to private field"),t.set(e,n),n);const u={500:"#171717",50010:"#1717171A",50020:"#17171733"},h={200:"#F5F5F5",400:"#3A3A3A",500:"#E5E5E5",600:"#737373"},c={500:"#FFFFFF",50010:"#FFFFFF1A",50020:"#FFFFFF33"},v={400:"#60A5FA",500:"#2563EB"},p={light:{colors:{primary:u[500],secondary:c[500],border:h[500],link:v[500],icon:u[500]},button:{cornerRadius:"4px"}},dark:{colors:{primary:c[500],secondary:u[500],border:h[400],link:v[400],icon:c[500]},button:{cornerRadius:"4px"}}},g=()=>"undefined"==typeof window?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",m=e=>{if("undefined"==typeof window)return()=>{};const t=window.matchMedia("(prefers-color-scheme: dark)"),n=t=>{e(t.matches?"dark":"light")};return t.addEventListener("change",n),()=>{t.removeEventListener("change",n)}},_=(()=>{try{return"undefined"==typeof HTMLElement?class{}:HTMLElement}catch{return class{}}})();class b extends _{constructor(){var e,t,i;super(...arguments),e=this,i=!1,(t=n).has(e)?l("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i)}static get id(){return"courier-base-element"}connectedCallback(){var e,t,i;(a(t=this,i=n,"read from private field"),i.get(t))||(d(this,n,!0),null==(e=this.onComponentMounted)||e.call(this))}disconnectedCallback(){var e;d(this,n,!1),null==(e=this.onComponentUnmounted)||e.call(this)}onComponentMounted(){}onComponentUnmounted(){}}n=new WeakMap;class x extends b{constructor(){super(),r(this,"_currentSystemTheme"),r(this,"_systemThemeCleanup"),this._currentSystemTheme=g(),this._systemThemeCleanup=m((e=>{this._currentSystemTheme=e,this.onSystemThemeChange(e)}))}static get id(){return"courier-system-theme-element"}get currentSystemTheme(){return this._currentSystemTheme}onComponentUnmounted(){var e;null==(e=this._systemThemeCleanup)||e.call(this),super.onComponentUnmounted()}onSystemThemeChange(e){}}const C={borderRadius:"4px",fontSize:"14px"},f=e=>({...C,backgroundColor:p[e].colors.secondary,textColor:p[e].colors.primary,fontWeight:"500",border:`1px solid ${p[e].colors.border}`,shadow:"light"===e?"0px 1px 2px 0px rgba(0, 0, 0, 0.06)":"0px 1px 2px 0px rgba(255, 255, 255, 0.1)"});class y extends x{constructor(e){super(),r(this,"_button"),r(this,"_style");const t=this.attachShadow({mode:"open"});this._button=document.createElement("button"),this._button.setAttribute("part","button"),this._style=document.createElement("style"),this._style.textContent=this.getStyles(e),t.appendChild(this._style),t.appendChild(this._button),this.updateButton(e),this._button.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),e.onClick&&e.onClick()}))}static get id(){return"courier-button"}getStyles(e){return`\n :host {\n display: inline-block;\n }\n\n button {\n border: none;\n border-radius: ${e.borderRadius??(()=>f(this.currentSystemTheme).borderRadius)()};\n font-weight: ${e.fontWeight??(()=>f(this.currentSystemTheme).fontWeight)()};\n font-family: ${e.fontFamily??"inherit"};\n font-size: ${e.fontSize??(()=>f(this.currentSystemTheme).fontSize)()};\n padding: 6px 10px;\n cursor: pointer;\n width: 100%;\n height: 100%;\n background-color: ${e.backgroundColor??(()=>f(this.currentSystemTheme).backgroundColor)()};\n color: ${e.textColor??(()=>f(this.currentSystemTheme).textColor)()};\n border: ${e.border??(()=>f(this.currentSystemTheme).border)()};\n box-shadow: ${e.shadow??(()=>f(this.currentSystemTheme).shadow)()};\n touch-action: manipulation;\n }\n\n button:hover {\n ${e.hoverBackgroundColor?`background-color: ${e.hoverBackgroundColor};`:"filter: brightness(0.9);"}\n }\n\n button:active {\n ${e.activeBackgroundColor?`background-color: ${e.activeBackgroundColor};`:"filter: brightness(0.8);"}\n }\n\n button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n `}updateButton(e){e.text&&(this._button.textContent=e.text),this._style.textContent=this.getStyles(e)}}const k={inbox:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.5 14.5V17C5.5 17.2812 5.71875 17.5 6 17.5H18C18.25 17.5 18.5 17.2812 18.5 17V14.5H15.9375L15.2812 15.8125C15.0938 16.25 14.6562 16.5 14.1875 16.5H9.78125C9.3125 16.5 8.875 16.25 8.6875 15.8125L8.03125 14.5H5.5ZM18.1875 13L16.6562 6.90625C16.5938 6.65625 16.4062 6.5 16.1875 6.5H7.8125C7.5625 6.5 7.375 6.65625 7.3125 6.90625L5.78125 13H8.1875C8.65625 13 9.09375 13.2812 9.3125 13.7188L9.9375 15H14.0312L14.6875 13.7188C14.875 13.2812 15.3125 13 15.7812 13H18.1875ZM4 14.25C4 14.0938 4 13.9375 4.03125 13.7812L5.84375 6.53125C6.09375 5.625 6.875 5 7.8125 5H16.1875C17.0938 5 17.9062 5.625 18.125 6.53125L19.9375 13.7812C19.9688 13.9375 20 14.0938 20 14.25V17C20 18.125 19.0938 19 18 19H6C4.875 19 4 18.125 4 17V14.25Z" fill="currentColor"/>\n</svg>',archive:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.5 6.5V8H18.5V6.5H5.5ZM5 5H19C19.5312 5 20 5.46875 20 6V8.5C20 9.0625 19.5312 9.5 19 9.5H5C4.4375 9.5 4 9.0625 4 8.5V6C4 5.46875 4.4375 5 5 5ZM9 11.75C9 11.3438 9.3125 11 9.75 11H14.25C14.6562 11 15 11.3438 15 11.75C15 12.1875 14.6562 12.5 14.25 12.5H9.75C9.3125 12.5 9 12.1875 9 11.75ZM5 17V10.5H6.5V17C6.5 17.2812 6.71875 17.5 7 17.5H17C17.25 17.5 17.5 17.2812 17.5 17V10.5H19V17C19 18.125 18.0938 19 17 19H7C5.875 19 5 18.125 5 17Z" fill="currentColor"/>\n</svg>',check:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M18.793 7.33203C19.0742 7.64453 19.0742 8.11328 18.793 8.39453L10.543 16.6445C10.2305 16.957 9.76172 16.957 9.48047 16.6445L5.23047 12.3945C4.91797 12.1133 4.91797 11.6445 5.23047 11.3633C5.51172 11.0508 5.98047 11.0508 6.26172 11.3633L9.98047 15.082L17.7305 7.33203C18.0117 7.05078 18.4805 7.05078 18.7617 7.33203H18.793Z" fill="currentColor"/>\n</svg>',filter:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5 7C5 6.59375 5.3125 6.25 5.75 6.25H18.25C18.6562 6.25 19 6.59375 19 7C19 7.4375 18.6562 7.75 18.25 7.75H5.75C5.3125 7.75 5 7.4375 5 7ZM7 12C7 11.5938 7.3125 11.25 7.75 11.25H16.25C16.6562 11.25 17 11.5938 17 12C17 12.4375 16.6562 12.75 16.25 12.75H7.75C7.3125 12.75 7 12.4375 7 12ZM14 17C14 17.4375 13.6562 17.75 13.25 17.75H10.75C10.3125 17.75 10 17.4375 10 17C10 16.5938 10.3125 16.25 10.75 16.25H13.25C13.6562 16.25 14 16.5938 14 17Z" fill="currentColor"/>\n</svg>',overflow:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M18.5117 11.9883C18.5117 12.5508 18.1992 13.0195 17.7617 13.3008C17.293 13.582 16.6992 13.582 16.2617 13.3008C15.793 13.0195 15.5117 12.5508 15.5117 11.9883C15.5117 11.457 15.793 10.9883 16.2617 10.707C16.6992 10.4258 17.293 10.4258 17.7617 10.707C18.1992 10.9883 18.5117 11.457 18.5117 11.9883ZM13.5117 11.9883C13.5117 12.5508 13.1992 13.0195 12.7617 13.3008C12.293 13.582 11.6992 13.582 11.2617 13.3008C10.793 13.0195 10.5117 12.5508 10.5117 11.9883C10.5117 11.457 10.793 10.9883 11.2617 10.707C11.6992 10.4258 12.293 10.4258 12.7617 10.707C13.1992 10.9883 13.5117 11.457 13.5117 11.9883ZM7.01172 13.4883C6.44922 13.4883 5.98047 13.207 5.69922 12.7383C5.41797 12.3008 5.41797 11.707 5.69922 11.2383C5.98047 10.8008 6.44922 10.4883 7.01172 10.4883C7.54297 10.4883 8.01172 10.8008 8.29297 11.2383C8.57422 11.707 8.57422 12.3008 8.29297 12.7383C8.01172 13.207 7.54297 13.4883 7.01172 13.4883Z" fill="currentColor"/>\n</svg>',read:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M7 6.5C6.71875 6.5 6.5 6.75 6.5 7V17C6.5 17.2812 6.71875 17.5 7 17.5H17C17.25 17.5 17.5 17.2812 17.5 17V7C17.5 6.75 17.25 6.5 17 6.5H7ZM5 7C5 5.90625 5.875 5 7 5H17C18.0938 5 19 5.90625 19 7V17C19 18.125 18.0938 19 17 19H7C5.875 19 5 18.125 5 17V7ZM15.5312 10.5312L11.5312 14.5312C11.2188 14.8438 10.75 14.8438 10.4688 14.5312L8.46875 12.5312C8.15625 12.25 8.15625 11.7812 8.46875 11.5C8.75 11.1875 9.21875 11.1875 9.53125 11.5L11 12.9688L14.4688 9.46875C14.75 9.1875 15.2188 9.1875 15.5 9.46875C15.8125 9.78125 15.8125 10.25 15.5 10.5312H15.5312Z" fill="currentColor"/>\n</svg>',archiveRead:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M7.5 6.5V15.25H16.5V6.5H7.5ZM6 15.25V6.5C6 5.6875 6.65625 5 7.5 5H16.5C17.3125 5 18 5.6875 18 6.5V15.25C18.4062 15.25 18.75 15.5938 18.75 16C18.75 16.4375 18.4062 16.75 18 16.75H6C5.5625 16.75 5.25 16.4375 5.25 16C5.25 15.5938 5.5625 15.25 6 15.25ZM5 13V14.5H4.5V17.5H19.5V14.5H19V13H19.5C20.3125 13 21 13.6875 21 14.5V17.5C21 18.3438 20.3125 19 19.5 19H4.5C3.65625 19 3 18.3438 3 17.5V14.5C3 13.6875 3.65625 13 4.5 13H5ZM15.0312 9.625L11.6875 12.9688C11.5312 13.0938 11.3438 13.1875 11.1562 13.1875C10.9375 13.1875 10.75 13.0938 10.625 12.9688L8.96875 11.2812C8.65625 11 8.65625 10.5312 8.96875 10.25C9.25 9.9375 9.71875 9.9375 10 10.25L11.1562 11.375L13.9688 8.5625C14.25 8.28125 14.7188 8.28125 15 8.5625C15.3125 8.875 15.3125 9.34375 15 9.625H15.0312Z" fill="currentColor"/>\n</svg>',unread:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M17 6.5H7C6.71875 6.5 6.5 6.75 6.5 7V17C6.5 17.2812 6.71875 17.5 7 17.5H17C17.25 17.5 17.5 17.2812 17.5 17V7C17.5 6.75 17.25 6.5 17 6.5ZM7 5H17C18.0938 5 19 5.90625 19 7V17C19 18.125 18.0938 19 17 19H7C5.875 19 5 18.125 5 17V7C5 5.90625 5.875 5 7 5Z" fill="currentColor"/>\n</svg>',unarchive:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.5 11C5.0625 11 4.75 10.6875 4.75 10.25V5.75C4.75 5.34375 5.0625 5 5.5 5C5.90625 5 6.25 5.34375 6.25 5.75V8.28125L6.875 7.53125C8.15625 6 10.0625 5 12.25 5C16.0938 5 19.25 8.15625 19.25 12C19.25 15.875 16.0938 19 12.25 19C10.6562 19 9.21875 18.5 8.03125 17.625C7.71875 17.375 7.625 16.9062 7.875 16.5625C8.125 16.2188 8.59375 16.1562 8.9375 16.4062C9.84375 17.0938 11 17.5 12.25 17.5C15.2812 17.5 17.75 15.0625 17.75 12C17.75 8.96875 15.2812 6.5 12.25 6.5C10.5312 6.5 9.03125 7.28125 8 8.5L7.15625 9.5H10C10.4062 9.5 10.75 9.84375 10.75 10.25C10.75 10.6875 10.4062 11 10 11H5.5Z" fill="currentColor"/>\n</svg>'};class S extends b{constructor(e,t){super(),r(this,"_color"),r(this,"_svg"),r(this,"_iconContainer"),r(this,"_style"),this._color=e??u[500],this._svg=t;const n=this.attachShadow({mode:"open"});this._iconContainer=document.createElement("div"),n.appendChild(this._iconContainer),this._style=document.createElement("style"),this._style.textContent=this.getStyles(this._color),n.appendChild(this._style),this.refresh()}static get id(){return"courier-icon"}getStyles(e){return`\n :host {\n display: inline-block;\n line-height: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n svg {\n width: 24px;\n height: 24px;\n color: ${e};\n }\n `}refresh(){this._svg&&(this._iconContainer.innerHTML=this._svg),this._color&&(this._style.textContent=this.getStyles(this._color))}updateColor(e){this._color=e,this.refresh()}updateSVG(e){this._svg=e,this.refresh()}}class w extends b{constructor(){super(),r(this,"link");const e=this.attachShadow({mode:"open"});this.link=document.createElement("a"),this.link.setAttribute("part","link");const t=document.createElement("style");t.textContent=`\n :host {\n display: inline-block;\n }\n\n a {\n text-decoration: none;\n border-radius: 4px;\n cursor: pointer;\n font-weight: 500;\n transition: all 0.2s ease;\n font-family: var(--courier-link-font-family, inherit);\n font-size: var(--courier-link-font-size, inherit);\n }\n\n /* Variants */\n a[data-variant="primary"][data-mode="light"] {\n color: var(--courier-link-color, ${p.light.colors.link});\n }\n\n a[data-variant="primary"][data-mode="light"]:hover {\n opacity: 0.8;\n }\n\n a[data-variant="primary"][data-mode="light"]:active {\n opacity: 0.6;\n }\n\n a[data-variant="primary"][data-mode="dark"] {\n color: var(--courier-link-color, ${p.dark.colors.link});\n }\n\n a[data-variant="primary"][data-mode="dark"]:hover {\n opacity: 0.8;\n }\n\n a[data-variant="primary"][data-mode="dark"]:active {\n opacity: 0.6;\n }\n\n a[data-underline="true"] {\n text-decoration: underline;\n }\n\n a:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n pointer-events: none;\n }\n `,e.appendChild(t),e.appendChild(this.link),this.updateVariant(),this.updateUnderline(),this.updateMode()}static get id(){return"courier-link"}connectedCallback(){const e=document.createElement("slot");this.link.appendChild(e),this.updateHref()}attributeChangedCallback(e,t,n){if(t!==n)switch(e){case"href":this.updateHref();break;case"variant":case"mode":this.updateVariant();break;case"disabled":this.link.style.pointerEvents=this.hasAttribute("disabled")?"none":"auto",this.link.style.opacity=this.hasAttribute("disabled")?"0.6":"1";break;case"color":this.updateColor();break;case"underline":this.updateUnderline();break;case"target":this.updateTarget();break;case"font-family":this.updateFontFamily();break;case"font-size":this.updateFontSize()}}updateHref(){const e=this.getAttribute("href");e&&(this.link.href=e)}updateVariant(){const e=this.getAttribute("variant")||"primary",t=this.getAttribute("mode")||"light";this.link.setAttribute("data-variant",e),this.link.setAttribute("data-mode",t)}updateColor(){const e=this.getAttribute("color");e?this.link.style.setProperty("--courier-link-color",e):this.link.style.removeProperty("--courier-link-color")}updateUnderline(){const e="true"===this.getAttribute("underline");this.link.setAttribute("data-underline",e.toString())}updateMode(){const e=this.getAttribute("mode")||"light";this.link.setAttribute("data-mode",e)}updateTarget(){const e=this.getAttribute("target");e&&(this.link.target=e)}updateFontFamily(){const e=this.getAttribute("font-family");e?this.link.style.setProperty("--courier-link-font-family",e):this.link.style.removeProperty("--courier-link-font-family")}updateFontSize(){const e=this.getAttribute("font-size");e?this.link.style.setProperty("--courier-link-font-size",e):this.link.style.removeProperty("--courier-link-font-size")}}r(w,"observedAttributes",["href","variant","disabled","color","underline","mode","target","font-family","font-size"]);class M extends x{constructor(){super()}build(e){if(null===e)return void this.replaceChildren();const t=e??this.defaultElement();this.replaceChildren(t)}defaultElement(){const e=document.createElement("div");return e.textContent="Default Element Factory",e.style.cssText="\n background-color: red;\n text-align: center;\n padding: 12px;\n ",e}}class I extends M{constructor(e){super(),r(this,"_props"),r(this,"_title"),r(this,"_button"),r(this,"_style"),r(this,"_buttonClickCallback",null),this._props=e}static get id(){return"courier-info-state"}defaultElement(){var e,t;const n=document.createElement("div");return this._title=document.createElement("h2"),(null==(e=this._props.title)?void 0:e.text)&&(this._title.textContent=this._props.title.text),this._button=new y(this._props.button??f(this.currentSystemTheme)),this._style=document.createElement("style"),this._style.textContent=this.getStyles(this._props),n.className="container",n.appendChild(this._style),n.appendChild(this._title),n.appendChild(this._button),this.appendChild(n),null==(t=this._button)||t.addEventListener("click",(()=>{this._buttonClickCallback&&this._buttonClickCallback()})),n}onSystemThemeChange(e){this.updateStyles(this._props)}getStyles(e){var t,n,i,o;return`\n :host {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n width: 100%;\n }\n\n .container {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 16px;\n text-align: center;\n padding: 24px;\n box-sizing: border-box;\n height: 100%;\n }\n\n .container h2 {\n margin: 0;\n color: ${(null==(t=e.title)?void 0:t.textColor)??"red"};\n font-size: ${(null==(n=e.title)?void 0:n.fontSize)??"16px"};\n font-weight: ${(null==(i=e.title)?void 0:i.fontWeight)??"500"};\n font-family: ${(null==(o=e.title)?void 0:o.fontFamily)??"inherit"};\n }\n `}updateStyles(e){this._props=e,this._style&&(this._style.textContent=this.getStyles(e)),this._button&&this._button.updateButton(e.button)}setButtonClickCallback(e){this._buttonClickCallback=e}}class E extends b{constructor(e,t,n,i,o,s,l,a){super(),r(this,"_backgroundColor"),r(this,"_hoverBackgroundColor"),r(this,"_activeBackgroundColor"),r(this,"_borderRadius"),r(this,"_height"),r(this,"_width"),r(this,"_style"),r(this,"_button"),r(this,"_icon"),this._borderRadius=s,this._backgroundColor=n,this._hoverBackgroundColor=i,this._activeBackgroundColor=o,this._height=l,this._width=a;const d=this.attachShadow({mode:"open"});this._button=document.createElement("button"),this._button.setAttribute("part","button"),this._icon=new S(t,e),this._style=document.createElement("style"),this.refresh(),d.appendChild(this._style),this._button.appendChild(this._icon),d.appendChild(this._button)}static get id(){return"courier-icon-button"}refresh(){this._style.textContent=this.getStyles()}getStyles(){return`\n :host {\n display: inline-block;\n border-radius: ${this._borderRadius??"50%"};\n }\n\n button {\n border: none;\n border-radius: ${this._borderRadius??"50%"};\n cursor: pointer;\n width: ${this._width??"36px"};\n height: ${this._height??"36px"};\n display: flex;\n align-items: center;\n justify-content: center;\n background: ${this._backgroundColor??"transparent"};\n transition: background-color 0.2s ease;\n touch-action: manipulation;\n }\n\n button:hover {\n background-color: ${this._hoverBackgroundColor??"red"};\n }\n\n button:active {\n background-color: ${this._activeBackgroundColor??"red"};\n }\n\n button:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n }\n\n [part="icon"] {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n }\n `}updateIconColor(e){this._icon.updateColor(e)}updateIconSVG(e){this._icon.updateSVG(e)}updateBackgroundColor(e){this._backgroundColor=e,this.refresh()}updateHoverBackgroundColor(e){this._hoverBackgroundColor=e,this.refresh()}updateActiveBackgroundColor(e){this._activeBackgroundColor=e,this.refresh()}}function $(e){"undefined"==typeof window||customElements.get(e.id)||customElements.define(e.id,e)}function T(e,t){const n=`style[data-${e}]`,i=document.querySelector(n);if(!i){const n=document.createElement("style");return n.setAttribute(`data-${e}`,""),n.textContent=t,document.head.appendChild(n),n}return i}function D(e){const t={...e};return e.actions&&(t.actions=e.actions.map((e=>function(e){const t={...e};e.data&&(t.data=JSON.parse(JSON.stringify(e.data)));return t}(e)))),e.data&&(t.data=JSON.parse(JSON.stringify(e.data))),e.tags&&(t.tags=[...e.tags]),e.trackingIds&&(t.trackingIds={...e.trackingIds}),t}function L(e){if(e)return{...e,messages:e.messages.map((e=>D(e)))}}$(y),$(S),$(w),$(I),$(E),$(x);class A extends b{constructor(e){super(),o(this,"_theme"),o(this,"_options",[]),this._theme=e}static get id(){return"courier-inbox-list-item-menu"}onComponentMounted(){const e=document.createElement("ul");e.className="menu",this.appendChild(e)}static getStyles(e){var t,n,i;const o=null==(i=null==(n=null==(t=e.inbox)?void 0:t.list)?void 0:n.item)?void 0:i.menu;return`\n ${A.id} {\n display: none;\n position: absolute;\n background: ${(null==o?void 0:o.backgroundColor)??"red"};\n border: ${(null==o?void 0:o.border)??"1px solid red"};\n border-radius: ${(null==o?void 0:o.borderRadius)??"0px"};\n box-shadow: ${(null==o?void 0:o.shadow)??"0 2px 8px red"};\n user-select: none;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s;\n overflow: hidden;\n }\n\n ${A.id}.visible {\n display: block;\n opacity: 1;\n pointer-events: auto;\n }\n\n ${A.id} ul.menu {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: row;\n }\n\n ${A.id} li.menu-item {\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n border-bottom: none;\n background: transparent;\n }\n `}setOptions(e){this._options=e,this.renderMenu()}renderMenu(){var e,t,n;const i=this.querySelector("ul.menu");if(!i)return;i.innerHTML="";const o=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.menu,s=e=>{e.stopPropagation(),e.preventDefault()};this._options.forEach((e=>{var t,n,l;const r=new E(e.icon.svg,e.icon.color,null==o?void 0:o.backgroundColor,null==(t=null==o?void 0:o.item)?void 0:t.hoverBackgroundColor,null==(n=null==o?void 0:o.item)?void 0:n.activeBackgroundColor,null==(l=null==o?void 0:o.item)?void 0:l.borderRadius),a=t=>{s(t),e.onClick()};r.addEventListener("click",a),r.addEventListener("touchstart",s),r.addEventListener("touchend",a),r.addEventListener("touchmove",s),r.addEventListener("mousedown",s),r.addEventListener("mouseup",s),i.appendChild(r)}))}show(){this.style.display="block",this.classList.add("visible")}hide(){this.style.display="none",this.classList.remove("visible")}}$(A);const B=class e{constructor(){o(this,"_inboxDataSet"),o(this,"_archiveDataSet"),o(this,"_dataStoreListeners",[]),o(this,"_unreadCount"),o(this,"isPaginatingInbox",!1),o(this,"isPaginatingArchive",!1)}static get shared(){return e.instance||(e.instance=new e),e.instance}get unreadCount(){return this._unreadCount??0}get inboxDataSet(){return this._inboxDataSet??{feedType:"inbox",messages:[],canPaginate:!1,paginationCursor:null}}get archiveDataSet(){return this._archiveDataSet??{feedType:"archive",messages:[],canPaginate:!1,paginationCursor:null}}addDataStoreListener(e){this._dataStoreListeners.push(e)}removeDataStoreListener(e){this._dataStoreListeners=this._dataStoreListeners.filter((t=>t!==e))}async fetchCachableDataSet(e){var t,n,i,o,s,l,r,a;if(e.canUseCache){if("inbox"===e.feedType&&this._inboxDataSet)return this._inboxDataSet;if("archive"===e.feedType&&this._archiveDataSet)return this._archiveDataSet}const d=await e.fetch;return{feedType:e.feedType,messages:(null==(n=null==(t=d.data)?void 0:t.messages)?void 0:n.nodes)??[],canPaginate:(null==(s=null==(o=null==(i=d.data)?void 0:i.messages)?void 0:o.pageInfo)?void 0:s.hasNextPage)??!1,paginationCursor:(null==(a=null==(r=null==(l=d.data)?void 0:l.messages)?void 0:r.pageInfo)?void 0:a.startCursor)??null}}async fetchUnreadCount(e){var n;if(e.canUseCache&&void 0!==this._unreadCount)return this._unreadCount;return await(null==(n=t.Courier.shared.client)?void 0:n.inbox.getUnreadMessageCount())??0}async load(e){var n,i;try{const n=t.Courier.shared.client;if(!(null==n?void 0:n.options.userId))throw new Error("User is not signed in");const i=e??{canUseCache:!0},[o,s,l]=await Promise.all([this.fetchCachableDataSet({fetch:n.inbox.getMessages(),feedType:"inbox",canUseCache:i.canUseCache}),this.fetchCachableDataSet({fetch:n.inbox.getArchivedMessages(),feedType:"archive",canUseCache:i.canUseCache}),this.fetchUnreadCount(i)]);this._inboxDataSet=o,this._archiveDataSet=s,this._unreadCount=l,this._dataStoreListeners.forEach((e=>{var t,n,i,o,s,l;this._inboxDataSet&&(null==(n=(t=e.events).onDataSetChange)||n.call(t,this._inboxDataSet,"inbox")),this._archiveDataSet&&(null==(o=(i=e.events).onDataSetChange)||o.call(i,this._archiveDataSet,"archive")),null==(l=(s=e.events).onUnreadCountChange)||l.call(s,this._unreadCount??0)}))}catch(o){null==(i=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||i.error("Error loading inbox:",o),this._dataStoreListeners.forEach((e=>{var t,n;null==(n=(t=e.events).onError)||n.call(t,o)}))}}async listenForUpdates(){var e,n;try{await this.connectSocket()}catch(i){null==(n=null==(e=t.Courier.shared.client)?void 0:e.options.logger)||n.error("Error listening for updates:",i),this._dataStoreListeners.forEach((e=>{var t,n;null==(n=(t=e.events).onError)||n.call(t,i)}))}}async connectSocket(){var e,n,i,o,s,l,r,a,d,u,h;const c=null==(e=t.Courier.shared.client)?void 0:e.inbox.socket;try{if(!c)return void(null==(i=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||i.info("CourierInbox socket not available"));if(c.isConnecting||c.isOpen)return void(null==(l=null==(o=t.Courier.shared.client)?void 0:o.options.logger)||l.info(`Inbox socket already connecting or open for client ID: [${null==(s=t.Courier.shared.client)?void 0:s.options.connectionId}]`));c.addMessageEventListener((e=>{if(e.event===t.InboxMessageEvent.NewMessage){const t=e.data;return void this.addMessage(t,0,"inbox")}const n=this.getMessage({messageId:e.messageId});switch(e.event){case t.InboxMessageEvent.MarkAllRead:this.readAllMessages({canCallApi:!1});break;case t.InboxMessageEvent.Read:n&&this.readMessage({message:n,canCallApi:!1});break;case t.InboxMessageEvent.Unread:n&&this.unreadMessage({message:n,canCallApi:!1});break;case t.InboxMessageEvent.Opened:n&&this.openMessage({message:n,canCallApi:!1});break;case t.InboxMessageEvent.Archive:n&&this.archiveMessage({message:n,canCallApi:!1});break;case t.InboxMessageEvent.ArchiveRead:this.archiveReadMessages({canCallApi:!1});break;case t.InboxMessageEvent.ArchiveAll:this.archiveAllMessages({canCallApi:!1});break;case t.InboxMessageEvent.Clicked:n&&this.clickMessage({message:n,canCallApi:!1});break;case t.InboxMessageEvent.Unarchive:n&&this.unarchiveMessage({message:n,canCallApi:!1});case t.InboxMessageEvent.Unopened:}})),await c.connect(),null==(d=null==(r=t.Courier.shared.client)?void 0:r.options.logger)||d.info(`Inbox socket connected for client ID: [${null==(a=t.Courier.shared.client)?void 0:a.options.connectionId}]`)}catch(v){null==(h=null==(u=t.Courier.shared.client)?void 0:u.options.logger)||h.error("Failed to connect socket:",v)}}getMessage(e){var t,n;if(e.messageId)return(null==(t=this._inboxDataSet)?void 0:t.messages.find((t=>t.messageId===e.messageId)))??(null==(n=this._archiveDataSet)?void 0:n.messages.find((t=>t.messageId===e.messageId)))}async fetchNextPageOfMessages(e){var n,i,o,s,l,r,a,d,u,h,c,v,p,g,m,_,b,x,C,f,y,k,S,w;switch(e.feedType){case"inbox":if(this.isPaginatingInbox)return null;if((null==(n=this._inboxDataSet)?void 0:n.canPaginate)&&this._inboxDataSet.paginationCursor)try{this.isPaginatingInbox=!0;const e=await(null==(i=t.Courier.shared.client)?void 0:i.inbox.getMessages({paginationLimit:t.Courier.shared.paginationLimit,startCursor:this._inboxDataSet.paginationCursor})),n={feedType:"inbox",messages:(null==(s=null==(o=null==e?void 0:e.data)?void 0:o.messages)?void 0:s.nodes)??[],canPaginate:(null==(a=null==(r=null==(l=null==e?void 0:e.data)?void 0:l.messages)?void 0:r.pageInfo)?void 0:a.hasNextPage)??!1,paginationCursor:(null==(h=null==(u=null==(d=null==e?void 0:e.data)?void 0:d.messages)?void 0:u.pageInfo)?void 0:h.startCursor)??null};return this.addPage(n),n}catch(M){return null==(v=null==(c=t.Courier.shared.client)?void 0:c.options.logger)||v.error("Error fetching next page of inbox messages:",M),null}finally{this.isPaginatingInbox=!1}break;case"archive":if(this.isPaginatingArchive)return null;if((null==(p=this._archiveDataSet)?void 0:p.canPaginate)&&this._archiveDataSet.paginationCursor)try{this.isPaginatingArchive=!0;const e=await(null==(g=t.Courier.shared.client)?void 0:g.inbox.getArchivedMessages({paginationLimit:t.Courier.shared.paginationLimit,startCursor:this._archiveDataSet.paginationCursor})),n={feedType:"archive",messages:(null==(_=null==(m=null==e?void 0:e.data)?void 0:m.messages)?void 0:_.nodes)??[],canPaginate:(null==(C=null==(x=null==(b=null==e?void 0:e.data)?void 0:b.messages)?void 0:x.pageInfo)?void 0:C.hasNextPage)??!1,paginationCursor:(null==(k=null==(y=null==(f=null==e?void 0:e.data)?void 0:f.messages)?void 0:y.pageInfo)?void 0:k.startCursor)??null};return this.addPage(n),n}catch(M){return null==(w=null==(S=t.Courier.shared.client)?void 0:S.options.logger)||w.error("Error fetching next page of archived messages:",M),null}finally{this.isPaginatingArchive=!1}}return null}canMutate(){return!!(t.Courier.shared.client&&this._inboxDataSet&&this._archiveDataSet)}async readMessage({message:e,canCallApi:n=!0}){var i,o,s;if(!this.canMutate())return;const l=this.getDatastoreSnapshot(this.unreadCount,this._inboxDataSet,this._archiveDataSet),r=this.getMessageSnapshot(e);if(!r.message.read)try{r.message.read=(new Date).toISOString(),this.applyMessageSnapshot(r),this._unreadCount=l.unreadCount-1,this._dataStoreListeners.forEach((e=>{var t,n;null==(n=(t=e.events).onUnreadCountChange)||n.call(t,this._unreadCount)})),n&&await(null==(i=t.Courier.shared.client)?void 0:i.inbox.read({messageId:e.messageId}))}catch(a){null==(s=null==(o=t.Courier.shared.client)?void 0:o.options.logger)||s.error("Error reading message:",a),this.applyDatastoreSnapshot(l)}}async unreadMessage({message:e,canCallApi:n=!0}){var i,o,s;if(!this.canMutate())return;const l=this.getDatastoreSnapshot(this.unreadCount,this._inboxDataSet,this._archiveDataSet),r=this.getMessageSnapshot(e);if(r.message.read)try{r.message.read=void 0,this.applyMessageSnapshot(r),this._unreadCount=l.unreadCount+1,this._dataStoreListeners.forEach((e=>{var t,n;null==(n=(t=e.events).onUnreadCountChange)||n.call(t,this._unreadCount)})),n&&await(null==(i=t.Courier.shared.client)?void 0:i.inbox.unread({messageId:e.messageId}))}catch(a){null==(s=null==(o=t.Courier.shared.client)?void 0:o.options.logger)||s.error("Error unreading message:",a),this.applyDatastoreSnapshot(l)}}async openMessage({message:e,canCallApi:n=!0}){var i,o,s;if(!this.canMutate())return;const l=this.getMessageSnapshot(e);if((void 0!==l.inboxIndex||void 0!==l.archiveIndex)&&!l.message.opened)try{e.opened=(new Date).toISOString(),this.applyMessageSnapshot(l),n&&await(null==(i=t.Courier.shared.client)?void 0:i.inbox.open({messageId:e.messageId}))}catch(r){this.applyMessageSnapshot(l),null==(s=null==(o=t.Courier.shared.client)?void 0:o.options.logger)||s.error("Error opening message:",r)}}async clickMessage({message:e,canCallApi:n=!0}){var i,o,s,l,r;if(this.canMutate())try{(null==(i=e.trackingIds)?void 0:i.clickTrackingId)&&n&&await(null==(s=t.Courier.shared.client)?void 0:s.inbox.click({messageId:e.messageId,trackingId:null==(o=e.trackingIds)?void 0:o.clickTrackingId}))}catch(a){null==(r=null==(l=t.Courier.shared.client)?void 0:l.options.logger)||r.error("Error clicking message:",a)}}async archiveMessage({message:e,canCallApi:n=!0}){var i,o,s,l;if(!this.canMutate())return;const r=this.getMessageSnapshot(e);if(void 0===r.inboxIndex)return;const a=this.getDatastoreSnapshot(this.unreadCount,this._inboxDataSet,this._archiveDataSet);try{if(e.archived=(new Date).toISOString(),this.removeMessage(e,r.inboxIndex,"inbox"),null==(i=this._archiveDataSet)?void 0:i.messages){const t=this.findInsertIndex(e,this._archiveDataSet);this.addMessage(e,t,"archive")}n&&await(null==(o=t.Courier.shared.client)?void 0:o.inbox.archive({messageId:e.messageId}))}catch(d){null==(l=null==(s=t.Courier.shared.client)?void 0:s.options.logger)||l.error("Error archiving message:",d),this.applyDatastoreSnapshot(a)}}async unarchiveMessage({message:e,canCallApi:n=!0}){var i,o,s,l;if(!this.canMutate())return;const r=this.getDatastoreSnapshot(this.unreadCount,this._inboxDataSet,this._archiveDataSet),a=this.getMessageSnapshot(e);if(void 0!==a.archiveIndex)try{if(a.message.archived=void 0,this.removeMessage(e,a.archiveIndex,"archive"),null==(i=this._inboxDataSet)?void 0:i.messages){const t=this.findInsertIndex(e,this._inboxDataSet);this.addMessage(e,t,"inbox")}n&&await(null==(o=t.Courier.shared.client)?void 0:o.inbox.unarchive({messageId:e.messageId}))}catch(d){null==(l=null==(s=t.Courier.shared.client)?void 0:s.options.logger)||l.error("Error unarchiving message:",d),this.applyDatastoreSnapshot(r)}}async archiveReadMessages({canCallApi:e=!0}={}){var n,i,o,s;if(!this.canMutate())return;const l=this.getDatastoreSnapshot(this.unreadCount,this._inboxDataSet,this._archiveDataSet);try{const o=(new Date).toISOString();((null==(n=this._inboxDataSet)?void 0:n.messages.filter((e=>e.read)))??[]).forEach((e=>{var t,n,i;e.archived=o;const s=null==(t=this._inboxDataSet)?void 0:t.messages.findIndex((t=>t.messageId===e.messageId));if(void 0!==s&&-1!==s&&(null==(n=this._inboxDataSet)||n.messages.splice(s,1)),null==(i=this._archiveDataSet)?void 0:i.messages){const t=this.findInsertIndex(e,this._archiveDataSet);this._archiveDataSet.messages.splice(t,0,e)}})),this._dataStoreListeners.forEach((e=>{var t,n,i,o;this._inboxDataSet&&(null==(n=(t=e.events).onDataSetChange)||n.call(t,this._inboxDataSet,"inbox")),this._archiveDataSet&&(null==(o=(i=e.events).onDataSetChange)||o.call(i,this._archiveDataSet,"archive"))})),e&&await(null==(i=t.Courier.shared.client)?void 0:i.inbox.archiveRead())}catch(r){null==(s=null==(o=t.Courier.shared.client)?void 0:o.options.logger)||s.error("Error archiving read messages:",r),this.applyDatastoreSnapshot(l)}}async archiveAllMessages({canCallApi:e=!0}={}){var n,i,o,s;if(!this.canMutate())return;const l=this.getDatastoreSnapshot(this.unreadCount,this._inboxDataSet,this._archiveDataSet);try{const o=(new Date).toISOString();null==(n=this._inboxDataSet)||n.messages.forEach((e=>{var t;if(e.archived=o,null==(t=this._archiveDataSet)?void 0:t.messages){const t=this.findInsertIndex(e,this._archiveDataSet);this._archiveDataSet.messages.splice(t,0,e)}})),this._inboxDataSet={messages:[],canPaginate:!1,paginationCursor:null,feedType:"inbox"},this._unreadCount=0,this._dataStoreListeners.forEach((e=>{var t,n,i,o,s,l;this._inboxDataSet&&(null==(n=(t=e.events).onDataSetChange)||n.call(t,this._inboxDataSet,"inbox")),this._archiveDataSet&&(null==(o=(i=e.events).onDataSetChange)||o.call(i,this._archiveDataSet,"archive")),null==(l=(s=e.events).onUnreadCountChange)||l.call(s,this._unreadCount)})),e&&await(null==(i=t.Courier.shared.client)?void 0:i.inbox.archiveAll())}catch(r){null==(s=null==(o=t.Courier.shared.client)?void 0:o.options.logger)||s.error("Error archiving all messages:",r),this.applyDatastoreSnapshot(l)}}async readAllMessages({canCallApi:e=!0}={}){var n,i,o,s,l;if(!this.canMutate())return;const r=this.getDatastoreSnapshot(this.unreadCount,this._inboxDataSet,this._archiveDataSet);try{const s=(new Date).toISOString();null==(n=this._inboxDataSet)||n.messages.forEach((e=>{e.read||(e.read=s)})),null==(i=this._archiveDataSet)||i.messages.forEach((e=>{e.read||(e.read=s)})),this._unreadCount=0,this._dataStoreListeners.forEach((e=>{var t,n,i,o,s,l;this._inboxDataSet&&(null==(n=(t=e.events).onDataSetChange)||n.call(t,this._inboxDataSet,"inbox")),this._archiveDataSet&&(null==(o=(i=e.events).onDataSetChange)||o.call(i,this._archiveDataSet,"archive")),null==(l=(s=e.events).onUnreadCountChange)||l.call(s,this._unreadCount)})),e&&await(null==(o=t.Courier.shared.client)?void 0:o.inbox.readAll())}catch(a){null==(l=null==(s=t.Courier.shared.client)?void 0:s.options.logger)||l.error("Error reading all messages:",a),this.applyDatastoreSnapshot(r)}}findInsertIndex(e,t){const n=t.messages;for(let i=0;i<n.length;i++){const t=n[i];if(t.created&&e.created&&t.created<e.created)return i}return n.length}addPage(e){switch(e.feedType){case"inbox":this._inboxDataSet&&(this._inboxDataSet.canPaginate=e.canPaginate,this._inboxDataSet.paginationCursor=e.paginationCursor,this._inboxDataSet.messages=[...this._inboxDataSet.messages,...e.messages]);break;case"archive":this._archiveDataSet&&(this._archiveDataSet.canPaginate=e.canPaginate,this._archiveDataSet.paginationCursor=e.paginationCursor,this._archiveDataSet.messages=[...this._archiveDataSet.messages,...e.messages])}this._dataStoreListeners.forEach((t=>{var n,i;return null==(i=(n=t.events).onPageAdded)?void 0:i.call(n,e,e.feedType)}))}addMessage(e,t,n){var i,o;switch(n){case"inbox":e.read||void 0===this._unreadCount||(this._unreadCount=this._unreadCount+1),null==(i=this._inboxDataSet)||i.messages.splice(t,0,e);break;case"archive":null==(o=this._archiveDataSet)||o.messages.splice(t,0,e)}this._dataStoreListeners.forEach((i=>{var o,s,l,r;null==(s=(o=i.events).onMessageAdd)||s.call(o,e,t,n),null==(r=(l=i.events).onUnreadCountChange)||r.call(l,this._unreadCount??0)}))}removeMessage(e,t,n){var i,o;switch(n){case"inbox":e.read||void 0===this._unreadCount||(this._unreadCount=this._unreadCount-1),null==(i=this._inboxDataSet)||i.messages.splice(t,1);break;case"archive":null==(o=this._archiveDataSet)||o.messages.splice(t,1)}this._dataStoreListeners.forEach((i=>{var o,s,l,r;null==(s=(o=i.events).onMessageRemove)||s.call(o,e,t,n),null==(r=(l=i.events).onUnreadCountChange)||r.call(l,this._unreadCount??0)}))}applyMessageSnapshot(e){void 0!==e.archiveIndex&&this.updateMessage(e.message,e.archiveIndex,"archive"),void 0!==e.inboxIndex&&this.updateMessage(e.message,e.inboxIndex,"inbox")}applyDatastoreSnapshot(e){const{unreadCount:t,inbox:n,archive:i}=e;this._inboxDataSet=n,this._archiveDataSet=i,this._dataStoreListeners.forEach((e=>{var n,i,o,s,l,r;this._inboxDataSet&&(null==(i=(n=e.events).onDataSetChange)||i.call(n,this._inboxDataSet,"inbox")),this._archiveDataSet&&(null==(s=(o=e.events).onDataSetChange)||s.call(o,this._archiveDataSet,"archive")),null==(r=(l=e.events).onUnreadCountChange)||r.call(l,t)}))}updateMessage(e,t,n){switch(n){case"inbox":void 0===this._unreadCount||e.archived||(e.read&&(this._unreadCount=Math.max(0,this._unreadCount-1)),e.read||(this._unreadCount=this._unreadCount+1)),this._inboxDataSet&&(this._inboxDataSet.messages[t]=e);break;case"archive":this._archiveDataSet&&(this._archiveDataSet.messages[t]=e)}this._dataStoreListeners.forEach((i=>{var o,s,l,r;null==(s=(o=i.events).onMessageUpdate)||s.call(o,e,t,n),null==(r=(l=i.events).onUnreadCountChange)||r.call(l,this._unreadCount??0)}))}getDatastoreSnapshot(e,t,n){return{unreadCount:e,inbox:L(t),archive:L(n)}}getMessageSnapshot(e){const t=this._archiveDataSet?this._archiveDataSet.messages.findIndex((t=>t.messageId===e.messageId)):void 0,n=this._inboxDataSet?this._inboxDataSet.messages.findIndex((t=>t.messageId===e.messageId)):void 0;return{message:D(e),archiveIndex:t,inboxIndex:n}}};o(B,"instance");let P=B;class F extends b{constructor(e){super(),o(this,"_theme"),o(this,"_message",null),o(this,"_feedType","inbox"),o(this,"_isMobile",!1),o(this,"_titleElement"),o(this,"_subtitleElement"),o(this,"_timeElement"),o(this,"_menu"),o(this,"_unreadIndicator"),o(this,"_actionsContainer"),o(this,"_longPressTimeout",null),o(this,"_isLongPress",!1),o(this,"onItemClick",null),o(this,"onItemLongPress",null),o(this,"onItemActionClick",null),this._theme=e,this._isMobile="ontouchstart"in window,this.render()}static get id(){return"courier-inbox-list-item"}render(){const e=document.createElement("div");e.className="content-container",this._titleElement=document.createElement("p"),this._titleElement.className="title",this._subtitleElement=document.createElement("p"),this._subtitleElement.className="subtitle",this._actionsContainer=document.createElement("div"),this._actionsContainer.className="actions-container",e.appendChild(this._titleElement),e.appendChild(this._subtitleElement),e.appendChild(this._actionsContainer),this._timeElement=document.createElement("p"),this._timeElement.className="time",this._unreadIndicator=document.createElement("div"),this._unreadIndicator.className="unread-indicator",this._menu=new A(this._theme),this._menu.setOptions(this._getMenuOptions()),this.append(this._unreadIndicator,e,this._timeElement,this._menu);const t=e=>{e.stopPropagation(),e.preventDefault()};this._menu.addEventListener("mousedown",t),this._menu.addEventListener("pointerdown",t),this._menu.addEventListener("click",t),this.addEventListener("click",(e=>{this._menu&&(this._menu.contains(e.target)||e.composedPath().includes(this._menu))||!this._message||!this.onItemClick||e.target instanceof S||this._isLongPress||this.onItemClick(this._message)})),this._setupHoverBehavior(),this._setupLongPressBehavior()}static getStyles(e){var t,n,i,o,s,l,r,a,d,u,h,c,v,p,g,m,_,b,x,C,f,y,k,S,w,M;const I=null==(t=e.inbox)?void 0:t.list;return`\n ${F.id} {\n display: flex;\n flex-direction: row;\n align-items: flex-start;\n justify-content: space-between;\n border-bottom: ${(null==(n=null==I?void 0:I.item)?void 0:n.divider)??"1px solid red"};\n font-family: inherit;\n cursor: pointer;\n transition: background-color 0.2s ease;\n margin: 0;\n width: 100%;\n box-sizing: border-box;\n padding: 12px 20px;\n position: relative;\n background-color: ${(null==(i=null==I?void 0:I.item)?void 0:i.backgroundColor)??"transparent"};\n user-select: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n touch-action: manipulation;\n }\n\n /* Base hover / active */\n @media (hover: hover) {\n ${F.id}:hover {\n background-color: ${(null==(o=null==I?void 0:I.item)?void 0:o.hoverBackgroundColor)??"red"};\n }\n }\n\n ${F.id}:active {\n background-color: ${(null==(s=null==I?void 0:I.item)?void 0:s.activeBackgroundColor)??"red"};\n }\n\n /* Menu hover / active */\n @media (hover: hover) {\n ${F.id}:hover:has(courier-inbox-list-item-menu:hover, courier-inbox-list-item-menu *:hover, courier-button:hover, courier-button *:hover) {\n background-color: ${(null==(l=null==I?void 0:I.item)?void 0:l.backgroundColor)??"transparent"};\n }\n }\n\n ${F.id}:active:has(courier-inbox-list-item-menu:active, courier-inbox-list-item-menu *:active, courier-button:active, courier-button *:active) {\n background-color: ${(null==(r=null==I?void 0:I.item)?void 0:r.backgroundColor)??"transparent"};\n }\n\n ${F.id}:last-child {\n border-bottom: none;\n }\n\n ${F.id} .unread-indicator {\n position: absolute;\n top: 28px;\n left: 6px;\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background-color: ${(null==(a=null==I?void 0:I.item)?void 0:a.unreadIndicatorColor)??"red"};\n display: none;\n }\n\n ${F.id}.unread .unread-indicator {\n display: block;\n }\n\n ${F.id} .content-container {\n flex: 1;\n display: flex;\n flex-direction: column;\n margin-right: 12px;\n }\n\n ${F.id} p {\n margin: 0;\n overflow-wrap: break-word;\n word-break: break-word;\n hyphens: auto;\n line-height: 1.4;\n user-select: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n text-align: left;\n }\n\n ${F.id} .title {\n font-family: ${(null==(u=null==(d=null==I?void 0:I.item)?void 0:d.title)?void 0:u.family)??"inherit"};\n font-size: ${(null==(c=null==(h=null==I?void 0:I.item)?void 0:h.title)?void 0:c.size)??"14px"};\n color: ${(null==(p=null==(v=null==I?void 0:I.item)?void 0:v.title)?void 0:p.color)??"red"};\n margin-bottom: 4px;\n }\n\n ${F.id} .subtitle {\n font-family: ${(null==(m=null==(g=null==I?void 0:I.item)?void 0:g.subtitle)?void 0:m.family)??"inherit"};\n font-size: ${(null==(b=null==(_=null==I?void 0:I.item)?void 0:_.subtitle)?void 0:b.size)??"14px"};\n color: ${(null==(C=null==(x=null==I?void 0:I.item)?void 0:x.subtitle)?void 0:C.color)??"red"};\n }\n\n ${F.id} .time {\n font-family: ${(null==(y=null==(f=null==I?void 0:I.item)?void 0:f.time)?void 0:y.family)??"inherit"};\n font-size: ${(null==(S=null==(k=null==I?void 0:I.item)?void 0:k.time)?void 0:S.size)??"14px"};\n color: ${(null==(M=null==(w=null==I?void 0:I.item)?void 0:w.time)?void 0:M.color)??"red"};\n text-align: right;\n white-space: nowrap;\n }\n\n ${F.id} courier-inbox-list-item-menu {\n z-index: 1;\n position: absolute;\n top: 8px;\n right: 8px;\n display: none;\n }\n\n ${F.id} .actions-container {\n display: flex;\n margin-top: 10px;\n flex-wrap: wrap;\n flex-direction: row;\n align-items: center;\n gap: 8px;\n display: none;\n }\n `}_setupHoverBehavior(){this._isMobile||(this.addEventListener("mouseenter",(()=>{this._isLongPress=!1,this._showMenu()})),this.addEventListener("mouseleave",(()=>this._hideMenu())))}_setupLongPressBehavior(){var e,t,n;const i=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.menu;if(!(null==i?void 0:i.enabled))return;const o=i.longPress;this.addEventListener("touchstart",(()=>{this._longPressTimeout=window.setTimeout((()=>{this._isLongPress=!0,this._showMenu(),this._message&&this.onItemLongPress&&(this.onItemLongPress(this._message),navigator.vibrate&&navigator.vibrate((null==o?void 0:o.vibrationDuration)??50)),setTimeout((()=>{this._hideMenu(),this._isLongPress=!1}),(null==o?void 0:o.displayDuration)??2e3)}),650)}),{passive:!0}),this.addEventListener("touchend",(()=>{this._longPressTimeout&&(window.clearTimeout(this._longPressTimeout),this._longPressTimeout=null)}))}setOnLongPress(e){this.onItemLongPress=e}_getMenuOptions(){var e,t,n,i,o,s,l,r,a,d,u,h,c,v,p;const g=null==(i=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.menu)?void 0:i.item;let m=[];const _="archive"===this._feedType;return _||m.push({id:(null==(o=this._message)?void 0:o.read)?"unread":"read",icon:{svg:(null==(s=this._message)?void 0:s.read)?null==(l=null==g?void 0:g.unread)?void 0:l.svg:null==(r=null==g?void 0:g.read)?void 0:r.svg,color:(null==(a=this._message)?void 0:a.read)?null==(d=null==g?void 0:g.unread)?void 0:d.color:(null==(u=null==g?void 0:g.read)?void 0:u.color)??"red"},onClick:()=>{this._message&&(this._message.read?P.shared.unreadMessage({message:this._message}):P.shared.readMessage({message:this._message}))}}),m.push({id:_?"unarchive":"archive",icon:{svg:_?null==(h=null==g?void 0:g.unarchive)?void 0:h.svg:null==(c=null==g?void 0:g.archive)?void 0:c.svg,color:_?null==(v=null==g?void 0:g.unarchive)?void 0:v.color:(null==(p=null==g?void 0:g.archive)?void 0:p.color)??"red"},onClick:()=>{this._message&&(_?P.shared.unarchiveMessage({message:this._message}):P.shared.archiveMessage({message:this._message}))}}),m}_showMenu(){var e,t,n;const i=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.menu;i&&i.enabled&&this._menu&&this._timeElement&&(this._menu.setOptions(this._getMenuOptions()),this._menu.style.display="block",this._menu.show(),this._timeElement.style.opacity="0")}_hideMenu(){var e,t,n;const i=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.menu;i&&i.enabled&&this._menu&&this._timeElement&&(this._menu.hide(),this._menu.style.display="none",this._timeElement.style.opacity="1")}setMessage(e,t){this._message=e,this._feedType=t,this._updateContent()}setOnItemClick(e){this.onItemClick=e}setOnItemActionClick(e){this.onItemActionClick=e}setOnItemLongPress(e){this.onItemLongPress=e}_updateContent(){var e,t,n;if(!this._message)return this._titleElement&&(this._titleElement.textContent=""),void(this._subtitleElement&&(this._subtitleElement.textContent=""));this.classList.toggle("unread",!this._message.read&&"archive"!==this._feedType),this._titleElement&&(this._titleElement.textContent=this._message.title||"Untitled Message"),this._subtitleElement&&(this._subtitleElement.textContent=this._message.preview||this._message.body||""),this._timeElement&&(this._timeElement.textContent=function(e){if(!e.created)return"Now";const t=new Date,n=new Date(e.created),i=Math.floor((t.getTime()-n.getTime())/1e3);return i<5?"Now":i<60?`${i}s`:i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:i<604800?`${Math.floor(i/86400)}d`:i<31536e3?`${Math.floor(i/604800)}w`:`${Math.floor(i/31536e3)}y`}(this._message)),this._menu&&this._menu.setOptions(this._getMenuOptions());const i=this._message.actions&&this._message.actions.length>0;this._actionsContainer&&(this._actionsContainer.style.display=i?"flex":"none");const o=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.actions;this._actionsContainer&&this._message.actions&&this._message.actions.forEach((e=>{var t,n,i,s,l;const r=new y({text:e.content,variant:"secondary",backgroundColor:null==o?void 0:o.backgroundColor,hoverBackgroundColor:null==o?void 0:o.hoverBackgroundColor,activeBackgroundColor:null==o?void 0:o.activeBackgroundColor,border:null==o?void 0:o.border,borderRadius:null==o?void 0:o.borderRadius,shadow:null==o?void 0:o.shadow,fontFamily:null==(t=null==o?void 0:o.font)?void 0:t.family,fontSize:null==(n=null==o?void 0:o.font)?void 0:n.size,fontWeight:null==(i=null==o?void 0:o.font)?void 0:i.weight,textColor:null==(s=null==o?void 0:o.font)?void 0:s.color,onClick:()=>{this._message&&this.onItemActionClick&&this.onItemActionClick(this._message,e)}});null==(l=this._actionsContainer)||l.appendChild(r)}))}}$(F);class R extends b{constructor(e){super(),o(this,"_theme"),o(this,"_style"),this._theme=e}static get id(){return"courier-inbox-skeleton-list-item"}onComponentMounted(){this._style=T(R.id,R.getStyles(this._theme)),this.render()}onComponentUnmounted(){var e;null==(e=this._style)||e.remove()}render(){const e=new H(this._theme),t=new H(this._theme),n=new H(this._theme);this.appendChild(e),this.appendChild(t),this.appendChild(n)}static getStyles(e){return`\n ${R.id} {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 12px;\n width: 100%;\n box-sizing: border-box;\n }\n\n ${R.id} > *:first-child {\n width: 35%;\n }\n\n ${R.id} > *:nth-child(2) {\n width: 100%;\n }\n\n ${R.id} > *:nth-child(3) {\n width: 82%;\n }\n `}}$(R);class H extends b{constructor(e){super(),o(this,"_theme"),o(this,"_style"),this._theme=e}static get id(){return"courier-skeleton-animated-row"}onComponentMounted(){this._style=T(H.id,H.getStyles(this._theme)),this.render()}onComponentUnmounted(){var e;null==(e=this._style)||e.remove()}render(){const e=document.createElement("div");e.className="skeleton-item",this.appendChild(e)}static getStyles(e){var t,n,i,o,s,l,r,a,d,u,h,c;const v=(null==(i=null==(n=null==(t=e.inbox)?void 0:t.loading)?void 0:n.animation)?void 0:i.barColor)??"#000",p=4===v.length?`#${v[1]}${v[1]}${v[2]}${v[2]}${v[3]}${v[3]}`:v,g=parseInt(p.slice(1,3),16),m=parseInt(p.slice(3,5),16),_=parseInt(p.slice(5,7),16),b=`rgba(${g}, ${m}, ${_}, 0.8)`,x=`rgba(${g}, ${m}, ${_}, 0.4)`;return`\n ${H.id} {\n display: flex;\n height: 100%;\n width: 100%;\n align-items: flex-start;\n justify-content: flex-start;\n }\n\n ${H.id} .skeleton-item {\n height: ${(null==(l=null==(s=null==(o=e.inbox)?void 0:o.loading)?void 0:s.animation)?void 0:l.barHeight)??"14px"};\n width: 100%;\n background: linear-gradient(\n 90deg,\n ${b} 25%,\n ${x} 50%,\n ${b} 75%\n );\n background-size: 200% 100%;\n animation: ${H.id}-shimmer ${(null==(d=null==(a=null==(r=e.inbox)?void 0:r.loading)?void 0:a.animation)?void 0:d.duration)??"2s"} ease-in-out infinite;\n border-radius: ${(null==(c=null==(h=null==(u=e.inbox)?void 0:u.loading)?void 0:h.animation)?void 0:c.barBorderRadius)??"14px"};\n }\n\n @keyframes ${H.id}-shimmer {\n 0% {\n background-position: 200% 0;\n }\n 100% {\n background-position: -200% 0;\n }\n }\n `}}$(H);class z extends M{constructor(e){super(),o(this,"_theme"),o(this,"_style"),this._theme=e}static get id(){return"courier-inbox-skeleton-list"}onComponentMounted(){this._style=T(z.id,z.getStyles(this._theme))}onComponentUnmounted(){var e;null==(e=this._style)||e.remove()}defaultElement(){const e=document.createElement("div");e.className="list";for(let t=0;t<3;t++){const t=new R(this._theme);e.appendChild(t)}return this.appendChild(e),e}static getStyles(e){var t,n,i,o;return`\n ${z.id} {\n display: flex;\n height: 100%;\n width: 100%;\n align-items: flex-start;\n justify-content: flex-start;\n overflow: hidden;\n }\n\n ${z.id} .list {\n display: flex;\n flex-direction: column;\n width: 100%;\n overflow: hidden;\n }\n\n ${z.id} .list > * {\n border-bottom: ${(null==(n=null==(t=e.inbox)?void 0:t.loading)?void 0:n.divider)??"1px solid red"};\n opacity: 100%;\n }\n\n ${z.id} .list > *:nth-child(2) {\n border-bottom: ${(null==(o=null==(i=e.inbox)?void 0:i.loading)?void 0:o.divider)??"1px solid red"};\n opacity: 88%;\n }\n\n ${z.id} .list > *:nth-child(3) {\n border-bottom: none;\n opacity: 50%;\n }\n `}}$(z);class O extends b{constructor(e){super(),o(this,"_theme"),o(this,"_style"),o(this,"_skeletonLoadingList"),o(this,"_observer"),o(this,"_customItem"),o(this,"_onPaginationTrigger"),this._theme=e.theme,this._customItem=e.customItem,this._onPaginationTrigger=e.onPaginationTrigger}static get id(){return"courier-inbox-pagination-list-item"}onComponentMounted(){if(this._style=T(O.id,O.getStyles(this._theme)),this._customItem)this.appendChild(this._customItem);else{const e=document.createElement("div");e.className="skeleton-container",this._skeletonLoadingList=new z(this._theme),this._skeletonLoadingList.build(void 0),e.appendChild(this._skeletonLoadingList),this.appendChild(e)}this._observer=new IntersectionObserver((e=>{e.forEach((e=>{e.isIntersecting&&this._onPaginationTrigger()}))})),this._observer.observe(this)}onComponentUnmounted(){var e,t;null==(e=this._observer)||e.disconnect(),null==(t=this._style)||t.remove()}static getStyles(e){return`\n ${O.id} {\n padding: 0;\n margin: 0;\n box-sizing: border-box;\n }\n\n ${O.id} .skeleton-container {\n height: 150%;\n }\n `}}$(O);class U extends b{constructor(e){super(),o(this,"_themeSubscription"),o(this,"_messages",[]),o(this,"_feedType","inbox"),o(this,"_isLoading",!0),o(this,"_error",null),o(this,"_canPaginate",!1),o(this,"_onMessageClick",null),o(this,"_onMessageActionClick",null),o(this,"_onMessageLongPress",null),o(this,"_onRefresh"),o(this,"_onPaginationTrigger"),o(this,"_listItemFactory"),o(this,"_paginationItemFactory"),o(this,"_loadingStateFactory"),o(this,"_emptyStateFactory"),o(this,"_errorStateFactory"),o(this,"_listStyles"),o(this,"_listItemStyles"),o(this,"_listItemMenuStyles"),this._onRefresh=e.onRefresh,this._onPaginationTrigger=e.onPaginationTrigger,this._onMessageClick=e.onMessageClick,this._onMessageActionClick=e.onMessageActionClick,this._onMessageLongPress=e.onMessageLongPress,this._themeSubscription=e.themeManager.subscribe((e=>{this.render()}))}static get id(){return"courier-inbox-list"}get messages(){return this._messages}get theme(){return this._themeSubscription.manager.getTheme()}onComponentMounted(){this._listStyles=T(U.id,U.getStyles(this.theme)),this._listItemStyles=T(F.id,F.getStyles(this.theme)),this._listItemMenuStyles=T(A.id,A.getStyles(this.theme)),this.render()}onComponentUnmounted(){var e,t,n;this._themeSubscription.unsubscribe(),null==(e=this._listStyles)||e.remove(),null==(t=this._listItemStyles)||t.remove(),null==(n=this._listItemMenuStyles)||n.remove()}static getStyles(e){var t;const n=null==(t=e.inbox)?void 0:t.list;return`\n ${U.id} {\n flex: 1;\n width: 100%;\n background-color: ${(null==n?void 0:n.backgroundColor)??"red"};\n }\n\n ${U.id} ul {\n list-style: none;\n padding: 0;\n margin: 0;\n height: 100%;\n }\n `}setDataSet(e){this._messages=[...e.messages],this._canPaginate=Boolean(e.canPaginate),this._error=null,this._isLoading=!1,this.render()}addPage(e){this._messages=[...this._messages,...e.messages],this._canPaginate=Boolean(e.canPaginate),this._error=null,this._isLoading=!1,this.render()}addMessage(e,t=0){this._messages.splice(t,0,e),this.render()}removeMessage(e=0){this._messages.splice(e,1),this.render()}updateMessage(e,t=0){this._messages[t]=e,this.render()}setFeedType(e){this._feedType=e,this._error=null,this._isLoading=!0,this.render()}setLoading(e){this._error=null,this._isLoading=e,this.render()}setError(e){this._error=e,this._isLoading=!1,this._messages=[],this.render()}setErrorNoClient(){this.setError(new Error("No user signed in"))}handleRetry(){this._onRefresh()}handleRefresh(){this._onRefresh()}render(){for(var e,t,n,i,o,s,l,r,a,d,u,h,c,v,p,g,m,_,b,x,C,f,y,k,S,w,M,E,$,T,D,L,B,P,R,H,V,N,Z,j,G,W,J,q,X,Y,K,Q,ee,te,ne,ie,oe,se;this.firstChild;)this.removeChild(this.firstChild);if(this._listStyles&&(this._listStyles.textContent=U.getStyles(this.theme)),this._listItemStyles&&(this._listItemStyles.textContent=F.getStyles(this.theme)),this._listItemMenuStyles&&(this._listItemMenuStyles.textContent=A.getStyles(this.theme)),this._error){const M=null==(e=this.theme.inbox)?void 0:e.error,E=new I({title:{text:(null==(t=null==M?void 0:M.title)?void 0:t.text)??this._error.message,textColor:null==(i=null==(n=null==M?void 0:M.title)?void 0:n.font)?void 0:i.color,fontFamily:null==(s=null==(o=null==M?void 0:M.title)?void 0:o.font)?void 0:s.family,fontSize:null==(r=null==(l=null==M?void 0:M.title)?void 0:l.font)?void 0:r.size,fontWeight:null==(d=null==(a=null==M?void 0:M.title)?void 0:a.font)?void 0:d.weight},button:{text:null==(u=null==M?void 0:M.button)?void 0:u.text,backgroundColor:null==(h=null==M?void 0:M.button)?void 0:h.backgroundColor,hoverBackgroundColor:null==(c=null==M?void 0:M.button)?void 0:c.hoverBackgroundColor,activeBackgroundColor:null==(v=null==M?void 0:M.button)?void 0:v.activeBackgroundColor,textColor:null==(g=null==(p=null==M?void 0:M.button)?void 0:p.font)?void 0:g.color,fontFamily:null==(_=null==(m=null==M?void 0:M.button)?void 0:m.font)?void 0:_.family,fontSize:null==(x=null==(b=null==M?void 0:M.button)?void 0:b.font)?void 0:x.size,fontWeight:null==(f=null==(C=null==M?void 0:M.button)?void 0:C.font)?void 0:f.weight,shadow:null==(y=null==M?void 0:M.button)?void 0:y.shadow,border:null==(k=null==M?void 0:M.button)?void 0:k.border,borderRadius:null==(S=null==M?void 0:M.button)?void 0:S.borderRadius}});return E.build(null==(w=this._errorStateFactory)?void 0:w.call(this,{feedType:this._feedType,error:this._error})),E.setButtonClickCallback((()=>this.handleRetry())),void this.appendChild(E)}if(this._isLoading){const e=new z(this.theme);return e.build(null==(M=this._loadingStateFactory)?void 0:M.call(this,{feedType:this._feedType})),void this.appendChild(e)}if(0===this._messages.length){const e=null==(E=this.theme.inbox)?void 0:E.empty,t=new I({title:{text:(null==($=null==e?void 0:e.title)?void 0:$.text)??`No ${this._feedType} messages yet`,textColor:null==(D=null==(T=null==e?void 0:e.title)?void 0:T.font)?void 0:D.color,fontFamily:null==(B=null==(L=null==e?void 0:e.title)?void 0:L.font)?void 0:B.family,fontSize:null==(R=null==(P=null==e?void 0:e.title)?void 0:P.font)?void 0:R.size,fontWeight:null==(V=null==(H=null==e?void 0:e.title)?void 0:H.font)?void 0:V.weight},button:{text:null==(N=null==e?void 0:e.button)?void 0:N.text,backgroundColor:null==(Z=null==e?void 0:e.button)?void 0:Z.backgroundColor,hoverBackgroundColor:null==(j=null==e?void 0:e.button)?void 0:j.hoverBackgroundColor,activeBackgroundColor:null==(G=null==e?void 0:e.button)?void 0:G.activeBackgroundColor,textColor:null==(J=null==(W=null==e?void 0:e.button)?void 0:W.font)?void 0:J.color,fontFamily:null==(X=null==(q=null==e?void 0:e.button)?void 0:q.font)?void 0:X.family,fontSize:null==(K=null==(Y=null==e?void 0:e.button)?void 0:Y.font)?void 0:K.size,fontWeight:null==(ee=null==(Q=null==e?void 0:e.button)?void 0:Q.font)?void 0:ee.weight,shadow:null==(te=null==e?void 0:e.button)?void 0:te.shadow,border:null==(ne=null==e?void 0:e.button)?void 0:ne.border,borderRadius:null==(ie=null==e?void 0:e.button)?void 0:ie.borderRadius}});return t.build(null==(oe=this._emptyStateFactory)?void 0:oe.call(this,{feedType:this._feedType})),t.setButtonClickCallback((()=>this.handleRefresh())),void this.appendChild(t)}const le=document.createElement("ul");if(this.appendChild(le),this._messages.forEach(((e,t)=>{if(this._listItemFactory)return void le.appendChild(this._listItemFactory({message:e,index:t}));const n=new F(this.theme);n.setMessage(e,this._feedType),n.setOnItemClick((e=>{var n;return null==(n=this._onMessageClick)?void 0:n.call(this,e,t)})),n.setOnItemActionClick(((e,n)=>{var i;return null==(i=this._onMessageActionClick)?void 0:i.call(this,e,n,t)})),n.setOnItemLongPress((e=>{var n;return null==(n=this._onMessageLongPress)?void 0:n.call(this,e,t)})),le.appendChild(n)})),this._canPaginate){const e=new O({theme:this.theme,customItem:null==(se=this._paginationItemFactory)?void 0:se.call(this,{feedType:this._feedType}),onPaginationTrigger:()=>{var e;return null==(e=this._onPaginationTrigger)?void 0:e.call(this,this._feedType)}});le.appendChild(e)}}setLoadingStateFactory(e){this._loadingStateFactory=e,this.render()}setEmptyStateFactory(e){this._emptyStateFactory=e,this.render()}setErrorStateFactory(e){this._errorStateFactory=e,this.render()}setListItemFactory(e){this._listItemFactory=e,this.render()}setPaginationItemFactory(e){this._paginationItemFactory=e,this.render()}}$(U);class V extends b{constructor(e){super(),o(this,"_option"),o(this,"_isSelectedable"),o(this,"_isSelected"),o(this,"_content"),o(this,"_itemIcon"),o(this,"_title"),o(this,"_selectionIcon"),this._option=e.option,this._isSelected=e.isSelected,this._isSelectedable=e.selectable}static get id(){return"courier-inbox-option-menu-item"}onComponentMounted(){this._content=document.createElement("div"),this._content.className="menu-item",this._itemIcon=new S(this._option.icon.svg??k.inbox),this._itemIcon.setAttribute("size","16"),this._title=document.createElement("p"),this._title.textContent=this._option.text;const e=document.createElement("div");e.className="spacer",this._selectionIcon=new S(k.check),this._content.appendChild(this._itemIcon),this._content.appendChild(this._title),this._content.appendChild(e),this._isSelectedable&&this._content.appendChild(this._selectionIcon),this.appendChild(this._content),this._selectionIcon.style.display=this._isSelected?"block":"none",this.refreshTheme()}refreshTheme(){var e,t,n,i,o,s,l,r;null==(t=this._selectionIcon)||t.updateColor((null==(e=this._option.selectionIcon)?void 0:e.color)??"red"),null==(i=this._selectionIcon)||i.updateSVG((null==(n=this._option.selectionIcon)?void 0:n.svg)??k.check),this._title&&(this._title.textContent=this._option.text??"Missing Text"),null==(s=this._itemIcon)||s.updateColor((null==(o=this._option.icon)?void 0:o.color)??"red"),null==(r=this._itemIcon)||r.updateSVG((null==(l=this._option.icon)?void 0:l.svg)??k.inbox)}}$(V);class N extends b{constructor(e,t,n,i,s){super(),o(this,"_themeSubscription"),o(this,"_type"),o(this,"_selectedIndex",0),o(this,"_options"),o(this,"_selectable"),o(this,"_onMenuOpen"),o(this,"_menuButton"),o(this,"_menu"),o(this,"_style"),this._type=t,this._selectable=n,this._options=i,this._selectedIndex=0,this._onMenuOpen=s,this._themeSubscription=e.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-inbox-option-menu"}onComponentMounted(){this._style=T(N.id,this.getStyles()),this._menuButton=new E("filters"===this._type?k.filter:k.overflow),this._menu=document.createElement("div"),this._menu.className=`menu ${this._type}`,this.appendChild(this._menuButton),this.appendChild(this._menu),this._menuButton.addEventListener("click",this.toggleMenu.bind(this)),document.addEventListener("click",this.handleOutsideClick.bind(this)),this.refreshTheme()}onComponentUnmounted(){var e;this._themeSubscription.unsubscribe(),null==(e=this._style)||e.remove()}getStyles(){var e,t,n,i,o,s,l,r,a,d,u,h,c,v,p,g,m,_,b,x,C,f,y,k,S,w,M,I,E,$,T,D,L,A,B,P,F,R,H,z,O,U,Z,j,G,W,J,q,X,Y,K,Q,ee,te,ne;const ie=this._themeSubscription.manager.getTheme();return`\n ${N.id} {\n position: relative;\n display: inline-block;\n }\n\n ${N.id} .menu {\n display: none;\n position: absolute;\n top: 42px;\n right: -6px;\n border-radius: ${(null==(i=null==(n=null==(t=null==(e=ie.inbox)?void 0:e.header)?void 0:t.menus)?void 0:n.popup)?void 0:i.borderRadius)??"6px"};\n border: ${(null==(r=null==(l=null==(s=null==(o=ie.inbox)?void 0:o.header)?void 0:s.menus)?void 0:l.popup)?void 0:r.border)??"1px solid red"};\n background: ${(null==(h=null==(u=null==(d=null==(a=ie.inbox)?void 0:a.header)?void 0:d.menus)?void 0:u.popup)?void 0:h.backgroundColor)??"red"};\n box-shadow: ${(null==(g=null==(p=null==(v=null==(c=ie.inbox)?void 0:c.header)?void 0:v.menus)?void 0:p.popup)?void 0:g.shadow)??"0 4px 12px 0 red"};\n z-index: 1000;\n min-width: 200px;\n overflow: hidden;\n padding: 4px 0;\n }\n\n ${N.id} courier-inbox-filter-menu-item {\n border-bottom: ${(null==(C=null==(x=null==(b=null==(_=null==(m=ie.inbox)?void 0:m.header)?void 0:_.menus)?void 0:b.popup)?void 0:x.list)?void 0:C.divider)??"none"};\n }\n\n ${N.id} courier-inbox-filter-menu-item:last-child {\n border-bottom: none;\n }\n\n ${V.id} {\n display: flex;\n flex-direction: row;\n padding: 6px 12px;\n cursor: pointer;\n }\n\n ${V.id}:hover {\n background-color: ${(null==(w=null==(S=null==(k=null==(y=null==(f=ie.inbox)?void 0:f.header)?void 0:y.menus)?void 0:k.popup)?void 0:S.list)?void 0:w.hoverBackgroundColor)??"red"};\n }\n\n ${V.id}:active {\n background-color: ${(null==(T=null==($=null==(E=null==(I=null==(M=ie.inbox)?void 0:M.header)?void 0:I.menus)?void 0:E.popup)?void 0:$.list)?void 0:T.activeBackgroundColor)??"red"};\n }\n\n ${V.id} .menu-item {\n display: flex;\n align-items: center;\n width: 100%;\n gap: 12px;\n }\n\n ${V.id} .spacer {\n flex: 1;\n }\n\n ${V.id} p {\n margin: 0;\n font-family: ${(null==(F=null==(P=null==(B=null==(A=null==(L=null==(D=ie.inbox)?void 0:D.header)?void 0:L.menus)?void 0:A.popup)?void 0:B.list)?void 0:P.font)?void 0:F.family)??"inherit"};\n font-weight: ${(null==(Z=null==(U=null==(O=null==(z=null==(H=null==(R=ie.inbox)?void 0:R.header)?void 0:H.menus)?void 0:z.popup)?void 0:O.list)?void 0:U.font)?void 0:Z.weight)??"inherit"};\n font-size: ${(null==(X=null==(q=null==(J=null==(W=null==(G=null==(j=ie.inbox)?void 0:j.header)?void 0:G.menus)?void 0:W.popup)?void 0:J.list)?void 0:q.font)?void 0:X.size)??"14px"};\n color: ${(null==(ne=null==(te=null==(ee=null==(Q=null==(K=null==(Y=ie.inbox)?void 0:Y.header)?void 0:K.menus)?void 0:Q.popup)?void 0:ee.list)?void 0:te.font)?void 0:ne.color)??"red"};\n white-space: nowrap;\n }\n\n ${V.id} .check-icon {\n display: none;\n }\n `}refreshTheme(){var e,t,n,i,o,s,l,r,a,d,u;this._style&&(this._style.textContent=this.getStyles());const h=null==(t=null==(e=this._themeSubscription.manager.getTheme().inbox)?void 0:e.header)?void 0:t.menus,c="filters"===this._type,v=c?null==(n=null==h?void 0:h.filters)?void 0:n.button:null==(i=null==h?void 0:h.actions)?void 0:i.button,p=c?k.filter:k.overflow;null==(s=this._menuButton)||s.updateIconSVG((null==(o=null==v?void 0:v.icon)?void 0:o.svg)??p),null==(r=this._menuButton)||r.updateIconColor((null==(l=null==v?void 0:v.icon)?void 0:l.color)??"red"),null==(a=this._menuButton)||a.updateBackgroundColor((null==v?void 0:v.backgroundColor)??"transparent"),null==(d=this._menuButton)||d.updateHoverBackgroundColor((null==v?void 0:v.hoverBackgroundColor)??"red"),null==(u=this._menuButton)||u.updateActiveBackgroundColor((null==v?void 0:v.activeBackgroundColor)??"red"),this.refreshMenuItems()}setOptions(e){this._options=e,this.refreshMenuItems()}refreshMenuItems(){this._menu&&(this._menu.innerHTML=""),this._options.forEach(((e,t)=>{var n;const i=new V({option:e,selectable:this._selectable,isSelected:this._selectedIndex===t,themeManager:this._themeSubscription.manager});i.addEventListener("click",(()=>{this._selectedIndex=t,e.onClick(e),this.refreshMenuItems(),this.closeMenu()})),null==(n=this._menu)||n.appendChild(i)}))}toggleMenu(e){var t;e.stopPropagation();const n="block"!==(null==(t=this._menu)?void 0:t.style.display);this._menu&&(this._menu.style.display=n?"block":"none"),n&&this._onMenuOpen()}handleOutsideClick(e){this.contains(e.target)||this.closeMenu()}closeMenu(){this._menu&&(this._menu.style.display="none")}selectOption(e){this._selectedIndex=this._options.findIndex((t=>t.id===e.id)),this.refreshMenuItems()}}$(N);class Z extends b{constructor(e){super(),o(this,"_themeSubscription"),o(this,"_location"),o(this,"_count",0),o(this,"_badge"),o(this,"_style"),this._location=e.location,this._themeSubscription=e.themeBus.subscribe((e=>{this.refreshTheme(this._location)}))}static get id(){return"courier-unread-count-badge"}get theme(){return this._themeSubscription.manager.getTheme()}onComponentMounted(){this._badge=document.createElement("span"),this._badge.className=`unread-badge ${this._location}`,this.appendChild(this._badge),this.updateBadge()}onComponentUnmounted(){var e;this._themeSubscription.unsubscribe(),null==(e=this._style)||e.remove()}static getStyles(e){var t,n,i,o,s,l,r,a,d,u,h,c,v,p,g,m,_,b,x,C,f,y,k,S,w,M,I,E,$,T,D,L;return`\n ${Z.id} {\n display: inline-block;\n }\n\n ${Z.id} .unread-badge {\n padding: 4px 8px;\n text-align: center;\n display: none;\n pointer-events: none;\n }\n\n ${Z.id} .button {\n background-color: ${null==(i=null==(n=null==(t=e.popup)?void 0:t.button)?void 0:n.unreadIndicator)?void 0:i.backgroundColor};\n color: ${null==(r=null==(l=null==(s=null==(o=e.popup)?void 0:o.button)?void 0:s.unreadIndicator)?void 0:l.font)?void 0:r.color};\n border-radius: ${null==(u=null==(d=null==(a=e.popup)?void 0:a.button)?void 0:d.unreadIndicator)?void 0:u.borderRadius};\n font-size: ${null==(p=null==(v=null==(c=null==(h=e.popup)?void 0:h.button)?void 0:c.unreadIndicator)?void 0:v.font)?void 0:p.size};\n }\n\n ${Z.id} .header {\n background-color: ${null==(b=null==(_=null==(m=null==(g=e.inbox)?void 0:g.header)?void 0:m.filters)?void 0:_.unreadIndicator)?void 0:b.backgroundColor};\n color: ${null==(k=null==(y=null==(f=null==(C=null==(x=e.inbox)?void 0:x.header)?void 0:C.filters)?void 0:f.unreadIndicator)?void 0:y.font)?void 0:k.color};\n border-radius: ${null==(I=null==(M=null==(w=null==(S=e.inbox)?void 0:S.header)?void 0:w.filters)?void 0:M.unreadIndicator)?void 0:I.borderRadius};\n font-size: ${null==(L=null==(D=null==(T=null==($=null==(E=e.inbox)?void 0:E.header)?void 0:$.filters)?void 0:T.unreadIndicator)?void 0:D.font)?void 0:L.size};\n }\n `}setCount(e){this._count=e,this.updateBadge()}refreshTheme(e){this._location=e,this.updateBadge()}updateBadge(){this._badge&&(this._count>0?(this._badge.textContent=this._count.toString(),this._badge.style.display="block"):this._badge.style.display="none")}}$(Z);class j extends b{constructor(e,t){super(),o(this,"_themeSubscription"),o(this,"_option"),o(this,"_feedType"),o(this,"_style"),o(this,"_titleElement"),o(this,"_iconElement"),o(this,"_unreadBadge"),this._option=t,this._themeSubscription=e.subscribe((e=>{this.refreshTheme(this._feedType??"inbox")}))}static get id(){return"courier-inbox-header-title"}get theme(){return this._themeSubscription.manager.getTheme()}static getStyles(e){var t,n,i,o,s,l,r,a,d,u,h,c,v,p,g,m;return`\n ${j.id} {\n display: flex;\n align-items: center;\n gap: 8px;\n position: relative;\n }\n\n ${j.id} courier-icon {\n display: flex;\n align-items: center;\n }\n\n ${j.id} h2 {\n margin: 0;\n font-family: ${(null==(o=null==(i=null==(n=null==(t=e.inbox)?void 0:t.header)?void 0:n.filters)?void 0:i.font)?void 0:o.family)??"inherit"};\n font-size: ${(null==(a=null==(r=null==(l=null==(s=e.inbox)?void 0:s.header)?void 0:l.filters)?void 0:r.font)?void 0:a.size)??"18px"};\n font-weight: ${(null==(c=null==(h=null==(u=null==(d=e.inbox)?void 0:d.header)?void 0:u.filters)?void 0:h.font)?void 0:c.weight)??"500"};\n color: ${(null==(m=null==(g=null==(p=null==(v=e.inbox)?void 0:v.header)?void 0:p.filters)?void 0:g.font)?void 0:m.color)??"red"};\n }\n\n ${j.id} courier-unread-count-badge {\n margin-left: 4px;\n }\n `}onComponentMounted(){this._style=T(j.id,j.getStyles(this.theme)),this._iconElement=new S(void 0,this._option.icon.svg),this._titleElement=document.createElement("h2"),this._unreadBadge=new Z({themeBus:this._themeSubscription.manager,location:"header"}),this.appendChild(this._iconElement),this.appendChild(this._titleElement),this.appendChild(this._unreadBadge),this.refreshTheme(this._feedType??"inbox")}onComponentUnmounted(){var e;this._themeSubscription.unsubscribe(),null==(e=this._style)||e.remove()}refreshTheme(e){var t;this._feedType=e,this._style&&(this._style.textContent=j.getStyles(this.theme)),null==(t=this._unreadBadge)||t.refreshTheme("header"),this.updateFilter()}updateSelectedOption(e,t,n){var i;this._option=e,this._feedType=t,null==(i=this._unreadBadge)||i.setCount(n),this.updateFilter()}updateFilter(){var e,t,n,i,o,s,l,r,a,d,u,h,c,v,p,g,m,_,b,x,C,f,y,S,w,M,I,E,$,T,D,L;const A=this._themeSubscription.manager.getTheme();switch(this._feedType){case"inbox":this._titleElement&&(this._titleElement.textContent=(null==(i=null==(n=null==(t=null==(e=A.inbox)?void 0:e.header)?void 0:t.filters)?void 0:n.inbox)?void 0:i.text)??"Inbox"),null==(d=this._iconElement)||d.updateSVG((null==(a=null==(r=null==(l=null==(s=null==(o=A.inbox)?void 0:o.header)?void 0:s.filters)?void 0:l.inbox)?void 0:r.icon)?void 0:a.svg)??k.inbox),null==(g=this._iconElement)||g.updateColor((null==(p=null==(v=null==(c=null==(h=null==(u=A.inbox)?void 0:u.header)?void 0:h.filters)?void 0:c.inbox)?void 0:v.icon)?void 0:p.color)??"red");break;case"archive":this._titleElement&&(this._titleElement.textContent=(null==(x=null==(b=null==(_=null==(m=A.inbox)?void 0:m.header)?void 0:_.filters)?void 0:b.archive)?void 0:x.text)??"Archive"),null==(M=this._iconElement)||M.updateSVG((null==(w=null==(S=null==(y=null==(f=null==(C=A.inbox)?void 0:C.header)?void 0:f.filters)?void 0:y.archive)?void 0:S.icon)?void 0:w.svg)??k.archive),null==(L=this._iconElement)||L.updateColor((null==(D=null==(T=null==($=null==(E=null==(I=A.inbox)?void 0:I.header)?void 0:E.filters)?void 0:$.archive)?void 0:T.icon)?void 0:D.color)??"red")}}}$(j);class G extends M{constructor(e){super(),o(this,"_themeSubscription"),o(this,"_feedType","inbox"),o(this,"_unreadCount",0),o(this,"_titleSection"),o(this,"_filterMenu"),o(this,"_actionMenu"),o(this,"_style"),o(this,"_onFeedTypeChange"),this._themeSubscription=e.themeManager.subscribe((e=>{this.refreshTheme()})),this._onFeedTypeChange=e.onFeedTypeChange}static get id(){return"courier-inbox-header"}static get observedAttributes(){return["icon","title","feed-type"]}get theme(){return this._themeSubscription.manager.getTheme()}onComponentMounted(){this._style=T(G.id,G.getStyles(this.theme))}onComponentUmounted(){var e;this._themeSubscription.unsubscribe(),null==(e=this._style)||e.remove()}getFilterOptions(){var e,t,n,i,o,s,l,r,a,d,u,h,c,v,p,g,m,_,b,x,C,f,y,S,w,M,I,E,$,T,D,L,A,B,P,F,R;const H=this._themeSubscription.manager.getTheme(),z=null==(n=null==(t=null==(e=H.inbox)?void 0:e.header)?void 0:t.menus)?void 0:n.filters;return[{id:"inbox",text:(null==(i=null==z?void 0:z.inbox)?void 0:i.text)??"Inbox",icon:{color:(null==(s=null==(o=null==z?void 0:z.inbox)?void 0:o.icon)?void 0:s.color)??"red",svg:(null==(r=null==(l=null==z?void 0:z.inbox)?void 0:l.icon)?void 0:r.svg)??k.inbox},selectionIcon:{color:(null==(v=null==(c=null==(h=null==(u=null==(d=null==(a=H.inbox)?void 0:a.header)?void 0:d.menus)?void 0:u.popup)?void 0:h.list)?void 0:c.selectionIcon)?void 0:v.color)??"red",svg:(null==(x=null==(b=null==(_=null==(m=null==(g=null==(p=H.inbox)?void 0:p.header)?void 0:g.menus)?void 0:m.popup)?void 0:_.list)?void 0:b.selectionIcon)?void 0:x.svg)??k.check},onClick:e=>{this.handleOptionMenuItemClick("inbox",e)}},{id:"archive",text:(null==(C=null==z?void 0:z.archive)?void 0:C.text)??"Archive",icon:{color:(null==(y=null==(f=null==z?void 0:z.archive)?void 0:f.icon)?void 0:y.color)??"red",svg:(null==(w=null==(S=null==z?void 0:z.archive)?void 0:S.icon)?void 0:w.svg)??k.archive},selectionIcon:{color:(null==(D=null==(T=null==($=null==(E=null==(I=null==(M=H.inbox)?void 0:M.header)?void 0:I.menus)?void 0:E.popup)?void 0:$.list)?void 0:T.selectionIcon)?void 0:D.color)??"red",svg:(null==(R=null==(F=null==(P=null==(B=null==(A=null==(L=H.inbox)?void 0:L.header)?void 0:A.menus)?void 0:B.popup)?void 0:P.list)?void 0:F.selectionIcon)?void 0:R.svg)??k.check},onClick:e=>{this.handleOptionMenuItemClick("archive",e)}}]}getActionOptions(){var e,t,n,i,o,s,l,r,a,d,u,h,c,v,p,g,m,_;const b=null==(n=null==(t=null==(e=this._themeSubscription.manager.getTheme().inbox)?void 0:e.header)?void 0:t.menus)?void 0:n.actions;return[{id:"markAllRead",text:(null==(i=null==b?void 0:b.markAllRead)?void 0:i.text)??"Mark All as Read",icon:{color:(null==(s=null==(o=null==b?void 0:b.markAllRead)?void 0:o.icon)?void 0:s.color)??"red",svg:(null==(r=null==(l=null==b?void 0:b.markAllRead)?void 0:l.icon)?void 0:r.svg)??k.inbox},selectionIcon:null,onClick:e=>{P.shared.readAllMessages({canCallApi:!0})}},{id:"archiveAll",text:(null==(a=null==b?void 0:b.archiveAll)?void 0:a.text)??"Archive All",icon:{color:(null==(u=null==(d=null==b?void 0:b.archiveAll)?void 0:d.icon)?void 0:u.color)??"red",svg:(null==(c=null==(h=null==b?void 0:b.archiveAll)?void 0:h.icon)?void 0:c.svg)??k.archive},selectionIcon:null,onClick:e=>{P.shared.archiveAllMessages({canCallApi:!0})}},{id:"archiveRead",text:(null==(v=null==b?void 0:b.archiveRead)?void 0:v.text)??"Archive Read",icon:{color:(null==(g=null==(p=null==b?void 0:b.archiveRead)?void 0:p.icon)?void 0:g.color)??"red",svg:(null==(_=null==(m=null==b?void 0:b.archiveRead)?void 0:m.icon)?void 0:_.svg)??k.archive},selectionIcon:null,onClick:e=>{P.shared.archiveReadMessages({canCallApi:!0})}}]}refreshTheme(){var e,t;this._style&&(this._style.textContent=G.getStyles(this.theme)),null==(e=this._filterMenu)||e.setOptions(this.getFilterOptions()),null==(t=this._actionMenu)||t.setOptions(this.getActionOptions())}handleOptionMenuItemClick(e,t){this._feedType=e,this._titleSection&&this._titleSection.updateSelectedOption(t,this._feedType,"inbox"===this._feedType?this._unreadCount:0),this._onFeedTypeChange(e)}render(e){var t,n;this._feedType=e.feedType,this._unreadCount=e.unreadCount;const i=this.getFilterOptions().find((e=>["inbox","archive"].includes(e.id)&&e.id===this._feedType));i&&(null==(t=this._titleSection)||t.updateSelectedOption(i,this._feedType,"inbox"===this._feedType?this._unreadCount:0),null==(n=this._filterMenu)||n.selectOption(i))}build(e){super.build(e),this.refreshTheme()}defaultElement(){const e=this.getFilterOptions();this._titleSection=new j(this._themeSubscription.manager,e[0]),this._filterMenu=new N(this._themeSubscription.manager,"filters",!0,e,(()=>{var e;null==(e=this._actionMenu)||e.closeMenu()})),this._actionMenu=new N(this._themeSubscription.manager,"actions",!1,this.getActionOptions(),(()=>{var e;null==(e=this._filterMenu)||e.closeMenu()})),this._filterMenu.selectOption(e[0]);const t=document.createElement("div");t.className="spacer";const n=document.createElement("div");n.className="actions",n.appendChild(this._filterMenu),n.appendChild(this._actionMenu);const i=document.createElement("div");return i.className="header-content",i.appendChild(this._titleSection),i.appendChild(t),i.appendChild(n),i}static getStyles(e){var t,n,i,o;return`\n ${G.id} {\n display: flex;\n align-items: center;\n flex-shrink: 0;\n }\n\n ${G.id} .header-content {\n padding: 10px 10px 10px 16px;\n background-color: ${(null==(n=null==(t=e.inbox)?void 0:t.header)?void 0:n.backgroundColor)??c[500]};\n box-shadow: ${(null==(o=null==(i=e.inbox)?void 0:i.header)?void 0:o.shadow)??"0px 1px 0px 0px red"};\n display: flex;\n align-items: center;\n justify-content: space-between;\n flex: 1;\n z-index: 100;\n }\n\n ${G.id} .spacer {\n flex: 1;\n }\n\n ${G.id} .actions {\n display: flex;\n align-items: center;\n gap: 4px;\n }\n `}}$(G);class W{constructor(e){o(this,"events"),this.events=e}remove(){P.shared.removeDataStoreListener(this)}}const J={popup:{button:{icon:{color:u[500],svg:k.inbox},backgroundColor:"transparent",hoverBackgroundColor:u[50010],activeBackgroundColor:u[50020],unreadIndicator:{font:{color:c[500],size:"14px",family:void 0,weight:void 0},backgroundColor:v[500],borderRadius:"12px"}},window:{backgroundColor:c[500],borderRadius:"8px",border:`1px solid ${h[500]}`,shadow:`0px 8px 16px -4px ${h[500]}`}},inbox:{header:{backgroundColor:c[500],shadow:`0px 1px 0px 0px ${h[500]}`,filters:{font:{color:u[500],family:void 0,size:"18px"},inbox:{icon:{color:u[500],svg:k.inbox},text:"Inbox"},archive:{icon:{color:u[500],svg:k.archive},text:"Archive"},unreadIndicator:{font:{color:c[500],family:void 0,size:"14px"},backgroundColor:v[500],borderRadius:"12px"}},menus:{popup:{backgroundColor:c[500],border:`1px solid ${h[500]}`,borderRadius:"4px",shadow:`0px 4px 8px -2px ${h[500]}`,list:{hoverBackgroundColor:h[200],activeBackgroundColor:h[500],divider:"none",font:{color:u[500],family:void 0,size:"14px"},selectionIcon:{color:u[500],svg:k.check}}},filters:{button:{icon:{color:u[500],svg:k.filter},backgroundColor:"transparent",hoverBackgroundColor:u[50010],activeBackgroundColor:u[50020]},inbox:{icon:{color:u[500],svg:k.inbox},text:"Inbox"},archive:{icon:{color:u[500],svg:k.archive},text:"Archive"}},actions:{button:{icon:{color:u[500],svg:k.overflow},backgroundColor:"transparent",hoverBackgroundColor:u[50010],activeBackgroundColor:u[50020]},markAllRead:{icon:{color:u[500],svg:k.read},text:"Read All"},archiveAll:{icon:{color:u[500],svg:k.archive},text:"Archive All"},archiveRead:{icon:{color:u[500],svg:k.archiveRead},text:"Archive Read"}}}},list:{backgroundColor:c[500],item:{backgroundColor:"transparent",unreadIndicatorColor:v[500],hoverBackgroundColor:h[200],activeBackgroundColor:h[500],actions:{backgroundColor:"transparent",hoverBackgroundColor:h[200],activeBackgroundColor:h[500],border:`1px solid ${h[500]}`,borderRadius:"4px",shadow:"0px 1px 2px 0px rgba(0, 0, 0, 0.06)",font:{color:u[500],family:void 0,size:"14px"}},title:{color:u[500],family:void 0,size:"14px"},subtitle:{color:h[600],family:void 0,size:"14px"},time:{color:h[600],family:void 0,size:"14px"},divider:`1px solid ${h[200]}`,menu:{enabled:!0,backgroundColor:c[500],border:`1px solid ${h[500]}`,borderRadius:"4px",shadow:`0px 2px 4px -2px ${h[500]}`,longPress:{displayDuration:4e3,vibrationDuration:50},item:{hoverBackgroundColor:h[200],activeBackgroundColor:h[500],borderRadius:"0px",read:{color:u[500],svg:k.read},unread:{color:u[500],svg:k.unread},archive:{color:u[500],svg:k.archive},unarchive:{color:u[500],svg:k.unarchive}}}}},loading:{animation:{barColor:h[500],barHeight:"14px",barBorderRadius:"14px",duration:"2s"},divider:`1px solid ${h[200]}`},empty:{title:{font:{size:"16px",weight:"500",color:u[500]}},button:{text:"Refresh"}},error:{title:{font:{size:"16px",weight:"500",color:u[500]}},button:{text:"Retry"}}}},q={popup:{button:{icon:{color:c[500],svg:k.inbox},backgroundColor:"transparent",hoverBackgroundColor:c[50010],activeBackgroundColor:c[50020],unreadIndicator:{font:{color:c[500],size:"14px",family:void 0,weight:void 0},backgroundColor:v[500],borderRadius:"12px"}},window:{backgroundColor:u[500],borderRadius:"8px",border:`1px solid ${h[400]}`,shadow:`0px 4px 8px -2px ${c[50020]}`}},inbox:{header:{backgroundColor:u[500],shadow:`0px 1px 0px 0px ${h[400]}`,filters:{font:{color:c[500],family:void 0,size:"18px"},inbox:{icon:{color:c[500],svg:k.inbox},text:"Inbox"},archive:{icon:{color:c[500],svg:k.archive},text:"Archive"},unreadIndicator:{font:{color:c[500],family:void 0,size:"14px"},backgroundColor:v[500],borderRadius:"12px"}},menus:{popup:{backgroundColor:u[500],border:`1px solid ${h[400]}`,borderRadius:"4px",shadow:`0px 4px 8px -2px ${c[50020]}`,list:{hoverBackgroundColor:c[50010],activeBackgroundColor:c[50020],divider:"none",font:{color:c[500],family:void 0,size:"14px"},selectionIcon:{color:c[500],svg:k.check}}},filters:{button:{icon:{color:c[500],svg:k.filter},backgroundColor:"transparent",hoverBackgroundColor:c[50010],activeBackgroundColor:c[50020]},inbox:{icon:{color:c[500],svg:k.inbox},text:"Inbox"},archive:{icon:{color:c[500],svg:k.archive},text:"Archive"}},actions:{button:{icon:{color:c[500],svg:k.overflow},backgroundColor:"transparent",hoverBackgroundColor:c[50010],activeBackgroundColor:c[50020]},markAllRead:{icon:{color:c[500],svg:k.read},text:"Read All"},archiveAll:{icon:{color:c[500],svg:k.archive},text:"Archive All"},archiveRead:{icon:{color:c[500],svg:k.archiveRead},text:"Archive Read"}}}},list:{backgroundColor:u[500],item:{backgroundColor:"transparent",unreadIndicatorColor:v[500],hoverBackgroundColor:c[50010],activeBackgroundColor:c[50020],actions:{backgroundColor:"transparent",hoverBackgroundColor:c[50010],activeBackgroundColor:c[50020],border:`1px solid ${h[400]}`,borderRadius:"4px",shadow:`0px 1px 2px 0px ${c[50010]}`,font:{color:c[500],family:void 0,size:"14px"}},title:{color:c[500],family:void 0,size:"14px"},subtitle:{color:h[500],family:void 0,size:"14px"},time:{color:h[500],family:void 0,size:"12px"},divider:`1px solid ${h[400]}`,menu:{enabled:!0,backgroundColor:u[500],border:`1px solid ${h[400]}`,borderRadius:"4px",shadow:`0px 2px 4px -2px ${c[50020]}`,longPress:{displayDuration:4e3,vibrationDuration:50},item:{hoverBackgroundColor:c[50010],activeBackgroundColor:c[50020],borderRadius:"0px",read:{color:c[500],svg:k.read},unread:{color:c[500],svg:k.unread},archive:{color:c[500],svg:k.archive},unarchive:{color:c[500],svg:k.unarchive}}}}},loading:{animation:{barColor:h[400],barHeight:"14px",barBorderRadius:"14px",duration:"2s"},divider:`1px solid ${h[400]}`},empty:{title:{font:{size:"16px",weight:"500",color:c[500]}},button:{text:"Refresh"}},error:{title:{font:{size:"16px",weight:"500",color:c[500]}},button:{text:"Retry"}}}},X=(e,t)=>{var n,i,o,s,l,r,a,d,u,h,c,v,p,g,m,_,b,x,C,f,y,k,S,w,M,I,E,$,T,D,L,A,B,P,F,R,H,z,O,U,V,N,Z,j,G,W,X,Y,K,Q,ee,te,ne,ie,oe,se,le,re,ae,de,ue,he,ce,ve,pe,ge,me,_e,be,xe,Ce,fe,ye,ke,Se,we,Me,Ie,Ee,$e,Te,De,Le,Ae,Be,Pe,Fe,Re,He,ze,Oe,Ue,Ve,Ne,Ze,je,Ge,We,Je,qe,Xe,Ye,Ke,Qe,et,tt,nt,it,ot,st,lt,rt,at,dt,ut,ht,ct,vt,pt,gt,mt,_t,bt,xt,Ct,ft,yt,kt,St,wt,Mt,It,Et,$t,Tt,Dt,Lt,At,Bt,Pt,Ft,Rt,Ht,zt,Ot,Ut,Vt,Nt,Zt,jt,Gt,Wt,Jt,qt,Xt,Yt,Kt,Qt,en,tn,nn,on,sn,ln,rn,an,dn,un,hn,cn,vn,pn,gn,mn,_n,bn,xn,Cn,fn,yn,kn,Sn,wn,Mn,In,En,$n,Tn,Dn,Ln,An,Bn,Pn,Fn,Rn,Hn,zn,On,Un,Vn,Nn,Zn,jn,Gn,Wn,Jn,qn,Xn,Yn,Kn,Qn,ei,ti,ni,ii,oi,si,li,ri,ai,di,ui,hi,ci,vi,pi,gi,mi,_i,bi,xi,Ci,fi,yi,ki,Si,wi,Mi,Ii,Ei,$i,Ti,Di,Li,Ai,Bi,Pi,Fi,Ri,Hi,zi,Oi,Ui,Vi,Ni,Zi,ji,Gi;const Wi="light"===e?J:q;return{popup:{button:{...null==(n=Wi.popup)?void 0:n.button,...null==(i=t.popup)?void 0:i.button,icon:{...null==(s=null==(o=Wi.popup)?void 0:o.button)?void 0:s.icon,...null==(r=null==(l=t.popup)?void 0:l.button)?void 0:r.icon},unreadIndicator:{...null==(d=null==(a=Wi.popup)?void 0:a.button)?void 0:d.unreadIndicator,...null==(h=null==(u=t.popup)?void 0:u.button)?void 0:h.unreadIndicator}},window:{...null==(c=Wi.popup)?void 0:c.window,...null==(v=t.popup)?void 0:v.window}},inbox:{header:{...null==(p=Wi.inbox)?void 0:p.header,...null==(g=t.inbox)?void 0:g.header,filters:{...null==(_=null==(m=Wi.inbox)?void 0:m.header)?void 0:_.filters,...null==(x=null==(b=t.inbox)?void 0:b.header)?void 0:x.filters,inbox:{...null==(y=null==(f=null==(C=Wi.inbox)?void 0:C.header)?void 0:f.filters)?void 0:y.inbox,...null==(w=null==(S=null==(k=t.inbox)?void 0:k.header)?void 0:S.filters)?void 0:w.inbox,icon:{...null==($=null==(E=null==(I=null==(M=Wi.inbox)?void 0:M.header)?void 0:I.filters)?void 0:E.inbox)?void 0:$.icon,...null==(A=null==(L=null==(D=null==(T=t.inbox)?void 0:T.header)?void 0:D.filters)?void 0:L.inbox)?void 0:A.icon}},archive:{...null==(F=null==(P=null==(B=Wi.inbox)?void 0:B.header)?void 0:P.filters)?void 0:F.archive,...null==(z=null==(H=null==(R=t.inbox)?void 0:R.header)?void 0:H.filters)?void 0:z.archive,icon:{...null==(N=null==(V=null==(U=null==(O=Wi.inbox)?void 0:O.header)?void 0:U.filters)?void 0:V.archive)?void 0:N.icon,...null==(W=null==(G=null==(j=null==(Z=t.inbox)?void 0:Z.header)?void 0:j.filters)?void 0:G.archive)?void 0:W.icon}},unreadIndicator:{...null==(K=null==(Y=null==(X=Wi.inbox)?void 0:X.header)?void 0:Y.filters)?void 0:K.unreadIndicator,...null==(te=null==(ee=null==(Q=t.inbox)?void 0:Q.header)?void 0:ee.filters)?void 0:te.unreadIndicator}},menus:{...null==(ie=null==(ne=Wi.inbox)?void 0:ne.header)?void 0:ie.menus,...null==(se=null==(oe=t.inbox)?void 0:oe.header)?void 0:se.menus,popup:{...null==(ae=null==(re=null==(le=Wi.inbox)?void 0:le.header)?void 0:re.menus)?void 0:ae.popup,...null==(he=null==(ue=null==(de=t.inbox)?void 0:de.header)?void 0:ue.menus)?void 0:he.popup,list:{...null==(ge=null==(pe=null==(ve=null==(ce=Wi.inbox)?void 0:ce.header)?void 0:ve.menus)?void 0:pe.popup)?void 0:ge.list,...null==(xe=null==(be=null==(_e=null==(me=t.inbox)?void 0:me.header)?void 0:_e.menus)?void 0:be.popup)?void 0:xe.list,font:{...null==(Se=null==(ke=null==(ye=null==(fe=null==(Ce=Wi.inbox)?void 0:Ce.header)?void 0:fe.menus)?void 0:ye.popup)?void 0:ke.list)?void 0:Se.font,...null==($e=null==(Ee=null==(Ie=null==(Me=null==(we=t.inbox)?void 0:we.header)?void 0:Me.menus)?void 0:Ie.popup)?void 0:Ee.list)?void 0:$e.font},selectionIcon:{...null==(Be=null==(Ae=null==(Le=null==(De=null==(Te=Wi.inbox)?void 0:Te.header)?void 0:De.menus)?void 0:Le.popup)?void 0:Ae.list)?void 0:Be.selectionIcon,...null==(ze=null==(He=null==(Re=null==(Fe=null==(Pe=t.inbox)?void 0:Pe.header)?void 0:Fe.menus)?void 0:Re.popup)?void 0:He.list)?void 0:ze.selectionIcon}}},filters:{...null==(Ve=null==(Ue=null==(Oe=Wi.inbox)?void 0:Oe.header)?void 0:Ue.menus)?void 0:Ve.filters,...null==(je=null==(Ze=null==(Ne=t.inbox)?void 0:Ne.header)?void 0:Ze.menus)?void 0:je.filters,inbox:{...null==(qe=null==(Je=null==(We=null==(Ge=Wi.inbox)?void 0:Ge.header)?void 0:We.menus)?void 0:Je.filters)?void 0:qe.inbox,...null==(Qe=null==(Ke=null==(Ye=null==(Xe=t.inbox)?void 0:Xe.header)?void 0:Ye.menus)?void 0:Ke.filters)?void 0:Qe.inbox,icon:{...null==(ot=null==(it=null==(nt=null==(tt=null==(et=Wi.inbox)?void 0:et.header)?void 0:tt.menus)?void 0:nt.filters)?void 0:it.inbox)?void 0:ot.icon,...null==(dt=null==(at=null==(rt=null==(lt=null==(st=t.inbox)?void 0:st.header)?void 0:lt.menus)?void 0:rt.filters)?void 0:at.inbox)?void 0:dt.icon}},archive:{...null==(vt=null==(ct=null==(ht=null==(ut=Wi.inbox)?void 0:ut.header)?void 0:ht.menus)?void 0:ct.filters)?void 0:vt.archive,...null==(_t=null==(mt=null==(gt=null==(pt=t.inbox)?void 0:pt.header)?void 0:gt.menus)?void 0:mt.filters)?void 0:_t.archive,icon:{...null==(yt=null==(ft=null==(Ct=null==(xt=null==(bt=Wi.inbox)?void 0:bt.header)?void 0:xt.menus)?void 0:Ct.filters)?void 0:ft.archive)?void 0:yt.icon,...null==(It=null==(Mt=null==(wt=null==(St=null==(kt=t.inbox)?void 0:kt.header)?void 0:St.menus)?void 0:wt.filters)?void 0:Mt.archive)?void 0:It.icon}}},actions:{...null==(Tt=null==($t=null==(Et=Wi.inbox)?void 0:Et.header)?void 0:$t.menus)?void 0:Tt.actions,...null==(At=null==(Lt=null==(Dt=t.inbox)?void 0:Dt.header)?void 0:Lt.menus)?void 0:At.actions,markAllRead:{...null==(Rt=null==(Ft=null==(Pt=null==(Bt=Wi.inbox)?void 0:Bt.header)?void 0:Pt.menus)?void 0:Ft.actions)?void 0:Rt.markAllRead,...null==(Ut=null==(Ot=null==(zt=null==(Ht=t.inbox)?void 0:Ht.header)?void 0:zt.menus)?void 0:Ot.actions)?void 0:Ut.markAllRead,icon:{...null==(Gt=null==(jt=null==(Zt=null==(Nt=null==(Vt=Wi.inbox)?void 0:Vt.header)?void 0:Nt.menus)?void 0:Zt.actions)?void 0:jt.markAllRead)?void 0:Gt.icon,...null==(Yt=null==(Xt=null==(qt=null==(Jt=null==(Wt=t.inbox)?void 0:Wt.header)?void 0:Jt.menus)?void 0:qt.actions)?void 0:Xt.markAllRead)?void 0:Yt.icon}},archiveAll:{...null==(tn=null==(en=null==(Qt=null==(Kt=Wi.inbox)?void 0:Kt.header)?void 0:Qt.menus)?void 0:en.actions)?void 0:tn.archiveAll,...null==(ln=null==(sn=null==(on=null==(nn=t.inbox)?void 0:nn.header)?void 0:on.menus)?void 0:sn.actions)?void 0:ln.archiveAll,icon:{...null==(hn=null==(un=null==(dn=null==(an=null==(rn=Wi.inbox)?void 0:rn.header)?void 0:an.menus)?void 0:dn.actions)?void 0:un.archiveAll)?void 0:hn.icon,...null==(mn=null==(gn=null==(pn=null==(vn=null==(cn=t.inbox)?void 0:cn.header)?void 0:vn.menus)?void 0:pn.actions)?void 0:gn.archiveAll)?void 0:mn.icon}},archiveRead:{...null==(Cn=null==(xn=null==(bn=null==(_n=Wi.inbox)?void 0:_n.header)?void 0:bn.menus)?void 0:xn.actions)?void 0:Cn.archiveRead,...null==(Sn=null==(kn=null==(yn=null==(fn=t.inbox)?void 0:fn.header)?void 0:yn.menus)?void 0:kn.actions)?void 0:Sn.archiveRead,icon:{...null==($n=null==(En=null==(In=null==(Mn=null==(wn=Wi.inbox)?void 0:wn.header)?void 0:Mn.menus)?void 0:In.actions)?void 0:En.archiveRead)?void 0:$n.icon,...null==(Bn=null==(An=null==(Ln=null==(Dn=null==(Tn=t.inbox)?void 0:Tn.header)?void 0:Dn.menus)?void 0:Ln.actions)?void 0:An.archiveRead)?void 0:Bn.icon}}}}},list:{...null==(Pn=Wi.inbox)?void 0:Pn.list,...null==(Fn=t.inbox)?void 0:Fn.list,item:{...null==(Hn=null==(Rn=Wi.inbox)?void 0:Rn.list)?void 0:Hn.item,...null==(On=null==(zn=t.inbox)?void 0:zn.list)?void 0:On.item,menu:{...null==(Nn=null==(Vn=null==(Un=Wi.inbox)?void 0:Un.list)?void 0:Vn.item)?void 0:Nn.menu,...null==(Gn=null==(jn=null==(Zn=t.inbox)?void 0:Zn.list)?void 0:jn.item)?void 0:Gn.menu,item:{...null==(Xn=null==(qn=null==(Jn=null==(Wn=Wi.inbox)?void 0:Wn.list)?void 0:Jn.item)?void 0:qn.menu)?void 0:Xn.item,...null==(ei=null==(Qn=null==(Kn=null==(Yn=t.inbox)?void 0:Yn.list)?void 0:Kn.item)?void 0:Qn.menu)?void 0:ei.item,read:{...null==(si=null==(oi=null==(ii=null==(ni=null==(ti=Wi.inbox)?void 0:ti.list)?void 0:ni.item)?void 0:ii.menu)?void 0:oi.item)?void 0:si.read,...null==(ui=null==(di=null==(ai=null==(ri=null==(li=t.inbox)?void 0:li.list)?void 0:ri.item)?void 0:ai.menu)?void 0:di.item)?void 0:ui.read},unread:{...null==(gi=null==(pi=null==(vi=null==(ci=null==(hi=Wi.inbox)?void 0:hi.list)?void 0:ci.item)?void 0:vi.menu)?void 0:pi.item)?void 0:gi.unread,...null==(Ci=null==(xi=null==(bi=null==(_i=null==(mi=t.inbox)?void 0:mi.list)?void 0:_i.item)?void 0:bi.menu)?void 0:xi.item)?void 0:Ci.unread},archive:{...null==(wi=null==(Si=null==(ki=null==(yi=null==(fi=Wi.inbox)?void 0:fi.list)?void 0:yi.item)?void 0:ki.menu)?void 0:Si.item)?void 0:wi.archive,...null==(Ti=null==($i=null==(Ei=null==(Ii=null==(Mi=t.inbox)?void 0:Mi.list)?void 0:Ii.item)?void 0:Ei.menu)?void 0:$i.item)?void 0:Ti.archive},unarchive:{...null==(Pi=null==(Bi=null==(Ai=null==(Li=null==(Di=Wi.inbox)?void 0:Di.list)?void 0:Li.item)?void 0:Ai.menu)?void 0:Bi.item)?void 0:Pi.unarchive,...null==(Oi=null==(zi=null==(Hi=null==(Ri=null==(Fi=t.inbox)?void 0:Fi.list)?void 0:Ri.item)?void 0:Hi.menu)?void 0:zi.item)?void 0:Oi.unarchive}}}}},loading:{...null==(Ui=Wi.inbox)?void 0:Ui.loading,...null==(Vi=t.inbox)?void 0:Vi.loading},empty:{...null==(Ni=Wi.inbox)?void 0:Ni.empty,...null==(Zi=t.inbox)?void 0:Zi.empty},error:{...null==(ji=Wi.inbox)?void 0:ji.error,...null==(Gi=t.inbox)?void 0:Gi.error}}}};class Y{constructor(e){o(this,"THEME_CHANGE_EVENT","courier_inbox_theme_change"),o(this,"_theme"),o(this,"_lightTheme",J),o(this,"_darkTheme",q),o(this,"_target"),o(this,"_subscriptions",[]),o(this,"_userMode"),o(this,"_systemMode"),o(this,"_systemThemeCleanup"),this._theme=e,this._target=new EventTarget,this._userMode="system",this._systemMode=g(),this.setLightTheme(J),this.setDarkTheme(q),this._systemThemeCleanup=m((e=>{this._systemMode=e,this.updateTheme()}))}setLightTheme(e){this._lightTheme=e,"light"===this._systemMode&&this.updateTheme()}setDarkTheme(e){this._darkTheme=e,"dark"===this._systemMode&&this.updateTheme()}get currentSystemTheme(){return this._systemMode}getTheme(){return this._theme}updateTheme(){const e="system"===this._userMode?this._systemMode:this._userMode,t="light"===e?this._lightTheme:this._darkTheme,n=X(e,t);this.setTheme(n)}setTheme(e){e!==this._theme&&(this._theme=e,this._target.dispatchEvent(new CustomEvent(this.THEME_CHANGE_EVENT,{detail:{theme:e}})))}setMode(e){this._userMode=e,this.updateTheme()}subscribe(e){const t=new AbortController;this._target.addEventListener(this.THEME_CHANGE_EVENT,(t=>{e(t.detail.theme)}),{signal:t.signal});const n={manager:this,unsubscribe:()=>{t.abort();const e=this._subscriptions.indexOf(n);e>-1&&this._subscriptions.splice(e,1)}};return this._subscriptions.push(n),n}cleanup(){this._systemThemeCleanup&&this._systemThemeCleanup(),this._subscriptions.forEach((e=>e.unsubscribe())),this._subscriptions=[]}}class K extends b{constructor(e){super(),o(this,"_currentFeed","inbox"),o(this,"_themeManager"),o(this,"_inboxStyle"),o(this,"_unreadIndicatorStyle"),o(this,"_list"),o(this,"_datastoreListener"),o(this,"_authListener"),o(this,"_header"),o(this,"_headerFactory"),o(this,"_onMessageClick"),o(this,"_onMessageActionClick"),o(this,"_onMessageLongPress"),o(this,"_defaultProps",{title:"Inbox",icon:k.inbox,feedType:this._currentFeed,height:"768px"}),this._themeManager=e??new Y(J)}static get id(){return"courier-inbox"}get theme(){return this._themeManager.getTheme()}setLightTheme(e){this._themeManager.setLightTheme(e)}setDarkTheme(e){this._themeManager.setDarkTheme(e)}static get observedAttributes(){return["height","light-theme","dark-theme","mode","message-click","message-action-click","message-long-press"]}onComponentMounted(){var e,n;this._inboxStyle=T(K.id,this.getStyles()),this._unreadIndicatorStyle=T(Z.id,Z.getStyles(this.theme)),this._header=new G({themeManager:this._themeManager,onFeedTypeChange:e=>{this.setFeedType(e)}}),this._header.build(void 0),this.appendChild(this._header),this._list=new U({themeManager:this._themeManager,onRefresh:()=>{this.refresh()},onPaginationTrigger:async e=>{var n,i;try{await P.shared.fetchNextPageOfMessages({feedType:e})}catch(o){null==(i=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||i.error("Failed to fetch next page of messages:",o)}},onMessageClick:(e,t)=>{var n;P.shared.clickMessage({message:e}),this.dispatchEvent(new CustomEvent("message-click",{detail:{message:e,index:t},bubbles:!0,composed:!0})),null==(n=this._onMessageClick)||n.call(this,{message:e,index:t})},onMessageActionClick:(e,t,n)=>{var i;this.dispatchEvent(new CustomEvent("message-action-click",{detail:{message:e,action:t,index:n},bubbles:!0,composed:!0})),null==(i=this._onMessageActionClick)||i.call(this,{message:e,action:t,index:n})},onMessageLongPress:(e,t)=>{var n;this.dispatchEvent(new CustomEvent("message-long-press",{detail:{message:e,index:t},bubbles:!0,composed:!0})),null==(n=this._onMessageLongPress)||n.call(this,{message:e,index:t})}}),this.refreshTheme(),this.appendChild(this._list),this._datastoreListener=new W({onError:e=>{var t;null==(t=this._list)||t.setError(e)},onDataSetChange:(e,t)=>{var n;this._currentFeed===t&&(null==(n=this._list)||n.setDataSet(e),this.updateHeader())},onPageAdded:(e,t)=>{var n;this._currentFeed===t&&(null==(n=this._list)||n.addPage(e),this.updateHeader())},onMessageAdd:(e,t,n)=>{var i;this._currentFeed===n&&(null==(i=this._list)||i.addMessage(e,t),this.updateHeader())},onMessageRemove:(e,t,n)=>{var i;this._currentFeed===n&&(null==(i=this._list)||i.removeMessage(t),this.updateHeader())},onMessageUpdate:(e,t,n)=>{var i;this._currentFeed===n&&(null==(i=this._list)||i.updateMessage(e,t),this.updateHeader())},onUnreadCountChange:e=>{this.updateHeader()}}),P.shared.addDataStoreListener(this._datastoreListener),this._themeManager.subscribe((e=>{this.refreshTheme()})),this._authListener=t.Courier.shared.addAuthenticationListener((e=>{this.refresh()})),(null==(e=t.Courier.shared.client)?void 0:e.options.userId)?this.refresh():null==(n=t.Courier.shared.client)||n.options.logger.error("No user signed in. Please call Courier.shared.signIn(...) to load the inbox.")}onComponentUnmounted(){var e,t,n,i;this._themeManager.cleanup(),null==(e=this._datastoreListener)||e.remove(),null==(t=this._authListener)||t.remove(),null==(n=this._inboxStyle)||n.remove(),null==(i=this._unreadIndicatorStyle)||i.remove()}refreshTheme(){this._inboxStyle&&(this._inboxStyle.textContent=this.getStyles()),this._unreadIndicatorStyle&&(this._unreadIndicatorStyle.textContent=Z.getStyles(this.theme))}getStyles(){return`\n ${K.id} {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: ${this._defaultProps.height};\n }\n\n ${K.id} courier-inbox-list {\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n }\n `}setHeader(e){this._headerFactory=e,this.updateHeader()}removeHeader(){this._headerFactory=null,this.updateHeader()}setLoadingState(e){var t;null==(t=this._list)||t.setLoadingStateFactory(e)}setEmptyState(e){var t;null==(t=this._list)||t.setEmptyStateFactory(e)}setErrorState(e){var t;null==(t=this._list)||t.setErrorStateFactory(e)}setListItem(e){var t;null==(t=this._list)||t.setListItemFactory(e)}setPaginationItem(e){var t;null==(t=this._list)||t.setPaginationItemFactory(e)}onMessageClick(e){this._onMessageClick=e}onMessageActionClick(e){this._onMessageActionClick=e}onMessageLongPress(e){this._onMessageLongPress=e}setFeedType(e){var t;this._currentFeed=e,null==(t=this._list)||t.setFeedType(e),this.updateHeader(),this.load({canUseCache:!0})}updateHeader(){var e,t,n,i;const o={feedType:this._currentFeed,unreadCount:P.shared.unreadCount,messageCount:(null==(e=this._list)?void 0:e.messages.length)??0};switch(this._headerFactory){case void 0:null==(t=this._header)||t.render(o);break;case null:null==(n=this._header)||n.build(null);break;default:const e=this._headerFactory(o);null==(i=this._header)||i.build(e)}}async load(e){await P.shared.load(e),await P.shared.listenForUpdates()}refresh(){this.load({canUseCache:!1})}attributeChangedCallback(e,n,i){var o,s,l,r,a,d;if(n!==i)switch(e){case"height":const e=i||this._defaultProps.height;this.style.height=e;break;case"message-click":if(i)try{this._onMessageClick=new Function("props",i)}catch(u){null==(s=null==(o=t.Courier.shared.client)?void 0:o.options.logger)||s.error("Failed to parse message-click handler:",u)}else this._onMessageClick=void 0;break;case"message-action-click":if(i)try{this._onMessageActionClick=new Function("props",i)}catch(u){null==(r=null==(l=t.Courier.shared.client)?void 0:l.options.logger)||r.error("Failed to parse message-action-click handler:",u)}else this._onMessageActionClick=void 0;break;case"message-long-press":if(i)try{this._onMessageLongPress=new Function("props",i)}catch(u){null==(d=null==(a=t.Courier.shared.client)?void 0:a.options.logger)||d.error("Failed to parse message-long-press handler:",u)}else this._onMessageLongPress=void 0;break;case"light-theme":i&&this.setLightTheme(JSON.parse(i));break;case"dark-theme":i&&this.setDarkTheme(JSON.parse(i));break;case"mode":this._themeManager.setMode(i)}}}$(K);class Q extends M{constructor(e){super(),o(this,"_themeSubscription"),o(this,"_style"),o(this,"_container"),o(this,"_triggerButton"),o(this,"_unreadCountBadge"),this._themeSubscription=e.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-inbox-menu-button"}get theme(){return this._themeSubscription.manager.getTheme()}onComponentMounted(){this._style=T(Q.id,Q.getStyles(this.theme))}onComponentUnmounted(){var e;this._themeSubscription.unsubscribe(),null==(e=this._style)||e.remove()}defaultElement(){return this._container=document.createElement("div"),this._container.className="menu-button-container",this._triggerButton=new E(k.inbox),this._unreadCountBadge=new Z({themeBus:this._themeSubscription.manager,location:"button"}),this._unreadCountBadge.id="unread-badge",this._container.appendChild(this._triggerButton),this._container.appendChild(this._unreadCountBadge),this.appendChild(this._container),this.refreshTheme(),this._container}static getStyles(e){return`\n ${Q.id} .menu-button-container {\n position: relative;\n display: inline-block;\n }\n \n ${Q.id} #unread-badge {\n position: absolute;\n top: -8px;\n left: 50%;\n pointer-events: none;\n }\n `}onUnreadCountChange(e){var t;null==(t=this._unreadCountBadge)||t.setCount(e),this.refreshTheme()}refreshTheme(){var e,t,n,i,o,s,l,r,a,d,h,c,v,p,g,m,_,b,x,C,f,y,S;null==(o=this._triggerButton)||o.updateIconColor((null==(i=null==(n=null==(t=null==(e=this.theme)?void 0:e.popup)?void 0:t.button)?void 0:n.icon)?void 0:i.color)??u[500]),null==(d=this._triggerButton)||d.updateIconSVG((null==(a=null==(r=null==(l=null==(s=this.theme)?void 0:s.popup)?void 0:l.button)?void 0:r.icon)?void 0:a.svg)??k.inbox),null==(p=this._triggerButton)||p.updateBackgroundColor((null==(v=null==(c=null==(h=this.theme)?void 0:h.popup)?void 0:c.button)?void 0:v.backgroundColor)??"transparent"),null==(b=this._triggerButton)||b.updateHoverBackgroundColor((null==(_=null==(m=null==(g=this.theme)?void 0:g.popup)?void 0:m.button)?void 0:_.hoverBackgroundColor)??u[50010]),null==(y=this._triggerButton)||y.updateActiveBackgroundColor((null==(f=null==(C=null==(x=this.theme)?void 0:x.popup)?void 0:C.button)?void 0:f.activeBackgroundColor)??u[50020]),null==(S=this._unreadCountBadge)||S.refreshTheme("button")}}$(Q);class ee extends b{constructor(){super(),o(this,"_width","440px"),o(this,"_height","440px"),o(this,"_popupAlignment","top-right"),o(this,"_top","40px"),o(this,"_right","0"),o(this,"_bottom","40px"),o(this,"_left","0"),o(this,"_themeManager",new Y(J)),o(this,"_triggerButton"),o(this,"_popup"),o(this,"_inbox"),o(this,"_style"),o(this,"_datastoreListener"),o(this,"_popupMenuButtonFactory"),o(this,"handleOutsideClick",(e=>{if(!this._popup)return;const t=["courier-inbox-option-menu"];e.composedPath().some((e=>e instanceof HTMLElement&&(!(e!==this._popup&&!this._popup.contains(e))||t.some((t=>e.matches(t))))))||(this._popup.style.display="none")})),this._themeManager.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-inbox-popup-menu"}get theme(){return this._themeManager.getTheme()}setLightTheme(e){this._themeManager.setLightTheme(e)}setDarkTheme(e){this._themeManager.setDarkTheme(e)}static get observedAttributes(){return["popup-alignment","message-click","message-action-click","message-long-press","popup-width","popup-height","top","right","bottom","left","light-theme","dark-theme","mode"]}onComponentMounted(){this._style=T(ee.id,ee.getStyles(this.theme,this._width,this._height)),this._triggerButton=new Q(this._themeManager),this._triggerButton.build(void 0),this._popup=document.createElement("div"),this._popup.className="popup",this._inbox=new K(this._themeManager),this._inbox.setAttribute("height","100%"),this.refreshTheme(),this.appendChild(this._triggerButton),this.appendChild(this._popup),this._popup.appendChild(this._inbox),this._triggerButton.addEventListener("click",this.togglePopup.bind(this)),document.addEventListener("click",this.handleOutsideClick.bind(this)),this.updatePopupPosition(),this._datastoreListener=new W(this),P.shared.addDataStoreListener(this._datastoreListener)}onComponentUnmounted(){var e,t;null==(e=this._style)||e.remove(),null==(t=this._datastoreListener)||t.remove(),this._themeManager.cleanup()}refreshTheme(){this._style&&(this._style.textContent=ee.getStyles(this.theme,this._width,this._height))}static getStyles(e,t,n){var i,o,s,l,r,a,d,u;return`\n ${ee.id} {\n display: inline-block;\n position: relative;\n }\n\n ${ee.id} .menu-button-container {\n position: relative;\n display: inline-block;\n }\n\n ${ee.id} .popup {\n display: none;\n position: absolute;\n background: ${(null==(o=null==(i=e.popup)?void 0:i.window)?void 0:o.backgroundColor)??"red"};\n border-radius: ${(null==(l=null==(s=e.popup)?void 0:s.window)?void 0:l.borderRadius)??"8px"};\n border: ${(null==(a=null==(r=e.popup)?void 0:r.window)?void 0:a.border)??"1px solid red"};\n box-shadow: ${(null==(u=null==(d=e.popup)?void 0:d.window)?void 0:u.shadow)??"0px 8px 16px -4px red"};\n z-index: 1000;\n width: ${t};\n height: ${n};\n overflow: hidden;\n transform: translateZ(0);\n will-change: transform;\n }\n \n ${ee.id} #unread-badge {\n position: absolute;\n top: -8px;\n left: 50%;\n pointer-events: none;\n }\n\n ${ee.id} courier-inbox {\n height: 100%;\n }\n `}attributeChangedCallback(e,t,n){switch(e){case"popup-alignment":this.isValidPosition(n)&&(this._popupAlignment=n,this.updatePopupPosition());break;case"popup-width":this._width=n,this.setSize(n,this._height);break;case"popup-height":this._height=n,this.setSize(this._width,n);break;case"top":this._top=n,this.updatePopupPosition();break;case"right":this._right=n,this.updatePopupPosition();break;case"bottom":this._bottom=n,this.updatePopupPosition();break;case"left":this._left=n,this.updatePopupPosition();break;case"light-theme":n&&this.setLightTheme(JSON.parse(n));break;case"dark-theme":n&&this.setDarkTheme(JSON.parse(n));break;case"mode":this._themeManager.setMode(n)}}onUnreadCountChange(e){this.render()}onMessageClick(e){var t;null==(t=this._inbox)||t.onMessageClick(e)}onMessageActionClick(e){var t;null==(t=this._inbox)||t.onMessageActionClick(e)}onMessageLongPress(e){var t;null==(t=this._inbox)||t.onMessageLongPress(e)}isValidPosition(e){return["top-right","top-left","top-center","bottom-right","bottom-left","bottom-center","center-right","center-left","center-center"].includes(e)}updatePopupPosition(){if(this._popup)switch(this._popup.style.top="",this._popup.style.bottom="",this._popup.style.left="",this._popup.style.right="",this._popup.style.margin="",this._popup.style.transform="",this._popupAlignment){case"top-right":this._popup.style.top=this._top,this._popup.style.right=this._right;break;case"top-left":this._popup.style.top=this._top,this._popup.style.left=this._left;break;case"top-center":this._popup.style.top=this._top,this._popup.style.left="50%",this._popup.style.transform="translateX(-50%)";break;case"bottom-right":this._popup.style.bottom=this._bottom,this._popup.style.right=this._right;break;case"bottom-left":this._popup.style.bottom=this._bottom,this._popup.style.left=this._left;break;case"bottom-center":this._popup.style.bottom=this._bottom,this._popup.style.left="50%",this._popup.style.transform="translateX(-50%)";break;case"center-right":this._popup.style.top="50%",this._popup.style.right=this._right,this._popup.style.transform="translateY(-50%)";break;case"center-left":this._popup.style.top="50%",this._popup.style.left=this._left,this._popup.style.transform="translateY(-50%)";break;case"center-center":this._popup.style.top="50%",this._popup.style.left="50%",this._popup.style.transform="translate(-50%, -50%)"}}togglePopup(e){if(e.stopPropagation(),!this._popup)return;const t="block"===this._popup.style.display;this._popup.style.display=t?"none":"block"}setContent(e){this._inbox&&(this._inbox.innerHTML="",this._inbox.appendChild(e))}setSize(e,t){this._width=e,this._height=t,this._popup&&(this._popup.style.width=e,this._popup.style.height=t)}setPosition(e){var n,i;this.isValidPosition(e)?(this._popupAlignment=e,this.updatePopupPosition()):null==(i=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||i.error(`Invalid position: ${e}`)}setFeedType(e){var t;null==(t=this._inbox)||t.setFeedType(e)}setPopupHeader(e){var t;null==(t=this._inbox)||t.setHeader(e)}removePopupHeader(){var e;null==(e=this._inbox)||e.removeHeader()}setPopupLoadingState(e){var t;null==(t=this._inbox)||t.setLoadingState(e)}setPopupEmptyState(e){var t;null==(t=this._inbox)||t.setEmptyState(e)}setPopupErrorState(e){var t;null==(t=this._inbox)||t.setErrorState(e)}setPopupListItem(e){var t;null==(t=this._inbox)||t.setListItem(e)}setPopupPaginationItem(e){var t;null==(t=this._inbox)||t.setPaginationItem(e)}setPopupMenuButton(e){this._popupMenuButtonFactory=e,this.render()}render(){const e=P.shared.unreadCount;if(this._triggerButton)switch(this._popupMenuButtonFactory){case void 0:case null:this._triggerButton.build(void 0),this._triggerButton.onUnreadCountChange(e);break;default:const t=this._popupMenuButtonFactory({unreadCount:e});this._triggerButton.build(t)}}}$(ee);e.CourierInbox=K,e.CourierInboxDataStoreListener=W,e.CourierInboxDatastore=P,e.CourierInboxDatastoreEvents=class{onDataSetChange(e,t){}onPageAdded(e,t){}onUnreadCountChange(e){}onMessageAdd(e,t,n){}onMessageRemove(e,t,n){}onMessageUpdate(e,t,n){}onError(e){}},e.CourierInboxHeader=G,e.CourierInboxListItem=F,e.CourierInboxPopupMenu=ee,e.CourierInboxThemeManager=Y,e.archiveMessage=function(e){return P.shared.archiveMessage({message:e})},e.clickMessage=function(e){return P.shared.clickMessage({message:e})},e.defaultDarkTheme=q,e.defaultLightTheme=J,e.markAsRead=function(e){return P.shared.readMessage({message:e})},e.markAsUnread=function(e){return P.shared.unreadMessage({message:e})},e.mergeTheme=X,e.openMessage=function(e){return P.shared.openMessage({message:e})},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
2
2
|
//# sourceMappingURL=index.js.map
|