1import{z as ce,q as e,J as g,x as w,w as T,u as I,p as v,D as de,W as he,v as pe,K as ue}from"./-1RkBR9N.js";import{m as xe,cV as me,w as ge,cW as Te,aC as je,aD as R,aE as Se,c5 as u,U as se,X as ae,H as fe,d as we,aF as Ce,aG as ye,aH as ve,G as be,bw as qe,l as A,a as H,cX as Ae,_ as ke,T as Pe,bx as Ee,by as De,c4 as ne,bz as Le,bn as Fe,bA as Me,bB as Re,bC as Be,bG as Oe,o as Q,M as _e,D as Ge,b8 as $,cY as $e,bo as He,ah as Ie,ai as Ne,ap as We,Z as z,bp as Ve,k as Ue,f as Qe,g as ze,h as k,i as Ke,bE as Xe}from"./CiccYPAo.js";import"./OD3CCZJ0.js";import"./DcX6Tqyv.js";import"./CDnTS3JI.js";import"./q0y4LOUZ.js";import"./WS1EPDiJ.js";import{E as Je}from"./DMFe3sIy.js";import{u as Ye}from"./DBA8Dbw-.js";import"./BEJVGkx6.js";import"./CHXTyely.js";import"./DT8QgAgI.js";const Ze=(t,n)=>{const{availability:l,search:o}=t,{data:h,...p}=xe(["get-sequence-templates",l,o],()=>me(t),{refetchOnMount:!0,...n});return{data:h,...p}},et=(t,n)=>{const l=ce(),o=["get-sequence-templates"],{mutate:h,...p}=ge(["toggle-sequence-template-availability",t],()=>Te(t),{...n,onMutate:async c=>{await l.cancelQueries({queryKey:o});const d=l.getQueryData(o);return l.setQueriesData({queryKey:o},r=>{var x;return r&&{...r,sequenceTemplates:(x=r==null?void 0:r.sequenceTemplates)==null?void 0:x.map(i=>(i.id===t&&(i.isAvailableForTeam=!i.isAvailableForTeam),i))}}),{prevData:d}}});return{toggleSequenceTemplateAvailability:h,...p}},tt=7,st=w(T,{target:"elvbhae7"})("flex:1;min-width:0;height:100%;display:flex;flex-direction:column;border-radius:12px;border:1px solid ",({theme:t})=>t.palette.greyBlue[30],";background-color:#ffffff;overflow:hidden;"),at=w(T,{target:"elvbhae6"})({name:"1qcgktf",styles:"flex:1;min-height:0;overflow:hidden"}),K=w(T,{target:"elvbhae5"})({name:"149wjj1",styles:"flex:0 0 72px;display:flex;align-items:center;justify-content:flex-start"}),X=w(T,{target:"elvbhae4"})({name:"wxw611",styles:"flex:0 0 220px;min-width:0;display:flex;align-items:center"}),J=w(T,{target:"elvbhae3"})({name:"1e5i182",styles:"flex:1 1 0;min-width:0;display:flex;align-items:center;gap:8px"}),Y=w(T,{target:"elvbhae2"})({name:"paswu9",styles:"flex:0 0 150px;min-width:0;display:flex;align-items:center"}),Z=w(T,{target:"elvbhae1"})({name:"1syjchl",styles:"flex:0 0 100px;display:flex;justify-content:center"}),ee=w(T,{shouldForwardProp:t=>t!=="widthPx",target:"elvbhae0"})("flex:0 0 ",({widthPx:t})=>t,"px;min-width:0;display:flex;justify-content:flex-end;gap:24px;"),nt=({availability:t,"data-testid":n="sequence-templates-table-skeleton"})=>{const l=t===u.personal,o=l?205:110,h=l?4:2;return e.jsxs(st,{"data-testid":n,children:[e.jsxs(je,{children:[!l&&e.jsx(K,{}),e.jsx(X,{children:e.jsx(g,{variant:"rounded",width:56,height:18,sx:R})}),e.jsx(J,{children:e.jsx(g,{variant:"rounded",width:80,height:18,sx:R})}),e.jsx(Y,{children:e.jsx(g,{variant:"rounded",width:48,height:18,sx:R})}),l&&e.jsx(Z,{children:e.jsx(g,{variant:"rounded",width:56,height:18,sx:R})}),e.jsx(ee,{widthPx:o})]}),e.jsx(at,{children:Array.from({length:tt},(p,c)=>e.jsxs(Se,{sx:{minHeight:64},children:[!l&&e.jsx(K,{children:e.jsx(g,{variant:"circular",width:35,height:35})}),e.jsx(X,{children:e.jsx(g,{variant:"rounded",width:"72%",height:16})}),e.jsx(J,{children:e.jsx(g,{variant:"rounded",width:"86%",height:14})}),e.jsx(Y,{children:e.jsx(g,{variant:"rounded",width:"60%",height:16})}),l&&e.jsx(Z,{children:e.jsx(g,{variant:"rounded",width:56,height:22,sx:{borderRadius:"12px"}})}),e.jsx(ee,{widthPx:o,children:Array.from({length:h},(d,r)=>e.jsx(g,{variant:"rounded",width:20,height:20},r))})]},c))})]})},lt=({title:t,children:n,guideLink:l,videoLink:o})=>{const h=I(),{checkFeature:p}=se(),[c,d]=p(ae.sequenceTeamTemplates),r=v.useMemo(()=>[{name:"Personal",route:"personal"},{name:"Team",route:"team",disabled:!c,disabledTooltip:d}],[c,d]),x=()=>{h("/sequence-templates/new")};return e.jsxs(e.Fragment,{children:[e.jsxs(fe,{children:[e.jsx(we,{children:t}),e.jsx(Ce,{children:r.map(({name:i,route:P,disabled:j,disabledTooltip:S})=>{const b=`/sequence-templates/${P}`;return e.jsx(ye,{to:b,disabled:j,...j&&S&&{tooltip:S},children:i},i)})}),e.jsx(ve,{articleLink:l,videoLink:o}),e.jsx(be,{onClick:x,children:"Create Template"})]}),n]})},te=ne.reduce((t,n)=>(t[n.category]=n.name,t),{}),rt=({sequenceTemplate:t,availability:n,rowIndex:l=0})=>{const o=I(),h=de(),{id:p,sequence:c,name:d,category:r,owner:x,isAvailableForTeam:i}=t,{deleteSequenceTemplate:P,isLoading:j}=Ye(p),{toggleSequenceTemplateAvailability:S,isLoading:b}=et(p),{checkFeature:C}=se(),[B]=C(ae.sequenceTeamTemplates),a=()=>{h(Q({type:_e.VIEW_SEQUENCE_TEMPLATE,headerText:d==null?void 0:d.slice(0,40),size:"medium",params:{sequenceTemplate:{...t},availability:n}}))},L=()=>{const y=c.map(f=>({...f,is_editing:!0}));o(`/sequence-templates/${p}`,{state:{name:d,category:r,sequence:y,isAvailableForTeam:i}})},F=()=>{o("/sequence-templates/new",{state:{name:`${d} (clone)`,category:r,sequence:c,isAvailableForTeam:i}})},O=()=>{S()},M=()=>{h(Q({headerText:"Delete Template",descriptionText:"Are you sure to delete this template?",onConfirm:P}))},E=[{isShown:!0,title:"View Template",onClick:a,icon:e.jsx(Le,{width:"20px",height:"20px"})},{isShown:n===u.personal,title:"Edit Template",onClick:L,icon:e.jsx(Fe,{width:"20px",height:"20px"})},{isShown:n===u.personal&&B,title:i?"Unshare template":"Share to Team",onClick:O,isLoading:b,icon:i?e.jsx(Me,{width:"20px",height:"20px"}):e.jsx(Re,{width:"20px",height:"20px"})},{isShown:n===u.personal,title:"Delete Template",onClick:M,isLoading:j,icon:e.jsx(Be,{width:"20px",height:"20px"})},{isShown:n===u.team,title:"Clone Template",onClick:F,icon:e.jsx(Oe,{width:"20px",height:"20px"})}];return e.jsxs(qe,{staggerDelayMs:De(l),children:[n===u.team&&e.jsx(A,{paddingBox:"14px 16px",children:e.jsx(he,{sx:{width:35,height:35},src:(x==null?void 0:x.picture)||Je})}),e.jsx(A,{maxWidth:"200px",tooltip:d,children:e.jsx(H,{inline:!0,fontSize:"15px",children:d})}),e.jsx(A,{children:c==null?void 0:c.map((y,f)=>{const{title:q}=Ae(y.type,y)??{};
1return e.jsxs(H,{color:"primary.wlLight",maxWidth:"250px",inline:!0,crop:!0,fontSize:"15px",children:[f?", ":"","Step - ",f+1," - ",q]},f)})}),e.jsx(A,{tooltip:te[r],children:te[r]}),n===u.personal&&e.jsx(A,{justifyContent:"center",children:i?e.jsx(ke,{border:"1px solid #A0CCE3",color:"#026AA2",bgColor:"#DDEDF6",tag:"Shared"}):""}),e.jsx(A,{contentStyle:{width:"100%"},paddingBox:"22px 16px",children:e.jsx(T,{display:"flex",gap:"28px",px:"8px",justifyContent:"flex-end",children:E==null?void 0:E.map(({icon:y,onClick:f,title:q,isShown:_})=>_&&e.jsx(Pe,{title:q,children:e.jsx(Ee,{onClick:f,children:y})},q))})})]})},it=[{label:"All",value:""},...ne.map(({category:t,name:n})=>({label:n,value:t}))],ot=w(T,{target:"e55257w0"})({name:"1pajyl6",styles:"position:relative;flex:1;min-height:0;display:flex;flex-direction:column"}),wt=({availability:t})=>{var U;const{palette:n}=pe(),[l]=ue(),o=I(),[h,p]=v.useState([]),[c,d]=v.useState("name"),[r,x]=v.useState("ASC"),[i,P]=v.useState(Ge),[j,S]=v.useState($),b=l.get("category"),{data:C,isLoading:B}=Ze({availability:t,search:h},{select:s=>({...s,"":Object.values(s).reduce((m,G)=>m+G,0)})}),{data:a,isLoading:L,isFetching:F,isPlaceholderData:O}=$e({availability:t,search:h,sortField:c,sortOrder:r,page:j,perPage:i,category:b},{keepPreviousData:!0}),M=He(L,t),{route:E,title:y,guideLink:f,videoLink:q}=v.useMemo(()=>t===u.personal?{route:"personal",title:"Personal Templates",guideLink:"https://help.meetalfred.com/en/articles/9118624-create-campaign-sequence-templates",videoLink:"https://player.vimeo.com/video/1152424974"}:{route:"team",title:"Team Templates",guideLink:"https://help.meetalfred.com/en/articles/9118624-create-campaign-sequence-templates",videoLink:"https://player.vimeo.com/video/1152424974"},[t]),_=!(a!=null&&a.total)&&!h.length&&!b&&!L&&!F,N=F&&O&&!M;let D;M||N?D="skeleton":_?D="empty":D="data";const le=D==="data"||N,re=s=>{if((s==null?void 0:s.value)!==b){S($);const m=`/sequence-templates/${E}`,G=s!=null&&s.value?`${m}?category=${s.value}`:m;o(G)}},ie=s=>{p((s==null?void 0:s.map(({label:m})=>m))||[]),S(1)},W=(s,m)=>{d(s),x(m)},oe=s=>{S(s.page),P(s.perPage)};v.useEffect(()=>{a&&a.sequenceTemplates&&!a.sequenceTemplates.length&&j*i-a.total===i&&S(s=>s-1||$)},[(U=a==null?void 0:a.sequenceTemplates)==null?void 0:U.length,a==null?void 0:a.total,j,i]);const V=it.map(s=>({value:String(s.value),label:`${s.label} ${!B&&(C!=null&&C[s.value])?`(${C==null?void 0:C[s.value]})`:"(0)"}`}));return e.jsx(lt,{title:y,guideLink:f,videoLink:q,children:e.jsxs(Ie,{children:[le&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{bgcolor:`${n.greyNeutral[30]}!important`}),e.jsxs(We,{className:"flex",justifyContent:"space-between",children:[e.jsx(z,{isMulti:!0,isCreatable:!0,placeholder:"Search by name...",onChange:ie,wrapperProps:{width:"fit-content",minWidth:"305px"},additionalProps:{noOptionsMessage:()=>"Type and hit Return",isSearchable:!0,components:{DropdownIndicator:()=>null,ClearIndicator:()=>null}}}),e.jsx(z,{value:V.find(s=>s.value===String(l.get("category")||"")),onChange:re,wrapperProps:{width:"fit-content",minWidth:"305px"},controlLabel:e.jsx(e.Fragment,{children:e.jsx(H,{inline:!0,children:"Category:Â "})}),options:V})]})]}),e.jsx(ot,{children:e.jsx(Ve,{view:D,skeleton:e.jsx(nt,{availability:t}),emptyState:e.jsx(Xe,{src:q,title:`No ${t} templates yet`,description:`It looks like you don't have ${t} templates yet.`}),children:e.jsxs(Ue,{paginationProps:{page:j,perPage:i,total:a==null?void 0:a.total,onPaginationChange:oe},children:[e.jsx(Qe,{children:e.jsxs(ze,{children:[t===u.team&&e.jsx(k,{width:"72px"}),e.jsx(k,{name:"name",sorting:{sortOrder:r,sortField:c,onSortFieldChange:W},width:"220px",justifyContent:"flex-start",children:"Name"}),e.jsx(k,{children:"Sequence"}),e.jsx(k,{width:"150px",children:"Type"}),t===u.personal&&e.jsx(k,{name:"isAvailableForTeam",sorting:{sortOrder:r,sortField:c,onSortFieldChange:W},width:"100px",justifyContent:"center",children:"Status"}),e.jsx(k,{width:t==="team"?"110px":"205px"})]})}),e.jsx(Ke,{placeholder:!(a!=null&&a.total)&&`No ${t===u.personal?"Personal":"Team"} Templates`,children:((a==null?void 0:a.sequenceTemplates)??[]).map((s,m)=>e.jsx(rt,{sequenceTemplate:s,availability:t,rowIndex:m},s.id))})]})})})]})})};export{wt as SequenceTemplates,lt as SequenceTemplatesLayout};
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.