(function(){"use strict";var e=u8._;u8.Crm.SignatureDemoParser=function(e){this.SignatureParser(e)};$.extend(u8.Crm.SignatureDemoParser.prototype,{parseSignature:function(a,i){var t={};function r(){for(var e=0;e<f.length;e++){if(f[e].special){f[e].available=false}}}function n(a,i){var t=f.find(e.eq("id",a));if(t){t.available=i===false?i:true}}function l(e){var a=e.match(/(Herr|Mr\.?)?\s*(Frau|Mrs\.?|Ms\.?|Miss)?\s*(Dr\.?)?\s*(\s*Dipl\.? Ing\.?|\s*Mag\.?|\s*Ing.?)*\s*(.[^,]+)(,(\s\w+)*)?/i);if(!a){return}if(a[1]){t["Gender"]="Male";t["Prefix"]=a[1]}if(a[2]){t["Gender"]="Female";t["Prefix"]=a[2]}if(a[3]){t["Prefix"]=a[3]}var i=[];if(a[4]){if(typeof a[4]=="string"){i.push(a[4])}else{for(var r=0;r<a[4].length;r++){if(a[4][r]&&a[4][r].length>0){i.push(a[4][r])}}}}if(a[5]){var n=a[5].match(/^(\w+)\s*(.+)/);if(n){t["First name"]=n[1];t["Last name"]=n[2]}}if(a[7]){a=a[7].split(/\s+/);for(r=0;a&&r<a.length;r++){if(a[r]){i.push(a[r])}}}if(i.length>0){t["Academic titles"]=i.join(" ")}}var f=[{filter:/.+(?:\[at\]|@).+/i,available:true,fn:function(e){r();t["Email"]=e}},{filter:/(?:.+:\/\/)?.+\..{2,4}(?:\/|$|\s)/,available:true,fn:function(e){r();t["Web site"]=e}},{filter:/(?:fax:?)\s*(.+)/i,available:true,fn:function(e){r();var a=e.match(this.filter);if(a.length>=1){t["Fax"]=a[1]}}},{filter:/(?:handy:?|mobile?:?|cell:?)\s*(.+)/i,available:true,fn:function(e){r();var a=e.match(this.filter);if(a.length>=1){t["Mobile phone"]=a[1]}}},{filter:/(?:telefon:?|telephone:?|phone:?|tel:?)\s*(.+)/i,available:true,fn:function(e){r();var a=e.match(this.filter);if(a.length>=1){t["Phone"]=a[1]}n("unprefixedTel",false)}},{filter:/\w+\s+\d+/i,available:true,fn:function(e){this.available=false;r();t["Street address"]=e}},{filter:/(\d+)\s+(\w+)/i,available:true,fn:function(e){this.available=false;r();var a=e.match(this.filter);if(a.length>=1){t["ZIP/Postal code"]=a[1]}if(a.length>=2){t["Place name"]=a[2]}n("country")}},{id:"unprefixedTel",filter:/\s*[+]?\d+/i,available:true,fn:function(e){r();t["Phone"]=e}},{id:"country",special:true,filter:/\w+/,available:false,fn:function(e){this.available=false;r();t["Country"]=e}},{id:"personName",filter:/\w+/,available:true,fn:function(e){this.available=false;r();t["Name"]=e;n("personTitle")}},{id:"personTitle",special:true,filter:/\w+/,available:true,fn:function(e){this.available=false;r();t["Title"]=e}},{id:"companyName",filter:/\w+/,available:true,fn:function(e){this.available=false;r();t["Company"]=e}}];a.text.split(/[\n|]+/).map($.trim).filter(e.trueish).forEach(function(e){var a=f.find(function(a){return a.available&&a.filter.test(e)});if(a){a.fn(e)}});if(!t["Company"]&&t["Name"]){t["Company"]=t["Name"];delete t["Name"]}if(t["Name"]){l(t["Name"])}return i&&i({signature:t})}});u8.Crm.SignatureDemoParser.makeClass({name:"SignatureDemoParser",deriveFrom:u8.Crm.SignatureParser});u8.using({types:"DataQuality"},function(){u8.services.dataQuality.signatureParser=new u8.Crm.SignatureDemoParser})})();