@webority/ui-elements 0.175.0 → 0.176.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/WuiCommentThread-D8Cv8y8v.js +1 -0
- package/dist/WuiInlineEdit-B7VCQXeG.js +1 -0
- package/dist/{WuiMentionInput-DJv-WwW6.js → WuiMentionInput-DAPLGewp.js} +1 -1
- package/dist/WuiNotificationCenter-BIxUJ0tJ.js +1 -0
- package/dist/{WuiSavedViews-OjB-ZiCo.js → WuiSavedViews-BmJmnkHu.js} +1 -1
- package/dist/{WuiSelect-D89S-POU.js → WuiSelect-CBcfLzOF.js} +1 -1
- package/dist/{WuiTree-CIOM1G59.js → WuiTree-C3yMSmC2.js} +1 -1
- package/dist/{chips-_rw5Aev4.js → chips-DpD0EbS0.js} +1 -1
- package/dist/{httpFailure.g-DBKzEpAf.js → commentThread.g-C7L18Tvy.js} +1 -1
- package/dist/drawerDiscard-Dl33Ytd2.js +1 -0
- package/dist/elements/comment-thread.js +1 -1
- package/dist/elements/inline-edit.js +1 -1
- package/dist/elements/kanban.js +1 -1
- package/dist/elements/mention-input.js +1 -1
- package/dist/elements/notification-center.js +1 -1
- package/dist/elements/saved-views.js +1 -1
- package/dist/elements/select.js +1 -1
- package/dist/elements/tree.js +1 -1
- package/dist/httpFailure.g-SkEFc60Y.js +1 -0
- package/dist/kanban-BCOQDfvj.js +1 -0
- package/dist/{loader-C2hgZrCR.js → loader-DvNLnnaO.js} +1 -1
- package/dist/{search-D-lfoHy9.js → search-BTNIAZY3.js} +1 -1
- package/dist/server.js +1 -1
- package/dist/text/en.json +1 -0
- package/dist/text.js +1 -1
- package/dist/ui-calendar.global.js +1 -1
- package/dist/ui-calendar.js +1 -1
- package/dist/ui-elements/carousel.global.js +1 -1
- package/dist/ui-elements/code-block.global.js +1 -1
- package/dist/ui-elements/command-palette.global.js +1 -1
- package/dist/ui-elements/comment-thread.global.js +1 -1
- package/dist/ui-elements/consent-banner.global.js +1 -1
- package/dist/ui-elements/context-menu.global.js +1 -1
- package/dist/ui-elements/date-range.global.js +1 -1
- package/dist/ui-elements/date-time.global.js +1 -1
- package/dist/ui-elements/datepicker.global.js +1 -1
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/dropdown.global.js +1 -1
- package/dist/ui-elements/entry-grid.global.js +1 -1
- package/dist/ui-elements/gantt.global.js +1 -1
- package/dist/ui-elements/glyphs.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +1 -1
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lead-popup.global.js +1 -1
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +1 -1
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/phone.global.js +1 -1
- package/dist/ui-elements/popover.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/select-chips.global.js +1 -1
- package/dist/ui-elements/select-recents.global.js +1 -1
- package/dist/ui-elements/select-search.global.js +1 -1
- package/dist/ui-elements/select-window.global.js +1 -1
- package/dist/ui-elements/slider.global.js +1 -1
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/table-export.global.js +1 -1
- package/dist/ui-elements/timepicker.global.js +1 -1
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree-picker.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +1 -1
- package/dist/ui-elements.js +1 -1
- package/dist/wuiHttp-BiwgFpmq.js +1 -0
- package/package.json +5 -5
- package/types/global/shared.d.ts +2 -0
- package/types/server/wuiHttp.d.ts +4 -3
- package/types/text/web/httpFailure.g.d.ts +1 -0
- package/dist/WuiCommentThread-C5n933uz.js +0 -1
- package/dist/WuiInlineEdit-BwB-w61N.js +0 -1
- package/dist/WuiNotificationCenter-1Hw7W0st.js +0 -1
- package/dist/drawerDiscard-D_n8guAp.js +0 -1
- package/dist/kanban-DlVHIpxL.js +0 -1
- package/dist/wuiHttp-BWf9dDsZ.js +0 -1
package/dist/ui-elements.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./elementBase-Cxeyx0tU.js";import{n as ee}from"./filterPopover-DskHFNLi.js";import{t}from"./kanban-
|
|
1
|
+
import{n as e}from"./elementBase-Cxeyx0tU.js";import{n as ee}from"./filterPopover-DskHFNLi.js";import{t}from"./kanban-BCOQDfvj.js";import{n}from"./statusIcons-Cd3GJcBR.js";import{t as r}from"./WuiCarousel-B0yPDH5I.js";import{t as i}from"./WuiCodeBlock-BWYZ1S70.js";import{t as a}from"./WuiCommandPalette-u1XD5WMv.js";import{t as o}from"./WuiCommentThread-D8Cv8y8v.js";import{t as s}from"./WuiConsentBanner-nTua-kEd.js";import{t as c}from"./WuiContextMenu-DEWYYFRG.js";import{t as l}from"./WuiDataTable-Ble3hl5L.js";import{t as u}from"./WuiDatePicker-3D33rzH4.js";import{t as d}from"./WuiDateRange-qTncGobM.js";import{t as f}from"./WuiDateTime-Vimu6grS.js";import{t as p}from"./WuiDock-2LGlbEFx.js";import{t as m}from"./WuiDrawer-BsY0fs_u.js";import{t as h}from"./WuiDropdown-6g074v1T.js";import{t as g}from"./WuiEntryGrid-DkW0tIDy.js";import{t as _}from"./WuiGantt-BqNhYIr6.js";import{t as v}from"./WuiHoverCard-DhJcIIM1.js";import{t as y}from"./WuiImageCrop-UakcSM2k.js";import{t as b}from"./WuiInlineEdit-B7VCQXeG.js";import{t as x}from"./WuiLeadPopup-DaYZ2zCJ.js";import{t as S}from"./WuiLightbox-DpHJAMO3.js";import{t as C}from"./WuiMarkdown-DsN4YbiZ.js";import{r as w}from"./WuiMentionInput-DAPLGewp.js";import{t as T}from"./WuiModal-DQbVJGUo.js";import{t as E}from"./WuiNavigationMenu-KdW7yuLn.js";import{t as D}from"./WuiNotificationCenter-BIxUJ0tJ.js";import{t as O}from"./WuiOnboardingChecklist-C-nllg2h.js";import{t as k}from"./WuiOrgTree-DWSk_LHd.js";import{t as A}from"./WuiOtp-Cc0formv.js";import{t as j}from"./WuiOverflow-fZKqdsr-.js";import{t as M}from"./WuiPhone-CBge7oVA.js";import{t as N}from"./WuiPopover-BvWKRNQY.js";import{t as P}from"./WuiRating-DIQfif9x.js";import{t as F}from"./WuiRecordPager-BXoe4KfU.js";import{t as I}from"./WuiRelativeTime-CSg9vzfk.js";import{t as L}from"./WuiSavedViews-BmJmnkHu.js";import{t as R}from"./WuiSelect-CBcfLzOF.js";import{t as z}from"./WuiShortcuts-CRCctX82.js";import{t as B}from"./WuiShowMore-BoYCrYYf.js";import{t as V}from"./WuiSlider-R_mTula0.js";import{t as H}from"./WuiSortable-x8Mg0tOv.js";import{t as U}from"./WuiTimePicker-DYLFaWDc.js";import{t as W}from"./WuiTour-BU00-6Lf.js";import{t as G}from"./WuiTree-C3yMSmC2.js";import{t as K}from"./WuiTreePicker-DLddmEgG.js";import{t as q}from"./WuiTruncate-BB4i8wHE.js";import{n as J,t as Y}from"./WuiWhatsNew-Dm4Yl68x.js";import{n as X,t as Z}from"./WuiWizardStep-gFtuUzsL.js";import{c as Q,f as te,l as ne,m as re,p as ie,s as ae,u as oe}from"./formatters-DTW53DjY.js";import{_ as se,r as ce}from"./themeTransition-DBv2olsl.js";import{t as le}from"./drawerDiscard-Dl33Ytd2.js";import{n as ue}from"./shortcutKeys-BMTWgV2g.js";function $(){ee(),e(`wui-select`,R),e(`wui-saved-views`,L),e(`wui-phone`,M),e(`wui-datepicker`,u),e(`wui-date-range`,d),e(`wui-date-time`,f),e(`wui-dock`,p),e(`wui-image-crop`,y),e(`wui-kanban`,t),e(`wui-lead-popup`,x),e(`wui-inline-edit`,b),e(`wui-consent-banner`,s),e(`wui-slider`,V),e(`wui-sortable`,H),e(`wui-timepicker`,U),e(`wui-tour`,W),e(`wui-tree`,G),e(`wui-tree-picker`,K),e(`wui-org-tree`,k),e(`wui-command-palette`,a),e(`wui-context-menu`,c),e(`wui-otp`,A),e(`wui-status-icon`,n),e(`wui-shortcuts`,z),e(`wui-record-pager`,F),e(`wui-carousel`,r),e(`wui-code-block`,i),e(`wui-markdown`,C),e(`wui-modal`,T),e(`wui-data-table`,l),e(`wui-drawer`,m),e(`wui-dropdown`,h),e(`wui-entry-grid`,g),e(`wui-gantt`,_),e(`wui-hover-card`,v),e(`wui-lightbox`,S),e(`wui-navigation-menu`,E),e(`wui-notification-center`,D),e(`wui-onboarding-checklist`,O),e(`wui-overflow`,j),e(`wui-popover`,N),e(`wui-rating`,P),e(`wui-relative-time`,I),e(`wui-show-more`,B),e(`wui-truncate`,q),e(`wui-whats-new`,J),e(`wui-mention-input`,w),e(`wui-comment-thread`,o),e(`wui-wizard-step`,Z),e(`wui-wizard`,X)}$();export{le as DISCARD_EVENT,se as ROW_DROP_EVENT,ue as SHORTCUT_EVENT,ce as THEME_CHANGE_EVENT,Y as WHATS_NEW_READ_EVENT,r as WuiCarousel,i as WuiCodeBlock,a as WuiCommandPalette,o as WuiCommentThread,s as WuiConsentBanner,c as WuiContextMenu,l as WuiDataTable,u as WuiDatePicker,d as WuiDateRange,f as WuiDateTime,p as WuiDock,m as WuiDrawer,h as WuiDropdown,g as WuiEntryGrid,_ as WuiGantt,v as WuiHoverCard,y as WuiImageCrop,b as WuiInlineEdit,t as WuiKanban,x as WuiLeadPopup,S as WuiLightbox,C as WuiMarkdown,w as WuiMentionInput,T as WuiModal,E as WuiNavigationMenu,D as WuiNotificationCenter,O as WuiOnboardingChecklist,k as WuiOrgTree,A as WuiOtp,j as WuiOverflow,M as WuiPhone,N as WuiPopover,P as WuiRating,F as WuiRecordPager,I as WuiRelativeTime,L as WuiSavedViews,R as WuiSelect,z as WuiShortcuts,B as WuiShowMore,V as WuiSlider,H as WuiSortable,n as WuiStatusIcon,U as WuiTimePicker,W as WuiTour,G as WuiTree,K as WuiTreePicker,q as WuiTruncate,J as WuiWhatsNew,X as WuiWizard,Z as WuiWizardStep,$ as defineWeborityElements,ae as formatCompact,Q as formatCurrency,ne as formatDate,oe as formatDateTime,te as formatNumber,ie as formatPercent,re as formatValue};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./devWarn-DXdRWZs3.js";var t=Object.freeze([`POST`,`PUT`,`PATCH`,`DELETE`]),n=t=>(e(`[@webority/ui-elements] Wui-Toast-Action: ${t}; the toast shows no action.`),null),r=e=>typeof e==`object`&&!!e;function i(e){if(e==null||e===``)return null;let i;try{i=JSON.parse(e)}catch{return n(`the value is not JSON`)}let a=r(i)?i:{},o=a.label,s=a.url,c=String(a.method??`POST`).toUpperCase();return typeof o!=`string`||o===``||typeof s!=`string`||s===``?n(`label and url must be non-empty strings`):t.includes(c)?{label:o,url:s,method:c}:n(`method must be one of ${t.join(`, `)}`)}var a=`wui-csrf`,o=`RequestVerificationToken`,s={metaName:a,header:o};function c({metaName:e=a,header:t=o}={}){s={metaName:e,header:t}}var l=`Wui-Request`,u=Object.freeze({fragment:`Wui-Fragment`,message:`Wui-Message`,redirect:`Wui-Redirect`,result:`Wui-Result`,keepOpen:`Wui-Keep-Open`,toastVariant:`Wui-Toast-Variant`,toastAction:`Wui-Toast-Action`,data:`Wui-Data`,next:`Wui-Next`}),d=Object.freeze([`ok`,`validation`,`forbidden`,`networkCheck`,`client`,`server`,`network`,`timeout`,`aborted`,`stale`,`session`]),f=/* @__PURE__ */ new Set([`GET`,`HEAD`]);function p(e=document){let t=[...e.querySelectorAll(`meta`)].find(e=>e.getAttribute(`name`)===s.metaName),n=t?.getAttribute(`content`);return!t||!n?null:{header:t.getAttribute(`data-header`)||s.header,token:n}}var m=e=>{try{return new URL(e,window.location.href).origin===window.location.origin}catch{return!1}};function h(e,t=null){return e>=200&&e<300?`ok`:e===401?`session`:e===403?t?.get(`cf-mitigated`)===`challenge`?`networkCheck`:`forbidden`:e===422?`validation`:e>=400&&e<500?`client`:`server`}var g=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,_=3e4;function v(e){let t=e?.trim()??``;return/^\d+$/.test(t)?Number(t):void 0}var y=e=>{if(e==null||e===``)return null;try{return JSON.parse(e)}catch(e){throw TypeError(`The ${u.data} response header is not JSON: ${e instanceof Error?e.message:String(e)}`,{cause:e})}};async function b(e,t={}){let n=(t.method||`GET`).toUpperCase(),r=t.navigate||(e=>window.location.assign(e)),a={Accept:`text/html`,"X-Requested-With":`XMLHttpRequest`,[l]:`1`,...t.headers};if(!f.has(n)&&m(e)){let e=p();e&&(a[e.header]=e.token)}let o=e=>{if(e==null)return null;try{return decodeURIComponent(e)}catch{return e}},s=(e,t=null,n=``)=>{let r=e=>t?.headers.get(e)??null;return{kind:e,ok:e===`ok`,status:t?.status??0,html:n,response:t,message:o(r(u.message)),redirect:r(u.redirect),result:r(u.result),keepOpen:r(u.keepOpen)===`1`,toastVariant:r(u.toastVariant),toastAction:i(r(u.toastAction)),fragment:r(u.fragment)===`1`,data:y(o(r(u.data))),next:r(u.next)}},c=new AbortController,d=()=>c.abort(),_=t.signal;_?.aborted&&c.abort(),_?.addEventListener(`abort`,d,{once:!0});let v=t.timeoutMs??0,b=!1,x=v>0?setTimeout(()=>{b=!0,c.abort()},v):void 0,S=e=>_?.aborted?`aborted`:b?`timeout`:g(e)?`aborted`:`network`;try{let i;try{i=await fetch(e,{method:n,...t.body===void 0?{}:{body:t.body},headers:a,signal:c.signal,credentials:`same-origin`})}catch(e){return s(S(e))}let o=h(i.status,i.headers);if(o===`ok`&&i.redirected&&i.headers.get(u.fragment)!==`1`&&(o=`session`),o===`session`)return r(i.status===401?i.headers.get(`Location`)||window.location.href:i.url),s(o,i);let l=``;if(o===`ok`||o===`validation`)try{l=await i.text()}catch(e){return s(S(e),i)}return s(o,i,l)}finally{clearTimeout(x),_?.removeEventListener(`abort`,d)}}function x(){let e=null,t=0;return{async run(n,r={}){e?.abort();let i=new AbortController;e=i;let a=++t,o=r.signal;o&&(o.aborted?i.abort():o.addEventListener(`abort`,()=>i.abort(),{once:!0}));let s;try{s=await b(n,{...r,signal:i.signal})}finally{e===i&&(e=null)}return a!==t&&s.kind!==`aborted`?{...s,kind:`stale`,ok:!1}:s},abort(){e?.abort(),e=null}}}export{u as a,x as c,b as d,t as f,d as i,p as l,o as n,h as o,i as p,_ as r,c as s,a as t,v as u};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/ui-elements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.176.0",
|
|
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",
|
|
@@ -275,10 +275,10 @@
|
|
|
275
275
|
"@tiptap/starter-kit": "3.31.4",
|
|
276
276
|
"@types/node": "25.6.0",
|
|
277
277
|
"@vitest/coverage-v8": "5.1.0",
|
|
278
|
-
"@webority/biome-config": "0.
|
|
279
|
-
"@webority/markdown-core": "0.
|
|
280
|
-
"@webority/theme": "0.
|
|
281
|
-
"@webority/web-core": "0.
|
|
278
|
+
"@webority/biome-config": "0.176.0",
|
|
279
|
+
"@webority/markdown-core": "0.176.0",
|
|
280
|
+
"@webority/theme": "0.176.0",
|
|
281
|
+
"@webority/web-core": "0.176.0",
|
|
282
282
|
"echarts": "6.1.0",
|
|
283
283
|
"jsdom": "30.1.1",
|
|
284
284
|
"libphonenumber-js": "^1.13.9",
|
package/types/global/shared.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ import * as tableSelect from "../tableSelect.ts";
|
|
|
34
34
|
import * as textStore from "../text/textStore.ts";
|
|
35
35
|
import * as datePickerText from "../text/web/datePicker.g.ts";
|
|
36
36
|
import * as drawerText from "../text/web/drawer.g.ts";
|
|
37
|
+
import * as httpFailureText from "../text/web/httpFailure.g.ts";
|
|
37
38
|
import * as selectText from "../text/web/select.g.ts";
|
|
38
39
|
import * as textMatch from "../textMatch.ts";
|
|
39
40
|
import * as tooltips from "../tooltips.ts";
|
|
@@ -60,6 +61,7 @@ export interface SharedModules {
|
|
|
60
61
|
readonly formMirror: typeof formMirror;
|
|
61
62
|
readonly glyphs: typeof glyphs;
|
|
62
63
|
readonly hasOwn: typeof hasOwn;
|
|
64
|
+
readonly httpFailureText: typeof httpFailureText;
|
|
63
65
|
readonly iconGlyphs: typeof iconGlyphs;
|
|
64
66
|
readonly imeSafeEnter: typeof imeSafeEnter;
|
|
65
67
|
readonly isDrawn: typeof isDrawn;
|
|
@@ -28,12 +28,13 @@ export declare const WUI_HEADERS: Readonly<{
|
|
|
28
28
|
/**
|
|
29
29
|
* Every `kind` a request settles as.
|
|
30
30
|
* ok: 2xx. validation: 422 (the form re-rendered with its errors). forbidden: 403.
|
|
31
|
+
* networkCheck: a 403 that Cloudflare answered with a challenge (`cf-mitigated: challenge`), not the server refusing access.
|
|
31
32
|
* client: any other 4xx. server: 5xx. network: no answer at all. aborted: the caller (or a newer
|
|
32
33
|
* request on the same queue) cancelled it. stale: answered, but a newer request on the same queue
|
|
33
34
|
* started meanwhile. session: the sign-in expired and the browser is being sent to sign in.
|
|
34
35
|
* timeout: no answer within the time limit; a caller's or newer request's abort is still aborted.
|
|
35
36
|
*/
|
|
36
|
-
export type HttpKind = "ok" | "validation" | "forbidden" | "client" | "server" | "network" | "timeout" | "aborted" | "stale" | "session";
|
|
37
|
+
export type HttpKind = "ok" | "validation" | "forbidden" | "networkCheck" | "client" | "server" | "network" | "timeout" | "aborted" | "stale" | "session";
|
|
37
38
|
export declare const HTTP_KINDS: readonly HttpKind[];
|
|
38
39
|
export interface WuiToastAction {
|
|
39
40
|
label: string;
|
|
@@ -75,8 +76,8 @@ export declare function readCsrf(doc?: Document): {
|
|
|
75
76
|
header: string;
|
|
76
77
|
token: string;
|
|
77
78
|
} | null;
|
|
78
|
-
/** Classify a status code. Exported so a caller holding a raw Response applies the same rule. */
|
|
79
|
-
export declare function classifyStatus(status: number): HttpKind;
|
|
79
|
+
/** Classify a status code, with the response headers when there are any. Exported so a caller holding a raw Response applies the same rule. */
|
|
80
|
+
export declare function classifyStatus(status: number, headers?: Pick<Headers, "get"> | null): HttpKind;
|
|
80
81
|
/** The answer time limit the modal, drawer, form, table and post surfaces apply; other callers stay unlimited. */
|
|
81
82
|
export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
82
83
|
/** The `data-wui-timeout` attribute value (milliseconds); anything that is not a whole number reads as no value. */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{n}from"./commentText-NWsssKvj.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{t as i}from"./hasOwn-CJsplJ62.js";import{a,l as o,s}from"./nativeOverlay-BHD2QV02.js";import{n as c,t as l}from"./rtl-g7G8Bsib.js";import{t as u}from"./serverHtml-BC6tAyAl.js";import{d}from"./wuiHttp-BWf9dDsZ.js";import{r as f,t as p}from"./textStore-DBplASiZ.js";import{n as m,t as h}from"./httpFailure.g-DBKzEpAf.js";import{r as g}from"./WuiMentionInput-DJv-WwW6.js";var _=`[data-wui-items]`,v=`[data-wui-picker]`,y=`[data-wui-composer]`,b=`[data-wui-comment]`,x=`[data-wui-live]`,S=()=>f(`commentThread`,m),C=e=>({forbidden:S().forbiddenMessage,client:S().failedClientMessage,validation:S().validationMessage,server:S().failedServerMessage,network:f(`httpFailure`,h).networkText})[e],w=e=>({post:S().donePostText,reply:S().doneReplyText,edit:S().doneEditText,delete:S().doneDeleteText,react:``})[e],T=e=>{let t=typeof e==`object`&&e&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:S().failedServerMessage},E=e=>e instanceof Element?e:null,D=e=>`disabled`in e&&e.disabled===!0,O=(e,t)=>{if(e==null)throw Error(`${t} missing`);return e},k=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},A=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},j=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],M=class extends r{_wired;_busy;_peopleProp;_pickerFor;_openers;constructor(){super(),this._wired=!1,this._busy=!1,this._peopleProp=null,this._pickerFor=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onSubmitKey=this._onSubmitKey.bind(this)}connectedCallback(){if(i(this,`people`)){let e=this.people;Reflect.deleteProperty(this,`people`),this.people=e}if(this._wired)return;this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey),customElements.upgrade(this);let e=k(this,`${y} wui-mention-input`,g);this._handPeople(e),this._applyComposerPlaceholder(e)}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:j(this,`:scope > [data-wui-people] > wui-option`,HTMLElement).map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0}))}set people(e){this._peopleProp=Array.isArray(e)?e:[];for(let e of this.querySelectorAll(`wui-mention-input`))e.people=this._peopleProp}_handPeople(e){!e||this.hasAttribute(`remote`)||this.hasAttribute(`source`)||(e.people=this.people)}_applyComposerPlaceholder(e){let t=this.getAttribute(`composer-placeholder`);e&&t!=null&&e.setAttribute(`placeholder`,t)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:n}_onClick(e){let t=A(E(e.target),`[data-wui-emoji]`,HTMLElement);if(t&&this.contains(t)&&!D(t)){let e=t.closest(v),n=e?this._pickerFor?.comment:t.closest(b);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=A(E(e.target),`[data-wui-action]`,HTMLElement);if(!n||!this.contains(n)||D(n))return;let r=n.closest(b);switch(n.getAttribute(`data-wui-action`)){case`reply`:this._openReply(r,n);break;case`edit`:this._openEditor(r,n);break;case`delete`:this._askDelete(r);break;case`cancel-delete`:this._closeConfirm(r,!0);break;case`confirm-delete`:{let e=O(r,`comment`);this._send(`delete`,{commentId:e.getAttribute(`data-wui-comment`)},{comment:e,scope:e});break}case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(A(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement),!0);break;case`post`:case`send`:this._sendFrom(n)}}_onKeyDown(e){let t=k(this,v,HTMLElement),n=E(e.target),r=c(e.key,l(this));if(this._pickerFor&&t?.contains(n)){let i=j(t,`[data-wui-emoji]`,HTMLElement),a=n instanceof HTMLElement?i.indexOf(n):-1;e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):r===`ArrowRight`||r===`ArrowLeft`?(e.preventDefault(),i[(a+(r===`ArrowRight`?1:-1)+i.length)%i.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let i=A(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement);if(i&&this.contains(i)){e.preventDefault(),e.stopPropagation(),this._closeSlot(i,!0);return}let a=A(n,`[data-wui-comment-confirm]`,HTMLElement);a&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(a.closest(b),!0))}_onSubmitKey(e){let t=k(A(E(e.target),`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement),`[data-wui-action="send"], [data-wui-action="post"]`,HTMLElement);t&&!D(t)&&this._sendFrom(t)}_openReply(e,t){if(this.hasAttribute(`no-replies`))return;let n=k(e,`:scope > [data-wui-reply]`,HTMLElement);if(!n)return;if(!n.hidden){n.querySelector(`wui-mention-input`)?.focus();return}let r=e?.querySelector(`.wui-comment-author`)?.textContent?.trim()||``;this._fillSlot(n,{label:p(S().replyToText,{author:r}),placeholder:S().replyPlaceholder,value:``,send:S().replyLabel,opener:t})}_openEditor(e,t){let n=k(e,`:scope > .wui-comment-row [data-wui-editor]`,HTMLElement);if(!n?.hidden)return;let r=k(O(n.parentElement,`comment row`),`:scope > [data-wui-text]`,HTMLElement);r&&(r.hidden=!0),this._fillSlot(n,{label:S().editCommentLabel,placeholder:``,value:e?.getAttribute(`data-value`)??``,send:S().saveLabel,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,s=o.createElement(`wui-mention-input`);s.className=`wui-mention-input`,s.setAttribute(`label`,t),n&&s.setAttribute(`placeholder`,n),s.setAttribute(`rows`,`2`),s.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`]){let t=this.getAttribute(e);t!=null&&s.setAttribute(e,t)}let c=o.createElement(`div`);c.className=`wui-comment-form-actions`,c.append(this._button(`primary`,`solid`,`sm`,`send`,i),this._button(`primary`,`ghost`,`sm`,`cancel`,S().cancelLabel));let l=o.createElement(`div`);l.className=`wui-comment-error`,l.setAttribute(`data-wui-error`,``),l.hidden=!0,e.replaceChildren(s,c,l),this._handPeople(s),e.hidden=!1,this._openers??=/* @__PURE__ */ new WeakMap,this._openers.set(e,a),s.focus();let u=s.querySelector(`textarea`);u?.setSelectionRange(u.value.length,u.value.length)}_button(n,r,i,a,o){let s=this.ownerDocument.createElement(`button`);return s.type=`button`,s.className=e(n,r,i),s.dataset.wui=t,s.setAttribute(`data-wui-action`,a),s.textContent=o,s}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=k(e.parentElement,`:scope > [data-wui-text]`,HTMLElement);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=k(e,`:scope > .wui-comment-row`,HTMLElement),n=k(t,`[data-wui-comment-confirm]`,HTMLElement),r=k(t,`[data-wui-actions]`,HTMLElement);n&&(n.hidden=!1,r&&(r.hidden=!0),k(n,`[data-wui-action="cancel-delete"]`,HTMLElement)?.focus())}_closeConfirm(e,t){let n=k(e,`:scope > .wui-comment-row`,HTMLElement),r=k(n,`[data-wui-comment-confirm]`,HTMLElement),i=k(n,`[data-wui-actions]`,HTMLElement);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&k(i,`[data-wui-action="delete"]`,HTMLElement)?.focus()}_openPicker(e,t){let n=k(this,v,HTMLElement);n&&e&&!this.hasAttribute(`no-reactions`)&&(this._closePicker(!1),this._pickerFor={comment:e,button:t},t.setAttribute(`aria-expanded`,`true`),o(t,n,{mode:`auto`,onClosed:()=>this._pickerClosed()}),k(n,`[data-wui-emoji]`,HTMLElement)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;let n=k(this,v,HTMLElement);n&&a(n),this._pickerClosed(),e&&t.button.isConnected&&t.button.focus()}_pickerClosed(){let e=k(this,v,HTMLElement),t=this._pickerFor;!t||e&&s(e)||(this._pickerFor=null,t.button.setAttribute(`aria-expanded`,`false`))}_react(e,t){t&&!this.hasAttribute(`no-reactions`)&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=A(e,`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,S().emptyBodyMessage),n?.focus();return}let i=t.closest(b);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:O(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:O(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t})}async _send(e,t,{comment:n,scope:r,form:i}){if(this._busy)return;this._busy=!0,this.setAttribute(`aria-busy`,`true`);let a=i??k(n,`:scope > .wui-comment-row`,HTMLElement)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>e instanceof HTMLButtonElement||e instanceof HTMLTextAreaElement).filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let s=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let c=t.commentId??null,l=t.parentId??null;s.ok?(s.html!=null&&this._swapItems(s.html),e===`post`?i?.querySelector(`wui-mention-input`)?.clear():i?.isConnected&&this._closeSlot(i,!1),e===`delete`&&n?.isConnected&&this._closeConfirm(n,!1),this._restoreFocus(e,t,i),w(e)&&this._announce(w(e)),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:c,parentId:l}}))):s.kind!==`session`&&s.kind!==`aborted`&&(this._showError(a.isConnected?a:this,s.message),this._announce(s.message),this.dispatchEvent(new CustomEvent(`wui:comment-thread:failed`,{bubbles:!0,detail:{intent:e,kind:s.kind,message:s.message}})))}async _persist(e){if(this.hasAttribute(`controlled`)){if(typeof this.submit!=`function`)return{ok:!0,html:null};try{return await this.submit(e),{ok:!0,html:null}}catch(e){return{ok:!1,kind:`server`,message:T(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:S().failedClientMessage};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await d(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||C(r.kind)||S().failedServerMessage}}_swapItems(e){let t=k(this,_,HTMLElement);if(!t||!e.trim())return;let n=u(e),r=k(n,_,HTMLElement);t.replaceChildren(...r?r.childNodes:n.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!D(i))return;let a=e=>e?j(this,b,HTMLElement).find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>k(a(e),`:scope > .wui-comment-row`,HTMLElement),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=k(o(t.parentId),`[data-wui-action="reply"]`,HTMLElement);else if(e===`edit`)s=k(o(t.commentId),`[data-wui-action="edit"]`,HTMLElement);else if(e===`react`){let e=o(t.commentId);s=j(e,`button[data-wui-emoji]`,HTMLButtonElement).find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??k(e,`[data-wui-action="react-menu"]`,HTMLElement)}s??=k(this,`${y} textarea`,HTMLTextAreaElement),s?.focus()}_showError(e,t){let n=k(e,`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`,HTMLElement);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=k(this,`:scope > ${x}`,HTMLElement);t&&e&&(t.textContent=``,t.textContent=e)}};export{M as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./calendarMath-CT99RyhR.js";import{n as t,r as n,t as r}from"./digitGrouping-CCPI3HK3.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{o as a}from"./formatters-DTW53DjY.js";import{n as o}from"./imeSafeEnter-DeO_3lXy.js";import{n as s,t as c}from"./inlineEditText-DRBhMnam.js";import{d as l}from"./wuiHttp-BWf9dDsZ.js";import{r as u,t as d}from"./textStore-DBplASiZ.js";import{t as f}from"./inlineEdit.g-ZxRNYq0t.js";var p=()=>u(`inlineEdit`,f),m=e=>s.some(t=>t===e),h=`[data-wui-display]`,g=`[data-wui-value]`,_=`[data-wui-editor]`,v=`[data-wui-control]`,y=`[data-wui-error]`,b=`[data-wui-live]`,x=`[aria-expanded="true"]`,S=/* @__PURE__ */ new Set([`select`,`date`]),C=e=>{let t=(typeof e==`object`||typeof e==`function`)&&e!==null&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:p().serverMessage},w=e=>e instanceof HTMLElement&&typeof(`value`in e?e.value:void 0)==`string`,T=(e,t)=>{let n=e?.querySelector(t)??null;return n instanceof HTMLElement?n:null},E=class extends i{_wired;_editing;_busy;_draft;_pressed;_popupOpen;_savedTimer;static get observedAttributes(){return[`disabled`]}constructor(){super(),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._onClick=this._onClick.bind(this),this._onKeyCapture=this._onKeyCapture.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onChange=this._onChange.bind(this)}connectedCallback(){this._wired||(this._wired=!0,this._grouping(),this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=T(this,h),t=T(this,_),n=this._control();e&&t&&n&&(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._focusControl(n),e.hidden=!0)}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_onClick(e){e.stopPropagation();let t=e.target instanceof Node?e.target:null;e.type===`click`&&!this._editing&&this.querySelector(h)?.contains(t)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(_)?.querySelector(x))}_onKeyDown(e){if(!this._editing){(o(e)||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||S.has(t)||(t!==`textarea`||e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget instanceof Node?e.relatedTarget:null;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!S.has(this._type()))return;let t=this._control();t&&e.target===t&&queueMicrotask(()=>this._commit(t.value))}async _commit(e){if(!this._editing||this._busy)return;let t=this._value();if(e===t){this.cancel();return}let n=typeof this.validate==`function`?this.validate(e):null;if(n){this._setError(n),this._announce(n);return}let r=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let i=r?null:this._readShown();r||this._showValue(e),this._close();let a=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let o=this.getAttribute(`label`)||``;a.ok?(this.setAttribute(`value`,e),!r&&a.text&&this._showText(a.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),c),this._announce(d(p().savedText,{label:o})),this._fire(`wui:inline-edit:saved`,{value:e,previous:t})):(i&&this._restoreShown(i),a.kind===`session`||a.kind===`aborted`?this._setState(null):(this._draft=e,this._setState(`error`),this._setError(a.message),this._announce(d(p().notSavedText,{label:o,reason:a.message})),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:a.kind,message:a.message})))}async _persist(e,t){if(t){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:C(e)}}}let n=this.getAttribute(`action`);if(!n)return{ok:!0};let r=new URLSearchParams({[this.getAttribute(`name`)||`value`]:e}),i=await l(n,{method:`POST`,body:r});if(i.ok)return{ok:!0,text:i.html.trim()};let a={forbidden:p().forbiddenMessage,client:p().clientMessage,validation:p().validationMessage,server:p().serverMessage,network:p().networkMessage};return{ok:!1,kind:i.kind,message:i.message||a[i.kind]||p().serverMessage}}_close(){let e=T(this,h),t=T(this,_),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),T(t,x)?.click(),n&&e?.focus()}_focusControl(e){if(!S.has(this._type())){e.focus(),e.select?.();return}let t=T(e,`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(t){if(t===``){this._showText(this.getAttribute(`placeholder`)||a(),!0);return}let n=this._type(),i=t;if(n===`date`)i=e(t)||t;else if(n===`select`){let e=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(e=>e.getAttribute(`data-value`)===t);e&&(i=(e.textContent??``).trim())}else n===`number`&&this._grouping()===`indian`&&(i=r(t));this._showText(i,!1)}_readShown(){let e=this.querySelector(g);return e?{nodes:[...e.childNodes].map(e=>e.cloneNode(!0)),empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(g);t&&(t.replaceChildren(...e.nodes),t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(g);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=T(this,y),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(b);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){let e=this.querySelector(v);return w(e)?e:null}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return m(e)?e:`text`}_grouping(){let e=this.getAttribute(`grouping`)??`none`;if(!n(e))throw Error(t(e));return e}};export{E as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{t as n}from"./isDrawn-BbF4phmB.js";import{a as r,l as i,m as a,s as o}from"./nativeOverlay-BHD2QV02.js";import{o as s,r as c,s as l}from"./notificationDays-wMr8rZko.js";import{d as u}from"./wuiHttp-BWf9dDsZ.js";import{r as d}from"./textStore-DBplASiZ.js";import{t as f}from"./notificationCentre.g-UsAurkUz.js";var p=()=>d(`notificationCentre`,f),m=`.wui-notification-center-trigger`,h=`.wui-notification-center-panel`,g=`.wui-notification-center-count`,_=`.wui-notification-center-live`,v=`.wui-notification-center-markall`,y=`.wui-notification-center-item`,b=`wui-notification-center-item-read`,x=`.wui-notification-center-unread-label`,S=`.app-tabs`,C=`.wui-notification-center-tabs [role='tablist']`,w=`.wui-notification-center-tabs [role='tab']`,T=`.wui-notification-center-empty`,E=`(max-width: 767.98px)`,D={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`},O=e=>!!e,k=()=>({forbidden:p().forbiddenMessage,client:p().clientMessage,validation:p().clientMessage,server:p().serverMessage,network:p().networkMessage}),A=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},j=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),M=class extends t{constructor(){super(),this._unread=0,this._busy=!1,this._sheet=!1,this._awaitChildren=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onToggle=e=>{e.type===`toggle`&&`newState`in e&&e.newState===`closed`&&this._closedByBrowser()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}static get observedAttributes(){return[`open`]}connectedCallback(){this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`toggle`,this._onToggle,!0),this.isOpen&&(A(this,h)===null||A(this,m)===null)?(this._awaitChildren=new MutationObserver(()=>this._finishAwaitedOpen()),this._awaitChildren.observe(this,{childList:!0})):(this._syncOpen(),this.isOpen&&this._showPanel())}disconnectedCallback(){this._disarmAwait(),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`toggle`,this._onToggle,!0);let e=A(this,h);e&&r(e)}attributeChangedCallback(e,t,n){e===`open`&&t!==n&&(this._awaitChildren?n===null&&this._disarmAwait():this.isConnected&&(n===null?this._hidePanel():this._showPanel()))}_finishAwaitedOpen(){A(this,h)!==null&&A(this,m)!==null&&(this._disarmAwait(),this._syncOpen(),this._showPanel())}_disarmAwait(){this._awaitChildren?.disconnect(),this._awaitChildren=null}_showPanel(){let t=e(A(this,h),`<wui-notification-center> needs its panel to open.`),n=e(A(this,m),`<wui-notification-center> needs its trigger to open.`);o(t)||(this._sheet=window.matchMedia(E).matches,this._sheet?a(t,!0):i(n,t,{mode:`auto`,onClosed:()=>this._closedByBrowser()}),o(t)&&this._layoutTabs())}_hidePanel(){let e=A(this,h);e&&o(e)&&(this._sheet?a(e,!1):r(e))}_closedByBrowser(){if(!this.isConnected||!this.hasAttribute(`open`))return;let e=A(this,h);this.close({restoreFocus:e?.contains(this.ownerDocument.activeElement)??!1})}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(e(A(this,h),`<wui-notification-center> needs its panel to open.`),e(A(this,m),`<wui-notification-center> needs its trigger to open.`),this.setAttribute(`open`,``),this._syncOpen(),A(this,h)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&A(this,m)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(m)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${y}:not(.${b}):not([data-archived="true"])`).length}_click(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(w);if(n instanceof HTMLElement&&this.contains(n)){if(this.hasAttribute(`controlled`))return;this._pickTab(n);return}let r=t.closest(`${m}, ${v}, ${y}`);r instanceof HTMLElement&&this.contains(r)&&(r.matches(m)?this.toggle():this.hasAttribute(`controlled`)||(r.matches(v)?this._markAll():this._markItem(r)))}_key(e){if(!this.isOpen)return;let t=e.target;if(!(t instanceof Element))throw Error(`Keyboard event target is not an element.`);if(!this.querySelector(h)?.contains(t)||t.closest(S))return;let r=D[e.key];if(r===void 0)return;let i=j(this,y).filter(n);if(i.length===0)return;let a=t.closest(y),o=a instanceof HTMLElement?i.indexOf(a):-1,s;s=r===`first`?0:r===`last`?i.length-1:o===-1?r===1?0:i.length-1:Math.min(i.length-1,Math.max(0,o+r)),e.preventDefault(),i[s]?.focus()}_markItem(e){e.classList.contains(b)||(this._applyRead(e),e.dataset.archived!==`true`&&(this._unread=Math.max(0,this._unread-1)),this._render(),this._say(l(this._unread)),this._emitRead([e.dataset.id].filter(O),!1))}async _markAll(){if(this._busy)return;let e=j(this,`${y}:not(.${b})`);if(e.length===0&&this._unread===0)return;let t=e.map(e=>e.dataset.id).filter(O),n=this.getAttribute(`read-action`);if(n){this._setBusy(!0);let e=new URLSearchParams;for(let n of t)e.append(`ids`,n);let r=await u(n,{method:`POST`,body:e});if(this._setBusy(!1),!r.ok){if(r.kind===`session`||r.kind===`aborted`)return;let e=r.kind,t=r.message||k()[e]||p().serverMessage;this._say(t),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:e,message:t}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(p().allReadText),this._emitRead(t,!0)}_pickTab(e){let t=e.closest(C);if(t instanceof HTMLElement){for(let n of j(t,w)){let t=n===e;n.classList.toggle(`active`,t),n.setAttribute(`aria-selected`,t?`true`:`false`),n.setAttribute(`tabindex`,t?`0`:`-1`)}this._layoutTabs(),this._filterItems(e.dataset.key)}}_layoutTabs(){for(let e of j(this,C)){let t=A(e,`.app-tab.active`);t&&(e.style.setProperty(`--wui-tab-x`,`${t.offsetLeft}px`),e.style.setProperty(`--wui-tab-w`,`${t.offsetWidth}px`)),e.setAttribute(`data-wui-tabs`,``)}}_filterItems(e){let t=!1;for(let n of j(this,y)){let r=n.dataset.archived===`true`,i=n.classList.contains(b),a=e===`archived`?r:!r&&(e!==`unread`||!i);a&&(t=!0);let o=n.closest(`li`);o&&(o.hidden=!a)}for(let e of j(this,`.wui-notification-center-list section`))e.hidden=[...e.querySelectorAll(`li`)].every(e=>e.hidden);let n=A(this,T);n&&(n.hidden=t)}_applyRead(e){e.classList.add(b),e.querySelector(x)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(v);t instanceof HTMLButtonElement&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=A(this,g);e&&(e.textContent=c(this._unread),e.hidden=this._unread===0),this.querySelector(m)?.setAttribute(`aria-label`,s(this.getAttribute(`label`)||p().label,this._unread));let t=this.querySelector(v);t instanceof HTMLButtonElement&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(_);t&&(t.textContent=e)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{M as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{i as n,n as r,r as i,t as a}from"./dom-DMQu--xV.js";import{t as o}from"./loader-C2hgZrCR.js";import{r as s,t as c}from"./textStore-DBplASiZ.js";import{t as l}from"./drawer.g-B-zYKBfQ.js";import{a as u,i as d,n as f,r as p,t as m}from"./tableSelect.g-Bmd-ExRE.js";import{M as h,O as ee,T as te,b as ne,j as re,y as ie}from"./dataTable-VB3nBucm.js";import{n as g,t as _}from"./devWarn-DXdRWZs3.js";import{t as ae}from"./hasOwn-CJsplJ62.js";import{t as oe}from"./svgNodes-CyPS2oFH.js";import{t as se}from"./serverHtml-BC6tAyAl.js";import{t as ce}from"./iconGlyphs.g-a9FtjPXh.js";import{LIST_QUERY_RESERVED as le,SEARCH_PARAM as ue}from"./listQuery.js";import{t as de}from"./dataTable.g-DazoWWps.js";import{c as fe,d as v,u as pe}from"./wuiHttp-BWf9dDsZ.js";var y=()=>s(`tableSelect`,m),b=`wui-select-cell`,x=(e,t)=>{let n=e.createElement(`input`);return n.type=`checkbox`,n.className=`wui-check`,n.setAttribute(`aria-label`,t),n};function me(e=document){let t=e.createElement(`th`);return t.className=b,t.appendChild(x(e,y().selectAllLabel)),t}function he(e=document,{disabled:t=!1}={}){let n=e.createElement(`td`);n.className=b;let r=x(e,y().selectRowLabel);return r.disabled=t,n.appendChild(r),n}function S(e=document){let t=e.createElement(`td`);return t.className=b,t}var ge=e=>e.firstElementChild?.classList.contains(b),C=e=>e.matches(`.wui-group-row, .wui-virtual-spacer, .wui-row-expanded`),w=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n);function _e(e){for(let t of e){if(ge(t)||C(t))continue;let e=t.getAttribute(`data-row-selectable`)===`false`;t.insertBefore(he(t.ownerDocument,{disabled:e}),t.firstChild)}}function ve(e){let t=e.querySelector(`thead tr`);if(!(t instanceof HTMLTableRowElement))return null;ge(t)||t.insertBefore(me(e.ownerDocument),t.firstChild),_e(w(e,`tbody tr`,HTMLTableRowElement));for(let t of w(e,`tfoot tr`,HTMLTableRowElement))ge(t)||t.insertBefore(S(e.ownerDocument),t.firstChild);let n=t.querySelector(`.${b} .wui-check`);return n instanceof HTMLInputElement?n:null}function ye(e){let t=e.querySelector(`thead .${b} .wui-check`),n=w(e,`tbody tr .wui-check:not(:disabled)`,HTMLInputElement),r=n.length,i=n.filter(e=>e.checked).length;t instanceof HTMLInputElement&&(t.checked=r>0&&i===r,t.indeterminate=i>0&&i<r);for(let t of w(e,`tbody tr`,HTMLTableRowElement)){let e=t.querySelector(`.wui-check`);t.classList.toggle(`is-selected`,e instanceof HTMLInputElement&&e.checked)}return{selected:i,total:r}}var be=`tbody .${b} .wui-check:not(:disabled)`;function xe(e,t){let n=null,r=e=>e instanceof Element&&e.matches(`.wui-select-cell .wui-check:not(:disabled)`)&&!!e.closest(`tbody`);e.addEventListener(`mousedown`,e=>{e.shiftKey&&r(e.target)&&e.preventDefault()}),e.addEventListener(`click`,i=>{let a=i.target;if(r(a)){if(i.shiftKey&&n?.isConnected&&n!==a){let r=w(e,be,HTMLInputElement),i=r.indexOf(n),o=r.indexOf(a);if(i>=0&&o>=0){let e=[];for(let t of r.slice(Math.min(i,o),Math.max(i,o)+1))t!==a&&t.checked!==a.checked&&(t.checked=a.checked,e.push(t));e.length&&t?.(e,a.checked)}}n=a}})}var T=()=>s(`dataTable`,de),Se=5,Ce=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,we=e=>e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled,Te=e=>Ce(e)&&`type`in e&&e.type===`hidden`,E=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),D=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},O=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Ee=e=>e.localName===`wui-select`,De=/* @__PURE__ */ new WeakMap,k=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},Oe=e=>({total:k(e.dataset.total,0),totalCapped:e.dataset.totalCapped===`true`,page:k(e.dataset.page,1),pageSize:k(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`,pending:e.dataset.totalPending===`true`,rowCount:k(e.dataset.rowCount,0)}),ke=(e,t)=>{e&&P().toast(e,{variant:t})},Ae=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>!Te(e)||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!le.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of E(e,`[data-wui-filter-clear]`,HTMLElement))t.hidden=!r},je=new Intl.NumberFormat(`en-IN`),Me=(e,t)=>t?`${je.format(e)}+`:je.format(e),Ne=(e,t,n)=>{let r=e.closest(`.wui-list-card`),i=r?D(r,`.wui-list-card-count`,HTMLElement):null;i&&(i.textContent=Me(t,n))};function Pe(e=document){let t=E(e,`[data-wui-server]`,HTMLElement);e instanceof HTMLElement&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t){if(De.has(e))continue;let t=Fe(e);De.set(e,t),e.hasAttribute(`data-load-first-page`)&&t.reload()}}function A(e){let t=e instanceof Element?O(e,`[data-wui-server]`,HTMLElement):null;return t&&De.get(t)||null}function Fe(i){let a=D(i,`.table-wrap`,HTMLElement),o=a?D(a,`:scope > table`,HTMLTableElement):null,s=i.dataset.src;if(!a||!o||!s)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let l=D(a,`:scope > [data-wui-table-state]`,HTMLElement),u=D(i,`[data-wui-table-pager]`,HTMLElement),d=D(i,`[data-wui-table-status]`,HTMLElement),f={urlState:i.dataset.urlState!==`false`,refreshOnSuccess:i.dataset.refreshOnSuccess!==`false`,filtersForm:i.dataset.filtersForm||null,filtersRegion:i.dataset.filtersRegion||null,searchInput:i.dataset.searchInput||null,loadingText:i.dataset.loadingText||T().loadingText,errorText:i.dataset.errorText||T().errorText,timeoutMs:pe(i.getAttribute(`data-wui-timeout`))??3e4},p=new URL(s,window.location.href),m=i.dataset.totalSrc||null,ae=m===null?null:new URL(m,window.location.href),oe=/* @__PURE__ */ new Set([...p.searchParams.keys(),...ae?.searchParams.keys()??[]]),de=o.hasAttribute(`data-app-datatable-selectable`),y=/* @__PURE__ */ new Set,x=!1,me=fe(),he=new AbortController,S={signal:he.signal},ge=D(o,`:scope > tbody[data-wui-rows]`,HTMLTableSectionElement),C=n(ge,`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`),w=Oe(C),be=null,De=null,je=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))oe.has(n)||t.append(n,r);return t},Pe=e=>je(new URL(e,window.location.href).search),A=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},Fe=(e,t)=>{let n=new URL(e.href);for(let[e,r]of t)oe.has(e)||n.searchParams.append(e,r);return n.origin===window.location.origin?`${n.pathname}${n.search}`:n.href},Ie=e=>Fe(p,e),Le=(e,t)=>{let n=new URLSearchParams(e);return n.has(`page`)&&n.set(`page`,String(t.page)),n.has(`pageSize`)&&n.set(`pageSize`,String(t.pageSize)),n.has(`sortBy`)?t.sortBy?(n.set(`sortBy`,t.sortBy),n.set(`sortOrder`,t.sortOrder)):(n.delete(`sortBy`),n.delete(`sortOrder`)):n.delete(`sortOrder`),n},j=Le(f.urlState?je(window.location.search):new URLSearchParams,w);f.urlState&&A(j)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,A(j));let M=(e,t)=>a.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),N=e=>{d&&(d.textContent=e)},ze=e=>{if(e.pending)return e.rowCount===0?T().emptyLabel:c(T().pageTextPending,{page:e.page});if(e.total===0)return T().emptyLabel;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1,n=e.totalCapped?Me(e.total,!0):`${e.total}`;return c(e.total===1?T().pageTextOne:T().pageTextOther,{page:e.page,pages:t,total:n})},Be=()=>E(o,`:scope > thead > tr:first-child > th`,HTMLTableCellElement),Ve=e=>{if(de&&E(e,`:scope > tr:not(.wui-group-row, .wui-virtual-spacer)`,HTMLTableRowElement).some(e=>!e.dataset.rowKey))throw Error(`A selectable server-paged table needs data-row-key on every row, so a selection can span pages.`)},He=e=>{let t=i.dataset.activeRowKey;if(t!==void 0)for(let n of e){let e=n.classList.contains(`wui-row-active`),r=t!==``&&n.dataset.rowKey===t;n.classList.toggle(`wui-row-active`,r),r?n.setAttribute(`aria-current`,`true`):e&&n.removeAttribute(`aria-current`)}},Ue=e=>{if(de){_e(e);for(let t of e){let e=D(t,`.${b} .wui-check:not(:disabled)`,HTMLInputElement);e&&(x&&y.add(t.dataset.rowKey),e.checked=y.has(t.dataset.rowKey))}ye(o)}He(e);let t=Be();if(o.classList.contains(`wui-table-stack`))for(let n of e)[...n.cells].forEach((e,n)=>{let r=t[n]?.textContent?.trim();r&&!e.hasAttribute(`data-label`)&&e.setAttribute(`data-label`,r)});t.forEach((t,n)=>{if(t.classList.contains(`wui-col-hidden`))for(let t of e)t.cells[n]?.classList.add(`wui-col-hidden`)})},We=e=>Ue(E(e,`:scope > tr`,HTMLTableRowElement)),F=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},I=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),Ge=(e,t)=>{if(!l)return;let n=D(e,`:scope > template[data-wui-empty]`,HTMLTemplateElement);I(l),(t.pending?t.rowCount:t.total)===0&&n?(l.replaceChildren(n.content.cloneNode(!0)),l.hidden=!1):(l.replaceChildren(),l.hidden=!0)},Ke=e=>{u&&(I(u),u.replaceChildren(...e?[e.content.cloneNode(!0)]:[]),u.hidden=!1)},qe=e=>{let t=f.filtersRegion&&e?D(document,f.filtersRegion,HTMLElement):null;return t&&e&&(I(t),t.replaceChildren(e.content.cloneNode(!0))),t},Je=0,Ye=e=>{let t=Oe(e);t.pending&&Object.assign(t,{total:w.total,totalCapped:w.totalCapped});let n=t.sortBy!==w.sortBy||t.sortOrder!==w.sortOrder?ie(C.rows):null;Ke(D(e,`:scope > template[data-wui-pager]`,HTMLTemplateElement)),Ge(e,t);let r=qe(D(e,`:scope > template[data-wui-filters]`,HTMLTemplateElement));F(e),I(C),o.replaceChild(e,C),C=e,Je+=1;let i=x&&t.total!==w.total;return w=t,i&&(x=!1),a.removeAttribute(`data-wui-table-error`),We(e),nt(),te(e.rows,n),i&&U(),r},Xe=e=>{let t=D(se(`<table>${e}</table>`),`tbody[data-wui-rows]`,HTMLTableSectionElement);return t&&Ve(t),t?document.importNode(t,!0):null},Ze=(e,t=Be())=>{let n=document.createElement(`tr`);for(let r=0;r<e;r++){let e=t[r],i=e?.classList.contains(`text-center`),a=!i&&(e?.classList.contains(`num`)||e?.classList.contains(`text-end`)||e?.classList.contains(`wui-cell-end`)),o=document.createElement(`td`);i?o.classList.add(`text-center`):a&&o.classList.add(e?.classList.contains(`num`)?`num`:`wui-cell-end`);let s=document.createElement(`span`);s.className=`skeleton`,s.setAttribute(`aria-hidden`,`true`);let c=i?44:a?56:60;s.style.cssText=`display:block;width:${c}%;height:12px;border-radius:6px`,o.append(s),n.append(o)}return n},Qe=()=>{if(C.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,Be().length);C.replaceChildren(...Array.from({length:Se},()=>{let t=Ze(e);return t.setAttribute(`data-wui-skeleton`,``),t})),a.removeAttribute(`data-wui-table-error`),l&&(l.hidden=!0)},$e=e=>{e?(a.setAttribute(`aria-busy`,`true`),Qe()):a.removeAttribute(`aria-busy`)},L=e=>e===`forbidden`?T().forbiddenMessage:e===`network`?T().networkMessage:e===`timeout`?T().timeoutMessage:f.errorText,et=n=>{let r=L(n);if(a.setAttribute(`data-wui-table-error`,n),u&&(u.hidden=!0),l){let i=document.createElement(`div`);i.className=`empty-state wui-empty-state-table wui-table-error`,i.setAttribute(`role`,`alert`);let a=document.createElement(`span`);a.className=`empty-state-icon`;let o=ce(n===`forbidden`?`lock`:`alert-circle`,{size:24});o&&a.replaceChildren(o);let s=document.createElement(`div`);s.className=`empty-state-title`,s.textContent=r;let c=document.createElement(`div`);c.className=`empty-state-action`;let u=document.createElement(`button`);u.type=`button`,u.className=e(`primary`,`outline`,`sm`),u.dataset.wui=t,u.setAttribute(`data-wui-table-retry`,``),u.textContent=T().retryLabel,c.append(u),i.append(a,s,c),I(l),l.replaceChildren(i),l.hidden=!1}N(r)},R=()=>f.filtersForm?D(document,f.filtersForm,HTMLFormElement):null,z=async(e,t=`none`,{quiet:n=!1}={})=>{let r=new URLSearchParams(e);n||(be={query:r,mode:t},$e(!0),N(f.loadingText)),M(`wui:table:loading`,{query:r.toString()});let o=await me.run(Ie(r),{timeoutMs:f.timeoutMs});if(o.kind===`aborted`||o.kind===`stale`||o.kind===`session`)return o;n||$e(!1);let s=null;if(o.ok)try{s=Xe(o.html)}catch(e){_(e)}if(!o.ok||!s){let e=o.ok?`server`:o.kind;return n?g(`A quiet server table refresh failed; the rows on screen are kept.`,e):et(e),M(`wui:table:error`,{status:o.status,kind:e,message:L(e)}),o}let c=Ye(s);return j=Le(r,w),Ae(R(),j),f.urlState&&t===`push`?window.history.pushState(window.history.state,``,A(j)):f.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,A(j)),n||N(ze(w)),P().refresh(a),c&&P().refresh(c),w.pending?tt():Ne(i,w.total,w.totalCapped),M(`wui:table:loaded`,{...w,query:j.toString()}),o},B=e=>(e.delete(`page`),e),tt=()=>{if(!ae||!w.pending)return;let e=Je;v(Fe(ae,j),{timeoutMs:f.timeoutMs}).then(t=>{if(e!==Je)return;if(!t.ok){g(`[@webority/ui-elements] A server table's total did not load; its pager keeps Previous and Next.`,t.kind);return}let n=D(se(t.html),`div[data-wui-total]`,HTMLElement);if(!n){g(`[@webority/ui-elements] A server table's count answer has no div[data-wui-total]; its pager keeps Previous and Next.`);return}if(k(n.dataset.page,-1)!==w.page||k(n.dataset.pageSize,-1)!==w.pageSize)return;let r=k(n.dataset.total,-1);if(r<0){g(`[@webority/ui-elements] A server table's count answer has no whole data-total; its pager keeps Previous and Next.`);return}let a=n.dataset.totalCapped===`true`,o=x&&r!==w.total;w={...w,total:r,totalCapped:a,pending:!1},o&&(x=!1);let s=D(n,`:scope > template[data-wui-pager]`,HTMLTemplateElement);s&&Ke(s);let c=qe(D(n,`:scope > template[data-wui-filters]`,HTMLTemplateElement));c&&P().refresh(c),Ne(i,w.total,w.totalCapped),N(ze(w)),o&&U(),M(`wui:table:total`,{total:r,totalCapped:a})})},V=()=>E(o,`:scope > thead th[data-sort-key]`,HTMLTableCellElement),nt=()=>{for(let e of V()){let t=e.dataset.sortKey===w.sortBy;e.setAttribute(`aria-sort`,t?w.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of V())if(e.classList.add(`sortable`),e.tabIndex=0,!e.querySelector(`.sort-icon`)){let t=e.classList.contains(`num`)||e.classList.contains(`text-end`),n=document.createElement(`span`);n.className=t?`sort-icon wui-sort-lead`:`sort-icon`;let r=ce(`chevrons-up-down`,{size:14});r&&n.replaceChildren(r),t?e.prepend(n):e.append(n)}let H=e=>{let t=B(new URLSearchParams(j)),n=w.sortBy===e&&w.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),z(t,`push`)};o.addEventListener(`click`,e=>{let t=e.target instanceof Element?O(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&o.tHead?.contains(t)&&H(t.dataset.sortKey??``)}),o.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof Element?O(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&o.tHead?.contains(t)&&(e.preventDefault(),H(t.dataset.sortKey??``))});let U=()=>{ye(o);let e=x?{selected:w.total,total:w.total,allMatching:x}:{selected:y.size,total:w.total};o.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};de&&(xe(o,(e,t)=>{for(let n of e){let e=O(n,`tr`,HTMLTableRowElement)?.dataset.rowKey;e&&(t?y.add(e):y.delete(e))}t||(x=!1)}),o.addEventListener(`change`,e=>{let t=e.target;if(t instanceof HTMLInputElement&&t.matches(`.wui-select-cell .wui-check:not(:disabled)`)){if(t.checked||(x=!1),o.tHead?.contains(t))for(let e of E(C,`:scope > tr`,HTMLTableRowElement)){let n=D(e,`.${b} .wui-check:not(:disabled)`,HTMLInputElement);n&&(n.checked=t.checked,t.checked?y.add(e.dataset.rowKey):y.delete(e.dataset.rowKey))}else{let e=O(t,`tr`,HTMLTableRowElement)?.dataset.rowKey;if(!e)return;t.checked?y.add(e):y.delete(e)}U()}})),u&&(u.addEventListener(`click`,e=>{let t=e.target instanceof Element?O(e.target,`a[href]`,HTMLAnchorElement):null;!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),z(Pe(t.getAttribute(`href`)??``),`push`))}),u.addEventListener(`change`,e=>{let t=e.target;t instanceof HTMLSelectElement&&t.classList.contains(`tpg-select`)&&t.value&&(e.stopPropagation(),z(Pe(t.value),`push`))}));let rt=()=>{if(!f.searchInput)return null;let e=D(document,f.searchInput,HTMLElement);return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:e?D(e,`input`,HTMLInputElement):null},W=()=>i.isConnected?!0:(he.abort(),clearTimeout(De??void 0),!1),it=(e,t)=>{let n=[...e.elements].filter(Ce),r=/* @__PURE__ */ new Set;for(let e of n)e.name&&!Te(e)&&r.add(e.name);let i=[];for(let e of n)if(e.name&&!we(e)){if(e instanceof HTMLInputElement&&e.matches(`input[type="hidden"][data-wui-carried]`))r.has(e.name)||i.push([e.name,e.value]);else if(e instanceof HTMLInputElement&&e.matches(`input[type=checkbox], input[type=radio]`))e.checked&&i.push([e.name,e.value]);else if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)e.matches(`[type=submit], [type=button], [type=reset], [type=image], [type=file]`)||i.push([e.name,e.value]);else if(e instanceof HTMLSelectElement)for(let t of e.selectedOptions)i.push([e.name,t.value])}return(t instanceof HTMLButtonElement||t instanceof HTMLInputElement)&&t.name&&!t.disabled&&i.push([t.name,t.value]),i},G=(e,t)=>{let n=new Set([...e.elements].filter(Ce).map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&le.includes(e);for(let[e,t]of j)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of it(e,t))a===``||i(n)||oe.has(n)||r.append(n,a);let a=rt();if(a){r.delete(ue);let e=a.value.trim();e&&r.set(ue,e)}return z(r,`push`)},at=e=>f.filtersForm&&e.closest?.(f.filtersForm)||f.filtersRegion&&e.closest?.(f.filtersRegion)||null;document.addEventListener(`submit`,e=>{W()&&f.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(f.filtersForm)&&(e.preventDefault(),G(e.target,e.submitter))},S),document.addEventListener(`change`,e=>{if(!W()||!f.filtersForm||!(e.target instanceof Element))return;let t=O(e.target,f.filtersForm,HTMLFormElement);!t||e.target===rt()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest(`wui-filter-popover`)||G(t)},S);let ot=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of E(e,`input[name]:not([type=hidden])`,HTMLInputElement))if(r.type===`checkbox`)r.checked=t.getAll(r.name).includes(r.value);else if(r.type===`radio`){let e=n(r.name)===r.value;if(r.checked===e)continue;r.checked=e,e&&r.dispatchEvent(new Event(`change`))}else r.value!==n(r.name)&&(r.value=n(r.name),r.dispatchEvent(new Event(`input`,{bubbles:!0})));for(let r of E(e,`select[name]`,HTMLSelectElement))if(!r.multiple)r.value=n(r.name);else for(let e of r.options)e.selected=t.getAll(r.name).includes(e.value);for(let r of[...e.querySelectorAll(`wui-select[name]`)].filter(Ee)){let e=r.getAttribute(`name`)??``;r.value=r.mode===`multiple`||r.mode===`tag`?t.getAll(e):n(e)}for(let t of e.querySelectorAll(`wui-date-range`)){let e=t.getAttribute(`start-name`)||t.getAttribute(`name`),r=t.getAttribute(`end-name`);t.value={start:e?n(e):``,end:r?n(r):``}}};document.addEventListener(`click`,e=>{if(!W())return;let t=e.target instanceof Element?O(e.target,`a[href]`,HTMLAnchorElement):null;if(!t||!at(t)||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let n=new URL(t.getAttribute(`href`)??``,window.location.href);if(n.origin!==window.location.origin||n.pathname!==window.location.pathname)return;e.preventDefault();let r=B(Pe(n.href));ot(t.closest(`form`),r),Ae(t.closest(`form`),r),z(r,`push`)},S),document.addEventListener(`input`,e=>{if(!W())return;let t=rt();t&&e.target===t&&(clearTimeout(De??void 0),De=setTimeout(()=>{if(!W())return;let e=B(new URLSearchParams(j)),n=t.value.trim();n?e.set(ue,n):e.delete(ue),e.toString()!==j.toString()&&z(e,`replace`)},300))},S),f.urlState&&window.addEventListener(`popstate`,()=>{if(!W())return;let e=je(window.location.search),t=rt();t&&(t.value=e.get(`search`)??``),Ae(R(),e),z(e,`none`)},S),document.addEventListener(`wui:modal:success`,()=>{W()&&f.refreshOnSuccess&&z(j,`none`)},S),l?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`[data-wui-table-retry]`)&&be&&z(be.query,be.mode)});let st=e=>[...C.rows].find(t=>t.dataset.rowKey===e)??null,K=e=>{if(!e?.trim())return null;let t=se(`<table><tbody>${e}</tbody></table>`);if(t.querySelector(`tbody[data-wui-rows]`))return null;let n=E(t,`table > tbody > tr[data-row-key]`,HTMLTableRowElement);return n.length?n.map(e=>document.importNode(e,!0)):null},ct=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let i=[];for(let n of e){let e=n===r?t:st(n.dataset.rowKey);e&&(I(e),e.replaceWith(n),i.push(n))}return Ue(i),P().refresh(a),r},lt=e=>e.message||(e.kind===`forbidden`?T().actionForbiddenMessage:T().actionFailedMessage),ut=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&h(e,null)},dt=async({url:e,method:t=`POST`,body:n,key:i,row:o}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let s=i==null,c=s?null:st(String(i));if(!s&&!c)throw Error(`saveRow found no row with data-row-key="${i}" on this page.`);let u=Be().filter(e=>!e.classList.contains(b)),d=o===void 0?c??Ze(Math.max(1,u.length),u):r(o,HTMLTableRowElement,"saveRow's `row` is required to be a row element: the <tr> as it will read, not its HTML.");c&&d!==c?c.replaceWith(d):c||C.insertBefore(d,C.firstChild),d!==c&&Ue([d]),l&&!a.hasAttribute(`data-wui-table-error`)&&(l.hidden=!0),h(d,`saving`);let f=ee(d),p=await v(e,{method:t.toUpperCase(),body:n});if(p.kind===`session`)return!1;if(p.ok){let e=K(p.html),t=e&&d.isConnected?ct(e,d,s):null;return t?N(re(ee(t)||f)):(await z(j,`none`),ut(d)),Re(p,p.toastVariant||`success`),M(`wui:table:saved`,{key:t?.dataset.rowKey??(s?null:String(i)),added:s,status:p.status}),!0}let m=lt(p),te=d;return c&&d!==c&&d.isConnected?(d.replaceWith(c),te=c):s&&!o&&(d.remove(),te=null,l?.childElementCount&&!C.querySelector(`:scope > tr`)&&(l.hidden=!1)),te?.isConnected&&h(te,`error`,m),p.kind!==`aborted`&&ke(m,`danger`),N(ne(f,m)),M(`wui:table:failed`,{key:s?null:String(i),added:s,status:p.status,kind:p.kind,message:m}),!1},ft=async e=>{let t=e.dataset.url;if(!t)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);let n=O(e,`tr`,HTMLTableRowElement),r=n?.dataset.rowKey??null,i=e.dataset.wuiRowAction||``,a=n?ee(n):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),n&&h(n,`saving`);let o=await v(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),o.kind===`session`||o.kind===`aborted`)ut(n);else{if(o.ok){Re(o,o.toastVariant||`success`);let e=n?.isConnected?K(o.html):null,t=e&&n?ct(e,n,!1):null;t?N(re(ee(t)||a)):(await z(j,`none`),ut(n))}else{let e=lt(o);ke(e,`danger`),n?.isConnected&&h(n,`error`,e),N(ne(a,e))}M(`wui:table:action`,{action:i,key:r,ok:o.ok,status:o.status})}};return o.addEventListener(`click`,e=>{let t=e.target instanceof Element?O(e.target,`[data-wui-row-action]`,HTMLButtonElement):null;t&&C.contains(t)&&!t.disabled&&(e.preventDefault(),ft(t))}),Ve(C),F(C),de&&ve(o),We(C),nt(),w.pending&&(N(ze(w)),tt()),{el:i,reload:async e=>{let t=e?.quiet===!0;return t&&a.getAttribute(`aria-busy`)===`true`?null:z(j,`none`,{quiet:t})},query:()=>new URLSearchParams(j),setQuery:e=>{let t=new URLSearchParams(j);for(let[n,r]of Object.entries(e??{})){t.delete(n);for(let e of Array.isArray(r)?r:[r])e!=null&&e!==``&&t.append(n,String(e))}return e&&`page`in e||t.delete(`page`),z(t,`push`)},saveRow:dt,setActiveRow:e=>{i.dataset.activeRowKey=e==null?``:String(e),He(E(C,`:scope > tr`,HTMLTableRowElement))},selection:{keys:()=>[...y],count:()=>x?w.total:y.size,allMatching:()=>x,selectAllMatching:()=>{if(w.pending)g(`[@webority/ui-elements] select all matching needs the total; the table is still waiting for its count.`);else{x=!0;for(let e of E(C,`:scope > tr`,HTMLTableRowElement)){let t=D(e,`.${b} .wui-check`,HTMLInputElement);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&y.add(e.dataset.rowKey))}U()}},clear:()=>{x=!1,y.clear();for(let e of E(C,`:scope > tr > .${b} .wui-check:not(:disabled)`,HTMLInputElement))e.checked=!1;U()}}}}var Ie=8e3,Le=()=>s(`toast`,f),j=[`success`,`info`,`warning`,`danger`],M=e=>j.some(t=>t===e);function N(e){if(!M(e))throw RangeError(`Unknown toast variant "${e}".`);return e}function P(){return n(window.WUI,`window.WUI is not defined: the Razor behaviour script did not load on this page.`)}function Re(e,t=`success`){if(!e?.message)return;let n=e.toastAction;n?P().toast(e.message,{variant:N(t),duration:Ie,action:{label:n.label,onClick:()=>ze(n)}}):P().toast(e.message,{variant:N(t)})}async function ze(e){let t=await v(e.url,{method:e.method});if(t.kind!==`session`&&t.kind!==`aborted`){if(t.ok){Re(t,t.toastVariant||`success`);for(let e of document.querySelectorAll(`[data-wui-server]`))e instanceof HTMLElement&&e.dataset.refreshOnSuccess!==`false`&&A(e)?.reload()}else P().toast(t.message||Le().failedText,{variant:`danger`})}}var Be=`wui-remote-modal`,Ve=`wui-remote-drawer`,He=Object.freeze({sm:360,md:480,lg:640,xl:720}),Ue=`wui-modal-fullscreen`,We=`wui-modal-wide`,F=Object.freeze({sm:380,md:440,lg:640,xl:880,wide:1080}),I=()=>s(`modal`,p),Ge=e=>pe(e?.getAttribute(`data-wui-timeout`)??null)??3e4,Ke=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,qe=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,Je=`[aria-invalid="true"], .is-invalid, .input-validation-error`,Ye=`invalid`,Xe=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,Ze=`[data-wui-modal-content]`,Qe=`[data-wui-pane-close], [data-wui-dismiss]`,$e=()=>i(`button`,{type:`button`,class:`wui-modal-close`,"data-wui-dismiss":!0,"aria-label":I().closeLabel},oe({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`}]])),L=/* @__PURE__ */ new WeakMap,et=/* @__PURE__ */ new WeakSet;function R(e,t){if(e==null)throw TypeError(`The remote modal needs ${t}, and the page does not have it.`);return e}var z=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},B=(e,t,n)=>R(z(e,t),n),tt=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),V=()=>Object.assign(/* @__PURE__ */ Error(`The remote modal load was aborted.`),{name:`AbortError`}),nt=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,H=(e,t)=>{let n=e instanceof Element?e.closest(t):null;return n instanceof HTMLElement?n:null},U=e=>ae(F,e),rt=e=>ae(He,e);function W(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(U(e))return e===`wide`?{px:F.wide,wide:!0}:{px:F[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported modal size "${String(e)}". Use sm, md, lg, xl, wide, fullscreen or a px number.`)}var it=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};if(e.classList.contains(`wui-modal-wide`))return{px:F.wide,wide:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:F.md}},G=(e,t)=>{e.classList.toggle(Ue,!!t.fullscreen),e.classList.toggle(We,!t.fullscreen&&!!t.wide),t.fullscreen?e.style.removeProperty(`--wui-modal-max-width`):e.style.setProperty(`--wui-modal-max-width`,`${t.px}px`)},at=[`center`,`top`];function ot(e){if(e==null||e===``)return null;if(rt(e))return{px:He[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported drawer size "${String(e)}". Use sm, md, lg, xl or a px number.`)}var st=e=>e.container===`drawer`,K=e=>e.container===`pane`,ct=e=>e.container!==`modal`,lt=(e,t)=>st(e)?ot(t):W(t),ut=e=>{let t=typeof e==`string`?document.querySelector(e):e,n=t instanceof HTMLElement?t:null;return n?.matches(`[data-wui-pane-host]`)?n:null},dt=e=>K(e)?e.shell:B(e.shell,`.modal-dialog`,`a dialog frame`);function ft(e=`modal`){let t=e===`drawer`,n=t?Ve:Be,r=document.getElementById(n);if(r)return r;let a=document.createElement(`wui-modal`);a.id=n,a.setAttribute(`data-wui`,`AppModal`);let o=document.createElement(`dialog`);return o.className=t?`modal wui-modal-shell wui-remote-drawer`:`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${t?He.md:F.md}px`),o.replaceChildren(i(`div`,{class:t?`modal-dialog wui-remote-drawer-dialog`:`modal-dialog modal-dialog-centered wui-rb-dialog`},i(`div`,{class:`modal-content wui-modal`}))),a.append(o),document.body.appendChild(a),a}var pt=e=>i(`div`,{class:`wui-modal-header`},i(`div`,{class:`wui-modal-heading`},i(`div`,{class:`wui-modal-headtext`},i(`div`,{class:`wui-modal-title`},e))),$e()),mt=e=>i(`div`,{class:`modal-content wui-modal`,"aria-busy":`true`},pt(e),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-loading`,role:`status`},i(`span`,{class:`visually-hidden`},I().loadingLabel),i(`div`,{class:`skeleton wui-modal-skeleton`}),i(`div`,{class:`skeleton wui-modal-skeleton`}),i(`div`,{class:`skeleton wui-modal-skeleton wui-modal-skeleton--short`})))),ht=(n,r)=>{let a={forbidden:I().forbiddenMessage,client:I().clientMessage,server:I().serverMessage,network:I().networkMessage,timeout:I().timeoutMessage};return i(`div`,{class:`modal-content wui-modal`,"data-wui-modal-error":r},pt(n),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-state`,role:`alert`},i(`p`,{class:`wui-modal-state-title`},I().errorTitle),i(`p`,{class:`wui-modal-state-text`},a[r]||I().serverMessage),i(`div`,{class:`wui-modal-state-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":!0,"data-wui":t},I().closeLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-wui-modal-retry":!0,"data-wui":t},I().retryLabel)))))},q=e=>z(e.shell,`.modal-content`),gt=e=>r(e.cloneNode(!0),HTMLElement,`a card copy is not an element`);function _t(e){e&&e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}))}function vt(e,t){let n=q(e),r=n?bt(n):/* @__PURE__ */ new Map;_t(n),n?n.replaceWith(t):dt(e).appendChild(t),xt(t,r),P().refresh()}var yt=`input[type="file"][name]`;function bt(e){let t=/* @__PURE__ */ new Map;for(let n of e.querySelectorAll(yt)){if(!(n instanceof HTMLInputElement))continue;let e=n.files;e&&e.length>0&&t.set(n.name,[...e])}return t}function xt(e,t){if(t.size!==0&&typeof DataTransfer<`u`)for(let n of e.querySelectorAll(yt)){if(!(n instanceof HTMLInputElement))continue;let e=t.get(n.name);if(!e)continue;let r=new DataTransfer;for(let t of e)r.items.add(t);n.files=r.files,n.dispatchEvent(new Event(`change`,{bubbles:!0}))}}var St=e=>K(e)?!e.shell.hidden:e.host.hasAttribute(`open`);function Ct(e,t,n=!1){let r=t?z(e,Je):null,i=r?r.matches(Ke)?r:z(r,Ke)||r:null;if(!i&&n)i=z(e,`[data-autofocus]`)||z(e,qe)||z(e,`.wui-modal-close`);else if(!i){let t=tt(e,Ke);i=z(e,`[data-autofocus]`)||t.find(e=>!e.classList.contains(`wui-modal-close`))||t[0]||e}r?i?.focus?.():i?.focus?.({preventScroll:!0})}function wt(e,t){let n=z(e.shell,`[data-wui-modal-live]`);n||(n=document.createElement(`div`),n.className=`visually-hidden`,n.setAttribute(`aria-live`,`assertive`),n.setAttribute(`data-wui-modal-live`,``),dt(e).appendChild(n)),n.textContent=``,n.textContent=t}var Tt=e=>{let t=z(e.shell,`[data-wui-modal-live]`);t&&(t.textContent=``)},Et=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};function Dt(e,t,n,r){let i={...r,container:e.container};Et(t,`wui:modal:${n}`,i),st(e)&&Et(t,`wui:drawer:${n}`,i),K(e)&&Et(t,`wui:pane:${n}`,i)}var Ot=e=>e.matches(`[data-wui-pane-host]`)?`pane`:B(e,`dialog`,`a dialog`).classList.contains(`wui-remote-drawer`)?`drawer`:`modal`,kt=e=>R(e.host.closest(`wui-modal`),`a wui-modal host`);function At(e){let t=L.get(e);if(t)return t;let n=Ot(e),r=n===`pane`?e:B(e,`dialog`,`a dialog`),a=q({shell:r}),o={host:e,shell:r,container:n,queue:fe(),defaultSize:it(r),defaultLabel:r.getAttribute(`aria-label`),placeholder:a?gt(a):i(`div`,{class:`modal-content wui-modal`}),remoteUrl:e.getAttribute(`data-wui-remote-url`),cache:e.getAttribute(`data-wui-remote-cache`)===`true`,loadedUrl:null,session:null};return L.set(e,o),e.addEventListener(`submit`,e=>Zt(o,e)),e.addEventListener(`click`,e=>{H(e.target,`[data-wui-modal-retry]`)&&o.session&&(e.preventDefault(),Lt(o,o.session))}),K(o)&&e.addEventListener(`click`,t=>{let n=H(t.target,Qe);n&&e.contains(n)&&o.session&&J(o,o.session,`dismissed`,null)}),e.addEventListener(`wui-modal-close`,t=>{t.target===e&&t instanceof CustomEvent&&qt(t.detail,`reason`)===`escape`&&e.querySelector(`form[data-wui-submitting]`)&&t.preventDefault()}),e.addEventListener(`wui-modal-closed`,t=>{t.target===e&&Pt(o)}),e.addEventListener(`wui-modal-opened`,t=>{if(t.target!==e)return;let n=q(o);o.session&&n?.matches(Ze)&&!n.contains(document.activeElement)&&Ct(n,!1,ct(o))}),o.remoteUrl&&e.addEventListener(`wui-modal-open`,t=>{t.target===e&&Ft(o,t)}),o}function jt(e,t,n){e.session&&(e.queue.abort(),e.session.resolveClosed({status:`dismissed`,detail:{replaced:!0}}));let r=()=>void 0,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:{el:e.shell,closed:i,close:()=>J(e,a,`dismissed`,null),reload:()=>Lt(e,a)}};return e.session=a,a}function J(e,t,n,r){e.session===t&&(t.closing={status:n,detail:r},K(e)?Nt(e,t):Mt(e))}function Mt(e){let t=kt(e);t.dispatchEvent(new CustomEvent(`wui-modal-close`,{bubbles:!0,cancelable:!0,detail:{reason:`dismiss`}}))&&t.hide()}function Nt(e,t){let n=e.shell,{status:r,detail:i}=R(t.closing,`the closing state`),a=n.contains(document.activeElement);e.queue.abort(),e.session=null,_t(q(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),Dt(e,n,`closed`,{status:r,url:t.url}),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function Pt(e){let t=e.session;if(e.queue.abort(),e.session=null,Tt(e),t){let n=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n.status,detail:n.detail}),Dt(e,e.shell,`closed`,{status:n.status,url:t.url});let r=document.activeElement;t.trigger?.isConnected&&(!r||r===document.body||e.shell.contains(r))&&t.trigger.focus?.()}e.cache||(vt(e,gt(e.placeholder)),e.loadedUrl=null,G(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function Ft(e,t){let n=qt(t instanceof CustomEvent?t.detail:null,`trigger`),r=n instanceof HTMLElement?n:null,i=r?.getAttribute(`data-wui-url`)||e.remoteUrl||``,a=jt(e,i,{trigger:r});a.explicitSize=It(e,r?.getAttribute(`data-wui-size`)),a.explicitSize&&G(e.shell,a.explicitSize),e.cache&&e.loadedUrl===i||(e.loadedUrl&&vt(e,gt(e.placeholder)),Lt(e,a,{keepPlaceholder:!0}))}function It(e,t){try{return lt(e,t)}catch(e){return _(e),null}}async function Lt(e,t,{keepPlaceholder:n=!1}={}){n||vt(e,mt(t.options.title||Rt(e)));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate,timeoutMs:Ge(t.trigger)});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if(r.kind===`ok`&&Ht(e,t,r.html,!1))return e.loadedUrl=t.url,Dt(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return vt(e,ht(t.options.title||Rt(e),i)),St(e)&&Ct(R(q(e),`a card`),!1,ct(e)),Dt(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var Rt=e=>q(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,zt=`/_content/Webority.Ui.Razor/js/`,Bt=e=>new URL(e,window.location.href).pathname.includes(zt);function Vt(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function Ht(e,t,n,r){let i=se(n),a=!1;for(let e of i.querySelectorAll(`script`)){if(e.getAttribute(`type`)===`application/json`)continue;let t=e.getAttribute(`src`);e.remove(),t&&Bt(t)?Vt(t):a=!0}a&&g(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let o=z(i,Ze);if(!o)return _(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;if(vt(e,o),r||Tt(e),!K(e)){G(e.shell,t.explicitSize||It(e,o.getAttribute(`data-wui-size`))||e.defaultSize);let n=o.getAttribute(`data-wui-title`);n&&e.shell.setAttribute(`aria-label`,n)}return St(e)&&Ct(o,r,ct(e)),!0}var Ut=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function Wt(e,t,n){let r=[...e.elements].filter(e=>e.matches(Ut));if(n){e.setAttribute(`data-wui-submitting`,``);let n=t&&r.includes(t)?t:r[0];for(let e of r)e.toggleAttribute(`data-wui-was-disabled`,e.disabled),e.disabled=!0;n&&(n.classList.add(`is-loading`),n.setAttribute(`aria-busy`,`true`),n.tagName===`BUTTON`&&n.prepend(i(`span`,{class:`spinner-border spinner-border-sm me-2`,"aria-hidden":`true`,"data-wui-submit-spinner":!0})))}else{e.removeAttribute(`data-wui-submitting`);for(let e of r)e.disabled=e.hasAttribute(`data-wui-was-disabled`),e.removeAttribute(`data-wui-was-disabled`),e.classList.remove(`is-loading`),e.removeAttribute(`aria-busy`),e.querySelector(`[data-wui-submit-spinner]`)?.remove()}}function Gt(e){for(let t of e.querySelectorAll(Xe))t.remove();for(let t of e.querySelectorAll(Je))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}var Kt=/* @__PURE__ */ new Set(/* @__PURE__ */ `bad request.unauthorized.payment required.forbidden.not found.method not allowed.not acceptable.proxy authentication required.request timeout.conflict.gone.length required.precondition failed.payload too large.uri too long.unsupported media type.range not satisfiable.expectation failed.misdirected request.unprocessable content.unprocessable entity.locked.failed dependency.too early.upgrade required.precondition required.too many requests.request header fields too large.unavailable for legal reasons`.split(`.`)),qt=(e,t)=>{if(typeof e==`object`&&e&&t in e)return Reflect.get(e,t)};async function Jt(e){if(!e||e.status<400||e.status>499||!e.headers.get(`content-type`)?.toLowerCase().includes(`json`))return null;let t;try{t=JSON.parse(await e.text())}catch{return null}let n=e=>typeof e==`string`?e.trim():``,r=n(qt(t,`title`)),i=(e.statusText||``).trim().toLowerCase(),a=Kt.has(r.toLowerCase())||r.toLowerCase()===i;return n(qt(t,`message`))||n(qt(t,`detail`))||(r&&!a?r:null)}function Yt(e,t,n,r){let i={forbidden:I().forbiddenMessage,client:I().clientMessage,server:I().serverMessage,network:I().networkMessage,timeout:I().timeoutMessage},a=t.closest(`.wui-modal-body`)||t;a.querySelector(`[data-wui-modal-submit-error]`)?.remove(),Gt(a);let o=document.createElement(`div`);o.className=`alert alert-danger wui-modal-submit-error`,o.setAttribute(`role`,`alert`),o.setAttribute(`data-wui-modal-submit-error`,``),o.textContent=`${I().submitFailedMessage} ${r||i[n]||I().serverMessage}`,a.prepend(o),wt(e,o.textContent)}var Xt=(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 Zt(e,t){let n=t.target,r=e.session;if(!(n instanceof HTMLFormElement)||!r||n.hasAttribute(`data-wui-native`)||!n.closest(Ze)||(t.preventDefault(),n.hasAttribute(`data-wui-submitting`)))return;let i=`submitter`in t&&(t.submitter instanceof HTMLButtonElement||t.submitter instanceof HTMLInputElement)?t.submitter:null,a=i?.getAttribute(`formaction`)||n.getAttribute(`action`)||r.url,o=(i?.getAttribute(`formmethod`)||n.getAttribute(`method`)||`GET`).toUpperCase(),s=new FormData(n);i?.name&&!s.has(i.name)&&s.append(i.name,i.value);let c=o===`GET`;Wt(n,i,!0);let l;try{l=await e.queue.run(c?Xt(a,s):a,{method:o,body:c?void 0:s,navigate:r.options.navigate,timeoutMs:Ge(r.trigger)})}catch(t){_(t),e.session===r&&n.isConnected&&(Wt(n,i,!1),Yt(e,n,`server`,null));return}if(e.session!==r)return;if(n.isConnected&&Wt(n,i,!1),l.kind===`ok`&&l.result===`success`){Qt(e,r,l);return}if(l.kind===`aborted`||l.kind===`stale`||l.kind===`session`)return;if(l.kind===`ok`&&l.html){let t=l.result===Ye;if(Ht(e,r,l.html,t)){if(t){let t=R(q(e),`a card`).querySelector(Xe)?.textContent?.replace(/\s+/g,` `).trim();wt(e,t||I().invalidMessage)}return}}let u=l.kind===`ok`||l.kind===`validation`?`server`:l.kind,d=await Jt(l.response);e.session===r&&Yt(e,n,u,d)}function Qt(e,t,n){let r=n.message,i=n.redirect||null,a=n.toastVariant||`success`;if(!dn(a))throw TypeError(`Unknown toast variant "${a}". Use ${un.join(`, `)}.`);let o={url:t.url,trigger:t.trigger,handle:t.handle,message:r,redirect:i,data:n.data??null,container:e.container};i&&!t.options.navigate?Mn(r,a):r&&P().toast(r,{variant:a}),Dt(e,t.trigger?.isConnected?t.trigger:document,`success`,o),t.options.onSuccess?.(o,t.handle),i&&(t.options.navigate||(e=>window.location.assign(e)))(i);let s=n.next;s&&!i?(t.url=s,t.method=`GET`,t.body=void 0,Lt(e,t)):n.keepOpen?n.html&&Ht(e,t,n.html,!1):J(e,t,`success`,o)}function $t(e){let t=H(e.target,`[data-wui-modal], [data-wui-drawer], [data-wui-pane]`);t&&(t.matches(`a[href]`)&&(e.ctrlKey||e.metaKey||e.shiftKey||e.button!==0)||(e.preventDefault(),t.hasAttribute(`data-wui-pane`)?sn(t.getAttribute(`data-wui-pane`)??``,{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{nt(e)||_(e)}):t.hasAttribute(`data-wui-modal`)?nn(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=>{nt(e)||_(e)}):an(t.getAttribute(`data-wui-drawer`)??``,{size:t.getAttribute(`data-wui-drawer-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{nt(e)||_(e)})))}function en(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=H(e.target,on);if(!t)return;let n=L.get(t),r=e.currentTarget;n?.session&&r instanceof Document&&!r.querySelector(`wui-modal[open]`)&&(t.querySelector(`form[data-wui-submitting]`)||(e.preventDefault(),J(n,n.session,`dismissed`,null)))}function tn(e=document){let t=e instanceof Document?e:R(e.ownerDocument,`an owner document`);et.has(t)||(et.add(t),t.addEventListener(`click`,$t),t.addEventListener(`keydown`,en));let n=tt(e,`wui-modal[data-wui-remote-url]`);e instanceof HTMLElement&&e.matches(`wui-modal[data-wui-remote-url]`)&&n.unshift(e);for(let e of n)At(e)}function nn(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=t.container===`drawer`,r=n?ot(t.size):W(t.size),i=t.placement||`center`;if(!at.includes(i))throw TypeError(`WUI.modal.load: unsupported placement "${i}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(V());let a=ft(n?`drawer`:`modal`);tn(document);let o=At(a),s=St(o),c=jt(o,e,t);c.explicitSize=r,G(o.shell,r||o.defaultSize),n||B(o.shell,`.modal-dialog`,`a dialog frame`).classList.toggle(`modal-dialog-centered`,i===`center`),t.title&&o.shell.setAttribute(`aria-label`,t.title),s||(a.toggleAttribute(`static`,t.staticBackdrop!==!1),a.toggleAttribute(`no-escape`,t.closeOnEscape===!1));let l=s?Promise.resolve():new Promise(e=>a.addEventListener(`wui-modal-opened`,()=>e(),{once:!0})),u=Lt(o,c);return s||kt(o).show(),rn(o,c,t,l,u,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function rn(e,t,n,r,i,a){let o=new Promise((r,i)=>{n.signal?.addEventListener(`abort`,()=>{e.session===t&&(e.queue.abort(),J(e,t,`dismissed`,{aborted:!0})),i(V())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw V();if(e===`session`)throw Error(`${a}(${t.url}): the session expired; the browser is signing in again.`);return t.handle});return Promise.race([s,o])}function an(e,t={}){return nn(e,{...t,container:`drawer`,placement:void 0})}var on=`[data-wui-pane-host]`;function sn(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=ut(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(V());tn(document);let r=At(n),i=jt(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=Lt(r,i);return rn(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function cn(e){let t=ut(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=L.get(t);n?.session&&J(n,n.session,`dismissed`,null)}var Y=`wuiConfirm`,ln=Object.freeze([`danger`]),un=Object.freeze([`success`,`info`,`warning`,`danger`]),dn=e=>un.some(t=>t===e),fn=`wui.flash`,X=()=>s(`confirmDialog`,d),pn=/* @__PURE__ */ new WeakSet,mn=/* @__PURE__ */ new WeakSet,hn=null,gn=null,_n=!1,vn=(e,t)=>{e&&P().toast(e,{variant:t})};function yn(){let r=document.getElementById(Y);if(r)return n(r.closest(`wui-modal`),`#${Y} must be a wui-modal.`);let a=document.createElement(`wui-modal`);a.id=Y;let o=document.createElement(`dialog`);return o.className=`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${F.md}px`),o.replaceChildren(i(`div`,{class:`modal-dialog modal-dialog-centered wui-rb-dialog`},i(`div`,{class:`modal-content wui-modal wui-confirm`},i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-confirm-content`},i(`span`,{class:`wui-confirm-icon`},i(`wui-status-icon`,{tone:`info`,size:120})),i(`h3`,{class:`wui-confirm-title`,tabindex:-1,"data-autofocus":``}),i(`p`,{class:`wui-confirm-msg`}))),i(`div`,{class:`wui-modal-footer`},i(`div`,{class:`wui-confirm-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":``,"data-wui":t},X().cancelLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-app-confirm":``,"data-wui":t})))))),a.append(o),document.body.appendChild(a),a}function bn(e,t){let n=e.getAttribute(`data-wui-confirm-tone`);if(n!==null&&!ln.includes(n))throw TypeError(`data-wui-confirm-tone="${n}" is not supported. Use danger, or leave it off.`);xn({title:e.getAttribute(`data-wui-confirm-title`),message:e.getAttribute(`data-wui-confirm`),label:e.getAttribute(`data-wui-confirm-label`),danger:n===`danger`},t)}function xn({title:e,message:t,label:r,danger:i},a){let o=yn(),s=o.querySelector(`.wui-confirm-title`),c=o.querySelector(`[data-app-confirm]`);if(!s||!c)throw Error(`#${Y} is not a confirm dialog with a confirm button. Render <app-confirm-dialog id="${Y}"> without confirm-href, or leave the dialog to the library.`);let l=o.querySelector(`.wui-confirm-msg`);l||(l=document.createElement(`p`),l.className=`wui-confirm-msg`,s.after(l));let u=e||X().confirmTitle;s.textContent=u,l.textContent=t,c.textContent=r||X().confirmLabel,c.classList.toggle(`btn-danger`,i),c.classList.toggle(`btn-primary`,!i),o.querySelector(`wui-status-icon`)?.setAttribute(`tone`,i?`delete`:`info`),n(o.querySelector(`dialog`),`#${Y} has no <dialog>.`).setAttribute(`aria-label`,u),gn=a,_n=!1,o.show()}var Sn=(e,t)=>{hn=e;try{t()}finally{hn=null}},Cn=(e,t)=>{let n=Reflect.get(e,t);if(n===void 0||typeof n==`string`)return n;throw TypeError(`confirmAction: ${t} must be text.`)},wn=e=>{if(typeof e!=`object`||!e)throw TypeError(`confirmAction: options must be an object with a message.`);let t=`message`in e?e.message:void 0;if(typeof t!=`string`)throw TypeError(`confirmAction: message must be text.`);return{title:Cn(e,`title`),message:t,label:Cn(e,`label`),tone:Cn(e,`tone`)}};function Tn(e,t,n){let{title:r,message:i,label:a,tone:o}=wn(t);if(o!=null&&!ln.includes(o))throw TypeError(`confirmAction: tone "${o}" is not supported. Use danger, or leave it off.`);Jn(e.ownerDocument),xn({title:r,message:i,label:a,danger:o===`danger`},()=>Sn(e,n))}var En=e=>`disabled`in e&&e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`,Dn=e=>{r(e,HTMLElement,`data-wui-confirm needs an HTML element to click.`).click()};function On(e){let t=a(e.target,`[data-wui-confirm]:not(form)`);t&&t!==hn&&!En(t)&&(e.preventDefault(),e.stopImmediatePropagation(),bn(t,()=>Sn(t,()=>Dn(t))))}function kn(e){let t=e.target;if(!(t instanceof HTMLFormElement)||!t.hasAttribute(`data-wui-confirm`)||t===hn||e.submitter&&e.submitter===hn||t.querySelector(`input[data-app-repeater-hidden]`))return;e.preventDefault(),e.stopImmediatePropagation();let n=e.submitter instanceof HTMLButtonElement||e.submitter instanceof HTMLInputElement?e.submitter:null,r=n?.form===t?n:void 0;bn(t,()=>Sn(t,()=>t.requestSubmit(r)))}function An(e){let t=a(e.target,`#${Y} [data-app-confirm]`);t&&!t.hasAttribute(`disabled`)&&gn&&(_n=!0,n(t.closest(`wui-modal`),`#${Y} is missing around its confirm button.`).hide())}function jn(e){if(!(e.target instanceof Element)||e.target.id!==`wuiConfirm`)return;let t=_n?gn:null;gn=null,_n=!1,t?.()}function Mn(e,t){e&&window.sessionStorage.setItem(fn,JSON.stringify({message:e,variant:t}))}var Nn=e=>e===`forbidden`?X().forbiddenMessage:e===`network`?X().networkMessage:e===`timeout`?X().timeoutMessage:X().failedMessage;function Pn(){for(let e of document.querySelectorAll(`[data-wui-server]`))e.getAttribute(`data-refresh-on-success`)!==`false`&&A(e)?.reload()}var Fn=(e,t)=>{`disabled`in e&&(e.disabled=t)};async function In(e){let t=e.getAttribute(`data-wui-post`);if(!t)throw Error(`A data-wui-post button needs the URL the action posts to.`);return Ln(t,e)}async function Ln(e,t,n){let r=t.getAttribute(`data-wui-post-reload`);if(r!==null&&r!==`page`)throw TypeError(`data-wui-post-reload="${r}" is not supported. Use page, or leave it off to reload the server tables.`);Fn(t,!0),t.setAttribute(`aria-busy`,`true`);let i=pe(t.getAttribute(`data-wui-timeout`))??3e4,a=await v(e,{method:`POST`,body:n,timeoutMs:i});if(a.kind===`session`||a.kind===`aborted`)return;let o=a.toastVariant||`success`;a.ok&&(a.redirect||r===`page`)?(Mn(a.message,o),a.redirect?window.location.assign(a.redirect):window.location.reload()):(Fn(t,!1),t.removeAttribute(`aria-busy`),a.ok?(Re(a,o),Pn()):vn(a.message||Nn(a.kind),`danger`))}function Rn(e,t){Fn(e,!1),e.removeAttribute(`aria-busy`),_(t),vn(X().failedMessage,`danger`)}function zn(e){let t=a(e.target,`[data-wui-post]`);t&&(e.preventDefault(),En(t)||t.getAttribute(`aria-busy`)===`true`||In(t).catch(e=>Rn(t,e)))}function Bn(e){let t=a(e.target,`form[data-wui-post-form]`);if(!(t instanceof HTMLFormElement)||e.defaultPrevented)return;e.preventDefault();let r=n(e.submitter||t.querySelector(`button:not(.repeater-add):not(.repeater-remove)`),`A data-wui-post-form needs a submit button to report its result on.`);if(r.getAttribute(`aria-busy`)===`true`)return;let i=new URL(n(t.getAttribute(`action`),`A data-wui-post-form needs an action attribute to post to.`),document.baseURI).href;Ln(i,r,new FormData(t)).catch(e=>Rn(r,e)),t.closest(`wui-dropdown`)?.hide()}var Vn=(e,t)=>{e.disabled=!1,e.removeAttribute(`aria-busy`),t&&h(t,null)};async function Hn(e,t){let n=e.dataset.url;if(!n)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);e.disabled=!0,e.setAttribute(`aria-busy`,`true`),t&&h(t,`saving`);let r=pe(e.getAttribute(`data-wui-timeout`))??3e4,i=await v(n,{method:(e.dataset.method||`post`).toUpperCase(),timeoutMs:r});if(i.kind===`session`)return;if(i.kind===`aborted`){Vn(e,t);return}if(i.ok){Mn(i.message,i.toastVariant||`success`),i.redirect?window.location.assign(i.redirect):window.location.reload();return}let a=i.message||Nn(i.kind);e.disabled=!1,e.removeAttribute(`aria-busy`),t&&h(t,`error`,a),vn(a,`danger`)}function Un(e){let t=a(e.target,`[data-wui-row-action]`);if(!(t instanceof HTMLButtonElement)||t.closest(`[data-wui-server]`)||(e.preventDefault(),t.disabled||t.getAttribute(`aria-busy`)===`true`))return;let n=t.closest(`tr`);Hn(t,n).catch(e=>{Vn(t,n),_(e),vn(X().failedMessage,`danger`)})}function Wn(){let e=window.sessionStorage.getItem(fn);if(!e)return;window.sessionStorage.removeItem(fn);let t=JSON.parse(e);if(typeof t!=`object`||!t)throw TypeError(`stored flash is not an object.`);let n=`message`in t?t.message:void 0,r=`variant`in t?t.variant:void 0;if(typeof r!=`string`||!dn(r))throw TypeError(`stored flash variant "${String(r)}" is not supported.`);if(typeof n!=`string`)throw TypeError(`stored flash message is not text.`);vn(n,r)}function Gn(e){let t=e.querySelectorAll?[...e.querySelectorAll(`[data-wui-flash]`)]:[];e instanceof Element&&e.matches(`[data-wui-flash]`)&&t.unshift(e);for(let e of t){let t=e.getAttribute(`data-wui-flash-variant`)||`success`;if(!dn(t))throw TypeError(`data-wui-flash-variant="${t}" is not supported. Use ${un.join(`, `)}.`);let n=e.getAttribute(`data-wui-flash`)||(e.textContent??``).trim();e.remove(),vn(n,t)}}var Kn=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.form:null;function qn(e){if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-wui-auto-submit]`);if(!t)return;let n=Kn(e.target)||t.closest(`form`);n instanceof HTMLFormElement&&n.requestSubmit()}function Jn(e){mn.has(e)||(mn.add(e),e.addEventListener(`click`,An),e.addEventListener(`wui-modal-closed`,jn))}function Yn(e=document){let t=e instanceof Element?e.ownerDocument:e;pn.has(t)||(pn.add(t),t.addEventListener(`click`,On,!0),t.addEventListener(`submit`,kn,!0),Jn(t),t.addEventListener(`click`,zn),t.addEventListener(`click`,Un),t.addEventListener(`submit`,Bn),t.addEventListener(`change`,qn),Wn()),Gn(e)}var Xn=()=>s(`unsavedChanges`,u),Zn=`form[data-wui-unsaved]`,Qn=`[aria-invalid="true"], .field-error:not(:empty), .field-validation-error, .validation-summary-errors, .wui-error-summary`,$n=`[download], [data-wui-modal], [data-wui-post], [data-bs-toggle]`,er=/* @__PURE__ */ new Set([`submit`,`button`,`reset`,`image`]),tr=/* @__PURE__ */ new Set([`hidden`,`checkbox`,`radio`,`file`,`submit`,`button`,`reset`,`image`,`range`,`color`]),nr=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,rr=e=>nr(e)?e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled:`disabled`in e&&!!e.disabled,ir=e=>`name`in e&&typeof e.name==`string`&&e.name!==``,ar=e=>typeof e==`object`&&!!e,or=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&typeof e[0]==`string`);function sr(e){let t=JSON.parse(e);if(!or(t))throw Error(`unsaved-changes snapshot is malformed`);return t}var Z=/* @__PURE__ */ new WeakMap,cr=/* @__PURE__ */ new WeakSet,lr=e=>`${e.name}:${e.size}:${e.lastModified}`,ur=e=>[...e.querySelectorAll(Zn)].filter(e=>e instanceof HTMLFormElement);function Q(e){let t=[];for(let n of e.elements)ir(n)&&!rr(n)&&(nr(n)&&er.has(n.type)||(n instanceof HTMLInputElement&&(n.type===`checkbox`||n.type===`radio`)?t.push([n.name,n.value,n.checked]):n instanceof HTMLInputElement&&n.type===`file`?t.push([n.name,[...n.files||[]].map(lr)]):n instanceof HTMLSelectElement&&n.type===`select-multiple`?t.push([n.name,[...n.selectedOptions].map(e=>e.value)]):n instanceof HTMLFieldSetElement||n instanceof HTMLObjectElement?t.push([n.name,null]):t.push([n.name,`value`in n?n.value:null])));return JSON.stringify(t)}function dr(e){return Q(e)}function fr(e,t){let n=/* @__PURE__ */ new Map,r=sr(t);for(let e of r){let t=n.get(e[0]);t?t.push(e):n.set(e[0],[e])}let i=sr(Q(e)).map(e=>n.get(e[0])?.shift()??e);for(let e of n.values())i.push(...e);return JSON.stringify(i)}function pr(e){for(let t of e.elements)if(nr(t)&&t.name&&!rr(t)){if(t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement&&!tr.has(t.type)){if(t.value.trim()!==``)return!0}else if(t instanceof HTMLInputElement&&t.type===`file`&&(t.files?.length??0)>0)return!0}return!1}var mr=e=>({saved:e.querySelector(Qn)&&pr(e)?null:Q(e),engaged:!1,discarded:!1});function hr(e){let t=Z.get(e);return!t||t.discarded||!e.isConnected?!1:t.saved===null||t.engaged&&Q(e)!==t.saved}var gr=(e,t)=>ur(e).filter(e=>e!==t&&hr(e));function _r(e,t,n){let r=t.map(e=>e.getAttribute(`data-wui-unsaved`)).find(Boolean)||Xn().message;Tn(e,{title:Xn().title,message:r,label:Xn().leaveLabel,tone:`danger`},()=>{for(let e of t){let t=Z.get(e);t&&(t.discarded=!0)}n()})}function vr(e){if(e.matches($n))return!1;let t=e.getAttribute(`target`);if(t&&t.toLowerCase()!==`_self`)return!1;let n=e.getAttribute(`href`);if(n===null)return!1;let r=new URL(n,window.location.href);if(r.protocol!==`http:`&&r.protocol!==`https:`)return!1;let i=window.location;return!(r.hash&&r.origin===i.origin&&r.pathname===i.pathname&&r.search===i.search)}function yr(e,t){if((t?.getAttribute(`formmethod`)||e.getAttribute(`method`)||`get`).toLowerCase()===`dialog`)return!1;let n=t?.getAttribute(`formtarget`)||e.getAttribute(`target`);return!n||n.toLowerCase()===`_self`}function br(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target,n=a(t,`a[href]`);if(!(n instanceof HTMLAnchorElement)||!vr(n))return;let r=gr(n.ownerDocument,null);r.length&&(e.preventDefault(),_r(n,r,()=>n.click()))}function xr(e){let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented||!yr(t,e.submitter))return;let n=gr(t.ownerDocument,t);if(n.length){e.preventDefault();let r=e.submitter,i=(r instanceof HTMLButtonElement||r instanceof HTMLInputElement)&&r.form===t?r:void 0;_r(t,n,()=>t.requestSubmit(i));return}let r=Z.get(t);r&&(r.saved=Q(t),r.discarded=!1)}function Sr(e){gr(document,null).length&&e.preventDefault()}function Cr(e){let t=e.target,n=a(t,Zn);return n instanceof HTMLFormElement?n:null}function wr(e){let t=Cr(e);if(!t)return;let n=Z.get(t);n&&!n.engaged&&(n.saved!==null&&(n.saved=Q(t)),n.engaged=!0)}function Tr(e){let t=Cr(e),n=t&&Z.get(t);n&&(n.discarded=!1,e.isTrusted&&(n.engaged=!0))}function Er(e){for(let t of ur(e)){let e=Z.get(t);e?.saved&&(e.saved=fr(t,e.saved))}}function Dr(e){let t=ar(e)?e.handle:void 0;return ar(t)?t.el:void 0}function Or(e){if(!(e instanceof CustomEvent))return;let t=Dr(e.detail);if(t instanceof Element)for(let e of ur(t))Ar(e)}function kr(e=document){let t=e instanceof Document?e:e.ownerDocument;if(!cr.has(t)){cr.add(t);for(let e of[`focusin`,`pointerdown`,`drop`])t.addEventListener(e,wr,!0);for(let e of[`input`,`change`])t.addEventListener(e,Tr,!0);t.addEventListener(`click`,br),t.addEventListener(`submit`,xr),t.addEventListener(`wui:modal:success`,Or),t.addEventListener(o,()=>Er(t)),n(t.defaultView,`unsaved-changes guard needs a document with a window`).addEventListener(`beforeunload`,Sr)}let r=ur(e);e instanceof HTMLFormElement&&e.matches(Zn)&&r.unshift(e);for(let e of r)Z.has(e)||Z.set(e,mr(e))}function Ar(e){if(!(e instanceof HTMLFormElement)||!e.matches(Zn))throw TypeError(`resetUnsavedChanges: ${String(e)} is not a <form data-wui-unsaved>.`);Z.set(e,{saved:Q(e),engaged:!1,discarded:!1})}var jr=()=>s(`drawer`,l),Mr=`wui:drawer:discard`,Nr=`wui-drawer[confirm-discard]`,Pr=`wui-modal`,Fr=`data-wui-no-discard`,Ir=`.wui-drawer-discard`,Lr=`input, select, textarea`,Rr=e=>typeof e==`object`&&!!e||typeof e==`function`;function zr(e){let t=e.currentTarget;if(!(t instanceof Document))throw Error(`The discard guard is not wired on a document.`);return t}function Br(e,t){return a(e,t)}var Vr=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement,$=/* @__PURE__ */ new WeakMap,Hr=/* @__PURE__ */ new WeakSet,Ur=/* @__PURE__ */ new WeakSet;function Wr(n,r,i,a,o){let s=n.createElement(`button`);return s.type=`button`,s.className=e(r,i,`sm`),s.dataset.wui=t,s.setAttribute(a,``),s.textContent=o,s}function Gr(e,t){let n=e.createElement(`div`);n.className=`wui-drawer-discard`,n.setAttribute(`role`,`alert`);let r=e.createElement(`span`);return r.className=`wui-drawer-discard-text`,r.textContent=t,n.append(r,Wr(e,`danger`,`solid`,`data-wui-discard-confirm`,jr().discardLabel),Wr(e,`primary`,`soft`,`data-wui-discard-keep`,jr().keepLabel)),n}function Kr(e){if(!(e instanceof Element))return null;let t=e.closest(Nr);if(t)return t;let n=e.closest(Pr);return n&&Yr(n).length?n:null}function qr(e){return e.closest(Nr)??e.closest(Pr)}function Jr(e,t){return t.hasAttribute(Fr)||e.hasAttribute(Fr)?!1:t.hasAttribute(`confirm-discard`)||e.hasAttribute(`data-wui-confirm-discard`)?!0:(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`}function Yr(e){return e.matches(Nr)?e.querySelectorAll(`form`):[...e.querySelectorAll(`form`)].filter(t=>Jr(t,e))}function Xr(e){let t=$.get(e);return t!=null&&dr(e)!==t}function Zr(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-drawer-footer`,n(e.querySelector(`.wui-drawer-panel`),`The drawer has no panel to hold its footer.`).append(t),Ur.add(t),t}function Qr(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-modal-footer`,(e.querySelector(`.wui-modal-body`)?.parentElement??e.querySelector(`.modal-content`)??e).append(t),Ur.add(t),t}function $r(e){let t=e.querySelector(`[data-wui-discard-confirm]`);if(!(t instanceof HTMLElement))throw Error(`The discard prompt has no confirm button.`);t.focus()}function ei(e,t,n){let r=e.querySelector(Ir);if(r){$r(r);return}let i=Gr(e.ownerDocument,t),a;if(e.matches(Nr))a=e.querySelector(`.wui-drawer-footer`)??Zr(e),a.prepend(i);else if(e.hasAttribute(`confirm-discard`))a=e.querySelector(`.wui-modal-footer`)??Qr(e),a.prepend(i);else{if(!n)throw Error(`A discard prompt needs the form that is dirty.`);a=n.querySelector(`.modal-footer`)??e.querySelector(`.wui-modal-footer`)??Qr(e),a.prepend(i)}a.classList.add(`wui-drawer-discarding`),$r(i)}function ti(e){let t=e.parentElement;if(e.remove(),!t)throw Error(`The discard prompt has no footer.`);t.classList.remove(`wui-drawer-discarding`),Ur.has(t)&&t.remove()}function ni(e){for(let t of Yr(e))for(let e of t.querySelectorAll(Lr))if(Vr(e)&&e.type!==`hidden`&&!e.disabled){e.focus({preventScroll:!0});return}}function ri(e){let t=Kr(e.target);if(t)for(let e of Yr(t))$.get(e)??$.set(e,dr(e))}function ii(e){for(let t of zr(e).querySelectorAll(`form`)){let e=$.get(t);e!=null&&$.set(t,fr(t,e))}}function ai(e){let t=e.target;t instanceof HTMLFormElement&&Kr(t)&&$.set(t,dr(t))}function oi(e){if(!Rr(e))return;let t=`handle`in e?e.handle:void 0;if(Rr(t))return`el`in t?t.el:void 0}function si(e){if(!(e instanceof CustomEvent))return;let t=e.detail,n=oi(t);if(n instanceof Element)for(let e of n.querySelectorAll(`form`))$.delete(e)}function ci(e){let t=e.target;t instanceof Element&&t.matches(Nr)&&[...Yr(t)].some(Xr)&&(e.preventDefault(),ei(t,t.getAttribute(`confirm-discard`),null))}function li(e){let t=e.target;if(!(t instanceof Element)||!t.matches(Pr))return;let n=[...Yr(t)].find(Xr);n&&(e.preventDefault(),ei(t,n.getAttribute(`data-wui-confirm-discard`)??t.getAttribute(`confirm-discard`)??jr().confirmDiscard,n))}function ui(e){let t=n(e.closest(Ir),`The discard button is outside its prompt.`),r=qr(t);if(ti(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);for(let e of Yr(r))$.set(e,dr(e));r.dispatchEvent(new CustomEvent(Mr,{bubbles:!0})),r.matches(Nr)?n(r.closest(`wui-drawer`),`The confirm-discard drawer is not a wui-drawer.`).hide():n(r.closest(`wui-modal`),`The discarded dialog is not a wui-modal.`).hide()}function di(e){let t=n(e.closest(Ir),`The keep button is outside its prompt.`),r=qr(t);if(ti(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);ni(r)}function fi(e){let t=Br(e.target,`[data-wui-discard-confirm]`);if(t){ui(t);return}let n=Br(e.target,`[data-wui-discard-keep]`);n&&di(n)}function pi(e=document){let t=e instanceof Document?e:e.ownerDocument;Hr.has(t)||(Hr.add(t),t.addEventListener(`focusin`,ri),t.addEventListener(`pointerdown`,ri),t.addEventListener(`submit`,ai),t.addEventListener(o,ii),t.addEventListener(`wui:modal:success`,si),t.addEventListener(`wui:modal:loaded`,si),t.addEventListener(`wui-drawer-close`,ci,!0),t.addEventListener(`wui-modal-close`,li),t.addEventListener(`click`,fi))}export{Pe as S,sn as _,kr as a,Re as b,ln as c,Tn as d,Yn as f,nn as g,an as h,dr as i,fn as l,tn as m,Gr as n,Ar as o,cn as p,pi as r,Y as s,Mr as t,un as u,Ie as v,A as x,ze as y};
|
package/dist/kanban-DlVHIpxL.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./devWarn-DXdRWZs3.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{m as r}from"./formatters-DTW53DjY.js";import{t as i}from"./hasOwn-CJsplJ62.js";import{c as a,d as o,f as s,m as c,p as l,s as u,u as d}from"./kanbanModel-BzXK4SkM.js";import{n as f,t as p}from"./rtl-g7G8Bsib.js";import{t as m}from"./serverHtml-BC6tAyAl.js";import{d as h}from"./wuiHttp-BWf9dDsZ.js";import{n as g,r as _,t as v}from"./textStore-DBplASiZ.js";import{t as y}from"./kanban.g-dtKYyIpr.js";var b=()=>_(`kanban`,y),x=()=>({forbidden:b().forbiddenMessage,client:b().clientMessage,validation:b().clientMessage,server:b().serverMessage,network:b().networkMessage}),S=`[data-wui-column]`,C=`[data-wui-body]`,w=`[data-wui-card]`,T=`[data-wui-count]`,E=`[data-wui-summary]`,D=`[data-wui-empty]`,O=`[data-wui-drop-note]`,ee=`[data-wui-live]`,te=`[data-wui-help]`,k=`[data-wui-switch]`,A=`[data-wui-scroller]`,j=`[data-wui-collapse]`,M=`[data-wui-more]`,N=`data-wui-visible-limit`,P=`data-wui-overflow`,F=`input, select, textarea, [contenteditable=""], [contenteditable="true"], [data-wui-no-drag]`,I=`[data-wui-load-more]`,L=`data-wui-more-url`,R=`data-wui-total`,z=`data-wui-unloaded`,B=48,V=16,H=160,U=e=>e.getAttribute(`data-wui-column`),W=e=>e.getAttribute(`data-wui-card`),G=e=>e instanceof HTMLElement&&!!e.hidden||e.hasAttribute(`hidden`),K=e=>G(e)||e.hasAttribute(P),q=e=>e instanceof Element?e:null,J=e=>typeof e==`object`&&e&&`name`in e?e.name:void 0,ne=e=>typeof e==`object`&&e&&`message`in e?e.message:void 0,Y=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},X=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),Z=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Q=()=>window.WUI??null,$=(e,t)=>{e&&Q()?.toast(e,{variant:t})},re=class extends n{constructor(){super(),this._wired=!1,this._filter=null,this._expanded=/* @__PURE__ */ new Set,this._revealed=/* @__PURE__ */ 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)},this.addEventListener(`pointerdown`,e=>this._pointerDown(e)),this.addEventListener(`keydown`,e=>this._keyDown(e)),this.addEventListener(`click`,e=>this._click(e),!0),this.addEventListener(`scroll`,e=>{e.target instanceof Element&&this._loadOnScroll(e.target)},!0),this.addEventListener(`dragstart`,e=>{q(e.target)?.closest(w)&&e.preventDefault()}),this.addEventListener(`touchmove`,e=>{this._drag&&e.preventDefault()},{passive:!1})}_controlled(){return this.hasAttribute(`controlled`)}connectedCallback(){if(!this._wired){this._wired=!0,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 instanceof HTMLElement&&e.matches(w)&&this._prepareCard(e);this._queueRefresh()});for(let e of this.querySelectorAll(C))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 t of this._columns()){let n=U(t),i=o(t.getAttribute(N)),s=[],c=[];for(let e of this._cardsIn(t))this._filter&&(e.hidden=this._filter(e)===!1),G(e)?e.removeAttribute(P):(s.push(e),c.push(e.getAttribute(`data-wui-value`)));let u=this._expanded.has(n),d=a(s.map(W),i,u,this._revealed);for(let e of s)e.toggleAttribute(P,d.has(W(e)));let f=this._unloadedIn(t),p=String(s.length+f);for(let e of this._countsOf(t))e.textContent!==p&&(e.textContent=p);let m=Y(t,D,HTMLElement);if(m&&(m.hidden=s.length>0),e){let n=t.querySelector(E);n&&(n.textContent=r(l(c),e))}let h=Y(t,M,HTMLElement);if(h){h.hidden=i==null||(u?s.length<=i:d.size===0),h.setAttribute(`aria-expanded`,u?`true`:`false`);let e=u?b().fewerLabel:v(b().moreText,{count:d.size});h.textContent!==e&&(h.textContent=e)}let g=Y(t,I,HTMLButtonElement);if(g&&(g.hidden=f<=0,!t.hasAttribute(`data-wui-loading`))){g.disabled=!1;let e=v(b().loadMoreText,{n:f});g.textContent!==e&&(g.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 X(this,S,HTMLElement)}_columnByKey(e){return this._columns().find(t=>U(t)===e)||null}_columnOf(e){return Z(e,S,HTMLElement)}_titleOf(e){return(e.querySelector(`.wui-kanban-title`)?.textContent||U(e)||``).replace(/\s+/g,` `).trim()}_bodyOf(e){return Y(e,C,HTMLElement)}_cardsIn(e){let t=this._bodyOf(e);return t?[...t.children].filter(e=>e instanceof HTMLElement&&e.matches(w)):[]}_visibleCardsIn(e){return this._cardsIn(e).filter(e=>!K(e))}_allCards(){return X(this,`${C} > ${w}`,HTMLElement)}_cardByKey(e){return this._allCards().find(t=>W(t)===e)||null}_countsOf(e){let t=U(e),n=[...this.querySelectorAll(k)].filter(e=>e.getAttribute(`data-wui-switch`)===t);return[...e.querySelectorAll(T),...n.flatMap(e=>[...e.querySelectorAll(T)])]}_scroller(){return Y(this,A,HTMLElement)}_summaryFormat(){let e=this.getAttribute(`summary-format`);return e?d(e,this.getAttribute(`summary-unit`)):null}_queueRefresh(){this._refreshQueued||(this._refreshQueued=!0,queueMicrotask(()=>{this._refreshQueued&&this.refresh()}))}_prepareCard(e){let t=this.querySelector(te);t?.id&&!e.hasAttribute(`aria-describedby`)&&e.setAttribute(`aria-describedby`,t.id),e.hasAttribute(`tabindex`)||(e.tabIndex=0)}_announce(e){let t=Y(this,ee,HTMLElement);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=u(e),n=this.hasAttribute(`readonly`);return n||e.hasAttribute(`data-wui-locked`)?(this._announce(v(b().lockedText,{card:t})),this._fire(`wui:kanban:locked`,{key:W(e),card:e,reason:n?`readonly`:`locked`},!0),!1):e.getAttribute(`aria-busy`)!==`true`||(this._announce(b().busyMessage),$(b().busyMessage,`info`),!1)}_check(e,t,n){if(t===n)return{ok:!1,source:!0,reason:null};let r=this._columnByKey(t),i=this._columnByKey(n),a=v(b().refusedText,{from:r?this._titleOf(r):String(t),to:i?this._titleOf(i):String(n)}),o=i?.getAttribute(`data-accept-from`),s=o?.split(/\s+/).filter(Boolean)??[];if(o!=null&&!s.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=u(e),r=/* @__PURE__ */ new Map;for(let i of this._columns()){let a=U(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=Y(i,O,HTMLElement);s&&!o.source&&(s.textContent=o.ok?v(b().dropHereText,{card:n,column: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=Y(e,O,HTMLElement);t&&(t.hidden=!0,t.textContent=``)}}async _commit(e,t,n){let r=this._columnOf(e);if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let i=U(r),a=this._columnByKey(t),o=u(e);if(i===t||!this._canLift(e))return!1;let s=this._check(e,i,t);if(!s.ok)return this._announce(s.reason),$(s.reason,`info`),!1;if(!a)throw Error(`wui-kanban: no column "${String(t)}" on this board.`);let c=this._cardsIn(a),l=Number.isInteger(n)?Math.max(0,Math.min(n??0,c.length)):c.length,d={key:W(e),card:e,from:i,to:t,index:l},f=e.contains(document.activeElement);if(this._controlled())return this._fire(`wui:kanban:move`,d),this._announce(v(b().movedText,{card:o,column:this._titleOf(a)})),f&&this._refocusSoon(d.key),!0;if(!this._fire(`wui:kanban:move`,d,!0))return!1;let p=a.hasAttribute(N)&&!this._revealed.has(d.key);p&&this._revealed.add(d.key);let m={parent:e.parentNode,next:e.nextSibling,column:r,revealed:p},g=this._bodyOf(a);if(!g)throw Error(`wui-kanban: the target column has no body.`);g.insertBefore(e,c[l]||null),f&&this._focusMoved(e),this.refresh();let _=a.getAttribute(`data-wui-step`);if(_)return this._runStep(e,d,m,_,a.getAttribute(`data-wui-step-size`));let y=this.getAttribute(`move-url`);if(!y)return this._announce(v(b().movedText,{card:o,column:this._titleOf(a)})),this._fire(`wui:kanban:moved`,{...d,result:null}),!0;this._lock(e,!0),this._announce(v(b().movingText,{card:o,column:this._titleOf(a)}));let S=new URLSearchParams({card:String(d.key),from:String(i),to:String(t),index:String(l)}),C=await h(y,{method:`POST`,body:S});if(this._lock(e,!1),C.kind===`session`)return!1;if(C.ok){let t=this._applyFragment(C.html)||e;return $(C.message,`success`),this._announce(v(b().movedText,{card:u(t),column:this._titleOf(a)})),this._fire(`wui:kanban:moved`,{...d,card:t,result:C}),!0}return this._rollback(e,m),C.kind!==`aborted`&&$(C.message||x()[C.kind]||b().serverMessage,`danger`),this._fire(`wui:kanban:failed`,{...d,kind:C.kind,status:C.status,message:C.message}),!1}async _runStep(e,t,n,r,i){let a=u(e),o=this._columnByKey(t.to),s=new URLSearchParams({card:String(t.key),from:String(t.from),to:String(t.to)}).toString(),c=r+(r.includes(`?`)?`&`:`?`)+s;this._lock(e,!0);let l;try{let t=window.WUI?.modal?.load;if(typeof t!=`function`)throw Error(`<wui-kanban> data-wui-step needs the Razor script webority-ui.js (WUI.modal.load).`);l=await(await t(c,{trigger:e,size:i||void 0})).closed}catch(r){return this._lock(e,!1),this._rollback(e,n),J(r)!==`AbortError`&&$(b().serverMessage,`danger`),this._fire(`wui:kanban:failed`,{...t,kind:`step`,status:0,message:ne(r)??null}),!1}if(l?.status!==`success`)return this._lock(e,!1),this._rollback(e,n),this._announce(v(b().cancelledText,{card:a})),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 h(`${f}${f.includes(`?`)?`&`:`?`}${new URLSearchParams({card:String(t.key)})}`);n.ok&&(d=this._applyFragment(n.html)||e)}if(this._lock(d,!1),!o)throw Error(`wui-kanban: no column "${String(t.to)}" on this board.`);return this._announce(v(b().movedText,{card:u(d),column:this._titleOf(o)})),this._fire(`wui:kanban:moved`,{...t,card:d,result:l}),!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;if(t.revealed&&this._revealed.delete(W(e)),!t.parent)throw Error(`wui-kanban: the card had no parent to go back to.`);t.parent.insertBefore(e,r),n&&e.focus(),this.refresh(),this._announce(v(b().rolledBackText,{card:u(e),column:this._titleOf(t.column)}))}_applyFragment(t){if(!t)return null;let n=m(t);for(let t of n.querySelectorAll(`script`))e(`[@webority/ui-elements] A kanban fragment carried a script tag; it was removed, not run.`),t.remove();let r=null;for(let e of X(n,w,HTMLElement)){if(e.closest(`template`))continue;let t=this._cardByKey(W(e));if(!t)continue;let n=t.contains(document.activeElement);t.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),t.hidden&&(e.hidden=!0),t.replaceWith(e),this._prepareCard(e),n&&e.focus(),r??=e}for(let e of X(n,`template[data-wui-kanban-summary]`,HTMLTemplateElement))this._columnByKey(e.getAttribute(`data-wui-kanban-summary`))?.querySelector(E)?.replaceChildren(e.content.cloneNode(!0));return this.refresh(),Q()?.refresh(),r}_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=q(e.target),n=t?Z(t,w,HTMLElement):null;if(!n||!this.contains(n)||t?.closest(F))return;let r={card:n,id:e.pointerId,x:e.clientX,y:e.clientY,type:e.pointerType,timer:0};this._press=r,e.pointerType===`touch`&&(r.timer=setTimeout(()=>{this._press===r&&this._startDrag(r,r.x,r.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=this._columnOf(r);if(!i)throw Error(`wui-kanban: the card is not inside a column.`);let a=U(i),o=r.getBoundingClientRect(),s=r.cloneNode(!0);if(!(s instanceof HTMLElement))return;let c=s;for(let e of[c,...c.querySelectorAll(`[id]`)])e.removeAttribute(`id`);c.removeAttribute(`data-wui-card`),c.removeAttribute(`tabindex`),c.setAttribute(`aria-hidden`,`true`),c.classList.add(`wui-kanban-ghost`),c.style.width=`${o.width}px`,this.appendChild(c),r.setAttribute(`data-wui-dragging`,``),this.setAttribute(`data-wui-dragging`,``),this._drag={card:r,from:a,ghost:c,dx:t-o.left,dy:n-o.top,x:t,y:n,over:null,verdicts:this._markTargets(r,a)},this._announce(v(b().liftedText,{card:u(r),column:this._titleOf(i)})),document.addEventListener(`keydown`,this._onDocKeyDown),this._dragTo(t,n)}_dragTo(e,t){let n=this._drag;if(!n)throw Error(`wui-kanban: no drag in progress.`);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+B?r.scrollBy?.({left:-16}):e>t.right-B&&r.scrollBy?.({left:V}))}if(n&&this._scrollColumn(n,t))return;let i=window.innerHeight||0;i>0&&(t<B?window.scrollBy?.({top:-16}):t>i-B&&window.scrollBy?.({top:V}))}_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+B&&n.scrollTop>0?(n.scrollBy?.({top:-16}),!0):t>r.bottom-B&&n.scrollTop+n.clientHeight<n.scrollHeight-1&&(n.scrollBy?.({top:V}),!0)}_endPointer(e){let t=this._press,n=this._drag;if(t&&clearTimeout(t.timer||void 0),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(v(b().cancelledText,{card:u(n.card)}));return}let i=U(r),a=n.verdicts.get(i);a?.source?this._announce(v(b().cancelledText,{card:u(n.card)})):a?.ok?this._commit(n.card,i,this._indexAt(r,n.y)):(this._announce(a?.reason),$(a?.reason,`info`))}_click(e){let t=q(e.target);if(this._suppressClick&&t?.closest(w)){e.preventDefault(),e.stopPropagation(),this._suppressClick=!1;return}let n=t?.closest(j);if(n&&this.contains(n)){let e=Z(n,S,HTMLElement);e&&this._setCollapsed(e,!e.hasAttribute(`data-collapsed`),!0);return}let r=t?.closest(I);if(r&&this.contains(r)){this._controlled()||this._loadMore(Z(r,S,HTMLElement));return}let i=t?.closest(M);if(i&&this.contains(i)){this._controlled()||this._toggleMore(Z(i,S,HTMLElement));return}let a=t?.closest(k);a&&this.contains(a)&&this._showColumn(a.getAttribute(`data-wui-switch`))}_keyDown(e){let t=this._kbd;if(t){this._liftedKey(e,t);return}let n=e.target instanceof HTMLElement?e.target:null;if(!n?.matches(w)||!this.contains(n))return;let r=this._columnOf(n),i=f(e.key,p(this));switch(i){case` `:case`Spacebar`:{if(e.preventDefault(),!this._canLift(n))return;if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let t=U(r),i=this._columns();this._kbd={card:n,from:t,target:i.indexOf(r),verdicts:this._markTargets(n,t)},n.setAttribute(`data-wui-lifted`,``),this.setAttribute(`data-wui-dragging`,``),r.setAttribute(`data-wui-target`,``),this._announce(v(b().liftedText,{card:u(n),column:this._titleOf(r)}));return}case`ArrowDown`:case`ArrowUp`:{if(!r)throw Error(`wui-kanban: the card is not inside a column.`);let t=this._visibleCardsIn(r),i=t[t.indexOf(n)+(e.key===`ArrowDown`?1:-1)];i&&(e.preventDefault(),i.focus());return}case`ArrowLeft`:case`ArrowRight`:{let t=this._columns(),n=i===`ArrowRight`?1:-1;for(let i=(r?t.indexOf(r):-1)+n;i>=0&&i<t.length;i+=n){let n=t[i],r=n?this._visibleCardsIn(n)[0]:void 0;if(r&&n&&!n.hasAttribute(`data-collapsed`)){e.preventDefault(),r.focus();return}}return}}}_liftedKey(e,t){let n=this._columns(),r=f(e.key,p(this));switch(r){case`ArrowLeft`:case`ArrowRight`:{e.preventDefault();let i=t.target+(r===`ArrowRight`?1:-1);if(i<0||i>=n.length)return;n[t.target]?.removeAttribute(`data-wui-target`),t.target=i;let a=n[i];if(!a)return;a.setAttribute(`data-wui-target`,``),this._showColumn(U(a),!1);let o=t.verdicts.get(U(a));if(!o)throw Error(`wui-kanban: no verdict for the column.`);let s=this._titleOf(a);this._announce(o.source?v(b().overSourceText,{column:s}):o.ok?g(b(),`overText`,this._cardsIn(a).filter(e=>!G(e)).length,{column:s}):v(b().overRefusedText,{column:s,reason:o.reason??``}));return}case` `:case`Spacebar`:case`Enter`:{e.preventDefault();let r=n[t.target];if(!r)throw Error(`wui-kanban: the lifted card has no target column.`);let i=U(r),a=t.verdicts.get(i);if(!a)throw Error(`wui-kanban: no verdict for the column.`);if(!a.source&&!a.ok){this._announce(a.reason);return}this._endKeyboard(),a.source?this._announce(v(b().cancelledText,{card:u(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(v(b().cancelledText,{card:u(t.card)}));return}}_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=s(this.getAttribute(`board-id`));for(let t of this._columns()){let n=U(t);t.hasAttribute(`data-collapsible`)&&i(e,String(n))&&this._setCollapsed(t,e[String(n)],!1)}}_setCollapsed(e,t,n){let r=U(e);e.toggleAttribute(`data-collapsed`,t);let i=this._titleOf(e);for(let n of e.querySelectorAll(j))n.setAttribute(`aria-expanded`,t?`false`:`true`),n.setAttribute(`aria-label`,v(t?b().expandLabel:b().collapseLabel,{title:i}));n&&(c(this.getAttribute(`board-id`),r,t),this._fire(`wui:kanban:collapse`,{column:r,collapsed:t}))}_toggleMore(e){if(!e)return;let t=U(e);if(this._expanded.delete(t))for(let t of this._cardsIn(e))this._revealed.delete(W(t));else this._expanded.add(t);this.refresh()}_unloadedIn(e){return e.hasAttribute(L)?(e.hasAttribute(z)||e.setAttribute(z,String(Math.max(0,Number(e.getAttribute(R))-this._cardsIn(e).length))),Number(e.getAttribute(z))):0}async _loadMore(e){if(!e)throw Error(`wui-kanban: the load-more button is outside a column.`);let n=Number(e.getAttribute(z));if(e.hasAttribute(`data-wui-loading`)||!(n>0))return;e.setAttribute(`data-wui-loading`,``);let r=Y(e,I,HTMLButtonElement);r&&(r.disabled=!0,r.textContent=b().loadingLabel);let i=new URL(String(e.getAttribute(L)),document.baseURI);i.searchParams.set(`skip`,String(this._cardsIn(e).length));let a=0,o=!1;try{let t=await h(i.toString());if(t.ok){let r=m(t.html),i=this._bodyOf(e);for(let e of[...r.children])if(e.matches(w)&&!this._cardByKey(W(e))){if(!i)throw Error(`wui-kanban: the column has no body.`);i.append(e),a++}let s=t.response?.headers.get(`Wui-Kanban-Remaining`)??``;e.setAttribute(z,String(/^\d+$/.test(s)?Number(s):Math.max(0,n-a))),o=!0}}catch(e){t(`[@webority/ui-elements] A kanban column could not load its next cards.`,e)}e.removeAttribute(`data-wui-loading`),this.refresh(),o?this._fire(`wui:kanban:loaded`,{key:U(e),added:a}):$(b().loadFailedMessage,`danger`)}_loadOnScroll(e){if(this._controlled()||!e.matches(C))return;let t=Z(e,S,HTMLElement);t?.hasAttribute(L)&&e.scrollTop+e.clientHeight>=e.scrollHeight-H&&this._loadMore(t)}_isPhone(){return typeof matchMedia==`function`&&matchMedia(`(max-width: 767.98px)`).matches}_showColumn(e,t=!0){for(let t of this.querySelectorAll(k))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(k))e.getAttribute(`data-wui-switch`)===U(n)?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`)}};export{re as t};
|
package/dist/wuiHttp-BWf9dDsZ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./devWarn-DXdRWZs3.js";var t=Object.freeze([`POST`,`PUT`,`PATCH`,`DELETE`]),n=t=>(e(`[@webority/ui-elements] Wui-Toast-Action: ${t}; the toast shows no action.`),null),r=e=>typeof e==`object`&&!!e;function i(e){if(e==null||e===``)return null;let i;try{i=JSON.parse(e)}catch{return n(`the value is not JSON`)}let a=r(i)?i:{},o=a.label,s=a.url,c=String(a.method??`POST`).toUpperCase();return typeof o!=`string`||o===``||typeof s!=`string`||s===``?n(`label and url must be non-empty strings`):t.includes(c)?{label:o,url:s,method:c}:n(`method must be one of ${t.join(`, `)}`)}var a=`wui-csrf`,o=`RequestVerificationToken`,s={metaName:a,header:o};function c({metaName:e=a,header:t=o}={}){s={metaName:e,header:t}}var l=`Wui-Request`,u=Object.freeze({fragment:`Wui-Fragment`,message:`Wui-Message`,redirect:`Wui-Redirect`,result:`Wui-Result`,keepOpen:`Wui-Keep-Open`,toastVariant:`Wui-Toast-Variant`,toastAction:`Wui-Toast-Action`,data:`Wui-Data`,next:`Wui-Next`}),d=Object.freeze([`ok`,`validation`,`forbidden`,`client`,`server`,`network`,`timeout`,`aborted`,`stale`,`session`]),f=/* @__PURE__ */ new Set([`GET`,`HEAD`]);function p(e=document){let t=[...e.querySelectorAll(`meta`)].find(e=>e.getAttribute(`name`)===s.metaName),n=t?.getAttribute(`content`);return!t||!n?null:{header:t.getAttribute(`data-header`)||s.header,token:n}}var m=e=>{try{return new URL(e,window.location.href).origin===window.location.origin}catch{return!1}};function h(e){return e>=200&&e<300?`ok`:e===401?`session`:e===403?`forbidden`:e===422?`validation`:e>=400&&e<500?`client`:`server`}var g=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,_=3e4;function v(e){let t=e?.trim()??``;return/^\d+$/.test(t)?Number(t):void 0}var y=e=>{if(e==null||e===``)return null;try{return JSON.parse(e)}catch(e){throw TypeError(`The ${u.data} response header is not JSON: ${e instanceof Error?e.message:String(e)}`,{cause:e})}};async function b(e,t={}){let n=(t.method||`GET`).toUpperCase(),r=t.navigate||(e=>window.location.assign(e)),a={Accept:`text/html`,"X-Requested-With":`XMLHttpRequest`,[l]:`1`,...t.headers};if(!f.has(n)&&m(e)){let e=p();e&&(a[e.header]=e.token)}let o=e=>{if(e==null)return null;try{return decodeURIComponent(e)}catch{return e}},s=(e,t=null,n=``)=>{let r=e=>t?.headers.get(e)??null;return{kind:e,ok:e===`ok`,status:t?.status??0,html:n,response:t,message:o(r(u.message)),redirect:r(u.redirect),result:r(u.result),keepOpen:r(u.keepOpen)===`1`,toastVariant:r(u.toastVariant),toastAction:i(r(u.toastAction)),fragment:r(u.fragment)===`1`,data:y(o(r(u.data))),next:r(u.next)}},c=new AbortController,d=()=>c.abort(),_=t.signal;_?.aborted&&c.abort(),_?.addEventListener(`abort`,d,{once:!0});let v=t.timeoutMs??0,b=!1,x=v>0?setTimeout(()=>{b=!0,c.abort()},v):void 0,S=e=>_?.aborted?`aborted`:b?`timeout`:g(e)?`aborted`:`network`;try{let i;try{i=await fetch(e,{method:n,...t.body===void 0?{}:{body:t.body},headers:a,signal:c.signal,credentials:`same-origin`})}catch(e){return s(S(e))}let o=h(i.status);if(o===`ok`&&i.redirected&&i.headers.get(u.fragment)!==`1`&&(o=`session`),o===`session`)return r(i.status===401?i.headers.get(`Location`)||window.location.href:i.url),s(o,i);let l=``;if(o===`ok`||o===`validation`)try{l=await i.text()}catch(e){return s(S(e),i)}return s(o,i,l)}finally{clearTimeout(x),_?.removeEventListener(`abort`,d)}}function x(){let e=null,t=0;return{async run(n,r={}){e?.abort();let i=new AbortController;e=i;let a=++t,o=r.signal;o&&(o.aborted?i.abort():o.addEventListener(`abort`,()=>i.abort(),{once:!0}));let s;try{s=await b(n,{...r,signal:i.signal})}finally{e===i&&(e=null)}return a!==t&&s.kind!==`aborted`?{...s,kind:`stale`,ok:!1}:s},abort(){e?.abort(),e=null}}}export{u as a,x as c,b as d,t as f,d as i,p as l,o as n,h as o,i as p,_ as r,c as s,a as t,v as u};
|