Scraped ${g} WFO days and ${h} WFH days across ${M} weeks, between ${D(c)} and ${D(d)}.
WFO
${w}%25
${g} days
WFH
${f}%25
${h} days
Target (WFH)
40%25
`,document.body.appendChild(l),l.showModal();let C=!1,k="rolling",H=V,L={rolling:"WFH %25 over a rolling window of recent scheduled days. Reacts quickly to recent changes.",cumulative:"WFH %25 from the start of the range. Smooth, but slow to react as history grows.",deficit:"Running WFH budget in days. Positive (green) = WFH days to spare. Negative (red) = too few WFH days so far.",monthly:"Monthly WFH budget. Each bar shows the WFO/WFH split; labels show the signed WFH surplus or deficit."},A=l.querySelector(".view-description"),y=l.querySelector(".window-input"),$=l.querySelector(".window-input input"),F=()=>{A.textContent=L[k]},I=()=>{y.classList.toggle("hidden",k!=="rolling")},N=()=>nt(l,r,n,k,H);$.addEventListener("input",()=>{let b=parseInt($.value,10);if(!Number.isFinite(b))return;H=Math.max(2,Math.round(b)),k==="rolling"&&C&&N()}),$.addEventListener("blur",()=>{$.value=String(H)}),F(),I(),l.querySelectorAll(".view-btn").forEach(b=>{b.addEventListener("click",()=>{let S=b.dataset.view;S!==k&&(k=S,l.querySelectorAll(".view-btn").forEach(R=>R.classList.remove("active")),b.classList.add("active"),F(),I(),N())})}),l.querySelectorAll(".tab").forEach(b=>{b.addEventListener("click",()=>{l.querySelectorAll(".tab").forEach(S=>S.classList.remove("active")),l.querySelectorAll(".tab-content").forEach(S=>S.classList.remove("active")),b.classList.add("active"),l.querySelector(`.tab-content[data-tab="${b.dataset.tab}"]`).classList.add("active"),b.dataset.tab==="analysis"&&!C&&(C=!0,N())})}),l.querySelector(".btn-combined").addEventListener("click",()=>{U(o,e,"text/calendar;charset=utf-8")}),l.querySelector(".btn-split").addEventListener("click",()=>{let b=`NICE Schedule WFO ${t}.ics`,S=`NICE Schedule WFH ${t}.ics`;U(_(s,{calendarName:"NICE Schedule (WFO)"}),b,"text/calendar;charset=utf-8"),U(_(i,{calendarName:"NICE Schedule (WFH)"}),S,"text/calendar;charset=utf-8")}),l.querySelector(".btn-close").addEventListener("click",()=>{l.close()}),l.addEventListener("close",()=>{l.remove()})}function rt(o){let e=parseInt(o.slice(1,3),10),r=parseInt(o.slice(3,5),10),t=parseInt(o.slice(5,7),10);return new Date(2e3+e,r-1,t)}function st(o){return(o.contentWindow?.location.href??o.src??"").match(/startDay=(\d+)/)?.[1]??null}function it(o){let e=String(o.getFullYear()%25100).padStart(2,"0"),r=String(o.getMonth()+1).padStart(2,"0"),t=String(o.getDate()).padStart(2,"0");return`1${e}${r}${t}`}function lt(o){return`https://uber.nicecloudsvc.com/agent/displayMyScheduleAction.mvc?startDay=${o}&viewFormat=weekly`}async function ct(o,e,r=2e4){return new Promise(t=>{let i=setTimeout(()=>{console.log(`[NICE Export] Navigation timed out after ${r}ms`),t(!1)},r);o.addEventListener("load",()=>{clearTimeout(i),t(!0)},{once:!0}),o.contentWindow.location.href=e})}async function dt(o,e){let r=[],t=e.end?1/0:52;console.log(`[NICE Export] Starting from: ${e.start.toDateString()}`+(e.end?`, ending at week containing: ${e.end.toDateString()}`:` (go until done, cap ${t})`));for(let n=0;ne.end)break;let c=lt(it(a));if(console.log(`[NICE Export] Page ${n+1}: navigating to ${c}`),!await ct(o,c)){console.log("[NICE Export] Navigation timed out, stopping");break}let u=o.contentDocument;if(!u){console.log("[NICE Export] No iframe document, stopping");break}let g=ut(u);if(g.length===0){if(e.end){console.log(`[NICE Export] Page ${n+1}: no rows, continuing (end date set)`);continue}console.log(`[NICE Export] Page ${n+1}: no rows, stopping`);break}let h=gt(g);console.log(`[NICE Export] Page ${n+1}: ${h.length} events`),r.push(...h)}let i=new Date(e.start.getFullYear(),e.start.getMonth(),e.start.getDate()),s=e.end?new Date(e.end.getFullYear(),e.end.getMonth(),e.end.getDate(),23,59,59,999):null;return r.filter(n=>!(n.starts))}function ut(o){return Array.from(o.querySelectorAll("#scheduleDetailTableDiv > table tr")).filter(e=>{let r=e.textContent.trim();return!(e.className==="schedTableHdr"||r===""||r==="Add an activity"||r.endsWith("OFF")||r.endsWith("No data available")||e.children.length===1)}).map(e=>Array.from(e.children))}function gt(o){let e=[],r,t,i;for(let s of o){if(s[0]?.querySelector('[title="Trade schedule"]')){let M=s[1]?.textContent?.trim(),[,D]=M?.split(" ")??["",""];[t,i,r]=D.split("/").map(Number)}let a=s[s.length-5]?.textContent?.trim()??"",c=s[s.length-4]?.textContent?.trim()??"12:00 AM",d=s[s.length-3]?.textContent?.trim()??"12:00 AM",[u,g]=K(c),[h,p]=K(d),w=new Date(2e3+r,t-1,i,u,g,0,0),f=new Date(2e3+r,t-1,i,h,p,0,0);f