@webority/ui-elements 0.59.0 → 0.59.2

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 (43) hide show
  1. package/dist/{WuiAutocomplete-CE7wT-Vc.js → WuiAutocomplete-B2SKLPOV.js} +1 -1
  2. package/dist/{WuiCountrySelect-D92rrSvW.js → WuiCountrySelect-D-K0dm77.js} +1 -1
  3. package/dist/WuiDatePicker-B4E_NvAh.js +31 -0
  4. package/dist/{WuiDateRange-CrVodISl.js → WuiDateRange-BuVA1MK5.js} +1 -1
  5. package/dist/WuiDrawer-D6K2eRlW.js +1 -0
  6. package/dist/WuiHoverCard-BsYAwmbA.js +1 -0
  7. package/dist/{WuiMultiSelect-WUNCdkzW.js → WuiMultiSelect-BGZOG93I.js} +1 -1
  8. package/dist/{WuiNotificationCenter-DKdvaSbm.js → WuiNotificationCenter-BZwVMUSV.js} +1 -1
  9. package/dist/{WuiPhone-DtuXp6o2.js → WuiPhone-Dbb_9J8q.js} +1 -1
  10. package/dist/{WuiSelect-CT8tgsxL.js → WuiSelect-U5Owq3wT.js} +1 -1
  11. package/dist/{WuiTimePicker-Bolpp93P.js → WuiTimePicker-UjvUcDrS.js} +1 -1
  12. package/dist/elements/autocomplete.js +1 -1
  13. package/dist/elements/country-select.js +1 -1
  14. package/dist/elements/date-range.js +1 -1
  15. package/dist/elements/datepicker.js +1 -1
  16. package/dist/elements/drawer.js +1 -1
  17. package/dist/elements/hover-card.js +1 -1
  18. package/dist/elements/kanban.js +1 -1
  19. package/dist/elements/multiselect.js +1 -1
  20. package/dist/elements/notification-center.js +1 -1
  21. package/dist/elements/phone.js +1 -1
  22. package/dist/elements/select.js +1 -1
  23. package/dist/elements/timepicker.js +1 -1
  24. package/dist/{fileViewerImage-Bis2gnyc.js → fileViewerImage-DEhhKbIU.js} +1 -1
  25. package/dist/{fileViewerMedia-CaJaVnjE.js → fileViewerMedia-B12HzBnN.js} +1 -1
  26. package/dist/{fileViewerPdf-DGU_-iub.js → fileViewerPdf-L8OJZRPO.js} +2 -2
  27. package/dist/{fileViewerUi-DasgDsU-.js → fileViewerUi-KPTQsM_Y.js} +1 -1
  28. package/dist/helpers.js +1 -1
  29. package/dist/kanban-29Pv2HU9.js +1 -0
  30. package/dist/{themeTransition-C61cbmZ4.js → themeTransition-DO95LPdz.js} +1 -1
  31. package/dist/ui-chat.global.js +1 -1
  32. package/dist/ui-chat.js +1 -1
  33. package/dist/ui-elements.global.js +112 -112
  34. package/dist/ui-elements.js +1 -1
  35. package/dist/ui-file-viewer.global.js +2 -2
  36. package/dist/ui-file-viewer.js +1 -1
  37. package/dist/ui-rich-text.global.js +1 -1
  38. package/dist/ui-rich-text.js +1 -1
  39. package/package.json +1 -1
  40. package/dist/WuiDatePicker-_BzQ2m1e.js +0 -31
  41. package/dist/WuiDrawer-BuvDLR6M.js +0 -1
  42. package/dist/WuiHoverCard-CNEawHmO.js +0 -1
  43. package/dist/kanban-CdELdS3U.js +0 -1
