UNPKG

@usercentrics/cmp-browser-sdk

Version:
2 lines (1 loc) 31.2 kB
import{_ as e,d as t,g as s,q as n,$ as i,w as r,x as a,y as o,h as c,z as u,B as d,H as l,I as h,J as p,K as v,M as f,N as m,O as g,P as I,Q as C,u as y,b,R as E,T as S,U as V,i as A,V as T,X as D,Y as M,Z as k,a0 as L,a1 as w,a2 as P,a3 as _,a4 as R,a5 as O,a6 as N,a7 as F,l as U,m as G,t as Q,a8 as x,a9 as B,aa as j,ab as H,G as W,ac as X,ad as q,ae as z,af as J,ag as Y,ah as K,ai as Z,aj as $,ak as ee,al as te,n as se,am as ne,an as ie,ao as re}from"./index-a467e104.js";import ae from"./DefaultData-b709c3f8.js";var oe,ce;function ue(e,t){return Object.keys(t).forEach(function(s){"default"===s||"__esModule"===s||Object.prototype.hasOwnProperty.call(e,s)||Object.defineProperty(e,s,{enumerable:!0,get:function(){return t[s]}})}),e}function de(e,t,s,n){Object.defineProperty(e,t,{get:s,set:n,enumerable:!0,configurable:!0})}var le={},he={};de(he,"TCFCommand",function(){return pe});var pe=function(e){return e.PING="ping",e.GET_TC_DATA="getTCData",e.GET_IN_APP_TC_DATA="getInAppTCData",e.GET_VENDOR_LIST="getVendorList",e.ADD_EVENT_LISTENER="addEventListener",e.REMOVE_EVENT_LISTENER="removeEventListener",e}({});ue(le,he),ue(le,{});var ve={},fe={};de(fe,"InAppTCData",function(){return we});var me={};de(me,"TCData",function(){return Le});de({},"CmpApiModel",function(){return De});var ge={},Ie={};de(Ie,"CmpStatus",function(){return Ce});var Ce=function(e){return e.STUB="stub",e.LOADING="loading",e.LOADED="loaded",e.ERROR="error",e}({}),ye={};de(ye,"DisplayStatus",function(){return be});var be=function(e){return e.VISIBLE="visible",e.HIDDEN="hidden",e.DISABLED="disabled",e}({}),Ee={};de(Ee,"EventStatus",function(){return Se});var Se=function(e){return e.TC_LOADED="tcloaded",e.CMP_UI_SHOWN="cmpuishown",e.USER_ACTION_COMPLETE="useractioncomplete",e}({});ue(ge,Ie),ue(ge,ye),ue(ge,Ee);var Ve=function(){return t(function e(t,n,i,r){s(this,e),this.success=!0,Object.assign(this,{callback:t,listenerId:i,param:n,next:r});try{this.respond()}catch(a){this.invokeCallback(null)}},[{key:"invokeCallback",value:function(e){var t=null!==e;"function"==typeof this.next?this.callback(this.next,e,t):this.callback(e,t)}}])}(),Ae=function(){function n(){return s(this,n),c(this,n,arguments)}return e(n,Ve),t(n,[{key:"respond",value:function(){this.throwIfParamInvalid(),this.invokeCallback(new Le(this.param,this.listenerId))}},{key:"throwIfParamInvalid",value:function(){if(!(void 0===this.param||Array.isArray(this.param)&&this.param.every(Number.isInteger)))throw new Error("Invalid Parameter")}}])}(),Te=function(){return t(function e(){s(this,e),this.eventQueue=new Map,this.queueNumber=0},[{key:"add",value:function(e){return this.eventQueue.set(this.queueNumber,e),this.queueNumber++}},{key:"remove",value:function(e){return this.eventQueue.delete(e)}},{key:"exec",value:function(){this.eventQueue.forEach(function(e,t){new Ae(e.callback,e.param,t,e.next)})}},{key:"clear",value:function(){this.queueNumber=0,this.eventQueue.clear()}},{key:"size",get:function(){return this.eventQueue.size}}])}(),De=function(){return t(function e(){s(this,e)},null,[{key:"reset",value:function(){delete this.cmpId,delete this.cmpVersion,delete this.eventStatus,delete this.gdprApplies,delete this.tcModel,delete this.tcString,delete this.tcfPolicyVersion,this.enableAdvertiserConsentMode=!1,this.addtlConsent="",this.cmpStatus=Ce.LOADING,this.disabled=!1,this.displayStatus=be.HIDDEN,this.eventQueue.clear()}}])}();(oe=De).apiVersion="2",oe.eventQueue=new Te,oe.cmpStatus=Ce.LOADING,oe.disabled=!1,oe.displayStatus=be.HIDDEN,oe.enableAdvertiserConsentMode=!1,oe.addtlConsent="";var Me={};de(Me,"Response",function(){return ke});var ke=t(function e(){s(this,e),this.cmpId=De.cmpId,this.cmpVersion=De.cmpVersion,this.gdprApplies=De.gdprApplies,this.tcfPolicyVersion=De.tcfPolicyVersion}),Le=function(){function i(e,t){var n;if(s(this,i),(n=c(this,i)).eventStatus=De.eventStatus,n.cmpStatus=De.cmpStatus,n.listenerId=t,De.gdprApplies){var r=De.tcModel;n.tcString=De.tcString,n.addtlConsent=r.addtlConsent,n.enableAdvertiserConsentMode=r.enableAdvertiserConsentMode,n.isServiceSpecific=r.isServiceSpecific,n.useNonStandardTexts=r.useNonStandardTexts,n.purposeOneTreatment=r.purposeOneTreatment,n.publisherCC=r.publisherCountryCode,!1===n.isServiceSpecific&&(n.outOfBand={allowedVendors:n.createVectorField(r.vendorsAllowed,e),disclosedVendors:n.createVectorField(r.vendorsDisclosed,e)}),n.purpose={consents:n.createVectorField(r.purposeConsents),legitimateInterests:n.createVectorField(r.purposeLegitimateInterests)},n.vendor={consents:n.createVectorField(r.vendorConsents,e),legitimateInterests:n.createVectorField(r.vendorLegitimateInterests,e),disclosedVendors:n.createVectorField(r.vendorsDisclosed,e)},n.specialFeatureOptins=n.createVectorField(r.specialFeatureOptins),n.publisher={consents:n.createVectorField(r.publisherConsents),legitimateInterests:n.createVectorField(r.publisherLegitimateInterests),customPurpose:{consents:n.createVectorField(r.publisherCustomConsents),legitimateInterests:n.createVectorField(r.publisherCustomLegitimateInterests)},restrictions:n.createRestrictions(r.publisherRestrictions)}}return n}return e(i,ke),t(i,[{key:"createRestrictions",value:function(e){var t={};if(e.numRestrictions>0)for(var s=e.getMaxVendorId(),n=function(){var s=i.toString();e.getRestrictions(i).forEach(function(e){var n=e.purposeId.toString();t[n]||(t[n]={}),t[n][s]=e.restrictionType})},i=1;i<=s;i++)n();return t}},{key:"createVectorField",value:function(e,t){return t?t.reduce(function(t,s){return t[String(s)]=e.has(Number(s)),t},{}):n(e).reduce(function(e,t){return e[t[0].toString(10)]=t[1],e},{})}}])}(),we=function(){function i(e){var t;return s(this,i),delete(t=c(this,i,[e])).outOfBand,t}return e(i,Le),t(i,[{key:"createVectorField",value:function(e){return n(e).reduce(function(e,t){return e+=t[1]?"1":"0"},"")}},{key:"createRestrictions",value:function(e){var t={};if(e.numRestrictions>0){var s=e.getMaxVendorId();e.getRestrictions().forEach(function(e){t[e.purposeId.toString()]="_".repeat(s)});for(var n=function(s){var n=s+1;e.getRestrictions(n).forEach(function(e){var n=e.restrictionType.toString(),i=e.purposeId.toString(),r=t[i].substr(0,s),a=t[i].substr(s+1);t[i]=r+n+a})},i=0;i<s;i++)n(i)}return t}}])}(),Pe={};de(Pe,"Ping",function(){return _e});var _e=function(){function n(){var e;return s(this,n),(e=c(this,n)).cmpLoaded=!0,e.cmpStatus=De.cmpStatus,e.displayStatus=De.displayStatus,e.apiVersion=String(De.apiVersion),De.tcModel&&De.tcModel.vendorListVersion&&(e.gvlVersion=+De.tcModel.vendorListVersion),e}return e(n,ke),t(n)}();ue(ve,fe),ue(ve,Pe),ue(ve,Me),ue(ve,me);de({},"CmpApi",function(){return Ye});var Re,Oe,Ne,Fe,Ue,Ge,Qe=function(){function n(){return s(this,n),c(this,n,arguments)}return e(n,Ve),t(n,[{key:"respond",value:function(){this.invokeCallback(new _e)}}])}(),xe=function(){function n(){return s(this,n),c(this,n,arguments)}return e(n,Ae),t(n,[{key:"respond",value:function(){this.throwIfParamInvalid(),this.invokeCallback(new we(this.param))}}])}(),Be=function(){function n(){return s(this,n),c(this,n,arguments)}return e(n,Ve),t(n,[{key:"respond",value:function(){var e,t=this,s=De.tcModel,n=s.vendorListVersion;void 0===this.param&&(this.param=n),(e=this.param===n&&s.gvl?s.gvl:new i(this.param)).readyPromise.then(function(){t.invokeCallback(e.getJson())})}}])}(),je=function(){function n(){return s(this,n),c(this,n,arguments)}return e(n,Ae),t(n,[{key:"respond",value:function(){this.listenerId=De.eventQueue.add({callback:this.callback,param:this.param,next:this.next}),r(n,"respond",this,3)([])}}])}(),He=function(){function n(){return s(this,n),c(this,n,arguments)}return e(n,Ve),t(n,[{key:"respond",value:function(){this.invokeCallback(De.eventQueue.remove(this.param))}}])}(),We=t(function e(){s(this,e)});ce=We,Re=pe.PING,Oe=pe.GET_TC_DATA,Ne=pe.GET_IN_APP_TC_DATA,Fe=pe.GET_VENDOR_LIST,Ue=pe.ADD_EVENT_LISTENER,Ge=pe.REMOVE_EVENT_LISTENER,ce[Re]=Qe,ce[Oe]=Ae,ce[Ne]=xe,ce[Fe]=Be,ce[Ue]=je,ce[Ge]=He;var Xe=function(){function n(){var e;s(this,n);for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return(e=c(this,n,[].concat(i))).cmpStatus=Ce.ERROR,e}return e(n,ke),t(n)}(),qe=function(){return t(function e(){s(this,e)},null,[{key:"has",value:function(e){return"string"==typeof e&&(e=Number(e)),this.set_.has(e)}}])}();qe.set_=new Set([0,2,void 0,null]);var ze="__tcfapi",Je=function(){return t(function e(t){if(s(this,e),t){var n=pe.ADD_EVENT_LISTENER;if(null!=t&&t[n])throw new Error("Built-In Custom Commmand for ".concat(n," not allowed: Use ").concat(pe.GET_TC_DATA," instead"));if(n=pe.REMOVE_EVENT_LISTENER,null!=t&&t[n])throw new Error("Built-In Custom Commmand for ".concat(n," not allowed"));null!=t&&t[pe.GET_TC_DATA]&&(t[pe.ADD_EVENT_LISTENER]=t[pe.GET_TC_DATA],t[pe.REMOVE_EVENT_LISTENER]=t[pe.GET_TC_DATA]),this.customCommands=t}try{this.callQueue=window[ze]()||[]}catch(i){this.callQueue=[]}finally{window[ze]=this.apiCall.bind(this),this.purgeQueuedCalls()}},[{key:"apiCall",value:function(e,t,s){for(var n,i=arguments.length,r=new Array(i>3?i-3:0),a=3;a<i;a++)r[a-3]=arguments[a];if("string"!=typeof e&&"function"==typeof s)s(null,!1);else if(qe.has(t)){if("function"!=typeof s)throw new Error("invalid callback function");De.disabled?s(new Xe,!1):this.isCustomCommand(e)||this.isBuiltInCommand(e)?this.isCustomCommand(e)&&!this.isBuiltInCommand(e)?(n=this.customCommands)[e].apply(n,[s].concat(r)):e===pe.PING?this.isCustomCommand(e)?new We[e](this.customCommands[e],r[0],null,s):new We[e](s,r[0]):void 0===De.tcModel?this.callQueue.push([e,t,s].concat(r)):this.isCustomCommand(e)&&this.isBuiltInCommand(e)?new We[e](this.customCommands[e],r[0],null,s):new We[e](s,r[0]):s(null,!1)}else s(null,!1)}},{key:"purgeQueuedCalls",value:function(){var e=this.callQueue;this.callQueue=[],e.forEach(function(e){var t;(t=window)[ze].apply(t,n(e))})}},{key:"isCustomCommand",value:function(e){return this.customCommands&&"function"==typeof this.customCommands[e]}},{key:"isBuiltInCommand",value:function(e){return void 0!==We[e]}}])}(),Ye=function(){return t(function e(t,n){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3?arguments[3]:void 0;s(this,e),this.numUpdates=0,this.throwIfInvalidInt(t,"cmpId",2),this.throwIfInvalidInt(n,"cmpVersion",0),De.cmpId=t,De.cmpVersion=n,De.tcfPolicyVersion=5,this.isServiceSpecific=!!i,this.callResponder=new Je(r)},[{key:"throwIfInvalidInt",value:function(e,t,s){if(!("number"==typeof e&&Number.isInteger(e)&&e>=s))throw new Error("Invalid ".concat(t,": ").concat(e))}},{key:"update",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=arguments.length>2?arguments[2]:void 0;if(De.disabled)throw new Error("CmpApi Disabled");De.cmpStatus=Ce.LOADED,t?(De.displayStatus=be.VISIBLE,De.eventStatus=Se.CMP_UI_SHOWN):void 0===De.tcModel?(De.displayStatus=be.DISABLED,De.eventStatus=Se.TC_LOADED):(De.displayStatus=be.HIDDEN,De.eventStatus=Se.USER_ACTION_COMPLETE),De.gdprApplies=null!==e,De.gdprApplies?(""===e?(De.tcModel=new a,De.tcModel.cmpId=De.cmpId,De.tcModel.cmpVersion=De.cmpVersion):De.tcModel=o.decode(e),De.tcModel.addtlConsent=s||"",De.tcModel.enableAdvertiserConsentMode=De.enableAdvertiserConsentMode,De.tcModel.isServiceSpecific=this.isServiceSpecific,De.tcfPolicyVersion=Number(De.tcModel.policyVersion),De.tcString=e):De.tcModel=null,0===this.numUpdates?this.callResponder.purgeQueuedCalls():De.eventQueue.exec(),this.numUpdates++}},{key:"disable",value:function(){De.disabled=!0,De.cmpStatus=Ce.ERROR}}])}(),Ke=function(){function r(e,t,n,i,a,o,u,d){var l;s(this,r),l=c(this,r,[n,a]),A(l,"acmData",void 0),A(l,"advertiserConsentModeEnabled",void 0),A(l,"gcmEnabled",!1),A(l,"changedPurposes",void 0),A(l,"cmpId",void 0),A(l,"cmpVersion",void 0),A(l,"consensuScriptPath",void 0),A(l,"consensuSubdomain",void 0),A(l,"disabledSpecialFeatures",void 0),A(l,"gdprApplies",void 0),A(l,"hideLegitimateInterestToggles",void 0),A(l,"isAnalyticsEnabled",void 0),A(l,"isApiV2Enabled",void 0),A(l,"isConsentXDeviceEnabled",void 0),A(l,"publisherCountryCode",void 0),A(l,"purposeOneTreatment",void 0),A(l,"resurfaceOptions",void 0),A(l,"resurfacePeriodInDays",void 0),A(l,"stackIds",void 0),A(l,"tcfv2HistoryDisabled",void 0),A(l,"useGranularChoice",void 0),A(l,"vendorIds",void 0),A(l,"vendorIdsOutsideEUList",void 0),A(l,"dataRetentionLabel",void 0),A(l,"policyVersion",5),A(l,"dataTransferSettings",void 0),A(l,"locationInstance",T.getInstance()),A(l,"botInstance",D.getInstance()),A(l,"previousStorage",null),A(l,"selectedVendorsIncludeNonDisclosed",!1),A(l,"cmpApi",{}),A(l,"tcModel",null),A(l,"tcfData",null),A(l,"vendors",[]),A(l,"selectedLanguage",void 0),A(l,"excludeAcceptAllVendors",void 0),A(l,"enableDeprecatedV1ConsentSaving",void 0);var h=e.tcf2,p=h.acmV2Enabled,v=h.advertiserConsentModeEnabled,f=h.atpPurposes,m=h.changedPurposes,g=h.cmpId,I=h.cmpVersion,C=h.consensuDomain,y=h.consensuScriptPath,b=h.dataRetentionPeriodLabel,E=h.disabledSpecialFeatures,S=h.firstLayerHideToggles,V=h.gdprApplies,U=h.hideLegitimateInterestToggles,G=h.publisherCountryCode,Q=h.purposeOneTreatment,x=h.secondLayerHideToggles,B=h.selectedStacks,j=h.selectedVendorIds,H=h.selectedATPIds,W=h.tcfv2HistoryDisabled,X=h.vendorIdsOutsideEUList,q=h.version,z=e.googleConsentMode;return l.acmData={isEnabled:!0===p,vendorIds:p&&H||[],vendorsPurposes:p&&f?M(f):[]},l.advertiserConsentModeEnabled=v,l.gcmEnabled=!0===z,l.changedPurposes=k(m),l.cmpId=g||5,l.cmpVersion=I||L(),l.policyVersion="2.0"===q||"2.1"===q?2:5,l.consensuScriptPath=w(y),l.consensuSubdomain=P(C),l.dataRetentionLabel=b,l.disabledSpecialFeatures=E||[],l.gdprApplies=_(V,!1),l.hideLegitimateInterestToggles=U,l.isAnalyticsEnabled=!0===e.consentAnalytics,l.isApiV2Enabled=!0===e.consentAPIv2,l.isConsentXDeviceEnabled=!0===e.consentXDevice,l.publisherCountryCode=G||"DE",l.purposeOneTreatment=_(Q,!1),l.resurfaceOptions=R(t),l.resurfacePeriodInDays=O(t.resurfacePeriod),l.stackIds=B||[],l.tcfv2HistoryDisabled=W,l.useGranularChoice=N(S,x),l.vendorIds=j||[],l.vendorIdsOutsideEUList=X||[],l.selectedLanguage=F(o),l.enableDeprecatedV1ConsentSaving=d,l.cmpApi=new Ye(l.cmpId,l.cmpVersion,!0),l.dataTransferSettings=i,l.excludeAcceptAllVendors=u,l}return e(r,ae),t(r,[{key:"updateControllerId",value:function(e){this.dataTransferSettings.controllerId=e}},{key:"applySpecialCasesForVendors",value:function(){var e=this;this.tcModel&&Object.values(this.vendors).forEach(function(t){var s=t.id;if(e.tcModel){var n=e.tcModel.gvl.vendors[s];(n&&0===n.purposes.length&&0===n.legIntPurposes.length&&n.specialPurposes.length>0||n&&n.purposes.length>0&&0===n.legIntPurposes.length&&n.specialPurposes.length>0)&&e.tcModel.vendorLegitimateInterests.set(s)}})}},{key:"acceptAllDisclosed",value:(Se=U(G().m(function e(t){var s,n,i,r=this;return G().w(function(e){for(;;)switch(e.n){case 0:if(s=this.tcModel){e.n=1;break}return e.a(2);case 1:return this.acmData.isEnabled&&this.acmData.vendors&&(this.acmData.vendors=this.acmData.vendors.map(function(e){return Q(Q({},e),{},{consent:{status:!0}})})),n=[],i=[],this.getVendors().forEach(function(e){var t=e.id,a=e.legitimateInterestPurposes,o=e.purposes,c=e.specialPurposes,u=-1===r.excludeAcceptAllVendors.indexOf(t);o.length?(u&&s.vendorConsents.set(t),n=n.concat(o.map(function(e){return e.id}))):u&&s.vendorConsents.unset(t),a.length||c.length&&0===a.length&&0===o.length?(u&&s.vendorLegitimateInterests.set(t),i=i.concat(a.map(function(e){return e.id}))):u&&s.vendorLegitimateInterests.unset(t)}),s.purposeConsents.set(x(n)),s.publisherConsents.set(x(n)),s.purposeLegitimateInterests.set(x(i)),s.publisherLegitimateInterests.set(x(i)),this.hideLegitimateInterestToggles&&(s.unsetAllVendorLegitimateInterests(),s.unsetAllPurposeLegitimateInterests()),this.applySpecialCasesForVendors(),s.specialFeatureOptins.set(B(this.getVendors(),this.disabledSpecialFeatures)),this.tcModel=s,e.n=2,this.updateTCString(t);case 2:return e.a(2)}},e,this)})),function(e){return Se.apply(this,arguments)})},{key:"areAllPurposesAccepted",value:function(){var e,t;return u(this.tcModel,null===(e=this.tcModel)||void 0===e?void 0:e.gvl.stacks,null===(t=this.tcModel)||void 0===t?void 0:t.gvl.purposes,this.vendors,this.disabledSpecialFeatures,this.stackIds,this.purposeOneTreatment,this.useGranularChoice,this.hideLegitimateInterestToggles).every(function(e){var t=!0,s=!0;return e.showConsentToggle&&null!==e.consent&&(t=e.consent),e.showLegitimateInterestToggle&&null!==e.legitimateInterestConsent&&(s=e.legitimateInterestConsent),t&&s})}},{key:"areAllVendorsAccepted",value:function(){return this.getVendors().every(function(e){var t=!0,s=!0;return e.showConsentToggle&&null!==e.consent&&(t=e.consent),e.showLegitimateInterestConsentToggle&&null!==e.legitimateInterestConsent&&(s=e.legitimateInterestConsent),t&&s})}},{key:"changeLanguage",value:(Ee=U(G().m(function e(t,s){var n,i,r,a=this;return G().w(function(e){for(;;)switch(e.n){case 0:return n=F(t),e.n=1,this.resetGVLWithLanguage("en"===n?"".concat(n,"-v2"):n);case 1:s&&(this.dataRetentionLabel=s.dataRetentionPeriodLabel,s.acmV2Enabled&&s.atpPurposes&&(this.acmData.vendorsPurposes=M(s.atpPurposes),r=null===(i=this.acmData.vendors)||void 0===i?void 0:i.map(function(e){return Q(Q({},e),{},{purposes:a.acmData.vendorsPurposes})}),this.acmData.vendors=r)),this.tcModel&&this.tcModel.gvl.narrowVendorsTo(this.vendorIds),this.resetTcfData();case 2:return e.a(2)}},e,this)})),function(e,t){return Ee.apply(this,arguments)})},{key:"denyAllDisclosed",value:(be=U(G().m(function e(t){var s;return G().w(function(e){for(;;)switch(e.n){case 0:if(this.tcModel){e.n=1;break}return e.a(2);case 1:return this.acmData.isEnabled&&this.acmData.vendors&&(this.acmData.vendors=this.acmData.vendors.map(function(e){return Q(Q({},e),{},{consent:{status:!1}})})),this.tcModel.unsetAllVendorConsents(),this.tcModel.unsetAllVendorLegitimateInterests(),this.applySpecialCasesForVendors(),s=j(this.getVendors(),this.purposeOneTreatment),this.tcModel.purposeConsents.unset(s),this.tcModel.purposeLegitimateInterests.unset(s),this.tcModel.specialFeatureOptins.unset(B(this.getVendors(),this.disabledSpecialFeatures)),this.tcModel.publisherConsents.unset(s),this.tcModel.publisherLegitimateInterests.unset(s),e.n=2,this.updateTCString(t);case 2:return e.a(2)}},e,this)})),function(e){return be.apply(this,arguments)})},{key:"getSelectedVendorsIncludeNonDisclosed",value:function(){return this.selectedVendorsIncludeNonDisclosed}},{key:"getTcModel",value:function(){return this.tcModel}},{key:"getTCFData",value:function(){var e,t,s,n,i,r;this.tcfData||(this.tcfData={acmVendors:this.getAcmVendors(),features:d(this.getVendors(),null===(e=this.tcModel)||void 0===e||null===(e=e.gvl)||void 0===e?void 0:e.features),purposes:u(this.tcModel,null===(t=this.tcModel)||void 0===t?void 0:t.gvl.stacks,null===(s=this.tcModel)||void 0===s?void 0:s.gvl.purposes,this.getVendors(),this.disabledSpecialFeatures,this.stackIds,this.purposeOneTreatment,this.useGranularChoice,this.hideLegitimateInterestToggles),specialFeatures:l(this.tcModel,null===(n=this.tcModel)||void 0===n?void 0:n.gvl,this.getVendors(),this.disabledSpecialFeatures,this.stackIds,this.useGranularChoice),specialPurposes:h(null===(i=this.tcModel)||void 0===i||null===(i=i.gvl)||void 0===i?void 0:i.specialPurposes,this.getVendors()),stacks:p(null===(r=this.tcModel)||void 0===r||null===(r=r.gvl)||void 0===r?void 0:r.stacks,this.disabledSpecialFeatures,this.stackIds),vendors:this.getVendors()});return this.tcfData}},{key:"getGdprApplies",value:(ye=U(G().m(function e(){var t;return G().w(function(e){for(;;)switch(e.n){case 0:if(this.gdprApplies){e.n=1;break}return e.a(2,!0);case 1:return e.n=2,this.locationInstance.getIsUserInEU();case 2:return t=e.v,e.a(2,t)}},e,this)})),function(){return ye.apply(this,arguments)})},{key:"getACString",value:function(){var e;if(this.acmData.isEnabled&&null!==(e=this.acmData.vendors)&&void 0!==e&&e.length){var t=this.acmData.vendors.reduce(function(e,t){var s=e.consentedAcmVendorIds,n=e.disclosedAcmVendorIds;return t.consent.status?s.push(t.id):n.push(t.id),{consentedAcmVendorIds:s,disclosedAcmVendorIds:n}},{consentedAcmVendorIds:[],disclosedAcmVendorIds:[]}),s=t.consentedAcmVendorIds,n=t.disclosedAcmVendorIds;return"2~".concat(s.join("."),"~dv.").concat(n.join("."))}return""}},{key:"getTCString",value:function(e){return this.tcModel?o.encode(this.tcModel,e):""}},{key:"getTCFDisclosedVendorsSegmentString",value:function(){return this.getTCString({segments:[v.VENDORS_DISCLOSED]})}},{key:"init",value:(Ce=U(G().m(function e(t){var s,n;return G().w(function(e){for(;;)switch(e.n){case 0:return this.previousStorage=b.fetchTCFData(),s=b.fetchTCString()||"",n=b.fetchACString()||"",e.n=1,this.initTCModel({acString:n,tcString:s},t);case 1:this.botInstance.isRobot()&&this.acceptAllDisclosed(H.FIRST_LAYER);case 2:return e.a(2)}},e,this)})),function(e){return Ce.apply(this,arguments)})},{key:"setUIAsClosed",value:(Ie=U(G().m(function e(){return G().w(function(e){for(;;)if(0===e.n)return e.a(2,this.cmpApiUpdate(b.fetchTCString(),!1,b.fetchACString()))},e,this)})),function(){return Ie.apply(this,arguments)})},{key:"setUIAsOpen",value:(ge=U(G().m(function e(){return G().w(function(e){for(;;)if(0===e.n)return e.a(2,this.cmpApiUpdate(b.fetchTCString(),!0,b.fetchACString()))},e,this)})),function(){return ge.apply(this,arguments)})},{key:"shouldResurfaceUI",value:function(){var e=this.resurfaceOptions;return this.policyVersion>=4&&e.onATPListChanged&&f(this.previousStorage,this.getAcmVendors())||e.onVendorAdded&&m(this.previousStorage,this.getVendors())||e.onPurposeChanged&&g(this.previousStorage,this.getVendors())||e.onPeriodEnded&&I(this.previousStorage,this.resurfacePeriodInDays)}},{key:"updateChoices",value:(me=U(G().m(function e(t,s){var n=this;return G().w(function(e){for(;;)switch(e.n){case 0:if(!t.purposes){e.n=1;break}return e.n=1,this.savePurposes(t.purposes);case 1:if(!t.specialFeatures){e.n=2;break}return e.n=2,this.saveSpecialFeatures(t.specialFeatures);case 2:if(!t.vendors){e.n=3;break}return e.n=3,this.saveVendors(t.vendors);case 3:if(this.tcModel&&this.hideLegitimateInterestToggles&&(this.tcModel.unsetAllVendorLegitimateInterests(),this.tcModel.unsetAllPurposeLegitimateInterests()),this.applySpecialCasesForVendors(),t.acmVendors&&this.acmData.isEnabled&&this.acmData.vendors&&t.acmVendors.forEach(function(e){var t,s=null===(t=n.acmData.vendors)||void 0===t?void 0:t.find(function(t){return t.id===e.id});s&&(s.consent.status=e.consent)}),!(t.purposes||t.specialFeatures||t.vendors||t.acmVendors)){e.n=4;break}return e.n=4,this.updateTCString(s);case 4:return e.a(2)}},e,this)})),function(e,t){return me.apply(this,arguments)})},{key:"resetTcf",value:function(){this.cmpApi={},this.selectedVendorsIncludeNonDisclosed=!1,this.tcModel={},this.tcfData=null,this.vendors=[]}},{key:"applyPurposeRestrictions",value:function(e,t){var s=this;e.forEach(function(e){var n,i=new C(e,t);null===(n=s.tcModel)||void 0===n||n.publisherRestrictions.restrictPurposeToLegalBasis(i)})}},{key:"cmpApiUpdate",value:(fe=U(G().m(function e(t,s){var n,i,r=arguments;return G().w(function(e){for(;;)switch(e.n){case 0:return n=r.length>2&&void 0!==r[2]?r[2]:"",null==(i=W.getInstance())||i.setSectionString(t,"tcfeuv2"),e.n=1,this.getGdprApplies();case 1:if(!e.v){e.n=2;break}this.cmpApi.update(t,s,n),e.n=3;break;case 2:this.cmpApi.update(null);case 3:return e.a(2)}},e,this)})),function(e,t){return fe.apply(this,arguments)})},{key:"getVendors",value:function(){return y(this.vendors)||this.setVendors(),this.vendors}},{key:"initTCModel",value:(ve=U(G().m(function e(t,s){var r,c,u,d,l,h,p,v,f,m,g,I,C,y,b,E,S,V,A,T,D,M,k,L,w,P,_,R,O=this;return G().w(function(e){for(;;)switch(e.n){case 0:if(r=t.tcString,c=t.acString,!this.acmData.isEnabled||!this.acmData.vendorIds.length||this.acmData.vendors){e.n=1;break}if(u=[],c)try{u=c.split("~")[1].split(".").map(function(e){return parseInt(e,10)})}catch(N){}return d=se.getInstance(),e.n=1,d.fetchAcmVendors().then(function(e){var t=[];O.acmData.vendorIds.forEach(function(s){if(e.providers[s]){var n=ne(e.providers[s],2),i=n[0],r=n[1];t.push({consent:{status:u.some(function(e){return e===s})},id:s,name:i,privacyPolicyUrl:r,purposes:O.acmData.vendorsPurposes})}}),O.acmData.vendors=t});case 1:return this.isPolicyVersion2()?(i.baseUrl=s?z:J,i.languageFilename=Y,i.latestFilename=K):(i.baseUrl=s?Z:$,i.languageFilename=ee,i.latestFilename=te),e.n=2,se.getInstance().fetchVendorsList("".concat(i.baseUrl).concat(i.latestFilename),this.changedPurposes.notAllowedPurposes);case 2:if(l=e.v,h=new i(l),this.tcModel=new a(h),this.tcModel.cmpId=this.cmpId,this.tcModel.cmpVersion=this.cmpVersion,this.tcModel.isServiceSpecific=!0,this.tcModel.publisherCountryCode=this.publisherCountryCode,this.tcModel.purposeOneTreatment=this.purposeOneTreatment,this.gcmEnabled&&(p=void 0===this.advertiserConsentModeEnabled||this.advertiserConsentModeEnabled,v=void 0!==window.advertiserConsentMode?window.advertiserConsentMode:p,this.setEnableAdvertiserConsentMode(v)),this.acmData.isEnabled&&this.setAddtlConsent(c||""),r)try{if(f=this.tcModel.gvl,m=this.tcModel.publisherRestrictions,g=o.decode(r,this.tcModel),parseInt(g.policyVersion.toString(),10)>2){for(this.tcModel=g,this.isPolicyVersion2()||this.tcModel.purposeLegitimateInterests.unset([1,3,4,5,6]),I=this.tcModel.purposeConsents.values(),C=this.tcModel.purposeConsents.size,y=0;y<=C-1;y+=1)b=I.next().value,f.purposes[b]||null===(E=this.tcModel)||void 0===E||E.purposeConsents.unset(b);for(S=this.tcModel.purposeLegitimateInterests.values(),V=this.tcModel.purposeLegitimateInterests.size,A=0;A<=V-1;A+=1)T=S.next().value,f.purposes[T]||null===(D=this.tcModel)||void 0===D||D.purposeLegitimateInterests.unset(T);this.tcModel=Object.assign(this.tcModel,{gvl:f,publisherRestrictions:m}),null==(M=W.getInstance())||M.setSectionString(r,"tcfeuv2")}}catch(U){console.warn(q.INIT_TCF_ERROR,U)}if(null!==this.tcModel){e.n=3;break}throw new Error(q.TC_MODEL_UNDEFINED);case 3:if(this.selectedLanguage){e.n=4;break}throw new Error(q.SELECTED_LANGUAGE_UNDEFINED);case 4:return e.n=5,this.tcModel.gvl.readyPromise.catch(function(e){console.warn(q.RESET_GVL_FAILURE,e)});case 5:return this.tcModel.gvl.narrowVendorsTo(this.vendorIds),k=n(this.tcModel.gvl.vendorIds),L=F(this.selectedLanguage),e.n=6,this.resetGVLWithLanguage("en"===L?"".concat(L,"-v2"):L);case 6:w=this.changedPurposes,P=w.purposes,_=w.legitimateInterestPurposes,R=w.notAllowedPurposes,this.applyPurposeRestrictions(P,X.REQUIRE_CONSENT),this.applyPurposeRestrictions(_,X.REQUIRE_LI),this.applyPurposeRestrictions(R,X.NOT_ALLOWED),this.setSelectedVendorsIncludeNonDisclosed(k);case 7:return e.a(2)}},e,this)})),function(e,t){return ve.apply(this,arguments)})},{key:"setEnableAdvertiserConsentMode",value:function(e){this.tcModel&&(this.tcModel.enableAdvertiserConsentMode=e),De.enableAdvertiserConsentMode=e}},{key:"setAddtlConsent",value:function(e){this.tcModel&&(this.tcModel.addtlConsent=e),De.addtlConsent=e}},{key:"resetGVLWithLanguage",value:(pe=U(G().m(function e(t){var s,n;return G().w(function(e){for(;;)if(0===e.n)return n=F(t),e.a(2,null===(s=this.tcModel)||void 0===s||null===(s=s.gvl)||void 0===s?void 0:s.changeLanguage(n).catch(function(e){console.warn(q.RESET_GVL_FAILURE,e)}))},e,this)})),function(e){return pe.apply(this,arguments)})},{key:"resetTcfData",value:function(){this.setVendors(),this.tcfData=null}},{key:"setSelectedVendorsIncludeNonDisclosed",value:function(e){var t=b.fetchTCFVendorsDisclosedObject();e.some(function(e){return!E(e,t)})&&(this.selectedVendorsIncludeNonDisclosed=!0)}},{key:"savePurposes",value:(he=U(G().m(function e(t){var s;return G().w(function(e){for(;;)switch(e.n){case 0:if(s=this.tcModel){e.n=1;break}return e.a(2);case 1:t.forEach(function(e){e.consent?(s.purposeConsents.set(e.id),s.publisherConsents.set(e.id)):(s.purposeConsents.unset(e.id),s.publisherConsents.unset(e.id)),e.legitimateInterestConsent?(s.purposeLegitimateInterests.set(e.id),s.publisherLegitimateInterests.set(e.id)):(s.purposeLegitimateInterests.unset(e.id),s.publisherLegitimateInterests.unset(e.id))});case 2:return e.a(2)}},e,this)})),function(e){return he.apply(this,arguments)})},{key:"saveSpecialFeatures",value:(le=U(G().m(function e(t){var s;return G().w(function(e){for(;;)switch(e.n){case 0:if(s=this.tcModel){e.n=1;break}return e.a(2);case 1:t.forEach(function(e){e.consent?s.specialFeatureOptins.set(e.id):s.specialFeatureOptins.unset(e.id)});case 2:return e.a(2)}},e,this)})),function(e){return le.apply(this,arguments)})},{key:"saveVendors",value:(de=U(G().m(function e(t){var s;return G().w(function(e){for(;;)switch(e.n){case 0:if(s=this.tcModel){e.n=1;break}return e.a(2);case 1:t.forEach(function(e){e.consent?s.vendorConsents.set(e.id):s.vendorConsents.unset(e.id),e.legitimateInterestConsent?s.vendorLegitimateInterests.set(e.id):s.vendorLegitimateInterests.unset(e.id)});case 2:return e.a(2)}},e,this)})),function(e){return de.apply(this,arguments)})},{key:"setVendors",value:function(){this.vendors=S(this.tcModel,this.disabledSpecialFeatures,this.useGranularChoice,this.hideLegitimateInterestToggles,this.purposeOneTreatment,this.vendorIdsOutsideEUList,this.dataRetentionLabel)}},{key:"getTcfData",value:function(){return{acString:this.getACString(),tcString:this.getTCString(),timestamp:Date.now(),vendors:V(this.getVendors())}}},{key:"injectTCString",value:(ue=U(G().m(function e(t){var s,n;return G().w(function(e){for(;;)switch(e.n){case 0:if(s=o.decode(t),this.isPolicyVersion2()||s.purposeLegitimateInterests.unset([1,3,4,5,6]),!(this.tcModel&&s.lastUpdated>=this.tcModel.lastUpdated)){e.n=2;break}return n=this.getTcfData(),b.saveTCFData(Q(Q({},n),{},{tcString:t})),e.n=1,this.saveTCFData(n);case 1:return e.a(2,!0);case 2:return e.a(2,!1)}},e,this)})),function(e){return ue.apply(this,arguments)})},{key:"isPolicyVersion2",value:function(){return 2===this.policyVersion}},{key:"saveTCFData",value:(ce=U(G().m(function e(t){var s;return G().w(function(e){for(;;)if(0===e.n)return s=se.getInstance(),e.a(2,s.saveTCFConsents(this.dataTransferSettings,t,ie.TCF_STRING_CHANGE,re.EXPLICIT,this.isApiV2Enabled?{isAnalyticsEnabled:this.isAnalyticsEnabled,isConsentAPIv2Enabled:this.isConsentXDeviceEnabled}:null,this.enableDeprecatedV1ConsentSaving))},e,this)})),function(e){return ce.apply(this,arguments)})},{key:"updateTCString",value:(oe=U(G().m(function e(t){var s;return G().w(function(e){for(;;)switch(e.n){case 0:return this.tcModel&&(this.isPolicyVersion2()||this.tcModel.purposeLegitimateInterests.unset([1,3,4,5,6]),this.tcModel.consentScreen=t,this.tcModel.updated()),s=this.getTcfData(),b.saveTCFData(s),e.n=1,this.cmpApiUpdate(s.tcString,!1,s.acString);case 1:if(this.resetTcfData(),this.botInstance.isRobot()){e.n=2;break}return e.n=2,this.saveTCFData(s);case 2:return e.a(2)}},e,this)})),function(e){return oe.apply(this,arguments)})},{key:"getVendorsCount",value:function(){return(this.getVendors().length||0)+this.getAcmVendorsCount()}},{key:"getAcmVendors",value:function(){return this.acmData.vendors||[]}},{key:"getAcmVendorsCount",value:function(){return this.getAcmVendors().length||0}}]);var oe,ce,ue,de,le,he,pe,ve,fe,me,ge,Ie,Ce,ye,be,Ee,Se}();export{Ke as default};