@nyaruka/temba-components 0.173.0 → 0.173.1
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/CHANGELOG.md +6 -0
- package/dist/temba-components.js +2 -2
- package/dist/temba-components.js.map +1 -1
- package/package.json +1 -1
- package/src/live/ContactChat.ts +3 -10
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v0.173.1](https://github.com/nyaruka/temba-components/compare/v0.173.0...v0.173.1)
|
|
8
|
+
|
|
9
|
+
- Search the full contact history even when the chat is viewing a ticket [`#1109`](https://github.com/nyaruka/temba-components/pull/1109)
|
|
10
|
+
|
|
7
11
|
#### [v0.173.0](https://github.com/nyaruka/temba-components/compare/v0.172.0...v0.173.0)
|
|
8
12
|
|
|
13
|
+
> 3 August 2026
|
|
14
|
+
|
|
9
15
|
- Add a shortcut list component and let header bars fit their content [`#1108`](https://github.com/nyaruka/temba-components/pull/1108)
|
|
10
16
|
- Record screenshots for the shortcut list and fit-content header bar [`e15751a`](https://github.com/nyaruka/temba-components/commit/e15751a2e1f4c8109e8cb7162f8d596e522a0ca5)
|
|
11
17
|
|
package/dist/temba-components.js
CHANGED
|
@@ -4638,7 +4638,7 @@ const{I:Uu}=lt,qu=t=>t,Wu=()=>document.createComment(""),ju=(t,e,i)=>{const o=t.
|
|
|
4638
4638
|
temba-button {
|
|
4639
4639
|
--button-border: 1px solid #ddd;
|
|
4640
4640
|
}
|
|
4641
|
-
`}set showMessageLogsAfter(t){const e=this._showMessageLogsAfter;this._showMessageLogsAfter=t?new Date(t):null,this.requestUpdate("showMessageLogsAfter",e)}get showMessageLogsAfter(){return this._showMessageLogsAfter}constructor(){super(),this.watchTypes=null,this.contactsEndpoint="/api/v2/contacts.json",this.currentNote="",this.showDetails=!0,this.currentTicket=null,this.currentContact=null,this.agent="",this.userUuid="",this.blockFetching=!1,this.showInterrupt=!1,this.disableAssign=!1,this.disableReply=!1,this.showSearch=!1,this.avatar=$d,this._showMessageLogsAfter=null,this.searchMode=!1,this.searchQuery="",this.searchResults=[],this.searchIndex=-1,this.searchLoading=!1,this.searchFocused=!1,this.searchClosing=!1,this.searchNoResults=!1,this.ticket=null,this.beforeUUID=null,this.afterUUID=null,this.subscriptions=new Map,this.fetchingMissed=!1,this.lastIncomingMsgOn=null,this.lastIncomingMsgExternalId=null,this.typingChannel=null,this.typingPulse=null,this.typingDisabled=!1,this.stateRefresh=null,this.lastSearchedQuery="",this.pendingSearch=null,this.forcedShowSearch=!1,this.searchGeneration=0,this.blockFetchingNewer=!1,this.fetchingNewer=!1}willUpdate(t){if(super.willUpdate(t),t.has("data")&&(this.currentContact=this.data),t.has("currentContact")&&this.currentContact){const e=t.get("currentContact");this.currentContact.uuid!==(null==e?void 0:e.uuid)&&(this.blockFetching=!1,this.errorMessage=null)}}firstUpdated(t){super.firstUpdated(t)}connectedCallback(){super.connectedCallback(),this.chat=this.shadowRoot.querySelector("temba-chat"),this.tryPendingSearch(),this.updateSubscriptions(),this.stateRefresh=window.setInterval(()=>this.requestUpdate(),6e4)}disconnectedCallback(){super.disconnectedCallback(),this.stopTyping(),this.unsubscribeAll(),window.clearInterval(this.stateRefresh),this.stateRefresh=null}updated(t){var e;super.updated(t),(t.has("currentContact")||t.has("currentTicket"))&&this.updateSubscriptions(),t.has("currentContact")&&this.currentContact&&(this.chat=this.shadowRoot.querySelector("temba-chat"),this.currentContact.uuid!==(null===(e=t.get("currentContact"))||void 0===e?void 0:e.uuid)?this.reset():this.fetchMissedEvents(),this.fetchPreviousMessages(),this.tryPendingSearch())}unsubscribeAll(){this.subscriptions.forEach(t=>t.unsubscribe()),this.subscriptions.clear()}updateSubscriptions(){const t=new Map;if(this.isConnected&&this.currentContact){const e=this.currentContact.uuid;t.set(e,{contact:e,ticket:null});const i=this.contact&&this.contact!==e;this.currentTicket&&!i&&t.set(`${e}:${this.currentTicket.uuid}`,{contact:e,ticket:this.currentTicket.uuid})}this.subscriptions.forEach((e,i)=>{t.has(i)||(e.unsubscribe(),this.subscriptions.delete(i))}),t.forEach((t,e)=>{this.subscriptions.has(e)||this.subscriptions.set(e,t.ticket?Rs(t.contact,t.ticket,t=>this.handleSocketEvent(t),()=>this.fetchMissedEvents()):Ru(t.contact,"*",t=>this.handleSocketEvent(t),()=>this.fetchMissedEvents()))})}handleSocketEvent(t){if(!this.currentContact)return;if(t.type===du.CONTACT_LAST_SEEN_CHANGED||t.type===du.CONTACT_FLOW_CHANGED)return void this.handleContactStateEvent(t);if(!this.chat||this.searchMode)return;if(t.type===du.TYPING_STARTED||t.type===du.TYPING_STOPPED)return void this.handleTypingEvent(t);const e=this.createMessages({events:[this.copyWireEvent(t)],next:null});e.length>0&&this.chat.addMessages(e,null,!0)}handleContactStateEvent(t){((t,e)=>{const i=Tu[e.type];if(t&&i)i(t,e)})(this.currentContact,t),this.requestUpdate()}getLastSeen(){var t;const e=null===(t=this.currentContact)||void 0===t?void 0:t.last_seen_on;if(!e||!this.store)return null;const i=ed.fromISO(e);if(!i.isValid||i.year<=1)return null;return ed.now().diff(i,"minutes").minutes<60?null:{duration:this.store.getShortDuration(i),title:i.toLocaleString(ed.DATETIME_SHORT)}}handleTypingEvent(t){if(t._user&&this.userUuid&&t._user.uuid===this.userUuid)return;const e={...this.copyWireEvent(t),created_on:new Date(t.created_on)};this.resolveUserAvatar(e),t.type===du.TYPING_STARTED?this.chat.setTyping(e):this.chat.clearTyping(e)}handleComposeChanged(t){const e=Object.values(t.detail||{}).some(t=>{var e;return null===(e=null==t?void 0:t.text)||void 0===e?void 0:e.trim()});e?this.startTyping():this.stopTyping()}getTypingPayload(t){const e={type:t};return this.lastIncomingMsgExternalId&&(e.msg_external_id=this.lastIncomingMsgExternalId),e}startTyping(){this.typingDisabled||this.typingPulse||!this.currentContact||(this.typingChannel=`history:${this.currentContact.uuid}`,this.sendTypingPulse(),this.typingPulse=window.setInterval(()=>this.sendTypingPulse(),4e3))}sendTypingPulse(){if(!this.typingChannel)return;const t=this.typingChannel;zs(t,this.getTypingPayload("typing_started")).catch(e=>{!(null==e?void 0:e.temporary)&&this.isCurrentTypingChannel(t)&&(this.typingDisabled=!0,this.clearTypingPulse())})}isCurrentTypingChannel(t){var e;return t===`history:${null===(e=this.currentContact)||void 0===e?void 0:e.uuid}`}clearTypingPulse(){this.typingPulse&&(window.clearInterval(this.typingPulse),this.typingPulse=null),this.typingChannel=null}stopTyping(){if(!this.typingPulse)return;const t=this.typingChannel;this.clearTypingPulse(),zs(t,this.getTypingPayload("typing_stopped")).catch(e=>{!(null==e?void 0:e.temporary)&&this.isCurrentTypingChannel(t)&&(this.typingDisabled=!0)})}reset(){this.chat&&this.chat.reset(),this.ticket=null,this.beforeUUID=null,this.afterUUID=null,this.fetchingMissed=!1,this.stopTyping(),this.typingDisabled=!1,this.lastIncomingMsgOn=null,this.lastIncomingMsgExternalId=null;const t=this.shadowRoot.querySelector("temba-compose");t&&t.reset()}resetSearchState(t="",e=!1){this.searchQuery=t,this.searchResults=[],this.searchIndex=-1,this.searchLoading=!1,this.searchNoResults=!1,e&&(this.lastSearchedQuery="")}focusSearchInput(){window.setTimeout(()=>{const t=this.shadowRoot.querySelector(".search-input");t&&t.focus()},50)}handleSearchToggle(){this.pendingSearch=null,this.searchMode?this.handleSearchClose():(this.searchMode=!0,this.resetSearchState(),this.focusSearchInput())}restoreUnsearchedView(){const t=this.chat;t&&(t.searchHighlight=null,t.highlightMessageUuid=null,t.reset(),this.blockFetching=!1,this.blockFetchingNewer=!1,this.fetchingNewer=!1,this.beforeUUID=null,this.afterUUID=null,this.fetchPreviousMessages())}handleSearchClose(){this.searchGeneration++,this.pendingSearch=null,this.searchClosing=!0,window.setTimeout(()=>{this.searchClosing=!1,this.searchMode=!1,this.forcedShowSearch&&(this.forcedShowSearch=!1,this.showSearch=!1),this.resetSearchState("",!0),this.restoreUnsearchedView()},150)}handleSearchInput(t){const e=t.target;if(this.searchQuery=e.value,this.pendingSearch=null,this.searchQuery.trim()!==this.lastSearchedQuery){const t=""!==this.lastSearchedQuery;this.searchGeneration++,this.searchResults=[],this.searchIndex=-1,this.searchNoResults=!1,this.lastSearchedQuery="",t&&this.restoreUnsearchedView()}}startSearch(t,e=null){t&&t.trim()&&(this.searchMode=!0,this.showSearch||(this.showSearch=!0,this.forcedShowSearch=!0),this.resetSearchState(t,!0),this.pendingSearch={query:t.trim(),event:e,contactUuid:this.contact},this.focusSearchInput(),this.tryPendingSearch())}tryPendingSearch(){const t=this.pendingSearch;t&&this.currentContact&&this.chat&&(t.contactUuid&&t.contactUuid!==this.currentContact.uuid?t.contactUuid!==this.contact&&(this.pendingSearch=null):(this.searchQuery=t.query,this.executeSearch(t.event)&&(this.pendingSearch=null)))}handleSearchKeydown(t){if("Enter"===t.key){t.preventDefault();this.searchQuery.trim()!==this.lastSearchedQuery?this.executeSearch():t.shiftKey?this.handleSearchPrev():this.handleSearchNext()}else"Escape"===t.key&&(this.handleSearchClose(),t.preventDefault())}executeSearch(t=null){const e=this.searchQuery.trim();if(!e||!this.currentContact||this.searchLoading)return!1;this.searchGeneration++,this.searchLoading=!0,this.searchResults=[],this.searchIndex=-1,this.searchNoResults=!1,this.lastSearchedQuery=e,this.chat&&(this.chat.searchHighlight=null,this.chat.highlightMessageUuid=null,this.chat.reset());let i=`/contact/chat_search/${this.currentContact.uuid}/?text=${encodeURIComponent(e)}`;return this.currentTicket&&(i+=`&ticket=${encodeURIComponent(this.currentTicket.uuid)}`),fe(i).then(i=>{if(this.searchLoading=!1,this.lastSearchedQuery!==e||!this.searchMode)return;const o=(i.json.results||[]).sort((t,e)=>e.uuid.toLowerCase().localeCompare(t.uuid.toLowerCase()));if(t&&!o.some(e=>e.uuid===t.uuid)){const e=o.findIndex(e=>e.uuid.toLowerCase().localeCompare(t.uuid.toLowerCase())<0);o.splice(-1===e?o.length:e,0,t)}if(this.searchResults=o,this.searchResults.length>0){this.searchNoResults=!1;const e=t?this.searchResults.findIndex(e=>e.uuid===t.uuid):-1,i=-1!==e?e:0;this.searchIndex=i,this.navigateToResult(i)}else this.searchNoResults=!0,this.searchIndex=-1}).catch(()=>{this.searchLoading=!1,this.lastSearchedQuery===e&&this.searchMode&&(this.searchResults=[],this.searchIndex=-1,this.searchNoResults=!1)}),!0}navigateToResult(t){var e,i;if(t<0||t>=this.searchResults.length)return;this.searchIndex=t;const o=this.searchResults[t];if(!this.chat)return;const s=this.getEndpoint();if(!s)return;const n=this.searchGeneration,r=()=>n!==this.searchGeneration;this.chat.searchHighlight=this.lastSearchedQuery;const a=rp(s,null===(e=this.currentTicket)||void 0===e?void 0:e.uuid,o.uuid,null),l=rp(s,null===(i=this.currentTicket)||void 0===i?void 0:i.uuid,null,o.uuid);this.chat.style.opacity="0",window.setTimeout(()=>{if(r())return void(this.chat.style.opacity="1");this.chat.style.visibility="hidden",this.chat.reset(),this.blockFetching=!1,this.blockFetchingNewer=!1,this.fetchingNewer=!1,this.beforeUUID=null,this.afterUUID=null;const t={...o,created_on:new Date(o.created_on)};let e=!1;Promise.all([a,l]).then(([i,s])=>{if(r())return;const n=this.createMessages(s);n.reverse();const a=this.createMessages(i);a.reverse();const l={events:[t],next:null},d=this.createMessages(l);if(d.reverse(),i.next)this.beforeUUID=i.next;else if(a.length>0){const t=i.events[i.events.length-1];this.beforeUUID=t.uuid}else{this.blockFetching=!0;const t=[...n,...d];if(t.length>0){const e=t[t.length-1];this.chat.setEndOfHistory(new Date(e.created_on))}}const c=[...a,...d,...n];this.chat.loadMessages(c),e=!0,this.chat.updateComplete.then(()=>{window.setTimeout(()=>{var t,e;if(!this.chat)return;if(r())return this.chat.style.visibility="visible",void(this.chat.style.opacity="1");this.chat.highlightMessageUuid=o.uuid;const i=null===(t=this.chat.shadowRoot)||void 0===t?void 0:t.querySelector(".scroll"),s=null===(e=this.chat.shadowRoot)||void 0===e?void 0:e.querySelector(`.row[data-uuid="${o.uuid}"]`);if(i&&s){const t=i.getBoundingClientRect(),e=s.getBoundingClientRect(),o=e.top+e.height/2-(t.top+t.height/2);i.scrollTop=i.scrollTop+o}else i&&(i.scrollTop=0);window.setTimeout(()=>{this.chat&&(this.chat.style.visibility="visible",this.chat.style.opacity="0",window.setTimeout(()=>{this.chat&&(this.chat.style.opacity="1")},16))},16)},16)})}).catch(()=>{r()||(this.blockFetching=!1,this.blockFetchingNewer=!1,this.fetchingNewer=!1,this.beforeUUID=null,this.afterUUID=null,this.fetchPreviousMessages())}).finally(()=>{!e&&this.chat&&(this.chat.style.visibility="visible",this.chat.style.opacity="1")})},120)}handleSearchPrev(){if(0===this.searchResults.length)return;const t=this.searchIndex<=0?this.searchResults.length-1:this.searchIndex-1;this.navigateToResult(t)}handleSearchNext(){if(0===this.searchResults.length)return;const t=this.searchIndex>=this.searchResults.length-1?0:this.searchIndex+1;this.navigateToResult(t)}handleInterrupt(){this.fireCustomEvent(jo.Interrupt,{contact:this.currentContact})}handleRetry(){this.shadowRoot.querySelector("temba-compose").triggerSend()}handleSend(t){this.errorMessage=null;const e=t.currentTarget,i=t.detail.langValues.und,o={contact:this.currentContact.uuid},s=i.text;s&&s.length>0&&(o.text=s);const n=i.attachments;if(n&&n.length>0){const t=n.map(t=>t.uuid);o.attachments=t}this.currentTicket&&(o.ticket=this.currentTicket.uuid);const r="Send failed, please try again.";ke(`/contact/chat/${this.currentContact.uuid}/`,o).then(t=>{if(t.status<400){const i=t.json.event;i.created_on=new Date(i.created_on),this.resolveUserAvatar(i),this.chat.addMessages([i],null,!0),e.reset(),this.fireCustomEvent(jo.MessageSent,{msg:o,response:t})}else this.errorMessage=r}).catch(()=>{this.errorMessage=r})}getEndpoint(){return this.contact?`/contact/chat/${this.contact}/`:null}prerender(t){const e=Cu(t,!1);e&&(t._rendered={html:e,type:Xu.Inline})}copyWireEvent(t){const e={...t};return e._user&&(e._user={...e._user}),e.assignee&&(e.assignee={...e.assignee}),e}resolveUserAvatar(t){for(const e of[t._user,t.assignee])e&&e.uuid&&this.store&&(e.avatar?this.store.setUserAvatar(e.uuid,e.avatar):e.avatar=this.store.getUserAvatar(e.uuid))}createMessages(t){if(t.events){const e=[];return t.events.forEach(t=>{var i;this.resolveUserAvatar(t),(!this.afterUUID||t.uuid.toLowerCase()>this.afterUUID.toLowerCase())&&(this.afterUUID=t.uuid),t.created_on=new Date(t.created_on),"msg_received"===t.type&&(!this.lastIncomingMsgOn||t.created_on>this.lastIncomingMsgOn)&&(this.lastIncomingMsgOn=t.created_on,this.lastIncomingMsgExternalId=(null===(i=t.msg)||void 0===i?void 0:i.external_id)||null),"msg_created"===t.type||"msg_received"===t.type||"ivr_created"===t.type||"ticket_note_added"===t.type?e.push(t):(this.prerender(t),t._rendered&&e.push(t))}),e.filter(t=>!!t)}return[]}fetchMissedEvents(){var t;if(this.fetchingMissed||this.searchMode)return;const e=this.chat;if(this.currentContact&&this.afterUUID){this.fetchingMissed=!0;const i=this.getEndpoint();if(!i)return void(this.fetchingMissed=!1);const o=this.currentContact.uuid,s=null===(t=this.currentTicket)||void 0===t?void 0:t.uuid;rp(i,s,null,this.afterUUID).then(t=>{var i,n;if(this.fetchingMissed=!1,this.searchMode||o!==(null===(i=this.currentContact)||void 0===i?void 0:i.uuid)||s!==(null===(n=this.currentTicket)||void 0===n?void 0:n.uuid))return;const r=this.createMessages(t);r.reverse(),e.addMessages(r,null,!0)})}}fetchPreviousMessages(){var t;const e=this.chat,i=this;if(e&&!e.fetching&&!i.blockFetching&&(e.fetching=!0,this.currentContact)){const o=this.getEndpoint();if(!o)return void(e.fetching=!1);if(!this.beforeUUID&&!this.afterUUID){const t=Jt();this.beforeUUID=t,this.afterUUID=t}const s=this.beforeUUID;rp(o,null===(t=this.currentTicket)||void 0===t?void 0:t.uuid,this.beforeUUID,null).then(t=>{if(this.beforeUUID!==s)return void(e.fetching=!1);const o=this.createMessages(t);if(o.reverse(),0===o.length)i.blockFetching=!0;else if(t.next)this.beforeUUID=t.next;else if(i.blockFetching=!0,t.events&&t.events.length>0){const i=t.events[t.events.length-1];e.setEndOfHistory(new Date(i.created_on))}e.addMessages(o)})}}fetchComplete(){this.chat&&(this.chat.fetching=!1),this.fetchingNewer=!1}fetchNewerMessages(){var t;if(!this.searchMode||!this.afterUUID||!this.chat||this.fetchingNewer||this.blockFetchingNewer)return;this.fetchingNewer=!0;const e=this.getEndpoint();e?rp(e,null===(t=this.currentTicket)||void 0===t?void 0:t.uuid,null,this.afterUUID).then(t=>{if(!this.chat)return void(this.fetchingNewer=!1);const e=this.createMessages(t);if(e.reverse(),0===e.length)return this.blockFetchingNewer=!0,void(this.fetchingNewer=!1);this.chat.addMessages(e,null,!0,!0)}).catch(()=>{this.fetchingNewer=!1}):this.fetchingNewer=!1}getTembaCompose(){return this.currentTicket?this.currentContact&&"active"!==this.currentContact.status||this.currentTicket.closed_on?null:!this.disableReply||this.currentTicket.assignee&&this.currentTicket.assignee.email===this.agent?this.getCompose():null:this.currentContact&&"active"!==this.currentContact.status?null:this.getCompose()}getCompose(){return G`<div class="chat-box">
|
|
4641
|
+
`}set showMessageLogsAfter(t){const e=this._showMessageLogsAfter;this._showMessageLogsAfter=t?new Date(t):null,this.requestUpdate("showMessageLogsAfter",e)}get showMessageLogsAfter(){return this._showMessageLogsAfter}constructor(){super(),this.watchTypes=null,this.contactsEndpoint="/api/v2/contacts.json",this.currentNote="",this.showDetails=!0,this.currentTicket=null,this.currentContact=null,this.agent="",this.userUuid="",this.blockFetching=!1,this.showInterrupt=!1,this.disableAssign=!1,this.disableReply=!1,this.showSearch=!1,this.avatar=$d,this._showMessageLogsAfter=null,this.searchMode=!1,this.searchQuery="",this.searchResults=[],this.searchIndex=-1,this.searchLoading=!1,this.searchFocused=!1,this.searchClosing=!1,this.searchNoResults=!1,this.ticket=null,this.beforeUUID=null,this.afterUUID=null,this.subscriptions=new Map,this.fetchingMissed=!1,this.lastIncomingMsgOn=null,this.lastIncomingMsgExternalId=null,this.typingChannel=null,this.typingPulse=null,this.typingDisabled=!1,this.stateRefresh=null,this.lastSearchedQuery="",this.pendingSearch=null,this.forcedShowSearch=!1,this.searchGeneration=0,this.blockFetchingNewer=!1,this.fetchingNewer=!1}willUpdate(t){if(super.willUpdate(t),t.has("data")&&(this.currentContact=this.data),t.has("currentContact")&&this.currentContact){const e=t.get("currentContact");this.currentContact.uuid!==(null==e?void 0:e.uuid)&&(this.blockFetching=!1,this.errorMessage=null)}}firstUpdated(t){super.firstUpdated(t)}connectedCallback(){super.connectedCallback(),this.chat=this.shadowRoot.querySelector("temba-chat"),this.tryPendingSearch(),this.updateSubscriptions(),this.stateRefresh=window.setInterval(()=>this.requestUpdate(),6e4)}disconnectedCallback(){super.disconnectedCallback(),this.stopTyping(),this.unsubscribeAll(),window.clearInterval(this.stateRefresh),this.stateRefresh=null}updated(t){var e;super.updated(t),(t.has("currentContact")||t.has("currentTicket"))&&this.updateSubscriptions(),t.has("currentContact")&&this.currentContact&&(this.chat=this.shadowRoot.querySelector("temba-chat"),this.currentContact.uuid!==(null===(e=t.get("currentContact"))||void 0===e?void 0:e.uuid)?this.reset():this.fetchMissedEvents(),this.fetchPreviousMessages(),this.tryPendingSearch())}unsubscribeAll(){this.subscriptions.forEach(t=>t.unsubscribe()),this.subscriptions.clear()}updateSubscriptions(){const t=new Map;if(this.isConnected&&this.currentContact){const e=this.currentContact.uuid;t.set(e,{contact:e,ticket:null});const i=this.contact&&this.contact!==e;this.currentTicket&&!i&&t.set(`${e}:${this.currentTicket.uuid}`,{contact:e,ticket:this.currentTicket.uuid})}this.subscriptions.forEach((e,i)=>{t.has(i)||(e.unsubscribe(),this.subscriptions.delete(i))}),t.forEach((t,e)=>{this.subscriptions.has(e)||this.subscriptions.set(e,t.ticket?Rs(t.contact,t.ticket,t=>this.handleSocketEvent(t),()=>this.fetchMissedEvents()):Ru(t.contact,"*",t=>this.handleSocketEvent(t),()=>this.fetchMissedEvents()))})}handleSocketEvent(t){if(!this.currentContact)return;if(t.type===du.CONTACT_LAST_SEEN_CHANGED||t.type===du.CONTACT_FLOW_CHANGED)return void this.handleContactStateEvent(t);if(!this.chat||this.searchMode)return;if(t.type===du.TYPING_STARTED||t.type===du.TYPING_STOPPED)return void this.handleTypingEvent(t);const e=this.createMessages({events:[this.copyWireEvent(t)],next:null});e.length>0&&this.chat.addMessages(e,null,!0)}handleContactStateEvent(t){((t,e)=>{const i=Tu[e.type];if(t&&i)i(t,e)})(this.currentContact,t),this.requestUpdate()}getLastSeen(){var t;const e=null===(t=this.currentContact)||void 0===t?void 0:t.last_seen_on;if(!e||!this.store)return null;const i=ed.fromISO(e);if(!i.isValid||i.year<=1)return null;return ed.now().diff(i,"minutes").minutes<60?null:{duration:this.store.getShortDuration(i),title:i.toLocaleString(ed.DATETIME_SHORT)}}handleTypingEvent(t){if(t._user&&this.userUuid&&t._user.uuid===this.userUuid)return;const e={...this.copyWireEvent(t),created_on:new Date(t.created_on)};this.resolveUserAvatar(e),t.type===du.TYPING_STARTED?this.chat.setTyping(e):this.chat.clearTyping(e)}handleComposeChanged(t){const e=Object.values(t.detail||{}).some(t=>{var e;return null===(e=null==t?void 0:t.text)||void 0===e?void 0:e.trim()});e?this.startTyping():this.stopTyping()}getTypingPayload(t){const e={type:t};return this.lastIncomingMsgExternalId&&(e.msg_external_id=this.lastIncomingMsgExternalId),e}startTyping(){this.typingDisabled||this.typingPulse||!this.currentContact||(this.typingChannel=`history:${this.currentContact.uuid}`,this.sendTypingPulse(),this.typingPulse=window.setInterval(()=>this.sendTypingPulse(),4e3))}sendTypingPulse(){if(!this.typingChannel)return;const t=this.typingChannel;zs(t,this.getTypingPayload("typing_started")).catch(e=>{!(null==e?void 0:e.temporary)&&this.isCurrentTypingChannel(t)&&(this.typingDisabled=!0,this.clearTypingPulse())})}isCurrentTypingChannel(t){var e;return t===`history:${null===(e=this.currentContact)||void 0===e?void 0:e.uuid}`}clearTypingPulse(){this.typingPulse&&(window.clearInterval(this.typingPulse),this.typingPulse=null),this.typingChannel=null}stopTyping(){if(!this.typingPulse)return;const t=this.typingChannel;this.clearTypingPulse(),zs(t,this.getTypingPayload("typing_stopped")).catch(e=>{!(null==e?void 0:e.temporary)&&this.isCurrentTypingChannel(t)&&(this.typingDisabled=!0)})}reset(){this.chat&&this.chat.reset(),this.ticket=null,this.beforeUUID=null,this.afterUUID=null,this.fetchingMissed=!1,this.stopTyping(),this.typingDisabled=!1,this.lastIncomingMsgOn=null,this.lastIncomingMsgExternalId=null;const t=this.shadowRoot.querySelector("temba-compose");t&&t.reset()}resetSearchState(t="",e=!1){this.searchQuery=t,this.searchResults=[],this.searchIndex=-1,this.searchLoading=!1,this.searchNoResults=!1,e&&(this.lastSearchedQuery="")}focusSearchInput(){window.setTimeout(()=>{const t=this.shadowRoot.querySelector(".search-input");t&&t.focus()},50)}handleSearchToggle(){this.pendingSearch=null,this.searchMode?this.handleSearchClose():(this.searchMode=!0,this.resetSearchState(),this.focusSearchInput())}restoreUnsearchedView(){const t=this.chat;t&&(t.searchHighlight=null,t.highlightMessageUuid=null,t.reset(),this.blockFetching=!1,this.blockFetchingNewer=!1,this.fetchingNewer=!1,this.beforeUUID=null,this.afterUUID=null,this.fetchPreviousMessages())}handleSearchClose(){this.searchGeneration++,this.pendingSearch=null,this.searchClosing=!0,window.setTimeout(()=>{this.searchClosing=!1,this.searchMode=!1,this.forcedShowSearch&&(this.forcedShowSearch=!1,this.showSearch=!1),this.resetSearchState("",!0),this.restoreUnsearchedView()},150)}handleSearchInput(t){const e=t.target;if(this.searchQuery=e.value,this.pendingSearch=null,this.searchQuery.trim()!==this.lastSearchedQuery){const t=""!==this.lastSearchedQuery;this.searchGeneration++,this.searchResults=[],this.searchIndex=-1,this.searchNoResults=!1,this.lastSearchedQuery="",t&&this.restoreUnsearchedView()}}startSearch(t,e=null){t&&t.trim()&&(this.searchMode=!0,this.showSearch||(this.showSearch=!0,this.forcedShowSearch=!0),this.resetSearchState(t,!0),this.pendingSearch={query:t.trim(),event:e,contactUuid:this.contact},this.focusSearchInput(),this.tryPendingSearch())}tryPendingSearch(){const t=this.pendingSearch;t&&this.currentContact&&this.chat&&(t.contactUuid&&t.contactUuid!==this.currentContact.uuid?t.contactUuid!==this.contact&&(this.pendingSearch=null):(this.searchQuery=t.query,this.executeSearch(t.event)&&(this.pendingSearch=null)))}handleSearchKeydown(t){if("Enter"===t.key){t.preventDefault();this.searchQuery.trim()!==this.lastSearchedQuery?this.executeSearch():t.shiftKey?this.handleSearchPrev():this.handleSearchNext()}else"Escape"===t.key&&(this.handleSearchClose(),t.preventDefault())}executeSearch(t=null){const e=this.searchQuery.trim();if(!e||!this.currentContact||this.searchLoading)return!1;this.searchGeneration++,this.searchLoading=!0,this.searchResults=[],this.searchIndex=-1,this.searchNoResults=!1,this.lastSearchedQuery=e,this.chat&&(this.chat.searchHighlight=null,this.chat.highlightMessageUuid=null,this.chat.reset());const i=`/contact/chat_search/${this.currentContact.uuid}/?text=${encodeURIComponent(e)}`;return fe(i).then(i=>{if(this.searchLoading=!1,this.lastSearchedQuery!==e||!this.searchMode)return;const o=(i.json.results||[]).sort((t,e)=>e.uuid.toLowerCase().localeCompare(t.uuid.toLowerCase()));if(t&&!o.some(e=>e.uuid===t.uuid)){const e=o.findIndex(e=>e.uuid.toLowerCase().localeCompare(t.uuid.toLowerCase())<0);o.splice(-1===e?o.length:e,0,t)}if(this.searchResults=o,this.searchResults.length>0){this.searchNoResults=!1;const e=t?this.searchResults.findIndex(e=>e.uuid===t.uuid):-1,i=-1!==e?e:0;this.searchIndex=i,this.navigateToResult(i)}else this.searchNoResults=!0,this.searchIndex=-1}).catch(()=>{this.searchLoading=!1,this.lastSearchedQuery===e&&this.searchMode&&(this.searchResults=[],this.searchIndex=-1,this.searchNoResults=!1)}),!0}navigateToResult(t){var e,i;if(t<0||t>=this.searchResults.length)return;this.searchIndex=t;const o=this.searchResults[t];if(!this.chat)return;const s=this.getEndpoint();if(!s)return;const n=this.searchGeneration,r=()=>n!==this.searchGeneration;this.chat.searchHighlight=this.lastSearchedQuery;const a=rp(s,null===(e=this.currentTicket)||void 0===e?void 0:e.uuid,o.uuid,null),l=rp(s,null===(i=this.currentTicket)||void 0===i?void 0:i.uuid,null,o.uuid);this.chat.style.opacity="0",window.setTimeout(()=>{if(r())return void(this.chat.style.opacity="1");this.chat.style.visibility="hidden",this.chat.reset(),this.blockFetching=!1,this.blockFetchingNewer=!1,this.fetchingNewer=!1,this.beforeUUID=null,this.afterUUID=null;const t={...o,created_on:new Date(o.created_on)};let e=!1;Promise.all([a,l]).then(([i,s])=>{if(r())return;const n=this.createMessages(s);n.reverse();const a=this.createMessages(i);a.reverse();const l={events:[t],next:null},d=this.createMessages(l);if(d.reverse(),i.next)this.beforeUUID=i.next;else if(a.length>0){const t=i.events[i.events.length-1];this.beforeUUID=t.uuid}else{this.blockFetching=!0;const t=[...n,...d];if(t.length>0){const e=t[t.length-1];this.chat.setEndOfHistory(new Date(e.created_on))}}const c=[...a,...d,...n];this.chat.loadMessages(c),e=!0,this.chat.updateComplete.then(()=>{window.setTimeout(()=>{var t,e;if(!this.chat)return;if(r())return this.chat.style.visibility="visible",void(this.chat.style.opacity="1");this.chat.highlightMessageUuid=o.uuid;const i=null===(t=this.chat.shadowRoot)||void 0===t?void 0:t.querySelector(".scroll"),s=null===(e=this.chat.shadowRoot)||void 0===e?void 0:e.querySelector(`.row[data-uuid="${o.uuid}"]`);if(i&&s){const t=i.getBoundingClientRect(),e=s.getBoundingClientRect(),o=e.top+e.height/2-(t.top+t.height/2);i.scrollTop=i.scrollTop+o}else i&&(i.scrollTop=0);window.setTimeout(()=>{this.chat&&(this.chat.style.visibility="visible",this.chat.style.opacity="0",window.setTimeout(()=>{this.chat&&(this.chat.style.opacity="1")},16))},16)},16)})}).catch(()=>{r()||(this.blockFetching=!1,this.blockFetchingNewer=!1,this.fetchingNewer=!1,this.beforeUUID=null,this.afterUUID=null,this.fetchPreviousMessages())}).finally(()=>{!e&&this.chat&&(this.chat.style.visibility="visible",this.chat.style.opacity="1")})},120)}handleSearchPrev(){if(0===this.searchResults.length)return;const t=this.searchIndex<=0?this.searchResults.length-1:this.searchIndex-1;this.navigateToResult(t)}handleSearchNext(){if(0===this.searchResults.length)return;const t=this.searchIndex>=this.searchResults.length-1?0:this.searchIndex+1;this.navigateToResult(t)}handleInterrupt(){this.fireCustomEvent(jo.Interrupt,{contact:this.currentContact})}handleRetry(){this.shadowRoot.querySelector("temba-compose").triggerSend()}handleSend(t){this.errorMessage=null;const e=t.currentTarget,i=t.detail.langValues.und,o={contact:this.currentContact.uuid},s=i.text;s&&s.length>0&&(o.text=s);const n=i.attachments;if(n&&n.length>0){const t=n.map(t=>t.uuid);o.attachments=t}this.currentTicket&&(o.ticket=this.currentTicket.uuid);const r="Send failed, please try again.";ke(`/contact/chat/${this.currentContact.uuid}/`,o).then(t=>{if(t.status<400){const i=t.json.event;i.created_on=new Date(i.created_on),this.resolveUserAvatar(i),this.chat.addMessages([i],null,!0),e.reset(),this.fireCustomEvent(jo.MessageSent,{msg:o,response:t})}else this.errorMessage=r}).catch(()=>{this.errorMessage=r})}getEndpoint(){return this.contact?`/contact/chat/${this.contact}/`:null}prerender(t){const e=Cu(t,!1);e&&(t._rendered={html:e,type:Xu.Inline})}copyWireEvent(t){const e={...t};return e._user&&(e._user={...e._user}),e.assignee&&(e.assignee={...e.assignee}),e}resolveUserAvatar(t){for(const e of[t._user,t.assignee])e&&e.uuid&&this.store&&(e.avatar?this.store.setUserAvatar(e.uuid,e.avatar):e.avatar=this.store.getUserAvatar(e.uuid))}createMessages(t){if(t.events){const e=[];return t.events.forEach(t=>{var i;this.resolveUserAvatar(t),(!this.afterUUID||t.uuid.toLowerCase()>this.afterUUID.toLowerCase())&&(this.afterUUID=t.uuid),t.created_on=new Date(t.created_on),"msg_received"===t.type&&(!this.lastIncomingMsgOn||t.created_on>this.lastIncomingMsgOn)&&(this.lastIncomingMsgOn=t.created_on,this.lastIncomingMsgExternalId=(null===(i=t.msg)||void 0===i?void 0:i.external_id)||null),"msg_created"===t.type||"msg_received"===t.type||"ivr_created"===t.type||"ticket_note_added"===t.type?e.push(t):(this.prerender(t),t._rendered&&e.push(t))}),e.filter(t=>!!t)}return[]}fetchMissedEvents(){var t;if(this.fetchingMissed||this.searchMode)return;const e=this.chat;if(this.currentContact&&this.afterUUID){this.fetchingMissed=!0;const i=this.getEndpoint();if(!i)return void(this.fetchingMissed=!1);const o=this.currentContact.uuid,s=null===(t=this.currentTicket)||void 0===t?void 0:t.uuid;rp(i,s,null,this.afterUUID).then(t=>{var i,n;if(this.fetchingMissed=!1,this.searchMode||o!==(null===(i=this.currentContact)||void 0===i?void 0:i.uuid)||s!==(null===(n=this.currentTicket)||void 0===n?void 0:n.uuid))return;const r=this.createMessages(t);r.reverse(),e.addMessages(r,null,!0)})}}fetchPreviousMessages(){var t;const e=this.chat,i=this;if(e&&!e.fetching&&!i.blockFetching&&(e.fetching=!0,this.currentContact)){const o=this.getEndpoint();if(!o)return void(e.fetching=!1);if(!this.beforeUUID&&!this.afterUUID){const t=Jt();this.beforeUUID=t,this.afterUUID=t}const s=this.beforeUUID;rp(o,null===(t=this.currentTicket)||void 0===t?void 0:t.uuid,this.beforeUUID,null).then(t=>{if(this.beforeUUID!==s)return void(e.fetching=!1);const o=this.createMessages(t);if(o.reverse(),0===o.length)i.blockFetching=!0;else if(t.next)this.beforeUUID=t.next;else if(i.blockFetching=!0,t.events&&t.events.length>0){const i=t.events[t.events.length-1];e.setEndOfHistory(new Date(i.created_on))}e.addMessages(o)})}}fetchComplete(){this.chat&&(this.chat.fetching=!1),this.fetchingNewer=!1}fetchNewerMessages(){var t;if(!this.searchMode||!this.afterUUID||!this.chat||this.fetchingNewer||this.blockFetchingNewer)return;this.fetchingNewer=!0;const e=this.getEndpoint();e?rp(e,null===(t=this.currentTicket)||void 0===t?void 0:t.uuid,null,this.afterUUID).then(t=>{if(!this.chat)return void(this.fetchingNewer=!1);const e=this.createMessages(t);if(e.reverse(),0===e.length)return this.blockFetchingNewer=!0,void(this.fetchingNewer=!1);this.chat.addMessages(e,null,!0,!0)}).catch(()=>{this.fetchingNewer=!1}):this.fetchingNewer=!1}getTembaCompose(){return this.currentTicket?this.currentContact&&"active"!==this.currentContact.status||this.currentTicket.closed_on?null:!this.disableReply||this.currentTicket.assignee&&this.currentTicket.assignee.email===this.agent?this.getCompose():null:this.currentContact&&"active"!==this.currentContact.status?null:this.getCompose()}getCompose(){return G`<div class="chat-box">
|
|
4642
4642
|
<div class="compose">
|
|
4643
4643
|
<temba-compose
|
|
4644
4644
|
attachments
|
|
@@ -14539,7 +14539,7 @@ background: #ccc;
|
|
|
14539
14539
|
${this.renderUploader()}
|
|
14540
14540
|
</div>
|
|
14541
14541
|
</div>
|
|
14542
|
-
</div>`}}i([ft({type:String,attribute:!1})],Am.prototype,"endpoint",void 0),i([ft({type:Boolean})],Am.prototype,"pendingDrop",void 0),i([ft({type:Boolean})],Am.prototype,"ignoreDrops",void 0),i([ft({type:String})],Am.prototype,"icon",void 0),i([ft({type:String})],Am.prototype,"accept",void 0),i([ft({type:Number})],Am.prototype,"max",void 0),i([ft({type:Array})],Am.prototype,"attachments",void 0),i([ft({type:Boolean,attribute:!1})],Am.prototype,"uploading",void 0);let Dm="dev";try{Dm="0.173.
|
|
14542
|
+
</div>`}}i([ft({type:String,attribute:!1})],Am.prototype,"endpoint",void 0),i([ft({type:Boolean})],Am.prototype,"pendingDrop",void 0),i([ft({type:Boolean})],Am.prototype,"ignoreDrops",void 0),i([ft({type:String})],Am.prototype,"icon",void 0),i([ft({type:String})],Am.prototype,"accept",void 0),i([ft({type:Number})],Am.prototype,"max",void 0),i([ft({type:Array})],Am.prototype,"attachments",void 0),i([ft({type:Boolean,attribute:!1})],Am.prototype,"uploading",void 0);let Dm="dev";try{Dm="0.173.1"}catch(t){}const Mm=Dm,zm=[{type:"has_any_word",name:"has any of the words",operands:1},{type:"has_all_words",name:"has all of the words",operands:1},{type:"has_phrase",name:"has the phrase",operands:1},{type:"has_only_phrase",name:"has only the phrase",operands:1},{type:"has_beginning",name:"starts with",operands:1},{type:"has_text",name:"has some text",operands:0,categoryName:"Has Text"},{type:"has_number",name:"has a number",operands:0,categoryName:"Has Number"},{type:"has_number_between",name:"has a number between",operands:2},{type:"has_number_lt",name:"has a number below",operands:1},{type:"has_number_lte",name:"has a number at or below",operands:1},{type:"has_number_eq",name:"has a number equal to",operands:1},{type:"has_number_gte",name:"has a number at or above",operands:1},{type:"has_number_gt",name:"has a number above",operands:1},{type:"has_date",name:"has a date",operands:0,categoryName:"Has Date"},{type:"has_date_lt",name:"has a date before",operands:1},{type:"has_date_eq",name:"has a date equal to",operands:1},{type:"has_date_gt",name:"has a date after",operands:1},{type:"has_time",name:"has a time",operands:0,categoryName:"Has Time"},{type:"has_phone",name:"has a phone number",operands:0,categoryName:"Has Phone"},{type:"has_email",name:"has an email",operands:0,categoryName:"Has Email"},{type:"has_state",name:"has state",operands:0,categoryName:"Has State",filter:"locations"},{type:"has_district",name:"has district",operands:1,categoryName:"Has District",filter:"locations"},{type:"has_ward",name:"has ward",operands:2,categoryName:"Has Ward",filter:"locations"},{type:"has_group",name:"is in the group",operands:1,visibility:"hidden"},{type:"has_category",name:"has the category",operands:0,visibility:"hidden"},{type:"has_error",name:"has an error",operands:0,categoryName:"Has Error",visibility:"hidden"},{type:"has_value",name:"is not empty",operands:0,categoryName:"Not Empty",visibility:"hidden"},{type:"has_pattern",name:"matches regex",operands:1}],Pm=t=>zm.filter(e=>"hidden"!==e.visibility&&(!e.filter||!!t&&t.includes(e.filter))),Im=new Set(["has_beginning","has_number","has_number_between","has_number_lt","has_number_lte","has_number_eq","has_number_gte","has_number_gt","has_pattern"]),Om=t=>zm.find(e=>e.type===t),Rm=t=>t.map(t=>({value:t.type,name:t.name})),Lm={type:"text",required:!1,maxLength:64,placeholder:"(optional)",helpText:"The name to use to reference this result in the flow"},Nm={type:"checkbox",label:"Require rules to be localized",helpText:"Each language must specify its own rules for this node"},Fm={type:"checkbox",label:"Require categories to be localized",helpText:t=>{var e;const i=null===(e=t.result_name)||void 0===e?void 0:e.trim();if(i){return`Only enable if you plan to use @results.${i.toLowerCase().replace(/\s+/g,"_")}.category_localized`}return"Only enable if you plan to use category_localized in your expressions for this result"},conditions:{visible:t=>!!t.result_name}},Bm={label:"Save Result",localizable:!1,items:["result_name"],collapsed:t=>!(t._isNew&&t.result_name),getValueCount:t=>!!t.result_name},Um={type:"accordion",multi:!0,sections:[Bm,{label:"Localization",localizable:!1,items:["localizeRules","localizeCategories"],collapsed:!0,getValueCount:t=>!(!t.localizeRules&&!t.localizeCategories)}]},qm={type:"accordion",multi:!0,sections:[Bm]},Wm={type:"accordion",multi:!0,sections:[Bm,{label:"Localization",localizable:!1,items:["localizeCategories"],collapsed:!0,getValueCount:t=>!!t.localizeCategories}]};function jm(t,e){var i,o;const s=(null===(i=t.router)||void 0===i?void 0:i.categories)||[],n={};s.forEach(t=>{const i=t.uuid,o=e[i];n[i]={originalName:t.name,localizedName:o&&o.name?Array.isArray(o.name)?o.name[0]||"":o.name:""}});const r=(null===(o=t.router)||void 0===o?void 0:o.cases)||[],a={};return r.forEach(t=>{var i,o;if(!(null===(i=t.arguments)||void 0===i?void 0:i.length)||!t.arguments.some(t=>t))return;const s=e[t.uuid],n=(null===(o=Om(t.type))||void 0===o?void 0:o.name)||t.type;a[t.uuid]={operatorName:n,originalArguments:[...t.arguments],localizedArguments:(null==s?void 0:s.arguments)?[...s.arguments]:t.arguments.map(()=>"")}}),{categories:n,rules:a}}function Hm(t,e){const i={};return t.categories&&Object.keys(t.categories).forEach(e=>{var o,s;const n=t.categories[e],r=(null===(o=n.localizedName)||void 0===o?void 0:o.trim())||"",a=(null===(s=n.originalName)||void 0===s?void 0:s.trim())||"";r&&r!==a&&(i[e]={name:[r]})}),t.rules&&Object.keys(t.rules).forEach(e=>{const o=t.rules[e],s=o.localizedArguments||[],n=o.originalArguments||[],r=s.some((t,e)=>(null==t?void 0:t.trim())&&t.trim()!==(n[e]||""));r&&(i[e]={arguments:s.map(t=>(null==t?void 0:t.trim())||"")})}),i}function Vm(t,e,i,o=[]){const s=[],n=[],r=[];return t.forEach(t=>{const a=ae(e,t.name),l=a?i.find(t=>t.uuid===a.exit_uuid):null,d=(null==l?void 0:l.uuid)||Xt(),c=(null==a?void 0:a.uuid)||Xt();if(s.push({uuid:c,name:t.name,exit_uuid:d}),n.push({uuid:d,destination_uuid:(null==l?void 0:l.destination_uuid)||null}),t.case){const e=t.case.arguments[0],i=o.find(t=>{var i;return(null===(i=t.arguments)||void 0===i?void 0:i[0])===e});r.push({uuid:(null==i?void 0:i.uuid)||Xt(),type:t.case.type,arguments:t.case.arguments,category_uuid:c})}}),{categories:s,exits:n,cases:r}}function Gm(t,e,i,o,s){const n=s.some(t=>re(t,"Other"))?null:ae(i,"Other"),r=n?o.find(t=>t.uuid===n.exit_uuid):null,a=(null==r?void 0:r.uuid)||Xt(),l=(null==n?void 0:n.uuid)||Xt();return t.push({uuid:l,name:"Other",exit_uuid:a}),e.push({uuid:a,destination_uuid:(null==r?void 0:r.destination_uuid)||null}),l}function Km(t){return e=>{const i={};return t(e,i),{valid:0===Object.keys(i).length,errors:i}}}function Zm(t){const e=t.filter(t=>"contact"===t.type||!t.type&&!t.expression&&t.id),i=t.filter(t=>"group"===t.type),o=t.filter(t=>"expression"===t.type||t.expression);if(e.length>100)return"You can only add up to 100 contacts";if(i.length>100)return"You can only add up to 100 groups";if(o.length>100)return"You can only add up to 100 expressions";const s=o.some(t=>{const e=t.value||t.name||t.id||"";return"string"==typeof e&&e.length>1e3});return s?"Expressions must be no more than 1000 characters":null}function Ym(t){const e=t.some(t=>"string"==typeof t&&t.length>1e4);return e?"Template variables must be no more than 10000 characters":null}function Xm(t){return t.toLocalizationFormData?t.toLocalizationFormData:"categories"===t.localizable?jm:Array.isArray(t.localizable)?(e=t.localizable,(t,i)=>{const o={uuid:t.uuid};return e.forEach(t=>{const e=i[t];o[t]=Array.isArray(e)&&e[0]||""}),o}):void 0;var e}function Qm(t){return t.fromLocalizationFormData?t.fromLocalizationFormData:"categories"===t.localizable?Hm:Array.isArray(t.localizable)?(e=t.localizable,(t,i)=>{const o={};return e.forEach(e=>{const s=t[e];s&&""!==s.trim()&&s!==i[e]&&(o[e]=[s])}),o}):void 0;var e}const Jm="undefined"!=typeof navigator&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function tg(t){return 0!==t.button||!(!Jm||!t.ctrlKey)}function eg(t){if(t.dependency){const e=t.dependency.name||t.dependency.key;return`Cannot find a ${t.dependency.type} for ${e}`}return t.description}function ig(t){const e=20*Math.round(t/20);return Math.max(e,0)}const og="font-family:SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;font-size:0.95em",sg={[ch.ExpressionPrefix]:`color:${Dh.expression};font-weight:600;${og}`,[ch.Identifier]:`color:${Dh.expression};${og}`,[ch.FunctionName]:`color:${Dh.fn};font-weight:900;${og}`,[ch.StringLiteral]:`color:${Dh.string};${og}`,[ch.NumberLiteral]:`color:${Dh.number};${og}`,[ch.Keyword]:`color:${Dh.keyword};${og}`,[ch.Operator]:`color:${Dh.operator};${og}`,[ch.ContextRef]:`color:${Dh.expression};${og}`,[ch.Separator]:`color:${Dh.operator};${og}`,[ch.Arrow]:`color:${Dh.operator};${og}`,[ch.Bracket]:`color:${Dh.operator};${og}`,[ch.Paren]:`color:${Dh.paren};${og}`,[ch.Whitespace]:og},ng=[[/claude|anthropic/i,"anthropic"],[/gpt|openai|o1|o3|o4/i,"openai"],[/gemini|google/i,"gemini"],[/azure|microsoft/i,"azure"],[/deepseek/i,"deepseek"]],rg=(t,e=!1)=>{const i=fh(t||"",e?ih:eh),o=[];for(const t of i){const e=!!sg[t.type],i=o[o.length-1];i&&i.isExpr===e?i.tokens.push(t):o.push({isExpr:e,tokens:[t]})}const s=t=>{const e=sg[t.type];if(!e){const e=t.text.split("\n");return G`${e.map((t,e)=>G`${e>0?G`<br />`:null}${t}`)}`}const i=t.text.split("\n");return G`${i.map((t,i)=>G`${i>0?G`<br />`:null}${t?G`<span style="${e}">${t}</span>`:null}`)}`};return G`${o.map(t=>{const e=G`${t.tokens.map(s)}`;return t.isExpr?G`<span style="hyphens:none">${e}</span>`:e})}`},ag=(t,e,i=3)=>G`<div
|
|
14543
14543
|
style="display: -webkit-box; -webkit-line-clamp: ${i}; -webkit-box-orient: vertical; overflow: hidden; word-wrap: break-word; overflow-wrap: break-word; hyphens: auto;"
|
|
14544
14544
|
title="${e}"
|
|
14545
14545
|
>
|