function e(e,t){return`${e}:${t}`.toLowerCase()}function t(t,n,r){return{kind:t,id:n,raw:r,normalized:e(t,n)}}function n(e){if(!e.pattern.test(e.candidate))throw Error(e.errorMessage);return e.candidate}function r(e){let n=e.raw.match(e.mentionPattern);if(n?.[1])return t(e.kind,n[1],e.raw)}function i(e){if(!e.raw.startsWith(e.prefix))return;let n=e.raw.slice(e.prefix.length).trim();return n?t(e.kind,n,e.raw):void 0}function a(e){for(let t of e.prefixes){let n=i({raw:e.raw,prefix:t.prefix,kind:t.kind});if(n)return n}}function o(e){if(e.raw.startsWith(`@`))return t(`user`,n({candidate:e.raw.slice(1).trim(),pattern:e.pattern,errorMessage:e.errorMessage}),e.raw)}function s(e){return r({raw:e.raw,mentionPattern:e.mentionPattern,kind:`user`})||a({raw:e.raw,prefixes:e.prefixes})||o({raw:e.raw,pattern:e.atUserPattern,errorMessage:e.atUserErrorMessage})}function c(e){let t=e.kind;if(!e.target)throw Error(`${e.platform} ${t} id is required.`);if(e.target.kind!==e.kind)throw Error(`${e.platform} ${t} id is required (use ${t}:<id>).`);return e.target.id}export{c as i,n,s as r,t};
