1import{bindHashStyleCopy as F}from"./hashStyleCopy-B7l2OPhl.js";import{s as x}from"./ctToast-C2BAo121.js";import"./ctFullscreenAd-CL-AA_Ul.js";import"./app-gOHIPY12.js";function y(t){const e=document.getElementById("ctCalcToastBody"),o=document.getElementById("ctCalcToast");!e||!o||x(o,{bodyEl:e,message:t,delay:8e3})}function q(t){return t>=90?"A":t>=85?"A-":t>=80?"B+":t>=75?"B":t>=70?"B-":t>=65?"C+":t>=60?"C":t>=50?"D":"F"}function H(){const t=document.getElementById("ctCalcGradeBody"),e=document.getElementById("ctCalcGradeSummary"),o=document.getElementById("ctCalcGradeAdd");if(!t||!e||!o)return;const n=()=>[...t.querySelectorAll("tr")].map(r=>{var s,l,d;return{name:((s=r.querySelector('[data-field="name"]'))==null?void 0:s.value)||"",weight:((l=r.querySelector('[data-field="weight"]'))==null?void 0:l.value)||"",percentage:((d=r.querySelector('[data-field="percentage"]'))==null?void 0:d.value)||""}}),a=()=>{const r=n(),s=r.reduce((u,f)=>u+parseFloat(f.weight||0),0),l=r.reduce((u,f)=>u+parseFloat(f.percentage||0)*(parseFloat(f.weight||0)/100),0),d=s?l:0,g=q(d);e.textContent=`Final grade: ${d.toFixed(2)}% (${g})`},i=()=>{var s;const r=document.createElement("tr");r.innerHTML=` 2 <td><input type="text" class="form-control form-control-sm" data-field="name" placeholder="Assignment" /></td> 3 <td><input type="number" class="form-control form-control-sm" data-field="weight" placeholder="%" /></td> 4 <td><input type="number" class="form-control form-control-sm" data-field="percentage" placeholder="%" /></td> 5 <td><button type="button" class="btn btn-sm btn-outline-danger" data-action="del" title="Remove">Ã</button></td>`,t.appendChild(r),r.querySelectorAll("input").forEach(l=>l.addEventListener("input",a)),(s=r.querySelector('[data-action="del"]'))==null||s.addEventListener("click",()=>{r.remove(),a()}),a()};for(let r=0;r<5;r++)i();o.addEventListener("click",()=>i()),t.addEventListener("input",a),a()}function U(t,e){if(e<t)return null;let o=e.getFullYear()-t.getFullYear(),n=e.getMonth()-t.getMonth(),a=e.getDate()-t.getDate();if(a<0){n--;const g=new Date(e.getFullYear(),e.getMonth(),0).getDate();a+=g}n<0&&(o--,n+=12);const i=e.getTime()-t.getTime(),r=Math.floor(i/(7*24*3600*1e3)),s=Math.floor(i/(3600*1e3)),l=Math.floor(i/(60*1e3)),d=Math.floor(i/1e3);return{years:o,months:n,days:a,weeks:r,hours:s,minutes:l,seconds:d}}function N(){const t=document.getElementById("ctCalcBirth"),e=document.getElementById("ctCalcAt"),o=document.getElementById("ctCalcAgeBtn"),n=document.getElementById("ctCalcAgeOut");!t||!o||!n||o.addEventListener("click",()=>{const a=t.value;if(!a){y("Please enter a valid birthdate.");return}const i=new Date(a+"T12:00:00"),r=e!=null&&e.value?new Date(e.value+"T12:00:00"):new Date;if(e!=null&&e.value&&i>r){y("Birthdate cannot be later than the specified date.");return}const s=U(i,r);if(!s){y("Invalid date range.");return}n.classList.remove("d-none"),n.innerHTML=` 6 <div class="fw-semibold mb-2">Age breakdown</div> 7 <div><strong>${s.years}</strong> years, <strong>${s.months}</strong> months, and <strong>${s.days}</strong> days</div> 8 <div><strong>${s.weeks}</strong> weeks and <strong>${s.days%7}</strong> days</div> 9 <div><strong>${s.hours}</strong> hours</div> 10 <div><strong>${s.minutes}</strong> minutes</div> 11 <div><strong>${s.seconds}</strong> seconds</div>`})}function R(t){const e=new Map;let o=t;for(;o%2===0;)e.set(2,(e.get(2)||0)+1),o/=2;for(let n=3;n*n<=o;n+=2)for(;o%n===0;)e.set(n,(e.get(n)||0)+1),o/=n;return o>1&&e.set(o,(e.get(o)||0)+1),e}function z(t){if(t.size===0)return"1";const e=[];for(const o of[...t.keys()].sort((n,a)=>n-a)){const n=t.get(o)||1;e.push(n===1?`${o}`:`${o}^${n}`)}return e.join(" Ã ")}function Y(t){let e=[1];for(const[o,n]of t){const a=[];let i=1;for(let s=0;s<=n;s++)a.push(i),i*=o;const r=[];for(const s of e)for(const l of a)r.push(s*l);e=r}return e.sort((o,n)=>o-n)}function j(t){const e=[],o=Math.floor(Math.sqrt(t));for(let n=1;n<=o;n++)t%n===0&&e.push([n,t/n]);return e}function O(){const t=document.getElementById("ctFactN"),e=document.getElementById("ctFactRun"),o=document.getElementById("ctFactEx"),n=document.getElementById("ctFactOutWrap"),a=document.getElementById("ctFactSummary"),i=document.getElementById("ctFactPrime"),r=document.getElementById("ctFactDivisors"),s=document.getElementById("ctFactDivCount"),l=document.getElementById("ctFactPairsBody"),d=document.getElementById("ctFact
11CopyPrime"),g=document.getElementById("ctFactCopyDiv"),u=document.getElementById("ctFactFeedback");if(!t||!e||!n||!a||!i||!r||!s||!l)return;const f=1e12,v=()=>{t.classList.remove("is-invalid"),u&&(u.textContent="")},I=c=>{t.classList.add("is-invalid"),u&&(u.textContent=c),t.focus()},L=F(d,()=>i.value||"",y),S=F(g,()=>r.value||"",y),h=c=>{d&&(d.disabled=!c,c||L()),g&&(g.disabled=!c,c||S())},M=()=>{const c=String(t.value||"").trim().replace(/\s+/g,"");if(!c)return{error:"Type a whole number, then tap Factorize."};if(!/^\d+$/.test(c))return{error:"Use digits only (whole numbers, no letters or decimals)."};const m=Number(c);return!Number.isSafeInteger(m)||m<0?{error:"That number is too large for this tool. Try a smaller value."}:m<1?{error:"Use 1 or larger."}:m>f?{error:`Use at most ${f.toLocaleString("en-US")}.`}:{n:m}},B=c=>{v();const m=R(c),C=z(m),w=Y(m),$=j(c),E=w.length,D=c>1&&E===2,T=Math.sqrt(c),k=Number.isInteger(T);i.value=C,r.value=w.join(", "),s.textContent=String(E);let p=`<strong>${c.toLocaleString("en-US")}</strong> = ${C.replace(/Ã/g,"×")}`;c===1?p="<strong>1</strong> is the multiplicative unit (no prime factors).":D?p+=' â <span class="text-success">prime</span> (exactly two divisors).':p+=` â <span class="text-body-secondary">composite</span>, ${E} divisors.`,c>1&&k&&(p+=" Perfect square."),a.innerHTML=p,l.innerHTML="";for(const[P,A]of $){const b=document.createElement("tr");b.innerHTML=`<td class="font-monospace">${P.toLocaleString("en-US")}</td><td class="font-monospace">${A.toLocaleString("en-US")}</td>`,l.appendChild(b)}n.classList.remove("d-none"),h(!0)};e.addEventListener("click",()=>{const c=M();if("error"in c){I(c.error),n.classList.add("d-none"),h(!1);return}B(c.n)}),o==null||o.addEventListener("click",()=>{v(),t.value="360",B(360)}),t.addEventListener("input",()=>{v()}),t.addEventListener("keydown",c=>{c.key==="Enter"&&(c.preventDefault(),e.click())}),h(!1)}function K(){const t=document.getElementById("ct-calculator-root");if(!t)return;const e=(t.dataset.ctSlug||"").toLowerCase();e==="grade"?H():e==="age"?N():e==="factoring"&&O()}export{K as initCalculatorPage};
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.