import{r as t}from"./p-d2af20eb.js";import{a as e}from"./p-25a090c9.js";import{s as r}from"./p-d65a44ad.js";import{w as i}from"./p-1d921be2.js";import"./p-b70d1ec1.js";var s;!function(t){t.OPEN="open",t.CANCELED="canceled",t.IN_PROCESS="in_process",t.PARTIALLY_COMPLETED="partially_completed",t.COMPLETED="completed"}(s||(s={}));const n=({returnNumber:t,status:e,createdAt:r,createdBy:i,positions:n,detailLink:o})=>`\n
\n ${t} | \n ${(({type:t,text:e})=>`${e}`)(e)} | \n ${r} | \n ${i} | \n ${n} | \n | \n
\n `;let o=class{constructor(e){t(this,e),this.url="",this.filterSelector="",this.dateFormSelector="",this.sortFormSelector="",this.tableSelector="",this.totalNumberSelector="",this.filteredNumberSelector="",this.scrollSensorSelector="",this.filter=null,this.filterForm=null,this.dateForm=null,this.sortForm=null,this.table=null,this.tableBody=null,this.filteredNumberElements=null,this.totalNumberElements=null,this.nextPage="",this.scrollSensor=null}componentDidLoad(){this.setDateForm(),this.setSortForm(),this.setFilter(),this.setTable(),this.setScrollSensor(),this.setTotalNumberElements(),this.setFilteredNumberElements(),this.requestData(this.url)}setDateForm(){""!==this.dateFormSelector&&(this.dateForm=document.querySelector(this.dateFormSelector),null!==this.dateForm&&this.dateForm.addEventListener("submit",(t=>t.preventDefault())))}setFilter(){""!==this.filterSelector&&(this.filter=document.querySelector(this.filterSelector),i(this.filter,(()=>this.setFilterForm())),this.filter.addEventListener("uxFilterChange",(()=>this.requestData(this.url))))}setSortForm(){""!==this.sortFormSelector&&(this.sortForm=document.querySelector(this.sortFormSelector),null!==this.sortForm&&this.sortForm.addEventListener("submit",l))}setTotalNumberElements(){""!==this.totalNumberSelector&&(this.totalNumberElements=document.querySelectorAll(this.totalNumberSelector))}setFilteredNumberElements(){""!==this.filteredNumberSelector&&(this.filteredNumberElements=document.querySelectorAll(this.filteredNumberSelector))}setFilterForm(){this.filterForm=this.filter.querySelector("form"),null!==this.filterForm&&this.filterForm.addEventListener("submit",l)}syncSortStateToTable(){if(null===this.table||null===this.sortForm)return;const{value:t}=this.sortForm.querySelector("input"),e=this.table.querySelector('ux-table-sort[sorted-direction="desc"], ux-table-sort[sorted-direction="asc"]');null!==e&&(e.sortedDirection="");const r=this.table.querySelector(`ux-table-sort[asc-name="${t}"]`),i=this.table.querySelector(`ux-table-sort[desc-name="${t}"]`);null!==r&&(r.sortedDirection="asc"),null!==i&&(i.sortedDirection="desc")}updateNumbers(t,e){a(this.filteredNumberElements,t.toString()),a(this.totalNumberElements,e.toString())}setTable(){var t;""!==this.tableSelector&&(this.table=document.querySelector(this.tableSelector),this.tableBody=null===(t=this.table)||void 0===t?void 0:t.querySelector("tbody"),null!==this.table&&null!==this.sortForm&&(this.table.addEventListener("uxTableSort",(t=>{const e=t.detail;""!==e&&(this.sortForm.querySelector("input").value=e,this.requestData(this.url))})),this.syncSortStateToTable()))}setScrollSensor(){""!==this.scrollSensorSelector&&(this.scrollSensor=document.querySelector(this.scrollSensorSelector),null!==this.scrollSensor&&this.scrollSensor.addEventListener("uxInfiniteScrollSensorScrolledIntoView",(()=>{this.requestData(this.nextPage)})))}initialRequest(){this.requestData(this.url)}getSerializedFormData(){return[r(this.dateForm),r(this.filterForm),r(this.sortForm)].filter((t=>""!==t)).join("&")}requestData(t){if(""===t)return;const r=function(t){return t.indexOf("mock-data/")>-1}(t)?{}:{method:"POST",body:this.getSerializedFormData(),headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}};e(t,r).then((e=>{this.url===t&&(this.clearExistingData(),this.replaceFilter(e.filterHTML)),this.appendItemsToTable(e.items),this.updateNumbers(e.filteredCount,e.totalCount),this.nextPage=e.nextPage||"",""!==this.nextPage&&null!==this.scrollSensor&&(this.scrollSensor.hasFired=!1)}))}replaceFilter(t){if("string"==typeof t&&t.length>0&&null!==this.filter){const e=this.filter.parentElement;null!==e&&(e.style.height=`${e.offsetHeight}px`),this.filter.outerHTML=t,this.setFilter(),setTimeout((()=>{e.style.height="auto"}),200)}}clearExistingData(){null!==this.tableBody&&(this.tableBody.textContent="")}appendItemsToTable(t){null!==this.tableBody&&this.tableBody.insertAdjacentHTML("beforeend",t.map(n).join(""))}render(){return null}static get watchers(){return{dateFormSelector:["setDateForm"],filterSelector:["setFilter"],sortFormSelector:["setSortForm"],totalNumberSelector:["setTotalNumberElements"],filteredNumberSelector:["setFilteredNumberElements"],tableSelector:["setTable"],scrollSensorSelector:["setScrollSensor"],url:["initialRequest"]}}};function l(t){t.preventDefault()}function a(t,e){null!==t&&[].forEach.call(t,(t=>t.textContent=e))}o.style='.order-return-overview__filter-container::before,.order-return-overview__filter-container::after{content:" ";display:table}.order-return-overview__filter-container::after{clear:both}.order-return-overview__filter-container .ux-tag{background-color:#285172}.order-return-overview__filter-container .datepicker-range{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-align:center;align-items:center;-ms-flex-pack:start;justify-content:flex-start}.order-return-overview__filter-container .datepicker-range__divider{-ms-flex:0 0 20px;flex:0 0 20px}.order-return-overview__filter-container .datepicker{-ms-flex:1 1 auto;flex:1 1 auto}.order-return-overview__filter-dropdown{min-width:250px;max-width:300px;position:relative;display:inline-block;margin-right:18px;margin-bottom:20px}.order-return-overview__result-set.result-set{margin-top:0;position:relative;text-align:center}.order-return-overview__table-container .ux-text-status{display:-ms-flexbox;display:flex;-ms-flex-flow:row nowrap;flex-flow:row nowrap;-ms-flex-align:center;align-items:center;-ms-flex-pack:start;justify-content:flex-start}.order-return-overview__table-container .ux-text-status::before{content:"";display:inline-block;background-color:currentColor;width:0.8em;height:0.8em;border-radius:100%;margin-right:0.8em}.order-return-overview .ux-collapsible-button__container{padding:15px;text-align:center}';export{o as ux_iws_data_controller_order_return}