(()=>{var g=s=>String(s).replace(/[^a-zA-Z0-9\s]/g,"").trim().replace(/\s+/g," ").split(" ").map(m=>m.toLowerCase()).join("_");var b={initTrecaptcha:(s,m=!0)=>{if(!s){console.error("unable to init");return}let w=(r,n)=>{let o=null;return(...l)=>{window.clearTimeout(o),o=window.setTimeout(()=>{r.apply(null,l)},n)}},y=(r,n)=>new Promise((o,l)=>{let p=new TextEncoder("utf-8"),a={name:"HMAC",hash:"SHA-256"};crypto.subtle.importKey("raw",p.encode(r),a,!1,["sign","verify"]).then(u=>{crypto.subtle.sign(a.name,u,p.encode(n)).then(i=>{let h=window.btoa(String.fromCharCode(...new Uint8Array(i)));o(h)}).catch(i=>{l("failed")})}).catch(u=>{l("failed")})}),t={c:0,rf:0,ttf:0,fh:"",sw:0,ref:0,st:0};try{let r=document.getElementById(m?`form_${s}`:s),n=new Set(["text","tel","email","textarea"]),o=new Set;(tresioConfig?.forms?.[s]?.fields??[]).forEach(e=>{Array.isArray(e)&&e.forEach(c=>{n.has(c.type)&&c?.required&&(o.add(g(c?.label)),t.rf+=1)})});let a=(e,c)=>{let f=window.btoa(JSON.stringify(c));e.value!==f&&(e.value=f)},u=()=>{if(r.querySelector("input[name=form_meta]"))return;let e=document.createElement("input");return Object.assign(e,{type:"hidden",name:"form_meta"}),r.append(e),e},i=[];Array.from(o).forEach(e=>{i.push(r.querySelector(`input[name=${e}]`))});let h=u();t.ref=document.referrer!==""?1:0,t.st=Date.parse(new Date().toUTCString()),document.addEventListener("wheel",()=>{t.sw=1},{once:!0});let S=()=>new Promise((e,c)=>{let f="";i.forEach(d=>{d?.value&&(f+=d?.value)}),y(document.location.host,f).then(d=>{e(d)}).catch(d=>{c(d)})}),E=!1,v=Date.now();i.forEach(e=>{e?.getAttribute("data-tc")||(e?.addEventListener("keydown",()=>{E||(v=Date.now(),E=!0)}),e?.addEventListener("keydown",w(()=>{t.ttf+=(Date.now()-v)/1e3,E=!1,a(h,t)},500)),e?.addEventListener("focus",()=>{t.c+=1,a(h,t)}),e?.addEventListener("blur",c=>{o.has(c.target.name)&&S().then(f=>{t.fh=f}),a(h,t)}),e?.setAttribute("data-tc",!0))})}catch(r){console.debug(r)}return t},init:()=>{let s=Array.from(document.querySelectorAll("form")).reduce((t,r)=>(t.set(g(r?.id?.replace("form_","")),{initialized:!1,form:r}),t),new Map),m=(t,r)=>{t.forEach((n,o)=>{new MutationObserver(p=>{p.forEach(a=>{if(a.type==="attributes"){let u=g(a.target?.id?.replace("form_",""))?.toLowerCase(),i=r.get(u);i&&!i.initialized&&(b.initTrecaptcha(a.target.id?.replace("form_","")),i.initialized=!0)}})}).observe(n.form,{attributes:!0,attributeFilter:["id"]})})},w=0,y=()=>{if(!document.querySelector("form"))return;let t=typeof tresioConfig>"u"?null:tresioConfig,r=!1;if(t){let n=new Map;for(let o in t?.forms)n.set(o?.toLowerCase(),{initialized:!1}),s.has(o)&&(r=!0,b.initTrecaptcha(o));r||m(s,n)}else setTimeout(()=>{w<10&&(w++,y())},1e3)};y()}};window.treCaptcha=b;b.init();})();