import{c as e}from"./home-dir-C44RaPME-B5iLWwCq.mjs";import{r as t}from"./account-id-BM1T6029-BzQ_cMoi.mjs";import{n}from"./message-channel-core-DTA--Gjh-CIh10vfo.mjs";function r(e){return t(e)}function i(t){if(!t)return;let i=typeof t.channel==`string`?n(t.channel)??t.channel.trim():void 0,a=e(t.to),o=r(t.accountId),s=typeof t.threadId==`number`&&Number.isFinite(t.threadId)?Math.trunc(t.threadId):typeof t.threadId==`string`?e(t.threadId):void 0,c=typeof s==`string`?s||void 0:s;if(!i&&!a&&!o&&c==null)return;let l={channel:i||void 0,to:a||void 0,accountId:o};return c!=null&&(l.threadId=c),l}function a(e){if(!e)return{deliveryContext:void 0,lastChannel:void 0,lastTo:void 0,lastAccountId:void 0,lastThreadId:void 0};let t=o(i({channel:e.lastChannel??e.channel,to:e.lastTo,accountId:e.lastAccountId,threadId:e.lastThreadId}),i(e.deliveryContext));return t?{deliveryContext:t,lastChannel:t.channel,lastTo:t.to,lastAccountId:t.accountId,lastThreadId:t.threadId}:{deliveryContext:void 0,lastChannel:void 0,lastTo:void 0,lastAccountId:void 0,lastThreadId:void 0}}function o(e,t){let n=i(e),r=i(t);if(!n&&!r)return;let a=n?.channel&&r?.channel&&n.channel!==r.channel;return i({channel:n?.channel??r?.channel,to:a?n?.to:n?.to??r?.to,accountId:a?n?.accountId:n?.accountId??r?.accountId,threadId:a?n?.threadId:n?.threadId??r?.threadId})}function s(e){let t=i(e);if(!t?.channel||!t?.to)return;let n=t.threadId!=null&&t.threadId!==``?String(t.threadId):``;return`${t.channel}|${t.to}|${t.accountId??``}|${n}`}export{a as i,o as n,i as r,s as t};