@opencxh/domain 1.245.0 → 1.246.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entities/document-template/tokens.d.ts +8 -0
- package/dist/index.cjs +9 -9
- package/dist/index.js +403 -399
- package/package.json +1 -1
|
@@ -23,6 +23,14 @@ export declare function conditionHolds(condition: TemplateCondition | undefined,
|
|
|
23
23
|
export interface FillDocumentResult {
|
|
24
24
|
blocks: DocumentBlock[];
|
|
25
25
|
unresolved: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Slots the template had no placeholder for.
|
|
28
|
+
*
|
|
29
|
+
* A slot the caller computed and the template cannot place is **dropped**, and dropping a
|
|
30
|
+
* quote's totals without a word is how a document goes out missing its total. Reported here so
|
|
31
|
+
* the preview can say it and the issue gate can refuse it.
|
|
32
|
+
*/
|
|
33
|
+
unusedSlots: string[];
|
|
26
34
|
}
|
|
27
35
|
/**
|
|
28
36
|
* Blocks the caller computes, keyed by the `block_id` of the template block they replace.
|
package/dist/index.cjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ke=10,ee=10,te=10,ne=5,vo=new Set(["header","section","context","divider","image","list","actions","attachments"]);function Re(e){if(typeof e=="string")return e.length>0;if(!e||typeof e!="object")return!1;const t=e;return typeof t.key=="string"||typeof t.value=="string"}function Do(e,t=()=>{}){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(n.length>=Ke){t(`more than ${Ke} blocks; the rest was dropped`);break}if(!r||typeof r!="object")continue;const o=r;if(!vo.has(o.type)){t(`unknown block type ${String(o.type)}`);continue}switch(o.type){case"header":if(!Re(o.text)){t("a header without text");continue}break;case"context":if(!Re(o.text)){t("a context block without text");continue}break;case"image":if(!o.url||!o.alt){t("an image without url or alt");continue}break;case"section":Array.isArray(o.fields)&&o.fields.length>ee&&(t(`more than ${ee} fields in a section`),o.fields=o.fields.slice(0,ee));break;case"list":if(!Array.isArray(o.items)||o.items.length===0){t("a list without items");continue}o.items.length>te&&(t(`more than ${te} list items`),o.items=o.items.slice(0,te));break;case"actions":{const i=Array.isArray(o.elements)?o.elements:[],s=i.filter(a=>a?.action_id&&a.invoke&&Re(a.text));if(s.length!==i.length&&t("an action without action_id, invoke or text"),s.length===0)continue;s.length>ne&&t(`more than ${ne} actions`),o.elements=s.slice(0,ne);break}}n.push(o)}return n}const xo=/(\*\*|__)(?=\S)([\s\S]*?\S)\1/g,Lo=/(\*|_)(?=\S)([^*_\n]*?\S)\1/g;function Qt(e){if(typeof e!="string"||!e)return"";let t=e;return t=t.replace(/```[a-z]*\n?/gi,"").replace(/~~~[a-z]*\n?/gi,""),t=t.replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1"),t=t.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1"),t=t.replace(/\[([^\]]*)\]\[[^\]]*\]/g,"$1"),t=t.replace(/<((?:https?|mailto):[^>\s]+)>/gi,"$1"),t=t.split(`
|
|
2
2
|
`).map(n=>n.replace(/^\s{0,3}#{1,6}\s+/,"").replace(/^\s{0,3}>\s?/,"").replace(/^\s*[-*+]\s+/,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*(?:[-*_]\s*){3,}$/,"")).join(`
|
|
3
|
-
`),t=t.replace(xo,"$2"),t=t.replace(Lo,"$2"),t=t.replace(/~~(?=\S)([\s\S]*?\S)~~/g,"$1"),t=t.replace(/`([^`\n]+)`/g,"$1"),t.replace(/\s+/g," ").trim()}function Jt(e){return e.replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim()}function J(e){if(!e||e<0)return"";const t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${n.toString().padStart(2,"0")}`}function Tt(e){return e?` — ${Math.floor(e/60)}m ${e%60}s`:""}function ve(e){return e?.split("@")?.[0]||e||""}function Z(e){return e.map(t=>t.name).join(", ")}function It(e){return e==="meeting"?"Meeting":e==="video"?"Video call":"Audio call"}const D={VOICE_CALL_STARTED:{shape:"event",channelKind:"voice",icon:"phone",snippet:()=>"Gesprek gestart",timeline:e=>e.direction==="inbound"?`Inbound call started — ${ve(e.payload.from)}`:`Outbound call started — ${ve(e.payload.to)}`},VOICE_CALL_ANSWERED:{shape:"event",channelKind:"voice",icon:"phone",connected:!0,snippet:()=>"Gesprek aangenomen",timeline:(e,t)=>`Call answered — ${t}`},VOICE_CALL_HOLD:{shape:"event",channelKind:"voice",icon:"phone",snippet:()=>"In de wacht",timeline:(e,t)=>`Call on hold — ${t}`},VOICE_CALL_UNHOLD:{shape:"event",channelKind:"voice",icon:"phone",snippet:()=>"Hervat"},VOICE_CALL_ENDED:{shape:"event",channelKind:"voice",icon:"phone",snippet:e=>`Gesprek beëindigd${e.payload.duration?` (${J(e.payload.duration)})`:""}`,timeline:e=>`Call ended${Tt(e.payload.duration)}`},VOICE_CALL_MISSED:{shape:"event",channelKind:"voice",icon:"phone",snippet:()=>"Gemiste oproep",timeline:e=>`Missed call — ${ve(e.payload.from)}`},VOICE_CALL_FAILED:{shape:"event",channelKind:"voice",icon:"phone",snippet:()=>"Gesprek mislukt",timeline:()=>"Call failed"},VOICE_CALL_VOICEMAIL:{shape:"artifact",channelKind:"voice",icon:"phone",snippet:e=>e.payload.transcription?.trim()?e.payload.transcription:"Voicemail ontvangen"},VIDEO_CALL_STARTED:{shape:"event",channelKind:"video",icon:"video",snippet:()=>"Gesprek gestart",timeline:()=>"Video call started"},VIDEO_CALL_ANSWERED:{shape:"event",channelKind:"video",icon:"video",connected:!0,snippet:()=>"Gesprek aangenomen",timeline:()=>"Video call answered"},VIDEO_CALL_HOLD:{shape:"event",channelKind:"video",icon:"video",snippet:()=>"In de wacht"},VIDEO_CALL_UNHOLD:{shape:"event",channelKind:"video",icon:"video",snippet:()=>"Hervat"},VIDEO_CALL_ENDED:{shape:"event",channelKind:"video",icon:"video",snippet:e=>`Gesprek beëindigd${e.payload.duration?` (${J(e.payload.duration)})`:""}`,timeline:()=>"Video call ended"},VIDEO_CALL_MISSED:{shape:"event",channelKind:"video",icon:"video",snippet:()=>"Gemiste oproep",timeline:()=>"Missed video call"},VIDEO_CALL_FAILED:{shape:"event",channelKind:"video",icon:"video",snippet:()=>"Gesprek mislukt",timeline:()=>"Video call failed"},EMAIL_RECEIVED:{shape:"message",triggerable:!0,displayNameKey:"communication:activity.EMAIL_RECEIVED",component:"communication:EmailActivity",channelKind:"mail",icon:"mail",replyable:!0,carriesText:!0,countsAs:"inbound_message",snippet:Ot},EMAIL_SENT:{shape:"message",component:"communication:EmailActivity",channelKind:"mail",icon:"mail",replyable:!0,carriesText:!0,countsAs:"outbound_message",snippet:Ot},CHAT_MESSAGE_SENT:{shape:"message",component:"communication:ChatMessage",channelKind:"chat",icon:"message-circle",replyable:!0,carriesText:!0,countsAs:"outbound_message",snippet:e=>e.payload.text??""},CHAT_MESSAGE_RECEIVED:{shape:"message",triggerable:!0,displayNameKey:"communication:activity.CHAT_MESSAGE_RECEIVED",component:"communication:ChatMessage",channelKind:"chat",icon:"message-circle",replyable:!0,carriesText:!0,countsAs:"inbound_message",snippet:e=>e.payload.text??""},CHAT_MEMBER_JOINED:{shape:"event",channelKind:"chat",icon:"message-circle",snippet:e=>`${Z(e.payload.members)} toegevoegd`,timeline:e=>{const t=Z(e.payload.members)||"Someone",n=e.payload.initiator?.name?` · added by ${e.payload.initiator.name}`:"";return`${t} joined the chat${n}`}},CHAT_MEMBER_LEFT:{shape:"event",channelKind:"chat",icon:"message-circle",snippet:e=>`${Z(e.payload.members)} verlaten`,timeline:e=>{const t=Z(e.payload.members)||"Someone",n=e.payload.initiator?.name?` · removed by ${e.payload.initiator.name}`:"";return`${t} left the chat${n}`}},CHAT_RENAMED:{shape:"event",channelKind:"chat",icon:"message-circle",snippet:e=>`Hernoemd naar "${e.payload.newName}"`,timeline:e=>`Chat renamed to "${e.payload.newName}"${e.payload.initiator?` by ${e.payload.initiator.name}`:""}`},CHAT_CALL_STARTED:{shape:"event",channelKind:"chat",icon:"message-circle",snippet:()=>"Gesprek gestart",timeline:e=>`${It(e.payload.callType)} started${e.payload.initiator?` by ${e.payload.initiator.name}`:""}`,joinUrl:e=>e.payload.joinUrl},CHAT_CALL_ENDED:{shape:"event",channelKind:"chat",icon:"message-circle",snippet:e=>`Gesprek beëindigd${e.payload.duration?` (${J(e.payload.duration)})`:""}`,timeline:e=>`${It(e.payload.callType)} ended${Tt(e.payload.duration)}`,joinUrl:e=>e.payload.joinUrl},CHAT_EVENT:{shape:"event",channelKind:"chat",icon:"message-circle",snippet:e=>e.payload.text??e.payload.eventType,timeline:e=>e.payload.text||e.payload.eventType},TRANSCRIPT_ADDED:{shape:"artifact",triggerable:!0,displayNameKey:"communication:activity.TRANSCRIPT_ADDED",component:"communication:TranscriptionActivity",icon:"captions",carriesText:!0,snippet:e=>(e.payload.segments??[]).map(t=>t.text).join(" ")},COMMENT_ADDED:{shape:"note",component:"communication:CommentActivity",icon:"sticky-note",carriesText:!0,snippet:e=>e.payload.text??""},FILE_UPLOADED:{shape:"artifact",component:"communication:FileActivity",icon:"paperclip",snippet:e=>`Bestand: ${e.payload.fileName}`},AI_MESSAGE_ADDED:{shape:"event",triggerable:!0,displayNameKey:"communication:activity.AI_MESSAGE_ADDED",icon:"circle",snippet:e=>e.payload.output?.text??e.payload.input?.text??"",timeline:()=>"AI message added"},AI_ACTION_PROPOSED:{shape:"event",component:"communication:ProposedActionCard",icon:"circle",playbookAuthored:!0,snippet:e=>`Voorstel wacht op goedkeuring (${e.payload.actions?.length??0} actie(s))`},PLAYBOOK_STARTED:{shape:"event",icon:"circle",playbookAuthored:!0,snippet:e=>`Playbook gestart${e.payload.playbookName?`: ${e.payload.playbookName}`:""}`,timeline:e=>`Playbook gestart${e.payload.playbookName?` — ${e.payload.playbookName}`:""}`},PLAYBOOK_COMPLETED:{shape:"event",icon:"circle",playbookAuthored:!0,snippet:()=>"Playbook afgerond",timeline:()=>"Playbook afgerond"},PLAYBOOK_ESCALATED:{shape:"event",icon:"circle",playbookAuthored:!0,snippet:()=>"Playbook geëscaleerd naar een mens",timeline:()=>"Playbook geëscaleerd naar een mens"},MEETING_SCHEDULED:{shape:"event",icon:"calendar",snippet:e=>`Vergadering gepland: ${e.payload.title}`,timeline:()=>"Meeting scheduled",joinUrl:e=>e.payload.joinUrl},MEETING_STARTED:{shape:"event",icon:"calendar",connected:!0,snippet:e=>`Vergadering gestart: ${e.payload.title}`,timeline:()=>"Meeting started",joinUrl:e=>e.payload.joinUrl},MEETING_ENDED:{shape:"event",icon:"calendar",snippet:e=>`Vergadering beëindigd${e.payload.duration?` (${J(e.payload.duration)})`:""}`,timeline:()=>"Meeting ended"},MEETING_PARTICIPANT_JOINED:{shape:"event",icon:"calendar",snippet:e=>`${e.payload.name} deelgenomen`,timeline:(e,t)=>`${t} joined the meeting`},MEETING_PARTICIPANT_LEFT:{shape:"event",icon:"calendar",snippet:e=>`${e.payload.name} verlaten`,timeline:(e,t)=>`${t} left the meeting`},INTERACTION_CREATED:{shape:"event",icon:"circle",snippet:()=>"Interactie aangemaakt",timeline:(e,t)=>`Interaction started by ${t}`},INTERACTION_STATUS_CHANGED:{shape:"event",triggerable:!0,displayNameKey:"communication:activity.INTERACTION_STATUS_CHANGED",icon:"circle-dot",snippet:e=>`Status: ${e.payload.fromStatus} → ${e.payload.toStatus}`,timeline:(e,t)=>`Status changed to ${e.payload.toStatus} by ${t}`},INTERACTION_ASSIGNED:{shape:"event",icon:"user",snippet:()=>"Interactie toegewezen",timeline:(e,t)=>`Assigned by ${t}`},SLA_BREACHED:{shape:"event",triggerable:!0,displayNameKey:"communication:activity.SLA_BREACHED",icon:"alarm-clock",snippet:e=>`SLA verlopen: ${e.payload.metric}`,timeline:e=>`SLA target ${e.payload.metric} passed its deadline`},WORK_COMMENT_ADDED:{shape:"note",icon:"sticky-note",carriesText:!0,snippet:()=>"Reactie"},WORK_ITEM_ASSIGNED:{shape:"event",icon:"user",snippet:()=>"Taak toegewezen",timeline:(e,t)=>`Assigned by ${t}`},WORK_ITEM_STATUS_CHANGED:{shape:"event",triggerable:!0,icon:"circle-dot",snippet:()=>"Status gewijzigd",timeline:(e,t)=>`Status changed by ${t}`}};function Ot(e){const t=e.payload,n=Qt(t.bodyText).trim()||t.bodySnippet?.trim()||Jt(t.body??"");return t.subject?`${t.subject} — ${n}`:n}function O(e){return D[e]}function Po(e){return O(e)?.icon??"circle"}function $o(e){return O(e)?.channelKind}function Qe(e){return e==="message"||e==="note"}function Ko(e){return Qe(O(e)?.shape)}function Je(e){return e==="note"}function Uo(e){return Je(O(e)?.shape)}function Fo(e){return O(e)?.replyable===!0}function Bo(e){return O(e)?.carriesText===!0}function Zt(e){return O(e)?.countsAs}function Ho(e){return O(e)?.playbookAuthored===!0}function Wo(e){return O(e)?.connected===!0}function Go(e){const t=O(e);return t?.shape==="artifact"&&t?.carriesText===!0}function en(e){const t=O(e.type)?.snippet;return t?t(e):""}function jo(e,t){const n=O(e.type)?.timeline;return n?n(e,t):e.type.replace(/_/g," ").toLowerCase()}function Vo(e){const t=O(e.type)?.joinUrl;return t?t(e):void 0}function ae(e,t){let n=e;for(const r of t.split(".")){if(n==null||typeof n!="object")return"";n=n[r]}return n==null?"":typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"?String(n):""}function ce(e,t,n){if(e===void 0)return null;if(typeof e=="string")return e||null;if("value"in e)return ae(t,e.value)||null;const r={};for(const[i,s]of Object.entries(e.params??{}))r[i]=ae(t,s);const o=n(e.key,r);return o===e.key?null:o}function tn(e,t){if(!e||typeof e=="string"||"value"in e)return null;const n={};for(const[r,o]of Object.entries(e.params??{}))n[r]=ae(t,o);return{key:e.key,params:n}}const Mt=140;function Xo(e){const t=e.trim();return t.length<=Mt?t:`${t.slice(0,Mt-1).trimEnd()}…`}function Yo(e,t){const n=tn(t?.text,e),r=t?ce(t.text,e,o=>o):null;return{activityId:e.id,type:e.type,snippet:Xo(r??en(e)),authorName:e.author?.name??"",direction:e.direction,createdAt:e.createdAt??Date.now(),...n?{snippetKey:n.key,snippetParams:n.params}:{}}}const zo=e=>e;function Ct(e){const t=D[e];return{type:e,shape:t.shape,channelKind:t.channelKind,icon:t.icon,replyable:t.replyable===!0,countsAs:t.countsAs,carriesText:t.carriesText===!0,triggerable:t.triggerable===!0,component:t.component,builtIn:!0,displayNameKey:t.displayNameKey}}function kt(e){return{type:e.type,shape:e.shape,channelKind:e.channelKind,icon:e.icon||"circle",replyable:e.replyable===!0,countsAs:e.countsAs,carriesText:e.carriesText===!0,triggerable:e.triggerable===!0,component:e.component,builtIn:!1,displayNameKey:e.displayNameKey}}class nn{constructor(t=[],n=zo){this.translate=n;for(const r of t)r?.type&&(r.type in D||this.declared.has(r.type)||this.declared.set(r.type,r))}declared=new Map;get(t){if(t in D)return Ct(t);const n=this.declared.get(t);return n?kt(n):void 0}triggerable(){const t=Object.keys(D).filter(r=>D[r].triggerable).map(Ct),n=[...this.declared.values()].map(kt).filter(r=>r.triggerable);return[...t,...n]}timelineText(t,n){const r=D[t.type];if(r?.timeline)return r.timeline(t,n);const o=this.declared.get(t.type);return ce(o?.text,t,this.translate)??t.type.replace(/_/g," ").toLowerCase()}snippet(t){const n=D[t.type];if(n?.snippet)return n.snippet(t);const r=this.declared.get(t.type);return ce(r?.text,t,this.translate)??""}descriptor(t){return this.declared.get(t)}blocks(t){const n=this.declared.get(t)?.render;return n?.length?n:void 0}isMessage(t){return Qe(this.get(t)?.shape)}nestsUnderParent(t){return Je(this.get(t)?.shape)}isReplyable(t){return this.get(t)?.replyable===!0}carriesText(t){return this.get(t)?.carriesText===!0}countsAs(t){return this.get(t)?.countsAs}channelKind(t){return this.get(t)?.channelKind}isTranscript(t){const n=this.get(t);return n?.shape==="artifact"&&n.carriesText}get translator(){return this.translate}}const qo=new nn;function Qo(e,t,n=[]){const r=e.createdAt;if(!r)return[];const o=new Set(n);return e.author.type==="user"&&e.author.id&&o.add(e.author.id),Object.entries(t).filter(([i,s])=>s>=r&&!o.has(i)).map(([i])=>i)}function rn(e){return e.createdAt??0}function Jo(e){return e.type==="EMAIL_RECEIVED"||e.type==="EMAIL_SENT"}function Zo(e){return e.type==="CHAT_MESSAGE_SENT"||e.type==="CHAT_MESSAGE_RECEIVED"}const Ze=[{id:"openai",attachmentKinds:["image","pdf"],label:"OpenAI",capabilities:["chat","transcription","embedding"],defaultModel:"gpt-5-mini",baseUrl:"https://api.openai.com/v1"},{id:"gemini",attachmentKinds:["image","pdf"],label:"Google Gemini",capabilities:["chat","transcription","embedding"],defaultModel:"gemini-3.5-flash",baseUrl:"https://generativelanguage.googleapis.com/v1beta"},{id:"anthropic",attachmentKinds:["image","pdf"],label:"Anthropic",capabilities:["chat"],defaultModel:"claude-haiku-4-5",baseUrl:"https://api.anthropic.com/v1"},{id:"elevenlabs",label:"ElevenLabs",capabilities:["transcription"],baseUrl:"https://api.elevenlabs.io/v1"},{id:"moonshot",label:"Moonshot (Kimi)",capabilities:["chat"],defaultModel:"kimi-k3",baseUrl:"https://api.moonshot.ai/v1"},{id:"deepseek",label:"DeepSeek",capabilities:["chat"],defaultModel:"deepseek-v4-flash",baseUrl:"https://api.deepseek.com/v1"},{id:"groq",label:"Groq",capabilities:["chat"],defaultModel:"openai/gpt-oss-120b",baseUrl:"https://api.groq.com/openai/v1"},{id:"mistral",label:"Mistral",capabilities:["chat"],defaultModel:"mistral-large-latest",baseUrl:"https://api.mistral.ai/v1"},{id:"openrouter",label:"OpenRouter",capabilities:["chat"],defaultModel:"openrouter/auto",baseUrl:"https://openrouter.ai/api/v1"},{id:"ollama",label:"Ollama (self-hosted)",capabilities:["chat"],defaultModel:"llama3.3"},{id:"openai-compatible",label:"OpenAI-compatible (eigen endpoint)",capabilities:["chat"],defaultModel:"default"}];function z(e){return Ze.find(t=>t.id===e)}function ei(e){return z(e)?.label??e}function ti(e,t="gpt-5-mini"){return z(e)?.defaultModel??t}function ni(e){return Ze.filter(t=>t.capabilities.includes(e))}function ri(e){const t=z(e);return!!t&&!t.baseUrl}function oi(e,t){return t==="text"?!0:z(e)?.attachmentKinds?.includes(t)===!0}function ii(e,t){if(!e.enabled)return"ok";const n=Ue(e.hardLimitNanos),r=Ue(e.softLimitNanos);return n!==void 0&&t>=n?"hard":r!==void 0&&t>=r?"soft":"ok"}function Ue(e){return typeof e=="number"?e:void 0}function on(e,t="month"){const n=new Date(e);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),1)}function si(e,t="month"){const n=new Date(on(e,t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,"0")}`}function ai(e){return e?.listeningEnabled!==!1}const ci=[{id:"agent",label:"Agent",labelSource:"user"},{id:"team",label:"Team",labelSource:"team"},{id:"inbox",label:"Inbox",labelSource:"inbox"},{id:"channel",label:"Kanaal",labelSource:"channel"},{id:"provider",label:"Provider",labelSource:"raw"},{id:"status",label:"Status",labelSource:"raw"},{id:"handledBy",label:"Afhandelaar",labelSource:"raw"},{id:"time",label:"Tijd",labelSource:"raw"}];function De(e){return e<10?`0${e}`:`${e}`}function F(e,t){const n=new Date(e),r=`${n.getUTCFullYear()}-${De(n.getUTCMonth()+1)}-${De(n.getUTCDate())}`;return t==="day"?r:`${r}T${De(n.getUTCHours())}`}function B(e,t){const n=new Date(e);return n.setUTCMinutes(0,0,0),t==="day"&&n.setUTCHours(0),n.getTime()}const li=36e5,ui=864e5;function di(e,t,n){const r=n==="hour"?li:ui,o=[];for(let i=B(e,n);i<=t;i+=r)o.push(F(i,n));return o}const pi=new Set(["time"]);function fi(e,t,n){if(!e)return[];const r=new Set(e.supportedDimensions??[]);return t.filter(o=>r.has(o.id)&&!pi.has(o.id)).map(o=>({id:o.id,label:o.label,options:o.options?.length?o.options:n[o.id]??[]})).filter(o=>o.options.length>0)}function mi(e,t){const n=t.find(o=>o.id===e.dimensionId),r=n?.options.find(o=>o.value===e.value);return`${n?.label??e.dimensionId} · ${r?.label??e.value}`}function gi(e){return{value:e.id,label:`${e.category} · ${e.label}`}}const sn=[{id:"resource",label:"Resource",labelSource:"raw"},{id:"origin",label:"Herkomst",labelSource:"raw"}],an=sn.map(e=>e.id);function cn(e,t){return`${e}.usage.${t}`}function hi(e,t){return t.map(n=>({id:cn(e,n.unit),label:n.label,category:"Verbruik",valueType:n.valueType??"count",aggregation:"sum",supportedDimensions:["provider",...an,...n.extraDimensions??[],"time"]}))}const ln=new Set(["info","success","warning","destructive"]),le=200,ue=100,de=200,pe=12,fe=4,Fe=10,un=8,Be=12,be=4e3,K=500,dn=1024*1024,yi=new Set(["heading","paragraph","list","quote","code","divider","table","kpi","callout","image","letterhead","totals","pagebreak"]),pn=["http:","https:","mailto:","tel:"],Ei=/^[a-z][a-z0-9+.-]*:/i;function et(e){const t=e.trim().replace(/^<|>$/g,"");if(!t)return!1;const n=Ei.exec(t)?.[0];return n?pn.includes(n.toLowerCase()):!t.startsWith("//")}const _i=/^[ \t]{0,3}\[([^\]]+)\]:[ \t]*(\S+).*$/gm;function Si(e){let t="",n=0;for(;n<e.length;){const r=e[n]==="!"&&e[n+1]==="[";if(e[n]!=="["&&!r){t+=e[n],n+=1;continue}const o=n+(r?2:1),i=wt(e,o,"[","]");if(i<0||e[i+1]!=="("){t+=e[n],n+=1;continue}const s=wt(e,i+2,"(",")");if(s<0){t+=e[n],n+=1;continue}const a=e.slice(o,i),c=e.slice(i+2,s).trim().split(/\s+/)[0]??"";t+=r||!et(c)?a:e.slice(n,s+1),n=s+1}return t}function wt(e,t,n,r){let o=1;for(let i=t;i<e.length;i+=1){if(e[i]==="\\"){i+=1;continue}if(e[i]===n)o+=1;else if(e[i]===r&&(o-=1,o===0))return i}return-1}function fn(e){return Si(e).replace(_i,(t,n,r)=>et(r)?t:"")}function I(e,t=be){return typeof e=="string"?fn(e).slice(0,t):""}function Ai(e,t=be){return typeof e=="string"?e.slice(0,t):""}function G(e,t=200){return I(e,t)}function bi(e,t="info"){return typeof e=="string"&&ln.has(e)?e:t}function mn(e,t=()=>{}){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(n.length>=le){t(`more than ${le} blocks; the rest was dropped`);break}if(!r||typeof r!="object")continue;const o=r;if(!yi.has(o.type)){t(`unknown block type ${String(o.type)}`);continue}const i=typeof o.block_id=="string"?{block_id:o.block_id}:{};switch(o.type){case"heading":{const s=I(o.text);if(!s){t("a heading without text");continue}const a=o.level===2||o.level===3?o.level:1;n.push({...i,type:"heading",level:a,text:s});break}case"paragraph":{const s=I(o.text);if(!s){t("a paragraph without text");continue}n.push({...i,type:"paragraph",text:s});break}case"quote":{const s=I(o.text);if(!s){t("a quote without text");continue}n.push({...i,type:"quote",text:s});break}case"code":{const s=Ai(o.text);if(!s){t("a code block without text");continue}const a=typeof o.lang=="string"?{lang:o.lang.slice(0,32)}:{};n.push({...i,type:"code",...a,text:s});break}case"divider":n.push({...i,type:"divider"});break;case"list":{const s=Array.isArray(o.items)?o.items:[],a=[];for(const u of s){if(a.length>=ue){t(`more than ${ue} list items`);break}const d=I(u?.text);if(!d)continue;const l=I(u?.lead,200);a.push(l?{lead:l,text:d}:{text:d})}if(a.length===0){t("a list without usable items");continue}const c=o.style==="numbered"?"numbered":"bulleted";n.push({...i,type:"list",style:c,items:a});break}case"table":{const s=Array.isArray(o.columns)?o.columns:[],a=[];for(const l of s){if(a.length>=pe){t(`more than ${pe} table columns`);break}const p=I(l?.label,K),f=l?.align==="right"?"right":void 0;a.push(f?{label:p,align:f}:{label:p})}if(a.length===0){t("a table without columns");continue}const c=Array.isArray(o.rows)?o.rows:[],u=[];for(const l of c){if(u.length>=de){t(`more than ${de} table rows`);break}const p=Array.isArray(l)?l:[];u.push(a.map((f,y)=>I(p[y],K)))}const d=I(o.caption,K);n.push({...i,type:"table",columns:a,rows:u,...d?{caption:d}:{}});break}case"kpi":{const s=Array.isArray(o.items)?o.items:[],a=[];for(const c of s){if(a.length>=fe){t(`more than ${fe} kpi items`);break}const u=I(c?.value,40),d=I(c?.label,80);if(!u||!d)continue;const l=c?.tone;a.push(typeof l=="string"&&ln.has(l)?{value:u,label:d,tone:l}:{value:u,label:d})}if(a.length===0){t("a kpi block without usable items");continue}n.push({...i,type:"kpi",items:a});break}case"image":{const s=typeof o.url=="string"?o.url.trim():"";if(!s||!et(s)){t("an image without a usable url");continue}const a=I(o.alt,200),c=I(o.caption,K);n.push({...i,type:"image",url:s,...a?{alt:a}:{},...c?{caption:c}:{}});break}case"letterhead":{const s=Array.isArray(o.fields)?o.fields:[],a=[];for(const d of s){if(a.length>=Fe){t(`more than ${Fe} letterhead fields`);break}const l=d,p=typeof l?.key=="string"?l.key.slice(0,48):"",f=G(l?.value);if(!p||!f)continue;const y=G(l?.label,80);a.push(y?{key:p,label:y,value:f}:{key:p,value:f})}const u=(Array.isArray(o.recipient)?o.recipient:[]).slice(0,un).map(d=>G(d)).filter(Boolean);if(a.length===0&&u.length===0){t("a letterhead without fields or recipient");continue}n.push({...i,type:"letterhead",fields:a,...u.length>0?{recipient:u}:{}});break}case"totals":{const s=u=>{const d=Array.isArray(u)?u:[],l=[];for(const p of d){if(l.length>=Be){t(`more than ${Be} totals rows`);break}const f=p,y=G(f?.label),m=G(f?.amount,40);!y||!m||l.push(f?.emphasis===!0?{label:y,amount:m,emphasis:!0}:{label:y,amount:m})}return l},a=s(o.rows);if(a.length===0&&!o.block_id){t("a totals block without usable rows");continue}const c=s(o.taxRows);n.push({...i,type:"totals",rows:a,...c.length>0?{taxRows:c}:{}});break}case"pagebreak":n.push({...i,type:"pagebreak"});break;case"callout":{const s=I(o.text);if(!s){t("a callout without text");continue}const a=I(o.title,200);n.push({...i,type:"callout",tone:bi(o.tone),...a?{title:a}:{},text:s});break}}}return n}function gn(e){return JSON.stringify(e).length}function hn(e){return{blocks:e.length,types:e.map(t=>t.type),headings:e.flatMap(t=>t.type==="heading"?[t.text]:[])}}function Nt(e){return e.replace(/\|/g,"\\|").replace(/\r?\n/g," ").trim()}function xe(e,t,n){const r=e.map((o,i)=>n?.[i]==="right"?"---:":"---");return[`| ${e.map(Nt).join(" | ")} |`,`| ${r.join(" | ")} |`,...t.map(o=>`| ${o.map(Nt).join(" | ")} |`)]}function Ti(e){switch(e.type){case"heading":return[`${"#".repeat(e.level)} ${e.text}`];case"paragraph":return[e.text];case"quote":return e.text.split(/\r?\n/).map(t=>`> ${t}`);case"code":return[`\`\`\`${e.lang??""}`,e.text,"```"];case"divider":return["---"];case"list":return e.items.map((t,n)=>{const r=e.style==="numbered"?`${n+1}.`:"-";return t.lead?`${r} **${t.lead}** ${t.text}`:`${r} ${t.text}`});case"table":{const t=xe(e.columns.map(n=>n.label),e.rows,e.columns.map(n=>n.align??"left"));return e.caption?[...t,"",`*${e.caption}*`]:t}case"kpi":return xe(e.items.map(t=>t.value),[e.items.map(t=>t.label)]);case"callout":return(e.title?`**${e.title}** ${e.text}`:e.text).split(/\r?\n/).map(n=>`> ${n}`);case"image":{const t=``;return e.caption?[t,"",`*${e.caption}*`]:[t]}case"letterhead":{const t=[...e.recipient??[]];t.length>0&&e.fields.length>0&&t.push("");for(const n of e.fields)t.push(n.label?`**${n.label}:** ${n.value}`:n.value);return t.map((n,r)=>r<t.length-1?`${n} `:n)}case"totals":return xe(["",""],[...e.rows,...e.taxRows??[]].map(t=>[t.emphasis?`**${t.label}**`:t.label,t.emphasis?`**${t.amount}**`:t.amount]),["left","right"]);case"pagebreak":return["---"]}}function tt(e,t){const n=[],r=e.some(o=>o.type==="heading"&&o.level===1);t&&!r&&n.push(`# ${t}`);for(const o of e){const i=Ti(o);i.length>0&&n.push(i.join(`
|
|
3
|
+
`),t=t.replace(xo,"$2"),t=t.replace(Lo,"$2"),t=t.replace(/~~(?=\S)([\s\S]*?\S)~~/g,"$1"),t=t.replace(/`([^`\n]+)`/g,"$1"),t.replace(/\s+/g," ").trim()}function Jt(e){return e.replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim()}function J(e){if(!e||e<0)return"";const t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${n.toString().padStart(2,"0")}`}function Tt(e){return e?` — ${Math.floor(e/60)}m ${e%60}s`:""}function ve(e){return e?.split("@")?.[0]||e||""}function Z(e){return e.map(t=>t.name).join(", ")}function It(e){return e==="meeting"?"Meeting":e==="video"?"Video call":"Audio call"}const D={VOICE_CALL_STARTED:{shape:"event",channelKind:"voice",icon:"phone",snippet:()=>"Gesprek gestart",timeline:e=>e.direction==="inbound"?`Inbound call started — ${ve(e.payload.from)}`:`Outbound call started — ${ve(e.payload.to)}`},VOICE_CALL_ANSWERED:{shape:"event",channelKind:"voice",icon:"phone",connected:!0,snippet:()=>"Gesprek aangenomen",timeline:(e,t)=>`Call answered — ${t}`},VOICE_CALL_HOLD:{shape:"event",channelKind:"voice",icon:"phone",snippet:()=>"In de wacht",timeline:(e,t)=>`Call on hold — ${t}`},VOICE_CALL_UNHOLD:{shape:"event",channelKind:"voice",icon:"phone",snippet:()=>"Hervat"},VOICE_CALL_ENDED:{shape:"event",channelKind:"voice",icon:"phone",snippet:e=>`Gesprek beëindigd${e.payload.duration?` (${J(e.payload.duration)})`:""}`,timeline:e=>`Call ended${Tt(e.payload.duration)}`},VOICE_CALL_MISSED:{shape:"event",channelKind:"voice",icon:"phone",snippet:()=>"Gemiste oproep",timeline:e=>`Missed call — ${ve(e.payload.from)}`},VOICE_CALL_FAILED:{shape:"event",channelKind:"voice",icon:"phone",snippet:()=>"Gesprek mislukt",timeline:()=>"Call failed"},VOICE_CALL_VOICEMAIL:{shape:"artifact",channelKind:"voice",icon:"phone",snippet:e=>e.payload.transcription?.trim()?e.payload.transcription:"Voicemail ontvangen"},VIDEO_CALL_STARTED:{shape:"event",channelKind:"video",icon:"video",snippet:()=>"Gesprek gestart",timeline:()=>"Video call started"},VIDEO_CALL_ANSWERED:{shape:"event",channelKind:"video",icon:"video",connected:!0,snippet:()=>"Gesprek aangenomen",timeline:()=>"Video call answered"},VIDEO_CALL_HOLD:{shape:"event",channelKind:"video",icon:"video",snippet:()=>"In de wacht"},VIDEO_CALL_UNHOLD:{shape:"event",channelKind:"video",icon:"video",snippet:()=>"Hervat"},VIDEO_CALL_ENDED:{shape:"event",channelKind:"video",icon:"video",snippet:e=>`Gesprek beëindigd${e.payload.duration?` (${J(e.payload.duration)})`:""}`,timeline:()=>"Video call ended"},VIDEO_CALL_MISSED:{shape:"event",channelKind:"video",icon:"video",snippet:()=>"Gemiste oproep",timeline:()=>"Missed video call"},VIDEO_CALL_FAILED:{shape:"event",channelKind:"video",icon:"video",snippet:()=>"Gesprek mislukt",timeline:()=>"Video call failed"},EMAIL_RECEIVED:{shape:"message",triggerable:!0,displayNameKey:"communication:activity.EMAIL_RECEIVED",component:"communication:EmailActivity",channelKind:"mail",icon:"mail",replyable:!0,carriesText:!0,countsAs:"inbound_message",snippet:Ot},EMAIL_SENT:{shape:"message",component:"communication:EmailActivity",channelKind:"mail",icon:"mail",replyable:!0,carriesText:!0,countsAs:"outbound_message",snippet:Ot},CHAT_MESSAGE_SENT:{shape:"message",component:"communication:ChatMessage",channelKind:"chat",icon:"message-circle",replyable:!0,carriesText:!0,countsAs:"outbound_message",snippet:e=>e.payload.text??""},CHAT_MESSAGE_RECEIVED:{shape:"message",triggerable:!0,displayNameKey:"communication:activity.CHAT_MESSAGE_RECEIVED",component:"communication:ChatMessage",channelKind:"chat",icon:"message-circle",replyable:!0,carriesText:!0,countsAs:"inbound_message",snippet:e=>e.payload.text??""},CHAT_MEMBER_JOINED:{shape:"event",channelKind:"chat",icon:"message-circle",snippet:e=>`${Z(e.payload.members)} toegevoegd`,timeline:e=>{const t=Z(e.payload.members)||"Someone",n=e.payload.initiator?.name?` · added by ${e.payload.initiator.name}`:"";return`${t} joined the chat${n}`}},CHAT_MEMBER_LEFT:{shape:"event",channelKind:"chat",icon:"message-circle",snippet:e=>`${Z(e.payload.members)} verlaten`,timeline:e=>{const t=Z(e.payload.members)||"Someone",n=e.payload.initiator?.name?` · removed by ${e.payload.initiator.name}`:"";return`${t} left the chat${n}`}},CHAT_RENAMED:{shape:"event",channelKind:"chat",icon:"message-circle",snippet:e=>`Hernoemd naar "${e.payload.newName}"`,timeline:e=>`Chat renamed to "${e.payload.newName}"${e.payload.initiator?` by ${e.payload.initiator.name}`:""}`},CHAT_CALL_STARTED:{shape:"event",channelKind:"chat",icon:"message-circle",snippet:()=>"Gesprek gestart",timeline:e=>`${It(e.payload.callType)} started${e.payload.initiator?` by ${e.payload.initiator.name}`:""}`,joinUrl:e=>e.payload.joinUrl},CHAT_CALL_ENDED:{shape:"event",channelKind:"chat",icon:"message-circle",snippet:e=>`Gesprek beëindigd${e.payload.duration?` (${J(e.payload.duration)})`:""}`,timeline:e=>`${It(e.payload.callType)} ended${Tt(e.payload.duration)}`,joinUrl:e=>e.payload.joinUrl},CHAT_EVENT:{shape:"event",channelKind:"chat",icon:"message-circle",snippet:e=>e.payload.text??e.payload.eventType,timeline:e=>e.payload.text||e.payload.eventType},TRANSCRIPT_ADDED:{shape:"artifact",triggerable:!0,displayNameKey:"communication:activity.TRANSCRIPT_ADDED",component:"communication:TranscriptionActivity",icon:"captions",carriesText:!0,snippet:e=>(e.payload.segments??[]).map(t=>t.text).join(" ")},COMMENT_ADDED:{shape:"note",component:"communication:CommentActivity",icon:"sticky-note",carriesText:!0,snippet:e=>e.payload.text??""},FILE_UPLOADED:{shape:"artifact",component:"communication:FileActivity",icon:"paperclip",snippet:e=>`Bestand: ${e.payload.fileName}`},AI_MESSAGE_ADDED:{shape:"event",triggerable:!0,displayNameKey:"communication:activity.AI_MESSAGE_ADDED",icon:"circle",snippet:e=>e.payload.output?.text??e.payload.input?.text??"",timeline:()=>"AI message added"},AI_ACTION_PROPOSED:{shape:"event",component:"communication:ProposedActionCard",icon:"circle",playbookAuthored:!0,snippet:e=>`Voorstel wacht op goedkeuring (${e.payload.actions?.length??0} actie(s))`},PLAYBOOK_STARTED:{shape:"event",icon:"circle",playbookAuthored:!0,snippet:e=>`Playbook gestart${e.payload.playbookName?`: ${e.payload.playbookName}`:""}`,timeline:e=>`Playbook gestart${e.payload.playbookName?` — ${e.payload.playbookName}`:""}`},PLAYBOOK_COMPLETED:{shape:"event",icon:"circle",playbookAuthored:!0,snippet:()=>"Playbook afgerond",timeline:()=>"Playbook afgerond"},PLAYBOOK_ESCALATED:{shape:"event",icon:"circle",playbookAuthored:!0,snippet:()=>"Playbook geëscaleerd naar een mens",timeline:()=>"Playbook geëscaleerd naar een mens"},MEETING_SCHEDULED:{shape:"event",icon:"calendar",snippet:e=>`Vergadering gepland: ${e.payload.title}`,timeline:()=>"Meeting scheduled",joinUrl:e=>e.payload.joinUrl},MEETING_STARTED:{shape:"event",icon:"calendar",connected:!0,snippet:e=>`Vergadering gestart: ${e.payload.title}`,timeline:()=>"Meeting started",joinUrl:e=>e.payload.joinUrl},MEETING_ENDED:{shape:"event",icon:"calendar",snippet:e=>`Vergadering beëindigd${e.payload.duration?` (${J(e.payload.duration)})`:""}`,timeline:()=>"Meeting ended"},MEETING_PARTICIPANT_JOINED:{shape:"event",icon:"calendar",snippet:e=>`${e.payload.name} deelgenomen`,timeline:(e,t)=>`${t} joined the meeting`},MEETING_PARTICIPANT_LEFT:{shape:"event",icon:"calendar",snippet:e=>`${e.payload.name} verlaten`,timeline:(e,t)=>`${t} left the meeting`},INTERACTION_CREATED:{shape:"event",icon:"circle",snippet:()=>"Interactie aangemaakt",timeline:(e,t)=>`Interaction started by ${t}`},INTERACTION_STATUS_CHANGED:{shape:"event",triggerable:!0,displayNameKey:"communication:activity.INTERACTION_STATUS_CHANGED",icon:"circle-dot",snippet:e=>`Status: ${e.payload.fromStatus} → ${e.payload.toStatus}`,timeline:(e,t)=>`Status changed to ${e.payload.toStatus} by ${t}`},INTERACTION_ASSIGNED:{shape:"event",icon:"user",snippet:()=>"Interactie toegewezen",timeline:(e,t)=>`Assigned by ${t}`},SLA_BREACHED:{shape:"event",triggerable:!0,displayNameKey:"communication:activity.SLA_BREACHED",icon:"alarm-clock",snippet:e=>`SLA verlopen: ${e.payload.metric}`,timeline:e=>`SLA target ${e.payload.metric} passed its deadline`},WORK_COMMENT_ADDED:{shape:"note",icon:"sticky-note",carriesText:!0,snippet:()=>"Reactie"},WORK_ITEM_ASSIGNED:{shape:"event",icon:"user",snippet:()=>"Taak toegewezen",timeline:(e,t)=>`Assigned by ${t}`},WORK_ITEM_STATUS_CHANGED:{shape:"event",triggerable:!0,icon:"circle-dot",snippet:()=>"Status gewijzigd",timeline:(e,t)=>`Status changed by ${t}`}};function Ot(e){const t=e.payload,n=Qt(t.bodyText).trim()||t.bodySnippet?.trim()||Jt(t.body??"");return t.subject?`${t.subject} — ${n}`:n}function O(e){return D[e]}function Po(e){return O(e)?.icon??"circle"}function $o(e){return O(e)?.channelKind}function Qe(e){return e==="message"||e==="note"}function Ko(e){return Qe(O(e)?.shape)}function Je(e){return e==="note"}function Uo(e){return Je(O(e)?.shape)}function Fo(e){return O(e)?.replyable===!0}function Bo(e){return O(e)?.carriesText===!0}function Zt(e){return O(e)?.countsAs}function Ho(e){return O(e)?.playbookAuthored===!0}function Wo(e){return O(e)?.connected===!0}function Go(e){const t=O(e);return t?.shape==="artifact"&&t?.carriesText===!0}function en(e){const t=O(e.type)?.snippet;return t?t(e):""}function jo(e,t){const n=O(e.type)?.timeline;return n?n(e,t):e.type.replace(/_/g," ").toLowerCase()}function Vo(e){const t=O(e.type)?.joinUrl;return t?t(e):void 0}function ae(e,t){let n=e;for(const r of t.split(".")){if(n==null||typeof n!="object")return"";n=n[r]}return n==null?"":typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"?String(n):""}function ce(e,t,n){if(e===void 0)return null;if(typeof e=="string")return e||null;if("value"in e)return ae(t,e.value)||null;const r={};for(const[i,s]of Object.entries(e.params??{}))r[i]=ae(t,s);const o=n(e.key,r);return o===e.key?null:o}function tn(e,t){if(!e||typeof e=="string"||"value"in e)return null;const n={};for(const[r,o]of Object.entries(e.params??{}))n[r]=ae(t,o);return{key:e.key,params:n}}const Mt=140;function Xo(e){const t=e.trim();return t.length<=Mt?t:`${t.slice(0,Mt-1).trimEnd()}…`}function Yo(e,t){const n=tn(t?.text,e),r=t?ce(t.text,e,o=>o):null;return{activityId:e.id,type:e.type,snippet:Xo(r??en(e)),authorName:e.author?.name??"",direction:e.direction,createdAt:e.createdAt??Date.now(),...n?{snippetKey:n.key,snippetParams:n.params}:{}}}const zo=e=>e;function Ct(e){const t=D[e];return{type:e,shape:t.shape,channelKind:t.channelKind,icon:t.icon,replyable:t.replyable===!0,countsAs:t.countsAs,carriesText:t.carriesText===!0,triggerable:t.triggerable===!0,component:t.component,builtIn:!0,displayNameKey:t.displayNameKey}}function kt(e){return{type:e.type,shape:e.shape,channelKind:e.channelKind,icon:e.icon||"circle",replyable:e.replyable===!0,countsAs:e.countsAs,carriesText:e.carriesText===!0,triggerable:e.triggerable===!0,component:e.component,builtIn:!1,displayNameKey:e.displayNameKey}}class nn{constructor(t=[],n=zo){this.translate=n;for(const r of t)r?.type&&(r.type in D||this.declared.has(r.type)||this.declared.set(r.type,r))}declared=new Map;get(t){if(t in D)return Ct(t);const n=this.declared.get(t);return n?kt(n):void 0}triggerable(){const t=Object.keys(D).filter(r=>D[r].triggerable).map(Ct),n=[...this.declared.values()].map(kt).filter(r=>r.triggerable);return[...t,...n]}timelineText(t,n){const r=D[t.type];if(r?.timeline)return r.timeline(t,n);const o=this.declared.get(t.type);return ce(o?.text,t,this.translate)??t.type.replace(/_/g," ").toLowerCase()}snippet(t){const n=D[t.type];if(n?.snippet)return n.snippet(t);const r=this.declared.get(t.type);return ce(r?.text,t,this.translate)??""}descriptor(t){return this.declared.get(t)}blocks(t){const n=this.declared.get(t)?.render;return n?.length?n:void 0}isMessage(t){return Qe(this.get(t)?.shape)}nestsUnderParent(t){return Je(this.get(t)?.shape)}isReplyable(t){return this.get(t)?.replyable===!0}carriesText(t){return this.get(t)?.carriesText===!0}countsAs(t){return this.get(t)?.countsAs}channelKind(t){return this.get(t)?.channelKind}isTranscript(t){const n=this.get(t);return n?.shape==="artifact"&&n.carriesText}get translator(){return this.translate}}const qo=new nn;function Qo(e,t,n=[]){const r=e.createdAt;if(!r)return[];const o=new Set(n);return e.author.type==="user"&&e.author.id&&o.add(e.author.id),Object.entries(t).filter(([i,s])=>s>=r&&!o.has(i)).map(([i])=>i)}function rn(e){return e.createdAt??0}function Jo(e){return e.type==="EMAIL_RECEIVED"||e.type==="EMAIL_SENT"}function Zo(e){return e.type==="CHAT_MESSAGE_SENT"||e.type==="CHAT_MESSAGE_RECEIVED"}const Ze=[{id:"openai",attachmentKinds:["image","pdf"],label:"OpenAI",capabilities:["chat","transcription","embedding"],defaultModel:"gpt-5-mini",baseUrl:"https://api.openai.com/v1"},{id:"gemini",attachmentKinds:["image","pdf"],label:"Google Gemini",capabilities:["chat","transcription","embedding"],defaultModel:"gemini-3.5-flash",baseUrl:"https://generativelanguage.googleapis.com/v1beta"},{id:"anthropic",attachmentKinds:["image","pdf"],label:"Anthropic",capabilities:["chat"],defaultModel:"claude-haiku-4-5",baseUrl:"https://api.anthropic.com/v1"},{id:"elevenlabs",label:"ElevenLabs",capabilities:["transcription"],baseUrl:"https://api.elevenlabs.io/v1"},{id:"moonshot",label:"Moonshot (Kimi)",capabilities:["chat"],defaultModel:"kimi-k3",baseUrl:"https://api.moonshot.ai/v1"},{id:"deepseek",label:"DeepSeek",capabilities:["chat"],defaultModel:"deepseek-v4-flash",baseUrl:"https://api.deepseek.com/v1"},{id:"groq",label:"Groq",capabilities:["chat"],defaultModel:"openai/gpt-oss-120b",baseUrl:"https://api.groq.com/openai/v1"},{id:"mistral",label:"Mistral",capabilities:["chat"],defaultModel:"mistral-large-latest",baseUrl:"https://api.mistral.ai/v1"},{id:"openrouter",label:"OpenRouter",capabilities:["chat"],defaultModel:"openrouter/auto",baseUrl:"https://openrouter.ai/api/v1"},{id:"ollama",label:"Ollama (self-hosted)",capabilities:["chat"],defaultModel:"llama3.3"},{id:"openai-compatible",label:"OpenAI-compatible (eigen endpoint)",capabilities:["chat"],defaultModel:"default"}];function z(e){return Ze.find(t=>t.id===e)}function ei(e){return z(e)?.label??e}function ti(e,t="gpt-5-mini"){return z(e)?.defaultModel??t}function ni(e){return Ze.filter(t=>t.capabilities.includes(e))}function ri(e){const t=z(e);return!!t&&!t.baseUrl}function oi(e,t){return t==="text"?!0:z(e)?.attachmentKinds?.includes(t)===!0}function ii(e,t){if(!e.enabled)return"ok";const n=Ue(e.hardLimitNanos),r=Ue(e.softLimitNanos);return n!==void 0&&t>=n?"hard":r!==void 0&&t>=r?"soft":"ok"}function Ue(e){return typeof e=="number"?e:void 0}function on(e,t="month"){const n=new Date(e);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),1)}function si(e,t="month"){const n=new Date(on(e,t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,"0")}`}function ai(e){return e?.listeningEnabled!==!1}const ci=[{id:"agent",label:"Agent",labelSource:"user"},{id:"team",label:"Team",labelSource:"team"},{id:"inbox",label:"Inbox",labelSource:"inbox"},{id:"channel",label:"Kanaal",labelSource:"channel"},{id:"provider",label:"Provider",labelSource:"raw"},{id:"status",label:"Status",labelSource:"raw"},{id:"handledBy",label:"Afhandelaar",labelSource:"raw"},{id:"time",label:"Tijd",labelSource:"raw"}];function De(e){return e<10?`0${e}`:`${e}`}function F(e,t){const n=new Date(e),r=`${n.getUTCFullYear()}-${De(n.getUTCMonth()+1)}-${De(n.getUTCDate())}`;return t==="day"?r:`${r}T${De(n.getUTCHours())}`}function B(e,t){const n=new Date(e);return n.setUTCMinutes(0,0,0),t==="day"&&n.setUTCHours(0),n.getTime()}const li=36e5,ui=864e5;function di(e,t,n){const r=n==="hour"?li:ui,o=[];for(let i=B(e,n);i<=t;i+=r)o.push(F(i,n));return o}const pi=new Set(["time"]);function fi(e,t,n){if(!e)return[];const r=new Set(e.supportedDimensions??[]);return t.filter(o=>r.has(o.id)&&!pi.has(o.id)).map(o=>({id:o.id,label:o.label,options:o.options?.length?o.options:n[o.id]??[]})).filter(o=>o.options.length>0)}function mi(e,t){const n=t.find(o=>o.id===e.dimensionId),r=n?.options.find(o=>o.value===e.value);return`${n?.label??e.dimensionId} · ${r?.label??e.value}`}function gi(e){return{value:e.id,label:`${e.category} · ${e.label}`}}const sn=[{id:"resource",label:"Resource",labelSource:"raw"},{id:"origin",label:"Herkomst",labelSource:"raw"}],an=sn.map(e=>e.id);function cn(e,t){return`${e}.usage.${t}`}function hi(e,t){return t.map(n=>({id:cn(e,n.unit),label:n.label,category:"Verbruik",valueType:n.valueType??"count",aggregation:"sum",supportedDimensions:["provider",...an,...n.extraDimensions??[],"time"]}))}const ln=new Set(["info","success","warning","destructive"]),le=200,ue=100,de=200,pe=12,fe=4,Fe=10,un=8,Be=12,be=4e3,K=500,dn=1024*1024,yi=new Set(["heading","paragraph","list","quote","code","divider","table","kpi","callout","image","letterhead","totals","pagebreak"]),pn=["http:","https:","mailto:","tel:"],Ei=/^[a-z][a-z0-9+.-]*:/i;function et(e){const t=e.trim().replace(/^<|>$/g,"");if(!t)return!1;const n=Ei.exec(t)?.[0];return n?pn.includes(n.toLowerCase()):!t.startsWith("//")}const _i=/^[ \t]{0,3}\[([^\]]+)\]:[ \t]*(\S+).*$/gm;function Si(e){let t="",n=0;for(;n<e.length;){const r=e[n]==="!"&&e[n+1]==="[";if(e[n]!=="["&&!r){t+=e[n],n+=1;continue}const o=n+(r?2:1),i=wt(e,o,"[","]");if(i<0||e[i+1]!=="("){t+=e[n],n+=1;continue}const s=wt(e,i+2,"(",")");if(s<0){t+=e[n],n+=1;continue}const a=e.slice(o,i),u=e.slice(i+2,s).trim().split(/\s+/)[0]??"";t+=r||!et(u)?a:e.slice(n,s+1),n=s+1}return t}function wt(e,t,n,r){let o=1;for(let i=t;i<e.length;i+=1){if(e[i]==="\\"){i+=1;continue}if(e[i]===n)o+=1;else if(e[i]===r&&(o-=1,o===0))return i}return-1}function fn(e){return Si(e).replace(_i,(t,n,r)=>et(r)?t:"")}function I(e,t=be){return typeof e=="string"?fn(e).slice(0,t):""}function Ai(e,t=be){return typeof e=="string"?e.slice(0,t):""}function G(e,t=200){return I(e,t)}function bi(e,t="info"){return typeof e=="string"&&ln.has(e)?e:t}function mn(e,t=()=>{}){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(n.length>=le){t(`more than ${le} blocks; the rest was dropped`);break}if(!r||typeof r!="object")continue;const o=r;if(!yi.has(o.type)){t(`unknown block type ${String(o.type)}`);continue}const i=typeof o.block_id=="string"?{block_id:o.block_id}:{};switch(o.type){case"heading":{const s=I(o.text);if(!s){t("a heading without text");continue}const a=o.level===2||o.level===3?o.level:1;n.push({...i,type:"heading",level:a,text:s});break}case"paragraph":{const s=I(o.text);if(!s){t("a paragraph without text");continue}n.push({...i,type:"paragraph",text:s});break}case"quote":{const s=I(o.text);if(!s){t("a quote without text");continue}n.push({...i,type:"quote",text:s});break}case"code":{const s=Ai(o.text);if(!s){t("a code block without text");continue}const a=typeof o.lang=="string"?{lang:o.lang.slice(0,32)}:{};n.push({...i,type:"code",...a,text:s});break}case"divider":n.push({...i,type:"divider"});break;case"list":{const s=Array.isArray(o.items)?o.items:[],a=[];for(const l of s){if(a.length>=ue){t(`more than ${ue} list items`);break}const d=I(l?.text);if(!d)continue;const c=I(l?.lead,200);a.push(c?{lead:c,text:d}:{text:d})}if(a.length===0){t("a list without usable items");continue}const u=o.style==="numbered"?"numbered":"bulleted";n.push({...i,type:"list",style:u,items:a});break}case"table":{const s=Array.isArray(o.columns)?o.columns:[],a=[];for(const c of s){if(a.length>=pe){t(`more than ${pe} table columns`);break}const p=I(c?.label,K),f=c?.align==="right"?"right":void 0;a.push(f?{label:p,align:f}:{label:p})}if(a.length===0){t("a table without columns");continue}const u=Array.isArray(o.rows)?o.rows:[],l=[];for(const c of u){if(l.length>=de){t(`more than ${de} table rows`);break}const p=Array.isArray(c)?c:[];l.push(a.map((f,y)=>I(p[y],K)))}const d=I(o.caption,K);n.push({...i,type:"table",columns:a,rows:l,...d?{caption:d}:{}});break}case"kpi":{const s=Array.isArray(o.items)?o.items:[],a=[];for(const u of s){if(a.length>=fe){t(`more than ${fe} kpi items`);break}const l=I(u?.value,40),d=I(u?.label,80);if(!l||!d)continue;const c=u?.tone;a.push(typeof c=="string"&&ln.has(c)?{value:l,label:d,tone:c}:{value:l,label:d})}if(a.length===0){t("a kpi block without usable items");continue}n.push({...i,type:"kpi",items:a});break}case"image":{const s=typeof o.url=="string"?o.url.trim():"";if(!s||!et(s)){t("an image without a usable url");continue}const a=I(o.alt,200),u=I(o.caption,K);n.push({...i,type:"image",url:s,...a?{alt:a}:{},...u?{caption:u}:{}});break}case"letterhead":{const s=Array.isArray(o.fields)?o.fields:[],a=[];for(const d of s){if(a.length>=Fe){t(`more than ${Fe} letterhead fields`);break}const c=d,p=typeof c?.key=="string"?c.key.slice(0,48):"",f=G(c?.value);if(!p||!f)continue;const y=G(c?.label,80);a.push(y?{key:p,label:y,value:f}:{key:p,value:f})}const l=(Array.isArray(o.recipient)?o.recipient:[]).slice(0,un).map(d=>G(d)).filter(Boolean);if(a.length===0&&l.length===0){t("a letterhead without fields or recipient");continue}n.push({...i,type:"letterhead",fields:a,...l.length>0?{recipient:l}:{}});break}case"totals":{const s=l=>{const d=Array.isArray(l)?l:[],c=[];for(const p of d){if(c.length>=Be){t(`more than ${Be} totals rows`);break}const f=p,y=G(f?.label),m=G(f?.amount,40);!y||!m||c.push(f?.emphasis===!0?{label:y,amount:m,emphasis:!0}:{label:y,amount:m})}return c},a=s(o.rows);if(a.length===0&&!o.block_id){t("a totals block without usable rows");continue}const u=s(o.taxRows);n.push({...i,type:"totals",rows:a,...u.length>0?{taxRows:u}:{}});break}case"pagebreak":n.push({...i,type:"pagebreak"});break;case"callout":{const s=I(o.text);if(!s){t("a callout without text");continue}const a=I(o.title,200);n.push({...i,type:"callout",tone:bi(o.tone),...a?{title:a}:{},text:s});break}}}return n}function gn(e){return JSON.stringify(e).length}function hn(e){return{blocks:e.length,types:e.map(t=>t.type),headings:e.flatMap(t=>t.type==="heading"?[t.text]:[])}}function Nt(e){return e.replace(/\|/g,"\\|").replace(/\r?\n/g," ").trim()}function xe(e,t,n){const r=e.map((o,i)=>n?.[i]==="right"?"---:":"---");return[`| ${e.map(Nt).join(" | ")} |`,`| ${r.join(" | ")} |`,...t.map(o=>`| ${o.map(Nt).join(" | ")} |`)]}function Ti(e){switch(e.type){case"heading":return[`${"#".repeat(e.level)} ${e.text}`];case"paragraph":return[e.text];case"quote":return e.text.split(/\r?\n/).map(t=>`> ${t}`);case"code":return[`\`\`\`${e.lang??""}`,e.text,"```"];case"divider":return["---"];case"list":return e.items.map((t,n)=>{const r=e.style==="numbered"?`${n+1}.`:"-";return t.lead?`${r} **${t.lead}** ${t.text}`:`${r} ${t.text}`});case"table":{const t=xe(e.columns.map(n=>n.label),e.rows,e.columns.map(n=>n.align??"left"));return e.caption?[...t,"",`*${e.caption}*`]:t}case"kpi":return xe(e.items.map(t=>t.value),[e.items.map(t=>t.label)]);case"callout":return(e.title?`**${e.title}** ${e.text}`:e.text).split(/\r?\n/).map(n=>`> ${n}`);case"image":{const t=``;return e.caption?[t,"",`*${e.caption}*`]:[t]}case"letterhead":{const t=[...e.recipient??[]];t.length>0&&e.fields.length>0&&t.push("");for(const n of e.fields)t.push(n.label?`**${n.label}:** ${n.value}`:n.value);return t.map((n,r)=>r<t.length-1?`${n} `:n)}case"totals":return xe(["",""],[...e.rows,...e.taxRows??[]].map(t=>[t.emphasis?`**${t.label}**`:t.label,t.emphasis?`**${t.amount}**`:t.amount]),["left","right"]);case"pagebreak":return["---"]}}function tt(e,t){const n=[],r=e.some(o=>o.type==="heading"&&o.level===1);t&&!r&&n.push(`# ${t}`);for(const o of e){const i=Ti(o);i.length>0&&n.push(i.join(`
|
|
4
4
|
`))}return`${n.join(`
|
|
5
5
|
|
|
6
6
|
`)}
|
|
7
|
-
`}const nt=e=>`user:${e}`,rt=e=>`team:${e}`;function Ii(e){const t=new Set;for(const n of e??[])n?.id&&(n.kind==="user"&&t.add(nt(n.id)),n.kind==="team"&&t.add(rt(n.id)));return[...t].sort()}function Oi(e,t){return[nt(e),...t.map(rt)]}function Mi(e){const t=new Set;for(const n of e??[])n?.kind&&t.add(n.kind);return[...t]}const yn=["done","escalated"],Ci=["open","waiting"];function ki(e){return yn.includes(e)}const En="assignment";function wi(e){return`${En}:${e}`}function Ni(e,t,n,r){if(e.direction==="inbound")return!0;if(e.author?.type==="user"&&e.author.id===t)return!1;const o=e.payload?.mentions;return Array.isArray(o)&&o.includes(t)||r&&r===t?!0:n==="reply"}function Ri(e){const{targetAuthorId:t,reactorId:n,agentId:r,on:o}=e;return!o||!t||t!==r?!1:n!==r}function vi(e){return e.subjectKind&&e.subjectId?{type:e.subjectKind,id:e.subjectId}:void 0}const _n=12;function Di(e,t,n=_n){const r=t+1;return e?e.kind==="done"?{status:"done",waitingOn:null,turns:r,reason:e.note}:e.kind==="escalate"?{status:"escalated",waitingOn:null,turns:r,reason:e.reason}:r>=n?{status:"escalated",waitingOn:null,turns:r,reason:`na ${n} beurten nog niet afgerond, dus een mens neemt het over`}:{status:"waiting",waitingOn:e.on,turns:r}:{status:"escalated",waitingOn:null,turns:r,reason:"de agent rondde zijn beurt af zonder te zeggen wat er moet gebeuren (wachten, afronden of overdragen)"}}function Sn(e){const t=e.trim().replace(/[\s-]/g,"");if(!/^\d+$/.test(t)||![8,12,13,14].includes(t.length))return;const n=t.padStart(14,"0");return xi(n.slice(0,13))===Number(n[13])?n:void 0}function xi(e){let t=0;for(let n=0;n<e.length;n++)t+=Number(e[n])*(n%2===0?3:1);return(10-t%10)%10}function Li(e,t){const n=t.trim(),r=Sn(n),o=[{sku:n},{barcodes:{$in:[n]}}];return r&&o.push({gtin:r}),{organizationId:e,$or:o}}function H(e){return e<0?-Math.round(-e):Math.round(e)}function An(e,t){if(t.length===0)return[];const n=t.reduce((
|
|
7
|
+
`}const nt=e=>`user:${e}`,rt=e=>`team:${e}`;function Ii(e){const t=new Set;for(const n of e??[])n?.id&&(n.kind==="user"&&t.add(nt(n.id)),n.kind==="team"&&t.add(rt(n.id)));return[...t].sort()}function Oi(e,t){return[nt(e),...t.map(rt)]}function Mi(e){const t=new Set;for(const n of e??[])n?.kind&&t.add(n.kind);return[...t]}const yn=["done","escalated"],Ci=["open","waiting"];function ki(e){return yn.includes(e)}const En="assignment";function wi(e){return`${En}:${e}`}function Ni(e,t,n,r){if(e.direction==="inbound")return!0;if(e.author?.type==="user"&&e.author.id===t)return!1;const o=e.payload?.mentions;return Array.isArray(o)&&o.includes(t)||r&&r===t?!0:n==="reply"}function Ri(e){const{targetAuthorId:t,reactorId:n,agentId:r,on:o}=e;return!o||!t||t!==r?!1:n!==r}function vi(e){return e.subjectKind&&e.subjectId?{type:e.subjectKind,id:e.subjectId}:void 0}const _n=12;function Di(e,t,n=_n){const r=t+1;return e?e.kind==="done"?{status:"done",waitingOn:null,turns:r,reason:e.note}:e.kind==="escalate"?{status:"escalated",waitingOn:null,turns:r,reason:e.reason}:r>=n?{status:"escalated",waitingOn:null,turns:r,reason:`na ${n} beurten nog niet afgerond, dus een mens neemt het over`}:{status:"waiting",waitingOn:e.on,turns:r}:{status:"escalated",waitingOn:null,turns:r,reason:"de agent rondde zijn beurt af zonder te zeggen wat er moet gebeuren (wachten, afronden of overdragen)"}}function Sn(e){const t=e.trim().replace(/[\s-]/g,"");if(!/^\d+$/.test(t)||![8,12,13,14].includes(t.length))return;const n=t.padStart(14,"0");return xi(n.slice(0,13))===Number(n[13])?n:void 0}function xi(e){let t=0;for(let n=0;n<e.length;n++)t+=Number(e[n])*(n%2===0?3:1);return(10-t%10)%10}function Li(e,t){const n=t.trim(),r=Sn(n),o=[{sku:n},{barcodes:{$in:[n]}}];return r&&o.push({gtin:r}),{organizationId:e,$or:o}}function H(e){return e<0?-Math.round(-e):Math.round(e)}function An(e,t){if(t.length===0)return[];const n=t.reduce((u,l)=>u+l,0);if(n===0)return t.map((u,l)=>l===0?e:0);const r=t.map(u=>e*u/n),o=r.map(u=>Math.trunc(u));let i=e-o.reduce((u,l)=>u+l,0);const s=r.map((u,l)=>({index:l,fraction:Math.abs(u-o[l])})).sort((u,l)=>l.fraction-u.fraction),a=i<0?-1:1;for(let u=0;i!==0&&u<s.length;u++)o[s[u].index]+=a,i-=a;return o}function x(e,t={}){const n=t.decimal??",",r=t.group??".",o=e<0,i=Math.abs(Math.trunc(e)).toString().padStart(3,"0"),s=i.slice(0,-2),a=i.slice(-2);let u="";for(let l=0;l<s.length;l++)l>0&&(s.length-l)%3===0&&(u+=r),u+=s[l];return`${o?"-":""}${u}${n}${a}`}function Pi(e){const t=e.trim().replace(/[\s ]/g,"");if(!t)return;const n=t.replace(/^[-+]?[^\d.,-]*/,"").replace(/[^\d.,-]+$/,""),r=/^-/.test(t)||/-$/.test(t),o=n.replace(/-/g,"");if(!o||!/^[\d.,]+$/.test(o))return;const i=o.lastIndexOf(","),s=o.lastIndexOf("."),a=Math.max(i,s),u=a===-1?"":o.slice(a+1),l=a!==-1&&u.length>=1&&u.length<=2,d=l?o.slice(0,a):o;if(!$i(d))return;const c=d.replace(/[.,]/g,""),p=l?u.padEnd(2,"0"):"00";if(c==="")return;const f=Number(c)*100+Number(p);return r?-f:f}function $i(e){return/^\d+$/.test(e)?!0:e.includes(".")&&e.includes(",")?!1:/^\d{1,3}([.,]\d{3})*$/.test(e)}function Ki(e){return e.costPriceCents==null?e.netCents:e.netCents-H(e.costPriceCents*e.quantity)}const Ui=[{key:"contract",matches:(e,t)=>!!e.contractId&&e.contractId===t.contractId&&!!e.productId},{key:"customer",matches:(e,t)=>!e.contractId&&!!e.companyId&&e.companyId===t.companyId&&!!e.productId},{key:"customer_category",matches:(e,t)=>!e.contractId&&!!e.companyId&&e.companyId===t.companyId&&!!e.categoryKey},{key:"segment",matches:(e,t)=>!e.contractId&&!e.companyId&&!!e.segmentKey&&e.segmentKey===t.segmentKey&&!!e.productId},{key:"segment_category",matches:(e,t)=>!e.contractId&&!e.companyId&&!!e.segmentKey&&e.segmentKey===t.segmentKey&&!!e.categoryKey}];function Fi(e,t,n){const r=n.filter(o=>o.currency===e.currency&&(o.validFrom==null||o.validFrom<=t.at)&&(o.validTo==null||o.validTo>=t.at)&&(o.minQuantity==null||t.quantity>=o.minQuantity)&&(o.productId==null||o.productId===e.id)&&(o.categoryKey==null||o.categoryKey===e.categoryKey)&&(o.productId!=null||o.categoryKey!=null));for(const o of Ui){const i=r.filter(a=>o.matches(a,t));if(i.length===0)continue;const s=i.reduce((a,u)=>(u.minQuantity??0)>=(a.minQuantity??0)?u:a);return{unitPriceCents:Bi(s,e.listPriceCents),sourceKey:(s.minQuantity??0)>1?"tier":o.key,ruleId:s.id}}return{unitPriceCents:e.listPriceCents,sourceKey:"list"}}function Bi(e,t){return e.unitPriceCents!=null?e.unitPriceCents:e.discountPercent!=null?H(t*(1-e.discountPercent/100)):t}const Hi=["piece","hour","day","month","km","license"],Wi=new Set(["mail","message"]);function bn(e,t){const n=e.settings?.signatures?.[t];return!n?.enabled||!n.body||n.body.trim()===""?null:n}function Gi(e,t,n,r="html"){if(!e)return n;const o=bn(e,t);return o?`${n}${r==="text"?`
|
|
8
8
|
|
|
9
|
-
`:t==="mail"?"<br><br>-- <br>":"<br><br>"}${o.body}`:n}function ji(e){return e.endpoints??[]}function $(e){const t=(e??"").trim().toLowerCase();if(t)return t.split(/[-_]/)[0]||void 0}function Vi(e){return $(e.contactLocale)??$(e.companyLocale)??$(e.organizationLocale)}function Xi(e,t,n,r){const o=e.filter(a=>a.key===t&&!a.archived);if(o.length===0)return;const i=$(n),s=$(r);return o.find(a=>$(a.locale)===i)??o.find(a=>$(a.locale)===s)??o.find(a=>!a.locale)??o[0]}const Yi=/\{([a-zA-Z0-9_.]+)\}/g;function ot(e,t){let n=e;for(const r of t.split(".")){if(n==null||typeof n!="object")return;n=n[r]}return n}function zi(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Tn(e,t,n){const r=[];return{text:e.replace(Yi,(i,s)=>{const a=ot(t,s);return a==null||a===""?(r.includes(s)||r.push(s),n??`{${s}}`):zi(a)}),unresolved:r}}function In(e,t){if(!e)return!0;const n=ot(t,e.key);if(e.exists!==void 0){const r=n!=null&&n!==""&&n!==!1;return e.exists?r:!r}return e.equals!==void 0?n===e.equals:!0}function qi(e,t,n,r,o){const i=[],s=[],a=c=>{const u=Tn(c,t,o);for(const d of u.unresolved)i.includes(d)||i.push(d);return u.text};for(const c of e){if(c.block_id&&!In(n?.[c.block_id],t))continue;const u=c.block_id?r?.[c.block_id]:void 0;if(u){s.push(...u);continue}switch(c.type){case"heading":case"paragraph":case"quote":s.push({...c,text:a(c.text)});break;case"callout":s.push({...c,...c.title?{title:a(c.title)}:{},text:a(c.text)});break;case"code":s.push(c);break;case"list":s.push({...c,items:c.items.map(d=>({...d.lead?{lead:a(d.lead)}:{},text:a(d.text)}))});break;case"table":s.push({...c,columns:c.columns.map(d=>({...d,label:a(d.label)})),rows:c.rows.map(d=>d.map(a)),...c.caption?{caption:a(c.caption)}:{}});break;case"kpi":s.push({...c,items:c.items.map(d=>({...d,value:a(d.value),label:a(d.label)}))});break;case"letterhead":s.push({...c,fields:c.fields.map(d=>({...d,value:a(d.value)})),...c.recipient?{recipient:c.recipient.map(a)}:{}});break;case"totals":s.push({...c,rows:c.rows.map(d=>({...d,label:a(d.label),amount:a(d.amount)})),...c.taxRows?{taxRows:c.taxRows.map(d=>({...d,label:a(d.label),amount:a(d.amount)}))}:{}});break;case"image":s.push({...c,url:a(c.url),...c.alt?{alt:a(c.alt)}:{}});break;default:s.push(c)}}return{blocks:s,unresolved:i}}function Qi(e){const t=e?.billing,n=e?.address,r=e?.houseStyle,o=[n?.street,n?.houseNumber].filter(Boolean).join(" "),i=[n?.postalCode,n?.city].filter(Boolean).join(" ");return{name:t?.companyName||e?.name||e?.displayName||"",addressLines:[o,i,n?.country??""].filter(Boolean),footerLines:[r?.footerText??"",t?.kvkNumber?`KvK ${t.kvkNumber}`:"",t?.vatNumber?`Btw ${t.vatNumber}`:"",r?.iban?`IBAN ${r.iban}`:""].filter(Boolean),...e?.logo?{logo:e.logo}:{}}}const On=36e5,Mn=864e5,L=-1/0,Ji=e=>e.score>L,X={urgent:40,high:25,normal:10,low:0};function Zi(e){return Object.fromEntries(e.map(t=>[t.resourceId,t]))}const es=/(^|[._+-])(no-?reply|noreply|donotreply|do-not-reply|newsletter|nieuwsbrief|mailer|mailing|notifications?|bounce|postmaster|marketing)@/i,Cn=/\b(unsubscribe|afmelden|uitschrijven|opt[\s-]?out|manage (your )?preferences|geen (e-?mails?|nieuwsbrief|berichten) meer)\b/i;function kn(e,t){return!!(e&&es.test(e)||t&&Cn.test(t))}const wn=3,Nn=600;function ts(e,t){return e>=wn||t>=Nn}const Rn=["list-unsubscribe","list-unsubscribe-post","list-id","precedence","auto-submitted","x-auto-response-suppress","feedback-id","x-mailer"];function ns(e){const t={};for(const n of e){const r=n.name?.toLowerCase();r&&n.value!==void 0&&Rn.includes(r)&&(t[r]=n.value)}return t}const rs=/(^|[._+-])(no-?reply|noreply|donotreply|do-not-reply|notifications?|bounce|postmaster|mailer)@/i,os=/(^|[._+-])(newsletter|nieuwsbrief|marketing|mailing)@/i;function is(e){const t=e.headers??{},n=e.from?.email,r=t["auto-submitted"]?.toLowerCase();if(r&&r!=="no"||t["x-auto-response-suppress"]||n&&rs.test(n))return"automated";const o=t.precedence?.toLowerCase();if(t["list-unsubscribe"]||t["list-unsubscribe-post"]||t["list-id"]||o==="bulk"||o==="list"||e.body&&Cn.test(e.body)||n&&os.test(n))return"marketing"}function vn(e,t){return e.lastActivityAt?!(e.seenBy??[]).includes(t):!1}const Dn=["open"],xn=1e3,Ln={urgent:1,high:4,normal:8,low:24},Pn=72;function $n(e){return e.lastActivityAt??(e.createdAt?new Date(rn(e)).getTime():0)}function Kn(e,t){return Un(t.remindersById?.[e.id],e,t.now)}function Un(e,t,n){return!e||e.remindAt<=n?!1:!((t.lastActivityAt??0)>e.parkedAt&&t.lastActivityPreview?.direction==="inbound")}const Fn=e=>Zt(e)==="outbound_message",Bn=e=>Dn.includes(e);function Te(e,t){return Math.max(0,(t-$n(e))/On)}function Hn(e,t){const n=e.assignedInboxId?t?.[e.assignedInboxId]:void 0;return typeof n=="number"&&n>0?n:Ln[e.priority??"normal"]}function ss(e){const t={};for(const n of e)typeof n.slaHours=="number"&&n.slaHours>0&&(t[n.id]=n.slaHours);return t}function as(e,t,n){return!Bn(e.status)||e.firstResponseAt?!1:Te(e,t)>Hn(e,n)}function Wn(e,t){const n=e.lastActivityPreview;return n?.direction!=="outbound"||!Fn(n.type)?!1:Te(e,t)<Pn}function cs(e,t){if(!Bn(e.status))return{score:L,reasons:[]};if(e.snoozedTill&&e.snoozedTill>t.now)return{score:L,reasons:[]};if(Wn(e,t.now))return{score:L,reasons:[]};if(Kn(e,t))return{score:L,reasons:[]};let n=0;const r=[],o=e.priority??"normal";X[o]>0&&(n+=X[o],r.push(`priority:${o}`)),vn(e,t.userId)&&(n+=20,r.push("unseen")),e.assignedUserId&&e.assignedUserId===t.userId&&(n+=15,r.push("assigned-to-you"));const i=Te(e,t.now);if(i>0){const c=Math.min(i*2,30);n+=c,i>=1&&r.push(`waiting:${Math.round(i)}h`)}const s=e.lastActivityPreview;return s?.type==="AI_ACTION_PROPOSED"&&(n+=30,r.push("awaiting-approval")),s?.direction==="outbound"&&Fn(s.type)&&(n+=10,r.push("no-reply")),!e.firstResponseAt&&e.lastActivityPreview?.direction==="inbound"&&(n+=10,r.push("awaiting-reply")),(e.tags?.some(c=>c==="marketing"||c==="automated")||kn(e.remoteParty?.resource,e.lastActivityPreview?.snippet))&&(n-=xn,r.push("bulk")),{score:n,reasons:r}}const ls=e=>!!e.assignedUserId||!!e.assignedInboxId,us=e=>e.status==="closed",ds=e=>({urgent:10,high:5,normal:2,low:1})[e.priority]||0,ps=(e,t=30)=>e.title?.length<=t?e.title:`${e.title.substring(0,t)}...`;function fs(e,t){const n=e.labels??[];return n.find(r=>r.locale===t)?.label??n[0]?.label??e.url}function ms(e,t,n){const r=e.translations??[];return r.find(o=>o.locale===t)??(n?r.find(o=>o.locale===n):void 0)??{locale:t}}const me=[{code:"nl",label:"Nederlands",english:"Dutch"},{code:"en",label:"English",english:"English"},{code:"de",label:"Deutsch",english:"German"},{code:"fr",label:"Français",english:"French"},{code:"es",label:"Español",english:"Spanish"},{code:"it",label:"Italiano",english:"Italian"},{code:"pt",label:"Português",english:"Portuguese"},{code:"pl",label:"Polski",english:"Polish"},{code:"sv",label:"Svenska",english:"Swedish"},{code:"da",label:"Dansk",english:"Danish"},{code:"nb",label:"Norsk bokmål",english:"Norwegian Bokmål"},{code:"fi",label:"Suomi",english:"Finnish"},{code:"tr",label:"Türkçe",english:"Turkish"}];function Gn(e){const t=(e??"").toLowerCase();return me.find(n=>n.code===t)??me.find(n=>n.code===t.split("-")[0])}function gs(e){return Gn(e)?.label??e}function hs(e){const t=Gn(e);return t?t.english===t.label?`${t.english} (${t.code})`:`${t.english} — ${t.label} (${t.code})`:e}const it=3;function jn(e,t){const n=new Set;let r=1,o=t.get(e)?.parentId;for(;o;){if(n.has(o)||(n.add(o),r++,r>it+1))return 1/0;o=t.get(o)?.parentId}return r}function ys(e,t,n){if(!e)return!0;if(e===t)return!1;const r=new Map(n.map(s=>[s.id,s]));if(!r.has(e)||t&&Vn(e,t,r))return!1;const o=jn(e,r),i=t?st(t,n):1;return o+i<=it}function Vn(e,t,n){const r=new Set;let o=n.get(e)?.parentId;for(;o;){if(o===t)return!0;if(r.has(o))return!1;r.add(o),o=n.get(o)?.parentId}return!1}function st(e,t,n=new Set){if(n.has(e))return 1;n.add(e);const r=t.filter(o=>o.parentId===e);return r.length?1+Math.max(...r.map(o=>st(o.id,t,n))):1}const Xn="en";function Yn(e){return e.defaultLocale||e.locale||Xn}function Es(e){const t=new Set,n=[];for(const r of[Yn(e),...e.locales??[]])!r||t.has(r)||(t.add(r),n.push(r));return n}function _s(e,t,n){const r=e.translations??[];return r.find(o=>o.locale===t)?.name??(n?r.find(o=>o.locale===n)?.name:void 0)??e.name}const He=["lookup","condition","parallel","for-each"];function We(e){for(const t of e){if(!He.includes(t.type))return`staptype "${t.type}" mag niet meelezen (alleen ${He.join(", ")})`;if(t.type==="parallel")for(const n of t.branches??[]){const r=We(n);if(r)return r}if(t.type==="for-each"){const n=We(t.body??[]);if(n)return n}}return null}function Ss(e,t){switch(e.kind){case"org":return!0;case"team":return!!t.teamId&&e.teamId===t.teamId;case"personal":return e.userId===t.userId}}function As(e,t){return e.filter(n=>n.enabled&&Ss(n.ownerScope,t))}function bs(e){return e.credentialScope?e.credentialScope:(e.authMode??"header")==="header"||e.oauth?.scope==="org"?"shared":"per-user"}function Ts(e){return`mcp__${e}__`}const Is=1e3,Os=2e3,Ms=500,Cs=12e3,ks=4e3,zn=["contact","company","work_item"];function ws(e){if(!e)return!1;const t=e.slice(0,e.indexOf(":"));return zn.includes(t)}const Ns=[{key:"high",label:"tax_high",percent:21,kind:"standard"},{key:"low",label:"tax_low",percent:9,kind:"reduced"},{key:"zero",label:"tax_zero",percent:0,kind:"zero"},{key:"reverse_charge",label:"tax_reverse_charge",percent:0,kind:"reverse_charge"},{key:"exempt",label:"tax_exempt",percent:0,kind:"exempt"}];function qn(e,t){return t.find(n=>n.key===e)??{key:e,label:e,percent:0,kind:"zero"}}function Qn(e){if(e.kind!=="product")return 0;const t=1-(e.discountPercent??0)/100;return H(e.quantity*e.unitPriceCents*t)}function Rs(e,t,n){const r=e.map(u=>({...u,netCents:Qn(u),taxCents:0})),o=new Map;for(let u=0;u<r.length;u++){if(r[u].kind!=="product"||r[u].optional)continue;const d=n??r[u].taxRateKey,l=o.get(d);l?l.push(u):o.set(d,[u])}const i=[];let s=0,a=0;for(const[u,d]of o){const l=qn(u,t),p=d.reduce((m,b)=>m+r[b].netCents,0),f=H(p*l.percent/100),y=An(f,d.map(m=>r[m].netCents));for(let m=0;m<d.length;m++)r[d[m]].taxCents=y[m];i.push({taxRateKey:u,netCents:p,taxCents:f}),s+=p,a+=f}const c=r.reduce((u,d)=>d.costPriceCents==null||d.optional?u:u+H(d.costPriceCents*d.quantity),0);return{lines:r,totals:{netCents:s,taxCents:a,grossCents:s+a,costCents:c,byRate:i}}}const vs="onboarding-source",Ds=["support","billing","availability","sales","onboarding"],xs=["keep","replace"],Ie=[{key:"shift",label:"kind_shift",capacity:!0,productive:!1,absent:!1,icon:"calendar-clock"},{key:"allocation",label:"kind_allocation",capacity:!1,productive:!0,absent:!1,icon:"briefcase"},{key:"meeting",label:"kind_meeting",capacity:!1,productive:!1,absent:!1,icon:"users"},{key:"travel",label:"kind_travel",capacity:!1,productive:!1,absent:!1,icon:"car"},{key:"training",label:"kind_training",capacity:!1,productive:!1,absent:!1,icon:"graduation-cap"},{key:"break",label:"kind_break",capacity:!1,productive:!1,absent:!1,icon:"coffee"},{key:"absence",label:"kind_absence",capacity:!1,productive:!1,absent:!0,approvable:!0,icon:"palmtree"},{key:"sick",label:"kind_sick",capacity:!1,productive:!1,absent:!0,icon:"thermometer"},{key:"holiday",label:"kind_holiday",capacity:!1,productive:!1,absent:!0,icon:"party-popper"}],Jn={key:"unknown",label:"kind_unknown",capacity:!1,productive:!1,absent:!1};function R(e,t=Ie){return t.find(n=>n.key===e)??{...Jn,key:e}}function W(e){return e==="published"||e==="approved"}function at(e,t,n=Ie){if(e.workstreamId!==t)return!1;const r=R(e.kindKey,n);return r.absent?!1:r.productive||r.capacity}function Ls(e,t=Ie){if(!e.userId||!W(e.status))return!1;const n=R(e.kindKey,t);return n.capacity||n.productive||n.absent}const Ps=864e5;function Zn(e,t){return Math.round((t-e)/Ps)}function ct(e,t){const n=e.cycleMinutes.length;return n===0?0:(Zn(e.anchor,t)%n+n)%n}function lt(e,t){return e.effectiveFrom!==void 0&&t<e.effectiveFrom?0:e.cycleMinutes[ct(e,t)]??0}function ut(e,t){return e.startTimes?.[ct(e,t)]}function dt(e,t,n,r){const o=e.filter(a=>a.effectiveFrom===void 0||a.effectiveFrom<=r),i=a=>a.sort((c,u)=>(u.effectiveFrom??0)-(c.effectiveFrom??0))[0],s=i(o.filter(a=>a.userId===t));return s||i(o.filter(a=>!a.userId&&a.teamId&&n.includes(a.teamId)))}function er(e,t,n){return e.filter(r=>r.userId===t&&(r.effectiveFrom===void 0||r.effectiveFrom<=n)).sort((r,o)=>(o.effectiveFrom??0)-(r.effectiveFrom??0))[0]}const Ge=864e5;function $s(e){const t=Math.max(1,Math.round((e.to-e.from)/Ge));return Array.from({length:t},(n,r)=>e.from+r*Ge)}function je(e,t,n,r){const o=Math.min(t,r)-Math.max(e,n);return o>0?o/1e3:0}const Rt={interval:0,day:1,week:2};function Ks(e,t){const{entries:n,patterns:r=[],terms:o=[]}=t,i=n.filter(l=>l.userId&&W(l.status)&&R(l.kindKey).capacity),s=n.filter(l=>l.userId&&W(l.status)&&R(l.kindKey).absent),a=t.userIds??[...new Set([...i.map(l=>l.userId),...r.map(l=>l.userId),...o.map(l=>l.userId)])].filter(l=>!!l),c={};let u="interval";const d=l=>{Rt[l]>Rt[u]&&(u=l)};for(const l of a){const p=t.teamIdsOf?.(l)??[];let f=0,y=0,m=0;for(const g of $s(e)){const A=Math.max(g,e.from),v=Math.min(g+Ge,e.to);m++;const w=i.filter(M=>M.userId===l).reduce((M,bt)=>M+je(bt.start,bt.end,A,v),0);if(w>0){f+=w;continue}const C=dt(r,l,p,g),N=C?lt(C,g):0;if(C&&N>0){f+=N*60,d(ut(C,g)?"interval":"day");continue}C||y++}if(y>0){const g=er(o,l,e.from);g&&(f+=g.weeklyMinutes*60*(y/7),d("week"))}const b=s.filter(g=>g.userId===l).reduce((g,A)=>g+je(A.start,A.end,e.from,e.to),0),h=Math.max(0,f-b);(h>0||m>0)&&(c[l]=h)}return{seconds:Object.values(c).reduce((l,p)=>l+p,0),precision:u,byUser:c}}function Us(e,t){if(!e.some(a=>a.userId))return[];const n="",r=new Map;for(const a of e){const c=a.userId??n;r.set(c,(r.get(c)??0)+a.seconds)}const i=[...new Set([...Object.keys(t.byUser),...[...r.keys()].filter(a=>a!==n)])].map(a=>{const c=r.get(a)??0,u=t.byUser[a]??0;return{userId:a,requiredSeconds:c,capacitySeconds:u,netSeconds:u-c}});i.sort((a,c)=>a.netSeconds-c.netSeconds);const s=r.get(n)??0;return s>0&&i.push({requiredSeconds:s,capacitySeconds:0,netSeconds:-s}),i}function Fs(e,t,n,r){const o=e.filter(s=>s.userId&&W(s.status)&&!R(s.kindKey).absent),i=Object.entries(r.byUser).map(([s,a])=>{let c=0,u=0;for(const d of o){if(d.userId!==s||R(d.kindKey).capacity&&!d.workstreamId)continue;const l=je(d.start,d.end,n.from,n.to);l<=0||(at(d,t)?c+=l:u+=l)}return{userId:s,capacitySeconds:a,onThisSeconds:c,elsewhereSeconds:u,freeSeconds:Math.max(0,a-c-u)}});return i.sort((s,a)=>a.freeSeconds-s.freeSeconds),i}const Bs="demand-source",vt=1e3;function Hs(e,t){let n=1;for(let r=1;r<=e;r++)n=t*n/(r+t*n);return n}function tr(e,t){if(e<=0)return 1;if(t<=0)return 0;if(e<=t)return 1;const n=Hs(e,t),r=t/e;return n/(1-r*(1-n))}function nr(e,t,n,r){return r<=0?1:e<=t?0:1-tr(e,t)*Math.exp(-(e-t)*n/r)}function rr(e,t,n){return n<=0?0:e*t/n}function or(e,t,n,r){if(e<=0||t<=0)return 0;const o=rr(e,t,n);if(o<=0)return 0;const i=r.serviceLevelPercent/100,s=r.maxOccupancyPercent?r.maxOccupancyPercent/100:void 0;for(let a=Math.max(1,Math.ceil(o));a<=vt;a++)if(!(a<=o)&&!(nr(a,o,r.targetSeconds,t)<i)&&!(s&&o/a>s))return a;return vt}const Ws=36e5,Gs=864e5;function js(e){return e==="day"?Gs:Ws}function Vs(e,t){return e.start<t.end&&t.start<e.end}function re(e,t,n){const r=Math.min(e.end,n)-Math.max(e.start,t);return r>0?r/1e3:0}function ir(e,t,n){const r=e.handleSeconds??0,o=e.seconds??(e.volume!==void 0?e.volume*r:0);if(o<=0&&!e.volume)return{seconds:0,headcount:0};const i=(t.unplannedLossPercent??0)/100,s=i>0&&i<1?1/(1-i):1;if(t.model==="queue"&&e.volume!==void 0&&r>0){const a=or(e.volume,r,n,t);return{seconds:o,headcount:a*s}}return{seconds:o,headcount:o/n*s}}function Xs(e){const{entries:t,workstreamId:n,staffing:r,demand:o,range:i}=e,s=e.grain??"hour",a=js(s),c=a/1e3,u=e.kinds,d=t.filter(m=>W(m.status)),l=d.filter(m=>at(m,n,u)),p=d.filter(m=>R(m.kindKey,u).capacity),f=d.filter(m=>R(m.kindKey,u).absent),y=[];for(let m=B(i.from,s);m<i.to;m+=a){const b=m+a,h=F(m,s);let g=0;for(const M of l)g+=re(M,m,b);let A=0;for(const M of p)A+=re(M,m,b);let v=0;for(const M of f)v+=re(M,m,b);const w=o?.[h]??{},C=ir(w,r,c),N=g/c;y.push({period:h,forecastVolume:w.volume,requiredSeconds:C.seconds,requiredHeadcount:C.headcount,scheduledSeconds:g,scheduledHeadcount:N,netHeadcount:N-C.headcount,capacitySeconds:A,absentSeconds:v})}return y}function sr(e,t){return e.workTypeKey??t?.defaultWorkTypeKey}function Ys(e,t,n){const r=sr(e,t);return r?n.find(o=>o.key===r)?.defaultBillable??!1:!1}function zs(e){return e.filter(t=>t.netHeadcount<0&&t.requiredHeadcount>0)}const qs=36e5,Ve=6048e5,ar=8,Qs=.5,Js=2;function Zs(e){const t=Number(e.slice(0,4)),n=Number(e.slice(5,7)),r=Number(e.slice(8,10)),o=e.length>10?Number(e.slice(11,13)):0;return Date.UTC(t,n-1,r,o)}function ea(e,t,n){const r=[];for(let i=0;i<n;i++){const s=t-i*Ve,a=s-Ve;let c=0,u=!1;for(const[d,l]of e)d>=a&&d<s&&(c+=l,u=!0);u&&r.push(c)}if(r.length<2)return 1;const o=r.reduce((i,s)=>i+s,0)/r.length;return o<=0?1:Math.min(Js,Math.max(Qs,r[0]/o))}function ta(e,t){if(!e?.length)return;let n;for(const r of e)t>=r.from&&t<r.to&&(n=r);return n}function na(e,t,n){const r=Math.max(1,n?.weeks??ar),o=new Map,i=new Set;for(const c of e)o.set(Zs(c.period),c.value),i.add(c.period.slice(0,10));const s=ea(o,B(t.from,"hour"),r),a=[];for(let c=B(t.from,"hour");c<t.to;c+=qs){let u=0,d=0;for(let f=1;f<=r;f++){const y=c-f*Ve,b=o.get(y)??(i.has(F(y,"day"))?0:void 0);if(b===void 0)continue;const h=r-f+1;u+=b*h,d+=h}let l=d>0?u/d*s:0;const p=ta(n?.adjustments,c);p?.absoluteVolume!==void 0?l=p.absoluteVolume:p?.factor!==void 0&&(l*=p.factor),a.push({period:F(c,"hour"),volume:l})}return a}const cr="schedule_entry",lr="workstream";function ra(e){return`${cr}:${e}`}function oa(e){return`${lr}:${e}`}const Xe=36e5,U=864e5;function ia(e,t){const n=t==="day"?U:Xe,r=[];for(let o=B(e.from,t);o<e.to;o+=n)r.push(o);return r}function Dt(e){const t=Math.max(1,Math.round((e.to-e.from)/U));return Array.from({length:t},(n,r)=>e.from+r*U)}function Le(e,t,n,r){const o=Math.min(t,r)-Math.max(e,n);return o>0?o/1e3:0}function sa(e,t,n={}){const r=n.grain??"hour",o=ia(t,r),i=r==="day"?U:Xe,s=new Map(o.map(l=>[l,0])),a=e.filter(l=>l.userId&&R(l.kindKey).capacity),c=n.userIds?.length?new Set(n.userIds):null,u=new Set;for(const l of a)if(!(c&&l.userId&&!c.has(l.userId))){for(const p of o){const f=Le(l.start,l.end,p,p+i);f>0&&s.set(p,(s.get(p)??0)+f)}for(const p of Dt(t))Le(l.start,l.end,p,p+U)>0&&u.add(`${l.userId}:${p}`)}const d=n.userIds??[...new Set([...a.map(l=>l.userId),...(n.patterns??[]).map(l=>l.userId)])].filter(l=>!!l);if(n.patterns?.length)for(const l of d){const p=n.teamIdsOf?.(l)??[];for(const f of Dt(t)){if(u.has(`${l}:${f}`))continue;const y=dt(n.patterns,l,p,f);if(!y)continue;const m=lt(y,f);if(m<=0)continue;const b=ut(y,f);if(b){const[A,v]=b.split(":").map(Number),w=f+A*Xe+(v??0)*6e4,C=w+m*6e4;for(const N of o){const M=Le(w,C,N,N+i);M>0&&s.set(N,(s.get(N)??0)+M)}continue}const h=o.filter(A=>A>=f&&A<f+U);if(!h.length)continue;const g=m*60/h.length;for(const A of h)s.set(A,(s.get(A)??0)+g)}}return o.map(l=>({period:F(l,r),weight:s.get(l)??0}))}function ur(e,t){if(e<=0||!t.length)return[];const n=t.reduce((r,o)=>r+Math.max(0,o.weight),0);if(n<=0){const r=e/t.length;return t.map(o=>({period:o.period,seconds:r}))}return t.filter(r=>r.weight>0).map(r=>({period:r.period,seconds:e*r.weight/n}))}function aa(e,t,n){const r=new Map;for(const o of e){const i=o.by?t.filter(a=>n(a.period)<o.by):t,s=i.length?i:t;for(const a of ur(o.seconds,s)){const c=`${a.period}|${o.userId??""}`,u=r.get(c);u?u.seconds+=a.seconds:r.set(c,{...a,userId:o.userId})}}return[...r.values()].sort((o,i)=>o.period.localeCompare(i.period)||(o.userId??"").localeCompare(i.userId??""))}function dr(e){switch(e.kind){case"user":return`user:${e.userId}`;case"team":return`team:${e.teamId}`;case"org":return"org"}}function ca(e){if(typeof e!="string")return;const t=e.trim();if(t==="org")return{kind:"org"};const n=t.indexOf(":");if(n<=0)return;const r=t.slice(0,n),o=t.slice(n+1).trim();if(o){if(r==="user")return{kind:"user",userId:o};if(r==="team")return{kind:"team",teamId:o}}}function pr(e){return dr(e)}function fr(e){switch(e.kind){case"personal":return{kind:"user",userId:e.userId};case"team":return{kind:"team",teamId:e.teamId};case"org":return{kind:"org"}}}const mr=fr;function la(e){return e.agentId?{kind:"user",userId:e.agentId}:mr(e.ownerScope)}function ua(e){return pr(e)}function da(e,t){if(!t)return;let n=e;for(const r of t.split(".")){if(n===null||typeof n!="object")return;n=n[r]}return n}function pa(e,t){return e.targets.find(n=>n.activityTypes.includes(t))}function fa(e,t){if(t)return e.targets.find(n=>n.id===t)}function gr(e){return e?.kind==="assignment"}function ma(e){const{trigger:t,agentId:n,target:r,activityType:o,assigneeUserId:i,authorUserId:s}=e;return gr(t)?n?r?r.activityTypes.includes(o)?i?i!==n?"assigned to someone else":s&&s===n?"the agent assigned this to itself, which would restart its own run":null:`no assignee found at ${r.assigneePath}`:`activity type ${o} does not announce an assignment for ${r.id}`:`assignment target kind "${t.targetKind}" is not declared by any installed app`:"this playbook has no agent, so an assignment can never be for it":"trigger is not an assignment trigger"}function ga(e){return(e.startsWith("tool:")?e.slice(5):e).replace(/__/g," · ").replace(/\./g," · ").replace(/_/g," ")}const ha=[{name:"text",type:"string"},{name:"subject",type:"string"},{name:"from",type:"string"},{name:"type",type:"string"},{name:"direction",type:"string"},{name:"channelId",type:"string"},{name:"interactionId",type:"string"},{name:"itemId",type:"string"},{name:"activityId",type:"string"},{name:"authorType",type:"string"},{name:"authorName",type:"string"},{name:"textRaw",type:"string"},{name:"fromStatus",type:"string"},{name:"toStatus",type:"string"},{name:"toCategory",type:"string"},{name:"contactId",type:"string"},{name:"companyId",type:"string"},{name:"priority",type:"string"},{name:"inboxId",type:"string"},{name:"topicId",type:"string"},{name:"assigneeUserId",type:"string"}],ya={topics:[{name:"topicId",type:"string"},{name:"topic",type:"string"},{name:"confidence",type:"number"},{name:"reasoning",type:"string"}],question:[{name:"answer",type:"boolean"},{name:"reasoning",type:"string"}],extract:[]};function hr(e){return`${e.type}:${e.id}`}const yr="interaction";function Er(e){return e?.type===yr?e.id:void 0}const _r=64,Sr=8e3;function Ea(e){const t=typeof e=="number"?e:Number(String(e??"").trim());if(!(!Number.isFinite(t)||t<=0))return Math.min(Math.max(Math.round(t),_r),Sr)}const _a={kind:"workflow",steps:[]};function Sa(e){return e?.kind==="workflow"?e.steps:[]}function Aa(e){return e?.kind==="procedure"?e.procedure:void 0}function Ar(e){const t=e?.approved??0,n=t+(e?.rejected??0);return{total:n,rate:n?t/n:0}}const br=10,Tr=.9;function ba(e){const{total:t,rate:n}=Ar(e);return t>=br&&n>=Tr}const Ir=["done","escalated","failed","stopped"];function Ta(e){return Ir.includes(e)}function Or(e){return e==="waiting"}function Ia(e){return e==="running"||Or(e)}function pt(e){return e.subjectKind&&e.subjectId?{type:e.subjectKind,id:e.subjectId}:void 0}function Oa(e){const t=pt(e);return t?hr(t):void 0}function Ma(e){return Er(pt(e))}function Ca(e){const t=[],n=new Map;for(const r of[...e].sort(ka)){const o=n.get(r.emoji);if(o){o.push(r.actor);continue}t.push(r.emoji),n.set(r.emoji,[r.actor])}return t.map(r=>{const o=n.get(r);return{emoji:r,count:o.length,actors:o}}).sort((r,o)=>o.count-r.count||t.indexOf(r.emoji)-t.indexOf(o.emoji))}const ka=(e,t)=>(e.createdAt??0)-(t.createdAt??0);function wa(e,t){return t?e.actors.some(n=>n.type==="user"&&n.id===t):!1}const Ye=6e4,Na=36e5,Y=864e5,Mr=800;function xt(e,t){const n=Date.UTC(e,t+1,0);return n-new Date(n).getUTCDay()*Y+Na}function Ra(e){const t=new Date(e).getUTCFullYear();return e>=xt(t,2)&&e<xt(t,9)}function Cr(e,t){const n=t.dst==="eu"&&Ra(e)?60:0;return(t.utcOffsetMinutes+n)*Ye}function va(e){return(e+3)%7+1}function kr(e,t){const n=Cr(e,t),r=e+n,o=Math.floor(r/Y);if(!t.days.includes(va(o)))return null;const i=o*Y;return{open:i+t.fromMinutes*Ye-n,close:i+t.toMinutes*Ye-n}}function wr(e,t){const n=Cr(e,t),r=e+n;return(Math.floor(r/Y)+1)*Y-n}function ge(e,t,n){if(t<=e)return 0;if(!n)return t-e;let r=0,o=e;for(let i=0;i<Mr&&o<t;i++){const s=kr(o,n);if(s){const a=Math.max(o,s.open),c=Math.min(t,s.close);c>a&&(r+=c-a)}o=wr(o,n)}return r}function Oe(e,t,n){if(!n)return e+t;let r=t,o=e;for(let i=0;i<Mr;i++){const s=kr(o,n);if(s){const a=Math.max(o,s.open);if(s.close>a){const c=s.close-a;if(r<=c)return a+r;r-=c}}o=wr(o,n)}return e+t}function Da(e){const t=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(e);return t?Number(t[1])*60+Number(t[2]):null}const he=1,ye=2;function xa(e){return e==="snoozed"?he:ye}function Me(e){const t=e.calendar;return t&&Array.isArray(t.days)?t:null}const La=["speed_of_answer","first_response","next_response","resolution","close"],Pa=["snoozed","waiting_for_customer"],$a=6e4,Nr=["speed_of_answer","first_response","next_response"],Ka=[...Nr,"resolution","close"];function q(e){return e.state==="running"||e.state==="paused"}function Ua(e,t){return q(e)?{state:(e.state==="paused"?e.remainingMs>0:t<=e.dueAt)?"hit":"missed",settledAt:Math.max(t,e.startedAt)}:null}function Lt(e){return q(e)?{state:"void"}:null}function Fa(e,t,n,r){if(!q(e)||(e.pauseBits&t)!==0)return null;const o=e.pauseBits|t;return e.state==="paused"?{pauseBits:o}:{pauseBits:o,state:"paused",remainingMs:ge(n,e.dueAt,r)}}function Ba(e,t,n,r){if(!q(e)||(e.pauseBits&t)===0)return null;const o=e.pauseBits&~t;return o!==0?{pauseBits:o}:{pauseBits:o,state:"running",dueAt:Oe(n,e.remainingMs,r)}}function Ha({event:e,at:t,now:n,clocks:r,profile:o}){const i=Me(o),s=Math.min(t,n),a=r.map(h=>({...h})),c=[],u=(h,g)=>{g&&(c.push({op:"patch",clockId:h.id,patch:g}),Object.assign(h,g))},d=h=>{for(const g of a)g.metric===h&&u(g,Ua(g,s))},l=h=>{for(const g of a)h.includes(g.metric)&&u(g,Lt(g))},p=h=>{for(const g of a)u(g,Fa(g,h,s,i))},f=h=>{for(const g of a)u(g,Ba(g,h,s,i))},y=h=>a.reduce((g,A)=>A.metric===h?Math.max(g,A.attempt):g,0)+1,m=h=>a.some(g=>g.metric===h&&q(g)),b=(h,g)=>{const A=o.targets.find(w=>w.metric===h);if(!A)return;const v=A.minutes*$a;c.push({op:"start",metric:h,attempt:y(h),startedAt:g,targetMs:v,dueAt:Oe(g,v,i)})};switch(e){case"apply":{for(const h of a)h.profileId!==o.id&&u(h,Lt(h));for(const h of o.targets){if(h.metric==="next_response")continue;a.some(A=>A.metric===h.metric&&A.profileId===o.id)||b(h.metric,s)}break}case"answered":d("speed_of_answer");break;case"outbound":{d("first_response"),d("next_response"),o.pauseOn.includes("waiting_for_customer")&&p(ye);break}case"inbound":{f(ye),!m("first_response")&&!m("next_response")&&b("next_response",s);break}case"resolved":d("resolution");break;case"closed":d("close"),d("resolution"),l(Nr);break;case"reopened":m("resolution")||b("resolution",s),m("close")||b("close",s);break;case"snoozed":o.pauseOn.includes("snoozed")&&p(he);break;case"unsnoozed":f(he);break;case"discarded":l(Ka);break}return c}function Rr(e){return e.state==="running"||e.state==="paused"}function Ee(e,t){const n=Me(e);return e.state==="paused"?e.remainingMs:t>=e.dueAt?-ge(e.dueAt,t,n):ge(t,e.dueAt,n)}function Wa(e,t){return e.state==="paused"?Oe(t,e.remainingMs,Me(e)):e.dueAt}function Ga(e,t){const n=e.filter(Rr);if(!n.length)return;const r=n.filter(i=>i.state==="running");return(r.length?r:n).reduce((i,s)=>Ee(s,t)<Ee(i,t)?s:i)}function ja(e,t){if(e.state==="missed")return"breached";if(e.state==="hit")return"met";if(e.state==="paused")return"paused";if(e.state==="void")return"met";const n=Ee(e,t);return n<=0?"breached":n<=e.targetMs/5?"urgent":"running"}function Va(e){const t=Math.floor(Math.abs(e)/1e3),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),o=Math.floor(t%3600/60);return n?r?`${n}d ${r}u`:`${n}d`:r?o?`${r}u ${o}m`:`${r}u`:o?`${o}m`:`${t%60}s`}const vr="strategy_item";function ft(e){return`${vr}:${e}`}function Xa(e,t=25){const n=new Set([ft(e.id)]);for(const r of e.ancestorKeys??[])n.add(r);return Array.from(n).slice(0,t)}function Ya(e){return e?[...e.ancestorKeys??[],ft(e.id)]:[]}const Q=[{key:"area",label:"level_area",order:10,measurable:!1,icon:"compass"},{key:"objective",label:"level_objective",order:20,measurable:!0,icon:"target"},{key:"key_result",label:"level_key_result",order:30,measurable:!0,icon:"gauge"}],Dr=999,xr=7;function Lr(e,t=Q){return t.find(n=>n.key===e)}function _e(e,t=Q){return Lr(e,t)?.order??Dr}function za(e,t,n=Q){return _e(t,n)<=_e(e,n)}function qa(e,t=Q){const n=_e(e,t);return t.filter(o=>o.order>n).sort((o,i)=>o.order-i.order)[0]?.key??e}function Qa(e){const t=e.trim().toLowerCase();return t?t.includes("key result")||t.includes("keyresult")||t==="kr"?"key_result":t.includes("objective")||t.includes("goal")||t.includes("doel")?"objective":t.includes("focus")||t.includes("area")||t.includes("theme")?"area":null:null}const ze={pending:"open",on_track:"open",at_risk:"open",off_track:"open",paused:"paused",achieved:"closed",missed:"closed"};function Ja(e){return ze[e]??"open"}function Za(e){return Object.keys(ze).filter(t=>e.includes(ze[t]))}const ec=864e5,Ce=e=>e<=0?0:e>1?1:e;function tc(e,t){const{direction:n}=e,r=e.startValue??0,o=e.targetValue??0;if(!Number.isFinite(t))return 0;const i=n==="down"?t<=o:t>=o,s=o-r;return(n==="down"?s<0:s>0)?Ce((t-r)/s):i?1:0}function nc(e,t){const{startDate:n,targetDate:r}=e;if(!(typeof n!="number"||typeof r!="number")&&!(r<=n))return Ce((t-n)/(r-n))}const Pr=.1,$r=.25;function rc(e,t){if(typeof e!="number"||typeof t!="number")return;if(e>=1)return"achieved";const n=t-e;return n>=$r?"off_track":n>=Pr?"at_risk":"on_track"}function oc(e,t){if(t)return Ce(e/t)}function ic(e){const t=e.map(n=>n.progress?.ratio).filter(n=>typeof n=="number"&&Number.isFinite(n));if(t.length)return Ce(t.reduce((n,r)=>n+r,0)/t.length)}function sc(e,t){const n=e.lastCheckInAt??e.createdAt;if(typeof n!="number")return 0;const r=(e.checkInEveryDays??xr)*ec,o=t-n-r;return o>0?o:0}function ac(e){return e.targetDate??Number.MAX_SAFE_INTEGER}function cc(e,t){const n=e.accumulatedSeconds||0;return e.runningSince?n+Math.max(0,Math.floor((t-e.runningSince)/1e3)):n}function lc(e,t){const n=Math.max(1,Math.ceil(Math.max(0,e)/60));if(!t||t==="exact")return n*60;const r=Number(t);return!Number.isFinite(r)||r<=0?n*60:Math.ceil(n/r)*r*60}function uc(e){const t=Math.max(0,Math.round(e/60));return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function dc(e){const t=Math.max(0,Math.floor(e)),n=i=>String(i).padStart(2,"0"),r=Math.floor(t/60)%60,o=Math.floor(t/3600);return o>0?`${o}:${n(r)}:${n(t%60)}`:`${n(r)}:${n(t%60)}`}function Kr(e){return(e||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").slice(0,48).replace(/^-+|-+$/g,"")}function pc(e,t){const n=Kr(e)||"werksoort",r=new Set(t);if(!r.has(n))return n;for(let o=2;o<500;o++){const i=`${n}-${o}`;if(!r.has(i))return i}return`${n}-${r.size+1}`}function fc(e,t){const n=e.ownerScope;return!n||n.kind==="org"?!0:t.includes(n.teamId)}function mc(e){return e.filter(t=>!t.archived).sort(Ur)}function Ur(e,t){const n=(e.order??0)-(t.order??0);return n!==0?n:(e.label||"").localeCompare(t.label||"")}const Fr=20,Br=20,oe=300;function P(e){return e.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function Hr(e){const t=e.replace(/\s+/g," ").trim();if(t.length<=oe)return t;const n=t.slice(0,oe),r=Math.max(n.lastIndexOf(". "),n.lastIndexOf("! "),n.lastIndexOf("? "));return r>oe*.6?n.slice(0,r+1):`${n.trimEnd()}…`}function gc(e,t){const n=Hr(t.text),r=P(n);if(!r||(e.examples??[]).some(s=>P(s)===r))return null;const o=e.exampleCandidates??[],i=o.findIndex(s=>P(s.text)===r);if(i>=0){if(o[i].corrected||!t.corrected)return null;const s=[...o];return s[i]={...s[i],corrected:!0,addedAt:t.addedAt},Pt(s)}return Pt([{...t,text:n},...o]).slice(0,Br)}function Pt(e){return[...e].sort((t,n)=>Number(n.corrected)-Number(t.corrected)||n.addedAt-t.addedAt)}function hc(e,t){const n=P(t),r=(e.examples??[]).filter(i=>i.trim());return{examples:r.some(i=>P(i)===n)?r:[...r,t].slice(-Fr),exampleCandidates:Wr(e,t)}}function Wr(e,t){const n=P(t);return(e.exampleCandidates??[]).filter(r=>P(r.text)!==n)}function Gr(e,t){const n=e.ownerScope;return n?n.kind==="org"?!0:n.kind==="team"?!!t&&n.teamId===t:!1:!1}function yc(e,t){return e.filter(n=>Gr(n,t))}const mt=[{key:"quote",label:"kind_quote",numbered:!1,signFlip:!1,statuses:["draft","sent","accepted","rejected","expired","cancelled"]},{key:"order",label:"kind_order",numbered:!1,signFlip:!1,statuses:["draft","confirmed","delivered","cancelled"]},{key:"invoice",label:"kind_invoice",numbered:!0,signFlip:!1,statuses:["draft","open","paid","overdue","cancelled"]},{key:"credit_note",label:"kind_credit_note",numbered:!0,signFlip:!0,statuses:["draft","open","settled","cancelled"]}];function Se(e){return mt.find(t=>t.key===e)??{key:e,label:e,numbered:!1,signFlip:!1,statuses:["draft"]}}function Ec(e){return e.issuedAt!=null}const _c=["status","fileRef","number","externalIds","postedAt","dunning","updatedAt"];function jr(e,t){const n=Se(t).signFlip!==Se(e.kindKey).signFlip,r=e.lines.map(o=>({...o,quantity:n?-o.quantity:o.quantity,netCents:0,taxCents:0}));return{kindKey:t,sourceTransactionId:e.id,agreementId:e.agreementId,version:1,companyId:e.companyId,contactId:e.contactId,dealItemId:e.dealItemId,ownerScope:e.ownerScope,ownerUserId:e.ownerUserId,title:e.title,reference:e.reference,currency:e.currency,status:"draft",lines:r,totals:{netCents:0,taxCents:0,grossCents:0,byRate:[]},taxOverrideKey:e.taxOverrideKey,introText:e.introText,termsText:e.termsText,source:e.source}}function Sc(e){return{...jr(e,e.kindKey),sourceTransactionId:e.sourceTransactionId,previousVersionId:e.id,version:e.version+1,lines:e.lines.map(n=>({...n})),totals:e.totals}}function Ac(e,t={}){const n=Se(e.kindKey),r=e.totals??{netCents:0,taxCents:0,grossCents:0};return{customer:{name:t.companyName??"",contact:t.contactName??"",address:Ic(t.companyAddress),street:t.companyAddress?.street??"",house_number:t.companyAddress?.houseNumber??"",postal_code:t.companyAddress?.postalCode??"",city:t.companyAddress?.city??"",country:t.companyAddress?.country??""},organization:{name:t.organizationName??""},[n.key]:{number:e.number??"",title:e.title??"",reference:e.reference??"",version:String(e.version??1),date:$t(e.issuedAt),valid_until:$t(e.expiresAt)},totals:{net:x(r.netCents),tax:x(r.taxCents),gross:x(r.grossCents)}}}function bc(e,t=[],n=Vr){const r=e.totals??{netCents:0,grossCents:0,byRate:[]},o=a=>t.find(c=>c.key===a)?.percent??0,i={block_id:"lines",type:"table",columns:[{label:n.description},{label:n.quantity,align:"right"},{label:n.unitPrice,align:"right"},{label:n.net,align:"right"}],rows:(e.lines??[]).map(a=>a.kind==="text"?[a.name,"","",""]:[Tc(a.name,a.description,a.optional,n.optional),Oc(a.quantity),x(a.unitPriceCents),x(a.netCents)])},s={block_id:"totals",type:"totals",rows:[{label:n.net,amount:x(r.netCents)},{label:n.gross,amount:x(r.grossCents),emphasis:!0}],taxRows:r.byRate.map(a=>({label:`${n.tax} ${o(a.taxRateKey)}%`,amount:x(a.taxCents)}))};return{lines:[i],totals:[s]}}const Vr={description:"Omschrijving",optional:"optioneel",quantity:"Aantal",unitPrice:"Stuksprijs",net:"Netto",tax:"Btw",gross:"Totaal"};function Tc(e,t,n,r){const o=t?`${e} — ${t}`:e;return n?`${o} (${r})`:o}function Ic(e){return e?.street?[e.street,e.houseNumber].filter(Boolean).join(" "):""}function Oc(e){return Number.isInteger(e)?String(e):String(e).replace(".",",")}function $t(e){if(!e)return"";const t=new Date(e),n=r=>String(r).padStart(2,"0");return`${n(t.getDate())}-${n(t.getMonth()+1)}-${t.getFullYear()}`}const Mc=[{block_id:"head",type:"letterhead",fields:[{key:"number",label:"Offertenummer",value:"{quote.number}"},{key:"date",label:"Datum",value:"{quote.date}"},{key:"valid_until",label:"Geldig tot",value:"{quote.valid_until}"},{key:"reference",label:"Referentie",value:"{quote.reference}"}],recipient:["{customer.name}","{customer.contact}","{customer.address}","{customer.postal_code} {customer.city}"]},{block_id:"title",type:"heading",level:1,text:"{quote.title}"},{block_id:"intro",type:"paragraph",text:`Beste {customer.contact},
|
|
9
|
+
`:t==="mail"?"<br><br>-- <br>":"<br><br>"}${o.body}`:n}function ji(e){return e.endpoints??[]}function $(e){const t=(e??"").trim().toLowerCase();if(t)return t.split(/[-_]/)[0]||void 0}function Vi(e){return $(e.contactLocale)??$(e.companyLocale)??$(e.organizationLocale)}function Xi(e,t,n,r){const o=e.filter(a=>a.key===t&&!a.archived);if(o.length===0)return;const i=$(n),s=$(r);return o.find(a=>$(a.locale)===i)??o.find(a=>$(a.locale)===s)??o.find(a=>!a.locale)??o[0]}const Yi=/\{([a-zA-Z0-9_.]+)\}/g;function ot(e,t){let n=e;for(const r of t.split(".")){if(n==null||typeof n!="object")return;n=n[r]}return n}function zi(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Tn(e,t,n){const r=[];return{text:e.replace(Yi,(i,s)=>{const a=ot(t,s);return a==null||a===""?(r.includes(s)||r.push(s),n??`{${s}}`):zi(a)}),unresolved:r}}function In(e,t){if(!e)return!0;const n=ot(t,e.key);if(e.exists!==void 0){const r=n!=null&&n!==""&&n!==!1;return e.exists?r:!r}return e.equals!==void 0?n===e.equals:!0}function qi(e,t,n,r,o){const i=[],s=[],a=new Set,u=l=>{const d=Tn(l,t,o);for(const c of d.unresolved)i.includes(c)||i.push(c);return d.text};for(const l of e){if(l.block_id&&!In(n?.[l.block_id],t))continue;const d=l.block_id?r?.[l.block_id]:void 0;if(d&&l.block_id){a.add(l.block_id),s.push(...d);continue}switch(l.type){case"heading":case"paragraph":case"quote":s.push({...l,text:u(l.text)});break;case"callout":s.push({...l,...l.title?{title:u(l.title)}:{},text:u(l.text)});break;case"code":s.push(l);break;case"list":s.push({...l,items:l.items.map(c=>({...c.lead?{lead:u(c.lead)}:{},text:u(c.text)}))});break;case"table":s.push({...l,columns:l.columns.map(c=>({...c,label:u(c.label)})),rows:l.rows.map(c=>c.map(u)),...l.caption?{caption:u(l.caption)}:{}});break;case"kpi":s.push({...l,items:l.items.map(c=>({...c,value:u(c.value),label:u(c.label)}))});break;case"letterhead":s.push({...l,fields:l.fields.map(c=>({...c,value:u(c.value)})),...l.recipient?{recipient:l.recipient.map(u)}:{}});break;case"totals":s.push({...l,rows:l.rows.map(c=>({...c,label:u(c.label),amount:u(c.amount)})),...l.taxRows?{taxRows:l.taxRows.map(c=>({...c,label:u(c.label),amount:u(c.amount)}))}:{}});break;case"image":s.push({...l,url:u(l.url),...l.alt?{alt:u(l.alt)}:{}});break;default:s.push(l)}}return{blocks:s,unresolved:i,unusedSlots:Object.keys(r??{}).filter(l=>!a.has(l))}}function Qi(e){const t=e?.billing,n=e?.address,r=e?.houseStyle,o=[n?.street,n?.houseNumber].filter(Boolean).join(" "),i=[n?.postalCode,n?.city].filter(Boolean).join(" ");return{name:t?.companyName||e?.name||e?.displayName||"",addressLines:[o,i,n?.country??""].filter(Boolean),footerLines:[r?.footerText??"",t?.kvkNumber?`KvK ${t.kvkNumber}`:"",t?.vatNumber?`Btw ${t.vatNumber}`:"",r?.iban?`IBAN ${r.iban}`:""].filter(Boolean),...e?.logo?{logo:e.logo}:{}}}const On=36e5,Mn=864e5,L=-1/0,Ji=e=>e.score>L,X={urgent:40,high:25,normal:10,low:0};function Zi(e){return Object.fromEntries(e.map(t=>[t.resourceId,t]))}const es=/(^|[._+-])(no-?reply|noreply|donotreply|do-not-reply|newsletter|nieuwsbrief|mailer|mailing|notifications?|bounce|postmaster|marketing)@/i,Cn=/\b(unsubscribe|afmelden|uitschrijven|opt[\s-]?out|manage (your )?preferences|geen (e-?mails?|nieuwsbrief|berichten) meer)\b/i;function kn(e,t){return!!(e&&es.test(e)||t&&Cn.test(t))}const wn=3,Nn=600;function ts(e,t){return e>=wn||t>=Nn}const Rn=["list-unsubscribe","list-unsubscribe-post","list-id","precedence","auto-submitted","x-auto-response-suppress","feedback-id","x-mailer"];function ns(e){const t={};for(const n of e){const r=n.name?.toLowerCase();r&&n.value!==void 0&&Rn.includes(r)&&(t[r]=n.value)}return t}const rs=/(^|[._+-])(no-?reply|noreply|donotreply|do-not-reply|notifications?|bounce|postmaster|mailer)@/i,os=/(^|[._+-])(newsletter|nieuwsbrief|marketing|mailing)@/i;function is(e){const t=e.headers??{},n=e.from?.email,r=t["auto-submitted"]?.toLowerCase();if(r&&r!=="no"||t["x-auto-response-suppress"]||n&&rs.test(n))return"automated";const o=t.precedence?.toLowerCase();if(t["list-unsubscribe"]||t["list-unsubscribe-post"]||t["list-id"]||o==="bulk"||o==="list"||e.body&&Cn.test(e.body)||n&&os.test(n))return"marketing"}function vn(e,t){return e.lastActivityAt?!(e.seenBy??[]).includes(t):!1}const Dn=["open"],xn=1e3,Ln={urgent:1,high:4,normal:8,low:24},Pn=72;function $n(e){return e.lastActivityAt??(e.createdAt?new Date(rn(e)).getTime():0)}function Kn(e,t){return Un(t.remindersById?.[e.id],e,t.now)}function Un(e,t,n){return!e||e.remindAt<=n?!1:!((t.lastActivityAt??0)>e.parkedAt&&t.lastActivityPreview?.direction==="inbound")}const Fn=e=>Zt(e)==="outbound_message",Bn=e=>Dn.includes(e);function Te(e,t){return Math.max(0,(t-$n(e))/On)}function Hn(e,t){const n=e.assignedInboxId?t?.[e.assignedInboxId]:void 0;return typeof n=="number"&&n>0?n:Ln[e.priority??"normal"]}function ss(e){const t={};for(const n of e)typeof n.slaHours=="number"&&n.slaHours>0&&(t[n.id]=n.slaHours);return t}function as(e,t,n){return!Bn(e.status)||e.firstResponseAt?!1:Te(e,t)>Hn(e,n)}function Wn(e,t){const n=e.lastActivityPreview;return n?.direction!=="outbound"||!Fn(n.type)?!1:Te(e,t)<Pn}function cs(e,t){if(!Bn(e.status))return{score:L,reasons:[]};if(e.snoozedTill&&e.snoozedTill>t.now)return{score:L,reasons:[]};if(Wn(e,t.now))return{score:L,reasons:[]};if(Kn(e,t))return{score:L,reasons:[]};let n=0;const r=[],o=e.priority??"normal";X[o]>0&&(n+=X[o],r.push(`priority:${o}`)),vn(e,t.userId)&&(n+=20,r.push("unseen")),e.assignedUserId&&e.assignedUserId===t.userId&&(n+=15,r.push("assigned-to-you"));const i=Te(e,t.now);if(i>0){const u=Math.min(i*2,30);n+=u,i>=1&&r.push(`waiting:${Math.round(i)}h`)}const s=e.lastActivityPreview;return s?.type==="AI_ACTION_PROPOSED"&&(n+=30,r.push("awaiting-approval")),s?.direction==="outbound"&&Fn(s.type)&&(n+=10,r.push("no-reply")),!e.firstResponseAt&&e.lastActivityPreview?.direction==="inbound"&&(n+=10,r.push("awaiting-reply")),(e.tags?.some(u=>u==="marketing"||u==="automated")||kn(e.remoteParty?.resource,e.lastActivityPreview?.snippet))&&(n-=xn,r.push("bulk")),{score:n,reasons:r}}const ls=e=>!!e.assignedUserId||!!e.assignedInboxId,us=e=>e.status==="closed",ds=e=>({urgent:10,high:5,normal:2,low:1})[e.priority]||0,ps=(e,t=30)=>e.title?.length<=t?e.title:`${e.title.substring(0,t)}...`;function fs(e,t){const n=e.labels??[];return n.find(r=>r.locale===t)?.label??n[0]?.label??e.url}function ms(e,t,n){const r=e.translations??[];return r.find(o=>o.locale===t)??(n?r.find(o=>o.locale===n):void 0)??{locale:t}}const me=[{code:"nl",label:"Nederlands",english:"Dutch"},{code:"en",label:"English",english:"English"},{code:"de",label:"Deutsch",english:"German"},{code:"fr",label:"Français",english:"French"},{code:"es",label:"Español",english:"Spanish"},{code:"it",label:"Italiano",english:"Italian"},{code:"pt",label:"Português",english:"Portuguese"},{code:"pl",label:"Polski",english:"Polish"},{code:"sv",label:"Svenska",english:"Swedish"},{code:"da",label:"Dansk",english:"Danish"},{code:"nb",label:"Norsk bokmål",english:"Norwegian Bokmål"},{code:"fi",label:"Suomi",english:"Finnish"},{code:"tr",label:"Türkçe",english:"Turkish"}];function Gn(e){const t=(e??"").toLowerCase();return me.find(n=>n.code===t)??me.find(n=>n.code===t.split("-")[0])}function gs(e){return Gn(e)?.label??e}function hs(e){const t=Gn(e);return t?t.english===t.label?`${t.english} (${t.code})`:`${t.english} — ${t.label} (${t.code})`:e}const it=3;function jn(e,t){const n=new Set;let r=1,o=t.get(e)?.parentId;for(;o;){if(n.has(o)||(n.add(o),r++,r>it+1))return 1/0;o=t.get(o)?.parentId}return r}function ys(e,t,n){if(!e)return!0;if(e===t)return!1;const r=new Map(n.map(s=>[s.id,s]));if(!r.has(e)||t&&Vn(e,t,r))return!1;const o=jn(e,r),i=t?st(t,n):1;return o+i<=it}function Vn(e,t,n){const r=new Set;let o=n.get(e)?.parentId;for(;o;){if(o===t)return!0;if(r.has(o))return!1;r.add(o),o=n.get(o)?.parentId}return!1}function st(e,t,n=new Set){if(n.has(e))return 1;n.add(e);const r=t.filter(o=>o.parentId===e);return r.length?1+Math.max(...r.map(o=>st(o.id,t,n))):1}const Xn="en";function Yn(e){return e.defaultLocale||e.locale||Xn}function Es(e){const t=new Set,n=[];for(const r of[Yn(e),...e.locales??[]])!r||t.has(r)||(t.add(r),n.push(r));return n}function _s(e,t,n){const r=e.translations??[];return r.find(o=>o.locale===t)?.name??(n?r.find(o=>o.locale===n)?.name:void 0)??e.name}const He=["lookup","condition","parallel","for-each"];function We(e){for(const t of e){if(!He.includes(t.type))return`staptype "${t.type}" mag niet meelezen (alleen ${He.join(", ")})`;if(t.type==="parallel")for(const n of t.branches??[]){const r=We(n);if(r)return r}if(t.type==="for-each"){const n=We(t.body??[]);if(n)return n}}return null}function Ss(e,t){switch(e.kind){case"org":return!0;case"team":return!!t.teamId&&e.teamId===t.teamId;case"personal":return e.userId===t.userId}}function As(e,t){return e.filter(n=>n.enabled&&Ss(n.ownerScope,t))}function bs(e){return e.credentialScope?e.credentialScope:(e.authMode??"header")==="header"||e.oauth?.scope==="org"?"shared":"per-user"}function Ts(e){return`mcp__${e}__`}const Is=1e3,Os=2e3,Ms=500,Cs=12e3,ks=4e3,zn=["contact","company","work_item"];function ws(e){if(!e)return!1;const t=e.slice(0,e.indexOf(":"));return zn.includes(t)}const Ns=[{key:"high",label:"tax_high",percent:21,kind:"standard"},{key:"low",label:"tax_low",percent:9,kind:"reduced"},{key:"zero",label:"tax_zero",percent:0,kind:"zero"},{key:"reverse_charge",label:"tax_reverse_charge",percent:0,kind:"reverse_charge"},{key:"exempt",label:"tax_exempt",percent:0,kind:"exempt"}];function qn(e,t){return t.find(n=>n.key===e)??{key:e,label:e,percent:0,kind:"zero"}}function Qn(e){if(e.kind!=="product")return 0;const t=1-(e.discountPercent??0)/100;return H(e.quantity*e.unitPriceCents*t)}function Rs(e,t,n){const r=e.map(l=>({...l,netCents:Qn(l),taxCents:0})),o=new Map;for(let l=0;l<r.length;l++){if(r[l].kind!=="product"||r[l].optional)continue;const d=n??r[l].taxRateKey,c=o.get(d);c?c.push(l):o.set(d,[l])}const i=[];let s=0,a=0;for(const[l,d]of o){const c=qn(l,t),p=d.reduce((m,b)=>m+r[b].netCents,0),f=H(p*c.percent/100),y=An(f,d.map(m=>r[m].netCents));for(let m=0;m<d.length;m++)r[d[m]].taxCents=y[m];i.push({taxRateKey:l,netCents:p,taxCents:f}),s+=p,a+=f}const u=r.reduce((l,d)=>d.costPriceCents==null||d.optional?l:l+H(d.costPriceCents*d.quantity),0);return{lines:r,totals:{netCents:s,taxCents:a,grossCents:s+a,costCents:u,byRate:i}}}const vs="onboarding-source",Ds=["support","billing","availability","sales","onboarding"],xs=["keep","replace"],Ie=[{key:"shift",label:"kind_shift",capacity:!0,productive:!1,absent:!1,icon:"calendar-clock"},{key:"allocation",label:"kind_allocation",capacity:!1,productive:!0,absent:!1,icon:"briefcase"},{key:"meeting",label:"kind_meeting",capacity:!1,productive:!1,absent:!1,icon:"users"},{key:"travel",label:"kind_travel",capacity:!1,productive:!1,absent:!1,icon:"car"},{key:"training",label:"kind_training",capacity:!1,productive:!1,absent:!1,icon:"graduation-cap"},{key:"break",label:"kind_break",capacity:!1,productive:!1,absent:!1,icon:"coffee"},{key:"absence",label:"kind_absence",capacity:!1,productive:!1,absent:!0,approvable:!0,icon:"palmtree"},{key:"sick",label:"kind_sick",capacity:!1,productive:!1,absent:!0,icon:"thermometer"},{key:"holiday",label:"kind_holiday",capacity:!1,productive:!1,absent:!0,icon:"party-popper"}],Jn={key:"unknown",label:"kind_unknown",capacity:!1,productive:!1,absent:!1};function R(e,t=Ie){return t.find(n=>n.key===e)??{...Jn,key:e}}function W(e){return e==="published"||e==="approved"}function at(e,t,n=Ie){if(e.workstreamId!==t)return!1;const r=R(e.kindKey,n);return r.absent?!1:r.productive||r.capacity}function Ls(e,t=Ie){if(!e.userId||!W(e.status))return!1;const n=R(e.kindKey,t);return n.capacity||n.productive||n.absent}const Ps=864e5;function Zn(e,t){return Math.round((t-e)/Ps)}function ct(e,t){const n=e.cycleMinutes.length;return n===0?0:(Zn(e.anchor,t)%n+n)%n}function lt(e,t){return e.effectiveFrom!==void 0&&t<e.effectiveFrom?0:e.cycleMinutes[ct(e,t)]??0}function ut(e,t){return e.startTimes?.[ct(e,t)]}function dt(e,t,n,r){const o=e.filter(a=>a.effectiveFrom===void 0||a.effectiveFrom<=r),i=a=>a.sort((u,l)=>(l.effectiveFrom??0)-(u.effectiveFrom??0))[0],s=i(o.filter(a=>a.userId===t));return s||i(o.filter(a=>!a.userId&&a.teamId&&n.includes(a.teamId)))}function er(e,t,n){return e.filter(r=>r.userId===t&&(r.effectiveFrom===void 0||r.effectiveFrom<=n)).sort((r,o)=>(o.effectiveFrom??0)-(r.effectiveFrom??0))[0]}const Ge=864e5;function $s(e){const t=Math.max(1,Math.round((e.to-e.from)/Ge));return Array.from({length:t},(n,r)=>e.from+r*Ge)}function je(e,t,n,r){const o=Math.min(t,r)-Math.max(e,n);return o>0?o/1e3:0}const Rt={interval:0,day:1,week:2};function Ks(e,t){const{entries:n,patterns:r=[],terms:o=[]}=t,i=n.filter(c=>c.userId&&W(c.status)&&R(c.kindKey).capacity),s=n.filter(c=>c.userId&&W(c.status)&&R(c.kindKey).absent),a=t.userIds??[...new Set([...i.map(c=>c.userId),...r.map(c=>c.userId),...o.map(c=>c.userId)])].filter(c=>!!c),u={};let l="interval";const d=c=>{Rt[c]>Rt[l]&&(l=c)};for(const c of a){const p=t.teamIdsOf?.(c)??[];let f=0,y=0,m=0;for(const g of $s(e)){const A=Math.max(g,e.from),v=Math.min(g+Ge,e.to);m++;const w=i.filter(M=>M.userId===c).reduce((M,bt)=>M+je(bt.start,bt.end,A,v),0);if(w>0){f+=w;continue}const C=dt(r,c,p,g),N=C?lt(C,g):0;if(C&&N>0){f+=N*60,d(ut(C,g)?"interval":"day");continue}C||y++}if(y>0){const g=er(o,c,e.from);g&&(f+=g.weeklyMinutes*60*(y/7),d("week"))}const b=s.filter(g=>g.userId===c).reduce((g,A)=>g+je(A.start,A.end,e.from,e.to),0),h=Math.max(0,f-b);(h>0||m>0)&&(u[c]=h)}return{seconds:Object.values(u).reduce((c,p)=>c+p,0),precision:l,byUser:u}}function Us(e,t){if(!e.some(a=>a.userId))return[];const n="",r=new Map;for(const a of e){const u=a.userId??n;r.set(u,(r.get(u)??0)+a.seconds)}const i=[...new Set([...Object.keys(t.byUser),...[...r.keys()].filter(a=>a!==n)])].map(a=>{const u=r.get(a)??0,l=t.byUser[a]??0;return{userId:a,requiredSeconds:u,capacitySeconds:l,netSeconds:l-u}});i.sort((a,u)=>a.netSeconds-u.netSeconds);const s=r.get(n)??0;return s>0&&i.push({requiredSeconds:s,capacitySeconds:0,netSeconds:-s}),i}function Fs(e,t,n,r){const o=e.filter(s=>s.userId&&W(s.status)&&!R(s.kindKey).absent),i=Object.entries(r.byUser).map(([s,a])=>{let u=0,l=0;for(const d of o){if(d.userId!==s||R(d.kindKey).capacity&&!d.workstreamId)continue;const c=je(d.start,d.end,n.from,n.to);c<=0||(at(d,t)?u+=c:l+=c)}return{userId:s,capacitySeconds:a,onThisSeconds:u,elsewhereSeconds:l,freeSeconds:Math.max(0,a-u-l)}});return i.sort((s,a)=>a.freeSeconds-s.freeSeconds),i}const Bs="demand-source",vt=1e3;function Hs(e,t){let n=1;for(let r=1;r<=e;r++)n=t*n/(r+t*n);return n}function tr(e,t){if(e<=0)return 1;if(t<=0)return 0;if(e<=t)return 1;const n=Hs(e,t),r=t/e;return n/(1-r*(1-n))}function nr(e,t,n,r){return r<=0?1:e<=t?0:1-tr(e,t)*Math.exp(-(e-t)*n/r)}function rr(e,t,n){return n<=0?0:e*t/n}function or(e,t,n,r){if(e<=0||t<=0)return 0;const o=rr(e,t,n);if(o<=0)return 0;const i=r.serviceLevelPercent/100,s=r.maxOccupancyPercent?r.maxOccupancyPercent/100:void 0;for(let a=Math.max(1,Math.ceil(o));a<=vt;a++)if(!(a<=o)&&!(nr(a,o,r.targetSeconds,t)<i)&&!(s&&o/a>s))return a;return vt}const Ws=36e5,Gs=864e5;function js(e){return e==="day"?Gs:Ws}function Vs(e,t){return e.start<t.end&&t.start<e.end}function re(e,t,n){const r=Math.min(e.end,n)-Math.max(e.start,t);return r>0?r/1e3:0}function ir(e,t,n){const r=e.handleSeconds??0,o=e.seconds??(e.volume!==void 0?e.volume*r:0);if(o<=0&&!e.volume)return{seconds:0,headcount:0};const i=(t.unplannedLossPercent??0)/100,s=i>0&&i<1?1/(1-i):1;if(t.model==="queue"&&e.volume!==void 0&&r>0){const a=or(e.volume,r,n,t);return{seconds:o,headcount:a*s}}return{seconds:o,headcount:o/n*s}}function Xs(e){const{entries:t,workstreamId:n,staffing:r,demand:o,range:i}=e,s=e.grain??"hour",a=js(s),u=a/1e3,l=e.kinds,d=t.filter(m=>W(m.status)),c=d.filter(m=>at(m,n,l)),p=d.filter(m=>R(m.kindKey,l).capacity),f=d.filter(m=>R(m.kindKey,l).absent),y=[];for(let m=B(i.from,s);m<i.to;m+=a){const b=m+a,h=F(m,s);let g=0;for(const M of c)g+=re(M,m,b);let A=0;for(const M of p)A+=re(M,m,b);let v=0;for(const M of f)v+=re(M,m,b);const w=o?.[h]??{},C=ir(w,r,u),N=g/u;y.push({period:h,forecastVolume:w.volume,requiredSeconds:C.seconds,requiredHeadcount:C.headcount,scheduledSeconds:g,scheduledHeadcount:N,netHeadcount:N-C.headcount,capacitySeconds:A,absentSeconds:v})}return y}function sr(e,t){return e.workTypeKey??t?.defaultWorkTypeKey}function Ys(e,t,n){const r=sr(e,t);return r?n.find(o=>o.key===r)?.defaultBillable??!1:!1}function zs(e){return e.filter(t=>t.netHeadcount<0&&t.requiredHeadcount>0)}const qs=36e5,Ve=6048e5,ar=8,Qs=.5,Js=2;function Zs(e){const t=Number(e.slice(0,4)),n=Number(e.slice(5,7)),r=Number(e.slice(8,10)),o=e.length>10?Number(e.slice(11,13)):0;return Date.UTC(t,n-1,r,o)}function ea(e,t,n){const r=[];for(let i=0;i<n;i++){const s=t-i*Ve,a=s-Ve;let u=0,l=!1;for(const[d,c]of e)d>=a&&d<s&&(u+=c,l=!0);l&&r.push(u)}if(r.length<2)return 1;const o=r.reduce((i,s)=>i+s,0)/r.length;return o<=0?1:Math.min(Js,Math.max(Qs,r[0]/o))}function ta(e,t){if(!e?.length)return;let n;for(const r of e)t>=r.from&&t<r.to&&(n=r);return n}function na(e,t,n){const r=Math.max(1,n?.weeks??ar),o=new Map,i=new Set;for(const u of e)o.set(Zs(u.period),u.value),i.add(u.period.slice(0,10));const s=ea(o,B(t.from,"hour"),r),a=[];for(let u=B(t.from,"hour");u<t.to;u+=qs){let l=0,d=0;for(let f=1;f<=r;f++){const y=u-f*Ve,b=o.get(y)??(i.has(F(y,"day"))?0:void 0);if(b===void 0)continue;const h=r-f+1;l+=b*h,d+=h}let c=d>0?l/d*s:0;const p=ta(n?.adjustments,u);p?.absoluteVolume!==void 0?c=p.absoluteVolume:p?.factor!==void 0&&(c*=p.factor),a.push({period:F(u,"hour"),volume:c})}return a}const cr="schedule_entry",lr="workstream";function ra(e){return`${cr}:${e}`}function oa(e){return`${lr}:${e}`}const Xe=36e5,U=864e5;function ia(e,t){const n=t==="day"?U:Xe,r=[];for(let o=B(e.from,t);o<e.to;o+=n)r.push(o);return r}function Dt(e){const t=Math.max(1,Math.round((e.to-e.from)/U));return Array.from({length:t},(n,r)=>e.from+r*U)}function Le(e,t,n,r){const o=Math.min(t,r)-Math.max(e,n);return o>0?o/1e3:0}function sa(e,t,n={}){const r=n.grain??"hour",o=ia(t,r),i=r==="day"?U:Xe,s=new Map(o.map(c=>[c,0])),a=e.filter(c=>c.userId&&R(c.kindKey).capacity),u=n.userIds?.length?new Set(n.userIds):null,l=new Set;for(const c of a)if(!(u&&c.userId&&!u.has(c.userId))){for(const p of o){const f=Le(c.start,c.end,p,p+i);f>0&&s.set(p,(s.get(p)??0)+f)}for(const p of Dt(t))Le(c.start,c.end,p,p+U)>0&&l.add(`${c.userId}:${p}`)}const d=n.userIds??[...new Set([...a.map(c=>c.userId),...(n.patterns??[]).map(c=>c.userId)])].filter(c=>!!c);if(n.patterns?.length)for(const c of d){const p=n.teamIdsOf?.(c)??[];for(const f of Dt(t)){if(l.has(`${c}:${f}`))continue;const y=dt(n.patterns,c,p,f);if(!y)continue;const m=lt(y,f);if(m<=0)continue;const b=ut(y,f);if(b){const[A,v]=b.split(":").map(Number),w=f+A*Xe+(v??0)*6e4,C=w+m*6e4;for(const N of o){const M=Le(w,C,N,N+i);M>0&&s.set(N,(s.get(N)??0)+M)}continue}const h=o.filter(A=>A>=f&&A<f+U);if(!h.length)continue;const g=m*60/h.length;for(const A of h)s.set(A,(s.get(A)??0)+g)}}return o.map(c=>({period:F(c,r),weight:s.get(c)??0}))}function ur(e,t){if(e<=0||!t.length)return[];const n=t.reduce((r,o)=>r+Math.max(0,o.weight),0);if(n<=0){const r=e/t.length;return t.map(o=>({period:o.period,seconds:r}))}return t.filter(r=>r.weight>0).map(r=>({period:r.period,seconds:e*r.weight/n}))}function aa(e,t,n){const r=new Map;for(const o of e){const i=o.by?t.filter(a=>n(a.period)<o.by):t,s=i.length?i:t;for(const a of ur(o.seconds,s)){const u=`${a.period}|${o.userId??""}`,l=r.get(u);l?l.seconds+=a.seconds:r.set(u,{...a,userId:o.userId})}}return[...r.values()].sort((o,i)=>o.period.localeCompare(i.period)||(o.userId??"").localeCompare(i.userId??""))}function dr(e){switch(e.kind){case"user":return`user:${e.userId}`;case"team":return`team:${e.teamId}`;case"org":return"org"}}function ca(e){if(typeof e!="string")return;const t=e.trim();if(t==="org")return{kind:"org"};const n=t.indexOf(":");if(n<=0)return;const r=t.slice(0,n),o=t.slice(n+1).trim();if(o){if(r==="user")return{kind:"user",userId:o};if(r==="team")return{kind:"team",teamId:o}}}function pr(e){return dr(e)}function fr(e){switch(e.kind){case"personal":return{kind:"user",userId:e.userId};case"team":return{kind:"team",teamId:e.teamId};case"org":return{kind:"org"}}}const mr=fr;function la(e){return e.agentId?{kind:"user",userId:e.agentId}:mr(e.ownerScope)}function ua(e){return pr(e)}function da(e,t){if(!t)return;let n=e;for(const r of t.split(".")){if(n===null||typeof n!="object")return;n=n[r]}return n}function pa(e,t){return e.targets.find(n=>n.activityTypes.includes(t))}function fa(e,t){if(t)return e.targets.find(n=>n.id===t)}function gr(e){return e?.kind==="assignment"}function ma(e){const{trigger:t,agentId:n,target:r,activityType:o,assigneeUserId:i,authorUserId:s}=e;return gr(t)?n?r?r.activityTypes.includes(o)?i?i!==n?"assigned to someone else":s&&s===n?"the agent assigned this to itself, which would restart its own run":null:`no assignee found at ${r.assigneePath}`:`activity type ${o} does not announce an assignment for ${r.id}`:`assignment target kind "${t.targetKind}" is not declared by any installed app`:"this playbook has no agent, so an assignment can never be for it":"trigger is not an assignment trigger"}function ga(e){return(e.startsWith("tool:")?e.slice(5):e).replace(/__/g," · ").replace(/\./g," · ").replace(/_/g," ")}const ha=[{name:"text",type:"string"},{name:"subject",type:"string"},{name:"from",type:"string"},{name:"type",type:"string"},{name:"direction",type:"string"},{name:"channelId",type:"string"},{name:"interactionId",type:"string"},{name:"itemId",type:"string"},{name:"activityId",type:"string"},{name:"authorType",type:"string"},{name:"authorName",type:"string"},{name:"textRaw",type:"string"},{name:"fromStatus",type:"string"},{name:"toStatus",type:"string"},{name:"toCategory",type:"string"},{name:"contactId",type:"string"},{name:"companyId",type:"string"},{name:"priority",type:"string"},{name:"inboxId",type:"string"},{name:"topicId",type:"string"},{name:"assigneeUserId",type:"string"}],ya={topics:[{name:"topicId",type:"string"},{name:"topic",type:"string"},{name:"confidence",type:"number"},{name:"reasoning",type:"string"}],question:[{name:"answer",type:"boolean"},{name:"reasoning",type:"string"}],extract:[]};function hr(e){return`${e.type}:${e.id}`}const yr="interaction";function Er(e){return e?.type===yr?e.id:void 0}const _r=64,Sr=8e3;function Ea(e){const t=typeof e=="number"?e:Number(String(e??"").trim());if(!(!Number.isFinite(t)||t<=0))return Math.min(Math.max(Math.round(t),_r),Sr)}const _a={kind:"workflow",steps:[]};function Sa(e){return e?.kind==="workflow"?e.steps:[]}function Aa(e){return e?.kind==="procedure"?e.procedure:void 0}function Ar(e){const t=e?.approved??0,n=t+(e?.rejected??0);return{total:n,rate:n?t/n:0}}const br=10,Tr=.9;function ba(e){const{total:t,rate:n}=Ar(e);return t>=br&&n>=Tr}const Ir=["done","escalated","failed","stopped"];function Ta(e){return Ir.includes(e)}function Or(e){return e==="waiting"}function Ia(e){return e==="running"||Or(e)}function pt(e){return e.subjectKind&&e.subjectId?{type:e.subjectKind,id:e.subjectId}:void 0}function Oa(e){const t=pt(e);return t?hr(t):void 0}function Ma(e){return Er(pt(e))}function Ca(e){const t=[],n=new Map;for(const r of[...e].sort(ka)){const o=n.get(r.emoji);if(o){o.push(r.actor);continue}t.push(r.emoji),n.set(r.emoji,[r.actor])}return t.map(r=>{const o=n.get(r);return{emoji:r,count:o.length,actors:o}}).sort((r,o)=>o.count-r.count||t.indexOf(r.emoji)-t.indexOf(o.emoji))}const ka=(e,t)=>(e.createdAt??0)-(t.createdAt??0);function wa(e,t){return t?e.actors.some(n=>n.type==="user"&&n.id===t):!1}const Ye=6e4,Na=36e5,Y=864e5,Mr=800;function xt(e,t){const n=Date.UTC(e,t+1,0);return n-new Date(n).getUTCDay()*Y+Na}function Ra(e){const t=new Date(e).getUTCFullYear();return e>=xt(t,2)&&e<xt(t,9)}function Cr(e,t){const n=t.dst==="eu"&&Ra(e)?60:0;return(t.utcOffsetMinutes+n)*Ye}function va(e){return(e+3)%7+1}function kr(e,t){const n=Cr(e,t),r=e+n,o=Math.floor(r/Y);if(!t.days.includes(va(o)))return null;const i=o*Y;return{open:i+t.fromMinutes*Ye-n,close:i+t.toMinutes*Ye-n}}function wr(e,t){const n=Cr(e,t),r=e+n;return(Math.floor(r/Y)+1)*Y-n}function ge(e,t,n){if(t<=e)return 0;if(!n)return t-e;let r=0,o=e;for(let i=0;i<Mr&&o<t;i++){const s=kr(o,n);if(s){const a=Math.max(o,s.open),u=Math.min(t,s.close);u>a&&(r+=u-a)}o=wr(o,n)}return r}function Oe(e,t,n){if(!n)return e+t;let r=t,o=e;for(let i=0;i<Mr;i++){const s=kr(o,n);if(s){const a=Math.max(o,s.open);if(s.close>a){const u=s.close-a;if(r<=u)return a+r;r-=u}}o=wr(o,n)}return e+t}function Da(e){const t=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(e);return t?Number(t[1])*60+Number(t[2]):null}const he=1,ye=2;function xa(e){return e==="snoozed"?he:ye}function Me(e){const t=e.calendar;return t&&Array.isArray(t.days)?t:null}const La=["speed_of_answer","first_response","next_response","resolution","close"],Pa=["snoozed","waiting_for_customer"],$a=6e4,Nr=["speed_of_answer","first_response","next_response"],Ka=[...Nr,"resolution","close"];function q(e){return e.state==="running"||e.state==="paused"}function Ua(e,t){return q(e)?{state:(e.state==="paused"?e.remainingMs>0:t<=e.dueAt)?"hit":"missed",settledAt:Math.max(t,e.startedAt)}:null}function Lt(e){return q(e)?{state:"void"}:null}function Fa(e,t,n,r){if(!q(e)||(e.pauseBits&t)!==0)return null;const o=e.pauseBits|t;return e.state==="paused"?{pauseBits:o}:{pauseBits:o,state:"paused",remainingMs:ge(n,e.dueAt,r)}}function Ba(e,t,n,r){if(!q(e)||(e.pauseBits&t)===0)return null;const o=e.pauseBits&~t;return o!==0?{pauseBits:o}:{pauseBits:o,state:"running",dueAt:Oe(n,e.remainingMs,r)}}function Ha({event:e,at:t,now:n,clocks:r,profile:o}){const i=Me(o),s=Math.min(t,n),a=r.map(h=>({...h})),u=[],l=(h,g)=>{g&&(u.push({op:"patch",clockId:h.id,patch:g}),Object.assign(h,g))},d=h=>{for(const g of a)g.metric===h&&l(g,Ua(g,s))},c=h=>{for(const g of a)h.includes(g.metric)&&l(g,Lt(g))},p=h=>{for(const g of a)l(g,Fa(g,h,s,i))},f=h=>{for(const g of a)l(g,Ba(g,h,s,i))},y=h=>a.reduce((g,A)=>A.metric===h?Math.max(g,A.attempt):g,0)+1,m=h=>a.some(g=>g.metric===h&&q(g)),b=(h,g)=>{const A=o.targets.find(w=>w.metric===h);if(!A)return;const v=A.minutes*$a;u.push({op:"start",metric:h,attempt:y(h),startedAt:g,targetMs:v,dueAt:Oe(g,v,i)})};switch(e){case"apply":{for(const h of a)h.profileId!==o.id&&l(h,Lt(h));for(const h of o.targets){if(h.metric==="next_response")continue;a.some(A=>A.metric===h.metric&&A.profileId===o.id)||b(h.metric,s)}break}case"answered":d("speed_of_answer");break;case"outbound":{d("first_response"),d("next_response"),o.pauseOn.includes("waiting_for_customer")&&p(ye);break}case"inbound":{f(ye),!m("first_response")&&!m("next_response")&&b("next_response",s);break}case"resolved":d("resolution");break;case"closed":d("close"),d("resolution"),c(Nr);break;case"reopened":m("resolution")||b("resolution",s),m("close")||b("close",s);break;case"snoozed":o.pauseOn.includes("snoozed")&&p(he);break;case"unsnoozed":f(he);break;case"discarded":c(Ka);break}return u}function Rr(e){return e.state==="running"||e.state==="paused"}function Ee(e,t){const n=Me(e);return e.state==="paused"?e.remainingMs:t>=e.dueAt?-ge(e.dueAt,t,n):ge(t,e.dueAt,n)}function Wa(e,t){return e.state==="paused"?Oe(t,e.remainingMs,Me(e)):e.dueAt}function Ga(e,t){const n=e.filter(Rr);if(!n.length)return;const r=n.filter(i=>i.state==="running");return(r.length?r:n).reduce((i,s)=>Ee(s,t)<Ee(i,t)?s:i)}function ja(e,t){if(e.state==="missed")return"breached";if(e.state==="hit")return"met";if(e.state==="paused")return"paused";if(e.state==="void")return"met";const n=Ee(e,t);return n<=0?"breached":n<=e.targetMs/5?"urgent":"running"}function Va(e){const t=Math.floor(Math.abs(e)/1e3),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),o=Math.floor(t%3600/60);return n?r?`${n}d ${r}u`:`${n}d`:r?o?`${r}u ${o}m`:`${r}u`:o?`${o}m`:`${t%60}s`}const vr="strategy_item";function ft(e){return`${vr}:${e}`}function Xa(e,t=25){const n=new Set([ft(e.id)]);for(const r of e.ancestorKeys??[])n.add(r);return Array.from(n).slice(0,t)}function Ya(e){return e?[...e.ancestorKeys??[],ft(e.id)]:[]}const Q=[{key:"area",label:"level_area",order:10,measurable:!1,icon:"compass"},{key:"objective",label:"level_objective",order:20,measurable:!0,icon:"target"},{key:"key_result",label:"level_key_result",order:30,measurable:!0,icon:"gauge"}],Dr=999,xr=7;function Lr(e,t=Q){return t.find(n=>n.key===e)}function _e(e,t=Q){return Lr(e,t)?.order??Dr}function za(e,t,n=Q){return _e(t,n)<=_e(e,n)}function qa(e,t=Q){const n=_e(e,t);return t.filter(o=>o.order>n).sort((o,i)=>o.order-i.order)[0]?.key??e}function Qa(e){const t=e.trim().toLowerCase();return t?t.includes("key result")||t.includes("keyresult")||t==="kr"?"key_result":t.includes("objective")||t.includes("goal")||t.includes("doel")?"objective":t.includes("focus")||t.includes("area")||t.includes("theme")?"area":null:null}const ze={pending:"open",on_track:"open",at_risk:"open",off_track:"open",paused:"paused",achieved:"closed",missed:"closed"};function Ja(e){return ze[e]??"open"}function Za(e){return Object.keys(ze).filter(t=>e.includes(ze[t]))}const ec=864e5,Ce=e=>e<=0?0:e>1?1:e;function tc(e,t){const{direction:n}=e,r=e.startValue??0,o=e.targetValue??0;if(!Number.isFinite(t))return 0;const i=n==="down"?t<=o:t>=o,s=o-r;return(n==="down"?s<0:s>0)?Ce((t-r)/s):i?1:0}function nc(e,t){const{startDate:n,targetDate:r}=e;if(!(typeof n!="number"||typeof r!="number")&&!(r<=n))return Ce((t-n)/(r-n))}const Pr=.1,$r=.25;function rc(e,t){if(typeof e!="number"||typeof t!="number")return;if(e>=1)return"achieved";const n=t-e;return n>=$r?"off_track":n>=Pr?"at_risk":"on_track"}function oc(e,t){if(t)return Ce(e/t)}function ic(e){const t=e.map(n=>n.progress?.ratio).filter(n=>typeof n=="number"&&Number.isFinite(n));if(t.length)return Ce(t.reduce((n,r)=>n+r,0)/t.length)}function sc(e,t){const n=e.lastCheckInAt??e.createdAt;if(typeof n!="number")return 0;const r=(e.checkInEveryDays??xr)*ec,o=t-n-r;return o>0?o:0}function ac(e){return e.targetDate??Number.MAX_SAFE_INTEGER}function cc(e,t){const n=e.accumulatedSeconds||0;return e.runningSince?n+Math.max(0,Math.floor((t-e.runningSince)/1e3)):n}function lc(e,t){const n=Math.max(1,Math.ceil(Math.max(0,e)/60));if(!t||t==="exact")return n*60;const r=Number(t);return!Number.isFinite(r)||r<=0?n*60:Math.ceil(n/r)*r*60}function uc(e){const t=Math.max(0,Math.round(e/60));return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function dc(e){const t=Math.max(0,Math.floor(e)),n=i=>String(i).padStart(2,"0"),r=Math.floor(t/60)%60,o=Math.floor(t/3600);return o>0?`${o}:${n(r)}:${n(t%60)}`:`${n(r)}:${n(t%60)}`}function Kr(e){return(e||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").slice(0,48).replace(/^-+|-+$/g,"")}function pc(e,t){const n=Kr(e)||"werksoort",r=new Set(t);if(!r.has(n))return n;for(let o=2;o<500;o++){const i=`${n}-${o}`;if(!r.has(i))return i}return`${n}-${r.size+1}`}function fc(e,t){const n=e.ownerScope;return!n||n.kind==="org"?!0:t.includes(n.teamId)}function mc(e){return e.filter(t=>!t.archived).sort(Ur)}function Ur(e,t){const n=(e.order??0)-(t.order??0);return n!==0?n:(e.label||"").localeCompare(t.label||"")}const Fr=20,Br=20,oe=300;function P(e){return e.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function Hr(e){const t=e.replace(/\s+/g," ").trim();if(t.length<=oe)return t;const n=t.slice(0,oe),r=Math.max(n.lastIndexOf(". "),n.lastIndexOf("! "),n.lastIndexOf("? "));return r>oe*.6?n.slice(0,r+1):`${n.trimEnd()}…`}function gc(e,t){const n=Hr(t.text),r=P(n);if(!r||(e.examples??[]).some(s=>P(s)===r))return null;const o=e.exampleCandidates??[],i=o.findIndex(s=>P(s.text)===r);if(i>=0){if(o[i].corrected||!t.corrected)return null;const s=[...o];return s[i]={...s[i],corrected:!0,addedAt:t.addedAt},Pt(s)}return Pt([{...t,text:n},...o]).slice(0,Br)}function Pt(e){return[...e].sort((t,n)=>Number(n.corrected)-Number(t.corrected)||n.addedAt-t.addedAt)}function hc(e,t){const n=P(t),r=(e.examples??[]).filter(i=>i.trim());return{examples:r.some(i=>P(i)===n)?r:[...r,t].slice(-Fr),exampleCandidates:Wr(e,t)}}function Wr(e,t){const n=P(t);return(e.exampleCandidates??[]).filter(r=>P(r.text)!==n)}function Gr(e,t){const n=e.ownerScope;return n?n.kind==="org"?!0:n.kind==="team"?!!t&&n.teamId===t:!1:!1}function yc(e,t){return e.filter(n=>Gr(n,t))}const mt=[{key:"quote",label:"kind_quote",numbered:!1,signFlip:!1,statuses:["draft","sent","accepted","rejected","expired","cancelled"]},{key:"order",label:"kind_order",numbered:!1,signFlip:!1,statuses:["draft","confirmed","delivered","cancelled"]},{key:"invoice",label:"kind_invoice",numbered:!0,signFlip:!1,statuses:["draft","open","paid","overdue","cancelled"]},{key:"credit_note",label:"kind_credit_note",numbered:!0,signFlip:!0,statuses:["draft","open","settled","cancelled"]}];function Se(e){return mt.find(t=>t.key===e)??{key:e,label:e,numbered:!1,signFlip:!1,statuses:["draft"]}}function Ec(e){return e.issuedAt!=null}const _c=["status","fileRef","number","externalIds","postedAt","dunning","updatedAt"];function jr(e,t){const n=Se(t).signFlip!==Se(e.kindKey).signFlip,r=e.lines.map(o=>({...o,quantity:n?-o.quantity:o.quantity,netCents:0,taxCents:0}));return{kindKey:t,sourceTransactionId:e.id,agreementId:e.agreementId,version:1,companyId:e.companyId,contactId:e.contactId,dealItemId:e.dealItemId,ownerScope:e.ownerScope,ownerUserId:e.ownerUserId,title:e.title,reference:e.reference,currency:e.currency,status:"draft",lines:r,totals:{netCents:0,taxCents:0,grossCents:0,byRate:[]},taxOverrideKey:e.taxOverrideKey,introText:e.introText,termsText:e.termsText,source:e.source}}function Sc(e){return{...jr(e,e.kindKey),sourceTransactionId:e.sourceTransactionId,previousVersionId:e.id,version:e.version+1,lines:e.lines.map(n=>({...n})),totals:e.totals}}function Ac(e,t={}){const n=Se(e.kindKey),r=e.totals??{netCents:0,taxCents:0,grossCents:0};return{customer:{name:t.companyName??"",contact:t.contactName??"",address:Ic(t.companyAddress),street:t.companyAddress?.street??"",house_number:t.companyAddress?.houseNumber??"",postal_code:t.companyAddress?.postalCode??"",city:t.companyAddress?.city??"",country:t.companyAddress?.country??""},organization:{name:t.organizationName??""},[n.key]:{number:e.number??"",title:e.title??"",reference:e.reference??"",version:String(e.version??1),date:$t(e.issuedAt),valid_until:$t(e.expiresAt)},totals:{net:x(r.netCents),tax:x(r.taxCents),gross:x(r.grossCents)}}}function bc(e,t=[],n=Vr){const r=e.totals??{netCents:0,grossCents:0,byRate:[]},o=a=>t.find(u=>u.key===a)?.percent??0,i={block_id:"lines",type:"table",columns:[{label:n.description},{label:n.quantity,align:"right"},{label:n.unitPrice,align:"right"},{label:n.net,align:"right"}],rows:(e.lines??[]).map(a=>a.kind==="text"?[a.name,"","",""]:[Tc(a.name,a.description,a.optional,n.optional),Oc(a.quantity),x(a.unitPriceCents),x(a.netCents)])},s={block_id:"totals",type:"totals",rows:[{label:n.net,amount:x(r.netCents)},{label:n.gross,amount:x(r.grossCents),emphasis:!0}],taxRows:r.byRate.map(a=>({label:`${n.tax} ${o(a.taxRateKey)}%`,amount:x(a.taxCents)}))};return{lines:[i],totals:[s]}}const Vr={description:"Omschrijving",optional:"optioneel",quantity:"Aantal",unitPrice:"Stuksprijs",net:"Netto",tax:"Btw",gross:"Totaal"};function Tc(e,t,n,r){const o=t?`${e} — ${t}`:e;return n?`${o} (${r})`:o}function Ic(e){return e?.street?[e.street,e.houseNumber].filter(Boolean).join(" "):""}function Oc(e){return Number.isInteger(e)?String(e):String(e).replace(".",",")}function $t(e){if(!e)return"";const t=new Date(e),n=r=>String(r).padStart(2,"0");return`${n(t.getDate())}-${n(t.getMonth()+1)}-${t.getFullYear()}`}const Mc=[{block_id:"head",type:"letterhead",fields:[{key:"number",label:"Offertenummer",value:"{quote.number}"},{key:"date",label:"Datum",value:"{quote.date}"},{key:"valid_until",label:"Geldig tot",value:"{quote.valid_until}"},{key:"reference",label:"Referentie",value:"{quote.reference}"}],recipient:["{customer.name}","{customer.contact}","{customer.address}","{customer.postal_code} {customer.city}"]},{block_id:"title",type:"heading",level:1,text:"{quote.title}"},{block_id:"intro",type:"paragraph",text:`Beste {customer.contact},
|
|
10
10
|
|
|
11
11
|
Hierbij onze offerte. Hieronder vindt u de specificatie.`},{block_id:"lines",type:"table",columns:[{label:""}],rows:[]},{block_id:"totals",type:"totals",rows:[]},{block_id:"terms",type:"paragraph",text:"Genoemde bedragen zijn exclusief btw tenzij anders vermeld. Deze offerte is geldig tot {quote.valid_until}."}],Xr=mt.map(e=>e.key),Yr="product";function Cc(e,t){return`${e}:${t}`}function kc(e){return`${Yr}:${e}`}function wc(e){const t=e.indexOf(":");if(t<0)return;const n=e.slice(0,t);return Xr.includes(n)?e.slice(t+1):void 0}function Nc(e){return e.type==="agent"}const Rc="WORK_COMMENT_ADDED",vc="WORK_ITEM_ASSIGNED",Dc="WORK_ITEM_STATUS_CHANGED";function xc(e,t){const n=r=>{const o=new Date(r);return o.setHours(0,0,0,0),o.getTime()};return Math.round((n(e)-n(t))/Mn)}function Lc(e,t){if(e.closedAt!=null)return{score:L,reasons:[]};const n=t.remindersById?.[e.id];if(n&&n.remindAt>t.now)return{score:L,reasons:[]};let r=0;const o=[],i=e.priority??"normal";if(X[i]>0&&(r+=X[i],o.push(`priority:${i}`)),typeof e.dueDate=="number"){const s=xc(e.dueDate,t.now);s<0?(r+=35,o.push("overdue")):s===0&&(r+=20,o.push("due-today"))}return e.source?.initiator==="system"&&e.source.systemReason&&(r+=15,o.push(`auto:${e.source.systemReason}`)),{score:r,reasons:o}}const ke=[{key:"task",label:"type_task"},{key:"bug",label:"type_bug"},{key:"story",label:"type_story"},{key:"epic",label:"type_epic"},{key:"subtask",label:"type_subtask"},{key:"case",label:"type_case"},{key:"deal",label:"type_deal"}],Pc=ke.map(e=>e.key);function $c(e){return e?.types?.length?e.types:ke}function Kc(e,t){return t.find(n=>n.key===e)}function Uc(e){const t=e.trim().toLowerCase();return t?t.includes("sub-task")||t.includes("subtask")||t.includes("sub task")?"subtask":t.includes("bug")||t.includes("defect")?"bug":t.includes("epic")?"epic":t.includes("story")?"story":t.includes("incident")||t.includes("problem")||t.includes("service request")||t.includes("change")?"case":t.includes("task")?"task":null:null}function Fc(...e){return e.map(t=>ke.find(n=>n.key===t)).filter(t=>!!t)}const zr="work_item",qr="work_project",Qr="work_activity",Bc="work_cycle";function Jr(e){return`${zr}:${e}`}function gt(e){return`${qr}:${e}`}function Hc(e){return`${Qr}:${e}`}function Wc(e,t,n){const r=`${e}-${t}`;return n?`${r}-${n}`:r}function Gc(e){const t=/^([A-Za-z0-9]{2,8})-(\d+)(?:-(\d+))?$/.exec((e||"").trim());return t?{projectKey:t[1].toUpperCase(),sequenceNumber:Number(t[2]),...t[3]?{subSequence:Number(t[3])}:{}}:null}function jc(e){return(e||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toUpperCase().replace(/[^A-Z0-9]/g,"").slice(0,3)||"PRJ"}function Vc(e,t=25){const n=new Set([Jr(e.id)]);e.projectId&&n.add(gt(e.projectId));for(const r of e.ancestorKeys??[])n.add(r);for(const r of e.partyKeys??[])n.add(r);return Array.from(n).slice(0,t)}function Xc(e){return[gt(e.id)]}const we=[{key:"open",label:"status_open",category:"todo",order:0},{key:"in_progress",label:"status_in_progress",category:"in_progress",order:1},{key:"done",label:"status_done",category:"done",order:2},{key:"cancelled",label:"status_cancelled",category:"done",order:3}],ht=we.map(e=>e.key);function Zr(e){return e?.statuses?.length?e.statuses:we}function eo(e,t){return t.find(n=>n.key===e)?.category??"todo"}function Yc(e,t){return t.find(n=>n.key===e)}function zc(e){const t=Zr(e),n=e?.defaultStatusKey;return n&&t.some(r=>r.key===n)?n:to(t)[0]?.key??we[0].key}function to(e){return[...e].sort((t,n)=>{const r=(t.order??0)-(n.order??0);return r!==0?r:(t.label||"").localeCompare(n.label||"")})}function qc(e,t){return eo(e,t)==="done"}function no(e){return(e||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").slice(0,48).replace(/^-+|-+$/g,"")}function Qc(e,t){const n=no(e)||"status",r=new Set([...t,...ht]);if(!r.has(n))return n;for(let o=2;o<500;o++){const i=`${n}-${o}`;if(!r.has(i))return i}return`${n}-${r.size+1}`}function Jc(e){const t=[];if(!e.length)return[{index:-1,reason:"empty"}];const n=new Set;return e.forEach((r,o)=>{if(!r.key){t.push({index:o,reason:"missing_key"});return}ht.includes(r.key)&&t.push({index:o,reason:"reserved_key",key:r.key}),n.has(r.key)&&t.push({index:o,reason:"duplicate_key",key:r.key}),n.add(r.key)}),e.some(r=>r.category==="todo"||r.category==="in_progress")||t.push({index:-1,reason:"no_open"}),e.some(r=>r.category==="done")||t.push({index:-1,reason:"no_done"}),t}function Zc(e){return e.startDate??Number.MAX_SAFE_INTEGER}function el(e){return e.completedAt?"completed":e.startedAt?"active":"planned"}const tl=new Set(["image/png","image/jpeg","image/jpg","image/gif","image/webp"]),nl=new Set(["text/plain","text/markdown","text/csv","application/json","text/html","application/xml","text/xml"]);function ro(e){const t=(e??"").trim().toLowerCase().split(";")[0];return t?tl.has(t)?"image":t==="application/pdf"?"pdf":nl.has(t)?"text":t.startsWith("audio/")?"audio":"unsupported":"unsupported"}const j=1024*1024,oo={image:5*j,pdf:20*j,text:1*j,audio:20*j},rl=25*j,ol=5;function il(e,t){const n=ro(e);return n==="unsupported"?"unsupported":t>oo[n]?"too-large":null}function sl(e){return e.access!=="read"&&e.effect!=="internal"}function io(e){return`${e.kind}:${e.id||e.url||e.title}`}function al(e,t=[]){const n=new Set(t),r=[],o=[];for(const i of e){const s=io(i);n.has(s)||(n.add(s),r.push(i),o.push(s))}return{sources:r,keys:o}}const cl="assist-source",ll=["blocking","due","open"];function ul(e,t){const[n,r]=(e.subjectKey??"").split(":");return n===t&&r?r:void 0}const Kt={blocking:0,due:1,open:2};function dl(e,t){return Kt[e.band??"open"]-Kt[t.band??"open"]||(t.priority??0)-(e.priority??0)||e.id.localeCompare(t.id)}function pl(e){return e.sessions.filter(t=>t.id!==e.exceptSessionId&&t.state==="connected"&&e.canHold(t.providerId))}function fl(e){return e.sessions.filter(t=>t.id!==e.exceptSessionId&&t.state==="connected"&&!e.canHold(t.providerId))}function ml(e){return e.sessions.some(n=>n.id!==e.exceptSessionId&&(n.state==="connected"||n.state==="on_hold"))?{admit:!1,reason:"busy"}:{admit:!0}}function so(e,t){const n=new Set(e.disabledIntents??[]),r=e.intentOverrides??{},o=t.intents.filter(s=>!n.has(s.intent)).map(s=>hl(s,r[s.intent]));if(!e.extraIntents||e.extraIntents.length===0)return o;const i=new Set(o.map(s=>s.intent));for(const s of e.extraIntents)i.has(s.intent)||(o.push(s),i.add(s.intent));return o}function ao(e,t){const n={};for(const r of e.intents){if(!r.togglable)continue;const o=t?.[r.intent];n[r.intent]=o??r.defaultEnabled??!0}return n}function gl(e,t){const n=ao(e,t);return Object.entries(n).filter(([,r])=>!r).map(([r])=>r)}function hl(e,t){return t?{intent:t.intent??e.intent,targetSchemes:t.targetSchemes??e.targetSchemes,transport:t.transport??e.transport}:e}function yl(e,t){const n=[];for(const r of e){if(!r.enabled)continue;const o=t[r.providerId];if(o)for(const i of so(r,o))n.push({channel:r,description:o,capability:i})}return n}function El(e,t){return t.filter(n=>n.capability.intent===e)}function co(e,t){return t.filter(n=>n.capability.targetSchemes.includes(e))}function _l(e,t){return co(e.scheme,t)}function Sl(e,t,n){const r=[];for(const o of e)for(const i of n)i.capability.intent===t&&i.capability.targetSchemes.includes(o.scheme)&&r.push({channelIntent:i,endpoint:o});return r}var lo=(e=>(e.MAILTO="mailto",e.SIP="sip",e.TEL="tel",e.WEBHOOK="webhook",e.USERNAME="username",e.ID="id",e.CUSTOM="custom",e.URL="url",e.TELEGRAM="telegram",e.WHATSAPP="whatsapp",e.MESSENGER="messenger",e.INSTAGRAM="instagram",e.VIBER="viber",e.SMS="sms",e.FAX="fax",e.TEAMS="teams",e.CALENDAR="calendar",e))(lo||{});const Al={mailto:"mail",sip:"tel",tel:"tel",fax:"tel",sms:"chat",teams:"chat",telegram:"chat",messenger:"chat",instagram:"chat",viber:"chat",whatsapp:"wa",webhook:"note",url:"note",calendar:"note",username:"note",id:"note",custom:"note"};function bl(e){return e?Al[e]??"note":"note"}const Tl="message_window",Il="message_templates",Ol={FROM:"from",TO:"to",CC:"cc",BCC:"bcc",ORGANIZER:"organizer",PRESENTER:"presenter",ATTENDEE:"attendee",OWNER:"owner",MEMBER:"member",GUEST:"guest",HOST:"host",PARTICIPANT:"participant"},Ml=(e,t)=>({intent:e,...t}),Cl="folder_management",kl="remote_search",wl="message_reactions",Nl={ok:!1,code:"UNSUPPORTED",message:"Provider does not support this op"},Rl="connector",vl="context.collect",S=e=>({type:"string",description:e}),_=e=>({type:"number",description:e}),ie=e=>({type:"boolean",description:e}),k=S("Sheet name. Omit for the sheet the user is looking at."),Ut=S("Slide id, as `inspect` reports it.");function E(e,t,n,r,o,i){return{op:e,kinds:t,summary:n,parameters:{type:"object",properties:r,required:o},undoable:i.undoable,visible:i.visible}}const V={undoable:!1,visible:!0},T={undoable:!0,visible:!0},Ft={undoable:!1,visible:!0},Ae={undoable:!1,visible:!1},Dl=[E("pdf.goToPage",["pdf"],"Scroll the viewer to a page.",{page:_("1-based page number.")},["page"],V),E("pdf.search",["pdf"],"Search the document and highlight the matches, as the find bar does.",{query:S("Text to find."),next:ie("Jump to the next match instead of the first.")},["query"],V),E("pdf.setTool",["pdf"],"Select a markup tool for the user, so their next click draws it.",{tool:{type:"string",enum:["highlight","text","draw","image","signature","none"],description:"Which tool to arm. `none` puts the tool row back to reading."}},["tool"],V),E("pdf.fillField",["pdf"],"Fill one form field of a fillable PDF.",{field:S("Field name, exactly as `inspect` reports it under `fields`."),value:{type:["string","boolean"],description:"Text for a text field, true/false for a checkbox or radio."}},["field","value"],T),E("pdf.reorderPages",["pdf"],"Put the pages in a different order. Pages left out are deleted.",{order:{type:"array",items:{type:"number"},description:"1-based source page numbers, in the order they should end up in."}},["order"],Ft),E("pdf.deletePages",["pdf"],"Remove pages, keeping the rest in order.",{pages:{type:"array",items:{type:"number"},description:"1-based page numbers."}},["pages"],Ft),E("pdf.addNote",["pdf"],"Place a text note on a page. Written on save; not visible before that.",{page:_("1-based page number."),text:S("The note's text."),left:_("Distance from the left edge, in PDF points (72 per inch)."),top:_("Distance from the top edge, in PDF points."),width:_("Box width in points. Omit for a sensible default."),height:_("Box height in points. Omit for a sensible default."),fontSize:_("Font size in points. Omit for 12.")},["page","text","left","top"],Ae),E("pdf.highlightText",["pdf"],"Highlight a phrase on a page. Written on save; not visible before that.",{page:_("1-based page number."),text:S("The exact phrase to highlight, as it appears in the page's text."),occurrence:_("Which occurrence on that page, 1-based. Omit for the first.")},["page","text"],Ae)],xl=[E("sheet.setValues",["sheet"],"Write a block of values. The block's shape must match the range.",{sheet:k,range:S("A1 notation, e.g. `B2:D5` or a single `A1`."),values:{type:"array",items:{type:"array",items:{type:["string","number","boolean","null"]}},description:"Rows of cells, top-left first. `null` clears a cell."}},["range","values"],T),E("sheet.setFormula",["sheet"],"Put a formula in every cell of a range.",{sheet:k,range:S("A1 notation."),formula:S("Including the leading `=`.")},["range","formula"],T),E("sheet.setStyle",["sheet"],"Change the look of a range. Only the properties you pass are touched.",{sheet:k,range:S("A1 notation."),bold:ie("Bold on or off."),italic:ie("Italic on or off."),fontSize:_("Point size."),fontColor:S("CSS colour, e.g. `#b91c1c`."),background:S("CSS colour for the cell fill."),horizontalAlignment:{type:"string",enum:["left","center","right"],description:"Horizontal alignment."},numberFormat:S("Number format pattern, e.g. `#,##0.00` or `0%`.")},["range"],T),E("sheet.insertRows",["sheet"],"Insert empty rows, pushing the rest down.",{sheet:k,at:_("1-based row number to insert before."),count:_("How many. Omit for 1.")},["at"],T),E("sheet.deleteRows",["sheet"],"Delete rows, pulling the rest up.",{sheet:k,at:_("1-based first row to delete."),count:_("How many. Omit for 1.")},["at"],T),E("sheet.insertColumns",["sheet"],"Insert empty columns, pushing the rest right.",{sheet:k,at:_("1-based column number to insert before."),count:_("How many. Omit for 1.")},["at"],T),E("sheet.deleteColumns",["sheet"],"Delete columns, pulling the rest left.",{sheet:k,at:_("1-based first column to delete."),count:_("How many. Omit for 1.")},["at"],T),E("sheet.merge",["sheet"],"Merge a range into one cell.",{sheet:k,range:S("A1 notation.")},["range"],T),E("sheet.unmerge",["sheet"],"Break merged cells in a range apart.",{sheet:k,range:S("A1 notation.")},["range"],T),E("sheet.sort",["sheet"],"Sort a range on one of its columns.",{sheet:k,range:S("A1 notation covering the rows to sort, header excluded."),column:_("1-based column *within the range*, not within the sheet."),ascending:ie("Ascending. Omit for ascending.")},["range","column"],T),E("sheet.insertSheet",["sheet"],"Add a new sheet.",{name:S("Name for the new sheet.")},["name"],T),E("sheet.renameSheet",["sheet"],"Rename a sheet.",{sheet:S("Current name."),name:S("New name.")},["sheet","name"],T),E("sheet.deleteSheet",["sheet"],"Remove a sheet and everything on it.",{sheet:S("Name of the sheet to delete.")},["sheet"],T),E("sheet.activate",["sheet"],"Show the user a sheet and select a range on it.",{sheet:k,range:S("A1 notation to select. Omit to only switch sheets.")},[],V)],Ll=[E("word.replaceParagraph",["word"],"Rewrite one whole paragraph, keeping its style. This is the verb for shortening or rephrasing something; call it once per paragraph.",{at:_("The offset the paragraph starts at, exactly as `inspect` prints it."),text:S("The new text for that paragraph. A newline starts a further paragraph.")},["at","text"],T),E("word.replaceRange",["word"],"Replace a stretch of text inside a paragraph - a sentence, a phrase. To rewrite whole paragraphs use word.replaceParagraph: a range covering several paragraph styles is refused, because a replacement carries one style and would set the whole span in the first.",{start:_("Character offset where the replaced text starts, as `inspect` reports offsets."),end:_("Character offset just past the last character to replace."),text:S("The replacement text. A newline starts a new paragraph.")},["start","end","text"],T),E("word.insertText",["word"],"Insert text at a character offset, without removing anything.",{index:_("Character offset, as `inspect` reports offsets."),text:S("The text to insert.")},["index","text"],T),E("word.appendText",["word"],"Add text at the end of the document.",{text:S("The text to append.")},["text"],T),E("word.insertParagraph",["word"],"Start a new paragraph, optionally with text in it.",{text:S("Paragraph text. Newlines start further paragraphs."),index:_("Character offset to insert at. Omit for the end of the document.")},[],T),E("word.setSelection",["word"],"Put the user's cursor on a stretch of text, and move the reading window there: the page context carries one window of a long document, and the text around this offset arrives in the next turn.",{start:_("Start character offset."),end:_("End character offset. Omit for a caret.")},["start"],V)],Pl=[E("slides.setText",["slides"],"Replace the text of one shape. Written on save; not visible before that, and not undoable.",{slide:Ut,element:S("Element id, as `inspect` reports it."),text:S("The new text.")},["slide","element","text"],Ae),E("slides.setTransform",["slides"],"Move or resize one shape. Only the values you pass change. Written on save; not visible before that, and not undoable.",{slide:Ut,element:S("Element id."),left:_("Distance from the left edge, in pixels."),top:_("Distance from the top edge, in pixels."),width:_("Width in pixels."),height:_("Height in pixels.")},["slide","element"],Ae)],yt=[...Dl,...xl,...Ll,...Pl];function $l(e){return yt.filter(t=>t.kinds.includes(e))}function Kl(e){return yt.find(t=>t.op===e)}const Bt=/(?: {2,}|\\)$/,Ul=/^\*\*([^*]+)\*\*\s+(.*)$/;function Ht(e){const t=Ul.exec(e);return t?{lead:t[1],text:t[2]}:{text:e}}function Fl(e){const t=(e??"").replace(/\r\n/g,`
|
|
12
12
|
`).split(`
|
|
13
|
-
`),n=[];let r=null;const o=()=>{r&&n.push({type:"list",style:r.style,items:r.items}),r=null},i=(p,f)=>{r&&r.style!==p&&o(),r?r.items.push(Ht(f)):r={style:p,items:[Ht(f)]}};let s=[],a=[];const
|
|
14
|
-
`)}),a=[])},d=()=>{
|
|
15
|
-
`)});continue}const y=p.match(/^(#{1,3})\s+(.*)$/);if(y){d(),n.push({type:"heading",level:y[1].length,text:y[2].trim()}),
|
|
16
|
-
`:" ")),
|
|
13
|
+
`),n=[];let r=null;const o=()=>{r&&n.push({type:"list",style:r.style,items:r.items}),r=null},i=(p,f)=>{r&&r.style!==p&&o(),r?r.items.push(Ht(f)):r={style:p,items:[Ht(f)]}};let s=[],a=[];const u=()=>{if(s.length){const p=s.join("").trim();p&&n.push({type:"paragraph",text:p}),s=[]}},l=()=>{a.length&&(n.push({type:"quote",text:a.join(`
|
|
14
|
+
`)}),a=[])},d=()=>{u(),l(),o()};let c=0;for(;c<t.length;){const p=t[c]??"",f=p.match(/^```(\w*)\s*$/);if(f){d();const h=[];for(c++;c<t.length&&!/^```\s*$/.test(t[c]??"");)h.push(t[c]??""),c++;c++,n.push({type:"code",...f[1]?{lang:f[1]}:{},text:h.join(`
|
|
15
|
+
`)});continue}const y=p.match(/^(#{1,3})\s+(.*)$/);if(y){d(),n.push({type:"heading",level:y[1].length,text:y[2].trim()}),c++;continue}const m=p.match(/^!\[([^\]]*)\]\(([^)\s]+)\)\s*$/);if(m){d(),n.push({type:"image",url:m[2],...m[1]?{alt:m[1]}:{}}),c++;continue}if(/^\s*[-*]\s+/.test(p)){u(),l(),i("bulleted",p.replace(/^\s*[-*]\s+/,"")),c++;continue}if(/^\s*\d+\.\s+/.test(p)){u(),l(),i("numbered",p.replace(/^\s*\d+\.\s+/,"")),c++;continue}if(/^\s*(-{3,}|\*{3,}|_{3,})\s*$/.test(p)){d(),n.push({type:"divider"}),c++;continue}if(/^>\s?/.test(p)){u(),o(),a.push(p.replace(/^>\s?/,"")),c++;continue}if(p.trim()===""){d(),c++;continue}l(),o();const b=Bt.test(p);s.push(p.replace(Bt,"").trim()+(b?`
|
|
16
|
+
`:" ")),c++}return d(),n}function Bl(e,t){return tt(e,t).replace(/^```.*$/gm,"").replace(/^\|[\s:|-]*\|$/gm,"").replace(/[ \t]*\|[ \t]*/g," ").replace(/^[ \t]*(#{1,6}|>|[-*+]|\d+\.)[ \t]+/gm,"").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/(\*\*|__|\*|_|`|~~)/g,"").replace(/[ \t]+$/gm,"").replace(/\n{3,}/g,`
|
|
17
17
|
|
|
18
|
-
`).trim()}const Hl="documents.describe",Wl="documents.inspect",Gl="documents.apply";function jl(e){const t=e.indexOf(":");if(t!==-1)return e.slice(0,t);const n=e.indexOf(".");return n===-1?e:e.slice(0,n)}const Vl="installation-id";function Xl(e){const t=[];for(const n of Object.keys(e))for(const r of Object.keys(e[n]))t.push({lang:n,key:r,value:e[n][r]});return t}const Yl="notification-source",zl=(e,t)=>`${e}.pref.${t}`,ql={ai:["account.read","account.write","agent.read","agent.write","assignment.read","assignment.write","budget.read","budget.write","connector.read","connector.write","context.read","context.write","conversation.read","conversation.write","lens.read","lens.write","message.read","message.write","playbook.read","playbook.write","profile.read","profile.write","run.read","run.write","settings.read","settings.write","tool.read","transcript.write","usage.read"],analytics:["report.read"],"app-store":["app.publish","app.read","app.write","setting.read","setting.write"],assist:["board.read"],automations:["sync.read","sync.write","webhook.read","webhook.write"],communication:["account.read","account.write","activity-type.read","activity.read","activity.write","attachment.read","attribute.read","attribute.write","calendar.read","calendar.write","channel.read","channel.write","custom-field.read","custom-field.write","folder.read","folder.write","inbox.read","inbox.write","interaction.read","interaction.write","reaction.read","reaction.write","reminder.read","template.read","template.write","topic.read","topic.write"],context:["kind.read","kind.write","memory.read","memory.write"],crm:["company.read","company.write","contact.read","contact.write"],"eylo-voip":["account.read","account.write","callflow.read","callflow.write","channel.read","channel.write","contact.read","contact.write","device.read","device.write","group.read","group.write","interaction.read","interaction.write","media.read","media.write","menu.read","menu.write","phone-number.read","phone-number.write","recording.read","recording.write","sip.read","temporal-rule.read","temporal-rule.write","user.read","user.write","vmbox.read","vmbox.write","webhook.read","webhook.write"],google:["account.read","account.write","contact.read"],kb:["article.read","article.write","category.read","category.write","help-center.read","help-center.write","kb.read","kb.write"],mail:["account.write"],meta:["account.read","account.write"],microsoft:["account.read","account.write","contact.read","sync.write"],organization:["billing.read","billing.write","settings.read","settings.write","team.read","team.write"],shopify:["account.read","account.write","order.read"],slack:["thread.read","thread.write"],storage:["artifact.read","artifact.write","file.read","file.write","mount.read","mount.write"],time:["entry.read","entry.write","work-type.read","work-type.write"],user:["user.read","user.write"],work:["item.read","item.write","project.read","project.write"]},Et=9e4,uo=["out_of_office"],po=e=>uo.includes(e);function Ql(e,t,n){const r=n-e<Et,o=t?.status&&(!t.expiresAt||t.expiresAt>n)?t:void 0;if(!o?.status)return{online:r,status:r?"available":"offline"};const i=o.status;return!r&&!po(i)?{online:!1,status:"offline"}:{online:r,status:i,message:o.message}}function Jl(e,t){const n=t-e.lastSeenAt<Et,r=n||po(e.status)?e.status:"offline";return n===e.online&&r===e.status?e:{...e,online:n,status:r}}function Zl(e,t){return e?.teamId&&t.includes(e.teamId)?{teamId:e.teamId,mustChoose:!1}:t.length===1?{teamId:t[0],mustChoose:!1}:{teamId:void 0,mustChoose:t.length>1}}function eu(e){return e.providerAvailable&&e.allowed}const tu="resources.describe",nu="resources.search",ru="resources.resolve",ou="resources.attached";function iu(e){const t=e.indexOf(":");return t===-1?e:e.slice(0,t)}const su="/provider/scope/related",au="/provider/scope/read",_t="auth";function St(e){const t=typeof e=="string"?e.match(/apps\/([^/?#]+)/):null;return t?t[1]:null}function cu(e){const t=St(e);return t?t!==_t:typeof e=="string"&&e.startsWith("/wake")}function lu(e){return typeof e!="string"||e===""||e==="/"?!0:St(e)===_t}function uu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fo(e){const n=e.split("/").filter(Boolean).map(r=>r.startsWith(":")?r.endsWith("?")?"(?:/[^/]+)?":"/[^/]+":`/${uu(r)}`).join("");return new RegExp(`^${n}\\/?$`)}function mo(e,t){const n=e.split("/").filter(Boolean),r=t.split("/").filter(Boolean),o={};return n.forEach((i,s)=>{if(i.startsWith(":")){const a=i.endsWith("?")?i.slice(1,-1):i.slice(1),c=r[s];c&&(o[a]=c)}}),o}function go(e){return e.publicBasePath??`/apps/${e.name}`}function du(e){const t=[];for(const n of e){if(!n?.name)continue;const r=go(n);for(const o of n.routes??[]){if(!o.public)continue;const i=o.path==="/"?"":o.path;t.push({appName:n.name,resource:o.resource,pattern:`${r}${i}`,props:o.props})}}return t}function ho(e,t){const n=e.split("/").filter(Boolean),r=t.split("/").filter(Boolean);for(let o=0;o<Math.min(n.length,r.length);o++){const i=n[o].startsWith(":"),s=r[o].startsWith(":");if(i!==s)return s}return n.length>r.length}function yo(e,t){if(typeof e!="string")return null;let n=null;for(const r of t)fo(r.pattern).test(e)&&(!n||ho(r.pattern,n.pattern))&&(n=r);return n?{...n,params:{...n.props,...mo(n.pattern,e)}}:null}function pu(e,t){return yo(e,t)!==null}const fu=10*1024*1024,mu=25*1024*1024,gu="sync-target",hu=20,yu={afrikaans:["[Muziek]","(C) TV GELDERLAND 2021","*Thomp thomp thomp*","www.youtube.com","ä n wood s","!.."],english:["[applause]","[APPLAUSE]","(claps)","(clapping)","(audience applauds)","(keyboard clicking)","(keyboard clacking)","(clicking)","[CLICK]","[BLANK_AUDIO]","(upbeat music)","(dramatic music)","[music playing]","(electronic music)","(audience cheering)","(audience cheers)","[MUSIC]","( ( ( ( ) ( ) ( ) ( )","(laughs)","(air whooshing)","<u>Transcribed</u> by https://otter.ai","All new tonight at 6... coming up. A new look at your forecast is A new look at your forecast is","www.mooji.org","KATHRYN A new forecast is coming up... A new forecast is coming up...","KATHRYN pandemic started. increasing since the The pandemic has been","A new look at your forecast this morning... A new look at your","We'll be right back.","We'll see you next week.","Thanks for watching!","❤️ Translated by Amara.org Communit"],flemish:["*clap*","TV GELDERLAND 2020","TV Gelderland 2021","(C) TV GELDERLAND 2021","[Muziek]","Kuman","Ondertitels ingediend door de Amara.org gemeenschap","Ondertiteld door de Amara.org gemeenschap","Dank u wel voor het kijken.","Ondertiteling door de Amara.org gemeenschap","GELUID VAN MAHIH U similarly"],french:["(applaudissements)","[Applaudissements]","Sous-titres réalisés par la communauté d'Amara.org","- Bonne journée. - Bonjour.","POP POP הי","Merci d'avoir regardé cette vidéo.","Merci d'avoir regardé cette vidéo!","Merci d'avoir regardé la vidéo.","J'espère que vous avez apprécié la vidéo.","Je vous remercie de vous abonner","Merci d'avoir regardé!","❤️ par SousTitreur.com","— Sous-titrage ST'501 —","Thanks for watching!","Sous-titres réalisés par l'Amara.org","Sous-titres réalisés para la communauté d'Amara.org","Sous-titres réalisés par la communauté d'Amara.org","Sous-titres fait par Sous-titres par Amara.org","Sous-titres réalisés par les SousTitres d'Amara.org","Sous-titres par Amara.org","Sous-titres par la communauté d'Amara.org","Sous-titres réalisés pour la communauté d'Amara.org","Sous-titres réalisés par la communauté de l'Amara.org","Sous-Titres faits par la communauté d'Amara.org","Sous-titres par l'Amara.org","Sous-titres fait par la communauté d'Amara.org","Sous-titrage ST' 501","Sous-titrage ST'501","Cliquez-vous sur les sous-titres et abonnez-vous à la chaîne d'Amara.org","❤️ par SousTitreur.com"],german:["[Klicken]","(Jubel)","*lacht*","[Anhaltender Beifall]","[Applaus]","(Applaus)","* Applaus *","[MUSIK]","* mustard ml Drumglöck und knack in einem Handbewerb *","Untertitelung aufgrund der Amara.org-Community","Untertitel im Auftrag des ZDF für funk, 2017","Untertitel von Stephanie Geiges","Untertitel der Amara.org-Community","Untertitel im Auftrag des ZDF, 2017","Untertitel im Auftrag des ZDF, 2020","Untertitel im Auftrag des ZDF, 2018","Untertitel im Auftrag des ZDF, 2021","Untertitelung im Auftrag des ZDF, 2021","Copyright WDR 2021","Copyright WDR 2020","Copyright WDR 2019","SWR 2021","SWR 2020"],italian:["Alla prossima!","*applauso*","[Musica]","[Musica]","[Applausi]","*Bip bip bip bip*","(musica del NS shore)","D' 1962 alle tribunte del Gulf","Sottotitoli creati dalla comunità Amara.org","Sottotitoli di Sottotitoli di Amara.org","Sottotitoli e revisione al canale di Amara.org","Sottotitoli e revisione a cura di Amara.org","Sottotitoli e revisione a cura di QTSS","Sottotitoli e revisione a cura di QTSS.","Sottotitoli a cura di QTSS","Sottotitoli a cura di Sottotitoli"],spanish:["[música]","[Música de cierre]","[Aplausos]","(Aplausos)","www.alimmenta.com","¡Gracias por ver el vídeo!","(sonidos del celular) (Inudible distorsión)","¡Suscríbete!","Subtítulos realizados por la comunidad de Amara.org","Subtitulado por la comunidad de Amara.org","Subtítulos por la comunidad de Amara.org","Subtítulos creados por la comunidad de Amara.org","Subtítulos en español de Amara.org","Subtítulos hechos por la comunidad de Amara.org","Subtitulos por la comunidad de Amara.org","Más información www.alimmenta.com","www.mooji.org","[MÚSICA]","[Music cuts in British]"]},Eo=e=>{let t=e;return Object.values(yu).forEach(n=>{n.forEach(r=>{t=t.replaceAll(r,"")})}),t=t.replace(/\(.*?\)/g,""),t=t.replace(/\[.*?\]/g,""),t},_o=6e4,So=8e3,Ao=2,bo=.4,Eu=3,_u=new Set(["aan","als","ben","bent","bij","dan","dat","deze","die","dit","doen","door","dus","echt","een","eens","even","gaan","gaat","geen","geweest","goed","graag","had","heb","hebben","hebt","heeft","het","hier","hoe","hoor","iets","inderdaad","kan","klopt","kunnen","kunt","maar","mag","mee","meer","met","mij","mijn","misschien","moet","moeten","naar","net","niet","nog","nou","oke","ook","over","prima","toch","uhm","uit","van","veel","voor","wat","weer","weet","wel","wij","wil","wilt","worden","wordt","zeg","zeggen","zijn","zou","zult","about","and","are","been","but","can","does","for","have","just","know","like","not","okay","right","she","that","the","them","then","there","they","this","want","was","well","were","what","will","with","would","yeah","you","your"]);function To(e){const t=new Set;for(const n of e.toLowerCase().split(/[^a-z0-9À-ɏ]+/))n.length<Eu||_u.has(n)||t.add(n);return[...t]}function Io(e,t){if(!e.length)return 0;if(!t.length)return 1;const n=new Set(t),r=new Set(e);let o=0;for(const i of r)n.has(i)||(o+=1);return o/r.size}function Oo(e,t=_o){const n=e.filter(s=>!s.partial&&typeof s.text=="string");if(!n.length)return{text:"",segmentCount:0};const o=n.reduce((s,a)=>Math.max(s,a.endedAt??0),0)-t;return{text:n.filter(s=>(s.endedAt??0)>=o).map(s=>Eo(s.text).trim()).filter(Boolean).join(" ").replace(/\s+/g," ").trim(),segmentCount:n.length}}const Mo=60;function Su(e,t,n=Mo){const r=new Set(e),o=[...e];for(const i of t)!i||r.has(i)||(r.add(i),o.push(i));return o.slice(-n)}function Au(e){const{segments:t,now:n,state:r}=e;if(r.lastTriggerAt&&n-r.lastTriggerAt<So)return{trigger:!1,reason:"too_soon"};const o=Oo(t,e.windowMs);if(!o.text)return{trigger:!1,reason:"no_speech"};const i=o.segmentCount-(r.lastSegmentCount??0);if(r.lastQueryTerms&&i<Ao)return{trigger:!1,reason:"too_few_new"};const s=To(o.text);return s.length?r.lastQueryTerms?.length&&Io(s,r.lastQueryTerms)<bo?{trigger:!1,reason:"same_topic"}:{trigger:!0,text:o.text,terms:s,segmentCount:o.segmentCount}:{trigger:!1,reason:"no_speech"}}const bu=["personal","workspace","connections","work","ai"],Tu="navNotice",Ne={NL:{callingCode:"31",trunkPrefix:"0",nsnMin:7,nsnMax:9},BE:{callingCode:"32",trunkPrefix:"0",nsnMin:8,nsnMax:9},LU:{callingCode:"352",nsnMin:6,nsnMax:9},DE:{callingCode:"49",trunkPrefix:"0",nsnMin:6,nsnMax:13},FR:{callingCode:"33",trunkPrefix:"0",nsnMin:9,nsnMax:9},GB:{callingCode:"44",trunkPrefix:"0",nsnMin:9,nsnMax:10},IE:{callingCode:"353",trunkPrefix:"0",nsnMin:7,nsnMax:9},ES:{callingCode:"34",nsnMin:9,nsnMax:9},PT:{callingCode:"351",nsnMin:9,nsnMax:9},IT:{callingCode:"39",nsnMin:6,nsnMax:11},AT:{callingCode:"43",trunkPrefix:"0",nsnMin:7,nsnMax:13},CH:{callingCode:"41",trunkPrefix:"0",nsnMin:9,nsnMax:9},DK:{callingCode:"45",nsnMin:8,nsnMax:8},SE:{callingCode:"46",trunkPrefix:"0",nsnMin:7,nsnMax:13},NO:{callingCode:"47",nsnMin:8,nsnMax:8},FI:{callingCode:"358",trunkPrefix:"0",nsnMin:5,nsnMax:12},PL:{callingCode:"48",nsnMin:9,nsnMax:9},US:{callingCode:"1",nsnMin:10,nsnMax:10},CA:{callingCode:"1",nsnMin:10,nsnMax:10}},Co="NL",Iu=15,Ou=8,Mu=Array.from(new Set(Object.values(Ne).map(e=>e.callingCode))).sort((e,t)=>t.length-e.length);function Wt(e){if(e)return Ne[e.trim().toUpperCase()]}function se(e,t){return e.length>=t.nsnMin&&e.length<=t.nsnMax}function Gt(e){if(e.length>Iu)return null;for(const t of Mu){if(!e.startsWith(t))continue;const n=e.slice(t.length);for(const r of Object.values(Ne)){if(r.callingCode!==t)continue;const o=r.trunkPrefix,i=o&&n.startsWith(o)?n.slice(o.length):n;if(se(i,r))return`+${t}${i}`}return null}return e.length<Ou?null:`+${e}`}function Cu(e){let t=e.trim();const n=t.match(/^(sips?|tel|whatsapp):/i);n&&(t=t.slice(n[0].length));const r=t.indexOf("@");return r>=0&&(t=t.slice(0,r)),t.trim()}function ku(e){if(!e)return!1;const t=e.indexOf("@");if(t<=0)return!1;const n=e.slice(0,t).trim();return!/^[+\d\s().-]+$/.test(n)}function qe(e,t){if(!e)return null;const n=Cu(e);if(!n)return null;const r=n.startsWith("+"),o=n.replace(/\D/g,"");if(!o)return null;if(r)return Gt(o);if(o.startsWith("00"))return Gt(o.slice(2));const i=Wt(t)??Wt(Co);if(!i)return null;const s=i.trunkPrefix;if(s&&o.startsWith(s)){const a=o.slice(s.length);return se(a,i)?`+${i.callingCode}${a}`:null}if(o.startsWith(i.callingCode)){const a=o.slice(i.callingCode.length);if(se(a,i))return`+${i.callingCode}${a}`}return!s&&se(o,i)?`+${i.callingCode}${o}`:null}function wu(e,t=9){const n=(e??"").replace(/\D/g,"");return n.length<t?null:n.slice(-t)}function At(e){if(!e)return null;const t=e.trim().toLowerCase(),n=t.lastIndexOf("@");if(n<=0||n===t.length-1)return null;const r=t.slice(0,n).split("+")[0],o=t.slice(n+1);return!r||!o.includes(".")?null:`${r}@${o}`}function Nu(e){const t=At(e);return t?t.slice(t.lastIndexOf("@")+1):null}const Ru=new Set(["co.uk","org.uk","gov.uk","ac.uk","com.au","co.nz","com.br","co.za"]);function ko(e){if(!e)return null;const t=e.trim().toLowerCase().replace(/\.$/,"").split(".").filter(Boolean);if(t.length<2)return null;const n=t.slice(-2).join(".");return Ru.has(n)&&t.length>=3?t.slice(-3).join("."):n}const wo=new Set(["gmail.com","googlemail.com","outlook.com","hotmail.com","hotmail.nl","hotmail.be","hotmail.co.uk","live.com","live.nl","live.be","msn.com","yahoo.com","yahoo.co.uk","ymail.com","icloud.com","me.com","mac.com","aol.com","gmx.net","gmx.de","web.de","protonmail.com","proton.me","pm.me","tutanota.com","zoho.com","mail.com","ziggo.nl","kpnmail.nl","planet.nl","home.nl","casema.nl","chello.nl","xs4all.nl","telfort.nl","hetnet.nl","zonnet.nl","upcmail.nl","quicknet.nl","telenet.be","skynet.be","proximus.be","scarlet.be"]);function vu(e){const t=ko(e);return t?wo.has(t):!1}function Du(e){if(!e)return!1;const t=e.trim().toLowerCase();return t==="tel"||t==="sms"||t==="whatsapp"||t==="fax"}function xu(e,t,n){if(!e||!t)return null;const r=e.trim().toLowerCase();if(r==="tel"||r==="sms"||r==="whatsapp"){const i=qe(t,n);return i?`tel:${i}`:null}if(r==="fax"){const i=qe(t,n);return i?`fax:${i}`:null}if(r==="mailto"||r==="email"){const i=At(t);return i?`mailto:${i}`:null}const o=t.trim().toLowerCase();return o?`${r}:${o}`:null}const Lu=[/<blockquote/i,/class="?gmail_quote/i,/id="?[^"]*divRplyFwdMsg/i,/id="?[^"]*mail-editor-reference-message-container/i,/-{3,}\s*Original Message\s*-{3,}/i,/\n_{5,}\s*\n/,/\bOn\b[\s\S]{0,200}?\bwrote:/i],jt=/^\s*(?:>+\s*)?(?:from|van|sent|verzonden|to|aan|cc|subject|onderwerp|date|datum)\s*:/i,Pu=/^\s*(?:on|op)\b.{0,200}?\b(?:wrote|schreef|geschreven)\s*:?\s*$/i;function $u(e){const t=e.split(`
|
|
18
|
+
`).trim()}const Hl="documents.describe",Wl="documents.inspect",Gl="documents.apply";function jl(e){const t=e.indexOf(":");if(t!==-1)return e.slice(0,t);const n=e.indexOf(".");return n===-1?e:e.slice(0,n)}const Vl="installation-id";function Xl(e){const t=[];for(const n of Object.keys(e))for(const r of Object.keys(e[n]))t.push({lang:n,key:r,value:e[n][r]});return t}const Yl="notification-source",zl=(e,t)=>`${e}.pref.${t}`,ql={ai:["account.read","account.write","agent.read","agent.write","assignment.read","assignment.write","budget.read","budget.write","connector.read","connector.write","context.read","context.write","conversation.read","conversation.write","lens.read","lens.write","message.read","message.write","playbook.read","playbook.write","profile.read","profile.write","run.read","run.write","settings.read","settings.write","tool.read","transcript.write","usage.read"],analytics:["report.read"],"app-store":["app.publish","app.read","app.write","setting.read","setting.write"],assist:["board.read"],automations:["sync.read","sync.write","webhook.read","webhook.write"],communication:["account.read","account.write","activity-type.read","activity.read","activity.write","attachment.read","attribute.read","attribute.write","calendar.read","calendar.write","channel.read","channel.write","custom-field.read","custom-field.write","folder.read","folder.write","inbox.read","inbox.write","interaction.read","interaction.write","reaction.read","reaction.write","reminder.read","template.read","template.write","topic.read","topic.write"],context:["kind.read","kind.write","memory.read","memory.write"],crm:["company.read","company.write","contact.read","contact.write"],"eylo-voip":["account.read","account.write","callflow.read","callflow.write","channel.read","channel.write","contact.read","contact.write","device.read","device.write","group.read","group.write","interaction.read","interaction.write","media.read","media.write","menu.read","menu.write","phone-number.read","phone-number.write","recording.read","recording.write","sip.read","temporal-rule.read","temporal-rule.write","user.read","user.write","vmbox.read","vmbox.write","webhook.read","webhook.write"],google:["account.read","account.write","contact.read"],kb:["article.read","article.write","category.read","category.write","help-center.read","help-center.write","kb.read","kb.write"],mail:["account.write"],meta:["account.read","account.write"],microsoft:["account.read","account.write","contact.read","sync.write"],organization:["billing.read","billing.write","settings.read","settings.write","team.read","team.write"],shopify:["account.read","account.write","order.read"],slack:["thread.read","thread.write"],storage:["artifact.read","artifact.write","file.read","file.write","mount.read","mount.write"],time:["entry.read","entry.write","work-type.read","work-type.write"],user:["user.read","user.write"],work:["item.read","item.write","project.read","project.write"]},Et=9e4,uo=["out_of_office"],po=e=>uo.includes(e);function Ql(e,t,n){const r=n-e<Et,o=t?.status&&(!t.expiresAt||t.expiresAt>n)?t:void 0;if(!o?.status)return{online:r,status:r?"available":"offline"};const i=o.status;return!r&&!po(i)?{online:!1,status:"offline"}:{online:r,status:i,message:o.message}}function Jl(e,t){const n=t-e.lastSeenAt<Et,r=n||po(e.status)?e.status:"offline";return n===e.online&&r===e.status?e:{...e,online:n,status:r}}function Zl(e,t){return e?.teamId&&t.includes(e.teamId)?{teamId:e.teamId,mustChoose:!1}:t.length===1?{teamId:t[0],mustChoose:!1}:{teamId:void 0,mustChoose:t.length>1}}function eu(e){return e.providerAvailable&&e.allowed}const tu="resources.describe",nu="resources.search",ru="resources.resolve",ou="resources.attached";function iu(e){const t=e.indexOf(":");return t===-1?e:e.slice(0,t)}const su="/provider/scope/related",au="/provider/scope/read",_t="auth";function St(e){const t=typeof e=="string"?e.match(/apps\/([^/?#]+)/):null;return t?t[1]:null}function cu(e){const t=St(e);return t?t!==_t:typeof e=="string"&&e.startsWith("/wake")}function lu(e){return typeof e!="string"||e===""||e==="/"?!0:St(e)===_t}function uu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fo(e){const n=e.split("/").filter(Boolean).map(r=>r.startsWith(":")?r.endsWith("?")?"(?:/[^/]+)?":"/[^/]+":`/${uu(r)}`).join("");return new RegExp(`^${n}\\/?$`)}function mo(e,t){const n=e.split("/").filter(Boolean),r=t.split("/").filter(Boolean),o={};return n.forEach((i,s)=>{if(i.startsWith(":")){const a=i.endsWith("?")?i.slice(1,-1):i.slice(1),u=r[s];u&&(o[a]=u)}}),o}function go(e){return e.publicBasePath??`/apps/${e.name}`}function du(e){const t=[];for(const n of e){if(!n?.name)continue;const r=go(n);for(const o of n.routes??[]){if(!o.public)continue;const i=o.path==="/"?"":o.path;t.push({appName:n.name,resource:o.resource,pattern:`${r}${i}`,props:o.props})}}return t}function ho(e,t){const n=e.split("/").filter(Boolean),r=t.split("/").filter(Boolean);for(let o=0;o<Math.min(n.length,r.length);o++){const i=n[o].startsWith(":"),s=r[o].startsWith(":");if(i!==s)return s}return n.length>r.length}function yo(e,t){if(typeof e!="string")return null;let n=null;for(const r of t)fo(r.pattern).test(e)&&(!n||ho(r.pattern,n.pattern))&&(n=r);return n?{...n,params:{...n.props,...mo(n.pattern,e)}}:null}function pu(e,t){return yo(e,t)!==null}const fu=10*1024*1024,mu=25*1024*1024,gu="sync-target",hu=20,yu={afrikaans:["[Muziek]","(C) TV GELDERLAND 2021","*Thomp thomp thomp*","www.youtube.com","ä n wood s","!.."],english:["[applause]","[APPLAUSE]","(claps)","(clapping)","(audience applauds)","(keyboard clicking)","(keyboard clacking)","(clicking)","[CLICK]","[BLANK_AUDIO]","(upbeat music)","(dramatic music)","[music playing]","(electronic music)","(audience cheering)","(audience cheers)","[MUSIC]","( ( ( ( ) ( ) ( ) ( )","(laughs)","(air whooshing)","<u>Transcribed</u> by https://otter.ai","All new tonight at 6... coming up. A new look at your forecast is A new look at your forecast is","www.mooji.org","KATHRYN A new forecast is coming up... A new forecast is coming up...","KATHRYN pandemic started. increasing since the The pandemic has been","A new look at your forecast this morning... A new look at your","We'll be right back.","We'll see you next week.","Thanks for watching!","❤️ Translated by Amara.org Communit"],flemish:["*clap*","TV GELDERLAND 2020","TV Gelderland 2021","(C) TV GELDERLAND 2021","[Muziek]","Kuman","Ondertitels ingediend door de Amara.org gemeenschap","Ondertiteld door de Amara.org gemeenschap","Dank u wel voor het kijken.","Ondertiteling door de Amara.org gemeenschap","GELUID VAN MAHIH U similarly"],french:["(applaudissements)","[Applaudissements]","Sous-titres réalisés par la communauté d'Amara.org","- Bonne journée. - Bonjour.","POP POP הי","Merci d'avoir regardé cette vidéo.","Merci d'avoir regardé cette vidéo!","Merci d'avoir regardé la vidéo.","J'espère que vous avez apprécié la vidéo.","Je vous remercie de vous abonner","Merci d'avoir regardé!","❤️ par SousTitreur.com","— Sous-titrage ST'501 —","Thanks for watching!","Sous-titres réalisés par l'Amara.org","Sous-titres réalisés para la communauté d'Amara.org","Sous-titres réalisés par la communauté d'Amara.org","Sous-titres fait par Sous-titres par Amara.org","Sous-titres réalisés par les SousTitres d'Amara.org","Sous-titres par Amara.org","Sous-titres par la communauté d'Amara.org","Sous-titres réalisés pour la communauté d'Amara.org","Sous-titres réalisés par la communauté de l'Amara.org","Sous-Titres faits par la communauté d'Amara.org","Sous-titres par l'Amara.org","Sous-titres fait par la communauté d'Amara.org","Sous-titrage ST' 501","Sous-titrage ST'501","Cliquez-vous sur les sous-titres et abonnez-vous à la chaîne d'Amara.org","❤️ par SousTitreur.com"],german:["[Klicken]","(Jubel)","*lacht*","[Anhaltender Beifall]","[Applaus]","(Applaus)","* Applaus *","[MUSIK]","* mustard ml Drumglöck und knack in einem Handbewerb *","Untertitelung aufgrund der Amara.org-Community","Untertitel im Auftrag des ZDF für funk, 2017","Untertitel von Stephanie Geiges","Untertitel der Amara.org-Community","Untertitel im Auftrag des ZDF, 2017","Untertitel im Auftrag des ZDF, 2020","Untertitel im Auftrag des ZDF, 2018","Untertitel im Auftrag des ZDF, 2021","Untertitelung im Auftrag des ZDF, 2021","Copyright WDR 2021","Copyright WDR 2020","Copyright WDR 2019","SWR 2021","SWR 2020"],italian:["Alla prossima!","*applauso*","[Musica]","[Musica]","[Applausi]","*Bip bip bip bip*","(musica del NS shore)","D' 1962 alle tribunte del Gulf","Sottotitoli creati dalla comunità Amara.org","Sottotitoli di Sottotitoli di Amara.org","Sottotitoli e revisione al canale di Amara.org","Sottotitoli e revisione a cura di Amara.org","Sottotitoli e revisione a cura di QTSS","Sottotitoli e revisione a cura di QTSS.","Sottotitoli a cura di QTSS","Sottotitoli a cura di Sottotitoli"],spanish:["[música]","[Música de cierre]","[Aplausos]","(Aplausos)","www.alimmenta.com","¡Gracias por ver el vídeo!","(sonidos del celular) (Inudible distorsión)","¡Suscríbete!","Subtítulos realizados por la comunidad de Amara.org","Subtitulado por la comunidad de Amara.org","Subtítulos por la comunidad de Amara.org","Subtítulos creados por la comunidad de Amara.org","Subtítulos en español de Amara.org","Subtítulos hechos por la comunidad de Amara.org","Subtitulos por la comunidad de Amara.org","Más información www.alimmenta.com","www.mooji.org","[MÚSICA]","[Music cuts in British]"]},Eo=e=>{let t=e;return Object.values(yu).forEach(n=>{n.forEach(r=>{t=t.replaceAll(r,"")})}),t=t.replace(/\(.*?\)/g,""),t=t.replace(/\[.*?\]/g,""),t},_o=6e4,So=8e3,Ao=2,bo=.4,Eu=3,_u=new Set(["aan","als","ben","bent","bij","dan","dat","deze","die","dit","doen","door","dus","echt","een","eens","even","gaan","gaat","geen","geweest","goed","graag","had","heb","hebben","hebt","heeft","het","hier","hoe","hoor","iets","inderdaad","kan","klopt","kunnen","kunt","maar","mag","mee","meer","met","mij","mijn","misschien","moet","moeten","naar","net","niet","nog","nou","oke","ook","over","prima","toch","uhm","uit","van","veel","voor","wat","weer","weet","wel","wij","wil","wilt","worden","wordt","zeg","zeggen","zijn","zou","zult","about","and","are","been","but","can","does","for","have","just","know","like","not","okay","right","she","that","the","them","then","there","they","this","want","was","well","were","what","will","with","would","yeah","you","your"]);function To(e){const t=new Set;for(const n of e.toLowerCase().split(/[^a-z0-9À-ɏ]+/))n.length<Eu||_u.has(n)||t.add(n);return[...t]}function Io(e,t){if(!e.length)return 0;if(!t.length)return 1;const n=new Set(t),r=new Set(e);let o=0;for(const i of r)n.has(i)||(o+=1);return o/r.size}function Oo(e,t=_o){const n=e.filter(s=>!s.partial&&typeof s.text=="string");if(!n.length)return{text:"",segmentCount:0};const o=n.reduce((s,a)=>Math.max(s,a.endedAt??0),0)-t;return{text:n.filter(s=>(s.endedAt??0)>=o).map(s=>Eo(s.text).trim()).filter(Boolean).join(" ").replace(/\s+/g," ").trim(),segmentCount:n.length}}const Mo=60;function Su(e,t,n=Mo){const r=new Set(e),o=[...e];for(const i of t)!i||r.has(i)||(r.add(i),o.push(i));return o.slice(-n)}function Au(e){const{segments:t,now:n,state:r}=e;if(r.lastTriggerAt&&n-r.lastTriggerAt<So)return{trigger:!1,reason:"too_soon"};const o=Oo(t,e.windowMs);if(!o.text)return{trigger:!1,reason:"no_speech"};const i=o.segmentCount-(r.lastSegmentCount??0);if(r.lastQueryTerms&&i<Ao)return{trigger:!1,reason:"too_few_new"};const s=To(o.text);return s.length?r.lastQueryTerms?.length&&Io(s,r.lastQueryTerms)<bo?{trigger:!1,reason:"same_topic"}:{trigger:!0,text:o.text,terms:s,segmentCount:o.segmentCount}:{trigger:!1,reason:"no_speech"}}const bu=["personal","workspace","connections","work","ai"],Tu="navNotice",Ne={NL:{callingCode:"31",trunkPrefix:"0",nsnMin:7,nsnMax:9},BE:{callingCode:"32",trunkPrefix:"0",nsnMin:8,nsnMax:9},LU:{callingCode:"352",nsnMin:6,nsnMax:9},DE:{callingCode:"49",trunkPrefix:"0",nsnMin:6,nsnMax:13},FR:{callingCode:"33",trunkPrefix:"0",nsnMin:9,nsnMax:9},GB:{callingCode:"44",trunkPrefix:"0",nsnMin:9,nsnMax:10},IE:{callingCode:"353",trunkPrefix:"0",nsnMin:7,nsnMax:9},ES:{callingCode:"34",nsnMin:9,nsnMax:9},PT:{callingCode:"351",nsnMin:9,nsnMax:9},IT:{callingCode:"39",nsnMin:6,nsnMax:11},AT:{callingCode:"43",trunkPrefix:"0",nsnMin:7,nsnMax:13},CH:{callingCode:"41",trunkPrefix:"0",nsnMin:9,nsnMax:9},DK:{callingCode:"45",nsnMin:8,nsnMax:8},SE:{callingCode:"46",trunkPrefix:"0",nsnMin:7,nsnMax:13},NO:{callingCode:"47",nsnMin:8,nsnMax:8},FI:{callingCode:"358",trunkPrefix:"0",nsnMin:5,nsnMax:12},PL:{callingCode:"48",nsnMin:9,nsnMax:9},US:{callingCode:"1",nsnMin:10,nsnMax:10},CA:{callingCode:"1",nsnMin:10,nsnMax:10}},Co="NL",Iu=15,Ou=8,Mu=Array.from(new Set(Object.values(Ne).map(e=>e.callingCode))).sort((e,t)=>t.length-e.length);function Wt(e){if(e)return Ne[e.trim().toUpperCase()]}function se(e,t){return e.length>=t.nsnMin&&e.length<=t.nsnMax}function Gt(e){if(e.length>Iu)return null;for(const t of Mu){if(!e.startsWith(t))continue;const n=e.slice(t.length);for(const r of Object.values(Ne)){if(r.callingCode!==t)continue;const o=r.trunkPrefix,i=o&&n.startsWith(o)?n.slice(o.length):n;if(se(i,r))return`+${t}${i}`}return null}return e.length<Ou?null:`+${e}`}function Cu(e){let t=e.trim();const n=t.match(/^(sips?|tel|whatsapp):/i);n&&(t=t.slice(n[0].length));const r=t.indexOf("@");return r>=0&&(t=t.slice(0,r)),t.trim()}function ku(e){if(!e)return!1;const t=e.indexOf("@");if(t<=0)return!1;const n=e.slice(0,t).trim();return!/^[+\d\s().-]+$/.test(n)}function qe(e,t){if(!e)return null;const n=Cu(e);if(!n)return null;const r=n.startsWith("+"),o=n.replace(/\D/g,"");if(!o)return null;if(r)return Gt(o);if(o.startsWith("00"))return Gt(o.slice(2));const i=Wt(t)??Wt(Co);if(!i)return null;const s=i.trunkPrefix;if(s&&o.startsWith(s)){const a=o.slice(s.length);return se(a,i)?`+${i.callingCode}${a}`:null}if(o.startsWith(i.callingCode)){const a=o.slice(i.callingCode.length);if(se(a,i))return`+${i.callingCode}${a}`}return!s&&se(o,i)?`+${i.callingCode}${o}`:null}function wu(e,t=9){const n=(e??"").replace(/\D/g,"");return n.length<t?null:n.slice(-t)}function At(e){if(!e)return null;const t=e.trim().toLowerCase(),n=t.lastIndexOf("@");if(n<=0||n===t.length-1)return null;const r=t.slice(0,n).split("+")[0],o=t.slice(n+1);return!r||!o.includes(".")?null:`${r}@${o}`}function Nu(e){const t=At(e);return t?t.slice(t.lastIndexOf("@")+1):null}const Ru=new Set(["co.uk","org.uk","gov.uk","ac.uk","com.au","co.nz","com.br","co.za"]);function ko(e){if(!e)return null;const t=e.trim().toLowerCase().replace(/\.$/,"").split(".").filter(Boolean);if(t.length<2)return null;const n=t.slice(-2).join(".");return Ru.has(n)&&t.length>=3?t.slice(-3).join("."):n}const wo=new Set(["gmail.com","googlemail.com","outlook.com","hotmail.com","hotmail.nl","hotmail.be","hotmail.co.uk","live.com","live.nl","live.be","msn.com","yahoo.com","yahoo.co.uk","ymail.com","icloud.com","me.com","mac.com","aol.com","gmx.net","gmx.de","web.de","protonmail.com","proton.me","pm.me","tutanota.com","zoho.com","mail.com","ziggo.nl","kpnmail.nl","planet.nl","home.nl","casema.nl","chello.nl","xs4all.nl","telfort.nl","hetnet.nl","zonnet.nl","upcmail.nl","quicknet.nl","telenet.be","skynet.be","proximus.be","scarlet.be"]);function vu(e){const t=ko(e);return t?wo.has(t):!1}function Du(e){if(!e)return!1;const t=e.trim().toLowerCase();return t==="tel"||t==="sms"||t==="whatsapp"||t==="fax"}function xu(e,t,n){if(!e||!t)return null;const r=e.trim().toLowerCase();if(r==="tel"||r==="sms"||r==="whatsapp"){const i=qe(t,n);return i?`tel:${i}`:null}if(r==="fax"){const i=qe(t,n);return i?`fax:${i}`:null}if(r==="mailto"||r==="email"){const i=At(t);return i?`mailto:${i}`:null}const o=t.trim().toLowerCase();return o?`${r}:${o}`:null}const Lu=[/<blockquote/i,/class="?gmail_quote/i,/id="?[^"]*divRplyFwdMsg/i,/id="?[^"]*mail-editor-reference-message-container/i,/-{3,}\s*Original Message\s*-{3,}/i,/\n_{5,}\s*\n/,/\bOn\b[\s\S]{0,200}?\bwrote:/i],jt=/^\s*(?:>+\s*)?(?:from|van|sent|verzonden|to|aan|cc|subject|onderwerp|date|datum)\s*:/i,Pu=/^\s*(?:on|op)\b.{0,200}?\b(?:wrote|schreef|geschreven)\s*:?\s*$/i;function $u(e){const t=e.split(`
|
|
19
19
|
`);for(let n=0;n<t.length;n++)if(Pu.test(t[n])||jt.test(t[n])&&t.slice(n+1,n+4).some(r=>jt.test(r)))return t.slice(0,n).join(`
|
|
20
20
|
`).trim();return e}const Ku=/^(?:https?:|mailto:|tel:)/i,Uu=/^(?:https?:|cid:|data:image\/)/i;function Pe(e,t){const n=e.match(new RegExp(`\\b${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s">]+))`,"i"));return(n?.[1]??n?.[2]??n?.[3]??"").trim()}const Fu=/(!\[[^\]]*\]\([^)]*\))/;function Vt(e){return e.replace(/\s+/g," ").trim().split(Fu).map((t,n)=>n%2===1?t:t.replace(/[[\]]/g,"\\$&")).join("")}function $e(e){return e.replace(/[()\s<>"]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)}function Bu(e){return e.replace(/<img\b([^>]*?)\/?>/gi,(n,r)=>{const o=Pe(r,"src");return Uu.test(o)?`})`:""}).replace(/<a\b([^>]*)>([\s\S]*?)<\/a\s*>/gi,(n,r,o)=>{const i=Vt(o.replace(/<[^>]*>/g,"")),s=Pe(r,"href");return Ku.test(s)?`[${i||$e(s)}](${$e(s)})`:i})}const Hu=/<table\b[^>]*>((?:(?!<table\b)[\s\S])*?)<\/table\s*>/i,Wu=/<tr\b[^>]*>([\s\S]*?)<\/tr\s*>/gi,Gu=/<(t[dh])\b([^>]*)>([\s\S]*?)<\/\1\s*>/gi;function ju(e,t){return/<table\b/i.test(e)||e.includes(`
|
|
21
21
|
|
|
22
|
-
|`)||t.includes("![")||t.length>200}const Vu=40,Xu={left:"---",center:":---:",right:"---:"};function Yu(e){const t=e.match(/align\s*[=:]\s*["']?\s*(right|center)/i);return t?t[1].toLowerCase():"left"}function zu(e){return e.replace(/<[^>]*>/g,"").replace(/\s+/g," ").trim().replace(/\|/g,"\\|")}function qu(e){const t=[];for(const s of e.matchAll(Wu)){const a=[];for(const
|
|
22
|
+
|`)||t.includes("![")||t.length>200}const Vu=40,Xu={left:"---",center:":---:",right:"---:"};function Yu(e){const t=e.match(/align\s*[=:]\s*["']?\s*(right|center)/i);return t?t[1].toLowerCase():"left"}function zu(e){return e.replace(/<[^>]*>/g,"").replace(/\s+/g," ").trim().replace(/\|/g,"\\|")}function qu(e){const t=[];for(const s of e.matchAll(Wu)){const a=[];for(const u of s[1].matchAll(Gu)){const l=zu(u[3]);if(ju(u[3],l))return null;a.push({text:l,align:Yu(u[2])})}if(a.length===0)return null;a.some(u=>u.text!=="")&&t.push(a)}const n=t[0]?.length??0;if(t.length<2||n<2||t.some(s=>s.length!==n))return null;const r=s=>`| ${s.map(a=>a.text).join(" | ")} |`,o=t[1].map(s=>Xu[s.align]).join(" | "),i=t.slice(1).map(r).join(`
|
|
23
23
|
`);return`
|
|
24
24
|
|
|
25
25
|
${r(t[0])}
|