import{ag as P,ah as _,ai as C,aj as G,ak as Q,al as W,am as K,an as M,ao as U,ap as I,aq as X,ar as Y,r as z,s as m,R as H,a5 as J,T as Z}from"./entry.1586686a.js";var j=4;function nn(n){return P(n,j)}var en="Expected a function";function an(n){if(typeof n!="function")throw new TypeError(en);return function(){var e=arguments;switch(e.length){case 0:return!n.call(this);case 1:return!n.call(this,e[0]);case 2:return!n.call(this,e[0],e[1]);case 3:return!n.call(this,e[0],e[1],e[2])}return!n.apply(this,e)}}function tn(n,e,t,a){if(!_(n))return n;e=C(e,n);for(var u=-1,s=e.length,c=s-1,r=n;r!=null&&++u<s;){var d=G(e[u]),v=t;if(d==="__proto__"||d==="constructor"||d==="prototype")return n;if(u!=c){var h=r[d];v=a?a(h,d,r):void 0,v===void 0&&(v=_(h)?h:Q(e[u+1])?[]:{})}W(r,d,v),r=r[d]}return n}function F(n,e,t){for(var a=-1,u=e.length,s={};++a<u;){var c=e[a],r=K(n,c);t(r,c)&&tn(s,C(c,n),r)}return s}function rn(n,e){if(n==null)return{};var t=M(U(n),function(a){return[a]});return e=I(e),F(n,t,function(a,u){return e(a,u[0])})}function ln(n,e){return rn(n,an(I(e)))}function sn(n,e){return F(n,e,function(t,a){return X(n,a)})}var on=Y(function(n,e){return n==null?{}:sn(n,e)});const un=on;var N={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"pickBrand"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"nick"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"soft"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"defaultbrandnick"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"hostname"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uri"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"pickBrand"},arguments:[{kind:"Argument",name:{kind:"Name",value:"nick"},value:{kind:"Variable",name:{kind:"Name",value:"nick"}}},{kind:"Argument",name:{kind:"Name",value:"soft"},value:{kind:"Variable",name:{kind:"Name",value:"soft"}}},{kind:"Argument",name:{kind:"Name",value:"defaultbrandnick"},value:{kind:"Variable",name:{kind:"Name",value:"defaultbrandnick"}}},{kind:"Argument",name:{kind:"Name",value:"hostname"},value:{kind:"Variable",name:{kind:"Name",value:"hostname"}}},{kind:"Argument",name:{kind:"Name",value:"uri"},value:{kind:"Variable",name:{kind:"Name",value:"uri"}}}],directives:[]}]}}],loc:{start:0,end:216}};N.loc.source={body:`query pickBrand($nick: String, $soft: String, $defaultbrandnick: String, $hostname: String, $uri: String) {
  pickBrand(nick: $nick, soft: $soft, defaultbrandnick: $defaultbrandnick, hostname: $hostname, uri: $uri)
}`,name:"GraphQL request",locationOffset:{line:1,column:1}};function y(n,e){if(n.kind==="FragmentSpread")e.add(n.name.value);else if(n.kind==="VariableDefinition"){var t=n.type;t.kind==="NamedType"&&e.add(t.name.value)}n.selectionSet&&n.selectionSet.selections.forEach(function(a){y(a,e)}),n.variableDefinitions&&n.variableDefinitions.forEach(function(a){y(a,e)}),n.definitions&&n.definitions.forEach(function(a){y(a,e)})}var b={};(function(){N.definitions.forEach(function(e){if(e.name){var t=new Set;y(e,t),b[e.name.value]=t}})})();function A(n,e){for(var t=0;t<n.definitions.length;t++){var a=n.definitions[t];if(a.name&&a.name.value==e)return a}}function dn(n,e){var t={kind:n.kind,definitions:[A(n,e)]};n.hasOwnProperty("loc")&&(t.loc=n.loc);var a=b[e]||new Set,u=new Set,s=new Set;for(a.forEach(function(r){s.add(r)});s.size>0;){var c=s;s=new Set,c.forEach(function(r){if(!u.has(r)){u.add(r);var d=b[r]||new Set;d.forEach(function(v){s.add(v)})}})}return u.forEach(function(r){var d=A(n,r);d&&t.definitions.push(d)}),t}const cn=dn(N,"pickBrand"),fn=n=>n?n==="index.html"||n==="/index.html"?"/":n.indexOf("/")===0?n:`/${n}`:"",w=n=>typeof n=="string"&&(n.startsWith("http:")||n.startsWith("https:")||n.startsWith("//")),q=n=>{const e=n.to||n.href;return e?w(e)?e:fn(e):!1};function vn(n){var S,x,E,V,D,T,$,B,L;const e=z(!1),t=(o,f,i)=>(i&&i.preventDefault(),f.push(o),!1),a=(o,f)=>{if(o.nick||o.soft)return{click:i=>m(e)?!1:h(o.nick,o.soft)};if(f){const i=q(o);if(!w(i))return{click:k=>t(i,f,k)}}return{}},u=(o,f)=>{var p,l;const i=nn(o),k=q(i);if(delete i.href,delete i.to,k&&typeof k=="string"&&(w(k)||f?i.href=k:i.to=k),i.class=(p=i.meta)!=null&&p.hideOn?[`d-${(l=i.meta)==null?void 0:l.hideOn}-none`]:i.class?[i.class]:[],!o.href&&!o.to){if(i.external=!0,i.rel="external nofollow noopener noreferrer",!i.nick&&!i.soft)return{custom:!0};i.class.push({ldsdualring:m(e)}),i.class.push("lead"),i.href="#"}return i.class.push("inner-link"),ln(f?un(i,["to","href","class"]):i,g=>!g)},s=H();let c=(x=(S=m(n))==null?void 0:S.download)==null?void 0:x.url;const r=(E=m(n))==null?void 0:E.defaultNick;(V=s.public)!=null&&V.matomo&&((T=(D=s.public)==null?void 0:D.matomo)==null||T.siteId),($=s.public)!=null&&$.gtm&&((L=(B=s.public)==null?void 0:B.gtm)==null||L.id);const d=async(o=null,f=null)=>{var g,O,R;if(c)return;const i=m(n).uri==="index.html"?"/":"/"+m(n).uri,k={nick:o,soft:f,defaultbrandnick:r,hostname:m(n).hostname,uri:i},{data:p}=await J(cn,k);if(!p||!Object.keys(p).length){console.log("pickBrand failed");return}const l=p.value.pickBrand;c=(l==null?void 0:l.download)||((g=l==null?void 0:l.downloads)==null?void 0:g.casino),window&&(!l||l.tracked)&&(((O=m(n).anl)==null?void 0:O.type)==="gtm"?(window.dataLayer=window.dataLayer??[]).push({event:"lead",brand:l.title,vendor:l.Vendor,price:l.popularity,content_type:m(n).typename}):((R=m(n).anl)==null?void 0:R.type)==="matomo"&&(window._paq=window._paq??[]).push(["trackEvent","downloads",l.title,l.Vendor,l.popularity]))},v=()=>{c?Z(c,{external:!0}):console.log("no url to redirect")},h=async(o=null,f=null)=>{e.value=!0,await d(o,f),setTimeout(()=>e.value=!1,2e4),v()};return{lead:h,loadingLead:()=>e,makeAttrs:u,makeClick:a,loading:e}}export{q as f,un as p,vn as u};
//# sourceMappingURL=useLead.c2ddd3c1.js.map
