text: "use strict";(self.webpackChunknetspeak=self.webpackChunknetspeak||[]).push([[691],{373:function(e,t,n){n.r(t),n.d(t,{default:function(){return D}});var a=n(7294),r=n(4578),i=n(1790),o=n(5785),s=n(5133);function u(e){var t,n,r=(0,s.B3)(e,c),i=function(t){var n=t.currentTarget.value,a=e.corpora.find((function(e){return e.key===n}));if(!a)throw new Error('Cannot find corpus with key "'+n+'".');e.onCorpusSelected(a)},u=(t=e.corpora,n=["en","de"],(0,o.Z)(t).sort((function(e,t){var a=n.indexOf(e.language),r=n.indexOf(t.language);return-1===a&&(a=n.length),-1===r&&(r=n.length),a-r}))),l=u.find((function(t){return t.key===e.selected}));if(!l&&u.length>0){var m=u[0];l=m,setTimeout((function(){e.onCorpusSelected(m)}),1)}var h=u.map((function(t){var n=[];return t===l&&n.push("selected"),e.unavailable.has(t)&&n.push("unavailable"),a.createElement("button",{key:t.key,className:n.join(" "),value:t.key,onClick:i},r("label-"+t.name.toLowerCase())||t.name)}));return a.createElement("div",{className:"NetspeakCorpusSelector"},a.createElement("div",{className:"wrapper"},h))}var c={en:{"label-english":"English","label-german":"German"},de:{"label-english":"Englisch","label-german":"Deutsch"}};function l(e){var t=(0,s.B3)(e,m);return a.createElement("div",{className:"AdditionalViewSelector"},a.createElement("div",{className:"wrapper"},a.createElement("button",{onClick:e.onClicked,className:e.active?"addon-shown":"addon-hidden"},a.createElement("img",{className:"view-button-image",src:"data:image/svg+xml;base64,PHN2ZyBhcmlhLWhpZGRlbj0idHJ1ZSIKICAgICBmb2N1c2FibGU9ImZhbHNlIiBkYXRhLXByZWZpeD0iZmFzIiBkYXRhLWljb249ImZsYXNrIgogICAgIGNsYXNzPSJzdmctaW5saW5lLS1mYSBmYS1mbGFzayBmYS13LTE0IgogICAgIHJvbGU9ImltZyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgNDQ4IDUxMiI+CiAgICA8cGF0aCBmaWxsPSIjMDA3NGE4IgogICAgICAgICAgZD0iTTQzNy4yIDQwMy41TDMyMCAyMTVWNjRoOGMxMy4zIDAgMjQtMTAuNyAyNC0yNFYyNGMwLTEzLjMtMTAuNy0yNC0yNC0yNEgxMjBjLTEzLjMgMC0yNCAxMC43LTI0IDI0djE2YzAgMTMuMyAxMC43IDI0IDI0IDI0aDh2MTUxTDEwLjggNDAzLjVDLTE4LjUgNDUwLjYgMTUuMyA1MTIgNzAuOSA1MTJoMzA2LjJjNTUuNyAwIDg5LjQtNjEuNSA2MC4xLTEwOC41ek0xMzcuOSAzMjBsNDguMi03Ny42YzMuNy01LjIgNS44LTExLjYgNS44LTE4LjRWNjRoNjR2MTYwYzAgNi45IDIuMiAxMy4yIDUuOCAxOC40bDQ4LjIgNzcuNmgtMTcyeiI+PC9wYXRoPgo8L3N2Zz4=",alt:" "}),e.active?t("hideEXP"):t("showEXP"))))}var m={en:{hideEXP:"Hide Beta Results",showEXP:"Show Beta Results"},de:{hideEXP:"Beta Ergebnisse ausblenden",showEXP:"Beta Ergebnisse anzeigen"}},h=n(6223),p=n(7344),y=n(6206),d=n(8200),g=function(){function e(e){void 0===e&&(e=[]),this.items=e}var t=e.prototype;return t.push=function(t){return this.items.some((function(e){return e===t}))?new e([t].concat((0,o.Z)(this.items.filter((function(e){return e!==t}))))):new e([t].concat((0,o.Z)(this.items)))},t.limit=function(t){return this.items.length<=t?this:new e(this.items.slice(0,t))},t.toJSON=function(){return JSON.stringify(this.items)},e.fromJSON=function(t){return new e(JSON.parse(t))},e}(),f=new Set;function v(){f.forEach((function(e){return e()}))}var N=void 0;"undefined"!=typeof window&&(window.addEventListener("hashchange",(function(){N=location.hash,v()})),setInterval((function(){if(void 0!==N){var e=location.hash;N!==e&&(N=location.hash,v())}}),10));var w=[{key:"web-en",name:"English",language:"en"},{key:"web-de",name:"German",language:"de"}],E="web-en",I=function(e){function t(){for(var t,n,a=arguments.length,r=new Array(a),i=0;i<a;i++)r[i]=arguments[i];return(n=e.call.apply(e,[this].concat(r))||this).lang=(0,s._f)(),n.state=Object.assign({},C(S("corpus")||E),{corpora:w,unavailableCorpora:new Set,betaResults:!1,pageQuery:S("q")||"",currentQuery:"",queryId:(0,d.To)(),exampleVisibility:null!==(t=L())&&void 0!==t?t:"peek"}),n._onHashUpdateHandler=function(){var e=S("q")||"",t=S("corpus");n.setState((function(n){return Object.assign({pageQuery:e},C(t||n.currentCorpusKey,n),{currentQuery:e,queryId:e===n.pageQuery||e===n.currentQuery?n.queryId:(0,d.To)()})}))},n._onCorpusSelectedHandler=function(e){n.setState((function(t){return C(e.key,t)})),M("corpus",e.key)},n._onQueryCommitHandler=function(e){n.setState((function(t){var n=t.history;return e.trim()&&(n=n.push(e),A(t.currentCorpusKey,n)),{currentQuery:e,history:n}})),M("q",e)},n._onSetExampleVisibilityHandler=function(e){j(e),n.setState({exampleVisibility:e})},n._onShowExperimental=function(){n.setState((function(e){return{betaResults:!e.betaResults}}))},n}(0,r.Z)(t,e);var n=t.prototype;return n.componentDidMount=function(){var e,t=this;this._corporaPromise=new y.OR(p.Cz.getNetspeakClient(p.zM.ngram).queryCorpora()),this._corporaPromise.then((function(e){var n=new Set(e.corpora.map((function(e){return e.key})));t.setState((function(e){return{unavailableCorpora:new Set(e.corpora.filter((function(e){return!n.has(e.key)})))}}))}),y.xv).catch((function(e){t.setState((function(e){return{unavailableCorpora:new Set(e.corpora)}})),console.error(e)})),e=this._onHashUpdateHandler,f.add(e)},n.componentWillUnmount=function(){var e,t;null===(e=this._corporaPromise)||void 0===e||e.cancel(),t=this._onHashUpdateHandler,f.delete(t)},n.render=function(){var e=this;return a.createElement(i.Z,{lang:this.lang,className:"SearchPage"},a.createElement("div",{className:"section"},a.createElement("div",{className:"options-wrapper"},(0,d.jt)(this.state.corpora.length>0,(function(){return a.createElement(u,{lang:e.lang,selected:e.state.currentCorpusKey,corpora:e.state.corpora,unavailable:e.state.unavailableCorpora,onCorpusSelected:e._onCorpusSelectedHandler})}))),a.createElement("div",{className:"search-wrapper"},a.createElement(h.x,{key:this.state.queryId+";"+this.state.currentCorpusKey,lang:this.lang,corpusKey:this.state.currentCorpusKey,defaultQuery:this.state.pageQuery,onCommitQuery:this._onQueryCommitHandler,storedQuery:"",history:this.state.history,defaultExampleVisibility:this.state.exampleVisibility,onSetExampleVisibility:this._onSetExampleVisibilityHandler,pageSize:40,autoFocus:!0}))),a.createElement("div",{className:"section"},a.createElement("div",{className:"options-wrapper"},a.createElement(l,{lang:this.lang,active:this.state.betaResults,onClicked:this._onShowExperimental})),a.createElement("div",{className:"search-wrapper"},(0,d.jt)(this.state.betaResults,(function(){return a.createElement(h.x,{key:e.state.queryId+";"+e.state.currentCorpusKey,lang:e.lang,corpusKey:e.state.currentCorpusKey,defaultQuery:e.state.pageQuery,apiType:p.zM.neural,beta:!0,storedQuery:e.state.currentQuery,defaultExampleVisibility:"hidden",pageSize:40,autoFocus:!1})})))))},t}(a.PureComponent);function C(e,t){return{currentCorpusKey:e,history:(null==t?void 0:t.currentCorpusKey)===e?t.history:k(e)}}function b(){try{return new URLSearchParams((location.hash||"#").substr(1))}catch(e){return new URLSearchParams("")}}function S(e){return b().get(e)}function M(e,t){var n=b();n.set(e,t),function(e){location.hash=e.toString()}(n)}function k(e){var t=localStorage.getItem("queryHistory:"+e);return t?g.fromJSON(t):new g}function A(e,t){localStorage.setItem("queryHistory:"+e,t.toJSON())}function L(){return sessionStorage.getItem("exampleVisibility")}function j(e){sessionStorage.setItem("exampleVisibility",e)}var x=n(5414),T=n(8743),z=n(7274);function D(){return a.createElement(a.Fragment,null,(0,T.Z)((function(){return a.createElement(I,null)})),a.createElement(z.Z,null),a.createElement(x.q,null,a.createElement("title",null,"Netspeak"),a.createElement("meta",{name:"keywords",content:"netspeak, common language, dictionary, phrase dictionary, netfreak, net speak, net-speak, net slang, internet slang, net-speak, writing assistant"}),a.createElement("meta",{name:"description",content:"Netspeak helps you to search for words you don't know, yet. It is a new kind of dictionary that contains everything that has ever been written on the web."})))}}}]);
  //# sourceMappingURL=component---src-pages-index-tsx-535c2d49b71a67b7dc17.js.map