@webority/ui-elements 0.200.0 → 0.201.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/{WuiInlineEdit-8QIAUktT.js → WuiInlineEdit-BKjUqAFD.js} +1 -1
  2. package/dist/{drawerDiscard-233UVlX5.js → drawerDiscard-DO4bmfVZ.js} +1 -1
  3. package/dist/elements/inline-edit.js +1 -1
  4. package/dist/refreshAfter-C2bqZfb9.js +1 -0
  5. package/dist/server.js +1 -1
  6. package/dist/ui-elements/calendar-views.global.js +1 -1
  7. package/dist/ui-elements/carousel.global.js +1 -1
  8. package/dist/ui-elements/code-block.global.js +1 -1
  9. package/dist/ui-elements/command-palette.global.js +1 -1
  10. package/dist/ui-elements/comment-thread.global.js +1 -1
  11. package/dist/ui-elements/consent-banner.global.js +1 -1
  12. package/dist/ui-elements/context-menu.global.js +1 -1
  13. package/dist/ui-elements/dashboard-grid.global.js +1 -1
  14. package/dist/ui-elements/data-table.global.js +1 -1
  15. package/dist/ui-elements/date-range.global.js +1 -1
  16. package/dist/ui-elements/date-time.global.js +1 -1
  17. package/dist/ui-elements/datepicker.global.js +1 -1
  18. package/dist/ui-elements/dock.global.js +1 -1
  19. package/dist/ui-elements/drawer.global.js +1 -1
  20. package/dist/ui-elements/dropdown.global.js +1 -1
  21. package/dist/ui-elements/entry-grid.global.js +1 -1
  22. package/dist/ui-elements/gantt.global.js +1 -1
  23. package/dist/ui-elements/glyphs-a.global.js +1 -1
  24. package/dist/ui-elements/glyphs-b.global.js +1 -1
  25. package/dist/ui-elements/glyphs-c.global.js +1 -1
  26. package/dist/ui-elements/glyphs-d.global.js +1 -1
  27. package/dist/ui-elements/glyphs-e.global.js +1 -1
  28. package/dist/ui-elements/glyphs-f.global.js +1 -1
  29. package/dist/ui-elements/glyphs-g.global.js +1 -1
  30. package/dist/ui-elements/glyphs-h.global.js +1 -1
  31. package/dist/ui-elements/glyphs-i.global.js +1 -1
  32. package/dist/ui-elements/glyphs-j.global.js +1 -1
  33. package/dist/ui-elements/glyphs-k.global.js +1 -1
  34. package/dist/ui-elements/glyphs-l.global.js +1 -1
  35. package/dist/ui-elements/glyphs-m.global.js +1 -1
  36. package/dist/ui-elements/glyphs-n.global.js +1 -1
  37. package/dist/ui-elements/glyphs-o.global.js +1 -1
  38. package/dist/ui-elements/glyphs-p.global.js +1 -1
  39. package/dist/ui-elements/glyphs-q.global.js +1 -1
  40. package/dist/ui-elements/glyphs-r.global.js +1 -1
  41. package/dist/ui-elements/glyphs-s.global.js +1 -1
  42. package/dist/ui-elements/glyphs-t.global.js +1 -1
  43. package/dist/ui-elements/glyphs-u.global.js +1 -1
  44. package/dist/ui-elements/glyphs-v.global.js +1 -1
  45. package/dist/ui-elements/glyphs-w.global.js +1 -1
  46. package/dist/ui-elements/glyphs-x.global.js +1 -1
  47. package/dist/ui-elements/glyphs-z.global.js +1 -1
  48. package/dist/ui-elements/glyphs.global.js +1 -1
  49. package/dist/ui-elements/hover-card.global.js +1 -1
  50. package/dist/ui-elements/image-crop.global.js +1 -1
  51. package/dist/ui-elements/inline-edit.global.js +1 -1
  52. package/dist/ui-elements/kanban.global.js +1 -1
  53. package/dist/ui-elements/lead-popup.global.js +1 -1
  54. package/dist/ui-elements/lightbox.global.js +1 -1
  55. package/dist/ui-elements/markdown.global.js +1 -1
  56. package/dist/ui-elements/mini-calendar.global.js +1 -1
  57. package/dist/ui-elements/navigation-menu.global.js +1 -1
  58. package/dist/ui-elements/notification-center.global.js +1 -1
  59. package/dist/ui-elements/offline-banner.global.js +1 -1
  60. package/dist/ui-elements/onboarding-checklist.global.js +1 -1
  61. package/dist/ui-elements/org-tree.global.js +1 -1
  62. package/dist/ui-elements/otp.global.js +1 -1
  63. package/dist/ui-elements/overflow.global.js +1 -1
  64. package/dist/ui-elements/phone.global.js +1 -1
  65. package/dist/ui-elements/popover.global.js +1 -1
  66. package/dist/ui-elements/rating.global.js +1 -1
  67. package/dist/ui-elements/record-pager.global.js +1 -1
  68. package/dist/ui-elements/relative-time.global.js +1 -1
  69. package/dist/ui-elements/saved-views.global.js +1 -1
  70. package/dist/ui-elements/select-chips.global.js +1 -1
  71. package/dist/ui-elements/select-recents.global.js +1 -1
  72. package/dist/ui-elements/select-search.global.js +1 -1
  73. package/dist/ui-elements/select-window.global.js +1 -1
  74. package/dist/ui-elements/server.global.js +1 -1
  75. package/dist/ui-elements/shell.global.js +1 -1
  76. package/dist/ui-elements/shortcuts.global.js +1 -1
  77. package/dist/ui-elements/show-more.global.js +1 -1
  78. package/dist/ui-elements/slider.global.js +1 -1
  79. package/dist/ui-elements/sortable.global.js +1 -1
  80. package/dist/ui-elements/status-icon.global.js +1 -1
  81. package/dist/ui-elements/table-export.global.js +1 -1
  82. package/dist/ui-elements/timepicker.global.js +1 -1
  83. package/dist/ui-elements/tour.global.js +1 -1
  84. package/dist/ui-elements/tree-picker.global.js +1 -1
  85. package/dist/ui-elements/tree.global.js +1 -1
  86. package/dist/ui-elements/truncate.global.js +1 -1
  87. package/dist/ui-elements/whats-new.global.js +1 -1
  88. package/dist/ui-elements/wizard.global.js +1 -1
  89. package/dist/ui-elements.global.js +1 -1
  90. package/dist/ui-elements.js +1 -1
  91. package/package.json +5 -5
  92. package/types/server/regionMorph.d.ts +1 -0
  93. package/types/server/regions.d.ts +1 -0
  94. package/dist/refreshAfter-DhYgWXmQ.js +0 -1
