@editora/plugins 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/approval-workflow.cjs.js +14 -14
  3. package/dist/approval-workflow.esm.js +265 -262
  4. package/dist/blockquote.cjs.js +1 -1
  5. package/dist/blockquote.esm.js +177 -15
  6. package/dist/blocks-library.cjs.js +6 -6
  7. package/dist/blocks-library.esm.js +95 -92
  8. package/dist/bold.cjs.js +1 -1
  9. package/dist/bold.esm.js +10 -6
  10. package/dist/capitalization.cjs.js +1 -1
  11. package/dist/capitalization.esm.js +124 -44
  12. package/dist/checklist.cjs.js +1 -1
  13. package/dist/checklist.esm.js +251 -191
  14. package/dist/citations.cjs.js +4 -4
  15. package/dist/citations.esm.js +131 -128
  16. package/dist/clear-formatting.cjs.js +1 -1
  17. package/dist/clear-formatting.esm.js +68 -36
  18. package/dist/code.cjs.js +121 -44
  19. package/dist/code.esm.js +2694 -889
  20. package/dist/content-rules.cjs.js +5 -5
  21. package/dist/content-rules.esm.js +104 -101
  22. package/dist/data-binding.cjs.js +3 -3
  23. package/dist/data-binding.esm.js +51 -48
  24. package/dist/direction.cjs.js +1 -1
  25. package/dist/direction.esm.js +97 -74
  26. package/dist/doc-schema.cjs.js +4 -4
  27. package/dist/doc-schema.esm.js +104 -101
  28. package/dist/embed-iframe.cjs.js +21 -4
  29. package/dist/embed-iframe.esm.js +279 -116
  30. package/dist/heading.cjs.js +1 -1
  31. package/dist/heading.esm.js +239 -56
  32. package/dist/history.cjs.js +1 -1
  33. package/dist/history.esm.js +74 -89
  34. package/dist/inlineFormatting-DOYOJdnD.js +1 -0
  35. package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
  36. package/dist/italic.cjs.js +1 -1
  37. package/dist/italic.esm.js +12 -8
  38. package/dist/math.cjs.js +27 -21
  39. package/dist/math.esm.js +218 -146
  40. package/dist/merge-tag.cjs.js +8 -2
  41. package/dist/merge-tag.esm.js +130 -111
  42. package/dist/pii-redaction.cjs.js +6 -6
  43. package/dist/pii-redaction.esm.js +169 -166
  44. package/dist/smart-paste.cjs.js +5 -5
  45. package/dist/smart-paste.esm.js +120 -117
  46. package/dist/special-characters.cjs.js +6 -10
  47. package/dist/special-characters.esm.js +97 -75
  48. package/dist/strikethrough.cjs.js +1 -1
  49. package/dist/strikethrough.esm.js +11 -25
  50. package/dist/translation-workflow.cjs.js +7 -7
  51. package/dist/translation-workflow.esm.js +103 -100
  52. package/dist/underline.cjs.js +1 -1
  53. package/dist/underline.esm.js +7 -3
  54. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=".rte-content, .editora-content",ae="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",ke="__editoraCommandEditorRoot",we="rte-pii-redaction-styles",u="rte-pii-redaction-panel",k="pii-redaction",v="piiRedaction",$=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',pe=typeof NodeFilter<"u"?NodeFilter.SHOW_TEXT:4,Ne=["email","phone","ssn","credit-card","ipv4","api-key","jwt"],Oe={panelTitle:"PII Redaction",panelAriaLabel:"PII redaction panel",scanText:"Scan PII",redactAllText:"Redact All",redactText:"Redact",locateText:"Locate",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noFindingsText:"No PII detected in the document.",summaryPrefix:"Findings",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+I/U/M/Y",readonlyRedactionText:"Editor is read-only. Reopen editable mode to redact.",matchLabel:"Detected",maskedLabel:"Masked",excerptLabel:"Context"},ze={email:{label:"Email",severity:"medium",pattern:/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi},phone:{label:"Phone",severity:"medium",pattern:/\b(?:\+?\d{1,3}[\s.-]?)?(?:\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4})\b/g},ssn:{label:"SSN",severity:"high",pattern:/\b\d{3}-\d{2}-\d{4}\b/g},"credit-card":{label:"Credit Card",severity:"high",pattern:/\b(?:\d[ -]*?){13,19}\b/g,validator:e=>qe(e)},ipv4:{label:"IPv4",severity:"low",pattern:/\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b/g},"api-key":{label:"API Key",severity:"high",pattern:/\b(?:sk-[A-Za-z0-9]{20,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z\-_]{35}|ghp_[A-Za-z0-9]{36}|xox[baprs]-[A-Za-z0-9-]{10,})\b/g},jwt:{label:"JWT",severity:"high",pattern:/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g}},f=new WeakMap,I=new WeakMap,E=new WeakMap,S=new WeakMap,te=new WeakMap,de=new WeakMap,Q=new WeakMap,m=new Map,Z=new WeakMap,q=new Set,W=new Set;let G=0,Fe=0,Ee=0,M=null,b=null,P=null,L=null,_=null,R=null,D=null;function p(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function He(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function Y(e){const t=e.flags.includes("g")?e.flags:`${e.flags}g`;return new RegExp(e.source,t)}function ge(e){return new RegExp(e.source,e.flags)}function X(e,t,n){return Math.max(t,Math.min(n,e))}function Be(e,t){return e==="high"||e==="medium"||e==="low"?e:t}function Ke(e){const t=(e||"*").slice(0,1)||"*";return/[A-Za-z0-9._%+\-\s]/.test(t)?"*":t}function ve(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function qe(e){const t=e.replace(/\D/g,"");if(t.length<13||t.length>19)return!1;let n=0,r=!1;for(let i=t.length-1;i>=0;i-=1){let o=Number(t[i]);r&&(o*=2,o>9&&(o-=9)),n+=o,r=!r}return n%10===0}function We(e,t){const n=ze[e];if(typeof t=="boolean")return{type:e,label:n.label,severity:n.severity,enabled:t,pattern:Y(n.pattern),validator:n.validator};if(!t)return{type:e,label:n.label,severity:n.severity,enabled:!0,pattern:Y(n.pattern),validator:n.validator};const r=t.pattern instanceof RegExp?Y(t.pattern):Y(n.pattern);return{type:e,label:n.label,severity:Be(t.severity,n.severity),enabled:t.enabled!==!1,pattern:r,validator:n.validator}}function ee(e={}){const t=Ne.map(r=>We(r,e.detectors?.[r])),n=t.map(r=>`${r.type}:${r.enabled?"1":"0"}:${r.severity}:${r.pattern.source}:${r.pattern.flags}`).join("|");return{enableRealtime:e.enableRealtime!==!1,debounceMs:X(Number(e.debounceMs??220),60,3e3),maxFindings:X(Number(e.maxFindings??140),1,500),maskChar:Ke(e.maskChar),revealStart:X(Number(e.revealStart??2),0,12),revealEnd:X(Number(e.revealEnd??2),0,12),redactionMode:e.redactionMode==="mask"?"mask":"token",redactionToken:(e.redactionToken||"REDACTED").trim()||"REDACTED",skipInCodeBlocks:e.skipInCodeBlocks!==!1,labels:{...Oe,...e.labels||{}},normalizeText:e.normalizeText||He,detectors:t,detectorSignature:n}}function ce(e){const t={};return e.detectors.forEach(n=>{t[n.type]={enabled:n.enabled,severity:n.severity,pattern:n.pattern}}),{enableRealtime:e.enableRealtime,debounceMs:e.debounceMs,maxFindings:e.maxFindings,maskChar:e.maskChar,revealStart:e.revealStart,revealEnd:e.revealEnd,redactionMode:e.redactionMode,redactionToken:e.redactionToken,skipInCodeBlocks:e.skipInCodeBlocks,labels:{...e.labels},normalizeText:e.normalizeText,detectors:t}}function be(e){return e.closest(ae)||e}function je(e){const t=e.closest("[data-editora-editor]");if(t&&O(t)===e)return t;let n=e;for(;n;){if(n.matches(ae)&&(n===e||O(n)===e))return n;n=n.parentElement}return be(e)}function O(e){if(!e)return null;if(e.matches(x))return e;const t=e.querySelector(x);return t instanceof HTMLElement?t:null}function Ze(){if(typeof window>"u")return null;const e=window[ke];if(!(e instanceof HTMLElement))return null;window[ke]=null;const t=O(e);if(t)return t;const n=e.closest(ae);if(n){const i=O(n);if(i)return i}const r=e.closest(x);return r instanceof HTMLElement?r:null}function J(e){return e?(e.getAttribute("data-theme")||e.getAttribute("theme")||"").toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark"):!1}function Ve(e){const t=be(e);if(J(t))return!0;const n=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return J(n)?!0:J(document.documentElement)||J(document.body)}function ne(e,t){e.classList.remove("rte-pii-redaction-theme-dark"),Ve(t)&&e.classList.add("rte-pii-redaction-theme-dark")}function re(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function me(e){const t=te.get(e);typeof t=="number"&&(window.clearTimeout(t),W.delete(t),te.delete(e))}function V(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function le(e=0){return{total:0,high:0,medium:0,low:0,redactedCount:e,byType:{email:0,phone:0,ssn:0,"credit-card":0,ipv4:0,"api-key":0,jwt:0}}}function K(){Array.from(q).forEach(t=>{t.isConnected||Ie(t)})}function Ue(e){for(let t=0;t<e.length;t+=1){const n=e[t];if(!(n.type!=="childList"||n.removedNodes.length===0))for(let r=0;r<n.removedNodes.length;r+=1){const i=n.removedNodes[r];if(i.nodeType!==Node.ELEMENT_NODE)continue;const o=i;if(o.matches?.(x)||o.matches?.(`.${u}`)||o.querySelector?.(x)||o.querySelector?.(`.${u}`))return!0}}return!1}function T(e,t=!0){if(K(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const o=e.editorElement,a=O(o);if(a)return a}const n=Ze();if(n)return n;const r=window.getSelection();if(r&&r.rangeCount>0){const a=re(r.getRangeAt(0).startContainer)?.closest(x);if(a)return a}const i=document.activeElement;if(i){if(i.matches(x))return i;const o=i.closest(x);if(o)return o}return b&&b.isConnected?b:(b&&!b.isConnected&&(b=null),t?document.querySelector(x):null)}function Ie(e){me(e),m.get(e)?.remove(),m.delete(e),Z.delete(e),f.delete(e),I.delete(e),E.delete(e),S.delete(e),de.delete(e),Q.delete(e),q.delete(e),b===e&&(b=null)}function C(e,t,n){const r=je(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function w(e,t){f.has(e)||f.set(e,t),I.has(e)||I.set(e,[]),E.has(e)||E.set(e,le(0)),S.has(e)||S.set(e,t.enableRealtime),q.add(e)}function oe(e){return Z.get(e)===!0}function $e(e,t,n,r){if(!e)return e;if(e.length<=n+r)return t.repeat(e.length);const i=e.slice(0,n),o=r>0?e.slice(e.length-r):"";return`${i}${t.repeat(Math.max(1,e.length-n-r))}${o}`}function se(e,t,n){const r=e.replace(/\D/g,"");if(r.length===0)return e;let i=0;const o=Math.max(0,r.length-n);return e.split("").map(a=>/\d/.test(a)?(i+=1,i<=o?t:a):a).join("")}function Ge(e,t){const n=e.indexOf("@");if(n<=0)return e;const r=e.slice(0,n),i=e.slice(n+1);return r.length<=2?`${r[0]||""}${t}[at]${i}`:`${r[0]}${t.repeat(Math.max(1,r.length-2))}${r[r.length-1]}[at]${i}`}function Ye(e,t){const n=e.split(".");return n.length!==4?e:`${n[0]}.${n[1]}.${n[2]}.${t.repeat(Math.max(1,n[3].length))}`}function Te(e,t,n){return e&&(t==="email"?Ge(e,n.maskChar):t==="phone"||t==="ssn"||t==="credit-card"?se(e,n.maskChar,4):t==="ipv4"?Ye(e,n.maskChar):t==="api-key"||t==="jwt"?$e(e,n.maskChar,0,0):$e(e,n.maskChar,n.revealStart,n.revealEnd))}function Ce(e,t,n){return n.redactionMode==="mask"?Te(e,t,n):`[${n.redactionToken}:${t.toUpperCase()}]`}function Xe(e){return Ee+=1,`pii-${e}-${Date.now().toString(36)}-${Ee.toString(36)}`}function he(e,t){return t.skipInCodeBlocks?!!e.parentElement?.closest("code, pre, kbd, samp"):!1}function Je(e,t){return t.some(n=>e.start<n.end&&n.start<e.end)}function Qe(e,t,n){const r=[];t.filter(a=>a.enabled).forEach(a=>{const l=ge(a.pattern);let c=l.exec(e);for(;c&&r.length<n*5;){const d=c[0]||"",s=c.index,g=s+d.length;d&&g>s&&(!a.validator||a.validator(d))&&r.push({type:a.type,severity:a.severity,value:d,start:s,end:g}),l.lastIndex===c.index&&(l.lastIndex+=1),c=l.exec(e)}}),r.sort((a,l)=>a.start!==l.start?a.start-l.start:l.end-a.end);const o=[];for(let a=0;a<r.length&&!(o.length>=n);a+=1){const l=r[a];Je({start:l.start,end:l.end},o)||o.push(l)}return o}function ue(e,t=120){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}...`}function et(e,t,n){const r=Math.max(0,t-28),i=Math.min(e.length,n+28);return ue(e.slice(r,i).trim(),180)}function tt(e,t){const n=le(t);return n.total=e.length,e.forEach(r=>{n.byType[r.type]+=1,r.severity==="high"?n.high+=1:r.severity==="medium"?n.medium+=1:n.low+=1}),n}function ie(e,t){const n=e.querySelector(".rte-pii-redaction-live");n&&(n.textContent=t)}function z(e,t,n){const r=t.querySelector('[data-action="toggle-realtime"]');if(!r)return;const i=F(e,n);r.textContent=i?n.labels.realtimeOnText:n.labels.realtimeOffText,r.setAttribute("aria-pressed",i?"true":"false"),C(e,"togglePIIRealtime",i)}function nt(e,t){e.setAttribute("aria-label",t.labels.panelAriaLabel);const n=e.querySelector(".rte-pii-redaction-title");n&&(n.textContent=t.labels.panelTitle);const r=e.querySelector('[data-action="close"]');r&&r.setAttribute("aria-label",t.labels.closeText);const i=e.querySelector('[data-action="run-scan"]');i&&(i.textContent=t.labels.scanText);const o=e.querySelector('[data-action="redact-all"]');o&&(o.textContent=t.labels.redactAllText);const a=e.querySelector(".rte-pii-redaction-shortcut");a&&(a.textContent=t.labels.shortcutText)}function H(e){const t=m.get(e);if(!t)return;const n=f.get(e)||M;if(!n)return;const r=I.get(e)||[],i=E.get(e)||le(0),o=V(e),a=t.querySelector(".rte-pii-redaction-count"),l=t.querySelector(".rte-pii-redaction-summary"),c=t.querySelector(".rte-pii-redaction-list"),d=t.querySelector('[data-action="redact-all"]');if(!(!a||!l||!c||!d)){if(a.textContent=String(i.total),l.textContent=`${n.labels.summaryPrefix}: ${i.total} | High ${i.high} | Medium ${i.medium} | Low ${i.low} | Redacted ${i.redactedCount}`,d.disabled=o||r.length===0,o?ie(t,n.labels.readonlyRedactionText):ie(t,`${i.total} PII findings detected.`),z(e,t,n),r.length===0){c.innerHTML=`<li class="rte-pii-redaction-empty">${p(n.labels.noFindingsText)}</li>`;return}c.innerHTML=r.map(s=>{const g=s.type.toUpperCase(),A=s.suggestion||"Redact this finding before export/share.",B=`${n.labels.locateText}: ${s.match}`,y=`${n.labels.redactText}: ${s.match}`,U=o?'disabled aria-disabled="true"':"";return`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=".rte-content, .editora-content",ae="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",we="__editoraCommandEditorRoot",Ee="rte-pii-redaction-styles",u="rte-pii-redaction-panel",k="pii-redaction",v="piiRedaction",$=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',ge=typeof NodeFilter<"u"?NodeFilter.SHOW_TEXT:4,Oe=["email","phone","ssn","credit-card","ipv4","api-key","jwt"],ze={panelTitle:"PII Redaction",panelAriaLabel:"PII redaction panel",scanText:"Scan PII",redactAllText:"Redact All",redactText:"Redact",locateText:"Locate",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noFindingsText:"No PII detected in the document.",summaryPrefix:"Findings",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+I/U/M/Y",readonlyRedactionText:"Editor is read-only. Reopen editable mode to redact.",matchLabel:"Detected",maskedLabel:"Masked",excerptLabel:"Context"},Fe={email:{label:"Email",severity:"medium",pattern:/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi},phone:{label:"Phone",severity:"medium",pattern:/\b(?:\+?\d{1,3}[\s.-]?)?(?:\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4})\b/g},ssn:{label:"SSN",severity:"high",pattern:/\b\d{3}-\d{2}-\d{4}\b/g},"credit-card":{label:"Credit Card",severity:"high",pattern:/\b(?:\d[ -]*?){13,19}\b/g,validator:e=>We(e)},ipv4:{label:"IPv4",severity:"low",pattern:/\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b/g},"api-key":{label:"API Key",severity:"high",pattern:/\b(?:sk-[A-Za-z0-9]{20,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z\-_]{35}|ghp_[A-Za-z0-9]{36}|xox[baprs]-[A-Za-z0-9-]{10,})\b/g},jwt:{label:"JWT",severity:"high",pattern:/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g}},f=new WeakMap,I=new WeakMap,E=new WeakMap,S=new WeakMap,te=new WeakMap,ue=new WeakMap,Q=new WeakMap,m=new Map,Z=new WeakMap,q=new Set,W=new Set;let G=0,He=0,ve=0,M=null,b=null,P=null,L=null,_=null,R=null,D=null;function p(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Be(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function Y(e){const t=e.flags.includes("g")?e.flags:`${e.flags}g`;return new RegExp(e.source,t)}function be(e){return new RegExp(e.source,e.flags)}function X(e,t,n){return Math.max(t,Math.min(n,e))}function Ke(e,t){return e==="high"||e==="medium"||e==="low"?e:t}function qe(e){const t=(e||"*").slice(0,1)||"*";return/[A-Za-z0-9._%+\-\s]/.test(t)?"*":t}function $e(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function We(e){const t=e.replace(/\D/g,"");if(t.length<13||t.length>19)return!1;let n=0,r=!1;for(let i=t.length-1;i>=0;i-=1){let o=Number(t[i]);r&&(o*=2,o>9&&(o-=9)),n+=o,r=!r}return n%10===0}function je(e,t){const n=Fe[e];if(typeof t=="boolean")return{type:e,label:n.label,severity:n.severity,enabled:t,pattern:Y(n.pattern),validator:n.validator};if(!t)return{type:e,label:n.label,severity:n.severity,enabled:!0,pattern:Y(n.pattern),validator:n.validator};const r=t.pattern instanceof RegExp?Y(t.pattern):Y(n.pattern);return{type:e,label:n.label,severity:Ke(t.severity,n.severity),enabled:t.enabled!==!1,pattern:r,validator:n.validator}}function ee(e={}){const t=Oe.map(r=>je(r,e.detectors?.[r])),n=t.map(r=>`${r.type}:${r.enabled?"1":"0"}:${r.severity}:${r.pattern.source}:${r.pattern.flags}`).join("|");return{enableRealtime:e.enableRealtime!==!1,debounceMs:X(Number(e.debounceMs??220),60,3e3),maxFindings:X(Number(e.maxFindings??140),1,500),maskChar:qe(e.maskChar),revealStart:X(Number(e.revealStart??2),0,12),revealEnd:X(Number(e.revealEnd??2),0,12),redactionMode:e.redactionMode==="mask"?"mask":"token",redactionToken:(e.redactionToken||"REDACTED").trim()||"REDACTED",skipInCodeBlocks:e.skipInCodeBlocks!==!1,labels:{...ze,...e.labels||{}},normalizeText:e.normalizeText||Be,detectors:t,detectorSignature:n}}function se(e){const t={};return e.detectors.forEach(n=>{t[n.type]={enabled:n.enabled,severity:n.severity,pattern:n.pattern}}),{enableRealtime:e.enableRealtime,debounceMs:e.debounceMs,maxFindings:e.maxFindings,maskChar:e.maskChar,revealStart:e.revealStart,revealEnd:e.revealEnd,redactionMode:e.redactionMode,redactionToken:e.redactionToken,skipInCodeBlocks:e.skipInCodeBlocks,labels:{...e.labels},normalizeText:e.normalizeText,detectors:t}}function me(e){return e.closest(ae)||e}function Ze(e){const t=e.closest("[data-editora-editor]");if(t&&O(t)===e)return t;let n=e;for(;n;){if(n.matches(ae)&&(n===e||O(n)===e))return n;n=n.parentElement}return me(e)}function O(e){if(!e)return null;if(e.matches(x))return e;const t=e.querySelector(x);return t instanceof HTMLElement?t:null}function Ve(){if(typeof window>"u")return null;const e=window[we];if(!(e instanceof HTMLElement))return null;window[we]=null;const t=O(e);if(t)return t;const n=e.closest(ae);if(n){const i=O(n);if(i)return i}const r=e.closest(x);return r instanceof HTMLElement?r:null}function J(e){return e?(e.getAttribute("data-theme")||e.getAttribute("theme")||"").toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark"):!1}function Ue(e){const t=me(e);if(J(t))return!0;const n=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return J(n)?!0:J(document.documentElement)||J(document.body)}function ne(e,t){e.classList.remove("rte-pii-redaction-theme-dark"),Ue(t)&&e.classList.add("rte-pii-redaction-theme-dark")}function re(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function he(e){const t=te.get(e);typeof t=="number"&&(window.clearTimeout(t),W.delete(t),te.delete(e))}function V(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function le(e=0){return{total:0,high:0,medium:0,low:0,redactedCount:e,byType:{email:0,phone:0,ssn:0,"credit-card":0,ipv4:0,"api-key":0,jwt:0}}}function K(){Array.from(q).forEach(t=>{t.isConnected||Te(t)})}function Ge(e){for(let t=0;t<e.length;t+=1){const n=e[t];if(!(n.type!=="childList"||n.removedNodes.length===0))for(let r=0;r<n.removedNodes.length;r+=1){const i=n.removedNodes[r];if(i.nodeType!==Node.ELEMENT_NODE)continue;const o=i;if(o.matches?.(x)||o.matches?.(`.${u}`)||o.querySelector?.(x)||o.querySelector?.(`.${u}`))return!0}}return!1}function T(e,t=!0){if(K(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const o=e.editorElement,a=O(o);if(a)return a}const n=Ve();if(n)return n;const r=window.getSelection();if(r&&r.rangeCount>0){const a=re(r.getRangeAt(0).startContainer)?.closest(x);if(a)return a}const i=document.activeElement;if(i){if(i.matches(x))return i;const o=i.closest(x);if(o)return o}return b&&b.isConnected?b:(b&&!b.isConnected&&(b=null),t?document.querySelector(x):null)}function Te(e){he(e),m.get(e)?.remove(),m.delete(e),Z.delete(e),f.delete(e),I.delete(e),E.delete(e),S.delete(e),ue.delete(e),Q.delete(e),q.delete(e),b===e&&(b=null)}function C(e,t,n){const r=Ze(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function w(e,t){f.has(e)||f.set(e,t),I.has(e)||I.set(e,[]),E.has(e)||E.set(e,le(0)),S.has(e)||S.set(e,t.enableRealtime),q.add(e)}function oe(e){return Z.get(e)===!0}function Ie(e,t,n,r){if(!e)return e;if(e.length<=n+r)return t.repeat(e.length);const i=e.slice(0,n),o=r>0?e.slice(e.length-r):"";return`${i}${t.repeat(Math.max(1,e.length-n-r))}${o}`}function de(e,t,n){const r=e.replace(/\D/g,"");if(r.length===0)return e;let i=0;const o=Math.max(0,r.length-n);return e.split("").map(a=>/\d/.test(a)?(i+=1,i<=o?t:a):a).join("")}function Ye(e,t){const n=e.indexOf("@");if(n<=0)return e;const r=e.slice(0,n),i=e.slice(n+1);return r.length<=2?`${r[0]||""}${t}[at]${i}`:`${r[0]}${t.repeat(Math.max(1,r.length-2))}${r[r.length-1]}[at]${i}`}function Xe(e,t){const n=e.split(".");return n.length!==4?e:`${n[0]}.${n[1]}.${n[2]}.${t.repeat(Math.max(1,n[3].length))}`}function Ce(e,t,n){return e&&(t==="email"?Ye(e,n.maskChar):t==="phone"||t==="ssn"||t==="credit-card"?de(e,n.maskChar,4):t==="ipv4"?Xe(e,n.maskChar):t==="api-key"||t==="jwt"?Ie(e,n.maskChar,0,0):Ie(e,n.maskChar,n.revealStart,n.revealEnd))}function Re(e,t,n){return n.redactionMode==="mask"?Ce(e,t,n):`[${n.redactionToken}:${t.toUpperCase()}]`}function Je(e){return ve+=1,`pii-${e}-${Date.now().toString(36)}-${ve.toString(36)}`}function xe(e,t){return t.skipInCodeBlocks?!!e.parentElement?.closest("code, pre, kbd, samp"):!1}function Qe(e,t){return t.some(n=>e.start<n.end&&n.start<e.end)}function et(e,t,n){const r=[];t.filter(a=>a.enabled).forEach(a=>{const l=be(a.pattern);let c=l.exec(e);for(;c&&r.length<n*5;){const d=c[0]||"",s=c.index,g=s+d.length;d&&g>s&&(!a.validator||a.validator(d))&&r.push({type:a.type,severity:a.severity,value:d,start:s,end:g}),l.lastIndex===c.index&&(l.lastIndex+=1),c=l.exec(e)}}),r.sort((a,l)=>a.start!==l.start?a.start-l.start:l.end-a.end);const o=[];for(let a=0;a<r.length&&!(o.length>=n);a+=1){const l=r[a];Qe({start:l.start,end:l.end},o)||o.push(l)}return o}function fe(e,t=120){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}...`}function tt(e,t,n){const r=Math.max(0,t-28),i=Math.min(e.length,n+28);return fe(e.slice(r,i).trim(),180)}function nt(e,t){const n=le(t);return n.total=e.length,e.forEach(r=>{n.byType[r.type]+=1,r.severity==="high"?n.high+=1:r.severity==="medium"?n.medium+=1:n.low+=1}),n}function ie(e,t){const n=e.querySelector(".rte-pii-redaction-live");n&&(n.textContent=t)}function z(e,t,n){const r=t.querySelector('[data-action="toggle-realtime"]');if(!r)return;const i=F(e,n);r.textContent=i?n.labels.realtimeOnText:n.labels.realtimeOffText,r.setAttribute("aria-pressed",i?"true":"false"),C(e,"togglePIIRealtime",i)}function rt(e,t){e.setAttribute("aria-label",t.labels.panelAriaLabel);const n=e.querySelector(".rte-pii-redaction-title");n&&(n.textContent=t.labels.panelTitle);const r=e.querySelector('[data-action="close"]');r&&r.setAttribute("aria-label",t.labels.closeText);const i=e.querySelector('[data-action="run-scan"]');i&&(i.textContent=t.labels.scanText);const o=e.querySelector('[data-action="redact-all"]');o&&(o.textContent=t.labels.redactAllText);const a=e.querySelector(".rte-pii-redaction-shortcut");a&&(a.textContent=t.labels.shortcutText)}function H(e){const t=m.get(e);if(!t)return;const n=f.get(e)||M;if(!n)return;const r=I.get(e)||[],i=E.get(e)||le(0),o=V(e),a=t.querySelector(".rte-pii-redaction-count"),l=t.querySelector(".rte-pii-redaction-summary"),c=t.querySelector(".rte-pii-redaction-list"),d=t.querySelector('[data-action="redact-all"]');if(!(!a||!l||!c||!d)){if(a.textContent=String(i.total),l.textContent=`${n.labels.summaryPrefix}: ${i.total} | High ${i.high} | Medium ${i.medium} | Low ${i.low} | Redacted ${i.redactedCount}`,d.disabled=o||r.length===0,o?ie(t,n.labels.readonlyRedactionText):ie(t,`${i.total} PII findings detected.`),z(e,t,n),r.length===0){c.innerHTML=`<li class="rte-pii-redaction-empty">${p(n.labels.noFindingsText)}</li>`;return}c.innerHTML=r.map(s=>{const g=s.type.toUpperCase(),A=s.suggestion||"Redact this finding before export/share.",B=`${n.labels.locateText}: ${s.match}`,y=`${n.labels.redactText}: ${s.match}`,U=o?'disabled aria-disabled="true"':"";return`
2
2
  <li class="rte-pii-redaction-item rte-pii-redaction-item-${s.severity}">
3
3
  <button
4
4
  type="button"
@@ -11,15 +11,15 @@
11
11
  <span class="rte-pii-redaction-badge">${p(s.severity.toUpperCase())}</span>
12
12
  <span class="rte-pii-redaction-type">${p(g)}</span>
13
13
  </button>
14
- <p class="rte-pii-redaction-line"><strong>${p(n.labels.matchLabel)}:</strong> ${p(ue(s.match,80))}</p>
15
- <p class="rte-pii-redaction-line"><strong>${p(n.labels.maskedLabel)}:</strong> ${p(ue(s.masked,80))}</p>
14
+ <p class="rte-pii-redaction-line"><strong>${p(n.labels.matchLabel)}:</strong> ${p(fe(s.match,80))}</p>
15
+ <p class="rte-pii-redaction-line"><strong>${p(n.labels.maskedLabel)}:</strong> ${p(fe(s.masked,80))}</p>
16
16
  ${s.excerpt?`<p class="rte-pii-redaction-line"><strong>${p(n.labels.excerptLabel)}:</strong> ${p(s.excerpt)}</p>`:""}
17
17
  <p class="rte-pii-redaction-help">${p(A)}</p>
18
18
  <div class="rte-pii-redaction-item-actions">
19
19
  <button type="button" class="rte-pii-redaction-btn" data-action="redact-finding" data-finding-id="${p(s.id)}" aria-label="${p(y)}" ${U}>${p(n.labels.redactText)}</button>
20
20
  </div>
21
21
  </li>
22
- `}).join("")}}function fe(e,t){if(!t.classList.contains("show"))return;const r=be(e).getBoundingClientRect(),i=Math.min(window.innerWidth-20,390),o=Math.max(10,window.innerWidth-i-10),a=Math.min(Math.max(10,r.right-i),o),l=Math.max(10,Math.min(window.innerHeight-10-280,r.top+10));t.style.width=`${i}px`,t.style.left=`${a}px`,t.style.top=`${l}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function F(e,t){const n=S.get(e);return typeof n=="boolean"?n:t?t.enableRealtime:!0}function Re(e,t){if(t===e.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",e,t,e.innerHTML)}catch{}}function Se(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function Me(e,t){e.dispatchEvent(new CustomEvent("editora:pii-redacted",{bubbles:!0,detail:{redactedCount:t}}))}function Ae(e,t){return(I.get(e)||[]).find(r=>r.id===t)}function rt(e){const t=m.get(e);if(t)return t;const n=f.get(e)||M||ee(),r=`rte-pii-redaction-panel-${Fe++}`,i=document.createElement("section");return i.className=u,i.id=r,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","false"),i.setAttribute("aria-label",n.labels.panelAriaLabel),i.innerHTML=`
22
+ `}).join("")}}function pe(e,t){if(!t.classList.contains("show"))return;const r=me(e).getBoundingClientRect(),i=Math.min(window.innerWidth-20,390),o=Math.max(10,window.innerWidth-i-10),a=Math.min(Math.max(10,r.right-i),o),l=Math.max(10,Math.min(window.innerHeight-10-280,r.top+10));t.style.width=`${i}px`,t.style.left=`${a}px`,t.style.top=`${l}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function F(e,t){const n=S.get(e);return typeof n=="boolean"?n:t?t.enableRealtime:!0}function Se(e,t){if(t===e.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",e,t,e.innerHTML)}catch{}}function Me(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function Ae(e,t){e.dispatchEvent(new CustomEvent("editora:pii-redacted",{bubbles:!0,detail:{redactedCount:t}}))}function Pe(e,t){return(I.get(e)||[]).find(r=>r.id===t)}function ot(e){const t=m.get(e);if(t)return t;const n=f.get(e)||M||ee(),r=`rte-pii-redaction-panel-${He++}`,i=document.createElement("section");return i.className=u,i.id=r,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","false"),i.setAttribute("aria-label",n.labels.panelAriaLabel),i.innerHTML=`
23
23
  <header class="rte-pii-redaction-header">
24
24
  <h2 class="rte-pii-redaction-title">${p(n.labels.panelTitle)}</h2>
25
25
  <button type="button" class="rte-pii-redaction-icon-btn" data-action="close" aria-label="${p(n.labels.closeText)}">✕</button>
@@ -38,7 +38,7 @@
38
38
  <p class="rte-pii-redaction-shortcut">${p(n.labels.shortcutText)}</p>
39
39
  <span class="rte-pii-redaction-live" aria-live="polite"></span>
40
40
  </div>
41
- `,i.addEventListener("click",o=>{const l=o.target?.closest("[data-action]");if(!l)return;const c=l.getAttribute("data-action")||"",d=f.get(e)||M||n;if(f.set(e,d),w(e,d),c==="close"){j(e,!0);return}if(c==="run-scan"){h(e,d,!0);return}if(c==="toggle-realtime"){const s=!F(e,d);S.set(e,s),z(e,i,d),s&&h(e,d,!0);return}if(c==="redact-all"){xe(e,d);return}if(c==="locate-finding"){const s=l.getAttribute("data-finding-id")||"",g=Ae(e,s);if(!g)return;at(e,g,d);return}if(c==="redact-finding"){const s=l.getAttribute("data-finding-id")||"";_e(e,s,d)}}),i.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),j(e,!0);return}if(o.key!=="ArrowDown"&&o.key!=="ArrowUp")return;const a=Array.from(i.querySelectorAll('[data-role="finding-button"]'));if(a.length===0)return;const l=document.activeElement,c=a.findIndex(g=>g===l);if(c===-1)return;o.preventDefault();const d=o.key==="ArrowDown"?1:-1,s=(c+d+a.length)%a.length;a[s].focus()}),ne(i,e),document.body.appendChild(i),m.set(e,i),Z.set(e,!1),H(e),i}function j(e,t=!1){const n=m.get(e);n&&(n.classList.remove("show"),Z.set(e,!1),C(e,"togglePIIRedactionPanel",!1),t&&e.focus({preventScroll:!0}))}function N(e){K();const t=rt(e);m.forEach((r,i)=>{i!==e&&j(i,!1)}),t.classList.add("show"),Z.set(e,!0),C(e,"togglePIIRedactionPanel",!0),ne(t,e),fe(e,t),H(e),t.querySelector('[data-action="run-scan"]')?.focus()}function Pe(e,t){const n=oe(e);return(typeof t=="boolean"?t:!n)?N(e):j(e),!0}function ot(e,t){const n=t.normalizeText(e.innerText||e.textContent||""),r=e.innerHTML;return`${n.length}:${ve(n)}:${r.length}:${ve(r)}:${t.detectorSignature}`}function it(e,t){const n=[],r=ge(e.pattern);let i=r.exec(t);for(;i;){const o=i[0]||"",a=i.index,l=a+o.length;o&&l>a&&(!e.validator||e.validator(o))&&n.push({value:o,start:a,end:l}),r.lastIndex===i.index&&(r.lastIndex+=1),i=r.exec(t)}return n}function Le(e,t,n){const r=n.detectors.find(c=>c.type===t.type&&c.enabled);if(!r)return null;const i=t.match.toLowerCase();let o=0;const a=document.createTreeWalker(e,pe,null);let l=a.nextNode();for(;l;){if(!he(l,n)){const c=it(r,l.data);for(let d=0;d<c.length;d+=1){const s=c[d];if(s.value.toLowerCase()===i&&(o+=1,o===t.occurrence)){const g=document.createRange();return g.setStart(l,s.start),g.setEnd(l,s.end),g}}}l=a.nextNode()}return null}function at(e,t,n){const r=Le(e,t,n);if(!r)return!1;const i=window.getSelection();return i?(i.removeAllRanges(),i.addRange(r),re(r.startContainer)?.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),e.focus({preventScroll:!0}),!0):!1}async function h(e,t,n=!1){w(e,t);const r=ot(e,t);if(!n&&de.get(e)===r)return I.get(e)||[];const i=(Q.get(e)||0)+1;Q.set(e,i);const o=[],a=new Map,l=document.createTreeWalker(e,pe,null);let c=l.nextNode();for(;c&&o.length<t.maxFindings;){const g=c.data||"";if(g.trim()&&!he(c,t)){const A=Qe(g,t.detectors,t.maxFindings-o.length);for(let B=0;B<A.length&&!(o.length>=t.maxFindings);B+=1){const y=A[B],U=`${y.type}:${y.value.toLowerCase()}`,ye=(a.get(U)||0)+1;a.set(U,ye),o.push({id:Xe(y.type),type:y.type,severity:y.severity,match:y.value,masked:Te(y.value,y.type,t),occurrence:ye,excerpt:et(g,y.start,y.end),suggestion:"Review and redact this value before external sharing."})}}c=l.nextNode()}if(Q.get(e)!==i)return I.get(e)||[];const d=E.get(e)?.redactedCount||0,s=tt(o,d);return de.set(e,r),I.set(e,o),E.set(e,s),H(e),e.dispatchEvent(new CustomEvent("editora:pii-scan",{bubbles:!0,detail:{findings:o,stats:s}})),o}function lt(e,t){let n=e,r=0;return t.detectors.filter(o=>o.enabled).forEach(o=>{const a=ge(o.pattern);n=n.replace(a,l=>o.validator&&!o.validator(l)?l:(r+=1,Ce(l,o.type,t)))}),{nextValue:n,count:r}}async function _e(e,t,n){if(V(e)){const d=m.get(e);return d&&ie(d,n.labels.readonlyRedactionText),!1}const r=Ae(e,t);if(!r)return!1;const i=Le(e,r,n);if(!i)return!1;const o=e.innerHTML,a=Ce(r.match,r.type,n);if(i.startContainer===i.endContainer&&i.startContainer.nodeType===Node.TEXT_NODE){const d=i.startContainer,s=d.data,g=i.startOffset,A=i.endOffset;d.data=`${s.slice(0,g)}${a}${s.slice(A)}`}else i.deleteContents(),i.insertNode(document.createTextNode(a));Se(e),Re(e,o);const l=E.get(e)?.redactedCount||0;await h(e,n,!0);const c=E.get(e);return c&&(c.redactedCount=l+1,H(e)),Me(e,1),!0}async function xe(e,t){if(V(e)){const d=m.get(e);return d&&ie(d,t.labels.readonlyRedactionText),0}(I.get(e)||[]).length===0&&await h(e,t,!0);const r=e.innerHTML;let i=0;const o=document.createTreeWalker(e,pe,null);let a=o.nextNode();for(;a;){if(he(a,t)){a=o.nextNode();continue}const d=a.data||"";if(!d){a=o.nextNode();continue}const s=lt(d,t);s.count>0&&s.nextValue!==d&&(a.data=s.nextValue,i+=s.count),a=o.nextNode()}if(i===0)return 0;Se(e),Re(e,r);const l=E.get(e)?.redactedCount||0;await h(e,t,!0);const c=E.get(e);return c&&(c.redactedCount=l+i,H(e)),Me(e,i),i}function De(e){const t=f.get(e)||M;if(!t||!F(e,t)||V(e))return;me(e);const n=window.setTimeout(()=>{W.delete(n),te.delete(e),h(e,t,!1)},t.debounceMs);W.add(n),te.set(e,n)}function ct(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="i"}function st(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="u"}function dt(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="m"}function ut(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="y"}function ft(e){const t=re(e.target);if(t){const r=t.closest(x);if(r)return r;const i=t.closest(ae);if(i){const a=O(i);if(a)return a}const o=t.closest(`.${u}`);if(o){const a=Array.from(m.entries()).find(([,l])=>l===o);if(a)return a[0]}}const n=window.getSelection();if(n&&n.rangeCount>0){const r=re(n.getRangeAt(0).startContainer)?.closest(x);if(r)return r}return null}function pt(){if(typeof document>"u"||document.getElementById(we))return;const e=document.createElement("style");e.id=we,e.textContent=`
41
+ `,i.addEventListener("click",o=>{const l=o.target?.closest("[data-action]");if(!l)return;const c=l.getAttribute("data-action")||"",d=f.get(e)||M||n;if(f.set(e,d),w(e,d),c==="close"){j(e,!0);return}if(c==="run-scan"){h(e,d,!0);return}if(c==="toggle-realtime"){const s=!F(e,d);S.set(e,s),z(e,i,d),s&&h(e,d,!0);return}if(c==="redact-all"){ye(e,d);return}if(c==="locate-finding"){const s=l.getAttribute("data-finding-id")||"",g=Pe(e,s);if(!g)return;lt(e,g,d);return}if(c==="redact-finding"){const s=l.getAttribute("data-finding-id")||"";De(e,s,d)}}),i.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),j(e,!0);return}if(o.key!=="ArrowDown"&&o.key!=="ArrowUp")return;const a=Array.from(i.querySelectorAll('[data-role="finding-button"]'));if(a.length===0)return;const l=document.activeElement,c=a.findIndex(g=>g===l);if(c===-1)return;o.preventDefault();const d=o.key==="ArrowDown"?1:-1,s=(c+d+a.length)%a.length;a[s].focus()}),ne(i,e),document.body.appendChild(i),m.set(e,i),Z.set(e,!1),H(e),i}function j(e,t=!1){const n=m.get(e);n&&(n.classList.remove("show"),Z.set(e,!1),C(e,"togglePIIRedactionPanel",!1),t&&e.focus({preventScroll:!0}))}function N(e){K();const t=ot(e);m.forEach((r,i)=>{i!==e&&j(i,!1)}),t.classList.add("show"),Z.set(e,!0),C(e,"togglePIIRedactionPanel",!0),ne(t,e),pe(e,t),H(e),t.querySelector('[data-action="run-scan"]')?.focus()}function Le(e,t){const n=oe(e);return(typeof t=="boolean"?t:!n)?N(e):j(e),!0}function it(e,t){const n=t.normalizeText(e.innerText||e.textContent||""),r=e.innerHTML;return`${n.length}:${$e(n)}:${r.length}:${$e(r)}:${t.detectorSignature}`}function at(e,t){const n=[],r=be(e.pattern);let i=r.exec(t);for(;i;){const o=i[0]||"",a=i.index,l=a+o.length;o&&l>a&&(!e.validator||e.validator(o))&&n.push({value:o,start:a,end:l}),r.lastIndex===i.index&&(r.lastIndex+=1),i=r.exec(t)}return n}function _e(e,t,n){const r=n.detectors.find(c=>c.type===t.type&&c.enabled);if(!r)return null;const i=t.match.toLowerCase();let o=0;const a=document.createTreeWalker(e,ge,null);let l=a.nextNode();for(;l;){if(!xe(l,n)){const c=at(r,l.data);for(let d=0;d<c.length;d+=1){const s=c[d];if(s.value.toLowerCase()===i&&(o+=1,o===t.occurrence)){const g=document.createRange();return g.setStart(l,s.start),g.setEnd(l,s.end),g}}}l=a.nextNode()}return null}function lt(e,t,n){const r=_e(e,t,n);if(!r)return!1;const i=window.getSelection();return i?(i.removeAllRanges(),i.addRange(r),re(r.startContainer)?.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),e.focus({preventScroll:!0}),!0):!1}async function h(e,t,n=!1){w(e,t);const r=it(e,t);if(!n&&ue.get(e)===r)return I.get(e)||[];const i=(Q.get(e)||0)+1;Q.set(e,i);const o=[],a=new Map,l=document.createTreeWalker(e,ge,null);let c=l.nextNode();for(;c&&o.length<t.maxFindings;){const g=c.data||"";if(g.trim()&&!xe(c,t)){const A=et(g,t.detectors,t.maxFindings-o.length);for(let B=0;B<A.length&&!(o.length>=t.maxFindings);B+=1){const y=A[B],U=`${y.type}:${y.value.toLowerCase()}`,ke=(a.get(U)||0)+1;a.set(U,ke),o.push({id:Je(y.type),type:y.type,severity:y.severity,match:y.value,masked:Ce(y.value,y.type,t),occurrence:ke,excerpt:tt(g,y.start,y.end),suggestion:"Review and redact this value before external sharing."})}}c=l.nextNode()}if(Q.get(e)!==i)return I.get(e)||[];const d=E.get(e)?.redactedCount||0,s=nt(o,d);return ue.set(e,r),I.set(e,o),E.set(e,s),H(e),e.dispatchEvent(new CustomEvent("editora:pii-scan",{bubbles:!0,detail:{findings:o,stats:s}})),o}function ct(e,t){let n=e,r=0;return t.detectors.filter(o=>o.enabled).forEach(o=>{const a=be(o.pattern);n=n.replace(a,l=>o.validator&&!o.validator(l)?l:(r+=1,Re(l,o.type,t)))}),{nextValue:n,count:r}}async function De(e,t,n){if(V(e)){const d=m.get(e);return d&&ie(d,n.labels.readonlyRedactionText),!1}const r=Pe(e,t);if(!r)return!1;const i=_e(e,r,n);if(!i)return!1;const o=e.innerHTML,a=Re(r.match,r.type,n);if(i.startContainer===i.endContainer&&i.startContainer.nodeType===Node.TEXT_NODE){const d=i.startContainer,s=d.data,g=i.startOffset,A=i.endOffset;d.data=`${s.slice(0,g)}${a}${s.slice(A)}`}else i.deleteContents(),i.insertNode(document.createTextNode(a));Me(e),Se(e,o);const l=E.get(e)?.redactedCount||0;await h(e,n,!0);const c=E.get(e);return c&&(c.redactedCount=l+1,H(e)),Ae(e,1),!0}async function ye(e,t){if(V(e)){const d=m.get(e);return d&&ie(d,t.labels.readonlyRedactionText),0}(I.get(e)||[]).length===0&&await h(e,t,!0);const r=e.innerHTML;let i=0;const o=document.createTreeWalker(e,ge,null);let a=o.nextNode();for(;a;){if(xe(a,t)){a=o.nextNode();continue}const d=a.data||"";if(!d){a=o.nextNode();continue}const s=ct(d,t);s.count>0&&s.nextValue!==d&&(a.data=s.nextValue,i+=s.count),a=o.nextNode()}if(i===0)return 0;Me(e),Se(e,r);const l=E.get(e)?.redactedCount||0;await h(e,t,!0);const c=E.get(e);return c&&(c.redactedCount=l+i,H(e)),Ae(e,i),i}function Ne(e){const t=f.get(e)||M;if(!t||!F(e,t)||V(e))return;he(e);const n=window.setTimeout(()=>{W.delete(n),te.delete(e),h(e,t,!1)},t.debounceMs);W.add(n),te.set(e,n)}function ce(e){return typeof e.key=="string"?e.key.toLowerCase():""}function st(e){const t=ce(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="i"}function dt(e){const t=ce(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="u"}function ut(e){const t=ce(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="m"}function ft(e){const t=ce(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="y"}function pt(e){const t=re(e.target);if(t){const r=t.closest(x);if(r)return r;const i=t.closest(ae);if(i){const a=O(i);if(a)return a}const o=t.closest(`.${u}`);if(o){const a=Array.from(m.entries()).find(([,l])=>l===o);if(a)return a[0]}}const n=window.getSelection();if(n&&n.rangeCount>0){const r=re(n.getRangeAt(0).startContainer)?.closest(x);if(r)return r}return null}function gt(){if(typeof document>"u"||document.getElementById(Ee))return;const e=document.createElement("style");e.id=Ee,e.textContent=`
42
42
  .rte-toolbar-group-items.${k},
43
43
  .editora-toolbar-group-items.${k},
44
44
  .rte-toolbar-group-items.${v},
@@ -433,4 +433,4 @@
433
433
  max-height: 45vh;
434
434
  }
435
435
  }
436
- `,document.head.appendChild(e)}function gt(e){M=e,P||(P=t=>{K();const r=t.target?.closest(x);if(!r)return;b=r;const i=f.get(r)||e;w(r,i),f.set(r,i),C(r,"togglePIIRedactionPanel",oe(r)),C(r,"togglePIIRealtime",F(r,i));const o=m.get(r);o&&(ne(o,r),fe(r,o),z(r,o,i))},document.addEventListener("focusin",P,!0)),L||(L=t=>{const r=t.target?.closest(x);r&&(b=r,De(r))},document.addEventListener("input",L,!0)),_||(_=t=>{if(t.defaultPrevented||t.target?.closest(`.${u} input, .${u} textarea, .${u} select`))return;const r=ft(t);if(!r)return;const i=f.get(r)||M||e;if(w(r,i),f.set(r,i),b=r,t.key==="Escape"&&oe(r)){t.preventDefault(),j(r,!0);return}if(ct(t)){t.preventDefault(),t.stopPropagation(),Pe(r);return}if(st(t)){t.preventDefault(),t.stopPropagation(),h(r,i,!0),N(r);return}if(dt(t)){t.preventDefault(),t.stopPropagation(),V(r)||(xe(r,i),N(r));return}if(ut(t)){t.preventDefault(),t.stopPropagation();const o=!F(r,i);S.set(r,o);const a=m.get(r);a&&z(r,a,i),C(r,"togglePIIRealtime",o),o&&h(r,i,!0)}},document.addEventListener("keydown",_,!0)),R||(R=()=>{K(),m.forEach((t,n)=>{!n.isConnected||!t.isConnected||(ne(t,n),fe(n,t))})},window.addEventListener("scroll",R,!0),window.addEventListener("resize",R)),!D&&typeof MutationObserver<"u"&&document.body&&(D=new MutationObserver(t=>{Ue(t)&&K()}),D.observe(document.body,{childList:!0,subtree:!0}))}function bt(){P&&(document.removeEventListener("focusin",P,!0),P=null),L&&(document.removeEventListener("input",L,!0),L=null),_&&(document.removeEventListener("keydown",_,!0),_=null),R&&(window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R),R=null),D&&(D.disconnect(),D=null),m.forEach(e=>e.remove()),m.clear(),q.forEach(e=>me(e)),q.clear(),M=null,b=null}const mt=(e={})=>{const t=ee(e),n=new Set;return pt(),{name:"piiRedaction",toolbar:[{id:"piiRedactionGroup",label:"PII Redaction",type:"group",command:"piiRedaction",items:[{id:"piiRedaction",label:"PII Redaction",command:"togglePIIRedactionPanel",shortcut:"Mod-Alt-Shift-i",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3.5 19 6.5v4.8c0 4.4-2.7 8.1-7 9.2-4.3-1.1-7-4.8-7-9.2V6.5l7-3Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M8.8 11.6h6.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12" cy="11.6" r="1.2" fill="currentColor"/></svg>'},{id:"piiScan",label:"Scan PII",command:"runPIIScan",shortcut:"Mod-Alt-Shift-u",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4.5" y="3.5" width="11" height="15" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M7.5 8.2h5M7.5 11.2h5M7.5 14.2h3.2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="16.8" cy="16.8" r="2.8" stroke="currentColor" stroke-width="1.6"/><path d="m18.8 18.8 2 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"piiRedactAll",label:"Redact All PII",command:"redactAllPII",shortcut:"Mod-Alt-Shift-m",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 18h14" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M7 6h10l-1 8H8L7 6Z" stroke="currentColor" stroke-width="1.7"/><path d="m9 9 6 4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'},{id:"piiRealtime",label:"Toggle Realtime PII Scan",command:"togglePIIRealtime",shortcut:"Mod-Alt-Shift-y",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3v4M12 17v4M4 12h4M16 12h4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.7"/></svg>'}]}],commands:{piiRedaction:(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;return w(o,a),f.set(o,a),b=o,N(o),h(o,a,!1),!0},togglePIIRedactionPanel:(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;w(o,a),f.set(o,a),b=o;const l=Pe(o,typeof r=="boolean"?r:void 0);return oe(o)&&h(o,a,!1),l},runPIIScan:async(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;return w(o,a),f.set(o,a),b=o,await h(o,a,!0),N(o),!0},redactAllPII:async(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;w(o,a),f.set(o,a),b=o;const l=await xe(o,a);return l>0&&N(o),l>0},redactPIIFinding:async(r,i)=>{const o=T(i);if(!o||typeof r!="string"||!r)return!1;const a=f.get(o)||t;return w(o,a),f.set(o,a),b=o,_e(o,r,a)},togglePIIRealtime:(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;w(o,a),f.set(o,a);const l=typeof r=="boolean"?r:!F(o,a);S.set(o,l);const c=m.get(o);return c&&z(o,c,a),C(o,"togglePIIRealtime",l),l&&h(o,a,!0),!0},getPIIRedactionFindings:(r,i)=>{const o=T(i);if(!o)return!1;const a=I.get(o)||[],l=E.get(o)||le(0),c=a.map(s=>({...s})),d={...l,byType:{...l.byType}};if(typeof r=="function")try{r(c,d)}catch{}return o.__piiRedactionFindings=c,o.dispatchEvent(new CustomEvent("editora:pii-findings",{bubbles:!0,detail:{findings:c,stats:d}})),!0},setPIIRedactionOptions:(r,i)=>{const o=T(i);if(!o||!r||typeof r!="object")return!1;const a=f.get(o)||t,l=ee({...ce(a),...r,labels:{...a.labels,...r.labels||{}},detectors:{...ce(a).detectors||{},...r.detectors||{}},normalizeText:r.normalizeText||a.normalizeText});f.set(o,l),typeof r.enableRealtime=="boolean"&&S.set(o,r.enableRealtime);const c=m.get(o);return c&&(nt(c,l),H(o),z(o,c,l)),h(o,l,!0),!0}},keymap:{"Mod-Alt-Shift-i":"togglePIIRedactionPanel","Mod-Alt-Shift-I":"togglePIIRedactionPanel","Mod-Alt-Shift-u":"runPIIScan","Mod-Alt-Shift-U":"runPIIScan","Mod-Alt-Shift-m":"redactAllPII","Mod-Alt-Shift-M":"redactAllPII","Mod-Alt-Shift-y":"togglePIIRealtime","Mod-Alt-Shift-Y":"togglePIIRealtime"},init:function(i){G+=1;const o=this&&typeof this.__pluginConfig=="object"?ee({...ce(t),...this.__pluginConfig}):t;gt(o);const a=T(i?.editorElement?{editorElement:i.editorElement}:void 0,!1);a&&(b=a,n.add(a),w(a,o),f.set(a,o),C(a,"togglePIIRedactionPanel",!1),C(a,"togglePIIRealtime",o.enableRealtime),o.enableRealtime&&De(a))},destroy:()=>{n.forEach(r=>Ie(r)),n.clear(),G=Math.max(0,G-1),!(G>0)&&(W.forEach(r=>{window.clearTimeout(r)}),W.clear(),bt())}}};exports.PIIRedactionPlugin=mt;
436
+ `,document.head.appendChild(e)}function bt(e){M=e,P||(P=t=>{K();const r=t.target?.closest(x);if(!r)return;b=r;const i=f.get(r)||e;w(r,i),f.set(r,i),C(r,"togglePIIRedactionPanel",oe(r)),C(r,"togglePIIRealtime",F(r,i));const o=m.get(r);o&&(ne(o,r),pe(r,o),z(r,o,i))},document.addEventListener("focusin",P,!0)),L||(L=t=>{const r=t.target?.closest(x);r&&(b=r,Ne(r))},document.addEventListener("input",L,!0)),_||(_=t=>{if(t.defaultPrevented||t.target?.closest(`.${u} input, .${u} textarea, .${u} select`))return;const r=pt(t);if(!r)return;const i=f.get(r)||M||e;if(w(r,i),f.set(r,i),b=r,t.key==="Escape"&&oe(r)){t.preventDefault(),j(r,!0);return}if(st(t)){t.preventDefault(),t.stopPropagation(),Le(r);return}if(dt(t)){t.preventDefault(),t.stopPropagation(),h(r,i,!0),N(r);return}if(ut(t)){t.preventDefault(),t.stopPropagation(),V(r)||(ye(r,i),N(r));return}if(ft(t)){t.preventDefault(),t.stopPropagation();const o=!F(r,i);S.set(r,o);const a=m.get(r);a&&z(r,a,i),C(r,"togglePIIRealtime",o),o&&h(r,i,!0)}},document.addEventListener("keydown",_,!0)),R||(R=()=>{K(),m.forEach((t,n)=>{!n.isConnected||!t.isConnected||(ne(t,n),pe(n,t))})},window.addEventListener("scroll",R,!0),window.addEventListener("resize",R)),!D&&typeof MutationObserver<"u"&&document.body&&(D=new MutationObserver(t=>{Ge(t)&&K()}),D.observe(document.body,{childList:!0,subtree:!0}))}function mt(){P&&(document.removeEventListener("focusin",P,!0),P=null),L&&(document.removeEventListener("input",L,!0),L=null),_&&(document.removeEventListener("keydown",_,!0),_=null),R&&(window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R),R=null),D&&(D.disconnect(),D=null),m.forEach(e=>e.remove()),m.clear(),q.forEach(e=>he(e)),q.clear(),M=null,b=null}const ht=(e={})=>{const t=ee(e),n=new Set;return gt(),{name:"piiRedaction",toolbar:[{id:"piiRedactionGroup",label:"PII Redaction",type:"group",command:"piiRedaction",items:[{id:"piiRedaction",label:"PII Redaction",command:"togglePIIRedactionPanel",shortcut:"Mod-Alt-Shift-i",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3.5 19 6.5v4.8c0 4.4-2.7 8.1-7 9.2-4.3-1.1-7-4.8-7-9.2V6.5l7-3Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M8.8 11.6h6.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12" cy="11.6" r="1.2" fill="currentColor"/></svg>'},{id:"piiScan",label:"Scan PII",command:"runPIIScan",shortcut:"Mod-Alt-Shift-u",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4.5" y="3.5" width="11" height="15" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M7.5 8.2h5M7.5 11.2h5M7.5 14.2h3.2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="16.8" cy="16.8" r="2.8" stroke="currentColor" stroke-width="1.6"/><path d="m18.8 18.8 2 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"piiRedactAll",label:"Redact All PII",command:"redactAllPII",shortcut:"Mod-Alt-Shift-m",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 18h14" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M7 6h10l-1 8H8L7 6Z" stroke="currentColor" stroke-width="1.7"/><path d="m9 9 6 4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'},{id:"piiRealtime",label:"Toggle Realtime PII Scan",command:"togglePIIRealtime",shortcut:"Mod-Alt-Shift-y",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3v4M12 17v4M4 12h4M16 12h4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.7"/></svg>'}]}],commands:{piiRedaction:(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;return w(o,a),f.set(o,a),b=o,N(o),h(o,a,!1),!0},togglePIIRedactionPanel:(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;w(o,a),f.set(o,a),b=o;const l=Le(o,typeof r=="boolean"?r:void 0);return oe(o)&&h(o,a,!1),l},runPIIScan:async(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;return w(o,a),f.set(o,a),b=o,await h(o,a,!0),N(o),!0},redactAllPII:async(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;w(o,a),f.set(o,a),b=o;const l=await ye(o,a);return l>0&&N(o),l>0},redactPIIFinding:async(r,i)=>{const o=T(i);if(!o||typeof r!="string"||!r)return!1;const a=f.get(o)||t;return w(o,a),f.set(o,a),b=o,De(o,r,a)},togglePIIRealtime:(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;w(o,a),f.set(o,a);const l=typeof r=="boolean"?r:!F(o,a);S.set(o,l);const c=m.get(o);return c&&z(o,c,a),C(o,"togglePIIRealtime",l),l&&h(o,a,!0),!0},getPIIRedactionFindings:(r,i)=>{const o=T(i);if(!o)return!1;const a=I.get(o)||[],l=E.get(o)||le(0),c=a.map(s=>({...s})),d={...l,byType:{...l.byType}};if(typeof r=="function")try{r(c,d)}catch{}return o.__piiRedactionFindings=c,o.dispatchEvent(new CustomEvent("editora:pii-findings",{bubbles:!0,detail:{findings:c,stats:d}})),!0},setPIIRedactionOptions:(r,i)=>{const o=T(i);if(!o||!r||typeof r!="object")return!1;const a=f.get(o)||t,l=ee({...se(a),...r,labels:{...a.labels,...r.labels||{}},detectors:{...se(a).detectors||{},...r.detectors||{}},normalizeText:r.normalizeText||a.normalizeText});f.set(o,l),typeof r.enableRealtime=="boolean"&&S.set(o,r.enableRealtime);const c=m.get(o);return c&&(rt(c,l),H(o),z(o,c,l)),h(o,l,!0),!0}},keymap:{"Mod-Alt-Shift-i":"togglePIIRedactionPanel","Mod-Alt-Shift-I":"togglePIIRedactionPanel","Mod-Alt-Shift-u":"runPIIScan","Mod-Alt-Shift-U":"runPIIScan","Mod-Alt-Shift-m":"redactAllPII","Mod-Alt-Shift-M":"redactAllPII","Mod-Alt-Shift-y":"togglePIIRealtime","Mod-Alt-Shift-Y":"togglePIIRealtime"},init:function(i){G+=1;const o=this&&typeof this.__pluginConfig=="object"?ee({...se(t),...this.__pluginConfig}):t;bt(o);const a=T(i?.editorElement?{editorElement:i.editorElement}:void 0,!1);a&&(b=a,n.add(a),w(a,o),f.set(a,o),C(a,"togglePIIRedactionPanel",!1),C(a,"togglePIIRealtime",o.enableRealtime),o.enableRealtime&&Ne(a))},destroy:()=>{n.forEach(r=>Te(r)),n.clear(),G=Math.max(0,G-1),!(G>0)&&(W.forEach(r=>{window.clearTimeout(r)}),W.clear(),mt())}}};exports.PIIRedactionPlugin=ht;