@@ -1 +1 @@
1
- import{i as e,r as t,t as n}from"./fileViewerUi-DasgDsU-.js";var r=typeof HTMLElement>`u`?class{}:HTMLElement,i={pdf:`pdf`,jpg:`image`,jpeg:`image`,png:`image`,webp:`image`,gif:`image`,avif:`image`,bmp:`image`,svg:`image`,mp4:`video`,m4v:`video`,webm:`video`,ogv:`video`,mp3:`audio`,m4a:`audio`,aac:`audio`,wav:`audio`,ogg:`audio`,oga:`audio`,opus:`audio`,flac:`audio`},a={"application/pdf":`pdf`,"image/jpeg":`image`,"image/png":`image`,"image/webp":`image`,"image/gif":`image`,"image/avif":`image`,"image/bmp":`image`,"image/svg+xml":`image`,"video/mp4":`video`,"video/webm":`video`,"video/ogg":`video`,"audio/mpeg":`audio`,"audio/mp4":`audio`,"audio/aac":`audio`,"audio/wav":`audio`,"audio/x-wav":`audio`,"audio/ogg":`audio`,"audio/opus":`audio`,"audio/webm":`audio`,"audio/flac":`audio`},o=`wui-file-viewer:load`,s=`wui-file-viewer:error`,c=`wui-file-viewer:prefs-change`;function l(e,t){let n=String(e??``).split(`;`)[0].trim().toLowerCase();if(n)return a[n]??null;let r=String(t??``).split(/[?#]/)[0];return i[r.includes(`.`)?r.split(`.`).pop().toLowerCase():``]??null}function u(e){let t=String(e??``).split(/[?#]/)[0].split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}var d={pdf:()=>import(`./fileViewerPdf-DGU_-iub.js`).then(e=>e.PdfView),image:()=>import(`./fileViewerImage-Bis2gnyc.js`).then(e=>e.ImageView),video:()=>import(`./fileViewerMedia-CaJaVnjE.js`).then(e=>e.MediaView),audio:()=>import(`./fileViewerMedia-CaJaVnjE.js`).then(e=>e.MediaView)},f=0,p=class i extends r{static defaultAssetBase=``;static get observedAttributes(){return[`src`,`name`,`type`,`download`,`print`,`worker-src`,`asset-base`,`captions`]}constructor(){super(),f+=1,this.uid=`wui-file-viewer-${f}`,this._prefs={},this._onFullscreen=()=>this._syncFullscreen()}get src(){return this.getAttribute(`src`)??``}set src(e){this.setAttribute(`src`,String(e??``))}get name(){return this.getAttribute(`name`)??``}set name(e){this.setAttribute(`name`,String(e??``))}get type(){return this.getAttribute(`type`)??``}set type(e){this.setAttribute(`type`,String(e??``))}get viewKey(){return this.getAttribute(`view-key`)??``}set viewKey(e){this.setAttribute(`view-key`,String(e??``))}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get print(){return this.getAttribute(`print`)!==`false`}set print(e){this.setAttribute(`print`,e===!1||e===`false`?`false`:`true`)}get workerSrc(){return this.getAttribute(`worker-src`)??``}set workerSrc(e){this.setAttribute(`worker-src`,String(e??``))}get captions(){return this.getAttribute(`captions`)??``}set captions(e){this.setAttribute(`captions`,String(e??``))}get assetBase(){return this.getAttribute(`asset-base`)??``}set assetBase(e){this.setAttribute(`asset-base`,String(e??``))}get prefs(){return{...this._prefs}}set prefs(e){this._hostPrefs=!0,this._prefs=e&&typeof e==`object`?{...e}:{}}get actionsContainer(){return this._actionsBox??null}seekTo(e){if(typeof e!=`number`||!Number.isFinite(e))throw TypeError(`[wui-file-viewer] seekTo takes a number of seconds; got ${String(e)}.`);return this._view?.seekTo?(this._view.seekTo(e),!0):!1}displayName(){return this.name||u(this.src)||`Document`}connectedCallback(){if(Object.hasOwn(this,`prefs`)){let e=this.prefs;delete this.prefs,this.prefs=e}document.addEventListener(`fullscreenchange`,this._onFullscreen),this._open()}disconnectedCallback(){document.removeEventListener(`fullscreenchange`,this._onFullscreen),this._close()}attributeChangedCallback(e,t,n){!this.isConnected||!this._parts||t===n||(e===`name`?this._parts.name.textContent=this.displayName():e===`download`?this._syncDownload():e===`print`?this._syncPrint():this._open())}_close(){this._view?.destroy(),this._view=null,this._loadId=(this._loadId??0)+1}async _open(){this._close();let e=this._loadId;this._render(),this._prefs=this._readPrefs();let t=l(this.type,this.name||this.src);if(!this.src){this._status(`No file to show.`);return}if(!t){this._status(`This file can't be shown here.`,{offerDownload:!0});return}this._status(`Loading...`);let n;try{n=await d[t]()}catch(t){e===this._loadId&&this._fail(t);return}e===this._loadId&&(this._view=new n(this._shell(e),{src:this.src,kind:t,captions:this.captions,workerSrc:this.workerSrc,assetBase:m(this.assetBase||i.defaultAssetBase)}),this._view.load())}_shell(e){let t=()=>e===this._loadId,n=this._parts;return{host:this,start:n.start,center:n.center,end:n.viewEnd,search:n.search,body:n.body,prefs:{...this._prefs},name:()=>this.displayName(),print:()=>this.print,savePrefs:e=>{t()&&this._savePrefs(e)},loaded:e=>{t()&&(n.body.removeAttribute(`aria-busy`),this.dispatchEvent(new CustomEvent(o,{bubbles:!0,detail:e})))},fail:e=>{t()&&this._fail(e)}}}_render(){let r=(e,t)=>{let n=document.createElement(e);return n.className=t,n},i=r(`div`,`wui-file-viewer-toolbar`),a=r(`div`,`wui-file-viewer-group wui-file-viewer-start`),o=r(`span`,`wui-file-viewer-name`);o.textContent=this.displayName(),o.title=this.displayName(),a.append(o);let s=r(`div`,`wui-file-viewer-group wui-file-viewer-center`),c=r(`div`,`wui-file-viewer-group wui-file-viewer-end`),l=r(`div`,`wui-file-viewer-group wui-file-viewer-view-end`),u=r(`a`,`u-action wui-file-viewer-download`);u.style.setProperty(`--wui-action-size`,`32px`),t(u,`download`),e(u,`Download`);let d=n(`maximize-4`,`Full screen`,{className:`wui-file-viewer-fullscreen`});d.addEventListener(`click`,()=>this.toggleFullscreen()),d.hidden=!document.fullscreenEnabled,this._actionsBox??=r(`div`,`wui-file-viewer-actions`);let f=this._actionsBox;f.append(...this.querySelectorAll(`:scope > [slot="actions"]`)),c.append(l,u,d,f);let p=r(`search`,`wui-file-viewer-search`);p.hidden=!0,i.append(a,s,c,p);let m=r(`div`,`wui-file-viewer-body`);m.setAttribute(`aria-busy`,`true`),this.replaceChildren(i,m),this._parts={toolbar:i,start:a,name:o,center:s,end:c,viewEnd:l,downloadLink:u,fullscreen:d,actionsBox:f,search:p,body:m},this._syncDownload(),this._syncFullscreen()}_syncDownload(){let e=this._parts.downloadLink;e.hidden=!this.download||!this.src,e.href=this.src,e.setAttribute(`download`,this.displayName())}_syncPrint(){for(let e of this._parts.toolbar.querySelectorAll(`.wui-file-viewer-print`))e.hidden=!this.print}_status(e,{offerDownload:t=!1}={}){let n=document.createElement(`div`);n.className=`wui-file-viewer-status`;let r=document.createElement(`p`);if(r.textContent=e,n.append(r),t&&this.src){let e=document.createElement(`a`);e.className=`btn btn-sm btn-outline-secondary`,e.href=this.src,e.setAttribute(`download`,this.displayName()),e.textContent=`Download`,n.append(e)}this._parts.body.replaceChildren(n)}_fail(e){this._view?.destroy(),this._view=null,this._parts.body.removeAttribute(`aria-busy`),this._status(`Couldn't open this file.`,{offerDownload:!0}),this.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{message:e?.message??String(e)}}))}toggleFullscreen(){if(document.fullscreenElement){document.exitFullscreen();return}this.requestFullscreen().catch(e=>{console.warn(`[wui-file-viewer] full screen refused:`,e?.message)})}_syncFullscreen(){if(!this._parts)return;let n=document.fullscreenElement===this,r=this._parts.fullscreen;t(r,n?`x`:`maximize-4`),e(r,n?`Exit full screen`:`Full screen`),this._parts.actionsBox.hidden=n}_readPrefs(){if(this._hostPrefs||!this.viewKey)return{...this._prefs};try{return JSON.parse(window.localStorage.getItem(`wui-view:${this.viewKey}`)??`{}`)??{}}catch{return{}}}_savePrefs(e){if(this._prefs={...this._prefs,...e},this.dispatchEvent(new CustomEvent(c,{bubbles:!0,detail:{...this._prefs}})),!(this._hostPrefs||!this.viewKey))try{window.localStorage.setItem(`wui-view:${this.viewKey}`,JSON.stringify(this._prefs))}catch{}}};function m(e){return e&&new URL(e,document.baseURI).href}var h=typeof document>`u`?null:document.currentScript;h?.src&&(p.defaultAssetBase=new URL(`pdfjs/`,h.src).href),typeof customElements<`u`&&!customElements.get(`wui-file-viewer`)&&customElements.define(`wui-file-viewer`,p);var g=(e,t)=>import(`./fileViewerPdf-DGU_-iub.js`).then(n=>n.renderFirstPage(e,{assetBase:p.defaultAssetBase||void 0,...t}));export{p as WuiFileViewer,l as fileKind,u as fileNameFromUrl,g as renderPdfFirstPage};
1
+ import{i as e,r as t,t as n}from"./fileViewerUi-KPTQsM_Y.js";var r=typeof HTMLElement>`u`?class{}:HTMLElement,i={pdf:`pdf`,jpg:`image`,jpeg:`image`,png:`image`,webp:`image`,gif:`image`,avif:`image`,bmp:`image`,svg:`image`,mp4:`video`,m4v:`video`,webm:`video`,ogv:`video`,mp3:`audio`,m4a:`audio`,aac:`audio`,wav:`audio`,ogg:`audio`,oga:`audio`,opus:`audio`,flac:`audio`},a={"application/pdf":`pdf`,"image/jpeg":`image`,"image/png":`image`,"image/webp":`image`,"image/gif":`image`,"image/avif":`image`,"image/bmp":`image`,"image/svg+xml":`image`,"video/mp4":`video`,"video/webm":`video`,"video/ogg":`video`,"audio/mpeg":`audio`,"audio/mp4":`audio`,"audio/aac":`audio`,"audio/wav":`audio`,"audio/x-wav":`audio`,"audio/ogg":`audio`,"audio/opus":`audio`,"audio/webm":`audio`,"audio/flac":`audio`},o=`wui-file-viewer:load`,s=`wui-file-viewer:error`,c=`wui-file-viewer:prefs-change`;function l(e,t){let n=String(e??``).split(`;`)[0].trim().toLowerCase();if(n)return a[n]??null;let r=String(t??``).split(/[?#]/)[0];return i[r.includes(`.`)?r.split(`.`).pop().toLowerCase():``]??null}function u(e){let t=String(e??``).split(/[?#]/)[0].split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}var d={pdf:()=>import(`./fileViewerPdf-L8OJZRPO.js`).then(e=>e.PdfView),image:()=>import(`./fileViewerImage-DEhhKbIU.js`).then(e=>e.ImageView),video:()=>import(`./fileViewerMedia-B12HzBnN.js`).then(e=>e.MediaView),audio:()=>import(`./fileViewerMedia-B12HzBnN.js`).then(e=>e.MediaView)},f=0,p=class i extends r{static defaultAssetBase=``;static get observedAttributes(){return[`src`,`name`,`type`,`download`,`print`,`worker-src`,`asset-base`,`captions`]}constructor(){super(),f+=1,this.uid=`wui-file-viewer-${f}`,this._prefs={},this._onFullscreen=()=>this._syncFullscreen()}get src(){return this.getAttribute(`src`)??``}set src(e){this.setAttribute(`src`,String(e??``))}get name(){return this.getAttribute(`name`)??``}set name(e){this.setAttribute(`name`,String(e??``))}get type(){return this.getAttribute(`type`)??``}set type(e){this.setAttribute(`type`,String(e??``))}get viewKey(){return this.getAttribute(`view-key`)??``}set viewKey(e){this.setAttribute(`view-key`,String(e??``))}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get print(){return this.getAttribute(`print`)!==`false`}set print(e){this.setAttribute(`print`,e===!1||e===`false`?`false`:`true`)}get workerSrc(){return this.getAttribute(`worker-src`)??``}set workerSrc(e){this.setAttribute(`worker-src`,String(e??``))}get captions(){return this.getAttribute(`captions`)??``}set captions(e){this.setAttribute(`captions`,String(e??``))}get assetBase(){return this.getAttribute(`asset-base`)??``}set assetBase(e){this.setAttribute(`asset-base`,String(e??``))}get prefs(){return{...this._prefs}}set prefs(e){this._hostPrefs=!0,this._prefs=e&&typeof e==`object`?{...e}:{}}get actionsContainer(){return this._actionsBox??null}seekTo(e){if(typeof e!=`number`||!Number.isFinite(e))throw TypeError(`[wui-file-viewer] seekTo takes a number of seconds; got ${String(e)}.`);return this._view?.seekTo?(this._view.seekTo(e),!0):!1}displayName(){return this.name||u(this.src)||`Document`}connectedCallback(){if(Object.hasOwn(this,`prefs`)){let e=this.prefs;delete this.prefs,this.prefs=e}document.addEventListener(`fullscreenchange`,this._onFullscreen),this._open()}disconnectedCallback(){document.removeEventListener(`fullscreenchange`,this._onFullscreen),this._close()}attributeChangedCallback(e,t,n){!this.isConnected||!this._parts||t===n||(e===`name`?this._parts.name.textContent=this.displayName():e===`download`?this._syncDownload():e===`print`?this._syncPrint():this._open())}_close(){this._view?.destroy(),this._view=null,this._loadId=(this._loadId??0)+1}async _open(){this._close();let e=this._loadId;this._render(),this._prefs=this._readPrefs();let t=l(this.type,this.name||this.src);if(!this.src){this._status(`No file to show.`);return}if(!t){this._status(`This file can't be shown here.`,{offerDownload:!0});return}this._status(`Loading...`);let n;try{n=await d[t]()}catch(t){e===this._loadId&&this._fail(t);return}e===this._loadId&&(this._view=new n(this._shell(e),{src:this.src,kind:t,captions:this.captions,workerSrc:this.workerSrc,assetBase:m(this.assetBase||i.defaultAssetBase)}),this._view.load())}_shell(e){let t=()=>e===this._loadId,n=this._parts;return{host:this,start:n.start,center:n.center,end:n.viewEnd,search:n.search,body:n.body,prefs:{...this._prefs},name:()=>this.displayName(),print:()=>this.print,savePrefs:e=>{t()&&this._savePrefs(e)},loaded:e=>{t()&&(n.body.removeAttribute(`aria-busy`),this.dispatchEvent(new CustomEvent(o,{bubbles:!0,detail:e})))},fail:e=>{t()&&this._fail(e)}}}_render(){let r=(e,t)=>{let n=document.createElement(e);return n.className=t,n},i=r(`div`,`wui-file-viewer-toolbar`),a=r(`div`,`wui-file-viewer-group wui-file-viewer-start`),o=r(`span`,`wui-file-viewer-name`);o.textContent=this.displayName(),o.title=this.displayName(),a.append(o);let s=r(`div`,`wui-file-viewer-group wui-file-viewer-center`),c=r(`div`,`wui-file-viewer-group wui-file-viewer-end`),l=r(`div`,`wui-file-viewer-group wui-file-viewer-view-end`),u=r(`a`,`u-action wui-file-viewer-download`);u.style.setProperty(`--wui-action-size`,`32px`),t(u,`download`),e(u,`Download`);let d=n(`maximize-4`,`Full screen`,{className:`wui-file-viewer-fullscreen`});d.addEventListener(`click`,()=>this.toggleFullscreen()),d.hidden=!document.fullscreenEnabled,this._actionsBox??=r(`div`,`wui-file-viewer-actions`);let f=this._actionsBox;f.append(...this.querySelectorAll(`:scope > [slot="actions"]`)),c.append(l,u,d,f);let p=r(`search`,`wui-file-viewer-search`);p.hidden=!0,i.append(a,s,c,p);let m=r(`div`,`wui-file-viewer-body`);m.setAttribute(`aria-busy`,`true`),this.replaceChildren(i,m),this._parts={toolbar:i,start:a,name:o,center:s,end:c,viewEnd:l,downloadLink:u,fullscreen:d,actionsBox:f,search:p,body:m},this._syncDownload(),this._syncFullscreen()}_syncDownload(){let e=this._parts.downloadLink;e.hidden=!this.download||!this.src,e.href=this.src,e.setAttribute(`download`,this.displayName())}_syncPrint(){for(let e of this._parts.toolbar.querySelectorAll(`.wui-file-viewer-print`))e.hidden=!this.print}_status(e,{offerDownload:t=!1}={}){let n=document.createElement(`div`);n.className=`wui-file-viewer-status`;let r=document.createElement(`p`);if(r.textContent=e,n.append(r),t&&this.src){let e=document.createElement(`a`);e.className=`btn btn-sm btn-outline-secondary`,e.href=this.src,e.setAttribute(`download`,this.displayName()),e.textContent=`Download`,n.append(e)}this._parts.body.replaceChildren(n)}_fail(e){this._view?.destroy(),this._view=null,this._parts.body.removeAttribute(`aria-busy`),this._status(`Couldn't open this file.`,{offerDownload:!0}),this.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{message:e?.message??String(e)}}))}toggleFullscreen(){if(document.fullscreenElement){document.exitFullscreen();return}this.requestFullscreen().catch(e=>{console.warn(`[wui-file-viewer] full screen refused:`,e?.message)})}_syncFullscreen(){if(!this._parts)return;let n=document.fullscreenElement===this,r=this._parts.fullscreen;t(r,n?`x`:`maximize-4`),e(r,n?`Exit full screen`:`Full screen`),this._parts.actionsBox.hidden=n}_readPrefs(){if(this._hostPrefs||!this.viewKey)return{...this._prefs};try{return JSON.parse(window.localStorage.getItem(`wui-view:${this.viewKey}`)??`{}`)??{}}catch{return{}}}_savePrefs(e){if(this._prefs={...this._prefs,...e},this.dispatchEvent(new CustomEvent(c,{bubbles:!0,detail:{...this._prefs}})),!(this._hostPrefs||!this.viewKey))try{window.localStorage.setItem(`wui-view:${this.viewKey}`,JSON.stringify(this._prefs))}catch{}}};function m(e){return e&&new URL(e,document.baseURI).href}var h=typeof document>`u`?null:document.currentScript;h?.src&&(p.defaultAssetBase=new URL(`pdfjs/`,h.src).href),typeof customElements<`u`&&!customElements.get(`wui-file-viewer`)&&customElements.define(`wui-file-viewer`,p);var g=(e,t)=>import(`./fileViewerPdf-L8OJZRPO.js`).then(n=>n.renderFirstPage(e,{assetBase:p.defaultAssetBase||void 0,...t}));export{p as WuiFileViewer,l as fileKind,u as fileNameFromUrl,g as renderPdfFirstPage};
@@ -201,4 +201,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
201
201
  <div class="wui-rich-text-link-error" data-link-error role="alert" hidden>${cb(sb)}</div>
202
202
  </div>
203
203
  <div class="wui-rich-text-content" data-editor></div>
204
- </div>`,this._toolbar=this.querySelector(`.wui-rich-text-toolbar`),this._linkbar=this.querySelector(`[data-linkbar]`),this._linkInput=this.querySelector(`[data-link-input]`),this._linkError=this.querySelector(`[data-link-error]`),this._editor=tb({element:this.querySelector(`[data-editor]`),content:this._value,format:this.format,placeholder:()=>this.getAttribute(`placeholder`)||``,editable:this._isEditable(),attributes:this._surfaceAttributes(),onChange:()=>this._onEdit(),onSelection:()=>this._syncToolbar(),onFocus:()=>{},onBlur:()=>this._onBlur()}),this._committed=this.value,this._wire(),this._syncEditable(),this._afterValueChange()}_teardown(){this._editor&&=(this._value=this.value,this._abort?.abort(),this._editor.destroy(),null)}_isEditable(){return!this.hasAttribute(`disabled`)&&!this.hasAttribute(`readonly`)}_syncEditable(){this._editor.setEditable(this._isEditable()),this._editor.setAttributes(this._surfaceAttributes()),this._syncToolbar(),this._syncMirror()}_syncMirror(){a(this,this.value)}_syncValidity(){let e=this._internals;typeof e?.setValidity==`function`&&(this.hasAttribute(`required`)&&this._editor.isEmpty()?e.setValidity({valueMissing:!0},`Please fill in this field.`,this.querySelector(`[data-editor] [contenteditable]`)):e.setValidity({}))}_afterValueChange(){this._syncMirror(),this._syncValidity(),this._syncToolbar()}_onEdit(){this._lastSet=null,this._afterValueChange(),this.dispatchEvent(new Event(`input`,{bubbles:!0}))}_onBlur(){let e=this.value;e!==this._committed&&(this._committed=e,this.dispatchEvent(new Event(`change`,{bubbles:!0})))}_buttons(){return[...this._toolbar.querySelectorAll(`button`)]}_syncToolbar(){if(!this._editor)return;let e=this._editor.state(),t=!this._isEditable();for(let n of this._buttons()){let r=n.dataset.action;n.hasAttribute(`aria-pressed`)?n.setAttribute(`aria-pressed`,String(!!e[r])):r===`link`&&n.setAttribute(`aria-pressed`,String(!!e.link)),n.disabled=t||(r===`undo`||r===`redo`)&&!e[r]}let n=this._buttons(),r=n.find(e=>e.tabIndex===0&&!e.disabled)??n.find(e=>!e.disabled);for(let e of n)e.tabIndex=e===r?0:-1}_wire(){this._abort=new AbortController;let{signal:e}=this._abort;this._toolbar.addEventListener(`mousedown`,e=>e.preventDefault(),{signal:e}),this._toolbar.addEventListener(`click`,e=>{let t=e.target.closest(`button[data-action]`);if(!t||t.disabled)return;let n=t.dataset.action;n===`link`?this._openLinkBar():this._editor.run(n)},{signal:e}),this._toolbar.addEventListener(`keydown`,e=>this._toolbarKey(e),{signal:e}),this._toolbar.addEventListener(`focusin`,e=>{let t=e.target.closest(`button`);if(t)for(let e of this._buttons())e.tabIndex=e===t?0:-1},{signal:e}),this.querySelector(`[data-editor]`).addEventListener(`keydown`,e=>{e.key.toLowerCase()===`k`&&(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&this._isEditable()&&(e.preventDefault(),this._openLinkBar())},{signal:e}),this._linkbar.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),this._applyLink()):e.key===`Escape`&&(e.preventDefault(),this._closeLinkBar())},{signal:e}),this._linkbar.addEventListener(`click`,e=>{e.target.closest(`[data-link-apply]`)?this._applyLink():e.target.closest(`[data-link-remove]`)?(this._editor.removeLink(),this._closeLinkBar()):e.target.closest(`[data-link-cancel]`)&&this._closeLinkBar()},{signal:e}),this._linkInput.addEventListener(`input`,()=>{this._linkError.hidden=!0,this._linkInput.removeAttribute(`aria-invalid`)},{signal:e})}_toolbarKey(e){let t={ArrowRight:1,ArrowLeft:-1,Home:`first`,End:`last`};if(!(e.key in t))return;let n=this._buttons().filter(e=>!e.disabled);if(!n.length)return;e.preventDefault();let r=n.indexOf(e.target.closest(`button`)),i=t[e.key];n[i===`first`?0:i===`last`?n.length-1:(r+i+n.length)%n.length].focus()}_openLinkBar(){this._linkInput.value=this._editor.linkHref(),this._linkError.hidden=!0,this._linkInput.removeAttribute(`aria-invalid`),this._linkbar.querySelector(`[data-link-remove]`).hidden=!this._editor.state().link,this._linkbar.hidden=!1,this._linkInput.focus(),this._linkInput.select()}_closeLinkBar(){this._linkbar.hidden=!0,this._editor.focus()}_applyLink(){if(this._editor.setLink(this._linkInput.value)){this._closeLinkBar();return}this._linkError.hidden=!1,this._linkInput.setAttribute(`aria-invalid`,`true`),this._linkInput.focus()}};return typeof customElements<`u`&&!customElements.get(`wui-rich-text`)&&customElements.define(`wui-rich-text`,ub),e.WuiRichText=ub,e})({});
204
+ </div>`,this._toolbar=this.querySelector(`.wui-rich-text-toolbar`),this._linkbar=this.querySelector(`[data-linkbar]`),this._linkInput=this.querySelector(`[data-link-input]`),this._linkError=this.querySelector(`[data-link-error]`),this._editor=tb({element:this.querySelector(`[data-editor]`),content:this._value,format:this.format,placeholder:()=>this.getAttribute(`placeholder`)||``,editable:this._isEditable(),attributes:this._surfaceAttributes(),onChange:()=>this._onEdit(),onSelection:()=>this._syncToolbar(),onFocus:()=>{},onBlur:()=>this._onBlur()}),this._committed=this.value,this._wire(),this._syncEditable(),this._afterValueChange()}_teardown(){this._editor&&=(this._value=this.value,this._abort?.abort(),this._editor.destroy(),null)}_isEditable(){return!this.hasAttribute(`disabled`)&&!this.hasAttribute(`readonly`)}_syncEditable(){this._editor.setEditable(this._isEditable()),this._editor.setAttributes(this._surfaceAttributes()),this._syncToolbar(),this._syncMirror()}_syncMirror(){a(this,this.value)}_syncValidity(){let e=this._internals;typeof e?.setValidity==`function`&&(this.hasAttribute(`required`)&&this._editor.isEmpty()?e.setValidity({valueMissing:!0},`Please fill in this field.`,this.querySelector(`[data-editor] [contenteditable]`)):e.setValidity({}))}_afterValueChange(){this._syncMirror(),this._syncValidity(),this._syncToolbar()}_onEdit(){this._lastSet=null,this._afterValueChange(),this.dispatchEvent(new Event(`input`,{bubbles:!0}))}_onBlur(){let e=this.value;e!==this._committed&&(this._committed=e,this.dispatchEvent(new Event(`change`,{bubbles:!0})))}_buttons(){return[...this._toolbar.querySelectorAll(`button`)]}_syncToolbar(){if(!this._editor)return;let e=this._editor.state(),t=!this._isEditable();for(let n of this._buttons()){let r=n.dataset.action;n.hasAttribute(`aria-pressed`)?n.setAttribute(`aria-pressed`,String(!!e[r])):r===`link`&&n.setAttribute(`aria-pressed`,String(!!e.link)),n.disabled=t||(r===`undo`||r===`redo`)&&!e[r]}let n=this._buttons(),r=n.find(e=>e.tabIndex===0&&!e.disabled)??n.find(e=>!e.disabled);for(let e of n)e.tabIndex=e===r?0:-1}_wire(){this._abort=new AbortController;let{signal:e}=this._abort;this._toolbar.addEventListener(`mousedown`,e=>e.preventDefault(),{signal:e}),this._toolbar.addEventListener(`click`,e=>{let t=e.target.closest(`button[data-action]`);if(!t||t.disabled)return;let n=t.dataset.action;n===`link`?this._openLinkBar():this._editor.run(n)},{signal:e}),this._toolbar.addEventListener(`keydown`,e=>this._toolbarKey(e),{signal:e}),this._toolbar.addEventListener(`focusin`,e=>{let t=e.target.closest(`button`);if(t)for(let e of this._buttons())e.tabIndex=e===t?0:-1},{signal:e}),this.querySelector(`[data-editor]`).addEventListener(`keydown`,e=>{e.key.toLowerCase()===`k`&&(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&this._isEditable()&&(e.preventDefault(),this._openLinkBar())},{signal:e}),this._linkbar.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),this._applyLink()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this._closeLinkBar())},{signal:e}),this._linkbar.addEventListener(`click`,e=>{e.target.closest(`[data-link-apply]`)?this._applyLink():e.target.closest(`[data-link-remove]`)?(this._editor.removeLink(),this._closeLinkBar()):e.target.closest(`[data-link-cancel]`)&&this._closeLinkBar()},{signal:e}),this._linkInput.addEventListener(`input`,()=>{this._linkError.hidden=!0,this._linkInput.removeAttribute(`aria-invalid`)},{signal:e})}_toolbarKey(e){let t={ArrowRight:1,ArrowLeft:-1,Home:`first`,End:`last`};if(!(e.key in t))return;let n=this._buttons().filter(e=>!e.disabled);if(!n.length)return;e.preventDefault();let r=n.indexOf(e.target.closest(`button`)),i=t[e.key];n[i===`first`?0:i===`last`?n.length-1:(r+i+n.length)%n.length].focus()}_openLinkBar(){this._linkInput.value=this._editor.linkHref(),this._linkError.hidden=!0,this._linkInput.removeAttribute(`aria-invalid`),this._linkbar.querySelector(`[data-link-remove]`).hidden=!this._editor.state().link,this._linkbar.hidden=!1,this._linkInput.focus(),this._linkInput.select()}_closeLinkBar(){this._linkbar.hidden=!0,this._editor.focus()}_applyLink(){if(this._editor.setLink(this._linkInput.value)){this._closeLinkBar();return}this._linkError.hidden=!1,this._linkInput.setAttribute(`aria-invalid`,`true`),this._linkInput.focus()}};return typeof customElements<`u`&&!customElements.get(`wui-rich-text`)&&customElements.define(`wui-rich-text`,ub),e.WuiRichText=ub,e})({});
@@ -201,4 +201,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
201
201
  <div class="wui-rich-text-link-error" data-link-error role="alert" hidden>${sb(ob)}</div>
