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B,OAAemB,GAC9B3C,EAAQY,IAAI,iBAAiB,MAAMkC,aAEtD,EAEG,OAAOpE,CACX","sources":["webpack:///./src/js/units/gdprutil.js"],"sourcesContent":["TNZ = window.TNZ || {};\n\n/******************************************\n * GDPR Utilities\n *\n * This file is responsible for the core parts of the GDPR functionality - namely\n * setting the opt-in cookie and detecting what country/locale the user is from or visiting\n *\n * There is a high-level description of how this works for the analytics team that needs\n * updating if any of this changes @see https://tourismnz.atlassian.net/wiki/spaces/SWPRJ/pages/1975123977/GDPR+Front-end+code+setup\n *\n * The following parameters are not relevant to the consumer site and are always set to 'global' and '1'.\n *\n * @param {string} optin_market - the market we are checking\n * some sites (not the consumer site) have different optin conditions (list of marketing providers), so the\n * user has to opt in for each market\n * @param {string} optin_version - this is the version of that markets optin.\n * If the list is updated, the version of that market should be incremented\n ****************************************/\nTNZ.GDPRUtil = function(optin_market,optin_version) {\n\tvar pub = {};\n\n\tvar optin_market_ = optin_market || 'global';\n\tvar optin_version_\t= optin_version || 1;\n\tvar self_\t= this;\n\n\t//cookie getting/setting/checking\n\n\t//list replicated in DTM eu_country_list data element\n\t//list of country codes (from Akamai COUNTRY_CODE cookie) that are considered to be part of the GDPR changes\n\tvar eu_country_list = 'AT,BE,BG,HR,CY,CZ,DK,EE,FI,FR,DE,GR,HU,IE,IT,LV,LT,LU,MT,NL,PL,PT,RO,SI,SK,ES,CH,GB,GI,NO,IS,LI,VA'.split(',');\n\n\t//relicated from DTM optin_in_eu data element\n\t//is the user in GDPR affected country?\n\tpub.in_eu = function(){\n\t\t\tvar b = eu_country_list.indexOf( _getCountryCode()) !== -1; //list of akamai EU country codes\n\t\t\treturn  b;\n\t}\n\n\t//call this function to set the user's cookie to allow\n\tpub.optin_allow = function(){\n\t\tvar now_ = new Date();\n\t\tnow_.setDate(now_.getDate() + 365);\n\t\tvar sDate = now_.getUTCFullYear() + \"-\" + (\"0\" + (now_.getUTCMonth() + 1)).slice(-2) + \"-\" + (\"0\" + now_.getUTCDate()).slice(-2);\n\n\t\tvar sValue = 'true,'+optin_version_+','+sDate+','+encodeURI(window.location.pathname);\n\n\t\t_cookie.set( _resolve_cookie_name() , sValue, 365 );\n\n\t}\n\n\t//call this function to set the user's cookie to deny\n\tpub.optin_deny = function(){\n\n\t\t_cookie.set( _resolve_cookie_name() , 'false,1,n-a', 0 );\n\n\n\t}\n\n\t//is the user currently opted in for the correct version\n\t// nameing to keep consistant with TNZ.DTM.getVar('optin_marketing');\n\tpub.optin_marketing = function(){\n\t\tvar bValue = _cookie_set();\n\n\t\tif( bValue ){\n\t\t\tvar aCookie = _optin_cookie().split(',');\n\n\t\t\tbValue = (\n\t\t\t\taCookie[0].toLowerCase() === 'true'\n\t\t\t\t&& parseInt( aCookie[1] ) === parseInt(optin_version_)\n\t\t\t);\n\t\t}\n\n\t\treturn bValue;\n\t}\n\n\t//is the cookie set?\n\tvar _cookie_set = function(){ return !!_optin_cookie(); }\n\tpub.cookie_set = _cookie_set;\n\n\tvar _optin_cookie = function(){\n\t\treturn _cookie.get(_resolve_cookie_name());\n\t}\n\tpub.optin_cookie = _optin_cookie;\n\n\tvar _resolve_cookie_name = function(){\n\t\treturn '__tnz_optin_marketing_' + optin_market_;\n\t}\n\n\t/***********************************\n\t * clears some 'window' level cached values\n\t * that the DTM may have cached\n\t * replicated from DTM dataelement \"optin_reset\"\n\t **********************************/\n\tvar _clearCachedValues = function(){\n\t\tvar a = [\n\t\t\t'__optin_in_eu',\n\t\t\t'__optin_marketing',\n\t\t\t'__optin_marketing_cookie',\n\t\t\t'__optin_marketing_cookie_set',\n\t\t\t'__load_marketing_tags'\n\t\t];\n\n\t\tfor( var i = a.length; i-- ; ){ delete window[ a[i] ]; }\n\n\t\treturn 'completed';\n\t}\n\n\tvar _cookie = {};\n\t\t// http://www.w3schools.com/js/js_cookies.asp\n\t\t_cookie.set = function(cname, cvalue, exdays ,domain) {\n\n\t\texdays = exdays || 0;\n\t\tdomain = domain || '';\n\n\t\tvar aData =[cname,'=',cvalue];\n\n\t\tif(exdays  !== 0 )\n\t\t{\n\t\t\tvar d = new Date();\n\t\t\tvar expires = \"\";\n\t\t\td.setDate(d.getDate() + exdays);\n\t\t\texpires = '; expires='+d.toUTCString();\n\t\t\taData.push(expires);\n\t\t}\n\t\taData.push('; path=/');\n\n\t\tif(domain.length !== 0 )\n\t\t{\n\t\t\tvar theDomain = '';\n\t\t\ttheDomain = \"; domain=\"+domain;\n\t\t\taData.push(theDomain);\n\t\t}\n\n\t\tif(_isHTTPS())\n\t\t{\n\t\t\taData.push('; secure');\n\t\t}\n\n\t\tdocument.cookie = aData.join('');\n\n\t\t_clearCachedValues();\n\t};\n\n\t_cookie.get = function(cname) {\n\t    var name = cname + \"=\";\n\t    var ca = document.cookie.split(';');\n\t    for(var i=0; i<ca.length; i++) {\n\t        var c = ca[i];\n\t        while (c.charAt(0)==' ') c = c.substring(1);\n            //if (c.indexOf(name) != -1) return c.substring(name.length, c.length);\n            if (c.indexOf(name) === 0) return c.substring(name.length, c.length); // MUST MATCH FROM START OF STRING.\n\t    }\n\t    return undefined;\n\t};\n\n\t_cookie.delete = function(cname,domain) {\n\t\tdomain = domain || '';\n\t    var d = new Date();\n\t    d.setTime(d.getTime() - 1);\n\t    var expires = \"expires=\"+d.toUTCString();\n\t\tvar secure = _isHTTPS() ? ';secure' : '';\n\t\tvar theDomain = '';\n\n\t\tif(domain.length !== 0 )\n\t\t{\n\t\t\ttheDomain = \";domain=\"+domain;\n\t\t}\n//\t    document.cookie = cname + \"=; \" + expires + secure + \" ;domain=.newzealand.com;path=/\";\n\t    document.cookie = cname + \"=; \" + expires + secure + \" \"+theDomain+\";path=/\";\n    };\n\n    var _isHTTPS = function(){\n\t\treturn document.location.protocol == 'https:' ? 1 : 0;\n    }\n\n    /**\n     * _getCountryCode()\n     * We can't be sure that TNZ.GeoLocation.getCountryCode(); will exist\n     * So use it if it's there, else we do our own local check, which is s duplicate of the\n     * TNZ.GeoLocation.getCountryCode(); function in geolocation.js\n     */\n    var _getCountryCode = function() {\n        if(!!TNZ.GeoLocation){\n            return TNZ.GeoLocation.getCountryCode();\n        }else{\n            var v = TNZ.Cookie.get('override_X-Country-Code');\n            if(v != undefined && v.length) return v;\n            return (_cookie.get(\"COUNTRY_CODE\")||'AA').toUpperCase();\n        }\n\t};\n\n    return pub;\n}\n"],"names":["TNZ","window","GDPRUtil","optin_market","optin_version","pub","optin_market_","optin_version_","eu_country_list","split","in_eu","indexOf","_getCountryCode","optin_allow","now_","Date","setDate","getDate","sDate","getUTCFullYear","getUTCMonth","slice","getUTCDate","sValue","encodeURI","location","pathname","_cookie","set","_resolve_cookie_name","optin_deny","optin_marketing","bValue","_cookie_set","aCookie","_optin_cookie","toLowerCase","parseInt","cookie_set","get","optin_cookie","cname","cvalue","exdays","domain","theDomain","aData","expires","d","toUTCString","push","length","_isHTTPS","document","cookie","join","a","i","_clearCachedValues","name","ca","c","charAt","substring","setTime","getTime","secure","protocol","GeoLocation","getCountryCode","v","Cookie","undefined","toUpperCase"],"sourceRoot":""}