@trycourier/courier-ui-inbox 2.2.0 → 2.3.0

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/index.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@trycourier/courier-js"),require("@trycourier/courier-ui-core")):"function"==typeof define&&define.amd?define(["exports","@trycourier/courier-js","@trycourier/courier-ui-core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CourierUIInbox={},e.CourierJS,e.CourierUICore)}(this,(function(e,t,i){"use strict";var n=Object.defineProperty,o=(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);function s(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=>s(e)))}}class r extends i.CourierBaseElement{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,i,n;const o=null==(n=null==(i=null==(t=e.inbox)?void 0:t.list)?void 0:i.item)?void 0:n.menu,s=null==o?void 0:o.animation,l=(null==s?void 0:s.initialTransform)??"translate3d(0, 0, 0)",a=(null==s?void 0:s.visibleTransform)??"translate3d(0, 0, 0)";return`\n ${r.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: ${(null==s?void 0:s.transition)??"all 0.2s ease"};\n overflow: hidden;\n transform: ${l};\n will-change: transform, opacity;\n }\n\n ${r.id}.visible {\n opacity: 1;\n pointer-events: auto;\n transform: ${a};\n }\n\n ${r.id} ul.menu {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: row;\n }\n\n ${r.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 touch-action: none;\n }\n `}setOptions(e){this._options=e,this.renderMenu()}renderMenu(){var e,t,n;const o=this.querySelector("ul.menu");if(!o)return;o.innerHTML="";const s=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.menu,l=e=>{e.stopPropagation(),"touchstart"!==e.type&&"mousedown"!==e.type||e.preventDefault()};this._options.forEach((e=>{var t,n,r;const a=new i.CourierIconButton(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==(r=null==s?void 0:s.item)?void 0:r.borderRadius),d=t=>{t.stopPropagation(),e.onClick()};a.addEventListener("click",d),a.addEventListener("touchstart",l,{passive:!1}),a.addEventListener("touchend",d,{passive:!0}),a.addEventListener("touchmove",(e=>{e.stopPropagation()}),{passive:!0}),a.addEventListener("mousedown",l),a.addEventListener("mouseup",l),o.appendChild(a)}))}show(){this.style.display="block",this.classList.remove("visible"),requestAnimationFrame((()=>{requestAnimationFrame((()=>{this.classList.add("visible")}))}))}hide(){this.classList.remove("visible");const e=t=>{t.target===this&&(this.classList.contains("visible")||(this.style.display="none",this.removeEventListener("transitionend",e)))};this.addEventListener("transitionend",e)}}i.registerElement(r);class a{constructor(e,t){o(this,"_id"),o(this,"_messages",[]),o(this,"_firstFetchComplete",!1),o(this,"_hasNextPage",!1),o(this,"_lastPaginationCursor"),o(this,"_filter"),o(this,"_datastoreListeners",[]),o(this,"_totalUnreadCount",0),this._id=e,this._filter={tags:t.tags?[...t.tags]:void 0,archived:t.archived||!1,status:t.status}}get totalUnreadCount(){return this._totalUnreadCount}set totalUnreadCount(e){this._totalUnreadCount=e>0?e:0}setUnreadCount(e){this.totalUnreadCount=e,this._datastoreListeners.forEach((t=>{var i,n,o,s;null==(n=(i=t.events).onUnreadCountChange)||n.call(i,e,this._id),null==(s=(o=t.events).onTotalUnreadCountChange)||s.call(o,u.shared.totalUnreadCount)}))}getFilter(){return{tags:this._filter.tags,archived:this._filter.archived,status:this._filter.status}}addMessage(e,t=0){const i=s(e);return!!this.messageQualifiesForDataset(i)&&(this._messages.splice(t,0,i),i.read||(this.totalUnreadCount+=1),this._datastoreListeners.forEach((e=>{var n,o,s,l,r,a;null==(o=(n=e.events).onMessageAdd)||o.call(n,i,t,this._id),null==(l=(s=e.events).onUnreadCountChange)||l.call(s,this.totalUnreadCount,this._id),null==(a=(r=e.events).onTotalUnreadCountChange)||a.call(r,u.shared.totalUnreadCount)})),!0)}updateWithMessageChange(e,t){const i=this.indexOfMessage(t),n=this._messages[i],o=s(t);if(n&&(r=o,(l=n).archived===r.archived&&l.read===r.read&&l.opened===r.opened))return!0;var l,r;if(n){if(this.messageQualifiesForDataset(o)){const e=this.calculateUnreadChange(n,o);return this._messages.splice(i,1,o),this.totalUnreadCount+=e,this._datastoreListeners.forEach((e=>{var t,n,s,l,r,a;null==(n=(t=e.events).onMessageUpdate)||n.call(t,o,i,this._id),null==(l=(s=e.events).onUnreadCountChange)||l.call(s,this.totalUnreadCount,this._id),null==(a=(r=e.events).onTotalUnreadCountChange)||a.call(r,u.shared.totalUnreadCount)})),!0}return this.removeMessage(n),!1}if(this.messageQualifiesForDataset(t)){const i=this.findInsertIndex(t);this._messages.splice(i,0,s(t));const n=this.messageQualifiesForDataset(e)?this.calculateUnreadChange(e,t):t.read?0:1;return this.totalUnreadCount+=n,this._datastoreListeners.forEach((e=>{var n,o,s,l,r,a;null==(o=(n=e.events).onMessageAdd)||o.call(n,t,i,this._id),null==(l=(s=e.events).onUnreadCountChange)||l.call(s,this.totalUnreadCount,this._id),null==(a=(r=e.events).onTotalUnreadCountChange)||a.call(r,u.shared.totalUnreadCount)})),!0}return this.messageQualifiesForDataset(e)&&(this.totalUnreadCount+=this.calculateUnreadChange(e,t),this._datastoreListeners.forEach((e=>{var t,n,s,l,r,a;null==(n=(t=e.events).onMessageUpdate)||n.call(t,o,i,this._id),null==(l=(s=e.events).onUnreadCountChange)||l.call(s,this.totalUnreadCount,this._id),null==(a=(r=e.events).onTotalUnreadCountChange)||a.call(r,u.shared.totalUnreadCount)}))),!1}calculateUnreadChange(e,t){return e.read&&!t.read?1:!e.read&&t.read?-1:0}removeMessage(e){const t=this.indexOfMessage(e);return t>-1&&(this._messages.splice(t,1),e.read||(this.totalUnreadCount-=1),this._datastoreListeners.forEach((i=>{var n,o,s,l,r,a;null==(o=(n=i.events).onMessageRemove)||o.call(n,e,t,this._id),null==(l=(s=i.events).onUnreadCountChange)||l.call(s,this.totalUnreadCount,this._id),null==(a=(r=i.events).onTotalUnreadCountChange)||a.call(r,u.shared.totalUnreadCount)})),!0)}getMessage(e){return this._messages.find((t=>t.messageId===e))}async loadDataset(e){if(e&&this._firstFetchComplete)return void this._datastoreListeners.forEach((e=>{var t,i,n,o,s,l;null==(i=(t=e.events).onDataSetChange)||i.call(t,this.toInboxDataset()),null==(o=(n=e.events).onUnreadCountChange)||o.call(n,this.totalUnreadCount,this._id),null==(l=(s=e.events).onTotalUnreadCountChange)||l.call(s,u.shared.totalUnreadCount)}));const t=await this.fetchMessages();this._messages=[...t.messages],this.totalUnreadCount=t.unreadCount,this._hasNextPage=t.canPaginate,this._lastPaginationCursor=t.paginationCursor??void 0,this._firstFetchComplete=!0,this._datastoreListeners.forEach((e=>{var t,i,n,o,s,l;null==(i=(t=e.events).onDataSetChange)||i.call(t,this.toInboxDataset()),null==(o=(n=e.events).onUnreadCountChange)||o.call(n,this.totalUnreadCount,this._id),null==(l=(s=e.events).onTotalUnreadCountChange)||l.call(s,u.shared.totalUnreadCount)}))}async fetchNextPageOfMessages(){if(!this._hasNextPage)return null;const e=await this.fetchMessages(this._lastPaginationCursor);return this._messages=[...this._messages,...e.messages],this._hasNextPage=e.canPaginate,this._lastPaginationCursor=e.paginationCursor??void 0,this._firstFetchComplete=!0,this._datastoreListeners.forEach((t=>{var i,n,o,s,l,r,a,d;null==(n=(i=t.events).onDataSetChange)||n.call(i,this.toInboxDataset()),null==(s=(o=t.events).onUnreadCountChange)||s.call(o,this.totalUnreadCount,this._id),null==(r=(l=t.events).onPageAdded)||r.call(l,e),null==(d=(a=t.events).onTotalUnreadCountChange)||d.call(a,u.shared.totalUnreadCount)})),e}addDatastoreListener(e){this._datastoreListeners.push(e)}removeDatastoreListener(e){const t=this._datastoreListeners.indexOf(e);t>-1&&this._datastoreListeners.splice(t,1)}toInboxDataset(){return{id:this._id,messages:[...this._messages],unreadCount:this.totalUnreadCount,canPaginate:this._hasNextPage,paginationCursor:this._lastPaginationCursor??null}}async fetchMessages(e){var i,n,o,s,l,r,a,d,u;const h=t.Courier.shared.client;if(!(null==h?void 0:h.options.userId))throw new Error("User is not signed in");const c=await h.inbox.getMessages({paginationLimit:t.Courier.shared.paginationLimit,startCursor:e,filter:this.getFilter()});return{id:this._id,messages:[...(null==(n=null==(i=c.data)?void 0:i.messages)?void 0:n.nodes)??[]],unreadCount:(null==(o=c.data)?void 0:o.unreadCount)??0,canPaginate:(null==(r=null==(l=null==(s=c.data)?void 0:s.messages)?void 0:l.pageInfo)?void 0:r.hasNextPage)??!1,paginationCursor:(null==(u=null==(d=null==(a=c.data)?void 0:a.messages)?void 0:d.pageInfo)?void 0:u.startCursor)??null}}indexOfMessage(e){return this._messages.findIndex((t=>t.messageId===e.messageId))}findInsertIndex(e){const t=this._messages;for(let i=0;i<t.length;i++){const n=t[i];if(n.created&&e.created&&n.created<e.created)return i}return t.length}messageQualifiesForDataset(e){if(e.archived&&!this._filter.archived||!e.archived&&this._filter.archived)return!1;if(e.read&&"unread"===this._filter.status||!e.read&&"read"===this._filter.status)return!1;if(this._filter.tags&&!e.tags)return!1;if(this._filter.tags&&e.tags){for(const t of this._filter.tags)if(e.tags.includes(t))return!0;return!1}return!0}restoreFromSnapshot(e){this._messages=e.messages.map((e=>s(e))),this.totalUnreadCount=e.unreadCount,this._hasNextPage=e.canPaginate,this._lastPaginationCursor=e.paginationCursor??void 0,this._datastoreListeners.forEach((t=>{var i,n,o,s,l,r;null==(n=(i=t.events).onDataSetChange)||n.call(i,e),null==(s=(o=t.events).onUnreadCountChange)||s.call(o,this.totalUnreadCount,this._id),null==(r=(l=t.events).onTotalUnreadCountChange)||r.call(l,u.shared.totalUnreadCount)}))}}const d=class e{constructor(){o(this,"_datasets",new Map),o(this,"_listeners",[]),o(this,"_removeMessageEventListener"),o(this,"_globalMessages",new Map)}registerFeeds(e){const t=new Map(e.flatMap((e=>e.tabs)).map((e=>[e.datasetId,e.filter])));this.createDatasetsFromFilters(t)}createDatasetsFromFilters(e){this.clearDatasets();for(let[t,i]of e){const e=new a(t,i);for(let t of this._listeners)e.addDatastoreListener(t);this._datasets.set(t,e)}}addMessage(e){this._globalMessages.set(e.messageId,e);for(let t of this._datasets.values())t.addMessage(e)}updateDatasetsWithMessageChange(e,t){for(let i of this._datasets.values())i.updateWithMessageChange(e,t)}async listenForUpdates(){var e,i,n,o,s,l,r,a,d,u,h;const c=null==(e=t.Courier.shared.client)?void 0:e.inbox.socket;if(c)try{if(this._removeMessageEventListener&&this._removeMessageEventListener(),this._removeMessageEventListener=c.addMessageEventListener((e=>this.handleMessageEvent(e))),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}]`));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)}else null==(n=null==(i=t.Courier.shared.client)?void 0:i.options.logger)||n.info("CourierInbox socket not available")}async loadUnreadCountsForTabs(e){const i=t.Courier.shared.client;if(!i)return;const n={};for(const t of e){const e=this._datasets.get(t);e&&(n[t]=e.getFilter())}if(0===Object.keys(n).length)return;const o=await i.inbox.getUnreadCounts(n);for(const[t,s]of Object.entries(o)){const e=this._datasets.get(t);e&&e.setUnreadCount(s)}}addDataStoreListener(e){this._listeners.push(e);for(let t of this._datasets.values())t.addDatastoreListener(e)}removeDataStoreListener(e){this._listeners=this._listeners.filter((t=>t!==e));for(let t of this._datasets.values())t.removeDatastoreListener(e)}async readMessage({message:i}){if(i.read)return;const n=this._globalMessages.get(i.messageId);n&&await this.executeWithRollback((async()=>{var o;const l=s(n);l.read=e.getISONow(),this._globalMessages.set(i.messageId,l),this.updateDatasetsWithMessageChange(n,l),await(null==(o=t.Courier.shared.client)?void 0:o.inbox.read({messageId:i.messageId}))}))}async unreadMessage({message:e}){if(!e.read)return;const i=this._globalMessages.get(e.messageId);i&&await this.executeWithRollback((async()=>{var n;const o=s(i);o.read=void 0,this._globalMessages.set(e.messageId,o),this.updateDatasetsWithMessageChange(i,o),await(null==(n=t.Courier.shared.client)?void 0:n.inbox.unread({messageId:e.messageId}))}))}async openMessage({message:i}){if(i.opened)return;const n=this._globalMessages.get(i.messageId);n&&await this.executeWithRollback((async()=>{var o;const l=s(n);l.opened=e.getISONow(),this._globalMessages.set(i.messageId,l),this.updateDatasetsWithMessageChange(n,l),await(null==(o=t.Courier.shared.client)?void 0:o.inbox.open({messageId:i.messageId}))}))}async unarchiveMessage({message:e}){if(!e.archived)return;const i=this._globalMessages.get(e.messageId);i&&await this.executeWithRollback((async()=>{var n;const o=s(i);o.archived=void 0,this._globalMessages.set(e.messageId,o),this.updateDatasetsWithMessageChange(i,o),await(null==(n=t.Courier.shared.client)?void 0:n.inbox.unarchive({messageId:e.messageId}))}))}async archiveMessage({message:i}){if(i.archived)return;const n=this._globalMessages.get(i.messageId);n&&await this.executeWithRollback((async()=>{var o;const l=s(n);l.archived=e.getISONow(),this._globalMessages.set(i.messageId,l),this.updateDatasetsWithMessageChange(n,l),await(null==(o=t.Courier.shared.client)?void 0:o.inbox.archive({messageId:i.messageId}))}))}async clickMessage({message:i}){var n,o,s,l;if(null==(n=i.trackingIds)?void 0:n.clickTrackingId)try{await(null==(o=t.Courier.shared.client)?void 0:o.inbox.click({messageId:i.messageId,trackingId:i.trackingIds.clickTrackingId}))}catch(r){null==(l=null==(s=t.Courier.shared.client)?void 0:s.options.logger)||l.error(`[${e.TAG}] Error clicking message:`,r),this._listeners.forEach((e=>{var t,i;null==(i=(t=e.events).onError)||i.call(t,r)}))}}async archiveAllMessages(){await this.executeWithRollback((async()=>{var i;const n=e.getISONow();for(const[e,t]of this._globalMessages.entries())if(!t.archived){const i=s(t);i.archived=n,this._globalMessages.set(e,i),this.updateDatasetsWithMessageChange(t,i)}await(null==(i=t.Courier.shared.client)?void 0:i.inbox.archiveAll())}))}async readAllMessages(){await this.executeWithRollback((async()=>{var i;const n=e.getISONow();for(const[e,t]of this._globalMessages.entries())if(!t.read){const i=s(t);i.read=n,this._globalMessages.set(e,i),this.updateDatasetsWithMessageChange(t,i)}await(null==(i=t.Courier.shared.client)?void 0:i.inbox.readAll())}))}async archiveReadMessages(){await this.executeWithRollback((async()=>{var i;const n=e.getISONow();for(const[e,t]of this._globalMessages.entries())if(t.read&&!t.archived){const i=s(t);i.archived=n,this._globalMessages.set(e,i),this.updateDatasetsWithMessageChange(t,i)}await(null==(i=t.Courier.shared.client)?void 0:i.inbox.archiveRead())}))}async load(e){const i=t.Courier.shared.client;if(!(null==i?void 0:i.options.userId))throw new Error("[Datastore] User is not signed in");const n=(null==e?void 0:e.canUseCache)??!0;if(null==e?void 0:e.datasetIds){const t=e.datasetIds.flatMap((e=>{const t=this._datasets.get(e);return t?[t]:[]}));return await this.loadDatasets({canUseCache:n,datasets:t})}return await this.loadDatasets({canUseCache:n,datasets:Array.from(this._datasets.values())})}async loadDatasets(e){await Promise.all(e.datasets.map((async t=>{await t.loadDataset(e.canUseCache),this.syncDatasetMessagesToGlobalStore(t)})))}syncDatasetMessagesToGlobalStore(e){const t=e.toInboxDataset();for(const i of t.messages)this._globalMessages.has(i.messageId)||this._globalMessages.set(i.messageId,i)}async fetchNextPageOfMessages(i){var n;const o=t.Courier.shared.client;if(!(null==o?void 0:o.options.userId))throw new Error("User is not signed in");let s;if(i.feedType&&!i.datasetId)null==(n=t.Courier.shared.client)||n.options.logger.warn(`[${e.TAG}] feedType is deprecated andwill be removed in the next major version. Please update callers to use datasetIds.`),s=i.feedType;else{if(!i.datasetId)throw new Error(`[${e.TAG}] Exactly one of feedType or datasetId is required to call fetchNextPageOfMessages.`);s=i.datasetId}const l=this._datasets.get(s);if(!l)throw new Error(`[${e.TAG}] Attempted to fetch next page of messages for dataset ${s}, but the dataset does not exist.`);return this.fetchNextPageForDataset({dataset:l})}getDatasetById(e){var t;return null==(t=this._datasets.get(e))?void 0:t.toInboxDataset()}getDatasets(){const e={};for(const[t,i]of this._datasets.entries())e[t]=i.toInboxDataset();return e}get totalUnreadCount(){let e=0;for(let t of this._datasets.values())e+=t.totalUnreadCount;return e}async fetchNextPageForDataset(e){const t=await e.dataset.fetchNextPageOfMessages();return t&&this.syncDatasetMessagesToGlobalStore(e.dataset),t}handleMessageEvent(i){var n,o;const s=i.event;if(s===t.InboxMessageEvent.NewMessage){const e=i.data;this._globalMessages.set(e.messageId,e);for(let t of this._datasets.values())t.addMessage(e);return}if(s===t.InboxMessageEvent.ArchiveAll||s===t.InboxMessageEvent.ArchiveRead||s===t.InboxMessageEvent.MarkAllRead)return void this.updateAllMessages(s);const l=i.messageId;l?this.updateMessage(l,s):null==(o=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||o.warn(`[${e.TAG}] Received unexpected event: ${s}`)}updateAllMessages(i){const n=e.getISONow();for(const[e,o]of this._globalMessages.entries()){let l=null;switch(i){case t.InboxMessageEvent.MarkAllRead:o.read||(l=s(o),l.read=n);break;case t.InboxMessageEvent.ArchiveAll:o.archived||(l=s(o),l.archived=n);break;case t.InboxMessageEvent.ArchiveRead:o.read&&!o.archived&&(l=s(o),l.archived=n)}l&&(this._globalMessages.set(e,l),this.updateDatasetsWithMessageChange(o,l))}}updateMessage(i,n){const o=this._globalMessages.get(i);if(!o)return;let l;switch(n){case t.InboxMessageEvent.Archive:l=s(o),l.archived=e.getISONow();break;case t.InboxMessageEvent.Opened:l=s(o),l.opened=e.getISONow();break;case t.InboxMessageEvent.Read:l=s(o),l.read=e.getISONow();break;case t.InboxMessageEvent.Unarchive:l=s(o),l.archived=void 0;break;case t.InboxMessageEvent.Unread:l=s(o),l.read=void 0;break;case t.InboxMessageEvent.Clicked:case t.InboxMessageEvent.Unopened:default:return}this._globalMessages.set(i,l),this.updateDatasetsWithMessageChange(o,l)}clearDatasets(){this._datasets.clear(),this._globalMessages.clear()}static getISONow(){return(new Date).toISOString()}createDatastoreSnapshot(){const e=[];for(const[i,n]of this._datasets.entries()){const t=n.toInboxDataset();if(t){const n=l(t);n&&e.push({id:i,dataset:n})}}const t=new Map;for(const[i,n]of this._globalMessages.entries())t.set(i,s(n));return{datasets:e,globalMessages:t}}restoreDatastoreSnapshot(e){this._globalMessages.clear();for(const[t,i]of e.globalMessages.entries())this._globalMessages.set(t,s(i));for(const t of e.datasets){const e=this._datasets.get(t.id);e&&e.restoreFromSnapshot(t.dataset)}}async executeWithRollback(i){var n,o;const s=this.createDatastoreSnapshot();try{return await i()}catch(l){null==(o=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||o.error(`[${e.TAG}] Error during operation:`,l),this.restoreDatastoreSnapshot(s),this._listeners.forEach((e=>{var t,i;null==(i=(t=e.events).onError)||i.call(t,l)}))}}static get shared(){return e.instance||(e.instance=new e),e.instance}};o(d,"TAG","CourierInboxDatastore"),o(d,"instance");let u=d;class h extends i.CourierBaseElement{constructor(e,t,i,n){super(),o(this,"_themeManager"),o(this,"_theme"),o(this,"_message",null),o(this,"_isMobile",!1),o(this,"_canClick",!1),o(this,"_listItemActions",B.defaultListItemActions()),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,"_observer"),o(this,"onItemClick",null),o(this,"onItemLongPress",null),o(this,"onItemActionClick",null),o(this,"onItemVisible",null),this._canClick=t,this._themeManager=e,this._theme=e.getTheme(),this._isMobile="ontouchstart"in window,n&&(this._listItemActions=n),this.render(),this._setupIntersectionObserver()}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 r(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._canClick&&(this._menu&&(this._menu.contains(e.target)||e.composedPath().includes(this._menu))||!this._message||!this.onItemClick||e.target instanceof i.CourierIcon||this._isLongPress||this.onItemClick(this._message))})),this._setupHoverBehavior(),this._setupLongPressBehavior(),this._canClick&&this.classList.add("clickable")}_setupIntersectionObserver(){"undefined"!=typeof window&&"undefined"!=typeof IntersectionObserver&&(this._observer&&this._observer.disconnect(),this._observer=new IntersectionObserver((e=>{e.forEach((e=>{1===e.intersectionRatio&&this.onItemVisible&&this._message&&this.onItemVisible(this._message)}))}),{threshold:1}),this._observer.observe(this))}onComponentUnmounted(){var e;null==(e=this._observer)||e.disconnect()}static getStyles(e){var t,i,n,o,s,l,r,a,d,u,c,v,g,p,m,b,_,C,f,x,y,I,k,w,M,S,T;const $=null==(t=e.inbox)?void 0:t.list;return`\n ${h.id} {\n display: flex;\n flex-direction: row;\n align-items: flex-start;\n justify-content: space-between;\n border-bottom: ${(null==(i=null==$?void 0:$.item)?void 0:i.divider)??"1px solid red"};\n font-family: inherit;\n cursor: default;\n transition: ${(null==(n=null==$?void 0:$.item)?void 0:n.transition)??"all 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==(o=null==$?void 0:$.item)?void 0:o.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 /* Only apply hover/active background if clickable */\n @media (hover: hover) {\n ${h.id}.clickable:hover {\n cursor: pointer;\n background-color: ${(null==(s=null==$?void 0:$.item)?void 0:s.hoverBackgroundColor)??"red"};\n }\n }\n\n ${h.id}.clickable:active {\n cursor: pointer;\n background-color: ${(null==(l=null==$?void 0:$.item)?void 0:l.activeBackgroundColor)??"red"};\n }\n\n /* Menu hover / active */\n @media (hover: hover) {\n ${h.id}.clickable:hover:has(courier-inbox-list-item-menu:hover, courier-inbox-list-item-menu *:hover, courier-button:hover, courier-button *:hover) {\n background-color: ${(null==(r=null==$?void 0:$.item)?void 0:r.backgroundColor)??"transparent"};\n }\n }\n\n ${h.id}.clickable:active:has(courier-inbox-list-item-menu:active, courier-inbox-list-item-menu *:active, courier-button:active, courier-button *:active) {\n background-color: ${(null==(a=null==$?void 0:$.item)?void 0:a.backgroundColor)??"transparent"};\n }\n\n ${h.id}:last-child {\n border-bottom: none;\n }\n\n ${h.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==(d=null==$?void 0:$.item)?void 0:d.unreadIndicatorColor)??"red"};\n display: none;\n }\n\n ${h.id}.unread .unread-indicator {\n display: block;\n }\n\n ${h.id} .content-container {\n flex: 1;\n display: flex;\n flex-direction: column;\n margin-right: 12px;\n }\n\n ${h.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 ${h.id} .title {\n font-family: ${(null==(c=null==(u=null==$?void 0:$.item)?void 0:u.title)?void 0:c.family)??"inherit"};\n font-size: ${(null==(g=null==(v=null==$?void 0:$.item)?void 0:v.title)?void 0:g.size)??"14px"};\n color: ${(null==(m=null==(p=null==$?void 0:$.item)?void 0:p.title)?void 0:m.color)??"red"};\n margin-bottom: 4px;\n }\n\n ${h.id} .subtitle {\n font-family: ${(null==(_=null==(b=null==$?void 0:$.item)?void 0:b.subtitle)?void 0:_.family)??"inherit"};\n font-size: ${(null==(f=null==(C=null==$?void 0:$.item)?void 0:C.subtitle)?void 0:f.size)??"14px"};\n color: ${(null==(y=null==(x=null==$?void 0:$.item)?void 0:x.subtitle)?void 0:y.color)??"red"};\n }\n\n ${h.id} .time {\n font-family: ${(null==(k=null==(I=null==$?void 0:$.item)?void 0:I.time)?void 0:k.family)??"inherit"};\n font-size: ${(null==(M=null==(w=null==$?void 0:$.item)?void 0:w.time)?void 0:M.size)??"14px"};\n color: ${(null==(T=null==(S=null==$?void 0:$.item)?void 0:S.time)?void 0:T.color)??"red"};\n text-align: right;\n white-space: nowrap;\n }\n\n ${h.id} courier-inbox-list-item-menu {\n z-index: 1;\n position: absolute;\n top: 8px;\n right: 8px;\n display: none;\n opacity: 0;\n transition: opacity 0.2s ease;\n }\n\n ${h.id} courier-inbox-list-item-menu.visible {\n opacity: 1;\n }\n\n /* Show menu on hover for non-mobile devices - CSS handles this reliably */\n @media (hover: hover) {\n ${h.id}.clickable:hover courier-inbox-list-item-menu {\n display: block;\n }\n ${h.id}.clickable:hover courier-inbox-list-item-menu.visible {\n display: block;\n }\n ${h.id}.clickable:hover .time {\n opacity: 0;\n transition: opacity 0.2s ease;\n }\n }\n\n ${h.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;const e=this._getMenuOptions();e.length>0&&this._menu&&(this._menu.setOptions(e),this._menu.show(),this._timeElement&&(this._timeElement.style.opacity="0"))})),this.addEventListener("mouseleave",(()=>{this._menu&&this._menu.hide(),this._timeElement&&(this._timeElement.style.opacity="1")})))}_setupLongPressBehavior(){var e,t,i;const n=null==(i=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:i.menu;if(!(null==n?void 0:n.enabled))return;const o=n.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)}))}_getMenuOptions(){var e,t,n,o,s,l,r,a,d,h,c,v,g,p,m,b;const _=null==(o=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.menu)?void 0:o.item;let C=[];const f=!!(null==(s=this._message)?void 0:s.archived);for(const x of this._listItemActions)switch(x.id){case"read_unread":C.push({id:(null==(l=this._message)?void 0:l.read)?"unread":"read",icon:{svg:(null==(r=this._message)?void 0:r.read)?x.unreadIconSVG??(null==(a=null==_?void 0:_.unread)?void 0:a.svg)??i.CourierIconSVGs.unread:x.readIconSVG??(null==(d=null==_?void 0:_.read)?void 0:d.svg)??i.CourierIconSVGs.read,color:(null==(h=this._message)?void 0:h.read)?null==(c=null==_?void 0:_.unread)?void 0:c.color:(null==(v=null==_?void 0:_.read)?void 0:v.color)??"red"},onClick:()=>{this._message&&(this._message.read?u.shared.unreadMessage({message:this._message}):u.shared.readMessage({message:this._message}))}});break;case"archive_unarchive":C.push({id:f?"unarchive":"archive",icon:{svg:f?x.unarchiveIconSVG??(null==(g=null==_?void 0:_.unarchive)?void 0:g.svg)??i.CourierIconSVGs.unarchive:x.archiveIconSVG??(null==(p=null==_?void 0:_.archive)?void 0:p.svg)??i.CourierIconSVGs.archive,color:f?null==(m=null==_?void 0:_.unarchive)?void 0:m.color:(null==(b=null==_?void 0:_.archive)?void 0:b.color)??"red"},onClick:()=>{this._message&&(f?u.shared.unarchiveMessage({message:this._message}):u.shared.archiveMessage({message:this._message}))}})}return C}_showMenu(){var e,t,i;const n=null==(i=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:i.menu,o=this._getMenuOptions();0!==o.length&&n&&n.enabled&&this._menu&&this._timeElement&&(this._menu.setOptions(o),this._menu.show(),this._timeElement.style.opacity="0")}_hideMenu(){var e,t,i;const n=null==(i=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:i.menu;n&&n.enabled&&this._menu&&this._timeElement&&(this._menu.hide(),this._timeElement.style.opacity="1")}setMessage(e){this._message=e,this._updateContent()}setOnItemClick(e){this.onItemClick=e}setOnItemActionClick(e){this.onItemActionClick=e}setOnItemLongPress(e){this.onItemLongPress=e}setOnItemVisible(e){this.onItemVisible=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),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,i=new Date(e.created),n=Math.floor((t.getTime()-i.getTime())/1e3);return n<5?"Now":n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:n<604800?`${Math.floor(n/86400)}d`:n<31536e3?`${Math.floor(n/604800)}w`:`${Math.floor(n/31536e3)}y`}(this._message)),this._menu&&this._menu.setOptions(this._getMenuOptions());const o=this._message.actions&&this._message.actions.length>0;this._actionsContainer&&(this._actionsContainer.style.display=o?"flex":"none");const s=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._actionsContainer.innerHTML="",this._message.actions.forEach((e=>{var t,n,o,l,r;const a=new i.CourierButton({mode:this._themeManager.mode,text:e.content,variant:"secondary",backgroundColor:null==s?void 0:s.backgroundColor,hoverBackgroundColor:null==s?void 0:s.hoverBackgroundColor,activeBackgroundColor:null==s?void 0:s.activeBackgroundColor,border:null==s?void 0:s.border,borderRadius:null==s?void 0:s.borderRadius,shadow:null==s?void 0:s.shadow,fontFamily:null==(t=null==s?void 0:s.font)?void 0:t.family,fontSize:null==(n=null==s?void 0:s.font)?void 0:n.size,fontWeight:null==(o=null==s?void 0:s.font)?void 0:o.weight,textColor:null==(l=null==s?void 0:s.font)?void 0:l.color,onClick:()=>{this._message&&this.onItemActionClick&&this.onItemActionClick(this._message,e)}});null==(r=this._actionsContainer)||r.appendChild(a)})))}}i.registerElement(h);class c extends i.CourierBaseElement{constructor(e){super(),o(this,"_theme"),o(this,"_style"),this._theme=e}static get id(){return"courier-inbox-skeleton-list-item"}onComponentMounted(){this._style=i.injectGlobalStyle(c.id,c.getStyles(this._theme)),this.render()}onComponentUnmounted(){var e;null==(e=this._style)||e.remove()}render(){const e=new v(this._theme),t=new v(this._theme),i=new v(this._theme);this.appendChild(e),this.appendChild(t),this.appendChild(i)}static getStyles(e){return`\n ${c.id} {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px 20px 16px 20px;\n width: 100%;\n box-sizing: border-box;\n }\n\n ${c.id} > *:first-child {\n width: 35%;\n }\n\n ${c.id} > *:nth-child(2) {\n width: 100%;\n }\n\n ${c.id} > *:nth-child(3) {\n width: 82%;\n }\n `}}i.registerElement(c);class v extends i.CourierBaseElement{constructor(e){super(),o(this,"_theme"),o(this,"_style"),this._theme=e}static get id(){return"courier-skeleton-animated-row"}onComponentMounted(){this._style=i.injectGlobalStyle(v.id,v.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,i,n,o,s,l,r,a,d,u,h,c;const g=(null==(n=null==(i=null==(t=e.inbox)?void 0:t.loading)?void 0:i.animation)?void 0:n.barColor)??"#000",p=4===g.length?`#${g[1]}${g[1]}${g[2]}${g[2]}${g[3]}${g[3]}`:g,m=parseInt(p.slice(1,3),16),b=parseInt(p.slice(3,5),16),_=parseInt(p.slice(5,7),16),C=`rgba(${m}, ${b}, ${_}, 0.8)`,f=`rgba(${m}, ${b}, ${_}, 0.4)`;return`\n ${v.id} {\n display: flex;\n height: 100%;\n width: 100%;\n align-items: flex-start;\n justify-content: flex-start;\n }\n\n ${v.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 ${C} 25%,\n ${f} 50%,\n ${C} 75%\n );\n background-size: 200% 100%;\n animation: ${v.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 ${v.id}-shimmer {\n 0% {\n background-position: 200% 0;\n }\n 100% {\n background-position: -200% 0;\n }\n }\n `}}i.registerElement(v);class g extends i.CourierFactoryElement{constructor(e){super(),o(this,"_theme"),o(this,"_style"),this._theme=e}static get id(){return"courier-inbox-skeleton-list"}onComponentMounted(){this._style=i.injectGlobalStyle(g.id,g.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 c(this._theme);e.appendChild(t)}return this.appendChild(e),e}static getStyles(e){var t,i,n,o;return`\n ${g.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 ${g.id} .list {\n display: flex;\n flex-direction: column;\n width: 100%;\n overflow: hidden;\n }\n\n ${g.id} .list > * {\n border-bottom: ${(null==(i=null==(t=e.inbox)?void 0:t.loading)?void 0:i.divider)??"1px solid red"};\n opacity: 100%;\n }\n\n ${g.id} .list > *:nth-child(2) {\n border-bottom: ${(null==(o=null==(n=e.inbox)?void 0:n.loading)?void 0:o.divider)??"1px solid red"};\n opacity: 88%;\n }\n\n ${g.id} .list > *:nth-child(3) {\n border-bottom: none;\n opacity: 50%;\n }\n `}}i.registerElement(g);class p extends i.CourierBaseElement{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=i.injectGlobalStyle(p.id,p.getStyles(this._theme)),this._customItem)this.appendChild(this._customItem);else{const e=document.createElement("div");e.className="skeleton-container",this._skeletonLoadingList=new g(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 ${p.id} {\n padding: 0;\n margin: 0;\n box-sizing: border-box;\n }\n\n ${p.id} .skeleton-container {\n height: 150%;\n }\n `}}function m(e){return u.shared.openMessage({message:e})}function b(){return[{feedId:"inbox_feed",title:"Inbox",iconSVG:i.CourierIconSVGs.inbox,tabs:[{datasetId:"all_messages",title:"All Messages",filter:{}}]},{feedId:"archive_feed",title:"Archive",iconSVG:i.CourierIconSVGs.archive,tabs:[{datasetId:"archived_messages",title:"Archived Messages",filter:{archived:!0}}]}]}function _(){return[{id:"readAll"},{id:"archiveRead"},{id:"archiveAll"}]}function C(){return[{id:"read_unread"},{id:"archive_unarchive"}]}i.registerElement(p);class f extends i.CourierBaseElement{constructor(e){super(),o(this,"_themeSubscription"),o(this,"_messages",[]),o(this,"_datasetId",b()[0].tabs[0].datasetId),o(this,"_isLoading",!0),o(this,"_error",null),o(this,"_canPaginate",!1),o(this,"_canClickListItems",!1),o(this,"_canLongPressListItems",!1),o(this,"_listItemActions",B.defaultListItemActions()),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"),o(this,"_errorContainer"),o(this,"_emptyContainer"),this._onRefresh=e.onRefresh,this._onPaginationTrigger=e.onPaginationTrigger,this._onMessageClick=e.onMessageClick,this._onMessageActionClick=e.onMessageActionClick,this._onMessageLongPress=e.onMessageLongPress,e.listItemActions&&(this._listItemActions=e.listItemActions),this._themeSubscription=e.themeManager.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-inbox-list"}get messages(){return this._messages}get theme(){return this._themeSubscription.manager.getTheme()}onComponentMounted(){this._listStyles=i.injectGlobalStyle(f.id,f.getStyles(this.theme)),this._listItemStyles=i.injectGlobalStyle(h.id,h.getStyles(this.theme)),this._listItemMenuStyles=i.injectGlobalStyle(r.id,r.getStyles(this.theme)),this.render()}onComponentUnmounted(){var e,t,i;this._themeSubscription.unsubscribe(),null==(e=this._listStyles)||e.remove(),null==(t=this._listItemStyles)||t.remove(),null==(i=this._listItemMenuStyles)||i.remove()}setCanClickListItems(e){this._canClickListItems=e}setCanLongPressListItems(e){this._canLongPressListItems=e}setListItemActions(e){this._listItemActions=e,this.render()}static getStyles(e){var t;const i=null==(t=e.inbox)?void 0:t.list,n=null==i?void 0:i.scrollbar;return`\n ${f.id} {\n flex: 1;\n width: 100%;\n background-color: ${(null==i?void 0:i.backgroundColor)??"red"};\n scrollbar-width: ${(null==n?void 0:n.width)??"thin"};\n scrollbar-color: ${(null==n?void 0:n.thumbColor)??"rgba(0, 0, 0, 0.2)"} ${(null==n?void 0:n.trackBackgroundColor)??"transparent"};\n }\n\n ${f.id} ul {\n list-style: none;\n padding: 0;\n margin: 0;\n height: 100%;\n }\n\n /* Webkit scrollbar styling - show thumb, hide track background, overlay above content */\n ${f.id}::-webkit-scrollbar {\n width: ${(null==n?void 0:n.width)??"8px"};\n height: ${(null==n?void 0:n.height)??"8px"};\n }\n\n ${f.id}::-webkit-scrollbar-track {\n background: ${(null==n?void 0:n.trackBackgroundColor)??"transparent"};\n }\n\n ${f.id}::-webkit-scrollbar-thumb {\n background: ${(null==n?void 0:n.thumbColor)??"rgba(0, 0, 0, 0.2)"};\n border-radius: ${(null==n?void 0:n.borderRadius)??"4px"};\n }\n\n ${f.id}::-webkit-scrollbar-thumb:hover {\n background: ${(null==n?void 0:n.thumbHoverColor)??(null==n?void 0:n.thumbColor)??"rgba(0, 0, 0, 0.3)"};\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()}selectDataset(e){this._datasetId=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()}refreshTheme(){this._listStyles&&(this._listStyles.textContent=f.getStyles(this.theme)),this._listItemStyles&&(this._listItemStyles.textContent=h.getStyles(this.theme)),this._listItemMenuStyles&&(this._listItemMenuStyles.textContent=r.getStyles(this.theme)),this.refreshInfoStateThemes()}refreshInfoStateThemes(){var e,t;null==(e=this._emptyContainer)||e.updateStyles(this.errorProps),null==(t=this._emptyContainer)||t.updateStyles(this.emptyProps)}get errorProps(){var e,t,i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f,x,y,I,k,w;const M=null==(e=this.theme.inbox)?void 0:e.error,S=this._themeSubscription.manager.mode;return{title:{text:(null==(t=null==M?void 0:M.title)?void 0:t.text)??(null==(i=this._error)?void 0:i.message),textColor:null==(o=null==(n=null==M?void 0:M.title)?void 0:n.font)?void 0:o.color,fontFamily:null==(l=null==(s=null==M?void 0:M.title)?void 0:s.font)?void 0:l.family,fontSize:null==(a=null==(r=null==M?void 0:M.title)?void 0:r.font)?void 0:a.size,fontWeight:null==(u=null==(d=null==M?void 0:M.title)?void 0:d.font)?void 0:u.weight},button:{mode:S,text:null==(h=null==M?void 0:M.button)?void 0:h.text,backgroundColor:null==(c=null==M?void 0:M.button)?void 0:c.backgroundColor,hoverBackgroundColor:null==(v=null==M?void 0:M.button)?void 0:v.hoverBackgroundColor,activeBackgroundColor:null==(g=null==M?void 0:M.button)?void 0:g.activeBackgroundColor,textColor:null==(m=null==(p=null==M?void 0:M.button)?void 0:p.font)?void 0:m.color,fontFamily:null==(_=null==(b=null==M?void 0:M.button)?void 0:b.font)?void 0:_.family,fontSize:null==(f=null==(C=null==M?void 0:M.button)?void 0:C.font)?void 0:f.size,fontWeight:null==(y=null==(x=null==M?void 0:M.button)?void 0:x.font)?void 0:y.weight,shadow:null==(I=null==M?void 0:M.button)?void 0:I.shadow,border:null==(k=null==M?void 0:M.button)?void 0:k.border,borderRadius:null==(w=null==M?void 0:M.button)?void 0:w.borderRadius,onClick:()=>this.handleRetry()}}}get emptyProps(){var e,t,i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f,x,y,I,k;const w=null==(e=this.theme.inbox)?void 0:e.empty,M=this._themeSubscription.manager.mode;return{title:{text:(null==(t=null==w?void 0:w.title)?void 0:t.text)??"No Messages",textColor:null==(n=null==(i=null==w?void 0:w.title)?void 0:i.font)?void 0:n.color,fontFamily:null==(s=null==(o=null==w?void 0:w.title)?void 0:o.font)?void 0:s.family,fontSize:null==(r=null==(l=null==w?void 0:w.title)?void 0:l.font)?void 0:r.size,fontWeight:null==(d=null==(a=null==w?void 0:w.title)?void 0:a.font)?void 0:d.weight},button:{mode:M,text:null==(u=null==w?void 0:w.button)?void 0:u.text,backgroundColor:null==(h=null==w?void 0:w.button)?void 0:h.backgroundColor,hoverBackgroundColor:null==(c=null==w?void 0:w.button)?void 0:c.hoverBackgroundColor,activeBackgroundColor:null==(v=null==w?void 0:w.button)?void 0:v.activeBackgroundColor,textColor:null==(p=null==(g=null==w?void 0:w.button)?void 0:g.font)?void 0:p.color,fontFamily:null==(b=null==(m=null==w?void 0:w.button)?void 0:m.font)?void 0:b.family,fontSize:null==(C=null==(_=null==w?void 0:w.button)?void 0:_.font)?void 0:C.size,fontWeight:null==(x=null==(f=null==w?void 0:w.button)?void 0:f.font)?void 0:x.weight,shadow:null==(y=null==w?void 0:w.button)?void 0:y.shadow,border:null==(I=null==w?void 0:w.button)?void 0:I.border,borderRadius:null==(k=null==w?void 0:w.button)?void 0:k.borderRadius,onClick:()=>this.handleRefresh()}}}render(){for(var e,t,n,o;this.firstChild;)this.removeChild(this.firstChild),this._errorContainer=void 0,this._emptyContainer=void 0;if(this.refreshTheme(),this._error)return this._errorContainer=new i.CourierInfoState(this.errorProps),this._errorContainer.build(null==(e=this._errorStateFactory)?void 0:e.call(this,{datasetId:this._datasetId,error:this._error})),void this.appendChild(this._errorContainer);if(this._isLoading){const e=new g(this.theme);return e.build(null==(t=this._loadingStateFactory)?void 0:t.call(this,{datasetId:this._datasetId})),void this.appendChild(e)}if(0===this._messages.length)return this._emptyContainer=new i.CourierInfoState(this.emptyProps),this._emptyContainer.build(null==(n=this._emptyStateFactory)?void 0:n.call(this,{datasetId:this._datasetId})),void this.appendChild(this._emptyContainer);const s=document.createElement("ul");if(this.appendChild(s),this._messages.forEach(((e,t)=>{if(this._listItemFactory)return void s.appendChild(this._listItemFactory({message:e,index:t}));const i=new h(this._themeSubscription.manager,this._canClickListItems,this._canLongPressListItems,this._listItemActions);i.setMessage(e),i.setOnItemClick((e=>{var i;return null==(i=this._onMessageClick)?void 0:i.call(this,e,t)})),i.setOnItemActionClick(((e,i)=>{var n;return null==(n=this._onMessageActionClick)?void 0:n.call(this,e,i,t)})),i.setOnItemLongPress((e=>{var i;return null==(i=this._onMessageLongPress)?void 0:i.call(this,e,t)})),i.setOnItemVisible((e=>this.openVisibleMessage(e))),s.appendChild(i)})),this._canPaginate){const e=new p({theme:this.theme,customItem:null==(o=this._paginationItemFactory)?void 0:o.call(this,{datasetId:this._datasetId}),onPaginationTrigger:()=>{var e;return null==(e=this._onPaginationTrigger)?void 0:e.call(this,this._datasetId)}});s.appendChild(e)}}async openVisibleMessage(e){try{await m(e)}catch(t){}}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()}scrollToTop(e=!0){this.scrollTo({top:0,behavior:e?"smooth":"instant"})}}i.registerElement(f);class x extends i.CourierBaseElement{constructor(e){super(),o(this,"_themeSubscription"),o(this,"_location"),o(this,"_count",0),o(this,"_style"),o(this,"_shadowRoot"),o(this,"_container"),this._location=e.location,this._themeSubscription=e.themeBus.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-unread-count-badge"}get theme(){return this._themeSubscription.manager.getTheme()}onComponentMounted(){this.attachElements(),this.setActive(!0),this.updateBadge()}attachElements(){this._shadowRoot=this.attachShadow({mode:"closed"}),this._container=document.createElement("div"),this._container.className="badge-container",this._style=document.createElement("style"),this._style.textContent=this.getStyles(),this._shadowRoot.appendChild(this._style),this._shadowRoot.appendChild(this._container)}onComponentUnmounted(){this._themeSubscription.unsubscribe()}static getThemePath(e,t,i){var n,o,s,l,r,a,d,u;if("tab"===t){const t=null==(o=null==(n=e.inbox)?void 0:n.header)?void 0:o.tabs;return i?null==(s=null==t?void 0:t.selected)?void 0:s.unreadIndicator:null==(l=null==t?void 0:t.default)?void 0:l.unreadIndicator}return null==(u=null==(d=null==(a=null==(r=e.inbox)?void 0:r.header)?void 0:a.feeds)?void 0:d.button)?void 0:u.unreadCountIndicator}static getStyles(e,t="feed"){var i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f,y;const I=x.getThemePath(e,t,!0),k=x.getThemePath(e,t,!1),w=null==(s=null==(o=null==(n=null==(i=e.inbox)?void 0:i.header)?void 0:n.feeds)?void 0:o.button)?void 0:s.unreadCountIndicator;return`\n :host {\n display: inline-block;\n }\n\n .badge-container {\n display: none;\n pointer-events: none;\n }\n\n :host(.active) .badge-container {\n display: inline-block;\n background-color: ${(null==I?void 0:I.backgroundColor)??(null==w?void 0:w.backgroundColor)};\n color: ${(null==(l=null==I?void 0:I.font)?void 0:l.color)??(null==(r=null==w?void 0:w.font)?void 0:r.color)};\n border-radius: ${(null==I?void 0:I.borderRadius)??(null==w?void 0:w.borderRadius)};\n font-size: ${(null==(a=null==I?void 0:I.font)?void 0:a.size)??(null==(d=null==w?void 0:w.font)?void 0:d.size)};\n font-family: ${(null==(u=null==I?void 0:I.font)?void 0:u.family)??(null==(h=null==w?void 0:w.font)?void 0:h.family)??"inherit"};\n font-weight: ${(null==(c=null==I?void 0:I.font)?void 0:c.weight)??(null==(v=null==w?void 0:w.font)?void 0:v.weight)??"inherit"};\n padding: ${(null==I?void 0:I.padding)??(null==w?void 0:w.padding)};\n }\n\n :host(.inactive) .badge-container {\n display: inline-block;\n background-color: ${(null==k?void 0:k.backgroundColor)??(null==w?void 0:w.backgroundColor)};\n color: ${(null==(g=null==k?void 0:k.font)?void 0:g.color)??(null==(p=null==w?void 0:w.font)?void 0:p.color)};\n border-radius: ${(null==k?void 0:k.borderRadius)??(null==w?void 0:w.borderRadius)};\n font-size: ${(null==(m=null==k?void 0:k.font)?void 0:m.size)??(null==(b=null==w?void 0:w.font)?void 0:b.size)};\n font-family: ${(null==(_=null==k?void 0:k.font)?void 0:_.family)??(null==(C=null==w?void 0:w.font)?void 0:C.family)??"inherit"};\n font-weight: ${(null==(f=null==k?void 0:k.font)?void 0:f.weight)??(null==(y=null==w?void 0:w.font)?void 0:y.weight)??"inherit"};\n padding: ${(null==k?void 0:k.padding)??(null==w?void 0:w.padding)};\n }\n `}getStyles(){return x.getStyles(this.theme,this._location)}setCount(e){this._count=e,this.updateBadge()}setActive(e){this.className=e?"active":"inactive",this._style&&(this._style.textContent=this.getStyles()),this.updateBadge()}refreshTheme(){this._style&&(this._style.textContent=this.getStyles()),this.updateBadge()}updateBadge(){this._container&&(this._count>0?(this.style.display="inline-block",this._container.textContent=this._count>99?"99+":this._count.toString()):(this.style.display="none",this._container.textContent=""))}}i.registerElement(x);class y extends i.CourierBaseElement{constructor(e,t){super(),o(this,"_themeSubscription"),o(this,"_feeds"),o(this,"_selectedFeed"),o(this,"_style"),o(this,"_iconElement"),o(this,"_titleElement"),o(this,"_switchIconElement"),o(this,"_unreadBadge"),this._feeds=t,this._themeSubscription=e.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-inbox-header-title"}get selectedFeed(){return this._selectedFeed}get theme(){return this._themeSubscription.manager.getTheme()}getStyles(e){var t,i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f,x,I,k,w,M,S,T,$,E,L,B,F;const A=this._feeds.length>1,P=A?`${y.id}:hover {\n background: ${(null==(o=null==(n=null==(i=null==(t=e.inbox)?void 0:t.header)?void 0:i.feeds)?void 0:n.button)?void 0:o.hoverBackgroundColor)??"red"};\n }`:"",R=A?`${y.id}:active {\n background: ${(null==(a=null==(r=null==(l=null==(s=e.inbox)?void 0:s.header)?void 0:l.feeds)?void 0:r.button)?void 0:a.activeBackgroundColor)??"red"};\n }`:"";return`\n ${y.id} {\n display: flex;\n align-items: center;\n gap: 8px;\n position: relative;\n transition: ${(null==(c=null==(h=null==(u=null==(d=e.inbox)?void 0:d.header)?void 0:u.feeds)?void 0:h.button)?void 0:c.transition)??"all 0.2s ease"};\n border-radius: 6px;\n padding-top: 4px;\n padding-bottom: 4px;\n padding-left: 4px;\n padding-right: 8px;\n }\n\n ${P}\n\n ${R}\n\n ${y.id} courier-icon {\n display: flex;\n align-items: center;\n }\n\n ${y.id} .title-container {\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 0px;\n }\n\n ${y.id} .title-container h2 {\n margin: 0;\n font-family: ${(null==(b=null==(m=null==(p=null==(g=null==(v=e.inbox)?void 0:v.header)?void 0:g.feeds)?void 0:p.button)?void 0:m.font)?void 0:b.family)??"inherit"};\n font-size: ${(null==(I=null==(x=null==(f=null==(C=null==(_=e.inbox)?void 0:_.header)?void 0:C.feeds)?void 0:f.button)?void 0:x.font)?void 0:I.size)??"16px"};\n font-weight: ${(null==(T=null==(S=null==(M=null==(w=null==(k=e.inbox)?void 0:k.header)?void 0:w.feeds)?void 0:M.button)?void 0:S.font)?void 0:T.weight)??"500"};\n color: ${(null==(F=null==(B=null==(L=null==(E=null==($=e.inbox)?void 0:$.header)?void 0:E.feeds)?void 0:L.button)?void 0:B.font)?void 0:F.color)??"red"};\n }\n\n `}onComponentMounted(){this.render()}onComponentUnmounted(){var e;this._themeSubscription.unsubscribe(),null==(e=this._style)||e.remove()}render(){var e,t,n,o;this._style=i.injectGlobalStyle(y.id,this.getStyles(this.theme)),this._iconElement=new i.CourierIcon,this.appendChild(this._iconElement);const s=document.createElement("div");s.className="title-container",this._titleElement=document.createElement("h2"),s.appendChild(this._titleElement);const l=null==(o=null==(n=null==(t=null==(e=this.theme.inbox)?void 0:e.header)?void 0:t.feeds)?void 0:n.button)?void 0:o.changeFeedIcon;this._switchIconElement=new i.CourierIcon((null==l?void 0:l.color)??"red",(null==l?void 0:l.svg)??i.CourierIconSVGs.chevronDown),this._switchIconElement.style.display=this._feeds.length>1?"flex":"none",s.appendChild(this._switchIconElement),this.appendChild(s),this._unreadBadge=new x({themeBus:this._themeSubscription.manager,location:"feed"}),this.appendChild(this._unreadBadge),this.refreshTheme()}setUnreadCount(e){var t;null==(t=this._unreadBadge)||t.setCount(e)}setFeeds(e){this._feeds=e,this._switchIconElement&&(this._switchIconElement.style.display=this._feeds.length>1?"flex":"none"),this.refreshTheme()}setSelectedFeed(e){this._selectedFeed=this._feeds.find((t=>t.feedId===e)),this.refreshSelectedFeed()}refreshTheme(){this._style&&(this._style.textContent=this.getStyles(this.theme)),this.refreshSelectedFeed(),this.refreshSwitchIcon(),this.refreshUnreadBadge()}refreshSelectedFeed(){var e,t,n,o,s,l;this._selectedFeed&&(null==(e=this._iconElement)||e.updateSVG(this._selectedFeed.iconSVG??i.CourierIconSVGs.inbox),null==(l=this._iconElement)||l.updateColor((null==(s=null==(o=null==(n=null==(t=this.theme.inbox)?void 0:t.header)?void 0:n.feeds)?void 0:o.button)?void 0:s.selectedFeedIconColor)??"red"),this._titleElement&&(this._titleElement.textContent=this._selectedFeed.title))}refreshSwitchIcon(){var e,t,n,o;if(this._switchIconElement){const s=null==(o=null==(n=null==(t=null==(e=this.theme.inbox)?void 0:e.header)?void 0:t.feeds)?void 0:n.button)?void 0:o.changeFeedIcon;this._switchIconElement.updateSVG((null==s?void 0:s.svg)??i.CourierIconSVGs.chevronDown),this._switchIconElement.updateColor((null==s?void 0:s.color)??"red")}}refreshUnreadBadge(){this._unreadBadge&&this._unreadBadge.refreshTheme()}}i.registerElement(y);class I extends i.CourierBaseElement{constructor(e){super(),o(this,"_themeManager"),o(this,"_themeSubscription"),o(this,"_selectedTabId"),o(this,"_tabs",[]),o(this,"_onTabClick"),o(this,"_onTabReselected"),o(this,"_tabBadges",new Map),o(this,"_style"),this._themeManager=e.themeManager,this._onTabClick=e.onTabClick,this._onTabReselected=e.onTabReselected,this._themeSubscription=e.themeManager.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-inbox-tabs"}get theme(){return this._themeSubscription.manager.getTheme()}onComponentMounted(){this._style=i.injectGlobalStyle(I.id,I.getStyles(this.theme)),this.render()}onComponentUnmounted(){var e;this._themeSubscription.unsubscribe(),null==(e=this._style)||e.remove()}render(){this.innerHTML="";const e=document.createElement("div");e.className="tab-container";for(let t of this._tabs){const i=this.createTab(t);e.appendChild(i)}this.appendChild(e),this.refreshTheme()}static getStyles(e){var t,i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f;const x=null==(i=null==(t=e.inbox)?void 0:t.header)?void 0:i.tabs;return`\n ${I.id} {\n position: relative;\n width: 100%;\n max-width: 100%;\n min-width: 0;\n margin-top: -5px;\n overflow-x: auto;\n scrollbar-width: none; /* Firefox */\n -ms-overflow-style: none; /* IE and Edge */\n height: 41px;\n }\n\n ${I.id}::-webkit-scrollbar {\n display: none;\n }\n\n ${I.id} .tab-container {\n display: flex;\n flex-direction: row;\n gap: 4px;\n padding: 0 10px;\n width: fit-content;\n height: 100%;\n }\n\n ${I.id} .tab-item {\n position: relative;\n display: flex;\n align-items: center;\n cursor: pointer;\n transition: ${(null==x?void 0:x.transition)??"all 0.2s ease"};\n user-select: none;\n padding: 0 10px;\n flex-shrink: 0;\n height: 100%;\n ${(e=>{if(!e)return"";if("string"==typeof e)return`border-radius: ${e};`;const t=[];return e.topLeft?t.push(e.topLeft):t.push("0"),e.topRight?t.push(e.topRight):t.push("0"),e.bottomRight?t.push(e.bottomRight):t.push("0"),e.bottomLeft?t.push(e.bottomLeft):t.push("0"),`border-radius: ${t.join(" ")};`})(null==x?void 0:x.borderRadius)}\n }\n\n ${I.id} .tab {\n position: relative;\n display: flex;\n align-items: center;\n gap: 8px;\n border-bottom: ${(null==(n=null==x?void 0:x.default)?void 0:n.indicatorHeight)??"1px"} solid ${(null==(o=null==x?void 0:x.default)?void 0:o.indicatorColor)??"transparent"};\n height: 40px;\n min-width: 40px;\n justify-content: center;\n position: relative;\n }\n\n ${I.id} .tab-item:hover {\n background-color: ${(null==(s=null==x?void 0:x.default)?void 0:s.hoverBackgroundColor)??"transparent"};\n }\n\n ${I.id} .tab-item:active {\n background-color: ${(null==(l=null==x?void 0:x.default)?void 0:l.activeBackgroundColor)??"transparent"};\n }\n\n ${I.id} .tab.selected {\n border-bottom: ${(null==(r=null==x?void 0:x.selected)?void 0:r.indicatorHeight)??"1px"} solid ${(null==(a=null==x?void 0:x.selected)?void 0:a.indicatorColor)??"transparent"};\n }\n\n ${I.id} .tab-item:hover.selected {\n background-color: ${(null==(d=null==x?void 0:x.selected)?void 0:d.hoverBackgroundColor)??"transparent"};\n }\n\n ${I.id} .tab-item:active.selected {\n background-color: ${(null==(u=null==x?void 0:x.selected)?void 0:u.activeBackgroundColor)??"transparent"};\n }\n\n ${I.id} .tab-label {\n font-size: ${(null==(c=null==(h=null==x?void 0:x.default)?void 0:h.font)?void 0:c.size)??"14px"};\n font-family: ${(null==(g=null==(v=null==x?void 0:x.default)?void 0:v.font)?void 0:g.family)??"inherit"};\n font-weight: ${(null==(m=null==(p=null==x?void 0:x.default)?void 0:p.font)?void 0:m.weight)??"inherit"};\n color: ${(null==(_=null==(b=null==x?void 0:x.default)?void 0:b.font)?void 0:_.color)??"red"};\n user-select: none;\n white-space: nowrap;\n }\n\n ${I.id} .tab.selected .tab-label {\n color: ${(null==(f=null==(C=null==x?void 0:x.selected)?void 0:C.font)?void 0:f.color)??"red"};\n }\n `}setTabs(e){this._tabs=e,this._tabBadges.clear(),this.render()}setSelectedTab(e){this._selectedTabId=e,this.reloadTabs(),this.updateBadgeStates()}updateTabUnreadCount(e,t){const i=this._tabBadges.get(e);i&&i.setCount(t)}scrollToStart(e=!0){e?this.scrollTo({left:0,behavior:"smooth"}):this.scrollLeft=0}refreshTheme(){this._style&&(this._style.textContent=I.getStyles(this.theme))}reloadTabs(){const e=this.querySelector(".tab-container");if(e)for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.classList.contains("tab-item")){const e=t.getAttribute("data-tab-id"),i=t.querySelector(".tab");i instanceof HTMLElement&&(e===this._selectedTabId?i.classList.add("selected"):i.classList.remove("selected"))}}updateBadgeStates(){for(let[e,t]of this._tabBadges)t.setActive(e===this._selectedTabId)}createTab(e){const t=document.createElement("div");t.className="tab-item",t.setAttribute("data-tab-id",e.datasetId);const i=document.createElement("div");i.className="tab",e.datasetId===this._selectedTabId&&i.classList.add("selected");const n=document.createElement("div");n.className="tab-label",n.innerText=e.title;const o=new x({themeBus:this._themeManager,location:"tab"});return this._tabBadges.set(e.datasetId,o),i.appendChild(n),i.appendChild(o),t.appendChild(i),t.addEventListener("click",(()=>{e.datasetId===this._selectedTabId?this._onTabReselected(e):this._onTabClick(e)})),t}}i.registerElement(I);class k extends i.CourierBaseElement{constructor(e){super(),o(this,"_option"),o(this,"_isSelectedable"),o(this,"_isSelected"),o(this,"_theme"),o(this,"_content"),o(this,"_itemIcon"),o(this,"_title"),o(this,"_selectionIcon"),this._option=e.option,this._isSelected=e.isSelected,this._isSelectedable=e.selectable,this._theme=e.themeManager}static get id(){return"courier-inbox-option-menu-item"}onComponentMounted(){this._content=document.createElement("div"),this._content.className="menu-item",this._itemIcon=new i.CourierIcon(this._option.icon.svg??i.CourierIconSVGs.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 i.CourierIcon(i.CourierIconSVGs.check),this._selectionIcon.classList.add("check-icon"),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.updateSelectionState(),this.refreshTheme()}refreshTheme(){var e,t,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_;this._title&&(this._title.textContent=this._option.text??"Missing Text");const C=this._theme.getTheme();null==(r=this._selectionIcon)||r.updateColor((null==(l=null==(s=null==(o=null==(n=null==(t=null==(e=C.inbox)?void 0:e.header)?void 0:t.feeds)?void 0:n.menu)?void 0:o.list)?void 0:s.selectedIcon)?void 0:l.color)??"red"),null==(g=this._selectionIcon)||g.updateSVG((null==(v=null==(c=null==(h=null==(u=null==(d=null==(a=C.inbox)?void 0:a.header)?void 0:d.feeds)?void 0:u.menu)?void 0:h.list)?void 0:c.selectedIcon)?void 0:v.svg)??i.CourierIconSVGs.check),null==(m=this._itemIcon)||m.updateColor((null==(p=this._option.icon)?void 0:p.color)??"red"),null==(_=this._itemIcon)||_.updateSVG((null==(b=this._option.icon)?void 0:b.svg)??i.CourierIconSVGs.inbox)}setSelected(e){this._isSelected=e,this.updateSelectionState()}updateSelectionState(){this._selectionIcon&&(this._selectionIcon.style.display=this._isSelected?"block":"none")}}i.registerElement(k);class w extends i.CourierBaseElement{constructor(e,t,i,n,s){super(),o(this,"_themeSubscription"),o(this,"_selectedIndex",0),o(this,"_options"),o(this,"_selectable"),o(this,"_onMenuOpen"),o(this,"_isOpen",!1),o(this,"_menuType"),o(this,"_style"),o(this,"_shadowRoot"),o(this,"_container"),this._selectable=t,this._options=i,this._onMenuOpen=s,this._menuType=n,this._themeSubscription=e.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-inbox-option-menu"}onComponentMounted(){this.attachElements(),document.addEventListener("click",this.handleOutsideClick.bind(this)),this.refreshTheme()}onComponentUnmounted(){this._themeSubscription.unsubscribe()}attachElements(){this._shadowRoot=this.attachShadow({mode:"closed"}),this._container=document.createElement("div"),this._container.className="menu-container",this._style=document.createElement("style"),this._style.textContent=this.getStyles(),this._shadowRoot.appendChild(this._style),this._shadowRoot.appendChild(this._container)}getStyles(){var e,t,i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f,x,y,I,w,M,S;const T=this._themeSubscription.manager.getTheme(),$="feed"===this._menuType?null==(n=null==(i=null==(t=null==(e=T.inbox)?void 0:e.header)?void 0:t.feeds)?void 0:i.menu)?void 0:n.animation:null==(l=null==(s=null==(o=T.inbox)?void 0:o.header)?void 0:s.actions)?void 0:l.animation,E="feed"===this._menuType?null==(d=null==(a=null==(r=T.inbox)?void 0:r.header)?void 0:a.feeds)?void 0:d.menu:(null==(c=null==(h=null==(u=T.inbox)?void 0:u.header)?void 0:h.actions)?void 0:c.menu)??(null==(p=null==(g=null==(v=T.inbox)?void 0:v.header)?void 0:g.feeds)?void 0:p.menu),L=(null==$?void 0:$.initialTransform)??"translate3d(0, 0, 0)",B=(null==$?void 0:$.visibleTransform)??"translate3d(0, 0, 0)";return`\n :host {\n position: absolute;\n top: 42px;\n z-index: 1000;\n min-width: 200px;\n user-select: none;\n opacity: 0;\n pointer-events: none;\n transition: ${(null==$?void 0:$.transition)??"all 0.2s ease"};\n transform: ${L};\n will-change: transform, opacity;\n display: none;\n }\n\n :host(.displayed) {\n display: block;\n }\n\n :host(.visible) {\n opacity: 1;\n pointer-events: auto;\n transform: ${B};\n }\n\n .menu-container {\n display: flex;\n flex-direction: column;\n border-radius: ${(null==E?void 0:E.borderRadius)??"6px"};\n border: ${(null==E?void 0:E.border)??"1px solid red"};\n background: ${(null==E?void 0:E.backgroundColor)??"red"};\n box-shadow: ${(null==E?void 0:E.shadow)??"0 4px 12px 0 red"};\n overflow: hidden;\n padding: 4px 0;\n }\n\n courier-inbox-option-menu-item {\n border-bottom: ${(null==(m=null==E?void 0:E.list)?void 0:m.divider)??"none"};\n }\n\n courier-inbox-option-menu-item:last-child {\n border-bottom: none;\n }\n\n ${k.id} {\n display: flex;\n flex-direction: row;\n padding: 6px 12px;\n cursor: pointer;\n }\n\n ${k.id}:hover {\n background-color: ${(null==(b=null==E?void 0:E.list)?void 0:b.hoverBackgroundColor)??"red"};\n }\n\n ${k.id}:active {\n background-color: ${(null==(_=null==E?void 0:E.list)?void 0:_.activeBackgroundColor)??"red"};\n }\n\n ${k.id} .menu-item {\n display: flex;\n align-items: center;\n width: 100%;\n gap: 12px;\n }\n\n ${k.id} .spacer {\n flex: 1;\n }\n\n ${k.id} p {\n margin: 0;\n font-family: ${(null==(f=null==(C=null==E?void 0:E.list)?void 0:C.font)?void 0:f.family)??"inherit"};\n font-weight: ${(null==(y=null==(x=null==E?void 0:E.list)?void 0:x.font)?void 0:y.weight)??"inherit"};\n font-size: ${(null==(w=null==(I=null==E?void 0:E.list)?void 0:I.font)?void 0:w.size)??"14px"};\n color: ${(null==(S=null==(M=null==E?void 0:E.list)?void 0:M.font)?void 0:S.color)??"red"};\n white-space: nowrap;\n }\n\n ${k.id} .check-icon {\n display: block;\n }\n `}setPosition(e){this.style.left=e.left??"auto",this.style.right=e.right??"auto",this.style.top=e.top??"auto"}refreshTheme(){this._style&&(this._style.textContent=this.getStyles()),this.refreshMenuItems()}setOptions(e){this._options=e,this.refreshMenuItems()}refreshMenuItems(){if(!this._container)return;const e=this._container;e.innerHTML="",this._options.forEach(((t,i)=>{const n=new k({option:t,selectable:this._selectable,isSelected:this._selectedIndex===i,themeManager:this._themeSubscription.manager});n.addEventListener("click",(()=>{this._selectable&&this.selectionItemAtIndex(i),t.onClick(t),this.closeMenu()})),e.appendChild(n)}))}toggleMenu(){var e;this._isOpen=!this._isOpen,this._isOpen?(this.showMenu(),null==(e=this._onMenuOpen)||e.call(this)):this.hideMenu()}showMenu(){this.classList.remove("visible"),this.classList.add("displayed"),requestAnimationFrame((()=>{requestAnimationFrame((()=>{this.classList.add("visible")}))}))}hideMenu(){this.classList.remove("visible");if(!window.getComputedStyle(this).transitionDuration.split(",").map((e=>parseFloat(e)||0)).some((e=>e>0)))return void this.classList.remove("displayed");const e=t=>{t.target===this&&(this.classList.contains("visible")||(this.classList.remove("displayed"),this.removeEventListener("transitionend",e)))};this.addEventListener("transitionend",e)}closeMenu(){this._isOpen=!1,this.hideMenu()}handleOutsideClick(e){const t=e.target;this.contains(t)||this.closeMenu()}selectionItemAtIndex(e){this._selectable&&this._container&&(this._selectedIndex=e,this._options.forEach(((t,i)=>{var n;const o=null==(n=this._container)?void 0:n.children[i];o&&o.setSelected&&o.setSelected(i===e)})))}}i.registerElement(w);class M extends i.CourierFactoryElement{constructor(e){super(),o(this,"_themeSubscription"),o(this,"_feeds",[]),o(this,"_currentFeedId"),o(this,"_actions",B.defaultActions()),o(this,"_feedButton"),o(this,"_feedMenu"),o(this,"_actionMenuButton"),o(this,"_actionMenu"),o(this,"tabs"),o(this,"_style"),o(this,"_feedButtonClickHandler"),o(this,"_onFeedChange"),o(this,"_onFeedReselected"),o(this,"_onTabChange"),o(this,"_onTabReselected"),this._themeSubscription=e.themeManager.subscribe((e=>{this.refreshTheme()})),e.actions&&(this._actions=e.actions),this._onFeedChange=e.onFeedChange,this._onFeedReselected=e.onFeedReselected,this._onTabChange=e.onTabChange,this._onTabReselected=e.onTabReselected}static get id(){return"courier-inbox-header"}get theme(){return this._themeSubscription.manager.getTheme()}get showTabs(){var e;const t=this._feeds.find((e=>e.feedId===this._currentFeedId));return((null==(e=null==t?void 0:t.tabs)?void 0:e.length)??0)>1}onComponentMounted(){this._style?this._style.textContent=M.getStyles(this.theme):this._style=i.injectGlobalStyle(M.id,M.getStyles(this.theme))}onComponentUmounted(){var e;this._themeSubscription.unsubscribe(),null==(e=this._style)||e.remove()}getActionOptions(){var e,t,n,o,s,l,r,a,d,h,c,v,g,p,m,b,_;const C=null==(t=null==(e=this._themeSubscription.manager.getTheme().inbox)?void 0:e.header)?void 0:t.actions,f=[];for(const x of this._actions)switch(x.id){case"readAll":f.push({id:"make_all_read",text:x.text??(null==(n=null==C?void 0:C.markAllRead)?void 0:n.text)??"Mark All as Read",icon:{color:(null==(s=null==(o=null==C?void 0:C.markAllRead)?void 0:o.icon)?void 0:s.color)??"red",svg:x.iconSVG??(null==(r=null==(l=null==C?void 0:C.markAllRead)?void 0:l.icon)?void 0:r.svg)??i.CourierIconSVGs.read},onClick:e=>{u.shared.readAllMessages()}});break;case"archiveAll":f.push({id:"archive_all",text:x.text??(null==(a=null==C?void 0:C.archiveAll)?void 0:a.text)??"Archive All",icon:{color:(null==(h=null==(d=null==C?void 0:C.archiveAll)?void 0:d.icon)?void 0:h.color)??"red",svg:x.iconSVG??(null==(v=null==(c=null==C?void 0:C.archiveAll)?void 0:c.icon)?void 0:v.svg)??i.CourierIconSVGs.archive},onClick:e=>{u.shared.archiveAllMessages()}});break;case"archiveRead":f.push({id:"archive_read",text:x.text??(null==(g=null==C?void 0:C.archiveRead)?void 0:g.text)??"Archive Read",icon:{color:(null==(m=null==(p=null==C?void 0:C.archiveRead)?void 0:p.icon)?void 0:m.color)??"red",svg:x.iconSVG??(null==(_=null==(b=null==C?void 0:C.archiveRead)?void 0:b.icon)?void 0:_.svg)??i.CourierIconSVGs.archiveRead},onClick:e=>{u.shared.archiveReadMessages()}})}return f}refreshTheme(){var e,t;this._style?this._style.textContent=M.getStyles(this.theme):this._style=i.injectGlobalStyle(M.id,M.getStyles(this.theme)),this.refreshActionMenuButton(),null==(e=this._actionMenu)||e.setOptions(this.getActionOptions()),null==(t=this._feedMenu)||t.setOptions(this.getFeedMenuOptions()),this._actionMenuButton&&(this._actionMenuButton.style.display=this._actions.length>0?"":"none"),this._actionMenu&&(this._actionMenu.style.display=this._actions.length>0?"":"none")}getFeedMenuOptions(){return this._feeds.map(((e,t)=>{var n,o,s,l;return{id:e.feedId,text:e.title,icon:{color:(null==(l=null==(s=null==(o=null==(n=this.theme.inbox)?void 0:n.header)?void 0:o.feeds)?void 0:s.button)?void 0:l.selectedFeedIconColor)??"red",svg:e.iconSVG??i.CourierIconSVGs.inbox},onClick:t=>{e.feedId===this._currentFeedId?this._onFeedReselected(e):this._onFeedChange(e)}}}))}render(e){const t=e.feeds.find((e=>e.isSelected)),i=null==t?void 0:t.tabs.find((e=>e.isSelected)),n=((null==t?void 0:t.tabs.length)??0)>1;this._feedButton&&(this._feedButton.setSelectedFeed((null==t?void 0:t.feedId)??""),this._feedButton.setUnreadCount(n?0:(null==i?void 0:i.unreadCount)??0),this.updateFeedButtonInteraction()),this.tabs&&(this.tabs.style.display=n?"flex":"none",this.tabs.setSelectedTab((null==i?void 0:i.datasetId)??""),this.tabs.updateTabUnreadCount((null==i?void 0:i.datasetId)??"",(null==i?void 0:i.unreadCount)??0))}build(e){super.build(e),this.refreshTheme()}defaultElement(){this._feedButton=new y(this._themeSubscription.manager,this._feeds),this._feedMenu=new w(this._themeSubscription.manager,!0,this.getFeedMenuOptions(),"feed"),this._feedMenu.setPosition({left:"12px",top:"51px"}),this._feedButtonClickHandler=e=>{var t,i;e.stopPropagation(),null==(t=this._feedMenu)||t.toggleMenu(),null==(i=this._actionMenu)||i.closeMenu()},this.updateFeedButtonInteraction(),this._actionMenu=new w(this._themeSubscription.manager,!1,this.getActionOptions(),"action"),this._actionMenu.setPosition({right:"12px",top:"51px"}),this._actionMenuButton=new i.CourierIconButton(i.CourierIconSVGs.overflow),this.refreshActionMenuButton(),this._actionMenuButton.addEventListener("click",(e=>{var t,i;e.stopPropagation(),null==(t=this._actionMenu)||t.toggleMenu(),null==(i=this._feedMenu)||i.closeMenu()}));const e=document.createElement("div");e.className="title",e.appendChild(this._feedButton);const t=document.createElement("div");t.className="spacer";const n=document.createElement("div");n.className="header-content",n.appendChild(e),n.appendChild(t),this._actions.length>0&&(n.appendChild(this._actionMenuButton),n.appendChild(this._actionMenu)),n.appendChild(this._feedMenu),this.tabs=new I({themeManager:this._themeSubscription.manager,onTabClick:e=>{this._onTabChange(e)},onTabReselected:e=>{this._onTabReselected(e)}});const o=document.createElement("div");return o.className="header",o.appendChild(n),o.appendChild(this.tabs),o}refreshActionMenuButton(){var e,t,n,o,s,l,r,a,d,u,h;const c=null==(o=null==(n=null==(t=null==(e=this.theme)?void 0:e.inbox)?void 0:t.header)?void 0:n.actions)?void 0:o.button;null==(l=this._actionMenuButton)||l.updateIconSVG((null==(s=null==c?void 0:c.icon)?void 0:s.svg)??i.CourierIconSVGs.overflow),null==(a=this._actionMenuButton)||a.updateIconColor((null==(r=null==c?void 0:c.icon)?void 0:r.color)??"red"),null==(d=this._actionMenuButton)||d.updateBackgroundColor((null==c?void 0:c.backgroundColor)??"transparent"),null==(u=this._actionMenuButton)||u.updateHoverBackgroundColor((null==c?void 0:c.hoverBackgroundColor)??i.CourierColors.black[50010]),null==(h=this._actionMenuButton)||h.updateActiveBackgroundColor((null==c?void 0:c.activeBackgroundColor)??i.CourierColors.black[50020])}updateFeedButtonInteraction(){if(!this._feedButton||!this._feedButtonClickHandler)return;this._feedButton.removeEventListener("click",this._feedButtonClickHandler);this._feeds.length>1?(this._feedButton.style.cursor="pointer",this._feedButton.addEventListener("click",this._feedButtonClickHandler)):this._feedButton.style.cursor="default"}setFeeds(e){var t,i;if(0===e.length)throw new Error("[CourierInboxHeader] Cannot set feeds to an empty array.");if(!e[0].tabs.length)throw new Error("[CourierInboxHeader] First feed does not have a tab.");this._feeds=e,null==(t=this._feedButton)||t.setFeeds(e),this.selectFeed(e[0].feedId,e[0].tabs[0].datasetId),null==(i=this._feedMenu)||i.setOptions(this.getFeedMenuOptions()),this.updateFeedButtonInteraction()}setActions(e){var t;this._actions=e,null==(t=this._actionMenu)||t.setOptions(this.getActionOptions()),this._actionMenuButton&&(this._actionMenuButton.style.display=this._actions.length>0?"":"none"),this._actionMenu&&(this._actionMenu.style.display=this._actions.length>0?"":"none")}selectFeed(e,t){var i,n,o;this._currentFeedId=e,null==(i=this._feedButton)||i.setSelectedFeed(e);const s=this._feeds.findIndex((t=>t.feedId===e));null==(n=this._feedMenu)||n.selectionItemAtIndex(s);const l=(null==(o=this._feeds.find((t=>t.feedId===e)))?void 0:o.tabs)??[];if(l.length>0&&this.tabs){this.tabs.style.display=l.length>1?"flex":"none",this.tabs.setTabs(l),this.tabs.setSelectedTab(t);for(const e of l){const t=u.shared.getDatasetById(e.datasetId);t&&this.tabs.updateTabUnreadCount(e.datasetId,t.unreadCount)}}}static getStyles(e){var t,n,o,s,l,r;return`\n ${M.id} {\n display: flex;\n }\n\n ${M.id} > .header {\n display: flex;\n flex-direction: column;\n flex: 1;\n width: 100%;\n max-width: 100%;\n min-width: 0;\n position: relative;\n overflow-y: visible;\n background-color: ${(null==(n=null==(t=e.inbox)?void 0:t.header)?void 0:n.backgroundColor)??i.CourierColors.white[500]};\n box-shadow: ${(null==(s=null==(o=e.inbox)?void 0:o.header)?void 0:s.shadow)??"0px 1px 0px 0px red"};\n border-bottom: ${(null==(r=null==(l=e.inbox)?void 0:l.header)?void 0:r.border)??"1px solid red"};\n z-index: 100;\n }\n\n ${M.id} .header-content {\n padding-top: 10px;\n padding-right: 12px;\n padding-bottom: 10px;\n padding-left: 12px;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n flex: 1;\n width: 100%;\n max-width: 100%;\n min-width: 0;\n position: relative;\n box-sizing: border-box;\n }\n\n ${M.id} .title {\n display: flex;\n align-items: center;\n gap: 4px;\n }\n\n ${M.id} .spacer {\n flex: 1;\n }\n\n ${M.id} .actions {\n display: flex;\n align-items: center;\n gap: 4px;\n }\n `}}i.registerElement(M);class S{constructor(e){o(this,"events"),this.events=e}remove(){u.shared.removeDataStoreListener(this)}}const T={popup:{button:{icon:{color:i.CourierColors.black[500],svg:i.CourierIconSVGs.inbox},backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.black[50010],activeBackgroundColor:i.CourierColors.black[50020],unreadDotIndicator:{backgroundColor:i.CourierColors.blue[500],borderRadius:"50%",height:"8px",width:"8px"}},window:{backgroundColor:i.CourierColors.white[500],borderRadius:"8px",border:`1px solid ${i.CourierColors.gray[500]}`,shadow:`0px 8px 16px -4px ${i.CourierColors.gray[500]}`,animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"}}},inbox:{header:{backgroundColor:i.CourierColors.white[500],shadow:"none",border:`1px solid ${i.CourierColors.gray[500]}`,feeds:{button:{selectedFeedIconColor:i.CourierColors.black[500],hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],transition:"all 0.2s ease",font:{color:i.CourierColors.black[500],family:void 0,size:"16px"},changeFeedIcon:{color:i.CourierColors.black[500],svg:i.CourierIconSVGs.chevronDown},unreadCountIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.blue[500],borderRadius:"4px",padding:"2px 6px"}},menu:{backgroundColor:i.CourierColors.white[500],border:`1px solid ${i.CourierColors.gray[500]}`,borderRadius:"6px",shadow:`0px 4px 8px -2px ${i.CourierColors.gray[500]}`,animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"},list:{hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],divider:"none",font:{color:i.CourierColors.black[500],family:void 0,size:"14px"},selectedIcon:{color:i.CourierColors.black[500],svg:i.CourierIconSVGs.check}}},tabs:{borderRadius:{topLeft:"4px",topRight:"4px"},transition:"all 0.2s ease",default:{indicatorHeight:"1px",indicatorColor:"transparent",backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],font:{color:i.CourierColors.gray[600],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.gray[600],family:void 0,size:"12px"},backgroundColor:i.CourierColors.black[50010],borderRadius:"4px",padding:"2px 6px"}},selected:{indicatorHeight:"1px",indicatorColor:i.CourierColors.blue[500],backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],font:{color:i.CourierColors.blue[500],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.blue[500],borderRadius:"4px",padding:"2px 6px"}}}},tabs:{borderRadius:{topLeft:"4px",topRight:"4px"},transition:"all 0.2s ease",default:{indicatorHeight:"1px",indicatorColor:"transparent",backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],font:{color:i.CourierColors.gray[600],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.gray[600],family:void 0,size:"12px"},backgroundColor:i.CourierColors.black[50010],borderRadius:"4px",padding:"2px 6px"}},selected:{indicatorHeight:"1px",indicatorColor:i.CourierColors.blue[500],backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],font:{color:i.CourierColors.blue[500],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.blue[500],borderRadius:"4px",padding:"2px 6px"}}},actions:{button:{icon:{color:i.CourierColors.black[500],svg:i.CourierIconSVGs.overflow},backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500]},markAllRead:{icon:{color:i.CourierColors.black[500]},text:"Read All"},archiveAll:{icon:{color:i.CourierColors.black[500]},text:"Archive All"},archiveRead:{icon:{color:i.CourierColors.black[500]},text:"Archive Read"},animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"}}},list:{backgroundColor:i.CourierColors.white[500],scrollbar:{trackBackgroundColor:"transparent",thumbColor:i.CourierColors.black[50020],thumbHoverColor:i.CourierColors.black[50020],width:"8px",height:"8px",borderRadius:"4px"},item:{backgroundColor:"transparent",unreadIndicatorColor:i.CourierColors.blue[500],hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],transition:"all 0.2s ease",actions:{backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],border:`1px solid ${i.CourierColors.gray[500]}`,borderRadius:"4px",shadow:"0px 1px 2px 0px rgba(0, 0, 0, 0.06)",font:{color:i.CourierColors.black[500],family:void 0,size:"14px"}},title:{color:i.CourierColors.black[500],family:void 0,size:"14px"},subtitle:{color:i.CourierColors.gray[600],family:void 0,size:"14px"},time:{color:i.CourierColors.gray[600],family:void 0,size:"14px"},divider:`1px solid ${i.CourierColors.gray[200]}`,menu:{enabled:!0,backgroundColor:i.CourierColors.white[500],border:`1px solid ${i.CourierColors.gray[500]}`,borderRadius:"4px",shadow:`0px 2px 4px -2px ${i.CourierColors.gray[500]}`,animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"},longPress:{displayDuration:4e3,vibrationDuration:50},item:{hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],borderRadius:"0px",read:{color:i.CourierColors.black[500]},unread:{color:i.CourierColors.black[500]},archive:{color:i.CourierColors.black[500]},unarchive:{color:i.CourierColors.black[500]}}}}},loading:{animation:{barColor:i.CourierColors.gray[500],barHeight:"14px",barBorderRadius:"14px",duration:"2s"},divider:`1px solid ${i.CourierColors.gray[200]}`},empty:{title:{font:{size:"16px",weight:"500",color:i.CourierColors.black[500]}},button:{text:"Refresh"}},error:{title:{font:{size:"16px",weight:"500",color:i.CourierColors.black[500]}},button:{text:"Retry"}}}},$={popup:{button:{icon:{color:i.CourierColors.white[500],svg:i.CourierIconSVGs.inbox},backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],unreadDotIndicator:{backgroundColor:i.CourierColors.blue[500],borderRadius:"50%",height:"8px",width:"8px"}},window:{backgroundColor:i.CourierColors.black[500],borderRadius:"8px",border:`1px solid ${i.CourierColors.gray[400]}`,shadow:`0px 4px 8px -2px ${i.CourierColors.white[50020]}`,animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"}}},inbox:{header:{backgroundColor:i.CourierColors.black[500],shadow:"none",border:`1px solid ${i.CourierColors.gray[400]}`,feeds:{button:{selectedFeedIconColor:i.CourierColors.white[500],hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],transition:"all 0.2s ease",font:{color:i.CourierColors.white[500],family:void 0,size:"16px"},changeFeedIcon:{color:i.CourierColors.white[500],svg:i.CourierIconSVGs.chevronDown},unreadCountIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.blue[500],borderRadius:"4px",padding:"3px 8px"}},menu:{backgroundColor:i.CourierColors.black[500],border:`1px solid ${i.CourierColors.gray[400]}`,borderRadius:"6px",shadow:`0px 4px 8px -2px ${i.CourierColors.white[50020]}`,animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"},list:{hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],divider:"none",font:{color:i.CourierColors.white[500],family:void 0,size:"14px"},selectedIcon:{color:i.CourierColors.white[500],svg:i.CourierIconSVGs.check}}},tabs:{borderRadius:{topLeft:"4px",topRight:"4px"},transition:"all 0.2s ease",default:{indicatorHeight:"1px",indicatorColor:"transparent",backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],font:{color:i.CourierColors.white[500],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.white[50010],borderRadius:"4px",padding:"3px 8px"}},selected:{indicatorHeight:"1px",indicatorColor:i.CourierColors.blue[500],backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],font:{color:i.CourierColors.blue[500],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.blue[500],borderRadius:"4px",padding:"3px 8px"}}}},tabs:{borderRadius:{topLeft:"4px",topRight:"4px"},transition:"all 0.2s ease",default:{indicatorHeight:"1px",indicatorColor:"transparent",backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],font:{color:i.CourierColors.white[500],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.white[50010],borderRadius:"4px",padding:"3px 8px"}},selected:{indicatorHeight:"1px",indicatorColor:i.CourierColors.blue[500],backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],font:{color:i.CourierColors.blue[500],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.blue[500],borderRadius:"4px",padding:"3px 8px"}}},actions:{button:{icon:{color:i.CourierColors.white[500],svg:i.CourierIconSVGs.overflow},backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020]},markAllRead:{icon:{color:i.CourierColors.white[500]},text:"Read All"},archiveAll:{icon:{color:i.CourierColors.white[500]},text:"Archive All"},archiveRead:{icon:{color:i.CourierColors.white[500]},text:"Archive Read"},animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"}}},list:{backgroundColor:i.CourierColors.black[500],scrollbar:{trackBackgroundColor:"transparent",thumbColor:i.CourierColors.white[50020],thumbHoverColor:i.CourierColors.white[50020],width:"8px",height:"8px",borderRadius:"4px"},item:{backgroundColor:"transparent",unreadIndicatorColor:i.CourierColors.blue[500],hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],transition:"all 0.2s ease",actions:{backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],border:`1px solid ${i.CourierColors.gray[400]}`,borderRadius:"4px",shadow:`0px 1px 2px 0px ${i.CourierColors.white[50010]}`,font:{color:i.CourierColors.white[500],family:void 0,size:"14px"}},title:{color:i.CourierColors.white[500],family:void 0,size:"14px"},subtitle:{color:i.CourierColors.gray[500],family:void 0,size:"14px"},time:{color:i.CourierColors.gray[500],family:void 0,size:"12px"},divider:`1px solid ${i.CourierColors.gray[400]}`,menu:{enabled:!0,backgroundColor:i.CourierColors.black[500],border:`1px solid ${i.CourierColors.gray[400]}`,borderRadius:"4px",shadow:`0px 2px 4px -2px ${i.CourierColors.white[50020]}`,animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"},longPress:{displayDuration:4e3,vibrationDuration:50},item:{hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],borderRadius:"0px",read:{color:i.CourierColors.white[500]},unread:{color:i.CourierColors.white[500]},archive:{color:i.CourierColors.white[500]},unarchive:{color:i.CourierColors.white[500]}}}}},loading:{animation:{barColor:i.CourierColors.gray[400],barHeight:"14px",barBorderRadius:"14px",duration:"2s"},divider:`1px solid ${i.CourierColors.gray[400]}`},empty:{title:{font:{size:"16px",weight:"500",color:i.CourierColors.white[500]}},button:{text:"Refresh"}},error:{title:{font:{size:"16px",weight:"500",color:i.CourierColors.white[500]}},button:{text:"Retry"}}}},E=(e,t)=>{var i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f,x,y,I,k,w,M,S,E,L,B,F,A,P,R,U,D,O,z,N,G,V,H,j,W,J,q,Q,Y,X,K,Z,ee,te,ie,ne,oe,se,le,re,ae,de,ue,he,ce,ve,ge,pe,me,be,_e,Ce,fe,xe,ye,Ie,ke,we,Me,Se,Te,$e,Ee,Le,Be,Fe,Ae,Pe,Re,Ue,De,Oe,ze,Ne,Ge,Ve,He,je,We,Je,qe,Qe,Ye,Xe,Ke,Ze,et,tt,it,nt,ot,st,lt,rt,at,dt,ut,ht,ct,vt,gt,pt,mt,bt,_t,Ct,ft,xt,yt,It,kt,wt,Mt,St,Tt,$t,Et,Lt,Bt,Ft,At,Pt,Rt,Ut,Dt,Ot,zt,Nt,Gt,Vt,Ht,jt,Wt,Jt,qt,Qt,Yt,Xt,Kt,Zt,ei,ti,ii,ni,oi,si,li,ri,ai,di,ui,hi,ci,vi,gi,pi,mi,bi,_i,Ci,fi,xi,yi,Ii,ki,wi,Mi,Si,Ti,$i,Ei,Li,Bi,Fi,Ai,Pi,Ri,Ui,Di,Oi,zi,Ni,Gi,Vi,Hi,ji,Wi,Ji,qi,Qi,Yi,Xi,Ki,Zi,en,tn,nn,on,sn,ln,rn,an,dn,un,hn,cn,vn,gn,pn,mn,bn,_n,Cn,fn,xn,yn,In,kn,wn,Mn,Sn,Tn,$n,En,Ln,Bn,Fn,An,Pn,Rn,Un,Dn,On,zn,Nn,Gn,Vn,Hn,jn,Wn,Jn,qn,Qn,Yn,Xn,Kn,Zn,eo,to,io,no,oo,so,lo,ro,ao,uo,ho,co,vo,go,po,mo,bo,_o,Co,fo,xo,yo,Io,ko,wo,Mo,So,To,$o,Eo,Lo,Bo,Fo,Ao,Po,Ro,Uo,Do,Oo,zo,No,Go,Vo,Ho,jo,Wo,Jo,qo,Qo,Yo,Xo,Ko,Zo,es,ts,is,ns,os,ss,ls,rs,as,ds,us,hs,cs,vs,gs,ps,ms,bs,_s,Cs,fs,xs,ys,Is,ks,ws,Ms,Ss,Ts,$s,Es,Ls,Bs,Fs,As,Ps,Rs,Us,Ds,Os,zs,Ns,Gs,Vs,Hs,js,Ws,Js,qs,Qs,Ys,Xs,Ks,Zs,el,tl,il,nl,ol,sl,ll,rl,al,dl,ul,hl,cl,vl,gl,pl,ml,bl,_l,Cl,fl,xl,yl,Il,kl,wl,Ml,Sl,Tl,$l,El,Ll,Bl,Fl,Al,Pl,Rl,Ul,Dl,Ol,zl,Nl,Gl,Vl,Hl,jl,Wl,Jl,ql,Ql,Yl,Xl,Kl,Zl,er,tr,ir,nr,or,sr,lr,rr,ar,dr,ur,hr,cr,vr,gr,pr,mr,br,_r,Cr,fr,xr,yr,Ir,kr,wr,Mr,Sr,Tr,$r,Er,Lr,Br,Fr,Ar,Pr,Rr,Ur,Dr,Or,zr,Nr,Gr,Vr,Hr,jr,Wr,Jr,qr,Qr,Yr,Xr;const Kr="light"===e?T:$;return{popup:{button:{...null==(i=Kr.popup)?void 0:i.button,...null==(n=t.popup)?void 0:n.button,icon:{...null==(s=null==(o=Kr.popup)?void 0:o.button)?void 0:s.icon,...null==(r=null==(l=t.popup)?void 0:l.button)?void 0:r.icon},unreadDotIndicator:{...null==(d=null==(a=Kr.popup)?void 0:a.button)?void 0:d.unreadDotIndicator,...null==(h=null==(u=t.popup)?void 0:u.button)?void 0:h.unreadDotIndicator}},window:{...null==(c=Kr.popup)?void 0:c.window,...null==(v=t.popup)?void 0:v.window,animation:{...null==(p=null==(g=Kr.popup)?void 0:g.window)?void 0:p.animation,...null==(b=null==(m=t.popup)?void 0:m.window)?void 0:b.animation}}},inbox:{header:{...null==(_=Kr.inbox)?void 0:_.header,...null==(C=t.inbox)?void 0:C.header,feeds:{...null==(x=null==(f=Kr.inbox)?void 0:f.header)?void 0:x.feeds,...null==(I=null==(y=t.inbox)?void 0:y.header)?void 0:I.feeds,button:{...null==(M=null==(w=null==(k=Kr.inbox)?void 0:k.header)?void 0:w.feeds)?void 0:M.button,...null==(L=null==(E=null==(S=t.inbox)?void 0:S.header)?void 0:E.feeds)?void 0:L.button,font:{...null==(P=null==(A=null==(F=null==(B=Kr.inbox)?void 0:B.header)?void 0:F.feeds)?void 0:A.button)?void 0:P.font,...null==(O=null==(D=null==(U=null==(R=t.inbox)?void 0:R.header)?void 0:U.feeds)?void 0:D.button)?void 0:O.font},changeFeedIcon:{...null==(V=null==(G=null==(N=null==(z=Kr.inbox)?void 0:z.header)?void 0:N.feeds)?void 0:G.button)?void 0:V.changeFeedIcon,...null==(J=null==(W=null==(j=null==(H=t.inbox)?void 0:H.header)?void 0:j.feeds)?void 0:W.button)?void 0:J.changeFeedIcon},unreadCountIndicator:{...null==(X=null==(Y=null==(Q=null==(q=Kr.inbox)?void 0:q.header)?void 0:Q.feeds)?void 0:Y.button)?void 0:X.unreadCountIndicator,...null==(te=null==(ee=null==(Z=null==(K=t.inbox)?void 0:K.header)?void 0:Z.feeds)?void 0:ee.button)?void 0:te.unreadCountIndicator,font:{...null==(le=null==(se=null==(oe=null==(ne=null==(ie=Kr.inbox)?void 0:ie.header)?void 0:ne.feeds)?void 0:oe.button)?void 0:se.unreadCountIndicator)?void 0:le.font,...null==(he=null==(ue=null==(de=null==(ae=null==(re=t.inbox)?void 0:re.header)?void 0:ae.feeds)?void 0:de.button)?void 0:ue.unreadCountIndicator)?void 0:he.font}}},menu:{...null==(ge=null==(ve=null==(ce=Kr.inbox)?void 0:ce.header)?void 0:ve.feeds)?void 0:ge.menu,...null==(be=null==(me=null==(pe=t.inbox)?void 0:pe.header)?void 0:me.feeds)?void 0:be.menu,animation:{...null==(xe=null==(fe=null==(Ce=null==(_e=Kr.inbox)?void 0:_e.header)?void 0:Ce.feeds)?void 0:fe.menu)?void 0:xe.animation,...null==(we=null==(ke=null==(Ie=null==(ye=t.inbox)?void 0:ye.header)?void 0:Ie.feeds)?void 0:ke.menu)?void 0:we.animation},list:{...null==($e=null==(Te=null==(Se=null==(Me=Kr.inbox)?void 0:Me.header)?void 0:Se.feeds)?void 0:Te.menu)?void 0:$e.list,...null==(Fe=null==(Be=null==(Le=null==(Ee=t.inbox)?void 0:Ee.header)?void 0:Le.feeds)?void 0:Be.menu)?void 0:Fe.list,font:{...null==(De=null==(Ue=null==(Re=null==(Pe=null==(Ae=Kr.inbox)?void 0:Ae.header)?void 0:Pe.feeds)?void 0:Re.menu)?void 0:Ue.list)?void 0:De.font,...null==(Ve=null==(Ge=null==(Ne=null==(ze=null==(Oe=t.inbox)?void 0:Oe.header)?void 0:ze.feeds)?void 0:Ne.menu)?void 0:Ge.list)?void 0:Ve.font},selectedIcon:{...null==(qe=null==(Je=null==(We=null==(je=null==(He=Kr.inbox)?void 0:He.header)?void 0:je.feeds)?void 0:We.menu)?void 0:Je.list)?void 0:qe.selectedIcon,...null==(Ze=null==(Ke=null==(Xe=null==(Ye=null==(Qe=t.inbox)?void 0:Qe.header)?void 0:Ye.feeds)?void 0:Xe.menu)?void 0:Ke.list)?void 0:Ze.selectedIcon}}},tabs:{...null==(it=null==(tt=null==(et=Kr.inbox)?void 0:et.header)?void 0:tt.feeds)?void 0:it.tabs,...null==(st=null==(ot=null==(nt=t.inbox)?void 0:nt.header)?void 0:ot.feeds)?void 0:st.tabs,default:{...null==(dt=null==(at=null==(rt=null==(lt=Kr.inbox)?void 0:lt.header)?void 0:rt.feeds)?void 0:at.tabs)?void 0:dt.default,...null==(vt=null==(ct=null==(ht=null==(ut=t.inbox)?void 0:ut.header)?void 0:ht.feeds)?void 0:ct.tabs)?void 0:vt.default,font:{...null==(_t=null==(bt=null==(mt=null==(pt=null==(gt=Kr.inbox)?void 0:gt.header)?void 0:pt.feeds)?void 0:mt.tabs)?void 0:bt.default)?void 0:_t.font,...null==(It=null==(yt=null==(xt=null==(ft=null==(Ct=t.inbox)?void 0:Ct.header)?void 0:ft.feeds)?void 0:xt.tabs)?void 0:yt.default)?void 0:It.font},unreadIndicator:{...null==(Tt=null==(St=null==(Mt=null==(wt=null==(kt=Kr.inbox)?void 0:kt.header)?void 0:wt.feeds)?void 0:Mt.tabs)?void 0:St.default)?void 0:Tt.unreadIndicator,...null==(Ft=null==(Bt=null==(Lt=null==(Et=null==($t=t.inbox)?void 0:$t.header)?void 0:Et.feeds)?void 0:Lt.tabs)?void 0:Bt.default)?void 0:Ft.unreadIndicator,font:{...null==(Ot=null==(Dt=null==(Ut=null==(Rt=null==(Pt=null==(At=Kr.inbox)?void 0:At.header)?void 0:Pt.feeds)?void 0:Rt.tabs)?void 0:Ut.default)?void 0:Dt.unreadIndicator)?void 0:Ot.font,...null==(jt=null==(Ht=null==(Vt=null==(Gt=null==(Nt=null==(zt=t.inbox)?void 0:zt.header)?void 0:Nt.feeds)?void 0:Gt.tabs)?void 0:Vt.default)?void 0:Ht.unreadIndicator)?void 0:jt.font}}},selected:{...null==(Qt=null==(qt=null==(Jt=null==(Wt=Kr.inbox)?void 0:Wt.header)?void 0:Jt.feeds)?void 0:qt.tabs)?void 0:Qt.selected,...null==(Zt=null==(Kt=null==(Xt=null==(Yt=t.inbox)?void 0:Yt.header)?void 0:Xt.feeds)?void 0:Kt.tabs)?void 0:Zt.selected,font:{...null==(oi=null==(ni=null==(ii=null==(ti=null==(ei=Kr.inbox)?void 0:ei.header)?void 0:ti.feeds)?void 0:ii.tabs)?void 0:ni.selected)?void 0:oi.font,...null==(di=null==(ai=null==(ri=null==(li=null==(si=t.inbox)?void 0:si.header)?void 0:li.feeds)?void 0:ri.tabs)?void 0:ai.selected)?void 0:di.font},unreadIndicator:{...null==(gi=null==(vi=null==(ci=null==(hi=null==(ui=Kr.inbox)?void 0:ui.header)?void 0:hi.feeds)?void 0:ci.tabs)?void 0:vi.selected)?void 0:gi.unreadIndicator,...null==(Ci=null==(_i=null==(bi=null==(mi=null==(pi=t.inbox)?void 0:pi.header)?void 0:mi.feeds)?void 0:bi.tabs)?void 0:_i.selected)?void 0:Ci.unreadIndicator,font:{...null==(wi=null==(ki=null==(Ii=null==(yi=null==(xi=null==(fi=Kr.inbox)?void 0:fi.header)?void 0:xi.feeds)?void 0:yi.tabs)?void 0:Ii.selected)?void 0:ki.unreadIndicator)?void 0:wi.font,...null==(Li=null==(Ei=null==($i=null==(Ti=null==(Si=null==(Mi=t.inbox)?void 0:Mi.header)?void 0:Si.feeds)?void 0:Ti.tabs)?void 0:$i.selected)?void 0:Ei.unreadIndicator)?void 0:Li.font}}}}},tabs:{...null==(Fi=null==(Bi=Kr.inbox)?void 0:Bi.header)?void 0:Fi.tabs,...null==(Pi=null==(Ai=t.inbox)?void 0:Ai.header)?void 0:Pi.tabs,default:{...null==(Di=null==(Ui=null==(Ri=Kr.inbox)?void 0:Ri.header)?void 0:Ui.tabs)?void 0:Di.default,...null==(Ni=null==(zi=null==(Oi=t.inbox)?void 0:Oi.header)?void 0:zi.tabs)?void 0:Ni.default,font:{...null==(ji=null==(Hi=null==(Vi=null==(Gi=Kr.inbox)?void 0:Gi.header)?void 0:Vi.tabs)?void 0:Hi.default)?void 0:ji.font,...null==(Qi=null==(qi=null==(Ji=null==(Wi=t.inbox)?void 0:Wi.header)?void 0:Ji.tabs)?void 0:qi.default)?void 0:Qi.font},unreadIndicator:{...null==(Zi=null==(Ki=null==(Xi=null==(Yi=Kr.inbox)?void 0:Yi.header)?void 0:Xi.tabs)?void 0:Ki.default)?void 0:Zi.unreadIndicator,...null==(on=null==(nn=null==(tn=null==(en=t.inbox)?void 0:en.header)?void 0:tn.tabs)?void 0:nn.default)?void 0:on.unreadIndicator,font:{...null==(dn=null==(an=null==(rn=null==(ln=null==(sn=Kr.inbox)?void 0:sn.header)?void 0:ln.tabs)?void 0:rn.default)?void 0:an.unreadIndicator)?void 0:dn.font,...null==(gn=null==(vn=null==(cn=null==(hn=null==(un=t.inbox)?void 0:un.header)?void 0:hn.tabs)?void 0:cn.default)?void 0:vn.unreadIndicator)?void 0:gn.font}}},selected:{...null==(bn=null==(mn=null==(pn=Kr.inbox)?void 0:pn.header)?void 0:mn.tabs)?void 0:bn.selected,...null==(fn=null==(Cn=null==(_n=t.inbox)?void 0:_n.header)?void 0:Cn.tabs)?void 0:fn.selected,font:{...null==(kn=null==(In=null==(yn=null==(xn=Kr.inbox)?void 0:xn.header)?void 0:yn.tabs)?void 0:In.selected)?void 0:kn.font,...null==(Tn=null==(Sn=null==(Mn=null==(wn=t.inbox)?void 0:wn.header)?void 0:Mn.tabs)?void 0:Sn.selected)?void 0:Tn.font},unreadIndicator:{...null==(Bn=null==(Ln=null==(En=null==($n=Kr.inbox)?void 0:$n.header)?void 0:En.tabs)?void 0:Ln.selected)?void 0:Bn.unreadIndicator,...null==(Rn=null==(Pn=null==(An=null==(Fn=t.inbox)?void 0:Fn.header)?void 0:An.tabs)?void 0:Pn.selected)?void 0:Rn.unreadIndicator,font:{...null==(Nn=null==(zn=null==(On=null==(Dn=null==(Un=Kr.inbox)?void 0:Un.header)?void 0:Dn.tabs)?void 0:On.selected)?void 0:zn.unreadIndicator)?void 0:Nn.font,...null==(Wn=null==(jn=null==(Hn=null==(Vn=null==(Gn=t.inbox)?void 0:Gn.header)?void 0:Vn.tabs)?void 0:Hn.selected)?void 0:jn.unreadIndicator)?void 0:Wn.font}}}},actions:{...null==(qn=null==(Jn=Kr.inbox)?void 0:Jn.header)?void 0:qn.actions,...null==(Yn=null==(Qn=t.inbox)?void 0:Qn.header)?void 0:Yn.actions,button:{...null==(Zn=null==(Kn=null==(Xn=Kr.inbox)?void 0:Xn.header)?void 0:Kn.actions)?void 0:Zn.button,...null==(io=null==(to=null==(eo=t.inbox)?void 0:eo.header)?void 0:to.actions)?void 0:io.button,icon:{...null==(lo=null==(so=null==(oo=null==(no=Kr.inbox)?void 0:no.header)?void 0:oo.actions)?void 0:so.button)?void 0:lo.icon,...null==(ho=null==(uo=null==(ao=null==(ro=t.inbox)?void 0:ro.header)?void 0:ao.actions)?void 0:uo.button)?void 0:ho.icon}},markAllRead:{...null==(go=null==(vo=null==(co=Kr.inbox)?void 0:co.header)?void 0:vo.actions)?void 0:go.markAllRead,...null==(bo=null==(mo=null==(po=t.inbox)?void 0:po.header)?void 0:mo.actions)?void 0:bo.markAllRead,icon:{...null==(xo=null==(fo=null==(Co=null==(_o=Kr.inbox)?void 0:_o.header)?void 0:Co.actions)?void 0:fo.markAllRead)?void 0:xo.icon,...null==(wo=null==(ko=null==(Io=null==(yo=t.inbox)?void 0:yo.header)?void 0:Io.actions)?void 0:ko.markAllRead)?void 0:wo.icon}},archiveAll:{...null==(To=null==(So=null==(Mo=Kr.inbox)?void 0:Mo.header)?void 0:So.actions)?void 0:To.archiveAll,...null==(Lo=null==(Eo=null==($o=t.inbox)?void 0:$o.header)?void 0:Eo.actions)?void 0:Lo.archiveAll,icon:{...null==(Po=null==(Ao=null==(Fo=null==(Bo=Kr.inbox)?void 0:Bo.header)?void 0:Fo.actions)?void 0:Ao.archiveAll)?void 0:Po.icon,...null==(Oo=null==(Do=null==(Uo=null==(Ro=t.inbox)?void 0:Ro.header)?void 0:Uo.actions)?void 0:Do.archiveAll)?void 0:Oo.icon}},archiveRead:{...null==(Go=null==(No=null==(zo=Kr.inbox)?void 0:zo.header)?void 0:No.actions)?void 0:Go.archiveRead,...null==(jo=null==(Ho=null==(Vo=t.inbox)?void 0:Vo.header)?void 0:Ho.actions)?void 0:jo.archiveRead,icon:{...null==(Qo=null==(qo=null==(Jo=null==(Wo=Kr.inbox)?void 0:Wo.header)?void 0:Jo.actions)?void 0:qo.archiveRead)?void 0:Qo.icon,...null==(Zo=null==(Ko=null==(Xo=null==(Yo=t.inbox)?void 0:Yo.header)?void 0:Xo.actions)?void 0:Ko.archiveRead)?void 0:Zo.icon}},animation:{...null==(is=null==(ts=null==(es=Kr.inbox)?void 0:es.header)?void 0:ts.actions)?void 0:is.animation,...null==(ss=null==(os=null==(ns=t.inbox)?void 0:ns.header)?void 0:os.actions)?void 0:ss.animation}}},list:{...null==(ls=Kr.inbox)?void 0:ls.list,...null==(rs=t.inbox)?void 0:rs.list,scrollbar:{...null==(ds=null==(as=Kr.inbox)?void 0:as.list)?void 0:ds.scrollbar,...null==(hs=null==(us=t.inbox)?void 0:us.list)?void 0:hs.scrollbar},item:{...null==(vs=null==(cs=Kr.inbox)?void 0:cs.list)?void 0:vs.item,...null==(ps=null==(gs=t.inbox)?void 0:gs.list)?void 0:ps.item,actions:{...null==(_s=null==(bs=null==(ms=Kr.inbox)?void 0:ms.list)?void 0:bs.item)?void 0:_s.actions,...null==(xs=null==(fs=null==(Cs=t.inbox)?void 0:Cs.list)?void 0:fs.item)?void 0:xs.actions,font:{...null==(ws=null==(ks=null==(Is=null==(ys=Kr.inbox)?void 0:ys.list)?void 0:Is.item)?void 0:ks.actions)?void 0:ws.font,...null==($s=null==(Ts=null==(Ss=null==(Ms=t.inbox)?void 0:Ms.list)?void 0:Ss.item)?void 0:Ts.actions)?void 0:$s.font}},title:{...null==(Bs=null==(Ls=null==(Es=Kr.inbox)?void 0:Es.list)?void 0:Ls.item)?void 0:Bs.title,...null==(Ps=null==(As=null==(Fs=t.inbox)?void 0:Fs.list)?void 0:As.item)?void 0:Ps.title},subtitle:{...null==(Ds=null==(Us=null==(Rs=Kr.inbox)?void 0:Rs.list)?void 0:Us.item)?void 0:Ds.subtitle,...null==(Ns=null==(zs=null==(Os=t.inbox)?void 0:Os.list)?void 0:zs.item)?void 0:Ns.subtitle},time:{...null==(Hs=null==(Vs=null==(Gs=Kr.inbox)?void 0:Gs.list)?void 0:Vs.item)?void 0:Hs.time,...null==(Js=null==(Ws=null==(js=t.inbox)?void 0:js.list)?void 0:Ws.item)?void 0:Js.time},menu:{...null==(Ys=null==(Qs=null==(qs=Kr.inbox)?void 0:qs.list)?void 0:Qs.item)?void 0:Ys.menu,...null==(Zs=null==(Ks=null==(Xs=t.inbox)?void 0:Xs.list)?void 0:Ks.item)?void 0:Zs.menu,animation:{...null==(nl=null==(il=null==(tl=null==(el=Kr.inbox)?void 0:el.list)?void 0:tl.item)?void 0:il.menu)?void 0:nl.animation,...null==(rl=null==(ll=null==(sl=null==(ol=t.inbox)?void 0:ol.list)?void 0:sl.item)?void 0:ll.menu)?void 0:rl.animation},item:{...null==(hl=null==(ul=null==(dl=null==(al=Kr.inbox)?void 0:al.list)?void 0:dl.item)?void 0:ul.menu)?void 0:hl.item,...null==(pl=null==(gl=null==(vl=null==(cl=t.inbox)?void 0:cl.list)?void 0:vl.item)?void 0:gl.menu)?void 0:pl.item,read:{...null==(fl=null==(Cl=null==(_l=null==(bl=null==(ml=Kr.inbox)?void 0:ml.list)?void 0:bl.item)?void 0:_l.menu)?void 0:Cl.item)?void 0:fl.read,...null==(wl=null==(kl=null==(Il=null==(yl=null==(xl=t.inbox)?void 0:xl.list)?void 0:yl.item)?void 0:Il.menu)?void 0:kl.item)?void 0:wl.read},unread:{...null==(El=null==($l=null==(Tl=null==(Sl=null==(Ml=Kr.inbox)?void 0:Ml.list)?void 0:Sl.item)?void 0:Tl.menu)?void 0:$l.item)?void 0:El.unread,...null==(Pl=null==(Al=null==(Fl=null==(Bl=null==(Ll=t.inbox)?void 0:Ll.list)?void 0:Bl.item)?void 0:Fl.menu)?void 0:Al.item)?void 0:Pl.unread},archive:{...null==(zl=null==(Ol=null==(Dl=null==(Ul=null==(Rl=Kr.inbox)?void 0:Rl.list)?void 0:Ul.item)?void 0:Dl.menu)?void 0:Ol.item)?void 0:zl.archive,...null==(jl=null==(Hl=null==(Vl=null==(Gl=null==(Nl=t.inbox)?void 0:Nl.list)?void 0:Gl.item)?void 0:Vl.menu)?void 0:Hl.item)?void 0:jl.archive},unarchive:{...null==(Yl=null==(Ql=null==(ql=null==(Jl=null==(Wl=Kr.inbox)?void 0:Wl.list)?void 0:Jl.item)?void 0:ql.menu)?void 0:Ql.item)?void 0:Yl.unarchive,...null==(tr=null==(er=null==(Zl=null==(Kl=null==(Xl=t.inbox)?void 0:Xl.list)?void 0:Kl.item)?void 0:Zl.menu)?void 0:er.item)?void 0:tr.unarchive}}}}},loading:{...null==(ir=Kr.inbox)?void 0:ir.loading,...null==(nr=t.inbox)?void 0:nr.loading,animation:{...null==(sr=null==(or=Kr.inbox)?void 0:or.loading)?void 0:sr.animation,...null==(rr=null==(lr=t.inbox)?void 0:lr.loading)?void 0:rr.animation}},empty:{...null==(ar=Kr.inbox)?void 0:ar.empty,...null==(dr=t.inbox)?void 0:dr.empty,title:{...null==(hr=null==(ur=Kr.inbox)?void 0:ur.empty)?void 0:hr.title,...null==(vr=null==(cr=t.inbox)?void 0:cr.empty)?void 0:vr.title,font:{...null==(mr=null==(pr=null==(gr=Kr.inbox)?void 0:gr.empty)?void 0:pr.title)?void 0:mr.font,...null==(Cr=null==(_r=null==(br=t.inbox)?void 0:br.empty)?void 0:_r.title)?void 0:Cr.font}},button:{...null==(xr=null==(fr=Kr.inbox)?void 0:fr.empty)?void 0:xr.button,...null==(Ir=null==(yr=t.inbox)?void 0:yr.empty)?void 0:Ir.button,font:{...null==(Mr=null==(wr=null==(kr=Kr.inbox)?void 0:kr.empty)?void 0:wr.button)?void 0:Mr.font,...null==($r=null==(Tr=null==(Sr=t.inbox)?void 0:Sr.empty)?void 0:Tr.button)?void 0:$r.font}}},error:{...null==(Er=Kr.inbox)?void 0:Er.error,...null==(Lr=t.inbox)?void 0:Lr.error,title:{...null==(Fr=null==(Br=Kr.inbox)?void 0:Br.error)?void 0:Fr.title,...null==(Pr=null==(Ar=t.inbox)?void 0:Ar.error)?void 0:Pr.title,font:{...null==(Dr=null==(Ur=null==(Rr=Kr.inbox)?void 0:Rr.error)?void 0:Ur.title)?void 0:Dr.font,...null==(Nr=null==(zr=null==(Or=t.inbox)?void 0:Or.error)?void 0:zr.title)?void 0:Nr.font}},button:{...null==(Vr=null==(Gr=Kr.inbox)?void 0:Gr.error)?void 0:Vr.button,...null==(jr=null==(Hr=t.inbox)?void 0:Hr.error)?void 0:jr.button,font:{...null==(qr=null==(Jr=null==(Wr=Kr.inbox)?void 0:Wr.error)?void 0:Jr.button)?void 0:qr.font,...null==(Xr=null==(Yr=null==(Qr=t.inbox)?void 0:Qr.error)?void 0:Yr.button)?void 0:Xr.font}}}}}};class L extends i.CourierThemeManager{constructor(e){super(e),o(this,"THEME_CHANGE_EVENT","courier_inbox_theme_change")}getDefaultLightTheme(){return T}getDefaultDarkTheme(){return $}mergeTheme(e,t){return E(e,t)}subscribe(e){return{...super.subscribe(e),manager:this}}}class B extends i.CourierBaseElement{constructor(e){super(),o(this,"_currentFeedId",b()[0].feedId),o(this,"_feedTabMap",new Map),o(this,"_themeManager"),o(this,"_inboxStyle"),o(this,"_list"),o(this,"_datastoreListener"),o(this,"_authListener"),o(this,"_feeds",b()),o(this,"_header"),o(this,"_headerFactory"),o(this,"_actions",B.defaultActions()),o(this,"_onMessageClick"),o(this,"_onMessageActionClick"),o(this,"_onMessageLongPress"),o(this,"_listItemActions",B.defaultListItemActions()),o(this,"_defaultProps",{height:"auto"}),this._themeManager=e??new L(T)}static get id(){return"courier-inbox"}static defaultFeeds(){return b()}static defaultActions(){return[{id:"readAll"},{id:"archiveRead"},{id:"archiveAll"}]}static defaultListItemActions(){return[{id:"read_unread"},{id:"archive_unarchive"}]}get currentFeedId(){return this._currentFeedId}get _currentTabId(){return this.getSelectedTabIdForFeed(this._currentFeedId)}getSelectedTabIdForFeed(e){return this._feedTabMap.get(e)??"unknown_tab"}get theme(){return this._themeManager.getTheme()}setLightTheme(e){this._themeManager.setLightTheme(e)}setDarkTheme(e){this._themeManager.setDarkTheme(e)}setMode(e){this._themeManager.setMode(e)}static get observedAttributes(){return["height","light-theme","dark-theme","mode","message-click","message-action-click","message-long-press"]}resetInitialFeedAndTab(){if(!this._feeds.length)throw new Error("No feeds are available to initialize.");this._feedTabMap.clear();for(const e of this._feeds){if(!e.tabs||!e.tabs.length)throw new Error(`Feed "${e.feedId}" does not contain any tabs. You must have at least one tab in each feed.`);this._feedTabMap.set(e.feedId,e.tabs[0].datasetId)}this._currentFeedId=this._feeds[0].feedId}onComponentMounted(){this.readInitialThemeAttributes(),this.attachElements(),this.setupThemeSubscription(),this.setupAuthListener(),this.initializeInboxData()}readInitialThemeAttributes(){var e,i,n,o;const s=this.getAttribute("light-theme");if(s)try{this.setLightTheme(JSON.parse(s))}catch(a){null==(i=null==(e=t.Courier.shared.client)?void 0:e.options.logger)||i.error("Failed to parse light-theme attribute:",a)}const l=this.getAttribute("dark-theme");if(l)try{this.setDarkTheme(JSON.parse(l))}catch(a){null==(o=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||o.error("Failed to parse dark-theme attribute:",a)}const r=this.getAttribute("mode");r&&this._themeManager.setMode(r)}setupThemeSubscription(){this._themeManager.subscribe((e=>{this.refreshTheme()})),this.refreshTheme()}setupAuthListener(){this._authListener=t.Courier.shared.addAuthenticationListener((async({userId:e})=>{e&&await this.refresh()}))}initializeInboxData(){this.resetInitialFeedAndTab(),u.shared.registerFeeds(this._feeds),this._datastoreListener=new S({onError:e=>{var t;null==(t=this._list)||t.setError(e)},onDataSetChange:e=>{var t;this._currentTabId===e.id&&(null==(t=this._list)||t.setDataSet(e),this.updateHeader())},onPageAdded:e=>{var t;this._currentTabId===e.id&&(null==(t=this._list)||t.addPage(e),this.updateHeader())},onMessageAdd:(e,t,i)=>{var n;this._currentTabId===i&&(null==(n=this._list)||n.addMessage(e,t),this.updateHeader())},onMessageRemove:(e,t,i)=>{var n;this._currentTabId===i&&(null==(n=this._list)||n.removeMessage(t),this.updateHeader())},onMessageUpdate:(e,t,i)=>{var n;this._currentTabId===i&&(null==(n=this._list)||n.updateMessage(e,t),this.updateHeader())},onUnreadCountChange:(e,t)=>{var i,n;null==(n=null==(i=this._header)?void 0:i.tabs)||n.updateTabUnreadCount(t,e),this._currentTabId===t&&this.updateHeader()},onTotalUnreadCountChange:e=>{this.updateHeader()}}),u.shared.addDataStoreListener(this._datastoreListener),this.refresh()}attachElements(){var e,n;this._inboxStyle=i.injectGlobalStyle(B.id,this.getStyles()),this._header=new M({themeManager:this._themeManager,actions:this._actions,onFeedChange:e=>{this.selectFeed(e.feedId)},onFeedReselected:e=>{var t,i,n;this.selectTab(e.tabs[0].datasetId),null==(t=this._list)||t.scrollToTop(),null==(n=null==(i=this._header)?void 0:i.tabs)||n.scrollToStart()},onTabChange:e=>{this.selectTab(e.datasetId)},onTabReselected:e=>{var t;null==(t=this._list)||t.scrollToTop()}}),null==(e=this._header)||e.build(void 0),null==(n=this._header)||n.setFeeds(this._feeds),this.appendChild(this._header),this._list=new f({themeManager:this._themeManager,listItemActions:this._listItemActions,canClickListItems:!1,canLongPressListItems:!1,onRefresh:()=>{this.refresh()},onPaginationTrigger:async e=>{var i,n;try{await u.shared.fetchNextPageOfMessages({datasetId:e})}catch(o){null==(n=null==(i=t.Courier.shared.client)?void 0:i.options.logger)||n.error("Failed to fetch next page of messages:",o)}},onMessageClick:(e,t)=>{var i;u.shared.clickMessage({message:e}),this.dispatchEvent(new CustomEvent("message-click",{detail:{message:e,index:t},bubbles:!0,composed:!0})),null==(i=this._onMessageClick)||i.call(this,{message:e,index:t})},onMessageActionClick:(e,t,i)=>{var n;this.dispatchEvent(new CustomEvent("message-action-click",{detail:{message:e,action:t,index:i},bubbles:!0,composed:!0})),null==(n=this._onMessageActionClick)||n.call(this,{message:e,action:t,index:i})},onMessageLongPress:(e,t)=>{var i;this.dispatchEvent(new CustomEvent("message-long-press",{detail:{message:e,index:t},bubbles:!0,composed:!0})),null==(i=this._onMessageLongPress)||i.call(this,{message:e,index:t})}}),this.appendChild(this._list)}onComponentUnmounted(){var e,t,i;this._themeManager.cleanup(),null==(e=this._datastoreListener)||e.remove(),null==(t=this._authListener)||t.remove(),null==(i=this._inboxStyle)||i.remove()}refreshTheme(){var e;null==(e=this._list)||e.refreshInfoStateThemes(),this._inboxStyle&&(this._inboxStyle.textContent=this.getStyles())}getStyles(){return`\n ${B.id} {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: ${this._defaultProps.height};\n }\n\n ${B.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){var t;this._onMessageClick=e,null==(t=this._list)||t.setCanClickListItems(void 0!==e)}onMessageActionClick(e){this._onMessageActionClick=e}onMessageLongPress(e){var t;this._onMessageLongPress=e,null==(t=this._list)||t.setCanLongPressListItems(void 0!==e)}async reloadListForTab(){var e;null==(e=this._list)||e.selectDataset(this._currentTabId),await u.shared.load({canUseCache:!0,datasetIds:[this._currentTabId]})}selectFeed(e){var t,i;const n=this._feeds.find((t=>t.feedId===e));if(!n)throw new Error(`Feed "${e}" does not exist.`);if(this._currentFeedId===e){if(!n.tabs||0===n.tabs.length)throw new Error(`Feed "${e}" does not contain any tabs. You must have at least one tab in each feed.`);const i=n.tabs[0].datasetId;return null==(t=this._header)||t.selectFeed(e,i),void this.selectTab(i)}this._currentFeedId=e,null==(i=this._header)||i.selectFeed(e,this._currentTabId),this.selectTab(this._currentTabId)}selectTab(e){var t,i,n;const o=this._feeds.find((e=>e.feedId===this._currentFeedId));if(!o)throw new Error(`Feed "${this._currentFeedId}" does not exist.`);if(!(null==(t=o.tabs)?void 0:t.some((t=>t.datasetId===e))))throw new Error(`Tab "${e}" does not exist in feed "${o.feedId}".`);this._feedTabMap.set(this._currentFeedId,e),null==(n=null==(i=this._header)?void 0:i.tabs)||n.setSelectedTab(e),this.reloadListForTab()}updateTabUnreadCounts(e){var t,i;for(const n of e){const e=u.shared.getDatasetById(n.datasetId);e&&(null==(i=null==(t=this._header)?void 0:t.tabs)||i.updateTabUnreadCount(n.datasetId,e.unreadCount))}}setActions(e){var t;this._actions=e,null==(t=this._header)||t.setActions(this._actions)}setListItemActions(e){var t;this._listItemActions=e,null==(t=this._list)||t.setListItemActions(this._listItemActions)}setFeeds(e){var t,i,n,o;this._feeds=e,this.resetInitialFeedAndTab(),u.shared.registerFeeds(this._feeds),null==(t=this._header)||t.setFeeds(this._feeds),null==(i=this._header)||i.selectFeed(this._currentFeedId,this._currentTabId),this.updateHeader(),null==(n=this._list)||n.selectDataset(this._currentTabId),null==(o=this._list)||o.scrollToTop(!1),this.refresh()}getFeeds(){return this._feeds}getHeaderFeeds(){return this._feeds.map((e=>({feedId:e.feedId,title:e.title,iconSVG:e.iconSVG,tabs:e.tabs.map((e=>{var t;return{datasetId:e.datasetId,title:e.title,unreadCount:(null==(t=u.shared.getDatasetById(e.datasetId))?void 0:t.unreadCount)??0,isSelected:e.datasetId===this._currentTabId,filter:e.filter}})),isSelected:e.feedId===this._currentFeedId})))}updateHeader(){var e,t,i;if(!this._currentTabId)return;const n={feeds:this.getHeaderFeeds()};switch(this._headerFactory){case void 0:null==(e=this._header)||e.render(n);break;case null:null==(t=this._header)||t.build(null);break;default:const o=this._headerFactory(n);null==(i=this._header)||i.build(o)}}async load(e){await u.shared.load(e);for(const t of this._feeds)this.updateTabUnreadCounts(t.tabs);await u.shared.listenForUpdates()}async refresh(){var e,i;if(null==(e=t.Courier.shared.client)?void 0:e.options.userId)return this.load({canUseCache:!1});null==(i=t.Courier.shared.client)||i.options.logger.error("No user signed in. Please call Courier.shared.signIn(...) to load the inbox.")}attributeChangedCallback(e,i,n){var o,s,l,r,a,d;if(i!==n)switch(e){case"height":const e=n||this._defaultProps.height;this.style.height=e;break;case"message-click":if(n)try{this._onMessageClick=new Function("props",n)}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(n)try{this._onMessageActionClick=new Function("props",n)}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(n)try{this._onMessageLongPress=new Function("props",n)}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":n&&this.setLightTheme(JSON.parse(n));break;case"dark-theme":n&&this.setDarkTheme(JSON.parse(n));break;case"mode":this._themeManager.setMode(n)}}}i.registerElement(B);class F extends i.CourierFactoryElement{constructor(e){super(),o(this,"_themeSubscription"),o(this,"_style"),o(this,"_container"),o(this,"_triggerButton"),o(this,"_unreadBadge"),this._themeSubscription=e.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-inbox-menu-button"}get theme(){return this._themeSubscription.manager.getTheme()}onComponentMounted(){this.refreshTheme()}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 i.CourierIconButton(i.CourierIconSVGs.inbox),this._unreadBadge=document.createElement("div"),this._unreadBadge.id="unread-badge",this._unreadBadge.style.display="none",this._container.appendChild(this._triggerButton),this._container.appendChild(this._unreadBadge),this._container}static getStyles(e){var t,i,n,o,s,l,r,a,d,u,h,c;return`\n ${F.id} {\n display: inline-block;\n }\n\n ${F.id} .menu-button-container {\n position: relative;\n display: inline-block;\n }\n \n ${F.id} .menu-button-container #unread-badge {\n position: absolute;\n top: 2px;\n right: 2px;\n pointer-events: none;\n width: ${(null==(n=null==(i=null==(t=e.popup)?void 0:t.button)?void 0:i.unreadDotIndicator)?void 0:n.width)??"8px"};\n height: ${(null==(l=null==(s=null==(o=e.popup)?void 0:o.button)?void 0:s.unreadDotIndicator)?void 0:l.height)??"8px"};\n background: ${(null==(d=null==(a=null==(r=e.popup)?void 0:r.button)?void 0:a.unreadDotIndicator)?void 0:d.backgroundColor)??"red"};\n border-radius: ${(null==(c=null==(h=null==(u=e.popup)?void 0:u.button)?void 0:h.unreadDotIndicator)?void 0:c.borderRadius)??"50%"};\n display: none;\n z-index: 1;\n }\n `}onUnreadCountChange(e){this._unreadBadge&&(this._unreadBadge.style.display=e>0?"block":"none"),this.refreshTheme()}refreshTheme(){var e,t,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f,x,y,I;null==(e=this._style)||e.remove(),this._style=i.injectGlobalStyle(F.id,F.getStyles(this.theme)),null==(l=this._triggerButton)||l.updateIconColor((null==(s=null==(o=null==(n=null==(t=this.theme)?void 0:t.popup)?void 0:n.button)?void 0:o.icon)?void 0:s.color)??i.CourierColors.black[500]),null==(h=this._triggerButton)||h.updateIconSVG((null==(u=null==(d=null==(a=null==(r=this.theme)?void 0:r.popup)?void 0:a.button)?void 0:d.icon)?void 0:u.svg)??i.CourierIconSVGs.inbox),null==(p=this._triggerButton)||p.updateBackgroundColor((null==(g=null==(v=null==(c=this.theme)?void 0:c.popup)?void 0:v.button)?void 0:g.backgroundColor)??"transparent"),null==(C=this._triggerButton)||C.updateHoverBackgroundColor((null==(_=null==(b=null==(m=this.theme)?void 0:m.popup)?void 0:b.button)?void 0:_.hoverBackgroundColor)??i.CourierColors.black[50010]),null==(I=this._triggerButton)||I.updateActiveBackgroundColor((null==(y=null==(x=null==(f=this.theme)?void 0:f.popup)?void 0:x.button)?void 0:y.activeBackgroundColor)??i.CourierColors.black[50020])}}i.registerElement(F);class A extends i.CourierBaseElement{constructor(){super(),o(this,"_width","440px"),o(this,"_height","440px"),o(this,"_popupAlignment","top-left"),o(this,"_top"),o(this,"_right"),o(this,"_bottom"),o(this,"_left"),o(this,"_themeManager",new L(T)),o(this,"_triggerButton"),o(this,"_popup"),o(this,"_inbox"),o(this,"_style"),o(this,"_datastoreListener"),o(this,"_totalUnreadCount",0),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.hidePopup()})),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)}setMode(e){this._themeManager.setMode(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.readInitialThemeAttributes(),this._style=i.injectGlobalStyle(A.id,A.getStyles(this.theme,this._width,this._height)),this._triggerButton=new F(this._themeManager),this._popup=document.createElement("div"),this._popup.className="popup",this._inbox=new B(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 S(this),u.shared.addDataStoreListener(this._datastoreListener),this.render()}onComponentUnmounted(){var e,t;null==(e=this._style)||e.remove(),null==(t=this._datastoreListener)||t.remove(),this._themeManager.cleanup()}readInitialThemeAttributes(){var e,i,n,o;const s=this.getAttribute("light-theme");if(s)try{this.setLightTheme(JSON.parse(s))}catch(a){null==(i=null==(e=t.Courier.shared.client)?void 0:e.options.logger)||i.error("Failed to parse light-theme attribute:",a)}const l=this.getAttribute("dark-theme");if(l)try{this.setDarkTheme(JSON.parse(l))}catch(a){null==(o=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||o.error("Failed to parse dark-theme attribute:",a)}const r=this.getAttribute("mode");r&&this._themeManager.setMode(r)}refreshTheme(){this._style&&(this._style.textContent=A.getStyles(this.theme,this._width,this._height))}static getStyles(e,t,i){var n,o,s,l,r,a,d,u,h,c;const v=null==(o=null==(n=e.popup)?void 0:n.window)?void 0:o.animation,g=(null==v?void 0:v.initialTransform)??"translate3d(-10px, -10px, 0) scale(0.9)",p=(null==v?void 0:v.visibleTransform)??"translate3d(0, 0, 0) scale(1)";return`\n ${A.id} {\n display: inline-block;\n position: relative;\n }\n\n ${A.id} .popup {\n display: none;\n position: absolute;\n background: ${(null==(l=null==(s=e.popup)?void 0:s.window)?void 0:l.backgroundColor)??"red"};\n border-radius: ${(null==(a=null==(r=e.popup)?void 0:r.window)?void 0:a.borderRadius)??"8px"};\n border: ${(null==(u=null==(d=e.popup)?void 0:d.window)?void 0:u.border)??"1px solid red"};\n box-shadow: ${(null==(c=null==(h=e.popup)?void 0:h.window)?void 0:c.shadow)??"0px 8px 16px -4px red"};\n z-index: 1000;\n width: ${t};\n height: ${i};\n overflow: hidden;\n transform: ${g};\n will-change: transform, opacity;\n transition: ${(null==v?void 0:v.transition)??"all 0.2s ease"};\n opacity: 0;\n }\n\n ${A.id} .popup.displayed {\n display: block;\n }\n\n ${A.id} .popup.visible {\n opacity: 1;\n transform: ${p};\n }\n\n ${A.id} courier-inbox {\n height: 100%;\n }\n `}attributeChangedCallback(e,t,i){switch(e){case"popup-alignment":this.isValidPosition(i)&&(this._popupAlignment=i,this.updatePopupPosition());break;case"popup-width":this._width=i,this.setSize(i,this._height);break;case"popup-height":this._height=i,this.setSize(this._width,i);break;case"top":this._top=i,this.updatePopupPosition();break;case"right":this._right=i,this.updatePopupPosition();break;case"bottom":this._bottom=i,this.updatePopupPosition();break;case"left":this._left=i,this.updatePopupPosition();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)}}onUnreadCountChange(e){this.render()}onTotalUnreadCountChange(e){this._totalUnreadCount=e,this.render()}onMessageClick(e){var t;null==(t=this._inbox)||t.onMessageClick((t=>{e&&e(t),this.closePopup()}))}onMessageActionClick(e){var t;null==(t=this._inbox)||t.onMessageActionClick((t=>{e&&e(t),this.closePopup()}))}onMessageLongPress(e){var t;null==(t=this._inbox)||t.onMessageLongPress((t=>{e&&e(t),this.closePopup()}))}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??"40px",this._popup.style.right=this._right??"0px";break;case"top-left":this._popup.style.top=this._top??"40px",this._popup.style.left=this._left??"0px";break;case"top-center":this._popup.style.top=this._top??"40px",this._popup.style.left="50%",this._popup.style.transform="translateX(-50%)";break;case"bottom-right":this._popup.style.bottom=this._bottom??"40px",this._popup.style.right=this._right??"0px";break;case"bottom-left":this._popup.style.bottom=this._bottom??"40px",this._popup.style.left=this._left??"0px";break;case"bottom-center":this._popup.style.bottom=this._bottom??"40px",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??"40px",this._popup.style.transform="translateY(-50%)";break;case"center-left":this._popup.style.top="50%",this._popup.style.left=this._left??"40px",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;this._popup.classList.contains("visible")?this.hidePopup():this.showPopup()}showPopup(){this._popup&&(this._popup.classList.remove("visible"),this._popup.classList.add("displayed"),requestAnimationFrame((()=>{requestAnimationFrame((()=>{this._popup&&this._popup.classList.add("visible")}))})))}hidePopup(){if(!this._popup)return;this._popup.classList.remove("visible");if(!window.getComputedStyle(this._popup).transitionDuration.split(",").map((e=>parseFloat(e)||0)).some((e=>e>0)))return void this._popup.classList.remove("displayed");const e=t=>{t.target===this._popup&&"opacity"===t.propertyName&&this._popup&&!this._popup.classList.contains("visible")&&(this._popup.classList.remove("displayed"),this._popup.removeEventListener("transitionend",e))};this._popup.addEventListener("transitionend",e)}closePopup(){this.hidePopup()}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 i,n;this.isValidPosition(e)?(this._popupAlignment=e,this.updatePopupPosition()):null==(n=null==(i=t.Courier.shared.client)?void 0:i.options.logger)||n.error(`Invalid position: ${e}`)}setHeader(e){var t;null==(t=this._inbox)||t.setHeader(e)}removeHeader(){var e;null==(e=this._inbox)||e.removeHeader()}setLoadingState(e){var t;null==(t=this._inbox)||t.setLoadingState(e)}setEmptyState(e){var t;null==(t=this._inbox)||t.setEmptyState(e)}setErrorState(e){var t;null==(t=this._inbox)||t.setErrorState(e)}setListItem(e){var t;null==(t=this._inbox)||t.setListItem(e)}setPaginationItem(e){var t;null==(t=this._inbox)||t.setPaginationItem(e)}setMenuButton(e){this._popupMenuButtonFactory=e,this.render()}selectFeed(e){var t;null==(t=this._inbox)||t.selectFeed(e)}selectTab(e){var t;null==(t=this._inbox)||t.selectTab(e)}setFeeds(e){var t;null==(t=this._inbox)||t.setFeeds(e)}getFeeds(){var e;return(null==(e=this._inbox)?void 0:e.getFeeds())??[]}setActions(e){var t;null==(t=this._inbox)||t.setActions(e)}setListItemActions(e){var t;null==(t=this._inbox)||t.setListItemActions(e)}get currentFeedId(){var e;return(null==(e=this._inbox)?void 0:e.currentFeedId)??""}async refresh(){var e;return null==(e=this._inbox)?void 0:e.refresh()}render(){var e;const t=this._totalUnreadCount;if(!this._triggerButton)return;const i=(null==(e=this._inbox)?void 0:e.getHeaderFeeds())??[];switch(this._popupMenuButtonFactory){case void 0:case null:this._triggerButton.build(void 0),this._triggerButton.onUnreadCountChange(t);break;default:const e=this._popupMenuButtonFactory({totalUnreadCount:t,feeds:i});this._triggerButton.build(e)}}}i.registerElement(A);t.Courier.shared.courierUserAgentName="courier-ui-inbox",t.Courier.shared.courierUserAgentVersion="2.2.0",Object.defineProperty(e,"Courier",{enumerable:!0,get:()=>t.Courier}),e.CourierInbox=B,e.CourierInboxDataStoreListener=S,e.CourierInboxDatastore=u,e.CourierInboxDatastoreEvents=class{onDataSetChange(e){}onPageAdded(e){}onUnreadCountChange(e,t){}onTotalUnreadCountChange(e){}onMessageAdd(e,t,i){}onMessageRemove(e,t,i){}onMessageUpdate(e,t,i){}onError(e){}},e.CourierInboxHeader=M,e.CourierInboxListItem=h,e.CourierInboxPopupMenu=A,e.CourierInboxThemeManager=L,e.archiveMessage=function(e){return u.shared.archiveMessage({message:e})},e.clickMessage=function(e){return u.shared.clickMessage({message:e})},e.defaultActions=_,e.defaultDarkTheme=$,e.defaultFeeds=b,e.defaultLightTheme=T,e.defaultListItemActions=C,e.markAsRead=function(e){return u.shared.readMessage({message:e})},e.markAsUnread=function(e){return u.shared.unreadMessage({message:e})},e.mergeTheme=E,e.openMessage=m,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@trycourier/courier-js"),require("@trycourier/courier-ui-core")):"function"==typeof define&&define.amd?define(["exports","@trycourier/courier-js","@trycourier/courier-ui-core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CourierUIInbox={},e.CourierJS,e.CourierUICore)}(this,(function(e,t,i){"use strict";var n=Object.defineProperty,o=(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);function s(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=>s(e)))}}function r(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return String(e).replace(/[&<>"']/g,(e=>t[e]??e))}function a(e){return r(e).replace(/\n/g," ")}function d(e){return!(!e||"string"!=typeof e)&&/<[a-z][\s\S]*>/i.test(e)}const u=' class="courier-inbox-subtitle-link" style="cursor: pointer;"';function h(e){if("string"!=typeof e||!e)return"";const t=/\[([^\]]*)\]\((https?:\/\/[^\s)]+)\)|(https?:\/\/[^\s<>"']+)/gi,i=[];let n,o=0;for(t.lastIndex=0;null!==(n=t.exec(e));){i.push(r(e.slice(o,n.index)));const t=n[1],s=n[2],l=n[3];if(void 0!==s){const e=a(s),n=r(t??s);i.push(`<a href="${e}" target="_blank" rel="noopener noreferrer"${u}>${n}</a>`)}else if(void 0!==l){const e=a(l);i.push(`<a href="${e}" target="_blank" rel="noopener noreferrer"${u}>${r(l)}</a>`)}o=n.index+n[0].length}return i.push(r(e.slice(o))),i.join("")}function c(e){if("string"!=typeof e)return"";if(!e.trim())return"";const t=function(e){let t=e;return t=t.replace(/href\s*=\s*["']?\[[^\]]*\]\s*\(\s*(https?:\/\/[^\s)]+)\s*\)/gi,((e,t)=>`href="${t}"`)),t=t.replace(/target\s*=\s*["']?\+?blank["']?/gi,'target="_blank"'),t=t.replace(/rel\s*=\s*["']?noopener\s+no\s*referrer["']?/gi,'rel="noopener noreferrer"'),t=t.replace(/rel\s*=\s*["']?noopener\s*noreferrer["']?/gi,'rel="noopener noreferrer"'),t=t.replace(/rel\s*=\s*["']?noopener["']?/gi,'rel="noopener noreferrer"'),t}(e);try{let i=function(e){if(e.nodeType===Node.TEXT_NODE)return r(e.textContent??"");if(e.nodeType!==Node.ELEMENT_NODE)return"";const t=e;if("A"===t.tagName.toUpperCase()){const e=t.getAttribute("href")??"";if(/^https?:\/\//i.test(e)){return`<a href="${a(e)}" target="_blank" rel="noopener noreferrer" class="courier-inbox-subtitle-link" style="cursor: pointer;">${Array.from(t.childNodes).map(i).join("")}</a>`}}return Array.from(t.childNodes).map(i).join("")};const n="undefined"!=typeof DOMParser?new DOMParser:null;if(!n)return r(e);const o=n.parseFromString(t,"text/html");return Array.from(o.body.childNodes).map(i).join("")}catch{return r(t)}}class v extends i.CourierBaseElement{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,i,n;const o=null==(n=null==(i=null==(t=e.inbox)?void 0:t.list)?void 0:i.item)?void 0:n.menu,s=null==o?void 0:o.animation,l=(null==s?void 0:s.initialTransform)??"translate3d(0, 0, 0)",r=(null==s?void 0:s.visibleTransform)??"translate3d(0, 0, 0)";return`\n ${v.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: ${(null==s?void 0:s.transition)??"all 0.2s ease"};\n overflow: hidden;\n transform: ${l};\n will-change: transform, opacity;\n }\n\n ${v.id}.visible {\n opacity: 1;\n pointer-events: auto;\n transform: ${r};\n }\n\n ${v.id} ul.menu {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: row;\n }\n\n ${v.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 touch-action: none;\n }\n `}setOptions(e){this._options=e,this.renderMenu()}renderMenu(){var e,t,n;const o=this.querySelector("ul.menu");if(!o)return;o.innerHTML="";const s=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.menu,l=e=>{e.stopPropagation(),"touchstart"!==e.type&&"mousedown"!==e.type||e.preventDefault()};this._options.forEach((e=>{var t,n,r;const a=new i.CourierIconButton(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==(r=null==s?void 0:s.item)?void 0:r.borderRadius),d=t=>{t.stopPropagation(),e.onClick()};a.addEventListener("click",d),a.addEventListener("touchstart",l,{passive:!1}),a.addEventListener("touchend",d,{passive:!0}),a.addEventListener("touchmove",(e=>{e.stopPropagation()}),{passive:!0}),a.addEventListener("mousedown",l),a.addEventListener("mouseup",l),o.appendChild(a)}))}show(){this.style.display="block",this.classList.remove("visible"),requestAnimationFrame((()=>{requestAnimationFrame((()=>{this.classList.add("visible")}))}))}hide(){this.classList.remove("visible");const e=t=>{t.target===this&&(this.classList.contains("visible")||(this.style.display="none",this.removeEventListener("transitionend",e)))};this.addEventListener("transitionend",e)}}i.registerElement(v);class g{constructor(e,t){o(this,"_id"),o(this,"_messages",[]),o(this,"_firstFetchComplete",!1),o(this,"_hasNextPage",!1),o(this,"_lastPaginationCursor"),o(this,"_filter"),o(this,"_datastoreListeners",[]),o(this,"_totalUnreadCount",0),this._id=e,this._filter={tags:t.tags?[...t.tags]:void 0,archived:t.archived||!1,status:t.status}}get totalUnreadCount(){return this._totalUnreadCount}set totalUnreadCount(e){this._totalUnreadCount=e>0?e:0}setUnreadCount(e){this.totalUnreadCount=e,this._datastoreListeners.forEach((t=>{var i,n,o,s;null==(n=(i=t.events).onUnreadCountChange)||n.call(i,e,this._id),null==(s=(o=t.events).onTotalUnreadCountChange)||s.call(o,m.shared.totalUnreadCount)}))}getFilter(){return{tags:this._filter.tags,archived:this._filter.archived,status:this._filter.status}}addMessage(e,t=0){const i=s(e);return!!this.messageQualifiesForDataset(i)&&(this._messages.splice(t,0,i),i.read||(this.totalUnreadCount+=1),this._datastoreListeners.forEach((e=>{var n,o,s,l,r,a;null==(o=(n=e.events).onMessageAdd)||o.call(n,i,t,this._id),null==(l=(s=e.events).onUnreadCountChange)||l.call(s,this.totalUnreadCount,this._id),null==(a=(r=e.events).onTotalUnreadCountChange)||a.call(r,m.shared.totalUnreadCount)})),!0)}updateWithMessageChange(e,t){const i=this.indexOfMessage(t),n=this._messages[i],o=s(t);if(n&&(r=o,(l=n).archived===r.archived&&l.read===r.read&&l.opened===r.opened))return!0;var l,r;if(n){if(this.messageQualifiesForDataset(o)){const e=this.calculateUnreadChange(n,o);return this._messages.splice(i,1,o),this.totalUnreadCount+=e,this._datastoreListeners.forEach((e=>{var t,n,s,l,r,a;null==(n=(t=e.events).onMessageUpdate)||n.call(t,o,i,this._id),null==(l=(s=e.events).onUnreadCountChange)||l.call(s,this.totalUnreadCount,this._id),null==(a=(r=e.events).onTotalUnreadCountChange)||a.call(r,m.shared.totalUnreadCount)})),!0}return this.removeMessage(n),!1}if(this.messageQualifiesForDataset(t)){const i=this.findInsertIndex(t);this._messages.splice(i,0,s(t));const n=this.messageQualifiesForDataset(e)?this.calculateUnreadChange(e,t):t.read?0:1;return this.totalUnreadCount+=n,this._datastoreListeners.forEach((e=>{var n,o,s,l,r,a;null==(o=(n=e.events).onMessageAdd)||o.call(n,t,i,this._id),null==(l=(s=e.events).onUnreadCountChange)||l.call(s,this.totalUnreadCount,this._id),null==(a=(r=e.events).onTotalUnreadCountChange)||a.call(r,m.shared.totalUnreadCount)})),!0}return this.messageQualifiesForDataset(e)&&(this.totalUnreadCount+=this.calculateUnreadChange(e,t),this._datastoreListeners.forEach((e=>{var t,n,s,l,r,a;null==(n=(t=e.events).onMessageUpdate)||n.call(t,o,i,this._id),null==(l=(s=e.events).onUnreadCountChange)||l.call(s,this.totalUnreadCount,this._id),null==(a=(r=e.events).onTotalUnreadCountChange)||a.call(r,m.shared.totalUnreadCount)}))),!1}calculateUnreadChange(e,t){return e.read&&!t.read?1:!e.read&&t.read?-1:0}removeMessage(e){const t=this.indexOfMessage(e);return t>-1&&(this._messages.splice(t,1),e.read||(this.totalUnreadCount-=1),this._datastoreListeners.forEach((i=>{var n,o,s,l,r,a;null==(o=(n=i.events).onMessageRemove)||o.call(n,e,t,this._id),null==(l=(s=i.events).onUnreadCountChange)||l.call(s,this.totalUnreadCount,this._id),null==(a=(r=i.events).onTotalUnreadCountChange)||a.call(r,m.shared.totalUnreadCount)})),!0)}getMessage(e){return this._messages.find((t=>t.messageId===e))}async loadDataset(e){if(e&&this._firstFetchComplete)return void this._datastoreListeners.forEach((e=>{var t,i,n,o,s,l;null==(i=(t=e.events).onDataSetChange)||i.call(t,this.toInboxDataset()),null==(o=(n=e.events).onUnreadCountChange)||o.call(n,this.totalUnreadCount,this._id),null==(l=(s=e.events).onTotalUnreadCountChange)||l.call(s,m.shared.totalUnreadCount)}));const t=await this.fetchMessages();this._messages=[...t.messages],this.totalUnreadCount=t.unreadCount,this._hasNextPage=t.canPaginate,this._lastPaginationCursor=t.paginationCursor??void 0,this._firstFetchComplete=!0,this._datastoreListeners.forEach((e=>{var t,i,n,o,s,l;null==(i=(t=e.events).onDataSetChange)||i.call(t,this.toInboxDataset()),null==(o=(n=e.events).onUnreadCountChange)||o.call(n,this.totalUnreadCount,this._id),null==(l=(s=e.events).onTotalUnreadCountChange)||l.call(s,m.shared.totalUnreadCount)}))}async fetchNextPageOfMessages(){if(!this._hasNextPage)return null;const e=await this.fetchMessages(this._lastPaginationCursor);return this._messages=[...this._messages,...e.messages],this._hasNextPage=e.canPaginate,this._lastPaginationCursor=e.paginationCursor??void 0,this._firstFetchComplete=!0,this._datastoreListeners.forEach((t=>{var i,n,o,s,l,r,a,d;null==(n=(i=t.events).onDataSetChange)||n.call(i,this.toInboxDataset()),null==(s=(o=t.events).onUnreadCountChange)||s.call(o,this.totalUnreadCount,this._id),null==(r=(l=t.events).onPageAdded)||r.call(l,e),null==(d=(a=t.events).onTotalUnreadCountChange)||d.call(a,m.shared.totalUnreadCount)})),e}addDatastoreListener(e){this._datastoreListeners.push(e)}removeDatastoreListener(e){const t=this._datastoreListeners.indexOf(e);t>-1&&this._datastoreListeners.splice(t,1)}toInboxDataset(){return{id:this._id,messages:[...this._messages],unreadCount:this.totalUnreadCount,canPaginate:this._hasNextPage,paginationCursor:this._lastPaginationCursor??null}}async fetchMessages(e){var i,n,o,s,l,r,a,d,u;const h=t.Courier.shared.client;if(!(null==h?void 0:h.options.userId))throw new Error("User is not signed in");const c=await h.inbox.getMessages({paginationLimit:t.Courier.shared.paginationLimit,startCursor:e,filter:this.getFilter()});return{id:this._id,messages:[...(null==(n=null==(i=c.data)?void 0:i.messages)?void 0:n.nodes)??[]],unreadCount:(null==(o=c.data)?void 0:o.unreadCount)??0,canPaginate:(null==(r=null==(l=null==(s=c.data)?void 0:s.messages)?void 0:l.pageInfo)?void 0:r.hasNextPage)??!1,paginationCursor:(null==(u=null==(d=null==(a=c.data)?void 0:a.messages)?void 0:d.pageInfo)?void 0:u.startCursor)??null}}indexOfMessage(e){return this._messages.findIndex((t=>t.messageId===e.messageId))}findInsertIndex(e){const t=this._messages;for(let i=0;i<t.length;i++){const n=t[i];if(n.created&&e.created&&n.created<e.created)return i}return t.length}messageQualifiesForDataset(e){if(e.archived&&!this._filter.archived||!e.archived&&this._filter.archived)return!1;if(e.read&&"unread"===this._filter.status||!e.read&&"read"===this._filter.status)return!1;if(this._filter.tags&&!e.tags)return!1;if(this._filter.tags&&e.tags){for(const t of this._filter.tags)if(e.tags.includes(t))return!0;return!1}return!0}restoreFromSnapshot(e){this._messages=e.messages.map((e=>s(e))),this.totalUnreadCount=e.unreadCount,this._hasNextPage=e.canPaginate,this._lastPaginationCursor=e.paginationCursor??void 0,this._datastoreListeners.forEach((t=>{var i,n,o,s,l,r;null==(n=(i=t.events).onDataSetChange)||n.call(i,e),null==(s=(o=t.events).onUnreadCountChange)||s.call(o,this.totalUnreadCount,this._id),null==(r=(l=t.events).onTotalUnreadCountChange)||r.call(l,m.shared.totalUnreadCount)}))}}const p=class e{constructor(){o(this,"_datasets",new Map),o(this,"_listeners",[]),o(this,"_removeMessageEventListener"),o(this,"_globalMessages",new Map)}registerFeeds(e){const t=new Map(e.flatMap((e=>e.tabs)).map((e=>[e.datasetId,e.filter])));this.createDatasetsFromFilters(t)}createDatasetsFromFilters(e){this.clearDatasets();for(let[t,i]of e){const e=new g(t,i);for(let t of this._listeners)e.addDatastoreListener(t);this._datasets.set(t,e)}}addMessage(e){this._globalMessages.set(e.messageId,e);for(let t of this._datasets.values())t.addMessage(e)}updateDatasetsWithMessageChange(e,t){for(let i of this._datasets.values())i.updateWithMessageChange(e,t)}async listenForUpdates(){var e,i,n,o,s,l,r,a,d,u,h;const c=null==(e=t.Courier.shared.client)?void 0:e.inbox.socket;if(c)try{if(this._removeMessageEventListener&&this._removeMessageEventListener(),this._removeMessageEventListener=c.addMessageEventListener((e=>this.handleMessageEvent(e))),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}]`));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)}else null==(n=null==(i=t.Courier.shared.client)?void 0:i.options.logger)||n.info("CourierInbox socket not available")}async loadUnreadCountsForTabs(e){const i=t.Courier.shared.client;if(!i)return;const n={};for(const t of e){const e=this._datasets.get(t);e&&(n[t]=e.getFilter())}if(0===Object.keys(n).length)return;const o=await i.inbox.getUnreadCounts(n);for(const[t,s]of Object.entries(o)){const e=this._datasets.get(t);e&&e.setUnreadCount(s)}}addDataStoreListener(e){this._listeners.push(e);for(let t of this._datasets.values())t.addDatastoreListener(e)}removeDataStoreListener(e){this._listeners=this._listeners.filter((t=>t!==e));for(let t of this._datasets.values())t.removeDatastoreListener(e)}async readMessage({message:i}){if(i.read)return;const n=this._globalMessages.get(i.messageId);n&&await this.executeWithRollback((async()=>{var o;const l=s(n);l.read=e.getISONow(),this._globalMessages.set(i.messageId,l),this.updateDatasetsWithMessageChange(n,l),await(null==(o=t.Courier.shared.client)?void 0:o.inbox.read({messageId:i.messageId}))}))}async unreadMessage({message:e}){if(!e.read)return;const i=this._globalMessages.get(e.messageId);i&&await this.executeWithRollback((async()=>{var n;const o=s(i);o.read=void 0,this._globalMessages.set(e.messageId,o),this.updateDatasetsWithMessageChange(i,o),await(null==(n=t.Courier.shared.client)?void 0:n.inbox.unread({messageId:e.messageId}))}))}async openMessage({message:i}){if(i.opened)return;const n=this._globalMessages.get(i.messageId);n&&await this.executeWithRollback((async()=>{var o;const l=s(n);l.opened=e.getISONow(),this._globalMessages.set(i.messageId,l),this.updateDatasetsWithMessageChange(n,l),await(null==(o=t.Courier.shared.client)?void 0:o.inbox.open({messageId:i.messageId}))}))}async unarchiveMessage({message:e}){if(!e.archived)return;const i=this._globalMessages.get(e.messageId);i&&await this.executeWithRollback((async()=>{var n;const o=s(i);o.archived=void 0,this._globalMessages.set(e.messageId,o),this.updateDatasetsWithMessageChange(i,o),await(null==(n=t.Courier.shared.client)?void 0:n.inbox.unarchive({messageId:e.messageId}))}))}async archiveMessage({message:i}){if(i.archived)return;const n=this._globalMessages.get(i.messageId);n&&await this.executeWithRollback((async()=>{var o;const l=s(n);l.archived=e.getISONow(),this._globalMessages.set(i.messageId,l),this.updateDatasetsWithMessageChange(n,l),await(null==(o=t.Courier.shared.client)?void 0:o.inbox.archive({messageId:i.messageId}))}))}async clickMessage({message:i}){var n,o,s,l;if(null==(n=i.trackingIds)?void 0:n.clickTrackingId)try{await(null==(o=t.Courier.shared.client)?void 0:o.inbox.click({messageId:i.messageId,trackingId:i.trackingIds.clickTrackingId}))}catch(r){null==(l=null==(s=t.Courier.shared.client)?void 0:s.options.logger)||l.error(`[${e.TAG}] Error clicking message:`,r),this._listeners.forEach((e=>{var t,i;null==(i=(t=e.events).onError)||i.call(t,r)}))}}async archiveAllMessages(){await this.executeWithRollback((async()=>{var i;const n=e.getISONow();for(const[e,t]of this._globalMessages.entries())if(!t.archived){const i=s(t);i.archived=n,this._globalMessages.set(e,i),this.updateDatasetsWithMessageChange(t,i)}await(null==(i=t.Courier.shared.client)?void 0:i.inbox.archiveAll())}))}async readAllMessages(){await this.executeWithRollback((async()=>{var i;const n=e.getISONow();for(const[e,t]of this._globalMessages.entries())if(!t.read){const i=s(t);i.read=n,this._globalMessages.set(e,i),this.updateDatasetsWithMessageChange(t,i)}await(null==(i=t.Courier.shared.client)?void 0:i.inbox.readAll())}))}async archiveReadMessages(){await this.executeWithRollback((async()=>{var i;const n=e.getISONow();for(const[e,t]of this._globalMessages.entries())if(t.read&&!t.archived){const i=s(t);i.archived=n,this._globalMessages.set(e,i),this.updateDatasetsWithMessageChange(t,i)}await(null==(i=t.Courier.shared.client)?void 0:i.inbox.archiveRead())}))}async load(e){const i=t.Courier.shared.client;if(!(null==i?void 0:i.options.userId))throw new Error("[Datastore] User is not signed in");const n=(null==e?void 0:e.canUseCache)??!0;if(null==e?void 0:e.datasetIds){const t=e.datasetIds.flatMap((e=>{const t=this._datasets.get(e);return t?[t]:[]}));return await this.loadDatasets({canUseCache:n,datasets:t})}return await this.loadDatasets({canUseCache:n,datasets:Array.from(this._datasets.values())})}async loadDatasets(e){await Promise.all(e.datasets.map((async t=>{await t.loadDataset(e.canUseCache),this.syncDatasetMessagesToGlobalStore(t)})))}syncDatasetMessagesToGlobalStore(e){const t=e.toInboxDataset();for(const i of t.messages)this._globalMessages.has(i.messageId)||this._globalMessages.set(i.messageId,i)}async fetchNextPageOfMessages(i){var n;const o=t.Courier.shared.client;if(!(null==o?void 0:o.options.userId))throw new Error("User is not signed in");let s;if(i.feedType&&!i.datasetId)null==(n=t.Courier.shared.client)||n.options.logger.warn(`[${e.TAG}] feedType is deprecated andwill be removed in the next major version. Please update callers to use datasetIds.`),s=i.feedType;else{if(!i.datasetId)throw new Error(`[${e.TAG}] Exactly one of feedType or datasetId is required to call fetchNextPageOfMessages.`);s=i.datasetId}const l=this._datasets.get(s);if(!l)throw new Error(`[${e.TAG}] Attempted to fetch next page of messages for dataset ${s}, but the dataset does not exist.`);return this.fetchNextPageForDataset({dataset:l})}getDatasetById(e){var t;return null==(t=this._datasets.get(e))?void 0:t.toInboxDataset()}getDatasets(){const e={};for(const[t,i]of this._datasets.entries())e[t]=i.toInboxDataset();return e}get totalUnreadCount(){let e=0;for(let t of this._datasets.values())e+=t.totalUnreadCount;return e}async fetchNextPageForDataset(e){const t=await e.dataset.fetchNextPageOfMessages();return t&&this.syncDatasetMessagesToGlobalStore(e.dataset),t}handleMessageEvent(i){var n,o;const s=i.event;if(s===t.InboxMessageEvent.NewMessage){const e=i.data;this._globalMessages.set(e.messageId,e);for(let t of this._datasets.values())t.addMessage(e);return}if(s===t.InboxMessageEvent.ArchiveAll||s===t.InboxMessageEvent.ArchiveRead||s===t.InboxMessageEvent.MarkAllRead)return void this.updateAllMessages(s);const l=i.messageId;l?this.updateMessage(l,s):null==(o=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||o.warn(`[${e.TAG}] Received unexpected event: ${s}`)}updateAllMessages(i){const n=e.getISONow();for(const[e,o]of this._globalMessages.entries()){let l=null;switch(i){case t.InboxMessageEvent.MarkAllRead:o.read||(l=s(o),l.read=n);break;case t.InboxMessageEvent.ArchiveAll:o.archived||(l=s(o),l.archived=n);break;case t.InboxMessageEvent.ArchiveRead:o.read&&!o.archived&&(l=s(o),l.archived=n)}l&&(this._globalMessages.set(e,l),this.updateDatasetsWithMessageChange(o,l))}}updateMessage(i,n){const o=this._globalMessages.get(i);if(!o)return;let l;switch(n){case t.InboxMessageEvent.Archive:l=s(o),l.archived=e.getISONow();break;case t.InboxMessageEvent.Opened:l=s(o),l.opened=e.getISONow();break;case t.InboxMessageEvent.Read:l=s(o),l.read=e.getISONow();break;case t.InboxMessageEvent.Unarchive:l=s(o),l.archived=void 0;break;case t.InboxMessageEvent.Unread:l=s(o),l.read=void 0;break;case t.InboxMessageEvent.Clicked:case t.InboxMessageEvent.Unopened:default:return}this._globalMessages.set(i,l),this.updateDatasetsWithMessageChange(o,l)}clearDatasets(){this._datasets.clear(),this._globalMessages.clear()}static getISONow(){return(new Date).toISOString()}createDatastoreSnapshot(){const e=[];for(const[i,n]of this._datasets.entries()){const t=n.toInboxDataset();if(t){const n=l(t);n&&e.push({id:i,dataset:n})}}const t=new Map;for(const[i,n]of this._globalMessages.entries())t.set(i,s(n));return{datasets:e,globalMessages:t}}restoreDatastoreSnapshot(e){this._globalMessages.clear();for(const[t,i]of e.globalMessages.entries())this._globalMessages.set(t,s(i));for(const t of e.datasets){const e=this._datasets.get(t.id);e&&e.restoreFromSnapshot(t.dataset)}}async executeWithRollback(i){var n,o;const s=this.createDatastoreSnapshot();try{return await i()}catch(l){null==(o=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||o.error(`[${e.TAG}] Error during operation:`,l),this.restoreDatastoreSnapshot(s),this._listeners.forEach((e=>{var t,i;null==(i=(t=e.events).onError)||i.call(t,l)}))}}static get shared(){return e.instance||(e.instance=new e),e.instance}};o(p,"TAG","CourierInboxDatastore"),o(p,"instance");let m=p;class b extends i.CourierBaseElement{constructor(e,t,i,n){super(),o(this,"_themeManager"),o(this,"_theme"),o(this,"_message",null),o(this,"_isMobile",!1),o(this,"_canClick",!1),o(this,"_listItemActions",D.defaultListItemActions()),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,"_observer"),o(this,"onItemClick",null),o(this,"onItemLongPress",null),o(this,"onItemActionClick",null),o(this,"onItemVisible",null),this._canClick=t,this._themeManager=e,this._theme=e.getTheme(),this._isMobile="ontouchstart"in window,n&&(this._listItemActions=n),this.render(),this._setupIntersectionObserver()}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 v(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._canClick&&(this._menu&&(this._menu.contains(e.target)||e.composedPath().includes(this._menu))||e.target instanceof HTMLAnchorElement||!this._message||!this.onItemClick||e.target instanceof i.CourierIcon||this._isLongPress||this.onItemClick(this._message))})),this._setupHoverBehavior(),this._setupLongPressBehavior(),this._canClick&&this.classList.add("clickable")}_setupIntersectionObserver(){"undefined"!=typeof window&&"undefined"!=typeof IntersectionObserver&&(this._observer&&this._observer.disconnect(),this._observer=new IntersectionObserver((e=>{e.forEach((e=>{1===e.intersectionRatio&&this.onItemVisible&&this._message&&this.onItemVisible(this._message)}))}),{threshold:1}),this._observer.observe(this))}onComponentUnmounted(){var e;null==(e=this._observer)||e.disconnect()}static getStyles(e){var t,i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,_,C,f,x,y,k,I,w,M,S,$,T,E,L,B,F,A,P,R,U,D,O,N,z,G,H,V;const j=null==(t=e.inbox)?void 0:t.list;return`\n ${b.id} {\n display: flex;\n flex-direction: row;\n align-items: flex-start;\n justify-content: space-between;\n border-bottom: ${(null==(i=null==j?void 0:j.item)?void 0:i.divider)??"1px solid red"};\n font-family: inherit;\n cursor: default;\n transition: ${(null==(n=null==j?void 0:j.item)?void 0:n.transition)??"all 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==(o=null==j?void 0:j.item)?void 0:o.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 /* Only apply hover/active background if clickable */\n @media (hover: hover) {\n ${b.id}.clickable:hover {\n cursor: pointer;\n background-color: ${(null==(s=null==j?void 0:j.item)?void 0:s.hoverBackgroundColor)??"red"};\n }\n }\n\n ${b.id}.clickable:active {\n cursor: pointer;\n background-color: ${(null==(l=null==j?void 0:j.item)?void 0:l.activeBackgroundColor)??"red"};\n }\n\n /* Menu hover / active */\n @media (hover: hover) {\n ${b.id}.clickable:hover:has(courier-inbox-list-item-menu:hover, courier-inbox-list-item-menu *:hover, courier-button:hover, courier-button *:hover) {\n background-color: ${(null==(r=null==j?void 0:j.item)?void 0:r.backgroundColor)??"transparent"};\n }\n }\n\n ${b.id}.clickable:active:has(courier-inbox-list-item-menu:active, courier-inbox-list-item-menu *:active, courier-button:active, courier-button *:active) {\n background-color: ${(null==(a=null==j?void 0:j.item)?void 0:a.backgroundColor)??"transparent"};\n }\n\n ${b.id}:last-child {\n border-bottom: none;\n }\n\n ${b.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==(d=null==j?void 0:j.item)?void 0:d.unreadIndicatorColor)??"red"};\n display: none;\n }\n\n ${b.id}.unread .unread-indicator {\n display: block;\n }\n\n ${b.id} .content-container {\n flex: 1;\n display: flex;\n flex-direction: column;\n margin-right: 12px;\n }\n\n ${b.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 ${b.id} .title {\n font-family: ${(null==(h=null==(u=null==j?void 0:j.item)?void 0:u.title)?void 0:h.family)??"inherit"};\n font-size: ${(null==(v=null==(c=null==j?void 0:j.item)?void 0:c.title)?void 0:v.size)??"14px"};\n color: ${(null==(p=null==(g=null==j?void 0:j.item)?void 0:g.title)?void 0:p.color)??"red"};\n margin-bottom: 4px;\n }\n ${b.id} .title a,\n ${b.id} .title .courier-inbox-subtitle-link {\n --courier-inbox-subtitle-link-color: ${(null==(_=null==(m=null==j?void 0:j.item)?void 0:m.subtitleLink)?void 0:_.color)??"#2563EB"};\n --courier-inbox-subtitle-link-decoration: ${(null==(f=null==(C=null==j?void 0:j.item)?void 0:C.subtitleLink)?void 0:f.textDecoration)??"underline"};\n color: var(--courier-inbox-subtitle-link-color);\n text-decoration: var(--courier-inbox-subtitle-link-decoration);\n cursor: pointer;\n }\n ${b.id} .title a:hover,\n ${b.id} .title .courier-inbox-subtitle-link:hover {\n color: ${(null==(y=null==(x=null==j?void 0:j.item)?void 0:x.subtitleLink)?void 0:y.hoverColor)??(null==(I=null==(k=null==j?void 0:j.item)?void 0:k.subtitleLink)?void 0:I.color)??"#2563EB"};\n }\n\n ${b.id} .subtitle {\n font-family: ${(null==(M=null==(w=null==j?void 0:j.item)?void 0:w.subtitle)?void 0:M.family)??"inherit"};\n font-size: ${(null==($=null==(S=null==j?void 0:j.item)?void 0:S.subtitle)?void 0:$.size)??"14px"};\n color: ${(null==(E=null==(T=null==j?void 0:j.item)?void 0:T.subtitle)?void 0:E.color)??"red"};\n }\n\n ${b.id} .subtitle a,\n ${b.id} .subtitle .courier-inbox-subtitle-link {\n --courier-inbox-subtitle-link-color: ${(null==(B=null==(L=null==j?void 0:j.item)?void 0:L.subtitleLink)?void 0:B.color)??"#2563EB"};\n --courier-inbox-subtitle-link-decoration: ${(null==(A=null==(F=null==j?void 0:j.item)?void 0:F.subtitleLink)?void 0:A.textDecoration)??"underline"};\n color: var(--courier-inbox-subtitle-link-color);\n text-decoration: var(--courier-inbox-subtitle-link-decoration);\n cursor: pointer;\n }\n\n ${b.id} .subtitle a:hover,\n ${b.id} .subtitle .courier-inbox-subtitle-link:hover {\n color: ${(null==(R=null==(P=null==j?void 0:j.item)?void 0:P.subtitleLink)?void 0:R.hoverColor)??(null==(D=null==(U=null==j?void 0:j.item)?void 0:U.subtitleLink)?void 0:D.color)??"#2563EB"};\n }\n\n ${b.id} .time {\n font-family: ${(null==(N=null==(O=null==j?void 0:j.item)?void 0:O.time)?void 0:N.family)??"inherit"};\n font-size: ${(null==(G=null==(z=null==j?void 0:j.item)?void 0:z.time)?void 0:G.size)??"14px"};\n color: ${(null==(V=null==(H=null==j?void 0:j.item)?void 0:H.time)?void 0:V.color)??"red"};\n text-align: right;\n white-space: nowrap;\n }\n\n ${b.id} courier-inbox-list-item-menu {\n z-index: 1;\n position: absolute;\n top: 8px;\n right: 8px;\n display: none;\n opacity: 0;\n transition: opacity 0.2s ease;\n }\n\n ${b.id} courier-inbox-list-item-menu.visible {\n opacity: 1;\n }\n\n /* Show menu on hover for non-mobile devices - CSS handles this reliably */\n @media (hover: hover) {\n ${b.id}.clickable:hover courier-inbox-list-item-menu {\n display: block;\n }\n ${b.id}.clickable:hover courier-inbox-list-item-menu.visible {\n display: block;\n }\n ${b.id}.clickable:hover .time {\n opacity: 0;\n transition: opacity 0.2s ease;\n }\n }\n\n ${b.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;const e=this._getMenuOptions();e.length>0&&this._menu&&(this._menu.setOptions(e),this._menu.show(),this._timeElement&&(this._timeElement.style.opacity="0"))})),this.addEventListener("mouseleave",(()=>{this._menu&&this._menu.hide(),this._timeElement&&(this._timeElement.style.opacity="1")})))}_setupLongPressBehavior(){var e,t,i;const n=null==(i=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:i.menu;if(!(null==n?void 0:n.enabled))return;const o=n.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)}))}_getMenuOptions(){var e,t,n,o,s,l,r,a,d,u,h,c,v,g,p,b;const _=null==(o=null==(n=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:n.menu)?void 0:o.item;let C=[];const f=!!(null==(s=this._message)?void 0:s.archived);for(const x of this._listItemActions)switch(x.id){case"read_unread":C.push({id:(null==(l=this._message)?void 0:l.read)?"unread":"read",icon:{svg:(null==(r=this._message)?void 0:r.read)?x.unreadIconSVG??(null==(a=null==_?void 0:_.unread)?void 0:a.svg)??i.CourierIconSVGs.unread:x.readIconSVG??(null==(d=null==_?void 0:_.read)?void 0:d.svg)??i.CourierIconSVGs.read,color:(null==(u=this._message)?void 0:u.read)?null==(h=null==_?void 0:_.unread)?void 0:h.color:(null==(c=null==_?void 0:_.read)?void 0:c.color)??"red"},onClick:()=>{this._message&&(this._message.read?m.shared.unreadMessage({message:this._message}):m.shared.readMessage({message:this._message}))}});break;case"archive_unarchive":C.push({id:f?"unarchive":"archive",icon:{svg:f?x.unarchiveIconSVG??(null==(v=null==_?void 0:_.unarchive)?void 0:v.svg)??i.CourierIconSVGs.unarchive:x.archiveIconSVG??(null==(g=null==_?void 0:_.archive)?void 0:g.svg)??i.CourierIconSVGs.archive,color:f?null==(p=null==_?void 0:_.unarchive)?void 0:p.color:(null==(b=null==_?void 0:_.archive)?void 0:b.color)??"red"},onClick:()=>{this._message&&(f?m.shared.unarchiveMessage({message:this._message}):m.shared.archiveMessage({message:this._message}))}})}return C}_showMenu(){var e,t,i;const n=null==(i=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:i.menu,o=this._getMenuOptions();0!==o.length&&n&&n.enabled&&this._menu&&this._timeElement&&(this._menu.setOptions(o),this._menu.show(),this._timeElement.style.opacity="0")}_hideMenu(){var e,t,i;const n=null==(i=null==(t=null==(e=this._theme.inbox)?void 0:e.list)?void 0:t.item)?void 0:i.menu;n&&n.enabled&&this._menu&&this._timeElement&&(this._menu.hide(),this._timeElement.style.opacity="1")}setMessage(e){this._message=e,this._updateContent()}setOnItemClick(e){this.onItemClick=e}setOnItemActionClick(e){this.onItemActionClick=e}setOnItemLongPress(e){this.onItemLongPress=e}setOnItemVisible(e){this.onItemVisible=e}_updateContent(){var e,t,n;if(!this._message)return this._titleElement&&(this._titleElement.textContent=""),void(this._subtitleElement&&(this._subtitleElement.textContent=""));if(this.classList.toggle("unread",!this._message.read),this._titleElement){const e=this._message.title||"Untitled Message";d(e)?this._titleElement.innerHTML=c(e):this._titleElement.innerHTML=c(h(e))}if(this._subtitleElement){const e=this._message.body??"",t=this._message.preview??"",i=e&&d(e)?e:t||e||"";d(i)?this._subtitleElement.innerHTML=c(i):this._subtitleElement.innerHTML=c(h(i))}this._timeElement&&(this._timeElement.textContent=function(e){if(!e.created)return"Now";const t=new Date,i=new Date(e.created),n=Math.floor((t.getTime()-i.getTime())/1e3);return n<5?"Now":n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:n<604800?`${Math.floor(n/86400)}d`:n<31536e3?`${Math.floor(n/604800)}w`:`${Math.floor(n/31536e3)}y`}(this._message)),this._menu&&this._menu.setOptions(this._getMenuOptions());const o=this._message.actions&&this._message.actions.length>0;this._actionsContainer&&(this._actionsContainer.style.display=o?"flex":"none");const s=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._actionsContainer.innerHTML="",this._message.actions.forEach((e=>{var t,n,o,l,r;const a=new i.CourierButton({mode:this._themeManager.mode,text:e.content,variant:"secondary",backgroundColor:null==s?void 0:s.backgroundColor,hoverBackgroundColor:null==s?void 0:s.hoverBackgroundColor,activeBackgroundColor:null==s?void 0:s.activeBackgroundColor,border:null==s?void 0:s.border,borderRadius:null==s?void 0:s.borderRadius,shadow:null==s?void 0:s.shadow,fontFamily:null==(t=null==s?void 0:s.font)?void 0:t.family,fontSize:null==(n=null==s?void 0:s.font)?void 0:n.size,fontWeight:null==(o=null==s?void 0:s.font)?void 0:o.weight,textColor:null==(l=null==s?void 0:s.font)?void 0:l.color,onClick:()=>{this._message&&this.onItemActionClick&&this.onItemActionClick(this._message,e)}});null==(r=this._actionsContainer)||r.appendChild(a)})))}}i.registerElement(b);class _ extends i.CourierBaseElement{constructor(e){super(),o(this,"_theme"),o(this,"_style"),this._theme=e}static get id(){return"courier-inbox-skeleton-list-item"}onComponentMounted(){this._style=i.injectGlobalStyle(_.id,_.getStyles(this._theme)),this.render()}onComponentUnmounted(){var e;null==(e=this._style)||e.remove()}render(){const e=new C(this._theme),t=new C(this._theme),i=new C(this._theme);this.appendChild(e),this.appendChild(t),this.appendChild(i)}static getStyles(e){return`\n ${_.id} {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px 20px 16px 20px;\n width: 100%;\n box-sizing: border-box;\n }\n\n ${_.id} > *:first-child {\n width: 35%;\n }\n\n ${_.id} > *:nth-child(2) {\n width: 100%;\n }\n\n ${_.id} > *:nth-child(3) {\n width: 82%;\n }\n `}}i.registerElement(_);class C extends i.CourierBaseElement{constructor(e){super(),o(this,"_theme"),o(this,"_style"),this._theme=e}static get id(){return"courier-skeleton-animated-row"}onComponentMounted(){this._style=i.injectGlobalStyle(C.id,C.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,i,n,o,s,l,r,a,d,u,h,c;const v=(null==(n=null==(i=null==(t=e.inbox)?void 0:t.loading)?void 0:i.animation)?void 0:n.barColor)??"#000",g=4===v.length?`#${v[1]}${v[1]}${v[2]}${v[2]}${v[3]}${v[3]}`:v,p=parseInt(g.slice(1,3),16),m=parseInt(g.slice(3,5),16),b=parseInt(g.slice(5,7),16),_=`rgba(${p}, ${m}, ${b}, 0.8)`,f=`rgba(${p}, ${m}, ${b}, 0.4)`;return`\n ${C.id} {\n display: flex;\n height: 100%;\n width: 100%;\n align-items: flex-start;\n justify-content: flex-start;\n }\n\n ${C.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 ${_} 25%,\n ${f} 50%,\n ${_} 75%\n );\n background-size: 200% 100%;\n animation: ${C.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 ${C.id}-shimmer {\n 0% {\n background-position: 200% 0;\n }\n 100% {\n background-position: -200% 0;\n }\n }\n `}}i.registerElement(C);class f extends i.CourierFactoryElement{constructor(e){super(),o(this,"_theme"),o(this,"_style"),this._theme=e}static get id(){return"courier-inbox-skeleton-list"}onComponentMounted(){this._style=i.injectGlobalStyle(f.id,f.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 _(this._theme);e.appendChild(t)}return this.appendChild(e),e}static getStyles(e){var t,i,n,o;return`\n ${f.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 ${f.id} .list {\n display: flex;\n flex-direction: column;\n width: 100%;\n overflow: hidden;\n }\n\n ${f.id} .list > * {\n border-bottom: ${(null==(i=null==(t=e.inbox)?void 0:t.loading)?void 0:i.divider)??"1px solid red"};\n opacity: 100%;\n }\n\n ${f.id} .list > *:nth-child(2) {\n border-bottom: ${(null==(o=null==(n=e.inbox)?void 0:n.loading)?void 0:o.divider)??"1px solid red"};\n opacity: 88%;\n }\n\n ${f.id} .list > *:nth-child(3) {\n border-bottom: none;\n opacity: 50%;\n }\n `}}i.registerElement(f);class x extends i.CourierBaseElement{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=i.injectGlobalStyle(x.id,x.getStyles(this._theme)),this._customItem)this.appendChild(this._customItem);else{const e=document.createElement("div");e.className="skeleton-container",this._skeletonLoadingList=new f(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 ${x.id} {\n padding: 0;\n margin: 0;\n box-sizing: border-box;\n }\n\n ${x.id} .skeleton-container {\n height: 150%;\n }\n `}}function y(e){return m.shared.openMessage({message:e})}function k(){return[{feedId:"inbox_feed",title:"Inbox",iconSVG:i.CourierIconSVGs.inbox,tabs:[{datasetId:"all_messages",title:"All Messages",filter:{}}]},{feedId:"archive_feed",title:"Archive",iconSVG:i.CourierIconSVGs.archive,tabs:[{datasetId:"archived_messages",title:"Archived Messages",filter:{archived:!0}}]}]}function I(){return[{id:"readAll"},{id:"archiveRead"},{id:"archiveAll"}]}function w(){return[{id:"read_unread"},{id:"archive_unarchive"}]}i.registerElement(x);class M extends i.CourierBaseElement{constructor(e){super(),o(this,"_themeSubscription"),o(this,"_messages",[]),o(this,"_datasetId",k()[0].tabs[0].datasetId),o(this,"_isLoading",!0),o(this,"_error",null),o(this,"_canPaginate",!1),o(this,"_canClickListItems",!1),o(this,"_canLongPressListItems",!1),o(this,"_listItemActions",D.defaultListItemActions()),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"),o(this,"_errorContainer"),o(this,"_emptyContainer"),this._onRefresh=e.onRefresh,this._onPaginationTrigger=e.onPaginationTrigger,this._onMessageClick=e.onMessageClick,this._onMessageActionClick=e.onMessageActionClick,this._onMessageLongPress=e.onMessageLongPress,e.listItemActions&&(this._listItemActions=e.listItemActions),this._themeSubscription=e.themeManager.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-inbox-list"}get messages(){return this._messages}get theme(){return this._themeSubscription.manager.getTheme()}onComponentMounted(){this._listStyles=i.injectGlobalStyle(M.id,M.getStyles(this.theme)),this._listItemStyles=i.injectGlobalStyle(b.id,b.getStyles(this.theme)),this._listItemMenuStyles=i.injectGlobalStyle(v.id,v.getStyles(this.theme)),this.render()}onComponentUnmounted(){var e,t,i;this._themeSubscription.unsubscribe(),null==(e=this._listStyles)||e.remove(),null==(t=this._listItemStyles)||t.remove(),null==(i=this._listItemMenuStyles)||i.remove()}setCanClickListItems(e){this._canClickListItems=e}setCanLongPressListItems(e){this._canLongPressListItems=e}setListItemActions(e){this._listItemActions=e,this.render()}static getStyles(e){var t;const i=null==(t=e.inbox)?void 0:t.list,n=null==i?void 0:i.scrollbar;return`\n ${M.id} {\n flex: 1;\n width: 100%;\n background-color: ${(null==i?void 0:i.backgroundColor)??"red"};\n scrollbar-width: ${(null==n?void 0:n.width)??"thin"};\n scrollbar-color: ${(null==n?void 0:n.thumbColor)??"rgba(0, 0, 0, 0.2)"} ${(null==n?void 0:n.trackBackgroundColor)??"transparent"};\n }\n\n ${M.id} ul {\n list-style: none;\n padding: 0;\n margin: 0;\n height: 100%;\n }\n\n /* Webkit scrollbar styling - show thumb, hide track background, overlay above content */\n ${M.id}::-webkit-scrollbar {\n width: ${(null==n?void 0:n.width)??"8px"};\n height: ${(null==n?void 0:n.height)??"8px"};\n }\n\n ${M.id}::-webkit-scrollbar-track {\n background: ${(null==n?void 0:n.trackBackgroundColor)??"transparent"};\n }\n\n ${M.id}::-webkit-scrollbar-thumb {\n background: ${(null==n?void 0:n.thumbColor)??"rgba(0, 0, 0, 0.2)"};\n border-radius: ${(null==n?void 0:n.borderRadius)??"4px"};\n }\n\n ${M.id}::-webkit-scrollbar-thumb:hover {\n background: ${(null==n?void 0:n.thumbHoverColor)??(null==n?void 0:n.thumbColor)??"rgba(0, 0, 0, 0.3)"};\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()}selectDataset(e){this._datasetId=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()}refreshTheme(){this._listStyles&&(this._listStyles.textContent=M.getStyles(this.theme)),this._listItemStyles&&(this._listItemStyles.textContent=b.getStyles(this.theme)),this._listItemMenuStyles&&(this._listItemMenuStyles.textContent=v.getStyles(this.theme)),this.refreshInfoStateThemes()}refreshInfoStateThemes(){var e,t;null==(e=this._emptyContainer)||e.updateStyles(this.errorProps),null==(t=this._emptyContainer)||t.updateStyles(this.emptyProps)}get errorProps(){var e,t,i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f,x,y,k,I,w;const M=null==(e=this.theme.inbox)?void 0:e.error,S=this._themeSubscription.manager.mode;return{title:{text:(null==(t=null==M?void 0:M.title)?void 0:t.text)??(null==(i=this._error)?void 0:i.message),textColor:null==(o=null==(n=null==M?void 0:M.title)?void 0:n.font)?void 0:o.color,fontFamily:null==(l=null==(s=null==M?void 0:M.title)?void 0:s.font)?void 0:l.family,fontSize:null==(a=null==(r=null==M?void 0:M.title)?void 0:r.font)?void 0:a.size,fontWeight:null==(u=null==(d=null==M?void 0:M.title)?void 0:d.font)?void 0:u.weight},button:{mode:S,text:null==(h=null==M?void 0:M.button)?void 0:h.text,backgroundColor:null==(c=null==M?void 0:M.button)?void 0:c.backgroundColor,hoverBackgroundColor:null==(v=null==M?void 0:M.button)?void 0:v.hoverBackgroundColor,activeBackgroundColor:null==(g=null==M?void 0:M.button)?void 0:g.activeBackgroundColor,textColor:null==(m=null==(p=null==M?void 0:M.button)?void 0:p.font)?void 0:m.color,fontFamily:null==(_=null==(b=null==M?void 0:M.button)?void 0:b.font)?void 0:_.family,fontSize:null==(f=null==(C=null==M?void 0:M.button)?void 0:C.font)?void 0:f.size,fontWeight:null==(y=null==(x=null==M?void 0:M.button)?void 0:x.font)?void 0:y.weight,shadow:null==(k=null==M?void 0:M.button)?void 0:k.shadow,border:null==(I=null==M?void 0:M.button)?void 0:I.border,borderRadius:null==(w=null==M?void 0:M.button)?void 0:w.borderRadius,onClick:()=>this.handleRetry()}}}get emptyProps(){var e,t,i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f,x,y,k,I;const w=null==(e=this.theme.inbox)?void 0:e.empty,M=this._themeSubscription.manager.mode;return{title:{text:(null==(t=null==w?void 0:w.title)?void 0:t.text)??"No Messages",textColor:null==(n=null==(i=null==w?void 0:w.title)?void 0:i.font)?void 0:n.color,fontFamily:null==(s=null==(o=null==w?void 0:w.title)?void 0:o.font)?void 0:s.family,fontSize:null==(r=null==(l=null==w?void 0:w.title)?void 0:l.font)?void 0:r.size,fontWeight:null==(d=null==(a=null==w?void 0:w.title)?void 0:a.font)?void 0:d.weight},button:{mode:M,text:null==(u=null==w?void 0:w.button)?void 0:u.text,backgroundColor:null==(h=null==w?void 0:w.button)?void 0:h.backgroundColor,hoverBackgroundColor:null==(c=null==w?void 0:w.button)?void 0:c.hoverBackgroundColor,activeBackgroundColor:null==(v=null==w?void 0:w.button)?void 0:v.activeBackgroundColor,textColor:null==(p=null==(g=null==w?void 0:w.button)?void 0:g.font)?void 0:p.color,fontFamily:null==(b=null==(m=null==w?void 0:w.button)?void 0:m.font)?void 0:b.family,fontSize:null==(C=null==(_=null==w?void 0:w.button)?void 0:_.font)?void 0:C.size,fontWeight:null==(x=null==(f=null==w?void 0:w.button)?void 0:f.font)?void 0:x.weight,shadow:null==(y=null==w?void 0:w.button)?void 0:y.shadow,border:null==(k=null==w?void 0:w.button)?void 0:k.border,borderRadius:null==(I=null==w?void 0:w.button)?void 0:I.borderRadius,onClick:()=>this.handleRefresh()}}}render(){for(var e,t,n,o;this.firstChild;)this.removeChild(this.firstChild),this._errorContainer=void 0,this._emptyContainer=void 0;if(this.refreshTheme(),this._error)return this._errorContainer=new i.CourierInfoState(this.errorProps),this._errorContainer.build(null==(e=this._errorStateFactory)?void 0:e.call(this,{datasetId:this._datasetId,error:this._error})),void this.appendChild(this._errorContainer);if(this._isLoading){const e=new f(this.theme);return e.build(null==(t=this._loadingStateFactory)?void 0:t.call(this,{datasetId:this._datasetId})),void this.appendChild(e)}if(0===this._messages.length)return this._emptyContainer=new i.CourierInfoState(this.emptyProps),this._emptyContainer.build(null==(n=this._emptyStateFactory)?void 0:n.call(this,{datasetId:this._datasetId})),void this.appendChild(this._emptyContainer);const s=document.createElement("ul");if(this.appendChild(s),this._messages.forEach(((e,t)=>{if(this._listItemFactory)return void s.appendChild(this._listItemFactory({message:e,index:t}));const i=new b(this._themeSubscription.manager,this._canClickListItems,this._canLongPressListItems,this._listItemActions);i.setMessage(e),i.setOnItemClick((e=>{var i;return null==(i=this._onMessageClick)?void 0:i.call(this,e,t)})),i.setOnItemActionClick(((e,i)=>{var n;return null==(n=this._onMessageActionClick)?void 0:n.call(this,e,i,t)})),i.setOnItemLongPress((e=>{var i;return null==(i=this._onMessageLongPress)?void 0:i.call(this,e,t)})),i.setOnItemVisible((e=>this.openVisibleMessage(e))),s.appendChild(i)})),this._canPaginate){const e=new x({theme:this.theme,customItem:null==(o=this._paginationItemFactory)?void 0:o.call(this,{datasetId:this._datasetId}),onPaginationTrigger:()=>{var e;return null==(e=this._onPaginationTrigger)?void 0:e.call(this,this._datasetId)}});s.appendChild(e)}}async openVisibleMessage(e){try{await y(e)}catch(t){}}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()}scrollToTop(e=!0){this.scrollTo({top:0,behavior:e?"smooth":"instant"})}}i.registerElement(M);class S extends i.CourierBaseElement{constructor(e){super(),o(this,"_themeSubscription"),o(this,"_location"),o(this,"_count",0),o(this,"_style"),o(this,"_shadowRoot"),o(this,"_container"),this._location=e.location,this._themeSubscription=e.themeBus.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-unread-count-badge"}get theme(){return this._themeSubscription.manager.getTheme()}onComponentMounted(){this.attachElements(),this.setActive(!0),this.updateBadge()}attachElements(){this._shadowRoot=this.attachShadow({mode:"closed"}),this._container=document.createElement("div"),this._container.className="badge-container",this._style=document.createElement("style"),this._style.textContent=this.getStyles(),this._shadowRoot.appendChild(this._style),this._shadowRoot.appendChild(this._container)}onComponentUnmounted(){this._themeSubscription.unsubscribe()}static getThemePath(e,t,i){var n,o,s,l,r,a,d,u;if("tab"===t){const t=null==(o=null==(n=e.inbox)?void 0:n.header)?void 0:o.tabs;return i?null==(s=null==t?void 0:t.selected)?void 0:s.unreadIndicator:null==(l=null==t?void 0:t.default)?void 0:l.unreadIndicator}return null==(u=null==(d=null==(a=null==(r=e.inbox)?void 0:r.header)?void 0:a.feeds)?void 0:d.button)?void 0:u.unreadCountIndicator}static getStyles(e,t="feed"){var i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f,x;const y=S.getThemePath(e,t,!0),k=S.getThemePath(e,t,!1),I=null==(s=null==(o=null==(n=null==(i=e.inbox)?void 0:i.header)?void 0:n.feeds)?void 0:o.button)?void 0:s.unreadCountIndicator;return`\n :host {\n display: inline-block;\n }\n\n .badge-container {\n display: none;\n pointer-events: none;\n }\n\n :host(.active) .badge-container {\n display: inline-block;\n background-color: ${(null==y?void 0:y.backgroundColor)??(null==I?void 0:I.backgroundColor)};\n color: ${(null==(l=null==y?void 0:y.font)?void 0:l.color)??(null==(r=null==I?void 0:I.font)?void 0:r.color)};\n border-radius: ${(null==y?void 0:y.borderRadius)??(null==I?void 0:I.borderRadius)};\n font-size: ${(null==(a=null==y?void 0:y.font)?void 0:a.size)??(null==(d=null==I?void 0:I.font)?void 0:d.size)};\n font-family: ${(null==(u=null==y?void 0:y.font)?void 0:u.family)??(null==(h=null==I?void 0:I.font)?void 0:h.family)??"inherit"};\n font-weight: ${(null==(c=null==y?void 0:y.font)?void 0:c.weight)??(null==(v=null==I?void 0:I.font)?void 0:v.weight)??"inherit"};\n padding: ${(null==y?void 0:y.padding)??(null==I?void 0:I.padding)};\n }\n\n :host(.inactive) .badge-container {\n display: inline-block;\n background-color: ${(null==k?void 0:k.backgroundColor)??(null==I?void 0:I.backgroundColor)};\n color: ${(null==(g=null==k?void 0:k.font)?void 0:g.color)??(null==(p=null==I?void 0:I.font)?void 0:p.color)};\n border-radius: ${(null==k?void 0:k.borderRadius)??(null==I?void 0:I.borderRadius)};\n font-size: ${(null==(m=null==k?void 0:k.font)?void 0:m.size)??(null==(b=null==I?void 0:I.font)?void 0:b.size)};\n font-family: ${(null==(_=null==k?void 0:k.font)?void 0:_.family)??(null==(C=null==I?void 0:I.font)?void 0:C.family)??"inherit"};\n font-weight: ${(null==(f=null==k?void 0:k.font)?void 0:f.weight)??(null==(x=null==I?void 0:I.font)?void 0:x.weight)??"inherit"};\n padding: ${(null==k?void 0:k.padding)??(null==I?void 0:I.padding)};\n }\n `}getStyles(){return S.getStyles(this.theme,this._location)}setCount(e){this._count=e,this.updateBadge()}setActive(e){this.className=e?"active":"inactive",this._style&&(this._style.textContent=this.getStyles()),this.updateBadge()}refreshTheme(){this._style&&(this._style.textContent=this.getStyles()),this.updateBadge()}updateBadge(){this._container&&(this._count>0?(this.style.display="inline-block",this._container.textContent=this._count>99?"99+":this._count.toString()):(this.style.display="none",this._container.textContent=""))}}i.registerElement(S);class $ extends i.CourierBaseElement{constructor(e,t){super(),o(this,"_themeSubscription"),o(this,"_feeds"),o(this,"_selectedFeed"),o(this,"_style"),o(this,"_iconElement"),o(this,"_titleElement"),o(this,"_switchIconElement"),o(this,"_unreadBadge"),this._feeds=t,this._themeSubscription=e.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-inbox-header-title"}get selectedFeed(){return this._selectedFeed}get theme(){return this._themeSubscription.manager.getTheme()}getStyles(e){var t,i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f,x,y,k,I,w,M,S,T,E,L,B,F;const A=this._feeds.length>1,P=A?`${$.id}:hover {\n background: ${(null==(o=null==(n=null==(i=null==(t=e.inbox)?void 0:t.header)?void 0:i.feeds)?void 0:n.button)?void 0:o.hoverBackgroundColor)??"red"};\n }`:"",R=A?`${$.id}:active {\n background: ${(null==(a=null==(r=null==(l=null==(s=e.inbox)?void 0:s.header)?void 0:l.feeds)?void 0:r.button)?void 0:a.activeBackgroundColor)??"red"};\n }`:"";return`\n ${$.id} {\n display: flex;\n align-items: center;\n gap: 8px;\n position: relative;\n transition: ${(null==(c=null==(h=null==(u=null==(d=e.inbox)?void 0:d.header)?void 0:u.feeds)?void 0:h.button)?void 0:c.transition)??"all 0.2s ease"};\n border-radius: 6px;\n padding-top: 4px;\n padding-bottom: 4px;\n padding-left: 4px;\n padding-right: 8px;\n }\n\n ${P}\n\n ${R}\n\n ${$.id} courier-icon {\n display: flex;\n align-items: center;\n }\n\n ${$.id} .title-container {\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 0px;\n }\n\n ${$.id} .title-container h2 {\n margin: 0;\n font-family: ${(null==(b=null==(m=null==(p=null==(g=null==(v=e.inbox)?void 0:v.header)?void 0:g.feeds)?void 0:p.button)?void 0:m.font)?void 0:b.family)??"inherit"};\n font-size: ${(null==(y=null==(x=null==(f=null==(C=null==(_=e.inbox)?void 0:_.header)?void 0:C.feeds)?void 0:f.button)?void 0:x.font)?void 0:y.size)??"16px"};\n font-weight: ${(null==(S=null==(M=null==(w=null==(I=null==(k=e.inbox)?void 0:k.header)?void 0:I.feeds)?void 0:w.button)?void 0:M.font)?void 0:S.weight)??"500"};\n color: ${(null==(F=null==(B=null==(L=null==(E=null==(T=e.inbox)?void 0:T.header)?void 0:E.feeds)?void 0:L.button)?void 0:B.font)?void 0:F.color)??"red"};\n }\n\n `}onComponentMounted(){this.render()}onComponentUnmounted(){var e;this._themeSubscription.unsubscribe(),null==(e=this._style)||e.remove()}render(){var e,t,n,o;this._style=i.injectGlobalStyle($.id,this.getStyles(this.theme)),this._iconElement=new i.CourierIcon,this.appendChild(this._iconElement);const s=document.createElement("div");s.className="title-container",this._titleElement=document.createElement("h2"),s.appendChild(this._titleElement);const l=null==(o=null==(n=null==(t=null==(e=this.theme.inbox)?void 0:e.header)?void 0:t.feeds)?void 0:n.button)?void 0:o.changeFeedIcon;this._switchIconElement=new i.CourierIcon((null==l?void 0:l.color)??"red",(null==l?void 0:l.svg)??i.CourierIconSVGs.chevronDown),this._switchIconElement.style.display=this._feeds.length>1?"flex":"none",s.appendChild(this._switchIconElement),this.appendChild(s),this._unreadBadge=new S({themeBus:this._themeSubscription.manager,location:"feed"}),this.appendChild(this._unreadBadge),this.refreshTheme()}setUnreadCount(e){var t;null==(t=this._unreadBadge)||t.setCount(e)}setFeeds(e){this._feeds=e,this._switchIconElement&&(this._switchIconElement.style.display=this._feeds.length>1?"flex":"none"),this.refreshTheme()}setSelectedFeed(e){this._selectedFeed=this._feeds.find((t=>t.feedId===e)),this.refreshSelectedFeed()}refreshTheme(){this._style&&(this._style.textContent=this.getStyles(this.theme)),this.refreshSelectedFeed(),this.refreshSwitchIcon(),this.refreshUnreadBadge()}refreshSelectedFeed(){var e,t,n,o,s,l;this._selectedFeed&&(null==(e=this._iconElement)||e.updateSVG(this._selectedFeed.iconSVG??i.CourierIconSVGs.inbox),null==(l=this._iconElement)||l.updateColor((null==(s=null==(o=null==(n=null==(t=this.theme.inbox)?void 0:t.header)?void 0:n.feeds)?void 0:o.button)?void 0:s.selectedFeedIconColor)??"red"),this._titleElement&&(this._titleElement.textContent=this._selectedFeed.title))}refreshSwitchIcon(){var e,t,n,o;if(this._switchIconElement){const s=null==(o=null==(n=null==(t=null==(e=this.theme.inbox)?void 0:e.header)?void 0:t.feeds)?void 0:n.button)?void 0:o.changeFeedIcon;this._switchIconElement.updateSVG((null==s?void 0:s.svg)??i.CourierIconSVGs.chevronDown),this._switchIconElement.updateColor((null==s?void 0:s.color)??"red")}}refreshUnreadBadge(){this._unreadBadge&&this._unreadBadge.refreshTheme()}}i.registerElement($);class T extends i.CourierBaseElement{constructor(e){super(),o(this,"_themeManager"),o(this,"_themeSubscription"),o(this,"_selectedTabId"),o(this,"_tabs",[]),o(this,"_onTabClick"),o(this,"_onTabReselected"),o(this,"_tabBadges",new Map),o(this,"_style"),this._themeManager=e.themeManager,this._onTabClick=e.onTabClick,this._onTabReselected=e.onTabReselected,this._themeSubscription=e.themeManager.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-inbox-tabs"}get theme(){return this._themeSubscription.manager.getTheme()}onComponentMounted(){this._style=i.injectGlobalStyle(T.id,T.getStyles(this.theme)),this.render()}onComponentUnmounted(){var e;this._themeSubscription.unsubscribe(),null==(e=this._style)||e.remove()}render(){this.innerHTML="";const e=document.createElement("div");e.className="tab-container";for(let t of this._tabs){const i=this.createTab(t);e.appendChild(i)}this.appendChild(e),this.refreshTheme()}static getStyles(e){var t,i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f;const x=null==(i=null==(t=e.inbox)?void 0:t.header)?void 0:i.tabs;return`\n ${T.id} {\n position: relative;\n width: 100%;\n max-width: 100%;\n min-width: 0;\n margin-top: -5px;\n overflow-x: auto;\n scrollbar-width: none; /* Firefox */\n -ms-overflow-style: none; /* IE and Edge */\n height: 41px;\n }\n\n ${T.id}::-webkit-scrollbar {\n display: none;\n }\n\n ${T.id} .tab-container {\n display: flex;\n flex-direction: row;\n gap: 4px;\n padding: 0 10px;\n width: fit-content;\n height: 100%;\n }\n\n ${T.id} .tab-item {\n position: relative;\n display: flex;\n align-items: center;\n cursor: pointer;\n transition: ${(null==x?void 0:x.transition)??"all 0.2s ease"};\n user-select: none;\n padding: 0 10px;\n flex-shrink: 0;\n height: 100%;\n ${(e=>{if(!e)return"";if("string"==typeof e)return`border-radius: ${e};`;const t=[];return e.topLeft?t.push(e.topLeft):t.push("0"),e.topRight?t.push(e.topRight):t.push("0"),e.bottomRight?t.push(e.bottomRight):t.push("0"),e.bottomLeft?t.push(e.bottomLeft):t.push("0"),`border-radius: ${t.join(" ")};`})(null==x?void 0:x.borderRadius)}\n }\n\n ${T.id} .tab {\n position: relative;\n display: flex;\n align-items: center;\n gap: 8px;\n border-bottom: ${(null==(n=null==x?void 0:x.default)?void 0:n.indicatorHeight)??"1px"} solid ${(null==(o=null==x?void 0:x.default)?void 0:o.indicatorColor)??"transparent"};\n height: 40px;\n min-width: 40px;\n justify-content: center;\n position: relative;\n }\n\n ${T.id} .tab-item:hover {\n background-color: ${(null==(s=null==x?void 0:x.default)?void 0:s.hoverBackgroundColor)??"transparent"};\n }\n\n ${T.id} .tab-item:active {\n background-color: ${(null==(l=null==x?void 0:x.default)?void 0:l.activeBackgroundColor)??"transparent"};\n }\n\n ${T.id} .tab.selected {\n border-bottom: ${(null==(r=null==x?void 0:x.selected)?void 0:r.indicatorHeight)??"1px"} solid ${(null==(a=null==x?void 0:x.selected)?void 0:a.indicatorColor)??"transparent"};\n }\n\n ${T.id} .tab-item:hover.selected {\n background-color: ${(null==(d=null==x?void 0:x.selected)?void 0:d.hoverBackgroundColor)??"transparent"};\n }\n\n ${T.id} .tab-item:active.selected {\n background-color: ${(null==(u=null==x?void 0:x.selected)?void 0:u.activeBackgroundColor)??"transparent"};\n }\n\n ${T.id} .tab-label {\n font-size: ${(null==(c=null==(h=null==x?void 0:x.default)?void 0:h.font)?void 0:c.size)??"14px"};\n font-family: ${(null==(g=null==(v=null==x?void 0:x.default)?void 0:v.font)?void 0:g.family)??"inherit"};\n font-weight: ${(null==(m=null==(p=null==x?void 0:x.default)?void 0:p.font)?void 0:m.weight)??"inherit"};\n color: ${(null==(_=null==(b=null==x?void 0:x.default)?void 0:b.font)?void 0:_.color)??"red"};\n user-select: none;\n white-space: nowrap;\n }\n\n ${T.id} .tab.selected .tab-label {\n color: ${(null==(f=null==(C=null==x?void 0:x.selected)?void 0:C.font)?void 0:f.color)??"red"};\n }\n `}setTabs(e){this._tabs=e,this._tabBadges.clear(),this.render()}setSelectedTab(e){this._selectedTabId=e,this.reloadTabs(),this.updateBadgeStates()}updateTabUnreadCount(e,t){const i=this._tabBadges.get(e);i&&i.setCount(t)}scrollToStart(e=!0){e?this.scrollTo({left:0,behavior:"smooth"}):this.scrollLeft=0}refreshTheme(){this._style&&(this._style.textContent=T.getStyles(this.theme))}reloadTabs(){const e=this.querySelector(".tab-container");if(e)for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.classList.contains("tab-item")){const e=t.getAttribute("data-tab-id"),i=t.querySelector(".tab");i instanceof HTMLElement&&(e===this._selectedTabId?i.classList.add("selected"):i.classList.remove("selected"))}}updateBadgeStates(){for(let[e,t]of this._tabBadges)t.setActive(e===this._selectedTabId)}createTab(e){const t=document.createElement("div");t.className="tab-item",t.setAttribute("data-tab-id",e.datasetId);const i=document.createElement("div");i.className="tab",e.datasetId===this._selectedTabId&&i.classList.add("selected");const n=document.createElement("div");n.className="tab-label",n.innerText=e.title;const o=new S({themeBus:this._themeManager,location:"tab"});return this._tabBadges.set(e.datasetId,o),i.appendChild(n),i.appendChild(o),t.appendChild(i),t.addEventListener("click",(()=>{e.datasetId===this._selectedTabId?this._onTabReselected(e):this._onTabClick(e)})),t}}i.registerElement(T);class E extends i.CourierBaseElement{constructor(e){super(),o(this,"_option"),o(this,"_isSelectedable"),o(this,"_isSelected"),o(this,"_theme"),o(this,"_content"),o(this,"_itemIcon"),o(this,"_title"),o(this,"_selectionIcon"),this._option=e.option,this._isSelected=e.isSelected,this._isSelectedable=e.selectable,this._theme=e.themeManager}static get id(){return"courier-inbox-option-menu-item"}onComponentMounted(){this._content=document.createElement("div"),this._content.className="menu-item",this._itemIcon=new i.CourierIcon(this._option.icon.svg??i.CourierIconSVGs.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 i.CourierIcon(i.CourierIconSVGs.check),this._selectionIcon.classList.add("check-icon"),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.updateSelectionState(),this.refreshTheme()}refreshTheme(){var e,t,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_;this._title&&(this._title.textContent=this._option.text??"Missing Text");const C=this._theme.getTheme();null==(r=this._selectionIcon)||r.updateColor((null==(l=null==(s=null==(o=null==(n=null==(t=null==(e=C.inbox)?void 0:e.header)?void 0:t.feeds)?void 0:n.menu)?void 0:o.list)?void 0:s.selectedIcon)?void 0:l.color)??"red"),null==(g=this._selectionIcon)||g.updateSVG((null==(v=null==(c=null==(h=null==(u=null==(d=null==(a=C.inbox)?void 0:a.header)?void 0:d.feeds)?void 0:u.menu)?void 0:h.list)?void 0:c.selectedIcon)?void 0:v.svg)??i.CourierIconSVGs.check),null==(m=this._itemIcon)||m.updateColor((null==(p=this._option.icon)?void 0:p.color)??"red"),null==(_=this._itemIcon)||_.updateSVG((null==(b=this._option.icon)?void 0:b.svg)??i.CourierIconSVGs.inbox)}setSelected(e){this._isSelected=e,this.updateSelectionState()}updateSelectionState(){this._selectionIcon&&(this._selectionIcon.style.display=this._isSelected?"block":"none")}}i.registerElement(E);class L extends i.CourierBaseElement{constructor(e,t,i,n,s){super(),o(this,"_themeSubscription"),o(this,"_selectedIndex",0),o(this,"_options"),o(this,"_selectable"),o(this,"_onMenuOpen"),o(this,"_isOpen",!1),o(this,"_menuType"),o(this,"_style"),o(this,"_shadowRoot"),o(this,"_container"),this._selectable=t,this._options=i,this._onMenuOpen=s,this._menuType=n,this._themeSubscription=e.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-inbox-option-menu"}onComponentMounted(){this.attachElements(),document.addEventListener("click",this.handleOutsideClick.bind(this)),this.refreshTheme()}onComponentUnmounted(){this._themeSubscription.unsubscribe()}attachElements(){this._shadowRoot=this.attachShadow({mode:"closed"}),this._container=document.createElement("div"),this._container.className="menu-container",this._style=document.createElement("style"),this._style.textContent=this.getStyles(),this._shadowRoot.appendChild(this._style),this._shadowRoot.appendChild(this._container)}getStyles(){var e,t,i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f,x,y,k,I,w,M;const S=this._themeSubscription.manager.getTheme(),$="feed"===this._menuType?null==(n=null==(i=null==(t=null==(e=S.inbox)?void 0:e.header)?void 0:t.feeds)?void 0:i.menu)?void 0:n.animation:null==(l=null==(s=null==(o=S.inbox)?void 0:o.header)?void 0:s.actions)?void 0:l.animation,T="feed"===this._menuType?null==(d=null==(a=null==(r=S.inbox)?void 0:r.header)?void 0:a.feeds)?void 0:d.menu:(null==(c=null==(h=null==(u=S.inbox)?void 0:u.header)?void 0:h.actions)?void 0:c.menu)??(null==(p=null==(g=null==(v=S.inbox)?void 0:v.header)?void 0:g.feeds)?void 0:p.menu),L=(null==$?void 0:$.initialTransform)??"translate3d(0, 0, 0)",B=(null==$?void 0:$.visibleTransform)??"translate3d(0, 0, 0)";return`\n :host {\n position: absolute;\n top: 42px;\n z-index: 1000;\n min-width: 200px;\n user-select: none;\n opacity: 0;\n pointer-events: none;\n transition: ${(null==$?void 0:$.transition)??"all 0.2s ease"};\n transform: ${L};\n will-change: transform, opacity;\n display: none;\n }\n\n :host(.displayed) {\n display: block;\n }\n\n :host(.visible) {\n opacity: 1;\n pointer-events: auto;\n transform: ${B};\n }\n\n .menu-container {\n display: flex;\n flex-direction: column;\n border-radius: ${(null==T?void 0:T.borderRadius)??"6px"};\n border: ${(null==T?void 0:T.border)??"1px solid red"};\n background: ${(null==T?void 0:T.backgroundColor)??"red"};\n box-shadow: ${(null==T?void 0:T.shadow)??"0 4px 12px 0 red"};\n overflow: hidden;\n padding: 4px 0;\n }\n\n courier-inbox-option-menu-item {\n border-bottom: ${(null==(m=null==T?void 0:T.list)?void 0:m.divider)??"none"};\n }\n\n courier-inbox-option-menu-item:last-child {\n border-bottom: none;\n }\n\n ${E.id} {\n display: flex;\n flex-direction: row;\n padding: 6px 12px;\n cursor: pointer;\n }\n\n ${E.id}:hover {\n background-color: ${(null==(b=null==T?void 0:T.list)?void 0:b.hoverBackgroundColor)??"red"};\n }\n\n ${E.id}:active {\n background-color: ${(null==(_=null==T?void 0:T.list)?void 0:_.activeBackgroundColor)??"red"};\n }\n\n ${E.id} .menu-item {\n display: flex;\n align-items: center;\n width: 100%;\n gap: 12px;\n }\n\n ${E.id} .spacer {\n flex: 1;\n }\n\n ${E.id} p {\n margin: 0;\n font-family: ${(null==(f=null==(C=null==T?void 0:T.list)?void 0:C.font)?void 0:f.family)??"inherit"};\n font-weight: ${(null==(y=null==(x=null==T?void 0:T.list)?void 0:x.font)?void 0:y.weight)??"inherit"};\n font-size: ${(null==(I=null==(k=null==T?void 0:T.list)?void 0:k.font)?void 0:I.size)??"14px"};\n color: ${(null==(M=null==(w=null==T?void 0:T.list)?void 0:w.font)?void 0:M.color)??"red"};\n white-space: nowrap;\n }\n\n ${E.id} .check-icon {\n display: block;\n }\n `}setPosition(e){this.style.left=e.left??"auto",this.style.right=e.right??"auto",this.style.top=e.top??"auto"}refreshTheme(){this._style&&(this._style.textContent=this.getStyles()),this.refreshMenuItems()}setOptions(e){this._options=e,this.refreshMenuItems()}refreshMenuItems(){if(!this._container)return;const e=this._container;e.innerHTML="",this._options.forEach(((t,i)=>{const n=new E({option:t,selectable:this._selectable,isSelected:this._selectedIndex===i,themeManager:this._themeSubscription.manager});n.addEventListener("click",(()=>{this._selectable&&this.selectionItemAtIndex(i),t.onClick(t),this.closeMenu()})),e.appendChild(n)}))}toggleMenu(){var e;this._isOpen=!this._isOpen,this._isOpen?(this.showMenu(),null==(e=this._onMenuOpen)||e.call(this)):this.hideMenu()}showMenu(){this.classList.remove("visible"),this.classList.add("displayed"),requestAnimationFrame((()=>{requestAnimationFrame((()=>{this.classList.add("visible")}))}))}hideMenu(){this.classList.remove("visible");if(!window.getComputedStyle(this).transitionDuration.split(",").map((e=>parseFloat(e)||0)).some((e=>e>0)))return void this.classList.remove("displayed");const e=t=>{t.target===this&&(this.classList.contains("visible")||(this.classList.remove("displayed"),this.removeEventListener("transitionend",e)))};this.addEventListener("transitionend",e)}closeMenu(){this._isOpen=!1,this.hideMenu()}handleOutsideClick(e){const t=e.target;this.contains(t)||this.closeMenu()}selectionItemAtIndex(e){this._selectable&&this._container&&(this._selectedIndex=e,this._options.forEach(((t,i)=>{var n;const o=null==(n=this._container)?void 0:n.children[i];o&&o.setSelected&&o.setSelected(i===e)})))}}i.registerElement(L);class B extends i.CourierFactoryElement{constructor(e){super(),o(this,"_themeSubscription"),o(this,"_feeds",[]),o(this,"_currentFeedId"),o(this,"_actions",D.defaultActions()),o(this,"_feedButton"),o(this,"_feedMenu"),o(this,"_actionMenuButton"),o(this,"_actionMenu"),o(this,"tabs"),o(this,"_style"),o(this,"_feedButtonClickHandler"),o(this,"_onFeedChange"),o(this,"_onFeedReselected"),o(this,"_onTabChange"),o(this,"_onTabReselected"),this._themeSubscription=e.themeManager.subscribe((e=>{this.refreshTheme()})),e.actions&&(this._actions=e.actions),this._onFeedChange=e.onFeedChange,this._onFeedReselected=e.onFeedReselected,this._onTabChange=e.onTabChange,this._onTabReselected=e.onTabReselected}static get id(){return"courier-inbox-header"}get theme(){return this._themeSubscription.manager.getTheme()}get showTabs(){var e;const t=this._feeds.find((e=>e.feedId===this._currentFeedId));return((null==(e=null==t?void 0:t.tabs)?void 0:e.length)??0)>1}onComponentMounted(){this._style?this._style.textContent=B.getStyles(this.theme):this._style=i.injectGlobalStyle(B.id,B.getStyles(this.theme))}onComponentUmounted(){var e;this._themeSubscription.unsubscribe(),null==(e=this._style)||e.remove()}getActionOptions(){var e,t,n,o,s,l,r,a,d,u,h,c,v,g,p,b,_;const C=null==(t=null==(e=this._themeSubscription.manager.getTheme().inbox)?void 0:e.header)?void 0:t.actions,f=[];for(const x of this._actions)switch(x.id){case"readAll":f.push({id:"make_all_read",text:x.text??(null==(n=null==C?void 0:C.markAllRead)?void 0:n.text)??"Mark All as Read",icon:{color:(null==(s=null==(o=null==C?void 0:C.markAllRead)?void 0:o.icon)?void 0:s.color)??"red",svg:x.iconSVG??(null==(r=null==(l=null==C?void 0:C.markAllRead)?void 0:l.icon)?void 0:r.svg)??i.CourierIconSVGs.read},onClick:e=>{m.shared.readAllMessages()}});break;case"archiveAll":f.push({id:"archive_all",text:x.text??(null==(a=null==C?void 0:C.archiveAll)?void 0:a.text)??"Archive All",icon:{color:(null==(u=null==(d=null==C?void 0:C.archiveAll)?void 0:d.icon)?void 0:u.color)??"red",svg:x.iconSVG??(null==(c=null==(h=null==C?void 0:C.archiveAll)?void 0:h.icon)?void 0:c.svg)??i.CourierIconSVGs.archive},onClick:e=>{m.shared.archiveAllMessages()}});break;case"archiveRead":f.push({id:"archive_read",text:x.text??(null==(v=null==C?void 0:C.archiveRead)?void 0:v.text)??"Archive Read",icon:{color:(null==(p=null==(g=null==C?void 0:C.archiveRead)?void 0:g.icon)?void 0:p.color)??"red",svg:x.iconSVG??(null==(_=null==(b=null==C?void 0:C.archiveRead)?void 0:b.icon)?void 0:_.svg)??i.CourierIconSVGs.archiveRead},onClick:e=>{m.shared.archiveReadMessages()}})}return f}refreshTheme(){var e,t;this._style?this._style.textContent=B.getStyles(this.theme):this._style=i.injectGlobalStyle(B.id,B.getStyles(this.theme)),this.refreshActionMenuButton(),null==(e=this._actionMenu)||e.setOptions(this.getActionOptions()),null==(t=this._feedMenu)||t.setOptions(this.getFeedMenuOptions()),this._actionMenuButton&&(this._actionMenuButton.style.display=this._actions.length>0?"":"none"),this._actionMenu&&(this._actionMenu.style.display=this._actions.length>0?"":"none")}getFeedMenuOptions(){return this._feeds.map(((e,t)=>{var n,o,s,l;return{id:e.feedId,text:e.title,icon:{color:(null==(l=null==(s=null==(o=null==(n=this.theme.inbox)?void 0:n.header)?void 0:o.feeds)?void 0:s.button)?void 0:l.selectedFeedIconColor)??"red",svg:e.iconSVG??i.CourierIconSVGs.inbox},onClick:t=>{e.feedId===this._currentFeedId?this._onFeedReselected(e):this._onFeedChange(e)}}}))}render(e){const t=e.feeds.find((e=>e.isSelected)),i=null==t?void 0:t.tabs.find((e=>e.isSelected)),n=((null==t?void 0:t.tabs.length)??0)>1;this._feedButton&&(this._feedButton.setSelectedFeed((null==t?void 0:t.feedId)??""),this._feedButton.setUnreadCount(n?0:(null==i?void 0:i.unreadCount)??0),this.updateFeedButtonInteraction()),this.tabs&&(this.tabs.style.display=n?"flex":"none",this.tabs.setSelectedTab((null==i?void 0:i.datasetId)??""),this.tabs.updateTabUnreadCount((null==i?void 0:i.datasetId)??"",(null==i?void 0:i.unreadCount)??0))}build(e){super.build(e),this.refreshTheme()}defaultElement(){this._feedButton=new $(this._themeSubscription.manager,this._feeds),this._feedMenu=new L(this._themeSubscription.manager,!0,this.getFeedMenuOptions(),"feed"),this._feedMenu.setPosition({left:"12px",top:"51px"}),this._feedButtonClickHandler=e=>{var t,i;e.stopPropagation(),null==(t=this._feedMenu)||t.toggleMenu(),null==(i=this._actionMenu)||i.closeMenu()},this.updateFeedButtonInteraction(),this._actionMenu=new L(this._themeSubscription.manager,!1,this.getActionOptions(),"action"),this._actionMenu.setPosition({right:"12px",top:"51px"}),this._actionMenuButton=new i.CourierIconButton(i.CourierIconSVGs.overflow),this.refreshActionMenuButton(),this._actionMenuButton.addEventListener("click",(e=>{var t,i;e.stopPropagation(),null==(t=this._actionMenu)||t.toggleMenu(),null==(i=this._feedMenu)||i.closeMenu()}));const e=document.createElement("div");e.className="title",e.appendChild(this._feedButton);const t=document.createElement("div");t.className="spacer";const n=document.createElement("div");n.className="header-content",n.appendChild(e),n.appendChild(t),this._actions.length>0&&(n.appendChild(this._actionMenuButton),n.appendChild(this._actionMenu)),n.appendChild(this._feedMenu),this.tabs=new T({themeManager:this._themeSubscription.manager,onTabClick:e=>{this._onTabChange(e)},onTabReselected:e=>{this._onTabReselected(e)}});const o=document.createElement("div");return o.className="header",o.appendChild(n),o.appendChild(this.tabs),o}refreshActionMenuButton(){var e,t,n,o,s,l,r,a,d,u,h;const c=null==(o=null==(n=null==(t=null==(e=this.theme)?void 0:e.inbox)?void 0:t.header)?void 0:n.actions)?void 0:o.button;null==(l=this._actionMenuButton)||l.updateIconSVG((null==(s=null==c?void 0:c.icon)?void 0:s.svg)??i.CourierIconSVGs.overflow),null==(a=this._actionMenuButton)||a.updateIconColor((null==(r=null==c?void 0:c.icon)?void 0:r.color)??"red"),null==(d=this._actionMenuButton)||d.updateBackgroundColor((null==c?void 0:c.backgroundColor)??"transparent"),null==(u=this._actionMenuButton)||u.updateHoverBackgroundColor((null==c?void 0:c.hoverBackgroundColor)??i.CourierColors.black[50010]),null==(h=this._actionMenuButton)||h.updateActiveBackgroundColor((null==c?void 0:c.activeBackgroundColor)??i.CourierColors.black[50020])}updateFeedButtonInteraction(){if(!this._feedButton||!this._feedButtonClickHandler)return;this._feedButton.removeEventListener("click",this._feedButtonClickHandler);this._feeds.length>1?(this._feedButton.style.cursor="pointer",this._feedButton.addEventListener("click",this._feedButtonClickHandler)):this._feedButton.style.cursor="default"}setFeeds(e){var t,i;if(0===e.length)throw new Error("[CourierInboxHeader] Cannot set feeds to an empty array.");if(!e[0].tabs.length)throw new Error("[CourierInboxHeader] First feed does not have a tab.");this._feeds=e,null==(t=this._feedButton)||t.setFeeds(e),this.selectFeed(e[0].feedId,e[0].tabs[0].datasetId),null==(i=this._feedMenu)||i.setOptions(this.getFeedMenuOptions()),this.updateFeedButtonInteraction()}setActions(e){var t;this._actions=e,null==(t=this._actionMenu)||t.setOptions(this.getActionOptions()),this._actionMenuButton&&(this._actionMenuButton.style.display=this._actions.length>0?"":"none"),this._actionMenu&&(this._actionMenu.style.display=this._actions.length>0?"":"none")}selectFeed(e,t){var i,n,o;this._currentFeedId=e,null==(i=this._feedButton)||i.setSelectedFeed(e);const s=this._feeds.findIndex((t=>t.feedId===e));null==(n=this._feedMenu)||n.selectionItemAtIndex(s);const l=(null==(o=this._feeds.find((t=>t.feedId===e)))?void 0:o.tabs)??[];if(l.length>0&&this.tabs){this.tabs.style.display=l.length>1?"flex":"none",this.tabs.setTabs(l),this.tabs.setSelectedTab(t);for(const e of l){const t=m.shared.getDatasetById(e.datasetId);t&&this.tabs.updateTabUnreadCount(e.datasetId,t.unreadCount)}}}static getStyles(e){var t,n,o,s,l,r;return`\n ${B.id} {\n display: flex;\n }\n\n ${B.id} > .header {\n display: flex;\n flex-direction: column;\n flex: 1;\n width: 100%;\n max-width: 100%;\n min-width: 0;\n position: relative;\n overflow-y: visible;\n background-color: ${(null==(n=null==(t=e.inbox)?void 0:t.header)?void 0:n.backgroundColor)??i.CourierColors.white[500]};\n box-shadow: ${(null==(s=null==(o=e.inbox)?void 0:o.header)?void 0:s.shadow)??"0px 1px 0px 0px red"};\n border-bottom: ${(null==(r=null==(l=e.inbox)?void 0:l.header)?void 0:r.border)??"1px solid red"};\n z-index: 100;\n }\n\n ${B.id} .header-content {\n padding-top: 10px;\n padding-right: 12px;\n padding-bottom: 10px;\n padding-left: 12px;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n flex: 1;\n width: 100%;\n max-width: 100%;\n min-width: 0;\n position: relative;\n box-sizing: border-box;\n }\n\n ${B.id} .title {\n display: flex;\n align-items: center;\n gap: 4px;\n }\n\n ${B.id} .spacer {\n flex: 1;\n }\n\n ${B.id} .actions {\n display: flex;\n align-items: center;\n gap: 4px;\n }\n `}}i.registerElement(B);class F{constructor(e){o(this,"events"),this.events=e}remove(){m.shared.removeDataStoreListener(this)}}const A={popup:{button:{icon:{color:i.CourierColors.black[500],svg:i.CourierIconSVGs.inbox},backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.black[50010],activeBackgroundColor:i.CourierColors.black[50020],unreadDotIndicator:{backgroundColor:i.CourierColors.blue[500],borderRadius:"50%",height:"8px",width:"8px"}},window:{backgroundColor:i.CourierColors.white[500],borderRadius:"8px",border:`1px solid ${i.CourierColors.gray[500]}`,shadow:`0px 8px 16px -4px ${i.CourierColors.gray[500]}`,animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"}}},inbox:{header:{backgroundColor:i.CourierColors.white[500],shadow:"none",border:`1px solid ${i.CourierColors.gray[500]}`,feeds:{button:{selectedFeedIconColor:i.CourierColors.black[500],hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],transition:"all 0.2s ease",font:{color:i.CourierColors.black[500],family:void 0,size:"16px"},changeFeedIcon:{color:i.CourierColors.black[500],svg:i.CourierIconSVGs.chevronDown},unreadCountIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.blue[500],borderRadius:"4px",padding:"2px 6px"}},menu:{backgroundColor:i.CourierColors.white[500],border:`1px solid ${i.CourierColors.gray[500]}`,borderRadius:"6px",shadow:`0px 4px 8px -2px ${i.CourierColors.gray[500]}`,animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"},list:{hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],divider:"none",font:{color:i.CourierColors.black[500],family:void 0,size:"14px"},selectedIcon:{color:i.CourierColors.black[500],svg:i.CourierIconSVGs.check}}},tabs:{borderRadius:{topLeft:"4px",topRight:"4px"},transition:"all 0.2s ease",default:{indicatorHeight:"1px",indicatorColor:"transparent",backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],font:{color:i.CourierColors.gray[600],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.gray[600],family:void 0,size:"12px"},backgroundColor:i.CourierColors.black[50010],borderRadius:"4px",padding:"2px 6px"}},selected:{indicatorHeight:"1px",indicatorColor:i.CourierColors.blue[500],backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],font:{color:i.CourierColors.blue[500],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.blue[500],borderRadius:"4px",padding:"2px 6px"}}}},tabs:{borderRadius:{topLeft:"4px",topRight:"4px"},transition:"all 0.2s ease",default:{indicatorHeight:"1px",indicatorColor:"transparent",backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],font:{color:i.CourierColors.gray[600],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.gray[600],family:void 0,size:"12px"},backgroundColor:i.CourierColors.black[50010],borderRadius:"4px",padding:"2px 6px"}},selected:{indicatorHeight:"1px",indicatorColor:i.CourierColors.blue[500],backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],font:{color:i.CourierColors.blue[500],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.blue[500],borderRadius:"4px",padding:"2px 6px"}}},actions:{button:{icon:{color:i.CourierColors.black[500],svg:i.CourierIconSVGs.overflow},backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500]},markAllRead:{icon:{color:i.CourierColors.black[500]},text:"Read All"},archiveAll:{icon:{color:i.CourierColors.black[500]},text:"Archive All"},archiveRead:{icon:{color:i.CourierColors.black[500]},text:"Archive Read"},animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"}}},list:{backgroundColor:i.CourierColors.white[500],scrollbar:{trackBackgroundColor:"transparent",thumbColor:i.CourierColors.black[50020],thumbHoverColor:i.CourierColors.black[50020],width:"8px",height:"8px",borderRadius:"4px"},item:{backgroundColor:"transparent",unreadIndicatorColor:i.CourierColors.blue[500],hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],transition:"all 0.2s ease",actions:{backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],border:`1px solid ${i.CourierColors.gray[500]}`,borderRadius:"4px",shadow:"0px 1px 2px 0px rgba(0, 0, 0, 0.06)",font:{color:i.CourierColors.black[500],family:void 0,size:"14px"}},title:{color:i.CourierColors.black[500],family:void 0,size:"14px"},subtitle:{color:i.CourierColors.gray[600],family:void 0,size:"14px"},subtitleLink:{color:i.CourierColors.blue[500],textDecoration:"underline",hoverColor:i.CourierColors.blue[400]},time:{color:i.CourierColors.gray[600],family:void 0,size:"14px"},divider:`1px solid ${i.CourierColors.gray[200]}`,menu:{enabled:!0,backgroundColor:i.CourierColors.white[500],border:`1px solid ${i.CourierColors.gray[500]}`,borderRadius:"4px",shadow:`0px 2px 4px -2px ${i.CourierColors.gray[500]}`,animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"},longPress:{displayDuration:4e3,vibrationDuration:50},item:{hoverBackgroundColor:i.CourierColors.gray[200],activeBackgroundColor:i.CourierColors.gray[500],borderRadius:"0px",read:{color:i.CourierColors.black[500]},unread:{color:i.CourierColors.black[500]},archive:{color:i.CourierColors.black[500]},unarchive:{color:i.CourierColors.black[500]}}}}},loading:{animation:{barColor:i.CourierColors.gray[500],barHeight:"14px",barBorderRadius:"14px",duration:"2s"},divider:`1px solid ${i.CourierColors.gray[200]}`},empty:{title:{font:{size:"16px",weight:"500",color:i.CourierColors.black[500]}},button:{text:"Refresh"}},error:{title:{font:{size:"16px",weight:"500",color:i.CourierColors.black[500]}},button:{text:"Retry"}}}},P={popup:{button:{icon:{color:i.CourierColors.white[500],svg:i.CourierIconSVGs.inbox},backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],unreadDotIndicator:{backgroundColor:i.CourierColors.blue[500],borderRadius:"50%",height:"8px",width:"8px"}},window:{backgroundColor:i.CourierColors.black[500],borderRadius:"8px",border:`1px solid ${i.CourierColors.gray[400]}`,shadow:`0px 4px 8px -2px ${i.CourierColors.white[50020]}`,animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"}}},inbox:{header:{backgroundColor:i.CourierColors.black[500],shadow:"none",border:`1px solid ${i.CourierColors.gray[400]}`,feeds:{button:{selectedFeedIconColor:i.CourierColors.white[500],hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],transition:"all 0.2s ease",font:{color:i.CourierColors.white[500],family:void 0,size:"16px"},changeFeedIcon:{color:i.CourierColors.white[500],svg:i.CourierIconSVGs.chevronDown},unreadCountIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.blue[500],borderRadius:"4px",padding:"3px 8px"}},menu:{backgroundColor:i.CourierColors.black[500],border:`1px solid ${i.CourierColors.gray[400]}`,borderRadius:"6px",shadow:`0px 4px 8px -2px ${i.CourierColors.white[50020]}`,animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"},list:{hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],divider:"none",font:{color:i.CourierColors.white[500],family:void 0,size:"14px"},selectedIcon:{color:i.CourierColors.white[500],svg:i.CourierIconSVGs.check}}},tabs:{borderRadius:{topLeft:"4px",topRight:"4px"},transition:"all 0.2s ease",default:{indicatorHeight:"1px",indicatorColor:"transparent",backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],font:{color:i.CourierColors.white[500],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.white[50010],borderRadius:"4px",padding:"3px 8px"}},selected:{indicatorHeight:"1px",indicatorColor:i.CourierColors.blue[500],backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],font:{color:i.CourierColors.blue[500],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.blue[500],borderRadius:"4px",padding:"3px 8px"}}}},tabs:{borderRadius:{topLeft:"4px",topRight:"4px"},transition:"all 0.2s ease",default:{indicatorHeight:"1px",indicatorColor:"transparent",backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],font:{color:i.CourierColors.white[500],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.white[50010],borderRadius:"4px",padding:"3px 8px"}},selected:{indicatorHeight:"1px",indicatorColor:i.CourierColors.blue[500],backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],font:{color:i.CourierColors.blue[500],family:void 0,size:"14px"},unreadIndicator:{font:{color:i.CourierColors.white[500],family:void 0,size:"12px"},backgroundColor:i.CourierColors.blue[500],borderRadius:"4px",padding:"3px 8px"}}},actions:{button:{icon:{color:i.CourierColors.white[500],svg:i.CourierIconSVGs.overflow},backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020]},markAllRead:{icon:{color:i.CourierColors.white[500]},text:"Read All"},archiveAll:{icon:{color:i.CourierColors.white[500]},text:"Archive All"},archiveRead:{icon:{color:i.CourierColors.white[500]},text:"Archive Read"},animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"}}},list:{backgroundColor:i.CourierColors.black[500],scrollbar:{trackBackgroundColor:"transparent",thumbColor:i.CourierColors.white[50020],thumbHoverColor:i.CourierColors.white[50020],width:"8px",height:"8px",borderRadius:"4px"},item:{backgroundColor:"transparent",unreadIndicatorColor:i.CourierColors.blue[500],hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],transition:"all 0.2s ease",actions:{backgroundColor:"transparent",hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],border:`1px solid ${i.CourierColors.gray[400]}`,borderRadius:"4px",shadow:`0px 1px 2px 0px ${i.CourierColors.white[50010]}`,font:{color:i.CourierColors.white[500],family:void 0,size:"14px"}},title:{color:i.CourierColors.white[500],family:void 0,size:"14px"},subtitle:{color:i.CourierColors.gray[500],family:void 0,size:"14px"},subtitleLink:{color:i.CourierColors.blue[500],textDecoration:"underline",hoverColor:i.CourierColors.blue[400]},time:{color:i.CourierColors.gray[500],family:void 0,size:"12px"},divider:`1px solid ${i.CourierColors.gray[400]}`,menu:{enabled:!0,backgroundColor:i.CourierColors.black[500],border:`1px solid ${i.CourierColors.gray[400]}`,borderRadius:"4px",shadow:`0px 2px 4px -2px ${i.CourierColors.white[50020]}`,animation:{transition:"none",initialTransform:"translate3d(0, 0, 0)",visibleTransform:"translate3d(0, 0, 0)"},longPress:{displayDuration:4e3,vibrationDuration:50},item:{hoverBackgroundColor:i.CourierColors.white[50010],activeBackgroundColor:i.CourierColors.white[50020],borderRadius:"0px",read:{color:i.CourierColors.white[500]},unread:{color:i.CourierColors.white[500]},archive:{color:i.CourierColors.white[500]},unarchive:{color:i.CourierColors.white[500]}}}}},loading:{animation:{barColor:i.CourierColors.gray[400],barHeight:"14px",barBorderRadius:"14px",duration:"2s"},divider:`1px solid ${i.CourierColors.gray[400]}`},empty:{title:{font:{size:"16px",weight:"500",color:i.CourierColors.white[500]}},button:{text:"Refresh"}},error:{title:{font:{size:"16px",weight:"500",color:i.CourierColors.white[500]}},button:{text:"Retry"}}}},R=(e,t)=>{var i,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f,x,y,k,I,w,M,S,$,T,E,L,B,F,R,U,D,O,N,z,G,H,V,j,W,q,J,Q,Y,X,K,Z,ee,te,ie,ne,oe,se,le,re,ae,de,ue,he,ce,ve,ge,pe,me,be,_e,Ce,fe,xe,ye,ke,Ie,we,Me,Se,$e,Te,Ee,Le,Be,Fe,Ae,Pe,Re,Ue,De,Oe,Ne,ze,Ge,He,Ve,je,We,qe,Je,Qe,Ye,Xe,Ke,Ze,et,tt,it,nt,ot,st,lt,rt,at,dt,ut,ht,ct,vt,gt,pt,mt,bt,_t,Ct,ft,xt,yt,kt,It,wt,Mt,St,$t,Tt,Et,Lt,Bt,Ft,At,Pt,Rt,Ut,Dt,Ot,Nt,zt,Gt,Ht,Vt,jt,Wt,qt,Jt,Qt,Yt,Xt,Kt,Zt,ei,ti,ii,ni,oi,si,li,ri,ai,di,ui,hi,ci,vi,gi,pi,mi,bi,_i,Ci,fi,xi,yi,ki,Ii,wi,Mi,Si,$i,Ti,Ei,Li,Bi,Fi,Ai,Pi,Ri,Ui,Di,Oi,Ni,zi,Gi,Hi,Vi,ji,Wi,qi,Ji,Qi,Yi,Xi,Ki,Zi,en,tn,nn,on,sn,ln,rn,an,dn,un,hn,cn,vn,gn,pn,mn,bn,_n,Cn,fn,xn,yn,kn,In,wn,Mn,Sn,$n,Tn,En,Ln,Bn,Fn,An,Pn,Rn,Un,Dn,On,Nn,zn,Gn,Hn,Vn,jn,Wn,qn,Jn,Qn,Yn,Xn,Kn,Zn,eo,to,io,no,oo,so,lo,ro,ao,uo,ho,co,vo,go,po,mo,bo,_o,Co,fo,xo,yo,ko,Io,wo,Mo,So,$o,To,Eo,Lo,Bo,Fo,Ao,Po,Ro,Uo,Do,Oo,No,zo,Go,Ho,Vo,jo,Wo,qo,Jo,Qo,Yo,Xo,Ko,Zo,es,ts,is,ns,os,ss,ls,rs,as,ds,us,hs,cs,vs,gs,ps,ms,bs,_s,Cs,fs,xs,ys,ks,Is,ws,Ms,Ss,$s,Ts,Es,Ls,Bs,Fs,As,Ps,Rs,Us,Ds,Os,Ns,zs,Gs,Hs,Vs,js,Ws,qs,Js,Qs,Ys,Xs,Ks,Zs,el,tl,il,nl,ol,sl,ll,rl,al,dl,ul,hl,cl,vl,gl,pl,ml,bl,_l,Cl,fl,xl,yl,kl,Il,wl,Ml,Sl,$l,Tl,El,Ll,Bl,Fl,Al,Pl,Rl,Ul,Dl,Ol,Nl,zl,Gl,Hl,Vl,jl,Wl,ql,Jl,Ql,Yl,Xl,Kl,Zl,er,tr,ir,nr,or,sr,lr,rr,ar,dr,ur,hr,cr,vr,gr,pr,mr,br,_r,Cr,fr,xr,yr,kr,Ir,wr,Mr,Sr,$r,Tr,Er,Lr,Br,Fr,Ar,Pr,Rr,Ur,Dr,Or,Nr,zr,Gr,Hr,Vr,jr,Wr,qr,Jr,Qr,Yr,Xr,Kr,Zr,ea,ta,ia,na;const oa="light"===e?A:P;return{popup:{button:{...null==(i=oa.popup)?void 0:i.button,...null==(n=t.popup)?void 0:n.button,icon:{...null==(s=null==(o=oa.popup)?void 0:o.button)?void 0:s.icon,...null==(r=null==(l=t.popup)?void 0:l.button)?void 0:r.icon},unreadDotIndicator:{...null==(d=null==(a=oa.popup)?void 0:a.button)?void 0:d.unreadDotIndicator,...null==(h=null==(u=t.popup)?void 0:u.button)?void 0:h.unreadDotIndicator}},window:{...null==(c=oa.popup)?void 0:c.window,...null==(v=t.popup)?void 0:v.window,animation:{...null==(p=null==(g=oa.popup)?void 0:g.window)?void 0:p.animation,...null==(b=null==(m=t.popup)?void 0:m.window)?void 0:b.animation}}},inbox:{header:{...null==(_=oa.inbox)?void 0:_.header,...null==(C=t.inbox)?void 0:C.header,feeds:{...null==(x=null==(f=oa.inbox)?void 0:f.header)?void 0:x.feeds,...null==(k=null==(y=t.inbox)?void 0:y.header)?void 0:k.feeds,button:{...null==(M=null==(w=null==(I=oa.inbox)?void 0:I.header)?void 0:w.feeds)?void 0:M.button,...null==(T=null==($=null==(S=t.inbox)?void 0:S.header)?void 0:$.feeds)?void 0:T.button,font:{...null==(F=null==(B=null==(L=null==(E=oa.inbox)?void 0:E.header)?void 0:L.feeds)?void 0:B.button)?void 0:F.font,...null==(O=null==(D=null==(U=null==(R=t.inbox)?void 0:R.header)?void 0:U.feeds)?void 0:D.button)?void 0:O.font},changeFeedIcon:{...null==(H=null==(G=null==(z=null==(N=oa.inbox)?void 0:N.header)?void 0:z.feeds)?void 0:G.button)?void 0:H.changeFeedIcon,...null==(q=null==(W=null==(j=null==(V=t.inbox)?void 0:V.header)?void 0:j.feeds)?void 0:W.button)?void 0:q.changeFeedIcon},unreadCountIndicator:{...null==(X=null==(Y=null==(Q=null==(J=oa.inbox)?void 0:J.header)?void 0:Q.feeds)?void 0:Y.button)?void 0:X.unreadCountIndicator,...null==(te=null==(ee=null==(Z=null==(K=t.inbox)?void 0:K.header)?void 0:Z.feeds)?void 0:ee.button)?void 0:te.unreadCountIndicator,font:{...null==(le=null==(se=null==(oe=null==(ne=null==(ie=oa.inbox)?void 0:ie.header)?void 0:ne.feeds)?void 0:oe.button)?void 0:se.unreadCountIndicator)?void 0:le.font,...null==(he=null==(ue=null==(de=null==(ae=null==(re=t.inbox)?void 0:re.header)?void 0:ae.feeds)?void 0:de.button)?void 0:ue.unreadCountIndicator)?void 0:he.font}}},menu:{...null==(ge=null==(ve=null==(ce=oa.inbox)?void 0:ce.header)?void 0:ve.feeds)?void 0:ge.menu,...null==(be=null==(me=null==(pe=t.inbox)?void 0:pe.header)?void 0:me.feeds)?void 0:be.menu,animation:{...null==(xe=null==(fe=null==(Ce=null==(_e=oa.inbox)?void 0:_e.header)?void 0:Ce.feeds)?void 0:fe.menu)?void 0:xe.animation,...null==(we=null==(Ie=null==(ke=null==(ye=t.inbox)?void 0:ye.header)?void 0:ke.feeds)?void 0:Ie.menu)?void 0:we.animation},list:{...null==(Te=null==($e=null==(Se=null==(Me=oa.inbox)?void 0:Me.header)?void 0:Se.feeds)?void 0:$e.menu)?void 0:Te.list,...null==(Fe=null==(Be=null==(Le=null==(Ee=t.inbox)?void 0:Ee.header)?void 0:Le.feeds)?void 0:Be.menu)?void 0:Fe.list,font:{...null==(De=null==(Ue=null==(Re=null==(Pe=null==(Ae=oa.inbox)?void 0:Ae.header)?void 0:Pe.feeds)?void 0:Re.menu)?void 0:Ue.list)?void 0:De.font,...null==(He=null==(Ge=null==(ze=null==(Ne=null==(Oe=t.inbox)?void 0:Oe.header)?void 0:Ne.feeds)?void 0:ze.menu)?void 0:Ge.list)?void 0:He.font},selectedIcon:{...null==(Je=null==(qe=null==(We=null==(je=null==(Ve=oa.inbox)?void 0:Ve.header)?void 0:je.feeds)?void 0:We.menu)?void 0:qe.list)?void 0:Je.selectedIcon,...null==(Ze=null==(Ke=null==(Xe=null==(Ye=null==(Qe=t.inbox)?void 0:Qe.header)?void 0:Ye.feeds)?void 0:Xe.menu)?void 0:Ke.list)?void 0:Ze.selectedIcon}}},tabs:{...null==(it=null==(tt=null==(et=oa.inbox)?void 0:et.header)?void 0:tt.feeds)?void 0:it.tabs,...null==(st=null==(ot=null==(nt=t.inbox)?void 0:nt.header)?void 0:ot.feeds)?void 0:st.tabs,default:{...null==(dt=null==(at=null==(rt=null==(lt=oa.inbox)?void 0:lt.header)?void 0:rt.feeds)?void 0:at.tabs)?void 0:dt.default,...null==(vt=null==(ct=null==(ht=null==(ut=t.inbox)?void 0:ut.header)?void 0:ht.feeds)?void 0:ct.tabs)?void 0:vt.default,font:{...null==(_t=null==(bt=null==(mt=null==(pt=null==(gt=oa.inbox)?void 0:gt.header)?void 0:pt.feeds)?void 0:mt.tabs)?void 0:bt.default)?void 0:_t.font,...null==(kt=null==(yt=null==(xt=null==(ft=null==(Ct=t.inbox)?void 0:Ct.header)?void 0:ft.feeds)?void 0:xt.tabs)?void 0:yt.default)?void 0:kt.font},unreadIndicator:{...null==($t=null==(St=null==(Mt=null==(wt=null==(It=oa.inbox)?void 0:It.header)?void 0:wt.feeds)?void 0:Mt.tabs)?void 0:St.default)?void 0:$t.unreadIndicator,...null==(Ft=null==(Bt=null==(Lt=null==(Et=null==(Tt=t.inbox)?void 0:Tt.header)?void 0:Et.feeds)?void 0:Lt.tabs)?void 0:Bt.default)?void 0:Ft.unreadIndicator,font:{...null==(Ot=null==(Dt=null==(Ut=null==(Rt=null==(Pt=null==(At=oa.inbox)?void 0:At.header)?void 0:Pt.feeds)?void 0:Rt.tabs)?void 0:Ut.default)?void 0:Dt.unreadIndicator)?void 0:Ot.font,...null==(jt=null==(Vt=null==(Ht=null==(Gt=null==(zt=null==(Nt=t.inbox)?void 0:Nt.header)?void 0:zt.feeds)?void 0:Gt.tabs)?void 0:Ht.default)?void 0:Vt.unreadIndicator)?void 0:jt.font}}},selected:{...null==(Qt=null==(Jt=null==(qt=null==(Wt=oa.inbox)?void 0:Wt.header)?void 0:qt.feeds)?void 0:Jt.tabs)?void 0:Qt.selected,...null==(Zt=null==(Kt=null==(Xt=null==(Yt=t.inbox)?void 0:Yt.header)?void 0:Xt.feeds)?void 0:Kt.tabs)?void 0:Zt.selected,font:{...null==(oi=null==(ni=null==(ii=null==(ti=null==(ei=oa.inbox)?void 0:ei.header)?void 0:ti.feeds)?void 0:ii.tabs)?void 0:ni.selected)?void 0:oi.font,...null==(di=null==(ai=null==(ri=null==(li=null==(si=t.inbox)?void 0:si.header)?void 0:li.feeds)?void 0:ri.tabs)?void 0:ai.selected)?void 0:di.font},unreadIndicator:{...null==(gi=null==(vi=null==(ci=null==(hi=null==(ui=oa.inbox)?void 0:ui.header)?void 0:hi.feeds)?void 0:ci.tabs)?void 0:vi.selected)?void 0:gi.unreadIndicator,...null==(Ci=null==(_i=null==(bi=null==(mi=null==(pi=t.inbox)?void 0:pi.header)?void 0:mi.feeds)?void 0:bi.tabs)?void 0:_i.selected)?void 0:Ci.unreadIndicator,font:{...null==(wi=null==(Ii=null==(ki=null==(yi=null==(xi=null==(fi=oa.inbox)?void 0:fi.header)?void 0:xi.feeds)?void 0:yi.tabs)?void 0:ki.selected)?void 0:Ii.unreadIndicator)?void 0:wi.font,...null==(Li=null==(Ei=null==(Ti=null==($i=null==(Si=null==(Mi=t.inbox)?void 0:Mi.header)?void 0:Si.feeds)?void 0:$i.tabs)?void 0:Ti.selected)?void 0:Ei.unreadIndicator)?void 0:Li.font}}}}},tabs:{...null==(Fi=null==(Bi=oa.inbox)?void 0:Bi.header)?void 0:Fi.tabs,...null==(Pi=null==(Ai=t.inbox)?void 0:Ai.header)?void 0:Pi.tabs,default:{...null==(Di=null==(Ui=null==(Ri=oa.inbox)?void 0:Ri.header)?void 0:Ui.tabs)?void 0:Di.default,...null==(zi=null==(Ni=null==(Oi=t.inbox)?void 0:Oi.header)?void 0:Ni.tabs)?void 0:zi.default,font:{...null==(ji=null==(Vi=null==(Hi=null==(Gi=oa.inbox)?void 0:Gi.header)?void 0:Hi.tabs)?void 0:Vi.default)?void 0:ji.font,...null==(Qi=null==(Ji=null==(qi=null==(Wi=t.inbox)?void 0:Wi.header)?void 0:qi.tabs)?void 0:Ji.default)?void 0:Qi.font},unreadIndicator:{...null==(Zi=null==(Ki=null==(Xi=null==(Yi=oa.inbox)?void 0:Yi.header)?void 0:Xi.tabs)?void 0:Ki.default)?void 0:Zi.unreadIndicator,...null==(on=null==(nn=null==(tn=null==(en=t.inbox)?void 0:en.header)?void 0:tn.tabs)?void 0:nn.default)?void 0:on.unreadIndicator,font:{...null==(dn=null==(an=null==(rn=null==(ln=null==(sn=oa.inbox)?void 0:sn.header)?void 0:ln.tabs)?void 0:rn.default)?void 0:an.unreadIndicator)?void 0:dn.font,...null==(gn=null==(vn=null==(cn=null==(hn=null==(un=t.inbox)?void 0:un.header)?void 0:hn.tabs)?void 0:cn.default)?void 0:vn.unreadIndicator)?void 0:gn.font}}},selected:{...null==(bn=null==(mn=null==(pn=oa.inbox)?void 0:pn.header)?void 0:mn.tabs)?void 0:bn.selected,...null==(fn=null==(Cn=null==(_n=t.inbox)?void 0:_n.header)?void 0:Cn.tabs)?void 0:fn.selected,font:{...null==(In=null==(kn=null==(yn=null==(xn=oa.inbox)?void 0:xn.header)?void 0:yn.tabs)?void 0:kn.selected)?void 0:In.font,...null==($n=null==(Sn=null==(Mn=null==(wn=t.inbox)?void 0:wn.header)?void 0:Mn.tabs)?void 0:Sn.selected)?void 0:$n.font},unreadIndicator:{...null==(Bn=null==(Ln=null==(En=null==(Tn=oa.inbox)?void 0:Tn.header)?void 0:En.tabs)?void 0:Ln.selected)?void 0:Bn.unreadIndicator,...null==(Rn=null==(Pn=null==(An=null==(Fn=t.inbox)?void 0:Fn.header)?void 0:An.tabs)?void 0:Pn.selected)?void 0:Rn.unreadIndicator,font:{...null==(zn=null==(Nn=null==(On=null==(Dn=null==(Un=oa.inbox)?void 0:Un.header)?void 0:Dn.tabs)?void 0:On.selected)?void 0:Nn.unreadIndicator)?void 0:zn.font,...null==(Wn=null==(jn=null==(Vn=null==(Hn=null==(Gn=t.inbox)?void 0:Gn.header)?void 0:Hn.tabs)?void 0:Vn.selected)?void 0:jn.unreadIndicator)?void 0:Wn.font}}}},actions:{...null==(Jn=null==(qn=oa.inbox)?void 0:qn.header)?void 0:Jn.actions,...null==(Yn=null==(Qn=t.inbox)?void 0:Qn.header)?void 0:Yn.actions,button:{...null==(Zn=null==(Kn=null==(Xn=oa.inbox)?void 0:Xn.header)?void 0:Kn.actions)?void 0:Zn.button,...null==(io=null==(to=null==(eo=t.inbox)?void 0:eo.header)?void 0:to.actions)?void 0:io.button,icon:{...null==(lo=null==(so=null==(oo=null==(no=oa.inbox)?void 0:no.header)?void 0:oo.actions)?void 0:so.button)?void 0:lo.icon,...null==(ho=null==(uo=null==(ao=null==(ro=t.inbox)?void 0:ro.header)?void 0:ao.actions)?void 0:uo.button)?void 0:ho.icon}},markAllRead:{...null==(go=null==(vo=null==(co=oa.inbox)?void 0:co.header)?void 0:vo.actions)?void 0:go.markAllRead,...null==(bo=null==(mo=null==(po=t.inbox)?void 0:po.header)?void 0:mo.actions)?void 0:bo.markAllRead,icon:{...null==(xo=null==(fo=null==(Co=null==(_o=oa.inbox)?void 0:_o.header)?void 0:Co.actions)?void 0:fo.markAllRead)?void 0:xo.icon,...null==(wo=null==(Io=null==(ko=null==(yo=t.inbox)?void 0:yo.header)?void 0:ko.actions)?void 0:Io.markAllRead)?void 0:wo.icon}},archiveAll:{...null==($o=null==(So=null==(Mo=oa.inbox)?void 0:Mo.header)?void 0:So.actions)?void 0:$o.archiveAll,...null==(Lo=null==(Eo=null==(To=t.inbox)?void 0:To.header)?void 0:Eo.actions)?void 0:Lo.archiveAll,icon:{...null==(Po=null==(Ao=null==(Fo=null==(Bo=oa.inbox)?void 0:Bo.header)?void 0:Fo.actions)?void 0:Ao.archiveAll)?void 0:Po.icon,...null==(Oo=null==(Do=null==(Uo=null==(Ro=t.inbox)?void 0:Ro.header)?void 0:Uo.actions)?void 0:Do.archiveAll)?void 0:Oo.icon}},archiveRead:{...null==(Go=null==(zo=null==(No=oa.inbox)?void 0:No.header)?void 0:zo.actions)?void 0:Go.archiveRead,...null==(jo=null==(Vo=null==(Ho=t.inbox)?void 0:Ho.header)?void 0:Vo.actions)?void 0:jo.archiveRead,icon:{...null==(Qo=null==(Jo=null==(qo=null==(Wo=oa.inbox)?void 0:Wo.header)?void 0:qo.actions)?void 0:Jo.archiveRead)?void 0:Qo.icon,...null==(Zo=null==(Ko=null==(Xo=null==(Yo=t.inbox)?void 0:Yo.header)?void 0:Xo.actions)?void 0:Ko.archiveRead)?void 0:Zo.icon}},animation:{...null==(is=null==(ts=null==(es=oa.inbox)?void 0:es.header)?void 0:ts.actions)?void 0:is.animation,...null==(ss=null==(os=null==(ns=t.inbox)?void 0:ns.header)?void 0:os.actions)?void 0:ss.animation}}},list:{...null==(ls=oa.inbox)?void 0:ls.list,...null==(rs=t.inbox)?void 0:rs.list,scrollbar:{...null==(ds=null==(as=oa.inbox)?void 0:as.list)?void 0:ds.scrollbar,...null==(hs=null==(us=t.inbox)?void 0:us.list)?void 0:hs.scrollbar},item:{...null==(vs=null==(cs=oa.inbox)?void 0:cs.list)?void 0:vs.item,...null==(ps=null==(gs=t.inbox)?void 0:gs.list)?void 0:ps.item,actions:{...null==(_s=null==(bs=null==(ms=oa.inbox)?void 0:ms.list)?void 0:bs.item)?void 0:_s.actions,...null==(xs=null==(fs=null==(Cs=t.inbox)?void 0:Cs.list)?void 0:fs.item)?void 0:xs.actions,font:{...null==(ws=null==(Is=null==(ks=null==(ys=oa.inbox)?void 0:ys.list)?void 0:ks.item)?void 0:Is.actions)?void 0:ws.font,...null==(Ts=null==($s=null==(Ss=null==(Ms=t.inbox)?void 0:Ms.list)?void 0:Ss.item)?void 0:$s.actions)?void 0:Ts.font}},title:{...null==(Bs=null==(Ls=null==(Es=oa.inbox)?void 0:Es.list)?void 0:Ls.item)?void 0:Bs.title,...null==(Ps=null==(As=null==(Fs=t.inbox)?void 0:Fs.list)?void 0:As.item)?void 0:Ps.title},subtitle:{...null==(Ds=null==(Us=null==(Rs=oa.inbox)?void 0:Rs.list)?void 0:Us.item)?void 0:Ds.subtitle,...null==(zs=null==(Ns=null==(Os=t.inbox)?void 0:Os.list)?void 0:Ns.item)?void 0:zs.subtitle},subtitleLink:{...null==(Vs=null==(Hs=null==(Gs=oa.inbox)?void 0:Gs.list)?void 0:Hs.item)?void 0:Vs.subtitleLink,...null==(qs=null==(Ws=null==(js=t.inbox)?void 0:js.list)?void 0:Ws.item)?void 0:qs.subtitleLink},time:{...null==(Ys=null==(Qs=null==(Js=oa.inbox)?void 0:Js.list)?void 0:Qs.item)?void 0:Ys.time,...null==(Zs=null==(Ks=null==(Xs=t.inbox)?void 0:Xs.list)?void 0:Ks.item)?void 0:Zs.time},menu:{...null==(il=null==(tl=null==(el=oa.inbox)?void 0:el.list)?void 0:tl.item)?void 0:il.menu,...null==(sl=null==(ol=null==(nl=t.inbox)?void 0:nl.list)?void 0:ol.item)?void 0:sl.menu,animation:{...null==(dl=null==(al=null==(rl=null==(ll=oa.inbox)?void 0:ll.list)?void 0:rl.item)?void 0:al.menu)?void 0:dl.animation,...null==(vl=null==(cl=null==(hl=null==(ul=t.inbox)?void 0:ul.list)?void 0:hl.item)?void 0:cl.menu)?void 0:vl.animation},item:{...null==(bl=null==(ml=null==(pl=null==(gl=oa.inbox)?void 0:gl.list)?void 0:pl.item)?void 0:ml.menu)?void 0:bl.item,...null==(xl=null==(fl=null==(Cl=null==(_l=t.inbox)?void 0:_l.list)?void 0:Cl.item)?void 0:fl.menu)?void 0:xl.item,read:{...null==(Ml=null==(wl=null==(Il=null==(kl=null==(yl=oa.inbox)?void 0:yl.list)?void 0:kl.item)?void 0:Il.menu)?void 0:wl.item)?void 0:Ml.read,...null==(Ll=null==(El=null==(Tl=null==($l=null==(Sl=t.inbox)?void 0:Sl.list)?void 0:$l.item)?void 0:Tl.menu)?void 0:El.item)?void 0:Ll.read},unread:{...null==(Rl=null==(Pl=null==(Al=null==(Fl=null==(Bl=oa.inbox)?void 0:Bl.list)?void 0:Fl.item)?void 0:Al.menu)?void 0:Pl.item)?void 0:Rl.unread,...null==(zl=null==(Nl=null==(Ol=null==(Dl=null==(Ul=t.inbox)?void 0:Ul.list)?void 0:Dl.item)?void 0:Ol.menu)?void 0:Nl.item)?void 0:zl.unread},archive:{...null==(Wl=null==(jl=null==(Vl=null==(Hl=null==(Gl=oa.inbox)?void 0:Gl.list)?void 0:Hl.item)?void 0:Vl.menu)?void 0:jl.item)?void 0:Wl.archive,...null==(Xl=null==(Yl=null==(Ql=null==(Jl=null==(ql=t.inbox)?void 0:ql.list)?void 0:Jl.item)?void 0:Ql.menu)?void 0:Yl.item)?void 0:Xl.archive},unarchive:{...null==(ir=null==(tr=null==(er=null==(Zl=null==(Kl=oa.inbox)?void 0:Kl.list)?void 0:Zl.item)?void 0:er.menu)?void 0:tr.item)?void 0:ir.unarchive,...null==(rr=null==(lr=null==(sr=null==(or=null==(nr=t.inbox)?void 0:nr.list)?void 0:or.item)?void 0:sr.menu)?void 0:lr.item)?void 0:rr.unarchive}}}}},loading:{...null==(ar=oa.inbox)?void 0:ar.loading,...null==(dr=t.inbox)?void 0:dr.loading,animation:{...null==(hr=null==(ur=oa.inbox)?void 0:ur.loading)?void 0:hr.animation,...null==(vr=null==(cr=t.inbox)?void 0:cr.loading)?void 0:vr.animation}},empty:{...null==(gr=oa.inbox)?void 0:gr.empty,...null==(pr=t.inbox)?void 0:pr.empty,title:{...null==(br=null==(mr=oa.inbox)?void 0:mr.empty)?void 0:br.title,...null==(Cr=null==(_r=t.inbox)?void 0:_r.empty)?void 0:Cr.title,font:{...null==(yr=null==(xr=null==(fr=oa.inbox)?void 0:fr.empty)?void 0:xr.title)?void 0:yr.font,...null==(wr=null==(Ir=null==(kr=t.inbox)?void 0:kr.empty)?void 0:Ir.title)?void 0:wr.font}},button:{...null==(Sr=null==(Mr=oa.inbox)?void 0:Mr.empty)?void 0:Sr.button,...null==(Tr=null==($r=t.inbox)?void 0:$r.empty)?void 0:Tr.button,font:{...null==(Br=null==(Lr=null==(Er=oa.inbox)?void 0:Er.empty)?void 0:Lr.button)?void 0:Br.font,...null==(Pr=null==(Ar=null==(Fr=t.inbox)?void 0:Fr.empty)?void 0:Ar.button)?void 0:Pr.font}}},error:{...null==(Rr=oa.inbox)?void 0:Rr.error,...null==(Ur=t.inbox)?void 0:Ur.error,title:{...null==(Or=null==(Dr=oa.inbox)?void 0:Dr.error)?void 0:Or.title,...null==(zr=null==(Nr=t.inbox)?void 0:Nr.error)?void 0:zr.title,font:{...null==(Vr=null==(Hr=null==(Gr=oa.inbox)?void 0:Gr.error)?void 0:Hr.title)?void 0:Vr.font,...null==(qr=null==(Wr=null==(jr=t.inbox)?void 0:jr.error)?void 0:Wr.title)?void 0:qr.font}},button:{...null==(Qr=null==(Jr=oa.inbox)?void 0:Jr.error)?void 0:Qr.button,...null==(Xr=null==(Yr=t.inbox)?void 0:Yr.error)?void 0:Xr.button,font:{...null==(ea=null==(Zr=null==(Kr=oa.inbox)?void 0:Kr.error)?void 0:Zr.button)?void 0:ea.font,...null==(na=null==(ia=null==(ta=t.inbox)?void 0:ta.error)?void 0:ia.button)?void 0:na.font}}}}}};class U extends i.CourierThemeManager{constructor(e){super(e),o(this,"THEME_CHANGE_EVENT","courier_inbox_theme_change")}getDefaultLightTheme(){return A}getDefaultDarkTheme(){return P}mergeTheme(e,t){return R(e,t)}subscribe(e){return{...super.subscribe(e),manager:this}}}class D extends i.CourierBaseElement{constructor(e){super(),o(this,"_currentFeedId",k()[0].feedId),o(this,"_feedTabMap",new Map),o(this,"_themeManager"),o(this,"_inboxStyle"),o(this,"_list"),o(this,"_datastoreListener"),o(this,"_authListener"),o(this,"_feeds",k()),o(this,"_header"),o(this,"_headerFactory"),o(this,"_actions",D.defaultActions()),o(this,"_onMessageClick"),o(this,"_onMessageActionClick"),o(this,"_onMessageLongPress"),o(this,"_listItemActions",D.defaultListItemActions()),o(this,"_defaultProps",{height:"auto"}),this._themeManager=e??new U(A)}static get id(){return"courier-inbox"}static defaultFeeds(){return k()}static defaultActions(){return[{id:"readAll"},{id:"archiveRead"},{id:"archiveAll"}]}static defaultListItemActions(){return[{id:"read_unread"},{id:"archive_unarchive"}]}get currentFeedId(){return this._currentFeedId}get _currentTabId(){return this.getSelectedTabIdForFeed(this._currentFeedId)}getSelectedTabIdForFeed(e){return this._feedTabMap.get(e)??"unknown_tab"}get theme(){return this._themeManager.getTheme()}setLightTheme(e){this._themeManager.setLightTheme(e)}setDarkTheme(e){this._themeManager.setDarkTheme(e)}setMode(e){this._themeManager.setMode(e)}static get observedAttributes(){return["height","light-theme","dark-theme","mode","message-click","message-action-click","message-long-press"]}resetInitialFeedAndTab(){if(!this._feeds.length)throw new Error("No feeds are available to initialize.");this._feedTabMap.clear();for(const e of this._feeds){if(!e.tabs||!e.tabs.length)throw new Error(`Feed "${e.feedId}" does not contain any tabs. You must have at least one tab in each feed.`);this._feedTabMap.set(e.feedId,e.tabs[0].datasetId)}this._currentFeedId=this._feeds[0].feedId}onComponentMounted(){this.readInitialThemeAttributes(),this.attachElements(),this.setupThemeSubscription(),this.setupAuthListener(),this.initializeInboxData()}readInitialThemeAttributes(){var e,i,n,o;const s=this.getAttribute("light-theme");if(s)try{this.setLightTheme(JSON.parse(s))}catch(a){null==(i=null==(e=t.Courier.shared.client)?void 0:e.options.logger)||i.error("Failed to parse light-theme attribute:",a)}const l=this.getAttribute("dark-theme");if(l)try{this.setDarkTheme(JSON.parse(l))}catch(a){null==(o=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||o.error("Failed to parse dark-theme attribute:",a)}const r=this.getAttribute("mode");r&&this._themeManager.setMode(r)}setupThemeSubscription(){this._themeManager.subscribe((e=>{this.refreshTheme()})),this.refreshTheme()}setupAuthListener(){this._authListener=t.Courier.shared.addAuthenticationListener((async({userId:e})=>{e&&await this.refresh()}))}initializeInboxData(){this.resetInitialFeedAndTab(),m.shared.registerFeeds(this._feeds),this._datastoreListener=new F({onError:e=>{var t;null==(t=this._list)||t.setError(e)},onDataSetChange:e=>{var t;this._currentTabId===e.id&&(null==(t=this._list)||t.setDataSet(e),this.updateHeader())},onPageAdded:e=>{var t;this._currentTabId===e.id&&(null==(t=this._list)||t.addPage(e),this.updateHeader())},onMessageAdd:(e,t,i)=>{var n;this._currentTabId===i&&(null==(n=this._list)||n.addMessage(e,t),this.updateHeader())},onMessageRemove:(e,t,i)=>{var n;this._currentTabId===i&&(null==(n=this._list)||n.removeMessage(t),this.updateHeader())},onMessageUpdate:(e,t,i)=>{var n;this._currentTabId===i&&(null==(n=this._list)||n.updateMessage(e,t),this.updateHeader())},onUnreadCountChange:(e,t)=>{var i,n;null==(n=null==(i=this._header)?void 0:i.tabs)||n.updateTabUnreadCount(t,e),this._currentTabId===t&&this.updateHeader()},onTotalUnreadCountChange:e=>{this.updateHeader()}}),m.shared.addDataStoreListener(this._datastoreListener),this.refresh()}attachElements(){var e,n;this._inboxStyle=i.injectGlobalStyle(D.id,this.getStyles()),this._header=new B({themeManager:this._themeManager,actions:this._actions,onFeedChange:e=>{this.selectFeed(e.feedId)},onFeedReselected:e=>{var t,i,n;this.selectTab(e.tabs[0].datasetId),null==(t=this._list)||t.scrollToTop(),null==(n=null==(i=this._header)?void 0:i.tabs)||n.scrollToStart()},onTabChange:e=>{this.selectTab(e.datasetId)},onTabReselected:e=>{var t;null==(t=this._list)||t.scrollToTop()}}),null==(e=this._header)||e.build(void 0),null==(n=this._header)||n.setFeeds(this._feeds),this.appendChild(this._header),this._list=new M({themeManager:this._themeManager,listItemActions:this._listItemActions,canClickListItems:!1,canLongPressListItems:!1,onRefresh:()=>{this.refresh()},onPaginationTrigger:async e=>{var i,n;try{await m.shared.fetchNextPageOfMessages({datasetId:e})}catch(o){null==(n=null==(i=t.Courier.shared.client)?void 0:i.options.logger)||n.error("Failed to fetch next page of messages:",o)}},onMessageClick:(e,t)=>{var i;m.shared.clickMessage({message:e}),this.dispatchEvent(new CustomEvent("message-click",{detail:{message:e,index:t},bubbles:!0,composed:!0})),null==(i=this._onMessageClick)||i.call(this,{message:e,index:t})},onMessageActionClick:(e,t,i)=>{var n;this.dispatchEvent(new CustomEvent("message-action-click",{detail:{message:e,action:t,index:i},bubbles:!0,composed:!0})),null==(n=this._onMessageActionClick)||n.call(this,{message:e,action:t,index:i})},onMessageLongPress:(e,t)=>{var i;this.dispatchEvent(new CustomEvent("message-long-press",{detail:{message:e,index:t},bubbles:!0,composed:!0})),null==(i=this._onMessageLongPress)||i.call(this,{message:e,index:t})}}),this.appendChild(this._list)}onComponentUnmounted(){var e,t,i;this._themeManager.cleanup(),null==(e=this._datastoreListener)||e.remove(),null==(t=this._authListener)||t.remove(),null==(i=this._inboxStyle)||i.remove()}refreshTheme(){var e;null==(e=this._list)||e.refreshInfoStateThemes(),this._inboxStyle&&(this._inboxStyle.textContent=this.getStyles())}getStyles(){return`\n ${D.id} {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: ${this._defaultProps.height};\n }\n\n ${D.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){var t;this._onMessageClick=e,null==(t=this._list)||t.setCanClickListItems(void 0!==e)}onMessageActionClick(e){this._onMessageActionClick=e}onMessageLongPress(e){var t;this._onMessageLongPress=e,null==(t=this._list)||t.setCanLongPressListItems(void 0!==e)}async reloadListForTab(){var e;null==(e=this._list)||e.selectDataset(this._currentTabId),await m.shared.load({canUseCache:!0,datasetIds:[this._currentTabId]})}selectFeed(e){var t,i;const n=this._feeds.find((t=>t.feedId===e));if(!n)throw new Error(`Feed "${e}" does not exist.`);if(this._currentFeedId===e){if(!n.tabs||0===n.tabs.length)throw new Error(`Feed "${e}" does not contain any tabs. You must have at least one tab in each feed.`);const i=n.tabs[0].datasetId;return null==(t=this._header)||t.selectFeed(e,i),void this.selectTab(i)}this._currentFeedId=e,null==(i=this._header)||i.selectFeed(e,this._currentTabId),this.selectTab(this._currentTabId)}selectTab(e){var t,i,n;const o=this._feeds.find((e=>e.feedId===this._currentFeedId));if(!o)throw new Error(`Feed "${this._currentFeedId}" does not exist.`);if(!(null==(t=o.tabs)?void 0:t.some((t=>t.datasetId===e))))throw new Error(`Tab "${e}" does not exist in feed "${o.feedId}".`);this._feedTabMap.set(this._currentFeedId,e),null==(n=null==(i=this._header)?void 0:i.tabs)||n.setSelectedTab(e),this.reloadListForTab()}updateTabUnreadCounts(e){var t,i;for(const n of e){const e=m.shared.getDatasetById(n.datasetId);e&&(null==(i=null==(t=this._header)?void 0:t.tabs)||i.updateTabUnreadCount(n.datasetId,e.unreadCount))}}setActions(e){var t;this._actions=e,null==(t=this._header)||t.setActions(this._actions)}setListItemActions(e){var t;this._listItemActions=e,null==(t=this._list)||t.setListItemActions(this._listItemActions)}setFeeds(e){var t,i,n,o;this._feeds=e,this.resetInitialFeedAndTab(),m.shared.registerFeeds(this._feeds),null==(t=this._header)||t.setFeeds(this._feeds),null==(i=this._header)||i.selectFeed(this._currentFeedId,this._currentTabId),this.updateHeader(),null==(n=this._list)||n.selectDataset(this._currentTabId),null==(o=this._list)||o.scrollToTop(!1),this.refresh()}getFeeds(){return this._feeds}getHeaderFeeds(){return this._feeds.map((e=>({feedId:e.feedId,title:e.title,iconSVG:e.iconSVG,tabs:e.tabs.map((e=>{var t;return{datasetId:e.datasetId,title:e.title,unreadCount:(null==(t=m.shared.getDatasetById(e.datasetId))?void 0:t.unreadCount)??0,isSelected:e.datasetId===this._currentTabId,filter:e.filter}})),isSelected:e.feedId===this._currentFeedId})))}updateHeader(){var e,t,i;if(!this._currentTabId)return;const n={feeds:this.getHeaderFeeds()};switch(this._headerFactory){case void 0:null==(e=this._header)||e.render(n);break;case null:null==(t=this._header)||t.build(null);break;default:const o=this._headerFactory(n);null==(i=this._header)||i.build(o)}}async load(e){await m.shared.load(e);for(const t of this._feeds)this.updateTabUnreadCounts(t.tabs);await m.shared.listenForUpdates()}async refresh(){var e,i;if(null==(e=t.Courier.shared.client)?void 0:e.options.userId)return this.load({canUseCache:!1});null==(i=t.Courier.shared.client)||i.options.logger.error("No user signed in. Please call Courier.shared.signIn(...) to load the inbox.")}attributeChangedCallback(e,i,n){var o,s,l,r,a,d;if(i!==n)switch(e){case"height":const e=n||this._defaultProps.height;this.style.height=e;break;case"message-click":if(n)try{this._onMessageClick=new Function("props",n)}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(n)try{this._onMessageActionClick=new Function("props",n)}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(n)try{this._onMessageLongPress=new Function("props",n)}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":n&&this.setLightTheme(JSON.parse(n));break;case"dark-theme":n&&this.setDarkTheme(JSON.parse(n));break;case"mode":this._themeManager.setMode(n)}}}i.registerElement(D);class O extends i.CourierFactoryElement{constructor(e){super(),o(this,"_themeSubscription"),o(this,"_style"),o(this,"_container"),o(this,"_triggerButton"),o(this,"_unreadBadge"),this._themeSubscription=e.subscribe((e=>{this.refreshTheme()}))}static get id(){return"courier-inbox-menu-button"}get theme(){return this._themeSubscription.manager.getTheme()}onComponentMounted(){this.refreshTheme()}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 i.CourierIconButton(i.CourierIconSVGs.inbox),this._unreadBadge=document.createElement("div"),this._unreadBadge.id="unread-badge",this._unreadBadge.style.display="none",this._container.appendChild(this._triggerButton),this._container.appendChild(this._unreadBadge),this._container}static getStyles(e){var t,i,n,o,s,l,r,a,d,u,h,c;return`\n ${O.id} {\n display: inline-block;\n }\n\n ${O.id} .menu-button-container {\n position: relative;\n display: inline-block;\n }\n \n ${O.id} .menu-button-container #unread-badge {\n position: absolute;\n top: 2px;\n right: 2px;\n pointer-events: none;\n width: ${(null==(n=null==(i=null==(t=e.popup)?void 0:t.button)?void 0:i.unreadDotIndicator)?void 0:n.width)??"8px"};\n height: ${(null==(l=null==(s=null==(o=e.popup)?void 0:o.button)?void 0:s.unreadDotIndicator)?void 0:l.height)??"8px"};\n background: ${(null==(d=null==(a=null==(r=e.popup)?void 0:r.button)?void 0:a.unreadDotIndicator)?void 0:d.backgroundColor)??"red"};\n border-radius: ${(null==(c=null==(h=null==(u=e.popup)?void 0:u.button)?void 0:h.unreadDotIndicator)?void 0:c.borderRadius)??"50%"};\n display: none;\n z-index: 1;\n }\n `}onUnreadCountChange(e){this._unreadBadge&&(this._unreadBadge.style.display=e>0?"block":"none"),this.refreshTheme()}refreshTheme(){var e,t,n,o,s,l,r,a,d,u,h,c,v,g,p,m,b,_,C,f,x,y,k;null==(e=this._style)||e.remove(),this._style=i.injectGlobalStyle(O.id,O.getStyles(this.theme)),null==(l=this._triggerButton)||l.updateIconColor((null==(s=null==(o=null==(n=null==(t=this.theme)?void 0:t.popup)?void 0:n.button)?void 0:o.icon)?void 0:s.color)??i.CourierColors.black[500]),null==(h=this._triggerButton)||h.updateIconSVG((null==(u=null==(d=null==(a=null==(r=this.theme)?void 0:r.popup)?void 0:a.button)?void 0:d.icon)?void 0:u.svg)??i.CourierIconSVGs.inbox),null==(p=this._triggerButton)||p.updateBackgroundColor((null==(g=null==(v=null==(c=this.theme)?void 0:c.popup)?void 0:v.button)?void 0:g.backgroundColor)??"transparent"),null==(C=this._triggerButton)||C.updateHoverBackgroundColor((null==(_=null==(b=null==(m=this.theme)?void 0:m.popup)?void 0:b.button)?void 0:_.hoverBackgroundColor)??i.CourierColors.black[50010]),null==(k=this._triggerButton)||k.updateActiveBackgroundColor((null==(y=null==(x=null==(f=this.theme)?void 0:f.popup)?void 0:x.button)?void 0:y.activeBackgroundColor)??i.CourierColors.black[50020])}}i.registerElement(O);class N extends i.CourierBaseElement{constructor(){super(),o(this,"_width","440px"),o(this,"_height","440px"),o(this,"_popupAlignment","top-left"),o(this,"_top"),o(this,"_right"),o(this,"_bottom"),o(this,"_left"),o(this,"_themeManager",new U(A)),o(this,"_triggerButton"),o(this,"_popup"),o(this,"_inbox"),o(this,"_style"),o(this,"_datastoreListener"),o(this,"_totalUnreadCount",0),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.hidePopup()})),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)}setMode(e){this._themeManager.setMode(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.readInitialThemeAttributes(),this._style=i.injectGlobalStyle(N.id,N.getStyles(this.theme,this._width,this._height)),this._triggerButton=new O(this._themeManager),this._popup=document.createElement("div"),this._popup.className="popup",this._inbox=new D(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 F(this),m.shared.addDataStoreListener(this._datastoreListener),this.render()}onComponentUnmounted(){var e,t;null==(e=this._style)||e.remove(),null==(t=this._datastoreListener)||t.remove(),this._themeManager.cleanup()}readInitialThemeAttributes(){var e,i,n,o;const s=this.getAttribute("light-theme");if(s)try{this.setLightTheme(JSON.parse(s))}catch(a){null==(i=null==(e=t.Courier.shared.client)?void 0:e.options.logger)||i.error("Failed to parse light-theme attribute:",a)}const l=this.getAttribute("dark-theme");if(l)try{this.setDarkTheme(JSON.parse(l))}catch(a){null==(o=null==(n=t.Courier.shared.client)?void 0:n.options.logger)||o.error("Failed to parse dark-theme attribute:",a)}const r=this.getAttribute("mode");r&&this._themeManager.setMode(r)}refreshTheme(){this._style&&(this._style.textContent=N.getStyles(this.theme,this._width,this._height))}static getStyles(e,t,i){var n,o,s,l,r,a,d,u,h,c;const v=null==(o=null==(n=e.popup)?void 0:n.window)?void 0:o.animation,g=(null==v?void 0:v.initialTransform)??"translate3d(-10px, -10px, 0) scale(0.9)",p=(null==v?void 0:v.visibleTransform)??"translate3d(0, 0, 0) scale(1)";return`\n ${N.id} {\n display: inline-block;\n position: relative;\n }\n\n ${N.id} .popup {\n display: none;\n position: absolute;\n background: ${(null==(l=null==(s=e.popup)?void 0:s.window)?void 0:l.backgroundColor)??"red"};\n border-radius: ${(null==(a=null==(r=e.popup)?void 0:r.window)?void 0:a.borderRadius)??"8px"};\n border: ${(null==(u=null==(d=e.popup)?void 0:d.window)?void 0:u.border)??"1px solid red"};\n box-shadow: ${(null==(c=null==(h=e.popup)?void 0:h.window)?void 0:c.shadow)??"0px 8px 16px -4px red"};\n z-index: 1000;\n width: ${t};\n height: ${i};\n overflow: hidden;\n transform: ${g};\n will-change: transform, opacity;\n transition: ${(null==v?void 0:v.transition)??"all 0.2s ease"};\n opacity: 0;\n }\n\n ${N.id} .popup.displayed {\n display: block;\n }\n\n ${N.id} .popup.visible {\n opacity: 1;\n transform: ${p};\n }\n\n ${N.id} courier-inbox {\n height: 100%;\n }\n `}attributeChangedCallback(e,t,i){switch(e){case"popup-alignment":this.isValidPosition(i)&&(this._popupAlignment=i,this.updatePopupPosition());break;case"popup-width":this._width=i,this.setSize(i,this._height);break;case"popup-height":this._height=i,this.setSize(this._width,i);break;case"top":this._top=i,this.updatePopupPosition();break;case"right":this._right=i,this.updatePopupPosition();break;case"bottom":this._bottom=i,this.updatePopupPosition();break;case"left":this._left=i,this.updatePopupPosition();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)}}onUnreadCountChange(e){this.render()}onTotalUnreadCountChange(e){this._totalUnreadCount=e,this.render()}onMessageClick(e){var t;null==(t=this._inbox)||t.onMessageClick((t=>{e&&e(t),this.closePopup()}))}onMessageActionClick(e){var t;null==(t=this._inbox)||t.onMessageActionClick((t=>{e&&e(t),this.closePopup()}))}onMessageLongPress(e){var t;null==(t=this._inbox)||t.onMessageLongPress((t=>{e&&e(t),this.closePopup()}))}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??"40px",this._popup.style.right=this._right??"0px";break;case"top-left":this._popup.style.top=this._top??"40px",this._popup.style.left=this._left??"0px";break;case"top-center":this._popup.style.top=this._top??"40px",this._popup.style.left="50%",this._popup.style.transform="translateX(-50%)";break;case"bottom-right":this._popup.style.bottom=this._bottom??"40px",this._popup.style.right=this._right??"0px";break;case"bottom-left":this._popup.style.bottom=this._bottom??"40px",this._popup.style.left=this._left??"0px";break;case"bottom-center":this._popup.style.bottom=this._bottom??"40px",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??"40px",this._popup.style.transform="translateY(-50%)";break;case"center-left":this._popup.style.top="50%",this._popup.style.left=this._left??"40px",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;this._popup.classList.contains("visible")?this.hidePopup():this.showPopup()}showPopup(){this._popup&&(this._popup.classList.remove("visible"),this._popup.classList.add("displayed"),requestAnimationFrame((()=>{requestAnimationFrame((()=>{this._popup&&this._popup.classList.add("visible")}))})))}hidePopup(){if(!this._popup)return;this._popup.classList.remove("visible");if(!window.getComputedStyle(this._popup).transitionDuration.split(",").map((e=>parseFloat(e)||0)).some((e=>e>0)))return void this._popup.classList.remove("displayed");const e=t=>{t.target===this._popup&&"opacity"===t.propertyName&&this._popup&&!this._popup.classList.contains("visible")&&(this._popup.classList.remove("displayed"),this._popup.removeEventListener("transitionend",e))};this._popup.addEventListener("transitionend",e)}closePopup(){this.hidePopup()}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 i,n;this.isValidPosition(e)?(this._popupAlignment=e,this.updatePopupPosition()):null==(n=null==(i=t.Courier.shared.client)?void 0:i.options.logger)||n.error(`Invalid position: ${e}`)}setHeader(e){var t;null==(t=this._inbox)||t.setHeader(e)}removeHeader(){var e;null==(e=this._inbox)||e.removeHeader()}setLoadingState(e){var t;null==(t=this._inbox)||t.setLoadingState(e)}setEmptyState(e){var t;null==(t=this._inbox)||t.setEmptyState(e)}setErrorState(e){var t;null==(t=this._inbox)||t.setErrorState(e)}setListItem(e){var t;null==(t=this._inbox)||t.setListItem(e)}setPaginationItem(e){var t;null==(t=this._inbox)||t.setPaginationItem(e)}setMenuButton(e){this._popupMenuButtonFactory=e,this.render()}selectFeed(e){var t;null==(t=this._inbox)||t.selectFeed(e)}selectTab(e){var t;null==(t=this._inbox)||t.selectTab(e)}setFeeds(e){var t;null==(t=this._inbox)||t.setFeeds(e)}getFeeds(){var e;return(null==(e=this._inbox)?void 0:e.getFeeds())??[]}setActions(e){var t;null==(t=this._inbox)||t.setActions(e)}setListItemActions(e){var t;null==(t=this._inbox)||t.setListItemActions(e)}get currentFeedId(){var e;return(null==(e=this._inbox)?void 0:e.currentFeedId)??""}async refresh(){var e;return null==(e=this._inbox)?void 0:e.refresh()}render(){var e;const t=this._totalUnreadCount;if(!this._triggerButton)return;const i=(null==(e=this._inbox)?void 0:e.getHeaderFeeds())??[];switch(this._popupMenuButtonFactory){case void 0:case null:this._triggerButton.build(void 0),this._triggerButton.onUnreadCountChange(t);break;default:const e=this._popupMenuButtonFactory({totalUnreadCount:t,feeds:i});this._triggerButton.build(e)}}}i.registerElement(N);t.Courier.shared.courierUserAgentName="courier-ui-inbox",t.Courier.shared.courierUserAgentVersion="2.3.0",Object.defineProperty(e,"Courier",{enumerable:!0,get:()=>t.Courier}),e.CourierInbox=D,e.CourierInboxDataStoreListener=F,e.CourierInboxDatastore=m,e.CourierInboxDatastoreEvents=class{onDataSetChange(e){}onPageAdded(e){}onUnreadCountChange(e,t){}onTotalUnreadCountChange(e){}onMessageAdd(e,t,i){}onMessageRemove(e,t,i){}onMessageUpdate(e,t,i){}onError(e){}},e.CourierInboxHeader=B,e.CourierInboxListItem=b,e.CourierInboxPopupMenu=N,e.CourierInboxThemeManager=U,e.archiveMessage=function(e){return m.shared.archiveMessage({message:e})},e.clickMessage=function(e){return m.shared.clickMessage({message:e})},e.defaultActions=I,e.defaultDarkTheme=P,e.defaultFeeds=k,e.defaultLightTheme=A,e.defaultListItemActions=w,e.markAsRead=function(e){return m.shared.readMessage({message:e})},e.markAsUnread=function(e){return m.shared.unreadMessage({message:e})},e.mergeTheme=R,e.openMessage=y,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
2
2
  //# sourceMappingURL=index.js.map