UNPKG

@trustcomponent/trustcaptcha-frontend

Version:

TrustCaptcha – Privacy-first CAPTCHA solution. GDPR-compliant, bot protection made in Europe.

1,380 lines (1,357 loc) 165 kB
const NAMESPACE = 'frontendlibrary'; const BUILD = /* frontendlibrary */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: false, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: false, element: false, event: true, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, hydratedSelectorName: "hydrated", invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: false, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, modernPropertyDecls: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: false, propNumber: false, propString: true, reflect: true, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, slot: false, slotChildNodesFix: false, slotRelocation: false, state: true, style: true, svg: true, taskQueue: true, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: false, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: false, watchCallback: true }; /* Stencil Client Platform v4.26.0 | MIT Licensed | https://stenciljs.com */ var __defProp = Object.defineProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; // src/utils/constants.ts var SVG_NS = "http://www.w3.org/2000/svg"; var HTML_NS = "http://www.w3.org/1999/xhtml"; // src/client/client-host-ref.ts var hostRefs = /* @__PURE__ */ new WeakMap(); var deleteHostRef = (ref) => hostRefs.delete(ref); var getHostRef = (ref) => hostRefs.get(ref); var registerHost = (hostElement, cmpMeta) => { const hostRef = { $flags$: 0, $hostElement$: hostElement, $cmpMeta$: cmpMeta, $instanceValues$: /* @__PURE__ */ new Map() }; { hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r); hostElement["s-p"] = []; hostElement["s-rc"] = []; } const ref = hostRefs.set(hostElement, hostRef); return ref; }; var isMemberInElement = (elm, memberName) => memberName in elm; var consoleError = (e, el) => (0, console.error)(e, el); // src/client/client-style.ts var styles = /* @__PURE__ */ new Map(); var HYDRATED_STYLE_ID = "sty-id"; var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}"; var win = typeof window !== "undefined" ? window : {}; var doc = win.document || { head: {} }; var H = win.HTMLElement || class { }; var plt = { $flags$: 0, $resourcesUrl$: "", jmp: (h2) => h2(), raf: (h2) => requestAnimationFrame(h2), ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts), rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts), ce: (eventName, opts) => new CustomEvent(eventName, opts) }; var promiseResolve = (v) => Promise.resolve(v); var supportsConstructableStylesheets = /* @__PURE__ */ (() => { try { new CSSStyleSheet(); return typeof new CSSStyleSheet().replaceSync === "function"; } catch (e) { } return false; })() ; var queuePending = false; var queueDomReads = []; var queueDomWrites = []; var queueTask = (queue, write) => (cb) => { queue.push(cb); if (!queuePending) { queuePending = true; if (write && plt.$flags$ & 4 /* queueSync */) { nextTick(flush); } else { plt.raf(flush); } } }; var consume = (queue) => { for (let i2 = 0; i2 < queue.length; i2++) { try { queue[i2](performance.now()); } catch (e) { consoleError(e); } } queue.length = 0; }; var flush = () => { consume(queueDomReads); { consume(queueDomWrites); if (queuePending = queueDomReads.length > 0) { plt.raf(flush); } } }; var nextTick = (cb) => promiseResolve().then(cb); var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true); // src/runtime/asset-path.ts var getAssetPath = (path) => { const assetUrl = new URL(path, plt.$resourcesUrl$); return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname; }; var setAssetPath = (path) => plt.$resourcesUrl$ = path; var isComplexType = (o) => { o = typeof o; return o === "object" || o === "function"; }; // src/utils/query-nonce-meta-tag-content.ts function queryNonceMetaTagContent(doc2) { var _a, _b, _c; return (_c = (_b = (_a = doc2.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0; } // src/utils/result.ts var result_exports = {}; __export(result_exports, { err: () => err, map: () => map, ok: () => ok, unwrap: () => unwrap, unwrapErr: () => unwrapErr }); var ok = (value) => ({ isOk: true, isErr: false, value }); var err = (value) => ({ isOk: false, isErr: true, value }); function map(result, fn) { if (result.isOk) { const val = fn(result.value); if (val instanceof Promise) { return val.then((newVal) => ok(newVal)); } else { return ok(val); } } if (result.isErr) { const value = result.value; return err(value); } throw "should never get here"; } var unwrap = (result) => { if (result.isOk) { return result.value; } else { throw result.value; } }; var unwrapErr = (result) => { if (result.isErr) { return result.value; } else { throw result.value; } }; var createTime = (fnName, tagName = "") => { { return () => { return; }; } }; var h = (nodeName, vnodeData, ...children) => { let child = null; let key = null; let simple = false; let lastSimple = false; const vNodeChildren = []; const walk = (c) => { for (let i2 = 0; i2 < c.length; i2++) { child = c[i2]; if (Array.isArray(child)) { walk(child); } else if (child != null && typeof child !== "boolean") { if (simple = typeof nodeName !== "function" && !isComplexType(child)) { child = String(child); } if (simple && lastSimple) { vNodeChildren[vNodeChildren.length - 1].$text$ += child; } else { vNodeChildren.push(simple ? newVNode(null, child) : child); } lastSimple = simple; } } }; walk(children); if (vnodeData) { if (vnodeData.key) { key = vnodeData.key; } { const classData = vnodeData.className || vnodeData.class; if (classData) { vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" "); } } } if (typeof nodeName === "function") { return nodeName( vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils ); } const vnode = newVNode(nodeName, null); vnode.$attrs$ = vnodeData; if (vNodeChildren.length > 0) { vnode.$children$ = vNodeChildren; } { vnode.$key$ = key; } return vnode; }; var newVNode = (tag, text) => { const vnode = { $flags$: 0, $tag$: tag, $text$: text, $elm$: null, $children$: null }; { vnode.$attrs$ = null; } { vnode.$key$ = null; } return vnode; }; var Host = {}; var isHost = (node) => node && node.$tag$ === Host; var vdomFnUtils = { forEach: (children, cb) => children.map(convertToPublic).forEach(cb), map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate) }; var convertToPublic = (node) => ({ vattrs: node.$attrs$, vchildren: node.$children$, vkey: node.$key$, vname: node.$name$, vtag: node.$tag$, vtext: node.$text$ }); var convertToPrivate = (node) => { if (typeof node.vtag === "function") { const vnodeData = { ...node.vattrs }; if (node.vkey) { vnodeData.key = node.vkey; } if (node.vname) { vnodeData.name = node.vname; } return h(node.vtag, vnodeData, ...node.vchildren || []); } const vnode = newVNode(node.vtag, node.vtext); vnode.$attrs$ = node.vattrs; vnode.$children$ = node.vchildren; vnode.$key$ = node.vkey; vnode.$name$ = node.vname; return vnode; }; var parsePropertyValue = (propValue, propType) => { if (propValue != null && !isComplexType(propValue)) { if (propType & 4 /* Boolean */) { return propValue === "false" ? false : propValue === "" || !!propValue; } if (propType & 1 /* String */) { return String(propValue); } return propValue; } return propValue; }; var getElement = (ref) => ref; // src/runtime/event-emitter.ts var createEvent = (ref, name, flags) => { const elm = getElement(ref); return { emit: (detail) => { return emitEvent(elm, name, { bubbles: !!(flags & 4 /* Bubbles */), composed: !!(flags & 2 /* Composed */), cancelable: !!(flags & 1 /* Cancellable */), detail }); } }; }; var emitEvent = (elm, name, opts) => { const ev = plt.ce(name, opts); elm.dispatchEvent(ev); return ev; }; var rootAppliedStyles = /* @__PURE__ */ new WeakMap(); var registerStyle = (scopeId2, cssText, allowCS) => { let style = styles.get(scopeId2); if (supportsConstructableStylesheets && allowCS) { style = style || new CSSStyleSheet(); if (typeof style === "string") { style = cssText; } else { style.replaceSync(cssText); } } else { style = cssText; } styles.set(scopeId2, style); }; var addStyle = (styleContainerNode, cmpMeta, mode) => { var _a; const scopeId2 = getScopeId(cmpMeta); const style = styles.get(scopeId2); styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc; if (style) { if (typeof style === "string") { styleContainerNode = styleContainerNode.head || styleContainerNode; let appliedStyles = rootAppliedStyles.get(styleContainerNode); let styleElm; if (!appliedStyles) { rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set()); } if (!appliedStyles.has(scopeId2)) { { styleElm = document.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`) || doc.createElement("style"); styleElm.innerHTML = style; const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc); if (nonce != null) { styleElm.setAttribute("nonce", nonce); } if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) { if (styleContainerNode.nodeName === "HEAD") { const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]"); const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style"); styleContainerNode.insertBefore( styleElm, (referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null ); } else if ("host" in styleContainerNode) { if (supportsConstructableStylesheets) { const stylesheet = new CSSStyleSheet(); stylesheet.replaceSync(style); styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets]; } else { const existingStyleContainer = styleContainerNode.querySelector("style"); if (existingStyleContainer) { existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML; } else { styleContainerNode.prepend(styleElm); } } } else { styleContainerNode.append(styleElm); } } if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) { styleContainerNode.insertBefore(styleElm, null); } } if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) { styleElm.innerHTML += SLOT_FB_CSS; } if (appliedStyles) { appliedStyles.add(scopeId2); } } } else if (!styleContainerNode.adoptedStyleSheets.includes(style)) { styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style]; } } return scopeId2; }; var attachStyles = (hostRef) => { const cmpMeta = hostRef.$cmpMeta$; const elm = hostRef.$hostElement$; const flags = cmpMeta.$flags$; const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$); const scopeId2 = addStyle( elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta); if ((flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */ || flags & 128 /* shadowNeedsScopedCss */)) { elm["s-sc"] = scopeId2; elm.classList.add(scopeId2 + "-h"); } endAttachStyles(); }; var getScopeId = (cmp, mode) => "sc-" + (cmp.$tagName$); var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => { if (oldValue !== newValue) { let isProp = isMemberInElement(elm, memberName); let ln = memberName.toLowerCase(); if (memberName === "class") { const classList = elm.classList; const oldClasses = parseClassList(oldValue); let newClasses = parseClassList(newValue); { classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c))); classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c))); } } else if (memberName === "style") { { for (const prop in oldValue) { if (!newValue || newValue[prop] == null) { if (prop.includes("-")) { elm.style.removeProperty(prop); } else { elm.style[prop] = ""; } } } } for (const prop in newValue) { if (!oldValue || newValue[prop] !== oldValue[prop]) { if (prop.includes("-")) { elm.style.setProperty(prop, newValue[prop]); } else { elm.style[prop] = newValue[prop]; } } } } else if (memberName === "key") ; else if ((!elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") { if (memberName[2] === "-") { memberName = memberName.slice(3); } else if (isMemberInElement(win, ln)) { memberName = ln.slice(2); } else { memberName = ln[2] + memberName.slice(3); } if (oldValue || newValue) { const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX); memberName = memberName.replace(CAPTURE_EVENT_REGEX, ""); if (oldValue) { plt.rel(elm, memberName, oldValue, capture); } if (newValue) { plt.ael(elm, memberName, newValue, capture); } } } else { const isComplex = isComplexType(newValue); if ((isProp || isComplex && newValue !== null) && !isSvg) { try { if (!elm.tagName.includes("-")) { const n = newValue == null ? "" : newValue; if (memberName === "list") { isProp = false; } else if (oldValue == null || elm[memberName] != n) { if (typeof elm.__lookupSetter__(memberName) === "function") { elm[memberName] = n; } else { elm.setAttribute(memberName, n); } } } else if (elm[memberName] !== newValue) { elm[memberName] = newValue; } } catch (e) { } } if (newValue == null || newValue === false) { if (newValue !== false || elm.getAttribute(memberName) === "") { { elm.removeAttribute(memberName); } } } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) { newValue = newValue === true ? "" : newValue; { elm.setAttribute(memberName, newValue); } } } } }; var parseClassListRegex = /\s/; var parseClassList = (value) => { if (typeof value === "object" && value && "baseVal" in value) { value = value.baseVal; } if (!value || typeof value !== "string") { return []; } return value.split(parseClassListRegex); }; var CAPTURE_EVENT_SUFFIX = "Capture"; var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$"); // src/runtime/vdom/update-element.ts var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => { const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$; const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {}; const newVnodeAttrs = newVnode.$attrs$ || {}; { for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) { if (!(memberName in newVnodeAttrs)) { setAccessor( elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$); } } } for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) { setAccessor( elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$); } }; function sortedAttrNames(attrNames) { return attrNames.includes("ref") ? ( // we need to sort these to ensure that `'ref'` is the last attr [...attrNames.filter((attr) => attr !== "ref"), "ref"] ) : ( // no need to sort, return the original array attrNames ); } var hostTagName; var useNativeShadowDom = false; var isSvgMode = false; var createElm = (oldParentVNode, newParentVNode, childIndex) => { const newVNode2 = newParentVNode.$children$[childIndex]; let i2 = 0; let elm; let childNode; if (newVNode2.$text$ !== null) { elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$); } else { if (!isSvgMode) { isSvgMode = newVNode2.$tag$ === "svg"; } elm = newVNode2.$elm$ = doc.createElementNS( isSvgMode ? SVG_NS : HTML_NS, !useNativeShadowDom && BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$ ) ; if (isSvgMode && newVNode2.$tag$ === "foreignObject") { isSvgMode = false; } { updateElement(null, newVNode2, isSvgMode); } if (newVNode2.$children$) { for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) { childNode = createElm(oldParentVNode, newVNode2, i2); if (childNode) { elm.appendChild(childNode); } } } { if (newVNode2.$tag$ === "svg") { isSvgMode = false; } else if (elm.tagName === "foreignObject") { isSvgMode = true; } } } elm["s-hn"] = hostTagName; return elm; }; var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => { let containerElm = parentElm; let childNode; if (containerElm.shadowRoot && containerElm.tagName === hostTagName) { containerElm = containerElm.shadowRoot; } for (; startIdx <= endIdx; ++startIdx) { if (vnodes[startIdx]) { childNode = createElm(null, parentVNode, startIdx); if (childNode) { vnodes[startIdx].$elm$ = childNode; insertBefore(containerElm, childNode, before); } } } }; var removeVnodes = (vnodes, startIdx, endIdx) => { for (let index = startIdx; index <= endIdx; ++index) { const vnode = vnodes[index]; if (vnode) { const elm = vnode.$elm$; if (elm) { elm.remove(); } } } }; var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => { let oldStartIdx = 0; let newStartIdx = 0; let idxInOld = 0; let i2 = 0; let oldEndIdx = oldCh.length - 1; let oldStartVnode = oldCh[0]; let oldEndVnode = oldCh[oldEndIdx]; let newEndIdx = newCh.length - 1; let newStartVnode = newCh[0]; let newEndVnode = newCh[newEndIdx]; let node; let elmToMove; while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) { if (oldStartVnode == null) { oldStartVnode = oldCh[++oldStartIdx]; } else if (oldEndVnode == null) { oldEndVnode = oldCh[--oldEndIdx]; } else if (newStartVnode == null) { newStartVnode = newCh[++newStartIdx]; } else if (newEndVnode == null) { newEndVnode = newCh[--newEndIdx]; } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) { patch(oldStartVnode, newStartVnode, isInitialRender); oldStartVnode = oldCh[++oldStartIdx]; newStartVnode = newCh[++newStartIdx]; } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) { patch(oldEndVnode, newEndVnode, isInitialRender); oldEndVnode = oldCh[--oldEndIdx]; newEndVnode = newCh[--newEndIdx]; } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) { patch(oldStartVnode, newEndVnode, isInitialRender); insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling); oldStartVnode = oldCh[++oldStartIdx]; newEndVnode = newCh[--newEndIdx]; } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) { patch(oldEndVnode, newStartVnode, isInitialRender); insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$); oldEndVnode = oldCh[--oldEndIdx]; newStartVnode = newCh[++newStartIdx]; } else { idxInOld = -1; { for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) { if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) { idxInOld = i2; break; } } } if (idxInOld >= 0) { elmToMove = oldCh[idxInOld]; if (elmToMove.$tag$ !== newStartVnode.$tag$) { node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld); } else { patch(elmToMove, newStartVnode, isInitialRender); oldCh[idxInOld] = void 0; node = elmToMove.$elm$; } newStartVnode = newCh[++newStartIdx]; } else { node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx); newStartVnode = newCh[++newStartIdx]; } if (node) { { insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$); } } } } if (oldStartIdx > oldEndIdx) { addVnodes( parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode2, newCh, newStartIdx, newEndIdx ); } else if (newStartIdx > newEndIdx) { removeVnodes(oldCh, oldStartIdx, oldEndIdx); } }; var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => { if (leftVNode.$tag$ === rightVNode.$tag$) { if (!isInitialRender) { return leftVNode.$key$ === rightVNode.$key$; } if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) { leftVNode.$key$ = rightVNode.$key$; } return true; } return false; }; var patch = (oldVNode, newVNode2, isInitialRender = false) => { const elm = newVNode2.$elm$ = oldVNode.$elm$; const oldChildren = oldVNode.$children$; const newChildren = newVNode2.$children$; const tag = newVNode2.$tag$; const text = newVNode2.$text$; if (text === null) { { isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode; } { { updateElement(oldVNode, newVNode2, isSvgMode); } } if (oldChildren !== null && newChildren !== null) { updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender); } else if (newChildren !== null) { if (oldVNode.$text$ !== null) { elm.textContent = ""; } addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1); } else if ( // don't do this on initial render as it can cause non-hydrated content to be removed !isInitialRender && BUILD.updatable && oldChildren !== null ) { removeVnodes(oldChildren, 0, oldChildren.length - 1); } if (isSvgMode && tag === "svg") { isSvgMode = false; } } else if (oldVNode.$text$ !== text) { elm.data = text; } }; var insertBefore = (parent, newNode, reference) => { { return parent == null ? void 0 : parent.insertBefore(newNode, reference); } }; var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => { const hostElm = hostRef.$hostElement$; const cmpMeta = hostRef.$cmpMeta$; const oldVNode = hostRef.$vnode$ || newVNode(null, null); const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults); hostTagName = hostElm.tagName; if (cmpMeta.$attrsToReflect$) { rootVnode.$attrs$ = rootVnode.$attrs$ || {}; cmpMeta.$attrsToReflect$.map( ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName] ); } if (isInitialLoad && rootVnode.$attrs$) { for (const key of Object.keys(rootVnode.$attrs$)) { if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) { rootVnode.$attrs$[key] = hostElm[key]; } } } rootVnode.$tag$ = null; rootVnode.$flags$ |= 4 /* isHost */; hostRef.$vnode$ = rootVnode; rootVnode.$elm$ = oldVNode.$elm$ = hostElm.shadowRoot || hostElm ; useNativeShadowDom = !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) && !(cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */); patch(oldVNode, rootVnode, isInitialLoad); }; // src/runtime/update-component.ts var attachToAncestor = (hostRef, ancestorComponent) => { if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) { const index = ancestorComponent["s-p"].push( new Promise( (r) => hostRef.$onRenderResolve$ = () => { ancestorComponent["s-p"].splice(index - 1, 1); r(); } ) ); } }; var scheduleUpdate = (hostRef, isInitialLoad) => { { hostRef.$flags$ |= 16 /* isQueuedForUpdate */; } if (hostRef.$flags$ & 4 /* isWaitingForChildren */) { hostRef.$flags$ |= 512 /* needsRerender */; return; } attachToAncestor(hostRef, hostRef.$ancestorComponent$); const dispatch = () => dispatchHooks(hostRef, isInitialLoad); return writeTask(dispatch) ; }; var dispatchHooks = (hostRef, isInitialLoad) => { const elm = hostRef.$hostElement$; const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$); const instance = elm; if (!instance) { throw new Error( `Can't render component <${elm.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime` ); } let maybePromise; if (isInitialLoad) { { maybePromise = safeCall(instance, "componentWillLoad", void 0, elm); } } endSchedule(); return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad)); }; var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn).catch((err2) => { console.error(err2); fn(); }) : fn(); var isPromisey = (maybePromise) => maybePromise instanceof Promise || maybePromise && maybePromise.then && typeof maybePromise.then === "function"; var updateComponent = async (hostRef, instance, isInitialLoad) => { var _a; const elm = hostRef.$hostElement$; const endUpdate = createTime("update", hostRef.$cmpMeta$.$tagName$); const rc = elm["s-rc"]; if (isInitialLoad) { attachStyles(hostRef); } const endRender = createTime("render", hostRef.$cmpMeta$.$tagName$); { callRender(hostRef, instance, elm, isInitialLoad); } if (rc) { rc.map((cb) => cb()); elm["s-rc"] = void 0; } endRender(); endUpdate(); { const childrenPromises = (_a = elm["s-p"]) != null ? _a : []; const postUpdate = () => postUpdateComponent(hostRef); if (childrenPromises.length === 0) { postUpdate(); } else { Promise.all(childrenPromises).then(postUpdate); hostRef.$flags$ |= 4 /* isWaitingForChildren */; childrenPromises.length = 0; } } }; var callRender = (hostRef, instance, elm, isInitialLoad) => { try { instance = instance.render() ; { hostRef.$flags$ &= ~16 /* isQueuedForUpdate */; } { hostRef.$flags$ |= 2 /* hasRendered */; } { { { renderVdom(hostRef, instance, isInitialLoad); } } } } catch (e) { consoleError(e, hostRef.$hostElement$); } return null; }; var postUpdateComponent = (hostRef) => { const tagName = hostRef.$cmpMeta$.$tagName$; const elm = hostRef.$hostElement$; const endPostUpdate = createTime("postUpdate", tagName); const ancestorComponent = hostRef.$ancestorComponent$; if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) { hostRef.$flags$ |= 64 /* hasLoadedComponent */; { addHydratedFlag(elm); } endPostUpdate(); { hostRef.$onReadyResolve$(elm); if (!ancestorComponent) { appDidLoad(); } } } else { endPostUpdate(); } { if (hostRef.$onRenderResolve$) { hostRef.$onRenderResolve$(); hostRef.$onRenderResolve$ = void 0; } if (hostRef.$flags$ & 512 /* needsRerender */) { nextTick(() => scheduleUpdate(hostRef, false)); } hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */); } }; var appDidLoad = (who) => { nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } })); }; var safeCall = (instance, method, arg, elm) => { if (instance && instance[method]) { try { return instance[method](arg); } catch (e) { consoleError(e, elm); } } return void 0; }; var addHydratedFlag = (elm) => { var _a; return elm.classList.add((_a = BUILD.hydratedSelectorName) != null ? _a : "hydrated") ; }; // src/runtime/set-value.ts var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName); var setValue = (ref, propName, newVal, cmpMeta) => { const hostRef = getHostRef(ref); const elm = ref; const oldVal = hostRef.$instanceValues$.get(propName); const flags = hostRef.$flags$; const instance = elm; newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]); const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal); const didValueChange = newVal !== oldVal && !areBothNaN; if (didValueChange) { hostRef.$instanceValues$.set(propName, newVal); { if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) { const watchMethods = cmpMeta.$watchers$[propName]; if (watchMethods) { watchMethods.map((watchMethodName) => { try { instance[watchMethodName](newVal, oldVal, propName); } catch (e) { consoleError(e, elm); } }); } } if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) { scheduleUpdate(hostRef, false); } } } }; // src/runtime/proxy-component.ts var proxyComponent = (Cstr, cmpMeta, flags) => { var _a, _b; const prototype = Cstr.prototype; if (cmpMeta.$members$ || (cmpMeta.$watchers$ || Cstr.watchers)) { if (Cstr.watchers && !cmpMeta.$watchers$) { cmpMeta.$watchers$ = Cstr.watchers; } const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {}); members.map(([memberName, [memberFlags]]) => { if ((memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) { const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(prototype, memberName) || {}; if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */; if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */; if (flags & 1 /* isElementConstructor */ || !origGetter) { Object.defineProperty(prototype, memberName, { get() { { return origGetter ? origGetter.apply(this) : getValue(this, memberName); } }, configurable: true, enumerable: true }); } Object.defineProperty(prototype, memberName, { set(newValue) { const ref = getHostRef(this); if (origSetter) { const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName]; if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) { newValue = ref.$instanceValues$.get(memberName); } else if (!ref.$instanceValues$.get(memberName) && currentValue) { ref.$instanceValues$.set(memberName, currentValue); } origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]); newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName]; setValue(this, memberName, newValue, cmpMeta); return; } { setValue(this, memberName, newValue, cmpMeta); return; } } }); } }); { const attrNameToPropName = /* @__PURE__ */ new Map(); prototype.attributeChangedCallback = function(attrName, oldValue, newValue) { plt.jmp(() => { var _a2; const propName = attrNameToPropName.get(attrName); if (this.hasOwnProperty(propName) && BUILD.lazyLoad) { newValue = this[propName]; delete this[propName]; } else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && // cast type to number to avoid TS compiler issues this[propName] == newValue) { return; } else if (propName == null) { const hostRef = getHostRef(this); const flags2 = hostRef == null ? void 0 : hostRef.$flags$; if (flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) { const elm = this; const instance = elm; const entry = (_a2 = cmpMeta.$watchers$) == null ? void 0 : _a2[attrName]; entry == null ? void 0 : entry.forEach((callbackName) => { if (instance[callbackName] != null) { instance[callbackName].call(instance, newValue, oldValue, attrName); } }); } return; } const propDesc = Object.getOwnPropertyDescriptor(prototype, propName); newValue = newValue === null && typeof this[propName] === "boolean" ? false : newValue; if (newValue !== this[propName] && (!propDesc.get || !!propDesc.set)) { this[propName] = newValue; } }); }; Cstr.observedAttributes = Array.from( /* @__PURE__ */ new Set([ ...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}), ...members.filter(([_, m]) => m[0] & 15 /* HasAttribute */).map(([propName, m]) => { var _a2; const attrName = m[1] || propName; attrNameToPropName.set(attrName, propName); if (m[0] & 512 /* ReflectAttr */) { (_a2 = cmpMeta.$attrsToReflect$) == null ? void 0 : _a2.push([propName, attrName]); } return attrName; }) ]) ); } } return Cstr; }; // src/runtime/initialize-component.ts var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => { let Cstr; if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) { hostRef.$flags$ |= 32 /* hasInitializedComponent */; { Cstr = elm.constructor; const cmpTag = elm.localName; customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= 128 /* isWatchReady */); } if (Cstr && Cstr.style) { let style; if (typeof Cstr.style === "string") { style = Cstr.style; } const scopeId2 = getScopeId(cmpMeta); if (!styles.has(scopeId2)) { const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$); registerStyle(scopeId2, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)); endRegisterStyles(); } } } const ancestorComponent = hostRef.$ancestorComponent$; const schedule = () => scheduleUpdate(hostRef, true); if (ancestorComponent && ancestorComponent["s-rc"]) { ancestorComponent["s-rc"].push(schedule); } else { schedule(); } }; var fireConnectedCallback = (instance, elm) => { }; // src/runtime/connected-callback.ts var connectedCallback = (elm) => { if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) { const hostRef = getHostRef(elm); const cmpMeta = hostRef.$cmpMeta$; const endConnected = createTime("connectedCallback", cmpMeta.$tagName$); if (!(hostRef.$flags$ & 1 /* hasConnected */)) { hostRef.$flags$ |= 1 /* hasConnected */; { let ancestorComponent = elm; while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) { if (ancestorComponent["s-p"]) { attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent); break; } } } if (cmpMeta.$members$) { Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => { if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) { const value = elm[memberName]; delete elm[memberName]; elm[memberName] = value; } }); } { initializeComponent(elm, hostRef, cmpMeta); } } else { if (hostRef == null ? void 0 : hostRef.$lazyInstance$) ; else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) { hostRef.$onReadyPromise$.then(() => fireConnectedCallback()); } } endConnected(); } }; var disconnectedCallback = async (elm) => { if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) { getHostRef(elm); } if (rootAppliedStyles.has(elm)) { rootAppliedStyles.delete(elm); } if (elm.shadowRoot && rootAppliedStyles.has(elm.shadowRoot)) { rootAppliedStyles.delete(elm.shadowRoot); } }; var proxyCustomElement = (Cstr, compactMeta) => { const cmpMeta = { $flags$: compactMeta[0], $tagName$: compactMeta[1] }; { cmpMeta.$members$ = compactMeta[2]; } { cmpMeta.$watchers$ = Cstr.$watchers$; } { cmpMeta.$attrsToReflect$ = []; } Object.assign(Cstr.prototype, { __hasHostListenerAttached: false, __registerHost() { registerHost(this, cmpMeta); }, connectedCallback() { if (!this.__hasHostListenerAttached) { getHostRef(this); this.__hasHostListenerAttached = true; } connectedCallback(this); }, disconnectedCallback() { disconnectedCallback(this); plt.raf(() => { var _a; const hostRef = getHostRef(this); if (((_a = hostRef == null ? void 0 : hostRef.$vnode$) == null ? void 0 : _a.$elm$) instanceof Node && !hostRef.$vnode$.$elm$.isConnected) { delete hostRef.$vnode$; } if (this instanceof Node && !this.isConnected) { deleteHostRef(this); } }); }, __attachShadow() { { if (!this.shadowRoot) { { this.attachShadow({ mode: "open" }); } } else { if (this.shadowRoot.mode !== "open") { throw new Error( `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.` ); } } } } }); Cstr.is = cmpMeta.$tagName$; return proxyComponent(Cstr, cmpMeta, 1 /* isElementConstructor */ | 2 /* proxyState */); }; // src/runtime/nonce.ts var setNonce = (nonce) => plt.$nonce$ = nonce; // src/runtime/platform-options.ts var setPlatformOptions = (opts) => Object.assign(plt, opts); class ApiService { static async verifyUser(config, body, signal) { const url = `${config.trustcaptchaApi}/verifications?siteKey=${config.sitekey}`; return await this.post(url, body, signal); } static async sendSolutions(config, verificationId, startSolvingTimestamp, solvedTimestamp, tasks, honeypotField, userEvents, signal) { const url = `${config.trustcaptchaApi}/verifications/${verificationId}/challenges`; const body = { startSolvingTimestamp, solvedTimestamp, tasks, honeypotField, userEvents }; return await this.post(url, body, signal); } static async post(url = '', body = {}, signal) { return await fetch(url, { method: 'POST', mode: 'cors', cache: 'no-cache', credentials: 'same-origin', headers: { 'Content-Type': 'application/json' }, redirect: 'follow', referrerPolicy: 'no-referrer', body: JSON.stringify(body), signal, }); } } const powWorkerScript = ` var __awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{c(r.next(e))}catch(e){o(e)}}function u(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,u)}c((r=r.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){i.label=u[1];break}if(6===u[0]&&i.label<a[1]){i.label=a[1],a=u;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(u);break}a[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},_this=this;function base64ToArrayBuffer(e){for(var t=self.atob(e),n=t.length,r=new Uint8Array(n),a=0;a<n;a++)r[a]=t.charCodeAt(a);return r.buffer}function appendBuffer(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}function countLeadingZeroBits(e){var t=new Uint8Array(e),n=t.findIndex((function(e){return 0!==e}));return-1===n?8*t.length:8*n+(Math.clz32(t[n])-24)}function executePowTask(e,t){return __awaiter(this,void 0,void 0,(function(){var n,r,a,o;return __generator(this,(function(i){switch(i.label){case 0:n=base64ToArrayBuffer(e.input),r=0,i.label=1;case 1:return a="tcn".concat(r),o=appendBuffer(n,(new TextEncoder).encode(a).buffer),[4,crypto.subtle.digest("SHA-256",o)];case 2:return countLeadingZeroBits(i.sent())===t?[2,{number:e.number,nonce:a}]:(r++,[3,1]);case 3:return[2]}}))}))}self.addEventListener("message",(function(e){return __awaiter(_this,void 0,void 0,(function(){var t,n,r,a;return __generator(this,(function(o){switch(o.label){case 0:return t=e.data,n=t.task,r=t.difficulty,a=postMessage,[4,executePowTask(n,r)];case 1:return a.apply(void 0,[o.sent()]),[2]}}))}))})); `; class WorkerPool { constructor() { this.queue = []; this.activeTasks = 0; this.workers = []; this.isReset = false; const blob = new Blob([powWorkerScript], { type: "application/javascript" }); this.objectUrl = URL.createObjectURL(blob); this.maxWorkers = Math.min(Math.max(4, navigator.hardwareConcurrency || 4), 10); } enqueue(task, difficulty) { return new Promise((resolve, reject) => { if (this.isReset) { reject(new Error("WorkerPool has been reset")); return; } this.queue.push({ task, difficulty, resolve, reject }); this.processQueue(); }); } processQueue() { if (this.queue.length === 0 || this.activeTasks >= this.maxWorkers || this.isReset) { return; } const { task, difficulty, resolve, reject } = this.queue.shift(); this.activeTasks++; const worker = new Worker(this.objectUrl); this.workers.push(worker); worker.postMessage({ task, difficulty }); worker.onmessage = (event) => { if (this.isReset) { reject(new Error("WorkerPool has been reset")); } else { resolve(event.data); } this.activeTasks--; this.workers.splice(this.workers.indexOf(worker), 1); worker.terminate(); this.processQueue(); }; worker.onerror = () => { if (!this.isReset) { reject(new Error("Worker error")); } else { reject(new Error("WorkerPool has been reset")); } this.activeTasks--; this.workers.splice(this.workers.indexOf(worker), 1); worker.terminate(); this.processQueue(); }; } reset() { this.isReset = true; // Terminate all active workers for (const worker of this.workers) { worker.terminate(); } this.workers = []; // Clear the queue this.queue = []; } } class PowSolver { constructor() { this.workerPool = new WorkerPool(); } async solveTasks(userResponseDto) { const promises = userResponseDto.challenge.tasks.map(task => this.workerPool.enqueue(task, userResponseDto.challenge.difficulty)); return Promise.all(promises); } reset() { this.workerPool.reset(); } } const VERSION = '2.1.1'; class InformationCollector { constructor(box) { this.box = box; } async collectInformation() { const browserInformation = await this.collectProperties(this.box.config.mode === 'minimal' ? this.minimalPropertiesToCollect() : this.standardPropertiesToCollect()); let userEvents = []; if (this.box.config.mode === 'standard') { userEvents = this.box.eventTracker.getEventsAndResetArray(); } return { custom: { boxCreationTimestamp: this.box.boxCreationTimestamp, startSolvingTimestamp: new Date(), timezone: this.getTimezone(), honeypotField: this.box.honeypotField.value, framework: this.safeGet(() => this.detectFrontendFramework()), version: VERSION, bypassToken: this.box.config.bypassToken, mode: this.getMode(), boxSettings: { language: this.box.config.language, currentLanguage: this.box.config.translation.language, theme: this.box.config.theme, currentTheme: this.box.config.currentTheme, autostart: this.box.config.autostart, mode: this.box.config.mode, hideBranding: this.box.config.hideBranding, customPrivacy: this.box.config.privacyUrl !== undefined, invisible: this.box.config.invisible, } }, browserInformation: browserInformation, userEvents: userEvents, }; } getTimezone() { var _a; const DateTimeFormat = (_a = window.Intl) === null || _a === void 0 ? void 0 : _a.DateTimeFormat; if (DateTimeFormat) { const timezone = new DateTimeFormat().resolvedOptions().timeZone; if (timezone) { return timezone; } } const offset = -this.getTimezoneOffset(); return `UTC${offset >= 0 ? '+' : ''}${Math.abs(offset)}`; } getTimezoneOffset() { const currentYear = new Date().getFullYear(); return Math.max(this.toFloat(new Date(currentYear, 0, 1).getTimezoneOffset()), this.toFloat(new Date(currentYear, 6, 1).getTimezoneOffset())); } toFloat(value) { return parseFloat(value); } getMode() { return this.box.config.mode === 'minimal' ? 'MINIMAL_DATA' : 'STANDARD'; } minimalPropertiesToCollect() { return [ 'devicePixelRatio', 'navigator.connection.downlink', 'navigator.connection.effectiveType', 'navigator.connection.rtt', 'navigator.connection.saveData', 'location.href', 'navigator.cookieEnabled',