1const g="This field contains language we cannot accept.",f=Object.freeze({0:"o",1:"i",3:"e",4:"a",5:"s",7:"t","@":"a",$:"s"});let l=0;const i=new WeakMap;function p(e){return e.normalize("NFKD").toLocaleLowerCase("en-GB").replace(/[\p{M}\p{Cf}]/gu,"").replace(/[013457@$]/g,t=>f[t])}function c(e){return e.replace(/[^\p{L}\p{N}]+/gu," ").replace(/\s+/gu," ").trim()}function u(e){return c(p(e))}function v(e){return c(e.replace(new RegExp("(?<=[\\p{L}\\p{N}])[\\p{P}\\p{S}]+(?=[\\p{L}\\p{N}])","gu"),""))}function E(e){return e.replace(new RegExp("(?<![\\p{L}\\p{N}])(?:[\\p{L}\\p{N}]\\s+){2,}[\\p{L}\\p{N}](?![\\p{L}\\p{N}])","gu"),t=>t.replace(/\s+/gu,""))}function b(e){const t=p(e),r=c(t);return[...new Set([r,v(t),E(r)])]}function L(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function y(e){const t=e.split(/\s+/u).filter(Boolean).map(L);return t.length===0?null:new RegExp(`(?<![\\p{L}\\p{N}])${t.join("\\s+")}(?![\\p{L}\\p{N}])`,"u")}function s(e,t){const r=e==null?void 0:e[t];return Array.isArray(r)?r.filter(n=>typeof n=="string"):[]}function h(e){if(e!==null&&typeof e=="object"&&i.has(e))return i.get(e);const t=Object.freeze({allowedValues:new Set(s(e,"allowed_exact_values").map(u)),blockedPatterns:[...s(e,"blocked_terms"),...s(e,"blocked_phrases")].map(u).map(y).filter(r=>r!==null)});return e!==null&&typeof e=="object"&&i.set(e,t),t}function A(e,t){if(typeof e!="string"||e==="")return!1;const r=b(e),n=h(t);return r.some(o=>n.allowedValues.has(o))?!1:n.blockedPatterns.some(o=>r.some(m=>o.test(m)))}function w(e,t){return A(e,t)?g:null}function T(e,t=!1){if(t||(e==null?void 0:e.content_moderation)===!1||!["text","textarea"].includes(e==null?void 0:e.type))return!1;const r=String((e==null?void 0:e.slug)||"").toLocaleLowerCase("en-GB");if(/(?:^|_)(?:email|phone|mobile|postcode|date|year|property|voter|address|url)(?:_|$)/u.test(r))return!1;const n=Array.isArray(e==null?void 0:e.validation)?e.validation.join("|"):String((e==null?void 0:e.validation)||"");return!/(?:^|\|)(?:email|url|date|date_format|integer|numeric|boolean|regex|not_regex)(?::|\||$)/u.test(n.toLocaleLowerCase("en-GB"))}function S(e=globalThis.document){var r;const t=(r=e==null?void 0:e.querySelector('meta[name="content-moderation-policy"]'))==null?void 0:r.getAttribute("content");if(!t)return null;try{const n=Uint8Array.from(globalThis.atob(t),a=>
1a.charCodeAt(0));return JSON.parse(new TextDecoder().decode(n))}catch(n){throw new Error("Unable to read the content moderation policy.",{cause:n})}}function N(e,t){const r=(e.getAttribute("aria-describedby")||"").split(/\s+/u).filter(n=>n&&n!==t);r.length>0?e.setAttribute("aria-describedby",r.join(" ")):e.removeAttribute("aria-describedby")}function C(e){var r;const t=e.dataset.contentModerationErrorId;t&&((r=e.ownerDocument.getElementById(t))==null||r.remove(),N(e,t),delete e.dataset.contentModerationErrorId),e.removeAttribute("aria-invalid"),e.removeAttribute("data-content-moderation-invalid")}function M(e,t){let r=e.dataset.contentModerationErrorId,n=r?e.ownerDocument.getElementById(r):null;if(!n){l+=1,r=`content-moderation-error-${l}`,n=e.ownerDocument.createElement("p"),n.id=r,n.className="mt-1 text-sm text-red-600",n.dataset.contentModerationError="true",e.insertAdjacentElement("afterend",n),e.dataset.contentModerationErrorId=r;const a=(e.getAttribute("aria-describedby")||"").trim();e.setAttribute("aria-describedby",[a,r].filter(Boolean).join(" "))}n.textContent=t,e.setAttribute("aria-invalid","true"),e.setAttribute("data-content-moderation-invalid","true")}function d(e,t){var n;if(!((n=e==null?void 0:e.matches)!=null&&n.call(e,"[data-content-moderation]"))||typeof e.setCustomValidity!="function")return!0;const r=w(e.value,t);return e.setCustomValidity(r||""),r?(M(e,r),!1):(C(e),!0)}function x(e=globalThis.document){var r,n,a;const t=(r=e==null?void 0:e.querySelector)==null?void 0:r.call(e,'[data-content-moderation-invalid="true"]');return t?((n=t.reportValidity)==null||n.call(t),(a=t.focus)==null||a.call(t),!0):!1}function I(e=globalThis.document){const t=S(e);if(!t||!(e!=null&&e.addEventListener))return()=>{};const r=n=>d(n.target,t);return e.addEventListener("input",r),e.addEventListener("blur",r,!0),e.querySelectorAll("[data-content-moderation]").forEach(n=>{d(n,t)}),()=>{e.removeEventListener("input",r),e.removeEventListener("blur",r,!0)}}export{S as a,I as i,w as m,x as r,T as s};
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.