202
202
  </div>
203
203
  <div class="wui-rich-text-content" data-editor></div>
204
- </div>`,this._toolbar=this.querySelector(`.wui-rich-text-toolbar`),this._linkbar=this.querySelector(`[data-linkbar]`),this._linkInput=this.querySelector(`[data-link-input]`),this._linkError=this.querySelector(`[data-link-error]`),this._editor=eb({element:this.querySelector(`[data-editor]`),content:this._value,format:this.format,placeholder:()=>this.getAttribute(`placeholder`)||``,editable:this._isEditable(),attributes:this._surfaceAttributes(),onChange:()=>this._onEdit(),onSelection:()=>this._syncToolbar(),onFocus:()=>{},onBlur:()=>this._onBlur()}),this._committed=this.value,this._wire(),this._syncEditable(),this._afterValueChange()}_teardown(){this._editor&&=(this._value=this.value,this._abort?.abort(),this._editor.destroy(),null)}_isEditable(){return!this.hasAttribute(`disabled`)&&!this.hasAttribute(`readonly`)}_syncEditable(){this._editor.setEditable(this._isEditable()),this._editor.setAttributes(this._surfaceAttributes()),this._syncToolbar(),this._syncMirror()}_syncMirror(){i(this,this.value)}_syncValidity(){let e=this._internals;typeof e?.setValidity==`function`&&(this.hasAttribute(`required`)&&this._editor.isEmpty()?e.setValidity({valueMissing:!0},`Please fill in this field.`,this.querySelector(`[data-editor] [contenteditable]`)):e.setValidity({}))}_afterValueChange(){this._syncMirror(),this._syncValidity(),this._syncToolbar()}_onEdit(){this._lastSet=null,this._afterValueChange(),this.dispatchEvent(new Event(`input`,{bubbles:!0}))}_onBlur(){let e=this.value;e!==this._committed&&(this._committed=e,this.dispatchEvent(new Event(`change`,{bubbles:!0})))}_buttons(){return[...this._toolbar.querySelectorAll(`button`)]}_syncToolbar(){if(!this._editor)return;let e=this._editor.state(),t=!this._isEditable();for(let n of this._buttons()){let r=n.dataset.action;n.hasAttribute(`aria-pressed`)?n.setAttribute(`aria-pressed`,String(!!e[r])):r===`link`&&n.setAttribute(`aria-pressed`,String(!!e.link)),n.disabled=t||(r===`undo`||r===`redo`)&&!e[r]}let n=this._buttons(),r=n.find(e=>e.tabIndex===0&&!e.disabled)??n.find(e=>!e.disabled);for(let e of n)e.tabIndex=e===r?0:-1}_wire(){this._abort=new AbortController;let{signal:e}=this._abort;this._toolbar.addEventListener(`mousedown`,e=>e.preventDefault(),{signal:e}),this._toolbar.addEventListener(`click`,e=>{let t=e.target.closest(`button[data-action]`);if(!t||t.disabled)return;let n=t.dataset.action;n===`link`?this._openLinkBar():this._editor.run(n)},{signal:e}),this._toolbar.addEventListener(`keydown`,e=>this._toolbarKey(e),{signal:e}),this._toolbar.addEventListener(`focusin`,e=>{let t=e.target.closest(`button`);if(t)for(let e of this._buttons())e.tabIndex=e===t?0:-1},{signal:e}),this.querySelector(`[data-editor]`).addEventListener(`keydown`,e=>{e.key.toLowerCase()===`k`&&(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&this._isEditable()&&(e.preventDefault(),this._openLinkBar())},{signal:e}),this._linkbar.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),this._applyLink()):e.key===`Escape`&&(e.preventDefault(),this._closeLinkBar())},{signal:e}),this._linkbar.addEventListener(`click`,e=>{e.target.closest(`[data-link-apply]`)?this._applyLink():e.target.closest(`[data-link-remove]`)?(this._editor.removeLink(),this._closeLinkBar()):e.target.closest(`[data-link-cancel]`)&&this._closeLinkBar()},{signal:e}),this._linkInput.addEventListener(`input`,()=>{this._linkError.hidden=!0,this._linkInput.removeAttribute(`aria-invalid`)},{signal:e})}_toolbarKey(e){let t={ArrowRight:1,ArrowLeft:-1,Home:`first`,End:`last`};if(!(e.key in t))return;let n=this._buttons().filter(e=>!e.disabled);if(!n.length)return;e.preventDefault();let r=n.indexOf(e.target.closest(`button`)),i=t[e.key];n[i===`first`?0:i===`last`?n.length-1:(r+i+n.length)%n.length].focus()}_openLinkBar(){this._linkInput.value=this._editor.linkHref(),this._linkError.hidden=!0,this._linkInput.removeAttribute(`aria-invalid`),this._linkbar.querySelector(`[data-link-remove]`).hidden=!this._editor.state().link,this._linkbar.hidden=!1,this._linkInput.focus(),this._linkInput.select()}_closeLinkBar(){this._linkbar.hidden=!0,this._editor.focus()}_applyLink(){if(this._editor.setLink(this._linkInput.value)){this._closeLinkBar();return}this._linkError.hidden=!1,this._linkInput.setAttribute(`aria-invalid`,`true`),this._linkInput.focus()}};typeof customElements<`u`&&!customElements.get(`wui-rich-text`)&&customElements.define(`wui-rich-text`,lb);export{lb as WuiRichText};
204
+ </div>`,this._toolbar=this.querySelector(`.wui-rich-text-toolbar`),this._linkbar=this.querySelector(`[data-linkbar]`),this._linkInput=this.querySelector(`[data-link-input]`),this._linkError=this.querySelector(`[data-link-error]`),this._editor=eb({element:this.querySelector(`[data-editor]`),content:this._value,format:this.format,placeholder:()=>this.getAttribute(`placeholder`)||``,editable:this._isEditable(),attributes:this._surfaceAttributes(),onChange:()=>this._onEdit(),onSelection:()=>this._syncToolbar(),onFocus:()=>{},onBlur:()=>this._onBlur()}),this._committed=this.value,this._wire(),this._syncEditable(),this._afterValueChange()}_teardown(){this._editor&&=(this._value=this.value,this._abort?.abort(),this._editor.destroy(),null)}_isEditable(){return!this.hasAttribute(`disabled`)&&!this.hasAttribute(`readonly`)}_syncEditable(){this._editor.setEditable(this._isEditable()),this._editor.setAttributes(this._surfaceAttributes()),this._syncToolbar(),this._syncMirror()}_syncMirror(){i(this,this.value)}_syncValidity(){let e=this._internals;typeof e?.setValidity==`function`&&(this.hasAttribute(`required`)&&this._editor.isEmpty()?e.setValidity({valueMissing:!0},`Please fill in this field.`,this.querySelector(`[data-editor] [contenteditable]`)):e.setValidity({}))}_afterValueChange(){this._syncMirror(),this._syncValidity(),this._syncToolbar()}_onEdit(){this._lastSet=null,this._afterValueChange(),this.dispatchEvent(new Event(`input`,{bubbles:!0}))}_onBlur(){let e=this.value;e!==this._committed&&(this._committed=e,this.dispatchEvent(new Event(`change`,{bubbles:!0})))}_buttons(){return[...this._toolbar.querySelectorAll(`button`)]}_syncToolbar(){if(!this._editor)return;let e=this._editor.state(),t=!this._isEditable();for(let n of this._buttons()){let r=n.dataset.action;n.hasAttribute(`aria-pressed`)?n.setAttribute(`aria-pressed`,String(!!e[r])):r===`link`&&n.setAttribute(`aria-pressed`,String(!!e.link)),n.disabled=t||(r===`undo`||r===`redo`)&&!e[r]}let n=this._buttons(),r=n.find(e=>e.tabIndex===0&&!e.disabled)??n.find(e=>!e.disabled);for(let e of n)e.tabIndex=e===r?0:-1}_wire(){this._abort=new AbortController;let{signal:e}=this._abort;this._toolbar.addEventListener(`mousedown`,e=>e.preventDefault(),{signal:e}),this._toolbar.addEventListener(`click`,e=>{let t=e.target.closest(`button[data-action]`);if(!t||t.disabled)return;let n=t.dataset.action;n===`link`?this._openLinkBar():this._editor.run(n)},{signal:e}),this._toolbar.addEventListener(`keydown`,e=>this._toolbarKey(e),{signal:e}),this._toolbar.addEventListener(`focusin`,e=>{let t=e.target.closest(`button`);if(t)for(let e of this._buttons())e.tabIndex=e===t?0:-1},{signal:e}),this.querySelector(`[data-editor]`).addEventListener(`keydown`,e=>{e.key.toLowerCase()===`k`&&(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&this._isEditable()&&(e.preventDefault(),this._openLinkBar())},{signal:e}),this._linkbar.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),this._applyLink()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this._closeLinkBar())},{signal:e}),this._linkbar.addEventListener(`click`,e=>{e.target.closest(`[data-link-apply]`)?this._applyLink():e.target.closest(`[data-link-remove]`)?(this._editor.removeLink(),this._closeLinkBar()):e.target.closest(`[data-link-cancel]`)&&this._closeLinkBar()},{signal:e}),this._linkInput.addEventListener(`input`,()=>{this._linkError.hidden=!0,this._linkInput.removeAttribute(`aria-invalid`)},{signal:e})}_toolbarKey(e){let t={ArrowRight:1,ArrowLeft:-1,Home:`first`,End:`last`};if(!(e.key in t))return;let n=this._buttons().filter(e=>!e.disabled);if(!n.length)return;e.preventDefault();let r=n.indexOf(e.target.closest(`button`)),i=t[e.key];n[i===`first`?0:i===`last`?n.length-1:(r+i+n.length)%n.length].focus()}_openLinkBar(){this._linkInput.value=this._editor.linkHref(),this._linkError.hidden=!0,this._linkInput.removeAttribute(`aria-invalid`),this._linkbar.querySelector(`[data-link-remove]`).hidden=!this._editor.state().link,this._linkbar.hidden=!1,this._linkInput.focus(),this._linkInput.select()}_closeLinkBar(){this._linkbar.hidden=!0,this._editor.focus()}_applyLink(){if(this._editor.setLink(this._linkInput.value)){this._closeLinkBar();return}this._linkError.hidden=!1,this._linkInput.setAttribute(`aria-invalid`,`true`),this._linkInput.focus()}};typeof customElements<`u`&&!customElements.get(`wui-rich-text`)&&customElements.define(`wui-rich-text`,lb);export{lb as WuiRichText};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/ui-elements",
3
- "version": "0.59.0",
3
+ "version": "0.59.2",
4
4
  "description": "Webority framework-agnostic UI custom elements (<wui-*>) — the single implementation of the interactive components, styled by @webority/theme. Used natively in Razor and wrapped by @webority/ui-react.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -1,31 +0,0 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-WcDeH46q.js";import{t as i}from"./formMirror-BgY7zkC3.js";import{t as a}from"./iconGlyphs.g-CUm_mfze.js";import{n as o}from"./optionLabel-BBaur8Bs.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p,t as m}from"./calendarMath-BC2wGCD-.js";var h=class extends e{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`display-format`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._slide=``}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&(e===`value`?(this._value=n||``,this._syncFormValue(),this._syncTrigger()):e===`display-format`?this._syncTrigger():e===`first-day`?this.querySelector(`.datepicker-pop`)?.hidden||this._renderView():this.render())}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,i(this,this._value),this._syncTrigger()}_firstDay(){return s(this)}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this.getAttribute(`placeholder`)||`Enter Date`,t=p(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),r=n===`sm`?` input-sm`:n===`lg`?` input-lg`:``,s=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`);this.innerHTML=`
