UNPKG

@microblink/blinkid-in-browser-sdk

Version:

A simple ID scanning library for WebAssembly-enabled browsers.

2 lines 9.91 kB
let t,e,n=!1,l=!1;const o="http://www.w3.org/1999/xlink",s={},c=t=>"object"==(t=typeof t)||"function"===t;function i(t){var e,n,l;return null!==(l=null===(n=null===(e=t.head)||void 0===e?void 0:e.querySelector('meta[name="csp-nonce"]'))||void 0===n?void 0:n.getAttribute("content"))&&void 0!==l?l:void 0}const r=(t,e,...n)=>{let l=null,o=!1,s=!1;const i=[],r=e=>{for(let n=0;n<e.length;n++)l=e[n],Array.isArray(l)?r(l):null!=l&&"boolean"!=typeof l&&((o="function"!=typeof t&&!c(l))&&(l+=""),o&&s?i[i.length-1].t+=l:i.push(o?a(null,l):l),s=o)};if(r(n),e){const t=e.className||e.class;t&&(e.class="object"!=typeof t?t:Object.keys(t).filter((e=>t[e])).join(" "))}if("function"==typeof t)return t(null===e?{}:e,i,f);const u=a(t,null);return u.l=e,i.length>0&&(u.o=i),u},a=(t,e)=>({i:0,u:t,t:e,p:null,o:null,l:null}),u={},f={forEach:(t,e)=>t.map(d).forEach(e),map:(t,e)=>t.map(d).map(e).map(p)},d=t=>({vattrs:t.l,vchildren:t.o,vkey:t.h,vname:t.m,vtag:t.u,vtext:t.t}),p=t=>{if("function"==typeof t.vtag){const e=Object.assign({},t.vattrs);return t.vkey&&(e.key=t.vkey),t.vname&&(e.name=t.vname),r(t.vtag,e,...t.vchildren||[])}const e=a(t.vtag,t.vtext);return e.l=t.vattrs,e.o=t.vchildren,e.h=t.vkey,e.m=t.vname,e},h=t=>J(t).$,m=(t,e,n)=>{const l=h(t);return{emit:t=>y(l,e,{bubbles:!!(4&n),composed:!!(2&n),cancelable:!!(1&n),detail:t})}},y=(t,e,n)=>{const l=ot.ce(e,n);return t.dispatchEvent(l),l},b=new WeakMap,w=t=>"sc-"+t.v,$=(t,e,n,l,s,i)=>{if(n!==l){let r=X(t,e),a=e.toLowerCase();if("class"===e){const e=t.classList,o=g(n),s=g(l);e.remove(...o.filter((t=>t&&!s.includes(t)))),e.add(...s.filter((t=>t&&!o.includes(t))))}else if("ref"===e)l&&l(t);else if(r||"o"!==e[0]||"n"!==e[1]){const u=c(l);if((r||u&&null!==l)&&!s)try{if(t.tagName.includes("-"))t[e]=l;else{const o=null==l?"":l;"list"===e?r=!1:null!=n&&t[e]==o||(t[e]=o)}}catch(t){}let f=!1;a!==(a=a.replace(/^xlink\:?/,""))&&(e=a,f=!0),null==l||!1===l?!1===l&&""!==t.getAttribute(e)||(f?t.removeAttributeNS(o,e):t.removeAttribute(e)):(!r||4&i||s)&&!u&&(l=!0===l?"":l,f?t.setAttributeNS(o,e,l):t.setAttribute(e,l))}else e="-"===e[2]?e.slice(3):X(nt,a)?a.slice(2):a[2]+e.slice(3),n&&ot.rel(t,e,n,!1),l&&ot.ael(t,e,l,!1)}},v=/\s/,g=t=>t?t.split(v):[],j=(t,e,n,l)=>{const o=11===e.p.nodeType&&e.p.host?e.p.host:e.p,c=t&&t.l||s,i=e.l||s;for(l in c)l in i||$(o,l,c[l],void 0,n,e.i);for(l in i)$(o,l,c[l],i[l],n,e.i)},S=(e,l,o)=>{const s=l.o[o];let c,i,r=0;if(null!==s.t)c=s.p=lt.createTextNode(s.t);else{if(n||(n="svg"===s.u),c=s.p=lt.createElementNS(n?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",s.u),n&&"foreignObject"===s.u&&(n=!1),j(null,s,n),null!=t&&c["s-si"]!==t&&c.classList.add(c["s-si"]=t),s.o)for(r=0;r<s.o.length;++r)i=S(e,s,r),i&&c.appendChild(i);"svg"===s.u?n=!1:"foreignObject"===c.tagName&&(n=!0)}return c},k=(t,n,l,o,s,c)=>{let i,r=t;for(r.shadowRoot&&r.tagName===e&&(r=r.shadowRoot);s<=c;++s)o[s]&&(i=S(null,l,s),i&&(o[s].p=i,r.insertBefore(i,n)))},O=(t,e,n,l,o)=>{for(;e<=n;++e)(l=t[e])&&(o=l.p,x(l),o.remove())},C=(t,e)=>t.u===e.u,M=(t,e)=>{const l=e.p=t.p,o=t.o,s=e.o,c=e.u,i=e.t;null===i?(n="svg"===c||"foreignObject"!==c&&n,"slot"===c||j(t,e,n),null!==o&&null!==s?((t,e,n,l)=>{let o,s=0,c=0,i=e.length-1,r=e[0],a=e[i],u=l.length-1,f=l[0],d=l[u];for(;s<=i&&c<=u;)null==r?r=e[++s]:null==a?a=e[--i]:null==f?f=l[++c]:null==d?d=l[--u]:C(r,f)?(M(r,f),r=e[++s],f=l[++c]):C(a,d)?(M(a,d),a=e[--i],d=l[--u]):C(r,d)?(M(r,d),t.insertBefore(r.p,a.p.nextSibling),r=e[++s],d=l[--u]):C(a,f)?(M(a,f),t.insertBefore(a.p,r.p),a=e[--i],f=l[++c]):(o=S(e&&e[c],n,c),f=l[++c],o&&r.p.parentNode.insertBefore(o,r.p));s>i?k(t,null==l[u+1]?null:l[u+1].p,n,l,c,u):c>u&&O(e,s,i)})(l,o,e,s):null!==s?(null!==t.t&&(l.textContent=""),k(l,null,e,s,0,s.length-1)):null!==o&&O(o,0,o.length-1),n&&"svg"===c&&(n=!1)):t.t!==i&&(l.data=i)},x=t=>{t.l&&t.l.ref&&t.l.ref(null),t.o&&t.o.map(x)},P=(t,e)=>{e&&!t.g&&e["s-p"]&&e["s-p"].push(new Promise((e=>t.g=e)))},E=(t,e)=>{if(t.i|=16,!(4&t.i))return P(t,t.j),pt((()=>L(t,e)));t.i|=512},L=(t,e)=>{const n=t.S;let l;return e?(t.i|=256,t.k&&(t.k.map((([t,e])=>R(n,t,e))),t.k=null),l=R(n,"componentWillLoad")):l=R(n,"componentWillUpdate"),T(l,(()=>U(t,n,e)))},U=async(t,e,n)=>{const l=t.$,o=l["s-rc"];n&&(t=>{const e=t.O,n=t.$,l=e.i,o=((t,e)=>{var n;let l=w(e);const o=et.get(l);if(t=11===t.nodeType?t:lt,o)if("string"==typeof o){let e,s=b.get(t=t.head||t);if(s||b.set(t,s=new Set),!s.has(l)){{e=lt.createElement("style"),e.innerHTML=o;const l=null!==(n=ot.C)&&void 0!==n?n:i(lt);null!=l&&e.setAttribute("nonce",l),t.insertBefore(e,t.querySelector("link"))}s&&s.add(l)}}else t.adoptedStyleSheets.includes(o)||(t.adoptedStyleSheets=[...t.adoptedStyleSheets,o]);return l})(n.shadowRoot?n.shadowRoot:n.getRootNode(),e);10&l&&(n["s-sc"]=o,n.classList.add(o+"-h"))})(t);W(t,e),o&&(o.map((t=>t())),l["s-rc"]=void 0);{const e=l["s-p"],n=()=>D(t);0===e.length?n():(Promise.all(e).then(n),t.i|=4,e.length=0)}},W=(n,l)=>{try{l=l.render(),n.i&=-17,n.i|=2,((n,l)=>{const o=n.$,s=n.M||a(null,null),c=(t=>t&&t.u===u)(l)?l:r(null,null,l);e=o.tagName,c.u=null,c.i|=4,n.M=c,c.p=s.p=o.shadowRoot||o,t=o["s-sc"],M(s,c)})(n,l)}catch(t){Y(t,n.$)}return null},D=t=>{const e=t.$,n=t.S,l=t.j;R(n,"componentDidRender"),64&t.i?R(n,"componentDidUpdate"):(t.i|=64,A(e),R(n,"componentDidLoad"),t.P(e),l||N()),t.L(e),t.g&&(t.g(),t.g=void 0),512&t.i&&dt((()=>E(t,!1))),t.i&=-517},N=()=>{A(lt.documentElement),dt((()=>y(nt,"appload",{detail:{namespace:"blinkid-in-browser"}})))},R=(t,e,n)=>{if(t&&t[e])try{return t[e](n)}catch(t){Y(t)}},T=(t,e)=>t&&t.then?t.then(e):e(),A=t=>t.classList.add("hydrated"),F=(t,e,n)=>{if(e.U){t.watchers&&(e.W=t.watchers);const l=Object.entries(e.U),o=t.prototype;if(l.map((([t,[l]])=>{31&l||2&n&&32&l?Object.defineProperty(o,t,{get(){return((t,e)=>J(this).D.get(e))(0,t)},set(n){((t,e,n,l)=>{const o=J(t),s=o.$,i=o.D.get(e),r=o.i,a=o.S;if(n=((t,e)=>null==t||c(t)?t:4&e?"false"!==t&&(""===t||!!t):2&e?parseFloat(t):1&e?t+"":t)(n,l.U[e][0]),(!(8&r)||void 0===i)&&n!==i&&(!Number.isNaN(i)||!Number.isNaN(n))&&(o.D.set(e,n),a)){if(l.W&&128&r){const t=l.W[e];t&&t.map((t=>{try{a[t](n,i,e)}catch(t){Y(t,s)}}))}2==(18&r)&&E(o,!1)}})(this,t,n,e)},configurable:!0,enumerable:!0}):1&n&&64&l&&Object.defineProperty(o,t,{value(...e){const n=J(this);return n.N.then((()=>n.S[t](...e)))}})})),1&n){const e=new Map;o.attributeChangedCallback=function(t,n,l){ot.jmp((()=>{const n=e.get(t);if(this.hasOwnProperty(n))l=this[n],delete this[n];else if(o.hasOwnProperty(n)&&"number"==typeof this[n]&&this[n]==l)return;this[n]=(null!==l||"boolean"!=typeof this[n])&&l}))},t.observedAttributes=l.filter((([t,e])=>15&e[0])).map((([t,n])=>{const l=n[1]||t;return e.set(l,t),l}))}}return t},H=t=>{R(t,"connectedCallback")},q=(t,e={})=>{var n;const l=[],o=e.exclude||[],s=nt.customElements,c=lt.head,r=c.querySelector("meta[charset]"),a=lt.createElement("style"),u=[];let f,d=!0;Object.assign(ot,e),ot.R=new URL(e.resourcesUrl||"./",lt.baseURI).href,t.map((t=>{t[1].map((e=>{const n={i:e[0],v:e[1],U:e[2],T:e[3]};n.U=e[2],n.T=e[3],n.W={};const c=n.v,i=class extends HTMLElement{constructor(t){super(t),Q(t=this,n),1&n.i&&t.attachShadow({mode:"open"})}connectedCallback(){f&&(clearTimeout(f),f=null),d?u.push(this):ot.jmp((()=>(t=>{if(0==(1&ot.i)){const e=J(t),n=e.O,l=()=>{};if(1&e.i)V(t,e,n.T),H(e.S);else{e.i|=1;{let n=t;for(;n=n.parentNode||n.host;)if(n["s-p"]){P(e,e.j=n);break}}n.U&&Object.entries(n.U).map((([e,[n]])=>{if(31&n&&t.hasOwnProperty(e)){const n=t[e];delete t[e],t[e]=n}})),(async(t,e,n,l,o)=>{if(0==(32&e.i)){{if(e.i|=32,(o=tt(n)).then){const t=()=>{};o=await o,t()}o.isProxied||(n.W=o.watchers,F(o,n,2),o.isProxied=!0);const t=()=>{};e.i|=8;try{new o(e)}catch(t){Y(t)}e.i&=-9,e.i|=128,t(),H(e.S)}if(o.style){let t=o.style;const e=w(n);if(!et.has(e)){const l=()=>{};((t,e,n)=>{let l=et.get(t);ct&&n?(l=l||new CSSStyleSheet,"string"==typeof l?l=e:l.replaceSync(e)):l=e,et.set(t,l)})(e,t,!!(1&n.i)),l()}}}const s=e.j,c=()=>E(e,!0);s&&s["s-rc"]?s["s-rc"].push(c):c()})(0,e,n)}l()}})(this)))}disconnectedCallback(){ot.jmp((()=>(()=>{if(0==(1&ot.i)){const t=J(this),e=t.S;t.A&&(t.A.map((t=>t())),t.A=void 0),R(e,"disconnectedCallback")}})()))}componentOnReady(){return J(this).F}};n.H=t[0],o.includes(c)||s.get(c)||(l.push(c),s.define(c,F(i,n,1)))}))}));{a.innerHTML=l+"{visibility:hidden}.hydrated{visibility:inherit}",a.setAttribute("data-styles","");const t=null!==(n=ot.C)&&void 0!==n?n:i(lt);null!=t&&a.setAttribute("nonce",t),c.insertBefore(a,r?r.nextSibling:c.firstChild)}d=!1,u.length?u.map((t=>t.connectedCallback())):ot.jmp((()=>f=setTimeout(N,30)))},V=(t,e,n)=>{n&&n.map((([n,l,o])=>{const s=z(t,n),c=_(e,o),i=B(n);ot.ael(s,l,c,i),(e.A=e.A||[]).push((()=>ot.rel(s,l,c,i)))}))},_=(t,e)=>n=>{try{256&t.i?t.S[e](n):(t.k=t.k||[]).push([e,n])}catch(t){Y(t)}},z=(t,e)=>8&e?nt:t,B=t=>0!=(2&t),G=t=>ot.C=t,I=new WeakMap,J=t=>I.get(t),K=(t,e)=>I.set(e.S=t,e),Q=(t,e)=>{const n={i:0,$:t,O:e,D:new Map};return n.N=new Promise((t=>n.L=t)),n.F=new Promise((t=>n.P=t)),t["s-p"]=[],t["s-rc"]=[],V(t,n,e.T),I.set(t,n)},X=(t,e)=>e in t,Y=(t,e)=>(0,console.error)(t,e),Z=new Map,tt=t=>{const e=t.v.replace(/-/g,"_"),n=t.H,l=Z.get(n);return l?l[e]:import(`./${n}.entry.js`).then((t=>(Z.set(n,t),t[e])),Y) /*!__STENCIL_STATIC_IMPORT_SWITCH__*/},et=new Map,nt="undefined"!=typeof window?window:{},lt=nt.document||{head:{}},ot={i:0,R:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,l)=>t.addEventListener(e,n,l),rel:(t,e,n,l)=>t.removeEventListener(e,n,l),ce:(t,e)=>new CustomEvent(t,e)},st=t=>Promise.resolve(t),ct=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync}catch(t){}return!1})(),it=[],rt=[],at=(t,e)=>n=>{t.push(n),l||(l=!0,e&&4&ot.i?dt(ft):ot.raf(ft))},ut=t=>{for(let e=0;e<t.length;e++)try{t[e](performance.now())}catch(t){Y(t)}t.length=0},ft=()=>{ut(it),ut(rt),(l=it.length>0)&&ot.raf(ft)},dt=t=>st().then(t),pt=at(rt,!0);export{u as H,q as b,m as c,h as g,r as h,st as p,K as r,G as s}