(function(n,t,i){var r=function(t){var i={Version:9,ServerUrl:t+"//api.webfont.com/webfont/fastjsPost",MD5UrlTemplate:t+"//vip-youzikuwebfont.oss-cn-beijing.aliyuncs.com/selectors/webUrl/",CdnMD5UrlTemplate:t+"//cdn.repository.webfont.com/selectors/webUrl/",OSSBlackListUrlTemplate:t+"//youziku.oss-cn-beijing.aliyuncs.com/userAuth/",Protocol:t,HttpMethod:{GET:"GET",POST:"POST"}},u={internalGlobalSettings:{fontfaceStyle:[]},drawed:!1,promises:[],localArray:[],remoteArray:[],applyFontfaceArray:[],fontfaceArray:[],isSync:!1,url:"",md5jsURl:"",preContents:[],adminContents:[],init:function(){var f=$youziku.UrlModule.getUrl(!1),t,r;if($youziku.UrlModule.loadSync){t=encodeURI(decodeURI($youziku.UrlModule.getSubmitUrl(f)));this.url=t;var u=$youziku.Md5Module.encrypt(t),e=i.CdnMD5UrlTemplate+u+".js",o=i.MD5UrlTemplate+u+".js";this.requestAndRunMd5js(e);this.md5jsURl=o}r=this;n.addEventListener?n.addEventListener("load",function(){r.checkLoad()}):n.attachEvent("onload",function(){r.checkLoad()})},submitToServer:function(){var i=0,n=[],u,f,e,c,l,o,t,s,a,h,r;for(t in this.localArray)(u=this.preContents[this.localArray[t].selector],u==undefined&&(u=""),f=this.adminContents[this.localArray[t].selector],f==undefined&&(f=""),e=$youziku.TextModule.getText(this.localArray[t].selector,u+f),c=$youziku.Md5Module.encrypt(e),e!=="")&&(undefined==this.remoteArray[t]||c!==this.remoteArray[t].contentMd5||this.localArray[t].accessKey!==this.remoteArray[t].accessKey)&&(n.push({k:"s"+i,v:this.localArray[t].selector}),n.push({k:"k"+i,v:this.localArray[t].accessKey}),n.push({k:"a"+i,v:!0}),u!==""?(l=$youziku.TextModule.getText(this.localArray[t].selector,f),n.push({k:"m"+i,v:$youziku.Md5Module.encrypt(l)}),n.push({k:"t"+i,v:l})):(n.push({k:"m"+i,v:c}),n.push({k:"t"+i,v:e})),i++);o=[];for(t in this.remoteArray)t!==""&&undefined===this.localArray[t]&&(n.push({k:"s"+i,v:this.remoteArray[t].selector}),n.push({k:"k"+i,v:$youziku.TextModule.trim(this.remoteArray[t].accessKey)}),n.push({k:"a"+i,v:!1}),n.push({k:"m"+i,v:""}),n.push({k:"t"+i,v:""}),i++,o.push(t));for(s=0;s0){for(n.push({k:"num",v:i}),a=this.url?this.url:$youziku.UrlModule.getPageUrl(),n.push({k:"url",v:a}),h="",r=0;r=n.length-1?n[r].k+"="+encodeURIComponent($youziku.TextModule.trim(n[r].v)):n[r].k+"="+encodeURIComponent($youziku.TextModule.trim(n[r].v))+"&";location.hostname!==""&&location.hostname!=="localhost"&&location.hostname!=="127.0.0.1"?this.validateOSS(h):this.makeWebFont(h)}},checkLoad:function(){this.isSync?this.syncMode():this.asyncMode()},asyncMode:function(){if(!(this.promises.length<=0)){var n=this;Promise.all(n.promises).then(function(t){t.length===n.promises.length&&(n.isSync||(n.isSync=!0,n.syncMode()))},function(n){console.error("$youziku:"+n)})}},syncMode:function(){this.drawed||(this.drawed=!0,this.submitToServer())},makeWebFont:function(n){var t=this;$youziku.HttpModule.request(i.HttpMethod.POST,i.ServerUrl,!0,n,function(n){var i=JSON.parse(n);t.showMsg(i)},function(){})},validateOSS:function(n){var r=(new $youziku.PunycodeModule).toASCII(location.hostname),u=i.OSSBlackListUrlTemplate+$youziku.Md5Module.encrypt(r)+".backlist.json?rom="+Math.random(),t=this,f=function(n,t){navigator.userAgent.indexOf("Firefox")>=0&&n.setHours(n.getHours()+8);var i=new Date(t);return(navigator.userAgent.indexOf("Firefox")>=0&&i.setHours(i.getHours()+8),n.getTime()>i.getTime())?!0:!1};$youziku.HttpModule.request(i.HttpMethod.GET,u,!0,null,function(i){var r=JSON.parse(i),u=r.Expires.toString(),s=f(new Date,u),e=location.hostname,o;r.Host&&(e=r.Host);s?t.makeWebFont(n):(o={Code:403,Result:"warn",Value:"'"+e+"'请求过于频繁!已被系统拦截,在一段时间内将无法处理该页面的请求,预计"+u+"解除拦截!拦截原因:"+r.Reason},t.showMsg(o))},function(){t.makeWebFont(n)})},showMsg:function(n){console.log("%c有字库Api生成服务器响应:","color:#35bc73;font-size:23px;");var i=n.Result,t="green";i==="warn"||i==="null"?t="#FF7F24":i==="error"&&(t="red");console.log("\t%c code:"+n.Code," font-size:16px;color:"+t);console.log("\t%c errMsg:"+n.Value," font-size:16px;color:"+t);this.requestAndRunMd5js(this.md5jsURl+"?refreshToken="+Math.random())},requestAndRunMd5js:function(n){var t;$youziku.HttpModule.request(i.HttpMethod.GET,n,!1,null,function(n){t=n},function(){t="$youziku.verify('', '','');"});try{window.execScript(t)}catch(r){window.eval(t)}},writeContent:function(n,t){this.preContents[n]=t},appendContent:function(n,t){this.adminContents[n]=t},applyNewFontface:function(){var o,l,a,s,d,v,r,y,c,w,t,u,it,i,f,b,e,n,k;if(this.fontfaceArray)for(o=0;o>>32-t},f=function(n,t){var i=(n&65535)+(t&65535),r=(n>>16)+(t>>16)+(i>>16);return r<<16|i&65535},c=function(n){for(var i=Array(),r=(1<>5]|=(n.charCodeAt(t/e)&r)<>2]>>t%4*8+4&15)+i.charAt(n[t>>2]>>t%4*8&15);return r},a=function(n,e){var l;n[e>>5]|=128<>>9<<4)+14]=e;var o=1732584193,s=-271733879,h=-1732584194,c=271733878;for(l=0;l/g,"").replace(/.*?<\/script>/ig,"").replace(/.*?<\/select>/ig,"").replace(/<\/?[^>]*>/g,"").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"").replace(/ /g,"").replace(/"/g,'"').replace(/&/g,"").replace(/\s/g,"").replace("<","<=");return i=this.replaceEmoji(i),new RegExp("[A-Za-z]").test(i)&&(i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"+i),new RegExp("[0-9]").test(i)&&(i="0123456789"+i),i=this.removeDuplicate2(i),i.split("").sort(function(n,t){return n.charCodeAt(0)-t.charCodeAt(0)}).join("")},replaceEmoji:function(n){return n.replace(/[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\\A9|\\AE]\u3030|\\uA9|\\uAE|\u3030/ig,"")}},FontfaceModule:{remove:function(n){var f=t.getElementsByTagName("head")[0],r,i,u;try{for(r=t.getElementsByTagName("style"),i=0;i1&&(r=i[0]+"@",n=i[1]),n=n.replace(d,"."),u=n.split("."),f=l(u,t).join("."),r+f}function nt(n){for(var r=[],i=0,f=n.length,t,u;i=55296&&t<=56319&&i65535&&(n-=65536,t+=f(n>>>10&1023|55296),n=56320|n&1023),t+f(n)}).join("")}function it(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:n}function v(n,t){return n+22+75*(n<26)-((t!=0)<<5)}function y(i,r,f){var e=0;for(i=f?t(i/w):i>>1,i+=t(i/r);i>o*u>>1;e+=n)i=t(i/o);return t(e+(o+1)*i/(i+p))}function rt(f){var k=[],et=f.length,a,o=0,nt=h,d=s,l,v,g,rt,p,w,b,ut,ft;for(l=f.lastIndexOf(c),l<0&&(l=0),v=0;v=128&&i("not-basic"),k.push(f.charCodeAt(v));for(g=l>0?l+1:0;g=et&&i("invalid-input"),b=it(f.charCodeAt(g++)),(b>=n||b>t((r-o)/p))&&i("overflow"),o+=b*p,ut=w<=d?e:w>=d+u?u:w-d,bt(r/ft)&&i("overflow");p*=ft}a=k.length+1;d=y(o-rt,a,rt==0);t(o/a)>r-nt&&i("overflow");nt+=t(o/a);o%=a;k.splice(o++,0,nt)}return tt(k)}function ut(o){var p,w,d,et,g,l,b,tt,it,rt,a,k=[],ut,ft,ot,st;for(o=nt(o),ut=o.length,p=h,w=0,g=s,l=0;l=p&&at((r-w)/ft)&&i("overflow"),w+=(b-p)*ft,p=b,l=0;lr&&i("overflow"),a==p){for(tt=w,it=n;;it+=n){if(rt=it<=g?e:it>=g+u?u:it-g,tt= 0x80 (not a basic code point)","invalid-input":"Invalid input"},o=n-e,t=Math.floor,f=String.fromCharCode;this.toUnicode=function(n){return a(n,function(n){return b.test(n)?rt(n.slice(4).toLowerCase()):n})};this.toASCII=function(n){return a(n,function(n){return k.test(n)?"xn--"+ut(n):n})}}this.toASCII=function(t){var i=new n;return i.toASCII(t)};this.toUnicode=function(t){var i=new n;return i.toUnicode(t)}},EnvironmentModule:{isMobile:function(){return/(iPhone|iPad|iPod|iOS|Android)/i.test(i.userAgent)}}};r.prototype.ApiModule.prototype=r.fn;u="https:"===document.location.protocol?"https:":"http:";n.$youziku=r(u);n.$webfont=n.$youziku;n.$youziku.run()})(window,document,navigator);