@kronor/dtv 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/assets/{index-BHV4-0-3.js → index-Cty-bDnK.js} +2 -2
  2. package/dist/index.es.js +31267 -0
  3. package/dist/index.html +1 -1
  4. package/dist/types/App.d.ts +31 -0
  5. package/dist/types/App.d.ts.map +1 -0
  6. package/dist/types/components/AIAssistantForm.d.ts +18 -0
  7. package/dist/types/components/AIAssistantForm.d.ts.map +1 -0
  8. package/dist/types/components/ActionButtons.d.ts +24 -0
  9. package/dist/types/components/ActionButtons.d.ts.map +1 -0
  10. package/dist/types/components/AsyncSearchDropdownFilter.d.ts +8 -0
  11. package/dist/types/components/AsyncSearchDropdownFilter.d.ts.map +1 -0
  12. package/dist/types/components/FilterForm.d.ts +19 -0
  13. package/dist/types/components/FilterForm.d.ts.map +1 -0
  14. package/dist/types/components/PhoneNumberFilter.d.ts +6 -0
  15. package/dist/types/components/PhoneNumberFilter.d.ts.map +1 -0
  16. package/dist/types/components/SavedFilterList.d.ts +15 -0
  17. package/dist/types/components/SavedFilterList.d.ts.map +1 -0
  18. package/dist/types/components/SpeechInput.d.ts +7 -0
  19. package/dist/types/components/SpeechInput.d.ts.map +1 -0
  20. package/dist/types/components/Table.d.ts +28 -0
  21. package/dist/types/components/Table.d.ts.map +1 -0
  22. package/dist/types/components/TablePagination.d.ts +12 -0
  23. package/dist/types/components/TablePagination.d.ts.map +1 -0
  24. package/dist/types/components/aiAssistant.d.ts +12 -0
  25. package/dist/types/components/aiAssistant.d.ts.map +1 -0
  26. package/dist/types/framework/actions.d.ts +36 -0
  27. package/dist/types/framework/actions.d.ts.map +1 -0
  28. package/dist/types/framework/cell-renderer-components/CurrencyAmount.d.ts +11 -0
  29. package/dist/types/framework/cell-renderer-components/CurrencyAmount.d.ts.map +1 -0
  30. package/dist/types/framework/cell-renderer-components/LayoutHelpers.d.ts +24 -0
  31. package/dist/types/framework/cell-renderer-components/LayoutHelpers.d.ts.map +1 -0
  32. package/dist/types/framework/cell-renderer-components/Link.d.ts +12 -0
  33. package/dist/types/framework/cell-renderer-components/Link.d.ts.map +1 -0
  34. package/dist/types/framework/cell-renderer-components/Mapping.d.ts +13 -0
  35. package/dist/types/framework/cell-renderer-components/Mapping.d.ts.map +1 -0
  36. package/dist/types/framework/column-definition.d.ts +63 -0
  37. package/dist/types/framework/column-definition.d.ts.map +1 -0
  38. package/dist/types/framework/currency.d.ts +22 -0
  39. package/dist/types/framework/currency.d.ts.map +1 -0
  40. package/dist/types/framework/data.d.ts +31 -0
  41. package/dist/types/framework/data.d.ts.map +1 -0
  42. package/dist/types/framework/filter-form-state.d.ts +81 -0
  43. package/dist/types/framework/filter-form-state.d.ts.map +1 -0
  44. package/dist/types/framework/filter-sharing.d.ts +24 -0
  45. package/dist/types/framework/filter-sharing.d.ts.map +1 -0
  46. package/dist/types/framework/filters.d.ts +233 -0
  47. package/dist/types/framework/filters.d.ts.map +1 -0
  48. package/dist/types/framework/graphql.d.ts +77 -0
  49. package/dist/types/framework/graphql.d.ts.map +1 -0
  50. package/dist/types/framework/native-runtime/index.d.ts +13 -0
  51. package/dist/types/framework/native-runtime/index.d.ts.map +1 -0
  52. package/dist/types/framework/runtime.d.ts +14 -0
  53. package/dist/types/framework/runtime.d.ts.map +1 -0
  54. package/dist/types/framework/saved-filters.d.ts +47 -0
  55. package/dist/types/framework/saved-filters.d.ts.map +1 -0
  56. package/dist/types/framework/state.d.ts +40 -0
  57. package/dist/types/framework/state.d.ts.map +1 -0
  58. package/dist/types/framework/view-parser.d.ts +168 -0
  59. package/dist/types/framework/view-parser.d.ts.map +1 -0
  60. package/dist/types/framework/view.d.ts +29 -0
  61. package/dist/types/framework/view.d.ts.map +1 -0
  62. package/dist/types/lib/index.d.ts +13 -0
  63. package/dist/types/lib/index.d.ts.map +1 -0
  64. package/dist/types/main.d.ts +23 -0
  65. package/dist/types/main.d.ts.map +1 -0
  66. package/dist/types/views/index.d.ts +8 -0
  67. package/dist/types/views/index.d.ts.map +1 -0
  68. package/dist/types/views/payment-requests/components/NoRowsExtendDateRange.d.ts +4 -0
  69. package/dist/types/views/payment-requests/components/NoRowsExtendDateRange.d.ts.map +1 -0
  70. package/dist/types/views/payment-requests/components/PaymentMethod.d.ts +9 -0
  71. package/dist/types/views/payment-requests/components/PaymentMethod.d.ts.map +1 -0
  72. package/dist/types/views/payment-requests/components/PaymentStatusTag.d.ts +4 -0
  73. package/dist/types/views/payment-requests/components/PaymentStatusTag.d.ts.map +1 -0
  74. package/dist/types/views/payment-requests/index.d.ts +2 -0
  75. package/dist/types/views/payment-requests/index.d.ts.map +1 -0
  76. package/dist/types/views/payment-requests/runtime.d.ts +30 -0
  77. package/dist/types/views/payment-requests/runtime.d.ts.map +1 -0
  78. package/dist/types/views/request-log/index.d.ts +3 -0
  79. package/dist/types/views/request-log/index.d.ts.map +1 -0
  80. package/dist/types/views/request-log/runtime.d.ts +3 -0
  81. package/dist/types/views/request-log/runtime.d.ts.map +1 -0
  82. package/dist/types/views/simple-test-view/index.d.ts +4 -0
  83. package/dist/types/views/simple-test-view/index.d.ts.map +1 -0
  84. package/dist/types/views/simple-test-view/runtime.d.ts +10 -0
  85. package/dist/types/views/simple-test-view/runtime.d.ts.map +1 -0
  86. package/package.json +1 -1
@@ -1741,7 +1741,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1741
1741
  position: relative;
1742
1742
  }
1743
1743
  }
