/*! For license information please see 9222.72d421dbd8b27500.js.LICENSE.txt */
export const __webpack_ids__=["9222"];export const __webpack_modules__={54681:function(e,t,s){s.d(t,{Z:()=>o});var i=s(8081),r=s.n(i),a=s(23645),n=s.n(a)()(r());n.push([e.id,"*,:after,:before{box-sizing:border-box}button,input,select,textarea{font:inherit}button{color:inherit;cursor:pointer}img{height:auto;max-width:100%}a{color:var(--color-link-normal)}[hidden]{display:none!important}",""]);let o=n.toString()},38235:function(e,t,s){e.exports=s.p+"arrow-right.648145f00e77b7f0.svg"},6882:function(e,t,s){s.r(t),s.d(t,{MDNSiteSearch:()=>MDNSiteSearch});var i=s(35470),r=s(14703),a=s(67621),n=s(69535);s(50272);var o=s(56276),l=s(15381),c=s(47270);let h={"en-us":"English (US)",de:"Deutsch",fr:"Fran\xe7ais",es:"Espa\xf1ol",it:"Italiano",ja:"日本語",ko:"한국어","pt-br":"Portugu\xeas (BR)",ru:"Русский","zh-cn":"简体中文","zh-tw":"繁體中文"};function d(e){return h[e.toLowerCase()]||e}let MDNSiteSearch=class MDNSiteSearch extends(0,n.q)(r.oi){static styles=c.Z;static ssr=!1;static properties={_inputValue:{state:!0},_query:{state:!0},_page:{state:!0}};constructor(){super(),this._inputValue=void 0,this._query=void 0,this._locales=[this.locale],this._sort="",this._page=1}_searchTask=new i.iQ(this,{args:()=>[this._query,this._locales,this._sort,this._page],task:async([e,t,s,i],{signal:r})=>{if(!e)return;let a=new URLSearchParams({q:e,sort:s,page:i.toString()});for(let e of t)a.append("locale",e);let n=await fetch(`/api/v1/search?${a}`,{signal:r});if(!n.ok)throw Error(`${n.status}: ${n.statusText}`);return n.json()}});connectedCallback(){super.connectedCallback();let e=new URLSearchParams(location.search),t=e.get("q")||void 0;this._inputValue=t,this._query=t,this._locales=e.has("locale")?e.getAll("locale").sort():[this.locale],this._sort=e.get("sort")||"best";let s=e.get("page");if(s)try{this._page=Number.parseInt(s,10)}catch{this._page=1}}_handleInput(e){let t=e.target;this._inputValue=t.value}_handleKeyDown(e){"Enter"===e.key&&(e.preventDefault(),this._executeSearch())}_handleSearch(e){e.preventDefault(),this._executeSearch()}_executeSearch(){let e=this._inputValue?.trim();if(e){let t=new URL(location.href);t.searchParams.set("q",e),t.searchParams.set("page","1"),globalThis.history.pushState({},"",t),this._page=1,this._query=e}}renderInputs(){return(0,r.dy)`
      <div class="site-search-form">
        <div class="site-search-form__form">
          <input
            class="site-search-form__input"
            name="query"
            type="text"
            .value=${this._inputValue||""}
            @input=${this._handleInput}
            @keydown=${this._handleKeyDown}
          />
          <mdn-button
            icon-only="true"
            .icon=${l.Z}
            variant="plain"
            class="site-search-form__submit"
            @click=${this._handleSearch}
            ?disabled=${!this._inputValue||""===this._inputValue.trim()}
            >${this.l10n`Search`}</mdn-button
          >
        </div>
      </div>
    `}renderPagination(e,t,s){let i=Math.ceil(t/s);if(t<=s)return r.Ld;let a=null,n=null,o=null,l=null;return(t>e*s&&e<i&&(o=e+1),e>1&&(a=e-1),o||null!==a)?(a&&(n=new URL(globalThis.location.href),1===a?n.searchParams.delete("page"):n.searchParams.set("page",a.toString())),o&&(l=new URL(globalThis.location.href)).searchParams.set("page",o.toString()),(0,r.dy)` <ul>
        ${n?(0,r.dy)` <li>
              <mdn-button variant="secondary" href=${n.toString()}
                >${this.l10n`Previous`}</mdn-button
              >
            </li>`:(0,r.dy)`<li></li>`}
        ${o?(0,r.dy)` <li>
              <mdn-button variant="secondary" href=${l}
                >${this.l10n`Next`}</mdn-button
              >
            </li>`:(0,r.dy)`<li></li>`}
      </ul>`):r.Ld}renderSuggestions(e){return e.suggestions.length>0?(0,r.dy)`
        <section class="site-search__suggestions">
          <p class="site-search-suggestions__text">
            ${this.l10n("site-search-suggestions-text")`Did you mean…`}
          </p>
          <ul class="site-search-suggestions__list">
            ${e.suggestions.map(e=>{let t=new URL(location.href);return t.searchParams.delete("page"),t.searchParams.set("q",e.text),(0,r.dy)`
                <li class="site-search-suggestions__item">
                  <a class="site-search-suggestions__link" href=${t.href}
                    >${e.text}</a
                  >
                  <span class="site-search-suggestions__matches"
                    >${this.l10n.raw({id:"site-search-suggestion-matches",args:{matches:e.total.value,relation:e.total.relation}})}</span
                  >
                </li>
              `})}
          </ul>
        </section>
      `:r.Ld}render(){let e="en-US"===this.locale?[]:[[this.locale],["en-US"],[this.locale,"en-US"].sort()],t=[["best",this.l10n`Best`],["relevance",this.l10n`Relevance`],["popularity",this.l10n`Popularity`]];return this._searchTask.render({pending:()=>(0,r.dy)`
        ${this.renderInputs()}
        <div class="site-search__searching">${this.l10n`Searching…`}</div>
      `,complete:s=>s?(0,r.dy)`
              ${this.renderInputs()}

                ${this.renderSuggestions(s)}
              <section class="site-search__options">
                ${e.length>0?(0,r.dy)` <h2>${this.l10n`Language`}</h2>
                        <ul>
                          ${e.map(e=>{let t=1==e.length?d(e.at(0)||"en-US"):this.l10n`Both`;if(this._locales.join(",")===e.join(","))return(0,r.dy)`<li><em>${t}</em></li>`;{let s=new URL(location.href);for(let t of(s.searchParams.delete("locale"),e))s.searchParams.append("locale",t);return(0,r.dy)`<li>
                                <a href=${s.toString()}>${t}</a>
                              </li>`}})}
                        </ul>`:r.Ld}
                <h2>${this.l10n`Sort by`}</h2>
                <ul>
                  ${t.map(([e,t])=>{if(this._sort===e)return(0,r.dy)`<li><em>${t}</em></li>`;{let s=new URL(location.href);return s.searchParams.set("sort",e),(0,r.dy)`<li>
                        <a href=${s.toString()}>${t}</a>
                      </li>`}})}
                </ul>
              </section>
              <section class="site-search__results">
                <p class="site-search__results-stats">${this.l10n.raw({id:"site-search-search-stats",args:{results:s.metadata.total.value}})}</p>
              <ul class="site-search-results">
                ${s.documents.map(e=>(0,r.dy)`<li class="site-search-results__item">
                      <article>
                        <p class="site-search-results__path">
                          ${(0,o.H)(e.mdn_url,this.locale)}
                        </p>
                        <h2 class="site-search-results__title">
                          <a href=${e.mdn_url}>
                            ${e.highlight.title&&e.highlight.title.length>0?(0,a.A)(e.highlight.title[0]):e.title}
                            ${e.locale.toLowerCase()===this.locale.toLowerCase()?r.Ld:(0,r.dy)`<sup
                                  class="site-search-results__locale-indicator"
                                  >${d(e.locale)}</sup
                                >`}
                          </a>
                        </h2>
                        <p class="site-search-results__description">
                          ${e.highlight.body&&e.highlight.body.length>0?e.highlight.body.map(e=>(0,a.A)(e)):e.summary}
                        </p>
                      </article>
                    </li>`)}
                </ul>
                </section>
                </section>
                <nav class="site-search__results-pagination">
                  ${this.renderPagination(s.metadata.page,s.metadata.total.value,s.metadata.size)}
                </nav>
              </section>
            `:(0,r.dy)`${this.renderInputs()}`,error:e=>(0,r.dy)`Error: ${e}`})}};customElements.define("mdn-site-search",MDNSiteSearch)},13566:function(e,t,s){s.d(t,{o:()=>r});var i=s(32529);let r=e=>e??i.Ld},47270:function(e,t,s){s.d(t,{Z:()=>_});var i=s(14703),r=s(8081),a=s.n(r),n=s(23645),o=s.n(n),l=s(54681),c=s(61667),h=s.n(c),d=new s.U(s(38235)),u=o()(a());u.i(l.Z);var g=h()(d);u.push([e.id,`:host{line-height:var(--font-line-content)}:host a{color:var(--color-link-normal)}:host a:visited{color:var(--color-link-visited)}:host a:active,:host a:hover{-webkit-text-decoration:none;text-decoration:none}:host{--color-highlight-background:var(--color-background-yellow)}.site-search__options{align-items:baseline;display:flex;flex-direction:row;gap:.25rem}@media (width <= 769px){.site-search__options{align-items:flex-start;flex-direction:column}.site-search__options h2{margin-bottom:0;margin-top:.5rem}.site-search__options ul{margin-bottom:.5rem;margin-top:0}}.site-search__options li,.site-search__options ul{display:inline-block}.site-search__options li:not(:last-child):after{content:" | ";display:inline;margin-right:.5ch}.site-search__options h2{display:inline;font-size:var(--font-size-small);font-weight:var(--font-weight-bold)}.site-search__options ul{font-size:var(--font-size-small);margin-right:1rem;padding-inline:0}.site-search__title{display:none;font-size:var(--font-size-large);font-weight:700}.site-search__searching{font-size:var(--font-size-small);margin-top:1rem}.site-search__results-stats{color:var(--color-text-secondary);font-size:var(--font-size-small);margin:.25rem 0 1rem}@media (width <= 426px){.site-search__results-stats{display:none}}.site-search-results{list-style:none;margin:0;padding-inline:0}.site-search-results__title{font-size:var(--font-size-large);font-weight:var(--font-weight-normal)}.site-search-suggestions__list{padding:0;padding-inline:0}.site-search-suggestions__item:before{background-color:var(--color-text-secondary);content:"";display:inline-block;height:1em;margin-right:.1em;-webkit-mask-image:url(${g});mask-image:url(${g});-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:contain;mask-size:contain;vertical-align:middle;width:1em}.site-search-suggestions__item{list-style-type:none}.site-search-suggestions__text{margin:1rem 0}.site-search-suggestions__matches{color:var(--color-text-secondary);font-size:var(--font-size-small)}.site-search-form{display:flex;flex-direction:column;margin-top:2rem}.site-search-form__form{background-color:var(--color-background-primary);border:1px solid var(--color-border-primary);border-radius:2rem;display:flex;padding:.25rem 1rem;width:fit-content}.site-search-form__submit{--color-gray-80:#0000;--color-gray-20:#0000}.site-search-form__input{background:#0000;border:none;font-size:var(--font-size-large);font-weight:var(--font-weight-normal);outline:none}.site-search-results__item article{display:grid;grid-template-areas:"path" "title" "description"}.site-search-results__item{margin-bottom:1.5rem}.site-search-results__title{grid-area:title;margin:0}.site-search-results__title mark{background-color:var(--color-highlight-background);color:inherit}.site-search-results__path{color:var(--color-text-secondary);font-size:var(--font-size-small);grid-area:path;margin:0}.site-search-results__description{grid-area:description;margin:0 0 .25rem}.site-search-results__description mark{background-color:var(--color-highlight-background);color:inherit}.site-search-results__locale-indicator{background-color:var(--color-background-secondary);border-radius:1em;color:var(--color-text-secondary);font-size:var(--font-size-small);margin:0 0 .25em;padding:.25em .5em}.site-search__results-pagination ul{align-items:center;display:flex;gap:.5rem;justify-content:space-between;list-style:none;padding-inline:0}`,""]);let _=(0,i.iv)([u.toString()])},15381:function(e,t,s){s.d(t,{Z:()=>r});var i=s(14703);let r=(0,i.YP)`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24"><path d="m21 21-4.34-4.34"/><circle cx="11" cy="11" r="8"/></svg>`}};
//# sourceMappingURL=9222.72d421dbd8b27500.js.map