import{r as m,a5 as p,h as s,a6 as b,c as r,H as y,B as h,w as v,X as C,p as z}from"./index-TUFJsQwj.js";import{t as o}from"./i18n-3dd5729d-B7Hl56hm.js";import{n as c}from"./dev.utils-52f8c2e9-DbX55uYj.js";import{r as g,a as k}from"./unique-nav-labels-4be6182a-BJ-iQziI.js";import{v as w}from"./custom-class-14f41251-DeC8Y5WC.js";import{v as S}from"./label-7d1ce375-CT1s1cqK.js";import{v as P}from"./tooltip-align-6964dd71-BXzKXa0P.js";import"./align-f3101425-R_Wp7ep4.js";/*!
 * KoliBri - The accessible HTML-Standard
 */const B=(n,t,e)=>{h(n,"_max",t,e)},A=`@charset "UTF-8";
/*
 * This file contains all rules for accessibility.
 */
@layer kol-a11y {
  :host {
    /*
     * Minimum size of interactive elements.
     */
    --a11y-min-size: calc(44rem / var(--kolibri-root-font-size, 16));
    color: black;
    /*
     * No element should be used without a background and font color whose contrast ratio has
     * not been checked. By initially setting the background color to white and the font color
     * to black, the contrast ratio is ensured and explicit adjustment is forced.
     */
    background-color: white;
    /*
     * Verdana is an accessible font that can be used without requiring additional loading time.
     */
    font-family: Verdana;
    /*
     * Letter spacing is required for all texts.
     */
    letter-spacing: inherit;
    /*
     * Word spacing is required for all texts.
     */
    word-spacing: inherit;
  }
  * {
    /*
     * This rule enables the word dividing for all texts. That is important for high zoom levels.
     */
    hyphens: auto;
    /*
     * This rule enables the word dividing for all texts. That is important for high zoom levels.
     */
    word-break: break-word;
  }
  /*
   * All interactive elements should have a minimum size of rem(44).
   */
  /* input:not([type='checkbox'], [type='radio'], [type='range']), */
  /* option, */
  /* select, */
  /* textarea, */
  button,
  .kol-input .input {
    min-width: var(--a11y-min-size);
    min-height: var(--a11y-min-size);
  }
  /*
   * Some interactive elements should not inherit the font-family and font-size.
   */
  a,
  button,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  input,
  option,
  select,
  textarea {
    /*
     * All elements should inherit the font family from his parent element.
     */
    font-family: inherit;
    /*
     * All elements should inherit the font size from his parent element.
     */
    font-size: inherit;
    /*
     * Letter spacing is required for all texts.
     */
    letter-spacing: inherit;
    /*
     * Word spacing is required for all texts.
     */
    word-spacing: inherit;
  }
  /**
  * Sometimes we need the semantic element for accessibility reasons,
  * but we don't want to show it.
  *
  * - https://www.a11yproject.com/posts/how-to-hide-content/
  */
  .visually-hidden {
    position: fixed;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;
    clip-path: inset(50%);
  }
}
@layer kol-global {
  /*
   * Dieses CSS stellt sicher, dass der Standard-Style
   * von A und Button resettet werden.
   */
  :is(a, button) {
    background-color: transparent;
    width: 100%; /* 100% needed for custom width from outside */
    margin: 0;
    padding: 0;
    border: none;
  }
  /*
   * Ensure elements with hidden attribute to be actually not visible
   * @see https://meowni.ca/hidden.is.a.lie.html
   */
  [hidden] {
    display: none !important;
  }
}
@layer kol-global {
  :host {
    /*
     * The max-width is needed to prevent the table from overflowing the
     * parent node, if the table is wider than the parent node.
     */
    max-width: 100%;
    font-size: calc(16rem / var(--kolibri-root-font-size, 16));
  }
  * {
    /*
     * We prefer to box-sizing: border-box for all elements.
     */
    box-sizing: border-box;
  }
  /* KolSpan is a layout component with icons in all directions and a label text in the middle. */
  .kol-span-wc {
    display: grid;
    place-items: center;
  }
  /* The sub span in KolSpan is the horizontal span with icon left and right and the label text in the middle. */
  .kol-span-wc > span {
    display: flex;
    place-items: center;
  }
  a,
  button {
    cursor: pointer;
  }
  /* This is the text label. */
  .hide-label > .kol-span-wc > span > span {
    display: none;
  }
  /* Reset browser agent style. */
  button:disabled {
    color: unset;
  }
  .disabled label,
  .disabled:focus-within label,
  [aria-disabled=true],
  [aria-disabled=true]:focus,
  [disabled],
  [disabled]:focus {
    opacity: 0.5;
    outline: none;
    cursor: not-allowed;
  }
  [aria-disabled=true]:focus .kol-span-wc,
  [disabled]:focus .kol-span-wc {
    outline: none !important;
  }
  .badge-text-hint {
    color: black;
    background-color: lightgray;
  }
}
@layer kol-component {
  .kol-tooltip-wc {
    display: contents;
    contain: layout;
  }
  .kol-tooltip-wc .tooltip-floating {
    display: none;
    position: fixed;
    /* Avoid layout interference - see https://floating-ui.com/docs/computePosition */
    top: 0;
    left: 0;
    /* Can be used to specify the tooltip-width from the outside. Unset by default.  */
    width: var(--kol-tooltip-width);
    max-width: 90vw;
    max-height: 90vh;
    visibility: hidden;
    animation-duration: 0.25s;
    animation-iteration-count: 1;
    animation-name: fadeInOpacity;
    animation-timing-function: ease-in;
  }
  /* Shared between content and arrow */
  .kol-tooltip-wc .tooltip-area {
    color: #000;
    background-color: #fff;
  }
  .kol-tooltip-wc .tooltip-arrow {
    transform: rotate(45deg);
    position: absolute;
    z-index: 999;
    width: calc(10rem / var(--kolibri-root-font-size, 16));
    height: calc(10rem / var(--kolibri-root-font-size, 16));
  }
  .kol-tooltip-wc .tooltip-content {
    position: relative;
    z-index: 1000;
  }
  @keyframes fadeInOpacity {
    0% {
      opacity: 0;
    }
    100% {
      opacity: 1;
    }
  }
}
@layer kol-component {
  :host {
    display: grid;
    gap: calc(16rem / var(--kolibri-root-font-size, 16));
    align-items: center;
    grid-template-columns: 1fr auto;
  }
  .navigation-list {
    display: inline-flex;
    margin: 0;
    padding: 0;
    gap: 0.5em;
    flex-wrap: wrap;
    align-items: center;
    list-style: none;
  }
  .separator:before {
    content: "•••";
  }
}`,T=A,x={left:"codicon codicon-debug-reverse-continue"},O={left:"codicon codicon-chevron-left"},L={right:"codicon codicon-chevron-right"},E={right:"codicon codicon-debug-continue"};function M(){const n=navigator.language||"de-DE";return n.includes("-")?n:`${n}-${n.toUpperCase()}`}const j=M(),u=new Intl.NumberFormat(j,{style:"decimal",minimumFractionDigits:0,maximumFractionDigits:0}),D=class{constructor(n){m(this,n),this.nonce=c(),this.calcCount=(t,e=1)=>Math.ceil(t/e),this.getCount=()=>this.calcCount(this.state._max,this.state._pageSize),this.onClick=(t,e)=>{typeof this.state._on.onClick=="function"&&this.state._on.onClick(t,e),this.onChangePage(t,e)},this.onChangePage=(t,e)=>{const a=setTimeout(()=>{clearTimeout(a),typeof this.state._on.onChangePage=="function"&&this.state._on.onChangePage(t,e)})},this.onChangePageSize=(t,e)=>{if(e=parseInt(e[0]),typeof e=="number"&&e>0&&this._pageSize!==e){this._pageSize=e;const a=setTimeout(()=>{clearTimeout(a),typeof this.state._on.onChangePageSize=="function"&&this.state._on.onChangePageSize(t,this._pageSize)})}},this.onGoToFirst={onClick:t=>{this.onClick(t,1)}},this.onGoToEnd={onClick:t=>{this.onClick(t,this.getCount())}},this.onGoBackward={onClick:t=>{this.onClick(t,this.state._page-1)}},this.onGoForward={onClick:t=>{this.onClick(t,this.state._page+1)}},this.beforePageSize=(t,e)=>{let a=e.has("_pageSize")?e.get("_pageSize"):this.state._pageSize;const i=e.has("_pageSizeOptions")?e.get("_pageSizeOptions"):this.state._pageSizeOptions;if(Array.isArray(i)&&i.length>0){const d=i.find(f=>f.value===a);d===void 0?a=i[0].value:a=d.value,e.set("_pageSize",a)}const l=e.has("_page")?e.get("_page"):this.state._page,_=e.has("_max")?e.get("_max"):this.state._max;this.syncPage(e,l,e.get("_pageSize"),_)},this.syncPage=(t,e,a,i)=>{if(i>0){const l=this.calcCount(i,a);l>0&&(e>l?(t.set("_page",l),this.onChangePage(p,l)):e<1&&(t.set("_page",1),this.onChangePage(p,1)))}},this.beforePageSizeOptions=(t,e)=>{const a=[];if(Array.isArray(t))for(const i of t)typeof i=="number"&&a.push({label:o("kol-page-per-site",{placeholders:{entries:`${i}`}}),value:i});e.set("_pageSizeOptions",a),this.beforePageSize(a,e)},this._boundaryCount=1,this._customClass=void 0,this._label=void 0,this._hasButtons=!0,this._page=void 0,this._pageSize=1,this._pageSizeOptions=[],this._on=void 0,this._siblingCount=1,this._tooltipAlign="top",this._max=void 0,this.state={_boundaryCount:1,_label:o("kol-pagination"),_hasButtons:{first:!0,last:!0,next:!0,previous:!0},_on:{onClick:()=>null},_page:0,_pageSize:1,_pageSizeOptions:[],_siblingCount:1,_max:0}}render(){var n;let t=!1;const e=this.getCount(),a=Array.from(Array(e).keys()).map(i=>i+1).map(i=>i<=this.state._boundaryCount||i>e-this.state._boundaryCount||i>=this.state._page-this.state._siblingCount&&i<=this.state._page+this.state._siblingCount?(t=!0,this.state._page===i?this.getSelectedPageButton(i):this.getUnselectedPageButton(i)):t===!0?(t=!1,s("li",{key:c()},s("span",{class:"separator","aria-hidden":"true"}))):null);return s(y,{class:"kol-pagination"},s("nav",{"aria-label":this.state._label},s("ul",{class:"navigation-list"},this.state._hasButtons.first&&s("li",null,s(r,{class:"first",exportparts:"icon",_customClass:this.state._customClass,_disabled:this.state._page<=1,_icons:x,_hideLabel:!0,_label:o("kol-page-first"),_on:this.onGoToFirst,_tooltipAlign:this.state._tooltipAlign})),this.state._hasButtons.previous&&s("li",null,s(r,{class:"previous",exportparts:"icon",_customClass:this.state._customClass,_disabled:this.state._page<=1,_icons:O,_hideLabel:!0,_label:o("kol-page-back"),_on:this.onGoBackward,_tooltipAlign:this.state._tooltipAlign})),a,this.state._hasButtons.next&&s("li",null,s(r,{class:"next",exportparts:"icon",_customClass:this.state._customClass,_disabled:e<=this.state._page,_icons:L,_hideLabel:!0,_label:o("kol-page-next"),_on:this.onGoForward,_tooltipAlign:this.state._tooltipAlign})),this.state._hasButtons.last&&s("li",null,s(r,{class:"last",exportparts:"icon",_customClass:this.state._customClass,_disabled:e<=this.state._page,_icons:E,_hideLabel:!0,_label:o("kol-page-last"),_on:this.onGoToEnd,_tooltipAlign:this.state._tooltipAlign})))),((n=this.state._pageSizeOptions)===null||n===void 0?void 0:n.length)>0&&s(b,{_hideLabel:!0,_id:`pagination-size-${this.nonce}`,_label:o("kol-entries-per-site"),_options:this.state._pageSizeOptions,_on:{onChange:this.onChangePageSize},_value:[this.state._pageSize]}))}getUnselectedPageButton(n){const t=u.format(n);return s("li",{key:c()},s(r,{_ariaDescription:`${o("kol-page")} ${t}`,_customClass:this.state._customClass,_label:t,_on:{onClick:e=>{this.onClick(e,n)}}}))}getSelectedPageButton(n){const t=u.format(n);return s("li",{key:c()},s(r,{"aria-current":"page",class:"selected",_ariaDescription:`${o("kol-page")} ${t}`,_customClass:this.state._customClass,_disabled:!0,_label:t}))}validateBoundaryCount(n){h(this,"_boundaryCount",Math.max(0,n??1))}validateCustomClass(n){w(this,n)}validateLabel(n,t,e=!1){e||g(this.state._label),S(this,n),k(this.state._label)}validateHasButtons(n){v(this,"_hasButtons",t=>typeof t=="boolean"||typeof t=="string"||typeof t=="object"&&t!==null,new Set(["Boolean","PaginationHasButton"]),n,{hooks:{beforePatch:(t,e)=>{if(typeof t=="boolean")e.set("_hasButtons",{first:t,last:t,next:t,previous:t});else{if(typeof t=="string")try{t=z(t)}catch{e.delete("_hasButtons")}typeof t=="object"&&t!==null&&e.set("_hasButtons",Object.assign(Object.assign({},this.state._hasButtons),{first:typeof t.first=="boolean"?t.first===!0:this.state._hasButtons.first,last:typeof t.last=="boolean"?t.last===!0:this.state._hasButtons.last,next:typeof t.next=="boolean"?t.next===!0:this.state._hasButtons.next,previous:typeof t.previous=="boolean"?t.previous===!0:this.state._hasButtons.previous}))}}}})}validateOn(n){typeof n=="object"&&n!==null&&(this.state=Object.assign(Object.assign({},this.state),{_on:n}))}validatePage(n){h(this,"_page",n,{hooks:{beforePatch:(t,e)=>{const a=e.has("_pageSize")?e.get("_pageSize"):this.state._pageSize,i=e.has("_max")?e.get("_max"):this.state._max;this.syncPage(e,t,a,i)}}})}validatePageSize(n){h(this,"_pageSize",n,{hooks:{beforePatch:this.beforePageSize}})}validatePageSizeOptions(n){C(this,"_pageSizeOptions",t=>typeof t=="number",n,void 0,{hooks:{beforePatch:this.beforePageSizeOptions}})}validateSiblingCount(n){h(this,"_siblingCount",Math.max(0,n??1))}validateMax(n){B(this,n,{hooks:{beforePatch:(t,e)=>{const a=e.has("_page")?e.get("_page"):this.state._page,i=e.has("_pageSize")?e.get("_pageSize"):this.state._pageSize;this.syncPage(e,a,i,t)}}})}validateTooltipAlign(n){P(this,n)}componentWillLoad(){this.validateBoundaryCount(this._boundaryCount),this.validateCustomClass(this._customClass),this.validateHasButtons(this._hasButtons),this.validateLabel(this._label,void 0,!0),this.validateOn(this._on),this.validatePage(this._page),this.validatePageSize(this._pageSize),this.validatePageSizeOptions(this._pageSizeOptions),this.validateSiblingCount(this._siblingCount),this.validateTooltipAlign(this._tooltipAlign),this.validateMax(this._max),this.validatePage(this._page)}disconnectedCallback(){g(this.state._label)}static get watchers(){return{_boundaryCount:["validateBoundaryCount"],_customClass:["validateCustomClass"],_label:["validateLabel"],_hasButtons:["validateHasButtons"],_on:["validateOn"],_page:["validatePage"],_pageSize:["validatePageSize"],_pageSizeOptions:["validatePageSizeOptions"],_siblingCount:["validateSiblingCount"],_max:["validateMax"],_tooltipAlign:["validateTooltipAlign"]}}};D.style={default:T};export{D as kol_pagination};
//# sourceMappingURL=kol-pagination.entry-DZpkAMZl.js.map
