@trycourier/courier-ui-inbox 1.0.4-beta → 1.0.5-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +69 -199
- package/dist/index.mjs +820 -1722
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,168 +1,38 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
📡 New Courier ${e} Request: ${t}
|
|
3
|
-
URL: ${i.url}
|
|
4
|
-
${i.method?`Method: ${i.method}`:""}
|
|
5
|
-
${i.query?`Query: ${i.query}`:""}
|
|
6
|
-
${i.variables?`Variables: ${JSON.stringify(i.variables,null,2)}`:""}
|
|
7
|
-
Headers: ${JSON.stringify(i.headers,null,2)}
|
|
8
|
-
Body: ${i.body?JSON.stringify(i.body,null,2):"Empty"}
|
|
9
|
-
`)}function tt(c,t,e,i){c.log(`
|
|
10
|
-
📡 New Courier ${e} Response: ${t}
|
|
11
|
-
Status Code: ${i.status}
|
|
12
|
-
Response JSON: ${JSON.stringify(i.response,null,2)}
|
|
13
|
-
`)}async function K(c){const t=c.validCodes??[200],e=c.options.showLogs?Be.generate():void 0,i=new Request(c.url,{method:c.method,headers:{"Content-Type":"application/json",...c.headers},body:c.body?JSON.stringify(c.body):void 0});e&&et(c.options.logger,e,"HTTP",{url:i.url,method:i.method,headers:Object.fromEntries(i.headers.entries()),body:c.body});const s=await fetch(i);if(s.status===204)return;let o;try{o=await s.json()}catch{if(s.status===200)return;throw new De(s.status,"Failed to parse response as JSON","PARSE_ERROR")}if(e&&tt(c.options.logger,e,"HTTP",{status:s.status,response:o}),!t.includes(s.status))throw new De(s.status,(o==null?void 0:o.message)||"Unknown Error",o==null?void 0:o.type);return o}async function N(c){const t=c.options.showLogs?Be.generate():void 0;t&&et(c.options.logger,t,"GraphQL",{url:c.url,headers:c.headers,query:c.query,variables:c.variables});const e=await fetch(c.url,{method:"POST",headers:{"Content-Type":"application/json",...c.headers},body:JSON.stringify({query:c.query,variables:c.variables})});let i;try{i=await e.json()}catch{throw new De(e.status,"Failed to parse response as JSON","PARSE_ERROR")}if(t&&tt(c.options.logger,t,"GraphQL",{status:e.status,response:i}),!e.ok)throw new De(e.status,(i==null?void 0:i.message)||"Unknown Error",i==null?void 0:i.type);return i}class re{constructor(t){this.options=t}}class Xo extends re{async getBrand(t){const e=`
|
|
14
|
-
query GetBrand {
|
|
15
|
-
brand(brandId: "${t.brandId}") {
|
|
16
|
-
settings {
|
|
17
|
-
colors {
|
|
18
|
-
primary
|
|
19
|
-
secondary
|
|
20
|
-
tertiary
|
|
21
|
-
}
|
|
22
|
-
inapp {
|
|
23
|
-
borderRadius
|
|
24
|
-
disableCourierFooter
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`;return(await N({options:this.options,url:this.options.apiUrls.courier.graphql,headers:{"x-courier-user-id":this.options.userId,"x-courier-client-key":"empty",Authorization:`Bearer ${this.options.accessToken}`},query:e,variables:{brandId:t.brandId}})).data.brand}}class Ue extends Wo{constructor(t){const e=Ue.buildUrl(t);super(e,t),$(this,"receivedMessage"),$(this,"receivedMessageEvent"),this.onMessageReceived=i=>this.convertToType(i)}convertToType(t){var e,i,s,o;try{switch(JSON.parse(t).type){case"event":const h=JSON.parse(t);(e=this.receivedMessageEvent)==null||e.call(this,h);break;case"message":const d=JSON.parse(t);(i=this.receivedMessage)==null||i.call(this,d);break}}catch(n){(s=this.options.logger)==null||s.error("Error parsing socket message",n),n instanceof Error&&((o=this.onError)==null||o.call(this,n))}}async sendSubscribe(t){var e;const i={action:"subscribe",data:{userAgent:"courier-js",channel:this.options.userId,event:"*",version:(t==null?void 0:t.version)??5}};this.options.connectionId&&(i.data.clientSourceId=this.options.connectionId),this.options.tenantId&&(i.data.accountId=this.options.tenantId),(e=this.options.logger)==null||e.debug("Sending subscribe request",i),await this.send(i)}static buildUrl(t){var e;let i=((e=t.apiUrls)==null?void 0:e.inbox.webSocket)??"";return t.accessToken&&(i+=`/?auth=${t.accessToken}`),i}}class Qo extends re{constructor(t){super(t),$(this,"socket"),this.socket=new Ue(t)}async getMessages(t){const e=`
|
|
30
|
-
query GetInboxMessages(
|
|
31
|
-
$params: FilterParamsInput = { ${this.options.tenantId?`accountId: "${this.options.tenantId}"`:""} }
|
|
32
|
-
$limit: Int = ${(t==null?void 0:t.paginationLimit)??24}
|
|
33
|
-
$after: String ${t!=null&&t.startCursor?`= "${t.startCursor}"`:""}
|
|
34
|
-
) {
|
|
35
|
-
count(params: $params)
|
|
36
|
-
messages(params: $params, limit: $limit, after: $after) {
|
|
37
|
-
totalCount
|
|
38
|
-
pageInfo {
|
|
39
|
-
startCursor
|
|
40
|
-
hasNextPage
|
|
41
|
-
}
|
|
42
|
-
nodes {
|
|
43
|
-
messageId
|
|
44
|
-
read
|
|
45
|
-
archived
|
|
46
|
-
created
|
|
47
|
-
opened
|
|
48
|
-
title
|
|
49
|
-
preview
|
|
50
|
-
data
|
|
51
|
-
tags
|
|
52
|
-
trackingIds {
|
|
53
|
-
clickTrackingId
|
|
54
|
-
}
|
|
55
|
-
actions {
|
|
56
|
-
content
|
|
57
|
-
data
|
|
58
|
-
href
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
`;return await N({options:this.options,query:e,headers:{"x-courier-user-id":this.options.userId,Authorization:`Bearer ${this.options.accessToken}`},url:this.options.apiUrls.inbox.graphql})}async getArchivedMessages(t){const e=`
|
|
64
|
-
query GetInboxMessages(
|
|
65
|
-
$params: FilterParamsInput = { ${this.options.tenantId?`accountId: "${this.options.tenantId}"`:""}, archived: true }
|
|
66
|
-
$limit: Int = ${(t==null?void 0:t.paginationLimit)??24}
|
|
67
|
-
$after: String ${t!=null&&t.startCursor?`= "${t.startCursor}"`:""}
|
|
68
|
-
) {
|
|
69
|
-
count(params: $params)
|
|
70
|
-
messages(params: $params, limit: $limit, after: $after) {
|
|
71
|
-
totalCount
|
|
72
|
-
pageInfo {
|
|
73
|
-
startCursor
|
|
74
|
-
hasNextPage
|
|
75
|
-
}
|
|
76
|
-
nodes {
|
|
77
|
-
messageId
|
|
78
|
-
read
|
|
79
|
-
archived
|
|
80
|
-
created
|
|
81
|
-
opened
|
|
82
|
-
title
|
|
83
|
-
preview
|
|
84
|
-
data
|
|
85
|
-
tags
|
|
86
|
-
trackingIds {
|
|
87
|
-
clickTrackingId
|
|
88
|
-
}
|
|
89
|
-
actions {
|
|
90
|
-
content
|
|
91
|
-
data
|
|
92
|
-
href
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
`;return N({options:this.options,query:e,headers:{"x-courier-user-id":this.options.userId,Authorization:`Bearer ${this.options.accessToken}`},url:this.options.apiUrls.inbox.graphql})}async getUnreadMessageCount(){var t;const e=`
|
|
98
|
-
query GetMessages {
|
|
99
|
-
count(params: { status: "unread" ${this.options.tenantId?`, accountId: "${this.options.tenantId}"`:""} })
|
|
100
|
-
}
|
|
101
|
-
`;return((t=(await N({options:this.options,query:e,headers:{"x-courier-user-id":this.options.userId,Authorization:`Bearer ${this.options.accessToken}`},url:this.options.apiUrls.inbox.graphql})).data)==null?void 0:t.count)??0}async click(t){const e=`
|
|
102
|
-
mutation TrackEvent {
|
|
103
|
-
clicked(messageId: "${t.messageId}", trackingId: "${t.trackingId}")
|
|
104
|
-
}
|
|
105
|
-
`,i={"x-courier-user-id":this.options.userId,Authorization:`Bearer ${this.options.accessToken}`};this.options.connectionId&&(i["x-courier-client-source-id"]=this.options.connectionId),await N({options:this.options,query:e,headers:i,url:this.options.apiUrls.inbox.graphql})}async read(t){const e=`
|
|
106
|
-
mutation TrackEvent {
|
|
107
|
-
read(messageId: "${t.messageId}")
|
|
108
|
-
}
|
|
109
|
-
`,i={"x-courier-user-id":this.options.userId,Authorization:`Bearer ${this.options.accessToken}`};this.options.connectionId&&(i["x-courier-client-source-id"]=this.options.connectionId),await N({options:this.options,query:e,headers:i,url:this.options.apiUrls.inbox.graphql})}async unread(t){const e=`
|
|
110
|
-
mutation TrackEvent {
|
|
111
|
-
unread(messageId: "${t.messageId}")
|
|
112
|
-
}
|
|
113
|
-
`,i={"x-courier-user-id":this.options.userId,Authorization:`Bearer ${this.options.accessToken}`};this.options.connectionId&&(i["x-courier-client-source-id"]=this.options.connectionId),await N({options:this.options,query:e,headers:i,url:this.options.apiUrls.inbox.graphql})}async readAll(){const t=`
|
|
114
|
-
mutation TrackEvent {
|
|
115
|
-
markAllRead
|
|
116
|
-
}
|
|
117
|
-
`,e={"x-courier-user-id":this.options.userId,Authorization:`Bearer ${this.options.accessToken}`};this.options.connectionId&&(e["x-courier-client-source-id"]=this.options.connectionId),await N({options:this.options,query:t,headers:e,url:this.options.apiUrls.inbox.graphql})}async open(t){const e=`
|
|
118
|
-
mutation TrackEvent {
|
|
119
|
-
opened(messageId: "${t.messageId}")
|
|
120
|
-
}
|
|
121
|
-
`,i={"x-courier-user-id":this.options.userId,Authorization:`Bearer ${this.options.accessToken}`};this.options.connectionId&&(i["x-courier-client-source-id"]=this.options.connectionId),await N({options:this.options,query:e,headers:i,url:this.options.apiUrls.inbox.graphql})}async archive(t){const e=`
|
|
122
|
-
mutation TrackEvent {
|
|
123
|
-
archive(messageId: "${t.messageId}")
|
|
124
|
-
}
|
|
125
|
-
`,i={"x-courier-user-id":this.options.userId,Authorization:`Bearer ${this.options.accessToken}`};this.options.connectionId&&(i["x-courier-client-source-id"]=this.options.connectionId),await N({options:this.options,query:e,headers:i,url:this.options.apiUrls.inbox.graphql})}async archiveRead(){const t=`
|
|
126
|
-
mutation TrackEvent {
|
|
127
|
-
archiveRead
|
|
128
|
-
}
|
|
129
|
-
`,e={"x-courier-user-id":this.options.userId,Authorization:`Bearer ${this.options.accessToken}`};this.options.connectionId&&(e["x-courier-client-source-id"]=this.options.connectionId),await N({options:this.options,query:t,headers:e,url:this.options.apiUrls.inbox.graphql})}}class Yo{transformItem(t){return{topicId:t.topic_id,topicName:t.topic_name,sectionId:t.section_id,sectionName:t.section_name,status:t.status,defaultStatus:t.default_status,hasCustomRouting:t.has_custom_routing,customRouting:t.custom_routing||[]}}*transform(t){for(const e of t)yield this.transformItem(e)}}function en(c){const t=atob(c),e=new Uint8Array(t.length);for(let i=0;i<t.length;i++)e[i]=t.charCodeAt(i);return String.fromCharCode(...e)}function tn(c){const t=new Uint8Array(c.length);for(let e=0;e<c.length;e++)t[e]=c.charCodeAt(e);return btoa(String.fromCharCode(...t))}class sn extends re{constructor(){super(...arguments),$(this,"transformer",new Yo)}async getUserPreferences(t){let e=`${this.options.apiUrls.courier.rest}/users/${this.options.userId}/preferences`;t!=null&&t.paginationCursor&&(e+=`?cursor=${t.paginationCursor}`);const s=await K({options:this.options,url:e,method:"GET",headers:{Authorization:`Bearer ${this.options.accessToken}`}});return{items:[...this.transformer.transform(s.items)],paging:s.paging}}async getUserPreferenceTopic(t){const i=await K({options:this.options,url:`${this.options.apiUrls.courier.rest}/users/${this.options.userId}/preferences/${t.topicId}`,method:"GET",headers:{Authorization:`Bearer ${this.options.accessToken}`}});return this.transformer.transformItem(i.topic)}async putUserPreferenceTopic(t){const e={topic:{status:t.status,has_custom_routing:t.hasCustomRouting,custom_routing:t.customRouting}};await K({options:this.options,url:`${this.options.apiUrls.courier.rest}/users/${this.options.userId}/preferences/${t.topicId}`,method:"PUT",headers:{Authorization:`Bearer ${this.options.accessToken}`},body:e})}getNotificationCenterUrl(t){const e=en(t.clientKey);return`https://view.notificationcenter.app/p/${tn(`${e}#${this.options.userId}${this.options.tenantId?`#${this.options.tenantId}`:""}#false`)}`}}class on extends re{async putUserToken(t){const e={provider_key:t.provider,...t.device&&{device:{app_id:t.device.appId,ad_id:t.device.adId,device_id:t.device.deviceId,platform:t.device.platform,manufacturer:t.device.manufacturer,model:t.device.model}}};await K({options:this.options,url:`${this.options.apiUrls.courier.rest}/users/${this.options.userId}/tokens/${t.token}`,method:"PUT",headers:{Authorization:`Bearer ${this.options.accessToken}`},body:e,validCodes:[200,204]})}async deleteUserToken(t){await K({options:this.options,url:`${this.options.apiUrls.courier.rest}/users/${this.options.userId}/tokens/${t.token}`,method:"DELETE",headers:{Authorization:`Bearer ${this.options.accessToken}`},validCodes:[200,204]})}}class nn extends re{async putSubscription(t){return await K({url:`${this.options.apiUrls.courier.rest}/lists/${t.listId}/subscriptions/${this.options.userId}`,options:this.options,method:"PUT",headers:{Authorization:`Bearer ${this.options.accessToken}`}})}async deleteSubscription(t){return await K({url:`${this.options.apiUrls.courier.rest}/lists/${t.listId}/subscriptions/${this.options.userId}`,options:this.options,method:"DELETE",headers:{Authorization:`Bearer ${this.options.accessToken}`}})}}class rn extends re{async postInboundCourier(t){return await K({url:`${this.options.apiUrls.courier.rest}/inbound/courier`,options:this.options,method:"POST",headers:{Authorization:`Bearer ${this.options.accessToken}`},body:{...t,userId:this.options.userId},validCodes:[200,202]})}async postTrackingUrl(t){return await K({url:t.url,options:this.options,method:"POST",body:{event:t.event}})}}class an extends re{constructor(t){var e,i;const s=t.showLogs!==void 0?t.showLogs:process.env.NODE_ENV==="development",o={...t,showLogs:s,apiUrls:t.apiUrls||Ye(),accessToken:t.jwt??t.publicApiKey};super({...o,logger:new Ko(o.showLogs),apiUrls:Ye(o.apiUrls)}),$(this,"tokens"),$(this,"brands"),$(this,"preferences"),$(this,"inbox"),$(this,"lists"),$(this,"tracking"),this.tokens=new on(this.options),this.brands=new Xo(this.options),this.preferences=new sn(this.options),this.inbox=new Qo(this.options),this.lists=new nn(this.options),this.tracking=new rn(this.options),!this.options.jwt&&!this.options.publicApiKey&&this.options.logger.warn("Courier Client initialized with no authentication method. Please provide a JWT or public API key."),this.options.publicApiKey&&((e=this.options.logger)==null||e.warn(`Courier Warning: Public API Keys are for testing only. Please use JWTs for production.
|
|
130
|
-
You can generate a JWT with this endpoint: https://www.courier.com/docs/reference/auth/issue-token
|
|
131
|
-
This endpoint should be called from your backend server, not the SDK.`)),this.options.jwt&&this.options.publicApiKey&&((i=this.options.logger)==null||i.warn("Courier Warning: Both a JWT and a Public API Key were provided. The Public API Key will be ignored."))}}class hn{constructor(t){$(this,"callback"),this.callback=t}remove(){v.shared.removeAuthenticationListener(this)}}const it=class Pe{constructor(){$(this,"id",Be.generate()),$(this,"instanceClient"),$(this,"_paginationLimit",24),$(this,"authenticationListeners",[])}get paginationLimit(){return this._paginationLimit}set paginationLimit(t){this._paginationLimit=Math.min(Math.max(t,1),100)}get client(){return this.instanceClient}static get shared(){return Pe.instance||(Pe.instance=new Pe),Pe.instance}signIn(t){const e=t.connectionId??Be.generate();this.instanceClient=new an({...t,connectionId:e}),this.notifyAuthenticationListeners({userId:t.userId})}signOut(){this.instanceClient=void 0,this.notifyAuthenticationListeners({userId:void 0})}addAuthenticationListener(t){var e;(e=this.instanceClient)==null||e.options.logger.info("Adding authentication listener");const i=new hn(t);return this.authenticationListeners.push(i),i}removeAuthenticationListener(t){var e;(e=this.instanceClient)==null||e.options.logger.info("Removing authentication listener"),this.authenticationListeners=this.authenticationListeners.filter(i=>i!==t)}notifyAuthenticationListeners(t){this.authenticationListeners.forEach(e=>e.callback(t))}};$(it,"instance");let v=it;var cn=Object.defineProperty,ln=(c,t,e)=>t in c?cn(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e,L=(c,t,e)=>ln(c,typeof t!="symbol"?t+"":t,e);const r={black:{500:"#171717",50010:"#1717171A",50020:"#17171733"},gray:{200:"#F5F5F5",400:"#3A3A3A",500:"#E5E5E5",600:"#737373"},white:{500:"#FFFFFF",50010:"#FFFFFF1A",50020:"#FFFFFF33"},blue:{400:"#60A5FA",500:"#2563EB"}},X={light:{colors:{primary:r.black[500],secondary:r.white[500],border:r.gray[500],link:r.blue[500],icon:r.black[500]},button:{cornerRadius:"4px"}},dark:{colors:{primary:r.white[500],secondary:r.black[500],border:r.gray[400],link:r.blue[400],icon:r.white[500]},button:{cornerRadius:"4px"}}},st=()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",ot=c=>{if(typeof window>"u")return()=>{};const t=window.matchMedia("(prefers-color-scheme: dark)"),e=i=>{c(i.matches?"dark":"light")};return t.addEventListener("change",e),()=>{t.removeEventListener("change",e)}};class nt extends HTMLElement{constructor(){super(),L(this,"_currentSystemTheme"),L(this,"_systemThemeCleanup"),this._currentSystemTheme=st(),this._systemThemeCleanup=ot(t=>{this._currentSystemTheme=t,this.onSystemThemeChange(t)})}get currentSystemTheme(){return this._currentSystemTheme}disconnectedCallback(){this._systemThemeCleanup&&this._systemThemeCleanup()}onSystemThemeChange(t){}}const Ne={borderRadius:"4px",fontSize:"14px"},Y={primary:c=>({...Ne,backgroundColor:X[c].colors.primary,textColor:X[c].colors.secondary,fontWeight:"500",shadow:"none"}),secondary:c=>({...Ne,backgroundColor:X[c].colors.secondary,textColor:X[c].colors.primary,fontWeight:"500",border:`1px solid ${X[c].colors.border}`,shadow:c==="light"?"0px 1px 2px 0px rgba(0, 0, 0, 0.06)":"0px 1px 2px 0px rgba(255, 255, 255, 0.1)"}),tertiary:c=>({...Ne,backgroundColor:X[c].colors.border,textColor:X[c].colors.primary,fontWeight:"500",border:"none",shadow:"none"})};class Re extends nt{constructor(t){super(),L(this,"_button"),L(this,"_style");const e=this.attachShadow({mode:"open"});this._button=document.createElement("button"),this._button.setAttribute("part","button"),this._style=document.createElement("style"),this._style.textContent=this.getStyles(t),e.appendChild(this._style),e.appendChild(this._button),this.updateButton(t),this._button.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),t.onClick&&t.onClick()})}getStyles(t){const e=()=>Y.secondary(this.currentSystemTheme).textColor,i=()=>Y.secondary(this.currentSystemTheme).backgroundColor,s=()=>Y.secondary(this.currentSystemTheme).border,o=()=>Y.secondary(this.currentSystemTheme).shadow,n=()=>Y.secondary(this.currentSystemTheme).borderRadius,h=()=>Y.secondary(this.currentSystemTheme).fontSize,d=()=>Y.secondary(this.currentSystemTheme).fontWeight;return`
|
|
1
|
+
(function(E,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("@trycourier/courier-js")):typeof define=="function"&&define.amd?define(["exports","@trycourier/courier-js"],_):(E=typeof globalThis<"u"?globalThis:E||self,_(E.CourierUIInbox={},E.CourierJS))})(this,function(E,_){"use strict";var No=Object.defineProperty;var Uo=(E,_,oe)=>_ in E?No(E,_,{enumerable:!0,configurable:!0,writable:!0,value:oe}):E[_]=oe;var a=(E,_,oe)=>Uo(E,typeof _!="symbol"?_+"":_,oe);var oe=Object.defineProperty,Po=(m,i,e)=>i in m?oe(m,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):m[i]=e,T=(m,i,e)=>Po(m,typeof i!="symbol"?i+"":i,e);const r={black:{500:"#171717",50010:"#1717171A",50020:"#17171733"},gray:{200:"#F5F5F5",400:"#3A3A3A",500:"#E5E5E5",600:"#737373"},white:{500:"#FFFFFF",50010:"#FFFFFF1A",50020:"#FFFFFF33"},blue:{400:"#60A5FA",500:"#2563EB"}},G={light:{colors:{primary:r.black[500],secondary:r.white[500],border:r.gray[500],link:r.blue[500],icon:r.black[500]},button:{cornerRadius:"4px"}},dark:{colors:{primary:r.white[500],secondary:r.black[500],border:r.gray[400],link:r.blue[400],icon:r.white[500]},button:{cornerRadius:"4px"}}},Ve=()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",Ze=m=>{if(typeof window>"u")return()=>{};const i=window.matchMedia("(prefers-color-scheme: dark)"),e=t=>{m(t.matches?"dark":"light")};return i.addEventListener("change",e),()=>{i.removeEventListener("change",e)}};class je extends HTMLElement{constructor(){super(),T(this,"_currentSystemTheme"),T(this,"_systemThemeCleanup"),this._currentSystemTheme=Ve(),this._systemThemeCleanup=Ze(i=>{this._currentSystemTheme=i,this.onSystemThemeChange(i)})}get currentSystemTheme(){return this._currentSystemTheme}disconnectedCallback(){this._systemThemeCleanup&&this._systemThemeCleanup()}onSystemThemeChange(i){}}const De={borderRadius:"4px",fontSize:"14px"},X={primary:m=>({...De,backgroundColor:G[m].colors.primary,textColor:G[m].colors.secondary,fontWeight:"500",shadow:"none"}),secondary:m=>({...De,backgroundColor:G[m].colors.secondary,textColor:G[m].colors.primary,fontWeight:"500",border:`1px solid ${G[m].colors.border}`,shadow:m==="light"?"0px 1px 2px 0px rgba(0, 0, 0, 0.06)":"0px 1px 2px 0px rgba(255, 255, 255, 0.1)"}),tertiary:m=>({...De,backgroundColor:G[m].colors.border,textColor:G[m].colors.primary,fontWeight:"500",border:"none",shadow:"none"})};class Ie extends je{constructor(i){super(),T(this,"_button"),T(this,"_style");const e=this.attachShadow({mode:"open"});this._button=document.createElement("button"),this._button.setAttribute("part","button"),this._style=document.createElement("style"),this._style.textContent=this.getStyles(i),e.appendChild(this._style),e.appendChild(this._button),this.updateButton(i),this._button.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),i.onClick&&i.onClick()})}getStyles(i){const e=()=>X.secondary(this.currentSystemTheme).textColor,t=()=>X.secondary(this.currentSystemTheme).backgroundColor,s=()=>X.secondary(this.currentSystemTheme).border,o=()=>X.secondary(this.currentSystemTheme).shadow,n=()=>X.secondary(this.currentSystemTheme).borderRadius,h=()=>X.secondary(this.currentSystemTheme).fontSize,d=()=>X.secondary(this.currentSystemTheme).fontWeight;return`
|
|
132
2
|
:host {
|
|
133
3
|
display: inline-block;
|
|
134
4
|
}
|
|
135
5
|
|
|
136
6
|
button {
|
|
137
7
|
border: none;
|
|
138
|
-
border-radius: ${
|
|
139
|
-
font-weight: ${
|
|
140
|
-
font-family: ${
|
|
141
|
-
font-size: ${
|
|
8
|
+
border-radius: ${i.borderRadius??n()};
|
|
9
|
+
font-weight: ${i.fontWeight??d()};
|
|
10
|
+
font-family: ${i.fontFamily??"inherit"};
|
|
11
|
+
font-size: ${i.fontSize??h()};
|
|
142
12
|
padding: 6px 10px;
|
|
143
13
|
cursor: pointer;
|
|
144
14
|
width: 100%;
|
|
145
15
|
height: 100%;
|
|
146
|
-
background-color: ${
|
|
147
|
-
color: ${
|
|
148
|
-
border: ${
|
|
149
|
-
box-shadow: ${
|
|
16
|
+
background-color: ${i.backgroundColor??t()};
|
|
17
|
+
color: ${i.textColor??e()};
|
|
18
|
+
border: ${i.border??s()};
|
|
19
|
+
box-shadow: ${i.shadow??o()};
|
|
150
20
|
touch-action: manipulation;
|
|
151
21
|
}
|
|
152
22
|
|
|
153
23
|
button:hover {
|
|
154
|
-
${
|
|
24
|
+
${i.hoverBackgroundColor?`background-color: ${i.hoverBackgroundColor};`:"filter: brightness(0.9);"}
|
|
155
25
|
}
|
|
156
26
|
|
|
157
27
|
button:active {
|
|
158
|
-
${
|
|
28
|
+
${i.activeBackgroundColor?`background-color: ${i.activeBackgroundColor};`:"filter: brightness(0.8);"}
|
|
159
29
|
}
|
|
160
30
|
|
|
161
31
|
button:disabled {
|
|
162
32
|
opacity: 0.5;
|
|
163
33
|
cursor: not-allowed;
|
|
164
34
|
}
|
|
165
|
-
`}updateButton(
|
|
35
|
+
`}updateButton(i){i.text&&(this._button.textContent=i.text),this._style.textContent=this.getStyles(i)}}customElements.get("courier-button")||customElements.define("courier-button",Ie);const C={inbox:`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
166
36
|
<path d="M5.5 14.5V17C5.5 17.2812 5.71875 17.5 6 17.5H18C18.25 17.5 18.5 17.2812 18.5 17V14.5H15.9375L15.2812 15.8125C15.0938 16.25 14.6562 16.5 14.1875 16.5H9.78125C9.3125 16.5 8.875 16.25 8.6875 15.8125L8.03125 14.5H5.5ZM18.1875 13L16.6562 6.90625C16.5938 6.65625 16.4062 6.5 16.1875 6.5H7.8125C7.5625 6.5 7.375 6.65625 7.3125 6.90625L5.78125 13H8.1875C8.65625 13 9.09375 13.2812 9.3125 13.7188L9.9375 15H14.0312L14.6875 13.7188C14.875 13.2812 15.3125 13 15.7812 13H18.1875ZM4 14.25C4 14.0938 4 13.9375 4.03125 13.7812L5.84375 6.53125C6.09375 5.625 6.875 5 7.8125 5H16.1875C17.0938 5 17.9062 5.625 18.125 6.53125L19.9375 13.7812C19.9688 13.9375 20 14.0938 20 14.25V17C20 18.125 19.0938 19 18 19H6C4.875 19 4 18.125 4 17V14.25Z" fill="currentColor"/>
|
|
167
37
|
</svg>`,archive:`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
168
38
|
<path d="M5.5 6.5V8H18.5V6.5H5.5ZM5 5H19C19.5312 5 20 5.46875 20 6V8.5C20 9.0625 19.5312 9.5 19 9.5H5C4.4375 9.5 4 9.0625 4 8.5V6C4 5.46875 4.4375 5 5 5ZM9 11.75C9 11.3438 9.3125 11 9.75 11H14.25C14.6562 11 15 11.3438 15 11.75C15 12.1875 14.6562 12.5 14.25 12.5H9.75C9.3125 12.5 9 12.1875 9 11.75ZM5 17V10.5H6.5V17C6.5 17.2812 6.71875 17.5 7 17.5H17C17.25 17.5 17.5 17.2812 17.5 17V10.5H19V17C19 18.125 18.0938 19 17 19H7C5.875 19 5 18.125 5 17Z" fill="currentColor"/>
|
|
@@ -180,7 +50,7 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
180
50
|
<path d="M17 6.5H7C6.71875 6.5 6.5 6.75 6.5 7V17C6.5 17.2812 6.71875 17.5 7 17.5H17C17.25 17.5 17.5 17.2812 17.5 17V7C17.5 6.75 17.25 6.5 17 6.5ZM7 5H17C18.0938 5 19 5.90625 19 7V17C19 18.125 18.0938 19 17 19H7C5.875 19 5 18.125 5 17V7C5 5.90625 5.875 5 7 5Z" fill="currentColor"/>
|
|
181
51
|
</svg>`,unarchive:`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
182
52
|
<path d="M5.5 11C5.0625 11 4.75 10.6875 4.75 10.25V5.75C4.75 5.34375 5.0625 5 5.5 5C5.90625 5 6.25 5.34375 6.25 5.75V8.28125L6.875 7.53125C8.15625 6 10.0625 5 12.25 5C16.0938 5 19.25 8.15625 19.25 12C19.25 15.875 16.0938 19 12.25 19C10.6562 19 9.21875 18.5 8.03125 17.625C7.71875 17.375 7.625 16.9062 7.875 16.5625C8.125 16.2188 8.59375 16.1562 8.9375 16.4062C9.84375 17.0938 11 17.5 12.25 17.5C15.2812 17.5 17.75 15.0625 17.75 12C17.75 8.96875 15.2812 6.5 12.25 6.5C10.5312 6.5 9.03125 7.28125 8 8.5L7.15625 9.5H10C10.4062 9.5 10.75 9.84375 10.75 10.25C10.75 10.6875 10.4062 11 10 11H5.5Z" fill="currentColor"/>
|
|
183
|
-
</svg>`};class
|
|
53
|
+
</svg>`};class ie extends HTMLElement{constructor(i,e){super(),T(this,"_color"),T(this,"_svg"),T(this,"_iconContainer"),T(this,"_style"),this._color=i??r.black[500],this._svg=e;const t=this.attachShadow({mode:"open"});this._iconContainer=document.createElement("div"),t.appendChild(this._iconContainer),this._style=document.createElement("style"),this._style.textContent=this.getStyles(this._color),t.appendChild(this._style),this.refresh()}getStyles(i){return`
|
|
184
54
|
:host {
|
|
185
55
|
display: inline-block;
|
|
186
56
|
line-height: 0;
|
|
@@ -192,9 +62,9 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
192
62
|
svg {
|
|
193
63
|
width: 24px;
|
|
194
64
|
height: 24px;
|
|
195
|
-
color: ${
|
|
65
|
+
color: ${i};
|
|
196
66
|
}
|
|
197
|
-
`}refresh(){this._svg&&(this._iconContainer.innerHTML=this._svg),this._color&&(this._style.textContent=this.getStyles(this._color))}updateColor(
|
|
67
|
+
`}refresh(){this._svg&&(this._iconContainer.innerHTML=this._svg),this._color&&(this._style.textContent=this.getStyles(this._color))}updateColor(i){this._color=i,this.refresh()}updateSVG(i){this._svg=i,this.refresh()}}customElements.get("courier-icon")||customElements.define("courier-icon",ie);class Pe extends HTMLElement{constructor(){super(),T(this,"link");const i=this.attachShadow({mode:"open"});this.link=document.createElement("a"),this.link.setAttribute("part","link");const e=document.createElement("style");e.textContent=`
|
|
198
68
|
:host {
|
|
199
69
|
display: inline-block;
|
|
200
70
|
}
|
|
@@ -211,7 +81,7 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
211
81
|
|
|
212
82
|
/* Variants */
|
|
213
83
|
a[data-variant="primary"][data-mode="light"] {
|
|
214
|
-
color: var(--courier-link-color, ${
|
|
84
|
+
color: var(--courier-link-color, ${G.light.colors.link});
|
|
215
85
|
}
|
|
216
86
|
|
|
217
87
|
a[data-variant="primary"][data-mode="light"]:hover {
|
|
@@ -223,7 +93,7 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
223
93
|
}
|
|
224
94
|
|
|
225
95
|
a[data-variant="primary"][data-mode="dark"] {
|
|
226
|
-
color: var(--courier-link-color, ${
|
|
96
|
+
color: var(--courier-link-color, ${G.dark.colors.link});
|
|
227
97
|
}
|
|
228
98
|
|
|
229
99
|
a[data-variant="primary"][data-mode="dark"]:hover {
|
|
@@ -243,11 +113,11 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
243
113
|
cursor: not-allowed;
|
|
244
114
|
pointer-events: none;
|
|
245
115
|
}
|
|
246
|
-
`,
|
|
116
|
+
`,i.appendChild(e),i.appendChild(this.link),this.updateVariant(),this.updateUnderline(),this.updateMode()}connectedCallback(){const i=document.createElement("slot");this.link.appendChild(i),this.updateHref()}attributeChangedCallback(i,e,t){if(e!==t)switch(i){case"href":this.updateHref();break;case"variant":case"mode":this.updateVariant();break;case"disabled":this.link.style.pointerEvents=this.hasAttribute("disabled")?"none":"auto",this.link.style.opacity=this.hasAttribute("disabled")?"0.6":"1";break;case"color":this.updateColor();break;case"underline":this.updateUnderline();break;case"target":this.updateTarget();break;case"font-family":this.updateFontFamily();break;case"font-size":this.updateFontSize();break}}updateHref(){const i=this.getAttribute("href");i&&(this.link.href=i)}updateVariant(){const i=this.getAttribute("variant")||"primary",e=this.getAttribute("mode")||"light";this.link.setAttribute("data-variant",i),this.link.setAttribute("data-mode",e)}updateColor(){const i=this.getAttribute("color");i?this.link.style.setProperty("--courier-link-color",i):this.link.style.removeProperty("--courier-link-color")}updateUnderline(){const i=this.getAttribute("underline")==="true";this.link.setAttribute("data-underline",i.toString())}updateMode(){const i=this.getAttribute("mode")||"light";this.link.setAttribute("data-mode",i)}updateTarget(){const i=this.getAttribute("target");i&&(this.link.target=i)}updateFontFamily(){const i=this.getAttribute("font-family");i?this.link.style.setProperty("--courier-link-font-family",i):this.link.style.removeProperty("--courier-link-font-family")}updateFontSize(){const i=this.getAttribute("font-size");i?this.link.style.setProperty("--courier-link-font-size",i):this.link.style.removeProperty("--courier-link-font-size")}}T(Pe,"observedAttributes",["href","variant","disabled","color","underline","mode","target","font-family","font-size"]),customElements.get("courier-link")||customElements.define("courier-link",Pe);class Le extends je{constructor(){super(),T(this,"shadow"),this.shadow=this.attachShadow({mode:"open"})}build(i){if(i===null){this.shadow.replaceChildren();return}const e=i??this.defaultElement();this.shadow.replaceChildren(e)}defaultElement(){const i=document.createElement("div");return i.textContent="Default Element Factory",i.style.cssText=`
|
|
247
117
|
background-color: red;
|
|
248
118
|
text-align: center;
|
|
249
119
|
padding: 12px;
|
|
250
|
-
`,
|
|
120
|
+
`,i}}class Te extends Le{constructor(i){super(),T(this,"_props"),T(this,"_title"),T(this,"_button"),T(this,"_style"),T(this,"_buttonClickCallback",null),this._props=i}defaultElement(){var i,e;const t=document.createElement("div");return this._title=document.createElement("h2"),(i=this._props.title)!=null&&i.text&&(this._title.textContent=this._props.title.text),this._button=new Ie(this._props.button??X.secondary(this.currentSystemTheme)),this._style=document.createElement("style"),this._style.textContent=this.getStyles(this._props),t.className="container",t.appendChild(this._style),t.appendChild(this._title),t.appendChild(this._button),this.shadow.appendChild(t),(e=this._button)==null||e.addEventListener("click",()=>{this._buttonClickCallback&&this._buttonClickCallback()}),t}onSystemThemeChange(i){this.updateStyles(this._props)}getStyles(i){var e,t,s,o;return`
|
|
251
121
|
:host {
|
|
252
122
|
display: flex;
|
|
253
123
|
align-items: center;
|
|
@@ -268,12 +138,12 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
268
138
|
|
|
269
139
|
.container h2 {
|
|
270
140
|
margin: 0;
|
|
271
|
-
color: ${((e=
|
|
272
|
-
font-size: ${((i
|
|
273
|
-
font-weight: ${((s=
|
|
274
|
-
font-family: ${((o=
|
|
141
|
+
color: ${((e=i.title)==null?void 0:e.textColor)??"red"};
|
|
142
|
+
font-size: ${((t=i.title)==null?void 0:t.fontSize)??"16px"};
|
|
143
|
+
font-weight: ${((s=i.title)==null?void 0:s.fontWeight)??"500"};
|
|
144
|
+
font-family: ${((o=i.title)==null?void 0:o.fontFamily)??"inherit"};
|
|
275
145
|
}
|
|
276
|
-
`}updateStyles(
|
|
146
|
+
`}updateStyles(i){this._props=i,this._style&&(this._style.textContent=this.getStyles(i)),this._button&&this._button.updateButton(i.button)}setButtonClickCallback(i){this._buttonClickCallback=i}}customElements.get("courier-info-state")||customElements.define("courier-info-state",Te);class re extends HTMLElement{constructor(i,e,t,s,o,n,h,d){super(),T(this,"_backgroundColor"),T(this,"_hoverBackgroundColor"),T(this,"_activeBackgroundColor"),T(this,"_borderRadius"),T(this,"_height"),T(this,"_width"),T(this,"_style"),T(this,"_button"),T(this,"_icon"),this._borderRadius=n,this._backgroundColor=t,this._hoverBackgroundColor=s,this._activeBackgroundColor=o,this._height=h,this._width=d;const c=this.attachShadow({mode:"open"});this._button=document.createElement("button"),this._button.setAttribute("part","button"),this._icon=new ie(e,i),this._style=document.createElement("style"),this.refresh(),c.appendChild(this._style),this._button.appendChild(this._icon),c.appendChild(this._button)}refresh(){this._style.textContent=this.getStyles()}getStyles(){return`
|
|
277
147
|
:host {
|
|
278
148
|
display: inline-block;
|
|
279
149
|
border-radius: ${this._borderRadius??"50%"};
|
|
@@ -313,7 +183,7 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
313
183
|
width: 24px;
|
|
314
184
|
height: 24px;
|
|
315
185
|
}
|
|
316
|
-
`}updateIconColor(t){this._icon.updateColor(t)}updateIconSVG(t){this._icon.updateSVG(t)}updateBackgroundColor(t){this._backgroundColor=t,this.refresh()}updateHoverBackgroundColor(t){this._hoverBackgroundColor=t,this.refresh()}updateActiveBackgroundColor(t){this._activeBackgroundColor=t,this.refresh()}}customElements.get("courier-icon-button")||customElements.define("courier-icon-button",de),[{name:"courier-button",class:Re},{name:"courier-icon",class:ae},{name:"courier-link",class:qe},{name:"courier-info-state",class:He},{name:"courier-icon-button",class:de}].forEach(({name:c,class:t})=>{customElements.get(c)||customElements.define(c,t)});const he=class he{constructor(){a(this,"_inboxDataSet");a(this,"_archiveDataSet");a(this,"_dataStoreListeners",[]);a(this,"_unreadCount");a(this,"isPaginatingInbox",!1);a(this,"isPaginatingArchive",!1)}static get shared(){return he.instance||(he.instance=new he),he.instance}get unreadCount(){return this._unreadCount??0}get inboxDataSet(){return this._inboxDataSet??{messages:[],canPaginate:!1,paginationCursor:null}}get archiveDataSet(){return this._archiveDataSet??{messages:[],canPaginate:!1,paginationCursor:null}}addDataStoreListener(t){this._dataStoreListeners.push(t)}removeDataStoreListener(t){this._dataStoreListeners=this._dataStoreListeners.filter(e=>e!==t)}async fetchDataSet(t){var i,s,o,n,h,d,l,p,m,g;if(t.canUseCache)switch(t.feedType){case"inbox":if(this._inboxDataSet)return this._inboxDataSet;break;case"archive":if(this._archiveDataSet)return this._archiveDataSet;break}const e=t.feedType==="inbox"?await((i=v.shared.client)==null?void 0:i.inbox.getMessages()):await((s=v.shared.client)==null?void 0:s.inbox.getArchivedMessages());return{messages:((n=(o=e==null?void 0:e.data)==null?void 0:o.messages)==null?void 0:n.nodes)??[],canPaginate:((l=(d=(h=e==null?void 0:e.data)==null?void 0:h.messages)==null?void 0:d.pageInfo)==null?void 0:l.hasNextPage)??!1,paginationCursor:((g=(m=(p=e==null?void 0:e.data)==null?void 0:p.messages)==null?void 0:m.pageInfo)==null?void 0:g.startCursor)??null}}async fetchUnreadCount(t){var i;return t.canUseCache&&this._unreadCount!==void 0?this._unreadCount:await((i=v.shared.client)==null?void 0:i.inbox.getUnreadMessageCount())??0}async load(t){var e,i,s;try{if(!((e=v.shared.client)!=null&&e.options.userId))throw new Error("User is not signed in");const o=t??{feedType:"inbox",canUseCache:!0},[n,h]=await Promise.all([this.fetchDataSet(o),this.fetchUnreadCount(o)]);switch(o.feedType){case"inbox":this._inboxDataSet=n;break;case"archive":this._archiveDataSet=n;break}this._unreadCount=h,this._dataStoreListeners.forEach(d=>{var l,p,m,g;(p=(l=d.events).onDataSetChange)==null||p.call(l,n,o.feedType),(g=(m=d.events).onUnreadCountChange)==null||g.call(m,this._unreadCount??0)}),await this.connectSocket()}catch(o){(s=(i=v.shared.client)==null?void 0:i.options.logger)==null||s.error("Error loading inbox:",o),this._dataStoreListeners.forEach(n=>{var h,d;(d=(h=n.events).onError)==null||d.call(h,o)})}}async connectSocket(){var e,i,s,o,n,h,d,l,p,m,g,f;const t=(e=v.shared.client)==null?void 0:e.inbox.socket;try{if(!t){(s=(i=v.shared.client)==null?void 0:i.options.logger)==null||s.info("CourierInbox socket not available");return}if((h=(o=v.shared.client)==null?void 0:o.options.logger)==null||h.info("CourierInbox socket connectionId:",(n=v.shared.client)==null?void 0:n.options.connectionId),t.isConnected){(l=(d=v.shared.client)==null?void 0:d.options.logger)==null||l.info("CourierInbox socket already connected. Socket will not attempt reconnection.");return}t.receivedMessage=_=>{this.addMessage(_,0,"inbox")},t.receivedMessageEvent=_=>{let b;switch(_.messageId&&(b=this.getMessage({messageId:_.messageId})),_.event){case"mark-all-read":this.readAllMessages({canCallApi:!1});break;case"read":b&&this.readMessage({message:b,canCallApi:!1});break;case"unread":b&&this.unreadMessage({message:b,canCallApi:!1});break;case"opened":b&&this.openMessage({message:b,canCallApi:!1});break;case"archive":b&&this.archiveMessage({message:b,canCallApi:!1});break;case"archive-read":this.archiveReadMessages({canCallApi:!1});break;case"click":b&&this.clickMessage({message:b,canCallApi:!1});break;case"unopened":case"unarchive":break}},await t.connect(),await t.sendSubscribe(),t.keepAlive(),(m=(p=v.shared.client)==null?void 0:p.options.logger)==null||m.info("CourierInbox socket connected")}catch(_){(f=(g=v.shared.client)==null?void 0:g.options.logger)==null||f.error("Failed to connect socket:",_)}}getMessage(t){var e,i;return((e=this._inboxDataSet)==null?void 0:e.messages.find(s=>s.messageId===t.messageId))??((i=this._archiveDataSet)==null?void 0:i.messages.find(s=>s.messageId===t.messageId))}async fetchNextPageOfMessages(t){var e,i,s,o,n,h,d,l,p,m,g,f,_,b,C,k,w,S,I,E,M,A,R,F;switch(t.feedType){case"inbox":if(this.isPaginatingInbox)return null;if((e=this._inboxDataSet)!=null&&e.canPaginate&&this._inboxDataSet.paginationCursor)try{this.isPaginatingInbox=!0;const y=await((i=v.shared.client)==null?void 0:i.inbox.getMessages({paginationLimit:v.shared.paginationLimit,startCursor:this._inboxDataSet.paginationCursor})),B={messages:((o=(s=y==null?void 0:y.data)==null?void 0:s.messages)==null?void 0:o.nodes)??[],canPaginate:((d=(h=(n=y==null?void 0:y.data)==null?void 0:n.messages)==null?void 0:h.pageInfo)==null?void 0:d.hasNextPage)??!1,paginationCursor:((m=(p=(l=y==null?void 0:y.data)==null?void 0:l.messages)==null?void 0:p.pageInfo)==null?void 0:m.startCursor)??null};return this.addPage(B,"inbox"),B}catch(y){return(f=(g=v.shared.client)==null?void 0:g.options.logger)==null||f.error("Error fetching next page of inbox messages:",y),null}finally{this.isPaginatingInbox=!1}break;case"archive":if(this.isPaginatingArchive)return null;if((_=this._archiveDataSet)!=null&&_.canPaginate&&this._archiveDataSet.paginationCursor)try{this.isPaginatingArchive=!0;const y=await((b=v.shared.client)==null?void 0:b.inbox.getArchivedMessages({paginationLimit:v.shared.paginationLimit,startCursor:this._archiveDataSet.paginationCursor})),B={messages:((k=(C=y==null?void 0:y.data)==null?void 0:C.messages)==null?void 0:k.nodes)??[],canPaginate:((I=(S=(w=y==null?void 0:y.data)==null?void 0:w.messages)==null?void 0:S.pageInfo)==null?void 0:I.hasNextPage)??!1,paginationCursor:((A=(M=(E=y==null?void 0:y.data)==null?void 0:E.messages)==null?void 0:M.pageInfo)==null?void 0:A.startCursor)??null};return this.addPage(B,"archive"),B}catch(y){return(F=(R=v.shared.client)==null?void 0:R.options.logger)==null||F.error("Error fetching next page of archived messages:",y),null}finally{this.isPaginatingArchive=!1}break}return null}applyLocalMessageChange(t,e){for(const[i,s]of Object.entries(e))s!==void 0&&this.updateMessage(t,s,i)}async readMessage({message:t,canCallApi:e=!0}){var o,n,h,d;if(!v.shared.client)return;const i=t;if(i.read)return;const s={inbox:(o=this._inboxDataSet)==null?void 0:o.messages.findIndex(l=>l.messageId===t.messageId),archive:(n=this._archiveDataSet)==null?void 0:n.messages.findIndex(l=>l.messageId===t.messageId)};try{t.read=new Date().toISOString(),this.applyLocalMessageChange(t,s),e&&await v.shared.client.inbox.read({messageId:t.messageId})}catch(l){this.applyLocalMessageChange(i,s),(d=(h=v.shared.client)==null?void 0:h.options.logger)==null||d.error("Error reading message:",l)}}async unreadMessage({message:t,canCallApi:e=!0}){var o,n,h,d;if(!v.shared.client)return;const i=t;if(!i.read)return;const s={inbox:(o=this._inboxDataSet)==null?void 0:o.messages.findIndex(l=>l.messageId===t.messageId),archive:(n=this._archiveDataSet)==null?void 0:n.messages.findIndex(l=>l.messageId===t.messageId)};try{t.read=void 0,this.applyLocalMessageChange(t,s),e&&await v.shared.client.inbox.unread({messageId:t.messageId})}catch(l){this.applyLocalMessageChange(i,s),(d=(h=v.shared.client)==null?void 0:h.options.logger)==null||d.error("Error unreading message:",l)}}async openMessage({message:t,canCallApi:e=!0}){var o,n,h,d;if(!v.shared.client)return;const i=t,s={inbox:(o=this._inboxDataSet)==null?void 0:o.messages.findIndex(l=>l.messageId===t.messageId),archive:(n=this._archiveDataSet)==null?void 0:n.messages.findIndex(l=>l.messageId===t.messageId)};if(!(!s.inbox&&!s.archive)&&!i.opened)try{t.opened=new Date().toISOString(),this.applyLocalMessageChange(t,s),e&&await v.shared.client.inbox.open({messageId:t.messageId})}catch(l){this.applyLocalMessageChange(i,s),(d=(h=v.shared.client)==null?void 0:h.options.logger)==null||d.error("Error opening message:",l)}}async clickMessage({message:t,canCallApi:e=!0}){var i,s,o,n;if(v.shared.client)try{(i=t.trackingIds)!=null&&i.clickTrackingId&&e&&await v.shared.client.inbox.click({messageId:t.messageId,trackingId:(s=t.trackingIds)==null?void 0:s.clickTrackingId})}catch(h){(n=(o=v.shared.client)==null?void 0:o.options.logger)==null||n.error("Error clicking message:",h)}}async archiveMessage({message:t,canCallApi:e=!0}){var o,n;if(!v.shared.client)return;const i=t,s=(o=this._inboxDataSet)==null?void 0:o.messages.findIndex(h=>h.messageId===t.messageId);if(s!==void 0)try{if(this.removeMessage(t,s,"inbox"),(n=this._archiveDataSet)!=null&&n.messages){const h=this.findInsertIndex(t,this._archiveDataSet.messages);t.archived=new Date().toISOString(),this.addMessage(t,h,"archive")}e&&await v.shared.client.inbox.archive({messageId:t.messageId})}catch{this.addMessage(i,s,"inbox"),t.archived=void 0,this.removeMessage(t,s,"archive")}}async archiveReadMessages({canCallApi:t=!0}={}){var s;if(!v.shared.client)return;const e=this._inboxDataSet,i=this._archiveDataSet;try{(s=this._inboxDataSet)==null||s.messages.forEach(o=>{var h,d;if(!o.read)return;const n=(h=this._inboxDataSet)==null?void 0:h.messages.findIndex(l=>l.messageId===o.messageId);if(n!==void 0&&(this.removeMessage(o,n,"inbox"),(d=this._archiveDataSet)!=null&&d.messages)){const l=this.findInsertIndex(o,this._archiveDataSet.messages);o.archived=new Date().toISOString(),this.addMessage(o,l,"archive")}}),this._dataStoreListeners.forEach(o=>{var n,h,d,l;this._inboxDataSet&&((h=(n=o.events).onDataSetChange)==null||h.call(n,this._inboxDataSet,"inbox")),this._archiveDataSet&&((l=(d=o.events).onDataSetChange)==null||l.call(d,this._archiveDataSet,"archive"))}),t&&await v.shared.client.inbox.archiveRead()}catch(o){console.error("Error archiving read messages:",o),this._inboxDataSet&&e&&(this._inboxDataSet.messages=e.messages),this._archiveDataSet&&i&&(this._archiveDataSet.messages=i.messages),this._dataStoreListeners.forEach(n=>{var h,d,l,p;this._inboxDataSet&&((d=(h=n.events).onDataSetChange)==null||d.call(h,this._inboxDataSet,"inbox")),this._archiveDataSet&&((p=(l=n.events).onDataSetChange)==null||p.call(l,this._archiveDataSet,"archive"))})}}async readAllMessages({canCallApi:t=!0}={}){var o,n,h,d;if(!v.shared.client)return;const e=this._inboxDataSet,i=this._archiveDataSet,s=this._unreadCount;try{(o=this._inboxDataSet)==null||o.messages.forEach(l=>{l.read||(l.read=new Date().toISOString())}),(n=this._archiveDataSet)==null||n.messages.forEach(l=>{l.read||(l.read=new Date().toISOString())}),this._unreadCount=0,this._dataStoreListeners.forEach(l=>{var p,m,g,f,_,b;this._inboxDataSet&&((m=(p=l.events).onDataSetChange)==null||m.call(p,this._inboxDataSet,"inbox")),this._archiveDataSet&&((f=(g=l.events).onDataSetChange)==null||f.call(g,this._archiveDataSet,"archive")),(b=(_=l.events).onUnreadCountChange)==null||b.call(_,this._unreadCount)}),t&&await v.shared.client.inbox.readAll()}catch(l){(d=(h=v.shared.client)==null?void 0:h.options.logger)==null||d.error("Error reading all messages:",l),this._inboxDataSet&&e&&(this._inboxDataSet.messages=e.messages),this._archiveDataSet&&i&&(this._archiveDataSet.messages=i.messages),this._unreadCount=s,this._dataStoreListeners.forEach(p=>{var m,g,f,_,b,C;this._inboxDataSet&&((g=(m=p.events).onDataSetChange)==null||g.call(m,this._inboxDataSet,"inbox")),this._archiveDataSet&&((_=(f=p.events).onDataSetChange)==null||_.call(f,this._archiveDataSet,"archive")),(C=(b=p.events).onUnreadCountChange)==null||C.call(b,this._unreadCount)})}}findInsertIndex(t,e){const i=[...e];i.push(t),i.sort((o,n)=>{const h=new Date(o.created??Date.now()).getTime();return new Date(n.created??Date.now()).getTime()-h});const s=i.findIndex(o=>o.messageId===t.messageId);return Math.max(s-1,0)}addPage(t,e){switch(e){case"inbox":this._inboxDataSet&&(this._inboxDataSet.canPaginate=t.canPaginate,this._inboxDataSet.paginationCursor=t.paginationCursor,this._inboxDataSet.messages=[...this._inboxDataSet.messages,...t.messages]);break;case"archive":this._archiveDataSet&&(this._archiveDataSet.canPaginate=t.canPaginate,this._archiveDataSet.paginationCursor=t.paginationCursor,this._archiveDataSet.messages=[...this._archiveDataSet.messages,...t.messages]);break}this._dataStoreListeners.forEach(i=>{var s,o;return(o=(s=i.events).onPageAdded)==null?void 0:o.call(s,t,e)})}addMessage(t,e,i){var s,o;switch(i){case"inbox":!t.read&&this._unreadCount!==void 0&&(this._unreadCount=this._unreadCount+1),(s=this._inboxDataSet)==null||s.messages.splice(e,0,t);break;case"archive":(o=this._archiveDataSet)==null||o.messages.splice(e,0,t);break}this._dataStoreListeners.forEach(n=>{var h,d,l,p;(d=(h=n.events).onMessageAdd)==null||d.call(h,t,e,i),(p=(l=n.events).onUnreadCountChange)==null||p.call(l,this._unreadCount??0)})}removeMessage(t,e,i){var s,o;switch(i){case"inbox":!t.read&&this._unreadCount!==void 0&&(this._unreadCount=this._unreadCount-1),(s=this._inboxDataSet)==null||s.messages.splice(e,1);break;case"archive":(o=this._archiveDataSet)==null||o.messages.splice(e,1);break}this._dataStoreListeners.forEach(n=>{var h,d,l,p;(d=(h=n.events).onMessageRemove)==null||d.call(h,t,e,i),(p=(l=n.events).onUnreadCountChange)==null||p.call(l,this._unreadCount??0)})}updateMessage(t,e,i){switch(i){case"inbox":this._unreadCount!==void 0&&!t.archived&&(t.read&&(this._unreadCount=Math.max(0,this._unreadCount-1)),t.read||(this._unreadCount=this._unreadCount+1)),this._inboxDataSet&&(this._inboxDataSet.messages[e]=t);break;case"archive":this._archiveDataSet&&(this._archiveDataSet.messages[e]=t);break}this._dataStoreListeners.forEach(s=>{var o,n,h,d;(n=(o=s.events).onMessageUpdate)==null||n.call(o,t,e,i),(d=(h=s.events).onUnreadCountChange)==null||d.call(h,this._unreadCount??0)})}};a(he,"instance");let P=he;function dn(c){return P.shared.readMessage({message:c})}function un(c){return P.shared.unreadMessage({message:c})}function pn(c){return P.shared.clickMessage({message:c})}function gn(c){return P.shared.archiveMessage({message:c})}function mn(c){return P.shared.openMessage({message:c})}function rt(c){if(!c.created)return"Now";const t=new Date,e=new Date(c.created),i=Math.floor((t.getTime()-e.getTime())/1e3);return i<60?`${i}s`:i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:i<604800?`${Math.floor(i/86400)}d`:i<31536e3?`${Math.floor(i/604800)}w`:`${Math.floor(i/31536e3)}y`}class at extends HTMLElement{constructor(e){super();a(this,"_theme");a(this,"_options",[]);a(this,"_style");this._theme=e;const i=this.attachShadow({mode:"open"});this._style=document.createElement("style"),this._style.textContent=this.getStyles(),i.appendChild(this._style);const s=document.createElement("ul");s.className="menu",i.appendChild(s)}getStyles(){var i,s,o;const e=(o=(s=(i=this._theme.inbox)==null?void 0:i.list)==null?void 0:s.item)==null?void 0:o.menu;return`
|
|
186
|
+
`}updateIconColor(i){this._icon.updateColor(i)}updateIconSVG(i){this._icon.updateSVG(i)}updateBackgroundColor(i){this._backgroundColor=i,this.refresh()}updateHoverBackgroundColor(i){this._hoverBackgroundColor=i,this.refresh()}updateActiveBackgroundColor(i){this._activeBackgroundColor=i,this.refresh()}}customElements.get("courier-icon-button")||customElements.define("courier-icon-button",re),[{name:"courier-button",class:Ie},{name:"courier-icon",class:ie},{name:"courier-link",class:Pe},{name:"courier-info-state",class:Te},{name:"courier-icon-button",class:re}].forEach(({name:m,class:i})=>{customElements.get(m)||customElements.define(m,i)});const se=class se{constructor(){a(this,"_inboxDataSet");a(this,"_archiveDataSet");a(this,"_dataStoreListeners",[]);a(this,"_unreadCount");a(this,"isPaginatingInbox",!1);a(this,"isPaginatingArchive",!1)}static get shared(){return se.instance||(se.instance=new se),se.instance}get unreadCount(){return this._unreadCount??0}get inboxDataSet(){return this._inboxDataSet??{messages:[],canPaginate:!1,paginationCursor:null}}get archiveDataSet(){return this._archiveDataSet??{messages:[],canPaginate:!1,paginationCursor:null}}addDataStoreListener(i){this._dataStoreListeners.push(i)}removeDataStoreListener(i){this._dataStoreListeners=this._dataStoreListeners.filter(e=>e!==i)}async fetchDataSet(i){var t,s,o,n,h,d,c,u,g,p;if(i.canUseCache)switch(i.feedType){case"inbox":if(this._inboxDataSet)return this._inboxDataSet;break;case"archive":if(this._archiveDataSet)return this._archiveDataSet;break}const e=i.feedType==="inbox"?await((t=_.Courier.shared.client)==null?void 0:t.inbox.getMessages()):await((s=_.Courier.shared.client)==null?void 0:s.inbox.getArchivedMessages());return{messages:((n=(o=e==null?void 0:e.data)==null?void 0:o.messages)==null?void 0:n.nodes)??[],canPaginate:((c=(d=(h=e==null?void 0:e.data)==null?void 0:h.messages)==null?void 0:d.pageInfo)==null?void 0:c.hasNextPage)??!1,paginationCursor:((p=(g=(u=e==null?void 0:e.data)==null?void 0:u.messages)==null?void 0:g.pageInfo)==null?void 0:p.startCursor)??null}}async fetchUnreadCount(i){var t;return i.canUseCache&&this._unreadCount!==void 0?this._unreadCount:await((t=_.Courier.shared.client)==null?void 0:t.inbox.getUnreadMessageCount())??0}async load(i){var e,t,s;try{if(!((e=_.Courier.shared.client)!=null&&e.options.userId))throw new Error("User is not signed in");const o=i??{feedType:"inbox",canUseCache:!0},[n,h]=await Promise.all([this.fetchDataSet(o),this.fetchUnreadCount(o)]);switch(o.feedType){case"inbox":this._inboxDataSet=n;break;case"archive":this._archiveDataSet=n;break}this._unreadCount=h,this._dataStoreListeners.forEach(d=>{var c,u,g,p;(u=(c=d.events).onDataSetChange)==null||u.call(c,n,o.feedType),(p=(g=d.events).onUnreadCountChange)==null||p.call(g,this._unreadCount??0)}),await this.connectSocket()}catch(o){(s=(t=_.Courier.shared.client)==null?void 0:t.options.logger)==null||s.error("Error loading inbox:",o),this._dataStoreListeners.forEach(n=>{var h,d;(d=(h=n.events).onError)==null||d.call(h,o)})}}async connectSocket(){var e,t,s,o,n,h,d,c,u,g,p,x;const i=(e=_.Courier.shared.client)==null?void 0:e.inbox.socket;try{if(!i){(s=(t=_.Courier.shared.client)==null?void 0:t.options.logger)==null||s.info("CourierInbox socket not available");return}if((h=(o=_.Courier.shared.client)==null?void 0:o.options.logger)==null||h.info("CourierInbox socket connectionId:",(n=_.Courier.shared.client)==null?void 0:n.options.connectionId),i.isConnected){(c=(d=_.Courier.shared.client)==null?void 0:d.options.logger)==null||c.info("CourierInbox socket already connected. Socket will not attempt reconnection.");return}i.receivedMessage=f=>{this.addMessage(f,0,"inbox")},i.receivedMessageEvent=f=>{let b;switch(f.messageId&&(b=this.getMessage({messageId:f.messageId})),f.event){case"mark-all-read":this.readAllMessages({canCallApi:!1});break;case"read":b&&this.readMessage({message:b,canCallApi:!1});break;case"unread":b&&this.unreadMessage({message:b,canCallApi:!1});break;case"opened":b&&this.openMessage({message:b,canCallApi:!1});break;case"archive":b&&this.archiveMessage({message:b,canCallApi:!1});break;case"archive-read":this.archiveReadMessages({canCallApi:!1});break;case"click":b&&this.clickMessage({message:b,canCallApi:!1});break;case"unopened":case"unarchive":break}},await i.connect(),await i.sendSubscribe(),i.keepAlive(),(g=(u=_.Courier.shared.client)==null?void 0:u.options.logger)==null||g.info("CourierInbox socket connected")}catch(f){(x=(p=_.Courier.shared.client)==null?void 0:p.options.logger)==null||x.error("Failed to connect socket:",f)}}getMessage(i){var e,t;return((e=this._inboxDataSet)==null?void 0:e.messages.find(s=>s.messageId===i.messageId))??((t=this._archiveDataSet)==null?void 0:t.messages.find(s=>s.messageId===i.messageId))}async fetchNextPageOfMessages(i){var e,t,s,o,n,h,d,c,u,g,p,x,f,b,v,k,w,S,M,I,L,A,$,F;switch(i.feedType){case"inbox":if(this.isPaginatingInbox)return null;if((e=this._inboxDataSet)!=null&&e.canPaginate&&this._inboxDataSet.paginationCursor)try{this.isPaginatingInbox=!0;const y=await((t=_.Courier.shared.client)==null?void 0:t.inbox.getMessages({paginationLimit:_.Courier.shared.paginationLimit,startCursor:this._inboxDataSet.paginationCursor})),D={messages:((o=(s=y==null?void 0:y.data)==null?void 0:s.messages)==null?void 0:o.nodes)??[],canPaginate:((d=(h=(n=y==null?void 0:y.data)==null?void 0:n.messages)==null?void 0:h.pageInfo)==null?void 0:d.hasNextPage)??!1,paginationCursor:((g=(u=(c=y==null?void 0:y.data)==null?void 0:c.messages)==null?void 0:u.pageInfo)==null?void 0:g.startCursor)??null};return this.addPage(D,"inbox"),D}catch(y){return(x=(p=_.Courier.shared.client)==null?void 0:p.options.logger)==null||x.error("Error fetching next page of inbox messages:",y),null}finally{this.isPaginatingInbox=!1}break;case"archive":if(this.isPaginatingArchive)return null;if((f=this._archiveDataSet)!=null&&f.canPaginate&&this._archiveDataSet.paginationCursor)try{this.isPaginatingArchive=!0;const y=await((b=_.Courier.shared.client)==null?void 0:b.inbox.getArchivedMessages({paginationLimit:_.Courier.shared.paginationLimit,startCursor:this._archiveDataSet.paginationCursor})),D={messages:((k=(v=y==null?void 0:y.data)==null?void 0:v.messages)==null?void 0:k.nodes)??[],canPaginate:((M=(S=(w=y==null?void 0:y.data)==null?void 0:w.messages)==null?void 0:S.pageInfo)==null?void 0:M.hasNextPage)??!1,paginationCursor:((A=(L=(I=y==null?void 0:y.data)==null?void 0:I.messages)==null?void 0:L.pageInfo)==null?void 0:A.startCursor)??null};return this.addPage(D,"archive"),D}catch(y){return(F=($=_.Courier.shared.client)==null?void 0:$.options.logger)==null||F.error("Error fetching next page of archived messages:",y),null}finally{this.isPaginatingArchive=!1}break}return null}applyLocalMessageChange(i,e){for(const[t,s]of Object.entries(e))s!==void 0&&this.updateMessage(i,s,t)}async readMessage({message:i,canCallApi:e=!0}){var o,n,h,d;if(!_.Courier.shared.client)return;const t=i;if(t.read)return;const s={inbox:(o=this._inboxDataSet)==null?void 0:o.messages.findIndex(c=>c.messageId===i.messageId),archive:(n=this._archiveDataSet)==null?void 0:n.messages.findIndex(c=>c.messageId===i.messageId)};try{i.read=new Date().toISOString(),this.applyLocalMessageChange(i,s),e&&await _.Courier.shared.client.inbox.read({messageId:i.messageId})}catch(c){this.applyLocalMessageChange(t,s),(d=(h=_.Courier.shared.client)==null?void 0:h.options.logger)==null||d.error("Error reading message:",c)}}async unreadMessage({message:i,canCallApi:e=!0}){var o,n,h,d;if(!_.Courier.shared.client)return;const t=i;if(!t.read)return;const s={inbox:(o=this._inboxDataSet)==null?void 0:o.messages.findIndex(c=>c.messageId===i.messageId),archive:(n=this._archiveDataSet)==null?void 0:n.messages.findIndex(c=>c.messageId===i.messageId)};try{i.read=void 0,this.applyLocalMessageChange(i,s),e&&await _.Courier.shared.client.inbox.unread({messageId:i.messageId})}catch(c){this.applyLocalMessageChange(t,s),(d=(h=_.Courier.shared.client)==null?void 0:h.options.logger)==null||d.error("Error unreading message:",c)}}async openMessage({message:i,canCallApi:e=!0}){var o,n,h,d;if(!_.Courier.shared.client)return;const t=i,s={inbox:(o=this._inboxDataSet)==null?void 0:o.messages.findIndex(c=>c.messageId===i.messageId),archive:(n=this._archiveDataSet)==null?void 0:n.messages.findIndex(c=>c.messageId===i.messageId)};if(!(!s.inbox&&!s.archive)&&!t.opened)try{i.opened=new Date().toISOString(),this.applyLocalMessageChange(i,s),e&&await _.Courier.shared.client.inbox.open({messageId:i.messageId})}catch(c){this.applyLocalMessageChange(t,s),(d=(h=_.Courier.shared.client)==null?void 0:h.options.logger)==null||d.error("Error opening message:",c)}}async clickMessage({message:i,canCallApi:e=!0}){var t,s,o,n;if(_.Courier.shared.client)try{(t=i.trackingIds)!=null&&t.clickTrackingId&&e&&await _.Courier.shared.client.inbox.click({messageId:i.messageId,trackingId:(s=i.trackingIds)==null?void 0:s.clickTrackingId})}catch(h){(n=(o=_.Courier.shared.client)==null?void 0:o.options.logger)==null||n.error("Error clicking message:",h)}}async archiveMessage({message:i,canCallApi:e=!0}){var o,n;if(!_.Courier.shared.client)return;const t=i,s=(o=this._inboxDataSet)==null?void 0:o.messages.findIndex(h=>h.messageId===i.messageId);if(s!==void 0)try{if(this.removeMessage(i,s,"inbox"),(n=this._archiveDataSet)!=null&&n.messages){const h=this.findInsertIndex(i,this._archiveDataSet.messages);i.archived=new Date().toISOString(),this.addMessage(i,h,"archive")}e&&await _.Courier.shared.client.inbox.archive({messageId:i.messageId})}catch{this.addMessage(t,s,"inbox"),i.archived=void 0,this.removeMessage(i,s,"archive")}}async archiveReadMessages({canCallApi:i=!0}={}){var s;if(!_.Courier.shared.client)return;const e=this._inboxDataSet,t=this._archiveDataSet;try{(s=this._inboxDataSet)==null||s.messages.forEach(o=>{var h,d;if(!o.read)return;const n=(h=this._inboxDataSet)==null?void 0:h.messages.findIndex(c=>c.messageId===o.messageId);if(n!==void 0&&(this.removeMessage(o,n,"inbox"),(d=this._archiveDataSet)!=null&&d.messages)){const c=this.findInsertIndex(o,this._archiveDataSet.messages);o.archived=new Date().toISOString(),this.addMessage(o,c,"archive")}}),this._dataStoreListeners.forEach(o=>{var n,h,d,c;this._inboxDataSet&&((h=(n=o.events).onDataSetChange)==null||h.call(n,this._inboxDataSet,"inbox")),this._archiveDataSet&&((c=(d=o.events).onDataSetChange)==null||c.call(d,this._archiveDataSet,"archive"))}),i&&await _.Courier.shared.client.inbox.archiveRead()}catch(o){console.error("Error archiving read messages:",o),this._inboxDataSet&&e&&(this._inboxDataSet.messages=e.messages),this._archiveDataSet&&t&&(this._archiveDataSet.messages=t.messages),this._dataStoreListeners.forEach(n=>{var h,d,c,u;this._inboxDataSet&&((d=(h=n.events).onDataSetChange)==null||d.call(h,this._inboxDataSet,"inbox")),this._archiveDataSet&&((u=(c=n.events).onDataSetChange)==null||u.call(c,this._archiveDataSet,"archive"))})}}async readAllMessages({canCallApi:i=!0}={}){var o,n,h,d;if(!_.Courier.shared.client)return;const e=this._inboxDataSet,t=this._archiveDataSet,s=this._unreadCount;try{(o=this._inboxDataSet)==null||o.messages.forEach(c=>{c.read||(c.read=new Date().toISOString())}),(n=this._archiveDataSet)==null||n.messages.forEach(c=>{c.read||(c.read=new Date().toISOString())}),this._unreadCount=0,this._dataStoreListeners.forEach(c=>{var u,g,p,x,f,b;this._inboxDataSet&&((g=(u=c.events).onDataSetChange)==null||g.call(u,this._inboxDataSet,"inbox")),this._archiveDataSet&&((x=(p=c.events).onDataSetChange)==null||x.call(p,this._archiveDataSet,"archive")),(b=(f=c.events).onUnreadCountChange)==null||b.call(f,this._unreadCount)}),i&&await _.Courier.shared.client.inbox.readAll()}catch(c){(d=(h=_.Courier.shared.client)==null?void 0:h.options.logger)==null||d.error("Error reading all messages:",c),this._inboxDataSet&&e&&(this._inboxDataSet.messages=e.messages),this._archiveDataSet&&t&&(this._archiveDataSet.messages=t.messages),this._unreadCount=s,this._dataStoreListeners.forEach(u=>{var g,p,x,f,b,v;this._inboxDataSet&&((p=(g=u.events).onDataSetChange)==null||p.call(g,this._inboxDataSet,"inbox")),this._archiveDataSet&&((f=(x=u.events).onDataSetChange)==null||f.call(x,this._archiveDataSet,"archive")),(v=(b=u.events).onUnreadCountChange)==null||v.call(b,this._unreadCount)})}}findInsertIndex(i,e){const t=[...e];t.push(i),t.sort((o,n)=>{const h=new Date(o.created??Date.now()).getTime();return new Date(n.created??Date.now()).getTime()-h});const s=t.findIndex(o=>o.messageId===i.messageId);return Math.max(s-1,0)}addPage(i,e){switch(e){case"inbox":this._inboxDataSet&&(this._inboxDataSet.canPaginate=i.canPaginate,this._inboxDataSet.paginationCursor=i.paginationCursor,this._inboxDataSet.messages=[...this._inboxDataSet.messages,...i.messages]);break;case"archive":this._archiveDataSet&&(this._archiveDataSet.canPaginate=i.canPaginate,this._archiveDataSet.paginationCursor=i.paginationCursor,this._archiveDataSet.messages=[...this._archiveDataSet.messages,...i.messages]);break}this._dataStoreListeners.forEach(t=>{var s,o;return(o=(s=t.events).onPageAdded)==null?void 0:o.call(s,i,e)})}addMessage(i,e,t){var s,o;switch(t){case"inbox":!i.read&&this._unreadCount!==void 0&&(this._unreadCount=this._unreadCount+1),(s=this._inboxDataSet)==null||s.messages.splice(e,0,i);break;case"archive":(o=this._archiveDataSet)==null||o.messages.splice(e,0,i);break}this._dataStoreListeners.forEach(n=>{var h,d,c,u;(d=(h=n.events).onMessageAdd)==null||d.call(h,i,e,t),(u=(c=n.events).onUnreadCountChange)==null||u.call(c,this._unreadCount??0)})}removeMessage(i,e,t){var s,o;switch(t){case"inbox":!i.read&&this._unreadCount!==void 0&&(this._unreadCount=this._unreadCount-1),(s=this._inboxDataSet)==null||s.messages.splice(e,1);break;case"archive":(o=this._archiveDataSet)==null||o.messages.splice(e,1);break}this._dataStoreListeners.forEach(n=>{var h,d,c,u;(d=(h=n.events).onMessageRemove)==null||d.call(h,i,e,t),(u=(c=n.events).onUnreadCountChange)==null||u.call(c,this._unreadCount??0)})}updateMessage(i,e,t){switch(t){case"inbox":this._unreadCount!==void 0&&!i.archived&&(i.read&&(this._unreadCount=Math.max(0,this._unreadCount-1)),i.read||(this._unreadCount=this._unreadCount+1)),this._inboxDataSet&&(this._inboxDataSet.messages[e]=i);break;case"archive":this._archiveDataSet&&(this._archiveDataSet.messages[e]=i);break}this._dataStoreListeners.forEach(s=>{var o,n,h,d;(n=(o=s.events).onMessageUpdate)==null||n.call(o,i,e,t),(d=(h=s.events).onUnreadCountChange)==null||d.call(h,this._unreadCount??0)})}};a(se,"instance");let B=se;function $o(m){return B.shared.readMessage({message:m})}function Fo(m){return B.shared.unreadMessage({message:m})}function Ho(m){return B.shared.clickMessage({message:m})}function Ro(m){return B.shared.archiveMessage({message:m})}function zo(m){return B.shared.openMessage({message:m})}function We(m){if(!m.created)return"Now";const i=new Date,e=new Date(m.created),t=Math.floor((i.getTime()-e.getTime())/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:t<604800?`${Math.floor(t/86400)}d`:t<31536e3?`${Math.floor(t/604800)}w`:`${Math.floor(t/31536e3)}y`}class Ge extends HTMLElement{constructor(e){super();a(this,"_theme");a(this,"_options",[]);a(this,"_style");this._theme=e;const t=this.attachShadow({mode:"open"});this._style=document.createElement("style"),this._style.textContent=this.getStyles(),t.appendChild(this._style);const s=document.createElement("ul");s.className="menu",t.appendChild(s)}getStyles(){var t,s,o;const e=(o=(s=(t=this._theme.inbox)==null?void 0:t.list)==null?void 0:s.item)==null?void 0:o.menu;return`
|
|
317
187
|
:host {
|
|
318
188
|
display: block;
|
|
319
189
|
position: absolute;
|
|
@@ -349,7 +219,7 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
349
219
|
border-bottom: none;
|
|
350
220
|
background: transparent;
|
|
351
221
|
}
|
|
352
|
-
`}setOptions(e){this._options=e,this.renderMenu()}renderMenu(){var o,n,h,d;const e=(o=this.shadowRoot)==null?void 0:o.querySelector("ul.menu");if(!e)return;e.innerHTML="";const
|
|
222
|
+
`}setOptions(e){this._options=e,this.renderMenu()}renderMenu(){var o,n,h,d;const e=(o=this.shadowRoot)==null?void 0:o.querySelector("ul.menu");if(!e)return;e.innerHTML="";const t=(d=(h=(n=this._theme.inbox)==null?void 0:n.list)==null?void 0:h.item)==null?void 0:d.menu,s=c=>{c.stopPropagation(),c.preventDefault()};this._options.forEach(c=>{var p,x,f;const u=new re(c.icon.svg,c.icon.color,t==null?void 0:t.backgroundColor,(p=t==null?void 0:t.item)==null?void 0:p.hoverBackgroundColor,(x=t==null?void 0:t.item)==null?void 0:x.activeBackgroundColor,(f=t==null?void 0:t.item)==null?void 0:f.borderRadius),g=b=>{s(b),c.onClick()};u.addEventListener("click",g),u.addEventListener("touchstart",s),u.addEventListener("touchend",g),u.addEventListener("touchmove",s),u.addEventListener("mousedown",s),u.addEventListener("mouseup",s),e.appendChild(u)})}show(){this.classList.add("visible")}hide(){this.classList.remove("visible")}}customElements.get("courier-list-item-menu")||customElements.define("courier-list-item-menu",Ge);class $e extends HTMLElement{constructor(e){super();a(this,"_theme");a(this,"_message",null);a(this,"_feedType","inbox");a(this,"_isMobile",!1);a(this,"_titleElement");a(this,"_subtitleElement");a(this,"_timeElement");a(this,"_style");a(this,"_menu");a(this,"_unreadIndicator");a(this,"_actionsContainer");a(this,"_longPressTimeout",null);a(this,"_isLongPress",!1);a(this,"onItemClick",null);a(this,"onItemLongPress",null);a(this,"onItemActionClick",null);this._theme=e,this._isMobile="ontouchstart"in window;const t=this.attachShadow({mode:"open"}),s=document.createElement("div");s.className="content-container",this._titleElement=document.createElement("p"),this._titleElement.setAttribute("part","title"),this._subtitleElement=document.createElement("p"),this._subtitleElement.setAttribute("part","subtitle"),this._actionsContainer=document.createElement("div"),this._actionsContainer.className="actions-container",s.appendChild(this._titleElement),s.appendChild(this._subtitleElement),s.appendChild(this._actionsContainer),this._timeElement=document.createElement("p"),this._timeElement.setAttribute("part","time"),this._unreadIndicator=document.createElement("div"),this._unreadIndicator.className="unread-indicator",this._style=document.createElement("style"),this._refreshStyles(),this._menu=new Ge(this._theme),this._menu.setOptions(this._getMenuOptions()),t.append(this._style,this._unreadIndicator,s,this._timeElement,this._menu);const o=n=>{n.stopPropagation(),n.preventDefault()};this._menu.addEventListener("mousedown",o),this._menu.addEventListener("pointerdown",o),this._menu.addEventListener("click",o),this.addEventListener("click",n=>{this._menu.contains(n.target)||n.composedPath().includes(this._menu)||this._message&&this.onItemClick&&!(n.target instanceof ie)&&!this._isLongPress&&this.onItemClick(this._message)}),this._setupHoverBehavior(),this._setupLongPressBehavior()}_setupHoverBehavior(){this._isMobile||(this.addEventListener("mouseenter",()=>{this._isLongPress=!1,this._showMenu()}),this.addEventListener("mouseleave",()=>this._hideMenu()))}_setupLongPressBehavior(){var s,o,n;const e=(n=(o=(s=this._theme.inbox)==null?void 0:s.list)==null?void 0:o.item)==null?void 0:n.menu;if(!(e!=null&&e.enabled))return;const t=e.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((t==null?void 0:t.vibrationDuration)??50)),setTimeout(()=>{this._hideMenu(),this._isLongPress=!1},(t==null?void 0:t.displayDuration)??2e3)},650)},{passive:!0}),this.addEventListener("touchend",()=>{this._longPressTimeout&&(window.clearTimeout(this._longPressTimeout),this._longPressTimeout=null)})}setOnLongPress(e){this.onItemLongPress=e}_getMenuOptions(){var s,o,n,h,d,c,u,g,p,x,f,b,v,k,w,S,M,I,L;const e=(h=(n=(o=(s=this._theme.inbox)==null?void 0:s.list)==null?void 0:o.item)==null?void 0:n.menu)==null?void 0:h.item;let t=[];return(d=this._message)!=null&&d.archived||t.push({id:(c=this._message)!=null&&c.read?"unread":"read",icon:{svg:(u=this._message)!=null&&u.read?(g=e==null?void 0:e.unread)==null?void 0:g.svg:(p=e==null?void 0:e.read)==null?void 0:p.svg,color:(x=this._message)!=null&&x.read?(f=e==null?void 0:e.unread)==null?void 0:f.color:((b=e==null?void 0:e.read)==null?void 0:b.color)??"red"},onClick:()=>{this._message&&(this._message.read?B.shared.unreadMessage({message:this._message}):B.shared.readMessage({message:this._message}))}}),t.push({id:(v=this._message)!=null&&v.archived?"unarchive":"archive",icon:{svg:(k=this._message)!=null&&k.archived?(w=e==null?void 0:e.unarchive)==null?void 0:w.svg:(S=e==null?void 0:e.archive)==null?void 0:S.svg,color:(M=this._message)!=null&&M.archived?(I=e==null?void 0:e.unarchive)==null?void 0:I.color:((L=e==null?void 0:e.archive)==null?void 0:L.color)??"red"},onClick:()=>{this._message&&(this._message.archived?alert("unarchive"):B.shared.archiveMessage({message:this._message}))}}),t}_showMenu(){var t,s,o;const e=(o=(s=(t=this._theme.inbox)==null?void 0:t.list)==null?void 0:s.item)==null?void 0:o.menu;e&&e.enabled&&(this._menu.setOptions(this._getMenuOptions()),this._menu.style.display="block",this._menu.show(),this._timeElement.style.opacity="0")}_hideMenu(){var t,s,o;const e=(o=(s=(t=this._theme.inbox)==null?void 0:t.list)==null?void 0:s.item)==null?void 0:o.menu;e&&e.enabled&&(this._menu.hide(),this._menu.style.display="none",this._timeElement.style.opacity="1")}_getStyles(){var t,s,o,n,h,d,c,u,g,p,x;const e=(s=(t=this._theme.inbox)==null?void 0:t.list)==null?void 0:s.item;return`
|
|
353
223
|
:host {
|
|
354
224
|
display: flex;
|
|
355
225
|
flex-direction: row;
|
|
@@ -440,14 +310,14 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
440
310
|
|
|
441
311
|
p[part='subtitle'] {
|
|
442
312
|
font-family: ${((d=e==null?void 0:e.subtitle)==null?void 0:d.family)??"inherit"};
|
|
443
|
-
font-size: ${((
|
|
444
|
-
color: ${((
|
|
313
|
+
font-size: ${((c=e==null?void 0:e.subtitle)==null?void 0:c.size)??"14px"};
|
|
314
|
+
color: ${((u=e==null?void 0:e.subtitle)==null?void 0:u.color)??"red"};
|
|
445
315
|
}
|
|
446
316
|
|
|
447
317
|
p[part='time'] {
|
|
448
|
-
font-family: ${((
|
|
449
|
-
font-size: ${((
|
|
450
|
-
color: ${((
|
|
318
|
+
font-family: ${((g=e==null?void 0:e.time)==null?void 0:g.family)??"inherit"};
|
|
319
|
+
font-size: ${((p=e==null?void 0:e.time)==null?void 0:p.size)??"14px"};
|
|
320
|
+
color: ${((x=e==null?void 0:e.time)==null?void 0:x.color)??"red"};
|
|
451
321
|
text-align: right;
|
|
452
322
|
white-space: nowrap;
|
|
453
323
|
}
|
|
@@ -470,7 +340,7 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
470
340
|
display: none;
|
|
471
341
|
}
|
|
472
342
|
|
|
473
|
-
`}_refreshStyles(){this._style.textContent=this._getStyles()}connectedCallback(){var s,o;const e=this.getAttribute("message"),
|
|
343
|
+
`}_refreshStyles(){this._style.textContent=this._getStyles()}connectedCallback(){var s,o;const e=this.getAttribute("message"),t=this.getAttribute("feed-type");if(t&&(this._feedType=t),e)try{this._message=JSON.parse(e),this._updateContent()}catch(n){(o=(s=_.Courier.shared.client)==null?void 0:s.options.logger)==null||o.error("CourierListItem – failed to parse message:",n)}}setMessage(e,t){this._message=e,this._feedType=t,this._updateContent()}setOnItemClick(e){this.onItemClick=e}setOnItemActionClick(e){this.onItemActionClick=e}setOnItemLongPress(e){this.onItemLongPress=e}_updateContent(){var s,o,n,h,d,c;if(!this._message){this._titleElement.textContent="",this._subtitleElement.textContent="";return}this.classList.toggle("unread",!this._message.read&&this._feedType!=="archive"),this._titleElement.textContent=this._message.title||"Untitled Message",this._subtitleElement.textContent=this._message.preview||this._message.body||"",this._timeElement.textContent=We(this._message),this._menu.setOptions(this._getMenuOptions());const e=((s=this._message)==null?void 0:s.actions)&&this._message.actions.length>0;this._actionsContainer.style.display=e?"flex":"none";const t=(h=(n=(o=this._theme.inbox)==null?void 0:o.list)==null?void 0:n.item)==null?void 0:h.actions;(c=(d=this._message)==null?void 0:d.actions)==null||c.forEach(u=>{var p,x,f,b;const g=new Ie({text:u.content,variant:"secondary",backgroundColor:t==null?void 0:t.backgroundColor,hoverBackgroundColor:t==null?void 0:t.hoverBackgroundColor,activeBackgroundColor:t==null?void 0:t.activeBackgroundColor,border:t==null?void 0:t.border,borderRadius:t==null?void 0:t.borderRadius,shadow:t==null?void 0:t.shadow,fontFamily:(p=t==null?void 0:t.font)==null?void 0:p.family,fontSize:(x=t==null?void 0:t.font)==null?void 0:x.size,fontWeight:(f=t==null?void 0:t.font)==null?void 0:f.weight,textColor:(b=t==null?void 0:t.font)==null?void 0:b.color,onClick:()=>{this._message&&this.onItemActionClick&&this.onItemActionClick(this._message,u)}});this._actionsContainer.appendChild(g)})}}customElements.get("courier-list-item")||customElements.define("courier-list-item",$e);class qe extends HTMLElement{constructor(e,t){super();a(this,"_shadow");this._shadow=this.attachShadow({mode:"open"});const s=document.createElement("style");s.textContent=this.getStyles(t),this._shadow.appendChild(s);const o=new Ae(e,35),n=new Ae(e,100),h=new Ae(e,82);this._shadow.appendChild(o),this._shadow.appendChild(n),this._shadow.appendChild(h)}getStyles(e){return`
|
|
474
344
|
:host {
|
|
475
345
|
display: flex;
|
|
476
346
|
flex-direction: column;
|
|
@@ -480,27 +350,27 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
480
350
|
box-sizing: border-box;
|
|
481
351
|
opacity: ${e};
|
|
482
352
|
}
|
|
483
|
-
`}}customElements.get("courier-inbox-skeleton-list-item")||customElements.define("courier-inbox-skeleton-list-item",
|
|
353
|
+
`}}customElements.get("courier-inbox-skeleton-list-item")||customElements.define("courier-inbox-skeleton-list-item",qe);class Ae extends HTMLElement{constructor(e,t){super();a(this,"_shadow");this._shadow=this.attachShadow({mode:"open"});const s=document.createElement("style");s.textContent=this.getStyles(e,t),this._shadow.appendChild(s);const o=document.createElement("div");o.className="skeleton-item",this._shadow.appendChild(o)}getStyles(e,t){var g,p,x,f,b,v,k,w,S,M,I,L;const s=((x=(p=(g=e.inbox)==null?void 0:g.loading)==null?void 0:p.animation)==null?void 0:x.barColor)??"#000",o=s.length===4?`#${s[1]}${s[1]}${s[2]}${s[2]}${s[3]}${s[3]}`:s,n=parseInt(o.slice(1,3),16),h=parseInt(o.slice(3,5),16),d=parseInt(o.slice(5,7),16),c=`rgba(${n}, ${h}, ${d}, 0.8)`,u=`rgba(${n}, ${h}, ${d}, 0.4)`;return`
|
|
484
354
|
:host {
|
|
485
355
|
display: flex;
|
|
486
356
|
height: 100%;
|
|
487
|
-
width: ${
|
|
357
|
+
width: ${t}%;
|
|
488
358
|
align-items: flex-start;
|
|
489
359
|
justify-content: flex-start;
|
|
490
360
|
}
|
|
491
361
|
|
|
492
362
|
.skeleton-item {
|
|
493
|
-
height: ${((
|
|
363
|
+
height: ${((v=(b=(f=e.inbox)==null?void 0:f.loading)==null?void 0:b.animation)==null?void 0:v.barHeight)??"14px"};
|
|
494
364
|
width: 100%;
|
|
495
365
|
background: linear-gradient(
|
|
496
366
|
90deg,
|
|
497
|
-
${
|
|
498
|
-
${
|
|
499
|
-
${
|
|
367
|
+
${c} 25%,
|
|
368
|
+
${u} 50%,
|
|
369
|
+
${c} 75%
|
|
500
370
|
);
|
|
501
371
|
background-size: 200% 100%;
|
|
502
372
|
animation: shimmer ${((S=(w=(k=e.inbox)==null?void 0:k.loading)==null?void 0:w.animation)==null?void 0:S.duration)??"2s"} ease-in-out infinite;
|
|
503
|
-
border-radius: ${((
|
|
373
|
+
border-radius: ${((L=(I=(M=e.inbox)==null?void 0:M.loading)==null?void 0:I.animation)==null?void 0:L.barBorderRadius)??"14px"};
|
|
504
374
|
}
|
|
505
375
|
|
|
506
376
|
@keyframes shimmer {
|
|
@@ -511,7 +381,7 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
511
381
|
background-position: -200% 0;
|
|
512
382
|
}
|
|
513
383
|
}
|
|
514
|
-
`}}customElements.get("courier-skeleton-animated-row")||customElements.define("courier-skeleton-animated-row",
|
|
384
|
+
`}}customElements.get("courier-skeleton-animated-row")||customElements.define("courier-skeleton-animated-row",Ae);class Fe extends Le{constructor(e){super();a(this,"_theme");this._theme=e}defaultElement(){const e=document.createElement("div");e.className="list";const t=document.createElement("style");t.textContent=this.getStyles(),e.appendChild(t);for(let s=0;s<3;s++){const o=new qe(this._theme,1/(s+1));e.appendChild(o)}return this.shadow.appendChild(e),e}getStyles(){var e,t;return`
|
|
515
385
|
:host {
|
|
516
386
|
display: flex;
|
|
517
387
|
height: 100%;
|
|
@@ -530,13 +400,13 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
530
400
|
}
|
|
531
401
|
|
|
532
402
|
.list > * {
|
|
533
|
-
border-bottom: ${((
|
|
403
|
+
border-bottom: ${((t=(e=this._theme.inbox)==null?void 0:e.loading)==null?void 0:t.divider)??"1px solid red"};
|
|
534
404
|
}
|
|
535
405
|
|
|
536
406
|
.list > *:last-child {
|
|
537
407
|
border-bottom: none;
|
|
538
408
|
}
|
|
539
|
-
`}}customElements.get("courier-inbox-skeleton-list")||customElements.define("courier-inbox-skeleton-list",
|
|
409
|
+
`}}customElements.get("courier-inbox-skeleton-list")||customElements.define("courier-inbox-skeleton-list",Fe);class Xe extends HTMLElement{constructor(e){super();a(this,"skeletonLoadingList");a(this,"observer");a(this,"customItem");a(this,"onPaginationTrigger");this.onPaginationTrigger=e.onPaginationTrigger,this.customItem=e.customItem;const t=this.attachShadow({mode:"open"}),s=document.createElement("style");if(s.textContent=this.getStyles(),t.appendChild(s),this.customItem)t.appendChild(this.customItem);else{const o=document.createElement("div");o.className="skeleton-container",this.skeletonLoadingList=new Fe(e.theme),this.skeletonLoadingList.build(void 0),o.appendChild(this.skeletonLoadingList),t.appendChild(o)}this.observer=new IntersectionObserver(o=>{o.forEach(n=>{n.isIntersecting&&this.onPaginationTrigger()})}),this.observer.observe(this)}getStyles(){return`
|
|
540
410
|
:host {
|
|
541
411
|
padding: 0;
|
|
542
412
|
margin: 0;
|
|
@@ -546,7 +416,7 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
546
416
|
.skeleton-container {
|
|
547
417
|
height: 150%;
|
|
548
418
|
}
|
|
549
|
-
`}disconnectedCallback(){this.observer.disconnect()}}customElements.get("courier-inbox-pagination-list-item")||customElements.define("courier-inbox-pagination-list-item",
|
|
419
|
+
`}disconnectedCallback(){this.observer.disconnect()}}customElements.get("courier-inbox-pagination-list-item")||customElements.define("courier-inbox-pagination-list-item",Xe);class Ye extends HTMLElement{constructor(e){super();a(this,"_themeSubscription");a(this,"_messages",[]);a(this,"_feedType","inbox");a(this,"_isLoading",!0);a(this,"_error",null);a(this,"_canPaginate",!1);a(this,"_onMessageClick",null);a(this,"_onMessageActionClick",null);a(this,"_onMessageLongPress",null);a(this,"_onRefresh");a(this,"_onPaginationTrigger");a(this,"_listItemFactory");a(this,"_paginationItemFactory");a(this,"_loadingStateFactory");a(this,"_emptyStateFactory");a(this,"_errorStateFactory");this._themeSubscription=e.themeManager.subscribe(o=>{this.refreshTheme()}),this._onRefresh=e.onRefresh,this._onPaginationTrigger=e.onPaginationTrigger,this._onMessageClick=e.onMessageClick,this._onMessageActionClick=e.onMessageActionClick,this._onMessageLongPress=e.onMessageLongPress;const t=this.attachShadow({mode:"open"}),s=document.createElement("style");s.textContent=this.getStyles(),t.appendChild(s)}get messages(){return this._messages}getStyles(){var t;const e=(t=this._themeSubscription.manager.getTheme().inbox)==null?void 0:t.list;return`
|
|
550
420
|
:host {
|
|
551
421
|
flex: 1;
|
|
552
422
|
width: 100%;
|
|
@@ -559,7 +429,7 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
559
429
|
margin: 0;
|
|
560
430
|
height: 100%;
|
|
561
431
|
}
|
|
562
|
-
`}reset(){var
|
|
432
|
+
`}reset(){var t,s;for(;(t=this.shadowRoot)!=null&&t.firstChild;)this.shadowRoot.removeChild(this.shadowRoot.firstChild);const e=document.createElement("style");e.textContent=this.getStyles(),(s=this.shadowRoot)==null||s.appendChild(e)}setDataSet(e){this._messages=[...e.messages],this._canPaginate=!!e.canPaginate,this._error=null,this._isLoading=!1,this.render()}addPage(e){this._messages=[...this._messages,...e.messages],this._canPaginate=!!e.canPaginate,this._error=null,this._isLoading=!1,this.render()}addMessage(e,t=0){this._messages.splice(t,0,e),this.render()}removeMessage(e=0){this._messages.splice(e,1),this.render()}updateMessage(e,t=0){this._messages[t]=e,this.render()}setFeedType(e){this._feedType=e,this._error=null,this._isLoading=!0,this.render()}setLoading(e){this._error=null,this._isLoading=e,this.render()}setError(e){this._error=e,this._isLoading=!1,this._messages=[],this.render()}setErrorNoClient(){this.setError(new Error("No user signed in"))}handleRetry(){this._onRefresh()}handleRefresh(){this._onRefresh()}render(){var s,o,n,h,d,c,u,g,p,x,f,b,v,k,w,S,M,I,L,A,$,F,y,D,H,R,z,O,N,U,V,Z,j,Y,K,Q,J,q,ae,he,ce,le,de,ue,pe,ge,me,be,_e,fe,xe,Ce,ve,ye,ke,we,Se,Me;this.reset();const e=this._themeSubscription.manager.getTheme();if(this._error){const l=(s=e.inbox)==null?void 0:s.error,P=new Te({title:{text:((o=l==null?void 0:l.title)==null?void 0:o.text)??this._error.message,textColor:(h=(n=l==null?void 0:l.title)==null?void 0:n.font)==null?void 0:h.color,fontFamily:(c=(d=l==null?void 0:l.title)==null?void 0:d.font)==null?void 0:c.family,fontSize:(g=(u=l==null?void 0:l.title)==null?void 0:u.font)==null?void 0:g.size,fontWeight:(x=(p=l==null?void 0:l.title)==null?void 0:p.font)==null?void 0:x.weight},button:{text:(f=l==null?void 0:l.button)==null?void 0:f.text,backgroundColor:(b=l==null?void 0:l.button)==null?void 0:b.backgroundColor,hoverBackgroundColor:(v=l==null?void 0:l.button)==null?void 0:v.hoverBackgroundColor,activeBackgroundColor:(k=l==null?void 0:l.button)==null?void 0:k.activeBackgroundColor,textColor:(S=(w=l==null?void 0:l.button)==null?void 0:w.font)==null?void 0:S.color,fontFamily:(I=(M=l==null?void 0:l.button)==null?void 0:M.font)==null?void 0:I.family,fontSize:(A=(L=l==null?void 0:l.button)==null?void 0:L.font)==null?void 0:A.size,fontWeight:(F=($=l==null?void 0:l.button)==null?void 0:$.font)==null?void 0:F.weight,shadow:(y=l==null?void 0:l.button)==null?void 0:y.shadow,border:(D=l==null?void 0:l.button)==null?void 0:D.border,borderRadius:(H=l==null?void 0:l.button)==null?void 0:H.borderRadius}});P.build((R=this._errorStateFactory)==null?void 0:R.call(this,{feedType:this._feedType,error:this._error})),P.setButtonClickCallback(()=>this.handleRetry()),(z=this.shadowRoot)==null||z.appendChild(P);return}if(this._isLoading){const l=new Fe(e);l.build((O=this._loadingStateFactory)==null?void 0:O.call(this,{feedType:this._feedType})),(N=this.shadowRoot)==null||N.appendChild(l);return}if(this._messages.length===0){const l=(U=e.inbox)==null?void 0:U.empty,P=new Te({title:{text:((V=l==null?void 0:l.title)==null?void 0:V.text)??`No ${this._feedType} messages yet`,textColor:(j=(Z=l==null?void 0:l.title)==null?void 0:Z.font)==null?void 0:j.color,fontFamily:(K=(Y=l==null?void 0:l.title)==null?void 0:Y.font)==null?void 0:K.family,fontSize:(J=(Q=l==null?void 0:l.title)==null?void 0:Q.font)==null?void 0:J.size,fontWeight:(ae=(q=l==null?void 0:l.title)==null?void 0:q.font)==null?void 0:ae.weight},button:{text:(he=l==null?void 0:l.button)==null?void 0:he.text,backgroundColor:(ce=l==null?void 0:l.button)==null?void 0:ce.backgroundColor,hoverBackgroundColor:(le=l==null?void 0:l.button)==null?void 0:le.hoverBackgroundColor,activeBackgroundColor:(de=l==null?void 0:l.button)==null?void 0:de.activeBackgroundColor,textColor:(pe=(ue=l==null?void 0:l.button)==null?void 0:ue.font)==null?void 0:pe.color,fontFamily:(me=(ge=l==null?void 0:l.button)==null?void 0:ge.font)==null?void 0:me.family,fontSize:(_e=(be=l==null?void 0:l.button)==null?void 0:be.font)==null?void 0:_e.size,fontWeight:(xe=(fe=l==null?void 0:l.button)==null?void 0:fe.font)==null?void 0:xe.weight,shadow:(Ce=l==null?void 0:l.button)==null?void 0:Ce.shadow,border:(ve=l==null?void 0:l.button)==null?void 0:ve.border,borderRadius:(ye=l==null?void 0:l.button)==null?void 0:ye.borderRadius}});P.build((ke=this._emptyStateFactory)==null?void 0:ke.call(this,{feedType:this._feedType})),P.setButtonClickCallback(()=>this.handleRefresh()),(we=this.shadowRoot)==null||we.appendChild(P);return}const t=document.createElement("ul");if((Se=this.shadowRoot)==null||Se.appendChild(t),this._messages.forEach((l,P)=>{if(this._listItemFactory){t.appendChild(this._listItemFactory({message:l,index:P}));return}const ee=new $e(e);ee.setMessage(l,this._feedType),ee.setOnItemClick(te=>{var W;return(W=this._onMessageClick)==null?void 0:W.call(this,te,P)}),ee.setOnItemActionClick((te,W)=>{var Ee;return(Ee=this._onMessageActionClick)==null?void 0:Ee.call(this,te,W,P)}),ee.setOnItemLongPress(te=>{var W;return(W=this._onMessageLongPress)==null?void 0:W.call(this,te,P)}),t.appendChild(ee)}),this._canPaginate){const l=new Xe({theme:e,customItem:(Me=this._paginationItemFactory)==null?void 0:Me.call(this,{feedType:this._feedType}),onPaginationTrigger:()=>{var P;return(P=this._onPaginationTrigger)==null?void 0:P.call(this,this._feedType)}});t.appendChild(l)}}setLoadingStateFactory(e){this._loadingStateFactory=e,this.render()}setEmptyStateFactory(e){this._emptyStateFactory=e,this.render()}setErrorStateFactory(e){this._errorStateFactory=e,this.render()}setListItemFactory(e){this._listItemFactory=e,this.render()}setPaginationItemFactory(e){this._paginationItemFactory=e,this.render()}refreshTheme(){this.render()}disconnectedCallback(){this._themeSubscription.unsubscribe()}}customElements.get("courier-inbox-list")||customElements.define("courier-inbox-list",Ye);class Ke extends HTMLElement{constructor(e){super();a(this,"_option");a(this,"_isSelected");a(this,"_content");a(this,"_itemIcon");a(this,"_title");a(this,"_selectionIcon");a(this,"_style");a(this,"_themeManager");this._option=e.option,this._isSelected=e.isSelected,this._themeManager=e.themeManager;const t=this.attachShadow({mode:"open"});this._style=document.createElement("style"),this._content=document.createElement("div"),this._content.className="menu-item",this._itemIcon=new ie(this._option.icon.svg??C.inbox),this._itemIcon.setAttribute("size","16"),this._title=document.createElement("p"),this._title.textContent=this._option.text;const s=document.createElement("div");s.className="spacer",this._selectionIcon=new ie(C.check),this._content.appendChild(this._itemIcon),this._content.appendChild(this._title),this._content.appendChild(s),e.selectable&&this._content.appendChild(this._selectionIcon),t.appendChild(this._style),t.appendChild(this._content),this._selectionIcon.style.display=this._isSelected?"block":"none",this.refreshTheme()}getStyles(){var t,s,o,n,h,d,c,u,g,p,x,f,b,v,k,w,S,M,I,L,A,$,F,y,D,H,R,z,O,N,U,V,Z,j;const e=this._themeManager.getTheme();return`
|
|
563
433
|
:host {
|
|
564
434
|
display: flex;
|
|
565
435
|
flex-direction: row;
|
|
@@ -568,11 +438,11 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
568
438
|
}
|
|
569
439
|
|
|
570
440
|
:host(:hover) {
|
|
571
|
-
background-color: ${((h=(n=(o=(s=(
|
|
441
|
+
background-color: ${((h=(n=(o=(s=(t=e.inbox)==null?void 0:t.header)==null?void 0:s.menus)==null?void 0:o.popup)==null?void 0:n.list)==null?void 0:h.hoverBackgroundColor)??"red"};
|
|
572
442
|
}
|
|
573
443
|
|
|
574
444
|
:host(:active) {
|
|
575
|
-
background-color: ${((
|
|
445
|
+
background-color: ${((p=(g=(u=(c=(d=e.inbox)==null?void 0:d.header)==null?void 0:c.menus)==null?void 0:u.popup)==null?void 0:g.list)==null?void 0:p.activeBackgroundColor)??"red"};
|
|
576
446
|
}
|
|
577
447
|
|
|
578
448
|
.menu-item {
|
|
@@ -588,17 +458,17 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
588
458
|
|
|
589
459
|
p {
|
|
590
460
|
margin: 0;
|
|
591
|
-
font-family: ${((w=(k=(
|
|
592
|
-
font-weight: ${((
|
|
593
|
-
font-size: ${((z=(
|
|
594
|
-
color: ${((
|
|
461
|
+
font-family: ${((w=(k=(v=(b=(f=(x=e.inbox)==null?void 0:x.header)==null?void 0:f.menus)==null?void 0:b.popup)==null?void 0:v.list)==null?void 0:k.font)==null?void 0:w.family)??"inherit"};
|
|
462
|
+
font-weight: ${(($=(A=(L=(I=(M=(S=e.inbox)==null?void 0:S.header)==null?void 0:M.menus)==null?void 0:I.popup)==null?void 0:L.list)==null?void 0:A.font)==null?void 0:$.weight)??"inherit"};
|
|
463
|
+
font-size: ${((z=(R=(H=(D=(y=(F=e.inbox)==null?void 0:F.header)==null?void 0:y.menus)==null?void 0:D.popup)==null?void 0:H.list)==null?void 0:R.font)==null?void 0:z.size)??"14px"};
|
|
464
|
+
color: ${((j=(Z=(V=(U=(N=(O=e.inbox)==null?void 0:O.header)==null?void 0:N.menus)==null?void 0:U.popup)==null?void 0:V.list)==null?void 0:Z.font)==null?void 0:j.color)??"red"};
|
|
595
465
|
white-space: nowrap;
|
|
596
466
|
}
|
|
597
467
|
|
|
598
468
|
.check-icon {
|
|
599
469
|
display: none;
|
|
600
470
|
}
|
|
601
|
-
`}refreshTheme(){var e,
|
|
471
|
+
`}refreshTheme(){var e,t,s,o;this._style.textContent=this.getStyles(),this._selectionIcon.updateColor(((e=this._option.selectionIcon)==null?void 0:e.color)??"red"),this._selectionIcon.updateSVG(((t=this._option.selectionIcon)==null?void 0:t.svg)??C.check),this._title.textContent=this._option.text??"Missing Text",this._itemIcon.updateColor(((s=this._option.icon)==null?void 0:s.color)??"red"),this._itemIcon.updateSVG(((o=this._option.icon)==null?void 0:o.svg)??C.inbox)}}customElements.get("courier-inbox-filter-menu-item")||customElements.define("courier-inbox-filter-menu-item",Ke);class He extends HTMLElement{constructor(e,t,s,o,n){super();a(this,"_themeSubscription");a(this,"_type");a(this,"_selectedIndex",0);a(this,"_options");a(this,"_selectable");a(this,"_onMenuOpen");a(this,"_menuButton");a(this,"_menu");a(this,"_style");this._type=t,this._selectable=s,this._options=o,this._selectedIndex=0,this._onMenuOpen=n;const h=this.attachShadow({mode:"open"});this._menuButton=new re(t==="filters"?C.filter:C.overflow),this._menu=document.createElement("div"),this._menu.className=`menu ${t}`,this._style=document.createElement("style"),h.appendChild(this._style),h.appendChild(this._menuButton),h.appendChild(this._menu),this._menuButton.addEventListener("click",this.toggleMenu.bind(this)),document.addEventListener("click",this.handleOutsideClick.bind(this)),this._themeSubscription=e.subscribe(d=>{this.refreshTheme()}),this.refreshTheme()}getStyles(){var t,s,o,n,h,d,c,u,g,p,x,f,b,v,k,w,S,M,I,L,A;const e=this._themeSubscription.manager.getTheme();return`
|
|
602
472
|
:host {
|
|
603
473
|
position: relative;
|
|
604
474
|
display: inline-block;
|
|
@@ -609,10 +479,10 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
609
479
|
position: absolute;
|
|
610
480
|
top: 42px;
|
|
611
481
|
right: -6px;
|
|
612
|
-
border-radius: ${((n=(o=(s=(
|
|
613
|
-
border: ${((
|
|
614
|
-
background: ${((
|
|
615
|
-
box-shadow: ${((w=(k=(
|
|
482
|
+
border-radius: ${((n=(o=(s=(t=e.inbox)==null?void 0:t.header)==null?void 0:s.menus)==null?void 0:o.popup)==null?void 0:n.borderRadius)??"6px"};
|
|
483
|
+
border: ${((u=(c=(d=(h=e.inbox)==null?void 0:h.header)==null?void 0:d.menus)==null?void 0:c.popup)==null?void 0:u.border)??"1px solid red"};
|
|
484
|
+
background: ${((f=(x=(p=(g=e.inbox)==null?void 0:g.header)==null?void 0:p.menus)==null?void 0:x.popup)==null?void 0:f.backgroundColor)??"red"};
|
|
485
|
+
box-shadow: ${((w=(k=(v=(b=e.inbox)==null?void 0:b.header)==null?void 0:v.menus)==null?void 0:k.popup)==null?void 0:w.shadow)??"0 4px 12px 0 red"};
|
|
616
486
|
z-index: 1000;
|
|
617
487
|
min-width: 200px;
|
|
618
488
|
overflow: hidden;
|
|
@@ -620,13 +490,13 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
620
490
|
}
|
|
621
491
|
|
|
622
492
|
courier-inbox-filter-menu-item {
|
|
623
|
-
border-bottom: ${((A=(
|
|
493
|
+
border-bottom: ${((A=(L=(I=(M=(S=e.inbox)==null?void 0:S.header)==null?void 0:M.menus)==null?void 0:I.popup)==null?void 0:L.list)==null?void 0:A.divider)??"none"};
|
|
624
494
|
}
|
|
625
495
|
|
|
626
496
|
courier-inbox-filter-menu-item:last-child {
|
|
627
497
|
border-bottom: none;
|
|
628
498
|
}
|
|
629
|
-
`}refreshTheme(){var h,d,
|
|
499
|
+
`}refreshTheme(){var h,d,c,u,g,p;this._style.textContent=this.getStyles();const t=(d=(h=this._themeSubscription.manager.getTheme().inbox)==null?void 0:h.header)==null?void 0:d.menus,s=this._type==="filters",o=s?(c=t==null?void 0:t.filters)==null?void 0:c.button:(u=t==null?void 0:t.actions)==null?void 0:u.button,n=s?C.filter:C.overflow;this._menuButton.updateIconSVG(((g=o==null?void 0:o.icon)==null?void 0:g.svg)??n),this._menuButton.updateIconColor(((p=o==null?void 0:o.icon)==null?void 0:p.color)??"red"),this._menuButton.updateBackgroundColor((o==null?void 0:o.backgroundColor)??"transparent"),this._menuButton.updateHoverBackgroundColor((o==null?void 0:o.hoverBackgroundColor)??"red"),this._menuButton.updateActiveBackgroundColor((o==null?void 0:o.activeBackgroundColor)??"red"),this.refreshMenuItems()}setOptions(e){this._options=e,this.refreshMenuItems()}refreshMenuItems(){this._menu.innerHTML="",this._options.forEach((e,t)=>{const s=new Ke({option:e,selectable:this._selectable,isSelected:this._selectedIndex===t,themeManager:this._themeSubscription.manager});s.addEventListener("click",()=>{this._selectedIndex=t,e.onClick(e),this.refreshMenuItems(),this.closeMenu()}),this._menu.appendChild(s)})}toggleMenu(e){e.stopPropagation();const t=this._menu.style.display!=="block";this._menu.style.display=t?"block":"none",t&&this._onMenuOpen()}handleOutsideClick(e){this.contains(e.target)||this.closeMenu()}closeMenu(){this._menu.style.display="none"}selectOption(e){this._selectedIndex=this._options.findIndex(t=>t.id===e.id),this.refreshMenuItems()}disconnectedCallback(){this._themeSubscription.unsubscribe()}}customElements.get("courier-inbox-option-menu")||customElements.define("courier-inbox-option-menu",He);class Re extends HTMLElement{constructor(e){super();a(this,"_themeSubscription");a(this,"_location");a(this,"_count",0);a(this,"_badge");a(this,"_style");this._location=e.location,this._themeSubscription=e.themeBus.subscribe(s=>{this.refreshTheme(this._location)});const t=this.attachShadow({mode:"open"});this._badge=document.createElement("span"),this._badge.className="unread-badge",this._style=document.createElement("style"),this._style.textContent=this.getStyles(this._location),t.appendChild(this._style),t.appendChild(this._badge)}getStyles(e){var c,u,g,p,x,f,b;const t=this._themeSubscription.manager.getTheme(),s=e==="button"?(u=(c=t.popup)==null?void 0:c.button)==null?void 0:u.unreadIndicator:(x=(p=(g=t.inbox)==null?void 0:g.header)==null?void 0:p.filters)==null?void 0:x.unreadIndicator,o=s==null?void 0:s.backgroundColor,n=s==null?void 0:s.borderRadius,h=(f=s==null?void 0:s.font)==null?void 0:f.color,d=(b=s==null?void 0:s.font)==null?void 0:b.size;return`
|
|
630
500
|
:host {
|
|
631
501
|
display: inline-block;
|
|
632
502
|
}
|
|
@@ -641,7 +511,7 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
641
511
|
display: none;
|
|
642
512
|
pointer-events: none;
|
|
643
513
|
}
|
|
644
|
-
`}setCount(e){this._count=e,this.updateBadge()}refreshTheme(e){this._location=e,this.updateBadge()}updateBadge(){this._style.textContent=this.getStyles(this._location),this._count>0?(this._badge.textContent=this._count.toString(),this._badge.style.display="block"):this._badge.style.display="none"}disconnectedCallback(){this._themeSubscription.unsubscribe()}}customElements.get("courier-unread-count-badge")||customElements.define("courier-unread-count-badge",
|
|
514
|
+
`}setCount(e){this._count=e,this.updateBadge()}refreshTheme(e){this._location=e,this.updateBadge()}updateBadge(){this._style.textContent=this.getStyles(this._location),this._count>0?(this._badge.textContent=this._count.toString(),this._badge.style.display="block"):this._badge.style.display="none"}disconnectedCallback(){this._themeSubscription.unsubscribe()}}customElements.get("courier-unread-count-badge")||customElements.define("courier-unread-count-badge",Re);class Qe extends HTMLElement{constructor(e,t){super();a(this,"_themeSubscription");a(this,"_option");a(this,"_feedType");a(this,"_titleElement");a(this,"_iconElement");a(this,"_unreadBadge");a(this,"_container");a(this,"_style");this._option=t;const s=this.attachShadow({mode:"open"});this._style=document.createElement("style"),this._container=document.createElement("div"),this._container.className="title-section",this._iconElement=new ie(void 0,this._option.icon.svg),this._titleElement=document.createElement("h2"),this._unreadBadge=new Re({themeBus:e,location:"header"}),this._container.appendChild(this._iconElement),this._container.appendChild(this._titleElement),this._container.appendChild(this._unreadBadge),s.appendChild(this._style),s.appendChild(this._container),this._themeSubscription=e.subscribe(o=>{this.refreshTheme(this._feedType??"inbox")}),this.refreshTheme(this._feedType??"inbox")}getStyles(){var t,s,o,n,h,d,c,u,g,p,x,f,b,v,k,w;const e=this._themeSubscription.manager.getTheme();return`
|
|
645
515
|
.title-section {
|
|
646
516
|
display: flex;
|
|
647
517
|
align-items: center;
|
|
@@ -656,16 +526,16 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
656
526
|
|
|
657
527
|
h2 {
|
|
658
528
|
margin: 0;
|
|
659
|
-
font-family: ${((n=(o=(s=(
|
|
660
|
-
font-size: ${((
|
|
661
|
-
font-weight: ${((
|
|
662
|
-
color: ${((w=(k=(
|
|
529
|
+
font-family: ${((n=(o=(s=(t=e.inbox)==null?void 0:t.header)==null?void 0:s.filters)==null?void 0:o.font)==null?void 0:n.family)??"inherit"};
|
|
530
|
+
font-size: ${((u=(c=(d=(h=e.inbox)==null?void 0:h.header)==null?void 0:d.filters)==null?void 0:c.font)==null?void 0:u.size)??"18px"};
|
|
531
|
+
font-weight: ${((f=(x=(p=(g=e.inbox)==null?void 0:g.header)==null?void 0:p.filters)==null?void 0:x.font)==null?void 0:f.weight)??"500"};
|
|
532
|
+
color: ${((w=(k=(v=(b=e.inbox)==null?void 0:b.header)==null?void 0:v.filters)==null?void 0:k.font)==null?void 0:w.color)??"red"};
|
|
663
533
|
}
|
|
664
534
|
|
|
665
535
|
courier-unread-count-badge {
|
|
666
536
|
margin-left: 4px;
|
|
667
537
|
}
|
|
668
|
-
`}refreshTheme(e){this._feedType=e,this._style.textContent=this.getStyles(),this._unreadBadge.refreshTheme("header"),this.updateFilter()}updateSelectedOption(e,
|
|
538
|
+
`}refreshTheme(e){this._feedType=e,this._style.textContent=this.getStyles(),this._unreadBadge.refreshTheme("header"),this.updateFilter()}updateSelectedOption(e,t,s){this._option=e,this._feedType=t,this._unreadBadge.setCount(s),this.updateFilter()}updateFilter(){var t,s,o,n,h,d,c,u,g,p,x,f,b,v,k,w,S,M,I,L,A,$,F,y,D,H,R,z;const e=this._themeSubscription.manager.getTheme();switch(this._feedType){case"inbox":this._titleElement.textContent=((n=(o=(s=(t=e.inbox)==null?void 0:t.header)==null?void 0:s.filters)==null?void 0:o.inbox)==null?void 0:n.text)??"Inbox",this._iconElement.updateSVG(((g=(u=(c=(d=(h=e.inbox)==null?void 0:h.header)==null?void 0:d.filters)==null?void 0:c.inbox)==null?void 0:u.icon)==null?void 0:g.svg)??C.inbox),this._iconElement.updateColor(((v=(b=(f=(x=(p=e.inbox)==null?void 0:p.header)==null?void 0:x.filters)==null?void 0:f.inbox)==null?void 0:b.icon)==null?void 0:v.color)??"red");break;case"archive":this._titleElement.textContent=((M=(S=(w=(k=e.inbox)==null?void 0:k.header)==null?void 0:w.filters)==null?void 0:S.archive)==null?void 0:M.text)??"Archive",this._iconElement.updateSVG(((F=($=(A=(L=(I=e.inbox)==null?void 0:I.header)==null?void 0:L.filters)==null?void 0:A.archive)==null?void 0:$.icon)==null?void 0:F.svg)??C.archive),this._iconElement.updateColor(((z=(R=(H=(D=(y=e.inbox)==null?void 0:y.header)==null?void 0:D.filters)==null?void 0:H.archive)==null?void 0:R.icon)==null?void 0:z.color)??"red");break}}disconnectedCallback(){this._themeSubscription.unsubscribe()}}customElements.get("courier-inbox-header-title")||customElements.define("courier-inbox-header-title",Qe);class ze extends Le{constructor(e){super();a(this,"_themeSubscription");a(this,"_feedType","inbox");a(this,"_unreadCount",0);a(this,"_titleSection");a(this,"_filterMenu");a(this,"_actionMenu");a(this,"_style");a(this,"_onFeedTypeChange");this._themeSubscription=e.themeManager.subscribe(t=>{this.refreshTheme()}),this._onFeedTypeChange=e.onFeedTypeChange}getFilterOptions(){var s,o,n,h,d,c,u,g,p,x,f,b,v,k,w,S,M,I,L,A,$,F,y,D,H,R,z,O,N,U,V,Z,j,Y,K,Q,J;const e=this._themeSubscription.manager.getTheme(),t=(n=(o=(s=e.inbox)==null?void 0:s.header)==null?void 0:o.menus)==null?void 0:n.filters;return[{id:"inbox",text:((h=t==null?void 0:t.inbox)==null?void 0:h.text)??"Inbox",icon:{color:((c=(d=t==null?void 0:t.inbox)==null?void 0:d.icon)==null?void 0:c.color)??"red",svg:((g=(u=t==null?void 0:t.inbox)==null?void 0:u.icon)==null?void 0:g.svg)??C.inbox},selectionIcon:{color:((k=(v=(b=(f=(x=(p=e.inbox)==null?void 0:p.header)==null?void 0:x.menus)==null?void 0:f.popup)==null?void 0:b.list)==null?void 0:v.selectionIcon)==null?void 0:k.color)??"red",svg:((A=(L=(I=(M=(S=(w=e.inbox)==null?void 0:w.header)==null?void 0:S.menus)==null?void 0:M.popup)==null?void 0:I.list)==null?void 0:L.selectionIcon)==null?void 0:A.svg)??C.check},onClick:q=>{this.handleOptionMenuItemClick("inbox",q)}},{id:"archive",text:(($=t==null?void 0:t.archive)==null?void 0:$.text)??"Archive",icon:{color:((y=(F=t==null?void 0:t.archive)==null?void 0:F.icon)==null?void 0:y.color)??"red",svg:((H=(D=t==null?void 0:t.archive)==null?void 0:D.icon)==null?void 0:H.svg)??C.archive},selectionIcon:{color:((V=(U=(N=(O=(z=(R=e.inbox)==null?void 0:R.header)==null?void 0:z.menus)==null?void 0:O.popup)==null?void 0:N.list)==null?void 0:U.selectionIcon)==null?void 0:V.color)??"red",svg:((J=(Q=(K=(Y=(j=(Z=e.inbox)==null?void 0:Z.header)==null?void 0:j.menus)==null?void 0:Y.popup)==null?void 0:K.list)==null?void 0:Q.selectionIcon)==null?void 0:J.svg)??C.check},onClick:q=>{this.handleOptionMenuItemClick("archive",q)}}]}getActionOptions(){var s,o,n,h,d,c,u,g,p,x,f,b,v,k,w,S,M,I;const t=(n=(o=(s=this._themeSubscription.manager.getTheme().inbox)==null?void 0:s.header)==null?void 0:o.menus)==null?void 0:n.actions;return[{id:"markAllRead",text:((h=t==null?void 0:t.markAllRead)==null?void 0:h.text)??"Mark All as Read",icon:{color:((c=(d=t==null?void 0:t.markAllRead)==null?void 0:d.icon)==null?void 0:c.color)??"red",svg:((g=(u=t==null?void 0:t.markAllRead)==null?void 0:u.icon)==null?void 0:g.svg)??C.inbox},selectionIcon:null,onClick:L=>{B.shared.readAllMessages({canCallApi:!0})}},{id:"archiveAll",text:((p=t==null?void 0:t.archiveAll)==null?void 0:p.text)??"Archive All",icon:{color:((f=(x=t==null?void 0:t.archiveAll)==null?void 0:x.icon)==null?void 0:f.color)??"red",svg:((v=(b=t==null?void 0:t.archiveAll)==null?void 0:b.icon)==null?void 0:v.svg)??C.archive},selectionIcon:null,onClick:L=>{var A;alert(JSON.stringify((A=_.Courier.shared.client)==null?void 0:A.options))}},{id:"archiveRead",text:((k=t==null?void 0:t.archiveRead)==null?void 0:k.text)??"Archive Read",icon:{color:((S=(w=t==null?void 0:t.archiveRead)==null?void 0:w.icon)==null?void 0:S.color)??"red",svg:((I=(M=t==null?void 0:t.archiveRead)==null?void 0:M.icon)==null?void 0:I.svg)??C.archive},selectionIcon:null,onClick:L=>{B.shared.archiveReadMessages({canCallApi:!0})}}]}static get observedAttributes(){return["icon","title","feed-type"]}refreshTheme(){var s,o,n,h,d,c,u;const e=this._themeSubscription.manager.getTheme(),t=(s=this.shadow)==null?void 0:s.querySelector(".courier-inbox-header");t&&(t.style.backgroundColor=((n=(o=e.inbox)==null?void 0:o.header)==null?void 0:n.backgroundColor)??r.white[500],t.style.boxShadow=((d=(h=e.inbox)==null?void 0:h.header)==null?void 0:d.shadow)??`0px 1px 0px 0px ${r.gray[500]}`),(c=this._filterMenu)==null||c.setOptions(this.getFilterOptions()),(u=this._actionMenu)==null||u.setOptions(this.getActionOptions())}handleOptionMenuItemClick(e,t){this._feedType=e,this._titleSection&&this._titleSection.updateSelectedOption(t,this._feedType,this._feedType==="inbox"?this._unreadCount:0),this._onFeedTypeChange(e)}render(e){this._feedType=e.feedType,this._unreadCount=e.unreadCount,this.refreshTitleSection()}refreshTitleSection(){var t,s;const e=this.getFilterOptions().find(o=>["inbox","archive"].includes(o.id)&&o.id===this._feedType);e&&((t=this._titleSection)==null||t.updateSelectedOption(e,this._feedType,this._feedType==="inbox"?this._unreadCount:0),(s=this._filterMenu)==null||s.selectOption(e))}build(e){var t;super.build(e),this._style=document.createElement("style"),this._style.textContent=this.getStyles(),(t=this.shadow)==null||t.appendChild(this._style),this.refreshTheme()}defaultElement(){const e=this.getFilterOptions();this._titleSection=new Qe(this._themeSubscription.manager,e[0]),this._filterMenu=new He(this._themeSubscription.manager,"filters",!0,e,()=>{var n;(n=this._actionMenu)==null||n.closeMenu()}),this._actionMenu=new He(this._themeSubscription.manager,"actions",!1,this.getActionOptions(),()=>{var n;(n=this._filterMenu)==null||n.closeMenu()}),this._filterMenu.selectOption(e[0]);const t=document.createElement("div");t.className="spacer";const s=document.createElement("div");s.className="actions",s.appendChild(this._filterMenu),s.appendChild(this._actionMenu);const o=document.createElement("div");return o.className="courier-inbox-header",o.appendChild(this._titleSection),o.appendChild(t),o.appendChild(s),o}getStyles(){return`
|
|
669
539
|
:host {
|
|
670
540
|
z-index: 100;
|
|
671
541
|
}
|
|
@@ -694,7 +564,7 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
694
564
|
align-items: center;
|
|
695
565
|
gap: 4px;
|
|
696
566
|
}
|
|
697
|
-
`}disconnectedCallback(){this._themeSubscription.unsubscribe()}}customElements.get("courier-inbox-header")||customElements.define("courier-inbox-header",Ge);class We{constructor(t){a(this,"events");this.events=t}remove(){P.shared.removeDataStoreListener(this)}}const le={popup:{button:{icon:{color:r.black[500],svg:x.inbox},backgroundColor:"transparent",hoverBackgroundColor:r.black[50010],activeBackgroundColor:r.black[50020],unreadIndicator:{font:{color:r.white[500],size:"14px",family:void 0,weight:void 0},backgroundColor:r.blue[500],borderRadius:"12px"}},window:{backgroundColor:r.white[500],borderRadius:"8px",border:`1px solid ${r.gray[500]}`,shadow:`0px 8px 16px -4px ${r.gray[500]}`}},inbox:{header:{backgroundColor:r.white[500],shadow:`0px 1px 0px 0px ${r.gray[500]}`,filters:{font:{color:r.black[500],family:void 0,size:"18px"},inbox:{icon:{color:r.black[500],svg:x.inbox},text:"Inbox"},archive:{icon:{color:r.black[500],svg:x.archive},text:"Archive"},unreadIndicator:{font:{color:r.white[500],family:void 0,size:"14px"},backgroundColor:r.blue[500],borderRadius:"12px"}},menus:{popup:{backgroundColor:r.white[500],border:`1px solid ${r.gray[500]}`,borderRadius:"4px",shadow:`0px 4px 8px -2px ${r.gray[500]}`,list:{hoverBackgroundColor:r.gray[200],activeBackgroundColor:r.gray[500],divider:"none",font:{color:r.black[500],family:void 0,size:"14px"},selectionIcon:{color:r.black[500],svg:x.check}}},filters:{button:{icon:{color:r.black[500],svg:x.filter},backgroundColor:"transparent",hoverBackgroundColor:r.black[50010],activeBackgroundColor:r.black[50020]},inbox:{icon:{color:r.black[500],svg:x.inbox},text:"Inbox"},archive:{icon:{color:r.black[500],svg:x.archive},text:"Archive"}},actions:{button:{icon:{color:r.black[500],svg:x.overflow},backgroundColor:"transparent",hoverBackgroundColor:r.black[50010],activeBackgroundColor:r.black[50020]},markAllRead:{icon:{color:r.black[500],svg:x.read},text:"Mark All as Read"},archiveAll:{icon:{color:r.black[500],svg:x.archive},text:"Archive All"},archiveRead:{icon:{color:r.black[500],svg:x.archiveRead},text:"Archive Read"}}}},list:{backgroundColor:r.white[500],item:{backgroundColor:"transparent",unreadIndicatorColor:r.blue[500],hoverBackgroundColor:r.gray[200],activeBackgroundColor:r.gray[500],actions:{backgroundColor:"transparent",hoverBackgroundColor:r.gray[200],activeBackgroundColor:r.gray[500],border:`1px solid ${r.gray[500]}`,borderRadius:"4px",shadow:"0px 1px 2px 0px rgba(0, 0, 0, 0.06)",font:{color:r.black[500],family:void 0,size:"14px"}},title:{color:r.black[500],family:void 0,size:"14px"},subtitle:{color:r.gray[600],family:void 0,size:"14px"},time:{color:r.gray[600],family:void 0,size:"14px"},divider:`1px solid ${r.gray[200]}`,menu:{enabled:!0,backgroundColor:r.white[500],border:`1px solid ${r.gray[500]}`,borderRadius:"4px",shadow:`0px 2px 4px -2px ${r.gray[500]}`,longPress:{displayDuration:4e3,vibrationDuration:50},item:{hoverBackgroundColor:r.gray[200],activeBackgroundColor:r.gray[500],borderRadius:"0px",read:{color:r.black[500],svg:x.read},unread:{color:r.black[500],svg:x.unread},archive:{color:r.black[500],svg:x.archive},unarchive:{color:r.black[500],svg:x.unarchive}}}}},loading:{animation:{barColor:r.gray[500],barHeight:"14px",barBorderRadius:"14px",duration:"2s"},divider:`1px solid ${r.gray[200]}`},empty:{title:{font:{size:"16px",weight:"500",color:r.black[500]}},button:{text:"Refresh"}},error:{title:{font:{size:"16px",weight:"500",color:r.black[500]}},button:{text:"Retry"}}}},ze={popup:{button:{icon:{color:r.white[500],svg:x.inbox},backgroundColor:"transparent",hoverBackgroundColor:r.white[50010],activeBackgroundColor:r.white[50020],unreadIndicator:{font:{color:r.white[500],size:"14px",family:void 0,weight:void 0},backgroundColor:r.blue[500],borderRadius:"12px"}},window:{backgroundColor:r.black[500],borderRadius:"8px",border:`1px solid ${r.gray[400]}`,shadow:`0px 4px 8px -2px ${r.white[50020]}`}},inbox:{header:{backgroundColor:r.black[500],shadow:`0px 1px 0px 0px ${r.gray[400]}`,filters:{font:{color:r.white[500],family:void 0,size:"18px"},inbox:{icon:{color:r.white[500],svg:x.inbox},text:"Inbox"},archive:{icon:{color:r.white[500],svg:x.archive},text:"Archive"},unreadIndicator:{font:{color:r.white[500],family:void 0,size:"14px"},backgroundColor:r.blue[500],borderRadius:"12px"}},menus:{popup:{backgroundColor:r.black[500],border:`1px solid ${r.gray[400]}`,borderRadius:"4px",shadow:`0px 4px 8px -2px ${r.white[50020]}`,list:{hoverBackgroundColor:r.white[50010],activeBackgroundColor:r.white[50020],divider:"none",font:{color:r.white[500],family:void 0,size:"14px"},selectionIcon:{color:r.white[500],svg:x.check}}},filters:{button:{icon:{color:r.white[500],svg:x.filter},backgroundColor:"transparent",hoverBackgroundColor:r.white[50010],activeBackgroundColor:r.white[50020]},inbox:{icon:{color:r.white[500],svg:x.inbox},text:"Inbox"},archive:{icon:{color:r.white[500],svg:x.archive},text:"Archive"}},actions:{button:{icon:{color:r.white[500],svg:x.overflow},backgroundColor:"transparent",hoverBackgroundColor:r.white[50010],activeBackgroundColor:r.white[50020]},markAllRead:{icon:{color:r.white[500],svg:x.read},text:"Mark All as Read"},archiveAll:{icon:{color:r.white[500],svg:x.archive},text:"Archive All"},archiveRead:{icon:{color:r.white[500],svg:x.archiveRead},text:"Archive Read"}}}},list:{backgroundColor:r.black[500],item:{backgroundColor:"transparent",unreadIndicatorColor:r.blue[500],hoverBackgroundColor:r.white[50010],activeBackgroundColor:r.white[50020],actions:{backgroundColor:"transparent",hoverBackgroundColor:r.white[50010],activeBackgroundColor:r.white[50020],border:`1px solid ${r.gray[400]}`,borderRadius:"4px",shadow:`0px 1px 2px 0px ${r.white[50010]}`,font:{color:r.white[500],family:void 0,size:"14px"}},title:{color:r.white[500],family:void 0,size:"14px"},subtitle:{color:r.gray[500],family:void 0,size:"14px"},time:{color:r.gray[500],family:void 0,size:"12px"},divider:`1px solid ${r.gray[400]}`,menu:{enabled:!0,backgroundColor:r.black[500],border:`1px solid ${r.gray[400]}`,borderRadius:"4px",shadow:`0px 2px 4px -2px ${r.white[50020]}`,longPress:{displayDuration:4e3,vibrationDuration:50},item:{hoverBackgroundColor:r.white[50010],activeBackgroundColor:r.white[50020],borderRadius:"0px",read:{color:r.white[500],svg:x.read},unread:{color:r.white[500],svg:x.unread},archive:{color:r.white[500],svg:x.archive},unarchive:{color:r.white[500],svg:x.unarchive}}}}},loading:{animation:{barColor:r.white[500],barHeight:"14px",barBorderRadius:"14px",duration:"2s"},divider:`1px solid ${r.gray[400]}`},empty:{title:{font:{size:"16px",weight:"500",color:r.white[500]}},button:{text:"Refresh"}},error:{title:{font:{size:"16px",weight:"500",color:r.white[500]}},button:{text:"Retry"}}}},pt=(c,t)=>{var i,s,o,n,h,d,l,p,m,g,f,_,b,C,k,w,S,I,E,M,A,R,F,y,B,H,O,z,q,V,j,Z,J,G,ee,te,ie,se,Q,ue,pe,ge,me,be,_e,fe,xe,ve,Ce,ye,ke,we,Se,Ie,Ee,Me,Te,$e,Le,u,D,oe,ne,W,Ae,bt,_t,ft,xt,vt,Ct,yt,kt,wt,St,It,Et,Mt,Tt,$t,Lt,At,Pt,Bt,Dt,Rt,Ft,Ht,Ot,zt,Ut,Nt,qt,Vt,jt,Zt,Jt,Gt,Wt,Kt,Xt,Qt,Yt,ei,ti,ii,si,oi,ni,ri,ai,hi,ci,li,di,ui,pi,gi,mi,bi,_i,fi,xi,vi,Ci,yi,ki,wi,Si,Ii,Ei,Mi,Ti,$i,Li,Ai,Pi,Bi,Di,Ri,Fi,Hi,Oi,zi,Ui,Ni,qi,Vi,ji,Zi,Ji,Gi,Wi,Ki,Xi,Qi,Yi,es,ts,is,ss,os,ns,rs,as,hs,cs,ls,ds,us,ps,gs,ms,bs,_s,fs,xs,vs,Cs,ys,ks,ws,Ss,Is,Es,Ms,Ts,$s,Ls,As,Ps,Bs,Ds,Rs,Fs,Hs,Os,zs,Us,Ns,qs,Vs,js,Zs,Js,Gs,Ws,Ks,Xs,Qs,Ys,eo,to,io,so,oo,no,ro,ao,ho,co,lo,uo,po,go,mo,bo,_o,fo,xo,vo,Co,yo,ko,wo,So,Io,Eo,Mo,To,$o,Lo,Ao,Po,Bo,Do,Ro,Fo,Ho,Oo,zo,Uo,No,qo,Vo,jo,Zo,Jo;const e=c==="light"?le:ze;return{popup:{button:{...(i=e.popup)==null?void 0:i.button,...(s=t.popup)==null?void 0:s.button,icon:{...(n=(o=e.popup)==null?void 0:o.button)==null?void 0:n.icon,...(d=(h=t.popup)==null?void 0:h.button)==null?void 0:d.icon},unreadIndicator:{...(p=(l=e.popup)==null?void 0:l.button)==null?void 0:p.unreadIndicator,...(g=(m=t.popup)==null?void 0:m.button)==null?void 0:g.unreadIndicator}},window:{...(f=e.popup)==null?void 0:f.window,...(_=t.popup)==null?void 0:_.window}},inbox:{header:{...(b=e.inbox)==null?void 0:b.header,...(C=t.inbox)==null?void 0:C.header,filters:{...(w=(k=e.inbox)==null?void 0:k.header)==null?void 0:w.filters,...(I=(S=t.inbox)==null?void 0:S.header)==null?void 0:I.filters,inbox:{...(A=(M=(E=e.inbox)==null?void 0:E.header)==null?void 0:M.filters)==null?void 0:A.inbox,...(y=(F=(R=t.inbox)==null?void 0:R.header)==null?void 0:F.filters)==null?void 0:y.inbox,icon:{...(z=(O=(H=(B=e.inbox)==null?void 0:B.header)==null?void 0:H.filters)==null?void 0:O.inbox)==null?void 0:z.icon,...(Z=(j=(V=(q=t.inbox)==null?void 0:q.header)==null?void 0:V.filters)==null?void 0:j.inbox)==null?void 0:Z.icon}},archive:{...(ee=(G=(J=e.inbox)==null?void 0:J.header)==null?void 0:G.filters)==null?void 0:ee.archive,...(se=(ie=(te=t.inbox)==null?void 0:te.header)==null?void 0:ie.filters)==null?void 0:se.archive,icon:{...(ge=(pe=(ue=(Q=e.inbox)==null?void 0:Q.header)==null?void 0:ue.filters)==null?void 0:pe.archive)==null?void 0:ge.icon,...(fe=(_e=(be=(me=t.inbox)==null?void 0:me.header)==null?void 0:be.filters)==null?void 0:_e.archive)==null?void 0:fe.icon}},unreadIndicator:{...(Ce=(ve=(xe=e.inbox)==null?void 0:xe.header)==null?void 0:ve.filters)==null?void 0:Ce.unreadIndicator,...(we=(ke=(ye=t.inbox)==null?void 0:ye.header)==null?void 0:ke.filters)==null?void 0:we.unreadIndicator}},menus:{...(Ie=(Se=e.inbox)==null?void 0:Se.header)==null?void 0:Ie.menus,...(Me=(Ee=t.inbox)==null?void 0:Ee.header)==null?void 0:Me.menus,popup:{...(Le=($e=(Te=e.inbox)==null?void 0:Te.header)==null?void 0:$e.menus)==null?void 0:Le.popup,...(oe=(D=(u=t.inbox)==null?void 0:u.header)==null?void 0:D.menus)==null?void 0:oe.popup,list:{...(bt=(Ae=(W=(ne=e.inbox)==null?void 0:ne.header)==null?void 0:W.menus)==null?void 0:Ae.popup)==null?void 0:bt.list,...(vt=(xt=(ft=(_t=t.inbox)==null?void 0:_t.header)==null?void 0:ft.menus)==null?void 0:xt.popup)==null?void 0:vt.list,font:{...(St=(wt=(kt=(yt=(Ct=e.inbox)==null?void 0:Ct.header)==null?void 0:yt.menus)==null?void 0:kt.popup)==null?void 0:wt.list)==null?void 0:St.font,...($t=(Tt=(Mt=(Et=(It=t.inbox)==null?void 0:It.header)==null?void 0:Et.menus)==null?void 0:Mt.popup)==null?void 0:Tt.list)==null?void 0:$t.font},selectionIcon:{...(Dt=(Bt=(Pt=(At=(Lt=e.inbox)==null?void 0:Lt.header)==null?void 0:At.menus)==null?void 0:Pt.popup)==null?void 0:Bt.list)==null?void 0:Dt.selectionIcon,...(zt=(Ot=(Ht=(Ft=(Rt=t.inbox)==null?void 0:Rt.header)==null?void 0:Ft.menus)==null?void 0:Ht.popup)==null?void 0:Ot.list)==null?void 0:zt.selectionIcon}}},filters:{...(qt=(Nt=(Ut=e.inbox)==null?void 0:Ut.header)==null?void 0:Nt.menus)==null?void 0:qt.filters,...(Zt=(jt=(Vt=t.inbox)==null?void 0:Vt.header)==null?void 0:jt.menus)==null?void 0:Zt.filters,inbox:{...(Kt=(Wt=(Gt=(Jt=e.inbox)==null?void 0:Jt.header)==null?void 0:Gt.menus)==null?void 0:Wt.filters)==null?void 0:Kt.inbox,...(ei=(Yt=(Qt=(Xt=t.inbox)==null?void 0:Xt.header)==null?void 0:Qt.menus)==null?void 0:Yt.filters)==null?void 0:ei.inbox,icon:{...(ni=(oi=(si=(ii=(ti=e.inbox)==null?void 0:ti.header)==null?void 0:ii.menus)==null?void 0:si.filters)==null?void 0:oi.inbox)==null?void 0:ni.icon,...(li=(ci=(hi=(ai=(ri=t.inbox)==null?void 0:ri.header)==null?void 0:ai.menus)==null?void 0:hi.filters)==null?void 0:ci.inbox)==null?void 0:li.icon}},archive:{...(gi=(pi=(ui=(di=e.inbox)==null?void 0:di.header)==null?void 0:ui.menus)==null?void 0:pi.filters)==null?void 0:gi.archive,...(fi=(_i=(bi=(mi=t.inbox)==null?void 0:mi.header)==null?void 0:bi.menus)==null?void 0:_i.filters)==null?void 0:fi.archive,icon:{...(ki=(yi=(Ci=(vi=(xi=e.inbox)==null?void 0:xi.header)==null?void 0:vi.menus)==null?void 0:Ci.filters)==null?void 0:yi.archive)==null?void 0:ki.icon,...(Mi=(Ei=(Ii=(Si=(wi=t.inbox)==null?void 0:wi.header)==null?void 0:Si.menus)==null?void 0:Ii.filters)==null?void 0:Ei.archive)==null?void 0:Mi.icon}}},actions:{...(Li=($i=(Ti=e.inbox)==null?void 0:Ti.header)==null?void 0:$i.menus)==null?void 0:Li.actions,...(Bi=(Pi=(Ai=t.inbox)==null?void 0:Ai.header)==null?void 0:Pi.menus)==null?void 0:Bi.actions,markAllRead:{...(Hi=(Fi=(Ri=(Di=e.inbox)==null?void 0:Di.header)==null?void 0:Ri.menus)==null?void 0:Fi.actions)==null?void 0:Hi.markAllRead,...(Ni=(Ui=(zi=(Oi=t.inbox)==null?void 0:Oi.header)==null?void 0:zi.menus)==null?void 0:Ui.actions)==null?void 0:Ni.markAllRead,icon:{...(Ji=(Zi=(ji=(Vi=(qi=e.inbox)==null?void 0:qi.header)==null?void 0:Vi.menus)==null?void 0:ji.actions)==null?void 0:Zi.markAllRead)==null?void 0:Ji.icon,...(Qi=(Xi=(Ki=(Wi=(Gi=t.inbox)==null?void 0:Gi.header)==null?void 0:Wi.menus)==null?void 0:Ki.actions)==null?void 0:Xi.markAllRead)==null?void 0:Qi.icon}},archiveAll:{...(is=(ts=(es=(Yi=e.inbox)==null?void 0:Yi.header)==null?void 0:es.menus)==null?void 0:ts.actions)==null?void 0:is.archiveAll,...(rs=(ns=(os=(ss=t.inbox)==null?void 0:ss.header)==null?void 0:os.menus)==null?void 0:ns.actions)==null?void 0:rs.archiveAll,icon:{...(ds=(ls=(cs=(hs=(as=e.inbox)==null?void 0:as.header)==null?void 0:hs.menus)==null?void 0:cs.actions)==null?void 0:ls.archiveAll)==null?void 0:ds.icon,...(bs=(ms=(gs=(ps=(us=t.inbox)==null?void 0:us.header)==null?void 0:ps.menus)==null?void 0:gs.actions)==null?void 0:ms.archiveAll)==null?void 0:bs.icon}},archiveRead:{...(vs=(xs=(fs=(_s=e.inbox)==null?void 0:_s.header)==null?void 0:fs.menus)==null?void 0:xs.actions)==null?void 0:vs.archiveRead,...(ws=(ks=(ys=(Cs=t.inbox)==null?void 0:Cs.header)==null?void 0:ys.menus)==null?void 0:ks.actions)==null?void 0:ws.archiveRead,icon:{...(Ts=(Ms=(Es=(Is=(Ss=e.inbox)==null?void 0:Ss.header)==null?void 0:Is.menus)==null?void 0:Es.actions)==null?void 0:Ms.archiveRead)==null?void 0:Ts.icon,...(Bs=(Ps=(As=(Ls=($s=t.inbox)==null?void 0:$s.header)==null?void 0:Ls.menus)==null?void 0:As.actions)==null?void 0:Ps.archiveRead)==null?void 0:Bs.icon}}}}},list:{...(Ds=e.inbox)==null?void 0:Ds.list,...(Rs=t.inbox)==null?void 0:Rs.list,item:{...(Hs=(Fs=e.inbox)==null?void 0:Fs.list)==null?void 0:Hs.item,...(zs=(Os=t.inbox)==null?void 0:Os.list)==null?void 0:zs.item,menu:{...(qs=(Ns=(Us=e.inbox)==null?void 0:Us.list)==null?void 0:Ns.item)==null?void 0:qs.menu,...(Zs=(js=(Vs=t.inbox)==null?void 0:Vs.list)==null?void 0:js.item)==null?void 0:Zs.menu,item:{...(Ks=(Ws=(Gs=(Js=e.inbox)==null?void 0:Js.list)==null?void 0:Gs.item)==null?void 0:Ws.menu)==null?void 0:Ks.item,...(eo=(Ys=(Qs=(Xs=t.inbox)==null?void 0:Xs.list)==null?void 0:Qs.item)==null?void 0:Ys.menu)==null?void 0:eo.item,read:{...(no=(oo=(so=(io=(to=e.inbox)==null?void 0:to.list)==null?void 0:io.item)==null?void 0:so.menu)==null?void 0:oo.item)==null?void 0:no.read,...(lo=(co=(ho=(ao=(ro=t.inbox)==null?void 0:ro.list)==null?void 0:ao.item)==null?void 0:ho.menu)==null?void 0:co.item)==null?void 0:lo.read},unread:{...(bo=(mo=(go=(po=(uo=e.inbox)==null?void 0:uo.list)==null?void 0:po.item)==null?void 0:go.menu)==null?void 0:mo.item)==null?void 0:bo.unread,...(Co=(vo=(xo=(fo=(_o=t.inbox)==null?void 0:_o.list)==null?void 0:fo.item)==null?void 0:xo.menu)==null?void 0:vo.item)==null?void 0:Co.unread},archive:{...(Io=(So=(wo=(ko=(yo=e.inbox)==null?void 0:yo.list)==null?void 0:ko.item)==null?void 0:wo.menu)==null?void 0:So.item)==null?void 0:Io.archive,...(Lo=($o=(To=(Mo=(Eo=t.inbox)==null?void 0:Eo.list)==null?void 0:Mo.item)==null?void 0:To.menu)==null?void 0:$o.item)==null?void 0:Lo.archive},unarchive:{...(Ro=(Do=(Bo=(Po=(Ao=e.inbox)==null?void 0:Ao.list)==null?void 0:Po.item)==null?void 0:Bo.menu)==null?void 0:Do.item)==null?void 0:Ro.unarchive,...(Uo=(zo=(Oo=(Ho=(Fo=t.inbox)==null?void 0:Fo.list)==null?void 0:Ho.item)==null?void 0:Oo.menu)==null?void 0:zo.item)==null?void 0:Uo.unarchive}}}}},loading:{...(No=e.inbox)==null?void 0:No.loading,...(qo=t.inbox)==null?void 0:qo.loading},empty:{...(Vo=e.inbox)==null?void 0:Vo.empty,...(jo=t.inbox)==null?void 0:jo.empty},error:{...(Zo=e.inbox)==null?void 0:Zo.error,...(Jo=t.inbox)==null?void 0:Jo.error}}}};class Ke{constructor(t){a(this,"THEME_CHANGE_EVENT","courier_inbox_theme_change");a(this,"_theme");a(this,"_lightTheme",le);a(this,"_darkTheme",ze);a(this,"_target");a(this,"_subscriptions",[]);a(this,"_userMode");a(this,"_systemMode");a(this,"_systemThemeCleanup");this._theme=t,this._target=new EventTarget,this._userMode="system",this._systemMode=st(),this.setLightTheme(le),this.setDarkTheme(ze),this._systemThemeCleanup=ot(e=>{this._systemMode=e,this.updateTheme()})}setLightTheme(t){this._lightTheme=t,this._systemMode==="light"&&this.updateTheme()}setDarkTheme(t){this._darkTheme=t,this._systemMode==="dark"&&this.updateTheme()}get currentSystemTheme(){return this._systemMode}getTheme(){return this._theme}updateTheme(){const t=this._userMode==="system"?this._systemMode:this._userMode,e=t==="light"?this._lightTheme:this._darkTheme,i=pt(t,e);this.setTheme(i)}setTheme(t){t!==this._theme&&(this._theme=t,this._target.dispatchEvent(new CustomEvent(this.THEME_CHANGE_EVENT,{detail:{theme:t}})))}setMode(t){this._userMode=t,this.updateTheme()}subscribe(t){const e=new AbortController;this._target.addEventListener(this.THEME_CHANGE_EVENT,s=>{t(s.detail.theme)},{signal:e.signal});const i={manager:this,unsubscribe:()=>{e.abort();const s=this._subscriptions.indexOf(i);s>-1&&this._subscriptions.splice(s,1)}};return this._subscriptions.push(i),i}cleanup(){this._systemThemeCleanup&&this._systemThemeCleanup(),this._subscriptions.forEach(t=>t.unsubscribe()),this._subscriptions=[]}}class Xe extends HTMLElement{constructor(e){var i;super();a(this,"_currentFeed","inbox");a(this,"_themeManager");a(this,"_shadow");a(this,"_list");a(this,"_datastoreListener");a(this,"_authListener");a(this,"_style");a(this,"_header");a(this,"_headerFactory");a(this,"_onMessageClick");a(this,"_onMessageActionClick");a(this,"_onMessageLongPress");a(this,"_defaultProps",{title:"Inbox",icon:x.inbox,feedType:this._currentFeed,height:"768px"});this._shadow=this.attachShadow({mode:"open"}),this._themeManager=e??new Ke(le),this._header=new Ge({themeManager:this._themeManager,onFeedTypeChange:s=>{this.setFeedType(s)}}),this._header.build(void 0),this._shadow.appendChild(this._header),this._list=new lt({themeManager:this._themeManager,onRefresh:()=>{this.refresh()},onPaginationTrigger:async s=>{var o,n;try{await P.shared.fetchNextPageOfMessages({feedType:s})}catch(h){(n=(o=v.shared.client)==null?void 0:o.options.logger)==null||n.error("Failed to fetch next page of messages:",h)}},onMessageClick:(s,o)=>{var n;P.shared.clickMessage({message:s}),this.dispatchEvent(new CustomEvent("message-click",{detail:{message:s,index:o},bubbles:!0,composed:!0})),(n=this._onMessageClick)==null||n.call(this,{message:s,index:o})},onMessageActionClick:(s,o,n)=>{var h;this.dispatchEvent(new CustomEvent("message-action-click",{detail:{message:s,action:o,index:n},bubbles:!0,composed:!0})),(h=this._onMessageActionClick)==null||h.call(this,{message:s,action:o,index:n})},onMessageLongPress:(s,o)=>{var n;this.dispatchEvent(new CustomEvent("message-long-press",{detail:{message:s,index:o},bubbles:!0,composed:!0})),(n=this._onMessageLongPress)==null||n.call(this,{message:s,index:o})}}),this._style=document.createElement("style"),this.refreshTheme(),this._shadow.appendChild(this._style),this._shadow.appendChild(this._list),this._datastoreListener=new We({onError:s=>{this._list.setError(s)},onDataSetChange:(s,o)=>{this._currentFeed===o&&(this._list.setDataSet(s),this.updateHeader())},onPageAdded:(s,o)=>{this._currentFeed===o&&(this._list.addPage(s),this.updateHeader())},onMessageAdd:(s,o,n)=>{this._currentFeed===n&&(this._list.addMessage(s,o),this.updateHeader())},onMessageRemove:(s,o,n)=>{this._currentFeed===n&&(this._list.removeMessage(o),this.updateHeader())},onMessageUpdate:(s,o,n)=>{this._currentFeed===n&&(this._list.updateMessage(s,o),this.updateHeader())},onUnreadCountChange:s=>{this.updateHeader()}}),P.shared.addDataStoreListener(this._datastoreListener),this._themeManager.subscribe(s=>{this.refreshTheme()}),this._authListener=v.shared.addAuthenticationListener(s=>{this.refresh()}),(i=v.shared.client)!=null&&i.options.userId&&this.refresh()}get theme(){return this._themeManager.getTheme()}setLightTheme(e){this._themeManager.setLightTheme(e)}setDarkTheme(e){this._themeManager.setDarkTheme(e)}static get observedAttributes(){return["height","light-theme","dark-theme","mode","message-click","message-action-click","message-long-press"]}refreshTheme(){this._style.textContent=this.getStyles()}getStyles(){return`
|
|
567
|
+
`}disconnectedCallback(){this._themeSubscription.unsubscribe()}}customElements.get("courier-inbox-header")||customElements.define("courier-inbox-header",ze);class Oe{constructor(i){a(this,"events");this.events=i}remove(){B.shared.removeDataStoreListener(this)}}const ne={popup:{button:{icon:{color:r.black[500],svg:C.inbox},backgroundColor:"transparent",hoverBackgroundColor:r.black[50010],activeBackgroundColor:r.black[50020],unreadIndicator:{font:{color:r.white[500],size:"14px",family:void 0,weight:void 0},backgroundColor:r.blue[500],borderRadius:"12px"}},window:{backgroundColor:r.white[500],borderRadius:"8px",border:`1px solid ${r.gray[500]}`,shadow:`0px 8px 16px -4px ${r.gray[500]}`}},inbox:{header:{backgroundColor:r.white[500],shadow:`0px 1px 0px 0px ${r.gray[500]}`,filters:{font:{color:r.black[500],family:void 0,size:"18px"},inbox:{icon:{color:r.black[500],svg:C.inbox},text:"Inbox"},archive:{icon:{color:r.black[500],svg:C.archive},text:"Archive"},unreadIndicator:{font:{color:r.white[500],family:void 0,size:"14px"},backgroundColor:r.blue[500],borderRadius:"12px"}},menus:{popup:{backgroundColor:r.white[500],border:`1px solid ${r.gray[500]}`,borderRadius:"4px",shadow:`0px 4px 8px -2px ${r.gray[500]}`,list:{hoverBackgroundColor:r.gray[200],activeBackgroundColor:r.gray[500],divider:"none",font:{color:r.black[500],family:void 0,size:"14px"},selectionIcon:{color:r.black[500],svg:C.check}}},filters:{button:{icon:{color:r.black[500],svg:C.filter},backgroundColor:"transparent",hoverBackgroundColor:r.black[50010],activeBackgroundColor:r.black[50020]},inbox:{icon:{color:r.black[500],svg:C.inbox},text:"Inbox"},archive:{icon:{color:r.black[500],svg:C.archive},text:"Archive"}},actions:{button:{icon:{color:r.black[500],svg:C.overflow},backgroundColor:"transparent",hoverBackgroundColor:r.black[50010],activeBackgroundColor:r.black[50020]},markAllRead:{icon:{color:r.black[500],svg:C.read},text:"Mark All as Read"},archiveAll:{icon:{color:r.black[500],svg:C.archive},text:"Archive All"},archiveRead:{icon:{color:r.black[500],svg:C.archiveRead},text:"Archive Read"}}}},list:{backgroundColor:r.white[500],item:{backgroundColor:"transparent",unreadIndicatorColor:r.blue[500],hoverBackgroundColor:r.gray[200],activeBackgroundColor:r.gray[500],actions:{backgroundColor:"transparent",hoverBackgroundColor:r.gray[200],activeBackgroundColor:r.gray[500],border:`1px solid ${r.gray[500]}`,borderRadius:"4px",shadow:"0px 1px 2px 0px rgba(0, 0, 0, 0.06)",font:{color:r.black[500],family:void 0,size:"14px"}},title:{color:r.black[500],family:void 0,size:"14px"},subtitle:{color:r.gray[600],family:void 0,size:"14px"},time:{color:r.gray[600],family:void 0,size:"14px"},divider:`1px solid ${r.gray[200]}`,menu:{enabled:!0,backgroundColor:r.white[500],border:`1px solid ${r.gray[500]}`,borderRadius:"4px",shadow:`0px 2px 4px -2px ${r.gray[500]}`,longPress:{displayDuration:4e3,vibrationDuration:50},item:{hoverBackgroundColor:r.gray[200],activeBackgroundColor:r.gray[500],borderRadius:"0px",read:{color:r.black[500],svg:C.read},unread:{color:r.black[500],svg:C.unread},archive:{color:r.black[500],svg:C.archive},unarchive:{color:r.black[500],svg:C.unarchive}}}}},loading:{animation:{barColor:r.gray[500],barHeight:"14px",barBorderRadius:"14px",duration:"2s"},divider:`1px solid ${r.gray[200]}`},empty:{title:{font:{size:"16px",weight:"500",color:r.black[500]}},button:{text:"Refresh"}},error:{title:{font:{size:"16px",weight:"500",color:r.black[500]}},button:{text:"Retry"}}}},Be={popup:{button:{icon:{color:r.white[500],svg:C.inbox},backgroundColor:"transparent",hoverBackgroundColor:r.white[50010],activeBackgroundColor:r.white[50020],unreadIndicator:{font:{color:r.white[500],size:"14px",family:void 0,weight:void 0},backgroundColor:r.blue[500],borderRadius:"12px"}},window:{backgroundColor:r.black[500],borderRadius:"8px",border:`1px solid ${r.gray[400]}`,shadow:`0px 4px 8px -2px ${r.white[50020]}`}},inbox:{header:{backgroundColor:r.black[500],shadow:`0px 1px 0px 0px ${r.gray[400]}`,filters:{font:{color:r.white[500],family:void 0,size:"18px"},inbox:{icon:{color:r.white[500],svg:C.inbox},text:"Inbox"},archive:{icon:{color:r.white[500],svg:C.archive},text:"Archive"},unreadIndicator:{font:{color:r.white[500],family:void 0,size:"14px"},backgroundColor:r.blue[500],borderRadius:"12px"}},menus:{popup:{backgroundColor:r.black[500],border:`1px solid ${r.gray[400]}`,borderRadius:"4px",shadow:`0px 4px 8px -2px ${r.white[50020]}`,list:{hoverBackgroundColor:r.white[50010],activeBackgroundColor:r.white[50020],divider:"none",font:{color:r.white[500],family:void 0,size:"14px"},selectionIcon:{color:r.white[500],svg:C.check}}},filters:{button:{icon:{color:r.white[500],svg:C.filter},backgroundColor:"transparent",hoverBackgroundColor:r.white[50010],activeBackgroundColor:r.white[50020]},inbox:{icon:{color:r.white[500],svg:C.inbox},text:"Inbox"},archive:{icon:{color:r.white[500],svg:C.archive},text:"Archive"}},actions:{button:{icon:{color:r.white[500],svg:C.overflow},backgroundColor:"transparent",hoverBackgroundColor:r.white[50010],activeBackgroundColor:r.white[50020]},markAllRead:{icon:{color:r.white[500],svg:C.read},text:"Mark All as Read"},archiveAll:{icon:{color:r.white[500],svg:C.archive},text:"Archive All"},archiveRead:{icon:{color:r.white[500],svg:C.archiveRead},text:"Archive Read"}}}},list:{backgroundColor:r.black[500],item:{backgroundColor:"transparent",unreadIndicatorColor:r.blue[500],hoverBackgroundColor:r.white[50010],activeBackgroundColor:r.white[50020],actions:{backgroundColor:"transparent",hoverBackgroundColor:r.white[50010],activeBackgroundColor:r.white[50020],border:`1px solid ${r.gray[400]}`,borderRadius:"4px",shadow:`0px 1px 2px 0px ${r.white[50010]}`,font:{color:r.white[500],family:void 0,size:"14px"}},title:{color:r.white[500],family:void 0,size:"14px"},subtitle:{color:r.gray[500],family:void 0,size:"14px"},time:{color:r.gray[500],family:void 0,size:"12px"},divider:`1px solid ${r.gray[400]}`,menu:{enabled:!0,backgroundColor:r.black[500],border:`1px solid ${r.gray[400]}`,borderRadius:"4px",shadow:`0px 2px 4px -2px ${r.white[50020]}`,longPress:{displayDuration:4e3,vibrationDuration:50},item:{hoverBackgroundColor:r.white[50010],activeBackgroundColor:r.white[50020],borderRadius:"0px",read:{color:r.white[500],svg:C.read},unread:{color:r.white[500],svg:C.unread},archive:{color:r.white[500],svg:C.archive},unarchive:{color:r.white[500],svg:C.unarchive}}}}},loading:{animation:{barColor:r.white[500],barHeight:"14px",barBorderRadius:"14px",duration:"2s"},divider:`1px solid ${r.gray[400]}`},empty:{title:{font:{size:"16px",weight:"500",color:r.white[500]}},button:{text:"Refresh"}},error:{title:{font:{size:"16px",weight:"500",color:r.white[500]}},button:{text:"Retry"}}}},Je=(m,i)=>{var t,s,o,n,h,d,c,u,g,p,x,f,b,v,k,w,S,M,I,L,A,$,F,y,D,H,R,z,O,N,U,V,Z,j,Y,K,Q,J,q,ae,he,ce,le,de,ue,pe,ge,me,be,_e,fe,xe,Ce,ve,ye,ke,we,Se,Me,l,P,ee,te,W,Ee,it,st,ot,nt,rt,at,ht,ct,lt,dt,ut,pt,gt,mt,bt,_t,ft,xt,Ct,vt,yt,kt,wt,St,Mt,Et,It,Lt,Tt,At,Bt,Dt,Pt,$t,Ft,Ht,Rt,zt,Ot,Nt,Ut,Vt,Zt,jt,Wt,Gt,qt,Xt,Yt,Kt,Qt,Jt,ei,ti,ii,si,oi,ni,ri,ai,hi,ci,li,di,ui,pi,gi,mi,bi,_i,fi,xi,Ci,vi,yi,ki,wi,Si,Mi,Ei,Ii,Li,Ti,Ai,Bi,Di,Pi,$i,Fi,Hi,Ri,zi,Oi,Ni,Ui,Vi,Zi,ji,Wi,Gi,qi,Xi,Yi,Ki,Qi,Ji,es,ts,is,ss,os,ns,rs,as,hs,cs,ls,ds,us,ps,gs,ms,bs,_s,fs,xs,Cs,vs,ys,ks,ws,Ss,Ms,Es,Is,Ls,Ts,As,Bs,Ds,Ps,$s,Fs,Hs,Rs,zs,Os,Ns,Us,Vs,Zs,js,Ws,Gs,qs,Xs,Ys,Ks,Qs,Js,eo,to,io,so,oo,no,ro,ao,ho,co,lo,uo,po,go,mo,bo,_o,fo,xo,Co,vo,yo,ko,wo,So,Mo,Eo,Io,Lo,To,Ao,Bo,Do;const e=m==="light"?ne:Be;return{popup:{button:{...(t=e.popup)==null?void 0:t.button,...(s=i.popup)==null?void 0:s.button,icon:{...(n=(o=e.popup)==null?void 0:o.button)==null?void 0:n.icon,...(d=(h=i.popup)==null?void 0:h.button)==null?void 0:d.icon},unreadIndicator:{...(u=(c=e.popup)==null?void 0:c.button)==null?void 0:u.unreadIndicator,...(p=(g=i.popup)==null?void 0:g.button)==null?void 0:p.unreadIndicator}},window:{...(x=e.popup)==null?void 0:x.window,...(f=i.popup)==null?void 0:f.window}},inbox:{header:{...(b=e.inbox)==null?void 0:b.header,...(v=i.inbox)==null?void 0:v.header,filters:{...(w=(k=e.inbox)==null?void 0:k.header)==null?void 0:w.filters,...(M=(S=i.inbox)==null?void 0:S.header)==null?void 0:M.filters,inbox:{...(A=(L=(I=e.inbox)==null?void 0:I.header)==null?void 0:L.filters)==null?void 0:A.inbox,...(y=(F=($=i.inbox)==null?void 0:$.header)==null?void 0:F.filters)==null?void 0:y.inbox,icon:{...(z=(R=(H=(D=e.inbox)==null?void 0:D.header)==null?void 0:H.filters)==null?void 0:R.inbox)==null?void 0:z.icon,...(V=(U=(N=(O=i.inbox)==null?void 0:O.header)==null?void 0:N.filters)==null?void 0:U.inbox)==null?void 0:V.icon}},archive:{...(Y=(j=(Z=e.inbox)==null?void 0:Z.header)==null?void 0:j.filters)==null?void 0:Y.archive,...(J=(Q=(K=i.inbox)==null?void 0:K.header)==null?void 0:Q.filters)==null?void 0:J.archive,icon:{...(ce=(he=(ae=(q=e.inbox)==null?void 0:q.header)==null?void 0:ae.filters)==null?void 0:he.archive)==null?void 0:ce.icon,...(pe=(ue=(de=(le=i.inbox)==null?void 0:le.header)==null?void 0:de.filters)==null?void 0:ue.archive)==null?void 0:pe.icon}},unreadIndicator:{...(be=(me=(ge=e.inbox)==null?void 0:ge.header)==null?void 0:me.filters)==null?void 0:be.unreadIndicator,...(xe=(fe=(_e=i.inbox)==null?void 0:_e.header)==null?void 0:fe.filters)==null?void 0:xe.unreadIndicator}},menus:{...(ve=(Ce=e.inbox)==null?void 0:Ce.header)==null?void 0:ve.menus,...(ke=(ye=i.inbox)==null?void 0:ye.header)==null?void 0:ke.menus,popup:{...(Me=(Se=(we=e.inbox)==null?void 0:we.header)==null?void 0:Se.menus)==null?void 0:Me.popup,...(ee=(P=(l=i.inbox)==null?void 0:l.header)==null?void 0:P.menus)==null?void 0:ee.popup,list:{...(it=(Ee=(W=(te=e.inbox)==null?void 0:te.header)==null?void 0:W.menus)==null?void 0:Ee.popup)==null?void 0:it.list,...(rt=(nt=(ot=(st=i.inbox)==null?void 0:st.header)==null?void 0:ot.menus)==null?void 0:nt.popup)==null?void 0:rt.list,font:{...(dt=(lt=(ct=(ht=(at=e.inbox)==null?void 0:at.header)==null?void 0:ht.menus)==null?void 0:ct.popup)==null?void 0:lt.list)==null?void 0:dt.font,...(bt=(mt=(gt=(pt=(ut=i.inbox)==null?void 0:ut.header)==null?void 0:pt.menus)==null?void 0:gt.popup)==null?void 0:mt.list)==null?void 0:bt.font},selectionIcon:{...(vt=(Ct=(xt=(ft=(_t=e.inbox)==null?void 0:_t.header)==null?void 0:ft.menus)==null?void 0:xt.popup)==null?void 0:Ct.list)==null?void 0:vt.selectionIcon,...(Mt=(St=(wt=(kt=(yt=i.inbox)==null?void 0:yt.header)==null?void 0:kt.menus)==null?void 0:wt.popup)==null?void 0:St.list)==null?void 0:Mt.selectionIcon}}},filters:{...(Lt=(It=(Et=e.inbox)==null?void 0:Et.header)==null?void 0:It.menus)==null?void 0:Lt.filters,...(Bt=(At=(Tt=i.inbox)==null?void 0:Tt.header)==null?void 0:At.menus)==null?void 0:Bt.filters,inbox:{...(Ft=($t=(Pt=(Dt=e.inbox)==null?void 0:Dt.header)==null?void 0:Pt.menus)==null?void 0:$t.filters)==null?void 0:Ft.inbox,...(Ot=(zt=(Rt=(Ht=i.inbox)==null?void 0:Ht.header)==null?void 0:Rt.menus)==null?void 0:zt.filters)==null?void 0:Ot.inbox,icon:{...(jt=(Zt=(Vt=(Ut=(Nt=e.inbox)==null?void 0:Nt.header)==null?void 0:Ut.menus)==null?void 0:Vt.filters)==null?void 0:Zt.inbox)==null?void 0:jt.icon,...(Yt=(Xt=(qt=(Gt=(Wt=i.inbox)==null?void 0:Wt.header)==null?void 0:Gt.menus)==null?void 0:qt.filters)==null?void 0:Xt.inbox)==null?void 0:Yt.icon}},archive:{...(ei=(Jt=(Qt=(Kt=e.inbox)==null?void 0:Kt.header)==null?void 0:Qt.menus)==null?void 0:Jt.filters)==null?void 0:ei.archive,...(oi=(si=(ii=(ti=i.inbox)==null?void 0:ti.header)==null?void 0:ii.menus)==null?void 0:si.filters)==null?void 0:oi.archive,icon:{...(ci=(hi=(ai=(ri=(ni=e.inbox)==null?void 0:ni.header)==null?void 0:ri.menus)==null?void 0:ai.filters)==null?void 0:hi.archive)==null?void 0:ci.icon,...(gi=(pi=(ui=(di=(li=i.inbox)==null?void 0:li.header)==null?void 0:di.menus)==null?void 0:ui.filters)==null?void 0:pi.archive)==null?void 0:gi.icon}}},actions:{...(_i=(bi=(mi=e.inbox)==null?void 0:mi.header)==null?void 0:bi.menus)==null?void 0:_i.actions,...(Ci=(xi=(fi=i.inbox)==null?void 0:fi.header)==null?void 0:xi.menus)==null?void 0:Ci.actions,markAllRead:{...(wi=(ki=(yi=(vi=e.inbox)==null?void 0:vi.header)==null?void 0:yi.menus)==null?void 0:ki.actions)==null?void 0:wi.markAllRead,...(Ii=(Ei=(Mi=(Si=i.inbox)==null?void 0:Si.header)==null?void 0:Mi.menus)==null?void 0:Ei.actions)==null?void 0:Ii.markAllRead,icon:{...(Di=(Bi=(Ai=(Ti=(Li=e.inbox)==null?void 0:Li.header)==null?void 0:Ti.menus)==null?void 0:Ai.actions)==null?void 0:Bi.markAllRead)==null?void 0:Di.icon,...(Ri=(Hi=(Fi=($i=(Pi=i.inbox)==null?void 0:Pi.header)==null?void 0:$i.menus)==null?void 0:Fi.actions)==null?void 0:Hi.markAllRead)==null?void 0:Ri.icon}},archiveAll:{...(Ui=(Ni=(Oi=(zi=e.inbox)==null?void 0:zi.header)==null?void 0:Oi.menus)==null?void 0:Ni.actions)==null?void 0:Ui.archiveAll,...(Wi=(ji=(Zi=(Vi=i.inbox)==null?void 0:Vi.header)==null?void 0:Zi.menus)==null?void 0:ji.actions)==null?void 0:Wi.archiveAll,icon:{...(Ki=(Yi=(Xi=(qi=(Gi=e.inbox)==null?void 0:Gi.header)==null?void 0:qi.menus)==null?void 0:Xi.actions)==null?void 0:Yi.archiveAll)==null?void 0:Ki.icon,...(is=(ts=(es=(Ji=(Qi=i.inbox)==null?void 0:Qi.header)==null?void 0:Ji.menus)==null?void 0:es.actions)==null?void 0:ts.archiveAll)==null?void 0:is.icon}},archiveRead:{...(rs=(ns=(os=(ss=e.inbox)==null?void 0:ss.header)==null?void 0:os.menus)==null?void 0:ns.actions)==null?void 0:rs.archiveRead,...(ls=(cs=(hs=(as=i.inbox)==null?void 0:as.header)==null?void 0:hs.menus)==null?void 0:cs.actions)==null?void 0:ls.archiveRead,icon:{...(ms=(gs=(ps=(us=(ds=e.inbox)==null?void 0:ds.header)==null?void 0:us.menus)==null?void 0:ps.actions)==null?void 0:gs.archiveRead)==null?void 0:ms.icon,...(Cs=(xs=(fs=(_s=(bs=i.inbox)==null?void 0:bs.header)==null?void 0:_s.menus)==null?void 0:fs.actions)==null?void 0:xs.archiveRead)==null?void 0:Cs.icon}}}}},list:{...(vs=e.inbox)==null?void 0:vs.list,...(ys=i.inbox)==null?void 0:ys.list,item:{...(ws=(ks=e.inbox)==null?void 0:ks.list)==null?void 0:ws.item,...(Ms=(Ss=i.inbox)==null?void 0:Ss.list)==null?void 0:Ms.item,menu:{...(Ls=(Is=(Es=e.inbox)==null?void 0:Es.list)==null?void 0:Is.item)==null?void 0:Ls.menu,...(Bs=(As=(Ts=i.inbox)==null?void 0:Ts.list)==null?void 0:As.item)==null?void 0:Bs.menu,item:{...(Fs=($s=(Ps=(Ds=e.inbox)==null?void 0:Ds.list)==null?void 0:Ps.item)==null?void 0:$s.menu)==null?void 0:Fs.item,...(Os=(zs=(Rs=(Hs=i.inbox)==null?void 0:Hs.list)==null?void 0:Rs.item)==null?void 0:zs.menu)==null?void 0:Os.item,read:{...(js=(Zs=(Vs=(Us=(Ns=e.inbox)==null?void 0:Ns.list)==null?void 0:Us.item)==null?void 0:Vs.menu)==null?void 0:Zs.item)==null?void 0:js.read,...(Ys=(Xs=(qs=(Gs=(Ws=i.inbox)==null?void 0:Ws.list)==null?void 0:Gs.item)==null?void 0:qs.menu)==null?void 0:Xs.item)==null?void 0:Ys.read},unread:{...(to=(eo=(Js=(Qs=(Ks=e.inbox)==null?void 0:Ks.list)==null?void 0:Qs.item)==null?void 0:Js.menu)==null?void 0:eo.item)==null?void 0:to.unread,...(ro=(no=(oo=(so=(io=i.inbox)==null?void 0:io.list)==null?void 0:so.item)==null?void 0:oo.menu)==null?void 0:no.item)==null?void 0:ro.unread},archive:{...(uo=(lo=(co=(ho=(ao=e.inbox)==null?void 0:ao.list)==null?void 0:ho.item)==null?void 0:co.menu)==null?void 0:lo.item)==null?void 0:uo.archive,...(_o=(bo=(mo=(go=(po=i.inbox)==null?void 0:po.list)==null?void 0:go.item)==null?void 0:mo.menu)==null?void 0:bo.item)==null?void 0:_o.archive},unarchive:{...(yo=(vo=(Co=(xo=(fo=e.inbox)==null?void 0:fo.list)==null?void 0:xo.item)==null?void 0:Co.menu)==null?void 0:vo.item)==null?void 0:yo.unarchive,...(Eo=(Mo=(So=(wo=(ko=i.inbox)==null?void 0:ko.list)==null?void 0:wo.item)==null?void 0:So.menu)==null?void 0:Mo.item)==null?void 0:Eo.unarchive}}}}},loading:{...(Io=e.inbox)==null?void 0:Io.loading,...(Lo=i.inbox)==null?void 0:Lo.loading},empty:{...(To=e.inbox)==null?void 0:To.empty,...(Ao=i.inbox)==null?void 0:Ao.empty},error:{...(Bo=e.inbox)==null?void 0:Bo.error,...(Do=i.inbox)==null?void 0:Do.error}}}};class Ne{constructor(i){a(this,"THEME_CHANGE_EVENT","courier_inbox_theme_change");a(this,"_theme");a(this,"_lightTheme",ne);a(this,"_darkTheme",Be);a(this,"_target");a(this,"_subscriptions",[]);a(this,"_userMode");a(this,"_systemMode");a(this,"_systemThemeCleanup");this._theme=i,this._target=new EventTarget,this._userMode="system",this._systemMode=Ve(),this.setLightTheme(ne),this.setDarkTheme(Be),this._systemThemeCleanup=Ze(e=>{this._systemMode=e,this.updateTheme()})}setLightTheme(i){this._lightTheme=i,this._systemMode==="light"&&this.updateTheme()}setDarkTheme(i){this._darkTheme=i,this._systemMode==="dark"&&this.updateTheme()}get currentSystemTheme(){return this._systemMode}getTheme(){return this._theme}updateTheme(){const i=this._userMode==="system"?this._systemMode:this._userMode,e=i==="light"?this._lightTheme:this._darkTheme,t=Je(i,e);this.setTheme(t)}setTheme(i){i!==this._theme&&(this._theme=i,this._target.dispatchEvent(new CustomEvent(this.THEME_CHANGE_EVENT,{detail:{theme:i}})))}setMode(i){this._userMode=i,this.updateTheme()}subscribe(i){const e=new AbortController;this._target.addEventListener(this.THEME_CHANGE_EVENT,s=>{i(s.detail.theme)},{signal:e.signal});const t={manager:this,unsubscribe:()=>{e.abort();const s=this._subscriptions.indexOf(t);s>-1&&this._subscriptions.splice(s,1)}};return this._subscriptions.push(t),t}cleanup(){this._systemThemeCleanup&&this._systemThemeCleanup(),this._subscriptions.forEach(i=>i.unsubscribe()),this._subscriptions=[]}}class Ue extends HTMLElement{constructor(e){var t;super();a(this,"_currentFeed","inbox");a(this,"_themeManager");a(this,"_shadow");a(this,"_list");a(this,"_datastoreListener");a(this,"_authListener");a(this,"_style");a(this,"_header");a(this,"_headerFactory");a(this,"_onMessageClick");a(this,"_onMessageActionClick");a(this,"_onMessageLongPress");a(this,"_defaultProps",{title:"Inbox",icon:C.inbox,feedType:this._currentFeed,height:"768px"});this._shadow=this.attachShadow({mode:"open"}),this._themeManager=e??new Ne(ne),this._header=new ze({themeManager:this._themeManager,onFeedTypeChange:s=>{this.setFeedType(s)}}),this._header.build(void 0),this._shadow.appendChild(this._header),this._list=new Ye({themeManager:this._themeManager,onRefresh:()=>{this.refresh()},onPaginationTrigger:async s=>{var o,n;try{await B.shared.fetchNextPageOfMessages({feedType:s})}catch(h){(n=(o=_.Courier.shared.client)==null?void 0:o.options.logger)==null||n.error("Failed to fetch next page of messages:",h)}},onMessageClick:(s,o)=>{var n;B.shared.clickMessage({message:s}),this.dispatchEvent(new CustomEvent("message-click",{detail:{message:s,index:o},bubbles:!0,composed:!0})),(n=this._onMessageClick)==null||n.call(this,{message:s,index:o})},onMessageActionClick:(s,o,n)=>{var h;this.dispatchEvent(new CustomEvent("message-action-click",{detail:{message:s,action:o,index:n},bubbles:!0,composed:!0})),(h=this._onMessageActionClick)==null||h.call(this,{message:s,action:o,index:n})},onMessageLongPress:(s,o)=>{var n;this.dispatchEvent(new CustomEvent("message-long-press",{detail:{message:s,index:o},bubbles:!0,composed:!0})),(n=this._onMessageLongPress)==null||n.call(this,{message:s,index:o})}}),this._style=document.createElement("style"),this.refreshTheme(),this._shadow.appendChild(this._style),this._shadow.appendChild(this._list),this._datastoreListener=new Oe({onError:s=>{this._list.setError(s)},onDataSetChange:(s,o)=>{this._currentFeed===o&&(this._list.setDataSet(s),this.updateHeader())},onPageAdded:(s,o)=>{this._currentFeed===o&&(this._list.addPage(s),this.updateHeader())},onMessageAdd:(s,o,n)=>{this._currentFeed===n&&(this._list.addMessage(s,o),this.updateHeader())},onMessageRemove:(s,o,n)=>{this._currentFeed===n&&(this._list.removeMessage(o),this.updateHeader())},onMessageUpdate:(s,o,n)=>{this._currentFeed===n&&(this._list.updateMessage(s,o),this.updateHeader())},onUnreadCountChange:s=>{this.updateHeader()}}),B.shared.addDataStoreListener(this._datastoreListener),this._themeManager.subscribe(s=>{this.refreshTheme()}),this._authListener=_.Courier.shared.addAuthenticationListener(s=>{this.refresh()}),(t=_.Courier.shared.client)!=null&&t.options.userId&&this.refresh()}get theme(){return this._themeManager.getTheme()}setLightTheme(e){this._themeManager.setLightTheme(e)}setDarkTheme(e){this._themeManager.setDarkTheme(e)}static get observedAttributes(){return["height","light-theme","dark-theme","mode","message-click","message-action-click","message-long-press"]}refreshTheme(){this._style.textContent=this.getStyles()}getStyles(){return`
|
|
698
568
|
:host {
|
|
699
569
|
display: flex;
|
|
700
570
|
flex-direction: column;
|
|
@@ -711,7 +581,7 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
711
581
|
overflow-y: auto;
|
|
712
582
|
overflow-x: hidden;
|
|
713
583
|
}
|
|
714
|
-
`}setHeader(e){this._headerFactory=e,this.updateHeader()}removeHeader(){this._headerFactory=null,this.updateHeader()}setLoadingState(e){this._list.setLoadingStateFactory(e)}setEmptyState(e){this._list.setEmptyStateFactory(e)}setErrorState(e){this._list.setErrorStateFactory(e)}setListItem(e){this._list.setListItemFactory(e)}setPaginationItem(e){this._list.setPaginationItemFactory(e)}onMessageClick(e){this._onMessageClick=e}onMessageActionClick(e){this._onMessageActionClick=e}onMessageLongPress(e){this._onMessageLongPress=e}setFeedType(e){this._currentFeed=e,this._list.setFeedType(e),this.updateHeader(),this.load({feedType:this._currentFeed,canUseCache:!0})}updateHeader(){const e={feedType:this._currentFeed,unreadCount:
|
|
584
|
+
`}setHeader(e){this._headerFactory=e,this.updateHeader()}removeHeader(){this._headerFactory=null,this.updateHeader()}setLoadingState(e){this._list.setLoadingStateFactory(e)}setEmptyState(e){this._list.setEmptyStateFactory(e)}setErrorState(e){this._list.setErrorStateFactory(e)}setListItem(e){this._list.setListItemFactory(e)}setPaginationItem(e){this._list.setPaginationItemFactory(e)}onMessageClick(e){this._onMessageClick=e}onMessageActionClick(e){this._onMessageActionClick=e}onMessageLongPress(e){this._onMessageLongPress=e}setFeedType(e){this._currentFeed=e,this._list.setFeedType(e),this.updateHeader(),this.load({feedType:this._currentFeed,canUseCache:!0})}updateHeader(){const e={feedType:this._currentFeed,unreadCount:B.shared.unreadCount,messageCount:this._list.messages.length};switch(this._headerFactory){case void 0:this._header.render(e);break;case null:this._header.build(null);break;default:const t=this._headerFactory(e);this._header.build(t);break}}async load(e){await B.shared.load(e)}refresh(){this.load({feedType:this._currentFeed,canUseCache:!1})}connectedCallback(){this.refresh()}disconnectedCallback(){var e,t;this._themeManager.cleanup(),(e=this._datastoreListener)==null||e.remove(),(t=this._authListener)==null||t.remove()}attributeChangedCallback(e,t,s){var o,n,h,d,c,u;if(t!==s)switch(e){case"height":const g=s||this._defaultProps.height;this.style.height=g;break;case"message-click":if(s)try{this._onMessageClick=new Function("props",s)}catch(p){(n=(o=_.Courier.shared.client)==null?void 0:o.options.logger)==null||n.error("Failed to parse message-click handler:",p)}else this._onMessageClick=void 0;break;case"message-action-click":if(s)try{this._onMessageActionClick=new Function("props",s)}catch(p){(d=(h=_.Courier.shared.client)==null?void 0:h.options.logger)==null||d.error("Failed to parse message-action-click handler:",p)}else this._onMessageActionClick=void 0;break;case"message-long-press":if(s)try{this._onMessageLongPress=new Function("props",s)}catch(p){(u=(c=_.Courier.shared.client)==null?void 0:c.options.logger)==null||u.error("Failed to parse message-long-press handler:",p)}else this._onMessageLongPress=void 0;break;case"light-theme":s&&this.setLightTheme(JSON.parse(s));break;case"dark-theme":s&&this.setDarkTheme(JSON.parse(s));break;case"mode":this._themeManager.setMode(s);break}}}customElements.get("courier-inbox")||customElements.define("courier-inbox",Ue);class et extends Le{constructor(e){super();a(this,"_themeSubscription");a(this,"_container");a(this,"_triggerButton");a(this,"_unreadCountBadge");this._themeSubscription=e.subscribe(t=>{this.updateTheme()})}defaultElement(){this._container=document.createElement("div"),this._container.className="menu-button-container",this._triggerButton=new re(C.inbox),this._unreadCountBadge=new Re({themeBus:this._themeSubscription.manager,location:"button"}),this._unreadCountBadge.id="unread-badge";const e=document.createElement("style");return e.textContent=this.getStyles(),this._container.appendChild(e),this._container.appendChild(this._triggerButton),this._container.appendChild(this._unreadCountBadge),this.shadow.appendChild(this._container),this.updateTheme(),this._container}getStyles(){return`
|
|
715
585
|
.menu-button-container {
|
|
716
586
|
position: relative;
|
|
717
587
|
display: inline-block;
|
|
@@ -723,7 +593,7 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
723
593
|
left: 50%;
|
|
724
594
|
pointer-events: none;
|
|
725
595
|
}
|
|
726
|
-
`}onUnreadCountChange(e){var
|
|
596
|
+
`}onUnreadCountChange(e){var t;(t=this._unreadCountBadge)==null||t.setCount(e),this.updateTheme()}updateTheme(){var t,s,o,n,h,d,c,u,g,p,x,f,b,v,k,w,S,M;const e=this._themeSubscription.manager.getTheme();(n=this._triggerButton)==null||n.updateIconColor(((o=(s=(t=e==null?void 0:e.popup)==null?void 0:t.button)==null?void 0:s.icon)==null?void 0:o.color)??r.black[500]),(u=this._triggerButton)==null||u.updateIconSVG(((c=(d=(h=e==null?void 0:e.popup)==null?void 0:h.button)==null?void 0:d.icon)==null?void 0:c.svg)??C.inbox),(x=this._triggerButton)==null||x.updateBackgroundColor(((p=(g=e==null?void 0:e.popup)==null?void 0:g.button)==null?void 0:p.backgroundColor)??"transparent"),(v=this._triggerButton)==null||v.updateHoverBackgroundColor(((b=(f=e==null?void 0:e.popup)==null?void 0:f.button)==null?void 0:b.hoverBackgroundColor)??r.black[50010]),(S=this._triggerButton)==null||S.updateActiveBackgroundColor(((w=(k=e==null?void 0:e.popup)==null?void 0:k.button)==null?void 0:w.activeBackgroundColor)??r.black[50020]),(M=this._unreadCountBadge)==null||M.refreshTheme("button")}disconnectedCallback(){this._themeSubscription.unsubscribe()}}customElements.get("courier-inbox-menu-button")||customElements.define("courier-inbox-menu-button",et);class tt extends HTMLElement{constructor(){super();a(this,"_width","440px");a(this,"_height","440px");a(this,"_popupAlignment","top-right");a(this,"_top","40px");a(this,"_right","0");a(this,"_bottom","40px");a(this,"_left","0");a(this,"_themeManager",new Ne(ne));a(this,"_triggerButton");a(this,"_popup");a(this,"_inbox");a(this,"_style");a(this,"_datastoreListener");a(this,"_popupMenuButtonFactory");const e=this.attachShadow({mode:"open"});this._triggerButton=new et(this._themeManager),this._triggerButton.build(void 0),this._popup=document.createElement("div"),this._popup.className="popup",this._inbox=new Ue(this._themeManager),this._inbox.setAttribute("height","100%"),this._style=document.createElement("style"),this.refreshTheme(),e.appendChild(this._style),e.appendChild(this._triggerButton),e.appendChild(this._popup),this._popup.appendChild(this._inbox),this._triggerButton.addEventListener("click",this.togglePopup.bind(this)),document.addEventListener("click",this.handleOutsideClick.bind(this)),this.updatePopupPosition(),this._datastoreListener=new Oe(this),B.shared.addDataStoreListener(this._datastoreListener),this._themeManager.subscribe(t=>{this.refreshTheme()})}get theme(){return this._themeManager.getTheme()}setLightTheme(e){this._themeManager.setLightTheme(e)}setDarkTheme(e){this._themeManager.setDarkTheme(e)}static get observedAttributes(){return["popup-alignment","message-click","message-action-click","message-long-press","popup-width","popup-height","top","right","bottom","left","light-theme","dark-theme","mode"]}refreshTheme(){this._style.textContent=this.getStyles()}getStyles(){var e,t,s,o,n,h,d,c;return`
|
|
727
597
|
:host {
|
|
728
598
|
display: inline-block;
|
|
729
599
|
position: relative;
|
|
@@ -737,10 +607,10 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
737
607
|
.popup {
|
|
738
608
|
display: none;
|
|
739
609
|
position: absolute;
|
|
740
|
-
background: ${((
|
|
610
|
+
background: ${((t=(e=this.theme.popup)==null?void 0:e.window)==null?void 0:t.backgroundColor)??"red"};
|
|
741
611
|
border-radius: ${((o=(s=this.theme.popup)==null?void 0:s.window)==null?void 0:o.borderRadius)??"8px"};
|
|
742
612
|
border: ${((h=(n=this.theme.popup)==null?void 0:n.window)==null?void 0:h.border)??"1px solid red"};
|
|
743
|
-
box-shadow: ${((
|
|
613
|
+
box-shadow: ${((c=(d=this.theme.popup)==null?void 0:d.window)==null?void 0:c.shadow)??"0px 8px 16px -4px red"};
|
|
744
614
|
z-index: 1000;
|
|
745
615
|
width: ${this._width};
|
|
746
616
|
height: ${this._height};
|
|
@@ -759,4 +629,4 @@ This endpoint should be called from your backend server, not the SDK.`)),this.op
|
|
|
759
629
|
courier-inbox {
|
|
760
630
|
height: 100%;
|
|
761
631
|
}
|
|
762
|
-
`}attributeChangedCallback(e,
|
|
632
|
+
`}attributeChangedCallback(e,t,s){switch(e){case"popup-alignment":this.isValidPosition(s)&&(this._popupAlignment=s,this.updatePopupPosition());break;case"popup-width":this._width=s,this.setSize(s,this._height);break;case"popup-height":this._height=s,this.setSize(this._width,s);break;case"top":this._top=s,this.updatePopupPosition();break;case"right":this._right=s,this.updatePopupPosition();break;case"bottom":this._bottom=s,this.updatePopupPosition();break;case"left":this._left=s,this.updatePopupPosition();break;case"light-theme":s&&this.setLightTheme(JSON.parse(s));break;case"dark-theme":s&&this.setDarkTheme(JSON.parse(s));break;case"mode":this._themeManager.setMode(s);break}}onUnreadCountChange(e){this.render()}onMessageClick(e){this._inbox.onMessageClick(e)}onMessageActionClick(e){this._inbox.onMessageActionClick(e)}onMessageLongPress(e){this._inbox.onMessageLongPress(e)}isValidPosition(e){return["top-right","top-left","top-center","bottom-right","bottom-left","bottom-center","center-right","center-left","center-center"].includes(e)}updatePopupPosition(){switch(this._popup.style.top="",this._popup.style.bottom="",this._popup.style.left="",this._popup.style.right="",this._popup.style.margin="",this._popup.style.transform="",this._popupAlignment){case"top-right":this._popup.style.top=this._top,this._popup.style.right=this._right;break;case"top-left":this._popup.style.top=this._top,this._popup.style.left=this._left;break;case"top-center":this._popup.style.top=this._top,this._popup.style.left="50%",this._popup.style.transform="translateX(-50%)";break;case"bottom-right":this._popup.style.bottom=this._bottom,this._popup.style.right=this._right;break;case"bottom-left":this._popup.style.bottom=this._bottom,this._popup.style.left=this._left;break;case"bottom-center":this._popup.style.bottom=this._bottom,this._popup.style.left="50%",this._popup.style.transform="translateX(-50%)";break;case"center-right":this._popup.style.top="50%",this._popup.style.right=this._right,this._popup.style.transform="translateY(-50%)";break;case"center-left":this._popup.style.top="50%",this._popup.style.left=this._left,this._popup.style.transform="translateY(-50%)";break;case"center-center":this._popup.style.top="50%",this._popup.style.left="50%",this._popup.style.transform="translate(-50%, -50%)";break}}togglePopup(e){e.stopPropagation(),this._popup.style.display==="block"?this._popup.style.display="none":this._popup.style.display="block"}handleOutsideClick(e){this.contains(e.target)||(this._popup.style.display="none")}setContent(e){this._inbox.innerHTML="",this._inbox.appendChild(e)}setSize(e,t){this._width=e,this._height=t,this._popup.style.width=e,this._popup.style.height=t}setPosition(e){var t,s;this.isValidPosition(e)?(this._popupAlignment=e,this.updatePopupPosition()):(s=(t=_.Courier.shared.client)==null?void 0:t.options.logger)==null||s.error(`Invalid position: ${e}`)}setFeedType(e){this._inbox.setFeedType(e)}setPopupHeader(e){this._inbox.setHeader(e)}removePopupHeader(){this._inbox.removeHeader()}setPopupLoadingState(e){this._inbox.setLoadingState(e)}setPopupEmptyState(e){this._inbox.setEmptyState(e)}setPopupErrorState(e){this._inbox.setErrorState(e)}setPopupListItem(e){this._inbox.setListItem(e)}setPopupPaginationItem(e){this._inbox.setPaginationItem(e)}setPopupMenuButton(e){this._popupMenuButtonFactory=e,this.render()}render(){const e=B.shared.unreadCount;switch(this._popupMenuButtonFactory){case void 0:case null:this._triggerButton.build(void 0),this._triggerButton.onUnreadCountChange(e);break;default:const t=this._popupMenuButtonFactory({unreadCount:e});this._triggerButton.build(t);break}}disconnectedCallback(){var e;(e=this._datastoreListener)==null||e.remove(),this._themeManager.cleanup()}}customElements.get("courier-inbox-menu")||customElements.define("courier-inbox-menu",tt);class Oo{onDataSetChange(i,e){}onPageAdded(i,e){}onUnreadCountChange(i){}onMessageAdd(i,e,t){}onMessageRemove(i,e,t){}onMessageUpdate(i,e,t){}onError(i){}}E.CourierInbox=Ue,E.CourierInboxDataStoreListener=Oe,E.CourierInboxDatastore=B,E.CourierInboxDatastoreEvents=Oo,E.CourierInboxHeader=ze,E.CourierInboxMenu=tt,E.CourierInboxThemeManager=Ne,E.CourierListItem=$e,E.archiveMessage=Ro,E.clickMessage=Ho,E.defaultDarkTheme=Be,E.defaultLightTheme=ne,E.getMessageTime=We,E.markAsRead=$o,E.markAsUnread=Fo,E.mergeTheme=Je,E.openMessage=zo,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
|