1/** 2 * @license 3 * PrivacyScrubber Core Processing Engine (ZTDS) 4 * Copyright (c) 2026 PrivacyScrubber. All Rights Reserved. 5 * 6 * WARNING: This is proprietary, commercial software. 7 * Unauthorized copying, modification, distribution, or use of this source code, 8 * via any medium, is strictly prohibited. Protected by international copyright 9 * laws and treaties. 10 */ 11import"../../scripts/ps-license-manager.js";import{openModal as e,closeModal as t,hydrateLazyModal as o}from"./ui-modals.js";export const UI_STATE={isPro:!1,isTeam:!1,tier:"FREE"};export const generateLicenseKey=(e="PRO")=>{let t="";const o=window.crypto||window.msCrypto,n=new Uint32Array(8);o.getRandomValues(n);for(let e=0;e<8;e++)t+="ABCDEFGHJKLMNPQRSTUVWXYZ23456789".charAt(n[e]%32);const a=t+("function"==typeof atob?atob("WlREU19TQUxUXzIwMjZfIUAj"):["ZTDS","SALT","2026","!@#"].join("_"))+e;let i=0;for(let e=0;e<a.length;e++)i+=a.charCodeAt(e)*(e+1);return`PS-${e}-${t}-${(i%9999).toString().padStart(4,"0")}`};export const validateLicenseKey=(e,t=null)=>{if(void 0===globalThis.LicenseManager)return null;let o=globalThis.LicenseManager.validate(e,{mockTime:t,storage:"undefined"!=typeof localStorage?localStorage:null,onAnomaly:()=>{"function"==typeof window.PrivacyScrubberUI?.showStatus&&window.PrivacyScrubberUI.showStatus("System clock anomaly detected. License locked.","error",1e4)},onExpired:e=>{"function"==typeof window.PrivacyScrubberUI?.showStatus&&null===t&&window.PrivacyScrubberUI.showStatus("Your License/Pilot has expired.","error",1e4)}});return o.valid?o.tier:null};export const updateGlobalTierUI=()=>{const e=UI_STATE.isSdk||"SDK"===localStorage.getItem("ps_license_type"),t=e||UI_STATE.isTeam,o=UI_STATE.isPro||t||e;[{id:"psNavProBtn",tSuffix:"1",proText:"Dashboard",teamText:"Dashboard"},{id:"psNavProBtnMobile",tSuffix:"Mobile",proText:"Dashboard",teamText:"Dashboard"},{id:"psNavProBtnDrawer",tSuffix:"Drawer",proText:"Dashboard",teamText:"Dashboard"}].forEach(n=>{const a=document.getElementById(n.id);if(a&&(t||o)){"psNavProBtn"===n.id?(a.style.background="transparent",a.style.color=e?"#06b6d4":t?"#10b981":"#3b82f6"):a.style.background=e?"linear-gradient(to right, #06b6d4, #3b82f6)":t?"linear-gradient(to right, #10b981, #14b8a6)":"linear-gradient(to right, #10b981, #3b82f6)",a.classList.add("ps-pro-active-theme");const o=document.getElementById("psLiveDot"+n.tSuffix),i=document.getElementById("psProIcon"+n.tSuffix),r=document.getElementById("psProText"+n.tSuffix);o&&(o.style.display="none"),i&&(i.style.display="inline-block",i.className="",i.innerHTML=e?'<svg class="w-4 h-4 mr-1.5 inline-block"><use href="#icon-code"></use></svg>':t?'<svg class="w-4 h-4 mr-1.5 inline-block"><use href="#icon-users"></use></svg>':'<svg class="w-4 h-4 mr-1.5 inline-block"><use href="#icon-crown"></use></svg>'),r&&(r.innerText=e?"SDK":t?n.teamText:n.proText)}});const n=document.getElementById("tool-tier-badge");n&&(e?(n.textContent="SDK",n.className="px-2 py-0.5 rounded text-tiny font-black bg-neon-cyan/20 text-neon-cyan border border-neon-cyan/30 uppercase tracking-tighter"):t?(n.textContent="TEAM",n.className="px-2 py-0.5 rounded text-tiny font-black bg-neon-purple/20 text-neon-purple border border-neon-purple/30 uppercase tracking-tighter"):o&&(n.textContent="PRO",n.className="px-2 py-0.5 rounded text-tiny font-black bg-neon-blue/20 text-neon-blue border border-neon-blue/30 uppercase tracking-tighter"))};const n=async e=>{if(!e)return"";try{const t=(new TextEncoder).encode(e.trim()),o=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(o)).map(e=>e.toString(16).padStart(2,"0")).join("")}catch(e){return""}};export const initSharedUI=()=>{const e=localStorage.getItem("ps_pro_key"),t=localStorage.getItem("ps_pro_sub"),o=localStorage.getItem("ps_team_key");["isPro","ps_pro_v1","ps_pro_lifetime","ps_team_v1"].forEach(e=>{localStorage.getItem(e)&&localStorage.removeItem(e)});let a=validateLicenseKey(e)||validateLicenseKey(t),i=validateLicenseKey(o);const r=e=>"string"==typeof e&&/^(I-[A-Z0-9]{8,40}|sub_[a-z0-9_]{8,50}|txn_[a-z0-9_]{8,50}|chk_[a-z0-9_]{8,50}
11)/i.test(e.trim()),s=o&&r(o),d=e&&r(e)||t&&r(t);UI_STATE.isTeam="TEAMS"===i||"TEAMS"===a||s,UI_STATE.isPro=UI_STATE.isTeam||"PRO"===a||"SDK"===a||d,UI_STATE.tier=UI_STATE.isTeam?"TEAMS":UI_STATE.isPro?"PRO":"FREE",window.isPro=UI_STATE.isPro,window.isTeam=UI_STATE.isTeam;const l=new URLSearchParams(window.location.search);let c=l.get("key");if(!c&&window.location.hash){const e=window.location.hash.substring(1).match(/(?:^|&)key=([^&]+)/);e&&(c=decodeURIComponent(e[1]))}if(c){let e=validateLicenseKey(c);if(/^(I-|sub_|txn_|chk_)/.test(c)&&(e="TEAMS"),"TEAMS"===e?(UI_STATE.isTeam=!0,UI_STATE.isPro=!0,localStorage.setItem("ps_team_key",c.trim())):"PRO"===e&&(UI_STATE.isPro=!0,localStorage.setItem("ps_pro_key",c.trim())),l.has("key")){l.delete("key");const e=l.toString()?"?"+l.toString():"";window.history.replaceState({},"",window.location.pathname+e+window.location.hash)}else if(window.location.hash.includes("key=")){const e=window.location.hash.replace(/#?key=[^&]+&?/,"").replace(/&$/,"");window.history.replaceState({},"",window.location.pathname+window.location.search+(e?"#"+e:""))}window.isPro=UI_STATE.isPro,window.isTeam=UI_STATE.isTeam,setTimeout(()=>{"function"==typeof window.showStatus&&window.showStatus(`ð¡ï¸ ${"TEAMS"===e?"TEAMS Governance":"PRO Edition"} License Activated!`,"success"),"TEAMS"!==e&&"PRO"!==e||"function"!=typeof window.openTeamModal||window.openTeamModal(!0)},400)}if(updateGlobalTierUI(),"undefined"!=typeof window){const e=()=>{const e=window.location.hash.toLowerCase(),t=window.location.search.toLowerCase();"#teams"===e||t.includes("tier=teams")||t.includes("action=teams")?setTimeout(()=>{"function"==typeof window.openTeamsModal?window.openTeamsModal():"function"==typeof window.openTierModal&&window.openTierModal("TEAMS")},200):"#pro"===e||t.includes("tier=pro")||t.includes("action=pro")?setTimeout(()=>{"function"==typeof window.openTierModal&&window.openTierModal("PRO")},200):"#dashboard"===e||t.includes("dashboard=1")||t.includes("action=dashboard")?setTimeout(()=>{UI_STATE.isTeam||UI_STATE.isPro?"function"==typeof window.openTeamModal&&window.openTeamModal(!0):"function"==typeof window.openTierModal&&window.openTierModal("TEAMS")},200):"#ai"===e?setTimeout(()=>{const e=document.getElementById("modeTabAI");if(e){e.click();const t=document.getElementById("tool-grid")||document.getElementById("step1Panel")||e;t&&t.scrollIntoView({behavior:"smooth",block:"start"})}},100):("#doc"===e||"#file"===e||e.startsWith("#doc"))&&setTimeout(()=>{const e=document.getElementById("modeTabDoc");if(e){e.click();const t=document.getElementById("tool-grid")||document.getElementById("step1Panel")||e;t&&t.scrollIntoView({behavior:"smooth",block:"start"})}},100)};e(),window.addEventListener("hashchange",e)}"undefined"!=typeof window&&window.crypto&&window.crypto.subtle&&(async()=>{const e=[];if(["ps_pro_key","ps_pro_sub","ps_team_key"].forEach(t=>{const o=localStorage.getItem(t);o&&e.push({key:t,val:o.trim()})}),0===e.length)return;if("undefined"!=typeof navigator&&navigator.onLine)for(const t of e){const e=t.val.toUpperCase();if(!e.startsWith("PS-RSA-")&&!e.startsWith("PS-PILOT-"))try{const e=window.location.origin+"/api/upgrade-key",o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldKey:t.val})});if(o.ok){const e=await o.json();if(e&&e.success&&e.key)return localStorage.setItem(t.key,e.key),void setTimeout(()=>{initSharedUI()},50)}}catch(e){}}let t=[];const o=Date.now(),a=parseInt(localStorage.getItem("ps_krl_last_fetch")||"0",10),i=localStorage.getItem("ps_krl_cache");if(i)try{t=JSON.parse(i)}catch(e){}if((o-a>864e5||!i)&&"undefined"!=typeof navigator&&navigator.onLine)try{const e=window.location.origin+"/revoked-keys.json",n=await fetch(e);if(n.ok){const e=await n.json();e&&Array.isArray(e.revoked)&&(t=e.revoked,localStorage.setItem("ps_krl_cache",JSON.stringify(e.revoked)),localStorage.setItem("ps_krl_last_fetch",o.toString()))}}catch(e){}let r=!1;for(const o of e){const e=await n(o.val);e&&t.includes(e)&&(localStorage.removeItem(o.key),r=!0)}
11r&&(UI_STATE.isPro=!1,UI_STATE.isTeam=!1,UI_STATE.tier="FREE",window.isPro=!1,window.isTeam=!1,updateGlobalTierUI(),alert("â ï¸ [PrivacyScrubber] Your license key has been deactivated. Please contact [email protected] if you believe this is an error."))})().catch(e=>{}),window.refreshAppState=()=>{initSharedUI()}};if("undefined"!=typeof window&&(window.PrivacyScrubberUI={UI_STATE,validateLicenseKey,generateLicenseKey,updateGlobalTierUI,initSharedUI,openModal:e,closeModal:t,hydrateLazyModal:o},window.generateLicenseKey=generateLicenseKey,window.validateLicenseKey=validateLicenseKey,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",initSharedUI):initSharedUI(),window.openTierModal=e=>{if(!document.getElementById("tierModal"))return void(window.location.href="TEAMS"===e?"/teams/":"/pricing/");window.PrivacyScrubberUI.openModal("tierModal","tierModalContent");const t=document.getElementById("tierModalContent");if(t)try{t.scrollTop=0}catch(e){}const o=document.getElementById("tierCheckoutView");o&&o.classList.remove("hidden","opacity-0"),"string"==typeof e&&"function"==typeof window.switchTierView?window.switchTierView("checkout",e):"object"==typeof e&&null!==e&&"function"==typeof window.applyModalContext&&setTimeout(()=>window.applyModalContext(e),50)},window.closeTierModal=()=>{window.PrivacyScrubberUI.closeModal("tierModal","tierModalContent");const e=document.getElementById("checkoutContextBanner");e&&e.classList.add("hidden")},window.applyModalContext=(e={})=>{const t=document.getElementById("checkoutContextBanner"),o=document.getElementById("contextBannerTitle"),n=document.getElementById("contextBannerSubtitle"),a=document.getElementById("contextBannerIcon"),i=document.getElementById("contextBannerB2bBtn"),r=document.getElementById("contextBannerB2bBtnLabel"),s=document.getElementById("checkoutTitle"),d=document.getElementById("checkoutSubtitle"),l=document.getElementById("checkoutMobileTitle");if(e&&e.type)if(t&&t.classList.remove("hidden"),"profile"===e.type){const c=["dev","engineering","agents","tech","security","sdk","developer"].includes(String(e.profileId||"").toLowerCase()),m=(window.INDUSTRY_PROFILES||[]).find(t=>t.id===e.profileId)||{label:e.profileId||"Specialized Profile",title:"Custom PII pattern protection."};t&&(t.className="mb-6 p-4 rounded-xl border border-amber-500/30 bg-amber-500/10 backdrop-blur-md"),a&&(a.className="w-8 h-8 rounded-lg bg-amber-500/20 text-amber-400 flex items-center justify-center shrink-0",a.innerHTML='<i class="fa-solid fa-shield-halved text-sm"></i>'),o&&(o.textContent=`${m.label} â 5,000 Chars Quota Limit`),n&&(n.textContent=`Free 24-hour quota for ${m.label} reached. Upgrade to PRO for unlimited redaction.`),i&&(i.onclick=()=>{"function"==typeof window.triggerB2bCisoMemoFromQuota&&window.triggerB2bCisoMemoFromQuota(c?"sdk":"teams")}),r&&(r.textContent=c?"Generate Developer SDK Memo for CISO ($299/mo)":"Generate Team Approval Memo ($99/mo Flat)"),s&&(s.textContent=`${m.label.toUpperCase()} UNLOCK`),d&&(d.textContent=`Unlimited ${m.label} Processing`),l&&(l.textContent=`${m.label.toUpperCase()} UNLOCK`)}else if("audit_receipt"===e.type)t&&(t.className="mb-6 p-4 rounded-xl border border-blue-500/30 bg-blue-500/10 backdrop-blur-md"),a&&(a.className="w-8 h-8 rounded-lg bg-blue-500/20 text-neon-blue flex items-center justify-center shrink-0",a.innerHTML='<i class="fa-solid fa-file-shield text-sm"></i>'),o&&(o.textContent="Trial Audit Receipt Generated"),n&&(n.textContent='Remove the "TRIAL / UNVERIFIED" watermark and activate tamper-evident SHA-256 compliance proofs.'),i&&(i.onclick=()=>{"function"==typeof window.triggerB2bCisoMemoFromQuota&&window.triggerB2bCisoMemoFromQuota("teams")}),r&&(r.textContent="Generate CISO Approval Memo ($99/mo Flat)"),s&&(s.textContent="CISO AUDIT CERTIFICATE UNLOCK"),d&&(d.textContent="Official Compliance Proofs (SOC 2, GDPR, HIPAA)"),l&&(l.textContent="CISO AUDIT UNLOCK");else if("bulk_files"===e.type){const c=e.fileCount||"Batch";t&&(t.className="mb-6 p-4 rounded-xl border border-emerald-500/30 bg-emerald-500/10 backdrop-blur-md"),a&&(a.className="w-8 h-8 rounded-lg bg-emerald-500/20 text-neon-green flex items-center justify-center shrink-0",a.innerHTML='<i class="fa-solid fa-layer-group text-sm"></i>'),o&&(o.textContent=`${c} Files Detected · 1 File Free Limit`),n&&(n.textContent="Sanitize 50+ batch documents, Excel spreadsheets, and scanned PDFs simultaneously in local RAM."),i&&(i.onclick=()=>{"function"==typeof window.triggerB2bCisoMemoFromQuota&&window.triggerB2bCisoMemoFromQuota("teams")}),r&&(r.textContent="Generate Team Approval Memo ($99/mo Flat)"),s&&(s.textContent="BULK & OFFLINE OCR UNLOCK"),d&&(d.textContent="Unlimited Batch & OCR Processing"),l&&(l.textContent="BULK & OCR UNLOCK")}else"teams_handoff"===e.type&&(t&&(t.className="mb-6 p-4 rounded-xl border border-purple-500/30 bg-purple-500/10 backdrop-blur-md"),a&&(a.className="w-8 h-8 rounded-lg bg-purple-500/20 text-neon-purple flex items-center justify-center shrink-0",a.innerHTML='<i class="fa-solid fa-users text-sm"></i>'),o&&(o.textContent="Teams Cryptographic Session Handoff"),n&&(n.textContent="Zero-server session handoff via XChaCha20-Poly1305 + centralized regex blueprints for your team."),i&&(i.onclick=()=>{"function"==typeof window.triggerB2bCisoMemoFromQuota&&window.triggerB2bCisoMemoFromQuota("teams")}),r&&(r.textContent="Generate CISO Approval Memo ($99/mo Flat)"),s&&(s.textContent="TEAMS HUB UNLOCK"),d&&(d.textContent="Unlimited Seats · $99/mo Flat Rate"),l&&(l.textContent="TEAMS HUB UNLOCK"));else t&&t.classList.add("hidden")},window.openContextualUpgradeModal=(e={})=>
11{const t=e&&"teams_handoff"===e.type?"TEAMS":"PRO";window.openTierModal(t),setTimeout(()=>{"function"==typeof window.applyModalContext&&window.applyModalContext(e)},50)},"undefined"!=typeof window)){const a=".animate-pulse,.animate-ping,.animate-float-slow,.animate-handoff-flow,.border-beam,.demo-fo,.demo-fr,.btn-shine,#psContactFab";function i(e,t){try{const o=document.createElement("textarea");o.value=e,o.style.position="fixed",o.style.opacity="0",o.style.left="-9999px",document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o),"function"==typeof t&&t()}catch(e){}}document.addEventListener("visibilitychange",()=>{document.hidden?document.querySelectorAll(a).forEach(e=>{e.dataset.psPausedTab="1",e.style.animationPlayState="paused"}):document.querySelectorAll("[data-ps-paused-tab]").forEach(e=>{e.style.animationPlayState="",delete e.dataset.psPausedTab})},{passive:!0}),window.showOfflineModal=function(){const e=document.getElementById("offlineModal"),t=document.getElementById("offlineModalCard");e&&t&&(e.classList.remove("hidden"),e.classList.add("flex"),requestAnimationFrame(()=>{t.classList.remove("scale-90","opacity-0"),t.classList.add("scale-100","opacity-100")}))},window.hideOfflineModal=function(){window.offlineChallengeActive=!0;const e=document.getElementById("offlineModal"),t=document.getElementById("offlineModalCard");e&&t&&(t.classList.remove("scale-100","opacity-100"),t.classList.add("scale-90","opacity-0"),setTimeout(()=>{e.classList.remove("flex"),e.classList.add("hidden")},300))},window.copyArticleShareUrl=function(e){if(!e)return;const t=e.getAttribute("data-url")||window.location.href,o=()=>{e.dataset.originalHtml||(e.dataset.originalHtml=e.innerHTML),e.innerHTML='<i class="fa-solid fa-check text-neon-green text-xs" aria-hidden="true"></i> <span class="text-neon-green font-semibold">Copied!</span>',setTimeout(()=>{e.dataset.originalHtml&&(e.innerHTML=e.dataset.originalHtml)},2e3)};navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(t).then(o).catch(()=>{i(t,o)}):i(t,o)},window.nativeArticleShare=function(e){if(!e)return;const t=e.getAttribute("data-url")||window.location.href,o=e.getAttribute("data-title")||document.title;"undefined"!=typeof navigator&&navigator.share?navigator.share({title:o,url:t}).catch(()=>{}):window.copyArticleShareUrl(e)},import("./browser-fastpath.js").then(e=>{e&&"function"==typeof e.initBrowserFastPath&&e.initBrowserFastPath()}).catch(()=>{})}
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.