@@ -1 +1 @@
1
- import{a as e}from"./formatters-lNUhNemK.js";import{i as t}from"./calendarMath-D8B0i3XW.js";import{n,r,t as i}from"./digitGrouping-CCPI3HK3.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{n as o}from"./imeSafeEnter-DeO_3lXy.js";import{n as s,t as c}from"./inlineEditText-BjHkrr4q.js";import{c as l,i as u}from"./refreshAfter-DhYgWXmQ.js";import{m as d}from"./wuiHttp-8CYWEbRz.js";import{r as f,t as p}from"./textStore-Cs1SGBoI.js";import{n as m,t as h}from"./inlineEdit.g-DKIhYoPF.js";import{t as g}from"./httpFailure.g-DjZzGxPj.js";var _=()=>f(`inlineEdit`,h),v=()=>f(`asyncBlock`,m),y=e=>typeof e==`object`&&!!e&&`value`in e&&typeof e.value==`string`&&`label`in e&&typeof e.label==`string`;async function b(e){let t=await d(new URL(e,window.location.href).href,{headers:{Accept:`application/json`}});if(!t.ok)throw Error(`Loading options answered ${t.kind}.`);let n=JSON.parse(t.html),r=Array.isArray(n)?n:[];if(!Array.isArray(n)||!r.every(y))throw Error(`Options must be a JSON array of { value, label } strings.`);return r.filter(y)}var x=e=>s.some(t=>t===e),S=`[data-wui-display]`,C=`[data-wui-value]`,w=`[data-wui-editor]`,T=`[data-wui-control]`,E=`[data-wui-error]`,D=`[data-wui-live]`,O=`[aria-expanded="true"]`,k=/* @__PURE__ */ new Set([`select`,`date`]),A=e=>{let t=(typeof e==`object`||typeof e==`function`)&&e!==null&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:_().serverMessage},j=e=>e instanceof HTMLElement&&typeof(`value`in e?e.value:void 0)==`string`,M=(e,t)=>{let n=e?.querySelector(t)??null;return n instanceof HTMLElement?n:null},N=class extends a{_wired;_editing;_busy;_draft;_pressed;_popupOpen;_savedTimer;_optionsLoaded;_optionsLoading;static get observedAttributes(){return[`disabled`]}constructor(){super(),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._optionsLoaded=!1,this._optionsLoading=null,this._onClick=this._onClick.bind(this),this._onKeyCapture=this._onKeyCapture.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onChange=this._onChange.bind(this)}connectedCallback(){this._wired||(this._wired=!0,this._grouping(),this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=M(this,S),t=M(this,w),n=this._control();e&&t&&n&&(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._needsLoad()&&this._loadOptions(),this._focusControl(n),e.hidden=!0)}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_needsLoad(){return this._type()===`select`&&this.hasAttribute(`load-url`)&&!this._optionsLoaded}_loadOptions(){let e=this.getAttribute(`load-url`),t=this._control();e&&t&&this._optionsLoading===null&&(this._setError(null),t.setAttribute(`disabled`,``),this.setAttribute(`aria-busy`,`true`),Object.assign(t,{options:[{value:``,label:v().loadingLabel}]}),this._optionsLoading=b(e).then(e=>{this._optionsLoading=null,this._optionsLoaded=!0,this._showRows(t,e)},()=>{this._optionsLoading=null,this._showLoadError()}))}_showRows(e,t){this.removeAttribute(`aria-busy`),e.removeAttribute(`disabled`),Object.assign(e,{options:t}),e.value=this._draft??this._value(),this._editing&&this._focusControl(e)}_showLoadError(){this.removeAttribute(`aria-busy`);let e=M(this,E);if(!e)return;let t=v(),n=document.createElement(`button`);n.type=`button`,n.setAttribute(`data-wui-retry`,``),n.textContent=t.retryLabel,n.addEventListener(`click`,()=>this._loadOptions()),e.replaceChildren(`${t.errorTitle} `,n),e.hidden=!1,this._announce(t.errorTitle)}_onClick(e){e.stopPropagation();let t=e.target instanceof Node?e.target:null;e.type===`click`&&!this._editing&&this.querySelector(S)?.contains(t)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(w)?.querySelector(O))}_onKeyDown(e){if(!this._editing){(o(e)||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||k.has(t)||(t!==`textarea`||e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget instanceof Node?e.relatedTarget:null;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!k.has(this._type()))return;let t=this._control();t&&e.target===t&&queueMicrotask(()=>this._commit(t.value))}async _commit(e){if(!this._editing||this._busy)return;if(this._optionsLoading!==null){this.cancel();return}let t=this._value();if(e===t){this.cancel();return}let n=typeof this.validate==`function`?this.validate(e):null;if(n){this._setError(n),this._announce(n);return}let r=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let i=r?null:this._readShown();r||this._showValue(e),this._close();let a=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let o=this.getAttribute(`label`)||``;a.ok?(this.setAttribute(`value`,e),!r&&a.text&&this._showText(a.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),c),this._announce(p(_().savedText,{label:o})),this._fire(`wui:inline-edit:saved`,{value:e,previous:t}),a.result&&!u(this)&&await l(a.result,{origin:this})):(i&&this._restoreShown(i),a.kind===`session`||a.kind===`aborted`?this._setState(null):(this._draft=e,this._setState(`error`),this._setError(a.message),this._announce(p(_().notSavedText,{label:o,reason:a.message})),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:a.kind,message:a.message})))}async _persist(e,t){if(t){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:A(e)}}}let n=this.getAttribute(`action`);if(!n)return{ok:!0};let r=new URLSearchParams({[this.getAttribute(`name`)||`value`]:e}),i=await d(n,{method:`POST`,body:r});if(i.ok)return{ok:!0,text:i.data===null?i.html.trim():``,result:i};let a={forbidden:_().forbiddenMessage,networkCheck:f(`httpFailure`,g).networkCheckText,client:_().clientMessage,validation:_().validationMessage,server:_().serverMessage,network:_().networkMessage};return{ok:!1,kind:i.kind,message:i.message||a[i.kind]||_().serverMessage}}_close(){let e=M(this,S),t=M(this,w),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),M(t,O)?.click(),n&&e?.focus()}_focusControl(e){if(!k.has(this._type())){e.focus(),e.select?.();return}let t=M(e,`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(n){if(n===``){this._showText(this.getAttribute(`placeholder`)||e(),!0);return}let r=this._type(),a=n;if(r===`date`)a=t(n)||n;else if(r===`select`){let e=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(e=>e.getAttribute(`data-value`)===n);e&&(a=(e.textContent??``).trim())}else r===`number`&&this._grouping()===`indian`&&(a=i(n));this._showText(a,!1)}_readShown(){let e=this.querySelector(C);return e?{nodes:[...e.childNodes].map(e=>e.cloneNode(!0)),empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(C);t&&(t.replaceChildren(...e.nodes),t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(C);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=M(this,E),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(D);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){let e=this.querySelector(T);return j(e)?e:null}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return x(e)?e:`text`}_grouping(){let e=this.getAttribute(`grouping`)??`none`;if(!r(e))throw Error(n(e));return e}};export{N as t};
1
+ import{a as e}from"./formatters-lNUhNemK.js";import{i as t}from"./calendarMath-D8B0i3XW.js";import{n,r,t as i}from"./digitGrouping-CCPI3HK3.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{n as o}from"./imeSafeEnter-DeO_3lXy.js";import{n as s,t as c}from"./inlineEditText-BjHkrr4q.js";import{c as l,i as u}from"./refreshAfter-C2bqZfb9.js";import{m as d}from"./wuiHttp-8CYWEbRz.js";import{r as f,t as p}from"./textStore-Cs1SGBoI.js";import{n as m,t as h}from"./inlineEdit.g-DKIhYoPF.js";import{t as g}from"./httpFailure.g-DjZzGxPj.js";var _=()=>f(`inlineEdit`,h),v=()=>f(`asyncBlock`,m),y=e=>typeof e==`object`&&!!e&&`value`in e&&typeof e.value==`string`&&`label`in e&&typeof e.label==`string`;async function b(e){let t=await d(new URL(e,window.location.href).href,{headers:{Accept:`application/json`}});if(!t.ok)throw Error(`Loading options answered ${t.kind}.`);let n=JSON.parse(t.html),r=Array.isArray(n)?n:[];if(!Array.isArray(n)||!r.every(y))throw Error(`Options must be a JSON array of { value, label } strings.`);return r.filter(y)}var x=e=>s.some(t=>t===e),S=`[data-wui-display]`,C=`[data-wui-value]`,w=`[data-wui-editor]`,T=`[data-wui-control]`,E=`[data-wui-error]`,D=`[data-wui-live]`,O=`[aria-expanded="true"]`,k=/* @__PURE__ */ new Set([`select`,`date`]),A=e=>{let t=(typeof e==`object`||typeof e==`function`)&&e!==null&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:_().serverMessage},j=e=>e instanceof HTMLElement&&typeof(`value`in e?e.value:void 0)==`string`,M=(e,t)=>{let n=e?.querySelector(t)??null;return n instanceof HTMLElement?n:null},N=class extends a{_wired;_editing;_busy;_draft;_pressed;_popupOpen;_savedTimer;_optionsLoaded;_optionsLoading;static get observedAttributes(){return[`disabled`]}constructor(){super(),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._optionsLoaded=!1,this._optionsLoading=null,this._onClick=this._onClick.bind(this),this._onKeyCapture=this._onKeyCapture.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onChange=this._onChange.bind(this)}connectedCallback(){this._wired||(this._wired=!0,this._grouping(),this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=M(this,S),t=M(this,w),n=this._control();e&&t&&n&&(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._needsLoad()&&this._loadOptions(),this._focusControl(n),e.hidden=!0)}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_needsLoad(){return this._type()===`select`&&this.hasAttribute(`load-url`)&&!this._optionsLoaded}_loadOptions(){let e=this.getAttribute(`load-url`),t=this._control();e&&t&&this._optionsLoading===null&&(this._setError(null),t.setAttribute(`disabled`,``),this.setAttribute(`aria-busy`,`true`),Object.assign(t,{options:[{value:``,label:v().loadingLabel}]}),this._optionsLoading=b(e).then(e=>{this._optionsLoading=null,this._optionsLoaded=!0,this._showRows(t,e)},()=>{this._optionsLoading=null,this._showLoadError()}))}_showRows(e,t){this.removeAttribute(`aria-busy`),e.removeAttribute(`disabled`),Object.assign(e,{options:t}),e.value=this._draft??this._value(),this._editing&&this._focusControl(e)}_showLoadError(){this.removeAttribute(`aria-busy`);let e=M(this,E);if(!e)return;let t=v(),n=document.createElement(`button`);n.type=`button`,n.setAttribute(`data-wui-retry`,``),n.textContent=t.retryLabel,n.addEventListener(`click`,()=>this._loadOptions()),e.replaceChildren(`${t.errorTitle} `,n),e.hidden=!1,this._announce(t.errorTitle)}_onClick(e){e.stopPropagation();let t=e.target instanceof Node?e.target:null;e.type===`click`&&!this._editing&&this.querySelector(S)?.contains(t)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(w)?.querySelector(O))}_onKeyDown(e){if(!this._editing){(o(e)||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||k.has(t)||(t!==`textarea`||e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget instanceof Node?e.relatedTarget:null;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!k.has(this._type()))return;let t=this._control();t&&e.target===t&&queueMicrotask(()=>this._commit(t.value))}async _commit(e){if(!this._editing||this._busy)return;if(this._optionsLoading!==null){this.cancel();return}let t=this._value();if(e===t){this.cancel();return}let n=typeof this.validate==`function`?this.validate(e):null;if(n){this._setError(n),this._announce(n);return}let r=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let i=r?null:this._readShown();r||this._showValue(e),this._close();let a=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let o=this.getAttribute(`label`)||``;a.ok?(this.setAttribute(`value`,e),!r&&a.text&&this._showText(a.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),c),this._announce(p(_().savedText,{label:o})),this._fire(`wui:inline-edit:saved`,{value:e,previous:t}),a.result&&!u(this)&&await l(a.result,{origin:this})):(i&&this._restoreShown(i),a.kind===`session`||a.kind===`aborted`?this._setState(null):(this._draft=e,this._setState(`error`),this._setError(a.message),this._announce(p(_().notSavedText,{label:o,reason:a.message})),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:a.kind,message:a.message})))}async _persist(e,t){if(t){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:A(e)}}}let n=this.getAttribute(`action`);if(!n)return{ok:!0};let r=new URLSearchParams({[this.getAttribute(`name`)||`value`]:e}),i=await d(n,{method:`POST`,body:r});if(i.ok)return{ok:!0,text:i.data===null?i.html.trim():``,result:i};let a={forbidden:_().forbiddenMessage,networkCheck:f(`httpFailure`,g).networkCheckText,client:_().clientMessage,validation:_().validationMessage,server:_().serverMessage,network:_().networkMessage};return{ok:!1,kind:i.kind,message:i.message||a[i.kind]||_().serverMessage}}_close(){let e=M(this,S),t=M(this,w),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),M(t,O)?.click(),n&&e?.focus()}_focusControl(e){if(!k.has(this._type())){e.focus(),e.select?.();return}let t=M(e,`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(n){if(n===``){this._showText(this.getAttribute(`placeholder`)||e(),!0);return}let r=this._type(),a=n;if(r===`date`)a=t(n)||n;else if(r===`select`){let e=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(e=>e.getAttribute(`data-value`)===n);e&&(a=(e.textContent??``).trim())}else r===`number`&&this._grouping()===`indian`&&(a=i(n));this._showText(a,!1)}_readShown(){let e=this.querySelector(C);return e?{nodes:[...e.childNodes].map(e=>e.cloneNode(!0)),empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(C);t&&(t.replaceChildren(...e.nodes),t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(C);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=M(this,E),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(D);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){let e=this.querySelector(T);return j(e)?e:null}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return x(e)?e:`text`}_grouping(){let e=this.getAttribute(`grouping`)??`none`;if(!r(e))throw Error(n(e));return e}};export{N as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{i as n,n as r,r as i,t as a}from"./dom-DMQu--xV.js";import{t as o}from"./loader-AIIVAlsd.js";import{r as s}from"./textStore-Cs1SGBoI.js";import{t as c}from"./drawer.g-B-zYKBfQ.js";import{i as l,n as u,r as d,t as f}from"./toast.g-CJ8c0BNZ.js";import{N as p}from"./dataTable-CSP1x4ZA.js";import{n as ee,t as m}from"./devWarn-DXdRWZs3.js";import{t as te}from"./httpFailure.g-DjZzGxPj.js";import{_ as h,a as ne,b as re,c as ie,d as ae,f as oe,i as se,l as ce,o as le,r as ue,s as de,t as fe,u as pe,x as g,y as me}from"./refreshAfter-DhYgWXmQ.js";import{t as he}from"./hasOwn-CJsplJ62.js";import{n as ge}from"./svgNodes-CaPMDvv7.js";import{t as _e}from"./serverHtml-BC6tAyAl.js";import{a as ve,d as ye,f as be,h as xe,l as Se,m as _,o as Ce,p as we,s as Te,u as Ee}from"./wuiHttp-8CYWEbRz.js";var v=class extends Error{code;status;html;body;kind;constructor(e,t){super(e,t.cause===void 0?void 0:{cause:t.cause}),this.name=`WuiPostError`,this.code=t.code,this.status=t.status,this.html=t.html,this.body=t.body,this.kind=t.kind}},De=/* @__PURE__ */ new Set(/* @__PURE__ */ `bad request.unauthorized.payment required.forbidden.not found.method not allowed.not acceptable.proxy authentication required.request timeout.conflict.gone.length required.precondition failed.payload too large.uri too long.unsupported media type.range not satisfiable.expectation failed.misdirected request.unprocessable content.unprocessable entity.locked.failed dependency.too early.upgrade required.precondition required.too many requests.request header fields too large.unavailable for legal reasons`.split(`.`)),Oe=e=>typeof e!=`object`||!e?{message:void 0,detail:void 0,title:void 0}:{message:`message`in e?e.message:void 0,detail:`detail`in e?e.detail:void 0,title:`title`in e?e.title:void 0};async function ke(e){return e.html===``?e.response===null?``:e.response.text():e.html}function Ae(e,t){let n=e=>typeof e==`string`?e.trim():``,r=Oe(e),i=n(r.message);if(i)return i;let a=n(r.detail);if(a)return a;let o=n(r.title);if(!o)return null;let s=o.toLowerCase();return De.has(s)||s===t.trim().toLowerCase()?null:o}var je=`wui-remote-modal`,Me=`wui-remote-drawer`,Ne=Object.freeze({sm:360,md:480,lg:640,xl:720}),Pe=`wui-modal-fullscreen`,Fe=`wui-modal-wide`,y=Object.freeze({sm:380,md:440,lg:640,xl:880,wide:1080}),b=()=>s(`modal`,u),Ie=e=>we(e?.getAttribute(`data-wui-timeout`)??null)??3e4,Le=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,Re=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,ze=`[aria-invalid="true"], .is-invalid, .input-validation-error`,Be=`invalid`,Ve=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,He=`[data-wui-modal-content]`,Ue=`[data-wui-pane-close], [data-wui-dismiss]`,We=()=>i(`button`,{type:`button`,class:`wui-modal-close`,"data-wui-dismiss":!0,"aria-label":b().closeLabel},ge({width:18,height:18,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},[[`path`,{d:`M18 6 6 18M6 6l12 12`}]])),x=/* @__PURE__ */ new WeakMap,Ge=/* @__PURE__ */ new WeakSet;function S(e,t){if(e==null)throw TypeError(`The remote modal needs ${t}, and the page does not have it.`);return e}var C=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},w=(e,t,n)=>S(C(e,t),n),Ke=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),T=()=>Object.assign(/* @__PURE__ */ Error(`The remote modal load was aborted.`),{name:`AbortError`}),qe=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,E=(e,t)=>{let n=e instanceof Element?e.closest(t):null;return n instanceof HTMLElement?n:null},Je=e=>he(y,e),Ye=e=>he(Ne,e);function Xe(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(Je(e))return e===`wide`?{px:y.wide,wide:!0}:{px:y[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported modal size "${String(e)}". Use sm, md, lg, xl, wide, fullscreen or a px number.`)}var Ze=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};if(e.classList.contains(`wui-modal-wide`))return{px:y.wide,wide:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:y.md}},D=(e,t)=>{e.classList.toggle(Pe,!!t.fullscreen),e.classList.toggle(Fe,!t.fullscreen&&!!t.wide),t.fullscreen?e.style.removeProperty(`--wui-modal-max-width`):e.style.setProperty(`--wui-modal-max-width`,`${t.px}px`)},Qe=[`center`,`top`];function $e(e){if(e==null||e===``)return null;if(Ye(e))return{px:Ne[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported drawer size "${String(e)}". Use sm, md, lg, xl or a px number.`)}var et=e=>e.container===`drawer`,O=e=>e.container===`pane`,tt=e=>e.container!==`modal`,nt=(e,t)=>et(e)?$e(t):Xe(t),rt=e=>{let t=typeof e==`string`?document.querySelector(e):e,n=t instanceof HTMLElement?t:null;return n?.matches(`[data-wui-pane-host]`)?n:null},it=e=>O(e)?e.shell:w(e.shell,`.modal-dialog`,`a dialog frame`);function at(e=`modal`){let t=e===`drawer`,n=t?Me:je,r=document.getElementById(n);if(r)return r;let a=document.createElement(`wui-modal`);a.id=n,a.setAttribute(`data-wui`,`AppModal`);let o=document.createElement(`dialog`);return o.className=t?`modal wui-modal-shell wui-remote-drawer`:`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${t?Ne.md:y.md}px`),o.replaceChildren(i(`div`,{class:t?`modal-dialog wui-remote-drawer-dialog`:`modal-dialog modal-dialog-centered wui-rb-dialog`},i(`div`,{class:`modal-content wui-modal`}))),a.append(o),document.body.appendChild(a),a}var ot=e=>i(`div`,{class:`wui-modal-header`},i(`div`,{class:`wui-modal-heading`},i(`div`,{class:`wui-modal-headtext`},i(`div`,{class:`wui-modal-title`},e))),We()),st=e=>i(`div`,{class:`modal-content wui-modal`,"aria-busy":`true`},ot(e),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-loading`,role:`status`},i(`span`,{class:`visually-hidden`},b().loadingLabel),i(`div`,{class:`skeleton wui-modal-skeleton`}),i(`div`,{class:`skeleton wui-modal-skeleton`}),i(`div`,{class:`skeleton wui-modal-skeleton wui-modal-skeleton--short`})))),ct=(n,r)=>{let a={forbidden:b().forbiddenMessage,networkCheck:s(`httpFailure`,te).networkCheckText,client:b().clientMessage,server:b().serverMessage,network:b().networkMessage,timeout:b().timeoutMessage};return i(`div`,{class:`modal-content wui-modal`,"data-wui-modal-error":r},ot(n),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-state`,role:`alert`},i(`p`,{class:`wui-modal-state-title`},b().errorTitle),i(`p`,{class:`wui-modal-state-text`},a[r]||b().serverMessage),i(`div`,{class:`wui-modal-state-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":!0,"data-wui":t},b().closeLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-wui-modal-retry":!0,"data-wui":t},b().retryLabel)))))},k=e=>C(e.shell,`.modal-content`),lt=e=>r(e.cloneNode(!0),HTMLElement,`a card copy is not an element`);function ut(e){e&&e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}))}function A(e,t){let n=k(e),r=n?ft(n):/* @__PURE__ */ new Map;ut(n),n?n.replaceWith(t):it(e).appendChild(t),pt(t,r),h().refresh()}var dt=`input[type="file"][name]`;function ft(e){let t=/* @__PURE__ */ new Map;for(let n of e.querySelectorAll(dt)){if(!(n instanceof HTMLInputElement))continue;let e=n.files;e&&e.length>0&&t.set(n.name,[...e])}return t}function pt(e,t){if(t.size!==0&&typeof DataTransfer<`u`)for(let n of e.querySelectorAll(dt)){if(!(n instanceof HTMLInputElement))continue;let e=t.get(n.name);if(!e)continue;let r=new DataTransfer;for(let t of e)r.items.add(t);n.files=r.files,n.dispatchEvent(new Event(`change`,{bubbles:!0}))}}var mt=e=>O(e)?!e.shell.hidden:e.host.hasAttribute(`open`);function ht(e,t,n=!1){let r=t?C(e,ze):null,i=r?r.matches(Le)?r:C(r,Le)||r:null;if(!i&&n)i=C(e,`[data-autofocus]`)||C(e,Re)||C(e,`.wui-modal-close`);else if(!i){let t=Ke(e,Le);i=C(e,`[data-autofocus]`)||t.find(e=>!e.classList.contains(`wui-modal-close`))||t[0]||e}r?i?.focus?.():i?.focus?.({preventScroll:!0})}function gt(e,t){let n=C(e.shell,`[data-wui-modal-live]`);n||(n=document.createElement(`div`),n.className=`visually-hidden`,n.setAttribute(`aria-live`,`assertive`),n.setAttribute(`data-wui-modal-live`,``),it(e).appendChild(n)),n.textContent=``,n.textContent=t}var _t=e=>{let t=C(e.shell,`[data-wui-modal-live]`);t&&(t.textContent=``)},vt=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};function j(e,t,n,r){let i={...r,container:e.container};vt(t,`wui:modal:${n}`,i),et(e)&&vt(t,`wui:drawer:${n}`,i),O(e)&&vt(t,`wui:pane:${n}`,i)}var yt=e=>e.matches(`[data-wui-pane-host]`)?`pane`:w(e,`dialog`,`a dialog`).classList.contains(`wui-remote-drawer`)?`drawer`:`modal`,bt=e=>S(e.host.closest(`wui-modal`),`a wui-modal host`);function xt(e){let t=x.get(e);if(t)return t;let n=yt(e),r=n===`pane`?e:w(e,`dialog`,`a dialog`),a=k({shell:r}),o={host:e,shell:r,container:n,queue:Se(),defaultSize:Ze(r),defaultLabel:r.getAttribute(`aria-label`),placeholder:a?lt(a):i(`div`,{class:`modal-content wui-modal`}),remoteUrl:e.getAttribute(`data-wui-remote-url`),cache:e.getAttribute(`data-wui-remote-cache`)===`true`,loadedUrl:null,session:null};return x.set(e,o),e.addEventListener(`submit`,e=>Ht(o,e)),e.addEventListener(`click`,e=>{E(e.target,`[data-wui-modal-retry]`)&&o.session&&(e.preventDefault(),N(o,o.session))}),O(o)&&e.addEventListener(`click`,t=>{let n=E(t.target,Ue);n&&e.contains(n)&&o.session&&M(o,o.session,`dismissed`,null)}),e.addEventListener(`wui-modal-close`,t=>{t.target===e&&t instanceof CustomEvent&&Rt(t.detail,`reason`)===`escape`&&e.querySelector(`form[data-wui-submitting]`)&&t.preventDefault()}),e.addEventListener(`wui-modal-closed`,t=>{t.target===e&&Dt(o)}),e.addEventListener(`wui-modal-opened`,t=>{if(t.target!==e)return;let n=k(o);o.session&&n?.matches(He)&&!n.contains(document.activeElement)&&ht(n,!1,tt(o))}),o.remoteUrl&&e.addEventListener(`wui-modal-open`,t=>{t.target===e&&Ot(o,t)}),o}function St(e,t,n){let r=null;e.session&&(r=e.session.pendingRefresh,e.session.pendingRefresh=null,e.queue.abort(),e.session.resolveClosed({status:`dismissed`,detail:{replaced:!0}}));let i=()=>void 0,a=new Promise(e=>{i=e}),o={url:t,method:(n.method||`GET`).toUpperCase(),body:n.body,options:n,trigger:n.trigger||null,explicitSize:null,closing:null,resolveClosed:i,handle:{el:e.shell,closed:a,close:()=>M(e,o,`dismissed`,null),reload:()=>N(e,o)},pendingRefresh:r};return e.session=o,o}function M(e,t,n,r){e.session===t&&(t.closing={status:n,detail:r},O(e)?wt(e,t):Ct(e))}function Ct(e){let t=bt(e);t.dispatchEvent(new CustomEvent(`wui-modal-close`,{bubbles:!0,cancelable:!0,detail:{reason:`dismiss`}}))&&t.hide()}function wt(e,t){let n=e.shell,{status:r,detail:i}=S(t.closing,`the closing state`),a=n.contains(document.activeElement);e.queue.abort(),e.session=null,ut(k(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),j(e,n,`closed`,{status:r,url:t.url}),Tt(t),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function Tt(e){let t=e.pendingRefresh;e.pendingRefresh=null,t&&fe(t).catch(m)}function Et(e,t){for(let n=e;n!==null;n=n.parentElement){let e=n instanceof HTMLElement?x.get(n):void 0;if(e?.session){let n=de(t);return e.session.pendingRefresh=ne(e.session.pendingRefresh,{...t,message:n?t.message:null,action:n?t.action:null}),!0}}return!1}oe(Et);function Dt(e){let t=e.session;if(e.queue.abort(),e.session=null,_t(e),t){let n=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n.status,detail:n.detail}),j(e,e.shell,`closed`,{status:n.status,url:t.url}),Tt(t);let r=document.activeElement;t.trigger?.isConnected&&(!r||r===document.body||e.shell.contains(r))&&t.trigger.focus?.()}e.cache||(A(e,lt(e.placeholder)),e.loadedUrl=null,D(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function Ot(e,t){let n=Rt(t instanceof CustomEvent?t.detail:null,`trigger`),r=n instanceof HTMLElement?n:null,i=r?.getAttribute(`data-wui-url`)||e.remoteUrl||``,a=St(e,i,{trigger:r});a.explicitSize=kt(e,r?.getAttribute(`data-wui-size`)),a.explicitSize&&D(e.shell,a.explicitSize),e.cache&&e.loadedUrl===i||(e.loadedUrl&&A(e,lt(e.placeholder)),N(e,a,{keepPlaceholder:!0}))}function kt(e,t){try{return nt(e,t)}catch(e){return m(e),null}}async function N(e,t,{keepPlaceholder:n=!1}={}){n||A(e,st(t.options.title||At(e)));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate,timeoutMs:Ie(t.trigger)});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if(r.kind===`ok`&&Pt(e,t,r.html,!1))return e.loadedUrl=t.url,j(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return A(e,ct(t.options.title||At(e),i)),mt(e)&&ht(S(k(e),`a card`),!1,tt(e)),j(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var At=e=>k(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,jt=`/_content/Webority.Ui.Razor/js/`,Mt=e=>new URL(e,window.location.href).pathname.includes(jt);function Nt(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function Pt(e,t,n,r){let i=_e(n),a=!1;for(let e of i.querySelectorAll(`script`)){if(e.getAttribute(`type`)===`application/json`)continue;let t=e.getAttribute(`src`);e.remove(),t&&Mt(t)?Nt(t):a=!0}a&&ee(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let o=C(i,He);if(!o)return m(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;if(A(e,o),r||_t(e),!O(e)){D(e.shell,t.explicitSize||kt(e,o.getAttribute(`data-wui-size`))||e.defaultSize);let n=o.getAttribute(`data-wui-title`);n&&e.shell.setAttribute(`aria-label`,n)}return mt(e)&&ht(o,r,tt(e)),!0}var Ft=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function It(e,t,n){let r=[...e.elements].filter(e=>e.matches(Ft));if(n){e.setAttribute(`data-wui-submitting`,``);let n=t&&r.includes(t)?t:r[0];for(let e of r)e.toggleAttribute(`data-wui-was-disabled`,e.disabled),e.disabled=!0;n&&(n.classList.add(`is-loading`),n.setAttribute(`aria-busy`,`true`),n.tagName===`BUTTON`&&n.prepend(i(`span`,{class:`spinner-border spinner-border-sm me-2`,"aria-hidden":`true`,"data-wui-submit-spinner":!0})))}else{e.removeAttribute(`data-wui-submitting`);for(let e of r)e.disabled=e.hasAttribute(`data-wui-was-disabled`),e.removeAttribute(`data-wui-was-disabled`),e.classList.remove(`is-loading`),e.removeAttribute(`aria-busy`),e.querySelector(`[data-wui-submit-spinner]`)?.remove()}}function Lt(e){for(let t of e.querySelectorAll(Ve))t.remove();for(let t of e.querySelectorAll(ze))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}var Rt=(e,t)=>{if(typeof e==`object`&&e&&t in e)return Reflect.get(e,t)};async function zt(e){if(e.status<400||e.status>499||!e.response?.headers.get(`content-type`)?.toLowerCase().includes(`json`))return null;let t;try{t=JSON.parse(await ke(e))}catch{return null}return Ae(t,e.response.statusText)}function Bt(e,t,n,r){let i={forbidden:b().forbiddenMessage,networkCheck:s(`httpFailure`,te).networkCheckText,client:b().clientMessage,server:b().serverMessage,network:b().networkMessage,timeout:b().timeoutMessage},a=t.closest(`.wui-modal-body`)||t;a.querySelector(`[data-wui-modal-submit-error]`)?.remove(),Lt(a);let o=document.createElement(`div`);o.className=`alert alert-danger wui-modal-submit-error`,o.setAttribute(`role`,`alert`),o.setAttribute(`data-wui-modal-submit-error`,``),o.textContent=`${b().submitFailedMessage} ${r||i[n]||b().serverMessage}`,a.prepend(o),gt(e,o.textContent)}var Vt=(e,t)=>{let n=new URL(e,window.location.href);for(let[e,r]of t)typeof r==`string`&&n.searchParams.append(e,r);return n.origin===window.location.origin?n.pathname+n.search:n.href};async function Ht(e,t){let n=t.target,r=e.session;if(!(n instanceof HTMLFormElement)||!r||n.hasAttribute(`data-wui-native`)||!n.closest(He)||(t.preventDefault(),n.hasAttribute(`data-wui-submitting`)))return;let i=`submitter`in t&&(t.submitter instanceof HTMLButtonElement||t.submitter instanceof HTMLInputElement)?t.submitter:null,a=i?.getAttribute(`formaction`)||n.getAttribute(`action`)||r.url,o=(i?.getAttribute(`formmethod`)||n.getAttribute(`method`)||`GET`).toUpperCase(),s=new FormData(n);i?.name&&!s.has(i.name)&&s.append(i.name,i.value);let c=o===`GET`;It(n,i,!0);let l;try{l=await e.queue.run(c?Vt(a,s):a,{method:o,body:c?void 0:s,navigate:r.options.navigate,timeoutMs:Ie(r.trigger)})}catch(t){m(t),e.session===r&&n.isConnected&&(It(n,i,!1),Bt(e,n,`server`,null));return}if(e.session!==r)return;if(n.isConnected&&It(n,i,!1),l.kind===`ok`&&l.result===`success`){Ut(e,r,l);return}if(l.kind===`aborted`||l.kind===`stale`||l.kind===`session`)return;if(l.kind===`ok`&&l.html){let t=l.result===Be;if(Pt(e,r,l.html,t)){if(t){let t=S(k(e),`a card`).querySelector(Ve)?.textContent?.replace(/\s+/g,` `).trim();gt(e,t||b().invalidMessage)}return}}let u=l.kind===`ok`||l.kind===`validation`?`server`:l.kind,d=await zt(l);e.session===r&&Bt(e,n,u,d)}function Ut(e,t,n){let r=n.message,i=n.redirect||null,a=n.toastVariant||`success`;if(!re(a))throw TypeError(`Unknown toast variant "${a}". Use ${me.join(`, `)}.`);let o={url:t.url,trigger:t.trigger,handle:t.handle,message:r,redirect:i,data:n.data??null,container:e.container},s=i||se(t.trigger)?null:le(n),c=!(n.next&&!i)&&!n.keepOpen,l=s!==null&&c&&de(s);i&&!t.options.navigate?g(r,a):r&&!l&&h().toast(r,{variant:a}),j(e,t.trigger?.isConnected?t.trigger:document,`success`,o),t.options.onSuccess?.(o,t.handle),i&&(t.options.navigate||(e=>window.location.assign(e)))(i),s&&(t.pendingRefresh=ne(t.pendingRefresh,{...s,action:null,message:l?s.message:null}));let u=n.next;u&&!i?(t.url=u,t.method=`GET`,t.body=void 0,N(e,t)):n.keepOpen?n.html&&n.data===null&&Pt(e,t,n.html,!1):M(e,t,`success`,o)}function Wt(e){let t=E(e.target,`[data-wui-modal], [data-wui-drawer], [data-wui-pane]`);t&&(t.matches(`a[href]`)&&(e.ctrlKey||e.metaKey||e.shiftKey||e.button!==0)||(e.preventDefault(),t.hasAttribute(`data-wui-pane`)?Zt(t.getAttribute(`data-wui-pane`)??``,{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{qe(e)||m(e)}):t.hasAttribute(`data-wui-modal`)?qt(t.getAttribute(`data-wui-modal`)??``,{size:t.getAttribute(`data-wui-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{qe(e)||m(e)}):Yt(t.getAttribute(`data-wui-drawer`)??``,{size:t.getAttribute(`data-wui-drawer-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{qe(e)||m(e)})))}function Gt(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=E(e.target,Xt);if(!t)return;let n=x.get(t),r=e.currentTarget;n?.session&&r instanceof Document&&!r.querySelector(`wui-modal[open]`)&&(t.querySelector(`form[data-wui-submitting]`)||(e.preventDefault(),M(n,n.session,`dismissed`,null)))}function Kt(e=document){let t=e instanceof Document?e:S(e.ownerDocument,`an owner document`);Ge.has(t)||(Ge.add(t),t.addEventListener(`click`,Wt),t.addEventListener(`keydown`,Gt));let n=Ke(e,`wui-modal[data-wui-remote-url]`);e instanceof HTMLElement&&e.matches(`wui-modal[data-wui-remote-url]`)&&n.unshift(e);for(let e of n)xt(e)}function qt(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=t.container===`drawer`,r=n?$e(t.size):Xe(t.size),i=t.placement||`center`;if(!Qe.includes(i))throw TypeError(`WUI.modal.load: unsupported placement "${i}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(T());let a=at(n?`drawer`:`modal`);Kt(document);let o=xt(a),s=mt(o),c=St(o,e,t);c.explicitSize=r,D(o.shell,r||o.defaultSize),n||w(o.shell,`.modal-dialog`,`a dialog frame`).classList.toggle(`modal-dialog-centered`,i===`center`),t.title&&o.shell.setAttribute(`aria-label`,t.title),s||(a.toggleAttribute(`static`,t.staticBackdrop!==!1),a.toggleAttribute(`no-escape`,t.closeOnEscape===!1));let l=s?Promise.resolve():new Promise(e=>a.addEventListener(`wui-modal-opened`,()=>e(),{once:!0})),u=N(o,c);return s||bt(o).show(),Jt(o,c,t,l,u,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function Jt(e,t,n,r,i,a){let o=new Promise((r,i)=>{n.signal?.addEventListener(`abort`,()=>{e.session===t&&(e.queue.abort(),M(e,t,`dismissed`,{aborted:!0})),i(T())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw T();if(e===`session`)throw Error(`${a}(${t.url}): the session expired; the browser is signing in again.`);return t.handle});return Promise.race([s,o])}function Yt(e,t={}){return qt(e,{...t,container:`drawer`,placement:void 0})}var Xt=`[data-wui-pane-host]`;function Zt(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=rt(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(T());Kt(document);let r=xt(n),i=St(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=N(r,i);return Jt(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function Qt(e){let t=rt(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=x.get(t);n?.session&&M(n,n.session,`dismissed`,null)}var $t=8e3,en=()=>s(`toast`,f);function tn(e){if(!re(e))throw RangeError(`Unknown toast variant "${e}".`);return e}function P(e,t=`success`){e?.message&&nn(e.message,t,e.toastAction)}function nn(e,t,n=null){n?h().toast(e,{variant:tn(t),duration:$t,action:{label:n.label,onClick:e=>void rn(n,e)}}):h().toast(e,{variant:tn(t)})}async function rn(e,t=null){let n=await _(e.url,{method:e.method});n.kind!==`session`&&n.kind!==`aborted`&&(n.ok?(ae(n)||P(n,n.toastVariant||`success`),await ie(n,{origin:t})):h().toast(n.message||en().failedText,{variant:`danger`}))}var an=/* @__PURE__ */ new Set([204,205,304]),on=e=>{let t=new Headers;for(let n of e.split(/\r?\n/)){let e=n.indexOf(`:`);e>0&&t.append(n.slice(0,e).trim(),n.slice(e+1).trim())}return t};async function sn(e,t,n={}){if(!(t instanceof FormData))throw TypeError(`wuiUpload: body must be FormData`);let r=n.timeoutMs;if(r!==void 0&&!(Number.isFinite(r)&&r>0))throw TypeError(`wuiUpload: timeoutMs must be a positive number`);let i={Accept:`text/html`,"X-Requested-With":`XMLHttpRequest`,[Ce]:`1`,...n.headers};if(Ee(e)){let e=ye();e&&(i[e.header]=e.token)}let a=n.signal,o=n.navigate||(e=>window.location.assign(e));return a?.aborted?be(`aborted`):new Promise(s=>{let c=new XMLHttpRequest,l=!1,u,d=()=>c.abort(),f=(e,t=null,n=``)=>{u!==void 0&&clearTimeout(u),a?.removeEventListener(`abort`,d),s(be(e,t,n))};c.upload.onprogress=e=>{n.onProgress?.(e.loaded,e.lengthComputable?e.total:0)},c.onload=()=>{let t=c.status;if(t===0){f(`network`);return}let n=on(c.getAllResponseHeaders()),r=Te(t,n),i=c.responseURL!==``&&c.responseURL!==new URL(e,window.location.href).href;r===`ok`&&i&&n.get(ve.fragment)!==`1`&&(r=`session`);let a=c.responseText,s=r===`ok`||r===`validation`?a:``;if(t<200||t>599){f(r,null,s);return}let l=new Response(an.has(t)?null:a,{status:t,headers:n});r===`session`?(o(t===401?n.get(`Location`)||window.location.href:c.responseURL),f(`session`,l)):f(r,l,s)},c.onerror=()=>f(`network`),c.onabort=()=>{f(a?.aborted?`aborted`:l?`timeout`:`aborted`)},r!==void 0&&(u=setTimeout(()=>{l=!0,c.abort()},r)),a?.addEventListener(`abort`,d,{once:!0}),c.open(`POST`,e,!0);for(let[e,t]of Object.entries(i))c.setRequestHeader(e,t);c.send(t)})}var F=`wuiConfirm`,cn=Object.freeze([`danger`]),ln=Object.freeze([`warning`,`info`,`delete`]),I=()=>s(`confirmDialog`,d),un=/* @__PURE__ */ new WeakSet,dn=/* @__PURE__ */ new WeakSet,L=null,R=null,z=!1,B=(e,t)=>{e&&h().toast(e,{variant:t})};function fn(){let r=document.getElementById(F);if(r)return n(r.closest(`wui-modal`),`#${F} must be a wui-modal.`);let a=document.createElement(`wui-modal`);a.id=F;let o=document.createElement(`dialog`);return o.className=`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${y.md}px`),o.replaceChildren(i(`div`,{class:`modal-dialog modal-dialog-centered wui-rb-dialog`},i(`div`,{class:`modal-content wui-modal wui-confirm`},i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-confirm-content`},i(`span`,{class:`wui-confirm-icon`},i(`wui-status-icon`,{tone:`info`,size:120})),i(`h3`,{class:`wui-confirm-title`,tabindex:-1,"data-autofocus":``}),i(`p`,{class:`wui-confirm-msg`}))),i(`div`,{class:`wui-modal-footer`},i(`div`,{class:`wui-confirm-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":``,"data-wui":t},I().cancelLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-app-confirm":``,"data-wui":t})))))),a.append(o),document.body.appendChild(a),a}function pn(e,t){let n=e.getAttribute(`data-wui-confirm-tone`);if(n!==null&&!cn.includes(n))throw TypeError(`data-wui-confirm-tone="${n}" is not supported. Use danger, or leave it off.`);mn({title:e.getAttribute(`data-wui-confirm-title`),message:e.getAttribute(`data-wui-confirm`),label:e.getAttribute(`data-wui-confirm-label`),danger:n===`danger`,cancel:void 0,icon:void 0},t)}function mn({title:e,message:t,label:r,danger:i,cancel:a,icon:o},s){let c=fn(),l=c.querySelector(`.wui-confirm-title`),u=c.querySelector(`[data-app-confirm]`);if(!l||!u)throw Error(`#${F} is not a confirm dialog with a confirm button. Render <app-confirm-dialog id="${F}"> without confirm-href, or leave the dialog to the library.`);let d=c.querySelector(`.wui-confirm-msg`);d||(d=document.createElement(`p`),d.className=`wui-confirm-msg`,l.after(d));let f=e||I().confirmTitle;l.textContent=f,d.textContent=t,u.textContent=r||I().confirmLabel,u.classList.toggle(`btn-danger`,i),u.classList.toggle(`btn-primary`,!i),c.querySelector(`wui-status-icon`)?.setAttribute(`tone`,o??(i?`delete`:`info`));let p=c.querySelector(`[data-wui-dismiss]`);p&&(p.textContent=a||I().cancelLabel),n(c.querySelector(`dialog`),`#${F} has no <dialog>.`).setAttribute(`aria-label`,f),R=s,z=!1,c.show()}var V=(e,t)=>{L=e;try{t()}finally{L=null}},H=(e,t)=>{let n=Reflect.get(e,t);if(n===void 0||typeof n==`string`)return n;throw TypeError(`confirmAction: ${t} must be text.`)},hn=e=>{if(typeof e!=`object`||!e)throw TypeError(`confirmAction: options must be an object with a message.`);let t=`message`in e?e.message:void 0;if(typeof t!=`string`)throw TypeError(`confirmAction: message must be text.`);return{title:H(e,`title`),message:t,label:H(e,`label`),tone:H(e,`tone`),cancel:H(e,`cancel`),icon:H(e,`icon`)}};function gn(e,t,n){let{title:r,message:i,label:a,tone:o,cancel:s,icon:c}=hn(t);if(o!=null&&!cn.includes(o))throw TypeError(`confirmAction: tone "${o}" is not supported. Use danger, or leave it off.`);if(c!=null&&!ln.includes(c))throw TypeError(`confirmAction: icon "${c}" is not supported. Use warning, info or delete, or leave it off.`);Rn(e.ownerDocument),mn({title:r,message:i,label:a,danger:o===`danger`,cancel:s,icon:c},()=>V(e,n))}var _n=e=>`disabled`in e&&e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`,vn=e=>{r(e,HTMLElement,`data-wui-confirm needs an HTML element to click.`).click()};function yn(e){let t=a(e.target,`[data-wui-confirm]:not(form)`);t&&t!==L&&!_n(t)&&(e.preventDefault(),e.stopImmediatePropagation(),pn(t,()=>V(t,()=>vn(t))))}function bn(e){let t=e.target;if(!(t instanceof HTMLFormElement)||!t.hasAttribute(`data-wui-confirm`)||t===L||e.submitter&&e.submitter===L||t.querySelector(`input[data-app-repeater-hidden]`))return;e.preventDefault(),e.stopImmediatePropagation();let n=e.submitter instanceof HTMLButtonElement||e.submitter instanceof HTMLInputElement?e.submitter:null,r=n?.form===t?n:void 0;pn(t,()=>V(t,()=>t.requestSubmit(r)))}function xn(e){let t=a(e.target,`#${F} [data-app-confirm]`);t&&!t.hasAttribute(`disabled`)&&R&&(z=!0,n(t.closest(`wui-modal`),`#${F} is missing around its confirm button.`).hide())}function Sn(e){if(!(e.target instanceof Element)||e.target.id!==`wuiConfirm`)return;let t=z?R:null;R=null,z=!1,t?.()}var U=e=>e===`forbidden`?I().forbiddenMessage:e===`networkCheck`?s(`httpFailure`,te).networkCheckText:e===`network`?I().networkMessage:e===`timeout`?I().timeoutMessage:I().failedMessage,Cn=(e,t)=>{`disabled`in e&&(e.disabled=t)},wn=e=>{Cn(e,!1),e.removeAttribute(`aria-busy`)};async function Tn(e){let t=e.getAttribute(`data-wui-post`);if(!t)throw Error(`A data-wui-post button needs the URL the action posts to.`);return En(t,e)}async function En(e,t,n){Cn(t,!0),t.setAttribute(`aria-busy`,`true`);let r=we(t.getAttribute(`data-wui-timeout`))??3e4,i=await _(e,{method:`POST`,body:n,timeoutMs:r});if(i.kind===`session`||i.kind===`aborted`)return;let a=i.toastVariant||`success`;if(i.ok&&i.redirect)g(i.message,a,i.toastAction),window.location.assign(i.redirect);else if(i.ok){let e=se(t);if(!e&&ae(i)){await ie(i,{origin:t})===`held`&&wn(t);return}wn(t),P(i,a),e||await ie(i,{origin:t})}else wn(t),B(i.message||U(i.kind),`danger`)}var Dn=e=>typeof e!=`object`||!e||!(`code`in e)?null:typeof e.code==`string`?e.code:null,On=e=>(e.response?.headers.get(`Content-Type`)??``).toLowerCase().includes(`json`)?e.data:e.html===``?null:e.html;async function kn(e,t={}){if(t.body!==void 0&&t.json!==void 0)throw TypeError(`postAction takes a body or a json value, not both.`);let n=t.method??`POST`;if(!xe.includes(n))throw TypeError(`postAction method must be POST, PUT, PATCH or DELETE.`);let r=t.timeoutMs??3e4;if(!Number.isInteger(r)||r<0)throw TypeError(`postAction timeoutMs must be a whole number of milliseconds, 0 for no limit.`);if(t.onUploadProgress!==void 0){if(!(t.body instanceof FormData))throw TypeError(`postAction onUploadProgress needs a FormData body.`);if(n!==`POST`)throw TypeError(`postAction onUploadProgress needs the POST method.`)}let i={},a;t.json===void 0?t.body instanceof FormData||t.body instanceof URLSearchParams?a=t.body:t.body!==void 0&&(a=new URLSearchParams(t.body)):(i[`Content-Type`]=`application/json`,a=JSON.stringify(t.json));let o;try{o=t.onUploadProgress!==void 0&&t.body instanceof FormData?await sn(e,t.body,{onProgress:t.onUploadProgress,headers:i,timeoutMs:r===0?void 0:r}):await _(e,{method:n,body:a,headers:i,timeoutMs:r})}catch(e){throw m(e),e}if(o.kind===`session`||o.kind===`aborted`)throw new v(U(o.kind),{code:null,status:o.status,html:null,body:null,kind:o.kind});let s=t.toast!==!1,c=t.refresh!==!1,l=o.toastVariant||`success`;if(o.ok){if(o.redirect)g(s?o.message:null,l,s?o.toastAction:null),window.location.assign(o.redirect);else{let e=le(o);s&&!(c&&ae(o))&&P(o,l),e!==null&&c&&await fe({...e,message:s?e.message:null,action:s?e.action:null})}return On(o)}let u;try{u=await ke(o)}catch(e){m(e);let t=o.message||U(o.kind);throw B(t,`danger`),new v(t,{code:null,status:o.status,html:null,body:null,kind:o.kind,cause:e})}let d=(o.response?.headers.get(`Content-Type`)??``).toLowerCase(),f=null;if(d.includes(`json`))try{f=JSON.parse(u)}catch{f=null}let p=Ae(f,o.response?.statusText??``)||o.message||U(o.kind),ee=d.includes(`text/html`)?u:null;throw(o.kind!==`validation`||ee===null)&&B(p,`danger`),new v(p,{code:Dn(f),status:o.status,html:ee,body:f,kind:o.kind})}function An(e,t){Cn(e,!1),e.removeAttribute(`aria-busy`),m(t),B(I().failedMessage,`danger`)}function jn(e){let t=a(e.target,`[data-wui-post]`);t&&(e.preventDefault(),_n(t)||t.getAttribute(`aria-busy`)===`true`||Tn(t).catch(e=>An(t,e)))}function Mn(e){let t=a(e.target,`form[data-wui-post-form]`);if(!(t instanceof HTMLFormElement)||e.defaultPrevented)return;e.preventDefault();let r=n(e.submitter||t.querySelector(`button:not(.repeater-add):not(.repeater-remove)`),`A data-wui-post-form needs a submit button to report its result on.`);if(r.getAttribute(`aria-busy`)===`true`)return;let i=new URL(n(t.getAttribute(`action`),`A data-wui-post-form needs an action attribute to post to.`),document.baseURI).href;En(i,r,new FormData(t)).catch(e=>An(r,e)),t.closest(`wui-dropdown`)?.hide()}var W=(e,t)=>{e.disabled=!1,e.removeAttribute(`aria-busy`),t&&p(t,null)};async function Nn(e,t){let n=e.dataset.url;if(!n)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);e.disabled=!0,e.setAttribute(`aria-busy`,`true`),t&&p(t,`saving`);let r=we(e.getAttribute(`data-wui-timeout`))??3e4,i=await _(n,{method:(e.dataset.method||`post`).toUpperCase(),timeoutMs:r});if(i.kind===`session`)return;if(i.kind===`aborted`){W(e,t);return}let a=i.toastVariant||`success`;if(i.ok&&i.redirect){g(i.message,a,i.toastAction),window.location.assign(i.redirect);return}if(i.ok){let n=le(i);if(se(e)||n===null||ce(n)){W(e,t),P(i,a);return}if(ue({...n,reload:`page`},e)){W(e,t);return}g(i.message,a,i.toastAction),pe();return}let o=i.message||U(i.kind);e.disabled=!1,e.removeAttribute(`aria-busy`),t&&p(t,`error`,o),B(o,`danger`)}var Pn=/* @__PURE__ */ new WeakSet;function Fn(e){let t=a(e.target,`[data-wui-row-action]`);if(!t||t.closest(`[data-wui-server]`))return;if(!(t instanceof HTMLButtonElement)){if(Pn.has(t))return;Pn.add(t),m(/* @__PURE__ */ Error(`A [data-wui-row-action] element must be a button with data-url, so its click does nothing: ${t.getAttribute(`data-wui-row-action`)??``}`));return}if(e.preventDefault(),t.disabled||t.getAttribute(`aria-busy`)===`true`)return;let n=t.closest(`tr`);Nn(t,n).catch(e=>{W(t,n),m(e),B(I().failedMessage,`danger`)})}var In=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.form:null;function Ln(e){if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-wui-auto-submit]`);if(!t)return;let n=In(e.target)||t.closest(`form`);n instanceof HTMLFormElement&&n.requestSubmit()}function Rn(e){dn.has(e)||(dn.add(e),e.addEventListener(`click`,xn),e.addEventListener(`wui-modal-closed`,Sn))}function zn(e=document){let t=e instanceof Element?e.ownerDocument:e;un.has(t)||(un.add(t),t.addEventListener(`click`,yn,!0),t.addEventListener(`submit`,bn,!0),Rn(t),t.addEventListener(`click`,jn),t.addEventListener(`click`,Fn),t.addEventListener(`submit`,Mn),t.addEventListener(`change`,Ln))}var G=()=>s(`unsavedChanges`,l),K=`form[data-wui-unsaved]`,Bn=`[aria-invalid="true"], .field-error:not(:empty), .field-validation-error, .validation-summary-errors, .wui-error-summary`,Vn=`[download], [data-wui-modal], [data-wui-post], [data-bs-toggle]`,Hn=/* @__PURE__ */ new Set([`submit`,`button`,`reset`,`image`]),Un=/* @__PURE__ */ new Set([`hidden`,`checkbox`,`radio`,`file`,`submit`,`button`,`reset`,`image`,`range`,`color`]),Wn=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,Gn=e=>Wn(e)?e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled:`disabled`in e&&!!e.disabled,Kn=e=>`name`in e&&typeof e.name==`string`&&e.name!==``,qn=e=>typeof e==`object`&&!!e,Jn=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&typeof e[0]==`string`);function Yn(e){let t=JSON.parse(e);if(!Jn(t))throw Error(`unsaved-changes snapshot is malformed`);return t}var q=/* @__PURE__ */ new WeakMap,Xn=/* @__PURE__ */ new WeakSet,Zn=e=>`${e.name}:${e.size}:${e.lastModified}`,J=e=>[...e.querySelectorAll(K)].filter(e=>e instanceof HTMLFormElement);function Y(e){let t=[];for(let n of e.elements)Kn(n)&&!Gn(n)&&(Wn(n)&&Hn.has(n.type)||(n instanceof HTMLInputElement&&(n.type===`checkbox`||n.type===`radio`)?t.push([n.name,n.value,n.checked]):n instanceof HTMLInputElement&&n.type===`file`?t.push([n.name,[...n.files||[]].map(Zn)]):n instanceof HTMLSelectElement&&n.type===`select-multiple`?t.push([n.name,[...n.selectedOptions].map(e=>e.value)]):n instanceof HTMLFieldSetElement||n instanceof HTMLObjectElement?t.push([n.name,null]):t.push([n.name,`value`in n?n.value:null])));return JSON.stringify(t)}function X(e){return Y(e)}function Qn(e,t){let n=/* @__PURE__ */ new Map,r=Yn(t);for(let e of r){let t=n.get(e[0]);t?t.push(e):n.set(e[0],[e])}let i=Yn(Y(e)).map(e=>n.get(e[0])?.shift()??e);for(let e of n.values())i.push(...e);return JSON.stringify(i)}function $n(e){for(let t of e.elements)if(Wn(t)&&t.name&&!Gn(t)){if(t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement&&!Un.has(t.type)){if(t.value.trim()!==``)return!0}else if(t instanceof HTMLInputElement&&t.type===`file`&&(t.files?.length??0)>0)return!0}return!1}var er=e=>({saved:e.querySelector(Bn)&&$n(e)?null:Y(e),engaged:!1,discarded:!1});function tr(e){let t=q.get(e);return!t||t.discarded||!e.isConnected?!1:t.saved===null||t.engaged&&Y(e)!==t.saved}var nr=(e,t)=>J(e).filter(e=>e!==t&&tr(e));function rr(e,t,n){let r=t.map(e=>e.getAttribute(`data-wui-unsaved`)).find(Boolean)||G().message;gn(e,{title:G().title,message:r,label:G().leaveLabel,cancel:G().keepLabel,icon:`warning`,tone:`danger`},()=>{for(let e of t){let t=q.get(e);t&&(t.discarded=!0)}n()})}function ir(e){if(e.matches(Vn))return!1;let t=e.getAttribute(`target`);if(t&&t.toLowerCase()!==`_self`)return!1;let n=e.getAttribute(`href`);if(n===null)return!1;let r=new URL(n,window.location.href);if(r.protocol!==`http:`&&r.protocol!==`https:`)return!1;let i=window.location;return!(r.hash&&r.origin===i.origin&&r.pathname===i.pathname&&r.search===i.search)}function ar(e,t){if((t?.getAttribute(`formmethod`)||e.getAttribute(`method`)||`get`).toLowerCase()===`dialog`)return!1;let n=t?.getAttribute(`formtarget`)||e.getAttribute(`target`);return!n||n.toLowerCase()===`_self`}function or(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target,n=a(t,`a[href]`);if(!(n instanceof HTMLAnchorElement)||!ir(n))return;let r=nr(n.ownerDocument,null);r.length&&(e.preventDefault(),rr(n,r,()=>n.click()))}function sr(e){let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented||!ar(t,e.submitter))return;let n=nr(t.ownerDocument,t);if(n.length){e.preventDefault();let r=e.submitter,i=(r instanceof HTMLButtonElement||r instanceof HTMLInputElement)&&r.form===t?r:void 0;rr(t,n,()=>t.requestSubmit(i));return}let r=q.get(t);r&&(r.saved=Y(t),r.discarded=!1)}function cr(e){nr(document,null).length&&e.preventDefault()}function lr(e){let t=e.target,n=a(t,K);return n instanceof HTMLFormElement?n:null}function ur(e){let t=lr(e);if(!t)return;let n=q.get(t);n&&!n.engaged&&(n.saved!==null&&(n.saved=Y(t)),n.engaged=!0)}function dr(e){let t=lr(e),n=t&&q.get(t);n&&(n.discarded=!1,e.isTrusted&&(n.engaged=!0))}function fr(e){for(let t of J(e)){let e=q.get(t);e?.saved&&(e.saved=Qn(t,e.saved))}}function pr(e){let t=qn(e)?e.handle:void 0;return qn(t)?t.el:void 0}function mr(e){if(!(e instanceof CustomEvent))return;let t=pr(e.detail);if(t instanceof Element)for(let e of J(t))gr(e)}function hr(e=document){let t=e instanceof Document?e:e.ownerDocument;if(!Xn.has(t)){Xn.add(t);for(let e of[`focusin`,`pointerdown`,`drop`])t.addEventListener(e,ur,!0);for(let e of[`input`,`change`])t.addEventListener(e,dr,!0);t.addEventListener(`click`,or),t.addEventListener(`submit`,sr),t.addEventListener(`wui:modal:success`,mr),t.addEventListener(o,()=>fr(t)),n(t.defaultView,`unsaved-changes guard needs a document with a window`).addEventListener(`beforeunload`,cr)}let r=J(e);e instanceof HTMLFormElement&&e.matches(K)&&r.unshift(e);for(let e of r)q.has(e)||q.set(e,er(e))}function gr(e){if(!(e instanceof HTMLFormElement)||!e.matches(K))throw TypeError(`resetUnsavedChanges: ${String(e)} is not a <form data-wui-unsaved>.`);q.set(e,{saved:Y(e),engaged:!1,discarded:!1})}var _r=()=>s(`drawer`,c),vr=`wui:drawer:discard`,Z=`wui-drawer[confirm-discard]`,yr=`wui-modal`,br=`data-wui-no-discard`,xr=`.wui-drawer-discard`,Sr=`input, select, textarea`,Cr=e=>typeof e==`object`&&!!e||typeof e==`function`;function wr(e){let t=e.currentTarget;if(!(t instanceof Document))throw Error(`The discard guard is not wired on a document.`);return t}function Tr(e,t){return a(e,t)}var Er=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement,Q=/* @__PURE__ */ new WeakMap,Dr=/* @__PURE__ */ new WeakSet,Or=/* @__PURE__ */ new WeakSet;function kr(n,r,i,a,o){let s=n.createElement(`button`);return s.type=`button`,s.className=e(r,i,`sm`),s.dataset.wui=t,s.setAttribute(a,``),s.textContent=o,s}function Ar(e,t){let n=e.createElement(`div`);n.className=`wui-drawer-discard`,n.setAttribute(`role`,`alert`);let r=e.createElement(`span`);return r.className=`wui-drawer-discard-text`,r.textContent=t,n.append(r,kr(e,`danger`,`solid`,`data-wui-discard-confirm`,_r().discardLabel),kr(e,`primary`,`soft`,`data-wui-discard-keep`,_r().keepLabel)),n}function jr(e){if(!(e instanceof Element))return null;let t=e.closest(Z);if(t)return t;let n=e.closest(yr);return n&&$(n).length?n:null}function Mr(e){return e.closest(Z)??e.closest(yr)}function Nr(e,t){return t.hasAttribute(br)||e.hasAttribute(br)?!1:t.hasAttribute(`confirm-discard`)||e.hasAttribute(`data-wui-confirm-discard`)?!0:(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`}function $(e){return e.matches(Z)?e.querySelectorAll(`form`):[...e.querySelectorAll(`form`)].filter(t=>Nr(t,e))}function Pr(e){let t=Q.get(e);return t!=null&&X(e)!==t}function Fr(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-drawer-footer`,n(e.querySelector(`.wui-drawer-panel`),`The drawer has no panel to hold its footer.`).append(t),Or.add(t),t}function Ir(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-modal-footer`,(e.querySelector(`.wui-modal-body`)?.parentElement??e.querySelector(`.modal-content`)??e).append(t),Or.add(t),t}function Lr(e){let t=e.querySelector(`[data-wui-discard-confirm]`);if(!(t instanceof HTMLElement))throw Error(`The discard prompt has no confirm button.`);t.focus()}function Rr(e,t,n){let r=e.querySelector(xr);if(r){Lr(r);return}let i=Ar(e.ownerDocument,t),a;if(e.matches(Z))a=e.querySelector(`.wui-drawer-footer`)??Fr(e),a.prepend(i);else if(e.hasAttribute(`confirm-discard`))a=e.querySelector(`.wui-modal-footer`)??Ir(e),a.prepend(i);else{if(!n)throw Error(`A discard prompt needs the form that is dirty.`);a=n.querySelector(`.modal-footer`)??e.querySelector(`.wui-modal-footer`)??Ir(e),a.prepend(i)}a.classList.add(`wui-drawer-discarding`),Lr(i)}function zr(e){let t=e.parentElement;if(e.remove(),!t)throw Error(`The discard prompt has no footer.`);t.classList.remove(`wui-drawer-discarding`),Or.has(t)&&t.remove()}function Br(e){for(let t of $(e))for(let e of t.querySelectorAll(Sr))if(Er(e)&&e.type!==`hidden`&&!e.disabled){e.focus({preventScroll:!0});return}}function Vr(e){let t=jr(e.target);if(t)for(let e of $(t))Q.get(e)??Q.set(e,X(e))}function Hr(e){for(let t of wr(e).querySelectorAll(`form`)){let e=Q.get(t);e!=null&&Q.set(t,Qn(t,e))}}function Ur(e){let t=e.target;t instanceof HTMLFormElement&&jr(t)&&Q.set(t,X(t))}function Wr(e){if(!Cr(e))return;let t=`handle`in e?e.handle:void 0;if(Cr(t))return`el`in t?t.el:void 0}function Gr(e){if(!(e instanceof CustomEvent))return;let t=e.detail,n=Wr(t);if(n instanceof Element)for(let e of n.querySelectorAll(`form`))Q.delete(e)}function Kr(e){let t=e.target;t instanceof Element&&t.matches(Z)&&[...$(t)].some(Pr)&&(e.preventDefault(),Rr(t,t.getAttribute(`confirm-discard`),null))}function qr(e){let t=e.target;if(!(t instanceof Element)||!t.matches(yr))return;let n=[...$(t)].find(Pr);n&&(e.preventDefault(),Rr(t,n.getAttribute(`data-wui-confirm-discard`)??t.getAttribute(`confirm-discard`)??_r().confirmDiscard,n))}function Jr(e){let t=n(e.closest(xr),`The discard button is outside its prompt.`),r=Mr(t);if(zr(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);for(let e of $(r))Q.set(e,X(e));r.dispatchEvent(new CustomEvent(vr,{bubbles:!0})),r.matches(Z)?n(r.closest(`wui-drawer`),`The confirm-discard drawer is not a wui-drawer.`).hide():n(r.closest(`wui-modal`),`The discarded dialog is not a wui-modal.`).hide()}function Yr(e){let t=n(e.closest(xr),`The keep button is outside its prompt.`),r=Mr(t);if(zr(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);Br(r)}function Xr(e){let t=Tr(e.target,`[data-wui-discard-confirm]`);if(t){Jr(t);return}let n=Tr(e.target,`[data-wui-discard-keep]`);n&&Yr(n)}function Zr(e=document){let t=e instanceof Document?e:e.ownerDocument;Dr.has(t)||(Dr.add(t),t.addEventListener(`focusin`,Vr),t.addEventListener(`pointerdown`,Vr),t.addEventListener(`submit`,Ur),t.addEventListener(o,Hr),t.addEventListener(`wui:modal:success`,Gr),t.addEventListener(`wui:modal:loaded`,Gr),t.addEventListener(`wui-drawer-close`,Kr,!0),t.addEventListener(`wui-modal-close`,qr),t.addEventListener(`click`,Xr))}export{v as S,Qt as _,hr as a,qt as b,cn as c,kn as d,sn as f,nn as g,P as h,X as i,gn as l,rn as m,Ar as n,gr as o,$t as p,Zr as r,F as s,vr as t,zn as u,Kt as v,Zt as x,Yt as y};
1
+ import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{i as n,n as r,r as i,t as a}from"./dom-DMQu--xV.js";import{t as o}from"./loader-AIIVAlsd.js";import{r as s}from"./textStore-Cs1SGBoI.js";import{t as c}from"./drawer.g-B-zYKBfQ.js";import{i as l,n as u,r as d,t as f}from"./toast.g-CJ8c0BNZ.js";import{N as p}from"./dataTable-CSP1x4ZA.js";import{n as ee,t as m}from"./devWarn-DXdRWZs3.js";import{t as te}from"./httpFailure.g-DjZzGxPj.js";import{_ as h,a as ne,b as re,c as ie,d as ae,f as oe,i as se,l as ce,o as le,r as ue,s as de,t as fe,u as pe,x as g,y as me}from"./refreshAfter-C2bqZfb9.js";import{t as he}from"./hasOwn-CJsplJ62.js";import{n as ge}from"./svgNodes-CaPMDvv7.js";import{t as _e}from"./serverHtml-BC6tAyAl.js";import{a as ve,d as ye,f as be,h as xe,l as Se,m as _,o as Ce,p as we,s as Te,u as Ee}from"./wuiHttp-8CYWEbRz.js";var v=class extends Error{code;status;html;body;kind;constructor(e,t){super(e,t.cause===void 0?void 0:{cause:t.cause}),this.name=`WuiPostError`,this.code=t.code,this.status=t.status,this.html=t.html,this.body=t.body,this.kind=t.kind}},De=/* @__PURE__ */ new Set(/* @__PURE__ */ `bad request.unauthorized.payment required.forbidden.not found.method not allowed.not acceptable.proxy authentication required.request timeout.conflict.gone.length required.precondition failed.payload too large.uri too long.unsupported media type.range not satisfiable.expectation failed.misdirected request.unprocessable content.unprocessable entity.locked.failed dependency.too early.upgrade required.precondition required.too many requests.request header fields too large.unavailable for legal reasons`.split(`.`)),Oe=e=>typeof e!=`object`||!e?{message:void 0,detail:void 0,title:void 0}:{message:`message`in e?e.message:void 0,detail:`detail`in e?e.detail:void 0,title:`title`in e?e.title:void 0};async function ke(e){return e.html===``?e.response===null?``:e.response.text():e.html}function Ae(e,t){let n=e=>typeof e==`string`?e.trim():``,r=Oe(e),i=n(r.message);if(i)return i;let a=n(r.detail);if(a)return a;let o=n(r.title);if(!o)return null;let s=o.toLowerCase();return De.has(s)||s===t.trim().toLowerCase()?null:o}var je=`wui-remote-modal`,Me=`wui-remote-drawer`,Ne=Object.freeze({sm:360,md:480,lg:640,xl:720}),Pe=`wui-modal-fullscreen`,Fe=`wui-modal-wide`,y=Object.freeze({sm:380,md:440,lg:640,xl:880,wide:1080}),b=()=>s(`modal`,u),Ie=e=>we(e?.getAttribute(`data-wui-timeout`)??null)??3e4,Le=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,Re=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,ze=`[aria-invalid="true"], .is-invalid, .input-validation-error`,Be=`invalid`,Ve=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,He=`[data-wui-modal-content]`,Ue=`[data-wui-pane-close], [data-wui-dismiss]`,We=()=>i(`button`,{type:`button`,class:`wui-modal-close`,"data-wui-dismiss":!0,"aria-label":b().closeLabel},ge({width:18,height:18,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},[[`path`,{d:`M18 6 6 18M6 6l12 12`}]])),x=/* @__PURE__ */ new WeakMap,Ge=/* @__PURE__ */ new WeakSet;function S(e,t){if(e==null)throw TypeError(`The remote modal needs ${t}, and the page does not have it.`);return e}var C=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},w=(e,t,n)=>S(C(e,t),n),Ke=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),T=()=>Object.assign(/* @__PURE__ */ Error(`The remote modal load was aborted.`),{name:`AbortError`}),qe=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,E=(e,t)=>{let n=e instanceof Element?e.closest(t):null;return n instanceof HTMLElement?n:null},Je=e=>he(y,e),Ye=e=>he(Ne,e);function Xe(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(Je(e))return e===`wide`?{px:y.wide,wide:!0}:{px:y[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported modal size "${String(e)}". Use sm, md, lg, xl, wide, fullscreen or a px number.`)}var Ze=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};if(e.classList.contains(`wui-modal-wide`))return{px:y.wide,wide:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:y.md}},D=(e,t)=>{e.classList.toggle(Pe,!!t.fullscreen),e.classList.toggle(Fe,!t.fullscreen&&!!t.wide),t.fullscreen?e.style.removeProperty(`--wui-modal-max-width`):e.style.setProperty(`--wui-modal-max-width`,`${t.px}px`)},Qe=[`center`,`top`];function $e(e){if(e==null||e===``)return null;if(Ye(e))return{px:Ne[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported drawer size "${String(e)}". Use sm, md, lg, xl or a px number.`)}var et=e=>e.container===`drawer`,O=e=>e.container===`pane`,tt=e=>e.container!==`modal`,nt=(e,t)=>et(e)?$e(t):Xe(t),rt=e=>{let t=typeof e==`string`?document.querySelector(e):e,n=t instanceof HTMLElement?t:null;return n?.matches(`[data-wui-pane-host]`)?n:null},it=e=>O(e)?e.shell:w(e.shell,`.modal-dialog`,`a dialog frame`);function at(e=`modal`){let t=e===`drawer`,n=t?Me:je,r=document.getElementById(n);if(r)return r;let a=document.createElement(`wui-modal`);a.id=n,a.setAttribute(`data-wui`,`AppModal`);let o=document.createElement(`dialog`);return o.className=t?`modal wui-modal-shell wui-remote-drawer`:`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${t?Ne.md:y.md}px`),o.replaceChildren(i(`div`,{class:t?`modal-dialog wui-remote-drawer-dialog`:`modal-dialog modal-dialog-centered wui-rb-dialog`},i(`div`,{class:`modal-content wui-modal`}))),a.append(o),document.body.appendChild(a),a}var ot=e=>i(`div`,{class:`wui-modal-header`},i(`div`,{class:`wui-modal-heading`},i(`div`,{class:`wui-modal-headtext`},i(`div`,{class:`wui-modal-title`},e))),We()),st=e=>i(`div`,{class:`modal-content wui-modal`,"aria-busy":`true`},ot(e),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-loading`,role:`status`},i(`span`,{class:`visually-hidden`},b().loadingLabel),i(`div`,{class:`skeleton wui-modal-skeleton`}),i(`div`,{class:`skeleton wui-modal-skeleton`}),i(`div`,{class:`skeleton wui-modal-skeleton wui-modal-skeleton--short`})))),ct=(n,r)=>{let a={forbidden:b().forbiddenMessage,networkCheck:s(`httpFailure`,te).networkCheckText,client:b().clientMessage,server:b().serverMessage,network:b().networkMessage,timeout:b().timeoutMessage};return i(`div`,{class:`modal-content wui-modal`,"data-wui-modal-error":r},ot(n),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-state`,role:`alert`},i(`p`,{class:`wui-modal-state-title`},b().errorTitle),i(`p`,{class:`wui-modal-state-text`},a[r]||b().serverMessage),i(`div`,{class:`wui-modal-state-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":!0,"data-wui":t},b().closeLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-wui-modal-retry":!0,"data-wui":t},b().retryLabel)))))},k=e=>C(e.shell,`.modal-content`),lt=e=>r(e.cloneNode(!0),HTMLElement,`a card copy is not an element`);function ut(e){e&&e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}))}function A(e,t){let n=k(e),r=n?ft(n):/* @__PURE__ */ new Map;ut(n),n?n.replaceWith(t):it(e).appendChild(t),pt(t,r),h().refresh()}var dt=`input[type="file"][name]`;function ft(e){let t=/* @__PURE__ */ new Map;for(let n of e.querySelectorAll(dt)){if(!(n instanceof HTMLInputElement))continue;let e=n.files;e&&e.length>0&&t.set(n.name,[...e])}return t}function pt(e,t){if(t.size!==0&&typeof DataTransfer<`u`)for(let n of e.querySelectorAll(dt)){if(!(n instanceof HTMLInputElement))continue;let e=t.get(n.name);if(!e)continue;let r=new DataTransfer;for(let t of e)r.items.add(t);n.files=r.files,n.dispatchEvent(new Event(`change`,{bubbles:!0}))}}var mt=e=>O(e)?!e.shell.hidden:e.host.hasAttribute(`open`);function ht(e,t,n=!1){let r=t?C(e,ze):null,i=r?r.matches(Le)?r:C(r,Le)||r:null;if(!i&&n)i=C(e,`[data-autofocus]`)||C(e,Re)||C(e,`.wui-modal-close`);else if(!i){let t=Ke(e,Le);i=C(e,`[data-autofocus]`)||t.find(e=>!e.classList.contains(`wui-modal-close`))||t[0]||e}r?i?.focus?.():i?.focus?.({preventScroll:!0})}function gt(e,t){let n=C(e.shell,`[data-wui-modal-live]`);n||(n=document.createElement(`div`),n.className=`visually-hidden`,n.setAttribute(`aria-live`,`assertive`),n.setAttribute(`data-wui-modal-live`,``),it(e).appendChild(n)),n.textContent=``,n.textContent=t}var _t=e=>{let t=C(e.shell,`[data-wui-modal-live]`);t&&(t.textContent=``)},vt=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};function j(e,t,n,r){let i={...r,container:e.container};vt(t,`wui:modal:${n}`,i),et(e)&&vt(t,`wui:drawer:${n}`,i),O(e)&&vt(t,`wui:pane:${n}`,i)}var yt=e=>e.matches(`[data-wui-pane-host]`)?`pane`:w(e,`dialog`,`a dialog`).classList.contains(`wui-remote-drawer`)?`drawer`:`modal`,bt=e=>S(e.host.closest(`wui-modal`),`a wui-modal host`);function xt(e){let t=x.get(e);if(t)return t;let n=yt(e),r=n===`pane`?e:w(e,`dialog`,`a dialog`),a=k({shell:r}),o={host:e,shell:r,container:n,queue:Se(),defaultSize:Ze(r),defaultLabel:r.getAttribute(`aria-label`),placeholder:a?lt(a):i(`div`,{class:`modal-content wui-modal`}),remoteUrl:e.getAttribute(`data-wui-remote-url`),cache:e.getAttribute(`data-wui-remote-cache`)===`true`,loadedUrl:null,session:null};return x.set(e,o),e.addEventListener(`submit`,e=>Ht(o,e)),e.addEventListener(`click`,e=>{E(e.target,`[data-wui-modal-retry]`)&&o.session&&(e.preventDefault(),N(o,o.session))}),O(o)&&e.addEventListener(`click`,t=>{let n=E(t.target,Ue);n&&e.contains(n)&&o.session&&M(o,o.session,`dismissed`,null)}),e.addEventListener(`wui-modal-close`,t=>{t.target===e&&t instanceof CustomEvent&&Rt(t.detail,`reason`)===`escape`&&e.querySelector(`form[data-wui-submitting]`)&&t.preventDefault()}),e.addEventListener(`wui-modal-closed`,t=>{t.target===e&&Dt(o)}),e.addEventListener(`wui-modal-opened`,t=>{if(t.target!==e)return;let n=k(o);o.session&&n?.matches(He)&&!n.contains(document.activeElement)&&ht(n,!1,tt(o))}),o.remoteUrl&&e.addEventListener(`wui-modal-open`,t=>{t.target===e&&Ot(o,t)}),o}function St(e,t,n){let r=null;e.session&&(r=e.session.pendingRefresh,e.session.pendingRefresh=null,e.queue.abort(),e.session.resolveClosed({status:`dismissed`,detail:{replaced:!0}}));let i=()=>void 0,a=new Promise(e=>{i=e}),o={url:t,method:(n.method||`GET`).toUpperCase(),body:n.body,options:n,trigger:n.trigger||null,explicitSize:null,closing:null,resolveClosed:i,handle:{el:e.shell,closed:a,close:()=>M(e,o,`dismissed`,null),reload:()=>N(e,o)},pendingRefresh:r};return e.session=o,o}function M(e,t,n,r){e.session===t&&(t.closing={status:n,detail:r},O(e)?wt(e,t):Ct(e))}function Ct(e){let t=bt(e);t.dispatchEvent(new CustomEvent(`wui-modal-close`,{bubbles:!0,cancelable:!0,detail:{reason:`dismiss`}}))&&t.hide()}function wt(e,t){let n=e.shell,{status:r,detail:i}=S(t.closing,`the closing state`),a=n.contains(document.activeElement);e.queue.abort(),e.session=null,ut(k(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),j(e,n,`closed`,{status:r,url:t.url}),Tt(t),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function Tt(e){let t=e.pendingRefresh;e.pendingRefresh=null,t&&fe(t).catch(m)}function Et(e,t){for(let n=e;n!==null;n=n.parentElement){let e=n instanceof HTMLElement?x.get(n):void 0;if(e?.session){let n=de(t);return e.session.pendingRefresh=ne(e.session.pendingRefresh,{...t,message:n?t.message:null,action:n?t.action:null}),!0}}return!1}oe(Et);function Dt(e){let t=e.session;if(e.queue.abort(),e.session=null,_t(e),t){let n=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n.status,detail:n.detail}),j(e,e.shell,`closed`,{status:n.status,url:t.url}),Tt(t);let r=document.activeElement;t.trigger?.isConnected&&(!r||r===document.body||e.shell.contains(r))&&t.trigger.focus?.()}e.cache||(A(e,lt(e.placeholder)),e.loadedUrl=null,D(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function Ot(e,t){let n=Rt(t instanceof CustomEvent?t.detail:null,`trigger`),r=n instanceof HTMLElement?n:null,i=r?.getAttribute(`data-wui-url`)||e.remoteUrl||``,a=St(e,i,{trigger:r});a.explicitSize=kt(e,r?.getAttribute(`data-wui-size`)),a.explicitSize&&D(e.shell,a.explicitSize),e.cache&&e.loadedUrl===i||(e.loadedUrl&&A(e,lt(e.placeholder)),N(e,a,{keepPlaceholder:!0}))}function kt(e,t){try{return nt(e,t)}catch(e){return m(e),null}}async function N(e,t,{keepPlaceholder:n=!1}={}){n||A(e,st(t.options.title||At(e)));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate,timeoutMs:Ie(t.trigger)});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if(r.kind===`ok`&&Pt(e,t,r.html,!1))return e.loadedUrl=t.url,j(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return A(e,ct(t.options.title||At(e),i)),mt(e)&&ht(S(k(e),`a card`),!1,tt(e)),j(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var At=e=>k(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,jt=`/_content/Webority.Ui.Razor/js/`,Mt=e=>new URL(e,window.location.href).pathname.includes(jt);function Nt(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function Pt(e,t,n,r){let i=_e(n),a=!1;for(let e of i.querySelectorAll(`script`)){if(e.getAttribute(`type`)===`application/json`)continue;let t=e.getAttribute(`src`);e.remove(),t&&Mt(t)?Nt(t):a=!0}a&&ee(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let o=C(i,He);if(!o)return m(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;if(A(e,o),r||_t(e),!O(e)){D(e.shell,t.explicitSize||kt(e,o.getAttribute(`data-wui-size`))||e.defaultSize);let n=o.getAttribute(`data-wui-title`);n&&e.shell.setAttribute(`aria-label`,n)}return mt(e)&&ht(o,r,tt(e)),!0}var Ft=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function It(e,t,n){let r=[...e.elements].filter(e=>e.matches(Ft));if(n){e.setAttribute(`data-wui-submitting`,``);let n=t&&r.includes(t)?t:r[0];for(let e of r)e.toggleAttribute(`data-wui-was-disabled`,e.disabled),e.disabled=!0;n&&(n.classList.add(`is-loading`),n.setAttribute(`aria-busy`,`true`),n.tagName===`BUTTON`&&n.prepend(i(`span`,{class:`spinner-border spinner-border-sm me-2`,"aria-hidden":`true`,"data-wui-submit-spinner":!0})))}else{e.removeAttribute(`data-wui-submitting`);for(let e of r)e.disabled=e.hasAttribute(`data-wui-was-disabled`),e.removeAttribute(`data-wui-was-disabled`),e.classList.remove(`is-loading`),e.removeAttribute(`aria-busy`),e.querySelector(`[data-wui-submit-spinner]`)?.remove()}}function Lt(e){for(let t of e.querySelectorAll(Ve))t.remove();for(let t of e.querySelectorAll(ze))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}var Rt=(e,t)=>{if(typeof e==`object`&&e&&t in e)return Reflect.get(e,t)};async function zt(e){if(e.status<400||e.status>499||!e.response?.headers.get(`content-type`)?.toLowerCase().includes(`json`))return null;let t;try{t=JSON.parse(await ke(e))}catch{return null}return Ae(t,e.response.statusText)}function Bt(e,t,n,r){let i={forbidden:b().forbiddenMessage,networkCheck:s(`httpFailure`,te).networkCheckText,client:b().clientMessage,server:b().serverMessage,network:b().networkMessage,timeout:b().timeoutMessage},a=t.closest(`.wui-modal-body`)||t;a.querySelector(`[data-wui-modal-submit-error]`)?.remove(),Lt(a);let o=document.createElement(`div`);o.className=`alert alert-danger wui-modal-submit-error`,o.setAttribute(`role`,`alert`),o.setAttribute(`data-wui-modal-submit-error`,``),o.textContent=`${b().submitFailedMessage} ${r||i[n]||b().serverMessage}`,a.prepend(o),gt(e,o.textContent)}var Vt=(e,t)=>{let n=new URL(e,window.location.href);for(let[e,r]of t)typeof r==`string`&&n.searchParams.append(e,r);return n.origin===window.location.origin?n.pathname+n.search:n.href};async function Ht(e,t){let n=t.target,r=e.session;if(!(n instanceof HTMLFormElement)||!r||n.hasAttribute(`data-wui-native`)||!n.closest(He)||(t.preventDefault(),n.hasAttribute(`data-wui-submitting`)))return;let i=`submitter`in t&&(t.submitter instanceof HTMLButtonElement||t.submitter instanceof HTMLInputElement)?t.submitter:null,a=i?.getAttribute(`formaction`)||n.getAttribute(`action`)||r.url,o=(i?.getAttribute(`formmethod`)||n.getAttribute(`method`)||`GET`).toUpperCase(),s=new FormData(n);i?.name&&!s.has(i.name)&&s.append(i.name,i.value);let c=o===`GET`;It(n,i,!0);let l;try{l=await e.queue.run(c?Vt(a,s):a,{method:o,body:c?void 0:s,navigate:r.options.navigate,timeoutMs:Ie(r.trigger)})}catch(t){m(t),e.session===r&&n.isConnected&&(It(n,i,!1),Bt(e,n,`server`,null));return}if(e.session!==r)return;if(n.isConnected&&It(n,i,!1),l.kind===`ok`&&l.result===`success`){Ut(e,r,l);return}if(l.kind===`aborted`||l.kind===`stale`||l.kind===`session`)return;if(l.kind===`ok`&&l.html){let t=l.result===Be;if(Pt(e,r,l.html,t)){if(t){let t=S(k(e),`a card`).querySelector(Ve)?.textContent?.replace(/\s+/g,` `).trim();gt(e,t||b().invalidMessage)}return}}let u=l.kind===`ok`||l.kind===`validation`?`server`:l.kind,d=await zt(l);e.session===r&&Bt(e,n,u,d)}function Ut(e,t,n){let r=n.message,i=n.redirect||null,a=n.toastVariant||`success`;if(!re(a))throw TypeError(`Unknown toast variant "${a}". Use ${me.join(`, `)}.`);let o={url:t.url,trigger:t.trigger,handle:t.handle,message:r,redirect:i,data:n.data??null,container:e.container},s=i||se(t.trigger)?null:le(n),c=!(n.next&&!i)&&!n.keepOpen,l=s!==null&&c&&de(s);i&&!t.options.navigate?g(r,a):r&&!l&&h().toast(r,{variant:a}),j(e,t.trigger?.isConnected?t.trigger:document,`success`,o),t.options.onSuccess?.(o,t.handle),i&&(t.options.navigate||(e=>window.location.assign(e)))(i),s&&(t.pendingRefresh=ne(t.pendingRefresh,{...s,action:null,message:l?s.message:null}));let u=n.next;u&&!i?(t.url=u,t.method=`GET`,t.body=void 0,N(e,t)):n.keepOpen?n.html&&n.data===null&&Pt(e,t,n.html,!1):M(e,t,`success`,o)}function Wt(e){let t=E(e.target,`[data-wui-modal], [data-wui-drawer], [data-wui-pane]`);t&&(t.matches(`a[href]`)&&(e.ctrlKey||e.metaKey||e.shiftKey||e.button!==0)||(e.preventDefault(),t.hasAttribute(`data-wui-pane`)?Zt(t.getAttribute(`data-wui-pane`)??``,{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{qe(e)||m(e)}):t.hasAttribute(`data-wui-modal`)?qt(t.getAttribute(`data-wui-modal`)??``,{size:t.getAttribute(`data-wui-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{qe(e)||m(e)}):Yt(t.getAttribute(`data-wui-drawer`)??``,{size:t.getAttribute(`data-wui-drawer-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{qe(e)||m(e)})))}function Gt(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=E(e.target,Xt);if(!t)return;let n=x.get(t),r=e.currentTarget;n?.session&&r instanceof Document&&!r.querySelector(`wui-modal[open]`)&&(t.querySelector(`form[data-wui-submitting]`)||(e.preventDefault(),M(n,n.session,`dismissed`,null)))}function Kt(e=document){let t=e instanceof Document?e:S(e.ownerDocument,`an owner document`);Ge.has(t)||(Ge.add(t),t.addEventListener(`click`,Wt),t.addEventListener(`keydown`,Gt));let n=Ke(e,`wui-modal[data-wui-remote-url]`);e instanceof HTMLElement&&e.matches(`wui-modal[data-wui-remote-url]`)&&n.unshift(e);for(let e of n)xt(e)}function qt(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=t.container===`drawer`,r=n?$e(t.size):Xe(t.size),i=t.placement||`center`;if(!Qe.includes(i))throw TypeError(`WUI.modal.load: unsupported placement "${i}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(T());let a=at(n?`drawer`:`modal`);Kt(document);let o=xt(a),s=mt(o),c=St(o,e,t);c.explicitSize=r,D(o.shell,r||o.defaultSize),n||w(o.shell,`.modal-dialog`,`a dialog frame`).classList.toggle(`modal-dialog-centered`,i===`center`),t.title&&o.shell.setAttribute(`aria-label`,t.title),s||(a.toggleAttribute(`static`,t.staticBackdrop!==!1),a.toggleAttribute(`no-escape`,t.closeOnEscape===!1));let l=s?Promise.resolve():new Promise(e=>a.addEventListener(`wui-modal-opened`,()=>e(),{once:!0})),u=N(o,c);return s||bt(o).show(),Jt(o,c,t,l,u,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function Jt(e,t,n,r,i,a){let o=new Promise((r,i)=>{n.signal?.addEventListener(`abort`,()=>{e.session===t&&(e.queue.abort(),M(e,t,`dismissed`,{aborted:!0})),i(T())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw T();if(e===`session`)throw Error(`${a}(${t.url}): the session expired; the browser is signing in again.`);return t.handle});return Promise.race([s,o])}function Yt(e,t={}){return qt(e,{...t,container:`drawer`,placement:void 0})}var Xt=`[data-wui-pane-host]`;function Zt(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=rt(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(T());Kt(document);let r=xt(n),i=St(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=N(r,i);return Jt(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function Qt(e){let t=rt(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=x.get(t);n?.session&&M(n,n.session,`dismissed`,null)}var $t=8e3,en=()=>s(`toast`,f);function tn(e){if(!re(e))throw RangeError(`Unknown toast variant "${e}".`);return e}function P(e,t=`success`){e?.message&&nn(e.message,t,e.toastAction)}function nn(e,t,n=null){n?h().toast(e,{variant:tn(t),duration:$t,action:{label:n.label,onClick:e=>void rn(n,e)}}):h().toast(e,{variant:tn(t)})}async function rn(e,t=null){let n=await _(e.url,{method:e.method});n.kind!==`session`&&n.kind!==`aborted`&&(n.ok?(ae(n)||P(n,n.toastVariant||`success`),await ie(n,{origin:t})):h().toast(n.message||en().failedText,{variant:`danger`}))}var an=/* @__PURE__ */ new Set([204,205,304]),on=e=>{let t=new Headers;for(let n of e.split(/\r?\n/)){let e=n.indexOf(`:`);e>0&&t.append(n.slice(0,e).trim(),n.slice(e+1).trim())}return t};async function sn(e,t,n={}){if(!(t instanceof FormData))throw TypeError(`wuiUpload: body must be FormData`);let r=n.timeoutMs;if(r!==void 0&&!(Number.isFinite(r)&&r>0))throw TypeError(`wuiUpload: timeoutMs must be a positive number`);let i={Accept:`text/html`,"X-Requested-With":`XMLHttpRequest`,[Ce]:`1`,...n.headers};if(Ee(e)){let e=ye();e&&(i[e.header]=e.token)}let a=n.signal,o=n.navigate||(e=>window.location.assign(e));return a?.aborted?be(`aborted`):new Promise(s=>{let c=new XMLHttpRequest,l=!1,u,d=()=>c.abort(),f=(e,t=null,n=``)=>{u!==void 0&&clearTimeout(u),a?.removeEventListener(`abort`,d),s(be(e,t,n))};c.upload.onprogress=e=>{n.onProgress?.(e.loaded,e.lengthComputable?e.total:0)},c.onload=()=>{let t=c.status;if(t===0){f(`network`);return}let n=on(c.getAllResponseHeaders()),r=Te(t,n),i=c.responseURL!==``&&c.responseURL!==new URL(e,window.location.href).href;r===`ok`&&i&&n.get(ve.fragment)!==`1`&&(r=`session`);let a=c.responseText,s=r===`ok`||r===`validation`?a:``;if(t<200||t>599){f(r,null,s);return}let l=new Response(an.has(t)?null:a,{status:t,headers:n});r===`session`?(o(t===401?n.get(`Location`)||window.location.href:c.responseURL),f(`session`,l)):f(r,l,s)},c.onerror=()=>f(`network`),c.onabort=()=>{f(a?.aborted?`aborted`:l?`timeout`:`aborted`)},r!==void 0&&(u=setTimeout(()=>{l=!0,c.abort()},r)),a?.addEventListener(`abort`,d,{once:!0}),c.open(`POST`,e,!0);for(let[e,t]of Object.entries(i))c.setRequestHeader(e,t);c.send(t)})}var F=`wuiConfirm`,cn=Object.freeze([`danger`]),ln=Object.freeze([`warning`,`info`,`delete`]),I=()=>s(`confirmDialog`,d),un=/* @__PURE__ */ new WeakSet,dn=/* @__PURE__ */ new WeakSet,L=null,R=null,z=!1,B=(e,t)=>{e&&h().toast(e,{variant:t})};function fn(){let r=document.getElementById(F);if(r)return n(r.closest(`wui-modal`),`#${F} must be a wui-modal.`);let a=document.createElement(`wui-modal`);a.id=F;let o=document.createElement(`dialog`);return o.className=`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${y.md}px`),o.replaceChildren(i(`div`,{class:`modal-dialog modal-dialog-centered wui-rb-dialog`},i(`div`,{class:`modal-content wui-modal wui-confirm`},i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-confirm-content`},i(`span`,{class:`wui-confirm-icon`},i(`wui-status-icon`,{tone:`info`,size:120})),i(`h3`,{class:`wui-confirm-title`,tabindex:-1,"data-autofocus":``}),i(`p`,{class:`wui-confirm-msg`}))),i(`div`,{class:`wui-modal-footer`},i(`div`,{class:`wui-confirm-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":``,"data-wui":t},I().cancelLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-app-confirm":``,"data-wui":t})))))),a.append(o),document.body.appendChild(a),a}function pn(e,t){let n=e.getAttribute(`data-wui-confirm-tone`);if(n!==null&&!cn.includes(n))throw TypeError(`data-wui-confirm-tone="${n}" is not supported. Use danger, or leave it off.`);mn({title:e.getAttribute(`data-wui-confirm-title`),message:e.getAttribute(`data-wui-confirm`),label:e.getAttribute(`data-wui-confirm-label`),danger:n===`danger`,cancel:void 0,icon:void 0},t)}function mn({title:e,message:t,label:r,danger:i,cancel:a,icon:o},s){let c=fn(),l=c.querySelector(`.wui-confirm-title`),u=c.querySelector(`[data-app-confirm]`);if(!l||!u)throw Error(`#${F} is not a confirm dialog with a confirm button. Render <app-confirm-dialog id="${F}"> without confirm-href, or leave the dialog to the library.`);let d=c.querySelector(`.wui-confirm-msg`);d||(d=document.createElement(`p`),d.className=`wui-confirm-msg`,l.after(d));let f=e||I().confirmTitle;l.textContent=f,d.textContent=t,u.textContent=r||I().confirmLabel,u.classList.toggle(`btn-danger`,i),u.classList.toggle(`btn-primary`,!i),c.querySelector(`wui-status-icon`)?.setAttribute(`tone`,o??(i?`delete`:`info`));let p=c.querySelector(`[data-wui-dismiss]`);p&&(p.textContent=a||I().cancelLabel),n(c.querySelector(`dialog`),`#${F} has no <dialog>.`).setAttribute(`aria-label`,f),R=s,z=!1,c.show()}var V=(e,t)=>{L=e;try{t()}finally{L=null}},H=(e,t)=>{let n=Reflect.get(e,t);if(n===void 0||typeof n==`string`)return n;throw TypeError(`confirmAction: ${t} must be text.`)},hn=e=>{if(typeof e!=`object`||!e)throw TypeError(`confirmAction: options must be an object with a message.`);let t=`message`in e?e.message:void 0;if(typeof t!=`string`)throw TypeError(`confirmAction: message must be text.`);return{title:H(e,`title`),message:t,label:H(e,`label`),tone:H(e,`tone`),cancel:H(e,`cancel`),icon:H(e,`icon`)}};function gn(e,t,n){let{title:r,message:i,label:a,tone:o,cancel:s,icon:c}=hn(t);if(o!=null&&!cn.includes(o))throw TypeError(`confirmAction: tone "${o}" is not supported. Use danger, or leave it off.`);if(c!=null&&!ln.includes(c))throw TypeError(`confirmAction: icon "${c}" is not supported. Use warning, info or delete, or leave it off.`);Rn(e.ownerDocument),mn({title:r,message:i,label:a,danger:o===`danger`,cancel:s,icon:c},()=>V(e,n))}var _n=e=>`disabled`in e&&e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`,vn=e=>{r(e,HTMLElement,`data-wui-confirm needs an HTML element to click.`).click()};function yn(e){let t=a(e.target,`[data-wui-confirm]:not(form)`);t&&t!==L&&!_n(t)&&(e.preventDefault(),e.stopImmediatePropagation(),pn(t,()=>V(t,()=>vn(t))))}function bn(e){let t=e.target;if(!(t instanceof HTMLFormElement)||!t.hasAttribute(`data-wui-confirm`)||t===L||e.submitter&&e.submitter===L||t.querySelector(`input[data-app-repeater-hidden]`))return;e.preventDefault(),e.stopImmediatePropagation();let n=e.submitter instanceof HTMLButtonElement||e.submitter instanceof HTMLInputElement?e.submitter:null,r=n?.form===t?n:void 0;pn(t,()=>V(t,()=>t.requestSubmit(r)))}function xn(e){let t=a(e.target,`#${F} [data-app-confirm]`);t&&!t.hasAttribute(`disabled`)&&R&&(z=!0,n(t.closest(`wui-modal`),`#${F} is missing around its confirm button.`).hide())}function Sn(e){if(!(e.target instanceof Element)||e.target.id!==`wuiConfirm`)return;let t=z?R:null;R=null,z=!1,t?.()}var U=e=>e===`forbidden`?I().forbiddenMessage:e===`networkCheck`?s(`httpFailure`,te).networkCheckText:e===`network`?I().networkMessage:e===`timeout`?I().timeoutMessage:I().failedMessage,Cn=(e,t)=>{`disabled`in e&&(e.disabled=t)},wn=e=>{Cn(e,!1),e.removeAttribute(`aria-busy`)};async function Tn(e){let t=e.getAttribute(`data-wui-post`);if(!t)throw Error(`A data-wui-post button needs the URL the action posts to.`);return En(t,e)}async function En(e,t,n){Cn(t,!0),t.setAttribute(`aria-busy`,`true`);let r=we(t.getAttribute(`data-wui-timeout`))??3e4,i=await _(e,{method:`POST`,body:n,timeoutMs:r});if(i.kind===`session`||i.kind===`aborted`)return;let a=i.toastVariant||`success`;if(i.ok&&i.redirect)g(i.message,a,i.toastAction),window.location.assign(i.redirect);else if(i.ok){let e=se(t);if(!e&&ae(i)){await ie(i,{origin:t})===`held`&&wn(t);return}wn(t),P(i,a),e||await ie(i,{origin:t})}else wn(t),B(i.message||U(i.kind),`danger`)}var Dn=e=>typeof e!=`object`||!e||!(`code`in e)?null:typeof e.code==`string`?e.code:null,On=e=>(e.response?.headers.get(`Content-Type`)??``).toLowerCase().includes(`json`)?e.data:e.html===``?null:e.html;async function kn(e,t={}){if(t.body!==void 0&&t.json!==void 0)throw TypeError(`postAction takes a body or a json value, not both.`);let n=t.method??`POST`;if(!xe.includes(n))throw TypeError(`postAction method must be POST, PUT, PATCH or DELETE.`);let r=t.timeoutMs??3e4;if(!Number.isInteger(r)||r<0)throw TypeError(`postAction timeoutMs must be a whole number of milliseconds, 0 for no limit.`);if(t.onUploadProgress!==void 0){if(!(t.body instanceof FormData))throw TypeError(`postAction onUploadProgress needs a FormData body.`);if(n!==`POST`)throw TypeError(`postAction onUploadProgress needs the POST method.`)}let i={},a;t.json===void 0?t.body instanceof FormData||t.body instanceof URLSearchParams?a=t.body:t.body!==void 0&&(a=new URLSearchParams(t.body)):(i[`Content-Type`]=`application/json`,a=JSON.stringify(t.json));let o;try{o=t.onUploadProgress!==void 0&&t.body instanceof FormData?await sn(e,t.body,{onProgress:t.onUploadProgress,headers:i,timeoutMs:r===0?void 0:r}):await _(e,{method:n,body:a,headers:i,timeoutMs:r})}catch(e){throw m(e),e}if(o.kind===`session`||o.kind===`aborted`)throw new v(U(o.kind),{code:null,status:o.status,html:null,body:null,kind:o.kind});let s=t.toast!==!1,c=t.refresh!==!1,l=o.toastVariant||`success`;if(o.ok){if(o.redirect)g(s?o.message:null,l,s?o.toastAction:null),window.location.assign(o.redirect);else{let e=le(o);s&&!(c&&ae(o))&&P(o,l),e!==null&&c&&await fe({...e,message:s?e.message:null,action:s?e.action:null})}return On(o)}let u;try{u=await ke(o)}catch(e){m(e);let t=o.message||U(o.kind);throw B(t,`danger`),new v(t,{code:null,status:o.status,html:null,body:null,kind:o.kind,cause:e})}let d=(o.response?.headers.get(`Content-Type`)??``).toLowerCase(),f=null;if(d.includes(`json`))try{f=JSON.parse(u)}catch{f=null}let p=Ae(f,o.response?.statusText??``)||o.message||U(o.kind),ee=d.includes(`text/html`)?u:null;throw(o.kind!==`validation`||ee===null)&&B(p,`danger`),new v(p,{code:Dn(f),status:o.status,html:ee,body:f,kind:o.kind})}function An(e,t){Cn(e,!1),e.removeAttribute(`aria-busy`),m(t),B(I().failedMessage,`danger`)}function jn(e){let t=a(e.target,`[data-wui-post]`);t&&(e.preventDefault(),_n(t)||t.getAttribute(`aria-busy`)===`true`||Tn(t).catch(e=>An(t,e)))}function Mn(e){let t=a(e.target,`form[data-wui-post-form]`);if(!(t instanceof HTMLFormElement)||e.defaultPrevented)return;e.preventDefault();let r=n(e.submitter||t.querySelector(`button:not(.repeater-add):not(.repeater-remove)`),`A data-wui-post-form needs a submit button to report its result on.`);if(r.getAttribute(`aria-busy`)===`true`)return;let i=new URL(n(t.getAttribute(`action`),`A data-wui-post-form needs an action attribute to post to.`),document.baseURI).href;En(i,r,new FormData(t)).catch(e=>An(r,e)),t.closest(`wui-dropdown`)?.hide()}var W=(e,t)=>{e.disabled=!1,e.removeAttribute(`aria-busy`),t&&p(t,null)};async function Nn(e,t){let n=e.dataset.url;if(!n)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);e.disabled=!0,e.setAttribute(`aria-busy`,`true`),t&&p(t,`saving`);let r=we(e.getAttribute(`data-wui-timeout`))??3e4,i=await _(n,{method:(e.dataset.method||`post`).toUpperCase(),timeoutMs:r});if(i.kind===`session`)return;if(i.kind===`aborted`){W(e,t);return}let a=i.toastVariant||`success`;if(i.ok&&i.redirect){g(i.message,a,i.toastAction),window.location.assign(i.redirect);return}if(i.ok){let n=le(i);if(se(e)||n===null||ce(n)){W(e,t),P(i,a);return}if(ue({...n,reload:`page`},e)){W(e,t);return}g(i.message,a,i.toastAction),pe();return}let o=i.message||U(i.kind);e.disabled=!1,e.removeAttribute(`aria-busy`),t&&p(t,`error`,o),B(o,`danger`)}var Pn=/* @__PURE__ */ new WeakSet;function Fn(e){let t=a(e.target,`[data-wui-row-action]`);if(!t||t.closest(`[data-wui-server]`))return;if(!(t instanceof HTMLButtonElement)){if(Pn.has(t))return;Pn.add(t),m(/* @__PURE__ */ Error(`A [data-wui-row-action] element must be a button with data-url, so its click does nothing: ${t.getAttribute(`data-wui-row-action`)??``}`));return}if(e.preventDefault(),t.disabled||t.getAttribute(`aria-busy`)===`true`)return;let n=t.closest(`tr`);Nn(t,n).catch(e=>{W(t,n),m(e),B(I().failedMessage,`danger`)})}var In=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.form:null;function Ln(e){if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-wui-auto-submit]`);if(!t)return;let n=In(e.target)||t.closest(`form`);n instanceof HTMLFormElement&&n.requestSubmit()}function Rn(e){dn.has(e)||(dn.add(e),e.addEventListener(`click`,xn),e.addEventListener(`wui-modal-closed`,Sn))}function zn(e=document){let t=e instanceof Element?e.ownerDocument:e;un.has(t)||(un.add(t),t.addEventListener(`click`,yn,!0),t.addEventListener(`submit`,bn,!0),Rn(t),t.addEventListener(`click`,jn),t.addEventListener(`click`,Fn),t.addEventListener(`submit`,Mn),t.addEventListener(`change`,Ln))}var G=()=>s(`unsavedChanges`,l),K=`form[data-wui-unsaved]`,Bn=`[aria-invalid="true"], .field-error:not(:empty), .field-validation-error, .validation-summary-errors, .wui-error-summary`,Vn=`[download], [data-wui-modal], [data-wui-post], [data-bs-toggle]`,Hn=/* @__PURE__ */ new Set([`submit`,`button`,`reset`,`image`]),Un=/* @__PURE__ */ new Set([`hidden`,`checkbox`,`radio`,`file`,`submit`,`button`,`reset`,`image`,`range`,`color`]),Wn=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,Gn=e=>Wn(e)?e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled:`disabled`in e&&!!e.disabled,Kn=e=>`name`in e&&typeof e.name==`string`&&e.name!==``,qn=e=>typeof e==`object`&&!!e,Jn=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&typeof e[0]==`string`);function Yn(e){let t=JSON.parse(e);if(!Jn(t))throw Error(`unsaved-changes snapshot is malformed`);return t}var q=/* @__PURE__ */ new WeakMap,Xn=/* @__PURE__ */ new WeakSet,Zn=e=>`${e.name}:${e.size}:${e.lastModified}`,J=e=>[...e.querySelectorAll(K)].filter(e=>e instanceof HTMLFormElement);function Y(e){let t=[];for(let n of e.elements)Kn(n)&&!Gn(n)&&(Wn(n)&&Hn.has(n.type)||(n instanceof HTMLInputElement&&(n.type===`checkbox`||n.type===`radio`)?t.push([n.name,n.value,n.checked]):n instanceof HTMLInputElement&&n.type===`file`?t.push([n.name,[...n.files||[]].map(Zn)]):n instanceof HTMLSelectElement&&n.type===`select-multiple`?t.push([n.name,[...n.selectedOptions].map(e=>e.value)]):n instanceof HTMLFieldSetElement||n instanceof HTMLObjectElement?t.push([n.name,null]):t.push([n.name,`value`in n?n.value:null])));return JSON.stringify(t)}function X(e){return Y(e)}function Qn(e,t){let n=/* @__PURE__ */ new Map,r=Yn(t);for(let e of r){let t=n.get(e[0]);t?t.push(e):n.set(e[0],[e])}let i=Yn(Y(e)).map(e=>n.get(e[0])?.shift()??e);for(let e of n.values())i.push(...e);return JSON.stringify(i)}function $n(e){for(let t of e.elements)if(Wn(t)&&t.name&&!Gn(t)){if(t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement&&!Un.has(t.type)){if(t.value.trim()!==``)return!0}else if(t instanceof HTMLInputElement&&t.type===`file`&&(t.files?.length??0)>0)return!0}return!1}var er=e=>({saved:e.querySelector(Bn)&&$n(e)?null:Y(e),engaged:!1,discarded:!1});function tr(e){let t=q.get(e);return!t||t.discarded||!e.isConnected?!1:t.saved===null||t.engaged&&Y(e)!==t.saved}var nr=(e,t)=>J(e).filter(e=>e!==t&&tr(e));function rr(e,t,n){let r=t.map(e=>e.getAttribute(`data-wui-unsaved`)).find(Boolean)||G().message;gn(e,{title:G().title,message:r,label:G().leaveLabel,cancel:G().keepLabel,icon:`warning`,tone:`danger`},()=>{for(let e of t){let t=q.get(e);t&&(t.discarded=!0)}n()})}function ir(e){if(e.matches(Vn))return!1;let t=e.getAttribute(`target`);if(t&&t.toLowerCase()!==`_self`)return!1;let n=e.getAttribute(`href`);if(n===null)return!1;let r=new URL(n,window.location.href);if(r.protocol!==`http:`&&r.protocol!==`https:`)return!1;let i=window.location;return!(r.hash&&r.origin===i.origin&&r.pathname===i.pathname&&r.search===i.search)}function ar(e,t){if((t?.getAttribute(`formmethod`)||e.getAttribute(`method`)||`get`).toLowerCase()===`dialog`)return!1;let n=t?.getAttribute(`formtarget`)||e.getAttribute(`target`);return!n||n.toLowerCase()===`_self`}function or(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target,n=a(t,`a[href]`);if(!(n instanceof HTMLAnchorElement)||!ir(n))return;let r=nr(n.ownerDocument,null);r.length&&(e.preventDefault(),rr(n,r,()=>n.click()))}function sr(e){let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented||!ar(t,e.submitter))return;let n=nr(t.ownerDocument,t);if(n.length){e.preventDefault();let r=e.submitter,i=(r instanceof HTMLButtonElement||r instanceof HTMLInputElement)&&r.form===t?r:void 0;rr(t,n,()=>t.requestSubmit(i));return}let r=q.get(t);r&&(r.saved=Y(t),r.discarded=!1)}function cr(e){nr(document,null).length&&e.preventDefault()}function lr(e){let t=e.target,n=a(t,K);return n instanceof HTMLFormElement?n:null}function ur(e){let t=lr(e);if(!t)return;let n=q.get(t);n&&!n.engaged&&(n.saved!==null&&(n.saved=Y(t)),n.engaged=!0)}function dr(e){let t=lr(e),n=t&&q.get(t);n&&(n.discarded=!1,e.isTrusted&&(n.engaged=!0))}function fr(e){for(let t of J(e)){let e=q.get(t);e?.saved&&(e.saved=Qn(t,e.saved))}}function pr(e){let t=qn(e)?e.handle:void 0;return qn(t)?t.el:void 0}function mr(e){if(!(e instanceof CustomEvent))return;let t=pr(e.detail);if(t instanceof Element)for(let e of J(t))gr(e)}function hr(e=document){let t=e instanceof Document?e:e.ownerDocument;if(!Xn.has(t)){Xn.add(t);for(let e of[`focusin`,`pointerdown`,`drop`])t.addEventListener(e,ur,!0);for(let e of[`input`,`change`])t.addEventListener(e,dr,!0);t.addEventListener(`click`,or),t.addEventListener(`submit`,sr),t.addEventListener(`wui:modal:success`,mr),t.addEventListener(o,()=>fr(t)),n(t.defaultView,`unsaved-changes guard needs a document with a window`).addEventListener(`beforeunload`,cr)}let r=J(e);e instanceof HTMLFormElement&&e.matches(K)&&r.unshift(e);for(let e of r)q.has(e)||q.set(e,er(e))}function gr(e){if(!(e instanceof HTMLFormElement)||!e.matches(K))throw TypeError(`resetUnsavedChanges: ${String(e)} is not a <form data-wui-unsaved>.`);q.set(e,{saved:Y(e),engaged:!1,discarded:!1})}var _r=()=>s(`drawer`,c),vr=`wui:drawer:discard`,Z=`wui-drawer[confirm-discard]`,yr=`wui-modal`,br=`data-wui-no-discard`,xr=`.wui-drawer-discard`,Sr=`input, select, textarea`,Cr=e=>typeof e==`object`&&!!e||typeof e==`function`;function wr(e){let t=e.currentTarget;if(!(t instanceof Document))throw Error(`The discard guard is not wired on a document.`);return t}function Tr(e,t){return a(e,t)}var Er=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement,Q=/* @__PURE__ */ new WeakMap,Dr=/* @__PURE__ */ new WeakSet,Or=/* @__PURE__ */ new WeakSet;function kr(n,r,i,a,o){let s=n.createElement(`button`);return s.type=`button`,s.className=e(r,i,`sm`),s.dataset.wui=t,s.setAttribute(a,``),s.textContent=o,s}function Ar(e,t){let n=e.createElement(`div`);n.className=`wui-drawer-discard`,n.setAttribute(`role`,`alert`);let r=e.createElement(`span`);return r.className=`wui-drawer-discard-text`,r.textContent=t,n.append(r,kr(e,`danger`,`solid`,`data-wui-discard-confirm`,_r().discardLabel),kr(e,`primary`,`soft`,`data-wui-discard-keep`,_r().keepLabel)),n}function jr(e){if(!(e instanceof Element))return null;let t=e.closest(Z);if(t)return t;let n=e.closest(yr);return n&&$(n).length?n:null}function Mr(e){return e.closest(Z)??e.closest(yr)}function Nr(e,t){return t.hasAttribute(br)||e.hasAttribute(br)?!1:t.hasAttribute(`confirm-discard`)||e.hasAttribute(`data-wui-confirm-discard`)?!0:(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`}function $(e){return e.matches(Z)?e.querySelectorAll(`form`):[...e.querySelectorAll(`form`)].filter(t=>Nr(t,e))}function Pr(e){let t=Q.get(e);return t!=null&&X(e)!==t}function Fr(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-drawer-footer`,n(e.querySelector(`.wui-drawer-panel`),`The drawer has no panel to hold its footer.`).append(t),Or.add(t),t}function Ir(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-modal-footer`,(e.querySelector(`.wui-modal-body`)?.parentElement??e.querySelector(`.modal-content`)??e).append(t),Or.add(t),t}function Lr(e){let t=e.querySelector(`[data-wui-discard-confirm]`);if(!(t instanceof HTMLElement))throw Error(`The discard prompt has no confirm button.`);t.focus()}function Rr(e,t,n){let r=e.querySelector(xr);if(r){Lr(r);return}let i=Ar(e.ownerDocument,t),a;if(e.matches(Z))a=e.querySelector(`.wui-drawer-footer`)??Fr(e),a.prepend(i);else if(e.hasAttribute(`confirm-discard`))a=e.querySelector(`.wui-modal-footer`)??Ir(e),a.prepend(i);else{if(!n)throw Error(`A discard prompt needs the form that is dirty.`);a=n.querySelector(`.modal-footer`)??e.querySelector(`.wui-modal-footer`)??Ir(e),a.prepend(i)}a.classList.add(`wui-drawer-discarding`),Lr(i)}function zr(e){let t=e.parentElement;if(e.remove(),!t)throw Error(`The discard prompt has no footer.`);t.classList.remove(`wui-drawer-discarding`),Or.has(t)&&t.remove()}function Br(e){for(let t of $(e))for(let e of t.querySelectorAll(Sr))if(Er(e)&&e.type!==`hidden`&&!e.disabled){e.focus({preventScroll:!0});return}}function Vr(e){let t=jr(e.target);if(t)for(let e of $(t))Q.get(e)??Q.set(e,X(e))}function Hr(e){for(let t of wr(e).querySelectorAll(`form`)){let e=Q.get(t);e!=null&&Q.set(t,Qn(t,e))}}function Ur(e){let t=e.target;t instanceof HTMLFormElement&&jr(t)&&Q.set(t,X(t))}function Wr(e){if(!Cr(e))return;let t=`handle`in e?e.handle:void 0;if(Cr(t))return`el`in t?t.el:void 0}function Gr(e){if(!(e instanceof CustomEvent))return;let t=e.detail,n=Wr(t);if(n instanceof Element)for(let e of n.querySelectorAll(`form`))Q.delete(e)}function Kr(e){let t=e.target;t instanceof Element&&t.matches(Z)&&[...$(t)].some(Pr)&&(e.preventDefault(),Rr(t,t.getAttribute(`confirm-discard`),null))}function qr(e){let t=e.target;if(!(t instanceof Element)||!t.matches(yr))return;let n=[...$(t)].find(Pr);n&&(e.preventDefault(),Rr(t,n.getAttribute(`data-wui-confirm-discard`)??t.getAttribute(`confirm-discard`)??_r().confirmDiscard,n))}function Jr(e){let t=n(e.closest(xr),`The discard button is outside its prompt.`),r=Mr(t);if(zr(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);for(let e of $(r))Q.set(e,X(e));r.dispatchEvent(new CustomEvent(vr,{bubbles:!0})),r.matches(Z)?n(r.closest(`wui-drawer`),`The confirm-discard drawer is not a wui-drawer.`).hide():n(r.closest(`wui-modal`),`The discarded dialog is not a wui-modal.`).hide()}function Yr(e){let t=n(e.closest(xr),`The keep button is outside its prompt.`),r=Mr(t);if(zr(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);Br(r)}function Xr(e){let t=Tr(e.target,`[data-wui-discard-confirm]`);if(t){Jr(t);return}let n=Tr(e.target,`[data-wui-discard-keep]`);n&&Yr(n)}function Zr(e=document){let t=e instanceof Document?e:e.ownerDocument;Dr.has(t)||(Dr.add(t),t.addEventListener(`focusin`,Vr),t.addEventListener(`pointerdown`,Vr),t.addEventListener(`submit`,Ur),t.addEventListener(o,Hr),t.addEventListener(`wui:modal:success`,Gr),t.addEventListener(`wui:modal:loaded`,Gr),t.addEventListener(`wui-drawer-close`,Kr,!0),t.addEventListener(`wui-modal-close`,qr),t.addEventListener(`click`,Xr))}export{v as S,Qt as _,hr as a,qt as b,cn as c,kn as d,sn as f,nn as g,P as h,X as i,gn as l,rn as m,Ar as n,gr as o,$t as p,Zr as r,F as s,vr as t,zn as u,Kt as v,Zt as x,Yt as y};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-Cxeyx0tU.js";import{n as t,r as n,t as r}from"../inlineEditText-BjHkrr4q.js";import{t as i}from"../WuiInlineEdit-8QIAUktT.js";e(`wui-inline-edit`,i);export{r as INLINE_EDIT_SAVED_MS,t as INLINE_EDIT_TYPES,i as WuiInlineEdit,n as inlineEditText};
1
+ import{n as e}from"../elementBase-Cxeyx0tU.js";import{n as t,r as n,t as r}from"../inlineEditText-BjHkrr4q.js";import{t as i}from"../WuiInlineEdit-BKjUqAFD.js";e(`wui-inline-edit`,i);export{r as INLINE_EDIT_SAVED_MS,t as INLINE_EDIT_TYPES,i as WuiInlineEdit,n as inlineEditText};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./devWarn-DXdRWZs3.js";import{h as n,m as r}from"./wuiHttp-8CYWEbRz.js";import{t as i}from"./serverHtml-BC6tAyAl.js";import{i as a}from"./dom-DMQu--xV.js";var o=Object.freeze([`success`,`info`,`warning`,`danger`]),s=e=>o.some(t=>t===e),c=`wui.flash`;function l(e,t,n){e&&window.sessionStorage.setItem(c,JSON.stringify({message:e,variant:t,action:n??null}))}var u=e=>{if(typeof e!=`object`||!e||!(`label`in e)||!(`url`in e)||!(`method`in e))throw TypeError(`stored flash action is not an action.`);let{label:t,url:r,method:i}=e;if(typeof t!=`string`||t===``||typeof r!=`string`||r===``||typeof i!=`string`||!n.includes(i))throw TypeError(`stored flash action is not an action.`);return{label:t,url:r,method:i}};function d(){let e=window.sessionStorage.getItem(c);if(e===null)return null;window.sessionStorage.removeItem(c);let t=JSON.parse(e);if(typeof t!=`object`||!t)throw TypeError(`stored flash is not an object.`);let n=`message`in t?t.message:void 0,r=`variant`in t?t.variant:void 0;if(typeof r!=`string`||!s(r))throw TypeError(`stored flash variant "${String(r)}" is not supported.`);if(typeof n!=`string`)throw TypeError(`stored flash message is not text.`);let i=`action`in t?t.action:null;return{message:n,variant:r,action:i===null?null:u(i)}}var f=`data-a2ui-id`,p=1;function m(e){return e.nodeType===p}function h(e){return e.tagName.includes(`-`)}function g(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||e.removeAttribute(n.name);for(let n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}function _(e){return e.tagName===`INPUT`}function v(e){return e.tagName===`TEXTAREA`}function y(e){return e.tagName===`OPTION`}function b(e,t){_(e)?(e.value=t.getAttribute(`value`)??``,e.checked=t.hasAttribute(`checked`)):v(e)?e.value=t.textContent??``:y(e)&&(e.selected=t.hasAttribute(`selected`))}function x(e){let t=e.ownerDocument.defaultView?.CustomEvent??CustomEvent;e.dispatchEvent(new t(`wui:teardown`,{bubbles:!0}))}function S(e,t){let n=e.ownerDocument,r=/* @__PURE__ */ new Map;for(let t of e.querySelectorAll(`[${f}]`)){let e=t.getAttribute(f);e!==null&&!r.has(e)&&r.set(e,t)}let i=/* @__PURE__ */ new Set;function a(e,t){if(m(t)){if(h(t))return null;let n=t.getAttribute(f);if(n!==null){let a=r.get(n);return a!==void 0&&!i.has(a)&&a.tagName===t.tagName&&!a.contains(e)?a:null}for(let n of Array.from(e.childNodes))if(!i.has(n)&&m(n)&&n.tagName===t.tagName&&!n.hasAttribute(f))return n;return null}if(t.nodeType===3||t.nodeType===8){for(let n of Array.from(e.childNodes))if(!i.has(n)&&n.nodeType===t.nodeType)return n}return null}function o(e,t){let r=Array.from(t.childNodes);for(r.forEach((t,r)=>{let s=a(e,t);s===null?(s=n.importNode(t,!0),i.add(s)):(i.add(s),m(s)&&m(t)?(g(s,t),b(s,t),o(s,t)):s.nodeValue!==t.nodeValue&&(s.nodeValue=t.nodeValue));let c=e.childNodes[r]??null;c!==s&&e.insertBefore(s,c)});e.childNodes.length>r.length;){let t=e.childNodes[r.length];if(t===void 0)break;m(t)&&x(t),e.removeChild(t)}}o(e,t)}function C(){return a(window.WUI,`window.WUI is not defined: the Razor behaviour script did not load on this page.`)}var w=`data-wui-region-src`,T=`data-wui-region-key`,E=/* @__PURE__ */ new WeakSet,D=/* @__PURE__ */ new Map;async function O(e=`all`){if(e!==`all`&&e.length===0)return;let n=e===`all`?null:new Set(e),r=/* @__PURE__ */ new Map;for(let e of document.querySelectorAll(`[${w}]`)){if(!(e instanceof HTMLElement)||e.getAttribute(`data-wui-refresh`)===`none`)continue;let i=e.getAttribute(`data-wui-region-src`)??``,a=e.getAttribute(T);if(!a){E.has(e)||(E.add(e),t(/* @__PURE__ */ Error(`A [${w}] element needs ${T}: ${i}`)));continue}if(n&&!n.has(a))continue;let o=r.get(i)??[];o.push(e),r.set(i,o)}await Promise.all([...r].map(([e,t])=>k(e,t)))}async function k(t,n){let a=(D.get(t)??0)+1;D.set(t,a);let o=await r(t);if(D.get(t)!==a||o.kind===`aborted`||o.kind===`stale`||o.kind===`session`)return;if(!o.ok){e(`A region refresh failed; the region keeps its content.`,t,o.kind);return}let s=/* @__PURE__ */ new Map;for(let e of i(o.html).querySelectorAll(`[${T}]`)){if(!(e instanceof HTMLElement))continue;let t=e.getAttribute(T);t!==null&&!s.has(t)&&s.set(t,e)}for(let r of n){if(!r.isConnected)continue;let n=r.getAttribute(`data-wui-region-key`)??``,i=s.get(n);i?A(r,i):e(`A region refresh reply has no element for the region's key; the region keeps its content.`,t,n)}}function A(e,t){if(e.hasAttribute(`data-wui-screen`))S(e,t);else{for(let t of Array.from(e.children))t.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}));e.replaceChildren(...Array.from(t.childNodes,e=>document.importNode(e,!0)))}e.hidden=t.hidden;let n=t.getAttribute(`title`);n===null?e.removeAttribute(`title`):e.setAttribute(`title`,n);for(let t of Array.from(e.classList))t.startsWith(`tone-`)&&e.classList.remove(t);for(let n of Array.from(t.classList))n.startsWith(`tone-`)&&e.classList.add(n);C().refresh(e)}var j=/* @__PURE__ */ new WeakMap;function M(e,t){j.set(e,t)}function N(e){return j.has(e)}function P(e){let t=e instanceof Element?e.closest(`[data-wui-server]`):null;return t instanceof HTMLElement&&j.get(t)||null}var F=null;function I(e){return e?.getAttribute(`data-wui-refresh`)===`none`}function L(e){if(!e.ok)return null;let t=e.message,n=e.toastVariant||`success`,r=e.toastAction,i=e.refresh;return i===null?{tables:`all`,regions:`all`,reload:`auto`,message:t,variant:n,action:r}:{tables:i.tables,regions:i.regions,reload:i.reloadPage?`page`:`never`,message:t,variant:n,action:r}}var R={never:0,auto:1,page:2},z=(e,t)=>e===`all`||t===`all`?`all`:[.../* @__PURE__ */ new Set([...e,...t])];function B(e,t){return e===null?t:{tables:z(e.tables,t.tables),regions:z(e.regions,t.regions),reload:R[e.reload]>=R[t.reload]?e.reload:t.reload,message:t.message,variant:t.variant,action:t.action}}function V(e){return e.reload===`page`||e.reload===`auto`&&document.querySelector(`[data-wui-server]`)===null}function H(e){let t=L(e);return t!==null&&V(t)}function U(){let e=new URL(window.location.href);e.hash=``,window.location.assign(e.href)}function W(e){F=e}function G(e,t){return F?F(t,e):!1}function K(e){return e!==null&&e.tables!==`all`&&e.tables.length===0&&e.regions!==`all`&&e.regions.length===0&&e.reload===`never`}var q=e=>[e.querySelector(`.table-wrap`)?.id??``,e.id].filter(e=>e!==``),J=(t,n)=>{let r=[...document.querySelectorAll(`[data-wui-server]`)].filter(e=>e instanceof HTMLElement),i=r;if(t.tables!==`all`){let n=t.tables,a=new Set(r.flatMap(q));for(let t of n)a.has(t)||e(`A refresh names the table "${t}", which is not on this page.`);i=r.filter(e=>q(e).some(e=>n.includes(e)))}return i.filter(e=>(!n||e!==n&&!e.contains(n))&&!I(e))},Y=async e=>{await P(e)?.reload({quiet:!0})};async function X(e,n={}){if(n.origin&&G(e,n.origin))return`held`;if(V(e)&&(e.reload===`page`||n.allowReload!==!1))return l(e.message,e.variant,e.action),U(),`reloaded`;let r=J(e,n.skip).map(e=>Y(e).catch(t));return(e.regions===`all`||e.regions.length>0)&&r.push(O(e.regions).catch(t)),await Promise.all(r),`refreshed`}async function Z(e,t={}){let n=L(e);return n===null?`none`:X(n,t)}async function Q(){await X({tables:`all`,regions:`all`,reload:`never`,message:null,variant:`success`,action:null},{allowReload:!1})}export{d as S,C as _,B as a,s as b,Z as c,H as d,W as f,O as g,M as h,I as i,K as l,N as m,Q as n,L as o,P as p,G as r,V as s,X as t,U as u,c as v,l as x,o as y};
package/dist/server.js CHANGED
@@ -1 +1 @@
1
- import{i as e,n as t}from"./dom-DMQu--xV.js";import{n}from"./imeSafeEnter-DeO_3lXy.js";import{r,t as i}from"./textStore-Cs1SGBoI.js";import{t as a}from"./shell.g-BhC11Oe3.js";import{t as o}from"./serverHtml-BC6tAyAl.js";import{a as s,c,d as l,g as u,h as d,i as f,l as p,m as ee,n as m,p as h,s as g,t as _}from"./wuiHttp-8CYWEbRz.js";import{n as te,t as ne}from"./buttonClass-C8BRtTk8.js";import{E as v,M as y,N as b,b as x,k as S,y as C}from"./dataTable-CSP1x4ZA.js";import{n as w,t as re}from"./devWarn-DXdRWZs3.js";import{t as ie}from"./iconGlyphs.g-DRNDTVOs.js";import{LIST_QUERY_RESERVED as ae,SEARCH_PARAM as oe}from"./listQuery.js";import{a as se,c as ce,i as le,n as T,r as ue,s as de}from"./tableSelect-BrQSoqzs.js";import{t as fe}from"./dataTable.g-1PsmN1Nj.js";import{t as pe}from"./httpFailure.g-DjZzGxPj.js";import{S as E,_ as D,b as O,c as me,d as he,g as k,h as ge,i as _e,m as ve,n as A,p as ye,v as j,y as M}from"./refreshAfter-DhYgWXmQ.js";import{S as N,_ as be,a as xe,b as Se,c as P,d as Ce,f as we,g as F,h as Te,i as I,l as L,m as R,n as Ee,o as z,p as De,r as Oe,s as ke,t as Ae,u as je,v as B,x as Me,y as Ne}from"./drawerDiscard-233UVlX5.js";var V=()=>r(`dataTable`,fe),Pe=5,Fe=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,Ie=e=>e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled,Le=e=>Fe(e)&&`type`in e&&e.type===`hidden`,H=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),U=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},W=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Re=e=>e.localName===`wui-select`,G=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},ze=e=>({total:G(e.dataset.total,0),totalCapped:e.dataset.totalCapped===`true`,page:G(e.dataset.page,1),pageSize:G(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`,pending:e.dataset.totalPending===`true`,rowCount:G(e.dataset.rowCount,0)}),Be=(e,t)=>{e&&D().toast(e,{variant:t})},Ve=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>!Le(e)||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!ae.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of H(e,`[data-wui-filter-clear]`,HTMLElement))t.hidden=!r},He=new Intl.NumberFormat(`en-IN`),Ue=(e,t)=>t?`${He.format(e)}+`:He.format(e),We=(e,t,n)=>{let r=e.closest(`.wui-list-card`),i=r?U(r,`.wui-list-card-count`,HTMLElement):null;i&&(i.textContent=Ue(t,n))};function Ge(e=document){let t=H(e,`[data-wui-server]`,HTMLElement);e instanceof HTMLElement&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t){if(ve(e))continue;let t=Ke(e);ge(e,t),e.hasAttribute(`data-load-first-page`)&&t.reload()}}function Ke(n){let a=U(n,`.table-wrap`,HTMLElement),s=a?U(a,`:scope > table`,HTMLTableElement):null,c=n.dataset.src;if(!a||!s||!c)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let l=U(a,`:scope > [data-wui-table-state]`,HTMLElement),u=U(n,`[data-wui-table-pager]`,HTMLElement),d=U(n,`[data-wui-table-status]`,HTMLElement),f={urlState:n.dataset.urlState!==`false`,filtersForm:n.dataset.filtersForm||null,filtersRegion:n.dataset.filtersRegion||null,searchInput:n.dataset.searchInput||null,loadingText:n.dataset.loadingText||V().loadingText,errorText:n.dataset.errorText||V().errorText,timeoutMs:h(n.getAttribute(`data-wui-timeout`))??3e4},m=new URL(c,window.location.href),g=n.dataset.totalSrc||null,_=g===null?null:new URL(g,window.location.href),fe=/* @__PURE__ */ new Set([...m.searchParams.keys(),..._?.searchParams.keys()??[]]),E=s.hasAttribute(`data-app-datatable-selectable`),O=/* @__PURE__ */ new Set,k=!1,ge=p(),ve=new AbortController,A={signal:ve.signal},ye=U(s,`:scope > tbody[data-wui-rows]`,HTMLTableSectionElement),j=e(ye,`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`),M=ze(j),N=null,be=null,xe=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))fe.has(n)||t.append(n,r);return t},Se=e=>xe(new URL(e,window.location.href).search),P=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},Ce=(e,t)=>{let n=new URL(e.href);for(let[e,r]of t)fe.has(e)||n.searchParams.append(e,r);return n.origin===window.location.origin?`${n.pathname}${n.search}`:n.href},we=e=>Ce(m,e),F=(e,t)=>{let n=new URLSearchParams(e);return n.has(`page`)&&n.set(`page`,String(t.page)),n.has(`pageSize`)&&n.set(`pageSize`,String(t.pageSize)),n.has(`sortBy`)?t.sortBy?(n.set(`sortBy`,t.sortBy),n.set(`sortOrder`,t.sortOrder)):(n.delete(`sortBy`),n.delete(`sortOrder`)):n.delete(`sortOrder`),n},I=F(f.urlState?xe(window.location.search):new URLSearchParams,M);f.urlState&&P(I)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,P(I));let L=(e,t)=>a.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),R=e=>{d&&(d.textContent=e)},Ee=e=>{if(e.pending)return e.rowCount===0?V().emptyLabel:i(V().pageTextPending,{page:e.page});if(e.total===0)return V().emptyLabel;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1,n=e.totalCapped?Ue(e.total,!0):`${e.total}`;return i(e.total===1?V().pageTextOne:V().pageTextOther,{page:e.page,pages:t,total:n})},z=()=>H(s,`:scope > thead > tr:first-child > th`,HTMLTableCellElement),De=e=>{if(E&&H(e,`:scope > tr:not(.wui-group-row, .wui-virtual-spacer)`,HTMLTableRowElement).some(e=>!e.dataset.rowKey))throw Error(`A selectable server-paged table needs data-row-key on every row, so a selection can span pages.`)},Oe=e=>{let t=n.dataset.activeRowKey;if(t!==void 0)for(let n of e){let e=n.classList.contains(`wui-row-active`),r=t!==``&&n.dataset.rowKey===t;n.classList.toggle(`wui-row-active`,r),r?n.setAttribute(`aria-current`,`true`):e&&n.removeAttribute(`aria-current`)}},ke=e=>{if(E){ue(e);for(let t of e){let e=U(t,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement);e&&(k&&O.add(t.dataset.rowKey),e.checked=O.has(t.dataset.rowKey))}ce(s)}Oe(e);let t=z();if(s.classList.contains(`wui-table-stack`))for(let n of e)[...n.cells].forEach((e,n)=>{let r=t[n]?.textContent?.trim();r&&!e.hasAttribute(`data-label`)&&e.setAttribute(`data-label`,r)});t.forEach((t,n)=>{if(t.classList.contains(`wui-col-hidden`))for(let t of e)t.cells[n]?.classList.add(`wui-col-hidden`)})},Ae=e=>ke(H(e,`:scope > tr`,HTMLTableRowElement)),je=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},B=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),Me=(e,t)=>{if(!l)return;let n=U(e,`:scope > template[data-wui-empty]`,HTMLTemplateElement);B(l),(t.pending?t.rowCount:t.total)===0&&n?(l.replaceChildren(n.content.cloneNode(!0)),l.hidden=!1):(l.replaceChildren(),l.hidden=!0)},Ne=e=>{u&&(B(u),u.replaceChildren(...e?[e.content.cloneNode(!0)]:[]),u.hidden=!1)},He=e=>{let t=f.filtersRegion&&e?U(document,f.filtersRegion,HTMLElement):null;return t&&e&&(B(t),t.replaceChildren(e.content.cloneNode(!0))),t},Ge=0,Ke=e=>{let t=ze(e);t.pending&&Object.assign(t,{total:M.total,totalCapped:M.totalCapped});let n=t.sortBy!==M.sortBy||t.sortOrder!==M.sortOrder?C(j.rows):null;Ne(U(e,`:scope > template[data-wui-pager]`,HTMLTemplateElement)),Me(e,t);let r=He(U(e,`:scope > template[data-wui-filters]`,HTMLTemplateElement));je(e),B(j),s.replaceChild(e,j),j=e,Ge+=1;let i=k&&t.total!==M.total;return M=t,i&&(k=!1),a.removeAttribute(`data-wui-table-error`),Ae(e),rt(),v(e.rows,n),i&&Z(),r},qe=e=>{let t=U(o(`<table>${e}</table>`),`tbody[data-wui-rows]`,HTMLTableSectionElement);return t&&De(t),t?document.importNode(t,!0):null},Je=(e,t=z())=>{let n=document.createElement(`tr`);for(let r=0;r<e;r++){let e=t[r],i=e?.classList.contains(`text-center`),a=!i&&(e?.classList.contains(`num`)||e?.classList.contains(`text-end`)||e?.classList.contains(`wui-cell-end`)),o=document.createElement(`td`);i?o.classList.add(`text-center`):a&&o.classList.add(e?.classList.contains(`num`)?`num`:`wui-cell-end`);let s=document.createElement(`span`);s.className=`skeleton`,s.setAttribute(`aria-hidden`,`true`);let c=i?44:a?56:60;s.style.cssText=`display:block;width:${c}%;height:12px;border-radius:6px`,o.append(s),n.append(o)}return n},Ye=()=>{if(j.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,z().length);j.replaceChildren(...Array.from({length:Pe},()=>{let t=Je(e);return t.setAttribute(`data-wui-skeleton`,``),t})),a.removeAttribute(`data-wui-table-error`),l&&(l.hidden=!0)},K=e=>{e?(a.setAttribute(`aria-busy`,`true`),Ye()):a.removeAttribute(`aria-busy`)},Xe=e=>e===`forbidden`?V().forbiddenMessage:e===`networkCheck`?r(`httpFailure`,pe).networkCheckText:e===`network`?V().networkMessage:e===`timeout`?V().timeoutMessage:f.errorText,Ze=e=>{let t=Xe(e);if(a.setAttribute(`data-wui-table-error`,e),u&&(u.hidden=!0),l){let n=document.createElement(`div`);n.className=`empty-state wui-empty-state-table wui-table-error`,n.setAttribute(`role`,`alert`);let r=document.createElement(`span`);r.className=`empty-state-icon`;let i=ie(e===`forbidden`?`lock`:`alert-circle`,{size:24});i&&r.replaceChildren(i);let a=document.createElement(`div`);a.className=`empty-state-title`,a.textContent=t;let o=document.createElement(`div`);o.className=`empty-state-action`;let s=document.createElement(`button`);s.type=`button`,s.className=te(`primary`,`outline`,`sm`),s.dataset.wui=ne,s.setAttribute(`data-wui-table-retry`,``),s.textContent=V().retryLabel,o.append(s),n.append(r,a,o),B(l),l.replaceChildren(n),l.hidden=!1}R(t)},Qe=()=>f.filtersForm?U(document,f.filtersForm,HTMLFormElement):null,q=async(e,t=`none`,{quiet:r=!1}={})=>{let i=new URLSearchParams(e);r||(N={query:i,mode:t},K(!0),R(f.loadingText)),L(`wui:table:loading`,{query:i.toString()});let o=await ge.run(we(i),{timeoutMs:f.timeoutMs});if(o.kind===`aborted`||o.kind===`stale`||o.kind===`session`)return o;r||K(!1);let s=null;if(o.ok)try{s=qe(o.html)}catch(e){re(e)}if(!o.ok||!s){let e=o.ok?`server`:o.kind;return r?w(`A quiet server table refresh failed; the rows on screen are kept.`,e):Ze(e),L(`wui:table:error`,{status:o.status,kind:e,message:Xe(e)}),o}let c=Ke(s);return I=F(i,M),Ve(Qe(),I),f.urlState&&t===`push`?window.history.pushState(window.history.state,``,P(I)):f.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,P(I)),r||R(Ee(M)),D().refresh(a),c&&D().refresh(c),M.pending?nt():We(n,M.total,M.totalCapped),L(`wui:table:loaded`,{...M,query:I.toString()}),o},J=[],$e=null,et=()=>{if(J.length===0||a.getAttribute(`aria-busy`)===`true`)return;let e=J;J=[],q(I,`none`,{quiet:!0}).then(t=>{for(let n of e)n.resolve(t)},t=>{for(let n of e)n.reject(t)})},Y=async(e,t=`none`,n={})=>{let r;try{r=await q(e,t,n)}catch(e){let t=J;J=[];for(let n of t)n.reject(e);throw e}r.kind===`session`&&($e=r);let i=r.kind===`aborted`&&a.getAttribute(`aria-busy`)===`true`;if(r.kind===`session`||r.kind===`aborted`&&!i){let e=J;J=[];for(let t of e)t.resolve(r)}return et(),r},tt=e=>(e.delete(`page`),e),nt=()=>{if(!_||!M.pending)return;let e=Ge;ee(Ce(_,I),{timeoutMs:f.timeoutMs}).then(t=>{if(e!==Ge)return;if(!t.ok){w(`[@webority/ui-elements] A server table's total did not load; its pager keeps Previous and Next.`,t.kind);return}let r=U(o(t.html),`div[data-wui-total]`,HTMLElement);if(!r){w(`[@webority/ui-elements] A server table's count answer has no div[data-wui-total]; its pager keeps Previous and Next.`);return}if(G(r.dataset.page,-1)!==M.page||G(r.dataset.pageSize,-1)!==M.pageSize)return;let i=G(r.dataset.total,-1);if(i<0){w(`[@webority/ui-elements] A server table's count answer has no whole data-total; its pager keeps Previous and Next.`);return}let a=r.dataset.totalCapped===`true`,s=k&&i!==M.total;M={...M,total:i,totalCapped:a,pending:!1},s&&(k=!1);let c=U(r,`:scope > template[data-wui-pager]`,HTMLTemplateElement);c&&Ne(c);let l=He(U(r,`:scope > template[data-wui-filters]`,HTMLTemplateElement));l&&D().refresh(l),We(n,M.total,M.totalCapped),R(Ee(M)),s&&Z(),L(`wui:table:total`,{total:i,totalCapped:a})})},X=()=>H(s,`:scope > thead th[data-sort-key]`,HTMLTableCellElement),rt=()=>{for(let e of X()){let t=e.dataset.sortKey===M.sortBy;e.setAttribute(`aria-sort`,t?M.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of X())if(e.classList.add(`sortable`),e.tabIndex=0,!e.querySelector(`.sort-icon`)){let t=document.createElement(`span`);t.className=`sort-icon`;let n=ie(`chevrons-up-down`,{size:14});n&&t.replaceChildren(n),e.append(t)}let it=e=>{let t=tt(new URLSearchParams(I)),n=M.sortBy===e&&M.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),Y(t,`push`)};s.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&s.tHead?.contains(t)&&it(t.dataset.sortKey??``)}),s.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof Element?W(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&s.tHead?.contains(t)&&(e.preventDefault(),it(t.dataset.sortKey??``))});let Z=()=>{ce(s),de(s);let e=k?{selected:M.total,total:M.total,allMatching:k}:{selected:O.size,total:M.total};s.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};E&&(se(s,(e,t)=>{for(let n of e){let e=W(n,`tr`,HTMLTableRowElement)?.dataset.rowKey;e&&(t?O.add(e):O.delete(e))}t||(k=!1)}),s.addEventListener(`change`,e=>{let t=e.target;if(t instanceof HTMLInputElement&&t.matches(`.wui-select-cell .form-check-input:not(:disabled)`)){if(t.checked||(k=!1),s.tHead?.contains(t))for(let e of H(j,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let n=U(e,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement);n&&(n.checked=t.checked,t.checked?O.add(e.dataset.rowKey):O.delete(e.dataset.rowKey))}else if(W(t,`tr`,HTMLTableRowElement)?.classList.contains(`wui-group-row`)){let e=W(t,`tr`,HTMLTableRowElement);for(let n=e?.nextElementSibling;n instanceof HTMLTableRowElement&&!n.matches(`tr.wui-group-row`);n=n.nextElementSibling){let e=U(n,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement),r=n.dataset.rowKey;e&&r&&(e.checked=t.checked,t.checked?O.add(r):O.delete(r))}}else{let e=W(t,`tr`,HTMLTableRowElement)?.dataset.rowKey;if(!e)return;t.checked?O.add(e):O.delete(e)}Z()}})),u&&(u.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`a[href]`,HTMLAnchorElement):null;!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),Y(Se(t.getAttribute(`href`)??``),`push`))}),u.addEventListener(`change`,e=>{let t=e.target;t instanceof HTMLSelectElement&&t.classList.contains(`tpg-select`)&&t.value&&(e.stopPropagation(),Y(Se(t.value),`push`))}));let Q=()=>{if(!f.searchInput)return null;let e=U(document,f.searchInput,HTMLElement);return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:e?U(e,`input`,HTMLInputElement):null},$=()=>n.isConnected?!0:(ve.abort(),clearTimeout(be??void 0),!1),at=(e,t)=>{let n=[...e.elements].filter(Fe),r=/* @__PURE__ */ new Set;for(let e of n)e.name&&!Le(e)&&r.add(e.name);let i=[];for(let e of n)if(e.name&&!Ie(e)){if(e instanceof HTMLInputElement&&e.matches(`input[type="hidden"][data-wui-carried]`))r.has(e.name)||i.push([e.name,e.value]);else if(e instanceof HTMLInputElement&&e.matches(`input[type=checkbox], input[type=radio]`))e.checked&&i.push([e.name,e.value]);else if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)e.matches(`[type=submit], [type=button], [type=reset], [type=image], [type=file]`)||i.push([e.name,e.value]);else if(e instanceof HTMLSelectElement)for(let t of e.selectedOptions)i.push([e.name,t.value])}return(t instanceof HTMLButtonElement||t instanceof HTMLInputElement)&&t.name&&!t.disabled&&i.push([t.name,t.value]),i},ot=(e,t)=>{let n=new Set([...e.elements].filter(Fe).map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&ae.includes(e);for(let[e,t]of I)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of at(e,t))a===``||i(n)||fe.has(n)||r.append(n,a);let a=Q();if(a){r.delete(oe);let e=a.value.trim();e&&r.set(oe,e)}return Y(r,`push`)},st=e=>f.filtersForm&&e.closest?.(f.filtersForm)||f.filtersRegion&&e.closest?.(f.filtersRegion)||null;document.addEventListener(`submit`,e=>{$()&&f.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(f.filtersForm)&&(e.preventDefault(),ot(e.target,e.submitter))},A),document.addEventListener(`change`,e=>{if(!$()||!f.filtersForm||!(e.target instanceof Element))return;let t=W(e.target,f.filtersForm,HTMLFormElement);!t||e.target===Q()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest(`wui-filter-popover`)||ot(t)},A);let ct=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of H(e,`input[name]:not([type=hidden])`,HTMLInputElement))if(r.type===`checkbox`)r.checked=t.getAll(r.name).includes(r.value);else if(r.type===`radio`){let e=n(r.name)===r.value;if(r.checked===e)continue;r.checked=e,e&&r.dispatchEvent(new Event(`change`))}else r.value!==n(r.name)&&(r.value=n(r.name),r.dispatchEvent(new Event(`input`,{bubbles:!0})));for(let r of H(e,`select[name]`,HTMLSelectElement))if(!r.multiple)r.value=n(r.name);else for(let e of r.options)e.selected=t.getAll(r.name).includes(e.value);for(let r of[...e.querySelectorAll(`wui-select[name]`)].filter(Re)){let e=r.getAttribute(`name`)??``;r.value=r.mode===`multiple`||r.mode===`tag`?t.getAll(e):n(e)}for(let t of e.querySelectorAll(`wui-date-range`)){let e=t.getAttribute(`start-name`),r=t.getAttribute(`end-name`);t.value={start:e?n(e):``,end:r?n(r):``}}};document.addEventListener(`click`,e=>{if(!$())return;let t=e.target instanceof Element?W(e.target,`a[href]`,HTMLAnchorElement):null;if(!t||!st(t)||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let n=new URL(t.getAttribute(`href`)??``,window.location.href);if(n.origin!==window.location.origin||n.pathname!==window.location.pathname)return;e.preventDefault();let r=tt(Se(n.href));ct(t.closest(`form`),r),Ve(t.closest(`form`),r),Y(r,`push`)},A),document.addEventListener(`input`,e=>{if(!$())return;let t=Q();t&&e.target===t&&(clearTimeout(be??void 0),be=setTimeout(()=>{if(!$())return;let e=tt(new URLSearchParams(I)),n=t.value.trim();n?e.set(oe,n):e.delete(oe),e.toString()!==I.toString()&&Y(e,`replace`)},300))},A),f.urlState&&window.addEventListener(`popstate`,()=>{if(!$())return;let e=xe(window.location.search),t=Q();t&&(t.value=e.get(`search`)??``),Ve(Qe(),e),Y(e,`none`)},A),l?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`[data-wui-table-retry]`)&&N&&Y(N.query,N.mode)});let lt=e=>[...j.rows].find(t=>t.dataset.rowKey===e)??null,ut=e=>{if(!e?.trim())return null;let t=o(`<table><tbody>${e}</tbody></table>`);if(t.querySelector(`tbody[data-wui-rows]`))return null;let n=H(t,`table > tbody > tr[data-row-key]`,HTMLTableRowElement);return n.length?n.map(e=>document.importNode(e,!0)):null},dt=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let i=[];for(let n of e){let e=n===r?t:lt(n.dataset.rowKey);e&&(B(e),e.replaceWith(n),i.push(n))}return ke(i),D().refresh(a),r},ft=e=>e.message||(e.kind===`forbidden`?V().actionForbiddenMessage:V().actionFailedMessage),pt=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&b(e,null)},mt=async({url:e,method:r=`POST`,body:i,key:o,row:s}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let c=o==null,u=c?null:lt(String(o));if(!c&&!u)throw Error(`saveRow found no row with data-row-key="${o}" on this page.`);let d=z().filter(e=>!e.classList.contains(T)),f=s===void 0?u??Je(Math.max(1,d.length),d):t(s,HTMLTableRowElement,"saveRow's `row` is required to be a row element: the <tr> as it will read, not its HTML.");u&&f!==u?u.replaceWith(f):u||j.insertBefore(f,j.firstChild),f!==u&&ke([f]),l&&!a.hasAttribute(`data-wui-table-error`)&&(l.hidden=!0),b(f,`saving`);let p=S(f),m=await ee(e,{method:r.toUpperCase(),body:i});if(m.kind===`session`)return!1;if(m.ok){if(!_e(n)&&he(m))return pt(f),L(`wui:table:saved`,{key:c?null:String(o),added:c,status:m.status}),await me(m,{origin:n}),!0;let e=ut(m.html),t=e&&f.isConnected?dt(e,f,c):null;return t&&R(y(S(t)||p)),Te(m,m.toastVariant||`success`),_e(n)||await me(m,{skip:t?n:null,origin:n}),pt(f),L(`wui:table:saved`,{key:t?.dataset.rowKey??(c?null:String(o)),added:c,status:m.status}),!0}let h=ft(m),g=f;return u&&f!==u&&f.isConnected?(f.replaceWith(u),g=u):c&&!s&&(f.remove(),g=null,l?.childElementCount&&!j.querySelector(`:scope > tr`)&&(l.hidden=!1)),g?.isConnected&&b(g,`error`,h),m.kind!==`aborted`&&Be(h,`danger`),R(x(p,h)),L(`wui:table:failed`,{key:c?null:String(o),added:c,status:m.status,kind:m.kind,message:h}),!1},ht=async e=>{let t=e.dataset.url;if(!t)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);let r=W(e,`tr`,HTMLTableRowElement),i=r?.dataset.rowKey??null,a=e.dataset.wuiRowAction||``,o=r?S(r):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),r&&b(r,`saving`);let s=await ee(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),s.kind===`session`||s.kind===`aborted`)pt(r);else if(s.ok&&!_e(e)&&he(s))pt(r),L(`wui:table:action`,{action:a,key:i,ok:s.ok,status:s.status}),await me(s,{origin:e});else{if(s.ok){Te(s,s.toastVariant||`success`);let t=r?.isConnected?ut(s.html):null,i=t&&r?dt(t,r,!1):null;i&&R(y(S(i)||o)),_e(e)||await me(s,{skip:i?n:null,origin:e}),pt(r)}else{let e=ft(s);Be(e,`danger`),r?.isConnected&&b(r,`error`,e),R(x(o,e))}L(`wui:table:action`,{action:a,key:i,ok:s.ok,status:s.status})}};return s.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`[data-wui-row-action]`,HTMLButtonElement):null;t&&j.contains(t)&&!t.disabled&&(e.preventDefault(),ht(t))}),De(j),je(j),E&&le(s),Ae(j),rt(),M.pending&&(R(Ee(M)),nt()),{el:n,reload:async e=>{if($e)return $e;let t=e?.quiet===!0;return t&&a.getAttribute(`aria-busy`)===`true`?new Promise((e,t)=>{J.push({resolve:e,reject:t})}):Y(I,`none`,{quiet:t})},query:()=>new URLSearchParams(I),setQuery:e=>{let t=new URLSearchParams(I);for(let[n,r]of Object.entries(e??{})){t.delete(n);for(let e of Array.isArray(r)?r:[r])e!=null&&e!==``&&t.append(n,String(e))}return e&&`page`in e||t.delete(`page`),Y(t,`push`)},saveRow:mt,setActiveRow:e=>{n.dataset.activeRowKey=e==null?``:String(e),Oe(H(j,`:scope > tr`,HTMLTableRowElement))},selection:{keys:()=>[...O],count:()=>k?M.total:O.size,allMatching:()=>k,selectAllMatching:()=>{if(M.pending)w(`[@webority/ui-elements] select all matching needs the total; the table is still waiting for its count.`);else{k=!0;for(let e of H(j,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let t=U(e,`.${T} .form-check-input`,HTMLInputElement);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&O.add(e.dataset.rowKey))}Z()}},clear:()=>{k=!1,O.clear();for(let e of H(j,`:scope > tr > .${T} .form-check-input:not(:disabled)`,HTMLInputElement))e.checked=!1;Z()}}}}var qe=/* @__PURE__ */ new WeakSet;function Je(e){let t=e.querySelectorAll?[...e.querySelectorAll(`[data-wui-flash]`)]:[];e instanceof Element&&e.matches(`[data-wui-flash]`)&&t.unshift(e);for(let e of t){let t=e.getAttribute(`data-wui-flash-variant`)||`success`;if(!O(t))throw TypeError(`data-wui-flash-variant="${t}" is not supported. Use ${M.join(`, `)}.`);let n=e.getAttribute(`data-wui-flash`)||(e.textContent??``).trim();e.remove(),n&&F(n,t)}}function Ye(e=document){let t=e instanceof Element?e.ownerDocument:e;if(!qe.has(t)){qe.add(t);let e=E();e&&F(e.message,e.variant,e.action)}Je(e)}var K=/* @__PURE__ */ new WeakMap;function Xe(e,t){K.set(e,t)}function Ze(e){K.delete(e)}function Qe(e){let t=e?.closest(`[data-app-shell]`);return(t&&K.get(t))??null}var q=()=>r(`shell`,a),J=31536e3;function $e(e,t,n,r){let i=[...e.querySelectorAll(`nav.wui-tabbar a.wui-tabbar-item`)].find(e=>e.getAttribute(`href`)===t);if(!i)throw Error(`setTabCount: no tab bar item links to ${t}.`);let a=i.querySelector(`:scope > .wui-tabbar-badge`);if(n===null||n===0){a?.remove();return}a||(a=document.createElement(`span`),i.append(a)),a.className=`wui-tabbar-badge${r?` tone-${r}`:``}`;let o=e.querySelector(`nav.wui-tabbar`)?.hasAttribute(`data-wui-cap-badges`)===!0;a.textContent=o?et(n):String(n)}var et=e=>e>99?`99+`:String(e),Y=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,()=>String(n)),e);function tt(e,t,n=document){try{n.cookie=`${e}=${t?`1`:`0`}; Path=/; Max-Age=${J}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}function nt(e,t,n,r=document){try{let i=`${e}=`,a=r.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(i)),o=new Set(a?a.slice(i.length).split(`.`).filter(Boolean):[]);n?o.add(t):o.delete(t),r.cookie=`${e}=${[...o].join(`.`)}; Path=/; Max-Age=${J}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}var X=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},rt=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},it=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],Z=e=>{if(!(e.target instanceof Element))throw Error(`event target is not an element`);return e.target},Q=e=>{let t=e.getAttribute(`href`);if(t===null)throw Error(`search hit has no href`);return t},$=(e,t)=>{let n=document.createElement(`div`);return n.className=e,n.textContent=t,n},at=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),ot=(e,t,n)=>`${e}${e.includes(`?`)?`&`:`?`}${encodeURIComponent(t)}=${encodeURIComponent(n)}`;function st(t,r){let i=e(X(t,`input.search-input`,HTMLInputElement),`search input missing`),a=X(t,`.wui-topsearch-results`,HTMLElement),s=()=>e(a,`search results missing`),c=X(t,`.wui-topsearch-open`,HTMLElement),l=X(t,`[data-wui-topsearch-live]`,HTMLElement),{src:u,param:d=`q`,resultsHref:f}=t.dataset,ee=Number(t.dataset.minChars??2),m=Number(t.dataset.debounceMs??250),h=t.dataset.noResultsText??q().noResultsText,g=t.dataset.resultsCountText??q().resultsCountText,_=t.dataset.resultCountText??q().resultCountText,te=p(),ne,v=-1,y=()=>it(s(),`.wui-topsearch-hit`,HTMLElement),b=e=>{let t=y();v=t.length===0?-1:(e+t.length)%t.length,t.forEach((e,t)=>{let n=t===v;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-selected`,n?`true`:`false`)});let n=v>=0?t[v]:void 0;n?(i.setAttribute(`aria-activedescendant`,n.id),n.scrollIntoView?.({block:`nearest`})):i.removeAttribute(`aria-activedescendant`)},x=()=>{s().hidden=!0,i.setAttribute(`aria-expanded`,`false`),i.removeAttribute(`aria-activedescendant`),v=-1},S=()=>{s().hidden=!1,i.setAttribute(`aria-expanded`,`true`)},C=e=>{t.classList.toggle(`is-open`,e),c?.setAttribute(`aria-expanded`,e?`true`:`false`)},w=e=>{let n=new CustomEvent(`wui:search:select`,{bubbles:!0,cancelable:!0,detail:{href:e}});t.dispatchEvent(n)&&window.location.assign(e)},re=async e=>{if(t.classList.add(`is-loading`),u===void 0)throw Error(`search has no data-src`);let n=await te.run(ot(u,d,e));if(n.kind!==`aborted`&&n.kind!==`stale`&&n.kind!==`session`){if(t.classList.remove(`is-loading`),n.ok){let e=o(n.html),t=X(e,`[data-wui-count]`,HTMLElement);s().replaceChildren(e),y().forEach((e,t)=>{e.id=`${s().id}-opt-${t}`});let r=t?Number(t.getAttribute(`data-wui-count`)):y().length;l&&(l.textContent=r===0?h:Y(r===1?_:g,{count:r}))}else s().replaceChildren($(`wui-topsearch-empty`,q().searchUnavailableMessage));v=-1,S()}};i.addEventListener(`input`,()=>{clearTimeout(ne);let e=i.value.trim();e.length<ee?(te.abort(),t.classList.remove(`is-loading`),s().replaceChildren(),x()):ne=setTimeout(()=>re(e),m)}),i.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(s().hidden||y().length===0)return;e.preventDefault(),b(v+(e.key===`ArrowDown`?1:-1))}else if(n(e)){let t=y(),n=v>=0?t[v]:void 0;!s().hidden&&n?(e.preventDefault(),w(Q(n))):f&&i.value.trim()!==``&&(e.preventDefault(),w(ot(f,d,i.value.trim())))}else e.key===`Escape`&&(s().hidden?t.classList.contains(`is-open`)&&(e.preventDefault(),e.stopPropagation(),C(!1),c?.focus()):(e.preventDefault(),e.stopPropagation(),x()))}),s().addEventListener(`click`,e=>{let t=rt(Z(e),`.wui-topsearch-hit`,HTMLElement);!t||e.ctrlKey||e.metaKey||e.shiftKey||e.button===1||(e.preventDefault(),w(Q(t)))}),c?.addEventListener(`click`,()=>{let e=!t.classList.contains(`is-open`);C(e),e&&i.focus()});let ie=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||at(e.target)||(e.preventDefault(),C(!0),i.focus())},ae=e=>{e.target instanceof Node&&t.contains(e.target)||(x(),t.classList.contains(`is-open`)&&C(!1))};document.addEventListener(`keydown`,ie),document.addEventListener(`pointerdown`,ae),r.push(()=>{clearTimeout(ne),te.abort(),document.removeEventListener(`keydown`,ie),document.removeEventListener(`pointerdown`,ae)})}function ct(e){let t=[],n=e.dataset.wuiCollapsedCookie;n&&e.addEventListener(`wui:shell:collapse`,e=>{tt(n,!!e.detail?.collapsed)});let r=e.dataset.wuiFoldedCookie;r&&e.addEventListener(`wui:shell:nav-fold`,e=>{nt(r,e.detail?.key,!!e.detail?.folded)}),e.addEventListener(`click`,t=>{Z(t).closest(`[data-wui-tabbar-more]`)&&X(e,`[data-app-shell-menu]`,HTMLElement)?.click()});let i=X(e,`[data-wui-topsearch]`,HTMLElement);i&&st(i,t);let a={el:e,setTabCount(t,n,r){$e(e,t,n,r)},get collapsed(){return e.classList.contains(`collapsed`)},set collapsed(t){if(!!t===e.classList.contains(`collapsed`))return;let n=X(e,`[data-app-shell-collapse]`,HTMLElement);n?n.click():e.classList.toggle(`collapsed`,!!t)}};Xe(e,a);let o=n=>{if(n.target===e||n.target instanceof Node&&n.target.contains(e)){for(let e of t)e();Ze(e),delete e.dataset.wuiPartsWired,document.removeEventListener(`wui:teardown`,o)}};return document.addEventListener(`wui:teardown`,o),a}function lt(e=document){let t=[];e instanceof HTMLElement&&e.matches(`[data-app-shell]`)&&t.push(e),t.push(...it(e,`[data-app-shell]`,HTMLElement));for(let e of t)e.dataset.wuiPartsWired||(e.dataset.wuiPartsWired=`1`,ct(e))}function ut(e){let t=rt(e,`[data-app-shell]`,HTMLElement);return t?(Qe(t)||lt(t),Qe(t)):null}export{ke as CONFIRM_DIALOG_ID,P as CONFIRM_TONES,_ as CSRF_META_NAME,m as DEFAULT_CSRF_HEADER,Ae as DISCARD_EVENT,j as FLASH_STORAGE_KEY,M as FLASH_VARIANTS,f as HTTP_KINDS,d as TOAST_ACTION_METHODS,De as TOAST_ACTION_MS,s as WUI_HEADERS,N as WuiPostError,A as applyRefresh,g as classifyStatus,be as closeRemotePane,c as configureCsrf,L as confirmAction,Ee as createDiscardPrompt,p as createRequestQueue,I as formValues,ye as getServerTable,ut as getShell,Oe as initDrawerDiscard,Ye as initFlashToasts,B as initRemoteModals,je as initServerActions,Ge as initServerTables,lt as initShellParts,xe as initUnsavedChanges,Ne as loadRemoteDrawer,Se as loadRemoteModal,Me as loadRemotePane,o as parseServerHtml,u as parseToastAction,Ce as postAction,l as readCsrf,me as refreshAfter,k as refreshRegions,he as reloadsPage,z as resetUnsavedChanges,R as runToastAction,Te as showResultToast,F as showToast,h as timeoutFromAttribute,ee as wuiFetch,we as wuiUpload};
1
+ import{i as e,n as t}from"./dom-DMQu--xV.js";import{n}from"./imeSafeEnter-DeO_3lXy.js";import{r,t as i}from"./textStore-Cs1SGBoI.js";import{t as a}from"./shell.g-BhC11Oe3.js";import{t as o}from"./serverHtml-BC6tAyAl.js";import{a as s,c,d as l,g as u,h as d,i as f,l as p,m as ee,n as m,p as h,s as g,t as _}from"./wuiHttp-8CYWEbRz.js";import{n as te,t as ne}from"./buttonClass-C8BRtTk8.js";import{E as v,M as y,N as b,b as x,k as S,y as C}from"./dataTable-CSP1x4ZA.js";import{n as w,t as re}from"./devWarn-DXdRWZs3.js";import{t as ie}from"./iconGlyphs.g-DRNDTVOs.js";import{LIST_QUERY_RESERVED as ae,SEARCH_PARAM as oe}from"./listQuery.js";import{a as se,c as ce,i as le,n as T,r as ue,s as de}from"./tableSelect-BrQSoqzs.js";import{t as fe}from"./dataTable.g-1PsmN1Nj.js";import{t as pe}from"./httpFailure.g-DjZzGxPj.js";import{S as E,_ as D,b as O,c as me,d as he,g as k,h as ge,i as _e,m as ve,n as A,p as ye,v as j,y as M}from"./refreshAfter-C2bqZfb9.js";import{S as N,_ as be,a as xe,b as Se,c as P,d as Ce,f as we,g as F,h as Te,i as I,l as L,m as R,n as Ee,o as z,p as De,r as Oe,s as ke,t as Ae,u as je,v as B,x as Me,y as Ne}from"./drawerDiscard-DO4bmfVZ.js";var V=()=>r(`dataTable`,fe),Pe=5,Fe=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,Ie=e=>e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled,Le=e=>Fe(e)&&`type`in e&&e.type===`hidden`,H=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),U=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},W=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Re=e=>e.localName===`wui-select`,G=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},ze=e=>({total:G(e.dataset.total,0),totalCapped:e.dataset.totalCapped===`true`,page:G(e.dataset.page,1),pageSize:G(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`,pending:e.dataset.totalPending===`true`,rowCount:G(e.dataset.rowCount,0)}),Be=(e,t)=>{e&&D().toast(e,{variant:t})},Ve=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>!Le(e)||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!ae.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of H(e,`[data-wui-filter-clear]`,HTMLElement))t.hidden=!r},He=new Intl.NumberFormat(`en-IN`),Ue=(e,t)=>t?`${He.format(e)}+`:He.format(e),We=(e,t,n)=>{let r=e.closest(`.wui-list-card`),i=r?U(r,`.wui-list-card-count`,HTMLElement):null;i&&(i.textContent=Ue(t,n))};function Ge(e=document){let t=H(e,`[data-wui-server]`,HTMLElement);e instanceof HTMLElement&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t){if(ve(e))continue;let t=Ke(e);ge(e,t),e.hasAttribute(`data-load-first-page`)&&t.reload()}}function Ke(n){let a=U(n,`.table-wrap`,HTMLElement),s=a?U(a,`:scope > table`,HTMLTableElement):null,c=n.dataset.src;if(!a||!s||!c)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let l=U(a,`:scope > [data-wui-table-state]`,HTMLElement),u=U(n,`[data-wui-table-pager]`,HTMLElement),d=U(n,`[data-wui-table-status]`,HTMLElement),f={urlState:n.dataset.urlState!==`false`,filtersForm:n.dataset.filtersForm||null,filtersRegion:n.dataset.filtersRegion||null,searchInput:n.dataset.searchInput||null,loadingText:n.dataset.loadingText||V().loadingText,errorText:n.dataset.errorText||V().errorText,timeoutMs:h(n.getAttribute(`data-wui-timeout`))??3e4},m=new URL(c,window.location.href),g=n.dataset.totalSrc||null,_=g===null?null:new URL(g,window.location.href),fe=/* @__PURE__ */ new Set([...m.searchParams.keys(),..._?.searchParams.keys()??[]]),E=s.hasAttribute(`data-app-datatable-selectable`),O=/* @__PURE__ */ new Set,k=!1,ge=p(),ve=new AbortController,A={signal:ve.signal},ye=U(s,`:scope > tbody[data-wui-rows]`,HTMLTableSectionElement),j=e(ye,`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`),M=ze(j),N=null,be=null,xe=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))fe.has(n)||t.append(n,r);return t},Se=e=>xe(new URL(e,window.location.href).search),P=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},Ce=(e,t)=>{let n=new URL(e.href);for(let[e,r]of t)fe.has(e)||n.searchParams.append(e,r);return n.origin===window.location.origin?`${n.pathname}${n.search}`:n.href},we=e=>Ce(m,e),F=(e,t)=>{let n=new URLSearchParams(e);return n.has(`page`)&&n.set(`page`,String(t.page)),n.has(`pageSize`)&&n.set(`pageSize`,String(t.pageSize)),n.has(`sortBy`)?t.sortBy?(n.set(`sortBy`,t.sortBy),n.set(`sortOrder`,t.sortOrder)):(n.delete(`sortBy`),n.delete(`sortOrder`)):n.delete(`sortOrder`),n},I=F(f.urlState?xe(window.location.search):new URLSearchParams,M);f.urlState&&P(I)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,P(I));let L=(e,t)=>a.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),R=e=>{d&&(d.textContent=e)},Ee=e=>{if(e.pending)return e.rowCount===0?V().emptyLabel:i(V().pageTextPending,{page:e.page});if(e.total===0)return V().emptyLabel;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1,n=e.totalCapped?Ue(e.total,!0):`${e.total}`;return i(e.total===1?V().pageTextOne:V().pageTextOther,{page:e.page,pages:t,total:n})},z=()=>H(s,`:scope > thead > tr:first-child > th`,HTMLTableCellElement),De=e=>{if(E&&H(e,`:scope > tr:not(.wui-group-row, .wui-virtual-spacer)`,HTMLTableRowElement).some(e=>!e.dataset.rowKey))throw Error(`A selectable server-paged table needs data-row-key on every row, so a selection can span pages.`)},Oe=e=>{let t=n.dataset.activeRowKey;if(t!==void 0)for(let n of e){let e=n.classList.contains(`wui-row-active`),r=t!==``&&n.dataset.rowKey===t;n.classList.toggle(`wui-row-active`,r),r?n.setAttribute(`aria-current`,`true`):e&&n.removeAttribute(`aria-current`)}},ke=e=>{if(E){ue(e);for(let t of e){let e=U(t,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement);e&&(k&&O.add(t.dataset.rowKey),e.checked=O.has(t.dataset.rowKey))}ce(s)}Oe(e);let t=z();if(s.classList.contains(`wui-table-stack`))for(let n of e)[...n.cells].forEach((e,n)=>{let r=t[n]?.textContent?.trim();r&&!e.hasAttribute(`data-label`)&&e.setAttribute(`data-label`,r)});t.forEach((t,n)=>{if(t.classList.contains(`wui-col-hidden`))for(let t of e)t.cells[n]?.classList.add(`wui-col-hidden`)})},Ae=e=>ke(H(e,`:scope > tr`,HTMLTableRowElement)),je=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},B=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),Me=(e,t)=>{if(!l)return;let n=U(e,`:scope > template[data-wui-empty]`,HTMLTemplateElement);B(l),(t.pending?t.rowCount:t.total)===0&&n?(l.replaceChildren(n.content.cloneNode(!0)),l.hidden=!1):(l.replaceChildren(),l.hidden=!0)},Ne=e=>{u&&(B(u),u.replaceChildren(...e?[e.content.cloneNode(!0)]:[]),u.hidden=!1)},He=e=>{let t=f.filtersRegion&&e?U(document,f.filtersRegion,HTMLElement):null;return t&&e&&(B(t),t.replaceChildren(e.content.cloneNode(!0))),t},Ge=0,Ke=e=>{let t=ze(e);t.pending&&Object.assign(t,{total:M.total,totalCapped:M.totalCapped});let n=t.sortBy!==M.sortBy||t.sortOrder!==M.sortOrder?C(j.rows):null;Ne(U(e,`:scope > template[data-wui-pager]`,HTMLTemplateElement)),Me(e,t);let r=He(U(e,`:scope > template[data-wui-filters]`,HTMLTemplateElement));je(e),B(j),s.replaceChild(e,j),j=e,Ge+=1;let i=k&&t.total!==M.total;return M=t,i&&(k=!1),a.removeAttribute(`data-wui-table-error`),Ae(e),rt(),v(e.rows,n),i&&Z(),r},qe=e=>{let t=U(o(`<table>${e}</table>`),`tbody[data-wui-rows]`,HTMLTableSectionElement);return t&&De(t),t?document.importNode(t,!0):null},Je=(e,t=z())=>{let n=document.createElement(`tr`);for(let r=0;r<e;r++){let e=t[r],i=e?.classList.contains(`text-center`),a=!i&&(e?.classList.contains(`num`)||e?.classList.contains(`text-end`)||e?.classList.contains(`wui-cell-end`)),o=document.createElement(`td`);i?o.classList.add(`text-center`):a&&o.classList.add(e?.classList.contains(`num`)?`num`:`wui-cell-end`);let s=document.createElement(`span`);s.className=`skeleton`,s.setAttribute(`aria-hidden`,`true`);let c=i?44:a?56:60;s.style.cssText=`display:block;width:${c}%;height:12px;border-radius:6px`,o.append(s),n.append(o)}return n},Ye=()=>{if(j.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,z().length);j.replaceChildren(...Array.from({length:Pe},()=>{let t=Je(e);return t.setAttribute(`data-wui-skeleton`,``),t})),a.removeAttribute(`data-wui-table-error`),l&&(l.hidden=!0)},K=e=>{e?(a.setAttribute(`aria-busy`,`true`),Ye()):a.removeAttribute(`aria-busy`)},Xe=e=>e===`forbidden`?V().forbiddenMessage:e===`networkCheck`?r(`httpFailure`,pe).networkCheckText:e===`network`?V().networkMessage:e===`timeout`?V().timeoutMessage:f.errorText,Ze=e=>{let t=Xe(e);if(a.setAttribute(`data-wui-table-error`,e),u&&(u.hidden=!0),l){let n=document.createElement(`div`);n.className=`empty-state wui-empty-state-table wui-table-error`,n.setAttribute(`role`,`alert`);let r=document.createElement(`span`);r.className=`empty-state-icon`;let i=ie(e===`forbidden`?`lock`:`alert-circle`,{size:24});i&&r.replaceChildren(i);let a=document.createElement(`div`);a.className=`empty-state-title`,a.textContent=t;let o=document.createElement(`div`);o.className=`empty-state-action`;let s=document.createElement(`button`);s.type=`button`,s.className=te(`primary`,`outline`,`sm`),s.dataset.wui=ne,s.setAttribute(`data-wui-table-retry`,``),s.textContent=V().retryLabel,o.append(s),n.append(r,a,o),B(l),l.replaceChildren(n),l.hidden=!1}R(t)},Qe=()=>f.filtersForm?U(document,f.filtersForm,HTMLFormElement):null,q=async(e,t=`none`,{quiet:r=!1}={})=>{let i=new URLSearchParams(e);r||(N={query:i,mode:t},K(!0),R(f.loadingText)),L(`wui:table:loading`,{query:i.toString()});let o=await ge.run(we(i),{timeoutMs:f.timeoutMs});if(o.kind===`aborted`||o.kind===`stale`||o.kind===`session`)return o;r||K(!1);let s=null;if(o.ok)try{s=qe(o.html)}catch(e){re(e)}if(!o.ok||!s){let e=o.ok?`server`:o.kind;return r?w(`A quiet server table refresh failed; the rows on screen are kept.`,e):Ze(e),L(`wui:table:error`,{status:o.status,kind:e,message:Xe(e)}),o}let c=Ke(s);return I=F(i,M),Ve(Qe(),I),f.urlState&&t===`push`?window.history.pushState(window.history.state,``,P(I)):f.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,P(I)),r||R(Ee(M)),D().refresh(a),c&&D().refresh(c),M.pending?nt():We(n,M.total,M.totalCapped),L(`wui:table:loaded`,{...M,query:I.toString()}),o},J=[],$e=null,et=()=>{if(J.length===0||a.getAttribute(`aria-busy`)===`true`)return;let e=J;J=[],q(I,`none`,{quiet:!0}).then(t=>{for(let n of e)n.resolve(t)},t=>{for(let n of e)n.reject(t)})},Y=async(e,t=`none`,n={})=>{let r;try{r=await q(e,t,n)}catch(e){let t=J;J=[];for(let n of t)n.reject(e);throw e}r.kind===`session`&&($e=r);let i=r.kind===`aborted`&&a.getAttribute(`aria-busy`)===`true`;if(r.kind===`session`||r.kind===`aborted`&&!i){let e=J;J=[];for(let t of e)t.resolve(r)}return et(),r},tt=e=>(e.delete(`page`),e),nt=()=>{if(!_||!M.pending)return;let e=Ge;ee(Ce(_,I),{timeoutMs:f.timeoutMs}).then(t=>{if(e!==Ge)return;if(!t.ok){w(`[@webority/ui-elements] A server table's total did not load; its pager keeps Previous and Next.`,t.kind);return}let r=U(o(t.html),`div[data-wui-total]`,HTMLElement);if(!r){w(`[@webority/ui-elements] A server table's count answer has no div[data-wui-total]; its pager keeps Previous and Next.`);return}if(G(r.dataset.page,-1)!==M.page||G(r.dataset.pageSize,-1)!==M.pageSize)return;let i=G(r.dataset.total,-1);if(i<0){w(`[@webority/ui-elements] A server table's count answer has no whole data-total; its pager keeps Previous and Next.`);return}let a=r.dataset.totalCapped===`true`,s=k&&i!==M.total;M={...M,total:i,totalCapped:a,pending:!1},s&&(k=!1);let c=U(r,`:scope > template[data-wui-pager]`,HTMLTemplateElement);c&&Ne(c);let l=He(U(r,`:scope > template[data-wui-filters]`,HTMLTemplateElement));l&&D().refresh(l),We(n,M.total,M.totalCapped),R(Ee(M)),s&&Z(),L(`wui:table:total`,{total:i,totalCapped:a})})},X=()=>H(s,`:scope > thead th[data-sort-key]`,HTMLTableCellElement),rt=()=>{for(let e of X()){let t=e.dataset.sortKey===M.sortBy;e.setAttribute(`aria-sort`,t?M.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of X())if(e.classList.add(`sortable`),e.tabIndex=0,!e.querySelector(`.sort-icon`)){let t=document.createElement(`span`);t.className=`sort-icon`;let n=ie(`chevrons-up-down`,{size:14});n&&t.replaceChildren(n),e.append(t)}let it=e=>{let t=tt(new URLSearchParams(I)),n=M.sortBy===e&&M.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),Y(t,`push`)};s.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&s.tHead?.contains(t)&&it(t.dataset.sortKey??``)}),s.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof Element?W(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&s.tHead?.contains(t)&&(e.preventDefault(),it(t.dataset.sortKey??``))});let Z=()=>{ce(s),de(s);let e=k?{selected:M.total,total:M.total,allMatching:k}:{selected:O.size,total:M.total};s.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};E&&(se(s,(e,t)=>{for(let n of e){let e=W(n,`tr`,HTMLTableRowElement)?.dataset.rowKey;e&&(t?O.add(e):O.delete(e))}t||(k=!1)}),s.addEventListener(`change`,e=>{let t=e.target;if(t instanceof HTMLInputElement&&t.matches(`.wui-select-cell .form-check-input:not(:disabled)`)){if(t.checked||(k=!1),s.tHead?.contains(t))for(let e of H(j,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let n=U(e,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement);n&&(n.checked=t.checked,t.checked?O.add(e.dataset.rowKey):O.delete(e.dataset.rowKey))}else if(W(t,`tr`,HTMLTableRowElement)?.classList.contains(`wui-group-row`)){let e=W(t,`tr`,HTMLTableRowElement);for(let n=e?.nextElementSibling;n instanceof HTMLTableRowElement&&!n.matches(`tr.wui-group-row`);n=n.nextElementSibling){let e=U(n,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement),r=n.dataset.rowKey;e&&r&&(e.checked=t.checked,t.checked?O.add(r):O.delete(r))}}else{let e=W(t,`tr`,HTMLTableRowElement)?.dataset.rowKey;if(!e)return;t.checked?O.add(e):O.delete(e)}Z()}})),u&&(u.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`a[href]`,HTMLAnchorElement):null;!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),Y(Se(t.getAttribute(`href`)??``),`push`))}),u.addEventListener(`change`,e=>{let t=e.target;t instanceof HTMLSelectElement&&t.classList.contains(`tpg-select`)&&t.value&&(e.stopPropagation(),Y(Se(t.value),`push`))}));let Q=()=>{if(!f.searchInput)return null;let e=U(document,f.searchInput,HTMLElement);return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:e?U(e,`input`,HTMLInputElement):null},$=()=>n.isConnected?!0:(ve.abort(),clearTimeout(be??void 0),!1),at=(e,t)=>{let n=[...e.elements].filter(Fe),r=/* @__PURE__ */ new Set;for(let e of n)e.name&&!Le(e)&&r.add(e.name);let i=[];for(let e of n)if(e.name&&!Ie(e)){if(e instanceof HTMLInputElement&&e.matches(`input[type="hidden"][data-wui-carried]`))r.has(e.name)||i.push([e.name,e.value]);else if(e instanceof HTMLInputElement&&e.matches(`input[type=checkbox], input[type=radio]`))e.checked&&i.push([e.name,e.value]);else if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)e.matches(`[type=submit], [type=button], [type=reset], [type=image], [type=file]`)||i.push([e.name,e.value]);else if(e instanceof HTMLSelectElement)for(let t of e.selectedOptions)i.push([e.name,t.value])}return(t instanceof HTMLButtonElement||t instanceof HTMLInputElement)&&t.name&&!t.disabled&&i.push([t.name,t.value]),i},ot=(e,t)=>{let n=new Set([...e.elements].filter(Fe).map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&ae.includes(e);for(let[e,t]of I)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of at(e,t))a===``||i(n)||fe.has(n)||r.append(n,a);let a=Q();if(a){r.delete(oe);let e=a.value.trim();e&&r.set(oe,e)}return Y(r,`push`)},st=e=>f.filtersForm&&e.closest?.(f.filtersForm)||f.filtersRegion&&e.closest?.(f.filtersRegion)||null;document.addEventListener(`submit`,e=>{$()&&f.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(f.filtersForm)&&(e.preventDefault(),ot(e.target,e.submitter))},A),document.addEventListener(`change`,e=>{if(!$()||!f.filtersForm||!(e.target instanceof Element))return;let t=W(e.target,f.filtersForm,HTMLFormElement);!t||e.target===Q()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest(`wui-filter-popover`)||ot(t)},A);let ct=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of H(e,`input[name]:not([type=hidden])`,HTMLInputElement))if(r.type===`checkbox`)r.checked=t.getAll(r.name).includes(r.value);else if(r.type===`radio`){let e=n(r.name)===r.value;if(r.checked===e)continue;r.checked=e,e&&r.dispatchEvent(new Event(`change`))}else r.value!==n(r.name)&&(r.value=n(r.name),r.dispatchEvent(new Event(`input`,{bubbles:!0})));for(let r of H(e,`select[name]`,HTMLSelectElement))if(!r.multiple)r.value=n(r.name);else for(let e of r.options)e.selected=t.getAll(r.name).includes(e.value);for(let r of[...e.querySelectorAll(`wui-select[name]`)].filter(Re)){let e=r.getAttribute(`name`)??``;r.value=r.mode===`multiple`||r.mode===`tag`?t.getAll(e):n(e)}for(let t of e.querySelectorAll(`wui-date-range`)){let e=t.getAttribute(`start-name`),r=t.getAttribute(`end-name`);t.value={start:e?n(e):``,end:r?n(r):``}}};document.addEventListener(`click`,e=>{if(!$())return;let t=e.target instanceof Element?W(e.target,`a[href]`,HTMLAnchorElement):null;if(!t||!st(t)||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let n=new URL(t.getAttribute(`href`)??``,window.location.href);if(n.origin!==window.location.origin||n.pathname!==window.location.pathname)return;e.preventDefault();let r=tt(Se(n.href));ct(t.closest(`form`),r),Ve(t.closest(`form`),r),Y(r,`push`)},A),document.addEventListener(`input`,e=>{if(!$())return;let t=Q();t&&e.target===t&&(clearTimeout(be??void 0),be=setTimeout(()=>{if(!$())return;let e=tt(new URLSearchParams(I)),n=t.value.trim();n?e.set(oe,n):e.delete(oe),e.toString()!==I.toString()&&Y(e,`replace`)},300))},A),f.urlState&&window.addEventListener(`popstate`,()=>{if(!$())return;let e=xe(window.location.search),t=Q();t&&(t.value=e.get(`search`)??``),Ve(Qe(),e),Y(e,`none`)},A),l?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`[data-wui-table-retry]`)&&N&&Y(N.query,N.mode)});let lt=e=>[...j.rows].find(t=>t.dataset.rowKey===e)??null,ut=e=>{if(!e?.trim())return null;let t=o(`<table><tbody>${e}</tbody></table>`);if(t.querySelector(`tbody[data-wui-rows]`))return null;let n=H(t,`table > tbody > tr[data-row-key]`,HTMLTableRowElement);return n.length?n.map(e=>document.importNode(e,!0)):null},dt=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let i=[];for(let n of e){let e=n===r?t:lt(n.dataset.rowKey);e&&(B(e),e.replaceWith(n),i.push(n))}return ke(i),D().refresh(a),r},ft=e=>e.message||(e.kind===`forbidden`?V().actionForbiddenMessage:V().actionFailedMessage),pt=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&b(e,null)},mt=async({url:e,method:r=`POST`,body:i,key:o,row:s}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let c=o==null,u=c?null:lt(String(o));if(!c&&!u)throw Error(`saveRow found no row with data-row-key="${o}" on this page.`);let d=z().filter(e=>!e.classList.contains(T)),f=s===void 0?u??Je(Math.max(1,d.length),d):t(s,HTMLTableRowElement,"saveRow's `row` is required to be a row element: the <tr> as it will read, not its HTML.");u&&f!==u?u.replaceWith(f):u||j.insertBefore(f,j.firstChild),f!==u&&ke([f]),l&&!a.hasAttribute(`data-wui-table-error`)&&(l.hidden=!0),b(f,`saving`);let p=S(f),m=await ee(e,{method:r.toUpperCase(),body:i});if(m.kind===`session`)return!1;if(m.ok){if(!_e(n)&&he(m))return pt(f),L(`wui:table:saved`,{key:c?null:String(o),added:c,status:m.status}),await me(m,{origin:n}),!0;let e=ut(m.html),t=e&&f.isConnected?dt(e,f,c):null;return t&&R(y(S(t)||p)),Te(m,m.toastVariant||`success`),_e(n)||await me(m,{skip:t?n:null,origin:n}),pt(f),L(`wui:table:saved`,{key:t?.dataset.rowKey??(c?null:String(o)),added:c,status:m.status}),!0}let h=ft(m),g=f;return u&&f!==u&&f.isConnected?(f.replaceWith(u),g=u):c&&!s&&(f.remove(),g=null,l?.childElementCount&&!j.querySelector(`:scope > tr`)&&(l.hidden=!1)),g?.isConnected&&b(g,`error`,h),m.kind!==`aborted`&&Be(h,`danger`),R(x(p,h)),L(`wui:table:failed`,{key:c?null:String(o),added:c,status:m.status,kind:m.kind,message:h}),!1},ht=async e=>{let t=e.dataset.url;if(!t)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);let r=W(e,`tr`,HTMLTableRowElement),i=r?.dataset.rowKey??null,a=e.dataset.wuiRowAction||``,o=r?S(r):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),r&&b(r,`saving`);let s=await ee(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),s.kind===`session`||s.kind===`aborted`)pt(r);else if(s.ok&&!_e(e)&&he(s))pt(r),L(`wui:table:action`,{action:a,key:i,ok:s.ok,status:s.status}),await me(s,{origin:e});else{if(s.ok){Te(s,s.toastVariant||`success`);let t=r?.isConnected?ut(s.html):null,i=t&&r?dt(t,r,!1):null;i&&R(y(S(i)||o)),_e(e)||await me(s,{skip:i?n:null,origin:e}),pt(r)}else{let e=ft(s);Be(e,`danger`),r?.isConnected&&b(r,`error`,e),R(x(o,e))}L(`wui:table:action`,{action:a,key:i,ok:s.ok,status:s.status})}};return s.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`[data-wui-row-action]`,HTMLButtonElement):null;t&&j.contains(t)&&!t.disabled&&(e.preventDefault(),ht(t))}),De(j),je(j),E&&le(s),Ae(j),rt(),M.pending&&(R(Ee(M)),nt()),{el:n,reload:async e=>{if($e)return $e;let t=e?.quiet===!0;return t&&a.getAttribute(`aria-busy`)===`true`?new Promise((e,t)=>{J.push({resolve:e,reject:t})}):Y(I,`none`,{quiet:t})},query:()=>new URLSearchParams(I),setQuery:e=>{let t=new URLSearchParams(I);for(let[n,r]of Object.entries(e??{})){t.delete(n);for(let e of Array.isArray(r)?r:[r])e!=null&&e!==``&&t.append(n,String(e))}return e&&`page`in e||t.delete(`page`),Y(t,`push`)},saveRow:mt,setActiveRow:e=>{n.dataset.activeRowKey=e==null?``:String(e),Oe(H(j,`:scope > tr`,HTMLTableRowElement))},selection:{keys:()=>[...O],count:()=>k?M.total:O.size,allMatching:()=>k,selectAllMatching:()=>{if(M.pending)w(`[@webority/ui-elements] select all matching needs the total; the table is still waiting for its count.`);else{k=!0;for(let e of H(j,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let t=U(e,`.${T} .form-check-input`,HTMLInputElement);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&O.add(e.dataset.rowKey))}Z()}},clear:()=>{k=!1,O.clear();for(let e of H(j,`:scope > tr > .${T} .form-check-input:not(:disabled)`,HTMLInputElement))e.checked=!1;Z()}}}}var qe=/* @__PURE__ */ new WeakSet;function Je(e){let t=e.querySelectorAll?[...e.querySelectorAll(`[data-wui-flash]`)]:[];e instanceof Element&&e.matches(`[data-wui-flash]`)&&t.unshift(e);for(let e of t){let t=e.getAttribute(`data-wui-flash-variant`)||`success`;if(!O(t))throw TypeError(`data-wui-flash-variant="${t}" is not supported. Use ${M.join(`, `)}.`);let n=e.getAttribute(`data-wui-flash`)||(e.textContent??``).trim();e.remove(),n&&F(n,t)}}function Ye(e=document){let t=e instanceof Element?e.ownerDocument:e;if(!qe.has(t)){qe.add(t);let e=E();e&&F(e.message,e.variant,e.action)}Je(e)}var K=/* @__PURE__ */ new WeakMap;function Xe(e,t){K.set(e,t)}function Ze(e){K.delete(e)}function Qe(e){let t=e?.closest(`[data-app-shell]`);return(t&&K.get(t))??null}var q=()=>r(`shell`,a),J=31536e3;function $e(e,t,n,r){let i=[...e.querySelectorAll(`nav.wui-tabbar a.wui-tabbar-item`)].find(e=>e.getAttribute(`href`)===t);if(!i)throw Error(`setTabCount: no tab bar item links to ${t}.`);let a=i.querySelector(`:scope > .wui-tabbar-badge`);if(n===null||n===0){a?.remove();return}a||(a=document.createElement(`span`),i.append(a)),a.className=`wui-tabbar-badge${r?` tone-${r}`:``}`;let o=e.querySelector(`nav.wui-tabbar`)?.hasAttribute(`data-wui-cap-badges`)===!0;a.textContent=o?et(n):String(n)}var et=e=>e>99?`99+`:String(e),Y=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,()=>String(n)),e);function tt(e,t,n=document){try{n.cookie=`${e}=${t?`1`:`0`}; Path=/; Max-Age=${J}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}function nt(e,t,n,r=document){try{let i=`${e}=`,a=r.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(i)),o=new Set(a?a.slice(i.length).split(`.`).filter(Boolean):[]);n?o.add(t):o.delete(t),r.cookie=`${e}=${[...o].join(`.`)}; Path=/; Max-Age=${J}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}var X=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},rt=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},it=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],Z=e=>{if(!(e.target instanceof Element))throw Error(`event target is not an element`);return e.target},Q=e=>{let t=e.getAttribute(`href`);if(t===null)throw Error(`search hit has no href`);return t},$=(e,t)=>{let n=document.createElement(`div`);return n.className=e,n.textContent=t,n},at=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),ot=(e,t,n)=>`${e}${e.includes(`?`)?`&`:`?`}${encodeURIComponent(t)}=${encodeURIComponent(n)}`;function st(t,r){let i=e(X(t,`input.search-input`,HTMLInputElement),`search input missing`),a=X(t,`.wui-topsearch-results`,HTMLElement),s=()=>e(a,`search results missing`),c=X(t,`.wui-topsearch-open`,HTMLElement),l=X(t,`[data-wui-topsearch-live]`,HTMLElement),{src:u,param:d=`q`,resultsHref:f}=t.dataset,ee=Number(t.dataset.minChars??2),m=Number(t.dataset.debounceMs??250),h=t.dataset.noResultsText??q().noResultsText,g=t.dataset.resultsCountText??q().resultsCountText,_=t.dataset.resultCountText??q().resultCountText,te=p(),ne,v=-1,y=()=>it(s(),`.wui-topsearch-hit`,HTMLElement),b=e=>{let t=y();v=t.length===0?-1:(e+t.length)%t.length,t.forEach((e,t)=>{let n=t===v;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-selected`,n?`true`:`false`)});let n=v>=0?t[v]:void 0;n?(i.setAttribute(`aria-activedescendant`,n.id),n.scrollIntoView?.({block:`nearest`})):i.removeAttribute(`aria-activedescendant`)},x=()=>{s().hidden=!0,i.setAttribute(`aria-expanded`,`false`),i.removeAttribute(`aria-activedescendant`),v=-1},S=()=>{s().hidden=!1,i.setAttribute(`aria-expanded`,`true`)},C=e=>{t.classList.toggle(`is-open`,e),c?.setAttribute(`aria-expanded`,e?`true`:`false`)},w=e=>{let n=new CustomEvent(`wui:search:select`,{bubbles:!0,cancelable:!0,detail:{href:e}});t.dispatchEvent(n)&&window.location.assign(e)},re=async e=>{if(t.classList.add(`is-loading`),u===void 0)throw Error(`search has no data-src`);let n=await te.run(ot(u,d,e));if(n.kind!==`aborted`&&n.kind!==`stale`&&n.kind!==`session`){if(t.classList.remove(`is-loading`),n.ok){let e=o(n.html),t=X(e,`[data-wui-count]`,HTMLElement);s().replaceChildren(e),y().forEach((e,t)=>{e.id=`${s().id}-opt-${t}`});let r=t?Number(t.getAttribute(`data-wui-count`)):y().length;l&&(l.textContent=r===0?h:Y(r===1?_:g,{count:r}))}else s().replaceChildren($(`wui-topsearch-empty`,q().searchUnavailableMessage));v=-1,S()}};i.addEventListener(`input`,()=>{clearTimeout(ne);let e=i.value.trim();e.length<ee?(te.abort(),t.classList.remove(`is-loading`),s().replaceChildren(),x()):ne=setTimeout(()=>re(e),m)}),i.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(s().hidden||y().length===0)return;e.preventDefault(),b(v+(e.key===`ArrowDown`?1:-1))}else if(n(e)){let t=y(),n=v>=0?t[v]:void 0;!s().hidden&&n?(e.preventDefault(),w(Q(n))):f&&i.value.trim()!==``&&(e.preventDefault(),w(ot(f,d,i.value.trim())))}else e.key===`Escape`&&(s().hidden?t.classList.contains(`is-open`)&&(e.preventDefault(),e.stopPropagation(),C(!1),c?.focus()):(e.preventDefault(),e.stopPropagation(),x()))}),s().addEventListener(`click`,e=>{let t=rt(Z(e),`.wui-topsearch-hit`,HTMLElement);!t||e.ctrlKey||e.metaKey||e.shiftKey||e.button===1||(e.preventDefault(),w(Q(t)))}),c?.addEventListener(`click`,()=>{let e=!t.classList.contains(`is-open`);C(e),e&&i.focus()});let ie=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||at(e.target)||(e.preventDefault(),C(!0),i.focus())},ae=e=>{e.target instanceof Node&&t.contains(e.target)||(x(),t.classList.contains(`is-open`)&&C(!1))};document.addEventListener(`keydown`,ie),document.addEventListener(`pointerdown`,ae),r.push(()=>{clearTimeout(ne),te.abort(),document.removeEventListener(`keydown`,ie),document.removeEventListener(`pointerdown`,ae)})}function ct(e){let t=[],n=e.dataset.wuiCollapsedCookie;n&&e.addEventListener(`wui:shell:collapse`,e=>{tt(n,!!e.detail?.collapsed)});let r=e.dataset.wuiFoldedCookie;r&&e.addEventListener(`wui:shell:nav-fold`,e=>{nt(r,e.detail?.key,!!e.detail?.folded)}),e.addEventListener(`click`,t=>{Z(t).closest(`[data-wui-tabbar-more]`)&&X(e,`[data-app-shell-menu]`,HTMLElement)?.click()});let i=X(e,`[data-wui-topsearch]`,HTMLElement);i&&st(i,t);let a={el:e,setTabCount(t,n,r){$e(e,t,n,r)},get collapsed(){return e.classList.contains(`collapsed`)},set collapsed(t){if(!!t===e.classList.contains(`collapsed`))return;let n=X(e,`[data-app-shell-collapse]`,HTMLElement);n?n.click():e.classList.toggle(`collapsed`,!!t)}};Xe(e,a);let o=n=>{if(n.target===e||n.target instanceof Node&&n.target.contains(e)){for(let e of t)e();Ze(e),delete e.dataset.wuiPartsWired,document.removeEventListener(`wui:teardown`,o)}};return document.addEventListener(`wui:teardown`,o),a}function lt(e=document){let t=[];e instanceof HTMLElement&&e.matches(`[data-app-shell]`)&&t.push(e),t.push(...it(e,`[data-app-shell]`,HTMLElement));for(let e of t)e.dataset.wuiPartsWired||(e.dataset.wuiPartsWired=`1`,ct(e))}function ut(e){let t=rt(e,`[data-app-shell]`,HTMLElement);return t?(Qe(t)||lt(t),Qe(t)):null}export{ke as CONFIRM_DIALOG_ID,P as CONFIRM_TONES,_ as CSRF_META_NAME,m as DEFAULT_CSRF_HEADER,Ae as DISCARD_EVENT,j as FLASH_STORAGE_KEY,M as FLASH_VARIANTS,f as HTTP_KINDS,d as TOAST_ACTION_METHODS,De as TOAST_ACTION_MS,s as WUI_HEADERS,N as WuiPostError,A as applyRefresh,g as classifyStatus,be as closeRemotePane,c as configureCsrf,L as confirmAction,Ee as createDiscardPrompt,p as createRequestQueue,I as formValues,ye as getServerTable,ut as getShell,Oe as initDrawerDiscard,Ye as initFlashToasts,B as initRemoteModals,je as initServerActions,Ge as initServerTables,lt as initShellParts,xe as initUnsavedChanges,Ne as loadRemoteDrawer,Se as loadRemoteModal,Me as loadRemotePane,o as parseServerHtml,u as parseToastAction,Ce as postAction,l as readCsrf,me as refreshAfter,k as refreshRegions,he as reloadsPage,z as resetUnsavedChanges,R as runToastAction,Te as showResultToast,F as showToast,h as timeoutFromAttribute,ee as wuiFetch,we as wuiUpload};
@@ -1 +1 @@
1
- (function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.200.0`)throw Error(`[webority-ui] calendar-views expects ui-elements 0.200.0 but the page loaded `+r+`.`);function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=`#view=`,l=`wui-calendar-views:view-change`,u=`wui-calendar-views:period-change`,d=[`previous`,`next`,`today`],f=`.wui-cal-views-switch input[type='radio']`,p=class extends n.ElementBase{constructor(){super(),s(this,`_onChange`,void 0),s(this,`_onClick`,void 0),this._onChange=e=>this._choose(e),this._onClick=e=>this._step(e)}static get observedAttributes(){return[`view`]}connectedCallback(){if(this.addEventListener(`change`,this._onChange),this.addEventListener(`click`,this._onClick),!this.hasAttribute(`data-controlled`)){let e=m(this._views());e&&this.setAttribute(`view`,e)}if(!this.hasAttribute(`view`)){let e=this._views()[0];e&&this.setAttribute(`view`,e)}this._sync()}disconnectedCallback(){this.removeEventListener(`change`,this._onChange),this.removeEventListener(`click`,this._onClick)}attributeChangedCallback(){this._sync()}_views(){return Array.from(this.querySelectorAll(f),e=>e.value)}_sync(){let e=this.getAttribute(`view`)??``;for(let t of this.querySelectorAll(f))t.checked=t.value===e;for(let t of this.querySelectorAll(`:scope > .wui-cal-views-body[data-view]`))t.hidden=t.dataset.view!==e}_choose(e){let t=e.target;if(!(t instanceof HTMLInputElement)||t.type!==`radio`||!this.contains(t))return;let n=t.value;this.hasAttribute(`data-controlled`)||this.setAttribute(`view`,n),h(n),this.dispatchEvent(new CustomEvent(l,{bubbles:!0,detail:{view:n}})),this._sync()}_step(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`button[data-step]`),r=n?.getAttribute(`data-step`)??``;n&&this.contains(n)&&d.includes(r)&&this.dispatchEvent(new CustomEvent(u,{bubbles:!0,detail:{step:r}}))}};function m(e){if(!window.location.hash.startsWith(c))return null;let t=window.location.hash.slice(6);return e.includes(t)?t:null}function h(e){let t=new URL(window.location.href);t.hash=`view=${e}`,window.history.replaceState(window.history.state,``,t)}(0,t.defineElement)(`wui-calendar-views`,p),e.WuiCalendarViews=p})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase);
1
+ (function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.201.0`)throw Error(`[webority-ui] calendar-views expects ui-elements 0.201.0 but the page loaded `+r+`.`);function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=`#view=`,l=`wui-calendar-views:view-change`,u=`wui-calendar-views:period-change`,d=[`previous`,`next`,`today`],f=`.wui-cal-views-switch input[type='radio']`,p=class extends n.ElementBase{constructor(){super(),s(this,`_onChange`,void 0),s(this,`_onClick`,void 0),this._onChange=e=>this._choose(e),this._onClick=e=>this._step(e)}static get observedAttributes(){return[`view`]}connectedCallback(){if(this.addEventListener(`change`,this._onChange),this.addEventListener(`click`,this._onClick),!this.hasAttribute(`data-controlled`)){let e=m(this._views());e&&this.setAttribute(`view`,e)}if(!this.hasAttribute(`view`)){let e=this._views()[0];e&&this.setAttribute(`view`,e)}this._sync()}disconnectedCallback(){this.removeEventListener(`change`,this._onChange),this.removeEventListener(`click`,this._onClick)}attributeChangedCallback(){this._sync()}_views(){return Array.from(this.querySelectorAll(f),e=>e.value)}_sync(){let e=this.getAttribute(`view`)??``;for(let t of this.querySelectorAll(f))t.checked=t.value===e;for(let t of this.querySelectorAll(`:scope > .wui-cal-views-body[data-view]`))t.hidden=t.dataset.view!==e}_choose(e){let t=e.target;if(!(t instanceof HTMLInputElement)||t.type!==`radio`||!this.contains(t))return;let n=t.value;this.hasAttribute(`data-controlled`)||this.setAttribute(`view`,n),h(n),this.dispatchEvent(new CustomEvent(l,{bubbles:!0,detail:{view:n}})),this._sync()}_step(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`button[data-step]`),r=n?.getAttribute(`data-step`)??``;n&&this.contains(n)&&d.includes(r)&&this.dispatchEvent(new CustomEvent(u,{bubbles:!0,detail:{step:r}}))}};function m(e){if(!window.location.hash.startsWith(c))return null;let t=window.location.hash.slice(6);return e.includes(t)?t:null}function h(e){let t=new URL(window.location.href);t.hash=`view=${e}`,window.history.replaceState(window.history.state,``,t)}(0,t.defineElement)(`wui-calendar-views`,p),e.WuiCalendarViews=p})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase);
@@ -1 +1 @@
1
- (function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=globalThis.WeborityUiElementsInternal?.version;if(a!==`0.200.0`)throw Error(`[webority-ui] carousel expects ui-elements 0.200.0 but the page loaded `+a+`.`);var o={carouselLabel:`carousel`,dotLabel:`Go to slide`,nextLabel:`Next slide`,pauseLabel:`Pause`,playLabel:`Play`,previousLabel:`Previous slide`,slideLabel:`slide`,slideText:`{n} of {total}`,statusTextOne:`Slide {first} of {total}`,statusTextOther:`Slides {first} to {last} of {total}`};function s(e){"@babel/helpers - typeof";return s=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},s(e)}function c(e,t){if(s(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(s(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function l(e){var t=c(e,`string`);return s(t)==`symbol`?t:t+``}function u(e,t,n){return(t=l(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var d=()=>(0,i.readText)(`carousel`,o),f=120,p=class extends n.ElementBase{static get observedAttributes(){return[`autoplay`]}constructor(){super(),u(this,`_page`,void 0),u(this,`_pages`,void 0),u(this,`_perView`,void 0),u(this,`_paused`,void 0),u(this,`_hover`,void 0),u(this,`_focus`,void 0),u(this,`_timer`,void 0),u(this,`_settleTimer`,void 0),u(this,`_status`,void 0),u(this,`_ready`,void 0),u(this,`_motion`,void 0),u(this,`_mutations`,void 0),u(this,`_resizer`,void 0),u(this,`_doc`,void 0),u(this,`_track`,void 0),u(this,`_onClick`,void 0),u(this,`_onKeyDown`,void 0),u(this,`_onScroll`,void 0),u(this,`_onEnter`,void 0),u(this,`_onLeave`,void 0),u(this,`_onFocusIn`,void 0),u(this,`_onFocusOut`,void 0),u(this,`_onVisibility`,void 0),u(this,`_onMotion`,void 0),u(this,`_tick`,void 0),this._page=0,this._pages=1,this._perView=1,this._paused=!1,this._hover=!1,this._focus=!1,this._timer=null,this._settleTimer=null,this._status=``,this._ready=!1,this._motion=null,this._mutations=null,this._resizer=null,this._doc=null,this._track=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onScroll=()=>{this._settleTimer!==null&&clearTimeout(this._settleTimer),this._settleTimer=setTimeout(()=>this._settle(),f)},this._onEnter=()=>this._hold({hover:!0}),this._onLeave=()=>this._hold({hover:!1}),this._onFocusIn=()=>this._hold({focus:!0}),this._onFocusOut=e=>this._hold({focus:e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)}),this._onVisibility=()=>this._sync(),this._onMotion=()=>this._sync(),this._tick=()=>{this._timer=null,this._go(this._page+1<this._pages?this._page+1:0)}}connectedCallback(){let e=this.querySelector(`.wui-carousel-track`);if(this._track=e instanceof HTMLElement?e:null,!this._track){this.ownerDocument.readyState===`loading`&&this.ownerDocument.addEventListener(`DOMContentLoaded`,()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this._doc=this.ownerDocument;let t=this.getAttribute(`data-wui-style`);if(t){for(let e of t.split(`;`)){let t=e.indexOf(`:`);t>0&&this.style.setProperty(e.slice(0,t).trim(),e.slice(t+1).trim())}this.removeAttribute(`data-wui-style`)}this._motion=typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(`(prefers-reduced-motion: reduce)`):null,this._motion?.addEventListener(`change`,this._onMotion),this.addEventListener(`click`,this._onClick),this.addEventListener(`mouseenter`,this._onEnter),this.addEventListener(`mouseleave`,this._onLeave),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._track.addEventListener(`keydown`,this._onKeyDown),this._track.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._doc.addEventListener(`visibilitychange`,this._onVisibility),typeof MutationObserver<`u`&&(this._mutations=new MutationObserver(()=>this._refresh()),this._mutations.observe(this._track,{childList:!0})),typeof ResizeObserver<`u`&&(this._resizer=new ResizeObserver(()=>this._refresh()),this._resizer.observe(this._track)),this._ready=!0,this._refresh()}disconnectedCallback(){this._ready=!1,this._timer!==null&&clearTimeout(this._timer),this._settleTimer!==null&&clearTimeout(this._settleTimer),this._timer=null,this._motion?.removeEventListener(`change`,this._onMotion),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mouseenter`,this._onEnter),this.removeEventListener(`mouseleave`,this._onLeave),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._track?.removeEventListener(`keydown`,this._onKeyDown),this._track?.removeEventListener(`scroll`,this._onScroll),this._doc?.removeEventListener(`visibilitychange`,this._onVisibility),this._mutations?.disconnect(),this._resizer?.disconnect(),this._mutations=this._resizer=this._motion=this._doc=null}attributeChangedCallback(){this._ready&&this._sync()}get paused(){return this._paused}set paused(e){this._paused=!!e,this._ready&&this._sync()}next(){this._page+1<this._pages?this._go(this._page+1):this.hasAttribute(`loop`)&&this._go(0)}prev(){this._page>0?this._go(this._page-1):this.hasAttribute(`loop`)&&this._go(this._pages-1)}goTo(e){this._go(Number(e))}_interval(){let e=Number.parseInt(this.getAttribute(`autoplay`)??``,10);return Math.max(e||0,0)}_slides(){let e=this._track;if(!e)throw Error(`WuiCarousel used before it was connected`);return Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.classList.contains(`wui-carousel-slide`))}_playing(){return this._interval()>0&&this._pages>1&&!this._paused&&!this._hover&&!this._focus&&!this._motion?.matches&&!this._doc?.hidden}_hold({hover:e=this._hover,focus:t=this._focus}){this._hover=e,this._focus=t,this._sync()}_click(e){let t=(e.target instanceof Element?e.target:null)?.closest(`.wui-carousel-pause, .wui-carousel-prev, .wui-carousel-next, .wui-carousel-dot`),n=t instanceof HTMLElement?t:null;if(!n||!this.contains(n))return;let r=this._track;if(!r)throw Error(`WuiCarousel used before it was connected`);r.contains(n)||(n.classList.contains(`wui-carousel-pause`)?(this._paused=!this._paused,this._hover=!1,this._focus=!1,this._sync()):n.getAttribute(`aria-disabled`)===`true`?e.preventDefault():n.classList.contains(`wui-carousel-prev`)?this.prev():n.classList.contains(`wui-carousel-next`)?this.next():this._go(Number(n.dataset.page)))}_key(e){if(e.target!==this._track||e.altKey||e.ctrlKey||e.metaKey)return;let t={ArrowRight:()=>this.next(),ArrowLeft:()=>this.prev(),Home:()=>this._go(0),End:()=>this._go(this._pages-1)}[(0,r.mirrorKey)(e.key,(0,r.isRtl)(this))];t&&(e.preventDefault(),t())}_perViewNow(){let e=``;if(typeof window<`u`){let t=this._track;if(!t)throw Error(`WuiCarousel used before it was connected`);e=window.getComputedStyle(t).getPropertyValue(`--wui-carousel-view`)}return Math.max(Number.parseInt(e,10)||0,1)}_start(e){return Math.min(e*this._perView,Math.max(0,this._slides().length-this._perView))}_label(){let e=this._slides();return e.forEach((t,n)=>{let r=(0,i.fillText)(d().slideText,{n:n+1,total:e.length});t.getAttribute(`aria-label`)!==r&&t.setAttribute(`aria-label`,r)}),e.length}_refresh(){let e=this._label();this._perView=this._perViewNow();let t=Math.max(1,Math.ceil(e/this._perView)),n=this.querySelector(`.wui-carousel-dots`);if(n&&n.children.length!==t){let e=this.getAttribute(`dot-label`)||d().dotLabel;n.replaceChildren(...Array.from({length:t},(t,n)=>{let r=this.ownerDocument.createElement(`button`);return r.type=`button`,r.className=`wui-carousel-dot`,r.dataset.page=String(n),r.setAttribute(`aria-label`,`${e} ${this._start(n)+1}`),r}))}this._pages=t,this._page=Math.min(this._page,t-1),this.toggleAttribute(`data-single`,t<=1),this._render(!1),this._sync()}_settle(){let e=this._track;if(!e)throw Error(`WuiCarousel used before it was connected`);let t=this._slides();if(!t.length)return;let n;if(e.scrollWidth>e.clientWidth&&e.scrollLeft+e.clientWidth>=e.scrollWidth-2)n=this._pages-1;else{let r=0,i=1/0;t.forEach((t,n)=>{let a=Math.abs(t.offsetLeft-e.scrollLeft);a<i&&(i=a,r=n)}),n=Math.min(this._pages-1,Math.round(r/this._perView))}n!==this._page&&(this._page=n,this._render(!0),this._sync())}_go(e){if(!Number.isInteger(e))return;this._page=Math.max(0,Math.min(this._pages-1,e));let t=this._track;if(!t)throw Error(`WuiCarousel used before it was connected`);let n=this._slides()[this._start(this._page)];if(n){let e=this._motion?.matches?`auto`:`smooth`;typeof t.scrollTo==`function`?t.scrollTo({left:n.offsetLeft,behavior:e}):t.scrollLeft=n.offsetLeft}this._render(!0),this._sync()}_render(e){let t=this.hasAttribute(`loop`);for(let e of this.querySelectorAll(`.wui-carousel-dot`))e instanceof HTMLElement&&(Number(e.dataset.page)===this._page?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`));this.querySelector(`.wui-carousel-prev`)?.setAttribute(`aria-disabled`,String(!t&&this._page===0)),this.querySelector(`.wui-carousel-next`)?.setAttribute(`aria-disabled`,String(!t&&this._page===this._pages-1));let n=this._slides().length,r=this._start(this._page)+1,a=Math.min(n,r+this._perView-1),o=r===a?(0,i.fillText)(d().statusTextOne,{first:r,total:n}):(0,i.fillText)(d().statusTextOther,{first:r,last:a,total:n});if(o===this._status||(this._status=o,!e))return;let s=this.querySelector(`[data-wui-status]`);s&&!this._playing()&&(s.textContent=o),this.dispatchEvent(new CustomEvent(`wui:carousel:change`,{bubbles:!0,detail:{page:this._page,pages:this._pages}}))}_sync(){this._timer!==null&&clearTimeout(this._timer),this._timer=null;let e=this._interval(),t=this.querySelector(`.wui-carousel-pause`);if(t instanceof HTMLElement){t.hidden=e===0||this._pages<=1||!!this._motion?.matches;let n=this._paused?this.getAttribute(`play-label`)||d().playLabel:this.getAttribute(`pause-label`)||d().pauseLabel,r=t.querySelector(`.wui-carousel-pause-text`);r&&r.textContent!==n&&(r.textContent=n),this.toggleAttribute(`data-paused`,this._paused)}this._playing()&&(this._timer=setTimeout(this._tick,e))}};(0,t.defineElement)(`wui-carousel`,p),e.WuiCarousel=p})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore);
1
+ (function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=globalThis.WeborityUiElementsInternal?.version;if(a!==`0.201.0`)throw Error(`[webority-ui] carousel expects ui-elements 0.201.0 but the page loaded `+a+`.`);var o={carouselLabel:`carousel`,dotLabel:`Go to slide`,nextLabel:`Next slide`,pauseLabel:`Pause`,playLabel:`Play`,previousLabel:`Previous slide`,slideLabel:`slide`,slideText:`{n} of {total}`,statusTextOne:`Slide {first} of {total}`,statusTextOther:`Slides {first} to {last} of {total}`};function s(e){"@babel/helpers - typeof";return s=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},s(e)}function c(e,t){if(s(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(s(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function l(e){var t=c(e,`string`);return s(t)==`symbol`?t:t+``}function u(e,t,n){return(t=l(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var d=()=>(0,i.readText)(`carousel`,o),f=120,p=class extends n.ElementBase{static get observedAttributes(){return[`autoplay`]}constructor(){super(),u(this,`_page`,void 0),u(this,`_pages`,void 0),u(this,`_perView`,void 0),u(this,`_paused`,void 0),u(this,`_hover`,void 0),u(this,`_focus`,void 0),u(this,`_timer`,void 0),u(this,`_settleTimer`,void 0),u(this,`_status`,void 0),u(this,`_ready`,void 0),u(this,`_motion`,void 0),u(this,`_mutations`,void 0),u(this,`_resizer`,void 0),u(this,`_doc`,void 0),u(this,`_track`,void 0),u(this,`_onClick`,void 0),u(this,`_onKeyDown`,void 0),u(this,`_onScroll`,void 0),u(this,`_onEnter`,void 0),u(this,`_onLeave`,void 0),u(this,`_onFocusIn`,void 0),u(this,`_onFocusOut`,void 0),u(this,`_onVisibility`,void 0),u(this,`_onMotion`,void 0),u(this,`_tick`,void 0),this._page=0,this._pages=1,this._perView=1,this._paused=!1,this._hover=!1,this._focus=!1,this._timer=null,this._settleTimer=null,this._status=``,this._ready=!1,this._motion=null,this._mutations=null,this._resizer=null,this._doc=null,this._track=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onScroll=()=>{this._settleTimer!==null&&clearTimeout(this._settleTimer),this._settleTimer=setTimeout(()=>this._settle(),f)},this._onEnter=()=>this._hold({hover:!0}),this._onLeave=()=>this._hold({hover:!1}),this._onFocusIn=()=>this._hold({focus:!0}),this._onFocusOut=e=>this._hold({focus:e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)}),this._onVisibility=()=>this._sync(),this._onMotion=()=>this._sync(),this._tick=()=>{this._timer=null,this._go(this._page+1<this._pages?this._page+1:0)}}connectedCallback(){let e=this.querySelector(`.wui-carousel-track`);if(this._track=e instanceof HTMLElement?e:null,!this._track){this.ownerDocument.readyState===`loading`&&this.ownerDocument.addEventListener(`DOMContentLoaded`,()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this._doc=this.ownerDocument;let t=this.getAttribute(`data-wui-style`);if(t){for(let e of t.split(`;`)){let t=e.indexOf(`:`);t>0&&this.style.setProperty(e.slice(0,t).trim(),e.slice(t+1).trim())}this.removeAttribute(`data-wui-style`)}this._motion=typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(`(prefers-reduced-motion: reduce)`):null,this._motion?.addEventListener(`change`,this._onMotion),this.addEventListener(`click`,this._onClick),this.addEventListener(`mouseenter`,this._onEnter),this.addEventListener(`mouseleave`,this._onLeave),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._track.addEventListener(`keydown`,this._onKeyDown),this._track.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._doc.addEventListener(`visibilitychange`,this._onVisibility),typeof MutationObserver<`u`&&(this._mutations=new MutationObserver(()=>this._refresh()),this._mutations.observe(this._track,{childList:!0})),typeof ResizeObserver<`u`&&(this._resizer=new ResizeObserver(()=>this._refresh()),this._resizer.observe(this._track)),this._ready=!0,this._refresh()}disconnectedCallback(){this._ready=!1,this._timer!==null&&clearTimeout(this._timer),this._settleTimer!==null&&clearTimeout(this._settleTimer),this._timer=null,this._motion?.removeEventListener(`change`,this._onMotion),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mouseenter`,this._onEnter),this.removeEventListener(`mouseleave`,this._onLeave),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._track?.removeEventListener(`keydown`,this._onKeyDown),this._track?.removeEventListener(`scroll`,this._onScroll),this._doc?.removeEventListener(`visibilitychange`,this._onVisibility),this._mutations?.disconnect(),this._resizer?.disconnect(),this._mutations=this._resizer=this._motion=this._doc=null}attributeChangedCallback(){this._ready&&this._sync()}get paused(){return this._paused}set paused(e){this._paused=!!e,this._ready&&this._sync()}next(){this._page+1<this._pages?this._go(this._page+1):this.hasAttribute(`loop`)&&this._go(0)}prev(){this._page>0?this._go(this._page-1):this.hasAttribute(`loop`)&&this._go(this._pages-1)}goTo(e){this._go(Number(e))}_interval(){let e=Number.parseInt(this.getAttribute(`autoplay`)??``,10);return Math.max(e||0,0)}_slides(){let e=this._track;if(!e)throw Error(`WuiCarousel used before it was connected`);return Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.classList.contains(`wui-carousel-slide`))}_playing(){return this._interval()>0&&this._pages>1&&!this._paused&&!this._hover&&!this._focus&&!this._motion?.matches&&!this._doc?.hidden}_hold({hover:e=this._hover,focus:t=this._focus}){this._hover=e,this._focus=t,this._sync()}_click(e){let t=(e.target instanceof Element?e.target:null)?.closest(`.wui-carousel-pause, .wui-carousel-prev, .wui-carousel-next, .wui-carousel-dot`),n=t instanceof HTMLElement?t:null;if(!n||!this.contains(n))return;let r=this._track;if(!r)throw Error(`WuiCarousel used before it was connected`);r.contains(n)||(n.classList.contains(`wui-carousel-pause`)?(this._paused=!this._paused,this._hover=!1,this._focus=!1,this._sync()):n.getAttribute(`aria-disabled`)===`true`?e.preventDefault():n.classList.contains(`wui-carousel-prev`)?this.prev():n.classList.contains(`wui-carousel-next`)?this.next():this._go(Number(n.dataset.page)))}_key(e){if(e.target!==this._track||e.altKey||e.ctrlKey||e.metaKey)return;let t={ArrowRight:()=>this.next(),ArrowLeft:()=>this.prev(),Home:()=>this._go(0),End:()=>this._go(this._pages-1)}[(0,r.mirrorKey)(e.key,(0,r.isRtl)(this))];t&&(e.preventDefault(),t())}_perViewNow(){let e=``;if(typeof window<`u`){let t=this._track;if(!t)throw Error(`WuiCarousel used before it was connected`);e=window.getComputedStyle(t).getPropertyValue(`--wui-carousel-view`)}return Math.max(Number.parseInt(e,10)||0,1)}_start(e){return Math.min(e*this._perView,Math.max(0,this._slides().length-this._perView))}_label(){let e=this._slides();return e.forEach((t,n)=>{let r=(0,i.fillText)(d().slideText,{n:n+1,total:e.length});t.getAttribute(`aria-label`)!==r&&t.setAttribute(`aria-label`,r)}),e.length}_refresh(){let e=this._label();this._perView=this._perViewNow();let t=Math.max(1,Math.ceil(e/this._perView)),n=this.querySelector(`.wui-carousel-dots`);if(n&&n.children.length!==t){let e=this.getAttribute(`dot-label`)||d().dotLabel;n.replaceChildren(...Array.from({length:t},(t,n)=>{let r=this.ownerDocument.createElement(`button`);return r.type=`button`,r.className=`wui-carousel-dot`,r.dataset.page=String(n),r.setAttribute(`aria-label`,`${e} ${this._start(n)+1}`),r}))}this._pages=t,this._page=Math.min(this._page,t-1),this.toggleAttribute(`data-single`,t<=1),this._render(!1),this._sync()}_settle(){let e=this._track;if(!e)throw Error(`WuiCarousel used before it was connected`);let t=this._slides();if(!t.length)return;let n;if(e.scrollWidth>e.clientWidth&&e.scrollLeft+e.clientWidth>=e.scrollWidth-2)n=this._pages-1;else{let r=0,i=1/0;t.forEach((t,n)=>{let a=Math.abs(t.offsetLeft-e.scrollLeft);a<i&&(i=a,r=n)}),n=Math.min(this._pages-1,Math.round(r/this._perView))}n!==this._page&&(this._page=n,this._render(!0),this._sync())}_go(e){if(!Number.isInteger(e))return;this._page=Math.max(0,Math.min(this._pages-1,e));let t=this._track;if(!t)throw Error(`WuiCarousel used before it was connected`);let n=this._slides()[this._start(this._page)];if(n){let e=this._motion?.matches?`auto`:`smooth`;typeof t.scrollTo==`function`?t.scrollTo({left:n.offsetLeft,behavior:e}):t.scrollLeft=n.offsetLeft}this._render(!0),this._sync()}_render(e){let t=this.hasAttribute(`loop`);for(let e of this.querySelectorAll(`.wui-carousel-dot`))e instanceof HTMLElement&&(Number(e.dataset.page)===this._page?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`));this.querySelector(`.wui-carousel-prev`)?.setAttribute(`aria-disabled`,String(!t&&this._page===0)),this.querySelector(`.wui-carousel-next`)?.setAttribute(`aria-disabled`,String(!t&&this._page===this._pages-1));let n=this._slides().length,r=this._start(this._page)+1,a=Math.min(n,r+this._perView-1),o=r===a?(0,i.fillText)(d().statusTextOne,{first:r,total:n}):(0,i.fillText)(d().statusTextOther,{first:r,last:a,total:n});if(o===this._status||(this._status=o,!e))return;let s=this.querySelector(`[data-wui-status]`);s&&!this._playing()&&(s.textContent=o),this.dispatchEvent(new CustomEvent(`wui:carousel:change`,{bubbles:!0,detail:{page:this._page,pages:this._pages}}))}_sync(){this._timer!==null&&clearTimeout(this._timer),this._timer=null;let e=this._interval(),t=this.querySelector(`.wui-carousel-pause`);if(t instanceof HTMLElement){t.hidden=e===0||this._pages<=1||!!this._motion?.matches;let n=this._paused?this.getAttribute(`play-label`)||d().playLabel:this.getAttribute(`pause-label`)||d().pauseLabel,r=t.querySelector(`.wui-carousel-pause-text`);r&&r.textContent!==n&&(r.textContent=n),this.toggleAttribute(`data-paused`,this._paused)}this._playing()&&(this._timer=setTimeout(this._tick,e))}};(0,t.defineElement)(`wui-carousel`,p),e.WuiCarousel=p})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=globalThis.WeborityUiElementsInternal?.version;if(c!==`0.200.0`)throw Error(`[webority-ui] code-block expects ui-elements 0.200.0 but the page loaded `+c+`.`);Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`]);var l=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,razor:`Razor`,css:`CSS`}),u=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),d=`(?![\\s\\S])`,f=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${d})`).source,p=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,u([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],m=[[`comment`,RegExp(`//[^\\n]*|${f}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,u(`async.await.break.case.catch.class.const.continue.default.delete.do.else.export.extends.finally.for.from.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.yield`.split(`.`))],[`literal`,u([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,RegExp(`(?<![\\w$])[A-Za-z_$][\\w$]*(?=\\s*\\()`,``)],[`type`,RegExp(`(?<![\\w$])[A-Z][\\w$]*`,``)],[`punct`,/[{}()[\];,]/]],h=[[`comment`,RegExp(`//[^\\n]*|${f}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,u(`abstract.as.async.await.base.bool.break.byte.case.catch.char.checked.class.const.continue.decimal.default.delegate.do.double.else.enum.event.explicit.extern.finally.fixed.float.for.foreach.get.goto.if.implicit.in.init.int.interface.internal.is.lock.long.namespace.new.object.operator.out.override.params.private.protected.public.readonly.record.ref.required.return.sbyte.sealed.set.short.sizeof.static.string.struct.switch.this.throw.try.typeof.uint.ulong.unchecked.unsafe.ushort.using.var.virtual.void.volatile.when.while.with`.split(`.`))],[`literal`,u([`true`,`false`,`null`])],[`function`,RegExp(`(?<!\\w)[A-Za-z_]\\w*(?=\\s*\\()`,``)],[`type`,RegExp(`(?<!\\w)[A-Z]\\w*`,``)],[`punct`,/[{}()[\];,]/]],g=[[`comment`,RegExp(`--[^\\n]*|${f}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,u(`add.all.alter.and.as.asc.begin.between.by.case.check.column.commit.constraint.create.cross.database.declare.default.delete.desc.distinct.drop.else.end.exec.execute.exists.foreign.from.full.function.group.having.if.in.index.inner.insert.into.is.join.key.left.like.limit.not.null.offset.on.or.order.outer.over.partition.primary.procedure.references.return.returns.right.rollback.select.set.table.then.top.transaction.union.unique.update.values.view.when.where.while.with`.split(`.`))],[`literal`,u([`true`,`false`])],[`type`,u([`bigint`,`bit`,`char`,`date`,`datetime`,`datetime2`,`decimal`,`float`,`int`,`money`,`nchar`,`numeric`,`nvarchar`,`real`,`smallint`,`text`,`time`,`tinyint`,`uniqueidentifier`,`varchar`])],[`function`,/\b[A-Za-z_]\w*(?=\s*\()/],[`punct`,/[(),;]/]],_=[[`comment`,RegExp(`(?<![^\\s;|&(])#[^\\n]*`,``)],[`string`,/"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/],[`variable`,/\$(?:\{[^}\n]*\}?|[A-Za-z_]\w*|[0-9@#?$!*-])/],[`attr`,RegExp(`(?<![\\w-])--?[A-Za-z][\\w-]*`,``)],[`number`,RegExp(`(?<![\\w.-])\\d+(?:\\.\\d+)?\\b`,``)],[`keyword`,u([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,u(`awk.az.cat.cd.chmod.chown.cp.curl.docker.dotnet.echo.gcloud.git.grep.kubectl.ls.mkdir.mv.npm.npx.pnpm.rm.sed.source.sudo.wget`.split(`.`))],[`punct`,/[|&;<>(){}[\]]+/]],v=[[`comment`,/^#[^\n]*/m],[`keyword`,/^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)(?= )/m],[`literal`,/HTTP\/\d(?:\.\d)?/],[`number`,RegExp(`(?<=^HTTP\\/\\d(?:\\.\\d)? )\\d{3}\\b`,`m`)],[`function`,RegExp(`(?<=^[A-Z]+ )\\S+`,`m`)],[`attr`,/^[A-Za-z][\w-]*(?=:)/m],[`string`,RegExp(`(?<=^[A-Za-z][\\w-]*:[ \\t]*)[^\\n]+`,`m`)]],y=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${d})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],b=[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,RegExp(`(?<=\\s)[^\\s=<>/"']+`,``)],[`punct`,/\/?>|=/]],x={json:p,js:m,cs:h,sql:g,bash:_,http:v,css:[[`comment`,new RegExp(f)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`keyword`,/@[\w-]+|!important/],[`attr`,/[\w-]+(?=\s*:[^{};]*[;}])/],[`number`,RegExp(`#[0-9a-fA-F]{3,8}\\b|(?<![\\w-])-?(?:\\d+\\.?\\d*|\\.\\d+)(?:%|[A-Za-z]{1,4})?`,``)],[`function`,/[\w-]+(?=\()/],[`type`,/[.#](?!\d)[A-Za-z_][\w-]*/],[`punct`,/[{}();:,]/]],html:y,htmlTag:b},S=e=>(0,r.hasOwn)(x,e),C=new Map;function w(e){let t=C.get(e);if(!t){let n=x[e],r=e===`sql`?`gi`:`g`,i=n.map(([,e])=>`(${e.source})`).join(`|`);t={re:new RegExp(i,`${r}m`),types:n.map(([e])=>e)},C.set(e,t)}return t}function T(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function E(e,t,n=[]){let{re:r,types:i}=w(e),a=0;for(let o of t.matchAll(r)){let r=o[0];if(!r)continue;T(n,`plain`,t.slice(a,o.index));let s=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[s]===`tag`?E(`htmlTag`,r,n):T(n,i[s]??`plain`,r),a=o.index+r.length}return T(n,`plain`,t.slice(a)),n}function D(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return E(`http`,e);let n=t[0]??``,r=E(`http`,e.slice(0,t.index+n.length)),i=e.slice(t.index+n.length),a=i.trimStart()[0];return a===`{`||a===`[`?E(`json`,i,r):a===`<`?E(`html`,i,r):(T(r,`plain`,i),r)}function O(e,t){let n=String(e??``);if(!n||n.length>1e5)return n?[[`plain`,n]]:[];if(t===`http`)return D(n);let r=t===`razor`?`html`:t;return!S(r)||r===`htmlTag`?[[`plain`,n]]:E(r,n)}function k(e,t){let n=[],r=[n];for(let[i,a]of O(e,t))a.split(/\r\n|\r|\n/).forEach((e,t)=>{t>0&&(n=[],r.push(n)),e&&n.push([i,e])});return r.length>1&&n.length===0&&r.pop(),r}var A={copiedLabel:`Copied`,copyLabel:`Copy`,label:`Code`};function j(e){"@babel/helpers - typeof";return j=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},j(e)}function M(e,t){if(j(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(j(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function N(e){var t=M(e,`string`);return j(t)==`symbol`?t:t+``}function P(e,t,n){return(t=N(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var F=()=>(0,s.readText)(`codeBlock`,A);function I(e){return(0,r.hasOwn)(l,e)}var L=class extends a.ElementBase{constructor(){super(),P(this,`_title`,void 0),P(this,`_view`,void 0),P(this,`_codeEl`,void 0),P(this,`_copyIcon`,void 0),P(this,`_copyText`,void 0),P(this,`_chrome`,null),P(this,`_copied`,!1),P(this,`_observer`,null),P(this,`_timer`,0),P(this,`_cancelFrame`,null);let e=this.ownerDocument;this._title=e.createElement(`span`),this._title.className=`wui-code-title`,this._view=e.createElement(`div`),this._codeEl=e.createElement(`code`),this._copyIcon=e.createElement(`span`),this._copyIcon.className=`wui-code-copy-icon`,this._copyText=e.createElement(`span`)}static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}connectedCallback(){this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._chrome?.contains(e.target))&&this._schedule()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._cancelPending()}attributeChangedCallback(){this.isConnected&&this._render()}_source(){return Array.from(this.children).find(e=>e.classList.contains(`wui-code-source`))}_code(){return(this._source()?.textContent??``).replace(/\r?\n$/,``)}_schedule(){if(this._cancelFrame)return;let e=()=>{this._cancelFrame=null,this._render()};if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(e);this._cancelFrame=()=>cancelAnimationFrame(t)}else{let t=!0;queueMicrotask(()=>{t&&e()}),this._cancelFrame=()=>{t=!1}}}_cancelPending(){this._cancelFrame?.(),this._cancelFrame=null}_render(){if(!this._source())return;this._cancelPending();let e=this.ownerDocument;this._chrome||this._build(e);let t=this.getAttribute(`language`),n=t!==null&&I(t)?t:`text`,r=this.getAttribute(`label`)||``,i=k(this._code(),n);this._title.textContent=r||l[n],this._view.setAttribute(`aria-label`,r||F().label),this._view.style.setProperty(`--wui-code-digits`,String(String(i.length).length)),this._codeEl.replaceChildren(...i.map(t=>R(e,t))),this._copied||(this._copyText.textContent=this._copyLabel()),this.setAttribute(`data-wui-ready`,``),this._observer?.takeRecords()}_build(e){let t=e.createElement(`div`);t.className=`wui-code-chrome`,t.append(this._bar(e));let n=this._view;n.className=`wui-code-view`,n.setAttribute(`role`,`region`),n.tabIndex=0;let r=e.createElement(`pre`);r.className=`wui-code-pre`,r.append(this._codeEl),n.append(r),t.append(n),this._chrome=t,this.append(t)}_bar(e){let t=e.createElement(`div`);t.className=`wui-code-bar`;let r=e.createElement(`button`);return r.type=`button`,r.className=`${(0,n.buttonClass)(`primary`,`ghost`,`sm`)} wui-code-copy`,r.dataset.wui=n.APP_BUTTON_MARKER,r.setAttribute(`aria-live`,`polite`),this._setCopied(!1),r.append(this._copyIcon,this._copyText),r.addEventListener(`click`,async()=>{await(0,i.copyTextToClipboard)(this._code())&&(this._setCopied(!0),clearTimeout(this._timer),this._timer=window.setTimeout(()=>this._setCopied(!1),i.COPY_FEEDBACK_MS))}),t.append(this._title,r),t}_setCopied(e){this._copied=e;let t=(0,o.glyphNode)(e?`check`:`files`,{size:14});this._copyIcon.replaceChildren(...t?[t]:[]),this._copyText.textContent=this._copyLabel()}_copyLabel(){return this._copied?this.getAttribute(`copied-label`)||F().copiedLabel:this.getAttribute(`copy-label`)||F().copyLabel}};function R(e,t){let n=e.createElement(`span`);n.className=`wui-code-line`;for(let[r,i]of t){if(r===`plain`){n.append(i);continue}let t=e.createElement(`span`);t.className=`wui-code-t-${r}`,t.textContent=i,n.append(t)}return n}(0,t.defineElement)(`wui-code-block`,L),e.WuiCodeBlock=L})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.hasOwn,WeborityUiElementsInternal.modules.copyText,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.textStore);
1
+ (function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=globalThis.WeborityUiElementsInternal?.version;if(c!==`0.201.0`)throw Error(`[webority-ui] code-block expects ui-elements 0.201.0 but the page loaded `+c+`.`);Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`]);var l=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,razor:`Razor`,css:`CSS`}),u=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),d=`(?![\\s\\S])`,f=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${d})`).source,p=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,u([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],m=[[`comment`,RegExp(`//[^\\n]*|${f}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,u(`async.await.break.case.catch.class.const.continue.default.delete.do.else.export.extends.finally.for.from.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.yield`.split(`.`))],[`literal`,u([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,RegExp(`(?<![\\w$])[A-Za-z_$][\\w$]*(?=\\s*\\()`,``)],[`type`,RegExp(`(?<![\\w$])[A-Z][\\w$]*`,``)],[`punct`,/[{}()[\];,]/]],h=[[`comment`,RegExp(`//[^\\n]*|${f}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,u(`abstract.as.async.await.base.bool.break.byte.case.catch.char.checked.class.const.continue.decimal.default.delegate.do.double.else.enum.event.explicit.extern.finally.fixed.float.for.foreach.get.goto.if.implicit.in.init.int.interface.internal.is.lock.long.namespace.new.object.operator.out.override.params.private.protected.public.readonly.record.ref.required.return.sbyte.sealed.set.short.sizeof.static.string.struct.switch.this.throw.try.typeof.uint.ulong.unchecked.unsafe.ushort.using.var.virtual.void.volatile.when.while.with`.split(`.`))],[`literal`,u([`true`,`false`,`null`])],[`function`,RegExp(`(?<!\\w)[A-Za-z_]\\w*(?=\\s*\\()`,``)],[`type`,RegExp(`(?<!\\w)[A-Z]\\w*`,``)],[`punct`,/[{}()[\];,]/]],g=[[`comment`,RegExp(`--[^\\n]*|${f}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,u(`add.all.alter.and.as.asc.begin.between.by.case.check.column.commit.constraint.create.cross.database.declare.default.delete.desc.distinct.drop.else.end.exec.execute.exists.foreign.from.full.function.group.having.if.in.index.inner.insert.into.is.join.key.left.like.limit.not.null.offset.on.or.order.outer.over.partition.primary.procedure.references.return.returns.right.rollback.select.set.table.then.top.transaction.union.unique.update.values.view.when.where.while.with`.split(`.`))],[`literal`,u([`true`,`false`])],[`type`,u([`bigint`,`bit`,`char`,`date`,`datetime`,`datetime2`,`decimal`,`float`,`int`,`money`,`nchar`,`numeric`,`nvarchar`,`real`,`smallint`,`text`,`time`,`tinyint`,`uniqueidentifier`,`varchar`])],[`function`,/\b[A-Za-z_]\w*(?=\s*\()/],[`punct`,/[(),;]/]],_=[[`comment`,RegExp(`(?<![^\\s;|&(])#[^\\n]*`,``)],[`string`,/"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/],[`variable`,/\$(?:\{[^}\n]*\}?|[A-Za-z_]\w*|[0-9@#?$!*-])/],[`attr`,RegExp(`(?<![\\w-])--?[A-Za-z][\\w-]*`,``)],[`number`,RegExp(`(?<![\\w.-])\\d+(?:\\.\\d+)?\\b`,``)],[`keyword`,u([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,u(`awk.az.cat.cd.chmod.chown.cp.curl.docker.dotnet.echo.gcloud.git.grep.kubectl.ls.mkdir.mv.npm.npx.pnpm.rm.sed.source.sudo.wget`.split(`.`))],[`punct`,/[|&;<>(){}[\]]+/]],v=[[`comment`,/^#[^\n]*/m],[`keyword`,/^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)(?= )/m],[`literal`,/HTTP\/\d(?:\.\d)?/],[`number`,RegExp(`(?<=^HTTP\\/\\d(?:\\.\\d)? )\\d{3}\\b`,`m`)],[`function`,RegExp(`(?<=^[A-Z]+ )\\S+`,`m`)],[`attr`,/^[A-Za-z][\w-]*(?=:)/m],[`string`,RegExp(`(?<=^[A-Za-z][\\w-]*:[ \\t]*)[^\\n]+`,`m`)]],y=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${d})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],b=[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,RegExp(`(?<=\\s)[^\\s=<>/"']+`,``)],[`punct`,/\/?>|=/]],x={json:p,js:m,cs:h,sql:g,bash:_,http:v,css:[[`comment`,new RegExp(f)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`keyword`,/@[\w-]+|!important/],[`attr`,/[\w-]+(?=\s*:[^{};]*[;}])/],[`number`,RegExp(`#[0-9a-fA-F]{3,8}\\b|(?<![\\w-])-?(?:\\d+\\.?\\d*|\\.\\d+)(?:%|[A-Za-z]{1,4})?`,``)],[`function`,/[\w-]+(?=\()/],[`type`,/[.#](?!\d)[A-Za-z_][\w-]*/],[`punct`,/[{}();:,]/]],html:y,htmlTag:b},S=e=>(0,r.hasOwn)(x,e),C=new Map;function w(e){let t=C.get(e);if(!t){let n=x[e],r=e===`sql`?`gi`:`g`,i=n.map(([,e])=>`(${e.source})`).join(`|`);t={re:new RegExp(i,`${r}m`),types:n.map(([e])=>e)},C.set(e,t)}return t}function T(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function E(e,t,n=[]){let{re:r,types:i}=w(e),a=0;for(let o of t.matchAll(r)){let r=o[0];if(!r)continue;T(n,`plain`,t.slice(a,o.index));let s=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[s]===`tag`?E(`htmlTag`,r,n):T(n,i[s]??`plain`,r),a=o.index+r.length}return T(n,`plain`,t.slice(a)),n}function D(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return E(`http`,e);let n=t[0]??``,r=E(`http`,e.slice(0,t.index+n.length)),i=e.slice(t.index+n.length),a=i.trimStart()[0];return a===`{`||a===`[`?E(`json`,i,r):a===`<`?E(`html`,i,r):(T(r,`plain`,i),r)}function O(e,t){let n=String(e??``);if(!n||n.length>1e5)return n?[[`plain`,n]]:[];if(t===`http`)return D(n);let r=t===`razor`?`html`:t;return!S(r)||r===`htmlTag`?[[`plain`,n]]:E(r,n)}function k(e,t){let n=[],r=[n];for(let[i,a]of O(e,t))a.split(/\r\n|\r|\n/).forEach((e,t)=>{t>0&&(n=[],r.push(n)),e&&n.push([i,e])});return r.length>1&&n.length===0&&r.pop(),r}var A={copiedLabel:`Copied`,copyLabel:`Copy`,label:`Code`};function j(e){"@babel/helpers - typeof";return j=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},j(e)}function M(e,t){if(j(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(j(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function N(e){var t=M(e,`string`);return j(t)==`symbol`?t:t+``}function P(e,t,n){return(t=N(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var F=()=>(0,s.readText)(`codeBlock`,A);function I(e){return(0,r.hasOwn)(l,e)}var L=class extends a.ElementBase{constructor(){super(),P(this,`_title`,void 0),P(this,`_view`,void 0),P(this,`_codeEl`,void 0),P(this,`_copyIcon`,void 0),P(this,`_copyText`,void 0),P(this,`_chrome`,null),P(this,`_copied`,!1),P(this,`_observer`,null),P(this,`_timer`,0),P(this,`_cancelFrame`,null);let e=this.ownerDocument;this._title=e.createElement(`span`),this._title.className=`wui-code-title`,this._view=e.createElement(`div`),this._codeEl=e.createElement(`code`),this._copyIcon=e.createElement(`span`),this._copyIcon.className=`wui-code-copy-icon`,this._copyText=e.createElement(`span`)}static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}connectedCallback(){this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._chrome?.contains(e.target))&&this._schedule()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._cancelPending()}attributeChangedCallback(){this.isConnected&&this._render()}_source(){return Array.from(this.children).find(e=>e.classList.contains(`wui-code-source`))}_code(){return(this._source()?.textContent??``).replace(/\r?\n$/,``)}_schedule(){if(this._cancelFrame)return;let e=()=>{this._cancelFrame=null,this._render()};if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(e);this._cancelFrame=()=>cancelAnimationFrame(t)}else{let t=!0;queueMicrotask(()=>{t&&e()}),this._cancelFrame=()=>{t=!1}}}_cancelPending(){this._cancelFrame?.(),this._cancelFrame=null}_render(){if(!this._source())return;this._cancelPending();let e=this.ownerDocument;this._chrome||this._build(e);let t=this.getAttribute(`language`),n=t!==null&&I(t)?t:`text`,r=this.getAttribute(`label`)||``,i=k(this._code(),n);this._title.textContent=r||l[n],this._view.setAttribute(`aria-label`,r||F().label),this._view.style.setProperty(`--wui-code-digits`,String(String(i.length).length)),this._codeEl.replaceChildren(...i.map(t=>R(e,t))),this._copied||(this._copyText.textContent=this._copyLabel()),this.setAttribute(`data-wui-ready`,``),this._observer?.takeRecords()}_build(e){let t=e.createElement(`div`);t.className=`wui-code-chrome`,t.append(this._bar(e));let n=this._view;n.className=`wui-code-view`,n.setAttribute(`role`,`region`),n.tabIndex=0;let r=e.createElement(`pre`);r.className=`wui-code-pre`,r.append(this._codeEl),n.append(r),t.append(n),this._chrome=t,this.append(t)}_bar(e){let t=e.createElement(`div`);t.className=`wui-code-bar`;let r=e.createElement(`button`);return r.type=`button`,r.className=`${(0,n.buttonClass)(`primary`,`ghost`,`sm`)} wui-code-copy`,r.dataset.wui=n.APP_BUTTON_MARKER,r.setAttribute(`aria-live`,`polite`),this._setCopied(!1),r.append(this._copyIcon,this._copyText),r.addEventListener(`click`,async()=>{await(0,i.copyTextToClipboard)(this._code())&&(this._setCopied(!0),clearTimeout(this._timer),this._timer=window.setTimeout(()=>this._setCopied(!1),i.COPY_FEEDBACK_MS))}),t.append(this._title,r),t}_setCopied(e){this._copied=e;let t=(0,o.glyphNode)(e?`check`:`files`,{size:14});this._copyIcon.replaceChildren(...t?[t]:[]),this._copyText.textContent=this._copyLabel()}_copyLabel(){return this._copied?this.getAttribute(`copied-label`)||F().copiedLabel:this.getAttribute(`copy-label`)||F().copyLabel}};function R(e,t){let n=e.createElement(`span`);n.className=`wui-code-line`;for(let[r,i]of t){if(r===`plain`){n.append(i);continue}let t=e.createElement(`span`);t.className=`wui-code-t-${r}`,t.textContent=i,n.append(t)}return n}(0,t.defineElement)(`wui-code-block`,L),e.WuiCodeBlock=L})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.hasOwn,WeborityUiElementsInternal.modules.copyText,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.textStore);