@webority/ui-elements 0.182.0 → 0.183.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 (60) hide show
  1. package/dist/ui-elements/calendar-views.global.js +1 -1
  2. package/dist/ui-elements/carousel.global.js +1 -1
  3. package/dist/ui-elements/code-block.global.js +1 -1
  4. package/dist/ui-elements/command-palette.global.js +1 -1
  5. package/dist/ui-elements/comment-thread.global.js +1 -1
  6. package/dist/ui-elements/consent-banner.global.js +1 -1
  7. package/dist/ui-elements/context-menu.global.js +1 -1
  8. package/dist/ui-elements/dashboard-grid.global.js +1 -1
  9. package/dist/ui-elements/data-table.global.js +1 -1
  10. package/dist/ui-elements/date-range.global.js +1 -1
  11. package/dist/ui-elements/date-time.global.js +1 -1
  12. package/dist/ui-elements/datepicker.global.js +1 -1
  13. package/dist/ui-elements/dock.global.js +1 -1
  14. package/dist/ui-elements/drawer.global.js +1 -1
  15. package/dist/ui-elements/dropdown.global.js +1 -1
  16. package/dist/ui-elements/entry-grid.global.js +1 -1
  17. package/dist/ui-elements/gantt.global.js +1 -1
  18. package/dist/ui-elements/glyphs.global.js +1 -1
  19. package/dist/ui-elements/hover-card.global.js +1 -1
  20. package/dist/ui-elements/image-crop.global.js +1 -1
  21. package/dist/ui-elements/inline-edit.global.js +1 -1
  22. package/dist/ui-elements/kanban.global.js +1 -1
  23. package/dist/ui-elements/lead-popup.global.js +1 -1
  24. package/dist/ui-elements/lightbox.global.js +1 -1
  25. package/dist/ui-elements/markdown.global.js +1 -1
  26. package/dist/ui-elements/mini-calendar.global.js +1 -1
  27. package/dist/ui-elements/navigation-menu.global.js +1 -1
  28. package/dist/ui-elements/notification-center.global.js +1 -1
  29. package/dist/ui-elements/offline-banner.global.js +1 -1
  30. package/dist/ui-elements/onboarding-checklist.global.js +1 -1
  31. package/dist/ui-elements/org-tree.global.js +1 -1
  32. package/dist/ui-elements/otp.global.js +1 -1
  33. package/dist/ui-elements/overflow.global.js +1 -1
  34. package/dist/ui-elements/phone.global.js +1 -1
  35. package/dist/ui-elements/popover.global.js +1 -1
  36. package/dist/ui-elements/rating.global.js +1 -1
  37. package/dist/ui-elements/record-pager.global.js +1 -1
  38. package/dist/ui-elements/relative-time.global.js +1 -1
  39. package/dist/ui-elements/saved-views.global.js +1 -1
  40. package/dist/ui-elements/select-chips.global.js +1 -1
  41. package/dist/ui-elements/select-recents.global.js +1 -1
  42. package/dist/ui-elements/select-search.global.js +1 -1
  43. package/dist/ui-elements/select-window.global.js +1 -1
  44. package/dist/ui-elements/server.global.js +1 -1
  45. package/dist/ui-elements/shell.global.js +1 -1
  46. package/dist/ui-elements/shortcuts.global.js +1 -1
  47. package/dist/ui-elements/show-more.global.js +1 -1
  48. package/dist/ui-elements/slider.global.js +1 -1
  49. package/dist/ui-elements/sortable.global.js +1 -1
  50. package/dist/ui-elements/status-icon.global.js +1 -1
  51. package/dist/ui-elements/table-export.global.js +1 -1
  52. package/dist/ui-elements/timepicker.global.js +1 -1
  53. package/dist/ui-elements/tour.global.js +1 -1
  54. package/dist/ui-elements/tree-picker.global.js +1 -1
  55. package/dist/ui-elements/tree.global.js +1 -1
  56. package/dist/ui-elements/truncate.global.js +1 -1
  57. package/dist/ui-elements/whats-new.global.js +1 -1
  58. package/dist/ui-elements/wizard.global.js +1 -1
  59. package/dist/ui-elements.global.js +1 -1
  60. package/package.json +5 -5
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,ee,te,g,_,v,y,ne){var re=Object.defineProperty,ie=(e,t)=>{let n={};for(var r in e)re(n,r,{get:e[r],enumerable:!0});return t||re(n,Symbol.toStringTag,{value:`Module`}),n},ae=globalThis.WeborityUiElementsInternal?.version;if(ae!==`0.182.0`)throw Error(`[webority-ui] server expects ui-elements 0.182.0 but the page loaded `+ae+`.`);var b={keepLabel:`Keep editing`,leaveLabel:`Discard changes`,message:`Your changes on this page are not saved. If you leave now, they are lost.`,title:`Discard changes?`},x={cancelLabel:`Cancel`,confirmLabel:`Confirm`,confirmTitle:`Are you sure?`,failedMessage:`That did not work. Try again.`,forbiddenMessage:`You do not have permission to do that.`,networkMessage:`Could not reach the server. Check your connection and try again.`,timeoutMessage:`The server did not answer in time. Check your connection and try again.`,typePhraseLabel:`Type {phrase} to confirm`},oe={backLabel:`Back`,clientMessage:`It may have been moved or deleted.`,closeLabel:`Close`,errorTitle:`This could not be loaded`,forbiddenMessage:`You do not have access to this.`,invalidMessage:`Some fields need attention.`,loadingLabel:`Loading`,networkMessage:`Could not reach the server. Check your connection and try again.`,retryLabel:`Try again`,serverMessage:`Something went wrong on our side. Try again in a moment.`,submitFailedMessage:`Your changes were not saved.`,timeoutMessage:`The server did not answer in time. Check your connection and try again.`},se=new Set(`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(`.`)),ce=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 le(e){return e.html===``?e.response===null?``:e.response.text():e.html}function S(e,t){let n=e=>typeof e==`string`?e.trim():``,r=ce(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 se.has(s)||s===t.trim().toLowerCase()?null:o}var C=`wui-remote-modal`,ue=`wui-remote-drawer`,w=Object.freeze({sm:360,md:480,lg:640,xl:720}),de=`wui-modal-fullscreen`,fe=`wui-modal-wide`,T=Object.freeze({sm:380,md:440,lg:640,xl:880,wide:1080}),E=()=>(0,r.readText)(`modal`,oe),pe=e=>(0,h.timeoutFromAttribute)(e?.getAttribute(`data-wui-timeout`)??null)??h.DEFAULT_TIMEOUT_MS,me=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,D=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,O=`[aria-invalid="true"], .is-invalid, .input-validation-error`,k=`invalid`,he=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,A=`[data-wui-modal-content]`,ge=`[data-wui-pane-close], [data-wui-dismiss]`,_e=()=>(0,t.make)(`button`,{type:`button`,class:`wui-modal-close`,"data-wui-dismiss":!0,"aria-label":E().closeLabel},(0,f.svgRoot)({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`}]])),j=new WeakMap,ve=new WeakSet;function M(e,t){if(e==null)throw TypeError(`The remote modal needs ${t}, and the page does not have it.`);return e}var N=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},ye=(e,t,n)=>M(N(e,t),n),be=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),xe=()=>Object.assign(Error(`The remote modal load was aborted.`),{name:`AbortError`}),Se=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,Ce=(e,t)=>{let n=e instanceof Element?e.closest(t):null;return n instanceof HTMLElement?n:null},we=e=>(0,d.hasOwn)(T,e),Te=e=>(0,d.hasOwn)(w,e);function Ee(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(we(e))return e===`wide`?{px:T.wide,wide:!0}:{px:T[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 De=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};if(e.classList.contains(`wui-modal-wide`))return{px:T.wide,wide:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:T.md}},P=(e,t)=>{e.classList.toggle(de,!!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`)},Oe=[`center`,`top`];function ke(e){if(e==null||e===``)return null;if(Te(e))return{px:w[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 Ae=e=>e.container===`drawer`,F=e=>e.container===`pane`,je=e=>e.container!==`modal`,Me=(e,t)=>Ae(e)?ke(t):Ee(t),I=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},Ne=e=>F(e)?e.shell:ye(e.shell,`.modal-dialog`,`a dialog frame`);function Pe(e=`modal`){let n=e===`drawer`,r=n?ue:C,i=document.getElementById(r);if(i)return i;let a=document.createElement(`wui-modal`);a.id=r,a.setAttribute(`data-wui`,`AppModal`);let o=document.createElement(`dialog`);return o.className=n?`modal wui-modal-shell wui-remote-drawer`:`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${n?w.md:T.md}px`),o.replaceChildren((0,t.make)(`div`,{class:n?`modal-dialog wui-remote-drawer-dialog`:`modal-dialog modal-dialog-centered wui-rb-dialog`},(0,t.make)(`div`,{class:`modal-content wui-modal`}))),a.append(o),document.body.appendChild(a),a}var Fe=e=>(0,t.make)(`div`,{class:`wui-modal-header`},(0,t.make)(`div`,{class:`wui-modal-heading`},(0,t.make)(`div`,{class:`wui-modal-headtext`},(0,t.make)(`div`,{class:`wui-modal-title`},e))),_e()),Ie=e=>(0,t.make)(`div`,{class:`modal-content wui-modal`,"aria-busy":`true`},Fe(e),(0,t.make)(`div`,{class:`wui-modal-body`},(0,t.make)(`div`,{class:`wui-modal-loading`,role:`status`},(0,t.make)(`span`,{class:`visually-hidden`},E().loadingLabel),(0,t.make)(`div`,{class:`skeleton wui-modal-skeleton`}),(0,t.make)(`div`,{class:`skeleton wui-modal-skeleton`}),(0,t.make)(`div`,{class:`skeleton wui-modal-skeleton wui-modal-skeleton--short`})))),Le=(n,i)=>{let a={forbidden:E().forbiddenMessage,networkCheck:(0,r.readText)(`httpFailure`,s.HTTP_FAILURE_TEXT).networkCheckText,client:E().clientMessage,server:E().serverMessage,network:E().networkMessage,timeout:E().timeoutMessage};return(0,t.make)(`div`,{class:`modal-content wui-modal`,"data-wui-modal-error":i},Fe(n),(0,t.make)(`div`,{class:`wui-modal-body`},(0,t.make)(`div`,{class:`wui-modal-state`,role:`alert`},(0,t.make)(`p`,{class:`wui-modal-state-title`},E().errorTitle),(0,t.make)(`p`,{class:`wui-modal-state-text`},a[i]||E().serverMessage),(0,t.make)(`div`,{class:`wui-modal-state-actions`},(0,t.make)(`button`,{type:`button`,class:(0,e.buttonClass)(`primary`,`soft`,`md`),"data-wui-dismiss":!0,"data-wui":e.APP_BUTTON_MARKER},E().closeLabel),(0,t.make)(`button`,{type:`button`,class:(0,e.buttonClass)(`primary`,`solid`,`md`),"data-wui-modal-retry":!0,"data-wui":e.APP_BUTTON_MARKER},E().retryLabel)))))},L=e=>N(e.shell,`.modal-content`),R=e=>(0,t.elementOf)(e.cloneNode(!0),HTMLElement,`a card copy is not an element`);function z(e){e&&e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}))}function B(e,t){let n=L(e),r=n?ze(n):new Map;z(n),n?n.replaceWith(t):Ne(e).appendChild(t),Be(t,r),(0,m.wuiHost)().refresh()}var Re=`input[type="file"][name]`;function ze(e){let t=new Map;for(let n of e.querySelectorAll(Re)){if(!(n instanceof HTMLInputElement))continue;let e=n.files;e&&e.length>0&&t.set(n.name,[...e])}return t}function Be(e,t){if(t.size!==0&&typeof DataTransfer<`u`)for(let n of e.querySelectorAll(Re)){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 Ve=e=>F(e)?!e.shell.hidden:e.host.hasAttribute(`open`);function He(e,t,n=!1){let r=t?N(e,O):null,i=r?r.matches(me)?r:N(r,me)||r:null;if(!i&&n)i=N(e,`[data-autofocus]`)||N(e,D)||N(e,`.wui-modal-close`);else if(!i){let t=be(e,me);i=N(e,`[data-autofocus]`)||t.find(e=>!e.classList.contains(`wui-modal-close`))||t[0]||e}r?i?.focus?.():i?.focus?.({preventScroll:!0})}function Ue(e,t){let n=N(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`,``),Ne(e).appendChild(n)),n.textContent=``,n.textContent=t}var We=e=>{let t=N(e.shell,`[data-wui-modal-live]`);t&&(t.textContent=``)},V=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};function H(e,t,n,r){let i={...r,container:e.container};V(t,`wui:modal:${n}`,i),Ae(e)&&V(t,`wui:drawer:${n}`,i),F(e)&&V(t,`wui:pane:${n}`,i)}var Ge=e=>e.matches(`[data-wui-pane-host]`)?`pane`:ye(e,`dialog`,`a dialog`).classList.contains(`wui-remote-drawer`)?`drawer`:`modal`,Ke=e=>M(e.host.closest(`wui-modal`),`a wui-modal host`);function qe(e){let n=j.get(e);if(n)return n;let r=Ge(e),i=r===`pane`?e:ye(e,`dialog`,`a dialog`),a=L({shell:i}),o={host:e,shell:i,container:r,queue:(0,h.createRequestQueue)(),defaultSize:De(i),defaultLabel:i.getAttribute(`aria-label`),placeholder:a?R(a):(0,t.make)(`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 j.set(e,o),e.addEventListener(`submit`,e=>ht(o,e)),e.addEventListener(`click`,e=>{Ce(e.target,`[data-wui-modal-retry]`)&&o.session&&(e.preventDefault(),nt(o,o.session))}),F(o)&&e.addEventListener(`click`,t=>{let n=Ce(t.target,ge);n&&e.contains(n)&&o.session&&U(o,o.session,`dismissed`,null)}),e.addEventListener(`wui-modal-close`,t=>{t.target===e&&t instanceof CustomEvent&&dt(t.detail,`reason`)===`escape`&&e.querySelector(`form[data-wui-submitting]`)&&t.preventDefault()}),e.addEventListener(`wui-modal-closed`,t=>{t.target===e&&$e(o)}),e.addEventListener(`wui-modal-opened`,t=>{if(t.target!==e)return;let n=L(o);o.session&&n?.matches(A)&&!n.contains(document.activeElement)&&He(n,!1,je(o))}),o.remoteUrl&&e.addEventListener(`wui-modal-open`,t=>{t.target===e&&et(o,t)}),o}function Je(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:()=>U(e,o,`dismissed`,null),reload:()=>nt(e,o)},pendingRefresh:r};return e.session=o,o}function U(e,t,n,r){e.session===t&&(t.closing={status:n,detail:r},F(e)?Xe(e,t):Ye(e))}function Ye(e){let t=Ke(e);t.dispatchEvent(new CustomEvent(`wui-modal-close`,{bubbles:!0,cancelable:!0,detail:{reason:`dismiss`}}))&&t.hide()}function Xe(e,t){let n=e.shell,{status:r,detail:i}=M(t.closing,`the closing state`),a=n.contains(document.activeElement);e.queue.abort(),e.session=null,z(L(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),H(e,n,`closed`,{status:r,url:t.url}),Ze(t),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function Ze(e){let t=e.pendingRefresh;e.pendingRefresh=null,t&&(0,u.applyPlan)(t).catch(o.devError)}function Qe(e,t){for(let n=e;n!==null;n=n.parentElement){let e=n instanceof HTMLElement?j.get(n):void 0;if(e?.session){let n=(0,u.planReloads)(t);return e.session.pendingRefresh=(0,u.mergePlans)(e.session.pendingRefresh,{...t,message:n?t.message:null,action:n?t.action:null}),!0}}return!1}(0,u.setDialogHold)(Qe);function $e(e){let t=e.session;if(e.queue.abort(),e.session=null,We(e),t){let n=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n.status,detail:n.detail}),H(e,e.shell,`closed`,{status:n.status,url:t.url}),Ze(t);let r=document.activeElement;t.trigger?.isConnected&&(!r||r===document.body||e.shell.contains(r))&&t.trigger.focus?.()}e.cache||(B(e,R(e.placeholder)),e.loadedUrl=null,P(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function et(e,t){let n=dt(t instanceof CustomEvent?t.detail:null,`trigger`),r=n instanceof HTMLElement?n:null,i=r?.getAttribute(`data-wui-url`)||e.remoteUrl||``,a=Je(e,i,{trigger:r});a.explicitSize=tt(e,r?.getAttribute(`data-wui-size`)),a.explicitSize&&P(e.shell,a.explicitSize),e.cache&&e.loadedUrl===i||(e.loadedUrl&&B(e,R(e.placeholder)),nt(e,a,{keepPlaceholder:!0}))}function tt(e,t){try{return Me(e,t)}catch(e){return(0,o.devError)(e),null}}async function nt(e,t,{keepPlaceholder:n=!1}={}){n||B(e,Ie(t.options.title||rt(e)));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate,timeoutMs:pe(t.trigger)});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if(r.kind===`ok`&&st(e,t,r.html,!1))return e.loadedUrl=t.url,H(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return B(e,Le(t.options.title||rt(e),i)),Ve(e)&&He(M(L(e),`a card`),!1,je(e)),H(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var rt=e=>L(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,it=`/_content/Webority.Ui.Razor/js/`,at=e=>new URL(e,window.location.href).pathname.includes(it);function ot(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function st(e,t,n,r){let i=(0,p.parseServerHtml)(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&&at(t)?ot(t):a=!0}a&&(0,o.devWarn)(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let s=N(i,A);if(!s)return(0,o.devError)(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;if(B(e,s),r||We(e),!F(e)){P(e.shell,t.explicitSize||tt(e,s.getAttribute(`data-wui-size`))||e.defaultSize);let n=s.getAttribute(`data-wui-title`);n&&e.shell.setAttribute(`aria-label`,n)}return Ve(e)&&He(s,r,je(e)),!0}var ct=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function lt(e,n,r){let i=[...e.elements].filter(e=>e.matches(ct));if(r){e.setAttribute(`data-wui-submitting`,``);let r=n&&i.includes(n)?n:i[0];for(let e of i)e.toggleAttribute(`data-wui-was-disabled`,e.disabled),e.disabled=!0;r&&(r.classList.add(`is-loading`),r.setAttribute(`aria-busy`,`true`),r.tagName===`BUTTON`&&r.prepend((0,t.make)(`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 i)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 ut(e){for(let t of e.querySelectorAll(he))t.remove();for(let t of e.querySelectorAll(O))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}var dt=(e,t)=>{if(typeof e==`object`&&e&&t in e)return Reflect.get(e,t)};async function ft(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 le(e))}catch{return null}return S(t,e.response.statusText)}function pt(e,t,n,i){let a={forbidden:E().forbiddenMessage,networkCheck:(0,r.readText)(`httpFailure`,s.HTTP_FAILURE_TEXT).networkCheckText,client:E().clientMessage,server:E().serverMessage,network:E().networkMessage,timeout:E().timeoutMessage},o=t.closest(`.wui-modal-body`)||t;o.querySelector(`[data-wui-modal-submit-error]`)?.remove(),ut(o);let c=document.createElement(`div`);c.className=`alert alert-danger wui-modal-submit-error`,c.setAttribute(`role`,`alert`),c.setAttribute(`data-wui-modal-submit-error`,``),c.textContent=`${E().submitFailedMessage} ${i||a[n]||E().serverMessage}`,o.prepend(c),Ue(e,c.textContent)}var mt=(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(A)||(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,s=(i?.getAttribute(`formmethod`)||n.getAttribute(`method`)||`GET`).toUpperCase(),c=new FormData(n);i?.name&&!c.has(i.name)&&c.append(i.name,i.value);let l=s===`GET`;lt(n,i,!0);let u;try{u=await e.queue.run(l?mt(a,c):a,{method:s,body:l?void 0:c,navigate:r.options.navigate,timeoutMs:pe(r.trigger)})}catch(t){(0,o.devError)(t),e.session===r&&n.isConnected&&(lt(n,i,!1),pt(e,n,`server`,null));return}if(e.session!==r)return;if(n.isConnected&&lt(n,i,!1),u.kind===`ok`&&u.result===`success`){gt(e,r,u);return}if(u.kind===`aborted`||u.kind===`stale`||u.kind===`session`)return;if(u.kind===`ok`&&u.html){let t=u.result===k;if(st(e,r,u.html,t)){if(t){let t=M(L(e),`a card`).querySelector(he)?.textContent?.replace(/\s+/g,` `).trim();Ue(e,t||E().invalidMessage)}return}}let d=u.kind===`ok`||u.kind===`validation`?`server`:u.kind,f=await ft(u);e.session===r&&pt(e,n,d,f)}function gt(e,t,n){let r=n.message,i=n.redirect||null,a=n.toastVariant||`success`;if(!(0,c.isToastVariant)(a))throw TypeError(`Unknown toast variant "${a}". Use ${c.FLASH_VARIANTS.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||(0,u.isRefreshOff)(t.trigger)?null:(0,u.planOf)(n),l=!(n.next&&!i)&&!n.keepOpen,d=s!==null&&l&&(0,u.planReloads)(s);i&&!t.options.navigate?(0,c.storeFlash)(r,a):r&&!d&&(0,m.wuiHost)().toast(r,{variant:a}),H(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=(0,u.mergePlans)(t.pendingRefresh,{...s,action:null,message:d?s.message:null}));let f=n.next;f&&!i?(t.url=f,t.method=`GET`,t.body=void 0,nt(e,t)):n.keepOpen?n.html&&n.data===null&&st(e,t,n.html,!1):U(e,t,`success`,o)}function _t(e){let t=Ce(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`)?wt(t.getAttribute(`data-wui-pane`)??``,{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{Se(e)||(0,o.devError)(e)}):t.hasAttribute(`data-wui-modal`)?bt(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=>{Se(e)||(0,o.devError)(e)}):St(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=>{Se(e)||(0,o.devError)(e)})))}function vt(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=Ce(e.target,Ct);if(!t)return;let n=j.get(t),r=e.currentTarget;n?.session&&r instanceof Document&&!r.querySelector(`wui-modal[open]`)&&(t.querySelector(`form[data-wui-submitting]`)||(e.preventDefault(),U(n,n.session,`dismissed`,null)))}function yt(e=document){let t=e instanceof Document?e:M(e.ownerDocument,`an owner document`);ve.has(t)||(ve.add(t),t.addEventListener(`click`,_t),t.addEventListener(`keydown`,vt));let n=be(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)qe(e)}function bt(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=t.container===`drawer`,r=n?ke(t.size):Ee(t.size),i=t.placement||`center`;if(!Oe.includes(i))throw TypeError(`WUI.modal.load: unsupported placement "${i}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(xe());let a=Pe(n?`drawer`:`modal`);yt(document);let o=qe(a),s=Ve(o),c=Je(o,e,t);c.explicitSize=r,P(o.shell,r||o.defaultSize),n||ye(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=nt(o,c);return s||Ke(o).show(),xt(o,c,t,l,u,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function xt(e,t,n,r,i,a){let o=new Promise((r,i)=>{n.signal?.addEventListener(`abort`,()=>{e.session===t&&(e.queue.abort(),U(e,t,`dismissed`,{aborted:!0})),i(xe())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw xe();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 St(e,t={}){return bt(e,{...t,container:`drawer`,placement:void 0})}var Ct=`[data-wui-pane-host]`;function wt(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=I(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(xe());yt(document);let r=qe(n),i=Je(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=nt(r,i);return xt(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function Tt(e){let t=I(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=j.get(t);n?.session&&U(n,n.session,`dismissed`,null)}var W=`wuiConfirm`,Et=Object.freeze([`danger`]),Dt=Object.freeze([`warning`,`info`,`delete`]),G=()=>(0,r.readText)(`confirmDialog`,x),Ot=new WeakSet,kt=new WeakSet,At=null,jt=null,Mt=!1,Nt=(e,t)=>{e&&(0,m.wuiHost)().toast(e,{variant:t})};function Pt(){let n=document.getElementById(W);if(n)return(0,t.must)(n.closest(`wui-modal`),`#${W} must be a wui-modal.`);let r=document.createElement(`wui-modal`);r.id=W;let i=document.createElement(`dialog`);return i.className=`modal wui-modal-shell`,i.style.setProperty(`--wui-modal-max-width`,`${T.md}px`),i.replaceChildren((0,t.make)(`div`,{class:`modal-dialog modal-dialog-centered wui-rb-dialog`},(0,t.make)(`div`,{class:`modal-content wui-modal wui-confirm`},(0,t.make)(`div`,{class:`wui-modal-body`},(0,t.make)(`div`,{class:`wui-confirm-content`},(0,t.make)(`span`,{class:`wui-confirm-icon`},(0,t.make)(`wui-status-icon`,{tone:`info`,size:120})),(0,t.make)(`h3`,{class:`wui-confirm-title`,tabindex:-1,"data-autofocus":``}),(0,t.make)(`p`,{class:`wui-confirm-msg`}))),(0,t.make)(`div`,{class:`wui-modal-footer`},(0,t.make)(`div`,{class:`wui-confirm-actions`},(0,t.make)(`button`,{type:`button`,class:(0,e.buttonClass)(`primary`,`soft`,`md`),"data-wui-dismiss":``,"data-wui":e.APP_BUTTON_MARKER},G().cancelLabel),(0,t.make)(`button`,{type:`button`,class:(0,e.buttonClass)(`primary`,`solid`,`md`),"data-app-confirm":``,"data-wui":e.APP_BUTTON_MARKER})))))),r.append(i),document.body.appendChild(r),r}function Ft(e,t){let n=e.getAttribute(`data-wui-confirm-tone`);if(n!==null&&!Et.includes(n))throw TypeError(`data-wui-confirm-tone="${n}" is not supported. Use danger, or leave it off.`);It({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 It({title:e,message:n,label:r,danger:i,cancel:a,icon:o},s){let c=Pt(),l=c.querySelector(`.wui-confirm-title`),u=c.querySelector(`[data-app-confirm]`);if(!l||!u)throw Error(`#${W} is not a confirm dialog with a confirm button. Render <app-confirm-dialog id="${W}"> 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||G().confirmTitle;l.textContent=f,d.textContent=n,u.textContent=r||G().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||G().cancelLabel),(0,t.must)(c.querySelector(`dialog`),`#${W} has no <dialog>.`).setAttribute(`aria-label`,f),jt=s,Mt=!1,c.show()}var Lt=(e,t)=>{At=e;try{t()}finally{At=null}},Rt=(e,t)=>{let n=Reflect.get(e,t);if(n===void 0||typeof n==`string`)return n;throw TypeError(`confirmAction: ${t} must be text.`)},zt=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:Rt(e,`title`),message:t,label:Rt(e,`label`),tone:Rt(e,`tone`),cancel:Rt(e,`cancel`),icon:Rt(e,`icon`)}};function Bt(e,t,n){let{title:r,message:i,label:a,tone:o,cancel:s,icon:c}=zt(t);if(o!=null&&!Et.includes(o))throw TypeError(`confirmAction: tone "${o}" is not supported. Use danger, or leave it off.`);if(c!=null&&!Dt.includes(c))throw TypeError(`confirmAction: icon "${c}" is not supported. Use warning, info or delete, or leave it off.`);dn(e.ownerDocument),It({title:r,message:i,label:a,danger:o===`danger`,cancel:s,icon:c},()=>Lt(e,n))}var Vt=e=>`disabled`in e&&e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`,Ht=e=>{(0,t.elementOf)(e,HTMLElement,`data-wui-confirm needs an HTML element to click.`).click()};function Ut(e){let n=(0,t.closestOf)(e.target,`[data-wui-confirm]:not(form)`);n&&n!==At&&!Vt(n)&&(e.preventDefault(),e.stopImmediatePropagation(),Ft(n,()=>Lt(n,()=>Ht(n))))}function Wt(e){let t=e.target;if(!(t instanceof HTMLFormElement)||!t.hasAttribute(`data-wui-confirm`)||t===At||e.submitter&&e.submitter===At||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;Ft(t,()=>Lt(t,()=>t.requestSubmit(r)))}function Gt(e){let n=(0,t.closestOf)(e.target,`#${W} [data-app-confirm]`);n&&!n.hasAttribute(`disabled`)&&jt&&(Mt=!0,(0,t.must)(n.closest(`wui-modal`),`#${W} is missing around its confirm button.`).hide())}function Kt(e){if(!(e.target instanceof Element)||e.target.id!==`wuiConfirm`)return;let t=Mt?jt:null;jt=null,Mt=!1,t?.()}var qt=e=>e===`forbidden`?G().forbiddenMessage:e===`networkCheck`?(0,r.readText)(`httpFailure`,s.HTTP_FAILURE_TEXT).networkCheckText:e===`network`?G().networkMessage:e===`timeout`?G().timeoutMessage:G().failedMessage,Jt=(e,t)=>{`disabled`in e&&(e.disabled=t)},Yt=e=>{Jt(e,!1),e.removeAttribute(`aria-busy`)};async function Xt(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 Zt(t,e)}async function Zt(e,t,n){Jt(t,!0),t.setAttribute(`aria-busy`,`true`);let r=(0,h.timeoutFromAttribute)(t.getAttribute(`data-wui-timeout`))??h.DEFAULT_TIMEOUT_MS,i=await(0,h.wuiFetch)(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)(0,c.storeFlash)(i.message,a,i.toastAction),window.location.assign(i.redirect);else if(i.ok){let e=(0,u.isRefreshOff)(t);if(!e&&(0,u.reloadsPage)(i)){await(0,u.refreshAfter)(i,{origin:t})===`held`&&Yt(t);return}Yt(t),(0,ee.showResultToast)(i,a),e||await(0,u.refreshAfter)(i,{origin:t})}else Yt(t),Nt(i.message||qt(i.kind),`danger`)}var Qt=e=>typeof e!=`object`||!e||!(`code`in e)?null:typeof e.code==`string`?e.code:null,$t=e=>(e.response?.headers.get(`Content-Type`)??``).toLowerCase().includes(`json`)?e.data:e.html===``?null:e.html;async function en(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(!te.TOAST_ACTION_METHODS.includes(n))throw TypeError(`postAction method must be POST, PUT, PATCH or DELETE.`);let r=t.timeoutMs??h.DEFAULT_TIMEOUT_MS;if(!Number.isInteger(r)||r<0)throw TypeError(`postAction timeoutMs must be a whole number of milliseconds, 0 for no limit.`);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 s;try{s=await(0,h.wuiFetch)(e,{method:n,body:a,headers:i,timeoutMs:r})}catch(e){throw(0,o.devError)(e),e}if(s.kind===`session`||s.kind===`aborted`)throw new l.WuiPostError(qt(s.kind),{code:null,status:s.status,html:null,body:null,kind:s.kind});let d=t.toast!==!1,f=t.refresh!==!1,p=s.toastVariant||`success`;if(s.ok){if(s.redirect)(0,c.storeFlash)(d?s.message:null,p,d?s.toastAction:null),window.location.assign(s.redirect);else{let e=(0,u.planOf)(s);d&&!(f&&(0,u.reloadsPage)(s))&&(0,ee.showResultToast)(s,p),e!==null&&f&&await(0,u.applyPlan)({...e,message:d?e.message:null,action:d?e.action:null})}return $t(s)}let m;try{m=await le(s)}catch(e){(0,o.devError)(e);let t=s.message||qt(s.kind);throw Nt(t,`danger`),new l.WuiPostError(t,{code:null,status:s.status,html:null,body:null,kind:s.kind,cause:e})}let g=(s.response?.headers.get(`Content-Type`)??``).toLowerCase(),_=null;if(g.includes(`json`))try{_=JSON.parse(m)}catch{_=null}let v=S(_,s.response?.statusText??``)||s.message||qt(s.kind),y=g.includes(`text/html`)?m:null;throw(s.kind!==`validation`||y===null)&&Nt(v,`danger`),new l.WuiPostError(v,{code:Qt(_),status:s.status,html:y,body:_,kind:s.kind})}function tn(e,t){Jt(e,!1),e.removeAttribute(`aria-busy`),(0,o.devError)(t),Nt(G().failedMessage,`danger`)}function nn(e){let n=(0,t.closestOf)(e.target,`[data-wui-post]`);n&&(e.preventDefault(),Vt(n)||n.getAttribute(`aria-busy`)===`true`||Xt(n).catch(e=>tn(n,e)))}function rn(e){let n=(0,t.closestOf)(e.target,`form[data-wui-post-form]`);if(!(n instanceof HTMLFormElement)||e.defaultPrevented)return;e.preventDefault();let r=(0,t.must)(e.submitter||n.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((0,t.must)(n.getAttribute(`action`),`A data-wui-post-form needs an action attribute to post to.`),document.baseURI).href;Zt(i,r,new FormData(n)).catch(e=>tn(r,e)),n.closest(`wui-dropdown`)?.hide()}var an=(e,t)=>{e.disabled=!1,e.removeAttribute(`aria-busy`),t&&(0,a.setRowSaveState)(t,null)};async function on(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&&(0,a.setRowSaveState)(t,`saving`);let r=(0,h.timeoutFromAttribute)(e.getAttribute(`data-wui-timeout`))??h.DEFAULT_TIMEOUT_MS,i=await(0,h.wuiFetch)(n,{method:(e.dataset.method||`post`).toUpperCase(),timeoutMs:r});if(i.kind===`session`)return;if(i.kind===`aborted`){an(e,t);return}let o=i.toastVariant||`success`;if(i.ok&&i.redirect){(0,c.storeFlash)(i.message,o,i.toastAction),window.location.assign(i.redirect);return}if(i.ok){let n=(0,u.planOf)(i);if((0,u.isRefreshOff)(e)||n===null||(0,u.refreshesNothing)(n)){an(e,t),(0,ee.showResultToast)(i,o);return}if((0,u.holdInDialog)({...n,reload:`page`},e)){an(e,t);return}(0,c.storeFlash)(i.message,o,i.toastAction),(0,u.reloadPage)();return}let s=i.message||qt(i.kind);e.disabled=!1,e.removeAttribute(`aria-busy`),t&&(0,a.setRowSaveState)(t,`error`,s),Nt(s,`danger`)}var sn=new WeakSet;function cn(e){let n=(0,t.closestOf)(e.target,`[data-wui-row-action]`);if(!n||n.closest(`[data-wui-server]`))return;if(!(n instanceof HTMLButtonElement)){if(sn.has(n))return;sn.add(n),(0,o.devError)(Error(`A [data-wui-row-action] element must be a button with data-url, so its click does nothing: ${n.getAttribute(`data-wui-row-action`)??``}`));return}if(e.preventDefault(),n.disabled||n.getAttribute(`aria-busy`)===`true`)return;let r=n.closest(`tr`);on(n,r).catch(e=>{an(n,r),(0,o.devError)(e),Nt(G().failedMessage,`danger`)})}var ln=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.form:null;function un(e){if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-wui-auto-submit]`);if(!t)return;let n=ln(e.target)||t.closest(`form`);n instanceof HTMLFormElement&&n.requestSubmit()}function dn(e){kt.has(e)||(kt.add(e),e.addEventListener(`click`,Gt),e.addEventListener(`wui-modal-closed`,Kt))}function fn(e=document){let t=e instanceof Element?e.ownerDocument:e;Ot.has(t)||(Ot.add(t),t.addEventListener(`click`,Ut,!0),t.addEventListener(`submit`,Wt,!0),dn(t),t.addEventListener(`click`,nn),t.addEventListener(`click`,cn),t.addEventListener(`submit`,rn),t.addEventListener(`change`,un))}var pn=()=>(0,r.readText)(`unsavedChanges`,b),mn=`form[data-wui-unsaved]`,hn=`[aria-invalid="true"], .field-error:not(:empty), .field-validation-error, .validation-summary-errors, .wui-error-summary`,gn=`[download], [data-wui-modal], [data-wui-post], [data-bs-toggle]`,_n=new Set([`submit`,`button`,`reset`,`image`]),vn=new Set([`hidden`,`checkbox`,`radio`,`file`,`submit`,`button`,`reset`,`image`,`range`,`color`]),yn=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,bn=e=>yn(e)?e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled:`disabled`in e&&!!e.disabled,xn=e=>`name`in e&&typeof e.name==`string`&&e.name!==``,Sn=e=>typeof e==`object`&&!!e,Cn=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&typeof e[0]==`string`);function wn(e){let t=JSON.parse(e);if(!Cn(t))throw Error(`unsaved-changes snapshot is malformed`);return t}var K=new WeakMap,Tn=new WeakSet,En=e=>`${e.name}:${e.size}:${e.lastModified}`,Dn=e=>[...e.querySelectorAll(mn)].filter(e=>e instanceof HTMLFormElement);function q(e){let t=[];for(let n of e.elements)xn(n)&&!bn(n)&&(yn(n)&&_n.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(En)]):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 On(e){return q(e)}function kn(e,t){let n=new Map,r=wn(t);for(let e of r){let t=n.get(e[0]);t?t.push(e):n.set(e[0],[e])}let i=wn(q(e)).map(e=>n.get(e[0])?.shift()??e);for(let e of n.values())i.push(...e);return JSON.stringify(i)}function An(e){for(let t of e.elements)if(yn(t)&&t.name&&!bn(t)){if(t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement&&!vn.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 jn=e=>({saved:e.querySelector(hn)&&An(e)?null:q(e),engaged:!1,discarded:!1});function Mn(e){let t=K.get(e);return!t||t.discarded||!e.isConnected?!1:t.saved===null||t.engaged&&q(e)!==t.saved}var Nn=(e,t)=>Dn(e).filter(e=>e!==t&&Mn(e));function Pn(e,t,n){let r=t.map(e=>e.getAttribute(`data-wui-unsaved`)).find(Boolean)||pn().message;Bt(e,{title:pn().title,message:r,label:pn().leaveLabel,cancel:pn().keepLabel,icon:`warning`,tone:`danger`},()=>{for(let e of t){let t=K.get(e);t&&(t.discarded=!0)}n()})}function Fn(e){if(e.matches(gn))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 In(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 Ln(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let n=e.target,r=(0,t.closestOf)(n,`a[href]`);if(!(r instanceof HTMLAnchorElement)||!Fn(r))return;let i=Nn(r.ownerDocument,null);i.length&&(e.preventDefault(),Pn(r,i,()=>r.click()))}function Rn(e){let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented||!In(t,e.submitter))return;let n=Nn(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;Pn(t,n,()=>t.requestSubmit(i));return}let r=K.get(t);r&&(r.saved=q(t),r.discarded=!1)}function zn(e){Nn(document,null).length&&e.preventDefault()}function Bn(e){let n=e.target,r=(0,t.closestOf)(n,mn);return r instanceof HTMLFormElement?r:null}function Vn(e){let t=Bn(e);if(!t)return;let n=K.get(t);n&&!n.engaged&&(n.saved!==null&&(n.saved=q(t)),n.engaged=!0)}function Hn(e){let t=Bn(e),n=t&&K.get(t);n&&(n.discarded=!1,e.isTrusted&&(n.engaged=!0))}function Un(e){for(let t of Dn(e)){let e=K.get(t);e?.saved&&(e.saved=kn(t,e.saved))}}function Wn(e){let t=Sn(e)?e.handle:void 0;return Sn(t)?t.el:void 0}function Gn(e){if(!(e instanceof CustomEvent))return;let t=Wn(e.detail);if(t instanceof Element)for(let e of Dn(t))qn(e)}function Kn(e=document){let r=e instanceof Document?e:e.ownerDocument;if(!Tn.has(r)){Tn.add(r);for(let e of[`focusin`,`pointerdown`,`drop`])r.addEventListener(e,Vn,!0);for(let e of[`input`,`change`])r.addEventListener(e,Hn,!0);r.addEventListener(`click`,Ln),r.addEventListener(`submit`,Rn),r.addEventListener(`wui:modal:success`,Gn),r.addEventListener(n.ELEMENTS_DEFINED_EVENT,()=>Un(r)),(0,t.must)(r.defaultView,`unsaved-changes guard needs a document with a window`).addEventListener(`beforeunload`,zn)}let i=Dn(e);e instanceof HTMLFormElement&&e.matches(mn)&&i.unshift(e);for(let e of i)K.has(e)||K.set(e,jn(e))}function qn(e){if(!(e instanceof HTMLFormElement)||!e.matches(mn))throw TypeError(`resetUnsavedChanges: ${String(e)} is not a <form data-wui-unsaved>.`);K.set(e,{saved:q(e),engaged:!1,discarded:!1})}var Jn=()=>(0,r.readText)(`drawer`,i.DRAWER_TEXT),Yn=`wui:drawer:discard`,Xn=`wui-drawer[confirm-discard]`,Zn=`wui-modal`,Qn=`data-wui-no-discard`,$n=`.wui-drawer-discard`,er=`input, select, textarea`,tr=e=>typeof e==`object`&&!!e||typeof e==`function`;function nr(e){let t=e.currentTarget;if(!(t instanceof Document))throw Error(`The discard guard is not wired on a document.`);return t}function rr(e,n){return(0,t.closestOf)(e,n)}var ir=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement,J=new WeakMap,ar=new WeakSet,or=new WeakSet;function sr(t,n,r,i,a){let o=t.createElement(`button`);return o.type=`button`,o.className=(0,e.buttonClass)(n,r,`sm`),o.dataset.wui=e.APP_BUTTON_MARKER,o.setAttribute(i,``),o.textContent=a,o}function cr(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,sr(e,`danger`,`solid`,`data-wui-discard-confirm`,Jn().discardLabel),sr(e,`primary`,`soft`,`data-wui-discard-keep`,Jn().keepLabel)),n}function lr(e){if(!(e instanceof Element))return null;let t=e.closest(Xn);if(t)return t;let n=e.closest(Zn);return n&&fr(n).length?n:null}function ur(e){return e.closest(Xn)??e.closest(Zn)}function dr(e,t){return t.hasAttribute(Qn)||e.hasAttribute(Qn)?!1:t.hasAttribute(`confirm-discard`)||e.hasAttribute(`data-wui-confirm-discard`)?!0:(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`}function fr(e){return e.matches(Xn)?e.querySelectorAll(`form`):[...e.querySelectorAll(`form`)].filter(t=>dr(t,e))}function pr(e){let t=J.get(e);return t!=null&&On(e)!==t}function mr(e){let n=e.ownerDocument.createElement(`div`);return n.className=`wui-drawer-footer`,(0,t.must)(e.querySelector(`.wui-drawer-panel`),`The drawer has no panel to hold its footer.`).append(n),or.add(n),n}function hr(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 gr(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 _r(e,t,n){let r=e.querySelector($n);if(r){gr(r);return}let i=cr(e.ownerDocument,t),a;if(e.matches(Xn))a=e.querySelector(`.wui-drawer-footer`)??mr(e),a.prepend(i);else if(e.hasAttribute(`confirm-discard`))a=e.querySelector(`.wui-modal-footer`)??hr(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`)??hr(e),a.prepend(i)}a.classList.add(`wui-drawer-discarding`),gr(i)}function vr(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 yr(e){for(let t of fr(e))for(let e of t.querySelectorAll(er))if(ir(e)&&e.type!==`hidden`&&!e.disabled){e.focus({preventScroll:!0});return}}function br(e){let t=lr(e.target);if(t)for(let e of fr(t))J.get(e)??J.set(e,On(e))}function xr(e){for(let t of nr(e).querySelectorAll(`form`)){let e=J.get(t);e!=null&&J.set(t,kn(t,e))}}function Sr(e){let t=e.target;t instanceof HTMLFormElement&&lr(t)&&J.set(t,On(t))}function Cr(e){if(!tr(e))return;let t=`handle`in e?e.handle:void 0;if(tr(t))return`el`in t?t.el:void 0}function wr(e){if(!(e instanceof CustomEvent))return;let t=e.detail,n=Cr(t);if(n instanceof Element)for(let e of n.querySelectorAll(`form`))J.delete(e)}function Tr(e){let t=e.target;t instanceof Element&&t.matches(Xn)&&[...fr(t)].some(pr)&&(e.preventDefault(),_r(t,t.getAttribute(`confirm-discard`),null))}function Er(e){let t=e.target;if(!(t instanceof Element)||!t.matches(Zn))return;let n=[...fr(t)].find(pr);n&&(e.preventDefault(),_r(t,n.getAttribute(`data-wui-confirm-discard`)??t.getAttribute(`confirm-discard`)??Jn().confirmDiscard,n))}function Dr(e){let n=(0,t.must)(e.closest($n),`The discard button is outside its prompt.`),r=ur(n);if(vr(n),!r)throw Error(`The discard prompt is outside its drawer or modal.`);for(let e of fr(r))J.set(e,On(e));r.dispatchEvent(new CustomEvent(Yn,{bubbles:!0})),r.matches(Xn)?(0,t.must)(r.closest(`wui-drawer`),`The confirm-discard drawer is not a wui-drawer.`).hide():(0,t.must)(r.closest(`wui-modal`),`The discarded dialog is not a wui-modal.`).hide()}function Or(e){let n=(0,t.must)(e.closest($n),`The keep button is outside its prompt.`),r=ur(n);if(vr(n),!r)throw Error(`The discard prompt is outside its drawer or modal.`);yr(r)}function kr(e){let t=rr(e.target,`[data-wui-discard-confirm]`);if(t){Dr(t);return}let n=rr(e.target,`[data-wui-discard-keep]`);n&&Or(n)}function Ar(e=document){let t=e instanceof Document?e:e.ownerDocument;ar.has(t)||(ar.add(t),t.addEventListener(`focusin`,br),t.addEventListener(`pointerdown`,br),t.addEventListener(`submit`,Sr),t.addEventListener(n.ELEMENTS_DEFINED_EVENT,xr),t.addEventListener(`wui:modal:success`,wr),t.addEventListener(`wui:modal:loaded`,wr),t.addEventListener(`wui-drawer-close`,Tr,!0),t.addEventListener(`wui-modal-close`,Er),t.addEventListener(`click`,kr))}var jr=Object.freeze([`page`,`pageSize`,`sortBy`,`sortOrder`,`search`]),Mr=`search`,Y=()=>(0,r.readText)(`dataTable`,v.DATA_TABLE_TEXT),Nr=5,Pr=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,Fr=e=>e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled,Ir=e=>Pr(e)&&`type`in e&&e.type===`hidden`,X=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),Z=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},Q=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Lr=e=>e.localName===`wui-select`,$=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},Rr=e=>({total:$(e.dataset.total,0),totalCapped:e.dataset.totalCapped===`true`,page:$(e.dataset.page,1),pageSize:$(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`,pending:e.dataset.totalPending===`true`,rowCount:$(e.dataset.rowCount,0)}),zr=(e,t)=>{e&&(0,m.wuiHost)().toast(e,{variant:t})},Br=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>!Ir(e)||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!jr.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of X(e,`[data-wui-filter-clear]`,HTMLElement))t.hidden=!r},Vr=new Intl.NumberFormat(`en-IN`),Hr=(e,t)=>t?`${Vr.format(e)}+`:Vr.format(e),Ur=(e,t,n)=>{let r=e.closest(`.wui-list-card`),i=r?Z(r,`.wui-list-card-count`,HTMLElement):null;i&&(i.textContent=Hr(t,n))};function Wr(e=document){let t=X(e,`[data-wui-server]`,HTMLElement);e instanceof HTMLElement&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t){if((0,y.isServerTableWired)(e))continue;let t=Gr(e);(0,y.registerServerTable)(e,t),e.hasAttribute(`data-load-first-page`)&&t.reload()}}function Gr(n){let i=Z(n,`.table-wrap`,HTMLElement),c=i?Z(i,`:scope > table`,HTMLTableElement):null,l=n.dataset.src;if(!i||!c||!l)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let d=Z(i,`:scope > [data-wui-table-state]`,HTMLElement),f=Z(n,`[data-wui-table-pager]`,HTMLElement),te=Z(n,`[data-wui-table-status]`,HTMLElement),v={urlState:n.dataset.urlState!==`false`,filtersForm:n.dataset.filtersForm||null,filtersRegion:n.dataset.filtersRegion||null,searchInput:n.dataset.searchInput||null,loadingText:n.dataset.loadingText||Y().loadingText,errorText:n.dataset.errorText||Y().errorText,timeoutMs:(0,h.timeoutFromAttribute)(n.getAttribute(`data-wui-timeout`))??h.DEFAULT_TIMEOUT_MS},y=new URL(l,window.location.href),ne=n.dataset.totalSrc||null,re=ne===null?null:new URL(ne,window.location.href),ie=new Set([...y.searchParams.keys(),...re?.searchParams.keys()??[]]),ae=c.hasAttribute(`data-app-datatable-selectable`),b=new Set,x=!1,oe=(0,h.createRequestQueue)(),se=new AbortController,ce={signal:se.signal},le=Z(c,`:scope > tbody[data-wui-rows]`,HTMLTableSectionElement),S=(0,t.must)(le,`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`),C=Rr(S),ue=null,w=null,de=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))ie.has(n)||t.append(n,r);return t},fe=e=>de(new URL(e,window.location.href).search),T=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},E=(e,t)=>{let n=new URL(e.href);for(let[e,r]of t)ie.has(e)||n.searchParams.append(e,r);return n.origin===window.location.origin?`${n.pathname}${n.search}`:n.href},pe=e=>E(y,e),me=(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},D=me(v.urlState?de(window.location.search):new URLSearchParams,C);v.urlState&&T(D)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,T(D));let O=(e,t)=>i.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),k=e=>{te&&(te.textContent=e)},he=e=>{if(e.pending)return e.rowCount===0?Y().emptyLabel:(0,r.fillText)(Y().pageTextPending,{page:e.page});if(e.total===0)return Y().emptyLabel;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1,n=e.totalCapped?Hr(e.total,!0):`${e.total}`;return(0,r.fillText)(e.total===1?Y().pageTextOne:Y().pageTextOther,{page:e.page,pages:t,total:n})},A=()=>X(c,`:scope > thead > tr:first-child > th`,HTMLTableCellElement),ge=e=>{if(ae&&X(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.`)},_e=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`)}},j=e=>{if(ae){(0,_.addRowSelectCells)(e);for(let t of e){let e=Z(t,`.${_.SELECT_CELL_CLASS} .form-check-input:not(:disabled)`,HTMLInputElement);e&&(x&&b.add(t.dataset.rowKey),e.checked=b.has(t.dataset.rowKey))}(0,_.syncSelectAll)(c)}_e(e);let t=A();if(c.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`)})},ve=e=>j(X(e,`:scope > tr`,HTMLTableRowElement)),M=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},N=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),ye=(e,t)=>{if(!d)return;let n=Z(e,`:scope > template[data-wui-empty]`,HTMLTemplateElement);N(d),(t.pending?t.rowCount:t.total)===0&&n?(d.replaceChildren(n.content.cloneNode(!0)),d.hidden=!1):(d.replaceChildren(),d.hidden=!0)},be=e=>{f&&(N(f),f.replaceChildren(...e?[e.content.cloneNode(!0)]:[]),f.hidden=!1)},xe=e=>{let t=v.filtersRegion&&e?Z(document,v.filtersRegion,HTMLElement):null;return t&&e&&(N(t),t.replaceChildren(e.content.cloneNode(!0))),t},Se=0,Ce=e=>{let t=Rr(e);t.pending&&Object.assign(t,{total:C.total,totalCapped:C.totalCapped});let n=t.sortBy!==C.sortBy||t.sortOrder!==C.sortOrder?(0,a.measureRows)(S.rows):null;be(Z(e,`:scope > template[data-wui-pager]`,HTMLTemplateElement)),ye(e,t);let r=xe(Z(e,`:scope > template[data-wui-filters]`,HTMLTemplateElement));M(e),N(S),c.replaceChild(e,S),S=e,Se+=1;let o=x&&t.total!==C.total;return C=t,o&&(x=!1),i.removeAttribute(`data-wui-table-error`),ve(e),Ie(),(0,a.playRowMoves)(e.rows,n),o&&L(),r},we=e=>{let t=Z((0,p.parseServerHtml)(`<table>${e}</table>`),`tbody[data-wui-rows]`,HTMLTableSectionElement);return t&&ge(t),t?document.importNode(t,!0):null},Te=(e,t=A())=>{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},Ee=()=>{if(S.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,A().length);S.replaceChildren(...Array.from({length:Nr},()=>{let t=Te(e);return t.setAttribute(`data-wui-skeleton`,``),t})),i.removeAttribute(`data-wui-table-error`),d&&(d.hidden=!0)},De=e=>{e?(i.setAttribute(`aria-busy`,`true`),Ee()):i.removeAttribute(`aria-busy`)},P=e=>e===`forbidden`?Y().forbiddenMessage:e===`networkCheck`?(0,r.readText)(`httpFailure`,s.HTTP_FAILURE_TEXT).networkCheckText:e===`network`?Y().networkMessage:e===`timeout`?Y().timeoutMessage:v.errorText,Oe=t=>{let n=P(t);if(i.setAttribute(`data-wui-table-error`,t),f&&(f.hidden=!0),d){let r=document.createElement(`div`);r.className=`empty-state wui-empty-state-table wui-table-error`,r.setAttribute(`role`,`alert`);let i=document.createElement(`span`);i.className=`empty-state-icon`;let a=(0,g.glyphNode)(t===`forbidden`?`lock`:`alert-circle`,{size:24});a&&i.replaceChildren(a);let o=document.createElement(`div`);o.className=`empty-state-title`,o.textContent=n;let s=document.createElement(`div`);s.className=`empty-state-action`;let c=document.createElement(`button`);c.type=`button`,c.className=(0,e.buttonClass)(`primary`,`outline`,`sm`),c.dataset.wui=e.APP_BUTTON_MARKER,c.setAttribute(`data-wui-table-retry`,``),c.textContent=Y().retryLabel,s.append(c),r.append(i,o,s),N(d),d.replaceChildren(r),d.hidden=!1}k(n)},ke=()=>v.filtersForm?Z(document,v.filtersForm,HTMLFormElement):null,Ae=async(e,t=`none`,{quiet:r=!1}={})=>{let a=new URLSearchParams(e);r||(ue={query:a,mode:t},De(!0),k(v.loadingText)),O(`wui:table:loading`,{query:a.toString()});let s=await oe.run(pe(a),{timeoutMs:v.timeoutMs});if(s.kind===`aborted`||s.kind===`stale`||s.kind===`session`)return s;r||De(!1);let c=null;if(s.ok)try{c=we(s.html)}catch(e){(0,o.devError)(e)}if(!s.ok||!c){let e=s.ok?`server`:s.kind;return r?(0,o.devWarn)(`A quiet server table refresh failed; the rows on screen are kept.`,e):Oe(e),O(`wui:table:error`,{status:s.status,kind:e,message:P(e)}),s}let l=Ce(c);return D=me(a,C),Br(ke(),D),v.urlState&&t===`push`?window.history.pushState(window.history.state,``,T(D)):v.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,T(D)),r||k(he(C)),(0,m.wuiHost)().refresh(i),l&&(0,m.wuiHost)().refresh(l),C.pending?Pe():Ur(n,C.total,C.totalCapped),O(`wui:table:loaded`,{...C,query:D.toString()}),s},F=[],je=null,Me=()=>{if(F.length===0||i.getAttribute(`aria-busy`)===`true`)return;let e=F;F=[],Ae(D,`none`,{quiet:!0}).then(t=>{for(let n of e)n.resolve(t)},t=>{for(let n of e)n.reject(t)})},I=async(e,t=`none`,n={})=>{let r;try{r=await Ae(e,t,n)}catch(e){let t=F;F=[];for(let n of t)n.reject(e);throw e}r.kind===`session`&&(je=r);let a=r.kind===`aborted`&&i.getAttribute(`aria-busy`)===`true`;if(r.kind===`session`||r.kind===`aborted`&&!a){let e=F;F=[];for(let t of e)t.resolve(r)}return Me(),r},Ne=e=>(e.delete(`page`),e),Pe=()=>{if(!re||!C.pending)return;let e=Se;(0,h.wuiFetch)(E(re,D),{timeoutMs:v.timeoutMs}).then(t=>{if(e!==Se)return;if(!t.ok){(0,o.devWarn)(`[@webority/ui-elements] A server table's total did not load; its pager keeps Previous and Next.`,t.kind);return}let r=Z((0,p.parseServerHtml)(t.html),`div[data-wui-total]`,HTMLElement);if(!r){(0,o.devWarn)(`[@webority/ui-elements] A server table's count answer has no div[data-wui-total]; its pager keeps Previous and Next.`);return}if($(r.dataset.page,-1)!==C.page||$(r.dataset.pageSize,-1)!==C.pageSize)return;let i=$(r.dataset.total,-1);if(i<0){(0,o.devWarn)(`[@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=x&&i!==C.total;C={...C,total:i,totalCapped:a,pending:!1},s&&(x=!1);let c=Z(r,`:scope > template[data-wui-pager]`,HTMLTemplateElement);c&&be(c);let l=xe(Z(r,`:scope > template[data-wui-filters]`,HTMLTemplateElement));l&&(0,m.wuiHost)().refresh(l),Ur(n,C.total,C.totalCapped),k(he(C)),s&&L(),O(`wui:table:total`,{total:i,totalCapped:a})})},Fe=()=>X(c,`:scope > thead th[data-sort-key]`,HTMLTableCellElement),Ie=()=>{for(let e of Fe()){let t=e.dataset.sortKey===C.sortBy;e.setAttribute(`aria-sort`,t?C.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of Fe())if(e.classList.add(`sortable`),e.tabIndex=0,!e.querySelector(`.sort-icon`)){let t=e.classList.contains(`num`)||e.classList.contains(`text-end`),n=document.createElement(`span`);n.className=t?`sort-icon wui-sort-lead`:`sort-icon`;let r=(0,g.glyphNode)(`chevrons-up-down`,{size:14});r&&n.replaceChildren(r),t?e.prepend(n):e.append(n)}let Le=e=>{let t=Ne(new URLSearchParams(D)),n=C.sortBy===e&&C.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),I(t,`push`)};c.addEventListener(`click`,e=>{let t=e.target instanceof Element?Q(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&c.tHead?.contains(t)&&Le(t.dataset.sortKey??``)}),c.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof Element?Q(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&c.tHead?.contains(t)&&(e.preventDefault(),Le(t.dataset.sortKey??``))});let L=()=>{(0,_.syncSelectAll)(c),(0,_.syncGroupSelect)(c);let e=x?{selected:C.total,total:C.total,allMatching:x}:{selected:b.size,total:C.total};c.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};ae&&((0,_.attachShiftRange)(c,(e,t)=>{for(let n of e){let e=Q(n,`tr`,HTMLTableRowElement)?.dataset.rowKey;e&&(t?b.add(e):b.delete(e))}t||(x=!1)}),c.addEventListener(`change`,e=>{let t=e.target;if(t instanceof HTMLInputElement&&t.matches(`.${_.SELECT_CELL_CLASS} .form-check-input:not(:disabled)`)){if(t.checked||(x=!1),c.tHead?.contains(t))for(let e of X(S,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let n=Z(e,`.${_.SELECT_CELL_CLASS} .form-check-input:not(:disabled)`,HTMLInputElement);n&&(n.checked=t.checked,t.checked?b.add(e.dataset.rowKey):b.delete(e.dataset.rowKey))}else if(Q(t,`tr`,HTMLTableRowElement)?.classList.contains(`wui-group-row`)){let e=Q(t,`tr`,HTMLTableRowElement);for(let n=e?.nextElementSibling;n instanceof HTMLTableRowElement&&!n.matches(`tr.wui-group-row`);n=n.nextElementSibling){let e=Z(n,`.${_.SELECT_CELL_CLASS} .form-check-input:not(:disabled)`,HTMLInputElement),r=n.dataset.rowKey;e&&r&&(e.checked=t.checked,t.checked?b.add(r):b.delete(r))}}else{let e=Q(t,`tr`,HTMLTableRowElement)?.dataset.rowKey;if(!e)return;t.checked?b.add(e):b.delete(e)}L()}})),f&&(f.addEventListener(`click`,e=>{let t=e.target instanceof Element?Q(e.target,`a[href]`,HTMLAnchorElement):null;!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),I(fe(t.getAttribute(`href`)??``),`push`))}),f.addEventListener(`change`,e=>{let t=e.target;t instanceof HTMLSelectElement&&t.classList.contains(`tpg-select`)&&t.value&&(e.stopPropagation(),I(fe(t.value),`push`))}));let R=()=>{if(!v.searchInput)return null;let e=Z(document,v.searchInput,HTMLElement);return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:e?Z(e,`input`,HTMLInputElement):null},z=()=>n.isConnected?!0:(se.abort(),clearTimeout(w??void 0),!1),B=(e,t)=>{let n=[...e.elements].filter(Pr),r=new Set;for(let e of n)e.name&&!Ir(e)&&r.add(e.name);let i=[];for(let e of n)if(e.name&&!Fr(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},Re=(e,t)=>{let n=new Set([...e.elements].filter(Pr).map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&jr.includes(e);for(let[e,t]of D)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of B(e,t))a===``||i(n)||ie.has(n)||r.append(n,a);let a=R();if(a){r.delete(Mr);let e=a.value.trim();e&&r.set(Mr,e)}return I(r,`push`)},ze=e=>v.filtersForm&&e.closest?.(v.filtersForm)||v.filtersRegion&&e.closest?.(v.filtersRegion)||null;document.addEventListener(`submit`,e=>{z()&&v.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(v.filtersForm)&&(e.preventDefault(),Re(e.target,e.submitter))},ce),document.addEventListener(`change`,e=>{if(!z()||!v.filtersForm||!(e.target instanceof Element))return;let t=Q(e.target,v.filtersForm,HTMLFormElement);!t||e.target===R()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest(`wui-filter-popover`)||Re(t)},ce);let Be=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of X(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 X(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(Lr)){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(!z())return;let t=e.target instanceof Element?Q(e.target,`a[href]`,HTMLAnchorElement):null;if(!t||!ze(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=Ne(fe(n.href));Be(t.closest(`form`),r),Br(t.closest(`form`),r),I(r,`push`)},ce),document.addEventListener(`input`,e=>{if(!z())return;let t=R();t&&e.target===t&&(clearTimeout(w??void 0),w=setTimeout(()=>{if(!z())return;let e=Ne(new URLSearchParams(D)),n=t.value.trim();n?e.set(Mr,n):e.delete(Mr),e.toString()!==D.toString()&&I(e,`replace`)},300))},ce),v.urlState&&window.addEventListener(`popstate`,()=>{if(!z())return;let e=de(window.location.search),t=R();t&&(t.value=e.get(`search`)??``),Br(ke(),e),I(e,`none`)},ce),d?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`[data-wui-table-retry]`)&&ue&&I(ue.query,ue.mode)});let Ve=e=>[...S.rows].find(t=>t.dataset.rowKey===e)??null,He=e=>{if(!e?.trim())return null;let t=(0,p.parseServerHtml)(`<table><tbody>${e}</tbody></table>`);if(t.querySelector(`tbody[data-wui-rows]`))return null;let n=X(t,`table > tbody > tr[data-row-key]`,HTMLTableRowElement);return n.length?n.map(e=>document.importNode(e,!0)):null},Ue=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let a=[];for(let n of e){let e=n===r?t:Ve(n.dataset.rowKey);e&&(N(e),e.replaceWith(n),a.push(n))}return j(a),(0,m.wuiHost)().refresh(i),r},We=e=>e.message||(e.kind===`forbidden`?Y().actionForbiddenMessage:Y().actionFailedMessage),V=e=>{e?.isConnected&&e.getAttribute(a.ROW_SAVE_ATTR)===`saving`&&(0,a.setRowSaveState)(e,null)},H=async({url:e,method:r=`POST`,body:o,key:s,row:c}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let l=s==null,f=l?null:Ve(String(s));if(!l&&!f)throw Error(`saveRow found no row with data-row-key="${s}" on this page.`);let p=A().filter(e=>!e.classList.contains(_.SELECT_CELL_CLASS)),m=c===void 0?f??Te(Math.max(1,p.length),p):(0,t.elementOf)(c,HTMLTableRowElement,"saveRow's `row` is required to be a row element: the <tr> as it will read, not its HTML.");f&&m!==f?f.replaceWith(m):f||S.insertBefore(m,S.firstChild),m!==f&&j([m]),d&&!i.hasAttribute(`data-wui-table-error`)&&(d.hidden=!0),(0,a.setRowSaveState)(m,`saving`);let te=(0,a.rowLabel)(m),g=await(0,h.wuiFetch)(e,{method:r.toUpperCase(),body:o});if(g.kind===`session`)return!1;if(g.ok){if(!(0,u.isRefreshOff)(n)&&(0,u.reloadsPage)(g))return V(m),O(`wui:table:saved`,{key:l?null:String(s),added:l,status:g.status}),await(0,u.refreshAfter)(g,{origin:n}),!0;let e=He(g.html),t=e&&m.isConnected?Ue(e,m,l):null;return t&&k((0,a.savedText)((0,a.rowLabel)(t)||te)),(0,ee.showResultToast)(g,g.toastVariant||`success`),(0,u.isRefreshOff)(n)||await(0,u.refreshAfter)(g,{skip:t?n:null,origin:n}),V(m),O(`wui:table:saved`,{key:t?.dataset.rowKey??(l?null:String(s)),added:l,status:g.status}),!0}let v=We(g),y=m;return f&&m!==f&&m.isConnected?(m.replaceWith(f),y=f):l&&!c&&(m.remove(),y=null,d?.childElementCount&&!S.querySelector(`:scope > tr`)&&(d.hidden=!1)),y?.isConnected&&(0,a.setRowSaveState)(y,`error`,v),g.kind!==`aborted`&&zr(v,`danger`),k((0,a.notSavedText)(te,v)),O(`wui:table:failed`,{key:l?null:String(s),added:l,status:g.status,kind:g.kind,message:v}),!1},Ge=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=Q(e,`tr`,HTMLTableRowElement),i=r?.dataset.rowKey??null,o=e.dataset.wuiRowAction||``,s=r?(0,a.rowLabel)(r):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),r&&(0,a.setRowSaveState)(r,`saving`);let c=await(0,h.wuiFetch)(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),c.kind===`session`||c.kind===`aborted`)V(r);else if(c.ok&&!(0,u.isRefreshOff)(e)&&(0,u.reloadsPage)(c))V(r),O(`wui:table:action`,{action:o,key:i,ok:c.ok,status:c.status}),await(0,u.refreshAfter)(c,{origin:e});else{if(c.ok){(0,ee.showResultToast)(c,c.toastVariant||`success`);let t=r?.isConnected?He(c.html):null,i=t&&r?Ue(t,r,!1):null;i&&k((0,a.savedText)((0,a.rowLabel)(i)||s)),(0,u.isRefreshOff)(e)||await(0,u.refreshAfter)(c,{skip:i?n:null,origin:e}),V(r)}else{let e=We(c);zr(e,`danger`),r?.isConnected&&(0,a.setRowSaveState)(r,`error`,e),k((0,a.notSavedText)(s,e))}O(`wui:table:action`,{action:o,key:i,ok:c.ok,status:c.status})}};return c.addEventListener(`click`,e=>{let t=e.target instanceof Element?Q(e.target,`[data-wui-row-action]`,HTMLButtonElement):null;t&&S.contains(t)&&!t.disabled&&(e.preventDefault(),Ge(t))}),ge(S),M(S),ae&&(0,_.addSelectColumn)(c),ve(S),Ie(),C.pending&&(k(he(C)),Pe()),{el:n,reload:async e=>{if(je)return je;let t=e?.quiet===!0;return t&&i.getAttribute(`aria-busy`)===`true`?new Promise((e,t)=>{F.push({resolve:e,reject:t})}):I(D,`none`,{quiet:t})},query:()=>new URLSearchParams(D),setQuery:e=>{let t=new URLSearchParams(D);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`),I(t,`push`)},saveRow:H,setActiveRow:e=>{n.dataset.activeRowKey=e==null?``:String(e),_e(X(S,`:scope > tr`,HTMLTableRowElement))},selection:{keys:()=>[...b],count:()=>x?C.total:b.size,allMatching:()=>x,selectAllMatching:()=>{if(C.pending)(0,o.devWarn)(`[@webority/ui-elements] select all matching needs the total; the table is still waiting for its count.`);else{x=!0;for(let e of X(S,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let t=Z(e,`.${_.SELECT_CELL_CLASS} .form-check-input`,HTMLInputElement);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&b.add(e.dataset.rowKey))}L()}},clear:()=>{x=!1,b.clear();for(let e of X(S,`:scope > tr > .${_.SELECT_CELL_CLASS} .form-check-input:not(:disabled)`,HTMLInputElement))e.checked=!1;L()}}}}var Kr=ie({CONFIRM_DIALOG_ID:()=>W,CONFIRM_TONES:()=>Et,DISCARD_EVENT:()=>Yn,closeRemotePane:()=>Tt,confirmAction:()=>Bt,createDiscardPrompt:()=>cr,formValues:()=>On,getServerTable:()=>y.getServerTable,initDrawerDiscard:()=>Ar,initRemoteModals:()=>yt,initServerActions:()=>fn,initServerTables:()=>Wr,initUnsavedChanges:()=>Kn,loadRemoteDrawer:()=>St,loadRemoteModal:()=>bt,loadRemotePane:()=>wt,postAction:()=>en,resetUnsavedChanges:()=>qn});(0,ne.registerServer)(Kr)})(WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.loader,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.drawerText,WeborityUiElementsInternal.modules.dataTable,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.httpFailureText,WeborityUiElementsInternal.modules.flash,WeborityUiElementsInternal.modules.postError,WeborityUiElementsInternal.modules.refreshAfter,WeborityUiElementsInternal.modules.hasOwn,WeborityUiElementsInternal.modules.svgNodes,WeborityUiElementsInternal.modules.serverHtml,WeborityUiElementsInternal.modules.wuiHost,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.toastAction,WeborityUiElementsInternal.modules.toastHeader,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.tableSelect,WeborityUiElementsInternal.modules.dataTableText,WeborityUiElementsInternal.modules.serverTableRegistry,WeborityUiElementsInternal.modules.server);
1
+ (function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,ee,te,g,_,v,y,ne){var re=Object.defineProperty,ie=(e,t)=>{let n={};for(var r in e)re(n,r,{get:e[r],enumerable:!0});return t||re(n,Symbol.toStringTag,{value:`Module`}),n},ae=globalThis.WeborityUiElementsInternal?.version;if(ae!==`0.183.0`)throw Error(`[webority-ui] server expects ui-elements 0.183.0 but the page loaded `+ae+`.`);var b={keepLabel:`Keep editing`,leaveLabel:`Discard changes`,message:`Your changes on this page are not saved. If you leave now, they are lost.`,title:`Discard changes?`},x={cancelLabel:`Cancel`,confirmLabel:`Confirm`,confirmTitle:`Are you sure?`,failedMessage:`That did not work. Try again.`,forbiddenMessage:`You do not have permission to do that.`,networkMessage:`Could not reach the server. Check your connection and try again.`,timeoutMessage:`The server did not answer in time. Check your connection and try again.`,typePhraseLabel:`Type {phrase} to confirm`},oe={backLabel:`Back`,clientMessage:`It may have been moved or deleted.`,closeLabel:`Close`,errorTitle:`This could not be loaded`,forbiddenMessage:`You do not have access to this.`,invalidMessage:`Some fields need attention.`,loadingLabel:`Loading`,networkMessage:`Could not reach the server. Check your connection and try again.`,retryLabel:`Try again`,serverMessage:`Something went wrong on our side. Try again in a moment.`,submitFailedMessage:`Your changes were not saved.`,timeoutMessage:`The server did not answer in time. Check your connection and try again.`},se=new Set(`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(`.`)),ce=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 le(e){return e.html===``?e.response===null?``:e.response.text():e.html}function S(e,t){let n=e=>typeof e==`string`?e.trim():``,r=ce(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 se.has(s)||s===t.trim().toLowerCase()?null:o}var C=`wui-remote-modal`,ue=`wui-remote-drawer`,w=Object.freeze({sm:360,md:480,lg:640,xl:720}),de=`wui-modal-fullscreen`,fe=`wui-modal-wide`,T=Object.freeze({sm:380,md:440,lg:640,xl:880,wide:1080}),E=()=>(0,r.readText)(`modal`,oe),pe=e=>(0,h.timeoutFromAttribute)(e?.getAttribute(`data-wui-timeout`)??null)??h.DEFAULT_TIMEOUT_MS,me=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,D=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,O=`[aria-invalid="true"], .is-invalid, .input-validation-error`,k=`invalid`,he=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,A=`[data-wui-modal-content]`,ge=`[data-wui-pane-close], [data-wui-dismiss]`,_e=()=>(0,t.make)(`button`,{type:`button`,class:`wui-modal-close`,"data-wui-dismiss":!0,"aria-label":E().closeLabel},(0,f.svgRoot)({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`}]])),j=new WeakMap,ve=new WeakSet;function M(e,t){if(e==null)throw TypeError(`The remote modal needs ${t}, and the page does not have it.`);return e}var N=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},ye=(e,t,n)=>M(N(e,t),n),be=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),xe=()=>Object.assign(Error(`The remote modal load was aborted.`),{name:`AbortError`}),Se=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,Ce=(e,t)=>{let n=e instanceof Element?e.closest(t):null;return n instanceof HTMLElement?n:null},we=e=>(0,d.hasOwn)(T,e),Te=e=>(0,d.hasOwn)(w,e);function Ee(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(we(e))return e===`wide`?{px:T.wide,wide:!0}:{px:T[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 De=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};if(e.classList.contains(`wui-modal-wide`))return{px:T.wide,wide:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:T.md}},P=(e,t)=>{e.classList.toggle(de,!!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`)},Oe=[`center`,`top`];function ke(e){if(e==null||e===``)return null;if(Te(e))return{px:w[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 Ae=e=>e.container===`drawer`,F=e=>e.container===`pane`,je=e=>e.container!==`modal`,Me=(e,t)=>Ae(e)?ke(t):Ee(t),I=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},Ne=e=>F(e)?e.shell:ye(e.shell,`.modal-dialog`,`a dialog frame`);function Pe(e=`modal`){let n=e===`drawer`,r=n?ue:C,i=document.getElementById(r);if(i)return i;let a=document.createElement(`wui-modal`);a.id=r,a.setAttribute(`data-wui`,`AppModal`);let o=document.createElement(`dialog`);return o.className=n?`modal wui-modal-shell wui-remote-drawer`:`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${n?w.md:T.md}px`),o.replaceChildren((0,t.make)(`div`,{class:n?`modal-dialog wui-remote-drawer-dialog`:`modal-dialog modal-dialog-centered wui-rb-dialog`},(0,t.make)(`div`,{class:`modal-content wui-modal`}))),a.append(o),document.body.appendChild(a),a}var Fe=e=>(0,t.make)(`div`,{class:`wui-modal-header`},(0,t.make)(`div`,{class:`wui-modal-heading`},(0,t.make)(`div`,{class:`wui-modal-headtext`},(0,t.make)(`div`,{class:`wui-modal-title`},e))),_e()),Ie=e=>(0,t.make)(`div`,{class:`modal-content wui-modal`,"aria-busy":`true`},Fe(e),(0,t.make)(`div`,{class:`wui-modal-body`},(0,t.make)(`div`,{class:`wui-modal-loading`,role:`status`},(0,t.make)(`span`,{class:`visually-hidden`},E().loadingLabel),(0,t.make)(`div`,{class:`skeleton wui-modal-skeleton`}),(0,t.make)(`div`,{class:`skeleton wui-modal-skeleton`}),(0,t.make)(`div`,{class:`skeleton wui-modal-skeleton wui-modal-skeleton--short`})))),Le=(n,i)=>{let a={forbidden:E().forbiddenMessage,networkCheck:(0,r.readText)(`httpFailure`,s.HTTP_FAILURE_TEXT).networkCheckText,client:E().clientMessage,server:E().serverMessage,network:E().networkMessage,timeout:E().timeoutMessage};return(0,t.make)(`div`,{class:`modal-content wui-modal`,"data-wui-modal-error":i},Fe(n),(0,t.make)(`div`,{class:`wui-modal-body`},(0,t.make)(`div`,{class:`wui-modal-state`,role:`alert`},(0,t.make)(`p`,{class:`wui-modal-state-title`},E().errorTitle),(0,t.make)(`p`,{class:`wui-modal-state-text`},a[i]||E().serverMessage),(0,t.make)(`div`,{class:`wui-modal-state-actions`},(0,t.make)(`button`,{type:`button`,class:(0,e.buttonClass)(`primary`,`soft`,`md`),"data-wui-dismiss":!0,"data-wui":e.APP_BUTTON_MARKER},E().closeLabel),(0,t.make)(`button`,{type:`button`,class:(0,e.buttonClass)(`primary`,`solid`,`md`),"data-wui-modal-retry":!0,"data-wui":e.APP_BUTTON_MARKER},E().retryLabel)))))},L=e=>N(e.shell,`.modal-content`),R=e=>(0,t.elementOf)(e.cloneNode(!0),HTMLElement,`a card copy is not an element`);function z(e){e&&e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}))}function B(e,t){let n=L(e),r=n?ze(n):new Map;z(n),n?n.replaceWith(t):Ne(e).appendChild(t),Be(t,r),(0,m.wuiHost)().refresh()}var Re=`input[type="file"][name]`;function ze(e){let t=new Map;for(let n of e.querySelectorAll(Re)){if(!(n instanceof HTMLInputElement))continue;let e=n.files;e&&e.length>0&&t.set(n.name,[...e])}return t}function Be(e,t){if(t.size!==0&&typeof DataTransfer<`u`)for(let n of e.querySelectorAll(Re)){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 Ve=e=>F(e)?!e.shell.hidden:e.host.hasAttribute(`open`);function He(e,t,n=!1){let r=t?N(e,O):null,i=r?r.matches(me)?r:N(r,me)||r:null;if(!i&&n)i=N(e,`[data-autofocus]`)||N(e,D)||N(e,`.wui-modal-close`);else if(!i){let t=be(e,me);i=N(e,`[data-autofocus]`)||t.find(e=>!e.classList.contains(`wui-modal-close`))||t[0]||e}r?i?.focus?.():i?.focus?.({preventScroll:!0})}function Ue(e,t){let n=N(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`,``),Ne(e).appendChild(n)),n.textContent=``,n.textContent=t}var We=e=>{let t=N(e.shell,`[data-wui-modal-live]`);t&&(t.textContent=``)},V=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};function H(e,t,n,r){let i={...r,container:e.container};V(t,`wui:modal:${n}`,i),Ae(e)&&V(t,`wui:drawer:${n}`,i),F(e)&&V(t,`wui:pane:${n}`,i)}var Ge=e=>e.matches(`[data-wui-pane-host]`)?`pane`:ye(e,`dialog`,`a dialog`).classList.contains(`wui-remote-drawer`)?`drawer`:`modal`,Ke=e=>M(e.host.closest(`wui-modal`),`a wui-modal host`);function qe(e){let n=j.get(e);if(n)return n;let r=Ge(e),i=r===`pane`?e:ye(e,`dialog`,`a dialog`),a=L({shell:i}),o={host:e,shell:i,container:r,queue:(0,h.createRequestQueue)(),defaultSize:De(i),defaultLabel:i.getAttribute(`aria-label`),placeholder:a?R(a):(0,t.make)(`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 j.set(e,o),e.addEventListener(`submit`,e=>ht(o,e)),e.addEventListener(`click`,e=>{Ce(e.target,`[data-wui-modal-retry]`)&&o.session&&(e.preventDefault(),nt(o,o.session))}),F(o)&&e.addEventListener(`click`,t=>{let n=Ce(t.target,ge);n&&e.contains(n)&&o.session&&U(o,o.session,`dismissed`,null)}),e.addEventListener(`wui-modal-close`,t=>{t.target===e&&t instanceof CustomEvent&&dt(t.detail,`reason`)===`escape`&&e.querySelector(`form[data-wui-submitting]`)&&t.preventDefault()}),e.addEventListener(`wui-modal-closed`,t=>{t.target===e&&$e(o)}),e.addEventListener(`wui-modal-opened`,t=>{if(t.target!==e)return;let n=L(o);o.session&&n?.matches(A)&&!n.contains(document.activeElement)&&He(n,!1,je(o))}),o.remoteUrl&&e.addEventListener(`wui-modal-open`,t=>{t.target===e&&et(o,t)}),o}function Je(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:()=>U(e,o,`dismissed`,null),reload:()=>nt(e,o)},pendingRefresh:r};return e.session=o,o}function U(e,t,n,r){e.session===t&&(t.closing={status:n,detail:r},F(e)?Xe(e,t):Ye(e))}function Ye(e){let t=Ke(e);t.dispatchEvent(new CustomEvent(`wui-modal-close`,{bubbles:!0,cancelable:!0,detail:{reason:`dismiss`}}))&&t.hide()}function Xe(e,t){let n=e.shell,{status:r,detail:i}=M(t.closing,`the closing state`),a=n.contains(document.activeElement);e.queue.abort(),e.session=null,z(L(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),H(e,n,`closed`,{status:r,url:t.url}),Ze(t),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function Ze(e){let t=e.pendingRefresh;e.pendingRefresh=null,t&&(0,u.applyPlan)(t).catch(o.devError)}function Qe(e,t){for(let n=e;n!==null;n=n.parentElement){let e=n instanceof HTMLElement?j.get(n):void 0;if(e?.session){let n=(0,u.planReloads)(t);return e.session.pendingRefresh=(0,u.mergePlans)(e.session.pendingRefresh,{...t,message:n?t.message:null,action:n?t.action:null}),!0}}return!1}(0,u.setDialogHold)(Qe);function $e(e){let t=e.session;if(e.queue.abort(),e.session=null,We(e),t){let n=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n.status,detail:n.detail}),H(e,e.shell,`closed`,{status:n.status,url:t.url}),Ze(t);let r=document.activeElement;t.trigger?.isConnected&&(!r||r===document.body||e.shell.contains(r))&&t.trigger.focus?.()}e.cache||(B(e,R(e.placeholder)),e.loadedUrl=null,P(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function et(e,t){let n=dt(t instanceof CustomEvent?t.detail:null,`trigger`),r=n instanceof HTMLElement?n:null,i=r?.getAttribute(`data-wui-url`)||e.remoteUrl||``,a=Je(e,i,{trigger:r});a.explicitSize=tt(e,r?.getAttribute(`data-wui-size`)),a.explicitSize&&P(e.shell,a.explicitSize),e.cache&&e.loadedUrl===i||(e.loadedUrl&&B(e,R(e.placeholder)),nt(e,a,{keepPlaceholder:!0}))}function tt(e,t){try{return Me(e,t)}catch(e){return(0,o.devError)(e),null}}async function nt(e,t,{keepPlaceholder:n=!1}={}){n||B(e,Ie(t.options.title||rt(e)));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate,timeoutMs:pe(t.trigger)});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if(r.kind===`ok`&&st(e,t,r.html,!1))return e.loadedUrl=t.url,H(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return B(e,Le(t.options.title||rt(e),i)),Ve(e)&&He(M(L(e),`a card`),!1,je(e)),H(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var rt=e=>L(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,it=`/_content/Webority.Ui.Razor/js/`,at=e=>new URL(e,window.location.href).pathname.includes(it);function ot(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function st(e,t,n,r){let i=(0,p.parseServerHtml)(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&&at(t)?ot(t):a=!0}a&&(0,o.devWarn)(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let s=N(i,A);if(!s)return(0,o.devError)(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;if(B(e,s),r||We(e),!F(e)){P(e.shell,t.explicitSize||tt(e,s.getAttribute(`data-wui-size`))||e.defaultSize);let n=s.getAttribute(`data-wui-title`);n&&e.shell.setAttribute(`aria-label`,n)}return Ve(e)&&He(s,r,je(e)),!0}var ct=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function lt(e,n,r){let i=[...e.elements].filter(e=>e.matches(ct));if(r){e.setAttribute(`data-wui-submitting`,``);let r=n&&i.includes(n)?n:i[0];for(let e of i)e.toggleAttribute(`data-wui-was-disabled`,e.disabled),e.disabled=!0;r&&(r.classList.add(`is-loading`),r.setAttribute(`aria-busy`,`true`),r.tagName===`BUTTON`&&r.prepend((0,t.make)(`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 i)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 ut(e){for(let t of e.querySelectorAll(he))t.remove();for(let t of e.querySelectorAll(O))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}var dt=(e,t)=>{if(typeof e==`object`&&e&&t in e)return Reflect.get(e,t)};async function ft(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 le(e))}catch{return null}return S(t,e.response.statusText)}function pt(e,t,n,i){let a={forbidden:E().forbiddenMessage,networkCheck:(0,r.readText)(`httpFailure`,s.HTTP_FAILURE_TEXT).networkCheckText,client:E().clientMessage,server:E().serverMessage,network:E().networkMessage,timeout:E().timeoutMessage},o=t.closest(`.wui-modal-body`)||t;o.querySelector(`[data-wui-modal-submit-error]`)?.remove(),ut(o);let c=document.createElement(`div`);c.className=`alert alert-danger wui-modal-submit-error`,c.setAttribute(`role`,`alert`),c.setAttribute(`data-wui-modal-submit-error`,``),c.textContent=`${E().submitFailedMessage} ${i||a[n]||E().serverMessage}`,o.prepend(c),Ue(e,c.textContent)}var mt=(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(A)||(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,s=(i?.getAttribute(`formmethod`)||n.getAttribute(`method`)||`GET`).toUpperCase(),c=new FormData(n);i?.name&&!c.has(i.name)&&c.append(i.name,i.value);let l=s===`GET`;lt(n,i,!0);let u;try{u=await e.queue.run(l?mt(a,c):a,{method:s,body:l?void 0:c,navigate:r.options.navigate,timeoutMs:pe(r.trigger)})}catch(t){(0,o.devError)(t),e.session===r&&n.isConnected&&(lt(n,i,!1),pt(e,n,`server`,null));return}if(e.session!==r)return;if(n.isConnected&&lt(n,i,!1),u.kind===`ok`&&u.result===`success`){gt(e,r,u);return}if(u.kind===`aborted`||u.kind===`stale`||u.kind===`session`)return;if(u.kind===`ok`&&u.html){let t=u.result===k;if(st(e,r,u.html,t)){if(t){let t=M(L(e),`a card`).querySelector(he)?.textContent?.replace(/\s+/g,` `).trim();Ue(e,t||E().invalidMessage)}return}}let d=u.kind===`ok`||u.kind===`validation`?`server`:u.kind,f=await ft(u);e.session===r&&pt(e,n,d,f)}function gt(e,t,n){let r=n.message,i=n.redirect||null,a=n.toastVariant||`success`;if(!(0,c.isToastVariant)(a))throw TypeError(`Unknown toast variant "${a}". Use ${c.FLASH_VARIANTS.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||(0,u.isRefreshOff)(t.trigger)?null:(0,u.planOf)(n),l=!(n.next&&!i)&&!n.keepOpen,d=s!==null&&l&&(0,u.planReloads)(s);i&&!t.options.navigate?(0,c.storeFlash)(r,a):r&&!d&&(0,m.wuiHost)().toast(r,{variant:a}),H(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=(0,u.mergePlans)(t.pendingRefresh,{...s,action:null,message:d?s.message:null}));let f=n.next;f&&!i?(t.url=f,t.method=`GET`,t.body=void 0,nt(e,t)):n.keepOpen?n.html&&n.data===null&&st(e,t,n.html,!1):U(e,t,`success`,o)}function _t(e){let t=Ce(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`)?wt(t.getAttribute(`data-wui-pane`)??``,{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{Se(e)||(0,o.devError)(e)}):t.hasAttribute(`data-wui-modal`)?bt(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=>{Se(e)||(0,o.devError)(e)}):St(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=>{Se(e)||(0,o.devError)(e)})))}function vt(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=Ce(e.target,Ct);if(!t)return;let n=j.get(t),r=e.currentTarget;n?.session&&r instanceof Document&&!r.querySelector(`wui-modal[open]`)&&(t.querySelector(`form[data-wui-submitting]`)||(e.preventDefault(),U(n,n.session,`dismissed`,null)))}function yt(e=document){let t=e instanceof Document?e:M(e.ownerDocument,`an owner document`);ve.has(t)||(ve.add(t),t.addEventListener(`click`,_t),t.addEventListener(`keydown`,vt));let n=be(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)qe(e)}function bt(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=t.container===`drawer`,r=n?ke(t.size):Ee(t.size),i=t.placement||`center`;if(!Oe.includes(i))throw TypeError(`WUI.modal.load: unsupported placement "${i}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(xe());let a=Pe(n?`drawer`:`modal`);yt(document);let o=qe(a),s=Ve(o),c=Je(o,e,t);c.explicitSize=r,P(o.shell,r||o.defaultSize),n||ye(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=nt(o,c);return s||Ke(o).show(),xt(o,c,t,l,u,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function xt(e,t,n,r,i,a){let o=new Promise((r,i)=>{n.signal?.addEventListener(`abort`,()=>{e.session===t&&(e.queue.abort(),U(e,t,`dismissed`,{aborted:!0})),i(xe())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw xe();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 St(e,t={}){return bt(e,{...t,container:`drawer`,placement:void 0})}var Ct=`[data-wui-pane-host]`;function wt(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=I(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(xe());yt(document);let r=qe(n),i=Je(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=nt(r,i);return xt(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function Tt(e){let t=I(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=j.get(t);n?.session&&U(n,n.session,`dismissed`,null)}var W=`wuiConfirm`,Et=Object.freeze([`danger`]),Dt=Object.freeze([`warning`,`info`,`delete`]),G=()=>(0,r.readText)(`confirmDialog`,x),Ot=new WeakSet,kt=new WeakSet,At=null,jt=null,Mt=!1,Nt=(e,t)=>{e&&(0,m.wuiHost)().toast(e,{variant:t})};function Pt(){let n=document.getElementById(W);if(n)return(0,t.must)(n.closest(`wui-modal`),`#${W} must be a wui-modal.`);let r=document.createElement(`wui-modal`);r.id=W;let i=document.createElement(`dialog`);return i.className=`modal wui-modal-shell`,i.style.setProperty(`--wui-modal-max-width`,`${T.md}px`),i.replaceChildren((0,t.make)(`div`,{class:`modal-dialog modal-dialog-centered wui-rb-dialog`},(0,t.make)(`div`,{class:`modal-content wui-modal wui-confirm`},(0,t.make)(`div`,{class:`wui-modal-body`},(0,t.make)(`div`,{class:`wui-confirm-content`},(0,t.make)(`span`,{class:`wui-confirm-icon`},(0,t.make)(`wui-status-icon`,{tone:`info`,size:120})),(0,t.make)(`h3`,{class:`wui-confirm-title`,tabindex:-1,"data-autofocus":``}),(0,t.make)(`p`,{class:`wui-confirm-msg`}))),(0,t.make)(`div`,{class:`wui-modal-footer`},(0,t.make)(`div`,{class:`wui-confirm-actions`},(0,t.make)(`button`,{type:`button`,class:(0,e.buttonClass)(`primary`,`soft`,`md`),"data-wui-dismiss":``,"data-wui":e.APP_BUTTON_MARKER},G().cancelLabel),(0,t.make)(`button`,{type:`button`,class:(0,e.buttonClass)(`primary`,`solid`,`md`),"data-app-confirm":``,"data-wui":e.APP_BUTTON_MARKER})))))),r.append(i),document.body.appendChild(r),r}function Ft(e,t){let n=e.getAttribute(`data-wui-confirm-tone`);if(n!==null&&!Et.includes(n))throw TypeError(`data-wui-confirm-tone="${n}" is not supported. Use danger, or leave it off.`);It({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 It({title:e,message:n,label:r,danger:i,cancel:a,icon:o},s){let c=Pt(),l=c.querySelector(`.wui-confirm-title`),u=c.querySelector(`[data-app-confirm]`);if(!l||!u)throw Error(`#${W} is not a confirm dialog with a confirm button. Render <app-confirm-dialog id="${W}"> 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||G().confirmTitle;l.textContent=f,d.textContent=n,u.textContent=r||G().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||G().cancelLabel),(0,t.must)(c.querySelector(`dialog`),`#${W} has no <dialog>.`).setAttribute(`aria-label`,f),jt=s,Mt=!1,c.show()}var Lt=(e,t)=>{At=e;try{t()}finally{At=null}},Rt=(e,t)=>{let n=Reflect.get(e,t);if(n===void 0||typeof n==`string`)return n;throw TypeError(`confirmAction: ${t} must be text.`)},zt=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:Rt(e,`title`),message:t,label:Rt(e,`label`),tone:Rt(e,`tone`),cancel:Rt(e,`cancel`),icon:Rt(e,`icon`)}};function Bt(e,t,n){let{title:r,message:i,label:a,tone:o,cancel:s,icon:c}=zt(t);if(o!=null&&!Et.includes(o))throw TypeError(`confirmAction: tone "${o}" is not supported. Use danger, or leave it off.`);if(c!=null&&!Dt.includes(c))throw TypeError(`confirmAction: icon "${c}" is not supported. Use warning, info or delete, or leave it off.`);dn(e.ownerDocument),It({title:r,message:i,label:a,danger:o===`danger`,cancel:s,icon:c},()=>Lt(e,n))}var Vt=e=>`disabled`in e&&e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`,Ht=e=>{(0,t.elementOf)(e,HTMLElement,`data-wui-confirm needs an HTML element to click.`).click()};function Ut(e){let n=(0,t.closestOf)(e.target,`[data-wui-confirm]:not(form)`);n&&n!==At&&!Vt(n)&&(e.preventDefault(),e.stopImmediatePropagation(),Ft(n,()=>Lt(n,()=>Ht(n))))}function Wt(e){let t=e.target;if(!(t instanceof HTMLFormElement)||!t.hasAttribute(`data-wui-confirm`)||t===At||e.submitter&&e.submitter===At||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;Ft(t,()=>Lt(t,()=>t.requestSubmit(r)))}function Gt(e){let n=(0,t.closestOf)(e.target,`#${W} [data-app-confirm]`);n&&!n.hasAttribute(`disabled`)&&jt&&(Mt=!0,(0,t.must)(n.closest(`wui-modal`),`#${W} is missing around its confirm button.`).hide())}function Kt(e){if(!(e.target instanceof Element)||e.target.id!==`wuiConfirm`)return;let t=Mt?jt:null;jt=null,Mt=!1,t?.()}var qt=e=>e===`forbidden`?G().forbiddenMessage:e===`networkCheck`?(0,r.readText)(`httpFailure`,s.HTTP_FAILURE_TEXT).networkCheckText:e===`network`?G().networkMessage:e===`timeout`?G().timeoutMessage:G().failedMessage,Jt=(e,t)=>{`disabled`in e&&(e.disabled=t)},Yt=e=>{Jt(e,!1),e.removeAttribute(`aria-busy`)};async function Xt(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 Zt(t,e)}async function Zt(e,t,n){Jt(t,!0),t.setAttribute(`aria-busy`,`true`);let r=(0,h.timeoutFromAttribute)(t.getAttribute(`data-wui-timeout`))??h.DEFAULT_TIMEOUT_MS,i=await(0,h.wuiFetch)(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)(0,c.storeFlash)(i.message,a,i.toastAction),window.location.assign(i.redirect);else if(i.ok){let e=(0,u.isRefreshOff)(t);if(!e&&(0,u.reloadsPage)(i)){await(0,u.refreshAfter)(i,{origin:t})===`held`&&Yt(t);return}Yt(t),(0,ee.showResultToast)(i,a),e||await(0,u.refreshAfter)(i,{origin:t})}else Yt(t),Nt(i.message||qt(i.kind),`danger`)}var Qt=e=>typeof e!=`object`||!e||!(`code`in e)?null:typeof e.code==`string`?e.code:null,$t=e=>(e.response?.headers.get(`Content-Type`)??``).toLowerCase().includes(`json`)?e.data:e.html===``?null:e.html;async function en(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(!te.TOAST_ACTION_METHODS.includes(n))throw TypeError(`postAction method must be POST, PUT, PATCH or DELETE.`);let r=t.timeoutMs??h.DEFAULT_TIMEOUT_MS;if(!Number.isInteger(r)||r<0)throw TypeError(`postAction timeoutMs must be a whole number of milliseconds, 0 for no limit.`);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 s;try{s=await(0,h.wuiFetch)(e,{method:n,body:a,headers:i,timeoutMs:r})}catch(e){throw(0,o.devError)(e),e}if(s.kind===`session`||s.kind===`aborted`)throw new l.WuiPostError(qt(s.kind),{code:null,status:s.status,html:null,body:null,kind:s.kind});let d=t.toast!==!1,f=t.refresh!==!1,p=s.toastVariant||`success`;if(s.ok){if(s.redirect)(0,c.storeFlash)(d?s.message:null,p,d?s.toastAction:null),window.location.assign(s.redirect);else{let e=(0,u.planOf)(s);d&&!(f&&(0,u.reloadsPage)(s))&&(0,ee.showResultToast)(s,p),e!==null&&f&&await(0,u.applyPlan)({...e,message:d?e.message:null,action:d?e.action:null})}return $t(s)}let m;try{m=await le(s)}catch(e){(0,o.devError)(e);let t=s.message||qt(s.kind);throw Nt(t,`danger`),new l.WuiPostError(t,{code:null,status:s.status,html:null,body:null,kind:s.kind,cause:e})}let g=(s.response?.headers.get(`Content-Type`)??``).toLowerCase(),_=null;if(g.includes(`json`))try{_=JSON.parse(m)}catch{_=null}let v=S(_,s.response?.statusText??``)||s.message||qt(s.kind),y=g.includes(`text/html`)?m:null;throw(s.kind!==`validation`||y===null)&&Nt(v,`danger`),new l.WuiPostError(v,{code:Qt(_),status:s.status,html:y,body:_,kind:s.kind})}function tn(e,t){Jt(e,!1),e.removeAttribute(`aria-busy`),(0,o.devError)(t),Nt(G().failedMessage,`danger`)}function nn(e){let n=(0,t.closestOf)(e.target,`[data-wui-post]`);n&&(e.preventDefault(),Vt(n)||n.getAttribute(`aria-busy`)===`true`||Xt(n).catch(e=>tn(n,e)))}function rn(e){let n=(0,t.closestOf)(e.target,`form[data-wui-post-form]`);if(!(n instanceof HTMLFormElement)||e.defaultPrevented)return;e.preventDefault();let r=(0,t.must)(e.submitter||n.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((0,t.must)(n.getAttribute(`action`),`A data-wui-post-form needs an action attribute to post to.`),document.baseURI).href;Zt(i,r,new FormData(n)).catch(e=>tn(r,e)),n.closest(`wui-dropdown`)?.hide()}var an=(e,t)=>{e.disabled=!1,e.removeAttribute(`aria-busy`),t&&(0,a.setRowSaveState)(t,null)};async function on(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&&(0,a.setRowSaveState)(t,`saving`);let r=(0,h.timeoutFromAttribute)(e.getAttribute(`data-wui-timeout`))??h.DEFAULT_TIMEOUT_MS,i=await(0,h.wuiFetch)(n,{method:(e.dataset.method||`post`).toUpperCase(),timeoutMs:r});if(i.kind===`session`)return;if(i.kind===`aborted`){an(e,t);return}let o=i.toastVariant||`success`;if(i.ok&&i.redirect){(0,c.storeFlash)(i.message,o,i.toastAction),window.location.assign(i.redirect);return}if(i.ok){let n=(0,u.planOf)(i);if((0,u.isRefreshOff)(e)||n===null||(0,u.refreshesNothing)(n)){an(e,t),(0,ee.showResultToast)(i,o);return}if((0,u.holdInDialog)({...n,reload:`page`},e)){an(e,t);return}(0,c.storeFlash)(i.message,o,i.toastAction),(0,u.reloadPage)();return}let s=i.message||qt(i.kind);e.disabled=!1,e.removeAttribute(`aria-busy`),t&&(0,a.setRowSaveState)(t,`error`,s),Nt(s,`danger`)}var sn=new WeakSet;function cn(e){let n=(0,t.closestOf)(e.target,`[data-wui-row-action]`);if(!n||n.closest(`[data-wui-server]`))return;if(!(n instanceof HTMLButtonElement)){if(sn.has(n))return;sn.add(n),(0,o.devError)(Error(`A [data-wui-row-action] element must be a button with data-url, so its click does nothing: ${n.getAttribute(`data-wui-row-action`)??``}`));return}if(e.preventDefault(),n.disabled||n.getAttribute(`aria-busy`)===`true`)return;let r=n.closest(`tr`);on(n,r).catch(e=>{an(n,r),(0,o.devError)(e),Nt(G().failedMessage,`danger`)})}var ln=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.form:null;function un(e){if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-wui-auto-submit]`);if(!t)return;let n=ln(e.target)||t.closest(`form`);n instanceof HTMLFormElement&&n.requestSubmit()}function dn(e){kt.has(e)||(kt.add(e),e.addEventListener(`click`,Gt),e.addEventListener(`wui-modal-closed`,Kt))}function fn(e=document){let t=e instanceof Element?e.ownerDocument:e;Ot.has(t)||(Ot.add(t),t.addEventListener(`click`,Ut,!0),t.addEventListener(`submit`,Wt,!0),dn(t),t.addEventListener(`click`,nn),t.addEventListener(`click`,cn),t.addEventListener(`submit`,rn),t.addEventListener(`change`,un))}var pn=()=>(0,r.readText)(`unsavedChanges`,b),mn=`form[data-wui-unsaved]`,hn=`[aria-invalid="true"], .field-error:not(:empty), .field-validation-error, .validation-summary-errors, .wui-error-summary`,gn=`[download], [data-wui-modal], [data-wui-post], [data-bs-toggle]`,_n=new Set([`submit`,`button`,`reset`,`image`]),vn=new Set([`hidden`,`checkbox`,`radio`,`file`,`submit`,`button`,`reset`,`image`,`range`,`color`]),yn=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,bn=e=>yn(e)?e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled:`disabled`in e&&!!e.disabled,xn=e=>`name`in e&&typeof e.name==`string`&&e.name!==``,Sn=e=>typeof e==`object`&&!!e,Cn=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&typeof e[0]==`string`);function wn(e){let t=JSON.parse(e);if(!Cn(t))throw Error(`unsaved-changes snapshot is malformed`);return t}var K=new WeakMap,Tn=new WeakSet,En=e=>`${e.name}:${e.size}:${e.lastModified}`,Dn=e=>[...e.querySelectorAll(mn)].filter(e=>e instanceof HTMLFormElement);function q(e){let t=[];for(let n of e.elements)xn(n)&&!bn(n)&&(yn(n)&&_n.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(En)]):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 On(e){return q(e)}function kn(e,t){let n=new Map,r=wn(t);for(let e of r){let t=n.get(e[0]);t?t.push(e):n.set(e[0],[e])}let i=wn(q(e)).map(e=>n.get(e[0])?.shift()??e);for(let e of n.values())i.push(...e);return JSON.stringify(i)}function An(e){for(let t of e.elements)if(yn(t)&&t.name&&!bn(t)){if(t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement&&!vn.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 jn=e=>({saved:e.querySelector(hn)&&An(e)?null:q(e),engaged:!1,discarded:!1});function Mn(e){let t=K.get(e);return!t||t.discarded||!e.isConnected?!1:t.saved===null||t.engaged&&q(e)!==t.saved}var Nn=(e,t)=>Dn(e).filter(e=>e!==t&&Mn(e));function Pn(e,t,n){let r=t.map(e=>e.getAttribute(`data-wui-unsaved`)).find(Boolean)||pn().message;Bt(e,{title:pn().title,message:r,label:pn().leaveLabel,cancel:pn().keepLabel,icon:`warning`,tone:`danger`},()=>{for(let e of t){let t=K.get(e);t&&(t.discarded=!0)}n()})}function Fn(e){if(e.matches(gn))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 In(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 Ln(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let n=e.target,r=(0,t.closestOf)(n,`a[href]`);if(!(r instanceof HTMLAnchorElement)||!Fn(r))return;let i=Nn(r.ownerDocument,null);i.length&&(e.preventDefault(),Pn(r,i,()=>r.click()))}function Rn(e){let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented||!In(t,e.submitter))return;let n=Nn(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;Pn(t,n,()=>t.requestSubmit(i));return}let r=K.get(t);r&&(r.saved=q(t),r.discarded=!1)}function zn(e){Nn(document,null).length&&e.preventDefault()}function Bn(e){let n=e.target,r=(0,t.closestOf)(n,mn);return r instanceof HTMLFormElement?r:null}function Vn(e){let t=Bn(e);if(!t)return;let n=K.get(t);n&&!n.engaged&&(n.saved!==null&&(n.saved=q(t)),n.engaged=!0)}function Hn(e){let t=Bn(e),n=t&&K.get(t);n&&(n.discarded=!1,e.isTrusted&&(n.engaged=!0))}function Un(e){for(let t of Dn(e)){let e=K.get(t);e?.saved&&(e.saved=kn(t,e.saved))}}function Wn(e){let t=Sn(e)?e.handle:void 0;return Sn(t)?t.el:void 0}function Gn(e){if(!(e instanceof CustomEvent))return;let t=Wn(e.detail);if(t instanceof Element)for(let e of Dn(t))qn(e)}function Kn(e=document){let r=e instanceof Document?e:e.ownerDocument;if(!Tn.has(r)){Tn.add(r);for(let e of[`focusin`,`pointerdown`,`drop`])r.addEventListener(e,Vn,!0);for(let e of[`input`,`change`])r.addEventListener(e,Hn,!0);r.addEventListener(`click`,Ln),r.addEventListener(`submit`,Rn),r.addEventListener(`wui:modal:success`,Gn),r.addEventListener(n.ELEMENTS_DEFINED_EVENT,()=>Un(r)),(0,t.must)(r.defaultView,`unsaved-changes guard needs a document with a window`).addEventListener(`beforeunload`,zn)}let i=Dn(e);e instanceof HTMLFormElement&&e.matches(mn)&&i.unshift(e);for(let e of i)K.has(e)||K.set(e,jn(e))}function qn(e){if(!(e instanceof HTMLFormElement)||!e.matches(mn))throw TypeError(`resetUnsavedChanges: ${String(e)} is not a <form data-wui-unsaved>.`);K.set(e,{saved:q(e),engaged:!1,discarded:!1})}var Jn=()=>(0,r.readText)(`drawer`,i.DRAWER_TEXT),Yn=`wui:drawer:discard`,Xn=`wui-drawer[confirm-discard]`,Zn=`wui-modal`,Qn=`data-wui-no-discard`,$n=`.wui-drawer-discard`,er=`input, select, textarea`,tr=e=>typeof e==`object`&&!!e||typeof e==`function`;function nr(e){let t=e.currentTarget;if(!(t instanceof Document))throw Error(`The discard guard is not wired on a document.`);return t}function rr(e,n){return(0,t.closestOf)(e,n)}var ir=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement,J=new WeakMap,ar=new WeakSet,or=new WeakSet;function sr(t,n,r,i,a){let o=t.createElement(`button`);return o.type=`button`,o.className=(0,e.buttonClass)(n,r,`sm`),o.dataset.wui=e.APP_BUTTON_MARKER,o.setAttribute(i,``),o.textContent=a,o}function cr(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,sr(e,`danger`,`solid`,`data-wui-discard-confirm`,Jn().discardLabel),sr(e,`primary`,`soft`,`data-wui-discard-keep`,Jn().keepLabel)),n}function lr(e){if(!(e instanceof Element))return null;let t=e.closest(Xn);if(t)return t;let n=e.closest(Zn);return n&&fr(n).length?n:null}function ur(e){return e.closest(Xn)??e.closest(Zn)}function dr(e,t){return t.hasAttribute(Qn)||e.hasAttribute(Qn)?!1:t.hasAttribute(`confirm-discard`)||e.hasAttribute(`data-wui-confirm-discard`)?!0:(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`}function fr(e){return e.matches(Xn)?e.querySelectorAll(`form`):[...e.querySelectorAll(`form`)].filter(t=>dr(t,e))}function pr(e){let t=J.get(e);return t!=null&&On(e)!==t}function mr(e){let n=e.ownerDocument.createElement(`div`);return n.className=`wui-drawer-footer`,(0,t.must)(e.querySelector(`.wui-drawer-panel`),`The drawer has no panel to hold its footer.`).append(n),or.add(n),n}function hr(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 gr(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 _r(e,t,n){let r=e.querySelector($n);if(r){gr(r);return}let i=cr(e.ownerDocument,t),a;if(e.matches(Xn))a=e.querySelector(`.wui-drawer-footer`)??mr(e),a.prepend(i);else if(e.hasAttribute(`confirm-discard`))a=e.querySelector(`.wui-modal-footer`)??hr(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`)??hr(e),a.prepend(i)}a.classList.add(`wui-drawer-discarding`),gr(i)}function vr(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 yr(e){for(let t of fr(e))for(let e of t.querySelectorAll(er))if(ir(e)&&e.type!==`hidden`&&!e.disabled){e.focus({preventScroll:!0});return}}function br(e){let t=lr(e.target);if(t)for(let e of fr(t))J.get(e)??J.set(e,On(e))}function xr(e){for(let t of nr(e).querySelectorAll(`form`)){let e=J.get(t);e!=null&&J.set(t,kn(t,e))}}function Sr(e){let t=e.target;t instanceof HTMLFormElement&&lr(t)&&J.set(t,On(t))}function Cr(e){if(!tr(e))return;let t=`handle`in e?e.handle:void 0;if(tr(t))return`el`in t?t.el:void 0}function wr(e){if(!(e instanceof CustomEvent))return;let t=e.detail,n=Cr(t);if(n instanceof Element)for(let e of n.querySelectorAll(`form`))J.delete(e)}function Tr(e){let t=e.target;t instanceof Element&&t.matches(Xn)&&[...fr(t)].some(pr)&&(e.preventDefault(),_r(t,t.getAttribute(`confirm-discard`),null))}function Er(e){let t=e.target;if(!(t instanceof Element)||!t.matches(Zn))return;let n=[...fr(t)].find(pr);n&&(e.preventDefault(),_r(t,n.getAttribute(`data-wui-confirm-discard`)??t.getAttribute(`confirm-discard`)??Jn().confirmDiscard,n))}function Dr(e){let n=(0,t.must)(e.closest($n),`The discard button is outside its prompt.`),r=ur(n);if(vr(n),!r)throw Error(`The discard prompt is outside its drawer or modal.`);for(let e of fr(r))J.set(e,On(e));r.dispatchEvent(new CustomEvent(Yn,{bubbles:!0})),r.matches(Xn)?(0,t.must)(r.closest(`wui-drawer`),`The confirm-discard drawer is not a wui-drawer.`).hide():(0,t.must)(r.closest(`wui-modal`),`The discarded dialog is not a wui-modal.`).hide()}function Or(e){let n=(0,t.must)(e.closest($n),`The keep button is outside its prompt.`),r=ur(n);if(vr(n),!r)throw Error(`The discard prompt is outside its drawer or modal.`);yr(r)}function kr(e){let t=rr(e.target,`[data-wui-discard-confirm]`);if(t){Dr(t);return}let n=rr(e.target,`[data-wui-discard-keep]`);n&&Or(n)}function Ar(e=document){let t=e instanceof Document?e:e.ownerDocument;ar.has(t)||(ar.add(t),t.addEventListener(`focusin`,br),t.addEventListener(`pointerdown`,br),t.addEventListener(`submit`,Sr),t.addEventListener(n.ELEMENTS_DEFINED_EVENT,xr),t.addEventListener(`wui:modal:success`,wr),t.addEventListener(`wui:modal:loaded`,wr),t.addEventListener(`wui-drawer-close`,Tr,!0),t.addEventListener(`wui-modal-close`,Er),t.addEventListener(`click`,kr))}var jr=Object.freeze([`page`,`pageSize`,`sortBy`,`sortOrder`,`search`]),Mr=`search`,Y=()=>(0,r.readText)(`dataTable`,v.DATA_TABLE_TEXT),Nr=5,Pr=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,Fr=e=>e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled,Ir=e=>Pr(e)&&`type`in e&&e.type===`hidden`,X=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),Z=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},Q=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Lr=e=>e.localName===`wui-select`,$=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},Rr=e=>({total:$(e.dataset.total,0),totalCapped:e.dataset.totalCapped===`true`,page:$(e.dataset.page,1),pageSize:$(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`,pending:e.dataset.totalPending===`true`,rowCount:$(e.dataset.rowCount,0)}),zr=(e,t)=>{e&&(0,m.wuiHost)().toast(e,{variant:t})},Br=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>!Ir(e)||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!jr.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of X(e,`[data-wui-filter-clear]`,HTMLElement))t.hidden=!r},Vr=new Intl.NumberFormat(`en-IN`),Hr=(e,t)=>t?`${Vr.format(e)}+`:Vr.format(e),Ur=(e,t,n)=>{let r=e.closest(`.wui-list-card`),i=r?Z(r,`.wui-list-card-count`,HTMLElement):null;i&&(i.textContent=Hr(t,n))};function Wr(e=document){let t=X(e,`[data-wui-server]`,HTMLElement);e instanceof HTMLElement&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t){if((0,y.isServerTableWired)(e))continue;let t=Gr(e);(0,y.registerServerTable)(e,t),e.hasAttribute(`data-load-first-page`)&&t.reload()}}function Gr(n){let i=Z(n,`.table-wrap`,HTMLElement),c=i?Z(i,`:scope > table`,HTMLTableElement):null,l=n.dataset.src;if(!i||!c||!l)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let d=Z(i,`:scope > [data-wui-table-state]`,HTMLElement),f=Z(n,`[data-wui-table-pager]`,HTMLElement),te=Z(n,`[data-wui-table-status]`,HTMLElement),v={urlState:n.dataset.urlState!==`false`,filtersForm:n.dataset.filtersForm||null,filtersRegion:n.dataset.filtersRegion||null,searchInput:n.dataset.searchInput||null,loadingText:n.dataset.loadingText||Y().loadingText,errorText:n.dataset.errorText||Y().errorText,timeoutMs:(0,h.timeoutFromAttribute)(n.getAttribute(`data-wui-timeout`))??h.DEFAULT_TIMEOUT_MS},y=new URL(l,window.location.href),ne=n.dataset.totalSrc||null,re=ne===null?null:new URL(ne,window.location.href),ie=new Set([...y.searchParams.keys(),...re?.searchParams.keys()??[]]),ae=c.hasAttribute(`data-app-datatable-selectable`),b=new Set,x=!1,oe=(0,h.createRequestQueue)(),se=new AbortController,ce={signal:se.signal},le=Z(c,`:scope > tbody[data-wui-rows]`,HTMLTableSectionElement),S=(0,t.must)(le,`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`),C=Rr(S),ue=null,w=null,de=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))ie.has(n)||t.append(n,r);return t},fe=e=>de(new URL(e,window.location.href).search),T=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},E=(e,t)=>{let n=new URL(e.href);for(let[e,r]of t)ie.has(e)||n.searchParams.append(e,r);return n.origin===window.location.origin?`${n.pathname}${n.search}`:n.href},pe=e=>E(y,e),me=(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},D=me(v.urlState?de(window.location.search):new URLSearchParams,C);v.urlState&&T(D)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,T(D));let O=(e,t)=>i.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),k=e=>{te&&(te.textContent=e)},he=e=>{if(e.pending)return e.rowCount===0?Y().emptyLabel:(0,r.fillText)(Y().pageTextPending,{page:e.page});if(e.total===0)return Y().emptyLabel;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1,n=e.totalCapped?Hr(e.total,!0):`${e.total}`;return(0,r.fillText)(e.total===1?Y().pageTextOne:Y().pageTextOther,{page:e.page,pages:t,total:n})},A=()=>X(c,`:scope > thead > tr:first-child > th`,HTMLTableCellElement),ge=e=>{if(ae&&X(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.`)},_e=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`)}},j=e=>{if(ae){(0,_.addRowSelectCells)(e);for(let t of e){let e=Z(t,`.${_.SELECT_CELL_CLASS} .form-check-input:not(:disabled)`,HTMLInputElement);e&&(x&&b.add(t.dataset.rowKey),e.checked=b.has(t.dataset.rowKey))}(0,_.syncSelectAll)(c)}_e(e);let t=A();if(c.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`)})},ve=e=>j(X(e,`:scope > tr`,HTMLTableRowElement)),M=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},N=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),ye=(e,t)=>{if(!d)return;let n=Z(e,`:scope > template[data-wui-empty]`,HTMLTemplateElement);N(d),(t.pending?t.rowCount:t.total)===0&&n?(d.replaceChildren(n.content.cloneNode(!0)),d.hidden=!1):(d.replaceChildren(),d.hidden=!0)},be=e=>{f&&(N(f),f.replaceChildren(...e?[e.content.cloneNode(!0)]:[]),f.hidden=!1)},xe=e=>{let t=v.filtersRegion&&e?Z(document,v.filtersRegion,HTMLElement):null;return t&&e&&(N(t),t.replaceChildren(e.content.cloneNode(!0))),t},Se=0,Ce=e=>{let t=Rr(e);t.pending&&Object.assign(t,{total:C.total,totalCapped:C.totalCapped});let n=t.sortBy!==C.sortBy||t.sortOrder!==C.sortOrder?(0,a.measureRows)(S.rows):null;be(Z(e,`:scope > template[data-wui-pager]`,HTMLTemplateElement)),ye(e,t);let r=xe(Z(e,`:scope > template[data-wui-filters]`,HTMLTemplateElement));M(e),N(S),c.replaceChild(e,S),S=e,Se+=1;let o=x&&t.total!==C.total;return C=t,o&&(x=!1),i.removeAttribute(`data-wui-table-error`),ve(e),Ie(),(0,a.playRowMoves)(e.rows,n),o&&L(),r},we=e=>{let t=Z((0,p.parseServerHtml)(`<table>${e}</table>`),`tbody[data-wui-rows]`,HTMLTableSectionElement);return t&&ge(t),t?document.importNode(t,!0):null},Te=(e,t=A())=>{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},Ee=()=>{if(S.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,A().length);S.replaceChildren(...Array.from({length:Nr},()=>{let t=Te(e);return t.setAttribute(`data-wui-skeleton`,``),t})),i.removeAttribute(`data-wui-table-error`),d&&(d.hidden=!0)},De=e=>{e?(i.setAttribute(`aria-busy`,`true`),Ee()):i.removeAttribute(`aria-busy`)},P=e=>e===`forbidden`?Y().forbiddenMessage:e===`networkCheck`?(0,r.readText)(`httpFailure`,s.HTTP_FAILURE_TEXT).networkCheckText:e===`network`?Y().networkMessage:e===`timeout`?Y().timeoutMessage:v.errorText,Oe=t=>{let n=P(t);if(i.setAttribute(`data-wui-table-error`,t),f&&(f.hidden=!0),d){let r=document.createElement(`div`);r.className=`empty-state wui-empty-state-table wui-table-error`,r.setAttribute(`role`,`alert`);let i=document.createElement(`span`);i.className=`empty-state-icon`;let a=(0,g.glyphNode)(t===`forbidden`?`lock`:`alert-circle`,{size:24});a&&i.replaceChildren(a);let o=document.createElement(`div`);o.className=`empty-state-title`,o.textContent=n;let s=document.createElement(`div`);s.className=`empty-state-action`;let c=document.createElement(`button`);c.type=`button`,c.className=(0,e.buttonClass)(`primary`,`outline`,`sm`),c.dataset.wui=e.APP_BUTTON_MARKER,c.setAttribute(`data-wui-table-retry`,``),c.textContent=Y().retryLabel,s.append(c),r.append(i,o,s),N(d),d.replaceChildren(r),d.hidden=!1}k(n)},ke=()=>v.filtersForm?Z(document,v.filtersForm,HTMLFormElement):null,Ae=async(e,t=`none`,{quiet:r=!1}={})=>{let a=new URLSearchParams(e);r||(ue={query:a,mode:t},De(!0),k(v.loadingText)),O(`wui:table:loading`,{query:a.toString()});let s=await oe.run(pe(a),{timeoutMs:v.timeoutMs});if(s.kind===`aborted`||s.kind===`stale`||s.kind===`session`)return s;r||De(!1);let c=null;if(s.ok)try{c=we(s.html)}catch(e){(0,o.devError)(e)}if(!s.ok||!c){let e=s.ok?`server`:s.kind;return r?(0,o.devWarn)(`A quiet server table refresh failed; the rows on screen are kept.`,e):Oe(e),O(`wui:table:error`,{status:s.status,kind:e,message:P(e)}),s}let l=Ce(c);return D=me(a,C),Br(ke(),D),v.urlState&&t===`push`?window.history.pushState(window.history.state,``,T(D)):v.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,T(D)),r||k(he(C)),(0,m.wuiHost)().refresh(i),l&&(0,m.wuiHost)().refresh(l),C.pending?Pe():Ur(n,C.total,C.totalCapped),O(`wui:table:loaded`,{...C,query:D.toString()}),s},F=[],je=null,Me=()=>{if(F.length===0||i.getAttribute(`aria-busy`)===`true`)return;let e=F;F=[],Ae(D,`none`,{quiet:!0}).then(t=>{for(let n of e)n.resolve(t)},t=>{for(let n of e)n.reject(t)})},I=async(e,t=`none`,n={})=>{let r;try{r=await Ae(e,t,n)}catch(e){let t=F;F=[];for(let n of t)n.reject(e);throw e}r.kind===`session`&&(je=r);let a=r.kind===`aborted`&&i.getAttribute(`aria-busy`)===`true`;if(r.kind===`session`||r.kind===`aborted`&&!a){let e=F;F=[];for(let t of e)t.resolve(r)}return Me(),r},Ne=e=>(e.delete(`page`),e),Pe=()=>{if(!re||!C.pending)return;let e=Se;(0,h.wuiFetch)(E(re,D),{timeoutMs:v.timeoutMs}).then(t=>{if(e!==Se)return;if(!t.ok){(0,o.devWarn)(`[@webority/ui-elements] A server table's total did not load; its pager keeps Previous and Next.`,t.kind);return}let r=Z((0,p.parseServerHtml)(t.html),`div[data-wui-total]`,HTMLElement);if(!r){(0,o.devWarn)(`[@webority/ui-elements] A server table's count answer has no div[data-wui-total]; its pager keeps Previous and Next.`);return}if($(r.dataset.page,-1)!==C.page||$(r.dataset.pageSize,-1)!==C.pageSize)return;let i=$(r.dataset.total,-1);if(i<0){(0,o.devWarn)(`[@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=x&&i!==C.total;C={...C,total:i,totalCapped:a,pending:!1},s&&(x=!1);let c=Z(r,`:scope > template[data-wui-pager]`,HTMLTemplateElement);c&&be(c);let l=xe(Z(r,`:scope > template[data-wui-filters]`,HTMLTemplateElement));l&&(0,m.wuiHost)().refresh(l),Ur(n,C.total,C.totalCapped),k(he(C)),s&&L(),O(`wui:table:total`,{total:i,totalCapped:a})})},Fe=()=>X(c,`:scope > thead th[data-sort-key]`,HTMLTableCellElement),Ie=()=>{for(let e of Fe()){let t=e.dataset.sortKey===C.sortBy;e.setAttribute(`aria-sort`,t?C.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of Fe())if(e.classList.add(`sortable`),e.tabIndex=0,!e.querySelector(`.sort-icon`)){let t=e.classList.contains(`num`)||e.classList.contains(`text-end`),n=document.createElement(`span`);n.className=t?`sort-icon wui-sort-lead`:`sort-icon`;let r=(0,g.glyphNode)(`chevrons-up-down`,{size:14});r&&n.replaceChildren(r),t?e.prepend(n):e.append(n)}let Le=e=>{let t=Ne(new URLSearchParams(D)),n=C.sortBy===e&&C.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),I(t,`push`)};c.addEventListener(`click`,e=>{let t=e.target instanceof Element?Q(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&c.tHead?.contains(t)&&Le(t.dataset.sortKey??``)}),c.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof Element?Q(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&c.tHead?.contains(t)&&(e.preventDefault(),Le(t.dataset.sortKey??``))});let L=()=>{(0,_.syncSelectAll)(c),(0,_.syncGroupSelect)(c);let e=x?{selected:C.total,total:C.total,allMatching:x}:{selected:b.size,total:C.total};c.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};ae&&((0,_.attachShiftRange)(c,(e,t)=>{for(let n of e){let e=Q(n,`tr`,HTMLTableRowElement)?.dataset.rowKey;e&&(t?b.add(e):b.delete(e))}t||(x=!1)}),c.addEventListener(`change`,e=>{let t=e.target;if(t instanceof HTMLInputElement&&t.matches(`.${_.SELECT_CELL_CLASS} .form-check-input:not(:disabled)`)){if(t.checked||(x=!1),c.tHead?.contains(t))for(let e of X(S,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let n=Z(e,`.${_.SELECT_CELL_CLASS} .form-check-input:not(:disabled)`,HTMLInputElement);n&&(n.checked=t.checked,t.checked?b.add(e.dataset.rowKey):b.delete(e.dataset.rowKey))}else if(Q(t,`tr`,HTMLTableRowElement)?.classList.contains(`wui-group-row`)){let e=Q(t,`tr`,HTMLTableRowElement);for(let n=e?.nextElementSibling;n instanceof HTMLTableRowElement&&!n.matches(`tr.wui-group-row`);n=n.nextElementSibling){let e=Z(n,`.${_.SELECT_CELL_CLASS} .form-check-input:not(:disabled)`,HTMLInputElement),r=n.dataset.rowKey;e&&r&&(e.checked=t.checked,t.checked?b.add(r):b.delete(r))}}else{let e=Q(t,`tr`,HTMLTableRowElement)?.dataset.rowKey;if(!e)return;t.checked?b.add(e):b.delete(e)}L()}})),f&&(f.addEventListener(`click`,e=>{let t=e.target instanceof Element?Q(e.target,`a[href]`,HTMLAnchorElement):null;!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),I(fe(t.getAttribute(`href`)??``),`push`))}),f.addEventListener(`change`,e=>{let t=e.target;t instanceof HTMLSelectElement&&t.classList.contains(`tpg-select`)&&t.value&&(e.stopPropagation(),I(fe(t.value),`push`))}));let R=()=>{if(!v.searchInput)return null;let e=Z(document,v.searchInput,HTMLElement);return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:e?Z(e,`input`,HTMLInputElement):null},z=()=>n.isConnected?!0:(se.abort(),clearTimeout(w??void 0),!1),B=(e,t)=>{let n=[...e.elements].filter(Pr),r=new Set;for(let e of n)e.name&&!Ir(e)&&r.add(e.name);let i=[];for(let e of n)if(e.name&&!Fr(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},Re=(e,t)=>{let n=new Set([...e.elements].filter(Pr).map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&jr.includes(e);for(let[e,t]of D)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of B(e,t))a===``||i(n)||ie.has(n)||r.append(n,a);let a=R();if(a){r.delete(Mr);let e=a.value.trim();e&&r.set(Mr,e)}return I(r,`push`)},ze=e=>v.filtersForm&&e.closest?.(v.filtersForm)||v.filtersRegion&&e.closest?.(v.filtersRegion)||null;document.addEventListener(`submit`,e=>{z()&&v.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(v.filtersForm)&&(e.preventDefault(),Re(e.target,e.submitter))},ce),document.addEventListener(`change`,e=>{if(!z()||!v.filtersForm||!(e.target instanceof Element))return;let t=Q(e.target,v.filtersForm,HTMLFormElement);!t||e.target===R()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest(`wui-filter-popover`)||Re(t)},ce);let Be=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of X(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 X(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(Lr)){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(!z())return;let t=e.target instanceof Element?Q(e.target,`a[href]`,HTMLAnchorElement):null;if(!t||!ze(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=Ne(fe(n.href));Be(t.closest(`form`),r),Br(t.closest(`form`),r),I(r,`push`)},ce),document.addEventListener(`input`,e=>{if(!z())return;let t=R();t&&e.target===t&&(clearTimeout(w??void 0),w=setTimeout(()=>{if(!z())return;let e=Ne(new URLSearchParams(D)),n=t.value.trim();n?e.set(Mr,n):e.delete(Mr),e.toString()!==D.toString()&&I(e,`replace`)},300))},ce),v.urlState&&window.addEventListener(`popstate`,()=>{if(!z())return;let e=de(window.location.search),t=R();t&&(t.value=e.get(`search`)??``),Br(ke(),e),I(e,`none`)},ce),d?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`[data-wui-table-retry]`)&&ue&&I(ue.query,ue.mode)});let Ve=e=>[...S.rows].find(t=>t.dataset.rowKey===e)??null,He=e=>{if(!e?.trim())return null;let t=(0,p.parseServerHtml)(`<table><tbody>${e}</tbody></table>`);if(t.querySelector(`tbody[data-wui-rows]`))return null;let n=X(t,`table > tbody > tr[data-row-key]`,HTMLTableRowElement);return n.length?n.map(e=>document.importNode(e,!0)):null},Ue=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let a=[];for(let n of e){let e=n===r?t:Ve(n.dataset.rowKey);e&&(N(e),e.replaceWith(n),a.push(n))}return j(a),(0,m.wuiHost)().refresh(i),r},We=e=>e.message||(e.kind===`forbidden`?Y().actionForbiddenMessage:Y().actionFailedMessage),V=e=>{e?.isConnected&&e.getAttribute(a.ROW_SAVE_ATTR)===`saving`&&(0,a.setRowSaveState)(e,null)},H=async({url:e,method:r=`POST`,body:o,key:s,row:c}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let l=s==null,f=l?null:Ve(String(s));if(!l&&!f)throw Error(`saveRow found no row with data-row-key="${s}" on this page.`);let p=A().filter(e=>!e.classList.contains(_.SELECT_CELL_CLASS)),m=c===void 0?f??Te(Math.max(1,p.length),p):(0,t.elementOf)(c,HTMLTableRowElement,"saveRow's `row` is required to be a row element: the <tr> as it will read, not its HTML.");f&&m!==f?f.replaceWith(m):f||S.insertBefore(m,S.firstChild),m!==f&&j([m]),d&&!i.hasAttribute(`data-wui-table-error`)&&(d.hidden=!0),(0,a.setRowSaveState)(m,`saving`);let te=(0,a.rowLabel)(m),g=await(0,h.wuiFetch)(e,{method:r.toUpperCase(),body:o});if(g.kind===`session`)return!1;if(g.ok){if(!(0,u.isRefreshOff)(n)&&(0,u.reloadsPage)(g))return V(m),O(`wui:table:saved`,{key:l?null:String(s),added:l,status:g.status}),await(0,u.refreshAfter)(g,{origin:n}),!0;let e=He(g.html),t=e&&m.isConnected?Ue(e,m,l):null;return t&&k((0,a.savedText)((0,a.rowLabel)(t)||te)),(0,ee.showResultToast)(g,g.toastVariant||`success`),(0,u.isRefreshOff)(n)||await(0,u.refreshAfter)(g,{skip:t?n:null,origin:n}),V(m),O(`wui:table:saved`,{key:t?.dataset.rowKey??(l?null:String(s)),added:l,status:g.status}),!0}let v=We(g),y=m;return f&&m!==f&&m.isConnected?(m.replaceWith(f),y=f):l&&!c&&(m.remove(),y=null,d?.childElementCount&&!S.querySelector(`:scope > tr`)&&(d.hidden=!1)),y?.isConnected&&(0,a.setRowSaveState)(y,`error`,v),g.kind!==`aborted`&&zr(v,`danger`),k((0,a.notSavedText)(te,v)),O(`wui:table:failed`,{key:l?null:String(s),added:l,status:g.status,kind:g.kind,message:v}),!1},Ge=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=Q(e,`tr`,HTMLTableRowElement),i=r?.dataset.rowKey??null,o=e.dataset.wuiRowAction||``,s=r?(0,a.rowLabel)(r):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),r&&(0,a.setRowSaveState)(r,`saving`);let c=await(0,h.wuiFetch)(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),c.kind===`session`||c.kind===`aborted`)V(r);else if(c.ok&&!(0,u.isRefreshOff)(e)&&(0,u.reloadsPage)(c))V(r),O(`wui:table:action`,{action:o,key:i,ok:c.ok,status:c.status}),await(0,u.refreshAfter)(c,{origin:e});else{if(c.ok){(0,ee.showResultToast)(c,c.toastVariant||`success`);let t=r?.isConnected?He(c.html):null,i=t&&r?Ue(t,r,!1):null;i&&k((0,a.savedText)((0,a.rowLabel)(i)||s)),(0,u.isRefreshOff)(e)||await(0,u.refreshAfter)(c,{skip:i?n:null,origin:e}),V(r)}else{let e=We(c);zr(e,`danger`),r?.isConnected&&(0,a.setRowSaveState)(r,`error`,e),k((0,a.notSavedText)(s,e))}O(`wui:table:action`,{action:o,key:i,ok:c.ok,status:c.status})}};return c.addEventListener(`click`,e=>{let t=e.target instanceof Element?Q(e.target,`[data-wui-row-action]`,HTMLButtonElement):null;t&&S.contains(t)&&!t.disabled&&(e.preventDefault(),Ge(t))}),ge(S),M(S),ae&&(0,_.addSelectColumn)(c),ve(S),Ie(),C.pending&&(k(he(C)),Pe()),{el:n,reload:async e=>{if(je)return je;let t=e?.quiet===!0;return t&&i.getAttribute(`aria-busy`)===`true`?new Promise((e,t)=>{F.push({resolve:e,reject:t})}):I(D,`none`,{quiet:t})},query:()=>new URLSearchParams(D),setQuery:e=>{let t=new URLSearchParams(D);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`),I(t,`push`)},saveRow:H,setActiveRow:e=>{n.dataset.activeRowKey=e==null?``:String(e),_e(X(S,`:scope > tr`,HTMLTableRowElement))},selection:{keys:()=>[...b],count:()=>x?C.total:b.size,allMatching:()=>x,selectAllMatching:()=>{if(C.pending)(0,o.devWarn)(`[@webority/ui-elements] select all matching needs the total; the table is still waiting for its count.`);else{x=!0;for(let e of X(S,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let t=Z(e,`.${_.SELECT_CELL_CLASS} .form-check-input`,HTMLInputElement);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&b.add(e.dataset.rowKey))}L()}},clear:()=>{x=!1,b.clear();for(let e of X(S,`:scope > tr > .${_.SELECT_CELL_CLASS} .form-check-input:not(:disabled)`,HTMLInputElement))e.checked=!1;L()}}}}var Kr=ie({CONFIRM_DIALOG_ID:()=>W,CONFIRM_TONES:()=>Et,DISCARD_EVENT:()=>Yn,closeRemotePane:()=>Tt,confirmAction:()=>Bt,createDiscardPrompt:()=>cr,formValues:()=>On,getServerTable:()=>y.getServerTable,initDrawerDiscard:()=>Ar,initRemoteModals:()=>yt,initServerActions:()=>fn,initServerTables:()=>Wr,initUnsavedChanges:()=>Kn,loadRemoteDrawer:()=>St,loadRemoteModal:()=>bt,loadRemotePane:()=>wt,postAction:()=>en,resetUnsavedChanges:()=>qn});(0,ne.registerServer)(Kr)})(WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.loader,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.drawerText,WeborityUiElementsInternal.modules.dataTable,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.httpFailureText,WeborityUiElementsInternal.modules.flash,WeborityUiElementsInternal.modules.postError,WeborityUiElementsInternal.modules.refreshAfter,WeborityUiElementsInternal.modules.hasOwn,WeborityUiElementsInternal.modules.svgNodes,WeborityUiElementsInternal.modules.serverHtml,WeborityUiElementsInternal.modules.wuiHost,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.toastAction,WeborityUiElementsInternal.modules.toastHeader,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.tableSelect,WeborityUiElementsInternal.modules.dataTableText,WeborityUiElementsInternal.modules.serverTableRegistry,WeborityUiElementsInternal.modules.server);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o){var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.182.0`)throw Error(`[webority-ui] shell expects ui-elements 0.182.0 but the page loaded `+s+`.`);var c={accountMenuLabel:`Account menu for {name}`,collapseNavLabel:`Collapse navigation`,emptyText:`You are all caught up.`,expandNavLabel:`Expand navigation`,label:`Notifications`,logoutLabel:`Sign out`,moreLabel:`More`,navLabel:`Main navigation`,newLabel:`New`,noResultsForText:`No results for “{value}”`,noResultsText:`No results`,notificationsLoadErrorMessage:`Could not load notifications.`,openNavLabel:`Open navigation`,placeholder:`Search`,profileLabel:`My profile`,resultCountText:`{count} result`,resultsCountText:`{count} results`,retryLabel:`Retry`,roleLabel:`Role:`,rolesLabel:`Roles:`,searchResultsLabel:`Search results`,searchUnavailableMessage:`Search is unavailable right now.`,seeAllResultsForText:`See all results for “{query}”`,skipLabel:`Skip to content`,tabBarLabel:`Quick navigation`,togglePagesLabel:`Show or hide {name} pages`},l=()=>(0,n.readText)(`shell`,c),u=31536e3;function d(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?f(n):String(n)}var f=e=>e>99?`99+`:String(e),p=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,()=>String(n)),e);function m(e,t,n=document){try{n.cookie=`${e}=${t?`1`:`0`}; Path=/; Max-Age=${u}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}function h(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=${u}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}var g=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},_=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},v=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],y=e=>{if(!(e.target instanceof Element))throw Error(`event target is not an element`);return e.target},b=e=>{let t=e.getAttribute(`href`);if(t===null)throw Error(`search hit has no href`);return t},x=(e,t)=>{let n=document.createElement(`div`);return n.className=e,n.textContent=t,n},S=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),C=(e,t,n)=>`${e}${e.includes(`?`)?`&`:`?`}${encodeURIComponent(t)}=${encodeURIComponent(n)}`;function w(n,i){let o=(0,e.must)(g(n,`input.search-input`,HTMLInputElement),`search input missing`),s=g(n,`.wui-topsearch-results`,HTMLElement),c=()=>(0,e.must)(s,`search results missing`),u=g(n,`.wui-topsearch-open`,HTMLElement),d=g(n,`[data-wui-topsearch-live]`,HTMLElement),{src:f,param:m=`q`,resultsHref:h}=n.dataset,w=Number(n.dataset.minChars??2),T=Number(n.dataset.debounceMs??250),E=n.dataset.noResultsText??l().noResultsText,D=n.dataset.resultsCountText??l().resultsCountText,O=n.dataset.resultCountText??l().resultCountText,k=(0,a.createRequestQueue)(),A,j=-1,M=()=>v(c(),`.wui-topsearch-hit`,HTMLElement),N=e=>{let t=M();j=t.length===0?-1:(e+t.length)%t.length,t.forEach((e,t)=>{let n=t===j;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-selected`,n?`true`:`false`)});let n=j>=0?t[j]:void 0;n?(o.setAttribute(`aria-activedescendant`,n.id),n.scrollIntoView?.({block:`nearest`})):o.removeAttribute(`aria-activedescendant`)},P=()=>{c().hidden=!0,o.setAttribute(`aria-expanded`,`false`),o.removeAttribute(`aria-activedescendant`),j=-1},F=()=>{c().hidden=!1,o.setAttribute(`aria-expanded`,`true`)},I=e=>{n.classList.toggle(`is-open`,e),u?.setAttribute(`aria-expanded`,e?`true`:`false`)},L=e=>{let t=new CustomEvent(`wui:search:select`,{bubbles:!0,cancelable:!0,detail:{href:e}});n.dispatchEvent(t)&&window.location.assign(e)},R=async e=>{if(n.classList.add(`is-loading`),f===void 0)throw Error(`search has no data-src`);let t=await k.run(C(f,m,e));if(t.kind!==`aborted`&&t.kind!==`stale`&&t.kind!==`session`){if(n.classList.remove(`is-loading`),t.ok){let e=(0,r.parseServerHtml)(t.html),n=g(e,`[data-wui-count]`,HTMLElement);c().replaceChildren(e),M().forEach((e,t)=>{e.id=`${c().id}-opt-${t}`});let i=n?Number(n.getAttribute(`data-wui-count`)):M().length;d&&(d.textContent=i===0?E:p(i===1?O:D,{count:i}))}else c().replaceChildren(x(`wui-topsearch-empty`,l().searchUnavailableMessage));j=-1,F()}};o.addEventListener(`input`,()=>{clearTimeout(A);let e=o.value.trim();e.length<w?(k.abort(),n.classList.remove(`is-loading`),c().replaceChildren(),P()):A=setTimeout(()=>R(e),T)}),o.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(c().hidden||M().length===0)return;e.preventDefault(),N(j+(e.key===`ArrowDown`?1:-1))}else if((0,t.isImeSafeEnter)(e)){let t=M(),n=j>=0?t[j]:void 0;!c().hidden&&n?(e.preventDefault(),L(b(n))):h&&o.value.trim()!==``&&(e.preventDefault(),L(C(h,m,o.value.trim())))}else e.key===`Escape`&&(c().hidden?n.classList.contains(`is-open`)&&(e.preventDefault(),e.stopPropagation(),I(!1),u?.focus()):(e.preventDefault(),e.stopPropagation(),P()))}),c().addEventListener(`click`,e=>{let t=_(y(e),`.wui-topsearch-hit`,HTMLElement);!t||e.ctrlKey||e.metaKey||e.shiftKey||e.button===1||(e.preventDefault(),L(b(t)))}),u?.addEventListener(`click`,()=>{let e=!n.classList.contains(`is-open`);I(e),e&&o.focus()});let z=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||S(e.target)||(e.preventDefault(),I(!0),o.focus())},B=e=>{e.target instanceof Node&&n.contains(e.target)||(P(),n.classList.contains(`is-open`)&&I(!1))};document.addEventListener(`keydown`,z),document.addEventListener(`pointerdown`,B),i.push(()=>{clearTimeout(A),k.abort(),document.removeEventListener(`keydown`,z),document.removeEventListener(`pointerdown`,B)})}function T(e){let t=[],n=e.dataset.wuiCollapsedCookie;n&&e.addEventListener(`wui:shell:collapse`,e=>{m(n,!!e.detail?.collapsed)});let r=e.dataset.wuiFoldedCookie;r&&e.addEventListener(`wui:shell:nav-fold`,e=>{h(r,e.detail?.key,!!e.detail?.folded)}),e.addEventListener(`click`,t=>{y(t).closest(`[data-wui-tabbar-more]`)&&g(e,`[data-app-shell-menu]`,HTMLElement)?.click()});let a=g(e,`[data-wui-topsearch]`,HTMLElement);a&&w(a,t);let o={el:e,setTabCount(t,n,r){d(e,t,n,r)},get collapsed(){return e.classList.contains(`collapsed`)},set collapsed(t){if(!!t===e.classList.contains(`collapsed`))return;let n=g(e,`[data-app-shell-collapse]`,HTMLElement);n?n.click():e.classList.toggle(`collapsed`,!!t)}};(0,i.registerShell)(e,o);let s=n=>{if(n.target===e||n.target instanceof Node&&n.target.contains(e)){for(let e of t)e();(0,i.forgetShell)(e),delete e.dataset.wuiPartsWired,document.removeEventListener(`wui:teardown`,s)}};return document.addEventListener(`wui:teardown`,s),o}function E(e=document){let t=[];e instanceof HTMLElement&&e.matches(`[data-app-shell]`)&&t.push(e),t.push(...v(e,`[data-app-shell]`,HTMLElement));for(let e of t)e.dataset.wuiPartsWired||(e.dataset.wuiPartsWired=`1`,T(e))}function D(e){let t=_(e,`[data-app-shell]`,HTMLElement);return t?((0,i.wiredShell)(t)||E(t),(0,i.wiredShell)(t)):null}(0,o.registerShellParts)({getShell:D,initShellParts:E})})(WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.serverHtml,WeborityUiElementsInternal.modules.shellRegistry,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.server);
1
+ (function(e,t,n,r,i,a,o){var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.183.0`)throw Error(`[webority-ui] shell expects ui-elements 0.183.0 but the page loaded `+s+`.`);var c={accountMenuLabel:`Account menu for {name}`,collapseNavLabel:`Collapse navigation`,emptyText:`You are all caught up.`,expandNavLabel:`Expand navigation`,label:`Notifications`,logoutLabel:`Sign out`,moreLabel:`More`,navLabel:`Main navigation`,newLabel:`New`,noResultsForText:`No results for “{value}”`,noResultsText:`No results`,notificationsLoadErrorMessage:`Could not load notifications.`,openNavLabel:`Open navigation`,placeholder:`Search`,profileLabel:`My profile`,resultCountText:`{count} result`,resultsCountText:`{count} results`,retryLabel:`Retry`,roleLabel:`Role:`,rolesLabel:`Roles:`,searchResultsLabel:`Search results`,searchUnavailableMessage:`Search is unavailable right now.`,seeAllResultsForText:`See all results for “{query}”`,skipLabel:`Skip to content`,tabBarLabel:`Quick navigation`,togglePagesLabel:`Show or hide {name} pages`},l=()=>(0,n.readText)(`shell`,c),u=31536e3;function d(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?f(n):String(n)}var f=e=>e>99?`99+`:String(e),p=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,()=>String(n)),e);function m(e,t,n=document){try{n.cookie=`${e}=${t?`1`:`0`}; Path=/; Max-Age=${u}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}function h(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=${u}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}var g=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},_=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},v=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],y=e=>{if(!(e.target instanceof Element))throw Error(`event target is not an element`);return e.target},b=e=>{let t=e.getAttribute(`href`);if(t===null)throw Error(`search hit has no href`);return t},x=(e,t)=>{let n=document.createElement(`div`);return n.className=e,n.textContent=t,n},S=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),C=(e,t,n)=>`${e}${e.includes(`?`)?`&`:`?`}${encodeURIComponent(t)}=${encodeURIComponent(n)}`;function w(n,i){let o=(0,e.must)(g(n,`input.search-input`,HTMLInputElement),`search input missing`),s=g(n,`.wui-topsearch-results`,HTMLElement),c=()=>(0,e.must)(s,`search results missing`),u=g(n,`.wui-topsearch-open`,HTMLElement),d=g(n,`[data-wui-topsearch-live]`,HTMLElement),{src:f,param:m=`q`,resultsHref:h}=n.dataset,w=Number(n.dataset.minChars??2),T=Number(n.dataset.debounceMs??250),E=n.dataset.noResultsText??l().noResultsText,D=n.dataset.resultsCountText??l().resultsCountText,O=n.dataset.resultCountText??l().resultCountText,k=(0,a.createRequestQueue)(),A,j=-1,M=()=>v(c(),`.wui-topsearch-hit`,HTMLElement),N=e=>{let t=M();j=t.length===0?-1:(e+t.length)%t.length,t.forEach((e,t)=>{let n=t===j;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-selected`,n?`true`:`false`)});let n=j>=0?t[j]:void 0;n?(o.setAttribute(`aria-activedescendant`,n.id),n.scrollIntoView?.({block:`nearest`})):o.removeAttribute(`aria-activedescendant`)},P=()=>{c().hidden=!0,o.setAttribute(`aria-expanded`,`false`),o.removeAttribute(`aria-activedescendant`),j=-1},F=()=>{c().hidden=!1,o.setAttribute(`aria-expanded`,`true`)},I=e=>{n.classList.toggle(`is-open`,e),u?.setAttribute(`aria-expanded`,e?`true`:`false`)},L=e=>{let t=new CustomEvent(`wui:search:select`,{bubbles:!0,cancelable:!0,detail:{href:e}});n.dispatchEvent(t)&&window.location.assign(e)},R=async e=>{if(n.classList.add(`is-loading`),f===void 0)throw Error(`search has no data-src`);let t=await k.run(C(f,m,e));if(t.kind!==`aborted`&&t.kind!==`stale`&&t.kind!==`session`){if(n.classList.remove(`is-loading`),t.ok){let e=(0,r.parseServerHtml)(t.html),n=g(e,`[data-wui-count]`,HTMLElement);c().replaceChildren(e),M().forEach((e,t)=>{e.id=`${c().id}-opt-${t}`});let i=n?Number(n.getAttribute(`data-wui-count`)):M().length;d&&(d.textContent=i===0?E:p(i===1?O:D,{count:i}))}else c().replaceChildren(x(`wui-topsearch-empty`,l().searchUnavailableMessage));j=-1,F()}};o.addEventListener(`input`,()=>{clearTimeout(A);let e=o.value.trim();e.length<w?(k.abort(),n.classList.remove(`is-loading`),c().replaceChildren(),P()):A=setTimeout(()=>R(e),T)}),o.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(c().hidden||M().length===0)return;e.preventDefault(),N(j+(e.key===`ArrowDown`?1:-1))}else if((0,t.isImeSafeEnter)(e)){let t=M(),n=j>=0?t[j]:void 0;!c().hidden&&n?(e.preventDefault(),L(b(n))):h&&o.value.trim()!==``&&(e.preventDefault(),L(C(h,m,o.value.trim())))}else e.key===`Escape`&&(c().hidden?n.classList.contains(`is-open`)&&(e.preventDefault(),e.stopPropagation(),I(!1),u?.focus()):(e.preventDefault(),e.stopPropagation(),P()))}),c().addEventListener(`click`,e=>{let t=_(y(e),`.wui-topsearch-hit`,HTMLElement);!t||e.ctrlKey||e.metaKey||e.shiftKey||e.button===1||(e.preventDefault(),L(b(t)))}),u?.addEventListener(`click`,()=>{let e=!n.classList.contains(`is-open`);I(e),e&&o.focus()});let z=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||S(e.target)||(e.preventDefault(),I(!0),o.focus())},B=e=>{e.target instanceof Node&&n.contains(e.target)||(P(),n.classList.contains(`is-open`)&&I(!1))};document.addEventListener(`keydown`,z),document.addEventListener(`pointerdown`,B),i.push(()=>{clearTimeout(A),k.abort(),document.removeEventListener(`keydown`,z),document.removeEventListener(`pointerdown`,B)})}function T(e){let t=[],n=e.dataset.wuiCollapsedCookie;n&&e.addEventListener(`wui:shell:collapse`,e=>{m(n,!!e.detail?.collapsed)});let r=e.dataset.wuiFoldedCookie;r&&e.addEventListener(`wui:shell:nav-fold`,e=>{h(r,e.detail?.key,!!e.detail?.folded)}),e.addEventListener(`click`,t=>{y(t).closest(`[data-wui-tabbar-more]`)&&g(e,`[data-app-shell-menu]`,HTMLElement)?.click()});let a=g(e,`[data-wui-topsearch]`,HTMLElement);a&&w(a,t);let o={el:e,setTabCount(t,n,r){d(e,t,n,r)},get collapsed(){return e.classList.contains(`collapsed`)},set collapsed(t){if(!!t===e.classList.contains(`collapsed`))return;let n=g(e,`[data-app-shell-collapse]`,HTMLElement);n?n.click():e.classList.toggle(`collapsed`,!!t)}};(0,i.registerShell)(e,o);let s=n=>{if(n.target===e||n.target instanceof Node&&n.target.contains(e)){for(let e of t)e();(0,i.forgetShell)(e),delete e.dataset.wuiPartsWired,document.removeEventListener(`wui:teardown`,s)}};return document.addEventListener(`wui:teardown`,s),o}function E(e=document){let t=[];e instanceof HTMLElement&&e.matches(`[data-app-shell]`)&&t.push(e),t.push(...v(e,`[data-app-shell]`,HTMLElement));for(let e of t)e.dataset.wuiPartsWired||(e.dataset.wuiPartsWired=`1`,T(e))}function D(e){let t=_(e,`[data-app-shell]`,HTMLElement);return t?((0,i.wiredShell)(t)||E(t),(0,i.wiredShell)(t)):null}(0,o.registerShellParts)({getShell:D,initShellParts:E})})(WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.serverHtml,WeborityUiElementsInternal.modules.shellRegistry,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.server);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.182.0`)throw Error(`[webority-ui] shortcuts expects ui-elements 0.182.0 but the page loaded `+o+`.`);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=`wui-shortcuts-open-change`;function f(e,t){let n=e.querySelector(t);return n instanceof HTMLElement?n:null}function p(e,t){return[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement)}var m=class extends r.ElementBase{static get observedAttributes(){return[`open`,`no-trigger`]}constructor(){super(),u(this,`_doc`,void 0),u(this,`_onKeyDown`,void 0),u(this,`_onClick`,void 0),u(this,`_onDocClick`,void 0),u(this,`_onPointerDown`,void 0),u(this,`_onPressEnd`,void 0),u(this,`_pressedOpen`,void 0),u(this,`_pinned`,void 0),u(this,`_mirroring`,void 0),this._doc=null,this._pressedOpen=!1,this._pinned=!1,this._mirroring=!1,this._onKeyDown=e=>this._keydown(e),this._onClick=e=>this._click(e),this._onDocClick=e=>{let t=(0,n.closestOf)(e.target,`[data-wui-shortcuts-open]`)?.getAttribute(`data-wui-shortcuts-open`);t&&this.matches(t)&&this.setOpen(!0)},this._onPointerDown=e=>{(0,n.closestOf)(e.target,`.wui-shortcut-toggle`)&&(this._pressedOpen=this.open)},this._onPressEnd=e=>{e.type===`pointerup`&&(0,n.closestOf)(e.target,`.wui-shortcut-toggle`)||(this._pressedOpen=!1)}}connectedCallback(){this._doc=this.ownerDocument,this._doc.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`click`,this._onDocClick),this._doc.addEventListener(`pointerup`,this._onPressEnd,!0),this._doc.addEventListener(`pointercancel`,this._onPressEnd,!0),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.hasAttribute(`open`)&&!this.open&&(this._pinned=!0,this.setOpen(!0,{focus:!1})),this._syncTrigger()}attributeChangedCallback(e,t,n){e===`no-trigger`?this._syncTrigger():(this._mirroring||(this._pinned=n!==null),this._sheet()&&n!==null!==this.open&&this.setOpen(n!==null))}disconnectedCallback(){let e=this._sheet();e&&(0,i.closeAnchoredPopover)(e),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`click`,this._onDocClick),this._doc?.removeEventListener(`pointerup`,this._onPressEnd,!0),this._doc?.removeEventListener(`pointercancel`,this._onPressEnd,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this._doc=null}get open(){let e=this._sheet();return!!(e&&(0,i.isPopoverOpen)(e))}set open(e){let t=e===!0||e===``||e===`true`;this._pinned=t,this._sheet()?t!==this.open&&this.setOpen(t):this.toggleAttribute(`open`,t)}setOpen(e,{focus:t=!0}={}){let r=this._sheet();if(!r)return;let a=f(this,`.wui-shortcut-toggle`);if(e||(this._pinned=!1),e){r.removeAttribute(`hidden`);let e=this.hasAttribute(`no-trigger`)?a??this:(0,n.must)(a,`<wui-shortcuts> needs its toggle to anchor the sheet.`);(0,i.openAnchoredPopover)(e,r,{mode:`auto`,side:`top`,align:`end`,flipAlign:!0,gap:8,keepOffscreen:this._pinned,onClosed:()=>{this._pinned=!1,this._mirror(!1)}})}else(0,i.closeAnchoredPopover)(r);this._mirror(e),t&&(e?queueMicrotask(()=>{(0,i.isPopoverOpen)(r)&&f(r,`.wui-shortcut-close`)?.focus()}):a?.focus())}_mirror(e){let t=this._sheet();t&&(t.hidden=!e),f(this,`.wui-shortcut-toggle`)?.setAttribute(`aria-expanded`,String(e)),this.hasAttribute(`open`)!==e&&(this._mirroring=!0,this.toggleAttribute(`open`,e),this._mirroring=!1,this.dispatchEvent(new CustomEvent(d,{bubbles:!0,detail:{open:e}})))}_sheet(){return f(this,`.wui-shortcut-sheet`)}_syncTrigger(){let e=f(this,`.wui-shortcut-toggle`);e&&(e.hidden=this.hasAttribute(`no-trigger`))}_scope(){let e=this.closest(`[${a.SHORTCUT_SCOPE_ATTRIBUTE}]`);return e instanceof HTMLElement?e:null}_items(){let e=this.getAttribute(`items`);return e?p((0,n.must)(this._scope()??this._doc,`WuiShortcuts used before it was connected`),e):[]}_click(e){let t=e.target;if(t instanceof Element){if(t.closest(`.wui-shortcut-toggle`)){let e=this._pressedOpen;this._pressedOpen=!1,this.setOpen(!e&&!this.open)}else t.closest(`.wui-shortcut-close`)&&this.setOpen(!1)}}_tickFocused(){let e=this._items(),t=(0,n.must)(this._doc,`WuiShortcuts used before it was connected`).activeElement,r=t?.closest?.(`li, tr`),i=e.find(e=>e===t||e.contains(t)||r?.contains(e)),a=(i?.closest(`li, tr`)??i)?.querySelector(`input[type="checkbox"]`);a instanceof HTMLInputElement&&a.click()}_focusSearch(){let e=this.getAttribute(`search`);if(!e)return;let t=(0,n.must)(this._doc,`WuiShortcuts used before it was connected`);(f(this._scope()??t,e)??f(t,e))?.focus()}_keydown(e){if(e.defaultPrevented)return;let t=(0,a.shortcutName)(e);if(!t)return;if(t===`esc`&&this.open){e.preventDefault(),this.setOpen(!1);return}let r=this._scope(),i={help:()=>this.setOpen(!this.open)};if(this.getAttribute(`items`)&&(i.j=()=>(0,a.moveFocus)(this._items(),1),i.k=()=>(0,a.moveFocus)(this._items(),-1),i.x=()=>this._tickFocused()),this.getAttribute(`search`)&&(i.slash=()=>this._focusSearch()),i[t]){(0,a.runShortcut)(e,i,r);return}if(t===`enter`)return;let o=(0,n.must)(this._doc,`WuiShortcuts used before it was connected`),s=e.target instanceof Node?e.target:null;if((0,a.shortcutsOff)(o)||!(0,a.inShortcutScope)(s,r)||(0,a.isTypingTarget)(s))return;let c=(0,a.shortcutKey)(t),l=p(this,`.wui-shortcut-keys [data-shortcut]`).find(e=>e.dataset.shortcut===c);if(!l)return;let u=(r??o).querySelector(`[aria-current="true"]`)?.closest(`[data-key]`),d=u instanceof HTMLElement?u.dataset.key??null:null;if(!this.dispatchEvent(new CustomEvent(a.SHORTCUT_EVENT,{bubbles:!0,cancelable:!0,detail:{key:c,itemKey:d}}))){e.preventDefault();return}let m=l.dataset.target,h=m?f(o,m):null;h&&(e.preventDefault(),h.click())}};(0,t.defineElement)(`wui-shortcuts`,m),e.WuiShortcuts=m})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.shortcutKeys);
1
+ (function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.183.0`)throw Error(`[webority-ui] shortcuts expects ui-elements 0.183.0 but the page loaded `+o+`.`);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=`wui-shortcuts-open-change`;function f(e,t){let n=e.querySelector(t);return n instanceof HTMLElement?n:null}function p(e,t){return[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement)}var m=class extends r.ElementBase{static get observedAttributes(){return[`open`,`no-trigger`]}constructor(){super(),u(this,`_doc`,void 0),u(this,`_onKeyDown`,void 0),u(this,`_onClick`,void 0),u(this,`_onDocClick`,void 0),u(this,`_onPointerDown`,void 0),u(this,`_onPressEnd`,void 0),u(this,`_pressedOpen`,void 0),u(this,`_pinned`,void 0),u(this,`_mirroring`,void 0),this._doc=null,this._pressedOpen=!1,this._pinned=!1,this._mirroring=!1,this._onKeyDown=e=>this._keydown(e),this._onClick=e=>this._click(e),this._onDocClick=e=>{let t=(0,n.closestOf)(e.target,`[data-wui-shortcuts-open]`)?.getAttribute(`data-wui-shortcuts-open`);t&&this.matches(t)&&this.setOpen(!0)},this._onPointerDown=e=>{(0,n.closestOf)(e.target,`.wui-shortcut-toggle`)&&(this._pressedOpen=this.open)},this._onPressEnd=e=>{e.type===`pointerup`&&(0,n.closestOf)(e.target,`.wui-shortcut-toggle`)||(this._pressedOpen=!1)}}connectedCallback(){this._doc=this.ownerDocument,this._doc.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`click`,this._onDocClick),this._doc.addEventListener(`pointerup`,this._onPressEnd,!0),this._doc.addEventListener(`pointercancel`,this._onPressEnd,!0),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.hasAttribute(`open`)&&!this.open&&(this._pinned=!0,this.setOpen(!0,{focus:!1})),this._syncTrigger()}attributeChangedCallback(e,t,n){e===`no-trigger`?this._syncTrigger():(this._mirroring||(this._pinned=n!==null),this._sheet()&&n!==null!==this.open&&this.setOpen(n!==null))}disconnectedCallback(){let e=this._sheet();e&&(0,i.closeAnchoredPopover)(e),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`click`,this._onDocClick),this._doc?.removeEventListener(`pointerup`,this._onPressEnd,!0),this._doc?.removeEventListener(`pointercancel`,this._onPressEnd,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this._doc=null}get open(){let e=this._sheet();return!!(e&&(0,i.isPopoverOpen)(e))}set open(e){let t=e===!0||e===``||e===`true`;this._pinned=t,this._sheet()?t!==this.open&&this.setOpen(t):this.toggleAttribute(`open`,t)}setOpen(e,{focus:t=!0}={}){let r=this._sheet();if(!r)return;let a=f(this,`.wui-shortcut-toggle`);if(e||(this._pinned=!1),e){r.removeAttribute(`hidden`);let e=this.hasAttribute(`no-trigger`)?a??this:(0,n.must)(a,`<wui-shortcuts> needs its toggle to anchor the sheet.`);(0,i.openAnchoredPopover)(e,r,{mode:`auto`,side:`top`,align:`end`,flipAlign:!0,gap:8,keepOffscreen:this._pinned,onClosed:()=>{this._pinned=!1,this._mirror(!1)}})}else(0,i.closeAnchoredPopover)(r);this._mirror(e),t&&(e?queueMicrotask(()=>{(0,i.isPopoverOpen)(r)&&f(r,`.wui-shortcut-close`)?.focus()}):a?.focus())}_mirror(e){let t=this._sheet();t&&(t.hidden=!e),f(this,`.wui-shortcut-toggle`)?.setAttribute(`aria-expanded`,String(e)),this.hasAttribute(`open`)!==e&&(this._mirroring=!0,this.toggleAttribute(`open`,e),this._mirroring=!1,this.dispatchEvent(new CustomEvent(d,{bubbles:!0,detail:{open:e}})))}_sheet(){return f(this,`.wui-shortcut-sheet`)}_syncTrigger(){let e=f(this,`.wui-shortcut-toggle`);e&&(e.hidden=this.hasAttribute(`no-trigger`))}_scope(){let e=this.closest(`[${a.SHORTCUT_SCOPE_ATTRIBUTE}]`);return e instanceof HTMLElement?e:null}_items(){let e=this.getAttribute(`items`);return e?p((0,n.must)(this._scope()??this._doc,`WuiShortcuts used before it was connected`),e):[]}_click(e){let t=e.target;if(t instanceof Element){if(t.closest(`.wui-shortcut-toggle`)){let e=this._pressedOpen;this._pressedOpen=!1,this.setOpen(!e&&!this.open)}else t.closest(`.wui-shortcut-close`)&&this.setOpen(!1)}}_tickFocused(){let e=this._items(),t=(0,n.must)(this._doc,`WuiShortcuts used before it was connected`).activeElement,r=t?.closest?.(`li, tr`),i=e.find(e=>e===t||e.contains(t)||r?.contains(e)),a=(i?.closest(`li, tr`)??i)?.querySelector(`input[type="checkbox"]`);a instanceof HTMLInputElement&&a.click()}_focusSearch(){let e=this.getAttribute(`search`);if(!e)return;let t=(0,n.must)(this._doc,`WuiShortcuts used before it was connected`);(f(this._scope()??t,e)??f(t,e))?.focus()}_keydown(e){if(e.defaultPrevented)return;let t=(0,a.shortcutName)(e);if(!t)return;if(t===`esc`&&this.open){e.preventDefault(),this.setOpen(!1);return}let r=this._scope(),i={help:()=>this.setOpen(!this.open)};if(this.getAttribute(`items`)&&(i.j=()=>(0,a.moveFocus)(this._items(),1),i.k=()=>(0,a.moveFocus)(this._items(),-1),i.x=()=>this._tickFocused()),this.getAttribute(`search`)&&(i.slash=()=>this._focusSearch()),i[t]){(0,a.runShortcut)(e,i,r);return}if(t===`enter`)return;let o=(0,n.must)(this._doc,`WuiShortcuts used before it was connected`),s=e.target instanceof Node?e.target:null;if((0,a.shortcutsOff)(o)||!(0,a.inShortcutScope)(s,r)||(0,a.isTypingTarget)(s))return;let c=(0,a.shortcutKey)(t),l=p(this,`.wui-shortcut-keys [data-shortcut]`).find(e=>e.dataset.shortcut===c);if(!l)return;let u=(r??o).querySelector(`[aria-current="true"]`)?.closest(`[data-key]`),d=u instanceof HTMLElement?u.dataset.key??null:null;if(!this.dispatchEvent(new CustomEvent(a.SHORTCUT_EVENT,{bubbles:!0,cancelable:!0,detail:{key:c,itemKey:d}}))){e.preventDefault();return}let m=l.dataset.target,h=m?f(o,m):null;h&&(e.preventDefault(),h.click())}};(0,t.defineElement)(`wui-shortcuts`,m),e.WuiShortcuts=m})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.shortcutKeys);
@@ -1 +1 @@
1
- (function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=globalThis.WeborityUiElementsInternal?.version;if(a!==`0.182.0`)throw Error(`[webority-ui] show-more expects ui-elements 0.182.0 but the page loaded `+a+`.`);var o={lessLabel:`Show less`,moreLabel:`Show more`};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=3,f=()=>(0,i.readText)(`showMore`,o),p=class extends r.ElementBase{constructor(){super(),u(this,`_width`,void 0),u(this,`_observer`,void 0),u(this,`_toggle`,void 0),u(this,`_onClick`,void 0),this._width=-1,this._observer=null,this._toggle=null,this._onClick=()=>this.toggle()}connectedCallback(){let e=this.querySelector(`.wui-show-more-toggle`);if(this._toggle=e instanceof HTMLButtonElement?e:null,!this._toggle)return;let t=Number.parseInt(this.getAttribute(`lines`)??``,10);this.style.setProperty(`--wui-show-more-lines`,String(t>=1?t:d)),this._toggle.addEventListener(`click`,this._onClick),this._sync(),this._check(),typeof ResizeObserver<`u`&&(this._observer=new ResizeObserver(()=>{this.clientWidth!==this._width&&this._check()}),this._observer.observe(this))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._toggle?.removeEventListener(`click`,this._onClick),this._toggle=null}get expanded(){return this.hasAttribute(`expanded`)}toggle(e=!this.expanded){this.toggleAttribute(`expanded`,!!e),this._sync(),this.dispatchEvent(new CustomEvent(`wui:show-more:toggle`,{bubbles:!0,detail:{expanded:this.expanded}}))}_sync(){let e=(0,n.must)(this._toggle,`WuiShowMore used before it was connected`),t=this.expanded;e.setAttribute(`aria-expanded`,String(t)),e.textContent=t?this.getAttribute(`less-label`)||f().lessLabel:this.getAttribute(`more-label`)||f().moreLabel}_check(){let e=this.querySelector(`.wui-show-more-body`);if(!(e instanceof HTMLElement))return;this._width=this.clientWidth;let t=this.expanded;t&&this.removeAttribute(`expanded`);let r=e.scrollHeight>e.clientHeight+1;t&&this.setAttribute(`expanded`,``);let i=(0,n.must)(this._toggle,`WuiShowMore used before it was connected`);i.hidden=!r}};(0,t.defineElement)(`wui-show-more`,p),e.WuiShowMore=p})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,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.183.0`)throw Error(`[webority-ui] show-more expects ui-elements 0.183.0 but the page loaded `+a+`.`);var o={lessLabel:`Show less`,moreLabel:`Show more`};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=3,f=()=>(0,i.readText)(`showMore`,o),p=class extends r.ElementBase{constructor(){super(),u(this,`_width`,void 0),u(this,`_observer`,void 0),u(this,`_toggle`,void 0),u(this,`_onClick`,void 0),this._width=-1,this._observer=null,this._toggle=null,this._onClick=()=>this.toggle()}connectedCallback(){let e=this.querySelector(`.wui-show-more-toggle`);if(this._toggle=e instanceof HTMLButtonElement?e:null,!this._toggle)return;let t=Number.parseInt(this.getAttribute(`lines`)??``,10);this.style.setProperty(`--wui-show-more-lines`,String(t>=1?t:d)),this._toggle.addEventListener(`click`,this._onClick),this._sync(),this._check(),typeof ResizeObserver<`u`&&(this._observer=new ResizeObserver(()=>{this.clientWidth!==this._width&&this._check()}),this._observer.observe(this))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._toggle?.removeEventListener(`click`,this._onClick),this._toggle=null}get expanded(){return this.hasAttribute(`expanded`)}toggle(e=!this.expanded){this.toggleAttribute(`expanded`,!!e),this._sync(),this.dispatchEvent(new CustomEvent(`wui:show-more:toggle`,{bubbles:!0,detail:{expanded:this.expanded}}))}_sync(){let e=(0,n.must)(this._toggle,`WuiShowMore used before it was connected`),t=this.expanded;e.setAttribute(`aria-expanded`,String(t)),e.textContent=t?this.getAttribute(`less-label`)||f().lessLabel:this.getAttribute(`more-label`)||f().moreLabel}_check(){let e=this.querySelector(`.wui-show-more-body`);if(!(e instanceof HTMLElement))return;this._width=this.clientWidth;let t=this.expanded;t&&this.removeAttribute(`expanded`);let r=e.scrollHeight>e.clientHeight+1;t&&this.setAttribute(`expanded`,``);let i=(0,n.must)(this._toggle,`WuiShowMore used before it was connected`);i.hidden=!r}};(0,t.defineElement)(`wui-show-more`,p),e.WuiShowMore=p})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.textStore);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.182.0`)throw Error(`[webority-ui] slider expects ui-elements 0.182.0 but the page loaded `+s+`.`);var c=Object.freeze([`none`,`indian`]),l=e=>c.some(t=>t===e),u=e=>`grouping must be one of ${c.join(` or `)}, not "${String(e)}".`;function d(e){let t=/^(-?)(\d*)(\.\d*)?$/.exec(e);if(!t)return e;let[,n=``,r=``,i=``]=t;return r.length<=3?e:`${n}${(r.slice(0,-3).match(/\d{1,2}(?=(\d{2})*$)/g)??[]).join(`,`)},${r.slice(-3)}${i}`}var f={ariaLabel:`Value`,helpLabel:`More information`,maximumLabel:`Maximum`,minimumLabel:`Minimum`,optionalLabel:`(optional)`,rangeText:`{start} to {end}`};function p(e){"@babel/helpers - typeof";return p=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},p(e)}function m(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e){var t=m(e,`string`);return p(t)==`symbol`?t:t+``}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _=()=>(0,o.readText)(`slider`,f),v=class extends r.ElementBase{static get observedAttributes(){return[`min`,`max`,`step`,`value`,`start`,`end`,`name`,`start-name`,`end-name`,`disabled`,`readonly`,`loading`,`size`,`show-value`,`unit`,`grouping`,`aria-label`]}constructor(){super(),g(this,`_internals`,void 0),g(this,`_value`,void 0),g(this,`_start`,void 0),g(this,`_end`,void 0),g(this,`_isDragging`,void 0),g(this,`_dragThumb`,void 0),g(this,`_pointerDownListener`,void 0),g(this,`_pointerMoveListener`,void 0),g(this,`_pointerUpListener`,void 0),g(this,`_thumbKeyListener`,void 0),g(this,`_trackClickListener`,void 0),g(this,`_rendered`,void 0),g(this,`_defaultsCaptured`,void 0),g(this,`_defaultValue`,void 0),g(this,`_defaultStart`,void 0),g(this,`_defaultEnd`,void 0);try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=50,this._start=25,this._end=75,this._isDragging=!1,this._dragThumb=null,this._pointerDownListener=null,this._pointerMoveListener=null,this._pointerUpListener=null,this._thumbKeyListener=null,this._trackClickListener=null}connectedCallback(){this._rendered?this._wire():this.render()}get value(){return this._value}set value(e){this._value=this._snapToStep(this._clamp(y(e,this._value))),this._syncValue(),this._syncMirrors()}get start(){return this._start}set start(e){this._start=Math.min(this._snapToStep(this._clamp(y(e,this._start))),this._end),this._syncValue(),this._syncMirrors()}get end(){return this._end}set end(e){this._end=Math.max(this._snapToStep(this._clamp(y(e,this._end))),this._start),this._syncValue(),this._syncMirrors()}attributeChangedCallback(e,t,n){e===`value`||e===`start`||e===`end`||e===`min`||e===`max`||e===`step`?(this._updateFromAttribute(e),this._rendered&&(this._syncValue(),this._syncMirrors())):this._rendered&&this.render()}formResetCallback(){this._isRange()?this._resetRange():this._resetSingle()}_updateFromAttribute(e){e===`value`?this._value=this._snapToStep(this._clamp(y(this.getAttribute(`value`),this._value))):e===`start`?this._start=this._snapToStep(this._clamp(y(this.getAttribute(`start`),this._start))):e===`end`&&(this._end=this._snapToStep(this._clamp(y(this.getAttribute(`end`),this._end))))}_isRange(){return this.hasAttribute(`range`)}_min(){return y(this.getAttribute(`min`),0)}_max(){return y(this.getAttribute(`max`),100)}_step(){return y(this.getAttribute(`step`),1)}_clamp(e){return Math.max(this._min(),Math.min(e,this._max()))}_snapToStep(e){let t=this._step();if(t<=0)return e;let n=this._min();return this._clamp(n+Math.round((e-n)/t)*t)}_captureDefaults(){this._defaultsCaptured||=(this._isRange()?(this._defaultStart=this._start,this._defaultEnd=this._end):this._defaultValue=this._value,!0)}_resetSingle(){this._value=this._defaultValue??50,this._syncValue(),this._syncMirrors()}_resetRange(){this._start=this._defaultStart??25,this._end=this._defaultEnd??75,this._syncValue(),this._syncMirrors()}render(){this._captureDefaults();let e=this._min(),t=this._max(),r=this._isRange(),a=this.getAttribute(`size`),s=a===`sm`?` slider-sm`:a===`lg`?` slider-lg`:``,c=this.hasAttribute(`disabled`),l=this.hasAttribute(`readonly`);r?(this._start=this._clamp(this._start),this._end=this._clamp(this._end),this._start>this._end&&([this._start,this._end]=[this._end,this._start])):this._value=this._clamp(this._value);let u=r?[(0,n.make)(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`start`,"aria-label":_().minimumLabel,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._start,"aria-valuetext":this._formatValue(this._start),"aria-readonly":l?`true`:void 0,disabled:c}),(0,n.make)(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`end`,"aria-label":_().maximumLabel,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._end,"aria-valuetext":this._formatValue(this._end),"aria-readonly":l?`true`:void 0,disabled:c})]:[(0,n.make)(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`single`,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._value,"aria-valuetext":this._formatValue(this._value),"aria-readonly":l?`true`:void 0,disabled:c,"aria-label":this.getAttribute(`aria-label`)||_().ariaLabel})],d=(0,n.make)(`div`,{class:`wui-slider-rail`},(0,n.make)(`div`,{class:`slider-track`,role:`presentation`}),(0,n.make)(`div`,{class:`slider-fill`,role:`presentation`}),...u),f=this.hasAttribute(`show-value`)?(0,n.make)(`span`,{class:`slider-value`},r?(0,o.fillText)(_().rangeText,{start:this._formatValue(this._start),end:this._formatValue(this._end)}):this._formatValue(this._value)):!1;this.replaceChildren((0,n.make)(`div`,{class:`slider${s}`},d,f)),this._rendered=!0,this._placeParts(),this._syncMirrors(),(0,i.syncFieldState)(this,this.querySelector(`.slider`)),this._wire()}_formatValue(e){let t=this.getAttribute(`unit`)||``;return`${this._grouping()===`indian`?d(String(e)):String(e)}${t}`}_grouping(){let e=this.getAttribute(`grouping`)??`none`;if(!l(e))throw Error(u(e));return e}_placeParts(){let e=this._min(),t=this._max(),n=n=>t===e?0:(n-e)/(t-e),r=this._isRange(),i=r?n(this._start):0,a=n(r?this._end:this._value),o=b(this,`.slider-fill`);o&&(o.style.left=`${i*100}%`,o.style.right=`${100-a*100}%`,r&&o.style.setProperty(`--wui-fill-start`,String(i)),o.style.setProperty(`--wui-fill-end`,String(a)));let s=(e,t)=>{e&&(e.style.left=`${t*100}%`,e.style.setProperty(`--wui-t`,String(t)))};r?(s(b(this,`[data-thumb="start"]`),i),s(b(this,`[data-thumb="end"]`),a)):s(b(this,`.slider-thumb`),a)}_syncValue(){if(this._rendered){if(this._placeParts(),this._isRange()){let e=b(this,`[data-thumb="start"]`),t=b(this,`[data-thumb="end"]`);e&&(e.setAttribute(`aria-valuenow`,String(this._start)),e.setAttribute(`aria-valuetext`,this._formatValue(this._start))),t&&(t.setAttribute(`aria-valuenow`,String(this._end)),t.setAttribute(`aria-valuetext`,this._formatValue(this._end)));let n=b(this,`.slider-value`);n&&(n.textContent=(0,o.fillText)(_().rangeText,{start:this._formatValue(this._start),end:this._formatValue(this._end)}))}else{let e=b(this,`.slider-thumb`);e&&(e.setAttribute(`aria-valuenow`,String(this._value)),e.setAttribute(`aria-valuetext`,this._formatValue(this._value)));let t=b(this,`.slider-value`);t&&(t.textContent=this._formatValue(this._value))}}}_syncMirrors(){this._isRange()?this._syncRangeMirrors():this._syncSingleMirror()}_syncSingleMirror(){this.getAttribute(`name`)&&(0,a.syncFormMirror)(this,String(this._value))}_syncRangeMirrors(){let e=this.getAttribute(`start-name`),t=this.getAttribute(`end-name`);this._mirrorRange(`start`,e,this._start),this._mirrorRange(`end`,t,this._end)}_mirrorRange(e,t,n){if(!t)return;let r=x(this,`input[type="hidden"][data-slider-mirror="${e}"]`);r||(r=document.createElement(`input`),r.type=`hidden`,r.setAttribute(`data-slider-mirror`,e),this.appendChild(r)),r.name=t,r.value=String(n),r.disabled=this.hasAttribute(`disabled`)}_valueAtPosition(e){let t=b(this,`.slider-track`);if(!t)return this._min();let n=t.getBoundingClientRect(),r=b(this,`.slider-thumb`),i=r?r.offsetWidth/2:0,a=n.width-i*2,o=a>0?Math.max(0,Math.min(1,(e-n.left-i)/a)):0,s=this._min()+o*(this._max()-this._min());return this._snapToStep(s)}_nearestThumb(e){return Math.abs(e-this._start)<=Math.abs(e-this._end)?`start`:`end`}_wire(){if(this._teardown(),(0,i.isInert)(this))return;let e=S(this,`.slider-thumb`),t=b(this,`.slider-track`),n=this._isRange(),r=e=>{if((0,i.isInert)(this))return;let t=e.target;if(!(t instanceof Element))throw Error(`Pointer event target is not an element`);let n=t.closest(`.slider-thumb`);n&&(e.preventDefault(),this._isDragging=!0,this._dragThumb=n.getAttribute(`data-thumb`),document.addEventListener(`pointermove`,a),document.addEventListener(`pointerup`,o),document.addEventListener(`pointercancel`,o))},a=e=>{if(!this._isDragging)return;e.preventDefault();let t=this._valueAtPosition(e.clientX);if(this._dragThumb===`single`)this._value=this._clamp(t),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{value:this._value}}));else if(this._dragThumb===`start`){let e=Math.min(t,this._end);this._start=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}else if(this._dragThumb===`end`){let e=Math.max(t,this._start);this._end=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}},o=()=>{this._isDragging&&(this._isDragging=!1,this._dragThumb=null,document.removeEventListener(`pointermove`,a),document.removeEventListener(`pointerup`,o),document.removeEventListener(`pointercancel`,o),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},s=e=>{if(!(e.currentTarget instanceof HTMLElement))throw Error(`Keyboard event target is not an element`);let t=e.currentTarget;if((0,i.isInert)(this))return;let n=this._step(),r=n*10,a=null,o=t.getAttribute(`data-thumb`),s=o===`end`?this._end:o===`start`?this._start:this._value;e.key===`ArrowLeft`||e.key===`ArrowDown`?(e.preventDefault(),a=s-n):e.key===`ArrowRight`||e.key===`ArrowUp`?(e.preventDefault(),a=s+n):e.key===`PageDown`?(e.preventDefault(),a=s-r):e.key===`PageUp`?(e.preventDefault(),a=s+r):e.key===`Home`?(e.preventDefault(),a=this._min()):e.key===`End`&&(e.preventDefault(),a=this._max()),a!=null&&(a=this._clamp(a),o===`single`?this._value=a:o===`start`?this._start=Math.min(a,this._end):o===`end`&&(this._end=Math.max(a,this._start)),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},c=e=>{if((0,i.isInert)(this))return;let t=this._valueAtPosition(e.clientX);n?this._nearestThumb(t)===`start`?this._start=Math.min(this._clamp(t),this._end):this._end=Math.max(this._clamp(t),this._start):this._value=this._clamp(t),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))};this._pointerDownListener=r,this._pointerMoveListener=a,this._pointerUpListener=o,this._thumbKeyListener=s,this._trackClickListener=c,e.forEach(e=>{e.addEventListener(`pointerdown`,r),e.addEventListener(`keydown`,s)}),t?.addEventListener(`click`,c)}_teardown(){for(let e of S(this,`.slider-thumb`))this._pointerDownListener&&e.removeEventListener(`pointerdown`,this._pointerDownListener),this._thumbKeyListener&&e.removeEventListener(`keydown`,this._thumbKeyListener);this._pointerMoveListener&&document.removeEventListener(`pointermove`,this._pointerMoveListener),this._pointerUpListener&&(document.removeEventListener(`pointerup`,this._pointerUpListener),document.removeEventListener(`pointercancel`,this._pointerUpListener)),this._isDragging=!1,this._dragThumb=null;let e=b(this,`.slider-track`);e&&this._trackClickListener&&e.removeEventListener(`click`,this._trackClickListener)}disconnectedCallback(){this._teardown()}};g(v,`formAssociated`,!0);var y=(e,t)=>{let n=Number.parseFloat(String(e));return Number.isFinite(n)?n:t},b=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},x=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLInputElement?n:null},S=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement);(0,t.defineElement)(`wui-slider`,v),e.WuiSlider=v})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formMirror,WeborityUiElementsInternal.modules.textStore);
1
+ (function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.183.0`)throw Error(`[webority-ui] slider expects ui-elements 0.183.0 but the page loaded `+s+`.`);var c=Object.freeze([`none`,`indian`]),l=e=>c.some(t=>t===e),u=e=>`grouping must be one of ${c.join(` or `)}, not "${String(e)}".`;function d(e){let t=/^(-?)(\d*)(\.\d*)?$/.exec(e);if(!t)return e;let[,n=``,r=``,i=``]=t;return r.length<=3?e:`${n}${(r.slice(0,-3).match(/\d{1,2}(?=(\d{2})*$)/g)??[]).join(`,`)},${r.slice(-3)}${i}`}var f={ariaLabel:`Value`,helpLabel:`More information`,maximumLabel:`Maximum`,minimumLabel:`Minimum`,optionalLabel:`(optional)`,rangeText:`{start} to {end}`};function p(e){"@babel/helpers - typeof";return p=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},p(e)}function m(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e){var t=m(e,`string`);return p(t)==`symbol`?t:t+``}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _=()=>(0,o.readText)(`slider`,f),v=class extends r.ElementBase{static get observedAttributes(){return[`min`,`max`,`step`,`value`,`start`,`end`,`name`,`start-name`,`end-name`,`disabled`,`readonly`,`loading`,`size`,`show-value`,`unit`,`grouping`,`aria-label`]}constructor(){super(),g(this,`_internals`,void 0),g(this,`_value`,void 0),g(this,`_start`,void 0),g(this,`_end`,void 0),g(this,`_isDragging`,void 0),g(this,`_dragThumb`,void 0),g(this,`_pointerDownListener`,void 0),g(this,`_pointerMoveListener`,void 0),g(this,`_pointerUpListener`,void 0),g(this,`_thumbKeyListener`,void 0),g(this,`_trackClickListener`,void 0),g(this,`_rendered`,void 0),g(this,`_defaultsCaptured`,void 0),g(this,`_defaultValue`,void 0),g(this,`_defaultStart`,void 0),g(this,`_defaultEnd`,void 0);try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=50,this._start=25,this._end=75,this._isDragging=!1,this._dragThumb=null,this._pointerDownListener=null,this._pointerMoveListener=null,this._pointerUpListener=null,this._thumbKeyListener=null,this._trackClickListener=null}connectedCallback(){this._rendered?this._wire():this.render()}get value(){return this._value}set value(e){this._value=this._snapToStep(this._clamp(y(e,this._value))),this._syncValue(),this._syncMirrors()}get start(){return this._start}set start(e){this._start=Math.min(this._snapToStep(this._clamp(y(e,this._start))),this._end),this._syncValue(),this._syncMirrors()}get end(){return this._end}set end(e){this._end=Math.max(this._snapToStep(this._clamp(y(e,this._end))),this._start),this._syncValue(),this._syncMirrors()}attributeChangedCallback(e,t,n){e===`value`||e===`start`||e===`end`||e===`min`||e===`max`||e===`step`?(this._updateFromAttribute(e),this._rendered&&(this._syncValue(),this._syncMirrors())):this._rendered&&this.render()}formResetCallback(){this._isRange()?this._resetRange():this._resetSingle()}_updateFromAttribute(e){e===`value`?this._value=this._snapToStep(this._clamp(y(this.getAttribute(`value`),this._value))):e===`start`?this._start=this._snapToStep(this._clamp(y(this.getAttribute(`start`),this._start))):e===`end`&&(this._end=this._snapToStep(this._clamp(y(this.getAttribute(`end`),this._end))))}_isRange(){return this.hasAttribute(`range`)}_min(){return y(this.getAttribute(`min`),0)}_max(){return y(this.getAttribute(`max`),100)}_step(){return y(this.getAttribute(`step`),1)}_clamp(e){return Math.max(this._min(),Math.min(e,this._max()))}_snapToStep(e){let t=this._step();if(t<=0)return e;let n=this._min();return this._clamp(n+Math.round((e-n)/t)*t)}_captureDefaults(){this._defaultsCaptured||=(this._isRange()?(this._defaultStart=this._start,this._defaultEnd=this._end):this._defaultValue=this._value,!0)}_resetSingle(){this._value=this._defaultValue??50,this._syncValue(),this._syncMirrors()}_resetRange(){this._start=this._defaultStart??25,this._end=this._defaultEnd??75,this._syncValue(),this._syncMirrors()}render(){this._captureDefaults();let e=this._min(),t=this._max(),r=this._isRange(),a=this.getAttribute(`size`),s=a===`sm`?` slider-sm`:a===`lg`?` slider-lg`:``,c=this.hasAttribute(`disabled`),l=this.hasAttribute(`readonly`);r?(this._start=this._clamp(this._start),this._end=this._clamp(this._end),this._start>this._end&&([this._start,this._end]=[this._end,this._start])):this._value=this._clamp(this._value);let u=r?[(0,n.make)(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`start`,"aria-label":_().minimumLabel,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._start,"aria-valuetext":this._formatValue(this._start),"aria-readonly":l?`true`:void 0,disabled:c}),(0,n.make)(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`end`,"aria-label":_().maximumLabel,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._end,"aria-valuetext":this._formatValue(this._end),"aria-readonly":l?`true`:void 0,disabled:c})]:[(0,n.make)(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`single`,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._value,"aria-valuetext":this._formatValue(this._value),"aria-readonly":l?`true`:void 0,disabled:c,"aria-label":this.getAttribute(`aria-label`)||_().ariaLabel})],d=(0,n.make)(`div`,{class:`wui-slider-rail`},(0,n.make)(`div`,{class:`slider-track`,role:`presentation`}),(0,n.make)(`div`,{class:`slider-fill`,role:`presentation`}),...u),f=this.hasAttribute(`show-value`)?(0,n.make)(`span`,{class:`slider-value`},r?(0,o.fillText)(_().rangeText,{start:this._formatValue(this._start),end:this._formatValue(this._end)}):this._formatValue(this._value)):!1;this.replaceChildren((0,n.make)(`div`,{class:`slider${s}`},d,f)),this._rendered=!0,this._placeParts(),this._syncMirrors(),(0,i.syncFieldState)(this,this.querySelector(`.slider`)),this._wire()}_formatValue(e){let t=this.getAttribute(`unit`)||``;return`${this._grouping()===`indian`?d(String(e)):String(e)}${t}`}_grouping(){let e=this.getAttribute(`grouping`)??`none`;if(!l(e))throw Error(u(e));return e}_placeParts(){let e=this._min(),t=this._max(),n=n=>t===e?0:(n-e)/(t-e),r=this._isRange(),i=r?n(this._start):0,a=n(r?this._end:this._value),o=b(this,`.slider-fill`);o&&(o.style.left=`${i*100}%`,o.style.right=`${100-a*100}%`,r&&o.style.setProperty(`--wui-fill-start`,String(i)),o.style.setProperty(`--wui-fill-end`,String(a)));let s=(e,t)=>{e&&(e.style.left=`${t*100}%`,e.style.setProperty(`--wui-t`,String(t)))};r?(s(b(this,`[data-thumb="start"]`),i),s(b(this,`[data-thumb="end"]`),a)):s(b(this,`.slider-thumb`),a)}_syncValue(){if(this._rendered){if(this._placeParts(),this._isRange()){let e=b(this,`[data-thumb="start"]`),t=b(this,`[data-thumb="end"]`);e&&(e.setAttribute(`aria-valuenow`,String(this._start)),e.setAttribute(`aria-valuetext`,this._formatValue(this._start))),t&&(t.setAttribute(`aria-valuenow`,String(this._end)),t.setAttribute(`aria-valuetext`,this._formatValue(this._end)));let n=b(this,`.slider-value`);n&&(n.textContent=(0,o.fillText)(_().rangeText,{start:this._formatValue(this._start),end:this._formatValue(this._end)}))}else{let e=b(this,`.slider-thumb`);e&&(e.setAttribute(`aria-valuenow`,String(this._value)),e.setAttribute(`aria-valuetext`,this._formatValue(this._value)));let t=b(this,`.slider-value`);t&&(t.textContent=this._formatValue(this._value))}}}_syncMirrors(){this._isRange()?this._syncRangeMirrors():this._syncSingleMirror()}_syncSingleMirror(){this.getAttribute(`name`)&&(0,a.syncFormMirror)(this,String(this._value))}_syncRangeMirrors(){let e=this.getAttribute(`start-name`),t=this.getAttribute(`end-name`);this._mirrorRange(`start`,e,this._start),this._mirrorRange(`end`,t,this._end)}_mirrorRange(e,t,n){if(!t)return;let r=x(this,`input[type="hidden"][data-slider-mirror="${e}"]`);r||(r=document.createElement(`input`),r.type=`hidden`,r.setAttribute(`data-slider-mirror`,e),this.appendChild(r)),r.name=t,r.value=String(n),r.disabled=this.hasAttribute(`disabled`)}_valueAtPosition(e){let t=b(this,`.slider-track`);if(!t)return this._min();let n=t.getBoundingClientRect(),r=b(this,`.slider-thumb`),i=r?r.offsetWidth/2:0,a=n.width-i*2,o=a>0?Math.max(0,Math.min(1,(e-n.left-i)/a)):0,s=this._min()+o*(this._max()-this._min());return this._snapToStep(s)}_nearestThumb(e){return Math.abs(e-this._start)<=Math.abs(e-this._end)?`start`:`end`}_wire(){if(this._teardown(),(0,i.isInert)(this))return;let e=S(this,`.slider-thumb`),t=b(this,`.slider-track`),n=this._isRange(),r=e=>{if((0,i.isInert)(this))return;let t=e.target;if(!(t instanceof Element))throw Error(`Pointer event target is not an element`);let n=t.closest(`.slider-thumb`);n&&(e.preventDefault(),this._isDragging=!0,this._dragThumb=n.getAttribute(`data-thumb`),document.addEventListener(`pointermove`,a),document.addEventListener(`pointerup`,o),document.addEventListener(`pointercancel`,o))},a=e=>{if(!this._isDragging)return;e.preventDefault();let t=this._valueAtPosition(e.clientX);if(this._dragThumb===`single`)this._value=this._clamp(t),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{value:this._value}}));else if(this._dragThumb===`start`){let e=Math.min(t,this._end);this._start=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}else if(this._dragThumb===`end`){let e=Math.max(t,this._start);this._end=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}},o=()=>{this._isDragging&&(this._isDragging=!1,this._dragThumb=null,document.removeEventListener(`pointermove`,a),document.removeEventListener(`pointerup`,o),document.removeEventListener(`pointercancel`,o),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},s=e=>{if(!(e.currentTarget instanceof HTMLElement))throw Error(`Keyboard event target is not an element`);let t=e.currentTarget;if((0,i.isInert)(this))return;let n=this._step(),r=n*10,a=null,o=t.getAttribute(`data-thumb`),s=o===`end`?this._end:o===`start`?this._start:this._value;e.key===`ArrowLeft`||e.key===`ArrowDown`?(e.preventDefault(),a=s-n):e.key===`ArrowRight`||e.key===`ArrowUp`?(e.preventDefault(),a=s+n):e.key===`PageDown`?(e.preventDefault(),a=s-r):e.key===`PageUp`?(e.preventDefault(),a=s+r):e.key===`Home`?(e.preventDefault(),a=this._min()):e.key===`End`&&(e.preventDefault(),a=this._max()),a!=null&&(a=this._clamp(a),o===`single`?this._value=a:o===`start`?this._start=Math.min(a,this._end):o===`end`&&(this._end=Math.max(a,this._start)),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},c=e=>{if((0,i.isInert)(this))return;let t=this._valueAtPosition(e.clientX);n?this._nearestThumb(t)===`start`?this._start=Math.min(this._clamp(t),this._end):this._end=Math.max(this._clamp(t),this._start):this._value=this._clamp(t),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))};this._pointerDownListener=r,this._pointerMoveListener=a,this._pointerUpListener=o,this._thumbKeyListener=s,this._trackClickListener=c,e.forEach(e=>{e.addEventListener(`pointerdown`,r),e.addEventListener(`keydown`,s)}),t?.addEventListener(`click`,c)}_teardown(){for(let e of S(this,`.slider-thumb`))this._pointerDownListener&&e.removeEventListener(`pointerdown`,this._pointerDownListener),this._thumbKeyListener&&e.removeEventListener(`keydown`,this._thumbKeyListener);this._pointerMoveListener&&document.removeEventListener(`pointermove`,this._pointerMoveListener),this._pointerUpListener&&(document.removeEventListener(`pointerup`,this._pointerUpListener),document.removeEventListener(`pointercancel`,this._pointerUpListener)),this._isDragging=!1,this._dragThumb=null;let e=b(this,`.slider-track`);e&&this._trackClickListener&&e.removeEventListener(`click`,this._trackClickListener)}disconnectedCallback(){this._teardown()}};g(v,`formAssociated`,!0);var y=(e,t)=>{let n=Number.parseFloat(String(e));return Number.isFinite(n)?n:t},b=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},x=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLInputElement?n:null},S=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement);(0,t.defineElement)(`wui-slider`,v),e.WuiSlider=v})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formMirror,WeborityUiElementsInternal.modules.textStore);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.182.0`)throw Error(`[webority-ui] sortable expects ui-elements 0.182.0 but the page loaded `+o+`.`);var s={alreadyFirstText:`{label} is already first, {position}.`,alreadyLastText:`{label} is already last, {position}.`,destinationText:` to {destination}`,droppedText:`{label} dropped, {position}.`,liftedText:`{label} lifted, {position}. Use the arrow keys to move it, Space to drop it, Escape to cancel.`,movedPositionText:`{label} moved{destination}, position {position} of {total}.`,movedText:`{label} moved to {position}.`,positionText:`position {position} of {total}`,reorderCancelledText:`Reorder cancelled. {label} is back at {position}.`};function c(e){"@babel/helpers - typeof";return c=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},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var f=()=>(0,a.readText)(`sortable`,s),p=new Set,m=`.wui-sortable-handle`,h=`a[href],button,input,select,textarea,label,summary,[contenteditable='true'],[role='button'],[role='link']`,g=4,_=8,v=250,y=48,b=18,x=class extends n.ElementBase{static get observedAttributes(){return[`name`,`disabled`]}constructor(){super(),d(this,`_drag`,void 0),d(this,`_kb`,void 0),d(this,`_moving`,void 0),d(this,`controlled`,void 0),d(this,`_observer`,void 0),d(this,`_onDragStart`,void 0),d(this,`_onDocTouchMove`,void 0),d(this,`_onSelectStart`,void 0),this._drag=null,this._kb=null,this._moving=!1,this.controlled=!1,this._observer=null,this._onPointerDown=this._onPointerDown.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onDragStart=e=>e.preventDefault(),this._onDocMove=this._onDocMove.bind(this),this._onDocUp=this._onDocUp.bind(this),this._onDocCancel=this._onDocCancel.bind(this),this._onDocKey=this._onDocKey.bind(this),this._onDocTouchMove=e=>{this._drag?.started&&e.preventDefault()},this._onSelectStart=e=>e.preventDefault(),this._scrollTick=this._scrollTick.bind(this)}connectedCallback(){p.add(this),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`dragstart`,this._onDragStart),this._observer=new MutationObserver(()=>this._syncMirrors()),this._observer.observe(this,{childList:!0}),this._syncMirrors()}disconnectedCallback(){p.delete(this),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`dragstart`,this._onDragStart),this._observer?.disconnect(),this._observer=null,this._abort()}attributeChangedCallback(e){e===`disabled`&&this._abort(),this.isConnected&&this._syncMirrors()}get order(){return this._items().map(e=>e.getAttribute(`data-id`))}set order(e){if(this._drag?.started||this._kb)return;let t=this._items(),n=new Map(t.map(e=>[e.getAttribute(`data-id`),e])),r=[];for(let t of e??[]){let e=n.get(String(t));e&&!r.includes(e)&&r.push(e)}[...r,...t.filter(e=>!r.includes(e))].forEach((e,t)=>{let n=this._items()[t]??null;n!==e&&this.insertBefore(e,n)}),this._syncMirrors()}_items(){return[...this.querySelectorAll(`:scope > [data-id]`)].filter(e=>e instanceof HTMLElement)}_itemFrom(e){let t=e;for(;t&&t.parentElement!==this;)t=t.parentElement;return t instanceof HTMLElement&&t.hasAttribute(`data-id`)?t:null}_itemDisabled(e){return e.hasAttribute(`data-disabled`)}_horizontal(){return this.getAttribute(`orientation`)===`horizontal`}_syncMirrors(){(0,r.syncFormMirrors)(this,this.order.map(e=>e??``))}_insertAt(e,t){let n=this._items();if(n.indexOf(e)===t)return;let r=n.filter(t=>t!==e),i=r[t]??null;i?this.insertBefore(e,i):r.length>0?r[r.length-1]?.after(e):this.appendChild(e)}_indexFor(e,t,n){let r=this._items().filter(t=>t!==e),a=this._horizontal(),o=(0,i.isRtl)(this);for(let[e,i]of r.entries()){let r=i.getBoundingClientRect(),s=n<=r.bottom&&(o?t>r.left+r.width/2:t<r.left+r.width/2);if(a?n<r.top||s:n<r.top+r.height/2)return e}return r.length}_peers(){let e=this.getAttribute(`group`);return[...p].filter(t=>t===this||e&&t.getAttribute(`group`)===e&&!t.hasAttribute(`disabled`))}_labelOf(e){return e.getAttribute(`data-label`)||(e.textContent??``).replace(/\s+/g,` `).trim()||e.getAttribute(`data-id`)}_announce(e){let t=this.querySelector(`:scope > .wui-sortable-live`);t||(t=document.createElement(`div`),t.className=`wui-sortable-live`,t.setAttribute(`role`,`status`),t.setAttribute(`aria-live`,`polite`),t.setAttribute(`aria-atomic`,`true`),this.appendChild(t)),t.textContent=e}_position(e){let t=this._items();return(0,a.fillText)(f().positionText,{position:t.indexOf(e)+1,total:t.length})}_onPointerDown(e){if(this._drag||this._kb||this.hasAttribute(`disabled`)||e.pointerType===`mouse`&&e.button!==0)return;let t=e.target;if(!(t instanceof Element))return;let n=this._itemFrom(t);if(!n||this._itemDisabled(n))return;let r=n.querySelector(`:scope > ${m}`),i=!!r&&r.contains(t);if(this.hasAttribute(`handle`)&&!i)return;if(!i){let e=t.closest?.(h);if(e&&e!==n&&n.contains(e))return}let a=e.pointerType===`touch`&&!i,o={item:n,pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,x:e.clientX,y:e.clientY,slop:e.pointerType===`touch`?_:g,ready:!a,started:!1,timer:null,raf:0,list:this,ghost:null,offsetX:0,offsetY:0,fromIndex:0};this._drag=o,a&&(o.timer=setTimeout(()=>{o.timer=null,o.ready=!0,this._begin()},v)),document.addEventListener(`pointermove`,this._onDocMove),document.addEventListener(`pointerup`,this._onDocUp),document.addEventListener(`pointercancel`,this._onDocCancel),document.addEventListener(`keydown`,this._onDocKey,!0),document.addEventListener(`touchmove`,this._onDocTouchMove,{passive:!1})}_onDocMove(e){let t=this._drag;if(t&&e.pointerId===t.pointerId){if(t.x=e.clientX,t.y=e.clientY,!t.started){let e=Math.hypot(t.x-t.startX,t.y-t.startY);if(!t.ready){e>t.slop&&this._finish(!0);return}if(e<t.slop||(this._begin(),!this._drag?.started))return}e.preventDefault?.(),this._moveGhost(),this._update()}}_onDocUp(e){this._drag&&e.pointerId===this._drag.pointerId&&this._finish(!1)}_onDocCancel(e){this._drag&&e.pointerId===this._drag.pointerId&&this._finish(!0)}_onDocKey(e){e.key===`Escape`&&this._drag&&(e.preventDefault(),e.stopPropagation(),this._finish(!0))}_begin(){let e=this._drag;if(!e||e.started)return;e.started=!0;let t=e.item.getBoundingClientRect();e.offsetX=e.startX-t.left,e.offsetY=e.startY-t.top,e.fromIndex=this._items().indexOf(e.item);let n=e.item.cloneNode(!0);if(!(n instanceof HTMLElement))throw Error(`drag ghost is not an HTML element`);for(let e of[n,...n.querySelectorAll(`[id],[data-id]`)])e.removeAttribute(`id`),e.removeAttribute(`data-id`);n.classList.add(`wui-sortable-ghost`),n.setAttribute(`aria-hidden`,`true`),n.inert=!0,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,e.ghost=n,e.item.classList.add(`wui-sortable-dragging`),document.body.appendChild(n),document.documentElement.classList.add(`wui-sortable-active`),document.addEventListener(`selectstart`,this._onSelectStart),this._moveGhost(),e.raf=requestAnimationFrame(this._scrollTick),this._emit(this,`wui-sortable:start`,{id:e.item.getAttribute(`data-id`)})}_moveGhost(){let e=this._drag;e?.ghost&&(e.ghost.style.transform=`translate(${e.x-e.offsetX}px, ${e.y-e.offsetY}px)`)}_update(){let e=this._drag;if(!e?.started)return;let t=e.list;for(let n of this._peers()){let r=n.getBoundingClientRect();if(e.x>=r.left&&e.x<=r.right&&e.y>=r.top&&e.y<=r.bottom){t=n;break}}let n=t._indexFor(e.item,e.x,e.y);(t!==e.list||n!==t._items().indexOf(e.item))&&t._insertAt(e.item,n),e.list=t}_scrollTick(){let e=this._drag;if(!e?.started)return;let t=C(e.list),n=t?t.getBoundingClientRect():null,r=Math.max(n?.top??0,0),i=Math.min(n?.bottom??window.innerHeight,window.innerHeight),a=Math.max(n?.left??0,0),o=Math.min(n?.right??window.innerWidth,window.innerWidth),s=S(e.y,r,i),c=S(e.x,a,o);(c||s)&&(t?(t.scrollTop+=s,t.scrollLeft+=c):window.scrollBy(c,s),this._update()),e.raf=requestAnimationFrame(this._scrollTick)}_finish(e){let t=this._drag;if(!t||(this._drag=null,clearTimeout(t.timer??void 0),cancelAnimationFrame(t.raf),document.removeEventListener(`pointermove`,this._onDocMove),document.removeEventListener(`pointerup`,this._onDocUp),document.removeEventListener(`pointercancel`,this._onDocCancel),document.removeEventListener(`keydown`,this._onDocKey,!0),document.removeEventListener(`touchmove`,this._onDocTouchMove),document.removeEventListener(`selectstart`,this._onSelectStart),!t.started))return;t.ghost?.remove(),document.documentElement.classList.remove(`wui-sortable-active`),t.item.classList.remove(`wui-sortable-dragging`);let n=t.item.getAttribute(`data-id`);e?(this._insertAt(t.item,t.fromIndex),this._syncMirrors(),t.list!==this&&t.list._syncMirrors()):this._settle(t.item,this,t.fromIndex,t.list),this._emit(this,`wui-sortable:end`,{id:n,cancelled:e})}_settle(e,t,n,r){let i=r._items().indexOf(e);if(r===t&&i===n)return;let o=e.getAttribute(`data-id`),s=r.order,c=r!==t,l=t.order;c&&(t.controlled||r.controlled)&&t._insertAt(e,n),t._syncMirrors(),r._syncMirrors();let u=r._labelOf(e),d=c&&r.getAttribute(`aria-label`)?(0,a.fillText)(f().destinationText,{destination:String(r.getAttribute(`aria-label`))}):``,p={id:o,fromIndex:n,toIndex:i,from:t,to:r};c&&this._emit(t,`wui-sortable:change`,{...p,ids:l}),this._emit(r,`wui-sortable:change`,{...p,ids:s}),r._announce((0,a.fillText)(f().movedPositionText,{label:String(u),destination:d,position:i+1,total:s.length}))}_emit(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))}_abort(){this._drag&&this._finish(!0),this._kb&&this._dropKeyboard(!0)}_onKeyDown(e){if(this.hasAttribute(`disabled`))return;let t=e.target;if(!(t instanceof Element))return;let n=t.closest(m),r=n instanceof HTMLElement?n:null,o=r&&r.parentElement?.parentElement===this?r.parentElement:null;if(!r||!o||this._itemDisabled(o)||this._drag)return;let s=(0,i.mirrorKey)(e.key,(0,i.isRtl)(this));if(!this._kb){if(s!==` `&&s!==`Enter`)return;e.preventDefault(),this._liftKeyboard(o,r)}else if(this._kb.item===o){if(s===` `||s===`Enter`)e.preventDefault(),this._dropKeyboard(!1);else if(s===`Escape`)e.preventDefault(),e.stopPropagation(),this._dropKeyboard(!0);else if([`ArrowUp`,`ArrowLeft`,`ArrowDown`,`ArrowRight`,`Home`,`End`].includes(s)){e.preventDefault();let t=this._items(),n=t.indexOf(o),i=t.length-1,c=s===`Home`?0:s===`End`?i:Math.max(0,Math.min(i,n+(s===`ArrowUp`||s===`ArrowLeft`?-1:1)));if(c===n){let e=f();this._announce((0,a.fillText)(n===0?e.alreadyFirstText:e.alreadyLastText,{label:String(this._labelOf(o)),position:this._position(o)}));return}this._moveFocused(()=>this._insertAt(o,c),r),this._announce((0,a.fillText)(f().movedText,{label:String(this._labelOf(o)),position:this._position(o)}))}}}_onFocusOut(e){if(!this._kb||this._moving)return;let t=e.relatedTarget;if(t&&!(t instanceof Node))throw Error(`focus moved to a non-node target`);t&&this._kb.handle.contains(t)||this._dropKeyboard(!1)}_liftKeyboard(e,t){this._kb={item:e,handle:t,fromIndex:this._items().indexOf(e)},t.setAttribute(`aria-pressed`,`true`),this._announce((0,a.fillText)(f().liftedText,{label:String(this._labelOf(e)),position:this._position(e)}))}_dropKeyboard(e){let t=this._kb;t&&(this._kb=null,t.handle.removeAttribute(`aria-pressed`),e?(this._moveFocused(()=>this._insertAt(t.item,t.fromIndex),t.handle),this._announce((0,a.fillText)(f().reorderCancelledText,{label:String(this._labelOf(t.item)),position:this._position(t.item)}))):this._items().indexOf(t.item)===t.fromIndex?this._announce((0,a.fillText)(f().droppedText,{label:String(this._labelOf(t.item)),position:this._position(t.item)})):this._settle(t.item,this,t.fromIndex,this))}_moveFocused(e,t){this._moving=!0;let n=this.contains(document.activeElement);e(),n&&document.activeElement!==t&&t.focus(),this._moving=!1}};function S(e,t,n){return e<t+y?-Math.ceil(b*Math.min(1,(t+y-e)/y)):e>n-y?Math.ceil(b*Math.min(1,(e-(n-y))/y)):0}function C(e){for(let t=e.parentElement;t&&t!==document.body&&t!==document.documentElement;t=t.parentElement){let e=getComputedStyle(t),n=/(auto|scroll)/.test(e.overflowY)&&t.scrollHeight>t.clientHeight,r=/(auto|scroll)/.test(e.overflowX)&&t.scrollWidth>t.clientWidth;if(n||r)return t}return null}(0,t.defineElement)(`wui-sortable`,x),e.WuiSortable=x})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formMirror,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore);
1
+ (function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.183.0`)throw Error(`[webority-ui] sortable expects ui-elements 0.183.0 but the page loaded `+o+`.`);var s={alreadyFirstText:`{label} is already first, {position}.`,alreadyLastText:`{label} is already last, {position}.`,destinationText:` to {destination}`,droppedText:`{label} dropped, {position}.`,liftedText:`{label} lifted, {position}. Use the arrow keys to move it, Space to drop it, Escape to cancel.`,movedPositionText:`{label} moved{destination}, position {position} of {total}.`,movedText:`{label} moved to {position}.`,positionText:`position {position} of {total}`,reorderCancelledText:`Reorder cancelled. {label} is back at {position}.`};function c(e){"@babel/helpers - typeof";return c=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},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var f=()=>(0,a.readText)(`sortable`,s),p=new Set,m=`.wui-sortable-handle`,h=`a[href],button,input,select,textarea,label,summary,[contenteditable='true'],[role='button'],[role='link']`,g=4,_=8,v=250,y=48,b=18,x=class extends n.ElementBase{static get observedAttributes(){return[`name`,`disabled`]}constructor(){super(),d(this,`_drag`,void 0),d(this,`_kb`,void 0),d(this,`_moving`,void 0),d(this,`controlled`,void 0),d(this,`_observer`,void 0),d(this,`_onDragStart`,void 0),d(this,`_onDocTouchMove`,void 0),d(this,`_onSelectStart`,void 0),this._drag=null,this._kb=null,this._moving=!1,this.controlled=!1,this._observer=null,this._onPointerDown=this._onPointerDown.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onDragStart=e=>e.preventDefault(),this._onDocMove=this._onDocMove.bind(this),this._onDocUp=this._onDocUp.bind(this),this._onDocCancel=this._onDocCancel.bind(this),this._onDocKey=this._onDocKey.bind(this),this._onDocTouchMove=e=>{this._drag?.started&&e.preventDefault()},this._onSelectStart=e=>e.preventDefault(),this._scrollTick=this._scrollTick.bind(this)}connectedCallback(){p.add(this),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`dragstart`,this._onDragStart),this._observer=new MutationObserver(()=>this._syncMirrors()),this._observer.observe(this,{childList:!0}),this._syncMirrors()}disconnectedCallback(){p.delete(this),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`dragstart`,this._onDragStart),this._observer?.disconnect(),this._observer=null,this._abort()}attributeChangedCallback(e){e===`disabled`&&this._abort(),this.isConnected&&this._syncMirrors()}get order(){return this._items().map(e=>e.getAttribute(`data-id`))}set order(e){if(this._drag?.started||this._kb)return;let t=this._items(),n=new Map(t.map(e=>[e.getAttribute(`data-id`),e])),r=[];for(let t of e??[]){let e=n.get(String(t));e&&!r.includes(e)&&r.push(e)}[...r,...t.filter(e=>!r.includes(e))].forEach((e,t)=>{let n=this._items()[t]??null;n!==e&&this.insertBefore(e,n)}),this._syncMirrors()}_items(){return[...this.querySelectorAll(`:scope > [data-id]`)].filter(e=>e instanceof HTMLElement)}_itemFrom(e){let t=e;for(;t&&t.parentElement!==this;)t=t.parentElement;return t instanceof HTMLElement&&t.hasAttribute(`data-id`)?t:null}_itemDisabled(e){return e.hasAttribute(`data-disabled`)}_horizontal(){return this.getAttribute(`orientation`)===`horizontal`}_syncMirrors(){(0,r.syncFormMirrors)(this,this.order.map(e=>e??``))}_insertAt(e,t){let n=this._items();if(n.indexOf(e)===t)return;let r=n.filter(t=>t!==e),i=r[t]??null;i?this.insertBefore(e,i):r.length>0?r[r.length-1]?.after(e):this.appendChild(e)}_indexFor(e,t,n){let r=this._items().filter(t=>t!==e),a=this._horizontal(),o=(0,i.isRtl)(this);for(let[e,i]of r.entries()){let r=i.getBoundingClientRect(),s=n<=r.bottom&&(o?t>r.left+r.width/2:t<r.left+r.width/2);if(a?n<r.top||s:n<r.top+r.height/2)return e}return r.length}_peers(){let e=this.getAttribute(`group`);return[...p].filter(t=>t===this||e&&t.getAttribute(`group`)===e&&!t.hasAttribute(`disabled`))}_labelOf(e){return e.getAttribute(`data-label`)||(e.textContent??``).replace(/\s+/g,` `).trim()||e.getAttribute(`data-id`)}_announce(e){let t=this.querySelector(`:scope > .wui-sortable-live`);t||(t=document.createElement(`div`),t.className=`wui-sortable-live`,t.setAttribute(`role`,`status`),t.setAttribute(`aria-live`,`polite`),t.setAttribute(`aria-atomic`,`true`),this.appendChild(t)),t.textContent=e}_position(e){let t=this._items();return(0,a.fillText)(f().positionText,{position:t.indexOf(e)+1,total:t.length})}_onPointerDown(e){if(this._drag||this._kb||this.hasAttribute(`disabled`)||e.pointerType===`mouse`&&e.button!==0)return;let t=e.target;if(!(t instanceof Element))return;let n=this._itemFrom(t);if(!n||this._itemDisabled(n))return;let r=n.querySelector(`:scope > ${m}`),i=!!r&&r.contains(t);if(this.hasAttribute(`handle`)&&!i)return;if(!i){let e=t.closest?.(h);if(e&&e!==n&&n.contains(e))return}let a=e.pointerType===`touch`&&!i,o={item:n,pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,x:e.clientX,y:e.clientY,slop:e.pointerType===`touch`?_:g,ready:!a,started:!1,timer:null,raf:0,list:this,ghost:null,offsetX:0,offsetY:0,fromIndex:0};this._drag=o,a&&(o.timer=setTimeout(()=>{o.timer=null,o.ready=!0,this._begin()},v)),document.addEventListener(`pointermove`,this._onDocMove),document.addEventListener(`pointerup`,this._onDocUp),document.addEventListener(`pointercancel`,this._onDocCancel),document.addEventListener(`keydown`,this._onDocKey,!0),document.addEventListener(`touchmove`,this._onDocTouchMove,{passive:!1})}_onDocMove(e){let t=this._drag;if(t&&e.pointerId===t.pointerId){if(t.x=e.clientX,t.y=e.clientY,!t.started){let e=Math.hypot(t.x-t.startX,t.y-t.startY);if(!t.ready){e>t.slop&&this._finish(!0);return}if(e<t.slop||(this._begin(),!this._drag?.started))return}e.preventDefault?.(),this._moveGhost(),this._update()}}_onDocUp(e){this._drag&&e.pointerId===this._drag.pointerId&&this._finish(!1)}_onDocCancel(e){this._drag&&e.pointerId===this._drag.pointerId&&this._finish(!0)}_onDocKey(e){e.key===`Escape`&&this._drag&&(e.preventDefault(),e.stopPropagation(),this._finish(!0))}_begin(){let e=this._drag;if(!e||e.started)return;e.started=!0;let t=e.item.getBoundingClientRect();e.offsetX=e.startX-t.left,e.offsetY=e.startY-t.top,e.fromIndex=this._items().indexOf(e.item);let n=e.item.cloneNode(!0);if(!(n instanceof HTMLElement))throw Error(`drag ghost is not an HTML element`);for(let e of[n,...n.querySelectorAll(`[id],[data-id]`)])e.removeAttribute(`id`),e.removeAttribute(`data-id`);n.classList.add(`wui-sortable-ghost`),n.setAttribute(`aria-hidden`,`true`),n.inert=!0,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,e.ghost=n,e.item.classList.add(`wui-sortable-dragging`),document.body.appendChild(n),document.documentElement.classList.add(`wui-sortable-active`),document.addEventListener(`selectstart`,this._onSelectStart),this._moveGhost(),e.raf=requestAnimationFrame(this._scrollTick),this._emit(this,`wui-sortable:start`,{id:e.item.getAttribute(`data-id`)})}_moveGhost(){let e=this._drag;e?.ghost&&(e.ghost.style.transform=`translate(${e.x-e.offsetX}px, ${e.y-e.offsetY}px)`)}_update(){let e=this._drag;if(!e?.started)return;let t=e.list;for(let n of this._peers()){let r=n.getBoundingClientRect();if(e.x>=r.left&&e.x<=r.right&&e.y>=r.top&&e.y<=r.bottom){t=n;break}}let n=t._indexFor(e.item,e.x,e.y);(t!==e.list||n!==t._items().indexOf(e.item))&&t._insertAt(e.item,n),e.list=t}_scrollTick(){let e=this._drag;if(!e?.started)return;let t=C(e.list),n=t?t.getBoundingClientRect():null,r=Math.max(n?.top??0,0),i=Math.min(n?.bottom??window.innerHeight,window.innerHeight),a=Math.max(n?.left??0,0),o=Math.min(n?.right??window.innerWidth,window.innerWidth),s=S(e.y,r,i),c=S(e.x,a,o);(c||s)&&(t?(t.scrollTop+=s,t.scrollLeft+=c):window.scrollBy(c,s),this._update()),e.raf=requestAnimationFrame(this._scrollTick)}_finish(e){let t=this._drag;if(!t||(this._drag=null,clearTimeout(t.timer??void 0),cancelAnimationFrame(t.raf),document.removeEventListener(`pointermove`,this._onDocMove),document.removeEventListener(`pointerup`,this._onDocUp),document.removeEventListener(`pointercancel`,this._onDocCancel),document.removeEventListener(`keydown`,this._onDocKey,!0),document.removeEventListener(`touchmove`,this._onDocTouchMove),document.removeEventListener(`selectstart`,this._onSelectStart),!t.started))return;t.ghost?.remove(),document.documentElement.classList.remove(`wui-sortable-active`),t.item.classList.remove(`wui-sortable-dragging`);let n=t.item.getAttribute(`data-id`);e?(this._insertAt(t.item,t.fromIndex),this._syncMirrors(),t.list!==this&&t.list._syncMirrors()):this._settle(t.item,this,t.fromIndex,t.list),this._emit(this,`wui-sortable:end`,{id:n,cancelled:e})}_settle(e,t,n,r){let i=r._items().indexOf(e);if(r===t&&i===n)return;let o=e.getAttribute(`data-id`),s=r.order,c=r!==t,l=t.order;c&&(t.controlled||r.controlled)&&t._insertAt(e,n),t._syncMirrors(),r._syncMirrors();let u=r._labelOf(e),d=c&&r.getAttribute(`aria-label`)?(0,a.fillText)(f().destinationText,{destination:String(r.getAttribute(`aria-label`))}):``,p={id:o,fromIndex:n,toIndex:i,from:t,to:r};c&&this._emit(t,`wui-sortable:change`,{...p,ids:l}),this._emit(r,`wui-sortable:change`,{...p,ids:s}),r._announce((0,a.fillText)(f().movedPositionText,{label:String(u),destination:d,position:i+1,total:s.length}))}_emit(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))}_abort(){this._drag&&this._finish(!0),this._kb&&this._dropKeyboard(!0)}_onKeyDown(e){if(this.hasAttribute(`disabled`))return;let t=e.target;if(!(t instanceof Element))return;let n=t.closest(m),r=n instanceof HTMLElement?n:null,o=r&&r.parentElement?.parentElement===this?r.parentElement:null;if(!r||!o||this._itemDisabled(o)||this._drag)return;let s=(0,i.mirrorKey)(e.key,(0,i.isRtl)(this));if(!this._kb){if(s!==` `&&s!==`Enter`)return;e.preventDefault(),this._liftKeyboard(o,r)}else if(this._kb.item===o){if(s===` `||s===`Enter`)e.preventDefault(),this._dropKeyboard(!1);else if(s===`Escape`)e.preventDefault(),e.stopPropagation(),this._dropKeyboard(!0);else if([`ArrowUp`,`ArrowLeft`,`ArrowDown`,`ArrowRight`,`Home`,`End`].includes(s)){e.preventDefault();let t=this._items(),n=t.indexOf(o),i=t.length-1,c=s===`Home`?0:s===`End`?i:Math.max(0,Math.min(i,n+(s===`ArrowUp`||s===`ArrowLeft`?-1:1)));if(c===n){let e=f();this._announce((0,a.fillText)(n===0?e.alreadyFirstText:e.alreadyLastText,{label:String(this._labelOf(o)),position:this._position(o)}));return}this._moveFocused(()=>this._insertAt(o,c),r),this._announce((0,a.fillText)(f().movedText,{label:String(this._labelOf(o)),position:this._position(o)}))}}}_onFocusOut(e){if(!this._kb||this._moving)return;let t=e.relatedTarget;if(t&&!(t instanceof Node))throw Error(`focus moved to a non-node target`);t&&this._kb.handle.contains(t)||this._dropKeyboard(!1)}_liftKeyboard(e,t){this._kb={item:e,handle:t,fromIndex:this._items().indexOf(e)},t.setAttribute(`aria-pressed`,`true`),this._announce((0,a.fillText)(f().liftedText,{label:String(this._labelOf(e)),position:this._position(e)}))}_dropKeyboard(e){let t=this._kb;t&&(this._kb=null,t.handle.removeAttribute(`aria-pressed`),e?(this._moveFocused(()=>this._insertAt(t.item,t.fromIndex),t.handle),this._announce((0,a.fillText)(f().reorderCancelledText,{label:String(this._labelOf(t.item)),position:this._position(t.item)}))):this._items().indexOf(t.item)===t.fromIndex?this._announce((0,a.fillText)(f().droppedText,{label:String(this._labelOf(t.item)),position:this._position(t.item)})):this._settle(t.item,this,t.fromIndex,this))}_moveFocused(e,t){this._moving=!0;let n=this.contains(document.activeElement);e(),n&&document.activeElement!==t&&t.focus(),this._moving=!1}};function S(e,t,n){return e<t+y?-Math.ceil(b*Math.min(1,(t+y-e)/y)):e>n-y?Math.ceil(b*Math.min(1,(e-(n-y))/y)):0}function C(e){for(let t=e.parentElement;t&&t!==document.body&&t!==document.documentElement;t=t.parentElement){let e=getComputedStyle(t),n=/(auto|scroll)/.test(e.overflowY)&&t.scrollHeight>t.clientHeight,r=/(auto|scroll)/.test(e.overflowX)&&t.scrollWidth>t.clientWidth;if(n||r)return t}return null}(0,t.defineElement)(`wui-sortable`,x),e.WuiSortable=x})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formMirror,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore);