@zephr/browser
Version:
Zephr Browser
2 lines (1 loc) • 34.3 kB
JavaScript
var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){var t={exports:{}};return e(t,t.exports),t.exports}var n=function(e){return e&&e.Math===Math&&e},r=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof e&&e)||n("object"==typeof e&&e)||function(){return this}()||Function("return this")(),o=function(e){try{return!!e()}catch(e){return!0}},i=!o(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}),c=!o(function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}),a=Function.prototype,s=a.call,u=c&&a.bind.bind(s,s),l=c?u:function(e){return function(){return s.apply(e,arguments)}},f="object"==typeof document&&document.all,p=void 0===f&&void 0!==f?function(e){return"function"==typeof e||e===f}:function(e){return"function"==typeof e},d=function(e){return null==e},m=TypeError,h=function(e){if(d(e))throw new m("Can't call method on "+e);return e},y=Object,g=function(e){return y(h(e))},v=l({}.hasOwnProperty),b=Object.hasOwn||function(e,t){return v(g(e),t)},w=Function.prototype,O=i&&Object.getOwnPropertyDescriptor,S=b(w,"name"),I={EXISTS:S,PROPER:S&&"something"===function(){}.name,CONFIGURABLE:S&&(!i||i&&O(w,"name").configurable)},C=Object.defineProperty,E=function(e,t){try{C(r,e,{value:t,configurable:!0,writable:!0})}catch(n){r[e]=t}return t},T=t(function(e){var t="__core-js_shared__",n=e.exports=r[t]||E(t,{});(n.versions||(n.versions=[])).push({version:"3.36.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.36.1/LICENSE",source:"https://github.com/zloirock/core-js"})}),P=l(Function.toString);p(T.inspectSource)||(T.inspectSource=function(e){return P(e)});var x,j,A=T.inspectSource,L=r.WeakMap,D=p(L)&&/native code/.test(String(L)),R=function(e){return"object"==typeof e?null!==e:p(e)},_=r.document,F=R(_)&&R(_.createElement),k=function(e){return F?_.createElement(e):{}},N=!i&&!o(function(){return 7!==Object.defineProperty(k("div"),"a",{get:function(){return 7}}).a}),z=i&&o(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype}),M=String,U=TypeError,Z=function(e){if(R(e))return e;throw new U(M(e)+" is not an object")},H=Function.prototype.call,W=c?H.bind(H):function(){return H.apply(H,arguments)},$=function(e){return p(e)?e:void 0},G=function(e,t){return arguments.length<2?$(r[e]):r[e]&&r[e][t]},K=l({}.isPrototypeOf),B="undefined"!=typeof navigator&&String(navigator.userAgent)||"",V=r.process,q=r.Deno,Y=V&&V.versions||q&&q.version,X=Y&&Y.v8;X&&(j=(x=X.split("."))[0]>0&&x[0]<4?1:+(x[0]+x[1])),!j&&B&&(!(x=B.match(/Edge\/(\d+)/))||x[1]>=74)&&(x=B.match(/Chrome\/(\d+)/))&&(j=+x[1]);var J,Q,ee,te=j,ne=r.String,re=!!Object.getOwnPropertySymbols&&!o(function(){var e=Symbol("symbol detection");return!ne(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&te&&te<41}),oe=re&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ie=Object,ce=oe?function(e){return"symbol"==typeof e}:function(e){var t=G("Symbol");return p(t)&&K(t.prototype,ie(e))},ae=String,se=TypeError,ue=function(e){if(p(e))return e;throw new se(function(e){try{return ae(e)}catch(e){return"Object"}}(e)+" is not a function")},le=function(e,t){var n=e[t];return d(n)?void 0:ue(n)},fe=TypeError,pe=function(e,t){return T[e]||(T[e]=t||{})},de=0,me=Math.random(),he=l(1..toString),ye=function(e){return"Symbol("+(void 0===e?"":e)+")_"+he(++de+me,36)},ge=r.Symbol,ve=pe("wks"),be=oe?ge.for||ge:ge&&ge.withoutSetter||ye,we=function(e){return b(ve,e)||(ve[e]=re&&b(ge,e)?ge[e]:be("Symbol."+e)),ve[e]},Oe=TypeError,Se=we("toPrimitive"),Ie=function(e){var t=function(e,t){if(!R(e)||ce(e))return e;var n,r=le(e,Se);if(r){if(void 0===t&&(t="default"),n=W(r,e,t),!R(n)||ce(n))return n;throw new Oe("Can't convert object to primitive value")}return void 0===t&&(t="number"),function(e,t){var n,r;if("string"===t&&p(n=e.toString)&&!R(r=W(n,e)))return r;if(p(n=e.valueOf)&&!R(r=W(n,e)))return r;if("string"!==t&&p(n=e.toString)&&!R(r=W(n,e)))return r;throw new fe("Can't convert object to primitive value")}(e,t)}(e,"string");return ce(t)?t:t+""},Ce=TypeError,Ee=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Pe={f:i?z?function(e,t,n){if(Z(e),t=Ie(t),Z(n),"function"==typeof e&&"prototype"===t&&"value"in n&&"writable"in n&&!n.writable){var r=Te(e,t);r&&r.writable&&(e[t]=n.value,n={configurable:"configurable"in n?n.configurable:r.configurable,enumerable:"enumerable"in n?n.enumerable:r.enumerable,writable:!1})}return Ee(e,t,n)}:Ee:function(e,t,n){if(Z(e),t=Ie(t),Z(n),N)try{return Ee(e,t,n)}catch(e){}if("get"in n||"set"in n)throw new Ce("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},xe=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},je=i?function(e,t,n){return Pe.f(e,t,xe(1,n))}:function(e,t,n){return e[t]=n,e},Ae=pe("keys"),Le=function(e){return Ae[e]||(Ae[e]=ye(e))},De={},Re=r.TypeError;if(D||T.state){var _e=T.state||(T.state=new(0,r.WeakMap));_e.get=_e.get,_e.has=_e.has,_e.set=_e.set,J=function(e,t){if(_e.has(e))throw new Re("Object already initialized");return t.facade=e,_e.set(e,t),t},Q=function(e){return _e.get(e)||{}},ee=function(e){return _e.has(e)}}else{var Fe=Le("state");De[Fe]=!0,J=function(e,t){if(b(e,Fe))throw new Re("Object already initialized");return t.facade=e,je(e,Fe,t),t},Q=function(e){return b(e,Fe)?e[Fe]:{}},ee=function(e){return b(e,Fe)}}var ke,Ne,ze={set:J,get:Q,has:ee,enforce:function(e){return ee(e)?Q(e):J(e,{})},getterFor:function(e){return function(t){var n;if(!R(t)||(n=Q(t)).type!==e)throw new Re("Incompatible receiver, "+e+" required");return n}}},Me=t(function(e){var t=I.CONFIGURABLE,n=ze.enforce,r=ze.get,c=String,a=Object.defineProperty,s=l("".slice),u=l("".replace),f=l([].join),d=i&&!o(function(){return 8!==a(function(){},"length",{value:8}).length}),m=String(String).split("String"),h=e.exports=function(e,r,o){"Symbol("===s(c(r),0,7)&&(r="["+u(c(r),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),o&&o.getter&&(r="get "+r),o&&o.setter&&(r="set "+r),(!b(e,"name")||t&&e.name!==r)&&(i?a(e,"name",{value:r,configurable:!0}):e.name=r),d&&o&&b(o,"arity")&&e.length!==o.arity&&a(e,"length",{value:o.arity});try{o&&b(o,"constructor")&&o.constructor?i&&a(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var l=n(e);return b(l,"source")||(l.source=f(m,"string"==typeof r?r:"")),e};Function.prototype.toString=h(function(){return p(this)&&r(this).source||A(this)},"toString")}),Ue=function(){var e=Z(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Ze=r.RegExp,He=Ze.prototype;i&&o(function(){var e=!0;try{Ze(".","d")}catch(t){e=!1}var t={},n="",r=e?"dgimsy":"gimsy",o=function(e,r){Object.defineProperty(t,e,{get:function(){return n+=r,!0}})},i={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var c in e&&(i.hasIndices="d"),i)o(c,i[c]);return Object.getOwnPropertyDescriptor(He,"flags").get.call(t)!==r||n!==r})&&(ke=He,(Ne={configurable:!0,get:Ue}).get&&Me(Ne.get,"flags",{getter:!0}),Ne.set&&Me(Ne.set,"flags",{setter:!0}),Pe.f(ke,"flags",Ne));var We,$e={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Ge=k("span").classList,Ke=Ge&&Ge.constructor&&Ge.constructor.prototype,Be=Ke===Object.prototype?void 0:Ke,Ve=l({}.toString),qe=l("".slice),Ye=function(e){return qe(Ve(e),8,-1)},Xe=Object,Je=l("".split),Qe=o(function(){return!Xe("z").propertyIsEnumerable(0)})?function(e){return"String"===Ye(e)?Je(e,""):Xe(e)}:Xe,et=function(e){return Qe(h(e))},tt=Math.ceil,nt=Math.floor,rt=Math.trunc||function(e){var t=+e;return(t>0?nt:tt)(t)},ot=function(e){var t=+e;return t!=t||0===t?0:rt(t)},it=Math.max,ct=Math.min,at=Math.min,st=function(e){var t=ot(e);return t>0?at(t,9007199254740991):0},ut=function(e){return function(t,n,r){var o=et(t),i=st(o.length);if(0===i)return!e&&-1;var c,a=function(e,t){var n=ot(e);return n<0?it(n+t,0):ct(n,t)}(r,i);if(e&&n!=n){for(;i>a;)if((c=o[a++])!=c)return!0}else for(;i>a;a++)if((e||a in o)&&o[a]===n)return e||a||0;return!e&&-1}},lt=(ut(!0),ut(!1)),ft=l([].push),pt=function(e,t){var n,r=et(e),o=0,i=[];for(n in r)!b(De,n)&&b(r,n)&&ft(i,n);for(;t.length>o;)b(r,n=t[o++])&&(~lt(i,n)||ft(i,n));return i},dt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],mt=Object.keys||function(e){return pt(e,dt)},ht=i&&!z?Object.defineProperties:function(e,t){Z(e);for(var n,r=et(t),o=mt(t),i=o.length,c=0;i>c;)Pe.f(e,n=o[c++],r[n]);return e},yt={f:ht},gt=G("document","documentElement"),vt=Le("IE_PROTO"),bt=function(){},wt=function(e){return"<script>"+e+"<\/script>"},Ot=function(e){e.write(wt("")),e.close();var t=e.parentWindow.Object;return e=null,t},St=function(){try{We=new ActiveXObject("htmlfile")}catch(e){}var e,t;St="undefined"!=typeof document?document.domain&&We?Ot(We):((t=k("iframe")).style.display="none",gt.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(wt("document.F=Object")),e.close(),e.F):Ot(We);for(var n=dt.length;n--;)delete St.prototype[dt[n]];return St()};De[vt]=!0;var It=Object.create||function(e,t){var n;return null!==e?(bt.prototype=Z(e),n=new bt,bt.prototype=null,n[vt]=e):n=St(),void 0===t?n:yt.f(n,t)},Ct=Pe.f,Et=we("unscopables"),Tt=Array.prototype;void 0===Tt[Et]&&Ct(Tt,Et,{configurable:!0,value:It(null)});var Pt,xt,jt,At=function(e){Tt[Et][e]=!0},Lt={},Dt={}.propertyIsEnumerable,Rt=Object.getOwnPropertyDescriptor,_t=Rt&&!Dt.call({1:2},1)?function(e){var t=Rt(this,e);return!!t&&t.enumerable}:Dt,Ft={f:_t},kt=Object.getOwnPropertyDescriptor,Nt={f:i?kt:function(e,t){if(e=et(e),t=Ie(t),N)try{return kt(e,t)}catch(e){}if(b(e,t))return xe(!W(Ft.f,e,t),e[t])}},zt=function(e,t,n,r){r||(r={});var o=r.enumerable,i=void 0!==r.name?r.name:t;if(p(n)&&Me(n,i,r),r.global)o?e[t]=n:E(t,n);else{try{r.unsafe?e[t]&&(o=!0):delete e[t]}catch(e){}o?e[t]=n:Pe.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},Mt=dt.concat("length","prototype"),Ut={f:Object.getOwnPropertyNames||function(e){return pt(e,Mt)}},Zt={f:Object.getOwnPropertySymbols},Ht=l([].concat),Wt=G("Reflect","ownKeys")||function(e){var t=Ut.f(Z(e)),n=Zt.f;return n?Ht(t,n(e)):t},$t=function(e,t,n){for(var r=Wt(t),o=Pe.f,i=Nt.f,c=0;c<r.length;c++){var a=r[c];b(e,a)||n&&b(n,a)||o(e,a,i(t,a))}},Gt=/#|\.prototype\./,Kt=function(e,t){var n=Vt[Bt(e)];return n===Yt||n!==qt&&(p(t)?o(t):!!t)},Bt=Kt.normalize=function(e){return String(e).replace(Gt,".").toLowerCase()},Vt=Kt.data={},qt=Kt.NATIVE="N",Yt=Kt.POLYFILL="P",Xt=Kt,Jt=Nt.f,Qt=function(e,t){var n,o,i,c,a,s=e.target,u=e.global,l=e.stat;if(n=u?r:l?r[s]||E(s,{}):r[s]&&r[s].prototype)for(o in t){if(c=t[o],i=e.dontCallGetSet?(a=Jt(n,o))&&a.value:n[o],!Xt(u?o:s+(l?".":"#")+o,e.forced)&&void 0!==i){if(typeof c==typeof i)continue;$t(c,i)}(e.sham||i&&i.sham)&&je(c,"sham",!0),zt(n,o,c,e)}},en=!o(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),tn=Le("IE_PROTO"),nn=Object,rn=nn.prototype,on=en?nn.getPrototypeOf:function(e){var t=g(e);if(b(t,tn))return t[tn];var n=t.constructor;return p(n)&&t instanceof n?n.prototype:t instanceof nn?rn:null},cn=we("iterator"),an=!1;[].keys&&("next"in(jt=[].keys())?(xt=on(on(jt)))!==Object.prototype&&(Pt=xt):an=!0);var sn=!R(Pt)||o(function(){var e={};return Pt[cn].call(e)!==e});sn&&(Pt={}),p(Pt[cn])||zt(Pt,cn,function(){return this});var un={IteratorPrototype:Pt,BUGGY_SAFARI_ITERATORS:an},ln=Pe.f,fn=we("toStringTag"),pn=function(e,t,n){e&&!n&&(e=e.prototype),e&&!b(e,fn)&&ln(e,fn,{configurable:!0,value:t})},dn=un.IteratorPrototype,mn=function(){return this},hn=String,yn=TypeError,gn=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=function(e,t,n){try{return l(ue(Object.getOwnPropertyDescriptor(e,"__proto__").set))}catch(e){}}(Object.prototype))(n,[]),t=n instanceof Array}catch(e){}return function(n,r){return h(n),function(e){if(function(e){return R(e)||null===e}(e))return e;throw new yn("Can't set "+hn(e)+" as a prototype")}(r),R(n)?(t?e(n,r):n.__proto__=r,n):n}}():void 0),vn=I.PROPER,bn=I.CONFIGURABLE,wn=un.IteratorPrototype,On=un.BUGGY_SAFARI_ITERATORS,Sn=we("iterator"),In=function(){return this},Cn=function(e,t){return{value:e,done:t}},En=Pe.f,Tn=ze.set,Pn=ze.getterFor("Array Iterator"),xn=function(e,t,n,r,o,i,c){!function(e,t,n,r){var o="Array Iterator";e.prototype=It(dn,{next:xe(1,function(){var e=Pn(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=void 0,Cn(void 0,!0);switch(e.kind){case"keys":return Cn(n,!1);case"values":return Cn(t[n],!1)}return Cn([n,t[n]],!1)})}),pn(e,o,!1),Lt[o]=mn}(n);var a,s,u,l=function(e){if(e===o&&h)return h;if(!On&&e&&e in d)return d[e];switch(e){case"keys":case"values":case"entries":return function(){return new n(this,e)}}return function(){return new n(this)}},f=!1,d=e.prototype,m=d[Sn]||d["@@iterator"]||d.values,h=!On&&m||l(o),y=d.entries||m;if(y&&(a=on(y.call(new e)))!==Object.prototype&&a.next&&(on(a)!==wn&&(gn?gn(a,wn):p(a[Sn])||zt(a,Sn,In)),pn(a,"Array Iterator",!0)),vn&&m&&"values"!==m.name&&(bn?je(d,"name","values"):(f=!0,h=function(){return W(m,this)})),void(s={values:l("values"),keys:l("keys"),entries:l("entries")}))for(u in s)(On||f||!(u in d))&&zt(d,u,s[u]);else Qt({target:"Array",proto:!0,forced:On||f},s);return d[Sn]!==h&&zt(d,Sn,h,{name:o}),Lt.Array=h,s}(Array,0,function(e,t){Tn(this,{type:"Array Iterator",target:et(e),index:0,kind:t})},0,"values"),jn=Lt.Arguments=Lt.Array;if(At("keys"),At("values"),At("entries"),i&&"values"!==jn.name)try{En(jn,"name",{value:"values"})}catch(e){}var An=we("iterator"),Ln=xn.values,Dn=function(e,t){if(e){if(e[An]!==Ln)try{je(e,An,Ln)}catch(t){e[An]=Ln}if(pn(e,t,!0),$e[t])for(var n in xn)if(e[n]!==xn[n])try{je(e,n,xn[n])}catch(t){e[n]=xn[n]}}};for(var Rn in $e)Dn(r[Rn]&&r[Rn].prototype,Rn);Dn(Be,"DOMTokenList"),At("flat");const _n={transform:{concat:e=>e.map(e=>kn(e)),zoned:e=>({type:"Zone",id:e.zoneId,contents:e.transformations.map(e=>kn(e))}),form:e=>({type:"Form",formId:e}),paymentForm:e=>({type:"PaymentForm",formId:e}),resource:e=>({type:"UIComponent",componentId:e}),parameterisedResource:e=>({type:"UIComponent",componentId:e}),url:e=>({type:"HostedUIComponent",url:e}),componentTemplate:e=>({type:"ComponentTemplate",componentId:e}),parameterisedComponentTemplate:e=>({type:"ComponentTemplate",componentId:e}),truncate:e=>({type:"Truncate",truncateLength:Number(e),style:"nostyle"}),truncateWithStyle:(e,t)=>({type:"Truncate",truncateLength:Number(e),style:t}),outcomeTracker:(e,t,n,r)=>({type:"OutcomeTracker",featureId:e,featureLabel:t,outcomeId:n,outcomeLabel:r}),remove:()=>({type:"Remove"})}},Fn={type:"LeavePristine"},kn=e=>{const t=e.trim().length?e:"blaize.transform.remove()";return new Function("blaize,leave_pristine",'"use strict";return ('+t+");")(_n,Fn)};function Nn(e,t){let n;switch(t){case"fadeout":const t=document.createElement("div");t.style.position="absolute",t.style.height="100%",t.style.width="100%",t.style.bottom="0",t.style.backgroundImage="linear-gradient(0deg, #fff 0%, rgba(255, 255, 255, 0) 100%)",e.appendChild(t),n=document.createElement("div"),n.style.position="relative",n.appendChild(e);break;case"linebreak":const r=document.createElement("hr");r.style.border="1px solid #ebebeb",e.appendChild(r),n=e;break;default:n=e}return n}var zn=Function.prototype,Mn=zn.apply,Un=zn.call,Zn="object"==typeof Reflect&&Reflect.apply||(c?Un.bind(Mn):function(){return Un.apply(Mn,arguments)}),Hn={};Hn[we("toStringTag")]="z";var Wn,$n,Gn="[object z]"===String(Hn),Kn=we("toStringTag"),Bn=Object,Vn="Arguments"===Ye(function(){return arguments}()),qn=Gn?Ye:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Bn(e),Kn))?n:Vn?Ye(t):"Object"===(r=Ye(t))&&p(t.callee)?"Arguments":r},Yn=String,Xn=function(e){if("Symbol"===qn(e))throw new TypeError("Cannot convert a Symbol value to a string");return Yn(e)},Jn=r.RegExp,Qn=o(function(){var e=Jn("a","y");return e.lastIndex=2,null!==e.exec("abcd")}),er=Qn||o(function(){return!Jn("a","y").sticky}),tr={BROKEN_CARET:Qn||o(function(){var e=Jn("^r","gy");return e.lastIndex=2,null!==e.exec("str")}),MISSED_STICKY:er,UNSUPPORTED_Y:Qn},nr=r.RegExp,rr=o(function(){var e=nr(".","s");return!(e.dotAll&&e.test("\n")&&"s"===e.flags)}),or=r.RegExp,ir=o(function(){var e=or("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")}),cr=ze.get,ar=pe("native-string-replace",String.prototype.replace),sr=RegExp.prototype.exec,ur=sr,lr=l("".charAt),fr=l("".indexOf),pr=l("".replace),dr=l("".slice),mr=($n=/b*/g,W(sr,Wn=/a/,"a"),W(sr,$n,"a"),0!==Wn.lastIndex||0!==$n.lastIndex),hr=tr.BROKEN_CARET,yr=void 0!==/()??/.exec("")[1];(mr||yr||hr||rr||ir)&&(ur=function(e){var t,n,r,o,i,c,a,s=this,u=cr(s),l=Xn(e),f=u.raw;if(f)return f.lastIndex=s.lastIndex,t=W(ur,f,l),s.lastIndex=f.lastIndex,t;var p=u.groups,d=hr&&s.sticky,m=W(Ue,s),h=s.source,y=0,g=l;if(d&&(m=pr(m,"y",""),-1===fr(m,"g")&&(m+="g"),g=dr(l,s.lastIndex),s.lastIndex>0&&(!s.multiline||s.multiline&&"\n"!==lr(l,s.lastIndex-1))&&(h="(?: "+h+")",g=" "+g,y++),n=new RegExp("^(?:"+h+")",m)),yr&&(n=new RegExp("^"+h+"$(?!\\s)",m)),mr&&(r=s.lastIndex),o=W(sr,d?n:s,g),d?o?(o.input=dr(o.input,y),o[0]=dr(o[0],y),o.index=s.lastIndex,s.lastIndex+=o[0].length):s.lastIndex=0:mr&&o&&(s.lastIndex=s.global?o.index+o[0].length:r),yr&&o&&o.length>1&&W(ar,o[0],n,function(){for(i=1;i<arguments.length-2;i++)void 0===arguments[i]&&(o[i]=void 0)}),o&&p)for(o.groups=c=It(null),i=0;i<p.length;i++)c[(a=p[i])[0]]=o[a[1]];return o});var gr=ur;Qt({target:"RegExp",proto:!0,forced:/./.exec!==gr},{exec:gr}),we("species");var vr=RegExp.prototype,br=l("".charAt),wr=l("".charCodeAt),Or=l("".slice),Sr=function(e){return function(t,n){var r,o,i=Xn(h(t)),c=ot(n),a=i.length;return c<0||c>=a?e?"":void 0:(r=wr(i,c))<55296||r>56319||c+1===a||(o=wr(i,c+1))<56320||o>57343?e?br(i,c):r:e?Or(i,c,c+2):o-56320+(r-55296<<10)+65536}},Ir=(Sr(!1),Sr(!0)),Cr=function(e,t,n){return t+(n?Ir(e,t).length:1)},Er=Math.floor,Tr=l("".charAt),Pr=l("".replace),xr=l("".slice),jr=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Ar=/\$([$&'`]|\d{1,2})/g,Lr=function(e,t,n,r,o,i){var c=n+e.length,a=r.length,s=Ar;return void 0!==o&&(o=g(o),s=jr),Pr(i,s,function(i,s){var u;switch(Tr(s,0)){case"$":return"$";case"&":return e;case"`":return xr(t,0,n);case"'":return xr(t,c);case"<":u=o[xr(s,1,-1)];break;default:var l=+s;if(0===l)return i;if(l>a){var f=Er(l/10);return 0===f?i:f<=a?void 0===r[f-1]?Tr(s,1):r[f-1]+Tr(s,1):i}u=r[l-1]}return void 0===u?"":u})},Dr=TypeError,Rr=function(e,t){var n=e.exec;if(p(n)){var r=W(n,e,t);return null!==r&&Z(r),r}if("RegExp"===Ye(e))return W(gr,e,t);throw new Dr("RegExp#exec called on incompatible receiver")},_r=we("replace"),Fr=Math.max,kr=Math.min,Nr=l([].concat),zr=l([].push),Mr=l("".indexOf),Ur=l("".slice),Zr="$0"==="a".replace(/./,"$0"),Hr=!!/./[_r]&&""===/./[_r]("a","$0");!function(e,t,n,r){var i=we(e),c=!o(function(){var t={};return t[i]=function(){return 7},7!==""[e](t)}),a=c&&!o(function(){var e=!1,t=/a/;return t.exec=function(){return e=!0,null},t[i](""),!e});if(!c||!a||n){var s=/./[i],u=function(e,t,n){var r=Hr?"$":"$0";return[function(e,n){var r=h(this),o=d(e)?void 0:le(e,_r);return o?W(o,e,r,n):W(t,Xn(r),e,n)},function(e,n){var o,i,a,u,l,f=Z(this),d=Xn(e);if("string"==typeof n&&-1===Mr(n,r)&&-1===Mr(n,"$<")){var m=(o=t,a=d,u=n,(l=(i=f).exec)===gr||l===vr.exec?c?{done:!0,value:W(s,i,a,u)}:{done:!0,value:W(o,a,i,u)}:{done:!1});if(m.done)return m.value}var h=p(n);h||(n=Xn(n));var y,g=f.global;g&&(y=f.unicode,f.lastIndex=0);for(var v,b=[];null!==(v=Rr(f,d))&&(zr(b,v),g);)""===Xn(v[0])&&(f.lastIndex=Cr(d,st(f.lastIndex),y));for(var w,O="",S=0,I=0;I<b.length;I++){for(var C,E=Xn((v=b[I])[0]),T=Fr(kr(ot(v.index),d.length),0),P=[],x=1;x<v.length;x++)zr(P,void 0===(w=v[x])?w:String(w));var j=v.groups;if(h){var A=Nr([E],P,T,d);void 0!==j&&zr(A,j),C=Xn(Zn(n,void 0,A))}else C=Lr(E,d,T,P,j,n);T>=S&&(O+=Ur(d,S,T)+C,S=T+E.length)}return O+Ur(d,S)}]}(0,""[e]);zt(String.prototype,e,u[0]),zt(vr,i,u[1])}}("replace",0,!!o(function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")})||!Zr||Hr);const Wr=/<[^>]*>|[^<>]+/g,$r=/^[\p{Alpha}|\p{N}]$/u;class Gr{constructor(e,t,n){this.text=e,this.type=t,this.isSentenceEnd=n}}const Kr=Object.freeze({WORD:0,PUNCTUATION:1,WHITESPACE:2});function Br(e){return-1!==e.search(">[^<>]+<")}const Vr=Object.freeze(["script","style","noscript","template","iframe","svg","canvas"]);function qr(e){return Vr.some(t=>{const n=e.indexOf("<"+t)>=0,r=e.indexOf("</"+t)>=0;return n?!r:r})}const Yr=Object.freeze({LOCALE_AWARE_TRUNCATION:!1}),Xr=()=>Intl&&"Segmenter"in Intl,Jr=e=>{let t;return"function"==typeof Event?t=new Event(e):(t=document.createEvent("Event"),t.initEvent(e,!0,!0)),t},Qr=function(e){e&&console.log(...[].slice.call(arguments,1))},eo=e=>{const t=(new DOMParser).parseFromString(e,"text/html"),n=[...Array.from(t.head.childNodes),...Array.from(t.body.childNodes)];if(!n.length)return document.createTextNode(e);const r=document.createDocumentFragment();return n.forEach(e=>r.appendChild(e)),to(r),r},to=e=>{const t=e.querySelectorAll("script");t.length&&Array.from(t).map(e=>{const t=document.createElement("script");Array.from(e.attributes).forEach(e=>{t.setAttribute(e.name,e.value)}),t.innerHTML=e.innerHTML,e.parentNode.appendChild(t),e.parentNode.removeChild(e)})},no=(e,t,n,r)=>{switch(t.type){case"LeavePristine":return e;case"Truncate":return r.LOCALE_AWARE_TRUNCATION&&Xr()?function(e,t){var n;const r=(null==(n=document.documentElement)?void 0:n.lang)||"en",o=2*t.truncateLength,i=function(e,t){var n;void 0===t&&(t="en");const r=(null!=(n=null==e?void 0:e.outerHTML)?n:e.nodeValue).trim(),o=new Intl.Segmenter(t,{granularity:"sentence"}),i=new Intl.Segmenter(t,{granularity:"word"}),c=[],a=r.match(Wr).map(e=>e.startsWith("<")?"".padStart(e.length):e).join("").replace(/\n/g,""),s=Array.from(o.segment(a));let u=0,l=0;for(const e of s){let t=e.segment.trimStart();const n=e.segment.length-t.length;t=t.trimEnd();const o=e.segment.length-(n+t.length);if(n>0){const e=r.substring(u,u+n);c.push(new Gr(e,e.trim().length>0?Kr.WORD:Kr.WHITESPACE,!1))}u=l+n,l=u+t.length;const a=r.substring(u,l),s=Array.from(i.segment(t));let p=0,d=0;for(const[e,n]of s.entries()){p=d,d=p+n.segment.length;const r=a.substring(p,d);c.push(new Gr(r,0===(f=r).trim().length?Kr.WHITESPACE:1!==f.length||$r.test(f)?Kr.WORD:Kr.PUNCTUATION,t.length>1&&e===s.length-1))}if(o>0){const e=r.substring(l,l+o);c.push(new Gr(e,e.trim().length>0?Kr.WORD:Kr.WHITESPACE,!1)),l+=o}}var f;return c}(e,r);if(t.truncateLength>=i.length)return e;let c=0,a=!1,s=!1,u=0,l=0;for(const e of i){if(l++,e.type===Kr.WHITESPACE&&!e.isSentenceEnd)continue;const n=e.text.trim();if(s&&n.indexOf("</")>=0&&qr(n)?s=!1:n.indexOf("<")>=0&&qr(n)&&(s=!0),s)continue;const r=a,i=n.lastIndexOf("<"),f=n.lastIndexOf(">");if(i>=0&&(a=!0),f>=0&&(a=!1),-1!==i&&-1!==f&&i>f&&(a=!0),r&&f===n.length-1||0===i&&f===n.length-1)a=!1;else if(!a){if(c>0&&e.type===Kr.WORD)break;(e.type===Kr.WORD||e.isSentenceEnd)&&(e.type===Kr.WORD&&u++,(u===o||u>=t.truncateLength&&e.isSentenceEnd)&&(c=l))}}if(l===i.length)return e;l=c>0?c:l;let f=i.slice(0,l).map(e=>e.text).join("");return u===o&&(f+="..."),Nn((new DOMParser).parseFromString(f,"text/html").body.children[0],t.style)}(e,t):function(e,t){const n=2*t.truncateLength,r=e.outerHTML.trim().split(/\s+/);if(t.truncateLength>=r.length)return e;let o=0,i=!1,c=0,a=0;for(const e of r){a++;const r=i,s=e.lastIndexOf("<"),u=e.lastIndexOf(">");if(s>=0&&(i=!0),u>=0&&(i=!1),-1!==s&&-1!==u&&s>u&&(i=!0),r&&u===e.length-1&&!Br(e)||0===s&&u===e.length-1)i=!1;else if(!i){if(o>0)break;c++,(c>=t.truncateLength&&e.includes(".")||c===n)&&(o=a)}}if(a===r.length)return e;a=o>0?o:a;let s=r.slice(0,a).join(" ");return c===n&&(s+="...\n"),Nn((new DOMParser).parseFromString(s,"text/html").body.children[0],t.style)}(e,t);case"OutcomeTracker":(e=>{window.Zephr||(window.Zephr={}),window.Zephr.outcomes||(window.Zephr.outcomes={}),window.Zephr.outcomes[e.featureId]={featureLabel:e.featureLabel,outcomeId:e.outcomeId,outcomeLabel:e.outcomeLabel}})(t);break;case"Form":return((e,t)=>{if(t.forms&&t.forms[e.formId])return eo(t.forms[e.formId]);console.error("Form not found.")})(t,n);case"PaymentForm":return((e,t)=>{if(t.paymentForms&&t.paymentForms[e.formId])return eo(t.paymentForms[e.formId]);console.error("Payment form not found.")})(t,n);case"UIComponent":return((e,t)=>{if(t.uiComponents&&t.uiComponents[e.componentId])return eo(t.uiComponents[e.componentId]);console.error("UI component not found.")})(t,n);case"HostedUIComponent":return((e,t)=>{if(t.hostedUiComponents&&t.hostedUiComponents[e.url])return eo(t.hostedUiComponents[e.url]);console.error("Hosted UI component not found.")})(t,n);case"ComponentTemplate":return((e,t)=>{if(t.componentTemplates&&t.componentTemplates[e.componentId])return eo(t.componentTemplates[e.componentId]);console.error("Component template not found.")})(t,n);case"Remove":break;case"Zone":const o=t.contents.map(t=>no(e,t,n,r));return((e,t,n)=>{if(!n.uiComponents||!n.uiComponents[e])return void console.error("Zone not found.");const r=eo(n.uiComponents[e]),o=r.getElementById("zephr-zone-"+e.toLowerCase());return t.forEach(e=>o.appendChild(e)),r})(t.id,o,n);default:console.error("No matching outcome type "+t.type)}};function ro(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}const oo="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function io(e,t,n){if(!e.s){if(n instanceof co){if(!n.s)return void(n.o=io.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(io.bind(null,e,t),io.bind(null,e,2));e.s=t,e.v=n;const r=e.o;r&&r(e)}}const co=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,n){const r=new e,o=this.s;if(o){const e=1&o?t:n;if(e){try{io(r,1,e(this.v))}catch(e){io(r,2,e)}return r}return this}return this.o=function(e){try{const o=e.v;1&e.s?io(r,1,t?t(o):o):n?io(r,1,n(o)):io(r,2,o)}catch(e){io(r,2,e)}},r},e}();function ao(e){return e instanceof co&&1&e.s}class so{constructor(e,t){this.cdnApi=e||"",this.fetcher=t||null}fetchLiveFeatures(){try{const e=this;return Promise.resolve(ro(function(){return Promise.resolve(e._fetcher(e.cdnApi+"/zephr/features",{method:"GET",headers:{Accept:"application/json"}}).then(e=>e.json()))},function(){return Promise.reject(new Error("Live features endpoint failed."))}))}catch(e){return Promise.reject(e)}}fetchDecisions(e,t){let{jwt:n,customData:r={}}=void 0===t?{customData:{}}:t;try{const t=this,o=e.map(e=>e.id);return Promise.resolve(ro(function(){return Promise.resolve(t._fetcher(t.cdnApi+"/zephr/feature-decisions",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json",...n&&{Authorization:"Bearer "+n}},body:JSON.stringify({path:document.location.pathname+document.location.search+document.location.hash,referer:document.referrer,featureIds:o,customData:r})}).then(e=>e.json()))},function(){return Promise.reject(new Error("Feature decisions endpoint failed."))}))}catch(e){return Promise.reject(e)}}executeDecisions(e,t,n,r){try{const o=this;function i(){t.accessDetails&&(window.Zephr||(window.Zephr={}),window.Zephr.accessDetails?window.Zephr.accessDetails=o._mergeAccessDetails(window.Zephr.accessDetails,t.accessDetails):window.Zephr.accessDetails=t.accessDetails),n&&(e=>{const t=e.datalayerName;t in window||(window[t]=[]);const n={},r=[];e.includeOutcomes&&window.Zephr.outcomes&&(n.zephrOutcomes=window.Zephr.outcomes,e.outcomesAsEvents&&Object.keys(window.Zephr.outcomes||[]).forEach(function(e){const t={event:"zephr-outcome-"+e,featureId:e,featureLabel:window.Zephr.outcomes[e].featureLabel,outcomeId:window.Zephr.outcomes[e].outcomeId,outcomeLabel:window.Zephr.outcomes[e].outcomeLabel};r.push(t)})),window.Zephr&&window.Zephr.accessDetails&&(Object.keys(window.Zephr.accessDetails.trials||{}).forEach(function(t){const r=window.Zephr.accessDetails.trials[t];if(r.reportInDataLayer){const t=r.totalCredits-r.remainingCredits;e.groupFields&&!n.zephrTrials&&(n.zephrTrials={});const o=e.groupFields?n.zephrTrials:n;r.dataLayerCreditsUsedKey&&(o[r.dataLayerCreditsUsedKey]=t),r.dataLayerCreditsRemainingKey&&(o[r.dataLayerCreditsRemainingKey]=r.remainingCredits)}}),(window.Zephr.accessDetails.trialTrackingDetails||[]).forEach(function(t){const r=(window.Zephr.accessDetails["credits"===t.entitlementType?"credits":"meters"]||{})[t.entitlementId];r&&(e.groupFields&&!n.zephrTrials&&(n.zephrTrials={}),t.creditsRemainingKey&&(e.groupFields?n.zephrTrials[t.creditsRemainingKey]=r.remainingCredits:n[t.creditsRemainingKey]=r.remainingCredits),t.creditsUsedKey&&(e.groupFields?n.zephrTrials[t.creditsUsedKey]=r.totalCredits-r.remainingCredits:n[t.creditsUsedKey]=r.totalCredits-r.remainingCredits))})),Object.keys(n).length&&(n.event="zephr-pageview",r.unshift(n)),r.length&&(r.forEach(function(e){window[t].push(e)}),document.dispatchEvent(Jr("zephr.dataLayerReady")))})(n)}const c=function(e,t,n){if("function"==typeof e[oo]){var r,o,i,c=e[oo]();if(function e(n){try{for(;!(r=c.next()).done;)if((n=t(r.value))&&n.then){if(!ao(n))return void n.then(e,i||(i=io.bind(null,o=new co,2)));n=n.v}o?io(o,1,n):o=n}catch(e){io(o||(o=new co),2,e)}}(),c.return){var a=function(e){try{r.done||c.return()}catch(e){}return e};if(o&&o.then)return o.then(a,function(e){throw a(e)});a()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var s=[],u=0;u<e.length;u++)s.push(e[u]);return function(e,t,n){var r,o,i=-1;return function n(c){try{for(;++i<e.length;)if((c=t(i))&&c.then){if(!ao(c))return void c.then(n,o||(o=io.bind(null,r=new co,2)));c=c.v}r?io(r,1,c):r=c}catch(e){io(r||(r=new co),2,e)}}(),r}(s,function(e){return t(s[e])})}(e,function(e){function n(){!function(e,t,n,r){void 0===n&&(n={}),void 0===r&&(r=Yr),e.forEach(e=>{const o=e.parentNode,i=Array.from(o.children).indexOf(e),c=o.removeChild(e),a=t.map(e=>no(c,e,n,r)).filter(Boolean),s=document.createDocumentFragment();a.forEach(e=>s.appendChild(e)),i<o.children.length?o.insertBefore(s,o.children[i]):o.appendChild(s)})}(a,c,t.resources||{},o._mergeDefaultFlags(t.flags))}const i=(t.featureResults||{})[e.id];if(!i)return;const c=(e=>[kn(e)].flat())(i),a=o.selectFeatureNodes(e),s=c.some(e=>"Truncate"===e.type),u=function(){if(r.automaticPolyfills&&s&&!Xr())return Promise.resolve(function(e){try{const t=function(t,n){try{var r=Promise.resolve(fetch(e).then(e=>e.text()).then(e=>new Function(e)())).then(function(){})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(t){console.error("Error fetching and executing script from "+e+":",t)});return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}("https://assets.zephr.com/zephr-browser/1.9.1/polyfill-intl-segmenter.umd.js")).then(function(){})}();return u&&u.then?u.then(n):n()});return Promise.resolve(c&&c.then?c.then(i):i())}catch(a){return Promise.reject(a)}}_fetcher(e,t){return this.fetcher?this.fetcher(e,t):window.fetch(e,t)}_mergeAccessDetails(e,t){var n,r;return{...e,...t,authenticated:t.authenticated,accessDecisions:{...e.accessDecisions,...t.accessDecisions},entitlements:this._mergeCreditData(e.entitlements,t.entitlements),credits:this._mergeCreditData(e.credits,t.credits),meters:this._mergeCreditData(e.meters,t.meters),trials:this._mergeCreditData(null!=(n=e.trials)?n:{},null!=(r=t.trials)?r:{})}}_mergeCreditData(e,t){var n={...e,...t};for(const[r,o]of Object.entries(e)){const e=t[r];if(e){const t=n[r];this._eitherHasProperty(o,e,"decrementedInDecision")&&(t.decrementedInDecision=!(!o.decrementedInDecision&&!e.decrementedInDecision)),this._eitherHasProperty(o,e,"usedInDecision")&&(t.usedInDecision=!(!o.usedInDecision&&!e.usedInDecision)),this._eitherHasProperty(o,e,"remainingCredits")&&(t.remainingCredits=this._minOrNumber(o.remainingCredits,e.remainingCredits)),this._eitherHasProperty(o,e,"totalCredits")&&(t.totalCredits=this._minOrNumber(o.totalCredits,e.totalCredits))}}return n}_eitherHasProperty(e,t,n){return e&&e.hasOwnProperty(n)||t&&t.hasOwnProperty(n)}_minOrNumber(e,t){const n="number"==typeof e,r="number"==typeof t;return n&&r?Math.min(e,t):n?e:r?t:void 0}_mergeDefaultFlags(e){return void 0===e&&(e={}),{...Yr,...e}}findFeatures(e){return Array.isArray(e)&&e.length?e.filter(e=>"COMMENT_TAG"!==e.targetType&&null!==document.querySelector(e.cssSelector)):[]}selectFeatureNodes(e){return document.querySelectorAll(e.cssSelector)}}const uo=(e,t)=>new so(e,t),lo=function(e){try{const t=e&&e.debug||localStorage&&localStorage.getItem("zephrBrowserDebug");let n="",r={automaticPolyfills:!0};"string"==typeof e?n=e:"object"==typeof e&&(r={...r,...e},n=e.cdnApi||"");const o=uo(n,null==e?void 0:e.fetcher);return Promise.resolve(o.fetchLiveFeatures()).then(function(e){function n(){return document.dispatchEvent(Jr("zephr.browserDecisionsFinished")),o}let i,c;Array.isArray(e)?i=e:(i=e.features,c=e.datalayerOutcomesConfig),Qr(t,"Live Features:",i);const a=o.findFeatures(i),s=function(){if(a.length)return Qr(t,"Features on page:",a),Promise.resolve(o.fetchDecisions(a,r)).then(function(e){Qr(t,"Decisions:",e);const n=performance.now();return Promise.resolve(o.executeDecisions(a,e,c,r)).then(function(){Qr(t,"Decision execution finished: took "+(performance.now()-n)+" ms")})});Qr(t,"No features found on page.")}();return s&&s.then?s.then(n):n()})}catch(e){return Promise.reject(e)}};export{uo as createInstance,lo as run};