1import{a as e,i as t,l as n,o as r,s as i,t as a,u as o,x as s}from"./authStore-C1UGufCI.js";import{t as c}from"./constants-BsLED5u9.js";import"./timezoneUtils-BW5zHa_h.js";import{a as l,c as u,d,f,l as p,n as m,o as h,s as g,t as _,u as v}from"./types-p8Dqhvuz.js";var ee=async e=>await i(`/campaigns/${e}/draft`).then(s),y=async(e,t)=>await o(`/campaigns/${e}/accounts`,{accountIds:t}).then(s),te=async e=>await i(`/campaigns/${e}/accounts/active`).then(s),b=function(e){return e[e.CONNECTION_REQUEST=0]=`CONNECTION_REQUEST`,e[e.FOLLOW_UP=1]=`FOLLOW_UP`,e}({}),x=function(e){return e.ACTIVE=`ACTIVE`,e.INACTIVE=`INACTIVE`,e.REJECTED=`REJECTED`,e.DELETED=`DELETED`,e.NOT_STARTED=`NOT_STARTED`,e.PROCESSING=`PROCESSING`,e.SUCCESS=`SUCCESS`,e.DRAFT=`DRAFT`,e.RUNNING=`RUNNING`,e.COMPLETED=`COMPLETED`,e.PAUSED=`PAUSED`,e.ARCHIVED=`ARCHIVED`,e}({}),S=(e,t)=>{if(!(!e.data&&!t.data))return{...e.data||{},...t.data||{}}},C=e=>{if(!e?.nodes||!e.edges)return e;let t=[...e.nodes],n=[...e.edges],r=!1;for(;;){let e=t.find(e=>{if(e.type!==`delay`)return!1;let r=n.filter(t=>t.target===e.id),i=n.filter(t=>t.source===e.id);if(r.length!==1||i.length!==1)return!1;let a=t.find(e=>e.id===r[0].source),o=t.find(e=>e.id===i[0].target);if(!a||!o)return!1;let s=a.type===`start`&&o.type===`action`&&o.data?.actionType===`CHECK_CONNECTION`;return o.type===`delay`||s});if(!e)break;let i=n.find(t=>t.target===e.id),a=n.find(t=>t.source===e.id),o=t.find(e=>e.id===a.target);if(o&&o.type===`delay`){let n=t.findIndex(e=>e.id===o.id);n!==-1&&(t[n]={...t[n],data:{...e.data||{},...t[n].data||{}}})}let s={...i,target:a.target,targetHandle:a.targetHandle,label:a.label??i.label,data:S(i,a)};t=t.filter(t=>t.id!==e.id),n=n.filter(e=>e.id!==i.id&&e.id!==a.id).concat(s),r=!0}return r?{...e,nodes:t,edges:n}:e},ne=[`firstName`,`lastName`,`company`,`title`,`headline`,`location`],w=d([u({fixType:h(`sendBlank`)}).strict(),u({fixType:h(`skipLeads`)}).strict(),u({fixType:h(`insertDefaultValue`),defaultValue:v().refine(e=>e.trim().length>0,{message:`defaultValue must not be blank`})}).strict()]),T=u({fixType:h(`fetchFromLinkedIn`),sourceField:l(ne),fallback:w}).strict(),E=d([w,T,u({fixType:h(`allLeadsPresent`),fallback:d([w,T])}).strict()]),D=u({columnName:v().trim().min(1),fixChain:E,appliedAt:g().optional()}).strict(),O=u({schemaVersion:h(1),columnFixes:m(D).default([]),detectedColumns:m(v()).default([]),lastUpdated:g().optional(),mainIdentifier:v().optional()}).passthrough(),k=u({id:v().min(1),type:v().min(1),data:p(v(),_()).optional()}).passthrough(),A=u({id:v().optional(),source:v().min(1),target:v().min(1),label:_().optional(),data:u({outcome:l([`positive`,`negative`,`open_profile_false`]).optional()}).passthrough().optional()}).passthrough(),j=u({schemaVersion:h(1),flat:m(_()).optional(),nodes:m(k).optional(),edges:m(A).optional()}).passthrough();
1u({schemaVersion:h(1),sequenceType:l([`TREE`,`FLAT`]),sequenceDraft:j,csvConfig:O}).strict().superRefine((e,t)=>{e.sequenceType===`TREE`&&(e.sequenceDraft.nodes?.length||t.addIssue({code:f.custom,path:[`sequenceDraft`,`nodes`],message:`TREE sequenceDraft requires at least one node`}),e.sequenceDraft.edges?.length||t.addIssue({code:f.custom,path:[`sequenceDraft`,`edges`],message:`TREE sequenceDraft requires at least one edge`})),e.sequenceType===`FLAT`&&!Array.isArray(e.sequenceDraft.flat)&&t.addIssue({code:f.custom,path:[`sequenceDraft`,`flat`],message:`FLAT sequenceDraft requires a flat array`})});var M=e=>{if(e?.fallback!=null)throw Error(`Terminal fallback modes cannot contain another fallback`);let t=e?.fixType===`skipLead`?`skipLeads`:e?.fixType===`fallbackValue`?`insertDefaultValue`:e?.fixType;if(t===`sendBlank`||t===`skipLeads`)return{fixType:t};if(t===`insertDefaultValue`)return{fixType:t,defaultValue:e?.defaultValue??e?.fallbackValue??``};throw Error(`Unsupported terminal fallback fixType: ${String(t)}`)};function N(e){if(!e||typeof e!=`object`)throw Error(`fixChain must be an object`);if(e.fixType===`fetchFromLinkedIn`)return T.parse({fixType:`fetchFromLinkedIn`,sourceField:e.sourceField,fallback:M(e.fallback||{fixType:`skipLeads`})});if(e.fixType===`allLeadsPresent`){let t=e.fallback||{fixType:`skipLeads`};return E.parse({fixType:`allLeadsPresent`,fallback:t.fixType===`fetchFromLinkedIn`?N(t):M(t)})}return w.parse(M(e))}function P(e){let t=e&&typeof e==`object`?e:{},n=Array.isArray(t.columnFixes)?t.columnFixes.map(e=>({columnName:e?.columnName,fixChain:N(e?.fixChain),...typeof e?.appliedAt==`number`?{appliedAt:e.appliedAt}:{}})):[];return O.parse({...t,schemaVersion:1,columnFixes:n,detectedColumns:Array.isArray(t.detectedColumns)?t.detectedColumns:[]})}var F=e=>{if(typeof e==`string`){if(e===`No Open Profile`)return`open_profile_false`;if([`Connected`,`Yes`,`Replied`].includes(e))return`positive`;if([`Not Connected`,`No`,`Not Replied`].includes(e))return`negative`}};function I(e){let t=Array.isArray(e)&&e[0]?.nodes?e[0]:e;if(Array.isArray(t))return j.parse({schemaVersion:1,flat:t});if(!t||typeof t!=`object`)throw Error(`sequenceDraft must be an object`);let n=Array.isArray(t.edges)?t.edges.map(e=>{let t=e?.data?.outcome||F(e?.label);return{...e,...t?{data:{...e.data||{},outcome:t}}:{}}}):t.edges;return j.parse({...t,schemaVersion:1,...n?{edges:n}:{}})}var L=async e=>{let t=e.sequence?.excludeConnected??!0,n=e.sequence?.autoAcceptInvitation??!0,r={endOfSequenceAction:`WAIT_UNTIL_ACCEPTED`,...e.campaignConfig?.notConnectedConfig||{}},i=C(e.sequenceDraft);return{executionSchemaVersion:1,name:e.name,description:e.description||``,accountIDs:e.accountIDs||[],leadListId:e.leadListId||e.leads?.leadListId||null,sequenceDraft:i?I(i):void 0,excludeConnected:t,autoAcceptInvitation:n,operationalTimes:e.operationalTimes,timeZone:e.timeZone||`IST`,csvConfig:P(e.csvConfig),sequenceType:e.sequenceType,leadListConfiguration:e.leadListConfiguration,campaignConfig:{...e.campaignConfig,excludeConnected:t,autoAcceptInvitation:n,notConnectedConfig:r,leadListConfiguration:e.leadListConfiguration,aiContext:e.campaignConfig?.aiContext||e.aiContext||void 0}}};function R(e){return e?.status===`QUEUED`||e?.status===`PROCESSING`}function z(e){return R(e.launchOperation)?{...e,...e.status?{status:`ACTIVE`}:{},...e.campaignStatus?{campaignStatus:`ACTIVE`}:{},dynamicStatus:typeof e.dynamicStatus==`object`?{status:`RUNNING`}:`RUNNING`}:e.launchOperation?.failed?{...e,dynamicStatus:typeof e.dynamicStatus==`object`?{status:`FAILED`}:`FAILED`}:e}var B=class extends Error{problem;errorInfo;response;constructor(e,t){super(e),this.name=`CampaignPreviewStreamError`,this.problem=t?.problem,this.errorInfo={status:t?.status,problem:t?.problem,data:t?.body},t?.status&&t.body&&(this.response={status:t.status,data:t.body})}},V={"connection-note":`/campaigns/sequences/preview/connection-note`,message:`/campaigns/sequences/preview/message`,inmail:`/campaigns/sequences/preview/inmail`},H=async e=>{let t=await e.json();if(!e.ok)throw e.status===401&&a.setState({isAuthenticated:!1,user:null,accessToken:null}),new B(typeof t.error==`string`?t.error:`Preview generation failed.`,{status:e.status,body:t});return t};async function U(t,n,r){let i=e({Accept:`text/event-stream`,"Content-Type":`application/json; charset=utf-8`}).headers,o;try{o=await fetch(`${c}${V[t]}`,{method:`POST`,headers:i,body:JSON.stringify({...n,stream:!0})})}catch(e){throw new B(e instanceof Error?e.message:`Unable to reach the preview service.`,{problem:`NETWORK_E
1RROR`})}if(!(o.headers.get(`content-type`)||``).includes(`text/event-stream`))return H(o);if(!o.body)throw new B(`The preview stream could not be opened.`,{problem:`CONNECTION_ERROR`});let s=o.body.getReader(),l=new TextDecoder,u=``;for(;;){let e;try{e=await s.read()}catch(e){throw new B(e instanceof Error?e.message:`The preview stream was interrupted.`,{problem:`CONNECTION_ERROR`})}if(e.done)break;u+=l.decode(e.value,{stream:!0}).replace(/\r\n/g,` 2`);let t=u.indexOf(` 3 4`);for(;t>=0;){let e=u.slice(0,t);u=u.slice(t+2);let n=e.split(` 5`).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(` 6`);if(n){let e=JSON.parse(n);if(e.type===`progress`||e.type===`heartbeat`)r(e);else if(e.type===`completed`)return e.body;else if(e.type===`error`)throw e.status===401&&a.setState({isAuthenticated:!1,user:null,accessToken:null}),new B(typeof e.body.error==`string`?e.body.error:`Preview generation failed.`,{status:e.status,body:e.body})}t=u.indexOf(` 7 8`)}}throw new B(`The preview stream ended before completion.`,{problem:`CONNECTION_ERROR`})}var W=async e=>{let t={page:e?.page??1,limit:e?.limit??25};e?.searchText&&(t.searchText=e.searchText),e?.statuses&&e.statuses.length>0&&(t.status=e.statuses.join(`,`)),e?.accountIds&&e.accountIds.length>0&&(t.accountIds=e.accountIds.join(`,`));let n=await i(`/campaigns`,t).then(s);return{...n,data:{...n.data,campaigns:n.data.campaigns.map(z)}}},G=async e=>await i(`/campaigns/${e}`,{}).then(e=>s(e,!1)).then(e=>{let t=e.data.accountStatuses||{},n=e.data.leads;return{...e,data:{...z(e.data),accountStatuses:t,leads:n,configs:e.data.configs}}}),K=async e=>await n(`/campaigns/${e}/validate-sequence`,{}).then(s),q=async(e,t)=>await n(`/campaigns/${e}/launch`,t?{executionHash:t}:{}).then(s),J=async e=>i(`/campaigns/${e}/launch-status`,{}).then(s),Y=async e=>{let t=await i(`/campaigns/insights/${e}`,{}).then(s);return{...t,data:z(t.data)}},X=async(e,t)=>await n(`/campaigns/${e}/leads/account-reassignment-preview`,t).then(s),Z=async(e,t)=>await n(`/campaigns/${e}/leads/account-reassignment`,t).then(s),re=async(e,t)=>await n(`/campaigns/${e}/accounts`,{accountIds:t,reassignExistingLeads:!1}).then(s),ie=e=>{switch(e){case x.COMPLETED:return`success`;case x.PAUSED:return`paused`;case x.RUNNING:return`active`;case x.ARCHIVED:return`archived`;default:return e}},ae=async e=>await r(`/campaigns/${e}`).then(s),oe=async(e,t)=>{let n=ie(t.status),r={...t,status:n};if(r.operationalTimes){let e={...r.operationalTimes};Object.keys(e).forEach(t=>{if(t===`timezone`||typeof e[t]!=`object`)return;let n=e[t];n&&typeof n==`object`&&(`startTime`in n&&typeof n.startTime==`number`&&(n.startTime=Math.floor(n.startTime/60)),`endTime`in n&&typeof n.endTime==`number`&&(n.endTime=Math.floor(n.endTime/60)))}),r.operationalTimes=e}return await o(`/campaigns/${e}`,r).then(s)},se=async(e,t)=>{try{let e=t;if(!e?.id)throw Error(`Campaign ID is missing. Cannot update campaign.`);let n=await L(e);return await o(`/campaigns/${e.id}/update-paused-campaign`,n).then(s)}catch(e){throw e}},ce=async(e,t)=>(await n(`/campaigns/${e}/exclusion-reconciliation-preview`,{leadListConfiguration:t}).then(s)).data,le=async(n,r)=>{let i={...e({Accept:`text/csv`}),responseType:`blob`},a={};r?.filter&&(a.filter=r.filter),r?.connectionStatus?.length&&(a.connectionStatus=r.connectionStatus.join(`,`)),r?.engagementStatus?.length&&(a.engagementStatus=r.engagementStatus.join(`,`)),r?.replyStatus?.length&&(a.replyStatus=r.replyStatus.join(`,`)),r?.accountId?.length&&(a.accountId=r.accountId.join(`,`)),r?.overallStatus?.length&&(a.overallStatus=r.overallStatus.join(`,`)),r?.fromDate&&(a.fromDate=r.fromDate),r?.toDate&&(a.toDate=r.toDate),r?.searchText&&(a.searchText=r.searchText);let o=await t.get(`/campaigns/${n}/leads/export`,a,i);if(!o.ok||!o.data)throw Error(o.problem||`Failed to export campaign leads`);let s=`campaign_leads_${n}.csv`,c=o.headers||{},l=c[`content-disposition`]||c[`Content-Disposition`];if(l){let e=l.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);e&&e[1]&&(s=e[1].replace(/['"]/g,``).trim())}return{blob:o.data,filename:s}},ue=async(e,t,r)=>await n(`/campaigns/process-csv-to-campaign-lead`,{campaignId:e,s3Url:t,mainIdentifier:r}).then(s),de=async(e,t,r)=>await n(`/campaigns/pause-campaign-leads`,{campaignId:e,campaignLeadIds:t,filters:r}).then(s),fe=async(e,t,r)=>await n(`/campaigns/pause-leads`,{campaignId:e,campaignLeadIds:t,filters:r}).then(s),pe=async(e,t,r)=>await n(`/campaigns/resume-leads`,{campaignId:e,campaignLeadIds:t,filters:r}).then(s),me=async(e,t,r)=>await n(`/campaigns/delete-leads`,{campaignId:e,campaignLeadIds:t,filters:r}).then(s),he=async e=>await n(`/campaigns/enrichment/process`,e).then(s),ge=async(e,t)=>t?U(`connection-note`,e,t):await n(`/campaigns/sequences/preview/connection-note`,e).then(s),Q=async(e,t)=>t?U(`message`,e,t):await n(`/campaigns/sequences/preview/message`,e).then(s),_e=async(e,t)=>t?U(`inmail`,e,t):await n(`/campaigns/sequences/preview/inmail`,e).then(s),ve=async(e,t)=>await n(`/campaigns/${e}/duplicate`,{...t?{name:t}:{}}).then(s),$=new Map,ye=e=>{let t=$.get(e);if(t)return t;let n=i(`/campaigns/${e}/variable-health`,{}).then(s);$.set(e,n);let r=()=>{$.get(e)===n&&$.delete(e)};return n.then(r,r),n},be=async e=>await n(`/campaigns/${e}/duplicate-lead-choice`,{}).then(s),xe=async(e,t)=>await n(`/campaigns/${e}/share-token`,{includeMessages:t}).then(s),Se=async e=>await r(`/campaigns/${e}/share-token`).then(s);export{L as A,Z as C,se as D,oe as E,ee as F,te as I,y as L,C as M,x as N,K as O,b as P,ue as S,Se as T,de as _,be as a,X as b,ge as c,G as d,Y as f,q as g,W as h,me as i,P as j,R as k,_e as l,ye as m,xe as n,ve as o,J as p,ae as r,le as s,re as t,Q as u,fe as v,pe as w,he as x,ce as y};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.