2
- <div class="datepicker">
3
- <button type="button" class="input datepicker-trigger${r}${t?` has-value`:``}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${s?` aria-label="${o(s)}"`:``}${c?` aria-describedby="${o(c)}"`:``}>
4
- <span data-trigger-label class="${t?``:`search-select-placeholder`}">${o(t?d(this._value,this.getAttribute(`display-format`)):e)}</span>
5
- ${a(`calendar-dots`)}
6
- </button>
7
- <div class="datepicker-pop" role="dialog" aria-modal="false" hidden></div>
8
- </div>`,this._rendered=!0,i(this,this._value),this._wire()}_syncFormValue(){i(this,this._value)}_syncTrigger(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`[data-trigger-label]`);if(!t)return;let n=p(this._value);t.textContent=n?d(this._value,this.getAttribute(`display-format`)):this.getAttribute(`placeholder`)||`Enter Date`,t.classList.toggle(`search-select-placeholder`,!n),e?.classList.toggle(`has-value`,!!n)}_limits(){let e=p(this.getAttribute(`min`)),t=p(this.getAttribute(`max`)),n=e?new Date(e.y,e.m,e.d).getTime():-1/0,r=t?new Date(t.y,t.m,t.d).getTime():1/0;return{dayDisabled:(e,t,i)=>{let a=new Date(e,t,i).getTime();return a<n||a>r},monthDisabled:(e,t)=>{let i=new Date(e,t,1).getTime();return new Date(e,t,l(e,t)).getTime()<n||i>r},yearDisabled:e=>{let t=new Date(e,0,1).getTime();return new Date(e,11,31).getTime()<n||t>r}}}_renderView(){let e=this.querySelector(`.datepicker-pop`);e&&(this._mode===`months`?e.innerHTML=this._monthsHtml():this._mode===`years`?e.innerHTML=this._yearsHtml():e.innerHTML=this._daysHtml(),this._focusActive())}_daysHtml(){let e=this._firstDay(),t=(new Date(this._viewY,this._viewM,1).getDay()-e+7)%7,n=l(this._viewY,this._viewM),r=p(this._value),i=new Date,{dayDisabled:o}=this._limits(),s=this._focus||r||{y:this._viewY,m:this._viewM,d:1},d=(e,t,n,a)=>{let l=c(e,t,n),u=r&&r.y===e&&r.m===t&&r.d===n,d=i.getFullYear()===e&&i.getMonth()===t&&i.getDate()===n,f=s.y===e&&s.m===t&&s.d===n,p=o(e,t,n);return`<button type="button" class="${[`datepicker-day`,a?`is-outside`:``,d?`is-today`:``,u?`is-selected`:``].filter(Boolean).join(` `)}" data-iso="${l}" role="gridcell" tabindex="${f&&!p?`0`:`-1`}"${u?` aria-selected="true"`:``}${p?` disabled aria-disabled="true"`:``}>${n}</button>`},h=``,g=f(this._viewY,this._viewM-1),_=l(g.y,g.m);for(let e=t-1;e>=0;e--)h+=d(g.y,g.m,_-e,!0);for(let e=1;e<=n;e++)h+=d(this._viewY,this._viewM,e,!1);let v=f(this._viewY,this._viewM+1),y=(7-(t+n)%7)%7;for(let e=1;e<=y;e++)h+=d(v.y,v.m,e,!0);let b=o(i.getFullYear(),i.getMonth(),i.getDate()),x=u.map((t,n)=>u[(n+e)%7]).map(e=>`<span>${e}</span>`).join(``);return`
9
- <div class="datepicker-head">
10
- <button type="button" class="datepicker-nav-btn" data-nav="-1" aria-label="Previous month">${a(`chevron-left`)}</button>
11
- <button type="button" class="datepicker-month" data-view="months" aria-label="Choose month and year">${m[this._viewM]} ${this._viewY}</button>
12
- <button type="button" class="datepicker-nav-btn" data-nav="1" aria-label="Next month">${a(`chevron-right`)}</button>
13
- </div>
14
- <div class="datepicker-weekdays">${x}</div>
15
- <div class="datepicker-grid${this._slide?` ${this._slide}`:``}" role="grid">${h}</div>
16
- <div class="datepicker-foot">
17
- <button type="button" class="datepicker-link" data-today${b?` disabled`:``}>Today</button>
18
- <button type="button" class="datepicker-link" data-clear>Clear</button>
19
- </div>`}_monthsHtml(){let e=p(this._value),t=new Date,{monthDisabled:n}=this._limits(),r=``;for(let i=0;i<12;i++){let a=e&&e.y===this._viewY&&e.m===i,o=t.getFullYear()===this._viewY&&t.getMonth()===i,s=n(this._viewY,i),c=[`datepicker-cell`,o?`is-today`:``,a?`is-selected`:``].filter(Boolean).join(` `);r+=`<button type="button" class="${c}" data-month="${i}"${s?` disabled`:``}>${m[i].slice(0,3)}</button>`}return`
20
- <div class="datepicker-head">
21
- <button type="button" class="datepicker-nav-btn" data-nav-year="-1" aria-label="Previous year">${a(`chevron-left`)}</button>
22
- <button type="button" class="datepicker-month" data-view="years" aria-label="Choose year">${this._viewY}</button>
23
- <button type="button" class="datepicker-nav-btn" data-nav-year="1" aria-label="Next year">${a(`chevron-right`)}</button>
24
- </div>
25
- <div class="datepicker-cells">${r}</div>`}_yearsHtml(){let e=p(this._value),t=new Date().getFullYear(),{yearDisabled:n}=this._limits(),r=this._viewY-(this._viewY%10+10)%10-1,i=``;for(let a=0;a<12;a++){let o=r+a,s=e&&e.y===o,c=t===o,l=n(o),u=[`datepicker-cell`,c?`is-today`:``,s?`is-selected`:``].filter(Boolean).join(` `);i+=`<button type="button" class="${u}" data-year="${o}"${l?` disabled`:``}>${o}</button>`}return`
26
- <div class="datepicker-head">
27
- <button type="button" class="datepicker-nav-btn" data-nav-decade="-1" aria-label="Previous decade">${a(`chevron-left`)}</button>
28
- <span class="datepicker-month">${r+1} to ${r+10}</span>
29
- <button type="button" class="datepicker-nav-btn" data-nav-decade="1" aria-label="Next decade">${a(`chevron-right`)}</button>
30
- </div>
31
- <div class="datepicker-cells">${i}</div>`}_focusActive(){let e=this.querySelector(`.datepicker-pop`),t=e?.querySelector(`[tabindex="0"]`)||e?.querySelector(`.is-selected`)||e?.querySelector(`.datepicker-day:not(:disabled), .datepicker-cell:not(:disabled)`);t&&e.contains(document.activeElement)&&t.focus()}_position(e,t){r(e,t,{clampHeight:!0})}_setFocus(e,t,n,r){let{y:i,m:a}=f(e,t);this._focus={y:i,m:a,d:n};let o=i!==this._viewY||a!==this._viewM;this._viewY=i,this._viewM=a,this._slide=o&&r||``,this._renderView(),this._slide=``,this.querySelector(`.datepicker-day[data-iso="${c(i,a,n)}"]`)?.focus()}_onKey(e){if(this._mode!==`days`){e.key===`Escape`&&this._close();return}let t=this._focus||p(this._value)||{y:this._viewY,m:this._viewM,d:1},n=(n,r)=>{e.preventDefault();let i=new Date(t.y,t.m,t.d+n);this._setFocus(i.getFullYear(),i.getMonth(),i.getDate(),r)};switch(e.key){case`ArrowLeft`:return n(-1,`slide-prev`);case`ArrowRight`:return n(1,`slide-next`);case`ArrowUp`:return n(-7,`slide-prev`);case`ArrowDown`:return n(7,`slide-next`);case`Home`:return n(-((new Date(t.y,t.m,t.d).getDay()-this._firstDay()+7)%7),`slide-prev`);case`End`:return n(6-(new Date(t.y,t.m,t.d).getDay()-this._firstDay()+7)%7,`slide-next`);case`PageUp`:{e.preventDefault();let n=f(t.y,t.m-(e.shiftKey?12:1));return this._setFocus(n.y,n.m,Math.min(t.d,l(n.y,n.m)),`slide-prev`)}case`PageDown`:{e.preventDefault();let n=f(t.y,t.m+(e.shiftKey?12:1));return this._setFocus(n.y,n.m,Math.min(t.d,l(n.y,n.m)),`slide-next`)}case`Enter`:case` `:e.preventDefault(),this._limits().dayDisabled(t.y,t.m,t.d)||(this.value=c(t.y,t.m,t.d),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());return;case`Escape`:return this._close();default:}}_wire(){this._teardown();let e=this.querySelector(`.datepicker-trigger`),r=this.querySelector(`.datepicker-pop`),i=this.querySelector(`.datepicker`);if(!e||!r)return;let a=()=>!r.hidden,o=()=>{a()&&this._position(e,r)};this._open=()=>{let n=new Date,a=p(this._value);(a||!this._viewNavigated)&&(this._viewY=n.getFullYear(),this._viewM=n.getMonth()),this._mode=`days`;let s=n.getFullYear()===this._viewY&&n.getMonth()===this._viewM,c=a&&a.y===this._viewY&&a.m===this._viewM;this._focus=c?a:{y:this._viewY,m:this._viewM,d:s?n.getDate():1},this._renderView(),r.hidden=!1,i?.classList.add(`open`),this._position(e,r),t(this,o),e.setAttribute(`aria-expanded`,`true`),r.querySelector(`[tabindex="0"]`)?.focus()},this._close=()=>{r.hidden=!0,i?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),n(this),e.focus()},e.addEventListener(`click`,()=>a()?this._close():this._open()),r.addEventListener(`click`,e=>{this._popClick=!0;let t=e.target.closest(`[data-nav]`);if(t){this._viewNavigated=!0,this._slide=Number(t.dataset.nav)<0?`slide-prev`:`slide-next`;let e=f(this._viewY,this._viewM+Number(t.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._focus={y:e.y,m:e.m,d:1},this._renderView(),this._slide=``;return}let n=e.target.closest(`[data-nav-year]`);if(n){this._viewY+=Number(n.dataset.navYear),this._renderView();return}let r=e.target.closest(`[data-nav-decade]`);if(r){this._viewY+=Number(r.dataset.navDecade)*10,this._renderView();return}let i=e.target.closest(`[data-view]`);if(i){this._mode=i.dataset.view,this._renderView();return}let a=e.target.closest(`[data-month]`);if(a&&!a.disabled){this._viewNavigated=!0,this._viewM=Number(a.dataset.month),this._mode=`days`,this._focus={y:this._viewY,m:this._viewM,d:1},this._renderView();return}let o=e.target.closest(`[data-year]`);if(o&&!o.disabled){this._viewNavigated=!0,this._viewY=Number(o.dataset.year),this._mode=`months`,this._renderView();return}if(e.target.closest(`[data-today]`)){let e=new Date;if(this._limits().dayDisabled(e.getFullYear(),e.getMonth(),e.getDate()))return;this.value=c(e.getFullYear(),e.getMonth(),e.getDate()),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}if(e.target.closest(`[data-clear]`)){this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}let s=e.target.closest(`.datepicker-day[data-iso]`);s&&!s.disabled&&(this.value=s.dataset.iso,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}),this._onKeyBound=e=>{a()&&this._onKey(e)},r.addEventListener(`keydown`,this._onKeyBound),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,a()&&!t&&!this.contains(e.target)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{a()&&e.key===`Escape`&&this._close()},document.addEventListener(`keydown`,this._onDocKey),a()&&t(this,o)},this._bindGlobal(),this._syncFormValue()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),n(this)}disconnectedCallback(){this._teardown()}};export{h as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";var t=[50,90],n=10,r=100;function i(e,i=t){let a=Array.isArray(e)?e:String(e??``).split(`,`),o=[];for(let e of a){if(typeof e==`string`&&e.trim()===``)return i;let t=Number(e);if(!Number.isFinite(t)||t<n||t>r)return i;o.includes(t)||o.push(t)}return o.length?o.sort((e,t)=>e-t):i}function a({points:e,index:t,visible:n,velocity:r,canDismiss:i}){let a=i?-1:0;if(Math.abs(r)>=.5)return r>0?Math.max(t-1,a):Math.min(t+1,e.length-1);if(i&&n<e[0]/2)return-1;let o=0;for(let t=1;t<e.length;t++)Math.abs(e[t]-n)<Math.abs(e[o]-n)&&(o=t);return o}var o=`(max-width: 767.98px)`,s=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,c=4,l=0,u=new WeakSet;function d(e){u.has(e)||(u.add(e),e.addEventListener(`click`,t=>{let n=t.target?.closest?.(`[data-wui-drawer-open]`);if(!n)return;let r=n.getAttribute(`data-wui-drawer-open`).replace(/^#/,``),i=e.getElementById(r);typeof i?.show==`function`&&(t.preventDefault(),i.show(n))}))}var f=class extends e{static get observedAttributes(){return[`open`,`snap-points`]}constructor(){super(),this._doc=null,this._media=null,this._shown=!1,this._locked=!1,this._opener=null,this._snap=0,this._drag=null,this._onMedia=()=>this._syncMode(),this._onClick=e=>this._click(e),this._onPointerDown=e=>this._pointerDown(e),this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onKeyDown=e=>this._keyDown(e)}connectedCallback(){this._doc=this.ownerDocument,d(this._doc),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown),this._media=typeof matchMedia==`function`?matchMedia(o):null,this._media?.addEventListener?.(`change`,this._onMedia),this._syncMode(),this._applyPoints(),this.hasAttribute(`open`)?this._open():this.setAttribute(`inert`,``)}disconnectedCallback(){this._endDrag(),this._shown&&this._release(),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown),this._media?.removeEventListener?.(`change`,this._onMedia),this._media=null,this._doc=null}attributeChangedCallback(e){this._doc&&(e===`open`?this.hasAttribute(`open`)?this._open():this._close():(this._snap=Math.min(this._snap,this._points().length-1),this._applyPoints()))}get isOpen(){return this.hasAttribute(`open`)}show(e){e&&(this._opener=e),this.setAttribute(`open`,``)}hide(){this.removeAttribute(`open`)}_points(){return i(this.getAttribute(`snap-points`),t)}_sheet(){return!!this._media?.matches}_syncMode(){this.setAttribute(`data-mode`,this._sheet()?`sheet`:`side`)}_applyPoints(){let e=this._points();this._snap=Math.min(Math.max(this._snap,0),e.length-1),this.style.setProperty(`--wui-drawer-max`,String(e[e.length-1])),this.style.setProperty(`--wui-drawer-snap`,String(e[this._snap])),this.setAttribute(`data-snap`,String(this._snap));let t=this.querySelector(`.wui-drawer-handle`);if(!t)return;let n=e[this._snap];t.setAttribute(`aria-valuemin`,String(e[0])),t.setAttribute(`aria-valuemax`,String(e[e.length-1])),t.setAttribute(`aria-valuenow`,String(n)),t.setAttribute(`aria-valuetext`,`${n}% of the screen`)}_setSnap(e){let t=this._points(),n=Math.min(Math.max(e,0),t.length-1),r=n!==this._snap;this._snap=n,this._applyPoints(),r&&this.dispatchEvent(new CustomEvent(`wui-drawer-snap`,{bubbles:!0,detail:{index:n,percent:t[n]}}))}_open(){if(this._shown)return;this._shown=!0;let e=this._doc;this._opener??=e.activeElement;let t=Number.parseInt(this.getAttribute(`default-snap`)??`0`,10);this._snap=Number.isFinite(t)?t:0,this._syncMode(),this._applyPoints(),this.removeAttribute(`inert`),this._locked||(this._locked=!0,l++,e.body.classList.add(`wui-drawer-locked`)),e.addEventListener(`keydown`,this._onKeyDown),this._focusIn()}_close(){if(!this._shown)return;this._endDrag(),this.setAttribute(`inert`,``);let e=this._doc,t=this._opener,n=e.activeElement;this._release(),this._opener=null,t?.isConnected&&(n===e.body||this.contains(n))&&t.focus?.()}_release(){this._shown=!1,this._doc?.removeEventListener(`keydown`,this._onKeyDown),this._locked&&(this._locked=!1,l--,l<=0&&(l=0,this._doc?.body.classList.remove(`wui-drawer-locked`)))}_panel(){return this.querySelector(`.wui-drawer-panel`)}_focusables(){let e=this._panel();return e?Array.from(e.querySelectorAll(s)).filter(e=>!e.closest(`[hidden],[inert]`)):[]}_focusIn(){let e=this._panel();if(!e)return;let t=e.querySelector(`[data-autofocus]`),n=this._sheet()?null:this._focusables().find(e=>e.closest(`.wui-drawer-body`));(t||n||e).focus?.()}_requestClose(){let e=this.dispatchEvent(new CustomEvent(`wui-drawer-close`,{bubbles:!0,cancelable:!0}));return e&&this.hide(),e}_click(e){if(!this.isOpen)return;let t=e.target;(t.closest?.(`[data-wui-drawer-close]`)||t.closest?.(`[data-wui-drawer-backdrop]`)&&!this.hasAttribute(`static`))&&this._requestClose()}_keyDown(e){if(e.key===`Escape`){if(e.defaultPrevented||this.hasAttribute(`static`))return;e.preventDefault(),this._requestClose();return}if(e.key===`Tab`){this._trapTab(e);return}e.target?.closest?.(`.wui-drawer-handle`)&&this._sheet()&&this._handleKey(e)}_trapTab(e){let t=this._focusables(),n=this._panel();if(!t.length){e.preventDefault(),n?.focus?.();return}let r=t[0],i=t[t.length-1],a=this._doc.activeElement;!n?.contains(a)||a===n?(e.preventDefault(),(e.shiftKey?i:r).focus()):e.shiftKey&&a===r?(e.preventDefault(),i.focus()):!e.shiftKey&&a===i&&(e.preventDefault(),r.focus())}_handleKey(e){let t=this._points().length-1,n={ArrowUp:this._snap+1,ArrowDown:this._snap-1,Home:0,End:t};e.key in n&&(e.preventDefault(),this._setSnap(n[e.key]))}_pointerDown(e){if(!this.isOpen||!this._sheet()||(e.button??0)!==0)return;let t=e.target?.closest?.(`[data-wui-drawer-grip]`);!t||e.target.closest(`button`)||(this._drag={grip:t,id:e.pointerId,startY:e.clientY,lastY:e.clientY,lastT:e.timeStamp,velocity:0,moved:!1},t.setPointerCapture?.(e.pointerId),t.addEventListener(`pointermove`,this._onPointerMove),t.addEventListener(`pointerup`,this._onPointerUp),t.addEventListener(`pointercancel`,this._onPointerUp))}_viewport(){return this._doc.defaultView.innerHeight}_pointerMove(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let n=e.clientY-t.startY;if(!t.moved&&Math.abs(n)<c)return;t.moved=!0,this.classList.add(`is-dragging`);let r=e.timeStamp-t.lastT;r>0&&(t.velocity=(e.clientY-t.lastY)/r),t.lastY=e.clientY,t.lastT=e.timeStamp;let i=this._points(),a=(i[i.length-1]-i[this._snap])/100*this._viewport();t.offset=Math.max(n,-a),this.style.setProperty(`--wui-drawer-drag`,`${t.offset}px`)}_pointerUp(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let{moved:n,velocity:r,offset:i=0}=t;if(this._endDrag(),!n)return;let o=this._points(),s=this._viewport(),c=(o[this._snap]/100*s-i)/(s/100),l=!this.hasAttribute(`static`),u=a({points:o,index:this._snap,visible:c,velocity:r,canDismiss:l});u>=0?this._setSnap(u):this._requestClose()}_endDrag(){let e=this._drag;e&&(this._drag=null,e.grip.releasePointerCapture?.(e.id),e.grip.removeEventListener(`pointermove`,this._onPointerMove),e.grip.removeEventListener(`pointerup`,this._onPointerUp),e.grip.removeEventListener(`pointercancel`,this._onPointerUp),this.classList.remove(`is-dragging`),this.style.removeProperty(`--wui-drawer-drag`))}};export{f as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-WcDeH46q.js";var i=300,a=150,o=`.wui-hover-card-trigger`,s=`.wui-hover-card-panel`,c=`a[href],button,input,select,textarea,[tabindex]`,l=0,u=class extends e{constructor(){super(),this._doc=null,this._timer=null,this._described=null,this._refocusing=!1,this._onOver=e=>{if(e.pointerType===`touch`||e.pointerType===`pen`)return;let t=this._zone(e.target);t===`panel`?this._clear():t===`trigger`&&this._schedule(!0)},this._onOut=e=>{e.pointerType===`touch`||e.pointerType===`pen`||this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onFocusIn=e=>{this._refocusing||(this._zone(e.target)===`trigger`?this._schedule(!0):this._zone(e.target)===`panel`&&this._clear())},this._onFocusOut=e=>{this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onKeyDown=e=>{if(e.key!==`Escape`||!this.isOpen)return;let t=this._panel?.contains(this.ownerDocument.activeElement);this._clear(),this._setOpen(!1),t&&(this._refocusing=!0,this._anchor?.focus(),this._refocusing=!1)}}get isOpen(){return this._panel?.hasAttribute(`data-open`)??!1}connectedCallback(){this._doc=this.ownerDocument,this.addEventListener(`pointerover`,this._onOver),this.addEventListener(`pointerout`,this._onOut),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut)}disconnectedCallback(){this._clear(),this.removeEventListener(`pointerover`,this._onOver),this.removeEventListener(`pointerout`,this._onOut),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._doc?.removeEventListener(`keydown`,this._onKeyDown),n(this),this._doc=null}get _trigger(){return this.querySelector(o)}get _panel(){return this.querySelector(s)}get _anchor(){let e=this._trigger;return e?.querySelector(c)??e}_zone(e){if(!(e instanceof Node)||!this.contains(e))return null;let t=e instanceof Element?e:e.parentElement;return this._panel?.contains(t)?`panel`:this._trigger?.contains(t)?`trigger`:null}_delay(e,t){let n=Number(this.getAttribute(e));return this.hasAttribute(e)&&Number.isFinite(n)&&n>=0?n:t}_clear(){this._timer!==null&&clearTimeout(this._timer),this._timer=null}_schedule(e){if(this._clear(),this.isOpen===e)return;let t=e?this._delay(`open-delay`,i):this._delay(`close-delay`,a);this._timer=setTimeout(()=>{this._timer=null,this._setOpen(e)},t)}_setOpen(e){let r=this._panel;!r||this.isOpen===e||(e?(r.setAttribute(`data-open`,``),this._reposition(),t(this,()=>this._reposition()),this._doc?.addEventListener(`keydown`,this._onKeyDown),this._describe(r)):(r.removeAttribute(`data-open`),n(this),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this._described?.removeAttribute(`aria-describedby`),this._described=null),this.dispatchEvent(new CustomEvent(e?`wui:hover-card:open`:`wui:hover-card:close`,{bubbles:!0})))}_reposition(){this.isOpen&&r(this._trigger,this._panel,{clampHeight:!0})}_describe(e){let t=this._anchor;t&&(e.id||=`wui-hover-card-${++l}`,t.setAttribute(`aria-describedby`,e.id),this._described=t)}};export{u as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{m as t,s as n,t as r}from"./formatters-BAE__8ye.js";import{c as i,o as a}from"./wuiHttp-BC8co934.js";var o=`wui-remote-modal`,s=`wui-modal-fullscreen`,c=Object.freeze({sm:380,md:440,lg:640,xl:880}),l=Object.freeze({loading:`Loading`,close:`Close`,retry:`Try again`,errorTitle:`This could not be loaded`,forbidden:`You do not have access to this.`,client:`It may have been moved or deleted.`,server:`Something went wrong on our side. Try again in a moment.`,network:`Could not reach the server. Check your connection and try again.`,submitFailed:`Your changes were not saved.`,invalid:`Some fields need attention.`}),u=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,d=`[aria-invalid="true"], .is-invalid, .input-validation-error`,f=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,p=`[data-wui-modal-content]`,m=`<button type="button" class="wui-modal-close" data-bs-dismiss="modal" aria-label="Close"><svg 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"></path></svg></button>`,h=new WeakMap,g=new WeakSet,_=()=>Object.assign(Error(`The remote modal load was aborted.`),{name:`AbortError`}),ee=e=>{let t=window.bootstrap?.Modal;if(!t)throw Error(`WUI.modal.load(${String(e)}): Bootstrap's bundle (window.bootstrap) is not loaded on this page.`);return t},v=e=>{let t=document.createElement(`span`);return t.textContent=e??``,t.innerHTML};function te(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(Object.hasOwn(c,e))return{px:c[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, fullscreen or a px number.`)}var ne=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:c.md}},y=(e,t)=>{e.classList.toggle(s,!!t.fullscreen),t.fullscreen?e.style.removeProperty(`--wui-modal-max-width`):e.style.setProperty(`--wui-modal-max-width`,`${t.px}px`)},re=[`center`,`top`];function ie(){let e=document.getElementById(o);return e||(e=document.createElement(`div`),e.id=o,e.className=`modal fade wui-modal-shell`,e.tabIndex=-1,e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`role`,`dialog`),e.setAttribute(`aria-modal`,`true`),e.style.setProperty(`--wui-modal-max-width`,`${c.md}px`),e.innerHTML=`<div class="modal-dialog modal-dialog-centered wui-rb-dialog"><div class="modal-content wui-modal"></div></div>`,document.body.appendChild(e),e)}var b=e=>`<div class="wui-modal-header"><div class="wui-modal-heading"><div class="wui-modal-headtext"><div class="wui-modal-title">${v(e)}</div></div></div>${m}</div>`,ae=e=>`<div class="modal-content wui-modal" aria-busy="true">${b(e)}<div class="wui-modal-body"><div class="wui-modal-loading" role="status"><span class="visually-hidden">${v(l.loading)}</span><div class="skeleton wui-modal-skeleton"></div><div class="skeleton wui-modal-skeleton"></div><div class="skeleton wui-modal-skeleton wui-modal-skeleton--short"></div></div></div></div>`,oe=(e,t)=>`<div class="modal-content wui-modal" data-wui-modal-error="${v(t)}">${b(e)}<div class="wui-modal-body"><div class="wui-modal-state" role="alert"><p class="wui-modal-state-title">${v(l.errorTitle)}</p><p class="wui-modal-state-text">${v(l[t]||l.server)}</p><div class="wui-modal-state-actions"><button type="button" class="btn btn-secondary" data-bs-dismiss="modal">${v(l.close)}</button><button type="button" class="btn btn-primary" data-wui-modal-retry>${v(l.retry)}</button></div></div></div></div>`,x=e=>{let t=document.createElement(`template`);return t.innerHTML=e,t.content.querySelector(`.modal-content`)},S=e=>e.shell.querySelector(`.modal-content`);function se(e){if(!e)return;e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}));let t=window.bootstrap,n=[t?.Tooltip,t?.Popover,t?.Dropdown].filter(e=>e?.getInstance);for(let t of[e,...e.querySelectorAll(`*`)])for(let e of n)e.getInstance(t)?.dispose()}function C(e,t){let n=S(e);se(n),n?n.replaceWith(t):e.shell.querySelector(`.modal-dialog`).appendChild(t),window.WUI?.refresh?.()}var w=e=>e.shell.classList.contains(`show`);function T(e,t){let n=t&&e.querySelector(d),r=n?n.matches(u)?n:n.querySelector(u)||n:null;if(!r){let t=[...e.querySelectorAll(u)];r=e.querySelector(`[data-autofocus]`)||t.find(e=>!e.classList.contains(`wui-modal-close`))||t[0]||e}r.focus?.()}function ce(e,t){let n=e.shell.querySelector(`[data-wui-modal-live]`);n||(n=document.createElement(`div`),n.className=`visually-hidden`,n.setAttribute(`aria-live`,`assertive`),n.setAttribute(`data-wui-modal-live`,``),e.shell.querySelector(`.modal-dialog`).appendChild(n)),n.textContent=``,n.textContent=t}var E=(e,t,n)=>e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}));function D(e){let t=h.get(e);return t||(t={shell:e,queue:a(),defaultSize:ne(e),defaultLabel:e.getAttribute(`aria-label`),placeholder:S({shell:e})?.outerHTML||`<div class="modal-content wui-modal"></div>`,remoteUrl:e.getAttribute(`data-wui-remote-url`),cache:e.getAttribute(`data-wui-remote-cache`)===`true`,loadedUrl:null,session:null},h.set(e,t),e.addEventListener(`submit`,e=>me(t,e)),e.addEventListener(`click`,e=>{!e.target.closest?.(`[data-wui-modal-retry]`)||!t.session||(e.preventDefault(),j(t,t.session))}),e.addEventListener(`hidden.bs.modal`,n=>{n.target===e&&le(t)}),e.addEventListener(`shown.bs.modal`,n=>{let r=S(t);n.target===e&&t.session&&r?.matches(p)&&!r.contains(document.activeElement)&&T(r,!1)}),t.remoteUrl&&e.addEventListener(`show.bs.modal`,n=>{n.target===e&&ue(t,n)}),t)}function O(e,t,n){e.session&&(e.queue.abort(),e.session.resolveClosed({status:`dismissed`,detail:{replaced:!0}}));let r,i=new Promise(e=>{r=e}),a={url:t,method:(n.method||`GET`).toUpperCase(),body:n.body,options:n,trigger:n.trigger||null,explicitSize:null,closing:null,resolveClosed:r,handle:null};return a.handle={el:e.shell,closed:i,close:()=>k(e,a,`dismissed`,null),reload:()=>j(e,a)},e.session=a,a}function k(e,t,n,r){e.session===t&&(t.closing={status:n,detail:r},window.bootstrap?.Modal?.getOrCreateInstance(e.shell).hide())}function le(e){let t=e.session;if(e.queue.abort(),e.session=null,t){let{status:n,detail:r}=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n,detail:r}),E(e.shell,`wui:modal:closed`,{status:n,url:t.url});let i=document.activeElement;t.trigger?.isConnected&&(!i||i===document.body||e.shell.contains(i))&&t.trigger.focus?.()}e.cache||(C(e,x(e.placeholder)),e.loadedUrl=null,y(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function ue(e,t){let n=t.relatedTarget instanceof Element?t.relatedTarget:null,r=n?.getAttribute(`data-wui-url`)||e.remoteUrl,i=O(e,r,{trigger:n});i.explicitSize=A(n?.getAttribute(`data-wui-size`)),i.explicitSize&&y(e.shell,i.explicitSize),!(e.cache&&e.loadedUrl===r)&&(e.loadedUrl&&C(e,x(e.placeholder)),j(e,i,{keepPlaceholder:!0}))}function A(e){try{return te(e)}catch(e){return console.error(e),null}}async function j(e,t,{keepPlaceholder:n=!1}={}){n||C(e,x(ae(t.options.title||M(e))));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if((r.kind===`ok`||r.kind===`validation`)&&N(e,t,r.html,!1))return e.loadedUrl=t.url,E(e.shell,`wui:modal:loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return C(e,x(oe(t.options.title||M(e),i))),w(e)&&T(S(e),!1),E(e.shell,`wui:modal:error`,{url:t.url,kind:i,status:r.status}),`error`}var M=e=>S(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``;function N(e,t,n,r){let i=document.createElement(`template`);i.innerHTML=n;let a=i.content.querySelectorAll(`script`);if(a.length){console.warn(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);for(let e of a)e.remove()}let o=i.content.querySelector(p);if(!o)return console.error(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;C(e,o),y(e.shell,t.explicitSize||A(o.getAttribute(`data-wui-size`))||e.defaultSize);let s=o.getAttribute(`data-wui-title`);return s&&e.shell.setAttribute(`aria-label`,s),w(e)&&T(o,r),!0}var de=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function P(e,t,n){let r=[...e.elements].filter(e=>e.matches(de));if(n){e.setAttribute(`data-wui-submitting`,``);let n=t&&r.includes(t)?t:r[0];for(let e of r)e.toggleAttribute(`data-wui-was-disabled`,e.disabled),e.disabled=!0;n&&(n.classList.add(`is-loading`),n.setAttribute(`aria-busy`,`true`),n.tagName===`BUTTON`&&n.insertAdjacentHTML(`afterbegin`,`<span class="spinner-border spinner-border-sm me-2" aria-hidden="true" data-wui-submit-spinner></span>`));return}e.removeAttribute(`data-wui-submitting`);for(let e of r)e.disabled=e.hasAttribute(`data-wui-was-disabled`),e.removeAttribute(`data-wui-was-disabled`),e.classList.remove(`is-loading`),e.removeAttribute(`aria-busy`),e.querySelector(`[data-wui-submit-spinner]`)?.remove()}function fe(e,t,n){let r=t.closest(`.wui-modal-body`)||t;r.querySelector(`[data-wui-modal-submit-error]`)?.remove();let i=document.createElement(`div`);i.className=`alert alert-danger wui-modal-submit-error`,i.setAttribute(`role`,`alert`),i.setAttribute(`data-wui-modal-submit-error`,``),i.textContent=`${l.submitFailed} ${l[n]||l.server}`,r.prepend(i),ce(e,i.textContent)}var pe=(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 me(e,t){let n=t.target,r=e.session;if(!(n instanceof HTMLFormElement)||!r||n.hasAttribute(`data-wui-native`)||!n.closest(p)||(t.preventDefault(),n.hasAttribute(`data-wui-submitting`)))return;let i=t.submitter||null,a=i?.getAttribute(`formaction`)||n.getAttribute(`action`)||r.url,o=(i?.getAttribute(`formmethod`)||n.getAttribute(`method`)||`GET`).toUpperCase(),s=new FormData(n);i?.name&&!s.has(i.name)&&s.append(i.name,i.value);let c=o===`GET`;P(n,i,!0);let u=await e.queue.run(c?pe(a,s):a,{method:o,body:c?void 0:s,navigate:r.options.navigate});if(e.session===r){if(n.isConnected&&P(n,i,!1),u.kind===`ok`&&u.result===`success`){he(e,r,u);return}if(!(u.kind===`aborted`||u.kind===`stale`||u.kind===`session`)){if(u.kind===`validation`&&N(e,r,u.html,!0)){let t=S(e).querySelector(f)?.textContent.replace(/\s+/g,` `).trim();ce(e,t||l.invalid);return}u.kind===`ok`&&u.html&&N(e,r,u.html,!1)||fe(e,n,u.kind===`ok`||u.kind===`validation`?`server`:u.kind)}}}function he(e,t,n){let r=n.message,i=n.redirect||null,a={url:t.url,trigger:t.trigger,handle:t.handle,message:r,redirect:i};if(r&&window.WUI?.toast?.(r,{variant:`success`}),E(t.trigger?.isConnected?t.trigger:document,`wui:modal:success`,a),t.options.onSuccess?.(a,t.handle),i&&(t.options.navigate||(e=>window.location.assign(e)))(i),n.keepOpen){n.html&&N(e,t,n.html,!1);return}k(e,t,`success`,a)}function ge(e){let t=e.target.closest?.(`[data-wui-modal]`);t&&(t.matches(`a[href]`)&&(e.ctrlKey||e.metaKey||e.shiftKey||e.button!==0)||(e.preventDefault(),I(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=>{e?.name!==`AbortError`&&console.error(e)})))}function F(e=document){let t=e.ownerDocument||e;g.has(t)||(g.add(t),t.addEventListener(`click`,ge));let n=[...e.querySelectorAll?.(`.modal[data-wui-remote-url]`)||[]];e.matches?.(`.modal[data-wui-remote-url]`)&&n.unshift(e);for(let e of n)D(e)}function I(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=ee(e),r=te(t.size),i=t.placement||`center`;if(!re.includes(i))throw TypeError(`WUI.modal.load: unsupported placement "${i}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(_());let a=ie();F(document);let o=D(a),s=w(o),c=O(o,e,t);c.explicitSize=r,y(a,r||o.defaultSize),a.querySelector(`.modal-dialog`).classList.toggle(`modal-dialog-centered`,i===`center`),t.title&&a.setAttribute(`aria-label`,t.title),s||(n.getInstance(a)?.dispose(),n.getOrCreateInstance(a,{backdrop:!t.staticBackdrop||`static`,keyboard:!t.staticBackdrop}));let l=s?Promise.resolve():new Promise(e=>a.addEventListener(`shown.bs.modal`,()=>e(),{once:!0})),u=j(o,c);s||n.getOrCreateInstance(a).show();let d=new Promise((e,n)=>{t.signal?.addEventListener(`abort`,()=>{o.session===c&&(o.queue.abort(),k(o,c,`dismissed`,{aborted:!0})),n(_())},{once:!0})}),f=Promise.all([l,u]).then(([,t])=>{if(t===`aborted`)throw _();if(t===`session`)throw Error(`WUI.modal.load(${e}): the session expired; the browser is signing in again.`);return c.handle});return Promise.race([f,d])}catch(e){return Promise.reject(e)}}var _e=Object.freeze([`neutral`,`primary`,`info`,`success`,`warning`,`danger`]),L=Object.freeze([`number`,`currency`,`compact`]),R=`wui-kanban:`,ve=`(max-width: 767.98px)`,ye=400,be=6,z=Object.freeze({help:`Press Space to pick up the card. Use the Left and Right arrow keys to choose a column, then Space to drop it, or Escape to cancel.`,empty:`Nothing here`,collapse:e=>`Collapse ${e}`,expand:e=>`Expand ${e}`,lifted:(e,t)=>`Picked up ${e} in ${t}. Use the Left and Right arrow keys to choose a column.`,over:(e,t)=>`${e}, ${t===1?`1 card`:`${t} cards`}. Drop allowed.`,overSource:e=>`${e}, where the card started.`,overRefused:(e,t)=>`${e}. ${t}`,dropHere:(e,t)=>`Drop here to move ${e} to ${t}.`,refused:(e,t)=>`Cards in ${e} cannot move to ${t}.`,moved:(e,t)=>`Moved ${e} to ${t}.`,saving:(e,t)=>`Moving ${e} to ${t}.`,cancelled:e=>`${e} was not moved.`,rolledBack:(e,t)=>`${e} went back to ${t}.`,locked:e=>`${e} cannot be moved.`,more:e=>`Show ${e} more`,fewer:`Show fewer`,swipeHint:`Swipe sideways or tap a column`,busy:`This card is still saving. Try again in a moment.`,failed:Object.freeze({forbidden:`You do not have permission to move this card.`,client:`This card could not be moved. Refresh the board and try again.`,validation:`This card could not be moved. Refresh the board and try again.`,server:`Something went wrong on our side, so the card went back. Try again in a moment.`,network:`Could not reach the server, so the card went back. Check your connection and try again.`})}),B=`[data-wui-column]`,V=`[data-wui-body]`,H=`[data-wui-card]`,xe=`[data-wui-count]`,Se=`[data-wui-summary]`,Ce=`[data-wui-empty]`,we=`[data-wui-drop-note]`,Te=`[data-wui-live]`,Ee=`[data-wui-help]`,U=`[data-wui-switch]`,De=`[data-wui-scroller]`,Oe=`[data-wui-collapse]`,ke=`[data-wui-more]`,Ae=`data-wui-visible-limit`,W=`data-wui-overflow`,je=`input, select, textarea, [contenteditable=""], [contenteditable="true"], [data-wui-no-drag]`,G=48,K=16,q=e=>e.getAttribute(`data-wui-column`),J=e=>e.getAttribute(`data-wui-card`),Y=e=>e.hidden||e.hasAttribute(`hidden`),Me=e=>Y(e)||e.hasAttribute(W);function Ne(e){if(e==null||e===``)return null;let t=typeof e==`number`?e:Number(e);if(!Number.isInteger(t)||t<1)throw TypeError(`Unsupported kanban visible limit "${String(e)}". Use a whole number of 1 or more.`);return t}function Pe(e,t,n,r){let i=new Set;if(t==null||n)return i;let a=0;for(let n of e)r.has(n)||(a<t?a++:i.add(n));return i}function X(e){let t=(e.getAttribute(`aria-label`)||e.textContent||``).replace(/\s+/g,` `).trim();return t.length>80?`${t.slice(0,79)}…`:t||J(e)||`Card`}function Z(e){return e?`${R}${e}`:null}function Q(e,t=globalThis.localStorage){let n=Z(e);if(!n||!t)return{};try{let e=JSON.parse(t.getItem(n)||`null`);return e&&typeof e.collapsed==`object`&&e.collapsed?e.collapsed:{}}catch{return{}}}function Fe(e,t,n,r=globalThis.localStorage){let i=Z(e);if(!i||!r)return;let a={...Q(e,r),[t]:!!n};try{r.setItem(i,JSON.stringify({collapsed:a}))}catch{}}function Ie(e,t){if(!L.includes(e))throw TypeError(`Unsupported kanban summary format "${String(e)}". Use ${L.join(`, `)}.`);if(t!=null&&t!==``&&!n.includes(t))throw TypeError(`Unsupported kanban summary unit "${String(t)}". Use ${n.join(`, `)}.`);return e===`currency`?{style:`currency`,unit:t||`rupees`}:e===`compact`?{style:`compact`,currency:r[0],unit:t||`rupees`}:{style:`number`,decimals:0}}function Le(e){let t=0;for(let n of e){if(n==null||n===``)continue;let e=typeof n==`number`?n:Number(n);Number.isFinite(e)&&(t+=e)}return t}var $=(e,t)=>{e&&window.WUI?.toast?.(e,{variant:t})},Re=class extends e{constructor(){super(),this._wired=!1,this._filter=null,this._expanded=new Set,this._revealed=new Set,this._press=null,this._drag=null,this._kbd=null,this._suppressClick=!1,this._observer=null,this._refreshQueued=!1,this._scrollTimer=0,this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onPointerCancel=()=>this._endPointer(!1),this._onDocKeyDown=e=>{e.key===`Escape`&&this._drag&&(e.preventDefault(),this._endPointer(!1))},this._onScroll=()=>{clearTimeout(this._scrollTimer),this._scrollTimer=setTimeout(()=>this._syncSwitcherFromScroll(),80)}}_controlled(){return this.hasAttribute(`controlled`)}connectedCallback(){if(!this._wired){this._wired=!0,this.addEventListener(`pointerdown`,e=>this._pointerDown(e)),this.addEventListener(`keydown`,e=>this._keyDown(e)),this.addEventListener(`click`,e=>this._click(e),!0),this.addEventListener(`dragstart`,e=>{e.target.closest?.(H)&&e.preventDefault()}),this.addEventListener(`touchmove`,e=>{this._drag&&e.preventDefault()},{passive:!1}),this._scroller()?.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._restoreCollapsed();for(let e of this._allCards())this._prepareCard(e);if(typeof MutationObserver==`function`){this._observer=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e.nodeType===1&&e.matches(H)&&this._prepareCard(e);this._queueRefresh()});for(let e of this.querySelectorAll(V))this._observer.observe(e,{childList:!0})}this.refresh()}}disconnectedCallback(){this._endPointer(!1),this._observer?.disconnect(),this._observer=null,this._scroller()?.removeEventListener(`scroll`,this._onScroll),clearTimeout(this._scrollTimer),this._wired=!1}setFilter(e){if(e!=null&&typeof e!=`function`)throw TypeError(`wui-kanban setFilter: pass a function or null.`);if(this._filter=e,!e)for(let e of this._allCards())e.hidden=!1;this.refresh()}refresh(){if(this._controlled())return;this._refreshQueued=!1;let e=this._summaryFormat();for(let n of this._columns()){let r=q(n),i=Ne(n.getAttribute(Ae)),a=[],o=[];for(let e of this._cardsIn(n)){if(this._filter&&(e.hidden=this._filter(e)===!1),Y(e)){e.removeAttribute(W);continue}a.push(e),o.push(e.getAttribute(`data-wui-value`))}let s=this._expanded.has(r),c=Pe(a.map(J),i,s,this._revealed);for(let e of a)e.toggleAttribute(W,c.has(J(e)));let l=String(a.length);for(let e of this._countsOf(n))e.textContent!==l&&(e.textContent=l);let u=n.querySelector(Ce);if(u&&(u.hidden=a.length>0),e){let r=n.querySelector(Se);r&&(r.textContent=t(Le(o),e))}let d=n.querySelector(ke);if(d){d.hidden=i==null||(s?a.length<=i:c.size===0),d.setAttribute(`aria-expanded`,s?`true`:`false`);let e=s?z.fewer:z.more(c.size);d.textContent!==e&&(d.textContent=e)}}}moveCard(e,t,n){let r=this._cardByKey(e);if(!r)throw Error(`wui-kanban moveCard: no card "${String(e)}" on this board.`);if(!this._columnByKey(t))throw Error(`wui-kanban moveCard: no column "${String(t)}" on this board.`);return this._commit(r,t,n)}_columns(){return[...this.querySelectorAll(B)]}_columnByKey(e){return this._columns().find(t=>q(t)===e)||null}_columnOf(e){return e.closest(B)}_titleOf(e){return(e.querySelector(`.wui-kanban-title`)?.textContent||q(e)||``).replace(/\s+/g,` `).trim()}_bodyOf(e){return e.querySelector(V)}_cardsIn(e){let t=this._bodyOf(e);return t?[...t.children].filter(e=>e.matches(H)):[]}_visibleCardsIn(e){return this._cardsIn(e).filter(e=>!Me(e))}_allCards(){return[...this.querySelectorAll(`${V} > ${H}`)]}_cardByKey(e){return this._allCards().find(t=>J(t)===e)||null}_countsOf(e){let t=q(e),n=[...this.querySelectorAll(U)].filter(e=>e.getAttribute(`data-wui-switch`)===t);return[...e.querySelectorAll(xe),...n.flatMap(e=>[...e.querySelectorAll(xe)])]}_scroller(){return this.querySelector(De)}_summaryFormat(){let e=this.getAttribute(`summary-format`);return e?Ie(e,this.getAttribute(`summary-unit`)):null}_queueRefresh(){this._refreshQueued||(this._refreshQueued=!0,queueMicrotask(()=>{this._refreshQueued&&this.refresh()}))}_prepareCard(e){let t=this.querySelector(Ee);t?.id&&!e.hasAttribute(`aria-describedby`)&&e.setAttribute(`aria-describedby`,t.id),e.hasAttribute(`tabindex`)||(e.tabIndex=0)}_announce(e){let t=this.querySelector(Te);!t||!e||(t.textContent=``,t.textContent=e)}_fire(e,t,n=!1){return this.dispatchEvent(new CustomEvent(e,{bubbles:!0,cancelable:n,detail:t}))}_canLift(e){let t=X(e),n=this.hasAttribute(`readonly`);return n||e.hasAttribute(`data-wui-locked`)?(this._announce(z.locked(t)),this._fire(`wui:kanban:locked`,{key:J(e),card:e,reason:n?`readonly`:`locked`},!0),!1):e.getAttribute(`aria-busy`)===`true`?(this._announce(z.busy),$(z.busy,`info`),!1):!0}_check(e,t,n){if(t===n)return{ok:!1,source:!0,reason:null};let r=this._columnByKey(t),i=this._columnByKey(n),a=z.refused(r?this._titleOf(r):t,i?this._titleOf(i):n),o=i?.getAttribute(`data-accept-from`);if(o!=null&&!o.split(/\s+/).filter(Boolean).includes(t))return{ok:!1,reason:a};if(typeof this.accept==`function`){let r=this.accept(e,t,n);if(r===!1)return{ok:!1,reason:a};if(typeof r==`string`&&r)return{ok:!1,reason:r}}return{ok:!0,reason:null}}_markTargets(e,t){let n=X(e),r=new Map;for(let i of this._columns()){let a=q(i),o=this._check(e,t,a);r.set(a,o),i.setAttribute(`data-wui-drop`,o.source?`source`:o.ok?`ok`:`refused`);let s=i.querySelector(we);s&&!o.source&&(s.textContent=o.ok?z.dropHere(n,this._titleOf(i)):o.reason,s.hidden=!1)}return r}_clearTargets(){for(let e of this._columns()){e.removeAttribute(`data-wui-drop`),e.removeAttribute(`data-wui-over`),e.removeAttribute(`data-wui-target`);let t=e.querySelector(we);t&&(t.hidden=!0,t.textContent=``)}}async _commit(e,t,n){let r=this._columnOf(e),a=q(r),o=this._columnByKey(t),s=X(e);if(a===t||!this._canLift(e))return!1;let c=this._check(e,a,t);if(!c.ok)return this._announce(c.reason),$(c.reason,`info`),!1;let l=this._cardsIn(o),u=Number.isInteger(n)?Math.max(0,Math.min(n,l.length)):l.length,d={key:J(e),card:e,from:a,to:t,index:u},f=e.contains(document.activeElement);if(this._controlled())return this._fire(`wui:kanban:move`,d),this._announce(z.moved(s,this._titleOf(o))),f&&this._refocusSoon(d.key),!0;if(!this._fire(`wui:kanban:move`,d,!0))return!1;let p=o.hasAttribute(Ae)&&!this._revealed.has(d.key);p&&this._revealed.add(d.key);let m={parent:e.parentNode,next:e.nextSibling,column:r,revealed:p};this._bodyOf(o).insertBefore(e,l[u]||null),f&&this._focusMoved(e),this.refresh();let h=o.getAttribute(`data-wui-step`);if(h)return this._runStep(e,d,m,h,o.getAttribute(`data-wui-step-size`));let g=this.getAttribute(`move-url`);if(!g)return this._announce(z.moved(s,this._titleOf(o))),this._fire(`wui:kanban:moved`,{...d,result:null}),!0;this._lock(e,!0),this._announce(z.saving(s,this._titleOf(o)));let _=await i(g,{method:`POST`,body:new URLSearchParams({card:d.key,from:a,to:t,index:String(u)})});if(this._lock(e,!1),_.kind===`session`)return!1;if(_.ok){let t=this._applyFragment(_.html)||e;return $(_.message,`success`),this._announce(z.moved(X(t),this._titleOf(o))),this._fire(`wui:kanban:moved`,{...d,card:t,result:_}),!0}return this._rollback(e,m),_.kind!==`aborted`&&$(_.message||z.failed[_.kind]||z.failed.server,`danger`),this._fire(`wui:kanban:failed`,{...d,kind:_.kind,status:_.status,message:_.message}),!1}async _runStep(e,t,n,r,a){let o=X(e),s=this._columnByKey(t.to),c=new URLSearchParams({card:t.key,from:t.from,to:t.to}).toString(),l=r+(r.includes(`?`)?`&`:`?`)+c;this._lock(e,!0);let u;try{u=await(await I(l,{trigger:e,size:a||void 0})).closed}catch(r){return this._lock(e,!1),this._rollback(e,n),r?.name!==`AbortError`&&$(z.failed.server,`danger`),this._fire(`wui:kanban:failed`,{...t,kind:`step`,status:0,message:r?.message??null}),!1}if(u?.status!==`success`)return this._lock(e,!1),this._rollback(e,n),this._announce(z.cancelled(o)),this._fire(`wui:kanban:failed`,{...t,kind:`dismissed`,status:0,message:null}),!1;let d=e,f=this.getAttribute(`card-url`);if(f){let n=await i(`${f}${f.includes(`?`)?`&`:`?`}${new URLSearchParams({card:t.key})}`);n.ok&&(d=this._applyFragment(n.html)||e)}return this._lock(d,!1),this._announce(z.moved(X(d),this._titleOf(s))),this._fire(`wui:kanban:moved`,{...t,card:d,result:u}),!0}_lock(e,t){t?(e.setAttribute(`aria-busy`,`true`),e.setAttribute(`data-wui-saving`,``)):(e.removeAttribute(`aria-busy`),e.removeAttribute(`data-wui-saving`))}_rollback(e,t){let n=e.contains(document.activeElement),r=t.next&&t.next.parentNode===t.parent?t.next:null;t.revealed&&this._revealed.delete(J(e)),t.parent.insertBefore(e,r),n&&e.focus(),this.refresh(),this._announce(z.rolledBack(X(e),this._titleOf(t.column)))}_applyFragment(e){if(!e)return null;let t=document.createElement(`template`);t.innerHTML=e;for(let e of t.content.querySelectorAll(`script`))console.warn(`[@webority/ui-elements] A kanban fragment carried a script tag; it was removed, not run.`),e.remove();let n=null;for(let e of[...t.content.querySelectorAll(H)]){if(e.closest(`template`))continue;let t=this._cardByKey(J(e));if(!t)continue;let r=t.contains(document.activeElement);t.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),t.hidden&&(e.hidden=!0),t.replaceWith(e),this._prepareCard(e),r&&e.focus(),n??=e}for(let e of t.content.querySelectorAll(`template[data-wui-kanban-summary]`))this._columnByKey(e.getAttribute(`data-wui-kanban-summary`))?.querySelector(Se)?.replaceChildren(e.content.cloneNode(!0));return this.refresh(),window.WUI?.refresh?.(),n}_refocusSoon(e){let t=()=>{let t=this._cardByKey(e);t&&this._focusMoved(t)};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}_focusMoved(e){e.focus({preventScroll:!0}),e.scrollIntoView?.({block:`nearest`})}_pointerDown(e){if(e.button!==0||e.isPrimary===!1||this._drag||this._kbd)return;let t=e.target.closest?.(H);if(!t||!this.contains(t)||e.target.closest(je))return;let n={card:t,id:e.pointerId,x:e.clientX,y:e.clientY,type:e.pointerType,timer:0};this._press=n,e.pointerType===`touch`&&(n.timer=setTimeout(()=>{this._press===n&&this._startDrag(n,n.x,n.y)},400)),window.addEventListener(`pointermove`,this._onPointerMove),window.addEventListener(`pointerup`,this._onPointerUp),window.addEventListener(`pointercancel`,this._onPointerCancel)}_pointerMove(e){let t=this._press;if(!(!t||e.pointerId!==t.id)){if(!this._drag){if(!(Math.hypot(e.clientX-t.x,e.clientY-t.y)>6))return;if(t.type===`touch`){this._endPointer(!1);return}if(this._startDrag(t,e.clientX,e.clientY),!this._drag)return}this._dragTo(e.clientX,e.clientY)}}_pointerUp(e){!this._press||e.pointerId!==this._press.id||this._endPointer(!!this._drag)}_startDrag(e,t,n){let r=e.card;if(!this._canLift(r)){this._endPointer(!1);return}let i=q(this._columnOf(r)),a=r.getBoundingClientRect(),o=r.cloneNode(!0);for(let e of[o,...o.querySelectorAll(`[id]`)])e.removeAttribute(`id`);o.removeAttribute(`data-wui-card`),o.removeAttribute(`tabindex`),o.setAttribute(`aria-hidden`,`true`),o.classList.add(`wui-kanban-ghost`),o.style.width=`${a.width}px`,this.appendChild(o),r.setAttribute(`data-wui-dragging`,``),this.setAttribute(`data-wui-dragging`,``),this._drag={card:r,from:i,ghost:o,dx:t-a.left,dy:n-a.top,over:null,verdicts:this._markTargets(r,i)},this._announce(z.lifted(X(r),this._titleOf(this._columnOf(r)))),document.addEventListener(`keydown`,this._onDocKeyDown),this._dragTo(t,n)}_dragTo(e,t){let n=this._drag;n.x=e,n.y=t,n.ghost.style.transform=`translate(${e-n.dx}px, ${t-n.dy}px)`;let r=this._columnAt(e,t);r!==n.over&&(n.over?.removeAttribute(`data-wui-over`),r?.setAttribute(`data-wui-over`,``),n.over=r),this._autoScroll(e,t,r)}_columnAt(e,t){for(let n of this._columns()){let r=n.getBoundingClientRect();if(e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom)return n}return null}_indexAt(e,t){let n=this._visibleCardsIn(e).filter(e=>e!==this._drag?.card).find(e=>{let n=e.getBoundingClientRect();return t<n.top+n.height/2}),r=this._cardsIn(e).filter(e=>e!==this._drag?.card);return n?r.indexOf(n):r.length}_autoScroll(e,t,n){let r=this._scroller();if(r){let t=r.getBoundingClientRect();t.width>0&&(e<t.left+G?r.scrollBy?.({left:-16}):e>t.right-G&&r.scrollBy?.({left:K}))}if(n&&this._scrollColumn(n,t))return;let i=window.innerHeight||0;i>0&&(t<G?window.scrollBy?.({top:-16}):t>i-G&&window.scrollBy?.({top:K}))}_scrollColumn(e,t){let n=this._bodyOf(e);if(!n||e.hasAttribute(`data-collapsed`)||n.scrollHeight<=n.clientHeight)return!1;let r=n.getBoundingClientRect();return t<r.top+G&&n.scrollTop>0?(n.scrollBy?.({top:-16}),!0):t>r.bottom-G&&n.scrollTop+n.clientHeight<n.scrollHeight-1?(n.scrollBy?.({top:K}),!0):!1}_endPointer(e){let t=this._press,n=this._drag;if(t&&clearTimeout(t.timer),this._press=null,this._drag=null,window.removeEventListener(`pointermove`,this._onPointerMove),window.removeEventListener(`pointerup`,this._onPointerUp),window.removeEventListener(`pointercancel`,this._onPointerCancel),document.removeEventListener(`keydown`,this._onDocKeyDown),!n)return;n.ghost.remove(),n.card.removeAttribute(`data-wui-dragging`),this.removeAttribute(`data-wui-dragging`),this._suppressClick=!0,setTimeout(()=>{this._suppressClick=!1},0);let r=n.over;if(this._clearTargets(),!e||!r){this._announce(z.cancelled(X(n.card)));return}let i=q(r),a=n.verdicts.get(i);if(a?.source){this._announce(z.cancelled(X(n.card)));return}if(!a?.ok){this._announce(a?.reason),$(a?.reason,`info`);return}this._commit(n.card,i,this._indexAt(r,n.y))}_click(e){if(this._suppressClick&&e.target.closest?.(H)){e.preventDefault(),e.stopPropagation(),this._suppressClick=!1;return}let t=e.target.closest?.(Oe);if(t&&this.contains(t)){let e=t.closest(B);e&&this._setCollapsed(e,!e.hasAttribute(`data-collapsed`),!0);return}let n=e.target.closest?.(ke);if(n&&this.contains(n)){this._controlled()||this._toggleMore(n.closest(B));return}let r=e.target.closest?.(U);r&&this.contains(r)&&this._showColumn(r.getAttribute(`data-wui-switch`))}_keyDown(e){if(this._kbd){this._liftedKey(e);return}let t=e.target;if(!t.matches?.(H)||!this.contains(t))return;let n=this._columnOf(t);switch(e.key){case` `:case`Spacebar`:{if(e.preventDefault(),!this._canLift(t))return;let r=q(n),i=this._columns();this._kbd={card:t,from:r,target:i.indexOf(n),verdicts:this._markTargets(t,r)},t.setAttribute(`data-wui-lifted`,``),this.setAttribute(`data-wui-dragging`,``),n.setAttribute(`data-wui-target`,``),this._announce(z.lifted(X(t),this._titleOf(n)));return}case`ArrowDown`:case`ArrowUp`:{let r=this._visibleCardsIn(n),i=r[r.indexOf(t)+(e.key===`ArrowDown`?1:-1)];i&&(e.preventDefault(),i.focus());return}case`ArrowLeft`:case`ArrowRight`:{let t=this._columns(),r=e.key===`ArrowRight`?1:-1;for(let i=t.indexOf(n)+r;i>=0&&i<t.length;i+=r){let n=this._visibleCardsIn(t[i])[0];if(n&&!t[i].hasAttribute(`data-collapsed`)){e.preventDefault(),n.focus();return}}return}default:}}_liftedKey(e){let t=this._kbd,n=this._columns();switch(e.key){case`ArrowLeft`:case`ArrowRight`:{e.preventDefault();let r=t.target+(e.key===`ArrowRight`?1:-1);if(r<0||r>=n.length)return;n[t.target]?.removeAttribute(`data-wui-target`),t.target=r;let i=n[r];i.setAttribute(`data-wui-target`,``),this._showColumn(q(i),!1);let a=t.verdicts.get(q(i)),o=this._titleOf(i);this._announce(a.source?z.overSource(o):a.ok?z.over(o,this._cardsIn(i).filter(e=>!Y(e)).length):z.overRefused(o,a.reason));return}case` `:case`Spacebar`:case`Enter`:{e.preventDefault();let r=n[t.target],i=q(r),a=t.verdicts.get(i);if(!a.source&&!a.ok){this._announce(a.reason);return}this._endKeyboard(),a.source?this._announce(z.cancelled(X(t.card))):this._commit(t.card,i);return}case`Escape`:case`Tab`:e.key===`Escape`&&e.preventDefault(),this._endKeyboard(),this._showColumn(t.from,!1),this._announce(z.cancelled(X(t.card)));return;default:}}_endKeyboard(){let e=this._kbd;this._kbd=null,e&&(e.card.removeAttribute(`data-wui-lifted`),this.removeAttribute(`data-wui-dragging`),this._clearTargets())}_restoreCollapsed(){let e=Q(this.getAttribute(`board-id`));for(let t of this._columns()){let n=q(t);t.hasAttribute(`data-collapsible`)&&Object.hasOwn(e,n)&&this._setCollapsed(t,e[n],!1)}}_setCollapsed(e,t,n){let r=q(e);e.toggleAttribute(`data-collapsed`,t);let i=this._titleOf(e);for(let n of e.querySelectorAll(Oe))n.setAttribute(`aria-expanded`,t?`false`:`true`),n.setAttribute(`aria-label`,t?z.expand(i):z.collapse(i));n&&(Fe(this.getAttribute(`board-id`),r,t),this._fire(`wui:kanban:collapse`,{column:r,collapsed:t}))}_toggleMore(e){if(!e)return;let t=q(e);if(this._expanded.delete(t))for(let t of this._cardsIn(e))this._revealed.delete(J(t));else this._expanded.add(t);this.refresh()}_isPhone(){return typeof matchMedia==`function`&&matchMedia(`(max-width: 767.98px)`).matches}_showColumn(e,t=!0){for(let t of this.querySelectorAll(U))t.getAttribute(`data-wui-switch`)===e?t.setAttribute(`aria-current`,`true`):t.removeAttribute(`aria-current`);let n=this._columnByKey(e),r=this._scroller();if(!n||!r||!t&&!this._isPhone())return;let i=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.scrollTo?.({left:n.offsetLeft-r.offsetLeft,behavior:i?`auto`:`smooth`})}_syncSwitcherFromScroll(){let e=this._scroller();if(!e||!this._isPhone())return;let t=e.clientWidth||1,n=this._columns()[Math.round(e.scrollLeft/t)];if(n)for(let e of this.querySelectorAll(U))e.getAttribute(`data-wui-switch`)===q(n)?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`)}};export{c as _,L as a,Re as c,Z as d,Ie as f,Fe as g,Le as h,R as i,X as l,Q as m,ye as n,z as o,Ne as p,ve as r,_e as s,be as t,Pe as u,F as v,I as y};