1"use strict";(()=>{(self.webpackChunkpanelist_react=self.webpackChunkpanelist_react||[]).push([[5142],{15142:((Q,Z,c)=>{c.r(Z),c.d(Z,{InboxRunRulesDialog:()=>v,default:()=>K});var o=c(46417),f=c(47313),b=c(10437),w=c(38743),A=c(85281),z=c(94469),x=c(47605),e=c(35585),R=c(74512),L=c(86442);const W=(p,M)=>{if(p.action==="markRead")return"mark as read";if(p.action==="delete")return"delete";if(p.action==="move"){const y=M.find(D=>D.providerFolderId===p.targetFolderId);return y?`move to ${y.displayName}`:"move to a folder that is no longer listed"}return"an action this screen does not model"},v=({open:p,onClose:M,companyId:y,mailboxUserId:D,mailboxEmail:T=null,scope:U,folderLabel:i})=>{const[n,r]=(0,f.useState)([]),[d,u]=(0,f.useState)([]),[m,E]=(0,f.useState)(!1),[P,_]=(0,f.useState)(null),[S,a]=(0,f.useState)(new Set),[g,$]=(0,f.useState)(!1),[I,j]=(0,f.useState)(null),[C,O]=(0,f.useState)(null),B=t=>{var s,l;return t.action==="markRead"||t.action==="delete"?!!((s=t.fromContains)!=null&&s.trim()):t.action==="move"?!!((l=t.fromContains)!=null&&l.trim())&&!!t.targetFolderId:!1},k=t=>{var s;return t.condition?t.condition==="other":!((s=t.fromContains)!=null&&s.trim())},X=t=>{var s;return t.action==="other"?"This rule was made in "+(T?"the mail app":"the provider")+" and does something this screen does not model, so running part of it would be worse than not running it.":k(t)?"This rule matches on
1something this screen can\u2019t read \u2014 a subject, a recipient, more than one sender, or an \u201Cexcept when\u201D clause. It is still running in the mailbox; it just cannot be re-applied from here.":(s=t.fromContains)!=null&&s.trim()?t.action==="move"&&!t.targetFolderId?"This rule moves mail to a folder it no longer names.":null:"This rule names no sender, so there is nothing to match on."},N=(0,f.useCallback)(async()=>{E(!0),_(null),O(null);try{const[t,s]=await Promise.all([R.inboxService.listRules(y,D),R.inboxService.listMailFolders(y,D)]);r(t),u(s.folders),a(new Set(t.filter(B).map(l=>l.id)))}catch(t){r([]),_((0,R.inboxErrorText)(t,"Couldn\u2019t load this mailbox\u2019s rules."))}finally{E(!1)}},[y,D]);(0,f.useEffect)(()=>{p&&(j(null),N())},[p,N]);const Y=t=>{a(s=>{const l=new Set(s);return l.has(t)?l.delete(t):l.add(t),l})},F=n.filter(t=>S.has(t.id)&&B(t)),G=async()=>{if(!F.length)return;$(!0),j(null),O(null);const t=[];try{for(let s=0;s<F.length;s+=1){const l=F[s];try{const h=await(0,L.Px)(y,U,{fromQuery:l.fromContains}),H=h.conversations.map(ee=>String(ee.id));if(!H.length){t.push({ruleId:l.id,matched:0,changed:0,failed:0,truncated:h.truncated,error:null});continue}const q=l.action==="move"?{action:"move",folderId:String(l.targetFolderId)}:l.action==="delete"?{action:"trash"}:{action:"read",read:!0},V=await(0,L.dh)(y,H,q);t.push({ruleId:l.id,matched:H.length,changed:V.succeeded,failed:V.failed,truncated:h.truncated,error:null})}catch(h){t.push({ruleId:l.id,matched:0,changed:0,failed:0,truncated:!1,error:(0,R.inboxErrorText)(h,"Couldn\u2019t run that rule.")})}}O(t)}catch(s){O(t),j((0,R.inboxErrorText)(s,"The run stopped part-way through. Check the rows below for what did happen."))}finally{$(!1)}},J=t=>{var s;return(s=C==null?void 0:C.find(l=>l.ruleId===t))!=null?s:null};return(0,o.jsx)(z.Z,{open:p,onClose:M,maxWidth:"xs",fullWidth:!0,"aria-labelledby":"inbox-run-rules-title","aria-describedby":"inbox-run-rules-subtitle","data-testid":"inbox-run-rules-dialog",PaperProps:{sx:{borderRadius:`${e.hs.radius}px`}},children:(0,o.jsxs)(b.Z,{sx:{p:2.5,display:"flex",flexDirection:"column",gap:1.25},children:[(0,o.jsx)(x.Z,{id:"inbox-run-rules-title",component:"h2",sx:{fontFamily:e.hs.font,fontSize:15,fontWeight:700,color:e.hs.text},children:T?`Run rules now \u2014 ${T}`:"Run rules now"}),(0,o.jsxs)(x.Z,{id:"inbox-run-rules-subtitle",sx:{fontFamily:e.hs.font,fontSize:e.hs.fontSizeSm,color:e.hs.textSecondary},children:["Applies rules that already exist to the mail already in ",i,". Rules normally only act on mail as it arrives; this catches up everything that came before them."]}),m?(0,o.jsxs)(b.Z,{sx:{display:"flex",alignItems:"center",gap:1,py:3},children:[(0,o.jsx)(A.Z,{size:16}),(0,o.jsx)(x.Z,{sx:{fontFamily:e.hs.font,fontSize:e.hs.fontSizeSm,color:e.hs.textSecondary},children:"Loading\u2026"})]}):P?(0,o.jsxs)(b.Z,{sx:{display:"flex",flexDirection:"column",gap:1,alignItems:"flex-start"},children:[(0,o.jsx)(x.Z,{role:"alert","data-testid":"inbox-run-rules-error",sx:{fontFamily:e.hs.font,fontSize:e.hs.fontSizeSm,color:e.hs.danger},children:P}),(0,o.jsx)(w.Z,{focusRipple:!0,"data-testid":"inbox-run-rules-retry",onClick:()=>{N()},sx:{fontFamily:e.hs.font,fontSize:e.hs.fontSizeSm,fontWeight:700,color:e.hs.text,px:1.25,py:.6,borderRadius:1,border:`1px solid ${e.hs.border}`,"&:hover":{backgroundColor:e.hs.hover}},children:"Try again"})]}):n.length===0?(0,o.jsx)(x.Z,{"data-testid":"inbox-run-rules-empty",sx:{fontFamily:e.hs.font,fontSize:e.hs.fontSizeSm,color:e.hs.textSecondary},children:"This mailbox has no rules yet, so there is nothing to run. Create one first \u2014 the \u22EF menu beside the mailbox opens the rules editor."}):(0,o.jsx)(b.Z,{sx:{display:"flex",flexDirection:"column",gap:.25,maxHeight:280,overflowY:"auto"},children:n.map(t=>{const s=X(t),l=S.has(t.id)&&!s,h=J(t.id);return(0,o.jsx)(b.Z,{children:(0,o.jsxs)(w.Z,{focusRipple:!0,role:"checkbox","aria-checked":l,disabled:!!s||g,"data-testid":`inbox-run-rules-item-${t.id}`,onClick:()=>Y(t.id),sx:{width:"100%",display:"flex",alignItems:"flex-start",gap:1,px:1,py:.75,borderRadius:`${e.hs.radius}px`,textAlign:"left",justifyContent:"flex-start","&:hover":{backgroundColor:s?"transparent":e.hs.hover},"&.Mui-disabled":{opacity:1},"&.Mui-focusVisible":{boxShadow:`0 0 0 2px ${e.hs.focusRing}`}},children:[(0,o.jsx)(b.Z,{"aria-hidden":!0,sx:{mt:"2px",flexShrink:0,width:13,height:13,borderRadius:"3px",border:`1px solid ${l?e.hs.primaryBtn:e.hs.border}`,backgroundColor:l?e.hs.primaryBtn:"transparent"}}),(0,o.jsxs)(b.Z,{sx:{minWidth:0,flex:1}
1,children:[(0,o.jsx)(x.Z,{component:"span",sx:{display:"block",fontFamily:e.hs.font,fontSize:e.hs.fontSize,color:s?e.hs.textTertiary:e.hs.text,lineHeight:1.25},children:k(t)?`${t.displayName?`\u201C${t.displayName}\u201D`:"A rule created in the mail app"} \u2014 ${W(t,d)}`:`From contains \u201C${t.fromContains}\u201D \u2014 ${W(t,d)}`}),s?(0,o.jsx)(x.Z,{component:"span",sx:{display:"block",fontFamily:e.hs.font,fontSize:11,color:e.hs.textTertiary,lineHeight:1.35},children:s}):null,h?(0,o.jsx)(x.Z,{component:"span","data-testid":`inbox-run-rules-outcome-${t.id}`,sx:{display:"block",fontFamily:e.hs.font,fontSize:11,color:h.error?e.hs.danger:e.hs.textSecondary,lineHeight:1.35},children:h.error?h.error:h.matched===0?`Nothing in ${i} matched.`:`${h.changed} of ${h.matched} changed${h.failed?`, ${h.failed} refused`:""}${h.truncated?" \u2014 more matched than one pass reaches; run it again":""}.`}):null]})]})},t.id)})}),!m&&!P&&n.length>1&&n.every(t=>t.sequence===null)&&(0,o.jsx)(x.Z,{sx:{fontFamily:e.hs.font,fontSize:11,color:e.hs.textTertiary,lineHeight:1.35},children:"This provider does not rank rules, so these run top to bottom in the order shown \u2014 which is the order they were made, not a priority it keeps."}),I&&(0,o.jsx)(x.Z,{role:"alert","data-testid":"inbox-run-rules-run-error",sx:{fontFamily:e.hs.font,fontSize:e.hs.fontSizeSm,color:e.hs.danger},children:I}),(0,o.jsxs)(b.Z,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[(0,o.jsx)(w.Z,{focusRipple:!0,"data-testid":"inbox-run-rules-close",onClick:M,sx:{fontFamily:e.hs.font,fontSize:e.hs.fontSizeSm,fontWeight:700,color:e.hs.text,px:1.5,py:.75,borderRadius:1,border:`1px solid ${e.hs.border}`,"&:hover":{backgroundColor:e.hs.hover},"&.Mui-focusVisible":{boxShadow:`0 0 0 2px ${e.hs.focusRing}`}},children:C?"Close":"Cancel"}),(0,o.jsx)(w.Z,{focusRipple:!0,"data-testid":"inbox-run-rules-run",onClick:()=>{G()},disabled:g||m||!F.length,sx:{fontFamily:e.hs.font,fontSize:e.hs.fontSizeSm,fontWeight:700,color:e.hs.textOnDark,px:1.5,py:.75,borderRadius:1,backgroundColor:e.hs.primaryBtn,"&:hover":{backgroundColor:e.hs.primaryBtnHover},"&.Mui-disabled":{backgroundColor:e.hs.border,color:e.hs.textTertiary,opacity:1},"&.Mui-focusVisible":{boxShadow:`0 0 0 2px ${e.hs.focusRing}`}},children:g?"Running\u2026":F.length===1?"Run 1 rule":`Run ${F.length} rules`})]})]})})};v.displayName="InboxRunRulesDialog";const K=v}),86442:((Q,Z,c)=>{c.d(Z,{$L:()=>v,NF:()=>y,Px:()=>K,VL:()=>D,dh:()=>M,rc:()=>T,yO:()=>U});var o=c(95193),f=c(74512),b=Object.defineProperty,w=Object.defineProperties,A=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,e=Object.prototype.propertyIsEnumerable,R=(i,n,r)=>
1n in i?b(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,L=(i,n)=>{for(var r in n||(n={}))x.call(n,r)&&R(i,r,n[r]);if(z)for(var r of z(n))e.call(n,r)&&R(i,r,n[r]);return i},W=(i,n)=>w(i,A(n));const v=500,K=async(i,n,r)=>{var d,u,m,E,P;const _=((d=r.fromQuery)!=null?d:"").trim();if(!_)return{conversations:[],truncated:!1,total:null};const S=[],a=new Set;let g=null,$=null,I=!1;for(let j=0;j<Math.ceil(v/o.BS);j+=1){const C=await f.inboxService.listConversations(i,{folder:n.folder,teamKey:(u=n.teamKey)!=null?u:void 0,mailboxUserIds:n.mailboxUserIds,mailFolderId:(m=n.mailFolderId)!=null?m:void 0,fromQuery:_,before:(E=r.before)!=null?E:void 0,limit:o.BS,cursor:g});if(C.totalKnown&&typeof C.total=="number"&&($=C.total),C.conversations.forEach(O=>{var B;const k=String((B=O.id)!=null?B:"").trim();!k||a.has(k)||(a.add(k),S.push(O))}),g=(P=C.nextCursor)!=null?P:null,!g)break;if(S.length>=v){I=!0;break}}return g&&(I=!0),{conversations:S.slice(0,v),truncated:I||S.length>v,total:$}},p=(i,n)=>{var r;const d=n.flatMap(a=>a.results),u=d.filter(a=>a.ok),m=u.filter(a=>a.reversible).length,E=u.filter(a=>!a.reversible&&a.undecided).length,P=u.length-m-E,_=n.flatMap(a=>{var g;return(g=a.undo)!=null?g:[]}),S=(r=n.map(a=>a.irreversibleReason).find(a=>!!a))!=null?r:null;return{action:i,dryRun:n.every(a=>a.dryRun),requested:d.length,succeeded:u.length,failed:d.length-u.length,reversibleCount:m,irreversibleCount:P,undecidedCount:E,reversible:u.length>0&&m===u.length&&_.length>0,irreversibleReason:u.length>0&&m!==u.length?S:null,undo:_.length?_:null,truncatedCount:d.filter(a=>a.ok&&a.messagesTruncated).length,results:d}},M=async(i,n,r)=>{const d=[];for(let u=0;u<n.length;u+=o.D$){const m=await f.inboxService.bulkConversations(i,W(L({},r),{ids:n.slice(u,u+o.D$)}));d.push(m)}return d.length?d.length===1?d[0]:p(r.action,d):p(r.action,[])},y=10,D=(i,n=new Date)=>new Date(n.getTime()-Math.max(1,Math.round(i))*24*60*60*1e3).toISOString(),T=(i,n)=>{const r=n.conversations.map(d=>String(d.id));return i==="keepLatest"?r.slice(1):r},U=(i,n,r)=>i==="alwaysMove"&&!r?"Choose the folder this sender\u2019s mail should go to.":i==="keepLatest"&&n.truncated?`More than ${v} conversations match, which is more than this can take in one pass. Narrow the folder or use \u201CDelete everything from this sender\u201D, which can be run again.`:T(i,n).length?null:i==="keepLatest"?"Only one conversation matches, and that is the one this keeps.":"Nothing in this folder matches."})}]);})();
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.