@mohsinonxrm/pptb-fetchxml-studio 1.5.0-beta.12 → 1.5.0-beta.13
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/CHANGELOG.md +13 -0
- package/README.md +3 -3
- package/SECURITY.md +11 -0
- package/dist/assets/{index-CaYaZM-I.js → index-94JqCXrW.js} +12 -12
- package/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -58,26 +58,26 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
58
58
|
*Self-closing element*`}]}}if(s.match(new RegExp(`(${n.word})\\s*=`))){const c=B_(r,t);if(c.element){const l=Yl.elements[c.element];if(l){const a=l.attributes[n.word];if(a){const u=[{value:`**${n.word}**`},{value:a.description}];return"values"in a&&a.values&&u.push({value:`
|
|
59
59
|
**Valid values:** ${a.values.join(", ")}`}),"type"in a&&a.type&&u.push({value:`
|
|
60
60
|
**Type:** ${a.type}`}),"required"in a&&a.required&&u.push({value:`
|
|
61
|
-
*Required attribute*`}),{contents:u}}}}}return null}})}function Kee(e){const r=el(e);return r.success&&r.fetchNode?ya(r.fetchNode):null}const T5="The tree changed while you were editing",Yee=wr({container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},toolbar:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 8px",borderBottom:`1px solid ${le.colorNeutralStroke1}`,backgroundColor:le.colorNeutralBackground2,flexShrink:0},toolbarLeft:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},toolbarRight:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},editorWrapper:{flex:1,overflow:"hidden",minHeight:0},loadingContainer:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",backgroundColor:le.colorNeutralBackground1},messageBarContainer:{padding:le.spacingVerticalS,borderTop:`1px solid ${le.colorNeutralStroke1}`,maxHeight:"150px",overflowY:"auto",flexShrink:0},switchLabel:{fontSize:le.fontSizeBase200,fontWeight:le.fontWeightSemibold}}),wu="Invalid FetchXML",B5="Dataverse might reject this query";function Qee({xml:e,onParseToTree:r,onEditorStateChange:t,replaceRequest:n}){const s=Yee(),{isDark:o}=e1(),i=A.useRef(null),c=A.useRef(null),l=A.useRef(0),[a,u]=A.useState(!1),[h,d]=A.useState(""),[f,m]=A.useState([]),[p,g]=A.useState(null),b=a?h:e,y=A.useCallback((_,S,T)=>{const z={id:l.current++,intent:_,title:S,body:T};m(P=>[z,...P].slice(0,5))},[]),w=A.useCallback(_=>{m(S=>S.filter(T=>T.id!==_))},[]),C=A.useCallback(()=>{m([])},[]),N=A.useRef(e);A.useEffect(()=>{if(!a){N.current=e;return}if(e===N.current)return;const _=Kee(h);if(_===e){N.current=e;return}if(_!==null&&_===N.current){N.current=e,d(e),t?.(!0,e);return}N.current=e,m(S=>S.some(T=>T.title===T5)?S:[{id:l.current++,intent:"warning",title:T5,body:"Execute, Save and Send to tool use the editor's FetchXML and will replace the tree's changes. Use Reset to take the tree's FetchXML instead."},...S].slice(0,5))},[e,a]),A.useEffect(()=>{!n||!a||(d(n.xml),t?.(!0,n.xml),y("info","Editor updated","The editor now shows the FetchXML that was loaded into the tree, with the changes you confirmed."))},[n?.id]);const I=A.useCallback(_=>{_?(d(e),C(),t?.(!0,e)):t?.(!1,""),u(_)},[e,C,t]),$=A.useCallback(async()=>{await ws(b)?y("success","Copied","FetchXML copied to clipboard"):y("error","Copy failed","Could not copy to clipboard")},[b,y]),D=A.useCallback(async()=>{try{const _=await navigator.clipboard.readText();_.trim()&&(d(_),t?.(!0,_),y("info","Pasted","Content pasted from clipboard"))}catch(_){console.error("Failed to paste:",_),y("error","Paste failed","Could not read from clipboard")}},[y,t]),F=A.useCallback(()=>{c.current?.click()},[]),V=A.useCallback(_=>{const S=_.target.files?.[0];if(S){const T=new FileReader;T.onload=z=>{const P=z.target?.result;d(P),t?.(!0,P),y("info","File loaded",`Loaded ${S.name}`)},T.onerror=()=>{y("error","Load failed","Could not read file")},T.readAsText(S)}_.target.value=""},[y,t]),G=A.useCallback(()=>{d(e),t?.(!0,e),C(),y("info","Reset","Reverted to tree-generated FetchXML")},[e,C,y,t]),U=A.useCallback(()=>{C();const _=U8(h);if(!_.valid){y("error","Syntax error",_.error||"Invalid XML syntax");return}const S=el(h);if(!S.success){y("error",wu,S.errors);return}const T=S.warnings.filter(O=>O.severity==="info"),z=$8(S),P=ob(S);T.length>0&&y("info","Notes",T),z.length>0&&y("warning",B5,z),P.length>0&&y("error",wu,P),z.length===0&&P.length===0&&y("success","Valid","Dataverse should accept this FetchXML.")},[h,C,y]),E=A.useCallback((_,S)=>{if(!r)return;C();const T=r(_);if(!T.success){y("error",wu,T.errors);return}const z=new Set(Nh(T)),P=T.warnings.filter(J=>J.kind==="invalid"),O=P.filter(J=>J.severity==="error"),X=P.filter(J=>J.severity==="warning"),K=T.warnings.filter(J=>J.severity==="info"&&!(S&&z.has(J)));K.length>0&&y("info","Notes",K),X.length>0&&y("warning",B5,X),O.length>0&&y("error",wu,O),y("success","Parsed into the tree","The FetchXML was loaded into the tree builder."),t?.(!1,""),u(!1)},[r,C,y,t]),M=A.useCallback(()=>{if(!r)return;const _=el(h);if(!_.success){C(),y("error",wu,_.errors);return}const S=Nh(_);if(S.length>0){g({xml:h,changes:S});return}E(h,!1)},[h,r,C,y,E]),B=A.useCallback(()=>{if(!p)return;const{xml:_}=p;g(null),E(_,!0)},[p,E]),k=A.useCallback((_,S)=>{i.current=_,Xee(S),Gee(S)},[]);return j.jsxs("div",{className:s.container,children:[j.jsxs("div",{className:s.toolbar,children:[j.jsx("div",{className:s.toolbarLeft,children:a?j.jsxs(Bc,{size:"small",children:[j.jsx(Or,{content:"Copy FetchXML to clipboard",relationship:"label",children:j.jsx(Wn,{icon:j.jsx(E0,{}),onClick:$,children:"Copy"})}),j.jsx(Or,{content:"Paste from clipboard",relationship:"label",children:j.jsx(Wn,{icon:j.jsx(qR,{}),onClick:D,children:"Paste"})}),j.jsx(Or,{content:"Load from file",relationship:"label",children:j.jsx(Wn,{icon:j.jsx(HR,{}),onClick:F,children:"Load"})}),j.jsx(Or,{content:"Reset to tree-generated XML",relationship:"label",children:j.jsx(Wn,{icon:j.jsx(kR,{}),onClick:G,children:"Reset"})}),j.jsx(Si,{}),j.jsx(Or,{content:"Validate FetchXML syntax",relationship:"label",children:j.jsx(Wn,{icon:j.jsx(NR,{}),onClick:U,children:"Validate"})}),j.jsx(Or,{content:"Parse FetchXML into tree builder",relationship:"label",children:j.jsx(Wn,{icon:j.jsx(bR,{}),onClick:M,disabled:!r,children:"Parse to tree"})})]}):j.jsx(Or,{content:"Copy FetchXML to clipboard",relationship:"label",children:j.jsx(St,{appearance:"subtle",icon:j.jsx(E0,{}),onClick:$,children:"Copy"})})}),j.jsx("div",{className:s.toolbarRight,children:j.jsx(Qs,{checked:a,onChange:(_,S)=>I(S.checked),label:j.jsx("span",{className:s.switchLabel,children:"Editor mode"}),labelPosition:"before"})})]}),j.jsx("input",{ref:c,type:"file",accept:".xml,.fetchxml,.txt",style:{display:"none"},onChange:V}),j.jsx("div",{className:s.editorWrapper,children:j.jsx(Jv,{height:"100%",language:"xml",theme:o?"vs-dark":"vs",value:b,onChange:a?_=>{d(_||""),t?.(!0,_||"")}:void 0,loading:j.jsx("div",{className:s.loadingContainer,children:j.jsx(hn,{size:"medium",label:"Loading editor…"})}),options:{readOnly:!a,minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",folding:!0,wordWrap:"on",automaticLayout:!0,fontFamily:"Consolas, 'Courier New', monospace",fontSize:13},onMount:k})}),f.length>0&&j.jsx("div",{className:s.messageBarContainer,children:j.jsx(f8,{animate:"both",children:f.map(_=>j.jsxs(Ar,{intent:_.intent,shape:"rounded",layout:typeof _.body=="string"?"auto":"multiline",children:[j.jsxs(Rr,{children:[j.jsx(Hr,{children:_.title}),typeof _.body=="string"?_.body:j.jsx(rl,{items:_.body})]}),j.jsx(Fs,{containerAction:j.jsx(St,{onClick:()=>w(_.id),"aria-label":"dismiss",appearance:"transparent",icon:j.jsx(np,{}),size:"small"})})]},_.id))})}),j.jsx(T_,{action:p?"parse":null,changes:p?.changes??[],onConfirm:B,onCancel:()=>g(null)})]})}const Zee={"csharp-fetchexpr":"C# FetchExpression",javascript:"JavaScript",pac:"pac CLI",powerautomate:"Power Automate",webapi:"Web API"},Jee={"csharp-fetchexpr":"csharp",javascript:"javascript",pac:"shell",powerautomate:"xml",webapi:"plaintext"};function ete(e,r,t,n){switch(e){case"csharp-fetchexpr":return tte(r);case"javascript":return rte(r);case"pac":return
|
|
61
|
+
*Required attribute*`}),{contents:u}}}}}return null}})}function Kee(e){const r=el(e);return r.success&&r.fetchNode?ya(r.fetchNode):null}const T5="The tree changed while you were editing",Yee=wr({container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},toolbar:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 8px",borderBottom:`1px solid ${le.colorNeutralStroke1}`,backgroundColor:le.colorNeutralBackground2,flexShrink:0},toolbarLeft:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},toolbarRight:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},editorWrapper:{flex:1,overflow:"hidden",minHeight:0},loadingContainer:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",backgroundColor:le.colorNeutralBackground1},messageBarContainer:{padding:le.spacingVerticalS,borderTop:`1px solid ${le.colorNeutralStroke1}`,maxHeight:"150px",overflowY:"auto",flexShrink:0},switchLabel:{fontSize:le.fontSizeBase200,fontWeight:le.fontWeightSemibold}}),wu="Invalid FetchXML",B5="Dataverse might reject this query";function Qee({xml:e,onParseToTree:r,onEditorStateChange:t,replaceRequest:n}){const s=Yee(),{isDark:o}=e1(),i=A.useRef(null),c=A.useRef(null),l=A.useRef(0),[a,u]=A.useState(!1),[h,d]=A.useState(""),[f,m]=A.useState([]),[p,g]=A.useState(null),b=a?h:e,y=A.useCallback((_,S,T)=>{const z={id:l.current++,intent:_,title:S,body:T};m(P=>[z,...P].slice(0,5))},[]),w=A.useCallback(_=>{m(S=>S.filter(T=>T.id!==_))},[]),C=A.useCallback(()=>{m([])},[]),N=A.useRef(e);A.useEffect(()=>{if(!a){N.current=e;return}if(e===N.current)return;const _=Kee(h);if(_===e){N.current=e;return}if(_!==null&&_===N.current){N.current=e,d(e),t?.(!0,e);return}N.current=e,m(S=>S.some(T=>T.title===T5)?S:[{id:l.current++,intent:"warning",title:T5,body:"Execute, Save and Send to tool use the editor's FetchXML and will replace the tree's changes. Use Reset to take the tree's FetchXML instead."},...S].slice(0,5))},[e,a]),A.useEffect(()=>{!n||!a||(d(n.xml),t?.(!0,n.xml),y("info","Editor updated","The editor now shows the FetchXML that was loaded into the tree, with the changes you confirmed."))},[n?.id]);const I=A.useCallback(_=>{_?(d(e),C(),t?.(!0,e)):t?.(!1,""),u(_)},[e,C,t]),$=A.useCallback(async()=>{await ws(b)?y("success","Copied","FetchXML copied to clipboard"):y("error","Copy failed","Could not copy to clipboard")},[b,y]),D=A.useCallback(async()=>{try{const _=await navigator.clipboard.readText();_.trim()&&(d(_),t?.(!0,_),y("info","Pasted","Content pasted from clipboard"))}catch(_){console.error("Failed to paste:",_),y("error","Paste failed","Could not read from clipboard")}},[y,t]),F=A.useCallback(()=>{c.current?.click()},[]),V=A.useCallback(_=>{const S=_.target.files?.[0];if(S){const T=new FileReader;T.onload=z=>{const P=z.target?.result;d(P),t?.(!0,P),y("info","File loaded",`Loaded ${S.name}`)},T.onerror=()=>{y("error","Load failed","Could not read file")},T.readAsText(S)}_.target.value=""},[y,t]),G=A.useCallback(()=>{d(e),t?.(!0,e),C(),y("info","Reset","Reverted to tree-generated FetchXML")},[e,C,y,t]),U=A.useCallback(()=>{C();const _=U8(h);if(!_.valid){y("error","Syntax error",_.error||"Invalid XML syntax");return}const S=el(h);if(!S.success){y("error",wu,S.errors);return}const T=S.warnings.filter(O=>O.severity==="info"),z=$8(S),P=ob(S);T.length>0&&y("info","Notes",T),z.length>0&&y("warning",B5,z),P.length>0&&y("error",wu,P),z.length===0&&P.length===0&&y("success","Valid","Dataverse should accept this FetchXML.")},[h,C,y]),E=A.useCallback((_,S)=>{if(!r)return;C();const T=r(_);if(!T.success){y("error",wu,T.errors);return}const z=new Set(Nh(T)),P=T.warnings.filter(J=>J.kind==="invalid"),O=P.filter(J=>J.severity==="error"),X=P.filter(J=>J.severity==="warning"),K=T.warnings.filter(J=>J.severity==="info"&&!(S&&z.has(J)));K.length>0&&y("info","Notes",K),X.length>0&&y("warning",B5,X),O.length>0&&y("error",wu,O),y("success","Parsed into the tree","The FetchXML was loaded into the tree builder."),t?.(!1,""),u(!1)},[r,C,y,t]),M=A.useCallback(()=>{if(!r)return;const _=el(h);if(!_.success){C(),y("error",wu,_.errors);return}const S=Nh(_);if(S.length>0){g({xml:h,changes:S});return}E(h,!1)},[h,r,C,y,E]),B=A.useCallback(()=>{if(!p)return;const{xml:_}=p;g(null),E(_,!0)},[p,E]),k=A.useCallback((_,S)=>{i.current=_,Xee(S),Gee(S)},[]);return j.jsxs("div",{className:s.container,children:[j.jsxs("div",{className:s.toolbar,children:[j.jsx("div",{className:s.toolbarLeft,children:a?j.jsxs(Bc,{size:"small",children:[j.jsx(Or,{content:"Copy FetchXML to clipboard",relationship:"label",children:j.jsx(Wn,{icon:j.jsx(E0,{}),onClick:$,children:"Copy"})}),j.jsx(Or,{content:"Paste from clipboard",relationship:"label",children:j.jsx(Wn,{icon:j.jsx(qR,{}),onClick:D,children:"Paste"})}),j.jsx(Or,{content:"Load from file",relationship:"label",children:j.jsx(Wn,{icon:j.jsx(HR,{}),onClick:F,children:"Load"})}),j.jsx(Or,{content:"Reset to tree-generated XML",relationship:"label",children:j.jsx(Wn,{icon:j.jsx(kR,{}),onClick:G,children:"Reset"})}),j.jsx(Si,{}),j.jsx(Or,{content:"Validate FetchXML syntax",relationship:"label",children:j.jsx(Wn,{icon:j.jsx(NR,{}),onClick:U,children:"Validate"})}),j.jsx(Or,{content:"Parse FetchXML into tree builder",relationship:"label",children:j.jsx(Wn,{icon:j.jsx(bR,{}),onClick:M,disabled:!r,children:"Parse to tree"})})]}):j.jsx(Or,{content:"Copy FetchXML to clipboard",relationship:"label",children:j.jsx(St,{appearance:"subtle",icon:j.jsx(E0,{}),onClick:$,children:"Copy"})})}),j.jsx("div",{className:s.toolbarRight,children:j.jsx(Qs,{checked:a,onChange:(_,S)=>I(S.checked),label:j.jsx("span",{className:s.switchLabel,children:"Editor mode"}),labelPosition:"before"})})]}),j.jsx("input",{ref:c,type:"file",accept:".xml,.fetchxml,.txt",style:{display:"none"},onChange:V}),j.jsx("div",{className:s.editorWrapper,children:j.jsx(Jv,{height:"100%",language:"xml",theme:o?"vs-dark":"vs",value:b,onChange:a?_=>{d(_||""),t?.(!0,_||"")}:void 0,loading:j.jsx("div",{className:s.loadingContainer,children:j.jsx(hn,{size:"medium",label:"Loading editor…"})}),options:{readOnly:!a,minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",folding:!0,wordWrap:"on",automaticLayout:!0,fontFamily:"Consolas, 'Courier New', monospace",fontSize:13},onMount:k})}),f.length>0&&j.jsx("div",{className:s.messageBarContainer,children:j.jsx(f8,{animate:"both",children:f.map(_=>j.jsxs(Ar,{intent:_.intent,shape:"rounded",layout:typeof _.body=="string"?"auto":"multiline",children:[j.jsxs(Rr,{children:[j.jsx(Hr,{children:_.title}),typeof _.body=="string"?_.body:j.jsx(rl,{items:_.body})]}),j.jsx(Fs,{containerAction:j.jsx(St,{onClick:()=>w(_.id),"aria-label":"dismiss",appearance:"transparent",icon:j.jsx(np,{}),size:"small"})})]},_.id))})}),j.jsx(T_,{action:p?"parse":null,changes:p?.changes??[],onConfirm:B,onCancel:()=>g(null)})]})}const Zee={"csharp-fetchexpr":"C# FetchExpression",javascript:"JavaScript",pac:"pac CLI",powerautomate:"Power Automate",webapi:"Web API"},Jee={"csharp-fetchexpr":"csharp",javascript:"javascript",pac:"shell",powerautomate:"xml",webapi:"plaintext"};function ete(e,r,t,n){switch(e){case"csharp-fetchexpr":return tte(r);case"javascript":return rte(r);case"pac":return ate(r);case"powerautomate":return r.trim();case"webapi":return lte(r,n,t)}}function tte(e){const r=e.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return["// Generated by FetchXML Studio — Code Generation Panel","// Requires: Microsoft.PowerPlatform.Dataverse.Client or Microsoft.CrmSdk.CoreAssemblies","",`var fetchXml = ${e.includes(`
|
|
62
62
|
`)?`@"
|
|
63
63
|
${e.replace(/"/g,'""')}
|
|
64
64
|
"`:`"${r}"`};`,"","var query = new FetchExpression(fetchXml);","var results = service.RetrieveMultiple(query);","","foreach (var entity in results.Entities)","{",' // Access attributes: entity["attributename"]',"}"].join(`
|
|
65
65
|
`)}function rte(e){const r=e.match(/<fetch[^>]*>[\s\S]*?<entity\s+name=["']([^"']+)["']/i),t=r?r[1]:"entity_logical_name";return["// Generated by FetchXML Studio — Code Generation Panel","// Works in Power Apps model-driven app JS / PCF / Dataverse WebAPI","",`const fetchXml = \`${nte(e)}\`;`,"",`Xrm.WebApi.retrieveMultipleRecords("${t}", "?fetchXml=" + encodeURIComponent(fetchXml))`," .then(function (result) {"," result.entities.forEach(function (record) {",' // Access: record["attribute_name"]'," });"," })"," .catch(function (error) {"," console.error(error.message);"," });"].join(`
|
|
66
|
-
`)}function nte(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function ote(e){return["# Generated by FetchXML Studio — Code Generation Panel","# Requires: Power Platform CLI (pac)","# Docs: https://learn.microsoft.com/
|
|
67
|
-
`)}function
|
|
68
|
-
`)}function j_(e){const r=e.match(/<entity\s+name=["']([^"']+)["']/i);if(!r)return"records";const t=r[1];return{opportunity:"opportunities",activity:"activities",category:"categories",territory:"territories",currency:"transactioncurrencies",systemuser:"systemusers",businessunit:"businessunits",team:"teams"}[t]??`${t}s`}const
|
|
69
|
-
`);return j.jsxs("div",{children:[j.jsxs("div",{style:{marginBottom:16,display:"flex",alignItems:"baseline",gap:12,flexWrap:"wrap"},children:[j.jsx(vR,{style:{color:le.colorBrandForeground1,marginTop:6}}),j.jsx(gL,{style:{fontFamily:le.fontFamilyBase},children:e.actionName}),j.jsxs(kv,{style:{color:le.colorNeutralForeground3},children:["· ",e.connector]}),j.jsx("span",{style:{flexGrow:1}}),j.jsxs(ri,{appearance:"ghost",children:[t," of ",e.fields.length," populated"]}),j.jsx(Or,{content:"Copy every populated field as one block",relationship:"description",children:j.jsx(St,{size:"small",appearance:"outline",icon:j.jsx(wc,{}),onClick:()=>{ws(n)},children:"Copy all"})})]}),e.banner&&j.jsx(Ar,{layout:"multiline",intent:"info",style:{marginBottom:14},children:j.jsx(Rr,{children:e.banner})}),j.jsx(yL,{style:{display:"block",marginBottom:10,color:le.colorNeutralForeground2},children:e.actionName}),j.jsx("div",{children:e.fields.map(s=>j.jsx(
|
|
70
|
-
`)}function t1(e){if(e.AttributeExpressions&&e.AttributeExpressions.length>0){const t=["ColumnSet = new ColumnSet(false)"];t.push("{"),t.push(" AttributeExpressions ="),t.push(" {");for(const n of e.AttributeExpressions){const s=nl(n.AggregateType??0,fte,"None"),i=n.DateTimeGrouping!=null&&n.DateTimeGrouping!==0&&n.DateTimeGrouping!=="None"?`, XrmDateTimeGrouping.${nl(n.DateTimeGrouping,hte,"None")}`:"",c=n.Alias?`, "${n.Alias}"`:"",l=n.HasGroupBy?", hasGroupBy: true":"";t.push(` new XrmAttributeExpression("${n.AttributeName}", XrmAggregateType.${s}${c}${i}${l}),`)}return t.push(" },"),t.push("},"),t}return e.AllColumns?["ColumnSet = new ColumnSet(true),"]:!e.Columns||e.Columns.length===0?["ColumnSet = new ColumnSet(false),"]:[`ColumnSet = new ColumnSet(${e.Columns.map(t=>`"${t}"`).join(", ")}),`]}function r1(e){const r=["Criteria ="];return r.push(...E_(e)),xte(r),r}function E_(e,r=0){const t=nl(e.FilterOperator,ute,"And"),n=[];n.push(`new FilterExpression(LogicalOperator.${t})`),n.push("{");const s=e.Conditions&&e.Conditions.length>0,o=e.Filters&&e.Filters.length>0,i=e.AnyAllFilterLinkEntity!=null;if(s){n.push(" Conditions ="),n.push(" {");for(const c of e.Conditions)n.push(...Jn(gte(c),2));n.push(" },")}if(o){n.push(" Filters ="),n.push(" {");for(const c of e.Filters){const l=E_(c,r+1);n.push(...Jn(l,2)),z_(n)}n.push(" },")}return i&&n.push(...Jn(bte(e.AnyAllFilterLinkEntity))),n.push("}"),n}function gte(e){const r=nl(e.Operator,pte,`/* ConditionOperator(${e.Operator}) */`),t=e.EntityName?`"${e.EntityName}", `:"",n=new Set(["Null","NotNull"]),s=new Set([12,13]),o=new Set(["Yesterday","Today","Tomorrow","Last7Days","Next7Days","LastWeek","ThisWeek","NextWeek","LastMonth","ThisMonth","NextMonth","LastYear","ThisYear","NextYear","EqualUserId","NotEqualUserId","EqualBusinessId","NotEqualBusinessId","EqualUserLanguage"]),i=new Set([14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,47,48,49,50,57]),c=n.has(r)||typeof e.Operator=="number"&&s.has(e.Operator),l=o.has(r)||typeof e.Operator=="number"&&i.has(e.Operator),a=e.Values&&e.Values.length>0;if(c||l||!a)return[`new ConditionExpression(${t}"${e.AttributeName}", ConditionOperator.${r}),`];const u=new Set(["In","NotIn","Between","NotBetween","ContainValues","DoesNotContainValues"]),h=new Set([8,9,10,11,71,72]),d=u.has(r)||typeof e.Operator=="number"&&h.has(e.Operator),f=e.Values;if(e.CompareColumns){const m=f.map(p=>`"${p}"`).join(", ");return[`new ConditionExpression(${t}"${e.AttributeName}", ConditionOperator.${r}, compareColumns: true, ${m}),`]}if(d&&f.length>1){const m=f.map(j5).join(", ");return[`new ConditionExpression(${t}"${e.AttributeName}", ConditionOperator.${r}, ${m}),`]}return f.length===1?[`new ConditionExpression(${t}"${e.AttributeName}", ConditionOperator.${r}, ${j5(f[0])}),`]:[`new ConditionExpression(${t}"${e.AttributeName}", ConditionOperator.${r}),`]}function bte(e){const r=nl(e.JoinOperator,N_,"Inner"),t=["AnyAllFilterLinkEntity = new LinkEntity",` ("${e.LinkFromEntityName}", "${e.LinkToEntityName}", "${e.LinkFromAttributeName}", "${e.LinkToAttributeName}", JoinOperator.${r})`,"{"];return e.EntityAlias&&t.push(` EntityAlias = "${e.EntityAlias}",`),e.Columns&&t.push(...Jn(t1(e.Columns))),e.LinkCriteria&&n1(e.LinkCriteria)&&t.push(...Jn(r1(e.LinkCriteria))),t.push("},"),t}function A_(e){const r=["LinkEntities =","{"];for(const t of e)r.push(...Jn(vte(t))),z_(r);return r.push("},"),r}function vte(e){const r=nl(e.JoinOperator??0,N_,"Inner"),t=[`new LinkEntity("${e.LinkFromEntityName}", "${e.LinkToEntityName}", "${e.LinkFromAttributeName}", "${e.LinkToAttributeName}", JoinOperator.${r})`,"{"];return e.EntityAlias&&t.push(` EntityAlias = "${e.EntityAlias}",`),e.Columns&&t.push(...Jn(t1(e.Columns))),e.LinkCriteria&&n1(e.LinkCriteria)&&t.push(...Jn(r1(e.LinkCriteria))),e.LinkEntities&&e.LinkEntities.length>0&&t.push(...Jn(A_(e.LinkEntities))),e.Orders&&e.Orders.length>0&&t.push(...Jn(R_(e.Orders))),t.push("}"),t}function R_(e){const r=["Orders =","{"];for(const t of e)r.push(...Jn(yte(t)));return r.push("},"),r}function yte(e){const r=nl(e.OrderType??0,dte,"Ascending"),t=e.EntityName?`, "${e.EntityName}"`:"",n=e.Alias?`, "${e.Alias}"`:"";return[`new OrderExpression("${e.AttributeName}", OrderType.${r}${t}${n}),`]}function Jn(e,r=1){const t=" ".repeat(r);return e.map(n=>n.length>0?t+n:n)}function nl(e,r,t){return e==null?t:typeof e=="string"?e:r[e]??t}function wte(e){if(e==null||typeof e!="object")return e;const r=e,t=Object.keys(r).filter(n=>!n.startsWith("@"));return"value"in r&&t.length<=1?r.value:"Value"in r&&t.length<=1||"Value"in r&&"Type"in r&&t.length===2?r.Value:e}function j5(e){const r=wte(e);return r==null?"null":typeof r=="boolean"?r?"true":"false":typeof r=="number"?String(r):typeof r=="string"?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)?`new Guid("${r}")`:/^-?\d+(\.\d+)?$/.test(r)?r:`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`/* ${JSON.stringify(r)} */`}function n1(e){return e.Conditions!=null&&e.Conditions.length>0||e.Filters!=null&&e.Filters.length>0||e.AnyAllFilterLinkEntity!=null}function z_(e){for(let r=e.length-1;r>=0;r--)if(e[r].trim().length>0){e[r].endsWith(",")||(e[r]=e[r]+",");break}}function xte(e,r){for(let t=e.length-1;t>=0;t--)if(e[t].trim().length>0){e[t]=e[t].replace(/,\s*$/,""),e[t]=e[t]+",";break}}const kte=wr({root:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:`1px solid ${le.colorNeutralStroke2}`,paddingLeft:"8px",paddingRight:"8px",paddingTop:"4px",paddingBottom:"4px",flexShrink:0,backgroundColor:le.colorNeutralBackground2},tabListWrap:{display:"flex",alignItems:"center",gap:"4px",flexWrap:"wrap"},tabLabel:{display:"flex",alignItems:"center",gap:"4px"},copyButton:{flexShrink:0},body:{flex:1,overflow:"hidden",position:"relative"},paPane:{height:"100%",overflowY:"auto",padding:"16px",boxSizing:"border-box"},centerBox:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"12px",padding:"24px"},offlineText:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200,textAlign:"center",maxWidth:"320px"},messagePad:{padding:"12px"}}),Ste=["csharp-fetchexpr","csharp-queryexpr","sql","javascript","pac","powerautomate","webapi"],_te={...Zee,"csharp-queryexpr":"C# QueryExpression",sql:"SQL"},Cte={...Jee,"csharp-queryexpr":"csharp",sql:"sql"};function Tte({fetchXml:e}){const r=kte(),{isDark:t}=e1(),{connected:n,environmentUrl:s}=N8(),[o,i]=A.useState("csharp-fetchexpr"),[c,l]=A.useState(!1),[a,u]=A.useState(""),[h,d]=A.useState(!1),[f,m]=A.useState(null),[p,g]=A.useState(""),[b,y]=A.useState(!1),[w,C]=A.useState(null),[N,I]=A.useState(void 0),$=A.useRef({cancelled:!1});A.useEffect(()=>{$.current.cancelled=!0;const _={cancelled:!1};if($.current=_,!e||!n){u(""),m(null),g(""),C(null),I(void 0);return}const S=e.match(/entity\s+name=["']([^"']+)["']/i);S&&hc(S[1]).then(T=>{_.cancelled||I(T.EntitySetName)}).catch(()=>{}),d(!0),m(null),y(!0),C(null),Kv(e).then(T=>{if(_.cancelled)return;const z=mte(T);u(z)}).catch(T=>{_.cancelled||(m(T instanceof Error?T.message:String(T)),u(""))}).finally(()=>{_.cancelled||d(!1)}),zZ(e).then(T=>{_.cancelled||g(T)}).catch(T=>{_.cancelled||(C(T instanceof Error?T.message:String(T)),g(""))}).finally(()=>{_.cancelled||y(!1)})},[e,n]);const D=(_,S)=>{i(S.value)},F=A.useCallback(()=>{switch(o){case"csharp-queryexpr":return a;case"sql":return p;default:return ete(o,e,o==="webapi"?N:void 0,s)}},[o,e,a,p,s,N]),V=A.useCallback(()=>{const _=F();_&&ws(_).then(S=>{S&&(l(!0),setTimeout(()=>l(!1),1500))})},[F]),G=o==="csharp-queryexpr"&&h||o==="sql"&&b,U=o==="csharp-queryexpr"?f:o==="sql"?w:null,E=(o==="csharp-queryexpr"||o==="sql")&&!n,M=F(),B=t?"vs-dark":"light",k=Cte[o];return j.jsxs("div",{className:r.root,children:[j.jsxs("div",{className:r.header,children:[j.jsx("div",{className:r.tabListWrap,children:j.jsx(hp,{size:"small",appearance:"subtle",selectedValue:o,onTabSelect:D,children:Ste.map(_=>j.jsx(Za,{value:_,children:j.jsxs("span",{className:r.tabLabel,children:[_te[_],_==="sql"&&j.jsx(Or,{content:"Undocumented API — may change without notice",relationship:"label",children:j.jsx(ri,{size:"small",appearance:"tint",color:"warning",style:{cursor:"default"},children:"Preview"})}),(_==="csharp-queryexpr"||_==="sql")&&!n&&j.jsx(Or,{content:"Connect to an environment to generate",relationship:"label",children:j.jsx(ph,{style:{opacity:.5,width:14,height:14}})})]})},_))})}),j.jsx(Or,{content:o==="powerautomate"?"Use the per-field Copy buttons below":c?"Copied!":"Copy to clipboard",relationship:"label",children:j.jsx(St,{appearance:"subtle",size:"small",icon:j.jsx(wc,{}),className:r.copyButton,onClick:V,disabled:G||E||!M||o==="powerautomate","aria-label":"Copy code to clipboard",children:c?"Copied!":"Copy"})})]}),j.jsxs("div",{className:r.body,children:[G&&j.jsx("div",{className:r.centerBox,children:j.jsx(hn,{size:"medium",label:"Generating…"})}),!G&&U&&j.jsx("div",{className:r.messagePad,children:j.jsx(Ar,{intent:"error",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Generation failed"}),U]})})}),!G&&E&&j.jsxs("div",{className:r.centerBox,children:[j.jsx(ph,{style:{opacity:.4,width:32,height:32}}),j.jsxs("p",{className:r.offlineText,children:["Connect to a Dataverse environment to generate"," ",o==="csharp-queryexpr"?"C# QueryExpression":"SQL"," code."]})]}),!G&&!U&&!E&&o==="powerautomate"&&j.jsx("div",{className:r.paPane,children:j.jsx(lte,{spec:ite(e,N)})}),!G&&!U&&!E&&o!=="powerautomate"&&j.jsx(Jv,{height:"100%",language:k,value:M,theme:B,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:o==="webapi"?"on":"off",fontSize:13,lineNumbers:"on",renderLineHighlight:"none",folding:!0,automaticLayout:!0}})]})]})}const Bte=wr({container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},toolbar:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 8px",borderBottom:`1px solid ${le.colorNeutralStroke1}`,backgroundColor:le.colorNeutralBackground2,flexShrink:0},toolbarLeft:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},toolbarRight:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},editorWrapper:{flex:1,overflow:"hidden",minHeight:0},loadingContainer:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",backgroundColor:le.colorNeutralBackground1},label:{fontSize:le.fontSizeBase200,fontWeight:le.fontWeightSemibold,color:le.colorNeutralForeground2}});function jte({layoutXml:e}){const r=Bte(),{isDark:t}=e1(),n=A.useRef(null),o=(l=>{if(!l)return"";try{let a="",u=0;const h=l.replace(/>\s*</g,`>
|
|
66
|
+
`)}function nte(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function ote(e){return`'${e.replace(/'/g,"'\\''")}'`}function ite(e){return`'${e.replace(/'/g,"''")}'`}function ate(e){const r=e.replace(/>\s+</g,"><").replace(/\s*\n\s*/g," ").trim();return["# Generated by FetchXML Studio — Code Generation Panel","# Requires: Power Platform CLI (pac)","# Docs: https://learn.microsoft.com/power-platform/developer/cli/reference/env#pac-env-fetch","# Or save the query to a file and run: pac env fetch --xmlFile query.xml","","# bash / zsh",`pac env fetch --xml ${ote(r)}`,"","# PowerShell 7.3 or later (Windows PowerShell 5.1 drops the inner double quotes; use --xmlFile)",`pac env fetch --xml ${ite(r)}`].join(`
|
|
67
|
+
`)}function ste(e,r){const t=r??j_(e),s=(e.match(/<fetch\b[^>]*>/i)?.[0]??"").match(/\stop=["'](\d+)["']/i)?.[1]??"";return{actionName:"List rows",connector:"Microsoft Dataverse connector",banner:'Open the "List rows" action → Show advanced options → paste the FetchXML into the "Fetch Xml Query" field. Leave the OData fields (Select Columns, Filter Rows, Sort By, Expand Query) empty when using FetchXML.',fields:[{label:"Table name",value:t,hint:"Entity set name — plural (e.g. accounts, contacts)"},{label:"Select Columns",value:"",hint:"Leave empty — FetchXML controls column selection"},{label:"Filter Rows",value:"",hint:"Leave empty — FetchXML controls filtering"},{label:"Sort By",value:"",hint:"Leave empty — FetchXML controls ordering"},{label:"Top Count",value:s,hint:"Optional total rows cap (from the FetchXML top attribute; count is a page size, not a limit)"},{label:"Fetch Xml Query",value:e.trim(),hint:'Paste this into the "Fetch Xml Query" field (Show advanced options)',multiline:!0}],notes:["Fetch Xml Query is mutually exclusive with Select Columns / Filter Rows / Sort By — leave those empty.","Maximum Pagination Size enables auto-iteration of pages — set it if you need all rows without a Top Count.","The Table name must be the entity set name (plural), not the logical name."]}}function lte(e,r,t){const n=t??j_(e),s=r?r.replace(/\/$/,""):"https://<your-org>.crm.dynamics.com",o=`/api/data/v9.2/${n}`,i=e.replace(/>\s+</g,"><").replace(/\s*\n\s*/g," ").trim(),c=encodeURIComponent(i),l=`${s}${o}?fetchXml=${c}`;return["// Generated by FetchXML Studio — Code Generation Panel","","// ─── OData URL ───────────────────────────────────────────────────────────────",`GET ${s}${o}?fetchXml=<url-encoded-xml>`,"","// Full URL (with encoded FetchXML):",l,"","// ─── Headers ─────────────────────────────────────────────────────────────────","OData-MaxVersion: 4.0","OData-Version: 4.0","Accept: application/json","Authorization: Bearer <your-access-token>","// Formatted values, plus the paging cookie and more-records annotations:",'Prefer: odata.include-annotations="*"',"","// ─── Paging (https://learn.microsoft.com/power-apps/developer/data-platform/fetchxml/page-results) ───",`// Set count (page size) and page="1" on <fetch>; don't use top with paging.`,'// While the response has "@Microsoft.Dynamics.CRM.morerecords": true:','// 1. Read the pagingcookie attribute of "@Microsoft.Dynamics.CRM.fetchxmlpagingcookie".',"// 2. URL-decode it twice, XML-encode it, and set it as paging-cookie on <fetch>.","// 3. Increment page, URL-encode the FetchXML again, and send the next request.","","// ─── cURL ────────────────────────────────────────────────────────────────────","curl -X GET \\",` "${l}" \\`,' -H "OData-MaxVersion: 4.0" \\',' -H "OData-Version: 4.0" \\',' -H "Accept: application/json" \\',' -H "Prefer: odata.include-annotations=\\"*\\"" \\',' -H "Authorization: Bearer <your-access-token>"',"","// ─── PowerShell ──────────────────────────────────────────────────────────────","$headers = @{",' "OData-MaxVersion" = "4.0"',' "OData-Version" = "4.0"',' "Accept" = "application/json"',` "Prefer" = 'odata.include-annotations="*"'`,' "Authorization" = "Bearer <your-access-token>"',"}",`$url = "${l}"`,"$response = Invoke-RestMethod -Method Get -Uri $url -Headers $headers","$response.value"].join(`
|
|
68
|
+
`)}function j_(e){const r=e.match(/<entity\s+name=["']([^"']+)["']/i);if(!r)return"records";const t=r[1];return{opportunity:"opportunities",activity:"activities",category:"categories",territory:"territories",currency:"transactioncurrencies",systemuser:"systemusers",businessunit:"businessunits",team:"teams"}[t]??`${t}s`}const cte=wr({row:{display:"grid",gridTemplateColumns:"180px minmax(0, 1fr) auto",gap:"12px",alignItems:"start",marginBottom:"14px"},rowLabel:{paddingTop:"6px",fontWeight:500,color:le.colorNeutralForeground1},rowLabelEmpty:{color:le.colorNeutralForeground3},hint:{fontSize:"10px",color:le.colorNeutralForeground3,marginTop:"4px",display:"block"},copyBtn:{minWidth:"90px"}});function ute({spec:e}){const r=cte(),t=e.fields.filter(s=>s.value).length,n=e.fields.filter(s=>s.value).map(s=>`${s.label.padEnd(28)} ${s.value}`).join(`
|
|
69
|
+
`);return j.jsxs("div",{children:[j.jsxs("div",{style:{marginBottom:16,display:"flex",alignItems:"baseline",gap:12,flexWrap:"wrap"},children:[j.jsx(vR,{style:{color:le.colorBrandForeground1,marginTop:6}}),j.jsx(gL,{style:{fontFamily:le.fontFamilyBase},children:e.actionName}),j.jsxs(kv,{style:{color:le.colorNeutralForeground3},children:["· ",e.connector]}),j.jsx("span",{style:{flexGrow:1}}),j.jsxs(ri,{appearance:"ghost",children:[t," of ",e.fields.length," populated"]}),j.jsx(Or,{content:"Copy every populated field as one block",relationship:"description",children:j.jsx(St,{size:"small",appearance:"outline",icon:j.jsx(wc,{}),onClick:()=>{ws(n)},children:"Copy all"})})]}),e.banner&&j.jsx(Ar,{layout:"multiline",intent:"info",style:{marginBottom:14},children:j.jsx(Rr,{children:e.banner})}),j.jsx(yL,{style:{display:"block",marginBottom:10,color:le.colorNeutralForeground2},children:e.actionName}),j.jsx("div",{children:e.fields.map(s=>j.jsx(dte,{field:s,styles:r},s.label))}),e.notes&&e.notes.length>0&&j.jsx(Ar,{layout:"multiline",intent:"info",style:{marginTop:14},children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Notes"}),j.jsx("ul",{style:{margin:"6px 0 0",paddingLeft:18},children:e.notes.map((s,o)=>j.jsx("li",{children:s},o))})]})})]})}function dte({field:e,styles:r}){const[t,n]=A.useState(!1),s=()=>{e.value&&ws(e.value).then(o=>{o&&(n(!0),setTimeout(()=>n(!1),1400))})};return j.jsxs("div",{className:r.row,children:[j.jsx(Dn,{className:de(r.rowLabel,e.value?void 0:r.rowLabelEmpty),children:e.label}),j.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[e.multiline?j.jsx(Sv,{value:e.value,readOnly:!0,rows:Math.min(4,Math.max(1,Math.ceil(e.value.length/80))),appearance:"filled-lighter",style:{width:"100%",fontFamily:le.fontFamilyMonospace,fontSize:12}}):j.jsx(_n,{value:e.value,readOnly:!0,appearance:"filled-lighter",style:{width:"100%",fontFamily:le.fontFamilyMonospace,fontSize:12}}),e.hint&&j.jsx(kv,{className:r.hint,children:e.hint})]}),j.jsx(Or,{content:e.value?"Copy this value":"Empty — nothing to copy",relationship:"label",children:j.jsx(St,{size:"medium",appearance:e.value?"outline":"subtle",disabled:!e.value,icon:t?j.jsx(jR,{style:{color:le.colorPaletteGreenForeground1}}):j.jsx(wc,{}),onClick:s,className:r.copyBtn,children:t?"Copied":"Copy"})})]})}const fte={0:"And",1:"Or"},N_={0:"Inner",1:"LeftOuter",2:"Natural",3:"MatchFirstRowUsingCrossApply",4:"In",5:"Exists",6:"Any",7:"NotAny",8:"All",9:"NotAll"},hte={0:"Ascending",1:"Descending"},pte={0:"None",1:"Count",2:"CountColumn",3:"Sum",4:"Avg",5:"Min",6:"Max"},mte={0:"None",1:"Day",2:"Week",3:"Month",4:"Quarter",5:"Year",6:"FiscalPeriod",7:"FiscalYear"},gte={0:"Equal",1:"NotEqual",2:"GreaterThan",3:"LessThan",4:"GreaterEqual",5:"LessEqual",6:"Like",7:"NotLike",8:"In",9:"NotIn",10:"Between",11:"NotBetween",12:"Null",13:"NotNull",14:"Yesterday",15:"Today",16:"Tomorrow",17:"Last7Days",18:"Next7Days",19:"LastWeek",20:"ThisWeek",21:"NextWeek",22:"LastMonth",23:"ThisMonth",24:"NextMonth",25:"On",26:"OnOrBefore",27:"OnOrAfter",28:"LastYear",29:"ThisYear",30:"NextYear",31:"LastXHours",32:"NextXHours",33:"LastXDays",34:"NextXDays",35:"LastXWeeks",36:"NextXWeeks",37:"LastXMonths",38:"NextXMonths",39:"OlderThanXMonths",40:"OlderThanXYears",41:"OlderThanXWeeks",42:"OlderThanXDays",43:"OlderThanXHours",44:"OlderThanXMinutes",45:"LastXYears",46:"NextXYears",47:"EqualUserId",48:"NotEqualUserId",49:"EqualBusinessId",50:"NotEqualBusinessId",51:"ChildOf",52:"Mask",53:"NotMask",54:"MasksSelect",55:"Contains",56:"DoesNotContain",57:"EqualUserLanguage",58:"NotOn",59:"OlderThanXMinutes",60:"Next",61:"EqualUserOrUserTeams",62:"EqualUserTeams",63:"EqualUserOrUserHierarchy",64:"EqualUserOrUserHierarchyAndTeams",65:"Under",66:"NotUnder",67:"UnderOrEqual",68:"Above",69:"AboveOrEqual",70:"Begins",71:"ContainValues",72:"DoesNotContainValues",73:"EqualRoleBusinessId"};function bte(e){const r=["// Generated by FetchXML Studio — Code Generation Panel","// Requires: Microsoft.PowerPlatform.Dataverse.Client or Microsoft.CrmSdk.CoreAssemblies","",`var query = new QueryExpression("${e.EntityName}")`,"{"];if(r.push(...Jn(t1(e.ColumnSet))),e.Criteria&&n1(e.Criteria)&&r.push(...Jn(r1(e.Criteria))),e.LinkEntities&&e.LinkEntities.length>0&&r.push(...Jn(A_(e.LinkEntities))),e.Orders&&e.Orders.length>0&&r.push(...Jn(R_(e.Orders))),e.TopCount!=null&&r.push(` TopCount = ${e.TopCount},`),e.Distinct&&r.push(" Distinct = true,"),e.NoLock&&r.push(" NoLock = true,"),e.PageInfo){const t=e.PageInfo;r.push(" PageInfo = new PagingInfo"),r.push(" {"),t.Count!=null&&r.push(` Count = ${t.Count},`),t.PageNumber!=null&&r.push(` PageNumber = ${t.PageNumber},`),t.ReturnTotalRecordCount&&r.push(" ReturnTotalRecordCount = true,"),r.push(" },")}return r.push("};"),r.join(`
|
|
70
|
+
`)}function t1(e){if(e.AttributeExpressions&&e.AttributeExpressions.length>0){const t=["ColumnSet = new ColumnSet(false)"];t.push("{"),t.push(" AttributeExpressions ="),t.push(" {");for(const n of e.AttributeExpressions){const s=nl(n.AggregateType??0,pte,"None"),i=n.DateTimeGrouping!=null&&n.DateTimeGrouping!==0&&n.DateTimeGrouping!=="None"?`, XrmDateTimeGrouping.${nl(n.DateTimeGrouping,mte,"None")}`:"",c=n.Alias?`, "${n.Alias}"`:"",l=n.HasGroupBy?", hasGroupBy: true":"";t.push(` new XrmAttributeExpression("${n.AttributeName}", XrmAggregateType.${s}${c}${i}${l}),`)}return t.push(" },"),t.push("},"),t}return e.AllColumns?["ColumnSet = new ColumnSet(true),"]:!e.Columns||e.Columns.length===0?["ColumnSet = new ColumnSet(false),"]:[`ColumnSet = new ColumnSet(${e.Columns.map(t=>`"${t}"`).join(", ")}),`]}function r1(e){const r=["Criteria ="];return r.push(...E_(e)),Ste(r),r}function E_(e,r=0){const t=nl(e.FilterOperator,fte,"And"),n=[];n.push(`new FilterExpression(LogicalOperator.${t})`),n.push("{");const s=e.Conditions&&e.Conditions.length>0,o=e.Filters&&e.Filters.length>0,i=e.AnyAllFilterLinkEntity!=null;if(s){n.push(" Conditions ="),n.push(" {");for(const c of e.Conditions)n.push(...Jn(vte(c),2));n.push(" },")}if(o){n.push(" Filters ="),n.push(" {");for(const c of e.Filters){const l=E_(c,r+1);n.push(...Jn(l,2)),z_(n)}n.push(" },")}return i&&n.push(...Jn(yte(e.AnyAllFilterLinkEntity))),n.push("}"),n}function vte(e){const r=nl(e.Operator,gte,`/* ConditionOperator(${e.Operator}) */`),t=e.EntityName?`"${e.EntityName}", `:"",n=new Set(["Null","NotNull"]),s=new Set([12,13]),o=new Set(["Yesterday","Today","Tomorrow","Last7Days","Next7Days","LastWeek","ThisWeek","NextWeek","LastMonth","ThisMonth","NextMonth","LastYear","ThisYear","NextYear","EqualUserId","NotEqualUserId","EqualBusinessId","NotEqualBusinessId","EqualUserLanguage"]),i=new Set([14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,47,48,49,50,57]),c=n.has(r)||typeof e.Operator=="number"&&s.has(e.Operator),l=o.has(r)||typeof e.Operator=="number"&&i.has(e.Operator),a=e.Values&&e.Values.length>0;if(c||l||!a)return[`new ConditionExpression(${t}"${e.AttributeName}", ConditionOperator.${r}),`];const u=new Set(["In","NotIn","Between","NotBetween","ContainValues","DoesNotContainValues"]),h=new Set([8,9,10,11,71,72]),d=u.has(r)||typeof e.Operator=="number"&&h.has(e.Operator),f=e.Values;if(e.CompareColumns){const m=f.map(p=>`"${p}"`).join(", ");return[`new ConditionExpression(${t}"${e.AttributeName}", ConditionOperator.${r}, compareColumns: true, ${m}),`]}if(d&&f.length>1){const m=f.map(j5).join(", ");return[`new ConditionExpression(${t}"${e.AttributeName}", ConditionOperator.${r}, ${m}),`]}return f.length===1?[`new ConditionExpression(${t}"${e.AttributeName}", ConditionOperator.${r}, ${j5(f[0])}),`]:[`new ConditionExpression(${t}"${e.AttributeName}", ConditionOperator.${r}),`]}function yte(e){const r=nl(e.JoinOperator,N_,"Inner"),t=["AnyAllFilterLinkEntity = new LinkEntity",` ("${e.LinkFromEntityName}", "${e.LinkToEntityName}", "${e.LinkFromAttributeName}", "${e.LinkToAttributeName}", JoinOperator.${r})`,"{"];return e.EntityAlias&&t.push(` EntityAlias = "${e.EntityAlias}",`),e.Columns&&t.push(...Jn(t1(e.Columns))),e.LinkCriteria&&n1(e.LinkCriteria)&&t.push(...Jn(r1(e.LinkCriteria))),t.push("},"),t}function A_(e){const r=["LinkEntities =","{"];for(const t of e)r.push(...Jn(wte(t))),z_(r);return r.push("},"),r}function wte(e){const r=nl(e.JoinOperator??0,N_,"Inner"),t=[`new LinkEntity("${e.LinkFromEntityName}", "${e.LinkToEntityName}", "${e.LinkFromAttributeName}", "${e.LinkToAttributeName}", JoinOperator.${r})`,"{"];return e.EntityAlias&&t.push(` EntityAlias = "${e.EntityAlias}",`),e.Columns&&t.push(...Jn(t1(e.Columns))),e.LinkCriteria&&n1(e.LinkCriteria)&&t.push(...Jn(r1(e.LinkCriteria))),e.LinkEntities&&e.LinkEntities.length>0&&t.push(...Jn(A_(e.LinkEntities))),e.Orders&&e.Orders.length>0&&t.push(...Jn(R_(e.Orders))),t.push("}"),t}function R_(e){const r=["Orders =","{"];for(const t of e)r.push(...Jn(xte(t)));return r.push("},"),r}function xte(e){const r=nl(e.OrderType??0,hte,"Ascending"),t=e.EntityName?`, "${e.EntityName}"`:"",n=e.Alias?`, "${e.Alias}"`:"";return[`new OrderExpression("${e.AttributeName}", OrderType.${r}${t}${n}),`]}function Jn(e,r=1){const t=" ".repeat(r);return e.map(n=>n.length>0?t+n:n)}function nl(e,r,t){return e==null?t:typeof e=="string"?e:r[e]??t}function kte(e){if(e==null||typeof e!="object")return e;const r=e,t=Object.keys(r).filter(n=>!n.startsWith("@"));return"value"in r&&t.length<=1?r.value:"Value"in r&&t.length<=1||"Value"in r&&"Type"in r&&t.length===2?r.Value:e}function j5(e){const r=kte(e);return r==null?"null":typeof r=="boolean"?r?"true":"false":typeof r=="number"?String(r):typeof r=="string"?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)?`new Guid("${r}")`:/^-?\d+(\.\d+)?$/.test(r)?r:`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`/* ${JSON.stringify(r)} */`}function n1(e){return e.Conditions!=null&&e.Conditions.length>0||e.Filters!=null&&e.Filters.length>0||e.AnyAllFilterLinkEntity!=null}function z_(e){for(let r=e.length-1;r>=0;r--)if(e[r].trim().length>0){e[r].endsWith(",")||(e[r]=e[r]+",");break}}function Ste(e,r){for(let t=e.length-1;t>=0;t--)if(e[t].trim().length>0){e[t]=e[t].replace(/,\s*$/,""),e[t]=e[t]+",";break}}const _te=wr({root:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:`1px solid ${le.colorNeutralStroke2}`,paddingLeft:"8px",paddingRight:"8px",paddingTop:"4px",paddingBottom:"4px",flexShrink:0,backgroundColor:le.colorNeutralBackground2},tabListWrap:{display:"flex",alignItems:"center",gap:"4px",flexWrap:"wrap"},tabLabel:{display:"flex",alignItems:"center",gap:"4px"},copyButton:{flexShrink:0},body:{flex:1,overflow:"hidden",position:"relative"},paPane:{height:"100%",overflowY:"auto",padding:"16px",boxSizing:"border-box"},centerBox:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"12px",padding:"24px"},offlineText:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200,textAlign:"center",maxWidth:"320px"},messagePad:{padding:"12px"}}),Cte=["csharp-fetchexpr","csharp-queryexpr","sql","javascript","pac","powerautomate","webapi"],Tte={...Zee,"csharp-queryexpr":"C# QueryExpression",sql:"SQL"},Bte={...Jee,"csharp-queryexpr":"csharp",sql:"sql"};function jte({fetchXml:e}){const r=_te(),{isDark:t}=e1(),{connected:n,environmentUrl:s}=N8(),[o,i]=A.useState("csharp-fetchexpr"),[c,l]=A.useState(!1),[a,u]=A.useState(""),[h,d]=A.useState(!1),[f,m]=A.useState(null),[p,g]=A.useState(""),[b,y]=A.useState(!1),[w,C]=A.useState(null),[N,I]=A.useState(void 0),$=A.useRef({cancelled:!1});A.useEffect(()=>{$.current.cancelled=!0;const _={cancelled:!1};if($.current=_,!e||!n){u(""),m(null),g(""),C(null),I(void 0);return}const S=e.match(/entity\s+name=["']([^"']+)["']/i);S&&hc(S[1]).then(T=>{_.cancelled||I(T.EntitySetName)}).catch(()=>{}),d(!0),m(null),y(!0),C(null),Kv(e).then(T=>{if(_.cancelled)return;const z=bte(T);u(z)}).catch(T=>{_.cancelled||(m(T instanceof Error?T.message:String(T)),u(""))}).finally(()=>{_.cancelled||d(!1)}),zZ(e).then(T=>{_.cancelled||g(T)}).catch(T=>{_.cancelled||(C(T instanceof Error?T.message:String(T)),g(""))}).finally(()=>{_.cancelled||y(!1)})},[e,n]);const D=(_,S)=>{i(S.value)},F=A.useCallback(()=>{switch(o){case"csharp-queryexpr":return a;case"sql":return p;default:return ete(o,e,o==="webapi"?N:void 0,s)}},[o,e,a,p,s,N]),V=A.useCallback(()=>{const _=F();_&&ws(_).then(S=>{S&&(l(!0),setTimeout(()=>l(!1),1500))})},[F]),G=o==="csharp-queryexpr"&&h||o==="sql"&&b,U=o==="csharp-queryexpr"?f:o==="sql"?w:null,E=(o==="csharp-queryexpr"||o==="sql")&&!n,M=F(),B=t?"vs-dark":"light",k=Bte[o];return j.jsxs("div",{className:r.root,children:[j.jsxs("div",{className:r.header,children:[j.jsx("div",{className:r.tabListWrap,children:j.jsx(hp,{size:"small",appearance:"subtle",selectedValue:o,onTabSelect:D,children:Cte.map(_=>j.jsx(Za,{value:_,children:j.jsxs("span",{className:r.tabLabel,children:[Tte[_],_==="sql"&&j.jsx(Or,{content:"Undocumented API — may change without notice",relationship:"label",children:j.jsx(ri,{size:"small",appearance:"tint",color:"warning",style:{cursor:"default"},children:"Preview"})}),(_==="csharp-queryexpr"||_==="sql")&&!n&&j.jsx(Or,{content:"Connect to an environment to generate",relationship:"label",children:j.jsx(ph,{style:{opacity:.5,width:14,height:14}})})]})},_))})}),j.jsx(Or,{content:o==="powerautomate"?"Use the per-field Copy buttons below":c?"Copied!":"Copy to clipboard",relationship:"label",children:j.jsx(St,{appearance:"subtle",size:"small",icon:j.jsx(wc,{}),className:r.copyButton,onClick:V,disabled:G||E||!M||o==="powerautomate","aria-label":"Copy code to clipboard",children:c?"Copied!":"Copy"})})]}),j.jsxs("div",{className:r.body,children:[G&&j.jsx("div",{className:r.centerBox,children:j.jsx(hn,{size:"medium",label:"Generating…"})}),!G&&U&&j.jsx("div",{className:r.messagePad,children:j.jsx(Ar,{intent:"error",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Generation failed"}),U]})})}),!G&&E&&j.jsxs("div",{className:r.centerBox,children:[j.jsx(ph,{style:{opacity:.4,width:32,height:32}}),j.jsxs("p",{className:r.offlineText,children:["Connect to a Dataverse environment to generate"," ",o==="csharp-queryexpr"?"C# QueryExpression":"SQL"," code."]})]}),!G&&!U&&!E&&o==="powerautomate"&&j.jsx("div",{className:r.paPane,children:j.jsx(ute,{spec:ste(e,N)})}),!G&&!U&&!E&&o!=="powerautomate"&&j.jsx(Jv,{height:"100%",language:k,value:M,theme:B,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:o==="webapi"?"on":"off",fontSize:13,lineNumbers:"on",renderLineHighlight:"none",folding:!0,automaticLayout:!0}})]})]})}const Nte=wr({container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},toolbar:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 8px",borderBottom:`1px solid ${le.colorNeutralStroke1}`,backgroundColor:le.colorNeutralBackground2,flexShrink:0},toolbarLeft:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},toolbarRight:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},editorWrapper:{flex:1,overflow:"hidden",minHeight:0},loadingContainer:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",backgroundColor:le.colorNeutralBackground1},label:{fontSize:le.fontSizeBase200,fontWeight:le.fontWeightSemibold,color:le.colorNeutralForeground2}});function Ete({layoutXml:e}){const r=Nte(),{isDark:t}=e1(),n=A.useRef(null),o=(l=>{if(!l)return"";try{let a="",u=0;const h=l.replace(/>\s*</g,`>
|
|
71
71
|
<`).split(`
|
|
72
72
|
`);for(const d of h){const f=d.trim();f&&(f.startsWith("</")&&(u=Math.max(0,u-1)),a+=" ".repeat(u)+f+`
|
|
73
|
-
`,f.startsWith("<")&&!f.startsWith("</")&&!f.startsWith("<?")&&!f.endsWith("/>")&&!f.includes("</")&&u++)}return a.trim()}catch{return l}})(e),i=A.useCallback(l=>{n.current=l},[]),c=A.useCallback(async()=>{await ws(o)||console.error("Failed to copy to clipboard")},[o]);return j.jsxs("div",{className:r.container,children:[j.jsxs("div",{className:r.toolbar,children:[j.jsx("div",{className:r.toolbarLeft,children:j.jsx("span",{className:r.label,children:"LayoutXML (Read-only)"})}),j.jsx(Bc,{size:"small",children:j.jsx(Wn,{icon:j.jsx(E0,{}),onClick:c,disabled:!e,"aria-label":"Copy LayoutXML",children:"Copy"})})]}),j.jsx("div",{className:r.editorWrapper,children:j.jsx(Jv,{height:"100%",language:"xml",theme:t?"vs-dark":"vs",value:o,options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",fontSize:13,tabSize:2,automaticLayout:!0,folding:!0,renderLineHighlight:"line",scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:10,horizontalScrollbarSize:10}},onMount:i,loading:j.jsx("div",{className:r.loadingContainer,children:j.jsx(hn,{size:"medium",label:"Loading editor…"})})})})]})}const Nte=e=>(RS({...e,renderRow:()=>null}),e),I_=A.createContext(void 0),Ete=void 0,Ate=()=>{var e;return(e=A.useContext(I_))!=null?e:Ete},Rte=I_.Provider,M_=A.createContext({current:null}),zte={current:null},D_=()=>{var e;return(e=A.useContext(M_))!=null?e:zte},Ite=M_.Provider,P_=A.createContext({current:null}),Mte={current:null},O_=()=>{var e;return(e=A.useContext(P_))!=null?e:Mte},Dte=P_.Provider,Pte=(e,r)=>{const{height:t,itemSize:n,width:s="100%",ariaRowIndexStart:o=2,children:i,listProps:c}=e,l=D_(),a=O_(),h=AS({...e,children:i},r),d=A.useCallback(({data:p,index:g,style:b,isScrolling:y})=>{const w=p[g];return A.createElement(Rte,{value:o+g},A.createElement(CS,{value:w.rowId},i(w,b,g,y)))},[o,i]),f=A.useCallback(()=>{l.current&&a.current&&a.current.scroll({left:l.current.scrollLeft,behavior:"instant"})},[]),m=A.useCallback(p=>{var g;(g=l.current)==null||g.removeEventListener("scroll",f),l.current=p,p&&p.addEventListener("scroll",f)},[]);return{...h,itemSize:n,height:t,virtualizedRow:d,width:s,ariaRowIndexStart:o,listProps:c,outerRef:m}};function db(){return db=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},db.apply(null,arguments)}function N5(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function fb(e,r){return fb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},fb(e,r)}function Ote(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,fb(e,r)}var E5=Number.isNaN||function(r){return typeof r=="number"&&r!==r};function Fte(e,r){return!!(e===r||E5(e)&&E5(r))}function qte(e,r){if(e.length!==r.length)return!1;for(var t=0;t<e.length;t++)if(!Fte(e[t],r[t]))return!1;return!0}function t0(e,r){r===void 0&&(r=qte);var t,n=[],s,o=!1;function i(){for(var c=[],l=0;l<arguments.length;l++)c[l]=arguments[l];return o&&t===this&&r(c,n)||(s=e.apply(this,c),o=!0,t=this,n=c),s}return i}var Lte=typeof performance=="object"&&typeof performance.now=="function",A5=Lte?function(){return performance.now()}:function(){return Date.now()};function R5(e){cancelAnimationFrame(e.id)}function $te(e,r){var t=A5();function n(){A5()-t>=r?e.call(null):s.id=requestAnimationFrame(n)}var s={id:requestAnimationFrame(n)};return s}var r0=-1;function z5(e){if(e===void 0&&(e=!1),r0===-1||e){var r=document.createElement("div"),t=r.style;t.width="50px",t.height="50px",t.overflow="scroll",document.body.appendChild(r),r0=r.offsetWidth-r.clientWidth,document.body.removeChild(r)}return r0}var $l=null;function I5(e){if(e===void 0&&(e=!1),$l===null||e){var r=document.createElement("div"),t=r.style;t.width="50px",t.height="50px",t.overflow="scroll",t.direction="rtl";var n=document.createElement("div"),s=n.style;return s.width="100px",s.height="100px",r.appendChild(n),document.body.appendChild(r),r.scrollLeft>0?$l="positive-descending":(r.scrollLeft=1,r.scrollLeft===0?$l="negative":$l="positive-ascending"),document.body.removeChild(r),$l}return $l}var Hte=150,Vte=function(r,t){return r};function Wte(e){var r,t=e.getItemOffset,n=e.getEstimatedTotalSize,s=e.getItemSize,o=e.getOffsetForIndexAndAlignment,i=e.getStartIndexForOffset,c=e.getStopIndexForStartIndex,l=e.initInstanceProps,a=e.shouldResetStyleCacheOnItemSizeChange,u=e.validateProps;return r=(function(h){Ote(d,h);function d(m){var p;return p=h.call(this,m)||this,p._instanceProps=l(p.props,N5(p)),p._outerRef=void 0,p._resetIsScrollingTimeoutId=null,p.state={instance:N5(p),isScrolling:!1,scrollDirection:"forward",scrollOffset:typeof p.props.initialScrollOffset=="number"?p.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},p._callOnItemsRendered=void 0,p._callOnItemsRendered=t0(function(g,b,y,w){return p.props.onItemsRendered({overscanStartIndex:g,overscanStopIndex:b,visibleStartIndex:y,visibleStopIndex:w})}),p._callOnScroll=void 0,p._callOnScroll=t0(function(g,b,y){return p.props.onScroll({scrollDirection:g,scrollOffset:b,scrollUpdateWasRequested:y})}),p._getItemStyle=void 0,p._getItemStyle=function(g){var b=p.props,y=b.direction,w=b.itemSize,C=b.layout,N=p._getItemStyleCache(a&&w,a&&C,a&&y),I;if(N.hasOwnProperty(g))I=N[g];else{var $=t(p.props,g,p._instanceProps),D=s(p.props,g,p._instanceProps),F=y==="horizontal"||C==="horizontal",V=y==="rtl",G=F?$:0;N[g]=I={position:"absolute",left:V?void 0:G,right:V?G:void 0,top:F?0:$,height:F?"100%":D,width:F?D:"100%"}}return I},p._getItemStyleCache=void 0,p._getItemStyleCache=t0(function(g,b,y){return{}}),p._onScrollHorizontal=function(g){var b=g.currentTarget,y=b.clientWidth,w=b.scrollLeft,C=b.scrollWidth;p.setState(function(N){if(N.scrollOffset===w)return null;var I=p.props.direction,$=w;if(I==="rtl")switch(I5()){case"negative":$=-w;break;case"positive-descending":$=C-y-w;break}return $=Math.max(0,Math.min($,C-y)),{isScrolling:!0,scrollDirection:N.scrollOffset<$?"forward":"backward",scrollOffset:$,scrollUpdateWasRequested:!1}},p._resetIsScrollingDebounced)},p._onScrollVertical=function(g){var b=g.currentTarget,y=b.clientHeight,w=b.scrollHeight,C=b.scrollTop;p.setState(function(N){if(N.scrollOffset===C)return null;var I=Math.max(0,Math.min(C,w-y));return{isScrolling:!0,scrollDirection:N.scrollOffset<I?"forward":"backward",scrollOffset:I,scrollUpdateWasRequested:!1}},p._resetIsScrollingDebounced)},p._outerRefSetter=function(g){var b=p.props.outerRef;p._outerRef=g,typeof b=="function"?b(g):b!=null&&typeof b=="object"&&b.hasOwnProperty("current")&&(b.current=g)},p._resetIsScrollingDebounced=function(){p._resetIsScrollingTimeoutId!==null&&R5(p._resetIsScrollingTimeoutId),p._resetIsScrollingTimeoutId=$te(p._resetIsScrolling,Hte)},p._resetIsScrolling=function(){p._resetIsScrollingTimeoutId=null,p.setState({isScrolling:!1},function(){p._getItemStyleCache(-1,null)})},p}d.getDerivedStateFromProps=function(p,g){return Ute(p,g),u(p),null};var f=d.prototype;return f.scrollTo=function(p){p=Math.max(0,p),this.setState(function(g){return g.scrollOffset===p?null:{scrollDirection:g.scrollOffset<p?"forward":"backward",scrollOffset:p,scrollUpdateWasRequested:!0}},this._resetIsScrollingDebounced)},f.scrollToItem=function(p,g){g===void 0&&(g="auto");var b=this.props,y=b.itemCount,w=b.layout,C=this.state.scrollOffset;p=Math.max(0,Math.min(p,y-1));var N=0;if(this._outerRef){var I=this._outerRef;w==="vertical"?N=I.scrollWidth>I.clientWidth?z5():0:N=I.scrollHeight>I.clientHeight?z5():0}this.scrollTo(o(this.props,p,g,C,this._instanceProps,N))},f.componentDidMount=function(){var p=this.props,g=p.direction,b=p.initialScrollOffset,y=p.layout;if(typeof b=="number"&&this._outerRef!=null){var w=this._outerRef;g==="horizontal"||y==="horizontal"?w.scrollLeft=b:w.scrollTop=b}this._callPropsCallbacks()},f.componentDidUpdate=function(){var p=this.props,g=p.direction,b=p.layout,y=this.state,w=y.scrollOffset,C=y.scrollUpdateWasRequested;if(C&&this._outerRef!=null){var N=this._outerRef;if(g==="horizontal"||b==="horizontal")if(g==="rtl")switch(I5()){case"negative":N.scrollLeft=-w;break;case"positive-ascending":N.scrollLeft=w;break;default:var I=N.clientWidth,$=N.scrollWidth;N.scrollLeft=$-I-w;break}else N.scrollLeft=w;else N.scrollTop=w}this._callPropsCallbacks()},f.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&R5(this._resetIsScrollingTimeoutId)},f.render=function(){var p=this.props,g=p.children,b=p.className,y=p.direction,w=p.height,C=p.innerRef,N=p.innerElementType,I=p.innerTagName,$=p.itemCount,D=p.itemData,F=p.itemKey,V=F===void 0?Vte:F,G=p.layout,U=p.outerElementType,E=p.outerTagName,M=p.style,B=p.useIsScrolling,k=p.width,_=this.state.isScrolling,S=y==="horizontal"||G==="horizontal",T=S?this._onScrollHorizontal:this._onScrollVertical,z=this._getRangeToRender(),P=z[0],O=z[1],X=[];if($>0)for(var K=P;K<=O;K++)X.push(A.createElement(g,{data:D,key:V(K,D),index:K,isScrolling:B?_:void 0,style:this._getItemStyle(K)}));var J=n(this.props,this._instanceProps);return A.createElement(U||E||"div",{className:b,onScroll:T,ref:this._outerRefSetter,style:db({position:"relative",height:w,width:k,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:y},M)},A.createElement(N||I||"div",{children:X,ref:C,style:{height:S?"100%":J,pointerEvents:_?"none":void 0,width:S?J:"100%"}}))},f._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered=="function"){var p=this.props.itemCount;if(p>0){var g=this._getRangeToRender(),b=g[0],y=g[1],w=g[2],C=g[3];this._callOnItemsRendered(b,y,w,C)}}if(typeof this.props.onScroll=="function"){var N=this.state,I=N.scrollDirection,$=N.scrollOffset,D=N.scrollUpdateWasRequested;this._callOnScroll(I,$,D)}},f._getRangeToRender=function(){var p=this.props,g=p.itemCount,b=p.overscanCount,y=this.state,w=y.isScrolling,C=y.scrollDirection,N=y.scrollOffset;if(g===0)return[0,0,0,0];var I=i(this.props,N,this._instanceProps),$=c(this.props,I,N,this._instanceProps),D=!w||C==="backward"?Math.max(1,b):1,F=!w||C==="forward"?Math.max(1,b):1;return[Math.max(0,I-D),Math.max(0,Math.min(g-1,$+F)),I,$]},d})(A.PureComponent),r.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},r}var Ute=function(r,t){r.children,r.direction,r.height,r.layout,r.innerTagName,r.outerTagName,r.width,t.instance},Xte=Wte({getItemOffset:function(r,t){var n=r.itemSize;return t*n},getItemSize:function(r,t){var n=r.itemSize;return n},getEstimatedTotalSize:function(r){var t=r.itemCount,n=r.itemSize;return n*t},getOffsetForIndexAndAlignment:function(r,t,n,s,o,i){var c=r.direction,l=r.height,a=r.itemCount,u=r.itemSize,h=r.layout,d=r.width,f=c==="horizontal"||h==="horizontal",m=f?d:l,p=Math.max(0,a*u-m),g=Math.min(p,t*u),b=Math.max(0,t*u-m+u+i);switch(n==="smart"&&(s>=b-m&&s<=g+m?n="auto":n="center"),n){case"start":return g;case"end":return b;case"center":{var y=Math.round(b+(g-b)/2);return y<Math.ceil(m/2)?0:y>p+Math.floor(m/2)?p:y}default:return s>=b&&s<=g?s:s<b?b:g}},getStartIndexForOffset:function(r,t){var n=r.itemCount,s=r.itemSize;return Math.max(0,Math.min(n-1,Math.floor(t/s)))},getStopIndexForStartIndex:function(r,t,n){var s=r.direction,o=r.height,i=r.itemCount,c=r.itemSize,l=r.layout,a=r.width,u=s==="horizontal"||l==="horizontal",h=t*c,d=u?a:o,f=Math.ceil((d+n-h)/c);return Math.max(0,Math.min(i-1,t+f-1))},initInstanceProps:function(r){},shouldResetStyleCacheOnItemSizeChange:!0,validateProps:function(r){r.itemSize}});const Gte=e=>{const{slots:r,slotProps:t}=bB(e),{dir:n}=Yt();return A.createElement(r.root,t.root,A.createElement(Xte,{itemSize:e.itemSize,width:e.width,itemData:e.rows,height:e.height,itemCount:e.rows.length,direction:n,outerRef:e.outerRef,...e.listProps},e.virtualizedRow))},F_=A.forwardRef((e,r)=>{const t=Pte(e,r);return Nte(t),Gte(t)});F_.displayName="DataGridBody";const Kte=(e,r)=>{var t;const{targetDocument:n}=Yt(),s=p3({targetDocument:n}),o=A.useRef(null),i=A.useRef(null);let c=e.containerWidthOffset;c===void 0&&(c=e.selectionMode?-44:0,c-=s||0);const l=IS({...e,"aria-rowcount":e.items.length,containerWidthOffset:c},r);return e.resizableColumns&&((t=e.resizableColumnsOptions)==null?void 0:t.autoFitColumns)===!1&&l.root.style&&(l.root.style.minWidth="auto"),{...l,headerRef:o,bodyRef:i}},Yte=(e,r)=>A.createElement(Dte,{value:e.headerRef},A.createElement(Ite,{value:e.bodyRef},MS(e,r))),q_=A.forwardRef((e,r)=>{const t=Kte(e,r);return DS(t),Yte(t,PS(t))});q_.displayName="DataGrid";const Qte=(e,r)=>{const t=Ate();return jS({...e,"aria-rowindex":t},r)},Zte=wr({root:{minWidth:"fit-content"}}),Jte=e=>{const r=Zte();return e.root.className=de(r.root,e.root.className),ES(e),e},hb=A.forwardRef((e,r)=>{const t=Qte(e,r);return Jte(t),NS(t)});hb.displayName="DataGridRow";const ere=(e,r)=>{const t=D_(),n=O_(),s=A.useCallback(()=>{t.current&&n.current&&t.current.scroll({left:n.current.scrollLeft,behavior:"instant"})},[]),o=A.useCallback(c=>{var l;(l=n.current)==null||l.removeEventListener("scroll",s),n.current=c,c&&c.addEventListener("scroll",s)},[]),i=FS(e,r);return i.root.ref=Nt(i.root.ref,o),i},tre=wr({root:{overflowX:"auto",scrollbarWidth:"none","::-webkit-scrollbar":{width:0,height:0}}}),rre=e=>{const r=tre();return e.root.className=de(r.root,e.root.className),LS(e),e},L_=A.forwardRef((e,r)=>{const t=ere(e,r);return rre(t),qS(t)});L_.displayName="DataGridHeader";const pb=e=>e.toLocaleString("en-US");function nre(e,r,t){if(!(e===void 0||e<0))return r?`${pb(Math.max(e,t))}+ total`:`${pb(e)} total`}function ore(e,r){return`About ${pb(r)} ${e} records in all: a snapshot from the last 24 hours that ignores this query's filters (RetrieveTotalRecordCount).`}const $_=A.createContext("");function ire(e,r){const t=r.trim().toLowerCase();if(!t)return[];const n=e.toLowerCase(),s=[];for(let o=n.indexOf(t);o>=0;o=n.indexOf(t,o+t.length))s.push([o,o+t.length]);return s}const are=wr({mark:{backgroundColor:le.colorPaletteYellowBackground2,color:"inherit",borderRadius:le.borderRadiusSmall}});function ol({text:e}){const r=are(),t=A.useContext($_),n=ire(e,t);if(n.length===0)return j.jsx(j.Fragment,{children:e});const s=[];let o=0;for(const[i,c]of n)i>o&&s.push(e.slice(o,i)),s.push(j.jsx("mark",{className:r.mark,children:e.slice(i,c)},i)),o=c;return o<e.length&&s.push(e.slice(o)),j.jsx(j.Fragment,{children:s})}const Nc=wr({booleanCell:{display:"flex",alignItems:"center",gap:le.spacingHorizontalXS},lookupCell:{display:"flex",flexDirection:"column",gap:"2px",minWidth:0},lookupName:{display:"block",fontSize:le.fontSizeBase200,fontWeight:le.fontWeightSemibold,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},lookupType:{display:"block",fontSize:le.fontSizeBase100,color:le.colorNeutralForeground3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},numberCell:{display:"block",textAlign:"right",fontVariantNumeric:"tabular-nums",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},dateCell:{display:"block",fontVariantNumeric:"tabular-nums",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},picklistCell:{display:"flex",alignItems:"center"},truncateText:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}});function sre({value:e,formattedValue:r,attribute:t}){const n=Nc(),s=!!e,o=r||(s?t?.OptionSet?.TrueOption?.Label?.UserLocalizedLabel?.Label||"Yes":t?.OptionSet?.FalseOption?.Label?.UserLocalizedLabel?.Label||"No");return j.jsxs("div",{className:n.booleanCell,children:[j.jsx(Qs,{checked:s,disabled:!0}),j.jsx(Dn,{size:"small",children:String(o)})]})}function lre({value:e,formattedValue:r,attribute:t}){const n=Nc();if(r){const l=t?.AttributeType==="State"||t?.AttributeType==="Status"?"filled":"tint";return j.jsx("div",{className:n.picklistCell,children:j.jsx(ri,{appearance:l,children:String(r)})})}const s=typeof e=="number"?e:parseInt(String(e),10);if(isNaN(s))return j.jsx("span",{children:"—"});const i=t?.OptionSet?.Options?.find(l=>l.Value===s)?.Label?.UserLocalizedLabel?.Label||String(s),c=t?.AttributeType==="State"||t?.AttributeType==="Status"?"filled":"tint";return j.jsx("div",{className:n.picklistCell,children:j.jsx(ri,{appearance:c,children:i})})}function cre({value:e,formattedValue:r}){const t=Nc();if(r)return j.jsx("span",{className:t.lookupName,children:j.jsx(ol,{text:String(r)})});if(!e||typeof e!="object")return j.jsx("span",{children:"—"});const n=e;return j.jsxs("div",{className:t.lookupCell,children:[j.jsx("span",{className:t.lookupName,children:j.jsx(ol,{text:n.Name||"—"})}),n.LogicalName&&j.jsx("span",{className:t.lookupType,children:n.LogicalName})]})}function ure({value:e,formattedValue:r,attribute:t}){const n=Nc();if(r)return j.jsx("span",{className:n.numberCell,children:j.jsx(ol,{text:String(r)})});if(e==null||e==="")return j.jsx("span",{children:"—"});const s=typeof e=="number"?e:parseFloat(String(e));if(isNaN(s))return j.jsx("span",{children:"—"});if(t?.AttributeType==="Money")return j.jsxs("span",{className:n.numberCell,children:["$",s.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]});if(t?.AttributeType==="Integer"||t?.AttributeType==="BigInt")return j.jsx("span",{className:n.numberCell,children:s.toLocaleString()});const o=t?.Precision??2;return j.jsx("span",{className:n.numberCell,children:s.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:o})})}function dre({value:e,formattedValue:r,attribute:t}){const n=Nc();if(r)return j.jsx("span",{className:n.dateCell,children:j.jsx(ol,{text:String(r)})});if(!e)return j.jsx("span",{children:"—"});const s=new Date(String(e));return isNaN(s.getTime())?j.jsx("span",{children:"—"}):t?.Format==="DateOnly"||t?.DateTimeBehavior?.Value==="DateOnly"?j.jsx("span",{className:n.dateCell,children:s.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}):j.jsx("span",{className:n.dateCell,children:s.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})}function fre({value:e,formattedValue:r}){const t=Nc(),n=r??e;return n==null||n===""?j.jsx("span",{children:"—"}):j.jsx("span",{className:t.truncateText,children:j.jsx(ol,{text:String(n)})})}function M5(e,r,t,n){if(r==null)return j.jsx("span",{children:"—"});switch(e){case"Boolean":return j.jsx(sre,{value:r,formattedValue:t,attribute:n});case"Picklist":case"State":case"Status":return j.jsx(lre,{value:r,formattedValue:t,attribute:n});case"Lookup":case"Customer":case"Owner":return j.jsx(cre,{value:r,formattedValue:t});case"Integer":case"BigInt":case"Decimal":case"Double":case"Money":return j.jsx(ure,{value:r,formattedValue:t,attribute:n});case"DateTime":return j.jsx(dre,{value:r,formattedValue:t,attribute:n});default:return j.jsx(fre,{value:r,formattedValue:t})}}function hre(e,r){const t=new WeakMap,n=new Map,s=new Set;return e.forEach((o,i)=>{const c=r?o[r]:void 0,l=typeof c=="string"&&c.length>0,a=l&&!s.has(c)?c:`__row_${i}`;s.add(a),t.set(o,a),l&&n.set(a,c)}),{getRowId:o=>t.get(o)??`__row_unknown_${e.indexOf(o)}`,toRecordIds:o=>{const i=new Set;for(const c of o){const l=n.get(String(c));l&&i.add(l)}return Array.from(i)}}}const D5="@OData.Community.Display.V1.FormattedValue";function Xi(e,r){if(!e||!r)return null;const t=`${r}${D5}`;if(t in e)return e[t];if(r.startsWith("_")&&r.endsWith("_value"))return e[r];const n=`_${r}_value${D5}`;return n in e?e[n]:e[r]}function zh(e){const r=new Map;let t=0;const n=s=>s.links.forEach(o=>{t++,r.set(o.id,o.alias||`${o.name}${t}`),n(o)});return n(e.entity),r}function Cp(e){const r=zh(e),t=e.entity.attributes.map(s=>({key:s.alias||s.name,attribute:s,container:e.entity,isRoot:!0})),n=s=>s.links.forEach(o=>{const i=r.get(o.id);for(const c of o.attributes)t.push({key:c.alias||`${i}.${c.name}`,attribute:c,container:o,isRoot:!1,linkAlias:i});n(o)});return n(e.entity),t}function vd(e,r){const t=Cp(e),n=t.find(c=>c.key===r);if(n)return n;const s=/^_(.+)_value$/.exec(r)?.[1],o=s?t.find(c=>c.isRoot&&!c.attribute.alias&&c.attribute.name===s):void 0;if(o||r.includes("."))return o;const i=r.toLowerCase();return t.find(c=>!c.isRoot&&!c.attribute.alias&&c.container.linkType==="matchfirstrowusingcrossapply"&&c.attribute.name===i)}const pre=(e,r)=>e.attributes.every(t=>r.has(t.id))&&!e.allAttributes?.enabled&&e.filters.length===0&&e.orders.every(t=>r.has(t.id))&&e.links.every(t=>r.has(t.id));function mre(e,r){const t=new Set;for(const i of r){const c=vd(e,i);c&&(t.add(c.attribute.id),c.attribute.alias&&Z0(e,c.container,c.attribute.alias).forEach(l=>t.add(l.id)))}const n=[],s=i=>i.links.forEach(c=>{s(c),c.linkType==="outer"&&pre(c,t)&&c.attributes.some(l=>t.has(l.id))&&(t.add(c.id),n.push(c))});s(e.entity);const o=new Set(n.flatMap(i=>[...i.attributes.map(c=>c.id),...i.orders.map(c=>c.id)]));return{removeNodeIds:[...t].filter(i=>!o.has(i)),removedLinks:n}}function gre(e,r,t){const n=vd(e,r);if(!n)return{reason:"This column isn't an attribute of the query."};const s=M8(t);if(s)return{reason:s};const o=e.options.aggregate===!0;if(o&&!n.attribute.alias)return{reason:"Aggregate queries sort by alias; give the attribute an alias first."};const i=o?{alias:n.attribute.alias}:{attribute:n.attribute.name};if(n.isRoot)return{spec:i};const c=n.container,l=H_(e).filter(u=>u.name===c.name).length,a=c.alias??(l===1?c.name:void 0);return a?{spec:{...i,entityname:a}}:{spec:i,insideLink:c}}function H_(e){const r=[],t=n=>n.links.forEach(s=>{r.push(s),t(s)});return t(e.entity),r}function bre(e){const r=Cp(e),t=H_(e),n=new Map,s=(o,i)=>{const c=o.descending?"descending":"ascending";for(const l of r){if(l.container!==i)continue;(o.alias?l.attribute.alias===o.alias:l.attribute.name===o.attribute)&&!n.has(l.key)&&n.set(l.key,c)}};for(const o of e.entity.orders){const i=o.entityname?t.find(c=>c.alias===o.entityname)??t.find(c=>c.name===o.entityname):e.entity;i&&s(o,i)}for(const o of t)for(const i of o.orders)s(i,o);return n}function n0(e,r){if(e.options?.aggregate)return{reason:"Column filters aren't available in aggregate queries. Add conditions in the tree instead."};const t=vd(e,r);if(!t)return{reason:"This column isn't an attribute in the query."};if(t.isRoot)return{attribute:t.attribute.name,entityName:e.entity.name};const n=t.container;return{attribute:t.attribute.name,entityname:"alias"in n&&n.alias?n.alias:n.name,entityName:n.name}}function Ec(e,r,t=[]){for(const[n,s]of e.entries()){if(s.id===r)return[...t,n];const o=Ec(s.subfilters,r,[...t,n]);if(o)return o}}function mb(e,r){let t=e,n;for(const s of r){if(n=t[s],!n)return;t=n.subfilters}return n}function Tp(e,r,t){const[n,...s]=r;return e.flatMap((o,i)=>{if(i!==n)return[o];if(s.length===0){const c=t(o);return c?[c]:[]}return[{...o,subfilters:Tp(o.subfilters,s,t)}]})}const ed=(e,r)=>({...e,entity:{...e.entity,filters:r}});function V_(e,r){if(!e||!r)return;const t=Ec(e.entity.filters,r);return t?mb(e.entity.filters,t):void 0}function vre(e,r){return V_(e,r)?.conditions??[]}function yre(e,r,t,n){const s={...t,id:n(),type:"condition"},o=e.entity.filters,i=r?Ec(o,r):void 0;if(r&&i)return{fetch:ed(e,Tp(o,i,d=>({...d,conditions:[...d.conditions,s]}))),groupId:r,conditionId:s.id};const c={id:n(),type:"filter",conjunction:"and",conditions:[s],subfilters:[],links:[]},l=d=>({fetch:ed(e,d),groupId:c.id,conditionId:s.id}),[a,...u]=o;if(!a)return l([c]);if(a.conjunction!=="or")return l([{...a,subfilters:[...a.subfilters,c]},...u]);const h={id:n(),type:"filter",conjunction:"and",conditions:[],subfilters:[a,c],links:[]};return{...l([h,...u]),wrapperId:h.id}}function wre(e,r,t,n=null){const s=V_(e,r);if(!s||!r)return{fetch:e,groupId:null};const o=s.conditions.filter(i=>i.id!==t);if(o.length>0||s.subfilters.length>0||s.links.length>0){const i=Ec(e.entity.filters,r);return{fetch:ed(e,Tp(e.entity.filters,i,c=>({...c,conditions:o}))),groupId:r}}return{fetch:W_(e,r,n),groupId:null}}function W_(e,r,t=null){const n=r?Ec(e.entity.filters,r):void 0;if(!n)return e;const s=Tp(e.entity.filters,n,()=>{}),[o,...i]=s;return n.length===2&&o&&o.id===t&&o.conjunction==="and"&&o.conditions.length===0&&o.links.length===0&&o.subfilters.length===1&&!o.hint&&!o.isQuickFindFields&&!o.overrideQuickFindRecordLimitEnabled&&!o.overrideQuickFindRecordLimitDisabled&&!o.extraAttributes?ed(e,[o.subfilters[0],...i]):ed(e,s)}const P5=e=>JSON.stringify(e?.conditions.map(r=>[r.attribute,r.operator,r.value??null,r.entityname??null])??null);function xre(e,r,t,n){return!e||!t||!n?null:e.entity.filters[0]?.id===t?r.entity.filters[0]?.id??null:null}function kre(e,r,t){if(!e||!t)return null;const n=Ec(e.entity.filters,t);if(!n)return null;const s=mb(e.entity.filters,n),o=mb(r.entity.filters,n);return o&&P5(o)===P5(s)?o.id:null}function pc({entityLogicalName:e,value:r,onChange:t,placeholder:n="Select or type attribute name",disabled:s=!1,filterByTypes:o}){const i=mr("attribute-combobox"),[c,l]=A.useState([]),[a,u]=A.useState(!1),[h,d]=A.useState(null),[f,m]=A.useState(""),p=Sp();A.useEffect(()=>{if(!e){l([]);return}u(!0),d(null),Yv(e,p).then(C=>{let N=C;o&&o.length>0&&(N=C.filter(I=>o.includes(I.AttributeType||""))),l(N),u(!1)}).catch(C=>{console.error("Failed to load attributes:",C),d("Failed to load attributes"),u(!1)})},[e,o,p]),A.useEffect(()=>{if(r&&r!=="new_attribute"){const C=c.find(N=>N.LogicalName===r);if(C){const N=C.DisplayName?.UserLocalizedLabel?.Label||C.SchemaName;m(`${N} (${C.LogicalName})`)}else m(r)}else(!r||r==="new_attribute")&&m("")},[r,c]);const g=c.map(C=>({children:`${C.DisplayName?.UserLocalizedLabel?.Label||C.SchemaName} (${C.LogicalName})`,value:C.LogicalName})),b=dp(f,g,{noOptionsMessage:"No attributes match your search."}),y=(C,N)=>{N.optionValue?(m(N.optionText??""),t(N.optionValue)):(m(""),t(""))},w=r&&r!=="new_attribute"?[r]:[];return h?j.jsx(Zn,{"aria-labelledby":i,selectedOptions:w,value:f,onChange:C=>{const N=C.target.value;m(N),t(N)},placeholder:n,disabled:s}):j.jsx(Zn,{"aria-labelledby":i,onOptionSelect:y,selectedOptions:w,value:f,onChange:C=>m(C.target.value),placeholder:a?"Loading attributes…":n,disabled:s||a,clearable:!0,children:b})}function Sre({entityLogicalName:e,attributeLogicalName:r,value:t,onChange:n,placeholder:s="Select a value",disabled:o=!1}){const i=mr("optionset-combobox"),[c,l]=A.useState([]),[a,u]=A.useState(!1),[h,d]=A.useState(null),[f,m]=A.useState("");A.useEffect(()=>{if(!e||!r){l([]);return}u(!0),d(null),Qv(e,r).then(w=>{if(!w.OptionSet?.Options){d("No options found for this attribute"),l([]),u(!1);return}const C=w.OptionSet.Options.map(N=>{const I=N.Label?.UserLocalizedLabel?.Label||`Option ${N.Value}`;return{value:N.Value,label:I,displayText:`${I} - ${N.Value}`}});l(C),u(!1)}).catch(w=>{console.error("Failed to load option set values:",w),d("Failed to load options"),u(!1)})},[e,r]),A.useEffect(()=>{if(t!=null&&t!==""){const w=typeof t=="string"?parseInt(t,10):t,C=c.find(N=>N.value===w);m(C?C.displayText:String(t))}else m("")},[t,c]);const p=c.filter(w=>{if(!f)return!0;const C=f.toLowerCase();return w.label.toLowerCase().includes(C)||String(w.value).includes(C)}).map(w=>({children:w.displayText,value:String(w.value)})),g=dp(f,p,{noOptionsMessage:a?"Loading options…":h||"No options found",filter:()=>!0}),b=w=>{m(w.target.value)},y=(w,C)=>{if(!C.optionValue){m(""),n(void 0);return}const N=c.find(I=>String(I.value)===C.optionValue);N&&(m(N.displayText),n(N.value))};return j.jsx(Zn,{"aria-labelledby":i,placeholder:s,value:f,onChange:b,onOptionSelect:y,disabled:o||a,clearable:!0,children:g})}function _re({entityLogicalName:e,attributeLogicalName:r,value:t,onChange:n,placeholder:s="Select true or false",disabled:o=!1}){const i=mr("boolean-combobox"),[c,l]=A.useState([]),[a,u]=A.useState(!1),[h,d]=A.useState(null),[f,m]=A.useState("");A.useEffect(()=>{if(!e||!r){l([]);return}u(!0),d(null),Qv(e,r).then(w=>{if(!w.OptionSet){console.warn("No OptionSet found for boolean attribute, using defaults"),l([{value:!0,label:"Yes",displayText:"Yes - true"},{value:!1,label:"No",displayText:"No - false"}]),u(!1);return}const C=w.OptionSet.TrueOption?.Label?.UserLocalizedLabel?.Label||"Yes",N=w.OptionSet.FalseOption?.Label?.UserLocalizedLabel?.Label||"No";l([{value:!0,label:C,displayText:`${C} - true`},{value:!1,label:N,displayText:`${N} - false`}]),u(!1)}).catch(w=>{console.error("Failed to load boolean attribute metadata:",w),l([{value:!0,label:"Yes",displayText:"Yes - true"},{value:!1,label:"No",displayText:"No - false"}]),u(!1)})},[e,r]),A.useEffect(()=>{if(t!=null&&t!==""){let w;typeof t=="boolean"?w=t:typeof t=="string"?w=t==="true"||t==="1":w=!!t;const C=c.find(N=>N.value===w);m(C?C.displayText:String(t))}else m("")},[t,c]);const p=c.filter(w=>{if(!f)return!0;const C=f.toLowerCase();return w.label.toLowerCase().includes(C)||String(w.value).toLowerCase().includes(C)}).map(w=>({children:w.displayText,value:String(w.value)})),g=dp(f,p,{noOptionsMessage:a?"Loading…":h||"No options",filter:()=>!0}),b=w=>{m(w.target.value)},y=(w,C)=>{if(!C.optionValue){m(""),n(void 0);return}const N=c.find(I=>String(I.value)===C.optionValue);N&&(m(N.displayText),n(N.value))};return j.jsx(Zn,{"aria-labelledby":i,placeholder:s,value:f,onChange:b,onOptionSelect:y,disabled:o||a,clearable:!0,children:g})}function gb({attribute:e,value:r,onChange:t,placeholder:n="Enter a number",disabled:s=!1}){const o=mr("numeric-input"),[i,c]=A.useState(""),l=f=>Math.abs(f)<1e-10&&f!==0?f.toFixed(20).replace(/\.?0+$/,""):Number.isInteger(f)?f.toString():f.toFixed(10).replace(/\.?0+$/,"");A.useEffect(()=>{if(r!=null&&r!==""){const f=typeof r=="number"?r:parseFloat(String(r));c(isNaN(f)?String(r):l(f))}else c("")},[r]);const a=()=>{const f=e.AttributeType;if(f==="Integer"||f==="BigInt")return 1;if((f==="Decimal"||f==="Double")&&e.Precision!==void 0)return Math.pow(10,-e.Precision)},u=f=>{const m=e.AttributeType;if(m==="Integer"||m==="BigInt")return Math.round(f);if((m==="Decimal"||m==="Double")&&e.Precision!==void 0){const p=Math.pow(10,e.Precision);return Math.round(f*p)/p}return f},h=f=>{const m=f.target.value;if(c(m),m===""){t(void 0);return}const p=parseFloat(m);if(!isNaN(p)){const g=u(p);t(g)}},d=()=>{if(i===""){t(void 0);return}const f=parseFloat(i);if(isNaN(f)){c(""),t(void 0);return}let m=u(f);e.MinValue!==void 0&&m<e.MinValue&&(m=e.MinValue),e.MaxValue!==void 0&&m>e.MaxValue&&(m=e.MaxValue),m!==f&&(c(String(m)),t(m))};return j.jsx(_n,{id:o,type:"number",value:i,onChange:h,onBlur:d,placeholder:n,disabled:s,min:e.MinValue,max:e.MaxValue,step:a()})}var jo=(function(e){return e[e.Sunday=0]="Sunday",e[e.Monday=1]="Monday",e[e.Tuesday=2]="Tuesday",e[e.Wednesday=3]="Wednesday",e[e.Thursday=4]="Thursday",e[e.Friday=5]="Friday",e[e.Saturday=6]="Saturday",e})({}),Cre=(function(e){return e[e.January=0]="January",e[e.February=1]="February",e[e.March=2]="March",e[e.April=3]="April",e[e.May=4]="May",e[e.June=5]="June",e[e.July=6]="July",e[e.August=7]="August",e[e.September=8]="September",e[e.October=9]="October",e[e.November=10]="November",e[e.December=11]="December",e})({}),Ih=(function(e){return e[e.FirstDay=0]="FirstDay",e[e.FirstFullWeek=1]="FirstFullWeek",e[e.FirstFourDayWeek=2]="FirstFourDayWeek",e})({}),fo=(function(e){return e[e.Day=0]="Day",e[e.Week=1]="Week",e[e.Month=2]="Month",e[e.WorkWeek=3]="WorkWeek",e})({});const td=7,Kr={DaysInOneWeek:7,MonthInOneYear:12},Tre=e=>e.getDate().toString(),Bre=(e,r)=>r.months[e.getMonth()]+" "+e.getDate()+", "+e.getFullYear(),jre=(e,r)=>r.months[e.getMonth()]+" "+e.getFullYear(),Nre=(e,r)=>r.months[e.getMonth()],Ere=e=>e.getFullYear().toString(),Are={months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["S","M","T","W","T","F","S"]},U_={formatDay:Tre,formatMonth:Nre,formatYear:Ere,formatMonthDayYear:Bre,formatMonthYear:jre},X_={...Are,goToToday:"Go to today",weekNumberFormatString:"Week number {0}",prevMonthAriaLabel:"Previous month",nextMonthAriaLabel:"Next month",prevYearAriaLabel:"Previous year",nextYearAriaLabel:"Next year",prevYearRangeAriaLabel:"Previous year range",nextYearRangeAriaLabel:"Next year range",closeButtonAriaLabel:"Close",selectedDateFormatString:"Selected date {0}",todayDateFormatString:"Today's date {0}",monthPickerHeaderAriaLabel:"{0}, change year",yearPickerHeaderAriaLabel:"{0}, change month",dayMarkedAriaLabel:"marked"};function No(e,r){const t=new Date(e.getTime());return t.setDate(t.getDate()+r),t}function O5(e,r){return No(e,r*Kr.DaysInOneWeek)}function Ja(e,r){let t=new Date(e.getTime());const n=t.getMonth()+r;return t.setMonth(n),t.getMonth()!==(n%Kr.MonthInOneYear+Kr.MonthInOneYear)%Kr.MonthInOneYear&&(t=No(t,-t.getDate())),t}function Ql(e,r){let t=new Date(e.getTime());return t.setFullYear(e.getFullYear()+r),t.getMonth()!==(e.getMonth()%Kr.MonthInOneYear+Kr.MonthInOneYear)%Kr.MonthInOneYear&&(t=No(t,-t.getDate())),t}function G_(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function K_(e){return new Date(e.getFullYear(),e.getMonth()+1,0,0,0,0,0)}function Rre(e){return new Date(e.getFullYear(),0,1,0,0,0,0)}function zre(e){return new Date(e.getFullYear()+1,0,0,0,0,0,0)}function Lf(e,r){return Ja(e,r-e.getMonth())}function Sa(e,r){return!e&&!r?!0:!e||!r?!1:e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}function eo(e,r){return F5(e)-F5(r)}function Mh(e,r,t,n,s=1){const o=[];let i,c=null;switch(n||(n=[jo.Monday,jo.Tuesday,jo.Wednesday,jo.Thursday,jo.Friday]),r){case fo.Day:[i,c]=[e,No(e,s)],eo(i,c)>0&&([i,c]=[No(c,1),No(i,1)]);break;case fo.Week:case fo.WorkWeek:i=Pre(Ore(e),t),c=No(i,Kr.DaysInOneWeek);break;case fo.Month:i=new Date(e.getFullYear(),e.getMonth(),1),c=Ja(i,1);break;default:throw new Error("Unexpected object: "+r)}let l=i;do(r!==fo.WorkWeek||n.indexOf(l.getDay())!==-1)&&o.push(l),l=No(l,1);while(!Sa(l,c));return o}function Ire(e,r){for(const t of r)if(Sa(e,t))return!0;return!1}function Mre(e,r,t,n){const s=n.getFullYear(),o=n.getMonth();let i=1;const c=new Date(s,o,i),l=i+(r+Kr.DaysInOneWeek-1)-qre(r,c.getDay());let a=new Date(s,o,l);i=a.getDate();const u=[];for(let h=0;h<e;h++)u.push(Dre(a,r,t)),i+=Kr.DaysInOneWeek,a=new Date(s,o,i);return u}function Dre(e,r,t){switch(t){case Ih.FirstFullWeek:return q5(e,r,Kr.DaysInOneWeek);case Ih.FirstFourDayWeek:return q5(e,r,4);default:return Fre(e,r)}}function Pre(e,r){let t=r-e.getDay();return t>0&&(t-=Kr.DaysInOneWeek),No(e,t)}function Ore(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function F5(e){return e.getDate()+(e.getMonth()<<5)+(e.getFullYear()<<9)}function q5(e,r,t){const n=bb(e)-1;let s=e.getDay()-n%Kr.DaysInOneWeek;const o=new Date(e.getFullYear()-1,Cre.December,31),i=bb(o)-1;let c=(r-s+2*Kr.DaysInOneWeek)%Kr.DaysInOneWeek;c!==0&&c>=t&&(c-=Kr.DaysInOneWeek);let l=n-c;return l<0&&(s-=i%Kr.DaysInOneWeek,c=(r-s+2*Kr.DaysInOneWeek)%Kr.DaysInOneWeek,c!==0&&c+1>=t&&(c-=Kr.DaysInOneWeek),l=i-c),Math.floor(l/Kr.DaysInOneWeek+1)}function Fre(e,r){const t=bb(e)-1,s=(e.getDay()-t%Kr.DaysInOneWeek-r+2*Kr.DaysInOneWeek)%Kr.DaysInOneWeek;return Math.floor((t+s)/Kr.DaysInOneWeek+1)}function qre(e,r){return e!==jo.Sunday&&r<e?r+Kr.DaysInOneWeek:r}function bb(e){const r=e.getMonth(),t=e.getFullYear();let n=0;for(let s=0;s<r;s++)n+=Lre(s+1,t);return n+=e.getDate(),n}function Lre(e,r){return new Date(r,e,0).getDate()}const Y_=(e,r)=>{const{minDate:t}=r;return t?eo(t,e)>=1:!1},Q_=(e,r)=>{const{maxDate:t}=r;return t?eo(e,t)>=1:!1},Iu=(e,r)=>{const{restrictedDates:t,minDate:n,maxDate:s}=r;return!t&&!n&&!s?!1:t&&t.some(i=>Sa(i,e))||Y_(e,r)||Q_(e,r)},L5=e=>{const{targetDate:r,initialDate:t,direction:n,...s}=e;let o=r;if(!Iu(r,s))return r;for(;eo(t,o)!==0&&Iu(o,s)&&!Q_(o,s)&&!Y_(o,s);)o=No(o,n);if(eo(t,o)!==0&&!Iu(o,s))return o},Z_=(e,r,t)=>{let n=[...e];return r&&(n=n.filter(s=>eo(s,r)>=0)),t&&(n=n.filter(s=>eo(s,t)<=0)),n},$re=(e,r,t)=>{const n=new Set(e);let s=0;for(const o of e){const i=(o+1)%7;n.has(i)&&t!==i||s++}return s<2},Hre=(e,r,t)=>r&&e===fo.WorkWeek&&(!$re(r,!0,t)||r.length===0)?fo.Week:e,Vre=e=>{const{selectedDate:r,dateRangeType:t,firstDayOfWeek:n,today:s,minDate:o,maxDate:i,weeksToShow:c,workWeekDays:l,daysToSelectInDayView:a,restrictedDates:u,markedDays:h}=e,d={minDate:o,maxDate:i,restrictedDates:u},f=s||new Date,m=e.navigatedDate?e.navigatedDate:f;let p;c&&c<=4?p=new Date(m.getFullYear(),m.getMonth(),m.getDate()):p=new Date(m.getFullYear(),m.getMonth(),1);const g=[];for(;p.getDay()!==n;)p.setDate(p.getDate()-1);p=No(p,-td);let b=!1;const y=Hre(t,l,n);let w=[];r&&(w=Mh(r,y,n,l,a),w=Z_(w,o,i));let C=!0;for(let N=0;C;N++){const I=[];b=!0;for(let $=0;$<td;$++){const D=new Date(p.getTime()),F={key:p.toString(),date:p.getDate().toString(),originalDate:D,isInMonth:p.getMonth()===m.getMonth(),isToday:Sa(f,p),isSelected:Ire(p,w),isSingleSelected:w.length===1&&Sa(p,r),isInBounds:!Iu(p,d),isMarked:h?.some(V=>Sa(D,V))||!1};I.push(F),F.isInMonth&&(b=!1),p.setDate(p.getDate()+1)}C=c?N<c+1:!b||N===0,g.push(I)}return g};let Hl;function $5(e,r){if(e){if(Hl){Hl=e;return}Hl=e,r&&r.requestAnimationFrame(()=>{Hl&&Hl.focus(),Hl=void 0})}}const Ko={topRightCornerDate:"fui-CalendarDayGrid__topRightCornerDate",topLeftCornerDate:"fui-CalendarDayGrid__topLeftCornerDate",bottomRightCornerDate:"fui-CalendarDayGrid__bottomRightCornerDate",bottomLeftCornerDate:"fui-CalendarDayGrid__bottomLeftCornerDate"};function Wre(e){const{dir:r}=Yt(),t=o=>{const i={},c=o.slice(1,o.length-1);return c.forEach((l,a)=>{l.forEach((u,h)=>{const d=c[a-1]&&c[a-1][h]&&s(c[a-1][h].originalDate,u.originalDate,c[a-1][h].isSelected,u.isSelected),f=c[a+1]&&c[a+1][h]&&s(c[a+1][h].originalDate,u.originalDate,c[a+1][h].isSelected,u.isSelected),m=c[a][h-1]&&s(c[a][h-1].originalDate,u.originalDate,c[a][h-1].isSelected,u.isSelected),p=c[a][h+1]&&s(c[a][h+1].originalDate,u.originalDate,c[a][h+1].isSelected,u.isSelected);i[a+"_"+h]=n(d,f,m,p)})}),i},n=(o,i,c,l)=>{const a=[],u=!o&&!c,h=!o&&!l,d=!i&&!c,f=!i&&!l;return u&&a.push(r==="rtl"?Ko.topRightCornerDate:Ko.topLeftCornerDate),h&&a.push(r==="rtl"?Ko.topLeftCornerDate:Ko.topRightCornerDate),d&&a.push(r==="rtl"?Ko.bottomRightCornerDate:Ko.bottomLeftCornerDate),f&&a.push(r==="rtl"?Ko.bottomLeftCornerDate:Ko.bottomRightCornerDate),de(...a)},s=(o,i,c,l)=>{const{dateRangeType:a,firstDayOfWeek:u,workWeekDays:h}=e,d=a===fo.WorkWeek?fo.Week:a,f=Mh(o,d,u,h);return c!==l?!1:c&&l?!0:f.filter(m=>m.getTime()===i.getTime()).length>0};return[t,n]}const Hn={wrapper:"fui-CalendarDayGrid__wrapper",table:"fui-CalendarDayGrid__table",dayCell:"fui-CalendarDayGrid__dayCell",daySelected:"fui-CalendarDayGrid__daySelected",daySingleSelected:"fui-CalendarDayGrid__daySingleSelected",weekRow:"fui-CalendarDayGrid__weekRow",weekDayLabelCell:"fui-CalendarDayGrid__weekDayLabelCell",weekNumberCell:"fui-CalendarDayGrid__weekNumberCell",dayOutsideBounds:"fui-CalendarDayGrid__dayOutsideBounds",dayOutsideNavigatedMonth:"fui-CalendarDayGrid__dayOutsideNavigatedMonth",dayButton:"fui-CalendarDayGrid__dayButton",dayIsToday:"fui-CalendarDayGrid__dayIsToday",firstTransitionWeek:"fui-CalendarDayGrid__firstTransitionWeek",lastTransitionWeek:"fui-CalendarDayGrid__lastTransitionWeek",dayMarker:"fui-CalendarDayGrid__dayMarker",dayTodayMarker:"fui-CalendarDayGrid__dayTodayMarker"},xu={hoverStyle:"fui-CalendarDayGrid__hoverStyle",pressedStyle:"fui-CalendarDayGrid__pressedStyle"},Ure=ke({base:{Byoj8tv:"f1fow5ox"}},{d:[".f1fow5ox{padding-bottom:10px;}"]}),Xre=ke({base:{po53p8:"fgkb47j",Bxjg3zr:"f16vktn6",Be2twd7:"fjoy568",B6of3ja:"fvjh0tl",Byoj8tv:"f1fow5ox",qhf8xq:"f10pi13n",B73mfa3:"f14m3nip",fsow6f:"f17mccla",a9b677:"f4m2ahc"},showWeekNumbers:{a9b677:"fl524qk"}},{d:[".fgkb47j{border-collapse:collapse;}",".f16vktn6{border-spacing:0;}",".fjoy568{font-size:inherit;}",".fvjh0tl{margin-top:4px;}",".f1fow5ox{padding-bottom:10px;}",".f10pi13n{position:relative;}",".f14m3nip{table-layout:fixed;}",".f17mccla{text-align:center;}",".f4m2ahc{width:196px;}",".fl524qk{width:226px;}"]}),Gre=ke({base:{sj55zd:"f19n0e5",Bceei9c:"f1k6fduh",Be2twd7:"fy9rknc",Bhrd7zp:"figsok6",jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:"f1s184ao",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"fqtknz5",qhf8xq:"f10pi13n",By8wz76:"ftx6bta",B7iucu3:"fhs7xo9",cvlxnx:"fp6dsbd",Bweudez:"f4xgodq",D35jaw:0,Ehvor9:0,B2d49eq:0,Bup3k99:"f13vaffi",opggj9:"f1ndb8o",Bcb90bd:"f1m5g7hf",Bj67fi1:"f1lhgsq9",B2gfgcj:"fdbuq6n",Bg8e59q:"f1nsyjd2",oie0zm:"fs9m20f",mf9vuf:["f4ozsz2","fd6br62"],Gyav41:"fqrwank",tqq02e:["fd6br62","f4ozsz2"],Bua87ti:"fl9wzut"},focusIndicator:{Brovlpu:"ftqa4ok",B486eqv:"f2hkw1w",B8q5s1w:"f8hki3x",Bci5o5g:["f1d2448m","ffh67wi"],n8qw10:"f1bjia2o",Bdrgwmp:["ffh67wi","f1d2448m"],Bqhya38:"f1j6vpng",Bwxa6fj:["f1pniga2","f1ffjurs"],Bdhvstf:"f987i1v",B7zbvrb:["f1ffjurs","f1pniga2"],Bm4h7ae:"f15bsgw9",B7ys5i9:"f14e48fq",Busjfv9:"f18yb2kv",Bhk32uz:"fd6o370",f6g5ot:0,Boxcth7:0,Bhdgwq3:0,hgwjuy:0,Bshpdp8:0,Bsom6fd:0,Blkhhs4:0,Bonggc9:0,Ddfuxk:0,i03rao:0,kclons:0,clg4pj:0,Bpqj9nj:0,B6dhp37:0,Bf4ptjt:0,Bqtpl0w:0,i4rwgc:"fpqizxz",Dah5zi:0,B1tsrr9:0,qqdqy8:0,Bkh64rk:0,e3fwne:"f3znvyf",J0r882:"fqkqgbk",Bule8hv:["f1as04kd","ft30ozv"],Bjwuhne:"f8pxvb2",Ghsupd:["ft30ozv","f1as04kd"]}},{d:[".f19n0e5{color:var(--colorNeutralForeground1);}",".f1k6fduh{cursor:pointer;}",".fy9rknc{font-size:var(--fontSizeBase200);}",".figsok6{font-weight:var(--fontWeightRegular);}",[".f1s184ao{margin:0;}",{p:-1}],[".fqtknz5{padding:2px;}",{p:-1}],".f10pi13n{position:relative;}",".fp6dsbd.fui-CalendarDayGrid__hoverStyle{color:var(--colorNeutralForeground1Static);}",".f4xgodq.fui-CalendarDayGrid__hoverStyle{background-color:var(--colorBrandBackgroundInvertedHover);}",".f1lhgsq9.fui-CalendarDayGrid__pressedStyle{color:var(--colorNeutralForeground1Static);}",".fdbuq6n.fui-CalendarDayGrid__pressedStyle{background-color:var(--colorBrandBackgroundInvertedPressed);}",".f8hki3x[data-fui-focus-visible]{border-top-color:transparent;}",".f1d2448m[data-fui-focus-visible]{border-right-color:transparent;}",".ffh67wi[data-fui-focus-visible]{border-left-color:transparent;}",".f1bjia2o[data-fui-focus-visible]{border-bottom-color:transparent;}",'.f15bsgw9[data-fui-focus-visible]::after{content:"";}',".f14e48fq[data-fui-focus-visible]::after{position:absolute;}",".f18yb2kv[data-fui-focus-visible]::after{pointer-events:none;}",".fd6o370[data-fui-focus-visible]::after{z-index:1;}",[".fpqizxz[data-fui-focus-visible]::after{border:var(--strokeWidthThick) solid var(--colorStrokeFocus2);}",{p:-2}],[".f3znvyf[data-fui-focus-visible]::after{border-radius:var(--borderRadiusMedium);}",{p:-1}],".fqkqgbk[data-fui-focus-visible]::after{top:calc(var(--strokeWidthThick) * -1);}",".f1as04kd[data-fui-focus-visible]::after{right:calc(var(--strokeWidthThick) * -1);}",".ft30ozv[data-fui-focus-visible]::after{left:calc(var(--strokeWidthThick) * -1);}",".f8pxvb2[data-fui-focus-visible]::after{bottom:calc(var(--strokeWidthThick) * -1);}"],m:[["@media (forced-colors: active){.ftx6bta{background-color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fhs7xo9{color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f13vaffi.fui-CalendarDayGrid__hoverStyle{outline:1px solid Highlight;}}",{p:-1,m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1ndb8o.fui-CalendarDayGrid__hoverStyle{z-index:3;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1m5g7hf.fui-CalendarDayGrid__hoverStyle .fui-CalendarDayGrid__dayTodayMarker{background-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1nsyjd2.fui-CalendarDayGrid__pressedStyle{background-color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fs9m20f.fui-CalendarDayGrid__pressedStyle{border-top-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f4ozsz2.fui-CalendarDayGrid__pressedStyle{border-right-color:Highlight;}.fd6br62.fui-CalendarDayGrid__pressedStyle{border-left-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fqrwank.fui-CalendarDayGrid__pressedStyle{border-bottom-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fl9wzut.fui-CalendarDayGrid__pressedStyle{color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1j6vpng[data-fui-focus-visible]::after{border-top-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1ffjurs[data-fui-focus-visible]::after{border-left-color:Highlight;}.f1pniga2[data-fui-focus-visible]::after{border-right-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f987i1v[data-fui-focus-visible]::after{border-bottom-color:Highlight;}}",{m:"(forced-colors: active)"}]],f:[".ftqa4ok:focus{outline-style:none;}"],i:[".f2hkw1w:focus-visible{outline-style:none;}"]}),Kre=ke({base:{De3pzq:"f1vevd59",sj55zd:"ff5vbop",By8wz76:"f1nz3ub2",Bcq6wej:"fjq791v",Jcjdmf:["fkq2p2y","f1sehlss"],sc4o1m:"f11odvng",Bosien3:["f1sehlss","fkq2p2y"],B7iucu3:"fqc85l4",B8gzw0y:"f1h3a8gf",a3nq4f:"f1chdfq9",Bnf3alp:"fq0dbue",pdtyat:"fb3dhiz",z6f07v:"f1xnoze0",Bec5aua:"f1mubwa3"}},{d:[".f1vevd59{background-color:var(--colorBrandBackgroundInvertedSelected);}",".ff5vbop{color:var(--colorNeutralForeground1Static);}"],m:[["@media (forced-colors: active){.f1nz3ub2{background-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fjq791v{border-top-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1sehlss{border-left-color:Highlight;}.fkq2p2y{border-right-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f11odvng{border-bottom-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fqc85l4{color:HighlightText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1h3a8gf{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fb3dhiz:hover,.fb3dhiz.fui-CalendarDayGrid__hoverStyle,.fb3dhiz.fui-CalendarDayGrid__pressedStyle{background-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1xnoze0:hover,.f1xnoze0.fui-CalendarDayGrid__hoverStyle,.f1xnoze0.fui-CalendarDayGrid__pressedStyle{color:HighlightText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1mubwa3>.fui-CalendarDayGrid__dayMarker{background-color:Window;}}",{m:"(forced-colors: active)"}]],h:[".f1chdfq9:hover,.f1chdfq9.fui-CalendarDayGrid__hoverStyle,.f1chdfq9.fui-CalendarDayGrid__pressedStyle{color:var(--colorNeutralForeground1Static);}",".fq0dbue:hover,.fq0dbue.fui-CalendarDayGrid__hoverStyle,.fq0dbue.fui-CalendarDayGrid__pressedStyle{background-color:var(--colorBrandBackgroundInvertedSelected);}"]}),Yre=ke({base:{sj55zd:"ff5vbop",Bec5aua:"f1mubwa3",B2ns3jv:"fy35frb",Bwxf4zv:0,Bp8cau8:0,Buy161k:0,Bpzqh5e:0,Fh6yq5:"f8kna22",Bjnjwcd:0,Jh9m0u:0,k24jl4:0,yen2pv:0,isizv9:0,Fmkg4n:0,Bksmc0g:0,ydc5we:0,g36fg5:0,xn840g:0,Bvql7r5:0,Cmeexk:0,Brwjcd2:0,Buxuwzc:0,Bz06psx:0,B75pphk:0,Bkp00lz:"f11572cp",B4k9tdm:"f8qifl1",Ba18yr8:"f19flthw",B5fqyig:["fwk98tc","f3izcvc"],Bjrn8xn:"fi9jqiz",Bkpapd2:["f3izcvc","fwk98tc"],xrravj:"f12o3e7s",z0dzun:"f1fjwm8e"}},{d:[".ff5vbop{color:var(--colorNeutralForeground1Static);}",".fy35frb>.fui-CalendarDayGrid__dayButton{background-color:var(--colorBrandBackgroundInvertedSelected);}",[".f8kna22>.fui-CalendarDayGrid__dayButton{border-radius:var(--borderRadiusMedium);}",{p:-1}],[".f11572cp>.fui-CalendarDayGrid__dayButton{border:1px solid var(--colorBrandStroke1);}",{p:-2}]],m:[["@media (forced-colors: active){.f1mubwa3>.fui-CalendarDayGrid__dayMarker{background-color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f8qifl1>.fui-CalendarDayGrid__dayButton{background-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f19flthw>.fui-CalendarDayGrid__dayButton{border-top-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f3izcvc>.fui-CalendarDayGrid__dayButton{border-left-color:Highlight;}.fwk98tc>.fui-CalendarDayGrid__dayButton{border-right-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fi9jqiz>.fui-CalendarDayGrid__dayButton{border-bottom-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f12o3e7s>.fui-CalendarDayGrid__dayButton{color:HighlightText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1fjwm8e>.fui-CalendarDayGrid__dayButton{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}]]}),Qre=ke({base:{qhf8xq:"f10pi13n",mlyf9c:"f1gazwyt"}},{d:[".f10pi13n{position:relative;}"],w:[".f1gazwyt:focus-within{z-index:1;}"]}),Zre=ke({base:{famaaq:"f1xqy1su"}},{d:[".f1xqy1su{-webkit-user-select:none;-moz-user-select:none;user-select:none;}"]}),Jre=ke({base:{De3pzq:"f1c21dwh",h3c5rm:0,vrafjx:0,Bekrc4i:0,u1mtju:["fe2nn5g","f1rcbay7"],B7ck84d:"f1ewtqcl",sj55zd:"fxc4j92",Be2twd7:"fy9rknc",Bhrd7zp:"figsok6",Bqenvij:"fxldao9",jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:"f1s184ao",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai",a9b677:"f1w9dchk"}},{d:[".f1c21dwh{background-color:var(--colorTransparentBackground);}",[".fe2nn5g{border-right:1px solid var(--colorNeutralStroke2);}",{p:-1}],[".f1rcbay7{border-left:1px solid var(--colorNeutralStroke2);}",{p:-1}],".f1ewtqcl{box-sizing:border-box;}",".fxc4j92{color:var(--colorNeutralForeground4);}",".fy9rknc{font-size:var(--fontSizeBase200);}",".figsok6{font-weight:var(--fontWeightRegular);}",".fxldao9{height:28px;}",[".f1s184ao{margin:0;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".f1w9dchk{width:28px;}"]}),ene=ke({base:{x734em:"f1v4z6xg",B0ssf13:"f1u9q7oh",B8h8h5z:"f1a22lcc",B7iucu3:"f1cyfu5x"}},{d:[".f1v4z6xg,.f1v4z6xg:disabled,.f1v4z6xg button,.f1v4z6xg.fui-CalendarDayGrid__hoverStyle,.f1v4z6xg.fui-CalendarDayGrid__pressedStyle{background-color:var(--colorTransparentBackground);}",".f1u9q7oh,.f1u9q7oh:disabled,.f1u9q7oh button,.f1u9q7oh.fui-CalendarDayGrid__hoverStyle,.f1u9q7oh.fui-CalendarDayGrid__pressedStyle{color:var(--colorNeutralForegroundDisabled);}",".f1a22lcc,.f1a22lcc:disabled,.f1a22lcc button,.f1a22lcc.fui-CalendarDayGrid__hoverStyle,.f1a22lcc.fui-CalendarDayGrid__pressedStyle{pointer-events:none;}"],m:[["@media (forced-colors: active){.f1cyfu5x{color:GrayText;}}",{m:"(forced-colors: active)"}]]}),tne=ke({lightenDaysOutsideNavigatedMonth:{sj55zd:"fxc4j92",Bhrd7zp:"figsok6",B7iucu3:"f1cyfu5x"}},{d:[".fxc4j92{color:var(--colorNeutralForeground4);}",".figsok6{font-weight:var(--fontWeightRegular);}"],m:[["@media (forced-colors: active){.f1cyfu5x{color:GrayText;}}",{m:"(forced-colors: active)"}]]}),rne=ke({base:{De3pzq:"f1c21dwh",Bgfg5da:0,B9xav0g:0,oivjwe:0,Bn0qgzm:0,B4g9neb:0,zhjwy3:0,wvpqe5:0,ibv6hh:0,u1mtju:0,h3c5rm:0,vrafjx:0,Bekrc4i:0,i8vvqc:0,g2u3we:0,icvyot:0,B4j52fo:0,irswps:"f3bhgqh",sj55zd:"f1ym3bx4",Bceei9c:"f1k6fduh",Be2twd7:"fy9rknc",Bhrd7zp:"ff5ikls",Bqenvij:"frvgh55",Bg96gwp:"f8xlz6g",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1gl81tg",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai",a9b677:"fq4mcun",Bx0yju7:"f10y451g",l98f4w:"f1dwpgx3",Jwef8y:"f18a0fwf",Btmb5he:0,gu71dq:0,B2zomw9:0,Fgk69s:0,Bw6eyry:"f1mhq3ai",ecr2s2:"f7la2e8"}},{d:[".f1c21dwh{background-color:var(--colorTransparentBackground);}",[".f3bhgqh{border:none;}",{p:-2}],".f1ym3bx4{color:inherit;}",".f1k6fduh{cursor:pointer;}",".fy9rknc{font-size:var(--fontSizeBase200);}",".ff5ikls{font-weight:inherit;}",".frvgh55{height:24px;}",".f8xlz6g{line-height:24px;}",[".f1gl81tg{overflow:visible;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".fq4mcun{width:24px;}",".f10y451gspan{height:inherit;}",".f1dwpgx3span{line-height:inherit;}"],h:[".f18a0fwf:hover{background-color:var(--colorBrandBackgroundInvertedHover);}",[".f1mhq3ai:hover{border-radius:var(--borderRadiusMedium);}",{p:-1}]],a:[".f7la2e8:active{background-color:var(--colorBrandBackgroundInvertedPressed);}"]}),nne=ke({base:{mc9l5x:"f22iagw",Brf1p80:"f4d9j23",Bt984gj:"f122n59",sj55zd:"f1phragk",Bhrd7zp:"fl43uef",kof2un:"f1b5s8wn",Bec5aua:"f1mubwa3"}},{d:[".f22iagw{display:flex;}",".f4d9j23{justify-content:center;}",".f122n59{align-items:center;}",".f1phragk{color:var(--colorNeutralForegroundOnBrand);}",".fl43uef{font-weight:var(--fontWeightSemibold);}",".f1b5s8wn>.fui-CalendarDayGrid__dayMarker{background-color:var(--colorNeutralForegroundOnBrand);}"],m:[["@media (forced-colors: active){.f1mubwa3>.fui-CalendarDayGrid__dayMarker{background-color:Window;}}",{m:"(forced-colors: active)"}]]}),one=ke({base:{mc9l5x:"f22iagw",Brf1p80:"f4d9j23",Bt984gj:"f122n59",De3pzq:"ffp7eso",Beyfa6y:0,Bbmb7ep:0,Btl43ni:0,B7oj6ja:0,Dimara:"f1qtlz2s",a9b677:"f64fuq3",Bqenvij:"fjamq6b",Bg96gwp:"f1n95isl",By8wz76:"fq1p4f3",Bcq6wej:"fcwbuzc",Jcjdmf:["f1iyvy17","fu9dqmu"],sc4o1m:"fa5hmw6",Bosien3:["fu9dqmu","f1iyvy17"],B7iucu3:"fygpdla",B8gzw0y:"f1h3a8gf"}},{d:[".f22iagw{display:flex;}",".f4d9j23{justify-content:center;}",".f122n59{align-items:center;}",".ffp7eso{background-color:var(--colorBrandBackground);}",[".f1qtlz2s{border-radius:100%;}",{p:-1}],".f64fuq3{width:20px;}",".fjamq6b{height:20px;}",".f1n95isl{line-height:20px;}"],m:[["@media (forced-colors: active){.fq1p4f3{background-color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fcwbuzc{border-top-color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1iyvy17{border-right-color:WindowText;}.fu9dqmu{border-left-color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fa5hmw6{border-bottom-color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fygpdla{color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1h3a8gf{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}]]}),ine=ke({base:{abs64n:"fk73vx1",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1a3p1vp",Bkecrkj:"f1aehjj5",qhf8xq:"f1euv43f"}},{d:[".fk73vx1{opacity:0;}",[".f1a3p1vp{overflow:hidden;}",{p:-1}],".f1aehjj5{pointer-events:none;}",".f1euv43f{position:absolute;}"]}),ane=ke({base:{B6of3ja:"flykjtj",abs64n:"fk73vx1",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1a3p1vp",Bkecrkj:"f1aehjj5",qhf8xq:"f1euv43f"}},{d:[".flykjtj{margin-top:-28px;}",".fk73vx1{opacity:0;}",[".f1a3p1vp{overflow:hidden;}",{p:-1}],".f1aehjj5{pointer-events:none;}",".f1euv43f{position:absolute;}"]}),sne=ke({base:{De3pzq:"fnggedw",Beyfa6y:0,Bbmb7ep:0,Btl43ni:0,B7oj6ja:0,Dimara:"f1qtlz2s",B5kzvoi:"f1oq0udb",Bqenvij:"f6ywr7j",oyh7mz:["f1vgc2s3","f1e31b4d"],jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:"fcpdi13",qhf8xq:"f1euv43f",j35jbq:["f1e31b4d","f1vgc2s3"],a9b677:"faro0ui",By8wz76:"fq1p4f3",B8gzw0y:"f1h3a8gf"}},{d:[".fnggedw{background-color:var(--colorBrandForeground2);}",[".f1qtlz2s{border-radius:100%;}",{p:-1}],".f1oq0udb{bottom:1px;}",".f6ywr7j{height:4px;}",".f1vgc2s3{left:0;}",".f1e31b4d{right:0;}",[".fcpdi13{margin:auto;}",{p:-1}],".f1euv43f{position:absolute;}",".faro0ui{width:4px;}"],m:[["@media (forced-colors: active){.fq1p4f3{background-color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1h3a8gf{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}]]}),lne=ke({corners:{Cy64m2:["f1yxjewa","f5xfyye"],Bnn43bw:["f1kpdnd7","fokqrni"],feanbc:["f127emps","f1s6s1el"],B4268ip:["f39vr2a","frpqyrn"]}},{d:[".f1yxjewa.fui-CalendarDayGrid__topRightCornerDate{border-top-right-radius:var(--borderRadiusMedium);}",".f5xfyye.fui-CalendarDayGrid__topRightCornerDate{border-top-left-radius:var(--borderRadiusMedium);}",".f1kpdnd7.fui-CalendarDayGrid__topLeftCornerDate{border-top-left-radius:var(--borderRadiusMedium);}",".fokqrni.fui-CalendarDayGrid__topLeftCornerDate{border-top-right-radius:var(--borderRadiusMedium);}",".f127emps.fui-CalendarDayGrid__bottomRightCornerDate{border-bottom-right-radius:var(--borderRadiusMedium);}",".f1s6s1el.fui-CalendarDayGrid__bottomRightCornerDate{border-bottom-left-radius:var(--borderRadiusMedium);}",".f39vr2a.fui-CalendarDayGrid__bottomLeftCornerDate{border-bottom-left-radius:var(--borderRadiusMedium);}",".frpqyrn.fui-CalendarDayGrid__bottomLeftCornerDate{border-bottom-right-radius:var(--borderRadiusMedium);}"]}),cne=e=>{"use no memo";const r=Ure(),t=Xre(),n=Gre(),s=Kre(),o=Yre(),i=Qre(),c=Zre(),l=Jre(),a=ene(),u=tne(),h=rne(),d=nne(),f=ine(),m=ane(),p=sne(),g=lne(),b=one(),{lightenDaysOutsideNavigatedMonth:y,showWeekNumbers:w}=e;return{wrapper:de(Hn.wrapper,r.base),table:de(Hn.table,t.base,w&&t.showWeekNumbers),dayCell:de(Hn.dayCell,n.base,n.focusIndicator,g.corners),daySelected:de(Hn.daySelected,s.base),daySingleSelected:de(Hn.daySingleSelected,o.base),weekRow:de(Hn.weekRow,i.base),weekDayLabelCell:de(Hn.weekDayLabelCell,c.base),weekNumberCell:de(Hn.weekNumberCell,l.base),dayOutsideBounds:de(Hn.dayOutsideBounds,a.base),dayOutsideNavigatedMonth:de(Hn.dayOutsideNavigatedMonth,y&&u.lightenDaysOutsideNavigatedMonth),dayButton:de(Hn.dayButton,h.base),dayIsToday:de(Hn.dayIsToday,d.base),firstTransitionWeek:de(Hn.firstTransitionWeek,f.base),lastTransitionWeek:de(Hn.lastTransitionWeek,m.base),dayMarker:de(Hn.dayMarker,p.base),dayTodayMarker:de(Hn.dayTodayMarker,b.base)}},une=e=>{const{showWeekNumbers:r,strings:t,firstDayOfWeek:n,allFocusable:s,weeksToShow:o,weeks:i,classNames:c}=e,l=t.shortDays.slice();let a=-1;const u=i[1];for(let h=0;h<i[1].length;h++)if(u[h].originalDate.getDate()===1){a=h;break}if(o===1&&a>=0){const h=(a+n)%td;l[h]=t.shortMonths[i[1][a].originalDate.getMonth()]}return A.createElement("tr",null,r&&A.createElement("th",{className:c.dayCell}),l.map((h,d)=>{const f=(d+n)%td,m=t.days[f];return A.createElement(ev.In,{key:l[f]+" "+d,duration:Gt.durationGentle},A.createElement("th",{className:de(c.dayCell,c.weekDayLabelCell),scope:"col",title:m,"aria-label":m,tabIndex:s?0:void 0},l[f]))}))},dne=e=>{"use no memo";const{navigatedDate:r,dateTimeFormatter:t,allFocusable:n,strings:s,activeDescendantId:o,navigatedDayRef:i,calculateRoundedStyles:c,weeks:l,classNames:a,day:u,dayIndex:h,weekIndex:d,weekCorners:f,ariaHidden:m,customDayCellRef:p,dateRangeType:g,daysToSelectInDayView:b,onSelectDate:y,restrictedDates:w,minDate:C,maxDate:N,onNavigateDate:I,getDayInfosInRangeOfDay:$,getRefsFromDayInfos:D}=e;var F;const V=(F=f?.[d+"_"+h])!==null&&F!==void 0?F:"",G=Sa(r,u.originalDate),{dir:U}=Yt(),E=(P,O)=>{let X,K=1;if(P.key===rs?(X=O5(O,-1),K=-1):P.key===Ta?X=O5(O,1):P.key===Yw(ms,U)?(X=No(O,-1),K=-1):P.key===Yw(gs,U)&&(X=No(O,1)),!X)return;const J={initialDate:O,targetDate:X,direction:K,restrictedDates:w,minDate:C,maxDate:N};let H=L5(J);H||(J.direction=-K,H=L5(J)),!(l&&H&&l.slice(1,l.length-1).some(L=>L.some(q=>Sa(q.originalDate,H))))&&H&&(I(H,!0),P.preventDefault())},M=P=>{const O=$(u),X=D(O);X.forEach((K,J)=>{if(K&&(K.classList.add(xu.hoverStyle),!O[J].isSelected&&g===fo.Day&&b&&b>1)){K.classList.remove(Ko.bottomLeftCornerDate,Ko.bottomRightCornerDate,Ko.topLeftCornerDate,Ko.topRightCornerDate);const H=c(!1,!1,J>0,J<X.length-1).trim();H&&K.classList.add(...H.trim().split(" "))}})},B=P=>{const O=$(u);D(O).forEach(K=>{K&&K.classList.add(xu.pressedStyle)})},k=P=>{const O=$(u);D(O).forEach(K=>{K&&K.classList.remove(xu.pressedStyle)})},_=P=>{const O=$(u),X=D(O);X.forEach((K,J)=>{if(K&&(K.classList.remove(xu.hoverStyle),K.classList.remove(xu.pressedStyle),!O[J].isSelected&&g===fo.Day&&b&&b>1)){const H=c(!1,!1,J>0,J<X.length-1).trim();H&&K.classList.remove(...H.trim().split(" "))}})},S=P=>{P.key===gn?y?.(u.originalDate):E(P,u.originalDate)};let T=u.originalDate.getDate()+", "+s.months[u.originalDate.getMonth()]+", "+u.originalDate.getFullYear();u.isMarked&&(T=T+", "+s.dayMarkedAriaLabel);const z=!m&&(n||(u.isInBounds?!0:void 0));return A.createElement("td",{className:de(a.dayCell,f&&V,u.isSelected&&!u.isSingleSelected&&a.daySelected,u.isSingleSelected&&a.daySingleSelected,!u.isInBounds&&a.dayOutsideBounds,!u.isInMonth&&a.dayOutsideNavigatedMonth),ref:P=>{p?.(P,u.originalDate,a),u.setRef(P),G&&(i.current=P)},"aria-disabled":!m&&!u.isInBounds,onClick:u.isInBounds&&!m?u.onSelected:void 0,onMouseOver:m?void 0:M,onMouseDown:m?void 0:B,onMouseUp:m?void 0:k,onMouseOut:m?void 0:_,onKeyDown:m?void 0:S,role:"gridcell",tabIndex:G||z?0:void 0,"aria-current":u.isToday?"date":void 0,"aria-selected":u.isInBounds?u.isSelected:void 0},A.createElement("button",{key:u.key+"button",className:de(a.dayButton,u.isToday&&a.dayIsToday),"aria-label":T,id:G?o:void 0,disabled:!m&&!u.isInBounds,type:"button",tabIndex:-1},A.createElement("span",{className:u.isToday?de(a.dayTodayMarker):void 0},t.formatDay(u.originalDate)),u.isMarked&&A.createElement("div",{"aria-hidden":"true",className:a.dayMarker})))},ah=A.forwardRef((e,r)=>{const{ariaHidden:t,classNames:n,week:s,weeks:o,weekIndex:i,rowClassName:c,ariaRole:l,showWeekNumbers:a,firstDayOfWeek:u,firstWeekOfYear:h,navigatedDate:d,strings:f}=e,m=a?Mre(o.length,u,h,d):null,p=m?f.weekNumberFormatString&&f.weekNumberFormatString.replace("{0}",`${m[i]}`):"";return A.createElement("tr",{ref:r,role:l,"aria-hidden":t,className:c},a&&m&&A.createElement("th",{className:n.weekNumberCell,title:p,"aria-label":p,scope:"row"},A.createElement("span",null,m[i])),s.map((g,b)=>A.createElement(dne,{...e,key:g.key,day:g,dayIndex:b})))});ah.displayName="CalendarGridRow";function fne(e,r,t){return A.useMemo(()=>{var s;const o=Vre(e),i=o[1][0].originalDate,c=o[o.length-1][6].originalDate,l=((s=e.getMarkedDays)===null||s===void 0?void 0:s.call(e,i,c))||[],a=[];for(let u=0;u<o.length;u++){const h=[];for(let d=0;d<td;d++){const f=o[u][d],m={onSelected:()=>r(f.originalDate),setRef:t(f.key),...f,isMarked:f.isMarked||l?.some(p=>Sa(f.originalDate,p))};h.push(m)}a.push(h)}return a},[e])}const Dh="20px";function J_(e,r){const t=A.Children.only(e),n=Nt(r,gc(t));return A.cloneElement(t,{ref:n})}const Bp=A.forwardRef((e,r)=>{const{duration:t=Gt.durationSlower,easing:n=Gt.curveDecelerateMax,animationDirection:s=il.Vertical,animateBackwards:o=!1,replayKey:i,children:c}=e;let l="0px",a="0px";const u=o?`-${Dh}`:Dh;s===il.Horizontal?l=u:a=u;const h=J_(c,r),d=o?"back":"fwd";return A.createElement(rv.In,{key:d,duration:t,easing:n,outX:l,outY:a,replayKey:i},h)});Bp.displayName="DirectionalSlideIn";const hne=mh(({outY:e})=>{const r=Gt.durationSlower,t=Gt.curveDecelerateMax;return[to({direction:"exit",duration:r,easing:t}),uc({direction:"exit",duration:r,easing:t,outY:e})]}),vb=A.forwardRef((e,r)=>{const{edge:t,animationDirection:n=il.Vertical,animateBackwards:s,replayKey:o,children:i}=e,c=J_(i,r);if(!(n!==il.Horizontal&&s!==void 0&&(t==="first"?!s:s)))return c;const u=t==="first"?`-${Dh}`:Dh;return A.createElement(hne,{outY:u,replayKey:o},c)});vb.displayName="DirectionalSlideOut";function pne(){const e=A.useRef({});return[e,t=>n=>{n===null?delete e.current[t]:e.current[t]=n}]}function mne(e){const r=A.useRef(void 0);A.useEffect(()=>{r.current=e[0][0].originalDate});const t=r.current;if(!(!t||t.getTime()===e[0][0].originalDate.getTime()))return!(t<=e[0][0].originalDate)}const e7=e=>{const r=A.useRef(null),t=mr(),n=F=>{var V,G;const{firstDayOfWeek:U,minDate:E,maxDate:M,workWeekDays:B,daysToSelectInDayView:k,restrictedDates:_}=e,S={minDate:E,maxDate:M,restrictedDates:_};let T=Mh(F,f,U,B,k);T=Z_(T,E,M),T=T.filter(z=>!Iu(z,S)),(V=e.onSelectDate)===null||V===void 0||V.call(e,F,T),(G=e.onNavigateDate)===null||G===void 0||G.call(e,F,!0)},[s,o]=pne(),i=fne(e,n,o),c=mne(i),[l,a]=Wre(e);A.useImperativeHandle(e.componentRef,()=>({focus(){var F,V;(V=r.current)===null||V===void 0||(F=V.focus)===null||F===void 0||F.call(V)}}),[]);const u=F=>{const V=gne(e.dateRangeType,e.workWeekDays),G=Mh(F.originalDate,V,e.firstDayOfWeek,e.workWeekDays,e.daysToSelectInDayView).map(E=>E.getTime());return i.reduce((E,M)=>E.concat(M.filter(B=>G.indexOf(B.originalDate.getTime())!==-1)),[])},h=F=>{let V=[];return V=F.map(G=>s.current[G.key]),V},{gridLabel:d,dateRangeType:f,showWeekNumbers:m,labelledBy:p,lightenDaysOutsideNavigatedMonth:g,animationDirection:b=il.Vertical}=e,y=cne({lightenDaysOutsideNavigatedMonth:g===void 0?!0:g,showWeekNumbers:m}),w=l(i),C={weeks:i,navigatedDayRef:r,calculateRoundedStyles:a,activeDescendantId:t,classNames:y,weekCorners:w,getDayInfosInRangeOfDay:u,getRefsFromDayInfos:h},N=Mo({axis:"grid-linear"}),I=i[0],$=i[i.length-1],D=I[0].key;return A.createElement("table",{className:de(y.table,e.className),"aria-multiselectable":"false","aria-label":d,"aria-labelledby":p,"aria-activedescendant":t,role:"grid",...N},A.createElement("tbody",null,A.createElement(une,{...e,classNames:y,weeks:i}),A.createElement(vb,{edge:"first",replayKey:D,animationDirection:b,animateBackwards:c},A.createElement(ah,{...e,...C,week:I,weekIndex:-1,rowClassName:y.firstTransitionWeek,"aria-role":"presentation",ariaHidden:!0})),i.slice(1,i.length-1).map((F,V)=>A.createElement(Bp,{key:V,replayKey:D,animationDirection:b,animateBackwards:c},A.createElement(ah,{...e,...C,week:F,weekIndex:V,rowClassName:y.weekRow}))),A.createElement(vb,{edge:"last",replayKey:D,animationDirection:b,animateBackwards:c},A.createElement(ah,{...e,...C,week:$,weekIndex:-2,rowClassName:y.lastTransitionWeek,"aria-role":"presentation",ariaHidden:!0}))))};e7.displayName="CalendarDayGrid";function gne(e,r){if(r&&e===fo.WorkWeek){const t=r.slice().sort();let n=!0;for(let s=1;s<t.length;s++)if(t[s]!==t[s-1]+1){n=!1;break}if(!n||r.length===0)return fo.Week}return e}const Vl={root:"fui-CalendarDay",header:"fui-CalendarDay__header",monthAndYear:"fui-CalendarDay__monthAndYear",monthComponents:"fui-CalendarDay__monthComponents",headerIconButton:"fui-CalendarDay__headerIconButton",disabledStyle:"fui-CalendarDay__disabledStyle"},bne=ke({base:{B7ck84d:"f1e4lqlz",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1sy4kr4",a9b677:"f4m2ahc"},normalize:{E5pizo:"f1couhl3",B7ck84d:"f1ewtqcl",jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:"f1s184ao",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai"},showWeekNumbers:{a9b677:"fl524qk"}},{d:[".f1e4lqlz{box-sizing:content-box;}",[".f1sy4kr4{padding:12px;}",{p:-1}],".f4m2ahc{width:196px;}",".f1couhl3{box-shadow:none;}",".f1ewtqcl{box-sizing:border-box;}",[".f1s184ao{margin:0;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".fl524qk{width:226px;}"]}),vne=ke({base:{mc9l5x:"ftuwxu6",Bqenvij:"fxldao9",Bg96gwp:"f1vzymgo",qhf8xq:"f10pi13n",a9b677:"fly5x3f"}},{d:[".ftuwxu6{display:inline-flex;}",".fxldao9{height:28px;}",".f1vzymgo{line-height:44px;}",".f10pi13n{position:relative;}",".fly5x3f{width:100%;}"]}),yne=ke({base:{Bt984gj:"f122n59",De3pzq:"f1c21dwh",icvyot:"f1ern45e",vrafjx:["f1n71otn","f1deefiw"],oivjwe:"f1h8hb77",wvpqe5:["f1deefiw","f1n71otn"],Beyfa6y:0,Bbmb7ep:0,Btl43ni:0,B7oj6ja:0,Dimara:"ft85np5",sj55zd:"f19n0e5",mc9l5x:"f14t3ns0",Bh6795r:"fqerorx",Bahqtrf:"f1mo0ibp",Be2twd7:"fkhj508",Bhrd7zp:"fl43uef",Bg96gwp:"f336tjw",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1a3p1vp",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:["f1td8mcv","f1udkdxo"],fsow6f:["f1o700av","fes3tcz"],ygn44y:"f1cmbuwj",Huce71:"fz5stix"},headerIsClickable:{Jwef8y:"f18a0fwf",Bi91k9c:"f3sdaeg",eoavqd:"f8491dx",pugfm4:0,ukgb2i:0,Dwtyhm:0,Biisq0s:"f15rpok4",iro3zm:"f1wvkgvo",B2d53fq:"f1wdoaqd",c3iz72:"f13c0t7h",mghro0:0,Bx68yb:0,syojd9:0,E5hylx:"fy2scak"}},{d:[".f122n59{align-items:center;}",".f1c21dwh{background-color:var(--colorTransparentBackground);}",".f1ern45e{border-top-style:none;}",".f1n71otn{border-right-style:none;}",".f1deefiw{border-left-style:none;}",".f1h8hb77{border-bottom-style:none;}",[".ft85np5{border-radius:var(--borderRadiusMedium);}",{p:-1}],".f19n0e5{color:var(--colorNeutralForeground1);}",".f14t3ns0{display:inline-block;}",".fqerorx{flex-grow:1;}",".f1mo0ibp{font-family:inherit;}",".fkhj508{font-size:var(--fontSizeBase300);}",".fl43uef{font-weight:var(--fontWeightSemibold);}",".f336tjw{line-height:28px;}",[".f1a3p1vp{overflow:hidden;}",{p:-1}],[".f1td8mcv{padding:0 4px 0 10px;}",{p:-1}],[".f1udkdxo{padding:0 10px 0 4px;}",{p:-1}],".f1o700av{text-align:left;}",".fes3tcz{text-align:right;}",".f1cmbuwj{text-overflow:ellipsis;}",".fz5stix{white-space:nowrap;}"],h:[".f18a0fwf:hover{background-color:var(--colorBrandBackgroundInvertedHover);}",".f3sdaeg:hover{color:var(--colorBrandForegroundOnLightHover);}",".f8491dx:hover{cursor:pointer;}",[".f15rpok4:hover{outline:1px solid var(--colorTransparentStroke);}",{p:-1}],".f1wvkgvo:hover:active{background-color:var(--colorBrandBackgroundInvertedPressed);}",".f1wdoaqd:hover:active{color:var(--colorBrandForegroundOnLightPressed);}",".f13c0t7h:hover:active{cursor:pointer;}",[".fy2scak:hover:active{outline:1px solid var(--colorTransparentStroke);}",{p:-1}]]}),wne=ke({base:{qb2dma:"fpydfdc",mc9l5x:"ftuwxu6"}},{d:[".fpydfdc{align-self:flex-end;}",".ftuwxu6{display:inline-flex;}"]}),xne=ke({base:{De3pzq:"f1c21dwh",icvyot:"f1ern45e",vrafjx:["f1n71otn","f1deefiw"],oivjwe:"f1h8hb77",wvpqe5:["f1deefiw","f1n71otn"],Beyfa6y:0,Bbmb7ep:0,Btl43ni:0,B7oj6ja:0,Dimara:"ft85np5",sj55zd:"f11d4kpn",mc9l5x:"ftgm304",Bahqtrf:"f1mo0ibp",Be2twd7:"fy9rknc",Bqenvij:"fxldao9",Bg96gwp:"f336tjw",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1gl81tg",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai",qhf8xq:"f10pi13n",fsow6f:"f17mccla",a9b677:"f1w9dchk",Jwef8y:"f18a0fwf",Bi91k9c:"f3sdaeg",eoavqd:"f8491dx",pugfm4:0,ukgb2i:0,Dwtyhm:0,Biisq0s:"f15rpok4",iro3zm:"f1wvkgvo",B2d53fq:"f1wdoaqd"}},{d:[".f1c21dwh{background-color:var(--colorTransparentBackground);}",".f1ern45e{border-top-style:none;}",".f1n71otn{border-right-style:none;}",".f1deefiw{border-left-style:none;}",".f1h8hb77{border-bottom-style:none;}",[".ft85np5{border-radius:var(--borderRadiusMedium);}",{p:-1}],".f11d4kpn{color:var(--colorNeutralForeground3);}",".ftgm304{display:block;}",".f1mo0ibp{font-family:inherit;}",".fy9rknc{font-size:var(--fontSizeBase200);}",".fxldao9{height:28px;}",".f336tjw{line-height:28px;}",[".f1gl81tg{overflow:visible;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".f10pi13n{position:relative;}",".f17mccla{text-align:center;}",".f1w9dchk{width:28px;}"],h:[".f18a0fwf:hover{background-color:var(--colorBrandBackgroundInvertedHover);}",".f3sdaeg:hover{color:var(--colorBrandForegroundOnLightHover);}",".f8491dx:hover{cursor:pointer;}",[".f15rpok4:hover{outline:1px solid var(--colorTransparentStroke);}",{p:-1}],".f1wvkgvo:hover:active{background-color:var(--colorBrandBackgroundInvertedPressed);}",".f1wdoaqd:hover:active{color:var(--colorBrandForegroundOnLightPressed);}"]}),kne=ke({base:{Bg33ivm:"f1oelgmz",t69wg0:"fhh1ekj",Bnh7jwd:"fdb0nwj"}},{d:[".f1oelgmz,.f1oelgmz:disabled,.f1oelgmz button{color:var(--colorNeutralForegroundDisabled);}",".fhh1ekj,.fhh1ekj:disabled,.fhh1ekj button{pointer-events:none;}"],m:[["@media (forced-colors: active){.fdb0nwj,.fdb0nwj:disabled,.fdb0nwj button{color:GrayText;}}",{m:"(forced-colors: active)"}]]}),Sne=e=>{"use no memo";const r=bne(),t=vne(),n=yne(),s=wne(),o=xne(),i=kne(),{className:c,headerIsClickable:l,showWeekNumbers:a}=e;return{root:de(Vl.root,r.normalize,r.base,a&&r.showWeekNumbers,c),header:de(Vl.header,t.base),monthAndYear:de(Vl.monthAndYear,n.base,l&&n.headerIsClickable),monthComponents:de(Vl.monthComponents,s.base),headerIconButton:de(Vl.headerIconButton,o.base),disabledStyle:de(Vl.disabledStyle,i.base)}},t7=e=>{const r=A.useRef(null);A.useImperativeHandle(e.componentRef,()=>({focus(){var N,I;(I=r.current)===null||I===void 0||(N=I.focus)===null||N===void 0||N.call(I)}}),[]);const{strings:t,gridLabel:n,navigatedDate:s,dateTimeFormatter:o,className:i,onHeaderSelect:c,showSixWeeksByDefault:l,minDate:a,maxDate:u,restrictedDates:h,onNavigateDate:d,showWeekNumbers:f,dateRangeType:m,animationDirection:p=il.Vertical}=e,g=Sne({className:i,headerIsClickable:!!c,showWeekNumbers:f}),b=o.formatMonthYear(s,t),y=c?"button":"div",w=t.yearPickerHeaderAriaLabel?t.yearPickerHeaderAriaLabel.replace("{0}",b):b,{...C}=e;return A.createElement("div",{className:g.root},A.createElement("div",{className:g.header},A.createElement(y,{"aria-label":c?w:void 0,className:g.monthAndYear,onClick:c,tabIndex:c?0:-1,onKeyDown:sh(c),type:"button"},A.createElement("span",{"aria-live":"polite","aria-atomic":"true"},b)),A.createElement(r7,{...e,classNames:g})),A.createElement(e7,{...C,gridLabel:`${b}, ${n}`,componentRef:r,strings:t,navigatedDate:s,weeksToShow:l?6:void 0,dateTimeFormatter:o,minDate:a,maxDate:u,restrictedDates:h,onNavigateDate:d,dateRangeType:m}))};t7.displayName="CalendarDay";const r7=e=>{const{minDate:r,maxDate:t,navigatedDate:n,navigationIcons:s,allFocusable:o,strings:i,showCloseButton:c,classNames:l,onNavigateDate:a,onDismiss:u}=e,h=()=>{a(Ja(n,1),!1)},d=()=>{a(Ja(n,-1),!1)},f=r?eo(r,G_(n))<0:!0,m=t?eo(K_(n),t)<0:!0;return A.createElement("div",{className:l.monthComponents},A.createElement("button",{className:de(l.headerIconButton,!f&&l.disabledStyle),tabIndex:f?void 0:o?0:-1,"aria-disabled":!f,onClick:f?d:void 0,onKeyDown:f?sh(d):void 0,title:i.prevMonthAriaLabel?i.prevMonthAriaLabel+" "+i.months[Ja(n,-1).getMonth()]:void 0,type:"button"},s.upNavigation),A.createElement("button",{className:de(l.headerIconButton,!m&&l.disabledStyle),tabIndex:m?void 0:o?0:-1,"aria-disabled":!m,onClick:m?h:void 0,onKeyDown:m?sh(h):void 0,title:i.nextMonthAriaLabel?i.nextMonthAriaLabel+" "+i.months[Ja(n,1).getMonth()]:void 0,type:"button"},s.downNavigation),c&&A.createElement("button",{className:l.headerIconButton,onClick:u,onKeyDown:sh(u),title:i.closeButtonAriaLabel,type:"button"},s.dismiss))};r7.displayName="CalendarDayNavigationButtons";const sh=e=>r=>{r.key===gn&&e?.()},mi={root:"fui-CalendarPicker",headerContainer:"fui-CalendarPicker__headerContainer",currentItemButton:"fui-CalendarPicker__currentItemButton",navigationButtonsContainer:"fui-CalendarPicker__navigationButtonsContainer",navigationButton:"fui-CalendarPicker__navigationButton",gridContainer:"fui-CalendarPicker__gridContainer",buttonRow:"fui-CalendarPicker__buttonRow",itemButton:"fui-CalendarPicker__itemButton",current:"fui-CalendarPicker__current",selected:"fui-CalendarPicker__selected",disabled:"fui-CalendarPicker__disabled"},_ne=ke({base:{B7ck84d:"f1e4lqlz",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1a3p1vp",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1sy4kr4",a9b677:"f4m2ahc"},normalize:{E5pizo:"f1couhl3",B7ck84d:"f1ewtqcl",jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:"f1s184ao",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai"}},{d:[".f1e4lqlz{box-sizing:content-box;}",[".f1a3p1vp{overflow:hidden;}",{p:-1}],[".f1sy4kr4{padding:12px;}",{p:-1}],".f4m2ahc{width:196px;}",".f1couhl3{box-shadow:none;}",".f1ewtqcl{box-sizing:border-box;}",[".f1s184ao{margin:0;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}]]}),Cne=ke({base:{mc9l5x:"f22iagw"}},{d:[".f22iagw{display:flex;}"]}),Tne=ke({base:{De3pzq:"f1c21dwh",icvyot:"f1ern45e",vrafjx:["f1n71otn","f1deefiw"],oivjwe:"f1h8hb77",wvpqe5:["f1deefiw","f1n71otn"],Beyfa6y:0,Bbmb7ep:0,Btl43ni:0,B7oj6ja:0,Dimara:"ft85np5",sj55zd:"f1ym3bx4",Bh6795r:"fqerorx",Bahqtrf:"f1mo0ibp",Be2twd7:"fkhj508",Bhrd7zp:"fl43uef",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1gl81tg",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:["f1td8mcv","f1udkdxo"],fsow6f:["f1o700av","fes3tcz"]},hasHeaderClickCallback:{Jwef8y:"f18a0fwf",Bi91k9c:"f3sdaeg",eoavqd:"f8491dx",pugfm4:0,ukgb2i:0,Dwtyhm:0,Biisq0s:"f15rpok4",iro3zm:"f1wvkgvo",B2d53fq:"f1wdoaqd",c3iz72:"f13c0t7h",mghro0:0,Bx68yb:0,syojd9:0,E5hylx:"fy2scak"}},{d:[".f1c21dwh{background-color:var(--colorTransparentBackground);}",".f1ern45e{border-top-style:none;}",".f1n71otn{border-right-style:none;}",".f1deefiw{border-left-style:none;}",".f1h8hb77{border-bottom-style:none;}",[".ft85np5{border-radius:var(--borderRadiusMedium);}",{p:-1}],".f1ym3bx4{color:inherit;}",".fqerorx{flex-grow:1;}",".f1mo0ibp{font-family:inherit;}",".fkhj508{font-size:var(--fontSizeBase300);}",".fl43uef{font-weight:var(--fontWeightSemibold);}",[".f1gl81tg{overflow:visible;}",{p:-1}],[".f1td8mcv{padding:0 4px 0 10px;}",{p:-1}],[".f1udkdxo{padding:0 10px 0 4px;}",{p:-1}],".f1o700av{text-align:left;}",".fes3tcz{text-align:right;}"],h:[".f18a0fwf:hover{background-color:var(--colorBrandBackgroundInvertedHover);}",".f3sdaeg:hover{color:var(--colorBrandForegroundOnLightHover);}",".f8491dx:hover{cursor:pointer;}",[".f15rpok4:hover{outline:1px solid var(--colorTransparentStroke);}",{p:-1}],".f1wvkgvo:hover:active{background-color:var(--colorBrandBackgroundInvertedPressed);}",".f1wdoaqd:hover:active{color:var(--colorBrandForegroundOnLightPressed);}",".f13c0t7h:hover:active{cursor:pointer;}",[".fy2scak:hover:active{outline:1px solid var(--colorTransparentStroke);}",{p:-1}]]}),Bne=ke({base:{Bt984gj:"f122n59",mc9l5x:"f22iagw"}},{d:[".f122n59{align-items:center;}",".f22iagw{display:flex;}"]}),jne=ke({base:{De3pzq:"f1c21dwh",Bgfg5da:0,B9xav0g:0,oivjwe:0,Bn0qgzm:0,B4g9neb:0,zhjwy3:0,wvpqe5:0,ibv6hh:0,u1mtju:0,h3c5rm:0,vrafjx:0,Bekrc4i:0,i8vvqc:0,g2u3we:0,icvyot:0,B4j52fo:0,irswps:"f3bhgqh",Beyfa6y:0,Bbmb7ep:0,Btl43ni:0,B7oj6ja:0,Dimara:"ft85np5",sj55zd:"f19n0e5",mc9l5x:"ftgm304",Bahqtrf:"f1mo0ibp",Be2twd7:"fy9rknc",Bqenvij:"fxldao9",Bg96gwp:"f336tjw",sshi5w:"f1ysfysz",Bf4jedk:"f107v6xj",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1gl81tg",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai",qhf8xq:"f10pi13n",fsow6f:"f17mccla",a9b677:"f1w9dchk",Jwef8y:"f18a0fwf",Bi91k9c:"f3sdaeg",eoavqd:"f8491dx",pugfm4:0,ukgb2i:0,Dwtyhm:0,Biisq0s:"f15rpok4",iro3zm:"f1wvkgvo",B2d53fq:"f1wdoaqd"}},{d:[".f1c21dwh{background-color:var(--colorTransparentBackground);}",[".f3bhgqh{border:none;}",{p:-2}],[".ft85np5{border-radius:var(--borderRadiusMedium);}",{p:-1}],".f19n0e5{color:var(--colorNeutralForeground1);}",".ftgm304{display:block;}",".f1mo0ibp{font-family:inherit;}",".fy9rknc{font-size:var(--fontSizeBase200);}",".fxldao9{height:28px;}",".f336tjw{line-height:28px;}",".f1ysfysz{min-height:28px;}",".f107v6xj{min-width:28px;}",[".f1gl81tg{overflow:visible;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".f10pi13n{position:relative;}",".f17mccla{text-align:center;}",".f1w9dchk{width:28px;}"],h:[".f18a0fwf:hover{background-color:var(--colorBrandBackgroundInvertedHover);}",".f3sdaeg:hover{color:var(--colorBrandForegroundOnLightHover);}",".f8491dx:hover{cursor:pointer;}",[".f15rpok4:hover{outline:1px solid var(--colorTransparentStroke);}",{p:-1}],".f1wvkgvo:hover:active{background-color:var(--colorBrandBackgroundInvertedPressed);}",".f1wdoaqd:hover:active{color:var(--colorBrandForegroundOnLightPressed);}"]}),Nne=ke({base:{B6of3ja:"fvjh0tl"}},{d:[".fvjh0tl{margin-top:4px;}"]}),Ene=ke({base:{jrapky:"f15tpi3i",sw9gdo:"f1gdbdba"}},{d:[".f15tpi3i{margin-bottom:16px;}",".f1gdbdba:last-of-type{margin-bottom:0;}"]}),Ane=ke({base:{De3pzq:"f1c21dwh",Bgfg5da:0,B9xav0g:0,oivjwe:0,Bn0qgzm:0,B4g9neb:0,zhjwy3:0,wvpqe5:0,ibv6hh:0,u1mtju:0,h3c5rm:0,vrafjx:0,Bekrc4i:0,i8vvqc:0,g2u3we:0,icvyot:0,B4j52fo:0,irswps:"f3bhgqh",Beyfa6y:0,Bbmb7ep:0,Btl43ni:0,B7oj6ja:0,Dimara:"ft85np5",sj55zd:"f11d4kpn",Bahqtrf:"f1mo0ibp",Be2twd7:"fy9rknc",Bqenvij:"fbhnoac",Bg96gwp:"fc76cdq",sshi5w:"f1w5jphr",Bf4jedk:"f12clzc2",jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:["f1ytixos","fqk6p8t"],B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1gl81tg",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai",a9b677:"feqmc2u",Btgfwho:["f65zstl","f1yt3tqw"],xrote9:"flfbxit",Bja5ulm:"ff5vbxt",Jwef8y:"f18a0fwf",Bi91k9c:"f1u69ym5",eoavqd:"f8491dx",pugfm4:0,ukgb2i:0,Dwtyhm:0,Biisq0s:"f15rpok4",Bbkh6qg:"fse5cfe",Bahaeuw:"f1d0gba8",fmph8g:"fj239l",Bv6y5q5:0,uq1ffc:0,Bokaozi:0,Bfrni1f:"f1szuehs",iro3zm:"f1wvkgvo",rxnm8d:"f1n99sc9",Dcq74g:"fqfbdvs",Bs60fxl:"f12gwge8"}},{d:[".f1c21dwh{background-color:var(--colorTransparentBackground);}",[".f3bhgqh{border:none;}",{p:-2}],[".ft85np5{border-radius:var(--borderRadiusMedium);}",{p:-1}],".f11d4kpn{color:var(--colorNeutralForeground3);}",".f1mo0ibp{font-family:inherit;}",".fy9rknc{font-size:var(--fontSizeBase200);}",".fbhnoac{height:40px;}",".fc76cdq{line-height:40px;}",".f1w5jphr{min-height:40px;}",".f12clzc2{min-width:40px;}",[".f1ytixos{margin:0 12px 0 0;}",{p:-1}],[".fqk6p8t{margin:0 0 0 12px;}",{p:-1}],[".f1gl81tg{overflow:visible;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".feqmc2u{width:40px;}",".f65zstl:nth-child(4n + 4){margin-right:0;}",".f1yt3tqw:nth-child(4n + 4){margin-left:0;}",".flfbxit:nth-child(n + 9){margin-bottom:0;}",".ff5vbxt div{font-weight:var(--fontWeightRegular);}"],h:[".f18a0fwf:hover{background-color:var(--colorBrandBackgroundInvertedHover);}",".f1u69ym5:hover{color:var(--colorNeutralForeground1Static);}",".f8491dx:hover{cursor:pointer;}",[".f15rpok4:hover{outline:1px solid var(--colorTransparentStroke);}",{p:-1}],".f1wvkgvo:hover:active{background-color:var(--colorBrandBackgroundInvertedPressed);}"],m:[["@media (forced-colors: active){.fse5cfe:hover{background-color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1d0gba8:hover{color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fj239l:hover{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1szuehs:hover{outline:1px solid Highlight;}}",{p:-1,m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1n99sc9:hover:active{background-color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fqfbdvs:hover:active{color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f12gwge8:hover:active{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}]]}),Rne=ke({highlightCurrent:{De3pzq:"ffp7eso",sj55zd:"f1phragk",Bhrd7zp:"fl43uef",By8wz76:"fq1p4f3",B7iucu3:"fygpdla",B8gzw0y:"f1h3a8gf",mk428o:"ffic4m0",B1lrsqs:"f13lyc4l",B1piyhd:"f1cnwl3o",of3gr0:"f1w17wdy",hvfrz3:"fx2qnub"}},{d:[".ffp7eso{background-color:var(--colorBrandBackground);}",".f1phragk{color:var(--colorNeutralForegroundOnBrand);}",".fl43uef{font-weight:var(--fontWeightSemibold);}"],m:[["@media (forced-colors: active){.fq1p4f3{background-color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fygpdla{color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1h3a8gf{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1cnwl3o:hover,.f1cnwl3o:hover:active{background-color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1w17wdy:hover,.f1w17wdy:hover:active{color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fx2qnub:hover,.fx2qnub:hover:active{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}]],h:[".ffic4m0:hover,.ffic4m0:hover:active{background-color:var(--colorBrandBackground);}",".f13lyc4l:hover,.f13lyc4l:hover:active{color:var(--colorNeutralForegroundOnBrand);}"]}),zne=ke({highlightSelected:{De3pzq:"f1vevd59",sj55zd:"ff5vbop",Bhrd7zp:"fl43uef",By8wz76:"f1nz3ub2",B7iucu3:"fygpdla",B8gzw0y:"f1h3a8gf",Bja5ulm:"fospawf",Jwef8y:"fbo057p",Bi91k9c:"f1u69ym5",Bbkh6qg:"f1tx4pjd",Bahaeuw:"fn03n9l",fmph8g:"fj239l",iro3zm:"f1wvkgvo"}},{d:[".f1vevd59{background-color:var(--colorBrandBackgroundInvertedSelected);}",".ff5vbop{color:var(--colorNeutralForeground1Static);}",".fl43uef{font-weight:var(--fontWeightSemibold);}",".fospawf div{font-weight:var(--fontWeightSemibold);}"],m:[["@media (forced-colors: active){.f1nz3ub2{background-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fygpdla{color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1h3a8gf{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1tx4pjd:hover{background-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fn03n9l:hover{color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fj239l:hover{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}]],h:[".fbo057p:hover{background-color:var(--colorBrandBackgroundInvertedSelected);}",".f1u69ym5:hover{color:var(--colorNeutralForeground1Static);}",".f1wvkgvo:hover:active{background-color:var(--colorBrandBackgroundInvertedPressed);}"]}),Ine=ke({base:{Bg33ivm:"f1oelgmz",t69wg0:"fhh1ekj",B7iucu3:"f1cyfu5x",B8gzw0y:"f1h3a8gf"}},{d:[".f1oelgmz,.f1oelgmz:disabled,.f1oelgmz button{color:var(--colorNeutralForegroundDisabled);}",".fhh1ekj,.fhh1ekj:disabled,.fhh1ekj button{pointer-events:none;}"],m:[["@media (forced-colors: active){.f1cyfu5x{color:GrayText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1h3a8gf{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}]]}),n7=e=>{"use no memo";const r=_ne(),t=Cne(),n=Tne(),s=Bne(),o=jne(),i=Nne(),c=Ene(),l=Ane(),a=Rne(),u=zne(),h=Ine(),{className:d,hasHeaderClickCallback:f,highlightCurrent:m,highlightSelected:p}=e;return{root:de(mi.root,r.normalize,r.base,d),headerContainer:de(mi.headerContainer,t.base),currentItemButton:de(mi.currentItemButton,n.base,f&&n.hasHeaderClickCallback),navigationButtonsContainer:de(mi.navigationButtonsContainer,s.base),navigationButton:de(mi.navigationButton,o.base),gridContainer:de(mi.gridContainer,i.base),buttonRow:de(mi.buttonRow,c.base),itemButton:de(mi.itemButton,l.base),selected:de(mi.selected,p&&u.highlightSelected),current:de(mi.current,m&&a.highlightCurrent),disabled:de(mi.disabled,h.base)}},dl=e=>{"use no memo";return n7(e)},nc=12,H5=4,o7={prevRangeAriaLabel:void 0,nextRangeAriaLabel:void 0},i7=e=>{const{className:r,highlightCurrentYear:t,highlightSelectedYear:n,year:s,selected:o,disabled:i,componentRef:c,onSelectYear:l,onRenderYear:a}=e,u=A.useRef(null);A.useImperativeHandle(c,()=>({focus(){var p,g;(g=u.current)===null||g===void 0||(p=g.focus)===null||p===void 0||p.call(g)}}),[]);const h=()=>{l?.(s)},d=p=>{p.key===gn&&l?.(s)},f=dl({className:r,highlightCurrent:t,highlightSelected:n});var m;return A.createElement("button",{className:de(f.itemButton,o&&f.selected,i&&f.disabled),type:"button",role:"gridcell",onClick:i?void 0:h,onKeyDown:i?void 0:d,disabled:i,"aria-selected":o,ref:u},(m=a?.(s))!==null&&m!==void 0?m:s)};i7.displayName="CalendarYearGridCell";const a7=e=>{const{className:r,fromYear:t,toYear:n,animationDirection:s,animateBackwards:o,minYear:i,maxYear:c,onSelectYear:l,selectedYear:a,componentRef:u}=e,h=A.useRef(null),d=A.useRef(null);A.useImperativeHandle(u,()=>({focus(){var C,N;(N=h.current||d.current)===null||N===void 0||(C=N.focus)===null||C===void 0||C.call(N)}}),[]);const f=C=>{const N=C===a,I=i!==void 0&&C<i||c!==void 0&&C>c,$=C===new Date().getFullYear();return A.createElement(i7,{...e,key:C,year:C,selected:N,current:$,disabled:I,onSelectYear:l,componentRef:N?h:$?d:void 0})},m=dl({className:r}),p=C=>{var N,I;return(I=(N=e.onRenderYear)===null||N===void 0?void 0:N.call(e,C))!==null&&I!==void 0?I:C},g=`${p(t)} - ${p(n)}`;let b=t;const y=[];for(let C=0;C<(n-t+1)/H5;C++){y.push([]);for(let N=0;N<H5;N++)y[C].push(f(b)),b++}const w=Mo({axis:"grid"});return A.createElement("div",{...w,className:m.gridContainer,role:"grid","aria-label":g},y.map((C,N)=>A.createElement(Bp,{key:N,replayKey:t,animationDirection:s,animateBackwards:o},A.createElement("div",{role:"row",className:m.buttonRow},C))))};a7.displayName="CalendarYearGrid";const Ls={Previous:0,Next:1},yb=e=>{const{className:r,strings:t=o7,direction:n,onSelectPrev:s,onSelectNext:o,fromYear:i,toYear:c,maxYear:l,minYear:a,navigationIcons:u}=e,h=dl({className:r}),d=n===Ls.Previous?t.prevRangeAriaLabel:t.nextRangeAriaLabel,f=n===Ls.Previous?-nc:nc,m={fromYear:i+f,toYear:c+f},p=d?typeof d=="string"?d:d(m):void 0,g=n===Ls.Previous?a!==void 0&&i<a:l!==void 0&&e.fromYear+nc>l,b=()=>{n===Ls.Previous?s?.():o?.()},y=w=>{w.key===gn&&b()};return A.createElement("button",{className:de(h.navigationButton,g&&h.disabled),"aria-disabled":g,tabIndex:g?-1:void 0,onClick:g?void 0:b,onKeyDown:g?void 0:y,type:"button",title:p},n===Ls.Previous?u.upNavigation:u.downNavigation)};yb.displayName="CalendarYearNavArrow";const s7=e=>{const{className:r}=e,t=dl({className:r});return A.createElement("div",{className:t.navigationButtonsContainer},A.createElement(yb,{...e,direction:Ls.Previous}),A.createElement(yb,{...e,direction:Ls.Next}))};s7.displayName="CalendarYearNav";const l7=e=>{const{className:r,fromYear:t,toYear:n,strings:s=o7,animateBackwards:o,animationDirection:i}=e,c=()=>{var h;(h=e.onHeaderSelect)===null||h===void 0||h.call(e,!0)},l=h=>{(h.key===gn||h.key===In)&&c()},a=h=>{var d,f;return(f=(d=e.onRenderYear)===null||d===void 0?void 0:d.call(e,h))!==null&&f!==void 0?f:h},u=dl({className:r,hasHeaderClickCallback:!!e.onHeaderSelect});if(e.onHeaderSelect){const h=s.rangeAriaLabel,d=s.headerAriaLabelFormatString,f=h?typeof h=="string"?h:h(e):void 0,m=d?d.replace("{0}",f??""):f;return A.createElement("button",{className:u.currentItemButton,onClick:c,onKeyDown:l,"aria-label":m,role:"button",type:"button"},A.createElement("span",{"aria-live":"assertive","aria-atomic":"true"},a(t)," - ",a(n)))}return A.createElement("div",{className:u.current},a(t)," - ",a(n))};l7.displayName="CalendarYearTitle";const c7=e=>{const{className:r,animateBackwards:t,animationDirection:n,onRenderTitle:s}=e,o=dl({className:r,hasHeaderClickCallback:!!e.onHeaderSelect});var i;return A.createElement("div",{className:o.headerContainer},(i=s?.(e))!==null&&i!==void 0?i:A.createElement(l7,e),A.createElement(s7,e))};c7.displayName="CalendarYearHeader";function Mne(e){const r=A.useRef(void 0);A.useEffect(()=>{r.current=e});const t=r.current;if(!(t===void 0||t===e))return t>e}function Dne({selectedYear:e,navigatedYear:r,onNavigateDate:t}){const n=A.useMemo(()=>e||r||Math.floor(new Date().getFullYear()/10)*10,[r,e]),[s,o]=A.useState(n),i=()=>{const a=s+nc;o(a),t?.(a)},c=()=>{const a=s-nc;o(a),t?.(a)};A.useEffect(()=>{o(n)},[n]);const l=s+nc-1;return[s,l,i,c]}const u7=e=>{const[r,t,n,s]=Dne(e),o=Mne(r),i=A.useRef(null);A.useImperativeHandle(e.componentRef,()=>({focus(){var a,u;(u=i.current)===null||u===void 0||(a=u.focus)===null||a===void 0||a.call(u)}}));const{className:c}=e,l=dl({className:c});return A.createElement("div",{className:l.root},A.createElement(c7,{...e,fromYear:r,toYear:t,onSelectPrev:s,onSelectNext:n,animateBackwards:o}),A.createElement(a7,{...e,fromYear:r,toYear:t,animateBackwards:o,componentRef:i}))};u7.displayName="CalendarYear";const Pne=e=>{"use no memo";return n7(e)},$f=4;function One({navigatedDate:e}){const r=e.getFullYear(),t=A.useRef(void 0);A.useEffect(()=>{t.current=r});const n=t.current;if(!(n===void 0||n===r))return n>r}function Fne({componentRef:e}){const r=A.useRef(null),t=A.useRef(null),n=A.useRef(!1),s=A.useCallback(()=>{t.current?t.current.focus():r.current&&r.current.focus()},[]);return A.useImperativeHandle(e,()=>({focus:s}),[s]),A.useEffect(()=>{n.current&&(s(),n.current=!1)}),[r,t,()=>{n.current=!0}]}const d7=e=>{const{allFocusable:r,animationDirection:t=il.Vertical,className:n,componentRef:s,dateTimeFormatter:o=U_,highlightCurrentMonth:i,highlightSelectedMonth:c,maxDate:l,minDate:a,navigatedDate:u,navigationIcons:h,onHeaderSelect:d,onNavigateDate:f,selectedDate:m,strings:p,today:g=new Date,yearPickerHidden:b=!1}=e,[y,w,C]=Fne({componentRef:s}),[N,I]=A.useState(!1),$=One({navigatedDate:u}),D=X=>()=>G(X),F=()=>{f(Ql(u,1),!1)},V=()=>{f(Ql(u,-1),!1)},G=X=>{d?.(),f(Lf(u,X),!0)},U=()=>{b?d?.():(C(),I(!0))},E=X=>{if(C(),u.getFullYear()!==X){let J=new Date(u.getTime());J.setFullYear(X),l&&J>l?J=Lf(J,l.getMonth()):a&&J<a&&(J=Lf(J,a.getMonth())),f(J,!0)}I(!1)},M=X=>{C(),I(!1)},B=o,k=a?eo(a,Rre(u))<0:!0,_=l?eo(zre(u),l)<0:!0,S=Pne({className:n,hasHeaderClickCallback:!!d||!b,highlightCurrent:i,highlightSelected:c}),T=Mo({axis:"grid"});if(N){const[X,K]=qne({dateTimeFormatter:o,navigatedDate:u,strings:p});return A.createElement(u7,{key:"calendarYear",minYear:a?a.getFullYear():void 0,maxYear:l?l.getFullYear():void 0,onSelectYear:E,onHeaderSelect:M,selectedYear:m?m.getFullYear():u?u.getFullYear():void 0,navigatedYear:u.getFullYear(),navigationIcons:h,onRenderYear:X,strings:K,componentRef:w,highlightCurrentYear:i,highlightSelectedYear:c,animationDirection:t})}const z=[];for(let X=0;X<p.shortMonths.length/$f;X++)z.push(X);const P=B.formatYear(u),O=p.monthPickerHeaderAriaLabel?p.monthPickerHeaderAriaLabel.replace("{0}",P):P;return A.createElement("div",{className:S.root},A.createElement("div",{className:S.headerContainer},A.createElement("button",{className:S.currentItemButton,onClick:U,onKeyDown:Hf(U),"aria-label":O,tabIndex:d||!b?0:-1,type:"button"},A.createElement("span",{"aria-live":"polite","aria-atomic":"true"},P)),A.createElement("div",{className:S.navigationButtonsContainer},A.createElement("button",{className:de(S.navigationButton,!k&&S.disabled),"aria-disabled":!k,tabIndex:k?void 0:r?0:-1,onClick:k?V:void 0,onKeyDown:k?Hf(V):void 0,title:p.prevYearAriaLabel?p.prevYearAriaLabel+" "+B.formatYear(Ql(u,-1)):void 0,type:"button"},h.upNavigation),A.createElement("button",{className:de(S.navigationButton,!_&&S.disabled),"aria-disabled":!_,tabIndex:_?void 0:r?0:-1,onClick:_?F:void 0,onKeyDown:_?Hf(F):void 0,title:p.nextYearAriaLabel?p.nextYearAriaLabel+" "+B.formatYear(Ql(u,1)):void 0,type:"button"},h.downNavigation))),A.createElement("div",{...T,className:S.gridContainer,role:"grid","aria-label":P},z.map(X=>{const K=p.shortMonths.slice(X*$f,(X+1)*$f);return A.createElement(Bp,{key:X,replayKey:u.getFullYear(),animationDirection:t,animateBackwards:$},A.createElement("div",{role:"row",className:S.buttonRow},K.map((J,H)=>{const Z=X*$f+H,L=Lf(u,Z),q=u.getMonth()===Z,Y=m.getMonth()===Z,re=m.getFullYear()===u.getFullYear(),ie=(a?eo(a,K_(L))<1:!0)&&(l?eo(G_(L),l)<1:!0);return A.createElement("button",{ref:q?y:void 0,role:"gridcell",className:de(S.itemButton,i&&Lne(Z,u.getFullYear(),g)&&S.current,c&&Y&&re&&S.selected,!ie&&S.disabled),disabled:!r&&!ie,key:Z,onClick:ie?D(Z):void 0,onKeyDown:ie?Hf(D(Z)):void 0,"aria-label":B.formatMonth(L,p),"aria-selected":q,tabIndex:ie?0:-1,type:"button"},J)})))})))};d7.displayName="CalendarMonth";function qne({dateTimeFormatter:e,navigatedDate:r,strings:t}){const n=c=>{if(e){const l=new Date(r.getTime());return l.setFullYear(c),e.formatYear(l)}return String(c)},s=c=>`${n(c.fromYear)} - ${n(c.toYear)}`;return[n,{rangeAriaLabel:s,prevRangeAriaLabel:c=>t.prevYearRangeAriaLabel?`${t.prevYearRangeAriaLabel} ${s(c)}`:"",nextRangeAriaLabel:c=>t.nextYearRangeAriaLabel?`${t.nextYearRangeAriaLabel} ${s(c)}`:"",headerAriaLabelFormatString:t.monthPickerHeaderAriaLabel}]}function Lne(e,r,t){return t.getFullYear()===r&&t.getMonth()===e}function Hf(e){return r=>{r.key===gn&&e()}}const V5={dismiss:A.createElement(sl,null),downNavigation:A.createElement(h4,null),upNavigation:A.createElement(p4,null)},ku={root:"fui-Calendar",divider:"fui-Calendar__divider",goTodayButton:"fui-Calendar__goTodayButton",monthPickerWrapper:"fui-Calendar__monthPickerWrapper",liveRegion:"fui-Calendar__liveRegion"},$ne=ke({base:{mc9l5x:"f22iagw",a9b677:"f13dwy2t"},normalize:{E5pizo:"f1couhl3",B7ck84d:"f1ewtqcl",jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:"f1s184ao",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai"},monthPickerNotVisible:{Beiy3e4:"f1vx9l62"},dayAndMonthPickersVisible:{a9b677:"fcy5b15"},dayPickerVisibleAndWeekNumbersShown:{a9b677:"fhsg0in"},dayAndMonthPickersVisibleAndWeekNumbersShown:{a9b677:"fcarq7f"}},{d:[".f22iagw{display:flex;}",".f13dwy2t{width:220px;}",".f1couhl3{box-shadow:none;}",".f1ewtqcl{box-sizing:border-box;}",[".f1s184ao{margin:0;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".f1vx9l62{flex-direction:column;}",".fcy5b15{width:440px;}",".fhsg0in{width:250px;}",".fcarq7f{width:470px;}"]}),Hne=ke({base:{h3c5rm:0,vrafjx:0,Bekrc4i:0,u1mtju:["fe2nn5g","f1rcbay7"],Bhzewxz:"f15twtuk"}},{d:[[".fe2nn5g{border-right:1px solid var(--colorNeutralStroke2);}",{p:-1}],[".f1rcbay7{border-left:1px solid var(--colorNeutralStroke2);}",{p:-1}],".f15twtuk{top:0;}"]}),Vne=ke({base:{mc9l5x:"f22iagw",Beiy3e4:"f1vx9l62"}},{d:[".f22iagw{display:flex;}",".f1vx9l62{flex-direction:column;}"]}),Wne=ke({base:{qb2dma:"fpydfdc",De3pzq:"f1c21dwh",icvyot:"f1ern45e",vrafjx:["f1n71otn","f1deefiw"],oivjwe:"f1h8hb77",wvpqe5:["f1deefiw","f1n71otn"],B5kzvoi:"f1yab3r1",B7ck84d:"f1e4lqlz",sj55zd:"f19n0e5",Bahqtrf:"f1mo0ibp",Be2twd7:"fy9rknc",Bqenvij:"f1tvdnth",Bg96gwp:"fpfng1i",t21cq0:["f17vyym1","fb5scp"],B6of3ja:"f4gg0ds",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1gl81tg",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1p2x7z2",seuwu7:"fvy6vk6",Jwef8y:"f9ql6rf",Bi91k9c:"f1f1pb61",eoavqd:"f8491dx",Bv6y5q5:0,uq1ffc:0,Bokaozi:0,Bfrni1f:"f14aog0w",Bkzqrjd:0,hu2duy:0,n9pfp1:0,dfw8yp:0,qugvs6:"f1fgm6o",B2d53fq:"fc9d3oc",Dyrjrp:"f1cqwcg4",Be90el1:"fmjaa5u"}},{d:[".fpydfdc{align-self:flex-end;}",".f1c21dwh{background-color:var(--colorTransparentBackground);}",".f1ern45e{border-top-style:none;}",".f1n71otn{border-right-style:none;}",".f1deefiw{border-left-style:none;}",".f1h8hb77{border-bottom-style:none;}",".f1yab3r1{bottom:0;}",".f1e4lqlz{box-sizing:content-box;}",".f19n0e5{color:var(--colorNeutralForeground1);}",".f1mo0ibp{font-family:inherit;}",".fy9rknc{font-size:var(--fontSizeBase200);}",".f1tvdnth{height:30px;}",".fpfng1i{line-height:30px;}",".f17vyym1{margin-right:16px;}",".fb5scp{margin-left:16px;}",".f4gg0ds{margin-top:3px;}",[".f1gl81tg{overflow:visible;}",{p:-1}],[".f1p2x7z2{padding:0 4px;}",{p:-1}],".fvy6vk6 div{font-size:var(--fontSizeBase200);}",".f1cqwcg4:disabled{color:var(--colorNeutralForegroundDisabled);}",".fmjaa5u:disabled{pointer-events:none;}"],h:[".f9ql6rf:hover{background-color:var(--colorTransparentBackground);}",".f1f1pb61:hover{color:var(--colorBrandForeground1);}",".f8491dx:hover{cursor:pointer;}",".fc9d3oc:hover:active{color:var(--colorBrandForeground2);}"],m:[["@media (forced-colors: active){.f14aog0w:hover{outline:var(--strokeWidthThin);}}",{p:-1,m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1fgm6o:hover{border-radius:var(--borderRadiusSmall);}}",{p:-1,m:"(forced-colors: active)"}]]}),Une=ke({base:{Bgfg5da:0,B9xav0g:0,oivjwe:0,Bn0qgzm:0,B4g9neb:0,zhjwy3:0,wvpqe5:0,ibv6hh:0,u1mtju:0,h3c5rm:0,vrafjx:0,Bekrc4i:0,i8vvqc:0,g2u3we:0,icvyot:0,B4j52fo:0,irswps:"f3bhgqh",Bqenvij:"f1mpe4l3",jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:"f1jlpb2r",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1a3p1vp",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai",qhf8xq:"f1euv43f",a9b677:"frkrog8"}},{d:[[".f3bhgqh{border:none;}",{p:-2}],".f1mpe4l3{height:1px;}",[".f1jlpb2r{margin:-1px;}",{p:-1}],[".f1a3p1vp{overflow:hidden;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".f1euv43f{position:absolute;}",".frkrog8{width:1px;}"]}),Xne=e=>{"use no memo";const r=$ne(),t=Hne(),n=Vne(),s=Wne(),o=Une(),{className:i,isDayPickerVisible:c,isMonthPickerVisible:l,showWeekNumbers:a}=e;return{root:de(ku.root,r.base,r.normalize,!l&&r.monthPickerNotVisible,c&&l&&!a&&r.dayAndMonthPickersVisible,c&&!l&&a&&r.dayPickerVisibleAndWeekNumbersShown,c&&l&&a&&r.dayAndMonthPickersVisibleAndWeekNumbersShown,i),divider:de(ku.divider,t.base),monthPickerWrapper:de(ku.monthPickerWrapper,n.base),goTodayButton:de(ku.goTodayButton,s.base),liveRegion:de(ku.liveRegion,o.base)}},Gne=440,Kne=[jo.Monday,jo.Tuesday,jo.Wednesday,jo.Thursday,jo.Friday];function Yne(e){const{value:r,today:t,onSelectDate:n}=e,s=A.useMemo(()=>t??new Date,[t]),[o,i]=Wr({state:r,defaultState:r?void 0:s,initialState:s}),[c=s,l]=A.useState(r),[a=s,u]=A.useState(r),[h=s,d]=A.useState(r);return r&&h.valueOf()!==r.valueOf()&&(l(r),u(r),d(r)),[o,c,a,(g,b)=>{u(g),l(g),i(g),n?.(g,b)},g=>{u(g),l(g)},g=>{u(g)}]}function Qne({isDayPickerVisible:e,isMonthPickerVisible:r,showMonthPickerAsOverlay:t}){const n=f7({isDayPickerVisible:e,showMonthPickerAsOverlay:t}),[s,o]=A.useState(()=>n?!1:r??!1),[i,c]=A.useState(()=>n?!0:e??!0);return[s,i,()=>{o(!s),c(!i)}]}function Zne({componentRef:e},r,t){const n=A.useRef(null),s=A.useRef(null),o=A.useRef(!1),{targetDocument:i}=Yt(),c=i?.defaultView,l=A.useCallback(()=>{r&&n.current?$5(n.current,c):t&&s.current&&$5(s.current,c)},[r,t,c]);return A.useImperativeHandle(e,()=>({focus:l}),[l]),A.useEffect(()=>{o.current&&(l(),o.current=!1)}),[n,s,()=>{o.current=!0}]}const wb=A.forwardRef((e,r)=>{const{allFocusable:t=!1,calendarDayProps:n,calendarMonthProps:s,className:o,componentRef:i,dateRangeType:c=fo.Day,dateTimeFormatter:l=U_,firstDayOfWeek:a=jo.Sunday,firstWeekOfYear:u=Ih.FirstDay,highlightCurrentMonth:h=!1,highlightSelectedMonth:d=!1,id:f,isDayPickerVisible:m=!0,isMonthPickerVisible:p=!0,maxDate:g,minDate:b,onDismiss:y,onSelectDate:w,restrictedDates:C,showCloseButton:N=!1,showGoToToday:I=!0,showMonthPickerAsOverlay:$=!1,showSixWeeksByDefault:D=!1,showWeekNumbers:F=!1,strings:V=X_,today:G,value:U,workWeekDays:E=Kne}=e,M=A.useMemo(()=>G??new Date,[G]),[B,k,_,S,T,z]=Yne({onSelectDate:w,value:U,today:M}),[P,O,X]=Qne({isDayPickerVisible:m,isMonthPickerVisible:p,showMonthPickerAsOverlay:$}),[K,J,H]=Zne({componentRef:i},O,P),Z=()=>{let he=I;return he&&M&&(he=k.getFullYear()!==M.getFullYear()||k.getMonth()!==M.getMonth()||_.getFullYear()!==M.getFullYear()||_.getMonth()!==M.getMonth()),I&&A.createElement("button",{className:pe.goTodayButton,onClick:ie,onKeyDown:ne(ie),type:"button",disabled:!he},V.goToToday)},L=(he,me)=>{T(he),me&&H()},q=(he,me)=>{if(me&&H(),!me){z(he);return}be&&S(he),T(he)},Y=f7({isDayPickerVisible:m,showMonthPickerAsOverlay:$}),re=Y?()=>{X(),H()}:void 0,ie=()=>{T(M),Y&&P&&X(),H()},ne=he=>me=>{switch(me.key){case gn:case In:he();break}},ae=he=>{switch(he.key){case gn:he.preventDefault();break;case Kb:he.preventDefault();break;case Ni:he.stopPropagation(),y?.();break;case Gb:he.ctrlKey?T(Ql(k,1)):T(Ja(k,1)),he.preventDefault();break;case Xb:he.ctrlKey?T(Ql(k,-1)):T(Ja(k,-1)),he.preventDefault();break}},be=!Y&&!O,pe=Xne({className:o,isDayPickerVisible:O,isMonthPickerVisible:P,showWeekNumbers:F});let te="",se="";if(l&&V.todayDateFormatString&&(te=V.todayDateFormatString.replace("{0}",l.formatMonthDayYear(M,V))),l&&V.selectedDateFormatString&&B){const he=be?l.formatMonthYear:l.formatMonthDayYear;se=V.selectedDateFormatString.replace("{0}",he(B,V))}const ue=se+", "+te;return A.createElement("div",{id:f,ref:r,className:pe.root,onKeyDown:ae},A.createElement("div",{className:pe.liveRegion,"aria-live":"polite","aria-atomic":"true"},A.createElement("span",null,se)),O&&A.createElement(t7,{gridLabel:ue,selectedDate:B??M,navigatedDate:k??M,today:M,onSelectDate:S,onNavigateDate:L,onDismiss:y,firstDayOfWeek:a,dateRangeType:c,strings:V,onHeaderSelect:re,showWeekNumbers:F,firstWeekOfYear:u,dateTimeFormatter:l,showSixWeeksByDefault:D,minDate:b,maxDate:g,navigationIcons:V5,restrictedDates:C,workWeekDays:E,componentRef:K,showCloseButton:N,allFocusable:t,...n}),O&&P&&A.createElement("div",{className:pe.divider}),P?A.createElement("div",{className:pe.monthPickerWrapper},A.createElement(d7,{navigatedDate:_,selectedDate:k,strings:V,onNavigateDate:q,today:M,highlightCurrentMonth:h,highlightSelectedMonth:d,onHeaderSelect:re,dateTimeFormatter:l,minDate:b,maxDate:g,componentRef:J,navigationIcons:V5,...s}),Z()):Z())});wb.displayName="Calendar";const f7=({isDayPickerVisible:e,showMonthPickerAsOverlay:r})=>{const{targetDocument:t}=Yt(),n=t?.defaultView;return r||e&&n&&n.innerWidth<=Gne};var il=(function(e){return e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e})({});const Jne=X_,eoe={...Jne,prevMonthAriaLabel:"Go to previous month",nextMonthAriaLabel:"Go to next month",prevYearAriaLabel:"Go to previous year",nextYearAriaLabel:"Go to next year",closeButtonAriaLabel:"Close date picker"},toe=e=>{const{inlinePopup:r}=e;return Dt(A.Fragment,{children:[ve(e.root,{}),e.popupSurface&&(r?ve(e.popupSurface,{children:ve(e.calendar,{})}):ve(ia,{mountNode:e.mountNode,children:ve(e.popupSurface,{children:ve(e.calendar,{})})}))]})};function roe(e){const{positioning:r}=e,t={position:"below",align:"start",...ys(r)},{targetRef:n,containerRef:s}=Cc(t);return[n,s]}function noe(e,r,t){return!!r&&eo(r,e)>0||!!t&&eo(t,e)<0}function ooe(){const e=A.useRef(null),r=A.useRef(!1),t=A.useCallback(()=>{var s,o;(o=e.current)===null||o===void 0||(s=o.focus)===null||s===void 0||s.call(o)},[]),n=A.useCallback(()=>{r.current=!0},[]);return[t,e,r,n]}function ioe(e){const[r,t]=Wr({initialState:!1,defaultState:e.defaultOpen,state:e.open}),n=A.useRef(!1);return A.useEffect(()=>{if(n.current&&!r){var s;(s=e.onOpenChange)===null||s===void 0||s.call(e,!1)}n.current=!0},[e.allowTextInput,r]),[r,t]}function aoe({formatDate:e,onSelectDate:r,value:t}){const[n,s]=Wr({initialState:null,state:t}),[o,i]=A.useState(()=>t&&e?e(t):""),c=l=>{r?.(l),s(l),i(l&&e?e(l):"")};return A.useEffect(()=>{i(t&&e?e(t):"")},[e,t]),[n,o,c,i]}const soe=e=>e?e.toDateString():"",loe=e=>{const r=Date.parse(e);return r?new Date(r):null},coe=(e,r)=>{const{allowTextInput:t=!1,allFocusable:n=!1,borderless:s=!1,dateTimeFormatter:o,defaultOpen:i=!1,disableAutoFocus:c=!0,firstDayOfWeek:l=jo.Sunday,firstWeekOfYear:a=Ih.FirstDay,formatDate:u=soe,highlightCurrentMonth:h=!1,highlightSelectedMonth:d=!1,initialPickerDate:f,inlinePopup:m=!1,isMonthPickerVisible:p=!0,maxDate:g,minDate:b,mountNode:y,onOpenChange:w,onSelectDate:C,openOnClick:N=!0,onValidationResult:I,parseDateFromString:$=loe,showCloseButton:D=!1,showGoToToday:F=!0,showMonthPickerAsOverlay:V=!1,showWeekNumbers:G=!1,strings:U=eoe,today:E,underlined:M=!1,value:B,...k}=e,_=A.useMemo(()=>f??new Date,[f]),S=A.useRef(null),[T,z,P,O]=ooe(),[X,K,J,H]=aoe({formatDate:u,onSelectDate:C,value:B}),[Z,L]=ioe(e),q=aa();var Y;const re=(Y=q?.required)!==null&&Y!==void 0?Y:e.required,ie=mr("datePicker-input"),ne=mr("datePicker-popupSurface"),ae=A.useCallback((ct=null)=>{let Ot;if(t)if(K||ct){if(X&&u&&u(ct??X)===K)return;ct=ct||$(K),!ct||isNaN(ct.getTime())?(J(X),Ot="invalid-input"):noe(ct,b,g)?Ot="out-of-bounds":J(ct)}else re&&(Ot="required-input"),C?.(ct);else re&&!K&&(Ot="required-input");I?.({error:Ot})},[t,u,K,g,b,C,I,$,re,X,J]),be=A.useCallback(ct=>{w?.(ct),L(ct),!Z&&!e.disabled&&T()},[T,w,e.disabled,L]),pe=A.useCallback(ct=>{Z&&(be(!1),ae(ct),!t&&ct&&J(ct))},[t,Z,be,J,ae]),te=A.useCallback(()=>{Z||(O(),be(!0))},[Z,O,be]),se=A.useCallback(ct=>{O(),pe(ct)},[pe,O]),ue=A.useCallback((ct,Ot)=>{const{value:Ft}=Ot;t&&(Z&&pe(),H(Ft))},[t,pe,Z,H]),he=A.useCallback(()=>{ae()},[ae]),me=A.useCallback(ct=>{switch(ct.key){case gn:ct.preventDefault(),ct.stopPropagation(),Z?e.allowTextInput&&pe():(ae(),te());break;case Ni:Z&&(ct.stopPropagation(),ct.preventDefault(),se());break;case Ta:ct.preventDefault(),Z||te();break}},[se,pe,Z,e.allowTextInput,te,ae]),xe=A.useCallback(()=>{c||t||(P.current||te(),P.current=!1)},[t,c,P,te]),Be=A.useCallback(()=>{if((e.openOnClick||!e.disableAutoFocus)&&!Z&&!e.disabled){te();return}t&&pe()},[t,pe,Z,e.disabled,e.disableAutoFocus,e.openOnClick,te]),Re=ct=>{ct.preventDefault(),ct.stopPropagation(),!Z&&!e.disabled?te():e.allowTextInput&&pe()},He=M?"underline":s?"filled-lighter":"outline",[Je,Te]=roe(e),Ee=Ge(e.root,{defaultProps:{ref:Je},elementType:"span"});Ee.ref=Nt(Ee.ref,Je);const $e=Ge(e.input,{elementType:"input"});$e.ref=Nt($e.ref,r,z);const Ze=e["aria-labelledby"];var yt;const dt=(yt=e.id)!==null&&yt!==void 0?yt:ie,Ke=A.useMemo(()=>({role:"button","aria-expanded":Z,"aria-labelledby":Ze??dt}),[Z,Ze,dt]),We=Ge(e.contentAfter||{},{defaultProps:{children:A.createElement(YA,null),...Ke},elementType:"span"});We.onClick=De(jt(We.onClick,Re));const nt=Ge(k,{defaultProps:{appearance:He,"aria-controls":Z?ne:void 0,"aria-expanded":Z,"aria-haspopup":"dialog",readOnly:!t,role:"combobox",id:dt},elementType:_n});nt.root=Ee,nt.input=$e,nt.contentAfter=We,nt.onChange=De(jt(nt.onChange,ue)),nt.onBlur=De(jt(nt.onBlur,he)),nt.onKeyDown=De(jt(nt.onKeyDown,me)),nt.onFocus=De(jt(nt.onFocus,xe)),nt.onClick=De(jt(nt.onClick,Be));const{modalAttributes:Ve}=sd({trapFocus:!0,alwaysFocusable:!0,legacyTrapFocus:!0}),wt=Z?ut(e.popupSurface,{renderByDefault:!0,defaultProps:{"aria-label":"Calendar","aria-modal":!0,id:ne,role:"dialog",ref:Te,...Ve},elementType:"div"}):void 0,{targetDocument:Wt}=Yt();nd({element:Wt,callback:ct=>pe(),refs:[Je,Te],disabled:!Z}),Ob({element:Wt,callback:ct=>pe(),refs:[Je,Te],disabled:!Z}),A.useEffect(()=>{Z&&!e.disabled&&S.current&&S.current.focus()},[c,Z,e.disabled]);const Ct=Ge(e.calendar,{defaultProps:{allFocusable:n,componentRef:S,dateTimeFormatter:o,firstDayOfWeek:l,firstWeekOfYear:a,highlightCurrentMonth:h,highlightSelectedMonth:d,isMonthPickerVisible:p,maxDate:g,minDate:b,showCloseButton:D,showGoToToday:F,showMonthPickerAsOverlay:V,showWeekNumbers:G,strings:U,today:E,value:X||_},elementType:wb});Ct.onDismiss=De(jt(Ct.onDismiss,se)),Ct.onSelectDate=De(jt(Ct.onSelectDate,se));const Tt={disabled:!!e.disabled,inlinePopup:m,components:{root:_n,calendar:wb,popupSurface:"div"},calendar:Ct,mountNode:y,root:nt,popupSurface:wt};return Tt.root.value=K,Tt},o0={root:"fui-DatePicker",calendar:"fui-DatePicker__calendar",popupSurface:"fui-DatePicker__popupSurface"},uoe=ke({base:{qhf8xq:"f10pi13n",Bceei9c:"f1k6fduh",xfaavh:"faxec97"},disabled:{Bceei9c:"f158kwzp",xfaavh:"f19qwlmg"},inline:{Bj3rh1h:"f19g0ac"}},{d:[".f10pi13n{position:relative;}",".f1k6fduh{cursor:pointer;}",".faxec97 input{cursor:pointer;}",".f158kwzp{cursor:default;}",".f19qwlmg input{cursor:default;}",".f19g0ac{z-index:1;}"]}),doe=_t("r1ytv1z8",null,[".r1ytv1z8{background-color:var(--colorNeutralBackground1);box-shadow:var(--shadow16);border-radius:var(--borderRadiusMedium);border-width:1px;border-style:solid;border-color:var(--colorTransparentStroke);display:inline-flex;color:var(--colorNeutralForeground1);font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase300);font-weight:var(--fontWeightRegular);line-height:var(--lineHeightBase300);}"]),foe=e=>{const r=uoe(),t=doe(),{disabled:n,inlinePopup:s}=e;return e.root.className=de(o0.root,r.base,n&&r.disabled,e.root.className),e.popupSurface&&(e.popupSurface.className=de(o0.popupSurface,t,e.popupSurface.className,s&&r.inline)),e.calendar.className=de(o0.calendar,e.calendar.className),e},xb=A.forwardRef((e,r)=>{const t=coe(e,r);return foe(t),toe(t)});xb.displayName="DatePicker";function h7(e){return!isNaN(e.getTime())}function kb(e){return e?h7(e)?e.toISOString():"invalid":""}function hoe(e){if(e===""||e==="invalid")return null;const r=new Date(e);return h7(r)?r:null}function p7(e,{hourCycle:r,showSeconds:t}={}){return e.toLocaleTimeString(void 0,{hour:"numeric",hourCycle:r,minute:"2-digit",second:t?"2-digit":void 0})}function poe(e,r){const t=new Date(e);return t.setHours(r,0,0,0),t}function moe(e,r,t){const n=new Date(e);return(r>t||t===24)&&n.setDate(n.getDate()+1),n.setHours(t===24?0:t,0,0,0),n}function goe(e,r,t){if(t<=0)return console.error("Increment value should be a positive number."),[];const n=[],s=new Date(e);for(;s<r;)n.push(new Date(s)),s.setMinutes(s.getMinutes()+t);return n}const boe=/^((1[0-2]|0?[0-9]):([0-5][0-9]):([0-5][0-9])\s([AaPp][Mm]))$/,voe=/^((1[0-2]|0?[0-9]):[0-5][0-9]\s([AaPp][Mm]))$/,yoe=/^([0-1]?[0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9]$/,woe=/^([0-1]?[0-9]|2[0-4]):[0-5][0-9]$/;function xoe(e,r,t,n){if(!e)return{date:null,errorType:"required-input"};const{hourCycle:s,showSeconds:o}=n,i=s==="h11"||s==="h12";if(!(i?o?boe:voe:o?yoe:woe).test(e))return{date:null,errorType:"invalid-input"};const l=/^(\d\d?):(\d\d):?(\d\d)? ?([ap]m)?/i.exec(e);if(!l)return{date:null,errorType:"invalid-input"};const[,a,u,h,d]=l;let f=a;i&&d&&(d.toLowerCase()==="pm"&&+f!=12?f=(+f+12).toString():d.toLowerCase()==="am"&&+f==12&&(f="0"));const m=new Date(r);return m.setHours(+f,+u,h?+h:0),m<r&&m.setDate(m.getDate()+1),m>=t?{date:m,errorType:"out-of-bounds"}:{date:m}}const koe=(e,r)=>{var t;const{dateAnchor:n,defaultSelectedTime:s,endHour:o=24,formatDateToTimeString:i=p7,hourCycle:c,increment:l=30,onTimeChange:a,selectedTime:u,showSeconds:h=!1,startHour:d=0,parseTimeStringToDate:f,...m}=e,{freeform:p=!1}=m;var g;const{dateStartAnchor:b,dateEndAnchor:y}=Soe((g=n??u)!==null&&g!==void 0?g:s,d,o),w=A.useMemo(()=>goe(b,y,l).map(k=>({date:k,key:kb(k),text:i(k,{showSeconds:h,hourCycle:c})})),[y,b,i,c,l,h]),[C,N]=Wr({state:u,defaultState:s,initialState:null}),[I,$]=A.useState(void 0),D=De((k,_)=>{N(_.selectedTime),$(_.selectedTimeText),a?.(k,_)}),F=A.useMemo(()=>{const k=kb(C),_=w.find(S=>S.key===k);return _?[_.key]:[]},[w,C]),V=A.useRef(null),G=De((k,_)=>{if(p&&_.optionValue===void 0&&!(m.clearable&&k.type==="click"&&k.currentTarget===V.current))return;var S;const T={selectedTime:hoe((S=_.optionValue)!==null&&S!==void 0?S:""),selectedTimeText:_.optionText,errorType:void 0};D(k,T)}),U=T6({autoComplete:"off",...m,selectedOptions:F,onOptionSelect:G,children:w.map(k=>A.createElement(Jt,{key:k.key,value:k.key},k.text))},r),E=A.useCallback(k=>xoe(k,b,y,{hourCycle:c,showSeconds:h}),[y,b,c,h]),M=Nt((t=U.clearIcon)===null||t===void 0?void 0:t.ref,V),B={...U,clearIcon:U.clearIcon?{...U.clearIcon,ref:M}:void 0,freeform:p,parseTimeStringToDate:f??E,submittedText:I};return Coe(B),_oe(B,D),B},Soe=(e,r,t)=>{const[n]=A.useState(()=>new Date),s=kb(e??null);return A.useMemo(()=>{const o=e??n,i=poe(o,r),c=moe(o,r,t);return{dateStartAnchor:i,dateEndAnchor:c}},[t,n,s,r])},_oe=(e,r)=>{const{getOptionById:t,freeform:n,parseTimeStringToDate:s,submittedText:o,value:i,activeDescendantController:c}=e,l=A.useCallback(()=>{const f=c.active();return f?t(f):null},[c,t]);A.useEffect(()=>{if(n&&i){const f=l();if(!f)return;f.text.toLowerCase().indexOf(i.toLowerCase())===0||c.blur()}},[n,i,c,l]);const a=De(f=>{if(!n)return;const{date:m,errorType:p}=s(i);o!==i&&r?.(f,{selectedTime:m,selectedTimeText:i,errorType:p})}),u=De(f=>{!l()&&f.key===gn&&a(f)});e.root.onKeyDown=jt(u,e.root.onKeyDown);const h=A.useRef(null);e.root.ref=Nt(e.root.ref,h),e.listbox&&(e.listbox.tabIndex=-1),e.expandIcon&&(e.expandIcon.tabIndex=-1);const d=De(f=>{(!f.relatedTarget||!kn(h.current,f.relatedTarget))&&a(f)});e.input.onBlur=jt(d,e.input.onBlur)},Coe=e=>{var r;const t=aa(),n=mr("timepicker-chevron-");if(t?.labelId&&((r=e.expandIcon)===null||r===void 0?void 0:r["aria-label"])==="Open"){var o;const i=(o=e.expandIcon.id)!==null&&o!==void 0?o:n;e.expandIcon["aria-labelledby"]=`${i} ${t.labelId}`}},Su={root:"fui-TimePicker",input:"fui-TimePicker__input",expandIcon:"fui-TimePicker__expandIcon",clearIcon:"fui-TimePicker__clearIcon",listbox:"fui-TimePicker__listbox"},Toe=ke({listbox:{Bxyxcbc:"f1vfnyiv"}},{d:[".f1vfnyiv{max-height:min(80vh, 416px);}"]}),Boe=e=>{const r=Toe();return e.root.className=de(Su.root,e.root.className),e.input.className=de(Su.input,e.input.className),e.expandIcon&&(e.expandIcon.className=de(Su.expandIcon,e.expandIcon.className)),e.clearIcon&&(e.clearIcon.className=de(Su.clearIcon,e.clearIcon.className)),e.listbox&&(e.listbox.className=de(Su.listbox,r.listbox,e.listbox.className)),j6(e),e},m7=A.forwardRef((e,r)=>{const t=koe(e,r),n=mv(t);return Boe(t),ht("useTimePickerCompatStyles_unstable")(t),B6(t,n)});m7.displayName="TimePicker";const joe=wr({root:{display:"flex",flexDirection:"row",gap:"8px"},datePicker:{flexGrow:1},timePicker:{flexGrow:1}});function Sb({attribute:e,value:r,onChange:t,placeholder:n="Select a date",disabled:s=!1}){const o=joe(),[i,c]=A.useState(null),[l,a]=A.useState(null),[u,h]=A.useState(""),d=e.Format==="DateOnly";A.useEffect(()=>{if(r){const y=typeof r=="string"?new Date(r):r;isNaN(y.getTime())||(c(y),d||(a(y),h(p7(y))))}else c(null),a(null),h("")},[r,d]);const f=e.MinSupportedValue?new Date(e.MinSupportedValue):void 0,m=e.MaxSupportedValue?new Date(e.MaxSupportedValue):void 0,p=y=>{if(c(y??null),!y){t(void 0);return}if(d){const w=new Date(Date.UTC(y.getFullYear(),y.getMonth(),y.getDate()));t(w)}else if(l){const w=new Date(y.getFullYear(),y.getMonth(),y.getDate(),l.getHours(),l.getMinutes(),l.getSeconds());t(w)}else t(y)},g=(y,w)=>{if(a(w.selectedTime),h(w.selectedTimeText??""),i&&w.selectedTime){const C=new Date(i.getFullYear(),i.getMonth(),i.getDate(),w.selectedTime.getHours(),w.selectedTime.getMinutes(),w.selectedTime.getSeconds());t(C)}},b=y=>{h(y.target.value)};return d?j.jsx(xb,{value:i,onSelectDate:p,placeholder:n,disabled:s,minDate:f,maxDate:m,allowTextInput:!0,className:o.datePicker}):j.jsxs("div",{className:o.root,children:[j.jsx(xb,{value:i,onSelectDate:p,placeholder:"Select date",disabled:s,minDate:f,maxDate:m,allowTextInput:!0,className:o.datePicker}),j.jsx(m7,{placeholder:"Select time",freeform:!0,dateAnchor:i??void 0,selectedTime:l,onTimeChange:g,value:u,onInput:b,disabled:s||!i,className:o.timePicker})]})}const Noe=wr({container:{display:"flex",alignItems:"center",gap:le.spacingHorizontalM,width:"100%"},inputWrapper:{flex:1,minWidth:"120px"},separator:{color:le.colorNeutralForeground3,fontWeight:le.fontWeightSemibold,paddingInline:le.spacingHorizontalXS}});function Eoe({attribute:e,value:r=[void 0,void 0],onChange:t,placeholder1:n="Start value",placeholder2:s="End value"}){const o=Noe(),[i,c]=r,l=d=>{const f=d instanceof Date?d.toISOString():typeof d=="number"||typeof d=="string"?d:void 0;t([f,c])},a=d=>{const f=d instanceof Date?d.toISOString():typeof d=="number"||typeof d=="string"?d:void 0;t([i,f])},u=e.AttributeType==="Integer"||e.AttributeType==="BigInt"||e.AttributeType==="Decimal"||e.AttributeType==="Double",h=e.AttributeType==="DateTime";return j.jsxs("div",{className:o.container,children:[j.jsx("div",{className:o.inputWrapper,children:u?j.jsx(gb,{attribute:e,value:typeof i=="number"?i:void 0,onChange:l,placeholder:n}):h?j.jsx(Sb,{attribute:e,value:typeof i=="string"?i:void 0,onChange:l,placeholder:n}):null}),j.jsx(Dn,{className:o.separator,children:"and"}),j.jsx("div",{className:o.inputWrapper,children:u?j.jsx(gb,{attribute:e,value:typeof c=="number"?c:void 0,onChange:a,placeholder:s}):h?j.jsx(Sb,{attribute:e,value:typeof c=="string"?c:void 0,onChange:a,placeholder:s}):null})]})}const Aoe=wr({container:{display:"flex",flexDirection:"column",gap:le.spacingVerticalS,width:"100%"},row:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},input:{flexGrow:1},addButton:{marginTop:le.spacingVerticalXS}});function Roe({values:e,onChange:r,placeholder:t="Enter value",inputType:n="text"}){const s=Aoe(),[o,i]=A.useState(e.length>0?e:[""]);A.useEffect(()=>{if(e.length===0&&o.length===1&&o[0]==="")return;const u=o.filter(d=>d.trim()!=="");(e.length!==u.length||e.some((d,f)=>d!==u[f]))&&i(e.length>0?e:[""])},[e]);const c=(u,h)=>{const d=[...o];d[u]=h,i(d);const f=d.filter(m=>m.trim()!=="");r(f)},l=()=>{const u=[...o,""];i(u)},a=u=>{if(o.length===1)i([""]),r([]);else{const h=o.filter((f,m)=>m!==u);i(h);const d=h.filter(f=>f.trim()!=="");r(d)}};return j.jsxs("div",{className:s.container,children:[o.map((u,h)=>j.jsxs("div",{className:s.row,children:[j.jsx(_n,{className:s.input,value:u,onChange:(d,f)=>c(h,f.value),placeholder:`${t} ${h+1}`,type:n}),o.length>1&&j.jsx(St,{appearance:"subtle",icon:j.jsx(x4,{}),onClick:()=>a(h),"aria-label":`Remove value ${h+1}`})]},h)),j.jsx(St,{className:s.addButton,appearance:"secondary",icon:j.jsx(rp,{}),onClick:l,children:"Add value"})]})}const zoe=wr({container:{width:"100%"}});function Ioe({entityLogicalName:e,attributeLogicalName:r,attribute:t,value:n=[],onChange:s,placeholder:o="Enter value"}){const i=zoe(),[c,l]=A.useState([]),[a,u]=A.useState((n??[]).map(String)),h=t.AttributeType==="Picklist"||t.AttributeType==="State"||t.AttributeType==="Status"||t.AttributeTypeName?.Value==="MultiSelectPicklistType";A.useEffect(()=>{h&&Qv(e,r).then(p=>{if(p.OptionSet?.Options){const g=p.OptionSet.Options.map(b=>({label:b.Label?.UserLocalizedLabel?.Label||String(b.Value),value:b.Value}));l(g)}}).catch(p=>{console.error("Failed to load OptionSet metadata:",p)})},[e,r,h]),A.useEffect(()=>{if(!h)return;const p=(n??[]).map(String);(p.length!==a.length||p.some((b,y)=>b!==a[y]))&&u(p)},[n,h]);const d=p=>{if(t.AttributeType==="Integer"||t.AttributeType==="BigInt"||t.AttributeType==="Decimal"||t.AttributeType==="Double"||t.AttributeType==="Money"){const b=p.map(y=>parseFloat(y)).filter(y=>!isNaN(y));s(b.length>0?b:void 0)}else s(p.length>0?p:void 0)},f=(p,g)=>{const b=g.selectedOptions.map(y=>parseInt(y,10)).filter(y=>!isNaN(y));u(g.selectedOptions),s(b.length>0?b:void 0)};if(h){const p=c.filter(g=>!a.includes(String(g.value)));return j.jsx("div",{className:i.container,children:j.jsxs(S8,{onOptionSelect:f,selectedOptions:a,children:[j.jsxs(T8,{children:[j.jsx(B8,{"aria-label":"Selected values",children:a.map(g=>{const b=c.find(y=>String(y.value)===g);return j.jsx(pp,{shape:"rounded",value:g,children:b?`${b.label} - ${b.value}`:g},g)})}),j.jsx(_8,{"aria-label":o,placeholder:o})]}),j.jsx(C8,{children:p.length>0?p.map(g=>j.jsxs(G0,{value:String(g.value),text:`${g.label} - ${g.value}`,children:[g.label," - ",g.value]},g.value)):j.jsx(G0,{value:"no-options",text:"No options available",children:"No options available"})})]})})}const m=t.AttributeType==="Integer"||t.AttributeType==="BigInt"||t.AttributeType==="Decimal"||t.AttributeType==="Double"||t.AttributeType==="Money";return j.jsx("div",{className:i.container,children:j.jsx(Roe,{values:(n??[]).map(String),onChange:d,placeholder:o,inputType:m?"number":"text"})})}const Ps="https://learn.microsoft.com/power-apps/developer/data-platform",Fr=`${Ps}/fetchxml`,Kt={fetch:`${Fr}/reference/fetch`,fetchOptions:`${Fr}/reference/fetch#options`,entity:`${Fr}/reference/entity`,attribute:`${Fr}/reference/attribute`,aggregateFunctions:`${Fr}/reference/attribute#aggregate-functions`,order:`${Fr}/reference/order`,filter:`${Fr}/reference/filter`,condition:`${Fr}/reference/condition`,operators:`${Fr}/reference/operators`,linkEntity:`${Fr}/reference/link-entity`,linkEntityFromTo:`${Fr}/reference/link-entity#using-from-and-to-attributes`,aggregate:`${Fr}/aggregate-data`,aggregateDistinct:`${Fr}/aggregate-data#distinct-column-values`,aggregateDateGrouping:`${Fr}/aggregate-data#grouping-by-parts-of-a-date`,aggregateLimit:`${Fr}/aggregate-data#per-query-limit`,rowAggregate:`${Fr}/aggregate-data#row-aggregate`,columnAliases:`${Fr}/select-columns#column-aliases`,orderRows:`${Fr}/order-rows`,linkOrdersFirst:`${Fr}/order-rows#process-link-entity-orders-first`,filterRows:`${Fr}/filter-rows`,filterOnColumnValues:`${Fr}/filter-rows#filter-on-column-values-in-the-same-row`,filtersOnLinkEntity:`${Fr}/filter-rows#filters-on-link-entity`,joinTables:`${Fr}/join-tables`,pageResults:`${Fr}/page-results`,countRows:`${Fr}/count-rows`,limitRows:`${Fr}/overview#limit-the-number-of-rows`,distinctResults:`${Fr}/overview#return-distinct-results`,lateMaterialize:`${Fr}/optimize-performance#late-materialize-query`,unionHint:`${Fr}/optimize-performance#union-hint`,noLock:`${Fr}/optimize-performance#no-lock`,antiPatterns:`${Ps}/query-antipatterns`,quickFind:`${Ps}/quick-find?tabs=fetchxml`,quickFindLimits:`${Ps}/quick-find?tabs=fetchxml#quick-find-record-limits`,hierarchy:`${Ps}/query-hierarchical-data`,wildcards:`${Ps}/wildcard-characters?tabs=fetchxml`,choices:`${Ps}/multi-select-picklist#query-data-from-choices`,dataRetention:"https://learn.microsoft.com/power-apps/maker/data-platform/data-retention-overview",reportPrefiltering:"https://learn.microsoft.com/dynamics365/customerengagement/on-premises/analytics/improve-report-performance-by-using-filters?view=op-9-1"},Mi=wr({container:{display:"flex",flexDirection:"column",gap:le.spacingVerticalL,padding:le.spacingVerticalM},section:{display:"flex",flexDirection:"column",gap:le.spacingVerticalS},mono:{fontFamily:le.fontFamilyMonospace},readOnly:{color:le.colorNeutralForeground1,paddingTop:le.spacingVerticalXXS},secondary:{color:le.colorNeutralForeground3},optionText:{display:"flex",flexDirection:"column"},optionSecondary:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200},leftover:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:le.spacingHorizontalS},accordionHeader:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},accordionPanel:{display:"flex",flexDirection:"column",gap:le.spacingVerticalM,paddingBottom:le.spacingVerticalM},checkboxGroup:{display:"flex",flexDirection:"column",gap:le.spacingVerticalXXS}});function Qt({text:e,href:r}){return j.jsxs(j.Fragment,{children:[e,r&&j.jsxs(j.Fragment,{children:[" ",j.jsx(dd,{href:r,target:"_blank",rel:"noreferrer",inline:!0,children:"Learn more"})]})]})}function Xn({children:e}){return j.jsx(Dn,{weight:"semibold",children:e})}const g7=(e,r)=>r?{children:(t,n)=>j.jsx(Av,{...n,info:r,children:e})}:e;function kr({label:e,info:r,hint:t,required:n,validation:s,children:o}){return j.jsx(Eo,{label:g7(e,r),hint:s?.message?void 0:t,required:n,validationState:s?.state,validationMessage:s?.message,children:o})}function ei({label:e,info:r,checked:t,onChange:n,disabled:s,hint:o,validation:i}){const c=j.jsx(ho,{checked:t,disabled:s,onChange:(l,a)=>n(a.checked===!0),label:g7(e,r)});return!o&&!i?.message?c:j.jsx(Eo,{hint:i?.message?void 0:o,validationState:i?.state,validationMessage:i?.message,children:c})}function Ka({label:e,info:r,hint:t,value:n,min:s,max:o,rangeSeverity:i="error",placeholder:c,disabled:l,onChange:a,validation:u}){const d=n!==void 0&&(s!==void 0&&n<s||o!==void 0&&n>o)?{state:i,message:o===void 0?`Must be at least ${s?.toLocaleString()}.`:`Must be from ${s?.toLocaleString()} to ${o.toLocaleString()}.`}:void 0;return j.jsx(kr,{label:e,info:r,hint:t,validation:u??d,children:j.jsx(J6,{value:n??null,min:s,max:o,placeholder:c,disabled:l,onChange:(f,m)=>{if(m.value!==void 0&&m.value!==null)return a(m.value);const p=(m.displayValue??"").trim();if(p==="")return a(void 0);const g=Number(p);Number.isFinite(g)&&a(Math.trunc(g))}})})}function _a({text:e,validation:r,onRemove:t}){const n=Mi();return j.jsx(Eo,{validationState:r.state,validationMessage:r.message,children:j.jsxs("div",{className:n.leftover,children:[j.jsx(st,{children:e}),j.jsx(St,{size:"small",onClick:t,children:"Remove"})]})})}function Moe(e){const[r,t]=A.useState({});return A.useEffect(()=>{if(!e)return;let n=!1;return jc(e).then(s=>!n&&t({entity:e,attributes:s})).catch(()=>!n&&t({entity:e,attributes:void 0})),()=>{n=!0}},[e]),r.entity===e?r.attributes:void 0}function b7(e,r){const t=Moe(e),n=r?t?.find(s=>s.LogicalName===r):void 0;return n?I8(n):void 0}function jp(e){const[r,t]=A.useState({info:{}});return A.useEffect(()=>{if(!e)return;let n=!1;return Promise.allSettled([hc(e),SJ(e)]).then(([s,o])=>{n||t({entity:e,info:{metadata:s.status==="fulfilled"?s.value:void 0,isHierarchical:o.status==="fulfilled"?o.value:void 0}})}),()=>{n=!0}},[e]),r.entity===e?r.info:{}}const W5={error:0,warning:1,info:2};function Er(e,...r){const t=e.filter(n=>r.includes(n.attribute)).sort((n,s)=>W5[n.severity]-W5[s.severity])[0];if(t)return{state:t.severity==="info"?"none":t.severity,message:t.message}}function is(...e){const r=t=>t?t.state==="error"?0:t.state==="warning"?1:2:3;return e.filter(Boolean).sort((t,n)=>r(t)-r(n))[0]}const _u="__same";function Doe(e){const r=e.indexOf(".");return r===-1?{qualifier:void 0,attribute:e}:{qualifier:e.substring(0,r),attribute:e.substring(r+1)}}function Poe({fetchQuery:e,rootEntityName:r,effectiveEntityName:t,scope:n,sameAlias:s,valueof:o,compatibleTypes:i,validation:c,onChange:l}){const a=Mi(),u=A.useMemo(()=>Doe(o),[o]),h=A.useMemo(()=>{const p=[{value:_u,label:`${t} (same record)`,entityName:t}];r&&r!==t&&p.push({value:r,label:`${r} (root entity)`,entityName:r});const g=new Map(A8(e).map(b=>[b.alias,b.entityName]));for(const b of n?.aliases??[])b!==s&&p.push({value:b,label:`${b} (${g.get(b)??"?"})`,entityName:g.get(b)??""});if(u.qualifier&&!p.some(b=>b.value===u.qualifier)){const b=u.qualifier===s;p.push({value:u.qualifier,label:u.qualifier,entityName:b?t:"",secondary:b?"This record":n?.laterAliases.includes(u.qualifier)?"Joined after this link-entity":"Not a link-entity alias"})}return p},[e,r,t,n,s,u.qualifier]),[d,f]=A.useState(u.qualifier??_u);A.useEffect(()=>f(u.qualifier??_u),[u.qualifier]);const m=h.find(p=>p.value===d)??h[0];return j.jsxs(j.Fragment,{children:[j.jsx(kr,{label:"Entity",info:j.jsx(Qt,{text:"Compare to an attribute of the same record, the root entity, or a link-entity this condition can reach: link-entities need an alias, and a link-entity's filter can only reach link-entities joined before it.",href:Kt.filterOnColumnValues}),children:j.jsx(po,{value:m.label,selectedOptions:[m.value],onOptionSelect:(p,g)=>{f(g.optionValue??_u),l("")},children:h.map(p=>j.jsx(Jt,{value:p.value,text:p.label,children:j.jsxs("span",{className:a.optionText,children:[p.label,p.secondary&&j.jsx("span",{className:a.optionSecondary,children:p.secondary})]})},p.value))})}),j.jsx(kr,{label:"Attribute",required:!0,validation:c??(u.attribute?void 0:{state:"error",message:"Choose the attribute to compare to."}),info:j.jsx(Qt,{text:i.length>0?`Only attributes Dataverse can compare with this one are listed (${i.join(", ")}).`:"The attribute to compare to. Both attributes must have compatible types.",href:Kt.filterOnColumnValues}),children:j.jsx(pc,{entityLogicalName:m.entityName,value:u.attribute,onChange:p=>{const g=m.value===_u?void 0:m.value;l(p?g?`${g}.${p}`:p:"")},placeholder:m.entityName?"Select an attribute":"Choose an entity first",disabled:!m.entityName||i.length===0,filterByTypes:i})})]})}const Ooe=wr({matches:{flexWrap:"wrap"}}),i0=e=>e==null||e===""?void 0:String(e);function Foe({operator:e,value:r,advice:t,onChange:n}){const s=Ooe(),o=tl.has(e),[i,c]=A.useState(()=>nh(e,r)),l=A.useRef(i0(r)),a=A.useRef(e);A.useEffect(()=>{i0(r)===l.current&&e===a.current||(l.current=i0(r),a.current=e,c(nh(e,r)))},[e,r]);const u=g=>{const b={...i,...g};c(b);const y=b.text===""?void 0:cb(e,b);l.current=y,n(y)},h=g=>{if(g==="custom")return u({match:g,text:i.text===""?"":cb(e,i),literal:!1});if(i.match!=="custom")return u({match:g});const b=nh(e,i.text);u(b.match==="custom"?{match:g}:{match:g,text:b.text,literal:b.literal})},d=o&&i.match==="custom",f=!o&&!i.literal&&g5(i.text),m=d&&i.text!==""&&!g5(i.text),p=f?{state:"warning",message:"This value contains a wildcard character (% _ [). Turn on Match literally to search for it as text."}:m?{state:"warning",message:"No wildcard: this matches the whole value, like Equals."}:void 0;return j.jsxs(j.Fragment,{children:[o&&j.jsx(kr,{label:"Match",info:j.jsx(Qt,{text:"Contains writes %text%, Begins with text% and Ends with %text. Custom pattern writes the value as you type it, wildcards included.",href:Kt.wildcards}),children:j.jsxs(ta,{className:s.matches,layout:"horizontal",value:i.match,onChange:(g,b)=>h(b.value),children:[j.jsx(Yr,{value:"contains",label:"Contains"}),j.jsx(Yr,{value:"begins",label:"Begins with"}),j.jsx(Yr,{value:"ends",label:"Ends with"}),j.jsx(Yr,{value:"custom",label:"Custom pattern"})]})}),j.jsx(kr,{label:d?"Pattern":"Text",validation:is(p,t),info:j.jsx(Qt,{text:o?"like and not-like match only the wildcards in the value: % (any characters), _ (one character), [ ] (one character from a set). Pick a match above, or write the pattern yourself with Custom pattern.":"This operator adds the % wildcard itself, so don't type it. Any %, _ or [ in the value is still a wildcard unless Match literally is on.",href:Kt.wildcards}),children:j.jsx(_n,{value:i.text,placeholder:d?"e.g. con_oso%":"Text to find",onChange:(g,b)=>u({text:b.value})})}),j.jsx(ho,{label:"Match literally (% _ [ are text, not wildcards)",checked:i.literal&&!d,disabled:d,onChange:(g,b)=>u({literal:b.checked===!0})})]})}const qoe=300,U5="00000000-0000-0000-0000-000000000000",a0="__none";async function Loe(e){const r=await Js(`hierarchical-relationship:${e}`,()=>_Z(e));if(!r)return"";const t=r.referencingAttribute,s=(await jc(e).catch(()=>[])).find(o=>o.LogicalName===t)?.DisplayName?.UserLocalizedLabel?.Label;return`Hierarchy: ${s?`${s} (${t})`:t}. `}function $oe({entityName:e,metadata:r,value:t,onChange:n}){const s=Mi(),o=A.useMemo(()=>r?.EntitySetName&&r.PrimaryNameAttribute&&r.PrimaryIdAttribute?{entitySetName:r.EntitySetName,idAttribute:r.PrimaryIdAttribute,nameAttribute:r.PrimaryNameAttribute}:void 0,[r]),i=typeof t=="string"?t:"",c=A.useRef(null),[l,a]=A.useState(!1),[u,h]=A.useState(i),[d,f]=A.useState(""),[m,p]=A.useState(void 0),[g,b]=A.useState(void 0),[y,w]=A.useState(!1),[C,N]=A.useState(!1),[I,$]=A.useState(""),D=A.useRef(0);A.useEffect(()=>{let T=!1;return Loe(e).then(z=>!T&&$(z),()=>!T&&$("")),()=>{T=!0}},[e]);const F=A.useRef(void 0),V=A.useRef(0);A.useEffect(()=>{if(i===c.current&&o===F.current)return;c.current=i,F.current=o;const T=++V.current;if(h(i),N(!1),!o||!i){p(void 0),f("");return}if(!oh(i)){a(!0);return}TZ(o,i).then(z=>{if(T===V.current){if(z===void 0){N(!0),a(!0);return}p(z),f(z||ih(i))}})},[i,o]);const G=T=>{c.current=T??"",V.current++,n(T)},U=T=>{if(!o)return;const z=++D.current;w(!0),CZ(o,T).then(P=>{z===D.current&&(b(P),w(!1))},P=>{z===D.current&&(console.error("Record search failed:",P),b([]),w(!1))})},E=A.useRef(void 0);A.useEffect(()=>()=>clearTimeout(E.current),[]);const M=T=>{f(T),clearTimeout(E.current),E.current=setTimeout(()=>U(T),qoe)},B=r?.DisplayName?.UserLocalizedLabel?.Label??e,k=`${I}Dataverse follows up to 100 levels.`,_=j.jsx(Qt,{text:`The ${B} record to start from. Its ID (${r?.PrimaryIdAttribute??"primary key"}) is what the condition stores. The operators apply only to a hierarchical relationship.`,href:Kt.hierarchy}),S=o&&j.jsx(dd,{as:"button",inline:!0,onClick:()=>{l||h(i),a(T=>!T)},children:l?"Search for a record instead":"Enter an ID instead"});if(l||!o){const T=u.trim()!==""&&!oh(u);return j.jsxs(j.Fragment,{children:[j.jsx(kr,{label:"Record ID",info:_,hint:C?`No ${B} record with this ID was found, or you can't read it. ${k}`:k,validation:T?{state:"error",message:`Enter an ID like ${U5}.`}:void 0,children:j.jsx(_n,{className:s.mono,value:u,placeholder:U5,onChange:(z,P)=>{h(P.value);const O=P.value.trim();G(O===""?void 0:oh(O)?ih(O):O)}})}),S]})}return j.jsxs(j.Fragment,{children:[j.jsx(kr,{label:"Record",info:_,hint:k,children:j.jsx(Zn,{freeform:!0,placeholder:"Search by name (begins with)",value:d,selectedOptions:i?[ih(i).toLowerCase()]:[],onChange:T=>M(T.target.value),onOpenChange:(T,z)=>{z.open&&g===void 0&&U(d===m?"":d)},onOptionSelect:(T,z)=>{if(!z.optionValue||z.optionValue===a0)return;const P=g?.find(O=>O.id.toLowerCase()===z.optionValue);p(P?.name),f(P?.name||z.optionValue),G(z.optionValue)},children:y&&g===void 0?j.jsx(Jt,{disabled:!0,value:a0,text:"",children:j.jsx(hn,{size:"tiny",label:"Searching…"})}):g&&g.length>0?g.map(T=>j.jsx(Jt,{value:T.id.toLowerCase(),text:T.name||T.id,children:j.jsxs("span",{className:s.optionText,children:[T.name||"(No name)",j.jsx("span",{className:s.optionSecondary,children:T.id})]})},T.id)):j.jsx(Jt,{disabled:!0,value:a0,text:"",children:d?`No ${B} records start with "${d}"`:`No ${B} records found`})})}),S]})}const s0="__this",X5=new Set(["Picklist","State","Status"]),l0=new Set(["Integer","BigInt","Decimal","Double"]),Hoe=new Set(["Uniqueidentifier","Lookup","Customer","Owner"]),Voe=new Set(["under","not-under","above","eq-or-under","eq-or-above"]),Wl=e=>{const r=typeof e=="number"?e:typeof e=="string"&&/^-?\d+$/.test(e.trim())?Number(e):NaN;return Number.isInteger(r)?r:void 0};function v7({node:e,entityName:r,fetchQuery:t,findings:n,onUpdate:s,columnFilter:o=!1}){const i=Mi(),[c,l]=A.useState(null),a=A.useMemo(()=>A8(t),[t]),u=A.useMemo(()=>YY(t,e.id),[t,e.id]),h=e.entityname?a.find(X=>X.identifier===e.entityname):void 0,d=u&&h?h.entityName:r,f=A.useMemo(()=>L8(t).get(e.id),[t,e.id]),{isHierarchical:m,metadata:p}=jp(d),g=A.useMemo(()=>tQ(c??void 0,m),[c,m]),b=A.useMemo(()=>sQ(c?.AttributeType),[c?.AttributeType]);A.useEffect(()=>{let X=!1;if(!e.attribute||!d){l(null);return}return jc(d).then(async K=>{const J=K.find(L=>L.LogicalName===e.attribute),H=J?.AttributeType;let Z=J;if(J&&H&&(l0.has(H)||H==="DateTime"))try{Z=await xJ(d,e.attribute,H)}catch(L){console.error(`Failed to load detailed metadata for ${e.attribute}:`,L)}X||l(Z??null)}).catch(K=>{console.error("Failed to load attribute metadata for operator filtering:",K),!X&&l(null)}),()=>{X=!0}},[e.attribute,d]);const y=md(e.operator),w=g.find(X=>X.value===e.operator),C=jh(e.operator),N=C==="two",I=C==="multiple",$=C==="single"||C==="two"&&!c||C==="multiple"&&!c,D=e.valueof!==void 0,F=rb.has(e.operator),V=F&&b.length>0,G=Er(n,"valueof"),U=Er(n.filter(X=>X.kind==="advice"),"value"),E=c?.AttributeType,M=c?.AttributeTypeName?.Value==="MultiSelectPicklistType",k=!(E&&(X5.has(E)||l0.has(E)))&&E!=="Boolean"&&E!=="DateTime"&&!M&&ub(e.operator),_=Voe.has(e.operator)&&!!c?.IsPrimaryId,S=typeof e.value=="string"?e.value:"",T=E&&Hoe.has(E)&&S.trim()!==""&&!oh(S)?{state:"error",message:"Enter an ID like 00000000-0000-0000-0000-000000000000."}:void 0,z=!o&&(u&&a.length>0||!!e.entityname),P=e.entityname?h?.displayLabel??e.entityname:`This entity (${r})`,O=()=>E&&X5.has(E)||M?j.jsx(Sre,{entityLogicalName:d,attributeLogicalName:e.attribute,value:typeof e.value=="number"?e.value:void 0,onChange:X=>s({value:X}),placeholder:"Select a value"}):E==="Boolean"?j.jsx(_re,{entityLogicalName:d,attributeLogicalName:e.attribute,value:typeof e.value=="boolean"?e.value:typeof e.value=="string"?e.value==="true"||e.value==="1":void 0,onChange:X=>s({value:X}),placeholder:"Select true or false"}):E&&l0.has(E)&&c?j.jsx(gb,{attribute:c,value:typeof e.value=="number"?e.value:void 0,onChange:X=>s({value:X}),placeholder:"Enter a number"}):E==="DateTime"&&c?j.jsx(Sb,{attribute:c,value:typeof e.value=="string"||e.value instanceof Date?e.value:void 0,onChange:X=>s({value:X?.toISOString()}),placeholder:"Select a date"}):j.jsx(_n,{value:typeof e.value=="string"||typeof e.value=="number"?String(e.value):"",onChange:(X,K)=>s({value:K.value||void 0}),placeholder:"Value"});return j.jsx("div",{className:i.container,children:j.jsxs("div",{className:i.section,children:[!o&&j.jsx(Xn,{children:"Condition"}),z&&j.jsx(kr,{label:"Entity",validation:Er(n,"entityname"),info:j.jsx(Qt,{text:"Filter on a link-entity's attribute after the join instead of within it, usually with an outer link-entity (for example, records with no related record). Uses the link-entity's alias, or its name when it has none.",href:Kt.filtersOnLinkEntity}),children:j.jsxs(po,{value:P,selectedOptions:[e.entityname??s0],onOptionSelect:(X,K)=>s({entityname:K.optionValue===s0?void 0:K.optionValue,attribute:void 0,operator:void 0,value:void 0,valueof:void 0}),children:[j.jsx(Jt,{value:s0,children:`This entity (${r})`}),e.entityname&&!h&&j.jsx(Jt,{value:e.entityname,text:e.entityname,children:j.jsxs("span",{className:i.optionText,children:[e.entityname,j.jsx("span",{className:i.optionSecondary,children:"Not a link-entity in this query"})]})}),u&&a.map(X=>j.jsx(Jt,{value:X.identifier,children:X.displayLabel},X.nodeId))]})}),!o&&j.jsx(kr,{label:"Attribute",required:!0,validation:e.attribute?void 0:{state:"error",message:"Choose an attribute to filter on."},info:j.jsx(Qt,{text:`The logical name of the ${d} attribute to filter on.`,href:Kt.condition}),children:j.jsx(pc,{entityLogicalName:d,value:e.attribute,onChange:X=>s({attribute:X||void 0,operator:void 0,value:void 0,valueof:D?"":void 0}),placeholder:"Select an attribute"})}),j.jsx(kr,{label:"Operator",required:!0,validation:Er(n,"operator"),info:j.jsx(Qt,{text:[w?.description,M&&!w?.description?"For a choices attribute, contain-values matches records where any of the given options is selected.":void 0,"The operators listed depend on the attribute's type."].filter(Boolean).join(" "),href:w?.docsUrl??(M?Kt.choices:Kt.operators)}),children:j.jsxs(po,{value:w?.label??e.operator??"",selectedOptions:e.operator?[e.operator]:[],onOptionSelect:(X,K)=>{const J=K.optionValue??"",H=rQ(e.operator,J,e.value);s({operator:J,value:uZ(e.operator,J,H),...D&&!rb.has(J)?{valueof:void 0}:{}})},placeholder:"Select an operator",children:[e.operator&&!w&&g.length>0&&j.jsx(Jt,{value:e.operator,text:e.operator,children:j.jsxs("span",{className:i.optionText,children:[e.operator,j.jsx("span",{className:i.optionSecondary,children:"Not listed for this attribute type"})]})}),g.map(X=>j.jsx(Jt,{value:X.value,children:X.label},X.value))]})}),(C==="integer"||C==="year")&&j.jsx(Ka,{label:C==="year"?"Fiscal year":"Number",value:Wl(e.value),min:C==="year"?1e3:1,max:C==="year"?9999:void 0,onChange:X=>s({value:X}),validation:Wl(e.value)===void 0?{state:"error",message:C==="year"?"Enter a four-digit fiscal year.":"Enter a whole number above 0."}:void 0,info:j.jsx(Qt,{text:C==="year"?"A four-digit fiscal year, per the environment's fiscal year settings.":"A whole number above 0 (for example 7 for the last 7 days). Dataverse rejects 0, negative numbers and dates.",href:Kt.operators})}),C==="fiscalPeriodYear"&&j.jsxs(j.Fragment,{children:[j.jsx(Ka,{label:"Fiscal period",value:Array.isArray(e.value)?Wl(e.value[0]):void 0,min:1,onChange:X=>s({value:[X??"",Array.isArray(e.value)?e.value[1]??"":""]}),validation:!Array.isArray(e.value)||Wl(e.value[0])===void 0?{state:"error",message:"Enter the fiscal period (1 or more)."}:void 0,info:j.jsx(Qt,{text:"The period number within the fiscal year: a month, quarter or semester, depending on the environment's fiscal year settings. A period that doesn't exist returns no records.",href:Kt.operators})}),j.jsx(Ka,{label:"Fiscal year",value:Array.isArray(e.value)?Wl(e.value[1]):void 0,min:1e3,max:9999,onChange:X=>s({value:[Array.isArray(e.value)?e.value[0]??"":"",X??""]}),validation:!Array.isArray(e.value)||Wl(e.value[1])===void 0?{state:"error",message:"Enter a four-digit fiscal year."}:void 0,info:j.jsx(Qt,{text:"A four-digit fiscal year.",href:Kt.operators})})]}),y&&I&&c&&j.jsx(kr,{label:"Values",info:j.jsx(Qt,{text:"Each value is written as a <value> element.",href:Kt.condition}),children:j.jsx(Ioe,{entityLogicalName:d,attributeLogicalName:e.attribute,attribute:c,value:Array.isArray(e.value)?e.value:void 0,onChange:X=>s({value:X}),placeholder:"Enter values (comma-separated)"})}),y&&N&&!I&&c&&j.jsx(kr,{label:"Values",info:j.jsx(Qt,{text:"The two values the operator needs, written as <value> elements.",href:Kt.operators}),children:j.jsx(Eoe,{attribute:c,value:Array.isArray(e.value)&&e.value.length===2?[e.value[0],e.value[1]]:[void 0,void 0],onChange:X=>s({value:X}),placeholder1:"From",placeholder2:"To"})}),$&&!o&&(F||D)&&j.jsx(kr,{label:"Compare to",validation:G?.state==="error"?G:void 0,hint:!V&&!D&&c?`Comparing a ${c.AttributeTypeName?.Value?.replace(/Type$/,"")??c.AttributeType} attribute to another attribute isn't verified to work, so it isn't offered.`:void 0,info:j.jsx(Qt,{text:"A fixed value, or another attribute of the same record or of a link-entity. Comparing attributes works only with eq, ne, gt, ge, lt and le. The docs require the same type; FetchXML Studio also offers the type pairs verified to work (for example Money with Decimal).",href:Kt.filterOnColumnValues}),children:j.jsxs(ta,{layout:"horizontal",value:D?"attribute":"value",onChange:(X,K)=>s(K.value==="attribute"?{value:void 0,valueof:""}:{valueof:void 0,value:void 0}),children:[j.jsx(Yr,{value:"value",label:"A value"}),j.jsx(Yr,{value:"attribute",label:"Another attribute",disabled:!V&&!D})]})}),$&&(D?j.jsx(Poe,{fetchQuery:t,rootEntityName:t.entity.name,effectiveEntityName:d,scope:f,sameAlias:u?e.entityname:f?.selfAlias,valueof:e.valueof??"",compatibleTypes:b,onChange:X=>s({valueof:X??""})}):k?j.jsx(Foe,{operator:e.operator,value:e.value,advice:U,onChange:X=>s({value:X})},e.id):_?j.jsx($oe,{entityName:d,metadata:p,value:e.value,onChange:X=>s({value:X})},e.id):j.jsx(kr,{label:"Value",validation:is(T,U),info:j.jsx(Qt,{text:"The value to compare the attribute with.",href:Kt.filterRows}),children:O()})),!y&&e.valueof!==void 0&&j.jsx(_a,{text:`Compare to: ${e.valueof||"(empty)"}`,validation:{state:"warning",message:G?.message??`The '${e.operator}' operator doesn't compare to a value.`},onRemove:()=>s({valueof:void 0})}),e.aggregate&&j.jsx(_a,{text:`Aggregate (undocumented): ${e.aggregate}`,validation:{state:"warning",message:Er(n,"aggregate")?.message??"Dataverse ignores aggregate on a condition. FetchXML can't filter on aggregate values."},onRemove:()=>s({aggregate:void 0})})]})})}const Woe=new Set(["Lookup","Customer","Owner"]),G5="matchfirstrowusingcrossapply";function Uoe(e){const r=new Set;for(const t of e)for(const n of Object.keys(t))n.includes("@")||r.add(n);return[...r]}function Xoe(e){const r=[],t=(n,s)=>n.links.forEach(o=>{const i=s&&!cl.has(o.linkType);r.push({link:o,returnsColumns:i}),t(o,i)});return t(e.entity,!0),r}function o1(e,r,t,n){const s=Uoe(r);if(!e)return s.map(y=>({key:y}));const o=new Set(s),i=Xoe(e),c=new Set(i.filter(y=>!y.returnsColumns).map(y=>y.link.id)),l=[],a=new Set,u=y=>{a.has(y.key)||(a.add(y.key),l.push(y))},h=y=>{const{attribute:w,container:C}=y;if(w.alias)return y.key;const N=t?.(C.name,w.name);if(y.isRoot){const I=`_${w.name}_value`;return N?.AttributeType?Woe.has(N.AttributeType)?I:w.name:o.has(I)?I:w.name}if(C.linkType===G5){if(o.has(y.key))return y.key;if(N?.SchemaName)return N.SchemaName;const I=s.find($=>!$.includes(".")&&!a.has($)&&$.toLowerCase()===w.name);if(I)return I}return y.key},d=n&&n!==e?new Set(o1(n,r,t).map(y=>y.key)):void 0;for(const y of Cp(e)){if(!y.isRoot&&c.has(y.container.id))continue;const w=h(y);d&&!d.has(w)&&!o.has(w)||u({key:w,column:y})}const f=!!e.entity.allAttributes?.enabled||e.entity.attributes.length===0,m=zh(e),p=i.filter(y=>y.returnsColumns&&y.link.allAttributes?.enabled).map(y=>y.link),g=p.map(y=>`${m.get(y.id)}.`),b=p.some(y=>y.linkType===G5);for(const y of s){if(a.has(y))continue;(y.includes(".")?g.some(C=>y.startsWith(C)):f||b&&y!==y.toLowerCase())&&u({key:y})}return l}function y7(e,r){if(!r||r.columns.length===0)return e;const t=new Map;r.columns.forEach((i,c)=>{t.has(i.name)||t.set(i.name,c)});const n=i=>{const c=t.get(i.key)??(i.column?t.get(i.column.key):void 0);if(c!==void 0)return c;const l=/^_(.+)_value$/.exec(i.key)?.[1];return l?t.get(l):void 0},s=e.filter(i=>n(i)!==void 0),o=e.filter(i=>n(i)===void 0);return[...s.sort((i,c)=>n(i)-n(c)),...o]}const w7=e=>e==null?"":typeof e=="object"?JSON.stringify(e):String(e);function _b(e,r){return w7(e[r])}function x7(e,r){return w7(Xi(e,r)??e[r])}function Mu(e,r,t="shown"){return t==="raw"||r.showsRaw?_b(e,r.sourceCol):x7(e,r.sourceCol)}function Cb(e){return/[\t\r\n"]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function Goe(e,r){return r==="raw"?e.filter(t=>!t.id.endsWith("__raw")):e}function Koe(e,r,t="shown"){const n=Goe(r,t),s=n.map(i=>Cb(i.header)).join(" "),o=e.map(i=>n.map(c=>Cb(Mu(i,c,t))).join(" "));return[s,...o].join(`
|
|
74
|
-
`)}function
|
|
75
|
-
`)}const Qoe=e=>`${e} row${e===1?"":"s"}`,Zoe=e=>ws(e);function Joe(e){switch(e){case"Lookup":case"Customer":case"Owner":case"Uniqueidentifier":return"GUID";case"DateTime":return"ISO date";case"Picklist":case"State":case"Status":return"option value";case"Boolean":return"true/false";case"Integer":case"BigInt":case"Decimal":case"Double":case"Money":return"number";default:return}}const eie=42,tie=wr({container:{display:"flex",flexDirection:"column",height:"100%",backgroundColor:le.colorNeutralBackground1,position:"relative"},gridWrapper:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",backgroundColor:le.colorNeutralBackground1,position:"relative",minHeight:0},gridContent:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",width:"100%",minHeight:0},infoBar:{display:"flex",flexWrap:"wrap",columnGap:le.spacingHorizontalL,alignItems:"center",justifyContent:"space-between",padding:"8px 16px",borderTop:`1px solid ${le.colorNeutralStroke2}`,backgroundColor:le.colorNeutralBackground1,fontSize:le.fontSizeBase200,color:le.colorNeutralForeground2,minHeight:"32px",zIndex:1},selectionWarning:{color:le.colorPaletteYellowForeground1,marginLeft:le.spacingHorizontalM},emptyState:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:le.colorNeutralForeground3,fontSize:le.fontSizeBase300},cellContent:{padding:`${le.spacingVerticalS} ${le.spacingHorizontalM}`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},row:{boxSizing:"border-box",height:"44px"},body:{scrollbarGutter:"stable"},headerCellContent:{display:"flex",alignItems:"center",gap:le.spacingHorizontalXS},sortIndicator:{display:"flex",alignItems:"center",marginLeft:"auto"},headerCell:{},filterIndicator:{flexShrink:0,color:le.colorBrandForeground1},filterBar:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:le.spacingHorizontalS,padding:`${le.spacingVerticalXS} ${le.spacingHorizontalM}`,borderBottom:`1px solid ${le.colorNeutralStroke2}`},search:{marginLeft:"auto",minWidth:"140px",width:"240px",flexShrink:1},filterSurface:{display:"flex",flexDirection:"column",gap:le.spacingVerticalS,width:"320px",maxWidth:"calc(100vw - 32px)"},filterNote:{color:le.colorNeutralForeground3},filterActions:{display:"flex",justifyContent:"flex-end",gap:le.spacingHorizontalS}});function rie(e){switch(e){case"DateTime":return["Oldest to newest","Newest to oldest"];case"Integer":case"BigInt":case"Decimal":case"Double":case"Money":return["Smallest to largest","Largest to smallest"];default:return["A to Z","Z to A"]}}function K5(e){if(!e.operator)return!1;if(!md(e.operator))return!0;const{value:r}=e;return Array.isArray(r)?r.length>0&&r.every(t=>t!==""&&t!==void 0&&t!==null):r!=null&&r!==""}const c0=(e,r)=>e.attribute===r.attribute&&(e.entityname||void 0)===r.entityname,nie=A.forwardRef(function({result:r,isLoading:t,isLoadingMore:n,attributeMetadata:s,fetchQuery:o,primaryIdAttribute:i,onSelectedCountChange:c,onSelectionChange:l,columnConfig:a,onColumnResize:u,onSortChange:h,onLoadMore:d,displaySettings:f,searchText:m="",onSearchTextChange:p,columnFilters:g,onAddColumnFilter:b,onRemoveColumnFilters:y,onVisibleCountChange:w},C){const N=tie(),{targetDocument:I}=Yt(),$=p3({targetDocument:I}),[D,F]=A.useState(new Set),V=A.useRef(null),G=A.useRef(null),[U,E]=A.useState({width:0,height:0}),[M,B]=A.useState(0);A.useEffect(()=>{const je=V.current;if(!je){Ie("resultsGrid","[ResultsGrid] ResizeObserver: container ref is null");return}Ie("resultsGrid","[ResultsGrid] ResizeObserver: setting up observer on container",je);const Pe=new ResizeObserver(fe=>{for(const ye of fe){const{width:Ne,height:Ue}=ye.contentRect;Ie("resultsGrid","[ResultsGrid] ResizeObserver: dimensions updated",{width:Ne,height:Ue}),E({width:Ne,height:Ue})}});return Pe.observe(je),()=>Pe.disconnect()},[r]),A.useEffect(()=>{const je=G.current;if(!je)return;const Pe=new ResizeObserver(()=>{const fe=je.offsetHeight;Ie("resultsGrid","[ResultsGrid] Header height:",fe),B(fe)});return Pe.observe(je),()=>Pe.disconnect()},[r]);const k=A.useRef({onSelectedCountChange:c,onSelectionChange:l});k.current={onSelectedCountChange:c,onSelectionChange:l},A.useEffect(()=>{F(new Set),k.current.onSelectedCountChange?.(0),k.current.onSelectionChange?.([])},[r]);const _=A.useMemo(()=>{const je=new Map;if(!o?.entity)return je;for(const[Pe,fe]of bre(o)){je.set(Pe,{direction:fe});const ye=vd(o,Pe);ye?.isRoot&&!ye.attribute.alias&&je.set(`_${ye.attribute.name}_value`,{direction:fe})}return je},[o]),S=A.useMemo(()=>hre(r?.rows??[],i),[r?.rows,i]),T=S.getRowId,z=A.useMemo(()=>{if(!r)return[];const je=(Pe,fe)=>s?.get(Pe)?.get(fe);return y7(o1(o,r.rows,je,r.query),a)},[r,o,s,a]),P=A.useMemo(()=>{const je=new Map;for(const Pe of z)Pe.column&&je.set(Pe.key,Pe.column.key);return Pe=>je.get(Pe)??Pe},[z]),O=A.useMemo(()=>{const je=new Map;if(!o?.entity?.name)return je;const Pe=o.entity.name;o.entity.attributes&&o.entity.attributes.forEach(Ne=>{const Ue=Ne.alias||Ne.name;je.set(Ue,{attributeName:Ne.name,entityName:Pe,alias:Ne.alias}),je.set(`_${Ne.name}_value`,{attributeName:Ne.name,entityName:Pe,isLookupColumn:!0})});const fe=zh(o),ye=(Ne,Ue)=>{Ne.forEach(vt=>{const ze=fe.get(vt.id)??vt.alias??vt.name,gt=vt.to||Ue;vt.attributes&&vt.attributes.forEach(bt=>{const at=bt.alias||`${ze}.${bt.name}`;je.set(at,{attributeName:bt.name,entityName:vt.name,alias:bt.alias,linkEntityAlias:ze,lookupAttribute:gt})}),vt.links&&ye(vt.links,vt.to)})};return o.entity.links&&ye(o.entity.links),je},[o]),{columns:X,columnDisplayNames:K,columnAttributeTypes:J,copyColumns:H}=A.useMemo(()=>{if(!r||z.length===0)return{columns:[],columnDisplayNames:new Map,columnAttributeTypes:new Map,copyColumns:[]};const je=o?zh(o):new Map,Pe=new Map(Q0(o??null).map(ze=>[je.get(ze.id),ze])),fe=ze=>{const gt=ze.indexOf("."),bt=ze.slice(0,gt),at=gt>0?Pe.get(bt):void 0;return at?{attributeName:ze.slice(gt+1),entityName:at.name,linkEntityAlias:bt,lookupAttribute:at.to}:void 0},ye=new Map,Ne=new Map,Ue=[];return{columns:z.map(ze=>ze.key).flatMap(ze=>{const gt=O.get(ze)??O.get(P(ze))??fe(ze),bt=(qt,ce)=>s?.get(qt)?.get(ce);let at;if(gt)at=bt(gt.entityName,gt.attributeName);else if(ze.startsWith("_")&&ze.endsWith("_value")){const qt=ze.slice(1,-6),ce=o?.entity?.name;ce&&(at=bt(ce,qt))}else{const qt=o?.entity?.name;qt&&(at=bt(qt,ze))}let Bt;const Ut=()=>gt?.isLookupColumn?gt.attributeName||ze.slice(1,-6):gt?.linkEntityAlias?`${gt.linkEntityAlias}.${gt.attributeName||ze}`:gt?.attributeName||ze;if(f?.useLogicalNames)Bt=Ut();else if(gt?.alias)Bt=gt.alias;else if(gt?.isLookupColumn)Bt=at?.DisplayName?.UserLocalizedLabel?.Label||gt.attributeName||ze.slice(1,-6);else if(gt?.linkEntityAlias){const qt=at?.DisplayName?.UserLocalizedLabel?.Label||gt.attributeName;let ce=gt.linkEntityAlias;const we=o?.entity?.name,qe=gt.lookupAttribute&&we?bt(we,gt.lookupAttribute):void 0;if(["Lookup","Customer","Owner"].includes(qe?.AttributeType??"")&&qe?.DisplayName?.UserLocalizedLabel?.Label)ce=qe.DisplayName.UserLocalizedLabel.Label;else{const kt=ft=>ft?.find(hr=>hr.LogicalName===gt.entityName),ot=Zt.getEntityMetadata(gt.entityName)??kt(Zt.getAllEntityMetadata())??kt(Zt.getAllEntities());ot?.DisplayName?.UserLocalizedLabel?.Label&&(ce=ot.DisplayName.UserLocalizedLabel.Label)}Bt=`${qt} (${ce})`}else at?.DisplayName?.UserLocalizedLabel?.Label?Bt=at.DisplayName.UserLocalizedLabel.Label:ze.startsWith("_")&&ze.endsWith("_value")?Bt=ze.slice(1,-6):Bt=ze;const or=_.get(ze)??_.get(P(ze)),Tr=o?n0(o,ze):void 0,Sr=!!Tr&&!("reason"in Tr)&&!!g?.some(qt=>c0(qt,Tr)),_r=f?.valueDisplayMode??"formatted",xt=_r==="both"&&r?.rows?.some(qt=>{const ce=qt[ze],we=Xi(qt,ze);return we!==void 0&&we!==ce});if(ye.set(ze,Bt),Ne.set(ze,at?.AttributeType),_r==="both"&&xt){Ue.push({id:ze,header:Bt,sourceCol:ze,showsRaw:!1},{id:`${ze}__raw`,header:`${Bt} (Raw)`,sourceCol:ze,showsRaw:!0}),ye.set(`${ze}__raw`,`${Bt} (Raw)`),Ne.set(`${ze}__raw`,at?.AttributeType);const qt=rc({columnId:ze,compare:(we,qe)=>{const Xe=String(Xi(we,ze)??we[ze]??""),kt=String(Xi(qe,ze)??qe[ze]??"");return Xe.localeCompare(kt)},renderHeaderCell:()=>j.jsxs("span",{className:N.headerCellContent,children:[j.jsx("span",{style:{fontWeight:600},children:Bt}),Sr&&j.jsx(F2,{className:N.filterIndicator,"aria-label":"Filtered"}),or&&j.jsx("span",{className:N.sortIndicator,children:or.direction==="ascending"?j.jsx(O2,{}):j.jsx(P2,{})})]}),renderCell:we=>{const qe=we[ze],Xe=Xi(we,ze);return j.jsx(Gl,{truncate:!0,children:M5(at?.AttributeType,qe,Xe,at)})}}),ce=rc({columnId:`${ze}__raw`,compare:(we,qe)=>{const Xe=String(we[ze]??""),kt=String(qe[ze]??"");return Xe.localeCompare(kt)},renderHeaderCell:()=>j.jsx("span",{className:N.headerCellContent,children:j.jsxs("span",{style:{fontWeight:600},children:[Bt," (Raw)"]})}),renderCell:we=>{const qe=we[ze];return j.jsx(Gl,{truncate:!0,children:qe==null?j.jsx("span",{children:"—"}):j.jsx("span",{children:j.jsx(ol,{text:String(qe)})})})}});return[qt,ce]}return Ue.push({id:ze,header:Bt,sourceCol:ze,showsRaw:_r==="raw"}),rc({columnId:ze,compare:(qt,ce)=>{const we=String(Xi(qt,ze)??qt[ze]??""),qe=String(Xi(ce,ze)??ce[ze]??"");return we.localeCompare(qe)},renderHeaderCell:()=>j.jsxs("span",{className:N.headerCellContent,children:[j.jsx("span",{style:{fontWeight:600},children:Bt}),Sr&&j.jsx(F2,{className:N.filterIndicator,"aria-label":"Filtered"}),or&&j.jsx("span",{className:N.sortIndicator,children:or.direction==="ascending"?j.jsx(O2,{}):j.jsx(P2,{})})]}),renderCell:qt=>{const ce=qt[ze],we=Xi(qt,ze);return _r==="raw"?j.jsx(Gl,{truncate:!0,children:ce==null?j.jsx("span",{children:"—"}):j.jsx("span",{children:j.jsx(ol,{text:String(ce)})})}):j.jsx(Gl,{truncate:!0,children:M5(at?.AttributeType,ce,we,at)})}})}),columnDisplayNames:ye,columnAttributeTypes:Ne,copyColumns:Ue}},[r,s,O,o,z,P,N,_,f,g]),Z=A.useCallback((je,Pe)=>{F(Pe.selectedItems),c?.(Pe.selectedItems.size),l?.(S.toRecordIds(Pe.selectedItems))},[c,l,S]),[L,q]=A.useState({open:!1}),[Y,re]=A.useState(null),[ie,ne]=A.useState(null),ae=A.useCallback((je,Pe)=>{const fe=String(Pe.sortColumn);if(!je.shiftKey){const ze=je.target.closest('[role="columnheader"]');q({open:!0,anchor:ze??je.currentTarget,columnId:fe});return}if(!h)return;const ye=fe.replace(/__raw$/,""),Ne=!0,Ue=_.get(ye)??_.get(P(ye));let vt;Ue?vt=Ue.direction==="ascending"?"descending":"ascending":vt="ascending",h({columnId:ye,direction:vt,isMultiSort:Ne})},[h,_,P]),[be,pe]=A.useState(null),te=A.useCallback(je=>{pe({entity:je,status:"loading",text:`Counting all ${je} records…`}),BZ(je).then(Pe=>pe(Pe===void 0?{entity:je,status:"error",text:`Dataverse returned no total for ${je}.`}:{entity:je,status:"done",text:ore(je,Pe)}),Pe=>pe({entity:je,status:"error",text:`Couldn't count all ${je} records. ${zn(Pe)}`}))},[]),se=r?nre(r.totalRecordCount,r.totalRecordCountLimitExceeded,r.rows.length):void 0,ue=m.trim(),he=A.useMemo(()=>{const je=r?.rows??[];if(!ue)return je;const Pe=ue.toLowerCase();return je.filter(fe=>H.some(ye=>Mu(fe,ye).toLowerCase().includes(Pe)))},[r,ue,H]);A.useEffect(()=>{w?.(he.length)},[he.length,w]),A.useEffect(()=>{if(!ue||D.size===0)return;const je=new Set(he.map(fe=>T(fe))),Pe=new Set([...D].filter(fe=>je.has(fe)));Pe.size!==D.size&&Z(void 0,{selectedItems:Pe})},[ue,he,D,T,Z]);const me=mr("results-toaster"),{dispatchToast:xe}=JV(me),[Be,Re]=A.useState({open:!1}),He=A.useRef(null),Je=A.useCallback(je=>H.find(Pe=>Pe.id===je),[H]),Te=A.useCallback(()=>(r?.rows??[]).filter(je=>D.has(T(je))),[r,D,T]),Ee=A.useCallback(async(je,Pe)=>{const fe=await Zoe(je);xe(j.jsx(KS,{children:j.jsx(YS,{children:fe?`${Pe} copied`:"Couldn't copy to the clipboard"})}),{intent:fe?"success":"error",timeout:fe?2e3:4e3})},[xe]),$e=A.useCallback((je,Pe)=>{je.length!==0&&Ee(Koe(je,H,Pe),Qoe(je.length))},[Ee,H]);A.useImperativeHandle(C,()=>({copyRows:(je,Pe)=>$e(je==="all"?he:Te(),Pe)}),[$e,he,Te]);const Ze=A.useCallback((je,Pe,fe)=>{je.preventDefault();const{clientX:ye,clientY:Ne}=je,Ue=ye===0&&Ne===0?je.currentTarget:{getBoundingClientRect:()=>({x:ye,y:Ne,top:Ne,left:ye,bottom:Ne,right:ye,width:0,height:0})};Re({open:!0,target:Ue,item:Pe,columnId:fe})},[]),yt=A.useCallback(je=>{if(!(je.ctrlKey||je.metaKey)||je.key.toLowerCase()!=="c"||je.altKey||je.shiftKey||window.getSelection()?.toString())return;if(D.size>0){je.preventDefault(),$e(Te(),"shown");return}const Pe=He.current,fe=Pe&&Je(Pe.columnId);Pe&&fe&&(je.preventDefault(),Ee(Mu(Pe.item,fe),fe.header))},[D,$e,Te,Je,Ee]),dt=A.useMemo(()=>{const{item:je,columnId:Pe}=Be,fe=Pe?Je(Pe):void 0;if(!(!je||!fe))return{item:je,column:fe,shown:Mu(je,fe),raw:_b(je,fe.sourceCol),rawKind:Joe(J.get(fe.id))}},[Be,Je,J]),Ke=L.columnId?.replace(/__raw$/,""),We=A.useMemo(()=>o&&Ke?n0(o,Ke):void 0,[o,Ke]),nt=We&&!("reason"in We)?(g??[]).filter(je=>c0(je,We)):[],[Ve,wt]=rie(L.columnId?J.get(L.columnId):void 0),Wt=je=>{Ke&&h?.({columnId:Ke,direction:je,isMultiSort:!1})},Ct=()=>{!L.anchor||!Ke||!We||"reason"in We||(re({anchor:L.anchor,header:Je(Ke)?.header??We.attribute,target:We}),ne({id:"column-filter-draft",type:"condition",attribute:We.attribute,entityname:We.entityname,operator:""}))},Tt=()=>{if(!ie||!K5(ie))return;const{attribute:je,entityname:Pe,operator:fe,value:ye}=ie;b?.({attribute:je,entityname:Pe,operator:fe,value:ye}),re(null)},ct=A.useMemo(()=>Q0(o??null),[o]),Ot=A.useCallback(je=>{const fe=(je.entityname?ct.find(bt=>(bt.alias||bt.name)===je.entityname):void 0)?.name??o?.entity.name??"",ye=s?.get(fe)?.get(je.attribute),Ne=f?.useLogicalNames?`${je.entityname?`${je.entityname}.`:""}${je.attribute}`:`${ye?.DisplayName?.UserLocalizedLabel?.Label??je.attribute}${je.entityname?` (${je.entityname})`:""}`,Ue=(fc.find(bt=>bt.value===je.operator)?.label??je.operator).toLowerCase(),vt=je.value===void 0||je.value===null?[]:Array.isArray(je.value)?je.value:[je.value],ze=H.find(bt=>{const at=o?n0(o,bt.sourceCol):void 0;return!!at&&!("reason"in at)&&c0(je,at)}),gt=bt=>{const at=ze&&r?.rows.find(Bt=>_b(Bt,ze.sourceCol)===String(bt));return at&&ze?x7(at,ze.sourceCol):String(bt)};return[Ne,Ue,vt.map(gt).join(", ")].filter(Boolean).join(" ")},[ct,o,s,f,H,r]),Ft=!!g&&g.length>0,vr=!!p&&((r?.rows.length??0)>0||!!m),fr=Ft||vr?j.jsxs("div",{className:N.filterBar,children:[Ft&&j.jsxs(j.Fragment,{children:[j.jsx(st,{size:200,weight:"semibold",children:"Filters"}),j.jsx(Nv,{size:"small","aria-label":"Column filters",onDismiss:(je,Pe)=>y?.([String(Pe.value)]),children:g.map(je=>{const Pe=Ot(je);return j.jsx(pp,{value:je.id,dismissible:!0,dismissIcon:{"aria-label":`Remove filter: ${Pe}`},children:Pe},je.id)})}),g.length>1&&j.jsx(St,{size:"small",appearance:"transparent",onClick:()=>y?.(g.map(je=>je.id)),children:"Clear all"})]}),vr&&j.jsx(Or,{content:"Searches the loaded rows. To search every record, use Filter by… in a column header.",relationship:"description",children:j.jsx(zv,{className:N.search,size:"small",placeholder:"Search loaded rows","aria-label":"Search loaded rows",value:m,onChange:(je,Pe)=>p?.(Pe.value)})})]}):null,zt=A.useCallback(({item:je,rowId:Pe},fe,ye,Ne)=>j.jsx(hb,{style:fe,className:N.row,children:({renderCell:Ue,columnId:vt})=>j.jsx(Bv,{focusMode:"group",onContextMenu:ze=>Ze(ze,je,String(vt)),onFocus:()=>{He.current={item:je,columnId:String(vt)}},onBlur:()=>{He.current=null},children:Ne?j.jsx(Q6,{style:{width:"100%"},children:j.jsx(Z6,{shape:"rectangle",animation:"pulse",appearance:"translucent"})}):Ue(je)})},Pe),[N.row,Ze]),tr=A.useMemo(()=>{const je={},Pe=ye=>{switch(ye){case"Uniqueidentifier":return 260;case"DateTime":return 160;case"Boolean":return 100;case"Lookup":case"Customer":case"Owner":return 140;case"Money":return 120;default:return 100}},fe=new Map;if(a)for(const ye of a.columns)fe.set(ye.name,ye.width),fe.set(`_${ye.name}_value`,ye.width);for(const ye of X){const Ne=String(ye.columnId),Ue=fe.get(Ne)??fe.get(P(Ne));if(Ue!==void 0)je[Ne]={minWidth:80,defaultWidth:Ue,idealWidth:Ue};else{const vt=K.get(Ne)??Ne,ze=Math.ceil(vt.length*8)+52,gt=Pe(J.get(Ne)),bt=Math.max(ze,gt),at=Math.max(100,Math.min(bt,320));je[Ne]={minWidth:Math.max(80,Math.min(gt,200)),defaultWidth:at,idealWidth:at}}}return je},[X,a,K,J,P]),gr=A.useCallback((je,Pe)=>{if(u){let fe=P(String(Pe.columnId));fe.startsWith("_")&&fe.endsWith("_value")&&(fe=fe.slice(1,-6)),u(fe,Pe.width)}},[u,P]),Rt=A.useCallback(({visibleStopIndex:je})=>{if(!r||!d||n||ue)return;const Pe=r.rows.length,fe=Math.min(10,Math.max(1,Math.floor(Pe*.1)));je>=Pe-fe&&r.moreRecords&&(Ie("resultsGrid","[ResultsGrid] Near bottom, triggering load more:",{visibleStopIndex:je,rowCount:Pe,threshold:fe,moreRecords:r.moreRecords}),d())},[r,d,n,ue]),ur=je=>fr?j.jsxs("div",{className:N.container,children:[fr,je]}):je;return t?ur(j.jsx("div",{className:N.emptyState,children:"Loading results…"})):r?r.rows.length===0?ur(j.jsx("div",{className:N.emptyState,children:"No records found"})):(Ie("resultsGrid","[ResultsGrid] Rendering grid:",{rowCount:r.rows.length,columnCount:X.length,gridDimensions:U,primaryIdAttribute:i,firstRowId:r.rows.length>0?T(r.rows[0]):"none",columnIds:X.slice(0,5).map(je=>je.columnId),sortStateMapSize:_.size}),j.jsxs("div",{className:N.container,children:[fr,j.jsxs("div",{className:N.gridWrapper,onKeyDown:yt,children:[j.jsx("div",{ref:V,className:N.gridContent,children:j.jsx($_.Provider,{value:ue,children:j.jsxs(q_,{"aria-label":r?.entityLogicalName??"Results",items:he,columns:X,sortable:!0,sortState:{sortColumn:"__sort_managed_externally__",sortDirection:"ascending"},resizableColumns:!0,resizableColumnsOptions:{autoFitColumns:!1},columnSizingOptions:tr,onColumnResize:gr,onSortChange:ae,selectionMode:"multiselect",selectedItems:D,onSelectionChange:Z,getRowId:T,children:[j.jsx(L_,{ref:G,style:{paddingRight:$},children:j.jsx(hb,{style:{minHeight:"43px",maxHeight:"43px"},children:({renderHeaderCell:je})=>j.jsx(jv,{className:N.headerCell,children:je()})})}),j.jsx(F_,{itemSize:eie,height:Math.max(0,U.height-M),listProps:{useIsScrolling:!0,className:N.body,onItemsRendered:Rt},children:zt})]})})}),j.jsxs("div",{className:N.infoBar,children:[j.jsxs("span",{children:["Rows:"," ",ue?`${he.length} of ${r.rows.length} loaded match the search${se?` (${se})`:""}`:se?`${r.rows.length} of ${se}`:r.rows.length,r.moreRecords&&!n&&" (more available)",n&&" (loading more...)",r.executionTimeMs!==void 0&&` | Executed in ${r.executionTimeMs}ms`,r.totalRecordCountLimitExceeded&&r.entityLogicalName&&j.jsxs(j.Fragment,{children:[" | ",be?.entity===r.entityLogicalName&&be.status!=="error"?be.text:j.jsxs(j.Fragment,{children:[be?.entity===r.entityLogicalName&&`${be.text} `,j.jsx(dd,{as:"button",inline:!0,onClick:()=>te(r.entityLogicalName),children:`Count all ${r.entityLogicalName} records (unfiltered snapshot)`})]})]})]}),j.jsxs("span",{children:["Selected: ",D.size,D.size>0&&D.size===r.rows.length&&r.moreRecords&&j.jsx("span",{className:N.selectionWarning,children:'⚠ Selection limited to loaded records. Use "Retrieve all pages" to load more.'})]})]})]}),dt&&j.jsx(_i,{open:Be.open,onOpenChange:(je,Pe)=>Re(fe=>({...fe,open:Pe.open})),positioning:{target:Be.target,position:"below",align:"start"},children:j.jsx(Ti,{children:j.jsxs(Ci,{children:[j.jsx(Gr,{icon:j.jsx(wc,{}),onClick:()=>{Ee(dt.shown,dt.column.header)},children:"Copy value"}),dt.raw!==""&&dt.raw!==dt.shown&&j.jsxs(Gr,{onClick:()=>{Ee(dt.raw,`${dt.column.header} (raw)`)},children:["Copy raw value",dt.rawKind?` (${dt.rawKind})`:""]}),j.jsx(Ku,{}),j.jsx(Gr,{onClick:()=>$e([dt.item],"shown"),children:"Copy row"}),j.jsxs(Gr,{disabled:D.size===0,onClick:()=>$e(Te(),"shown"),children:["Copy selected rows (",D.size,")"]}),j.jsx(Gr,{onClick:()=>{Ee(Yoe(he,dt.column),`${dt.column.header} column`)},children:"Copy column"})]})})}),j.jsx(_i,{open:L.open,onOpenChange:(je,Pe)=>q(fe=>({...fe,open:Pe.open})),positioning:{target:L.anchor,position:"below",align:"start"},children:j.jsx(Ti,{children:j.jsxs(Ci,{children:[j.jsx(Gr,{icon:j.jsx(_R,{}),disabled:!h,onClick:()=>Wt("ascending"),children:Ve}),j.jsx(Gr,{icon:j.jsx(SR,{}),disabled:!h,onClick:()=>Wt("descending"),children:wt}),j.jsx(Ku,{}),We&&"reason"in We?j.jsx(Or,{content:We.reason,relationship:"description",positioning:"after",children:j.jsx(Gr,{icon:j.jsx(Os,{}),disabled:!0,children:"Filter by…"})}):j.jsx(Gr,{icon:j.jsx(Os,{}),disabled:!b||!We,onClick:Ct,children:"Filter by…"}),nt.length>0&&j.jsx(Gr,{icon:j.jsx(LR,{}),onClick:()=>y?.(nt.map(je=>je.id)),children:"Clear filter"})]})})}),j.jsx(kh,{open:!!Y,onOpenChange:(je,Pe)=>{Pe.open||re(null)},positioning:{target:Y?.anchor,position:"below",align:"start"},withArrow:!0,trapFocus:!0,children:j.jsx(xh,{className:N.filterSurface,"aria-label":Y?`Filter by ${Y.header}`:void 0,children:Y&&ie&&o&&j.jsxs(j.Fragment,{children:[j.jsxs(st,{weight:"semibold",children:["Filter by ",Y.header]}),j.jsx(v7,{columnFilter:!0,node:ie,entityName:Y.target.entityName,fetchQuery:o,findings:q8(ie),onUpdate:je=>ne(Pe=>Pe&&{...Pe,...je})}),j.jsx(st,{size:200,className:N.filterNote,children:"Adds a condition to the query and runs it again, so it covers every record."}),j.jsxs("div",{className:N.filterActions,children:[j.jsx(St,{onClick:()=>re(null),children:"Cancel"}),j.jsx(St,{appearance:"primary",disabled:!K5(ie),onClick:Tt,children:"Apply"})]})]})})}),j.jsx(GS,{toasterId:me,position:"bottom-end"})]})):ur(j.jsx("div",{className:N.emptyState,children:"Click Execute to run the query"}))}),oie="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAUCAYAAABvVQZ0AAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAAAHdElNRQfpDBAGOQ0cztfBAAADZ0lEQVQ4y12Tz6tWRRjHP88zc973vq9XL1cSVKiggkgII40oF9EiNCjKVtKioEXt3US7luGuf6CoVRTUOoTAIkrMFtLKstREveH94fG+5z1zzsw8Lea8dmlg4DkzPJ/zne93RgDO3T7DRtymt/RYnedn1nN7opY4ASXFxLxpCfOGZ/bu5eGVPcyBOUbACECHtRE+8wAhR1bcruVZmn80oz1plslmIJmcMjFGpiocXF6mA1qMFhuA0Jkt9dhbHmBJK4CnK3EnzIxshpExE3LOpJTIOdMDcYA1A6y1AozYxAM4BIP9wMQMzIxMBoRsmWyZmBIdRo/RDsC5FWCkDA9gpZZSG2YZM8Mo4EUdB1iHEQzaQSk7YZiRh0YWEGz4iaEidDnRpIiOlsiWSUAGdNBxb31WYNmMnE0AmYWefza3qfsOECwbfd8TQuDc1l9MbEywEkA/nCd2iWuXbuJfOHsaM0ME+btu+PH3NTa3trBs/+kXiG3kwi9/0my1qBNU9f62mWHZ8LGNfHP9Dof37bKf12vqPuFUQXfChNAFwr0OVUG9ok4RFeS+PeBV9chPt5rXLt6qn825JzYjLBTWyBnTcYtTK41OgAJzA3CnOt/M289D6A5tNh1hHkghotFwWfAI+1YrVlc7BEGdYIDziqsU9YpIWcMM3d6eHdquZ7z+yDHePnScqXlOP3+Kpx54lK2NmvpujyEgIIsjVopWDjcq048cfuzw81lL13Zcv3OLD198hwOTVY4cfJxPvvuafhboppmcKrY3GlDBVUWVGymucohKuakGGtse+sz3l3/l0s0/eO+5k3xx/luu3r4BfaZeu8eVizdYu7ZRvBo5XLWYivNS/KsUbyGR+8huP2V1aTdr9ToPre7HJSF1kZAC0jX4kcON3aBo8MwJyJAooLlL5JA4dfglSMb7X37My08e4+iDT5DaHjHw450gVzwb0lQniC/fnpiyT+iVm9f54dIFfrt6GWsj7byFPiPe7pvsRqXJVa5AVBCR4VWDHPjg+Fd927/Sz0NlXXLSG33bIdFwwPLejslKxo9cSdBLubAL2AIIeM32rhpHnckewt03JfZveAU3FfxYGE9AtaSmWl4DAiIFpG6hThpvsAmcJQZ82Dhv6mtRfdV7N3XegTh2DuF/QBHESQvy6b/BYujcihJ9AQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyNS0xMi0xNlQwNjo1NjoxMSswMDowMDSABtAAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjUtMTItMTZUMDY6NTY6MTErMDA6MDBF3b5sAAAAKHRFWHRkYXRlOnRpbWVzdGFtcAAyMDI1LTEyLTE2VDA2OjU3OjEzKzAwOjAwapXlpAAAAABJRU5ErkJggg==";function iie({size:e=20,className:r}){return j.jsx("img",{src:oie,alt:"",width:e,height:e,className:r,style:{display:"block"},"aria-hidden":"true"})}const aie=wr({drawer:{width:"400px"},headerActions:{display:"flex",gap:le.spacingHorizontalS},columnList:{display:"flex",flexDirection:"column",gap:le.spacingVerticalXS,marginTop:le.spacingVerticalM},columnItem:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,padding:`${le.spacingVerticalS} ${le.spacingHorizontalM}`,backgroundColor:le.colorNeutralBackground1,border:`1px solid ${le.colorNeutralStroke2}`,borderRadius:le.borderRadiusMedium,cursor:"grab",userSelect:"none","&:hover":{backgroundColor:le.colorNeutralBackground1Hover,border:`1px solid ${le.colorNeutralStroke1Hover}`}},columnItemSelected:{backgroundColor:le.colorNeutralBackground1Selected,border:`1px solid ${le.colorBrandStroke1}`},columnItemDragging:{opacity:.5,cursor:"grabbing"},columnItemDragOver:{borderTop:`2px solid ${le.colorBrandStroke1}`,marginTop:"-2px"},dragHandle:{cursor:"grab",color:le.colorNeutralForeground3,display:"flex",alignItems:"center"},columnName:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},columnActions:{display:"flex",gap:le.spacingHorizontalXXS},footer:{display:"flex",justifyContent:"flex-end",gap:le.spacingHorizontalS,padding:le.spacingVerticalM,borderTop:`1px solid ${le.colorNeutralStroke1}`,marginTop:"auto"},hint:{display:"block",color:le.colorNeutralForeground3,marginTop:le.spacingVerticalXS},footerHint:{flex:1,alignSelf:"center",color:le.colorPaletteRedForeground1},emptyState:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:le.spacingVerticalXXL,color:le.colorNeutralForeground3,textAlign:"center"}});function sie({open:e,columns:r,entityDisplayName:t,onClose:n,onApply:s,onAddColumns:o,onResetToDefault:i,addColumnsDisabledReason:c}){const l=aie(),[a,u]=A.useState([]),[h,d]=A.useState(null),[f,m]=A.useState(null),[p,g]=A.useState(null),b=A.useRef(null);A.useEffect(()=>{e&&(u([...r]),d(null))},[e,r]);const y=A.useCallback((G,U)=>{m(U),b.current=G.currentTarget,G.dataTransfer.effectAllowed="move",G.dataTransfer.setData("text/plain",U.toString()),setTimeout(()=>{b.current&&(b.current.style.opacity="0.5")},0)},[]),w=A.useCallback(()=>{m(null),g(null),b.current&&(b.current.style.opacity="1",b.current=null)},[]),C=A.useCallback((G,U)=>{G.preventDefault(),G.dataTransfer.dropEffect="move",f!==null&&f!==U&&g(U)},[f]),N=A.useCallback(()=>{g(null)},[]),I=A.useCallback((G,U)=>{if(G.preventDefault(),f===null||f===U){g(null);return}u(E=>{const M=[...E],[B]=M.splice(f,1),k=f<U?U-1:U;return M.splice(k,0,B),M}),d(f<U?U-1:U),m(null),g(null)},[f]),$=A.useCallback((G,U)=>{u(E=>{const M=[...E],B=U==="up"?G-1:G+1;return B<0||B>=M.length?E:([M[G],M[B]]=[M[B],M[G]],M)}),d(E=>E===G?U==="up"?G-1:G+1:E)},[]),D=A.useCallback(G=>{u(U=>U.filter((E,M)=>M!==G)),d(null)},[]),F=A.useCallback(()=>{s(a)},[a,s]),V=A.useCallback(G=>{d(U=>U===G?null:G)},[]);return j.jsxs(mp,{open:e,onOpenChange:(G,U)=>!U.open&&n(),position:"end",size:"medium",className:l.drawer,children:[j.jsx(bp,{children:j.jsxs(vp,{action:j.jsx(St,{appearance:"subtle","aria-label":"Close",icon:j.jsx(np,{}),onClick:n}),children:["Edit columns",t?`: ${t}`:""]})}),j.jsxs(gp,{children:[j.jsxs(Bc,{size:"small",children:[j.jsx(Wn,{icon:j.jsx(rp,{}),onClick:o,"aria-label":"Add columns",disabled:!!c,children:"Add columns"}),i&&j.jsx(Wn,{icon:j.jsx(xR,{}),onClick:i,"aria-label":"Reset to default",children:"Reset to default"})]}),c&&j.jsx(st,{size:200,className:l.hint,children:c}),a.length===0?j.jsxs("div",{className:l.emptyState,children:[j.jsx(st,{children:"No columns selected"}),j.jsx(st,{size:200,children:'Click "Add columns" to add columns to the view'})]}):j.jsx("div",{className:l.columnList,children:a.map((G,U)=>{const E=f===U,M=p===U;return j.jsxs("div",{className:`${l.columnItem} ${h===U?l.columnItemSelected:""} ${E?l.columnItemDragging:""} ${M?l.columnItemDragOver:""}`,onClick:()=>V(U),role:"button",tabIndex:0,draggable:!0,onDragStart:B=>y(B,U),onDragEnd:w,onDragOver:B=>C(B,U),onDragLeave:N,onDrop:B=>I(B,U),onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&V(U)},children:[j.jsx("span",{className:l.dragHandle,children:j.jsx(DR,{})}),j.jsx("span",{className:l.columnName,children:G.displayName||G.name}),j.jsxs("div",{className:l.columnActions,children:[j.jsx(St,{appearance:"subtle",size:"small",icon:j.jsx(CR,{}),disabled:U===0,onClick:B=>{B.stopPropagation(),$(U,"up")},title:"Move up","aria-label":"Move up"}),j.jsx(St,{appearance:"subtle",size:"small",icon:j.jsx(yR,{}),disabled:U===a.length-1,onClick:B=>{B.stopPropagation(),$(U,"down")},title:"Move down","aria-label":"Move down"}),j.jsx(St,{appearance:"subtle",size:"small",icon:j.jsx(Lu,{}),onClick:B=>{B.stopPropagation(),D(U)},title:"Remove","aria-label":"Remove column"})]})]},G.name)})}),j.jsxs("div",{className:l.footer,children:[r.length>0&&a.length===0&&j.jsx(st,{size:200,className:l.footerHint,children:"Keep at least one column: a query without columns returns every attribute."}),j.jsx(St,{appearance:"secondary",onClick:n,children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:F,disabled:r.length>0&&a.length===0,children:"Apply"})]})]})]})}const lie=wr({drawer:{width:"420px"},searchContainer:{display:"flex",gap:le.spacingHorizontalS,marginBottom:le.spacingVerticalM},searchInput:{flex:1},filterCombo:{minWidth:"120px"},tabContent:{marginTop:le.spacingVerticalM},attributeList:{display:"flex",flexDirection:"column",gap:le.spacingVerticalXXS,maxHeight:"calc(100vh - 300px)",overflowY:"auto"},attributeItem:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,padding:`${le.spacingVerticalXS} ${le.spacingHorizontalS}`,borderRadius:le.borderRadiusSmall,cursor:"pointer","&:hover":{backgroundColor:le.colorNeutralBackground1Hover}},attributeItemSelected:{backgroundColor:le.colorNeutralBackground1Selected},relationshipTree:{maxHeight:"calc(100vh - 300px)",overflowY:"auto"},relationshipItem:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},relationshipLabel:{display:"flex",flexDirection:"column"},relationshipName:{fontWeight:le.fontWeightSemibold},relationshipEntity:{fontSize:le.fontSizeBase200,color:le.colorNeutralForeground3},relationshipType:{marginLeft:le.spacingHorizontalS},relationshipHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},accordionHeader:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},warningBadge:{marginLeft:le.spacingHorizontalS},loadingContainer:{display:"flex",alignItems:"center",justifyContent:"center",padding:le.spacingVerticalXXL},footer:{display:"flex",justifyContent:"flex-end",gap:le.spacingHorizontalS,padding:le.spacingVerticalM,borderTop:`1px solid ${le.colorNeutralStroke1}`,marginTop:"auto"},emptyState:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:le.spacingVerticalXXL,color:le.colorNeutralForeground3,textAlign:"center"},selectedCount:{marginRight:"auto",color:le.colorNeutralForeground2,display:"flex",alignItems:"center"}});function cie({open:e,entityDisplayName:r,entityLogicalName:t,availableAttributes:n=[],selectedAttributes:s=[],lookupRelationships:o=[],oneToManyRelationships:i=[],isLoadingRelationships:c,onLoadRelatedAttributes:l,existingRelatedColumns:a,onClose:u,onApply:h}){const d=lie(),[f,m]=A.useState("entity"),[p,g]=A.useState(""),[b,y]=A.useState("all"),[w,C]=A.useState(new Set),[N,I]=A.useState([]),[$,D]=A.useState(new Set),[F,V]=A.useState(new Map),[G,U]=A.useState(new Set);A.useEffect(()=>{e&&(C(new Set),I([]),g(""),y("all"),m("entity"))},[e]);const E=A.useMemo(()=>{let K=n.filter(J=>!s.includes(J.LogicalName));if(b==="standard"?K=K.filter(J=>!J.LogicalName.startsWith("new_")&&!J.SchemaName.includes("_")):b==="custom"&&(K=K.filter(J=>J.LogicalName.startsWith("new_")||J.SchemaName.includes("_"))),p){const J=p.toLowerCase();K=K.filter(H=>H.LogicalName.toLowerCase().includes(J)||(H.DisplayName?.UserLocalizedLabel?.Label||"").toLowerCase().includes(J))}return K.sort((J,H)=>{const Z=J.DisplayName?.UserLocalizedLabel?.Label||J.LogicalName,L=H.DisplayName?.UserLocalizedLabel?.Label||H.LogicalName;return Z.localeCompare(L)})},[n,s,p,b]),{filteredN1Relationships:M,filtered1NRelationships:B}=A.useMemo(()=>{const K=p.toLowerCase();let J=o.map(Z=>{const q=n.find(Y=>Y.LogicalName===Z.ReferencingAttribute)?.DisplayName?.UserLocalizedLabel?.Label||Z.ReferencingAttribute;return{relationship:Z,type:"N1",displayName:q,relatedEntity:Z.ReferencedEntity}}),H=i.map(Z=>{const q=Zt.getEntityMetadata(Z.ReferencingEntity)?.DisplayName?.UserLocalizedLabel?.Label||Z.ReferencingEntity;return{relationship:Z,type:"1N",displayName:q,relatedEntity:Z.ReferencingEntity}});return p&&(J=J.filter(Z=>Z.relatedEntity.toLowerCase().includes(K)||Z.displayName.toLowerCase().includes(K)||Z.relationship.SchemaName.toLowerCase().includes(K)),H=H.filter(Z=>Z.relatedEntity.toLowerCase().includes(K)||Z.displayName.toLowerCase().includes(K)||Z.relationship.SchemaName.toLowerCase().includes(K))),J.sort((Z,L)=>Z.displayName.localeCompare(L.displayName)),H.sort((Z,L)=>Z.displayName.localeCompare(L.displayName)),{filteredN1Relationships:J,filtered1NRelationships:H}},[o,i,n,p]),k=(K,J)=>{const H=K.relationship,Z=K.type==="N1"?`${H.ReferencedEntity}|${H.ReferencedAttribute}|${H.ReferencingAttribute}|${J}`:`${H.ReferencingEntity}|${H.ReferencingAttribute}|${H.ReferencedAttribute}|${J}`;return a?.has(Z)??!1},_=A.useCallback((K,J)=>{m(J.value)},[]),S=A.useCallback(K=>{C(J=>{const H=new Set(J);return H.has(K)?H.delete(K):H.add(K),H})},[]),T=A.useCallback(async(K,J)=>{const H=vi(K);if(D(Z=>{const L=new Set(Z);return L.has(H)?L.delete(H):L.add(H),L}),!F.has(J)&&l){U(Z=>new Set(Z).add(J));try{const Z=await l(J);V(L=>new Map(L).set(J,Z))}finally{U(Z=>{const L=new Set(Z);return L.delete(J),L})}}},[F,l]),z=A.useCallback((K,J,H,Z)=>{const L=J.DisplayName?.UserLocalizedLabel?.Label||J.LogicalName;let q,Y;H==="N1"?(q=K.ReferencingAttribute,Y=n.find(ne=>ne.LogicalName===q)?.DisplayName?.UserLocalizedLabel?.Label||q):(q=K.ReferencingAttribute,Y=Z);const re={relationship:K,attribute:J,displayName:`${L} (${Y})`,lookupAttribute:q,relationshipType:H};I(ie=>{const ne=ie.findIndex(ae=>vi(ae.relationship)===vi(K)&&ae.attribute.LogicalName===J.LogicalName);return ne>=0?ie.filter((ae,be)=>be!==ne):[...ie,re]})},[n]),P=A.useCallback((K,J)=>N.some(H=>vi(H.relationship)===vi(K)&&H.attribute.LogicalName===J.LogicalName),[N]),O=A.useCallback(()=>{h({rootAttributes:Array.from(w),relatedColumns:N})},[w,N,h]),X=w.size+N.length;return j.jsxs(mp,{open:e,onOpenChange:(K,J)=>!J.open&&u(),position:"end",size:"medium",className:d.drawer,children:[j.jsx(bp,{children:j.jsx(vp,{action:j.jsx(St,{appearance:"subtle","aria-label":"Close",icon:j.jsx(np,{}),onClick:u}),children:"Add columns"})}),j.jsxs(gp,{children:[j.jsxs(hp,{selectedValue:f,onTabSelect:_,children:[j.jsx(Za,{value:"entity",children:r||t||"Entity"}),j.jsx(Za,{value:"related",children:"Related"})]}),j.jsxs("div",{className:d.tabContent,children:[j.jsxs("div",{className:d.searchContainer,children:[j.jsx(_n,{className:d.searchInput,contentBefore:j.jsx(iR,{}),placeholder:"Search columns…",value:p,onChange:(K,J)=>g(J.value)}),j.jsxs(Zn,{className:d.filterCombo,value:b==="all"?"All":b==="standard"?"Standard":"Custom",onOptionSelect:(K,J)=>y(J.optionValue||"all"),children:[j.jsx(Jt,{value:"all",children:"All"}),j.jsx(Jt,{value:"standard",children:"Standard"}),j.jsx(Jt,{value:"custom",children:"Custom"})]})]}),f==="entity"&&j.jsx("div",{className:d.attributeList,children:E.length===0?j.jsx("div",{className:d.emptyState,children:j.jsx(st,{children:p?"No matching attributes found":"All attributes already added"})}):E.map(K=>j.jsxs("div",{className:`${d.attributeItem} ${w.has(K.LogicalName)?d.attributeItemSelected:""}`,onClick:()=>S(K.LogicalName),role:"checkbox","aria-checked":w.has(K.LogicalName),tabIndex:0,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),S(K.LogicalName))},children:[j.jsx(ho,{checked:w.has(K.LogicalName),onChange:J=>{J.stopPropagation(),S(K.LogicalName)}}),j.jsx(st,{children:K.DisplayName?.UserLocalizedLabel?.Label||K.LogicalName})]},K.LogicalName))}),f==="related"&&j.jsx("div",{className:d.relationshipTree,children:c?j.jsx("div",{className:d.loadingContainer,children:j.jsx(hn,{size:"small",label:"Loading relationships…"})}):M.length===0&&B.length===0?j.jsx("div",{className:d.emptyState,children:j.jsx(st,{children:"No relationships found"})}):j.jsxs(Yh,{multiple:!0,collapsible:!0,defaultOpenItems:["n1"],children:[M.length>0&&j.jsxs(qu,{value:"n1",children:[j.jsx($u,{size:"small",children:j.jsxs("div",{className:d.accordionHeader,children:[j.jsx(st,{weight:"semibold",children:"Lookups (N:1)"}),j.jsx(ri,{appearance:"filled",color:"informative",size:"small",children:M.length})]})}),j.jsx(Hu,{children:j.jsx(Hs,{"aria-label":"Lookup relationships",children:M.map(K=>{const J=K.relationship,H=$.has(vi(J)),Z=F.get(K.relatedEntity),L=G.has(K.relatedEntity);return j.jsxs(Ui,{itemType:"branch",open:H,children:[j.jsx(Wi,{onClick:()=>T(J,K.relatedEntity),children:j.jsx("div",{className:d.relationshipHeader,children:j.jsxs("div",{className:d.relationshipLabel,children:[j.jsx("span",{className:d.relationshipName,children:K.displayName}),j.jsx("span",{className:d.relationshipEntity,children:K.relatedEntity})]})})}),H&&j.jsx(Hs,{children:L?j.jsx(Ui,{itemType:"leaf",children:j.jsx(Wi,{children:j.jsx(hn,{size:"tiny",label:"Loading…"})})}):Z&&Z.length>0?Z.filter(q=>q.AttributeType!=="Virtual"&&!k(K,q.LogicalName)).sort((q,Y)=>{const re=q.DisplayName?.UserLocalizedLabel?.Label||q.LogicalName,ie=Y.DisplayName?.UserLocalizedLabel?.Label||Y.LogicalName;return re.localeCompare(ie)}).map(q=>j.jsx(Ui,{itemType:"leaf",children:j.jsx(Wi,{onClick:()=>z(J,q,"N1",K.relatedEntity),children:j.jsxs("div",{className:d.attributeItem,children:[j.jsx(ho,{checked:P(J,q),onChange:Y=>{Y.stopPropagation(),z(J,q,"N1",K.relatedEntity)}}),j.jsx(st,{children:q.DisplayName?.UserLocalizedLabel?.Label||q.LogicalName})]})})},q.LogicalName)):j.jsx(Ui,{itemType:"leaf",children:j.jsx(Wi,{children:j.jsx(st,{style:{color:le.colorNeutralForeground3},children:"No attributes available"})})})})]},vi(J))})})})]}),B.length>0&&j.jsxs(qu,{value:"1n",children:[j.jsx($u,{size:"small",children:j.jsxs("div",{className:d.accordionHeader,children:[j.jsx(st,{weight:"semibold",children:"Related (1:N)"}),j.jsx(ri,{appearance:"filled",color:"informative",size:"small",children:B.length}),j.jsx(ri,{appearance:"tint",color:"warning",size:"small",className:d.warningBadge,children:"May duplicate rows"})]})}),j.jsx(Hu,{children:j.jsx(Hs,{"aria-label":"One-to-many relationships",children:B.map(K=>{const J=K.relationship,H=$.has(vi(J)),Z=F.get(K.relatedEntity),L=G.has(K.relatedEntity);return j.jsxs(Ui,{itemType:"branch",open:H,children:[j.jsx(Wi,{onClick:()=>T(J,K.relatedEntity),children:j.jsx("div",{className:d.relationshipHeader,children:j.jsxs("div",{className:d.relationshipLabel,children:[j.jsx("span",{className:d.relationshipName,children:K.displayName}),j.jsx("span",{className:d.relationshipEntity,children:J.SchemaName})]})})}),H&&j.jsx(Hs,{children:L?j.jsx(Ui,{itemType:"leaf",children:j.jsx(Wi,{children:j.jsx(hn,{size:"tiny",label:"Loading…"})})}):Z&&Z.length>0?Z.filter(q=>q.AttributeType!=="Virtual"&&!k(K,q.LogicalName)).sort((q,Y)=>{const re=q.DisplayName?.UserLocalizedLabel?.Label||q.LogicalName,ie=Y.DisplayName?.UserLocalizedLabel?.Label||Y.LogicalName;return re.localeCompare(ie)}).map(q=>j.jsx(Ui,{itemType:"leaf",children:j.jsx(Wi,{onClick:()=>z(J,q,"1N",K.relatedEntity),children:j.jsxs("div",{className:d.attributeItem,children:[j.jsx(ho,{checked:P(J,q),onChange:Y=>{Y.stopPropagation(),z(J,q,"1N",K.relatedEntity)}}),j.jsx(st,{children:q.DisplayName?.UserLocalizedLabel?.Label||q.LogicalName})]})})},q.LogicalName)):j.jsx(Ui,{itemType:"leaf",children:j.jsx(Wi,{children:j.jsx(st,{style:{color:le.colorNeutralForeground3},children:"No attributes available"})})})})]},vi(J))})})})]})]})})]}),j.jsxs("div",{className:d.footer,children:[X>0&&j.jsxs(st,{className:d.selectedCount,children:[X," column",X!==1?"s":""," selected"]}),j.jsx(St,{appearance:"secondary",onClick:u,children:"Close"}),j.jsx(St,{appearance:"primary",onClick:O,disabled:X===0,children:"Add"})]})]})]})}const uie=wr({toolbar:{padding:"0"},splitButtonAppearance:{}});function Y5({label:e,ariaLabel:r,icon:t,onClick:n,disabled:s,reason:o}){const i=j.jsx(Wn,{appearance:"subtle",icon:t,disabled:s,disabledFocusable:!!o,onClick:n,"aria-label":r,children:e});return o?j.jsx(Or,{content:o,relationship:"description",withArrow:!0,children:i}):i}function die({selectedCount:e,onOpen:r,onCopyUrl:t,onActivate:n,onDeactivate:s,activateDisabledReason:o,deactivateDisabledReason:i,onDelete:c,onBulkDelete:l,canDelete:a=!1,canBulkDelete:u=!1,deleteDisabled:h=!1,onRunSpecificWorkflow:d,canRunWorkflow:f=!1,workflowDisabled:m=!1,recordActionsDisabledReason:p,onFetchWorkflows:g,onExport:b,onExportLocal:y,loadedCount:w=0,onCopyRows:C,searchText:N="",canExport:I=!1,isExporting:$=!1,exportDisabledReason:D,entityName:F,entityDisplayName:V,columns:G,onReorderColumns:U,onRemoveColumns:E,availableAttributes:M,selectedAttributes:B,onAddColumn:k,onAddRelatedColumns:_,addColumnsDisabledReason:S,existingRelatedColumns:T,lookupRelationships:z,oneToManyRelationships:P,isLoadingRelationships:O,onLoadRelatedAttributes:X,onResetToDefault:K,isRetrieveAllInProgress:J=!1,onStopRetrieveAll:H}){const Z=uie(),L=e>0,q=e===1,Y=!!p,re=h||Y,ie=m||Y,ne=!L||re,[ae,be]=A.useState(!1),[pe,te]=A.useState(!1),[se,ue]=A.useState("shown"),[he,me]=A.useState([]),[xe,Be]=A.useState(!1),[Re,He]=A.useState(!1),Je=A.useCallback(async()=>{if(!(Re||xe||!g)){Be(!0);try{const Ke=await g();me(Ke),He(!0)}catch(Ke){console.error("Failed to load workflows:",Ke)}finally{Be(!1)}}},[Re,xe,g]),Te=A.useCallback(()=>{be(!0)},[]),Ee=A.useCallback(()=>{be(!1)},[]),$e=A.useCallback(()=>{te(!1)},[]),Ze=A.useCallback(Ke=>{if(G&&E){const We=new Set(Ke.map(Ve=>Ve.name)),nt=G.filter(Ve=>!We.has(Ve.name)).map(Ve=>Ve.name);nt.length>0&&E(nt)}U?.(Ke),be(!1)},[G,U,E]),yt=A.useCallback(Ke=>{for(const We of Ke.rootAttributes)k?.(We);Ke.relatedColumns.length>0&&_&&_(Ke.relatedColumns),te(!1)},[k,_]),dt=A.useCallback(()=>{te(!0)},[]);return j.jsxs(j.Fragment,{children:[j.jsxs(Bc,{className:Z.toolbar,size:"medium","aria-label":"Record actions",children:[J&&H&&j.jsxs(j.Fragment,{children:[j.jsx(Wn,{appearance:"subtle",icon:j.jsx(uR,{}),onClick:H,children:"Stop"}),j.jsx(Si,{})]}),j.jsx(Wn,{appearance:"subtle",icon:j.jsx(dR,{}),disabled:!q||Y,onClick:r,"aria-label":"Open record",children:"Open"}),j.jsx(Wn,{appearance:"subtle",icon:j.jsx(eh,{}),disabled:!q||Y,onClick:t,"aria-label":"Copy record URL",children:"Copy URL"}),p&&j.jsx(Or,{content:p,relationship:"description",withArrow:!0,children:j.jsx(Wn,{appearance:"transparent",icon:j.jsx(ph,{}),children:"Record actions unavailable"})}),j.jsx(Si,{}),j.jsx(Y5,{label:"Activate",ariaLabel:"Activate selected records",icon:j.jsx(cd,{}),onClick:n,disabled:ne||!n||!!o,reason:o}),j.jsx(Y5,{label:"Deactivate",ariaLabel:"Deactivate selected records",icon:j.jsx(k4,{}),onClick:s,disabled:ne||!s||!!i,reason:i}),j.jsx(Si,{}),a&&j.jsxs(_i,{positioning:"below-end",children:[j.jsx(va,{disableButtonEnhancement:!0,children:Ke=>j.jsx(hv,{appearance:"subtle",menuButton:Ke,primaryActionButton:{onClick:c,disabled:re},disabled:re,icon:j.jsx(Lu,{}),"aria-label":L?"Delete selected records":"Delete all records from view",children:L?"Delete":"Delete all"})}),j.jsx(Ti,{children:j.jsxs(Ci,{children:[j.jsxs(Gr,{icon:j.jsx(Lu,{}),onClick:c,disabled:re,children:["Delete",L?` (${e})`:" All"]}),u&&j.jsx(Gr,{icon:j.jsx(sR,{}),onClick:l,disabled:re,children:"Bulk delete (job)"})]})})]}),f&&j.jsxs(_i,{positioning:"below-end",onOpenChange:(Ke,We)=>We.open&&Je(),children:[j.jsx(va,{disableButtonEnhancement:!0,children:j.jsx(tc,{appearance:"subtle",icon:j.jsx(R0,{}),disabled:!L||ie,"aria-label":"Run workflow on selected records",children:"Run workflow"})}),j.jsx(Ti,{children:j.jsxs(Ci,{children:[xe&&j.jsx(Gr,{disabled:!0,children:"Loading workflows..."}),!xe&&he.length===0&&Re&&j.jsx(Gr,{disabled:!0,children:"No workflows available"}),!xe&&he.map(Ke=>j.jsx(Gr,{icon:j.jsx(R0,{}),onClick:()=>d?.(Ke),children:Ke.name},Ke.workflowid))]})})]}),j.jsx(Si,{}),j.jsxs(_i,{checkedValues:{copyValues:[se]},onCheckedValueChange:(Ke,We)=>ue(We.checkedItems[0]),children:[j.jsx(va,{disableButtonEnhancement:!0,children:j.jsx(tc,{appearance:"subtle",icon:j.jsx(wc,{}),disabled:w===0,children:"Copy"})}),j.jsx(Ti,{children:j.jsxs(Ci,{children:[j.jsxs(Gr,{disabled:e===0,onClick:()=>C?.("selected",se),children:["Selected rows (",e,")"]}),j.jsxs(Gr,{onClick:()=>C?.("all",se),children:[N.trim()?"All matching rows":"All loaded rows"," (",w,")"]}),j.jsx(Ku,{}),j.jsxs(q6,{children:[j.jsx(L6,{children:"Values"}),j.jsx(O0,{name:"copyValues",value:"shown",persistOnClick:!0,children:"As shown"}),j.jsx(O0,{name:"copyValues",value:"raw",persistOnClick:!0,children:"Raw (GUIDs, numbers, ISO dates)"})]})]})})]}),j.jsxs(_i,{children:[j.jsx(va,{disableButtonEnhancement:!0,children:j.jsx(Or,{content:$?"Export in progress...":"Export to Excel",relationship:"description",children:j.jsx(tc,{appearance:"subtle",icon:j.jsx(iie,{}),disabled:$,"aria-label":"Export to Excel",children:$?"Exporting...":"Export to Excel"})})}),j.jsx(Ti,{children:j.jsxs(Ci,{children:[j.jsx(Or,{content:I?"Export using Dataverse API (all records)":D||"Save as a view first to enable server export",relationship:"description",positioning:"before",children:j.jsx(Gr,{onClick:b,disabled:!I||$,children:"Export (Server)"})}),j.jsx(Gr,{onClick:y,disabled:$,children:"Export (Local)"})]})})]}),j.jsx(Si,{}),j.jsx(Wn,{appearance:"subtle",icon:j.jsx(cR,{}),onClick:Te,"aria-label":"Edit columns",children:"Edit columns"})]}),j.jsx(sie,{open:ae,columns:G||[],entityDisplayName:V,onClose:Ee,onApply:Ze,onAddColumns:dt,onResetToDefault:K,addColumnsDisabledReason:S}),j.jsx(cie,{open:pe,entityDisplayName:V,entityLogicalName:F,availableAttributes:M,selectedAttributes:B,lookupRelationships:z,oneToManyRelationships:P,isLoadingRelationships:O,onLoadRelatedAttributes:X,existingRelatedColumns:T,onClose:$e,onApply:yt})]})}const k7=A.createContext(null),fie={sync:async()=>({status:"unchanged"}),editorHasContent:!1};function S7(){return A.useContext(k7)??fie}const hie=wr({container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:`1px solid ${le.colorNeutralStroke1}`,paddingRight:"16px"},progressContainer:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px",borderBottom:`1px solid ${le.colorNeutralStroke1}`},tabContent:{flex:1,overflow:"hidden",padding:"6px",backgroundColor:le.colorNeutralBackground3},surfaceCard:{borderRadius:le.borderRadiusMedium,boxShadow:le.shadow16,backgroundColor:le.colorNeutralBackground1,border:`1px solid ${le.colorNeutralStroke2}`},toolbarCard:{borderRadius:le.borderRadiusMedium,boxShadow:le.shadow16,backgroundColor:le.colorNeutralBackground1,border:`1px solid ${le.colorNeutralStroke2}`,padding:"4px 8px",flexShrink:0},gridCard:{borderRadius:le.borderRadiusMedium,boxShadow:le.shadow16,backgroundColor:le.colorNeutralBackground1,border:`1px solid ${le.colorNeutralStroke2}`,display:"flex",flexDirection:"column",flex:1,minHeight:"240px",minWidth:"480px",overflow:"hidden",marginTop:"8px"},codeCard:{borderRadius:le.borderRadiusMedium,boxShadow:le.shadow16,backgroundColor:le.colorNeutralBackground1,border:`1px solid ${le.colorNeutralStroke2}`,height:"100%",display:"flex",flexDirection:"column"},resultsLayout:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},messageBarContainer:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px",borderBottom:`1px solid ${le.colorNeutralStroke1}`}});function pie({getCurrentXml:e}){const[r,t]=A.useState(!1),n=A.useCallback(async()=>{t(!0);try{await zJ(e())}catch(s){const o=s instanceof Error?s.message:String(s);await window.toolboxAPI?.utils?.showNotification?.({title:"Cannot return FetchXML",body:o,type:"error"})}finally{t(!1)}},[e]);return j.jsx(Or,{content:"Return the current FetchXML to the tool that launched this window",relationship:"description",children:j.jsx(St,{appearance:"subtle",icon:r?j.jsx(hn,{size:"tiny"}):j.jsx(wR,{}),onClick:n,disabled:r,children:"Return FetchXML"})})}function mie({xml:e,layoutXml:r,result:t,isExecuting:n,isLoadingMore:s,onExecute:o,onExport:i,onExportLocal:c,onParseToTree:l,attributeMetadata:a,fetchQuery:u,columnConfig:h,onColumnResize:d,onReorderColumns:f,onAddColumn:m,onAddRelatedColumns:p,onRemoveColumns:g,onSortChange:b,columnFilters:y,onAddColumnFilter:w,onRemoveColumnFilters:C,saveViewButton:N,quickFindTestValue:I,executeDisabledReason:$,sendToToolButton:D,isCallee:F,onLoadMore:V,pagingNotice:G,isRetrieveAllInProgress:U,onStopRetrieveAll:E,onRetryPaging:M,onDismissPagingNotice:B,canExport:k,isExporting:_,exportError:S,onDismissExportError:T,exportDisabledReason:z,executeError:P,onDismissExecuteError:O,entityDisplayName:X,lookupRelationships:K,oneToManyRelationships:J,isLoadingRelationships:H,onLoadRelatedAttributes:Z,onResetToDefault:L,onOpenRecord:q,onCopyRecordUrl:Y,onDeleteRecords:re,onBulkDeleteRecords:ie,onActivateRecords:ne,onDeactivateRecords:ae,activateDisabledReason:be,deactivateDisabledReason:pe,onRunSpecificWorkflow:te,canDelete:se,canBulkDelete:ue,canRunWorkflow:he,onFetchWorkflows:me,isAggregateQuery:xe,hasOneToManyRelationship:Be,recordActionsDisabledReason:Re,onSelectionChange:He,getSelectedRecordIds:Je,onOpenSettings:Te,displaySettings:Ee,primaryIdAttribute:$e}){const Ze=hie(),yt=Sp(),[dt,Ke]=A.useState("xml"),[We,nt]=A.useState(0),[Ve,wt]=A.useState([]),[Wt,Ct]=A.useState(!1),Tt=A.useRef(""),ct=A.useRef(null),[Ot,Ft]=A.useState(""),[vr,fr]=A.useState(0),[zt,tr]=A.useState(null),[gr,Rt]=A.useState(null),ur=A.useMemo(()=>new Set((u?.entity.links??[]).filter(xt=>!cl.has(xt.linkType)).flatMap(xt=>xt.attributes.map(qt=>`${xt.name}|${xt.from}|${xt.to}|${qt.name}`))),[u]),[je,Pe]=A.useState(!1),[fe,ye]=A.useState(null),[Ne,Ue]=A.useState(null),vt=A.useCallback(()=>Wt&&Tt.current||e,[Wt,e]),ze=A.useCallback((xt,qt)=>{Tt.current=qt,Ct(ce=>ce!==xt?xt:ce),Pe(xt&&qt.trim().length>0),Rt(ce=>ce&&(!xt||ce.xml!==qt)?null:ce),xt||tr(null)},[]),gt=(xt,qt)=>{Ke(qt.value),qt.value==="xml"&&tr(null)},bt=A.useCallback(async xt=>{if(!Wt)return{status:"unchanged"};const qt=Tt.current,ce=U8(qt);if(!ce.valid)return tr([{message:ce.error||"Invalid XML syntax"}]),{status:"cancelled"};const we=el(qt);if(!we.success||!we.fetchNode)return tr(we.errors),{status:"cancelled"};const qe=ob(we);if(qe.length>0)return tr(qe),{status:"cancelled"};if(e&&ya(we.fetchNode)===e)return{status:"unchanged"};const Xe=Nh(we);if(Xe.length>0&&!await new Promise(hr=>Ue({action:xt,changes:Xe,resolve:hr})))return{status:"cancelled"};const kt=l?.(qt,{preserveLayout:!0});if(!kt?.success||!kt.fetchNode)return tr(kt?.errors??[{message:"The FetchXML couldn't be loaded into the tree."}]),{status:"cancelled"};const ot=ya(kt.fetchNode);return Xe.length>0&&(Tt.current=ot,ye({xml:ot,id:Date.now()})),{status:"synced",fetchXml:ot,fetchQuery:kt.fetchNode}},[Wt,e,l]),at=A.useMemo(()=>({sync:bt,editorHasContent:Wt&&je}),[bt,Wt,je]),Bt=xt=>{Ne?.resolve(xt),Ue(null)},Ut=async()=>{const xt=await bt("execute");xt.status!=="cancelled"&&(Ke("results"),o?.(xt.status==="synced"?{xml:xt.fetchXml,fetchQuery:xt.fetchQuery}:void 0))},or=()=>{gr&&(Rt(null),Ut())},Tr=()=>{if(tr(null),Rt(null),Wt){const xt=Tt.current,qt=el(xt);if(qt.success&&ob(qt).length===0){const ce=$8(qt);if(ce.length>0){Rt({xml:xt,warnings:ce});return}}}Ut()},Sr=A.useCallback(xt=>{wt(xt),He?.(xt)},[He]),_r=A.useCallback(()=>Je?Je():Ve,[Je,Ve]);return j.jsx(k7.Provider,{value:at,children:j.jsxs("div",{className:Ze.container,children:[j.jsx(T_,{action:Ne?.action??null,changes:Ne?.changes??[],onConfirm:()=>Bt(!0),onCancel:()=>Bt(!1)}),j.jsxs("div",{className:Ze.header,children:[j.jsxs(hp,{selectedValue:dt,onTabSelect:gt,children:[j.jsx(Za,{value:"xml",children:"FetchXML"}),j.jsx(Za,{value:"layout",children:"LayoutXML"}),j.jsx(Za,{value:"results",children:"Results"}),j.jsx(Za,{value:"code",icon:j.jsx(aR,{}),children:"Code"})]}),j.jsxs(Bc,{size:"small",children:[$&&!Wt?j.jsx(Or,{content:$,relationship:"description",children:j.jsx("span",{children:j.jsx(St,{appearance:"primary",icon:j.jsx(I2,{}),disabled:!0,children:"Execute"})})}):j.jsx(St,{appearance:"primary",icon:j.jsx(I2,{}),onClick:Tr,disabled:n||s||(Wt?!je:!e),children:n?"Executing…":"Execute"}),F&&j.jsxs(j.Fragment,{children:[j.jsx(Si,{}),j.jsx(pie,{getCurrentXml:vt})]}),dt==="xml"&&N&&j.jsxs(j.Fragment,{children:[j.jsx(Si,{}),N]}),D&&j.jsxs(j.Fragment,{children:[j.jsx(Si,{}),D]}),j.jsx(Si,{}),j.jsx(St,{appearance:"subtle",icon:j.jsx(v4,{}),onClick:Te,"aria-label":"Settings"})]})]}),(n||s)&&j.jsx("div",{className:Ze.progressContainer,children:j.jsx(hd,{})}),I&&j.jsx("div",{className:Ze.messageBarContainer,children:I}),_&&j.jsx("div",{className:Ze.messageBarContainer,children:j.jsx(Ar,{intent:"info",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Exporting"}),"Exporting view to Excel…"]})})}),S&&!_&&j.jsx("div",{className:Ze.messageBarContainer,children:j.jsxs(Ar,{intent:"error",children:[j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Export failed"}),S]}),j.jsx(Fs,{containerAction:j.jsx(St,{appearance:"transparent",icon:j.jsx(lu,{}),onClick:T,"aria-label":"Dismiss"})})]})}),gr&&j.jsx("div",{className:Ze.messageBarContainer,children:j.jsxs(Ar,{intent:"warning",layout:"multiline",children:[j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Dataverse might reject this query"}),j.jsx(rl,{items:gr.warnings})]}),j.jsx(Fs,{containerAction:j.jsx(St,{appearance:"transparent",icon:j.jsx(lu,{}),onClick:()=>Rt(null),"aria-label":"Dismiss"}),children:j.jsx(St,{onClick:or,children:"Execute anyway"})})]})}),zt&&j.jsx("div",{className:Ze.messageBarContainer,children:j.jsxs(Ar,{intent:"error",layout:"multiline",children:[j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Invalid FetchXML"}),j.jsx(rl,{items:zt})]}),j.jsx(Fs,{containerAction:j.jsx(St,{appearance:"transparent",icon:j.jsx(lu,{}),onClick:()=>tr(null),"aria-label":"Dismiss"})})]})}),P&&j.jsx("div",{className:Ze.messageBarContainer,children:j.jsxs(Ar,{intent:"error",children:[j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Execution failed"}),P]}),j.jsx(Fs,{containerAction:j.jsx(St,{appearance:"transparent",icon:j.jsx(lu,{}),onClick:O,"aria-label":"Dismiss"})})]})}),j.jsxs("div",{className:Ze.tabContent,children:[j.jsx("div",{className:Ze.codeCard,style:dt!=="xml"?{display:"none"}:void 0,children:j.jsx(Qee,{xml:e,onParseToTree:l,onEditorStateChange:ze,replaceRequest:fe})}),dt==="layout"&&j.jsx("div",{className:Ze.codeCard,children:j.jsx(jte,{layoutXml:r||""})}),dt==="code"&&j.jsx("div",{className:Ze.codeCard,children:j.jsx(Tte,{fetchXml:e})}),dt==="results"&&j.jsxs("div",{className:Ze.resultsLayout,children:[j.jsx("div",{className:Ze.toolbarCard,children:j.jsx(die,{selectedCount:We,onOpen:()=>{const xt=_r();xt?.length&&q&&q(xt)},onCopyUrl:()=>{const xt=_r();xt?.length&&Y&&Y(xt)},onActivate:ne&&(()=>{const xt=_r();xt?.length&&ne&&ne(xt)}),onDeactivate:ae&&(()=>{const xt=_r();xt?.length&&ae&&ae(xt)}),activateDisabledReason:be,deactivateDisabledReason:pe,onDelete:()=>{const xt=_r();re&&re(xt||[])},onBulkDelete:()=>{const xt=_r();ie&&ie(xt||[])},canDelete:se,canBulkDelete:ue,deleteDisabled:xe||Be,onRunSpecificWorkflow:xt=>{const qt=_r();qt?.length&&te&&te(xt,qt)},canRunWorkflow:he,workflowDisabled:xe||Be,recordActionsDisabledReason:Re,onFetchWorkflows:me,onExport:i,onExportLocal:c,loadedCount:Ot.trim()?vr:t?.rows.length??0,searchText:Ot,onCopyRows:(xt,qt)=>ct.current?.copyRows(xt,qt),canExport:k,isExporting:_,exportDisabledReason:z,entityName:t?.entityLogicalName,entityDisplayName:X,columns:h?.columns,onReorderColumns:f,onRemoveColumns:g,availableAttributes:a&&u?.entity?.name?Array.from(a.get(u.entity.name)?.values()||[]).filter(xt=>h_(xt,yt)):void 0,selectedAttributes:u?.entity.attributes.map(xt=>xt.name),onAddColumn:m,onAddRelatedColumns:p,lookupRelationships:K,oneToManyRelationships:J,isLoadingRelationships:H,onLoadRelatedAttributes:Z,onResetToDefault:L,addColumnsDisabledReason:xe?"Aggregate queries only return Group by and aggregate attributes, with aliases: add them in the tree.":void 0,existingRelatedColumns:ur,isRetrieveAllInProgress:U,onStopRetrieveAll:E})}),G&&j.jsx("div",{className:Ze.messageBarContainer,children:j.jsxs(Ar,{intent:G.kind==="error"?"error":G.kind==="stopped"?"warning":"info",layout:"multiline",children:[j.jsxs(Rr,{children:[j.jsx(Hr,{children:G.kind==="error"?"Couldn't load all records":G.kind==="stopped"?"Retrieve all stopped":"Paging without a paging cookie"}),G.kind==="error"?`Loaded ${t?.rows.length??0} rows; ${G.page?`page ${G.page}`:"the next page"} failed: ${G.message}`:G.kind==="stopped"?`Stopped after ${t?.rows.length??0} rows. Scroll to the end of the grid to load more, or execute again.`:G.message]}),j.jsx(Fs,{containerAction:j.jsx(St,{appearance:"transparent",icon:j.jsx(lu,{}),onClick:B,"aria-label":"Dismiss"}),children:G.kind==="error"&&M&&j.jsx(St,{onClick:M,children:"Retry"})})]})}),j.jsx("div",{className:Ze.gridCard,children:j.jsx(nie,{ref:ct,result:t,isLoading:n,isLoadingMore:s,attributeMetadata:a,fetchQuery:u,primaryIdAttribute:$e,onSelectedCountChange:nt,onSelectionChange:Sr,columnConfig:h,onColumnResize:d,onSortChange:b,onLoadMore:V,displaySettings:Ee,searchText:Ot,onSearchTextChange:Ft,columnFilters:y,onAddColumnFilter:w,onRemoveColumnFilters:C,onVisibleCountChange:fr})})]})]})]})})}function _7(){const[e,r]=A.useState(null),[t,n]=A.useState(!0),[s,o]=A.useState(null);return A.useEffect(()=>{let i=!0;async function c(){try{n(!0),o(null);const l=await IZ();i&&(r(l),l&&!l.noAccessMode&&(Ie("metadataAPI","[useAccessMode] Preloading entity metadata..."),l_().then(a=>{Ie("metadataAPI","[useAccessMode] Entity metadata preloaded:",a.length,"entities")}).catch(a=>{console.error("[useAccessMode] Failed to preload entity metadata:",a)})))}catch(l){i&&o(l instanceof Error?l.message:String(l))}finally{i&&n(!1)}}return c(),()=>{i=!1}},[]),{accessSummary:e,loading:t,error:s,fullFilterMode:e?.fullFilterMode??!1,solutionsOnlyMode:e?.solutionsOnlyMode??!1,publishersOnlyMode:e?.publishersOnlyMode??!1,metadataOnlyMode:e?.metadataOnlyMode??!1,noAccessMode:e?.noAccessMode??!1}}function gie(){const[e,r]=A.useState([]),[t,n]=A.useState(!1),[s,o]=A.useState(null),[i,c]=A.useState(!1),[l,a]=A.useState([]),[u,h]=A.useState([]),[d,f]=A.useState([]),[m,p]=A.useState([]),[g,b]=A.useState(!1),[y,w]=A.useState(null);A.useEffect(()=>{let I=!0;const $=new AbortController;async function D(){const F=Zt.getPublishersWithSolutions();if(F){r(F),c(!0);return}try{n(!0),o(null);const V=await MZ();I&&(r(V),Zt.setPublishersWithSolutions(V))}catch(V){I&&!$.signal.aborted&&o(V instanceof Error?V.message:String(V))}finally{I&&(n(!1),c(!0))}}return D(),()=>{I=!1,$.abort()}},[]),A.useEffect(()=>{if(!l.length){h([]),f([]);return}const I=new Set(l),$=e.filter(D=>I.has(D.publisher.publisherid)).flatMap(D=>D.solutions);h($),f(D=>{if(D.length===0)return D;const F=new Set($.map(G=>G.solutionid)),V=D.filter(G=>F.has(G));return V.length===D.length?D:V})},[l,e]),A.useEffect(()=>{if(!d.length){p([]),w(null);return}let I=!0;const $=new AbortController;async function D(){const F=Zt.getFilteredEntities(d);if(F){p(F);return}try{b(!0),w(null),Ie("entityFilters","[usePublisherFilter] Loading entities for solutions:",d);const V=await s_(d);Ie("entityFilters","[usePublisherFilter] Solution components received:",{solutionIds:d,componentCount:V.length,components:V.slice(0,10)});const G=Array.from(new Set(V.map(E=>E.msdyn_name).filter(Boolean)));Ie("entityFilters","[usePublisherFilter] Unique entity logical names extracted:",{count:G.length,names:G});const U=c_(G);Ie("entityFilters","[usePublisherFilter] Filtered entities from cache:",{count:U.length,entities:U.map(E=>E.LogicalName)}),I&&(p(U),Zt.setFilteredEntities(d,U))}catch(V){I&&!$.signal.aborted&&w(V instanceof Error?V.message:String(V))}finally{I&&b(!1)}}return D(),()=>{I=!1,$.abort()}},[d]);const C=A.useCallback(I=>{a(I)},[]),N=A.useCallback(I=>{f(I)},[]);return{publishers:e.map(I=>I.publisher),publishersLoading:t,publishersError:s,publishersLoaded:i,publishersWithSolutions:e,selectedPublisherIds:l,updateSelectedPublishers:C,solutions:u,selectedSolutionIds:d,updateSelectedSolutions:N,entities:m,entitiesLoading:g,entitiesError:y}}function bie(){const[e,r]=A.useState([]),[t,n]=A.useState(!1),[s,o]=A.useState(null),[i,c]=A.useState(!1),[l,a]=A.useState([]),[u,h]=A.useState([]),[d,f]=A.useState(!1),[m,p]=A.useState(null);A.useEffect(()=>{let b=!0;const y=new AbortController;async function w(){const C=Zt.getSolutions([]);if(C){r(C),c(!0);return}try{n(!0),o(null);const N=await DZ();b&&(r(N),Zt.setSolutions([],N))}catch(N){b&&!y.signal.aborted&&o(N instanceof Error?N.message:String(N))}finally{b&&(n(!1),c(!0))}}return w(),()=>{b=!1,y.abort()}},[]),A.useEffect(()=>{if(!l.length){h([]),p(null);return}let b=!0;const y=new AbortController;async function w(){const C=Zt.getFilteredEntities(l);if(C){h(C);return}try{f(!0),p(null),Ie("entityFilters","[useSolutionFilter] Loading entities for solutions:",l);const N=await s_(l);Ie("entityFilters","[useSolutionFilter] Solution components received:",{solutionIds:l,componentCount:N.length,components:N.slice(0,10)});const I=Array.from(new Set(N.map(D=>D.msdyn_name).filter(Boolean)));Ie("entityFilters","[useSolutionFilter] Unique entity logical names extracted:",{count:I.length,names:I});const $=c_(I);Ie("entityFilters","[useSolutionFilter] Filtered entities from cache:",{count:$.length,entities:$.map(D=>D.LogicalName)}),b&&(h($),Zt.setFilteredEntities(l,$))}catch(N){b&&!y.signal.aborted&&p(N instanceof Error?N.message:String(N))}finally{b&&f(!1)}}return w(),()=>{b=!1,y.abort()}},[l]);const g=A.useCallback(b=>{a(b)},[]);return{solutions:e,solutionsLoading:t,solutionsError:s,solutionsLoaded:i,selectedSolutionIds:l,updateSelectedSolutions:g,entities:u,entitiesLoading:d,entitiesError:m}}function vie({entity:e,view:r,solutions:t}){const n=[];return e&&n.push(e),r&&n.push(`View: ${r}`),t?.length&&n.push(t.join(", ")),n}const Q5=e=>e.join(" · "),Z5="fetchxml-studio:scopeSelection";function yie(e){return(e??"").trim().replace(/\/+$/,"").toLowerCase()}const J5=e=>Array.isArray(e)?e.filter(r=>typeof r=="string"&&!!r):[];function C7(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const r={};for(const[t,n]of Object.entries(e)){if(!n||typeof n!="object")continue;const s=n;r[t]={publisherIds:J5(s.publisherIds),solutionIds:J5(s.solutionIds)}}return r}function ek(e,r){if(r)return C7(e)[r]}function wie(e,r,t){const n=C7(e);return r&&(t.publisherIds.length===0&&t.solutionIds.length===0?delete n[r]:n[r]={publisherIds:[...t.publisherIds],solutionIds:[...t.solutionIds]}),n}function tk(e,r){const t=new Set(r);return e.filter(n=>t.has(n))}const rk=(e,r)=>e.length===r.length&&e.every((t,n)=>t===r[n]),nk=()=>typeof window>"u"?void 0:window.toolboxAPI?.settings;function xie({mode:e,ready:r,availablePublisherIds:t,availableSolutionIds:n,publisherIds:s,solutionIds:o,apply:i}){const[c,l]=A.useState(null),a=A.useRef(void 0),[u,h]=A.useState(new Set);return A.useEffect(()=>{let d=!0;const f=nk();if(!f?.get){l({stored:void 0,envKey:""});return}return Promise.all([f.get(Z5),Zs()]).then(([m,p])=>{d&&(a.current=m,l({stored:m,envKey:yie(p?.url)}))}).catch(m=>{console.warn("Failed to read the remembered publisher / solution selection:",m),d&&l({stored:void 0,envKey:""})}),()=>{d=!1}},[]),A.useEffect(()=>{if(!c||!e||e==="all"||!r||u.has(e))return;const d=ek(a.current,c.envKey);if(d){const f=e==="publisher-solution"?tk(d.publisherIds,t):[],m=tk(d.solutionIds,n(f));Ie("entityFilters","[useRememberedScope] Restoring the selection:",{mode:e,publishers:f,solutions:m}),(e==="solution-only"||f.length>0)&&i({publisherIds:f,solutionIds:m})}h(f=>new Set(f).add(e))},[c,e,r,u,t,n,i]),A.useEffect(()=>{if(!c?.envKey||!e||e==="all"||!u.has(e))return;const d=ek(a.current,c.envKey),f={publisherIds:e==="publisher-solution"?[...s]:d?.publisherIds??[],solutionIds:[...o]};(d?rk(d.publisherIds,f.publisherIds)&&rk(d.solutionIds,f.solutionIds):!f.publisherIds.length&&!f.solutionIds.length)||(a.current=wie(a.current,c.envKey,f),nk()?.set?.(Z5,a.current).catch(m=>console.warn("Failed to remember the publisher / solution selection:",m)))},[c,e,u,s,o]),!!c?.envKey}const T7=wr({container:{display:"flex",flexDirection:"column",gap:"4px",flex:1,minWidth:0,maxWidth:"350px"},label:{fontSize:"14px",fontWeight:600,color:le.colorNeutralForeground2},combobox:{width:"100%",minWidth:0},comboboxInput:{minWidth:0,width:"100%"},loadingOption:{display:"flex",alignItems:"center",gap:"8px",padding:"8px"},noViewsOption:{fontStyle:"italic",color:le.colorNeutralForeground3},option:{display:"flex",flexDirection:"column",minWidth:0},optionSecondary:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200}});function ok({view:e,currentUserId:r}){const t=T7(),n=MQ(e,r);return j.jsx(Jt,{value:e.id,text:e.name,children:j.jsxs("span",{className:t.option,children:[j.jsx("span",{children:e.name}),n&&j.jsx("span",{className:t.optionSecondary,children:n})]})})}function kie({selectedEntityMetadata:e,onViewSelect:r,onViewClear:t,disabled:n=!1,onSelectedViewChange:s}){const o=T7(),[i,c]=A.useState([]),[l,a]=A.useState([]),[u,h]=A.useState(!1),[d,f]=A.useState(null),[m,p]=A.useState(""),[g,b]=A.useState(null),[y,w]=A.useState(void 0);A.useEffect(()=>{s?.(g)},[g,s]),A.useEffect(()=>{if(!e){c([]),a([]),f(null),b(null),p("");return}(async()=>{h(!0),f(null),b(null),p("");try{Ie("viewAPI",`Loading views for ${e.LogicalName}`);const[{systemViews:E,personalViews:M},B]=await Promise.all([FZ(e.LogicalName),oi()]);c(E),a(M),w(B?.UserId),Ie("viewAPI",`Loaded ${E.length} system views and ${M.length} personal views`)}catch(E){const M=E instanceof Error?E.message:"Failed to load views";f(M),console.error("LoadViewPicker: Failed to fetch views:",E)}finally{h(!1)}})()},[e]);const C=A.useMemo(()=>[...i,...l],[i,l]),N=m&&m!==g?m:"",I=A.useMemo(()=>{if(!N.trim())return i;const U=N.toLowerCase();return i.filter(E=>E.name.toLowerCase().includes(U))},[i,N]),$=A.useMemo(()=>{if(!N.trim())return l;const U=N.toLowerCase();return l.filter(E=>E.name.toLowerCase().includes(U))},[l,N]),D=A.useCallback((U,E)=>{if(!E.optionValue){b(null),p(""),t?.(),Ie("viewAPI","View selection cleared");return}if(!e)return;const M=C.find(B=>B.id===E.optionValue);if(M){const B={id:M.id,type:M.type,originalFetchXml:M.fetchxml,entitySetName:e.EntitySetName,name:M.name,layoutxml:M.layoutxml,queryType:M.queryType,isCustomizable:M.isCustomizable,description:M.description,isDefault:M.isDefault,isManaged:M.isManaged,solutionId:M.solutionId,ownerId:M.ownerId,ownerName:M.ownerName};r(B),Ie("viewAPI",`Selected view: ${M.name} (${M.type}) - ID: ${M.id}`),b(M.name),p(M.name)}},[C,r,t,e]),F=A.useCallback(U=>{p(U.target.value),U.target.value!==g&&b(null)},[g]);if(!e)return null;const V=i.length>0||l.length>0,G=I.length>0||$.length>0;return j.jsxs("div",{className:o.container,children:[j.jsx("label",{className:o.label,children:"Load view"}),j.jsxs(Zn,{className:o.combobox,input:{className:o.comboboxInput},placeholder:u?"Loading views…":"Select a view to load…",disabled:n||u||!V,value:m,onChange:F,onOptionSelect:D,clearable:!!g,freeform:!0,children:[u&&j.jsx(Jt,{value:"",text:"Loading…",disabled:!0,children:j.jsxs("div",{className:o.loadingOption,children:[j.jsx(hn,{size:"tiny"}),j.jsx("span",{children:"Loading views…"})]})},"loading"),!u&&d&&j.jsx(Jt,{value:"",text:"Error",disabled:!0,children:j.jsx("span",{style:{color:le.colorPaletteRedForeground1},children:d})},"error"),!u&&!d&&!V&&j.jsx(Jt,{value:"",text:"No views available",disabled:!0,children:j.jsx("span",{className:o.noViewsOption,children:"No views available"})},"no-views"),!u&&!d&&V&&!G&&N&&j.jsx(Jt,{value:"",text:"No matching views",disabled:!0,children:j.jsxs("span",{className:o.noViewsOption,children:['No views match "',N.trim(),'"']})},"no-match"),!u&&!d&&I.length>0&&j.jsx(ja,{label:"System views",children:I.map(U=>j.jsx(ok,{view:U,currentUserId:y},U.id))}),!u&&!d&&$.length>0&&j.jsx(ja,{label:"Personal views",children:$.map(U=>j.jsx(ok,{view:U,currentUserId:y},U.id))})]})]})}const Sie=wr({container:{display:"flex",flexDirection:"column",gap:"8px",padding:"8px 12px",borderBottom:`1px solid ${le.colorNeutralStroke1}`,containerType:"inline-size"},header:{display:"flex",alignItems:"center",gap:"6px",minWidth:0},summary:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},body:{display:"flex",flexDirection:"column",gap:"8px"},bodyCollapsed:{display:"none"},filtersRow:{display:"flex",gap:"12px",alignItems:"flex-end",flexWrap:"wrap","@container (max-width: 519px)":{flexDirection:"column",alignItems:"stretch"}},entityRow:{display:"flex",alignItems:"flex-end",gap:"12px"},combobox:{minWidth:0,width:"100%"},comboboxInput:{minWidth:0,width:"100%"},newButton:{flexShrink:0,marginLeft:"auto","@container (max-width: 299px)":{minWidth:"28px",maxWidth:"28px",paddingLeft:"3px",paddingRight:"3px"}},newButtonLabel:{"@container (max-width: 299px)":{display:"none"}},field:{display:"flex",flexDirection:"column",gap:"4px",flex:1,minWidth:0},label:{fontSize:"14px",fontWeight:600,color:le.colorNeutralForeground2,display:"flex",alignItems:"center",gap:"6px"},disabledLabel:{color:le.colorNeutralForegroundDisabled},option:{display:"flex",flexDirection:"column",minWidth:0},optionSecondary:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200},note:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200,lineHeight:le.lineHeightBase200},loadingContainer:{display:"flex",alignItems:"center",justifyContent:"center",padding:"24px"},errorText:{color:le.colorPaletteRedForeground1,fontSize:"12px",marginTop:"4px"},noAccessMessage:{padding:"16px",color:le.colorNeutralForeground3,fontSize:"14px",textAlign:"center"},viewPickerRow:{display:"flex",gap:"12px",alignItems:"flex-end"}}),ik={style:{minWidth:260}};function ak(e,r){return e.length===0?r:e.length===1?e[0]:`${e.length} selected`}const sk=(e,r)=>{const t=r.trim().toLowerCase();return!t||e.friendlyname.toLowerCase().includes(t)||(e.uniquename??"").toLowerCase().includes(t)},_ie=(e,r)=>{const t=r.trim().toLowerCase();return!t||e.friendlyname.toLowerCase().includes(t)||(e.uniquename??"").toLowerCase().includes(t)||(e.customizationprefix??"").toLowerCase().includes(t)};function Cie({selectedEntity:e,onEntityChange:r,onNewQuery:t,onViewLoad:n,entityScopeMode:s,advancedFindOnly:o,collapsed:i,onCollapsedChange:c}){const l=Sie(),a=mr("publisher-combobox"),u=mr("solution-combobox"),h=mr("entity-combobox"),d=mr("query-scope"),{accessSummary:f,loading:m,noAccessMode:p}=_7(),g=A.useMemo(()=>m||p||!f?"all":s==="publisher-solution"&&f.fullFilterMode?"publisher-solution":s!=="all"&&(f.fullFilterMode||f.solutionsOnlyMode)?"solution-only":"all",[s,f,m,p]),b=gie(),y=bie(),{loadEntities:w}=g_(),[C,N]=A.useState([]),[I,$]=A.useState(!1);A.useEffect(()=>{g==="all"&&($(!0),w().then(Te=>N(Te)).catch(Te=>console.error("Failed to load entities:",Te)).finally(()=>$(!1)))},[g,w]);const D=A.useMemo(()=>{let Te=[];return g==="publisher-solution"?Te=b.entities:g==="solution-only"?Te=y.entities:Te=C,o&&(Te=Te.filter(Ee=>bJ(Ee,o))),Te},[g,o,b.entities,y.entities,C]),F=A.useMemo(()=>e?D.find(Te=>Te.LogicalName===e)??Zt.getAllEntityMetadata()?.find(Te=>Te.LogicalName===e)??C.find(Te=>Te.LogicalName===e)??null:null,[e,D,C]),[V,G]=A.useState(null),U=A.useCallback(Te=>{n&&n(Te)},[n]),E=A.useCallback(()=>{e&&r(e)},[e,r]),[M,B]=A.useState(""),k=A.useMemo(()=>b.publishers.filter(Te=>_ie(Te,M)),[M,b.publishers]);A.useEffect(()=>{Ie("entityFilters","[EntitySelector] Publisher Filter State:",{publisherQuery:M,totalPublishers:b.publishers.length,filteredPublishers:k.length,selectedPublisherIds:b.selectedPublisherIds})},[M,b.publishers,k,b.selectedPublisherIds]);const _=(Te,Ee)=>{b.updateSelectedPublishers(Ee.selectedOptions),B("")},S=A.useMemo(()=>ak(b.publishers.filter(Te=>b.selectedPublisherIds.includes(Te.publisherid)).map(Te=>Te.friendlyname),"Select publishers…"),[b.selectedPublisherIds,b.publishers]),[T,z]=A.useState(""),P=g==="publisher-solution"?b.solutions:y.solutions,O=g==="publisher-solution"?b.selectedSolutionIds:y.selectedSolutionIds,{unmanagedSolutions:X,managedSolutions:K}=A.useMemo(()=>{const Te=P.filter($e=>!$e.ismanaged),Ee=P.filter($e=>$e.ismanaged);return{unmanagedSolutions:Te,managedSolutions:Ee}},[P]),J=(Te,Ee)=>{g==="publisher-solution"?b.updateSelectedSolutions(Ee.selectedOptions):g==="solution-only"&&y.updateSelectedSolutions(Ee.selectedOptions),z("")},H=A.useMemo(()=>P.filter(Te=>O.includes(Te.solutionid)).map(Te=>Te.friendlyname),[O,P]),{publishersWithSolutions:Z,updateSelectedPublishers:L,updateSelectedSolutions:q}=b,{updateSelectedSolutions:Y}=y,re=A.useMemo(()=>Z.map(Te=>Te.publisher.publisherid),[Z]),ie=A.useCallback(Te=>g==="publisher-solution"?Z.filter(Ee=>Te.includes(Ee.publisher.publisherid)).flatMap(Ee=>Ee.solutions.map($e=>$e.solutionid)):y.solutions.map(Ee=>Ee.solutionid),[g,Z,y.solutions]),ne=A.useCallback(Te=>{g==="publisher-solution"?(L(Te.publisherIds),q(Te.solutionIds)):Y(Te.solutionIds)},[g,L,q,Y]),ae=xie({mode:m?null:g,ready:g==="publisher-solution"?b.publishersLoaded:y.solutionsLoaded,availablePublisherIds:re,availableSolutionIds:ie,publisherIds:b.selectedPublisherIds,solutionIds:O,apply:ne}),[be,pe]=A.useState(""),te=A.useMemo(()=>D.map(Te=>{const $e=`${Te.DisplayName?.UserLocalizedLabel?.Label||Te.LogicalName} (${Te.LogicalName})`;return{value:Te.LogicalName,children:$e}}),[D]);A.useEffect(()=>{if(e){const Te=D.find(Ee=>Ee.LogicalName===e);if(Te){const Ee=Te.DisplayName?.UserLocalizedLabel?.Label||Te.LogicalName;pe(`${Ee} (${Te.LogicalName})`)}else pe(e)}else pe("")},[e,D]);const se=dp(be,te,{noOptionsMessage:"No entities found"}),ue=(Te,Ee)=>{Ee.optionValue?(r(Ee.optionValue),pe(Ee.optionText??"")):pe("")},he=e?F?.DisplayName?.UserLocalizedLabel?.Label||e:null,me=vie({entity:he,view:F&&n?V:null,solutions:g==="all"?[]:H});if(m)return j.jsx("div",{className:l.container,children:j.jsx("div",{className:l.loadingContainer,children:j.jsx(hn,{size:"small",label:"Checking access permissions…"})})});if(p)return j.jsx("div",{className:l.container,children:j.jsxs("div",{className:l.noAccessMessage,children:[j.jsx(M2,{style:{marginBottom:"8px"}}),j.jsx("div",{children:"You don't have permission to read metadata (prvReadCustomization)."}),j.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:"Contact your system administrator to request access."})]})});const xe=g==="publisher-solution"?b.entitiesLoading:g==="solution-only"?y.entitiesLoading:I,Be=g==="publisher-solution"?b.entitiesError:g==="solution-only"?y.entitiesError:null,Re=Te=>j.jsx(Jt,{value:Te.solutionid,text:Te.friendlyname,children:j.jsxs("span",{className:l.option,children:[j.jsx("span",{children:Te.friendlyname}),j.jsx("span",{className:l.optionSecondary,children:[Te.uniquename,Te.version&&`v${Te.version}`].filter(Boolean).join(" · ")})]})},Te.solutionid),He=Te=>{if(Te)return j.jsx(Jt,{disabled:!0,children:Te});if(X.length===0&&K.length===0)return j.jsx(Jt,{disabled:!0,children:"No solutions found"});const Ee=X.filter(Ze=>sk(Ze,T)),$e=K.filter(Ze=>sk(Ze,T));return Ee.length===0&&$e.length===0?j.jsx(Jt,{disabled:!0,children:`No solutions match "${T.trim()}"`}):j.jsxs(j.Fragment,{children:[Ee.length>0&&j.jsx(ja,{label:"Unmanaged",children:Ee.map(Re)}),$e.length>0&&j.jsx(ja,{label:"Managed",children:$e.map(Re)})]})},Je=(Te,Ee)=>j.jsx(Zn,{className:l.combobox,input:{className:l.comboboxInput},listbox:ik,"aria-labelledby":u,placeholder:ak(H,"Select solutions…"),multiselect:!0,value:T,selectedOptions:O,onOptionSelect:J,onChange:$e=>z($e.target.value),disabled:Te,children:He(Ee)});return j.jsxs("div",{className:l.container,children:[j.jsxs("div",{className:l.header,children:[j.jsx(Or,{content:i?"Expand":"Collapse",relationship:"label",children:j.jsx(St,{appearance:"subtle",size:"small",icon:i?j.jsx(RR,{}):j.jsx(MR,{}),onClick:()=>c(!i),"aria-expanded":!i,"aria-controls":d})}),i&&me.length>0?j.jsx(st,{className:l.summary,title:Q5(me),children:he?j.jsxs(j.Fragment,{children:[j.jsx("b",{children:me[0]}),me.slice(1).map(Te=>` · ${Te}`)]}):Q5(me)}):j.jsx(st,{weight:"semibold",className:l.summary,children:"Query scope"}),j.jsx(Or,{content:"New query",relationship:"label",children:j.jsx(St,{className:l.newButton,appearance:"primary",size:"small",icon:j.jsx(rp,{}),onClick:t,children:j.jsx("span",{className:l.newButtonLabel,children:"New"})})})]}),j.jsxs("div",{id:d,className:de(l.body,i&&l.bodyCollapsed),children:[g==="publisher-solution"&&j.jsxs("div",{className:l.filtersRow,children:[j.jsxs("div",{className:l.field,children:[j.jsx("label",{id:a,className:l.label,children:"Publishers"}),j.jsx(Zn,{className:l.combobox,input:{className:l.comboboxInput},listbox:ik,"aria-labelledby":a,placeholder:S,multiselect:!0,value:M,selectedOptions:b.selectedPublisherIds,onOptionSelect:_,onChange:Te=>B(Te.target.value),disabled:b.publishersLoading,children:k.length===0?j.jsx(Jt,{disabled:!0,children:M.trim()?`No publishers match "${M.trim()}"`:"No publishers found"}):k.map(Te=>j.jsx(Jt,{value:Te.publisherid,text:Te.friendlyname,children:j.jsxs("span",{className:l.option,children:[j.jsx("span",{children:Te.friendlyname}),j.jsx("span",{className:l.optionSecondary,children:[Te.uniquename,Te.customizationprefix&&`prefix ${Te.customizationprefix}_`].filter(Boolean).join(" · ")})]})},Te.publisherid))}),b.publishersError&&j.jsx("div",{className:l.errorText,children:b.publishersError})]}),j.jsxs("div",{className:l.field,children:[j.jsx("label",{id:u,className:l.label,children:"Solutions"}),Je(b.selectedPublisherIds.length===0,b.selectedPublisherIds.length===0?"Select a publisher first":void 0)]})]}),g==="solution-only"&&j.jsxs("div",{className:l.filtersRow,children:[j.jsxs("div",{className:l.field,children:[j.jsx(Or,{content:"Publisher filtering requires prvReadPublisher privilege",relationship:"description",children:j.jsxs("label",{id:a,className:`${l.label} ${l.disabledLabel}`,children:["Publishers ",j.jsx(M2,{fontSize:14})]})}),j.jsx(Zn,{className:l.combobox,input:{className:l.comboboxInput},"aria-labelledby":a,placeholder:"No access to publishers",disabled:!0,children:j.jsx(Jt,{children:"Requires prvReadPublisher privilege"})})]}),j.jsxs("div",{className:l.field,children:[j.jsx("label",{id:u,className:l.label,children:"Solutions"}),Je(y.solutionsLoading,y.solutionsLoading?"Loading…":void 0),y.solutionsError&&j.jsx("div",{className:l.errorText,children:y.solutionsError})]})]}),j.jsx("div",{className:l.entityRow,children:j.jsxs("div",{className:l.field,children:[j.jsx("label",{id:h,className:l.label,children:"Entity"}),j.jsx(Zn,{className:l.combobox,input:{className:l.comboboxInput},"aria-labelledby":h,placeholder:xe?"Loading entities…":"Select an entity…",value:be,onOptionSelect:ue,onChange:Te=>pe(Te.target.value),clearable:!0,disabled:xe||D.length===0,children:xe?j.jsx(Jt,{disabled:!0,children:"Loading…"}):D.length===0?j.jsx(Jt,{disabled:!0,children:g!=="all"?"Select a solution first":"No entities found"}):se}),Be&&j.jsx("div",{className:l.errorText,children:Be})]})}),F&&n&&j.jsx("div",{className:l.viewPickerRow,children:j.jsx(kie,{selectedEntityMetadata:F,onViewSelect:U,onViewClear:E,onSelectedViewChange:G})}),ae&&g!=="all"&&j.jsx(st,{className:l.note,children:g==="publisher-solution"?"Your publisher and solution selection is remembered for this environment.":"Your solution selection is remembered for this environment."})]})]})}const Tie=wr({container:{display:"flex",flexDirection:"column",gap:"4px"},combobox:{width:"100%"},hint:{fontSize:"12px",color:le.colorNeutralForeground3},solutionOption:{display:"flex",flexDirection:"column",gap:"2px"},solutionName:{fontWeight:500},solutionUniqueName:{fontSize:"11px",color:le.colorNeutralForeground3}});function Bie({solutions:e,selectedSolution:r,onSolutionChange:t,disabled:n=!1}){const s=Tie(),o=A.useMemo(()=>[...e].sort((c,l)=>(c.friendlyname||c.uniquename).localeCompare(l.friendlyname||l.uniquename)),[e]),i=(c,l)=>{if(l.optionValue==="__none__")t(null);else{const a=e.find(u=>u.solutionid===l.optionValue);t(a||null)}};return j.jsxs("div",{className:s.container,children:[j.jsx(Eo,{label:"Add to solution",hint:"Select a solution to include the view in",children:j.jsxs(Zn,{className:s.combobox,placeholder:"Select solution (optional)",value:r?.friendlyname||"",onOptionSelect:i,disabled:n,children:[j.jsx(Jt,{value:"__none__",text:"",children:j.jsx("span",{style:{fontStyle:"italic",color:le.colorNeutralForeground3},children:"None - don't add to any solution"})}),o.map(c=>j.jsx(Jt,{value:c.solutionid,text:c.friendlyname||c.uniquename,children:j.jsxs("div",{className:s.solutionOption,children:[j.jsx("span",{className:s.solutionName,children:c.friendlyname||c.uniquename}),j.jsxs("span",{className:s.solutionUniqueName,children:[c.uniquename,c.version&&` (v${c.version})`]})]})},c.solutionid))]})}),e.length===0&&j.jsx(st,{className:s.hint,children:"No unmanaged solutions available. The view will be created in the Default solution."})]})}const jie=100,B7=e=>e?.trim().toLowerCase()==="production",Vf=e=>e===1?"1 record":`${e.toLocaleString()} records`;function Nie(e){switch(e.kind){case"records":return Vf(e.count);case"text":return e.text;case"allMatching":{const r="Every record the query matches",t=e.loadedCount;return t?e.moreRecords===!0?`${r} (more than the ${Vf(t)} loaded)`:e.moreRecords===!1?`${r} (${Vf(t)} when the query last ran)`:`${r} (${Vf(t)} loaded; there may be more)`:r}}}function Eie(e,r){return B7(e)?!0:r.kind==="records"?r.count>jie:r.kind==="allMatching"}const Aie=(e,r)=>e.trim().toLowerCase()===r.trim().toLowerCase()&&r.trim()!=="",Rie=wr({root:{display:"flex",flexDirection:"column",gap:le.spacingVerticalS},box:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:le.spacingHorizontalM,rowGap:le.spacingVerticalXS,padding:`${le.spacingVerticalS} ${le.spacingHorizontalM}`,backgroundColor:le.colorNeutralBackground3,borderRadius:le.borderRadiusMedium},label:{color:le.colorNeutralForeground3},value:{display:"flex",flexWrap:"wrap",alignItems:"center",columnGap:le.spacingHorizontalS,minWidth:0},secondary:{color:le.colorNeutralForeground3,wordBreak:"break-all"}});function yd({entityLogicalName:e,entityDisplayName:r,scope:t,onConfirmationChange:n,disabled:s}){const o=Rie(),[i,c]=A.useState({status:"loading"}),[l,a]=A.useState("");A.useEffect(()=>{let g=!0;return Zs().then(b=>g&&c({status:"ready",connection:b})).catch(b=>{console.warn("TargetScope: couldn't read the connection:",b),g&&c({status:"ready",connection:null})}),()=>{g=!1}},[]);const u=i.status==="ready"?i.connection:null,h=B7(u?.environment),d=r||(e?Zt.getEntityMetadata(e)?.DisplayName?.UserLocalizedLabel?.Label:void 0),f=e||"confirm",m=!!n&&i.status==="ready"&&Eie(u?.environment,t),p=i.status==="ready"&&(!m||Aie(l,f));return A.useEffect(()=>{n?.(p)},[p,n]),j.jsxs("div",{className:o.root,children:[h&&j.jsx(Ar,{intent:"warning",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Production environment"}),"This changes live data."]})}),j.jsxs("div",{className:o.box,children:[j.jsx(st,{className:o.label,children:"Environment"}),j.jsx("div",{className:o.value,children:i.status==="loading"?j.jsx(st,{children:"Reading the connection..."}):u?j.jsxs(j.Fragment,{children:[j.jsx(st,{weight:"semibold",children:u.name}),u.environment&&j.jsx(ri,{size:"small",appearance:h?"filled":"tint",color:h?"warning":"informative",children:u.environment}),j.jsx(st,{size:200,className:o.secondary,children:u.url})]}):j.jsx(st,{children:"Unknown (the tool has no connection)"})}),j.jsx(st,{className:o.label,children:"Entity"}),j.jsxs("div",{className:o.value,children:[j.jsx(st,{weight:"semibold",children:d||e||"Unknown"}),d&&e&&d!==e&&j.jsxs(st,{className:o.secondary,children:["(",e,")"]})]}),j.jsx(st,{className:o.label,children:"Scope"}),j.jsx("div",{className:o.value,children:j.jsx(st,{weight:"semibold",children:Nie(t)})})]}),m&&j.jsx(Eo,{label:j.jsxs(j.Fragment,{children:["Type ",j.jsx("strong",{children:f})," to confirm"]}),hint:h?"Required on a Production environment.":"Required for more than 100 records, or when the total isn't known.",children:j.jsx(_n,{value:l,onChange:(g,b)=>a(b.value),disabled:s,autoComplete:"off"})})]})}const zie=wr({surface:{maxWidth:"500px",width:"100%"},content:{display:"flex",flexDirection:"column",gap:"16px"},fieldGroup:{display:"flex",flexDirection:"column",gap:"12px"},validationSection:{display:"flex",flexDirection:"column",gap:"8px"},validationHeader:{display:"flex",alignItems:"center",gap:"8px"},validationList:{display:"flex",flexDirection:"column",gap:"6px",maxHeight:"150px",overflowY:"auto",paddingLeft:"4px"},validationItem:{display:"flex",alignItems:"flex-start",gap:"8px",fontSize:"13px"},severityIcon:{flexShrink:0,marginTop:"2px"},severityLow:{color:le.colorPaletteBlueBackground2},severityMedium:{color:le.colorPaletteYellowForeground1},severityHigh:{color:le.colorPaletteRedForeground1},severityCritical:{color:le.colorPaletteRedForeground1},solutionInfo:{display:"flex",flexDirection:"column",gap:"4px",padding:"8px 12px",backgroundColor:le.colorNeutralBackground3,borderRadius:"4px",marginTop:"8px"},solutionLabel:{fontSize:"12px",color:le.colorNeutralForeground3},solutionValue:{fontSize:"13px",fontWeight:500},overwriteWarning:{marginTop:"4px"},radioDescription:{fontSize:"12px",color:le.colorNeutralForeground3,marginLeft:"28px",marginTop:"-4px"},publishNote:{fontSize:"12px",color:le.colorNeutralForeground3,fontStyle:"italic"},accessCheck:{display:"flex",alignItems:"center",gap:"8px"},placeholderNote:{fontSize:"12px",color:le.colorNeutralForeground3},code:{fontFamily:le.fontFamilyMonospace}});function Iie({open:e,onClose:r,onSaveComplete:t,mode:n,shouldPublish:s,fetchXml:o,layoutXml:i,entityLogicalName:c,entityDisplayName:l,objectTypeCode:a,primaryIdAttribute:u,loadedView:h}){const d=zie(),[f,m]=A.useState(""),[p,g]=A.useState(""),[b,y]=A.useState("personal"),[w,C]=A.useState(null),[N,I]=A.useState([]),[$,D]=A.useState(!1),[F,V]=A.useState(null),[G,U]=A.useState(null),[E,M]=A.useState({status:"idle",messages:[]}),[B,k]=A.useState(!1),[_,S]=A.useState(null),[T,z]=A.useState(!1),[P,O]=A.useState(void 0),[X,K]=A.useState("unknown"),[J,H]=A.useState(null),[Z,L]=A.useState(!1),[q,Y]=A.useState(null),re=n==="save"&&h!==null,ie=re&&!T,ne=ie&&h!==null&&!LQ(h),ae=ie&&X==="denied",be=ne||ae,pe=ie&&X==="checking",te=ie&&h!==null&&ib(h,P),se=ie&&h?.type==="system"&&h.isManaged===!0,ue=!be&&(ie&&h?PQ(h):b==="system"),he=ie&&h?.isDefault===!0,me=A.useMemo(()=>sb(o)>0,[o]);A.useEffect(()=>{e&&(re&&h?(m(h.name),y(h.type),g(h.description??""),L(h.isDefault===!0)):(m(""),y("personal"),g(""),L(!1)),z(!1),S(null),M({status:"idle",messages:[]}))},[e,re,h]),A.useEffect(()=>{if(!e||!re||h?.type!=="personal"){K("unknown");return}let Ee=!0;return K("checking"),(async()=>{const $e=await oi();if(!Ee)return;O($e?.UserId);const yt=!!$e&&!!h.ownerId&&!ib(h,$e.UserId)?!0:await VZ(h.id);Ee&&K(yt===void 0?"unknown":yt?"allowed":"denied")})(),()=>{Ee=!1}},[e,re,h]),A.useEffect(()=>{if(H(null),!e||!se||!h?.solutionId)return;let Ee=!0;return WZ(h.solutionId).then($e=>{Ee&&H($e)}),()=>{Ee=!1}},[e,se,h]),A.useEffect(()=>{if(!e||!ue||!c)return;let Ee=!0;return UZ(c).then($e=>{Ee&&Y($e)}),()=>{Ee=!1}},[e,ue,c]),A.useEffect(()=>{e&&($Z().then(V),HZ().then(U))},[e]),A.useEffect(()=>{if(!e||b!=="system")return;async function Ee(){D(!0);try{const $e=await XZ();I($e)}catch($e){console.error("Failed to load solution info:",$e),I([])}finally{D(!1)}}Ee()},[e,b]),A.useEffect(()=>{if(!e||!o)return;async function Ee(){M({status:"validating",messages:[]});try{const Ze=(await qZ(o)).ValidationResults?.Messages||[];M({status:qQ(Ze),messages:Ze})}catch($e){console.warn("FetchXML validation unavailable:",$e),M({status:"unavailable",messages:[],errorMessage:"Validation unavailable - FetchXML will be validated when saved"})}}Ee()},[e,o]);const xe=A.useCallback(Ee=>{switch(Ee){case 0:return j.jsx(jg,{className:`${d.severityIcon} ${d.severityLow}`});case 1:return j.jsx(B2,{className:`${d.severityIcon} ${d.severityMedium}`});case 2:case 3:return j.jsx(E2,{className:`${d.severityIcon} ${d.severityHigh}`});default:return j.jsx(jg,{className:`${d.severityIcon} ${d.severityLow}`})}},[d]),Be=A.useMemo(()=>{if(!f.trim()||B||be||pe)return!1;if(b==="system"){if(!F?.canWrite)return!1}else if(!G?.canWrite)return!1;return!0},[f,B,be,pe,b,F,G]),Re=A.useCallback(async()=>{if(!Be)return;k(!0),S(null);const Ee=Bh();try{let $e;const Ze=p.trim(),yt=ue&&Z&&!he;if(b==="personal")ie&&h?(await QZ(h.id,{name:f.trim(),fetchxml:o,layoutxml:i,description:Ze||null}),$e=h.id):$e=await YZ({name:f.trim(),fetchxml:o,layoutxml:i,returnedtypecode:c,description:Ze||void 0,querytype:0});else{const dt=ie&&h?h.queryType??0:0;await LZ(o,dt),ie&&h?(await KZ(h.id,{name:f.trim(),fetchxml:o,layoutxml:i,description:Ze||null,...yt?{isdefault:!0}:{}}),$e=h.id):($e=await GZ({name:f.trim(),fetchxml:o,layoutxml:i,returnedtypecode:c,description:Ze||void 0,querytype:0,isdefault:yt}),w&&await ZZ($e,JZ,w.uniquename,!1)),s&&await eJ(c)}t($e,b,f.trim(),{description:Ze||void 0,isDefault:b==="system"?yt||he:void 0})}catch($e){console.error("Failed to save view:",$e),S(zn($e,"Failed to save view"))}finally{Ee(),k(!1)}},[Be,b,ie,h,f,o,i,p,c,w,s,t,ue,Z,he]),He=A.useCallback(()=>{h&&(z(!0),m(`${h.name} (copy)`),y("personal"),L(!1),S(null))},[h]),Je=A.useMemo(()=>ie?s?"Save and publish view":"Save view":"Save as new view",[ie,s]),Te=A.useMemo(()=>{const Ee=s&&b==="system"?", then published":"";return ie&&h?`The ${h.type} view "${h.name}" (overwritten${Ee})`:`A new ${b} view${Ee}`},[ie,h,s,b]);return j.jsx(Do,{open:e,onOpenChange:(Ee,$e)=>!$e.open&&r(),children:j.jsx(zi,{className:d.surface,children:j.jsxs(Ai,{children:[j.jsx(Ri,{action:j.jsx(St,{appearance:"subtle","aria-label":"Close",icon:j.jsx(sl,{}),onClick:r}),children:Je}),j.jsxs(Ii,{className:d.content,children:[j.jsx(yd,{entityLogicalName:c,scope:{kind:"text",text:Te}}),j.jsxs("div",{className:d.validationSection,children:[j.jsxs("div",{className:d.validationHeader,children:[E.status==="validating"&&j.jsxs(j.Fragment,{children:[j.jsx(hn,{size:"tiny"}),j.jsx(st,{children:"Validating FetchXML..."})]}),E.status==="valid"&&j.jsxs(j.Fragment,{children:[j.jsx(eR,{style:{color:le.colorPaletteGreenForeground1}}),j.jsx(st,{children:"No performance issues found"})]}),(E.status==="warning"||E.status==="error")&&j.jsxs(j.Fragment,{children:[E.status==="error"?j.jsx(E2,{style:{color:le.colorPaletteRedForeground1}}):j.jsx(B2,{style:{color:le.colorPaletteYellowForeground1}}),j.jsxs(st,{children:[E.messages.length," validation"," ",E.messages.length===1?"message":"messages"]})]}),E.status==="unavailable"&&j.jsxs(j.Fragment,{children:[j.jsx(jg,{style:{color:le.colorNeutralForeground3}}),j.jsx(st,{children:E.errorMessage})]})]}),E.messages.length>0&&j.jsx("div",{className:d.validationList,children:E.messages.map((Ee,$e)=>j.jsxs("div",{className:d.validationItem,children:[xe(Ee.Severity),j.jsx("span",{children:Ee.LocalizedMessageText})]},$e))})]}),j.jsx(Sh,{}),pe&&h&&j.jsxs("div",{className:d.accessCheck,children:[j.jsx(hn,{size:"tiny"}),j.jsxs(st,{children:['Checking your access to "',h.name,'"…']})]}),!pe&&j.jsxs("div",{className:d.fieldGroup,children:[ae&&h&&j.jsx(Ar,{intent:"error",layout:"multiline",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Can't overwrite this view"}),h.ownerName?`${h.ownerName} shared "${h.name}" with you without write access. Save a copy instead.`:`"${h.name}" was shared with you without write access. Save a copy instead.`]})}),j.jsx(Eo,{label:"Name",required:!0,children:j.jsx(_n,{value:f,onChange:(Ee,$e)=>m($e.value),placeholder:"Enter view name",disabled:B||be})}),j.jsx(Eo,{label:"Description",hint:ie&&h?.description?"Loaded from the view.":void 0,children:j.jsx(Sv,{value:p,onChange:(Ee,$e)=>g($e.value),placeholder:"Optional description",disabled:B||be,rows:2})}),!ie&&j.jsx(Eo,{label:"View type",children:j.jsxs(ta,{value:b,onChange:(Ee,$e)=>y($e.value),disabled:B,children:[j.jsx(Yr,{value:"personal",label:"Personal view",disabled:!G?.canWrite}),j.jsx("div",{className:d.radioDescription,children:G?.canWrite?"Only visible to you":"You don't have permission to create personal views"}),j.jsx(Yr,{value:"system",label:"System view",disabled:!F?.canWrite}),j.jsx("div",{className:d.radioDescription,children:F?.canWrite?"Visible to all users with access to this entity":"You don't have permission to create system views"})]})}),b==="system"&&!ie&&j.jsx(j.Fragment,{children:$?j.jsx("div",{className:d.solutionInfo,children:j.jsx(hn,{size:"tiny",label:"Loading solutions..."})}):j.jsx(Bie,{solutions:N,selectedSolution:w,onSolutionChange:C,disabled:B})})," ",ue&&j.jsx(Eo,{hint:he?"This is the default view. To change the default, set another public view as default.":q&&q.id!==h?.id?`Replaces "${q.name}" as the default public view for ${l||c}.`:void 0,children:j.jsx(ho,{label:"Set as default view",checked:Z,disabled:B||he,onChange:(Ee,$e)=>L($e.checked===!0)})}),ne&&h&&j.jsx(Ar,{intent:"error",className:d.overwriteWarning,children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Can't overwrite this view"}),'"',h.name,`" isn't customizable. Save a copy instead.`]})}),se&&!be&&h&&j.jsx(Ar,{intent:"warning",layout:"multiline",className:d.overwriteWarning,children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Managed view"}),J?`"${h.name}" comes from the managed solution ${J.friendlyName} (${J.uniqueName}).`:`"${h.name}" comes from a managed solution.`," ","Saving adds an unmanaged customization on top of it, which stays in effect until it's removed, even after the solution is updated."]})}),te&&!be&&h&&j.jsx(Ar,{intent:"warning",layout:"multiline",className:d.overwriteWarning,children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Overwrite warning"}),'"',h.name,'" belongs to ',h.ownerName||"another user",". Saving changes it for everyone it's shared with."]})}),ie&&!be&&!se&&!te&&h&&j.jsx(Ar,{intent:"warning",className:d.overwriteWarning,children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Overwrite warning"}),'This will overwrite the existing view "',h.name,'".']})}),me&&!be&&j.jsxs(st,{className:d.placeholderNote,children:[j.jsx("span",{className:d.code,children:"{0}"})," placeholders are saved as written. The quick find test value is only used to run the query."]}),s&&b==="system"&&j.jsx(st,{className:d.publishNote,children:"The view will be published after saving, making it immediately available to users."})]}),_&&j.jsx(Ar,{intent:"error",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Save failed"}),_]})})]}),j.jsxs(Po,{children:[be&&j.jsx(St,{appearance:"secondary",onClick:He,disabled:B,children:"Save a copy…"}),j.jsx(St,{appearance:"secondary",onClick:r,disabled:B,children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:Re,disabled:!Be,children:B?j.jsx(hn,{size:"tiny"}):s&&b==="system"?"Save and publish":"Save"})]})]})})})}const Mie=wr({splitButton:{minWidth:"110px"},menuItem:{display:"flex",alignItems:"center",gap:"8px"},menuIcon:{fontSize:"16px",color:le.colorNeutralForeground2}});function Die({fetchXml:e,layoutXml:r,entityLogicalName:t,entityDisplayName:n,objectTypeCode:s,primaryIdAttribute:o,loadedView:i,onSaveComplete:c,disabled:l=!1}){const a=Mie(),[u,h]=A.useState(!1),[d,f]=A.useState("save"),[m,p]=A.useState(!1),{sync:g,editorHasContent:b}=S7(),[y,w]=A.useState(null),C=A.useCallback((E,M)=>{p(M),f(E),h(!0)},[]),N=A.useCallback(async(E,M)=>{const B=await g("save");if(B.status!=="cancelled"){if(B.status==="unchanged"){C(E,M);return}w({entity:B.fetchQuery.entity.name,xml:B.fetchXml})}},[g,C]);A.useEffect(()=>{!y||!(e===y.xml&&t===y.entity&&s>0&&o!=="")||(w(null),C("saveAs",!1))},[y,e,t,s,o,C]);const I=A.useCallback(()=>{N("save",!1)},[N]),$=A.useCallback(()=>{N("saveAs",!1)},[N]),D=A.useCallback(()=>{N("save",!0)},[N]),F=A.useCallback(()=>{h(!1)},[]),V=A.useCallback((E,M,B,k)=>{h(!1),c?.(E,M,B,k)},[c]),G=i?"Save":"Save as",U=i?j.jsx(j2,{}):j.jsx(N2,{});return j.jsxs(j.Fragment,{children:[j.jsxs(_i,{positioning:"below-end",children:[j.jsx(va,{disableButtonEnhancement:!0,children:E=>j.jsx(Or,{content:i?`Save changes to "${i.name}"`:"Save as new view",relationship:"description",children:j.jsx(hv,{className:a.splitButton,appearance:"primary",icon:U,menuButton:E,primaryActionButton:{onClick:i?I:$},disabled:l&&!b,children:G})})}),j.jsx(Ti,{children:j.jsxs(Ci,{children:[i&&j.jsx(Gr,{icon:j.jsx(j2,{className:a.menuIcon}),onClick:I,children:j.jsx("span",{className:a.menuItem,children:"Save"})}),j.jsx(Gr,{icon:j.jsx(N2,{className:a.menuIcon}),onClick:$,children:j.jsx("span",{className:a.menuItem,children:"Save as…"})}),i?.type==="system"&&j.jsx(Gr,{icon:j.jsx(ZA,{className:a.menuIcon}),onClick:D,children:j.jsx("span",{className:a.menuItem,children:"Save and publish"})})]})})]}),j.jsx(Iie,{open:u,onClose:F,onSaveComplete:V,mode:d,shouldPublish:m,fetchXml:e,layoutXml:r,entityLogicalName:t,entityDisplayName:n,objectTypeCode:s,primaryIdAttribute:o,loadedView:i})]})}const Pie=wr({menuItemContent:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"2px"},toolIdHint:{fontSize:le.fontSizeBase100,color:le.colorNeutralForeground3}});function Oie({fetchXml:e,entityLogicalName:r,tools:t,disabled:n}){const s=Pie(),{sync:o,editorHasContent:i}=S7(),c=A.useCallback(async a=>{const u=await o("send");if(u.status==="cancelled")return;const h=u.status==="synced"?u.fetchXml:e,d=u.status==="synced"?u.fetchQuery.entity.name:r;if(!h||!d)return;IJ(a,{fetchXml:h,entityLogicalName:d}).catch(async m=>{const p=m instanceof Error?m.message:String(m);/already in progress/i.test(p)||await window.toolboxAPI?.utils?.showNotification?.({title:"Cannot open tool",body:p,type:"error"})})},[e,r,o]),l=!i&&(n||!e||!r);return t.length===0?null:j.jsxs(_i,{children:[j.jsx(va,{disableButtonEnhancement:!0,children:j.jsx(St,{appearance:"subtle",icon:j.jsx(z2,{}),disabled:l,children:"Send to tool"})}),j.jsx(Ti,{children:j.jsx(Ci,{children:t.map(a=>j.jsx(Gr,{icon:j.jsx(z2,{}),onClick:()=>{c(a.id)},children:j.jsxs("div",{className:s.menuItemContent,children:[j.jsx("span",{children:a.name}),j.jsx("span",{className:s.toolIdHint,children:a.id})]})},a.id))})})]})}const lk={loading:!1,isCallee:!1,context:null};function Fie(){const[e,r]=A.useState({loading:!0,isCallee:!1,context:null});return A.useEffect(()=>{let t=!0;if(!b_()){r(lk);return}return(async()=>{try{const n=await NJ();t&&r({loading:!1,isCallee:n!==null,context:n})}catch(n){console.error("useLaunchContext: failed to read launch context",n),t&&r(lk)}})(),()=>{t=!1}},[]),e}function qie(){const[e,r]=A.useState({loading:!0,tools:[]});return A.useEffect(()=>{let t=!0;return(async()=>{const n=await jJ();t&&r({loading:!1,tools:n})})(),()=>{t=!1}},[]),e}function Lie(e,r){const t=e.from??"",n=e.to??"";return e.relationshipType==="N1"?n||t:e.relationshipType==="1N"||r&&n&&n===r?t||n:n||t}function $ie(e,r){if(e.alias)return`${e.alias} (${e.linkType})`;const t=Lie(e,r);return t?`${e.name} via ${t} (${e.linkType})`:`${e.name} (${e.linkType})`}function Hie(e){return cl.has(e.linkType)||e.intersect?!1:e.attributes.length===0&&!e.allAttributes?.enabled}function Zl(e){return e.type==="filter"?e.conditions.length+e.subfilters.reduce((r,t)=>r+1+Zl(t),0)+(e.links??[]).reduce((r,t)=>r+1+Zl(t),0):(e.allAttributes?.enabled?1:0)+e.attributes.length+e.orders.length+e.filters.reduce((r,t)=>r+1+Zl(t),0)+e.links.reduce((r,t)=>r+1+Zl(t),0)}function Vie(e){return e===1?"This also deletes the item inside it.":`This also deletes the ${e} items inside it.`}const Cu="All types",Wie=wr({surface:{width:"min(1000px, 94vw)",maxWidth:"min(1000px, 94vw)"},content:{display:"flex",flexDirection:"column",gap:le.spacingVerticalM,minHeight:"420px",maxHeight:"62vh"},filters:{display:"flex",alignItems:"center",gap:le.spacingHorizontalM,flexWrap:"wrap"},searchBox:{flex:1,minWidth:"220px"},typeFilter:{minWidth:"150px"},dataGridContainer:{flex:1,display:"flex",flexDirection:"column",minHeight:"300px",overflow:"hidden"},dataGrid:{minWidth:"100%",display:"flex",flexDirection:"column",height:"100%"},dataGridBody:{overflow:"auto",flex:1},truncate:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},mono:{fontFamily:le.fontFamilyMonospace,fontSize:le.fontSizeBase200},count:{marginRight:"auto",alignSelf:"center",color:le.colorNeutralForeground3}}),Uie=e=>(e.AttributeTypeName?.Value??e.AttributeType??"").replace(/Type$/,"")||"Unknown",Xie={displayName:{defaultWidth:300,idealWidth:300,minWidth:120},logicalName:{defaultWidth:300,idealWidth:300,minWidth:120},dataType:{defaultWidth:140,idealWidth:140,minWidth:90}};function Gie({open:e,onOpenChange:r,entityDisplayName:t,nodeId:n,attributes:s,selectedAttributeNames:o,onApply:i}){const c=Wie(),[l,a]=A.useState(""),[u,h]=A.useState(Cu),[d,f]=A.useState(!1),[m,p]=A.useState(new Set(o));A.useEffect(()=>{e&&(p(new Set(o)),a(""),h(Cu),f(!1))},[e,o]);const g=A.useMemo(()=>s.map(F=>({logicalName:F.LogicalName,displayName:F.DisplayName?.UserLocalizedLabel?.Label||F.LogicalName,dataType:Uie(F)})).sort((F,V)=>F.displayName.localeCompare(V.displayName)),[s]),b=A.useMemo(()=>[...new Set(g.map(F=>F.dataType))].sort(),[g]),y=A.useMemo(()=>{const F=l.trim().toLowerCase();return g.filter(V=>(!F||V.logicalName.toLowerCase().includes(F)||V.displayName.toLowerCase().includes(F))&&(u===Cu||V.dataType===u)&&(!d||m.has(V.logicalName)))},[g,l,u,d,m]),w=A.useMemo(()=>g.filter(F=>m.has(F.logicalName)).length,[g,m]),C=A.useMemo(()=>{const F=(V,G)=>j.jsx(Gl,{truncate:!0,children:j.jsx(Or,{content:V,relationship:"description",children:j.jsx("span",{className:G?de(c.truncate,c.mono):c.truncate,children:V})})});return[rc({columnId:"displayName",compare:(V,G)=>V.displayName.localeCompare(G.displayName),renderHeaderCell:()=>"Display name",renderCell:V=>F(V.displayName)}),rc({columnId:"logicalName",compare:(V,G)=>V.logicalName.localeCompare(G.logicalName),renderHeaderCell:()=>"Logical name",renderCell:V=>F(V.logicalName,!0)}),rc({columnId:"dataType",compare:(V,G)=>V.dataType.localeCompare(G.dataType),renderHeaderCell:()=>"Type",renderCell:V=>F(V.dataType)})]},[c.truncate,c.mono]),N=A.useCallback((F,V)=>{a(V.value)},[]),I=A.useCallback((F,V)=>{p(V.selectedItems)},[]),$=A.useCallback(()=>{const F=Array.from(m);i(n,F),r(!1)},[m,n,i,r]),D=A.useCallback(()=>{r(!1)},[r]);return j.jsx(Do,{open:e,onOpenChange:(F,V)=>r(V.open),children:j.jsx(zi,{className:c.surface,"aria-describedby":void 0,children:j.jsxs(Ai,{children:[j.jsxs(Ri,{children:["Select attributes · ",t]}),j.jsxs(Ii,{className:c.content,children:[j.jsxs("div",{className:c.filters,children:[j.jsx(zv,{className:c.searchBox,placeholder:"Search display or logical name",value:l,onChange:N}),j.jsx(po,{className:c.typeFilter,"aria-label":"Filter by type",value:u,selectedOptions:[u],onOptionSelect:(F,V)=>h(V.optionValue??Cu),children:[Cu,...b].map(F=>j.jsx(Jt,{value:F,children:F},F))}),j.jsx(Qs,{label:"Selected only",checked:d,onChange:(F,V)=>f(V.checked)})]}),j.jsx("div",{className:c.dataGridContainer,children:j.jsxs(OS,{className:c.dataGrid,items:y,columns:C,sortable:!0,resizableColumns:!0,columnSizingOptions:Xie,selectionMode:"multiselect",selectedItems:m,onSelectionChange:I,getRowId:F=>F.logicalName,size:"small",children:[j.jsx($S,{children:j.jsx(V0,{selectionCell:{checkboxIndicator:{"aria-label":"Select all attributes"}},children:({renderHeaderCell:F})=>j.jsx(jv,{children:F()})})}),j.jsx(zS,{className:c.dataGridBody,children:({item:F,rowId:V})=>j.jsx(V0,{selectionCell:{checkboxIndicator:{"aria-label":`Select ${F.displayName}`}},children:({renderCell:G})=>j.jsx(Bv,{children:G(F)})},V)})]})})]}),j.jsxs(Po,{fluid:!0,children:[j.jsxs(st,{className:c.count,size:200,children:[w," of ",g.length," selected"]}),j.jsx(St,{appearance:"primary",onClick:$,children:"Apply"}),j.jsx(St,{appearance:"secondary",onClick:D,children:"Cancel"})]})]})})})}function j7(e){return typeof e=="number"?Math.abs(e)<1e-10&&e!==0?e.toFixed(20).replace(/\.?0+$/,""):Number.isInteger(e)?e.toString():e.toFixed(10).replace(/\.?0+$/,""):Array.isArray(e)?e.map(r=>j7(r)).join(", "):String(e)}const Kie=wr({container:{flex:1,overflow:"auto",padding:"8px",minHeight:0,scrollbarGutter:"stable"},treeItem:{"&:hover":{backgroundColor:le.colorNeutralBackground1Hover}},actions:{display:"flex",gap:"4px",opacity:0,transition:"opacity 0.2s","&:focus-within":{opacity:1}},treeItemWithActions:{"&:hover .actions":{opacity:1}},badges:{display:"flex",gap:le.spacingHorizontalXXS,alignItems:"center"},hint:{color:le.colorNeutralForeground4,marginLeft:"6px",fontStyle:"italic"},danger:{color:le.colorPaletteRedForeground1,"& svg":{color:le.colorPaletteRedForeground1}}}),ck=(...e)=>e.filter(r=>!!r),Yie=e=>Zt.getEntityMetadata(e)?.PrimaryIdAttribute??Zt.getAllEntityMetadata()?.find(r=>r.LogicalName===e)?.PrimaryIdAttribute,Qie={count:"Count",countcolumn:"Count values",sum:"Sum",avg:"Average",min:"Min",max:"Max"};function Zie({fetchQuery:e,selectedNodeId:r,onNodeSelect:t,onAddAttribute:n,onAddAllAttributes:s,onAddOrder:o,onAddFilter:i,onAddSubfilter:c,onAddCondition:l,onAddLinkEntity:a,onRemoveNode:u,onUpdateAttributes:h}){const d=Kie(),f=A.useMemo(()=>{const te=new Map;for(const se of Fv(e))se.severity==="error"&&te.set(se.nodeId,[...te.get(se.nodeId)??[],se.message]);return te},[e]),m=(te,se=[])=>{const ue=f.get(te),he=ue?[...se,{text:"Error",color:"danger",title:ue.join(" ")}]:se;if(he.length!==0)return j.jsx("span",{className:d.badges,children:he.map(me=>j.jsx(ri,{size:"small",appearance:"tint",color:me.color??"informative",title:me.title,children:me.text},me.text))})},[p,g]=A.useState(!1),[b,y]=A.useState(null),[w,C]=A.useState(""),[N,I]=A.useState([]),[$,D]=A.useState([]),F=A.useRef(null),[V,G]=A.useState(new Set([e.id,e.entity.id])),U=te=>te.stopPropagation(),[E,M]=A.useState({open:!1}),B=A.useRef(null),[k,_]=A.useState(null),S=te=>{const se=[],ue=(he,me)=>{if(!he||typeof he!="object")return!1;const xe=he;if(xe.id===me)return Ie("treeExpansion","Found target node:",xe.id),!0;const Be=xe.id;Ie("treeExpansion","Checking node:",Be,"type:",xe.type);const Re=["attributes","orders","filters","conditions","subfilters","links"];for(const He of Re)if(Array.isArray(xe[He])){for(const Je of xe[He])if(ue(Je,me))return se.unshift(Be),!0}return xe.entity&&ue(xe.entity,me)?(se.unshift(Be),!0):!1};return ue(e,te),Ie("treeExpansion","Final path:",se),se};A.useEffect(()=>{if(r){Ie("treeExpansion","Node selected, expanding path:",r);const te=S(r);if(Ie("treeExpansion","Path to node:",te),te.length===0){xY("treeExpansion","Path is empty! Node might not be in tree yet.");return}G(ue=>{const he=new Set(ue),me=he.size;te.forEach(Be=>he.add(Be));const xe=Array.from(he).filter(Be=>!ue.has(Be));return Ie("treeExpansion","Updated openItems:",{sizeBefore:me,sizeAfter:he.size,added:xe,addedCount:xe.length,allOpen:Array.from(he)}),he});const se=setTimeout(()=>{F.current?.querySelector(`[data-fui-tree-item-value="${CSS.escape(r)}"]`)?.scrollIntoView({behavior:"smooth",block:"nearest"})},250);return()=>clearTimeout(se)}},[r]);const T=A.useCallback(async te=>{const se=te.name,ue=Zt.getEntityMetadata(se)?.DisplayName?.UserLocalizedLabel?.Label||se,he=te.attributes.map(xe=>xe.name);let me=[];try{me=await Yv(se)}catch(xe){console.error("Failed to load attributes:",xe)}y(te.id),C(ue),I(me),D(he),g(!0)},[]),z=A.useCallback((te,se)=>{h(te,se)},[h]),P=(te,se)=>{Ie("treeExpansion","handleOpenChange called:",{open:se.open,value:se.value,type:se.type,openItemsCount:se.openItems.size,openItems:Array.from(se.openItems)}),G(se.openItems)},O=te=>{te.descendants>0?_(te):u(te.id)},X=te=>{const se=te.type==="entity"||!cl.has(te.linkType),ue=te.filters.length>0;return[{key:"all",label:"All attributes",icon:j.jsx(R2,{}),disabled:!se,onClick:()=>s(te.id)},{key:"select",label:"Select attributes…",icon:j.jsx(BR,{}),disabled:!se,onClick:()=>{T(te)}},{key:"blank",label:"Blank attribute",icon:j.jsx(TR,{}),disabled:!se,onClick:()=>n(te.id)},{key:"order",label:"Order by",icon:j.jsx(D2,{}),disabled:!se,onClick:()=>o(te.id)},{key:"filter",label:"Filter",icon:j.jsx(Os,{}),disabled:ue,onClick:()=>i(te.id)},{key:"link",label:"Link-entity",icon:j.jsx(eh,{}),onClick:()=>a(te.id)}]},K=te=>[{key:"condition",label:"Condition",icon:j.jsx(Os,{}),onClick:()=>l(te.id)},{key:"subfilter",label:"Sub-filter",icon:j.jsx(Os,{}),onClick:()=>c(te.id)},{key:"link",label:"Link-entity (any/not any/all)",icon:j.jsx(eh,{}),onClick:()=>a(te.id)}],J=te=>te.map(se=>j.jsx(Gr,{icon:se.icon,disabled:se.disabled,onClick:se.onClick,children:se.label},se.key)),H=(te,se,ue,he)=>{t(ue.id),B.current=he,M({open:!0,addItems:ue.addItems,deleteTarget:ue.deleteTarget,target:{getBoundingClientRect:()=>({x:te,y:se,top:se,left:te,bottom:se,right:te,width:0,height:0,toJSON:()=>({})})}})},Z=te=>{const se=te.children?.filter(Boolean)??[],ue=se.length>0,he=!!te.addItems?.length||!!te.deleteTarget;return j.jsxs(Ui,{itemType:ue?"branch":"leaf",value:te.id,className:d.treeItemWithActions,onKeyDown:me=>{if(!(!he||me.target!==me.currentTarget)&&(me.key==="ContextMenu"||me.shiftKey&&me.key==="F10")){me.preventDefault();const Be=(me.currentTarget.querySelector(":scope > .fui-TreeItemLayout")??me.currentTarget).getBoundingClientRect();H(Be.left+24,Be.bottom,te,me.currentTarget)}},children:[j.jsxs(Wi,{iconBefore:te.icon,actions:te.addItems||te.deleteTarget?j.jsxs("div",{className:"actions",children:[te.addItems&&j.jsxs(_i,{children:[j.jsx(va,{disableButtonEnhancement:!0,children:j.jsx(St,{appearance:"subtle",size:"small",icon:j.jsx(rp,{}),title:"Add…","aria-label":"Add…"})}),j.jsx(Ti,{onClick:U,children:j.jsx(Ci,{children:J(te.addItems)})})]}),te.deleteTarget&&j.jsx(St,{appearance:"subtle",size:"small",icon:j.jsx(Lu,{}),onClick:me=>{me.stopPropagation(),O(te.deleteTarget)},title:"Delete","aria-label":"Delete"})]}):void 0,aside:m(te.id,te.badges),onClick:()=>t(te.id),onContextMenu:he?me=>{me.preventDefault(),me.stopPropagation(),H(me.clientX,me.clientY,te,me.currentTarget.closest('[role="treeitem"]'))}:void 0,children:[te.label,te.hint&&j.jsx("span",{className:d.hint,children:te.hint})]}),ue&&j.jsx(Hs,{children:se})]},te.id)},L=te=>Z({id:te.id,icon:j.jsx(A2,{}),label:"Fetch query",badges:ck(te.options.aggregate===!0&&{text:"Aggregate",color:"brand"},te.options.distinct&&{text:"Distinct"},te.options.dataSource==="retained"&&{text:"Retained"},(te.options.queryHints?.length??0)>0&&{text:"Hints"}),children:[Y(te.entity)]}),q=te=>[te.allAttributes?.enabled&&re(te.allAttributes),...te.attributes.map(se=>ie(se)),...te.orders.map(se=>ne(se)),...te.filters.map(se=>ae(se,te.name)),...te.links.map(se=>pe(se,te.name))],Y=te=>Z({id:te.id,icon:j.jsx(A2,{}),label:te.name,addItems:X(te),children:q(te)}),re=te=>Z({id:te.id,icon:j.jsx(R2,{}),label:"All attributes",deleteTarget:{id:te.id,title:"Delete all attributes?",descendants:0}}),ie=te=>{const se=[];return te.groupby&&se.push({text:te.dategrouping?`Group by · ${te.dategrouping}`:"Group by",color:"brand"}),te.aggregate&&se.push({text:Qie[te.aggregate]??te.aggregate,color:"brand"}),te.aggregate==="countcolumn"&&te.distinct&&se.push({text:"Unique"}),te.rowAggregate&&se.push({text:"Child count"}),Z({id:te.id,icon:j.jsx(lR,{}),label:te.alias?`${te.name} (as ${te.alias})`:te.name,badges:se,deleteTarget:{id:te.id,title:`Delete attribute ${te.name}?`,descendants:0}})},ne=te=>{const se=te.descending?"↓":"↑",ue=te.alias?`${te.alias} (alias)`:te.attribute??"",he=te.entityname?`${te.entityname}.${ue}`:ue;return Z({id:te.id,icon:j.jsx(D2,{}),label:`${he} ${se}`,deleteTarget:{id:te.id,title:`Delete order ${he}?`,descendants:0}})},ae=(te,se)=>Z({id:te.id,icon:j.jsx(Os,{}),label:`Filter (${te.conjunction})`,badges:ck(te.hint==="union"&&{text:"Union"},te.isQuickFindFields&&{text:"Quick find"}),addItems:K(te),deleteTarget:{id:te.id,title:`Delete filter (${te.conjunction})?`,descendants:Zl(te)},children:[...te.conditions.map(ue=>be(ue)),...te.subfilters.map(ue=>ae(ue,se)),...(te.links??[]).map(ue=>pe(ue,se))]}),be=te=>{const se=md(te.operator);let ue=`${te.attribute} ${te.operator}`;return se&&te.valueof?ue+=` → ${te.valueof}`:se&&te.value!==void 0&&te.value!==null&&te.value!==""&&(ue+=` = ${j7(te.value)}`),Z({id:te.id,icon:j.jsx(Os,{}),label:ue,deleteTarget:{id:te.id,title:`Delete condition ${te.attribute}?`,descendants:0}})},pe=(te,se)=>Z({id:te.id,icon:j.jsx(eh,{}),label:$ie(te,Yie(se)),hint:Hie(te)?"(no attributes)":void 0,addItems:X(te),deleteTarget:{id:te.id,title:`Delete link-entity ${te.alias||te.name}?`,descendants:Zl(te)},children:q(te)});return j.jsxs("div",{ref:F,className:d.container,children:[j.jsx(Hs,{"aria-label":"FetchXML Query Structure",openItems:V,onOpenChange:P,children:L(e)}),j.jsx(_i,{open:E.open,onOpenChange:(te,se)=>{if(M(ue=>({...ue,open:se.open})),!se.open){const ue=B.current;requestAnimationFrame(()=>{ue?.isConnected&&(!document.activeElement||document.activeElement===document.body)&&ue.focus()})}},positioning:{target:E.target,position:"below",align:"start"},children:j.jsx(Ti,{onClick:U,children:j.jsxs(Ci,{children:[E.addItems&&J(E.addItems),E.addItems&&E.deleteTarget&&j.jsx(Ku,{}),E.deleteTarget&&j.jsx(Gr,{className:d.danger,icon:j.jsx(Lu,{}),onClick:()=>E.deleteTarget&&O(E.deleteTarget),children:"Delete"})]})})}),j.jsx(Do,{open:k!==null,onOpenChange:(te,se)=>!se.open&&_(null),children:j.jsx(zi,{children:j.jsxs(Ai,{children:[j.jsx(Ri,{children:k?.title}),j.jsx(Ii,{children:k&&Vie(k.descendants)}),j.jsxs(Po,{children:[j.jsx(St,{appearance:"secondary",onClick:()=>_(null),children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:()=>{k&&u(k.id),_(null)},children:"Delete"})]})]})})}),j.jsx(Gie,{open:p,onOpenChange:g,entityDisplayName:w,nodeId:b||"",attributes:N,selectedAttributeNames:$,onApply:z})]})}const N7=A.createContext(null);function wd(){const e=A.useContext(N7);if(!e)throw new Error("useBuilder must be used within BuilderProvider");return e}function Jie(e,r,t,n){return t&&e.entityname?n.find(s=>s.alias===e.entityname)??n.find(s=>s.name===e.entityname)??r:r}function eae(e){const r={removed:[],converted:[],updates:[],removeNodeIds:[]},t=[],n=(i,c)=>{t.push({container:i,isRoot:c}),i.links.forEach(l=>n(l,!1))};n(e.entity,!0);const s=t.map(i=>i.container).filter(i=>i.type==="link-entity");for(const{container:i}of t)for(const c of i.attributes){const l=[c.groupby&&"Group by",c.aggregate&&`aggregate="${c.aggregate}"`,c.dategrouping&&`dategrouping="${c.dategrouping}"`,c.usertimezone!==void 0&&"time zone",c.distinct&&"unique values"].filter(a=>typeof a=="string");l.length!==0&&(r.removed.push({element:"attribute",message:`${c.name}${c.alias?` (${c.alias})`:""}: remove ${l.join(", ")}`}),r.updates.push({nodeId:c.id,updates:{groupby:void 0,aggregate:void 0,dategrouping:void 0,usertimezone:void 0,distinct:void 0}}))}const o=[];for(const{container:i,isRoot:c}of t)for(const l of i.orders){if(!l.alias)continue;const a=Jie(l,i,c,s).attributes.find(u=>u.alias===l.alias);a?.groupby?(r.converted.push({element:"order",message:`Sort by alias ${l.alias} → sort by attribute ${a.name}`}),r.updates.push({nodeId:l.id,updates:{alias:void 0,attribute:a.name}})):(o.push({element:"order",message:a?`Sort by ${l.alias} (it sorts by an aggregate value)`:`Sort by ${l.alias} (the alias isn't defined on that entity)`}),r.removeNodeIds.push(l.id))}return r.removed.push(...o),e.options.aggregateLimit!==void 0&&r.removed.push({element:"fetch",message:"Aggregate row limit (aggregatelimit)"}),r}function tae(e){return e.removed.length>0||e.converted.length>0}const rae=wr({content:{display:"flex",flexDirection:"column",gap:le.spacingVerticalM}});function nae({plan:e,onConfirm:r,onTurnOffOnly:t,onCancel:n}){const s=rae();return j.jsx(Do,{modalType:"alert",open:e!==null,onOpenChange:(o,i)=>!i.open&&n(),children:j.jsx(zi,{children:j.jsxs(Ai,{children:[j.jsx(Ri,{children:"Turn off aggregate query?"}),j.jsxs(Ii,{className:s.content,children:[j.jsx(_h,{children:"These settings only work in aggregate queries, and Dataverse rejects some of them in a normal query."}),e&&e.removed.length>0&&j.jsxs("div",{children:[j.jsx(Ch,{children:"Removed"}),j.jsx(rl,{items:e.removed})]}),e&&e.converted.length>0&&j.jsxs("div",{children:[j.jsx(Ch,{children:"Changed"}),j.jsx(rl,{items:e.converted})]})]}),j.jsx(Po,{position:"start",children:j.jsx(St,{appearance:"secondary",onClick:t,children:"Turn off only"})}),j.jsxs(Po,{position:"end",children:[j.jsx(St,{appearance:"secondary",onClick:n,children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:r,children:"Turn off and update"})]})]})})})}let uk=!1;const dk=[{name:"ForceOrder",sql:"FORCE ORDER"},{name:"DisableRowGoal",sql:"USE HINT DISABLE_OPTIMIZER_ROWGOAL"},{name:"EnableOptimizerHotfixes",sql:"USE HINT ENABLE_QUERY_OPTIMIZER_HOTFIXES"},{name:"LoopJoin",sql:"LOOP JOIN"},{name:"MergeJoin",sql:"MERGE JOIN"},{name:"HashJoin",sql:"HASH JOIN"},{name:"NO_PERFORMANCE_SPOOL",sql:"NO_PERFORMANCE_SPOOL"},{name:"ENABLE_HIST_AMENDMENT_FOR_ASC_KEYS",sql:"USE HINT ENABLE_HIST_AMENDMENT_FOR_ASC_KEYS"}];function oae({node:e,findings:r,onUpdate:t}){const n=Mi(),{options:s}=e,{retrieveAllRecords:o,setRetrieveAllRecords:i,updateNode:c,removeNode:l}=wd(),a=jp(e.entity.name),[u,h]=A.useState(!1),[d,f]=A.useState(null),[m,p]=A.useState(null);s.utcOffset!==void 0&&m!==e.id&&p(e.id);const g=s.utcOffset!==void 0||m===e.id,b=(T,z)=>{z.checked&&!uk&&(h(!0),uk=!0),i(z.checked)},y=T=>z=>t({[T]:z?!0:void 0}),w=T=>{if(T)return t({aggregate:!0});const z=eae(e);if(tae(z))return f(z);t({aggregate:void 0})},C=T=>{for(const{nodeId:z,updates:P}of T.updates)c(z,P);for(const z of T.removeNodeIds)l(z);t({aggregate:void 0,aggregateLimit:void 0}),f(null)},N=s.top!==void 0,I=s.count!==void 0||s.page!==void 0||s.returnTotalRecordCount===!0,$=Er(r,"top"),D="Not available with Maximum rows (top).",F="Not available with paging (page size, page number or total record count).",V=s.queryHints??[],G=new Set(dk.map(T=>T.name.toLowerCase())),U=V.filter(T=>!G.has(T.toLowerCase())),E=T=>V.some(z=>z.toLowerCase()===T.toLowerCase()),M=(T,z)=>{const P=z?[...V,T]:V.filter(O=>O.toLowerCase()!==T.toLowerCase());t({queryHints:P.length>0?P:void 0})},B=[s.latematerialize,V.length>0,s.noLock].filter(Boolean).length,k=a.metadata?.IsRetentionEnabled,_=iQ(s.dataSource,{logicalName:e.entity.name,isRetentionEnabled:k}),S=s.dataSource==="retained"?"Retained data (long-term retention)":s.dataSource==="bin"?"bin (undocumented)":s.dataSource??"Active data (default)";return j.jsxs("div",{className:n.container,children:[j.jsxs("div",{className:n.section,children:[j.jsx(Xn,{children:"Execution"}),j.jsxs(w8,{open:u,onOpenChange:(T,z)=>h(z.open),children:[j.jsx(Iv,{children:j.jsx(Qs,{checked:o,onChange:b,label:{children:(T,z)=>j.jsx(Av,{...z,info:"Fetches every page, one after another. Use with care on large entities.",children:"Retrieve all records"})}})}),j.jsxs(v8,{children:[j.jsxs(b8,{children:[j.jsx(y8,{children:"Retrieve all records"}),j.jsx("div",{children:"Fetches all pages progressively. Use with caution on large datasets."})]}),j.jsx(x8,{primary:{children:"Got it",onClick:()=>h(!1)}})]})]})]}),j.jsxs("div",{className:n.section,children:[j.jsx(Xn,{children:"Query"}),j.jsx(ei,{label:"Aggregate query",checked:s.aggregate===!0,onChange:w,validation:Er(r,"aggregate"),info:j.jsx(Qt,{text:"Groups records and calculates values (count, sum, average, minimum, maximum). Every attribute then needs Group by or an aggregate function, and an alias.",href:Kt.aggregate})}),j.jsx(ei,{label:"Distinct rows",checked:s.distinct===!0,onChange:y("distinct"),validation:Er(r,"distinct"),info:j.jsx(Qt,{text:"Leaves out duplicate rows from the results.",href:Kt.distinctResults})}),j.jsx(ei,{label:"Return total record count",checked:s.returnTotalRecordCount===!0,onChange:y("returnTotalRecordCount"),disabled:N&&!s.returnTotalRecordCount,hint:N&&!s.returnTotalRecordCount?D:void 0,validation:s.returnTotalRecordCount?$:void 0,info:j.jsx(Qt,{text:"Returns how many records match the query, up to 5,000 (500 for elastic entities), shown with the results. When more match, the count shows as 5,000+.",href:Kt.countRows})}),j.jsx(ei,{label:"Sort option sets by value",checked:s.useRawOrderBy===!0,onChange:y("useRawOrderBy"),info:j.jsx(Qt,{text:"Sorts option set (choice) attributes by their integer value instead of their label, for every option set attribute the query sorts by.",href:Kt.orderRows})})]}),j.jsxs("div",{className:n.section,children:[j.jsx(Xn,{children:"Paging and limits"}),j.jsx(Ka,{label:"Maximum rows (top)",value:s.top,min:1,max:5e3,rangeSeverity:"warning",placeholder:"No limit",disabled:I&&!N,hint:I&&!N?F:void 0,validation:is($,Er(r,"top")),onChange:T=>t({top:T}),info:j.jsx(Qt,{text:"Returns at most this many records (up to 5,000). Can't be combined with paging.",href:Kt.limitRows})}),j.jsx(Ka,{label:"Page size (count)",value:s.count,min:1,max:5e3,rangeSeverity:"warning",placeholder:"5,000",disabled:N&&s.count===void 0,hint:N&&s.count===void 0?D:void 0,validation:s.count!==void 0?is($,Er(r,"count")):void 0,onChange:T=>t({count:T}),info:j.jsx(Qt,{text:"Number of records per page (up to 5,000).",href:Kt.pageResults})}),j.jsx(Ka,{label:"Page number",value:s.page,min:1,placeholder:"1",disabled:N&&s.page===void 0,hint:N&&s.page===void 0?D:void 0,validation:s.page!==void 0?is($,Er(r,"page")):void 0,onChange:T=>t({page:T}),info:j.jsx(Qt,{text:"Which page to return, starting at 1.",href:Kt.pageResults})}),j.jsx(kr,{label:"Paging cookie",hint:"Copy it from the previous page's results.",info:j.jsx(Qt,{text:"Makes retrieving the next page more efficient. It must come from the page before the one requested.",href:Kt.pageResults}),children:j.jsx(_n,{className:n.mono,value:s.pagingCookie??"",placeholder:"<cookie … />",onChange:(T,z)=>t({pagingCookie:z.value||void 0})})})]}),(s.aggregate===!0||s.aggregateLimit!==void 0)&&j.jsxs("div",{className:n.section,children:[j.jsx(Xn,{children:"Aggregation"}),j.jsx(Ka,{label:"Aggregate row limit",value:s.aggregateLimit,min:1,max:5e4,placeholder:"50,000",hint:"Leave empty for the 50,000-row default.",validation:Er(r,"aggregatelimit"),onChange:T=>t({aggregateLimit:T}),info:j.jsx(Qt,{text:"Aggregates over at most this many records, below the 50,000-record default. When the limit is reached there's no error: the result covers at most limit + 1 arbitrary records.",href:Kt.aggregateLimit})})]}),j.jsx("div",{className:n.section,children:j.jsx(kr,{label:"Data source",validation:_?{state:"error",message:_}:Er(r,"datasource"),info:j.jsx(Qt,{text:"Retained data queries records moved to Dataverse long-term retention. The entity must have long-term retention enabled.",href:Kt.dataRetention}),children:j.jsxs(po,{value:S,selectedOptions:[s.dataSource??"active"],onOptionSelect:(T,z)=>t({dataSource:z.optionValue==="active"?void 0:z.optionValue}),children:[j.jsx(Jt,{value:"active",children:"Active data (default)"}),j.jsx(Jt,{value:"retained",text:"Retained data (long-term retention)",disabled:k===!1&&s.dataSource!=="retained",children:j.jsxs("span",{className:n.optionText,children:["Retained data (long-term retention)",k===!1&&j.jsxs("span",{className:n.optionSecondary,children:["Not enabled for ",e.entity.name]})]})}),s.dataSource==="bin"&&j.jsx(Jt,{value:"bin",children:"bin (undocumented)"})]})})}),j.jsx(Yh,{collapsible:!0,children:j.jsxs(qu,{value:"performance",children:[j.jsx($u,{children:j.jsxs("span",{className:n.accordionHeader,children:["Performance",B>0&&j.jsxs(ri,{appearance:"tint",size:"small",color:"informative",children:[B," set"]})]})}),j.jsx(Hu,{children:j.jsxs("div",{className:n.accordionPanel,children:[j.jsx(ei,{label:"Late materialize",checked:s.latematerialize===!0,onChange:y("latematerialize"),info:j.jsx(Qt,{text:"Breaks the query into smaller parts and reassembles the results. Can help queries with many joins or many lookup and calculated attributes; can make simple queries slower.",href:Kt.lateMaterialize})}),j.jsx(kr,{label:"Query hints (options)",info:j.jsx(Qt,{text:"SQL Server query hints, passed through the options attribute.",href:Kt.fetchOptions}),children:j.jsxs("div",{className:n.checkboxGroup,children:[j.jsx(Ar,{intent:"warning",layout:"multiline",children:j.jsx(Rr,{children:"Use query hints only when Microsoft support recommends them. Incorrect use can damage query performance."})}),dk.map(T=>j.jsx(ho,{checked:E(T.name),onChange:(z,P)=>M(T.name,P.checked===!0),label:j.jsxs("span",{className:n.optionText,children:[j.jsx("span",{className:n.mono,children:T.name}),j.jsx(kv,{className:n.secondary,children:T.sql})]})},T.name))]})}),U.length>0&&j.jsx(kr,{label:"Other hints (kept as written)",info:"Not documented option names. Dataverse accepts them, but Microsoft doesn't document what they do.",children:j.jsx(Nv,{onDismiss:(T,z)=>M(String(z.value),!1),"aria-label":"Other query hints",children:U.map(T=>j.jsx(pp,{value:T,dismissible:!0,dismissIcon:{"aria-label":`Remove ${T}`},appearance:"outline",children:T},T))})}),s.noLock&&j.jsx(ei,{label:"No lock (legacy)",checked:!0,onChange:y("noLock"),info:j.jsx(Qt,{text:"Legacy setting, no longer necessary: Dataverse doesn't need it to avoid shared locks. Shown because the query sets it.",href:Kt.noLock})})]})})]})}),g&&j.jsxs("div",{className:n.section,children:[j.jsx(Xn,{children:"Advanced"}),j.jsx(Ka,{label:"UTC offset (undocumented)",value:s.utcOffset,min:-720,max:720,rangeSeverity:"warning",placeholder:"Not set",onChange:T=>t({utcOffset:T}),info:j.jsx(Qt,{text:"Not in the fetch element reference; kept as written. Time zone offset in minutes for date and time filters, from −720 to 720. Clear it to remove it from the query.",href:Kt.fetch})})]}),j.jsx(nae,{plan:d,onConfirm:()=>d&&C(d),onTurnOffOnly:()=>{t({aggregate:void 0}),f(null)},onCancel:()=>f(null)})]})}function iae({node:e,onUpdate:r}){const t=Mi(),{metadata:n}=jp(e.name),s=n?.DisplayName?.UserLocalizedLabel?.Label,o=e.prefilterParameterName??"",i=!!e.enablePrefiltering||o!=="";return j.jsxs("div",{className:t.container,children:[j.jsx("div",{className:t.section,children:j.jsx(kr,{label:"Entity",hint:"Change it with the Entity picker above the tree.",info:j.jsx(Qt,{text:"The logical name of the entity the query is based on.",href:Kt.entity}),children:j.jsxs(st,{className:t.readOnly,children:[e.name,s&&j.jsxs("span",{className:t.secondary,children:[" (",s,")"]})]})})}),j.jsx(Yh,{collapsible:!0,defaultOpenItems:i?["prefilter"]:[],children:j.jsxs(qu,{value:"prefilter",children:[j.jsx($u,{children:j.jsxs("span",{className:t.accordionHeader,children:["Report prefiltering",i&&j.jsx(ri,{appearance:"tint",size:"small",color:"informative",children:"set"})]})}),j.jsx(Hu,{children:j.jsxs("div",{className:t.accordionPanel,children:[j.jsx(ei,{label:"Enable prefiltering",checked:!!e.enablePrefiltering,onChange:c=>r({enablePrefiltering:c?!0:void 0}),info:j.jsx(Qt,{text:"For SQL Server Reporting Services (Fetch-based) reports: lets people filter the report's records with Advanced Find before it runs. Dataverse ignores these attributes when the query runs here.",href:Kt.reportPrefiltering})}),(e.enablePrefiltering||o)&&j.jsx(kr,{label:"Parameter name",validation:o&&!o.startsWith("CRM_")?{state:"warning",message:"Start the name with CRM_ so the report hides the parameter."}:void 0,info:j.jsx(Qt,{text:"The report parameter that receives the prefilter.",href:Kt.reportPrefiltering}),children:j.jsx(_n,{className:t.mono,value:o,placeholder:"CRM_FilteredAccount",onChange:(c,l)=>r({prefilterParameterName:l.value||void 0})})})]})})]})})]})}function aae({isAggregateQuery:e,onRemove:r}){const t=Mi();return j.jsx("div",{className:t.container,children:j.jsxs("div",{className:t.section,children:[j.jsx(Xn,{children:"All attributes"}),j.jsx(_h,{children:"Returns every attribute that has a value, the same as listing no attributes at all."}),j.jsx(Ar,{intent:"info",layout:"multiline",children:j.jsx(Rr,{children:j.jsx(Qt,{text:"Microsoft doesn't recommend this for most queries: returning every attribute is slower. Select the attributes you need instead.",href:Kt.antiPatterns})})}),e&&j.jsx(Ar,{intent:"info",layout:"multiline",children:j.jsx(Rr,{children:"Ignored in an aggregate query: only the Group by and Aggregate attributes are returned."})}),j.jsx("div",{children:j.jsx(St,{onClick:r,children:"Remove all attributes"})})]})})}const u0={count:"Count records (count)",countcolumn:"Count values (countcolumn)",sum:"Sum (sum)",avg:"Average (avg)",min:"Minimum (min)",max:"Maximum (max)"},fk=[["day","Day"],["week","Week"],["month","Month"],["quarter","Quarter"],["year","Year"],["fiscal-period","Fiscal period"],["fiscal-year","Fiscal year"]],hk="__none";function sae({node:e,container:r,isRootEntity:t,isAggregateQuery:n,fetchQuery:s,findings:o,onUpdate:i}){const c=Mi(),{updateNode:l}=wd(),a=r.name,u=b7(a,e.name||void 0),h=u?Dv(u):void 0,d=jp(t?a:void 0),f=d.metadata?.PrimaryIdAttribute,[m,p]=A.useState(!1);A.useEffect(()=>p(!1),[e.id]);const g=e.alias?Z0(s,r,e.alias):[],b=S=>{const T=xp(S)||void 0;if(e.alias&&T)for(const z of Z0(s,r,e.alias))l(z.id,{alias:T});i({alias:T})},y=n||e.rowAggregate!==void 0,w=j.jsx(kr,{label:"Attribute",required:!0,info:j.jsx(Qt,{text:"The logical name of the attribute to return.",href:Kt.attribute}),children:j.jsx(pc,{entityLogicalName:a,value:e.name,onChange:S=>i({name:S}),placeholder:"Select an attribute"})}),C=j.jsx(kr,{label:"Alias",required:y,hint:g.length>0?`Sorting by this alias: renaming it also updates ${g.length===1?"that order":`those ${g.length} orders`}.`:void 0,validation:Er(o,"alias"),info:j.jsx(Qt,{text:"The name of the attribute in the results: letters, digits and underscores, starting with a letter or underscore. Unique across the query.",href:Kt.columnAliases}),children:j.jsx(_n,{value:e.alias??"",onChange:(S,T)=>b(T.value)})});if(!n){const S=!!e.name&&e.name===f,T=e.rowAggregate!==void 0||t&&S&&d.isHierarchical!==!1;let z=Er(o,"rowaggregate");!z&&e.rowAggregate!==void 0&&(d.isHierarchical===!1?z={state:"error",message:`${a} has no hierarchical relationship, so Dataverse rejects this (0x80047020).`}:f&&!S&&(z={state:"error",message:`Only works on the primary key (${f}); Dataverse rejects it on other attributes (0x80040203).`}));const P=[],O=X=>({state:"none",message:X});return e.groupby&&P.push({text:"Group by",field:"groupby",validation:Er(o,"groupby")??O("")}),e.aggregate&&P.push({text:`Aggregate: ${e.aggregate}`,field:"aggregate",validation:Er(o,"aggregate")??O("")}),e.dategrouping&&P.push({text:`Date grouping: ${e.dategrouping}`,field:"dategrouping",validation:O("Ignored outside aggregate queries.")}),e.usertimezone!==void 0&&P.push({text:"Time zone",field:"usertimezone",validation:O("Ignored outside aggregate queries.")}),e.distinct&&P.push({text:"Unique values only",field:"distinct",validation:O("Ignored outside aggregate queries.")}),j.jsxs("div",{className:c.container,children:[j.jsxs("div",{className:c.section,children:[j.jsx(Xn,{children:"Attribute"}),w,C]}),T&&j.jsxs("div",{className:c.section,children:[j.jsx(Xn,{children:"Hierarchy"}),j.jsx(ei,{label:"Count child records",checked:e.rowAggregate!==void 0,onChange:X=>i({rowAggregate:X?"CountChildren":void 0}),hint:e.rowAggregate!==void 0?"Returns the number of hierarchical child records in the alias attribute.":void 0,validation:z,info:j.jsx(Qt,{text:"Adds the number of child records under each record in a hierarchical relationship, such as parent accounts. The count includes records the user can't read. Only for entities with a hierarchical relationship.",href:Kt.rowAggregate})})]}),P.length>0&&j.jsxs("div",{className:c.section,children:[j.jsx(Xn,{children:"Aggregate settings"}),P.map(X=>j.jsx(_a,{text:X.text,validation:X.validation.message?X.validation:{state:"error",message:"The query isn't an aggregate query, so Dataverse rejects this."},onRemove:()=>i({[X.field]:void 0})},X.field))]})]})}const N=!!e.groupby&&!!e.aggregate,I=N?"":e.groupby?"groupby":e.aggregate||m?"aggregate":"",$=!h||h.groupby,D=tb.filter(S=>!h||h.functions.includes(S)),F=D.length>0,V=!!e.aggregate&&!!u&&!D.includes(e.aggregate),G=is(Er(o,void 0,"groupby"),e.groupby&&!$?{state:"error",message:h?.reason??"Dataverse can't group by this attribute."}:void 0,!I&&!N&&!$&&!F?{state:"error",message:`${h?.reason} Remove this attribute from the aggregate query.`}:void 0),U=e.aggregate?V?{state:"error",message:oQ(e.aggregate,u)}:Er(o,"aggregate"):{state:"error",message:"Choose an aggregate function."},E=h?.groupbyNeedsDateGrouping===!0,M=!u,B=I==="groupby"&&(E||M),k=I==="groupby"&&E&&!e.dategrouping?{state:"error",message:"Choose a date part. Dataverse can't group a DateTime attribute without one (0x80041135)."}:void 0,_=e.dategrouping!==void 0&&!B;return j.jsxs("div",{className:c.container,children:[j.jsxs("div",{className:c.section,children:[j.jsx(Xn,{children:"Attribute"}),w,C]}),j.jsxs("div",{className:c.section,children:[j.jsx(kr,{label:"Role",required:!0,validation:G,info:j.jsx(Qt,{text:"Group by makes a group per distinct value. Aggregate calculates a value for each group.",href:Kt.aggregate}),children:j.jsxs(ta,{layout:"horizontal",value:I,onChange:(S,T)=>{p(T.value==="aggregate"),T.value==="groupby"?i({groupby:!0,aggregate:void 0,distinct:void 0}):i({groupby:void 0,dategrouping:void 0,usertimezone:void 0})},children:[j.jsx(Yr,{value:"groupby",label:"Group by",disabled:!$&&!e.groupby}),j.jsx(Yr,{value:"aggregate",label:"Aggregate",disabled:!F&&!e.aggregate})]})}),I==="aggregate"&&j.jsxs(j.Fragment,{children:[j.jsx(kr,{label:"Function",required:!0,validation:U,hint:h&&D.length<tb.length?"Only functions this attribute type supports are listed.":void 0,info:j.jsx(Qt,{text:"Count records counts every record; Count values counts records where this attribute has a value.",href:Kt.aggregateFunctions}),children:j.jsxs(po,{placeholder:"Choose a function",value:e.aggregate?u0[e.aggregate]:"",selectedOptions:e.aggregate?[e.aggregate]:[],onOptionSelect:(S,T)=>i({aggregate:T.optionValue}),children:[V&&e.aggregate&&j.jsx(Jt,{value:e.aggregate,children:u0[e.aggregate]}),D.map(S=>j.jsx(Jt,{value:S,children:u0[S]},S))]})}),(e.aggregate==="countcolumn"||e.distinct)&&j.jsx(ei,{label:"Unique values only",checked:!!e.distinct,onChange:S=>i({distinct:S?!0:void 0}),validation:Er(o,"distinct"),info:j.jsx(Qt,{text:"With Count values, counts each distinct value once.",href:Kt.aggregateDistinct})})]}),B&&j.jsx(kr,{label:"Date grouping",required:E,validation:k,info:j.jsx(Qt,{text:"The part of the date to group by.",href:Kt.aggregateDateGrouping}),children:j.jsxs(po,{placeholder:"Choose a date part",value:fk.find(([S])=>S===e.dategrouping)?.[1]??"",selectedOptions:e.dategrouping?[e.dategrouping]:[],onOptionSelect:(S,T)=>i({dategrouping:T.optionValue===hk?void 0:T.optionValue}),children:[M&&j.jsx(Jt,{value:hk,children:"None"}),fk.map(([S,T])=>j.jsx(Jt,{value:S,children:T},S))]})}),_&&j.jsx(_a,{text:`Date grouping: ${e.dategrouping}`,validation:{state:"warning",message:"Ignored: date grouping only applies to Group by on DateTime attributes."},onRemove:()=>i({dategrouping:void 0})}),(B||e.usertimezone!==void 0)&&j.jsx(kr,{label:"Time zone",info:j.jsx(Qt,{text:"The same date can fall on different days in different time zones. By default Dataverse groups using the user's time zone; choose UTC to group on the stored UTC value.",href:Kt.attribute}),children:j.jsxs(ta,{value:e.usertimezone===!1?"utc":"user",onChange:(S,T)=>i({usertimezone:T.value==="utc"?!1:e.usertimezone===!0?!0:void 0}),children:[j.jsx(Yr,{value:"user",label:"User's time zone (default)"}),j.jsx(Yr,{value:"utc",label:"UTC"})]})}),e.rowAggregate!==void 0&&j.jsx(_a,{text:"Count child records",validation:Er(o,"rowaggregate")??{state:"error",message:"Doesn't work in an aggregate query."},onRemove:()=>i({rowAggregate:void 0})})]})]})}const lae=["String","Memo","Integer","BigInt","Decimal","Double","Money","DateTime","Boolean","Picklist","State","Status","Lookup","Customer","Owner","Uniqueidentifier","EntityName"],d0="__root",E7=e=>e.links.flatMap(r=>[r,...E7(r)]),cae=e=>e.groupby?`Group by${e.dategrouping?` · ${e.dategrouping}`:""}`:e.aggregate?{count:"Count records",countcolumn:"Count values",sum:"Sum",avg:"Average",min:"Minimum",max:"Maximum"}[e.aggregate]:"";function uae({node:e,container:r,isRootEntity:t,fetchQuery:n,findings:s,fetchFindings:o,onUpdate:i}){const c=Mi(),l=n.options.aggregate===!0,a=E7(n.entity),u=a.reduce((N,I)=>({...N,[I.name]:(N[I.name]??0)+1}),{}),h=a.map(N=>({link:N,key:N.alias??(u[N.name]===1?N.name:void 0)})).filter(N=>!!N.key),d=e.entityname?h.find(N=>N.key===e.entityname)?.link??a.find(N=>N.name===e.entityname):void 0,f=t?d??r:r,m=f.type==="entity"?`the root entity (${f.name})`:`${f.alias??f.name} (${f.name})`,p=f.attributes.filter(N=>N.alias&&(N.groupby||N.aggregate)),g=!!e.alias&&p.some(N=>N.alias===e.alias),b=b7(f.name,l?void 0:e.attribute),y=M8(b),w=Er(o,"aggregatelimit"),C=e.entityname?d?`${d.alias??d.name} (${d.name})`:e.entityname:`Root: ${n.entity.name}`;return j.jsx("div",{className:c.container,children:j.jsxs("div",{className:c.section,children:[j.jsx(Xn,{children:"Sort"}),t&&h.length>0&&j.jsx(kr,{label:"Entity",validation:Er(s,"entityname"),info:j.jsx(Qt,{text:"Choose a link-entity to apply its sort before the root entity's sorts. Otherwise link-entity sorts are applied last.",href:Kt.linkOrdersFirst}),children:j.jsxs(po,{value:C,selectedOptions:[e.entityname??d0],onOptionSelect:(N,I)=>i({entityname:I.optionValue===d0?void 0:I.optionValue,attribute:void 0,alias:void 0}),children:[j.jsx(Jt,{value:d0,children:`Root: ${n.entity.name}`}),h.map(({link:N,key:I})=>j.jsx(Jt,{value:I,children:`${N.alias??N.name} (${N.name})`},N.id))]})}),l?j.jsx(kr,{label:"Sort by",required:!0,validation:is(e.alias?void 0:{state:"error",message:p.length===0?`Add an alias to a Group by or Aggregate attribute of ${m} first.`:"Choose an alias to sort by."},Er(s,"alias"),w),info:j.jsx(Qt,{text:"Aggregate queries sort by an attribute alias. Only aliases of Group by or Aggregate attributes of the chosen entity are listed.",href:Kt.order}),children:j.jsxs(po,{placeholder:"Choose an alias",value:e.alias??"",selectedOptions:e.alias?[e.alias]:[],onOptionSelect:(N,I)=>i({alias:I.optionValue,attribute:void 0}),children:[e.alias&&!g&&j.jsx(Jt,{value:e.alias,text:e.alias,children:j.jsxs("span",{className:c.optionText,children:[e.alias,j.jsx("span",{className:c.optionSecondary,children:"Not defined on this entity"})]})}),p.map(N=>j.jsx(Jt,{value:N.alias,text:N.alias,children:j.jsxs("span",{className:c.optionText,children:[N.alias,j.jsxs("span",{className:c.optionSecondary,children:[N.name," · ",cae(N)]})]})},N.id))]})}):j.jsx(kr,{label:"Attribute",required:!0,validation:is(!e.attribute&&!e.alias?{state:"error",message:"Choose an attribute to sort by."}:void 0,y?{state:"error",message:y}:void 0,Er(s,"attribute")),info:j.jsx(Qt,{text:"The logical name of the attribute to sort by. It doesn't need to be a selected attribute.",href:Kt.orderRows}),children:j.jsx(pc,{entityLogicalName:f.name,filterByTypes:lae,value:e.attribute??"",onChange:N=>i({attribute:N||void 0}),placeholder:"Select an attribute"})}),!l&&e.alias&&j.jsx(_a,{text:`Alias: ${e.alias}`,validation:Er(s,"alias")??{state:"error",message:"Only aggregate queries sort by alias."},onRemove:()=>i({alias:void 0})}),l&&e.attribute&&j.jsx(_a,{text:`Attribute: ${e.attribute}`,validation:Er(s,"attribute")??{state:"error",message:"Aggregate queries sort by alias."},onRemove:()=>i({attribute:void 0})}),!t&&e.entityname&&j.jsx(_a,{text:`Entity: ${e.entityname}`,validation:Er(s,"entityname")??{state:"error",message:"Not allowed on an order inside a link-entity."},onRemove:()=>i({entityname:void 0})}),j.jsx(kr,{label:"Direction",info:j.jsx(Qt,{text:"Option set attributes sort by label unless 'Sort option sets by value' is on for the query. Lookups sort by the related record's primary name.",href:Kt.orderRows}),children:j.jsxs(ta,{value:e.descending?"desc":"asc",onChange:(N,I)=>i({descending:I.value==="desc"?!0:void 0}),children:[j.jsx(Yr,{value:"asc",label:"Ascending"}),j.jsx(Yr,{value:"desc",label:"Descending"})]})})]})})}function dae({node:e,unionElsewhere:r,findings:t,onUpdate:n}){const s=Mi(),o=e.conjunction==="or",i=!!e.isQuickFindFields||!!e.overrideQuickFindRecordLimitEnabled||!!e.overrideQuickFindRecordLimitDisabled,c=e.overrideQuickFindRecordLimitEnabled&&e.overrideQuickFindRecordLimitDisabled?"":e.overrideQuickFindRecordLimitEnabled?"apply":e.overrideQuickFindRecordLimitDisabled?"bypass":"default",l=!e.hint&&r;return j.jsxs("div",{className:s.container,children:[j.jsxs("div",{className:s.section,children:[j.jsx(Xn,{children:"Filter"}),j.jsx(kr,{label:"Match",info:j.jsx(Qt,{text:"Whether all conditions (and) or any condition (or) must be true.",href:Kt.filter}),children:j.jsxs(po,{value:o?"Any condition (or)":"All conditions (and)",selectedOptions:[e.conjunction],onOptionSelect:(a,u)=>n({conjunction:u.optionValue}),children:[j.jsx(Jt,{value:"and",children:"All conditions (and)"}),j.jsx(Jt,{value:"or",children:"Any condition (or)"})]})}),(o||e.hint)&&j.jsx(ei,{label:"Union hint",checked:!!e.hint,disabled:l,onChange:a=>n({hint:a?"union":void 0}),hint:l?"Only one filter per query can use the union hint, and another filter has it.":void 0,validation:Er(t,"hint"),info:j.jsx(Qt,{text:"Can improve performance for an 'any condition' filter whose conditions are on attributes of different entities. One per query.",href:Kt.unionHint})})]}),(o||i)&&j.jsxs("div",{className:s.section,children:[j.jsx(Xn,{children:"Quick find"}),j.jsx(ei,{label:"Quick find filter",checked:!!e.isQuickFindFields,onChange:a=>n({isQuickFindFields:a?!0:void 0}),info:j.jsx(Qt,{text:"Runs this filter as a quick find search, the pattern behind the search box in views. Dataverse applies the quick find record limit to it.",href:Kt.quickFind})}),i&&j.jsx(kr,{label:"Record limit",validation:Er(t,"overridequickfindrecordlimitenabled"),info:j.jsx(Qt,{text:"When the 'Quick Find record limits' environment setting is on (the default, and recommended), a quick find matching more than 10,000 records fails with QuickFindQueryRecordLimitExceeded. The count is taken before security filters. The overrides are for temporary testing.",href:Kt.quickFindLimits}),children:j.jsxs(ta,{value:c,onChange:(a,u)=>n({overrideQuickFindRecordLimitEnabled:u.value==="apply"?!0:void 0,overrideQuickFindRecordLimitDisabled:u.value==="bypass"?!0:void 0}),children:[j.jsx(Yr,{value:"default",label:"Use the environment setting (default)"}),j.jsx(Yr,{value:"apply",label:"Always apply the 10,000-record limit (testing)"}),j.jsx(Yr,{value:"bypass",label:"Bypass the limit (testing)"})]})})]})]})}const fae=["Many-to-one (N:1)","One-to-many (1:N)","Many-to-many (N:N)"],hae={N1:"Many-to-one (N:1)","1N":"One-to-many (1:N)",NN:"Many-to-many (N:N)"},pk=(e,r)=>r&&r!==e?`${r} (${e})`:e;function f0(e,r,t,n,s){const o=s.entity(t),i=n.logical?`via ${pk(n.logical,n.display)} · ${e.SchemaName}`:e.SchemaName;return{id:vi(e),schemaName:e.SchemaName,displayText:n.logical?`${o||t} via ${n.display||n.logical}`:o||t,primaryText:pk(t,o),secondaryText:i,searchText:[o,t,n.display,n.logical,e.SchemaName].filter(Boolean).join(" "),type:r,category:hae[r]}}function pae(e,r,t){const n=[],s=o=>({referencedEntity:o.ReferencedEntity,referencingEntity:o.ReferencingEntity,referencedAttribute:o.ReferencedAttribute,referencingAttribute:o.ReferencingAttribute});for(const o of r.manyToOne){const i=o.ReferencingAttribute||"";n.push({...f0(o,"N1",o.ReferencedEntity,{logical:i,display:i?t.attribute(o.ReferencingEntity,i):void 0},t),...s(o)})}for(const o of r.oneToMany){const i=o.ReferencingAttribute||"";n.push({...f0(o,"1N",o.ReferencingEntity,{logical:i,display:i?t.attribute(o.ReferencingEntity,i):void 0},t),...s(o)})}for(const o of r.manyToMany){const i=o.Entity1LogicalName||"",c=o.Entity2LogicalName||"",l=i===e?c:i,a=o.IntersectEntityName||"";n.push({...f0(o,"NN",l,{logical:a,display:a?t.entity(a):void 0},t),referencedEntity:c,referencingEntity:i,referencedAttribute:o.Entity2IntersectAttribute||"",referencingAttribute:o.Entity1IntersectAttribute||"",intersectEntity:o.IntersectEntityName})}return n}function mae(e,r){const t=r.trim().toLowerCase();return t?e.filter(n=>n.searchText.toLowerCase().includes(t)):e}const gae=wr({option:{display:"flex",flexDirection:"column",minWidth:0},optionSecondary:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200}}),bae={style:{minWidth:420}},mk=e=>e?.DisplayName?.UserLocalizedLabel?.Label||void 0;function vae({entityLogicalName:e,value:r,onChange:t,placeholder:n="Select a relationship…",disabled:s=!1}){const o=gae(),i=mr("relationship-combobox"),[c,l]=A.useState([]),[a,u]=A.useState(!1),[h,d]=A.useState(null),[f,m]=A.useState(""),[p,g]=A.useState(null),b=Sp();A.useEffect(()=>{if(!e){Ie("relationshipPicker","No entity name provided, clearing relationships"),l([]);return}Ie("relationshipPicker","Loading relationships for entity:",e);let I=!0;return u(!0),d(null),Promise.all([m_(e,b),p_().catch(()=>[]),jc(e).catch(()=>[])]).then(([$,D,F])=>{if(!I)return;Ie("relationshipPicker","Received relationship data:",{entityLogicalName:e,oneToManyCount:$.oneToMany.length,manyToOneCount:$.manyToOne.length,manyToManyCount:$.manyToMany.length});const V=new Map(D.map(E=>[E.LogicalName,E])),G=E=>E===e?F:Zt.getEntityAttributes(`${E}__all`)??[],U=pae(e,$,{entity:E=>mk(V.get(E)??Zt.getEntityMetadata(E)),attribute:(E,M)=>mk(G(E).find(B=>B.LogicalName===M))});l(U),u(!1),Ie("relationshipPicker","Relationships loaded successfully:",{entityLogicalName:e,totalRelationships:U.length})}).catch($=>{I&&(console.error("[RelationshipPicker] Failed to load relationships:",{entityLogicalName:e,error:$}),d("Failed to load relationships"),u(!1))}),()=>{I=!1}},[e,b]),A.useEffect(()=>{if(r){const I=c.find($=>$.schemaName===r);g(I?.id??null),m(I?I.displayText:r)}else g(null),m("")},[r,c]);const y=c.find(I=>I.id===p),w=y&&f===y.displayText?"":f,C=A.useMemo(()=>mae(c,w),[c,w]),N=(I,$)=>{const D=$.optionValue;if(Ie("relationshipPicker","Relationship selected:",{id:D}),D){const F=c.find(V=>V.id===D);F&&(Ie("relationshipPicker","Found relationship details:",F),g(F.id),m(F.displayText),t(F))}else g(null),m("")};return a?j.jsx(hn,{size:"tiny",label:"Loading relationships…"}):h?j.jsx(Zn,{"aria-labelledby":i,value:"",placeholder:"Error loading relationships",disabled:!0}):j.jsx(Zn,{"aria-labelledby":i,listbox:bae,value:f,selectedOptions:p?[p]:[],onOptionSelect:N,onChange:I=>m(I.target.value),placeholder:c.length===0?"No relationships found":n,disabled:s||c.length===0,clearable:!0,children:C.length===0&&w.trim()?j.jsx(Jt,{disabled:!0,children:`No relationships match "${w.trim()}"`}):fae.map(I=>{const $=C.filter(D=>D.category===I);return $.length>0&&j.jsx(ja,{label:I,children:$.map(D=>j.jsx(Jt,{value:D.id,text:D.searchText,children:j.jsxs("span",{className:o.option,children:[j.jsx("span",{children:D.primaryText}),j.jsx("span",{className:o.optionSecondary,children:D.secondaryText})]})},D.id))},I)})})}const Ds={inner:{label:"Inner",description:"Default. Only records with a matching related record."},outer:{label:"Outer",description:"Also records without a matching related record."},exists:{label:"Exists",description:"Like inner, using EXISTS: each record once, no related attributes."},in:{label:"In",description:"Like inner, using IN: each record once, no related attributes."},matchfirstrowusingcrossapply:{label:"Match first row",description:"Like inner, matching only one related record: each record once."},any:{label:"Any",description:"Records with at least one related record matching this link-entity's filter."},"not any":{label:"Not any",description:"Records with no related record matching this link-entity's filter."},all:{label:"All",description:"Records with related records, none of which match the filter. Invert the filter to require every related record to match."},"not all":{label:"Not all",description:"The same as Any, despite the name."},natural:{label:"Natural",description:"Not in the FetchXML reference; Dataverse accepts it."}},gk=["inner","outer","exists","in","matchfirstrowusingcrossapply"],Wf=["any","not any","all","not all"];function yae({node:e,parentEntityName:r,inFilter:t,findings:n,onUpdate:s}){const o=Mi(),{addLinkEntityWithConfig:i,fetchQuery:c}=wd(),[l,a]=A.useState(null),[u,h]=A.useState(null),d=e.name==="new_entity"||!e.name&&!e.from&&!e.to,[f,m]=A.useState(d);A.useEffect(()=>m(d),[e.id,d]);const p=[e.attributes.length>0&&`${e.attributes.length} attribute${e.attributes.length===1?"":"s"}`,e.allAttributes?.enabled&&"all attributes",e.orders.length>0&&`${e.orders.length} sort${e.orders.length===1?"":"s"}`].filter(D=>!!D),g=e.attributes.length+(e.allAttributes?.enabled?1:0)+e.orders.length,b=D=>{cl.has(D)&&p.length>0?a(D):s({linkType:D})},y=D=>{l&&s(D?{linkType:l,attributes:[],allAttributes:void 0,orders:[]}:{linkType:l}),a(null)},w=async D=>{h(null);try{if(!D.intersectEntity)throw new Error("the relationship has no intersect entity.");const F=D.referencingEntity===r?D.referencedEntity:D.referencingEntity,[V,G]=await Promise.all([hc(r),hc(F)]),U=yJ(r,V.PrimaryIdAttribute,{Entity1LogicalName:D.referencingEntity,Entity2LogicalName:D.referencedEntity,Entity1IntersectAttribute:D.referencingAttribute,Entity2IntersectAttribute:D.referencedAttribute,IntersectEntityName:D.intersectEntity},()=>G.PrimaryIdAttribute);if(!U)throw new Error(`${r} isn't part of ${D.schemaName}.`);s({name:U.intersect.name,from:U.intersect.from,to:U.intersect.to,intersect:!0,alias:void 0,relationshipType:"NN"}),i(e.id,U.target.name,U.target.from,U.target.to,"inner","NN"),m(!1)}catch(F){h(`Couldn't build the many-to-many join: ${F instanceof Error?F.message:String(F)}`)}},C=D=>{if(D.type==="NN"){w(D);return}Ie("linkEntityEditor","Relationship selected:",{nodeId:e.id,parentEntityName:r,relationship:D});const F={name:"",from:"",to:"",relationshipType:D.type};if(D.type==="1N"?D.referencedEntity===r?(F.name=D.referencingEntity,F.from=D.referencingAttribute,F.to=D.referencedAttribute):(F.name=D.referencedEntity,F.from=D.referencedAttribute,F.to=D.referencingAttribute):D.type==="N1"&&(D.referencingEntity===r?(F.name=D.referencedEntity,F.from=D.referencedAttribute,F.to=D.referencingAttribute):(F.name=D.referencingEntity,F.from=D.referencingAttribute,F.to=D.referencedAttribute)),e.alias?.startsWith("new_entity")&&typeof F.name=="string"&&F.name&&c){const V=J0(c);V.delete(e.alias),F.alias=eb(F.name,V)}s(F),m(!1)},N=t?Wf:[...gk,...Wf],I=(D,F=Ds[D]?.description)=>j.jsx(Jt,{value:D,text:Ds[D]?.label??D,children:j.jsxs("span",{className:o.optionText,children:[Ds[D]?.label??D,j.jsx("span",{className:o.optionSecondary,children:F})]})},D),$=!e.from&&!e.to?{state:"warning",message:"Neither attribute is set: Dataverse uses the system many-to-many relationship between the entities, and fails (0x80041102) if there isn't one."}:!e.from||!e.to?{state:"warning",message:"Set both attributes. With only one, Dataverse tries to work out the other from the relationship definitions."}:void 0;return j.jsxs("div",{className:o.container,children:[f&&r&&j.jsxs("div",{className:o.section,children:[j.jsx(Xn,{children:"Relationship"}),j.jsx(kr,{label:"Relationship",hint:"Fills in the entity and the attributes to match. A many-to-many relationship adds its intersect entity with the related entity inside it. Or set them below.",validation:u?{state:"error",message:u}:void 0,info:j.jsx(Qt,{text:`The relationships of ${r}.`,href:Kt.joinTables}),children:j.jsx(vae,{entityLogicalName:r,onChange:C,placeholder:"Select a relationship…"})})]}),j.jsxs("div",{className:o.section,children:[j.jsx(Xn,{children:"Link-entity"}),j.jsx(kr,{label:"Entity",required:!0,validation:e.name?void 0:{state:"error",message:"Enter the logical name of the related entity."},info:j.jsx(Qt,{text:"The logical name of the related entity.",href:Kt.linkEntity}),children:j.jsx(_n,{className:o.mono,value:e.name,onChange:(D,F)=>s({name:F.value}),placeholder:"e.g. contact"})}),j.jsx(kr,{label:"From attribute",validation:$,info:j.jsx(Qt,{text:`The ${e.name||"related entity"} attribute that matches the To attribute. Not technically required, but usually set. Both attributes should have the same type.`,href:Kt.linkEntityFromTo}),children:j.jsx(pc,{entityLogicalName:e.name,value:e.from??"",onChange:D=>s({from:D||void 0}),placeholder:"Select an attribute",disabled:!e.name})}),j.jsx(kr,{label:"To attribute",info:j.jsx(Qt,{text:`The ${r||"parent"} attribute that matches the From attribute. Not technically required, but usually set.`,href:Kt.linkEntityFromTo}),children:j.jsx(pc,{entityLogicalName:r,value:e.to??"",onChange:D=>s({to:D||void 0}),placeholder:"Select an attribute",disabled:!r})}),j.jsx(kr,{label:"Link type",validation:Er(n,"link-type"),hint:t?"Inside a filter, a link-entity checks related records and returns nothing.":void 0,info:j.jsx(Qt,{text:Ds[e.linkType]?.description??"How the related records are matched.",href:Kt.linkEntity}),children:j.jsxs(po,{value:Ds[e.linkType]?.label??e.linkType,selectedOptions:[e.linkType],onOptionSelect:(D,F)=>F.optionValue&&b(F.optionValue),children:[!N.includes(e.linkType)&&I(e.linkType,t?"Not allowed inside a filter":void 0),t?Wf.map(D=>I(D)):j.jsxs(j.Fragment,{children:[j.jsx(ja,{label:"Join",children:gk.map(D=>I(D))}),j.jsx(ja,{label:"Filter on related records",children:Wf.map(D=>I(D))})]})]})}),j.jsx(kr,{label:"Alias",validation:Er(n,"alias"),info:j.jsx(Qt,{text:"The name to use for this link-entity in conditions (entity, compare to) and sorts. Without one, Dataverse generates a name ({name}{N}) that the query can't reference. Letters, digits and underscores; starts with a letter or underscore.",href:Kt.linkEntity}),children:j.jsx(_n,{className:o.mono,value:e.alias??"",onChange:(D,F)=>s({alias:xp(F.value)||void 0}),placeholder:"e.g. parent_account"})}),j.jsx(ei,{label:"Intersect",checked:!!e.intersect,onChange:D=>s({intersect:D?!0:void 0}),info:j.jsx(Qt,{text:"Shows that this link-entity only joins (typically the intersect entity of a many-to-many relationship) and returns no attributes on purpose. It doesn't change how the query runs.",href:Kt.linkEntity})}),e.visible!==void 0&&j.jsx(_a,{text:`Visible: ${e.visible}`,validation:{state:"none",message:Er(n,"visible")?.message??"Dataverse ignores visible."},onRemove:()=>s({visible:void 0})})]}),j.jsx(Do,{modalType:"alert",open:l!==null,onOpenChange:(D,F)=>!F.open&&a(null),children:j.jsx(zi,{children:j.jsxs(Ai,{children:[j.jsxs(Ri,{children:["Change the link type to ",l?Ds[l].label:"","?"]}),j.jsxs(Ii,{children:["The ",l?Ds[l].label:""," link type returns no attributes, so Dataverse rejects this link-entity's ",p.join(" and "),". Remove ",g===1?"it":"them"," ","now? Its filters and nested link-entities are kept."]}),j.jsx(Po,{position:"start",children:j.jsx(St,{onClick:()=>y(!1),children:"Change only"})}),j.jsxs(Po,{position:"end",children:[j.jsx(St,{onClick:()=>a(null),children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:()=>y(!0),children:"Change and remove"})]})]})})})]})}const wae=wr({container:{overflow:"auto",height:"100%",minHeight:0,scrollbarGutter:"stable"},emptyState:{padding:le.spacingHorizontalL,color:le.colorNeutralForeground3,fontSize:le.fontSizeBase300,fontStyle:"italic"}});function xae({selectedNode:e,fetchQuery:r,onNodeUpdate:t}){const n=wae(),{removeNode:s}=wd(),o=A.useMemo(()=>r?Fv(r):[],[r]);if(!e||!r)return j.jsx("div",{className:n.container,children:j.jsx("div",{className:n.emptyState,children:"Select a node in the tree to view its properties."})});const i=o.filter(d=>d.nodeId===e.id),c=r.options.aggregate===!0,l=d=>t(e.id,d),a=ZY(r,e.id),u=j.jsx("div",{className:n.emptyState,children:"This node is no longer in the query."}),h=()=>{switch(e.type){case"fetch":return j.jsx(oae,{node:e,findings:i,onUpdate:l});case"entity":return j.jsx(iae,{node:e,onUpdate:l});case"all-attributes":return j.jsx(aae,{isAggregateQuery:c,onRemove:()=>s(e.id)});case"attribute":return a?j.jsx(sae,{node:e,container:a.container,isRootEntity:a.isRoot,isAggregateQuery:c,fetchQuery:r,findings:i,onUpdate:l}):u;case"order":return a?j.jsx(uae,{node:e,container:a.container,isRootEntity:a.isRoot,fetchQuery:r,findings:i,fetchFindings:o.filter(d=>d.nodeId===r.id),onUpdate:l}):u;case"filter":return j.jsx(dae,{node:e,unionElsewhere:t5(r).some(d=>d.id!==e.id&&d.hint==="union"),findings:i,onUpdate:l});case"condition":return j.jsx(v7,{node:e,entityName:a?.container.name??e5(r,e.id)??"",fetchQuery:r,findings:i,onUpdate:l});case"link-entity":return j.jsx(yae,{node:e,parentEntityName:e5(r,e.id)??r.entity.name,inFilter:t5(r).some(d=>d.links?.some(f=>f.id===e.id)),findings:i,onUpdate:l});default:return j.jsx("div",{className:n.emptyState,children:"Unknown node type."})}};return j.jsx("div",{className:n.container,children:h()},e.id)}const lh={String:200,Memo:250,Integer:100,BigInt:120,Decimal:120,Double:120,Money:130,DateTime:150,Lookup:180,Customer:180,Owner:180,Picklist:150,State:100,Status:120,MultiSelectPicklist:200,Boolean:80,Uniqueidentifier:280,Image:60,File:150,default:150};function kae(e){return e?lh[e]??lh.default:lh.default}function Sae(e){const t=new DOMParser().parseFromString(e,"text/xml"),n=t.querySelector("parsererror");if(n)throw new Error(`Invalid LayoutXML: ${n.textContent}`);const s=t.querySelector("grid");if(!s)throw new Error("Invalid LayoutXML: missing <grid> element");const o=t.querySelector("row"),i=t.querySelectorAll("cell"),c=[];return i.forEach(l=>{const a=l.getAttribute("name"),u=l.getAttribute("width"),h=l.getAttribute("disableSorting"),d=l.getAttribute("imageproviderwebresource"),f=l.getAttribute("imageproviderfunctionname");a&&c.push({name:a,width:u?parseInt(u,10):lh.default,disableSorting:h==="1",imageProviderName:d||void 0,imageProviderFunctionName:f||void 0})}),{gridName:s.getAttribute("name")||"resultset",objectTypeCode:s.getAttribute("object")?parseInt(s.getAttribute("object"),10):void 0,jumpAttribute:s.getAttribute("jump")||void 0,enableSelection:s.getAttribute("select")==="1",showIcon:s.getAttribute("icon")==="1",enablePreview:s.getAttribute("preview")==="1",primaryIdAttribute:o?.getAttribute("id")||void 0,columns:c}}function _ae(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Cae(e){const r=(o,i)=>`${o}="${_ae(String(i))}"`,t=e.columns.map(o=>{const i=[r("name",o.name),r("width",o.width)];return o.disableSorting&&i.push('disableSorting="1"'),o.imageProviderName&&i.push(r("imageproviderwebresource",o.imageProviderName)),o.imageProviderFunctionName&&i.push(r("imageproviderfunctionname",o.imageProviderFunctionName)),` <cell ${i.join(" ")} />`}).join(`
|
|
73
|
+
`,f.startsWith("<")&&!f.startsWith("</")&&!f.startsWith("<?")&&!f.endsWith("/>")&&!f.includes("</")&&u++)}return a.trim()}catch{return l}})(e),i=A.useCallback(l=>{n.current=l},[]),c=A.useCallback(async()=>{await ws(o)||console.error("Failed to copy to clipboard")},[o]);return j.jsxs("div",{className:r.container,children:[j.jsxs("div",{className:r.toolbar,children:[j.jsx("div",{className:r.toolbarLeft,children:j.jsx("span",{className:r.label,children:"LayoutXML (Read-only)"})}),j.jsx(Bc,{size:"small",children:j.jsx(Wn,{icon:j.jsx(E0,{}),onClick:c,disabled:!e,"aria-label":"Copy LayoutXML",children:"Copy"})})]}),j.jsx("div",{className:r.editorWrapper,children:j.jsx(Jv,{height:"100%",language:"xml",theme:t?"vs-dark":"vs",value:o,options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",fontSize:13,tabSize:2,automaticLayout:!0,folding:!0,renderLineHighlight:"line",scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:10,horizontalScrollbarSize:10}},onMount:i,loading:j.jsx("div",{className:r.loadingContainer,children:j.jsx(hn,{size:"medium",label:"Loading editor…"})})})})]})}const Ate=e=>(RS({...e,renderRow:()=>null}),e),I_=A.createContext(void 0),Rte=void 0,zte=()=>{var e;return(e=A.useContext(I_))!=null?e:Rte},Ite=I_.Provider,M_=A.createContext({current:null}),Mte={current:null},D_=()=>{var e;return(e=A.useContext(M_))!=null?e:Mte},Dte=M_.Provider,P_=A.createContext({current:null}),Pte={current:null},O_=()=>{var e;return(e=A.useContext(P_))!=null?e:Pte},Ote=P_.Provider,Fte=(e,r)=>{const{height:t,itemSize:n,width:s="100%",ariaRowIndexStart:o=2,children:i,listProps:c}=e,l=D_(),a=O_(),h=AS({...e,children:i},r),d=A.useCallback(({data:p,index:g,style:b,isScrolling:y})=>{const w=p[g];return A.createElement(Ite,{value:o+g},A.createElement(CS,{value:w.rowId},i(w,b,g,y)))},[o,i]),f=A.useCallback(()=>{l.current&&a.current&&a.current.scroll({left:l.current.scrollLeft,behavior:"instant"})},[]),m=A.useCallback(p=>{var g;(g=l.current)==null||g.removeEventListener("scroll",f),l.current=p,p&&p.addEventListener("scroll",f)},[]);return{...h,itemSize:n,height:t,virtualizedRow:d,width:s,ariaRowIndexStart:o,listProps:c,outerRef:m}};function db(){return db=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},db.apply(null,arguments)}function N5(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function fb(e,r){return fb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},fb(e,r)}function qte(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,fb(e,r)}var E5=Number.isNaN||function(r){return typeof r=="number"&&r!==r};function Lte(e,r){return!!(e===r||E5(e)&&E5(r))}function $te(e,r){if(e.length!==r.length)return!1;for(var t=0;t<e.length;t++)if(!Lte(e[t],r[t]))return!1;return!0}function t0(e,r){r===void 0&&(r=$te);var t,n=[],s,o=!1;function i(){for(var c=[],l=0;l<arguments.length;l++)c[l]=arguments[l];return o&&t===this&&r(c,n)||(s=e.apply(this,c),o=!0,t=this,n=c),s}return i}var Hte=typeof performance=="object"&&typeof performance.now=="function",A5=Hte?function(){return performance.now()}:function(){return Date.now()};function R5(e){cancelAnimationFrame(e.id)}function Vte(e,r){var t=A5();function n(){A5()-t>=r?e.call(null):s.id=requestAnimationFrame(n)}var s={id:requestAnimationFrame(n)};return s}var r0=-1;function z5(e){if(e===void 0&&(e=!1),r0===-1||e){var r=document.createElement("div"),t=r.style;t.width="50px",t.height="50px",t.overflow="scroll",document.body.appendChild(r),r0=r.offsetWidth-r.clientWidth,document.body.removeChild(r)}return r0}var $l=null;function I5(e){if(e===void 0&&(e=!1),$l===null||e){var r=document.createElement("div"),t=r.style;t.width="50px",t.height="50px",t.overflow="scroll",t.direction="rtl";var n=document.createElement("div"),s=n.style;return s.width="100px",s.height="100px",r.appendChild(n),document.body.appendChild(r),r.scrollLeft>0?$l="positive-descending":(r.scrollLeft=1,r.scrollLeft===0?$l="negative":$l="positive-ascending"),document.body.removeChild(r),$l}return $l}var Wte=150,Ute=function(r,t){return r};function Xte(e){var r,t=e.getItemOffset,n=e.getEstimatedTotalSize,s=e.getItemSize,o=e.getOffsetForIndexAndAlignment,i=e.getStartIndexForOffset,c=e.getStopIndexForStartIndex,l=e.initInstanceProps,a=e.shouldResetStyleCacheOnItemSizeChange,u=e.validateProps;return r=(function(h){qte(d,h);function d(m){var p;return p=h.call(this,m)||this,p._instanceProps=l(p.props,N5(p)),p._outerRef=void 0,p._resetIsScrollingTimeoutId=null,p.state={instance:N5(p),isScrolling:!1,scrollDirection:"forward",scrollOffset:typeof p.props.initialScrollOffset=="number"?p.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},p._callOnItemsRendered=void 0,p._callOnItemsRendered=t0(function(g,b,y,w){return p.props.onItemsRendered({overscanStartIndex:g,overscanStopIndex:b,visibleStartIndex:y,visibleStopIndex:w})}),p._callOnScroll=void 0,p._callOnScroll=t0(function(g,b,y){return p.props.onScroll({scrollDirection:g,scrollOffset:b,scrollUpdateWasRequested:y})}),p._getItemStyle=void 0,p._getItemStyle=function(g){var b=p.props,y=b.direction,w=b.itemSize,C=b.layout,N=p._getItemStyleCache(a&&w,a&&C,a&&y),I;if(N.hasOwnProperty(g))I=N[g];else{var $=t(p.props,g,p._instanceProps),D=s(p.props,g,p._instanceProps),F=y==="horizontal"||C==="horizontal",V=y==="rtl",G=F?$:0;N[g]=I={position:"absolute",left:V?void 0:G,right:V?G:void 0,top:F?0:$,height:F?"100%":D,width:F?D:"100%"}}return I},p._getItemStyleCache=void 0,p._getItemStyleCache=t0(function(g,b,y){return{}}),p._onScrollHorizontal=function(g){var b=g.currentTarget,y=b.clientWidth,w=b.scrollLeft,C=b.scrollWidth;p.setState(function(N){if(N.scrollOffset===w)return null;var I=p.props.direction,$=w;if(I==="rtl")switch(I5()){case"negative":$=-w;break;case"positive-descending":$=C-y-w;break}return $=Math.max(0,Math.min($,C-y)),{isScrolling:!0,scrollDirection:N.scrollOffset<$?"forward":"backward",scrollOffset:$,scrollUpdateWasRequested:!1}},p._resetIsScrollingDebounced)},p._onScrollVertical=function(g){var b=g.currentTarget,y=b.clientHeight,w=b.scrollHeight,C=b.scrollTop;p.setState(function(N){if(N.scrollOffset===C)return null;var I=Math.max(0,Math.min(C,w-y));return{isScrolling:!0,scrollDirection:N.scrollOffset<I?"forward":"backward",scrollOffset:I,scrollUpdateWasRequested:!1}},p._resetIsScrollingDebounced)},p._outerRefSetter=function(g){var b=p.props.outerRef;p._outerRef=g,typeof b=="function"?b(g):b!=null&&typeof b=="object"&&b.hasOwnProperty("current")&&(b.current=g)},p._resetIsScrollingDebounced=function(){p._resetIsScrollingTimeoutId!==null&&R5(p._resetIsScrollingTimeoutId),p._resetIsScrollingTimeoutId=Vte(p._resetIsScrolling,Wte)},p._resetIsScrolling=function(){p._resetIsScrollingTimeoutId=null,p.setState({isScrolling:!1},function(){p._getItemStyleCache(-1,null)})},p}d.getDerivedStateFromProps=function(p,g){return Gte(p,g),u(p),null};var f=d.prototype;return f.scrollTo=function(p){p=Math.max(0,p),this.setState(function(g){return g.scrollOffset===p?null:{scrollDirection:g.scrollOffset<p?"forward":"backward",scrollOffset:p,scrollUpdateWasRequested:!0}},this._resetIsScrollingDebounced)},f.scrollToItem=function(p,g){g===void 0&&(g="auto");var b=this.props,y=b.itemCount,w=b.layout,C=this.state.scrollOffset;p=Math.max(0,Math.min(p,y-1));var N=0;if(this._outerRef){var I=this._outerRef;w==="vertical"?N=I.scrollWidth>I.clientWidth?z5():0:N=I.scrollHeight>I.clientHeight?z5():0}this.scrollTo(o(this.props,p,g,C,this._instanceProps,N))},f.componentDidMount=function(){var p=this.props,g=p.direction,b=p.initialScrollOffset,y=p.layout;if(typeof b=="number"&&this._outerRef!=null){var w=this._outerRef;g==="horizontal"||y==="horizontal"?w.scrollLeft=b:w.scrollTop=b}this._callPropsCallbacks()},f.componentDidUpdate=function(){var p=this.props,g=p.direction,b=p.layout,y=this.state,w=y.scrollOffset,C=y.scrollUpdateWasRequested;if(C&&this._outerRef!=null){var N=this._outerRef;if(g==="horizontal"||b==="horizontal")if(g==="rtl")switch(I5()){case"negative":N.scrollLeft=-w;break;case"positive-ascending":N.scrollLeft=w;break;default:var I=N.clientWidth,$=N.scrollWidth;N.scrollLeft=$-I-w;break}else N.scrollLeft=w;else N.scrollTop=w}this._callPropsCallbacks()},f.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&R5(this._resetIsScrollingTimeoutId)},f.render=function(){var p=this.props,g=p.children,b=p.className,y=p.direction,w=p.height,C=p.innerRef,N=p.innerElementType,I=p.innerTagName,$=p.itemCount,D=p.itemData,F=p.itemKey,V=F===void 0?Ute:F,G=p.layout,U=p.outerElementType,E=p.outerTagName,M=p.style,B=p.useIsScrolling,k=p.width,_=this.state.isScrolling,S=y==="horizontal"||G==="horizontal",T=S?this._onScrollHorizontal:this._onScrollVertical,z=this._getRangeToRender(),P=z[0],O=z[1],X=[];if($>0)for(var K=P;K<=O;K++)X.push(A.createElement(g,{data:D,key:V(K,D),index:K,isScrolling:B?_:void 0,style:this._getItemStyle(K)}));var J=n(this.props,this._instanceProps);return A.createElement(U||E||"div",{className:b,onScroll:T,ref:this._outerRefSetter,style:db({position:"relative",height:w,width:k,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:y},M)},A.createElement(N||I||"div",{children:X,ref:C,style:{height:S?"100%":J,pointerEvents:_?"none":void 0,width:S?J:"100%"}}))},f._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered=="function"){var p=this.props.itemCount;if(p>0){var g=this._getRangeToRender(),b=g[0],y=g[1],w=g[2],C=g[3];this._callOnItemsRendered(b,y,w,C)}}if(typeof this.props.onScroll=="function"){var N=this.state,I=N.scrollDirection,$=N.scrollOffset,D=N.scrollUpdateWasRequested;this._callOnScroll(I,$,D)}},f._getRangeToRender=function(){var p=this.props,g=p.itemCount,b=p.overscanCount,y=this.state,w=y.isScrolling,C=y.scrollDirection,N=y.scrollOffset;if(g===0)return[0,0,0,0];var I=i(this.props,N,this._instanceProps),$=c(this.props,I,N,this._instanceProps),D=!w||C==="backward"?Math.max(1,b):1,F=!w||C==="forward"?Math.max(1,b):1;return[Math.max(0,I-D),Math.max(0,Math.min(g-1,$+F)),I,$]},d})(A.PureComponent),r.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},r}var Gte=function(r,t){r.children,r.direction,r.height,r.layout,r.innerTagName,r.outerTagName,r.width,t.instance},Kte=Xte({getItemOffset:function(r,t){var n=r.itemSize;return t*n},getItemSize:function(r,t){var n=r.itemSize;return n},getEstimatedTotalSize:function(r){var t=r.itemCount,n=r.itemSize;return n*t},getOffsetForIndexAndAlignment:function(r,t,n,s,o,i){var c=r.direction,l=r.height,a=r.itemCount,u=r.itemSize,h=r.layout,d=r.width,f=c==="horizontal"||h==="horizontal",m=f?d:l,p=Math.max(0,a*u-m),g=Math.min(p,t*u),b=Math.max(0,t*u-m+u+i);switch(n==="smart"&&(s>=b-m&&s<=g+m?n="auto":n="center"),n){case"start":return g;case"end":return b;case"center":{var y=Math.round(b+(g-b)/2);return y<Math.ceil(m/2)?0:y>p+Math.floor(m/2)?p:y}default:return s>=b&&s<=g?s:s<b?b:g}},getStartIndexForOffset:function(r,t){var n=r.itemCount,s=r.itemSize;return Math.max(0,Math.min(n-1,Math.floor(t/s)))},getStopIndexForStartIndex:function(r,t,n){var s=r.direction,o=r.height,i=r.itemCount,c=r.itemSize,l=r.layout,a=r.width,u=s==="horizontal"||l==="horizontal",h=t*c,d=u?a:o,f=Math.ceil((d+n-h)/c);return Math.max(0,Math.min(i-1,t+f-1))},initInstanceProps:function(r){},shouldResetStyleCacheOnItemSizeChange:!0,validateProps:function(r){r.itemSize}});const Yte=e=>{const{slots:r,slotProps:t}=bB(e),{dir:n}=Yt();return A.createElement(r.root,t.root,A.createElement(Kte,{itemSize:e.itemSize,width:e.width,itemData:e.rows,height:e.height,itemCount:e.rows.length,direction:n,outerRef:e.outerRef,...e.listProps},e.virtualizedRow))},F_=A.forwardRef((e,r)=>{const t=Fte(e,r);return Ate(t),Yte(t)});F_.displayName="DataGridBody";const Qte=(e,r)=>{var t;const{targetDocument:n}=Yt(),s=p3({targetDocument:n}),o=A.useRef(null),i=A.useRef(null);let c=e.containerWidthOffset;c===void 0&&(c=e.selectionMode?-44:0,c-=s||0);const l=IS({...e,"aria-rowcount":e.items.length,containerWidthOffset:c},r);return e.resizableColumns&&((t=e.resizableColumnsOptions)==null?void 0:t.autoFitColumns)===!1&&l.root.style&&(l.root.style.minWidth="auto"),{...l,headerRef:o,bodyRef:i}},Zte=(e,r)=>A.createElement(Ote,{value:e.headerRef},A.createElement(Dte,{value:e.bodyRef},MS(e,r))),q_=A.forwardRef((e,r)=>{const t=Qte(e,r);return DS(t),Zte(t,PS(t))});q_.displayName="DataGrid";const Jte=(e,r)=>{const t=zte();return jS({...e,"aria-rowindex":t},r)},ere=wr({root:{minWidth:"fit-content"}}),tre=e=>{const r=ere();return e.root.className=de(r.root,e.root.className),ES(e),e},hb=A.forwardRef((e,r)=>{const t=Jte(e,r);return tre(t),NS(t)});hb.displayName="DataGridRow";const rre=(e,r)=>{const t=D_(),n=O_(),s=A.useCallback(()=>{t.current&&n.current&&t.current.scroll({left:n.current.scrollLeft,behavior:"instant"})},[]),o=A.useCallback(c=>{var l;(l=n.current)==null||l.removeEventListener("scroll",s),n.current=c,c&&c.addEventListener("scroll",s)},[]),i=FS(e,r);return i.root.ref=Nt(i.root.ref,o),i},nre=wr({root:{overflowX:"auto",scrollbarWidth:"none","::-webkit-scrollbar":{width:0,height:0}}}),ore=e=>{const r=nre();return e.root.className=de(r.root,e.root.className),LS(e),e},L_=A.forwardRef((e,r)=>{const t=rre(e,r);return ore(t),qS(t)});L_.displayName="DataGridHeader";const pb=e=>e.toLocaleString("en-US");function ire(e,r,t){if(!(e===void 0||e<0))return r?`${pb(Math.max(e,t))}+ total`:`${pb(e)} total`}function are(e,r){return`About ${pb(r)} ${e} records in all: a snapshot from the last 24 hours that ignores this query's filters (RetrieveTotalRecordCount).`}const $_=A.createContext("");function sre(e,r){const t=r.trim().toLowerCase();if(!t)return[];const n=e.toLowerCase(),s=[];for(let o=n.indexOf(t);o>=0;o=n.indexOf(t,o+t.length))s.push([o,o+t.length]);return s}const lre=wr({mark:{backgroundColor:le.colorPaletteYellowBackground2,color:"inherit",borderRadius:le.borderRadiusSmall}});function ol({text:e}){const r=lre(),t=A.useContext($_),n=sre(e,t);if(n.length===0)return j.jsx(j.Fragment,{children:e});const s=[];let o=0;for(const[i,c]of n)i>o&&s.push(e.slice(o,i)),s.push(j.jsx("mark",{className:r.mark,children:e.slice(i,c)},i)),o=c;return o<e.length&&s.push(e.slice(o)),j.jsx(j.Fragment,{children:s})}const Nc=wr({booleanCell:{display:"flex",alignItems:"center",gap:le.spacingHorizontalXS},lookupCell:{display:"flex",flexDirection:"column",gap:"2px",minWidth:0},lookupName:{display:"block",fontSize:le.fontSizeBase200,fontWeight:le.fontWeightSemibold,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},lookupType:{display:"block",fontSize:le.fontSizeBase100,color:le.colorNeutralForeground3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},numberCell:{display:"block",textAlign:"right",fontVariantNumeric:"tabular-nums",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},dateCell:{display:"block",fontVariantNumeric:"tabular-nums",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},picklistCell:{display:"flex",alignItems:"center"},truncateText:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}});function cre({value:e,formattedValue:r,attribute:t}){const n=Nc(),s=!!e,o=r||(s?t?.OptionSet?.TrueOption?.Label?.UserLocalizedLabel?.Label||"Yes":t?.OptionSet?.FalseOption?.Label?.UserLocalizedLabel?.Label||"No");return j.jsxs("div",{className:n.booleanCell,children:[j.jsx(Qs,{checked:s,disabled:!0}),j.jsx(Dn,{size:"small",children:String(o)})]})}function ure({value:e,formattedValue:r,attribute:t}){const n=Nc();if(r){const l=t?.AttributeType==="State"||t?.AttributeType==="Status"?"filled":"tint";return j.jsx("div",{className:n.picklistCell,children:j.jsx(ri,{appearance:l,children:String(r)})})}const s=typeof e=="number"?e:parseInt(String(e),10);if(isNaN(s))return j.jsx("span",{children:"—"});const i=t?.OptionSet?.Options?.find(l=>l.Value===s)?.Label?.UserLocalizedLabel?.Label||String(s),c=t?.AttributeType==="State"||t?.AttributeType==="Status"?"filled":"tint";return j.jsx("div",{className:n.picklistCell,children:j.jsx(ri,{appearance:c,children:i})})}function dre({value:e,formattedValue:r}){const t=Nc();if(r)return j.jsx("span",{className:t.lookupName,children:j.jsx(ol,{text:String(r)})});if(!e||typeof e!="object")return j.jsx("span",{children:"—"});const n=e;return j.jsxs("div",{className:t.lookupCell,children:[j.jsx("span",{className:t.lookupName,children:j.jsx(ol,{text:n.Name||"—"})}),n.LogicalName&&j.jsx("span",{className:t.lookupType,children:n.LogicalName})]})}function fre({value:e,formattedValue:r,attribute:t}){const n=Nc();if(r)return j.jsx("span",{className:n.numberCell,children:j.jsx(ol,{text:String(r)})});if(e==null||e==="")return j.jsx("span",{children:"—"});const s=typeof e=="number"?e:parseFloat(String(e));if(isNaN(s))return j.jsx("span",{children:"—"});if(t?.AttributeType==="Money")return j.jsxs("span",{className:n.numberCell,children:["$",s.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]});if(t?.AttributeType==="Integer"||t?.AttributeType==="BigInt")return j.jsx("span",{className:n.numberCell,children:s.toLocaleString()});const o=t?.Precision??2;return j.jsx("span",{className:n.numberCell,children:s.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:o})})}function hre({value:e,formattedValue:r,attribute:t}){const n=Nc();if(r)return j.jsx("span",{className:n.dateCell,children:j.jsx(ol,{text:String(r)})});if(!e)return j.jsx("span",{children:"—"});const s=new Date(String(e));return isNaN(s.getTime())?j.jsx("span",{children:"—"}):t?.Format==="DateOnly"||t?.DateTimeBehavior?.Value==="DateOnly"?j.jsx("span",{className:n.dateCell,children:s.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}):j.jsx("span",{className:n.dateCell,children:s.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})}function pre({value:e,formattedValue:r}){const t=Nc(),n=r??e;return n==null||n===""?j.jsx("span",{children:"—"}):j.jsx("span",{className:t.truncateText,children:j.jsx(ol,{text:String(n)})})}function M5(e,r,t,n){if(r==null)return j.jsx("span",{children:"—"});switch(e){case"Boolean":return j.jsx(cre,{value:r,formattedValue:t,attribute:n});case"Picklist":case"State":case"Status":return j.jsx(ure,{value:r,formattedValue:t,attribute:n});case"Lookup":case"Customer":case"Owner":return j.jsx(dre,{value:r,formattedValue:t});case"Integer":case"BigInt":case"Decimal":case"Double":case"Money":return j.jsx(fre,{value:r,formattedValue:t,attribute:n});case"DateTime":return j.jsx(hre,{value:r,formattedValue:t,attribute:n});default:return j.jsx(pre,{value:r,formattedValue:t})}}function mre(e,r){const t=new WeakMap,n=new Map,s=new Set;return e.forEach((o,i)=>{const c=r?o[r]:void 0,l=typeof c=="string"&&c.length>0,a=l&&!s.has(c)?c:`__row_${i}`;s.add(a),t.set(o,a),l&&n.set(a,c)}),{getRowId:o=>t.get(o)??`__row_unknown_${e.indexOf(o)}`,toRecordIds:o=>{const i=new Set;for(const c of o){const l=n.get(String(c));l&&i.add(l)}return Array.from(i)}}}const D5="@OData.Community.Display.V1.FormattedValue";function Xi(e,r){if(!e||!r)return null;const t=`${r}${D5}`;if(t in e)return e[t];if(r.startsWith("_")&&r.endsWith("_value"))return e[r];const n=`_${r}_value${D5}`;return n in e?e[n]:e[r]}function zh(e){const r=new Map;let t=0;const n=s=>s.links.forEach(o=>{t++,r.set(o.id,o.alias||`${o.name}${t}`),n(o)});return n(e.entity),r}function Cp(e){const r=zh(e),t=e.entity.attributes.map(s=>({key:s.alias||s.name,attribute:s,container:e.entity,isRoot:!0})),n=s=>s.links.forEach(o=>{const i=r.get(o.id);for(const c of o.attributes)t.push({key:c.alias||`${i}.${c.name}`,attribute:c,container:o,isRoot:!1,linkAlias:i});n(o)});return n(e.entity),t}function vd(e,r){const t=Cp(e),n=t.find(c=>c.key===r);if(n)return n;const s=/^_(.+)_value$/.exec(r)?.[1],o=s?t.find(c=>c.isRoot&&!c.attribute.alias&&c.attribute.name===s):void 0;if(o||r.includes("."))return o;const i=r.toLowerCase();return t.find(c=>!c.isRoot&&!c.attribute.alias&&c.container.linkType==="matchfirstrowusingcrossapply"&&c.attribute.name===i)}const gre=(e,r)=>e.attributes.every(t=>r.has(t.id))&&!e.allAttributes?.enabled&&e.filters.length===0&&e.orders.every(t=>r.has(t.id))&&e.links.every(t=>r.has(t.id));function bre(e,r){const t=new Set;for(const i of r){const c=vd(e,i);c&&(t.add(c.attribute.id),c.attribute.alias&&Z0(e,c.container,c.attribute.alias).forEach(l=>t.add(l.id)))}const n=[],s=i=>i.links.forEach(c=>{s(c),c.linkType==="outer"&&gre(c,t)&&c.attributes.some(l=>t.has(l.id))&&(t.add(c.id),n.push(c))});s(e.entity);const o=new Set(n.flatMap(i=>[...i.attributes.map(c=>c.id),...i.orders.map(c=>c.id)]));return{removeNodeIds:[...t].filter(i=>!o.has(i)),removedLinks:n}}function vre(e,r,t){const n=vd(e,r);if(!n)return{reason:"This column isn't an attribute of the query."};const s=M8(t);if(s)return{reason:s};const o=e.options.aggregate===!0;if(o&&!n.attribute.alias)return{reason:"Aggregate queries sort by alias; give the attribute an alias first."};const i=o?{alias:n.attribute.alias}:{attribute:n.attribute.name};if(n.isRoot)return{spec:i};const c=n.container,l=H_(e).filter(u=>u.name===c.name).length,a=c.alias??(l===1?c.name:void 0);return a?{spec:{...i,entityname:a}}:{spec:i,insideLink:c}}function H_(e){const r=[],t=n=>n.links.forEach(s=>{r.push(s),t(s)});return t(e.entity),r}function yre(e){const r=Cp(e),t=H_(e),n=new Map,s=(o,i)=>{const c=o.descending?"descending":"ascending";for(const l of r){if(l.container!==i)continue;(o.alias?l.attribute.alias===o.alias:l.attribute.name===o.attribute)&&!n.has(l.key)&&n.set(l.key,c)}};for(const o of e.entity.orders){const i=o.entityname?t.find(c=>c.alias===o.entityname)??t.find(c=>c.name===o.entityname):e.entity;i&&s(o,i)}for(const o of t)for(const i of o.orders)s(i,o);return n}function n0(e,r){if(e.options?.aggregate)return{reason:"Column filters aren't available in aggregate queries. Add conditions in the tree instead."};const t=vd(e,r);if(!t)return{reason:"This column isn't an attribute in the query."};if(t.isRoot)return{attribute:t.attribute.name,entityName:e.entity.name};const n=t.container;return{attribute:t.attribute.name,entityname:"alias"in n&&n.alias?n.alias:n.name,entityName:n.name}}function Ec(e,r,t=[]){for(const[n,s]of e.entries()){if(s.id===r)return[...t,n];const o=Ec(s.subfilters,r,[...t,n]);if(o)return o}}function mb(e,r){let t=e,n;for(const s of r){if(n=t[s],!n)return;t=n.subfilters}return n}function Tp(e,r,t){const[n,...s]=r;return e.flatMap((o,i)=>{if(i!==n)return[o];if(s.length===0){const c=t(o);return c?[c]:[]}return[{...o,subfilters:Tp(o.subfilters,s,t)}]})}const ed=(e,r)=>({...e,entity:{...e.entity,filters:r}});function V_(e,r){if(!e||!r)return;const t=Ec(e.entity.filters,r);return t?mb(e.entity.filters,t):void 0}function wre(e,r){return V_(e,r)?.conditions??[]}function xre(e,r,t,n){const s={...t,id:n(),type:"condition"},o=e.entity.filters,i=r?Ec(o,r):void 0;if(r&&i)return{fetch:ed(e,Tp(o,i,d=>({...d,conditions:[...d.conditions,s]}))),groupId:r,conditionId:s.id};const c={id:n(),type:"filter",conjunction:"and",conditions:[s],subfilters:[],links:[]},l=d=>({fetch:ed(e,d),groupId:c.id,conditionId:s.id}),[a,...u]=o;if(!a)return l([c]);if(a.conjunction!=="or")return l([{...a,subfilters:[...a.subfilters,c]},...u]);const h={id:n(),type:"filter",conjunction:"and",conditions:[],subfilters:[a,c],links:[]};return{...l([h,...u]),wrapperId:h.id}}function kre(e,r,t,n=null){const s=V_(e,r);if(!s||!r)return{fetch:e,groupId:null};const o=s.conditions.filter(i=>i.id!==t);if(o.length>0||s.subfilters.length>0||s.links.length>0){const i=Ec(e.entity.filters,r);return{fetch:ed(e,Tp(e.entity.filters,i,c=>({...c,conditions:o}))),groupId:r}}return{fetch:W_(e,r,n),groupId:null}}function W_(e,r,t=null){const n=r?Ec(e.entity.filters,r):void 0;if(!n)return e;const s=Tp(e.entity.filters,n,()=>{}),[o,...i]=s;return n.length===2&&o&&o.id===t&&o.conjunction==="and"&&o.conditions.length===0&&o.links.length===0&&o.subfilters.length===1&&!o.hint&&!o.isQuickFindFields&&!o.overrideQuickFindRecordLimitEnabled&&!o.overrideQuickFindRecordLimitDisabled&&!o.extraAttributes?ed(e,[o.subfilters[0],...i]):ed(e,s)}const P5=e=>JSON.stringify(e?.conditions.map(r=>[r.attribute,r.operator,r.value??null,r.entityname??null])??null);function Sre(e,r,t,n){return!e||!t||!n?null:e.entity.filters[0]?.id===t?r.entity.filters[0]?.id??null:null}function _re(e,r,t){if(!e||!t)return null;const n=Ec(e.entity.filters,t);if(!n)return null;const s=mb(e.entity.filters,n),o=mb(r.entity.filters,n);return o&&P5(o)===P5(s)?o.id:null}function pc({entityLogicalName:e,value:r,onChange:t,placeholder:n="Select or type attribute name",disabled:s=!1,filterByTypes:o}){const i=mr("attribute-combobox"),[c,l]=A.useState([]),[a,u]=A.useState(!1),[h,d]=A.useState(null),[f,m]=A.useState(""),p=Sp();A.useEffect(()=>{if(!e){l([]);return}u(!0),d(null),Yv(e,p).then(C=>{let N=C;o&&o.length>0&&(N=C.filter(I=>o.includes(I.AttributeType||""))),l(N),u(!1)}).catch(C=>{console.error("Failed to load attributes:",C),d("Failed to load attributes"),u(!1)})},[e,o,p]),A.useEffect(()=>{if(r&&r!=="new_attribute"){const C=c.find(N=>N.LogicalName===r);if(C){const N=C.DisplayName?.UserLocalizedLabel?.Label||C.SchemaName;m(`${N} (${C.LogicalName})`)}else m(r)}else(!r||r==="new_attribute")&&m("")},[r,c]);const g=c.map(C=>({children:`${C.DisplayName?.UserLocalizedLabel?.Label||C.SchemaName} (${C.LogicalName})`,value:C.LogicalName})),b=dp(f,g,{noOptionsMessage:"No attributes match your search."}),y=(C,N)=>{N.optionValue?(m(N.optionText??""),t(N.optionValue)):(m(""),t(""))},w=r&&r!=="new_attribute"?[r]:[];return h?j.jsx(Zn,{"aria-labelledby":i,selectedOptions:w,value:f,onChange:C=>{const N=C.target.value;m(N),t(N)},placeholder:n,disabled:s}):j.jsx(Zn,{"aria-labelledby":i,onOptionSelect:y,selectedOptions:w,value:f,onChange:C=>m(C.target.value),placeholder:a?"Loading attributes…":n,disabled:s||a,clearable:!0,children:b})}function Cre({entityLogicalName:e,attributeLogicalName:r,value:t,onChange:n,placeholder:s="Select a value",disabled:o=!1}){const i=mr("optionset-combobox"),[c,l]=A.useState([]),[a,u]=A.useState(!1),[h,d]=A.useState(null),[f,m]=A.useState("");A.useEffect(()=>{if(!e||!r){l([]);return}u(!0),d(null),Qv(e,r).then(w=>{if(!w.OptionSet?.Options){d("No options found for this attribute"),l([]),u(!1);return}const C=w.OptionSet.Options.map(N=>{const I=N.Label?.UserLocalizedLabel?.Label||`Option ${N.Value}`;return{value:N.Value,label:I,displayText:`${I} - ${N.Value}`}});l(C),u(!1)}).catch(w=>{console.error("Failed to load option set values:",w),d("Failed to load options"),u(!1)})},[e,r]),A.useEffect(()=>{if(t!=null&&t!==""){const w=typeof t=="string"?parseInt(t,10):t,C=c.find(N=>N.value===w);m(C?C.displayText:String(t))}else m("")},[t,c]);const p=c.filter(w=>{if(!f)return!0;const C=f.toLowerCase();return w.label.toLowerCase().includes(C)||String(w.value).includes(C)}).map(w=>({children:w.displayText,value:String(w.value)})),g=dp(f,p,{noOptionsMessage:a?"Loading options…":h||"No options found",filter:()=>!0}),b=w=>{m(w.target.value)},y=(w,C)=>{if(!C.optionValue){m(""),n(void 0);return}const N=c.find(I=>String(I.value)===C.optionValue);N&&(m(N.displayText),n(N.value))};return j.jsx(Zn,{"aria-labelledby":i,placeholder:s,value:f,onChange:b,onOptionSelect:y,disabled:o||a,clearable:!0,children:g})}function Tre({entityLogicalName:e,attributeLogicalName:r,value:t,onChange:n,placeholder:s="Select true or false",disabled:o=!1}){const i=mr("boolean-combobox"),[c,l]=A.useState([]),[a,u]=A.useState(!1),[h,d]=A.useState(null),[f,m]=A.useState("");A.useEffect(()=>{if(!e||!r){l([]);return}u(!0),d(null),Qv(e,r).then(w=>{if(!w.OptionSet){console.warn("No OptionSet found for boolean attribute, using defaults"),l([{value:!0,label:"Yes",displayText:"Yes - true"},{value:!1,label:"No",displayText:"No - false"}]),u(!1);return}const C=w.OptionSet.TrueOption?.Label?.UserLocalizedLabel?.Label||"Yes",N=w.OptionSet.FalseOption?.Label?.UserLocalizedLabel?.Label||"No";l([{value:!0,label:C,displayText:`${C} - true`},{value:!1,label:N,displayText:`${N} - false`}]),u(!1)}).catch(w=>{console.error("Failed to load boolean attribute metadata:",w),l([{value:!0,label:"Yes",displayText:"Yes - true"},{value:!1,label:"No",displayText:"No - false"}]),u(!1)})},[e,r]),A.useEffect(()=>{if(t!=null&&t!==""){let w;typeof t=="boolean"?w=t:typeof t=="string"?w=t==="true"||t==="1":w=!!t;const C=c.find(N=>N.value===w);m(C?C.displayText:String(t))}else m("")},[t,c]);const p=c.filter(w=>{if(!f)return!0;const C=f.toLowerCase();return w.label.toLowerCase().includes(C)||String(w.value).toLowerCase().includes(C)}).map(w=>({children:w.displayText,value:String(w.value)})),g=dp(f,p,{noOptionsMessage:a?"Loading…":h||"No options",filter:()=>!0}),b=w=>{m(w.target.value)},y=(w,C)=>{if(!C.optionValue){m(""),n(void 0);return}const N=c.find(I=>String(I.value)===C.optionValue);N&&(m(N.displayText),n(N.value))};return j.jsx(Zn,{"aria-labelledby":i,placeholder:s,value:f,onChange:b,onOptionSelect:y,disabled:o||a,clearable:!0,children:g})}function gb({attribute:e,value:r,onChange:t,placeholder:n="Enter a number",disabled:s=!1}){const o=mr("numeric-input"),[i,c]=A.useState(""),l=f=>Math.abs(f)<1e-10&&f!==0?f.toFixed(20).replace(/\.?0+$/,""):Number.isInteger(f)?f.toString():f.toFixed(10).replace(/\.?0+$/,"");A.useEffect(()=>{if(r!=null&&r!==""){const f=typeof r=="number"?r:parseFloat(String(r));c(isNaN(f)?String(r):l(f))}else c("")},[r]);const a=()=>{const f=e.AttributeType;if(f==="Integer"||f==="BigInt")return 1;if((f==="Decimal"||f==="Double")&&e.Precision!==void 0)return Math.pow(10,-e.Precision)},u=f=>{const m=e.AttributeType;if(m==="Integer"||m==="BigInt")return Math.round(f);if((m==="Decimal"||m==="Double")&&e.Precision!==void 0){const p=Math.pow(10,e.Precision);return Math.round(f*p)/p}return f},h=f=>{const m=f.target.value;if(c(m),m===""){t(void 0);return}const p=parseFloat(m);if(!isNaN(p)){const g=u(p);t(g)}},d=()=>{if(i===""){t(void 0);return}const f=parseFloat(i);if(isNaN(f)){c(""),t(void 0);return}let m=u(f);e.MinValue!==void 0&&m<e.MinValue&&(m=e.MinValue),e.MaxValue!==void 0&&m>e.MaxValue&&(m=e.MaxValue),m!==f&&(c(String(m)),t(m))};return j.jsx(_n,{id:o,type:"number",value:i,onChange:h,onBlur:d,placeholder:n,disabled:s,min:e.MinValue,max:e.MaxValue,step:a()})}var jo=(function(e){return e[e.Sunday=0]="Sunday",e[e.Monday=1]="Monday",e[e.Tuesday=2]="Tuesday",e[e.Wednesday=3]="Wednesday",e[e.Thursday=4]="Thursday",e[e.Friday=5]="Friday",e[e.Saturday=6]="Saturday",e})({}),Bre=(function(e){return e[e.January=0]="January",e[e.February=1]="February",e[e.March=2]="March",e[e.April=3]="April",e[e.May=4]="May",e[e.June=5]="June",e[e.July=6]="July",e[e.August=7]="August",e[e.September=8]="September",e[e.October=9]="October",e[e.November=10]="November",e[e.December=11]="December",e})({}),Ih=(function(e){return e[e.FirstDay=0]="FirstDay",e[e.FirstFullWeek=1]="FirstFullWeek",e[e.FirstFourDayWeek=2]="FirstFourDayWeek",e})({}),fo=(function(e){return e[e.Day=0]="Day",e[e.Week=1]="Week",e[e.Month=2]="Month",e[e.WorkWeek=3]="WorkWeek",e})({});const td=7,Kr={DaysInOneWeek:7,MonthInOneYear:12},jre=e=>e.getDate().toString(),Nre=(e,r)=>r.months[e.getMonth()]+" "+e.getDate()+", "+e.getFullYear(),Ere=(e,r)=>r.months[e.getMonth()]+" "+e.getFullYear(),Are=(e,r)=>r.months[e.getMonth()],Rre=e=>e.getFullYear().toString(),zre={months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["S","M","T","W","T","F","S"]},U_={formatDay:jre,formatMonth:Are,formatYear:Rre,formatMonthDayYear:Nre,formatMonthYear:Ere},X_={...zre,goToToday:"Go to today",weekNumberFormatString:"Week number {0}",prevMonthAriaLabel:"Previous month",nextMonthAriaLabel:"Next month",prevYearAriaLabel:"Previous year",nextYearAriaLabel:"Next year",prevYearRangeAriaLabel:"Previous year range",nextYearRangeAriaLabel:"Next year range",closeButtonAriaLabel:"Close",selectedDateFormatString:"Selected date {0}",todayDateFormatString:"Today's date {0}",monthPickerHeaderAriaLabel:"{0}, change year",yearPickerHeaderAriaLabel:"{0}, change month",dayMarkedAriaLabel:"marked"};function No(e,r){const t=new Date(e.getTime());return t.setDate(t.getDate()+r),t}function O5(e,r){return No(e,r*Kr.DaysInOneWeek)}function Ja(e,r){let t=new Date(e.getTime());const n=t.getMonth()+r;return t.setMonth(n),t.getMonth()!==(n%Kr.MonthInOneYear+Kr.MonthInOneYear)%Kr.MonthInOneYear&&(t=No(t,-t.getDate())),t}function Ql(e,r){let t=new Date(e.getTime());return t.setFullYear(e.getFullYear()+r),t.getMonth()!==(e.getMonth()%Kr.MonthInOneYear+Kr.MonthInOneYear)%Kr.MonthInOneYear&&(t=No(t,-t.getDate())),t}function G_(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function K_(e){return new Date(e.getFullYear(),e.getMonth()+1,0,0,0,0,0)}function Ire(e){return new Date(e.getFullYear(),0,1,0,0,0,0)}function Mre(e){return new Date(e.getFullYear()+1,0,0,0,0,0,0)}function Lf(e,r){return Ja(e,r-e.getMonth())}function Sa(e,r){return!e&&!r?!0:!e||!r?!1:e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}function eo(e,r){return F5(e)-F5(r)}function Mh(e,r,t,n,s=1){const o=[];let i,c=null;switch(n||(n=[jo.Monday,jo.Tuesday,jo.Wednesday,jo.Thursday,jo.Friday]),r){case fo.Day:[i,c]=[e,No(e,s)],eo(i,c)>0&&([i,c]=[No(c,1),No(i,1)]);break;case fo.Week:case fo.WorkWeek:i=Fre(qre(e),t),c=No(i,Kr.DaysInOneWeek);break;case fo.Month:i=new Date(e.getFullYear(),e.getMonth(),1),c=Ja(i,1);break;default:throw new Error("Unexpected object: "+r)}let l=i;do(r!==fo.WorkWeek||n.indexOf(l.getDay())!==-1)&&o.push(l),l=No(l,1);while(!Sa(l,c));return o}function Dre(e,r){for(const t of r)if(Sa(e,t))return!0;return!1}function Pre(e,r,t,n){const s=n.getFullYear(),o=n.getMonth();let i=1;const c=new Date(s,o,i),l=i+(r+Kr.DaysInOneWeek-1)-$re(r,c.getDay());let a=new Date(s,o,l);i=a.getDate();const u=[];for(let h=0;h<e;h++)u.push(Ore(a,r,t)),i+=Kr.DaysInOneWeek,a=new Date(s,o,i);return u}function Ore(e,r,t){switch(t){case Ih.FirstFullWeek:return q5(e,r,Kr.DaysInOneWeek);case Ih.FirstFourDayWeek:return q5(e,r,4);default:return Lre(e,r)}}function Fre(e,r){let t=r-e.getDay();return t>0&&(t-=Kr.DaysInOneWeek),No(e,t)}function qre(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function F5(e){return e.getDate()+(e.getMonth()<<5)+(e.getFullYear()<<9)}function q5(e,r,t){const n=bb(e)-1;let s=e.getDay()-n%Kr.DaysInOneWeek;const o=new Date(e.getFullYear()-1,Bre.December,31),i=bb(o)-1;let c=(r-s+2*Kr.DaysInOneWeek)%Kr.DaysInOneWeek;c!==0&&c>=t&&(c-=Kr.DaysInOneWeek);let l=n-c;return l<0&&(s-=i%Kr.DaysInOneWeek,c=(r-s+2*Kr.DaysInOneWeek)%Kr.DaysInOneWeek,c!==0&&c+1>=t&&(c-=Kr.DaysInOneWeek),l=i-c),Math.floor(l/Kr.DaysInOneWeek+1)}function Lre(e,r){const t=bb(e)-1,s=(e.getDay()-t%Kr.DaysInOneWeek-r+2*Kr.DaysInOneWeek)%Kr.DaysInOneWeek;return Math.floor((t+s)/Kr.DaysInOneWeek+1)}function $re(e,r){return e!==jo.Sunday&&r<e?r+Kr.DaysInOneWeek:r}function bb(e){const r=e.getMonth(),t=e.getFullYear();let n=0;for(let s=0;s<r;s++)n+=Hre(s+1,t);return n+=e.getDate(),n}function Hre(e,r){return new Date(r,e,0).getDate()}const Y_=(e,r)=>{const{minDate:t}=r;return t?eo(t,e)>=1:!1},Q_=(e,r)=>{const{maxDate:t}=r;return t?eo(e,t)>=1:!1},Iu=(e,r)=>{const{restrictedDates:t,minDate:n,maxDate:s}=r;return!t&&!n&&!s?!1:t&&t.some(i=>Sa(i,e))||Y_(e,r)||Q_(e,r)},L5=e=>{const{targetDate:r,initialDate:t,direction:n,...s}=e;let o=r;if(!Iu(r,s))return r;for(;eo(t,o)!==0&&Iu(o,s)&&!Q_(o,s)&&!Y_(o,s);)o=No(o,n);if(eo(t,o)!==0&&!Iu(o,s))return o},Z_=(e,r,t)=>{let n=[...e];return r&&(n=n.filter(s=>eo(s,r)>=0)),t&&(n=n.filter(s=>eo(s,t)<=0)),n},Vre=(e,r,t)=>{const n=new Set(e);let s=0;for(const o of e){const i=(o+1)%7;n.has(i)&&t!==i||s++}return s<2},Wre=(e,r,t)=>r&&e===fo.WorkWeek&&(!Vre(r,!0,t)||r.length===0)?fo.Week:e,Ure=e=>{const{selectedDate:r,dateRangeType:t,firstDayOfWeek:n,today:s,minDate:o,maxDate:i,weeksToShow:c,workWeekDays:l,daysToSelectInDayView:a,restrictedDates:u,markedDays:h}=e,d={minDate:o,maxDate:i,restrictedDates:u},f=s||new Date,m=e.navigatedDate?e.navigatedDate:f;let p;c&&c<=4?p=new Date(m.getFullYear(),m.getMonth(),m.getDate()):p=new Date(m.getFullYear(),m.getMonth(),1);const g=[];for(;p.getDay()!==n;)p.setDate(p.getDate()-1);p=No(p,-td);let b=!1;const y=Wre(t,l,n);let w=[];r&&(w=Mh(r,y,n,l,a),w=Z_(w,o,i));let C=!0;for(let N=0;C;N++){const I=[];b=!0;for(let $=0;$<td;$++){const D=new Date(p.getTime()),F={key:p.toString(),date:p.getDate().toString(),originalDate:D,isInMonth:p.getMonth()===m.getMonth(),isToday:Sa(f,p),isSelected:Dre(p,w),isSingleSelected:w.length===1&&Sa(p,r),isInBounds:!Iu(p,d),isMarked:h?.some(V=>Sa(D,V))||!1};I.push(F),F.isInMonth&&(b=!1),p.setDate(p.getDate()+1)}C=c?N<c+1:!b||N===0,g.push(I)}return g};let Hl;function $5(e,r){if(e){if(Hl){Hl=e;return}Hl=e,r&&r.requestAnimationFrame(()=>{Hl&&Hl.focus(),Hl=void 0})}}const Ko={topRightCornerDate:"fui-CalendarDayGrid__topRightCornerDate",topLeftCornerDate:"fui-CalendarDayGrid__topLeftCornerDate",bottomRightCornerDate:"fui-CalendarDayGrid__bottomRightCornerDate",bottomLeftCornerDate:"fui-CalendarDayGrid__bottomLeftCornerDate"};function Xre(e){const{dir:r}=Yt(),t=o=>{const i={},c=o.slice(1,o.length-1);return c.forEach((l,a)=>{l.forEach((u,h)=>{const d=c[a-1]&&c[a-1][h]&&s(c[a-1][h].originalDate,u.originalDate,c[a-1][h].isSelected,u.isSelected),f=c[a+1]&&c[a+1][h]&&s(c[a+1][h].originalDate,u.originalDate,c[a+1][h].isSelected,u.isSelected),m=c[a][h-1]&&s(c[a][h-1].originalDate,u.originalDate,c[a][h-1].isSelected,u.isSelected),p=c[a][h+1]&&s(c[a][h+1].originalDate,u.originalDate,c[a][h+1].isSelected,u.isSelected);i[a+"_"+h]=n(d,f,m,p)})}),i},n=(o,i,c,l)=>{const a=[],u=!o&&!c,h=!o&&!l,d=!i&&!c,f=!i&&!l;return u&&a.push(r==="rtl"?Ko.topRightCornerDate:Ko.topLeftCornerDate),h&&a.push(r==="rtl"?Ko.topLeftCornerDate:Ko.topRightCornerDate),d&&a.push(r==="rtl"?Ko.bottomRightCornerDate:Ko.bottomLeftCornerDate),f&&a.push(r==="rtl"?Ko.bottomLeftCornerDate:Ko.bottomRightCornerDate),de(...a)},s=(o,i,c,l)=>{const{dateRangeType:a,firstDayOfWeek:u,workWeekDays:h}=e,d=a===fo.WorkWeek?fo.Week:a,f=Mh(o,d,u,h);return c!==l?!1:c&&l?!0:f.filter(m=>m.getTime()===i.getTime()).length>0};return[t,n]}const Hn={wrapper:"fui-CalendarDayGrid__wrapper",table:"fui-CalendarDayGrid__table",dayCell:"fui-CalendarDayGrid__dayCell",daySelected:"fui-CalendarDayGrid__daySelected",daySingleSelected:"fui-CalendarDayGrid__daySingleSelected",weekRow:"fui-CalendarDayGrid__weekRow",weekDayLabelCell:"fui-CalendarDayGrid__weekDayLabelCell",weekNumberCell:"fui-CalendarDayGrid__weekNumberCell",dayOutsideBounds:"fui-CalendarDayGrid__dayOutsideBounds",dayOutsideNavigatedMonth:"fui-CalendarDayGrid__dayOutsideNavigatedMonth",dayButton:"fui-CalendarDayGrid__dayButton",dayIsToday:"fui-CalendarDayGrid__dayIsToday",firstTransitionWeek:"fui-CalendarDayGrid__firstTransitionWeek",lastTransitionWeek:"fui-CalendarDayGrid__lastTransitionWeek",dayMarker:"fui-CalendarDayGrid__dayMarker",dayTodayMarker:"fui-CalendarDayGrid__dayTodayMarker"},xu={hoverStyle:"fui-CalendarDayGrid__hoverStyle",pressedStyle:"fui-CalendarDayGrid__pressedStyle"},Gre=ke({base:{Byoj8tv:"f1fow5ox"}},{d:[".f1fow5ox{padding-bottom:10px;}"]}),Kre=ke({base:{po53p8:"fgkb47j",Bxjg3zr:"f16vktn6",Be2twd7:"fjoy568",B6of3ja:"fvjh0tl",Byoj8tv:"f1fow5ox",qhf8xq:"f10pi13n",B73mfa3:"f14m3nip",fsow6f:"f17mccla",a9b677:"f4m2ahc"},showWeekNumbers:{a9b677:"fl524qk"}},{d:[".fgkb47j{border-collapse:collapse;}",".f16vktn6{border-spacing:0;}",".fjoy568{font-size:inherit;}",".fvjh0tl{margin-top:4px;}",".f1fow5ox{padding-bottom:10px;}",".f10pi13n{position:relative;}",".f14m3nip{table-layout:fixed;}",".f17mccla{text-align:center;}",".f4m2ahc{width:196px;}",".fl524qk{width:226px;}"]}),Yre=ke({base:{sj55zd:"f19n0e5",Bceei9c:"f1k6fduh",Be2twd7:"fy9rknc",Bhrd7zp:"figsok6",jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:"f1s184ao",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"fqtknz5",qhf8xq:"f10pi13n",By8wz76:"ftx6bta",B7iucu3:"fhs7xo9",cvlxnx:"fp6dsbd",Bweudez:"f4xgodq",D35jaw:0,Ehvor9:0,B2d49eq:0,Bup3k99:"f13vaffi",opggj9:"f1ndb8o",Bcb90bd:"f1m5g7hf",Bj67fi1:"f1lhgsq9",B2gfgcj:"fdbuq6n",Bg8e59q:"f1nsyjd2",oie0zm:"fs9m20f",mf9vuf:["f4ozsz2","fd6br62"],Gyav41:"fqrwank",tqq02e:["fd6br62","f4ozsz2"],Bua87ti:"fl9wzut"},focusIndicator:{Brovlpu:"ftqa4ok",B486eqv:"f2hkw1w",B8q5s1w:"f8hki3x",Bci5o5g:["f1d2448m","ffh67wi"],n8qw10:"f1bjia2o",Bdrgwmp:["ffh67wi","f1d2448m"],Bqhya38:"f1j6vpng",Bwxa6fj:["f1pniga2","f1ffjurs"],Bdhvstf:"f987i1v",B7zbvrb:["f1ffjurs","f1pniga2"],Bm4h7ae:"f15bsgw9",B7ys5i9:"f14e48fq",Busjfv9:"f18yb2kv",Bhk32uz:"fd6o370",f6g5ot:0,Boxcth7:0,Bhdgwq3:0,hgwjuy:0,Bshpdp8:0,Bsom6fd:0,Blkhhs4:0,Bonggc9:0,Ddfuxk:0,i03rao:0,kclons:0,clg4pj:0,Bpqj9nj:0,B6dhp37:0,Bf4ptjt:0,Bqtpl0w:0,i4rwgc:"fpqizxz",Dah5zi:0,B1tsrr9:0,qqdqy8:0,Bkh64rk:0,e3fwne:"f3znvyf",J0r882:"fqkqgbk",Bule8hv:["f1as04kd","ft30ozv"],Bjwuhne:"f8pxvb2",Ghsupd:["ft30ozv","f1as04kd"]}},{d:[".f19n0e5{color:var(--colorNeutralForeground1);}",".f1k6fduh{cursor:pointer;}",".fy9rknc{font-size:var(--fontSizeBase200);}",".figsok6{font-weight:var(--fontWeightRegular);}",[".f1s184ao{margin:0;}",{p:-1}],[".fqtknz5{padding:2px;}",{p:-1}],".f10pi13n{position:relative;}",".fp6dsbd.fui-CalendarDayGrid__hoverStyle{color:var(--colorNeutralForeground1Static);}",".f4xgodq.fui-CalendarDayGrid__hoverStyle{background-color:var(--colorBrandBackgroundInvertedHover);}",".f1lhgsq9.fui-CalendarDayGrid__pressedStyle{color:var(--colorNeutralForeground1Static);}",".fdbuq6n.fui-CalendarDayGrid__pressedStyle{background-color:var(--colorBrandBackgroundInvertedPressed);}",".f8hki3x[data-fui-focus-visible]{border-top-color:transparent;}",".f1d2448m[data-fui-focus-visible]{border-right-color:transparent;}",".ffh67wi[data-fui-focus-visible]{border-left-color:transparent;}",".f1bjia2o[data-fui-focus-visible]{border-bottom-color:transparent;}",'.f15bsgw9[data-fui-focus-visible]::after{content:"";}',".f14e48fq[data-fui-focus-visible]::after{position:absolute;}",".f18yb2kv[data-fui-focus-visible]::after{pointer-events:none;}",".fd6o370[data-fui-focus-visible]::after{z-index:1;}",[".fpqizxz[data-fui-focus-visible]::after{border:var(--strokeWidthThick) solid var(--colorStrokeFocus2);}",{p:-2}],[".f3znvyf[data-fui-focus-visible]::after{border-radius:var(--borderRadiusMedium);}",{p:-1}],".fqkqgbk[data-fui-focus-visible]::after{top:calc(var(--strokeWidthThick) * -1);}",".f1as04kd[data-fui-focus-visible]::after{right:calc(var(--strokeWidthThick) * -1);}",".ft30ozv[data-fui-focus-visible]::after{left:calc(var(--strokeWidthThick) * -1);}",".f8pxvb2[data-fui-focus-visible]::after{bottom:calc(var(--strokeWidthThick) * -1);}"],m:[["@media (forced-colors: active){.ftx6bta{background-color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fhs7xo9{color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f13vaffi.fui-CalendarDayGrid__hoverStyle{outline:1px solid Highlight;}}",{p:-1,m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1ndb8o.fui-CalendarDayGrid__hoverStyle{z-index:3;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1m5g7hf.fui-CalendarDayGrid__hoverStyle .fui-CalendarDayGrid__dayTodayMarker{background-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1nsyjd2.fui-CalendarDayGrid__pressedStyle{background-color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fs9m20f.fui-CalendarDayGrid__pressedStyle{border-top-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f4ozsz2.fui-CalendarDayGrid__pressedStyle{border-right-color:Highlight;}.fd6br62.fui-CalendarDayGrid__pressedStyle{border-left-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fqrwank.fui-CalendarDayGrid__pressedStyle{border-bottom-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fl9wzut.fui-CalendarDayGrid__pressedStyle{color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1j6vpng[data-fui-focus-visible]::after{border-top-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1ffjurs[data-fui-focus-visible]::after{border-left-color:Highlight;}.f1pniga2[data-fui-focus-visible]::after{border-right-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f987i1v[data-fui-focus-visible]::after{border-bottom-color:Highlight;}}",{m:"(forced-colors: active)"}]],f:[".ftqa4ok:focus{outline-style:none;}"],i:[".f2hkw1w:focus-visible{outline-style:none;}"]}),Qre=ke({base:{De3pzq:"f1vevd59",sj55zd:"ff5vbop",By8wz76:"f1nz3ub2",Bcq6wej:"fjq791v",Jcjdmf:["fkq2p2y","f1sehlss"],sc4o1m:"f11odvng",Bosien3:["f1sehlss","fkq2p2y"],B7iucu3:"fqc85l4",B8gzw0y:"f1h3a8gf",a3nq4f:"f1chdfq9",Bnf3alp:"fq0dbue",pdtyat:"fb3dhiz",z6f07v:"f1xnoze0",Bec5aua:"f1mubwa3"}},{d:[".f1vevd59{background-color:var(--colorBrandBackgroundInvertedSelected);}",".ff5vbop{color:var(--colorNeutralForeground1Static);}"],m:[["@media (forced-colors: active){.f1nz3ub2{background-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fjq791v{border-top-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1sehlss{border-left-color:Highlight;}.fkq2p2y{border-right-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f11odvng{border-bottom-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fqc85l4{color:HighlightText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1h3a8gf{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fb3dhiz:hover,.fb3dhiz.fui-CalendarDayGrid__hoverStyle,.fb3dhiz.fui-CalendarDayGrid__pressedStyle{background-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1xnoze0:hover,.f1xnoze0.fui-CalendarDayGrid__hoverStyle,.f1xnoze0.fui-CalendarDayGrid__pressedStyle{color:HighlightText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1mubwa3>.fui-CalendarDayGrid__dayMarker{background-color:Window;}}",{m:"(forced-colors: active)"}]],h:[".f1chdfq9:hover,.f1chdfq9.fui-CalendarDayGrid__hoverStyle,.f1chdfq9.fui-CalendarDayGrid__pressedStyle{color:var(--colorNeutralForeground1Static);}",".fq0dbue:hover,.fq0dbue.fui-CalendarDayGrid__hoverStyle,.fq0dbue.fui-CalendarDayGrid__pressedStyle{background-color:var(--colorBrandBackgroundInvertedSelected);}"]}),Zre=ke({base:{sj55zd:"ff5vbop",Bec5aua:"f1mubwa3",B2ns3jv:"fy35frb",Bwxf4zv:0,Bp8cau8:0,Buy161k:0,Bpzqh5e:0,Fh6yq5:"f8kna22",Bjnjwcd:0,Jh9m0u:0,k24jl4:0,yen2pv:0,isizv9:0,Fmkg4n:0,Bksmc0g:0,ydc5we:0,g36fg5:0,xn840g:0,Bvql7r5:0,Cmeexk:0,Brwjcd2:0,Buxuwzc:0,Bz06psx:0,B75pphk:0,Bkp00lz:"f11572cp",B4k9tdm:"f8qifl1",Ba18yr8:"f19flthw",B5fqyig:["fwk98tc","f3izcvc"],Bjrn8xn:"fi9jqiz",Bkpapd2:["f3izcvc","fwk98tc"],xrravj:"f12o3e7s",z0dzun:"f1fjwm8e"}},{d:[".ff5vbop{color:var(--colorNeutralForeground1Static);}",".fy35frb>.fui-CalendarDayGrid__dayButton{background-color:var(--colorBrandBackgroundInvertedSelected);}",[".f8kna22>.fui-CalendarDayGrid__dayButton{border-radius:var(--borderRadiusMedium);}",{p:-1}],[".f11572cp>.fui-CalendarDayGrid__dayButton{border:1px solid var(--colorBrandStroke1);}",{p:-2}]],m:[["@media (forced-colors: active){.f1mubwa3>.fui-CalendarDayGrid__dayMarker{background-color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f8qifl1>.fui-CalendarDayGrid__dayButton{background-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f19flthw>.fui-CalendarDayGrid__dayButton{border-top-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f3izcvc>.fui-CalendarDayGrid__dayButton{border-left-color:Highlight;}.fwk98tc>.fui-CalendarDayGrid__dayButton{border-right-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fi9jqiz>.fui-CalendarDayGrid__dayButton{border-bottom-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f12o3e7s>.fui-CalendarDayGrid__dayButton{color:HighlightText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1fjwm8e>.fui-CalendarDayGrid__dayButton{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}]]}),Jre=ke({base:{qhf8xq:"f10pi13n",mlyf9c:"f1gazwyt"}},{d:[".f10pi13n{position:relative;}"],w:[".f1gazwyt:focus-within{z-index:1;}"]}),ene=ke({base:{famaaq:"f1xqy1su"}},{d:[".f1xqy1su{-webkit-user-select:none;-moz-user-select:none;user-select:none;}"]}),tne=ke({base:{De3pzq:"f1c21dwh",h3c5rm:0,vrafjx:0,Bekrc4i:0,u1mtju:["fe2nn5g","f1rcbay7"],B7ck84d:"f1ewtqcl",sj55zd:"fxc4j92",Be2twd7:"fy9rknc",Bhrd7zp:"figsok6",Bqenvij:"fxldao9",jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:"f1s184ao",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai",a9b677:"f1w9dchk"}},{d:[".f1c21dwh{background-color:var(--colorTransparentBackground);}",[".fe2nn5g{border-right:1px solid var(--colorNeutralStroke2);}",{p:-1}],[".f1rcbay7{border-left:1px solid var(--colorNeutralStroke2);}",{p:-1}],".f1ewtqcl{box-sizing:border-box;}",".fxc4j92{color:var(--colorNeutralForeground4);}",".fy9rknc{font-size:var(--fontSizeBase200);}",".figsok6{font-weight:var(--fontWeightRegular);}",".fxldao9{height:28px;}",[".f1s184ao{margin:0;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".f1w9dchk{width:28px;}"]}),rne=ke({base:{x734em:"f1v4z6xg",B0ssf13:"f1u9q7oh",B8h8h5z:"f1a22lcc",B7iucu3:"f1cyfu5x"}},{d:[".f1v4z6xg,.f1v4z6xg:disabled,.f1v4z6xg button,.f1v4z6xg.fui-CalendarDayGrid__hoverStyle,.f1v4z6xg.fui-CalendarDayGrid__pressedStyle{background-color:var(--colorTransparentBackground);}",".f1u9q7oh,.f1u9q7oh:disabled,.f1u9q7oh button,.f1u9q7oh.fui-CalendarDayGrid__hoverStyle,.f1u9q7oh.fui-CalendarDayGrid__pressedStyle{color:var(--colorNeutralForegroundDisabled);}",".f1a22lcc,.f1a22lcc:disabled,.f1a22lcc button,.f1a22lcc.fui-CalendarDayGrid__hoverStyle,.f1a22lcc.fui-CalendarDayGrid__pressedStyle{pointer-events:none;}"],m:[["@media (forced-colors: active){.f1cyfu5x{color:GrayText;}}",{m:"(forced-colors: active)"}]]}),nne=ke({lightenDaysOutsideNavigatedMonth:{sj55zd:"fxc4j92",Bhrd7zp:"figsok6",B7iucu3:"f1cyfu5x"}},{d:[".fxc4j92{color:var(--colorNeutralForeground4);}",".figsok6{font-weight:var(--fontWeightRegular);}"],m:[["@media (forced-colors: active){.f1cyfu5x{color:GrayText;}}",{m:"(forced-colors: active)"}]]}),one=ke({base:{De3pzq:"f1c21dwh",Bgfg5da:0,B9xav0g:0,oivjwe:0,Bn0qgzm:0,B4g9neb:0,zhjwy3:0,wvpqe5:0,ibv6hh:0,u1mtju:0,h3c5rm:0,vrafjx:0,Bekrc4i:0,i8vvqc:0,g2u3we:0,icvyot:0,B4j52fo:0,irswps:"f3bhgqh",sj55zd:"f1ym3bx4",Bceei9c:"f1k6fduh",Be2twd7:"fy9rknc",Bhrd7zp:"ff5ikls",Bqenvij:"frvgh55",Bg96gwp:"f8xlz6g",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1gl81tg",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai",a9b677:"fq4mcun",Bx0yju7:"f10y451g",l98f4w:"f1dwpgx3",Jwef8y:"f18a0fwf",Btmb5he:0,gu71dq:0,B2zomw9:0,Fgk69s:0,Bw6eyry:"f1mhq3ai",ecr2s2:"f7la2e8"}},{d:[".f1c21dwh{background-color:var(--colorTransparentBackground);}",[".f3bhgqh{border:none;}",{p:-2}],".f1ym3bx4{color:inherit;}",".f1k6fduh{cursor:pointer;}",".fy9rknc{font-size:var(--fontSizeBase200);}",".ff5ikls{font-weight:inherit;}",".frvgh55{height:24px;}",".f8xlz6g{line-height:24px;}",[".f1gl81tg{overflow:visible;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".fq4mcun{width:24px;}",".f10y451gspan{height:inherit;}",".f1dwpgx3span{line-height:inherit;}"],h:[".f18a0fwf:hover{background-color:var(--colorBrandBackgroundInvertedHover);}",[".f1mhq3ai:hover{border-radius:var(--borderRadiusMedium);}",{p:-1}]],a:[".f7la2e8:active{background-color:var(--colorBrandBackgroundInvertedPressed);}"]}),ine=ke({base:{mc9l5x:"f22iagw",Brf1p80:"f4d9j23",Bt984gj:"f122n59",sj55zd:"f1phragk",Bhrd7zp:"fl43uef",kof2un:"f1b5s8wn",Bec5aua:"f1mubwa3"}},{d:[".f22iagw{display:flex;}",".f4d9j23{justify-content:center;}",".f122n59{align-items:center;}",".f1phragk{color:var(--colorNeutralForegroundOnBrand);}",".fl43uef{font-weight:var(--fontWeightSemibold);}",".f1b5s8wn>.fui-CalendarDayGrid__dayMarker{background-color:var(--colorNeutralForegroundOnBrand);}"],m:[["@media (forced-colors: active){.f1mubwa3>.fui-CalendarDayGrid__dayMarker{background-color:Window;}}",{m:"(forced-colors: active)"}]]}),ane=ke({base:{mc9l5x:"f22iagw",Brf1p80:"f4d9j23",Bt984gj:"f122n59",De3pzq:"ffp7eso",Beyfa6y:0,Bbmb7ep:0,Btl43ni:0,B7oj6ja:0,Dimara:"f1qtlz2s",a9b677:"f64fuq3",Bqenvij:"fjamq6b",Bg96gwp:"f1n95isl",By8wz76:"fq1p4f3",Bcq6wej:"fcwbuzc",Jcjdmf:["f1iyvy17","fu9dqmu"],sc4o1m:"fa5hmw6",Bosien3:["fu9dqmu","f1iyvy17"],B7iucu3:"fygpdla",B8gzw0y:"f1h3a8gf"}},{d:[".f22iagw{display:flex;}",".f4d9j23{justify-content:center;}",".f122n59{align-items:center;}",".ffp7eso{background-color:var(--colorBrandBackground);}",[".f1qtlz2s{border-radius:100%;}",{p:-1}],".f64fuq3{width:20px;}",".fjamq6b{height:20px;}",".f1n95isl{line-height:20px;}"],m:[["@media (forced-colors: active){.fq1p4f3{background-color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fcwbuzc{border-top-color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1iyvy17{border-right-color:WindowText;}.fu9dqmu{border-left-color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fa5hmw6{border-bottom-color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fygpdla{color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1h3a8gf{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}]]}),sne=ke({base:{abs64n:"fk73vx1",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1a3p1vp",Bkecrkj:"f1aehjj5",qhf8xq:"f1euv43f"}},{d:[".fk73vx1{opacity:0;}",[".f1a3p1vp{overflow:hidden;}",{p:-1}],".f1aehjj5{pointer-events:none;}",".f1euv43f{position:absolute;}"]}),lne=ke({base:{B6of3ja:"flykjtj",abs64n:"fk73vx1",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1a3p1vp",Bkecrkj:"f1aehjj5",qhf8xq:"f1euv43f"}},{d:[".flykjtj{margin-top:-28px;}",".fk73vx1{opacity:0;}",[".f1a3p1vp{overflow:hidden;}",{p:-1}],".f1aehjj5{pointer-events:none;}",".f1euv43f{position:absolute;}"]}),cne=ke({base:{De3pzq:"fnggedw",Beyfa6y:0,Bbmb7ep:0,Btl43ni:0,B7oj6ja:0,Dimara:"f1qtlz2s",B5kzvoi:"f1oq0udb",Bqenvij:"f6ywr7j",oyh7mz:["f1vgc2s3","f1e31b4d"],jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:"fcpdi13",qhf8xq:"f1euv43f",j35jbq:["f1e31b4d","f1vgc2s3"],a9b677:"faro0ui",By8wz76:"fq1p4f3",B8gzw0y:"f1h3a8gf"}},{d:[".fnggedw{background-color:var(--colorBrandForeground2);}",[".f1qtlz2s{border-radius:100%;}",{p:-1}],".f1oq0udb{bottom:1px;}",".f6ywr7j{height:4px;}",".f1vgc2s3{left:0;}",".f1e31b4d{right:0;}",[".fcpdi13{margin:auto;}",{p:-1}],".f1euv43f{position:absolute;}",".faro0ui{width:4px;}"],m:[["@media (forced-colors: active){.fq1p4f3{background-color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1h3a8gf{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}]]}),une=ke({corners:{Cy64m2:["f1yxjewa","f5xfyye"],Bnn43bw:["f1kpdnd7","fokqrni"],feanbc:["f127emps","f1s6s1el"],B4268ip:["f39vr2a","frpqyrn"]}},{d:[".f1yxjewa.fui-CalendarDayGrid__topRightCornerDate{border-top-right-radius:var(--borderRadiusMedium);}",".f5xfyye.fui-CalendarDayGrid__topRightCornerDate{border-top-left-radius:var(--borderRadiusMedium);}",".f1kpdnd7.fui-CalendarDayGrid__topLeftCornerDate{border-top-left-radius:var(--borderRadiusMedium);}",".fokqrni.fui-CalendarDayGrid__topLeftCornerDate{border-top-right-radius:var(--borderRadiusMedium);}",".f127emps.fui-CalendarDayGrid__bottomRightCornerDate{border-bottom-right-radius:var(--borderRadiusMedium);}",".f1s6s1el.fui-CalendarDayGrid__bottomRightCornerDate{border-bottom-left-radius:var(--borderRadiusMedium);}",".f39vr2a.fui-CalendarDayGrid__bottomLeftCornerDate{border-bottom-left-radius:var(--borderRadiusMedium);}",".frpqyrn.fui-CalendarDayGrid__bottomLeftCornerDate{border-bottom-right-radius:var(--borderRadiusMedium);}"]}),dne=e=>{"use no memo";const r=Gre(),t=Kre(),n=Yre(),s=Qre(),o=Zre(),i=Jre(),c=ene(),l=tne(),a=rne(),u=nne(),h=one(),d=ine(),f=sne(),m=lne(),p=cne(),g=une(),b=ane(),{lightenDaysOutsideNavigatedMonth:y,showWeekNumbers:w}=e;return{wrapper:de(Hn.wrapper,r.base),table:de(Hn.table,t.base,w&&t.showWeekNumbers),dayCell:de(Hn.dayCell,n.base,n.focusIndicator,g.corners),daySelected:de(Hn.daySelected,s.base),daySingleSelected:de(Hn.daySingleSelected,o.base),weekRow:de(Hn.weekRow,i.base),weekDayLabelCell:de(Hn.weekDayLabelCell,c.base),weekNumberCell:de(Hn.weekNumberCell,l.base),dayOutsideBounds:de(Hn.dayOutsideBounds,a.base),dayOutsideNavigatedMonth:de(Hn.dayOutsideNavigatedMonth,y&&u.lightenDaysOutsideNavigatedMonth),dayButton:de(Hn.dayButton,h.base),dayIsToday:de(Hn.dayIsToday,d.base),firstTransitionWeek:de(Hn.firstTransitionWeek,f.base),lastTransitionWeek:de(Hn.lastTransitionWeek,m.base),dayMarker:de(Hn.dayMarker,p.base),dayTodayMarker:de(Hn.dayTodayMarker,b.base)}},fne=e=>{const{showWeekNumbers:r,strings:t,firstDayOfWeek:n,allFocusable:s,weeksToShow:o,weeks:i,classNames:c}=e,l=t.shortDays.slice();let a=-1;const u=i[1];for(let h=0;h<i[1].length;h++)if(u[h].originalDate.getDate()===1){a=h;break}if(o===1&&a>=0){const h=(a+n)%td;l[h]=t.shortMonths[i[1][a].originalDate.getMonth()]}return A.createElement("tr",null,r&&A.createElement("th",{className:c.dayCell}),l.map((h,d)=>{const f=(d+n)%td,m=t.days[f];return A.createElement(ev.In,{key:l[f]+" "+d,duration:Gt.durationGentle},A.createElement("th",{className:de(c.dayCell,c.weekDayLabelCell),scope:"col",title:m,"aria-label":m,tabIndex:s?0:void 0},l[f]))}))},hne=e=>{"use no memo";const{navigatedDate:r,dateTimeFormatter:t,allFocusable:n,strings:s,activeDescendantId:o,navigatedDayRef:i,calculateRoundedStyles:c,weeks:l,classNames:a,day:u,dayIndex:h,weekIndex:d,weekCorners:f,ariaHidden:m,customDayCellRef:p,dateRangeType:g,daysToSelectInDayView:b,onSelectDate:y,restrictedDates:w,minDate:C,maxDate:N,onNavigateDate:I,getDayInfosInRangeOfDay:$,getRefsFromDayInfos:D}=e;var F;const V=(F=f?.[d+"_"+h])!==null&&F!==void 0?F:"",G=Sa(r,u.originalDate),{dir:U}=Yt(),E=(P,O)=>{let X,K=1;if(P.key===rs?(X=O5(O,-1),K=-1):P.key===Ta?X=O5(O,1):P.key===Yw(ms,U)?(X=No(O,-1),K=-1):P.key===Yw(gs,U)&&(X=No(O,1)),!X)return;const J={initialDate:O,targetDate:X,direction:K,restrictedDates:w,minDate:C,maxDate:N};let H=L5(J);H||(J.direction=-K,H=L5(J)),!(l&&H&&l.slice(1,l.length-1).some(L=>L.some(q=>Sa(q.originalDate,H))))&&H&&(I(H,!0),P.preventDefault())},M=P=>{const O=$(u),X=D(O);X.forEach((K,J)=>{if(K&&(K.classList.add(xu.hoverStyle),!O[J].isSelected&&g===fo.Day&&b&&b>1)){K.classList.remove(Ko.bottomLeftCornerDate,Ko.bottomRightCornerDate,Ko.topLeftCornerDate,Ko.topRightCornerDate);const H=c(!1,!1,J>0,J<X.length-1).trim();H&&K.classList.add(...H.trim().split(" "))}})},B=P=>{const O=$(u);D(O).forEach(K=>{K&&K.classList.add(xu.pressedStyle)})},k=P=>{const O=$(u);D(O).forEach(K=>{K&&K.classList.remove(xu.pressedStyle)})},_=P=>{const O=$(u),X=D(O);X.forEach((K,J)=>{if(K&&(K.classList.remove(xu.hoverStyle),K.classList.remove(xu.pressedStyle),!O[J].isSelected&&g===fo.Day&&b&&b>1)){const H=c(!1,!1,J>0,J<X.length-1).trim();H&&K.classList.remove(...H.trim().split(" "))}})},S=P=>{P.key===gn?y?.(u.originalDate):E(P,u.originalDate)};let T=u.originalDate.getDate()+", "+s.months[u.originalDate.getMonth()]+", "+u.originalDate.getFullYear();u.isMarked&&(T=T+", "+s.dayMarkedAriaLabel);const z=!m&&(n||(u.isInBounds?!0:void 0));return A.createElement("td",{className:de(a.dayCell,f&&V,u.isSelected&&!u.isSingleSelected&&a.daySelected,u.isSingleSelected&&a.daySingleSelected,!u.isInBounds&&a.dayOutsideBounds,!u.isInMonth&&a.dayOutsideNavigatedMonth),ref:P=>{p?.(P,u.originalDate,a),u.setRef(P),G&&(i.current=P)},"aria-disabled":!m&&!u.isInBounds,onClick:u.isInBounds&&!m?u.onSelected:void 0,onMouseOver:m?void 0:M,onMouseDown:m?void 0:B,onMouseUp:m?void 0:k,onMouseOut:m?void 0:_,onKeyDown:m?void 0:S,role:"gridcell",tabIndex:G||z?0:void 0,"aria-current":u.isToday?"date":void 0,"aria-selected":u.isInBounds?u.isSelected:void 0},A.createElement("button",{key:u.key+"button",className:de(a.dayButton,u.isToday&&a.dayIsToday),"aria-label":T,id:G?o:void 0,disabled:!m&&!u.isInBounds,type:"button",tabIndex:-1},A.createElement("span",{className:u.isToday?de(a.dayTodayMarker):void 0},t.formatDay(u.originalDate)),u.isMarked&&A.createElement("div",{"aria-hidden":"true",className:a.dayMarker})))},ah=A.forwardRef((e,r)=>{const{ariaHidden:t,classNames:n,week:s,weeks:o,weekIndex:i,rowClassName:c,ariaRole:l,showWeekNumbers:a,firstDayOfWeek:u,firstWeekOfYear:h,navigatedDate:d,strings:f}=e,m=a?Pre(o.length,u,h,d):null,p=m?f.weekNumberFormatString&&f.weekNumberFormatString.replace("{0}",`${m[i]}`):"";return A.createElement("tr",{ref:r,role:l,"aria-hidden":t,className:c},a&&m&&A.createElement("th",{className:n.weekNumberCell,title:p,"aria-label":p,scope:"row"},A.createElement("span",null,m[i])),s.map((g,b)=>A.createElement(hne,{...e,key:g.key,day:g,dayIndex:b})))});ah.displayName="CalendarGridRow";function pne(e,r,t){return A.useMemo(()=>{var s;const o=Ure(e),i=o[1][0].originalDate,c=o[o.length-1][6].originalDate,l=((s=e.getMarkedDays)===null||s===void 0?void 0:s.call(e,i,c))||[],a=[];for(let u=0;u<o.length;u++){const h=[];for(let d=0;d<td;d++){const f=o[u][d],m={onSelected:()=>r(f.originalDate),setRef:t(f.key),...f,isMarked:f.isMarked||l?.some(p=>Sa(f.originalDate,p))};h.push(m)}a.push(h)}return a},[e])}const Dh="20px";function J_(e,r){const t=A.Children.only(e),n=Nt(r,gc(t));return A.cloneElement(t,{ref:n})}const Bp=A.forwardRef((e,r)=>{const{duration:t=Gt.durationSlower,easing:n=Gt.curveDecelerateMax,animationDirection:s=il.Vertical,animateBackwards:o=!1,replayKey:i,children:c}=e;let l="0px",a="0px";const u=o?`-${Dh}`:Dh;s===il.Horizontal?l=u:a=u;const h=J_(c,r),d=o?"back":"fwd";return A.createElement(rv.In,{key:d,duration:t,easing:n,outX:l,outY:a,replayKey:i},h)});Bp.displayName="DirectionalSlideIn";const mne=mh(({outY:e})=>{const r=Gt.durationSlower,t=Gt.curveDecelerateMax;return[to({direction:"exit",duration:r,easing:t}),uc({direction:"exit",duration:r,easing:t,outY:e})]}),vb=A.forwardRef((e,r)=>{const{edge:t,animationDirection:n=il.Vertical,animateBackwards:s,replayKey:o,children:i}=e,c=J_(i,r);if(!(n!==il.Horizontal&&s!==void 0&&(t==="first"?!s:s)))return c;const u=t==="first"?`-${Dh}`:Dh;return A.createElement(mne,{outY:u,replayKey:o},c)});vb.displayName="DirectionalSlideOut";function gne(){const e=A.useRef({});return[e,t=>n=>{n===null?delete e.current[t]:e.current[t]=n}]}function bne(e){const r=A.useRef(void 0);A.useEffect(()=>{r.current=e[0][0].originalDate});const t=r.current;if(!(!t||t.getTime()===e[0][0].originalDate.getTime()))return!(t<=e[0][0].originalDate)}const e7=e=>{const r=A.useRef(null),t=mr(),n=F=>{var V,G;const{firstDayOfWeek:U,minDate:E,maxDate:M,workWeekDays:B,daysToSelectInDayView:k,restrictedDates:_}=e,S={minDate:E,maxDate:M,restrictedDates:_};let T=Mh(F,f,U,B,k);T=Z_(T,E,M),T=T.filter(z=>!Iu(z,S)),(V=e.onSelectDate)===null||V===void 0||V.call(e,F,T),(G=e.onNavigateDate)===null||G===void 0||G.call(e,F,!0)},[s,o]=gne(),i=pne(e,n,o),c=bne(i),[l,a]=Xre(e);A.useImperativeHandle(e.componentRef,()=>({focus(){var F,V;(V=r.current)===null||V===void 0||(F=V.focus)===null||F===void 0||F.call(V)}}),[]);const u=F=>{const V=vne(e.dateRangeType,e.workWeekDays),G=Mh(F.originalDate,V,e.firstDayOfWeek,e.workWeekDays,e.daysToSelectInDayView).map(E=>E.getTime());return i.reduce((E,M)=>E.concat(M.filter(B=>G.indexOf(B.originalDate.getTime())!==-1)),[])},h=F=>{let V=[];return V=F.map(G=>s.current[G.key]),V},{gridLabel:d,dateRangeType:f,showWeekNumbers:m,labelledBy:p,lightenDaysOutsideNavigatedMonth:g,animationDirection:b=il.Vertical}=e,y=dne({lightenDaysOutsideNavigatedMonth:g===void 0?!0:g,showWeekNumbers:m}),w=l(i),C={weeks:i,navigatedDayRef:r,calculateRoundedStyles:a,activeDescendantId:t,classNames:y,weekCorners:w,getDayInfosInRangeOfDay:u,getRefsFromDayInfos:h},N=Mo({axis:"grid-linear"}),I=i[0],$=i[i.length-1],D=I[0].key;return A.createElement("table",{className:de(y.table,e.className),"aria-multiselectable":"false","aria-label":d,"aria-labelledby":p,"aria-activedescendant":t,role:"grid",...N},A.createElement("tbody",null,A.createElement(fne,{...e,classNames:y,weeks:i}),A.createElement(vb,{edge:"first",replayKey:D,animationDirection:b,animateBackwards:c},A.createElement(ah,{...e,...C,week:I,weekIndex:-1,rowClassName:y.firstTransitionWeek,"aria-role":"presentation",ariaHidden:!0})),i.slice(1,i.length-1).map((F,V)=>A.createElement(Bp,{key:V,replayKey:D,animationDirection:b,animateBackwards:c},A.createElement(ah,{...e,...C,week:F,weekIndex:V,rowClassName:y.weekRow}))),A.createElement(vb,{edge:"last",replayKey:D,animationDirection:b,animateBackwards:c},A.createElement(ah,{...e,...C,week:$,weekIndex:-2,rowClassName:y.lastTransitionWeek,"aria-role":"presentation",ariaHidden:!0}))))};e7.displayName="CalendarDayGrid";function vne(e,r){if(r&&e===fo.WorkWeek){const t=r.slice().sort();let n=!0;for(let s=1;s<t.length;s++)if(t[s]!==t[s-1]+1){n=!1;break}if(!n||r.length===0)return fo.Week}return e}const Vl={root:"fui-CalendarDay",header:"fui-CalendarDay__header",monthAndYear:"fui-CalendarDay__monthAndYear",monthComponents:"fui-CalendarDay__monthComponents",headerIconButton:"fui-CalendarDay__headerIconButton",disabledStyle:"fui-CalendarDay__disabledStyle"},yne=ke({base:{B7ck84d:"f1e4lqlz",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1sy4kr4",a9b677:"f4m2ahc"},normalize:{E5pizo:"f1couhl3",B7ck84d:"f1ewtqcl",jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:"f1s184ao",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai"},showWeekNumbers:{a9b677:"fl524qk"}},{d:[".f1e4lqlz{box-sizing:content-box;}",[".f1sy4kr4{padding:12px;}",{p:-1}],".f4m2ahc{width:196px;}",".f1couhl3{box-shadow:none;}",".f1ewtqcl{box-sizing:border-box;}",[".f1s184ao{margin:0;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".fl524qk{width:226px;}"]}),wne=ke({base:{mc9l5x:"ftuwxu6",Bqenvij:"fxldao9",Bg96gwp:"f1vzymgo",qhf8xq:"f10pi13n",a9b677:"fly5x3f"}},{d:[".ftuwxu6{display:inline-flex;}",".fxldao9{height:28px;}",".f1vzymgo{line-height:44px;}",".f10pi13n{position:relative;}",".fly5x3f{width:100%;}"]}),xne=ke({base:{Bt984gj:"f122n59",De3pzq:"f1c21dwh",icvyot:"f1ern45e",vrafjx:["f1n71otn","f1deefiw"],oivjwe:"f1h8hb77",wvpqe5:["f1deefiw","f1n71otn"],Beyfa6y:0,Bbmb7ep:0,Btl43ni:0,B7oj6ja:0,Dimara:"ft85np5",sj55zd:"f19n0e5",mc9l5x:"f14t3ns0",Bh6795r:"fqerorx",Bahqtrf:"f1mo0ibp",Be2twd7:"fkhj508",Bhrd7zp:"fl43uef",Bg96gwp:"f336tjw",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1a3p1vp",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:["f1td8mcv","f1udkdxo"],fsow6f:["f1o700av","fes3tcz"],ygn44y:"f1cmbuwj",Huce71:"fz5stix"},headerIsClickable:{Jwef8y:"f18a0fwf",Bi91k9c:"f3sdaeg",eoavqd:"f8491dx",pugfm4:0,ukgb2i:0,Dwtyhm:0,Biisq0s:"f15rpok4",iro3zm:"f1wvkgvo",B2d53fq:"f1wdoaqd",c3iz72:"f13c0t7h",mghro0:0,Bx68yb:0,syojd9:0,E5hylx:"fy2scak"}},{d:[".f122n59{align-items:center;}",".f1c21dwh{background-color:var(--colorTransparentBackground);}",".f1ern45e{border-top-style:none;}",".f1n71otn{border-right-style:none;}",".f1deefiw{border-left-style:none;}",".f1h8hb77{border-bottom-style:none;}",[".ft85np5{border-radius:var(--borderRadiusMedium);}",{p:-1}],".f19n0e5{color:var(--colorNeutralForeground1);}",".f14t3ns0{display:inline-block;}",".fqerorx{flex-grow:1;}",".f1mo0ibp{font-family:inherit;}",".fkhj508{font-size:var(--fontSizeBase300);}",".fl43uef{font-weight:var(--fontWeightSemibold);}",".f336tjw{line-height:28px;}",[".f1a3p1vp{overflow:hidden;}",{p:-1}],[".f1td8mcv{padding:0 4px 0 10px;}",{p:-1}],[".f1udkdxo{padding:0 10px 0 4px;}",{p:-1}],".f1o700av{text-align:left;}",".fes3tcz{text-align:right;}",".f1cmbuwj{text-overflow:ellipsis;}",".fz5stix{white-space:nowrap;}"],h:[".f18a0fwf:hover{background-color:var(--colorBrandBackgroundInvertedHover);}",".f3sdaeg:hover{color:var(--colorBrandForegroundOnLightHover);}",".f8491dx:hover{cursor:pointer;}",[".f15rpok4:hover{outline:1px solid var(--colorTransparentStroke);}",{p:-1}],".f1wvkgvo:hover:active{background-color:var(--colorBrandBackgroundInvertedPressed);}",".f1wdoaqd:hover:active{color:var(--colorBrandForegroundOnLightPressed);}",".f13c0t7h:hover:active{cursor:pointer;}",[".fy2scak:hover:active{outline:1px solid var(--colorTransparentStroke);}",{p:-1}]]}),kne=ke({base:{qb2dma:"fpydfdc",mc9l5x:"ftuwxu6"}},{d:[".fpydfdc{align-self:flex-end;}",".ftuwxu6{display:inline-flex;}"]}),Sne=ke({base:{De3pzq:"f1c21dwh",icvyot:"f1ern45e",vrafjx:["f1n71otn","f1deefiw"],oivjwe:"f1h8hb77",wvpqe5:["f1deefiw","f1n71otn"],Beyfa6y:0,Bbmb7ep:0,Btl43ni:0,B7oj6ja:0,Dimara:"ft85np5",sj55zd:"f11d4kpn",mc9l5x:"ftgm304",Bahqtrf:"f1mo0ibp",Be2twd7:"fy9rknc",Bqenvij:"fxldao9",Bg96gwp:"f336tjw",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1gl81tg",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai",qhf8xq:"f10pi13n",fsow6f:"f17mccla",a9b677:"f1w9dchk",Jwef8y:"f18a0fwf",Bi91k9c:"f3sdaeg",eoavqd:"f8491dx",pugfm4:0,ukgb2i:0,Dwtyhm:0,Biisq0s:"f15rpok4",iro3zm:"f1wvkgvo",B2d53fq:"f1wdoaqd"}},{d:[".f1c21dwh{background-color:var(--colorTransparentBackground);}",".f1ern45e{border-top-style:none;}",".f1n71otn{border-right-style:none;}",".f1deefiw{border-left-style:none;}",".f1h8hb77{border-bottom-style:none;}",[".ft85np5{border-radius:var(--borderRadiusMedium);}",{p:-1}],".f11d4kpn{color:var(--colorNeutralForeground3);}",".ftgm304{display:block;}",".f1mo0ibp{font-family:inherit;}",".fy9rknc{font-size:var(--fontSizeBase200);}",".fxldao9{height:28px;}",".f336tjw{line-height:28px;}",[".f1gl81tg{overflow:visible;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".f10pi13n{position:relative;}",".f17mccla{text-align:center;}",".f1w9dchk{width:28px;}"],h:[".f18a0fwf:hover{background-color:var(--colorBrandBackgroundInvertedHover);}",".f3sdaeg:hover{color:var(--colorBrandForegroundOnLightHover);}",".f8491dx:hover{cursor:pointer;}",[".f15rpok4:hover{outline:1px solid var(--colorTransparentStroke);}",{p:-1}],".f1wvkgvo:hover:active{background-color:var(--colorBrandBackgroundInvertedPressed);}",".f1wdoaqd:hover:active{color:var(--colorBrandForegroundOnLightPressed);}"]}),_ne=ke({base:{Bg33ivm:"f1oelgmz",t69wg0:"fhh1ekj",Bnh7jwd:"fdb0nwj"}},{d:[".f1oelgmz,.f1oelgmz:disabled,.f1oelgmz button{color:var(--colorNeutralForegroundDisabled);}",".fhh1ekj,.fhh1ekj:disabled,.fhh1ekj button{pointer-events:none;}"],m:[["@media (forced-colors: active){.fdb0nwj,.fdb0nwj:disabled,.fdb0nwj button{color:GrayText;}}",{m:"(forced-colors: active)"}]]}),Cne=e=>{"use no memo";const r=yne(),t=wne(),n=xne(),s=kne(),o=Sne(),i=_ne(),{className:c,headerIsClickable:l,showWeekNumbers:a}=e;return{root:de(Vl.root,r.normalize,r.base,a&&r.showWeekNumbers,c),header:de(Vl.header,t.base),monthAndYear:de(Vl.monthAndYear,n.base,l&&n.headerIsClickable),monthComponents:de(Vl.monthComponents,s.base),headerIconButton:de(Vl.headerIconButton,o.base),disabledStyle:de(Vl.disabledStyle,i.base)}},t7=e=>{const r=A.useRef(null);A.useImperativeHandle(e.componentRef,()=>({focus(){var N,I;(I=r.current)===null||I===void 0||(N=I.focus)===null||N===void 0||N.call(I)}}),[]);const{strings:t,gridLabel:n,navigatedDate:s,dateTimeFormatter:o,className:i,onHeaderSelect:c,showSixWeeksByDefault:l,minDate:a,maxDate:u,restrictedDates:h,onNavigateDate:d,showWeekNumbers:f,dateRangeType:m,animationDirection:p=il.Vertical}=e,g=Cne({className:i,headerIsClickable:!!c,showWeekNumbers:f}),b=o.formatMonthYear(s,t),y=c?"button":"div",w=t.yearPickerHeaderAriaLabel?t.yearPickerHeaderAriaLabel.replace("{0}",b):b,{...C}=e;return A.createElement("div",{className:g.root},A.createElement("div",{className:g.header},A.createElement(y,{"aria-label":c?w:void 0,className:g.monthAndYear,onClick:c,tabIndex:c?0:-1,onKeyDown:sh(c),type:"button"},A.createElement("span",{"aria-live":"polite","aria-atomic":"true"},b)),A.createElement(r7,{...e,classNames:g})),A.createElement(e7,{...C,gridLabel:`${b}, ${n}`,componentRef:r,strings:t,navigatedDate:s,weeksToShow:l?6:void 0,dateTimeFormatter:o,minDate:a,maxDate:u,restrictedDates:h,onNavigateDate:d,dateRangeType:m}))};t7.displayName="CalendarDay";const r7=e=>{const{minDate:r,maxDate:t,navigatedDate:n,navigationIcons:s,allFocusable:o,strings:i,showCloseButton:c,classNames:l,onNavigateDate:a,onDismiss:u}=e,h=()=>{a(Ja(n,1),!1)},d=()=>{a(Ja(n,-1),!1)},f=r?eo(r,G_(n))<0:!0,m=t?eo(K_(n),t)<0:!0;return A.createElement("div",{className:l.monthComponents},A.createElement("button",{className:de(l.headerIconButton,!f&&l.disabledStyle),tabIndex:f?void 0:o?0:-1,"aria-disabled":!f,onClick:f?d:void 0,onKeyDown:f?sh(d):void 0,title:i.prevMonthAriaLabel?i.prevMonthAriaLabel+" "+i.months[Ja(n,-1).getMonth()]:void 0,type:"button"},s.upNavigation),A.createElement("button",{className:de(l.headerIconButton,!m&&l.disabledStyle),tabIndex:m?void 0:o?0:-1,"aria-disabled":!m,onClick:m?h:void 0,onKeyDown:m?sh(h):void 0,title:i.nextMonthAriaLabel?i.nextMonthAriaLabel+" "+i.months[Ja(n,1).getMonth()]:void 0,type:"button"},s.downNavigation),c&&A.createElement("button",{className:l.headerIconButton,onClick:u,onKeyDown:sh(u),title:i.closeButtonAriaLabel,type:"button"},s.dismiss))};r7.displayName="CalendarDayNavigationButtons";const sh=e=>r=>{r.key===gn&&e?.()},mi={root:"fui-CalendarPicker",headerContainer:"fui-CalendarPicker__headerContainer",currentItemButton:"fui-CalendarPicker__currentItemButton",navigationButtonsContainer:"fui-CalendarPicker__navigationButtonsContainer",navigationButton:"fui-CalendarPicker__navigationButton",gridContainer:"fui-CalendarPicker__gridContainer",buttonRow:"fui-CalendarPicker__buttonRow",itemButton:"fui-CalendarPicker__itemButton",current:"fui-CalendarPicker__current",selected:"fui-CalendarPicker__selected",disabled:"fui-CalendarPicker__disabled"},Tne=ke({base:{B7ck84d:"f1e4lqlz",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1a3p1vp",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1sy4kr4",a9b677:"f4m2ahc"},normalize:{E5pizo:"f1couhl3",B7ck84d:"f1ewtqcl",jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:"f1s184ao",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai"}},{d:[".f1e4lqlz{box-sizing:content-box;}",[".f1a3p1vp{overflow:hidden;}",{p:-1}],[".f1sy4kr4{padding:12px;}",{p:-1}],".f4m2ahc{width:196px;}",".f1couhl3{box-shadow:none;}",".f1ewtqcl{box-sizing:border-box;}",[".f1s184ao{margin:0;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}]]}),Bne=ke({base:{mc9l5x:"f22iagw"}},{d:[".f22iagw{display:flex;}"]}),jne=ke({base:{De3pzq:"f1c21dwh",icvyot:"f1ern45e",vrafjx:["f1n71otn","f1deefiw"],oivjwe:"f1h8hb77",wvpqe5:["f1deefiw","f1n71otn"],Beyfa6y:0,Bbmb7ep:0,Btl43ni:0,B7oj6ja:0,Dimara:"ft85np5",sj55zd:"f1ym3bx4",Bh6795r:"fqerorx",Bahqtrf:"f1mo0ibp",Be2twd7:"fkhj508",Bhrd7zp:"fl43uef",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1gl81tg",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:["f1td8mcv","f1udkdxo"],fsow6f:["f1o700av","fes3tcz"]},hasHeaderClickCallback:{Jwef8y:"f18a0fwf",Bi91k9c:"f3sdaeg",eoavqd:"f8491dx",pugfm4:0,ukgb2i:0,Dwtyhm:0,Biisq0s:"f15rpok4",iro3zm:"f1wvkgvo",B2d53fq:"f1wdoaqd",c3iz72:"f13c0t7h",mghro0:0,Bx68yb:0,syojd9:0,E5hylx:"fy2scak"}},{d:[".f1c21dwh{background-color:var(--colorTransparentBackground);}",".f1ern45e{border-top-style:none;}",".f1n71otn{border-right-style:none;}",".f1deefiw{border-left-style:none;}",".f1h8hb77{border-bottom-style:none;}",[".ft85np5{border-radius:var(--borderRadiusMedium);}",{p:-1}],".f1ym3bx4{color:inherit;}",".fqerorx{flex-grow:1;}",".f1mo0ibp{font-family:inherit;}",".fkhj508{font-size:var(--fontSizeBase300);}",".fl43uef{font-weight:var(--fontWeightSemibold);}",[".f1gl81tg{overflow:visible;}",{p:-1}],[".f1td8mcv{padding:0 4px 0 10px;}",{p:-1}],[".f1udkdxo{padding:0 10px 0 4px;}",{p:-1}],".f1o700av{text-align:left;}",".fes3tcz{text-align:right;}"],h:[".f18a0fwf:hover{background-color:var(--colorBrandBackgroundInvertedHover);}",".f3sdaeg:hover{color:var(--colorBrandForegroundOnLightHover);}",".f8491dx:hover{cursor:pointer;}",[".f15rpok4:hover{outline:1px solid var(--colorTransparentStroke);}",{p:-1}],".f1wvkgvo:hover:active{background-color:var(--colorBrandBackgroundInvertedPressed);}",".f1wdoaqd:hover:active{color:var(--colorBrandForegroundOnLightPressed);}",".f13c0t7h:hover:active{cursor:pointer;}",[".fy2scak:hover:active{outline:1px solid var(--colorTransparentStroke);}",{p:-1}]]}),Nne=ke({base:{Bt984gj:"f122n59",mc9l5x:"f22iagw"}},{d:[".f122n59{align-items:center;}",".f22iagw{display:flex;}"]}),Ene=ke({base:{De3pzq:"f1c21dwh",Bgfg5da:0,B9xav0g:0,oivjwe:0,Bn0qgzm:0,B4g9neb:0,zhjwy3:0,wvpqe5:0,ibv6hh:0,u1mtju:0,h3c5rm:0,vrafjx:0,Bekrc4i:0,i8vvqc:0,g2u3we:0,icvyot:0,B4j52fo:0,irswps:"f3bhgqh",Beyfa6y:0,Bbmb7ep:0,Btl43ni:0,B7oj6ja:0,Dimara:"ft85np5",sj55zd:"f19n0e5",mc9l5x:"ftgm304",Bahqtrf:"f1mo0ibp",Be2twd7:"fy9rknc",Bqenvij:"fxldao9",Bg96gwp:"f336tjw",sshi5w:"f1ysfysz",Bf4jedk:"f107v6xj",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1gl81tg",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai",qhf8xq:"f10pi13n",fsow6f:"f17mccla",a9b677:"f1w9dchk",Jwef8y:"f18a0fwf",Bi91k9c:"f3sdaeg",eoavqd:"f8491dx",pugfm4:0,ukgb2i:0,Dwtyhm:0,Biisq0s:"f15rpok4",iro3zm:"f1wvkgvo",B2d53fq:"f1wdoaqd"}},{d:[".f1c21dwh{background-color:var(--colorTransparentBackground);}",[".f3bhgqh{border:none;}",{p:-2}],[".ft85np5{border-radius:var(--borderRadiusMedium);}",{p:-1}],".f19n0e5{color:var(--colorNeutralForeground1);}",".ftgm304{display:block;}",".f1mo0ibp{font-family:inherit;}",".fy9rknc{font-size:var(--fontSizeBase200);}",".fxldao9{height:28px;}",".f336tjw{line-height:28px;}",".f1ysfysz{min-height:28px;}",".f107v6xj{min-width:28px;}",[".f1gl81tg{overflow:visible;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".f10pi13n{position:relative;}",".f17mccla{text-align:center;}",".f1w9dchk{width:28px;}"],h:[".f18a0fwf:hover{background-color:var(--colorBrandBackgroundInvertedHover);}",".f3sdaeg:hover{color:var(--colorBrandForegroundOnLightHover);}",".f8491dx:hover{cursor:pointer;}",[".f15rpok4:hover{outline:1px solid var(--colorTransparentStroke);}",{p:-1}],".f1wvkgvo:hover:active{background-color:var(--colorBrandBackgroundInvertedPressed);}",".f1wdoaqd:hover:active{color:var(--colorBrandForegroundOnLightPressed);}"]}),Ane=ke({base:{B6of3ja:"fvjh0tl"}},{d:[".fvjh0tl{margin-top:4px;}"]}),Rne=ke({base:{jrapky:"f15tpi3i",sw9gdo:"f1gdbdba"}},{d:[".f15tpi3i{margin-bottom:16px;}",".f1gdbdba:last-of-type{margin-bottom:0;}"]}),zne=ke({base:{De3pzq:"f1c21dwh",Bgfg5da:0,B9xav0g:0,oivjwe:0,Bn0qgzm:0,B4g9neb:0,zhjwy3:0,wvpqe5:0,ibv6hh:0,u1mtju:0,h3c5rm:0,vrafjx:0,Bekrc4i:0,i8vvqc:0,g2u3we:0,icvyot:0,B4j52fo:0,irswps:"f3bhgqh",Beyfa6y:0,Bbmb7ep:0,Btl43ni:0,B7oj6ja:0,Dimara:"ft85np5",sj55zd:"f11d4kpn",Bahqtrf:"f1mo0ibp",Be2twd7:"fy9rknc",Bqenvij:"fbhnoac",Bg96gwp:"fc76cdq",sshi5w:"f1w5jphr",Bf4jedk:"f12clzc2",jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:["f1ytixos","fqk6p8t"],B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1gl81tg",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai",a9b677:"feqmc2u",Btgfwho:["f65zstl","f1yt3tqw"],xrote9:"flfbxit",Bja5ulm:"ff5vbxt",Jwef8y:"f18a0fwf",Bi91k9c:"f1u69ym5",eoavqd:"f8491dx",pugfm4:0,ukgb2i:0,Dwtyhm:0,Biisq0s:"f15rpok4",Bbkh6qg:"fse5cfe",Bahaeuw:"f1d0gba8",fmph8g:"fj239l",Bv6y5q5:0,uq1ffc:0,Bokaozi:0,Bfrni1f:"f1szuehs",iro3zm:"f1wvkgvo",rxnm8d:"f1n99sc9",Dcq74g:"fqfbdvs",Bs60fxl:"f12gwge8"}},{d:[".f1c21dwh{background-color:var(--colorTransparentBackground);}",[".f3bhgqh{border:none;}",{p:-2}],[".ft85np5{border-radius:var(--borderRadiusMedium);}",{p:-1}],".f11d4kpn{color:var(--colorNeutralForeground3);}",".f1mo0ibp{font-family:inherit;}",".fy9rknc{font-size:var(--fontSizeBase200);}",".fbhnoac{height:40px;}",".fc76cdq{line-height:40px;}",".f1w5jphr{min-height:40px;}",".f12clzc2{min-width:40px;}",[".f1ytixos{margin:0 12px 0 0;}",{p:-1}],[".fqk6p8t{margin:0 0 0 12px;}",{p:-1}],[".f1gl81tg{overflow:visible;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".feqmc2u{width:40px;}",".f65zstl:nth-child(4n + 4){margin-right:0;}",".f1yt3tqw:nth-child(4n + 4){margin-left:0;}",".flfbxit:nth-child(n + 9){margin-bottom:0;}",".ff5vbxt div{font-weight:var(--fontWeightRegular);}"],h:[".f18a0fwf:hover{background-color:var(--colorBrandBackgroundInvertedHover);}",".f1u69ym5:hover{color:var(--colorNeutralForeground1Static);}",".f8491dx:hover{cursor:pointer;}",[".f15rpok4:hover{outline:1px solid var(--colorTransparentStroke);}",{p:-1}],".f1wvkgvo:hover:active{background-color:var(--colorBrandBackgroundInvertedPressed);}"],m:[["@media (forced-colors: active){.fse5cfe:hover{background-color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1d0gba8:hover{color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fj239l:hover{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1szuehs:hover{outline:1px solid Highlight;}}",{p:-1,m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1n99sc9:hover:active{background-color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fqfbdvs:hover:active{color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f12gwge8:hover:active{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}]]}),Ine=ke({highlightCurrent:{De3pzq:"ffp7eso",sj55zd:"f1phragk",Bhrd7zp:"fl43uef",By8wz76:"fq1p4f3",B7iucu3:"fygpdla",B8gzw0y:"f1h3a8gf",mk428o:"ffic4m0",B1lrsqs:"f13lyc4l",B1piyhd:"f1cnwl3o",of3gr0:"f1w17wdy",hvfrz3:"fx2qnub"}},{d:[".ffp7eso{background-color:var(--colorBrandBackground);}",".f1phragk{color:var(--colorNeutralForegroundOnBrand);}",".fl43uef{font-weight:var(--fontWeightSemibold);}"],m:[["@media (forced-colors: active){.fq1p4f3{background-color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fygpdla{color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1h3a8gf{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1cnwl3o:hover,.f1cnwl3o:hover:active{background-color:WindowText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1w17wdy:hover,.f1w17wdy:hover:active{color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fx2qnub:hover,.fx2qnub:hover:active{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}]],h:[".ffic4m0:hover,.ffic4m0:hover:active{background-color:var(--colorBrandBackground);}",".f13lyc4l:hover,.f13lyc4l:hover:active{color:var(--colorNeutralForegroundOnBrand);}"]}),Mne=ke({highlightSelected:{De3pzq:"f1vevd59",sj55zd:"ff5vbop",Bhrd7zp:"fl43uef",By8wz76:"f1nz3ub2",B7iucu3:"fygpdla",B8gzw0y:"f1h3a8gf",Bja5ulm:"fospawf",Jwef8y:"fbo057p",Bi91k9c:"f1u69ym5",Bbkh6qg:"f1tx4pjd",Bahaeuw:"fn03n9l",fmph8g:"fj239l",iro3zm:"f1wvkgvo"}},{d:[".f1vevd59{background-color:var(--colorBrandBackgroundInvertedSelected);}",".ff5vbop{color:var(--colorNeutralForeground1Static);}",".fl43uef{font-weight:var(--fontWeightSemibold);}",".fospawf div{font-weight:var(--fontWeightSemibold);}"],m:[["@media (forced-colors: active){.f1nz3ub2{background-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fygpdla{color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1h3a8gf{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1tx4pjd:hover{background-color:Highlight;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fn03n9l:hover{color:Window;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.fj239l:hover{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}]],h:[".fbo057p:hover{background-color:var(--colorBrandBackgroundInvertedSelected);}",".f1u69ym5:hover{color:var(--colorNeutralForeground1Static);}",".f1wvkgvo:hover:active{background-color:var(--colorBrandBackgroundInvertedPressed);}"]}),Dne=ke({base:{Bg33ivm:"f1oelgmz",t69wg0:"fhh1ekj",B7iucu3:"f1cyfu5x",B8gzw0y:"f1h3a8gf"}},{d:[".f1oelgmz,.f1oelgmz:disabled,.f1oelgmz button{color:var(--colorNeutralForegroundDisabled);}",".fhh1ekj,.fhh1ekj:disabled,.fhh1ekj button{pointer-events:none;}"],m:[["@media (forced-colors: active){.f1cyfu5x{color:GrayText;}}",{m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1h3a8gf{forced-color-adjust:none;}}",{m:"(forced-colors: active)"}]]}),n7=e=>{"use no memo";const r=Tne(),t=Bne(),n=jne(),s=Nne(),o=Ene(),i=Ane(),c=Rne(),l=zne(),a=Ine(),u=Mne(),h=Dne(),{className:d,hasHeaderClickCallback:f,highlightCurrent:m,highlightSelected:p}=e;return{root:de(mi.root,r.normalize,r.base,d),headerContainer:de(mi.headerContainer,t.base),currentItemButton:de(mi.currentItemButton,n.base,f&&n.hasHeaderClickCallback),navigationButtonsContainer:de(mi.navigationButtonsContainer,s.base),navigationButton:de(mi.navigationButton,o.base),gridContainer:de(mi.gridContainer,i.base),buttonRow:de(mi.buttonRow,c.base),itemButton:de(mi.itemButton,l.base),selected:de(mi.selected,p&&u.highlightSelected),current:de(mi.current,m&&a.highlightCurrent),disabled:de(mi.disabled,h.base)}},dl=e=>{"use no memo";return n7(e)},nc=12,H5=4,o7={prevRangeAriaLabel:void 0,nextRangeAriaLabel:void 0},i7=e=>{const{className:r,highlightCurrentYear:t,highlightSelectedYear:n,year:s,selected:o,disabled:i,componentRef:c,onSelectYear:l,onRenderYear:a}=e,u=A.useRef(null);A.useImperativeHandle(c,()=>({focus(){var p,g;(g=u.current)===null||g===void 0||(p=g.focus)===null||p===void 0||p.call(g)}}),[]);const h=()=>{l?.(s)},d=p=>{p.key===gn&&l?.(s)},f=dl({className:r,highlightCurrent:t,highlightSelected:n});var m;return A.createElement("button",{className:de(f.itemButton,o&&f.selected,i&&f.disabled),type:"button",role:"gridcell",onClick:i?void 0:h,onKeyDown:i?void 0:d,disabled:i,"aria-selected":o,ref:u},(m=a?.(s))!==null&&m!==void 0?m:s)};i7.displayName="CalendarYearGridCell";const a7=e=>{const{className:r,fromYear:t,toYear:n,animationDirection:s,animateBackwards:o,minYear:i,maxYear:c,onSelectYear:l,selectedYear:a,componentRef:u}=e,h=A.useRef(null),d=A.useRef(null);A.useImperativeHandle(u,()=>({focus(){var C,N;(N=h.current||d.current)===null||N===void 0||(C=N.focus)===null||C===void 0||C.call(N)}}),[]);const f=C=>{const N=C===a,I=i!==void 0&&C<i||c!==void 0&&C>c,$=C===new Date().getFullYear();return A.createElement(i7,{...e,key:C,year:C,selected:N,current:$,disabled:I,onSelectYear:l,componentRef:N?h:$?d:void 0})},m=dl({className:r}),p=C=>{var N,I;return(I=(N=e.onRenderYear)===null||N===void 0?void 0:N.call(e,C))!==null&&I!==void 0?I:C},g=`${p(t)} - ${p(n)}`;let b=t;const y=[];for(let C=0;C<(n-t+1)/H5;C++){y.push([]);for(let N=0;N<H5;N++)y[C].push(f(b)),b++}const w=Mo({axis:"grid"});return A.createElement("div",{...w,className:m.gridContainer,role:"grid","aria-label":g},y.map((C,N)=>A.createElement(Bp,{key:N,replayKey:t,animationDirection:s,animateBackwards:o},A.createElement("div",{role:"row",className:m.buttonRow},C))))};a7.displayName="CalendarYearGrid";const Ls={Previous:0,Next:1},yb=e=>{const{className:r,strings:t=o7,direction:n,onSelectPrev:s,onSelectNext:o,fromYear:i,toYear:c,maxYear:l,minYear:a,navigationIcons:u}=e,h=dl({className:r}),d=n===Ls.Previous?t.prevRangeAriaLabel:t.nextRangeAriaLabel,f=n===Ls.Previous?-nc:nc,m={fromYear:i+f,toYear:c+f},p=d?typeof d=="string"?d:d(m):void 0,g=n===Ls.Previous?a!==void 0&&i<a:l!==void 0&&e.fromYear+nc>l,b=()=>{n===Ls.Previous?s?.():o?.()},y=w=>{w.key===gn&&b()};return A.createElement("button",{className:de(h.navigationButton,g&&h.disabled),"aria-disabled":g,tabIndex:g?-1:void 0,onClick:g?void 0:b,onKeyDown:g?void 0:y,type:"button",title:p},n===Ls.Previous?u.upNavigation:u.downNavigation)};yb.displayName="CalendarYearNavArrow";const s7=e=>{const{className:r}=e,t=dl({className:r});return A.createElement("div",{className:t.navigationButtonsContainer},A.createElement(yb,{...e,direction:Ls.Previous}),A.createElement(yb,{...e,direction:Ls.Next}))};s7.displayName="CalendarYearNav";const l7=e=>{const{className:r,fromYear:t,toYear:n,strings:s=o7,animateBackwards:o,animationDirection:i}=e,c=()=>{var h;(h=e.onHeaderSelect)===null||h===void 0||h.call(e,!0)},l=h=>{(h.key===gn||h.key===In)&&c()},a=h=>{var d,f;return(f=(d=e.onRenderYear)===null||d===void 0?void 0:d.call(e,h))!==null&&f!==void 0?f:h},u=dl({className:r,hasHeaderClickCallback:!!e.onHeaderSelect});if(e.onHeaderSelect){const h=s.rangeAriaLabel,d=s.headerAriaLabelFormatString,f=h?typeof h=="string"?h:h(e):void 0,m=d?d.replace("{0}",f??""):f;return A.createElement("button",{className:u.currentItemButton,onClick:c,onKeyDown:l,"aria-label":m,role:"button",type:"button"},A.createElement("span",{"aria-live":"assertive","aria-atomic":"true"},a(t)," - ",a(n)))}return A.createElement("div",{className:u.current},a(t)," - ",a(n))};l7.displayName="CalendarYearTitle";const c7=e=>{const{className:r,animateBackwards:t,animationDirection:n,onRenderTitle:s}=e,o=dl({className:r,hasHeaderClickCallback:!!e.onHeaderSelect});var i;return A.createElement("div",{className:o.headerContainer},(i=s?.(e))!==null&&i!==void 0?i:A.createElement(l7,e),A.createElement(s7,e))};c7.displayName="CalendarYearHeader";function Pne(e){const r=A.useRef(void 0);A.useEffect(()=>{r.current=e});const t=r.current;if(!(t===void 0||t===e))return t>e}function One({selectedYear:e,navigatedYear:r,onNavigateDate:t}){const n=A.useMemo(()=>e||r||Math.floor(new Date().getFullYear()/10)*10,[r,e]),[s,o]=A.useState(n),i=()=>{const a=s+nc;o(a),t?.(a)},c=()=>{const a=s-nc;o(a),t?.(a)};A.useEffect(()=>{o(n)},[n]);const l=s+nc-1;return[s,l,i,c]}const u7=e=>{const[r,t,n,s]=One(e),o=Pne(r),i=A.useRef(null);A.useImperativeHandle(e.componentRef,()=>({focus(){var a,u;(u=i.current)===null||u===void 0||(a=u.focus)===null||a===void 0||a.call(u)}}));const{className:c}=e,l=dl({className:c});return A.createElement("div",{className:l.root},A.createElement(c7,{...e,fromYear:r,toYear:t,onSelectPrev:s,onSelectNext:n,animateBackwards:o}),A.createElement(a7,{...e,fromYear:r,toYear:t,animateBackwards:o,componentRef:i}))};u7.displayName="CalendarYear";const Fne=e=>{"use no memo";return n7(e)},$f=4;function qne({navigatedDate:e}){const r=e.getFullYear(),t=A.useRef(void 0);A.useEffect(()=>{t.current=r});const n=t.current;if(!(n===void 0||n===r))return n>r}function Lne({componentRef:e}){const r=A.useRef(null),t=A.useRef(null),n=A.useRef(!1),s=A.useCallback(()=>{t.current?t.current.focus():r.current&&r.current.focus()},[]);return A.useImperativeHandle(e,()=>({focus:s}),[s]),A.useEffect(()=>{n.current&&(s(),n.current=!1)}),[r,t,()=>{n.current=!0}]}const d7=e=>{const{allFocusable:r,animationDirection:t=il.Vertical,className:n,componentRef:s,dateTimeFormatter:o=U_,highlightCurrentMonth:i,highlightSelectedMonth:c,maxDate:l,minDate:a,navigatedDate:u,navigationIcons:h,onHeaderSelect:d,onNavigateDate:f,selectedDate:m,strings:p,today:g=new Date,yearPickerHidden:b=!1}=e,[y,w,C]=Lne({componentRef:s}),[N,I]=A.useState(!1),$=qne({navigatedDate:u}),D=X=>()=>G(X),F=()=>{f(Ql(u,1),!1)},V=()=>{f(Ql(u,-1),!1)},G=X=>{d?.(),f(Lf(u,X),!0)},U=()=>{b?d?.():(C(),I(!0))},E=X=>{if(C(),u.getFullYear()!==X){let J=new Date(u.getTime());J.setFullYear(X),l&&J>l?J=Lf(J,l.getMonth()):a&&J<a&&(J=Lf(J,a.getMonth())),f(J,!0)}I(!1)},M=X=>{C(),I(!1)},B=o,k=a?eo(a,Ire(u))<0:!0,_=l?eo(Mre(u),l)<0:!0,S=Fne({className:n,hasHeaderClickCallback:!!d||!b,highlightCurrent:i,highlightSelected:c}),T=Mo({axis:"grid"});if(N){const[X,K]=$ne({dateTimeFormatter:o,navigatedDate:u,strings:p});return A.createElement(u7,{key:"calendarYear",minYear:a?a.getFullYear():void 0,maxYear:l?l.getFullYear():void 0,onSelectYear:E,onHeaderSelect:M,selectedYear:m?m.getFullYear():u?u.getFullYear():void 0,navigatedYear:u.getFullYear(),navigationIcons:h,onRenderYear:X,strings:K,componentRef:w,highlightCurrentYear:i,highlightSelectedYear:c,animationDirection:t})}const z=[];for(let X=0;X<p.shortMonths.length/$f;X++)z.push(X);const P=B.formatYear(u),O=p.monthPickerHeaderAriaLabel?p.monthPickerHeaderAriaLabel.replace("{0}",P):P;return A.createElement("div",{className:S.root},A.createElement("div",{className:S.headerContainer},A.createElement("button",{className:S.currentItemButton,onClick:U,onKeyDown:Hf(U),"aria-label":O,tabIndex:d||!b?0:-1,type:"button"},A.createElement("span",{"aria-live":"polite","aria-atomic":"true"},P)),A.createElement("div",{className:S.navigationButtonsContainer},A.createElement("button",{className:de(S.navigationButton,!k&&S.disabled),"aria-disabled":!k,tabIndex:k?void 0:r?0:-1,onClick:k?V:void 0,onKeyDown:k?Hf(V):void 0,title:p.prevYearAriaLabel?p.prevYearAriaLabel+" "+B.formatYear(Ql(u,-1)):void 0,type:"button"},h.upNavigation),A.createElement("button",{className:de(S.navigationButton,!_&&S.disabled),"aria-disabled":!_,tabIndex:_?void 0:r?0:-1,onClick:_?F:void 0,onKeyDown:_?Hf(F):void 0,title:p.nextYearAriaLabel?p.nextYearAriaLabel+" "+B.formatYear(Ql(u,1)):void 0,type:"button"},h.downNavigation))),A.createElement("div",{...T,className:S.gridContainer,role:"grid","aria-label":P},z.map(X=>{const K=p.shortMonths.slice(X*$f,(X+1)*$f);return A.createElement(Bp,{key:X,replayKey:u.getFullYear(),animationDirection:t,animateBackwards:$},A.createElement("div",{role:"row",className:S.buttonRow},K.map((J,H)=>{const Z=X*$f+H,L=Lf(u,Z),q=u.getMonth()===Z,Y=m.getMonth()===Z,re=m.getFullYear()===u.getFullYear(),ie=(a?eo(a,K_(L))<1:!0)&&(l?eo(G_(L),l)<1:!0);return A.createElement("button",{ref:q?y:void 0,role:"gridcell",className:de(S.itemButton,i&&Hne(Z,u.getFullYear(),g)&&S.current,c&&Y&&re&&S.selected,!ie&&S.disabled),disabled:!r&&!ie,key:Z,onClick:ie?D(Z):void 0,onKeyDown:ie?Hf(D(Z)):void 0,"aria-label":B.formatMonth(L,p),"aria-selected":q,tabIndex:ie?0:-1,type:"button"},J)})))})))};d7.displayName="CalendarMonth";function $ne({dateTimeFormatter:e,navigatedDate:r,strings:t}){const n=c=>{if(e){const l=new Date(r.getTime());return l.setFullYear(c),e.formatYear(l)}return String(c)},s=c=>`${n(c.fromYear)} - ${n(c.toYear)}`;return[n,{rangeAriaLabel:s,prevRangeAriaLabel:c=>t.prevYearRangeAriaLabel?`${t.prevYearRangeAriaLabel} ${s(c)}`:"",nextRangeAriaLabel:c=>t.nextYearRangeAriaLabel?`${t.nextYearRangeAriaLabel} ${s(c)}`:"",headerAriaLabelFormatString:t.monthPickerHeaderAriaLabel}]}function Hne(e,r,t){return t.getFullYear()===r&&t.getMonth()===e}function Hf(e){return r=>{r.key===gn&&e()}}const V5={dismiss:A.createElement(sl,null),downNavigation:A.createElement(h4,null),upNavigation:A.createElement(p4,null)},ku={root:"fui-Calendar",divider:"fui-Calendar__divider",goTodayButton:"fui-Calendar__goTodayButton",monthPickerWrapper:"fui-Calendar__monthPickerWrapper",liveRegion:"fui-Calendar__liveRegion"},Vne=ke({base:{mc9l5x:"f22iagw",a9b677:"f13dwy2t"},normalize:{E5pizo:"f1couhl3",B7ck84d:"f1ewtqcl",jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:"f1s184ao",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai"},monthPickerNotVisible:{Beiy3e4:"f1vx9l62"},dayAndMonthPickersVisible:{a9b677:"fcy5b15"},dayPickerVisibleAndWeekNumbersShown:{a9b677:"fhsg0in"},dayAndMonthPickersVisibleAndWeekNumbersShown:{a9b677:"fcarq7f"}},{d:[".f22iagw{display:flex;}",".f13dwy2t{width:220px;}",".f1couhl3{box-shadow:none;}",".f1ewtqcl{box-sizing:border-box;}",[".f1s184ao{margin:0;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".f1vx9l62{flex-direction:column;}",".fcy5b15{width:440px;}",".fhsg0in{width:250px;}",".fcarq7f{width:470px;}"]}),Wne=ke({base:{h3c5rm:0,vrafjx:0,Bekrc4i:0,u1mtju:["fe2nn5g","f1rcbay7"],Bhzewxz:"f15twtuk"}},{d:[[".fe2nn5g{border-right:1px solid var(--colorNeutralStroke2);}",{p:-1}],[".f1rcbay7{border-left:1px solid var(--colorNeutralStroke2);}",{p:-1}],".f15twtuk{top:0;}"]}),Une=ke({base:{mc9l5x:"f22iagw",Beiy3e4:"f1vx9l62"}},{d:[".f22iagw{display:flex;}",".f1vx9l62{flex-direction:column;}"]}),Xne=ke({base:{qb2dma:"fpydfdc",De3pzq:"f1c21dwh",icvyot:"f1ern45e",vrafjx:["f1n71otn","f1deefiw"],oivjwe:"f1h8hb77",wvpqe5:["f1deefiw","f1n71otn"],B5kzvoi:"f1yab3r1",B7ck84d:"f1e4lqlz",sj55zd:"f19n0e5",Bahqtrf:"f1mo0ibp",Be2twd7:"fy9rknc",Bqenvij:"f1tvdnth",Bg96gwp:"fpfng1i",t21cq0:["f17vyym1","fb5scp"],B6of3ja:"f4gg0ds",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1gl81tg",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1p2x7z2",seuwu7:"fvy6vk6",Jwef8y:"f9ql6rf",Bi91k9c:"f1f1pb61",eoavqd:"f8491dx",Bv6y5q5:0,uq1ffc:0,Bokaozi:0,Bfrni1f:"f14aog0w",Bkzqrjd:0,hu2duy:0,n9pfp1:0,dfw8yp:0,qugvs6:"f1fgm6o",B2d53fq:"fc9d3oc",Dyrjrp:"f1cqwcg4",Be90el1:"fmjaa5u"}},{d:[".fpydfdc{align-self:flex-end;}",".f1c21dwh{background-color:var(--colorTransparentBackground);}",".f1ern45e{border-top-style:none;}",".f1n71otn{border-right-style:none;}",".f1deefiw{border-left-style:none;}",".f1h8hb77{border-bottom-style:none;}",".f1yab3r1{bottom:0;}",".f1e4lqlz{box-sizing:content-box;}",".f19n0e5{color:var(--colorNeutralForeground1);}",".f1mo0ibp{font-family:inherit;}",".fy9rknc{font-size:var(--fontSizeBase200);}",".f1tvdnth{height:30px;}",".fpfng1i{line-height:30px;}",".f17vyym1{margin-right:16px;}",".fb5scp{margin-left:16px;}",".f4gg0ds{margin-top:3px;}",[".f1gl81tg{overflow:visible;}",{p:-1}],[".f1p2x7z2{padding:0 4px;}",{p:-1}],".fvy6vk6 div{font-size:var(--fontSizeBase200);}",".f1cqwcg4:disabled{color:var(--colorNeutralForegroundDisabled);}",".fmjaa5u:disabled{pointer-events:none;}"],h:[".f9ql6rf:hover{background-color:var(--colorTransparentBackground);}",".f1f1pb61:hover{color:var(--colorBrandForeground1);}",".f8491dx:hover{cursor:pointer;}",".fc9d3oc:hover:active{color:var(--colorBrandForeground2);}"],m:[["@media (forced-colors: active){.f14aog0w:hover{outline:var(--strokeWidthThin);}}",{p:-1,m:"(forced-colors: active)"}],["@media (forced-colors: active){.f1fgm6o:hover{border-radius:var(--borderRadiusSmall);}}",{p:-1,m:"(forced-colors: active)"}]]}),Gne=ke({base:{Bgfg5da:0,B9xav0g:0,oivjwe:0,Bn0qgzm:0,B4g9neb:0,zhjwy3:0,wvpqe5:0,ibv6hh:0,u1mtju:0,h3c5rm:0,vrafjx:0,Bekrc4i:0,i8vvqc:0,g2u3we:0,icvyot:0,B4j52fo:0,irswps:"f3bhgqh",Bqenvij:"f1mpe4l3",jrapky:0,Frg6f3:0,t21cq0:0,B6of3ja:0,B74szlk:"f1jlpb2r",B68tc82:0,Bmxbyg5:0,Bpg54ce:"f1a3p1vp",Byoj8tv:0,uwmqm3:0,z189sj:0,z8tnut:0,B0ocmuz:"f1mk8lai",qhf8xq:"f1euv43f",a9b677:"frkrog8"}},{d:[[".f3bhgqh{border:none;}",{p:-2}],".f1mpe4l3{height:1px;}",[".f1jlpb2r{margin:-1px;}",{p:-1}],[".f1a3p1vp{overflow:hidden;}",{p:-1}],[".f1mk8lai{padding:0;}",{p:-1}],".f1euv43f{position:absolute;}",".frkrog8{width:1px;}"]}),Kne=e=>{"use no memo";const r=Vne(),t=Wne(),n=Une(),s=Xne(),o=Gne(),{className:i,isDayPickerVisible:c,isMonthPickerVisible:l,showWeekNumbers:a}=e;return{root:de(ku.root,r.base,r.normalize,!l&&r.monthPickerNotVisible,c&&l&&!a&&r.dayAndMonthPickersVisible,c&&!l&&a&&r.dayPickerVisibleAndWeekNumbersShown,c&&l&&a&&r.dayAndMonthPickersVisibleAndWeekNumbersShown,i),divider:de(ku.divider,t.base),monthPickerWrapper:de(ku.monthPickerWrapper,n.base),goTodayButton:de(ku.goTodayButton,s.base),liveRegion:de(ku.liveRegion,o.base)}},Yne=440,Qne=[jo.Monday,jo.Tuesday,jo.Wednesday,jo.Thursday,jo.Friday];function Zne(e){const{value:r,today:t,onSelectDate:n}=e,s=A.useMemo(()=>t??new Date,[t]),[o,i]=Wr({state:r,defaultState:r?void 0:s,initialState:s}),[c=s,l]=A.useState(r),[a=s,u]=A.useState(r),[h=s,d]=A.useState(r);return r&&h.valueOf()!==r.valueOf()&&(l(r),u(r),d(r)),[o,c,a,(g,b)=>{u(g),l(g),i(g),n?.(g,b)},g=>{u(g),l(g)},g=>{u(g)}]}function Jne({isDayPickerVisible:e,isMonthPickerVisible:r,showMonthPickerAsOverlay:t}){const n=f7({isDayPickerVisible:e,showMonthPickerAsOverlay:t}),[s,o]=A.useState(()=>n?!1:r??!1),[i,c]=A.useState(()=>n?!0:e??!0);return[s,i,()=>{o(!s),c(!i)}]}function eoe({componentRef:e},r,t){const n=A.useRef(null),s=A.useRef(null),o=A.useRef(!1),{targetDocument:i}=Yt(),c=i?.defaultView,l=A.useCallback(()=>{r&&n.current?$5(n.current,c):t&&s.current&&$5(s.current,c)},[r,t,c]);return A.useImperativeHandle(e,()=>({focus:l}),[l]),A.useEffect(()=>{o.current&&(l(),o.current=!1)}),[n,s,()=>{o.current=!0}]}const wb=A.forwardRef((e,r)=>{const{allFocusable:t=!1,calendarDayProps:n,calendarMonthProps:s,className:o,componentRef:i,dateRangeType:c=fo.Day,dateTimeFormatter:l=U_,firstDayOfWeek:a=jo.Sunday,firstWeekOfYear:u=Ih.FirstDay,highlightCurrentMonth:h=!1,highlightSelectedMonth:d=!1,id:f,isDayPickerVisible:m=!0,isMonthPickerVisible:p=!0,maxDate:g,minDate:b,onDismiss:y,onSelectDate:w,restrictedDates:C,showCloseButton:N=!1,showGoToToday:I=!0,showMonthPickerAsOverlay:$=!1,showSixWeeksByDefault:D=!1,showWeekNumbers:F=!1,strings:V=X_,today:G,value:U,workWeekDays:E=Qne}=e,M=A.useMemo(()=>G??new Date,[G]),[B,k,_,S,T,z]=Zne({onSelectDate:w,value:U,today:M}),[P,O,X]=Jne({isDayPickerVisible:m,isMonthPickerVisible:p,showMonthPickerAsOverlay:$}),[K,J,H]=eoe({componentRef:i},O,P),Z=()=>{let he=I;return he&&M&&(he=k.getFullYear()!==M.getFullYear()||k.getMonth()!==M.getMonth()||_.getFullYear()!==M.getFullYear()||_.getMonth()!==M.getMonth()),I&&A.createElement("button",{className:pe.goTodayButton,onClick:ie,onKeyDown:ne(ie),type:"button",disabled:!he},V.goToToday)},L=(he,me)=>{T(he),me&&H()},q=(he,me)=>{if(me&&H(),!me){z(he);return}be&&S(he),T(he)},Y=f7({isDayPickerVisible:m,showMonthPickerAsOverlay:$}),re=Y?()=>{X(),H()}:void 0,ie=()=>{T(M),Y&&P&&X(),H()},ne=he=>me=>{switch(me.key){case gn:case In:he();break}},ae=he=>{switch(he.key){case gn:he.preventDefault();break;case Kb:he.preventDefault();break;case Ni:he.stopPropagation(),y?.();break;case Gb:he.ctrlKey?T(Ql(k,1)):T(Ja(k,1)),he.preventDefault();break;case Xb:he.ctrlKey?T(Ql(k,-1)):T(Ja(k,-1)),he.preventDefault();break}},be=!Y&&!O,pe=Kne({className:o,isDayPickerVisible:O,isMonthPickerVisible:P,showWeekNumbers:F});let te="",se="";if(l&&V.todayDateFormatString&&(te=V.todayDateFormatString.replace("{0}",l.formatMonthDayYear(M,V))),l&&V.selectedDateFormatString&&B){const he=be?l.formatMonthYear:l.formatMonthDayYear;se=V.selectedDateFormatString.replace("{0}",he(B,V))}const ue=se+", "+te;return A.createElement("div",{id:f,ref:r,className:pe.root,onKeyDown:ae},A.createElement("div",{className:pe.liveRegion,"aria-live":"polite","aria-atomic":"true"},A.createElement("span",null,se)),O&&A.createElement(t7,{gridLabel:ue,selectedDate:B??M,navigatedDate:k??M,today:M,onSelectDate:S,onNavigateDate:L,onDismiss:y,firstDayOfWeek:a,dateRangeType:c,strings:V,onHeaderSelect:re,showWeekNumbers:F,firstWeekOfYear:u,dateTimeFormatter:l,showSixWeeksByDefault:D,minDate:b,maxDate:g,navigationIcons:V5,restrictedDates:C,workWeekDays:E,componentRef:K,showCloseButton:N,allFocusable:t,...n}),O&&P&&A.createElement("div",{className:pe.divider}),P?A.createElement("div",{className:pe.monthPickerWrapper},A.createElement(d7,{navigatedDate:_,selectedDate:k,strings:V,onNavigateDate:q,today:M,highlightCurrentMonth:h,highlightSelectedMonth:d,onHeaderSelect:re,dateTimeFormatter:l,minDate:b,maxDate:g,componentRef:J,navigationIcons:V5,...s}),Z()):Z())});wb.displayName="Calendar";const f7=({isDayPickerVisible:e,showMonthPickerAsOverlay:r})=>{const{targetDocument:t}=Yt(),n=t?.defaultView;return r||e&&n&&n.innerWidth<=Yne};var il=(function(e){return e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e})({});const toe=X_,roe={...toe,prevMonthAriaLabel:"Go to previous month",nextMonthAriaLabel:"Go to next month",prevYearAriaLabel:"Go to previous year",nextYearAriaLabel:"Go to next year",closeButtonAriaLabel:"Close date picker"},noe=e=>{const{inlinePopup:r}=e;return Dt(A.Fragment,{children:[ve(e.root,{}),e.popupSurface&&(r?ve(e.popupSurface,{children:ve(e.calendar,{})}):ve(ia,{mountNode:e.mountNode,children:ve(e.popupSurface,{children:ve(e.calendar,{})})}))]})};function ooe(e){const{positioning:r}=e,t={position:"below",align:"start",...ys(r)},{targetRef:n,containerRef:s}=Cc(t);return[n,s]}function ioe(e,r,t){return!!r&&eo(r,e)>0||!!t&&eo(t,e)<0}function aoe(){const e=A.useRef(null),r=A.useRef(!1),t=A.useCallback(()=>{var s,o;(o=e.current)===null||o===void 0||(s=o.focus)===null||s===void 0||s.call(o)},[]),n=A.useCallback(()=>{r.current=!0},[]);return[t,e,r,n]}function soe(e){const[r,t]=Wr({initialState:!1,defaultState:e.defaultOpen,state:e.open}),n=A.useRef(!1);return A.useEffect(()=>{if(n.current&&!r){var s;(s=e.onOpenChange)===null||s===void 0||s.call(e,!1)}n.current=!0},[e.allowTextInput,r]),[r,t]}function loe({formatDate:e,onSelectDate:r,value:t}){const[n,s]=Wr({initialState:null,state:t}),[o,i]=A.useState(()=>t&&e?e(t):""),c=l=>{r?.(l),s(l),i(l&&e?e(l):"")};return A.useEffect(()=>{i(t&&e?e(t):"")},[e,t]),[n,o,c,i]}const coe=e=>e?e.toDateString():"",uoe=e=>{const r=Date.parse(e);return r?new Date(r):null},doe=(e,r)=>{const{allowTextInput:t=!1,allFocusable:n=!1,borderless:s=!1,dateTimeFormatter:o,defaultOpen:i=!1,disableAutoFocus:c=!0,firstDayOfWeek:l=jo.Sunday,firstWeekOfYear:a=Ih.FirstDay,formatDate:u=coe,highlightCurrentMonth:h=!1,highlightSelectedMonth:d=!1,initialPickerDate:f,inlinePopup:m=!1,isMonthPickerVisible:p=!0,maxDate:g,minDate:b,mountNode:y,onOpenChange:w,onSelectDate:C,openOnClick:N=!0,onValidationResult:I,parseDateFromString:$=uoe,showCloseButton:D=!1,showGoToToday:F=!0,showMonthPickerAsOverlay:V=!1,showWeekNumbers:G=!1,strings:U=roe,today:E,underlined:M=!1,value:B,...k}=e,_=A.useMemo(()=>f??new Date,[f]),S=A.useRef(null),[T,z,P,O]=aoe(),[X,K,J,H]=loe({formatDate:u,onSelectDate:C,value:B}),[Z,L]=soe(e),q=aa();var Y;const re=(Y=q?.required)!==null&&Y!==void 0?Y:e.required,ie=mr("datePicker-input"),ne=mr("datePicker-popupSurface"),ae=A.useCallback((ct=null)=>{let Ot;if(t)if(K||ct){if(X&&u&&u(ct??X)===K)return;ct=ct||$(K),!ct||isNaN(ct.getTime())?(J(X),Ot="invalid-input"):ioe(ct,b,g)?Ot="out-of-bounds":J(ct)}else re&&(Ot="required-input"),C?.(ct);else re&&!K&&(Ot="required-input");I?.({error:Ot})},[t,u,K,g,b,C,I,$,re,X,J]),be=A.useCallback(ct=>{w?.(ct),L(ct),!Z&&!e.disabled&&T()},[T,w,e.disabled,L]),pe=A.useCallback(ct=>{Z&&(be(!1),ae(ct),!t&&ct&&J(ct))},[t,Z,be,J,ae]),te=A.useCallback(()=>{Z||(O(),be(!0))},[Z,O,be]),se=A.useCallback(ct=>{O(),pe(ct)},[pe,O]),ue=A.useCallback((ct,Ot)=>{const{value:Ft}=Ot;t&&(Z&&pe(),H(Ft))},[t,pe,Z,H]),he=A.useCallback(()=>{ae()},[ae]),me=A.useCallback(ct=>{switch(ct.key){case gn:ct.preventDefault(),ct.stopPropagation(),Z?e.allowTextInput&&pe():(ae(),te());break;case Ni:Z&&(ct.stopPropagation(),ct.preventDefault(),se());break;case Ta:ct.preventDefault(),Z||te();break}},[se,pe,Z,e.allowTextInput,te,ae]),xe=A.useCallback(()=>{c||t||(P.current||te(),P.current=!1)},[t,c,P,te]),Be=A.useCallback(()=>{if((e.openOnClick||!e.disableAutoFocus)&&!Z&&!e.disabled){te();return}t&&pe()},[t,pe,Z,e.disabled,e.disableAutoFocus,e.openOnClick,te]),Re=ct=>{ct.preventDefault(),ct.stopPropagation(),!Z&&!e.disabled?te():e.allowTextInput&&pe()},He=M?"underline":s?"filled-lighter":"outline",[Je,Te]=ooe(e),Ee=Ge(e.root,{defaultProps:{ref:Je},elementType:"span"});Ee.ref=Nt(Ee.ref,Je);const $e=Ge(e.input,{elementType:"input"});$e.ref=Nt($e.ref,r,z);const Ze=e["aria-labelledby"];var yt;const dt=(yt=e.id)!==null&&yt!==void 0?yt:ie,Ke=A.useMemo(()=>({role:"button","aria-expanded":Z,"aria-labelledby":Ze??dt}),[Z,Ze,dt]),We=Ge(e.contentAfter||{},{defaultProps:{children:A.createElement(YA,null),...Ke},elementType:"span"});We.onClick=De(jt(We.onClick,Re));const nt=Ge(k,{defaultProps:{appearance:He,"aria-controls":Z?ne:void 0,"aria-expanded":Z,"aria-haspopup":"dialog",readOnly:!t,role:"combobox",id:dt},elementType:_n});nt.root=Ee,nt.input=$e,nt.contentAfter=We,nt.onChange=De(jt(nt.onChange,ue)),nt.onBlur=De(jt(nt.onBlur,he)),nt.onKeyDown=De(jt(nt.onKeyDown,me)),nt.onFocus=De(jt(nt.onFocus,xe)),nt.onClick=De(jt(nt.onClick,Be));const{modalAttributes:Ve}=sd({trapFocus:!0,alwaysFocusable:!0,legacyTrapFocus:!0}),wt=Z?ut(e.popupSurface,{renderByDefault:!0,defaultProps:{"aria-label":"Calendar","aria-modal":!0,id:ne,role:"dialog",ref:Te,...Ve},elementType:"div"}):void 0,{targetDocument:Wt}=Yt();nd({element:Wt,callback:ct=>pe(),refs:[Je,Te],disabled:!Z}),Ob({element:Wt,callback:ct=>pe(),refs:[Je,Te],disabled:!Z}),A.useEffect(()=>{Z&&!e.disabled&&S.current&&S.current.focus()},[c,Z,e.disabled]);const Ct=Ge(e.calendar,{defaultProps:{allFocusable:n,componentRef:S,dateTimeFormatter:o,firstDayOfWeek:l,firstWeekOfYear:a,highlightCurrentMonth:h,highlightSelectedMonth:d,isMonthPickerVisible:p,maxDate:g,minDate:b,showCloseButton:D,showGoToToday:F,showMonthPickerAsOverlay:V,showWeekNumbers:G,strings:U,today:E,value:X||_},elementType:wb});Ct.onDismiss=De(jt(Ct.onDismiss,se)),Ct.onSelectDate=De(jt(Ct.onSelectDate,se));const Tt={disabled:!!e.disabled,inlinePopup:m,components:{root:_n,calendar:wb,popupSurface:"div"},calendar:Ct,mountNode:y,root:nt,popupSurface:wt};return Tt.root.value=K,Tt},o0={root:"fui-DatePicker",calendar:"fui-DatePicker__calendar",popupSurface:"fui-DatePicker__popupSurface"},foe=ke({base:{qhf8xq:"f10pi13n",Bceei9c:"f1k6fduh",xfaavh:"faxec97"},disabled:{Bceei9c:"f158kwzp",xfaavh:"f19qwlmg"},inline:{Bj3rh1h:"f19g0ac"}},{d:[".f10pi13n{position:relative;}",".f1k6fduh{cursor:pointer;}",".faxec97 input{cursor:pointer;}",".f158kwzp{cursor:default;}",".f19qwlmg input{cursor:default;}",".f19g0ac{z-index:1;}"]}),hoe=_t("r1ytv1z8",null,[".r1ytv1z8{background-color:var(--colorNeutralBackground1);box-shadow:var(--shadow16);border-radius:var(--borderRadiusMedium);border-width:1px;border-style:solid;border-color:var(--colorTransparentStroke);display:inline-flex;color:var(--colorNeutralForeground1);font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase300);font-weight:var(--fontWeightRegular);line-height:var(--lineHeightBase300);}"]),poe=e=>{const r=foe(),t=hoe(),{disabled:n,inlinePopup:s}=e;return e.root.className=de(o0.root,r.base,n&&r.disabled,e.root.className),e.popupSurface&&(e.popupSurface.className=de(o0.popupSurface,t,e.popupSurface.className,s&&r.inline)),e.calendar.className=de(o0.calendar,e.calendar.className),e},xb=A.forwardRef((e,r)=>{const t=doe(e,r);return poe(t),noe(t)});xb.displayName="DatePicker";function h7(e){return!isNaN(e.getTime())}function kb(e){return e?h7(e)?e.toISOString():"invalid":""}function moe(e){if(e===""||e==="invalid")return null;const r=new Date(e);return h7(r)?r:null}function p7(e,{hourCycle:r,showSeconds:t}={}){return e.toLocaleTimeString(void 0,{hour:"numeric",hourCycle:r,minute:"2-digit",second:t?"2-digit":void 0})}function goe(e,r){const t=new Date(e);return t.setHours(r,0,0,0),t}function boe(e,r,t){const n=new Date(e);return(r>t||t===24)&&n.setDate(n.getDate()+1),n.setHours(t===24?0:t,0,0,0),n}function voe(e,r,t){if(t<=0)return console.error("Increment value should be a positive number."),[];const n=[],s=new Date(e);for(;s<r;)n.push(new Date(s)),s.setMinutes(s.getMinutes()+t);return n}const yoe=/^((1[0-2]|0?[0-9]):([0-5][0-9]):([0-5][0-9])\s([AaPp][Mm]))$/,woe=/^((1[0-2]|0?[0-9]):[0-5][0-9]\s([AaPp][Mm]))$/,xoe=/^([0-1]?[0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9]$/,koe=/^([0-1]?[0-9]|2[0-4]):[0-5][0-9]$/;function Soe(e,r,t,n){if(!e)return{date:null,errorType:"required-input"};const{hourCycle:s,showSeconds:o}=n,i=s==="h11"||s==="h12";if(!(i?o?yoe:woe:o?xoe:koe).test(e))return{date:null,errorType:"invalid-input"};const l=/^(\d\d?):(\d\d):?(\d\d)? ?([ap]m)?/i.exec(e);if(!l)return{date:null,errorType:"invalid-input"};const[,a,u,h,d]=l;let f=a;i&&d&&(d.toLowerCase()==="pm"&&+f!=12?f=(+f+12).toString():d.toLowerCase()==="am"&&+f==12&&(f="0"));const m=new Date(r);return m.setHours(+f,+u,h?+h:0),m<r&&m.setDate(m.getDate()+1),m>=t?{date:m,errorType:"out-of-bounds"}:{date:m}}const _oe=(e,r)=>{var t;const{dateAnchor:n,defaultSelectedTime:s,endHour:o=24,formatDateToTimeString:i=p7,hourCycle:c,increment:l=30,onTimeChange:a,selectedTime:u,showSeconds:h=!1,startHour:d=0,parseTimeStringToDate:f,...m}=e,{freeform:p=!1}=m;var g;const{dateStartAnchor:b,dateEndAnchor:y}=Coe((g=n??u)!==null&&g!==void 0?g:s,d,o),w=A.useMemo(()=>voe(b,y,l).map(k=>({date:k,key:kb(k),text:i(k,{showSeconds:h,hourCycle:c})})),[y,b,i,c,l,h]),[C,N]=Wr({state:u,defaultState:s,initialState:null}),[I,$]=A.useState(void 0),D=De((k,_)=>{N(_.selectedTime),$(_.selectedTimeText),a?.(k,_)}),F=A.useMemo(()=>{const k=kb(C),_=w.find(S=>S.key===k);return _?[_.key]:[]},[w,C]),V=A.useRef(null),G=De((k,_)=>{if(p&&_.optionValue===void 0&&!(m.clearable&&k.type==="click"&&k.currentTarget===V.current))return;var S;const T={selectedTime:moe((S=_.optionValue)!==null&&S!==void 0?S:""),selectedTimeText:_.optionText,errorType:void 0};D(k,T)}),U=T6({autoComplete:"off",...m,selectedOptions:F,onOptionSelect:G,children:w.map(k=>A.createElement(Jt,{key:k.key,value:k.key},k.text))},r),E=A.useCallback(k=>Soe(k,b,y,{hourCycle:c,showSeconds:h}),[y,b,c,h]),M=Nt((t=U.clearIcon)===null||t===void 0?void 0:t.ref,V),B={...U,clearIcon:U.clearIcon?{...U.clearIcon,ref:M}:void 0,freeform:p,parseTimeStringToDate:f??E,submittedText:I};return Boe(B),Toe(B,D),B},Coe=(e,r,t)=>{const[n]=A.useState(()=>new Date),s=kb(e??null);return A.useMemo(()=>{const o=e??n,i=goe(o,r),c=boe(o,r,t);return{dateStartAnchor:i,dateEndAnchor:c}},[t,n,s,r])},Toe=(e,r)=>{const{getOptionById:t,freeform:n,parseTimeStringToDate:s,submittedText:o,value:i,activeDescendantController:c}=e,l=A.useCallback(()=>{const f=c.active();return f?t(f):null},[c,t]);A.useEffect(()=>{if(n&&i){const f=l();if(!f)return;f.text.toLowerCase().indexOf(i.toLowerCase())===0||c.blur()}},[n,i,c,l]);const a=De(f=>{if(!n)return;const{date:m,errorType:p}=s(i);o!==i&&r?.(f,{selectedTime:m,selectedTimeText:i,errorType:p})}),u=De(f=>{!l()&&f.key===gn&&a(f)});e.root.onKeyDown=jt(u,e.root.onKeyDown);const h=A.useRef(null);e.root.ref=Nt(e.root.ref,h),e.listbox&&(e.listbox.tabIndex=-1),e.expandIcon&&(e.expandIcon.tabIndex=-1);const d=De(f=>{(!f.relatedTarget||!kn(h.current,f.relatedTarget))&&a(f)});e.input.onBlur=jt(d,e.input.onBlur)},Boe=e=>{var r;const t=aa(),n=mr("timepicker-chevron-");if(t?.labelId&&((r=e.expandIcon)===null||r===void 0?void 0:r["aria-label"])==="Open"){var o;const i=(o=e.expandIcon.id)!==null&&o!==void 0?o:n;e.expandIcon["aria-labelledby"]=`${i} ${t.labelId}`}},Su={root:"fui-TimePicker",input:"fui-TimePicker__input",expandIcon:"fui-TimePicker__expandIcon",clearIcon:"fui-TimePicker__clearIcon",listbox:"fui-TimePicker__listbox"},joe=ke({listbox:{Bxyxcbc:"f1vfnyiv"}},{d:[".f1vfnyiv{max-height:min(80vh, 416px);}"]}),Noe=e=>{const r=joe();return e.root.className=de(Su.root,e.root.className),e.input.className=de(Su.input,e.input.className),e.expandIcon&&(e.expandIcon.className=de(Su.expandIcon,e.expandIcon.className)),e.clearIcon&&(e.clearIcon.className=de(Su.clearIcon,e.clearIcon.className)),e.listbox&&(e.listbox.className=de(Su.listbox,r.listbox,e.listbox.className)),j6(e),e},m7=A.forwardRef((e,r)=>{const t=_oe(e,r),n=mv(t);return Noe(t),ht("useTimePickerCompatStyles_unstable")(t),B6(t,n)});m7.displayName="TimePicker";const Eoe=wr({root:{display:"flex",flexDirection:"row",gap:"8px"},datePicker:{flexGrow:1},timePicker:{flexGrow:1}});function Sb({attribute:e,value:r,onChange:t,placeholder:n="Select a date",disabled:s=!1}){const o=Eoe(),[i,c]=A.useState(null),[l,a]=A.useState(null),[u,h]=A.useState(""),d=e.Format==="DateOnly";A.useEffect(()=>{if(r){const y=typeof r=="string"?new Date(r):r;isNaN(y.getTime())||(c(y),d||(a(y),h(p7(y))))}else c(null),a(null),h("")},[r,d]);const f=e.MinSupportedValue?new Date(e.MinSupportedValue):void 0,m=e.MaxSupportedValue?new Date(e.MaxSupportedValue):void 0,p=y=>{if(c(y??null),!y){t(void 0);return}if(d){const w=new Date(Date.UTC(y.getFullYear(),y.getMonth(),y.getDate()));t(w)}else if(l){const w=new Date(y.getFullYear(),y.getMonth(),y.getDate(),l.getHours(),l.getMinutes(),l.getSeconds());t(w)}else t(y)},g=(y,w)=>{if(a(w.selectedTime),h(w.selectedTimeText??""),i&&w.selectedTime){const C=new Date(i.getFullYear(),i.getMonth(),i.getDate(),w.selectedTime.getHours(),w.selectedTime.getMinutes(),w.selectedTime.getSeconds());t(C)}},b=y=>{h(y.target.value)};return d?j.jsx(xb,{value:i,onSelectDate:p,placeholder:n,disabled:s,minDate:f,maxDate:m,allowTextInput:!0,className:o.datePicker}):j.jsxs("div",{className:o.root,children:[j.jsx(xb,{value:i,onSelectDate:p,placeholder:"Select date",disabled:s,minDate:f,maxDate:m,allowTextInput:!0,className:o.datePicker}),j.jsx(m7,{placeholder:"Select time",freeform:!0,dateAnchor:i??void 0,selectedTime:l,onTimeChange:g,value:u,onInput:b,disabled:s||!i,className:o.timePicker})]})}const Aoe=wr({container:{display:"flex",alignItems:"center",gap:le.spacingHorizontalM,width:"100%"},inputWrapper:{flex:1,minWidth:"120px"},separator:{color:le.colorNeutralForeground3,fontWeight:le.fontWeightSemibold,paddingInline:le.spacingHorizontalXS}});function Roe({attribute:e,value:r=[void 0,void 0],onChange:t,placeholder1:n="Start value",placeholder2:s="End value"}){const o=Aoe(),[i,c]=r,l=d=>{const f=d instanceof Date?d.toISOString():typeof d=="number"||typeof d=="string"?d:void 0;t([f,c])},a=d=>{const f=d instanceof Date?d.toISOString():typeof d=="number"||typeof d=="string"?d:void 0;t([i,f])},u=e.AttributeType==="Integer"||e.AttributeType==="BigInt"||e.AttributeType==="Decimal"||e.AttributeType==="Double",h=e.AttributeType==="DateTime";return j.jsxs("div",{className:o.container,children:[j.jsx("div",{className:o.inputWrapper,children:u?j.jsx(gb,{attribute:e,value:typeof i=="number"?i:void 0,onChange:l,placeholder:n}):h?j.jsx(Sb,{attribute:e,value:typeof i=="string"?i:void 0,onChange:l,placeholder:n}):null}),j.jsx(Dn,{className:o.separator,children:"and"}),j.jsx("div",{className:o.inputWrapper,children:u?j.jsx(gb,{attribute:e,value:typeof c=="number"?c:void 0,onChange:a,placeholder:s}):h?j.jsx(Sb,{attribute:e,value:typeof c=="string"?c:void 0,onChange:a,placeholder:s}):null})]})}const zoe=wr({container:{display:"flex",flexDirection:"column",gap:le.spacingVerticalS,width:"100%"},row:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},input:{flexGrow:1},addButton:{marginTop:le.spacingVerticalXS}});function Ioe({values:e,onChange:r,placeholder:t="Enter value",inputType:n="text"}){const s=zoe(),[o,i]=A.useState(e.length>0?e:[""]);A.useEffect(()=>{if(e.length===0&&o.length===1&&o[0]==="")return;const u=o.filter(d=>d.trim()!=="");(e.length!==u.length||e.some((d,f)=>d!==u[f]))&&i(e.length>0?e:[""])},[e]);const c=(u,h)=>{const d=[...o];d[u]=h,i(d);const f=d.filter(m=>m.trim()!=="");r(f)},l=()=>{const u=[...o,""];i(u)},a=u=>{if(o.length===1)i([""]),r([]);else{const h=o.filter((f,m)=>m!==u);i(h);const d=h.filter(f=>f.trim()!=="");r(d)}};return j.jsxs("div",{className:s.container,children:[o.map((u,h)=>j.jsxs("div",{className:s.row,children:[j.jsx(_n,{className:s.input,value:u,onChange:(d,f)=>c(h,f.value),placeholder:`${t} ${h+1}`,type:n}),o.length>1&&j.jsx(St,{appearance:"subtle",icon:j.jsx(x4,{}),onClick:()=>a(h),"aria-label":`Remove value ${h+1}`})]},h)),j.jsx(St,{className:s.addButton,appearance:"secondary",icon:j.jsx(rp,{}),onClick:l,children:"Add value"})]})}const Moe=wr({container:{width:"100%"}});function Doe({entityLogicalName:e,attributeLogicalName:r,attribute:t,value:n=[],onChange:s,placeholder:o="Enter value"}){const i=Moe(),[c,l]=A.useState([]),[a,u]=A.useState((n??[]).map(String)),h=t.AttributeType==="Picklist"||t.AttributeType==="State"||t.AttributeType==="Status"||t.AttributeTypeName?.Value==="MultiSelectPicklistType";A.useEffect(()=>{h&&Qv(e,r).then(p=>{if(p.OptionSet?.Options){const g=p.OptionSet.Options.map(b=>({label:b.Label?.UserLocalizedLabel?.Label||String(b.Value),value:b.Value}));l(g)}}).catch(p=>{console.error("Failed to load OptionSet metadata:",p)})},[e,r,h]),A.useEffect(()=>{if(!h)return;const p=(n??[]).map(String);(p.length!==a.length||p.some((b,y)=>b!==a[y]))&&u(p)},[n,h]);const d=p=>{if(t.AttributeType==="Integer"||t.AttributeType==="BigInt"||t.AttributeType==="Decimal"||t.AttributeType==="Double"||t.AttributeType==="Money"){const b=p.map(y=>parseFloat(y)).filter(y=>!isNaN(y));s(b.length>0?b:void 0)}else s(p.length>0?p:void 0)},f=(p,g)=>{const b=g.selectedOptions.map(y=>parseInt(y,10)).filter(y=>!isNaN(y));u(g.selectedOptions),s(b.length>0?b:void 0)};if(h){const p=c.filter(g=>!a.includes(String(g.value)));return j.jsx("div",{className:i.container,children:j.jsxs(S8,{onOptionSelect:f,selectedOptions:a,children:[j.jsxs(T8,{children:[j.jsx(B8,{"aria-label":"Selected values",children:a.map(g=>{const b=c.find(y=>String(y.value)===g);return j.jsx(pp,{shape:"rounded",value:g,children:b?`${b.label} - ${b.value}`:g},g)})}),j.jsx(_8,{"aria-label":o,placeholder:o})]}),j.jsx(C8,{children:p.length>0?p.map(g=>j.jsxs(G0,{value:String(g.value),text:`${g.label} - ${g.value}`,children:[g.label," - ",g.value]},g.value)):j.jsx(G0,{value:"no-options",text:"No options available",children:"No options available"})})]})})}const m=t.AttributeType==="Integer"||t.AttributeType==="BigInt"||t.AttributeType==="Decimal"||t.AttributeType==="Double"||t.AttributeType==="Money";return j.jsx("div",{className:i.container,children:j.jsx(Ioe,{values:(n??[]).map(String),onChange:d,placeholder:o,inputType:m?"number":"text"})})}const Ps="https://learn.microsoft.com/power-apps/developer/data-platform",Fr=`${Ps}/fetchxml`,Kt={fetch:`${Fr}/reference/fetch`,fetchOptions:`${Fr}/reference/fetch#options`,entity:`${Fr}/reference/entity`,attribute:`${Fr}/reference/attribute`,aggregateFunctions:`${Fr}/reference/attribute#aggregate-functions`,order:`${Fr}/reference/order`,filter:`${Fr}/reference/filter`,condition:`${Fr}/reference/condition`,operators:`${Fr}/reference/operators`,linkEntity:`${Fr}/reference/link-entity`,linkEntityFromTo:`${Fr}/reference/link-entity#using-from-and-to-attributes`,aggregate:`${Fr}/aggregate-data`,aggregateDistinct:`${Fr}/aggregate-data#distinct-column-values`,aggregateDateGrouping:`${Fr}/aggregate-data#grouping-by-parts-of-a-date`,aggregateLimit:`${Fr}/aggregate-data#per-query-limit`,rowAggregate:`${Fr}/aggregate-data#row-aggregate`,columnAliases:`${Fr}/select-columns#column-aliases`,orderRows:`${Fr}/order-rows`,linkOrdersFirst:`${Fr}/order-rows#process-link-entity-orders-first`,filterRows:`${Fr}/filter-rows`,filterOnColumnValues:`${Fr}/filter-rows#filter-on-column-values-in-the-same-row`,filtersOnLinkEntity:`${Fr}/filter-rows#filters-on-link-entity`,joinTables:`${Fr}/join-tables`,pageResults:`${Fr}/page-results`,countRows:`${Fr}/count-rows`,limitRows:`${Fr}/overview#limit-the-number-of-rows`,distinctResults:`${Fr}/overview#return-distinct-results`,lateMaterialize:`${Fr}/optimize-performance#late-materialize-query`,unionHint:`${Fr}/optimize-performance#union-hint`,noLock:`${Fr}/optimize-performance#no-lock`,antiPatterns:`${Ps}/query-antipatterns`,quickFind:`${Ps}/quick-find?tabs=fetchxml`,quickFindLimits:`${Ps}/quick-find?tabs=fetchxml#quick-find-record-limits`,hierarchy:`${Ps}/query-hierarchical-data`,wildcards:`${Ps}/wildcard-characters?tabs=fetchxml`,choices:`${Ps}/multi-select-picklist#query-data-from-choices`,dataRetention:"https://learn.microsoft.com/power-apps/maker/data-platform/data-retention-overview",reportPrefiltering:"https://learn.microsoft.com/dynamics365/customerengagement/on-premises/analytics/improve-report-performance-by-using-filters?view=op-9-1"},Mi=wr({container:{display:"flex",flexDirection:"column",gap:le.spacingVerticalL,padding:le.spacingVerticalM},section:{display:"flex",flexDirection:"column",gap:le.spacingVerticalS},mono:{fontFamily:le.fontFamilyMonospace},readOnly:{color:le.colorNeutralForeground1,paddingTop:le.spacingVerticalXXS},secondary:{color:le.colorNeutralForeground3},optionText:{display:"flex",flexDirection:"column"},optionSecondary:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200},leftover:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:le.spacingHorizontalS},accordionHeader:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},accordionPanel:{display:"flex",flexDirection:"column",gap:le.spacingVerticalM,paddingBottom:le.spacingVerticalM},checkboxGroup:{display:"flex",flexDirection:"column",gap:le.spacingVerticalXXS}});function Qt({text:e,href:r}){return j.jsxs(j.Fragment,{children:[e,r&&j.jsxs(j.Fragment,{children:[" ",j.jsx(dd,{href:r,target:"_blank",rel:"noreferrer",inline:!0,children:"Learn more"})]})]})}function Xn({children:e}){return j.jsx(Dn,{weight:"semibold",children:e})}const g7=(e,r)=>r?{children:(t,n)=>j.jsx(Av,{...n,info:r,children:e})}:e;function kr({label:e,info:r,hint:t,required:n,validation:s,children:o}){return j.jsx(Eo,{label:g7(e,r),hint:s?.message?void 0:t,required:n,validationState:s?.state,validationMessage:s?.message,children:o})}function ei({label:e,info:r,checked:t,onChange:n,disabled:s,hint:o,validation:i}){const c=j.jsx(ho,{checked:t,disabled:s,onChange:(l,a)=>n(a.checked===!0),label:g7(e,r)});return!o&&!i?.message?c:j.jsx(Eo,{hint:i?.message?void 0:o,validationState:i?.state,validationMessage:i?.message,children:c})}function Ka({label:e,info:r,hint:t,value:n,min:s,max:o,rangeSeverity:i="error",placeholder:c,disabled:l,onChange:a,validation:u}){const d=n!==void 0&&(s!==void 0&&n<s||o!==void 0&&n>o)?{state:i,message:o===void 0?`Must be at least ${s?.toLocaleString()}.`:`Must be from ${s?.toLocaleString()} to ${o.toLocaleString()}.`}:void 0;return j.jsx(kr,{label:e,info:r,hint:t,validation:u??d,children:j.jsx(J6,{value:n??null,min:s,max:o,placeholder:c,disabled:l,onChange:(f,m)=>{if(m.value!==void 0&&m.value!==null)return a(m.value);const p=(m.displayValue??"").trim();if(p==="")return a(void 0);const g=Number(p);Number.isFinite(g)&&a(Math.trunc(g))}})})}function _a({text:e,validation:r,onRemove:t}){const n=Mi();return j.jsx(Eo,{validationState:r.state,validationMessage:r.message,children:j.jsxs("div",{className:n.leftover,children:[j.jsx(st,{children:e}),j.jsx(St,{size:"small",onClick:t,children:"Remove"})]})})}function Poe(e){const[r,t]=A.useState({});return A.useEffect(()=>{if(!e)return;let n=!1;return jc(e).then(s=>!n&&t({entity:e,attributes:s})).catch(()=>!n&&t({entity:e,attributes:void 0})),()=>{n=!0}},[e]),r.entity===e?r.attributes:void 0}function b7(e,r){const t=Poe(e),n=r?t?.find(s=>s.LogicalName===r):void 0;return n?I8(n):void 0}function jp(e){const[r,t]=A.useState({info:{}});return A.useEffect(()=>{if(!e)return;let n=!1;return Promise.allSettled([hc(e),SJ(e)]).then(([s,o])=>{n||t({entity:e,info:{metadata:s.status==="fulfilled"?s.value:void 0,isHierarchical:o.status==="fulfilled"?o.value:void 0}})}),()=>{n=!0}},[e]),r.entity===e?r.info:{}}const W5={error:0,warning:1,info:2};function Er(e,...r){const t=e.filter(n=>r.includes(n.attribute)).sort((n,s)=>W5[n.severity]-W5[s.severity])[0];if(t)return{state:t.severity==="info"?"none":t.severity,message:t.message}}function is(...e){const r=t=>t?t.state==="error"?0:t.state==="warning"?1:2:3;return e.filter(Boolean).sort((t,n)=>r(t)-r(n))[0]}const _u="__same";function Ooe(e){const r=e.indexOf(".");return r===-1?{qualifier:void 0,attribute:e}:{qualifier:e.substring(0,r),attribute:e.substring(r+1)}}function Foe({fetchQuery:e,rootEntityName:r,effectiveEntityName:t,scope:n,sameAlias:s,valueof:o,compatibleTypes:i,validation:c,onChange:l}){const a=Mi(),u=A.useMemo(()=>Ooe(o),[o]),h=A.useMemo(()=>{const p=[{value:_u,label:`${t} (same record)`,entityName:t}];r&&r!==t&&p.push({value:r,label:`${r} (root entity)`,entityName:r});const g=new Map(A8(e).map(b=>[b.alias,b.entityName]));for(const b of n?.aliases??[])b!==s&&p.push({value:b,label:`${b} (${g.get(b)??"?"})`,entityName:g.get(b)??""});if(u.qualifier&&!p.some(b=>b.value===u.qualifier)){const b=u.qualifier===s;p.push({value:u.qualifier,label:u.qualifier,entityName:b?t:"",secondary:b?"This record":n?.laterAliases.includes(u.qualifier)?"Joined after this link-entity":"Not a link-entity alias"})}return p},[e,r,t,n,s,u.qualifier]),[d,f]=A.useState(u.qualifier??_u);A.useEffect(()=>f(u.qualifier??_u),[u.qualifier]);const m=h.find(p=>p.value===d)??h[0];return j.jsxs(j.Fragment,{children:[j.jsx(kr,{label:"Entity",info:j.jsx(Qt,{text:"Compare to an attribute of the same record, the root entity, or a link-entity this condition can reach: link-entities need an alias, and a link-entity's filter can only reach link-entities joined before it.",href:Kt.filterOnColumnValues}),children:j.jsx(po,{value:m.label,selectedOptions:[m.value],onOptionSelect:(p,g)=>{f(g.optionValue??_u),l("")},children:h.map(p=>j.jsx(Jt,{value:p.value,text:p.label,children:j.jsxs("span",{className:a.optionText,children:[p.label,p.secondary&&j.jsx("span",{className:a.optionSecondary,children:p.secondary})]})},p.value))})}),j.jsx(kr,{label:"Attribute",required:!0,validation:c??(u.attribute?void 0:{state:"error",message:"Choose the attribute to compare to."}),info:j.jsx(Qt,{text:i.length>0?`Only attributes Dataverse can compare with this one are listed (${i.join(", ")}).`:"The attribute to compare to. Both attributes must have compatible types.",href:Kt.filterOnColumnValues}),children:j.jsx(pc,{entityLogicalName:m.entityName,value:u.attribute,onChange:p=>{const g=m.value===_u?void 0:m.value;l(p?g?`${g}.${p}`:p:"")},placeholder:m.entityName?"Select an attribute":"Choose an entity first",disabled:!m.entityName||i.length===0,filterByTypes:i})})]})}const qoe=wr({matches:{flexWrap:"wrap"}}),i0=e=>e==null||e===""?void 0:String(e);function Loe({operator:e,value:r,advice:t,onChange:n}){const s=qoe(),o=tl.has(e),[i,c]=A.useState(()=>nh(e,r)),l=A.useRef(i0(r)),a=A.useRef(e);A.useEffect(()=>{i0(r)===l.current&&e===a.current||(l.current=i0(r),a.current=e,c(nh(e,r)))},[e,r]);const u=g=>{const b={...i,...g};c(b);const y=b.text===""?void 0:cb(e,b);l.current=y,n(y)},h=g=>{if(g==="custom")return u({match:g,text:i.text===""?"":cb(e,i),literal:!1});if(i.match!=="custom")return u({match:g});const b=nh(e,i.text);u(b.match==="custom"?{match:g}:{match:g,text:b.text,literal:b.literal})},d=o&&i.match==="custom",f=!o&&!i.literal&&g5(i.text),m=d&&i.text!==""&&!g5(i.text),p=f?{state:"warning",message:"This value contains a wildcard character (% _ [). Turn on Match literally to search for it as text."}:m?{state:"warning",message:"No wildcard: this matches the whole value, like Equals."}:void 0;return j.jsxs(j.Fragment,{children:[o&&j.jsx(kr,{label:"Match",info:j.jsx(Qt,{text:"Contains writes %text%, Begins with text% and Ends with %text. Custom pattern writes the value as you type it, wildcards included.",href:Kt.wildcards}),children:j.jsxs(ta,{className:s.matches,layout:"horizontal",value:i.match,onChange:(g,b)=>h(b.value),children:[j.jsx(Yr,{value:"contains",label:"Contains"}),j.jsx(Yr,{value:"begins",label:"Begins with"}),j.jsx(Yr,{value:"ends",label:"Ends with"}),j.jsx(Yr,{value:"custom",label:"Custom pattern"})]})}),j.jsx(kr,{label:d?"Pattern":"Text",validation:is(p,t),info:j.jsx(Qt,{text:o?"like and not-like match only the wildcards in the value: % (any characters), _ (one character), [ ] (one character from a set). Pick a match above, or write the pattern yourself with Custom pattern.":"This operator adds the % wildcard itself, so don't type it. Any %, _ or [ in the value is still a wildcard unless Match literally is on.",href:Kt.wildcards}),children:j.jsx(_n,{value:i.text,placeholder:d?"e.g. con_oso%":"Text to find",onChange:(g,b)=>u({text:b.value})})}),j.jsx(ho,{label:"Match literally (% _ [ are text, not wildcards)",checked:i.literal&&!d,disabled:d,onChange:(g,b)=>u({literal:b.checked===!0})})]})}const $oe=300,U5="00000000-0000-0000-0000-000000000000",a0="__none";async function Hoe(e){const r=await Js(`hierarchical-relationship:${e}`,()=>_Z(e));if(!r)return"";const t=r.referencingAttribute,s=(await jc(e).catch(()=>[])).find(o=>o.LogicalName===t)?.DisplayName?.UserLocalizedLabel?.Label;return`Hierarchy: ${s?`${s} (${t})`:t}. `}function Voe({entityName:e,metadata:r,value:t,onChange:n}){const s=Mi(),o=A.useMemo(()=>r?.EntitySetName&&r.PrimaryNameAttribute&&r.PrimaryIdAttribute?{entitySetName:r.EntitySetName,idAttribute:r.PrimaryIdAttribute,nameAttribute:r.PrimaryNameAttribute}:void 0,[r]),i=typeof t=="string"?t:"",c=A.useRef(null),[l,a]=A.useState(!1),[u,h]=A.useState(i),[d,f]=A.useState(""),[m,p]=A.useState(void 0),[g,b]=A.useState(void 0),[y,w]=A.useState(!1),[C,N]=A.useState(!1),[I,$]=A.useState(""),D=A.useRef(0);A.useEffect(()=>{let T=!1;return Hoe(e).then(z=>!T&&$(z),()=>!T&&$("")),()=>{T=!0}},[e]);const F=A.useRef(void 0),V=A.useRef(0);A.useEffect(()=>{if(i===c.current&&o===F.current)return;c.current=i,F.current=o;const T=++V.current;if(h(i),N(!1),!o||!i){p(void 0),f("");return}if(!oh(i)){a(!0);return}TZ(o,i).then(z=>{if(T===V.current){if(z===void 0){N(!0),a(!0);return}p(z),f(z||ih(i))}})},[i,o]);const G=T=>{c.current=T??"",V.current++,n(T)},U=T=>{if(!o)return;const z=++D.current;w(!0),CZ(o,T).then(P=>{z===D.current&&(b(P),w(!1))},P=>{z===D.current&&(console.error("Record search failed:",P),b([]),w(!1))})},E=A.useRef(void 0);A.useEffect(()=>()=>clearTimeout(E.current),[]);const M=T=>{f(T),clearTimeout(E.current),E.current=setTimeout(()=>U(T),$oe)},B=r?.DisplayName?.UserLocalizedLabel?.Label??e,k=`${I}Dataverse follows up to 100 levels.`,_=j.jsx(Qt,{text:`The ${B} record to start from. Its ID (${r?.PrimaryIdAttribute??"primary key"}) is what the condition stores. The operators apply only to a hierarchical relationship.`,href:Kt.hierarchy}),S=o&&j.jsx(dd,{as:"button",inline:!0,onClick:()=>{l||h(i),a(T=>!T)},children:l?"Search for a record instead":"Enter an ID instead"});if(l||!o){const T=u.trim()!==""&&!oh(u);return j.jsxs(j.Fragment,{children:[j.jsx(kr,{label:"Record ID",info:_,hint:C?`No ${B} record with this ID was found, or you can't read it. ${k}`:k,validation:T?{state:"error",message:`Enter an ID like ${U5}.`}:void 0,children:j.jsx(_n,{className:s.mono,value:u,placeholder:U5,onChange:(z,P)=>{h(P.value);const O=P.value.trim();G(O===""?void 0:oh(O)?ih(O):O)}})}),S]})}return j.jsxs(j.Fragment,{children:[j.jsx(kr,{label:"Record",info:_,hint:k,children:j.jsx(Zn,{freeform:!0,placeholder:"Search by name (begins with)",value:d,selectedOptions:i?[ih(i).toLowerCase()]:[],onChange:T=>M(T.target.value),onOpenChange:(T,z)=>{z.open&&g===void 0&&U(d===m?"":d)},onOptionSelect:(T,z)=>{if(!z.optionValue||z.optionValue===a0)return;const P=g?.find(O=>O.id.toLowerCase()===z.optionValue);p(P?.name),f(P?.name||z.optionValue),G(z.optionValue)},children:y&&g===void 0?j.jsx(Jt,{disabled:!0,value:a0,text:"",children:j.jsx(hn,{size:"tiny",label:"Searching…"})}):g&&g.length>0?g.map(T=>j.jsx(Jt,{value:T.id.toLowerCase(),text:T.name||T.id,children:j.jsxs("span",{className:s.optionText,children:[T.name||"(No name)",j.jsx("span",{className:s.optionSecondary,children:T.id})]})},T.id)):j.jsx(Jt,{disabled:!0,value:a0,text:"",children:d?`No ${B} records start with "${d}"`:`No ${B} records found`})})}),S]})}const s0="__this",X5=new Set(["Picklist","State","Status"]),l0=new Set(["Integer","BigInt","Decimal","Double"]),Woe=new Set(["Uniqueidentifier","Lookup","Customer","Owner"]),Uoe=new Set(["under","not-under","above","eq-or-under","eq-or-above"]),Wl=e=>{const r=typeof e=="number"?e:typeof e=="string"&&/^-?\d+$/.test(e.trim())?Number(e):NaN;return Number.isInteger(r)?r:void 0};function v7({node:e,entityName:r,fetchQuery:t,findings:n,onUpdate:s,columnFilter:o=!1}){const i=Mi(),[c,l]=A.useState(null),a=A.useMemo(()=>A8(t),[t]),u=A.useMemo(()=>YY(t,e.id),[t,e.id]),h=e.entityname?a.find(X=>X.identifier===e.entityname):void 0,d=u&&h?h.entityName:r,f=A.useMemo(()=>L8(t).get(e.id),[t,e.id]),{isHierarchical:m,metadata:p}=jp(d),g=A.useMemo(()=>tQ(c??void 0,m),[c,m]),b=A.useMemo(()=>sQ(c?.AttributeType),[c?.AttributeType]);A.useEffect(()=>{let X=!1;if(!e.attribute||!d){l(null);return}return jc(d).then(async K=>{const J=K.find(L=>L.LogicalName===e.attribute),H=J?.AttributeType;let Z=J;if(J&&H&&(l0.has(H)||H==="DateTime"))try{Z=await xJ(d,e.attribute,H)}catch(L){console.error(`Failed to load detailed metadata for ${e.attribute}:`,L)}X||l(Z??null)}).catch(K=>{console.error("Failed to load attribute metadata for operator filtering:",K),!X&&l(null)}),()=>{X=!0}},[e.attribute,d]);const y=md(e.operator),w=g.find(X=>X.value===e.operator),C=jh(e.operator),N=C==="two",I=C==="multiple",$=C==="single"||C==="two"&&!c||C==="multiple"&&!c,D=e.valueof!==void 0,F=rb.has(e.operator),V=F&&b.length>0,G=Er(n,"valueof"),U=Er(n.filter(X=>X.kind==="advice"),"value"),E=c?.AttributeType,M=c?.AttributeTypeName?.Value==="MultiSelectPicklistType",k=!(E&&(X5.has(E)||l0.has(E)))&&E!=="Boolean"&&E!=="DateTime"&&!M&&ub(e.operator),_=Uoe.has(e.operator)&&!!c?.IsPrimaryId,S=typeof e.value=="string"?e.value:"",T=E&&Woe.has(E)&&S.trim()!==""&&!oh(S)?{state:"error",message:"Enter an ID like 00000000-0000-0000-0000-000000000000."}:void 0,z=!o&&(u&&a.length>0||!!e.entityname),P=e.entityname?h?.displayLabel??e.entityname:`This entity (${r})`,O=()=>E&&X5.has(E)||M?j.jsx(Cre,{entityLogicalName:d,attributeLogicalName:e.attribute,value:typeof e.value=="number"?e.value:void 0,onChange:X=>s({value:X}),placeholder:"Select a value"}):E==="Boolean"?j.jsx(Tre,{entityLogicalName:d,attributeLogicalName:e.attribute,value:typeof e.value=="boolean"?e.value:typeof e.value=="string"?e.value==="true"||e.value==="1":void 0,onChange:X=>s({value:X}),placeholder:"Select true or false"}):E&&l0.has(E)&&c?j.jsx(gb,{attribute:c,value:typeof e.value=="number"?e.value:void 0,onChange:X=>s({value:X}),placeholder:"Enter a number"}):E==="DateTime"&&c?j.jsx(Sb,{attribute:c,value:typeof e.value=="string"||e.value instanceof Date?e.value:void 0,onChange:X=>s({value:X?.toISOString()}),placeholder:"Select a date"}):j.jsx(_n,{value:typeof e.value=="string"||typeof e.value=="number"?String(e.value):"",onChange:(X,K)=>s({value:K.value||void 0}),placeholder:"Value"});return j.jsx("div",{className:i.container,children:j.jsxs("div",{className:i.section,children:[!o&&j.jsx(Xn,{children:"Condition"}),z&&j.jsx(kr,{label:"Entity",validation:Er(n,"entityname"),info:j.jsx(Qt,{text:"Filter on a link-entity's attribute after the join instead of within it, usually with an outer link-entity (for example, records with no related record). Uses the link-entity's alias, or its name when it has none.",href:Kt.filtersOnLinkEntity}),children:j.jsxs(po,{value:P,selectedOptions:[e.entityname??s0],onOptionSelect:(X,K)=>s({entityname:K.optionValue===s0?void 0:K.optionValue,attribute:void 0,operator:void 0,value:void 0,valueof:void 0}),children:[j.jsx(Jt,{value:s0,children:`This entity (${r})`}),e.entityname&&!h&&j.jsx(Jt,{value:e.entityname,text:e.entityname,children:j.jsxs("span",{className:i.optionText,children:[e.entityname,j.jsx("span",{className:i.optionSecondary,children:"Not a link-entity in this query"})]})}),u&&a.map(X=>j.jsx(Jt,{value:X.identifier,children:X.displayLabel},X.nodeId))]})}),!o&&j.jsx(kr,{label:"Attribute",required:!0,validation:e.attribute?void 0:{state:"error",message:"Choose an attribute to filter on."},info:j.jsx(Qt,{text:`The logical name of the ${d} attribute to filter on.`,href:Kt.condition}),children:j.jsx(pc,{entityLogicalName:d,value:e.attribute,onChange:X=>s({attribute:X||void 0,operator:void 0,value:void 0,valueof:D?"":void 0}),placeholder:"Select an attribute"})}),j.jsx(kr,{label:"Operator",required:!0,validation:Er(n,"operator"),info:j.jsx(Qt,{text:[w?.description,M&&!w?.description?"For a choices attribute, contain-values matches records where any of the given options is selected.":void 0,"The operators listed depend on the attribute's type."].filter(Boolean).join(" "),href:w?.docsUrl??(M?Kt.choices:Kt.operators)}),children:j.jsxs(po,{value:w?.label??e.operator??"",selectedOptions:e.operator?[e.operator]:[],onOptionSelect:(X,K)=>{const J=K.optionValue??"",H=rQ(e.operator,J,e.value);s({operator:J,value:uZ(e.operator,J,H),...D&&!rb.has(J)?{valueof:void 0}:{}})},placeholder:"Select an operator",children:[e.operator&&!w&&g.length>0&&j.jsx(Jt,{value:e.operator,text:e.operator,children:j.jsxs("span",{className:i.optionText,children:[e.operator,j.jsx("span",{className:i.optionSecondary,children:"Not listed for this attribute type"})]})}),g.map(X=>j.jsx(Jt,{value:X.value,children:X.label},X.value))]})}),(C==="integer"||C==="year")&&j.jsx(Ka,{label:C==="year"?"Fiscal year":"Number",value:Wl(e.value),min:C==="year"?1e3:1,max:C==="year"?9999:void 0,onChange:X=>s({value:X}),validation:Wl(e.value)===void 0?{state:"error",message:C==="year"?"Enter a four-digit fiscal year.":"Enter a whole number above 0."}:void 0,info:j.jsx(Qt,{text:C==="year"?"A four-digit fiscal year, per the environment's fiscal year settings.":"A whole number above 0 (for example 7 for the last 7 days). Dataverse rejects 0, negative numbers and dates.",href:Kt.operators})}),C==="fiscalPeriodYear"&&j.jsxs(j.Fragment,{children:[j.jsx(Ka,{label:"Fiscal period",value:Array.isArray(e.value)?Wl(e.value[0]):void 0,min:1,onChange:X=>s({value:[X??"",Array.isArray(e.value)?e.value[1]??"":""]}),validation:!Array.isArray(e.value)||Wl(e.value[0])===void 0?{state:"error",message:"Enter the fiscal period (1 or more)."}:void 0,info:j.jsx(Qt,{text:"The period number within the fiscal year: a month, quarter or semester, depending on the environment's fiscal year settings. A period that doesn't exist returns no records.",href:Kt.operators})}),j.jsx(Ka,{label:"Fiscal year",value:Array.isArray(e.value)?Wl(e.value[1]):void 0,min:1e3,max:9999,onChange:X=>s({value:[Array.isArray(e.value)?e.value[0]??"":"",X??""]}),validation:!Array.isArray(e.value)||Wl(e.value[1])===void 0?{state:"error",message:"Enter a four-digit fiscal year."}:void 0,info:j.jsx(Qt,{text:"A four-digit fiscal year.",href:Kt.operators})})]}),y&&I&&c&&j.jsx(kr,{label:"Values",info:j.jsx(Qt,{text:"Each value is written as a <value> element.",href:Kt.condition}),children:j.jsx(Doe,{entityLogicalName:d,attributeLogicalName:e.attribute,attribute:c,value:Array.isArray(e.value)?e.value:void 0,onChange:X=>s({value:X}),placeholder:"Enter values (comma-separated)"})}),y&&N&&!I&&c&&j.jsx(kr,{label:"Values",info:j.jsx(Qt,{text:"The two values the operator needs, written as <value> elements.",href:Kt.operators}),children:j.jsx(Roe,{attribute:c,value:Array.isArray(e.value)&&e.value.length===2?[e.value[0],e.value[1]]:[void 0,void 0],onChange:X=>s({value:X}),placeholder1:"From",placeholder2:"To"})}),$&&!o&&(F||D)&&j.jsx(kr,{label:"Compare to",validation:G?.state==="error"?G:void 0,hint:!V&&!D&&c?`Comparing a ${c.AttributeTypeName?.Value?.replace(/Type$/,"")??c.AttributeType} attribute to another attribute isn't verified to work, so it isn't offered.`:void 0,info:j.jsx(Qt,{text:"A fixed value, or another attribute of the same record or of a link-entity. Comparing attributes works only with eq, ne, gt, ge, lt and le. The docs require the same type; FetchXML Studio also offers the type pairs verified to work (for example Money with Decimal).",href:Kt.filterOnColumnValues}),children:j.jsxs(ta,{layout:"horizontal",value:D?"attribute":"value",onChange:(X,K)=>s(K.value==="attribute"?{value:void 0,valueof:""}:{valueof:void 0,value:void 0}),children:[j.jsx(Yr,{value:"value",label:"A value"}),j.jsx(Yr,{value:"attribute",label:"Another attribute",disabled:!V&&!D})]})}),$&&(D?j.jsx(Foe,{fetchQuery:t,rootEntityName:t.entity.name,effectiveEntityName:d,scope:f,sameAlias:u?e.entityname:f?.selfAlias,valueof:e.valueof??"",compatibleTypes:b,onChange:X=>s({valueof:X??""})}):k?j.jsx(Loe,{operator:e.operator,value:e.value,advice:U,onChange:X=>s({value:X})},e.id):_?j.jsx(Voe,{entityName:d,metadata:p,value:e.value,onChange:X=>s({value:X})},e.id):j.jsx(kr,{label:"Value",validation:is(T,U),info:j.jsx(Qt,{text:"The value to compare the attribute with.",href:Kt.filterRows}),children:O()})),!y&&e.valueof!==void 0&&j.jsx(_a,{text:`Compare to: ${e.valueof||"(empty)"}`,validation:{state:"warning",message:G?.message??`The '${e.operator}' operator doesn't compare to a value.`},onRemove:()=>s({valueof:void 0})}),e.aggregate&&j.jsx(_a,{text:`Aggregate (undocumented): ${e.aggregate}`,validation:{state:"warning",message:Er(n,"aggregate")?.message??"Dataverse ignores aggregate on a condition. FetchXML can't filter on aggregate values."},onRemove:()=>s({aggregate:void 0})})]})})}const Xoe=new Set(["Lookup","Customer","Owner"]),G5="matchfirstrowusingcrossapply";function Goe(e){const r=new Set;for(const t of e)for(const n of Object.keys(t))n.includes("@")||r.add(n);return[...r]}function Koe(e){const r=[],t=(n,s)=>n.links.forEach(o=>{const i=s&&!cl.has(o.linkType);r.push({link:o,returnsColumns:i}),t(o,i)});return t(e.entity,!0),r}function o1(e,r,t,n){const s=Goe(r);if(!e)return s.map(y=>({key:y}));const o=new Set(s),i=Koe(e),c=new Set(i.filter(y=>!y.returnsColumns).map(y=>y.link.id)),l=[],a=new Set,u=y=>{a.has(y.key)||(a.add(y.key),l.push(y))},h=y=>{const{attribute:w,container:C}=y;if(w.alias)return y.key;const N=t?.(C.name,w.name);if(y.isRoot){const I=`_${w.name}_value`;return N?.AttributeType?Xoe.has(N.AttributeType)?I:w.name:o.has(I)?I:w.name}if(C.linkType===G5){if(o.has(y.key))return y.key;if(N?.SchemaName)return N.SchemaName;const I=s.find($=>!$.includes(".")&&!a.has($)&&$.toLowerCase()===w.name);if(I)return I}return y.key},d=n&&n!==e?new Set(o1(n,r,t).map(y=>y.key)):void 0;for(const y of Cp(e)){if(!y.isRoot&&c.has(y.container.id))continue;const w=h(y);d&&!d.has(w)&&!o.has(w)||u({key:w,column:y})}const f=!!e.entity.allAttributes?.enabled||e.entity.attributes.length===0,m=zh(e),p=i.filter(y=>y.returnsColumns&&y.link.allAttributes?.enabled).map(y=>y.link),g=p.map(y=>`${m.get(y.id)}.`),b=p.some(y=>y.linkType===G5);for(const y of s){if(a.has(y))continue;(y.includes(".")?g.some(C=>y.startsWith(C)):f||b&&y!==y.toLowerCase())&&u({key:y})}return l}function y7(e,r){if(!r||r.columns.length===0)return e;const t=new Map;r.columns.forEach((i,c)=>{t.has(i.name)||t.set(i.name,c)});const n=i=>{const c=t.get(i.key)??(i.column?t.get(i.column.key):void 0);if(c!==void 0)return c;const l=/^_(.+)_value$/.exec(i.key)?.[1];return l?t.get(l):void 0},s=e.filter(i=>n(i)!==void 0),o=e.filter(i=>n(i)===void 0);return[...s.sort((i,c)=>n(i)-n(c)),...o]}const w7=e=>e==null?"":typeof e=="object"?JSON.stringify(e):String(e);function _b(e,r){return w7(e[r])}function x7(e,r){return w7(Xi(e,r)??e[r])}function Mu(e,r,t="shown"){return t==="raw"||r.showsRaw?_b(e,r.sourceCol):x7(e,r.sourceCol)}function Cb(e){return/[\t\r\n"]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function Yoe(e,r){return r==="raw"?e.filter(t=>!t.id.endsWith("__raw")):e}function Qoe(e,r,t="shown"){const n=Yoe(r,t),s=n.map(i=>Cb(i.header)).join(" "),o=e.map(i=>n.map(c=>Cb(Mu(i,c,t))).join(" "));return[s,...o].join(`
|
|
74
|
+
`)}function Zoe(e,r,t="shown"){return e.map(n=>Cb(Mu(n,r,t))).join(`
|
|
75
|
+
`)}const Joe=e=>`${e} row${e===1?"":"s"}`,eie=e=>ws(e);function tie(e){switch(e){case"Lookup":case"Customer":case"Owner":case"Uniqueidentifier":return"GUID";case"DateTime":return"ISO date";case"Picklist":case"State":case"Status":return"option value";case"Boolean":return"true/false";case"Integer":case"BigInt":case"Decimal":case"Double":case"Money":return"number";default:return}}const rie=42,nie=wr({container:{display:"flex",flexDirection:"column",height:"100%",backgroundColor:le.colorNeutralBackground1,position:"relative"},gridWrapper:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",backgroundColor:le.colorNeutralBackground1,position:"relative",minHeight:0},gridContent:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",width:"100%",minHeight:0},infoBar:{display:"flex",flexWrap:"wrap",columnGap:le.spacingHorizontalL,alignItems:"center",justifyContent:"space-between",padding:"8px 16px",borderTop:`1px solid ${le.colorNeutralStroke2}`,backgroundColor:le.colorNeutralBackground1,fontSize:le.fontSizeBase200,color:le.colorNeutralForeground2,minHeight:"32px",zIndex:1},selectionWarning:{color:le.colorPaletteYellowForeground1,marginLeft:le.spacingHorizontalM},emptyState:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:le.colorNeutralForeground3,fontSize:le.fontSizeBase300},cellContent:{padding:`${le.spacingVerticalS} ${le.spacingHorizontalM}`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},row:{boxSizing:"border-box",height:"44px"},body:{scrollbarGutter:"stable"},headerCellContent:{display:"flex",alignItems:"center",gap:le.spacingHorizontalXS},sortIndicator:{display:"flex",alignItems:"center",marginLeft:"auto"},headerCell:{},filterIndicator:{flexShrink:0,color:le.colorBrandForeground1},filterBar:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:le.spacingHorizontalS,padding:`${le.spacingVerticalXS} ${le.spacingHorizontalM}`,borderBottom:`1px solid ${le.colorNeutralStroke2}`},search:{marginLeft:"auto",minWidth:"140px",width:"240px",flexShrink:1},filterSurface:{display:"flex",flexDirection:"column",gap:le.spacingVerticalS,width:"320px",maxWidth:"calc(100vw - 32px)"},filterNote:{color:le.colorNeutralForeground3},filterActions:{display:"flex",justifyContent:"flex-end",gap:le.spacingHorizontalS}});function oie(e){switch(e){case"DateTime":return["Oldest to newest","Newest to oldest"];case"Integer":case"BigInt":case"Decimal":case"Double":case"Money":return["Smallest to largest","Largest to smallest"];default:return["A to Z","Z to A"]}}function K5(e){if(!e.operator)return!1;if(!md(e.operator))return!0;const{value:r}=e;return Array.isArray(r)?r.length>0&&r.every(t=>t!==""&&t!==void 0&&t!==null):r!=null&&r!==""}const c0=(e,r)=>e.attribute===r.attribute&&(e.entityname||void 0)===r.entityname,iie=A.forwardRef(function({result:r,isLoading:t,isLoadingMore:n,attributeMetadata:s,fetchQuery:o,primaryIdAttribute:i,onSelectedCountChange:c,onSelectionChange:l,columnConfig:a,onColumnResize:u,onSortChange:h,onLoadMore:d,displaySettings:f,searchText:m="",onSearchTextChange:p,columnFilters:g,onAddColumnFilter:b,onRemoveColumnFilters:y,onVisibleCountChange:w},C){const N=nie(),{targetDocument:I}=Yt(),$=p3({targetDocument:I}),[D,F]=A.useState(new Set),V=A.useRef(null),G=A.useRef(null),[U,E]=A.useState({width:0,height:0}),[M,B]=A.useState(0);A.useEffect(()=>{const je=V.current;if(!je){Ie("resultsGrid","[ResultsGrid] ResizeObserver: container ref is null");return}Ie("resultsGrid","[ResultsGrid] ResizeObserver: setting up observer on container",je);const Pe=new ResizeObserver(fe=>{for(const ye of fe){const{width:Ne,height:Ue}=ye.contentRect;Ie("resultsGrid","[ResultsGrid] ResizeObserver: dimensions updated",{width:Ne,height:Ue}),E({width:Ne,height:Ue})}});return Pe.observe(je),()=>Pe.disconnect()},[r]),A.useEffect(()=>{const je=G.current;if(!je)return;const Pe=new ResizeObserver(()=>{const fe=je.offsetHeight;Ie("resultsGrid","[ResultsGrid] Header height:",fe),B(fe)});return Pe.observe(je),()=>Pe.disconnect()},[r]);const k=A.useRef({onSelectedCountChange:c,onSelectionChange:l});k.current={onSelectedCountChange:c,onSelectionChange:l},A.useEffect(()=>{F(new Set),k.current.onSelectedCountChange?.(0),k.current.onSelectionChange?.([])},[r]);const _=A.useMemo(()=>{const je=new Map;if(!o?.entity)return je;for(const[Pe,fe]of yre(o)){je.set(Pe,{direction:fe});const ye=vd(o,Pe);ye?.isRoot&&!ye.attribute.alias&&je.set(`_${ye.attribute.name}_value`,{direction:fe})}return je},[o]),S=A.useMemo(()=>mre(r?.rows??[],i),[r?.rows,i]),T=S.getRowId,z=A.useMemo(()=>{if(!r)return[];const je=(Pe,fe)=>s?.get(Pe)?.get(fe);return y7(o1(o,r.rows,je,r.query),a)},[r,o,s,a]),P=A.useMemo(()=>{const je=new Map;for(const Pe of z)Pe.column&&je.set(Pe.key,Pe.column.key);return Pe=>je.get(Pe)??Pe},[z]),O=A.useMemo(()=>{const je=new Map;if(!o?.entity?.name)return je;const Pe=o.entity.name;o.entity.attributes&&o.entity.attributes.forEach(Ne=>{const Ue=Ne.alias||Ne.name;je.set(Ue,{attributeName:Ne.name,entityName:Pe,alias:Ne.alias}),je.set(`_${Ne.name}_value`,{attributeName:Ne.name,entityName:Pe,isLookupColumn:!0})});const fe=zh(o),ye=(Ne,Ue)=>{Ne.forEach(vt=>{const ze=fe.get(vt.id)??vt.alias??vt.name,gt=vt.to||Ue;vt.attributes&&vt.attributes.forEach(bt=>{const at=bt.alias||`${ze}.${bt.name}`;je.set(at,{attributeName:bt.name,entityName:vt.name,alias:bt.alias,linkEntityAlias:ze,lookupAttribute:gt})}),vt.links&&ye(vt.links,vt.to)})};return o.entity.links&&ye(o.entity.links),je},[o]),{columns:X,columnDisplayNames:K,columnAttributeTypes:J,copyColumns:H}=A.useMemo(()=>{if(!r||z.length===0)return{columns:[],columnDisplayNames:new Map,columnAttributeTypes:new Map,copyColumns:[]};const je=o?zh(o):new Map,Pe=new Map(Q0(o??null).map(ze=>[je.get(ze.id),ze])),fe=ze=>{const gt=ze.indexOf("."),bt=ze.slice(0,gt),at=gt>0?Pe.get(bt):void 0;return at?{attributeName:ze.slice(gt+1),entityName:at.name,linkEntityAlias:bt,lookupAttribute:at.to}:void 0},ye=new Map,Ne=new Map,Ue=[];return{columns:z.map(ze=>ze.key).flatMap(ze=>{const gt=O.get(ze)??O.get(P(ze))??fe(ze),bt=(qt,ce)=>s?.get(qt)?.get(ce);let at;if(gt)at=bt(gt.entityName,gt.attributeName);else if(ze.startsWith("_")&&ze.endsWith("_value")){const qt=ze.slice(1,-6),ce=o?.entity?.name;ce&&(at=bt(ce,qt))}else{const qt=o?.entity?.name;qt&&(at=bt(qt,ze))}let Bt;const Ut=()=>gt?.isLookupColumn?gt.attributeName||ze.slice(1,-6):gt?.linkEntityAlias?`${gt.linkEntityAlias}.${gt.attributeName||ze}`:gt?.attributeName||ze;if(f?.useLogicalNames)Bt=Ut();else if(gt?.alias)Bt=gt.alias;else if(gt?.isLookupColumn)Bt=at?.DisplayName?.UserLocalizedLabel?.Label||gt.attributeName||ze.slice(1,-6);else if(gt?.linkEntityAlias){const qt=at?.DisplayName?.UserLocalizedLabel?.Label||gt.attributeName;let ce=gt.linkEntityAlias;const we=o?.entity?.name,qe=gt.lookupAttribute&&we?bt(we,gt.lookupAttribute):void 0;if(["Lookup","Customer","Owner"].includes(qe?.AttributeType??"")&&qe?.DisplayName?.UserLocalizedLabel?.Label)ce=qe.DisplayName.UserLocalizedLabel.Label;else{const kt=ft=>ft?.find(hr=>hr.LogicalName===gt.entityName),ot=Zt.getEntityMetadata(gt.entityName)??kt(Zt.getAllEntityMetadata())??kt(Zt.getAllEntities());ot?.DisplayName?.UserLocalizedLabel?.Label&&(ce=ot.DisplayName.UserLocalizedLabel.Label)}Bt=`${qt} (${ce})`}else at?.DisplayName?.UserLocalizedLabel?.Label?Bt=at.DisplayName.UserLocalizedLabel.Label:ze.startsWith("_")&&ze.endsWith("_value")?Bt=ze.slice(1,-6):Bt=ze;const or=_.get(ze)??_.get(P(ze)),Tr=o?n0(o,ze):void 0,Sr=!!Tr&&!("reason"in Tr)&&!!g?.some(qt=>c0(qt,Tr)),_r=f?.valueDisplayMode??"formatted",xt=_r==="both"&&r?.rows?.some(qt=>{const ce=qt[ze],we=Xi(qt,ze);return we!==void 0&&we!==ce});if(ye.set(ze,Bt),Ne.set(ze,at?.AttributeType),_r==="both"&&xt){Ue.push({id:ze,header:Bt,sourceCol:ze,showsRaw:!1},{id:`${ze}__raw`,header:`${Bt} (Raw)`,sourceCol:ze,showsRaw:!0}),ye.set(`${ze}__raw`,`${Bt} (Raw)`),Ne.set(`${ze}__raw`,at?.AttributeType);const qt=rc({columnId:ze,compare:(we,qe)=>{const Xe=String(Xi(we,ze)??we[ze]??""),kt=String(Xi(qe,ze)??qe[ze]??"");return Xe.localeCompare(kt)},renderHeaderCell:()=>j.jsxs("span",{className:N.headerCellContent,children:[j.jsx("span",{style:{fontWeight:600},children:Bt}),Sr&&j.jsx(F2,{className:N.filterIndicator,"aria-label":"Filtered"}),or&&j.jsx("span",{className:N.sortIndicator,children:or.direction==="ascending"?j.jsx(O2,{}):j.jsx(P2,{})})]}),renderCell:we=>{const qe=we[ze],Xe=Xi(we,ze);return j.jsx(Gl,{truncate:!0,children:M5(at?.AttributeType,qe,Xe,at)})}}),ce=rc({columnId:`${ze}__raw`,compare:(we,qe)=>{const Xe=String(we[ze]??""),kt=String(qe[ze]??"");return Xe.localeCompare(kt)},renderHeaderCell:()=>j.jsx("span",{className:N.headerCellContent,children:j.jsxs("span",{style:{fontWeight:600},children:[Bt," (Raw)"]})}),renderCell:we=>{const qe=we[ze];return j.jsx(Gl,{truncate:!0,children:qe==null?j.jsx("span",{children:"—"}):j.jsx("span",{children:j.jsx(ol,{text:String(qe)})})})}});return[qt,ce]}return Ue.push({id:ze,header:Bt,sourceCol:ze,showsRaw:_r==="raw"}),rc({columnId:ze,compare:(qt,ce)=>{const we=String(Xi(qt,ze)??qt[ze]??""),qe=String(Xi(ce,ze)??ce[ze]??"");return we.localeCompare(qe)},renderHeaderCell:()=>j.jsxs("span",{className:N.headerCellContent,children:[j.jsx("span",{style:{fontWeight:600},children:Bt}),Sr&&j.jsx(F2,{className:N.filterIndicator,"aria-label":"Filtered"}),or&&j.jsx("span",{className:N.sortIndicator,children:or.direction==="ascending"?j.jsx(O2,{}):j.jsx(P2,{})})]}),renderCell:qt=>{const ce=qt[ze],we=Xi(qt,ze);return _r==="raw"?j.jsx(Gl,{truncate:!0,children:ce==null?j.jsx("span",{children:"—"}):j.jsx("span",{children:j.jsx(ol,{text:String(ce)})})}):j.jsx(Gl,{truncate:!0,children:M5(at?.AttributeType,ce,we,at)})}})}),columnDisplayNames:ye,columnAttributeTypes:Ne,copyColumns:Ue}},[r,s,O,o,z,P,N,_,f,g]),Z=A.useCallback((je,Pe)=>{F(Pe.selectedItems),c?.(Pe.selectedItems.size),l?.(S.toRecordIds(Pe.selectedItems))},[c,l,S]),[L,q]=A.useState({open:!1}),[Y,re]=A.useState(null),[ie,ne]=A.useState(null),ae=A.useCallback((je,Pe)=>{const fe=String(Pe.sortColumn);if(!je.shiftKey){const ze=je.target.closest('[role="columnheader"]');q({open:!0,anchor:ze??je.currentTarget,columnId:fe});return}if(!h)return;const ye=fe.replace(/__raw$/,""),Ne=!0,Ue=_.get(ye)??_.get(P(ye));let vt;Ue?vt=Ue.direction==="ascending"?"descending":"ascending":vt="ascending",h({columnId:ye,direction:vt,isMultiSort:Ne})},[h,_,P]),[be,pe]=A.useState(null),te=A.useCallback(je=>{pe({entity:je,status:"loading",text:`Counting all ${je} records…`}),BZ(je).then(Pe=>pe(Pe===void 0?{entity:je,status:"error",text:`Dataverse returned no total for ${je}.`}:{entity:je,status:"done",text:are(je,Pe)}),Pe=>pe({entity:je,status:"error",text:`Couldn't count all ${je} records. ${zn(Pe)}`}))},[]),se=r?ire(r.totalRecordCount,r.totalRecordCountLimitExceeded,r.rows.length):void 0,ue=m.trim(),he=A.useMemo(()=>{const je=r?.rows??[];if(!ue)return je;const Pe=ue.toLowerCase();return je.filter(fe=>H.some(ye=>Mu(fe,ye).toLowerCase().includes(Pe)))},[r,ue,H]);A.useEffect(()=>{w?.(he.length)},[he.length,w]),A.useEffect(()=>{if(!ue||D.size===0)return;const je=new Set(he.map(fe=>T(fe))),Pe=new Set([...D].filter(fe=>je.has(fe)));Pe.size!==D.size&&Z(void 0,{selectedItems:Pe})},[ue,he,D,T,Z]);const me=mr("results-toaster"),{dispatchToast:xe}=JV(me),[Be,Re]=A.useState({open:!1}),He=A.useRef(null),Je=A.useCallback(je=>H.find(Pe=>Pe.id===je),[H]),Te=A.useCallback(()=>(r?.rows??[]).filter(je=>D.has(T(je))),[r,D,T]),Ee=A.useCallback(async(je,Pe)=>{const fe=await eie(je);xe(j.jsx(KS,{children:j.jsx(YS,{children:fe?`${Pe} copied`:"Couldn't copy to the clipboard"})}),{intent:fe?"success":"error",timeout:fe?2e3:4e3})},[xe]),$e=A.useCallback((je,Pe)=>{je.length!==0&&Ee(Qoe(je,H,Pe),Joe(je.length))},[Ee,H]);A.useImperativeHandle(C,()=>({copyRows:(je,Pe)=>$e(je==="all"?he:Te(),Pe)}),[$e,he,Te]);const Ze=A.useCallback((je,Pe,fe)=>{je.preventDefault();const{clientX:ye,clientY:Ne}=je,Ue=ye===0&&Ne===0?je.currentTarget:{getBoundingClientRect:()=>({x:ye,y:Ne,top:Ne,left:ye,bottom:Ne,right:ye,width:0,height:0})};Re({open:!0,target:Ue,item:Pe,columnId:fe})},[]),yt=A.useCallback(je=>{if(!(je.ctrlKey||je.metaKey)||je.key.toLowerCase()!=="c"||je.altKey||je.shiftKey||window.getSelection()?.toString())return;if(D.size>0){je.preventDefault(),$e(Te(),"shown");return}const Pe=He.current,fe=Pe&&Je(Pe.columnId);Pe&&fe&&(je.preventDefault(),Ee(Mu(Pe.item,fe),fe.header))},[D,$e,Te,Je,Ee]),dt=A.useMemo(()=>{const{item:je,columnId:Pe}=Be,fe=Pe?Je(Pe):void 0;if(!(!je||!fe))return{item:je,column:fe,shown:Mu(je,fe),raw:_b(je,fe.sourceCol),rawKind:tie(J.get(fe.id))}},[Be,Je,J]),Ke=L.columnId?.replace(/__raw$/,""),We=A.useMemo(()=>o&&Ke?n0(o,Ke):void 0,[o,Ke]),nt=We&&!("reason"in We)?(g??[]).filter(je=>c0(je,We)):[],[Ve,wt]=oie(L.columnId?J.get(L.columnId):void 0),Wt=je=>{Ke&&h?.({columnId:Ke,direction:je,isMultiSort:!1})},Ct=()=>{!L.anchor||!Ke||!We||"reason"in We||(re({anchor:L.anchor,header:Je(Ke)?.header??We.attribute,target:We}),ne({id:"column-filter-draft",type:"condition",attribute:We.attribute,entityname:We.entityname,operator:""}))},Tt=()=>{if(!ie||!K5(ie))return;const{attribute:je,entityname:Pe,operator:fe,value:ye}=ie;b?.({attribute:je,entityname:Pe,operator:fe,value:ye}),re(null)},ct=A.useMemo(()=>Q0(o??null),[o]),Ot=A.useCallback(je=>{const fe=(je.entityname?ct.find(bt=>(bt.alias||bt.name)===je.entityname):void 0)?.name??o?.entity.name??"",ye=s?.get(fe)?.get(je.attribute),Ne=f?.useLogicalNames?`${je.entityname?`${je.entityname}.`:""}${je.attribute}`:`${ye?.DisplayName?.UserLocalizedLabel?.Label??je.attribute}${je.entityname?` (${je.entityname})`:""}`,Ue=(fc.find(bt=>bt.value===je.operator)?.label??je.operator).toLowerCase(),vt=je.value===void 0||je.value===null?[]:Array.isArray(je.value)?je.value:[je.value],ze=H.find(bt=>{const at=o?n0(o,bt.sourceCol):void 0;return!!at&&!("reason"in at)&&c0(je,at)}),gt=bt=>{const at=ze&&r?.rows.find(Bt=>_b(Bt,ze.sourceCol)===String(bt));return at&&ze?x7(at,ze.sourceCol):String(bt)};return[Ne,Ue,vt.map(gt).join(", ")].filter(Boolean).join(" ")},[ct,o,s,f,H,r]),Ft=!!g&&g.length>0,vr=!!p&&((r?.rows.length??0)>0||!!m),fr=Ft||vr?j.jsxs("div",{className:N.filterBar,children:[Ft&&j.jsxs(j.Fragment,{children:[j.jsx(st,{size:200,weight:"semibold",children:"Filters"}),j.jsx(Nv,{size:"small","aria-label":"Column filters",onDismiss:(je,Pe)=>y?.([String(Pe.value)]),children:g.map(je=>{const Pe=Ot(je);return j.jsx(pp,{value:je.id,dismissible:!0,dismissIcon:{"aria-label":`Remove filter: ${Pe}`},children:Pe},je.id)})}),g.length>1&&j.jsx(St,{size:"small",appearance:"transparent",onClick:()=>y?.(g.map(je=>je.id)),children:"Clear all"})]}),vr&&j.jsx(Or,{content:"Searches the loaded rows. To search every record, use Filter by… in a column header.",relationship:"description",children:j.jsx(zv,{className:N.search,size:"small",placeholder:"Search loaded rows","aria-label":"Search loaded rows",value:m,onChange:(je,Pe)=>p?.(Pe.value)})})]}):null,zt=A.useCallback(({item:je,rowId:Pe},fe,ye,Ne)=>j.jsx(hb,{style:fe,className:N.row,children:({renderCell:Ue,columnId:vt})=>j.jsx(Bv,{focusMode:"group",onContextMenu:ze=>Ze(ze,je,String(vt)),onFocus:()=>{He.current={item:je,columnId:String(vt)}},onBlur:()=>{He.current=null},children:Ne?j.jsx(Q6,{style:{width:"100%"},children:j.jsx(Z6,{shape:"rectangle",animation:"pulse",appearance:"translucent"})}):Ue(je)})},Pe),[N.row,Ze]),tr=A.useMemo(()=>{const je={},Pe=ye=>{switch(ye){case"Uniqueidentifier":return 260;case"DateTime":return 160;case"Boolean":return 100;case"Lookup":case"Customer":case"Owner":return 140;case"Money":return 120;default:return 100}},fe=new Map;if(a)for(const ye of a.columns)fe.set(ye.name,ye.width),fe.set(`_${ye.name}_value`,ye.width);for(const ye of X){const Ne=String(ye.columnId),Ue=fe.get(Ne)??fe.get(P(Ne));if(Ue!==void 0)je[Ne]={minWidth:80,defaultWidth:Ue,idealWidth:Ue};else{const vt=K.get(Ne)??Ne,ze=Math.ceil(vt.length*8)+52,gt=Pe(J.get(Ne)),bt=Math.max(ze,gt),at=Math.max(100,Math.min(bt,320));je[Ne]={minWidth:Math.max(80,Math.min(gt,200)),defaultWidth:at,idealWidth:at}}}return je},[X,a,K,J,P]),gr=A.useCallback((je,Pe)=>{if(u){let fe=P(String(Pe.columnId));fe.startsWith("_")&&fe.endsWith("_value")&&(fe=fe.slice(1,-6)),u(fe,Pe.width)}},[u,P]),Rt=A.useCallback(({visibleStopIndex:je})=>{if(!r||!d||n||ue)return;const Pe=r.rows.length,fe=Math.min(10,Math.max(1,Math.floor(Pe*.1)));je>=Pe-fe&&r.moreRecords&&(Ie("resultsGrid","[ResultsGrid] Near bottom, triggering load more:",{visibleStopIndex:je,rowCount:Pe,threshold:fe,moreRecords:r.moreRecords}),d())},[r,d,n,ue]),ur=je=>fr?j.jsxs("div",{className:N.container,children:[fr,je]}):je;return t?ur(j.jsx("div",{className:N.emptyState,children:"Loading results…"})):r?r.rows.length===0?ur(j.jsx("div",{className:N.emptyState,children:"No records found"})):(Ie("resultsGrid","[ResultsGrid] Rendering grid:",{rowCount:r.rows.length,columnCount:X.length,gridDimensions:U,primaryIdAttribute:i,firstRowId:r.rows.length>0?T(r.rows[0]):"none",columnIds:X.slice(0,5).map(je=>je.columnId),sortStateMapSize:_.size}),j.jsxs("div",{className:N.container,children:[fr,j.jsxs("div",{className:N.gridWrapper,onKeyDown:yt,children:[j.jsx("div",{ref:V,className:N.gridContent,children:j.jsx($_.Provider,{value:ue,children:j.jsxs(q_,{"aria-label":r?.entityLogicalName??"Results",items:he,columns:X,sortable:!0,sortState:{sortColumn:"__sort_managed_externally__",sortDirection:"ascending"},resizableColumns:!0,resizableColumnsOptions:{autoFitColumns:!1},columnSizingOptions:tr,onColumnResize:gr,onSortChange:ae,selectionMode:"multiselect",selectedItems:D,onSelectionChange:Z,getRowId:T,children:[j.jsx(L_,{ref:G,style:{paddingRight:$},children:j.jsx(hb,{style:{minHeight:"43px",maxHeight:"43px"},children:({renderHeaderCell:je})=>j.jsx(jv,{className:N.headerCell,children:je()})})}),j.jsx(F_,{itemSize:rie,height:Math.max(0,U.height-M),listProps:{useIsScrolling:!0,className:N.body,onItemsRendered:Rt},children:zt})]})})}),j.jsxs("div",{className:N.infoBar,children:[j.jsxs("span",{children:["Rows:"," ",ue?`${he.length} of ${r.rows.length} loaded match the search${se?` (${se})`:""}`:se?`${r.rows.length} of ${se}`:r.rows.length,r.moreRecords&&!n&&" (more available)",n&&" (loading more...)",r.executionTimeMs!==void 0&&` | Executed in ${r.executionTimeMs}ms`,r.totalRecordCountLimitExceeded&&r.entityLogicalName&&j.jsxs(j.Fragment,{children:[" | ",be?.entity===r.entityLogicalName&&be.status!=="error"?be.text:j.jsxs(j.Fragment,{children:[be?.entity===r.entityLogicalName&&`${be.text} `,j.jsx(dd,{as:"button",inline:!0,onClick:()=>te(r.entityLogicalName),children:`Count all ${r.entityLogicalName} records (unfiltered snapshot)`})]})]})]}),j.jsxs("span",{children:["Selected: ",D.size,D.size>0&&D.size===r.rows.length&&r.moreRecords&&j.jsx("span",{className:N.selectionWarning,children:'⚠ Selection limited to loaded records. Use "Retrieve all pages" to load more.'})]})]})]}),dt&&j.jsx(_i,{open:Be.open,onOpenChange:(je,Pe)=>Re(fe=>({...fe,open:Pe.open})),positioning:{target:Be.target,position:"below",align:"start"},children:j.jsx(Ti,{children:j.jsxs(Ci,{children:[j.jsx(Gr,{icon:j.jsx(wc,{}),onClick:()=>{Ee(dt.shown,dt.column.header)},children:"Copy value"}),dt.raw!==""&&dt.raw!==dt.shown&&j.jsxs(Gr,{onClick:()=>{Ee(dt.raw,`${dt.column.header} (raw)`)},children:["Copy raw value",dt.rawKind?` (${dt.rawKind})`:""]}),j.jsx(Ku,{}),j.jsx(Gr,{onClick:()=>$e([dt.item],"shown"),children:"Copy row"}),j.jsxs(Gr,{disabled:D.size===0,onClick:()=>$e(Te(),"shown"),children:["Copy selected rows (",D.size,")"]}),j.jsx(Gr,{onClick:()=>{Ee(Zoe(he,dt.column),`${dt.column.header} column`)},children:"Copy column"})]})})}),j.jsx(_i,{open:L.open,onOpenChange:(je,Pe)=>q(fe=>({...fe,open:Pe.open})),positioning:{target:L.anchor,position:"below",align:"start"},children:j.jsx(Ti,{children:j.jsxs(Ci,{children:[j.jsx(Gr,{icon:j.jsx(_R,{}),disabled:!h,onClick:()=>Wt("ascending"),children:Ve}),j.jsx(Gr,{icon:j.jsx(SR,{}),disabled:!h,onClick:()=>Wt("descending"),children:wt}),j.jsx(Ku,{}),We&&"reason"in We?j.jsx(Or,{content:We.reason,relationship:"description",positioning:"after",children:j.jsx(Gr,{icon:j.jsx(Os,{}),disabled:!0,children:"Filter by…"})}):j.jsx(Gr,{icon:j.jsx(Os,{}),disabled:!b||!We,onClick:Ct,children:"Filter by…"}),nt.length>0&&j.jsx(Gr,{icon:j.jsx(LR,{}),onClick:()=>y?.(nt.map(je=>je.id)),children:"Clear filter"})]})})}),j.jsx(kh,{open:!!Y,onOpenChange:(je,Pe)=>{Pe.open||re(null)},positioning:{target:Y?.anchor,position:"below",align:"start"},withArrow:!0,trapFocus:!0,children:j.jsx(xh,{className:N.filterSurface,"aria-label":Y?`Filter by ${Y.header}`:void 0,children:Y&&ie&&o&&j.jsxs(j.Fragment,{children:[j.jsxs(st,{weight:"semibold",children:["Filter by ",Y.header]}),j.jsx(v7,{columnFilter:!0,node:ie,entityName:Y.target.entityName,fetchQuery:o,findings:q8(ie),onUpdate:je=>ne(Pe=>Pe&&{...Pe,...je})}),j.jsx(st,{size:200,className:N.filterNote,children:"Adds a condition to the query and runs it again, so it covers every record."}),j.jsxs("div",{className:N.filterActions,children:[j.jsx(St,{onClick:()=>re(null),children:"Cancel"}),j.jsx(St,{appearance:"primary",disabled:!K5(ie),onClick:Tt,children:"Apply"})]})]})})}),j.jsx(GS,{toasterId:me,position:"bottom-end"})]})):ur(j.jsx("div",{className:N.emptyState,children:"Click Execute to run the query"}))}),aie="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAUCAYAAABvVQZ0AAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAAAHdElNRQfpDBAGOQ0cztfBAAADZ0lEQVQ4y12Tz6tWRRjHP88zc973vq9XL1cSVKiggkgII40oF9EiNCjKVtKioEXt3US7luGuf6CoVRTUOoTAIkrMFtLKstREveH94fG+5z1zzsw8Lea8dmlg4DkzPJ/zne93RgDO3T7DRtymt/RYnedn1nN7opY4ASXFxLxpCfOGZ/bu5eGVPcyBOUbACECHtRE+8wAhR1bcruVZmn80oz1plslmIJmcMjFGpiocXF6mA1qMFhuA0Jkt9dhbHmBJK4CnK3EnzIxshpExE3LOpJTIOdMDcYA1A6y1AozYxAM4BIP9wMQMzIxMBoRsmWyZmBIdRo/RDsC5FWCkDA9gpZZSG2YZM8Mo4EUdB1iHEQzaQSk7YZiRh0YWEGz4iaEidDnRpIiOlsiWSUAGdNBxb31WYNmMnE0AmYWefza3qfsOECwbfd8TQuDc1l9MbEywEkA/nCd2iWuXbuJfOHsaM0ME+btu+PH3NTa3trBs/+kXiG3kwi9/0my1qBNU9f62mWHZ8LGNfHP9Dof37bKf12vqPuFUQXfChNAFwr0OVUG9ok4RFeS+PeBV9chPt5rXLt6qn825JzYjLBTWyBnTcYtTK41OgAJzA3CnOt/M289D6A5tNh1hHkghotFwWfAI+1YrVlc7BEGdYIDziqsU9YpIWcMM3d6eHdquZ7z+yDHePnScqXlOP3+Kpx54lK2NmvpujyEgIIsjVopWDjcq048cfuzw81lL13Zcv3OLD198hwOTVY4cfJxPvvuafhboppmcKrY3GlDBVUWVGymucohKuakGGtse+sz3l3/l0s0/eO+5k3xx/luu3r4BfaZeu8eVizdYu7ZRvBo5XLWYivNS/KsUbyGR+8huP2V1aTdr9ToPre7HJSF1kZAC0jX4kcON3aBo8MwJyJAooLlL5JA4dfglSMb7X37My08e4+iDT5DaHjHw450gVzwb0lQniC/fnpiyT+iVm9f54dIFfrt6GWsj7byFPiPe7pvsRqXJVa5AVBCR4VWDHPjg+Fd927/Sz0NlXXLSG33bIdFwwPLejslKxo9cSdBLubAL2AIIeM32rhpHnckewt03JfZveAU3FfxYGE9AtaSmWl4DAiIFpG6hThpvsAmcJQZ82Dhv6mtRfdV7N3XegTh2DuF/QBHESQvy6b/BYujcihJ9AQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyNS0xMi0xNlQwNjo1NjoxMSswMDowMDSABtAAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjUtMTItMTZUMDY6NTY6MTErMDA6MDBF3b5sAAAAKHRFWHRkYXRlOnRpbWVzdGFtcAAyMDI1LTEyLTE2VDA2OjU3OjEzKzAwOjAwapXlpAAAAABJRU5ErkJggg==";function sie({size:e=20,className:r}){return j.jsx("img",{src:aie,alt:"",width:e,height:e,className:r,style:{display:"block"},"aria-hidden":"true"})}const lie=wr({drawer:{width:"400px"},headerActions:{display:"flex",gap:le.spacingHorizontalS},columnList:{display:"flex",flexDirection:"column",gap:le.spacingVerticalXS,marginTop:le.spacingVerticalM},columnItem:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,padding:`${le.spacingVerticalS} ${le.spacingHorizontalM}`,backgroundColor:le.colorNeutralBackground1,border:`1px solid ${le.colorNeutralStroke2}`,borderRadius:le.borderRadiusMedium,cursor:"grab",userSelect:"none","&:hover":{backgroundColor:le.colorNeutralBackground1Hover,border:`1px solid ${le.colorNeutralStroke1Hover}`}},columnItemSelected:{backgroundColor:le.colorNeutralBackground1Selected,border:`1px solid ${le.colorBrandStroke1}`},columnItemDragging:{opacity:.5,cursor:"grabbing"},columnItemDragOver:{borderTop:`2px solid ${le.colorBrandStroke1}`,marginTop:"-2px"},dragHandle:{cursor:"grab",color:le.colorNeutralForeground3,display:"flex",alignItems:"center"},columnName:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},columnActions:{display:"flex",gap:le.spacingHorizontalXXS},footer:{display:"flex",justifyContent:"flex-end",gap:le.spacingHorizontalS,padding:le.spacingVerticalM,borderTop:`1px solid ${le.colorNeutralStroke1}`,marginTop:"auto"},hint:{display:"block",color:le.colorNeutralForeground3,marginTop:le.spacingVerticalXS},footerHint:{flex:1,alignSelf:"center",color:le.colorPaletteRedForeground1},emptyState:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:le.spacingVerticalXXL,color:le.colorNeutralForeground3,textAlign:"center"}});function cie({open:e,columns:r,entityDisplayName:t,onClose:n,onApply:s,onAddColumns:o,onResetToDefault:i,addColumnsDisabledReason:c}){const l=lie(),[a,u]=A.useState([]),[h,d]=A.useState(null),[f,m]=A.useState(null),[p,g]=A.useState(null),b=A.useRef(null);A.useEffect(()=>{e&&(u([...r]),d(null))},[e,r]);const y=A.useCallback((G,U)=>{m(U),b.current=G.currentTarget,G.dataTransfer.effectAllowed="move",G.dataTransfer.setData("text/plain",U.toString()),setTimeout(()=>{b.current&&(b.current.style.opacity="0.5")},0)},[]),w=A.useCallback(()=>{m(null),g(null),b.current&&(b.current.style.opacity="1",b.current=null)},[]),C=A.useCallback((G,U)=>{G.preventDefault(),G.dataTransfer.dropEffect="move",f!==null&&f!==U&&g(U)},[f]),N=A.useCallback(()=>{g(null)},[]),I=A.useCallback((G,U)=>{if(G.preventDefault(),f===null||f===U){g(null);return}u(E=>{const M=[...E],[B]=M.splice(f,1),k=f<U?U-1:U;return M.splice(k,0,B),M}),d(f<U?U-1:U),m(null),g(null)},[f]),$=A.useCallback((G,U)=>{u(E=>{const M=[...E],B=U==="up"?G-1:G+1;return B<0||B>=M.length?E:([M[G],M[B]]=[M[B],M[G]],M)}),d(E=>E===G?U==="up"?G-1:G+1:E)},[]),D=A.useCallback(G=>{u(U=>U.filter((E,M)=>M!==G)),d(null)},[]),F=A.useCallback(()=>{s(a)},[a,s]),V=A.useCallback(G=>{d(U=>U===G?null:G)},[]);return j.jsxs(mp,{open:e,onOpenChange:(G,U)=>!U.open&&n(),position:"end",size:"medium",className:l.drawer,children:[j.jsx(bp,{children:j.jsxs(vp,{action:j.jsx(St,{appearance:"subtle","aria-label":"Close",icon:j.jsx(np,{}),onClick:n}),children:["Edit columns",t?`: ${t}`:""]})}),j.jsxs(gp,{children:[j.jsxs(Bc,{size:"small",children:[j.jsx(Wn,{icon:j.jsx(rp,{}),onClick:o,"aria-label":"Add columns",disabled:!!c,children:"Add columns"}),i&&j.jsx(Wn,{icon:j.jsx(xR,{}),onClick:i,"aria-label":"Reset to default",children:"Reset to default"})]}),c&&j.jsx(st,{size:200,className:l.hint,children:c}),a.length===0?j.jsxs("div",{className:l.emptyState,children:[j.jsx(st,{children:"No columns selected"}),j.jsx(st,{size:200,children:'Click "Add columns" to add columns to the view'})]}):j.jsx("div",{className:l.columnList,children:a.map((G,U)=>{const E=f===U,M=p===U;return j.jsxs("div",{className:`${l.columnItem} ${h===U?l.columnItemSelected:""} ${E?l.columnItemDragging:""} ${M?l.columnItemDragOver:""}`,onClick:()=>V(U),role:"button",tabIndex:0,draggable:!0,onDragStart:B=>y(B,U),onDragEnd:w,onDragOver:B=>C(B,U),onDragLeave:N,onDrop:B=>I(B,U),onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&V(U)},children:[j.jsx("span",{className:l.dragHandle,children:j.jsx(DR,{})}),j.jsx("span",{className:l.columnName,children:G.displayName||G.name}),j.jsxs("div",{className:l.columnActions,children:[j.jsx(St,{appearance:"subtle",size:"small",icon:j.jsx(CR,{}),disabled:U===0,onClick:B=>{B.stopPropagation(),$(U,"up")},title:"Move up","aria-label":"Move up"}),j.jsx(St,{appearance:"subtle",size:"small",icon:j.jsx(yR,{}),disabled:U===a.length-1,onClick:B=>{B.stopPropagation(),$(U,"down")},title:"Move down","aria-label":"Move down"}),j.jsx(St,{appearance:"subtle",size:"small",icon:j.jsx(Lu,{}),onClick:B=>{B.stopPropagation(),D(U)},title:"Remove","aria-label":"Remove column"})]})]},G.name)})}),j.jsxs("div",{className:l.footer,children:[r.length>0&&a.length===0&&j.jsx(st,{size:200,className:l.footerHint,children:"Keep at least one column: a query without columns returns every attribute."}),j.jsx(St,{appearance:"secondary",onClick:n,children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:F,disabled:r.length>0&&a.length===0,children:"Apply"})]})]})]})}const uie=wr({drawer:{width:"420px"},searchContainer:{display:"flex",gap:le.spacingHorizontalS,marginBottom:le.spacingVerticalM},searchInput:{flex:1},filterCombo:{minWidth:"120px"},tabContent:{marginTop:le.spacingVerticalM},attributeList:{display:"flex",flexDirection:"column",gap:le.spacingVerticalXXS,maxHeight:"calc(100vh - 300px)",overflowY:"auto"},attributeItem:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,padding:`${le.spacingVerticalXS} ${le.spacingHorizontalS}`,borderRadius:le.borderRadiusSmall,cursor:"pointer","&:hover":{backgroundColor:le.colorNeutralBackground1Hover}},attributeItemSelected:{backgroundColor:le.colorNeutralBackground1Selected},relationshipTree:{maxHeight:"calc(100vh - 300px)",overflowY:"auto"},relationshipItem:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},relationshipLabel:{display:"flex",flexDirection:"column"},relationshipName:{fontWeight:le.fontWeightSemibold},relationshipEntity:{fontSize:le.fontSizeBase200,color:le.colorNeutralForeground3},relationshipType:{marginLeft:le.spacingHorizontalS},relationshipHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},accordionHeader:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},warningBadge:{marginLeft:le.spacingHorizontalS},loadingContainer:{display:"flex",alignItems:"center",justifyContent:"center",padding:le.spacingVerticalXXL},footer:{display:"flex",justifyContent:"flex-end",gap:le.spacingHorizontalS,padding:le.spacingVerticalM,borderTop:`1px solid ${le.colorNeutralStroke1}`,marginTop:"auto"},emptyState:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:le.spacingVerticalXXL,color:le.colorNeutralForeground3,textAlign:"center"},selectedCount:{marginRight:"auto",color:le.colorNeutralForeground2,display:"flex",alignItems:"center"}});function die({open:e,entityDisplayName:r,entityLogicalName:t,availableAttributes:n=[],selectedAttributes:s=[],lookupRelationships:o=[],oneToManyRelationships:i=[],isLoadingRelationships:c,onLoadRelatedAttributes:l,existingRelatedColumns:a,onClose:u,onApply:h}){const d=uie(),[f,m]=A.useState("entity"),[p,g]=A.useState(""),[b,y]=A.useState("all"),[w,C]=A.useState(new Set),[N,I]=A.useState([]),[$,D]=A.useState(new Set),[F,V]=A.useState(new Map),[G,U]=A.useState(new Set);A.useEffect(()=>{e&&(C(new Set),I([]),g(""),y("all"),m("entity"))},[e]);const E=A.useMemo(()=>{let K=n.filter(J=>!s.includes(J.LogicalName));if(b==="standard"?K=K.filter(J=>!J.LogicalName.startsWith("new_")&&!J.SchemaName.includes("_")):b==="custom"&&(K=K.filter(J=>J.LogicalName.startsWith("new_")||J.SchemaName.includes("_"))),p){const J=p.toLowerCase();K=K.filter(H=>H.LogicalName.toLowerCase().includes(J)||(H.DisplayName?.UserLocalizedLabel?.Label||"").toLowerCase().includes(J))}return K.sort((J,H)=>{const Z=J.DisplayName?.UserLocalizedLabel?.Label||J.LogicalName,L=H.DisplayName?.UserLocalizedLabel?.Label||H.LogicalName;return Z.localeCompare(L)})},[n,s,p,b]),{filteredN1Relationships:M,filtered1NRelationships:B}=A.useMemo(()=>{const K=p.toLowerCase();let J=o.map(Z=>{const q=n.find(Y=>Y.LogicalName===Z.ReferencingAttribute)?.DisplayName?.UserLocalizedLabel?.Label||Z.ReferencingAttribute;return{relationship:Z,type:"N1",displayName:q,relatedEntity:Z.ReferencedEntity}}),H=i.map(Z=>{const q=Zt.getEntityMetadata(Z.ReferencingEntity)?.DisplayName?.UserLocalizedLabel?.Label||Z.ReferencingEntity;return{relationship:Z,type:"1N",displayName:q,relatedEntity:Z.ReferencingEntity}});return p&&(J=J.filter(Z=>Z.relatedEntity.toLowerCase().includes(K)||Z.displayName.toLowerCase().includes(K)||Z.relationship.SchemaName.toLowerCase().includes(K)),H=H.filter(Z=>Z.relatedEntity.toLowerCase().includes(K)||Z.displayName.toLowerCase().includes(K)||Z.relationship.SchemaName.toLowerCase().includes(K))),J.sort((Z,L)=>Z.displayName.localeCompare(L.displayName)),H.sort((Z,L)=>Z.displayName.localeCompare(L.displayName)),{filteredN1Relationships:J,filtered1NRelationships:H}},[o,i,n,p]),k=(K,J)=>{const H=K.relationship,Z=K.type==="N1"?`${H.ReferencedEntity}|${H.ReferencedAttribute}|${H.ReferencingAttribute}|${J}`:`${H.ReferencingEntity}|${H.ReferencingAttribute}|${H.ReferencedAttribute}|${J}`;return a?.has(Z)??!1},_=A.useCallback((K,J)=>{m(J.value)},[]),S=A.useCallback(K=>{C(J=>{const H=new Set(J);return H.has(K)?H.delete(K):H.add(K),H})},[]),T=A.useCallback(async(K,J)=>{const H=vi(K);if(D(Z=>{const L=new Set(Z);return L.has(H)?L.delete(H):L.add(H),L}),!F.has(J)&&l){U(Z=>new Set(Z).add(J));try{const Z=await l(J);V(L=>new Map(L).set(J,Z))}finally{U(Z=>{const L=new Set(Z);return L.delete(J),L})}}},[F,l]),z=A.useCallback((K,J,H,Z)=>{const L=J.DisplayName?.UserLocalizedLabel?.Label||J.LogicalName;let q,Y;H==="N1"?(q=K.ReferencingAttribute,Y=n.find(ne=>ne.LogicalName===q)?.DisplayName?.UserLocalizedLabel?.Label||q):(q=K.ReferencingAttribute,Y=Z);const re={relationship:K,attribute:J,displayName:`${L} (${Y})`,lookupAttribute:q,relationshipType:H};I(ie=>{const ne=ie.findIndex(ae=>vi(ae.relationship)===vi(K)&&ae.attribute.LogicalName===J.LogicalName);return ne>=0?ie.filter((ae,be)=>be!==ne):[...ie,re]})},[n]),P=A.useCallback((K,J)=>N.some(H=>vi(H.relationship)===vi(K)&&H.attribute.LogicalName===J.LogicalName),[N]),O=A.useCallback(()=>{h({rootAttributes:Array.from(w),relatedColumns:N})},[w,N,h]),X=w.size+N.length;return j.jsxs(mp,{open:e,onOpenChange:(K,J)=>!J.open&&u(),position:"end",size:"medium",className:d.drawer,children:[j.jsx(bp,{children:j.jsx(vp,{action:j.jsx(St,{appearance:"subtle","aria-label":"Close",icon:j.jsx(np,{}),onClick:u}),children:"Add columns"})}),j.jsxs(gp,{children:[j.jsxs(hp,{selectedValue:f,onTabSelect:_,children:[j.jsx(Za,{value:"entity",children:r||t||"Entity"}),j.jsx(Za,{value:"related",children:"Related"})]}),j.jsxs("div",{className:d.tabContent,children:[j.jsxs("div",{className:d.searchContainer,children:[j.jsx(_n,{className:d.searchInput,contentBefore:j.jsx(iR,{}),placeholder:"Search columns…",value:p,onChange:(K,J)=>g(J.value)}),j.jsxs(Zn,{className:d.filterCombo,value:b==="all"?"All":b==="standard"?"Standard":"Custom",onOptionSelect:(K,J)=>y(J.optionValue||"all"),children:[j.jsx(Jt,{value:"all",children:"All"}),j.jsx(Jt,{value:"standard",children:"Standard"}),j.jsx(Jt,{value:"custom",children:"Custom"})]})]}),f==="entity"&&j.jsx("div",{className:d.attributeList,children:E.length===0?j.jsx("div",{className:d.emptyState,children:j.jsx(st,{children:p?"No matching attributes found":"All attributes already added"})}):E.map(K=>j.jsxs("div",{className:`${d.attributeItem} ${w.has(K.LogicalName)?d.attributeItemSelected:""}`,onClick:()=>S(K.LogicalName),role:"checkbox","aria-checked":w.has(K.LogicalName),tabIndex:0,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),S(K.LogicalName))},children:[j.jsx(ho,{checked:w.has(K.LogicalName),onChange:J=>{J.stopPropagation(),S(K.LogicalName)}}),j.jsx(st,{children:K.DisplayName?.UserLocalizedLabel?.Label||K.LogicalName})]},K.LogicalName))}),f==="related"&&j.jsx("div",{className:d.relationshipTree,children:c?j.jsx("div",{className:d.loadingContainer,children:j.jsx(hn,{size:"small",label:"Loading relationships…"})}):M.length===0&&B.length===0?j.jsx("div",{className:d.emptyState,children:j.jsx(st,{children:"No relationships found"})}):j.jsxs(Yh,{multiple:!0,collapsible:!0,defaultOpenItems:["n1"],children:[M.length>0&&j.jsxs(qu,{value:"n1",children:[j.jsx($u,{size:"small",children:j.jsxs("div",{className:d.accordionHeader,children:[j.jsx(st,{weight:"semibold",children:"Lookups (N:1)"}),j.jsx(ri,{appearance:"filled",color:"informative",size:"small",children:M.length})]})}),j.jsx(Hu,{children:j.jsx(Hs,{"aria-label":"Lookup relationships",children:M.map(K=>{const J=K.relationship,H=$.has(vi(J)),Z=F.get(K.relatedEntity),L=G.has(K.relatedEntity);return j.jsxs(Ui,{itemType:"branch",open:H,children:[j.jsx(Wi,{onClick:()=>T(J,K.relatedEntity),children:j.jsx("div",{className:d.relationshipHeader,children:j.jsxs("div",{className:d.relationshipLabel,children:[j.jsx("span",{className:d.relationshipName,children:K.displayName}),j.jsx("span",{className:d.relationshipEntity,children:K.relatedEntity})]})})}),H&&j.jsx(Hs,{children:L?j.jsx(Ui,{itemType:"leaf",children:j.jsx(Wi,{children:j.jsx(hn,{size:"tiny",label:"Loading…"})})}):Z&&Z.length>0?Z.filter(q=>q.AttributeType!=="Virtual"&&!k(K,q.LogicalName)).sort((q,Y)=>{const re=q.DisplayName?.UserLocalizedLabel?.Label||q.LogicalName,ie=Y.DisplayName?.UserLocalizedLabel?.Label||Y.LogicalName;return re.localeCompare(ie)}).map(q=>j.jsx(Ui,{itemType:"leaf",children:j.jsx(Wi,{onClick:()=>z(J,q,"N1",K.relatedEntity),children:j.jsxs("div",{className:d.attributeItem,children:[j.jsx(ho,{checked:P(J,q),onChange:Y=>{Y.stopPropagation(),z(J,q,"N1",K.relatedEntity)}}),j.jsx(st,{children:q.DisplayName?.UserLocalizedLabel?.Label||q.LogicalName})]})})},q.LogicalName)):j.jsx(Ui,{itemType:"leaf",children:j.jsx(Wi,{children:j.jsx(st,{style:{color:le.colorNeutralForeground3},children:"No attributes available"})})})})]},vi(J))})})})]}),B.length>0&&j.jsxs(qu,{value:"1n",children:[j.jsx($u,{size:"small",children:j.jsxs("div",{className:d.accordionHeader,children:[j.jsx(st,{weight:"semibold",children:"Related (1:N)"}),j.jsx(ri,{appearance:"filled",color:"informative",size:"small",children:B.length}),j.jsx(ri,{appearance:"tint",color:"warning",size:"small",className:d.warningBadge,children:"May duplicate rows"})]})}),j.jsx(Hu,{children:j.jsx(Hs,{"aria-label":"One-to-many relationships",children:B.map(K=>{const J=K.relationship,H=$.has(vi(J)),Z=F.get(K.relatedEntity),L=G.has(K.relatedEntity);return j.jsxs(Ui,{itemType:"branch",open:H,children:[j.jsx(Wi,{onClick:()=>T(J,K.relatedEntity),children:j.jsx("div",{className:d.relationshipHeader,children:j.jsxs("div",{className:d.relationshipLabel,children:[j.jsx("span",{className:d.relationshipName,children:K.displayName}),j.jsx("span",{className:d.relationshipEntity,children:J.SchemaName})]})})}),H&&j.jsx(Hs,{children:L?j.jsx(Ui,{itemType:"leaf",children:j.jsx(Wi,{children:j.jsx(hn,{size:"tiny",label:"Loading…"})})}):Z&&Z.length>0?Z.filter(q=>q.AttributeType!=="Virtual"&&!k(K,q.LogicalName)).sort((q,Y)=>{const re=q.DisplayName?.UserLocalizedLabel?.Label||q.LogicalName,ie=Y.DisplayName?.UserLocalizedLabel?.Label||Y.LogicalName;return re.localeCompare(ie)}).map(q=>j.jsx(Ui,{itemType:"leaf",children:j.jsx(Wi,{onClick:()=>z(J,q,"1N",K.relatedEntity),children:j.jsxs("div",{className:d.attributeItem,children:[j.jsx(ho,{checked:P(J,q),onChange:Y=>{Y.stopPropagation(),z(J,q,"1N",K.relatedEntity)}}),j.jsx(st,{children:q.DisplayName?.UserLocalizedLabel?.Label||q.LogicalName})]})})},q.LogicalName)):j.jsx(Ui,{itemType:"leaf",children:j.jsx(Wi,{children:j.jsx(st,{style:{color:le.colorNeutralForeground3},children:"No attributes available"})})})})]},vi(J))})})})]})]})})]}),j.jsxs("div",{className:d.footer,children:[X>0&&j.jsxs(st,{className:d.selectedCount,children:[X," column",X!==1?"s":""," selected"]}),j.jsx(St,{appearance:"secondary",onClick:u,children:"Close"}),j.jsx(St,{appearance:"primary",onClick:O,disabled:X===0,children:"Add"})]})]})]})}const fie=wr({toolbar:{padding:"0"},splitButtonAppearance:{}});function Y5({label:e,ariaLabel:r,icon:t,onClick:n,disabled:s,reason:o}){const i=j.jsx(Wn,{appearance:"subtle",icon:t,disabled:s,disabledFocusable:!!o,onClick:n,"aria-label":r,children:e});return o?j.jsx(Or,{content:o,relationship:"description",withArrow:!0,children:i}):i}function hie({selectedCount:e,onOpen:r,onCopyUrl:t,onActivate:n,onDeactivate:s,activateDisabledReason:o,deactivateDisabledReason:i,onDelete:c,onBulkDelete:l,canDelete:a=!1,canBulkDelete:u=!1,deleteDisabled:h=!1,onRunSpecificWorkflow:d,canRunWorkflow:f=!1,workflowDisabled:m=!1,recordActionsDisabledReason:p,onFetchWorkflows:g,onExport:b,onExportLocal:y,loadedCount:w=0,onCopyRows:C,searchText:N="",canExport:I=!1,isExporting:$=!1,exportDisabledReason:D,entityName:F,entityDisplayName:V,columns:G,onReorderColumns:U,onRemoveColumns:E,availableAttributes:M,selectedAttributes:B,onAddColumn:k,onAddRelatedColumns:_,addColumnsDisabledReason:S,existingRelatedColumns:T,lookupRelationships:z,oneToManyRelationships:P,isLoadingRelationships:O,onLoadRelatedAttributes:X,onResetToDefault:K,isRetrieveAllInProgress:J=!1,onStopRetrieveAll:H}){const Z=fie(),L=e>0,q=e===1,Y=!!p,re=h||Y,ie=m||Y,ne=!L||re,[ae,be]=A.useState(!1),[pe,te]=A.useState(!1),[se,ue]=A.useState("shown"),[he,me]=A.useState([]),[xe,Be]=A.useState(!1),[Re,He]=A.useState(!1),Je=A.useCallback(async()=>{if(!(Re||xe||!g)){Be(!0);try{const Ke=await g();me(Ke),He(!0)}catch(Ke){console.error("Failed to load workflows:",Ke)}finally{Be(!1)}}},[Re,xe,g]),Te=A.useCallback(()=>{be(!0)},[]),Ee=A.useCallback(()=>{be(!1)},[]),$e=A.useCallback(()=>{te(!1)},[]),Ze=A.useCallback(Ke=>{if(G&&E){const We=new Set(Ke.map(Ve=>Ve.name)),nt=G.filter(Ve=>!We.has(Ve.name)).map(Ve=>Ve.name);nt.length>0&&E(nt)}U?.(Ke),be(!1)},[G,U,E]),yt=A.useCallback(Ke=>{for(const We of Ke.rootAttributes)k?.(We);Ke.relatedColumns.length>0&&_&&_(Ke.relatedColumns),te(!1)},[k,_]),dt=A.useCallback(()=>{te(!0)},[]);return j.jsxs(j.Fragment,{children:[j.jsxs(Bc,{className:Z.toolbar,size:"medium","aria-label":"Record actions",children:[J&&H&&j.jsxs(j.Fragment,{children:[j.jsx(Wn,{appearance:"subtle",icon:j.jsx(uR,{}),onClick:H,children:"Stop"}),j.jsx(Si,{})]}),j.jsx(Wn,{appearance:"subtle",icon:j.jsx(dR,{}),disabled:!q||Y,onClick:r,"aria-label":"Open record",children:"Open"}),j.jsx(Wn,{appearance:"subtle",icon:j.jsx(eh,{}),disabled:!q||Y,onClick:t,"aria-label":"Copy record URL",children:"Copy URL"}),p&&j.jsx(Or,{content:p,relationship:"description",withArrow:!0,children:j.jsx(Wn,{appearance:"transparent",icon:j.jsx(ph,{}),children:"Record actions unavailable"})}),j.jsx(Si,{}),j.jsx(Y5,{label:"Activate",ariaLabel:"Activate selected records",icon:j.jsx(cd,{}),onClick:n,disabled:ne||!n||!!o,reason:o}),j.jsx(Y5,{label:"Deactivate",ariaLabel:"Deactivate selected records",icon:j.jsx(k4,{}),onClick:s,disabled:ne||!s||!!i,reason:i}),j.jsx(Si,{}),a&&j.jsxs(_i,{positioning:"below-end",children:[j.jsx(va,{disableButtonEnhancement:!0,children:Ke=>j.jsx(hv,{appearance:"subtle",menuButton:Ke,primaryActionButton:{onClick:c,disabled:re},disabled:re,icon:j.jsx(Lu,{}),"aria-label":L?"Delete selected records":"Delete all records from view",children:L?"Delete":"Delete all"})}),j.jsx(Ti,{children:j.jsxs(Ci,{children:[j.jsxs(Gr,{icon:j.jsx(Lu,{}),onClick:c,disabled:re,children:["Delete",L?` (${e})`:" All"]}),u&&j.jsx(Gr,{icon:j.jsx(sR,{}),onClick:l,disabled:re,children:"Bulk delete (job)"})]})})]}),f&&j.jsxs(_i,{positioning:"below-end",onOpenChange:(Ke,We)=>We.open&&Je(),children:[j.jsx(va,{disableButtonEnhancement:!0,children:j.jsx(tc,{appearance:"subtle",icon:j.jsx(R0,{}),disabled:!L||ie,"aria-label":"Run workflow on selected records",children:"Run workflow"})}),j.jsx(Ti,{children:j.jsxs(Ci,{children:[xe&&j.jsx(Gr,{disabled:!0,children:"Loading workflows..."}),!xe&&he.length===0&&Re&&j.jsx(Gr,{disabled:!0,children:"No workflows available"}),!xe&&he.map(Ke=>j.jsx(Gr,{icon:j.jsx(R0,{}),onClick:()=>d?.(Ke),children:Ke.name},Ke.workflowid))]})})]}),j.jsx(Si,{}),j.jsxs(_i,{checkedValues:{copyValues:[se]},onCheckedValueChange:(Ke,We)=>ue(We.checkedItems[0]),children:[j.jsx(va,{disableButtonEnhancement:!0,children:j.jsx(tc,{appearance:"subtle",icon:j.jsx(wc,{}),disabled:w===0,children:"Copy"})}),j.jsx(Ti,{children:j.jsxs(Ci,{children:[j.jsxs(Gr,{disabled:e===0,onClick:()=>C?.("selected",se),children:["Selected rows (",e,")"]}),j.jsxs(Gr,{onClick:()=>C?.("all",se),children:[N.trim()?"All matching rows":"All loaded rows"," (",w,")"]}),j.jsx(Ku,{}),j.jsxs(q6,{children:[j.jsx(L6,{children:"Values"}),j.jsx(O0,{name:"copyValues",value:"shown",persistOnClick:!0,children:"As shown"}),j.jsx(O0,{name:"copyValues",value:"raw",persistOnClick:!0,children:"Raw (GUIDs, numbers, ISO dates)"})]})]})})]}),j.jsxs(_i,{children:[j.jsx(va,{disableButtonEnhancement:!0,children:j.jsx(Or,{content:$?"Export in progress...":"Export to Excel",relationship:"description",children:j.jsx(tc,{appearance:"subtle",icon:j.jsx(sie,{}),disabled:$,"aria-label":"Export to Excel",children:$?"Exporting...":"Export to Excel"})})}),j.jsx(Ti,{children:j.jsxs(Ci,{children:[j.jsx(Or,{content:I?"Export using Dataverse API (all records)":D||"Save as a view first to enable server export",relationship:"description",positioning:"before",children:j.jsx(Gr,{onClick:b,disabled:!I||$,children:"Export (Server)"})}),j.jsx(Gr,{onClick:y,disabled:$,children:"Export (Local)"})]})})]}),j.jsx(Si,{}),j.jsx(Wn,{appearance:"subtle",icon:j.jsx(cR,{}),onClick:Te,"aria-label":"Edit columns",children:"Edit columns"})]}),j.jsx(cie,{open:ae,columns:G||[],entityDisplayName:V,onClose:Ee,onApply:Ze,onAddColumns:dt,onResetToDefault:K,addColumnsDisabledReason:S}),j.jsx(die,{open:pe,entityDisplayName:V,entityLogicalName:F,availableAttributes:M,selectedAttributes:B,lookupRelationships:z,oneToManyRelationships:P,isLoadingRelationships:O,onLoadRelatedAttributes:X,existingRelatedColumns:T,onClose:$e,onApply:yt})]})}const k7=A.createContext(null),pie={sync:async()=>({status:"unchanged"}),editorHasContent:!1};function S7(){return A.useContext(k7)??pie}const mie=wr({container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:`1px solid ${le.colorNeutralStroke1}`,paddingRight:"16px"},progressContainer:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px",borderBottom:`1px solid ${le.colorNeutralStroke1}`},tabContent:{flex:1,overflow:"hidden",padding:"6px",backgroundColor:le.colorNeutralBackground3},surfaceCard:{borderRadius:le.borderRadiusMedium,boxShadow:le.shadow16,backgroundColor:le.colorNeutralBackground1,border:`1px solid ${le.colorNeutralStroke2}`},toolbarCard:{borderRadius:le.borderRadiusMedium,boxShadow:le.shadow16,backgroundColor:le.colorNeutralBackground1,border:`1px solid ${le.colorNeutralStroke2}`,padding:"4px 8px",flexShrink:0},gridCard:{borderRadius:le.borderRadiusMedium,boxShadow:le.shadow16,backgroundColor:le.colorNeutralBackground1,border:`1px solid ${le.colorNeutralStroke2}`,display:"flex",flexDirection:"column",flex:1,minHeight:"240px",minWidth:"480px",overflow:"hidden",marginTop:"8px"},codeCard:{borderRadius:le.borderRadiusMedium,boxShadow:le.shadow16,backgroundColor:le.colorNeutralBackground1,border:`1px solid ${le.colorNeutralStroke2}`,height:"100%",display:"flex",flexDirection:"column"},resultsLayout:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},messageBarContainer:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px",borderBottom:`1px solid ${le.colorNeutralStroke1}`}});function gie({getCurrentXml:e}){const[r,t]=A.useState(!1),n=A.useCallback(async()=>{t(!0);try{await zJ(e())}catch(s){const o=s instanceof Error?s.message:String(s);await window.toolboxAPI?.utils?.showNotification?.({title:"Cannot return FetchXML",body:o,type:"error"})}finally{t(!1)}},[e]);return j.jsx(Or,{content:"Return the current FetchXML to the tool that launched this window",relationship:"description",children:j.jsx(St,{appearance:"subtle",icon:r?j.jsx(hn,{size:"tiny"}):j.jsx(wR,{}),onClick:n,disabled:r,children:"Return FetchXML"})})}function bie({xml:e,layoutXml:r,result:t,isExecuting:n,isLoadingMore:s,onExecute:o,onExport:i,onExportLocal:c,onParseToTree:l,attributeMetadata:a,fetchQuery:u,columnConfig:h,onColumnResize:d,onReorderColumns:f,onAddColumn:m,onAddRelatedColumns:p,onRemoveColumns:g,onSortChange:b,columnFilters:y,onAddColumnFilter:w,onRemoveColumnFilters:C,saveViewButton:N,quickFindTestValue:I,executeDisabledReason:$,sendToToolButton:D,isCallee:F,onLoadMore:V,pagingNotice:G,isRetrieveAllInProgress:U,onStopRetrieveAll:E,onRetryPaging:M,onDismissPagingNotice:B,canExport:k,isExporting:_,exportError:S,onDismissExportError:T,exportDisabledReason:z,executeError:P,onDismissExecuteError:O,entityDisplayName:X,lookupRelationships:K,oneToManyRelationships:J,isLoadingRelationships:H,onLoadRelatedAttributes:Z,onResetToDefault:L,onOpenRecord:q,onCopyRecordUrl:Y,onDeleteRecords:re,onBulkDeleteRecords:ie,onActivateRecords:ne,onDeactivateRecords:ae,activateDisabledReason:be,deactivateDisabledReason:pe,onRunSpecificWorkflow:te,canDelete:se,canBulkDelete:ue,canRunWorkflow:he,onFetchWorkflows:me,isAggregateQuery:xe,hasOneToManyRelationship:Be,recordActionsDisabledReason:Re,onSelectionChange:He,getSelectedRecordIds:Je,onOpenSettings:Te,displaySettings:Ee,primaryIdAttribute:$e}){const Ze=mie(),yt=Sp(),[dt,Ke]=A.useState("xml"),[We,nt]=A.useState(0),[Ve,wt]=A.useState([]),[Wt,Ct]=A.useState(!1),Tt=A.useRef(""),ct=A.useRef(null),[Ot,Ft]=A.useState(""),[vr,fr]=A.useState(0),[zt,tr]=A.useState(null),[gr,Rt]=A.useState(null),ur=A.useMemo(()=>new Set((u?.entity.links??[]).filter(xt=>!cl.has(xt.linkType)).flatMap(xt=>xt.attributes.map(qt=>`${xt.name}|${xt.from}|${xt.to}|${qt.name}`))),[u]),[je,Pe]=A.useState(!1),[fe,ye]=A.useState(null),[Ne,Ue]=A.useState(null),vt=A.useCallback(()=>Wt&&Tt.current||e,[Wt,e]),ze=A.useCallback((xt,qt)=>{Tt.current=qt,Ct(ce=>ce!==xt?xt:ce),Pe(xt&&qt.trim().length>0),Rt(ce=>ce&&(!xt||ce.xml!==qt)?null:ce),xt||tr(null)},[]),gt=(xt,qt)=>{Ke(qt.value),qt.value==="xml"&&tr(null)},bt=A.useCallback(async xt=>{if(!Wt)return{status:"unchanged"};const qt=Tt.current,ce=U8(qt);if(!ce.valid)return tr([{message:ce.error||"Invalid XML syntax"}]),{status:"cancelled"};const we=el(qt);if(!we.success||!we.fetchNode)return tr(we.errors),{status:"cancelled"};const qe=ob(we);if(qe.length>0)return tr(qe),{status:"cancelled"};if(e&&ya(we.fetchNode)===e)return{status:"unchanged"};const Xe=Nh(we);if(Xe.length>0&&!await new Promise(hr=>Ue({action:xt,changes:Xe,resolve:hr})))return{status:"cancelled"};const kt=l?.(qt,{preserveLayout:!0});if(!kt?.success||!kt.fetchNode)return tr(kt?.errors??[{message:"The FetchXML couldn't be loaded into the tree."}]),{status:"cancelled"};const ot=ya(kt.fetchNode);return Xe.length>0&&(Tt.current=ot,ye({xml:ot,id:Date.now()})),{status:"synced",fetchXml:ot,fetchQuery:kt.fetchNode}},[Wt,e,l]),at=A.useMemo(()=>({sync:bt,editorHasContent:Wt&&je}),[bt,Wt,je]),Bt=xt=>{Ne?.resolve(xt),Ue(null)},Ut=async()=>{const xt=await bt("execute");xt.status!=="cancelled"&&(Ke("results"),o?.(xt.status==="synced"?{xml:xt.fetchXml,fetchQuery:xt.fetchQuery}:void 0))},or=()=>{gr&&(Rt(null),Ut())},Tr=()=>{if(tr(null),Rt(null),Wt){const xt=Tt.current,qt=el(xt);if(qt.success&&ob(qt).length===0){const ce=$8(qt);if(ce.length>0){Rt({xml:xt,warnings:ce});return}}}Ut()},Sr=A.useCallback(xt=>{wt(xt),He?.(xt)},[He]),_r=A.useCallback(()=>Je?Je():Ve,[Je,Ve]);return j.jsx(k7.Provider,{value:at,children:j.jsxs("div",{className:Ze.container,children:[j.jsx(T_,{action:Ne?.action??null,changes:Ne?.changes??[],onConfirm:()=>Bt(!0),onCancel:()=>Bt(!1)}),j.jsxs("div",{className:Ze.header,children:[j.jsxs(hp,{selectedValue:dt,onTabSelect:gt,children:[j.jsx(Za,{value:"xml",children:"FetchXML"}),j.jsx(Za,{value:"layout",children:"LayoutXML"}),j.jsx(Za,{value:"results",children:"Results"}),j.jsx(Za,{value:"code",icon:j.jsx(aR,{}),children:"Code"})]}),j.jsxs(Bc,{size:"small",children:[$&&!Wt?j.jsx(Or,{content:$,relationship:"description",children:j.jsx("span",{children:j.jsx(St,{appearance:"primary",icon:j.jsx(I2,{}),disabled:!0,children:"Execute"})})}):j.jsx(St,{appearance:"primary",icon:j.jsx(I2,{}),onClick:Tr,disabled:n||s||(Wt?!je:!e),children:n?"Executing…":"Execute"}),F&&j.jsxs(j.Fragment,{children:[j.jsx(Si,{}),j.jsx(gie,{getCurrentXml:vt})]}),dt==="xml"&&N&&j.jsxs(j.Fragment,{children:[j.jsx(Si,{}),N]}),D&&j.jsxs(j.Fragment,{children:[j.jsx(Si,{}),D]}),j.jsx(Si,{}),j.jsx(St,{appearance:"subtle",icon:j.jsx(v4,{}),onClick:Te,"aria-label":"Settings"})]})]}),(n||s)&&j.jsx("div",{className:Ze.progressContainer,children:j.jsx(hd,{})}),I&&j.jsx("div",{className:Ze.messageBarContainer,children:I}),_&&j.jsx("div",{className:Ze.messageBarContainer,children:j.jsx(Ar,{intent:"info",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Exporting"}),"Exporting view to Excel…"]})})}),S&&!_&&j.jsx("div",{className:Ze.messageBarContainer,children:j.jsxs(Ar,{intent:"error",children:[j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Export failed"}),S]}),j.jsx(Fs,{containerAction:j.jsx(St,{appearance:"transparent",icon:j.jsx(lu,{}),onClick:T,"aria-label":"Dismiss"})})]})}),gr&&j.jsx("div",{className:Ze.messageBarContainer,children:j.jsxs(Ar,{intent:"warning",layout:"multiline",children:[j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Dataverse might reject this query"}),j.jsx(rl,{items:gr.warnings})]}),j.jsx(Fs,{containerAction:j.jsx(St,{appearance:"transparent",icon:j.jsx(lu,{}),onClick:()=>Rt(null),"aria-label":"Dismiss"}),children:j.jsx(St,{onClick:or,children:"Execute anyway"})})]})}),zt&&j.jsx("div",{className:Ze.messageBarContainer,children:j.jsxs(Ar,{intent:"error",layout:"multiline",children:[j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Invalid FetchXML"}),j.jsx(rl,{items:zt})]}),j.jsx(Fs,{containerAction:j.jsx(St,{appearance:"transparent",icon:j.jsx(lu,{}),onClick:()=>tr(null),"aria-label":"Dismiss"})})]})}),P&&j.jsx("div",{className:Ze.messageBarContainer,children:j.jsxs(Ar,{intent:"error",children:[j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Execution failed"}),P]}),j.jsx(Fs,{containerAction:j.jsx(St,{appearance:"transparent",icon:j.jsx(lu,{}),onClick:O,"aria-label":"Dismiss"})})]})}),j.jsxs("div",{className:Ze.tabContent,children:[j.jsx("div",{className:Ze.codeCard,style:dt!=="xml"?{display:"none"}:void 0,children:j.jsx(Qee,{xml:e,onParseToTree:l,onEditorStateChange:ze,replaceRequest:fe})}),dt==="layout"&&j.jsx("div",{className:Ze.codeCard,children:j.jsx(Ete,{layoutXml:r||""})}),dt==="code"&&j.jsx("div",{className:Ze.codeCard,children:j.jsx(jte,{fetchXml:e})}),dt==="results"&&j.jsxs("div",{className:Ze.resultsLayout,children:[j.jsx("div",{className:Ze.toolbarCard,children:j.jsx(hie,{selectedCount:We,onOpen:()=>{const xt=_r();xt?.length&&q&&q(xt)},onCopyUrl:()=>{const xt=_r();xt?.length&&Y&&Y(xt)},onActivate:ne&&(()=>{const xt=_r();xt?.length&&ne&&ne(xt)}),onDeactivate:ae&&(()=>{const xt=_r();xt?.length&&ae&&ae(xt)}),activateDisabledReason:be,deactivateDisabledReason:pe,onDelete:()=>{const xt=_r();re&&re(xt||[])},onBulkDelete:()=>{const xt=_r();ie&&ie(xt||[])},canDelete:se,canBulkDelete:ue,deleteDisabled:xe||Be,onRunSpecificWorkflow:xt=>{const qt=_r();qt?.length&&te&&te(xt,qt)},canRunWorkflow:he,workflowDisabled:xe||Be,recordActionsDisabledReason:Re,onFetchWorkflows:me,onExport:i,onExportLocal:c,loadedCount:Ot.trim()?vr:t?.rows.length??0,searchText:Ot,onCopyRows:(xt,qt)=>ct.current?.copyRows(xt,qt),canExport:k,isExporting:_,exportDisabledReason:z,entityName:t?.entityLogicalName,entityDisplayName:X,columns:h?.columns,onReorderColumns:f,onRemoveColumns:g,availableAttributes:a&&u?.entity?.name?Array.from(a.get(u.entity.name)?.values()||[]).filter(xt=>h_(xt,yt)):void 0,selectedAttributes:u?.entity.attributes.map(xt=>xt.name),onAddColumn:m,onAddRelatedColumns:p,lookupRelationships:K,oneToManyRelationships:J,isLoadingRelationships:H,onLoadRelatedAttributes:Z,onResetToDefault:L,addColumnsDisabledReason:xe?"Aggregate queries only return Group by and aggregate attributes, with aliases: add them in the tree.":void 0,existingRelatedColumns:ur,isRetrieveAllInProgress:U,onStopRetrieveAll:E})}),G&&j.jsx("div",{className:Ze.messageBarContainer,children:j.jsxs(Ar,{intent:G.kind==="error"?"error":G.kind==="stopped"?"warning":"info",layout:"multiline",children:[j.jsxs(Rr,{children:[j.jsx(Hr,{children:G.kind==="error"?"Couldn't load all records":G.kind==="stopped"?"Retrieve all stopped":"Paging without a paging cookie"}),G.kind==="error"?`Loaded ${t?.rows.length??0} rows; ${G.page?`page ${G.page}`:"the next page"} failed: ${G.message}`:G.kind==="stopped"?`Stopped after ${t?.rows.length??0} rows. Scroll to the end of the grid to load more, or execute again.`:G.message]}),j.jsx(Fs,{containerAction:j.jsx(St,{appearance:"transparent",icon:j.jsx(lu,{}),onClick:B,"aria-label":"Dismiss"}),children:G.kind==="error"&&M&&j.jsx(St,{onClick:M,children:"Retry"})})]})}),j.jsx("div",{className:Ze.gridCard,children:j.jsx(iie,{ref:ct,result:t,isLoading:n,isLoadingMore:s,attributeMetadata:a,fetchQuery:u,primaryIdAttribute:$e,onSelectedCountChange:nt,onSelectionChange:Sr,columnConfig:h,onColumnResize:d,onSortChange:b,onLoadMore:V,displaySettings:Ee,searchText:Ot,onSearchTextChange:Ft,columnFilters:y,onAddColumnFilter:w,onRemoveColumnFilters:C,onVisibleCountChange:fr})})]})]})]})})}function _7(){const[e,r]=A.useState(null),[t,n]=A.useState(!0),[s,o]=A.useState(null);return A.useEffect(()=>{let i=!0;async function c(){try{n(!0),o(null);const l=await IZ();i&&(r(l),l&&!l.noAccessMode&&(Ie("metadataAPI","[useAccessMode] Preloading entity metadata..."),l_().then(a=>{Ie("metadataAPI","[useAccessMode] Entity metadata preloaded:",a.length,"entities")}).catch(a=>{console.error("[useAccessMode] Failed to preload entity metadata:",a)})))}catch(l){i&&o(l instanceof Error?l.message:String(l))}finally{i&&n(!1)}}return c(),()=>{i=!1}},[]),{accessSummary:e,loading:t,error:s,fullFilterMode:e?.fullFilterMode??!1,solutionsOnlyMode:e?.solutionsOnlyMode??!1,publishersOnlyMode:e?.publishersOnlyMode??!1,metadataOnlyMode:e?.metadataOnlyMode??!1,noAccessMode:e?.noAccessMode??!1}}function vie(){const[e,r]=A.useState([]),[t,n]=A.useState(!1),[s,o]=A.useState(null),[i,c]=A.useState(!1),[l,a]=A.useState([]),[u,h]=A.useState([]),[d,f]=A.useState([]),[m,p]=A.useState([]),[g,b]=A.useState(!1),[y,w]=A.useState(null);A.useEffect(()=>{let I=!0;const $=new AbortController;async function D(){const F=Zt.getPublishersWithSolutions();if(F){r(F),c(!0);return}try{n(!0),o(null);const V=await MZ();I&&(r(V),Zt.setPublishersWithSolutions(V))}catch(V){I&&!$.signal.aborted&&o(V instanceof Error?V.message:String(V))}finally{I&&(n(!1),c(!0))}}return D(),()=>{I=!1,$.abort()}},[]),A.useEffect(()=>{if(!l.length){h([]),f([]);return}const I=new Set(l),$=e.filter(D=>I.has(D.publisher.publisherid)).flatMap(D=>D.solutions);h($),f(D=>{if(D.length===0)return D;const F=new Set($.map(G=>G.solutionid)),V=D.filter(G=>F.has(G));return V.length===D.length?D:V})},[l,e]),A.useEffect(()=>{if(!d.length){p([]),w(null);return}let I=!0;const $=new AbortController;async function D(){const F=Zt.getFilteredEntities(d);if(F){p(F);return}try{b(!0),w(null),Ie("entityFilters","[usePublisherFilter] Loading entities for solutions:",d);const V=await s_(d);Ie("entityFilters","[usePublisherFilter] Solution components received:",{solutionIds:d,componentCount:V.length,components:V.slice(0,10)});const G=Array.from(new Set(V.map(E=>E.msdyn_name).filter(Boolean)));Ie("entityFilters","[usePublisherFilter] Unique entity logical names extracted:",{count:G.length,names:G});const U=c_(G);Ie("entityFilters","[usePublisherFilter] Filtered entities from cache:",{count:U.length,entities:U.map(E=>E.LogicalName)}),I&&(p(U),Zt.setFilteredEntities(d,U))}catch(V){I&&!$.signal.aborted&&w(V instanceof Error?V.message:String(V))}finally{I&&b(!1)}}return D(),()=>{I=!1,$.abort()}},[d]);const C=A.useCallback(I=>{a(I)},[]),N=A.useCallback(I=>{f(I)},[]);return{publishers:e.map(I=>I.publisher),publishersLoading:t,publishersError:s,publishersLoaded:i,publishersWithSolutions:e,selectedPublisherIds:l,updateSelectedPublishers:C,solutions:u,selectedSolutionIds:d,updateSelectedSolutions:N,entities:m,entitiesLoading:g,entitiesError:y}}function yie(){const[e,r]=A.useState([]),[t,n]=A.useState(!1),[s,o]=A.useState(null),[i,c]=A.useState(!1),[l,a]=A.useState([]),[u,h]=A.useState([]),[d,f]=A.useState(!1),[m,p]=A.useState(null);A.useEffect(()=>{let b=!0;const y=new AbortController;async function w(){const C=Zt.getSolutions([]);if(C){r(C),c(!0);return}try{n(!0),o(null);const N=await DZ();b&&(r(N),Zt.setSolutions([],N))}catch(N){b&&!y.signal.aborted&&o(N instanceof Error?N.message:String(N))}finally{b&&(n(!1),c(!0))}}return w(),()=>{b=!1,y.abort()}},[]),A.useEffect(()=>{if(!l.length){h([]),p(null);return}let b=!0;const y=new AbortController;async function w(){const C=Zt.getFilteredEntities(l);if(C){h(C);return}try{f(!0),p(null),Ie("entityFilters","[useSolutionFilter] Loading entities for solutions:",l);const N=await s_(l);Ie("entityFilters","[useSolutionFilter] Solution components received:",{solutionIds:l,componentCount:N.length,components:N.slice(0,10)});const I=Array.from(new Set(N.map(D=>D.msdyn_name).filter(Boolean)));Ie("entityFilters","[useSolutionFilter] Unique entity logical names extracted:",{count:I.length,names:I});const $=c_(I);Ie("entityFilters","[useSolutionFilter] Filtered entities from cache:",{count:$.length,entities:$.map(D=>D.LogicalName)}),b&&(h($),Zt.setFilteredEntities(l,$))}catch(N){b&&!y.signal.aborted&&p(N instanceof Error?N.message:String(N))}finally{b&&f(!1)}}return w(),()=>{b=!1,y.abort()}},[l]);const g=A.useCallback(b=>{a(b)},[]);return{solutions:e,solutionsLoading:t,solutionsError:s,solutionsLoaded:i,selectedSolutionIds:l,updateSelectedSolutions:g,entities:u,entitiesLoading:d,entitiesError:m}}function wie({entity:e,view:r,solutions:t}){const n=[];return e&&n.push(e),r&&n.push(`View: ${r}`),t?.length&&n.push(t.join(", ")),n}const Q5=e=>e.join(" · "),Z5="fetchxml-studio:scopeSelection";function xie(e){return(e??"").trim().replace(/\/+$/,"").toLowerCase()}const J5=e=>Array.isArray(e)?e.filter(r=>typeof r=="string"&&!!r):[];function C7(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const r={};for(const[t,n]of Object.entries(e)){if(!n||typeof n!="object")continue;const s=n;r[t]={publisherIds:J5(s.publisherIds),solutionIds:J5(s.solutionIds)}}return r}function ek(e,r){if(r)return C7(e)[r]}function kie(e,r,t){const n=C7(e);return r&&(t.publisherIds.length===0&&t.solutionIds.length===0?delete n[r]:n[r]={publisherIds:[...t.publisherIds],solutionIds:[...t.solutionIds]}),n}function tk(e,r){const t=new Set(r);return e.filter(n=>t.has(n))}const rk=(e,r)=>e.length===r.length&&e.every((t,n)=>t===r[n]),nk=()=>typeof window>"u"?void 0:window.toolboxAPI?.settings;function Sie({mode:e,ready:r,availablePublisherIds:t,availableSolutionIds:n,publisherIds:s,solutionIds:o,apply:i}){const[c,l]=A.useState(null),a=A.useRef(void 0),[u,h]=A.useState(new Set);return A.useEffect(()=>{let d=!0;const f=nk();if(!f?.get){l({stored:void 0,envKey:""});return}return Promise.all([f.get(Z5),Zs()]).then(([m,p])=>{d&&(a.current=m,l({stored:m,envKey:xie(p?.url)}))}).catch(m=>{console.warn("Failed to read the remembered publisher / solution selection:",m),d&&l({stored:void 0,envKey:""})}),()=>{d=!1}},[]),A.useEffect(()=>{if(!c||!e||e==="all"||!r||u.has(e))return;const d=ek(a.current,c.envKey);if(d){const f=e==="publisher-solution"?tk(d.publisherIds,t):[],m=tk(d.solutionIds,n(f));Ie("entityFilters","[useRememberedScope] Restoring the selection:",{mode:e,publishers:f,solutions:m}),(e==="solution-only"||f.length>0)&&i({publisherIds:f,solutionIds:m})}h(f=>new Set(f).add(e))},[c,e,r,u,t,n,i]),A.useEffect(()=>{if(!c?.envKey||!e||e==="all"||!u.has(e))return;const d=ek(a.current,c.envKey),f={publisherIds:e==="publisher-solution"?[...s]:d?.publisherIds??[],solutionIds:[...o]};(d?rk(d.publisherIds,f.publisherIds)&&rk(d.solutionIds,f.solutionIds):!f.publisherIds.length&&!f.solutionIds.length)||(a.current=kie(a.current,c.envKey,f),nk()?.set?.(Z5,a.current).catch(m=>console.warn("Failed to remember the publisher / solution selection:",m)))},[c,e,u,s,o]),!!c?.envKey}const T7=wr({container:{display:"flex",flexDirection:"column",gap:"4px",flex:1,minWidth:0,maxWidth:"350px"},label:{fontSize:"14px",fontWeight:600,color:le.colorNeutralForeground2},combobox:{width:"100%",minWidth:0},comboboxInput:{minWidth:0,width:"100%"},loadingOption:{display:"flex",alignItems:"center",gap:"8px",padding:"8px"},noViewsOption:{fontStyle:"italic",color:le.colorNeutralForeground3},option:{display:"flex",flexDirection:"column",minWidth:0},optionSecondary:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200}});function ok({view:e,currentUserId:r}){const t=T7(),n=MQ(e,r);return j.jsx(Jt,{value:e.id,text:e.name,children:j.jsxs("span",{className:t.option,children:[j.jsx("span",{children:e.name}),n&&j.jsx("span",{className:t.optionSecondary,children:n})]})})}function _ie({selectedEntityMetadata:e,onViewSelect:r,onViewClear:t,disabled:n=!1,onSelectedViewChange:s}){const o=T7(),[i,c]=A.useState([]),[l,a]=A.useState([]),[u,h]=A.useState(!1),[d,f]=A.useState(null),[m,p]=A.useState(""),[g,b]=A.useState(null),[y,w]=A.useState(void 0);A.useEffect(()=>{s?.(g)},[g,s]),A.useEffect(()=>{if(!e){c([]),a([]),f(null),b(null),p("");return}(async()=>{h(!0),f(null),b(null),p("");try{Ie("viewAPI",`Loading views for ${e.LogicalName}`);const[{systemViews:E,personalViews:M},B]=await Promise.all([FZ(e.LogicalName),oi()]);c(E),a(M),w(B?.UserId),Ie("viewAPI",`Loaded ${E.length} system views and ${M.length} personal views`)}catch(E){const M=E instanceof Error?E.message:"Failed to load views";f(M),console.error("LoadViewPicker: Failed to fetch views:",E)}finally{h(!1)}})()},[e]);const C=A.useMemo(()=>[...i,...l],[i,l]),N=m&&m!==g?m:"",I=A.useMemo(()=>{if(!N.trim())return i;const U=N.toLowerCase();return i.filter(E=>E.name.toLowerCase().includes(U))},[i,N]),$=A.useMemo(()=>{if(!N.trim())return l;const U=N.toLowerCase();return l.filter(E=>E.name.toLowerCase().includes(U))},[l,N]),D=A.useCallback((U,E)=>{if(!E.optionValue){b(null),p(""),t?.(),Ie("viewAPI","View selection cleared");return}if(!e)return;const M=C.find(B=>B.id===E.optionValue);if(M){const B={id:M.id,type:M.type,originalFetchXml:M.fetchxml,entitySetName:e.EntitySetName,name:M.name,layoutxml:M.layoutxml,queryType:M.queryType,isCustomizable:M.isCustomizable,description:M.description,isDefault:M.isDefault,isManaged:M.isManaged,solutionId:M.solutionId,ownerId:M.ownerId,ownerName:M.ownerName};r(B),Ie("viewAPI",`Selected view: ${M.name} (${M.type}) - ID: ${M.id}`),b(M.name),p(M.name)}},[C,r,t,e]),F=A.useCallback(U=>{p(U.target.value),U.target.value!==g&&b(null)},[g]);if(!e)return null;const V=i.length>0||l.length>0,G=I.length>0||$.length>0;return j.jsxs("div",{className:o.container,children:[j.jsx("label",{className:o.label,children:"Load view"}),j.jsxs(Zn,{className:o.combobox,input:{className:o.comboboxInput},placeholder:u?"Loading views…":"Select a view to load…",disabled:n||u||!V,value:m,onChange:F,onOptionSelect:D,clearable:!!g,freeform:!0,children:[u&&j.jsx(Jt,{value:"",text:"Loading…",disabled:!0,children:j.jsxs("div",{className:o.loadingOption,children:[j.jsx(hn,{size:"tiny"}),j.jsx("span",{children:"Loading views…"})]})},"loading"),!u&&d&&j.jsx(Jt,{value:"",text:"Error",disabled:!0,children:j.jsx("span",{style:{color:le.colorPaletteRedForeground1},children:d})},"error"),!u&&!d&&!V&&j.jsx(Jt,{value:"",text:"No views available",disabled:!0,children:j.jsx("span",{className:o.noViewsOption,children:"No views available"})},"no-views"),!u&&!d&&V&&!G&&N&&j.jsx(Jt,{value:"",text:"No matching views",disabled:!0,children:j.jsxs("span",{className:o.noViewsOption,children:['No views match "',N.trim(),'"']})},"no-match"),!u&&!d&&I.length>0&&j.jsx(ja,{label:"System views",children:I.map(U=>j.jsx(ok,{view:U,currentUserId:y},U.id))}),!u&&!d&&$.length>0&&j.jsx(ja,{label:"Personal views",children:$.map(U=>j.jsx(ok,{view:U,currentUserId:y},U.id))})]})]})}const Cie=wr({container:{display:"flex",flexDirection:"column",gap:"8px",padding:"8px 12px",borderBottom:`1px solid ${le.colorNeutralStroke1}`,containerType:"inline-size"},header:{display:"flex",alignItems:"center",gap:"6px",minWidth:0},summary:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},body:{display:"flex",flexDirection:"column",gap:"8px"},bodyCollapsed:{display:"none"},filtersRow:{display:"flex",gap:"12px",alignItems:"flex-end",flexWrap:"wrap","@container (max-width: 519px)":{flexDirection:"column",alignItems:"stretch"}},entityRow:{display:"flex",alignItems:"flex-end",gap:"12px"},combobox:{minWidth:0,width:"100%"},comboboxInput:{minWidth:0,width:"100%"},newButton:{flexShrink:0,marginLeft:"auto","@container (max-width: 299px)":{minWidth:"28px",maxWidth:"28px",paddingLeft:"3px",paddingRight:"3px"}},newButtonLabel:{"@container (max-width: 299px)":{display:"none"}},field:{display:"flex",flexDirection:"column",gap:"4px",flex:1,minWidth:0},label:{fontSize:"14px",fontWeight:600,color:le.colorNeutralForeground2,display:"flex",alignItems:"center",gap:"6px"},disabledLabel:{color:le.colorNeutralForegroundDisabled},option:{display:"flex",flexDirection:"column",minWidth:0},optionSecondary:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200},note:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200,lineHeight:le.lineHeightBase200},loadingContainer:{display:"flex",alignItems:"center",justifyContent:"center",padding:"24px"},errorText:{color:le.colorPaletteRedForeground1,fontSize:"12px",marginTop:"4px"},noAccessMessage:{padding:"16px",color:le.colorNeutralForeground3,fontSize:"14px",textAlign:"center"},viewPickerRow:{display:"flex",gap:"12px",alignItems:"flex-end"}}),ik={style:{minWidth:260}};function ak(e,r){return e.length===0?r:e.length===1?e[0]:`${e.length} selected`}const sk=(e,r)=>{const t=r.trim().toLowerCase();return!t||e.friendlyname.toLowerCase().includes(t)||(e.uniquename??"").toLowerCase().includes(t)},Tie=(e,r)=>{const t=r.trim().toLowerCase();return!t||e.friendlyname.toLowerCase().includes(t)||(e.uniquename??"").toLowerCase().includes(t)||(e.customizationprefix??"").toLowerCase().includes(t)};function Bie({selectedEntity:e,onEntityChange:r,onNewQuery:t,onViewLoad:n,entityScopeMode:s,advancedFindOnly:o,collapsed:i,onCollapsedChange:c}){const l=Cie(),a=mr("publisher-combobox"),u=mr("solution-combobox"),h=mr("entity-combobox"),d=mr("query-scope"),{accessSummary:f,loading:m,noAccessMode:p}=_7(),g=A.useMemo(()=>m||p||!f?"all":s==="publisher-solution"&&f.fullFilterMode?"publisher-solution":s!=="all"&&(f.fullFilterMode||f.solutionsOnlyMode)?"solution-only":"all",[s,f,m,p]),b=vie(),y=yie(),{loadEntities:w}=g_(),[C,N]=A.useState([]),[I,$]=A.useState(!1);A.useEffect(()=>{g==="all"&&($(!0),w().then(Te=>N(Te)).catch(Te=>console.error("Failed to load entities:",Te)).finally(()=>$(!1)))},[g,w]);const D=A.useMemo(()=>{let Te=[];return g==="publisher-solution"?Te=b.entities:g==="solution-only"?Te=y.entities:Te=C,o&&(Te=Te.filter(Ee=>bJ(Ee,o))),Te},[g,o,b.entities,y.entities,C]),F=A.useMemo(()=>e?D.find(Te=>Te.LogicalName===e)??Zt.getAllEntityMetadata()?.find(Te=>Te.LogicalName===e)??C.find(Te=>Te.LogicalName===e)??null:null,[e,D,C]),[V,G]=A.useState(null),U=A.useCallback(Te=>{n&&n(Te)},[n]),E=A.useCallback(()=>{e&&r(e)},[e,r]),[M,B]=A.useState(""),k=A.useMemo(()=>b.publishers.filter(Te=>Tie(Te,M)),[M,b.publishers]);A.useEffect(()=>{Ie("entityFilters","[EntitySelector] Publisher Filter State:",{publisherQuery:M,totalPublishers:b.publishers.length,filteredPublishers:k.length,selectedPublisherIds:b.selectedPublisherIds})},[M,b.publishers,k,b.selectedPublisherIds]);const _=(Te,Ee)=>{b.updateSelectedPublishers(Ee.selectedOptions),B("")},S=A.useMemo(()=>ak(b.publishers.filter(Te=>b.selectedPublisherIds.includes(Te.publisherid)).map(Te=>Te.friendlyname),"Select publishers…"),[b.selectedPublisherIds,b.publishers]),[T,z]=A.useState(""),P=g==="publisher-solution"?b.solutions:y.solutions,O=g==="publisher-solution"?b.selectedSolutionIds:y.selectedSolutionIds,{unmanagedSolutions:X,managedSolutions:K}=A.useMemo(()=>{const Te=P.filter($e=>!$e.ismanaged),Ee=P.filter($e=>$e.ismanaged);return{unmanagedSolutions:Te,managedSolutions:Ee}},[P]),J=(Te,Ee)=>{g==="publisher-solution"?b.updateSelectedSolutions(Ee.selectedOptions):g==="solution-only"&&y.updateSelectedSolutions(Ee.selectedOptions),z("")},H=A.useMemo(()=>P.filter(Te=>O.includes(Te.solutionid)).map(Te=>Te.friendlyname),[O,P]),{publishersWithSolutions:Z,updateSelectedPublishers:L,updateSelectedSolutions:q}=b,{updateSelectedSolutions:Y}=y,re=A.useMemo(()=>Z.map(Te=>Te.publisher.publisherid),[Z]),ie=A.useCallback(Te=>g==="publisher-solution"?Z.filter(Ee=>Te.includes(Ee.publisher.publisherid)).flatMap(Ee=>Ee.solutions.map($e=>$e.solutionid)):y.solutions.map(Ee=>Ee.solutionid),[g,Z,y.solutions]),ne=A.useCallback(Te=>{g==="publisher-solution"?(L(Te.publisherIds),q(Te.solutionIds)):Y(Te.solutionIds)},[g,L,q,Y]),ae=Sie({mode:m?null:g,ready:g==="publisher-solution"?b.publishersLoaded:y.solutionsLoaded,availablePublisherIds:re,availableSolutionIds:ie,publisherIds:b.selectedPublisherIds,solutionIds:O,apply:ne}),[be,pe]=A.useState(""),te=A.useMemo(()=>D.map(Te=>{const $e=`${Te.DisplayName?.UserLocalizedLabel?.Label||Te.LogicalName} (${Te.LogicalName})`;return{value:Te.LogicalName,children:$e}}),[D]);A.useEffect(()=>{if(e){const Te=D.find(Ee=>Ee.LogicalName===e);if(Te){const Ee=Te.DisplayName?.UserLocalizedLabel?.Label||Te.LogicalName;pe(`${Ee} (${Te.LogicalName})`)}else pe(e)}else pe("")},[e,D]);const se=dp(be,te,{noOptionsMessage:"No entities found"}),ue=(Te,Ee)=>{Ee.optionValue?(r(Ee.optionValue),pe(Ee.optionText??"")):pe("")},he=e?F?.DisplayName?.UserLocalizedLabel?.Label||e:null,me=wie({entity:he,view:F&&n?V:null,solutions:g==="all"?[]:H});if(m)return j.jsx("div",{className:l.container,children:j.jsx("div",{className:l.loadingContainer,children:j.jsx(hn,{size:"small",label:"Checking access permissions…"})})});if(p)return j.jsx("div",{className:l.container,children:j.jsxs("div",{className:l.noAccessMessage,children:[j.jsx(M2,{style:{marginBottom:"8px"}}),j.jsx("div",{children:"You don't have permission to read metadata (prvReadCustomization)."}),j.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:"Contact your system administrator to request access."})]})});const xe=g==="publisher-solution"?b.entitiesLoading:g==="solution-only"?y.entitiesLoading:I,Be=g==="publisher-solution"?b.entitiesError:g==="solution-only"?y.entitiesError:null,Re=Te=>j.jsx(Jt,{value:Te.solutionid,text:Te.friendlyname,children:j.jsxs("span",{className:l.option,children:[j.jsx("span",{children:Te.friendlyname}),j.jsx("span",{className:l.optionSecondary,children:[Te.uniquename,Te.version&&`v${Te.version}`].filter(Boolean).join(" · ")})]})},Te.solutionid),He=Te=>{if(Te)return j.jsx(Jt,{disabled:!0,children:Te});if(X.length===0&&K.length===0)return j.jsx(Jt,{disabled:!0,children:"No solutions found"});const Ee=X.filter(Ze=>sk(Ze,T)),$e=K.filter(Ze=>sk(Ze,T));return Ee.length===0&&$e.length===0?j.jsx(Jt,{disabled:!0,children:`No solutions match "${T.trim()}"`}):j.jsxs(j.Fragment,{children:[Ee.length>0&&j.jsx(ja,{label:"Unmanaged",children:Ee.map(Re)}),$e.length>0&&j.jsx(ja,{label:"Managed",children:$e.map(Re)})]})},Je=(Te,Ee)=>j.jsx(Zn,{className:l.combobox,input:{className:l.comboboxInput},listbox:ik,"aria-labelledby":u,placeholder:ak(H,"Select solutions…"),multiselect:!0,value:T,selectedOptions:O,onOptionSelect:J,onChange:$e=>z($e.target.value),disabled:Te,children:He(Ee)});return j.jsxs("div",{className:l.container,children:[j.jsxs("div",{className:l.header,children:[j.jsx(Or,{content:i?"Expand":"Collapse",relationship:"label",children:j.jsx(St,{appearance:"subtle",size:"small",icon:i?j.jsx(RR,{}):j.jsx(MR,{}),onClick:()=>c(!i),"aria-expanded":!i,"aria-controls":d})}),i&&me.length>0?j.jsx(st,{className:l.summary,title:Q5(me),children:he?j.jsxs(j.Fragment,{children:[j.jsx("b",{children:me[0]}),me.slice(1).map(Te=>` · ${Te}`)]}):Q5(me)}):j.jsx(st,{weight:"semibold",className:l.summary,children:"Query scope"}),j.jsx(Or,{content:"New query",relationship:"label",children:j.jsx(St,{className:l.newButton,appearance:"primary",size:"small",icon:j.jsx(rp,{}),onClick:t,children:j.jsx("span",{className:l.newButtonLabel,children:"New"})})})]}),j.jsxs("div",{id:d,className:de(l.body,i&&l.bodyCollapsed),children:[g==="publisher-solution"&&j.jsxs("div",{className:l.filtersRow,children:[j.jsxs("div",{className:l.field,children:[j.jsx("label",{id:a,className:l.label,children:"Publishers"}),j.jsx(Zn,{className:l.combobox,input:{className:l.comboboxInput},listbox:ik,"aria-labelledby":a,placeholder:S,multiselect:!0,value:M,selectedOptions:b.selectedPublisherIds,onOptionSelect:_,onChange:Te=>B(Te.target.value),disabled:b.publishersLoading,children:k.length===0?j.jsx(Jt,{disabled:!0,children:M.trim()?`No publishers match "${M.trim()}"`:"No publishers found"}):k.map(Te=>j.jsx(Jt,{value:Te.publisherid,text:Te.friendlyname,children:j.jsxs("span",{className:l.option,children:[j.jsx("span",{children:Te.friendlyname}),j.jsx("span",{className:l.optionSecondary,children:[Te.uniquename,Te.customizationprefix&&`prefix ${Te.customizationprefix}_`].filter(Boolean).join(" · ")})]})},Te.publisherid))}),b.publishersError&&j.jsx("div",{className:l.errorText,children:b.publishersError})]}),j.jsxs("div",{className:l.field,children:[j.jsx("label",{id:u,className:l.label,children:"Solutions"}),Je(b.selectedPublisherIds.length===0,b.selectedPublisherIds.length===0?"Select a publisher first":void 0)]})]}),g==="solution-only"&&j.jsxs("div",{className:l.filtersRow,children:[j.jsxs("div",{className:l.field,children:[j.jsx(Or,{content:"Publisher filtering requires prvReadPublisher privilege",relationship:"description",children:j.jsxs("label",{id:a,className:`${l.label} ${l.disabledLabel}`,children:["Publishers ",j.jsx(M2,{fontSize:14})]})}),j.jsx(Zn,{className:l.combobox,input:{className:l.comboboxInput},"aria-labelledby":a,placeholder:"No access to publishers",disabled:!0,children:j.jsx(Jt,{children:"Requires prvReadPublisher privilege"})})]}),j.jsxs("div",{className:l.field,children:[j.jsx("label",{id:u,className:l.label,children:"Solutions"}),Je(y.solutionsLoading,y.solutionsLoading?"Loading…":void 0),y.solutionsError&&j.jsx("div",{className:l.errorText,children:y.solutionsError})]})]}),j.jsx("div",{className:l.entityRow,children:j.jsxs("div",{className:l.field,children:[j.jsx("label",{id:h,className:l.label,children:"Entity"}),j.jsx(Zn,{className:l.combobox,input:{className:l.comboboxInput},"aria-labelledby":h,placeholder:xe?"Loading entities…":"Select an entity…",value:be,onOptionSelect:ue,onChange:Te=>pe(Te.target.value),clearable:!0,disabled:xe||D.length===0,children:xe?j.jsx(Jt,{disabled:!0,children:"Loading…"}):D.length===0?j.jsx(Jt,{disabled:!0,children:g!=="all"?"Select a solution first":"No entities found"}):se}),Be&&j.jsx("div",{className:l.errorText,children:Be})]})}),F&&n&&j.jsx("div",{className:l.viewPickerRow,children:j.jsx(_ie,{selectedEntityMetadata:F,onViewSelect:U,onViewClear:E,onSelectedViewChange:G})}),ae&&g!=="all"&&j.jsx(st,{className:l.note,children:g==="publisher-solution"?"Your publisher and solution selection is remembered for this environment.":"Your solution selection is remembered for this environment."})]})]})}const jie=wr({container:{display:"flex",flexDirection:"column",gap:"4px"},combobox:{width:"100%"},hint:{fontSize:"12px",color:le.colorNeutralForeground3},solutionOption:{display:"flex",flexDirection:"column",gap:"2px"},solutionName:{fontWeight:500},solutionUniqueName:{fontSize:"11px",color:le.colorNeutralForeground3}});function Nie({solutions:e,selectedSolution:r,onSolutionChange:t,disabled:n=!1}){const s=jie(),o=A.useMemo(()=>[...e].sort((c,l)=>(c.friendlyname||c.uniquename).localeCompare(l.friendlyname||l.uniquename)),[e]),i=(c,l)=>{if(l.optionValue==="__none__")t(null);else{const a=e.find(u=>u.solutionid===l.optionValue);t(a||null)}};return j.jsxs("div",{className:s.container,children:[j.jsx(Eo,{label:"Add to solution",hint:"Select a solution to include the view in",children:j.jsxs(Zn,{className:s.combobox,placeholder:"Select solution (optional)",value:r?.friendlyname||"",onOptionSelect:i,disabled:n,children:[j.jsx(Jt,{value:"__none__",text:"",children:j.jsx("span",{style:{fontStyle:"italic",color:le.colorNeutralForeground3},children:"None - don't add to any solution"})}),o.map(c=>j.jsx(Jt,{value:c.solutionid,text:c.friendlyname||c.uniquename,children:j.jsxs("div",{className:s.solutionOption,children:[j.jsx("span",{className:s.solutionName,children:c.friendlyname||c.uniquename}),j.jsxs("span",{className:s.solutionUniqueName,children:[c.uniquename,c.version&&` (v${c.version})`]})]})},c.solutionid))]})}),e.length===0&&j.jsx(st,{className:s.hint,children:"No unmanaged solutions available. The view will be created in the Default solution."})]})}const Eie=100,B7=e=>e?.trim().toLowerCase()==="production",Vf=e=>e===1?"1 record":`${e.toLocaleString()} records`;function Aie(e){switch(e.kind){case"records":return Vf(e.count);case"text":return e.text;case"allMatching":{const r="Every record the query matches",t=e.loadedCount;return t?e.moreRecords===!0?`${r} (more than the ${Vf(t)} loaded)`:e.moreRecords===!1?`${r} (${Vf(t)} when the query last ran)`:`${r} (${Vf(t)} loaded; there may be more)`:r}}}function Rie(e,r){return B7(e)?!0:r.kind==="records"?r.count>Eie:r.kind==="allMatching"}const zie=(e,r)=>e.trim().toLowerCase()===r.trim().toLowerCase()&&r.trim()!=="",Iie=wr({root:{display:"flex",flexDirection:"column",gap:le.spacingVerticalS},box:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:le.spacingHorizontalM,rowGap:le.spacingVerticalXS,padding:`${le.spacingVerticalS} ${le.spacingHorizontalM}`,backgroundColor:le.colorNeutralBackground3,borderRadius:le.borderRadiusMedium},label:{color:le.colorNeutralForeground3},value:{display:"flex",flexWrap:"wrap",alignItems:"center",columnGap:le.spacingHorizontalS,minWidth:0},secondary:{color:le.colorNeutralForeground3,wordBreak:"break-all"}});function yd({entityLogicalName:e,entityDisplayName:r,scope:t,onConfirmationChange:n,disabled:s}){const o=Iie(),[i,c]=A.useState({status:"loading"}),[l,a]=A.useState("");A.useEffect(()=>{let g=!0;return Zs().then(b=>g&&c({status:"ready",connection:b})).catch(b=>{console.warn("TargetScope: couldn't read the connection:",b),g&&c({status:"ready",connection:null})}),()=>{g=!1}},[]);const u=i.status==="ready"?i.connection:null,h=B7(u?.environment),d=r||(e?Zt.getEntityMetadata(e)?.DisplayName?.UserLocalizedLabel?.Label:void 0),f=e||"confirm",m=!!n&&i.status==="ready"&&Rie(u?.environment,t),p=i.status==="ready"&&(!m||zie(l,f));return A.useEffect(()=>{n?.(p)},[p,n]),j.jsxs("div",{className:o.root,children:[h&&j.jsx(Ar,{intent:"warning",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Production environment"}),"This changes live data."]})}),j.jsxs("div",{className:o.box,children:[j.jsx(st,{className:o.label,children:"Environment"}),j.jsx("div",{className:o.value,children:i.status==="loading"?j.jsx(st,{children:"Reading the connection..."}):u?j.jsxs(j.Fragment,{children:[j.jsx(st,{weight:"semibold",children:u.name}),u.environment&&j.jsx(ri,{size:"small",appearance:h?"filled":"tint",color:h?"warning":"informative",children:u.environment}),j.jsx(st,{size:200,className:o.secondary,children:u.url})]}):j.jsx(st,{children:"Unknown (the tool has no connection)"})}),j.jsx(st,{className:o.label,children:"Entity"}),j.jsxs("div",{className:o.value,children:[j.jsx(st,{weight:"semibold",children:d||e||"Unknown"}),d&&e&&d!==e&&j.jsxs(st,{className:o.secondary,children:["(",e,")"]})]}),j.jsx(st,{className:o.label,children:"Scope"}),j.jsx("div",{className:o.value,children:j.jsx(st,{weight:"semibold",children:Aie(t)})})]}),m&&j.jsx(Eo,{label:j.jsxs(j.Fragment,{children:["Type ",j.jsx("strong",{children:f})," to confirm"]}),hint:h?"Required on a Production environment.":"Required for more than 100 records, or when the total isn't known.",children:j.jsx(_n,{value:l,onChange:(g,b)=>a(b.value),disabled:s,autoComplete:"off"})})]})}const Mie=wr({surface:{maxWidth:"500px",width:"100%"},content:{display:"flex",flexDirection:"column",gap:"16px"},fieldGroup:{display:"flex",flexDirection:"column",gap:"12px"},validationSection:{display:"flex",flexDirection:"column",gap:"8px"},validationHeader:{display:"flex",alignItems:"center",gap:"8px"},validationList:{display:"flex",flexDirection:"column",gap:"6px",maxHeight:"150px",overflowY:"auto",paddingLeft:"4px"},validationItem:{display:"flex",alignItems:"flex-start",gap:"8px",fontSize:"13px"},severityIcon:{flexShrink:0,marginTop:"2px"},severityLow:{color:le.colorPaletteBlueBackground2},severityMedium:{color:le.colorPaletteYellowForeground1},severityHigh:{color:le.colorPaletteRedForeground1},severityCritical:{color:le.colorPaletteRedForeground1},solutionInfo:{display:"flex",flexDirection:"column",gap:"4px",padding:"8px 12px",backgroundColor:le.colorNeutralBackground3,borderRadius:"4px",marginTop:"8px"},solutionLabel:{fontSize:"12px",color:le.colorNeutralForeground3},solutionValue:{fontSize:"13px",fontWeight:500},overwriteWarning:{marginTop:"4px"},radioDescription:{fontSize:"12px",color:le.colorNeutralForeground3,marginLeft:"28px",marginTop:"-4px"},publishNote:{fontSize:"12px",color:le.colorNeutralForeground3,fontStyle:"italic"},accessCheck:{display:"flex",alignItems:"center",gap:"8px"},placeholderNote:{fontSize:"12px",color:le.colorNeutralForeground3},code:{fontFamily:le.fontFamilyMonospace}});function Die({open:e,onClose:r,onSaveComplete:t,mode:n,shouldPublish:s,fetchXml:o,layoutXml:i,entityLogicalName:c,entityDisplayName:l,objectTypeCode:a,primaryIdAttribute:u,loadedView:h}){const d=Mie(),[f,m]=A.useState(""),[p,g]=A.useState(""),[b,y]=A.useState("personal"),[w,C]=A.useState(null),[N,I]=A.useState([]),[$,D]=A.useState(!1),[F,V]=A.useState(null),[G,U]=A.useState(null),[E,M]=A.useState({status:"idle",messages:[]}),[B,k]=A.useState(!1),[_,S]=A.useState(null),[T,z]=A.useState(!1),[P,O]=A.useState(void 0),[X,K]=A.useState("unknown"),[J,H]=A.useState(null),[Z,L]=A.useState(!1),[q,Y]=A.useState(null),re=n==="save"&&h!==null,ie=re&&!T,ne=ie&&h!==null&&!LQ(h),ae=ie&&X==="denied",be=ne||ae,pe=ie&&X==="checking",te=ie&&h!==null&&ib(h,P),se=ie&&h?.type==="system"&&h.isManaged===!0,ue=!be&&(ie&&h?PQ(h):b==="system"),he=ie&&h?.isDefault===!0,me=A.useMemo(()=>sb(o)>0,[o]);A.useEffect(()=>{e&&(re&&h?(m(h.name),y(h.type),g(h.description??""),L(h.isDefault===!0)):(m(""),y("personal"),g(""),L(!1)),z(!1),S(null),M({status:"idle",messages:[]}))},[e,re,h]),A.useEffect(()=>{if(!e||!re||h?.type!=="personal"){K("unknown");return}let Ee=!0;return K("checking"),(async()=>{const $e=await oi();if(!Ee)return;O($e?.UserId);const yt=!!$e&&!!h.ownerId&&!ib(h,$e.UserId)?!0:await VZ(h.id);Ee&&K(yt===void 0?"unknown":yt?"allowed":"denied")})(),()=>{Ee=!1}},[e,re,h]),A.useEffect(()=>{if(H(null),!e||!se||!h?.solutionId)return;let Ee=!0;return WZ(h.solutionId).then($e=>{Ee&&H($e)}),()=>{Ee=!1}},[e,se,h]),A.useEffect(()=>{if(!e||!ue||!c)return;let Ee=!0;return UZ(c).then($e=>{Ee&&Y($e)}),()=>{Ee=!1}},[e,ue,c]),A.useEffect(()=>{e&&($Z().then(V),HZ().then(U))},[e]),A.useEffect(()=>{if(!e||b!=="system")return;async function Ee(){D(!0);try{const $e=await XZ();I($e)}catch($e){console.error("Failed to load solution info:",$e),I([])}finally{D(!1)}}Ee()},[e,b]),A.useEffect(()=>{if(!e||!o)return;async function Ee(){M({status:"validating",messages:[]});try{const Ze=(await qZ(o)).ValidationResults?.Messages||[];M({status:qQ(Ze),messages:Ze})}catch($e){console.warn("FetchXML validation unavailable:",$e),M({status:"unavailable",messages:[],errorMessage:"Validation unavailable - FetchXML will be validated when saved"})}}Ee()},[e,o]);const xe=A.useCallback(Ee=>{switch(Ee){case 0:return j.jsx(jg,{className:`${d.severityIcon} ${d.severityLow}`});case 1:return j.jsx(B2,{className:`${d.severityIcon} ${d.severityMedium}`});case 2:case 3:return j.jsx(E2,{className:`${d.severityIcon} ${d.severityHigh}`});default:return j.jsx(jg,{className:`${d.severityIcon} ${d.severityLow}`})}},[d]),Be=A.useMemo(()=>{if(!f.trim()||B||be||pe)return!1;if(b==="system"){if(!F?.canWrite)return!1}else if(!G?.canWrite)return!1;return!0},[f,B,be,pe,b,F,G]),Re=A.useCallback(async()=>{if(!Be)return;k(!0),S(null);const Ee=Bh();try{let $e;const Ze=p.trim(),yt=ue&&Z&&!he;if(b==="personal")ie&&h?(await QZ(h.id,{name:f.trim(),fetchxml:o,layoutxml:i,description:Ze||null}),$e=h.id):$e=await YZ({name:f.trim(),fetchxml:o,layoutxml:i,returnedtypecode:c,description:Ze||void 0,querytype:0});else{const dt=ie&&h?h.queryType??0:0;await LZ(o,dt),ie&&h?(await KZ(h.id,{name:f.trim(),fetchxml:o,layoutxml:i,description:Ze||null,...yt?{isdefault:!0}:{}}),$e=h.id):($e=await GZ({name:f.trim(),fetchxml:o,layoutxml:i,returnedtypecode:c,description:Ze||void 0,querytype:0,isdefault:yt}),w&&await ZZ($e,JZ,w.uniquename,!1)),s&&await eJ(c)}t($e,b,f.trim(),{description:Ze||void 0,isDefault:b==="system"?yt||he:void 0})}catch($e){console.error("Failed to save view:",$e),S(zn($e,"Failed to save view"))}finally{Ee(),k(!1)}},[Be,b,ie,h,f,o,i,p,c,w,s,t,ue,Z,he]),He=A.useCallback(()=>{h&&(z(!0),m(`${h.name} (copy)`),y("personal"),L(!1),S(null))},[h]),Je=A.useMemo(()=>ie?s?"Save and publish view":"Save view":"Save as new view",[ie,s]),Te=A.useMemo(()=>{const Ee=s&&b==="system"?", then published":"";return ie&&h?`The ${h.type} view "${h.name}" (overwritten${Ee})`:`A new ${b} view${Ee}`},[ie,h,s,b]);return j.jsx(Do,{open:e,onOpenChange:(Ee,$e)=>!$e.open&&r(),children:j.jsx(zi,{className:d.surface,children:j.jsxs(Ai,{children:[j.jsx(Ri,{action:j.jsx(St,{appearance:"subtle","aria-label":"Close",icon:j.jsx(sl,{}),onClick:r}),children:Je}),j.jsxs(Ii,{className:d.content,children:[j.jsx(yd,{entityLogicalName:c,scope:{kind:"text",text:Te}}),j.jsxs("div",{className:d.validationSection,children:[j.jsxs("div",{className:d.validationHeader,children:[E.status==="validating"&&j.jsxs(j.Fragment,{children:[j.jsx(hn,{size:"tiny"}),j.jsx(st,{children:"Validating FetchXML..."})]}),E.status==="valid"&&j.jsxs(j.Fragment,{children:[j.jsx(eR,{style:{color:le.colorPaletteGreenForeground1}}),j.jsx(st,{children:"No performance issues found"})]}),(E.status==="warning"||E.status==="error")&&j.jsxs(j.Fragment,{children:[E.status==="error"?j.jsx(E2,{style:{color:le.colorPaletteRedForeground1}}):j.jsx(B2,{style:{color:le.colorPaletteYellowForeground1}}),j.jsxs(st,{children:[E.messages.length," validation"," ",E.messages.length===1?"message":"messages"]})]}),E.status==="unavailable"&&j.jsxs(j.Fragment,{children:[j.jsx(jg,{style:{color:le.colorNeutralForeground3}}),j.jsx(st,{children:E.errorMessage})]})]}),E.messages.length>0&&j.jsx("div",{className:d.validationList,children:E.messages.map((Ee,$e)=>j.jsxs("div",{className:d.validationItem,children:[xe(Ee.Severity),j.jsx("span",{children:Ee.LocalizedMessageText})]},$e))})]}),j.jsx(Sh,{}),pe&&h&&j.jsxs("div",{className:d.accessCheck,children:[j.jsx(hn,{size:"tiny"}),j.jsxs(st,{children:['Checking your access to "',h.name,'"…']})]}),!pe&&j.jsxs("div",{className:d.fieldGroup,children:[ae&&h&&j.jsx(Ar,{intent:"error",layout:"multiline",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Can't overwrite this view"}),h.ownerName?`${h.ownerName} shared "${h.name}" with you without write access. Save a copy instead.`:`"${h.name}" was shared with you without write access. Save a copy instead.`]})}),j.jsx(Eo,{label:"Name",required:!0,children:j.jsx(_n,{value:f,onChange:(Ee,$e)=>m($e.value),placeholder:"Enter view name",disabled:B||be})}),j.jsx(Eo,{label:"Description",hint:ie&&h?.description?"Loaded from the view.":void 0,children:j.jsx(Sv,{value:p,onChange:(Ee,$e)=>g($e.value),placeholder:"Optional description",disabled:B||be,rows:2})}),!ie&&j.jsx(Eo,{label:"View type",children:j.jsxs(ta,{value:b,onChange:(Ee,$e)=>y($e.value),disabled:B,children:[j.jsx(Yr,{value:"personal",label:"Personal view",disabled:!G?.canWrite}),j.jsx("div",{className:d.radioDescription,children:G?.canWrite?"Only visible to you":"You don't have permission to create personal views"}),j.jsx(Yr,{value:"system",label:"System view",disabled:!F?.canWrite}),j.jsx("div",{className:d.radioDescription,children:F?.canWrite?"Visible to all users with access to this entity":"You don't have permission to create system views"})]})}),b==="system"&&!ie&&j.jsx(j.Fragment,{children:$?j.jsx("div",{className:d.solutionInfo,children:j.jsx(hn,{size:"tiny",label:"Loading solutions..."})}):j.jsx(Nie,{solutions:N,selectedSolution:w,onSolutionChange:C,disabled:B})})," ",ue&&j.jsx(Eo,{hint:he?"This is the default view. To change the default, set another public view as default.":q&&q.id!==h?.id?`Replaces "${q.name}" as the default public view for ${l||c}.`:void 0,children:j.jsx(ho,{label:"Set as default view",checked:Z,disabled:B||he,onChange:(Ee,$e)=>L($e.checked===!0)})}),ne&&h&&j.jsx(Ar,{intent:"error",className:d.overwriteWarning,children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Can't overwrite this view"}),'"',h.name,`" isn't customizable. Save a copy instead.`]})}),se&&!be&&h&&j.jsx(Ar,{intent:"warning",layout:"multiline",className:d.overwriteWarning,children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Managed view"}),J?`"${h.name}" comes from the managed solution ${J.friendlyName} (${J.uniqueName}).`:`"${h.name}" comes from a managed solution.`," ","Saving adds an unmanaged customization on top of it, which stays in effect until it's removed, even after the solution is updated."]})}),te&&!be&&h&&j.jsx(Ar,{intent:"warning",layout:"multiline",className:d.overwriteWarning,children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Overwrite warning"}),'"',h.name,'" belongs to ',h.ownerName||"another user",". Saving changes it for everyone it's shared with."]})}),ie&&!be&&!se&&!te&&h&&j.jsx(Ar,{intent:"warning",className:d.overwriteWarning,children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Overwrite warning"}),'This will overwrite the existing view "',h.name,'".']})}),me&&!be&&j.jsxs(st,{className:d.placeholderNote,children:[j.jsx("span",{className:d.code,children:"{0}"})," placeholders are saved as written. The quick find test value is only used to run the query."]}),s&&b==="system"&&j.jsx(st,{className:d.publishNote,children:"The view will be published after saving, making it immediately available to users."})]}),_&&j.jsx(Ar,{intent:"error",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Save failed"}),_]})})]}),j.jsxs(Po,{children:[be&&j.jsx(St,{appearance:"secondary",onClick:He,disabled:B,children:"Save a copy…"}),j.jsx(St,{appearance:"secondary",onClick:r,disabled:B,children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:Re,disabled:!Be,children:B?j.jsx(hn,{size:"tiny"}):s&&b==="system"?"Save and publish":"Save"})]})]})})})}const Pie=wr({splitButton:{minWidth:"110px"},menuItem:{display:"flex",alignItems:"center",gap:"8px"},menuIcon:{fontSize:"16px",color:le.colorNeutralForeground2}});function Oie({fetchXml:e,layoutXml:r,entityLogicalName:t,entityDisplayName:n,objectTypeCode:s,primaryIdAttribute:o,loadedView:i,onSaveComplete:c,disabled:l=!1}){const a=Pie(),[u,h]=A.useState(!1),[d,f]=A.useState("save"),[m,p]=A.useState(!1),{sync:g,editorHasContent:b}=S7(),[y,w]=A.useState(null),C=A.useCallback((E,M)=>{p(M),f(E),h(!0)},[]),N=A.useCallback(async(E,M)=>{const B=await g("save");if(B.status!=="cancelled"){if(B.status==="unchanged"){C(E,M);return}w({entity:B.fetchQuery.entity.name,xml:B.fetchXml})}},[g,C]);A.useEffect(()=>{!y||!(e===y.xml&&t===y.entity&&s>0&&o!=="")||(w(null),C("saveAs",!1))},[y,e,t,s,o,C]);const I=A.useCallback(()=>{N("save",!1)},[N]),$=A.useCallback(()=>{N("saveAs",!1)},[N]),D=A.useCallback(()=>{N("save",!0)},[N]),F=A.useCallback(()=>{h(!1)},[]),V=A.useCallback((E,M,B,k)=>{h(!1),c?.(E,M,B,k)},[c]),G=i?"Save":"Save as",U=i?j.jsx(j2,{}):j.jsx(N2,{});return j.jsxs(j.Fragment,{children:[j.jsxs(_i,{positioning:"below-end",children:[j.jsx(va,{disableButtonEnhancement:!0,children:E=>j.jsx(Or,{content:i?`Save changes to "${i.name}"`:"Save as new view",relationship:"description",children:j.jsx(hv,{className:a.splitButton,appearance:"primary",icon:U,menuButton:E,primaryActionButton:{onClick:i?I:$},disabled:l&&!b,children:G})})}),j.jsx(Ti,{children:j.jsxs(Ci,{children:[i&&j.jsx(Gr,{icon:j.jsx(j2,{className:a.menuIcon}),onClick:I,children:j.jsx("span",{className:a.menuItem,children:"Save"})}),j.jsx(Gr,{icon:j.jsx(N2,{className:a.menuIcon}),onClick:$,children:j.jsx("span",{className:a.menuItem,children:"Save as…"})}),i?.type==="system"&&j.jsx(Gr,{icon:j.jsx(ZA,{className:a.menuIcon}),onClick:D,children:j.jsx("span",{className:a.menuItem,children:"Save and publish"})})]})})]}),j.jsx(Die,{open:u,onClose:F,onSaveComplete:V,mode:d,shouldPublish:m,fetchXml:e,layoutXml:r,entityLogicalName:t,entityDisplayName:n,objectTypeCode:s,primaryIdAttribute:o,loadedView:i})]})}const Fie=wr({menuItemContent:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"2px"},toolIdHint:{fontSize:le.fontSizeBase100,color:le.colorNeutralForeground3}});function qie({fetchXml:e,entityLogicalName:r,tools:t,disabled:n}){const s=Fie(),{sync:o,editorHasContent:i}=S7(),c=A.useCallback(async a=>{const u=await o("send");if(u.status==="cancelled")return;const h=u.status==="synced"?u.fetchXml:e,d=u.status==="synced"?u.fetchQuery.entity.name:r;if(!h||!d)return;IJ(a,{fetchXml:h,entityLogicalName:d}).catch(async m=>{const p=m instanceof Error?m.message:String(m);/already in progress/i.test(p)||await window.toolboxAPI?.utils?.showNotification?.({title:"Cannot open tool",body:p,type:"error"})})},[e,r,o]),l=!i&&(n||!e||!r);return t.length===0?null:j.jsxs(_i,{children:[j.jsx(va,{disableButtonEnhancement:!0,children:j.jsx(St,{appearance:"subtle",icon:j.jsx(z2,{}),disabled:l,children:"Send to tool"})}),j.jsx(Ti,{children:j.jsx(Ci,{children:t.map(a=>j.jsx(Gr,{icon:j.jsx(z2,{}),onClick:()=>{c(a.id)},children:j.jsxs("div",{className:s.menuItemContent,children:[j.jsx("span",{children:a.name}),j.jsx("span",{className:s.toolIdHint,children:a.id})]})},a.id))})})]})}const lk={loading:!1,isCallee:!1,context:null};function Lie(){const[e,r]=A.useState({loading:!0,isCallee:!1,context:null});return A.useEffect(()=>{let t=!0;if(!b_()){r(lk);return}return(async()=>{try{const n=await NJ();t&&r({loading:!1,isCallee:n!==null,context:n})}catch(n){console.error("useLaunchContext: failed to read launch context",n),t&&r(lk)}})(),()=>{t=!1}},[]),e}function $ie(){const[e,r]=A.useState({loading:!0,tools:[]});return A.useEffect(()=>{let t=!0;return(async()=>{const n=await jJ();t&&r({loading:!1,tools:n})})(),()=>{t=!1}},[]),e}function Hie(e,r){const t=e.from??"",n=e.to??"";return e.relationshipType==="N1"?n||t:e.relationshipType==="1N"||r&&n&&n===r?t||n:n||t}function Vie(e,r){if(e.alias)return`${e.alias} (${e.linkType})`;const t=Hie(e,r);return t?`${e.name} via ${t} (${e.linkType})`:`${e.name} (${e.linkType})`}function Wie(e){return cl.has(e.linkType)||e.intersect?!1:e.attributes.length===0&&!e.allAttributes?.enabled}function Zl(e){return e.type==="filter"?e.conditions.length+e.subfilters.reduce((r,t)=>r+1+Zl(t),0)+(e.links??[]).reduce((r,t)=>r+1+Zl(t),0):(e.allAttributes?.enabled?1:0)+e.attributes.length+e.orders.length+e.filters.reduce((r,t)=>r+1+Zl(t),0)+e.links.reduce((r,t)=>r+1+Zl(t),0)}function Uie(e){return e===1?"This also deletes the item inside it.":`This also deletes the ${e} items inside it.`}const Cu="All types",Xie=wr({surface:{width:"min(1000px, 94vw)",maxWidth:"min(1000px, 94vw)"},content:{display:"flex",flexDirection:"column",gap:le.spacingVerticalM,minHeight:"420px",maxHeight:"62vh"},filters:{display:"flex",alignItems:"center",gap:le.spacingHorizontalM,flexWrap:"wrap"},searchBox:{flex:1,minWidth:"220px"},typeFilter:{minWidth:"150px"},dataGridContainer:{flex:1,display:"flex",flexDirection:"column",minHeight:"300px",overflow:"hidden"},dataGrid:{minWidth:"100%",display:"flex",flexDirection:"column",height:"100%"},dataGridBody:{overflow:"auto",flex:1},truncate:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},mono:{fontFamily:le.fontFamilyMonospace,fontSize:le.fontSizeBase200},count:{marginRight:"auto",alignSelf:"center",color:le.colorNeutralForeground3}}),Gie=e=>(e.AttributeTypeName?.Value??e.AttributeType??"").replace(/Type$/,"")||"Unknown",Kie={displayName:{defaultWidth:300,idealWidth:300,minWidth:120},logicalName:{defaultWidth:300,idealWidth:300,minWidth:120},dataType:{defaultWidth:140,idealWidth:140,minWidth:90}};function Yie({open:e,onOpenChange:r,entityDisplayName:t,nodeId:n,attributes:s,selectedAttributeNames:o,onApply:i}){const c=Xie(),[l,a]=A.useState(""),[u,h]=A.useState(Cu),[d,f]=A.useState(!1),[m,p]=A.useState(new Set(o));A.useEffect(()=>{e&&(p(new Set(o)),a(""),h(Cu),f(!1))},[e,o]);const g=A.useMemo(()=>s.map(F=>({logicalName:F.LogicalName,displayName:F.DisplayName?.UserLocalizedLabel?.Label||F.LogicalName,dataType:Gie(F)})).sort((F,V)=>F.displayName.localeCompare(V.displayName)),[s]),b=A.useMemo(()=>[...new Set(g.map(F=>F.dataType))].sort(),[g]),y=A.useMemo(()=>{const F=l.trim().toLowerCase();return g.filter(V=>(!F||V.logicalName.toLowerCase().includes(F)||V.displayName.toLowerCase().includes(F))&&(u===Cu||V.dataType===u)&&(!d||m.has(V.logicalName)))},[g,l,u,d,m]),w=A.useMemo(()=>g.filter(F=>m.has(F.logicalName)).length,[g,m]),C=A.useMemo(()=>{const F=(V,G)=>j.jsx(Gl,{truncate:!0,children:j.jsx(Or,{content:V,relationship:"description",children:j.jsx("span",{className:G?de(c.truncate,c.mono):c.truncate,children:V})})});return[rc({columnId:"displayName",compare:(V,G)=>V.displayName.localeCompare(G.displayName),renderHeaderCell:()=>"Display name",renderCell:V=>F(V.displayName)}),rc({columnId:"logicalName",compare:(V,G)=>V.logicalName.localeCompare(G.logicalName),renderHeaderCell:()=>"Logical name",renderCell:V=>F(V.logicalName,!0)}),rc({columnId:"dataType",compare:(V,G)=>V.dataType.localeCompare(G.dataType),renderHeaderCell:()=>"Type",renderCell:V=>F(V.dataType)})]},[c.truncate,c.mono]),N=A.useCallback((F,V)=>{a(V.value)},[]),I=A.useCallback((F,V)=>{p(V.selectedItems)},[]),$=A.useCallback(()=>{const F=Array.from(m);i(n,F),r(!1)},[m,n,i,r]),D=A.useCallback(()=>{r(!1)},[r]);return j.jsx(Do,{open:e,onOpenChange:(F,V)=>r(V.open),children:j.jsx(zi,{className:c.surface,"aria-describedby":void 0,children:j.jsxs(Ai,{children:[j.jsxs(Ri,{children:["Select attributes · ",t]}),j.jsxs(Ii,{className:c.content,children:[j.jsxs("div",{className:c.filters,children:[j.jsx(zv,{className:c.searchBox,placeholder:"Search display or logical name",value:l,onChange:N}),j.jsx(po,{className:c.typeFilter,"aria-label":"Filter by type",value:u,selectedOptions:[u],onOptionSelect:(F,V)=>h(V.optionValue??Cu),children:[Cu,...b].map(F=>j.jsx(Jt,{value:F,children:F},F))}),j.jsx(Qs,{label:"Selected only",checked:d,onChange:(F,V)=>f(V.checked)})]}),j.jsx("div",{className:c.dataGridContainer,children:j.jsxs(OS,{className:c.dataGrid,items:y,columns:C,sortable:!0,resizableColumns:!0,columnSizingOptions:Kie,selectionMode:"multiselect",selectedItems:m,onSelectionChange:I,getRowId:F=>F.logicalName,size:"small",children:[j.jsx($S,{children:j.jsx(V0,{selectionCell:{checkboxIndicator:{"aria-label":"Select all attributes"}},children:({renderHeaderCell:F})=>j.jsx(jv,{children:F()})})}),j.jsx(zS,{className:c.dataGridBody,children:({item:F,rowId:V})=>j.jsx(V0,{selectionCell:{checkboxIndicator:{"aria-label":`Select ${F.displayName}`}},children:({renderCell:G})=>j.jsx(Bv,{children:G(F)})},V)})]})})]}),j.jsxs(Po,{fluid:!0,children:[j.jsxs(st,{className:c.count,size:200,children:[w," of ",g.length," selected"]}),j.jsx(St,{appearance:"primary",onClick:$,children:"Apply"}),j.jsx(St,{appearance:"secondary",onClick:D,children:"Cancel"})]})]})})})}function j7(e){return typeof e=="number"?Math.abs(e)<1e-10&&e!==0?e.toFixed(20).replace(/\.?0+$/,""):Number.isInteger(e)?e.toString():e.toFixed(10).replace(/\.?0+$/,""):Array.isArray(e)?e.map(r=>j7(r)).join(", "):String(e)}const Qie=wr({container:{flex:1,overflow:"auto",padding:"8px",minHeight:0,scrollbarGutter:"stable"},treeItem:{"&:hover":{backgroundColor:le.colorNeutralBackground1Hover}},actions:{display:"flex",gap:"4px",opacity:0,transition:"opacity 0.2s","&:focus-within":{opacity:1}},treeItemWithActions:{"&:hover .actions":{opacity:1}},badges:{display:"flex",gap:le.spacingHorizontalXXS,alignItems:"center"},hint:{color:le.colorNeutralForeground4,marginLeft:"6px",fontStyle:"italic"},danger:{color:le.colorPaletteRedForeground1,"& svg":{color:le.colorPaletteRedForeground1}}}),ck=(...e)=>e.filter(r=>!!r),Zie=e=>Zt.getEntityMetadata(e)?.PrimaryIdAttribute??Zt.getAllEntityMetadata()?.find(r=>r.LogicalName===e)?.PrimaryIdAttribute,Jie={count:"Count",countcolumn:"Count values",sum:"Sum",avg:"Average",min:"Min",max:"Max"};function eae({fetchQuery:e,selectedNodeId:r,onNodeSelect:t,onAddAttribute:n,onAddAllAttributes:s,onAddOrder:o,onAddFilter:i,onAddSubfilter:c,onAddCondition:l,onAddLinkEntity:a,onRemoveNode:u,onUpdateAttributes:h}){const d=Qie(),f=A.useMemo(()=>{const te=new Map;for(const se of Fv(e))se.severity==="error"&&te.set(se.nodeId,[...te.get(se.nodeId)??[],se.message]);return te},[e]),m=(te,se=[])=>{const ue=f.get(te),he=ue?[...se,{text:"Error",color:"danger",title:ue.join(" ")}]:se;if(he.length!==0)return j.jsx("span",{className:d.badges,children:he.map(me=>j.jsx(ri,{size:"small",appearance:"tint",color:me.color??"informative",title:me.title,children:me.text},me.text))})},[p,g]=A.useState(!1),[b,y]=A.useState(null),[w,C]=A.useState(""),[N,I]=A.useState([]),[$,D]=A.useState([]),F=A.useRef(null),[V,G]=A.useState(new Set([e.id,e.entity.id])),U=te=>te.stopPropagation(),[E,M]=A.useState({open:!1}),B=A.useRef(null),[k,_]=A.useState(null),S=te=>{const se=[],ue=(he,me)=>{if(!he||typeof he!="object")return!1;const xe=he;if(xe.id===me)return Ie("treeExpansion","Found target node:",xe.id),!0;const Be=xe.id;Ie("treeExpansion","Checking node:",Be,"type:",xe.type);const Re=["attributes","orders","filters","conditions","subfilters","links"];for(const He of Re)if(Array.isArray(xe[He])){for(const Je of xe[He])if(ue(Je,me))return se.unshift(Be),!0}return xe.entity&&ue(xe.entity,me)?(se.unshift(Be),!0):!1};return ue(e,te),Ie("treeExpansion","Final path:",se),se};A.useEffect(()=>{if(r){Ie("treeExpansion","Node selected, expanding path:",r);const te=S(r);if(Ie("treeExpansion","Path to node:",te),te.length===0){xY("treeExpansion","Path is empty! Node might not be in tree yet.");return}G(ue=>{const he=new Set(ue),me=he.size;te.forEach(Be=>he.add(Be));const xe=Array.from(he).filter(Be=>!ue.has(Be));return Ie("treeExpansion","Updated openItems:",{sizeBefore:me,sizeAfter:he.size,added:xe,addedCount:xe.length,allOpen:Array.from(he)}),he});const se=setTimeout(()=>{F.current?.querySelector(`[data-fui-tree-item-value="${CSS.escape(r)}"]`)?.scrollIntoView({behavior:"smooth",block:"nearest"})},250);return()=>clearTimeout(se)}},[r]);const T=A.useCallback(async te=>{const se=te.name,ue=Zt.getEntityMetadata(se)?.DisplayName?.UserLocalizedLabel?.Label||se,he=te.attributes.map(xe=>xe.name);let me=[];try{me=await Yv(se)}catch(xe){console.error("Failed to load attributes:",xe)}y(te.id),C(ue),I(me),D(he),g(!0)},[]),z=A.useCallback((te,se)=>{h(te,se)},[h]),P=(te,se)=>{Ie("treeExpansion","handleOpenChange called:",{open:se.open,value:se.value,type:se.type,openItemsCount:se.openItems.size,openItems:Array.from(se.openItems)}),G(se.openItems)},O=te=>{te.descendants>0?_(te):u(te.id)},X=te=>{const se=te.type==="entity"||!cl.has(te.linkType),ue=te.filters.length>0;return[{key:"all",label:"All attributes",icon:j.jsx(R2,{}),disabled:!se,onClick:()=>s(te.id)},{key:"select",label:"Select attributes…",icon:j.jsx(BR,{}),disabled:!se,onClick:()=>{T(te)}},{key:"blank",label:"Blank attribute",icon:j.jsx(TR,{}),disabled:!se,onClick:()=>n(te.id)},{key:"order",label:"Order by",icon:j.jsx(D2,{}),disabled:!se,onClick:()=>o(te.id)},{key:"filter",label:"Filter",icon:j.jsx(Os,{}),disabled:ue,onClick:()=>i(te.id)},{key:"link",label:"Link-entity",icon:j.jsx(eh,{}),onClick:()=>a(te.id)}]},K=te=>[{key:"condition",label:"Condition",icon:j.jsx(Os,{}),onClick:()=>l(te.id)},{key:"subfilter",label:"Sub-filter",icon:j.jsx(Os,{}),onClick:()=>c(te.id)},{key:"link",label:"Link-entity (any/not any/all)",icon:j.jsx(eh,{}),onClick:()=>a(te.id)}],J=te=>te.map(se=>j.jsx(Gr,{icon:se.icon,disabled:se.disabled,onClick:se.onClick,children:se.label},se.key)),H=(te,se,ue,he)=>{t(ue.id),B.current=he,M({open:!0,addItems:ue.addItems,deleteTarget:ue.deleteTarget,target:{getBoundingClientRect:()=>({x:te,y:se,top:se,left:te,bottom:se,right:te,width:0,height:0,toJSON:()=>({})})}})},Z=te=>{const se=te.children?.filter(Boolean)??[],ue=se.length>0,he=!!te.addItems?.length||!!te.deleteTarget;return j.jsxs(Ui,{itemType:ue?"branch":"leaf",value:te.id,className:d.treeItemWithActions,onKeyDown:me=>{if(!(!he||me.target!==me.currentTarget)&&(me.key==="ContextMenu"||me.shiftKey&&me.key==="F10")){me.preventDefault();const Be=(me.currentTarget.querySelector(":scope > .fui-TreeItemLayout")??me.currentTarget).getBoundingClientRect();H(Be.left+24,Be.bottom,te,me.currentTarget)}},children:[j.jsxs(Wi,{iconBefore:te.icon,actions:te.addItems||te.deleteTarget?j.jsxs("div",{className:"actions",children:[te.addItems&&j.jsxs(_i,{children:[j.jsx(va,{disableButtonEnhancement:!0,children:j.jsx(St,{appearance:"subtle",size:"small",icon:j.jsx(rp,{}),title:"Add…","aria-label":"Add…"})}),j.jsx(Ti,{onClick:U,children:j.jsx(Ci,{children:J(te.addItems)})})]}),te.deleteTarget&&j.jsx(St,{appearance:"subtle",size:"small",icon:j.jsx(Lu,{}),onClick:me=>{me.stopPropagation(),O(te.deleteTarget)},title:"Delete","aria-label":"Delete"})]}):void 0,aside:m(te.id,te.badges),onClick:()=>t(te.id),onContextMenu:he?me=>{me.preventDefault(),me.stopPropagation(),H(me.clientX,me.clientY,te,me.currentTarget.closest('[role="treeitem"]'))}:void 0,children:[te.label,te.hint&&j.jsx("span",{className:d.hint,children:te.hint})]}),ue&&j.jsx(Hs,{children:se})]},te.id)},L=te=>Z({id:te.id,icon:j.jsx(A2,{}),label:"Fetch query",badges:ck(te.options.aggregate===!0&&{text:"Aggregate",color:"brand"},te.options.distinct&&{text:"Distinct"},te.options.dataSource==="retained"&&{text:"Retained"},(te.options.queryHints?.length??0)>0&&{text:"Hints"}),children:[Y(te.entity)]}),q=te=>[te.allAttributes?.enabled&&re(te.allAttributes),...te.attributes.map(se=>ie(se)),...te.orders.map(se=>ne(se)),...te.filters.map(se=>ae(se,te.name)),...te.links.map(se=>pe(se,te.name))],Y=te=>Z({id:te.id,icon:j.jsx(A2,{}),label:te.name,addItems:X(te),children:q(te)}),re=te=>Z({id:te.id,icon:j.jsx(R2,{}),label:"All attributes",deleteTarget:{id:te.id,title:"Delete all attributes?",descendants:0}}),ie=te=>{const se=[];return te.groupby&&se.push({text:te.dategrouping?`Group by · ${te.dategrouping}`:"Group by",color:"brand"}),te.aggregate&&se.push({text:Jie[te.aggregate]??te.aggregate,color:"brand"}),te.aggregate==="countcolumn"&&te.distinct&&se.push({text:"Unique"}),te.rowAggregate&&se.push({text:"Child count"}),Z({id:te.id,icon:j.jsx(lR,{}),label:te.alias?`${te.name} (as ${te.alias})`:te.name,badges:se,deleteTarget:{id:te.id,title:`Delete attribute ${te.name}?`,descendants:0}})},ne=te=>{const se=te.descending?"↓":"↑",ue=te.alias?`${te.alias} (alias)`:te.attribute??"",he=te.entityname?`${te.entityname}.${ue}`:ue;return Z({id:te.id,icon:j.jsx(D2,{}),label:`${he} ${se}`,deleteTarget:{id:te.id,title:`Delete order ${he}?`,descendants:0}})},ae=(te,se)=>Z({id:te.id,icon:j.jsx(Os,{}),label:`Filter (${te.conjunction})`,badges:ck(te.hint==="union"&&{text:"Union"},te.isQuickFindFields&&{text:"Quick find"}),addItems:K(te),deleteTarget:{id:te.id,title:`Delete filter (${te.conjunction})?`,descendants:Zl(te)},children:[...te.conditions.map(ue=>be(ue)),...te.subfilters.map(ue=>ae(ue,se)),...(te.links??[]).map(ue=>pe(ue,se))]}),be=te=>{const se=md(te.operator);let ue=`${te.attribute} ${te.operator}`;return se&&te.valueof?ue+=` → ${te.valueof}`:se&&te.value!==void 0&&te.value!==null&&te.value!==""&&(ue+=` = ${j7(te.value)}`),Z({id:te.id,icon:j.jsx(Os,{}),label:ue,deleteTarget:{id:te.id,title:`Delete condition ${te.attribute}?`,descendants:0}})},pe=(te,se)=>Z({id:te.id,icon:j.jsx(eh,{}),label:Vie(te,Zie(se)),hint:Wie(te)?"(no attributes)":void 0,addItems:X(te),deleteTarget:{id:te.id,title:`Delete link-entity ${te.alias||te.name}?`,descendants:Zl(te)},children:q(te)});return j.jsxs("div",{ref:F,className:d.container,children:[j.jsx(Hs,{"aria-label":"FetchXML Query Structure",openItems:V,onOpenChange:P,children:L(e)}),j.jsx(_i,{open:E.open,onOpenChange:(te,se)=>{if(M(ue=>({...ue,open:se.open})),!se.open){const ue=B.current;requestAnimationFrame(()=>{ue?.isConnected&&(!document.activeElement||document.activeElement===document.body)&&ue.focus()})}},positioning:{target:E.target,position:"below",align:"start"},children:j.jsx(Ti,{onClick:U,children:j.jsxs(Ci,{children:[E.addItems&&J(E.addItems),E.addItems&&E.deleteTarget&&j.jsx(Ku,{}),E.deleteTarget&&j.jsx(Gr,{className:d.danger,icon:j.jsx(Lu,{}),onClick:()=>E.deleteTarget&&O(E.deleteTarget),children:"Delete"})]})})}),j.jsx(Do,{open:k!==null,onOpenChange:(te,se)=>!se.open&&_(null),children:j.jsx(zi,{children:j.jsxs(Ai,{children:[j.jsx(Ri,{children:k?.title}),j.jsx(Ii,{children:k&&Uie(k.descendants)}),j.jsxs(Po,{children:[j.jsx(St,{appearance:"secondary",onClick:()=>_(null),children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:()=>{k&&u(k.id),_(null)},children:"Delete"})]})]})})}),j.jsx(Yie,{open:p,onOpenChange:g,entityDisplayName:w,nodeId:b||"",attributes:N,selectedAttributeNames:$,onApply:z})]})}const N7=A.createContext(null);function wd(){const e=A.useContext(N7);if(!e)throw new Error("useBuilder must be used within BuilderProvider");return e}function tae(e,r,t,n){return t&&e.entityname?n.find(s=>s.alias===e.entityname)??n.find(s=>s.name===e.entityname)??r:r}function rae(e){const r={removed:[],converted:[],updates:[],removeNodeIds:[]},t=[],n=(i,c)=>{t.push({container:i,isRoot:c}),i.links.forEach(l=>n(l,!1))};n(e.entity,!0);const s=t.map(i=>i.container).filter(i=>i.type==="link-entity");for(const{container:i}of t)for(const c of i.attributes){const l=[c.groupby&&"Group by",c.aggregate&&`aggregate="${c.aggregate}"`,c.dategrouping&&`dategrouping="${c.dategrouping}"`,c.usertimezone!==void 0&&"time zone",c.distinct&&"unique values"].filter(a=>typeof a=="string");l.length!==0&&(r.removed.push({element:"attribute",message:`${c.name}${c.alias?` (${c.alias})`:""}: remove ${l.join(", ")}`}),r.updates.push({nodeId:c.id,updates:{groupby:void 0,aggregate:void 0,dategrouping:void 0,usertimezone:void 0,distinct:void 0}}))}const o=[];for(const{container:i,isRoot:c}of t)for(const l of i.orders){if(!l.alias)continue;const a=tae(l,i,c,s).attributes.find(u=>u.alias===l.alias);a?.groupby?(r.converted.push({element:"order",message:`Sort by alias ${l.alias} → sort by attribute ${a.name}`}),r.updates.push({nodeId:l.id,updates:{alias:void 0,attribute:a.name}})):(o.push({element:"order",message:a?`Sort by ${l.alias} (it sorts by an aggregate value)`:`Sort by ${l.alias} (the alias isn't defined on that entity)`}),r.removeNodeIds.push(l.id))}return r.removed.push(...o),e.options.aggregateLimit!==void 0&&r.removed.push({element:"fetch",message:"Aggregate row limit (aggregatelimit)"}),r}function nae(e){return e.removed.length>0||e.converted.length>0}const oae=wr({content:{display:"flex",flexDirection:"column",gap:le.spacingVerticalM}});function iae({plan:e,onConfirm:r,onTurnOffOnly:t,onCancel:n}){const s=oae();return j.jsx(Do,{modalType:"alert",open:e!==null,onOpenChange:(o,i)=>!i.open&&n(),children:j.jsx(zi,{children:j.jsxs(Ai,{children:[j.jsx(Ri,{children:"Turn off aggregate query?"}),j.jsxs(Ii,{className:s.content,children:[j.jsx(_h,{children:"These settings only work in aggregate queries, and Dataverse rejects some of them in a normal query."}),e&&e.removed.length>0&&j.jsxs("div",{children:[j.jsx(Ch,{children:"Removed"}),j.jsx(rl,{items:e.removed})]}),e&&e.converted.length>0&&j.jsxs("div",{children:[j.jsx(Ch,{children:"Changed"}),j.jsx(rl,{items:e.converted})]})]}),j.jsx(Po,{position:"start",children:j.jsx(St,{appearance:"secondary",onClick:t,children:"Turn off only"})}),j.jsxs(Po,{position:"end",children:[j.jsx(St,{appearance:"secondary",onClick:n,children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:r,children:"Turn off and update"})]})]})})})}let uk=!1;const dk=[{name:"ForceOrder",sql:"FORCE ORDER"},{name:"DisableRowGoal",sql:"USE HINT DISABLE_OPTIMIZER_ROWGOAL"},{name:"EnableOptimizerHotfixes",sql:"USE HINT ENABLE_QUERY_OPTIMIZER_HOTFIXES"},{name:"LoopJoin",sql:"LOOP JOIN"},{name:"MergeJoin",sql:"MERGE JOIN"},{name:"HashJoin",sql:"HASH JOIN"},{name:"NO_PERFORMANCE_SPOOL",sql:"NO_PERFORMANCE_SPOOL"},{name:"ENABLE_HIST_AMENDMENT_FOR_ASC_KEYS",sql:"USE HINT ENABLE_HIST_AMENDMENT_FOR_ASC_KEYS"}];function aae({node:e,findings:r,onUpdate:t}){const n=Mi(),{options:s}=e,{retrieveAllRecords:o,setRetrieveAllRecords:i,updateNode:c,removeNode:l}=wd(),a=jp(e.entity.name),[u,h]=A.useState(!1),[d,f]=A.useState(null),[m,p]=A.useState(null);s.utcOffset!==void 0&&m!==e.id&&p(e.id);const g=s.utcOffset!==void 0||m===e.id,b=(T,z)=>{z.checked&&!uk&&(h(!0),uk=!0),i(z.checked)},y=T=>z=>t({[T]:z?!0:void 0}),w=T=>{if(T)return t({aggregate:!0});const z=rae(e);if(nae(z))return f(z);t({aggregate:void 0})},C=T=>{for(const{nodeId:z,updates:P}of T.updates)c(z,P);for(const z of T.removeNodeIds)l(z);t({aggregate:void 0,aggregateLimit:void 0}),f(null)},N=s.top!==void 0,I=s.count!==void 0||s.page!==void 0||s.returnTotalRecordCount===!0,$=Er(r,"top"),D="Not available with Maximum rows (top).",F="Not available with paging (page size, page number or total record count).",V=s.queryHints??[],G=new Set(dk.map(T=>T.name.toLowerCase())),U=V.filter(T=>!G.has(T.toLowerCase())),E=T=>V.some(z=>z.toLowerCase()===T.toLowerCase()),M=(T,z)=>{const P=z?[...V,T]:V.filter(O=>O.toLowerCase()!==T.toLowerCase());t({queryHints:P.length>0?P:void 0})},B=[s.latematerialize,V.length>0,s.noLock].filter(Boolean).length,k=a.metadata?.IsRetentionEnabled,_=iQ(s.dataSource,{logicalName:e.entity.name,isRetentionEnabled:k}),S=s.dataSource==="retained"?"Retained data (long-term retention)":s.dataSource==="bin"?"bin (undocumented)":s.dataSource??"Active data (default)";return j.jsxs("div",{className:n.container,children:[j.jsxs("div",{className:n.section,children:[j.jsx(Xn,{children:"Execution"}),j.jsxs(w8,{open:u,onOpenChange:(T,z)=>h(z.open),children:[j.jsx(Iv,{children:j.jsx(Qs,{checked:o,onChange:b,label:{children:(T,z)=>j.jsx(Av,{...z,info:"Fetches every page, one after another. Use with care on large entities.",children:"Retrieve all records"})}})}),j.jsxs(v8,{children:[j.jsxs(b8,{children:[j.jsx(y8,{children:"Retrieve all records"}),j.jsx("div",{children:"Fetches all pages progressively. Use with caution on large datasets."})]}),j.jsx(x8,{primary:{children:"Got it",onClick:()=>h(!1)}})]})]})]}),j.jsxs("div",{className:n.section,children:[j.jsx(Xn,{children:"Query"}),j.jsx(ei,{label:"Aggregate query",checked:s.aggregate===!0,onChange:w,validation:Er(r,"aggregate"),info:j.jsx(Qt,{text:"Groups records and calculates values (count, sum, average, minimum, maximum). Every attribute then needs Group by or an aggregate function, and an alias.",href:Kt.aggregate})}),j.jsx(ei,{label:"Distinct rows",checked:s.distinct===!0,onChange:y("distinct"),validation:Er(r,"distinct"),info:j.jsx(Qt,{text:"Leaves out duplicate rows from the results.",href:Kt.distinctResults})}),j.jsx(ei,{label:"Return total record count",checked:s.returnTotalRecordCount===!0,onChange:y("returnTotalRecordCount"),disabled:N&&!s.returnTotalRecordCount,hint:N&&!s.returnTotalRecordCount?D:void 0,validation:s.returnTotalRecordCount?$:void 0,info:j.jsx(Qt,{text:"Returns how many records match the query, up to 5,000 (500 for elastic entities), shown with the results. When more match, the count shows as 5,000+.",href:Kt.countRows})}),j.jsx(ei,{label:"Sort option sets by value",checked:s.useRawOrderBy===!0,onChange:y("useRawOrderBy"),info:j.jsx(Qt,{text:"Sorts option set (choice) attributes by their integer value instead of their label, for every option set attribute the query sorts by.",href:Kt.orderRows})})]}),j.jsxs("div",{className:n.section,children:[j.jsx(Xn,{children:"Paging and limits"}),j.jsx(Ka,{label:"Maximum rows (top)",value:s.top,min:1,max:5e3,rangeSeverity:"warning",placeholder:"No limit",disabled:I&&!N,hint:I&&!N?F:void 0,validation:is($,Er(r,"top")),onChange:T=>t({top:T}),info:j.jsx(Qt,{text:"Returns at most this many records (up to 5,000). Can't be combined with paging.",href:Kt.limitRows})}),j.jsx(Ka,{label:"Page size (count)",value:s.count,min:1,max:5e3,rangeSeverity:"warning",placeholder:"5,000",disabled:N&&s.count===void 0,hint:N&&s.count===void 0?D:void 0,validation:s.count!==void 0?is($,Er(r,"count")):void 0,onChange:T=>t({count:T}),info:j.jsx(Qt,{text:"Number of records per page (up to 5,000).",href:Kt.pageResults})}),j.jsx(Ka,{label:"Page number",value:s.page,min:1,placeholder:"1",disabled:N&&s.page===void 0,hint:N&&s.page===void 0?D:void 0,validation:s.page!==void 0?is($,Er(r,"page")):void 0,onChange:T=>t({page:T}),info:j.jsx(Qt,{text:"Which page to return, starting at 1.",href:Kt.pageResults})}),j.jsx(kr,{label:"Paging cookie",hint:"Copy it from the previous page's results.",info:j.jsx(Qt,{text:"Makes retrieving the next page more efficient. It must come from the page before the one requested.",href:Kt.pageResults}),children:j.jsx(_n,{className:n.mono,value:s.pagingCookie??"",placeholder:"<cookie … />",onChange:(T,z)=>t({pagingCookie:z.value||void 0})})})]}),(s.aggregate===!0||s.aggregateLimit!==void 0)&&j.jsxs("div",{className:n.section,children:[j.jsx(Xn,{children:"Aggregation"}),j.jsx(Ka,{label:"Aggregate row limit",value:s.aggregateLimit,min:1,max:5e4,placeholder:"50,000",hint:"Leave empty for the 50,000-row default.",validation:Er(r,"aggregatelimit"),onChange:T=>t({aggregateLimit:T}),info:j.jsx(Qt,{text:"Aggregates over at most this many records, below the 50,000-record default. When the limit is reached there's no error: the result covers at most limit + 1 arbitrary records.",href:Kt.aggregateLimit})})]}),j.jsx("div",{className:n.section,children:j.jsx(kr,{label:"Data source",validation:_?{state:"error",message:_}:Er(r,"datasource"),info:j.jsx(Qt,{text:"Retained data queries records moved to Dataverse long-term retention. The entity must have long-term retention enabled.",href:Kt.dataRetention}),children:j.jsxs(po,{value:S,selectedOptions:[s.dataSource??"active"],onOptionSelect:(T,z)=>t({dataSource:z.optionValue==="active"?void 0:z.optionValue}),children:[j.jsx(Jt,{value:"active",children:"Active data (default)"}),j.jsx(Jt,{value:"retained",text:"Retained data (long-term retention)",disabled:k===!1&&s.dataSource!=="retained",children:j.jsxs("span",{className:n.optionText,children:["Retained data (long-term retention)",k===!1&&j.jsxs("span",{className:n.optionSecondary,children:["Not enabled for ",e.entity.name]})]})}),s.dataSource==="bin"&&j.jsx(Jt,{value:"bin",children:"bin (undocumented)"})]})})}),j.jsx(Yh,{collapsible:!0,children:j.jsxs(qu,{value:"performance",children:[j.jsx($u,{children:j.jsxs("span",{className:n.accordionHeader,children:["Performance",B>0&&j.jsxs(ri,{appearance:"tint",size:"small",color:"informative",children:[B," set"]})]})}),j.jsx(Hu,{children:j.jsxs("div",{className:n.accordionPanel,children:[j.jsx(ei,{label:"Late materialize",checked:s.latematerialize===!0,onChange:y("latematerialize"),info:j.jsx(Qt,{text:"Breaks the query into smaller parts and reassembles the results. Can help queries with many joins or many lookup and calculated attributes; can make simple queries slower.",href:Kt.lateMaterialize})}),j.jsx(kr,{label:"Query hints (options)",info:j.jsx(Qt,{text:"SQL Server query hints, passed through the options attribute.",href:Kt.fetchOptions}),children:j.jsxs("div",{className:n.checkboxGroup,children:[j.jsx(Ar,{intent:"warning",layout:"multiline",children:j.jsx(Rr,{children:"Use query hints only when Microsoft support recommends them. Incorrect use can damage query performance."})}),dk.map(T=>j.jsx(ho,{checked:E(T.name),onChange:(z,P)=>M(T.name,P.checked===!0),label:j.jsxs("span",{className:n.optionText,children:[j.jsx("span",{className:n.mono,children:T.name}),j.jsx(kv,{className:n.secondary,children:T.sql})]})},T.name))]})}),U.length>0&&j.jsx(kr,{label:"Other hints (kept as written)",info:"Not documented option names. Dataverse accepts them, but Microsoft doesn't document what they do.",children:j.jsx(Nv,{onDismiss:(T,z)=>M(String(z.value),!1),"aria-label":"Other query hints",children:U.map(T=>j.jsx(pp,{value:T,dismissible:!0,dismissIcon:{"aria-label":`Remove ${T}`},appearance:"outline",children:T},T))})}),s.noLock&&j.jsx(ei,{label:"No lock (legacy)",checked:!0,onChange:y("noLock"),info:j.jsx(Qt,{text:"Legacy setting, no longer necessary: Dataverse doesn't need it to avoid shared locks. Shown because the query sets it.",href:Kt.noLock})})]})})]})}),g&&j.jsxs("div",{className:n.section,children:[j.jsx(Xn,{children:"Advanced"}),j.jsx(Ka,{label:"UTC offset (undocumented)",value:s.utcOffset,min:-720,max:720,rangeSeverity:"warning",placeholder:"Not set",onChange:T=>t({utcOffset:T}),info:j.jsx(Qt,{text:"Not in the fetch element reference; kept as written. Time zone offset in minutes for date and time filters, from −720 to 720. Clear it to remove it from the query.",href:Kt.fetch})})]}),j.jsx(iae,{plan:d,onConfirm:()=>d&&C(d),onTurnOffOnly:()=>{t({aggregate:void 0}),f(null)},onCancel:()=>f(null)})]})}function sae({node:e,onUpdate:r}){const t=Mi(),{metadata:n}=jp(e.name),s=n?.DisplayName?.UserLocalizedLabel?.Label,o=e.prefilterParameterName??"",i=!!e.enablePrefiltering||o!=="";return j.jsxs("div",{className:t.container,children:[j.jsx("div",{className:t.section,children:j.jsx(kr,{label:"Entity",hint:"Change it with the Entity picker above the tree.",info:j.jsx(Qt,{text:"The logical name of the entity the query is based on.",href:Kt.entity}),children:j.jsxs(st,{className:t.readOnly,children:[e.name,s&&j.jsxs("span",{className:t.secondary,children:[" (",s,")"]})]})})}),j.jsx(Yh,{collapsible:!0,defaultOpenItems:i?["prefilter"]:[],children:j.jsxs(qu,{value:"prefilter",children:[j.jsx($u,{children:j.jsxs("span",{className:t.accordionHeader,children:["Report prefiltering",i&&j.jsx(ri,{appearance:"tint",size:"small",color:"informative",children:"set"})]})}),j.jsx(Hu,{children:j.jsxs("div",{className:t.accordionPanel,children:[j.jsx(ei,{label:"Enable prefiltering",checked:!!e.enablePrefiltering,onChange:c=>r({enablePrefiltering:c?!0:void 0}),info:j.jsx(Qt,{text:"For SQL Server Reporting Services (Fetch-based) reports: lets people filter the report's records with Advanced Find before it runs. Dataverse ignores these attributes when the query runs here.",href:Kt.reportPrefiltering})}),(e.enablePrefiltering||o)&&j.jsx(kr,{label:"Parameter name",validation:o&&!o.startsWith("CRM_")?{state:"warning",message:"Start the name with CRM_ so the report hides the parameter."}:void 0,info:j.jsx(Qt,{text:"The report parameter that receives the prefilter.",href:Kt.reportPrefiltering}),children:j.jsx(_n,{className:t.mono,value:o,placeholder:"CRM_FilteredAccount",onChange:(c,l)=>r({prefilterParameterName:l.value||void 0})})})]})})]})})]})}function lae({isAggregateQuery:e,onRemove:r}){const t=Mi();return j.jsx("div",{className:t.container,children:j.jsxs("div",{className:t.section,children:[j.jsx(Xn,{children:"All attributes"}),j.jsx(_h,{children:"Returns every attribute that has a value, the same as listing no attributes at all."}),j.jsx(Ar,{intent:"info",layout:"multiline",children:j.jsx(Rr,{children:j.jsx(Qt,{text:"Microsoft doesn't recommend this for most queries: returning every attribute is slower. Select the attributes you need instead.",href:Kt.antiPatterns})})}),e&&j.jsx(Ar,{intent:"info",layout:"multiline",children:j.jsx(Rr,{children:"Ignored in an aggregate query: only the Group by and Aggregate attributes are returned."})}),j.jsx("div",{children:j.jsx(St,{onClick:r,children:"Remove all attributes"})})]})})}const u0={count:"Count records (count)",countcolumn:"Count values (countcolumn)",sum:"Sum (sum)",avg:"Average (avg)",min:"Minimum (min)",max:"Maximum (max)"},fk=[["day","Day"],["week","Week"],["month","Month"],["quarter","Quarter"],["year","Year"],["fiscal-period","Fiscal period"],["fiscal-year","Fiscal year"]],hk="__none";function cae({node:e,container:r,isRootEntity:t,isAggregateQuery:n,fetchQuery:s,findings:o,onUpdate:i}){const c=Mi(),{updateNode:l}=wd(),a=r.name,u=b7(a,e.name||void 0),h=u?Dv(u):void 0,d=jp(t?a:void 0),f=d.metadata?.PrimaryIdAttribute,[m,p]=A.useState(!1);A.useEffect(()=>p(!1),[e.id]);const g=e.alias?Z0(s,r,e.alias):[],b=S=>{const T=xp(S)||void 0;if(e.alias&&T)for(const z of Z0(s,r,e.alias))l(z.id,{alias:T});i({alias:T})},y=n||e.rowAggregate!==void 0,w=j.jsx(kr,{label:"Attribute",required:!0,info:j.jsx(Qt,{text:"The logical name of the attribute to return.",href:Kt.attribute}),children:j.jsx(pc,{entityLogicalName:a,value:e.name,onChange:S=>i({name:S}),placeholder:"Select an attribute"})}),C=j.jsx(kr,{label:"Alias",required:y,hint:g.length>0?`Sorting by this alias: renaming it also updates ${g.length===1?"that order":`those ${g.length} orders`}.`:void 0,validation:Er(o,"alias"),info:j.jsx(Qt,{text:"The name of the attribute in the results: letters, digits and underscores, starting with a letter or underscore. Unique across the query.",href:Kt.columnAliases}),children:j.jsx(_n,{value:e.alias??"",onChange:(S,T)=>b(T.value)})});if(!n){const S=!!e.name&&e.name===f,T=e.rowAggregate!==void 0||t&&S&&d.isHierarchical!==!1;let z=Er(o,"rowaggregate");!z&&e.rowAggregate!==void 0&&(d.isHierarchical===!1?z={state:"error",message:`${a} has no hierarchical relationship, so Dataverse rejects this (0x80047020).`}:f&&!S&&(z={state:"error",message:`Only works on the primary key (${f}); Dataverse rejects it on other attributes (0x80040203).`}));const P=[],O=X=>({state:"none",message:X});return e.groupby&&P.push({text:"Group by",field:"groupby",validation:Er(o,"groupby")??O("")}),e.aggregate&&P.push({text:`Aggregate: ${e.aggregate}`,field:"aggregate",validation:Er(o,"aggregate")??O("")}),e.dategrouping&&P.push({text:`Date grouping: ${e.dategrouping}`,field:"dategrouping",validation:O("Ignored outside aggregate queries.")}),e.usertimezone!==void 0&&P.push({text:"Time zone",field:"usertimezone",validation:O("Ignored outside aggregate queries.")}),e.distinct&&P.push({text:"Unique values only",field:"distinct",validation:O("Ignored outside aggregate queries.")}),j.jsxs("div",{className:c.container,children:[j.jsxs("div",{className:c.section,children:[j.jsx(Xn,{children:"Attribute"}),w,C]}),T&&j.jsxs("div",{className:c.section,children:[j.jsx(Xn,{children:"Hierarchy"}),j.jsx(ei,{label:"Count child records",checked:e.rowAggregate!==void 0,onChange:X=>i({rowAggregate:X?"CountChildren":void 0}),hint:e.rowAggregate!==void 0?"Returns the number of hierarchical child records in the alias attribute.":void 0,validation:z,info:j.jsx(Qt,{text:"Adds the number of child records under each record in a hierarchical relationship, such as parent accounts. The count includes records the user can't read. Only for entities with a hierarchical relationship.",href:Kt.rowAggregate})})]}),P.length>0&&j.jsxs("div",{className:c.section,children:[j.jsx(Xn,{children:"Aggregate settings"}),P.map(X=>j.jsx(_a,{text:X.text,validation:X.validation.message?X.validation:{state:"error",message:"The query isn't an aggregate query, so Dataverse rejects this."},onRemove:()=>i({[X.field]:void 0})},X.field))]})]})}const N=!!e.groupby&&!!e.aggregate,I=N?"":e.groupby?"groupby":e.aggregate||m?"aggregate":"",$=!h||h.groupby,D=tb.filter(S=>!h||h.functions.includes(S)),F=D.length>0,V=!!e.aggregate&&!!u&&!D.includes(e.aggregate),G=is(Er(o,void 0,"groupby"),e.groupby&&!$?{state:"error",message:h?.reason??"Dataverse can't group by this attribute."}:void 0,!I&&!N&&!$&&!F?{state:"error",message:`${h?.reason} Remove this attribute from the aggregate query.`}:void 0),U=e.aggregate?V?{state:"error",message:oQ(e.aggregate,u)}:Er(o,"aggregate"):{state:"error",message:"Choose an aggregate function."},E=h?.groupbyNeedsDateGrouping===!0,M=!u,B=I==="groupby"&&(E||M),k=I==="groupby"&&E&&!e.dategrouping?{state:"error",message:"Choose a date part. Dataverse can't group a DateTime attribute without one (0x80041135)."}:void 0,_=e.dategrouping!==void 0&&!B;return j.jsxs("div",{className:c.container,children:[j.jsxs("div",{className:c.section,children:[j.jsx(Xn,{children:"Attribute"}),w,C]}),j.jsxs("div",{className:c.section,children:[j.jsx(kr,{label:"Role",required:!0,validation:G,info:j.jsx(Qt,{text:"Group by makes a group per distinct value. Aggregate calculates a value for each group.",href:Kt.aggregate}),children:j.jsxs(ta,{layout:"horizontal",value:I,onChange:(S,T)=>{p(T.value==="aggregate"),T.value==="groupby"?i({groupby:!0,aggregate:void 0,distinct:void 0}):i({groupby:void 0,dategrouping:void 0,usertimezone:void 0})},children:[j.jsx(Yr,{value:"groupby",label:"Group by",disabled:!$&&!e.groupby}),j.jsx(Yr,{value:"aggregate",label:"Aggregate",disabled:!F&&!e.aggregate})]})}),I==="aggregate"&&j.jsxs(j.Fragment,{children:[j.jsx(kr,{label:"Function",required:!0,validation:U,hint:h&&D.length<tb.length?"Only functions this attribute type supports are listed.":void 0,info:j.jsx(Qt,{text:"Count records counts every record; Count values counts records where this attribute has a value.",href:Kt.aggregateFunctions}),children:j.jsxs(po,{placeholder:"Choose a function",value:e.aggregate?u0[e.aggregate]:"",selectedOptions:e.aggregate?[e.aggregate]:[],onOptionSelect:(S,T)=>i({aggregate:T.optionValue}),children:[V&&e.aggregate&&j.jsx(Jt,{value:e.aggregate,children:u0[e.aggregate]}),D.map(S=>j.jsx(Jt,{value:S,children:u0[S]},S))]})}),(e.aggregate==="countcolumn"||e.distinct)&&j.jsx(ei,{label:"Unique values only",checked:!!e.distinct,onChange:S=>i({distinct:S?!0:void 0}),validation:Er(o,"distinct"),info:j.jsx(Qt,{text:"With Count values, counts each distinct value once.",href:Kt.aggregateDistinct})})]}),B&&j.jsx(kr,{label:"Date grouping",required:E,validation:k,info:j.jsx(Qt,{text:"The part of the date to group by.",href:Kt.aggregateDateGrouping}),children:j.jsxs(po,{placeholder:"Choose a date part",value:fk.find(([S])=>S===e.dategrouping)?.[1]??"",selectedOptions:e.dategrouping?[e.dategrouping]:[],onOptionSelect:(S,T)=>i({dategrouping:T.optionValue===hk?void 0:T.optionValue}),children:[M&&j.jsx(Jt,{value:hk,children:"None"}),fk.map(([S,T])=>j.jsx(Jt,{value:S,children:T},S))]})}),_&&j.jsx(_a,{text:`Date grouping: ${e.dategrouping}`,validation:{state:"warning",message:"Ignored: date grouping only applies to Group by on DateTime attributes."},onRemove:()=>i({dategrouping:void 0})}),(B||e.usertimezone!==void 0)&&j.jsx(kr,{label:"Time zone",info:j.jsx(Qt,{text:"The same date can fall on different days in different time zones. By default Dataverse groups using the user's time zone; choose UTC to group on the stored UTC value.",href:Kt.attribute}),children:j.jsxs(ta,{value:e.usertimezone===!1?"utc":"user",onChange:(S,T)=>i({usertimezone:T.value==="utc"?!1:e.usertimezone===!0?!0:void 0}),children:[j.jsx(Yr,{value:"user",label:"User's time zone (default)"}),j.jsx(Yr,{value:"utc",label:"UTC"})]})}),e.rowAggregate!==void 0&&j.jsx(_a,{text:"Count child records",validation:Er(o,"rowaggregate")??{state:"error",message:"Doesn't work in an aggregate query."},onRemove:()=>i({rowAggregate:void 0})})]})]})}const uae=["String","Memo","Integer","BigInt","Decimal","Double","Money","DateTime","Boolean","Picklist","State","Status","Lookup","Customer","Owner","Uniqueidentifier","EntityName"],d0="__root",E7=e=>e.links.flatMap(r=>[r,...E7(r)]),dae=e=>e.groupby?`Group by${e.dategrouping?` · ${e.dategrouping}`:""}`:e.aggregate?{count:"Count records",countcolumn:"Count values",sum:"Sum",avg:"Average",min:"Minimum",max:"Maximum"}[e.aggregate]:"";function fae({node:e,container:r,isRootEntity:t,fetchQuery:n,findings:s,fetchFindings:o,onUpdate:i}){const c=Mi(),l=n.options.aggregate===!0,a=E7(n.entity),u=a.reduce((N,I)=>({...N,[I.name]:(N[I.name]??0)+1}),{}),h=a.map(N=>({link:N,key:N.alias??(u[N.name]===1?N.name:void 0)})).filter(N=>!!N.key),d=e.entityname?h.find(N=>N.key===e.entityname)?.link??a.find(N=>N.name===e.entityname):void 0,f=t?d??r:r,m=f.type==="entity"?`the root entity (${f.name})`:`${f.alias??f.name} (${f.name})`,p=f.attributes.filter(N=>N.alias&&(N.groupby||N.aggregate)),g=!!e.alias&&p.some(N=>N.alias===e.alias),b=b7(f.name,l?void 0:e.attribute),y=M8(b),w=Er(o,"aggregatelimit"),C=e.entityname?d?`${d.alias??d.name} (${d.name})`:e.entityname:`Root: ${n.entity.name}`;return j.jsx("div",{className:c.container,children:j.jsxs("div",{className:c.section,children:[j.jsx(Xn,{children:"Sort"}),t&&h.length>0&&j.jsx(kr,{label:"Entity",validation:Er(s,"entityname"),info:j.jsx(Qt,{text:"Choose a link-entity to apply its sort before the root entity's sorts. Otherwise link-entity sorts are applied last.",href:Kt.linkOrdersFirst}),children:j.jsxs(po,{value:C,selectedOptions:[e.entityname??d0],onOptionSelect:(N,I)=>i({entityname:I.optionValue===d0?void 0:I.optionValue,attribute:void 0,alias:void 0}),children:[j.jsx(Jt,{value:d0,children:`Root: ${n.entity.name}`}),h.map(({link:N,key:I})=>j.jsx(Jt,{value:I,children:`${N.alias??N.name} (${N.name})`},N.id))]})}),l?j.jsx(kr,{label:"Sort by",required:!0,validation:is(e.alias?void 0:{state:"error",message:p.length===0?`Add an alias to a Group by or Aggregate attribute of ${m} first.`:"Choose an alias to sort by."},Er(s,"alias"),w),info:j.jsx(Qt,{text:"Aggregate queries sort by an attribute alias. Only aliases of Group by or Aggregate attributes of the chosen entity are listed.",href:Kt.order}),children:j.jsxs(po,{placeholder:"Choose an alias",value:e.alias??"",selectedOptions:e.alias?[e.alias]:[],onOptionSelect:(N,I)=>i({alias:I.optionValue,attribute:void 0}),children:[e.alias&&!g&&j.jsx(Jt,{value:e.alias,text:e.alias,children:j.jsxs("span",{className:c.optionText,children:[e.alias,j.jsx("span",{className:c.optionSecondary,children:"Not defined on this entity"})]})}),p.map(N=>j.jsx(Jt,{value:N.alias,text:N.alias,children:j.jsxs("span",{className:c.optionText,children:[N.alias,j.jsxs("span",{className:c.optionSecondary,children:[N.name," · ",dae(N)]})]})},N.id))]})}):j.jsx(kr,{label:"Attribute",required:!0,validation:is(!e.attribute&&!e.alias?{state:"error",message:"Choose an attribute to sort by."}:void 0,y?{state:"error",message:y}:void 0,Er(s,"attribute")),info:j.jsx(Qt,{text:"The logical name of the attribute to sort by. It doesn't need to be a selected attribute.",href:Kt.orderRows}),children:j.jsx(pc,{entityLogicalName:f.name,filterByTypes:uae,value:e.attribute??"",onChange:N=>i({attribute:N||void 0}),placeholder:"Select an attribute"})}),!l&&e.alias&&j.jsx(_a,{text:`Alias: ${e.alias}`,validation:Er(s,"alias")??{state:"error",message:"Only aggregate queries sort by alias."},onRemove:()=>i({alias:void 0})}),l&&e.attribute&&j.jsx(_a,{text:`Attribute: ${e.attribute}`,validation:Er(s,"attribute")??{state:"error",message:"Aggregate queries sort by alias."},onRemove:()=>i({attribute:void 0})}),!t&&e.entityname&&j.jsx(_a,{text:`Entity: ${e.entityname}`,validation:Er(s,"entityname")??{state:"error",message:"Not allowed on an order inside a link-entity."},onRemove:()=>i({entityname:void 0})}),j.jsx(kr,{label:"Direction",info:j.jsx(Qt,{text:"Option set attributes sort by label unless 'Sort option sets by value' is on for the query. Lookups sort by the related record's primary name.",href:Kt.orderRows}),children:j.jsxs(ta,{value:e.descending?"desc":"asc",onChange:(N,I)=>i({descending:I.value==="desc"?!0:void 0}),children:[j.jsx(Yr,{value:"asc",label:"Ascending"}),j.jsx(Yr,{value:"desc",label:"Descending"})]})})]})})}function hae({node:e,unionElsewhere:r,findings:t,onUpdate:n}){const s=Mi(),o=e.conjunction==="or",i=!!e.isQuickFindFields||!!e.overrideQuickFindRecordLimitEnabled||!!e.overrideQuickFindRecordLimitDisabled,c=e.overrideQuickFindRecordLimitEnabled&&e.overrideQuickFindRecordLimitDisabled?"":e.overrideQuickFindRecordLimitEnabled?"apply":e.overrideQuickFindRecordLimitDisabled?"bypass":"default",l=!e.hint&&r;return j.jsxs("div",{className:s.container,children:[j.jsxs("div",{className:s.section,children:[j.jsx(Xn,{children:"Filter"}),j.jsx(kr,{label:"Match",info:j.jsx(Qt,{text:"Whether all conditions (and) or any condition (or) must be true.",href:Kt.filter}),children:j.jsxs(po,{value:o?"Any condition (or)":"All conditions (and)",selectedOptions:[e.conjunction],onOptionSelect:(a,u)=>n({conjunction:u.optionValue}),children:[j.jsx(Jt,{value:"and",children:"All conditions (and)"}),j.jsx(Jt,{value:"or",children:"Any condition (or)"})]})}),(o||e.hint)&&j.jsx(ei,{label:"Union hint",checked:!!e.hint,disabled:l,onChange:a=>n({hint:a?"union":void 0}),hint:l?"Only one filter per query can use the union hint, and another filter has it.":void 0,validation:Er(t,"hint"),info:j.jsx(Qt,{text:"Can improve performance for an 'any condition' filter whose conditions are on attributes of different entities. One per query.",href:Kt.unionHint})})]}),(o||i)&&j.jsxs("div",{className:s.section,children:[j.jsx(Xn,{children:"Quick find"}),j.jsx(ei,{label:"Quick find filter",checked:!!e.isQuickFindFields,onChange:a=>n({isQuickFindFields:a?!0:void 0}),info:j.jsx(Qt,{text:"Runs this filter as a quick find search, the pattern behind the search box in views. Dataverse applies the quick find record limit to it.",href:Kt.quickFind})}),i&&j.jsx(kr,{label:"Record limit",validation:Er(t,"overridequickfindrecordlimitenabled"),info:j.jsx(Qt,{text:"When the 'Quick Find record limits' environment setting is on (the default, and recommended), a quick find matching more than 10,000 records fails with QuickFindQueryRecordLimitExceeded. The count is taken before security filters. The overrides are for temporary testing.",href:Kt.quickFindLimits}),children:j.jsxs(ta,{value:c,onChange:(a,u)=>n({overrideQuickFindRecordLimitEnabled:u.value==="apply"?!0:void 0,overrideQuickFindRecordLimitDisabled:u.value==="bypass"?!0:void 0}),children:[j.jsx(Yr,{value:"default",label:"Use the environment setting (default)"}),j.jsx(Yr,{value:"apply",label:"Always apply the 10,000-record limit (testing)"}),j.jsx(Yr,{value:"bypass",label:"Bypass the limit (testing)"})]})})]})]})}const pae=["Many-to-one (N:1)","One-to-many (1:N)","Many-to-many (N:N)"],mae={N1:"Many-to-one (N:1)","1N":"One-to-many (1:N)",NN:"Many-to-many (N:N)"},pk=(e,r)=>r&&r!==e?`${r} (${e})`:e;function f0(e,r,t,n,s){const o=s.entity(t),i=n.logical?`via ${pk(n.logical,n.display)} · ${e.SchemaName}`:e.SchemaName;return{id:vi(e),schemaName:e.SchemaName,displayText:n.logical?`${o||t} via ${n.display||n.logical}`:o||t,primaryText:pk(t,o),secondaryText:i,searchText:[o,t,n.display,n.logical,e.SchemaName].filter(Boolean).join(" "),type:r,category:mae[r]}}function gae(e,r,t){const n=[],s=o=>({referencedEntity:o.ReferencedEntity,referencingEntity:o.ReferencingEntity,referencedAttribute:o.ReferencedAttribute,referencingAttribute:o.ReferencingAttribute});for(const o of r.manyToOne){const i=o.ReferencingAttribute||"";n.push({...f0(o,"N1",o.ReferencedEntity,{logical:i,display:i?t.attribute(o.ReferencingEntity,i):void 0},t),...s(o)})}for(const o of r.oneToMany){const i=o.ReferencingAttribute||"";n.push({...f0(o,"1N",o.ReferencingEntity,{logical:i,display:i?t.attribute(o.ReferencingEntity,i):void 0},t),...s(o)})}for(const o of r.manyToMany){const i=o.Entity1LogicalName||"",c=o.Entity2LogicalName||"",l=i===e?c:i,a=o.IntersectEntityName||"";n.push({...f0(o,"NN",l,{logical:a,display:a?t.entity(a):void 0},t),referencedEntity:c,referencingEntity:i,referencedAttribute:o.Entity2IntersectAttribute||"",referencingAttribute:o.Entity1IntersectAttribute||"",intersectEntity:o.IntersectEntityName})}return n}function bae(e,r){const t=r.trim().toLowerCase();return t?e.filter(n=>n.searchText.toLowerCase().includes(t)):e}const vae=wr({option:{display:"flex",flexDirection:"column",minWidth:0},optionSecondary:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200}}),yae={style:{minWidth:420}},mk=e=>e?.DisplayName?.UserLocalizedLabel?.Label||void 0;function wae({entityLogicalName:e,value:r,onChange:t,placeholder:n="Select a relationship…",disabled:s=!1}){const o=vae(),i=mr("relationship-combobox"),[c,l]=A.useState([]),[a,u]=A.useState(!1),[h,d]=A.useState(null),[f,m]=A.useState(""),[p,g]=A.useState(null),b=Sp();A.useEffect(()=>{if(!e){Ie("relationshipPicker","No entity name provided, clearing relationships"),l([]);return}Ie("relationshipPicker","Loading relationships for entity:",e);let I=!0;return u(!0),d(null),Promise.all([m_(e,b),p_().catch(()=>[]),jc(e).catch(()=>[])]).then(([$,D,F])=>{if(!I)return;Ie("relationshipPicker","Received relationship data:",{entityLogicalName:e,oneToManyCount:$.oneToMany.length,manyToOneCount:$.manyToOne.length,manyToManyCount:$.manyToMany.length});const V=new Map(D.map(E=>[E.LogicalName,E])),G=E=>E===e?F:Zt.getEntityAttributes(`${E}__all`)??[],U=gae(e,$,{entity:E=>mk(V.get(E)??Zt.getEntityMetadata(E)),attribute:(E,M)=>mk(G(E).find(B=>B.LogicalName===M))});l(U),u(!1),Ie("relationshipPicker","Relationships loaded successfully:",{entityLogicalName:e,totalRelationships:U.length})}).catch($=>{I&&(console.error("[RelationshipPicker] Failed to load relationships:",{entityLogicalName:e,error:$}),d("Failed to load relationships"),u(!1))}),()=>{I=!1}},[e,b]),A.useEffect(()=>{if(r){const I=c.find($=>$.schemaName===r);g(I?.id??null),m(I?I.displayText:r)}else g(null),m("")},[r,c]);const y=c.find(I=>I.id===p),w=y&&f===y.displayText?"":f,C=A.useMemo(()=>bae(c,w),[c,w]),N=(I,$)=>{const D=$.optionValue;if(Ie("relationshipPicker","Relationship selected:",{id:D}),D){const F=c.find(V=>V.id===D);F&&(Ie("relationshipPicker","Found relationship details:",F),g(F.id),m(F.displayText),t(F))}else g(null),m("")};return a?j.jsx(hn,{size:"tiny",label:"Loading relationships…"}):h?j.jsx(Zn,{"aria-labelledby":i,value:"",placeholder:"Error loading relationships",disabled:!0}):j.jsx(Zn,{"aria-labelledby":i,listbox:yae,value:f,selectedOptions:p?[p]:[],onOptionSelect:N,onChange:I=>m(I.target.value),placeholder:c.length===0?"No relationships found":n,disabled:s||c.length===0,clearable:!0,children:C.length===0&&w.trim()?j.jsx(Jt,{disabled:!0,children:`No relationships match "${w.trim()}"`}):pae.map(I=>{const $=C.filter(D=>D.category===I);return $.length>0&&j.jsx(ja,{label:I,children:$.map(D=>j.jsx(Jt,{value:D.id,text:D.searchText,children:j.jsxs("span",{className:o.option,children:[j.jsx("span",{children:D.primaryText}),j.jsx("span",{className:o.optionSecondary,children:D.secondaryText})]})},D.id))},I)})})}const Ds={inner:{label:"Inner",description:"Default. Only records with a matching related record."},outer:{label:"Outer",description:"Also records without a matching related record."},exists:{label:"Exists",description:"Like inner, using EXISTS: each record once, no related attributes."},in:{label:"In",description:"Like inner, using IN: each record once, no related attributes."},matchfirstrowusingcrossapply:{label:"Match first row",description:"Like inner, matching only one related record: each record once."},any:{label:"Any",description:"Records with at least one related record matching this link-entity's filter."},"not any":{label:"Not any",description:"Records with no related record matching this link-entity's filter."},all:{label:"All",description:"Records with related records, none of which match the filter. Invert the filter to require every related record to match."},"not all":{label:"Not all",description:"The same as Any, despite the name."},natural:{label:"Natural",description:"Not in the FetchXML reference; Dataverse accepts it."}},gk=["inner","outer","exists","in","matchfirstrowusingcrossapply"],Wf=["any","not any","all","not all"];function xae({node:e,parentEntityName:r,inFilter:t,findings:n,onUpdate:s}){const o=Mi(),{addLinkEntityWithConfig:i,fetchQuery:c}=wd(),[l,a]=A.useState(null),[u,h]=A.useState(null),d=e.name==="new_entity"||!e.name&&!e.from&&!e.to,[f,m]=A.useState(d);A.useEffect(()=>m(d),[e.id,d]);const p=[e.attributes.length>0&&`${e.attributes.length} attribute${e.attributes.length===1?"":"s"}`,e.allAttributes?.enabled&&"all attributes",e.orders.length>0&&`${e.orders.length} sort${e.orders.length===1?"":"s"}`].filter(D=>!!D),g=e.attributes.length+(e.allAttributes?.enabled?1:0)+e.orders.length,b=D=>{cl.has(D)&&p.length>0?a(D):s({linkType:D})},y=D=>{l&&s(D?{linkType:l,attributes:[],allAttributes:void 0,orders:[]}:{linkType:l}),a(null)},w=async D=>{h(null);try{if(!D.intersectEntity)throw new Error("the relationship has no intersect entity.");const F=D.referencingEntity===r?D.referencedEntity:D.referencingEntity,[V,G]=await Promise.all([hc(r),hc(F)]),U=yJ(r,V.PrimaryIdAttribute,{Entity1LogicalName:D.referencingEntity,Entity2LogicalName:D.referencedEntity,Entity1IntersectAttribute:D.referencingAttribute,Entity2IntersectAttribute:D.referencedAttribute,IntersectEntityName:D.intersectEntity},()=>G.PrimaryIdAttribute);if(!U)throw new Error(`${r} isn't part of ${D.schemaName}.`);s({name:U.intersect.name,from:U.intersect.from,to:U.intersect.to,intersect:!0,alias:void 0,relationshipType:"NN"}),i(e.id,U.target.name,U.target.from,U.target.to,"inner","NN"),m(!1)}catch(F){h(`Couldn't build the many-to-many join: ${F instanceof Error?F.message:String(F)}`)}},C=D=>{if(D.type==="NN"){w(D);return}Ie("linkEntityEditor","Relationship selected:",{nodeId:e.id,parentEntityName:r,relationship:D});const F={name:"",from:"",to:"",relationshipType:D.type};if(D.type==="1N"?D.referencedEntity===r?(F.name=D.referencingEntity,F.from=D.referencingAttribute,F.to=D.referencedAttribute):(F.name=D.referencedEntity,F.from=D.referencedAttribute,F.to=D.referencingAttribute):D.type==="N1"&&(D.referencingEntity===r?(F.name=D.referencedEntity,F.from=D.referencedAttribute,F.to=D.referencingAttribute):(F.name=D.referencingEntity,F.from=D.referencingAttribute,F.to=D.referencedAttribute)),e.alias?.startsWith("new_entity")&&typeof F.name=="string"&&F.name&&c){const V=J0(c);V.delete(e.alias),F.alias=eb(F.name,V)}s(F),m(!1)},N=t?Wf:[...gk,...Wf],I=(D,F=Ds[D]?.description)=>j.jsx(Jt,{value:D,text:Ds[D]?.label??D,children:j.jsxs("span",{className:o.optionText,children:[Ds[D]?.label??D,j.jsx("span",{className:o.optionSecondary,children:F})]})},D),$=!e.from&&!e.to?{state:"warning",message:"Neither attribute is set: Dataverse uses the system many-to-many relationship between the entities, and fails (0x80041102) if there isn't one."}:!e.from||!e.to?{state:"warning",message:"Set both attributes. With only one, Dataverse tries to work out the other from the relationship definitions."}:void 0;return j.jsxs("div",{className:o.container,children:[f&&r&&j.jsxs("div",{className:o.section,children:[j.jsx(Xn,{children:"Relationship"}),j.jsx(kr,{label:"Relationship",hint:"Fills in the entity and the attributes to match. A many-to-many relationship adds its intersect entity with the related entity inside it. Or set them below.",validation:u?{state:"error",message:u}:void 0,info:j.jsx(Qt,{text:`The relationships of ${r}.`,href:Kt.joinTables}),children:j.jsx(wae,{entityLogicalName:r,onChange:C,placeholder:"Select a relationship…"})})]}),j.jsxs("div",{className:o.section,children:[j.jsx(Xn,{children:"Link-entity"}),j.jsx(kr,{label:"Entity",required:!0,validation:e.name?void 0:{state:"error",message:"Enter the logical name of the related entity."},info:j.jsx(Qt,{text:"The logical name of the related entity.",href:Kt.linkEntity}),children:j.jsx(_n,{className:o.mono,value:e.name,onChange:(D,F)=>s({name:F.value}),placeholder:"e.g. contact"})}),j.jsx(kr,{label:"From attribute",validation:$,info:j.jsx(Qt,{text:`The ${e.name||"related entity"} attribute that matches the To attribute. Not technically required, but usually set. Both attributes should have the same type.`,href:Kt.linkEntityFromTo}),children:j.jsx(pc,{entityLogicalName:e.name,value:e.from??"",onChange:D=>s({from:D||void 0}),placeholder:"Select an attribute",disabled:!e.name})}),j.jsx(kr,{label:"To attribute",info:j.jsx(Qt,{text:`The ${r||"parent"} attribute that matches the From attribute. Not technically required, but usually set.`,href:Kt.linkEntityFromTo}),children:j.jsx(pc,{entityLogicalName:r,value:e.to??"",onChange:D=>s({to:D||void 0}),placeholder:"Select an attribute",disabled:!r})}),j.jsx(kr,{label:"Link type",validation:Er(n,"link-type"),hint:t?"Inside a filter, a link-entity checks related records and returns nothing.":void 0,info:j.jsx(Qt,{text:Ds[e.linkType]?.description??"How the related records are matched.",href:Kt.linkEntity}),children:j.jsxs(po,{value:Ds[e.linkType]?.label??e.linkType,selectedOptions:[e.linkType],onOptionSelect:(D,F)=>F.optionValue&&b(F.optionValue),children:[!N.includes(e.linkType)&&I(e.linkType,t?"Not allowed inside a filter":void 0),t?Wf.map(D=>I(D)):j.jsxs(j.Fragment,{children:[j.jsx(ja,{label:"Join",children:gk.map(D=>I(D))}),j.jsx(ja,{label:"Filter on related records",children:Wf.map(D=>I(D))})]})]})}),j.jsx(kr,{label:"Alias",validation:Er(n,"alias"),info:j.jsx(Qt,{text:"The name to use for this link-entity in conditions (entity, compare to) and sorts. Without one, Dataverse generates a name ({name}{N}) that the query can't reference. Letters, digits and underscores; starts with a letter or underscore.",href:Kt.linkEntity}),children:j.jsx(_n,{className:o.mono,value:e.alias??"",onChange:(D,F)=>s({alias:xp(F.value)||void 0}),placeholder:"e.g. parent_account"})}),j.jsx(ei,{label:"Intersect",checked:!!e.intersect,onChange:D=>s({intersect:D?!0:void 0}),info:j.jsx(Qt,{text:"Shows that this link-entity only joins (typically the intersect entity of a many-to-many relationship) and returns no attributes on purpose. It doesn't change how the query runs.",href:Kt.linkEntity})}),e.visible!==void 0&&j.jsx(_a,{text:`Visible: ${e.visible}`,validation:{state:"none",message:Er(n,"visible")?.message??"Dataverse ignores visible."},onRemove:()=>s({visible:void 0})})]}),j.jsx(Do,{modalType:"alert",open:l!==null,onOpenChange:(D,F)=>!F.open&&a(null),children:j.jsx(zi,{children:j.jsxs(Ai,{children:[j.jsxs(Ri,{children:["Change the link type to ",l?Ds[l].label:"","?"]}),j.jsxs(Ii,{children:["The ",l?Ds[l].label:""," link type returns no attributes, so Dataverse rejects this link-entity's ",p.join(" and "),". Remove ",g===1?"it":"them"," ","now? Its filters and nested link-entities are kept."]}),j.jsx(Po,{position:"start",children:j.jsx(St,{onClick:()=>y(!1),children:"Change only"})}),j.jsxs(Po,{position:"end",children:[j.jsx(St,{onClick:()=>a(null),children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:()=>y(!0),children:"Change and remove"})]})]})})})]})}const kae=wr({container:{overflow:"auto",height:"100%",minHeight:0,scrollbarGutter:"stable"},emptyState:{padding:le.spacingHorizontalL,color:le.colorNeutralForeground3,fontSize:le.fontSizeBase300,fontStyle:"italic"}});function Sae({selectedNode:e,fetchQuery:r,onNodeUpdate:t}){const n=kae(),{removeNode:s}=wd(),o=A.useMemo(()=>r?Fv(r):[],[r]);if(!e||!r)return j.jsx("div",{className:n.container,children:j.jsx("div",{className:n.emptyState,children:"Select a node in the tree to view its properties."})});const i=o.filter(d=>d.nodeId===e.id),c=r.options.aggregate===!0,l=d=>t(e.id,d),a=ZY(r,e.id),u=j.jsx("div",{className:n.emptyState,children:"This node is no longer in the query."}),h=()=>{switch(e.type){case"fetch":return j.jsx(aae,{node:e,findings:i,onUpdate:l});case"entity":return j.jsx(sae,{node:e,onUpdate:l});case"all-attributes":return j.jsx(lae,{isAggregateQuery:c,onRemove:()=>s(e.id)});case"attribute":return a?j.jsx(cae,{node:e,container:a.container,isRootEntity:a.isRoot,isAggregateQuery:c,fetchQuery:r,findings:i,onUpdate:l}):u;case"order":return a?j.jsx(fae,{node:e,container:a.container,isRootEntity:a.isRoot,fetchQuery:r,findings:i,fetchFindings:o.filter(d=>d.nodeId===r.id),onUpdate:l}):u;case"filter":return j.jsx(hae,{node:e,unionElsewhere:t5(r).some(d=>d.id!==e.id&&d.hint==="union"),findings:i,onUpdate:l});case"condition":return j.jsx(v7,{node:e,entityName:a?.container.name??e5(r,e.id)??"",fetchQuery:r,findings:i,onUpdate:l});case"link-entity":return j.jsx(xae,{node:e,parentEntityName:e5(r,e.id)??r.entity.name,inFilter:t5(r).some(d=>d.links?.some(f=>f.id===e.id)),findings:i,onUpdate:l});default:return j.jsx("div",{className:n.emptyState,children:"Unknown node type."})}};return j.jsx("div",{className:n.container,children:h()},e.id)}const lh={String:200,Memo:250,Integer:100,BigInt:120,Decimal:120,Double:120,Money:130,DateTime:150,Lookup:180,Customer:180,Owner:180,Picklist:150,State:100,Status:120,MultiSelectPicklist:200,Boolean:80,Uniqueidentifier:280,Image:60,File:150,default:150};function _ae(e){return e?lh[e]??lh.default:lh.default}function Cae(e){const t=new DOMParser().parseFromString(e,"text/xml"),n=t.querySelector("parsererror");if(n)throw new Error(`Invalid LayoutXML: ${n.textContent}`);const s=t.querySelector("grid");if(!s)throw new Error("Invalid LayoutXML: missing <grid> element");const o=t.querySelector("row"),i=t.querySelectorAll("cell"),c=[];return i.forEach(l=>{const a=l.getAttribute("name"),u=l.getAttribute("width"),h=l.getAttribute("disableSorting"),d=l.getAttribute("imageproviderwebresource"),f=l.getAttribute("imageproviderfunctionname");a&&c.push({name:a,width:u?parseInt(u,10):lh.default,disableSorting:h==="1",imageProviderName:d||void 0,imageProviderFunctionName:f||void 0})}),{gridName:s.getAttribute("name")||"resultset",objectTypeCode:s.getAttribute("object")?parseInt(s.getAttribute("object"),10):void 0,jumpAttribute:s.getAttribute("jump")||void 0,enableSelection:s.getAttribute("select")==="1",showIcon:s.getAttribute("icon")==="1",enablePreview:s.getAttribute("preview")==="1",primaryIdAttribute:o?.getAttribute("id")||void 0,columns:c}}function Tae(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Bae(e){const r=(o,i)=>`${o}="${Tae(String(i))}"`,t=e.columns.map(o=>{const i=[r("name",o.name),r("width",o.width)];return o.disableSorting&&i.push('disableSorting="1"'),o.imageProviderName&&i.push(r("imageproviderwebresource",o.imageProviderName)),o.imageProviderFunctionName&&i.push(r("imageproviderfunctionname",o.imageProviderFunctionName)),` <cell ${i.join(" ")} />`}).join(`
|
|
76
76
|
`),n=[r("name",e.gridName)];e.objectTypeCode!==void 0&&n.push(r("object",e.objectTypeCode)),e.jumpAttribute&&n.push(r("jump",e.jumpAttribute)),n.push(`select="${e.enableSelection?"1":"0"}"`),n.push(`icon="${e.showIcon?"1":"0"}"`),n.push(`preview="${e.enablePreview?"1":"0"}"`);const s=['name="result"'];return e.primaryIdAttribute&&s.push(r("id",e.primaryIdAttribute)),`<grid ${n.join(" ")}>
|
|
77
77
|
<row ${s.join(" ")}>
|
|
78
78
|
${t}
|
|
79
79
|
</row>
|
|
80
|
-
</grid>`}function Tae(e,r,t){const n=e??Nu(r,t.primaryIdAttribute);return Cae({...n,objectTypeCode:t.objectTypeCode,primaryIdAttribute:t.primaryIdAttribute,jumpAttribute:n.jumpAttribute||t.primaryNameAttribute||void 0})}function A7(e,r){return Cp(e).map(t=>{const n=t.isRoot?r?.get(t.attribute.name):r?.get(`${t.container.name}.${t.attribute.name}`);return{name:t.key,width:kae(n),...t.linkAlias?{linkEntityAlias:t.linkAlias}:{}}})}function Nu(e,r,t){const n=A7(e,t);return{gridName:"resultset",jumpAttribute:void 0,enableSelection:!0,showIcon:!0,enablePreview:!0,primaryIdAttribute:r,columns:n}}function Bae(e,r,t){const n=A7(r,t),s=new Set(n.map(c=>c.name)),o=new Set(e.columns.map(c=>c.name)),i=e.columns.filter(c=>s.has(c.name));for(const c of n)o.has(c.name)||i.push(c);return{...e,columns:i}}function jae(e,r,t){return{...e,columns:e.columns.map(n=>n.name===r?{...n,width:t}:n)}}function Nae(e,r,t){const n=[...e.columns],[s]=n.splice(r,1);return n.splice(t,0,s),{...e,columns:n}}let Eae=0;const co=()=>`node_${++Eae}`,R7={fetchQuery:null,selectedNodeId:null,selectedNode:null,loadedView:null,columnConfig:null,layoutNeedsSync:!1,retrieveAllRecords:!1,columnFilterId:null,columnFilterWrapperId:null};function h0(e,r,t,n){const s=e.selectedNodeId?jn(r,e.selectedNodeId):null;return{...e,fetchQuery:r,columnFilterId:t,columnFilterWrapperId:t?n:null,selectedNodeId:s?e.selectedNodeId:r.entity.id,selectedNode:s??r.entity,loadedView:null}}function jn(e,r){if(!e||typeof e!="object")return null;const t=e;if(t.id===r)return e;const n=["attributes","orders","filters","conditions","subfilters","links"];for(const s of n)if(Array.isArray(t[s]))for(const o of t[s]){const i=jn(o,r);if(i)return i}if(t.entity){const s=jn(t.entity,r);if(s)return s}if(t.allAttributes){const s=jn(t.allAttributes,r);if(s)return s}return null}function uo(e,r,t){if(e.id===r)return t(e);const n={...e};let s=!1;const o=["attributes","orders","filters","conditions","subfilters","links"];for(const c of o){const l=e[c];if(Array.isArray(l)){const a=l.map(u=>{const h=uo(u,r,t);return h!==u&&(s=!0),h});s&&(n[c]=a)}}const i=e;if(i.entity){const c=uo(i.entity,r,t);c!==i.entity&&(n.entity=c,s=!0)}if(i.allAttributes){const c=uo(i.allAttributes,r,t);c!==i.allAttributes&&(n.allAttributes=c,s=!0)}return s?n:e}function Tb(e,r){const t=e;if(e.id===r&&(t.type==="fetch"||t.type==="entity"))return e;const n={...e};let s=!1;const o=["attributes","orders","filters","conditions","subfilters","links"];for(const i of o){const c=t[i];if(Array.isArray(c)){const l=c.filter(a=>a.id!==r).map(a=>Tb(a,r)).filter(a=>a!==null);(l.length!==c.length||l.some((a,u)=>a!==c[u]))&&(n[i]=l,s=!0)}}if(t.entity){const i=Tb(t.entity,r);i!==t.entity&&(n.entity=i,s=!0)}return t.allAttributes&&t.allAttributes.id===r&&(delete n.allAttributes,s=!0),s?n:e}function Aae(e,r){switch(r.type){case"NEW_QUERY":return R7;case"LOAD_FETCHXML":{const t=r.fetchNode,n=r.preserveLayout===!0&&e.columnConfig!==null,s=n?e.columnConfig:Nu(t),o=kre(e.fetchQuery,t,e.columnFilterId);return{fetchQuery:t,selectedNodeId:t.entity.id,selectedNode:t.entity,loadedView:null,columnConfig:s,layoutNeedsSync:n,retrieveAllRecords:e.retrieveAllRecords,columnFilterId:o,columnFilterWrapperId:xre(e.fetchQuery,t,e.columnFilterWrapperId,o)}}case"LOAD_VIEW":{const t=r.fetchNode;let n;if(r.layoutXml)try{n=Sae(r.layoutXml)}catch(s){console.warn("Failed to parse view layoutxml, generating from FetchXML:",s),n=Nu(t)}else n=Nu(t);return{fetchQuery:t,selectedNodeId:t.entity.id,selectedNode:t.entity,loadedView:r.viewInfo,columnConfig:n,layoutNeedsSync:!1,retrieveAllRecords:e.retrieveAllRecords,columnFilterId:null,columnFilterWrapperId:null}}case"CLEAR_LOADED_VIEW":return{...e,loadedView:null,layoutNeedsSync:!0};case"SET_LOADED_VIEW":return{...e,loadedView:r.viewInfo};case"SET_ENTITY":{const t={id:co(),type:"entity",name:r.entityName,attributes:[],orders:[],filters:[],links:[]};return{fetchQuery:{id:co(),type:"fetch",entity:t,options:{count:50}},selectedNodeId:t.id,selectedNode:t,loadedView:null,columnConfig:null,layoutNeedsSync:!1,retrieveAllRecords:e.retrieveAllRecords,columnFilterId:null,columnFilterWrapperId:null}}case"SELECT_NODE":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.nodeId);return{...e,selectedNodeId:r.nodeId,selectedNode:t}}case"ADD_ATTRIBUTE":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity")return e;const n={id:co(),type:"attribute",name:"new_attribute"},s=uo(e.fetchQuery,r.parentId,o=>{const i=o;return{...i,attributes:[...i.attributes,n]}});return{...e,fetchQuery:s,selectedNodeId:n.id,selectedNode:n,loadedView:null,layoutNeedsSync:!0}}case"ADD_ATTRIBUTE_BY_NAME":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity")return e;const n=t.attributes.find(i=>i.name===r.attributeName);if(n)return{...e,selectedNodeId:n.id,selectedNode:n};const s={id:co(),type:"attribute",name:r.attributeName},o=uo(e.fetchQuery,r.parentId,i=>{const c=i;return{...c,attributes:[...c.attributes,s]}});return{...e,fetchQuery:o,selectedNodeId:s.id,selectedNode:s,loadedView:null,layoutNeedsSync:!0}}case"ADD_ALL_ATTRIBUTES":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity")return e;const n={id:co(),type:"all-attributes",enabled:!0},s=uo(e.fetchQuery,r.parentId,o=>({...o,allAttributes:n}));return{...e,fetchQuery:s,selectedNodeId:n.id,selectedNode:n,loadedView:null,layoutNeedsSync:!0}}case"UPDATE_ATTRIBUTES":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity")return e;const s=t.attributes,o=r.attributeNames,i=new Set(s.map(h=>h.name)),c=new Set(o),l=o.filter(h=>!i.has(h)),a=s.filter(h=>c.has(h.name));l.forEach(h=>{a.push({id:co(),type:"attribute",name:h})});const u=uo(e.fetchQuery,r.parentId,h=>({...h,attributes:a}));return{...e,fetchQuery:u,loadedView:null,layoutNeedsSync:!0}}case"ADD_ORDER":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity")return e;const n={id:co(),type:"order",attribute:"new_attribute",descending:!1},s=uo(e.fetchQuery,r.parentId,o=>{const i=o;return{...i,orders:[...i.orders,n]}});return{...e,fetchQuery:s,selectedNodeId:n.id,selectedNode:n,loadedView:null}}case"ADD_FILTER":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity")return e;const n={id:co(),type:"filter",conjunction:"and",conditions:[],subfilters:[],links:[]},s=uo(e.fetchQuery,r.parentId,o=>{const i=o;return{...i,filters:[...i.filters,n]}});return{...e,fetchQuery:s,selectedNodeId:n.id,selectedNode:n,loadedView:null}}case"ADD_SUBFILTER":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.filterId);if(!t||t.type!=="filter")return e;const n={id:co(),type:"filter",conjunction:"and",conditions:[],subfilters:[],links:[]},s=uo(e.fetchQuery,r.filterId,o=>{const i=o;return{...i,subfilters:[...i.subfilters,n]}});return{...e,fetchQuery:s,selectedNodeId:n.id,selectedNode:n,loadedView:null}}case"ADD_CONDITION":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.filterId);if(!t||t.type!=="filter")return e;const n={id:co(),type:"condition",attribute:"new_attribute",operator:"eq"},s=uo(e.fetchQuery,r.filterId,o=>{const i=o;return{...i,conditions:[...i.conditions,n]}});return{...e,fetchQuery:s,selectedNodeId:n.id,selectedNode:n,loadedView:null}}case"ADD_LINK_ENTITY":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity"&&t.type!=="filter")return e;const n=J0(e.fetchQuery),s=eb("new_entity",n),o={id:co(),type:"link-entity",name:"new_entity",alias:s,from:"id_field",to:"parent_id_field",linkType:t.type==="filter"?"any":"inner",attributes:[],orders:[],filters:[],links:[]},i=uo(e.fetchQuery,r.parentId,c=>{const l=c;if(l.type==="filter"){const a=l;return{...a,links:[...a.links||[],o]}}else{const a=l;return{...a,links:[...a.links,o]}}});return{...e,fetchQuery:i,selectedNodeId:o.id,selectedNode:o,loadedView:null,layoutNeedsSync:!0}}case"ADD_LINK_ENTITY_WITH_CONFIG":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity")return e;const n=J0(e.fetchQuery),s=eb(r.name,n),o={id:r.id,type:"link-entity",name:r.name,alias:s,from:r.from,to:r.to,linkType:r.linkType,relationshipType:r.relationshipType??"N1",attributes:[],orders:[],filters:[],links:[]},i=uo(e.fetchQuery,r.parentId,c=>{const l=c;return{...l,links:[...l.links,o]}});return{...e,fetchQuery:i,selectedNodeId:o.id,selectedNode:o,loadedView:null,layoutNeedsSync:!0}}case"ADD_COLUMN_FILTER":{if(!e.fetchQuery)return e;const t=yre(e.fetchQuery,e.columnFilterId,r.condition,co);return h0(e,t.fetch,t.groupId,t.wrapperId??e.columnFilterWrapperId)}case"REMOVE_COLUMN_FILTER":{if(!e.fetchQuery)return e;const t=wre(e.fetchQuery,e.columnFilterId,r.conditionId,e.columnFilterWrapperId);return h0(e,t.fetch,t.groupId,e.columnFilterWrapperId)}case"CLEAR_COLUMN_FILTERS":{if(!e.fetchQuery)return e;const t=W_(e.fetchQuery,e.columnFilterId,e.columnFilterWrapperId);return h0(e,t,null,null)}case"REMOVE_NODE":{if(!e.fetchQuery)return e;const t=Tb(e.fetchQuery,r.nodeId);if(!t)return e;const n=e.selectedNodeId===r.nodeId?null:e.selectedNodeId,s=n?jn(t,n):null;return{...e,fetchQuery:t,selectedNodeId:n,selectedNode:s,loadedView:null,layoutNeedsSync:!0}}case"UPDATE_NODE":{if(!e.fetchQuery||!jn(e.fetchQuery,r.nodeId))return e;const n=uo(e.fetchQuery,r.nodeId,o=>{const i=o;if(i.type==="fetch"){const c=o;return{...c,options:{...c.options,...r.updates}}}return{...i,...r.updates}}),s=e.selectedNodeId===r.nodeId?jn(n,r.nodeId):e.selectedNode;return{...e,fetchQuery:n,selectedNode:s,loadedView:null,layoutNeedsSync:!0}}case"SET_COLUMN_CONFIG":return{...e,columnConfig:r.config,layoutNeedsSync:!1};case"UPDATE_COLUMN_WIDTH":return e.columnConfig?{...e,columnConfig:jae(e.columnConfig,r.columnName,r.width)}:e;case"REORDER_COLUMNS":return e.columnConfig?{...e,columnConfig:Nae(e.columnConfig,r.fromIndex,r.toIndex)}:e;case"SYNC_LAYOUT_WITH_FETCHXML":{if(!e.fetchQuery)return e;let t;if(e.columnConfig)t=Bae(e.columnConfig,e.fetchQuery,r.attributeTypeMap);else if(r.primaryIdAttribute)t=Nu(e.fetchQuery,r.primaryIdAttribute,r.attributeTypeMap);else return e;return{...e,columnConfig:t,layoutNeedsSync:!1}}case"SET_SORT":{if(!e.fetchQuery?.entity)return e;const{plan:t,descending:n,isMultiSort:s}=r,o=d=>(d.attribute??void 0)===(t.spec.attribute??void 0)&&(d.alias??void 0)===(t.spec.alias??void 0)&&(d.entityname??void 0)===(t.spec.entityname??void 0),i={id:co(),type:"order",...t.spec.attribute?{attribute:t.spec.attribute}:{},...t.spec.alias?{alias:t.spec.alias}:{},...t.spec.entityname?{entityname:t.spec.entityname}:{},descending:n||void 0},c=d=>{const f=d.findIndex(o);return f>=0?d.map((m,p)=>p===f?{...m,descending:n||void 0}:m):[...d,i]},l=d=>d.map(f=>({...f,orders:[],links:l(f.links)})),a=t.insideLink?.id,u=d=>d.map(f=>f.id===a?{...f,orders:s?c(f.orders):[i],links:u(f.links)}:{...f,links:u(f.links)});let h=e.fetchQuery.entity;return s||(h={...h,orders:[],links:l(h.links)}),h=a?{...h,links:u(h.links)}:{...h,orders:s?c(h.orders):[i]},{...e,fetchQuery:{...e.fetchQuery,entity:h}}}case"SET_RETRIEVE_ALL_RECORDS":return{...e,retrieveAllRecords:r.enabled};default:return e}}function Rae({children:e}){const[r,t]=A.useReducer(Aae,R7),n=A.useMemo(()=>({setEntity:o=>t({type:"SET_ENTITY",entityName:o}),selectNode:o=>t({type:"SELECT_NODE",nodeId:o}),addAttribute:o=>t({type:"ADD_ATTRIBUTE",parentId:o}),addAttributeByName:(o,i)=>t({type:"ADD_ATTRIBUTE_BY_NAME",parentId:o,attributeName:i}),updateAttributes:(o,i)=>t({type:"UPDATE_ATTRIBUTES",parentId:o,attributeNames:i}),addAllAttributes:o=>t({type:"ADD_ALL_ATTRIBUTES",parentId:o}),addOrder:o=>t({type:"ADD_ORDER",parentId:o}),addFilter:o=>t({type:"ADD_FILTER",parentId:o}),addSubfilter:o=>t({type:"ADD_SUBFILTER",filterId:o}),addCondition:o=>t({type:"ADD_CONDITION",filterId:o}),addLinkEntity:o=>t({type:"ADD_LINK_ENTITY",parentId:o}),addLinkEntityWithConfig:(o,i,c,l,a,u)=>{const h=co();return t({type:"ADD_LINK_ENTITY_WITH_CONFIG",id:h,parentId:o,name:i,from:c,to:l,linkType:a,relationshipType:u}),h},removeNode:o=>t({type:"REMOVE_NODE",nodeId:o}),updateNode:(o,i)=>t({type:"UPDATE_NODE",nodeId:o,updates:i}),newQuery:()=>t({type:"NEW_QUERY"}),loadFetchXml:(o,i)=>{const c=el(o);return c.success&&c.fetchNode&&t({type:"LOAD_FETCHXML",fetchNode:c.fetchNode,preserveLayout:i?.preserveLayout}),c},loadView:(o,i,c)=>{const l=el(o);return l.success&&l.fetchNode&&t({type:"LOAD_VIEW",fetchNode:l.fetchNode,viewInfo:{...i,originalFetchXml:ya(l.fetchNode)},layoutXml:c}),l},clearLoadedView:()=>t({type:"CLEAR_LOADED_VIEW"}),setLoadedView:o=>t({type:"SET_LOADED_VIEW",viewInfo:{...o}}),setColumnConfig:o=>t({type:"SET_COLUMN_CONFIG",config:o}),updateColumnWidth:(o,i)=>t({type:"UPDATE_COLUMN_WIDTH",columnName:o,width:i}),reorderColumns:(o,i)=>t({type:"REORDER_COLUMNS",fromIndex:o,toIndex:i}),syncLayoutWithFetchXml:(o,i)=>t({type:"SYNC_LAYOUT_WITH_FETCHXML",attributeTypeMap:o,primaryIdAttribute:i}),setSort:(o,i,c)=>t({type:"SET_SORT",plan:o,descending:i,isMultiSort:c}),setRetrieveAllRecords:o=>t({type:"SET_RETRIEVE_ALL_RECORDS",enabled:o}),addColumnFilter:o=>t({type:"ADD_COLUMN_FILTER",condition:o}),removeColumnFilter:o=>t({type:"REMOVE_COLUMN_FILTER",conditionId:o}),clearColumnFilters:()=>t({type:"CLEAR_COLUMN_FILTERS"})}),[]),s=A.useMemo(()=>({...r,...n}),[r,n]);return j.jsx(N7.Provider,{value:s,children:e})}function zae({isDark:e,children:r}){return j.jsx(C_.Provider,{value:{isDark:e},children:r})}const Iae=wr({content:{display:"flex",flexDirection:"column",gap:le.spacingVerticalM},warningRow:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,color:le.colorPaletteRedForeground1},successRow:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,color:le.colorPaletteGreenForeground1},recordInfo:{backgroundColor:le.colorNeutralBackground3,padding:le.spacingVerticalS,borderRadius:le.borderRadiusMedium},errorMessage:{color:le.colorPaletteRedForeground1,marginTop:le.spacingVerticalS},progressSection:{display:"flex",flexDirection:"column",gap:le.spacingVerticalS},progressStats:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:le.spacingVerticalXS},eta:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200},resultSummary:{display:"flex",flexDirection:"column",gap:le.spacingVerticalXS}});function Mae({open:e,recordName:r,entityDisplayName:t,entityLogicalName:n,recordCount:s,onClose:o,onConfirm:i,onProgress:c}){const l=Iae(),[a,u]=A.useState("confirm"),[h,d]=A.useState(null),[f,m]=A.useState(null),[p,g]=A.useState(null),[b,y]=A.useState(!1);A.useEffect(()=>{c&&g(c)},[c]);const w=A.useCallback(async()=>{u("deleting"),d(null),g(null),m(null);try{const G=await i();G?(m(G),G.failed===0?u("success"):G.succeeded===0?(u("error"),d(`All ${G.failed} delete(s) failed`)):u("partial")):u("success")}catch(G){d(zn(G,"Failed to delete record(s)")),u("error")}},[i]),C=A.useCallback(()=>{a!=="deleting"&&(u("confirm"),d(null),m(null),g(null),o())},[a,o]),N=G=>{if(G<60)return`~${G}s remaining`;const U=Math.floor(G/60),E=Math.floor(U/60);if(U<60){const S=G%60;return`~${U}m ${S}s remaining`}if(E<12){const S=U%60;return`~${E}h ${S}m remaining`}const M=new Date(Date.now()+G*1e3),B=M.toDateString()===new Date().toDateString(),k=M.toDateString()===new Date(Date.now()+864e5).toDateString(),_=M.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return B?`Est. completion: today at ${_}`:k?`Est. completion: tomorrow at ${_}`:`Est. completion: ${M.toLocaleDateString([],{month:"short",day:"numeric"})} at ${_}`},I=s===1,$=I?"Delete record":`Delete ${s} records`,D=I?`Are you sure you want to delete this ${t||"record"}?`:`Are you sure you want to delete ${s} ${t||"records"}?`,F=()=>{switch(a){case"confirm":return j.jsxs(j.Fragment,{children:[j.jsx(yd,{entityLogicalName:n,entityDisplayName:t,scope:{kind:"records",count:s},onConfirmationChange:y}),j.jsxs("div",{className:l.warningRow,children:[j.jsx(hh,{}),j.jsx(st,{weight:"semibold",children:"This action cannot be undone."})]}),j.jsx(st,{children:D}),I&&r&&j.jsx("div",{className:l.recordInfo,children:j.jsx(st,{weight:"semibold",children:r})})]});case"deleting":return j.jsxs("div",{className:l.progressSection,children:[j.jsx(Ar,{intent:"info",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Deleting records..."}),p&&j.jsxs(j.Fragment,{children:["Processing batch ",p.batchesCompleted," of ",p.totalBatches]})]})}),p&&j.jsxs(j.Fragment,{children:[j.jsx(hd,{value:p.completed/p.total,max:1}),j.jsxs("div",{className:l.progressStats,children:[j.jsxs(st,{size:200,children:[p.completed," of ",p.total," (",p.succeeded," succeeded,"," ",p.failed," failed)"]}),p.estimatedSecondsRemaining!==void 0&&p.estimatedSecondsRemaining>0&&j.jsx(st,{className:l.eta,children:N(p.estimatedSecondsRemaining)})]})]}),!p&&j.jsxs("div",{style:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},children:[j.jsx(hn,{size:"small"}),j.jsx(st,{children:"Deleting..."})]})]});case"success":return j.jsx(j.Fragment,{children:j.jsxs("div",{className:l.successRow,children:[j.jsx(cd,{}),j.jsx(st,{weight:"semibold",children:f?`Successfully deleted ${f.succeeded} record(s)!`:"Record(s) deleted successfully!"})]})});case"partial":return j.jsxs(j.Fragment,{children:[j.jsx(Ar,{intent:"warning",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Partial success"}),f&&j.jsxs(j.Fragment,{children:[f.succeeded," of ",f.succeeded+f.failed," records deleted.",f.failed," failed."]})]})}),f&&f.errors.length>0&&j.jsxs("div",{className:l.resultSummary,children:[j.jsx(st,{weight:"semibold",size:200,children:"Errors:"}),f.errors.slice(0,5).map((G,U)=>j.jsx(st,{size:200,className:l.errorMessage,children:G},U)),f.errors.length>5&&j.jsxs(st,{size:200,className:l.errorMessage,children:["...and ",f.errors.length-5," more errors"]})]})]});case"error":return j.jsxs(j.Fragment,{children:[j.jsxs("div",{className:l.warningRow,children:[j.jsx(k4,{}),j.jsx(st,{weight:"semibold",children:"Delete failed"})]}),j.jsx(st,{className:l.errorMessage,children:h}),f&&f.errors.length>0&&j.jsxs("div",{className:l.resultSummary,children:[j.jsx(st,{weight:"semibold",size:200,children:"Errors:"}),f.errors.slice(0,5).map((G,U)=>j.jsx(st,{size:200,className:l.errorMessage,children:G},U)),f.errors.length>5&&j.jsxs(st,{size:200,className:l.errorMessage,children:["...and ",f.errors.length-5," more errors"]})]})]})}},V=()=>{switch(a){case"confirm":return j.jsxs(j.Fragment,{children:[j.jsx(St,{appearance:"secondary",onClick:C,children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:w,disabled:!b,children:"Delete"})]});case"deleting":return j.jsx(St,{appearance:"secondary",disabled:!0,children:"Cancel"});case"success":case"partial":case"error":return j.jsx(St,{appearance:"primary",onClick:C,children:"Close"})}};return j.jsx(Do,{open:e,onOpenChange:(G,U)=>!U.open&&C(),children:j.jsxs(zi,{children:[j.jsx(Ri,{children:$}),j.jsx(Ai,{children:j.jsx(Ii,{className:l.content,children:F()})}),j.jsx(Po,{children:V()})]})})}const Dae=wr({messageBarBody:{minWidth:0},content:{display:"flex",flexDirection:"column",gap:le.spacingVerticalM},warningRow:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,color:le.colorPaletteRedForeground1},dangerWarning:{backgroundColor:le.colorPaletteRedBackground1,padding:le.spacingVerticalM,borderRadius:le.borderRadiusMedium,border:`1px solid ${le.colorPaletteRedBorder1}`},successRow:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,color:le.colorPaletteGreenForeground1},infoBox:{backgroundColor:le.colorNeutralBackground3,padding:le.spacingVerticalM,borderRadius:le.borderRadiusMedium},jobUrlRow:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,marginTop:le.spacingVerticalS},errorMessage:{color:le.colorPaletteRedForeground1,marginTop:le.spacingVerticalS},confirmCheckbox:{marginTop:le.spacingVerticalS}});function Pae({open:e,recordCount:r,entityDisplayName:t,entityLogicalName:n,isAllRecords:s=!1,totalViewRecords:o,moreRecords:i,onClose:c,onConfirm:l}){const a=Dae(),[u,h]=A.useState("confirm"),[d,f]=A.useState(`Bulk Delete ${t||"Records"} - ${new Date().toLocaleString()}`),[m,p]=A.useState(null),[g,b]=A.useState(null),[y,w]=A.useState(!1),[C,N]=A.useState(!1),[I,$]=A.useState(!1),D=A.useCallback(async()=>{h("submitting"),p(null);try{const M=await l(d);b(M),h("success")}catch(M){p(zn(M,"Failed to submit bulk delete job")),h("error")}},[l,d]),F=A.useCallback(()=>{u!=="submitting"&&(h("confirm"),p(null),b(null),w(!1),N(!1),c())},[u,c]),V=A.useCallback(async()=>{g?.jobUrl&&await ws(g.jobUrl)&&(w(!0),setTimeout(()=>w(!1),2e3))},[g]),G=A.useCallback(()=>{g?.jobUrl&&j8(g.jobUrl)},[g]),U=()=>{switch(u){case"confirm":return j.jsxs(j.Fragment,{children:[j.jsx(yd,{entityLogicalName:n,entityDisplayName:t,scope:s?{kind:"allMatching",loadedCount:o,moreRecords:i}:{kind:"records",count:r},onConfirmationChange:$}),s?j.jsxs(j.Fragment,{children:[j.jsx(Ar,{intent:"error",children:j.jsxs(Rr,{className:a.messageBarBody,children:[j.jsx(Hr,{children:"Danger zone"}),"This will delete ALL records matching your current FetchXML query!"]})}),j.jsxs("div",{className:a.dangerWarning,children:[j.jsxs("div",{className:a.warningRow,children:[j.jsx(FR,{}),j.jsx(st,{weight:"semibold",children:"You have not selected any records. This will delete ALL records returned from the view."})]}),j.jsx(st,{style:{marginTop:le.spacingVerticalS,display:"block"},children:"This is a destructive operation that cannot be undone. The bulk delete job will delete every record that matches your FetchXML query."})]}),j.jsx(ho,{className:a.confirmCheckbox,checked:C,onChange:(M,B)=>N(B.checked===!0),label:"I understand that this will delete ALL records from the view"})]}):j.jsxs(j.Fragment,{children:[j.jsxs("div",{className:a.warningRow,children:[j.jsx(hh,{}),j.jsx(st,{weight:"semibold",children:"This action cannot be undone."})]}),j.jsxs(st,{children:["You are about to delete ",r," ",t||"records",". This will create a background job to process the deletion."]})]}),j.jsx(Eo,{label:"Job name",required:!0,children:j.jsx(_n,{value:d,onChange:(M,B)=>f(B.value),placeholder:"Enter a name for the bulk delete job"})}),j.jsx(st,{size:200,style:{color:le.colorNeutralForeground3},children:"You can track the progress of the job in the System Jobs area."})]});case"submitting":return j.jsx("div",{className:a.infoBox,children:j.jsxs("div",{style:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},children:[j.jsx(hn,{size:"small"}),j.jsx(st,{children:"Submitting bulk delete job..."})]})});case"success":return j.jsxs(j.Fragment,{children:[j.jsxs("div",{className:a.successRow,children:[j.jsx(cd,{}),j.jsx(st,{weight:"semibold",children:"Bulk delete job submitted successfully!"})]}),j.jsxs("div",{className:a.infoBox,children:[j.jsx(st,{children:"The bulk delete job has been submitted and will run in the background. You can track its progress using the link below."}),g?.jobUrl&&j.jsxs("div",{className:a.jobUrlRow,children:[j.jsx(dd,{onClick:G,children:"Open job status"}),j.jsx(St,{appearance:"subtle",size:"small",icon:j.jsx(wc,{}),onClick:V,children:y?"Copied!":"Copy URL"})]}),g?.asyncOperationId&&j.jsxs(st,{size:200,style:{marginTop:le.spacingVerticalS,color:le.colorNeutralForeground3},children:["Job ID: ",g.asyncOperationId]})]})]});case"error":return j.jsxs(j.Fragment,{children:[j.jsxs("div",{className:a.warningRow,children:[j.jsx(hh,{}),j.jsx(st,{weight:"semibold",children:"Failed to submit bulk delete job"})]}),j.jsx(st,{className:a.errorMessage,children:m}),j.jsx(st,{size:200,children:"Please check your permissions and try again. You need the prvBulkDelete privilege to submit bulk delete jobs."})]})}},E=()=>{switch(u){case"confirm":return j.jsxs(j.Fragment,{children:[j.jsx(St,{appearance:"secondary",onClick:F,children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:D,disabled:!d.trim()||s&&!C||!I,children:"Submit bulk delete"})]});case"submitting":return j.jsx(St,{appearance:"secondary",disabled:!0,children:"Cancel"});case"success":case"error":return j.jsx(St,{appearance:"primary",onClick:F,children:"Close"})}};return j.jsx(Do,{open:e,onOpenChange:(M,B)=>!B.open&&F(),children:j.jsxs(zi,{children:[j.jsx(Ri,{children:s?`Bulk delete all matching ${t||"records"}`:`Bulk delete ${r} records`}),j.jsx(Ai,{children:j.jsx(Ii,{className:a.content,children:U()})}),j.jsx(Po,{children:E()})]})})}const Oae=wr({content:{display:"flex",flexDirection:"column",gap:le.spacingVerticalM},workflowList:{maxHeight:"300px",overflowY:"auto",border:`1px solid ${le.colorNeutralStroke1}`,borderRadius:le.borderRadiusMedium,padding:le.spacingVerticalS},workflowOption:{display:"flex",flexDirection:"column",padding:le.spacingVerticalXS},workflowDescription:{marginLeft:"28px",color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200},progressSection:{display:"flex",flexDirection:"column",gap:le.spacingVerticalS},progressStats:{display:"flex",justifyContent:"space-between",alignItems:"center"},eta:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200},resultSection:{display:"flex",flexDirection:"column",gap:le.spacingVerticalS},successRow:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,color:le.colorPaletteGreenForeground1},errorRow:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,color:le.colorPaletteRedForeground1},emptyState:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:le.spacingVerticalXXL,color:le.colorNeutralForeground3},loadingState:{display:"flex",alignItems:"center",justifyContent:"center",padding:le.spacingVerticalXL,gap:le.spacingHorizontalS}});function Fae({open:e,recordCount:r,entityDisplayName:t,entityLogicalName:n,preSelectedWorkflow:s,onClose:o,onFetchWorkflows:i,onExecute:c}){const l=Oae(),[a,u]=A.useState("loading"),[h,d]=A.useState([]),[f,m]=A.useState(null),[p,g]=A.useState(null),[b,y]=A.useState(null),[w,C]=A.useState(!1),[N,I]=A.useState(null);A.useEffect(()=>{e&&(u("loading"),m(null),g(null),I(null),y(null),i().then(E=>{if(d(E),u("select"),s){const M=E.find(B=>B.workflowid===s.workflowid);M&&m(M.workflowid)}else E.length===1&&m(E[0].workflowid)}).catch(E=>{g(zn(E,"Failed to load workflows")),u("error")}))},[e,i,s]);const $=A.useCallback(async()=>{const E=h.find(M=>M.workflowid===f);if(E){u("executing"),y(null),g(null);try{const M=await c(E,B=>{y(B)});I(M),u("complete")}catch(M){g(zn(M,"Failed to execute workflow")),u("error")}}},[h,f,c]),D=A.useCallback(()=>{a!=="executing"&&o()},[a,o]),F=h.find(E=>E.workflowid===f),V=E=>{if(E<60)return`~${E}s remaining`;const M=Math.floor(E/60),B=Math.floor(M/60);if(M<60){const z=E%60;return`~${M}m ${z}s remaining`}if(B<12){const z=M%60;return`~${B}h ${z}m remaining`}const k=new Date(Date.now()+E*1e3),_=k.toDateString()===new Date().toDateString(),S=k.toDateString()===new Date(Date.now()+864e5).toDateString(),T=k.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return _?`Est. completion: today at ${T}`:S?`Est. completion: tomorrow at ${T}`:`Est. completion: ${k.toLocaleDateString([],{month:"short",day:"numeric"})} at ${T}`},G=()=>{switch(a){case"loading":return j.jsxs("div",{className:l.loadingState,children:[j.jsx(hn,{size:"small"}),j.jsx(st,{children:"Loading available workflows..."})]});case"select":return h.length===0?j.jsxs("div",{className:l.emptyState,children:[j.jsx(st,{weight:"semibold",children:"No workflows available"}),j.jsxs(st,{size:200,children:["There are no on-demand workflows configured for ",t||"this entity","."]})]}):j.jsxs(j.Fragment,{children:[j.jsx(yd,{entityLogicalName:n,entityDisplayName:t,scope:{kind:"records",count:r},onConfirmationChange:C}),j.jsxs(st,{children:["Select a workflow to run on ",r," ",r===1?"record":"records",":"]}),j.jsx("div",{className:l.workflowList,children:j.jsx(ta,{value:f||"",onChange:(E,M)=>m(M.value),children:h.map(E=>j.jsxs("div",{className:l.workflowOption,children:[j.jsx(Yr,{value:E.workflowid,label:E.name}),E.description&&j.jsx(st,{className:l.workflowDescription,children:E.description})]},E.workflowid))})})]});case"executing":return j.jsxs("div",{className:l.progressSection,children:[j.jsx(Ar,{intent:"info",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Running workflow..."}),"Executing ",j.jsx("strong",{children:F?.name})," on ",r," records",b&&` (batch ${b.batchesCompleted} of ${b.totalBatches})`]})}),b?j.jsxs(j.Fragment,{children:[j.jsx(hd,{value:b.completed,max:b.total,thickness:"large"}),j.jsxs("div",{className:l.progressStats,children:[j.jsxs(st,{size:200,children:[b.completed," of ",b.total," completed (",b.succeeded," ","succeeded, ",b.failed," failed)"]}),b.estimatedSecondsRemaining!==void 0&&b.estimatedSecondsRemaining>0&&j.jsx(st,{className:l.eta,children:V(b.estimatedSecondsRemaining)})]})]}):j.jsxs("div",{style:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},children:[j.jsx(hn,{size:"small"}),j.jsx(st,{children:"Starting workflow execution..."})]})]});case"complete":return j.jsxs("div",{className:l.resultSection,children:[N&&N.succeeded>0&&j.jsxs("div",{className:l.successRow,children:[j.jsx(cd,{}),j.jsxs(st,{weight:"semibold",children:[N.succeeded," record",N.succeeded!==1?"s":""," processed successfully"]})]}),N&&N.failed>0&&j.jsxs(j.Fragment,{children:[j.jsxs("div",{className:l.errorRow,children:[j.jsx(hh,{}),j.jsxs(st,{weight:"semibold",children:[N.failed," record",N.failed!==1?"s":""," failed"]})]}),N.errors.length>0&&j.jsx(Ar,{intent:"error",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Errors:"}),N.errors.slice(0,5).map((E,M)=>j.jsx(st,{size:200,block:!0,children:E},M)),N.errors.length>5&&j.jsxs(st,{size:200,children:["...and ",N.errors.length-5," more"]})]})})]})]});case"error":return j.jsx(Ar,{intent:"error",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Error"}),p]})})}},U=()=>{switch(a){case"loading":return j.jsx(St,{appearance:"secondary",onClick:D,children:"Cancel"});case"select":return j.jsxs(j.Fragment,{children:[j.jsx(St,{appearance:"secondary",onClick:D,children:"Cancel"}),j.jsx(St,{appearance:"primary",icon:j.jsx(R0,{}),onClick:$,disabled:!f||h.length===0||!w,children:"Run workflow"})]});case"executing":return j.jsx(St,{appearance:"secondary",disabled:!0,children:"Running..."});case"complete":case"error":return j.jsx(St,{appearance:"primary",onClick:D,children:"Close"})}};return j.jsx(Do,{open:e,onOpenChange:(E,M)=>!M.open&&D(),children:j.jsxs(zi,{children:[j.jsx(Ri,{children:"Run workflow"}),j.jsx(Ai,{children:j.jsx(Ii,{className:l.content,children:G()})}),j.jsx(Po,{children:U()})]})})}const qae=wr({content:{display:"flex",flexDirection:"column",gap:le.spacingVerticalM},row:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},success:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,color:le.colorPaletteGreenForeground1},errors:{display:"flex",flexDirection:"column",gap:le.spacingVerticalXS},errorText:{color:le.colorPaletteRedForeground1}}),bk=e=>`${e.statecode}:${e.statuscode}`;function Lae({open:e,action:r,recordIds:t,entityLogicalName:n,entityDisplayName:s,primaryIdAttribute:o,onClose:i,onExecute:c}){const l=qae(),[a,u]=A.useState("loading"),[h,d]=A.useState(null),[f,m]=A.useState(null),[p,g]=A.useState(null),[b,y]=A.useState(null),[w,C]=A.useState(null),[N,I]=A.useState(!1),$=A.useRef(o);$.current=o;const D=r==="activate"?"Activate":"Deactivate",F=t.length;A.useEffect(()=>{if(!e||!n)return;let _=!0;return u("loading"),d(null),m(null),g(null),y(null),C(null),(async()=>{const S=await f_(n);if(!S)return{kind:"none",reason:"This entity has no Status (statecode) column."};const T=$.current,z=S.enforceTransitions&&T?await mJ(n,T,t):void 0;return QQ(S,r,z,n)})().then(S=>{_&&(d(S),S.kind==="simple"&&m(S.target),S.kind==="choose"&&m(S.defaultTarget),u("confirm"))}).catch(S=>{_&&(g(zn(S,"Couldn't read the entity's status options")),u("error"))}),()=>{_=!1}},[e,n,t,r]);const V=A.useMemo(()=>{if(h?.kind!=="choose"||!f)return;const _=h.groups.find(T=>T.statecode===f.statecode),S=_?.choices.find(T=>T.statuscode===f.statuscode);return _&&S?{group:_,choice:S}:void 0},[h,f]),G=A.useCallback(async()=>{if(f){u("running"),y(null);try{const _=await c(f,y);C(_),_.succeeded===0&&_.failed>0?(g(`All ${_.failed} records failed.`),u("error")):u("done")}catch(_){g(zn(_,`${D} failed`)),u("error")}}},[f,c,D]),U=A.useCallback(()=>{a!=="running"&&i()},[a,i]),E=f?K8(n,f.statecode):void 0,M=()=>w&&w.errors.length>0?j.jsxs("div",{className:l.errors,children:[w.errors.slice(0,5).map((_,S)=>j.jsx(st,{size:200,className:l.errorText,children:_},S)),w.errors.length>5&&j.jsxs(st,{size:200,className:l.errorText,children:["...and ",w.errors.length-5," more"]})]}):null,B=()=>{switch(a){case"loading":return j.jsxs("div",{className:l.row,children:[j.jsx(hn,{size:"small"}),j.jsx(st,{children:"Reading the status options..."})]});case"confirm":return j.jsxs(j.Fragment,{children:[j.jsx(yd,{entityLogicalName:n,entityDisplayName:s,scope:{kind:"records",count:F},onConfirmationChange:I}),h?.kind==="none"&&j.jsx(Ar,{intent:"warning",layout:"multiline",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Nothing to change"}),h.reason]})}),h?.kind==="simple"&&j.jsxs(st,{children:["Sets Status to ",j.jsx("strong",{children:h.stateLabel})," and Status Reason to"," ",j.jsx("strong",{children:h.statusLabel}),"."]}),h?.kind==="choose"&&j.jsxs(j.Fragment,{children:[h.note&&j.jsx(Ar,{intent:"info",layout:"multiline",children:j.jsx(Rr,{children:h.note})}),j.jsx(Eo,{label:"Status reason",hint:"Grouped by Status. The default for each Status is marked.",children:j.jsx(po,{value:V?`${V.group.label}: ${V.choice.label}`:"",selectedOptions:f?[bk(f)]:[],onOptionSelect:(_,S)=>{const[T,z]=(S.optionValue??"").split(":").map(Number);Number.isFinite(T)&&Number.isFinite(z)&&m({statecode:T,statuscode:z})},children:h.groups.map(_=>j.jsx(ja,{label:_.label,children:_.choices.map(S=>j.jsx(Jt,{value:bk({statecode:_.statecode,statuscode:S.statuscode}),text:`${_.label}: ${S.label}`,children:S.isDefault?`${S.label} (default)`:S.label},S.statuscode))},_.statecode))})})]}),E&&j.jsx(Ar,{intent:"warning",layout:"multiline",children:j.jsx(Rr,{children:E})})]});case"running":return j.jsxs(j.Fragment,{children:[j.jsx(Ar,{intent:"info",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Updating records..."}),b&&`Batch ${b.batchesCompleted} of ${b.totalBatches}`]})}),b?j.jsxs(j.Fragment,{children:[j.jsx(hd,{value:b.completed/b.total,max:1}),j.jsxs(st,{size:200,children:[b.completed," of ",b.total," (",b.succeeded," succeeded, ",b.failed," failed)"]})]}):j.jsxs("div",{className:l.row,children:[j.jsx(hn,{size:"small"}),j.jsx(st,{children:"Updating..."})]})]});case"done":return w&&w.failed>0?j.jsxs(j.Fragment,{children:[j.jsx(Ar,{intent:"warning",layout:"multiline",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Partly done"}),w.succeeded," of ",w.succeeded+w.failed," records updated. ",w.failed," failed."]})}),M()]}):j.jsxs("div",{className:l.success,children:[j.jsx(cd,{}),j.jsx(st,{weight:"semibold",children:w?.succeeded===1?"1 record updated.":`${w?.succeeded??0} records updated.`})]});case"error":return j.jsxs(j.Fragment,{children:[j.jsx(Ar,{intent:"error",layout:"multiline",children:j.jsxs(Rr,{children:[j.jsxs(Hr,{children:[D," failed"]}),p]})}),M()]})}},k=()=>{switch(a){case"loading":case"confirm":return j.jsxs(j.Fragment,{children:[j.jsx(St,{appearance:"secondary",onClick:U,children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:G,disabled:a!=="confirm"||!f||h?.kind==="none"||!N,children:D})]});case"running":return j.jsx(St,{appearance:"secondary",disabled:!0,children:"Cancel"});case"done":case"error":return j.jsx(St,{appearance:"primary",onClick:U,children:"Close"})}};return j.jsx(Do,{open:e,onOpenChange:(_,S)=>!S.open&&U(),children:j.jsx(zi,{children:j.jsxs(Ai,{children:[j.jsx(Ri,{children:`${D} ${F===1?"1 record":`${F} records`}`}),j.jsx(Ii,{className:l.content,children:B()}),j.jsx(Po,{children:k()})]})})})}function Uf(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var p0={exports:{}};var vk;function $ae(){return vk||(vk=1,(function(e,r){(function(t){e.exports=t()})((function(){return(function t(n,s,o){function i(a,u){if(!s[a]){if(!n[a]){var h=typeof Uf=="function"&&Uf;if(!u&&h)return h(a,!0);if(c)return c(a,!0);var d=new Error("Cannot find module '"+a+"'");throw d.code="MODULE_NOT_FOUND",d}var f=s[a]={exports:{}};n[a][0].call(f.exports,(function(m){return i(n[a][1][m]||m)}),f,f.exports,t,n,s,o)}return s[a].exports}for(var c=typeof Uf=="function"&&Uf,l=0;l<o.length;l++)i(o[l]);return i})({1:[function(t,n,s){const o=t("fs"),i=t("fast-csv"),c=t("dayjs/plugin/customParseFormat"),l=t("dayjs/plugin/utc"),a=t("dayjs").extend(c).extend(l),u=t("../utils/stream-buf"),{fs:{exists:h}}=t("../utils/utils"),d={true:!0,false:!1,"#N/A":{error:"#N/A"},"#REF!":{error:"#REF!"},"#NAME?":{error:"#NAME?"},"#DIV/0!":{error:"#DIV/0!"},"#NULL!":{error:"#NULL!"},"#VALUE!":{error:"#VALUE!"},"#NUM!":{error:"#NUM!"}};n.exports=class{constructor(f){this.workbook=f,this.worksheet=null}async readFile(f,m){if(m=m||{},!await h(f))throw new Error("File not found: "+f);const p=o.createReadStream(f),g=await this.read(p,m);return p.close(),g}read(f,m){return m=m||{},new Promise((p,g)=>{const b=this.workbook.addWorksheet(m.sheetName),y=m.dateFormats||["YYYY-MM-DD[T]HH:mm:ssZ","YYYY-MM-DD[T]HH:mm:ss","MM-DD-YYYY","YYYY-MM-DD"],w=m.map||function(N){if(N==="")return null;const I=Number(N);if(!Number.isNaN(I)&&I!==1/0)return I;const $=y.reduce((F,V)=>{if(F)return F;const G=a(N,V,!0);return G.isValid()?G:null},null);if($)return new Date($.valueOf());const D=d[N];return D!==void 0?D:N},C=i.parse(m.parserOptions).on("data",N=>{b.addRow(N.map(w))}).on("end",()=>{C.emit("worksheet",b)});C.on("worksheet",p).on("error",g),f.pipe(C)})}createInputStream(){throw new Error("`CSV#createInputStream` is deprecated. You should use `CSV#read` instead. This method will be removed in version 5.0. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md")}write(f,m){return new Promise((p,g)=>{m=m||{};const b=this.workbook.getWorksheet(m.sheetName||m.sheetId),y=i.format(m.formatterOptions);f.on("finish",()=>{p()}),y.on("error",g),y.pipe(f);const{dateFormat:w,dateUTC:C}=m,N=m.map||(D=>{if(D){if(D.text||D.hyperlink)return D.hyperlink||D.text||"";if(D.formula||D.result)return D.result||"";if(D instanceof Date)return w?C?a.utc(D).format(w):a(D).format(w):C?a.utc(D).format():a(D).format();if(D.error)return D.error;if(typeof D=="object")return JSON.stringify(D)}return D}),I=m.includeEmptyRows===void 0||m.includeEmptyRows;let $=1;b&&b.eachRow((D,F)=>{if(I)for(;$++<F-1;)y.write([]);const{values:V}=D;V.shift(),y.write(V.map(N)),$=F}),y.end()})}writeFile(f,m){const p={encoding:(m=m||{}).encoding||"utf8"},g=o.createWriteStream(f,p);return this.write(g,m)}async writeBuffer(f){const m=new u;return await this.write(m,f),m.read()}}},{"../utils/stream-buf":24,"../utils/utils":27,dayjs:391,"dayjs/plugin/customParseFormat":392,"dayjs/plugin/utc":393,"fast-csv":424,fs:216}],2:[function(t,n,s){const o=t("../utils/col-cache");class i{constructor(l,a){let u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(this.worksheet=l,a)if(typeof a=="string"){const h=o.decodeAddress(a);this.nativeCol=h.col+u,this.nativeColOff=0,this.nativeRow=h.row+u,this.nativeRowOff=0}else a.nativeCol!==void 0?(this.nativeCol=a.nativeCol||0,this.nativeColOff=a.nativeColOff||0,this.nativeRow=a.nativeRow||0,this.nativeRowOff=a.nativeRowOff||0):a.col!==void 0?(this.col=a.col+u,this.row=a.row+u):(this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0);else this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0}static asInstance(l){return l instanceof i||l==null?l:new i(l)}get col(){return this.nativeCol+Math.min(this.colWidth-1,this.nativeColOff)/this.colWidth}set col(l){this.nativeCol=Math.floor(l),this.nativeColOff=Math.floor((l-this.nativeCol)*this.colWidth)}get row(){return this.nativeRow+Math.min(this.rowHeight-1,this.nativeRowOff)/this.rowHeight}set row(l){this.nativeRow=Math.floor(l),this.nativeRowOff=Math.floor((l-this.nativeRow)*this.rowHeight)}get colWidth(){return this.worksheet&&this.worksheet.getColumn(this.nativeCol+1)&&this.worksheet.getColumn(this.nativeCol+1).isCustomWidth?Math.floor(1e4*this.worksheet.getColumn(this.nativeCol+1).width):64e4}get rowHeight(){return this.worksheet&&this.worksheet.getRow(this.nativeRow+1)&&this.worksheet.getRow(this.nativeRow+1).height?Math.floor(1e4*this.worksheet.getRow(this.nativeRow+1).height):18e4}get model(){return{nativeCol:this.nativeCol,nativeColOff:this.nativeColOff,nativeRow:this.nativeRow,nativeRowOff:this.nativeRowOff}}set model(l){this.nativeCol=l.nativeCol,this.nativeColOff=l.nativeColOff,this.nativeRow=l.nativeRow,this.nativeRowOff=l.nativeRowOff}}n.exports=i},{"../utils/col-cache":19}],3:[function(t,n,s){const o=t("../utils/col-cache"),i=t("../utils/under-dash"),c=t("./enums"),{slideFormula:l}=t("../utils/shared-formula"),a=t("./note");class u{constructor(f,m,p){if(!f||!m)throw new Error("A Cell needs a Row");this._row=f,this._column=m,o.validateAddress(p),this._address=p,this._value=h.create(u.Types.Null,this),this.style=this._mergeStyle(f.style,m.style,{}),this._mergeCount=0}get worksheet(){return this._row.worksheet}get workbook(){return this._row.worksheet.workbook}destroy(){delete this.style,delete this._value,delete this._row,delete this._column,delete this._address}get numFmt(){return this.style.numFmt}set numFmt(f){this.style.numFmt=f}get font(){return this.style.font}set font(f){this.style.font=f}get alignment(){return this.style.alignment}set alignment(f){this.style.alignment=f}get border(){return this.style.border}set border(f){this.style.border=f}get fill(){return this.style.fill}set fill(f){this.style.fill=f}get protection(){return this.style.protection}set protection(f){this.style.protection=f}_mergeStyle(f,m,p){const g=f&&f.numFmt||m&&m.numFmt;g&&(p.numFmt=g);const b=f&&f.font||m&&m.font;b&&(p.font=b);const y=f&&f.alignment||m&&m.alignment;y&&(p.alignment=y);const w=f&&f.border||m&&m.border;w&&(p.border=w);const C=f&&f.fill||m&&m.fill;C&&(p.fill=C);const N=f&&f.protection||m&&m.protection;return N&&(p.protection=N),p}get address(){return this._address}get row(){return this._row.number}get col(){return this._column.number}get $col$row(){return`$${this._column.letter}$${this.row}`}get type(){return this._value.type}get effectiveType(){return this._value.effectiveType}toCsvString(){return this._value.toCsvString()}addMergeRef(){this._mergeCount++}releaseMergeRef(){this._mergeCount--}get isMerged(){return this._mergeCount>0||this.type===u.Types.Merge}merge(f,m){this._value.release(),this._value=h.create(u.Types.Merge,this,f),m||(this.style=f.style)}unmerge(){this.type===u.Types.Merge&&(this._value.release(),this._value=h.create(u.Types.Null,this),this.style=this._mergeStyle(this._row.style,this._column.style,{}))}isMergedTo(f){return this._value.type===u.Types.Merge&&this._value.isMergedTo(f)}get master(){return this.type===u.Types.Merge?this._value.master:this}get isHyperlink(){return this._value.type===u.Types.Hyperlink}get hyperlink(){return this._value.hyperlink}get value(){return this._value.value}set value(f){this.type!==u.Types.Merge?(this._value.release(),this._value=h.create(h.getType(f),this,f)):this._value.master.value=f}get note(){return this._comment&&this._comment.note}set note(f){this._comment=new a(f)}get text(){return this._value.toString()}get html(){return i.escapeHtml(this.text)}toString(){return this.text}_upgradeToHyperlink(f){this.type===u.Types.String&&(this._value=h.create(u.Types.Hyperlink,this,{text:this._value.value,hyperlink:f}))}get formula(){return this._value.formula}get result(){return this._value.result}get formulaType(){return this._value.formulaType}get fullAddress(){const{worksheet:f}=this._row;return{sheetName:f.name,address:this.address,row:this.row,col:this.col}}get name(){return this.names[0]}set name(f){this.names=[f]}get names(){return this.workbook.definedNames.getNamesEx(this.fullAddress)}set names(f){const{definedNames:m}=this.workbook;m.removeAllNames(this.fullAddress),f.forEach(p=>{m.addEx(this.fullAddress,p)})}addName(f){this.workbook.definedNames.addEx(this.fullAddress,f)}removeName(f){this.workbook.definedNames.removeEx(this.fullAddress,f)}removeAllNames(){this.workbook.definedNames.removeAllNames(this.fullAddress)}get _dataValidations(){return this.worksheet.dataValidations}get dataValidation(){return this._dataValidations.find(this.address)}set dataValidation(f){this._dataValidations.add(this.address,f)}get model(){const{model:f}=this._value;return f.style=this.style,this._comment&&(f.comment=this._comment.model),f}set model(f){this._value.release(),this._value=h.create(f.type,this),this._value.model=f,f.comment&&f.comment.type==="note"&&(this._comment=a.fromModel(f.comment)),f.style?this.style=f.style:this.style={}}}u.Types=c.ValueType;const h={getType:d=>d==null?u.Types.Null:d instanceof String||typeof d=="string"?u.Types.String:typeof d=="number"?u.Types.Number:typeof d=="boolean"?u.Types.Boolean:d instanceof Date?u.Types.Date:d.text&&d.hyperlink?u.Types.Hyperlink:d.formula||d.sharedFormula?u.Types.Formula:d.richText?u.Types.RichText:d.sharedString?u.Types.SharedString:d.error?u.Types.Error:u.Types.JSON,types:[{t:u.Types.Null,f:class{constructor(d){this.model={address:d.address,type:u.Types.Null}}get value(){return null}set value(d){}get type(){return u.Types.Null}get effectiveType(){return u.Types.Null}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return""}release(){}toString(){return""}}},{t:u.Types.Number,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.Number,value:f}}get value(){return this.model.value}set value(d){this.model.value=d}get type(){return u.Types.Number}get effectiveType(){return u.Types.Number}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}}},{t:u.Types.String,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.String,value:f}}get value(){return this.model.value}set value(d){this.model.value=d}get type(){return u.Types.String}get effectiveType(){return u.Types.String}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return`"${this.model.value.replace(/"/g,'""')}"`}release(){}toString(){return this.model.value}}},{t:u.Types.Date,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.Date,value:f}}get value(){return this.model.value}set value(d){this.model.value=d}get type(){return u.Types.Date}get effectiveType(){return u.Types.Date}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return this.model.value.toISOString()}release(){}toString(){return this.model.value.toString()}}},{t:u.Types.Hyperlink,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.Hyperlink,text:f?f.text:void 0,hyperlink:f?f.hyperlink:void 0},f&&f.tooltip&&(this.model.tooltip=f.tooltip)}get value(){const d={text:this.model.text,hyperlink:this.model.hyperlink};return this.model.tooltip&&(d.tooltip=this.model.tooltip),d}set value(d){this.model={text:d.text,hyperlink:d.hyperlink},d.tooltip&&(this.model.tooltip=d.tooltip)}get text(){return this.model.text}set text(d){this.model.text=d}get hyperlink(){return this.model.hyperlink}set hyperlink(d){this.model.hyperlink=d}get type(){return u.Types.Hyperlink}get effectiveType(){return u.Types.Hyperlink}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return this.model.hyperlink}release(){}toString(){return this.model.text}}},{t:u.Types.Formula,f:class{constructor(d,f){this.cell=d,this.model={address:d.address,type:u.Types.Formula,shareType:f?f.shareType:void 0,ref:f?f.ref:void 0,formula:f?f.formula:void 0,sharedFormula:f?f.sharedFormula:void 0,result:f?f.result:void 0}}_copyModel(d){const f={},m=p=>{const g=d[p];g&&(f[p]=g)};return m("formula"),m("result"),m("ref"),m("shareType"),m("sharedFormula"),f}get value(){return this._copyModel(this.model)}set value(d){this.model=this._copyModel(d)}validate(d){switch(h.getType(d)){case u.Types.Null:case u.Types.String:case u.Types.Number:case u.Types.Date:break;case u.Types.Hyperlink:case u.Types.Formula:default:throw new Error("Cannot process that type of result value")}}get dependencies(){return{ranges:this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g),cells:this.formula.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g,"").match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g)}}get formula(){return this.model.formula||this._getTranslatedFormula()}set formula(d){this.model.formula=d}get formulaType(){return this.model.formula?c.FormulaType.Master:this.model.sharedFormula?c.FormulaType.Shared:c.FormulaType.None}get result(){return this.model.result}set result(d){this.model.result=d}get type(){return u.Types.Formula}get effectiveType(){const d=this.model.result;return d==null?c.ValueType.Null:d instanceof String||typeof d=="string"?c.ValueType.String:typeof d=="number"?c.ValueType.Number:d instanceof Date?c.ValueType.Date:d.text&&d.hyperlink?c.ValueType.Hyperlink:d.formula?c.ValueType.Formula:c.ValueType.Null}get address(){return this.model.address}set address(d){this.model.address=d}_getTranslatedFormula(){if(!this._translatedFormula&&this.model.sharedFormula){const{worksheet:d}=this.cell,f=d.findCell(this.model.sharedFormula);this._translatedFormula=f&&l(f.formula,f.address,this.model.address)}return this._translatedFormula}toCsvString(){return""+(this.model.result||"")}release(){}toString(){return this.model.result?this.model.result.toString():""}}},{t:u.Types.Merge,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.Merge,master:f?f.address:void 0},this._master=f,f&&f.addMergeRef()}get value(){return this._master.value}set value(d){d instanceof u?(this._master&&this._master.releaseMergeRef(),d.addMergeRef(),this._master=d):this._master.value=d}isMergedTo(d){return d===this._master}get master(){return this._master}get type(){return u.Types.Merge}get effectiveType(){return this._master.effectiveType}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return""}release(){this._master.releaseMergeRef()}toString(){return this.value.toString()}}},{t:u.Types.JSON,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.String,value:JSON.stringify(f),rawValue:f}}get value(){return this.model.rawValue}set value(d){this.model.rawValue=d,this.model.value=JSON.stringify(d)}get type(){return u.Types.String}get effectiveType(){return u.Types.String}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return this.model.value}release(){}toString(){return this.model.value}}},{t:u.Types.SharedString,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.SharedString,value:f}}get value(){return this.model.value}set value(d){this.model.value=d}get type(){return u.Types.SharedString}get effectiveType(){return u.Types.SharedString}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}}},{t:u.Types.RichText,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.String,value:f}}get value(){return this.model.value}set value(d){this.model.value=d}toString(){return this.model.value.richText.map(d=>d.text).join("")}get type(){return u.Types.RichText}get effectiveType(){return u.Types.RichText}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return`"${this.text.replace(/"/g,'""')}"`}release(){}}},{t:u.Types.Boolean,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.Boolean,value:f}}get value(){return this.model.value}set value(d){this.model.value=d}get type(){return u.Types.Boolean}get effectiveType(){return u.Types.Boolean}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return this.model.value?1:0}release(){}toString(){return this.model.value.toString()}}},{t:u.Types.Error,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.Error,value:f}}get value(){return this.model.value}set value(d){this.model.value=d}get type(){return u.Types.Error}get effectiveType(){return u.Types.Error}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return this.toString()}release(){}toString(){return this.model.value.error.toString()}}}].reduce((d,f)=>(d[f.t]=f.f,d),[]),create(d,f,m){const p=this.types[d];if(!p)throw new Error("Could not create Value of type "+d);return new p(f,m)}};n.exports=u},{"../utils/col-cache":19,"../utils/shared-formula":23,"../utils/under-dash":26,"./enums":7,"./note":9}],4:[function(t,n,s){const o=t("../utils/under-dash"),i=t("./enums"),c=t("../utils/col-cache");class l{constructor(u,h,d){this._worksheet=u,this._number=h,d!==!1&&(this.defn=d)}get number(){return this._number}get worksheet(){return this._worksheet}get letter(){return c.n2l(this._number)}get isCustomWidth(){return this.width!==void 0&&this.width!==9}get defn(){return{header:this._header,key:this.key,width:this.width,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel}}set defn(u){u?(this.key=u.key,this.width=u.width!==void 0?u.width:9,this.outlineLevel=u.outlineLevel,u.style?this.style=u.style:this.style={},this.header=u.header,this._hidden=!!u.hidden):(delete this._header,delete this._key,delete this.width,this.style={},this.outlineLevel=0)}get headers(){return this._header&&this._header instanceof Array?this._header:[this._header]}get header(){return this._header}set header(u){u!==void 0?(this._header=u,this.headers.forEach((h,d)=>{this._worksheet.getCell(d+1,this.number).value=h})):this._header=void 0}get key(){return this._key}set key(u){(this._key&&this._worksheet.getColumnKey(this._key))===this&&this._worksheet.deleteColumnKey(this._key),this._key=u,u&&this._worksheet.setColumnKey(this._key,this)}get hidden(){return!!this._hidden}set hidden(u){this._hidden=u}get outlineLevel(){return this._outlineLevel||0}set outlineLevel(u){this._outlineLevel=u}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelCol)}toString(){return JSON.stringify({key:this.key,width:this.width,headers:this.headers.length?this.headers:void 0})}equivalentTo(u){return this.width===u.width&&this.hidden===u.hidden&&this.outlineLevel===u.outlineLevel&&o.isEqual(this.style,u.style)}get isDefault(){if(this.isCustomWidth||this.hidden||this.outlineLevel)return!1;const u=this.style;return!u||!(u.font||u.numFmt||u.alignment||u.border||u.fill||u.protection)}get headerCount(){return this.headers.length}eachCell(u,h){const d=this.number;h||(h=u,u=null),this._worksheet.eachRow(u,(f,m)=>{h(f.getCell(d),m)})}get values(){const u=[];return this.eachCell((h,d)=>{h&&h.type!==i.ValueType.Null&&(u[d]=h.value)}),u}set values(u){if(!u)return;const h=this.number;let d=0;u.hasOwnProperty("0")&&(d=1),u.forEach((f,m)=>{this._worksheet.getCell(m+d,h).value=f})}_applyStyle(u,h){return this.style[u]=h,this.eachCell(d=>{d[u]=h}),h}get numFmt(){return this.style.numFmt}set numFmt(u){this._applyStyle("numFmt",u)}get font(){return this.style.font}set font(u){this._applyStyle("font",u)}get alignment(){return this.style.alignment}set alignment(u){this._applyStyle("alignment",u)}get protection(){return this.style.protection}set protection(u){this._applyStyle("protection",u)}get border(){return this.style.border}set border(u){this._applyStyle("border",u)}get fill(){return this.style.fill}set fill(u){this._applyStyle("fill",u)}static toModel(u){const h=[];let d=null;return u&&u.forEach((f,m)=>{f.isDefault?d&&(d=null):d&&f.equivalentTo(d)?d.max=m+1:(d={min:m+1,max:m+1,width:f.width!==void 0?f.width:9,style:f.style,isCustomWidth:f.isCustomWidth,hidden:f.hidden,outlineLevel:f.outlineLevel,collapsed:f.collapsed},h.push(d))}),h.length?h:void 0}static fromModel(u,h){const d=[];let f=1,m=0;for(h=(h=h||[]).sort((function(p,g){return p.min-g.min}));m<h.length;){const p=h[m++];for(;f<p.min;)d.push(new l(u,f++));for(;f<=p.max;)d.push(new l(u,f++,p))}return d.length?d:null}}n.exports=l},{"../utils/col-cache":19,"../utils/under-dash":26,"./enums":7}],5:[function(t,n,s){n.exports=class{constructor(o){this.model=o||{}}add(o,i){return this.model[o]=i}find(o){return this.model[o]}remove(o){this.model[o]=void 0}}},{}],6:[function(t,n,s){const o=t("../utils/under-dash"),i=t("../utils/col-cache"),c=t("../utils/cell-matrix"),l=t("./range"),a=/[$](\w+)[$](\d+)(:[$](\w+)[$](\d+))?/;n.exports=class{constructor(){this.matrixMap={}}getMatrix(u){return this.matrixMap[u]||(this.matrixMap[u]=new c)}add(u,h){const d=i.decodeEx(u);this.addEx(d,h)}addEx(u,h){const d=this.getMatrix(h);if(u.top)for(let f=u.left;f<=u.right;f++)for(let m=u.top;m<=u.bottom;m++){const p={sheetName:u.sheetName,address:i.n2l(f)+m,row:m,col:f};d.addCellEx(p)}else d.addCellEx(u)}remove(u,h){const d=i.decodeEx(u);this.removeEx(d,h)}removeEx(u,h){this.getMatrix(h).removeCellEx(u)}removeAllNames(u){o.each(this.matrixMap,h=>{h.removeCellEx(u)})}forEach(u){o.each(this.matrixMap,(h,d)=>{h.forEach(f=>{u(d,f)})})}getNames(u){return this.getNamesEx(i.decodeEx(u))}getNamesEx(u){return o.map(this.matrixMap,(h,d)=>h.findCellEx(u)&&d).filter(Boolean)}_explore(u,h){h.mark=!1;const{sheetName:d}=h,f=new l(h.row,h.col,h.row,h.col,d);let m,p;function g(y,w){const C=u.findCellAt(d,y,h.col);return!(!C||!C.mark)&&(f[w]=y,C.mark=!1,!0)}for(p=h.row-1;g(p,"top");p--);for(p=h.row+1;g(p,"bottom");p++);function b(y,w){const C=[];for(p=f.top;p<=f.bottom;p++){const N=u.findCellAt(d,p,y);if(!N||!N.mark)return!1;C.push(N)}f[w]=y;for(let N=0;N<C.length;N++)C[N].mark=!1;return!0}for(m=h.col-1;b(m,"left");m--);for(m=h.col+1;b(m,"right");m++);return f}getRanges(u,h){return(h=h||this.matrixMap[u])?(h.forEach(d=>{d.mark=!0}),{name:u,ranges:h.map(d=>d.mark&&this._explore(h,d)).filter(Boolean).map(d=>d.$shortRange)}):{name:u,ranges:[]}}normaliseMatrix(u,h){u.forEachInSheet(h,(d,f,m)=>{d&&(d.row===f&&d.col===m||(d.row=f,d.col=m,d.address=i.n2l(m)+f))})}spliceRows(u,h,d,f){o.each(this.matrixMap,m=>{m.spliceRows(u,h,d,f),this.normaliseMatrix(m,u)})}spliceColumns(u,h,d,f){o.each(this.matrixMap,m=>{m.spliceColumns(u,h,d,f),this.normaliseMatrix(m,u)})}get model(){return o.map(this.matrixMap,(u,h)=>this.getRanges(h,u)).filter(u=>u.ranges.length)}set model(u){const h=this.matrixMap={};u.forEach(d=>{const f=h[d.name]=new c;d.ranges.forEach(m=>{a.test(m.split("!").pop()||"")&&f.addCell(m)})})}}},{"../utils/cell-matrix":18,"../utils/col-cache":19,"../utils/under-dash":26,"./range":10}],7:[function(t,n,s){n.exports={ValueType:{Null:0,Merge:1,Number:2,String:3,Date:4,Hyperlink:5,Formula:6,SharedString:7,RichText:8,Boolean:9,Error:10},FormulaType:{None:0,Master:1,Shared:2},RelationshipType:{None:0,OfficeDocument:1,Worksheet:2,CalcChain:3,SharedStrings:4,Styles:5,Theme:6,Hyperlink:7},DocumentType:{Xlsx:1},ReadingOrder:{LeftToRight:1,RightToLeft:2},ErrorValue:{NotApplicable:"#N/A",Ref:"#REF!",Name:"#NAME?",DivZero:"#DIV/0!",Null:"#NULL!",Value:"#VALUE!",Num:"#NUM!"}}},{}],8:[function(t,n,s){const o=t("../utils/col-cache"),i=t("./anchor");n.exports=class{constructor(c,l){this.worksheet=c,this.model=l}get model(){switch(this.type){case"background":return{type:this.type,imageId:this.imageId};case"image":return{type:this.type,imageId:this.imageId,hyperlinks:this.range.hyperlinks,range:{tl:this.range.tl.model,br:this.range.br&&this.range.br.model,ext:this.range.ext,editAs:this.range.editAs}};default:throw new Error("Invalid Image Type")}}set model(c){let{type:l,imageId:a,range:u,hyperlinks:h}=c;if(this.type=l,this.imageId=a,l==="image")if(typeof u=="string"){const d=o.decode(u);this.range={tl:new i(this.worksheet,{col:d.left,row:d.top},-1),br:new i(this.worksheet,{col:d.right,row:d.bottom},0),editAs:"oneCell"}}else this.range={tl:new i(this.worksheet,u.tl,0),br:u.br&&new i(this.worksheet,u.br,0),ext:u.ext,editAs:u.editAs,hyperlinks:h||u.hyperlinks}}}},{"../utils/col-cache":19,"./anchor":2}],9:[function(t,n,s){const o=t("../utils/under-dash");class i{constructor(l){this.note=l}get model(){let l=null;return typeof this.note==="string"?l={type:"note",note:{texts:[{text:this.note}]}}:l={type:"note",note:this.note},o.deepMerge({},i.DEFAULT_CONFIGS,l)}set model(l){const{note:a}=l,{texts:u}=a;u.length===1&&Object.keys(u[0]).length===1?this.note=u[0].text:this.note=a}static fromModel(l){const a=new i;return a.model=l,a}}i.DEFAULT_CONFIGS={note:{margins:{insetmode:"auto",inset:[.13,.13,.25,.25]},protection:{locked:"True",lockText:"True"},editAs:"absolute"}},n.exports=i},{"../utils/under-dash":26}],10:[function(t,n,s){const o=t("../utils/col-cache");class i{constructor(){this.decode(arguments)}setTLBR(l,a,u,h,d){if(arguments.length<4){const f=o.decodeAddress(l),m=o.decodeAddress(a);this.model={top:Math.min(f.row,m.row),left:Math.min(f.col,m.col),bottom:Math.max(f.row,m.row),right:Math.max(f.col,m.col),sheetName:u},this.setTLBR(f.row,f.col,m.row,m.col,d)}else this.model={top:Math.min(l,u),left:Math.min(a,h),bottom:Math.max(l,u),right:Math.max(a,h),sheetName:d}}decode(l){switch(l.length){case 5:this.setTLBR(l[0],l[1],l[2],l[3],l[4]);break;case 4:this.setTLBR(l[0],l[1],l[2],l[3]);break;case 3:this.setTLBR(l[0],l[1],l[2]);break;case 2:this.setTLBR(l[0],l[1]);break;case 1:{const a=l[0];if(a instanceof i)this.model={top:a.model.top,left:a.model.left,bottom:a.model.bottom,right:a.model.right,sheetName:a.sheetName};else if(a instanceof Array)this.decode(a);else if(a.top&&a.left&&a.bottom&&a.right)this.model={top:a.top,left:a.left,bottom:a.bottom,right:a.right,sheetName:a.sheetName};else{const u=o.decodeEx(a);u.top?this.model={top:u.top,left:u.left,bottom:u.bottom,right:u.right,sheetName:u.sheetName}:this.model={top:u.row,left:u.col,bottom:u.row,right:u.col,sheetName:u.sheetName}}break}case 0:this.model={top:0,left:0,bottom:0,right:0};break;default:throw new Error("Invalid number of arguments to _getDimensions() - "+l.length)}}get top(){return this.model.top||1}set top(l){this.model.top=l}get left(){return this.model.left||1}set left(l){this.model.left=l}get bottom(){return this.model.bottom||1}set bottom(l){this.model.bottom=l}get right(){return this.model.right||1}set right(l){this.model.right=l}get sheetName(){return this.model.sheetName}set sheetName(l){this.model.sheetName=l}get _serialisedSheetName(){const{sheetName:l}=this.model;return l?/^[a-zA-Z0-9]*$/.test(l)?l+"!":`'${l}'!`:""}expand(l,a,u,h){(!this.model.top||l<this.top)&&(this.top=l),(!this.model.left||a<this.left)&&(this.left=a),(!this.model.bottom||u>this.bottom)&&(this.bottom=u),(!this.model.right||h>this.right)&&(this.right=h)}expandRow(l){if(l){const{dimensions:a,number:u}=l;a&&this.expand(u,a.min,u,a.max)}}expandToAddress(l){const a=o.decodeEx(l);this.expand(a.row,a.col,a.row,a.col)}get tl(){return o.n2l(this.left)+this.top}get $t$l(){return`$${o.n2l(this.left)}$${this.top}`}get br(){return o.n2l(this.right)+this.bottom}get $b$r(){return`$${o.n2l(this.right)}$${this.bottom}`}get range(){return`${this._serialisedSheetName+this.tl}:${this.br}`}get $range(){return`${this._serialisedSheetName+this.$t$l}:${this.$b$r}`}get shortRange(){return this.count>1?this.range:this._serialisedSheetName+this.tl}get $shortRange(){return this.count>1?this.$range:this._serialisedSheetName+this.$t$l}get count(){return(1+this.bottom-this.top)*(1+this.right-this.left)}toString(){return this.range}intersects(l){return(!l.sheetName||!this.sheetName||l.sheetName===this.sheetName)&&!(l.bottom<this.top)&&!(l.top>this.bottom)&&!(l.right<this.left)&&!(l.left>this.right)}contains(l){const a=o.decodeEx(l);return this.containsEx(a)}containsEx(l){return(!l.sheetName||!this.sheetName||l.sheetName===this.sheetName)&&l.row>=this.top&&l.row<=this.bottom&&l.col>=this.left&&l.col<=this.right}forEachAddress(l){for(let a=this.left;a<=this.right;a++)for(let u=this.top;u<=this.bottom;u++)l(o.encodeAddress(u,a),u,a)}}n.exports=i},{"../utils/col-cache":19}],11:[function(t,n,s){const o=t("../utils/under-dash"),i=t("./enums"),c=t("../utils/col-cache"),l=t("./cell");n.exports=class{constructor(a,u){this._worksheet=a,this._number=u,this._cells=[],this.style={},this.outlineLevel=0}get number(){return this._number}get worksheet(){return this._worksheet}commit(){this._worksheet._commitRow(this)}destroy(){delete this._worksheet,delete this._cells,delete this.style}findCell(a){return this._cells[a-1]}getCellEx(a){let u=this._cells[a.col-1];if(!u){const h=this._worksheet.getColumn(a.col);u=new l(this,h,a.address),this._cells[a.col-1]=u}return u}getCell(a){if(typeof a=="string"){const u=this._worksheet.getColumnKey(a);a=u?u.number:c.l2n(a)}return this._cells[a-1]||this.getCellEx({address:c.encodeAddress(this._number,a),row:this._number,col:a})}splice(a,u){const h=a+u;for(var d=arguments.length,f=new Array(d>2?d-2:0),m=2;m<d;m++)f[m-2]=arguments[m];const p=f.length-u,g=this._cells.length;let b,y,w;if(p<0)for(b=a+f.length;b<=g;b++)w=this._cells[b-1],y=this._cells[b-p-1],y?(w=this.getCell(b),w.value=y.value,w.style=y.style,w._comment=y._comment):w&&(w.value=null,w.style={},w._comment=void 0);else if(p>0)for(b=g;b>=h;b--)y=this._cells[b-1],y?(w=this.getCell(b+p),w.value=y.value,w.style=y.style,w._comment=y._comment):this._cells[b+p-1]=void 0;for(b=0;b<f.length;b++)w=this.getCell(a+b),w.value=f[b],w.style={},w._comment=void 0}eachCell(a,u){if(u||(u=a,a=null),a&&a.includeEmpty){const h=this._cells.length;for(let d=1;d<=h;d++)u(this.getCell(d),d)}else this._cells.forEach((h,d)=>{h&&h.type!==i.ValueType.Null&&u(h,d+1)})}addPageBreak(a,u){const h=this._worksheet,d=Math.max(0,a-1)||0,f=Math.max(0,u-1)||16838,m={id:this._number,max:f,man:1};d&&(m.min=d),h.rowBreaks.push(m)}get values(){const a=[];return this._cells.forEach(u=>{u&&u.type!==i.ValueType.Null&&(a[u.col]=u.value)}),a}set values(a){if(this._cells=[],a)if(a instanceof Array){let u=0;a.hasOwnProperty("0")&&(u=1),a.forEach((h,d)=>{h!==void 0&&(this.getCellEx({address:c.encodeAddress(this._number,d+u),row:this._number,col:d+u}).value=h)})}else this._worksheet.eachColumnKey((u,h)=>{a[h]!==void 0&&(this.getCellEx({address:c.encodeAddress(this._number,u.number),row:this._number,col:u.number}).value=a[h])})}get hasValues(){return o.some(this._cells,a=>a&&a.type!==i.ValueType.Null)}get cellCount(){return this._cells.length}get actualCellCount(){let a=0;return this.eachCell(()=>{a++}),a}get dimensions(){let a=0,u=0;return this._cells.forEach(h=>{h&&h.type!==i.ValueType.Null&&((!a||a>h.col)&&(a=h.col),u<h.col&&(u=h.col))}),a>0?{min:a,max:u}:null}_applyStyle(a,u){return this.style[a]=u,this._cells.forEach(h=>{h&&(h[a]=u)}),u}get numFmt(){return this.style.numFmt}set numFmt(a){this._applyStyle("numFmt",a)}get font(){return this.style.font}set font(a){this._applyStyle("font",a)}get alignment(){return this.style.alignment}set alignment(a){this._applyStyle("alignment",a)}get protection(){return this.style.protection}set protection(a){this._applyStyle("protection",a)}get border(){return this.style.border}set border(a){this._applyStyle("border",a)}get fill(){return this.style.fill}set fill(a){this._applyStyle("fill",a)}get hidden(){return!!this._hidden}set hidden(a){this._hidden=a}get outlineLevel(){return this._outlineLevel||0}set outlineLevel(a){this._outlineLevel=a}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelRow)}get model(){const a=[];let u=0,h=0;return this._cells.forEach(d=>{if(d){const f=d.model;f&&((!u||u>d.col)&&(u=d.col),h<d.col&&(h=d.col),a.push(f))}}),this.height||a.length?{cells:a,number:this.number,min:u,max:h,height:this.height,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel,collapsed:this.collapsed}:null}set model(a){if(a.number!==this._number)throw new Error("Invalid row number in model");let u;this._cells=[],a.cells.forEach(h=>{switch(h.type){case l.Types.Merge:break;default:{let d;if(h.address)d=c.decodeAddress(h.address);else if(u){const{row:f}=u,m=u.col+1;d={row:f,col:m,address:c.encodeAddress(f,m),$col$row:`$${c.n2l(m)}$${f}`}}u=d,this.getCellEx(d).model=h;break}}}),a.height?this.height=a.height:delete this.height,this.hidden=a.hidden,this.outlineLevel=a.outlineLevel||0,this.style=a.style&&JSON.parse(JSON.stringify(a.style))||{}}}},{"../utils/col-cache":19,"../utils/under-dash":26,"./cell":3,"./enums":7}],12:[function(t,n,s){const o=t("../utils/col-cache");class i{constructor(l,a,u){this.table=l,this.column=a,this.index=u}_set(l,a){this.table.cacheState(),this.column[l]=a}get name(){return this.column.name}set name(l){this._set("name",l)}get filterButton(){return this.column.filterButton}set filterButton(l){this.column.filterButton=l}get style(){return this.column.style}set style(l){this.column.style=l}get totalsRowLabel(){return this.column.totalsRowLabel}set totalsRowLabel(l){this._set("totalsRowLabel",l)}get totalsRowFunction(){return this.column.totalsRowFunction}set totalsRowFunction(l){this._set("totalsRowFunction",l)}get totalsRowResult(){return this.column.totalsRowResult}set totalsRowResult(l){this._set("totalsRowResult",l)}get totalsRowFormula(){return this.column.totalsRowFormula}set totalsRowFormula(l){this._set("totalsRowFormula",l)}}n.exports=class{constructor(c,l){this.worksheet=c,l&&(this.table=l,this.validate(),this.store())}getFormula(c){switch(c.totalsRowFunction){case"none":return null;case"average":return`SUBTOTAL(101,${this.table.name}[${c.name}])`;case"countNums":return`SUBTOTAL(102,${this.table.name}[${c.name}])`;case"count":return`SUBTOTAL(103,${this.table.name}[${c.name}])`;case"max":return`SUBTOTAL(104,${this.table.name}[${c.name}])`;case"min":return`SUBTOTAL(105,${this.table.name}[${c.name}])`;case"stdDev":return`SUBTOTAL(106,${this.table.name}[${c.name}])`;case"var":return`SUBTOTAL(107,${this.table.name}[${c.name}])`;case"sum":return`SUBTOTAL(109,${this.table.name}[${c.name}])`;case"custom":return c.totalsRowFormula;default:throw new Error("Invalid Totals Row Function: "+c.totalsRowFunction)}}get width(){return this.table.columns.length}get height(){return this.table.rows.length}get filterHeight(){return this.height+(this.table.headerRow?1:0)}get tableHeight(){return this.filterHeight+(this.table.totalsRow?1:0)}validate(){const{table:c}=this,l=(p,g,b)=>{p[g]===void 0&&(p[g]=b)};l(c,"headerRow",!0),l(c,"totalsRow",!1),l(c,"style",{}),l(c.style,"theme","TableStyleMedium2"),l(c.style,"showFirstColumn",!1),l(c.style,"showLastColumn",!1),l(c.style,"showRowStripes",!1),l(c.style,"showColumnStripes",!1);const a=(p,g)=>{if(!p)throw new Error(g)};a(c.ref,"Table must have ref"),a(c.columns,"Table must have column definitions"),a(c.rows,"Table must have row definitions"),c.tl=o.decodeAddress(c.ref);const{row:u,col:h}=c.tl;a(u>0,"Table must be on valid row"),a(h>0,"Table must be on valid col");const{width:d,filterHeight:f,tableHeight:m}=this;c.autoFilterRef=o.encode(u,h,u+f-1,h+d-1),c.tableRef=o.encode(u,h,u+m-1,h+d-1),c.columns.forEach((p,g)=>{a(p.name,`Column ${g} must have a name`),g===0?l(p,"totalsRowLabel","Total"):(l(p,"totalsRowFunction","none"),p.totalsRowFormula=this.getFormula(p))})}store(){const c=(f,m)=>{m&&Object.keys(m).forEach(p=>{f[p]=m[p]})},{worksheet:l,table:a}=this,{row:u,col:h}=a.tl;let d=0;if(a.headerRow){const f=l.getRow(u+d++);a.columns.forEach((m,p)=>{const{style:g,name:b}=m,y=f.getCell(h+p);y.value=b,c(y,g)})}if(a.rows.forEach(f=>{const m=l.getRow(u+d++);f.forEach((p,g)=>{const b=m.getCell(h+g);b.value=p,c(b,a.columns[g].style)})}),a.totalsRow){const f=l.getRow(u+d++);a.columns.forEach((m,p)=>{const g=f.getCell(h+p);if(p===0)g.value=m.totalsRowLabel;else{const b=this.getFormula(m);g.value=b?{formula:m.totalsRowFormula,result:m.totalsRowResult}:null}c(g,m.style)})}}load(c){const{table:l}=this,{row:a,col:u}=l.tl;let h=0;if(l.headerRow){const d=c.getRow(a+h++);l.columns.forEach((f,m)=>{d.getCell(u+m).value=f.name})}if(l.rows.forEach(d=>{const f=c.getRow(a+h++);d.forEach((m,p)=>{f.getCell(u+p).value=m})}),l.totalsRow){const d=c.getRow(a+h++);l.columns.forEach((f,m)=>{const p=d.getCell(u+m);m===0?p.value=f.totalsRowLabel:this.getFormula(f)&&(p.value={formula:f.totalsRowFormula,result:f.totalsRowResult})})}}get model(){return this.table}set model(c){this.table=c}cacheState(){this._cache||(this._cache={ref:this.ref,width:this.width,tableHeight:this.tableHeight})}commit(){if(!this._cache)return;this.validate();const c=o.decodeAddress(this._cache.ref);if(this.ref!==this._cache.ref)for(let l=0;l<this._cache.tableHeight;l++){const a=this.worksheet.getRow(c.row+l);for(let u=0;u<this._cache.width;u++)a.getCell(c.col+u).value=null}else{for(let l=this.tableHeight;l<this._cache.tableHeight;l++){const a=this.worksheet.getRow(c.row+l);for(let u=0;u<this._cache.width;u++)a.getCell(c.col+u).value=null}for(let l=0;l<this.tableHeight;l++){const a=this.worksheet.getRow(c.row+l);for(let u=this.width;u<this._cache.width;u++)a.getCell(c.col+u).value=null}}this.store()}addRow(c,l){this.cacheState(),l===void 0?this.table.rows.push(c):this.table.rows.splice(l,0,c)}removeRows(c){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;this.cacheState(),this.table.rows.splice(c,l)}getColumn(c){const l=this.table.columns[c];return new i(this,l,c)}addColumn(c,l,a){this.cacheState(),a===void 0?(this.table.columns.push(c),this.table.rows.forEach((u,h)=>{u.push(l[h])})):(this.table.columns.splice(a,0,c),this.table.rows.forEach((u,h)=>{u.splice(a,0,l[h])}))}removeColumns(c){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;this.cacheState(),this.table.columns.splice(c,l),this.table.rows.forEach(a=>{a.splice(c,l)})}_assign(c,l,a){this.cacheState(),c[l]=a}get ref(){return this.table.ref}set ref(c){this._assign(this.table,"ref",c)}get name(){return this.table.name}set name(c){this.table.name=c}get displayName(){return this.table.displyName||this.table.name}set displayNamename(c){this.table.displayName=c}get headerRow(){return this.table.headerRow}set headerRow(c){this._assign(this.table,"headerRow",c)}get totalsRow(){return this.table.totalsRow}set totalsRow(c){this._assign(this.table,"totalsRow",c)}get theme(){return this.table.style.name}set theme(c){this.table.style.name=c}get showFirstColumn(){return this.table.style.showFirstColumn}set showFirstColumn(c){this.table.style.showFirstColumn=c}get showLastColumn(){return this.table.style.showLastColumn}set showLastColumn(c){this.table.style.showLastColumn=c}get showRowStripes(){return this.table.style.showRowStripes}set showRowStripes(c){this.table.style.showRowStripes=c}get showColumnStripes(){return this.table.style.showColumnStripes}set showColumnStripes(c){this.table.style.showColumnStripes=c}}},{"../utils/col-cache":19}],13:[function(t,n,s){const o=t("./worksheet"),i=t("./defined-names"),c=t("../xlsx/xlsx"),l=t("../csv/csv");n.exports=class{constructor(){this.category="",this.company="",this.created=new Date,this.description="",this.keywords="",this.manager="",this.modified=this.created,this.properties={},this.calcProperties={},this._worksheets=[],this.subject="",this.title="",this.views=[],this.media=[],this._definedNames=new i}get xlsx(){return this._xlsx||(this._xlsx=new c(this)),this._xlsx}get csv(){return this._csv||(this._csv=new l(this)),this._csv}get nextId(){for(let a=1;a<this._worksheets.length;a++)if(!this._worksheets[a])return a;return this._worksheets.length||1}addWorksheet(a,u){const h=this.nextId;u&&(typeof u=="string"?(console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }'),u={properties:{tabColor:{argb:u}}}):(u.argb||u.theme||u.indexed)&&(console.trace("tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }"),u={properties:{tabColor:u}}));const d=this._worksheets.reduce((p,g)=>(g&&g.orderNo)>p?g.orderNo:p,0),f=Object.assign({},u,{id:h,name:a,orderNo:d+1,workbook:this}),m=new o(f);return this._worksheets[h]=m,m}removeWorksheetEx(a){delete this._worksheets[a.id]}removeWorksheet(a){const u=this.getWorksheet(a);u&&u.destroy()}getWorksheet(a){return a===void 0?this._worksheets.find(Boolean):typeof a=="number"?this._worksheets[a]:typeof a=="string"?this._worksheets.find(u=>u&&u.name===a):void 0}get worksheets(){return this._worksheets.slice(1).sort((a,u)=>a.orderNo-u.orderNo).filter(Boolean)}eachSheet(a){this.worksheets.forEach(u=>{a(u,u.id)})}get definedNames(){return this._definedNames}clearThemes(){this._themes=void 0}addImage(a){const u=this.media.length;return this.media.push(Object.assign({},a,{type:"image"})),u}getImage(a){return this.media[a]}get model(){return{creator:this.creator||"Unknown",lastModifiedBy:this.lastModifiedBy||"Unknown",lastPrinted:this.lastPrinted,created:this.created,modified:this.modified,properties:this.properties,worksheets:this.worksheets.map(a=>a.model),sheets:this.worksheets.map(a=>a.model).filter(Boolean),definedNames:this._definedNames.model,views:this.views,company:this.company,manager:this.manager,title:this.title,subject:this.subject,keywords:this.keywords,category:this.category,description:this.description,language:this.language,revision:this.revision,contentStatus:this.contentStatus,themes:this._themes,media:this.media,calcProperties:this.calcProperties}}set model(a){this.creator=a.creator,this.lastModifiedBy=a.lastModifiedBy,this.lastPrinted=a.lastPrinted,this.created=a.created,this.modified=a.modified,this.company=a.company,this.manager=a.manager,this.title=a.title,this.subject=a.subject,this.keywords=a.keywords,this.category=a.category,this.description=a.description,this.language=a.language,this.revision=a.revision,this.contentStatus=a.contentStatus,this.properties=a.properties,this.calcProperties=a.calcProperties,this._worksheets=[],a.worksheets.forEach(u=>{const{id:h,name:d,state:f}=u,m=a.sheets&&a.sheets.findIndex(p=>p.id===h);(this._worksheets[h]=new o({id:h,name:d,orderNo:m,state:f,workbook:this})).model=u}),this._definedNames.model=a.definedNames,this.views=a.views,this._themes=a.themes,this.media=a.media||[]}}},{"../csv/csv":1,"../xlsx/xlsx":144,"./defined-names":6,"./worksheet":14}],14:[function(t,n,s){const o=t("../utils/under-dash"),i=t("../utils/col-cache"),c=t("./range"),l=t("./row"),a=t("./column"),u=t("./enums"),h=t("./image"),d=t("./table"),f=t("./data-validations"),m=t("../utils/encryptor"),{copyStyle:p}=t("../utils/copy-style");n.exports=class{constructor(g){g=g||{},this._workbook=g.workbook,this.id=g.id,this.orderNo=g.orderNo,this.name=g.name,this.state=g.state||"visible",this._rows=[],this._columns=null,this._keys={},this._merges={},this.rowBreaks=[],this.properties=Object.assign({},{defaultRowHeight:15,dyDescent:55,outlineLevelCol:0,outlineLevelRow:0},g.properties),this.pageSetup=Object.assign({},{margins:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},orientation:"portrait",horizontalDpi:4294967295,verticalDpi:4294967295,fitToPage:!(!g.pageSetup||!g.pageSetup.fitToWidth&&!g.pageSetup.fitToHeight||g.pageSetup.scale),pageOrder:"downThenOver",blackAndWhite:!1,draft:!1,cellComments:"None",errors:"displayed",scale:100,fitToWidth:1,fitToHeight:1,paperSize:void 0,showRowColHeaders:!1,showGridLines:!1,firstPageNumber:void 0,horizontalCentered:!1,verticalCentered:!1,rowBreaks:null,colBreaks:null},g.pageSetup),this.headerFooter=Object.assign({},{differentFirst:!1,differentOddEven:!1,oddHeader:null,oddFooter:null,evenHeader:null,evenFooter:null,firstHeader:null,firstFooter:null},g.headerFooter),this.dataValidations=new f,this.views=g.views||[],this.autoFilter=g.autoFilter||null,this._media=[],this.sheetProtection=null,this.tables={},this.conditionalFormattings=[]}get name(){return this._name}set name(g){if(g===void 0&&(g="sheet"+this.id),this._name!==g){if(typeof g!="string")throw new Error("The name has to be a string.");if(g==="")throw new Error("The name can't be empty.");if(g==="History")throw new Error('The name "History" is protected. Please use a different name.');if(/[*?:/\\[\]]/.test(g))throw new Error(`Worksheet name ${g} cannot include any of the following characters: * ? : \\ / [ ]`);if(/(^')|('$)/.test(g))throw new Error("The first or last character of worksheet name cannot be a single quotation mark: "+g);if(g&&g.length>31&&(console.warn(`Worksheet name ${g} exceeds 31 chars. This will be truncated`),g=g.substring(0,31)),this._workbook._worksheets.find(b=>b&&b.name.toLowerCase()===g.toLowerCase()))throw new Error("Worksheet name already exists: "+g);this._name=g}}get workbook(){return this._workbook}destroy(){this._workbook.removeWorksheetEx(this)}get dimensions(){const g=new c;return this._rows.forEach(b=>{if(b){const y=b.dimensions;y&&g.expand(b.number,y.min,b.number,y.max)}}),g}get columns(){return this._columns}set columns(g){this._headerRowCount=g.reduce((w,C)=>{const N=(C.header?1:C.headers&&C.headers.length)||0;return Math.max(w,N)},0);let b=1;const y=this._columns=[];g.forEach(w=>{const C=new a(this,b++,!1);y.push(C),C.defn=w})}getColumnKey(g){return this._keys[g]}setColumnKey(g,b){this._keys[g]=b}deleteColumnKey(g){delete this._keys[g]}eachColumnKey(g){o.each(this._keys,g)}getColumn(g){if(typeof g=="string"){const b=this._keys[g];if(b)return b;g=i.l2n(g)}if(this._columns||(this._columns=[]),g>this._columns.length){let b=this._columns.length+1;for(;b<=g;)this._columns.push(new a(this,b++))}return this._columns[g-1]}spliceColumns(g,b){const y=this._rows.length;for(var w=arguments.length,C=new Array(w>2?w-2:0),N=2;N<w;N++)C[N-2]=arguments[N];if(C.length>0)for(let F=0;F<y;F++){const V=[g,b];C.forEach(U=>{V.push(U[F]||null)});const G=this.getRow(F+1);G.splice.apply(G,V)}else this._rows.forEach(F=>{F&&F.splice(g,b)});const I=C.length-b,$=g+b,D=this._columns.length;if(I<0)for(let F=g+C.length;F<=D;F++)this.getColumn(F).defn=this.getColumn(F-I).defn;else if(I>0)for(let F=D;F>=$;F--)this.getColumn(F+I).defn=this.getColumn(F).defn;for(let F=g;F<g+C.length;F++)this.getColumn(F).defn=null;this.workbook.definedNames.spliceColumns(this.name,g,b,C.length)}get lastColumn(){return this.getColumn(this.columnCount)}get columnCount(){let g=0;return this.eachRow(b=>{g=Math.max(g,b.cellCount)}),g}get actualColumnCount(){const g=[];let b=0;return this.eachRow(y=>{y.eachCell(w=>{let{col:C}=w;g[C]||(g[C]=!0,b++)})}),b}_commitRow(){}get _lastRowNumber(){const g=this._rows;let b=g.length;for(;b>0&&g[b-1]===void 0;)b--;return b}get _nextRow(){return this._lastRowNumber+1}get lastRow(){if(this._rows.length)return this._rows[this._rows.length-1]}findRow(g){return this._rows[g-1]}findRows(g,b){return this._rows.slice(g-1,g-1+b)}get rowCount(){return this._lastRowNumber}get actualRowCount(){let g=0;return this.eachRow(()=>{g++}),g}getRow(g){let b=this._rows[g-1];return b||(b=this._rows[g-1]=new l(this,g)),b}getRows(g,b){if(b<1)return;const y=[];for(let w=g;w<g+b;w++)y.push(this.getRow(w));return y}addRow(g){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"n";const y=this._nextRow,w=this.getRow(y);return w.values=g,this._setStyleOption(y,b[0]==="i"?b:"n"),w}addRows(g){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"n";const y=[];return g.forEach(w=>{y.push(this.addRow(w,b))}),y}insertRow(g,b){let y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"n";return this.spliceRows(g,0,b),this._setStyleOption(g,y),this.getRow(g)}insertRows(g,b){let y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"n";if(this.spliceRows(g,0,...b),y!=="n")for(let w=0;w<b.length;w++)y[0]==="o"&&this.findRow(b.length+g+w)!==void 0?this._copyStyle(b.length+g+w,g+w,y[1]==="+"):y[0]==="i"&&this.findRow(g-1)!==void 0&&this._copyStyle(g-1,g+w,y[1]==="+");return this.getRows(g,b.length)}_setStyleOption(g){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"n";b[0]==="o"&&this.findRow(g+1)!==void 0?this._copyStyle(g+1,g,b[1]==="+"):b[0]==="i"&&this.findRow(g-1)!==void 0&&this._copyStyle(g-1,g,b[1]==="+")}_copyStyle(g,b){let y=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const w=this.getRow(g),C=this.getRow(b);C.style=p(w.style),w.eachCell({includeEmpty:y},(N,I)=>{C.getCell(I).style=p(N.style)}),C.height=w.height}duplicateRow(g,b){let y=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const w=this._rows[g-1],C=new Array(b).fill(w.values);this.spliceRows(g+1,y?0:b,...C);for(let N=0;N<b;N++){const I=this._rows[g+N];I.style=w.style,I.height=w.height,w.eachCell({includeEmpty:!0},($,D)=>{I.getCell(D).style=$.style})}}spliceRows(g,b){const y=g+b;for(var w=arguments.length,C=new Array(w>2?w-2:0),N=2;N<w;N++)C[N-2]=arguments[N];const I=C.length,$=I-b,D=this._rows.length;let F,V;if($<0)for(g===D&&(this._rows[D-1]=void 0),F=y;F<=D;F++)if(V=this._rows[F-1],V){const G=this.getRow(F+$);G.values=V.values,G.style=V.style,G.height=V.height,V.eachCell({includeEmpty:!0},(U,E)=>{G.getCell(E).style=U.style}),this._rows[F-1]=void 0}else this._rows[F+$-1]=void 0;else if($>0)for(F=D;F>=y;F--)if(V=this._rows[F-1],V){const G=this.getRow(F+$);G.values=V.values,G.style=V.style,G.height=V.height,V.eachCell({includeEmpty:!0},(U,E)=>{if(G.getCell(E).style=U.style,U._value.constructor.name==="MergeValue"){const M=this.getRow(U._row._number+I).getCell(E),B=U._value._master,k=this.getRow(B._row._number+I).getCell(B._column._number);M.merge(k)}})}else this._rows[F+$-1]=void 0;for(F=0;F<I;F++){const G=this.getRow(g+F);G.style={},G.values=C[F]}this.workbook.definedNames.spliceRows(this.name,g,b,I)}eachRow(g,b){if(b||(b=g,g=void 0),g&&g.includeEmpty){const y=this._rows.length;for(let w=1;w<=y;w++)b(this.getRow(w),w)}else this._rows.forEach(y=>{y&&y.hasValues&&b(y,y.number)})}getSheetValues(){const g=[];return this._rows.forEach(b=>{b&&(g[b.number]=b.values)}),g}findCell(g,b){const y=i.getAddress(g,b),w=this._rows[y.row-1];return w?w.findCell(y.col):void 0}getCell(g,b){const y=i.getAddress(g,b);return this.getRow(y.row).getCellEx(y)}mergeCells(){for(var g=arguments.length,b=new Array(g),y=0;y<g;y++)b[y]=arguments[y];const w=new c(b);this._mergeCellsInternal(w)}mergeCellsWithoutStyle(){for(var g=arguments.length,b=new Array(g),y=0;y<g;y++)b[y]=arguments[y];const w=new c(b);this._mergeCellsInternal(w,!0)}_mergeCellsInternal(g,b){o.each(this._merges,w=>{if(w.intersects(g))throw new Error("Cannot merge already merged cells")});const y=this.getCell(g.top,g.left);for(let w=g.top;w<=g.bottom;w++)for(let C=g.left;C<=g.right;C++)(w>g.top||C>g.left)&&this.getCell(w,C).merge(y,b);this._merges[y.address]=g}_unMergeMaster(g){const b=this._merges[g.address];if(b){for(let y=b.top;y<=b.bottom;y++)for(let w=b.left;w<=b.right;w++)this.getCell(y,w).unmerge();delete this._merges[g.address]}}get hasMerges(){return o.some(this._merges,Boolean)}unMergeCells(){for(var g=arguments.length,b=new Array(g),y=0;y<g;y++)b[y]=arguments[y];const w=new c(b);for(let C=w.top;C<=w.bottom;C++)for(let N=w.left;N<=w.right;N++){const I=this.findCell(C,N);I&&(I.type===u.ValueType.Merge?this._unMergeMaster(I.master):this._merges[I.address]&&this._unMergeMaster(I))}}fillFormula(g,b,y){let w=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"shared";const C=i.decode(g),{top:N,left:I,bottom:$,right:D}=C,F=D-I+1,V=i.encodeAddress(N,I),G=w==="shared";let U;U=typeof y=="function"?y:Array.isArray(y)?Array.isArray(y[0])?(M,B)=>y[M-N][B-I]:(M,B)=>y[(M-N)*F+(B-I)]:()=>{};let E=!0;for(let M=N;M<=$;M++)for(let B=I;B<=D;B++)E?(this.getCell(M,B).value={shareType:w,formula:b,ref:g,result:U(M,B)},E=!1):this.getCell(M,B).value=G?{sharedFormula:V,result:U(M,B)}:U(M,B)}addImage(g,b){const y={type:"image",imageId:g,range:b};this._media.push(new h(this,y))}getImages(){return this._media.filter(g=>g.type==="image")}addBackgroundImage(g){const b={type:"background",imageId:g};this._media.push(new h(this,b))}getBackgroundImageId(){const g=this._media.find(b=>b.type==="background");return g&&g.imageId}protect(g,b){return new Promise(y=>{this.sheetProtection={sheet:!0},b&&"spinCount"in b&&(b.spinCount=Number.isFinite(b.spinCount)?Math.round(Math.max(0,b.spinCount)):1e5),g&&(this.sheetProtection.algorithmName="SHA-512",this.sheetProtection.saltValue=m.randomBytes(16).toString("base64"),this.sheetProtection.spinCount=b&&"spinCount"in b?b.spinCount:1e5,this.sheetProtection.hashValue=m.convertPasswordToHash(g,"SHA512",this.sheetProtection.saltValue,this.sheetProtection.spinCount)),b&&(this.sheetProtection=Object.assign(this.sheetProtection,b),!g&&"spinCount"in b&&delete this.sheetProtection.spinCount),y()})}unprotect(){this.sheetProtection=null}addTable(g){const b=new d(this,g);return this.tables[g.name]=b,b}getTable(g){return this.tables[g]}removeTable(g){delete this.tables[g]}getTables(){return Object.values(this.tables)}addConditionalFormatting(g){this.conditionalFormattings.push(g)}removeConditionalFormatting(g){typeof g=="number"?this.conditionalFormattings.splice(g,1):this.conditionalFormattings=g instanceof Function?this.conditionalFormattings.filter(g):[]}get tabColor(){return console.trace("worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor"),this.properties.tabColor}set tabColor(g){console.trace("worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor"),this.properties.tabColor=g}get model(){const g={id:this.id,name:this.name,dataValidations:this.dataValidations.model,properties:this.properties,state:this.state,pageSetup:this.pageSetup,headerFooter:this.headerFooter,rowBreaks:this.rowBreaks,views:this.views,autoFilter:this.autoFilter,media:this._media.map(w=>w.model),sheetProtection:this.sheetProtection,tables:Object.values(this.tables).map(w=>w.model),conditionalFormattings:this.conditionalFormattings};g.cols=a.toModel(this.columns);const b=g.rows=[],y=g.dimensions=new c;return this._rows.forEach(w=>{const C=w&&w.model;C&&(y.expand(C.number,C.min,C.number,C.max),b.push(C))}),g.merges=[],o.each(this._merges,w=>{g.merges.push(w.range)}),g}_parseRows(g){this._rows=[],g.rows.forEach(b=>{const y=new l(this,b.number);this._rows[y.number-1]=y,y.model=b})}_parseMergeCells(g){o.each(g.mergeCells,b=>{this.mergeCellsWithoutStyle(b)})}set model(g){this.name=g.name,this._columns=a.fromModel(this,g.cols),this._parseRows(g),this._parseMergeCells(g),this.dataValidations=new f(g.dataValidations),this.properties=g.properties,this.pageSetup=g.pageSetup,this.headerFooter=g.headerFooter,this.views=g.views,this.autoFilter=g.autoFilter,this._media=g.media.map(b=>new h(this,b)),this.sheetProtection=g.sheetProtection,this.tables=g.tables.reduce((b,y)=>{const w=new d;return w.model=y,b[y.name]=w,b},{}),this.conditionalFormattings=g.conditionalFormattings}}},{"../utils/col-cache":19,"../utils/copy-style":20,"../utils/encryptor":21,"../utils/under-dash":26,"./column":4,"./data-validations":5,"./enums":7,"./image":8,"./range":10,"./row":11,"./table":12}],15:[function(t,n,s){t("core-js/modules/es.promise"),t("core-js/modules/es.promise.finally"),t("core-js/modules/es.object.assign"),t("core-js/modules/es.object.keys"),t("core-js/modules/es.object.values"),t("core-js/modules/es.symbol"),t("core-js/modules/es.symbol.async-iterator"),t("core-js/modules/es.array.iterator"),t("core-js/modules/es.array.includes"),t("core-js/modules/es.array.find-index"),t("core-js/modules/es.array.find"),t("core-js/modules/es.string.from-code-point"),t("core-js/modules/es.string.includes"),t("core-js/modules/es.number.is-nan"),t("regenerator-runtime/runtime");const o={Workbook:t("./doc/workbook")},i=t("./doc/enums");Object.keys(i).forEach(c=>{o[c]=i[c]}),n.exports=o},{"./doc/enums":7,"./doc/workbook":13,"core-js/modules/es.array.find":359,"core-js/modules/es.array.find-index":358,"core-js/modules/es.array.includes":360,"core-js/modules/es.array.iterator":361,"core-js/modules/es.number.is-nan":363,"core-js/modules/es.object.assign":364,"core-js/modules/es.object.keys":366,"core-js/modules/es.object.values":367,"core-js/modules/es.promise":372,"core-js/modules/es.promise.finally":371,"core-js/modules/es.string.from-code-point":376,"core-js/modules/es.string.includes":377,"core-js/modules/es.symbol":381,"core-js/modules/es.symbol.async-iterator":378,"regenerator-runtime/runtime":492}],16:[function(t,n,s){const o=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");s.bufferToString=function(i){return typeof i=="string"?i:o?o.decode(i):i.toString()}},{}],17:[function(t,n,s){const o=typeof TextEncoder>"u"?null:new TextEncoder("utf-8"),{Buffer:i}=t("buffer");s.stringToBuffer=function(c){return typeof c!="string"?c:o?i.from(o.encode(c).buffer):i.from(c)}},{buffer:220}],18:[function(t,n,s){const o=t("./under-dash"),i=t("./col-cache");n.exports=class{constructor(c){this.template=c,this.sheets={}}addCell(c){this.addCellEx(i.decodeEx(c))}getCell(c){return this.findCellEx(i.decodeEx(c),!0)}findCell(c){return this.findCellEx(i.decodeEx(c),!1)}findCellAt(c,l,a){const u=this.sheets[c],h=u&&u[l];return h&&h[a]}addCellEx(c){if(c.top)for(let l=c.top;l<=c.bottom;l++)for(let a=c.left;a<=c.right;a++)this.getCellAt(c.sheetName,l,a);else this.findCellEx(c,!0)}getCellEx(c){return this.findCellEx(c,!0)}findCellEx(c,l){const a=this.findSheet(c,l),u=this.findSheetRow(a,c,l);return this.findRowCell(u,c,l)}getCellAt(c,l,a){const u=this.sheets[c]||(this.sheets[c]=[]),h=u[l]||(u[l]=[]);return h[a]||(h[a]={sheetName:c,address:i.n2l(a)+l,row:l,col:a})}removeCellEx(c){const l=this.findSheet(c);if(!l)return;const a=this.findSheetRow(l,c);a&&delete a[c.col]}forEachInSheet(c,l){const a=this.sheets[c];a&&a.forEach((u,h)=>{u&&u.forEach((d,f)=>{d&&l(d,h,f)})})}forEach(c){o.each(this.sheets,(l,a)=>{this.forEachInSheet(a,c)})}map(c){const l=[];return this.forEach(a=>{l.push(c(a))}),l}findSheet(c,l){const a=c.sheetName;return this.sheets[a]?this.sheets[a]:l?this.sheets[a]=[]:void 0}findSheetRow(c,l,a){const{row:u}=l;return c&&c[u]?c[u]:a?c[u]=[]:void 0}findRowCell(c,l,a){const{col:u}=l;return c&&c[u]?c[u]:a?c[u]=this.template?Object.assign(l,JSON.parse(JSON.stringify(this.template))):l:void 0}spliceRows(c,l,a,u){const h=this.sheets[c];if(h){const d=[];for(let f=0;f<u;f++)d.push([]);h.splice(l,a,...d)}}spliceColumns(c,l,a,u){const h=this.sheets[c];if(h){const d=[];for(let f=0;f<u;f++)d.push(null);o.each(h,f=>{f.splice(l,a,...d)})}}}},{"./col-cache":19,"./under-dash":26}],19:[function(t,n,s){const o=/^[A-Z]+\d+$/,i={_dictionary:["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],_l2nFill:0,_l2n:{},_n2l:[],_level:c=>c<=26?1:c<=676?2:3,_fill(c){let l,a,u,h,d,f=1;if(c>=4)throw new Error("Out of bounds. Excel supports columns from 1 to 16384");if(this._l2nFill<1&&c>=1){for(;f<=26;)l=this._dictionary[f-1],this._n2l[f]=l,this._l2n[l]=f,f++;this._l2nFill=1}if(this._l2nFill<2&&c>=2){for(f=27;f<=702;)a=f-27,u=a%26,h=Math.floor(a/26),l=this._dictionary[h]+this._dictionary[u],this._n2l[f]=l,this._l2n[l]=f,f++;this._l2nFill=2}if(this._l2nFill<3&&c>=3){for(f=703;f<=16384;)a=f-703,u=a%26,h=Math.floor(a/26)%26,d=Math.floor(a/676),l=this._dictionary[d]+this._dictionary[h]+this._dictionary[u],this._n2l[f]=l,this._l2n[l]=f,f++;this._l2nFill=3}},l2n(c){if(this._l2n[c]||this._fill(c.length),!this._l2n[c])throw new Error("Out of bounds. Invalid column letter: "+c);return this._l2n[c]},n2l(c){if(c<1||c>16384)throw new Error(c+" is out of bounds. Excel supports columns from 1 to 16384");return this._n2l[c]||this._fill(this._level(c)),this._n2l[c]},_hash:{},validateAddress(c){if(!o.test(c))throw new Error("Invalid Address: "+c);return!0},decodeAddress(c){const l=c.length<5&&this._hash[c];if(l)return l;let a=!1,u="",h=0,d=!1,f="",m=0;for(let g,b=0;b<c.length;b++)if(g=c.charCodeAt(b),!d&&g>=65&&g<=90)a=!0,u+=c[b],h=26*h+g-64;else if(g>=48&&g<=57)d=!0,f+=c[b],m=10*m+g-48;else if(d&&a&&g!==36)break;if(a){if(h>16384)throw new Error("Out of bounds. Invalid column letter: "+u)}else h=void 0;d||(m=void 0);const p={address:c=u+f,col:h,row:m,$col$row:`$${u}$${f}`};return h<=100&&m<=100&&(this._hash[c]=p,this._hash[p.$col$row]=p),p},getAddress(c,l){if(l){const a=this.n2l(l)+c;return this.decodeAddress(a)}return this.decodeAddress(c)},decode(c){const l=c.split(":");if(l.length===2){const a=this.decodeAddress(l[0]),u=this.decodeAddress(l[1]),h={top:Math.min(a.row,u.row),left:Math.min(a.col,u.col),bottom:Math.max(a.row,u.row),right:Math.max(a.col,u.col)};return h.tl=this.n2l(h.left)+h.top,h.br=this.n2l(h.right)+h.bottom,h.dimensions=`${h.tl}:${h.br}`,h}return this.decodeAddress(c)},decodeEx(c){const l=c.match(/(?:(?:(?:'((?:[^']|'')*)')|([^'^ !]*))!)?(.*)/),a=l[1]||l[2],u=l[3],h=u.split(":");if(h.length>1){let f=this.decodeAddress(h[0]),m=this.decodeAddress(h[1]);const p=Math.min(f.row,m.row),g=Math.min(f.col,m.col),b=Math.max(f.row,m.row),y=Math.max(f.col,m.col);return f=this.n2l(g)+p,m=this.n2l(y)+b,{top:p,left:g,bottom:b,right:y,sheetName:a,tl:{address:f,col:g,row:p,$col$row:`$${this.n2l(g)}$${p}`,sheetName:a},br:{address:m,col:y,row:b,$col$row:`$${this.n2l(y)}$${b}`,sheetName:a},dimensions:`${f}:${m}`}}if(u.startsWith("#"))return a?{sheetName:a,error:u}:{error:u};const d=this.decodeAddress(u);return a?{sheetName:a,...d}:d},encodeAddress:(c,l)=>i.n2l(l)+c,encode(){switch(arguments.length){case 2:return i.encodeAddress(arguments[0],arguments[1]);case 4:return`${i.encodeAddress(arguments[0],arguments[1])}:${i.encodeAddress(arguments[2],arguments[3])}`;default:throw new Error("Can only encode with 2 or 4 arguments")}},inRange(c,l){const[a,u,,h,d]=c,[f,m]=l;return f>=a&&f<=h&&m>=u&&m<=d}};n.exports=i},{}],20:[function(t,n,s){const o=(c,l)=>({...c,...l.reduce((a,u)=>(c[u]&&(a[u]={...c[u]}),a),{})}),i=function(c,l,a){let u=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[];c[a]&&(l[a]=o(c[a],u))};s.copyStyle=c=>{if(!c)return c;if(l=c,Object.keys(l).length===0)return{};var l;const a={...c};return i(c,a,"font",["color"]),i(c,a,"alignment"),i(c,a,"protection"),c.border&&(i(c,a,"border"),i(c.border,a.border,"top",["color"]),i(c.border,a.border,"left",["color"]),i(c.border,a.border,"bottom",["color"]),i(c.border,a.border,"right",["color"]),i(c.border,a.border,"diagonal",["color"])),c.fill&&(i(c,a,"fill",["fgColor","bgColor","center"]),c.fill.stops&&(a.fill.stops=c.fill.stops.map(u=>o(u,["color"])))),a}},{}],21:[function(t,n,s){(function(o){(function(){const i=t("crypto"),c={hash(l){const a=i.createHash(l);for(var u=arguments.length,h=new Array(u>1?u-1:0),d=1;d<u;d++)h[d-1]=arguments[d];return a.update(o.concat(h)),a.digest()},convertPasswordToHash(l,a,u,h){if(a=a.toLowerCase(),i.getHashes().indexOf(a)<0)throw new Error(`Hash algorithm '${a}' not supported!`);const d=o.from(l,"utf16le");let f=this.hash(a,o.from(u,"base64"),d);for(let m=0;m<h;m++){const p=o.alloc(4);p.writeUInt32LE(m,0),f=this.hash(a,f,p)}return f.toString("base64")},randomBytes:l=>i.randomBytes(l)};n.exports=c}).call(this)}).call(this,t("buffer").Buffer)},{buffer:220,crypto:390}],22:[function(t,n,s){const{SaxesParser:o}=t("saxes"),{PassThrough:i}=t("readable-stream"),{bufferToString:c}=t("./browser-buffer-decode");n.exports=async function*(l){l.pipe&&!l[Symbol.asyncIterator]&&(l=l.pipe(new i));const a=new o;let u;a.on("error",d=>{u=d});let h=[];a.on("opentag",d=>h.push({eventType:"opentag",value:d})),a.on("text",d=>h.push({eventType:"text",value:d})),a.on("closetag",d=>h.push({eventType:"closetag",value:d}));for await(const d of l){if(a.write(c(d)),u)throw u;yield h,h=[]}}},{"./browser-buffer-decode":16,"readable-stream":491,saxes:496}],23:[function(t,n,s){const o=t("./col-cache"),i=/(([a-z_\-0-9]*)!)?([a-z0-9_$]{2,})([(])?/gi,c=/^([$])?([a-z]+)([$])?([1-9][0-9]*)$/i;n.exports={slideFormula:function(l,a,u){const h=o.decode(a),d=o.decode(u);return l.replace(i,(f,m,p,g,b)=>{if(b)return f;const y=c.exec(g);if(y){const w=y[1],C=y[2].toUpperCase(),N=y[3],I=y[4];if(C.length>3||C.length===3&&C>"XFD")return f;let $=o.l2n(C),D=parseInt(I,10);return w||($+=d.col-h.col),N||(D+=d.row-h.row),(m||"")+(w||"")+o.n2l($)+(N||"")+D}return f})}}},{"./col-cache":19}],24:[function(t,n,s){(function(o,i){(function(){const c=t("readable-stream"),l=t("./utils"),a=t("./string-buf");class u{constructor(g,b){this._data=g,this._encoding=b}get length(){return this.toBuffer().length}copy(g,b,y,w){return this.toBuffer().copy(g,b,y,w)}toBuffer(){return this._buffer||(this._buffer=i.from(this._data,this._encoding)),this._buffer}}class h{constructor(g){this._data=g}get length(){return this._data.length}copy(g,b,y,w){return this._data._buf.copy(g,b,y,w)}toBuffer(){return this._data.toBuffer()}}class d{constructor(g){this._data=g}get length(){return this._data.length}copy(g,b,y,w){this._data.copy(g,b,y,w)}toBuffer(){return this._data}}class f{constructor(g){this.size=g,this.buffer=i.alloc(g),this.iRead=0,this.iWrite=0}toBuffer(){if(this.iRead===0&&this.iWrite===this.size)return this.buffer;const g=i.alloc(this.iWrite-this.iRead);return this.buffer.copy(g,0,this.iRead,this.iWrite),g}get length(){return this.iWrite-this.iRead}get eod(){return this.iRead===this.iWrite}get full(){return this.iWrite===this.size}read(g){let b;return g===0?null:g===void 0||g>=this.length?(b=this.toBuffer(),this.iRead=this.iWrite,b):(b=i.alloc(g),this.buffer.copy(b,0,this.iRead,g),this.iRead+=g,b)}write(g,b,y){const w=Math.min(y,this.size-this.iWrite);return g.copy(this.buffer,this.iWrite,b,b+w),this.iWrite+=w,w}}const m=function(p){p=p||{},this.bufSize=p.bufSize||1048576,this.buffers=[],this.batch=p.batch||!1,this.corked=!1,this.inPos=0,this.outPos=0,this.pipes=[],this.paused=!1,this.encoding=null};l.inherits(m,c.Duplex,{toBuffer(){switch(this.buffers.length){case 0:return null;case 1:return this.buffers[0].toBuffer();default:return i.concat(this.buffers.map(p=>p.toBuffer()))}},_getWritableBuffer(){if(this.buffers.length){const g=this.buffers[this.buffers.length-1];if(!g.full)return g}const p=new f(this.bufSize);return this.buffers.push(p),p},async _pipe(p){await Promise.all(this.pipes.map((function(g){return new Promise(b=>{g.write(p.toBuffer(),()=>{b()})})})))},_writeToBuffers(p){let g=0;const b=p.length;for(;g<b;)g+=this._getWritableBuffer().write(p,g,b-g)},async write(p,g,b){let y;if(g instanceof Function&&(b=g,g="utf8"),b=b||l.nop,p instanceof a)y=new h(p);else if(p instanceof i)y=new d(p);else{if(!(typeof p=="string"||p instanceof String||p instanceof ArrayBuffer))throw new Error("Chunk must be one of type String, Buffer or StringBuf.");y=new u(p,g)}if(this.pipes.length)if(this.batch)for(this._writeToBuffers(y);!this.corked&&this.buffers.length>1;)this._pipe(this.buffers.shift());else this.corked?(this._writeToBuffers(y),o.nextTick(b)):(await this._pipe(y),b());else this.paused||this.emit("data",y.toBuffer()),this._writeToBuffers(y),this.emit("readable");return!0},cork(){this.corked=!0},_flush(){if(this.pipes.length)for(;this.buffers.length;)this._pipe(this.buffers.shift())},uncork(){this.corked=!1,this._flush()},end(p,g,b){const y=w=>{w?b(w):(this._flush(),this.pipes.forEach(C=>{C.end()}),this.emit("finish"))};p?this.write(p,g,y):y()},read(p){let g;if(p){for(g=[];p&&this.buffers.length&&!this.buffers[0].eod;){const b=this.buffers[0],y=b.read(p);p-=y.length,g.push(y),b.eod&&b.full&&this.buffers.shift()}return i.concat(g)}return g=this.buffers.map(b=>b.toBuffer()).filter(Boolean),this.buffers=[],i.concat(g)},setEncoding(p){this.encoding=p},pause(){this.paused=!0},resume(){this.paused=!1},isPaused(){return!!this.paused},pipe(p){this.pipes.push(p),!this.paused&&this.buffers.length&&this.end()},unpipe(p){this.pipes=this.pipes.filter(g=>g!==p)},unshift(){throw new Error("Not Implemented")},wrap(){throw new Error("Not Implemented")}}),n.exports=m}).call(this)}).call(this,t("_process"),t("buffer").Buffer)},{"./string-buf":25,"./utils":27,_process:467,buffer:220,"readable-stream":491}],25:[function(t,n,s){(function(o){(function(){n.exports=class{constructor(i){this._buf=o.alloc(i&&i.size||16384),this._encoding=i&&i.encoding||"utf8",this._inPos=0,this._buffer=void 0}get length(){return this._inPos}get capacity(){return this._buf.length}get buffer(){return this._buf}toBuffer(){return this._buffer||(this._buffer=o.alloc(this.length),this._buf.copy(this._buffer,0,0,this.length)),this._buffer}reset(i){i=i||0,this._buffer=void 0,this._inPos=i}_grow(i){let c=2*this._buf.length;for(;c<i;)c*=2;const l=o.alloc(c);this._buf.copy(l,0),this._buf=l}addText(i){this._buffer=void 0;let c=this._inPos+this._buf.write(i,this._inPos,this._encoding);for(;c>=this._buf.length-4;)this._grow(this._inPos+i.length),c=this._inPos+this._buf.write(i,this._inPos,this._encoding);this._inPos=c}addStringBuf(i){i.length&&(this._buffer=void 0,this.length+i.length>this.capacity&&this._grow(this.length+i.length),i._buf.copy(this._buf,this._inPos,0,i.length),this._inPos+=i.length)}}}).call(this)}).call(this,t("buffer").Buffer)},{buffer:220}],26:[function(t,n,s){const{toString:o}=Object.prototype,i=/["&<>]/,c={each:function(l,a){l&&(Array.isArray(l)?l.forEach(a):Object.keys(l).forEach(u=>{a(l[u],u)}))},some:function(l,a){return!!l&&(Array.isArray(l)?l.some(a):Object.keys(l).some(u=>a(l[u],u)))},every:function(l,a){return!l||(Array.isArray(l)?l.every(a):Object.keys(l).every(u=>a(l[u],u)))},map:function(l,a){return l?Array.isArray(l)?l.map(a):Object.keys(l).map(u=>a(l[u],u)):[]},keyBy:(l,a)=>l.reduce((u,h)=>(u[h[a]]=h,u),{}),isEqual:function(l,a){const u=typeof l,h=typeof a,d=Array.isArray(l),f=Array.isArray(a);let m;if(u!==h)return!1;switch(typeof l){case"object":if(d||f)return!(!d||!f)&&l.length===a.length&&l.every((p,g)=>{const b=a[g];return c.isEqual(p,b)});if(l===null||a===null)return l===a;if(m=Object.keys(l),Object.keys(a).length!==m.length)return!1;for(const p of m)if(!a.hasOwnProperty(p))return!1;return c.every(l,(p,g)=>{const b=a[g];return c.isEqual(p,b)});default:return l===a}},escapeHtml(l){const a=i.exec(l);if(!a)return l;let u="",h="",d=0,f=a.index;for(;f<l.length;f++){switch(l.charAt(f)){case'"':h=""";break;case"&":h="&";break;case"'":h="'";break;case"<":h="<";break;case">":h=">";break;default:continue}d!==f&&(u+=l.substring(d,f)),d=f+1,u+=h}return d!==f?u+l.substring(d,f):u},strcmp:(l,a)=>l<a?-1:l>a?1:0,isUndefined:l=>o.call(l)==="[object Undefined]",isObject:l=>o.call(l)==="[object Object]",deepMerge(){const l=arguments[0]||{},{length:a}=arguments;let u,h,d;function f(m,p){u=l[p],d=Array.isArray(m),c.isObject(m)||d?(d?(d=!1,h=u&&Array.isArray(u)?u:[]):h=u&&c.isObject(u)?u:{},l[p]=c.deepMerge(h,m)):c.isUndefined(m)||(l[p]=m)}for(let m=0;m<a;m++)c.each(arguments[m],f);return l}};n.exports=c},{}],27:[function(t,n,s){(function(o,i){(function(){const c=t("fs"),l=/[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/,a={nop(){},promiseImmediate:u=>new Promise(h=>{o.setImmediate?i(()=>{h(u)}):setTimeout(()=>{h(u)},1)}),inherits:function(u,h,d,f){u.super_=h,f||(f=d,d=null),d&&Object.keys(d).forEach(p=>{Object.defineProperty(u,p,Object.getOwnPropertyDescriptor(d,p))});const m={constructor:{value:u,enumerable:!1,writable:!1,configurable:!0}};f&&Object.keys(f).forEach(p=>{m[p]=Object.getOwnPropertyDescriptor(f,p)}),u.prototype=Object.create(h.prototype,m)},dateToExcel:(u,h)=>25569+u.getTime()/864e5-(h?1462:0),excelToDate(u,h){const d=Math.round(24*(u-25569+(h?1462:0))*3600*1e3);return new Date(d)},parsePath(u){const h=u.lastIndexOf("/");return{path:u.substring(0,h),name:u.substring(h+1)}},getRelsPath(u){const h=a.parsePath(u);return`${h.path}/_rels/${h.name}.rels`},xmlEncode(u){const h=l.exec(u);if(!h)return u;let d="",f="",m=0,p=h.index;for(;p<u.length;p++){const g=u.charCodeAt(p);switch(g){case 34:f=""";break;case 38:f="&";break;case 39:f="'";break;case 60:f="<";break;case 62:f=">";break;case 127:f="";break;default:if(g<=31&&(g<=8||g>=11&&g!==13)){f="";break}continue}m!==p&&(d+=u.substring(m,p)),m=p+1,f&&(d+=f)}return m!==p?d+u.substring(m,p):d},xmlDecode:u=>u.replace(/&([a-z]*);/g,h=>{switch(h){case"<":return"<";case">":return">";case"&":return"&";case"'":return"'";case""":return'"';default:return h}}),validInt(u){const h=parseInt(u,10);return Number.isNaN(h)?0:h},isDateFmt(u){return u?(u=(u=u.replace(/\[[^\]]*]/g,"")).replace(/"[^"]*"/g,"")).match(/[ymdhMsb]+/)!==null:!1},fs:{exists:u=>new Promise(h=>{c.access(u,c.constants.F_OK,d=>{h(!d)})})},toIsoDateString:u=>u.toIsoString().subsstr(0,10),parseBoolean:u=>u===!0||u==="true"||u===1||u==="1"};n.exports=a}).call(this)}).call(this,typeof Cr<"u"?Cr:typeof self<"u"?self:typeof window<"u"?window:{},t("timers").setImmediate)},{fs:216,timers:523}],28:[function(t,n,s){const o=t("./under-dash"),i=t("./utils");function c(u,h,d){u.push(` ${h}="${i.xmlEncode(d.toString())}"`)}function l(u,h){if(h){const d=[];o.each(h,(f,m)=>{f!==void 0&&c(d,m,f)}),u.push(d.join(""))}}class a{constructor(){this._xml=[],this._stack=[],this._rollbacks=[]}get tos(){return this._stack.length?this._stack[this._stack.length-1]:void 0}get cursor(){return this._xml.length}openXml(h){const d=this._xml;d.push("<?xml"),l(d,h),d.push(`?>
|
|
80
|
+
</grid>`}function jae(e,r,t){const n=e??Nu(r,t.primaryIdAttribute);return Bae({...n,objectTypeCode:t.objectTypeCode,primaryIdAttribute:t.primaryIdAttribute,jumpAttribute:n.jumpAttribute||t.primaryNameAttribute||void 0})}function A7(e,r){return Cp(e).map(t=>{const n=t.isRoot?r?.get(t.attribute.name):r?.get(`${t.container.name}.${t.attribute.name}`);return{name:t.key,width:_ae(n),...t.linkAlias?{linkEntityAlias:t.linkAlias}:{}}})}function Nu(e,r,t){const n=A7(e,t);return{gridName:"resultset",jumpAttribute:void 0,enableSelection:!0,showIcon:!0,enablePreview:!0,primaryIdAttribute:r,columns:n}}function Nae(e,r,t){const n=A7(r,t),s=new Set(n.map(c=>c.name)),o=new Set(e.columns.map(c=>c.name)),i=e.columns.filter(c=>s.has(c.name));for(const c of n)o.has(c.name)||i.push(c);return{...e,columns:i}}function Eae(e,r,t){return{...e,columns:e.columns.map(n=>n.name===r?{...n,width:t}:n)}}function Aae(e,r,t){const n=[...e.columns],[s]=n.splice(r,1);return n.splice(t,0,s),{...e,columns:n}}let Rae=0;const co=()=>`node_${++Rae}`,R7={fetchQuery:null,selectedNodeId:null,selectedNode:null,loadedView:null,columnConfig:null,layoutNeedsSync:!1,retrieveAllRecords:!1,columnFilterId:null,columnFilterWrapperId:null};function h0(e,r,t,n){const s=e.selectedNodeId?jn(r,e.selectedNodeId):null;return{...e,fetchQuery:r,columnFilterId:t,columnFilterWrapperId:t?n:null,selectedNodeId:s?e.selectedNodeId:r.entity.id,selectedNode:s??r.entity,loadedView:null}}function jn(e,r){if(!e||typeof e!="object")return null;const t=e;if(t.id===r)return e;const n=["attributes","orders","filters","conditions","subfilters","links"];for(const s of n)if(Array.isArray(t[s]))for(const o of t[s]){const i=jn(o,r);if(i)return i}if(t.entity){const s=jn(t.entity,r);if(s)return s}if(t.allAttributes){const s=jn(t.allAttributes,r);if(s)return s}return null}function uo(e,r,t){if(e.id===r)return t(e);const n={...e};let s=!1;const o=["attributes","orders","filters","conditions","subfilters","links"];for(const c of o){const l=e[c];if(Array.isArray(l)){const a=l.map(u=>{const h=uo(u,r,t);return h!==u&&(s=!0),h});s&&(n[c]=a)}}const i=e;if(i.entity){const c=uo(i.entity,r,t);c!==i.entity&&(n.entity=c,s=!0)}if(i.allAttributes){const c=uo(i.allAttributes,r,t);c!==i.allAttributes&&(n.allAttributes=c,s=!0)}return s?n:e}function Tb(e,r){const t=e;if(e.id===r&&(t.type==="fetch"||t.type==="entity"))return e;const n={...e};let s=!1;const o=["attributes","orders","filters","conditions","subfilters","links"];for(const i of o){const c=t[i];if(Array.isArray(c)){const l=c.filter(a=>a.id!==r).map(a=>Tb(a,r)).filter(a=>a!==null);(l.length!==c.length||l.some((a,u)=>a!==c[u]))&&(n[i]=l,s=!0)}}if(t.entity){const i=Tb(t.entity,r);i!==t.entity&&(n.entity=i,s=!0)}return t.allAttributes&&t.allAttributes.id===r&&(delete n.allAttributes,s=!0),s?n:e}function zae(e,r){switch(r.type){case"NEW_QUERY":return R7;case"LOAD_FETCHXML":{const t=r.fetchNode,n=r.preserveLayout===!0&&e.columnConfig!==null,s=n?e.columnConfig:Nu(t),o=_re(e.fetchQuery,t,e.columnFilterId);return{fetchQuery:t,selectedNodeId:t.entity.id,selectedNode:t.entity,loadedView:null,columnConfig:s,layoutNeedsSync:n,retrieveAllRecords:e.retrieveAllRecords,columnFilterId:o,columnFilterWrapperId:Sre(e.fetchQuery,t,e.columnFilterWrapperId,o)}}case"LOAD_VIEW":{const t=r.fetchNode;let n;if(r.layoutXml)try{n=Cae(r.layoutXml)}catch(s){console.warn("Failed to parse view layoutxml, generating from FetchXML:",s),n=Nu(t)}else n=Nu(t);return{fetchQuery:t,selectedNodeId:t.entity.id,selectedNode:t.entity,loadedView:r.viewInfo,columnConfig:n,layoutNeedsSync:!1,retrieveAllRecords:e.retrieveAllRecords,columnFilterId:null,columnFilterWrapperId:null}}case"CLEAR_LOADED_VIEW":return{...e,loadedView:null,layoutNeedsSync:!0};case"SET_LOADED_VIEW":return{...e,loadedView:r.viewInfo};case"SET_ENTITY":{const t={id:co(),type:"entity",name:r.entityName,attributes:[],orders:[],filters:[],links:[]};return{fetchQuery:{id:co(),type:"fetch",entity:t,options:{count:50}},selectedNodeId:t.id,selectedNode:t,loadedView:null,columnConfig:null,layoutNeedsSync:!1,retrieveAllRecords:e.retrieveAllRecords,columnFilterId:null,columnFilterWrapperId:null}}case"SELECT_NODE":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.nodeId);return{...e,selectedNodeId:r.nodeId,selectedNode:t}}case"ADD_ATTRIBUTE":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity")return e;const n={id:co(),type:"attribute",name:"new_attribute"},s=uo(e.fetchQuery,r.parentId,o=>{const i=o;return{...i,attributes:[...i.attributes,n]}});return{...e,fetchQuery:s,selectedNodeId:n.id,selectedNode:n,loadedView:null,layoutNeedsSync:!0}}case"ADD_ATTRIBUTE_BY_NAME":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity")return e;const n=t.attributes.find(i=>i.name===r.attributeName);if(n)return{...e,selectedNodeId:n.id,selectedNode:n};const s={id:co(),type:"attribute",name:r.attributeName},o=uo(e.fetchQuery,r.parentId,i=>{const c=i;return{...c,attributes:[...c.attributes,s]}});return{...e,fetchQuery:o,selectedNodeId:s.id,selectedNode:s,loadedView:null,layoutNeedsSync:!0}}case"ADD_ALL_ATTRIBUTES":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity")return e;const n={id:co(),type:"all-attributes",enabled:!0},s=uo(e.fetchQuery,r.parentId,o=>({...o,allAttributes:n}));return{...e,fetchQuery:s,selectedNodeId:n.id,selectedNode:n,loadedView:null,layoutNeedsSync:!0}}case"UPDATE_ATTRIBUTES":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity")return e;const s=t.attributes,o=r.attributeNames,i=new Set(s.map(h=>h.name)),c=new Set(o),l=o.filter(h=>!i.has(h)),a=s.filter(h=>c.has(h.name));l.forEach(h=>{a.push({id:co(),type:"attribute",name:h})});const u=uo(e.fetchQuery,r.parentId,h=>({...h,attributes:a}));return{...e,fetchQuery:u,loadedView:null,layoutNeedsSync:!0}}case"ADD_ORDER":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity")return e;const n={id:co(),type:"order",attribute:"new_attribute",descending:!1},s=uo(e.fetchQuery,r.parentId,o=>{const i=o;return{...i,orders:[...i.orders,n]}});return{...e,fetchQuery:s,selectedNodeId:n.id,selectedNode:n,loadedView:null}}case"ADD_FILTER":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity")return e;const n={id:co(),type:"filter",conjunction:"and",conditions:[],subfilters:[],links:[]},s=uo(e.fetchQuery,r.parentId,o=>{const i=o;return{...i,filters:[...i.filters,n]}});return{...e,fetchQuery:s,selectedNodeId:n.id,selectedNode:n,loadedView:null}}case"ADD_SUBFILTER":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.filterId);if(!t||t.type!=="filter")return e;const n={id:co(),type:"filter",conjunction:"and",conditions:[],subfilters:[],links:[]},s=uo(e.fetchQuery,r.filterId,o=>{const i=o;return{...i,subfilters:[...i.subfilters,n]}});return{...e,fetchQuery:s,selectedNodeId:n.id,selectedNode:n,loadedView:null}}case"ADD_CONDITION":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.filterId);if(!t||t.type!=="filter")return e;const n={id:co(),type:"condition",attribute:"new_attribute",operator:"eq"},s=uo(e.fetchQuery,r.filterId,o=>{const i=o;return{...i,conditions:[...i.conditions,n]}});return{...e,fetchQuery:s,selectedNodeId:n.id,selectedNode:n,loadedView:null}}case"ADD_LINK_ENTITY":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity"&&t.type!=="filter")return e;const n=J0(e.fetchQuery),s=eb("new_entity",n),o={id:co(),type:"link-entity",name:"new_entity",alias:s,from:"id_field",to:"parent_id_field",linkType:t.type==="filter"?"any":"inner",attributes:[],orders:[],filters:[],links:[]},i=uo(e.fetchQuery,r.parentId,c=>{const l=c;if(l.type==="filter"){const a=l;return{...a,links:[...a.links||[],o]}}else{const a=l;return{...a,links:[...a.links,o]}}});return{...e,fetchQuery:i,selectedNodeId:o.id,selectedNode:o,loadedView:null,layoutNeedsSync:!0}}case"ADD_LINK_ENTITY_WITH_CONFIG":{if(!e.fetchQuery)return e;const t=jn(e.fetchQuery,r.parentId);if(!t||t.type!=="entity"&&t.type!=="link-entity")return e;const n=J0(e.fetchQuery),s=eb(r.name,n),o={id:r.id,type:"link-entity",name:r.name,alias:s,from:r.from,to:r.to,linkType:r.linkType,relationshipType:r.relationshipType??"N1",attributes:[],orders:[],filters:[],links:[]},i=uo(e.fetchQuery,r.parentId,c=>{const l=c;return{...l,links:[...l.links,o]}});return{...e,fetchQuery:i,selectedNodeId:o.id,selectedNode:o,loadedView:null,layoutNeedsSync:!0}}case"ADD_COLUMN_FILTER":{if(!e.fetchQuery)return e;const t=xre(e.fetchQuery,e.columnFilterId,r.condition,co);return h0(e,t.fetch,t.groupId,t.wrapperId??e.columnFilterWrapperId)}case"REMOVE_COLUMN_FILTER":{if(!e.fetchQuery)return e;const t=kre(e.fetchQuery,e.columnFilterId,r.conditionId,e.columnFilterWrapperId);return h0(e,t.fetch,t.groupId,e.columnFilterWrapperId)}case"CLEAR_COLUMN_FILTERS":{if(!e.fetchQuery)return e;const t=W_(e.fetchQuery,e.columnFilterId,e.columnFilterWrapperId);return h0(e,t,null,null)}case"REMOVE_NODE":{if(!e.fetchQuery)return e;const t=Tb(e.fetchQuery,r.nodeId);if(!t)return e;const n=e.selectedNodeId===r.nodeId?null:e.selectedNodeId,s=n?jn(t,n):null;return{...e,fetchQuery:t,selectedNodeId:n,selectedNode:s,loadedView:null,layoutNeedsSync:!0}}case"UPDATE_NODE":{if(!e.fetchQuery||!jn(e.fetchQuery,r.nodeId))return e;const n=uo(e.fetchQuery,r.nodeId,o=>{const i=o;if(i.type==="fetch"){const c=o;return{...c,options:{...c.options,...r.updates}}}return{...i,...r.updates}}),s=e.selectedNodeId===r.nodeId?jn(n,r.nodeId):e.selectedNode;return{...e,fetchQuery:n,selectedNode:s,loadedView:null,layoutNeedsSync:!0}}case"SET_COLUMN_CONFIG":return{...e,columnConfig:r.config,layoutNeedsSync:!1};case"UPDATE_COLUMN_WIDTH":return e.columnConfig?{...e,columnConfig:Eae(e.columnConfig,r.columnName,r.width)}:e;case"REORDER_COLUMNS":return e.columnConfig?{...e,columnConfig:Aae(e.columnConfig,r.fromIndex,r.toIndex)}:e;case"SYNC_LAYOUT_WITH_FETCHXML":{if(!e.fetchQuery)return e;let t;if(e.columnConfig)t=Nae(e.columnConfig,e.fetchQuery,r.attributeTypeMap);else if(r.primaryIdAttribute)t=Nu(e.fetchQuery,r.primaryIdAttribute,r.attributeTypeMap);else return e;return{...e,columnConfig:t,layoutNeedsSync:!1}}case"SET_SORT":{if(!e.fetchQuery?.entity)return e;const{plan:t,descending:n,isMultiSort:s}=r,o=d=>(d.attribute??void 0)===(t.spec.attribute??void 0)&&(d.alias??void 0)===(t.spec.alias??void 0)&&(d.entityname??void 0)===(t.spec.entityname??void 0),i={id:co(),type:"order",...t.spec.attribute?{attribute:t.spec.attribute}:{},...t.spec.alias?{alias:t.spec.alias}:{},...t.spec.entityname?{entityname:t.spec.entityname}:{},descending:n||void 0},c=d=>{const f=d.findIndex(o);return f>=0?d.map((m,p)=>p===f?{...m,descending:n||void 0}:m):[...d,i]},l=d=>d.map(f=>({...f,orders:[],links:l(f.links)})),a=t.insideLink?.id,u=d=>d.map(f=>f.id===a?{...f,orders:s?c(f.orders):[i],links:u(f.links)}:{...f,links:u(f.links)});let h=e.fetchQuery.entity;return s||(h={...h,orders:[],links:l(h.links)}),h=a?{...h,links:u(h.links)}:{...h,orders:s?c(h.orders):[i]},{...e,fetchQuery:{...e.fetchQuery,entity:h}}}case"SET_RETRIEVE_ALL_RECORDS":return{...e,retrieveAllRecords:r.enabled};default:return e}}function Iae({children:e}){const[r,t]=A.useReducer(zae,R7),n=A.useMemo(()=>({setEntity:o=>t({type:"SET_ENTITY",entityName:o}),selectNode:o=>t({type:"SELECT_NODE",nodeId:o}),addAttribute:o=>t({type:"ADD_ATTRIBUTE",parentId:o}),addAttributeByName:(o,i)=>t({type:"ADD_ATTRIBUTE_BY_NAME",parentId:o,attributeName:i}),updateAttributes:(o,i)=>t({type:"UPDATE_ATTRIBUTES",parentId:o,attributeNames:i}),addAllAttributes:o=>t({type:"ADD_ALL_ATTRIBUTES",parentId:o}),addOrder:o=>t({type:"ADD_ORDER",parentId:o}),addFilter:o=>t({type:"ADD_FILTER",parentId:o}),addSubfilter:o=>t({type:"ADD_SUBFILTER",filterId:o}),addCondition:o=>t({type:"ADD_CONDITION",filterId:o}),addLinkEntity:o=>t({type:"ADD_LINK_ENTITY",parentId:o}),addLinkEntityWithConfig:(o,i,c,l,a,u)=>{const h=co();return t({type:"ADD_LINK_ENTITY_WITH_CONFIG",id:h,parentId:o,name:i,from:c,to:l,linkType:a,relationshipType:u}),h},removeNode:o=>t({type:"REMOVE_NODE",nodeId:o}),updateNode:(o,i)=>t({type:"UPDATE_NODE",nodeId:o,updates:i}),newQuery:()=>t({type:"NEW_QUERY"}),loadFetchXml:(o,i)=>{const c=el(o);return c.success&&c.fetchNode&&t({type:"LOAD_FETCHXML",fetchNode:c.fetchNode,preserveLayout:i?.preserveLayout}),c},loadView:(o,i,c)=>{const l=el(o);return l.success&&l.fetchNode&&t({type:"LOAD_VIEW",fetchNode:l.fetchNode,viewInfo:{...i,originalFetchXml:ya(l.fetchNode)},layoutXml:c}),l},clearLoadedView:()=>t({type:"CLEAR_LOADED_VIEW"}),setLoadedView:o=>t({type:"SET_LOADED_VIEW",viewInfo:{...o}}),setColumnConfig:o=>t({type:"SET_COLUMN_CONFIG",config:o}),updateColumnWidth:(o,i)=>t({type:"UPDATE_COLUMN_WIDTH",columnName:o,width:i}),reorderColumns:(o,i)=>t({type:"REORDER_COLUMNS",fromIndex:o,toIndex:i}),syncLayoutWithFetchXml:(o,i)=>t({type:"SYNC_LAYOUT_WITH_FETCHXML",attributeTypeMap:o,primaryIdAttribute:i}),setSort:(o,i,c)=>t({type:"SET_SORT",plan:o,descending:i,isMultiSort:c}),setRetrieveAllRecords:o=>t({type:"SET_RETRIEVE_ALL_RECORDS",enabled:o}),addColumnFilter:o=>t({type:"ADD_COLUMN_FILTER",condition:o}),removeColumnFilter:o=>t({type:"REMOVE_COLUMN_FILTER",conditionId:o}),clearColumnFilters:()=>t({type:"CLEAR_COLUMN_FILTERS"})}),[]),s=A.useMemo(()=>({...r,...n}),[r,n]);return j.jsx(N7.Provider,{value:s,children:e})}function Mae({isDark:e,children:r}){return j.jsx(C_.Provider,{value:{isDark:e},children:r})}const Dae=wr({content:{display:"flex",flexDirection:"column",gap:le.spacingVerticalM},warningRow:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,color:le.colorPaletteRedForeground1},successRow:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,color:le.colorPaletteGreenForeground1},recordInfo:{backgroundColor:le.colorNeutralBackground3,padding:le.spacingVerticalS,borderRadius:le.borderRadiusMedium},errorMessage:{color:le.colorPaletteRedForeground1,marginTop:le.spacingVerticalS},progressSection:{display:"flex",flexDirection:"column",gap:le.spacingVerticalS},progressStats:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:le.spacingVerticalXS},eta:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200},resultSummary:{display:"flex",flexDirection:"column",gap:le.spacingVerticalXS}});function Pae({open:e,recordName:r,entityDisplayName:t,entityLogicalName:n,recordCount:s,onClose:o,onConfirm:i,onProgress:c}){const l=Dae(),[a,u]=A.useState("confirm"),[h,d]=A.useState(null),[f,m]=A.useState(null),[p,g]=A.useState(null),[b,y]=A.useState(!1);A.useEffect(()=>{c&&g(c)},[c]);const w=A.useCallback(async()=>{u("deleting"),d(null),g(null),m(null);try{const G=await i();G?(m(G),G.failed===0?u("success"):G.succeeded===0?(u("error"),d(`All ${G.failed} delete(s) failed`)):u("partial")):u("success")}catch(G){d(zn(G,"Failed to delete record(s)")),u("error")}},[i]),C=A.useCallback(()=>{a!=="deleting"&&(u("confirm"),d(null),m(null),g(null),o())},[a,o]),N=G=>{if(G<60)return`~${G}s remaining`;const U=Math.floor(G/60),E=Math.floor(U/60);if(U<60){const S=G%60;return`~${U}m ${S}s remaining`}if(E<12){const S=U%60;return`~${E}h ${S}m remaining`}const M=new Date(Date.now()+G*1e3),B=M.toDateString()===new Date().toDateString(),k=M.toDateString()===new Date(Date.now()+864e5).toDateString(),_=M.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return B?`Est. completion: today at ${_}`:k?`Est. completion: tomorrow at ${_}`:`Est. completion: ${M.toLocaleDateString([],{month:"short",day:"numeric"})} at ${_}`},I=s===1,$=I?"Delete record":`Delete ${s} records`,D=I?`Are you sure you want to delete this ${t||"record"}?`:`Are you sure you want to delete ${s} ${t||"records"}?`,F=()=>{switch(a){case"confirm":return j.jsxs(j.Fragment,{children:[j.jsx(yd,{entityLogicalName:n,entityDisplayName:t,scope:{kind:"records",count:s},onConfirmationChange:y}),j.jsxs("div",{className:l.warningRow,children:[j.jsx(hh,{}),j.jsx(st,{weight:"semibold",children:"This action cannot be undone."})]}),j.jsx(st,{children:D}),I&&r&&j.jsx("div",{className:l.recordInfo,children:j.jsx(st,{weight:"semibold",children:r})})]});case"deleting":return j.jsxs("div",{className:l.progressSection,children:[j.jsx(Ar,{intent:"info",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Deleting records..."}),p&&j.jsxs(j.Fragment,{children:["Processing batch ",p.batchesCompleted," of ",p.totalBatches]})]})}),p&&j.jsxs(j.Fragment,{children:[j.jsx(hd,{value:p.completed/p.total,max:1}),j.jsxs("div",{className:l.progressStats,children:[j.jsxs(st,{size:200,children:[p.completed," of ",p.total," (",p.succeeded," succeeded,"," ",p.failed," failed)"]}),p.estimatedSecondsRemaining!==void 0&&p.estimatedSecondsRemaining>0&&j.jsx(st,{className:l.eta,children:N(p.estimatedSecondsRemaining)})]})]}),!p&&j.jsxs("div",{style:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},children:[j.jsx(hn,{size:"small"}),j.jsx(st,{children:"Deleting..."})]})]});case"success":return j.jsx(j.Fragment,{children:j.jsxs("div",{className:l.successRow,children:[j.jsx(cd,{}),j.jsx(st,{weight:"semibold",children:f?`Successfully deleted ${f.succeeded} record(s)!`:"Record(s) deleted successfully!"})]})});case"partial":return j.jsxs(j.Fragment,{children:[j.jsx(Ar,{intent:"warning",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Partial success"}),f&&j.jsxs(j.Fragment,{children:[f.succeeded," of ",f.succeeded+f.failed," records deleted.",f.failed," failed."]})]})}),f&&f.errors.length>0&&j.jsxs("div",{className:l.resultSummary,children:[j.jsx(st,{weight:"semibold",size:200,children:"Errors:"}),f.errors.slice(0,5).map((G,U)=>j.jsx(st,{size:200,className:l.errorMessage,children:G},U)),f.errors.length>5&&j.jsxs(st,{size:200,className:l.errorMessage,children:["...and ",f.errors.length-5," more errors"]})]})]});case"error":return j.jsxs(j.Fragment,{children:[j.jsxs("div",{className:l.warningRow,children:[j.jsx(k4,{}),j.jsx(st,{weight:"semibold",children:"Delete failed"})]}),j.jsx(st,{className:l.errorMessage,children:h}),f&&f.errors.length>0&&j.jsxs("div",{className:l.resultSummary,children:[j.jsx(st,{weight:"semibold",size:200,children:"Errors:"}),f.errors.slice(0,5).map((G,U)=>j.jsx(st,{size:200,className:l.errorMessage,children:G},U)),f.errors.length>5&&j.jsxs(st,{size:200,className:l.errorMessage,children:["...and ",f.errors.length-5," more errors"]})]})]})}},V=()=>{switch(a){case"confirm":return j.jsxs(j.Fragment,{children:[j.jsx(St,{appearance:"secondary",onClick:C,children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:w,disabled:!b,children:"Delete"})]});case"deleting":return j.jsx(St,{appearance:"secondary",disabled:!0,children:"Cancel"});case"success":case"partial":case"error":return j.jsx(St,{appearance:"primary",onClick:C,children:"Close"})}};return j.jsx(Do,{open:e,onOpenChange:(G,U)=>!U.open&&C(),children:j.jsxs(zi,{children:[j.jsx(Ri,{children:$}),j.jsx(Ai,{children:j.jsx(Ii,{className:l.content,children:F()})}),j.jsx(Po,{children:V()})]})})}const Oae=wr({messageBarBody:{minWidth:0},content:{display:"flex",flexDirection:"column",gap:le.spacingVerticalM},warningRow:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,color:le.colorPaletteRedForeground1},dangerWarning:{backgroundColor:le.colorPaletteRedBackground1,padding:le.spacingVerticalM,borderRadius:le.borderRadiusMedium,border:`1px solid ${le.colorPaletteRedBorder1}`},successRow:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,color:le.colorPaletteGreenForeground1},infoBox:{backgroundColor:le.colorNeutralBackground3,padding:le.spacingVerticalM,borderRadius:le.borderRadiusMedium},jobUrlRow:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,marginTop:le.spacingVerticalS},errorMessage:{color:le.colorPaletteRedForeground1,marginTop:le.spacingVerticalS},confirmCheckbox:{marginTop:le.spacingVerticalS}});function Fae({open:e,recordCount:r,entityDisplayName:t,entityLogicalName:n,isAllRecords:s=!1,totalViewRecords:o,moreRecords:i,onClose:c,onConfirm:l}){const a=Oae(),[u,h]=A.useState("confirm"),[d,f]=A.useState(`Bulk Delete ${t||"Records"} - ${new Date().toLocaleString()}`),[m,p]=A.useState(null),[g,b]=A.useState(null),[y,w]=A.useState(!1),[C,N]=A.useState(!1),[I,$]=A.useState(!1),D=A.useCallback(async()=>{h("submitting"),p(null);try{const M=await l(d);b(M),h("success")}catch(M){p(zn(M,"Failed to submit bulk delete job")),h("error")}},[l,d]),F=A.useCallback(()=>{u!=="submitting"&&(h("confirm"),p(null),b(null),w(!1),N(!1),c())},[u,c]),V=A.useCallback(async()=>{g?.jobUrl&&await ws(g.jobUrl)&&(w(!0),setTimeout(()=>w(!1),2e3))},[g]),G=A.useCallback(()=>{g?.jobUrl&&j8(g.jobUrl)},[g]),U=()=>{switch(u){case"confirm":return j.jsxs(j.Fragment,{children:[j.jsx(yd,{entityLogicalName:n,entityDisplayName:t,scope:s?{kind:"allMatching",loadedCount:o,moreRecords:i}:{kind:"records",count:r},onConfirmationChange:$}),s?j.jsxs(j.Fragment,{children:[j.jsx(Ar,{intent:"error",children:j.jsxs(Rr,{className:a.messageBarBody,children:[j.jsx(Hr,{children:"Danger zone"}),"This will delete ALL records matching your current FetchXML query!"]})}),j.jsxs("div",{className:a.dangerWarning,children:[j.jsxs("div",{className:a.warningRow,children:[j.jsx(FR,{}),j.jsx(st,{weight:"semibold",children:"You have not selected any records. This will delete ALL records returned from the view."})]}),j.jsx(st,{style:{marginTop:le.spacingVerticalS,display:"block"},children:"This is a destructive operation that cannot be undone. The bulk delete job will delete every record that matches your FetchXML query."})]}),j.jsx(ho,{className:a.confirmCheckbox,checked:C,onChange:(M,B)=>N(B.checked===!0),label:"I understand that this will delete ALL records from the view"})]}):j.jsxs(j.Fragment,{children:[j.jsxs("div",{className:a.warningRow,children:[j.jsx(hh,{}),j.jsx(st,{weight:"semibold",children:"This action cannot be undone."})]}),j.jsxs(st,{children:["You are about to delete ",r," ",t||"records",". This will create a background job to process the deletion."]})]}),j.jsx(Eo,{label:"Job name",required:!0,children:j.jsx(_n,{value:d,onChange:(M,B)=>f(B.value),placeholder:"Enter a name for the bulk delete job"})}),j.jsx(st,{size:200,style:{color:le.colorNeutralForeground3},children:"You can track the progress of the job in the System Jobs area."})]});case"submitting":return j.jsx("div",{className:a.infoBox,children:j.jsxs("div",{style:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},children:[j.jsx(hn,{size:"small"}),j.jsx(st,{children:"Submitting bulk delete job..."})]})});case"success":return j.jsxs(j.Fragment,{children:[j.jsxs("div",{className:a.successRow,children:[j.jsx(cd,{}),j.jsx(st,{weight:"semibold",children:"Bulk delete job submitted successfully!"})]}),j.jsxs("div",{className:a.infoBox,children:[j.jsx(st,{children:"The bulk delete job has been submitted and will run in the background. You can track its progress using the link below."}),g?.jobUrl&&j.jsxs("div",{className:a.jobUrlRow,children:[j.jsx(dd,{onClick:G,children:"Open job status"}),j.jsx(St,{appearance:"subtle",size:"small",icon:j.jsx(wc,{}),onClick:V,children:y?"Copied!":"Copy URL"})]}),g?.asyncOperationId&&j.jsxs(st,{size:200,style:{marginTop:le.spacingVerticalS,color:le.colorNeutralForeground3},children:["Job ID: ",g.asyncOperationId]})]})]});case"error":return j.jsxs(j.Fragment,{children:[j.jsxs("div",{className:a.warningRow,children:[j.jsx(hh,{}),j.jsx(st,{weight:"semibold",children:"Failed to submit bulk delete job"})]}),j.jsx(st,{className:a.errorMessage,children:m}),j.jsx(st,{size:200,children:"Please check your permissions and try again. You need the prvBulkDelete privilege to submit bulk delete jobs."})]})}},E=()=>{switch(u){case"confirm":return j.jsxs(j.Fragment,{children:[j.jsx(St,{appearance:"secondary",onClick:F,children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:D,disabled:!d.trim()||s&&!C||!I,children:"Submit bulk delete"})]});case"submitting":return j.jsx(St,{appearance:"secondary",disabled:!0,children:"Cancel"});case"success":case"error":return j.jsx(St,{appearance:"primary",onClick:F,children:"Close"})}};return j.jsx(Do,{open:e,onOpenChange:(M,B)=>!B.open&&F(),children:j.jsxs(zi,{children:[j.jsx(Ri,{children:s?`Bulk delete all matching ${t||"records"}`:`Bulk delete ${r} records`}),j.jsx(Ai,{children:j.jsx(Ii,{className:a.content,children:U()})}),j.jsx(Po,{children:E()})]})})}const qae=wr({content:{display:"flex",flexDirection:"column",gap:le.spacingVerticalM},workflowList:{maxHeight:"300px",overflowY:"auto",border:`1px solid ${le.colorNeutralStroke1}`,borderRadius:le.borderRadiusMedium,padding:le.spacingVerticalS},workflowOption:{display:"flex",flexDirection:"column",padding:le.spacingVerticalXS},workflowDescription:{marginLeft:"28px",color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200},progressSection:{display:"flex",flexDirection:"column",gap:le.spacingVerticalS},progressStats:{display:"flex",justifyContent:"space-between",alignItems:"center"},eta:{color:le.colorNeutralForeground3,fontSize:le.fontSizeBase200},resultSection:{display:"flex",flexDirection:"column",gap:le.spacingVerticalS},successRow:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,color:le.colorPaletteGreenForeground1},errorRow:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,color:le.colorPaletteRedForeground1},emptyState:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:le.spacingVerticalXXL,color:le.colorNeutralForeground3},loadingState:{display:"flex",alignItems:"center",justifyContent:"center",padding:le.spacingVerticalXL,gap:le.spacingHorizontalS}});function Lae({open:e,recordCount:r,entityDisplayName:t,entityLogicalName:n,preSelectedWorkflow:s,onClose:o,onFetchWorkflows:i,onExecute:c}){const l=qae(),[a,u]=A.useState("loading"),[h,d]=A.useState([]),[f,m]=A.useState(null),[p,g]=A.useState(null),[b,y]=A.useState(null),[w,C]=A.useState(!1),[N,I]=A.useState(null);A.useEffect(()=>{e&&(u("loading"),m(null),g(null),I(null),y(null),i().then(E=>{if(d(E),u("select"),s){const M=E.find(B=>B.workflowid===s.workflowid);M&&m(M.workflowid)}else E.length===1&&m(E[0].workflowid)}).catch(E=>{g(zn(E,"Failed to load workflows")),u("error")}))},[e,i,s]);const $=A.useCallback(async()=>{const E=h.find(M=>M.workflowid===f);if(E){u("executing"),y(null),g(null);try{const M=await c(E,B=>{y(B)});I(M),u("complete")}catch(M){g(zn(M,"Failed to execute workflow")),u("error")}}},[h,f,c]),D=A.useCallback(()=>{a!=="executing"&&o()},[a,o]),F=h.find(E=>E.workflowid===f),V=E=>{if(E<60)return`~${E}s remaining`;const M=Math.floor(E/60),B=Math.floor(M/60);if(M<60){const z=E%60;return`~${M}m ${z}s remaining`}if(B<12){const z=M%60;return`~${B}h ${z}m remaining`}const k=new Date(Date.now()+E*1e3),_=k.toDateString()===new Date().toDateString(),S=k.toDateString()===new Date(Date.now()+864e5).toDateString(),T=k.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return _?`Est. completion: today at ${T}`:S?`Est. completion: tomorrow at ${T}`:`Est. completion: ${k.toLocaleDateString([],{month:"short",day:"numeric"})} at ${T}`},G=()=>{switch(a){case"loading":return j.jsxs("div",{className:l.loadingState,children:[j.jsx(hn,{size:"small"}),j.jsx(st,{children:"Loading available workflows..."})]});case"select":return h.length===0?j.jsxs("div",{className:l.emptyState,children:[j.jsx(st,{weight:"semibold",children:"No workflows available"}),j.jsxs(st,{size:200,children:["There are no on-demand workflows configured for ",t||"this entity","."]})]}):j.jsxs(j.Fragment,{children:[j.jsx(yd,{entityLogicalName:n,entityDisplayName:t,scope:{kind:"records",count:r},onConfirmationChange:C}),j.jsxs(st,{children:["Select a workflow to run on ",r," ",r===1?"record":"records",":"]}),j.jsx("div",{className:l.workflowList,children:j.jsx(ta,{value:f||"",onChange:(E,M)=>m(M.value),children:h.map(E=>j.jsxs("div",{className:l.workflowOption,children:[j.jsx(Yr,{value:E.workflowid,label:E.name}),E.description&&j.jsx(st,{className:l.workflowDescription,children:E.description})]},E.workflowid))})})]});case"executing":return j.jsxs("div",{className:l.progressSection,children:[j.jsx(Ar,{intent:"info",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Running workflow..."}),"Executing ",j.jsx("strong",{children:F?.name})," on ",r," records",b&&` (batch ${b.batchesCompleted} of ${b.totalBatches})`]})}),b?j.jsxs(j.Fragment,{children:[j.jsx(hd,{value:b.completed,max:b.total,thickness:"large"}),j.jsxs("div",{className:l.progressStats,children:[j.jsxs(st,{size:200,children:[b.completed," of ",b.total," completed (",b.succeeded," ","succeeded, ",b.failed," failed)"]}),b.estimatedSecondsRemaining!==void 0&&b.estimatedSecondsRemaining>0&&j.jsx(st,{className:l.eta,children:V(b.estimatedSecondsRemaining)})]})]}):j.jsxs("div",{style:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},children:[j.jsx(hn,{size:"small"}),j.jsx(st,{children:"Starting workflow execution..."})]})]});case"complete":return j.jsxs("div",{className:l.resultSection,children:[N&&N.succeeded>0&&j.jsxs("div",{className:l.successRow,children:[j.jsx(cd,{}),j.jsxs(st,{weight:"semibold",children:[N.succeeded," record",N.succeeded!==1?"s":""," processed successfully"]})]}),N&&N.failed>0&&j.jsxs(j.Fragment,{children:[j.jsxs("div",{className:l.errorRow,children:[j.jsx(hh,{}),j.jsxs(st,{weight:"semibold",children:[N.failed," record",N.failed!==1?"s":""," failed"]})]}),N.errors.length>0&&j.jsx(Ar,{intent:"error",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Errors:"}),N.errors.slice(0,5).map((E,M)=>j.jsx(st,{size:200,block:!0,children:E},M)),N.errors.length>5&&j.jsxs(st,{size:200,children:["...and ",N.errors.length-5," more"]})]})})]})]});case"error":return j.jsx(Ar,{intent:"error",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Error"}),p]})})}},U=()=>{switch(a){case"loading":return j.jsx(St,{appearance:"secondary",onClick:D,children:"Cancel"});case"select":return j.jsxs(j.Fragment,{children:[j.jsx(St,{appearance:"secondary",onClick:D,children:"Cancel"}),j.jsx(St,{appearance:"primary",icon:j.jsx(R0,{}),onClick:$,disabled:!f||h.length===0||!w,children:"Run workflow"})]});case"executing":return j.jsx(St,{appearance:"secondary",disabled:!0,children:"Running..."});case"complete":case"error":return j.jsx(St,{appearance:"primary",onClick:D,children:"Close"})}};return j.jsx(Do,{open:e,onOpenChange:(E,M)=>!M.open&&D(),children:j.jsxs(zi,{children:[j.jsx(Ri,{children:"Run workflow"}),j.jsx(Ai,{children:j.jsx(Ii,{className:l.content,children:G()})}),j.jsx(Po,{children:U()})]})})}const $ae=wr({content:{display:"flex",flexDirection:"column",gap:le.spacingVerticalM},row:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS},success:{display:"flex",alignItems:"center",gap:le.spacingHorizontalS,color:le.colorPaletteGreenForeground1},errors:{display:"flex",flexDirection:"column",gap:le.spacingVerticalXS},errorText:{color:le.colorPaletteRedForeground1}}),bk=e=>`${e.statecode}:${e.statuscode}`;function Hae({open:e,action:r,recordIds:t,entityLogicalName:n,entityDisplayName:s,primaryIdAttribute:o,onClose:i,onExecute:c}){const l=$ae(),[a,u]=A.useState("loading"),[h,d]=A.useState(null),[f,m]=A.useState(null),[p,g]=A.useState(null),[b,y]=A.useState(null),[w,C]=A.useState(null),[N,I]=A.useState(!1),$=A.useRef(o);$.current=o;const D=r==="activate"?"Activate":"Deactivate",F=t.length;A.useEffect(()=>{if(!e||!n)return;let _=!0;return u("loading"),d(null),m(null),g(null),y(null),C(null),(async()=>{const S=await f_(n);if(!S)return{kind:"none",reason:"This entity has no Status (statecode) column."};const T=$.current,z=S.enforceTransitions&&T?await mJ(n,T,t):void 0;return QQ(S,r,z,n)})().then(S=>{_&&(d(S),S.kind==="simple"&&m(S.target),S.kind==="choose"&&m(S.defaultTarget),u("confirm"))}).catch(S=>{_&&(g(zn(S,"Couldn't read the entity's status options")),u("error"))}),()=>{_=!1}},[e,n,t,r]);const V=A.useMemo(()=>{if(h?.kind!=="choose"||!f)return;const _=h.groups.find(T=>T.statecode===f.statecode),S=_?.choices.find(T=>T.statuscode===f.statuscode);return _&&S?{group:_,choice:S}:void 0},[h,f]),G=A.useCallback(async()=>{if(f){u("running"),y(null);try{const _=await c(f,y);C(_),_.succeeded===0&&_.failed>0?(g(`All ${_.failed} records failed.`),u("error")):u("done")}catch(_){g(zn(_,`${D} failed`)),u("error")}}},[f,c,D]),U=A.useCallback(()=>{a!=="running"&&i()},[a,i]),E=f?K8(n,f.statecode):void 0,M=()=>w&&w.errors.length>0?j.jsxs("div",{className:l.errors,children:[w.errors.slice(0,5).map((_,S)=>j.jsx(st,{size:200,className:l.errorText,children:_},S)),w.errors.length>5&&j.jsxs(st,{size:200,className:l.errorText,children:["...and ",w.errors.length-5," more"]})]}):null,B=()=>{switch(a){case"loading":return j.jsxs("div",{className:l.row,children:[j.jsx(hn,{size:"small"}),j.jsx(st,{children:"Reading the status options..."})]});case"confirm":return j.jsxs(j.Fragment,{children:[j.jsx(yd,{entityLogicalName:n,entityDisplayName:s,scope:{kind:"records",count:F},onConfirmationChange:I}),h?.kind==="none"&&j.jsx(Ar,{intent:"warning",layout:"multiline",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Nothing to change"}),h.reason]})}),h?.kind==="simple"&&j.jsxs(st,{children:["Sets Status to ",j.jsx("strong",{children:h.stateLabel})," and Status Reason to"," ",j.jsx("strong",{children:h.statusLabel}),"."]}),h?.kind==="choose"&&j.jsxs(j.Fragment,{children:[h.note&&j.jsx(Ar,{intent:"info",layout:"multiline",children:j.jsx(Rr,{children:h.note})}),j.jsx(Eo,{label:"Status reason",hint:"Grouped by Status. The default for each Status is marked.",children:j.jsx(po,{value:V?`${V.group.label}: ${V.choice.label}`:"",selectedOptions:f?[bk(f)]:[],onOptionSelect:(_,S)=>{const[T,z]=(S.optionValue??"").split(":").map(Number);Number.isFinite(T)&&Number.isFinite(z)&&m({statecode:T,statuscode:z})},children:h.groups.map(_=>j.jsx(ja,{label:_.label,children:_.choices.map(S=>j.jsx(Jt,{value:bk({statecode:_.statecode,statuscode:S.statuscode}),text:`${_.label}: ${S.label}`,children:S.isDefault?`${S.label} (default)`:S.label},S.statuscode))},_.statecode))})})]}),E&&j.jsx(Ar,{intent:"warning",layout:"multiline",children:j.jsx(Rr,{children:E})})]});case"running":return j.jsxs(j.Fragment,{children:[j.jsx(Ar,{intent:"info",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Updating records..."}),b&&`Batch ${b.batchesCompleted} of ${b.totalBatches}`]})}),b?j.jsxs(j.Fragment,{children:[j.jsx(hd,{value:b.completed/b.total,max:1}),j.jsxs(st,{size:200,children:[b.completed," of ",b.total," (",b.succeeded," succeeded, ",b.failed," failed)"]})]}):j.jsxs("div",{className:l.row,children:[j.jsx(hn,{size:"small"}),j.jsx(st,{children:"Updating..."})]})]});case"done":return w&&w.failed>0?j.jsxs(j.Fragment,{children:[j.jsx(Ar,{intent:"warning",layout:"multiline",children:j.jsxs(Rr,{children:[j.jsx(Hr,{children:"Partly done"}),w.succeeded," of ",w.succeeded+w.failed," records updated. ",w.failed," failed."]})}),M()]}):j.jsxs("div",{className:l.success,children:[j.jsx(cd,{}),j.jsx(st,{weight:"semibold",children:w?.succeeded===1?"1 record updated.":`${w?.succeeded??0} records updated.`})]});case"error":return j.jsxs(j.Fragment,{children:[j.jsx(Ar,{intent:"error",layout:"multiline",children:j.jsxs(Rr,{children:[j.jsxs(Hr,{children:[D," failed"]}),p]})}),M()]})}},k=()=>{switch(a){case"loading":case"confirm":return j.jsxs(j.Fragment,{children:[j.jsx(St,{appearance:"secondary",onClick:U,children:"Cancel"}),j.jsx(St,{appearance:"primary",onClick:G,disabled:a!=="confirm"||!f||h?.kind==="none"||!N,children:D})]});case"running":return j.jsx(St,{appearance:"secondary",disabled:!0,children:"Cancel"});case"done":case"error":return j.jsx(St,{appearance:"primary",onClick:U,children:"Close"})}};return j.jsx(Do,{open:e,onOpenChange:(_,S)=>!S.open&&U(),children:j.jsx(zi,{children:j.jsxs(Ai,{children:[j.jsx(Ri,{children:`${D} ${F===1?"1 record":`${F} records`}`}),j.jsx(Ii,{className:l.content,children:B()}),j.jsx(Po,{children:k()})]})})})}function Uf(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var p0={exports:{}};var vk;function Vae(){return vk||(vk=1,(function(e,r){(function(t){e.exports=t()})((function(){return(function t(n,s,o){function i(a,u){if(!s[a]){if(!n[a]){var h=typeof Uf=="function"&&Uf;if(!u&&h)return h(a,!0);if(c)return c(a,!0);var d=new Error("Cannot find module '"+a+"'");throw d.code="MODULE_NOT_FOUND",d}var f=s[a]={exports:{}};n[a][0].call(f.exports,(function(m){return i(n[a][1][m]||m)}),f,f.exports,t,n,s,o)}return s[a].exports}for(var c=typeof Uf=="function"&&Uf,l=0;l<o.length;l++)i(o[l]);return i})({1:[function(t,n,s){const o=t("fs"),i=t("fast-csv"),c=t("dayjs/plugin/customParseFormat"),l=t("dayjs/plugin/utc"),a=t("dayjs").extend(c).extend(l),u=t("../utils/stream-buf"),{fs:{exists:h}}=t("../utils/utils"),d={true:!0,false:!1,"#N/A":{error:"#N/A"},"#REF!":{error:"#REF!"},"#NAME?":{error:"#NAME?"},"#DIV/0!":{error:"#DIV/0!"},"#NULL!":{error:"#NULL!"},"#VALUE!":{error:"#VALUE!"},"#NUM!":{error:"#NUM!"}};n.exports=class{constructor(f){this.workbook=f,this.worksheet=null}async readFile(f,m){if(m=m||{},!await h(f))throw new Error("File not found: "+f);const p=o.createReadStream(f),g=await this.read(p,m);return p.close(),g}read(f,m){return m=m||{},new Promise((p,g)=>{const b=this.workbook.addWorksheet(m.sheetName),y=m.dateFormats||["YYYY-MM-DD[T]HH:mm:ssZ","YYYY-MM-DD[T]HH:mm:ss","MM-DD-YYYY","YYYY-MM-DD"],w=m.map||function(N){if(N==="")return null;const I=Number(N);if(!Number.isNaN(I)&&I!==1/0)return I;const $=y.reduce((F,V)=>{if(F)return F;const G=a(N,V,!0);return G.isValid()?G:null},null);if($)return new Date($.valueOf());const D=d[N];return D!==void 0?D:N},C=i.parse(m.parserOptions).on("data",N=>{b.addRow(N.map(w))}).on("end",()=>{C.emit("worksheet",b)});C.on("worksheet",p).on("error",g),f.pipe(C)})}createInputStream(){throw new Error("`CSV#createInputStream` is deprecated. You should use `CSV#read` instead. This method will be removed in version 5.0. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md")}write(f,m){return new Promise((p,g)=>{m=m||{};const b=this.workbook.getWorksheet(m.sheetName||m.sheetId),y=i.format(m.formatterOptions);f.on("finish",()=>{p()}),y.on("error",g),y.pipe(f);const{dateFormat:w,dateUTC:C}=m,N=m.map||(D=>{if(D){if(D.text||D.hyperlink)return D.hyperlink||D.text||"";if(D.formula||D.result)return D.result||"";if(D instanceof Date)return w?C?a.utc(D).format(w):a(D).format(w):C?a.utc(D).format():a(D).format();if(D.error)return D.error;if(typeof D=="object")return JSON.stringify(D)}return D}),I=m.includeEmptyRows===void 0||m.includeEmptyRows;let $=1;b&&b.eachRow((D,F)=>{if(I)for(;$++<F-1;)y.write([]);const{values:V}=D;V.shift(),y.write(V.map(N)),$=F}),y.end()})}writeFile(f,m){const p={encoding:(m=m||{}).encoding||"utf8"},g=o.createWriteStream(f,p);return this.write(g,m)}async writeBuffer(f){const m=new u;return await this.write(m,f),m.read()}}},{"../utils/stream-buf":24,"../utils/utils":27,dayjs:391,"dayjs/plugin/customParseFormat":392,"dayjs/plugin/utc":393,"fast-csv":424,fs:216}],2:[function(t,n,s){const o=t("../utils/col-cache");class i{constructor(l,a){let u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(this.worksheet=l,a)if(typeof a=="string"){const h=o.decodeAddress(a);this.nativeCol=h.col+u,this.nativeColOff=0,this.nativeRow=h.row+u,this.nativeRowOff=0}else a.nativeCol!==void 0?(this.nativeCol=a.nativeCol||0,this.nativeColOff=a.nativeColOff||0,this.nativeRow=a.nativeRow||0,this.nativeRowOff=a.nativeRowOff||0):a.col!==void 0?(this.col=a.col+u,this.row=a.row+u):(this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0);else this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0}static asInstance(l){return l instanceof i||l==null?l:new i(l)}get col(){return this.nativeCol+Math.min(this.colWidth-1,this.nativeColOff)/this.colWidth}set col(l){this.nativeCol=Math.floor(l),this.nativeColOff=Math.floor((l-this.nativeCol)*this.colWidth)}get row(){return this.nativeRow+Math.min(this.rowHeight-1,this.nativeRowOff)/this.rowHeight}set row(l){this.nativeRow=Math.floor(l),this.nativeRowOff=Math.floor((l-this.nativeRow)*this.rowHeight)}get colWidth(){return this.worksheet&&this.worksheet.getColumn(this.nativeCol+1)&&this.worksheet.getColumn(this.nativeCol+1).isCustomWidth?Math.floor(1e4*this.worksheet.getColumn(this.nativeCol+1).width):64e4}get rowHeight(){return this.worksheet&&this.worksheet.getRow(this.nativeRow+1)&&this.worksheet.getRow(this.nativeRow+1).height?Math.floor(1e4*this.worksheet.getRow(this.nativeRow+1).height):18e4}get model(){return{nativeCol:this.nativeCol,nativeColOff:this.nativeColOff,nativeRow:this.nativeRow,nativeRowOff:this.nativeRowOff}}set model(l){this.nativeCol=l.nativeCol,this.nativeColOff=l.nativeColOff,this.nativeRow=l.nativeRow,this.nativeRowOff=l.nativeRowOff}}n.exports=i},{"../utils/col-cache":19}],3:[function(t,n,s){const o=t("../utils/col-cache"),i=t("../utils/under-dash"),c=t("./enums"),{slideFormula:l}=t("../utils/shared-formula"),a=t("./note");class u{constructor(f,m,p){if(!f||!m)throw new Error("A Cell needs a Row");this._row=f,this._column=m,o.validateAddress(p),this._address=p,this._value=h.create(u.Types.Null,this),this.style=this._mergeStyle(f.style,m.style,{}),this._mergeCount=0}get worksheet(){return this._row.worksheet}get workbook(){return this._row.worksheet.workbook}destroy(){delete this.style,delete this._value,delete this._row,delete this._column,delete this._address}get numFmt(){return this.style.numFmt}set numFmt(f){this.style.numFmt=f}get font(){return this.style.font}set font(f){this.style.font=f}get alignment(){return this.style.alignment}set alignment(f){this.style.alignment=f}get border(){return this.style.border}set border(f){this.style.border=f}get fill(){return this.style.fill}set fill(f){this.style.fill=f}get protection(){return this.style.protection}set protection(f){this.style.protection=f}_mergeStyle(f,m,p){const g=f&&f.numFmt||m&&m.numFmt;g&&(p.numFmt=g);const b=f&&f.font||m&&m.font;b&&(p.font=b);const y=f&&f.alignment||m&&m.alignment;y&&(p.alignment=y);const w=f&&f.border||m&&m.border;w&&(p.border=w);const C=f&&f.fill||m&&m.fill;C&&(p.fill=C);const N=f&&f.protection||m&&m.protection;return N&&(p.protection=N),p}get address(){return this._address}get row(){return this._row.number}get col(){return this._column.number}get $col$row(){return`$${this._column.letter}$${this.row}`}get type(){return this._value.type}get effectiveType(){return this._value.effectiveType}toCsvString(){return this._value.toCsvString()}addMergeRef(){this._mergeCount++}releaseMergeRef(){this._mergeCount--}get isMerged(){return this._mergeCount>0||this.type===u.Types.Merge}merge(f,m){this._value.release(),this._value=h.create(u.Types.Merge,this,f),m||(this.style=f.style)}unmerge(){this.type===u.Types.Merge&&(this._value.release(),this._value=h.create(u.Types.Null,this),this.style=this._mergeStyle(this._row.style,this._column.style,{}))}isMergedTo(f){return this._value.type===u.Types.Merge&&this._value.isMergedTo(f)}get master(){return this.type===u.Types.Merge?this._value.master:this}get isHyperlink(){return this._value.type===u.Types.Hyperlink}get hyperlink(){return this._value.hyperlink}get value(){return this._value.value}set value(f){this.type!==u.Types.Merge?(this._value.release(),this._value=h.create(h.getType(f),this,f)):this._value.master.value=f}get note(){return this._comment&&this._comment.note}set note(f){this._comment=new a(f)}get text(){return this._value.toString()}get html(){return i.escapeHtml(this.text)}toString(){return this.text}_upgradeToHyperlink(f){this.type===u.Types.String&&(this._value=h.create(u.Types.Hyperlink,this,{text:this._value.value,hyperlink:f}))}get formula(){return this._value.formula}get result(){return this._value.result}get formulaType(){return this._value.formulaType}get fullAddress(){const{worksheet:f}=this._row;return{sheetName:f.name,address:this.address,row:this.row,col:this.col}}get name(){return this.names[0]}set name(f){this.names=[f]}get names(){return this.workbook.definedNames.getNamesEx(this.fullAddress)}set names(f){const{definedNames:m}=this.workbook;m.removeAllNames(this.fullAddress),f.forEach(p=>{m.addEx(this.fullAddress,p)})}addName(f){this.workbook.definedNames.addEx(this.fullAddress,f)}removeName(f){this.workbook.definedNames.removeEx(this.fullAddress,f)}removeAllNames(){this.workbook.definedNames.removeAllNames(this.fullAddress)}get _dataValidations(){return this.worksheet.dataValidations}get dataValidation(){return this._dataValidations.find(this.address)}set dataValidation(f){this._dataValidations.add(this.address,f)}get model(){const{model:f}=this._value;return f.style=this.style,this._comment&&(f.comment=this._comment.model),f}set model(f){this._value.release(),this._value=h.create(f.type,this),this._value.model=f,f.comment&&f.comment.type==="note"&&(this._comment=a.fromModel(f.comment)),f.style?this.style=f.style:this.style={}}}u.Types=c.ValueType;const h={getType:d=>d==null?u.Types.Null:d instanceof String||typeof d=="string"?u.Types.String:typeof d=="number"?u.Types.Number:typeof d=="boolean"?u.Types.Boolean:d instanceof Date?u.Types.Date:d.text&&d.hyperlink?u.Types.Hyperlink:d.formula||d.sharedFormula?u.Types.Formula:d.richText?u.Types.RichText:d.sharedString?u.Types.SharedString:d.error?u.Types.Error:u.Types.JSON,types:[{t:u.Types.Null,f:class{constructor(d){this.model={address:d.address,type:u.Types.Null}}get value(){return null}set value(d){}get type(){return u.Types.Null}get effectiveType(){return u.Types.Null}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return""}release(){}toString(){return""}}},{t:u.Types.Number,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.Number,value:f}}get value(){return this.model.value}set value(d){this.model.value=d}get type(){return u.Types.Number}get effectiveType(){return u.Types.Number}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}}},{t:u.Types.String,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.String,value:f}}get value(){return this.model.value}set value(d){this.model.value=d}get type(){return u.Types.String}get effectiveType(){return u.Types.String}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return`"${this.model.value.replace(/"/g,'""')}"`}release(){}toString(){return this.model.value}}},{t:u.Types.Date,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.Date,value:f}}get value(){return this.model.value}set value(d){this.model.value=d}get type(){return u.Types.Date}get effectiveType(){return u.Types.Date}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return this.model.value.toISOString()}release(){}toString(){return this.model.value.toString()}}},{t:u.Types.Hyperlink,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.Hyperlink,text:f?f.text:void 0,hyperlink:f?f.hyperlink:void 0},f&&f.tooltip&&(this.model.tooltip=f.tooltip)}get value(){const d={text:this.model.text,hyperlink:this.model.hyperlink};return this.model.tooltip&&(d.tooltip=this.model.tooltip),d}set value(d){this.model={text:d.text,hyperlink:d.hyperlink},d.tooltip&&(this.model.tooltip=d.tooltip)}get text(){return this.model.text}set text(d){this.model.text=d}get hyperlink(){return this.model.hyperlink}set hyperlink(d){this.model.hyperlink=d}get type(){return u.Types.Hyperlink}get effectiveType(){return u.Types.Hyperlink}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return this.model.hyperlink}release(){}toString(){return this.model.text}}},{t:u.Types.Formula,f:class{constructor(d,f){this.cell=d,this.model={address:d.address,type:u.Types.Formula,shareType:f?f.shareType:void 0,ref:f?f.ref:void 0,formula:f?f.formula:void 0,sharedFormula:f?f.sharedFormula:void 0,result:f?f.result:void 0}}_copyModel(d){const f={},m=p=>{const g=d[p];g&&(f[p]=g)};return m("formula"),m("result"),m("ref"),m("shareType"),m("sharedFormula"),f}get value(){return this._copyModel(this.model)}set value(d){this.model=this._copyModel(d)}validate(d){switch(h.getType(d)){case u.Types.Null:case u.Types.String:case u.Types.Number:case u.Types.Date:break;case u.Types.Hyperlink:case u.Types.Formula:default:throw new Error("Cannot process that type of result value")}}get dependencies(){return{ranges:this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g),cells:this.formula.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g,"").match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g)}}get formula(){return this.model.formula||this._getTranslatedFormula()}set formula(d){this.model.formula=d}get formulaType(){return this.model.formula?c.FormulaType.Master:this.model.sharedFormula?c.FormulaType.Shared:c.FormulaType.None}get result(){return this.model.result}set result(d){this.model.result=d}get type(){return u.Types.Formula}get effectiveType(){const d=this.model.result;return d==null?c.ValueType.Null:d instanceof String||typeof d=="string"?c.ValueType.String:typeof d=="number"?c.ValueType.Number:d instanceof Date?c.ValueType.Date:d.text&&d.hyperlink?c.ValueType.Hyperlink:d.formula?c.ValueType.Formula:c.ValueType.Null}get address(){return this.model.address}set address(d){this.model.address=d}_getTranslatedFormula(){if(!this._translatedFormula&&this.model.sharedFormula){const{worksheet:d}=this.cell,f=d.findCell(this.model.sharedFormula);this._translatedFormula=f&&l(f.formula,f.address,this.model.address)}return this._translatedFormula}toCsvString(){return""+(this.model.result||"")}release(){}toString(){return this.model.result?this.model.result.toString():""}}},{t:u.Types.Merge,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.Merge,master:f?f.address:void 0},this._master=f,f&&f.addMergeRef()}get value(){return this._master.value}set value(d){d instanceof u?(this._master&&this._master.releaseMergeRef(),d.addMergeRef(),this._master=d):this._master.value=d}isMergedTo(d){return d===this._master}get master(){return this._master}get type(){return u.Types.Merge}get effectiveType(){return this._master.effectiveType}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return""}release(){this._master.releaseMergeRef()}toString(){return this.value.toString()}}},{t:u.Types.JSON,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.String,value:JSON.stringify(f),rawValue:f}}get value(){return this.model.rawValue}set value(d){this.model.rawValue=d,this.model.value=JSON.stringify(d)}get type(){return u.Types.String}get effectiveType(){return u.Types.String}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return this.model.value}release(){}toString(){return this.model.value}}},{t:u.Types.SharedString,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.SharedString,value:f}}get value(){return this.model.value}set value(d){this.model.value=d}get type(){return u.Types.SharedString}get effectiveType(){return u.Types.SharedString}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}}},{t:u.Types.RichText,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.String,value:f}}get value(){return this.model.value}set value(d){this.model.value=d}toString(){return this.model.value.richText.map(d=>d.text).join("")}get type(){return u.Types.RichText}get effectiveType(){return u.Types.RichText}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return`"${this.text.replace(/"/g,'""')}"`}release(){}}},{t:u.Types.Boolean,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.Boolean,value:f}}get value(){return this.model.value}set value(d){this.model.value=d}get type(){return u.Types.Boolean}get effectiveType(){return u.Types.Boolean}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return this.model.value?1:0}release(){}toString(){return this.model.value.toString()}}},{t:u.Types.Error,f:class{constructor(d,f){this.model={address:d.address,type:u.Types.Error,value:f}}get value(){return this.model.value}set value(d){this.model.value=d}get type(){return u.Types.Error}get effectiveType(){return u.Types.Error}get address(){return this.model.address}set address(d){this.model.address=d}toCsvString(){return this.toString()}release(){}toString(){return this.model.value.error.toString()}}}].reduce((d,f)=>(d[f.t]=f.f,d),[]),create(d,f,m){const p=this.types[d];if(!p)throw new Error("Could not create Value of type "+d);return new p(f,m)}};n.exports=u},{"../utils/col-cache":19,"../utils/shared-formula":23,"../utils/under-dash":26,"./enums":7,"./note":9}],4:[function(t,n,s){const o=t("../utils/under-dash"),i=t("./enums"),c=t("../utils/col-cache");class l{constructor(u,h,d){this._worksheet=u,this._number=h,d!==!1&&(this.defn=d)}get number(){return this._number}get worksheet(){return this._worksheet}get letter(){return c.n2l(this._number)}get isCustomWidth(){return this.width!==void 0&&this.width!==9}get defn(){return{header:this._header,key:this.key,width:this.width,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel}}set defn(u){u?(this.key=u.key,this.width=u.width!==void 0?u.width:9,this.outlineLevel=u.outlineLevel,u.style?this.style=u.style:this.style={},this.header=u.header,this._hidden=!!u.hidden):(delete this._header,delete this._key,delete this.width,this.style={},this.outlineLevel=0)}get headers(){return this._header&&this._header instanceof Array?this._header:[this._header]}get header(){return this._header}set header(u){u!==void 0?(this._header=u,this.headers.forEach((h,d)=>{this._worksheet.getCell(d+1,this.number).value=h})):this._header=void 0}get key(){return this._key}set key(u){(this._key&&this._worksheet.getColumnKey(this._key))===this&&this._worksheet.deleteColumnKey(this._key),this._key=u,u&&this._worksheet.setColumnKey(this._key,this)}get hidden(){return!!this._hidden}set hidden(u){this._hidden=u}get outlineLevel(){return this._outlineLevel||0}set outlineLevel(u){this._outlineLevel=u}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelCol)}toString(){return JSON.stringify({key:this.key,width:this.width,headers:this.headers.length?this.headers:void 0})}equivalentTo(u){return this.width===u.width&&this.hidden===u.hidden&&this.outlineLevel===u.outlineLevel&&o.isEqual(this.style,u.style)}get isDefault(){if(this.isCustomWidth||this.hidden||this.outlineLevel)return!1;const u=this.style;return!u||!(u.font||u.numFmt||u.alignment||u.border||u.fill||u.protection)}get headerCount(){return this.headers.length}eachCell(u,h){const d=this.number;h||(h=u,u=null),this._worksheet.eachRow(u,(f,m)=>{h(f.getCell(d),m)})}get values(){const u=[];return this.eachCell((h,d)=>{h&&h.type!==i.ValueType.Null&&(u[d]=h.value)}),u}set values(u){if(!u)return;const h=this.number;let d=0;u.hasOwnProperty("0")&&(d=1),u.forEach((f,m)=>{this._worksheet.getCell(m+d,h).value=f})}_applyStyle(u,h){return this.style[u]=h,this.eachCell(d=>{d[u]=h}),h}get numFmt(){return this.style.numFmt}set numFmt(u){this._applyStyle("numFmt",u)}get font(){return this.style.font}set font(u){this._applyStyle("font",u)}get alignment(){return this.style.alignment}set alignment(u){this._applyStyle("alignment",u)}get protection(){return this.style.protection}set protection(u){this._applyStyle("protection",u)}get border(){return this.style.border}set border(u){this._applyStyle("border",u)}get fill(){return this.style.fill}set fill(u){this._applyStyle("fill",u)}static toModel(u){const h=[];let d=null;return u&&u.forEach((f,m)=>{f.isDefault?d&&(d=null):d&&f.equivalentTo(d)?d.max=m+1:(d={min:m+1,max:m+1,width:f.width!==void 0?f.width:9,style:f.style,isCustomWidth:f.isCustomWidth,hidden:f.hidden,outlineLevel:f.outlineLevel,collapsed:f.collapsed},h.push(d))}),h.length?h:void 0}static fromModel(u,h){const d=[];let f=1,m=0;for(h=(h=h||[]).sort((function(p,g){return p.min-g.min}));m<h.length;){const p=h[m++];for(;f<p.min;)d.push(new l(u,f++));for(;f<=p.max;)d.push(new l(u,f++,p))}return d.length?d:null}}n.exports=l},{"../utils/col-cache":19,"../utils/under-dash":26,"./enums":7}],5:[function(t,n,s){n.exports=class{constructor(o){this.model=o||{}}add(o,i){return this.model[o]=i}find(o){return this.model[o]}remove(o){this.model[o]=void 0}}},{}],6:[function(t,n,s){const o=t("../utils/under-dash"),i=t("../utils/col-cache"),c=t("../utils/cell-matrix"),l=t("./range"),a=/[$](\w+)[$](\d+)(:[$](\w+)[$](\d+))?/;n.exports=class{constructor(){this.matrixMap={}}getMatrix(u){return this.matrixMap[u]||(this.matrixMap[u]=new c)}add(u,h){const d=i.decodeEx(u);this.addEx(d,h)}addEx(u,h){const d=this.getMatrix(h);if(u.top)for(let f=u.left;f<=u.right;f++)for(let m=u.top;m<=u.bottom;m++){const p={sheetName:u.sheetName,address:i.n2l(f)+m,row:m,col:f};d.addCellEx(p)}else d.addCellEx(u)}remove(u,h){const d=i.decodeEx(u);this.removeEx(d,h)}removeEx(u,h){this.getMatrix(h).removeCellEx(u)}removeAllNames(u){o.each(this.matrixMap,h=>{h.removeCellEx(u)})}forEach(u){o.each(this.matrixMap,(h,d)=>{h.forEach(f=>{u(d,f)})})}getNames(u){return this.getNamesEx(i.decodeEx(u))}getNamesEx(u){return o.map(this.matrixMap,(h,d)=>h.findCellEx(u)&&d).filter(Boolean)}_explore(u,h){h.mark=!1;const{sheetName:d}=h,f=new l(h.row,h.col,h.row,h.col,d);let m,p;function g(y,w){const C=u.findCellAt(d,y,h.col);return!(!C||!C.mark)&&(f[w]=y,C.mark=!1,!0)}for(p=h.row-1;g(p,"top");p--);for(p=h.row+1;g(p,"bottom");p++);function b(y,w){const C=[];for(p=f.top;p<=f.bottom;p++){const N=u.findCellAt(d,p,y);if(!N||!N.mark)return!1;C.push(N)}f[w]=y;for(let N=0;N<C.length;N++)C[N].mark=!1;return!0}for(m=h.col-1;b(m,"left");m--);for(m=h.col+1;b(m,"right");m++);return f}getRanges(u,h){return(h=h||this.matrixMap[u])?(h.forEach(d=>{d.mark=!0}),{name:u,ranges:h.map(d=>d.mark&&this._explore(h,d)).filter(Boolean).map(d=>d.$shortRange)}):{name:u,ranges:[]}}normaliseMatrix(u,h){u.forEachInSheet(h,(d,f,m)=>{d&&(d.row===f&&d.col===m||(d.row=f,d.col=m,d.address=i.n2l(m)+f))})}spliceRows(u,h,d,f){o.each(this.matrixMap,m=>{m.spliceRows(u,h,d,f),this.normaliseMatrix(m,u)})}spliceColumns(u,h,d,f){o.each(this.matrixMap,m=>{m.spliceColumns(u,h,d,f),this.normaliseMatrix(m,u)})}get model(){return o.map(this.matrixMap,(u,h)=>this.getRanges(h,u)).filter(u=>u.ranges.length)}set model(u){const h=this.matrixMap={};u.forEach(d=>{const f=h[d.name]=new c;d.ranges.forEach(m=>{a.test(m.split("!").pop()||"")&&f.addCell(m)})})}}},{"../utils/cell-matrix":18,"../utils/col-cache":19,"../utils/under-dash":26,"./range":10}],7:[function(t,n,s){n.exports={ValueType:{Null:0,Merge:1,Number:2,String:3,Date:4,Hyperlink:5,Formula:6,SharedString:7,RichText:8,Boolean:9,Error:10},FormulaType:{None:0,Master:1,Shared:2},RelationshipType:{None:0,OfficeDocument:1,Worksheet:2,CalcChain:3,SharedStrings:4,Styles:5,Theme:6,Hyperlink:7},DocumentType:{Xlsx:1},ReadingOrder:{LeftToRight:1,RightToLeft:2},ErrorValue:{NotApplicable:"#N/A",Ref:"#REF!",Name:"#NAME?",DivZero:"#DIV/0!",Null:"#NULL!",Value:"#VALUE!",Num:"#NUM!"}}},{}],8:[function(t,n,s){const o=t("../utils/col-cache"),i=t("./anchor");n.exports=class{constructor(c,l){this.worksheet=c,this.model=l}get model(){switch(this.type){case"background":return{type:this.type,imageId:this.imageId};case"image":return{type:this.type,imageId:this.imageId,hyperlinks:this.range.hyperlinks,range:{tl:this.range.tl.model,br:this.range.br&&this.range.br.model,ext:this.range.ext,editAs:this.range.editAs}};default:throw new Error("Invalid Image Type")}}set model(c){let{type:l,imageId:a,range:u,hyperlinks:h}=c;if(this.type=l,this.imageId=a,l==="image")if(typeof u=="string"){const d=o.decode(u);this.range={tl:new i(this.worksheet,{col:d.left,row:d.top},-1),br:new i(this.worksheet,{col:d.right,row:d.bottom},0),editAs:"oneCell"}}else this.range={tl:new i(this.worksheet,u.tl,0),br:u.br&&new i(this.worksheet,u.br,0),ext:u.ext,editAs:u.editAs,hyperlinks:h||u.hyperlinks}}}},{"../utils/col-cache":19,"./anchor":2}],9:[function(t,n,s){const o=t("../utils/under-dash");class i{constructor(l){this.note=l}get model(){let l=null;return typeof this.note==="string"?l={type:"note",note:{texts:[{text:this.note}]}}:l={type:"note",note:this.note},o.deepMerge({},i.DEFAULT_CONFIGS,l)}set model(l){const{note:a}=l,{texts:u}=a;u.length===1&&Object.keys(u[0]).length===1?this.note=u[0].text:this.note=a}static fromModel(l){const a=new i;return a.model=l,a}}i.DEFAULT_CONFIGS={note:{margins:{insetmode:"auto",inset:[.13,.13,.25,.25]},protection:{locked:"True",lockText:"True"},editAs:"absolute"}},n.exports=i},{"../utils/under-dash":26}],10:[function(t,n,s){const o=t("../utils/col-cache");class i{constructor(){this.decode(arguments)}setTLBR(l,a,u,h,d){if(arguments.length<4){const f=o.decodeAddress(l),m=o.decodeAddress(a);this.model={top:Math.min(f.row,m.row),left:Math.min(f.col,m.col),bottom:Math.max(f.row,m.row),right:Math.max(f.col,m.col),sheetName:u},this.setTLBR(f.row,f.col,m.row,m.col,d)}else this.model={top:Math.min(l,u),left:Math.min(a,h),bottom:Math.max(l,u),right:Math.max(a,h),sheetName:d}}decode(l){switch(l.length){case 5:this.setTLBR(l[0],l[1],l[2],l[3],l[4]);break;case 4:this.setTLBR(l[0],l[1],l[2],l[3]);break;case 3:this.setTLBR(l[0],l[1],l[2]);break;case 2:this.setTLBR(l[0],l[1]);break;case 1:{const a=l[0];if(a instanceof i)this.model={top:a.model.top,left:a.model.left,bottom:a.model.bottom,right:a.model.right,sheetName:a.sheetName};else if(a instanceof Array)this.decode(a);else if(a.top&&a.left&&a.bottom&&a.right)this.model={top:a.top,left:a.left,bottom:a.bottom,right:a.right,sheetName:a.sheetName};else{const u=o.decodeEx(a);u.top?this.model={top:u.top,left:u.left,bottom:u.bottom,right:u.right,sheetName:u.sheetName}:this.model={top:u.row,left:u.col,bottom:u.row,right:u.col,sheetName:u.sheetName}}break}case 0:this.model={top:0,left:0,bottom:0,right:0};break;default:throw new Error("Invalid number of arguments to _getDimensions() - "+l.length)}}get top(){return this.model.top||1}set top(l){this.model.top=l}get left(){return this.model.left||1}set left(l){this.model.left=l}get bottom(){return this.model.bottom||1}set bottom(l){this.model.bottom=l}get right(){return this.model.right||1}set right(l){this.model.right=l}get sheetName(){return this.model.sheetName}set sheetName(l){this.model.sheetName=l}get _serialisedSheetName(){const{sheetName:l}=this.model;return l?/^[a-zA-Z0-9]*$/.test(l)?l+"!":`'${l}'!`:""}expand(l,a,u,h){(!this.model.top||l<this.top)&&(this.top=l),(!this.model.left||a<this.left)&&(this.left=a),(!this.model.bottom||u>this.bottom)&&(this.bottom=u),(!this.model.right||h>this.right)&&(this.right=h)}expandRow(l){if(l){const{dimensions:a,number:u}=l;a&&this.expand(u,a.min,u,a.max)}}expandToAddress(l){const a=o.decodeEx(l);this.expand(a.row,a.col,a.row,a.col)}get tl(){return o.n2l(this.left)+this.top}get $t$l(){return`$${o.n2l(this.left)}$${this.top}`}get br(){return o.n2l(this.right)+this.bottom}get $b$r(){return`$${o.n2l(this.right)}$${this.bottom}`}get range(){return`${this._serialisedSheetName+this.tl}:${this.br}`}get $range(){return`${this._serialisedSheetName+this.$t$l}:${this.$b$r}`}get shortRange(){return this.count>1?this.range:this._serialisedSheetName+this.tl}get $shortRange(){return this.count>1?this.$range:this._serialisedSheetName+this.$t$l}get count(){return(1+this.bottom-this.top)*(1+this.right-this.left)}toString(){return this.range}intersects(l){return(!l.sheetName||!this.sheetName||l.sheetName===this.sheetName)&&!(l.bottom<this.top)&&!(l.top>this.bottom)&&!(l.right<this.left)&&!(l.left>this.right)}contains(l){const a=o.decodeEx(l);return this.containsEx(a)}containsEx(l){return(!l.sheetName||!this.sheetName||l.sheetName===this.sheetName)&&l.row>=this.top&&l.row<=this.bottom&&l.col>=this.left&&l.col<=this.right}forEachAddress(l){for(let a=this.left;a<=this.right;a++)for(let u=this.top;u<=this.bottom;u++)l(o.encodeAddress(u,a),u,a)}}n.exports=i},{"../utils/col-cache":19}],11:[function(t,n,s){const o=t("../utils/under-dash"),i=t("./enums"),c=t("../utils/col-cache"),l=t("./cell");n.exports=class{constructor(a,u){this._worksheet=a,this._number=u,this._cells=[],this.style={},this.outlineLevel=0}get number(){return this._number}get worksheet(){return this._worksheet}commit(){this._worksheet._commitRow(this)}destroy(){delete this._worksheet,delete this._cells,delete this.style}findCell(a){return this._cells[a-1]}getCellEx(a){let u=this._cells[a.col-1];if(!u){const h=this._worksheet.getColumn(a.col);u=new l(this,h,a.address),this._cells[a.col-1]=u}return u}getCell(a){if(typeof a=="string"){const u=this._worksheet.getColumnKey(a);a=u?u.number:c.l2n(a)}return this._cells[a-1]||this.getCellEx({address:c.encodeAddress(this._number,a),row:this._number,col:a})}splice(a,u){const h=a+u;for(var d=arguments.length,f=new Array(d>2?d-2:0),m=2;m<d;m++)f[m-2]=arguments[m];const p=f.length-u,g=this._cells.length;let b,y,w;if(p<0)for(b=a+f.length;b<=g;b++)w=this._cells[b-1],y=this._cells[b-p-1],y?(w=this.getCell(b),w.value=y.value,w.style=y.style,w._comment=y._comment):w&&(w.value=null,w.style={},w._comment=void 0);else if(p>0)for(b=g;b>=h;b--)y=this._cells[b-1],y?(w=this.getCell(b+p),w.value=y.value,w.style=y.style,w._comment=y._comment):this._cells[b+p-1]=void 0;for(b=0;b<f.length;b++)w=this.getCell(a+b),w.value=f[b],w.style={},w._comment=void 0}eachCell(a,u){if(u||(u=a,a=null),a&&a.includeEmpty){const h=this._cells.length;for(let d=1;d<=h;d++)u(this.getCell(d),d)}else this._cells.forEach((h,d)=>{h&&h.type!==i.ValueType.Null&&u(h,d+1)})}addPageBreak(a,u){const h=this._worksheet,d=Math.max(0,a-1)||0,f=Math.max(0,u-1)||16838,m={id:this._number,max:f,man:1};d&&(m.min=d),h.rowBreaks.push(m)}get values(){const a=[];return this._cells.forEach(u=>{u&&u.type!==i.ValueType.Null&&(a[u.col]=u.value)}),a}set values(a){if(this._cells=[],a)if(a instanceof Array){let u=0;a.hasOwnProperty("0")&&(u=1),a.forEach((h,d)=>{h!==void 0&&(this.getCellEx({address:c.encodeAddress(this._number,d+u),row:this._number,col:d+u}).value=h)})}else this._worksheet.eachColumnKey((u,h)=>{a[h]!==void 0&&(this.getCellEx({address:c.encodeAddress(this._number,u.number),row:this._number,col:u.number}).value=a[h])})}get hasValues(){return o.some(this._cells,a=>a&&a.type!==i.ValueType.Null)}get cellCount(){return this._cells.length}get actualCellCount(){let a=0;return this.eachCell(()=>{a++}),a}get dimensions(){let a=0,u=0;return this._cells.forEach(h=>{h&&h.type!==i.ValueType.Null&&((!a||a>h.col)&&(a=h.col),u<h.col&&(u=h.col))}),a>0?{min:a,max:u}:null}_applyStyle(a,u){return this.style[a]=u,this._cells.forEach(h=>{h&&(h[a]=u)}),u}get numFmt(){return this.style.numFmt}set numFmt(a){this._applyStyle("numFmt",a)}get font(){return this.style.font}set font(a){this._applyStyle("font",a)}get alignment(){return this.style.alignment}set alignment(a){this._applyStyle("alignment",a)}get protection(){return this.style.protection}set protection(a){this._applyStyle("protection",a)}get border(){return this.style.border}set border(a){this._applyStyle("border",a)}get fill(){return this.style.fill}set fill(a){this._applyStyle("fill",a)}get hidden(){return!!this._hidden}set hidden(a){this._hidden=a}get outlineLevel(){return this._outlineLevel||0}set outlineLevel(a){this._outlineLevel=a}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelRow)}get model(){const a=[];let u=0,h=0;return this._cells.forEach(d=>{if(d){const f=d.model;f&&((!u||u>d.col)&&(u=d.col),h<d.col&&(h=d.col),a.push(f))}}),this.height||a.length?{cells:a,number:this.number,min:u,max:h,height:this.height,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel,collapsed:this.collapsed}:null}set model(a){if(a.number!==this._number)throw new Error("Invalid row number in model");let u;this._cells=[],a.cells.forEach(h=>{switch(h.type){case l.Types.Merge:break;default:{let d;if(h.address)d=c.decodeAddress(h.address);else if(u){const{row:f}=u,m=u.col+1;d={row:f,col:m,address:c.encodeAddress(f,m),$col$row:`$${c.n2l(m)}$${f}`}}u=d,this.getCellEx(d).model=h;break}}}),a.height?this.height=a.height:delete this.height,this.hidden=a.hidden,this.outlineLevel=a.outlineLevel||0,this.style=a.style&&JSON.parse(JSON.stringify(a.style))||{}}}},{"../utils/col-cache":19,"../utils/under-dash":26,"./cell":3,"./enums":7}],12:[function(t,n,s){const o=t("../utils/col-cache");class i{constructor(l,a,u){this.table=l,this.column=a,this.index=u}_set(l,a){this.table.cacheState(),this.column[l]=a}get name(){return this.column.name}set name(l){this._set("name",l)}get filterButton(){return this.column.filterButton}set filterButton(l){this.column.filterButton=l}get style(){return this.column.style}set style(l){this.column.style=l}get totalsRowLabel(){return this.column.totalsRowLabel}set totalsRowLabel(l){this._set("totalsRowLabel",l)}get totalsRowFunction(){return this.column.totalsRowFunction}set totalsRowFunction(l){this._set("totalsRowFunction",l)}get totalsRowResult(){return this.column.totalsRowResult}set totalsRowResult(l){this._set("totalsRowResult",l)}get totalsRowFormula(){return this.column.totalsRowFormula}set totalsRowFormula(l){this._set("totalsRowFormula",l)}}n.exports=class{constructor(c,l){this.worksheet=c,l&&(this.table=l,this.validate(),this.store())}getFormula(c){switch(c.totalsRowFunction){case"none":return null;case"average":return`SUBTOTAL(101,${this.table.name}[${c.name}])`;case"countNums":return`SUBTOTAL(102,${this.table.name}[${c.name}])`;case"count":return`SUBTOTAL(103,${this.table.name}[${c.name}])`;case"max":return`SUBTOTAL(104,${this.table.name}[${c.name}])`;case"min":return`SUBTOTAL(105,${this.table.name}[${c.name}])`;case"stdDev":return`SUBTOTAL(106,${this.table.name}[${c.name}])`;case"var":return`SUBTOTAL(107,${this.table.name}[${c.name}])`;case"sum":return`SUBTOTAL(109,${this.table.name}[${c.name}])`;case"custom":return c.totalsRowFormula;default:throw new Error("Invalid Totals Row Function: "+c.totalsRowFunction)}}get width(){return this.table.columns.length}get height(){return this.table.rows.length}get filterHeight(){return this.height+(this.table.headerRow?1:0)}get tableHeight(){return this.filterHeight+(this.table.totalsRow?1:0)}validate(){const{table:c}=this,l=(p,g,b)=>{p[g]===void 0&&(p[g]=b)};l(c,"headerRow",!0),l(c,"totalsRow",!1),l(c,"style",{}),l(c.style,"theme","TableStyleMedium2"),l(c.style,"showFirstColumn",!1),l(c.style,"showLastColumn",!1),l(c.style,"showRowStripes",!1),l(c.style,"showColumnStripes",!1);const a=(p,g)=>{if(!p)throw new Error(g)};a(c.ref,"Table must have ref"),a(c.columns,"Table must have column definitions"),a(c.rows,"Table must have row definitions"),c.tl=o.decodeAddress(c.ref);const{row:u,col:h}=c.tl;a(u>0,"Table must be on valid row"),a(h>0,"Table must be on valid col");const{width:d,filterHeight:f,tableHeight:m}=this;c.autoFilterRef=o.encode(u,h,u+f-1,h+d-1),c.tableRef=o.encode(u,h,u+m-1,h+d-1),c.columns.forEach((p,g)=>{a(p.name,`Column ${g} must have a name`),g===0?l(p,"totalsRowLabel","Total"):(l(p,"totalsRowFunction","none"),p.totalsRowFormula=this.getFormula(p))})}store(){const c=(f,m)=>{m&&Object.keys(m).forEach(p=>{f[p]=m[p]})},{worksheet:l,table:a}=this,{row:u,col:h}=a.tl;let d=0;if(a.headerRow){const f=l.getRow(u+d++);a.columns.forEach((m,p)=>{const{style:g,name:b}=m,y=f.getCell(h+p);y.value=b,c(y,g)})}if(a.rows.forEach(f=>{const m=l.getRow(u+d++);f.forEach((p,g)=>{const b=m.getCell(h+g);b.value=p,c(b,a.columns[g].style)})}),a.totalsRow){const f=l.getRow(u+d++);a.columns.forEach((m,p)=>{const g=f.getCell(h+p);if(p===0)g.value=m.totalsRowLabel;else{const b=this.getFormula(m);g.value=b?{formula:m.totalsRowFormula,result:m.totalsRowResult}:null}c(g,m.style)})}}load(c){const{table:l}=this,{row:a,col:u}=l.tl;let h=0;if(l.headerRow){const d=c.getRow(a+h++);l.columns.forEach((f,m)=>{d.getCell(u+m).value=f.name})}if(l.rows.forEach(d=>{const f=c.getRow(a+h++);d.forEach((m,p)=>{f.getCell(u+p).value=m})}),l.totalsRow){const d=c.getRow(a+h++);l.columns.forEach((f,m)=>{const p=d.getCell(u+m);m===0?p.value=f.totalsRowLabel:this.getFormula(f)&&(p.value={formula:f.totalsRowFormula,result:f.totalsRowResult})})}}get model(){return this.table}set model(c){this.table=c}cacheState(){this._cache||(this._cache={ref:this.ref,width:this.width,tableHeight:this.tableHeight})}commit(){if(!this._cache)return;this.validate();const c=o.decodeAddress(this._cache.ref);if(this.ref!==this._cache.ref)for(let l=0;l<this._cache.tableHeight;l++){const a=this.worksheet.getRow(c.row+l);for(let u=0;u<this._cache.width;u++)a.getCell(c.col+u).value=null}else{for(let l=this.tableHeight;l<this._cache.tableHeight;l++){const a=this.worksheet.getRow(c.row+l);for(let u=0;u<this._cache.width;u++)a.getCell(c.col+u).value=null}for(let l=0;l<this.tableHeight;l++){const a=this.worksheet.getRow(c.row+l);for(let u=this.width;u<this._cache.width;u++)a.getCell(c.col+u).value=null}}this.store()}addRow(c,l){this.cacheState(),l===void 0?this.table.rows.push(c):this.table.rows.splice(l,0,c)}removeRows(c){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;this.cacheState(),this.table.rows.splice(c,l)}getColumn(c){const l=this.table.columns[c];return new i(this,l,c)}addColumn(c,l,a){this.cacheState(),a===void 0?(this.table.columns.push(c),this.table.rows.forEach((u,h)=>{u.push(l[h])})):(this.table.columns.splice(a,0,c),this.table.rows.forEach((u,h)=>{u.splice(a,0,l[h])}))}removeColumns(c){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;this.cacheState(),this.table.columns.splice(c,l),this.table.rows.forEach(a=>{a.splice(c,l)})}_assign(c,l,a){this.cacheState(),c[l]=a}get ref(){return this.table.ref}set ref(c){this._assign(this.table,"ref",c)}get name(){return this.table.name}set name(c){this.table.name=c}get displayName(){return this.table.displyName||this.table.name}set displayNamename(c){this.table.displayName=c}get headerRow(){return this.table.headerRow}set headerRow(c){this._assign(this.table,"headerRow",c)}get totalsRow(){return this.table.totalsRow}set totalsRow(c){this._assign(this.table,"totalsRow",c)}get theme(){return this.table.style.name}set theme(c){this.table.style.name=c}get showFirstColumn(){return this.table.style.showFirstColumn}set showFirstColumn(c){this.table.style.showFirstColumn=c}get showLastColumn(){return this.table.style.showLastColumn}set showLastColumn(c){this.table.style.showLastColumn=c}get showRowStripes(){return this.table.style.showRowStripes}set showRowStripes(c){this.table.style.showRowStripes=c}get showColumnStripes(){return this.table.style.showColumnStripes}set showColumnStripes(c){this.table.style.showColumnStripes=c}}},{"../utils/col-cache":19}],13:[function(t,n,s){const o=t("./worksheet"),i=t("./defined-names"),c=t("../xlsx/xlsx"),l=t("../csv/csv");n.exports=class{constructor(){this.category="",this.company="",this.created=new Date,this.description="",this.keywords="",this.manager="",this.modified=this.created,this.properties={},this.calcProperties={},this._worksheets=[],this.subject="",this.title="",this.views=[],this.media=[],this._definedNames=new i}get xlsx(){return this._xlsx||(this._xlsx=new c(this)),this._xlsx}get csv(){return this._csv||(this._csv=new l(this)),this._csv}get nextId(){for(let a=1;a<this._worksheets.length;a++)if(!this._worksheets[a])return a;return this._worksheets.length||1}addWorksheet(a,u){const h=this.nextId;u&&(typeof u=="string"?(console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }'),u={properties:{tabColor:{argb:u}}}):(u.argb||u.theme||u.indexed)&&(console.trace("tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }"),u={properties:{tabColor:u}}));const d=this._worksheets.reduce((p,g)=>(g&&g.orderNo)>p?g.orderNo:p,0),f=Object.assign({},u,{id:h,name:a,orderNo:d+1,workbook:this}),m=new o(f);return this._worksheets[h]=m,m}removeWorksheetEx(a){delete this._worksheets[a.id]}removeWorksheet(a){const u=this.getWorksheet(a);u&&u.destroy()}getWorksheet(a){return a===void 0?this._worksheets.find(Boolean):typeof a=="number"?this._worksheets[a]:typeof a=="string"?this._worksheets.find(u=>u&&u.name===a):void 0}get worksheets(){return this._worksheets.slice(1).sort((a,u)=>a.orderNo-u.orderNo).filter(Boolean)}eachSheet(a){this.worksheets.forEach(u=>{a(u,u.id)})}get definedNames(){return this._definedNames}clearThemes(){this._themes=void 0}addImage(a){const u=this.media.length;return this.media.push(Object.assign({},a,{type:"image"})),u}getImage(a){return this.media[a]}get model(){return{creator:this.creator||"Unknown",lastModifiedBy:this.lastModifiedBy||"Unknown",lastPrinted:this.lastPrinted,created:this.created,modified:this.modified,properties:this.properties,worksheets:this.worksheets.map(a=>a.model),sheets:this.worksheets.map(a=>a.model).filter(Boolean),definedNames:this._definedNames.model,views:this.views,company:this.company,manager:this.manager,title:this.title,subject:this.subject,keywords:this.keywords,category:this.category,description:this.description,language:this.language,revision:this.revision,contentStatus:this.contentStatus,themes:this._themes,media:this.media,calcProperties:this.calcProperties}}set model(a){this.creator=a.creator,this.lastModifiedBy=a.lastModifiedBy,this.lastPrinted=a.lastPrinted,this.created=a.created,this.modified=a.modified,this.company=a.company,this.manager=a.manager,this.title=a.title,this.subject=a.subject,this.keywords=a.keywords,this.category=a.category,this.description=a.description,this.language=a.language,this.revision=a.revision,this.contentStatus=a.contentStatus,this.properties=a.properties,this.calcProperties=a.calcProperties,this._worksheets=[],a.worksheets.forEach(u=>{const{id:h,name:d,state:f}=u,m=a.sheets&&a.sheets.findIndex(p=>p.id===h);(this._worksheets[h]=new o({id:h,name:d,orderNo:m,state:f,workbook:this})).model=u}),this._definedNames.model=a.definedNames,this.views=a.views,this._themes=a.themes,this.media=a.media||[]}}},{"../csv/csv":1,"../xlsx/xlsx":144,"./defined-names":6,"./worksheet":14}],14:[function(t,n,s){const o=t("../utils/under-dash"),i=t("../utils/col-cache"),c=t("./range"),l=t("./row"),a=t("./column"),u=t("./enums"),h=t("./image"),d=t("./table"),f=t("./data-validations"),m=t("../utils/encryptor"),{copyStyle:p}=t("../utils/copy-style");n.exports=class{constructor(g){g=g||{},this._workbook=g.workbook,this.id=g.id,this.orderNo=g.orderNo,this.name=g.name,this.state=g.state||"visible",this._rows=[],this._columns=null,this._keys={},this._merges={},this.rowBreaks=[],this.properties=Object.assign({},{defaultRowHeight:15,dyDescent:55,outlineLevelCol:0,outlineLevelRow:0},g.properties),this.pageSetup=Object.assign({},{margins:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},orientation:"portrait",horizontalDpi:4294967295,verticalDpi:4294967295,fitToPage:!(!g.pageSetup||!g.pageSetup.fitToWidth&&!g.pageSetup.fitToHeight||g.pageSetup.scale),pageOrder:"downThenOver",blackAndWhite:!1,draft:!1,cellComments:"None",errors:"displayed",scale:100,fitToWidth:1,fitToHeight:1,paperSize:void 0,showRowColHeaders:!1,showGridLines:!1,firstPageNumber:void 0,horizontalCentered:!1,verticalCentered:!1,rowBreaks:null,colBreaks:null},g.pageSetup),this.headerFooter=Object.assign({},{differentFirst:!1,differentOddEven:!1,oddHeader:null,oddFooter:null,evenHeader:null,evenFooter:null,firstHeader:null,firstFooter:null},g.headerFooter),this.dataValidations=new f,this.views=g.views||[],this.autoFilter=g.autoFilter||null,this._media=[],this.sheetProtection=null,this.tables={},this.conditionalFormattings=[]}get name(){return this._name}set name(g){if(g===void 0&&(g="sheet"+this.id),this._name!==g){if(typeof g!="string")throw new Error("The name has to be a string.");if(g==="")throw new Error("The name can't be empty.");if(g==="History")throw new Error('The name "History" is protected. Please use a different name.');if(/[*?:/\\[\]]/.test(g))throw new Error(`Worksheet name ${g} cannot include any of the following characters: * ? : \\ / [ ]`);if(/(^')|('$)/.test(g))throw new Error("The first or last character of worksheet name cannot be a single quotation mark: "+g);if(g&&g.length>31&&(console.warn(`Worksheet name ${g} exceeds 31 chars. This will be truncated`),g=g.substring(0,31)),this._workbook._worksheets.find(b=>b&&b.name.toLowerCase()===g.toLowerCase()))throw new Error("Worksheet name already exists: "+g);this._name=g}}get workbook(){return this._workbook}destroy(){this._workbook.removeWorksheetEx(this)}get dimensions(){const g=new c;return this._rows.forEach(b=>{if(b){const y=b.dimensions;y&&g.expand(b.number,y.min,b.number,y.max)}}),g}get columns(){return this._columns}set columns(g){this._headerRowCount=g.reduce((w,C)=>{const N=(C.header?1:C.headers&&C.headers.length)||0;return Math.max(w,N)},0);let b=1;const y=this._columns=[];g.forEach(w=>{const C=new a(this,b++,!1);y.push(C),C.defn=w})}getColumnKey(g){return this._keys[g]}setColumnKey(g,b){this._keys[g]=b}deleteColumnKey(g){delete this._keys[g]}eachColumnKey(g){o.each(this._keys,g)}getColumn(g){if(typeof g=="string"){const b=this._keys[g];if(b)return b;g=i.l2n(g)}if(this._columns||(this._columns=[]),g>this._columns.length){let b=this._columns.length+1;for(;b<=g;)this._columns.push(new a(this,b++))}return this._columns[g-1]}spliceColumns(g,b){const y=this._rows.length;for(var w=arguments.length,C=new Array(w>2?w-2:0),N=2;N<w;N++)C[N-2]=arguments[N];if(C.length>0)for(let F=0;F<y;F++){const V=[g,b];C.forEach(U=>{V.push(U[F]||null)});const G=this.getRow(F+1);G.splice.apply(G,V)}else this._rows.forEach(F=>{F&&F.splice(g,b)});const I=C.length-b,$=g+b,D=this._columns.length;if(I<0)for(let F=g+C.length;F<=D;F++)this.getColumn(F).defn=this.getColumn(F-I).defn;else if(I>0)for(let F=D;F>=$;F--)this.getColumn(F+I).defn=this.getColumn(F).defn;for(let F=g;F<g+C.length;F++)this.getColumn(F).defn=null;this.workbook.definedNames.spliceColumns(this.name,g,b,C.length)}get lastColumn(){return this.getColumn(this.columnCount)}get columnCount(){let g=0;return this.eachRow(b=>{g=Math.max(g,b.cellCount)}),g}get actualColumnCount(){const g=[];let b=0;return this.eachRow(y=>{y.eachCell(w=>{let{col:C}=w;g[C]||(g[C]=!0,b++)})}),b}_commitRow(){}get _lastRowNumber(){const g=this._rows;let b=g.length;for(;b>0&&g[b-1]===void 0;)b--;return b}get _nextRow(){return this._lastRowNumber+1}get lastRow(){if(this._rows.length)return this._rows[this._rows.length-1]}findRow(g){return this._rows[g-1]}findRows(g,b){return this._rows.slice(g-1,g-1+b)}get rowCount(){return this._lastRowNumber}get actualRowCount(){let g=0;return this.eachRow(()=>{g++}),g}getRow(g){let b=this._rows[g-1];return b||(b=this._rows[g-1]=new l(this,g)),b}getRows(g,b){if(b<1)return;const y=[];for(let w=g;w<g+b;w++)y.push(this.getRow(w));return y}addRow(g){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"n";const y=this._nextRow,w=this.getRow(y);return w.values=g,this._setStyleOption(y,b[0]==="i"?b:"n"),w}addRows(g){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"n";const y=[];return g.forEach(w=>{y.push(this.addRow(w,b))}),y}insertRow(g,b){let y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"n";return this.spliceRows(g,0,b),this._setStyleOption(g,y),this.getRow(g)}insertRows(g,b){let y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"n";if(this.spliceRows(g,0,...b),y!=="n")for(let w=0;w<b.length;w++)y[0]==="o"&&this.findRow(b.length+g+w)!==void 0?this._copyStyle(b.length+g+w,g+w,y[1]==="+"):y[0]==="i"&&this.findRow(g-1)!==void 0&&this._copyStyle(g-1,g+w,y[1]==="+");return this.getRows(g,b.length)}_setStyleOption(g){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"n";b[0]==="o"&&this.findRow(g+1)!==void 0?this._copyStyle(g+1,g,b[1]==="+"):b[0]==="i"&&this.findRow(g-1)!==void 0&&this._copyStyle(g-1,g,b[1]==="+")}_copyStyle(g,b){let y=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const w=this.getRow(g),C=this.getRow(b);C.style=p(w.style),w.eachCell({includeEmpty:y},(N,I)=>{C.getCell(I).style=p(N.style)}),C.height=w.height}duplicateRow(g,b){let y=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const w=this._rows[g-1],C=new Array(b).fill(w.values);this.spliceRows(g+1,y?0:b,...C);for(let N=0;N<b;N++){const I=this._rows[g+N];I.style=w.style,I.height=w.height,w.eachCell({includeEmpty:!0},($,D)=>{I.getCell(D).style=$.style})}}spliceRows(g,b){const y=g+b;for(var w=arguments.length,C=new Array(w>2?w-2:0),N=2;N<w;N++)C[N-2]=arguments[N];const I=C.length,$=I-b,D=this._rows.length;let F,V;if($<0)for(g===D&&(this._rows[D-1]=void 0),F=y;F<=D;F++)if(V=this._rows[F-1],V){const G=this.getRow(F+$);G.values=V.values,G.style=V.style,G.height=V.height,V.eachCell({includeEmpty:!0},(U,E)=>{G.getCell(E).style=U.style}),this._rows[F-1]=void 0}else this._rows[F+$-1]=void 0;else if($>0)for(F=D;F>=y;F--)if(V=this._rows[F-1],V){const G=this.getRow(F+$);G.values=V.values,G.style=V.style,G.height=V.height,V.eachCell({includeEmpty:!0},(U,E)=>{if(G.getCell(E).style=U.style,U._value.constructor.name==="MergeValue"){const M=this.getRow(U._row._number+I).getCell(E),B=U._value._master,k=this.getRow(B._row._number+I).getCell(B._column._number);M.merge(k)}})}else this._rows[F+$-1]=void 0;for(F=0;F<I;F++){const G=this.getRow(g+F);G.style={},G.values=C[F]}this.workbook.definedNames.spliceRows(this.name,g,b,I)}eachRow(g,b){if(b||(b=g,g=void 0),g&&g.includeEmpty){const y=this._rows.length;for(let w=1;w<=y;w++)b(this.getRow(w),w)}else this._rows.forEach(y=>{y&&y.hasValues&&b(y,y.number)})}getSheetValues(){const g=[];return this._rows.forEach(b=>{b&&(g[b.number]=b.values)}),g}findCell(g,b){const y=i.getAddress(g,b),w=this._rows[y.row-1];return w?w.findCell(y.col):void 0}getCell(g,b){const y=i.getAddress(g,b);return this.getRow(y.row).getCellEx(y)}mergeCells(){for(var g=arguments.length,b=new Array(g),y=0;y<g;y++)b[y]=arguments[y];const w=new c(b);this._mergeCellsInternal(w)}mergeCellsWithoutStyle(){for(var g=arguments.length,b=new Array(g),y=0;y<g;y++)b[y]=arguments[y];const w=new c(b);this._mergeCellsInternal(w,!0)}_mergeCellsInternal(g,b){o.each(this._merges,w=>{if(w.intersects(g))throw new Error("Cannot merge already merged cells")});const y=this.getCell(g.top,g.left);for(let w=g.top;w<=g.bottom;w++)for(let C=g.left;C<=g.right;C++)(w>g.top||C>g.left)&&this.getCell(w,C).merge(y,b);this._merges[y.address]=g}_unMergeMaster(g){const b=this._merges[g.address];if(b){for(let y=b.top;y<=b.bottom;y++)for(let w=b.left;w<=b.right;w++)this.getCell(y,w).unmerge();delete this._merges[g.address]}}get hasMerges(){return o.some(this._merges,Boolean)}unMergeCells(){for(var g=arguments.length,b=new Array(g),y=0;y<g;y++)b[y]=arguments[y];const w=new c(b);for(let C=w.top;C<=w.bottom;C++)for(let N=w.left;N<=w.right;N++){const I=this.findCell(C,N);I&&(I.type===u.ValueType.Merge?this._unMergeMaster(I.master):this._merges[I.address]&&this._unMergeMaster(I))}}fillFormula(g,b,y){let w=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"shared";const C=i.decode(g),{top:N,left:I,bottom:$,right:D}=C,F=D-I+1,V=i.encodeAddress(N,I),G=w==="shared";let U;U=typeof y=="function"?y:Array.isArray(y)?Array.isArray(y[0])?(M,B)=>y[M-N][B-I]:(M,B)=>y[(M-N)*F+(B-I)]:()=>{};let E=!0;for(let M=N;M<=$;M++)for(let B=I;B<=D;B++)E?(this.getCell(M,B).value={shareType:w,formula:b,ref:g,result:U(M,B)},E=!1):this.getCell(M,B).value=G?{sharedFormula:V,result:U(M,B)}:U(M,B)}addImage(g,b){const y={type:"image",imageId:g,range:b};this._media.push(new h(this,y))}getImages(){return this._media.filter(g=>g.type==="image")}addBackgroundImage(g){const b={type:"background",imageId:g};this._media.push(new h(this,b))}getBackgroundImageId(){const g=this._media.find(b=>b.type==="background");return g&&g.imageId}protect(g,b){return new Promise(y=>{this.sheetProtection={sheet:!0},b&&"spinCount"in b&&(b.spinCount=Number.isFinite(b.spinCount)?Math.round(Math.max(0,b.spinCount)):1e5),g&&(this.sheetProtection.algorithmName="SHA-512",this.sheetProtection.saltValue=m.randomBytes(16).toString("base64"),this.sheetProtection.spinCount=b&&"spinCount"in b?b.spinCount:1e5,this.sheetProtection.hashValue=m.convertPasswordToHash(g,"SHA512",this.sheetProtection.saltValue,this.sheetProtection.spinCount)),b&&(this.sheetProtection=Object.assign(this.sheetProtection,b),!g&&"spinCount"in b&&delete this.sheetProtection.spinCount),y()})}unprotect(){this.sheetProtection=null}addTable(g){const b=new d(this,g);return this.tables[g.name]=b,b}getTable(g){return this.tables[g]}removeTable(g){delete this.tables[g]}getTables(){return Object.values(this.tables)}addConditionalFormatting(g){this.conditionalFormattings.push(g)}removeConditionalFormatting(g){typeof g=="number"?this.conditionalFormattings.splice(g,1):this.conditionalFormattings=g instanceof Function?this.conditionalFormattings.filter(g):[]}get tabColor(){return console.trace("worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor"),this.properties.tabColor}set tabColor(g){console.trace("worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor"),this.properties.tabColor=g}get model(){const g={id:this.id,name:this.name,dataValidations:this.dataValidations.model,properties:this.properties,state:this.state,pageSetup:this.pageSetup,headerFooter:this.headerFooter,rowBreaks:this.rowBreaks,views:this.views,autoFilter:this.autoFilter,media:this._media.map(w=>w.model),sheetProtection:this.sheetProtection,tables:Object.values(this.tables).map(w=>w.model),conditionalFormattings:this.conditionalFormattings};g.cols=a.toModel(this.columns);const b=g.rows=[],y=g.dimensions=new c;return this._rows.forEach(w=>{const C=w&&w.model;C&&(y.expand(C.number,C.min,C.number,C.max),b.push(C))}),g.merges=[],o.each(this._merges,w=>{g.merges.push(w.range)}),g}_parseRows(g){this._rows=[],g.rows.forEach(b=>{const y=new l(this,b.number);this._rows[y.number-1]=y,y.model=b})}_parseMergeCells(g){o.each(g.mergeCells,b=>{this.mergeCellsWithoutStyle(b)})}set model(g){this.name=g.name,this._columns=a.fromModel(this,g.cols),this._parseRows(g),this._parseMergeCells(g),this.dataValidations=new f(g.dataValidations),this.properties=g.properties,this.pageSetup=g.pageSetup,this.headerFooter=g.headerFooter,this.views=g.views,this.autoFilter=g.autoFilter,this._media=g.media.map(b=>new h(this,b)),this.sheetProtection=g.sheetProtection,this.tables=g.tables.reduce((b,y)=>{const w=new d;return w.model=y,b[y.name]=w,b},{}),this.conditionalFormattings=g.conditionalFormattings}}},{"../utils/col-cache":19,"../utils/copy-style":20,"../utils/encryptor":21,"../utils/under-dash":26,"./column":4,"./data-validations":5,"./enums":7,"./image":8,"./range":10,"./row":11,"./table":12}],15:[function(t,n,s){t("core-js/modules/es.promise"),t("core-js/modules/es.promise.finally"),t("core-js/modules/es.object.assign"),t("core-js/modules/es.object.keys"),t("core-js/modules/es.object.values"),t("core-js/modules/es.symbol"),t("core-js/modules/es.symbol.async-iterator"),t("core-js/modules/es.array.iterator"),t("core-js/modules/es.array.includes"),t("core-js/modules/es.array.find-index"),t("core-js/modules/es.array.find"),t("core-js/modules/es.string.from-code-point"),t("core-js/modules/es.string.includes"),t("core-js/modules/es.number.is-nan"),t("regenerator-runtime/runtime");const o={Workbook:t("./doc/workbook")},i=t("./doc/enums");Object.keys(i).forEach(c=>{o[c]=i[c]}),n.exports=o},{"./doc/enums":7,"./doc/workbook":13,"core-js/modules/es.array.find":359,"core-js/modules/es.array.find-index":358,"core-js/modules/es.array.includes":360,"core-js/modules/es.array.iterator":361,"core-js/modules/es.number.is-nan":363,"core-js/modules/es.object.assign":364,"core-js/modules/es.object.keys":366,"core-js/modules/es.object.values":367,"core-js/modules/es.promise":372,"core-js/modules/es.promise.finally":371,"core-js/modules/es.string.from-code-point":376,"core-js/modules/es.string.includes":377,"core-js/modules/es.symbol":381,"core-js/modules/es.symbol.async-iterator":378,"regenerator-runtime/runtime":492}],16:[function(t,n,s){const o=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");s.bufferToString=function(i){return typeof i=="string"?i:o?o.decode(i):i.toString()}},{}],17:[function(t,n,s){const o=typeof TextEncoder>"u"?null:new TextEncoder("utf-8"),{Buffer:i}=t("buffer");s.stringToBuffer=function(c){return typeof c!="string"?c:o?i.from(o.encode(c).buffer):i.from(c)}},{buffer:220}],18:[function(t,n,s){const o=t("./under-dash"),i=t("./col-cache");n.exports=class{constructor(c){this.template=c,this.sheets={}}addCell(c){this.addCellEx(i.decodeEx(c))}getCell(c){return this.findCellEx(i.decodeEx(c),!0)}findCell(c){return this.findCellEx(i.decodeEx(c),!1)}findCellAt(c,l,a){const u=this.sheets[c],h=u&&u[l];return h&&h[a]}addCellEx(c){if(c.top)for(let l=c.top;l<=c.bottom;l++)for(let a=c.left;a<=c.right;a++)this.getCellAt(c.sheetName,l,a);else this.findCellEx(c,!0)}getCellEx(c){return this.findCellEx(c,!0)}findCellEx(c,l){const a=this.findSheet(c,l),u=this.findSheetRow(a,c,l);return this.findRowCell(u,c,l)}getCellAt(c,l,a){const u=this.sheets[c]||(this.sheets[c]=[]),h=u[l]||(u[l]=[]);return h[a]||(h[a]={sheetName:c,address:i.n2l(a)+l,row:l,col:a})}removeCellEx(c){const l=this.findSheet(c);if(!l)return;const a=this.findSheetRow(l,c);a&&delete a[c.col]}forEachInSheet(c,l){const a=this.sheets[c];a&&a.forEach((u,h)=>{u&&u.forEach((d,f)=>{d&&l(d,h,f)})})}forEach(c){o.each(this.sheets,(l,a)=>{this.forEachInSheet(a,c)})}map(c){const l=[];return this.forEach(a=>{l.push(c(a))}),l}findSheet(c,l){const a=c.sheetName;return this.sheets[a]?this.sheets[a]:l?this.sheets[a]=[]:void 0}findSheetRow(c,l,a){const{row:u}=l;return c&&c[u]?c[u]:a?c[u]=[]:void 0}findRowCell(c,l,a){const{col:u}=l;return c&&c[u]?c[u]:a?c[u]=this.template?Object.assign(l,JSON.parse(JSON.stringify(this.template))):l:void 0}spliceRows(c,l,a,u){const h=this.sheets[c];if(h){const d=[];for(let f=0;f<u;f++)d.push([]);h.splice(l,a,...d)}}spliceColumns(c,l,a,u){const h=this.sheets[c];if(h){const d=[];for(let f=0;f<u;f++)d.push(null);o.each(h,f=>{f.splice(l,a,...d)})}}}},{"./col-cache":19,"./under-dash":26}],19:[function(t,n,s){const o=/^[A-Z]+\d+$/,i={_dictionary:["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],_l2nFill:0,_l2n:{},_n2l:[],_level:c=>c<=26?1:c<=676?2:3,_fill(c){let l,a,u,h,d,f=1;if(c>=4)throw new Error("Out of bounds. Excel supports columns from 1 to 16384");if(this._l2nFill<1&&c>=1){for(;f<=26;)l=this._dictionary[f-1],this._n2l[f]=l,this._l2n[l]=f,f++;this._l2nFill=1}if(this._l2nFill<2&&c>=2){for(f=27;f<=702;)a=f-27,u=a%26,h=Math.floor(a/26),l=this._dictionary[h]+this._dictionary[u],this._n2l[f]=l,this._l2n[l]=f,f++;this._l2nFill=2}if(this._l2nFill<3&&c>=3){for(f=703;f<=16384;)a=f-703,u=a%26,h=Math.floor(a/26)%26,d=Math.floor(a/676),l=this._dictionary[d]+this._dictionary[h]+this._dictionary[u],this._n2l[f]=l,this._l2n[l]=f,f++;this._l2nFill=3}},l2n(c){if(this._l2n[c]||this._fill(c.length),!this._l2n[c])throw new Error("Out of bounds. Invalid column letter: "+c);return this._l2n[c]},n2l(c){if(c<1||c>16384)throw new Error(c+" is out of bounds. Excel supports columns from 1 to 16384");return this._n2l[c]||this._fill(this._level(c)),this._n2l[c]},_hash:{},validateAddress(c){if(!o.test(c))throw new Error("Invalid Address: "+c);return!0},decodeAddress(c){const l=c.length<5&&this._hash[c];if(l)return l;let a=!1,u="",h=0,d=!1,f="",m=0;for(let g,b=0;b<c.length;b++)if(g=c.charCodeAt(b),!d&&g>=65&&g<=90)a=!0,u+=c[b],h=26*h+g-64;else if(g>=48&&g<=57)d=!0,f+=c[b],m=10*m+g-48;else if(d&&a&&g!==36)break;if(a){if(h>16384)throw new Error("Out of bounds. Invalid column letter: "+u)}else h=void 0;d||(m=void 0);const p={address:c=u+f,col:h,row:m,$col$row:`$${u}$${f}`};return h<=100&&m<=100&&(this._hash[c]=p,this._hash[p.$col$row]=p),p},getAddress(c,l){if(l){const a=this.n2l(l)+c;return this.decodeAddress(a)}return this.decodeAddress(c)},decode(c){const l=c.split(":");if(l.length===2){const a=this.decodeAddress(l[0]),u=this.decodeAddress(l[1]),h={top:Math.min(a.row,u.row),left:Math.min(a.col,u.col),bottom:Math.max(a.row,u.row),right:Math.max(a.col,u.col)};return h.tl=this.n2l(h.left)+h.top,h.br=this.n2l(h.right)+h.bottom,h.dimensions=`${h.tl}:${h.br}`,h}return this.decodeAddress(c)},decodeEx(c){const l=c.match(/(?:(?:(?:'((?:[^']|'')*)')|([^'^ !]*))!)?(.*)/),a=l[1]||l[2],u=l[3],h=u.split(":");if(h.length>1){let f=this.decodeAddress(h[0]),m=this.decodeAddress(h[1]);const p=Math.min(f.row,m.row),g=Math.min(f.col,m.col),b=Math.max(f.row,m.row),y=Math.max(f.col,m.col);return f=this.n2l(g)+p,m=this.n2l(y)+b,{top:p,left:g,bottom:b,right:y,sheetName:a,tl:{address:f,col:g,row:p,$col$row:`$${this.n2l(g)}$${p}`,sheetName:a},br:{address:m,col:y,row:b,$col$row:`$${this.n2l(y)}$${b}`,sheetName:a},dimensions:`${f}:${m}`}}if(u.startsWith("#"))return a?{sheetName:a,error:u}:{error:u};const d=this.decodeAddress(u);return a?{sheetName:a,...d}:d},encodeAddress:(c,l)=>i.n2l(l)+c,encode(){switch(arguments.length){case 2:return i.encodeAddress(arguments[0],arguments[1]);case 4:return`${i.encodeAddress(arguments[0],arguments[1])}:${i.encodeAddress(arguments[2],arguments[3])}`;default:throw new Error("Can only encode with 2 or 4 arguments")}},inRange(c,l){const[a,u,,h,d]=c,[f,m]=l;return f>=a&&f<=h&&m>=u&&m<=d}};n.exports=i},{}],20:[function(t,n,s){const o=(c,l)=>({...c,...l.reduce((a,u)=>(c[u]&&(a[u]={...c[u]}),a),{})}),i=function(c,l,a){let u=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[];c[a]&&(l[a]=o(c[a],u))};s.copyStyle=c=>{if(!c)return c;if(l=c,Object.keys(l).length===0)return{};var l;const a={...c};return i(c,a,"font",["color"]),i(c,a,"alignment"),i(c,a,"protection"),c.border&&(i(c,a,"border"),i(c.border,a.border,"top",["color"]),i(c.border,a.border,"left",["color"]),i(c.border,a.border,"bottom",["color"]),i(c.border,a.border,"right",["color"]),i(c.border,a.border,"diagonal",["color"])),c.fill&&(i(c,a,"fill",["fgColor","bgColor","center"]),c.fill.stops&&(a.fill.stops=c.fill.stops.map(u=>o(u,["color"])))),a}},{}],21:[function(t,n,s){(function(o){(function(){const i=t("crypto"),c={hash(l){const a=i.createHash(l);for(var u=arguments.length,h=new Array(u>1?u-1:0),d=1;d<u;d++)h[d-1]=arguments[d];return a.update(o.concat(h)),a.digest()},convertPasswordToHash(l,a,u,h){if(a=a.toLowerCase(),i.getHashes().indexOf(a)<0)throw new Error(`Hash algorithm '${a}' not supported!`);const d=o.from(l,"utf16le");let f=this.hash(a,o.from(u,"base64"),d);for(let m=0;m<h;m++){const p=o.alloc(4);p.writeUInt32LE(m,0),f=this.hash(a,f,p)}return f.toString("base64")},randomBytes:l=>i.randomBytes(l)};n.exports=c}).call(this)}).call(this,t("buffer").Buffer)},{buffer:220,crypto:390}],22:[function(t,n,s){const{SaxesParser:o}=t("saxes"),{PassThrough:i}=t("readable-stream"),{bufferToString:c}=t("./browser-buffer-decode");n.exports=async function*(l){l.pipe&&!l[Symbol.asyncIterator]&&(l=l.pipe(new i));const a=new o;let u;a.on("error",d=>{u=d});let h=[];a.on("opentag",d=>h.push({eventType:"opentag",value:d})),a.on("text",d=>h.push({eventType:"text",value:d})),a.on("closetag",d=>h.push({eventType:"closetag",value:d}));for await(const d of l){if(a.write(c(d)),u)throw u;yield h,h=[]}}},{"./browser-buffer-decode":16,"readable-stream":491,saxes:496}],23:[function(t,n,s){const o=t("./col-cache"),i=/(([a-z_\-0-9]*)!)?([a-z0-9_$]{2,})([(])?/gi,c=/^([$])?([a-z]+)([$])?([1-9][0-9]*)$/i;n.exports={slideFormula:function(l,a,u){const h=o.decode(a),d=o.decode(u);return l.replace(i,(f,m,p,g,b)=>{if(b)return f;const y=c.exec(g);if(y){const w=y[1],C=y[2].toUpperCase(),N=y[3],I=y[4];if(C.length>3||C.length===3&&C>"XFD")return f;let $=o.l2n(C),D=parseInt(I,10);return w||($+=d.col-h.col),N||(D+=d.row-h.row),(m||"")+(w||"")+o.n2l($)+(N||"")+D}return f})}}},{"./col-cache":19}],24:[function(t,n,s){(function(o,i){(function(){const c=t("readable-stream"),l=t("./utils"),a=t("./string-buf");class u{constructor(g,b){this._data=g,this._encoding=b}get length(){return this.toBuffer().length}copy(g,b,y,w){return this.toBuffer().copy(g,b,y,w)}toBuffer(){return this._buffer||(this._buffer=i.from(this._data,this._encoding)),this._buffer}}class h{constructor(g){this._data=g}get length(){return this._data.length}copy(g,b,y,w){return this._data._buf.copy(g,b,y,w)}toBuffer(){return this._data.toBuffer()}}class d{constructor(g){this._data=g}get length(){return this._data.length}copy(g,b,y,w){this._data.copy(g,b,y,w)}toBuffer(){return this._data}}class f{constructor(g){this.size=g,this.buffer=i.alloc(g),this.iRead=0,this.iWrite=0}toBuffer(){if(this.iRead===0&&this.iWrite===this.size)return this.buffer;const g=i.alloc(this.iWrite-this.iRead);return this.buffer.copy(g,0,this.iRead,this.iWrite),g}get length(){return this.iWrite-this.iRead}get eod(){return this.iRead===this.iWrite}get full(){return this.iWrite===this.size}read(g){let b;return g===0?null:g===void 0||g>=this.length?(b=this.toBuffer(),this.iRead=this.iWrite,b):(b=i.alloc(g),this.buffer.copy(b,0,this.iRead,g),this.iRead+=g,b)}write(g,b,y){const w=Math.min(y,this.size-this.iWrite);return g.copy(this.buffer,this.iWrite,b,b+w),this.iWrite+=w,w}}const m=function(p){p=p||{},this.bufSize=p.bufSize||1048576,this.buffers=[],this.batch=p.batch||!1,this.corked=!1,this.inPos=0,this.outPos=0,this.pipes=[],this.paused=!1,this.encoding=null};l.inherits(m,c.Duplex,{toBuffer(){switch(this.buffers.length){case 0:return null;case 1:return this.buffers[0].toBuffer();default:return i.concat(this.buffers.map(p=>p.toBuffer()))}},_getWritableBuffer(){if(this.buffers.length){const g=this.buffers[this.buffers.length-1];if(!g.full)return g}const p=new f(this.bufSize);return this.buffers.push(p),p},async _pipe(p){await Promise.all(this.pipes.map((function(g){return new Promise(b=>{g.write(p.toBuffer(),()=>{b()})})})))},_writeToBuffers(p){let g=0;const b=p.length;for(;g<b;)g+=this._getWritableBuffer().write(p,g,b-g)},async write(p,g,b){let y;if(g instanceof Function&&(b=g,g="utf8"),b=b||l.nop,p instanceof a)y=new h(p);else if(p instanceof i)y=new d(p);else{if(!(typeof p=="string"||p instanceof String||p instanceof ArrayBuffer))throw new Error("Chunk must be one of type String, Buffer or StringBuf.");y=new u(p,g)}if(this.pipes.length)if(this.batch)for(this._writeToBuffers(y);!this.corked&&this.buffers.length>1;)this._pipe(this.buffers.shift());else this.corked?(this._writeToBuffers(y),o.nextTick(b)):(await this._pipe(y),b());else this.paused||this.emit("data",y.toBuffer()),this._writeToBuffers(y),this.emit("readable");return!0},cork(){this.corked=!0},_flush(){if(this.pipes.length)for(;this.buffers.length;)this._pipe(this.buffers.shift())},uncork(){this.corked=!1,this._flush()},end(p,g,b){const y=w=>{w?b(w):(this._flush(),this.pipes.forEach(C=>{C.end()}),this.emit("finish"))};p?this.write(p,g,y):y()},read(p){let g;if(p){for(g=[];p&&this.buffers.length&&!this.buffers[0].eod;){const b=this.buffers[0],y=b.read(p);p-=y.length,g.push(y),b.eod&&b.full&&this.buffers.shift()}return i.concat(g)}return g=this.buffers.map(b=>b.toBuffer()).filter(Boolean),this.buffers=[],i.concat(g)},setEncoding(p){this.encoding=p},pause(){this.paused=!0},resume(){this.paused=!1},isPaused(){return!!this.paused},pipe(p){this.pipes.push(p),!this.paused&&this.buffers.length&&this.end()},unpipe(p){this.pipes=this.pipes.filter(g=>g!==p)},unshift(){throw new Error("Not Implemented")},wrap(){throw new Error("Not Implemented")}}),n.exports=m}).call(this)}).call(this,t("_process"),t("buffer").Buffer)},{"./string-buf":25,"./utils":27,_process:467,buffer:220,"readable-stream":491}],25:[function(t,n,s){(function(o){(function(){n.exports=class{constructor(i){this._buf=o.alloc(i&&i.size||16384),this._encoding=i&&i.encoding||"utf8",this._inPos=0,this._buffer=void 0}get length(){return this._inPos}get capacity(){return this._buf.length}get buffer(){return this._buf}toBuffer(){return this._buffer||(this._buffer=o.alloc(this.length),this._buf.copy(this._buffer,0,0,this.length)),this._buffer}reset(i){i=i||0,this._buffer=void 0,this._inPos=i}_grow(i){let c=2*this._buf.length;for(;c<i;)c*=2;const l=o.alloc(c);this._buf.copy(l,0),this._buf=l}addText(i){this._buffer=void 0;let c=this._inPos+this._buf.write(i,this._inPos,this._encoding);for(;c>=this._buf.length-4;)this._grow(this._inPos+i.length),c=this._inPos+this._buf.write(i,this._inPos,this._encoding);this._inPos=c}addStringBuf(i){i.length&&(this._buffer=void 0,this.length+i.length>this.capacity&&this._grow(this.length+i.length),i._buf.copy(this._buf,this._inPos,0,i.length),this._inPos+=i.length)}}}).call(this)}).call(this,t("buffer").Buffer)},{buffer:220}],26:[function(t,n,s){const{toString:o}=Object.prototype,i=/["&<>]/,c={each:function(l,a){l&&(Array.isArray(l)?l.forEach(a):Object.keys(l).forEach(u=>{a(l[u],u)}))},some:function(l,a){return!!l&&(Array.isArray(l)?l.some(a):Object.keys(l).some(u=>a(l[u],u)))},every:function(l,a){return!l||(Array.isArray(l)?l.every(a):Object.keys(l).every(u=>a(l[u],u)))},map:function(l,a){return l?Array.isArray(l)?l.map(a):Object.keys(l).map(u=>a(l[u],u)):[]},keyBy:(l,a)=>l.reduce((u,h)=>(u[h[a]]=h,u),{}),isEqual:function(l,a){const u=typeof l,h=typeof a,d=Array.isArray(l),f=Array.isArray(a);let m;if(u!==h)return!1;switch(typeof l){case"object":if(d||f)return!(!d||!f)&&l.length===a.length&&l.every((p,g)=>{const b=a[g];return c.isEqual(p,b)});if(l===null||a===null)return l===a;if(m=Object.keys(l),Object.keys(a).length!==m.length)return!1;for(const p of m)if(!a.hasOwnProperty(p))return!1;return c.every(l,(p,g)=>{const b=a[g];return c.isEqual(p,b)});default:return l===a}},escapeHtml(l){const a=i.exec(l);if(!a)return l;let u="",h="",d=0,f=a.index;for(;f<l.length;f++){switch(l.charAt(f)){case'"':h=""";break;case"&":h="&";break;case"'":h="'";break;case"<":h="<";break;case">":h=">";break;default:continue}d!==f&&(u+=l.substring(d,f)),d=f+1,u+=h}return d!==f?u+l.substring(d,f):u},strcmp:(l,a)=>l<a?-1:l>a?1:0,isUndefined:l=>o.call(l)==="[object Undefined]",isObject:l=>o.call(l)==="[object Object]",deepMerge(){const l=arguments[0]||{},{length:a}=arguments;let u,h,d;function f(m,p){u=l[p],d=Array.isArray(m),c.isObject(m)||d?(d?(d=!1,h=u&&Array.isArray(u)?u:[]):h=u&&c.isObject(u)?u:{},l[p]=c.deepMerge(h,m)):c.isUndefined(m)||(l[p]=m)}for(let m=0;m<a;m++)c.each(arguments[m],f);return l}};n.exports=c},{}],27:[function(t,n,s){(function(o,i){(function(){const c=t("fs"),l=/[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/,a={nop(){},promiseImmediate:u=>new Promise(h=>{o.setImmediate?i(()=>{h(u)}):setTimeout(()=>{h(u)},1)}),inherits:function(u,h,d,f){u.super_=h,f||(f=d,d=null),d&&Object.keys(d).forEach(p=>{Object.defineProperty(u,p,Object.getOwnPropertyDescriptor(d,p))});const m={constructor:{value:u,enumerable:!1,writable:!1,configurable:!0}};f&&Object.keys(f).forEach(p=>{m[p]=Object.getOwnPropertyDescriptor(f,p)}),u.prototype=Object.create(h.prototype,m)},dateToExcel:(u,h)=>25569+u.getTime()/864e5-(h?1462:0),excelToDate(u,h){const d=Math.round(24*(u-25569+(h?1462:0))*3600*1e3);return new Date(d)},parsePath(u){const h=u.lastIndexOf("/");return{path:u.substring(0,h),name:u.substring(h+1)}},getRelsPath(u){const h=a.parsePath(u);return`${h.path}/_rels/${h.name}.rels`},xmlEncode(u){const h=l.exec(u);if(!h)return u;let d="",f="",m=0,p=h.index;for(;p<u.length;p++){const g=u.charCodeAt(p);switch(g){case 34:f=""";break;case 38:f="&";break;case 39:f="'";break;case 60:f="<";break;case 62:f=">";break;case 127:f="";break;default:if(g<=31&&(g<=8||g>=11&&g!==13)){f="";break}continue}m!==p&&(d+=u.substring(m,p)),m=p+1,f&&(d+=f)}return m!==p?d+u.substring(m,p):d},xmlDecode:u=>u.replace(/&([a-z]*);/g,h=>{switch(h){case"<":return"<";case">":return">";case"&":return"&";case"'":return"'";case""":return'"';default:return h}}),validInt(u){const h=parseInt(u,10);return Number.isNaN(h)?0:h},isDateFmt(u){return u?(u=(u=u.replace(/\[[^\]]*]/g,"")).replace(/"[^"]*"/g,"")).match(/[ymdhMsb]+/)!==null:!1},fs:{exists:u=>new Promise(h=>{c.access(u,c.constants.F_OK,d=>{h(!d)})})},toIsoDateString:u=>u.toIsoString().subsstr(0,10),parseBoolean:u=>u===!0||u==="true"||u===1||u==="1"};n.exports=a}).call(this)}).call(this,typeof Cr<"u"?Cr:typeof self<"u"?self:typeof window<"u"?window:{},t("timers").setImmediate)},{fs:216,timers:523}],28:[function(t,n,s){const o=t("./under-dash"),i=t("./utils");function c(u,h,d){u.push(` ${h}="${i.xmlEncode(d.toString())}"`)}function l(u,h){if(h){const d=[];o.each(h,(f,m)=>{f!==void 0&&c(d,m,f)}),u.push(d.join(""))}}class a{constructor(){this._xml=[],this._stack=[],this._rollbacks=[]}get tos(){return this._stack.length?this._stack[this._stack.length-1]:void 0}get cursor(){return this._xml.length}openXml(h){const d=this._xml;d.push("<?xml"),l(d,h),d.push(`?>
|
|
81
81
|
`)}openNode(h,d){const f=this.tos,m=this._xml;f&&this.open&&m.push(">"),this._stack.push(h),m.push("<"),m.push(h),l(m,d),this.leaf=!0,this.open=!0}addAttribute(h,d){if(!this.open)throw new Error("Cannot write attributes to node if it is not open");d!==void 0&&c(this._xml,h,d)}addAttributes(h){if(!this.open)throw new Error("Cannot write attributes to node if it is not open");l(this._xml,h)}writeText(h){const d=this._xml;this.open&&(d.push(">"),this.open=!1),this.leaf=!1,d.push(i.xmlEncode(h.toString()))}writeXml(h){this.open&&(this._xml.push(">"),this.open=!1),this.leaf=!1,this._xml.push(h)}closeNode(){const h=this._stack.pop(),d=this._xml;this.leaf?d.push("/>"):(d.push("</"),d.push(h),d.push(">")),this.open=!1,this.leaf=!1}leafNode(h,d,f){this.openNode(h,d),f!==void 0&&this.writeText(f),this.closeNode()}closeAll(){for(;this._stack.length;)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf,open:this.open}),this.cursor}commit(){this._rollbacks.pop()}rollback(){const h=this._rollbacks.pop();this._xml.length>h.xml&&this._xml.splice(h.xml,this._xml.length-h.xml),this._stack.length>h.stack&&this._stack.splice(h.stack,this._stack.length-h.stack),this.leaf=h.leaf,this.open=h.open}get xml(){return this.closeAll(),this._xml.join("")}}a.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"},n.exports=a},{"./under-dash":26,"./utils":27}],29:[function(t,n,s){(function(o){(function(){const i=t("events"),c=t("jszip"),l=t("./stream-buf"),{stringToBuffer:a}=t("./browser-buffer-encode");class u extends i.EventEmitter{constructor(d){super(),this.options=Object.assign({type:"nodebuffer",compression:"DEFLATE"},d),this.zip=new c,this.stream=new l}append(d,f){f.hasOwnProperty("base64")&&f.base64?this.zip.file(f.name,d,{base64:!0}):(o.browser&&typeof d=="string"&&(d=a(d)),this.zip.file(f.name,d))}async finalize(){const d=await this.zip.generateAsync(this.options);this.stream.end(d),this.emit("finish")}read(d){return this.stream.read(d)}setEncoding(d){return this.stream.setEncoding(d)}pause(){return this.stream.pause()}resume(){return this.stream.resume()}isPaused(){return this.stream.isPaused()}pipe(d,f){return this.stream.pipe(d,f)}unpipe(d){return this.stream.unpipe(d)}unshift(d){return this.stream.unshift(d)}wrap(d){return this.stream.wrap(d)}}n.exports={ZipWriter:u}}).call(this)}).call(this,t("_process"))},{"./browser-buffer-encode":17,"./stream-buf":24,_process:467,events:422,jszip:441}],30:[function(t,n,s){n.exports={0:{f:"General"},1:{f:"0"},2:{f:"0.00"},3:{f:"#,##0"},4:{f:"#,##0.00"},9:{f:"0%"},10:{f:"0.00%"},11:{f:"0.00E+00"},12:{f:"# ?/?"},13:{f:"# ??/??"},14:{f:"mm-dd-yy"},15:{f:"d-mmm-yy"},16:{f:"d-mmm"},17:{f:"mmm-yy"},18:{f:"h:mm AM/PM"},19:{f:"h:mm:ss AM/PM"},20:{f:"h:mm"},21:{f:"h:mm:ss"},22:{f:'m/d/yy "h":mm'},27:{"zh-tw":"[$-404]e/m/d","zh-cn":'yyyy"年"m"月"',"ja-jp":"[$-411]ge.m.d","ko-kr":'yyyy"年" mm"月" dd"日"'},28:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},29:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},30:{"zh-tw":"m/d/yy ","zh-cn":"m-d-yy","ja-jp":"m/d/yy","ko-kr":"mm-dd-yy"},31:{"zh-tw":'yyyy"年"m"月"d"日"',"zh-cn":'yyyy"年"m"月"d"日"',"ja-jp":'yyyy"年"m"月"d"日"',"ko-kr":'yyyy"년" mm"월" dd"일"'},32:{"zh-tw":'hh"時"mm"分"',"zh-cn":'h"时"mm"分"',"ja-jp":'h"時"mm"分"',"ko-kr":'h"시" mm"분"'},33:{"zh-tw":'hh"時"mm"分"ss"秒"',"zh-cn":'h"时"mm"分"ss"秒"',"ja-jp":'h"時"mm"分"ss"秒"',"ko-kr":'h"시" mm"분" ss"초"'},34:{"zh-tw":'上午/下午 hh"時"mm"分"',"zh-cn":'上午/下午 h"时"mm"分"',"ja-jp":'yyyy"年"m"月"',"ko-kr":"yyyy-mm-dd"},35:{"zh-tw":'上午/下午 hh"時"mm"分"ss"秒"',"zh-cn":'上午/下午 h"时"mm"分"ss"秒"',"ja-jp":'m"月"d"日"',"ko-kr":"yyyy-mm-dd"},36:{"zh-tw":"[$-404]e/m/d","zh-cn":'yyyy"年"m"月"',"ja-jp":"[$-411]ge.m.d","ko-kr":'yyyy"年" mm"月" dd"日"'},37:{f:"#,##0 ;(#,##0)"},38:{f:"#,##0 ;[Red](#,##0)"},39:{f:"#,##0.00 ;(#,##0.00)"},40:{f:"#,##0.00 ;[Red](#,##0.00)"},45:{f:"mm:ss"},46:{f:"[h]:mm:ss"},47:{f:"mmss.0"},48:{f:"##0.0E+0"},49:{f:"@"},50:{"zh-tw":"[$-404]e/m/d","zh-cn":'yyyy"年"m"月"',"ja-jp":"[$-411]ge.m.d","ko-kr":'yyyy"年" mm"月" dd"日"'},51:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},52:{"zh-tw":'上午/下午 hh"時"mm"分"',"zh-cn":'yyyy"年"m"月"',"ja-jp":'yyyy"年"m"月"',"ko-kr":"yyyy-mm-dd"},53:{"zh-tw":'上午/下午 hh"時"mm"分"ss"秒"',"zh-cn":'m"月"d"日"',"ja-jp":'m"月"d"日"',"ko-kr":"yyyy-mm-dd"},54:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},55:{"zh-tw":'上午/下午 hh"時"mm"分"',"zh-cn":'上午/下午 h"时"mm"分"',"ja-jp":'yyyy"年"m"月"',"ko-kr":"yyyy-mm-dd"},56:{"zh-tw":'上午/下午 hh"時"mm"分"ss"秒"',"zh-cn":'上午/下午 h"时"mm"分"ss"秒"',"ja-jp":'m"月"d"日"',"ko-kr":"yyyy-mm-dd"},57:{"zh-tw":"[$-404]e/m/d","zh-cn":'yyyy"年"m"月"',"ja-jp":"[$-411]ge.m.d","ko-kr":'yyyy"年" mm"月" dd"日"'},58:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},59:{"th-th":"t0"},60:{"th-th":"t0.00"},61:{"th-th":"t#,##0"},62:{"th-th":"t#,##0.00"},67:{"th-th":"t0%"},68:{"th-th":"t0.00%"},69:{"th-th":"t# ?/?"},70:{"th-th":"t# ??/??"},81:{"th-th":"d/m/bb"}}},{}],31:[function(t,n,s){n.exports={OfficeDocument:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",Worksheet:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",CalcChain:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain",SharedStrings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",Styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",Theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",Hyperlink:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",Image:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",CoreProperties:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",ExtenderProperties:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",Comments:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",VmlDrawing:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",Table:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table"}},{}],32:[function(t,n,s){const o=t("../../utils/parse-sax"),i=t("../../utils/xml-stream");class c{prepare(){}render(){}parseOpen(a){}parseText(a){}parseClose(a){}reconcile(a,u){}reset(){this.model=null,this.map&&Object.values(this.map).forEach(a=>{a instanceof c?a.reset():a.xform&&a.xform.reset()})}mergeModel(a){this.model=Object.assign(this.model||{},a)}async parse(a){for await(const u of a)for(const{eventType:h,value:d}of u)if(h==="opentag")this.parseOpen(d);else if(h==="text")this.parseText(d);else if(h==="closetag"&&!this.parseClose(d.name))return this.model;return this.model}async parseStream(a){return this.parse(o(a))}get xml(){return this.toXml(this.model)}toXml(a){const u=new i;return this.render(u,a),u.xml}static toAttribute(a,u){let h=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(a===void 0){if(h)return u}else if(h||a!==u)return a.toString()}static toStringAttribute(a,u){let h=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return c.toAttribute(a,u,h)}static toStringValue(a,u){return a===void 0?u:a}static toBoolAttribute(a,u){let h=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(a===void 0){if(h)return u}else if(h||a!==u)return a?"1":"0"}static toBoolValue(a,u){return a===void 0?u:a==="1"}static toIntAttribute(a,u){let h=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return c.toAttribute(a,u,h)}static toIntValue(a,u){return a===void 0?u:parseInt(a,10)}static toFloatAttribute(a,u){let h=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return c.toAttribute(a,u,h)}static toFloatValue(a,u){return a===void 0?u:parseFloat(a)}}n.exports=c},{"../../utils/parse-sax":22,"../../utils/xml-stream":28}],33:[function(t,n,s){const o=t("../base-xform"),i=t("../../../utils/col-cache");function c(a){try{return i.decodeEx(a),!0}catch{return!1}}function l(a){const u=[];let h=!1,d="";return a.split(",").forEach(f=>{if(!f)return;const m=(f.match(/'/g)||[]).length;if(!m)return void(h?d+=f+",":c(f)&&u.push(f));const p=m%2==0;!h&&p&&c(f)?u.push(f):h&&!p?(h=!1,c(d+f)&&u.push(d+f),d=""):(h=!0,d+=f+",")}),u}n.exports=class extends o{render(a,u){a.openNode("definedName",{name:u.name,localSheetId:u.localSheetId}),a.writeText(u.ranges.join(",")),a.closeNode()}parseOpen(a){return a.name==="definedName"?(this._parsedName=a.attributes.name,this._parsedLocalSheetId=a.attributes.localSheetId,this._parsedText=[],!0):!1}parseText(a){this._parsedText.push(a)}parseClose(){return this.model={name:this._parsedName,ranges:l(this._parsedText.join(""))},this._parsedLocalSheetId!==void 0&&(this.model.localSheetId=parseInt(this._parsedLocalSheetId,10)),!1}}},{"../../../utils/col-cache":19,"../base-xform":32}],34:[function(t,n,s){const o=t("../../../utils/utils"),i=t("../base-xform");n.exports=class extends i{render(c,l){c.leafNode("sheet",{sheetId:l.id,name:l.name,state:l.state,"r:id":l.rId})}parseOpen(c){return c.name==="sheet"&&(this.model={name:o.xmlDecode(c.attributes.name),id:parseInt(c.attributes.sheetId,10),state:c.attributes.state,rId:c.attributes["r:id"]},!0)}parseText(){}parseClose(){return!1}}},{"../../../utils/utils":27,"../base-xform":32}],35:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{render(i,c){i.leafNode("calcPr",{calcId:171027,fullCalcOnLoad:c.fullCalcOnLoad?1:void 0})}parseOpen(i){return i.name==="calcPr"&&(this.model={},!0)}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],36:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{render(i,c){i.leafNode("workbookPr",{date1904:c.date1904?1:void 0,defaultThemeVersion:164011,filterPrivacy:1})}parseOpen(i){return i.name==="workbookPr"&&(this.model={date1904:i.attributes.date1904==="1"},!0)}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],37:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{render(i,c){const l={xWindow:c.x||0,yWindow:c.y||0,windowWidth:c.width||12e3,windowHeight:c.height||24e3,firstSheet:c.firstSheet,activeTab:c.activeTab};c.visibility&&c.visibility!=="visible"&&(l.visibility=c.visibility),i.leafNode("workbookView",l)}parseOpen(i){if(i.name==="workbookView"){const c=this.model={},l=function(u,h,d){const f=h!==void 0?c[u]=h:d;f!==void 0&&(c[u]=f)},a=function(u,h,d){const f=h!==void 0?c[u]=parseInt(h,10):d;f!==void 0&&(c[u]=f)};return a("x",i.attributes.xWindow,0),a("y",i.attributes.yWindow,0),a("width",i.attributes.windowWidth,25e3),a("height",i.attributes.windowHeight,1e4),l("visibility",i.attributes.visibility,"visible"),a("activeTab",i.attributes.activeTab,void 0),a("firstSheet",i.attributes.firstSheet,void 0),!0}return!1}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],38:[function(t,n,s){const o=t("../../../utils/under-dash"),i=t("../../../utils/col-cache"),c=t("../../../utils/xml-stream"),l=t("../base-xform"),a=t("../static-xform"),u=t("../list-xform"),h=t("./defined-name-xform"),d=t("./sheet-xform"),f=t("./workbook-view-xform"),m=t("./workbook-properties-xform"),p=t("./workbook-calc-properties-xform");class g extends l{constructor(){super(),this.map={fileVersion:g.STATIC_XFORMS.fileVersion,workbookPr:new m,bookViews:new u({tag:"bookViews",count:!1,childXform:new f}),sheets:new u({tag:"sheets",count:!1,childXform:new d}),definedNames:new u({tag:"definedNames",count:!1,childXform:new h}),calcPr:new p}}prepare(y){y.sheets=y.worksheets;const w=[];let C=0;y.sheets.forEach(N=>{if(N.pageSetup&&N.pageSetup.printArea&&N.pageSetup.printArea.split("&&").forEach(I=>{const $=I.split(":"),D={name:"_xlnm.Print_Area",ranges:[`'${N.name}'!$${$[0]}:$${$[1]}`],localSheetId:C};w.push(D)}),N.pageSetup&&(N.pageSetup.printTitlesRow||N.pageSetup.printTitlesColumn)){const I=[];if(N.pageSetup.printTitlesColumn){const D=N.pageSetup.printTitlesColumn.split(":");I.push(`'${N.name}'!$${D[0]}:$${D[1]}`)}if(N.pageSetup.printTitlesRow){const D=N.pageSetup.printTitlesRow.split(":");I.push(`'${N.name}'!$${D[0]}:$${D[1]}`)}const $={name:"_xlnm.Print_Titles",ranges:I,localSheetId:C};w.push($)}C++}),w.length&&(y.definedNames=y.definedNames.concat(w)),(y.media||[]).forEach((N,I)=>{N.name=N.type+(I+1)})}render(y,w){y.openXml(c.StdDocAttributes),y.openNode("workbook",g.WORKBOOK_ATTRIBUTES),this.map.fileVersion.render(y),this.map.workbookPr.render(y,w.properties),this.map.bookViews.render(y,w.views),this.map.sheets.render(y,w.sheets),this.map.definedNames.render(y,w.definedNames),this.map.calcPr.render(y,w.calcProperties),y.closeNode()}parseOpen(y){return this.parser?(this.parser.parseOpen(y),!0):(y.name==="workbook"||(this.parser=this.map[y.name],this.parser&&this.parser.parseOpen(y)),!0)}parseText(y){this.parser&&this.parser.parseText(y)}parseClose(y){return this.parser?(this.parser.parseClose(y)||(this.parser=void 0),!0):y==="workbook"?(this.model={sheets:this.map.sheets.model,properties:this.map.workbookPr.model||{},views:this.map.bookViews.model,calcProperties:{}},this.map.definedNames.model&&(this.model.definedNames=this.map.definedNames.model),!1):!0}reconcile(y){const w=(y.workbookRels||[]).reduce((D,F)=>(D[F.Id]=F,D),{}),C=[];let N,I=0;(y.sheets||[]).forEach(D=>{const F=w[D.rId];F&&(N=y.worksheetHash["xl/"+F.Target.replace(/^(\s|\/xl\/)+/,"")],N&&(N.name=D.name,N.id=D.id,N.state=D.state,C[I++]=N))});const $=[];o.each(y.definedNames,D=>{if(D.name==="_xlnm.Print_Area"){if(N=C[D.localSheetId],N){N.pageSetup||(N.pageSetup={});const F=i.decodeEx(D.ranges[0]);N.pageSetup.printArea=N.pageSetup.printArea?`${N.pageSetup.printArea}&&${F.dimensions}`:F.dimensions}}else if(D.name==="_xlnm.Print_Titles"){if(N=C[D.localSheetId],N){N.pageSetup||(N.pageSetup={});const F=D.ranges.join(","),V=/\$/g,G=/\$\d+:\$\d+/,U=F.match(G);if(U&&U.length){const B=U[0];N.pageSetup.printTitlesRow=B.replace(V,"")}const E=/\$[A-Z]+:\$[A-Z]+/,M=F.match(E);if(M&&M.length){const B=M[0];N.pageSetup.printTitlesColumn=B.replace(V,"")}}}else $.push(D)}),y.definedNames=$,y.media.forEach((D,F)=>{D.index=F})}}g.WORKBOOK_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x15","xmlns:x15":"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"},g.STATIC_XFORMS={fileVersion:new a({tag:"fileVersion",$:{appName:"xl",lastEdited:5,lowestEdited:5,rupBuild:9303}})},n.exports=g},{"../../../utils/col-cache":19,"../../../utils/under-dash":26,"../../../utils/xml-stream":28,"../base-xform":32,"../list-xform":71,"../static-xform":120,"./defined-name-xform":33,"./sheet-xform":34,"./workbook-calc-properties-xform":35,"./workbook-properties-xform":36,"./workbook-view-xform":37}],39:[function(t,n,s){const o=t("../strings/rich-text-xform"),i=t("../../../utils/utils"),c=t("../base-xform"),l=n.exports=function(a){this.model=a};i.inherits(l,c,{get tag(){return"r"},get richTextXform(){return this._richTextXform||(this._richTextXform=new o),this._richTextXform},render(a,u){u=u||this.model,a.openNode("comment",{ref:u.ref,authorId:0}),a.openNode("text"),u&&u.note&&u.note.texts&&u.note.texts.forEach(h=>{this.richTextXform.render(a,h)}),a.closeNode(),a.closeNode()},parseOpen(a){if(this.parser)return this.parser.parseOpen(a),!0;switch(a.name){case"comment":return this.model={type:"note",note:{texts:[]},...a.attributes},!0;case"r":return this.parser=this.richTextXform,this.parser.parseOpen(a),!0;default:return!1}},parseText(a){this.parser&&this.parser.parseText(a)},parseClose(a){switch(a){case"comment":return!1;case"r":return this.model.note.texts.push(this.parser.model),this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(a),!0}}})},{"../../../utils/utils":27,"../base-xform":32,"../strings/rich-text-xform":122}],40:[function(t,n,s){const o=t("../../../utils/xml-stream"),i=t("../../../utils/utils"),c=t("../base-xform"),l=t("./comment-xform"),a=n.exports=function(){this.map={comment:new l}};i.inherits(a,c,{COMMENTS_ATTRIBUTES:{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main"}},{render(u,h){h=h||this.model,u.openXml(o.StdDocAttributes),u.openNode("comments",a.COMMENTS_ATTRIBUTES),u.openNode("authors"),u.leafNode("author",null,"Author"),u.closeNode(),u.openNode("commentList"),h.comments.forEach(d=>{this.map.comment.render(u,d)}),u.closeNode(),u.closeNode()},parseOpen(u){if(this.parser)return this.parser.parseOpen(u),!0;switch(u.name){case"commentList":return this.model={comments:[]},!0;case"comment":return this.parser=this.map.comment,this.parser.parseOpen(u),!0;default:return!1}},parseText(u){this.parser&&this.parser.parseText(u)},parseClose(u){switch(u){case"commentList":return!1;case"comment":return this.model.comments.push(this.parser.model),this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(u),!0}}})},{"../../../utils/utils":27,"../../../utils/xml-stream":28,"../base-xform":32,"./comment-xform":39}],41:[function(t,n,s){const o=t("../../base-xform");n.exports=class extends o{constructor(i){super(),this._model=i}get tag(){return this._model&&this._model.tag}render(i,c,l){(c===l[2]||this.tag==="x:SizeWithCells"&&c===l[1])&&i.leafNode(this.tag)}parseOpen(i){return i.name===this.tag?(this.model={},this.model[this.tag]=!0,!0):!1}parseText(){}parseClose(){return!1}}},{"../../base-xform":32}],42:[function(t,n,s){const o=t("../../base-xform");n.exports=class extends o{constructor(i){super(),this._model=i}get tag(){return this._model&&this._model.tag}render(i,c){i.leafNode(this.tag,null,c)}parseOpen(i){return i.name===this.tag?(this.text="",!0):!1}parseText(i){this.text=i}parseClose(){return!1}}},{"../../base-xform":32}],43:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"x:Anchor"}getAnchorRect(i){const c=Math.floor(i.left),l=Math.floor(68*(i.left-c)),a=Math.floor(i.top),u=Math.floor(18*(i.top-a)),h=Math.floor(i.right),d=Math.floor(68*(i.right-h)),f=Math.floor(i.bottom);return[c,l,a,u,h,d,f,Math.floor(18*(i.bottom-f))]}getDefaultRect(i){const c=i.col,l=Math.max(i.row-2,0);return[c,6,l,14,c+2,2,l+4,16]}render(i,c){const l=c.anchor?this.getAnchorRect(c.anchor):this.getDefaultRect(c.refAddress);i.leafNode("x:Anchor",null,l.join(", "))}parseOpen(i){return i.name===this.tag?(this.text="",!0):!1}parseText(i){this.text=i}parseClose(){return!1}}},{"../base-xform":32}],44:[function(t,n,s){const o=t("../base-xform"),i=t("./vml-anchor-xform"),c=t("./style/vml-protection-xform"),l=t("./style/vml-position-xform"),a=["twoCells","oneCells","absolute"];n.exports=class extends o{constructor(){super(),this.map={"x:Anchor":new i,"x:Locked":new c({tag:"x:Locked"}),"x:LockText":new c({tag:"x:LockText"}),"x:SizeWithCells":new l({tag:"x:SizeWithCells"}),"x:MoveWithCells":new l({tag:"x:MoveWithCells"})}}get tag(){return"x:ClientData"}render(u,h){const{protection:d,editAs:f}=h.note;u.openNode(this.tag,{ObjectType:"Note"}),this.map["x:MoveWithCells"].render(u,f,a),this.map["x:SizeWithCells"].render(u,f,a),this.map["x:Anchor"].render(u,h),this.map["x:Locked"].render(u,d.locked),u.leafNode("x:AutoFill",null,"False"),this.map["x:LockText"].render(u,d.lockText),u.leafNode("x:Row",null,h.refAddress.row-1),u.leafNode("x:Column",null,h.refAddress.col-1),u.closeNode()}parseOpen(u){return u.name===this.tag?(this.reset(),this.model={anchor:[],protection:{},editAs:""}):(this.parser=this.map[u.name],this.parser&&this.parser.parseOpen(u)),!0}parseText(u){this.parser&&this.parser.parseText(u)}parseClose(u){return this.parser?(this.parser.parseClose(u)||(this.parser=void 0),!0):u===this.tag?(this.normalizeModel(),!1):!0}normalizeModel(){const u=Object.assign({},this.map["x:MoveWithCells"].model,this.map["x:SizeWithCells"].model),h=Object.keys(u).length;this.model.editAs=a[h],this.model.anchor=this.map["x:Anchor"].text,this.model.protection.locked=this.map["x:Locked"].text,this.model.protection.lockText=this.map["x:LockText"].text}}},{"../base-xform":32,"./style/vml-position-xform":41,"./style/vml-protection-xform":42,"./vml-anchor-xform":43}],45:[function(t,n,s){const o=t("../../../utils/xml-stream"),i=t("../base-xform"),c=t("./vml-shape-xform");class l extends i{constructor(){super(),this.map={"v:shape":new c}}get tag(){return"xml"}render(u,h){u.openXml(o.StdDocAttributes),u.openNode(this.tag,l.DRAWING_ATTRIBUTES),u.openNode("o:shapelayout",{"v:ext":"edit"}),u.leafNode("o:idmap",{"v:ext":"edit",data:1}),u.closeNode(),u.openNode("v:shapetype",{id:"_x0000_t202",coordsize:"21600,21600","o:spt":202,path:"m,l,21600r21600,l21600,xe"}),u.leafNode("v:stroke",{joinstyle:"miter"}),u.leafNode("v:path",{gradientshapeok:"t","o:connecttype":"rect"}),u.closeNode(),h.comments.forEach((d,f)=>{this.map["v:shape"].render(u,d,f)}),u.closeNode()}parseOpen(u){return this.parser?(this.parser.parseOpen(u),!0):(u.name===this.tag?(this.reset(),this.model={comments:[]}):(this.parser=this.map[u.name],this.parser&&this.parser.parseOpen(u)),!0)}parseText(u){this.parser&&this.parser.parseText(u)}parseClose(u){return this.parser?(this.parser.parseClose(u)||(this.model.comments.push(this.parser.model),this.parser=void 0),!0):u!==this.tag}reconcile(u,h){u.anchors.forEach(d=>{d.br?this.map["xdr:twoCellAnchor"].reconcile(d,h):this.map["xdr:oneCellAnchor"].reconcile(d,h)})}}l.DRAWING_ATTRIBUTES={"xmlns:v":"urn:schemas-microsoft-com:vml","xmlns:o":"urn:schemas-microsoft-com:office:office","xmlns:x":"urn:schemas-microsoft-com:office:excel"},n.exports=l},{"../../../utils/xml-stream":28,"../base-xform":32,"./vml-shape-xform":46}],46:[function(t,n,s){const o=t("../base-xform"),i=t("./vml-textbox-xform"),c=t("./vml-client-data-xform");class l extends o{constructor(){super(),this.map={"v:textbox":new i,"x:ClientData":new c}}get tag(){return"v:shape"}render(u,h,d){u.openNode("v:shape",l.V_SHAPE_ATTRIBUTES(h,d)),u.leafNode("v:fill",{color2:"infoBackground [80]"}),u.leafNode("v:shadow",{color:"none [81]",obscured:"t"}),u.leafNode("v:path",{"o:connecttype":"none"}),this.map["v:textbox"].render(u,h),this.map["x:ClientData"].render(u,h),u.closeNode()}parseOpen(u){return this.parser?(this.parser.parseOpen(u),!0):(u.name===this.tag?(this.reset(),this.model={margins:{insetmode:u.attributes["o:insetmode"]},anchor:"",editAs:"",protection:{}}):(this.parser=this.map[u.name],this.parser&&this.parser.parseOpen(u)),!0)}parseText(u){this.parser&&this.parser.parseText(u)}parseClose(u){return this.parser?(this.parser.parseClose(u)||(this.parser=void 0),!0):u===this.tag?(this.model.margins.inset=this.map["v:textbox"].model&&this.map["v:textbox"].model.inset,this.model.protection=this.map["x:ClientData"].model&&this.map["x:ClientData"].model.protection,this.model.anchor=this.map["x:ClientData"].model&&this.map["x:ClientData"].model.anchor,this.model.editAs=this.map["x:ClientData"].model&&this.map["x:ClientData"].model.editAs,!1):!0}}l.V_SHAPE_ATTRIBUTES=(a,u)=>({id:"_x0000_s"+(1025+u),type:"#_x0000_t202",style:"position:absolute; margin-left:105.3pt;margin-top:10.5pt;width:97.8pt;height:59.1pt;z-index:1;visibility:hidden",fillcolor:"infoBackground [80]",strokecolor:"none [81]","o:insetmode":a.note.margins&&a.note.margins.insetmode}),n.exports=l},{"../base-xform":32,"./vml-client-data-xform":44,"./vml-textbox-xform":47}],47:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"v:textbox"}conversionUnit(i,c,l){return`${parseFloat(i)*c.toFixed(2)}${l}`}reverseConversionUnit(i){return(i||"").split(",").map(c=>Number(parseFloat(this.conversionUnit(parseFloat(c),.1,"")).toFixed(2)))}render(i,c){const l={style:"mso-direction-alt:auto"};if(c&&c.note){let{inset:a}=c.note&&c.note.margins;Array.isArray(a)&&(a=a.map(u=>this.conversionUnit(u,10,"mm")).join(",")),a&&(l.inset=a)}i.openNode("v:textbox",l),i.leafNode("div",{style:"text-align:left"}),i.closeNode()}parseOpen(i){return i.name===this.tag&&(this.model={inset:this.reverseConversionUnit(i.attributes.inset)}),!0}parseText(){}parseClose(i){return i!==this.tag}}},{"../base-xform":32}],48:[function(t,n,s){const o=t("./base-xform");n.exports=class extends o{createNewModel(i){return{}}parseOpen(i){return this.parser=this.parser||this.map[i.name],this.parser?(this.parser.parseOpen(i),!0):i.name===this.tag&&(this.model=this.createNewModel(i),!0)}parseText(i){this.parser&&this.parser.parseText(i)}onParserClose(i,c){this.model[i]=c.model}parseClose(i){return this.parser?(this.parser.parseClose(i)||(this.onParserClose(i,this.parser),this.parser=void 0),!0):i!==this.tag}}},{"./base-xform":32}],49:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{render(i,c){i.openNode("HeadingPairs"),i.openNode("vt:vector",{size:2,baseType:"variant"}),i.openNode("vt:variant"),i.leafNode("vt:lpstr",void 0,"Worksheets"),i.closeNode(),i.openNode("vt:variant"),i.leafNode("vt:i4",void 0,c.length),i.closeNode(),i.closeNode(),i.closeNode()}parseOpen(i){return i.name==="HeadingPairs"}parseText(){}parseClose(i){return i!=="HeadingPairs"}}},{"../base-xform":32}],50:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{render(i,c){i.openNode("TitlesOfParts"),i.openNode("vt:vector",{size:c.length,baseType:"lpstr"}),c.forEach(l=>{i.leafNode("vt:lpstr",void 0,l.name)}),i.closeNode(),i.closeNode()}parseOpen(i){return i.name==="TitlesOfParts"}parseText(){}parseClose(i){return i!=="TitlesOfParts"}}},{"../base-xform":32}],51:[function(t,n,s){const o=t("../../../utils/xml-stream"),i=t("../base-xform"),c=t("../simple/string-xform"),l=t("./app-heading-pairs-xform"),a=t("./app-titles-of-parts-xform");class u extends i{constructor(){super(),this.map={Company:new c({tag:"Company"}),Manager:new c({tag:"Manager"}),HeadingPairs:new l,TitleOfParts:new a}}render(d,f){d.openXml(o.StdDocAttributes),d.openNode("Properties",u.PROPERTY_ATTRIBUTES),d.leafNode("Application",void 0,"Microsoft Excel"),d.leafNode("DocSecurity",void 0,"0"),d.leafNode("ScaleCrop",void 0,"false"),this.map.HeadingPairs.render(d,f.worksheets),this.map.TitleOfParts.render(d,f.worksheets),this.map.Company.render(d,f.company||""),this.map.Manager.render(d,f.manager),d.leafNode("LinksUpToDate",void 0,"false"),d.leafNode("SharedDoc",void 0,"false"),d.leafNode("HyperlinksChanged",void 0,"false"),d.leafNode("AppVersion",void 0,"16.0300"),d.closeNode()}parseOpen(d){return this.parser?(this.parser.parseOpen(d),!0):d.name==="Properties"?!0:(this.parser=this.map[d.name],!!this.parser&&(this.parser.parseOpen(d),!0))}parseText(d){this.parser&&this.parser.parseText(d)}parseClose(d){return this.parser?(this.parser.parseClose(d)||(this.parser=void 0),!0):d==="Properties"?(this.model={worksheets:this.map.TitleOfParts.model,company:this.map.Company.model,manager:this.map.Manager.model},!1):!0}}u.DateFormat=function(h){return h.toISOString().replace(/[.]\d{3,6}/,"")},u.DateAttrs={"xsi:type":"dcterms:W3CDTF"},u.PROPERTY_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties","xmlns:vt":"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"},n.exports=u},{"../../../utils/xml-stream":28,"../base-xform":32,"../simple/string-xform":119,"./app-heading-pairs-xform":49,"./app-titles-of-parts-xform":50}],52:[function(t,n,s){const o=t("../../../utils/xml-stream"),i=t("../base-xform");class c extends i{render(a,u){a.openXml(o.StdDocAttributes),a.openNode("Types",c.PROPERTY_ATTRIBUTES);const h={};(u.media||[]).forEach(d=>{if(d.type==="image"){const f=d.extension;h[f]||(h[f]=!0,a.leafNode("Default",{Extension:f,ContentType:"image/"+f}))}}),a.leafNode("Default",{Extension:"rels",ContentType:"application/vnd.openxmlformats-package.relationships+xml"}),a.leafNode("Default",{Extension:"xml",ContentType:"application/xml"}),a.leafNode("Override",{PartName:"/xl/workbook.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"}),u.worksheets.forEach(d=>{const f=`/xl/worksheets/sheet${d.id}.xml`;a.leafNode("Override",{PartName:f,ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"})}),a.leafNode("Override",{PartName:"/xl/theme/theme1.xml",ContentType:"application/vnd.openxmlformats-officedocument.theme+xml"}),a.leafNode("Override",{PartName:"/xl/styles.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"}),u.sharedStrings&&u.sharedStrings.count&&a.leafNode("Override",{PartName:"/xl/sharedStrings.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"}),u.tables&&u.tables.forEach(d=>{a.leafNode("Override",{PartName:"/xl/tables/"+d.target,ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"})}),u.drawings&&u.drawings.forEach(d=>{a.leafNode("Override",{PartName:`/xl/drawings/${d.name}.xml`,ContentType:"application/vnd.openxmlformats-officedocument.drawing+xml"})}),u.commentRefs&&(a.leafNode("Default",{Extension:"vml",ContentType:"application/vnd.openxmlformats-officedocument.vmlDrawing"}),u.commentRefs.forEach(d=>{let{commentName:f}=d;a.leafNode("Override",{PartName:`/xl/${f}.xml`,ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"})})),a.leafNode("Override",{PartName:"/docProps/core.xml",ContentType:"application/vnd.openxmlformats-package.core-properties+xml"}),a.leafNode("Override",{PartName:"/docProps/app.xml",ContentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml"}),a.closeNode()}parseOpen(){return!1}parseText(){}parseClose(){return!1}}c.PROPERTY_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/package/2006/content-types"},n.exports=c},{"../../../utils/xml-stream":28,"../base-xform":32}],53:[function(t,n,s){const o=t("../../../utils/xml-stream"),i=t("../base-xform"),c=t("../simple/date-xform"),l=t("../simple/string-xform"),a=t("../simple/integer-xform");class u extends i{constructor(){super(),this.map={"dc:creator":new l({tag:"dc:creator"}),"dc:title":new l({tag:"dc:title"}),"dc:subject":new l({tag:"dc:subject"}),"dc:description":new l({tag:"dc:description"}),"dc:identifier":new l({tag:"dc:identifier"}),"dc:language":new l({tag:"dc:language"}),"cp:keywords":new l({tag:"cp:keywords"}),"cp:category":new l({tag:"cp:category"}),"cp:lastModifiedBy":new l({tag:"cp:lastModifiedBy"}),"cp:lastPrinted":new c({tag:"cp:lastPrinted",format:u.DateFormat}),"cp:revision":new a({tag:"cp:revision"}),"cp:version":new l({tag:"cp:version"}),"cp:contentStatus":new l({tag:"cp:contentStatus"}),"cp:contentType":new l({tag:"cp:contentType"}),"dcterms:created":new c({tag:"dcterms:created",attrs:u.DateAttrs,format:u.DateFormat}),"dcterms:modified":new c({tag:"dcterms:modified",attrs:u.DateAttrs,format:u.DateFormat})}}render(d,f){d.openXml(o.StdDocAttributes),d.openNode("cp:coreProperties",u.CORE_PROPERTY_ATTRIBUTES),this.map["dc:creator"].render(d,f.creator),this.map["dc:title"].render(d,f.title),this.map["dc:subject"].render(d,f.subject),this.map["dc:description"].render(d,f.description),this.map["dc:identifier"].render(d,f.identifier),this.map["dc:language"].render(d,f.language),this.map["cp:keywords"].render(d,f.keywords),this.map["cp:category"].render(d,f.category),this.map["cp:lastModifiedBy"].render(d,f.lastModifiedBy),this.map["cp:lastPrinted"].render(d,f.lastPrinted),this.map["cp:revision"].render(d,f.revision),this.map["cp:version"].render(d,f.version),this.map["cp:contentStatus"].render(d,f.contentStatus),this.map["cp:contentType"].render(d,f.contentType),this.map["dcterms:created"].render(d,f.created),this.map["dcterms:modified"].render(d,f.modified),d.closeNode()}parseOpen(d){if(this.parser)return this.parser.parseOpen(d),!0;switch(d.name){case"cp:coreProperties":case"coreProperties":return!0;default:if(this.parser=this.map[d.name],this.parser)return this.parser.parseOpen(d),!0;throw new Error("Unexpected xml node in parseOpen: "+JSON.stringify(d))}}parseText(d){this.parser&&this.parser.parseText(d)}parseClose(d){if(this.parser)return this.parser.parseClose(d)||(this.parser=void 0),!0;switch(d){case"cp:coreProperties":case"coreProperties":return this.model={creator:this.map["dc:creator"].model,title:this.map["dc:title"].model,subject:this.map["dc:subject"].model,description:this.map["dc:description"].model,identifier:this.map["dc:identifier"].model,language:this.map["dc:language"].model,keywords:this.map["cp:keywords"].model,category:this.map["cp:category"].model,lastModifiedBy:this.map["cp:lastModifiedBy"].model,lastPrinted:this.map["cp:lastPrinted"].model,revision:this.map["cp:revision"].model,contentStatus:this.map["cp:contentStatus"].model,contentType:this.map["cp:contentType"].model,created:this.map["dcterms:created"].model,modified:this.map["dcterms:modified"].model},!1;default:throw new Error("Unexpected xml node in parseClose: "+d)}}}u.DateFormat=function(h){return h.toISOString().replace(/[.]\d{3}/,"")},u.DateAttrs={"xsi:type":"dcterms:W3CDTF"},u.CORE_PROPERTY_ATTRIBUTES={"xmlns:cp":"http://schemas.openxmlformats.org/package/2006/metadata/core-properties","xmlns:dc":"http://purl.org/dc/elements/1.1/","xmlns:dcterms":"http://purl.org/dc/terms/","xmlns:dcmitype":"http://purl.org/dc/dcmitype/","xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance"},n.exports=u},{"../../../utils/xml-stream":28,"../base-xform":32,"../simple/date-xform":117,"../simple/integer-xform":118,"../simple/string-xform":119}],54:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{render(i,c){i.leafNode("Relationship",c)}parseOpen(i){return i.name==="Relationship"?(this.model=i.attributes,!0):!1}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],55:[function(t,n,s){const o=t("../../../utils/xml-stream"),i=t("../base-xform"),c=t("./relationship-xform");class l extends i{constructor(){super(),this.map={Relationship:new c}}render(u,h){h=h||this._values,u.openXml(o.StdDocAttributes),u.openNode("Relationships",l.RELATIONSHIPS_ATTRIBUTES),h.forEach(d=>{this.map.Relationship.render(u,d)}),u.closeNode()}parseOpen(u){if(this.parser)return this.parser.parseOpen(u),!0;switch(u.name){case"Relationships":return this.model=[],!0;default:if(this.parser=this.map[u.name],this.parser)return this.parser.parseOpen(u),!0;throw new Error("Unexpected xml node in parseOpen: "+JSON.stringify(u))}}parseText(u){this.parser&&this.parser.parseText(u)}parseClose(u){if(this.parser)return this.parser.parseClose(u)||(this.model.push(this.parser.model),this.parser=void 0),!0;if(u==="Relationships")return!1;throw new Error("Unexpected xml node in parseClose: "+u)}}l.RELATIONSHIPS_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},n.exports=l},{"../../../utils/xml-stream":28,"../base-xform":32,"./relationship-xform":54}],56:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{parseOpen(i){return this.parser?(this.parser.parseOpen(i),!0):(i.name===this.tag?(this.reset(),this.model={range:{editAs:i.attributes.editAs||"oneCell"}}):(this.parser=this.map[i.name],this.parser&&this.parser.parseOpen(i)),!0)}parseText(i){this.parser&&this.parser.parseText(i)}reconcilePicture(i,c){if(i&&i.rId){const l=c.rels[i.rId].Target.match(/.*\/media\/(.+[.][a-zA-Z]{3,4})/);if(l){const a=l[1],u=c.mediaIndex[a];return c.media[u]}}}}},{"../base-xform":32}],57:[function(t,n,s){const o=t("../base-xform"),i=t("./blip-xform");n.exports=class extends o{constructor(){super(),this.map={"a:blip":new i}}get tag(){return"xdr:blipFill"}render(c,l){c.openNode(this.tag),this.map["a:blip"].render(c,l),c.openNode("a:stretch"),c.leafNode("a:fillRect"),c.closeNode(),c.closeNode()}parseOpen(c){return this.parser?(this.parser.parseOpen(c),!0):(c.name===this.tag?this.reset():(this.parser=this.map[c.name],this.parser&&this.parser.parseOpen(c)),!0)}parseText(){}parseClose(c){return this.parser?(this.parser.parseClose(c)||(this.parser=void 0),!0):c===this.tag?(this.model=this.map["a:blip"].model,!1):!0}}},{"../base-xform":32,"./blip-xform":58}],58:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"a:blip"}render(i,c){i.leafNode(this.tag,{"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","r:embed":c.rId,cstate:"print"})}parseOpen(i){return i.name===this.tag&&(this.model={rId:i.attributes["r:embed"]}),!0}parseText(){}parseClose(i){return i!==this.tag}}},{"../base-xform":32}],59:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"xdr:cNvPicPr"}render(i){i.openNode(this.tag),i.leafNode("a:picLocks",{noChangeAspect:"1"}),i.closeNode()}parseOpen(i){switch(i.name){case this.tag:default:return!0}}parseText(){}parseClose(i){return i!==this.tag}}},{"../base-xform":32}],60:[function(t,n,s){const o=t("../base-xform"),i=t("./hlink-click-xform"),c=t("./ext-lst-xform");n.exports=class extends o{constructor(){super(),this.map={"a:hlinkClick":new i,"a:extLst":new c}}get tag(){return"xdr:cNvPr"}render(l,a){l.openNode(this.tag,{id:a.index,name:"Picture "+a.index}),this.map["a:hlinkClick"].render(l,a),this.map["a:extLst"].render(l,a),l.closeNode()}parseOpen(l){return this.parser?(this.parser.parseOpen(l),!0):(l.name===this.tag?this.reset():(this.parser=this.map[l.name],this.parser&&this.parser.parseOpen(l)),!0)}parseText(){}parseClose(l){return this.parser?(this.parser.parseClose(l)||(this.parser=void 0),!0):l===this.tag?(this.model=this.map["a:hlinkClick"].model,!1):!0}}},{"../base-xform":32,"./ext-lst-xform":63,"./hlink-click-xform":65}],61:[function(t,n,s){const o=t("../base-xform"),i=t("../simple/integer-xform");n.exports=class extends o{constructor(c){super(),this.tag=c.tag,this.map={"xdr:col":new i({tag:"xdr:col",zero:!0}),"xdr:colOff":new i({tag:"xdr:colOff",zero:!0}),"xdr:row":new i({tag:"xdr:row",zero:!0}),"xdr:rowOff":new i({tag:"xdr:rowOff",zero:!0})}}render(c,l){c.openNode(this.tag),this.map["xdr:col"].render(c,l.nativeCol),this.map["xdr:colOff"].render(c,l.nativeColOff),this.map["xdr:row"].render(c,l.nativeRow),this.map["xdr:rowOff"].render(c,l.nativeRowOff),c.closeNode()}parseOpen(c){return this.parser?(this.parser.parseOpen(c),!0):(c.name===this.tag?this.reset():(this.parser=this.map[c.name],this.parser&&this.parser.parseOpen(c)),!0)}parseText(c){this.parser&&this.parser.parseText(c)}parseClose(c){return this.parser?(this.parser.parseClose(c)||(this.parser=void 0),!0):c===this.tag?(this.model={nativeCol:this.map["xdr:col"].model,nativeColOff:this.map["xdr:colOff"].model,nativeRow:this.map["xdr:row"].model,nativeRowOff:this.map["xdr:rowOff"].model},!1):!0}}},{"../base-xform":32,"../simple/integer-xform":118}],62:[function(t,n,s){const o=t("../../../utils/col-cache"),i=t("../../../utils/xml-stream"),c=t("../base-xform"),l=t("./two-cell-anchor-xform"),a=t("./one-cell-anchor-xform");class u extends c{constructor(){super(),this.map={"xdr:twoCellAnchor":new l,"xdr:oneCellAnchor":new a}}prepare(d){d.anchors.forEach((f,m)=>{f.anchorType=(function(p){return(typeof p.range=="string"?o.decode(p.range):p.range).br?"xdr:twoCellAnchor":"xdr:oneCellAnchor"})(f),this.map[f.anchorType].prepare(f,{index:m})})}get tag(){return"xdr:wsDr"}render(d,f){d.openXml(i.StdDocAttributes),d.openNode(this.tag,u.DRAWING_ATTRIBUTES),f.anchors.forEach(m=>{this.map[m.anchorType].render(d,m)}),d.closeNode()}parseOpen(d){return this.parser?(this.parser.parseOpen(d),!0):(d.name===this.tag?(this.reset(),this.model={anchors:[]}):(this.parser=this.map[d.name],this.parser&&this.parser.parseOpen(d)),!0)}parseText(d){this.parser&&this.parser.parseText(d)}parseClose(d){return this.parser?(this.parser.parseClose(d)||(this.model.anchors.push(this.parser.model),this.parser=void 0),!0):d!==this.tag}reconcile(d,f){d.anchors.forEach(m=>{m.br?this.map["xdr:twoCellAnchor"].reconcile(m,f):this.map["xdr:oneCellAnchor"].reconcile(m,f)})}}u.DRAWING_ATTRIBUTES={"xmlns:xdr":"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing","xmlns:a":"http://schemas.openxmlformats.org/drawingml/2006/main"},n.exports=u},{"../../../utils/col-cache":19,"../../../utils/xml-stream":28,"../base-xform":32,"./one-cell-anchor-xform":67,"./two-cell-anchor-xform":70}],63:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"a:extLst"}render(i){i.openNode(this.tag),i.openNode("a:ext",{uri:"{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"}),i.leafNode("a16:creationId",{"xmlns:a16":"http://schemas.microsoft.com/office/drawing/2014/main",id:"{00000000-0008-0000-0000-000002000000}"}),i.closeNode(),i.closeNode()}parseOpen(i){switch(i.name){case this.tag:default:return!0}}parseText(){}parseClose(i){return i!==this.tag}}},{"../base-xform":32}],64:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{constructor(i){super(),this.tag=i.tag,this.map={}}render(i,c){i.openNode(this.tag);const l=Math.floor(9525*c.width),a=Math.floor(9525*c.height);i.addAttribute("cx",l),i.addAttribute("cy",a),i.closeNode()}parseOpen(i){return i.name===this.tag&&(this.model={width:parseInt(i.attributes.cx||"0",10)/9525,height:parseInt(i.attributes.cy||"0",10)/9525},!0)}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],65:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"a:hlinkClick"}render(i,c){c.hyperlinks&&c.hyperlinks.rId&&i.leafNode(this.tag,{"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","r:id":c.hyperlinks.rId,tooltip:c.hyperlinks.tooltip})}parseOpen(i){return i.name===this.tag&&(this.model={hyperlinks:{rId:i.attributes["r:id"],tooltip:i.attributes.tooltip}}),!0}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],66:[function(t,n,s){const o=t("../base-xform"),i=t("./c-nv-pr-xform"),c=t("./c-nv-pic-pr-xform");n.exports=class extends o{constructor(){super(),this.map={"xdr:cNvPr":new i,"xdr:cNvPicPr":new c}}get tag(){return"xdr:nvPicPr"}render(l,a){l.openNode(this.tag),this.map["xdr:cNvPr"].render(l,a),this.map["xdr:cNvPicPr"].render(l,a),l.closeNode()}parseOpen(l){return this.parser?(this.parser.parseOpen(l),!0):(l.name===this.tag?this.reset():(this.parser=this.map[l.name],this.parser&&this.parser.parseOpen(l)),!0)}parseText(){}parseClose(l){return this.parser?(this.parser.parseClose(l)||(this.parser=void 0),!0):l===this.tag?(this.model=this.map["xdr:cNvPr"].model,!1):!0}}},{"../base-xform":32,"./c-nv-pic-pr-xform":59,"./c-nv-pr-xform":60}],67:[function(t,n,s){const o=t("./base-cell-anchor-xform"),i=t("../static-xform"),c=t("./cell-position-xform"),l=t("./ext-xform"),a=t("./pic-xform");n.exports=class extends o{constructor(){super(),this.map={"xdr:from":new c({tag:"xdr:from"}),"xdr:ext":new l({tag:"xdr:ext"}),"xdr:pic":new a,"xdr:clientData":new i({tag:"xdr:clientData"})}}get tag(){return"xdr:oneCellAnchor"}prepare(u,h){this.map["xdr:pic"].prepare(u.picture,h)}render(u,h){u.openNode(this.tag,{editAs:h.range.editAs||"oneCell"}),this.map["xdr:from"].render(u,h.range.tl),this.map["xdr:ext"].render(u,h.range.ext),this.map["xdr:pic"].render(u,h.picture),this.map["xdr:clientData"].render(u,{}),u.closeNode()}parseClose(u){return this.parser?(this.parser.parseClose(u)||(this.parser=void 0),!0):u===this.tag?(this.model.range.tl=this.map["xdr:from"].model,this.model.range.ext=this.map["xdr:ext"].model,this.model.picture=this.map["xdr:pic"].model,!1):!0}reconcile(u,h){u.medium=this.reconcilePicture(u.picture,h)}}},{"../static-xform":120,"./base-cell-anchor-xform":56,"./cell-position-xform":61,"./ext-xform":64,"./pic-xform":68}],68:[function(t,n,s){const o=t("../base-xform"),i=t("../static-xform"),c=t("./blip-fill-xform"),l=t("./nv-pic-pr-xform"),a=t("./sp-pr");n.exports=class extends o{constructor(){super(),this.map={"xdr:nvPicPr":new l,"xdr:blipFill":new c,"xdr:spPr":new i(a)}}get tag(){return"xdr:pic"}prepare(u,h){u.index=h.index+1}render(u,h){u.openNode(this.tag),this.map["xdr:nvPicPr"].render(u,h),this.map["xdr:blipFill"].render(u,h),this.map["xdr:spPr"].render(u,h),u.closeNode()}parseOpen(u){return this.parser?(this.parser.parseOpen(u),!0):(u.name===this.tag?this.reset():(this.parser=this.map[u.name],this.parser&&this.parser.parseOpen(u)),!0)}parseText(){}parseClose(u){return this.parser?(this.parser.parseClose(u)||(this.mergeModel(this.parser.model),this.parser=void 0),!0):u!==this.tag}}},{"../base-xform":32,"../static-xform":120,"./blip-fill-xform":57,"./nv-pic-pr-xform":66,"./sp-pr":69}],69:[function(t,n,s){n.exports={tag:"xdr:spPr",c:[{tag:"a:xfrm",c:[{tag:"a:off",$:{x:"0",y:"0"}},{tag:"a:ext",$:{cx:"0",cy:"0"}}]},{tag:"a:prstGeom",$:{prst:"rect"},c:[{tag:"a:avLst"}]}]}},{}],70:[function(t,n,s){const o=t("./base-cell-anchor-xform"),i=t("../static-xform"),c=t("./cell-position-xform"),l=t("./pic-xform");n.exports=class extends o{constructor(){super(),this.map={"xdr:from":new c({tag:"xdr:from"}),"xdr:to":new c({tag:"xdr:to"}),"xdr:pic":new l,"xdr:clientData":new i({tag:"xdr:clientData"})}}get tag(){return"xdr:twoCellAnchor"}prepare(a,u){this.map["xdr:pic"].prepare(a.picture,u)}render(a,u){a.openNode(this.tag,{editAs:u.range.editAs||"oneCell"}),this.map["xdr:from"].render(a,u.range.tl),this.map["xdr:to"].render(a,u.range.br),this.map["xdr:pic"].render(a,u.picture),this.map["xdr:clientData"].render(a,{}),a.closeNode()}parseClose(a){return this.parser?(this.parser.parseClose(a)||(this.parser=void 0),!0):a===this.tag?(this.model.range.tl=this.map["xdr:from"].model,this.model.range.br=this.map["xdr:to"].model,this.model.picture=this.map["xdr:pic"].model,!1):!0}reconcile(a,u){a.medium=this.reconcilePicture(a.picture,u)}}},{"../static-xform":120,"./base-cell-anchor-xform":56,"./cell-position-xform":61,"./pic-xform":68}],71:[function(t,n,s){const o=t("./base-xform");n.exports=class extends o{constructor(i){super(),this.tag=i.tag,this.always=!!i.always,this.count=i.count,this.empty=i.empty,this.$count=i.$count||"count",this.$=i.$,this.childXform=i.childXform,this.maxItems=i.maxItems}prepare(i,c){const{childXform:l}=this;i&&i.forEach((a,u)=>{c.index=u,l.prepare(a,c)})}render(i,c){if(this.always||c&&c.length){i.openNode(this.tag,this.$),this.count&&i.addAttribute(this.$count,c&&c.length||0);const{childXform:l}=this;(c||[]).forEach((a,u)=>{l.render(i,a,u)}),i.closeNode()}else this.empty&&i.leafNode(this.tag)}parseOpen(i){return this.parser?(this.parser.parseOpen(i),!0):i.name===this.tag?(this.model=[],!0):!!this.childXform.parseOpen(i)&&(this.parser=this.childXform,!0)}parseText(i){this.parser&&this.parser.parseText(i)}parseClose(i){if(this.parser){if(!this.parser.parseClose(i)&&(this.model.push(this.parser.model),this.parser=void 0,this.maxItems&&this.model.length>this.maxItems))throw new Error(`Max ${this.childXform.tag} count (${this.maxItems}) exceeded`);return!0}return!1}reconcile(i,c){if(i){const{childXform:l}=this;i.forEach(a=>{l.reconcile(a,c)})}}}},{"./base-xform":32}],72:[function(t,n,s){const o=t("../../../utils/col-cache"),i=t("../base-xform");n.exports=class extends i{get tag(){return"autoFilter"}render(c,l){if(l)if(typeof l=="string")c.leafNode("autoFilter",{ref:l});else{const a=function(d){return typeof d=="string"?d:o.getAddress(d.row,d.column).address},u=a(l.from),h=a(l.to);u&&h&&c.leafNode("autoFilter",{ref:`${u}:${h}`})}}parseOpen(c){c.name==="autoFilter"&&(this.model=c.attributes.ref)}}},{"../../../utils/col-cache":19,"../base-xform":32}],73:[function(t,n,s){const o=t("../../../utils/utils"),i=t("../base-xform"),c=t("../../../doc/range"),l=t("../../../doc/enums"),a=t("../strings/rich-text-xform");function u(h){if(h==null)return l.ValueType.Null;if(h instanceof String||typeof h=="string")return l.ValueType.String;if(typeof h=="number")return l.ValueType.Number;if(typeof h=="boolean")return l.ValueType.Boolean;if(h instanceof Date)return l.ValueType.Date;if(h.text&&h.hyperlink)return l.ValueType.Hyperlink;if(h.formula)return l.ValueType.Formula;if(h.error)return l.ValueType.Error;throw new Error("I could not understand type of value")}n.exports=class extends i{constructor(){super(),this.richTextXForm=new a}get tag(){return"c"}prepare(h,d){const f=d.styles.addStyleModel(h.style||{},(function(m){return m.type===l.ValueType.Formula?u(m.result):m.type})(h));switch(f&&(h.styleId=f),h.comment&&d.comments.push({...h.comment,ref:h.address}),h.type){case l.ValueType.String:case l.ValueType.RichText:d.sharedStrings&&(h.ssId=d.sharedStrings.add(h.value));break;case l.ValueType.Date:d.date1904&&(h.date1904=!0);break;case l.ValueType.Hyperlink:d.sharedStrings&&h.text!==void 0&&h.text!==null&&(h.ssId=d.sharedStrings.add(h.text)),d.hyperlinks.push({address:h.address,target:h.hyperlink,tooltip:h.tooltip});break;case l.ValueType.Merge:d.merges.add(h);break;case l.ValueType.Formula:if(d.date1904&&(h.date1904=!0),h.shareType==="shared"&&(h.si=d.siFormulae++),h.formula)d.formulae[h.address]=h;else if(h.sharedFormula){const m=d.formulae[h.sharedFormula];if(!m)throw new Error("Shared Formula master must exist above and or left of clone for cell "+h.address);m.si===void 0?(m.shareType="shared",m.si=d.siFormulae++,m.range=new c(m.address,h.address)):m.range&&m.range.expandToAddress(h.address),h.si=m.si}}}renderFormula(h,d){let f=null;switch(d.shareType){case"shared":f={t:"shared",ref:d.ref||d.range.range,si:d.si};break;case"array":f={t:"array",ref:d.ref};break;default:d.si!==void 0&&(f={t:"shared",si:d.si})}switch(u(d.result)){case l.ValueType.Null:h.leafNode("f",f,d.formula);break;case l.ValueType.String:h.addAttribute("t","str"),h.leafNode("f",f,d.formula),h.leafNode("v",null,d.result);break;case l.ValueType.Number:h.leafNode("f",f,d.formula),h.leafNode("v",null,d.result);break;case l.ValueType.Boolean:h.addAttribute("t","b"),h.leafNode("f",f,d.formula),h.leafNode("v",null,d.result?1:0);break;case l.ValueType.Error:h.addAttribute("t","e"),h.leafNode("f",f,d.formula),h.leafNode("v",null,d.result.error);break;case l.ValueType.Date:h.leafNode("f",f,d.formula),h.leafNode("v",null,o.dateToExcel(d.result,d.date1904));break;default:throw new Error("I could not understand type of value")}}render(h,d){if(d.type!==l.ValueType.Null||d.styleId){switch(h.openNode("c"),h.addAttribute("r",d.address),d.styleId&&h.addAttribute("s",d.styleId),d.type){case l.ValueType.Null:break;case l.ValueType.Number:h.leafNode("v",null,d.value);break;case l.ValueType.Boolean:h.addAttribute("t","b"),h.leafNode("v",null,d.value?"1":"0");break;case l.ValueType.Error:h.addAttribute("t","e"),h.leafNode("v",null,d.value.error);break;case l.ValueType.String:case l.ValueType.RichText:d.ssId!==void 0?(h.addAttribute("t","s"),h.leafNode("v",null,d.ssId)):d.value&&d.value.richText?(h.addAttribute("t","inlineStr"),h.openNode("is"),d.value.richText.forEach(f=>{this.richTextXForm.render(h,f)}),h.closeNode("is")):(h.addAttribute("t","str"),h.leafNode("v",null,d.value));break;case l.ValueType.Date:h.leafNode("v",null,o.dateToExcel(d.value,d.date1904));break;case l.ValueType.Hyperlink:d.ssId!==void 0?(h.addAttribute("t","s"),h.leafNode("v",null,d.ssId)):(h.addAttribute("t","str"),h.leafNode("v",null,d.text));break;case l.ValueType.Formula:this.renderFormula(h,d);break;case l.ValueType.Merge:}h.closeNode()}}parseOpen(h){if(this.parser)return this.parser.parseOpen(h),!0;switch(h.name){case"c":return this.model={address:h.attributes.r},this.t=h.attributes.t,h.attributes.s&&(this.model.styleId=parseInt(h.attributes.s,10)),!0;case"f":return this.currentNode="f",this.model.si=h.attributes.si,this.model.shareType=h.attributes.t,this.model.ref=h.attributes.ref,!0;case"v":return this.currentNode="v",!0;case"t":return this.currentNode="t",!0;case"r":return this.parser=this.richTextXForm,this.parser.parseOpen(h),!0;default:return!1}}parseText(h){if(this.parser)this.parser.parseText(h);else switch(this.currentNode){case"f":this.model.formula=this.model.formula?this.model.formula+h:h;break;case"v":case"t":this.model.value&&this.model.value.richText?this.model.value.richText.text=this.model.value.richText.text?this.model.value.richText.text+h:h:this.model.value=this.model.value?this.model.value+h:h}}parseClose(h){switch(h){case"c":{const{model:d}=this;if(d.formula||d.shareType)d.type=l.ValueType.Formula,d.value&&(this.t==="str"?d.result=o.xmlDecode(d.value):this.t==="b"?d.result=parseInt(d.value,10)!==0:this.t==="e"?d.result={error:d.value}:d.result=parseFloat(d.value),d.value=void 0);else if(d.value!==void 0)switch(this.t){case"s":d.type=l.ValueType.String,d.value=parseInt(d.value,10);break;case"str":d.type=l.ValueType.String,d.value=o.xmlDecode(d.value);break;case"inlineStr":d.type=l.ValueType.String;break;case"b":d.type=l.ValueType.Boolean,d.value=parseInt(d.value,10)!==0;break;case"e":d.type=l.ValueType.Error,d.value={error:d.value};break;default:d.type=l.ValueType.Number,d.value=parseFloat(d.value)}else d.styleId?d.type=l.ValueType.Null:d.type=l.ValueType.Merge;return!1}case"f":case"v":case"is":return this.currentNode=void 0,!0;case"t":return this.parser?(this.parser.parseClose(h),!0):(this.currentNode=void 0,!0);case"r":return this.model.value=this.model.value||{},this.model.value.richText=this.model.value.richText||[],this.model.value.richText.push(this.parser.model),this.parser=void 0,this.currentNode=void 0,!0;default:return!!this.parser&&(this.parser.parseClose(h),!0)}}reconcile(h,d){const f=h.styleId&&d.styles&&d.styles.getStyleModel(h.styleId);switch(f&&(h.style=f),h.styleId!==void 0&&(h.styleId=void 0),h.type){case l.ValueType.String:typeof h.value=="number"&&d.sharedStrings&&(h.value=d.sharedStrings.getString(h.value)),h.value.richText&&(h.type=l.ValueType.RichText);break;case l.ValueType.Number:f&&o.isDateFmt(f.numFmt)&&(h.type=l.ValueType.Date,h.value=o.excelToDate(h.value,d.date1904));break;case l.ValueType.Formula:h.result!==void 0&&f&&o.isDateFmt(f.numFmt)&&(h.result=o.excelToDate(h.result,d.date1904)),h.shareType==="shared"&&(h.ref?d.formulae[h.si]=h.address:(h.sharedFormula=d.formulae[h.si],delete h.shareType),delete h.si)}const m=d.hyperlinkMap[h.address];m&&(h.type===l.ValueType.Formula?(h.text=h.result,h.result=void 0):(h.text=h.value,h.value=void 0),h.type=l.ValueType.Hyperlink,h.hyperlink=m);const p=d.commentsMap&&d.commentsMap[h.address];p&&(h.comment=p)}}},{"../../../doc/enums":7,"../../../doc/range":10,"../../../utils/utils":27,"../base-xform":32,"../strings/rich-text-xform":122}],74:[function(t,n,s){const o=t("../../base-xform");n.exports=class extends o{get tag(){return"x14:cfIcon"}render(i,c){i.leafNode(this.tag,{iconSet:c.iconSet,iconId:c.iconId})}parseOpen(i){let{attributes:c}=i;this.model={iconSet:c.iconSet,iconId:o.toIntValue(c.iconId)}}parseClose(i){return i!==this.tag}}},{"../../base-xform":32}],75:[function(t,n,s){const{v4:o}=t("uuid"),i=t("../../base-xform"),c=t("../../composite-xform"),l=t("./databar-ext-xform"),a=t("./icon-set-ext-xform"),u={"3Triangles":!0,"3Stars":!0,"5Boxes":!0};class h extends c{constructor(){super(),this.map={"x14:dataBar":this.databarXform=new l,"x14:iconSet":this.iconSetXform=new a}}get tag(){return"x14:cfRule"}static isExt(f){return f.type==="dataBar"?l.isExt(f):!(f.type!=="iconSet"||!f.custom&&!u[f.iconSet])}prepare(f){h.isExt(f)&&(f.x14Id=`{${o()}}`.toUpperCase())}render(f,m){if(h.isExt(m))switch(m.type){case"dataBar":this.renderDataBar(f,m);break;case"iconSet":this.renderIconSet(f,m)}}renderDataBar(f,m){f.openNode(this.tag,{type:"dataBar",id:m.x14Id}),this.databarXform.render(f,m),f.closeNode()}renderIconSet(f,m){f.openNode(this.tag,{type:"iconSet",priority:m.priority,id:m.x14Id||`{${o()}}`}),this.iconSetXform.render(f,m),f.closeNode()}createNewModel(f){let{attributes:m}=f;return{type:m.type,x14Id:m.id,priority:i.toIntValue(m.priority)}}onParserClose(f,m){Object.assign(this.model,m.model)}}n.exports=h},{"../../base-xform":32,"../../composite-xform":48,"./databar-ext-xform":79,"./icon-set-ext-xform":81,uuid:528}],76:[function(t,n,s){const o=t("../../composite-xform"),i=t("./f-ext-xform");n.exports=class extends o{constructor(){super(),this.map={"xm:f":this.fExtXform=new i}}get tag(){return"x14:cfvo"}render(c,l){c.openNode(this.tag,{type:l.type}),l.value!==void 0&&this.fExtXform.render(c,l.value),c.closeNode()}createNewModel(c){return{type:c.attributes.type}}onParserClose(c,l){c==="xm:f"&&(this.model.value=l.model?parseFloat(l.model):0)}}},{"../../composite-xform":48,"./f-ext-xform":80}],77:[function(t,n,s){const o=t("../../composite-xform"),i=t("./sqref-ext-xform"),c=t("./cf-rule-ext-xform");n.exports=class extends o{constructor(){super(),this.map={"xm:sqref":this.sqRef=new i,"x14:cfRule":this.cfRule=new c}}get tag(){return"x14:conditionalFormatting"}prepare(l,a){l.rules.forEach(u=>{this.cfRule.prepare(u,a)})}render(l,a){a.rules.some(c.isExt)&&(l.openNode(this.tag,{"xmlns:xm":"http://schemas.microsoft.com/office/excel/2006/main"}),a.rules.filter(c.isExt).forEach(u=>this.cfRule.render(l,u)),this.sqRef.render(l,a.ref),l.closeNode())}createNewModel(){return{rules:[]}}onParserClose(l,a){switch(l){case"xm:sqref":this.model.ref=a.model;break;case"x14:cfRule":this.model.rules.push(a.model)}}}},{"../../composite-xform":48,"./cf-rule-ext-xform":75,"./sqref-ext-xform":82}],78:[function(t,n,s){const o=t("../../composite-xform"),i=t("./cf-rule-ext-xform"),c=t("./conditional-formatting-ext-xform");n.exports=class extends o{constructor(){super(),this.map={"x14:conditionalFormatting":this.cfXform=new c}}get tag(){return"x14:conditionalFormattings"}hasContent(l){return l.hasExtContent===void 0&&(l.hasExtContent=l.some(a=>a.rules.some(i.isExt))),l.hasExtContent}prepare(l,a){l.forEach(u=>{this.cfXform.prepare(u,a)})}render(l,a){this.hasContent(a)&&(l.openNode(this.tag),a.forEach(u=>this.cfXform.render(l,u)),l.closeNode())}createNewModel(){return[]}onParserClose(l,a){this.model.push(a.model)}}},{"../../composite-xform":48,"./cf-rule-ext-xform":75,"./conditional-formatting-ext-xform":77}],79:[function(t,n,s){const o=t("../../base-xform"),i=t("../../composite-xform"),c=t("../../style/color-xform"),l=t("./cfvo-ext-xform");n.exports=class extends i{constructor(){super(),this.map={"x14:cfvo":this.cfvoXform=new l,"x14:borderColor":this.borderColorXform=new c("x14:borderColor"),"x14:negativeBorderColor":this.negativeBorderColorXform=new c("x14:negativeBorderColor"),"x14:negativeFillColor":this.negativeFillColorXform=new c("x14:negativeFillColor"),"x14:axisColor":this.axisColorXform=new c("x14:axisColor")}}static isExt(a){return!a.gradient}get tag(){return"x14:dataBar"}render(a,u){a.openNode(this.tag,{minLength:o.toIntAttribute(u.minLength,0,!0),maxLength:o.toIntAttribute(u.maxLength,100,!0),border:o.toBoolAttribute(u.border,!1),gradient:o.toBoolAttribute(u.gradient,!0),negativeBarColorSameAsPositive:o.toBoolAttribute(u.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:o.toBoolAttribute(u.negativeBarBorderColorSameAsPositive,!0),axisPosition:o.toAttribute(u.axisPosition,"auto"),direction:o.toAttribute(u.direction,"leftToRight")}),u.cfvo.forEach(h=>{this.cfvoXform.render(a,h)}),this.borderColorXform.render(a,u.borderColor),this.negativeBorderColorXform.render(a,u.negativeBorderColor),this.negativeFillColorXform.render(a,u.negativeFillColor),this.axisColorXform.render(a,u.axisColor),a.closeNode()}createNewModel(a){let{attributes:u}=a;return{cfvo:[],minLength:o.toIntValue(u.minLength,0),maxLength:o.toIntValue(u.maxLength,100),border:o.toBoolValue(u.border,!1),gradient:o.toBoolValue(u.gradient,!0),negativeBarColorSameAsPositive:o.toBoolValue(u.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:o.toBoolValue(u.negativeBarBorderColorSameAsPositive,!0),axisPosition:o.toStringValue(u.axisPosition,"auto"),direction:o.toStringValue(u.direction,"leftToRight")}}onParserClose(a,u){const[,h]=a.split(":");h==="cfvo"?this.model.cfvo.push(u.model):this.model[h]=u.model}}},{"../../base-xform":32,"../../composite-xform":48,"../../style/color-xform":128,"./cfvo-ext-xform":76}],80:[function(t,n,s){const o=t("../../base-xform");n.exports=class extends o{get tag(){return"xm:f"}render(i,c){i.leafNode(this.tag,null,c)}parseOpen(){this.model=""}parseText(i){this.model+=i}parseClose(i){return i!==this.tag}}},{"../../base-xform":32}],81:[function(t,n,s){const o=t("../../base-xform"),i=t("../../composite-xform"),c=t("./cfvo-ext-xform"),l=t("./cf-icon-ext-xform");n.exports=class extends i{constructor(){super(),this.map={"x14:cfvo":this.cfvoXform=new c,"x14:cfIcon":this.cfIconXform=new l}}get tag(){return"x14:iconSet"}render(a,u){a.openNode(this.tag,{iconSet:o.toStringAttribute(u.iconSet),reverse:o.toBoolAttribute(u.reverse,!1),showValue:o.toBoolAttribute(u.showValue,!0),custom:o.toBoolAttribute(u.icons,!1)}),u.cfvo.forEach(h=>{this.cfvoXform.render(a,h)}),u.icons&&u.icons.forEach((h,d)=>{h.iconId=d,this.cfIconXform.render(a,h)}),a.closeNode()}createNewModel(a){let{attributes:u}=a;return{cfvo:[],iconSet:o.toStringValue(u.iconSet,"3TrafficLights"),reverse:o.toBoolValue(u.reverse,!1),showValue:o.toBoolValue(u.showValue,!0)}}onParserClose(a,u){const[,h]=a.split(":");switch(h){case"cfvo":this.model.cfvo.push(u.model);break;case"cfIcon":this.model.icons||(this.model.icons=[]),this.model.icons.push(u.model);break;default:this.model[h]=u.model}}}},{"../../base-xform":32,"../../composite-xform":48,"./cf-icon-ext-xform":74,"./cfvo-ext-xform":76}],82:[function(t,n,s){const o=t("../../base-xform");n.exports=class extends o{get tag(){return"xm:sqref"}render(i,c){i.leafNode(this.tag,null,c)}parseOpen(){this.model=""}parseText(i){this.model+=i}parseClose(i){return i!==this.tag}}},{"../../base-xform":32}],83:[function(t,n,s){const o=t("../../base-xform"),i=t("../../composite-xform"),c=t("../../../../doc/range"),l=t("./databar-xform"),a=t("./ext-lst-ref-xform"),u=t("./formula-xform"),h=t("./color-scale-xform"),d=t("./icon-set-xform"),f={"3Triangles":!0,"3Stars":!0,"5Boxes":!0},m=g=>{const{type:b,operator:y}=g;switch(b){case"containsText":case"containsBlanks":case"notContainsBlanks":case"containsErrors":case"notContainsErrors":return{type:"containsText",operator:b};default:return{type:b,operator:y}}};class p extends i{constructor(){super(),this.map={dataBar:this.databarXform=new l,extLst:this.extLstRefXform=new a,formula:this.formulaXform=new u,colorScale:this.colorScaleXform=new h,iconSet:this.iconSetXform=new d}}get tag(){return"cfRule"}static isPrimitive(b){return b.type!=="iconSet"||!b.custom&&!f[b.iconSet]}render(b,y){switch(y.type){case"expression":this.renderExpression(b,y);break;case"cellIs":this.renderCellIs(b,y);break;case"top10":this.renderTop10(b,y);break;case"aboveAverage":this.renderAboveAverage(b,y);break;case"dataBar":this.renderDataBar(b,y);break;case"colorScale":this.renderColorScale(b,y);break;case"iconSet":this.renderIconSet(b,y);break;case"containsText":this.renderText(b,y);break;case"timePeriod":this.renderTimePeriod(b,y)}}renderExpression(b,y){b.openNode(this.tag,{type:"expression",dxfId:y.dxfId,priority:y.priority}),this.formulaXform.render(b,y.formulae[0]),b.closeNode()}renderCellIs(b,y){b.openNode(this.tag,{type:"cellIs",dxfId:y.dxfId,priority:y.priority,operator:y.operator}),y.formulae.forEach(w=>{this.formulaXform.render(b,w)}),b.closeNode()}renderTop10(b,y){b.leafNode(this.tag,{type:"top10",dxfId:y.dxfId,priority:y.priority,percent:o.toBoolAttribute(y.percent,!1),bottom:o.toBoolAttribute(y.bottom,!1),rank:o.toIntValue(y.rank,10,!0)})}renderAboveAverage(b,y){b.leafNode(this.tag,{type:"aboveAverage",dxfId:y.dxfId,priority:y.priority,aboveAverage:o.toBoolAttribute(y.aboveAverage,!0)})}renderDataBar(b,y){b.openNode(this.tag,{type:"dataBar",priority:y.priority}),this.databarXform.render(b,y),this.extLstRefXform.render(b,y),b.closeNode()}renderColorScale(b,y){b.openNode(this.tag,{type:"colorScale",priority:y.priority}),this.colorScaleXform.render(b,y),b.closeNode()}renderIconSet(b,y){p.isPrimitive(y)&&(b.openNode(this.tag,{type:"iconSet",priority:y.priority}),this.iconSetXform.render(b,y),b.closeNode())}renderText(b,y){b.openNode(this.tag,{type:y.operator,dxfId:y.dxfId,priority:y.priority,operator:o.toStringAttribute(y.operator,"containsText")});const w=(C=>{if(C.formulae&&C.formulae[0])return C.formulae[0];const N=new c(C.ref),{tl:I}=N;switch(C.operator){case"containsText":return`NOT(ISERROR(SEARCH("${C.text}",${I})))`;case"containsBlanks":return`LEN(TRIM(${I}))=0`;case"notContainsBlanks":return`LEN(TRIM(${I}))>0`;case"containsErrors":return`ISERROR(${I})`;case"notContainsErrors":return`NOT(ISERROR(${I}))`;default:return}})(y);w&&this.formulaXform.render(b,w),b.closeNode()}renderTimePeriod(b,y){b.openNode(this.tag,{type:"timePeriod",dxfId:y.dxfId,priority:y.priority,timePeriod:y.timePeriod});const w=(C=>{if(C.formulae&&C.formulae[0])return C.formulae[0];const N=new c(C.ref),{tl:I}=N;switch(C.timePeriod){case"thisWeek":return`AND(TODAY()-ROUNDDOWN(${I},0)<=WEEKDAY(TODAY())-1,ROUNDDOWN(${I},0)-TODAY()<=7-WEEKDAY(TODAY()))`;case"lastWeek":return`AND(TODAY()-ROUNDDOWN(${I},0)>=(WEEKDAY(TODAY())),TODAY()-ROUNDDOWN(${I},0)<(WEEKDAY(TODAY())+7))`;case"nextWeek":return`AND(ROUNDDOWN(${I},0)-TODAY()>(7-WEEKDAY(TODAY())),ROUNDDOWN(${I},0)-TODAY()<(15-WEEKDAY(TODAY())))`;case"yesterday":return`FLOOR(${I},1)=TODAY()-1`;case"today":return`FLOOR(${I},1)=TODAY()`;case"tomorrow":return`FLOOR(${I},1)=TODAY()+1`;case"last7Days":return`AND(TODAY()-FLOOR(${I},1)<=6,FLOOR(${I},1)<=TODAY())`;case"lastMonth":return`AND(MONTH(${I})=MONTH(EDATE(TODAY(),0-1)),YEAR(${I})=YEAR(EDATE(TODAY(),0-1)))`;case"thisMonth":return`AND(MONTH(${I})=MONTH(TODAY()),YEAR(${I})=YEAR(TODAY()))`;case"nextMonth":return`AND(MONTH(${I})=MONTH(EDATE(TODAY(),0+1)),YEAR(${I})=YEAR(EDATE(TODAY(),0+1)))`;default:return}})(y);w&&this.formulaXform.render(b,w),b.closeNode()}createNewModel(b){let{attributes:y}=b;return{...m(y),dxfId:o.toIntValue(y.dxfId),priority:o.toIntValue(y.priority),timePeriod:y.timePeriod,percent:o.toBoolValue(y.percent),bottom:o.toBoolValue(y.bottom),rank:o.toIntValue(y.rank),aboveAverage:o.toBoolValue(y.aboveAverage)}}onParserClose(b,y){switch(b){case"dataBar":case"extLst":case"colorScale":case"iconSet":Object.assign(this.model,y.model);break;case"formula":this.model.formulae=this.model.formulae||[],this.model.formulae.push(y.model)}}}n.exports=p},{"../../../../doc/range":10,"../../base-xform":32,"../../composite-xform":48,"./color-scale-xform":85,"./databar-xform":88,"./ext-lst-ref-xform":89,"./formula-xform":90,"./icon-set-xform":91}],84:[function(t,n,s){const o=t("../../base-xform");n.exports=class extends o{get tag(){return"cfvo"}render(i,c){i.leafNode(this.tag,{type:c.type,val:c.value})}parseOpen(i){this.model={type:i.attributes.type,value:o.toFloatValue(i.attributes.val)}}parseClose(i){return i!==this.tag}}},{"../../base-xform":32}],85:[function(t,n,s){const o=t("../../composite-xform"),i=t("../../style/color-xform"),c=t("./cfvo-xform");n.exports=class extends o{constructor(){super(),this.map={cfvo:this.cfvoXform=new c,color:this.colorXform=new i}}get tag(){return"colorScale"}render(l,a){l.openNode(this.tag),a.cfvo.forEach(u=>{this.cfvoXform.render(l,u)}),a.color.forEach(u=>{this.colorXform.render(l,u)}),l.closeNode()}createNewModel(l){return{cfvo:[],color:[]}}onParserClose(l,a){this.model[l].push(a.model)}}},{"../../composite-xform":48,"../../style/color-xform":128,"./cfvo-xform":84}],86:[function(t,n,s){const o=t("../../composite-xform"),i=t("./cf-rule-xform");n.exports=class extends o{constructor(){super(),this.map={cfRule:new i}}get tag(){return"conditionalFormatting"}render(c,l){l.rules.some(i.isPrimitive)&&(c.openNode(this.tag,{sqref:l.ref}),l.rules.forEach(a=>{i.isPrimitive(a)&&(a.ref=l.ref,this.map.cfRule.render(c,a))}),c.closeNode())}createNewModel(c){let{attributes:l}=c;return{ref:l.sqref,rules:[]}}onParserClose(c,l){this.model.rules.push(l.model)}}},{"../../composite-xform":48,"./cf-rule-xform":83}],87:[function(t,n,s){const o=t("../../base-xform"),i=t("./conditional-formatting-xform");n.exports=class extends o{constructor(){super(),this.cfXform=new i}get tag(){return"conditionalFormatting"}reset(){this.model=[]}prepare(c,l){let a=c.reduce((u,h)=>Math.max(u,...h.rules.map(d=>d.priority||0)),1);c.forEach(u=>{u.rules.forEach(h=>{h.priority||(h.priority=a++),h.style&&(h.dxfId=l.styles.addDxfStyle(h.style))})})}render(c,l){l.forEach(a=>{this.cfXform.render(c,a)})}parseOpen(c){return this.parser?(this.parser.parseOpen(c),!0):c.name==="conditionalFormatting"?(this.parser=this.cfXform,this.parser.parseOpen(c),!0):!1}parseText(c){this.parser&&this.parser.parseText(c)}parseClose(c){return!!this.parser&&(!!this.parser.parseClose(c)||(this.model.push(this.parser.model),this.parser=void 0,!1))}reconcile(c,l){c.forEach(a=>{a.rules.forEach(u=>{u.dxfId!==void 0&&(u.style=l.styles.getDxfStyle(u.dxfId),delete u.dxfId)})})}}},{"../../base-xform":32,"./conditional-formatting-xform":86}],88:[function(t,n,s){const o=t("../../composite-xform"),i=t("../../style/color-xform"),c=t("./cfvo-xform");n.exports=class extends o{constructor(){super(),this.map={cfvo:this.cfvoXform=new c,color:this.colorXform=new i}}get tag(){return"dataBar"}render(l,a){l.openNode(this.tag),a.cfvo.forEach(u=>{this.cfvoXform.render(l,u)}),this.colorXform.render(l,a.color),l.closeNode()}createNewModel(){return{cfvo:[]}}onParserClose(l,a){switch(l){case"cfvo":this.model.cfvo.push(a.model);break;case"color":this.model.color=a.model}}}},{"../../composite-xform":48,"../../style/color-xform":128,"./cfvo-xform":84}],89:[function(t,n,s){const o=t("../../base-xform"),i=t("../../composite-xform");class c extends o{get tag(){return"x14:id"}render(u,h){u.leafNode(this.tag,null,h)}parseOpen(){this.model=""}parseText(u){this.model+=u}parseClose(u){return u!==this.tag}}class l extends i{constructor(){super(),this.map={"x14:id":this.idXform=new c}}get tag(){return"ext"}render(u,h){u.openNode(this.tag,{uri:"{B025F937-C7B1-47D3-B67F-A62EFF666E3E}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}),this.idXform.render(u,h.x14Id),u.closeNode()}createNewModel(){return{}}onParserClose(u,h){this.model.x14Id=h.model}}n.exports=class extends i{constructor(){super(),this.map={ext:new l}}get tag(){return"extLst"}render(a,u){a.openNode(this.tag),this.map.ext.render(a,u),a.closeNode()}createNewModel(){return{}}onParserClose(a,u){Object.assign(this.model,u.model)}}},{"../../base-xform":32,"../../composite-xform":48}],90:[function(t,n,s){const o=t("../../base-xform");n.exports=class extends o{get tag(){return"formula"}render(i,c){i.leafNode(this.tag,null,c)}parseOpen(){this.model=""}parseText(i){this.model+=i}parseClose(i){return i!==this.tag}}},{"../../base-xform":32}],91:[function(t,n,s){const o=t("../../base-xform"),i=t("../../composite-xform"),c=t("./cfvo-xform");n.exports=class extends i{constructor(){super(),this.map={cfvo:this.cfvoXform=new c}}get tag(){return"iconSet"}render(l,a){l.openNode(this.tag,{iconSet:o.toStringAttribute(a.iconSet,"3TrafficLights"),reverse:o.toBoolAttribute(a.reverse,!1),showValue:o.toBoolAttribute(a.showValue,!0)}),a.cfvo.forEach(u=>{this.cfvoXform.render(l,u)}),l.closeNode()}createNewModel(l){let{attributes:a}=l;return{iconSet:o.toStringValue(a.iconSet,"3TrafficLights"),reverse:o.toBoolValue(a.reverse),showValue:o.toBoolValue(a.showValue),cfvo:[]}}onParserClose(l,a){this.model[l].push(a.model)}}},{"../../base-xform":32,"../../composite-xform":48,"./cfvo-xform":84}],92:[function(t,n,s){const o=t("../../../utils/utils"),i=t("../base-xform");n.exports=class extends i{get tag(){return"col"}prepare(c,l){const a=l.styles.addStyleModel(c.style||{});a&&(c.styleId=a)}render(c,l){c.openNode("col"),c.addAttribute("min",l.min),c.addAttribute("max",l.max),l.width&&c.addAttribute("width",l.width),l.styleId&&c.addAttribute("style",l.styleId),l.hidden&&c.addAttribute("hidden","1"),l.bestFit&&c.addAttribute("bestFit","1"),l.outlineLevel&&c.addAttribute("outlineLevel",l.outlineLevel),l.collapsed&&c.addAttribute("collapsed","1"),c.addAttribute("customWidth","1"),c.closeNode()}parseOpen(c){if(c.name==="col"){const l=this.model={min:parseInt(c.attributes.min||"0",10),max:parseInt(c.attributes.max||"0",10),width:c.attributes.width===void 0?void 0:parseFloat(c.attributes.width||"0")};return c.attributes.style&&(l.styleId=parseInt(c.attributes.style,10)),o.parseBoolean(c.attributes.hidden)&&(l.hidden=!0),o.parseBoolean(c.attributes.bestFit)&&(l.bestFit=!0),c.attributes.outlineLevel&&(l.outlineLevel=parseInt(c.attributes.outlineLevel,10)),o.parseBoolean(c.attributes.collapsed)&&(l.collapsed=!0),!0}return!1}parseText(){}parseClose(){return!1}reconcile(c,l){c.styleId&&(c.style=l.styles.getStyleModel(c.styleId))}}},{"../../../utils/utils":27,"../base-xform":32}],93:[function(t,n,s){const o=t("../../../utils/under-dash"),i=t("../../../utils/utils"),c=t("../../../utils/col-cache"),l=t("../base-xform"),a=t("../../../doc/range");function u(d,f,m,p){const g=f[m];g!==void 0?d[m]=g:p!==void 0&&(d[m]=p)}function h(d,f,m,p){const g=f[m];g!==void 0&&(d[m]=i.parseBoolean(g))}n.exports=class extends l{get tag(){return"dataValidations"}render(d,f){const m=(function(p){const g=o.map(p,(w,C)=>({address:C,dataValidation:w,marked:!1})).sort((w,C)=>o.strcmp(w.address,C.address)),b=o.keyBy(g,"address"),y=(w,C,N)=>{for(let I=0;I<C;I++){const $=c.encodeAddress(w.row+I,N);if(!p[$]||!o.isEqual(p[w.address],p[$]))return!1}return!0};return g.map(w=>{if(!w.marked){const C=c.decodeEx(w.address);if(C.dimensions)return b[C.dimensions].marked=!0,{...w.dataValidation,sqref:w.address};let N=1,I=c.encodeAddress(C.row+N,C.col);for(;p[I]&&o.isEqual(w.dataValidation,p[I]);)N++,I=c.encodeAddress(C.row+N,C.col);let $=1;for(;y(C,N,C.col+$);)$++;for(let D=0;D<N;D++)for(let F=0;F<$;F++)I=c.encodeAddress(C.row+D,C.col+F),b[I].marked=!0;if(N>1||$>1){const D=C.row+(N-1),F=C.col+($-1);return{...w.dataValidation,sqref:`${w.address}:${c.encodeAddress(D,F)}`}}return{...w.dataValidation,sqref:w.address}}return null}).filter(Boolean)})(f);m.length&&(d.openNode("dataValidations",{count:m.length}),m.forEach(p=>{d.openNode("dataValidation"),p.type!=="any"&&(d.addAttribute("type",p.type),p.operator&&p.type!=="list"&&p.operator!=="between"&&d.addAttribute("operator",p.operator),p.allowBlank&&d.addAttribute("allowBlank","1")),p.showInputMessage&&d.addAttribute("showInputMessage","1"),p.promptTitle&&d.addAttribute("promptTitle",p.promptTitle),p.prompt&&d.addAttribute("prompt",p.prompt),p.showErrorMessage&&d.addAttribute("showErrorMessage","1"),p.errorStyle&&d.addAttribute("errorStyle",p.errorStyle),p.errorTitle&&d.addAttribute("errorTitle",p.errorTitle),p.error&&d.addAttribute("error",p.error),d.addAttribute("sqref",p.sqref),(p.formulae||[]).forEach((g,b)=>{d.openNode("formula"+(b+1)),p.type==="date"?d.writeText(i.dateToExcel(new Date(g))):d.writeText(g),d.closeNode()}),d.closeNode()}),d.closeNode())}parseOpen(d){switch(d.name){case"dataValidations":return this.model={},!0;case"dataValidation":{this._address=d.attributes.sqref;const f={type:d.attributes.type||"any",formulae:[]};switch(d.attributes.type&&h(f,d.attributes,"allowBlank"),h(f,d.attributes,"showInputMessage"),h(f,d.attributes,"showErrorMessage"),f.type){case"any":case"list":case"custom":break;default:u(f,d.attributes,"operator","between")}return u(f,d.attributes,"promptTitle"),u(f,d.attributes,"prompt"),u(f,d.attributes,"errorStyle"),u(f,d.attributes,"errorTitle"),u(f,d.attributes,"error"),this._dataValidation=f,!0}case"formula1":case"formula2":return this._formula=[],!0;default:return!1}}parseText(d){this._formula&&this._formula.push(d)}parseClose(d){switch(d){case"dataValidations":return!1;case"dataValidation":return this._dataValidation.formulae&&this._dataValidation.formulae.length||(delete this._dataValidation.formulae,delete this._dataValidation.operator),(this._address.split(/\s+/g)||[]).forEach(f=>{f.includes(":")?new a(f).forEachAddress(m=>{this.model[m]=this._dataValidation}):this.model[f]=this._dataValidation}),!0;case"formula1":case"formula2":{let f=this._formula.join("");switch(this._dataValidation.type){case"whole":case"textLength":f=parseInt(f,10);break;case"decimal":f=parseFloat(f);break;case"date":f=i.excelToDate(parseFloat(f))}return this._dataValidation.formulae.push(f),this._formula=void 0,!0}default:return!0}}}},{"../../../doc/range":10,"../../../utils/col-cache":19,"../../../utils/under-dash":26,"../../../utils/utils":27,"../base-xform":32}],94:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"dimension"}render(i,c){c&&i.leafNode("dimension",{ref:c})}parseOpen(i){return i.name==="dimension"&&(this.model=i.attributes.ref,!0)}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],95:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"drawing"}render(i,c){c&&i.leafNode(this.tag,{"r:id":c.rId})}parseOpen(i){return i.name===this.tag?(this.model={rId:i.attributes["r:id"]},!0):!1}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],96:[function(t,n,s){const o=t("../composite-xform"),i=t("./cf-ext/conditional-formattings-ext-xform");class c extends o{constructor(){super(),this.map={"x14:conditionalFormattings":this.conditionalFormattings=new i}}get tag(){return"ext"}hasContent(a){return this.conditionalFormattings.hasContent(a.conditionalFormattings)}prepare(a,u){this.conditionalFormattings.prepare(a.conditionalFormattings,u)}render(a,u){a.openNode("ext",{uri:"{78C0D931-6437-407d-A8EE-F0AAD7539E65}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}),this.conditionalFormattings.render(a,u.conditionalFormattings),a.closeNode()}createNewModel(){return{}}onParserClose(a,u){this.model[a]=u.model}}n.exports=class extends o{constructor(){super(),this.map={ext:this.ext=new c}}get tag(){return"extLst"}prepare(l,a){this.ext.prepare(l,a)}hasContent(l){return this.ext.hasContent(l)}render(l,a){this.hasContent(a)&&(l.openNode("extLst"),this.ext.render(l,a),l.closeNode())}createNewModel(){return{}}onParserClose(l,a){Object.assign(this.model,a.model)}}},{"../composite-xform":48,"./cf-ext/conditional-formattings-ext-xform":78}],97:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"headerFooter"}render(i,c){if(c){i.addRollback();let l=!1;i.openNode("headerFooter"),c.differentFirst&&(i.addAttribute("differentFirst","1"),l=!0),c.differentOddEven&&(i.addAttribute("differentOddEven","1"),l=!0),c.oddHeader&&typeof c.oddHeader=="string"&&(i.leafNode("oddHeader",null,c.oddHeader),l=!0),c.oddFooter&&typeof c.oddFooter=="string"&&(i.leafNode("oddFooter",null,c.oddFooter),l=!0),c.evenHeader&&typeof c.evenHeader=="string"&&(i.leafNode("evenHeader",null,c.evenHeader),l=!0),c.evenFooter&&typeof c.evenFooter=="string"&&(i.leafNode("evenFooter",null,c.evenFooter),l=!0),c.firstHeader&&typeof c.firstHeader=="string"&&(i.leafNode("firstHeader",null,c.firstHeader),l=!0),c.firstFooter&&typeof c.firstFooter=="string"&&(i.leafNode("firstFooter",null,c.firstFooter),l=!0),l?(i.closeNode(),i.commit()):i.rollback()}}parseOpen(i){switch(i.name){case"headerFooter":return this.model={},i.attributes.differentFirst&&(this.model.differentFirst=parseInt(i.attributes.differentFirst,0)===1),i.attributes.differentOddEven&&(this.model.differentOddEven=parseInt(i.attributes.differentOddEven,0)===1),!0;case"oddHeader":return this.currentNode="oddHeader",!0;case"oddFooter":return this.currentNode="oddFooter",!0;case"evenHeader":return this.currentNode="evenHeader",!0;case"evenFooter":return this.currentNode="evenFooter",!0;case"firstHeader":return this.currentNode="firstHeader",!0;case"firstFooter":return this.currentNode="firstFooter",!0;default:return!1}}parseText(i){switch(this.currentNode){case"oddHeader":this.model.oddHeader=i;break;case"oddFooter":this.model.oddFooter=i;break;case"evenHeader":this.model.evenHeader=i;break;case"evenFooter":this.model.evenFooter=i;break;case"firstHeader":this.model.firstHeader=i;break;case"firstFooter":this.model.firstFooter=i}}parseClose(){switch(this.currentNode){case"oddHeader":case"oddFooter":case"evenHeader":case"evenFooter":case"firstHeader":case"firstFooter":return this.currentNode=void 0,!0;default:return!1}}}},{"../base-xform":32}],98:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"hyperlink"}render(i,c){this.isInternalLink(c)?i.leafNode("hyperlink",{ref:c.address,"r:id":c.rId,tooltip:c.tooltip,location:c.target}):i.leafNode("hyperlink",{ref:c.address,"r:id":c.rId,tooltip:c.tooltip})}parseOpen(i){return i.name==="hyperlink"&&(this.model={address:i.attributes.ref,rId:i.attributes["r:id"],tooltip:i.attributes.tooltip},i.attributes.location&&(this.model.target=i.attributes.location),!0)}parseText(){}parseClose(){return!1}isInternalLink(i){return i.target&&/^[^!]+![a-zA-Z]+[\d]+$/.test(i.target)}}},{"../base-xform":32}],99:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"mergeCell"}render(i,c){i.leafNode("mergeCell",{ref:c})}parseOpen(i){return i.name==="mergeCell"&&(this.model=i.attributes.ref,!0)}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],100:[function(t,n,s){const o=t("../../../utils/under-dash"),i=t("../../../doc/range"),c=t("../../../utils/col-cache"),l=t("../../../doc/enums");n.exports=class{constructor(){this.merges={}}add(a){if(this.merges[a.master])this.merges[a.master].expandToAddress(a.address);else{const u=`${a.master}:${a.address}`;this.merges[a.master]=new i(u)}}get mergeCells(){return o.map(this.merges,a=>a.range)}reconcile(a,u){o.each(a,h=>{const d=c.decode(h);for(let f=d.top;f<=d.bottom;f++){const m=u[f-1];for(let p=d.left;p<=d.right;p++){const g=m.cells[p-1];g?g.type===l.ValueType.Merge&&(g.master=d.tl):m.cells[p]={type:l.ValueType.Null,address:c.encodeAddress(f,p)}}}})}getMasterAddress(a){const u=this.hash[a];return u&&u.tl}}},{"../../../doc/enums":7,"../../../doc/range":10,"../../../utils/col-cache":19,"../../../utils/under-dash":26}],101:[function(t,n,s){const o=t("../base-xform"),i=c=>c!==void 0;n.exports=class extends o{get tag(){return"outlinePr"}render(c,l){return!(!l||!i(l.summaryBelow)&&!i(l.summaryRight))&&(c.leafNode(this.tag,{summaryBelow:i(l.summaryBelow)?Number(l.summaryBelow):void 0,summaryRight:i(l.summaryRight)?Number(l.summaryRight):void 0}),!0)}parseOpen(c){return c.name===this.tag&&(this.model={summaryBelow:i(c.attributes.summaryBelow)?!!Number(c.attributes.summaryBelow):void 0,summaryRight:i(c.attributes.summaryRight)?!!Number(c.attributes.summaryRight):void 0},!0)}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],102:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"brk"}render(i,c){i.leafNode("brk",c)}parseOpen(i){return i.name==="brk"&&(this.model=i.attributes.ref,!0)}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],103:[function(t,n,s){const o=t("../../../utils/under-dash"),i=t("../base-xform");n.exports=class extends i{get tag(){return"pageMargins"}render(c,l){if(l){const a={left:l.left,right:l.right,top:l.top,bottom:l.bottom,header:l.header,footer:l.footer};o.some(a,u=>u!==void 0)&&c.leafNode(this.tag,a)}}parseOpen(c){return c.name===this.tag?(this.model={left:parseFloat(c.attributes.left||.7),right:parseFloat(c.attributes.right||.7),top:parseFloat(c.attributes.top||.75),bottom:parseFloat(c.attributes.bottom||.75),header:parseFloat(c.attributes.header||.3),footer:parseFloat(c.attributes.footer||.3)},!0):!1}parseText(){}parseClose(){return!1}}},{"../../../utils/under-dash":26,"../base-xform":32}],104:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"pageSetUpPr"}render(i,c){return!(!c||!c.fitToPage)&&(i.leafNode(this.tag,{fitToPage:c.fitToPage?"1":void 0}),!0)}parseOpen(i){return i.name===this.tag&&(this.model={fitToPage:i.attributes.fitToPage==="1"},!0)}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],105:[function(t,n,s){const o=t("../../../utils/under-dash"),i=t("../base-xform");function c(h){return h?"1":void 0}function l(h){if(h==="overThenDown")return h}function a(h){switch(h){case"atEnd":case"asDisplyed":return h;default:return}}function u(h){switch(h){case"dash":case"blank":case"NA":return h;default:return}}n.exports=class extends i{get tag(){return"pageSetup"}render(h,d){if(d){const f={paperSize:d.paperSize,orientation:d.orientation,horizontalDpi:d.horizontalDpi,verticalDpi:d.verticalDpi,pageOrder:l(d.pageOrder),blackAndWhite:c(d.blackAndWhite),draft:c(d.draft),cellComments:a(d.cellComments),errors:u(d.errors),scale:d.scale,fitToWidth:d.fitToWidth,fitToHeight:d.fitToHeight,firstPageNumber:d.firstPageNumber,useFirstPageNumber:c(d.firstPageNumber),usePrinterDefaults:c(d.usePrinterDefaults),copies:d.copies};o.some(f,m=>m!==void 0)&&h.leafNode(this.tag,f)}}parseOpen(h){if(h.name===this.tag)return this.model={paperSize:(d=h.attributes.paperSize,d!==void 0?parseInt(d,10):void 0),orientation:h.attributes.orientation||"portrait",horizontalDpi:parseInt(h.attributes.horizontalDpi||"4294967295",10),verticalDpi:parseInt(h.attributes.verticalDpi||"4294967295",10),pageOrder:h.attributes.pageOrder||"downThenOver",blackAndWhite:h.attributes.blackAndWhite==="1",draft:h.attributes.draft==="1",cellComments:h.attributes.cellComments||"None",errors:h.attributes.errors||"displayed",scale:parseInt(h.attributes.scale||"100",10),fitToWidth:parseInt(h.attributes.fitToWidth||"1",10),fitToHeight:parseInt(h.attributes.fitToHeight||"1",10),firstPageNumber:parseInt(h.attributes.firstPageNumber||"1",10),useFirstPageNumber:h.attributes.useFirstPageNumber==="1",usePrinterDefaults:h.attributes.usePrinterDefaults==="1",copies:parseInt(h.attributes.copies||"1",10)},!0;return!1;var d}parseText(){}parseClose(){return!1}}},{"../../../utils/under-dash":26,"../base-xform":32}],106:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"picture"}render(i,c){c&&i.leafNode(this.tag,{"r:id":c.rId})}parseOpen(i){return i.name===this.tag?(this.model={rId:i.attributes["r:id"]},!0):!1}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],107:[function(t,n,s){const o=t("../../../utils/under-dash"),i=t("../base-xform");function c(l){return l?"1":void 0}n.exports=class extends i{get tag(){return"printOptions"}render(l,a){if(a){const u={headings:c(a.showRowColHeaders),gridLines:c(a.showGridLines),horizontalCentered:c(a.horizontalCentered),verticalCentered:c(a.verticalCentered)};o.some(u,h=>h!==void 0)&&l.leafNode(this.tag,u)}}parseOpen(l){return l.name===this.tag?(this.model={showRowColHeaders:l.attributes.headings==="1",showGridLines:l.attributes.gridLines==="1",horizontalCentered:l.attributes.horizontalCentered==="1",verticalCentered:l.attributes.verticalCentered==="1"},!0):!1}parseText(){}parseClose(){return!1}}},{"../../../utils/under-dash":26,"../base-xform":32}],108:[function(t,n,s){const o=t("./page-breaks-xform"),i=t("../list-xform");n.exports=class extends i{constructor(){super({tag:"rowBreaks",count:!0,childXform:new o})}render(c,l){if(l&&l.length){c.openNode(this.tag,this.$),this.count&&(c.addAttribute(this.$count,l.length),c.addAttribute("manualBreakCount",l.length));const{childXform:a}=this;l.forEach(u=>{a.render(c,u)}),c.closeNode()}else this.empty&&c.leafNode(this.tag)}}},{"../list-xform":71,"./page-breaks-xform":102}],109:[function(t,n,s){const o=t("../base-xform"),i=t("../../../utils/utils"),c=t("./cell-xform");n.exports=class extends o{constructor(l){super(),this.maxItems=l&&l.maxItems,this.map={c:new c}}get tag(){return"row"}prepare(l,a){const u=a.styles.addStyleModel(l.style);u&&(l.styleId=u);const h=this.map.c;l.cells.forEach(d=>{h.prepare(d,a)})}render(l,a,u){l.openNode("row"),l.addAttribute("r",a.number),a.height&&(l.addAttribute("ht",a.height),l.addAttribute("customHeight","1")),a.hidden&&l.addAttribute("hidden","1"),a.min>0&&a.max>0&&a.min<=a.max&&l.addAttribute("spans",`${a.min}:${a.max}`),a.styleId&&(l.addAttribute("s",a.styleId),l.addAttribute("customFormat","1")),l.addAttribute("x14ac:dyDescent","0.25"),a.outlineLevel&&l.addAttribute("outlineLevel",a.outlineLevel),a.collapsed&&l.addAttribute("collapsed","1");const h=this.map.c;a.cells.forEach(d=>{h.render(l,d,u)}),l.closeNode()}parseOpen(l){if(this.parser)return this.parser.parseOpen(l),!0;if(l.name==="row"){this.numRowsSeen+=1;const a=l.attributes.spans?l.attributes.spans.split(":").map(h=>parseInt(h,10)):[void 0,void 0],u=this.model={number:parseInt(l.attributes.r,10),min:a[0],max:a[1],cells:[]};return l.attributes.s&&(u.styleId=parseInt(l.attributes.s,10)),i.parseBoolean(l.attributes.hidden)&&(u.hidden=!0),i.parseBoolean(l.attributes.bestFit)&&(u.bestFit=!0),l.attributes.ht&&(u.height=parseFloat(l.attributes.ht)),l.attributes.outlineLevel&&(u.outlineLevel=parseInt(l.attributes.outlineLevel,10)),i.parseBoolean(l.attributes.collapsed)&&(u.collapsed=!0),!0}return this.parser=this.map[l.name],!!this.parser&&(this.parser.parseOpen(l),!0)}parseText(l){this.parser&&this.parser.parseText(l)}parseClose(l){if(this.parser){if(!this.parser.parseClose(l)){if(this.model.cells.push(this.parser.model),this.maxItems&&this.model.cells.length>this.maxItems)throw new Error(`Max column count (${this.maxItems}) exceeded`);this.parser=void 0}return!0}return!1}reconcile(l,a){l.style=l.styleId?a.styles.getStyleModel(l.styleId):{},l.styleId!==void 0&&(l.styleId=void 0);const u=this.map.c;l.cells.forEach(h=>{u.reconcile(h,a)})}}},{"../../../utils/utils":27,"../base-xform":32,"./cell-xform":73}],110:[function(t,n,s){const o=t("../../../utils/under-dash"),i=t("../base-xform");n.exports=class extends i{get tag(){return"sheetFormatPr"}render(c,l){if(l){const a={defaultRowHeight:l.defaultRowHeight,outlineLevelRow:l.outlineLevelRow,outlineLevelCol:l.outlineLevelCol,"x14ac:dyDescent":l.dyDescent};l.defaultColWidth&&(a.defaultColWidth=l.defaultColWidth),l.defaultRowHeight&&l.defaultRowHeight===15||(a.customHeight="1"),o.some(a,u=>u!==void 0)&&c.leafNode("sheetFormatPr",a)}}parseOpen(c){return c.name==="sheetFormatPr"&&(this.model={defaultRowHeight:parseFloat(c.attributes.defaultRowHeight||"0"),dyDescent:parseFloat(c.attributes["x14ac:dyDescent"]||"0"),outlineLevelRow:parseInt(c.attributes.outlineLevelRow||"0",10),outlineLevelCol:parseInt(c.attributes.outlineLevelCol||"0",10)},c.attributes.defaultColWidth&&(this.model.defaultColWidth=parseFloat(c.attributes.defaultColWidth)),!0)}parseText(){}parseClose(){return!1}}},{"../../../utils/under-dash":26,"../base-xform":32}],111:[function(t,n,s){const o=t("../base-xform"),i=t("../style/color-xform"),c=t("./page-setup-properties-xform"),l=t("./outline-properties-xform");n.exports=class extends o{constructor(){super(),this.map={tabColor:new i("tabColor"),pageSetUpPr:new c,outlinePr:new l}}get tag(){return"sheetPr"}render(a,u){if(u){a.addRollback(),a.openNode("sheetPr");let h=!1;h=this.map.tabColor.render(a,u.tabColor)||h,h=this.map.pageSetUpPr.render(a,u.pageSetup)||h,h=this.map.outlinePr.render(a,u.outlineProperties)||h,h?(a.closeNode(),a.commit()):a.rollback()}}parseOpen(a){return this.parser?(this.parser.parseOpen(a),!0):a.name===this.tag?(this.reset(),!0):!!this.map[a.name]&&(this.parser=this.map[a.name],this.parser.parseOpen(a),!0)}parseText(a){return!!this.parser&&(this.parser.parseText(a),!0)}parseClose(a){return this.parser?(this.parser.parseClose(a)||(this.parser=void 0),!0):(this.map.tabColor.model||this.map.pageSetUpPr.model||this.map.outlinePr.model?(this.model={},this.map.tabColor.model&&(this.model.tabColor=this.map.tabColor.model),this.map.pageSetUpPr.model&&(this.model.pageSetup=this.map.pageSetUpPr.model),this.map.outlinePr.model&&(this.model.outlineProperties=this.map.outlinePr.model)):this.model=null,!1)}}},{"../base-xform":32,"../style/color-xform":128,"./outline-properties-xform":101,"./page-setup-properties-xform":104}],112:[function(t,n,s){const o=t("../../../utils/under-dash"),i=t("../base-xform");function c(a,u){return a?u:void 0}function l(a,u){return a===u||void 0}n.exports=class extends i{get tag(){return"sheetProtection"}render(a,u){if(u){const h={sheet:c(u.sheet,"1"),selectLockedCells:u.selectLockedCells===!1?"1":void 0,selectUnlockedCells:u.selectUnlockedCells===!1?"1":void 0,formatCells:c(u.formatCells,"0"),formatColumns:c(u.formatColumns,"0"),formatRows:c(u.formatRows,"0"),insertColumns:c(u.insertColumns,"0"),insertRows:c(u.insertRows,"0"),insertHyperlinks:c(u.insertHyperlinks,"0"),deleteColumns:c(u.deleteColumns,"0"),deleteRows:c(u.deleteRows,"0"),sort:c(u.sort,"0"),autoFilter:c(u.autoFilter,"0"),pivotTables:c(u.pivotTables,"0")};u.sheet&&(h.algorithmName=u.algorithmName,h.hashValue=u.hashValue,h.saltValue=u.saltValue,h.spinCount=u.spinCount,h.objects=c(u.objects===!1,"1"),h.scenarios=c(u.scenarios===!1,"1")),o.some(h,d=>d!==void 0)&&a.leafNode(this.tag,h)}}parseOpen(a){return a.name===this.tag?(this.model={sheet:l(a.attributes.sheet,"1"),objects:a.attributes.objects!=="1"&&void 0,scenarios:a.attributes.scenarios!=="1"&&void 0,selectLockedCells:a.attributes.selectLockedCells!=="1"&&void 0,selectUnlockedCells:a.attributes.selectUnlockedCells!=="1"&&void 0,formatCells:l(a.attributes.formatCells,"0"),formatColumns:l(a.attributes.formatColumns,"0"),formatRows:l(a.attributes.formatRows,"0"),insertColumns:l(a.attributes.insertColumns,"0"),insertRows:l(a.attributes.insertRows,"0"),insertHyperlinks:l(a.attributes.insertHyperlinks,"0"),deleteColumns:l(a.attributes.deleteColumns,"0"),deleteRows:l(a.attributes.deleteRows,"0"),sort:l(a.attributes.sort,"0"),autoFilter:l(a.attributes.autoFilter,"0"),pivotTables:l(a.attributes.pivotTables,"0")},a.attributes.algorithmName&&(this.model.algorithmName=a.attributes.algorithmName,this.model.hashValue=a.attributes.hashValue,this.model.saltValue=a.attributes.saltValue,this.model.spinCount=parseInt(a.attributes.spinCount,10)),!0):!1}parseText(){}parseClose(){return!1}}},{"../../../utils/under-dash":26,"../base-xform":32}],113:[function(t,n,s){const o=t("../../../utils/col-cache"),i=t("../base-xform"),c={frozen:"frozen",frozenSplit:"frozen",split:"split"};n.exports=class extends i{get tag(){return"sheetView"}prepare(l){switch(l.state){case"frozen":case"split":break;default:l.state="normal"}}render(l,a){l.openNode("sheetView",{workbookViewId:a.workbookViewId||0});const u=function(p,g,b){b&&l.addAttribute(p,g)};let h,d,f,m;switch(u("rightToLeft","1",a.rightToLeft===!0),u("tabSelected","1",a.tabSelected),u("showRuler","0",a.showRuler===!1),u("showRowColHeaders","0",a.showRowColHeaders===!1),u("showGridLines","0",a.showGridLines===!1),u("zoomScale",a.zoomScale,a.zoomScale),u("zoomScaleNormal",a.zoomScaleNormal,a.zoomScaleNormal),u("view",a.style,a.style),a.state){case"frozen":d=a.xSplit||0,f=a.ySplit||0,h=a.topLeftCell||o.getAddress(f+1,d+1).address,m=(a.xSplit&&a.ySplit?"bottomRight":a.xSplit&&"topRight")||"bottomLeft",l.leafNode("pane",{xSplit:a.xSplit||void 0,ySplit:a.ySplit||void 0,topLeftCell:h,activePane:m,state:"frozen"}),l.leafNode("selection",{pane:m,activeCell:a.activeCell,sqref:a.activeCell});break;case"split":a.activePane==="topLeft"&&(a.activePane=void 0),l.leafNode("pane",{xSplit:a.xSplit||void 0,ySplit:a.ySplit||void 0,topLeftCell:a.topLeftCell,activePane:a.activePane}),l.leafNode("selection",{pane:a.activePane,activeCell:a.activeCell,sqref:a.activeCell});break;case"normal":a.activeCell&&l.leafNode("selection",{activeCell:a.activeCell,sqref:a.activeCell})}l.closeNode()}parseOpen(l){switch(l.name){case"sheetView":return this.sheetView={workbookViewId:parseInt(l.attributes.workbookViewId,10),rightToLeft:l.attributes.rightToLeft==="1",tabSelected:l.attributes.tabSelected==="1",showRuler:l.attributes.showRuler!=="0",showRowColHeaders:l.attributes.showRowColHeaders!=="0",showGridLines:l.attributes.showGridLines!=="0",zoomScale:parseInt(l.attributes.zoomScale||"100",10),zoomScaleNormal:parseInt(l.attributes.zoomScaleNormal||"100",10),style:l.attributes.view},this.pane=void 0,this.selections={},!0;case"pane":return this.pane={xSplit:parseInt(l.attributes.xSplit||"0",10),ySplit:parseInt(l.attributes.ySplit||"0",10),topLeftCell:l.attributes.topLeftCell,activePane:l.attributes.activePane||"topLeft",state:l.attributes.state},!0;case"selection":{const a=l.attributes.pane||"topLeft";return this.selections[a]={pane:a,activeCell:l.attributes.activeCell},!0}default:return!1}}parseText(){}parseClose(l){let a,u;return l==="sheetView"?(this.sheetView&&this.pane?(a=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,state:c[this.pane.state]||"split",xSplit:this.pane.xSplit,ySplit:this.pane.ySplit,topLeftCell:this.pane.topLeftCell,showRuler:this.sheetView.showRuler,showRowColHeaders:this.sheetView.showRowColHeaders,showGridLines:this.sheetView.showGridLines,zoomScale:this.sheetView.zoomScale,zoomScaleNormal:this.sheetView.zoomScaleNormal},this.model.state==="split"&&(a.activePane=this.pane.activePane),u=this.selections[this.pane.activePane],u&&u.activeCell&&(a.activeCell=u.activeCell),this.sheetView.style&&(a.style=this.sheetView.style)):(a=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,state:"normal",showRuler:this.sheetView.showRuler,showRowColHeaders:this.sheetView.showRowColHeaders,showGridLines:this.sheetView.showGridLines,zoomScale:this.sheetView.zoomScale,zoomScaleNormal:this.sheetView.zoomScaleNormal},u=this.selections.topLeft,u&&u.activeCell&&(a.activeCell=u.activeCell),this.sheetView.style&&(a.style=this.sheetView.style)),!1):!0}reconcile(){}}},{"../../../utils/col-cache":19,"../base-xform":32}],114:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"tablePart"}render(i,c){c&&i.leafNode(this.tag,{"r:id":c.rId})}parseOpen(i){return i.name===this.tag?(this.model={rId:i.attributes["r:id"]},!0):!1}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],115:[function(t,n,s){const o=t("../../../utils/under-dash"),i=t("../../../utils/col-cache"),c=t("../../../utils/xml-stream"),l=t("../../rel-type"),a=t("./merges"),u=t("../base-xform"),h=t("../list-xform"),d=t("./row-xform"),f=t("./col-xform"),m=t("./dimension-xform"),p=t("./hyperlink-xform"),g=t("./merge-cell-xform"),b=t("./data-validations-xform"),y=t("./sheet-properties-xform"),w=t("./sheet-format-properties-xform"),C=t("./sheet-view-xform"),N=t("./sheet-protection-xform"),I=t("./page-margins-xform"),$=t("./page-setup-xform"),D=t("./print-options-xform"),F=t("./auto-filter-xform"),V=t("./picture-xform"),G=t("./drawing-xform"),U=t("./table-part-xform"),E=t("./row-breaks-xform"),M=t("./header-footer-xform"),B=t("./cf/conditional-formattings-xform"),k=t("./ext-lst-xform"),_=(T,z)=>{if(!z||!z.length)return T;if(!T||!T.length)return z;const P={},O={};return T.forEach(X=>{P[X.ref]=X,X.rules.forEach(K=>{const{x14Id:J}=K;J&&(O[J]=K)})}),z.forEach(X=>{X.rules.forEach(K=>{const J=O[K.x14Id];J?((H,Z)=>{Object.keys(Z).forEach(L=>{const q=H[L],Y=Z[L];q===void 0&&Y!==void 0&&(H[L]=Y)})})(J,K):P[X.ref]?P[X.ref].rules.push(K):T.push({ref:X.ref,rules:[K]})})}),T};class S extends u{constructor(z){super();const{maxRows:P,maxCols:O,ignoreNodes:X}=z||{};this.ignoreNodes=X||[],this.map={sheetPr:new y,dimension:new m,sheetViews:new h({tag:"sheetViews",count:!1,childXform:new C}),sheetFormatPr:new w,cols:new h({tag:"cols",count:!1,childXform:new f}),sheetData:new h({tag:"sheetData",count:!1,empty:!0,childXform:new d({maxItems:O}),maxItems:P}),autoFilter:new F,mergeCells:new h({tag:"mergeCells",count:!0,childXform:new g}),rowBreaks:new E,hyperlinks:new h({tag:"hyperlinks",count:!1,childXform:new p}),pageMargins:new I,dataValidations:new b,pageSetup:new $,headerFooter:new M,printOptions:new D,picture:new V,drawing:new G,sheetProtection:new N,tableParts:new h({tag:"tableParts",count:!0,childXform:new U}),conditionalFormatting:new B,extLst:new k}}prepare(z,P){P.merges=new a,z.hyperlinks=P.hyperlinks=[],z.comments=P.comments=[],P.formulae={},P.siFormulae=0,this.map.cols.prepare(z.cols,P),this.map.sheetData.prepare(z.rows,P),this.map.conditionalFormatting.prepare(z.conditionalFormattings,P),z.mergeCells=P.merges.mergeCells;const O=z.rels=[];function X(H){return"rId"+(H.length+1)}if(z.hyperlinks.forEach(H=>{const Z=X(O);H.rId=Z,O.push({Id:Z,Type:l.Hyperlink,Target:H.target,TargetMode:"External"})}),z.comments.length>0){const H={Id:X(O),Type:l.Comments,Target:`../comments${z.id}.xml`};O.push(H);const Z={Id:X(O),Type:l.VmlDrawing,Target:`../drawings/vmlDrawing${z.id}.vml`};O.push(Z),z.comments.forEach(L=>{L.refAddress=i.decodeAddress(L.ref)}),P.commentRefs.push({commentName:"comments"+z.id,vmlDrawing:"vmlDrawing"+z.id})}const K=[];let J;z.media.forEach(H=>{if(H.type==="background"){const Z=X(O);J=P.media[H.imageId],O.push({Id:Z,Type:l.Image,Target:`../media/${J.name}.${J.extension}`}),z.background={rId:Z},z.image=P.media[H.imageId]}else if(H.type==="image"){let{drawing:Z}=z;J=P.media[H.imageId],Z||(Z=z.drawing={rId:X(O),name:"drawing"+ ++P.drawingsCount,anchors:[],rels:[]},P.drawings.push(Z),O.push({Id:Z.rId,Type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",Target:`../drawings/${Z.name}.xml`}));let L=this.preImageId===H.imageId?K[H.imageId]:K[Z.rels.length];L||(L=X(Z.rels),K[Z.rels.length]=L,Z.rels.push({Id:L,Type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",Target:`../media/${J.name}.${J.extension}`}));const q={picture:{rId:L},range:H.range};if(H.hyperlinks&&H.hyperlinks.hyperlink){const Y=X(Z.rels);K[Z.rels.length]=Y,q.picture.hyperlinks={tooltip:H.hyperlinks.tooltip,rId:Y},Z.rels.push({Id:Y,Type:l.Hyperlink,Target:H.hyperlinks.hyperlink,TargetMode:"External"})}this.preImageId=H.imageId,Z.anchors.push(q)}}),z.tables.forEach(H=>{const Z=X(O);H.rId=Z,O.push({Id:Z,Type:l.Table,Target:"../tables/"+H.target}),H.columns.forEach(L=>{const{style:q}=L;q&&(L.dxfId=P.styles.addDxfStyle(q))})}),this.map.extLst.prepare(z,P)}render(z,P){z.openXml(c.StdDocAttributes),z.openNode("worksheet",S.WORKSHEET_ATTRIBUTES);const O=P.properties?{defaultRowHeight:P.properties.defaultRowHeight,dyDescent:P.properties.dyDescent,outlineLevelCol:P.properties.outlineLevelCol,outlineLevelRow:P.properties.outlineLevelRow}:void 0;P.properties&&P.properties.defaultColWidth&&(O.defaultColWidth=P.properties.defaultColWidth);const X={outlineProperties:P.properties&&P.properties.outlineProperties,tabColor:P.properties&&P.properties.tabColor,pageSetup:P.pageSetup&&P.pageSetup.fitToPage?{fitToPage:P.pageSetup.fitToPage}:void 0},K=P.pageSetup&&P.pageSetup.margins,J={showRowColHeaders:P.pageSetup&&P.pageSetup.showRowColHeaders,showGridLines:P.pageSetup&&P.pageSetup.showGridLines,horizontalCentered:P.pageSetup&&P.pageSetup.horizontalCentered,verticalCentered:P.pageSetup&&P.pageSetup.verticalCentered},H=P.sheetProtection;this.map.sheetPr.render(z,X),this.map.dimension.render(z,P.dimensions),this.map.sheetViews.render(z,P.views),this.map.sheetFormatPr.render(z,O),this.map.cols.render(z,P.cols),this.map.sheetData.render(z,P.rows),this.map.sheetProtection.render(z,H),this.map.autoFilter.render(z,P.autoFilter),this.map.mergeCells.render(z,P.mergeCells),this.map.conditionalFormatting.render(z,P.conditionalFormattings),this.map.dataValidations.render(z,P.dataValidations),this.map.hyperlinks.render(z,P.hyperlinks),this.map.printOptions.render(z,J),this.map.pageMargins.render(z,K),this.map.pageSetup.render(z,P.pageSetup),this.map.headerFooter.render(z,P.headerFooter),this.map.rowBreaks.render(z,P.rowBreaks),this.map.drawing.render(z,P.drawing),this.map.picture.render(z,P.background),this.map.tableParts.render(z,P.tables),this.map.extLst.render(z,P),P.rels&&P.rels.forEach(Z=>{Z.Type===l.VmlDrawing&&z.leafNode("legacyDrawing",{"r:id":Z.Id})}),z.closeNode()}parseOpen(z){return this.parser?(this.parser.parseOpen(z),!0):z.name==="worksheet"?(o.each(this.map,P=>{P.reset()}),!0):(this.map[z.name]&&!this.ignoreNodes.includes(z.name)&&(this.parser=this.map[z.name],this.parser.parseOpen(z)),!0)}parseText(z){this.parser&&this.parser.parseText(z)}parseClose(z){if(this.parser)return this.parser.parseClose(z)||(this.parser=void 0),!0;if(z==="worksheet"){const P=this.map.sheetFormatPr.model||{};this.map.sheetPr.model&&this.map.sheetPr.model.tabColor&&(P.tabColor=this.map.sheetPr.model.tabColor),this.map.sheetPr.model&&this.map.sheetPr.model.outlineProperties&&(P.outlineProperties=this.map.sheetPr.model.outlineProperties);const O={fitToPage:this.map.sheetPr.model&&this.map.sheetPr.model.pageSetup&&this.map.sheetPr.model.pageSetup.fitToPage||!1,margins:this.map.pageMargins.model},X=Object.assign(O,this.map.pageSetup.model,this.map.printOptions.model),K=_(this.map.conditionalFormatting.model,this.map.extLst.model&&this.map.extLst.model["x14:conditionalFormattings"]);return this.model={dimensions:this.map.dimension.model,cols:this.map.cols.model,rows:this.map.sheetData.model,mergeCells:this.map.mergeCells.model,hyperlinks:this.map.hyperlinks.model,dataValidations:this.map.dataValidations.model,properties:P,views:this.map.sheetViews.model,pageSetup:X,headerFooter:this.map.headerFooter.model,background:this.map.picture.model,drawing:this.map.drawing.model,tables:this.map.tableParts.model,conditionalFormattings:K},this.map.autoFilter.model&&(this.model.autoFilter=this.map.autoFilter.model),this.map.sheetProtection.model&&(this.model.sheetProtection=this.map.sheetProtection.model),!1}else return!0}reconcile(z,P){const O=(z.relationships||[]).reduce((K,J)=>{if(K[J.Id]=J,J.Type===l.Comments&&(z.comments=P.comments[J.Target].comments),J.Type===l.VmlDrawing&&z.comments&&z.comments.length){const H=P.vmlDrawings[J.Target].comments;z.comments.forEach((Z,L)=>{Z.note=Object.assign({},Z.note,H[L])})}return K},{});if(P.commentsMap=(z.comments||[]).reduce((K,J)=>(J.ref&&(K[J.ref]=J),K),{}),P.hyperlinkMap=(z.hyperlinks||[]).reduce((K,J)=>(J.rId&&(K[J.address]=O[J.rId].Target),K),{}),P.formulae={},z.rows=z.rows&&z.rows.filter(Boolean)||[],z.rows.forEach(K=>{K.cells=K.cells&&K.cells.filter(Boolean)||[]}),this.map.cols.reconcile(z.cols,P),this.map.sheetData.reconcile(z.rows,P),this.map.conditionalFormatting.reconcile(z.conditionalFormattings,P),z.media=[],z.drawing){const K=O[z.drawing.rId].Target.match(/\/drawings\/([a-zA-Z0-9]+)[.][a-zA-Z]{3,4}$/);if(K){const J=K[1];P.drawings[J].anchors.forEach(H=>{if(H.medium){const Z={type:"image",imageId:H.medium.index,range:H.range,hyperlinks:H.picture.hyperlinks};z.media.push(Z)}})}}const X=z.background&&O[z.background.rId];if(X){const K=X.Target.split("/media/")[1],J=P.mediaIndex&&P.mediaIndex[K];J!==void 0&&z.media.push({type:"background",imageId:J})}z.tables=(z.tables||[]).map(K=>{const J=O[K.rId];return P.tables[J.Target]}),delete z.relationships,delete z.hyperlinks,delete z.comments}}S.WORKSHEET_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x14ac","xmlns:x14ac":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"},n.exports=S},{"../../../utils/col-cache":19,"../../../utils/under-dash":26,"../../../utils/xml-stream":28,"../../rel-type":31,"../base-xform":32,"../list-xform":71,"./auto-filter-xform":72,"./cf/conditional-formattings-xform":87,"./col-xform":92,"./data-validations-xform":93,"./dimension-xform":94,"./drawing-xform":95,"./ext-lst-xform":96,"./header-footer-xform":97,"./hyperlink-xform":98,"./merge-cell-xform":99,"./merges":100,"./page-margins-xform":103,"./page-setup-xform":105,"./picture-xform":106,"./print-options-xform":107,"./row-breaks-xform":108,"./row-xform":109,"./sheet-format-properties-xform":110,"./sheet-properties-xform":111,"./sheet-protection-xform":112,"./sheet-view-xform":113,"./table-part-xform":114}],116:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{constructor(i){super(),this.tag=i.tag,this.attr=i.attr}render(i,c){c&&(i.openNode(this.tag),i.closeNode())}parseOpen(i){i.name===this.tag&&(this.model=!0)}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],117:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{constructor(i){super(),this.tag=i.tag,this.attr=i.attr,this.attrs=i.attrs,this._format=i.format||function(c){try{return Number.isNaN(c.getTime())?"":c.toISOString()}catch{return""}},this._parse=i.parse||function(c){return new Date(c)}}render(i,c){c&&(i.openNode(this.tag),this.attrs&&i.addAttributes(this.attrs),this.attr?i.addAttribute(this.attr,this._format(c)):i.writeText(this._format(c)),i.closeNode())}parseOpen(i){i.name===this.tag&&(this.attr?this.model=this._parse(i.attributes[this.attr]):this.text=[])}parseText(i){this.attr||this.text.push(i)}parseClose(){return this.attr||(this.model=this._parse(this.text.join(""))),!1}}},{"../base-xform":32}],118:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{constructor(i){super(),this.tag=i.tag,this.attr=i.attr,this.attrs=i.attrs,this.zero=i.zero}render(i,c){(c||this.zero)&&(i.openNode(this.tag),this.attrs&&i.addAttributes(this.attrs),this.attr?i.addAttribute(this.attr,c):i.writeText(c),i.closeNode())}parseOpen(i){return i.name===this.tag&&(this.attr?this.model=parseInt(i.attributes[this.attr],10):this.text=[],!0)}parseText(i){this.attr||this.text.push(i)}parseClose(){return this.attr||(this.model=parseInt(this.text.join("")||0,10)),!1}}},{"../base-xform":32}],119:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{constructor(i){super(),this.tag=i.tag,this.attr=i.attr,this.attrs=i.attrs}render(i,c){c!==void 0&&(i.openNode(this.tag),this.attrs&&i.addAttributes(this.attrs),this.attr?i.addAttribute(this.attr,c):i.writeText(c),i.closeNode())}parseOpen(i){i.name===this.tag&&(this.attr?this.model=i.attributes[this.attr]:this.text=[])}parseText(i){this.attr||this.text.push(i)}parseClose(){return this.attr||(this.model=this.text.join("")),!1}}},{"../base-xform":32}],120:[function(t,n,s){const o=t("./base-xform"),i=t("../../utils/xml-stream");n.exports=class extends o{constructor(c){super(),this._model=c}render(c){if(!this._xml){const l=new i;(function a(u,h){u.openNode(h.tag,h.$),h.c&&h.c.forEach(d=>{a(u,d)}),h.t&&u.writeText(h.t),u.closeNode()})(l,this._model),this._xml=l.xml}c.writeXml(this._xml)}parseOpen(){return!0}parseText(){}parseClose(c){return c!==this._model.tag}}},{"../../utils/xml-stream":28,"./base-xform":32}],121:[function(t,n,s){const o=t("./text-xform"),i=t("./rich-text-xform"),c=t("../base-xform");n.exports=class extends c{constructor(){super(),this.map={r:new i,t:new o}}get tag(){return"rPh"}render(l,a){if(l.openNode(this.tag,{sb:a.sb||0,eb:a.eb||0}),a&&a.hasOwnProperty("richText")&&a.richText){const{r:u}=this.map;a.richText.forEach(h=>{u.render(l,h)})}else a&&this.map.t.render(l,a.text);l.closeNode()}parseOpen(l){const{name:a}=l;return this.parser?(this.parser.parseOpen(l),!0):a===this.tag?(this.model={sb:parseInt(l.attributes.sb,10),eb:parseInt(l.attributes.eb,10)},!0):(this.parser=this.map[a],!!this.parser&&(this.parser.parseOpen(l),!0))}parseText(l){this.parser&&this.parser.parseText(l)}parseClose(l){if(this.parser){if(!this.parser.parseClose(l)){switch(l){case"r":{let a=this.model.richText;a||(a=this.model.richText=[]),a.push(this.parser.model);break}case"t":this.model.text=this.parser.model}this.parser=void 0}return!0}return l!==this.tag}}},{"../base-xform":32,"./rich-text-xform":122,"./text-xform":125}],122:[function(t,n,s){const o=t("./text-xform"),i=t("../style/font-xform"),c=t("../base-xform");class l extends c{constructor(u){super(),this.model=u}get tag(){return"r"}get textXform(){return this._textXform||(this._textXform=new o)}get fontXform(){return this._fontXform||(this._fontXform=new i(l.FONT_OPTIONS))}render(u,h){h=h||this.model,u.openNode("r"),h.font&&this.fontXform.render(u,h.font),this.textXform.render(u,h.text),u.closeNode()}parseOpen(u){if(this.parser)return this.parser.parseOpen(u),!0;switch(u.name){case"r":return this.model={},!0;case"t":return this.parser=this.textXform,this.parser.parseOpen(u),!0;case"rPr":return this.parser=this.fontXform,this.parser.parseOpen(u),!0;default:return!1}}parseText(u){this.parser&&this.parser.parseText(u)}parseClose(u){switch(u){case"r":return!1;case"t":return this.model.text=this.parser.model,this.parser=void 0,!0;case"rPr":return this.model.font=this.parser.model,this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(u),!0}}}l.FONT_OPTIONS={tagName:"rPr",fontNameTag:"rFont"},n.exports=l},{"../base-xform":32,"../style/font-xform":131,"./text-xform":125}],123:[function(t,n,s){const o=t("./text-xform"),i=t("./rich-text-xform"),c=t("./phonetic-text-xform"),l=t("../base-xform");n.exports=class extends l{constructor(a){super(),this.model=a,this.map={r:new i,t:new o,rPh:new c}}get tag(){return"si"}render(a,u){a.openNode(this.tag),u&&u.hasOwnProperty("richText")&&u.richText?u.richText.length?u.richText.forEach(h=>{this.map.r.render(a,h)}):this.map.t.render(a,""):u!=null&&this.map.t.render(a,u),a.closeNode()}parseOpen(a){const{name:u}=a;return this.parser?(this.parser.parseOpen(a),!0):u===this.tag?(this.model={},!0):(this.parser=this.map[u],!!this.parser&&(this.parser.parseOpen(a),!0))}parseText(a){this.parser&&this.parser.parseText(a)}parseClose(a){if(this.parser){if(!this.parser.parseClose(a)){switch(a){case"r":{let u=this.model.richText;u||(u=this.model.richText=[]),u.push(this.parser.model);break}case"t":this.model=this.parser.model}this.parser=void 0}return!0}return a!==this.tag}}},{"../base-xform":32,"./phonetic-text-xform":121,"./rich-text-xform":122,"./text-xform":125}],124:[function(t,n,s){const o=t("../../../utils/xml-stream"),i=t("../base-xform"),c=t("./shared-string-xform");n.exports=class extends i{constructor(l){super(),this.model=l||{values:[],count:0},this.hash=Object.create(null),this.rich=Object.create(null)}get sharedStringXform(){return this._sharedStringXform||(this._sharedStringXform=new c)}get values(){return this.model.values}get uniqueCount(){return this.model.values.length}get count(){return this.model.count}getString(l){return this.model.values[l]}add(l){return l.richText?this.addRichText(l):this.addText(l)}addText(l){let a=this.hash[l];return a===void 0&&(a=this.hash[l]=this.model.values.length,this.model.values.push(l)),this.model.count++,a}addRichText(l){const a=this.sharedStringXform.toXml(l);let u=this.rich[a];return u===void 0&&(u=this.rich[a]=this.model.values.length,this.model.values.push(l)),this.model.count++,u}render(l,a){a=a||this._values,l.openXml(o.StdDocAttributes),l.openNode("sst",{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",count:a.count,uniqueCount:a.values.length});const u=this.sharedStringXform;a.values.forEach(h=>{u.render(l,h)}),l.closeNode()}parseOpen(l){if(this.parser)return this.parser.parseOpen(l),!0;switch(l.name){case"sst":return!0;case"si":return this.parser=this.sharedStringXform,this.parser.parseOpen(l),!0;default:throw new Error("Unexpected xml node in parseOpen: "+JSON.stringify(l))}}parseText(l){this.parser&&this.parser.parseText(l)}parseClose(l){if(this.parser)return this.parser.parseClose(l)||(this.model.values.push(this.parser.model),this.model.count++,this.parser=void 0),!0;if(l==="sst")return!1;throw new Error("Unexpected xml node in parseClose: "+l)}}},{"../../../utils/xml-stream":28,"../base-xform":32,"./shared-string-xform":123}],125:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"t"}render(i,c){i.openNode("t"),/^\s|\n|\s$/.test(c)&&i.addAttribute("xml:space","preserve"),i.writeText(c),i.closeNode()}get model(){return this._text.join("").replace(/_x([0-9A-F]{4})_/g,(i,c)=>String.fromCharCode(parseInt(c,16)))}parseOpen(i){return i.name==="t"?(this._text=[],!0):!1}parseText(i){this._text.push(i)}parseClose(){return!1}}},{"../base-xform":32}],126:[function(t,n,s){const o=t("../../../doc/enums"),i=t("../../../utils/utils"),c=t("../base-xform"),l={horizontalValues:["left","center","right","fill","centerContinuous","distributed","justify"].reduce((u,h)=>(u[h]=!0,u),{}),horizontal(u){return this.horizontalValues[u]?u:void 0},verticalValues:["top","middle","bottom","distributed","justify"].reduce((u,h)=>(u[h]=!0,u),{}),vertical(u){return u==="middle"?"center":this.verticalValues[u]?u:void 0},wrapText:u=>!!u||void 0,shrinkToFit:u=>!!u||void 0,textRotation(u){return u==="vertical"||(u=i.validInt(u))>=-90&&u<=90?u:void 0},indent:u=>(u=i.validInt(u),Math.max(0,u)),readingOrder(u){switch(u){case"ltr":return o.ReadingOrder.LeftToRight;case"rtl":return o.ReadingOrder.RightToLeft;default:return}}},a={toXml(u){if(u=l.textRotation(u)){if(u==="vertical")return 255;const h=Math.round(u);if(h>=0&&h<=90)return h;if(h<0&&h>=-90)return 90-h}},toModel(u){const h=i.validInt(u);if(h!==void 0){if(h===255)return"vertical";if(h>=0&&h<=90)return h;if(h>90&&h<=180)return 90-h}}};n.exports=class extends c{get tag(){return"alignment"}render(u,h){u.addRollback(),u.openNode("alignment");let d=!1;function f(m,p){p&&(u.addAttribute(m,p),d=!0)}f("horizontal",l.horizontal(h.horizontal)),f("vertical",l.vertical(h.vertical)),f("wrapText",!!l.wrapText(h.wrapText)&&"1"),f("shrinkToFit",!!l.shrinkToFit(h.shrinkToFit)&&"1"),f("indent",l.indent(h.indent)),f("textRotation",a.toXml(h.textRotation)),f("readingOrder",l.readingOrder(h.readingOrder)),u.closeNode(),d?u.commit():u.rollback()}parseOpen(u){const h={};let d=!1;function f(m,p,g){m&&(h[p]=g,d=!0)}f(u.attributes.horizontal,"horizontal",u.attributes.horizontal),f(u.attributes.vertical,"vertical",u.attributes.vertical==="center"?"middle":u.attributes.vertical),f(u.attributes.wrapText,"wrapText",i.parseBoolean(u.attributes.wrapText)),f(u.attributes.shrinkToFit,"shrinkToFit",i.parseBoolean(u.attributes.shrinkToFit)),f(u.attributes.indent,"indent",parseInt(u.attributes.indent,10)),f(u.attributes.textRotation,"textRotation",a.toModel(u.attributes.textRotation)),f(u.attributes.readingOrder,"readingOrder",u.attributes.readingOrder==="2"?"rtl":"ltr"),this.model=d?h:null}parseText(){}parseClose(){return!1}}},{"../../../doc/enums":7,"../../../utils/utils":27,"../base-xform":32}],127:[function(t,n,s){const o=t("../base-xform"),i=t("../../../utils/utils"),c=t("./color-xform");class l extends o{constructor(u){super(),this.name=u,this.map={color:new c}}get tag(){return this.name}render(u,h,d){const f=h&&h.color||d||this.defaultColor;u.openNode(this.name),h&&h.style&&(u.addAttribute("style",h.style),f&&this.map.color.render(u,f)),u.closeNode()}parseOpen(u){if(this.parser)return this.parser.parseOpen(u),!0;switch(u.name){case this.name:{const{style:h}=u.attributes;return this.model=h?{style:h}:void 0,!0}case"color":return this.parser=this.map.color,this.parser.parseOpen(u),!0;default:return!1}}parseText(u){this.parser&&this.parser.parseText(u)}parseClose(u){return this.parser?(this.parser.parseClose(u)||(this.parser=void 0),!0):(u===this.name&&this.map.color.model&&(this.model||(this.model={}),this.model.color=this.map.color.model),!1)}validStyle(u){return l.validStyleValues[u]}}l.validStyleValues=["thin","dashed","dotted","dashDot","hair","dashDotDot","slantDashDot","mediumDashed","mediumDashDotDot","mediumDashDot","medium","double","thick"].reduce((a,u)=>(a[u]=!0,a),{}),n.exports=class extends o{constructor(){super(),this.map={top:new l("top"),left:new l("left"),bottom:new l("bottom"),right:new l("right"),diagonal:new l("diagonal")}}render(a,u){const{color:h}=u;function d(f,m){f&&!f.color&&u.color&&(f={...f,color:u.color}),m.render(a,f,h)}a.openNode("border"),u.diagonal&&u.diagonal.style&&(u.diagonal.up&&a.addAttribute("diagonalUp","1"),u.diagonal.down&&a.addAttribute("diagonalDown","1")),d(u.left,this.map.left),d(u.right,this.map.right),d(u.top,this.map.top),d(u.bottom,this.map.bottom),d(u.diagonal,this.map.diagonal),a.closeNode()}parseOpen(a){return this.parser?(this.parser.parseOpen(a),!0):a.name==="border"?(this.reset(),this.diagonalUp=i.parseBoolean(a.attributes.diagonalUp),this.diagonalDown=i.parseBoolean(a.attributes.diagonalDown),!0):(this.parser=this.map[a.name],!!this.parser&&(this.parser.parseOpen(a),!0))}parseText(a){this.parser&&this.parser.parseText(a)}parseClose(a){if(this.parser)return this.parser.parseClose(a)||(this.parser=void 0),!0;if(a==="border"){const u=this.model={},h=function(d,f,m){f&&(m&&Object.assign(f,m),u[d]=f)};h("left",this.map.left.model),h("right",this.map.right.model),h("top",this.map.top.model),h("bottom",this.map.bottom.model),h("diagonal",this.map.diagonal.model,{up:this.diagonalUp,down:this.diagonalDown})}return!1}}},{"../../../utils/utils":27,"../base-xform":32,"./color-xform":128}],128:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{constructor(i){super(),this.name=i||"color"}get tag(){return this.name}render(i,c){return!!c&&(i.openNode(this.name),c.argb?i.addAttribute("rgb",c.argb):c.theme!==void 0?(i.addAttribute("theme",c.theme),c.tint!==void 0&&i.addAttribute("tint",c.tint)):c.indexed!==void 0?i.addAttribute("indexed",c.indexed):i.addAttribute("auto","1"),i.closeNode(),!0)}parseOpen(i){return i.name===this.name&&(i.attributes.rgb?this.model={argb:i.attributes.rgb}:i.attributes.theme?(this.model={theme:parseInt(i.attributes.theme,10)},i.attributes.tint&&(this.model.tint=parseFloat(i.attributes.tint))):i.attributes.indexed?this.model={indexed:parseInt(i.attributes.indexed,10)}:this.model=void 0,!0)}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],129:[function(t,n,s){const o=t("../base-xform"),i=t("./alignment-xform"),c=t("./border-xform"),l=t("./fill-xform"),a=t("./font-xform"),u=t("./numfmt-xform"),h=t("./protection-xform");n.exports=class extends o{constructor(){super(),this.map={alignment:new i,border:new c,fill:new l,font:new a,numFmt:new u,protection:new h}}get tag(){return"dxf"}render(d,f){if(d.openNode(this.tag),f.font&&this.map.font.render(d,f.font),f.numFmt&&f.numFmtId){const m={id:f.numFmtId,formatCode:f.numFmt};this.map.numFmt.render(d,m)}f.fill&&this.map.fill.render(d,f.fill),f.alignment&&this.map.alignment.render(d,f.alignment),f.border&&this.map.border.render(d,f.border),f.protection&&this.map.protection.render(d,f.protection),d.closeNode()}parseOpen(d){return this.parser?(this.parser.parseOpen(d),!0):d.name===this.tag?(this.reset(),!0):(this.parser=this.map[d.name],this.parser&&this.parser.parseOpen(d),!0)}parseText(d){this.parser&&this.parser.parseText(d)}parseClose(d){return this.parser?(this.parser.parseClose(d)||(this.parser=void 0),!0):d!==this.tag||(this.model={alignment:this.map.alignment.model,border:this.map.border.model,fill:this.map.fill.model,font:this.map.font.model,numFmt:this.map.numFmt.model,protection:this.map.protection.model},!1)}}},{"../base-xform":32,"./alignment-xform":126,"./border-xform":127,"./fill-xform":130,"./font-xform":131,"./numfmt-xform":132,"./protection-xform":133}],130:[function(t,n,s){const o=t("../base-xform"),i=t("./color-xform");class c extends o{constructor(){super(),this.map={color:new i}}get tag(){return"stop"}render(d,f){d.openNode("stop"),d.addAttribute("position",f.position),this.map.color.render(d,f.color),d.closeNode()}parseOpen(d){if(this.parser)return this.parser.parseOpen(d),!0;switch(d.name){case"stop":return this.model={position:parseFloat(d.attributes.position)},!0;case"color":return this.parser=this.map.color,this.parser.parseOpen(d),!0;default:return!1}}parseText(){}parseClose(d){return!!this.parser&&(this.parser.parseClose(d)||(this.model.color=this.parser.model,this.parser=void 0),!0)}}class l extends o{constructor(){super(),this.map={fgColor:new i("fgColor"),bgColor:new i("bgColor")}}get name(){return"pattern"}get tag(){return"patternFill"}render(d,f){d.openNode("patternFill"),d.addAttribute("patternType",f.pattern),f.fgColor&&this.map.fgColor.render(d,f.fgColor),f.bgColor&&this.map.bgColor.render(d,f.bgColor),d.closeNode()}parseOpen(d){return this.parser?(this.parser.parseOpen(d),!0):d.name==="patternFill"?(this.model={type:"pattern",pattern:d.attributes.patternType},!0):(this.parser=this.map[d.name],!!this.parser&&(this.parser.parseOpen(d),!0))}parseText(d){this.parser&&this.parser.parseText(d)}parseClose(d){return!!this.parser&&(this.parser.parseClose(d)||(this.parser.model&&(this.model[d]=this.parser.model),this.parser=void 0),!0)}}class a extends o{constructor(){super(),this.map={stop:new c}}get name(){return"gradient"}get tag(){return"gradientFill"}render(d,f){switch(d.openNode("gradientFill"),f.gradient){case"angle":d.addAttribute("degree",f.degree);break;case"path":d.addAttribute("type","path"),f.center.left&&(d.addAttribute("left",f.center.left),f.center.right===void 0&&d.addAttribute("right",f.center.left)),f.center.right&&d.addAttribute("right",f.center.right),f.center.top&&(d.addAttribute("top",f.center.top),f.center.bottom===void 0&&d.addAttribute("bottom",f.center.top)),f.center.bottom&&d.addAttribute("bottom",f.center.bottom)}const m=this.map.stop;f.stops.forEach(p=>{m.render(d,p)}),d.closeNode()}parseOpen(d){if(this.parser)return this.parser.parseOpen(d),!0;switch(d.name){case"gradientFill":{const f=this.model={stops:[]};return d.attributes.degree?(f.gradient="angle",f.degree=parseInt(d.attributes.degree,10)):d.attributes.type==="path"&&(f.gradient="path",f.center={left:d.attributes.left?parseFloat(d.attributes.left):0,top:d.attributes.top?parseFloat(d.attributes.top):0},d.attributes.right!==d.attributes.left&&(f.center.right=d.attributes.right?parseFloat(d.attributes.right):0),d.attributes.bottom!==d.attributes.top&&(f.center.bottom=d.attributes.bottom?parseFloat(d.attributes.bottom):0)),!0}case"stop":return this.parser=this.map.stop,this.parser.parseOpen(d),!0;default:return!1}}parseText(d){this.parser&&this.parser.parseText(d)}parseClose(d){return!!this.parser&&(this.parser.parseClose(d)||(this.model.stops.push(this.parser.model),this.parser=void 0),!0)}}class u extends o{constructor(){super(),this.map={patternFill:new l,gradientFill:new a}}get tag(){return"fill"}render(d,f){switch(d.addRollback(),d.openNode("fill"),f.type){case"pattern":this.map.patternFill.render(d,f);break;case"gradient":this.map.gradientFill.render(d,f);break;default:return void d.rollback()}d.closeNode(),d.commit()}parseOpen(d){return this.parser?(this.parser.parseOpen(d),!0):d.name==="fill"?(this.model={},!0):(this.parser=this.map[d.name],!!this.parser&&(this.parser.parseOpen(d),!0))}parseText(d){this.parser&&this.parser.parseText(d)}parseClose(d){return!!this.parser&&(this.parser.parseClose(d)||(this.model=this.parser.model,this.model.type=this.parser.name,this.parser=void 0),!0)}validStyle(d){return u.validPatternValues[d]}}u.validPatternValues=["none","solid","darkVertical","darkGray","mediumGray","lightGray","gray125","gray0625","darkHorizontal","darkVertical","darkDown","darkUp","darkGrid","darkTrellis","lightHorizontal","lightVertical","lightDown","lightUp","lightGrid","lightTrellis","lightGrid"].reduce((h,d)=>(h[d]=!0,h),{}),u.StopXform=c,u.PatternFillXform=l,u.GradientFillXform=a,n.exports=u},{"../base-xform":32,"./color-xform":128}],131:[function(t,n,s){const o=t("./color-xform"),i=t("../simple/boolean-xform"),c=t("../simple/integer-xform"),l=t("../simple/string-xform"),a=t("./underline-xform"),u=t("../../../utils/under-dash"),h=t("../base-xform");class d extends h{constructor(m){super(),this.options=m||d.OPTIONS,this.map={b:{prop:"bold",xform:new i({tag:"b",attr:"val"})},i:{prop:"italic",xform:new i({tag:"i",attr:"val"})},u:{prop:"underline",xform:new a},charset:{prop:"charset",xform:new c({tag:"charset",attr:"val"})},color:{prop:"color",xform:new o},condense:{prop:"condense",xform:new i({tag:"condense",attr:"val"})},extend:{prop:"extend",xform:new i({tag:"extend",attr:"val"})},family:{prop:"family",xform:new c({tag:"family",attr:"val"})},outline:{prop:"outline",xform:new i({tag:"outline",attr:"val"})},vertAlign:{prop:"vertAlign",xform:new l({tag:"vertAlign",attr:"val"})},scheme:{prop:"scheme",xform:new l({tag:"scheme",attr:"val"})},shadow:{prop:"shadow",xform:new i({tag:"shadow",attr:"val"})},strike:{prop:"strike",xform:new i({tag:"strike",attr:"val"})},sz:{prop:"size",xform:new c({tag:"sz",attr:"val"})}},this.map[this.options.fontNameTag]={prop:"name",xform:new l({tag:this.options.fontNameTag,attr:"val"})}}get tag(){return this.options.tagName}render(m,p){const{map:g}=this;m.openNode(this.options.tagName),u.each(this.map,(b,y)=>{g[y].xform.render(m,p[b.prop])}),m.closeNode()}parseOpen(m){return this.parser?(this.parser.parseOpen(m),!0):this.map[m.name]?(this.parser=this.map[m.name].xform,this.parser.parseOpen(m)):m.name===this.options.tagName?(this.model={},!0):!1}parseText(m){this.parser&&this.parser.parseText(m)}parseClose(m){if(this.parser&&!this.parser.parseClose(m)){const p=this.map[m];return this.parser.model&&(this.model[p.prop]=this.parser.model),this.parser=void 0,!0}return m!==this.options.tagName}}d.OPTIONS={tagName:"font",fontNameTag:"name"},n.exports=d},{"../../../utils/under-dash":26,"../base-xform":32,"../simple/boolean-xform":116,"../simple/integer-xform":118,"../simple/string-xform":119,"./color-xform":128,"./underline-xform":136}],132:[function(t,n,s){const o=t("../../../utils/under-dash"),i=t("../../defaultnumformats"),c=t("../base-xform"),l=(function(){const u={};return o.each(i,(h,d)=>{h.f&&(u[h.f]=parseInt(d,10))}),u})();class a extends c{constructor(h,d){super(),this.id=h,this.formatCode=d}get tag(){return"numFmt"}render(h,d){h.leafNode("numFmt",{numFmtId:d.id,formatCode:d.formatCode})}parseOpen(h){return h.name==="numFmt"?(this.model={id:parseInt(h.attributes.numFmtId,10),formatCode:h.attributes.formatCode.replace(/[\\](.)/g,"$1")},!0):!1}parseText(){}parseClose(){return!1}}a.getDefaultFmtId=function(u){return l[u]},a.getDefaultFmtCode=function(u){return i[u]&&i[u].f},n.exports=a},{"../../../utils/under-dash":26,"../../defaultnumformats":30,"../base-xform":32}],133:[function(t,n,s){const o=t("../base-xform"),i={boolean:(c,l)=>c===void 0?l:c};n.exports=class extends o{get tag(){return"protection"}render(c,l){c.addRollback(),c.openNode("protection");let a=!1;function u(h,d){d!==void 0&&(c.addAttribute(h,d),a=!0)}u("locked",i.boolean(l.locked,!0)?void 0:"0"),u("hidden",i.boolean(l.hidden,!1)?"1":void 0),c.closeNode(),a?c.commit():c.rollback()}parseOpen(c){const l={locked:c.attributes.locked!=="0",hidden:c.attributes.hidden==="1"},a=!l.locked||l.hidden;this.model=a?l:null}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],134:[function(t,n,s){const o=t("../base-xform"),i=t("./alignment-xform"),c=t("./protection-xform");n.exports=class extends o{constructor(l){super(),this.xfId=!(!l||!l.xfId),this.map={alignment:new i,protection:new c}}get tag(){return"xf"}render(l,a){l.openNode("xf",{numFmtId:a.numFmtId||0,fontId:a.fontId||0,fillId:a.fillId||0,borderId:a.borderId||0}),this.xfId&&l.addAttribute("xfId",a.xfId||0),a.numFmtId&&l.addAttribute("applyNumberFormat","1"),a.fontId&&l.addAttribute("applyFont","1"),a.fillId&&l.addAttribute("applyFill","1"),a.borderId&&l.addAttribute("applyBorder","1"),a.alignment&&l.addAttribute("applyAlignment","1"),a.protection&&l.addAttribute("applyProtection","1"),a.alignment&&this.map.alignment.render(l,a.alignment),a.protection&&this.map.protection.render(l,a.protection),l.closeNode()}parseOpen(l){if(this.parser)return this.parser.parseOpen(l),!0;switch(l.name){case"xf":return this.model={numFmtId:parseInt(l.attributes.numFmtId,10),fontId:parseInt(l.attributes.fontId,10),fillId:parseInt(l.attributes.fillId,10),borderId:parseInt(l.attributes.borderId,10)},this.xfId&&(this.model.xfId=parseInt(l.attributes.xfId,10)),!0;case"alignment":return this.parser=this.map.alignment,this.parser.parseOpen(l),!0;case"protection":return this.parser=this.map.protection,this.parser.parseOpen(l),!0;default:return!1}}parseText(l){this.parser&&this.parser.parseText(l)}parseClose(l){return this.parser?(this.parser.parseClose(l)||(this.map.protection===this.parser?this.model.protection=this.parser.model:this.model.alignment=this.parser.model,this.parser=void 0),!0):l!=="xf"}}},{"../base-xform":32,"./alignment-xform":126,"./protection-xform":133}],135:[function(t,n,s){const o=t("../../../doc/enums"),i=t("../../../utils/xml-stream"),c=t("../base-xform"),l=t("../static-xform"),a=t("../list-xform"),u=t("./font-xform"),h=t("./fill-xform"),d=t("./border-xform"),f=t("./numfmt-xform"),m=t("./style-xform"),p=t("./dxf-xform");class g extends c{constructor(y){super(),this.map={numFmts:new a({tag:"numFmts",count:!0,childXform:new f}),fonts:new a({tag:"fonts",count:!0,childXform:new u,$:{"x14ac:knownFonts":1}}),fills:new a({tag:"fills",count:!0,childXform:new h}),borders:new a({tag:"borders",count:!0,childXform:new d}),cellStyleXfs:new a({tag:"cellStyleXfs",count:!0,childXform:new m}),cellXfs:new a({tag:"cellXfs",count:!0,childXform:new m({xfId:!0})}),dxfs:new a({tag:"dxfs",always:!0,count:!0,childXform:new p}),numFmt:new f,font:new u,fill:new h,border:new d,style:new m({xfId:!0}),cellStyles:g.STATIC_XFORMS.cellStyles,tableStyles:g.STATIC_XFORMS.tableStyles,extLst:g.STATIC_XFORMS.extLst},y&&this.init()}initIndex(){this.index={style:{},numFmt:{},numFmtNextId:164,font:{},border:{},fill:{}}}init(){this.model={styles:[],numFmts:[],fonts:[],borders:[],fills:[],dxfs:[]},this.initIndex(),this._addBorder({}),this._addStyle({numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}),this._addFill({type:"pattern",pattern:"none"}),this._addFill({type:"pattern",pattern:"gray125"}),this.weakMap=new WeakMap}render(y,w){w=w||this.model,y.openXml(i.StdDocAttributes),y.openNode("styleSheet",g.STYLESHEET_ATTRIBUTES),this.index?(w.numFmts&&w.numFmts.length&&(y.openNode("numFmts",{count:w.numFmts.length}),w.numFmts.forEach(C=>{y.writeXml(C)}),y.closeNode()),w.fonts.length||this._addFont({size:11,color:{theme:1},name:"Calibri",family:2,scheme:"minor"}),y.openNode("fonts",{count:w.fonts.length,"x14ac:knownFonts":1}),w.fonts.forEach(C=>{y.writeXml(C)}),y.closeNode(),y.openNode("fills",{count:w.fills.length}),w.fills.forEach(C=>{y.writeXml(C)}),y.closeNode(),y.openNode("borders",{count:w.borders.length}),w.borders.forEach(C=>{y.writeXml(C)}),y.closeNode(),this.map.cellStyleXfs.render(y,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),y.openNode("cellXfs",{count:w.styles.length}),w.styles.forEach(C=>{y.writeXml(C)}),y.closeNode()):(this.map.numFmts.render(y,w.numFmts),this.map.fonts.render(y,w.fonts),this.map.fills.render(y,w.fills),this.map.borders.render(y,w.borders),this.map.cellStyleXfs.render(y,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),this.map.cellXfs.render(y,w.styles)),g.STATIC_XFORMS.cellStyles.render(y),this.map.dxfs.render(y,w.dxfs),g.STATIC_XFORMS.tableStyles.render(y),g.STATIC_XFORMS.extLst.render(y),y.closeNode()}parseOpen(y){return this.parser?(this.parser.parseOpen(y),!0):y.name==="styleSheet"?(this.initIndex(),!0):(this.parser=this.map[y.name],this.parser&&this.parser.parseOpen(y),!0)}parseText(y){this.parser&&this.parser.parseText(y)}parseClose(y){if(this.parser)return this.parser.parseClose(y)||(this.parser=void 0),!0;switch(y){case"styleSheet":{this.model={};const w=(C,N)=>{N.model&&N.model.length&&(this.model[C]=N.model)};if(w("numFmts",this.map.numFmts),w("fonts",this.map.fonts),w("fills",this.map.fills),w("borders",this.map.borders),w("styles",this.map.cellXfs),w("dxfs",this.map.dxfs),this.index={model:[],numFmt:[]},this.model.numFmts){const C=this.index.numFmt;this.model.numFmts.forEach(N=>{C[N.id]=N.formatCode})}return!1}default:return!0}}addStyleModel(y,w){if(!y)return 0;if(this.model.fonts.length||this._addFont({size:11,color:{theme:1},name:"Calibri",family:2,scheme:"minor"}),this.weakMap&&this.weakMap.has(y))return this.weakMap.get(y);const C={};if(w=w||o.ValueType.Number,y.numFmt)C.numFmtId=this._addNumFmtStr(y.numFmt);else switch(w){case o.ValueType.Number:C.numFmtId=this._addNumFmtStr("General");break;case o.ValueType.Date:C.numFmtId=this._addNumFmtStr("mm-dd-yy")}y.font&&(C.fontId=this._addFont(y.font)),y.border&&(C.borderId=this._addBorder(y.border)),y.fill&&(C.fillId=this._addFill(y.fill)),y.alignment&&(C.alignment=y.alignment),y.protection&&(C.protection=y.protection);const N=this._addStyle(C);return this.weakMap&&this.weakMap.set(y,N),N}getStyleModel(y){const w=this.model.styles[y];if(!w)return null;let C=this.index.model[y];if(C)return C;if(C=this.index.model[y]={},w.numFmtId){const I=this.index.numFmt[w.numFmtId]||f.getDefaultFmtCode(w.numFmtId);I&&(C.numFmt=I)}function N(I,$,D){if(D||D===0){const F=$[D];F&&(C[I]=F)}}return N("font",this.model.fonts,w.fontId),N("border",this.model.borders,w.borderId),N("fill",this.model.fills,w.fillId),w.alignment&&(C.alignment=w.alignment),w.protection&&(C.protection=w.protection),C}addDxfStyle(y){return y.numFmt&&(y.numFmtId=this._addNumFmtStr(y.numFmt)),this.model.dxfs.push(y),this.model.dxfs.length-1}getDxfStyle(y){return this.model.dxfs[y]}_addStyle(y){const w=this.map.style.toXml(y);let C=this.index.style[w];return C===void 0&&(C=this.index.style[w]=this.model.styles.length,this.model.styles.push(w)),C}_addNumFmtStr(y){let w=f.getDefaultFmtId(y);if(w!==void 0||(w=this.index.numFmt[y],w!==void 0))return w;w=this.index.numFmt[y]=164+this.model.numFmts.length;const C=this.map.numFmt.toXml({id:w,formatCode:y});return this.model.numFmts.push(C),w}_addFont(y){const w=this.map.font.toXml(y);let C=this.index.font[w];return C===void 0&&(C=this.index.font[w]=this.model.fonts.length,this.model.fonts.push(w)),C}_addBorder(y){const w=this.map.border.toXml(y);let C=this.index.border[w];return C===void 0&&(C=this.index.border[w]=this.model.borders.length,this.model.borders.push(w)),C}_addFill(y){const w=this.map.fill.toXml(y);let C=this.index.fill[w];return C===void 0&&(C=this.index.fill[w]=this.model.fills.length,this.model.fills.push(w)),C}}g.STYLESHEET_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x14ac x16r2","xmlns:x14ac":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac","xmlns:x16r2":"http://schemas.microsoft.com/office/spreadsheetml/2015/02/main"},g.STATIC_XFORMS={cellStyles:new l({tag:"cellStyles",$:{count:1},c:[{tag:"cellStyle",$:{name:"Normal",xfId:0,builtinId:0}}]}),dxfs:new l({tag:"dxfs",$:{count:0}}),tableStyles:new l({tag:"tableStyles",$:{count:0,defaultTableStyle:"TableStyleMedium2",defaultPivotStyle:"PivotStyleLight16"}}),extLst:new l({tag:"extLst",c:[{tag:"ext",$:{uri:"{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"},c:[{tag:"x14:slicerStyles",$:{defaultSlicerStyle:"SlicerStyleLight1"}}]},{tag:"ext",$:{uri:"{9260A510-F301-46a8-8635-F512D64BE5F5}","xmlns:x15":"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"},c:[{tag:"x15:timelineStyles",$:{defaultTimelineStyle:"TimeSlicerStyleLight1"}}]}]})},g.Mock=class extends g{constructor(){super(),this.model={styles:[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}],numFmts:[],fonts:[{size:11,color:{theme:1},name:"Calibri",family:2,scheme:"minor"}],borders:[{}],fills:[{type:"pattern",pattern:"none"},{type:"pattern",pattern:"gray125"}]}}parseStream(b){return b.autodrain(),Promise.resolve()}addStyleModel(b,y){return y===o.ValueType.Date?this.dateStyleId:0}get dateStyleId(){if(!this._dateStyleId){const b={numFmtId:f.getDefaultFmtId("mm-dd-yy")};this._dateStyleId=this.model.styles.length,this.model.styles.push(b)}return this._dateStyleId}getStyleModel(){return{}}},n.exports=g},{"../../../doc/enums":7,"../../../utils/xml-stream":28,"../base-xform":32,"../list-xform":71,"../static-xform":120,"./border-xform":127,"./dxf-xform":129,"./fill-xform":130,"./font-xform":131,"./numfmt-xform":132,"./style-xform":134}],136:[function(t,n,s){const o=t("../base-xform");class i extends o{constructor(l){super(),this.model=l}get tag(){return"u"}render(l,a){if((a=a||this.model)===!0)l.leafNode("u");else{const u=i.Attributes[a];u&&l.leafNode("u",u)}}parseOpen(l){l.name==="u"&&(this.model=l.attributes.val||!0)}parseText(){}parseClose(){return!1}}i.Attributes={single:{},double:{val:"double"},singleAccounting:{val:"singleAccounting"},doubleAccounting:{val:"doubleAccounting"}},n.exports=i},{"../base-xform":32}],137:[function(t,n,s){const o=t("../base-xform"),i=t("./filter-column-xform");n.exports=class extends o{constructor(){super(),this.map={filterColumn:new i}}get tag(){return"autoFilter"}prepare(c){c.columns.forEach((l,a)=>{this.map.filterColumn.prepare(l,{index:a})})}render(c,l){return c.openNode(this.tag,{ref:l.autoFilterRef}),l.columns.forEach(a=>{this.map.filterColumn.render(c,a)}),c.closeNode(),!0}parseOpen(c){if(this.parser)return this.parser.parseOpen(c),!0;switch(c.name){case this.tag:return this.model={autoFilterRef:c.attributes.ref,columns:[]},!0;default:if(this.parser=this.map[c.name],this.parser)return this.parseOpen(c),!0;throw new Error("Unexpected xml node in parseOpen: "+JSON.stringify(c))}}parseText(c){this.parser&&this.parser.parseText(c)}parseClose(c){if(this.parser)return this.parser.parseClose(c)||(this.model.columns.push(this.parser.model),this.parser=void 0),!0;if(c===this.tag)return!1;throw new Error("Unexpected xml node in parseClose: "+c)}}},{"../base-xform":32,"./filter-column-xform":139}],138:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"customFilter"}render(i,c){i.leafNode(this.tag,{val:c.val,operator:c.operator})}parseOpen(i){return i.name===this.tag&&(this.model={val:i.attributes.val,operator:i.attributes.operator},!0)}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],139:[function(t,n,s){const o=t("../base-xform"),i=t("../list-xform"),c=t("./custom-filter-xform"),l=t("./filter-xform");n.exports=class extends o{constructor(){super(),this.map={customFilters:new i({tag:"customFilters",count:!1,empty:!0,childXform:new c}),filters:new i({tag:"filters",count:!1,empty:!0,childXform:new l})}}get tag(){return"filterColumn"}prepare(a,u){a.colId=u.index.toString()}render(a,u){return u.customFilters?(a.openNode(this.tag,{colId:u.colId,hiddenButton:u.filterButton?"0":"1"}),this.map.customFilters.render(a,u.customFilters),a.closeNode(),!0):(a.leafNode(this.tag,{colId:u.colId,hiddenButton:u.filterButton?"0":"1"}),!0)}parseOpen(a){if(this.parser)return this.parser.parseOpen(a),!0;const{attributes:u}=a;switch(a.name){case this.tag:return this.model={filterButton:u.hiddenButton==="0"},!0;default:if(this.parser=this.map[a.name],this.parser)return this.parseOpen(a),!0;throw new Error("Unexpected xml node in parseOpen: "+JSON.stringify(a))}}parseText(){}parseClose(a){return this.parser?(this.parser.parseClose(a)||(this.parser=void 0),!0):a===this.tag?(this.model.customFilters=this.map.customFilters.model,!1):!0}}},{"../base-xform":32,"../list-xform":71,"./custom-filter-xform":138,"./filter-xform":140}],140:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"filter"}render(i,c){i.leafNode(this.tag,{val:c.val})}parseOpen(i){return i.name===this.tag&&(this.model={val:i.attributes.val},!0)}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],141:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"tableColumn"}prepare(i,c){i.id=c.index+1}render(i,c){return i.leafNode(this.tag,{id:c.id.toString(),name:c.name,totalsRowLabel:c.totalsRowLabel,totalsRowFunction:c.totalsRowFunction,dxfId:c.dxfId}),!0}parseOpen(i){if(i.name===this.tag){const{attributes:c}=i;return this.model={name:c.name,totalsRowLabel:c.totalsRowLabel,totalsRowFunction:c.totalsRowFunction,dxfId:c.dxfId},!0}return!1}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],142:[function(t,n,s){const o=t("../base-xform");n.exports=class extends o{get tag(){return"tableStyleInfo"}render(i,c){return i.leafNode(this.tag,{name:c.theme?c.theme:void 0,showFirstColumn:c.showFirstColumn?"1":"0",showLastColumn:c.showLastColumn?"1":"0",showRowStripes:c.showRowStripes?"1":"0",showColumnStripes:c.showColumnStripes?"1":"0"}),!0}parseOpen(i){if(i.name===this.tag){const{attributes:c}=i;return this.model={theme:c.name?c.name:null,showFirstColumn:c.showFirstColumn==="1",showLastColumn:c.showLastColumn==="1",showRowStripes:c.showRowStripes==="1",showColumnStripes:c.showColumnStripes==="1"},!0}return!1}parseText(){}parseClose(){return!1}}},{"../base-xform":32}],143:[function(t,n,s){const o=t("../../../utils/xml-stream"),i=t("../base-xform"),c=t("../list-xform"),l=t("./auto-filter-xform"),a=t("./table-column-xform"),u=t("./table-style-info-xform");class h extends i{constructor(){super(),this.map={autoFilter:new l,tableColumns:new c({tag:"tableColumns",count:!0,empty:!0,childXform:new a}),tableStyleInfo:new u}}prepare(f,m){this.map.autoFilter.prepare(f),this.map.tableColumns.prepare(f.columns,m)}get tag(){return"table"}render(f,m){f.openXml(o.StdDocAttributes),f.openNode(this.tag,{...h.TABLE_ATTRIBUTES,id:m.id,name:m.name,displayName:m.displayName||m.name,ref:m.tableRef,totalsRowCount:m.totalsRow?"1":void 0,totalsRowShown:m.totalsRow?void 0:"1",headerRowCount:m.headerRow?"1":"0"}),this.map.autoFilter.render(f,m),this.map.tableColumns.render(f,m.columns),this.map.tableStyleInfo.render(f,m.style),f.closeNode()}parseOpen(f){if(this.parser)return this.parser.parseOpen(f),!0;const{name:m,attributes:p}=f;return m===this.tag?(this.reset(),this.model={name:p.name,displayName:p.displayName||p.name,tableRef:p.ref,totalsRow:p.totalsRowCount==="1",headerRow:p.headerRowCount==="1"}):(this.parser=this.map[f.name],this.parser&&this.parser.parseOpen(f)),!0}parseText(f){this.parser&&this.parser.parseText(f)}parseClose(f){return this.parser?(this.parser.parseClose(f)||(this.parser=void 0),!0):f===this.tag?(this.model.columns=this.map.tableColumns.model,this.map.autoFilter.model&&(this.model.autoFilterRef=this.map.autoFilter.model.autoFilterRef,this.map.autoFilter.model.columns.forEach((m,p)=>{this.model.columns[p].filterButton=m.filterButton})),this.model.style=this.map.tableStyleInfo.model,!1):!0}reconcile(f,m){f.columns.forEach(p=>{p.dxfId!==void 0&&(p.style=m.styles.getDxfStyle(p.dxfId))})}}h.TABLE_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"xr xr3","xmlns:xr":"http://schemas.microsoft.com/office/spreadsheetml/2014/revision","xmlns:xr3":"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3"},n.exports=h},{"../../../utils/xml-stream":28,"../base-xform":32,"../list-xform":71,"./auto-filter-xform":137,"./table-column-xform":141,"./table-style-info-xform":142}],144:[function(t,n,s){(function(o,i){(function(){const c=t("fs"),l=t("jszip"),{PassThrough:a}=t("readable-stream"),u=t("../utils/zip-stream"),h=t("../utils/stream-buf"),d=t("../utils/utils"),f=t("../utils/xml-stream"),{bufferToString:m}=t("../utils/browser-buffer-decode"),p=t("./xform/style/styles-xform"),g=t("./xform/core/core-xform"),b=t("./xform/strings/shared-strings-xform"),y=t("./xform/core/relationships-xform"),w=t("./xform/core/content-types-xform"),C=t("./xform/core/app-xform"),N=t("./xform/book/workbook-xform"),I=t("./xform/sheet/worksheet-xform"),$=t("./xform/drawing/drawing-xform"),D=t("./xform/table/table-xform"),F=t("./xform/comment/comments-xform"),V=t("./xform/comment/vml-notes-xform"),G=t("./xml/theme1");class U{constructor(M){this.workbook=M}async readFile(M,B){if(!await d.fs.exists(M))throw new Error("File not found: "+M);const k=c.createReadStream(M);try{const _=await this.read(k,B);return k.close(),_}catch(_){throw k.close(),_}}parseRels(M){return new y().parseStream(M)}parseWorkbook(M){return new N().parseStream(M)}parseSharedStrings(M){return new b().parseStream(M)}reconcile(M,B){const k=new N,_=new I(B),S=new $,T=new D;k.reconcile(M);const z={media:M.media,mediaIndex:M.mediaIndex};Object.keys(M.drawings).forEach(X=>{const K=M.drawings[X],J=M.drawingRels[X];J&&(z.rels=J.reduce((H,Z)=>(H[Z.Id]=Z,H),{}),(K.anchors||[]).forEach(H=>{const Z=H.picture&&H.picture.hyperlinks;Z&&z.rels[Z.rId]&&(Z.hyperlink=z.rels[Z.rId].Target,delete Z.rId)}),S.reconcile(K,z))});const P={styles:M.styles};Object.values(M.tables).forEach(X=>{T.reconcile(X,P)});const O={styles:M.styles,sharedStrings:M.sharedStrings,media:M.media,mediaIndex:M.mediaIndex,date1904:M.properties&&M.properties.date1904,drawings:M.drawings,comments:M.comments,tables:M.tables,vmlDrawings:M.vmlDrawings};M.worksheets.forEach(X=>{X.relationships=M.worksheetRels[X.sheetNo],_.reconcile(X,O)}),delete M.worksheetHash,delete M.worksheetRels,delete M.globalRels,delete M.sharedStrings,delete M.workbookRels,delete M.sheetDefs,delete M.styles,delete M.mediaIndex,delete M.drawings,delete M.drawingRels,delete M.vmlDrawings}async _processWorksheetEntry(M,B,k,_,S){const T=new I(_),z=await T.parseStream(M);z.sheetNo=k,B.worksheetHash[S]=z,B.worksheets.push(z)}async _processCommentEntry(M,B,k){const _=new F,S=await _.parseStream(M);B.comments[`../${k}.xml`]=S}async _processTableEntry(M,B,k){const _=new D,S=await _.parseStream(M);B.tables[`../tables/${k}.xml`]=S}async _processWorksheetRelsEntry(M,B,k){const _=new y,S=await _.parseStream(M);B.worksheetRels[k]=S}async _processMediaEntry(M,B,k){const _=k.lastIndexOf(".");if(_>=1){const S=k.substr(_+1),T=k.substr(0,_);await new Promise((z,P)=>{const O=new h;O.on("finish",()=>{B.mediaIndex[k]=B.media.length,B.mediaIndex[T]=B.media.length;const X={type:"image",name:T,extension:S,buffer:O.toBuffer()};B.media.push(X),z()}),M.on("error",X=>{P(X)}),M.pipe(O)})}}async _processDrawingEntry(M,B,k){const _=new $,S=await _.parseStream(M);B.drawings[k]=S}async _processDrawingRelsEntry(M,B,k){const _=new y,S=await _.parseStream(M);B.drawingRels[k]=S}async _processVmlDrawingEntry(M,B,k){const _=new V,S=await _.parseStream(M);B.vmlDrawings[`../drawings/${k}.vml`]=S}async _processThemeEntry(M,B,k){await new Promise((_,S)=>{const T=new h;M.on("error",S),T.on("error",S),T.on("finish",()=>{B.themes[k]=T.read().toString(),_()}),M.pipe(T)})}createInputStream(){throw new Error("`XLSX#createInputStream` is deprecated. You should use `XLSX#read` instead. This method will be removed in version 5.0. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md")}async read(M,B){!M[Symbol.asyncIterator]&&M.pipe&&(M=M.pipe(new a));const k=[];for await(const _ of M)k.push(_);return this.load(i.concat(k),B)}async load(M,B){let k;k=B&&B.base64?i.from(M.toString(),"base64"):M;const _={worksheets:[],worksheetHash:{},worksheetRels:[],themes:{},media:[],mediaIndex:{},drawings:{},drawingRels:{},comments:{},tables:{},vmlDrawings:{}},S=await l.loadAsync(k);for(const T of Object.values(S.files))if(!T.dir){let z,P=T.name;if(P[0]==="/"&&(P=P.substr(1)),P.match(/xl\/media\//)||P.match(/xl\/theme\/([a-zA-Z0-9]+)[.]xml/))z=new a,z.write(await T.async("nodebuffer"));else{let O;z=new a({writableObjectMode:!0,readableObjectMode:!0}),O=o.browser?m(await T.async("nodebuffer")):await T.async("string");const X=16384;for(let K=0;K<O.length;K+=X)z.write(O.substring(K,K+X))}switch(z.end(),P){case"_rels/.rels":_.globalRels=await this.parseRels(z);break;case"xl/workbook.xml":{const O=await this.parseWorkbook(z);_.sheets=O.sheets,_.definedNames=O.definedNames,_.views=O.views,_.properties=O.properties,_.calcProperties=O.calcProperties;break}case"xl/_rels/workbook.xml.rels":_.workbookRels=await this.parseRels(z);break;case"xl/sharedStrings.xml":_.sharedStrings=new b,await _.sharedStrings.parseStream(z);break;case"xl/styles.xml":_.styles=new p,await _.styles.parseStream(z);break;case"docProps/app.xml":{const O=new C,X=await O.parseStream(z);_.company=X.company,_.manager=X.manager;break}case"docProps/core.xml":{const O=new g,X=await O.parseStream(z);Object.assign(_,X);break}default:{let O=P.match(/xl\/worksheets\/sheet(\d+)[.]xml/);if(O){await this._processWorksheetEntry(z,_,O[1],B,P);break}if(O=P.match(/xl\/worksheets\/_rels\/sheet(\d+)[.]xml.rels/),O){await this._processWorksheetRelsEntry(z,_,O[1]);break}if(O=P.match(/xl\/theme\/([a-zA-Z0-9]+)[.]xml/),O){await this._processThemeEntry(z,_,O[1]);break}if(O=P.match(/xl\/media\/([a-zA-Z0-9]+[.][a-zA-Z0-9]{3,4})$/),O){await this._processMediaEntry(z,_,O[1]);break}if(O=P.match(/xl\/drawings\/([a-zA-Z0-9]+)[.]xml/),O){await this._processDrawingEntry(z,_,O[1]);break}if(O=P.match(/xl\/(comments\d+)[.]xml/),O){await this._processCommentEntry(z,_,O[1]);break}if(O=P.match(/xl\/tables\/(table\d+)[.]xml/),O){await this._processTableEntry(z,_,O[1]);break}if(O=P.match(/xl\/drawings\/_rels\/([a-zA-Z0-9]+)[.]xml[.]rels/),O){await this._processDrawingRelsEntry(z,_,O[1]);break}if(O=P.match(/xl\/drawings\/(vmlDrawing\d+)[.]vml/),O){await this._processVmlDrawingEntry(z,_,O[1]);break}}}}return this.reconcile(_,B),this.workbook.model=_,this.workbook}async addMedia(M,B){await Promise.all(B.media.map(async k=>{if(k.type==="image"){const _=`xl/media/${k.name}.${k.extension}`;if(k.filename){const S=await(function(T,z){return new Promise((P,O)=>{c.readFile(T,z,(X,K)=>{X?O(X):P(K)})})})(k.filename);return M.append(S,{name:_})}if(k.buffer)return M.append(k.buffer,{name:_});if(k.base64){const S=k.base64,T=S.substring(S.indexOf(",")+1);return M.append(T,{name:_,base64:!0})}}throw new Error("Unsupported media")}))}addDrawings(M,B){const k=new $,_=new y;B.worksheets.forEach(S=>{const{drawing:T}=S;if(T){k.prepare(T,{});let z=k.toXml(T);M.append(z,{name:`xl/drawings/${T.name}.xml`}),z=_.toXml(T.rels),M.append(z,{name:`xl/drawings/_rels/${T.name}.xml.rels`})}})}addTables(M,B){const k=new D;B.worksheets.forEach(_=>{const{tables:S}=_;S.forEach(T=>{k.prepare(T,{});const z=k.toXml(T);M.append(z,{name:"xl/tables/"+T.target})})})}async addContentTypes(M,B){const k=new w().toXml(B);M.append(k,{name:"[Content_Types].xml"})}async addApp(M,B){const k=new C().toXml(B);M.append(k,{name:"docProps/app.xml"})}async addCore(M,B){const k=new g;M.append(k.toXml(B),{name:"docProps/core.xml"})}async addThemes(M,B){const k=B.themes||{theme1:G};Object.keys(k).forEach(_=>{const S=k[_],T=`xl/theme/${_}.xml`;M.append(S,{name:T})})}async addOfficeRels(M){const B=new y().toXml([{Id:"rId1",Type:U.RelType.OfficeDocument,Target:"xl/workbook.xml"},{Id:"rId2",Type:U.RelType.CoreProperties,Target:"docProps/core.xml"},{Id:"rId3",Type:U.RelType.ExtenderProperties,Target:"docProps/app.xml"}]);M.append(B,{name:"_rels/.rels"})}async addWorkbookRels(M,B){let k=1;const _=[{Id:"rId"+k++,Type:U.RelType.Styles,Target:"styles.xml"},{Id:"rId"+k++,Type:U.RelType.Theme,Target:"theme/theme1.xml"}];B.sharedStrings.count&&_.push({Id:"rId"+k++,Type:U.RelType.SharedStrings,Target:"sharedStrings.xml"}),B.worksheets.forEach(T=>{T.rId="rId"+k++,_.push({Id:T.rId,Type:U.RelType.Worksheet,Target:`worksheets/sheet${T.id}.xml`})});const S=new y().toXml(_);M.append(S,{name:"xl/_rels/workbook.xml.rels"})}async addSharedStrings(M,B){B.sharedStrings&&B.sharedStrings.count&&M.append(B.sharedStrings.xml,{name:"xl/sharedStrings.xml"})}async addStyles(M,B){const{xml:k}=B.styles;k&&M.append(k,{name:"xl/styles.xml"})}async addWorkbook(M,B){const k=new N;M.append(k.toXml(B),{name:"xl/workbook.xml"})}async addWorksheets(M,B){const k=new I,_=new y,S=new F,T=new V;B.worksheets.forEach(z=>{let P=new f;k.render(P,z),M.append(P.xml,{name:`xl/worksheets/sheet${z.id}.xml`}),z.rels&&z.rels.length&&(P=new f,_.render(P,z.rels),M.append(P.xml,{name:`xl/worksheets/_rels/sheet${z.id}.xml.rels`})),z.comments.length>0&&(P=new f,S.render(P,z),M.append(P.xml,{name:`xl/comments${z.id}.xml`}),P=new f,T.render(P,z),M.append(P.xml,{name:`xl/drawings/vmlDrawing${z.id}.vml`}))})}_finalize(M){return new Promise((B,k)=>{M.on("finish",()=>{B(this)}),M.on("error",k),M.finalize()})}prepareModel(M,B){M.creator=M.creator||"ExcelJS",M.lastModifiedBy=M.lastModifiedBy||"ExcelJS",M.created=M.created||new Date,M.modified=M.modified||new Date,M.useSharedStrings=B.useSharedStrings===void 0||B.useSharedStrings,M.useStyles=B.useStyles===void 0||B.useStyles,M.sharedStrings=new b,M.styles=M.useStyles?new p(!0):new p.Mock;const k=new N,_=new I;k.prepare(M);const S={sharedStrings:M.sharedStrings,styles:M.styles,date1904:M.properties.date1904,drawingsCount:0,media:M.media};S.drawings=M.drawings=[],S.commentRefs=M.commentRefs=[];let T=0;M.tables=[],M.worksheets.forEach(z=>{z.tables.forEach(P=>{T++,P.target=`table${T}.xml`,P.id=T,M.tables.push(P)}),_.prepare(z,S)})}async write(M,B){B=B||{};const{model:k}=this.workbook,_=new u.ZipWriter(B.zip);return _.pipe(M),this.prepareModel(k,B),await this.addContentTypes(_,k),await this.addOfficeRels(_,k),await this.addWorkbookRels(_,k),await this.addWorksheets(_,k),await this.addSharedStrings(_,k),await this.addDrawings(_,k),await this.addTables(_,k),await Promise.all([this.addThemes(_,k),this.addStyles(_,k)]),await this.addMedia(_,k),await Promise.all([this.addApp(_,k),this.addCore(_,k)]),await this.addWorkbook(_,k),this._finalize(_)}writeFile(M,B){const k=c.createWriteStream(M);return new Promise((_,S)=>{k.on("finish",()=>{_()}),k.on("error",T=>{S(T)}),this.write(k,B).then(()=>{k.end()}).catch(T=>{S(T)})})}async writeBuffer(M){const B=new h;return await this.write(B,M),B.read()}}U.RelType=t("./rel-type"),n.exports=U}).call(this)}).call(this,t("_process"),t("buffer").Buffer)},{"../utils/browser-buffer-decode":16,"../utils/stream-buf":24,"../utils/utils":27,"../utils/xml-stream":28,"../utils/zip-stream":29,"./rel-type":31,"./xform/book/workbook-xform":38,"./xform/comment/comments-xform":40,"./xform/comment/vml-notes-xform":45,"./xform/core/app-xform":51,"./xform/core/content-types-xform":52,"./xform/core/core-xform":53,"./xform/core/relationships-xform":55,"./xform/drawing/drawing-xform":62,"./xform/sheet/worksheet-xform":115,"./xform/strings/shared-strings-xform":124,"./xform/style/styles-xform":135,"./xform/table/table-xform":143,"./xml/theme1":145,_process:467,buffer:220,fs:216,jszip:441,"readable-stream":491}],145:[function(t,n,s){n.exports=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
82
82
|
<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"> <a:themeElements> <a:clrScheme name="Office"> <a:dk1> <a:sysClr val="windowText" lastClr="000000"/> </a:dk1> <a:lt1> <a:sysClr val="window" lastClr="FFFFFF"/> </a:lt1> <a:dk2> <a:srgbClr val="1F497D"/> </a:dk2> <a:lt2> <a:srgbClr val="EEECE1"/> </a:lt2> <a:accent1> <a:srgbClr val="4F81BD"/> </a:accent1> <a:accent2> <a:srgbClr val="C0504D"/> </a:accent2> <a:accent3> <a:srgbClr val="9BBB59"/> </a:accent3> <a:accent4> <a:srgbClr val="8064A2"/> </a:accent4> <a:accent5> <a:srgbClr val="4BACC6"/> </a:accent5> <a:accent6> <a:srgbClr val="F79646"/> </a:accent6> <a:hlink> <a:srgbClr val="0000FF"/> </a:hlink> <a:folHlink> <a:srgbClr val="800080"/> </a:folHlink> </a:clrScheme> <a:fontScheme name="Office"> <a:majorFont> <a:latin typeface="Cambria"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Times New Roman"/> <a:font script="Hebr" typeface="Times New Roman"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="MoolBoran"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Times New Roman"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:majorFont> <a:minorFont> <a:latin typeface="Calibri"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Arial"/> <a:font script="Hebr" typeface="Arial"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="DaunPenh"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Arial"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:minorFont> </a:fontScheme> <a:fmtScheme name="Office"> <a:fillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="35000"> <a:schemeClr val="phClr"> <a:tint val="37000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="15000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="1"/> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="100000"/> <a:shade val="100000"/> <a:satMod val="130000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:shade val="100000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="0"/> </a:gradFill> </a:fillStyleLst> <a:lnStyleLst> <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"> <a:shade val="95000"/> <a:satMod val="105000"/> </a:schemeClr> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> </a:lnStyleLst> <a:effectStyleLst> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="38000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> <a:scene3d> <a:camera prst="orthographicFront"> <a:rot lat="0" lon="0" rev="0"/> </a:camera> <a:lightRig rig="threePt" dir="t"> <a:rot lat="0" lon="0" rev="1200000"/> </a:lightRig> </a:scene3d> <a:sp3d> <a:bevelT w="63500" h="25400"/> </a:sp3d> </a:effectStyle> </a:effectStyleLst> <a:bgFillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="40000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="40000"> <a:schemeClr val="phClr"> <a:tint val="45000"/> <a:shade val="99000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="20000"/> <a:satMod val="255000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="-80000" r="50000" b="180000"/> </a:path> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="80000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="30000"/> <a:satMod val="200000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="50000" r="50000" b="50000"/> </a:path> </a:gradFill> </a:bgFillStyleLst> </a:fmtScheme> </a:themeElements> <a:objectDefaults> <a:spDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="1"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="3"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="2"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="lt1"/> </a:fontRef> </a:style> </a:spDef> <a:lnDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="2"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="0"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="1"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="tx1"/> </a:fontRef> </a:style> </a:lnDef> </a:objectDefaults> <a:extraClrSchemeLst/> </a:theme>`},{}],146:[function(t,n,s){(function(o){(function(){Object.defineProperty(s,"__esModule",{value:!0}),s.CsvFormatterStream=void 0;const i=t("stream"),c=t("./formatter");class l extends i.Transform{constructor(u){super({writableObjectMode:u.objectMode}),this.hasWrittenBOM=!1,this.formatterOptions=u,this.rowFormatter=new c.RowFormatter(u),this.hasWrittenBOM=!u.writeBOM}transform(u){return this.rowFormatter.rowTransform=u,this}_transform(u,h,d){let f=!1;try{this.hasWrittenBOM||(this.push(this.formatterOptions.BOM),this.hasWrittenBOM=!0),this.rowFormatter.format(u,(m,p)=>m?(f=!0,d(m)):(p&&p.forEach(g=>{this.push(o.from(g,"utf8"))}),f=!0,d()))}catch(m){if(f)throw m;d(m)}}_flush(u){this.rowFormatter.finish((h,d)=>h?u(h):(d&&d.forEach(f=>{this.push(o.from(f,"utf8"))}),u()))}}s.CsvFormatterStream=l}).call(this)}).call(this,t("buffer").Buffer)},{"./formatter":150,buffer:220,stream:505}],147:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.FormatterOptions=void 0,s.FormatterOptions=class{constructor(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};var i;this.objectMode=!0,this.delimiter=",",this.rowDelimiter=`
|
|
83
83
|
`,this.quote='"',this.escape=this.quote,this.quoteColumns=!1,this.quoteHeaders=this.quoteColumns,this.headers=null,this.includeEndRowDelimiter=!1,this.writeBOM=!1,this.BOM="\uFEFF",this.alwaysWriteHeaders=!1,Object.assign(this,o||{}),o?.quoteHeaders===void 0&&(this.quoteHeaders=this.quoteColumns),o?.quote===!0?this.quote='"':o?.quote===!1&&(this.quote=""),typeof o?.escape!="string"&&(this.escape=this.quote),this.shouldWriteHeaders=!!this.headers&&((i=o.writeHeaders)===null||i===void 0||i),this.headers=Array.isArray(this.headers)?this.headers:null,this.escapedQuote=`${this.escape}${this.quote}`}}},{}],148:[function(t,n,s){var o=function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(s,"__esModule",{value:!0}),s.FieldFormatter=void 0;const i=o(t("lodash.isboolean")),c=o(t("lodash.isnil")),l=o(t("lodash.escaperegexp"));s.FieldFormatter=class{constructor(a){this._headers=null,this.formatterOptions=a,a.headers!==null&&(this.headers=a.headers),this.REPLACE_REGEXP=new RegExp(a.quote,"g");const u=`[${a.delimiter}${l.default(a.rowDelimiter)}|\r|
|
|
@@ -105,5 +105,5 @@ use chrome, FireFox or Internet Explorer 11`)}var l=t("safe-buffer"),a=t("random
|
|
|
105
105
|
`)):X=k.stylize("[Circular]","special")),N(O)){if(P&&z.match(/^\d+$/))return X;(O=JSON.stringify(""+z)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(O=O.substr(1,O.length-2),O=k.stylize(O,"name")):(O=O.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),O=k.stylize(O,"string"))}return O+": "+X}function g(k){return Array.isArray(k)}function b(k){return typeof k=="boolean"}function y(k){return k===null}function w(k){return typeof k=="number"}function C(k){return typeof k=="string"}function N(k){return k===void 0}function I(k){return $(k)&&G(k)==="[object RegExp]"}function $(k){return typeof k=="object"&&k!==null}function D(k){return $(k)&&G(k)==="[object Date]"}function F(k){return $(k)&&(G(k)==="[object Error]"||k instanceof Error)}function V(k){return typeof k=="function"}function G(k){return Object.prototype.toString.call(k)}function U(k){return k<10?"0"+k.toString(10):k.toString(10)}s.debuglog=function(k){if(N(l)&&(l=o.env.NODE_DEBUG||""),k=k.toUpperCase(),!a[k])if(new RegExp("\\b"+k+"\\b","i").test(l)){var _=o.pid;a[k]=function(){var S=s.format.apply(s,arguments);console.error("%s %d: %s",k,_,S)}}else a[k]=function(){};return a[k]},s.inspect=u,u.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},u.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},s.isArray=g,s.isBoolean=b,s.isNull=y,s.isNullOrUndefined=function(k){return k==null},s.isNumber=w,s.isString=C,s.isSymbol=function(k){return typeof k=="symbol"},s.isUndefined=N,s.isRegExp=I,s.isObject=$,s.isDate=D,s.isError=F,s.isFunction=V,s.isPrimitive=function(k){return k===null||typeof k=="boolean"||typeof k=="number"||typeof k=="string"||typeof k=="symbol"||k===void 0},s.isBuffer=t("./support/isBuffer");var E=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(){var k=new Date,_=[U(k.getHours()),U(k.getMinutes()),U(k.getSeconds())].join(":");return[k.getDate(),E[k.getMonth()],_].join(" ")}function B(k,_){return Object.prototype.hasOwnProperty.call(k,_)}s.log=function(){console.log("%s - %s",M(),s.format.apply(s,arguments))},s.inherits=t("inherits"),s._extend=function(k,_){if(!_||!$(_))return k;for(var S=Object.keys(_),T=S.length;T--;)k[S[T]]=_[S[T]];return k}}).call(this)}).call(this,t("_process"),typeof Cr<"u"?Cr:typeof self<"u"?self:typeof window<"u"?window:{})},{"./support/isBuffer":526,_process:467,inherits:525}],528:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"v1",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(s,"v3",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(s,"v4",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(s,"v5",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(s,"NIL",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(s,"version",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(s,"validate",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(s,"stringify",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(s,"parse",{enumerable:!0,get:function(){return f.default}});var o=m(t("./v1.js")),i=m(t("./v3.js")),c=m(t("./v4.js")),l=m(t("./v5.js")),a=m(t("./nil.js")),u=m(t("./version.js")),h=m(t("./validate.js")),d=m(t("./stringify.js")),f=m(t("./parse.js"));function m(p){return p&&p.__esModule?p:{default:p}}},{"./nil.js":530,"./parse.js":531,"./stringify.js":535,"./v1.js":536,"./v3.js":537,"./v4.js":539,"./v5.js":540,"./validate.js":541,"./version.js":542}],529:[function(t,n,s){function o(f){return 14+(f+64>>>9<<4)+1}function i(f,m){const p=(65535&f)+(65535&m);return(f>>16)+(m>>16)+(p>>16)<<16|65535&p}function c(f,m,p,g,b,y){return i((w=i(i(m,f),i(g,y)))<<(C=b)|w>>>32-C,p);var w,C}function l(f,m,p,g,b,y,w){return c(m&p|~m&g,f,m,b,y,w)}function a(f,m,p,g,b,y,w){return c(m&g|p&~g,f,m,b,y,w)}function u(f,m,p,g,b,y,w){return c(m^p^g,f,m,b,y,w)}function h(f,m,p,g,b,y,w){return c(p^(m|~g),f,m,b,y,w)}Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var d=function(f){if(typeof f=="string"){const m=unescape(encodeURIComponent(f));f=new Uint8Array(m.length);for(let p=0;p<m.length;++p)f[p]=m.charCodeAt(p)}return(function(m){const p=[],g=32*m.length;for(let b=0;b<g;b+=8){const y=m[b>>5]>>>b%32&255,w=parseInt("0123456789abcdef".charAt(y>>>4&15)+"0123456789abcdef".charAt(15&y),16);p.push(w)}return p})((function(m,p){m[p>>5]|=128<<p%32,m[o(p)-1]=p;let g=1732584193,b=-271733879,y=-1732584194,w=271733878;for(let C=0;C<m.length;C+=16){const N=g,I=b,$=y,D=w;g=l(g,b,y,w,m[C],7,-680876936),w=l(w,g,b,y,m[C+1],12,-389564586),y=l(y,w,g,b,m[C+2],17,606105819),b=l(b,y,w,g,m[C+3],22,-1044525330),g=l(g,b,y,w,m[C+4],7,-176418897),w=l(w,g,b,y,m[C+5],12,1200080426),y=l(y,w,g,b,m[C+6],17,-1473231341),b=l(b,y,w,g,m[C+7],22,-45705983),g=l(g,b,y,w,m[C+8],7,1770035416),w=l(w,g,b,y,m[C+9],12,-1958414417),y=l(y,w,g,b,m[C+10],17,-42063),b=l(b,y,w,g,m[C+11],22,-1990404162),g=l(g,b,y,w,m[C+12],7,1804603682),w=l(w,g,b,y,m[C+13],12,-40341101),y=l(y,w,g,b,m[C+14],17,-1502002290),b=l(b,y,w,g,m[C+15],22,1236535329),g=a(g,b,y,w,m[C+1],5,-165796510),w=a(w,g,b,y,m[C+6],9,-1069501632),y=a(y,w,g,b,m[C+11],14,643717713),b=a(b,y,w,g,m[C],20,-373897302),g=a(g,b,y,w,m[C+5],5,-701558691),w=a(w,g,b,y,m[C+10],9,38016083),y=a(y,w,g,b,m[C+15],14,-660478335),b=a(b,y,w,g,m[C+4],20,-405537848),g=a(g,b,y,w,m[C+9],5,568446438),w=a(w,g,b,y,m[C+14],9,-1019803690),y=a(y,w,g,b,m[C+3],14,-187363961),b=a(b,y,w,g,m[C+8],20,1163531501),g=a(g,b,y,w,m[C+13],5,-1444681467),w=a(w,g,b,y,m[C+2],9,-51403784),y=a(y,w,g,b,m[C+7],14,1735328473),b=a(b,y,w,g,m[C+12],20,-1926607734),g=u(g,b,y,w,m[C+5],4,-378558),w=u(w,g,b,y,m[C+8],11,-2022574463),y=u(y,w,g,b,m[C+11],16,1839030562),b=u(b,y,w,g,m[C+14],23,-35309556),g=u(g,b,y,w,m[C+1],4,-1530992060),w=u(w,g,b,y,m[C+4],11,1272893353),y=u(y,w,g,b,m[C+7],16,-155497632),b=u(b,y,w,g,m[C+10],23,-1094730640),g=u(g,b,y,w,m[C+13],4,681279174),w=u(w,g,b,y,m[C],11,-358537222),y=u(y,w,g,b,m[C+3],16,-722521979),b=u(b,y,w,g,m[C+6],23,76029189),g=u(g,b,y,w,m[C+9],4,-640364487),w=u(w,g,b,y,m[C+12],11,-421815835),y=u(y,w,g,b,m[C+15],16,530742520),b=u(b,y,w,g,m[C+2],23,-995338651),g=h(g,b,y,w,m[C],6,-198630844),w=h(w,g,b,y,m[C+7],10,1126891415),y=h(y,w,g,b,m[C+14],15,-1416354905),b=h(b,y,w,g,m[C+5],21,-57434055),g=h(g,b,y,w,m[C+12],6,1700485571),w=h(w,g,b,y,m[C+3],10,-1894986606),y=h(y,w,g,b,m[C+10],15,-1051523),b=h(b,y,w,g,m[C+1],21,-2054922799),g=h(g,b,y,w,m[C+8],6,1873313359),w=h(w,g,b,y,m[C+15],10,-30611744),y=h(y,w,g,b,m[C+6],15,-1560198380),b=h(b,y,w,g,m[C+13],21,1309151649),g=h(g,b,y,w,m[C+4],6,-145523070),w=h(w,g,b,y,m[C+11],10,-1120210379),y=h(y,w,g,b,m[C+2],15,718787259),b=h(b,y,w,g,m[C+9],21,-343485551),g=i(g,N),b=i(b,I),y=i(y,$),w=i(w,D)}return[g,b,y,w]})((function(m){if(m.length===0)return[];const p=8*m.length,g=new Uint32Array(o(p));for(let b=0;b<p;b+=8)g[b>>5]|=(255&m[b/8])<<b%32;return g})(f),8*f.length))};s.default=d},{}],530:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0,s.default="00000000-0000-0000-0000-000000000000"},{}],531:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var o,i=(o=t("./validate.js"))&&o.__esModule?o:{default:o},c=function(l){if(!(0,i.default)(l))throw TypeError("Invalid UUID");let a;const u=new Uint8Array(16);return u[0]=(a=parseInt(l.slice(0,8),16))>>>24,u[1]=a>>>16&255,u[2]=a>>>8&255,u[3]=255&a,u[4]=(a=parseInt(l.slice(9,13),16))>>>8,u[5]=255&a,u[6]=(a=parseInt(l.slice(14,18),16))>>>8,u[7]=255&a,u[8]=(a=parseInt(l.slice(19,23),16))>>>8,u[9]=255&a,u[10]=(a=parseInt(l.slice(24,36),16))/1099511627776&255,u[11]=a/4294967296&255,u[12]=a>>>24&255,u[13]=a>>>16&255,u[14]=a>>>8&255,u[15]=255&a,u};s.default=c},{"./validate.js":541}],532:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0,s.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i},{}],533:[function(t,n,s){let o;Object.defineProperty(s,"__esModule",{value:!0}),s.default=function(){if(!o&&(o=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!o))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return o(i)};const i=new Uint8Array(16)},{}],534:[function(t,n,s){function o(l,a,u,h){switch(l){case 0:return a&u^~a&h;case 1:return a^u^h;case 2:return a&u^a&h^u&h;case 3:return a^u^h}}function i(l,a){return l<<a|l>>>32-a}Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var c=function(l){const a=[1518500249,1859775393,2400959708,3395469782],u=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof l=="string"){const m=unescape(encodeURIComponent(l));l=[];for(let p=0;p<m.length;++p)l.push(m.charCodeAt(p))}else Array.isArray(l)||(l=Array.prototype.slice.call(l));l.push(128);const h=l.length/4+2,d=Math.ceil(h/16),f=new Array(d);for(let m=0;m<d;++m){const p=new Uint32Array(16);for(let g=0;g<16;++g)p[g]=l[64*m+4*g]<<24|l[64*m+4*g+1]<<16|l[64*m+4*g+2]<<8|l[64*m+4*g+3];f[m]=p}f[d-1][14]=8*(l.length-1)/Math.pow(2,32),f[d-1][14]=Math.floor(f[d-1][14]),f[d-1][15]=8*(l.length-1)&4294967295;for(let m=0;m<d;++m){const p=new Uint32Array(80);for(let N=0;N<16;++N)p[N]=f[m][N];for(let N=16;N<80;++N)p[N]=i(p[N-3]^p[N-8]^p[N-14]^p[N-16],1);let g=u[0],b=u[1],y=u[2],w=u[3],C=u[4];for(let N=0;N<80;++N){const I=Math.floor(N/20),$=i(g,5)+o(I,b,y,w)+C+a[I]+p[N]>>>0;C=w,w=y,y=i(b,30)>>>0,b=g,g=$}u[0]=u[0]+g>>>0,u[1]=u[1]+b>>>0,u[2]=u[2]+y>>>0,u[3]=u[3]+w>>>0,u[4]=u[4]+C>>>0}return[u[0]>>24&255,u[0]>>16&255,u[0]>>8&255,255&u[0],u[1]>>24&255,u[1]>>16&255,u[1]>>8&255,255&u[1],u[2]>>24&255,u[2]>>16&255,u[2]>>8&255,255&u[2],u[3]>>24&255,u[3]>>16&255,u[3]>>8&255,255&u[3],u[4]>>24&255,u[4]>>16&255,u[4]>>8&255,255&u[4]]};s.default=c},{}],535:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var o,i=(o=t("./validate.js"))&&o.__esModule?o:{default:o};const c=[];for(let a=0;a<256;++a)c.push((a+256).toString(16).substr(1));var l=function(a){let u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;const h=(c[a[u+0]]+c[a[u+1]]+c[a[u+2]]+c[a[u+3]]+"-"+c[a[u+4]]+c[a[u+5]]+"-"+c[a[u+6]]+c[a[u+7]]+"-"+c[a[u+8]]+c[a[u+9]]+"-"+c[a[u+10]]+c[a[u+11]]+c[a[u+12]]+c[a[u+13]]+c[a[u+14]]+c[a[u+15]]).toLowerCase();if(!(0,i.default)(h))throw TypeError("Stringified UUID is invalid");return h};s.default=l},{"./validate.js":541}],536:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var o=c(t("./rng.js")),i=c(t("./stringify.js"));function c(f){return f&&f.__esModule?f:{default:f}}let l,a,u=0,h=0;var d=function(f,m,p){let g=m&&p||0;const b=m||new Array(16);let y=(f=f||{}).node||l,w=f.clockseq!==void 0?f.clockseq:a;if(y==null||w==null){const F=f.random||(f.rng||o.default)();y==null&&(y=l=[1|F[0],F[1],F[2],F[3],F[4],F[5]]),w==null&&(w=a=16383&(F[6]<<8|F[7]))}let C=f.msecs!==void 0?f.msecs:Date.now(),N=f.nsecs!==void 0?f.nsecs:h+1;const I=C-u+(N-h)/1e4;if(I<0&&f.clockseq===void 0&&(w=w+1&16383),(I<0||C>u)&&f.nsecs===void 0&&(N=0),N>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");u=C,h=N,a=w,C+=122192928e5;const $=(1e4*(268435455&C)+N)%4294967296;b[g++]=$>>>24&255,b[g++]=$>>>16&255,b[g++]=$>>>8&255,b[g++]=255&$;const D=C/4294967296*1e4&268435455;b[g++]=D>>>8&255,b[g++]=255&D,b[g++]=D>>>24&15|16,b[g++]=D>>>16&255,b[g++]=w>>>8|128,b[g++]=255&w;for(let F=0;F<6;++F)b[g+F]=y[F];return m||(0,i.default)(b)};s.default=d},{"./rng.js":533,"./stringify.js":535}],537:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var o=c(t("./v35.js")),i=c(t("./md5.js"));function c(a){return a&&a.__esModule?a:{default:a}}var l=(0,o.default)("v3",48,i.default);s.default=l},{"./md5.js":529,"./v35.js":538}],538:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=function(u,h,d){function f(m,p,g,b){if(typeof m=="string"&&(m=(function(w){w=unescape(encodeURIComponent(w));const C=[];for(let N=0;N<w.length;++N)C.push(w.charCodeAt(N));return C})(m)),typeof p=="string"&&(p=(0,i.default)(p)),p.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let y=new Uint8Array(16+m.length);if(y.set(p),y.set(m,p.length),y=d(y),y[6]=15&y[6]|h,y[8]=63&y[8]|128,g){b=b||0;for(let w=0;w<16;++w)g[b+w]=y[w];return g}return(0,o.default)(y)}try{f.name=u}catch{}return f.DNS=l,f.URL=a,f},s.URL=s.DNS=void 0;var o=c(t("./stringify.js")),i=c(t("./parse.js"));function c(u){return u&&u.__esModule?u:{default:u}}const l="6ba7b810-9dad-11d1-80b4-00c04fd430c8";s.DNS=l;const a="6ba7b811-9dad-11d1-80b4-00c04fd430c8";s.URL=a},{"./parse.js":531,"./stringify.js":535}],539:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var o=c(t("./rng.js")),i=c(t("./stringify.js"));function c(a){return a&&a.__esModule?a:{default:a}}var l=function(a,u,h){const d=(a=a||{}).random||(a.rng||o.default)();if(d[6]=15&d[6]|64,d[8]=63&d[8]|128,u){h=h||0;for(let f=0;f<16;++f)u[h+f]=d[f];return u}return(0,i.default)(d)};s.default=l},{"./rng.js":533,"./stringify.js":535}],540:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var o=c(t("./v35.js")),i=c(t("./sha1.js"));function c(a){return a&&a.__esModule?a:{default:a}}var l=(0,o.default)("v5",80,i.default);s.default=l},{"./sha1.js":534,"./v35.js":538}],541:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var o,i=(o=t("./regex.js"))&&o.__esModule?o:{default:o},c=function(l){return typeof l=="string"&&i.default.test(l)};s.default=c},{"./regex.js":532}],542:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var o,i=(o=t("./validate.js"))&&o.__esModule?o:{default:o},c=function(l){if(!(0,i.default)(l))throw TypeError("Invalid UUID");return parseInt(l.substr(14,1),16)};s.default=c},{"./validate.js":541}],543:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.CHAR=`
|
|
106
106
|
\r --�𐀀-`,s.S=` \r
|
|
107
107
|
`,s.NAME_START_CHAR=":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-",s.NAME_CHAR="-"+s.NAME_START_CHAR+".0-9·̀-ͯ‿-⁀",s.CHAR_RE=new RegExp("^["+s.CHAR+"]$","u"),s.S_RE=new RegExp("^["+s.S+"]+$","u"),s.NAME_START_CHAR_RE=new RegExp("^["+s.NAME_START_CHAR+"]$","u"),s.NAME_CHAR_RE=new RegExp("^["+s.NAME_CHAR+"]$","u"),s.NAME_RE=new RegExp("^["+s.NAME_START_CHAR+"]["+s.NAME_CHAR+"]*$","u"),s.NMTOKEN_RE=new RegExp("^["+s.NAME_CHAR+"]+$","u");function o(i){return i>=65&&i<=90||i>=97&&i<=122||i===58||i===95||i===8204||i===8205||i>=192&&i<=214||i>=216&&i<=246||i>=248&&i<=767||i>=880&&i<=893||i>=895&&i<=8191||i>=8304&&i<=8591||i>=11264&&i<=12271||i>=12289&&i<=55295||i>=63744&&i<=64975||i>=65008&&i<=65533||i>=65536&&i<=983039}s.S_LIST=[32,10,13,9],s.isChar=function(i){return i>=32&&i<=55295||i===10||i===13||i===9||i>=57344&&i<=65533||i>=65536&&i<=1114111},s.isS=function(i){return i===32||i===10||i===13||i===9},s.isNameStartChar=o,s.isNameChar=function(i){return o(i)||i>=48&&i<=57||i===45||i===46||i===183||i>=768&&i<=879||i>=8255&&i<=8256}},{}],544:[function(t,n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.CHAR="--�𐀀-",s.RESTRICTED_CHAR="-\b\v\f---",s.S=` \r
|
|
108
|
-
`,s.NAME_START_CHAR=":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-",s.NAME_CHAR="-"+s.NAME_START_CHAR+".0-9·̀-ͯ‿-⁀",s.CHAR_RE=new RegExp("^["+s.CHAR+"]$","u"),s.RESTRICTED_CHAR_RE=new RegExp("^["+s.RESTRICTED_CHAR+"]$","u"),s.S_RE=new RegExp("^["+s.S+"]+$","u"),s.NAME_START_CHAR_RE=new RegExp("^["+s.NAME_START_CHAR+"]$","u"),s.NAME_CHAR_RE=new RegExp("^["+s.NAME_CHAR+"]$","u"),s.NAME_RE=new RegExp("^["+s.NAME_START_CHAR+"]["+s.NAME_CHAR+"]*$","u"),s.NMTOKEN_RE=new RegExp("^["+s.NAME_CHAR+"]+$","u");function o(i){return i>=65&&i<=90||i>=97&&i<=122||i===58||i===95||i===8204||i===8205||i>=192&&i<=214||i>=216&&i<=246||i>=248&&i<=767||i>=880&&i<=893||i>=895&&i<=8191||i>=8304&&i<=8591||i>=11264&&i<=12271||i>=12289&&i<=55295||i>=63744&&i<=64975||i>=65008&&i<=65533||i>=65536&&i<=983039}s.S_LIST=[32,10,13,9],s.isChar=function(i){return i>=1&&i<=55295||i>=57344&&i<=65533||i>=65536&&i<=1114111},s.isRestrictedChar=function(i){return i>=1&&i<=8||i===11||i===12||i>=14&&i<=31||i>=127&&i<=132||i>=134&&i<=159},s.isCharAndNotRestricted=function(i){return i===9||i===10||i===13||i>31&&i<127||i===133||i>159&&i<=55295||i>=57344&&i<=65533||i>=65536&&i<=1114111},s.isS=function(i){return i===32||i===10||i===13||i===9},s.isNameStartChar=o,s.isNameChar=function(i){return o(i)||i>=48&&i<=57||i===45||i===46||i===183||i>=768&&i<=879||i>=8255&&i<=8256}},{}],545:[function(t,n,s){function o(i){return i>=65&&i<=90||i===95||i>=97&&i<=122||i>=192&&i<=214||i>=216&&i<=246||i>=248&&i<=767||i>=880&&i<=893||i>=895&&i<=8191||i>=8204&&i<=8205||i>=8304&&i<=8591||i>=11264&&i<=12271||i>=12289&&i<=55295||i>=63744&&i<=64975||i>=65008&&i<=65533||i>=65536&&i<=983039}Object.defineProperty(s,"__esModule",{value:!0}),s.NC_NAME_START_CHAR="A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ--⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-",s.NC_NAME_CHAR="-"+s.NC_NAME_START_CHAR+".0-9·̀-ͯ‿-⁀",s.NC_NAME_START_CHAR_RE=new RegExp("^["+s.NC_NAME_START_CHAR+"]$","u"),s.NC_NAME_CHAR_RE=new RegExp("^["+s.NC_NAME_CHAR+"]$","u"),s.NC_NAME_RE=new RegExp("^["+s.NC_NAME_START_CHAR+"]["+s.NC_NAME_CHAR+"]*$","u"),s.isNCNameStartChar=o,s.isNCNameChar=function(i){return o(i)||i===45||i===46||i>=48&&i<=57||i===183||i>=768&&i<=879||i>=8255&&i<=8256}},{}]},{},[15])(15)}))})(p0)),p0.exports}var Hae=$ae();const Vae=jb(Hae);async function Wae(e){const{records:r,columns:t,columnDisplayNames:n,attributeMetadata:s,entityName:o,fileName:i="export",displaySettings:c}=e,l=c?.useLogicalNames??!1,a=c?.valueDisplayMode??"formatted",u=new Vae.Workbook;u.creator="FetchXML Studio",u.created=new Date;const h=u.addWorksheet("Data"),d=C=>{if(s){if(o){const N=s.get(o);if(N){if(N.has(C))return N.get(C);if(C.startsWith("_")&&C.endsWith("_value")){const I=C.slice(1,-6);if(N.has(I))return N.get(I)}}}for(const[,N]of s){if(N.has(C))return N.get(C);if(C.startsWith("_")&&C.endsWith("_value")){const I=C.slice(1,-6);if(N.has(I))return N.get(I)}}}},f=C=>r.some(N=>{const I=N[C],$=Xi(N,C);return $!==void 0&&$!==I}),m=[];for(const C of t){const N=n.get(C)||C,I=l?C:N;a==="both"&&f(C)?(m.push({sourceCol:C,headerName:I,isRawColumn:!1}),m.push({sourceCol:C,headerName:`${I} (Raw)`,isRawColumn:!0})):m.push({sourceCol:C,headerName:I,isRawColumn:!1})}const p=h.addRow(m.map(C=>C.headerName));p.font={bold:!0},p.fill={type:"pattern",pattern:"solid",fgColor:{argb:"FFE0E0E0"}},h.columns=m.map((C,N)=>{const I=d(C.sourceCol);let $=Math.max(C.headerName.length+2,10);switch(I?.AttributeType){case"DateTime":$=Math.max($,18);break;case"Money":case"Decimal":case"Double":$=Math.max($,14);break;case"Lookup":case"Customer":case"Owner":$=Math.max($,25);break;case"Memo":$=Math.max($,40);break}return{key:`col_${N}`,width:$}});const g=(C,N,I,$)=>{const D=C[N],F=Xi(C,N);if(D==null)return"";if(I||a==="raw")switch($?.AttributeType){case"Integer":case"BigInt":return typeof D=="number"?D:parseInt(String(D),10);case"Decimal":case"Double":case"Money":return typeof D=="number"?D:parseFloat(String(D));case"DateTime":if(D instanceof Date)return D;if(typeof D=="string"){const V=new Date(D);return isNaN(V.getTime())?D:V}return D;case"Boolean":return D;default:return D}switch($?.AttributeType){case"Boolean":return F||(D?"Yes":"No");case"Integer":case"BigInt":return typeof D=="number"?D:parseInt(String(D),10);case"Decimal":case"Double":case"Money":return typeof D=="number"?D:parseFloat(String(D));case"DateTime":if(D instanceof Date)return D;if(typeof D=="string"){const V=new Date(D);return isNaN(V.getTime())?D:V}return D;case"Picklist":case"State":case"Status":return F||D;case"Lookup":case"Customer":case"Owner":return F||D;default:return F!==void 0&&F!==D?F:String(D)}};for(const C of r){const N=m.map($=>{const D=d($.sourceCol);return g(C,$.sourceCol,$.isRawColumn,D)}),I=h.addRow(N);m.forEach(($,D)=>{const F=d($.sourceCol),V=I.getCell(D+1);if(!$.isRawColumn)switch(F?.AttributeType){case"DateTime":V.numFmt="yyyy-mm-dd hh:mm:ss";break;case"Money":V.numFmt='"$"#,##0.00';break;case"Decimal":case"Double":{const G=F?.Precision??2;V.numFmt=`0.${"0".repeat(G)}`;break}case"Integer":case"BigInt":V.numFmt="#,##0";break}})}h.views=[{state:"frozen",ySplit:1}],m.length>0&&(h.autoFilter={from:{row:1,column:1},to:{row:r.length+1,column:m.length}});const b=await u.xlsx.writeBuffer(),y=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),w=`${i}_${y}.xlsx`;return{buffer:b,fileName:w}}async function Uae(e,r){if(window.toolboxAPI?.fileSystem?.saveFile){const o=await window.toolboxAPI.fileSystem.saveFile(r,new Uint8Array(e));o&&Ie("exportAPI",`✅ File saved via fileSystem: ${o}`);return}const t=new Blob([e],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),n=URL.createObjectURL(t),s=document.createElement("a");s.href=n,s.download=r,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(n)}const Xae=100,Gae=3;function Kae(e){if(e.mode!=="fetchxml")return;const r=e.pageSize??e.fullPageSize;if(!r||!Number.isInteger(r)||r%2!==0)return;const t=r/2;if(t<Xae)return;const n=e.pagingCookie?e.nextPage:2*(e.nextPage-1)+1;return{...e,pageSize:t,nextPage:n}}async function Yae(e,r,{retry:t,maxHalvings:n=Gae,onShrink:s}={}){let o=e;for(let i=0;;i++)try{return{result:await pd(()=>r(o),t),state:o}}catch(c){const l=i<n&&HY(c)?Kae(o):void 0;if(!l)throw c;s?.(l),o=l}}const Qae=wr({panel:{display:"flex",flexDirection:"column",gap:"8px",padding:"10px 12px",backgroundColor:le.colorNeutralBackground3,borderRadius:le.borderRadiusMedium},input:{maxWidth:"360px"},code:{fontFamily:le.fontFamilyMonospace}});function Zae({value:e,onValueChange:r,addPercent:t,onAddPercentChange:n,searchValue:s,disabled:o}){const i=Qae(),c=j.jsx("span",{className:i.code,children:"{0}"}),l=!e.trim();return j.jsxs("div",{className:i.panel,children:[j.jsx(Eo,{label:"Quick find value",hint:j.jsxs(j.Fragment,{children:["Replaces ",c," when you execute. The query keeps ",c,", so saving and copying are unchanged."]}),validationState:l?"warning":"none",validationMessage:l?"Enter a value to execute this quick find view.":void 0,children:j.jsx(_n,{className:i.input,value:e,onChange:(a,u)=>r(u.value),placeholder:"e.g. contoso",disabled:o})}),j.jsx(ho,{label:"Add % at the end",checked:t,disabled:o,onChange:(a,u)=>n(u.checked===!0)}),s&&j.jsxs(st,{size:200,children:["Runs with ",j.jsxs("span",{className:i.code,children:['value="',s,'"']})," in each ",c," condition."]})]})}const Jae=wr({drawer:{width:"360px"},section:{marginBottom:le.spacingVerticalL},sectionTitle:{fontSize:le.fontSizeBase400,fontWeight:le.fontWeightSemibold,marginBottom:le.spacingVerticalM,display:"flex",alignItems:"center",gap:le.spacingHorizontalS},settingItem:{display:"flex",flexDirection:"column",gap:le.spacingVerticalXS,marginBottom:le.spacingVerticalM},settingRow:{display:"flex",justifyContent:"space-between",alignItems:"center"},settingLabel:{fontWeight:le.fontWeightSemibold,display:"flex",alignItems:"center",gap:le.spacingHorizontalXS},settingDescription:{fontSize:le.fontSizeBase200,color:le.colorNeutralForeground3},dropdown:{minWidth:"160px"},radioGroup:{display:"flex",flexDirection:"column",gap:le.spacingVerticalXS,marginTop:le.spacingVerticalXS},disabledHint:{fontSize:le.fontSizeBase100,color:le.colorNeutralForegroundDisabled,fontStyle:"italic"}});function ese({open:e,settings:r,onClose:t,onSettingsChange:n,accessSummary:s}){const o=Jae(),i=A.useCallback(d=>{n({...r,useLogicalNames:d})},[r,n]),c=A.useCallback(d=>{n({...r,valueDisplayMode:d})},[r,n]),l=A.useCallback(d=>{n({...r,entityScopeMode:d})},[r,n]),a=A.useCallback(d=>{n({...r,advancedFindOnly:d})},[r,n]),u=!s||s.fullFilterMode,h=!s||s.fullFilterMode||s.solutionsOnlyMode;return j.jsxs(mp,{open:e,onOpenChange:(d,f)=>!f.open&&t(),position:"end",size:"small",className:o.drawer,children:[j.jsx(bp,{children:j.jsxs(vp,{action:j.jsx(St,{appearance:"subtle","aria-label":"Close",icon:j.jsx(np,{}),onClick:t}),children:[j.jsx(v4,{style:{marginRight:le.spacingHorizontalS}}),"Settings"]})}),j.jsxs(gp,{children:[j.jsxs("div",{className:o.section,children:[j.jsx(st,{className:o.sectionTitle,children:"Query scope"}),j.jsxs("div",{className:o.settingItem,children:[j.jsxs(st,{className:o.settingLabel,children:["Entity source",j.jsx(Or,{content:"Controls how the entity list is populated in the toolbar. Scoped modes are faster; 'All entities' loads every entity in the environment.",relationship:"description",children:j.jsx(A0,{style:{color:le.colorNeutralForeground3}})})]}),j.jsx(st,{className:o.settingDescription,block:!0,children:"How to scope the entity picker"}),j.jsxs(ta,{className:o.radioGroup,value:r.entityScopeMode,onChange:(d,f)=>l(f.value),children:[j.jsx(Or,{content:u?"":"Requires prvReadPublisher + prvReadSolution",relationship:"description",positioning:"before",children:j.jsx(Yr,{value:"publisher-solution",label:"Publisher → Solution (default)",disabled:!u})}),j.jsx(Or,{content:h?"":"Requires prvReadSolution",relationship:"description",positioning:"before",children:j.jsx(Yr,{value:"solution-only",label:"Solution only",disabled:!h})}),j.jsx(Yr,{value:"all",label:"All entities"})]})]}),j.jsx(Sh,{style:{marginBottom:le.spacingVerticalM}}),j.jsx("div",{className:o.settingItem,children:j.jsxs("div",{className:o.settingRow,children:[j.jsxs("div",{children:[j.jsxs(st,{className:o.settingLabel,children:["Advanced Find only",j.jsx(Or,{content:"When on, entities, attributes and relationships are limited to the ones Advanced Find shows (IsValidForAdvancedFind). Turn off to build queries Advanced Find can't: system and customization entities, intersect entities, and hidden attributes and relationships. Attributes that can't be read (IsValidForRead = false) are never listed.",relationship:"description",children:j.jsx(A0,{style:{color:le.colorNeutralForeground3}})})]}),j.jsx(st,{className:o.settingDescription,block:!0,children:"Limit entities, attributes & relationships to the ones Advanced Find shows"}),!r.advancedFindOnly&&j.jsx(st,{className:o.disabledHint,block:!0,children:"All entities, attributes and relationships are shown. A few system entities can't be queried; Dataverse returns an error for those."})]}),j.jsx(Qs,{checked:r.advancedFindOnly,onChange:(d,f)=>a(f.checked)})]})})]}),j.jsx(Sh,{}),j.jsxs("div",{className:o.section,style:{marginTop:le.spacingVerticalL},children:[j.jsx(st,{className:o.sectionTitle,children:"Display"}),j.jsx("div",{className:o.settingItem,children:j.jsxs("div",{className:o.settingRow,children:[j.jsxs("div",{children:[j.jsx(st,{className:o.settingLabel,children:"Use logical names"}),j.jsx(st,{className:o.settingDescription,block:!0,children:"Show attribute logical names in column headers instead of display names"})]}),j.jsx(Qs,{checked:r.useLogicalNames,onChange:(d,f)=>i(f.checked)})]})}),j.jsxs("div",{className:o.settingItem,children:[j.jsx(st,{className:o.settingLabel,children:"Value display mode"}),j.jsx(st,{className:o.settingDescription,block:!0,children:"How to display cell values in the results grid"}),j.jsxs(po,{className:o.dropdown,value:r.valueDisplayMode==="formatted"?"Formatted":r.valueDisplayMode==="raw"?"Raw":"Both",selectedOptions:[r.valueDisplayMode],onOptionSelect:(d,f)=>c(f.optionValue),children:[j.jsx(Jt,{value:"formatted",children:"Formatted"}),j.jsx(Jt,{value:"raw",children:"Raw"}),j.jsx(Jt,{value:"both",children:"Both (2 columns per attribute)"})]})]})]})]})]})}const Bb={useLogicalNames:!1,valueDisplayMode:"formatted",entityScopeMode:"publisher-solution",advancedFindOnly:!0,scopeCollapsed:!1},yk="fetchxml-studio:displaySettings";function tse(e){return!e||typeof e!="object"?{...Bb}:{...Bb,...e}}function rse(){const[e,r]=A.useState(Bb),t=A.useRef(!1);A.useEffect(()=>{let s=!0;async function o(){try{if(typeof window<"u"&&window.toolboxAPI?.settings?.get){const i=await window.toolboxAPI.settings.get(yk);if(s){const c=tse(i);r(c),Ie("settings","⚙️ Settings loaded from toolboxAPI:",c)}}else Ie("settings","⚙️ toolboxAPI.settings not available — using in-memory defaults")}catch(i){console.warn("⚙️ Failed to load settings from toolboxAPI:",i)}finally{s&&(t.current=!0)}}return o(),()=>{s=!1}},[]);const n=A.useCallback(s=>{r(s),t.current&&typeof window<"u"&&window.toolboxAPI?.settings?.set&&window.toolboxAPI.settings.set(yk,s).then(()=>{Ie("settings","⚙️ Settings saved to toolboxAPI:",s)}).catch(o=>{console.warn("⚙️ Failed to save settings to toolboxAPI:",o)})},[]);return[e,n]}const nse="Dataverse didn't return a paging cookie for this query (for example, it's sorted by a link-entity attribute or uses distinct), so pages are fetched with page numbers only. Microsoft recommends paging cookies; this works, but is slower for large result sets.",ose=wr({root:{backgroundColor:le.colorNeutralBackground1,color:le.colorNeutralForeground1,display:"flex",flexDirection:"row",height:"100%",width:"100%",overflow:"hidden",position:"absolute",top:0,left:0,right:0,bottom:0},leftPane:{display:"flex",flexDirection:"column",overflow:"hidden",minWidth:"300px",maxWidth:"800px",height:"100%"},leftPaneTop:{display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},horizontalResizeHandle:{height:"6px",cursor:"ns-resize",backgroundColor:le.colorNeutralBackground3,display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0,":hover":{backgroundColor:le.colorNeutralBackground3Hover},":active":{backgroundColor:le.colorBrandBackgroundPressed}},horizontalGrip:{fontSize:"10px",color:le.colorNeutralForeground3,userSelect:"none",pointerEvents:"none",display:"flex",gap:"3px",alignItems:"center"},verticalResizeHandle:{width:"6px",cursor:"ew-resize",backgroundColor:le.colorNeutralBackground3,display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0,":hover":{backgroundColor:le.colorNeutralBackground3Hover},":active":{backgroundColor:le.colorBrandBackgroundPressed}},verticalGrip:{fontSize:"10px",color:le.colorNeutralForeground3,userSelect:"none",pointerEvents:"none",display:"flex",flexDirection:"column",gap:"2px",lineHeight:"0.5"},leftPaneBottom:{display:"flex",flexDirection:"column",minHeight:"100px",overflow:"hidden",minWidth:0},propertiesContent:{flex:1,overflow:"hidden"},rightPane:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},toolbar:{padding:"12px 16px",borderTop:`1px solid ${le.colorNeutralStroke1}`,borderBottom:`1px solid ${le.colorNeutralStroke1}`,display:"flex",gap:"8px",alignItems:"center",flexShrink:0},placeholder:{padding:"16px",color:le.colorNeutralForeground3,display:"flex",alignItems:"center",justifyContent:"center",height:"100%"}});function ise(){const{theme:e,connectionKey:r,connectionName:t}=N8(),n=e==="dark";A.useEffect(()=>{document.documentElement.style.colorScheme=n?"dark":"light"},[n]);const s=A.useRef({prefillConsumed:!1}),[o,i]=A.useState({key:void 0,session:0}),c=yY(o,r);c.scope!==o&&(c.changed&&(Zt.clear(),KY(),s.current.fetchXml=s.current.readFetchXml?.()),i(c.scope));const l=o.session;return A.useEffect(()=>{l!==0&&window.toolboxAPI?.utils?.showNotification?.({title:"Connection changed",body:t?`FetchXML Studio reloaded its metadata for ${t}. Results and the loaded view were cleared.`:"FetchXML Studio has no connection now. Results and the loaded view were cleared.",type:"info"})},[l]),j.jsx(r4,{theme:n?ZE:KE,children:j.jsx(zae,{isDark:n,children:j.jsx(Rae,{children:j.jsx(ase,{carryOver:s.current})},l)})})}function ase({carryOver:e}){const r=ose(),t=wd(),{loadAttributes:n,loadEntityMetadata:s,loadRelationships:o}=g_(),i=Fie(),{tools:c}=qie();A.useEffect(()=>{const _e=e.fetchXml;if(!_e)return;e.fetchXml=void 0;const Le=t.loadFetchXml(_e);Le.success||console.error("Connection change: couldn't reload the query:",Le.errors)},[]);const l=t.fetchQuery;A.useEffect(()=>{e.readFetchXml=()=>l?ya(l):void 0},[e,l]),A.useEffect(()=>{i.loading||e.prefillConsumed||(e.prefillConsumed=!0,i.context&&(async()=>{try{const _e=await EJ(i.context);if(!_e)return;if(_e.kind==="entity"){t.setEntity(_e.entityLogicalName);return}const Le=t.loadFetchXml(_e.fetchXml);Le.success||(console.error("T2T prefill: failed to parse incoming FetchXML:",Le.errors),await window.toolboxAPI?.utils?.showNotification?.({title:"Could not load incoming query",body:"The tool that launched FetchXML Studio sent a query that couldn't be parsed.",type:"error"}))}catch(_e){console.error("T2T prefill: failed to load launch context:",_e)}})())},[i.loading,i.context]);const[a,u]=A.useState(null),[h,d]=A.useState(!1),[f,m]=A.useState(!1),[p,g]=A.useState(new Map),[b,y]=A.useState(null),[w,C]=A.useState([]),[N,I]=A.useState([]),[$,D]=A.useState(!1),F=A.useRef(null),[V,G]=A.useState(null),U=_e=>{F.current=_e,G(_e)},[E,M]=A.useState(null),B=A.useRef(0),k=A.useRef(0);A.useEffect(()=>()=>{B.current++,k.current++},[]);const[_,S]=A.useState({isExporting:!1,hasPrivilege:!1,privilegeChecked:!1}),[T,z]=A.useState(),[P,O]=A.useState(""),[X,K]=A.useState(!0),J=A.useRef(void 0),[H,Z]=A.useState({canDelete:!1,canBulkDelete:!1,canRunWorkflow:!1,privilegesChecked:!1}),[L,q]=A.useState({open:!1,recordIds:[]}),[Y,re]=A.useState(null),[ie,ne]=A.useState({open:!1,recordIds:[]}),[ae,be]=A.useState({open:!1,recordIds:[]}),[pe,te]=A.useState({open:!1,action:"activate",recordIds:[]}),[se,ue]=A.useState({}),[he,me]=A.useState([]),[xe,Be]=A.useState(!1),[Re,He]=rse();A.useLayoutEffect(()=>{Zu.setAdvancedFindOnly(Re.advancedFindOnly)},[Re.advancedFindOnly]);const Je=Sp(),{accessSummary:Te}=_7(),[Ee,$e]=A.useState(58),[Ze,yt]=A.useState(480),[dt,Ke]=A.useState(!1),[We,nt]=A.useState(!1);A.useEffect(()=>{if(!dt)return;const _e=Qe=>{const Ye=document.querySelector("[data-left-pane]");if(!Ye)return;const Lt=Ye.getBoundingClientRect(),Pt=(Qe.clientY-Lt.top)/Lt.height*100;Pt>=30&&Pt<=80&&$e(Pt)},Le=()=>{Ke(!1)};return document.addEventListener("mousemove",_e),document.addEventListener("mouseup",Le),()=>{document.removeEventListener("mousemove",_e),document.removeEventListener("mouseup",Le)}},[dt]),A.useEffect(()=>{if(!We)return;const _e=Qe=>{const Ye=document.querySelector("[data-app-root]");if(!Ye)return;const Lt=Ye.getBoundingClientRect(),Pt=Qe.clientX-Lt.left;Pt>=300&&Pt<=800&&yt(Pt)},Le=()=>{nt(!1)};return document.addEventListener("mousemove",_e),document.addEventListener("mouseup",Le),()=>{document.removeEventListener("mousemove",_e),document.removeEventListener("mouseup",Le)}},[We]),A.useEffect(()=>{if(!ir()){console.error("❌ Dataverse API not available on window object");return}oi().then(_e=>{_e?Ie("app","WhoAmI succeeded",{UserId:_e.UserId}):Ie("app","WhoAmI returned null - API may not be fully initialized")}).catch(_e=>{console.error("❌ WhoAmI Error:",_e)})},[]),A.useEffect(()=>{const _e=async()=>{try{const Le=await oi();if(Le){const Qe=await ni(Le.UserId,"prvExportToExcel");S(Ye=>({...Ye,hasPrivilege:Qe,privilegeChecked:!0})),Ie("app",`📊 Export to Excel privilege: ${Qe?"GRANTED":"DENIED"}`)}else S(Qe=>({...Qe,hasPrivilege:!1,privilegeChecked:!0}))}catch(Le){console.error("Failed to check export privilege:",Le),S(Qe=>({...Qe,hasPrivilege:!1,privilegeChecked:!0}))}};ir()&&_e()},[]);const Ve=t.fetchQuery?.entity.name;A.useEffect(()=>{if(!Ve||!ir()){Z({canDelete:!1,canBulkDelete:!1,canRunWorkflow:!1,privilegesChecked:!1});return}(async()=>{try{const Le=await uJ(Ve),Qe=await oJ(),Ye=await aJ();Z({canDelete:Le,canBulkDelete:Qe,canRunWorkflow:Ye,privilegesChecked:!0}),Ie("app",`🔐 Record action privileges for ${Ve}:`,{canDelete:Le,canBulkDelete:Qe,canRunWorkflow:Ye})}catch(Le){console.error("Failed to check record action privileges:",Le),Z({canDelete:!1,canBulkDelete:!1,canRunWorkflow:!1,privilegesChecked:!0})}})()},[Ve]),A.useEffect(()=>{const _e=WQ(Ve);if(!Ve||_e||!ir()){ue(_e?{activate:_e,deactivate:_e}:{});return}let Le=!0;return ue({}),(async()=>{const[Qe,Ye]=await Promise.all([f_(Ve).catch(Pt=>{console.warn("Activate/Deactivate: couldn't read the state model:",Pt)}),pJ(Ve)]);if(!Le)return;const Lt=Ye===!1?"You don't have the Write privilege on this entity, so you can't change its records' status.":void 0;ue({activate:(Qe!==void 0?f5(Qe,"activate"):void 0)??Lt,deactivate:(Qe!==void 0?f5(Qe,"deactivate"):void 0)??Lt})})(),()=>{Le=!1}},[Ve]);const wt=A.useMemo(()=>QY(t.fetchQuery),[t.fetchQuery]),Wt=wt.rootEntityName,Ct=b&&b.LogicalName===Wt?b:null;A.useEffect(()=>{const{rootEntityName:_e,entityNames:Le}=wt;if(!_e){g(new Map),y(null);return}let Qe=!1;return Promise.all(Le.map(async Ye=>{try{const Lt=await jc(Ye),Pt=new Map;return Lt.forEach(br=>{Pt.set(br.LogicalName,br)}),{entityName:Ye,attrMap:Pt}}catch(Lt){return console.error(`Failed to load attributes for ${Ye}:`,Lt),{entityName:Ye,attrMap:new Map}}})).then(Ye=>{if(Qe)return;const Lt=new Map;Ye.forEach(({entityName:Pt,attrMap:br})=>{Lt.set(Pt,br)}),g(Lt)}),s(_e).then(Ye=>{Qe||y(Ye)}).catch(Ye=>{console.error("Failed to load entity metadata:",Ye),Qe||y(null)}),D(!0),o(_e).then(Ye=>{Qe||(C(Ye.manyToOne),I(Ye.oneToMany))}).catch(Ye=>{console.error("Failed to load relationships:",Ye),!Qe&&(C([]),I([]))}).finally(()=>{Qe||D(!1)}),()=>{Qe=!0}},[wt.key,s,o,Je]),A.useEffect(()=>{const _e=t.fetchQuery?.entity?.id;_e!==void 0&&_e===J.current||(B.current++,k.current++,u(null),U(null),M(null),m(!1),d(!1))},[t.fetchQuery?.entity?.id]);const{syncLayoutWithFetchXml:Tt}=t;A.useEffect(()=>{const _e=(t.fetchQuery?.entity?.attributes?.length??0)>0;if((t.layoutNeedsSync||_e&&!t.columnConfig)&&t.fetchQuery){const Qe=new Map,Ye=t.fetchQuery.entity?.name;p&&Ye&&p.get(Ye)?.forEach((Pt,br)=>{Qe.set(br,Pt.AttributeType||"")}),Tt(Qe,Ct?.PrimaryIdAttribute)}},[t.layoutNeedsSync,t.fetchQuery,t.columnConfig,p,Ct,Tt]);const ct=t.fetchQuery?ya(t.fetchQuery):"",Ot=A.useMemo(()=>sb(ct),[ct]),Ft=OQ(P,X),vr=t.fetchQuery?.options?.aggregate===!0,fr=A.useMemo(()=>{if(!t.fetchQuery?.entity?.links)return!1;const _e=Le=>{for(const Qe of Le)if(Qe.relationshipType==="1N"||Qe.relationshipType==="NN"||Qe.links&&_e(Qe.links))return!0;return!1};return _e(t.fetchQuery.entity.links)},[t.fetchQuery]),zt=Ct?.PrimaryIdAttribute,tr=t.fetchQuery?.options?.distinct===!0,gr=A.useMemo(()=>{const _e=a?.rows;if(!(!_e||_e.length===0||!zt)&&!_e.some(Le=>typeof Le[zt]=="string"))return vr?"Aggregate query results don't contain record IDs, so record actions aren't available.":tr?"Distinct query results don't contain record IDs (Dataverse doesn't return the primary key for distinct queries), so record actions aren't available.":"These results don't include the table's primary key, so record actions aren't available."},[a,zt,vr,tr]),Rt=A.useMemo(()=>!t.fetchQuery||!Ct?"":Tae(t.columnConfig,t.fetchQuery,{objectTypeCode:Ct.ObjectTypeCode,primaryIdAttribute:Ct.PrimaryIdAttribute,primaryNameAttribute:Ct.PrimaryNameAttribute}),[t.columnConfig,t.fetchQuery,Ct]),ur=(_e,Le,Qe,Ye)=>{if(Ct&&t.fetchQuery){const Lt=t.loadedView?.id===_e?t.loadedView:null;t.setLoadedView({id:_e,type:Le,entitySetName:Ct.EntitySetName,name:Qe,originalFetchXml:ya(t.fetchQuery),queryType:Lt?Lt.queryType:0,isCustomizable:Lt?.isCustomizable,description:Ye.description,isDefault:Ye.isDefault,isManaged:Lt?.isManaged,solutionId:Lt?.solutionId,ownerId:Lt?.ownerId,ownerName:Lt?.ownerName})}Ie("app",`✅ View saved: ${Qe} (${Le}) - ${_e}`)},je=async _e=>{const Le=_e?.fetchQuery??t.fetchQuery,Qe=_e?.xml??ct;if(!Qe)return;const Ye=sb(Qe)>0;if(Ye&&!Ft)return;const Lt=Ye?FQ(Qe,Ft):Qe,Pt=++B.current;k.current++,d(!0),m(!1),u(null),U(null),M(null),z(void 0),J.current=Le?.entity.id;const br=performance.now(),dr=Le?.entity.name,sr=t.retrieveAllRecords,Ur=AY(Lt),Pn=Ur.top!==void 0;try{let Dr;const It=_e?null:t.loadedView;let On=!1;if(It&&!Ye&&zQ(Lt,It.originalFetchXml)&&(On=!0,Ie("app",`📋 Executing ${It.type} view "${It.name}" via ${It.type==="system"?"savedQuery":"userQuery"}=${It.id}`),It.type==="system"?Dr=await EZ(It.entitySetName,It.id):Dr=await AZ(It.entitySetName,It.id)),Dr||(Ie("app",_e?"✏️ Executing editor FetchXML (loaded into the tree)":Ye?"🔎 Executing quick find FetchXML with the test value":It?`📝 View "${It.name}" was modified - executing its FetchXML`:"📡 Executing FetchXML query"),Dr=await v5(Lt)),Pt!==B.current)return;const go=Math.round(performance.now()-br),Gn=!Pn&&E8(On?"view":"fetchxml",Dr),Di=Ur.page??1;u({query:Le,rows:Dr.records.map(si=>({...si})),totalRecordCount:Dr.totalRecordCount,totalRecordCountLimitExceeded:Dr.totalRecordCountLimitExceeded,moreRecords:Gn,pagingCookie:Dr.pagingCookie,entityLogicalName:dr,executionTimeMs:go}),U({mode:On?"view":"fetchxml",xml:Lt,pageSize:Ur.count,fullPageSize:Ur.count===void 0&&Gn?Dr.records.length:void 0,currentPage:Di,nextPage:Di+1,pagingCookie:Dr.pagingCookie,nextLink:Dr.nextLink,moreRecords:Gn,isRetrieveAllInProgress:sr&&Gn,retrieveAll:sr}),d(!1),sr&&Gn&&await Ut(Pt)}catch(Dr){if(Pt!==B.current)return;console.error("Failed to execute FetchXML:",Dr),z(zn(Dr,"An unexpected error occurred while executing the query.")),u({query:Le,rows:[]}),d(!1)}},Pe=A.useRef(je);A.useLayoutEffect(()=>{Pe.current=je});const fe=A.useMemo(()=>vre(t.fetchQuery,t.columnFilterId),[t.fetchQuery,t.columnFilterId]),[ye,Ne]=A.useState(0);A.useEffect(()=>{ye>0&&Pe.current()},[ye]);const{addColumnFilter:Ue,removeColumnFilter:vt,clearColumnFilters:ze}=t,gt=A.useCallback(_e=>{Ue(_e),Ne(Le=>Le+1)},[Ue]),bt=A.useCallback(_e=>{_e.length!==0&&(_e.length===fe.length?ze():_e.forEach(Le=>vt(Le)),Ne(Le=>Le+1))},[fe.length,ze,vt]),at=async _e=>{const{result:Le,state:Qe}=await Yae(_e,Ye=>Ye.mode==="view"?NZ(Ye.nextLink??""):v5(fQ(Ye.xml,Ye.nextPage,Ye.pagingCookie,Ye.pageSize)),{onShrink:Ye=>Ie("app",`Page too large: retrying page ${Ye.nextPage} with count ${Ye.pageSize}`)});return{result:Le,next:zY(Qe,Le)}},Bt=(_e,Le,Qe,Ye)=>{if(_e!==B.current)return!1;u(Pt=>Pt&&{...Pt,rows:Pt.rows.concat(Qe.records),moreRecords:Ye.moreRecords,pagingCookie:Ye.pagingCookie});const Lt=Le.mode==="fetchxml"&&!Le.pagingCookie?{kind:"simple",message:nse}:null;return M(Pt=>Pt&&Pt.kind!=="error"&&Pt.kind!=="stopped"?Pt:Lt),!0},Ut=async _e=>{const Le=++k.current,Qe=()=>_e===B.current&&Le===k.current;let Ye=F.current;if(!Ye)return;Ye={...Ye,isRetrieveAllInProgress:!0,retrieveAll:!0},m(!0),U(Ye);const Lt=Bh();try{for(;Ye?.moreRecords;){const{result:Pt,next:br}=await at(Ye);if(!Qe())return;Bt(_e,Ye,Pt,br),Ye={...br,isRetrieveAllInProgress:br.moreRecords},U(Ye)}Ie("app","✅ Retrieve All complete")}catch(Pt){if(!Qe())return;console.error("Failed during Retrieve All:",Pt),M({kind:"error",page:Ye?.nextPage,message:zn(Pt)})}finally{Lt(),Qe()&&(m(!1),F.current&&U({...F.current,isRetrieveAllInProgress:!1}))}},or=()=>{const _e=F.current;_e?.isRetrieveAllInProgress&&(k.current++,m(!1),U({..._e,isRetrieveAllInProgress:!1,retrieveAll:!1}),M({kind:"stopped",message:""}))},Tr=async()=>{const _e=F.current;if(!_e||!_e.moreRecords||_e.isRetrieveAllInProgress||f)return;const Le=B.current,Qe=++k.current,Ye=()=>Le===B.current&&Qe===k.current;m(!0);try{const{result:Lt,next:Pt}=await at(_e);if(!Ye())return;Bt(Le,_e,Lt,Pt),U(Pt),Ie("app",`✅ Page ${Pt.currentPage} loaded: ${Lt.records.length} records`)}catch(Lt){if(!Ye())return;console.error("Failed to load more records:",Lt),M({kind:"error",page:_e.nextPage,message:zn(Lt)})}finally{Ye()&&m(!1)}},Sr=()=>{M(null);const _e=F.current;_e&&(_e.retrieveAll?Ut(B.current):Tr())},_r=async()=>{if(!_.hasPrivilege){S(_e=>({..._e,error:"You don't have permission to export to Excel. Contact your administrator to request the 'Export to Excel' privilege."}));return}if(!t.loadedView){S(_e=>({..._e,error:"Export to Excel requires a saved view. Please save your query as a view first."}));return}if(!ct||!Rt){S(_e=>({..._e,error:"Export to Excel requires FetchXML and LayoutXML"}));return}S(_e=>({..._e,isExporting:!0,error:void 0}));try{Ie("app",`📤 Exporting to Excel via ${t.loadedView.type} view "${t.loadedView.name}"...`);const _e=t.loadedView.name,Le=await tJ(t.loadedView.id,t.loadedView.type,ct,Rt,_e);await rJ(Le.excelFile,Le.filename),Ie("app",`✅ Export complete: ${Le.filename}`),S(Qe=>({...Qe,isExporting:!1}))}catch(_e){console.error("Export to Excel failed:",_e),S(Le=>({...Le,isExporting:!1,error:zn(_e,"Export to Excel failed. Please try again.")}))}},xt=async()=>{if(!a||!a.rows.length){S(_e=>({..._e,error:"No data to export. Execute a query first."}));return}S(_e=>({..._e,isExporting:!0,error:void 0}));try{Ie("app",`📤 Exporting ${a.rows.length} records locally...`);const _e=new Map,Le=(br,dr)=>p?.get(br)?.get(dr),Qe=y7(o1(t.fetchQuery,a.rows,Le,a.query),t.columnConfig).map(br=>br.key);for(const br of Qe){let dr=br;if(p&&Ve){const sr=p.get(Ve);if(sr){const Ur=sr.get(br);if(Ur?.DisplayName?.UserLocalizedLabel?.Label&&(dr=Ur.DisplayName.UserLocalizedLabel.Label),br.startsWith("_")&&br.endsWith("_value")){const Pn=br.slice(1,-6),Dr=sr.get(Pn);Dr?.DisplayName?.UserLocalizedLabel?.Label&&(dr=Dr.DisplayName.UserLocalizedLabel.Label)}}}_e.set(br,dr)}const Ye=t.loadedView?.name||Ct?.DisplayName?.UserLocalizedLabel?.Label||Ve||"export",{buffer:Lt,fileName:Pt}=await Wae({records:a.rows,columns:Qe,columnDisplayNames:_e,attributeMetadata:p,entityName:Ve,fileName:Ye,displaySettings:Re});await Uae(Lt,Pt),Ie("app",`✅ Local export complete: ${Pt}`),S(br=>({...br,isExporting:!1}))}catch(_e){console.error("Local export failed:",_e),S(Le=>({...Le,isExporting:!1,error:_e instanceof Error?_e.message:"Local export failed. Please try again."}))}};A.useEffect(()=>{if(_.error){const _e=setTimeout(()=>{S(Le=>({...Le,error:void 0}))},1e4);return()=>clearTimeout(_e)}},[_.error]);const qt=A.useCallback(_e=>{me(_e)},[]),ce=A.useCallback(()=>he,[he]),we=A.useCallback(async _e=>{if(_e.length===0||!Ve)return;const Le=await Ah();if(!Le){console.error("Failed to get environment URL");return}for(const Qe of _e){const Ye=y5(Ve,Qe,Le);await j8(Ye)}},[Ve]),qe=A.useCallback(async _e=>{if(_e.length===0||!Ve)return;const Le=await Ah();if(!Le){console.error("Failed to get environment URL");return}const Qe=_e.map(Lt=>y5(Ve,Lt,Le)),Ye=Qe.join(`
|
|
109
|
-
`);await ws(Ye)?Ie("app",`📋 Copied ${Qe.length} record URL(s) to clipboard`):console.error("Failed to copy to clipboard")},[Ve]),Xe=A.useCallback(_e=>{if(!Ve)return;if(_e.length===0){if(!H.canBulkDelete){Ie("app","Bulk delete privilege required to delete all records from view");return}const Ye=a?.rows.length||0;ne({open:!0,recordIds:[],isAllRecords:!0,totalViewRecords:Ye});return}if(_e.length>100&&H.canBulkDelete){ne({open:!0,recordIds:_e,isAllRecords:!1});return}const Le=_e.length===1?a?.rows.find(Ye=>Ye[Ct?.PrimaryIdAttribute||""]===_e[0])?.[Ct?.PrimaryNameAttribute||""]:void 0,Qe=_e.length>=4;q({open:!0,recordIds:_e,recordName:Le,isBatchDelete:Qe})},[Ve,H.canBulkDelete,a,Ct]),kt=A.useCallback(_e=>{if(!Ve||!H.canBulkDelete)return;const Le=_e.length===0,Qe=a?.rows.length||0;ne({open:!0,recordIds:_e,isAllRecords:Le,totalViewRecords:Le?Qe:void 0})},[Ve,H.canBulkDelete,a]),ot=A.useCallback(async()=>{if(!Ve||L.recordIds.length===0)return;const _e=L.recordIds;re(null);const Le=Bh();try{if(L.isBatchDelete){const Lt=await dJ(Ve,_e,Pt=>re(Pt));return Lt.succeeded>0&&(Ie("app",`✅ Batch deleted ${Lt.succeeded} of ${_e.length} records`),Pe.current()),Lt}let Qe=0;const Ye=[];for(const Lt of _e)try{await nJ(Ve,Lt),Qe++}catch(Pt){Ye.push(`Failed to delete ${Lt}: ${zn(Pt)}`)}if(Qe>0&&(Ie("app",`✅ Deleted ${Qe} of ${_e.length} records`),Pe.current()),Ye.length>0)return console.error("Delete errors:",Ye),{succeeded:Qe,failed:Ye.length,errors:Ye}}finally{Le()}},[Ve,L.recordIds,L.isBatchDelete]),ft=A.useCallback(async _e=>{if(!Ve||!Ct)throw new Error("Missing entity information for bulk delete");if(ie.isAllRecords){if(!t.fetchQuery)throw new Error("No FetchXML query available");const Lt=ya(t.fetchQuery),Pt=await fJ(Lt,_e);return Ie("app",`📤 Bulk delete job (all records) submitted: ${Pt.asyncOperationId}`),Pt}if(ie.recordIds.length===0)throw new Error("No records selected for bulk delete");const Le=ie.recordIds,Qe=Ct.PrimaryIdAttribute,Ye=await iJ(Ve,Qe,Le,_e);return Ie("app",`📤 Bulk delete job submitted: ${Ye.asyncOperationId}`),Ye},[Ve,Ct,ie.recordIds,ie.isAllRecords,t.fetchQuery]),hr=A.useCallback((_e,Le)=>{Le.length!==0&&be({open:!0,recordIds:Le,preSelectedWorkflow:_e})},[]),ar=A.useCallback(async()=>Ve?sJ(Ve):[],[Ve]),er=A.useCallback(async(_e,Le,Qe)=>Ve?Qx(()=>cJ(_e,Le,Ve,Qe)):{succeeded:0,failed:Le.length,errors:["Entity not selected"]},[Ve]),Ht=A.useCallback((_e,Le)=>{!Ve||Le.length===0||te({open:!0,action:_e,recordIds:Le})},[Ve]),pr=A.useCallback(_e=>Ht("activate",_e),[Ht]),Br=A.useCallback(_e=>Ht("deactivate",_e),[Ht]),jr=A.useCallback(async(_e,Le)=>{if(!Ve)throw new Error("Entity not selected");const Qe=await Qx(()=>gJ(Ve,pe.recordIds,_e,Le));return Qe.succeeded>0&&(Ie("app",`✅ State changed on ${Qe.succeeded} of ${pe.recordIds.length} records`),Pe.current()),Qe},[Ve,pe.recordIds]),$r=fr?"The query has a one-to-many or many-to-many link-entity, so rows repeat. Remove it to activate or deactivate records.":void 0;return j.jsxs("div",{className:r.root,"data-app-root":!0,children:[j.jsxs("div",{className:r.leftPane,"data-left-pane":!0,style:{width:`${Ze}px`},children:[j.jsxs("div",{className:r.leftPaneTop,style:{height:`${Ee}%`},children:[j.jsx(Cie,{selectedEntity:t.fetchQuery?.entity.name||null,onEntityChange:t.setEntity,onNewQuery:t.newQuery,entityScopeMode:Re.entityScopeMode,advancedFindOnly:Re.advancedFindOnly,collapsed:Re.scopeCollapsed,onCollapsedChange:_e=>He({...Re,scopeCollapsed:_e}),onViewLoad:_e=>{const Le=t.loadView(_e.originalFetchXml,{id:_e.id,type:_e.type,entitySetName:_e.entitySetName,name:_e.name,queryType:_e.queryType,isCustomizable:_e.isCustomizable,description:_e.description,isDefault:_e.isDefault,isManaged:_e.isManaged,solutionId:_e.solutionId,ownerId:_e.ownerId,ownerName:_e.ownerName},_e.layoutxml);O("");const Qe=HQ(_e.name,Le);Qe&&(Le.success||console.error("Failed to parse view FetchXML:",Le.errors),window.toolboxAPI?.utils?.showNotification?.(Qe))}}),t.fetchQuery?j.jsx(Zie,{fetchQuery:t.fetchQuery,selectedNodeId:t.selectedNodeId,onNodeSelect:t.selectNode,onAddAttribute:t.addAttribute,onAddAllAttributes:t.addAllAttributes,onAddOrder:t.addOrder,onAddFilter:t.addFilter,onAddSubfilter:t.addSubfilter,onAddCondition:t.addCondition,onAddLinkEntity:t.addLinkEntity,onRemoveNode:t.removeNode,onUpdateAttributes:t.updateAttributes}):j.jsx("div",{className:r.placeholder,children:"Select an entity to begin"})]}),j.jsx("div",{className:r.horizontalResizeHandle,onMouseDown:()=>Ke(!0),title:"Drag to resize",children:j.jsxs("span",{className:r.horizontalGrip,children:[j.jsx("span",{children:"•"}),j.jsx("span",{children:"•"}),j.jsx("span",{children:"•"})]})})," ",j.jsxs("div",{className:r.leftPaneBottom,style:{height:`${100-Ee}%`},children:[j.jsx("div",{className:r.toolbar,children:j.jsx("span",{style:{fontWeight:600},children:"Properties"})}),j.jsx("div",{className:r.propertiesContent,children:j.jsx(xae,{selectedNode:t.selectedNode,fetchQuery:t.fetchQuery,onNodeUpdate:t.updateNode})})]})]}),j.jsx("div",{className:r.verticalResizeHandle,onMouseDown:()=>nt(!0),title:"Drag to resize",children:j.jsxs("span",{className:r.verticalGrip,children:[j.jsx("span",{children:"•"}),j.jsx("span",{children:"•"}),j.jsx("span",{children:"•"})]})})," ",j.jsx("div",{className:r.rightPane,children:j.jsx(mie,{xml:ct,layoutXml:Rt,result:a,isExecuting:h,isLoadingMore:f,onExecute:je,onExport:_r,onExportLocal:xt,canExport:!!t.loadedView&&_.hasPrivilege,isExporting:_.isExporting,exportError:_.error,onDismissExportError:()=>S(_e=>({..._e,error:void 0})),executeError:T,onDismissExecuteError:()=>z(void 0),exportDisabledReason:t.loadedView?_.hasPrivilege?void 0:"You don't have the prvExportToExcel privilege":"Save as a view first to enable export",onParseToTree:t.loadFetchXml,isCallee:i.isCallee,attributeMetadata:p,fetchQuery:t.fetchQuery,primaryIdAttribute:Ct?.PrimaryIdAttribute,columnConfig:t.columnConfig,onColumnResize:t.updateColumnWidth,onLoadMore:Tr,pagingNotice:E,isRetrieveAllInProgress:V?.isRetrieveAllInProgress??!1,onStopRetrieveAll:or,onRetryPaging:Sr,onDismissPagingNotice:()=>M(null),entityDisplayName:Ct?.DisplayName?.UserLocalizedLabel?.Label||Ct?.LogicalName,lookupRelationships:w,oneToManyRelationships:N,isLoadingRelationships:$,onLoadRelatedAttributes:n,quickFindTestValue:Ot>0?j.jsx(Zae,{value:P,onValueChange:O,addPercent:X,onAddPercentChange:K,searchValue:Ft,disabled:h}):void 0,executeDisabledReason:Ot>0&&!Ft?"Enter a quick find value to execute this query.":void 0,saveViewButton:j.jsx(Die,{fetchXml:ct,layoutXml:Rt,entityLogicalName:t.fetchQuery?.entity?.name||"",entityDisplayName:Ct?.DisplayName?.UserLocalizedLabel?.Label,objectTypeCode:Ct?.ObjectTypeCode||0,primaryIdAttribute:Ct?.PrimaryIdAttribute||"",loadedView:t.loadedView,onSaveComplete:ur,disabled:!ct||!Ct}),sendToToolButton:b_()&&c.length>0?j.jsx(Oie,{fetchXml:ct,entityLogicalName:t.fetchQuery?.entity?.name||"",tools:c,disabled:!ct||!t.fetchQuery?.entity?.name}):void 0,onReorderColumns:_e=>{t.columnConfig&&t.setColumnConfig({...t.columnConfig,columns:_e})},onRemoveColumns:_e=>{if(!t.fetchQuery)return;mre(t.fetchQuery,_e).removeNodeIds.forEach(Qe=>t.removeNode(Qe))},onAddColumn:_e=>{t.fetchQuery?.entity.id&&t.addAttributeByName(t.fetchQuery.entity.id,_e)},onAddRelatedColumns:_e=>{if(!t.fetchQuery?.entity.id)return;const Le=new Map;for(const Qe of _e){const Ye=vi(Qe.relationship);Le.has(Ye)||Le.set(Ye,[]),Le.get(Ye).push(Qe)}for(const[,Qe]of Le){const Ye=Qe[0].relationship,Lt=Qe[0].relationshipType;let Pt,br,dr,sr,Ur;Lt==="N1"?(Pt=Ye.ReferencedAttribute,br=Ye.ReferencingAttribute,dr=Ye.ReferencedEntity,sr="outer",Ur="N1"):(Pt=Ye.ReferencingAttribute,br=Ye.ReferencedAttribute,dr=Ye.ReferencingEntity,sr="outer",Ur="1N");const Pn=t.fetchQuery.entity.links.find(It=>It.from===Pt&&It.to===br&&It.name===dr&&!cl.has(It.linkType));let Dr;Pn?Dr=Pn.id:Dr=t.addLinkEntityWithConfig(t.fetchQuery.entity.id,dr,Pt,br,sr,Ur);for(const It of Qe)t.addAttributeByName(Dr,It.attribute.LogicalName)}},columnFilters:fe,onAddColumnFilter:gt,onRemoveColumnFilters:bt,onSortChange:_e=>{if(!t.fetchQuery)return;const Le=vd(t.fetchQuery,_e.columnId),Qe=Le?p?.get(Le.container.name)?.get(Le.attribute.name):void 0,Ye=gre(t.fetchQuery,_e.columnId,Qe?I8(Qe):void 0);if("reason"in Ye){window.toolboxAPI?.utils?.showNotification?.({title:"Can't sort by this column",body:Ye.reason,type:"warning"});return}t.setSort(Ye,_e.direction==="descending",_e.isMultiSort)},onOpenRecord:we,onCopyRecordUrl:qe,onDeleteRecords:Xe,onBulkDeleteRecords:kt,onActivateRecords:pr,onDeactivateRecords:Br,activateDisabledReason:se.activate??$r,deactivateDisabledReason:se.deactivate??$r,onRunSpecificWorkflow:hr,canDelete:H.canDelete,canBulkDelete:H.canBulkDelete,canRunWorkflow:H.canRunWorkflow,onFetchWorkflows:ar,isAggregateQuery:vr,hasOneToManyRelationship:fr,recordActionsDisabledReason:gr,onSelectionChange:qt,getSelectedRecordIds:ce,onOpenSettings:()=>Be(!0),displaySettings:Re})}),j.jsx(Mae,{open:L.open,recordName:L.recordName,entityDisplayName:Ct?.DisplayName?.UserLocalizedLabel?.Label||Ve||"record",entityLogicalName:Ve,recordCount:L.recordIds.length,onClose:()=>{q({open:!1,recordIds:[]}),re(null)},onConfirm:ot,onProgress:Y??void 0}),j.jsx(Pae,{open:ie.open,recordCount:ie.recordIds.length,entityDisplayName:Ct?.DisplayName?.UserLocalizedLabel?.Label||Ve||"records",entityLogicalName:Ve,isAllRecords:ie.isAllRecords,totalViewRecords:ie.totalViewRecords,moreRecords:a?.moreRecords,onClose:()=>ne({open:!1,recordIds:[]}),onConfirm:ft}),j.jsx(Fae,{open:ae.open,recordCount:ae.recordIds.length,entityDisplayName:Ct?.DisplayName?.UserLocalizedLabel?.Label||Ve||"records",entityLogicalName:Ve,preSelectedWorkflow:ae.preSelectedWorkflow,onClose:()=>be({open:!1,recordIds:[]}),onFetchWorkflows:ar,onExecute:(_e,Le)=>er(_e.workflowid,ae.recordIds,Le)}),j.jsx(Lae,{open:pe.open,action:pe.action,recordIds:pe.recordIds,entityLogicalName:Ve,entityDisplayName:Ct?.DisplayName?.UserLocalizedLabel?.Label,primaryIdAttribute:Ct?.PrimaryIdAttribute,onClose:()=>te(_e=>({..._e,open:!1})),onExecute:jr}),j.jsx(ese,{open:xe,settings:Re,accessSummary:Te,onClose:()=>Be(!1),onSettingsChange:He})]})}self.MonacoEnvironment={getWorker(e,r){throw new Error(`FXS runs Monaco's "${r}" worker on the main thread.`)}};Zv.config({monaco:dC});xC.createRoot(document.getElementById("root")).render(j.jsx(A.StrictMode,{children:j.jsx(ise,{})}));
|
|
108
|
+
`,s.NAME_START_CHAR=":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-",s.NAME_CHAR="-"+s.NAME_START_CHAR+".0-9·̀-ͯ‿-⁀",s.CHAR_RE=new RegExp("^["+s.CHAR+"]$","u"),s.RESTRICTED_CHAR_RE=new RegExp("^["+s.RESTRICTED_CHAR+"]$","u"),s.S_RE=new RegExp("^["+s.S+"]+$","u"),s.NAME_START_CHAR_RE=new RegExp("^["+s.NAME_START_CHAR+"]$","u"),s.NAME_CHAR_RE=new RegExp("^["+s.NAME_CHAR+"]$","u"),s.NAME_RE=new RegExp("^["+s.NAME_START_CHAR+"]["+s.NAME_CHAR+"]*$","u"),s.NMTOKEN_RE=new RegExp("^["+s.NAME_CHAR+"]+$","u");function o(i){return i>=65&&i<=90||i>=97&&i<=122||i===58||i===95||i===8204||i===8205||i>=192&&i<=214||i>=216&&i<=246||i>=248&&i<=767||i>=880&&i<=893||i>=895&&i<=8191||i>=8304&&i<=8591||i>=11264&&i<=12271||i>=12289&&i<=55295||i>=63744&&i<=64975||i>=65008&&i<=65533||i>=65536&&i<=983039}s.S_LIST=[32,10,13,9],s.isChar=function(i){return i>=1&&i<=55295||i>=57344&&i<=65533||i>=65536&&i<=1114111},s.isRestrictedChar=function(i){return i>=1&&i<=8||i===11||i===12||i>=14&&i<=31||i>=127&&i<=132||i>=134&&i<=159},s.isCharAndNotRestricted=function(i){return i===9||i===10||i===13||i>31&&i<127||i===133||i>159&&i<=55295||i>=57344&&i<=65533||i>=65536&&i<=1114111},s.isS=function(i){return i===32||i===10||i===13||i===9},s.isNameStartChar=o,s.isNameChar=function(i){return o(i)||i>=48&&i<=57||i===45||i===46||i===183||i>=768&&i<=879||i>=8255&&i<=8256}},{}],545:[function(t,n,s){function o(i){return i>=65&&i<=90||i===95||i>=97&&i<=122||i>=192&&i<=214||i>=216&&i<=246||i>=248&&i<=767||i>=880&&i<=893||i>=895&&i<=8191||i>=8204&&i<=8205||i>=8304&&i<=8591||i>=11264&&i<=12271||i>=12289&&i<=55295||i>=63744&&i<=64975||i>=65008&&i<=65533||i>=65536&&i<=983039}Object.defineProperty(s,"__esModule",{value:!0}),s.NC_NAME_START_CHAR="A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ--⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-",s.NC_NAME_CHAR="-"+s.NC_NAME_START_CHAR+".0-9·̀-ͯ‿-⁀",s.NC_NAME_START_CHAR_RE=new RegExp("^["+s.NC_NAME_START_CHAR+"]$","u"),s.NC_NAME_CHAR_RE=new RegExp("^["+s.NC_NAME_CHAR+"]$","u"),s.NC_NAME_RE=new RegExp("^["+s.NC_NAME_START_CHAR+"]["+s.NC_NAME_CHAR+"]*$","u"),s.isNCNameStartChar=o,s.isNCNameChar=function(i){return o(i)||i===45||i===46||i>=48&&i<=57||i===183||i>=768&&i<=879||i>=8255&&i<=8256}},{}]},{},[15])(15)}))})(p0)),p0.exports}var Wae=Vae();const Uae=jb(Wae);async function Xae(e){const{records:r,columns:t,columnDisplayNames:n,attributeMetadata:s,entityName:o,fileName:i="export",displaySettings:c}=e,l=c?.useLogicalNames??!1,a=c?.valueDisplayMode??"formatted",u=new Uae.Workbook;u.creator="FetchXML Studio",u.created=new Date;const h=u.addWorksheet("Data"),d=C=>{if(s){if(o){const N=s.get(o);if(N){if(N.has(C))return N.get(C);if(C.startsWith("_")&&C.endsWith("_value")){const I=C.slice(1,-6);if(N.has(I))return N.get(I)}}}for(const[,N]of s){if(N.has(C))return N.get(C);if(C.startsWith("_")&&C.endsWith("_value")){const I=C.slice(1,-6);if(N.has(I))return N.get(I)}}}},f=C=>r.some(N=>{const I=N[C],$=Xi(N,C);return $!==void 0&&$!==I}),m=[];for(const C of t){const N=n.get(C)||C,I=l?C:N;a==="both"&&f(C)?(m.push({sourceCol:C,headerName:I,isRawColumn:!1}),m.push({sourceCol:C,headerName:`${I} (Raw)`,isRawColumn:!0})):m.push({sourceCol:C,headerName:I,isRawColumn:!1})}const p=h.addRow(m.map(C=>C.headerName));p.font={bold:!0},p.fill={type:"pattern",pattern:"solid",fgColor:{argb:"FFE0E0E0"}},h.columns=m.map((C,N)=>{const I=d(C.sourceCol);let $=Math.max(C.headerName.length+2,10);switch(I?.AttributeType){case"DateTime":$=Math.max($,18);break;case"Money":case"Decimal":case"Double":$=Math.max($,14);break;case"Lookup":case"Customer":case"Owner":$=Math.max($,25);break;case"Memo":$=Math.max($,40);break}return{key:`col_${N}`,width:$}});const g=(C,N,I,$)=>{const D=C[N],F=Xi(C,N);if(D==null)return"";if(I||a==="raw")switch($?.AttributeType){case"Integer":case"BigInt":return typeof D=="number"?D:parseInt(String(D),10);case"Decimal":case"Double":case"Money":return typeof D=="number"?D:parseFloat(String(D));case"DateTime":if(D instanceof Date)return D;if(typeof D=="string"){const V=new Date(D);return isNaN(V.getTime())?D:V}return D;case"Boolean":return D;default:return D}switch($?.AttributeType){case"Boolean":return F||(D?"Yes":"No");case"Integer":case"BigInt":return typeof D=="number"?D:parseInt(String(D),10);case"Decimal":case"Double":case"Money":return typeof D=="number"?D:parseFloat(String(D));case"DateTime":if(D instanceof Date)return D;if(typeof D=="string"){const V=new Date(D);return isNaN(V.getTime())?D:V}return D;case"Picklist":case"State":case"Status":return F||D;case"Lookup":case"Customer":case"Owner":return F||D;default:return F!==void 0&&F!==D?F:String(D)}};for(const C of r){const N=m.map($=>{const D=d($.sourceCol);return g(C,$.sourceCol,$.isRawColumn,D)}),I=h.addRow(N);m.forEach(($,D)=>{const F=d($.sourceCol),V=I.getCell(D+1);if(!$.isRawColumn)switch(F?.AttributeType){case"DateTime":V.numFmt="yyyy-mm-dd hh:mm:ss";break;case"Money":V.numFmt='"$"#,##0.00';break;case"Decimal":case"Double":{const G=F?.Precision??2;V.numFmt=`0.${"0".repeat(G)}`;break}case"Integer":case"BigInt":V.numFmt="#,##0";break}})}h.views=[{state:"frozen",ySplit:1}],m.length>0&&(h.autoFilter={from:{row:1,column:1},to:{row:r.length+1,column:m.length}});const b=await u.xlsx.writeBuffer(),y=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),w=`${i}_${y}.xlsx`;return{buffer:b,fileName:w}}async function Gae(e,r){if(window.toolboxAPI?.fileSystem?.saveFile){const o=await window.toolboxAPI.fileSystem.saveFile(r,new Uint8Array(e));o&&Ie("exportAPI",`✅ File saved via fileSystem: ${o}`);return}const t=new Blob([e],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),n=URL.createObjectURL(t),s=document.createElement("a");s.href=n,s.download=r,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(n)}const Kae=100,Yae=3;function Qae(e){if(e.mode!=="fetchxml")return;const r=e.pageSize??e.fullPageSize;if(!r||!Number.isInteger(r)||r%2!==0)return;const t=r/2;if(t<Kae)return;const n=e.pagingCookie?e.nextPage:2*(e.nextPage-1)+1;return{...e,pageSize:t,nextPage:n}}async function Zae(e,r,{retry:t,maxHalvings:n=Yae,onShrink:s}={}){let o=e;for(let i=0;;i++)try{return{result:await pd(()=>r(o),t),state:o}}catch(c){const l=i<n&&HY(c)?Qae(o):void 0;if(!l)throw c;s?.(l),o=l}}const Jae=wr({panel:{display:"flex",flexDirection:"column",gap:"8px",padding:"10px 12px",backgroundColor:le.colorNeutralBackground3,borderRadius:le.borderRadiusMedium},input:{maxWidth:"360px"},code:{fontFamily:le.fontFamilyMonospace}});function ese({value:e,onValueChange:r,addPercent:t,onAddPercentChange:n,searchValue:s,disabled:o}){const i=Jae(),c=j.jsx("span",{className:i.code,children:"{0}"}),l=!e.trim();return j.jsxs("div",{className:i.panel,children:[j.jsx(Eo,{label:"Quick find value",hint:j.jsxs(j.Fragment,{children:["Replaces ",c," when you execute. The query keeps ",c,", so saving and copying are unchanged."]}),validationState:l?"warning":"none",validationMessage:l?"Enter a value to execute this quick find view.":void 0,children:j.jsx(_n,{className:i.input,value:e,onChange:(a,u)=>r(u.value),placeholder:"e.g. contoso",disabled:o})}),j.jsx(ho,{label:"Add % at the end",checked:t,disabled:o,onChange:(a,u)=>n(u.checked===!0)}),s&&j.jsxs(st,{size:200,children:["Runs with ",j.jsxs("span",{className:i.code,children:['value="',s,'"']})," in each ",c," condition."]})]})}const tse=wr({drawer:{width:"360px"},section:{marginBottom:le.spacingVerticalL},sectionTitle:{fontSize:le.fontSizeBase400,fontWeight:le.fontWeightSemibold,marginBottom:le.spacingVerticalM,display:"flex",alignItems:"center",gap:le.spacingHorizontalS},settingItem:{display:"flex",flexDirection:"column",gap:le.spacingVerticalXS,marginBottom:le.spacingVerticalM},settingRow:{display:"flex",justifyContent:"space-between",alignItems:"center"},settingLabel:{fontWeight:le.fontWeightSemibold,display:"flex",alignItems:"center",gap:le.spacingHorizontalXS},settingDescription:{fontSize:le.fontSizeBase200,color:le.colorNeutralForeground3},dropdown:{minWidth:"160px"},radioGroup:{display:"flex",flexDirection:"column",gap:le.spacingVerticalXS,marginTop:le.spacingVerticalXS},disabledHint:{fontSize:le.fontSizeBase100,color:le.colorNeutralForegroundDisabled,fontStyle:"italic"}});function rse({open:e,settings:r,onClose:t,onSettingsChange:n,accessSummary:s}){const o=tse(),i=A.useCallback(d=>{n({...r,useLogicalNames:d})},[r,n]),c=A.useCallback(d=>{n({...r,valueDisplayMode:d})},[r,n]),l=A.useCallback(d=>{n({...r,entityScopeMode:d})},[r,n]),a=A.useCallback(d=>{n({...r,advancedFindOnly:d})},[r,n]),u=!s||s.fullFilterMode,h=!s||s.fullFilterMode||s.solutionsOnlyMode;return j.jsxs(mp,{open:e,onOpenChange:(d,f)=>!f.open&&t(),position:"end",size:"small",className:o.drawer,children:[j.jsx(bp,{children:j.jsxs(vp,{action:j.jsx(St,{appearance:"subtle","aria-label":"Close",icon:j.jsx(np,{}),onClick:t}),children:[j.jsx(v4,{style:{marginRight:le.spacingHorizontalS}}),"Settings"]})}),j.jsxs(gp,{children:[j.jsxs("div",{className:o.section,children:[j.jsx(st,{className:o.sectionTitle,children:"Query scope"}),j.jsxs("div",{className:o.settingItem,children:[j.jsxs(st,{className:o.settingLabel,children:["Entity source",j.jsx(Or,{content:"Controls how the entity list is populated in the toolbar. Scoped modes are faster; 'All entities' loads every entity in the environment.",relationship:"description",children:j.jsx(A0,{style:{color:le.colorNeutralForeground3}})})]}),j.jsx(st,{className:o.settingDescription,block:!0,children:"How to scope the entity picker"}),j.jsxs(ta,{className:o.radioGroup,value:r.entityScopeMode,onChange:(d,f)=>l(f.value),children:[j.jsx(Or,{content:u?"":"Requires prvReadPublisher + prvReadSolution",relationship:"description",positioning:"before",children:j.jsx(Yr,{value:"publisher-solution",label:"Publisher → Solution (default)",disabled:!u})}),j.jsx(Or,{content:h?"":"Requires prvReadSolution",relationship:"description",positioning:"before",children:j.jsx(Yr,{value:"solution-only",label:"Solution only",disabled:!h})}),j.jsx(Yr,{value:"all",label:"All entities"})]})]}),j.jsx(Sh,{style:{marginBottom:le.spacingVerticalM}}),j.jsx("div",{className:o.settingItem,children:j.jsxs("div",{className:o.settingRow,children:[j.jsxs("div",{children:[j.jsxs(st,{className:o.settingLabel,children:["Advanced Find only",j.jsx(Or,{content:"When on, entities, attributes and relationships are limited to the ones Advanced Find shows (IsValidForAdvancedFind). Turn off to build queries Advanced Find can't: system and customization entities, intersect entities, and hidden attributes and relationships. Attributes that can't be read (IsValidForRead = false) are never listed.",relationship:"description",children:j.jsx(A0,{style:{color:le.colorNeutralForeground3}})})]}),j.jsx(st,{className:o.settingDescription,block:!0,children:"Limit entities, attributes & relationships to the ones Advanced Find shows"}),!r.advancedFindOnly&&j.jsx(st,{className:o.disabledHint,block:!0,children:"All entities, attributes and relationships are shown. A few system entities can't be queried; Dataverse returns an error for those."})]}),j.jsx(Qs,{checked:r.advancedFindOnly,onChange:(d,f)=>a(f.checked)})]})})]}),j.jsx(Sh,{}),j.jsxs("div",{className:o.section,style:{marginTop:le.spacingVerticalL},children:[j.jsx(st,{className:o.sectionTitle,children:"Display"}),j.jsx("div",{className:o.settingItem,children:j.jsxs("div",{className:o.settingRow,children:[j.jsxs("div",{children:[j.jsx(st,{className:o.settingLabel,children:"Use logical names"}),j.jsx(st,{className:o.settingDescription,block:!0,children:"Show attribute logical names in column headers instead of display names"})]}),j.jsx(Qs,{checked:r.useLogicalNames,onChange:(d,f)=>i(f.checked)})]})}),j.jsxs("div",{className:o.settingItem,children:[j.jsx(st,{className:o.settingLabel,children:"Value display mode"}),j.jsx(st,{className:o.settingDescription,block:!0,children:"How to display cell values in the results grid"}),j.jsxs(po,{className:o.dropdown,value:r.valueDisplayMode==="formatted"?"Formatted":r.valueDisplayMode==="raw"?"Raw":"Both",selectedOptions:[r.valueDisplayMode],onOptionSelect:(d,f)=>c(f.optionValue),children:[j.jsx(Jt,{value:"formatted",children:"Formatted"}),j.jsx(Jt,{value:"raw",children:"Raw"}),j.jsx(Jt,{value:"both",children:"Both (2 columns per attribute)"})]})]})]})]})]})}const Bb={useLogicalNames:!1,valueDisplayMode:"formatted",entityScopeMode:"publisher-solution",advancedFindOnly:!0,scopeCollapsed:!1},yk="fetchxml-studio:displaySettings";function nse(e){return!e||typeof e!="object"?{...Bb}:{...Bb,...e}}function ose(){const[e,r]=A.useState(Bb),t=A.useRef(!1);A.useEffect(()=>{let s=!0;async function o(){try{if(typeof window<"u"&&window.toolboxAPI?.settings?.get){const i=await window.toolboxAPI.settings.get(yk);if(s){const c=nse(i);r(c),Ie("settings","⚙️ Settings loaded from toolboxAPI:",c)}}else Ie("settings","⚙️ toolboxAPI.settings not available — using in-memory defaults")}catch(i){console.warn("⚙️ Failed to load settings from toolboxAPI:",i)}finally{s&&(t.current=!0)}}return o(),()=>{s=!1}},[]);const n=A.useCallback(s=>{r(s),t.current&&typeof window<"u"&&window.toolboxAPI?.settings?.set&&window.toolboxAPI.settings.set(yk,s).then(()=>{Ie("settings","⚙️ Settings saved to toolboxAPI:",s)}).catch(o=>{console.warn("⚙️ Failed to save settings to toolboxAPI:",o)})},[]);return[e,n]}const ise="Dataverse didn't return a paging cookie for this query (for example, it's sorted by a link-entity attribute or uses distinct), so pages are fetched with page numbers only. Microsoft recommends paging cookies; this works, but is slower for large result sets.",ase=wr({root:{backgroundColor:le.colorNeutralBackground1,color:le.colorNeutralForeground1,display:"flex",flexDirection:"row",height:"100%",width:"100%",overflow:"hidden",position:"absolute",top:0,left:0,right:0,bottom:0},leftPane:{display:"flex",flexDirection:"column",overflow:"hidden",minWidth:"300px",maxWidth:"800px",height:"100%"},leftPaneTop:{display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},horizontalResizeHandle:{height:"6px",cursor:"ns-resize",backgroundColor:le.colorNeutralBackground3,display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0,":hover":{backgroundColor:le.colorNeutralBackground3Hover},":active":{backgroundColor:le.colorBrandBackgroundPressed}},horizontalGrip:{fontSize:"10px",color:le.colorNeutralForeground3,userSelect:"none",pointerEvents:"none",display:"flex",gap:"3px",alignItems:"center"},verticalResizeHandle:{width:"6px",cursor:"ew-resize",backgroundColor:le.colorNeutralBackground3,display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0,":hover":{backgroundColor:le.colorNeutralBackground3Hover},":active":{backgroundColor:le.colorBrandBackgroundPressed}},verticalGrip:{fontSize:"10px",color:le.colorNeutralForeground3,userSelect:"none",pointerEvents:"none",display:"flex",flexDirection:"column",gap:"2px",lineHeight:"0.5"},leftPaneBottom:{display:"flex",flexDirection:"column",minHeight:"100px",overflow:"hidden",minWidth:0},propertiesContent:{flex:1,overflow:"hidden"},rightPane:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},toolbar:{padding:"12px 16px",borderTop:`1px solid ${le.colorNeutralStroke1}`,borderBottom:`1px solid ${le.colorNeutralStroke1}`,display:"flex",gap:"8px",alignItems:"center",flexShrink:0},placeholder:{padding:"16px",color:le.colorNeutralForeground3,display:"flex",alignItems:"center",justifyContent:"center",height:"100%"}});function sse(){const{theme:e,connectionKey:r,connectionName:t}=N8(),n=e==="dark";A.useEffect(()=>{document.documentElement.style.colorScheme=n?"dark":"light"},[n]);const s=A.useRef({prefillConsumed:!1}),[o,i]=A.useState({key:void 0,session:0}),c=yY(o,r);c.scope!==o&&(c.changed&&(Zt.clear(),KY(),s.current.fetchXml=s.current.readFetchXml?.()),i(c.scope));const l=o.session;return A.useEffect(()=>{l!==0&&window.toolboxAPI?.utils?.showNotification?.({title:"Connection changed",body:t?`FetchXML Studio reloaded its metadata for ${t}. Results and the loaded view were cleared.`:"FetchXML Studio has no connection now. Results and the loaded view were cleared.",type:"info"})},[l]),j.jsx(r4,{theme:n?ZE:KE,children:j.jsx(Mae,{isDark:n,children:j.jsx(Iae,{children:j.jsx(lse,{carryOver:s.current})},l)})})}function lse({carryOver:e}){const r=ase(),t=wd(),{loadAttributes:n,loadEntityMetadata:s,loadRelationships:o}=g_(),i=Lie(),{tools:c}=$ie();A.useEffect(()=>{const _e=e.fetchXml;if(!_e)return;e.fetchXml=void 0;const Le=t.loadFetchXml(_e);Le.success||console.error("Connection change: couldn't reload the query:",Le.errors)},[]);const l=t.fetchQuery;A.useEffect(()=>{e.readFetchXml=()=>l?ya(l):void 0},[e,l]),A.useEffect(()=>{i.loading||e.prefillConsumed||(e.prefillConsumed=!0,i.context&&(async()=>{try{const _e=await EJ(i.context);if(!_e)return;if(_e.kind==="entity"){t.setEntity(_e.entityLogicalName);return}const Le=t.loadFetchXml(_e.fetchXml);Le.success||(console.error("T2T prefill: failed to parse incoming FetchXML:",Le.errors),await window.toolboxAPI?.utils?.showNotification?.({title:"Could not load incoming query",body:"The tool that launched FetchXML Studio sent a query that couldn't be parsed.",type:"error"}))}catch(_e){console.error("T2T prefill: failed to load launch context:",_e)}})())},[i.loading,i.context]);const[a,u]=A.useState(null),[h,d]=A.useState(!1),[f,m]=A.useState(!1),[p,g]=A.useState(new Map),[b,y]=A.useState(null),[w,C]=A.useState([]),[N,I]=A.useState([]),[$,D]=A.useState(!1),F=A.useRef(null),[V,G]=A.useState(null),U=_e=>{F.current=_e,G(_e)},[E,M]=A.useState(null),B=A.useRef(0),k=A.useRef(0);A.useEffect(()=>()=>{B.current++,k.current++},[]);const[_,S]=A.useState({isExporting:!1,hasPrivilege:!1,privilegeChecked:!1}),[T,z]=A.useState(),[P,O]=A.useState(""),[X,K]=A.useState(!0),J=A.useRef(void 0),[H,Z]=A.useState({canDelete:!1,canBulkDelete:!1,canRunWorkflow:!1,privilegesChecked:!1}),[L,q]=A.useState({open:!1,recordIds:[]}),[Y,re]=A.useState(null),[ie,ne]=A.useState({open:!1,recordIds:[]}),[ae,be]=A.useState({open:!1,recordIds:[]}),[pe,te]=A.useState({open:!1,action:"activate",recordIds:[]}),[se,ue]=A.useState({}),[he,me]=A.useState([]),[xe,Be]=A.useState(!1),[Re,He]=ose();A.useLayoutEffect(()=>{Zu.setAdvancedFindOnly(Re.advancedFindOnly)},[Re.advancedFindOnly]);const Je=Sp(),{accessSummary:Te}=_7(),[Ee,$e]=A.useState(58),[Ze,yt]=A.useState(480),[dt,Ke]=A.useState(!1),[We,nt]=A.useState(!1);A.useEffect(()=>{if(!dt)return;const _e=Qe=>{const Ye=document.querySelector("[data-left-pane]");if(!Ye)return;const Lt=Ye.getBoundingClientRect(),Pt=(Qe.clientY-Lt.top)/Lt.height*100;Pt>=30&&Pt<=80&&$e(Pt)},Le=()=>{Ke(!1)};return document.addEventListener("mousemove",_e),document.addEventListener("mouseup",Le),()=>{document.removeEventListener("mousemove",_e),document.removeEventListener("mouseup",Le)}},[dt]),A.useEffect(()=>{if(!We)return;const _e=Qe=>{const Ye=document.querySelector("[data-app-root]");if(!Ye)return;const Lt=Ye.getBoundingClientRect(),Pt=Qe.clientX-Lt.left;Pt>=300&&Pt<=800&&yt(Pt)},Le=()=>{nt(!1)};return document.addEventListener("mousemove",_e),document.addEventListener("mouseup",Le),()=>{document.removeEventListener("mousemove",_e),document.removeEventListener("mouseup",Le)}},[We]),A.useEffect(()=>{if(!ir()){console.error("❌ Dataverse API not available on window object");return}oi().then(_e=>{_e?Ie("app","WhoAmI succeeded",{UserId:_e.UserId}):Ie("app","WhoAmI returned null - API may not be fully initialized")}).catch(_e=>{console.error("❌ WhoAmI Error:",_e)})},[]),A.useEffect(()=>{const _e=async()=>{try{const Le=await oi();if(Le){const Qe=await ni(Le.UserId,"prvExportToExcel");S(Ye=>({...Ye,hasPrivilege:Qe,privilegeChecked:!0})),Ie("app",`📊 Export to Excel privilege: ${Qe?"GRANTED":"DENIED"}`)}else S(Qe=>({...Qe,hasPrivilege:!1,privilegeChecked:!0}))}catch(Le){console.error("Failed to check export privilege:",Le),S(Qe=>({...Qe,hasPrivilege:!1,privilegeChecked:!0}))}};ir()&&_e()},[]);const Ve=t.fetchQuery?.entity.name;A.useEffect(()=>{if(!Ve||!ir()){Z({canDelete:!1,canBulkDelete:!1,canRunWorkflow:!1,privilegesChecked:!1});return}(async()=>{try{const Le=await uJ(Ve),Qe=await oJ(),Ye=await aJ();Z({canDelete:Le,canBulkDelete:Qe,canRunWorkflow:Ye,privilegesChecked:!0}),Ie("app",`🔐 Record action privileges for ${Ve}:`,{canDelete:Le,canBulkDelete:Qe,canRunWorkflow:Ye})}catch(Le){console.error("Failed to check record action privileges:",Le),Z({canDelete:!1,canBulkDelete:!1,canRunWorkflow:!1,privilegesChecked:!0})}})()},[Ve]),A.useEffect(()=>{const _e=WQ(Ve);if(!Ve||_e||!ir()){ue(_e?{activate:_e,deactivate:_e}:{});return}let Le=!0;return ue({}),(async()=>{const[Qe,Ye]=await Promise.all([f_(Ve).catch(Pt=>{console.warn("Activate/Deactivate: couldn't read the state model:",Pt)}),pJ(Ve)]);if(!Le)return;const Lt=Ye===!1?"You don't have the Write privilege on this entity, so you can't change its records' status.":void 0;ue({activate:(Qe!==void 0?f5(Qe,"activate"):void 0)??Lt,deactivate:(Qe!==void 0?f5(Qe,"deactivate"):void 0)??Lt})})(),()=>{Le=!1}},[Ve]);const wt=A.useMemo(()=>QY(t.fetchQuery),[t.fetchQuery]),Wt=wt.rootEntityName,Ct=b&&b.LogicalName===Wt?b:null;A.useEffect(()=>{const{rootEntityName:_e,entityNames:Le}=wt;if(!_e){g(new Map),y(null);return}let Qe=!1;return Promise.all(Le.map(async Ye=>{try{const Lt=await jc(Ye),Pt=new Map;return Lt.forEach(br=>{Pt.set(br.LogicalName,br)}),{entityName:Ye,attrMap:Pt}}catch(Lt){return console.error(`Failed to load attributes for ${Ye}:`,Lt),{entityName:Ye,attrMap:new Map}}})).then(Ye=>{if(Qe)return;const Lt=new Map;Ye.forEach(({entityName:Pt,attrMap:br})=>{Lt.set(Pt,br)}),g(Lt)}),s(_e).then(Ye=>{Qe||y(Ye)}).catch(Ye=>{console.error("Failed to load entity metadata:",Ye),Qe||y(null)}),D(!0),o(_e).then(Ye=>{Qe||(C(Ye.manyToOne),I(Ye.oneToMany))}).catch(Ye=>{console.error("Failed to load relationships:",Ye),!Qe&&(C([]),I([]))}).finally(()=>{Qe||D(!1)}),()=>{Qe=!0}},[wt.key,s,o,Je]),A.useEffect(()=>{const _e=t.fetchQuery?.entity?.id;_e!==void 0&&_e===J.current||(B.current++,k.current++,u(null),U(null),M(null),m(!1),d(!1))},[t.fetchQuery?.entity?.id]);const{syncLayoutWithFetchXml:Tt}=t;A.useEffect(()=>{const _e=(t.fetchQuery?.entity?.attributes?.length??0)>0;if((t.layoutNeedsSync||_e&&!t.columnConfig)&&t.fetchQuery){const Qe=new Map,Ye=t.fetchQuery.entity?.name;p&&Ye&&p.get(Ye)?.forEach((Pt,br)=>{Qe.set(br,Pt.AttributeType||"")}),Tt(Qe,Ct?.PrimaryIdAttribute)}},[t.layoutNeedsSync,t.fetchQuery,t.columnConfig,p,Ct,Tt]);const ct=t.fetchQuery?ya(t.fetchQuery):"",Ot=A.useMemo(()=>sb(ct),[ct]),Ft=OQ(P,X),vr=t.fetchQuery?.options?.aggregate===!0,fr=A.useMemo(()=>{if(!t.fetchQuery?.entity?.links)return!1;const _e=Le=>{for(const Qe of Le)if(Qe.relationshipType==="1N"||Qe.relationshipType==="NN"||Qe.links&&_e(Qe.links))return!0;return!1};return _e(t.fetchQuery.entity.links)},[t.fetchQuery]),zt=Ct?.PrimaryIdAttribute,tr=t.fetchQuery?.options?.distinct===!0,gr=A.useMemo(()=>{const _e=a?.rows;if(!(!_e||_e.length===0||!zt)&&!_e.some(Le=>typeof Le[zt]=="string"))return vr?"Aggregate query results don't contain record IDs, so record actions aren't available.":tr?"Distinct query results don't contain record IDs (Dataverse doesn't return the primary key for distinct queries), so record actions aren't available.":"These results don't include the table's primary key, so record actions aren't available."},[a,zt,vr,tr]),Rt=A.useMemo(()=>!t.fetchQuery||!Ct?"":jae(t.columnConfig,t.fetchQuery,{objectTypeCode:Ct.ObjectTypeCode,primaryIdAttribute:Ct.PrimaryIdAttribute,primaryNameAttribute:Ct.PrimaryNameAttribute}),[t.columnConfig,t.fetchQuery,Ct]),ur=(_e,Le,Qe,Ye)=>{if(Ct&&t.fetchQuery){const Lt=t.loadedView?.id===_e?t.loadedView:null;t.setLoadedView({id:_e,type:Le,entitySetName:Ct.EntitySetName,name:Qe,originalFetchXml:ya(t.fetchQuery),queryType:Lt?Lt.queryType:0,isCustomizable:Lt?.isCustomizable,description:Ye.description,isDefault:Ye.isDefault,isManaged:Lt?.isManaged,solutionId:Lt?.solutionId,ownerId:Lt?.ownerId,ownerName:Lt?.ownerName})}Ie("app",`✅ View saved: ${Qe} (${Le}) - ${_e}`)},je=async _e=>{const Le=_e?.fetchQuery??t.fetchQuery,Qe=_e?.xml??ct;if(!Qe)return;const Ye=sb(Qe)>0;if(Ye&&!Ft)return;const Lt=Ye?FQ(Qe,Ft):Qe,Pt=++B.current;k.current++,d(!0),m(!1),u(null),U(null),M(null),z(void 0),J.current=Le?.entity.id;const br=performance.now(),dr=Le?.entity.name,sr=t.retrieveAllRecords,Ur=AY(Lt),Pn=Ur.top!==void 0;try{let Dr;const It=_e?null:t.loadedView;let On=!1;if(It&&!Ye&&zQ(Lt,It.originalFetchXml)&&(On=!0,Ie("app",`📋 Executing ${It.type} view "${It.name}" via ${It.type==="system"?"savedQuery":"userQuery"}=${It.id}`),It.type==="system"?Dr=await EZ(It.entitySetName,It.id):Dr=await AZ(It.entitySetName,It.id)),Dr||(Ie("app",_e?"✏️ Executing editor FetchXML (loaded into the tree)":Ye?"🔎 Executing quick find FetchXML with the test value":It?`📝 View "${It.name}" was modified - executing its FetchXML`:"📡 Executing FetchXML query"),Dr=await v5(Lt)),Pt!==B.current)return;const go=Math.round(performance.now()-br),Gn=!Pn&&E8(On?"view":"fetchxml",Dr),Di=Ur.page??1;u({query:Le,rows:Dr.records.map(si=>({...si})),totalRecordCount:Dr.totalRecordCount,totalRecordCountLimitExceeded:Dr.totalRecordCountLimitExceeded,moreRecords:Gn,pagingCookie:Dr.pagingCookie,entityLogicalName:dr,executionTimeMs:go}),U({mode:On?"view":"fetchxml",xml:Lt,pageSize:Ur.count,fullPageSize:Ur.count===void 0&&Gn?Dr.records.length:void 0,currentPage:Di,nextPage:Di+1,pagingCookie:Dr.pagingCookie,nextLink:Dr.nextLink,moreRecords:Gn,isRetrieveAllInProgress:sr&&Gn,retrieveAll:sr}),d(!1),sr&&Gn&&await Ut(Pt)}catch(Dr){if(Pt!==B.current)return;console.error("Failed to execute FetchXML:",Dr),z(zn(Dr,"An unexpected error occurred while executing the query.")),u({query:Le,rows:[]}),d(!1)}},Pe=A.useRef(je);A.useLayoutEffect(()=>{Pe.current=je});const fe=A.useMemo(()=>wre(t.fetchQuery,t.columnFilterId),[t.fetchQuery,t.columnFilterId]),[ye,Ne]=A.useState(0);A.useEffect(()=>{ye>0&&Pe.current()},[ye]);const{addColumnFilter:Ue,removeColumnFilter:vt,clearColumnFilters:ze}=t,gt=A.useCallback(_e=>{Ue(_e),Ne(Le=>Le+1)},[Ue]),bt=A.useCallback(_e=>{_e.length!==0&&(_e.length===fe.length?ze():_e.forEach(Le=>vt(Le)),Ne(Le=>Le+1))},[fe.length,ze,vt]),at=async _e=>{const{result:Le,state:Qe}=await Zae(_e,Ye=>Ye.mode==="view"?NZ(Ye.nextLink??""):v5(fQ(Ye.xml,Ye.nextPage,Ye.pagingCookie,Ye.pageSize)),{onShrink:Ye=>Ie("app",`Page too large: retrying page ${Ye.nextPage} with count ${Ye.pageSize}`)});return{result:Le,next:zY(Qe,Le)}},Bt=(_e,Le,Qe,Ye)=>{if(_e!==B.current)return!1;u(Pt=>Pt&&{...Pt,rows:Pt.rows.concat(Qe.records),moreRecords:Ye.moreRecords,pagingCookie:Ye.pagingCookie});const Lt=Le.mode==="fetchxml"&&!Le.pagingCookie?{kind:"simple",message:ise}:null;return M(Pt=>Pt&&Pt.kind!=="error"&&Pt.kind!=="stopped"?Pt:Lt),!0},Ut=async _e=>{const Le=++k.current,Qe=()=>_e===B.current&&Le===k.current;let Ye=F.current;if(!Ye)return;Ye={...Ye,isRetrieveAllInProgress:!0,retrieveAll:!0},m(!0),U(Ye);const Lt=Bh();try{for(;Ye?.moreRecords;){const{result:Pt,next:br}=await at(Ye);if(!Qe())return;Bt(_e,Ye,Pt,br),Ye={...br,isRetrieveAllInProgress:br.moreRecords},U(Ye)}Ie("app","✅ Retrieve All complete")}catch(Pt){if(!Qe())return;console.error("Failed during Retrieve All:",Pt),M({kind:"error",page:Ye?.nextPage,message:zn(Pt)})}finally{Lt(),Qe()&&(m(!1),F.current&&U({...F.current,isRetrieveAllInProgress:!1}))}},or=()=>{const _e=F.current;_e?.isRetrieveAllInProgress&&(k.current++,m(!1),U({..._e,isRetrieveAllInProgress:!1,retrieveAll:!1}),M({kind:"stopped",message:""}))},Tr=async()=>{const _e=F.current;if(!_e||!_e.moreRecords||_e.isRetrieveAllInProgress||f)return;const Le=B.current,Qe=++k.current,Ye=()=>Le===B.current&&Qe===k.current;m(!0);try{const{result:Lt,next:Pt}=await at(_e);if(!Ye())return;Bt(Le,_e,Lt,Pt),U(Pt),Ie("app",`✅ Page ${Pt.currentPage} loaded: ${Lt.records.length} records`)}catch(Lt){if(!Ye())return;console.error("Failed to load more records:",Lt),M({kind:"error",page:_e.nextPage,message:zn(Lt)})}finally{Ye()&&m(!1)}},Sr=()=>{M(null);const _e=F.current;_e&&(_e.retrieveAll?Ut(B.current):Tr())},_r=async()=>{if(!_.hasPrivilege){S(_e=>({..._e,error:"You don't have permission to export to Excel. Contact your administrator to request the 'Export to Excel' privilege."}));return}if(!t.loadedView){S(_e=>({..._e,error:"Export to Excel requires a saved view. Please save your query as a view first."}));return}if(!ct||!Rt){S(_e=>({..._e,error:"Export to Excel requires FetchXML and LayoutXML"}));return}S(_e=>({..._e,isExporting:!0,error:void 0}));try{Ie("app",`📤 Exporting to Excel via ${t.loadedView.type} view "${t.loadedView.name}"...`);const _e=t.loadedView.name,Le=await tJ(t.loadedView.id,t.loadedView.type,ct,Rt,_e);await rJ(Le.excelFile,Le.filename),Ie("app",`✅ Export complete: ${Le.filename}`),S(Qe=>({...Qe,isExporting:!1}))}catch(_e){console.error("Export to Excel failed:",_e),S(Le=>({...Le,isExporting:!1,error:zn(_e,"Export to Excel failed. Please try again.")}))}},xt=async()=>{if(!a||!a.rows.length){S(_e=>({..._e,error:"No data to export. Execute a query first."}));return}S(_e=>({..._e,isExporting:!0,error:void 0}));try{Ie("app",`📤 Exporting ${a.rows.length} records locally...`);const _e=new Map,Le=(br,dr)=>p?.get(br)?.get(dr),Qe=y7(o1(t.fetchQuery,a.rows,Le,a.query),t.columnConfig).map(br=>br.key);for(const br of Qe){let dr=br;if(p&&Ve){const sr=p.get(Ve);if(sr){const Ur=sr.get(br);if(Ur?.DisplayName?.UserLocalizedLabel?.Label&&(dr=Ur.DisplayName.UserLocalizedLabel.Label),br.startsWith("_")&&br.endsWith("_value")){const Pn=br.slice(1,-6),Dr=sr.get(Pn);Dr?.DisplayName?.UserLocalizedLabel?.Label&&(dr=Dr.DisplayName.UserLocalizedLabel.Label)}}}_e.set(br,dr)}const Ye=t.loadedView?.name||Ct?.DisplayName?.UserLocalizedLabel?.Label||Ve||"export",{buffer:Lt,fileName:Pt}=await Xae({records:a.rows,columns:Qe,columnDisplayNames:_e,attributeMetadata:p,entityName:Ve,fileName:Ye,displaySettings:Re});await Gae(Lt,Pt),Ie("app",`✅ Local export complete: ${Pt}`),S(br=>({...br,isExporting:!1}))}catch(_e){console.error("Local export failed:",_e),S(Le=>({...Le,isExporting:!1,error:_e instanceof Error?_e.message:"Local export failed. Please try again."}))}};A.useEffect(()=>{if(_.error){const _e=setTimeout(()=>{S(Le=>({...Le,error:void 0}))},1e4);return()=>clearTimeout(_e)}},[_.error]);const qt=A.useCallback(_e=>{me(_e)},[]),ce=A.useCallback(()=>he,[he]),we=A.useCallback(async _e=>{if(_e.length===0||!Ve)return;const Le=await Ah();if(!Le){console.error("Failed to get environment URL");return}for(const Qe of _e){const Ye=y5(Ve,Qe,Le);await j8(Ye)}},[Ve]),qe=A.useCallback(async _e=>{if(_e.length===0||!Ve)return;const Le=await Ah();if(!Le){console.error("Failed to get environment URL");return}const Qe=_e.map(Lt=>y5(Ve,Lt,Le)),Ye=Qe.join(`
|
|
109
|
+
`);await ws(Ye)?Ie("app",`📋 Copied ${Qe.length} record URL(s) to clipboard`):console.error("Failed to copy to clipboard")},[Ve]),Xe=A.useCallback(_e=>{if(!Ve)return;if(_e.length===0){if(!H.canBulkDelete){Ie("app","Bulk delete privilege required to delete all records from view");return}const Ye=a?.rows.length||0;ne({open:!0,recordIds:[],isAllRecords:!0,totalViewRecords:Ye});return}if(_e.length>100&&H.canBulkDelete){ne({open:!0,recordIds:_e,isAllRecords:!1});return}const Le=_e.length===1?a?.rows.find(Ye=>Ye[Ct?.PrimaryIdAttribute||""]===_e[0])?.[Ct?.PrimaryNameAttribute||""]:void 0,Qe=_e.length>=4;q({open:!0,recordIds:_e,recordName:Le,isBatchDelete:Qe})},[Ve,H.canBulkDelete,a,Ct]),kt=A.useCallback(_e=>{if(!Ve||!H.canBulkDelete)return;const Le=_e.length===0,Qe=a?.rows.length||0;ne({open:!0,recordIds:_e,isAllRecords:Le,totalViewRecords:Le?Qe:void 0})},[Ve,H.canBulkDelete,a]),ot=A.useCallback(async()=>{if(!Ve||L.recordIds.length===0)return;const _e=L.recordIds;re(null);const Le=Bh();try{if(L.isBatchDelete){const Lt=await dJ(Ve,_e,Pt=>re(Pt));return Lt.succeeded>0&&(Ie("app",`✅ Batch deleted ${Lt.succeeded} of ${_e.length} records`),Pe.current()),Lt}let Qe=0;const Ye=[];for(const Lt of _e)try{await nJ(Ve,Lt),Qe++}catch(Pt){Ye.push(`Failed to delete ${Lt}: ${zn(Pt)}`)}if(Qe>0&&(Ie("app",`✅ Deleted ${Qe} of ${_e.length} records`),Pe.current()),Ye.length>0)return console.error("Delete errors:",Ye),{succeeded:Qe,failed:Ye.length,errors:Ye}}finally{Le()}},[Ve,L.recordIds,L.isBatchDelete]),ft=A.useCallback(async _e=>{if(!Ve||!Ct)throw new Error("Missing entity information for bulk delete");if(ie.isAllRecords){if(!t.fetchQuery)throw new Error("No FetchXML query available");const Lt=ya(t.fetchQuery),Pt=await fJ(Lt,_e);return Ie("app",`📤 Bulk delete job (all records) submitted: ${Pt.asyncOperationId}`),Pt}if(ie.recordIds.length===0)throw new Error("No records selected for bulk delete");const Le=ie.recordIds,Qe=Ct.PrimaryIdAttribute,Ye=await iJ(Ve,Qe,Le,_e);return Ie("app",`📤 Bulk delete job submitted: ${Ye.asyncOperationId}`),Ye},[Ve,Ct,ie.recordIds,ie.isAllRecords,t.fetchQuery]),hr=A.useCallback((_e,Le)=>{Le.length!==0&&be({open:!0,recordIds:Le,preSelectedWorkflow:_e})},[]),ar=A.useCallback(async()=>Ve?sJ(Ve):[],[Ve]),er=A.useCallback(async(_e,Le,Qe)=>Ve?Qx(()=>cJ(_e,Le,Ve,Qe)):{succeeded:0,failed:Le.length,errors:["Entity not selected"]},[Ve]),Ht=A.useCallback((_e,Le)=>{!Ve||Le.length===0||te({open:!0,action:_e,recordIds:Le})},[Ve]),pr=A.useCallback(_e=>Ht("activate",_e),[Ht]),Br=A.useCallback(_e=>Ht("deactivate",_e),[Ht]),jr=A.useCallback(async(_e,Le)=>{if(!Ve)throw new Error("Entity not selected");const Qe=await Qx(()=>gJ(Ve,pe.recordIds,_e,Le));return Qe.succeeded>0&&(Ie("app",`✅ State changed on ${Qe.succeeded} of ${pe.recordIds.length} records`),Pe.current()),Qe},[Ve,pe.recordIds]),$r=fr?"The query has a one-to-many or many-to-many link-entity, so rows repeat. Remove it to activate or deactivate records.":void 0;return j.jsxs("div",{className:r.root,"data-app-root":!0,children:[j.jsxs("div",{className:r.leftPane,"data-left-pane":!0,style:{width:`${Ze}px`},children:[j.jsxs("div",{className:r.leftPaneTop,style:{height:`${Ee}%`},children:[j.jsx(Bie,{selectedEntity:t.fetchQuery?.entity.name||null,onEntityChange:t.setEntity,onNewQuery:t.newQuery,entityScopeMode:Re.entityScopeMode,advancedFindOnly:Re.advancedFindOnly,collapsed:Re.scopeCollapsed,onCollapsedChange:_e=>He({...Re,scopeCollapsed:_e}),onViewLoad:_e=>{const Le=t.loadView(_e.originalFetchXml,{id:_e.id,type:_e.type,entitySetName:_e.entitySetName,name:_e.name,queryType:_e.queryType,isCustomizable:_e.isCustomizable,description:_e.description,isDefault:_e.isDefault,isManaged:_e.isManaged,solutionId:_e.solutionId,ownerId:_e.ownerId,ownerName:_e.ownerName},_e.layoutxml);O("");const Qe=HQ(_e.name,Le);Qe&&(Le.success||console.error("Failed to parse view FetchXML:",Le.errors),window.toolboxAPI?.utils?.showNotification?.(Qe))}}),t.fetchQuery?j.jsx(eae,{fetchQuery:t.fetchQuery,selectedNodeId:t.selectedNodeId,onNodeSelect:t.selectNode,onAddAttribute:t.addAttribute,onAddAllAttributes:t.addAllAttributes,onAddOrder:t.addOrder,onAddFilter:t.addFilter,onAddSubfilter:t.addSubfilter,onAddCondition:t.addCondition,onAddLinkEntity:t.addLinkEntity,onRemoveNode:t.removeNode,onUpdateAttributes:t.updateAttributes}):j.jsx("div",{className:r.placeholder,children:"Select an entity to begin"})]}),j.jsx("div",{className:r.horizontalResizeHandle,onMouseDown:()=>Ke(!0),title:"Drag to resize",children:j.jsxs("span",{className:r.horizontalGrip,children:[j.jsx("span",{children:"•"}),j.jsx("span",{children:"•"}),j.jsx("span",{children:"•"})]})})," ",j.jsxs("div",{className:r.leftPaneBottom,style:{height:`${100-Ee}%`},children:[j.jsx("div",{className:r.toolbar,children:j.jsx("span",{style:{fontWeight:600},children:"Properties"})}),j.jsx("div",{className:r.propertiesContent,children:j.jsx(Sae,{selectedNode:t.selectedNode,fetchQuery:t.fetchQuery,onNodeUpdate:t.updateNode})})]})]}),j.jsx("div",{className:r.verticalResizeHandle,onMouseDown:()=>nt(!0),title:"Drag to resize",children:j.jsxs("span",{className:r.verticalGrip,children:[j.jsx("span",{children:"•"}),j.jsx("span",{children:"•"}),j.jsx("span",{children:"•"})]})})," ",j.jsx("div",{className:r.rightPane,children:j.jsx(bie,{xml:ct,layoutXml:Rt,result:a,isExecuting:h,isLoadingMore:f,onExecute:je,onExport:_r,onExportLocal:xt,canExport:!!t.loadedView&&_.hasPrivilege,isExporting:_.isExporting,exportError:_.error,onDismissExportError:()=>S(_e=>({..._e,error:void 0})),executeError:T,onDismissExecuteError:()=>z(void 0),exportDisabledReason:t.loadedView?_.hasPrivilege?void 0:"You don't have the prvExportToExcel privilege":"Save as a view first to enable export",onParseToTree:t.loadFetchXml,isCallee:i.isCallee,attributeMetadata:p,fetchQuery:t.fetchQuery,primaryIdAttribute:Ct?.PrimaryIdAttribute,columnConfig:t.columnConfig,onColumnResize:t.updateColumnWidth,onLoadMore:Tr,pagingNotice:E,isRetrieveAllInProgress:V?.isRetrieveAllInProgress??!1,onStopRetrieveAll:or,onRetryPaging:Sr,onDismissPagingNotice:()=>M(null),entityDisplayName:Ct?.DisplayName?.UserLocalizedLabel?.Label||Ct?.LogicalName,lookupRelationships:w,oneToManyRelationships:N,isLoadingRelationships:$,onLoadRelatedAttributes:n,quickFindTestValue:Ot>0?j.jsx(ese,{value:P,onValueChange:O,addPercent:X,onAddPercentChange:K,searchValue:Ft,disabled:h}):void 0,executeDisabledReason:Ot>0&&!Ft?"Enter a quick find value to execute this query.":void 0,saveViewButton:j.jsx(Oie,{fetchXml:ct,layoutXml:Rt,entityLogicalName:t.fetchQuery?.entity?.name||"",entityDisplayName:Ct?.DisplayName?.UserLocalizedLabel?.Label,objectTypeCode:Ct?.ObjectTypeCode||0,primaryIdAttribute:Ct?.PrimaryIdAttribute||"",loadedView:t.loadedView,onSaveComplete:ur,disabled:!ct||!Ct}),sendToToolButton:b_()&&c.length>0?j.jsx(qie,{fetchXml:ct,entityLogicalName:t.fetchQuery?.entity?.name||"",tools:c,disabled:!ct||!t.fetchQuery?.entity?.name}):void 0,onReorderColumns:_e=>{t.columnConfig&&t.setColumnConfig({...t.columnConfig,columns:_e})},onRemoveColumns:_e=>{if(!t.fetchQuery)return;bre(t.fetchQuery,_e).removeNodeIds.forEach(Qe=>t.removeNode(Qe))},onAddColumn:_e=>{t.fetchQuery?.entity.id&&t.addAttributeByName(t.fetchQuery.entity.id,_e)},onAddRelatedColumns:_e=>{if(!t.fetchQuery?.entity.id)return;const Le=new Map;for(const Qe of _e){const Ye=vi(Qe.relationship);Le.has(Ye)||Le.set(Ye,[]),Le.get(Ye).push(Qe)}for(const[,Qe]of Le){const Ye=Qe[0].relationship,Lt=Qe[0].relationshipType;let Pt,br,dr,sr,Ur;Lt==="N1"?(Pt=Ye.ReferencedAttribute,br=Ye.ReferencingAttribute,dr=Ye.ReferencedEntity,sr="outer",Ur="N1"):(Pt=Ye.ReferencingAttribute,br=Ye.ReferencedAttribute,dr=Ye.ReferencingEntity,sr="outer",Ur="1N");const Pn=t.fetchQuery.entity.links.find(It=>It.from===Pt&&It.to===br&&It.name===dr&&!cl.has(It.linkType));let Dr;Pn?Dr=Pn.id:Dr=t.addLinkEntityWithConfig(t.fetchQuery.entity.id,dr,Pt,br,sr,Ur);for(const It of Qe)t.addAttributeByName(Dr,It.attribute.LogicalName)}},columnFilters:fe,onAddColumnFilter:gt,onRemoveColumnFilters:bt,onSortChange:_e=>{if(!t.fetchQuery)return;const Le=vd(t.fetchQuery,_e.columnId),Qe=Le?p?.get(Le.container.name)?.get(Le.attribute.name):void 0,Ye=vre(t.fetchQuery,_e.columnId,Qe?I8(Qe):void 0);if("reason"in Ye){window.toolboxAPI?.utils?.showNotification?.({title:"Can't sort by this column",body:Ye.reason,type:"warning"});return}t.setSort(Ye,_e.direction==="descending",_e.isMultiSort)},onOpenRecord:we,onCopyRecordUrl:qe,onDeleteRecords:Xe,onBulkDeleteRecords:kt,onActivateRecords:pr,onDeactivateRecords:Br,activateDisabledReason:se.activate??$r,deactivateDisabledReason:se.deactivate??$r,onRunSpecificWorkflow:hr,canDelete:H.canDelete,canBulkDelete:H.canBulkDelete,canRunWorkflow:H.canRunWorkflow,onFetchWorkflows:ar,isAggregateQuery:vr,hasOneToManyRelationship:fr,recordActionsDisabledReason:gr,onSelectionChange:qt,getSelectedRecordIds:ce,onOpenSettings:()=>Be(!0),displaySettings:Re})}),j.jsx(Pae,{open:L.open,recordName:L.recordName,entityDisplayName:Ct?.DisplayName?.UserLocalizedLabel?.Label||Ve||"record",entityLogicalName:Ve,recordCount:L.recordIds.length,onClose:()=>{q({open:!1,recordIds:[]}),re(null)},onConfirm:ot,onProgress:Y??void 0}),j.jsx(Fae,{open:ie.open,recordCount:ie.recordIds.length,entityDisplayName:Ct?.DisplayName?.UserLocalizedLabel?.Label||Ve||"records",entityLogicalName:Ve,isAllRecords:ie.isAllRecords,totalViewRecords:ie.totalViewRecords,moreRecords:a?.moreRecords,onClose:()=>ne({open:!1,recordIds:[]}),onConfirm:ft}),j.jsx(Lae,{open:ae.open,recordCount:ae.recordIds.length,entityDisplayName:Ct?.DisplayName?.UserLocalizedLabel?.Label||Ve||"records",entityLogicalName:Ve,preSelectedWorkflow:ae.preSelectedWorkflow,onClose:()=>be({open:!1,recordIds:[]}),onFetchWorkflows:ar,onExecute:(_e,Le)=>er(_e.workflowid,ae.recordIds,Le)}),j.jsx(Hae,{open:pe.open,action:pe.action,recordIds:pe.recordIds,entityLogicalName:Ve,entityDisplayName:Ct?.DisplayName?.UserLocalizedLabel?.Label,primaryIdAttribute:Ct?.PrimaryIdAttribute,onClose:()=>te(_e=>({..._e,open:!1})),onExecute:jr}),j.jsx(rse,{open:xe,settings:Re,accessSummary:Te,onClose:()=>Be(!1),onSettingsChange:He})]})}self.MonacoEnvironment={getWorker(e,r){throw new Error(`FXS runs Monaco's "${r}" worker on the main thread.`)}};Zv.config({monaco:dC});xC.createRoot(document.getElementById("root")).render(j.jsx(A.StrictMode,{children:j.jsx(sse,{})}));
|