import c from"react";const d=n=>{const{writeKey:t,trackPage:a,host:i="https://cdn.segment.io",includeTitleInPageCall:r=!0}=n,l=`(function () {
        let segmentPageviewCalledAlready = false;
        window.segmentPageviewCaller = function (force) {

          ${a!==!1?"":"return;"}
        
          if (!window.analytics) {
            return
          }
          if (segmentPageviewCalledAlready === true && !force) {
            return
          }
          segmentPageviewCalledAlready = true;
          window.analytics.page(${r?"document.title":""});
        };
      })();`;let e=`(function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src="${i}/analytics.js/v1/" + key + "/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._loadOptions=e};analytics._writeKey="${t}";analytics.SNIPPET_VERSION="4.15.3";
          analytics.load('${t}');
        `;a!==!1&&(e+="window.segmentPageviewCaller();"),e+="}})();";const s=`
        (function () {
          ${l}
          ${e}
        })();`;return c.createElement("script",{key:"plugin-segment",dangerouslySetInnerHTML:{__html:s}})};export{d as buildScript};
