var parseHttpHeaders;!function(n,t){var f=t.isDefined,r=t.isUndefined,e=t.isNumber,i=t.isObject,o=t.isArray,s=t.isString,h=t.extend,u=t.toJson;t.module("LocalStorageModule",[]).provider("localStorageService",function(){this.prefix="ls";this.storageType="localStorage";this.cookie={expiry:30,path:"/",secure:!1};this.defaultToCookie=!0;this.notify={setItem:!0,removeItem:!1};this.setPrefix=function(n){return this.prefix=n,this};this.setStorageType=function(n){return this.storageType=n,this};this.setDefaultToCookie=function(n){return this.defaultToCookie=!!n,this};this.setStorageCookie=function(n,t,i){return this.cookie.expiry=n,this.cookie.path=t,this.cookie.secure=i,this};this.setStorageCookieDomain=function(n){return this.cookie.domain=n,this};this.setNotify=function(n,t){return this.notify={setItem:n,removeItem:t},this};this.$get=["$rootScope","$window","$document","$parse","$timeout",function(n,t,c,l,a){function rt(i){if(i||(i=t.event),tt.setItem&&s(i.key)&&pt(i.key)){var r=st(i.key);a(function(){n.$broadcast("LocalStorageModule.notification.changed",{key:r,newvalue:i.newValue,storageType:v.storageType})})}}var b,v=this,y=v.prefix,nt=v.cookie,tt=v.notify,k=v.storageType,vt,yt;c?c[0]&&(c=c[0]):c=document;"."!==y.substr(-1)&&(y=y?y+".":"");var d=function(n){return y+n},st=function(n){return n.replace(new RegExp("^"+y,"g"),"")},pt=function(n){return 0===n.indexOf(y)},ht=function(){try{var i=k in t&&null!==t[k],r=d("__"+Math.round(1e7*Math.random()));return i&&(b=t[k],b.setItem(r,""),b.removeItem(r)),i}catch(u){return v.defaultToCookie&&(k="cookie"),n.$broadcast("LocalStorageModule.notification.error",u.message),!1}},p=ht(),ft=function(t,i,f){var e=g();try{if(w(f),i=r(i)?null:u(i),!p&&v.defaultToCookie||"cookie"===v.storageType)return p||n.$broadcast("LocalStorageModule.notification.warning","LOCAL_STORAGE_NOT_SUPPORTED"),tt.setItem&&n.$broadcast("LocalStorageModule.notification.setitem",{key:t,newvalue:i,storageType:"cookie"}),it(t,i);try{b&&b.setItem(d(t),i);tt.setItem&&n.$broadcast("LocalStorageModule.notification.setitem",{key:t,newvalue:i,storageType:v.storageType})}catch(o){return n.$broadcast("LocalStorageModule.notification.error",o.message),it(t,i)}return!0}finally{w(e)}},ct=function(t,i){var u=g(),r;try{if(w(i),!p&&v.defaultToCookie||"cookie"===v.storageType)return p||n.$broadcast("LocalStorageModule.notification.warning","LOCAL_STORAGE_NOT_SUPPORTED"),at(t);if(r=b?b.getItem(d(t)):null,!r||"null"===r)return null;try{return JSON.parse(r)}catch(f){return r}}finally{w(u)}},lt=function(){var u=g(),r,i,t;try{for(r=0,arguments.length>=1&&("localStorage"===arguments[arguments.length-1]||"sessionStorage"===arguments[arguments.length-1])&&(r=1,w(arguments[arguments.length-1])),i=0;i<arguments.length-r;i++)if(t=arguments[i],!p&&v.defaultToCookie||"cookie"===v.storageType)p||n.$broadcast("LocalStorageModule.notification.warning","LOCAL_STORAGE_NOT_SUPPORTED"),tt.removeItem&&n.$broadcast("LocalStorageModule.notification.removeitem",{key:t,storageType:"cookie"}),ut(t);else try{b.removeItem(d(t));tt.removeItem&&n.$broadcast("LocalStorageModule.notification.removeitem",{key:t,storageType:v.storageType})}catch(f){n.$broadcast("LocalStorageModule.notification.error",f.message);ut(t)}}finally{w(u)}},wt=function(t){var f=g(),i,r,u;try{if(w(t),!p)return n.$broadcast("LocalStorageModule.notification.warning","LOCAL_STORAGE_NOT_SUPPORTED"),[];i=y.length;r=[];for(u in b)if(u.substr(0,i)===y)try{r.push(u.substr(i))}catch(e){return n.$broadcast("LocalStorageModule.notification.error",e.Description),[]}return r}finally{w(f)}},bt=function(t,i){var o=g(),f,e,u,r;try{if(w(i),f=y?new RegExp("^"+y):new RegExp,e=t?new RegExp(t):new RegExp,!p&&v.defaultToCookie||"cookie"===v.storageType)return p||n.$broadcast("LocalStorageModule.notification.warning","LOCAL_STORAGE_NOT_SUPPORTED"),ot();if(!p&&!v.defaultToCookie)return!1;u=y.length;for(r in b)if(f.test(r)&&e.test(r.substr(u)))try{lt(r.substr(u))}catch(s){return n.$broadcast("LocalStorageModule.notification.error",s.message),ot()}return!0}finally{w(o)}},et=function(){try{return t.navigator.cookieEnabled||"cookie"in c&&(c.cookie.length>0||(c.cookie="test").indexOf.call(c.cookie,"test")>-1)}catch(i){return n.$broadcast("LocalStorageModule.notification.error",i.message),!1}}(),it=function(t,f,s,h){var y;if(r(f))return!1;if((o(f)||i(f))&&(f=u(f)),!et)return n.$broadcast("LocalStorageModule.notification.error","COOKIES_NOT_SUPPORTED"),!1;try{var a="",l=new Date,v="";(null===f?(l.setTime(l.getTime()+-864e5),a="; expires="+l.toGMTString(),f=""):e(s)&&0!==s?(l.setTime(l.getTime()+864e5*s),a="; expires="+l.toGMTString()):0!==nt.expiry&&(l.setTime(l.getTime()+864e5*nt.expiry),a="; expires="+l.toGMTString()),t)&&(y="; path="+nt.path,nt.domain&&(v="; domain="+nt.domain),"boolean"==typeof h?h===!0&&(v+="; secure"):nt.secure===!0&&(v+="; secure"),c.cookie=d(t)+"="+encodeURIComponent(f)+a+y+v)}catch(p){return n.$broadcast("LocalStorageModule.notification.error",p.message),!1}return!0},at=function(t){var f,r,i,u,e;if(!et)return n.$broadcast("LocalStorageModule.notification.error","COOKIES_NOT_SUPPORTED"),!1;for(f=c.cookie&&c.cookie.split(";")||[],r=0;r<f.length;r++){for(i=f[r];" "===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(d(t)+"=")){u=decodeURIComponent(i.substring(y.length+t.length+1,i.length));try{return e=JSON.parse(u),"number"==typeof e?u:e}catch(o){return u}}}return null},ut=function(n){it(n,null)},ot=function(){for(var r,n=null,u=y.length,i=c.cookie.split(";"),t=0;t<i.length;t++){for(n=i[t];" "===n.charAt(0);)n=n.substring(1,n.length);r=n.substring(u,n.indexOf("="));ut(r)}},g=function(){return k},w=function(n){return n&&k!==n&&(k=n,p=ht()),p},kt=function(n,t,r,u,e){u=u||t;var o=ct(u,e);return null===o&&f(r)?o=r:i(o)&&i(r)&&(o=h(o,r)),l(t).assign(n,o),n.$watch(t,function(n){ft(u,n,e)},i(n[t]))};return p&&(t.addEventListener?(t.addEventListener("storage",rt,!1),n.$on("$destroy",function(){t.removeEventListener("storage",rt)})):t.attachEvent&&(t.attachEvent("onstorage",rt),n.$on("$destroy",function(){t.detachEvent("onstorage",rt)}))),vt=function(n){var f=g();try{w(n);for(var r=0,u=t[k],i=0;i<u.length;i++)0===u.key(i).indexOf(y)&&r++;return r}finally{w(f)}},yt=function(n){y=n},{isSupported:p,getStorageType:g,setStorageType:w,setPrefix:yt,set:ft,add:ft,get:ct,keys:wt,remove:lt,clearAll:bt,bind:kt,deriveKey:d,underiveKey:st,length:vt,defaultToCookie:this.defaultToCookie,cookie:{isSupported:et,set:it,add:it,get:at,remove:ut,clearAll:ot}}}]})}(window,window.angular);!function(){"use strict";angular.module("angular-loading-bar",["chieffancypants.loadingBar"]);angular.module("chieffancypants.loadingBar",[]).config(["$httpProvider",function(n){var t=["$q","$cacheFactory","$timeout","$rootScope","cfpLoadingBar",function(t,i,r,u,f){function h(){r.cancel(c);f.complete();o=0;e=0}function s(t){var u,f=n.defaults,r;return"GET"!==t.method||t.cache===!1?(t.cached=!1,!1):(u=t.cache===!0&&void 0===f.cache?i.get("$http"):void 0!==f.cache?f.cache:t.cache,r=void 0!==u?void 0!==u.get(t.url):!1,void 0!==t.cached&&r!==t.cached?t.cached:(t.cached=r,r))}var c,e=0,o=0,l=f.latencyThreshold;return{request:function(n){return n.ignoreLoadingBar||s(n)||(u.$broadcast("cfpLoadingBar:loading",{url:n.url}),0===e&&(c=r(function(){f.start()},l)),e++,f.set(o/e)),n},response:function(n){return s(n.config)||(o++,u.$broadcast("cfpLoadingBar:loaded",{url:n.config.url}),o>=e?h():f.set(o/e)),n},responseError:function(n){return s(n.config)||(o++,u.$broadcast("cfpLoadingBar:loaded",{url:n.config.url}),o>=e?h():f.set(o/e)),t.reject(n)}}}];n.interceptors.push(t)}]).provider("cfpLoadingBar",function(){this.includeSpinner=!0;this.includeBar=!0;this.latencyThreshold=100;this.parentSelector="body";this.$get=["$document","$timeout","$animate","$rootScope",function(n,t,i,r){function y(){t.cancel(l);e||(r.$broadcast("cfpLoadingBar:started"),e=!0,d&&i.enter(o,a),k&&i.enter(v,a),u(.02))}function u(n){if(e){var i=100*n+"%";b.css("width",i);s=n;t.cancel(c);c=t(function(){h()},250)}}function h(){var t,n,i;f()>=1||(t=0,n=f(),t=n>=0&&.25>n?(3*Math.random()+3)/100:n>=.25&&.65>n?3*Math.random()/100:n>=.65&&.9>n?Math.random()/50:n>=.9&&.99>n?.005:0,i=f()+t,u(i))}function f(){return s}function p(){r.$broadcast("cfpLoadingBar:completed");u(1);l=t(function(){i.leave(o,function(){s=0;e=!1});i.leave(v)},500)}var c,l,w=this.parentSelector,a=n.find(w),o=angular.element('<div id="loading-bar"><div class="bar"><div class="peg"><\/div><\/div><\/div>'),b=o.find("div").eq(0),v=angular.element('<div id="loading-bar-spinner"><div class="spinner-icon"><\/div><\/div>'),e=!1,s=0,k=this.includeSpinner,d=this.includeBar;return{start:y,set:u,status:f,inc:h,complete:p,includeSpinner:this.includeSpinner,latencyThreshold:this.latencyThreshold,parentSelector:this.parentSelector}}]})}();var serviceBase="https://upi.thanhnien.vn/",imagesBase="https://images5.thanhnien.vn/",requires=["LocalStorageModule","angular-loading-bar"],app=angular.module("AuthUserTNApp",requires);app.constant("ngAuthSettings",{apiServiceBaseUri:serviceBase,apiImageBaseUri:imagesBase,clientId:"thanhnien"}).config(["$httpProvider",function(n){n.defaults.withCredentials=!0;n.interceptors.push("authInterceptorService")}]).run(["authService",function(n){n.fillAuthData()}]).directive("actualSrc",function(){return{link:function(n,t,i){i.$observe("actualSrc",function(n){if(n!==undefined){var r=new Image;r.src=i.actualSrc;angular.element(r).bind("load",function(){t.attr("src",i.actualSrc)})}})}}});$(".menu-nav a.item[href]").removeClass("active");$('.menu-nav a.item[href="'+window.location.pathname+'"]:not([href="#"])').addClass("active");var viewPass=function(n){var t=$(n).parent();t.find('[type="password"]').length?(t.find('[type="password"]').attr("type","text"),$(n).html('<svg class="icon-view eye-hide"><use xlink:href="#eye-hide"><\/use><\/svg>')):(t.find('[type="text"]').attr("type","password"),$(n).html('<svg class="icon-view eye-show"><use xlink:href="#eye-show"><\/use><\/svg>'))},eraseCookie=function(n){document.cookie=n+"=; Max-Age=0; path=/; domain=thanhnien.vn"},setCookie=function(n,t,i){const r=new Date;r.setTime(r.getTime()+i*864e5);let u="expires="+r.toUTCString();document.cookie=n+"="+t+";"+u+";path=/; domain=thanhnien.vn"},getCookie=function(n){function i(n){return n.replace(/([.*+?\^$(){}|\[\]\/\\])/g,"\\$1")}var t=document.cookie.match(RegExp("(?:^|;\\s*)"+i(n)+"=([^;]*)"));return t?t[1]:null},getQueryParam=function(n){var t=window.location.search.match(new RegExp("(\\?|&)"+n+"(\\[\\])?=([^&]*)"));return t?t[3]:undefined},timeSince=function(n){var i=Math.floor((new Date-new Date(n)+252e5)/1e3),t=i/31536e3;return t>1?Math.floor(t)+" năm trước":(t=i/2592e3,t>1)?Math.floor(t)+" tháng trước":(t=i/86400,t>1)?Math.floor(t)+" ngày trước":(t=i/3600,t>1)?Math.floor(t)+" giờ trước":(t=i/60,t>1)?Math.floor(t)+" phút trước":Math.floor(i)+" giây trước"},postMess=function(n){window.parent.postMessage(n,"*");window.webkit!=undefined&&window.webkit.messageHandlers.toggleMessagegeHandler.postMessage(n);window.JavaScriptInterfaceSDK&&window.JavaScriptInterfaceSDK.sendMess(JSON.stringify(n));console.log(n)};const validDate=n=>{if(!/^\d\d\/\d\d\/\d\d\d\d$/.test(n))return!1;const t=n.split("/").map(n=>parseInt(n,10));t[0]-=1;const i=new Date(t[2],t[0],t[1]);return i.getMonth()===t[0]&&i.getDate()===t[1]&&i.getFullYear()===t[2]},validEmail=n=>n.match(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),isWebview=()=>{if(typeof window=="undefined")return!1;if(typeof data!="undefined"&&data.wv==="1")return!0;const n=navigator.userAgent.toLowerCase();return/zalo/.test(n)},isZaloWebview=()=>{if(typeof window=="undefined")return!1;const n=navigator.userAgent.toLowerCase();return/zalo/.test(n)},inIframe=()=>{try{return window.self!==window.top}catch(n){return!0}};parseHttpHeaders=function(n){return n.split("\n").map(n=>n.split(/: */,2)).filter(n=>n[0]).reduce((n,t)=>n[t[0]]=t[1],n,{})};app.factory("authInterceptorService",["$q","$injector","$location","$window","localStorageService",function(n,t,i,r,u){var f={},e=function(n){n.headers=n.headers||{};var t=u.get("authorizationData");return t&&(n.headers.Authorization="Bearer "+t.token),n},o=function(f){if(f.status===401){var o=t.get("authService"),e=u.get("authorizationData");if(e&&e.useRefreshTokens)return i.path("/refresh"),n.reject(f);o.logOut();r.location.href="/app/login.html"}return n.reject(f)};return f.request=e,f.responseError=o,f}]);app.factory("authService",["$http","$q","localStorageService","ngAuthSettings",function(n,t,i,r){var e=r.apiServiceBaseUri,f={},u={isAuth:!1,userName:"",useRefreshTokens:!1},s=function(r){o();var f=t.defer();return n.post(e+"api/account/register",r).success(function(n){n.success&&(i.set("authorizationData",{token:n.data.access_token,userName:n.refId,refreshToken:"",useRefreshTokens:!1}),u.isAuth=!0,u.userName=n.refId,u.useRefreshTokens=!1,setCookie("my_tnoid",n.refId,30),setCookie("my_tnosso",n.data.access_token,30));f.resolve(n)}).error(function(n){f.reject(n)})},h=function(i){var r=t.defer();return n.post(e+"api/account/resetpassword",{email:i}).success(function(n){r.resolve(n)}).error(function(n){r.reject(n)})},c=function(i){var r=t.defer();return n.post(e+"api/account/active",{email:i}).success(function(n){r.resolve(n)}).error(function(n){r.reject(n)})},l=function(f){var h="email="+f.email+"&password="+f.password,s;return f.useRefreshTokens&&(h=h+"&client_id="+r.clientId),s=t.defer(),n.post(e+"api/account/login",h,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(n){n.success&&(f.useRefreshTokens?i.set("authorizationData",{token:n.data.access_token,userName:n.refId,refreshToken:n.data.refresh_token,useRefreshTokens:!0}):i.set("authorizationData",{token:n.data.access_token,userName:n.refId,refreshToken:"",useRefreshTokens:!1}),u.isAuth=!0,u.userName=n.refId,u.useRefreshTokens=f.useRefreshTokens,setCookie("my_tnoid",n.refId,30),setCookie("my_tnosso",n.data.access_token,30));s.resolve(n)}).error(function(n){o();s.reject(n)}),s.promise},a=function(f){var h="grant_type=password&username="+f.userName+"&password="+f.password,s;return f.useRefreshTokens&&(h=h+"&client_id="+r.clientId),s=t.defer(),n.post(e+"token",h,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(n){f.useRefreshTokens?i.set("authorizationData",{token:n.data.access_token,userName:n.refId,refreshToken:n.data.refresh_token,useRefreshTokens:!0}):i.set("authorizationData",{token:n.data.access_token,userName:n.refId,refreshToken:"",useRefreshTokens:!1});u.isAuth=!0;u.userName=n.refId;u.useRefreshTokens=f.useRefreshTokens;setCookie("my_tnoid",n.refId,30);setCookie("my_tnosso",n.data.access_token,30);s.resolve(n)}).error(function(n){o();s.reject(n)}),s.promise},o=function(){var r=t.defer();return n.post(e+"api/account/logout").success(function(n){r.resolve(n)}).error(function(n){r.reject(n)}),i.remove("authorizationData"),u.isAuth=!1,u.userName="",u.useRefreshTokens=!1,eraseCookie("_ck_user"+getCookie("my_tnoid")),eraseCookie("my_tnoid"),eraseCookie("my_tnosso"),r.promise},v=function(){var n=i.get("authorizationData");n&&(u.isAuth=!0,u.userName=n.userName,u.useRefreshTokens=n.useRefreshTokens)},y=function(){var u=t.defer(),f=i.get("authorizationData"),s;return f&&f.useRefreshTokens&&(s="grant_type=refresh_token&refresh_token="+f.refreshToken+"&client_id="+r.clientId,i.remove("authorizationData"),n.post(e+"token",s,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(n){i.set("authorizationData",{token:n.access_token,userName:n.userName,refreshToken:n.refresh_token,useRefreshTokens:!0});u.resolve(n)}).error(function(n){o();u.reject(n)})),u.promise},p=function(r){var f=t.defer();return n.get(e+"api/account/ObtainLocalAccessToken",{params:{provider:r.provider,externalAccessToken:r.externalAccessToken}}).success(function(n){n.success&&(i.set("authorizationData",{token:n.data.access_token,userName:n.refId,refreshToken:"",useRefreshTokens:!1}),setCookie("my_tnoid",n.refId,30),setCookie("my_tnosso",n.data.access_token,30));u.isAuth=!0;u.userName=n.refId;u.useRefreshTokens=!1;f.resolve(n)}).error(function(n){o();f.reject(n)}),f.promise},w=function(r){var f=t.defer();return n.post(e+"api/account/registerexternal",r).success(function(n){n.success&&(i.set("authorizationData",{token:n.data.access_token,userName:n.refId,refreshToken:"",useRefreshTokens:!1}),setCookie("my_tnoid",n.refId,30),setCookie("my_tnosso",n.data.access_token,30));u.isAuth=!0;u.userName=n.refId;u.useRefreshTokens=!1;f.resolve(n)}).error(function(n){o();f.reject(n)}),f.promise};return f.saveRegistration=s,f.commonLogin=l,f.login=a,f.logOut=o,f.fillAuthData=v,f.authentication=u,f.refreshToken=y,f.obtainAccessToken=p,f.externalAuthData={provider:"",userName:"",externalAccessToken:""},f.registerExternal=w,f.forgotPassword=h,f.active=c,f}]);app.factory("usersService",["$http","ngAuthSettings","localStorageService",function(n,t,i){var u=t.apiServiceBaseUri,r={},f=function(){return n.get(u+"api/users").then(function(n){return n})},e=function(){return typeof data!="undefined"&&data.user_id!==null&&(setCookie("my_tnoid",data.user_id,1),i.set("authorizationData",{token:data.access_token,userName:data.user_id,refreshToken:"",useRefreshTokens:!1})),n.get(u+"api/users/info").then(function(n){return n})},o=function(){return n.get(u+"api/users/addresses").then(function(n){return n})},s=function(t){return n.post(u+"api/users/comments",t).then(function(n){return n})},h=function(t){return n.post(u+"api/users/savenews",t).then(function(n){return n})},c=function(t){return n.post(u+"api/users/readnews",t).then(function(n){return n})},l=function(t){return n.post(u+"api/users/saveChanges",t).then(function(n){return n})},a=function(){return n.post(u+"api/users/sendconfirm").then(function(n){return n})},v=function(){return n.post(u+"api/users/delete").then(function(n){return n})},y=function(t){return n.post(u+"api/users/changePass",t).then(function(n){return n})};return r.get=f,r.getInfo=e,r.getComments=s,r.getSaveNews=h,r.getReadNews=c,r.getAddresses=o,r.sendConfirm=a,r.saveChanges=l,r.changePass=y,r.delete=v,r}])