1744
- `}}),r2=c.forwardRef(function(e,r){var t=mn(),o=c.useContext(Nn),n=Ff.getProps(e,o),s=c.useState(n.id),p=e0(s,2),d=p[0],m=p[1],g=c.useState(n.collapsed),b=e0(g,2),S=b[0],O=b[1],x=c.useRef(null),B=c.useRef(null),D=n.toggleable?n.onToggle?n.collapsed:S:!1,H=d+"_header",_=d+"_content",M=Ff.setMetaData({props:n,state:{id:d,collapsed:D}}),A=M.ptm,V=M.cx,U=M.isUnstyled;qr(Ff.css.styles,U,{name:"panel"});var me=function(ye){n.toggleable&&(D?ue(ye):ve(ye),ye&&(n.onToggle&&n.onToggle({originalEvent:ye,value:!D}),ye.preventDefault()))},ue=function(ye){n.onToggle||O(!1),n.onExpand&&ye&&n.onExpand(ye)},ve=function(ye){n.onToggle||O(!0),n.onCollapse&&ye&&n.onCollapse(ye)};c.useImperativeHandle(r,function(){return{props:n,toggle:me,expand:ue,collapse:ve,getElement:function(){return x.current},getContent:function(){return B.current}}}),zr(function(){d||m(al())});var K=function(){if(n.toggleable){var ye=d+"_label",we=t({className:V("toggler"),onClick:me,id:ye,"aria-controls":_,"aria-expanded":!D,type:"button",role:"button","aria-label":n.header},A("toggler")),N=t(A("togglericon")),te=D?n.expandIcon||c.createElement(tg,N):n.collapseIcon||c.createElement(n2,N),re=pn.getJSXIcon(te,N,{props:n,collapsed:D});return c.createElement("button",we,re,c.createElement(er,null))}return null},F=function(){var ye=k.getJSXElement(n.header,n),we=k.getJSXElement(n.icons,n),N=K(),te=t({id:H,className:V("title")},A("title")),re=c.createElement("span",te,ye),L=t({className:V("icons")},A("icons")),ne=c.createElement("div",L,we,N),ie=t({className:V("header")},A("header")),Ie=c.createElement("div",ie,re,ne);if(n.headerTemplate){var st={className:"p-panel-header",titleClassName:"p-panel-title",iconsClassName:"p-panel-icons",togglerClassName:"p-panel-header-icon p-panel-toggler p-link",onTogglerClick:me,titleElement:re,iconsElement:ne,togglerElement:N,element:Ie,id:d+"_header",props:n,collapsed:D};return k.getJSXElement(n.headerTemplate,st)}else if(n.header||n.toggleable)return Ie;return null},z=function(){var ye=k.getJSXElement(n.footer,n),we=t({className:V("footer")},A("footer")),N=c.createElement("div",we,ye);if(n.footerTemplate){var te={className:V("footer"),element:N,props:n};return k.getJSXElement(n.footerTemplate,te)}else if(n.footer)return N;return null},ae=function(){var ye=t({ref:B,className:V("toggleableContent"),"aria-hidden":D,role:"region",id:_,"aria-labelledby":H},A("toggleablecontent")),we=t({className:V("content")},A("content")),N=t({classNames:V("transition"),timeout:{enter:1e3,exit:450},in:!D,unmountOnExit:!0,options:n.transitionOptions},A("transition"));return c.createElement(mo,Ev({nodeRef:B},N),c.createElement("div",ye,c.createElement("div",we,n.children)))},j=t({id:d,ref:x,style:n.style,className:je(n.className,V("root"))},Ff.getOtherProps(n),A("root")),ee=F(),Y=ae(),Q=z();return c.createElement("div",j,ee,Y,Q)});r2.displayName="Panel";function a2(e,r,t){var o;switch(e.type){case"text":return Xe.jsx(fo,{className:"tw:w-full",placeholder:e.placeholder,value:r??"",onChange:n=>t(n.target.value)});case"number":return Xe.jsx(Gv,{className:"tw:w-full",placeholder:e.placeholder,value:r??null,onValueChange:n=>t(n.value)});case"date":return Xe.jsx(Yw,{className:"tw:w-full",placeholder:e.placeholder,value:r??null,onChange:n=>t(n.value),showIcon:!0,showButtonBar:!0,showTime:!0,dateFormat:"yy-mm-dd"});case"dropdown":return Xe.jsx(ki,{className:"tw:w-full",value:r??null,options:e.items,onChange:n=>t(n.value),optionLabel:"label",optionValue:"value",placeholder:"Any"});case"multiselect":return Xe.jsx(Ww,{className:"tw:w-full",value:r??[],options:e.items,onChange:n=>t(n.value),optionLabel:"label",optionValue:"value",placeholder:"Any",display:"chip",filter:e.filterable});case"customOperator":{const n=(r==null?void 0:r.operator)??((o=e.operators[0])==null?void 0:o.value),s=(r==null?void 0:r.value)??"";return Xe.jsxs("div",{className:"tw:flex tw:gap-2",children:[Xe.jsx(ki,{className:"tw:min-w-[90px]",value:n,options:e.operators,onChange:p=>t({operator:p.value,value:s}),optionLabel:"label",optionValue:"value",placeholder:"operator"}),Xe.jsx("div",{className:"tw:flex-1",children:a2(e.valueControl,s,p=>t({operator:n,value:p}))})]})}case"custom":return e.component?Xe.jsx(e.component,{...e.props||{},value:r,onChange:t}):null}}function ad(e,r,t,o){if(e.type==="and"||e.type==="or"){if(o.type!==e.type)throw new Error(`Schema consistency error: FilterFormState type "${e.type}" does not match FilterExpr type "${o.type}"`);const n=o.filters;if(n.length!==e.children.length)throw new Error(`Schema consistency error: FilterFormState has ${e.children.length} children but FilterExpr has ${n.length} filters`);return Xe.jsxs("div",{className:"tw:flex tw:flex-col tw:gap-2 tw:border-l-2 tw:pl-2 tw:ml-2",children:[t?Xe.jsx("div",{className:"tw:font-semibold tw:text-xs tw:mb-1 tw:uppercase",children:e.type}):null,e.children.map((s,p)=>Xe.jsx("div",{children:ad(s,d=>{const m=[...e.children];m[p]=d,r({...e,children:m})},t,n[p])},p))]})}else if(e.type==="not"){if(o.type!=="not")throw new Error(`Schema consistency error: FilterFormState type "not" does not match FilterExpr type "${o.type}"`);const n=o.filter;return Xe.jsxs("div",{className:"tw:flex tw:flex-col tw:gap-2 tw:border-l-2 tw:pl-2 tw:ml-2",children:[t?Xe.jsx("div",{className:"tw:font-semibold tw:text-xs tw:mb-1 tw:uppercase",children:e.type}):null,ad(e.child,s=>r({...e,child:s}),t,n)]})}else if(e.type==="leaf"){if(o.type==="and"||o.type==="or"||o.type==="not")throw new Error(`Schema consistency error: FilterFormState is leaf type but FilterExpr is "${o.type}"`);const n=p=>{const d={...e,value:p};r(d)},s=e.value;return Xe.jsxs("div",{className:"tw:flex tw:flex-col tw:min-w-[220px] tw:mb-2",children:[Xe.jsx("label",{className:"tw:text-sm tw:font-medium tw:mb-1",children:o.value.label}),a2(o.value,s,n)]})}return null}function W4({filterSchemasAndGroups:e,filterState:r,setFilterState:t,onSaveFilter:o,onUpdateFilter:n,onShareFilter:s,savedFilters:p,visibleFilterIds:d,onSubmit:m}){const g=c.useMemo(()=>new Map(e.filters.map(_=>[_.id,_])),[e]),b=c.useMemo(()=>new Set(d),[d]);function S(_){const M=g.get(_);if(!M)return;const A=Au(M.expression,ns.Empty);t(Hc(r,_,A))}function O(){t(bd(e,ns.Empty)),m()}const x=e.groups.find(_=>_.name==="default"),B=e.filters.filter(_=>_.group==="default"&&b.has(_.id)),H=e.groups.filter(_=>_.name!=="default").map(_=>({group:_,filters:e.filters.filter(M=>M.group===_.name&&b.has(M.id))})).filter(_=>_.filters.length>0);return Xe.jsxs("form",{className:"tw:mb-4",onSubmit:_=>{_.preventDefault(),m()},children:[x&&B.length>0&&Xe.jsx("div",{className:"tw:flex tw:flex-wrap tw:gap-4 tw:items-start tw:mb-4",children:B.map(_=>Xe.jsxs("div",{className:"tw:flex tw:flex-col tw:min-w-[220px] tw:mb-2",children:[Xe.jsxs("div",{className:"tw:flex tw:items-center tw:mb-1 tw:max-h-[20px]",children:[Xe.jsx("label",{className:"tw:text-sm tw:font-bold",children:_.label}),Xe.jsx(gr,{type:"button",size:"small",icon:"pi pi-filter-slash",rounded:!0,text:!0,title:"Reset filter",onClick:()=>S(_.id),visible:!Lb(Tu(r,_.id),_.expression)})]}),ad(Tu(r,_.id),M=>{t(Hc(r,_.id,M))},_.aiGenerated,_.expression)]},_.id))}),H.map(({group:_,filters:M})=>Xe.jsx(r2,{header:_.label,className:"tw:w-full tw:mb-4",children:Xe.jsx("div",{className:"tw:flex tw:flex-wrap tw:gap-4 tw:items-start",children:M.map(A=>Xe.jsxs("div",{className:"tw:flex tw:flex-col tw:min-w-[220px] mb-2",children:[Xe.jsxs("div",{className:"tw:flex tw:items-center tw:mb-1 tw:max-h-[20px]",children:[Xe.jsx("label",{className:"tw:text-sm tw:font-bold",children:A.label}),Xe.jsx(gr,{type:"button",size:"small",icon:"pi pi-filter-slash",rounded:!0,text:!0,title:"Reset filter",onClick:()=>S(A.id),visible:!Lb(Tu(r,A.id),A.expression)})]}),ad(Tu(r,A.id),V=>{t(Hc(r,A.id,V))},A.aiGenerated,A.expression)]},A.id))})},_.name)),Xe.jsxs("div",{className:"tw:flex tw:gap-2 tw:mb-3 tw:justify-end",children:[Xe.jsx(gr,{type:"submit",size:"small",label:"Apply filter",icon:"pi pi-filter"}),Xe.jsx(gr,{type:"button",size:"small",outlined:!0,label:"Reset All",icon:"pi pi-filter-slash",onClick:O,className:"p-button-secondary"}),Xe.jsx(t2,{size:"small",outlined:!0,label:"Save Filter",icon:"pi pi-bookmark",onClick:()=>o(r),model:p.map(_=>({label:`Update “${_.name}”`,icon:"pi pi-file-import",command:()=>n(_,r)})),className:"p-button-secondary"}),Xe.jsx(gr,{type:"button",size:"small",outlined:!0,icon:"pi pi-share-alt",label:"Share Filter",onClick:s,className:"p-button-secondary"})]})]})}function ls(e){"@babel/helpers - typeof";return ls=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ls(e)}function eO(e,r){if(ls(e)!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var o=t.call(e,r);if(ls(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function tO(e){var r=eO(e,"string");return ls(r)=="symbol"?r:r+""}function Mi(e,r,t){return(r=tO(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function nO(e){if(Array.isArray(e))return e}function rO(e,r){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var o,n,s,p,d=[],m=!0,g=!1;try{if(s=(t=t.call(e)).next,r!==0)for(;!(m=(o=s.call(t)).done)&&(d.push(o.value),d.length!==r);m=!0);}catch(b){g=!0,n=b}finally{try{if(!m&&t.return!=null&&(p=t.return(),Object(p)!==p))return}finally{if(g)throw n}}return d}}function t0(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,o=Array(r);t<r;t++)o[t]=e[t];return o}function aO(e,r){if(e){if(typeof e=="string")return t0(e,r);var t={}.toString.call(e).slice(8,-1);return t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set"?Array.from(e):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?t0(e,r):void 0}}function lO(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1744
+ `}}),r2=c.forwardRef(function(e,r){var t=mn(),o=c.useContext(Nn),n=Ff.getProps(e,o),s=c.useState(n.id),p=e0(s,2),d=p[0],m=p[1],g=c.useState(n.collapsed),b=e0(g,2),S=b[0],O=b[1],x=c.useRef(null),B=c.useRef(null),D=n.toggleable?n.onToggle?n.collapsed:S:!1,H=d+"_header",_=d+"_content",M=Ff.setMetaData({props:n,state:{id:d,collapsed:D}}),A=M.ptm,V=M.cx,U=M.isUnstyled;qr(Ff.css.styles,U,{name:"panel"});var me=function(ye){n.toggleable&&(D?ue(ye):ve(ye),ye&&(n.onToggle&&n.onToggle({originalEvent:ye,value:!D}),ye.preventDefault()))},ue=function(ye){n.onToggle||O(!1),n.onExpand&&ye&&n.onExpand(ye)},ve=function(ye){n.onToggle||O(!0),n.onCollapse&&ye&&n.onCollapse(ye)};c.useImperativeHandle(r,function(){return{props:n,toggle:me,expand:ue,collapse:ve,getElement:function(){return x.current},getContent:function(){return B.current}}}),zr(function(){d||m(al())});var K=function(){if(n.toggleable){var ye=d+"_label",we=t({className:V("toggler"),onClick:me,id:ye,"aria-controls":_,"aria-expanded":!D,type:"button",role:"button","aria-label":n.header},A("toggler")),N=t(A("togglericon")),te=D?n.expandIcon||c.createElement(tg,N):n.collapseIcon||c.createElement(n2,N),re=pn.getJSXIcon(te,N,{props:n,collapsed:D});return c.createElement("button",we,re,c.createElement(er,null))}return null},F=function(){var ye=k.getJSXElement(n.header,n),we=k.getJSXElement(n.icons,n),N=K(),te=t({id:H,className:V("title")},A("title")),re=c.createElement("span",te,ye),L=t({className:V("icons")},A("icons")),ne=c.createElement("div",L,we,N),ie=t({className:V("header")},A("header")),Ie=c.createElement("div",ie,re,ne);if(n.headerTemplate){var st={className:"p-panel-header",titleClassName:"p-panel-title",iconsClassName:"p-panel-icons",togglerClassName:"p-panel-header-icon p-panel-toggler p-link",onTogglerClick:me,titleElement:re,iconsElement:ne,togglerElement:N,element:Ie,id:d+"_header",props:n,collapsed:D};return k.getJSXElement(n.headerTemplate,st)}else if(n.header||n.toggleable)return Ie;return null},z=function(){var ye=k.getJSXElement(n.footer,n),we=t({className:V("footer")},A("footer")),N=c.createElement("div",we,ye);if(n.footerTemplate){var te={className:V("footer"),element:N,props:n};return k.getJSXElement(n.footerTemplate,te)}else if(n.footer)return N;return null},ae=function(){var ye=t({ref:B,className:V("toggleableContent"),"aria-hidden":D,role:"region",id:_,"aria-labelledby":H},A("toggleablecontent")),we=t({className:V("content")},A("content")),N=t({classNames:V("transition"),timeout:{enter:1e3,exit:450},in:!D,unmountOnExit:!0,options:n.transitionOptions},A("transition"));return c.createElement(mo,Ev({nodeRef:B},N),c.createElement("div",ye,c.createElement("div",we,n.children)))},j=t({id:d,ref:x,style:n.style,className:je(n.className,V("root"))},Ff.getOtherProps(n),A("root")),ee=F(),Y=ae(),Q=z();return c.createElement("div",j,ee,Y,Q)});r2.displayName="Panel";function a2(e,r,t){var o;switch(e.type){case"text":return Xe.jsx(fo,{className:"tw:w-full",placeholder:e.placeholder,value:r??"",onChange:n=>t(n.target.value)});case"number":return Xe.jsx(Gv,{className:"tw:w-full",placeholder:e.placeholder,value:r??null,onValueChange:n=>t(n.value)});case"date":return Xe.jsx(Yw,{className:"tw:w-full",placeholder:e.placeholder,value:r??null,onChange:n=>t(n.value),showIcon:!0,showButtonBar:!0,showTime:e.showTime??!0,dateFormat:"yy-mm-dd"});case"dropdown":return Xe.jsx(ki,{className:"tw:w-full",value:r??null,options:e.items,onChange:n=>t(n.value),optionLabel:"label",optionValue:"value",placeholder:"Any"});case"multiselect":return Xe.jsx(Ww,{className:"tw:w-full",value:r??[],options:e.items,onChange:n=>t(n.value),optionLabel:"label",optionValue:"value",placeholder:"Any",display:"chip",filter:e.filterable});case"customOperator":{const n=(r==null?void 0:r.operator)??((o=e.operators[0])==null?void 0:o.value),s=(r==null?void 0:r.value)??"";return Xe.jsxs("div",{className:"tw:flex tw:gap-2",children:[Xe.jsx(ki,{className:"tw:min-w-[90px]",value:n,options:e.operators,onChange:p=>t({operator:p.value,value:s}),optionLabel:"label",optionValue:"value",placeholder:"operator"}),Xe.jsx("div",{className:"tw:flex-1",children:a2(e.valueControl,s,p=>t({operator:n,value:p}))})]})}case"custom":return e.component?Xe.jsx(e.component,{...e.props||{},value:r,onChange:t}):null}}function ad(e,r,t,o){if(e.type==="and"||e.type==="or"){if(o.type!==e.type)throw new Error(`Schema consistency error: FilterFormState type "${e.type}" does not match FilterExpr type "${o.type}"`);const n=o.filters;if(n.length!==e.children.length)throw new Error(`Schema consistency error: FilterFormState has ${e.children.length} children but FilterExpr has ${n.length} filters`);return Xe.jsxs("div",{className:"tw:flex tw:flex-col tw:gap-2 tw:border-l-2 tw:pl-2 tw:ml-2",children:[t?Xe.jsx("div",{className:"tw:font-semibold tw:text-xs tw:mb-1 tw:uppercase",children:e.type}):null,e.children.map((s,p)=>Xe.jsx("div",{children:ad(s,d=>{const m=[...e.children];m[p]=d,r({...e,children:m})},t,n[p])},p))]})}else if(e.type==="not"){if(o.type!=="not")throw new Error(`Schema consistency error: FilterFormState type "not" does not match FilterExpr type "${o.type}"`);const n=o.filter;return Xe.jsxs("div",{className:"tw:flex tw:flex-col tw:gap-2 tw:border-l-2 tw:pl-2 tw:ml-2",children:[t?Xe.jsx("div",{className:"tw:font-semibold tw:text-xs tw:mb-1 tw:uppercase",children:e.type}):null,ad(e.child,s=>r({...e,child:s}),t,n)]})}else if(e.type==="leaf"){if(o.type==="and"||o.type==="or"||o.type==="not")throw new Error(`Schema consistency error: FilterFormState is leaf type but FilterExpr is "${o.type}"`);const n=p=>{const d={...e,value:p};r(d)},s=e.value;return Xe.jsxs("div",{className:"tw:flex tw:flex-col tw:min-w-[220px] tw:mb-2",children:[Xe.jsx("label",{className:"tw:text-sm tw:font-medium tw:mb-1",children:o.value.label}),a2(o.value,s,n)]})}return null}function W4({filterSchemasAndGroups:e,filterState:r,setFilterState:t,onSaveFilter:o,onUpdateFilter:n,onShareFilter:s,savedFilters:p,visibleFilterIds:d,onSubmit:m}){const g=c.useMemo(()=>new Map(e.filters.map(_=>[_.id,_])),[e]),b=c.useMemo(()=>new Set(d),[d]);function S(_){const M=g.get(_);if(!M)return;const A=Au(M.expression,ns.Empty);t(Hc(r,_,A))}function O(){t(bd(e,ns.Empty)),m()}const x=e.groups.find(_=>_.name==="default"),B=e.filters.filter(_=>_.group==="default"&&b.has(_.id)),H=e.groups.filter(_=>_.name!=="default").map(_=>({group:_,filters:e.filters.filter(M=>M.group===_.name&&b.has(M.id))})).filter(_=>_.filters.length>0);return Xe.jsxs("form",{className:"tw:mb-4",onSubmit:_=>{_.preventDefault(),m()},children:[x&&B.length>0&&Xe.jsx("div",{className:"tw:flex tw:flex-wrap tw:gap-4 tw:items-start tw:mb-4",children:B.map(_=>Xe.jsxs("div",{className:"tw:flex tw:flex-col tw:min-w-[220px] tw:mb-2",children:[Xe.jsxs("div",{className:"tw:flex tw:items-center tw:mb-1 tw:max-h-[20px]",children:[Xe.jsx("label",{className:"tw:text-sm tw:font-bold",children:_.label}),Xe.jsx(gr,{type:"button",size:"small",icon:"pi pi-filter-slash",rounded:!0,text:!0,title:"Reset filter",onClick:()=>S(_.id),visible:!Lb(Tu(r,_.id),_.expression)})]}),ad(Tu(r,_.id),M=>{t(Hc(r,_.id,M))},_.aiGenerated,_.expression)]},_.id))}),H.map(({group:_,filters:M})=>Xe.jsx(r2,{header:_.label,className:"tw:w-full tw:mb-4",children:Xe.jsx("div",{className:"tw:flex tw:flex-wrap tw:gap-4 tw:items-start",children:M.map(A=>Xe.jsxs("div",{className:"tw:flex tw:flex-col tw:min-w-[220px] mb-2",children:[Xe.jsxs("div",{className:"tw:flex tw:items-center tw:mb-1 tw:max-h-[20px]",children:[Xe.jsx("label",{className:"tw:text-sm tw:font-bold",children:A.label}),Xe.jsx(gr,{type:"button",size:"small",icon:"pi pi-filter-slash",rounded:!0,text:!0,title:"Reset filter",onClick:()=>S(A.id),visible:!Lb(Tu(r,A.id),A.expression)})]}),ad(Tu(r,A.id),V=>{t(Hc(r,A.id,V))},A.aiGenerated,A.expression)]},A.id))})},_.name)),Xe.jsxs("div",{className:"tw:flex tw:gap-2 tw:mb-3 tw:justify-end",children:[Xe.jsx(gr,{type:"submit",size:"small",label:"Apply filter",icon:"pi pi-filter"}),Xe.jsx(gr,{type:"button",size:"small",outlined:!0,label:"Reset All",icon:"pi pi-filter-slash",onClick:O,className:"p-button-secondary"}),Xe.jsx(t2,{size:"small",outlined:!0,label:"Save Filter",icon:"pi pi-bookmark",onClick:()=>o(r),model:p.map(_=>({label:`Update “${_.name}”`,icon:"pi pi-file-import",command:()=>n(_,r)})),className:"p-button-secondary"}),Xe.jsx(gr,{type:"button",size:"small",outlined:!0,icon:"pi pi-share-alt",label:"Share Filter",onClick:s,className:"p-button-secondary"})]})]})}function ls(e){"@babel/helpers - typeof";return ls=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ls(e)}function eO(e,r){if(ls(e)!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var o=t.call(e,r);if(ls(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function tO(e){var r=eO(e,"string");return ls(r)=="symbol"?r:r+""}function Mi(e,r,t){return(r=tO(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function nO(e){if(Array.isArray(e))return e}function rO(e,r){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var o,n,s,p,d=[],m=!0,g=!1;try{if(s=(t=t.call(e)).next,r!==0)for(;!(m=(o=s.call(t)).done)&&(d.push(o.value),d.length!==r);m=!0);}catch(b){g=!0,n=b}finally{try{if(!m&&t.return!=null&&(p=t.return(),Object(p)!==p))return}finally{if(g)throw n}}return d}}function t0(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,o=Array(r);t<r;t++)o[t]=e[t];return o}function aO(e,r){if(e){if(typeof e=="string")return t0(e,r);var t={}.toString.call(e).slice(8,-1);return t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set"?Array.from(e):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?t0(e,r):void 0}}function lO(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1745
1745
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ml(e,r){return nO(e)||rO(e,r)||aO(e,r)||lO()}var oO={start:"p-menubar-start",end:"p-menubar-end",button:"p-menubar-button",root:function(r){var t=r.mobileActiveState;return je("p-menubar p-component",{"p-menubar-mobile-active":t})},separator:"p-menuitem-separator",icon:"p-menuitem-icon",label:"p-menuitem-text",submenuIcon:"p-submenu-icon",menuitem:function(r){var t=r.active,o=r.focused,n=r.disabled;return je("p-menuitem",{"p-menuitem-active p-highlight":t,"p-focus":o,"p-disabled":n})},menu:"p-menubar-root-list",content:"p-menuitem-content",submenu:"p-submenu-list",action:function(r){var t=r.disabled;return je("p-menuitem-link",{"p-disabled":t})}},iO=`
1746
1746
  @layer primereact {
1747
1747
  .p-menubar {
@@ -2102,4 +2102,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
2102
2102
  `)}function n7(e,r,t){const o=new Map(e);return Object.entries(r).forEach(([n,s])=>{const p=t.filters.find(d=>d.id===n);if(p){const d=e.get(n)||Au(p.expression),m=Jf(p.expression,d,s);o.set(n,m)}}),o}function Jf(e,r,t){var o,n,s,p;if(!t)return r;if((e.type==="in"||e.type==="notIn")&&t.type==="or"&&Array.isArray(t.children)){const d=(g,b)=>(g&&(g.type==="leaf"?g.value!==void 0&&g.value!==""&&b.push(g.value):g.type==="or"&&Array.isArray(g.children)&&g.children.forEach(S=>d(S,b))),b),m=Array.from(new Set(d(t,[])));return{...r,type:"leaf",value:m}}if(r.type==="leaf"&&t.type==="not"&&((o=t.child)==null?void 0:o.type)==="leaf"){const m=e.value;if(m.type==="customOperator"){const g=t.child.value,b=(n=m.operators)==null?void 0:n.find(S=>S.value.includes("neq")||S.value.includes("not_equals")||S.label.toLowerCase().includes("not equals"));if(b){const S=typeof g=="string"?{operator:b.value,value:g}:g;return{...r,value:S}}}}if(r.type==="leaf"&&t.type==="leaf"){let d=t.value;const m=e,g=m.value;if((m.type==="in"||m.type==="notIn")&&(Array.isArray(d)||(d=[d])),g.type==="customOperator"&&typeof d=="string"&&(d={operator:(p=(s=g.operators)==null?void 0:s[0])==null?void 0:p.value,value:d}),g.type==="date"&&typeof d=="string"){const b=new Date(d);isNaN(b.getTime())?console.warn(`Failed to parse date for field ${m.field}:`,d):d=b}return{...r,value:d}}return r.type==="and"&&e.type==="and"&&t.type==="and"&&Array.isArray(t.children)?{...r,children:r.children.map((d,m)=>{const g=e.filters[m],b=t.children[m];return g?Jf(g,d,b):d})}:r.type==="or"&&e.type==="or"&&t.type==="or"&&Array.isArray(t.children)?{...r,children:r.children.map((d,m)=>{const g=e.filters[m],b=t.children[m];return g?Jf(g,d,b):d})}:r.type==="not"&&e.type==="not"&&t.type==="not"?{...r,child:Jf(e.filter,r.child,t.child)}:r}const r7={async sendPrompt(e,r,t,o,n){var p,d,m,g,b;const s=t7(e,r);try{const S=await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-lite:generateContent?key=${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contents:[{role:"user",parts:[{text:s}]}]})});if(!S.ok)throw new Error("Gemini API error");const B=(((b=(g=(m=(d=(p=(await S.json()).candidates)==null?void 0:p[0])==null?void 0:d.content)==null?void 0:m.parts)==null?void 0:g[0])==null?void 0:b.text)||"").match(/\{[\s\S]*\}/);if(B){const D=JSON.parse(B[0]),H=bd(e,ns.Empty),_=n7(H,D,e);t(_)}else{const D="Could not parse FilterFormState from Gemini response. Check the console.";n!=null&&n.current?n.current.show({severity:"warn",summary:"Parse Error",detail:D,life:3e3}):alert(D)}}catch(S){console.error(S);const O="Failed to get response from Gemini API.";n!=null&&n.current?n.current.show({severity:"error",summary:"API Error",detail:O,life:3e3}):alert(O)}}};function a7(e,r,t,o,n,s){return o.sendPrompt(e,r,t,n,s)}function l7({setFilterState:e,selectedView:r,geminiApiKey:t,toast:o,setShowFilterForm:n}){const[s,p]=c.useState("authorized payments in euro or danish krona in the first week of april 2025"),[d,m]=c.useState(!1);return Xe.jsxs("div",{className:"tw:flex tw:flex-col tw:gap-2 tw:mb-3",children:[Xe.jsx("label",{className:"tw:text-sm tw:font-semibold tw:mb-1",htmlFor:"ai-prompt",children:"AI Prompt"}),Xe.jsxs("div",{className:"tw:flex tw:gap-2",children:[Xe.jsx(WO,{value:s,onChange:p}),Xe.jsx(gr,{type:"button",outlined:!0,label:"Update filters",icon:"pi pi-sparkles",loading:d,onClick:async()=>{var g,b;m(!0);try{await a7(r.filterSchema,s,e,r7,t,o),n(!0),(g=o.current)==null||g.show({severity:"success",summary:"AI Filter Generated",detail:"Filter values have been populated based on your prompt",life:3e3})}catch(S){console.error("AI filter generation failed:",S),(b=o.current)==null||b.show({severity:"error",summary:"AI Generation Failed",detail:"Failed to generate filter from AI. Please try again.",life:3e3})}finally{m(!1)}},className:"p-button-secondary"})]})]})}function o7({savedFilters:e,onFilterDelete:r,onFilterLoad:t,onFilterApply:o,onFilterShare:n,visible:s,filterSchema:p}){if(!s)return null;const d=x=>{y2({message:`Are you sure you want to delete the filter "${x.name}"? This action cannot be undone.`,header:"Confirm Filter Deletion",icon:"pi pi-exclamation-triangle",defaultFocus:"reject",acceptClassName:"p-button-danger",accept:()=>{r(x.id)},reject:()=>{}})},m=x=>new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(x);function g(x){return typeof x=="object"&&x!==null&&"value"in x?Array.isArray(x.value)?x.value.length>0:typeof x.value=="object"&&x.value!==null&&"value"in x.value?g(x.value):x.value!=="":!1}const b=new Map(p.filters.map(x=>[x.id,x]));function S(x){const B=b.get(x);if(!B)return"";const D=B.expression;if(D&&"field"in D){const H=D.field;if(typeof H=="string")return H;if(H&&typeof H=="object"){if("and"in H&&Array.isArray(H.and))return H.and.join(" & ");if("or"in H&&Array.isArray(H.or))return H.or.join(" | ")}}return""}const O=x=>{if(!x||x.size===0)return null;const B=Array.from(x.entries()).filter(([,D])=>g(D));return B.length===0?null:Xe.jsx("div",{className:"tw:mt-2 tw:flex tw:flex-wrap tw:gap-1",children:B.map(([D,H],_)=>{let M="";if(H.type==="leaf"){const A=typeof H.value=="string"&&H.value.length>128?`${H.value.substring(0,128)}...`:String(H.value),V=S(D);M=V?`${V}: ${A}`:A}else H.type==="and"||H.type==="or"?M=`${H.type.toUpperCase()} (${H.children.length} filters)`:H.type==="not"&&(M="NOT (1 filter)");return Xe.jsx(og,{value:M,className:"tw:text-xs",style:{backgroundColor:"transparent",color:"#6366f1",borderWidth:1}},_)})})};return Xe.jsxs("div",{className:"tw:mb-4",children:[Xe.jsx("div",{className:"tw:mb-3",children:Xe.jsx("h3",{className:"tw:text-lg tw:font-medium tw:text-gray-900",children:"Saved Filters"})}),e.length===0?Xe.jsx("p",{className:"tw:text-gray-500 tw:text-center tw:py-4",children:"No saved filters for this view"}):Xe.jsx("div",{className:"tw:space-y-3",children:e.map(x=>Xe.jsxs("div",{className:"tw:flex tw:items-center tw:justify-between tw:p-3 tw:border tw:border-gray-200 tw:rounded-lg",children:[Xe.jsxs("div",{className:"tw:flex-1",children:[Xe.jsxs("div",{className:"tw:flex tw:items-center tw:gap-2 tw:mb-1",children:[Xe.jsx("h4",{className:"tw:font-medium tw:text-gray-900",children:x.name}),Xe.jsxs("span",{className:"tw:text-xs tw:text-gray-500 tw:bg-gray-100 tw:px-2 tw:py-1 tw:rounded",children:["Created: ",m(x.createdAt)]})]}),O(x.state)]}),Xe.jsxs("div",{className:"tw:flex tw:gap-2",children:[Xe.jsx(gr,{size:"small",outlined:!0,icon:"pi pi-filter",label:"Use",onClick:()=>{t(x.state),o()},className:"p-button"}),Xe.jsx(gr,{size:"small",outlined:!0,icon:"pi pi-share-alt",label:"Share",onClick:()=>n(x.state),className:"p-button-secondary"}),Xe.jsx(gr,{size:"small",outlined:!0,icon:"pi pi-trash",label:"Delete",onClick:()=>d(x),className:"p-button-danger"})]})]},x.id))})]})}function i7(e,r){function t(p,d){if(typeof p=="object"){if("and"in p)return{_and:p.and.map(g=>o(g,d))};if("or"in p)return{_or:p.or.map(g=>o(g,d))}}return typeof p=="string"?o(p,d):{}}function o(p,d){return p.includes(".")?p.split(".").reverse().reduce((g,b)=>({[b]:g}),d):{[p]:d}}function n(p,d){return Iu(p,d,{leaf:(m,g)=>{var B;let b=g.value,S=m.field;if(((B=m.transform)==null?void 0:B.toQuery)!==void 0){const D=m.transform.toQuery(g.value);D.field!==void 0&&(S=D.field),D.value!==void 0&&(b=D.value)}if(m.value.type==="customOperator"){const D=b;return!D||!D.operator||D.value===void 0||D.value===""||D.value===null||Array.isArray(D.value)&&D.value.length===0?null:t(S,{[D.operator]:D.value})}if(b===void 0||b===""||b===null||Array.isArray(b)&&b.length===0)return null;const x={equals:"_eq",notEquals:"_neq",greaterThan:"_gt",lessThan:"_lt",greaterThanOrEqual:"_gte",lessThanOrEqual:"_lte",in:"_in",notIn:"_nin",like:"_like",iLike:"_ilike",isNull:"_is_null"}[m.type];return x?t(S,{[x]:b}):null},and:(m,g,b)=>{const S=b.filter(O=>O!==null);return S.length===0?null:{_and:S}},or:(m,g,b)=>{const S=b.filter(O=>O!==null);return S.length===0?null:{_or:S}},not:(m,g,b)=>b?{_not:b}:null})}const s=[];for(const[p,d]of e.entries()){const m=r.filters.find(b=>b.id===p);if(!m)continue;const g=n(m.expression,d);g&&s.push(g)}return s.length===0?{}:s.length===1?s[0]:{_and:s}}function w2(e,r){const t=[...e];for(const o of r){const n=t.find(s=>s.field===o.field&&s.alias===o.alias&&s.path===o.path);n?(n.selections&&o.selections&&(n.selections=w2(n.selections,o.selections)),o.limit!==void 0&&(n.limit=o.limit),o.order_by&&(n.order_by=o.order_by),o.where&&(n.where=o.where),o.path&&(n.path=o.path)):t.push(o)}return t}function u7(e){function r(n,s){if(n.selections&&n.selections.length>0){const p=n.selections[n.selections.length-1],d=r(p,s);return{...n,selections:[...n.selections.slice(0,-1),d]}}else return{...n,alias:s}}function t(n){if(n.type==="field"){const s=n.path.split("."),p=d=>{const[m,...g]=d,b={field:m};return g.length>0&&(b.selections=[p(g)]),b};return p(s)}else if(n.type==="queryConfigs"){if(!n.configs.length)return null;const s=p=>{const[d,...m]=p,g={field:d.field};if(d.orderBy){const b=S=>Array.isArray(S)?S.map(O=>({[O.key]:O.direction.toUpperCase()})):{[S.key]:S.direction.toUpperCase()};g.order_by=b(d.orderBy)}return d.limit!==void 0&&(g.limit=d.limit),d.path&&(g.path=d.path),m.length&&(g.selections=[s(m)]),g};return s(n.configs)}else if(n.type==="fieldAlias"){const s=t(n.field);if(s){if(n.field.type==="field")return r(s,n.alias);if(n.field.type==="queryConfigs")return s.alias=n.alias,s}return s}return null}return e.flatMap(n=>n.data.map(t).filter(s=>!!s)).reduce((n,s)=>w2(n,[s]),[])}function S2(e,r,t,o,n){const s=u7(r);if(!s.some(d=>d.field===n||d.alias===n)){const d=m=>{const g=m.split("."),b=g[0];return g.length===1?{field:b}:{field:b,selections:[d(g.slice(1).join("."))]}};s.push(d(n))}return{operation:"query",variables:[{name:"conditions",type:`${t}!`},{name:"paginationCondition",type:`${t}!`},{name:"rowLimit",type:"Int"},{name:"orderBy",type:o}],rootField:`${e}(where: {_and: [$conditions, $paginationCondition]}, limit: $rowLimit, orderBy: $orderBy)`,selectionSet:s}}function c7(e,r,t,o,n){const s=S2(e,r,t,o,n);return E2(s)}function E2(e){function r(d){return d.length?"("+d.map(m=>`$${m.name}: ${m.type}`).join(", ")+")":""}function t(d){const m=[];if(d.where){const g=b=>Array.isArray(b)?`[${b.map(g).join(", ")}]`:typeof b=="object"&&b!==null?"_and"in b&&Array.isArray(b._and)?`_and: [${b._and.map(g).join(", ")}]`:"_or"in b&&Array.isArray(b._or)?`_or: [${b._or.map(g).join(", ")}]`:"_not"in b?`_not: {${g(b._not)}}`:Object.entries(b).map(([S,O])=>Array.isArray(O)?`${S}: [${O.map(g).join(", ")}]`:typeof O=="object"&&O!==null?`${S}: {${Object.entries(O).map(([x,B])=>`${x}: ${typeof B=="string"?`"${B}"`:JSON.stringify(B)}`).join(", ")}}`:`${S}: ${typeof O=="string"?`"${O}"`:JSON.stringify(O)}`).join(", "):JSON.stringify(b);m.push(`where: {${g(d.where)}}`)}if(d.limit!==void 0&&m.push(`limit: ${d.limit}`),d.path&&m.push(`path: "${d.path}"`),d.order_by){const g=b=>Array.isArray(b)?"["+b.map(g).join(", ")+"]":typeof b=="object"&&b!==void 0?"{"+Object.entries(b).map(([S,O])=>`${S}: ${String(O).toUpperCase()}`).join(", ")+"}":String(b).toUpperCase();m.push(`orderBy: ${g(d.order_by)}`)}return m.length?`(${m.join(", ")})`:""}function o(d,m=" "){return d.map(g=>{const b=t(g),S=g.alias?`${g.alias}: ${g.field}`:g.field;return g.selections&&g.selections.length?`${m}${S}${b} {`+o(g.selections,m+" ")+`${m}}`:`${m}${S}${b}`}).join(`
2103
2103
  `)}const n=r(e.variables),s=o(e.selectionSet),p=e.name?` ${e.name}`:"";return`${e.operation}${p}${n} { ${e.rootField} {`+s+`
2104
2104
  }
2105
- }`}function s7(e,r){return typeof e=="object"&&e!==null&&r in e&&Array.isArray(e[r])}let g0=0;const C2=(e,r,t,o)=>{let n=i7(r,e.filterSchema);e.staticConditions&&e.staticConditions.length>0&&(n={_and:[n,...e.staticConditions]});const s=o!==null?{[e.paginationKey]:{_lt:o}}:{};return{conditions:n,paginationCondition:s,rowLimit:t,orderBy:[{[e.paginationKey]:"DESC"}]}},f7=async({client:e,view:r,query:t,filterState:o,rowLimit:n,cursor:s})=>{const p=++g0;try{const d=C2(r,o,n,s),m=await e.request(t,d);if(p!==g0)throw new DOMException("Request superseded by newer request","AbortError");if(!s7(m,r.collectionName))return console.error("Error fetching data, unexpected response format:",m),{rows:[],flattenedRows:[]};const g=m[r.collectionName];return{rows:g,flattenedRows:d7(g,r.columnDefinitions)}}catch(d){if(d instanceof DOMException&&d.name==="AbortError")throw d;return console.error("Error fetching data:",d),{rows:[],flattenedRows:[]}}},d7=(e,r)=>e.map(t=>r.map(o=>p7(t,o))),p7=(e,r)=>{const t={},o=n=>{if(n.type==="field"){const s=n.path.split(".");let p=e;for(const d of s)if(Array.isArray(p)){p=p.map(m=>{let g=m;for(let b=s.indexOf(d);b<s.length;b++)g=g==null?void 0:g[s[b]];return g});break}else p=p==null?void 0:p[d];t[n.path]=p}else if(n.type==="queryConfigs"){const s=n.configs.map(d=>d.field).join("."),p=(d,m)=>{if(m.length===0)return d;if(d==null)return;const[g,...b]=m;if(Array.isArray(d))return d.map(S=>p(S,m));if(typeof d=="object"&&g.field in d){const S=d[g.field];return p(S,b)}};t[s]=p(e,n.configs)}else n.type==="fieldAlias"&&(t[n.alias]=e[n.alias])};return r.data.forEach(o),t};function m7(e){return"field"in e&&"value"in e}function Lv(e){const r=[];if(m7(e))r.push(e);else if(e.type==="and"||e.type==="or")for(const t of e.filters)r.push(...Lv(t));else e.type==="not"&&r.push(...Lv(e.filter));return r}function fs(e,r,t){const{section:o,key:n}=e;if(r&&r[o]&&r[o][n]!==void 0)return r[o][n];if(t[o]&&t[o][n]!==void 0)return t[o][n];const s=r?Object.keys(r[o]||{}):[],p=Object.keys(t[o]||{}),d=[...new Set([...s,...p])];throw new Error(`Reference "${n}" not found in ${o}. Available keys: ${d.join(", ")}`)}function vs(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid RuntimeReference: Expected an object");const r=e;if(typeof r.section!="string")throw new Error('Invalid RuntimeReference: "section" must be a string');if(typeof r.key!="string")throw new Error('Invalid RuntimeReference: "key" must be a string');const t=["cellRenderers","noRowsComponents","customFilterComponents","queryTransforms","initialValues"];if(!t.includes(r.section))throw new Error(`Invalid RuntimeReference: "section" must be one of: ${t.join(", ")}`);return{section:r.section,key:r.key}}function h0(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid orderBy: Expected an object");const r=e;if(typeof r.key!="string")throw new Error('Invalid orderBy: "key" field must be a string');if(r.direction!=="ASC"&&r.direction!=="DESC")throw new Error('Invalid orderBy: "direction" field must be "ASC" or "DESC"');return{key:r.key,direction:r.direction}}function v7(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid QueryConfig: Expected an object");const r=e;if(typeof r.field!="string")throw new Error('Invalid QueryConfig: "field" must be a string');const t={field:r.field};if(r.orderBy!==void 0&&r.orderBy!==null&&(Array.isArray(r.orderBy)?t.orderBy=r.orderBy.map(h0):t.orderBy=h0(r.orderBy)),r.limit!==void 0&&r.limit!==null){if(typeof r.limit!="number"||r.limit<0||!Number.isInteger(r.limit))throw new Error('Invalid QueryConfig: "limit" must be a non-negative integer');t.limit=r.limit}if(r.path!==void 0&&r.path!==null){if(typeof r.path!="string")throw new Error('Invalid QueryConfig: "path" must be a string');t.path=r.path}return t}function x2(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid FieldQuery: Expected an object");const r=e;if(r.type==="field"){if(typeof r.path!="string")throw new Error('Invalid Field: "path" must be a string');return{type:"field",path:r.path}}else if(r.type==="queryConfigs"){if(!Array.isArray(r.configs))throw new Error('Invalid QueryConfigs: "configs" must be an array');return{type:"queryConfigs",configs:r.configs.map(v7)}}else if(r.type==="fieldAlias"){if(typeof r.alias!="string")throw new Error('Invalid FieldAlias: "alias" must be a string');if(!r.field)throw new Error('Invalid FieldAlias: "field" is required');return{type:"fieldAlias",alias:r.alias,field:x2(r.field)}}else throw new Error('Invalid FieldQuery: "type" must be "field", "queryConfigs", or "fieldAlias"')}function g7(e,r,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid JSON: Expected an object");const o=e;if(!Array.isArray(o.data))throw new Error('Invalid JSON: "data" field must be an array of FieldQuery objects');if(typeof o.name!="string")throw new Error('Invalid JSON: "name" field must be a string');if(!o.cellRenderer)throw new Error('Invalid JSON: "cellRenderer" field is required');const n=vs(o.cellRenderer);if(n.section!=="cellRenderers")throw new Error('Invalid cellRenderer: section must be "cellRenderers"');const s=o.data.map((g,b)=>{try{return x2(g)}catch(S){throw new Error(`Invalid data[${b}]: ${S instanceof Error?S.message:"Unknown error"}`)}}),p=t?Object.keys(t.cellRenderers||{}):[],d=Object.keys(r.cellRenderers||{}),m=[...new Set([...p,...d])];if(!m.includes(n.key))throw new Error(`Invalid cellRenderer reference: "${n.key}". Valid keys are: ${m.join(", ")}`);return{data:s,name:o.name,cellRenderer:n}}function h7(e){if(typeof e=="string")return e;if(typeof e=="object"&&e!==null&&!Array.isArray(e)){const r=e;if("and"in r){if(!Array.isArray(r.and))throw new Error('Invalid FilterField: "and" must be an array of strings');if(!r.and.every(t=>typeof t=="string"))throw new Error('Invalid FilterField: "and" array must contain only strings');return{and:r.and}}if("or"in r){if(!Array.isArray(r.or))throw new Error('Invalid FilterField: "or" must be an array of strings');if(!r.or.every(t=>typeof t=="string"))throw new Error('Invalid FilterField: "or" array must contain only strings');return{or:r.or}}}throw new Error('Invalid FilterField: must be a string or object with "and" or "or" arrays')}function y7(e,r,t){if(e==null)return e;let o;try{o=vs(e)}catch{return e}return o.section==="initialValues"?fs(o,t,r):e}function O2(e,r,t){if(!e||typeof e!="object"&&!Array.isArray(e))throw new Error("Invalid FilterControl: Expected an object");const o=e,n=o.initialValue!==void 0?y7(o.initialValue,r,t):void 0;if(o.type==="custom"){const s=vs(o.component);if(s.section!=="customFilterComponents")throw new Error('Invalid custom filter component: section must be "customFilterComponents"');const p=fs(s,t,r);return{...o,component:p,initialValue:n}}return o.type==="customOperator"?{...o,valueControl:O2(o.valueControl,r,t),initialValue:n}:{...o,initialValue:n}}function jv(e,r,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid FilterExpr: Expected an object");const o=e;if(typeof o.type!="string")throw new Error('Invalid FilterExpr: "type" must be a string');if(o.type==="and"||o.type==="or"){if(!Array.isArray(o.filters))throw new Error(`Invalid ${o.type} FilterExpr: "filters" must be an array`);return{type:o.type,filters:o.filters.map(m=>jv(m,r,t))}}if(o.type==="not"){if(!o.filter||typeof o.filter!="object")throw new Error('Invalid not FilterExpr: "filter" must be an object');return{type:"not",filter:jv(o.filter,r,t)}}const n=["equals","notEquals","greaterThan","lessThan","greaterThanOrEqual","lessThanOrEqual","in","notIn","like","iLike","isNull"];if(!n.includes(o.type))throw new Error(`Invalid FilterExpr type: "${o.type}". Valid types are: ${n.join(", ")}, and, or, not`);const s=h7(o.field);if(!o.value)throw new Error('Invalid FilterExpr: "value" is required');const p=O2(o.value,r,t),d={type:o.type,field:s,value:p};if(o.transform){const m=vs(o.transform);if(m.section!=="queryTransforms")throw new Error('Invalid transform: section must be "queryTransforms"');const g=fs(m,t,r);d.transform=g}return d}function b7(e,r,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid FilterFieldSchema: Expected an object");const o=e;if(!Array.isArray(o.groups))throw new Error('Invalid FilterFieldSchema: "groups" must be an array');const n=o.groups.map((p,d)=>{if(!p||typeof p!="object"||Array.isArray(p))throw new Error(`Invalid group[${d}]: Expected an object`);const m=p;if(typeof m.name!="string")throw new Error(`Invalid group[${d}]: "name" must be a string`);if(m.label!==null&&typeof m.label!="string")throw new Error(`Invalid group[${d}]: "label" must be a string or null`);return{name:m.name,label:m.label}});if(!Array.isArray(o.filters))throw new Error('Invalid FilterFieldSchema: "filters" must be an array');const s=o.filters.map((p,d)=>{if(!p||typeof p!="object"||Array.isArray(p))throw new Error(`Invalid filter[${d}]: Expected an object`);const m=p;if(typeof m.id!="string")throw new Error(`Invalid filter[${d}]: "id" must be a string`);if(typeof m.label!="string")throw new Error(`Invalid filter[${d}]: "label" must be a string`);if(typeof m.group!="string")throw new Error(`Invalid filter[${d}]: "group" must be a string`);if(typeof m.aiGenerated!="boolean")throw new Error(`Invalid filter[${d}]: "aiGenerated" must be a boolean`);if(!m.expression)throw new Error(`Invalid filter[${d}]: "expression" is required`);let g;try{g=jv(m.expression,r,t)}catch(b){throw new Error(`Invalid filter[${d}] expression: ${b instanceof Error?b.message:"Unknown error"}`)}return{id:m.id,label:m.label,expression:g,group:m.group,aiGenerated:m.aiGenerated}});return{groups:n,filters:s}}function w7(e,r,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("View JSON must be a non-null object");const o=e;if(typeof o.title!="string")throw new Error('View "title" must be a string');if(typeof o.id!="string")throw new Error('View "id" must be a string');if(typeof o.collectionName!="string")throw new Error('View "collectionName" must be a string');if(typeof o.paginationKey!="string")throw new Error('View "paginationKey" must be a string');if(typeof o.boolExpType!="string")throw new Error('View "boolExpType" must be a string');if(typeof o.orderByType!="string")throw new Error('View "orderByType" must be a string');if(!Array.isArray(o.columns))throw new Error('View "columns" must be an array');if(!o.filterSchema)throw new Error('View "filterSchema" is required');const n=o.columns.map((m,g)=>{let b;try{b=g7(m,r,t)}catch(O){throw new Error(`Invalid column[${g}]: ${O instanceof Error?O.message:"Unknown error"}`)}const S=fs(b.cellRenderer,t,r);return{data:b.data,name:b.name,cellRenderer:S}});let s;try{s=b7(o.filterSchema,r,t)}catch(m){throw new Error(`Invalid filterSchema: ${m instanceof Error?m.message:"Unknown error"}`)}let p;if(o.noRowsComponent!==void 0){const m=vs(o.noRowsComponent);if(m.section!=="noRowsComponents")throw new Error('Invalid noRowsComponent: section must be "noRowsComponents"');p=fs(m,t,r)}let d;if(o.staticConditions!==void 0){if(!Array.isArray(o.staticConditions))throw new Error('View "staticConditions" must be an array when provided');const m=o.staticConditions.findIndex(g=>typeof g!="object"||g===null||Array.isArray(g));if(m!==-1)throw new Error(`View "staticConditions" entry[${m}] must be a non-null object`);d=o.staticConditions}return{title:o.title,id:o.id,collectionName:o.collectionName,columnDefinitions:n,filterSchema:s,boolExpType:o.boolExpType,orderByType:o.orderByType,paginationKey:o.paginationKey,noRowsComponent:p,staticConditions:d}}const y0="2025-09-04T00:00:00.000Z",Uf="2025-09-19T00:00:00.000Z",Xo="dtvSavedFilters",Sm="savedFilters";function S7(e,r){if(!Array.isArray(e))return console.warn("Expected array for conversion but got:",typeof e),{};const t={};return e.forEach((o,n)=>{if(n<r.filters.length){const s=r.filters[n].id;t[s]=o}}),t}function E7(){function e(){try{if(localStorage.getItem(Xo))return!1;const p=localStorage.getItem(Sm);if(!p)return!1;console.info("Found saved filters in legacy localStorage key, migrating..."),localStorage.setItem(Xo,p),localStorage.removeItem(Sm);const d=JSON.parse(p),m=Array.isArray(d)?d.length:0;return console.info(`Migrated ${m} filters from legacy localStorage key '${Sm}' to '${Xo}'`),!0}catch(p){return console.error("Failed to migrate legacy localStorage key:",p),!1}}function r(){try{e();const p=localStorage.getItem(Xo);if(!p)return[];const d=JSON.parse(p);return Array.isArray(d)?d.map(m=>{if(typeof m!="object"||m===null)throw new Error("Invalid saved filter structure");const g=m;return{id:typeof g.id=="string"?g.id:crypto.randomUUID(),name:typeof g.name=="string"?g.name:"Unnamed Filter",view:typeof g.view=="string"?g.view:"",state:g.state,createdAt:typeof g.createdAt=="string"?g.createdAt:new Date().toISOString(),formatRevision:typeof g.formatRevision=="string"?g.formatRevision:y0}}):[]}catch(p){return console.error("Failed to load saved filters from localStorage:",p),[]}}function t(p,d){const m=r();let g=!1;const b=m.map(x=>{if(x.formatRevision===y0){g=!0;const B=S7(x.state,d);return{...x,state:B,formatRevision:Uf}}return{...x,formatRevision:Uf}}),O=b.filter(x=>x.view===p).map(x=>{const B=Uw(x.state,d);return{id:x.id,name:x.name,view:x.view,state:B,createdAt:typeof x.createdAt=="string"?new Date(x.createdAt):x.createdAt,formatRevision:Uf}});if(g)try{localStorage.setItem(Xo,JSON.stringify(b)),console.info("Migrated filters from old array format to new object format")}catch(x){console.error("Failed to save migrated filters to localStorage:",x)}return O}function o(p){const d={id:crypto.randomUUID(),createdAt:new Date,formatRevision:Uf,...p},m=r(),g={...d,createdAt:d.createdAt.toISOString(),state:vv(d.state)};return m.push(g),localStorage.setItem(Xo,JSON.stringify(m)),d}function n(p,d){const m=r(),g=m.findIndex(O=>O.id===p.id);if(g===-1)return null;const b={...p,...d},S={...m[g],name:b.name,state:d.state?vv(d.state):m[g].state};return m[g]=S,localStorage.setItem(Xo,JSON.stringify(m)),b}function s(p){const d=r(),m=d.length,g=d.filter(b=>b.id!==p);return g.length===m?!1:(localStorage.setItem(Xo,JSON.stringify(g)),!0)}return{loadFilters:t,saveFilter:o,updateFilter:n,deleteFilter:s}}const Vf=E7();function D2(e){try{const r=vv(e),t=JSON.stringify(r);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}catch(r){throw console.error("Failed to encode filter state:",r),new Error("Failed to encode filter state")}}function C7(e){try{const r=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),t=atob(r);return JSON.parse(t)}catch(r){throw console.error("Failed to decode filter state:",r),new Error("Failed to decode filter state")}}const ds="dtv-filter-state";function b0(e){try{const r=D2(e),t=new URL(window.location.href);return t.searchParams.set(ds,r),t.toString()}catch(r){throw console.error("Failed to create shareable URL:",r),new Error("Failed to create shareable URL")}}async function w0(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(e);else{const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select(),document.execCommand("copy"),document.body.removeChild(r)}}catch(r){throw console.error("Failed to copy to clipboard:",r),new Error("Failed to copy to clipboard")}}function x7(){try{const r=new URLSearchParams(window.location.search).get(ds);return r?C7(r):null}catch(e){return console.warn("Failed to parse filter from URL:",e),null}}function O7(){const e=new URL(window.location.href);e.searchParams.delete(ds),window.history.replaceState({},"",e.toString())}function D7(e){try{const r=D2(e),t=new URL(window.location.href);t.searchParams.get(ds)!==r&&(t.searchParams.set(ds,r),window.history.replaceState({},"",t.toString()))}catch(r){console.warn("Failed to set filter in URL",r)}}function T7({actions:e,selectedView:r,filterState:t,setFilterState:o,refetch:n,showToast:s,paginationState:p,rowsPerPage:d}){const[m,g]=c.useState(()=>new Set);return Xe.jsx(Xe.Fragment,{children:e.map((b,S)=>{const O=m.has(S),x=async()=>{if(O)return;g(D=>new Set(D).add(S));const B={view:r,filterState:t,setFilterState:o,refetch:n,showToast:s,generateGraphQLQueryAST:S2,renderGraphQLQuery:E2,buildGraphQLQueryVariables:C2,getPaginationState:()=>p,rowsPerPage:d};try{await b.onClick(B)}catch(D){console.error("Action handler error",D),s({severity:"error",summary:"Action Failed",detail:b.label,life:3e3})}finally{g(D=>{const H=new Set(D);return H.delete(S),H})}};return Xe.jsx(gr,{type:"button",icon:b.icon,outlined:b.outlined!==!1,size:b.size==="normal"?void 0:"small",disabled:b.disabled||O,label:O?`${b.label}...`:b.label,onClick:x,"data-testid":`dtv-action-${S}`},`custom-action-${S}`)})})}const R7=i4;function T2({graphqlHost:e,graphqlToken:r,geminiApiKey:t,showViewsMenu:o,rowsPerPage:n=20,showViewTitle:s,showCsvExportButton:p=!1,showPopoutButton:d=!0,viewsJson:m,externalRuntime:g,isOverlay:b=!1,onCloseOverlay:S,syncFilterStateToUrl:O=!1,rowSelection:x,actions:B=[]}){const D=c.useMemo(()=>JSON.parse(m).map(fe=>w7(fe,R7,g)),[m,g]),H=c.useMemo(()=>new tC(e,{headers:{contentType:"application/json",Authorization:`Bearer ${r}`}}),[e,r]),_=c.useMemo(()=>{const ce=x7();if(ce)try{const fe=D[0];return fe?Uw(ce,fe.filterSchema):void 0}catch(fe){console.warn("Invalid initial filter state from URL, falling back to defaults",fe);return}},[m]),{state:M,selectedView:A,setSelectedViewId:V,setFilterSchema:U,setFilterState:me,setDataRows:ue}=r4(D,_),ve=c.useMemo(()=>c7(A.collectionName,A.columnDefinitions,A.boolExpType,A.orderByType,A.paginationKey),[A.id]),[K,F]=c.useState([]),[z,ae]=c.useState(""),j=c.useRef(null),ee=c.useRef(null),[Y,Q]=c.useState(!1),[xe,ye]=c.useState(!1),[we,N]=c.useState(!1),[te,re]=c.useState(0),[L,ne]=c.useState(!1);c.useEffect(()=>{z&&!xe&&ye(!0)},[z,xe]),c.useEffect(()=>{if(!b&&L){const ce=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=ce}}},[L,b]),c.useEffect(()=>{if(!b)return;const ce=fe=>{fe.key==="Escape"&&(S==null||S())};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[b,S]);const ie=M.data.rows.length===n,Ie=M.pagination.page>0;c.useEffect(()=>{const ce=Vf.loadFilters(A.id,A.filterSchema);F(ce)},[A.id]),c.useEffect(()=>{var ce;_&&!O&&(O7(),(ce=j.current)==null||ce.show({severity:"info",summary:"Filter Loaded",detail:"Loaded from URL",life:3e3}))},[]),c.useEffect(()=>{O&&D7(M.filterState)},[O,te]);const st=ce=>{var nt;const fe=prompt("Enter a name for this filter:");if(!fe)return;const Ze=Vf.saveFilter({view:A.id,name:fe,state:ce});F(ut=>[...ut,Ze]),(nt=j.current)==null||nt.show({severity:"success",summary:"Filter Saved",detail:`Filter "${fe}" has been saved successfully`,life:3e3})},dt=(ce,fe)=>{y2({message:`Are you sure you want to overwrite the existing filter "${ce.name}"?`,header:"Confirm Filter Update",icon:"pi pi-exclamation-triangle",defaultFocus:"reject",acceptClassName:"p-button-danger",accept:()=>{var nt;const Ze=Vf.updateFilter(ce,{state:fe});Ze&&(F(ut=>ut.map(un=>un.id===ce.id?Ze:un)),(nt=j.current)==null||nt.show({severity:"success",summary:"Filter Updated",detail:`Filter "${ce.name}" has been updated successfully`,life:3e3}))},reject:()=>{}})},At=ce=>{var Ze;Vf.deleteFilter(ce)&&(F(nt=>nt.filter(ut=>ut.id!==ce)),(Ze=j.current)==null||Ze.show({severity:"success",summary:"Filter Deleted",detail:"Filter has been deleted successfully",life:3e3}))},Qe=async()=>{var ce,fe;try{const Ze=b0(M.filterState);await w0(Ze),(ce=j.current)==null||ce.show({severity:"success",summary:"Filter Shared",detail:"Shareable link copied to clipboard!",life:3e3})}catch(Ze){console.error("Failed to share filter:",Ze),(fe=j.current)==null||fe.show({severity:"error",summary:"Share Failed",detail:"Failed to create shareable link",life:3e3})}},ot=async ce=>{var fe,Ze;try{const nt=b0(ce);await w0(nt),(fe=j.current)==null||fe.show({severity:"success",summary:"Filter Shared",detail:"Shareable link copied to clipboard!",life:3e3})}catch(nt){console.error("Failed to share saved filter:",nt),(Ze=j.current)==null||Ze.show({severity:"error",summary:"Share Failed",detail:"Failed to create shareable link",life:3e3})}},ke=()=>{ee.current&&ee.current.exportCSV({selectionOnly:!1})},Ye=c.useCallback(ce=>f7({client:H,view:A,query:ve,filterState:M.filterState,rowLimit:n,cursor:ce}),[H,A,ve,M.filterState,n]);c.useEffect(()=>{Ye(null).then(ce=>ue(ce)).catch(ce=>{ce instanceof DOMException&&ce.name})},[M.selectedViewId,te]);const pt=ce=>{me(ce)},Nt=M.filterSchemasAndGroups.filters.flatMap(ce=>{function fe(ut){return ut.toLowerCase().includes(z.toLowerCase())}function Ze(ut){return typeof ut=="string"?fe(ut):"and"in ut?ut.and.some(un=>fe(un)):"or"in ut?ut.or.some(un=>fe(un)):!1}return fe(ce.label)?[ce.id]:Lv(ce.expression).some(ut=>Ze(ut.field))?[ce.id]:[]}),jt=async()=>{const ce=M.data.rows.length>0?M.data.rows[M.data.rows.length-1][A.paginationKey]:null;if(typeof ce!="string"&&typeof ce!="number"){console.error("Invalid cursor type:",ce);return}const fe=await Ye(ce);ue(fe,{page:M.pagination.page+1,cursors:[...M.pagination.cursors,ce]})},Tt=async()=>{if(M.pagination.page===0)return;const ce=M.pagination.cursors.slice(0,-1),fe=ce[ce.length-1]??null,Ze=await Ye(fe);ue(Ze,{page:M.pagination.page-1,cursors:ce})};return Xe.jsxs("div",{className:"tw:p-2",children:[Xe.jsx(p2,{ref:j}),Xe.jsx(b2,{}),Xe.jsx(l2,{model:[...o?[{label:"Views",icon:"pi pi-eye",items:D.map(ce=>({label:ce.title,icon:"pi pi-table",command:()=>V(ce.id)}))}]:[]],className:"tw:mb-4 tw:border-b",start:Xe.jsxs("div",{className:"tw:flex tw:gap-2 tw:items-center",children:[Xe.jsx(gr,{type:"button",icon:xe?"pi pi-filter-slash":"pi pi-filter",outlined:!0,size:"small",label:xe?"Hide Filters":"Filters",onClick:()=>{ye(ce=>{const fe=!ce;return fe||ae(""),fe})}}),Xe.jsx(gr,{type:"button",icon:"pi pi-bookmark",outlined:!0,size:"small",label:we?"Hide Saved Filters":"Saved Filters",onClick:()=>N(ce=>!ce)}),p&&Xe.jsx(gr,{type:"button",icon:"pi pi-table",outlined:!0,size:"small",label:"Export page to CSV",onClick:ke,"data-testid":"export-csv-button"}),d&&Xe.jsx(gr,{type:"button",icon:b?"pi pi-times":"pi pi-window-maximize",outlined:!0,size:"small",label:b?"Close Popout":"Popout",onClick:()=>{b?S==null||S():ne(!0)}}),Xe.jsx(T7,{actions:B,selectedView:A,filterState:M.filterState,setFilterState:me,refetch:()=>re(ce=>ce+1),showToast:ce=>{var fe;return(fe=j.current)==null?void 0:fe.show({...ce})},paginationState:M.pagination,rowsPerPage:n})]}),end:Xe.jsxs("div",{className:"tw:flex tw:gap-2",children:[Xe.jsxs(o2,{iconPosition:"left",children:[Xe.jsx(i2,{className:"pi pi-search"}),Xe.jsx(fo,{value:z,onChange:ce=>ae(ce.target.value),placeholder:"Search filters..."})]}),Xe.jsx(gr,{type:"button",size:"small",icon:"pi pi-sparkles",label:"AI Filter Assistant",onClick:()=>Q(ce=>!ce)})]})}),(s||b)&&Xe.jsx("h1",{className:"tw:text-2xl tw:mb-4 tw:font-bold",children:A.title}),Y&&Xe.jsx("div",{className:"tw:mb-6",children:Xe.jsx(l7,{filterSchema:M.filterSchemasAndGroups,filterState:M.filterState,setFilterSchema:U,setFilterState:me,selectedView:A,geminiApiKey:t,toast:j,setShowFilterForm:ye})}),Xe.jsx(o7,{savedFilters:K,onFilterDelete:At,onFilterLoad:pt,onFilterApply:()=>re(ce=>ce+1),onFilterShare:ot,visible:we,filterSchema:M.filterSchemasAndGroups}),xe&&Xe.jsx(W4,{filterSchemasAndGroups:M.filterSchemasAndGroups,filterState:M.filterState,setFilterState:me,onSaveFilter:st,onUpdateFilter:dt,onShareFilter:Qe,savedFilters:K,visibleFilterIds:Nt,onSubmit:()=>{re(ce=>ce+1)}}),Xe.jsx(a4,{viewId:A.id,ref:ee,columns:A.columnDefinitions,data:M.data.flattenedRows,noRowsComponent:A.noRowsComponent,setFilterState:me,filterState:M.filterState,triggerRefetch:()=>re(ce=>ce+1),rowSelection:x}),M.data.rows.length>0&&Xe.jsx(QO,{onPageChange:jt,onPrevPage:Tt,hasNextPage:ie,hasPrevPage:Ie,currentPage:M.pagination.page,rowsPerPage:n,actualRows:M.data.rows.length}),L&&!b&&C0.createPortal(Xe.jsx("div",{className:"tw:fixed tw:inset-0 tw:bg-white tw:overflow-auto",children:Xe.jsx(T2,{graphqlHost:e,graphqlToken:r,geminiApiKey:t,showViewsMenu:o,rowsPerPage:n,showViewTitle:s,showCsvExportButton:p,showPopoutButton:d,viewsJson:m,externalRuntime:g,isOverlay:!0,onCloseOverlay:()=>ne(!1),syncFilterStateToUrl:O})}),document.body)]})}function I7(e,r){const t=typeof e=="string"?document.getElementById(e):e;if(!t)throw new Error("Target element not found");QS.createRoot(t).render(Xe.jsx(c.StrictMode,{children:Xe.jsx(RC,{value:{},children:Xe.jsx(T2,{graphqlHost:r.graphqlHost,graphqlToken:r.graphqlToken,geminiApiKey:r.geminiApiKey,showViewsMenu:r.showViewsMenu??!1,showViewTitle:r.showViewTitle??!1,showCsvExportButton:r.showCsvExportButton??!1,showPopoutButton:r.showPopoutButton??!0,viewsJson:r.viewsJson,externalRuntime:r.externalRuntime,syncFilterStateToUrl:r.syncFilterStateToUrl??!1,rowSelection:r.rowSelection,actions:r.actions})})}))}window.renderTableView=I7;
2105
+ }`}function s7(e,r){return typeof e=="object"&&e!==null&&r in e&&Array.isArray(e[r])}let g0=0;const C2=(e,r,t,o)=>{let n=i7(r,e.filterSchema);e.staticConditions&&e.staticConditions.length>0&&(n={_and:[n,...e.staticConditions]});const s=o!==null?{[e.paginationKey]:{_lt:o}}:{};return{conditions:n,paginationCondition:s,rowLimit:t,orderBy:[{[e.paginationKey]:"DESC"}]}},f7=async({client:e,view:r,query:t,filterState:o,rowLimit:n,cursor:s})=>{const p=++g0;try{const d=C2(r,o,n,s),m=await e.request(t,d);if(p!==g0)throw new DOMException("Request superseded by newer request","AbortError");if(!s7(m,r.collectionName))return console.error("Error fetching data, unexpected response format:",m),{rows:[],flattenedRows:[]};const g=m[r.collectionName];return{rows:g,flattenedRows:d7(g,r.columnDefinitions)}}catch(d){if(d instanceof DOMException&&d.name==="AbortError")throw d;return console.error("Error fetching data:",d),{rows:[],flattenedRows:[]}}},d7=(e,r)=>e.map(t=>r.map(o=>p7(t,o))),p7=(e,r)=>{const t={},o=n=>{if(n.type==="field"){const s=n.path.split(".");let p=e;for(const d of s)if(Array.isArray(p)){p=p.map(m=>{let g=m;for(let b=s.indexOf(d);b<s.length;b++)g=g==null?void 0:g[s[b]];return g});break}else p=p==null?void 0:p[d];t[n.path]=p}else if(n.type==="queryConfigs"){const s=n.configs.map(d=>d.field).join("."),p=(d,m)=>{if(m.length===0)return d;if(d==null)return;const[g,...b]=m;if(Array.isArray(d))return d.map(S=>p(S,m));if(typeof d=="object"&&g.field in d){const S=d[g.field];return p(S,b)}};t[s]=p(e,n.configs)}else n.type==="fieldAlias"&&(t[n.alias]=e[n.alias])};return r.data.forEach(o),t};function m7(e){return"field"in e&&"value"in e}function Lv(e){const r=[];if(m7(e))r.push(e);else if(e.type==="and"||e.type==="or")for(const t of e.filters)r.push(...Lv(t));else e.type==="not"&&r.push(...Lv(e.filter));return r}function fs(e,r,t){const{section:o,key:n}=e;if(r&&r[o]&&r[o][n]!==void 0)return r[o][n];if(t[o]&&t[o][n]!==void 0)return t[o][n];const s=r?Object.keys(r[o]||{}):[],p=Object.keys(t[o]||{}),d=[...new Set([...s,...p])];throw new Error(`Reference "${n}" not found in ${o}. Available keys: ${d.join(", ")}`)}function vs(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid RuntimeReference: Expected an object");const r=e;if(typeof r.section!="string")throw new Error('Invalid RuntimeReference: "section" must be a string');if(typeof r.key!="string")throw new Error('Invalid RuntimeReference: "key" must be a string');const t=["cellRenderers","noRowsComponents","customFilterComponents","queryTransforms","initialValues"];if(!t.includes(r.section))throw new Error(`Invalid RuntimeReference: "section" must be one of: ${t.join(", ")}`);return{section:r.section,key:r.key}}function h0(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid orderBy: Expected an object");const r=e;if(typeof r.key!="string")throw new Error('Invalid orderBy: "key" field must be a string');if(r.direction!=="ASC"&&r.direction!=="DESC")throw new Error('Invalid orderBy: "direction" field must be "ASC" or "DESC"');return{key:r.key,direction:r.direction}}function v7(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid QueryConfig: Expected an object");const r=e;if(typeof r.field!="string")throw new Error('Invalid QueryConfig: "field" must be a string');const t={field:r.field};if(r.orderBy!==void 0&&r.orderBy!==null&&(Array.isArray(r.orderBy)?t.orderBy=r.orderBy.map(h0):t.orderBy=h0(r.orderBy)),r.limit!==void 0&&r.limit!==null){if(typeof r.limit!="number"||r.limit<0||!Number.isInteger(r.limit))throw new Error('Invalid QueryConfig: "limit" must be a non-negative integer');t.limit=r.limit}if(r.path!==void 0&&r.path!==null){if(typeof r.path!="string")throw new Error('Invalid QueryConfig: "path" must be a string');t.path=r.path}return t}function x2(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid FieldQuery: Expected an object");const r=e;if(r.type==="field"){if(typeof r.path!="string")throw new Error('Invalid Field: "path" must be a string');return{type:"field",path:r.path}}else if(r.type==="queryConfigs"){if(!Array.isArray(r.configs))throw new Error('Invalid QueryConfigs: "configs" must be an array');return{type:"queryConfigs",configs:r.configs.map(v7)}}else if(r.type==="fieldAlias"){if(typeof r.alias!="string")throw new Error('Invalid FieldAlias: "alias" must be a string');if(!r.field)throw new Error('Invalid FieldAlias: "field" is required');return{type:"fieldAlias",alias:r.alias,field:x2(r.field)}}else throw new Error('Invalid FieldQuery: "type" must be "field", "queryConfigs", or "fieldAlias"')}function g7(e,r,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid JSON: Expected an object");const o=e;if(!Array.isArray(o.data))throw new Error('Invalid JSON: "data" field must be an array of FieldQuery objects');if(typeof o.name!="string")throw new Error('Invalid JSON: "name" field must be a string');if(!o.cellRenderer)throw new Error('Invalid JSON: "cellRenderer" field is required');const n=vs(o.cellRenderer);if(n.section!=="cellRenderers")throw new Error('Invalid cellRenderer: section must be "cellRenderers"');const s=o.data.map((g,b)=>{try{return x2(g)}catch(S){throw new Error(`Invalid data[${b}]: ${S instanceof Error?S.message:"Unknown error"}`)}}),p=t?Object.keys(t.cellRenderers||{}):[],d=Object.keys(r.cellRenderers||{}),m=[...new Set([...p,...d])];if(!m.includes(n.key))throw new Error(`Invalid cellRenderer reference: "${n.key}". Valid keys are: ${m.join(", ")}`);return{data:s,name:o.name,cellRenderer:n}}function h7(e){if(typeof e=="string")return e;if(typeof e=="object"&&e!==null&&!Array.isArray(e)){const r=e;if("and"in r){if(!Array.isArray(r.and))throw new Error('Invalid FilterField: "and" must be an array of strings');if(!r.and.every(t=>typeof t=="string"))throw new Error('Invalid FilterField: "and" array must contain only strings');return{and:r.and}}if("or"in r){if(!Array.isArray(r.or))throw new Error('Invalid FilterField: "or" must be an array of strings');if(!r.or.every(t=>typeof t=="string"))throw new Error('Invalid FilterField: "or" array must contain only strings');return{or:r.or}}}throw new Error('Invalid FilterField: must be a string or object with "and" or "or" arrays')}function y7(e,r,t){if(e==null)return e;let o;try{o=vs(e)}catch{return e}return o.section==="initialValues"?fs(o,t,r):e}function O2(e,r,t){if(!e||typeof e!="object"&&!Array.isArray(e))throw new Error("Invalid FilterControl: Expected an object");const o=e,n=o.initialValue!==void 0?y7(o.initialValue,r,t):void 0;if(o.type==="custom"){const s=vs(o.component);if(s.section!=="customFilterComponents")throw new Error('Invalid custom filter component: section must be "customFilterComponents"');const p=fs(s,t,r);return{...o,component:p,initialValue:n}}return o.type==="customOperator"?{...o,valueControl:O2(o.valueControl,r,t),initialValue:n}:{...o,initialValue:n}}function jv(e,r,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid FilterExpr: Expected an object");const o=e;if(typeof o.type!="string")throw new Error('Invalid FilterExpr: "type" must be a string');if(o.type==="and"||o.type==="or"){if(!Array.isArray(o.filters))throw new Error(`Invalid ${o.type} FilterExpr: "filters" must be an array`);return{type:o.type,filters:o.filters.map(m=>jv(m,r,t))}}if(o.type==="not"){if(!o.filter||typeof o.filter!="object")throw new Error('Invalid not FilterExpr: "filter" must be an object');return{type:"not",filter:jv(o.filter,r,t)}}const n=["equals","notEquals","greaterThan","lessThan","greaterThanOrEqual","lessThanOrEqual","in","notIn","like","iLike","isNull"];if(!n.includes(o.type))throw new Error(`Invalid FilterExpr type: "${o.type}". Valid types are: ${n.join(", ")}, and, or, not`);const s=h7(o.field);if(!o.value)throw new Error('Invalid FilterExpr: "value" is required');const p=O2(o.value,r,t),d={type:o.type,field:s,value:p};if(o.transform){const m=vs(o.transform);if(m.section!=="queryTransforms")throw new Error('Invalid transform: section must be "queryTransforms"');const g=fs(m,t,r);d.transform=g}return d}function b7(e,r,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid FilterFieldSchema: Expected an object");const o=e;if(!Array.isArray(o.groups))throw new Error('Invalid FilterFieldSchema: "groups" must be an array');const n=o.groups.map((p,d)=>{if(!p||typeof p!="object"||Array.isArray(p))throw new Error(`Invalid group[${d}]: Expected an object`);const m=p;if(typeof m.name!="string")throw new Error(`Invalid group[${d}]: "name" must be a string`);if(m.label!==null&&typeof m.label!="string")throw new Error(`Invalid group[${d}]: "label" must be a string or null`);return{name:m.name,label:m.label}});if(!Array.isArray(o.filters))throw new Error('Invalid FilterFieldSchema: "filters" must be an array');const s=o.filters.map((p,d)=>{if(!p||typeof p!="object"||Array.isArray(p))throw new Error(`Invalid filter[${d}]: Expected an object`);const m=p;if(typeof m.id!="string")throw new Error(`Invalid filter[${d}]: "id" must be a string`);if(typeof m.label!="string")throw new Error(`Invalid filter[${d}]: "label" must be a string`);if(typeof m.group!="string")throw new Error(`Invalid filter[${d}]: "group" must be a string`);if(typeof m.aiGenerated!="boolean")throw new Error(`Invalid filter[${d}]: "aiGenerated" must be a boolean`);if(!m.expression)throw new Error(`Invalid filter[${d}]: "expression" is required`);let g;try{g=jv(m.expression,r,t)}catch(b){throw new Error(`Invalid filter[${d}] expression: ${b instanceof Error?b.message:"Unknown error"}`)}return{id:m.id,label:m.label,expression:g,group:m.group,aiGenerated:m.aiGenerated}});return{groups:n,filters:s}}function w7(e,r,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("View JSON must be a non-null object");const o=e;if(typeof o.title!="string")throw new Error('View "title" must be a string');if(typeof o.id!="string")throw new Error('View "id" must be a string');if(typeof o.collectionName!="string")throw new Error('View "collectionName" must be a string');if(typeof o.paginationKey!="string")throw new Error('View "paginationKey" must be a string');if(typeof o.boolExpType!="string")throw new Error('View "boolExpType" must be a string');if(typeof o.orderByType!="string")throw new Error('View "orderByType" must be a string');if(!Array.isArray(o.columns))throw new Error('View "columns" must be an array');if(!o.filterSchema)throw new Error('View "filterSchema" is required');const n=o.columns.map((m,g)=>{let b;try{b=g7(m,r,t)}catch(O){throw new Error(`Invalid column[${g}]: ${O instanceof Error?O.message:"Unknown error"}`)}const S=fs(b.cellRenderer,t,r);return{data:b.data,name:b.name,cellRenderer:S}});let s;try{s=b7(o.filterSchema,r,t)}catch(m){throw new Error(`Invalid filterSchema: ${m instanceof Error?m.message:"Unknown error"}`)}let p;if(o.noRowsComponent!==void 0){const m=vs(o.noRowsComponent);if(m.section!=="noRowsComponents")throw new Error('Invalid noRowsComponent: section must be "noRowsComponents"');p=fs(m,t,r)}let d;if(o.staticConditions!==void 0){if(!Array.isArray(o.staticConditions))throw new Error('View "staticConditions" must be an array when provided');const m=o.staticConditions.findIndex(g=>typeof g!="object"||g===null||Array.isArray(g));if(m!==-1)throw new Error(`View "staticConditions" entry[${m}] must be a non-null object`);d=o.staticConditions}return{title:o.title,id:o.id,collectionName:o.collectionName,columnDefinitions:n,filterSchema:s,boolExpType:o.boolExpType,orderByType:o.orderByType,paginationKey:o.paginationKey,noRowsComponent:p,staticConditions:d}}const y0="2025-09-04T00:00:00.000Z",Uf="2025-09-19T00:00:00.000Z",Xo="dtvSavedFilters",Sm="savedFilters";function S7(e,r){if(!Array.isArray(e))return console.warn("Expected array for conversion but got:",typeof e),{};const t={};return e.forEach((o,n)=>{if(n<r.filters.length){const s=r.filters[n].id;t[s]=o}}),t}function E7(){function e(){try{if(localStorage.getItem(Xo))return!1;const p=localStorage.getItem(Sm);if(!p)return!1;console.info("Found saved filters in legacy localStorage key, migrating..."),localStorage.setItem(Xo,p),localStorage.removeItem(Sm);const d=JSON.parse(p),m=Array.isArray(d)?d.length:0;return console.info(`Migrated ${m} filters from legacy localStorage key '${Sm}' to '${Xo}'`),!0}catch(p){return console.error("Failed to migrate legacy localStorage key:",p),!1}}function r(){try{e();const p=localStorage.getItem(Xo);if(!p)return[];const d=JSON.parse(p);return Array.isArray(d)?d.map(m=>{if(typeof m!="object"||m===null)throw new Error("Invalid saved filter structure");const g=m;return{id:typeof g.id=="string"?g.id:crypto.randomUUID(),name:typeof g.name=="string"?g.name:"Unnamed Filter",view:typeof g.view=="string"?g.view:"",state:g.state,createdAt:typeof g.createdAt=="string"?g.createdAt:new Date().toISOString(),formatRevision:typeof g.formatRevision=="string"?g.formatRevision:y0}}):[]}catch(p){return console.error("Failed to load saved filters from localStorage:",p),[]}}function t(p,d){const m=r();let g=!1;const b=m.map(x=>{if(x.formatRevision===y0){g=!0;const B=S7(x.state,d);return{...x,state:B,formatRevision:Uf}}return{...x,formatRevision:Uf}}),O=b.filter(x=>x.view===p).map(x=>{const B=Uw(x.state,d);return{id:x.id,name:x.name,view:x.view,state:B,createdAt:typeof x.createdAt=="string"?new Date(x.createdAt):x.createdAt,formatRevision:Uf}});if(g)try{localStorage.setItem(Xo,JSON.stringify(b)),console.info("Migrated filters from old array format to new object format")}catch(x){console.error("Failed to save migrated filters to localStorage:",x)}return O}function o(p){const d={id:crypto.randomUUID(),createdAt:new Date,formatRevision:Uf,...p},m=r(),g={...d,createdAt:d.createdAt.toISOString(),state:vv(d.state)};return m.push(g),localStorage.setItem(Xo,JSON.stringify(m)),d}function n(p,d){const m=r(),g=m.findIndex(O=>O.id===p.id);if(g===-1)return null;const b={...p,...d},S={...m[g],name:b.name,state:d.state?vv(d.state):m[g].state};return m[g]=S,localStorage.setItem(Xo,JSON.stringify(m)),b}function s(p){const d=r(),m=d.length,g=d.filter(b=>b.id!==p);return g.length===m?!1:(localStorage.setItem(Xo,JSON.stringify(g)),!0)}return{loadFilters:t,saveFilter:o,updateFilter:n,deleteFilter:s}}const Vf=E7();function D2(e){try{const r=vv(e),t=JSON.stringify(r);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}catch(r){throw console.error("Failed to encode filter state:",r),new Error("Failed to encode filter state")}}function C7(e){try{const r=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),t=atob(r);return JSON.parse(t)}catch(r){throw console.error("Failed to decode filter state:",r),new Error("Failed to decode filter state")}}const ds="dtv-filter-state";function b0(e){try{const r=D2(e),t=new URL(window.location.href);return t.searchParams.set(ds,r),t.toString()}catch(r){throw console.error("Failed to create shareable URL:",r),new Error("Failed to create shareable URL")}}async function w0(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(e);else{const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select(),document.execCommand("copy"),document.body.removeChild(r)}}catch(r){throw console.error("Failed to copy to clipboard:",r),new Error("Failed to copy to clipboard")}}function x7(){try{const r=new URLSearchParams(window.location.search).get(ds);return r?C7(r):null}catch(e){return console.warn("Failed to parse filter from URL:",e),null}}function O7(){const e=new URL(window.location.href);e.searchParams.delete(ds),window.history.replaceState({},"",e.toString())}function D7(e){try{const r=D2(e),t=new URL(window.location.href);t.searchParams.get(ds)!==r&&(t.searchParams.set(ds,r),window.history.replaceState({},"",t.toString()))}catch(r){console.warn("Failed to set filter in URL",r)}}function T7({actions:e,selectedView:r,filterState:t,setFilterState:o,refetch:n,showToast:s,paginationState:p,rowsPerPage:d}){const[m,g]=c.useState(()=>new Set);return Xe.jsx(Xe.Fragment,{children:e.map((b,S)=>{const O=m.has(S),x=async()=>{if(O)return;g(D=>new Set(D).add(S));const B={view:r,filterState:t,setFilterState:o,refetch:n,showToast:s,generateGraphQLQueryAST:S2,renderGraphQLQuery:E2,buildGraphQLQueryVariables:C2,getPaginationState:()=>p,rowsPerPage:d};try{await b.onClick(B)}catch(D){console.error("Action handler error",D),s({severity:"error",summary:"Action Failed",detail:b.label,life:3e3})}finally{g(D=>{const H=new Set(D);return H.delete(S),H})}};return Xe.jsx(gr,{type:"button",icon:b.icon,outlined:b.outlined!==!1,size:b.size==="normal"?void 0:"small",disabled:b.disabled||O,label:O?`${b.label}...`:b.label,onClick:x,"data-testid":`dtv-action-${S}`},`custom-action-${S}`)})})}const R7=i4;function T2({graphqlHost:e,graphqlToken:r,geminiApiKey:t,showViewsMenu:o,rowsPerPage:n=20,showViewTitle:s,showCsvExportButton:p=!1,showPopoutButton:d=!0,viewsJson:m,externalRuntime:g,isOverlay:b=!1,onCloseOverlay:S,syncFilterStateToUrl:O=!1,rowSelection:x,actions:B=[]}){const D=c.useMemo(()=>JSON.parse(m).map(fe=>w7(fe,R7,g)),[m,g]),H=c.useMemo(()=>new tC(e,{headers:{contentType:"application/json",Authorization:`Bearer ${r}`}}),[e,r]),_=c.useMemo(()=>{const ce=x7();if(ce)try{const fe=D[0];return fe?Uw(ce,fe.filterSchema):void 0}catch(fe){console.warn("Invalid initial filter state from URL, falling back to defaults",fe);return}},[m]),{state:M,selectedView:A,setSelectedViewId:V,setFilterSchema:U,setFilterState:me,setDataRows:ue}=r4(D,_),ve=c.useMemo(()=>c7(A.collectionName,A.columnDefinitions,A.boolExpType,A.orderByType,A.paginationKey),[A.id]),[K,F]=c.useState([]),[z,ae]=c.useState(""),j=c.useRef(null),ee=c.useRef(null),[Y,Q]=c.useState(!1),[xe,ye]=c.useState(!1),[we,N]=c.useState(!1),[te,re]=c.useState(0),[L,ne]=c.useState(!1);c.useEffect(()=>{z&&!xe&&ye(!0)},[z,xe]),c.useEffect(()=>{if(!b&&L){const ce=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=ce}}},[L,b]),c.useEffect(()=>{if(!b)return;const ce=fe=>{fe.key==="Escape"&&(S==null||S())};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[b,S]);const ie=M.data.rows.length===n,Ie=M.pagination.page>0;c.useEffect(()=>{const ce=Vf.loadFilters(A.id,A.filterSchema);F(ce)},[A.id]),c.useEffect(()=>{var ce;_&&!O&&(O7(),(ce=j.current)==null||ce.show({severity:"info",summary:"Filter Loaded",detail:"Loaded from URL",life:3e3}))},[]),c.useEffect(()=>{O&&D7(M.filterState)},[O,te]);const st=ce=>{var nt;const fe=prompt("Enter a name for this filter:");if(!fe)return;const Ze=Vf.saveFilter({view:A.id,name:fe,state:ce});F(ut=>[...ut,Ze]),(nt=j.current)==null||nt.show({severity:"success",summary:"Filter Saved",detail:`Filter "${fe}" has been saved successfully`,life:3e3})},dt=(ce,fe)=>{y2({message:`Are you sure you want to overwrite the existing filter "${ce.name}"?`,header:"Confirm Filter Update",icon:"pi pi-exclamation-triangle",defaultFocus:"reject",acceptClassName:"p-button-danger",accept:()=>{var nt;const Ze=Vf.updateFilter(ce,{state:fe});Ze&&(F(ut=>ut.map(un=>un.id===ce.id?Ze:un)),(nt=j.current)==null||nt.show({severity:"success",summary:"Filter Updated",detail:`Filter "${ce.name}" has been updated successfully`,life:3e3}))},reject:()=>{}})},At=ce=>{var Ze;Vf.deleteFilter(ce)&&(F(nt=>nt.filter(ut=>ut.id!==ce)),(Ze=j.current)==null||Ze.show({severity:"success",summary:"Filter Deleted",detail:"Filter has been deleted successfully",life:3e3}))},Qe=async()=>{var ce,fe;try{const Ze=b0(M.filterState);await w0(Ze),(ce=j.current)==null||ce.show({severity:"success",summary:"Filter Shared",detail:"Shareable link copied to clipboard!",life:3e3})}catch(Ze){console.error("Failed to share filter:",Ze),(fe=j.current)==null||fe.show({severity:"error",summary:"Share Failed",detail:"Failed to create shareable link",life:3e3})}},ot=async ce=>{var fe,Ze;try{const nt=b0(ce);await w0(nt),(fe=j.current)==null||fe.show({severity:"success",summary:"Filter Shared",detail:"Shareable link copied to clipboard!",life:3e3})}catch(nt){console.error("Failed to share saved filter:",nt),(Ze=j.current)==null||Ze.show({severity:"error",summary:"Share Failed",detail:"Failed to create shareable link",life:3e3})}},ke=()=>{ee.current&&ee.current.exportCSV({selectionOnly:!1})},Ye=c.useCallback(ce=>f7({client:H,view:A,query:ve,filterState:M.filterState,rowLimit:n,cursor:ce}),[H,A,ve,M.filterState,n]);c.useEffect(()=>{Ye(null).then(ce=>ue(ce)).catch(ce=>{ce instanceof DOMException&&ce.name})},[M.selectedViewId,te]);const pt=ce=>{me(ce)},Nt=M.filterSchemasAndGroups.filters.flatMap(ce=>{function fe(ut){return ut.toLowerCase().includes(z.toLowerCase())}function Ze(ut){return typeof ut=="string"?fe(ut):"and"in ut?ut.and.some(un=>fe(un)):"or"in ut?ut.or.some(un=>fe(un)):!1}return fe(ce.label)?[ce.id]:Lv(ce.expression).some(ut=>Ze(ut.field))?[ce.id]:[]}),jt=async()=>{const ce=M.data.rows.length>0?M.data.rows[M.data.rows.length-1][A.paginationKey]:null;if(typeof ce!="string"&&typeof ce!="number"){console.error("Invalid cursor type:",ce);return}const fe=await Ye(ce);ue(fe,{page:M.pagination.page+1,cursors:[...M.pagination.cursors,ce]})},Tt=async()=>{if(M.pagination.page===0)return;const ce=M.pagination.cursors.slice(0,-1),fe=ce[ce.length-1]??null,Ze=await Ye(fe);ue(Ze,{page:M.pagination.page-1,cursors:ce})};return Xe.jsxs("div",{className:"tw:p-2",children:[Xe.jsx(p2,{ref:j}),Xe.jsx(b2,{}),Xe.jsx(l2,{model:[...o?[{label:"Views",icon:"pi pi-eye",items:D.map(ce=>({label:ce.title,icon:"pi pi-table",command:()=>V(ce.id)}))}]:[]],className:"tw:mb-4 tw:border-b",start:Xe.jsxs("div",{className:"tw:flex tw:gap-2 tw:items-center",children:[Xe.jsx(gr,{type:"button",icon:xe?"pi pi-filter-slash":"pi pi-filter",outlined:!0,size:"small",label:xe?"Hide Filters":"Filters",onClick:()=>{ye(ce=>{const fe=!ce;return fe||ae(""),fe})}}),Xe.jsx(gr,{type:"button",icon:"pi pi-bookmark",outlined:!0,size:"small",label:we?"Hide Saved Filters":"Saved Filters",onClick:()=>N(ce=>!ce)}),p&&Xe.jsx(gr,{type:"button",icon:"pi pi-table",outlined:!0,size:"small",label:"Export page to CSV",onClick:ke,"data-testid":"export-csv-button"}),d&&Xe.jsx(gr,{type:"button",icon:b?"pi pi-times":"pi pi-window-maximize",outlined:!0,size:"small",label:b?"Close Popout":"Popout",onClick:()=>{b?S==null||S():ne(!0)}}),Xe.jsx(T7,{actions:B,selectedView:A,filterState:M.filterState,setFilterState:me,refetch:()=>re(ce=>ce+1),showToast:ce=>{var fe;return(fe=j.current)==null?void 0:fe.show({...ce})},paginationState:M.pagination,rowsPerPage:n})]}),end:Xe.jsxs("div",{className:"tw:flex tw:gap-2",children:[Xe.jsxs(o2,{iconPosition:"left",children:[Xe.jsx(i2,{className:"pi pi-search"}),Xe.jsx(fo,{value:z,onChange:ce=>ae(ce.target.value),placeholder:"Search filters..."})]}),Xe.jsx(gr,{type:"button",size:"small",icon:"pi pi-sparkles",label:"AI Filter Assistant",onClick:()=>Q(ce=>!ce)})]})}),(s||b)&&Xe.jsx("h1",{className:"tw:text-2xl tw:mb-4 tw:font-bold",children:A.title}),Y&&Xe.jsx("div",{className:"tw:mb-6",children:Xe.jsx(l7,{filterSchema:M.filterSchemasAndGroups,filterState:M.filterState,setFilterSchema:U,setFilterState:me,selectedView:A,geminiApiKey:t,toast:j,setShowFilterForm:ye})}),Xe.jsx(o7,{savedFilters:K,onFilterDelete:At,onFilterLoad:pt,onFilterApply:()=>re(ce=>ce+1),onFilterShare:ot,visible:we,filterSchema:M.filterSchemasAndGroups}),xe&&Xe.jsx(W4,{filterSchemasAndGroups:M.filterSchemasAndGroups,filterState:M.filterState,setFilterState:me,onSaveFilter:st,onUpdateFilter:dt,onShareFilter:Qe,savedFilters:K,visibleFilterIds:Nt,onSubmit:()=>{re(ce=>ce+1)}}),Xe.jsx(a4,{viewId:A.id,ref:ee,columns:A.columnDefinitions,data:M.data.flattenedRows,noRowsComponent:A.noRowsComponent,setFilterState:me,filterState:M.filterState,triggerRefetch:()=>re(ce=>ce+1),rowSelection:x}),M.data.rows.length>0&&Xe.jsx(QO,{onPageChange:jt,onPrevPage:Tt,hasNextPage:ie,hasPrevPage:Ie,currentPage:M.pagination.page,rowsPerPage:n,actualRows:M.data.rows.length}),L&&!b&&C0.createPortal(Xe.jsx("div",{className:"tw:fixed tw:inset-0 tw:bg-white tw:overflow-auto",children:Xe.jsx(T2,{graphqlHost:e,graphqlToken:r,geminiApiKey:t,showViewsMenu:o,rowsPerPage:n,showViewTitle:s,showCsvExportButton:p,showPopoutButton:d,viewsJson:m,externalRuntime:g,isOverlay:!0,onCloseOverlay:()=>ne(!1),syncFilterStateToUrl:O,rowSelection:x})}),document.body)]})}function I7(e,r){const t=typeof e=="string"?document.getElementById(e):e;if(!t)throw new Error("Target element not found");QS.createRoot(t).render(Xe.jsx(c.StrictMode,{children:Xe.jsx(RC,{value:{},children:Xe.jsx(T2,{graphqlHost:r.graphqlHost,graphqlToken:r.graphqlToken,geminiApiKey:r.geminiApiKey,showViewsMenu:r.showViewsMenu??!1,showViewTitle:r.showViewTitle??!1,showCsvExportButton:r.showCsvExportButton??!1,showPopoutButton:r.showPopoutButton??!0,viewsJson:r.viewsJson,externalRuntime:r.externalRuntime,syncFilterStateToUrl:r.syncFilterStateToUrl??!1,rowSelection:r.rowSelection,actions:r.actions})})}))}window.renderTableView=I7;